@tmagic/editor 1.8.0-beta.28 → 1.8.0-beta.29

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.
@@ -48,9 +48,10 @@ var ScrollBar_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
48
48
  return props.scrollSize * ratio;
49
49
  };
50
50
  const scrollBy = (delta) => {
51
- if (delta < 0) if (props.pos <= 0) emit("scroll", 0);
52
- else emit("scroll", -Math.min(-delta, props.pos));
53
- else {
51
+ if (delta < 0) {
52
+ if (props.pos <= 0) emit("scroll", 0);
53
+ else emit("scroll", -Math.min(-delta, props.pos));
54
+ } else {
54
55
  const leftPos = props.size - (thumbSize.value + thumbPos.value);
55
56
  if (leftPos <= 0) emit("scroll", 0);
56
57
  else emit("scroll", Math.min(delta, leftPos));
@@ -20,7 +20,7 @@ var FieldSelect_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
20
20
  notEditable: { type: [Boolean, Function] },
21
21
  dataSourceId: {}
22
22
  }, {
23
- "modelValue": { default: [] },
23
+ "modelValue": { default: () => [] },
24
24
  "modelModifiers": {}
25
25
  }),
26
26
  emits: /*@__PURE__*/ mergeModels(["change"], ["update:modelValue"]),
@@ -42,8 +42,10 @@ var DataSourceMethods_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*
42
42
  let editIndex = -1;
43
43
  const editMethod = (method, index) => {
44
44
  let codeContent = "({ params, dataSource, app }) => {\n // place your code here\n}";
45
- if (method.content) if (typeof method.content !== "string") codeContent = method.content.toString();
46
- else codeContent = method.content;
45
+ if (method.content) {
46
+ if (typeof method.content !== "string") codeContent = method.content.toString();
47
+ else codeContent = method.content;
48
+ }
47
49
  codeConfig.value = {
48
50
  ...cloneDeep(method),
49
51
  content: codeContent
@@ -23,8 +23,10 @@ var useCodeBlockEdit = (codeBlockService) => {
23
23
  return;
24
24
  }
25
25
  let codeContent = "";
26
- if (codeBlock.content) if (typeof codeBlock.content !== "string") codeContent = codeBlock.content.toString();
27
- else codeContent = codeBlock.content;
26
+ if (codeBlock.content) {
27
+ if (typeof codeBlock.content !== "string") codeContent = codeBlock.content.toString();
28
+ else codeContent = codeBlock.content;
29
+ }
28
30
  codeConfig.value = {
29
31
  ...cloneDeep(codeBlock),
30
32
  content: codeContent
@@ -93,9 +93,10 @@ var CodeEditor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
93
93
  };
94
94
  const toString = (v, language) => {
95
95
  let value;
96
- if (typeof v !== "string") if (language === "json") value = JSON.stringify(v, null, 2);
97
- else value = serializeConfig(v);
98
- else value = v;
96
+ if (typeof v !== "string") {
97
+ if (language === "json") value = JSON.stringify(v, null, 2);
98
+ else value = serializeConfig(v);
99
+ } else value = v;
99
100
  if (language === "javascript" && value.startsWith("{") && value.endsWith("}")) value = `(${value})`;
100
101
  return value;
101
102
  };
@@ -68,13 +68,14 @@ var PropsPanel_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
68
68
  const historySource = eventData ? "props" : "code";
69
69
  const replace = historySource === "code";
70
70
  let newValue;
71
- if (replace) if (source === "style") newValue = {
72
- ...values.value,
73
- id: v.id || values.value.id,
74
- style: { ...v.style || {} }
75
- };
76
- else newValue = { ...v };
77
- else {
71
+ if (replace) {
72
+ if (source === "style") newValue = {
73
+ ...values.value,
74
+ id: v.id || values.value.id,
75
+ style: { ...v.style || {} }
76
+ };
77
+ else newValue = { ...v };
78
+ } else {
78
79
  newValue = {
79
80
  ...v,
80
81
  style: {}
@@ -109,16 +109,17 @@ var useDrag = ({ editorService }, options = {}) => {
109
109
  let targetParent = targetInfo.parent;
110
110
  if (!targetParent || !targetNode) return;
111
111
  let targetIndex = -1;
112
- if (Array.isArray(targetNode.items) && dragState.dropType === "inner") if (dragState.redirectedTargetId !== void 0) {
113
- const redirectedNode = editorService.getNodeInfo(dragState.redirectedTargetId, false).node;
114
- if (!redirectedNode || !Array.isArray(redirectedNode.items)) return;
115
- targetParent = redirectedNode;
116
- targetIndex = redirectedNode.items.length;
117
- } else {
118
- targetIndex = targetNode.items.length;
119
- targetParent = targetNode;
120
- }
121
- else targetIndex = getNodeIndex(dragState.dragOverNodeId, targetParent);
112
+ if (Array.isArray(targetNode.items) && dragState.dropType === "inner") {
113
+ if (dragState.redirectedTargetId !== void 0) {
114
+ const redirectedNode = editorService.getNodeInfo(dragState.redirectedTargetId, false).node;
115
+ if (!redirectedNode || !Array.isArray(redirectedNode.items)) return;
116
+ targetParent = redirectedNode;
117
+ targetIndex = redirectedNode.items.length;
118
+ } else {
119
+ targetIndex = targetNode.items.length;
120
+ targetParent = targetNode;
121
+ }
122
+ } else targetIndex = getNodeIndex(dragState.dragOverNodeId, targetParent);
122
123
  if (dragState.dropType === "after") targetIndex += 1;
123
124
  const selectedNodes = editorService.get("nodes");
124
125
  if (selectedNodes.find((n) => `${n.id}` === `${node.id}`)) editorService.dragTo(selectedNodes, targetParent, targetIndex);
@@ -151,11 +151,44 @@ var Stage_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComp
151
151
  height: contentRect.height
152
152
  });
153
153
  });
154
+ const parseDSL = getEditorConfig("parseDSL");
155
+ /**
156
+ * 本次拖拽是否由编辑器文档内部发起
157
+ *
158
+ * drop 的 text/json 里可能带函数(组件配置的事件、钩子等),还原只能交给 parseDSL,
159
+ * 而 parseDSL 的默认实现是 eval;HTML 拖放又允许其他源的页面在 DataTransfer 中投递
160
+ * 自定义 MIME 数据,跨源页面只要诱导用户拖拽一次,就能让 eval 执行任意脚本。
161
+ *
162
+ * 跨源页面既不会在本文档触发 dragstart,也无法往本文档创建的 DataTransfer 中写数据,
163
+ * 因此只有起源于本文档的拖拽才交给 parseDSL 还原。
164
+ * 同源拖拽源写入的 text/json 由业务保证可信。
165
+ */
166
+ let isInternalDrag = false;
167
+ let internalDragSession = 0;
168
+ let clearInternalDragTimer;
169
+ const documentDragStartHandler = () => {
170
+ internalDragSession += 1;
171
+ isInternalDrag = true;
172
+ if (clearInternalDragTimer !== void 0) {
173
+ globalThis.clearTimeout(clearInternalDragTimer);
174
+ clearInternalDragTimer = void 0;
175
+ }
176
+ };
177
+ const documentDragEndHandler = () => {
178
+ const session = internalDragSession;
179
+ if (clearInternalDragTimer !== void 0) globalThis.clearTimeout(clearInternalDragTimer);
180
+ clearInternalDragTimer = globalThis.setTimeout(() => {
181
+ clearInternalDragTimer = void 0;
182
+ if (session === internalDragSession) isInternalDrag = false;
183
+ }, 0);
184
+ };
154
185
  onMounted(() => {
155
186
  if (stageWrapRef.value?.container) {
156
187
  resizeObserver.observe(stageWrapRef.value.container);
157
188
  keybindingService.registerEl(KeyBindingContainerKey.STAGE, stageWrapRef.value.container);
158
189
  }
190
+ globalThis.document.addEventListener("dragstart", documentDragStartHandler, true);
191
+ globalThis.document.addEventListener("dragend", documentDragEndHandler, true);
159
192
  });
160
193
  onBeforeUnmount(() => {
161
194
  stage?.destroy();
@@ -163,8 +196,13 @@ var Stage_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComp
163
196
  resizeObserver.disconnect();
164
197
  editorService.set("stage", null);
165
198
  keybindingService.unregisterEl("stage");
199
+ if (clearInternalDragTimer !== void 0) {
200
+ globalThis.clearTimeout(clearInternalDragTimer);
201
+ clearInternalDragTimer = void 0;
202
+ }
203
+ globalThis.document.removeEventListener("dragstart", documentDragStartHandler, true);
204
+ globalThis.document.removeEventListener("dragend", documentDragEndHandler, true);
166
205
  });
167
- const parseDSL = getEditorConfig("parseDSL");
168
206
  const contextmenuHandler = (e) => {
169
207
  e.preventDefault();
170
208
  menuRef.value?.show(e);
@@ -175,11 +213,19 @@ var Stage_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComp
175
213
  e.dataTransfer.dropEffect = "move";
176
214
  };
177
215
  const dropHandler = async (e) => {
216
+ const allowed = isInternalDrag;
217
+ isInternalDrag = false;
178
218
  if (!e.dataTransfer) return;
179
219
  const data = e.dataTransfer.getData("text/json");
180
- if (!data) return;
181
- const config = parseDSL(`(${data})`);
182
- if (!config || config.dragType !== DragType.COMPONENT_LIST) return;
220
+ if (!data || !allowed) return;
221
+ let config;
222
+ try {
223
+ config = parseDSL(`(${data})`);
224
+ } catch {
225
+ return;
226
+ }
227
+ if (!config || config.dragType !== DragType.COMPONENT_LIST || !config.data) return;
228
+ const dragData = config.data;
183
229
  e.preventDefault();
184
230
  const doc = stage?.renderer?.contentWindow?.document;
185
231
  const parentEl = doc?.querySelector(`.${props.stageOptions?.containerHighlightClassName}`);
@@ -201,7 +247,7 @@ var Stage_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComp
201
247
  const layout = await editorService.getLayout(parent);
202
248
  const containerRect = stageContainerEl.value.getBoundingClientRect();
203
249
  const { scrollTop, scrollLeft } = stage.mask;
204
- const { style = {} } = config.data;
250
+ const { style = {} } = dragData;
205
251
  let top = 0;
206
252
  let left = 0;
207
253
  let position = "relative";
@@ -219,14 +265,14 @@ var Stage_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComp
219
265
  top = top - parentTop * zoom.value;
220
266
  }
221
267
  }
222
- config.data.style = {
268
+ dragData.style = {
223
269
  ...style,
224
270
  position,
225
271
  top: calcValueByFontsize(doc, top / zoom.value),
226
272
  left: calcValueByFontsize(doc, left / zoom.value)
227
273
  };
228
- config.data.inputEvent = e;
229
- editorService.add(config.data, parent, { historySource: "component-panel" });
274
+ dragData.inputEvent = e;
275
+ editorService.add(dragData, parent, { historySource: "component-panel" });
230
276
  }
231
277
  };
232
278
  return (_ctx, _cache) => {
@@ -455,13 +455,15 @@ var Editor = class extends BaseService {
455
455
  }
456
456
  await Promise.all(nodes.map((node) => this.doRemove(node, options)));
457
457
  this.removeInvalidNodesBySubtree(nodes);
458
- if (removedItems.length > 0 && pageForOp) if (!doNotPushHistory) this.pushOpHistory("remove", {
459
- diff: removedItems,
460
- pageData: pageForOp,
461
- historyDescription,
462
- source: historySource
463
- });
464
- else this.selectionBeforeOp = null;
458
+ if (removedItems.length > 0 && pageForOp) {
459
+ if (!doNotPushHistory) this.pushOpHistory("remove", {
460
+ diff: removedItems,
461
+ pageData: pageForOp,
462
+ historyDescription,
463
+ source: historySource
464
+ });
465
+ else this.selectionBeforeOp = null;
466
+ }
465
467
  this.emit("remove", nodes);
466
468
  this.emit("change", {
467
469
  type: "remove",
@@ -541,22 +543,24 @@ var Editor = class extends BaseService {
541
543
  }));
542
544
  this.applyInvalidInfo(config, invalidInfo);
543
545
  if (updateData[0].oldNode?.type !== NodeType.ROOT) {
544
- if (this.get("nodes").length) if (!doNotPushHistory) {
545
- const pageForOp = this.getNodeInfo(nodes[0].id, false).page;
546
- this.pushOpHistory("update", {
547
- diff: buildUpdateDiff(updateData.map((d) => ({
548
- oldNode: cloneDeep$1(d.oldNode),
549
- newNode: cloneDeep$1(d.newNode),
550
- changeRecords: d.changeRecords?.length ? cloneDeep$1(d.changeRecords) : void 0
551
- }))),
552
- pageData: {
553
- name: pageForOp?.name || "",
554
- id: pageForOp.id
555
- },
556
- historyDescription,
557
- source: historySource
558
- });
559
- } else this.selectionBeforeOp = null;
546
+ if (this.get("nodes").length) {
547
+ if (!doNotPushHistory) {
548
+ const pageForOp = this.getNodeInfo(nodes[0].id, false).page;
549
+ this.pushOpHistory("update", {
550
+ diff: buildUpdateDiff(updateData.map((d) => ({
551
+ oldNode: cloneDeep$1(d.oldNode),
552
+ newNode: cloneDeep$1(d.newNode),
553
+ changeRecords: d.changeRecords?.length ? cloneDeep$1(d.changeRecords) : void 0
554
+ }))),
555
+ pageData: {
556
+ name: pageForOp?.name || "",
557
+ id: pageForOp.id
558
+ },
559
+ historyDescription,
560
+ source: historySource
561
+ });
562
+ } else this.selectionBeforeOp = null;
563
+ }
560
564
  }
561
565
  this.emit("update", updateData);
562
566
  this.emit("change", {
@@ -684,8 +688,10 @@ var Editor = class extends BaseService {
684
688
  historyDescription,
685
689
  historySource
686
690
  });
687
- if (!doNotSelect) if (newNodes.length > 1) await stage?.multiSelect(newNodes.map((node) => node.id));
688
- else await stage?.select(newNodes[0].id);
691
+ if (!doNotSelect) {
692
+ if (newNodes.length > 1) await stage?.multiSelect(newNodes.map((node) => node.id));
693
+ else await stage?.select(newNodes[0].id);
694
+ }
689
695
  return newNode;
690
696
  }
691
697
  /**
package/dist/es/style.css CHANGED
@@ -1395,7 +1395,7 @@ fieldset.m-fieldset .m-form-tip {
1395
1395
  left: 40px;
1396
1396
  width: calc(100% - 40px);
1397
1397
  text-align: center;
1398
- background-color: rgba(252.5, 245.7, 235.5, 0.9);
1398
+ background-color: rgba(99.0196078431%, 96.3529411765%, 92.3529411765%, 0.9);
1399
1399
  color: #e6a23c;
1400
1400
  padding: 5px 0;
1401
1401
  font-size: 12px;
@@ -83,8 +83,10 @@ var removeConflictPosition = (style, primary, secondary) => {
83
83
  const secondaryInvalid = isInvalid(secondaryValue);
84
84
  if (primaryInvalid && !secondaryInvalid) delete style[primary];
85
85
  else if (secondaryInvalid && !primaryInvalid) delete style[secondary];
86
- else if (primaryInvalid && secondaryInvalid) if (secondaryValue === 0 && primaryValue !== 0) delete style[primary];
87
- else delete style[secondary];
86
+ else if (primaryInvalid && secondaryInvalid) {
87
+ if (secondaryValue === 0 && primaryValue !== 0) delete style[primary];
88
+ else delete style[secondary];
89
+ }
88
90
  };
89
91
  var getInitPositionStyle = (style = {}, layout) => {
90
92
  if (layout === Layout.ABSOLUTE) {
package/dist/style.css CHANGED
@@ -1395,7 +1395,7 @@ fieldset.m-fieldset .m-form-tip {
1395
1395
  left: 40px;
1396
1396
  width: calc(100% - 40px);
1397
1397
  text-align: center;
1398
- background-color: rgba(252.5, 245.7, 235.5, 0.9);
1398
+ background-color: rgba(99.0196078431%, 96.3529411765%, 92.3529411765%, 0.9);
1399
1399
  color: #e6a23c;
1400
1400
  padding: 5px 0;
1401
1401
  font-size: 12px;
@@ -1481,7 +1481,7 @@ fieldset.m-fieldset .m-form-tip {
1481
1481
  left: 40px;
1482
1482
  width: calc(100% - 40px);
1483
1483
  text-align: center;
1484
- background-color: rgba(252.5, 245.7, 235.5, 0.9);
1484
+ background-color: rgba(99.0196078431%, 96.3529411765%, 92.3529411765%, 0.9);
1485
1485
  color: #e6a23c;
1486
1486
  padding: 5px 0;
1487
1487
  font-size: 12px;
@@ -79,8 +79,10 @@
79
79
  var unmasked = true;
80
80
  } catch (e) {}
81
81
  var result = nativeObjectToString$1.call(value);
82
- if (unmasked) if (isOwn) value[symToStringTag$1] = tag;
83
- else delete value[symToStringTag$1];
82
+ if (unmasked) {
83
+ if (isOwn) value[symToStringTag$1] = tag;
84
+ else delete value[symToStringTag$1];
85
+ }
84
86
  return result;
85
87
  }
86
88
  //#endregion
@@ -217,7 +219,7 @@
217
219
  //#endregion
218
220
  //#region node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_baseToString.js
219
221
  /** Used as references for various `Number` constants. */
220
- var INFINITY$1 = Infinity;
222
+ var INFINITY$1 = 1 / 0;
221
223
  /** Used to convert symbols to primitives and strings. */
222
224
  var symbolProto$2 = Symbol$1 ? Symbol$1.prototype : void 0;
223
225
  var symbolToString = symbolProto$2 ? symbolProto$2.toString : void 0;
@@ -1815,7 +1817,7 @@
1815
1817
  //#endregion
1816
1818
  //#region node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_toKey.js
1817
1819
  /** Used as references for various `Number` constants. */
1818
- var INFINITY = Infinity;
1820
+ var INFINITY = 1 / 0;
1819
1821
  /**
1820
1822
  * Converts `value` to a string key if it's not a string or symbol.
1821
1823
  *
@@ -1923,9 +1925,10 @@
1923
1925
  result || (result = []);
1924
1926
  while (++index < length) {
1925
1927
  var value = array[index];
1926
- if (depth > 0 && predicate(value)) if (depth > 1) baseFlatten(value, depth - 1, predicate, isStrict, result);
1927
- else arrayPush(result, value);
1928
- else if (!isStrict) result[result.length] = value;
1928
+ if (depth > 0 && predicate(value)) {
1929
+ if (depth > 1) baseFlatten(value, depth - 1, predicate, isStrict, result);
1930
+ else arrayPush(result, value);
1931
+ } else if (!isStrict) result[result.length] = value;
1929
1932
  }
1930
1933
  return result;
1931
1934
  }
@@ -3281,16 +3284,17 @@
3281
3284
  if (isCommon) {
3282
3285
  var isArr = isArray(srcValue), isBuff = !isArr && isBuffer(srcValue), isTyped = !isArr && !isBuff && isTypedArray(srcValue);
3283
3286
  newValue = srcValue;
3284
- if (isArr || isBuff || isTyped) if (isArray(objValue)) newValue = objValue;
3285
- else if (isArrayLikeObject(objValue)) newValue = copyArray(objValue);
3286
- else if (isBuff) {
3287
- isCommon = false;
3288
- newValue = cloneBuffer(srcValue, true);
3289
- } else if (isTyped) {
3290
- isCommon = false;
3291
- newValue = cloneTypedArray(srcValue, true);
3292
- } else newValue = [];
3293
- else if (isPlainObject$1(srcValue) || isArguments(srcValue)) {
3287
+ if (isArr || isBuff || isTyped) {
3288
+ if (isArray(objValue)) newValue = objValue;
3289
+ else if (isArrayLikeObject(objValue)) newValue = copyArray(objValue);
3290
+ else if (isBuff) {
3291
+ isCommon = false;
3292
+ newValue = cloneBuffer(srcValue, true);
3293
+ } else if (isTyped) {
3294
+ isCommon = false;
3295
+ newValue = cloneTypedArray(srcValue, true);
3296
+ } else newValue = [];
3297
+ } else if (isPlainObject$1(srcValue) || isArguments(srcValue)) {
3294
3298
  newValue = objValue;
3295
3299
  if (isArguments(objValue)) newValue = toPlainObject(objValue);
3296
3300
  else if (!isObject(objValue) || isFunction(objValue)) newValue = initCloneObject(srcValue);
@@ -3604,7 +3608,7 @@
3604
3608
  * @param {Array} values The values to add to the set.
3605
3609
  * @returns {Object} Returns the new set.
3606
3610
  */
3607
- var createSet = !(Set$1 && 1 / setToArray(new Set$1([, -0]))[1] == Infinity) ? noop : function(values) {
3611
+ var createSet = !(Set$1 && 1 / setToArray(new Set$1([, -0]))[1] == 1 / 0) ? noop : function(values) {
3608
3612
  return new Set$1(values);
3609
3613
  };
3610
3614
  //#endregion
@@ -5369,8 +5373,10 @@
5369
5373
  const secondaryInvalid = isInvalid(secondaryValue);
5370
5374
  if (primaryInvalid && !secondaryInvalid) delete style[primary];
5371
5375
  else if (secondaryInvalid && !primaryInvalid) delete style[secondary];
5372
- else if (primaryInvalid && secondaryInvalid) if (secondaryValue === 0 && primaryValue !== 0) delete style[primary];
5373
- else delete style[secondary];
5376
+ else if (primaryInvalid && secondaryInvalid) {
5377
+ if (secondaryValue === 0 && primaryValue !== 0) delete style[primary];
5378
+ else delete style[secondary];
5379
+ }
5374
5380
  };
5375
5381
  var getInitPositionStyle = (style = {}, layout) => {
5376
5382
  if (layout === Layout.ABSOLUTE) {
@@ -6209,13 +6215,15 @@
6209
6215
  }
6210
6216
  await Promise.all(nodes.map((node) => this.doRemove(node, options)));
6211
6217
  this.removeInvalidNodesBySubtree(nodes);
6212
- if (removedItems.length > 0 && pageForOp) if (!doNotPushHistory) this.pushOpHistory("remove", {
6213
- diff: removedItems,
6214
- pageData: pageForOp,
6215
- historyDescription,
6216
- source: historySource
6217
- });
6218
- else this.selectionBeforeOp = null;
6218
+ if (removedItems.length > 0 && pageForOp) {
6219
+ if (!doNotPushHistory) this.pushOpHistory("remove", {
6220
+ diff: removedItems,
6221
+ pageData: pageForOp,
6222
+ historyDescription,
6223
+ source: historySource
6224
+ });
6225
+ else this.selectionBeforeOp = null;
6226
+ }
6219
6227
  this.emit("remove", nodes);
6220
6228
  this.emit("change", {
6221
6229
  type: "remove",
@@ -6295,22 +6303,24 @@
6295
6303
  }));
6296
6304
  this.applyInvalidInfo(config, invalidInfo);
6297
6305
  if (updateData[0].oldNode?.type !== _tmagic_core.NodeType.ROOT) {
6298
- if (this.get("nodes").length) if (!doNotPushHistory) {
6299
- const pageForOp = this.getNodeInfo(nodes[0].id, false).page;
6300
- this.pushOpHistory("update", {
6301
- diff: buildUpdateDiff(updateData.map((d) => ({
6302
- oldNode: cloneDeep(d.oldNode),
6303
- newNode: cloneDeep(d.newNode),
6304
- changeRecords: d.changeRecords?.length ? cloneDeep(d.changeRecords) : void 0
6305
- }))),
6306
- pageData: {
6307
- name: pageForOp?.name || "",
6308
- id: pageForOp.id
6309
- },
6310
- historyDescription,
6311
- source: historySource
6312
- });
6313
- } else this.selectionBeforeOp = null;
6306
+ if (this.get("nodes").length) {
6307
+ if (!doNotPushHistory) {
6308
+ const pageForOp = this.getNodeInfo(nodes[0].id, false).page;
6309
+ this.pushOpHistory("update", {
6310
+ diff: buildUpdateDiff(updateData.map((d) => ({
6311
+ oldNode: cloneDeep(d.oldNode),
6312
+ newNode: cloneDeep(d.newNode),
6313
+ changeRecords: d.changeRecords?.length ? cloneDeep(d.changeRecords) : void 0
6314
+ }))),
6315
+ pageData: {
6316
+ name: pageForOp?.name || "",
6317
+ id: pageForOp.id
6318
+ },
6319
+ historyDescription,
6320
+ source: historySource
6321
+ });
6322
+ } else this.selectionBeforeOp = null;
6323
+ }
6314
6324
  }
6315
6325
  this.emit("update", updateData);
6316
6326
  this.emit("change", {
@@ -6438,8 +6448,10 @@
6438
6448
  historyDescription,
6439
6449
  historySource
6440
6450
  });
6441
- if (!doNotSelect) if (newNodes.length > 1) await stage?.multiSelect(newNodes.map((node) => node.id));
6442
- else await stage?.select(newNodes[0].id);
6451
+ if (!doNotSelect) {
6452
+ if (newNodes.length > 1) await stage?.multiSelect(newNodes.map((node) => node.id));
6453
+ else await stage?.select(newNodes[0].id);
6454
+ }
6443
6455
  return newNode;
6444
6456
  }
6445
6457
  /**