From ecf9776f905d3ced3fff7c5288646b03258d3f73 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 23 May 2013 12:31:49 +0900 Subject: [PATCH] add a hack to prevent double newlines when deleting formatting prior to this change, if you entered an empty field, turned on bold, typed some text, and then backspaced over the text, it would expand to two lines and the formatting would not go away --- aqt/editor.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/aqt/editor.py b/aqt/editor.py index fcefddec7..f4be40a03 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -95,6 +95,13 @@ function onKeyUp(elem) { if (!elem.lastChild || elem.lastChild.nodeName.toLowerCase() != "br") { elem.appendChild(document.createElement("br")); } + var old = elem.innerHTML; + var new_ = old.replace(/<([biu])>
<\\/\\1>/g, ""); + if (old != new_) { + elem.innerHTML = new_; + // this may have caused the cursor to disappear + caretToEnd(); + } } function sendState() {