Can't insert formated text into editor

  • Thread starter Thread starter ragtek
  • Start date Start date
R

ragtek

Guest
I'm saving an text from the editor into a own table with:

PHP:
$input['message'] = $this->getHelper('Editor')->getMessageText('message', $this->_input);
        $input['message'] = XenForo_Helper_String::autoLinkBbCode($input['message']);

Saved text is:
Code:
first line
second
third
smiley:)

As next i format it and send it with json to the client
PHP:
  public function renderJson(){
        $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Text', array('view' => $this)));
        $output = $this->_params['template'];

        $output['content'] = new XenForo_BbCode_TextWrapper($output['content'], $bbCodeParser);
      $return = array(
          'text'  =>  $output
      );

      return XenForo_ViewRenderer_Json::jsonEncodeForOutput($return);

then i insert it via javascript

Code:
                            if (ed.isIE)
                            {
                                ed.execCommand("mceInsertContent", false, $text);
                            }
                            else
                            {
                                ed.execCommand("insertHtml", false, $text);
                            }

ajax response is:
Code:
{"text":{"tempalte_id":4,"user_id":1,"title":"3 lines test","content":"first\nsecond\nthird\nsmiley:)"}}

It's working fine BUT i'm getting everything in an line instead 4
 
Top Bottom