@leafer-editor/worker 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.js CHANGED
@@ -6074,7 +6074,7 @@ var LeaferUI = (function (exports) {
6074
6074
  }
6075
6075
  }
6076
6076
 
6077
- const version = "1.5.2";
6077
+ const version = "1.5.3";
6078
6078
 
6079
6079
  class LeaferCanvas extends LeaferCanvasBase {
6080
6080
  get allowBackgroundColor() { return true; }
@@ -11709,9 +11709,24 @@ var LeaferUI = (function (exports) {
11709
11709
  set(value) {
11710
11710
  const old = this[privateKey];
11711
11711
  if (old !== value) {
11712
- const type = key === 'target' ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER;
11713
- if (this.hasEvent(type))
11714
- this.emitEvent(new EditorEvent(type, { editor: this, value: value, oldValue: old }));
11712
+ if (this.config) {
11713
+ const isSelect = key === 'target';
11714
+ if (isSelect) {
11715
+ if (value instanceof Array && value.length > 1 && value[0].locked)
11716
+ value.splice(0, 1);
11717
+ const { beforeSelect } = this.config;
11718
+ if (beforeSelect) {
11719
+ const check = beforeSelect({ target: value });
11720
+ if (typeof check === 'object')
11721
+ value = check;
11722
+ else if (check === false)
11723
+ return;
11724
+ }
11725
+ }
11726
+ const type = isSelect ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER;
11727
+ if (this.hasEvent(type))
11728
+ this.emitEvent(new EditorEvent(type, { editor: this, value: value, oldValue: old }));
11729
+ }
11715
11730
  this[privateKey] = value, fn(this, old);
11716
11731
  }
11717
11732
  }
@@ -12746,11 +12761,7 @@ ${filterStyle}
12746
12761
  function onTarget(editor, oldValue) {
12747
12762
  const { target } = editor;
12748
12763
  if (target) {
12749
- const { list } = editor.leafList = target instanceof LeafList ? target : new LeafList(target instanceof Array ? target : target);
12750
- if (!list.every(checkEditable)) {
12751
- editor.target = list.filter(checkEditable);
12752
- return;
12753
- }
12764
+ editor.leafList = target instanceof LeafList ? target : new LeafList(target);
12754
12765
  if (editor.multiple)
12755
12766
  simulate(editor);
12756
12767
  }
@@ -12777,9 +12788,6 @@ ${filterStyle}
12777
12788
  function onHover(editor, oldValue) {
12778
12789
  editor.emitEvent(new EditorEvent(EditorEvent.HOVER, { editor, value: editor.hoverTarget, oldValue }));
12779
12790
  }
12780
- function checkEditable(item) {
12781
- return item.editable && !item.locked;
12782
- }
12783
12791
 
12784
12792
  const order = (a, b) => a.parent.children.indexOf(a) - b.parent.children.indexOf(b);
12785
12793
  const reverseOrder = (a, b) => b.parent.children.indexOf(b) - a.parent.children.indexOf(a);