Cursor improvements in pad, code and slide

This commit is contained in:
yflory
2018-12-17 11:44:08 +01:00
parent d76c21fcf5
commit a11a883cff
5 changed files with 37 additions and 8 deletions

View File

@@ -136,6 +136,15 @@ define([
end: cursorObj.selectionEnd
}, ops);
var cursorEl = makeCursor(id, cursorObj);
['start', 'end'].forEach(function (t) {
// Prevent the cursor from creating a new line at the beginning
if (r[t].el.nodeName.toUpperCase() === 'BODY') {
if (!r[t].el.childNodes.length) { r[t] = null; return; }
r[t].el = r[t].el.childNodes[0];
r[t].offset = 0;
}
});
if (!r.start || !r.end) { return; }
if (r.start.el === r.end.el && r.start.offset === r.end.offset) {
// Cursor
addCursorAtRange(cursorEl, r, cursorObj, '');