Yesterday I was repoted by a friend who likes to copy/paste his documents from MS Word (*.docx format), that the formatting is breaking.
When I looked into this, I found that Word produces quotation marks "" for each font-family, but the javascript only strips the marks on the beginning and end of the font-family list, resulting in a tag like this:
[font=Times New Roman","serif]
[font=Times New Roman","serif]
[font=Times New Roman","serif]
It's because of this quotation marks the whole formatting is breaking.
It is in this file: {ROOT}\themes\default\scripts\jquery.sceditor.bbcode.min.js
that you can correct it.
replace this:[/font]
[/font]"[font=" + c.replace(/"/g, "") + "]" + b + "[/font]"
[font]
[font=Times New Roman","serif]
with this:[/font]
[/font]"[font=" + this.stripQuotes(c) + "]" + b + "[/font]"
[font]
[font=Times New Roman","serif]
This works as it should.
Word.docX unfortunatly also produces a lot of extra bbcode on empty lines.
I tried to find a solution for it.
I came up with this:
[/font]
[/font]font: {
tags: {
font: {
face: null
}
},
styles: {
"font-family": null
},
quoteType: a.sceditor.BBCodeParser.QuoteType.never,
format: function(a, b) {
var c;
if(b === null){
return;
}else{
return "font" === a[0].nodeName.toLowerCase() && (c = a.attr("face")) || (c = a.css("font-family")),
"[font=" + c.replace(/"/g, "") + "]" + b + "[/font]";
}
},
html: '<font face="{defaultattr}">{0}</font>'
},
[font]
[font=Times New Roman","serif]
Though it works, you first need to save the whole post and open it again. Than the extra bbcode tags will be removed.
If you have a better idea to remove extra empty bbcode right away, please let me/us know.
I'm talking about the extra code like this:[/font]
[/font][font=Times New Roman,serif]Here is a text line[/font]
[font=Times New Roman,serif] [/font]
[font=Times New Roman,serif] [/font]
[font=Times New Roman,serif]Here comes my next line [/font]
P.S. I attached an unminified version with my changes
Kind regards,
Esteffano