Skip to content

Commit

Permalink
Merge pull request #1264 from SystemChanger/enh-improve-selection-ux
Browse files Browse the repository at this point in the history
enh: improve selection experience
  • Loading branch information
JiHong88 authored Jul 19, 2023
2 parents 4772550 + efa6d25 commit e669387
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dist/suneditor.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1643,6 +1643,10 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
_w.setTimeout(function () {
if (typeof plugin.select === 'function') this.callPlugin(pluginName, plugin.select.bind(this, element), null);
this._setComponentLineBreaker(element);

const compContext = context[pluginName];
const container = compContext._container;
core.setRange(container, 0, container, 0);
}.bind(this));
},

Expand Down Expand Up @@ -4517,6 +4521,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
break;
case 'selectAll':
this.containerOff();
this.controllersOff();
const wysiwyg = context.element.wysiwyg;
let first = util.getChildElement(wysiwyg.firstChild, function (current) { return current.childNodes.length === 0 || current.nodeType === 3; }, false) || wysiwyg.firstChild;
let last = util.getChildElement(wysiwyg.lastChild, function (current) { return current.childNodes.length === 0 || current.nodeType === 3; }, true) || wysiwyg.lastChild;
Expand Down Expand Up @@ -6812,6 +6817,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
},

onInput_wysiwyg: function (e) {
if (!document.body.contains(core.currentControllerTarget)) core.controllersOff();

if (core.isReadOnly || core.isDisabled) {
e.preventDefault();
e.stopPropagation();
Expand Down

0 comments on commit e669387

Please sign in to comment.