@leafer-in/editor 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/editor.cjs +19 -11
- package/dist/editor.cjs.map +1 -1
- package/dist/editor.esm.js +19 -11
- package/dist/editor.esm.js.map +1 -1
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.esm.min.js.map +1 -1
- package/dist/editor.js +19 -11
- package/dist/editor.js.map +1 -1
- package/dist/editor.min.cjs +1 -1
- package/dist/editor.min.cjs.map +1 -1
- package/dist/editor.min.js +1 -1
- package/dist/editor.min.js.map +1 -1
- package/package.json +5 -5
- package/src/decorator/data.ts +20 -4
- package/src/editor/target.ts +2 -11
package/dist/editor.cjs
CHANGED
|
@@ -90,9 +90,24 @@ function targetAttr(fn) {
|
|
|
90
90
|
set(value) {
|
|
91
91
|
const old = this[privateKey];
|
|
92
92
|
if (old !== value) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
if (this.config) {
|
|
94
|
+
const isSelect = key === 'target';
|
|
95
|
+
if (isSelect) {
|
|
96
|
+
if (value instanceof Array && value.length > 1 && value[0].locked)
|
|
97
|
+
value.splice(0, 1);
|
|
98
|
+
const { beforeSelect } = this.config;
|
|
99
|
+
if (beforeSelect) {
|
|
100
|
+
const check = beforeSelect({ target: value });
|
|
101
|
+
if (typeof check === 'object')
|
|
102
|
+
value = check;
|
|
103
|
+
else if (check === false)
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const type = isSelect ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER;
|
|
108
|
+
if (this.hasEvent(type))
|
|
109
|
+
this.emitEvent(new EditorEvent(type, { editor: this, value: value, oldValue: old }));
|
|
110
|
+
}
|
|
96
111
|
this[privateKey] = value, fn(this, old);
|
|
97
112
|
}
|
|
98
113
|
}
|
|
@@ -1127,11 +1142,7 @@ function simulate(editor) {
|
|
|
1127
1142
|
function onTarget(editor, oldValue) {
|
|
1128
1143
|
const { target } = editor;
|
|
1129
1144
|
if (target) {
|
|
1130
|
-
|
|
1131
|
-
if (!list.every(checkEditable)) {
|
|
1132
|
-
editor.target = list.filter(checkEditable);
|
|
1133
|
-
return;
|
|
1134
|
-
}
|
|
1145
|
+
editor.leafList = target instanceof draw.LeafList ? target : new draw.LeafList(target);
|
|
1135
1146
|
if (editor.multiple)
|
|
1136
1147
|
simulate(editor);
|
|
1137
1148
|
}
|
|
@@ -1158,9 +1169,6 @@ function onTarget(editor, oldValue) {
|
|
|
1158
1169
|
function onHover(editor, oldValue) {
|
|
1159
1170
|
editor.emitEvent(new EditorEvent(EditorEvent.HOVER, { editor, value: editor.hoverTarget, oldValue }));
|
|
1160
1171
|
}
|
|
1161
|
-
function checkEditable(item) {
|
|
1162
|
-
return item.editable && !item.locked;
|
|
1163
|
-
}
|
|
1164
1172
|
|
|
1165
1173
|
const order = (a, b) => a.parent.children.indexOf(a) - b.parent.children.indexOf(b);
|
|
1166
1174
|
const reverseOrder = (a, b) => b.parent.children.indexOf(b) - a.parent.children.indexOf(a);
|