简体   繁体   English

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

[英]bbcode tags formatting incorrectly in tinymce 4

I'm trying to get the order of bbcode tags to format correctly with tinymce 4.1.5. 我试图获取bbcode标签的顺序,以便使用tinymce 4.1.5正确格式化。

When I set the text color and underline it, the closing tags get mixed up or it puts the text-decoration="underline" attribute in the color tag. 当我设置文本颜色并在其下划线时,结束标签会混在一起,或者将text-decoration =“ underline”属性放入颜色标签。

For instance, I get 例如,我得到

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

When it should be 什么时候应该

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

Or I may get [color="ff0000"][u]some text[/color][u] 否则我可能会得到[color =“ ff0000”] [u]一些文本[/ color] [u]

Here is my text area 这是我的文字区域

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

Here is the initialization: 这是初始化:

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

I'm checking the value when it reaches the controller after it's submitted. 我正在检查提交后到达控制器的值。 I'm trying to see if there is any configurations, plugins, or tricks I can use to cleanup this bbcode. 我试图查看是否有任何配置,插件或技巧可以用来清理此bbcode。

I ended up overriding the formatting with tinymce so it breaks up the spans. 我最终用tinymce覆盖了格式,因此它破坏了跨度。 This way I don't get underline mixed in with color. 这样,我就不会将下划线混入颜色中。

To handle the tag closing mismatch, I used the SaveContent event and just cleaned up the tags. 为了处理标签关闭不匹配的问题,我使用了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