【问题标题】:TinyMCE BBCode removes trailing extra line/spaceTinyMCE BBCode 删除尾随多余的行/空格
【发布时间】:2016-07-29 08:07:15
【问题描述】:

我在我的项目中使用 TinyMCE 4.x 版本,BBCode 作为源。下面是它的 TinyMCE 初始化代码,

            tinymce.init({
                mode: "textareas",
                editor_selector: "mceEditor",
                resize: "both",
                forced_root_block: false,
                remove_redundant_brs : false,
                verify_html : false,
                force_br_newlines: true,
                force_p_newlines: false,
                remove_redundant_brs : false,
                remove_linebreaks : false,
                valid_elements: 'br',
                plugins: ["autolink link image anchor bbcode code noneditable"],
                toolbar: "bold italic link | code | bbcode",              
        });

如果我在内容末尾添加换行符或额外的行/空格并尝试从 javascript(tinyMCE.activeEditor.getElement().val()) 获取内容,则获得的内容为修剪形式。当我们从 TinyMCE 获取内容时,是否有停止修剪内容的正确修剪?

我尝试了不同的选项:Linebreaks in TinyMCE editor show extra line on preview, not in codetinymce remove text spaces and line breaks 链接,但选项对我不起作用。

有谁知道我需要做出哪些改变来克服这个问题?

【问题讨论】:

    标签: tinymce tinymce-4 bbcode tinymce-plugins


    【解决方案1】:

    我有类似的问题。 用 hakish 解决方案解决了它(在任何地方都没有 tinyMCE 文档)在 tinymce.init({... 为我解决问题

    中添加以下设置
    indent_before: 'h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,' +
                        'tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist',
                    indent_after: 'h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,' +
                        'tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist',
                    whitespace_elements: 'p pre script noscript style textarea video audio iframe object code',
    

    indent_before, indent_after - 我从该列表中删除了 p 元素,并保留了我在 tinymce.js 源文件中找到的所有默认值。 这停止在每个 p 之前和之后放置空间。 whitespace_elements - 我将 p 元素添加到该列表中,并保留了我在 tinymce.js 源文件中找到的所有默认值。这停止在 P 元素的开头删除训练空间

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-15
      相关资源
      最近更新 更多