繁体   English   中英

bbcode标签在tinymce 4中的格式不正确

[英]bbcode tags formatting incorrectly in tinymce 4

我试图获取bbcode标签的顺序,以便使用tinymce 4.1.5正确格式化。

当我设置文本颜色并在其下划线时,结束标签会混在一起,或者将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。

我最终用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);
        });

    },
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM