@tmagic/editor 1.5.20 → 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.
@@ -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() {
@@ -15190,6 +15190,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
15190
15190
  disabledMultiSelect: props.disabledMultiSelect
15191
15191
  };
15192
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
+ );
15193
15206
  provide("services", services);
15194
15207
  provide("codeOptions", props.codeOptions);
15195
15208
  provide("stageOptions", stageOptions);
@@ -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() {
@@ -19983,6 +19983,19 @@
19983
19983
  disabledMultiSelect: props.disabledMultiSelect
19984
19984
  };
19985
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
+ );
19986
19999
  vue.provide("services", services);
19987
20000
  vue.provide("codeOptions", props.codeOptions);
19988
20001
  vue.provide("stageOptions", stageOptions);
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.20",
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.20",
62
- "@tmagic/stage": "1.5.20",
63
- "@tmagic/form": "1.5.20",
64
- "@tmagic/table": "1.5.20",
65
- "@tmagic/utils": "1.5.20"
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.20"
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);
@@ -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
  }));
@@ -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;