I'm trying to get the order of bbcode tags to format correctly with 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.
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]
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.
I ended up overriding the formatting with tinymce so it breaks up the spans. 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.
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);
});
},
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.