TinyMCE粘贴问题

问题描述 投票:0回答:1

我在配置编辑器时遇到麻烦,我正在尝试删除中断。当我从其他应用程序(单词,写字板...)粘贴文本时。它产生<p>&nbsp;</p>哪里有休息,但每个段落之间的间隔太大(因为我认为p元素的默认边距)所以我尝试不使用[]

paste_create_paragraphs: false,
paste_create_linebreaks: false,

但是它仍然会生成<p>标签。然后,我尝试使用paste_postprocess强制删除<p>&nbsp;</p> 但没有任何作用

这是我的完整TinyMCE初始化

tinymce.init({
    selector: 'textarea',
    height: 200,
    theme: 'modern',
    plugins: 'print preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists textcolor wordcount imagetools contextmenu colorpicker textpattern help',
    toolbar1: 'formatselect | bold underline italic strikethrough | backcolor | alignleft aligncenter alignright alignjustify | table ',
    toolbar2: 'numlist bullist | outdent indent | removeformat | subscript superscript | link unlink',
    fontsize_formats: '7px 8px 9px 10px 11px 12px 13px 14px 15px 16px 17px 18px 19px 20px 21px 22px 23px 24px 25px 26px 27px 28px 29px 30px',
    image_advtab: true,
    block_formats: 'Paragraph=p;Header 1=h1;Header 2=h2;Header 3=h3;Header 4=h4;Header 5=h5;Header 6=h6;',
    image_class_list: [
      { title: 'Immagine Responsive', value: 'img-responsive img-fluid' },
      //{ title: 'Lightbox', value: 'lightbox' },
    ],
    theme_advanced_resize_horizontal: false,
    paste_create_paragraphs: false,
    paste_create_linebreaks: false,
    paste_auto_cleanup_on_paste: true,
    paste_postprocess: function (pl, o) {
        // remove &nbsp
        o.node.innerHTML = o.node.innerHTML.replace(/&nbsp;/ig, "");
        // just a try
        o.node.innerHTML = o.node.innerHTML.replace("<p>&nbsp;</p>", "");
      }
});

我在配置编辑器时遇到麻烦,我正在尝试删除中断。当我从其他应用程序(单词,写字板...)粘贴文本时。它会在出现中断的地方生成

,但是...
tinymce
1个回答
0
投票

已解决在paste块中添加plugins

© www.soinside.com 2019 - 2024. All rights reserved.