vectorsize / substance-text

Substance Text
substance.github.com/text
MIT License
281 stars 26 forks source link

The font-element is obsolete. #11

Closed heyLu closed 12 years ago

heyLu commented 12 years ago

According to the HTML 5 spec the font element is obsolete.

I think using <pre> would be appropriate...

timjb commented 12 years ago

I agree. But ... to get the editor to work we have to rely on the contenteditable attribute for cross-browser rich-text editing. The problem with this API is that it's only specified from a high perspective in HTML5 and lacks important features. For example, there is no possibility to wrap the current selection with an arbitrary inline element. We have to do everything with the API call document.execCommand(cmd, ...) where cmd is one of several strings including 'bold', 'italic' and 'fontName'. These commands work on all modern browsers (and even in Internet Explorer), handle all cases (e.g. selecting text across multiple paragraphs) nicely and push their changes onto the browser's undo/redo stack. Maybe it's possible to use <code> instead of <font> but this would require messing with the DOM, which leads to bugs, cross-browser incompatibilities and makes the code harder to maintain. I'd rather like to use the correct elements, too, but currently the best solution is to rely on the contenteditable API.