2017-12-01 1 views
0

내 웹 사이트에 tinymce를 설정하여 사용자가 텍스트를 작성하는 동안 툴바를 사용할 수 있고 사진을 업로드 할 수 있습니다. 불행히도 나는 tinymce와 관련된 문제를 깨달았습니다.Tinymce가 제출 된 텍스트를 저장하지 않습니다.

$(document).ready(function() { 
tinymce.init({ 
selector: "#market-product_info, #market-delivery_info, #market-facility_info", 
language_url: '/frontend/web/js/tinymce/langs/zh_CN.js', 
menubar:true, 
statusbar: true, 
relative_urls : false, 
branding: false, 
plugins: [ 
      "advlist autolink lists link image charmap print preview hr anchor pagebreak", 
      "searchreplace wordcount visualblocks visualchars code fullscreen", 
      "save table contextmenu directionality emoticons template paste textcolor", 
      "emoticons template paste textcolor colorpicker textpattern", 
      "save" 
], 
    toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | forecolor |styleselect | link unlink anchor |link image | preview code ", 
    image_advtab: true, 
    // enable title field in the Image dialog 


image_title: true, 
    // enable automatic uploads of images represented by blob or data URIs 
    automatic_uploads: true, 
    // URL of our upload handler (for more details check: https://www.tinymce.com/docs/configure/file-image-upload/#images_upload_url) 
    // images_upload_url: 'postAcceptor.php', 
    // here we add custom filepicker only to Image dialog 
    file_picker_types: 'image', 
    // and here's our custom image picker 
    file_picker_callback: function(cb, value, meta) { 
    var input = document.createElement('input'); 
    input.setAttribute('type', 'file'); 
    input.setAttribute('accept', 'image/*'); 

    // Note: In modern browsers input[type="file"] is functional without 
    // even adding it to the DOM, but that might not be the case in some older 
    // or quirky browsers like IE, so you might want to add it to the DOM 
    // just in case, and visually hide it. And do not forget do remove it 
    // once you do not need it anymore. 

    input.onchange = function() { 
     var file = this.files[0]; 

     var reader = new FileReader(); 
     reader.onload = function() { 
     // Note: Now we need to register the blob in TinyMCEs image blob 
     // registry. In the next release this part hopefully won't be 
     // necessary, as we are looking to handle it internally. 
     var id = 'blobid' + (new Date()).getTime(); 
     var blobCache = tinymce.activeEditor.editorUpload.blobCache; 
     var base64 = reader.result.split(',')[1]; 
     var blobInfo = blobCache.create(id, file, base64); 
     blobCache.add(blobInfo); 

     // call the callback and populate the Title field with the file name 
     cb(blobInfo.blobUri(), { title: file.name }); 
     }; 
     reader.readAsDataURL(file); 
    }; 
    input.click(); 
    } 
    }); 
});     

사용자 그러나 만약, 테이블을 생성 또는 툴바 옵션 (볼드체, 이탤릭체 텍스트 색상 또는 기타)를 사용하여 정보를 삽입 한 사용자로서 수신하여 데이터베이스에 제출하면 문제는 사용자가 정보를 편집하고 다시 제출하려는 경우 텍스트 영역에 모든 단어가 표나 툴바 기능없이 표시됩니다. 나는 그/그녀가 텍스트를 편집하고 싶은 경우 이전에 제출 된 것처럼 사용자가 자신의 텍스트를 찾는 방식으로 가지고 싶습니다.

tinyMCE.init({ 
    // input tinyMCE options 
    ... 
}); 
: TinyMCE를 init을 다음

$('#description').html('<table><tr><th>user info table</th></tr></table>'); 

:

<textarea style="width: 100%;" name="description" id="description"></textarea> 

다음 텍스트 영역의 내용을 설정

답변

0

는 텍스트 영역을 만들려고 되세요
관련 문제