【问题标题】:bbcode tags formatting incorrectly in tinymce 4tinymce 4中的bbcode标签格式不正确
【发布时间】:2014-09-12 16:34:32
【问题描述】:

我正在尝试使用 tinymce 4.1.5 正确格式化 bbcode 标记的顺序。

当我设置文本颜色并为其添加下划线时,结束标签会混淆或将 text-decoration="underline" 属性放在颜色标签中。

例如,我得到了

[color="ff0000" text-decoration="underline"]some text[/color]

应该是什么时候

[color="ff0000"][u]some text[/u][/color]

或者我可能会得到 [color="ff0000"][u]一些文字[/color][u]

这是我的文本区域

  @using (Html.BeginForm("TestTinyMce", "Content", FormMethod.Post))
{
@Html.TextArea("TextArea", Model.TextArea, new { @id = "TextArea", @class = "tinymce"   })
<input type="submit" value="submit"/>
}

这里是初始化:

    tinymce.init({
    selector: "textarea",
    theme: "modern",
    plugins: [
        "bbcode,paste,textcolor"
    ],
    toolbar1: "undo redo |  bold italic underline forecolor |  link unlink  "
});

当它提交后到达控制器时,我正在检查该值。我正在尝试查看是否有任何配置、插件或技巧可以用来清理此 bbcode。

【问题讨论】:

    标签: javascript asp.net-mvc tinymce bbcode tinymce-4


    【解决方案1】:

    我最终用 tinymce 覆盖了格式,所以它打破了跨度。这样我就不会把下划线和颜色混在一起。

    为了处理标签关闭不匹配,我使用了 SaveContent 事件并清理了标签。

    tinymce.init({
        selector: "textarea.tinymce",
        theme: "modern",
        width: "100%",
        height: "250px",
        plugins: [
            "bbcode paste textcolor link"
        ],
        toolbar1: "undo redo  bold italic underline forecolor   link unlink  ",
        formats: {
            bold: { inline: 'strong', exact: true },
            italic: { inline: 'em', exact: true },
            underline: { inline: 'span', styles: { "text-decoration": "underline" }, exact: true },
            forecolor: { inline: 'span', styles: { color: '%value' }, exact: true }
        },
        // New event
        setup: function (editor) {
            editor.on('init', function (args) {
            });
            editor.on('SaveContent', function (e) {
                e.content = FixTags(e.content);
            });
    
        },
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-15
      • 2012-12-14
      • 1970-01-01
      相关资源
      最近更新 更多