@tmagic/editor 1.5.19 → 1.5.21
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/tmagic-editor.js +25 -7
- package/dist/tmagic-editor.umd.cjs +25 -7
- package/package.json +7 -7
- package/src/Editor.vue +17 -1
- package/src/fields/DataSourceMethods.vue +1 -1
- package/src/fields/EventSelect.vue +3 -3
- package/src/initService.ts +10 -2
- package/src/services/events.ts +2 -2
- package/types/index.d.ts +1 -1
package/dist/tmagic-editor.js
CHANGED
|
@@ -5436,7 +5436,7 @@ const _sfc_main$1d = /* @__PURE__ */ defineComponent({
|
|
|
5436
5436
|
{
|
|
5437
5437
|
label: "参数",
|
|
5438
5438
|
prop: "params",
|
|
5439
|
-
formatter: (params) => params.map((item) => item.name).join(", ")
|
|
5439
|
+
formatter: (params = []) => params.map((item) => item.name).join(", ")
|
|
5440
5440
|
},
|
|
5441
5441
|
{
|
|
5442
5442
|
label: "操作",
|
|
@@ -6311,14 +6311,14 @@ const _sfc_main$18 = /* @__PURE__ */ defineComponent({
|
|
|
6311
6311
|
const node = editorService.getNodeById(model.to);
|
|
6312
6312
|
if (!node?.type) return [];
|
|
6313
6313
|
let methods = [];
|
|
6314
|
-
methods = eventsService.getMethod(node.type);
|
|
6314
|
+
methods = eventsService.getMethod(node.type, model.to);
|
|
6315
6315
|
if (node.type === "page-fragment-container" && node.pageFragmentId) {
|
|
6316
6316
|
const pageFragment = editorService.get("root")?.items?.find((page) => page.id === node.pageFragmentId);
|
|
6317
6317
|
if (pageFragment) {
|
|
6318
6318
|
methods = [];
|
|
6319
6319
|
pageFragment.items.forEach((node2) => {
|
|
6320
6320
|
traverseNode(node2, (node3) => {
|
|
6321
|
-
const nodeMethods = node3.type && eventsService.getMethod(node3.type) || [];
|
|
6321
|
+
const nodeMethods = node3.type && eventsService.getMethod(node3.type, node3.id) || [];
|
|
6322
6322
|
if (nodeMethods.length) {
|
|
6323
6323
|
methods.push({
|
|
6324
6324
|
label: `${node3.name}_${node3.id}`,
|
|
@@ -6384,7 +6384,7 @@ const _sfc_main$18 = /* @__PURE__ */ defineComponent({
|
|
|
6384
6384
|
options: (mForm, { model }) => {
|
|
6385
6385
|
const node = editorService.getNodeById(model.to);
|
|
6386
6386
|
if (!node?.type) return [];
|
|
6387
|
-
return eventsService.getMethod(node.type).map((option) => ({
|
|
6387
|
+
return eventsService.getMethod(node.type, model.to).map((option) => ({
|
|
6388
6388
|
text: option.label,
|
|
6389
6389
|
value: option.value
|
|
6390
6390
|
}));
|
|
@@ -14203,7 +14203,7 @@ class Events extends BaseService {
|
|
|
14203
14203
|
setMethod(type, method) {
|
|
14204
14204
|
methodMap[toLine(type)] = [...method];
|
|
14205
14205
|
}
|
|
14206
|
-
getMethod(type) {
|
|
14206
|
+
getMethod(type, _targetId) {
|
|
14207
14207
|
return cloneDeep(methodMap[toLine(type)]) || [];
|
|
14208
14208
|
}
|
|
14209
14209
|
resetState() {
|
|
@@ -14736,6 +14736,7 @@ const initServiceState = (props, {
|
|
|
14736
14736
|
});
|
|
14737
14737
|
};
|
|
14738
14738
|
const initServiceEvents = (props, emit, { editorService, codeBlockService, dataSourceService, depService }) => {
|
|
14739
|
+
let getTMagicAppPrimise = null;
|
|
14739
14740
|
const getTMagicApp = () => {
|
|
14740
14741
|
const renderer = editorService.get("stage")?.renderer;
|
|
14741
14742
|
if (!renderer) {
|
|
@@ -14744,17 +14745,21 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
14744
14745
|
if (renderer.runtime) {
|
|
14745
14746
|
return Promise.resolve(renderer.runtime.getApp?.());
|
|
14746
14747
|
}
|
|
14747
|
-
|
|
14748
|
+
if (getTMagicAppPrimise) {
|
|
14749
|
+
return getTMagicAppPrimise;
|
|
14750
|
+
}
|
|
14751
|
+
getTMagicAppPrimise = new Promise((resolve) => {
|
|
14748
14752
|
const timeout = globalThis.setTimeout(() => {
|
|
14749
14753
|
resolve(void 0);
|
|
14750
14754
|
}, 1e4);
|
|
14751
|
-
renderer.
|
|
14755
|
+
renderer.once("runtime-ready", () => {
|
|
14752
14756
|
if (timeout) {
|
|
14753
14757
|
globalThis.clearTimeout(timeout);
|
|
14754
14758
|
}
|
|
14755
14759
|
resolve(renderer.runtime?.getApp?.());
|
|
14756
14760
|
});
|
|
14757
14761
|
});
|
|
14762
|
+
return getTMagicAppPrimise;
|
|
14758
14763
|
};
|
|
14759
14764
|
const updateStageNodes = (nodes) => {
|
|
14760
14765
|
for (const node of nodes) {
|
|
@@ -15185,6 +15190,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
15185
15190
|
disabledMultiSelect: props.disabledMultiSelect
|
|
15186
15191
|
};
|
|
15187
15192
|
stageOverlayService.set("stageOptions", stageOptions);
|
|
15193
|
+
watch(
|
|
15194
|
+
() => props.runtimeUrl,
|
|
15195
|
+
(url) => {
|
|
15196
|
+
if (!url) {
|
|
15197
|
+
return;
|
|
15198
|
+
}
|
|
15199
|
+
const stage = editorService.get("stage");
|
|
15200
|
+
if (!stage) {
|
|
15201
|
+
return;
|
|
15202
|
+
}
|
|
15203
|
+
stage.reloadIframe(url);
|
|
15204
|
+
}
|
|
15205
|
+
);
|
|
15188
15206
|
provide("services", services);
|
|
15189
15207
|
provide("codeOptions", props.codeOptions);
|
|
15190
15208
|
provide("stageOptions", stageOptions);
|
|
@@ -10229,7 +10229,7 @@
|
|
|
10229
10229
|
{
|
|
10230
10230
|
label: "参数",
|
|
10231
10231
|
prop: "params",
|
|
10232
|
-
formatter: (params) => params.map((item) => item.name).join(", ")
|
|
10232
|
+
formatter: (params = []) => params.map((item) => item.name).join(", ")
|
|
10233
10233
|
},
|
|
10234
10234
|
{
|
|
10235
10235
|
label: "操作",
|
|
@@ -11104,14 +11104,14 @@
|
|
|
11104
11104
|
const node = editorService.getNodeById(model.to);
|
|
11105
11105
|
if (!node?.type) return [];
|
|
11106
11106
|
let methods = [];
|
|
11107
|
-
methods = eventsService.getMethod(node.type);
|
|
11107
|
+
methods = eventsService.getMethod(node.type, model.to);
|
|
11108
11108
|
if (node.type === "page-fragment-container" && node.pageFragmentId) {
|
|
11109
11109
|
const pageFragment = editorService.get("root")?.items?.find((page) => page.id === node.pageFragmentId);
|
|
11110
11110
|
if (pageFragment) {
|
|
11111
11111
|
methods = [];
|
|
11112
11112
|
pageFragment.items.forEach((node2) => {
|
|
11113
11113
|
utils.traverseNode(node2, (node3) => {
|
|
11114
|
-
const nodeMethods = node3.type && eventsService.getMethod(node3.type) || [];
|
|
11114
|
+
const nodeMethods = node3.type && eventsService.getMethod(node3.type, node3.id) || [];
|
|
11115
11115
|
if (nodeMethods.length) {
|
|
11116
11116
|
methods.push({
|
|
11117
11117
|
label: `${node3.name}_${node3.id}`,
|
|
@@ -11177,7 +11177,7 @@
|
|
|
11177
11177
|
options: (mForm, { model }) => {
|
|
11178
11178
|
const node = editorService.getNodeById(model.to);
|
|
11179
11179
|
if (!node?.type) return [];
|
|
11180
|
-
return eventsService.getMethod(node.type).map((option) => ({
|
|
11180
|
+
return eventsService.getMethod(node.type, model.to).map((option) => ({
|
|
11181
11181
|
text: option.label,
|
|
11182
11182
|
value: option.value
|
|
11183
11183
|
}));
|
|
@@ -18996,7 +18996,7 @@
|
|
|
18996
18996
|
setMethod(type, method) {
|
|
18997
18997
|
methodMap[utils.toLine(type)] = [...method];
|
|
18998
18998
|
}
|
|
18999
|
-
getMethod(type) {
|
|
18999
|
+
getMethod(type, _targetId) {
|
|
19000
19000
|
return cloneDeep(methodMap[utils.toLine(type)]) || [];
|
|
19001
19001
|
}
|
|
19002
19002
|
resetState() {
|
|
@@ -19529,6 +19529,7 @@
|
|
|
19529
19529
|
});
|
|
19530
19530
|
};
|
|
19531
19531
|
const initServiceEvents = (props, emit, { editorService, codeBlockService, dataSourceService, depService }) => {
|
|
19532
|
+
let getTMagicAppPrimise = null;
|
|
19532
19533
|
const getTMagicApp = () => {
|
|
19533
19534
|
const renderer = editorService.get("stage")?.renderer;
|
|
19534
19535
|
if (!renderer) {
|
|
@@ -19537,17 +19538,21 @@
|
|
|
19537
19538
|
if (renderer.runtime) {
|
|
19538
19539
|
return Promise.resolve(renderer.runtime.getApp?.());
|
|
19539
19540
|
}
|
|
19540
|
-
|
|
19541
|
+
if (getTMagicAppPrimise) {
|
|
19542
|
+
return getTMagicAppPrimise;
|
|
19543
|
+
}
|
|
19544
|
+
getTMagicAppPrimise = new Promise((resolve) => {
|
|
19541
19545
|
const timeout = globalThis.setTimeout(() => {
|
|
19542
19546
|
resolve(void 0);
|
|
19543
19547
|
}, 1e4);
|
|
19544
|
-
renderer.
|
|
19548
|
+
renderer.once("runtime-ready", () => {
|
|
19545
19549
|
if (timeout) {
|
|
19546
19550
|
globalThis.clearTimeout(timeout);
|
|
19547
19551
|
}
|
|
19548
19552
|
resolve(renderer.runtime?.getApp?.());
|
|
19549
19553
|
});
|
|
19550
19554
|
});
|
|
19555
|
+
return getTMagicAppPrimise;
|
|
19551
19556
|
};
|
|
19552
19557
|
const updateStageNodes = (nodes) => {
|
|
19553
19558
|
for (const node of nodes) {
|
|
@@ -19978,6 +19983,19 @@
|
|
|
19978
19983
|
disabledMultiSelect: props.disabledMultiSelect
|
|
19979
19984
|
};
|
|
19980
19985
|
stageOverlayService.set("stageOptions", stageOptions);
|
|
19986
|
+
vue.watch(
|
|
19987
|
+
() => props.runtimeUrl,
|
|
19988
|
+
(url) => {
|
|
19989
|
+
if (!url) {
|
|
19990
|
+
return;
|
|
19991
|
+
}
|
|
19992
|
+
const stage = editorService.get("stage");
|
|
19993
|
+
if (!stage) {
|
|
19994
|
+
return;
|
|
19995
|
+
}
|
|
19996
|
+
stage.reloadIframe(url);
|
|
19997
|
+
}
|
|
19998
|
+
);
|
|
19981
19999
|
vue.provide("services", services);
|
|
19982
20000
|
vue.provide("codeOptions", props.codeOptions);
|
|
19983
20001
|
vue.provide("stageOptions", stageOptions);
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.5.
|
|
2
|
+
"version": "1.5.21",
|
|
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": "^6.0.0",
|
|
60
60
|
"sortablejs": "^1.15.2",
|
|
61
|
-
"@tmagic/design": "1.5.
|
|
62
|
-
"@tmagic/form": "1.5.
|
|
63
|
-
"@tmagic/
|
|
64
|
-
"@tmagic/utils": "1.5.
|
|
65
|
-
"@tmagic/
|
|
61
|
+
"@tmagic/design": "1.5.21",
|
|
62
|
+
"@tmagic/form": "1.5.21",
|
|
63
|
+
"@tmagic/stage": "1.5.21",
|
|
64
|
+
"@tmagic/utils": "1.5.21",
|
|
65
|
+
"@tmagic/table": "1.5.21"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/events": "^3.0.0",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"monaco-editor": "^0.48.0",
|
|
77
77
|
"typescript": "*",
|
|
78
78
|
"vue": ">=3.5.0",
|
|
79
|
-
"@tmagic/core": "1.5.
|
|
79
|
+
"@tmagic/core": "1.5.21"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
|
82
82
|
"typescript": {
|
package/src/Editor.vue
CHANGED
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
<script lang="ts" setup>
|
|
129
129
|
import { EventEmitter } from 'events';
|
|
130
130
|
|
|
131
|
-
import { provide } from 'vue';
|
|
131
|
+
import { provide, watch } from 'vue';
|
|
132
132
|
|
|
133
133
|
import type { MApp } from '@tmagic/core';
|
|
134
134
|
|
|
@@ -209,6 +209,22 @@ const stageOptions: StageOptions = {
|
|
|
209
209
|
|
|
210
210
|
stageOverlayService.set('stageOptions', stageOptions);
|
|
211
211
|
|
|
212
|
+
watch(
|
|
213
|
+
() => props.runtimeUrl,
|
|
214
|
+
(url) => {
|
|
215
|
+
if (!url) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const stage = editorService.get('stage');
|
|
220
|
+
if (!stage) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
stage.reloadIframe(url);
|
|
225
|
+
},
|
|
226
|
+
);
|
|
227
|
+
|
|
212
228
|
provide('services', services);
|
|
213
229
|
|
|
214
230
|
provide('codeOptions', props.codeOptions);
|
|
@@ -64,7 +64,7 @@ const methodColumns: ColumnConfig[] = [
|
|
|
64
64
|
{
|
|
65
65
|
label: '参数',
|
|
66
66
|
prop: 'params',
|
|
67
|
-
formatter: (params: CodeParamStatement[]) => params.map((item) => item.name).join(', '),
|
|
67
|
+
formatter: (params: CodeParamStatement[] = []) => params.map((item) => item.name).join(', '),
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
70
|
label: '操作',
|
|
@@ -232,7 +232,7 @@ const compActionConfig = computed(() => {
|
|
|
232
232
|
|
|
233
233
|
let methods: EventOption[] | CascaderOption[] = [];
|
|
234
234
|
|
|
235
|
-
methods = eventsService.getMethod(node.type);
|
|
235
|
+
methods = eventsService.getMethod(node.type, model.to);
|
|
236
236
|
|
|
237
237
|
if (node.type === 'page-fragment-container' && node.pageFragmentId) {
|
|
238
238
|
const pageFragment = editorService.get('root')?.items?.find((page) => page.id === node.pageFragmentId);
|
|
@@ -240,7 +240,7 @@ const compActionConfig = computed(() => {
|
|
|
240
240
|
methods = [];
|
|
241
241
|
pageFragment.items.forEach((node: MComponent | MContainer) => {
|
|
242
242
|
traverseNode<MComponent | MContainer>(node, (node) => {
|
|
243
|
-
const nodeMethods = (node.type && eventsService.getMethod(node.type)) || [];
|
|
243
|
+
const nodeMethods = (node.type && eventsService.getMethod(node.type, node.id)) || [];
|
|
244
244
|
|
|
245
245
|
if (nodeMethods.length) {
|
|
246
246
|
methods.push({
|
|
@@ -317,7 +317,7 @@ const tableConfig = computed(() => ({
|
|
|
317
317
|
const node = editorService.getNodeById(model.to);
|
|
318
318
|
if (!node?.type) return [];
|
|
319
319
|
|
|
320
|
-
return eventsService.getMethod(node.type).map((option: any) => ({
|
|
320
|
+
return eventsService.getMethod(node.type, model.to).map((option: any) => ({
|
|
321
321
|
text: option.label,
|
|
322
322
|
value: option.value,
|
|
323
323
|
}));
|
package/src/initService.ts
CHANGED
|
@@ -215,6 +215,8 @@ export const initServiceEvents = (
|
|
|
215
215
|
((event: 'update:modelValue', value: MApp | null) => void),
|
|
216
216
|
{ editorService, codeBlockService, dataSourceService, depService }: Services,
|
|
217
217
|
) => {
|
|
218
|
+
let getTMagicAppPrimise: Promise<TMagicCore | undefined> | null = null;
|
|
219
|
+
|
|
218
220
|
const getTMagicApp = (): Promise<TMagicCore | undefined> => {
|
|
219
221
|
const renderer = editorService.get('stage')?.renderer;
|
|
220
222
|
if (!renderer) {
|
|
@@ -225,19 +227,25 @@ export const initServiceEvents = (
|
|
|
225
227
|
return Promise.resolve(renderer.runtime.getApp?.());
|
|
226
228
|
}
|
|
227
229
|
|
|
228
|
-
|
|
230
|
+
if (getTMagicAppPrimise) {
|
|
231
|
+
return getTMagicAppPrimise;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
getTMagicAppPrimise = new Promise<TMagicCore | undefined>((resolve) => {
|
|
229
235
|
// 设置 10s 超时
|
|
230
236
|
const timeout = globalThis.setTimeout(() => {
|
|
231
237
|
resolve(void 0);
|
|
232
238
|
}, 10000);
|
|
233
239
|
|
|
234
|
-
renderer.
|
|
240
|
+
renderer.once('runtime-ready', () => {
|
|
235
241
|
if (timeout) {
|
|
236
242
|
globalThis.clearTimeout(timeout);
|
|
237
243
|
}
|
|
238
244
|
resolve(renderer.runtime?.getApp?.());
|
|
239
245
|
});
|
|
240
246
|
});
|
|
247
|
+
|
|
248
|
+
return getTMagicAppPrimise;
|
|
241
249
|
};
|
|
242
250
|
|
|
243
251
|
const updateStageNodes = (nodes: MComponent[]) => {
|
package/src/services/events.ts
CHANGED
|
@@ -20,7 +20,7 @@ import { reactive } from 'vue';
|
|
|
20
20
|
import { cloneDeep } from 'lodash-es';
|
|
21
21
|
import type { Writable } from 'type-fest';
|
|
22
22
|
|
|
23
|
-
import { type EventOption } from '@tmagic/core';
|
|
23
|
+
import { type EventOption, type Id } from '@tmagic/core';
|
|
24
24
|
import { toLine } from '@tmagic/utils';
|
|
25
25
|
|
|
26
26
|
import type { AsyncHookPlugin, SyncHookPlugin } from '@editor/type';
|
|
@@ -70,7 +70,7 @@ class Events extends BaseService {
|
|
|
70
70
|
methodMap[toLine(type)] = [...method];
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
public getMethod(type: string) {
|
|
73
|
+
public getMethod(type: string, _targetId: Id) {
|
|
74
74
|
return cloneDeep(methodMap[toLine(type)]) || [];
|
|
75
75
|
}
|
|
76
76
|
|
package/types/index.d.ts
CHANGED
|
@@ -540,7 +540,7 @@ declare class Events extends export_default {
|
|
|
540
540
|
getEvent(type: string): EventOption[];
|
|
541
541
|
setMethods(methods: Record<string, EventOption[]>): void;
|
|
542
542
|
setMethod(type: string, method: EventOption[]): void;
|
|
543
|
-
getMethod(type: string): EventOption[];
|
|
543
|
+
getMethod(type: string, _targetId: Id): EventOption[];
|
|
544
544
|
resetState(): void;
|
|
545
545
|
destroy(): void;
|
|
546
546
|
usePlugin(options: AsyncHookPlugin<AsyncMethodName$2, Events> & SyncHookPlugin<SyncMethodName$3, Events>): void;
|