From afa1104d850e1bab3c931737b8361d54881bda1a Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 29 Mar 2016 15:36:03 +0200 Subject: [PATCH] Pull the cursor out of bogus BR tarpits when it gets stuck --- www/common/cursor.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/www/common/cursor.js b/www/common/cursor.js index 069f896c7..8eff84374 100644 --- a/www/common/cursor.js +++ b/www/common/cursor.js @@ -373,6 +373,26 @@ define([ }; }; + cursor.brFix = function () { + cursor.update(); + var start = Range.start; + var end = Range.end; + if (!start.el) { return; } + + if (start.el === end.el && start.offset === end.offset) { + if (start.el.tagName === 'BR') { + // get the parent element, which ought to be a P. + var P = start.el.parentNode; + + [cursor.fixStart, cursor.fixEnd].forEach(function (f) { + f(P, 0); + }); + + cursor.fixSelection(cursor.makeSelection(), cursor.makeRange()); + } + } + }; + return cursor; }; });