1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Can't insert formated text into editor

Discussion in 'XenForo Development Discussions' started by ragtek, May 12, 2011.

  1. ragtek

    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
     
  2. ragtek

    ragtek Guest

    ok got it:)
     

Share This Page