I made my own WYSIWYG text-editor.
The contenteditable-field is a div, see code below:
<div spellcheck="false" id="textEditorField" contenteditable="true"></div>
The button-events look like this:
boldButton.onclick = function() {
document.execCommand('bold', false, null);
return false;
}
The texteditor is working fine. It italics and un-italics the text, underlining works. But with bold there is a problem: it bolds the text, but doesn't unbold it. This is in every browser on both OS X and Windows.
I'm using a custom font which is imported using @font-face
.
In the css I do the following:
b {
font-family: "Caviar Dreams Bold";
font-weight: normal;
}
b i, i b {
font-family: "Caviar Dreams Bold Italic";
font-weight: normal;
}
If I remove the font-weight
property the text gets the font-family "Caviar Dreams Bold" AND it is made bold via CSS, so extra bold.
There are some similar questions, but without an answer I can use. I also have to note that I can't use jQuery for this.