Open mrlaunch opened 5 years ago
Came to see if there was a fix for this, as that's rather important that you can't 'toggle' header(int) size 'off' after adding it to text, where as bold/italic can be toggle on/off with the same button.
"undo" does work to remove that, but only if that was the last edit done to the string... other wise you'd have to remove/redo that sentance/word/etc.
Other issue with this that I've just noticed. If you say have "Title" and tag it is H1 (for example), as you can't remove that, or maybe undo is just too far back. Let's say you manually remove that "title", and then re-add it as bold text instead. The "h1" tag is still there.. and if any text is backspaced into it... it gets formatted by that H1 "trap".
Kind of a big deal.
You can check ZSSRichTextEditor's implementation.
In "RichEditorView.swift" replace header function with
public func header(_ h: Int) { runJS("RE.setHeading('h\(h)');") }
In "rich_editor.js" replace RE.setHeading with
var current_selection = $(RE.getSelectedNode()); var t = current_selection.prop("tagName").toLowerCase(); var is_heading = (t == 'h1' || t == 'h2' || t == 'h3' || t == 'h4' || t == 'h5' || t == 'h6'); if (is_heading && heading == t) { var c = current_selection.html(); current_selection.replaceWith(c); } else { document.execCommand('formatBlock', false, '<'+heading+'>'); }
In rich_editor.html, insert
<script type="text/javascript" src="jQuery.js"></script>
in between "<head /head>"
Finally, copy the jQuery.js file from ZSSRichTextEditor to RichEditorView and put under "Resources"
I think this should do the trick... Note that you may need to use the legacy build system if your changes were not registered properly. I found that the js part for ZSS is written a little better, but the swift part of this library is structured very well.
Is there any way to make
<h1></h1>
back to plain text?