@tmagic/editor 1.8.0-beta.15 → 1.8.0-beta.17
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/es/Editor.vue_vue_type_script_setup_true_lang.js +2 -0
- package/dist/es/editorProps.js +1 -0
- package/dist/es/fields/EventSelect.vue_vue_type_script_setup_true_lang.js +41 -40
- package/dist/es/hooks/use-stage.js +1 -0
- package/dist/es/index.js +2 -2
- package/dist/es/initService.js +18 -12
- package/dist/es/layouts/props-panel/FormPanel.vue_vue_type_script_setup_true_lang.js +11 -8
- package/dist/es/layouts/sidebar/ComponentListPanel.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/services/dep.js +87 -22
- package/dist/es/style.css +28 -13
- package/dist/es/utils/dep/idle-task.js +3 -0
- package/dist/es/utils/props.js +1 -45
- package/dist/es/utils/type-match-rules.js +1 -1
- package/dist/style.css +28 -13
- package/dist/themes/magic-admin.css +34 -13
- package/dist/tmagic-editor.umd.cjs +174 -108
- package/package.json +7 -7
- package/src/Editor.vue +1 -0
- package/src/editorProps.ts +6 -0
- package/src/fields/EventSelect.vue +8 -3
- package/src/hooks/use-stage.ts +1 -0
- package/src/initService.ts +25 -15
- package/src/layouts/props-panel/FormPanel.vue +12 -8
- package/src/layouts/sidebar/ComponentListPanel.vue +1 -1
- package/src/services/dep.ts +140 -24
- package/src/theme/code-block.scss +2 -2
- package/src/theme/event.scss +11 -7
- package/src/type.ts +5 -0
- package/src/utils/dep/idle-task.ts +6 -0
- package/src/utils/props.ts +1 -98
- package/src/utils/type-match-rules.ts +1 -1
- package/types/index.d.ts +27 -67
|
@@ -5182,7 +5182,7 @@
|
|
|
5182
5182
|
}));
|
|
5183
5183
|
//#endregion
|
|
5184
5184
|
//#region packages/editor/src/utils/props.ts
|
|
5185
|
-
var arrayOptions, eqOptions, numberOptions, booleanOptions, getCondOpOptionsByFieldType, styleTabConfig, eventTabConfig, advancedTabConfig, displayTabConfig, fillConfig, removeStyleDisplayConfig
|
|
5185
|
+
var arrayOptions, eqOptions, numberOptions, booleanOptions, getCondOpOptionsByFieldType, styleTabConfig, eventTabConfig, advancedTabConfig, displayTabConfig, fillConfig, removeStyleDisplayConfig;
|
|
5186
5186
|
var init_props = __esmMin((() => {
|
|
5187
5187
|
arrayOptions = [{
|
|
5188
5188
|
text: "包含",
|
|
@@ -5479,21 +5479,6 @@
|
|
|
5479
5479
|
})
|
|
5480
5480
|
};
|
|
5481
5481
|
});
|
|
5482
|
-
validatePropsForm = ({ config, values, appContext = null, services, stage, extendState, debug, typeMatchValid }) => (0, _tmagic_form.validateForm)({
|
|
5483
|
-
config,
|
|
5484
|
-
debug,
|
|
5485
|
-
typeMatchValid,
|
|
5486
|
-
initValues: values,
|
|
5487
|
-
appContext: appContext ? {
|
|
5488
|
-
...appContext,
|
|
5489
|
-
provides: { services }
|
|
5490
|
-
} : null,
|
|
5491
|
-
extendState: async (state) => ({
|
|
5492
|
-
...await extendState?.(state) || {},
|
|
5493
|
-
stage,
|
|
5494
|
-
services
|
|
5495
|
-
})
|
|
5496
|
-
});
|
|
5497
5482
|
}));
|
|
5498
5483
|
//#endregion
|
|
5499
5484
|
//#region packages/editor/src/hooks/use-compare-form.ts
|
|
@@ -8991,6 +8976,7 @@
|
|
|
8991
8976
|
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
8992
8977
|
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
8993
8978
|
containerHighlightType: stageOptions.containerHighlightType,
|
|
8979
|
+
containerHighlightAddOnly: stageOptions.containerHighlightAddOnly,
|
|
8994
8980
|
disabledDragStart: stageOptions.disabledDragStart,
|
|
8995
8981
|
renderType: stageOptions.renderType,
|
|
8996
8982
|
canSelect: (el, event, stop) => {
|
|
@@ -9670,6 +9656,9 @@
|
|
|
9670
9656
|
});
|
|
9671
9657
|
}, 1);
|
|
9672
9658
|
};
|
|
9659
|
+
globalThis.cancelIdleCallback = globalThis.cancelIdleCallback || function(handle) {
|
|
9660
|
+
clearTimeout(handle);
|
|
9661
|
+
};
|
|
9673
9662
|
var IdleTask = class extends events.EventEmitter {
|
|
9674
9663
|
taskList = [];
|
|
9675
9664
|
hightLevelTaskList = [];
|
|
@@ -10807,7 +10796,7 @@
|
|
|
10807
10796
|
}
|
|
10808
10797
|
return String(value);
|
|
10809
10798
|
};
|
|
10810
|
-
var MAX_SUGGESTION_OPTIONS =
|
|
10799
|
+
var MAX_SUGGESTION_OPTIONS = 20;
|
|
10811
10800
|
/**
|
|
10812
10801
|
* 生成「请使用以下某一个值:xxx;xxx」形式的参考建议;无可选值时返回空字符串(不追加建议)。
|
|
10813
10802
|
*/
|
|
@@ -12759,7 +12748,7 @@
|
|
|
12759
12748
|
class: "m-editor-history-list-item-saved",
|
|
12760
12749
|
title: "该记录为最近一次保存的状态"
|
|
12761
12750
|
};
|
|
12762
|
-
var _hoisted_5$
|
|
12751
|
+
var _hoisted_5$4 = {
|
|
12763
12752
|
key: 1,
|
|
12764
12753
|
class: "m-editor-history-list-item-actions"
|
|
12765
12754
|
};
|
|
@@ -12921,7 +12910,7 @@
|
|
|
12921
12910
|
(0, vue.createElementVNode)("span", { class: (0, vue.normalizeClass)(["m-editor-history-list-item-op", `op-${__props.group.opType}`]) }, (0, vue.toDisplayString)((0, vue.unref)(opLabel)(__props.group.opType)), 3),
|
|
12922
12911
|
(0, vue.createElementVNode)("span", _hoisted_3$12, (0, vue.toDisplayString)(__props.group.desc), 1),
|
|
12923
12912
|
headSaved.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_4$9, "已保存")) : (0, vue.createCommentVNode)("v-if", true),
|
|
12924
|
-
!merged.value && (headRevertable.value || headDiffable.value || canHeadGoto.value) ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_5$
|
|
12913
|
+
!merged.value && (headRevertable.value || headDiffable.value || canHeadGoto.value) ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_5$4, [
|
|
12925
12914
|
headRevertable.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", {
|
|
12926
12915
|
key: 0,
|
|
12927
12916
|
class: "m-editor-history-list-item-revert",
|
|
@@ -13031,7 +13020,7 @@
|
|
|
13031
13020
|
key: 1,
|
|
13032
13021
|
class: "m-editor-history-list-item-actions"
|
|
13033
13022
|
};
|
|
13034
|
-
var _hoisted_5$
|
|
13023
|
+
var _hoisted_5$3 = ["title"];
|
|
13035
13024
|
var InitialRow_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0, vue.defineComponent)({
|
|
13036
13025
|
name: "MEditorHistoryListInitialRow",
|
|
13037
13026
|
__name: "InitialRow",
|
|
@@ -13093,7 +13082,7 @@
|
|
|
13093
13082
|
key: 2,
|
|
13094
13083
|
class: "m-editor-history-list-item-time",
|
|
13095
13084
|
title: timeTitle.value
|
|
13096
|
-
}, (0, vue.toDisplayString)(time.value), 9, _hoisted_5$
|
|
13085
|
+
}, (0, vue.toDisplayString)(time.value), 9, _hoisted_5$3)) : (0, vue.createCommentVNode)("v-if", true)
|
|
13097
13086
|
], 10, _hoisted_1$66);
|
|
13098
13087
|
};
|
|
13099
13088
|
}
|
|
@@ -13475,7 +13464,7 @@
|
|
|
13475
13464
|
}));
|
|
13476
13465
|
//#endregion
|
|
13477
13466
|
//#region packages/editor/src/layouts/history-list/HistoryDiffDialog.vue?vue&type=script&setup=true&lang.ts
|
|
13478
|
-
var _hoisted_1$62, _hoisted_2$19, _hoisted_3$7, _hoisted_4$6, _hoisted_5$
|
|
13467
|
+
var _hoisted_1$62, _hoisted_2$19, _hoisted_3$7, _hoisted_4$6, _hoisted_5$2, _hoisted_6$2, _hoisted_7, HistoryDiffDialog_vue_vue_type_script_setup_true_lang_default;
|
|
13479
13468
|
var init_HistoryDiffDialog_vue_vue_type_script_setup_true_lang = __esmMin((() => {
|
|
13480
13469
|
init_lodash();
|
|
13481
13470
|
init_CompareForm();
|
|
@@ -13490,7 +13479,7 @@
|
|
|
13490
13479
|
};
|
|
13491
13480
|
_hoisted_3$7 = { class: "m-editor-history-diff-dialog-header" };
|
|
13492
13481
|
_hoisted_4$6 = { class: "m-editor-history-diff-dialog-target" };
|
|
13493
|
-
_hoisted_5$
|
|
13482
|
+
_hoisted_5$2 = { class: "m-editor-history-diff-dialog-controls" };
|
|
13494
13483
|
_hoisted_6$2 = { class: "m-editor-history-diff-dialog-legend" };
|
|
13495
13484
|
_hoisted_7 = {
|
|
13496
13485
|
key: 0,
|
|
@@ -13670,7 +13659,7 @@
|
|
|
13670
13659
|
}))]),
|
|
13671
13660
|
default: (0, vue.withCtx)(() => [payload.value && visible.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$62, [
|
|
13672
13661
|
__props.onConfirm ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_2$19, "仅回滚有差异的字段")) : (0, vue.createCommentVNode)("v-if", true),
|
|
13673
|
-
(0, vue.createElementVNode)("div", _hoisted_3$7, [(0, vue.createElementVNode)("span", _hoisted_4$6, (0, vue.toDisplayString)(targetText.value), 1), (0, vue.createElementVNode)("div", _hoisted_5$
|
|
13662
|
+
(0, vue.createElementVNode)("div", _hoisted_3$7, [(0, vue.createElementVNode)("span", _hoisted_4$6, (0, vue.toDisplayString)(targetText.value), 1), (0, vue.createElementVNode)("div", _hoisted_5$2, [(0, vue.createVNode)((0, vue.unref)(_tmagic_design.TMagicRadioGroup), {
|
|
13674
13663
|
modelValue: viewMode.value,
|
|
13675
13664
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => viewMode.value = $event),
|
|
13676
13665
|
size: "small",
|
|
@@ -14815,6 +14804,7 @@
|
|
|
14815
14804
|
containerHighlightClassName: _tmagic_stage.CONTAINER_HIGHLIGHT_CLASS_NAME,
|
|
14816
14805
|
containerHighlightDuration: 800,
|
|
14817
14806
|
containerHighlightType: _tmagic_stage.ContainerHighlightType.DEFAULT,
|
|
14807
|
+
containerHighlightAddOnly: false,
|
|
14818
14808
|
disabledShowSrc: false,
|
|
14819
14809
|
disabledDataSource: false,
|
|
14820
14810
|
disabledCodeBlock: false,
|
|
@@ -14840,7 +14830,6 @@
|
|
|
14840
14830
|
//#endregion
|
|
14841
14831
|
//#region packages/editor/src/layouts/props-panel/FormPanel.vue?vue&type=script&setup=true&lang.ts
|
|
14842
14832
|
init_Icon();
|
|
14843
|
-
init_props();
|
|
14844
14833
|
init_CodeEditor();
|
|
14845
14834
|
var _hoisted_1$59 = { class: "m-editor-props-form-panel" };
|
|
14846
14835
|
var FormPanel_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0, vue.defineComponent)({
|
|
@@ -14914,14 +14903,18 @@
|
|
|
14914
14903
|
return;
|
|
14915
14904
|
}
|
|
14916
14905
|
try {
|
|
14917
|
-
const error = await
|
|
14906
|
+
const error = await (0, _tmagic_form.validateForm)({
|
|
14918
14907
|
config: props.config,
|
|
14919
|
-
values: newValues,
|
|
14920
|
-
appContext: internalInstance?.appContext ?? null,
|
|
14921
|
-
services,
|
|
14922
|
-
stage: stage.value,
|
|
14923
14908
|
typeMatchValid: true,
|
|
14924
|
-
|
|
14909
|
+
initValues: newValues,
|
|
14910
|
+
appContext: internalInstance?.appContext ? {
|
|
14911
|
+
...internalInstance?.appContext,
|
|
14912
|
+
provides: { services }
|
|
14913
|
+
} : null,
|
|
14914
|
+
extendState: (state) => {
|
|
14915
|
+
if (configFormRef.value?.formState) return { ...configFormRef.value?.formState || {} };
|
|
14916
|
+
return props.extendState?.(state) || {};
|
|
14917
|
+
}
|
|
14925
14918
|
});
|
|
14926
14919
|
if (error) (0, _tmagic_design.tMagicMessage)({
|
|
14927
14920
|
type: "error",
|
|
@@ -17896,7 +17889,7 @@
|
|
|
17896
17889
|
return;
|
|
17897
17890
|
}
|
|
17898
17891
|
if (timeout || !stage.value) return;
|
|
17899
|
-
timeout = stage.value.delayedMarkContainer(e);
|
|
17892
|
+
timeout = stage.value.delayedMarkContainer(e, [], true);
|
|
17900
17893
|
};
|
|
17901
17894
|
return (_ctx, _cache) => {
|
|
17902
17895
|
return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicScrollbar), null, {
|
|
@@ -17964,7 +17957,7 @@
|
|
|
17964
17957
|
key: 1,
|
|
17965
17958
|
class: "magic-editor-tab-panel-title"
|
|
17966
17959
|
};
|
|
17967
|
-
var _hoisted_5$
|
|
17960
|
+
var _hoisted_5$1 = {
|
|
17968
17961
|
key: 0,
|
|
17969
17962
|
class: "m-editor-sidebar-tips"
|
|
17970
17963
|
};
|
|
@@ -18208,7 +18201,7 @@
|
|
|
18208
18201
|
`${index}`
|
|
18209
18202
|
].includes(activeTabName.value)]]);
|
|
18210
18203
|
}), 128)),
|
|
18211
|
-
tipsBarVisible.value && collecting.value && taskLength.value > 0 ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_5$
|
|
18204
|
+
tipsBarVisible.value && collecting.value && taskLength.value > 0 ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_5$1, [(0, vue.createElementVNode)("span", null, "依赖收集中(剩余任务:" + (0, vue.toDisplayString)(taskLength.value) + ")", 1), (0, vue.createVNode)(Icon_default, {
|
|
18212
18205
|
icon: (0, vue.unref)(_element_plus_icons_vue.Close),
|
|
18213
18206
|
class: "close-icon",
|
|
18214
18207
|
onClick: _cache[1] || (_cache[1] = (0, vue.withModifiers)(($event) => tipsBarVisible.value = false, ["stop"]))
|
|
@@ -19244,6 +19237,9 @@
|
|
|
19244
19237
|
idleTask = new IdleTask();
|
|
19245
19238
|
watcher = new _tmagic_core.Watcher({ initialTargets: (0, vue.reactive)({}) });
|
|
19246
19239
|
waitingWorker;
|
|
19240
|
+
resolveWaitingWorker;
|
|
19241
|
+
workerGeneration = 0;
|
|
19242
|
+
activeBatches = /* @__PURE__ */ new Set();
|
|
19247
19243
|
constructor() {
|
|
19248
19244
|
super();
|
|
19249
19245
|
this.idleTask.on("update-task-length", throttle(({ length }) => {
|
|
@@ -19293,33 +19289,36 @@
|
|
|
19293
19289
|
}
|
|
19294
19290
|
async collectIdle(nodes, depExtendedData = {}, deep = false, type) {
|
|
19295
19291
|
if (this.waitingWorker) await this.waitingWorker;
|
|
19296
|
-
|
|
19297
|
-
|
|
19292
|
+
const batch = {
|
|
19293
|
+
nodes,
|
|
19294
|
+
deep,
|
|
19295
|
+
pending: 0,
|
|
19296
|
+
dsPending: 0,
|
|
19297
|
+
collectedEmitted: false,
|
|
19298
|
+
dsSettled: false,
|
|
19299
|
+
resolve: () => {}
|
|
19300
|
+
};
|
|
19298
19301
|
this.watcher.collectByCallback(nodes, type, ({ node, target }) => {
|
|
19299
|
-
|
|
19300
|
-
this.enqueueTask(node, target, depExtendedData, deep);
|
|
19302
|
+
this.enqueueTask(node, target, depExtendedData, deep, batch);
|
|
19301
19303
|
});
|
|
19304
|
+
if (batch.pending === 0) {
|
|
19305
|
+
this.emit("collected", nodes, deep);
|
|
19306
|
+
this.updateCollectingState();
|
|
19307
|
+
return true;
|
|
19308
|
+
}
|
|
19309
|
+
this.activeBatches.add(batch);
|
|
19310
|
+
this.set("collecting", true);
|
|
19302
19311
|
return new Promise((resolve) => {
|
|
19303
|
-
|
|
19304
|
-
this.emit("collected", nodes, deep);
|
|
19305
|
-
this.set("collecting", false);
|
|
19306
|
-
resolve();
|
|
19307
|
-
return;
|
|
19308
|
-
}
|
|
19309
|
-
this.idleTask.once("finish", () => {
|
|
19310
|
-
this.emit("collected", nodes, deep);
|
|
19311
|
-
this.set("collecting", false);
|
|
19312
|
-
});
|
|
19313
|
-
this.idleTask.once("hight-level-finish", () => {
|
|
19314
|
-
this.emit("ds-collected", nodes, deep);
|
|
19315
|
-
resolve();
|
|
19316
|
-
});
|
|
19312
|
+
batch.resolve = resolve;
|
|
19317
19313
|
});
|
|
19318
19314
|
}
|
|
19319
19315
|
collectByWorker(dsl) {
|
|
19320
19316
|
this.set("collecting", true);
|
|
19317
|
+
this.workerGeneration += 1;
|
|
19318
|
+
const generation = this.workerGeneration;
|
|
19321
19319
|
const { promise, resolve: waitingResolve } = Promise.withResolvers();
|
|
19322
19320
|
this.waitingWorker = promise;
|
|
19321
|
+
this.resolveWaitingWorker = waitingResolve;
|
|
19323
19322
|
return new Promise((resolve) => {
|
|
19324
19323
|
const worker = new WorkerWrapper();
|
|
19325
19324
|
worker.postMessage({ dsl: (0, serialize_javascript.default)(dsl) });
|
|
@@ -19330,6 +19329,10 @@
|
|
|
19330
19329
|
resolve({});
|
|
19331
19330
|
};
|
|
19332
19331
|
}).then((depsData) => {
|
|
19332
|
+
if (generation !== this.workerGeneration) {
|
|
19333
|
+
waitingResolve();
|
|
19334
|
+
return depsData;
|
|
19335
|
+
}
|
|
19333
19336
|
(0, _tmagic_core.traverseTarget)(this.watcher.getTargetsList(), (target) => {
|
|
19334
19337
|
if (depsData[target.type]?.[target.id]) {
|
|
19335
19338
|
target.deps = (0, vue.reactive)(depsData[target.type][target.id]);
|
|
@@ -19342,6 +19345,10 @@
|
|
|
19342
19345
|
this.emit("collected", dsl.items, true);
|
|
19343
19346
|
this.emit("ds-collected", dsl.items, true);
|
|
19344
19347
|
waitingResolve();
|
|
19348
|
+
if (this.waitingWorker === promise) {
|
|
19349
|
+
this.waitingWorker = void 0;
|
|
19350
|
+
this.resolveWaitingWorker = void 0;
|
|
19351
|
+
}
|
|
19345
19352
|
return depsData;
|
|
19346
19353
|
});
|
|
19347
19354
|
}
|
|
@@ -19363,6 +19370,7 @@
|
|
|
19363
19370
|
return this.watcher.hasSpecifiedTypeTarget(type);
|
|
19364
19371
|
}
|
|
19365
19372
|
clearIdleTasks() {
|
|
19373
|
+
this.abortActiveBatches();
|
|
19366
19374
|
this.idleTask.clearTasks();
|
|
19367
19375
|
}
|
|
19368
19376
|
on(eventName, listener) {
|
|
@@ -19372,6 +19380,11 @@
|
|
|
19372
19380
|
return super.once(eventName, listener);
|
|
19373
19381
|
}
|
|
19374
19382
|
reset() {
|
|
19383
|
+
this.abortActiveBatches();
|
|
19384
|
+
this.workerGeneration += 1;
|
|
19385
|
+
this.resolveWaitingWorker?.();
|
|
19386
|
+
this.resolveWaitingWorker = void 0;
|
|
19387
|
+
this.waitingWorker = void 0;
|
|
19375
19388
|
this.idleTask.clearTasks();
|
|
19376
19389
|
for (const type of Object.keys(this.watcher.getTargetsList())) this.removeTargets(type);
|
|
19377
19390
|
this.set("collecting", false);
|
|
@@ -19396,18 +19409,63 @@
|
|
|
19396
19409
|
if (dep.data?.pageId && dep.data.pageId === depExtendedData.pageId) delete target.deps[depKey];
|
|
19397
19410
|
}
|
|
19398
19411
|
}
|
|
19399
|
-
enqueueTask(node, target, depExtendedData, deep) {
|
|
19412
|
+
enqueueTask(node, target, depExtendedData, deep, batch) {
|
|
19413
|
+
const isDataSource = target.type === _tmagic_core.DepTargetType.DATA_SOURCE;
|
|
19414
|
+
batch.pending += 1;
|
|
19415
|
+
if (isDataSource) batch.dsPending += 1;
|
|
19400
19416
|
this.idleTask.enqueueTask(({ node, deep, target }) => {
|
|
19401
|
-
|
|
19417
|
+
try {
|
|
19418
|
+
this.collectNode(node, target, depExtendedData, deep);
|
|
19419
|
+
} finally {
|
|
19420
|
+
this.onBatchTaskDone(batch, isDataSource);
|
|
19421
|
+
}
|
|
19402
19422
|
}, {
|
|
19403
19423
|
node,
|
|
19404
19424
|
deep: false,
|
|
19405
19425
|
target
|
|
19406
|
-
},
|
|
19426
|
+
}, isDataSource);
|
|
19407
19427
|
if (deep && Array.isArray(node.items) && node.items.length) node.items.forEach((item) => {
|
|
19408
|
-
this.enqueueTask(item, target, depExtendedData, deep);
|
|
19428
|
+
this.enqueueTask(item, target, depExtendedData, deep, batch);
|
|
19409
19429
|
});
|
|
19410
19430
|
}
|
|
19431
|
+
onBatchTaskDone(batch, isDataSource) {
|
|
19432
|
+
if (isDataSource) {
|
|
19433
|
+
batch.dsPending -= 1;
|
|
19434
|
+
if (batch.dsPending === 0) this.settleBatchDs(batch);
|
|
19435
|
+
}
|
|
19436
|
+
batch.pending -= 1;
|
|
19437
|
+
if (batch.pending === 0) this.finishBatch(batch);
|
|
19438
|
+
}
|
|
19439
|
+
settleBatchDs(batch) {
|
|
19440
|
+
if (batch.dsSettled) return;
|
|
19441
|
+
batch.dsSettled = true;
|
|
19442
|
+
this.emit("ds-collected", batch.nodes, batch.deep);
|
|
19443
|
+
batch.resolve(true);
|
|
19444
|
+
}
|
|
19445
|
+
finishBatch(batch) {
|
|
19446
|
+
if (!batch.collectedEmitted) {
|
|
19447
|
+
batch.collectedEmitted = true;
|
|
19448
|
+
this.emit("collected", batch.nodes, batch.deep);
|
|
19449
|
+
}
|
|
19450
|
+
this.settleBatchDs(batch);
|
|
19451
|
+
this.activeBatches.delete(batch);
|
|
19452
|
+
this.updateCollectingState();
|
|
19453
|
+
}
|
|
19454
|
+
/**
|
|
19455
|
+
* idleTask 被清空时,在途批次的任务不会再执行,必须主动结算,
|
|
19456
|
+
* 否则对应的 collectIdle Promise 永远不会 resolve(collecting 卡在 true、once 监听器泄漏)。
|
|
19457
|
+
* 收集被中断(通常紧跟一次全量重新收集),因此不再 emit collected/ds-collected,仅结算 Promise。
|
|
19458
|
+
*/
|
|
19459
|
+
abortActiveBatches() {
|
|
19460
|
+
if (!this.activeBatches.size) return;
|
|
19461
|
+
const batches = [...this.activeBatches];
|
|
19462
|
+
this.activeBatches.clear();
|
|
19463
|
+
for (const batch of batches) batch.resolve(false);
|
|
19464
|
+
this.updateCollectingState();
|
|
19465
|
+
}
|
|
19466
|
+
updateCollectingState() {
|
|
19467
|
+
this.set("collecting", this.activeBatches.size > 0);
|
|
19468
|
+
}
|
|
19411
19469
|
};
|
|
19412
19470
|
var dep_default = new Dep();
|
|
19413
19471
|
//#endregion
|
|
@@ -19851,15 +19909,15 @@
|
|
|
19851
19909
|
return pageId;
|
|
19852
19910
|
};
|
|
19853
19911
|
const collectIdle = (nodes, deep, type) => Promise.all(nodes.map((node) => {
|
|
19854
|
-
if (node.type === _tmagic_core.NodeType.ROOT) return Promise.resolve();
|
|
19912
|
+
if (node.type === _tmagic_core.NodeType.ROOT) return Promise.resolve(true);
|
|
19855
19913
|
return depService.collectIdle([node], { pageId: getPageIdByNode(node) }, deep, type);
|
|
19856
|
-
}));
|
|
19914
|
+
})).then((results) => results.every(Boolean));
|
|
19857
19915
|
(0, vue.watch)(() => editorService.get("stage"), (stage) => {
|
|
19858
19916
|
if (!stage) return;
|
|
19859
19917
|
stage.on("rerender", async () => {
|
|
19860
19918
|
const node = editorService.get("node");
|
|
19861
19919
|
if (!node) return;
|
|
19862
|
-
await collectIdle([node], true, _tmagic_core.DepTargetType.DATA_SOURCE);
|
|
19920
|
+
if (!await collectIdle([node], true, _tmagic_core.DepTargetType.DATA_SOURCE)) return;
|
|
19863
19921
|
updateStageNode(node);
|
|
19864
19922
|
});
|
|
19865
19923
|
});
|
|
@@ -19946,8 +20004,8 @@
|
|
|
19946
20004
|
})();
|
|
19947
20005
|
};
|
|
19948
20006
|
const nodeAddHandler = (nodes) => {
|
|
19949
|
-
collectIdle(nodes, true).then(() => {
|
|
19950
|
-
updateStageNodes(nodes);
|
|
20007
|
+
collectIdle(nodes, true).then((completed) => {
|
|
20008
|
+
if (completed) updateStageNodes(nodes);
|
|
19951
20009
|
});
|
|
19952
20010
|
};
|
|
19953
20011
|
const nodeUpdateHandler = (data) => {
|
|
@@ -19976,8 +20034,8 @@
|
|
|
19976
20034
|
else normalNodes.push(newNode);
|
|
19977
20035
|
if (needRecollectNodes.length) {
|
|
19978
20036
|
const handler = async () => {
|
|
19979
|
-
await collectIdle(needRecollectNodes, true, _tmagic_core.DepTargetType.DATA_SOURCE);
|
|
19980
|
-
await collectIdle(needRecollectNodes, true, _tmagic_core.DepTargetType.DATA_SOURCE_COND);
|
|
20037
|
+
if (!await collectIdle(needRecollectNodes, true, _tmagic_core.DepTargetType.DATA_SOURCE)) return;
|
|
20038
|
+
if (!await collectIdle(needRecollectNodes, true, _tmagic_core.DepTargetType.DATA_SOURCE_COND)) return;
|
|
19981
20039
|
updateStageNodes(needRecollectNodes);
|
|
19982
20040
|
};
|
|
19983
20041
|
handler();
|
|
@@ -19990,8 +20048,8 @@
|
|
|
19990
20048
|
depService.clear(nodes);
|
|
19991
20049
|
};
|
|
19992
20050
|
const historyChangeHandler = (page) => {
|
|
19993
|
-
collectIdle([page], true).then(() => {
|
|
19994
|
-
updateStageNode(page);
|
|
20051
|
+
collectIdle([page], true).then((completed) => {
|
|
20052
|
+
if (completed) updateStageNode(page);
|
|
19995
20053
|
});
|
|
19996
20054
|
};
|
|
19997
20055
|
editorService.on("history-change", historyChangeHandler);
|
|
@@ -20051,7 +20109,13 @@
|
|
|
20051
20109
|
depService.addTarget((0, _tmagic_core.createDataSourceMethodTarget)(config, (0, vue.reactive)({})));
|
|
20052
20110
|
collectIdlePromises = [collectIdle(root.items, true, _tmagic_core.DepTargetType.DATA_SOURCE_METHOD)];
|
|
20053
20111
|
}
|
|
20054
|
-
|
|
20112
|
+
const handler = async () => {
|
|
20113
|
+
if (!(await Promise.all(collectIdlePromises)).every(Boolean)) return;
|
|
20114
|
+
updateDataSourceSchema();
|
|
20115
|
+
await updateDsData();
|
|
20116
|
+
updateStageNodes(root.items);
|
|
20117
|
+
};
|
|
20118
|
+
handler();
|
|
20055
20119
|
}
|
|
20056
20120
|
} else if (root?.dataSources) updateDsData();
|
|
20057
20121
|
};
|
|
@@ -20065,11 +20129,11 @@
|
|
|
20065
20129
|
if (!root) return;
|
|
20066
20130
|
const handler = async () => {
|
|
20067
20131
|
const nodes = (0, _tmagic_utils.getNodes)(Object.keys(root.dataSourceDeps?.[id] || {}), root.items);
|
|
20068
|
-
await Promise.all([
|
|
20132
|
+
if (!(await Promise.all([
|
|
20069
20133
|
collectIdle(nodes, false, _tmagic_core.DepTargetType.DATA_SOURCE),
|
|
20070
20134
|
collectIdle(nodes, false, _tmagic_core.DepTargetType.DATA_SOURCE_COND),
|
|
20071
20135
|
collectIdle(nodes, false, _tmagic_core.DepTargetType.DATA_SOURCE_METHOD)
|
|
20072
|
-
]);
|
|
20136
|
+
])).every(Boolean)) return;
|
|
20073
20137
|
updateDataSourceSchema();
|
|
20074
20138
|
(await getTMagicApp())?.dataSourceManager?.removeDataSource(id);
|
|
20075
20139
|
updateStageNodes(nodes);
|
|
@@ -20162,6 +20226,7 @@
|
|
|
20162
20226
|
containerHighlightClassName: {},
|
|
20163
20227
|
containerHighlightDuration: {},
|
|
20164
20228
|
containerHighlightType: {},
|
|
20229
|
+
containerHighlightAddOnly: { type: Boolean },
|
|
20165
20230
|
stageRect: {},
|
|
20166
20231
|
codeOptions: {},
|
|
20167
20232
|
disabledDragStart: { type: Boolean },
|
|
@@ -20232,6 +20297,7 @@
|
|
|
20232
20297
|
containerHighlightClassName: props.containerHighlightClassName,
|
|
20233
20298
|
containerHighlightDuration: props.containerHighlightDuration,
|
|
20234
20299
|
containerHighlightType: props.containerHighlightType,
|
|
20300
|
+
containerHighlightAddOnly: props.containerHighlightAddOnly,
|
|
20235
20301
|
disabledDragStart: props.disabledDragStart,
|
|
20236
20302
|
renderType: props.renderType,
|
|
20237
20303
|
guidesOptions: props.guidesOptions,
|
|
@@ -22587,7 +22653,6 @@
|
|
|
22587
22653
|
};
|
|
22588
22654
|
var _hoisted_3$3 = { class: "event-select-header" };
|
|
22589
22655
|
var _hoisted_4$2 = { class: "event-item-header" };
|
|
22590
|
-
var _hoisted_5$1 = { class: "event-item-title" };
|
|
22591
22656
|
var EventSelect_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0, vue.defineComponent)({
|
|
22592
22657
|
name: "MFieldsEventSelect",
|
|
22593
22658
|
__name: "EventSelect",
|
|
@@ -22668,6 +22733,12 @@
|
|
|
22668
22733
|
typeMatch: true,
|
|
22669
22734
|
trigger: "blur"
|
|
22670
22735
|
}],
|
|
22736
|
+
onChange: (_mForm, _v, { setModel }) => {
|
|
22737
|
+
setModel("to", "");
|
|
22738
|
+
setModel("method", "");
|
|
22739
|
+
setModel("codeId", "");
|
|
22740
|
+
setModel("dataSourceMethod", []);
|
|
22741
|
+
},
|
|
22671
22742
|
...props.config.actionTypeConfig
|
|
22672
22743
|
};
|
|
22673
22744
|
});
|
|
@@ -22678,7 +22749,7 @@
|
|
|
22678
22749
|
type: "ui-select",
|
|
22679
22750
|
labelPosition: "left",
|
|
22680
22751
|
display: (_mForm, { model }) => model.actionType === _tmagic_core.ActionType.COMP,
|
|
22681
|
-
onChange: (
|
|
22752
|
+
onChange: (_mForm, _v, { setModel }) => {
|
|
22682
22753
|
setModel("method", "");
|
|
22683
22754
|
},
|
|
22684
22755
|
rules: [{
|
|
@@ -22885,46 +22956,42 @@
|
|
|
22885
22956
|
model: entry.cardItem,
|
|
22886
22957
|
"last-values": entry.lastCardItem,
|
|
22887
22958
|
"is-compare": isCompareMode.value,
|
|
22888
|
-
"hide-expand":
|
|
22959
|
+
"hide-expand": false,
|
|
22889
22960
|
"label-width": __props.config.labelWidth || "100px",
|
|
22890
22961
|
onChange: onChangeHandler
|
|
22891
22962
|
}, {
|
|
22892
|
-
header: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_4$2, [
|
|
22893
|
-
|
|
22894
|
-
|
|
22895
|
-
|
|
22896
|
-
|
|
22897
|
-
|
|
22898
|
-
|
|
22899
|
-
|
|
22900
|
-
|
|
22901
|
-
|
|
22902
|
-
|
|
22903
|
-
|
|
22904
|
-
|
|
22905
|
-
|
|
22906
|
-
|
|
22907
|
-
|
|
22908
|
-
|
|
22909
|
-
|
|
22910
|
-
|
|
22911
|
-
|
|
22912
|
-
|
|
22913
|
-
|
|
22914
|
-
|
|
22915
|
-
|
|
22916
|
-
|
|
22917
|
-
|
|
22918
|
-
|
|
22919
|
-
|
|
22920
|
-
|
|
22921
|
-
|
|
22922
|
-
|
|
22923
|
-
|
|
22924
|
-
"size",
|
|
22925
|
-
"onClick"
|
|
22926
|
-
])) : (0, vue.createCommentVNode)("v-if", true)
|
|
22927
|
-
])]),
|
|
22963
|
+
header: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_4$2, [(0, vue.createVNode)((0, vue.unref)(_tmagic_form.MContainer), {
|
|
22964
|
+
class: "fullWidth",
|
|
22965
|
+
config: eventNameConfig.value,
|
|
22966
|
+
model: entry.cardItem,
|
|
22967
|
+
"last-values": entry.lastCardItem,
|
|
22968
|
+
"is-compare": isCompareMode.value,
|
|
22969
|
+
disabled: __props.disabled,
|
|
22970
|
+
size: __props.size,
|
|
22971
|
+
prop: `${__props.prop}.${entry.index}`,
|
|
22972
|
+
onChange: eventNameChangeHandler
|
|
22973
|
+
}, null, 8, [
|
|
22974
|
+
"config",
|
|
22975
|
+
"model",
|
|
22976
|
+
"last-values",
|
|
22977
|
+
"is-compare",
|
|
22978
|
+
"disabled",
|
|
22979
|
+
"size",
|
|
22980
|
+
"prop"
|
|
22981
|
+
]), !isCompareMode.value ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_tmagic_design.TMagicButton), {
|
|
22982
|
+
key: 0,
|
|
22983
|
+
class: "event-item-delete-button",
|
|
22984
|
+
link: "",
|
|
22985
|
+
icon: (0, vue.unref)(_element_plus_icons_vue.Delete),
|
|
22986
|
+
disabled: __props.disabled,
|
|
22987
|
+
size: __props.size,
|
|
22988
|
+
onClick: ($event) => removeEvent(Number(entry.index))
|
|
22989
|
+
}, null, 8, [
|
|
22990
|
+
"icon",
|
|
22991
|
+
"disabled",
|
|
22992
|
+
"size",
|
|
22993
|
+
"onClick"
|
|
22994
|
+
])) : (0, vue.createCommentVNode)("v-if", true)])]),
|
|
22928
22995
|
_: 2
|
|
22929
22996
|
}, 1032, [
|
|
22930
22997
|
"disabled",
|
|
@@ -25930,7 +25997,6 @@
|
|
|
25930
25997
|
exports.useServices = useServices;
|
|
25931
25998
|
exports.useStage = useStage;
|
|
25932
25999
|
exports.useWindowRect = useWindowRect;
|
|
25933
|
-
exports.validatePropsForm = validatePropsForm;
|
|
25934
26000
|
exports.warn = warn;
|
|
25935
26001
|
Object.keys(_tmagic_form).forEach(function(k) {
|
|
25936
26002
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.8.0-beta.
|
|
2
|
+
"version": "1.8.0-beta.17",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"moveable": "^0.53.0",
|
|
59
59
|
"serialize-javascript": "^7.0.0",
|
|
60
60
|
"sortablejs": "^1.15.6",
|
|
61
|
-
"@tmagic/
|
|
62
|
-
"@tmagic/
|
|
63
|
-
"@tmagic/
|
|
64
|
-
"@tmagic/
|
|
65
|
-
"@tmagic/stage": "1.8.0-beta.
|
|
61
|
+
"@tmagic/form": "1.8.0-beta.17",
|
|
62
|
+
"@tmagic/design": "1.8.0-beta.17",
|
|
63
|
+
"@tmagic/utils": "1.8.0-beta.17",
|
|
64
|
+
"@tmagic/table": "1.8.0-beta.17",
|
|
65
|
+
"@tmagic/stage": "1.8.0-beta.17"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/events": "^3.0.3",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"type-fest": "^5.2.0",
|
|
77
77
|
"typescript": "^6.0.3",
|
|
78
78
|
"vue": "^3.5.40",
|
|
79
|
-
"@tmagic/core": "1.8.0-beta.
|
|
79
|
+
"@tmagic/core": "1.8.0-beta.17"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
|
82
82
|
"typescript": {
|
package/src/Editor.vue
CHANGED
|
@@ -218,6 +218,7 @@ const stageOptions: StageOptions = {
|
|
|
218
218
|
containerHighlightClassName: props.containerHighlightClassName,
|
|
219
219
|
containerHighlightDuration: props.containerHighlightDuration,
|
|
220
220
|
containerHighlightType: props.containerHighlightType,
|
|
221
|
+
containerHighlightAddOnly: props.containerHighlightAddOnly,
|
|
221
222
|
disabledDragStart: props.disabledDragStart,
|
|
222
223
|
renderType: props.renderType,
|
|
223
224
|
guidesOptions: props.guidesOptions,
|
package/src/editorProps.ts
CHANGED
|
@@ -82,6 +82,11 @@ export interface EditorProps {
|
|
|
82
82
|
containerHighlightDuration?: number;
|
|
83
83
|
/** 拖入画布中容器时,识别容器的操作类型 */
|
|
84
84
|
containerHighlightType?: ContainerHighlightType;
|
|
85
|
+
/**
|
|
86
|
+
* 是否仅在新增组件(从组件列表拖入新组件)时才启用识别容器,
|
|
87
|
+
* 开启后在画布中拖动已有组件不会识别容器,默认 false
|
|
88
|
+
*/
|
|
89
|
+
containerHighlightAddOnly?: boolean;
|
|
85
90
|
/** 画布大小 */
|
|
86
91
|
stageRect?: StageRect;
|
|
87
92
|
/** monaco editor 的配置 */
|
|
@@ -163,6 +168,7 @@ export const defaultEditorProps = {
|
|
|
163
168
|
containerHighlightClassName: CONTAINER_HIGHLIGHT_CLASS_NAME,
|
|
164
169
|
containerHighlightDuration: 800,
|
|
165
170
|
containerHighlightType: ContainerHighlightType.DEFAULT,
|
|
171
|
+
containerHighlightAddOnly: false,
|
|
166
172
|
disabledShowSrc: false,
|
|
167
173
|
disabledDataSource: false,
|
|
168
174
|
disabledCodeBlock: false,
|
|
@@ -37,13 +37,12 @@
|
|
|
37
37
|
:model="entry.cardItem"
|
|
38
38
|
:last-values="entry.lastCardItem"
|
|
39
39
|
:is-compare="isCompareMode"
|
|
40
|
-
:hide-expand="
|
|
40
|
+
:hide-expand="false"
|
|
41
41
|
:label-width="config.labelWidth || '100px'"
|
|
42
42
|
@change="onChangeHandler"
|
|
43
43
|
>
|
|
44
44
|
<template #header>
|
|
45
45
|
<div class="event-item-header">
|
|
46
|
-
<div class="event-item-title">事件{{ Number(entry.index) + 1 }}</div>
|
|
47
46
|
<MFormContainer
|
|
48
47
|
class="fullWidth"
|
|
49
48
|
:config="eventNameConfig"
|
|
@@ -210,6 +209,12 @@ const actionTypeConfig = computed(() => {
|
|
|
210
209
|
trigger: 'blur',
|
|
211
210
|
},
|
|
212
211
|
],
|
|
212
|
+
onChange: (_mForm: FormState, _v: string, { setModel }: any) => {
|
|
213
|
+
setModel('to', '');
|
|
214
|
+
setModel('method', '');
|
|
215
|
+
setModel('codeId', '');
|
|
216
|
+
setModel('dataSourceMethod', []);
|
|
217
|
+
},
|
|
213
218
|
};
|
|
214
219
|
return { ...defaultActionTypeConfig, ...props.config.actionTypeConfig };
|
|
215
220
|
});
|
|
@@ -222,7 +227,7 @@ const targetCompConfig = computed(() => {
|
|
|
222
227
|
type: 'ui-select',
|
|
223
228
|
labelPosition: 'left',
|
|
224
229
|
display: (_mForm, { model }) => model.actionType === ActionType.COMP,
|
|
225
|
-
onChange: (
|
|
230
|
+
onChange: (_mForm, _v, { setModel }) => {
|
|
226
231
|
setModel('method', '');
|
|
227
232
|
},
|
|
228
233
|
rules: [
|
package/src/hooks/use-stage.ts
CHANGED
|
@@ -28,6 +28,7 @@ export const useStage = (stageOptions: StageOptions) => {
|
|
|
28
28
|
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
29
29
|
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
30
30
|
containerHighlightType: stageOptions.containerHighlightType,
|
|
31
|
+
containerHighlightAddOnly: stageOptions.containerHighlightAddOnly,
|
|
31
32
|
disabledDragStart: stageOptions.disabledDragStart,
|
|
32
33
|
renderType: stageOptions.renderType,
|
|
33
34
|
canSelect: (el, event, stop) => {
|