@tmagic/editor 1.3.7 → 1.3.9

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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('monaco-editor'), require('serialize-javascript'), require('@tmagic/design'), require('@tmagic/schema'), require('@tmagic/form'), require('@tmagic/table'), require('@tmagic/utils'), require('gesto'), require('moveable'), require('@tmagic/dep'), require('@tmagic/stage'), require('events'), require('@tmagic/core'), require('keycon')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', 'monaco-editor', 'serialize-javascript', '@tmagic/design', '@tmagic/schema', '@tmagic/form', '@tmagic/table', '@tmagic/utils', 'gesto', 'moveable', '@tmagic/dep', '@tmagic/stage', 'events', '@tmagic/core', 'keycon'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.iconsVue, global.lodashEs, global.monaco, global.serialize, global.design, global.schema, global.form, global.table, global.utils, global.Gesto, global.Moveable, global.dep, global.StageCore, global.events, global.core, global.KeyController));
5
- })(this, (function (exports, vue, iconsVue, lodashEs, monaco, serialize, design, schema, form, table, utils, Gesto, Moveable, dep, StageCore, events, core, KeyController) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('serialize-javascript'), require('@tmagic/design'), require('emmet-monaco-es'), require('monaco-editor'), require('@tmagic/schema'), require('@tmagic/form'), require('@tmagic/table'), require('@tmagic/utils'), require('gesto'), require('moveable'), require('@tmagic/dep'), require('@tmagic/stage'), require('events'), require('@tmagic/core'), require('keycon')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', 'serialize-javascript', '@tmagic/design', 'emmet-monaco-es', 'monaco-editor', '@tmagic/schema', '@tmagic/form', '@tmagic/table', '@tmagic/utils', 'gesto', 'moveable', '@tmagic/dep', '@tmagic/stage', 'events', '@tmagic/core', 'keycon'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.iconsVue, global.lodashEs, global.serialize, global.design, global.emmetMonacoEs, global.monaco, global.schema, global.form, global.table, global.utils, global.Gesto, global.Moveable, global.dep, global.StageCore, global.events, global.core, global.KeyController));
5
+ })(this, (function (exports, vue, iconsVue, lodashEs, serialize, design, emmetMonacoEs, monaco, schema, form, table, utils, Gesto, Moveable, dep, StageCore, events, core, KeyController) { 'use strict';
6
6
 
7
7
  function _interopNamespaceDefault(e) {
8
8
  const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
@@ -29,6 +29,9 @@
29
29
  };
30
30
  const getConfig = (key) => $TMAGIC_EDITOR[key];
31
31
 
32
+ emmetMonacoEs.emmetHTML(monaco__namespace);
33
+ emmetMonacoEs.emmetCSS(monaco__namespace, ["css", "scss"]);
34
+
32
35
  const _hoisted_1$t = {
33
36
  class: /* @__PURE__ */ vue.normalizeClass(`magic-code-editor`)
34
37
  };
@@ -1139,6 +1142,22 @@
1139
1142
  events: {},
1140
1143
  methods: {}
1141
1144
  });
1145
+ constructor() {
1146
+ super([
1147
+ { name: "getFormConfig", isAsync: false },
1148
+ { name: "setFormConfig", isAsync: false },
1149
+ { name: "getFormValue", isAsync: false },
1150
+ { name: "setFormValue", isAsync: false },
1151
+ { name: "getFormEvent", isAsync: false },
1152
+ { name: "setFormEvent", isAsync: false },
1153
+ { name: "getFormMethod", isAsync: false },
1154
+ { name: "setFormMethod", isAsync: false },
1155
+ { name: "add", isAsync: false },
1156
+ { name: "update", isAsync: false },
1157
+ { name: "remove", isAsync: false },
1158
+ { name: "createId", isAsync: false }
1159
+ ]);
1160
+ }
1142
1161
  set(name, value) {
1143
1162
  this.state[name] = value;
1144
1163
  }
@@ -1824,6 +1843,9 @@
1824
1843
  clear(nodes) {
1825
1844
  return this.watcher.clear(nodes);
1826
1845
  }
1846
+ clearByType(type, nodes) {
1847
+ return this.watcher.clearByType(type, nodes);
1848
+ }
1827
1849
  hasTarget(id, type = dep.DepTargetType.DEFAULT) {
1828
1850
  return this.watcher.hasTarget(id, type);
1829
1851
  }
@@ -2240,11 +2262,11 @@
2240
2262
  if (!targetConfig)
2241
2263
  return;
2242
2264
  target.deps[config.id]?.keys?.forEach((fullKey) => {
2243
- const relateOriginId = lodashEs.get(config, fullKey);
2265
+ const relateOriginId = utils.getValueByKeyPath(fullKey, config);
2244
2266
  const relateTargetId = relateIdMap[relateOriginId];
2245
2267
  if (!relateTargetId)
2246
2268
  return;
2247
- lodashEs.set(targetConfig, fullKey, relateTargetId);
2269
+ utils.setValueByKeyPath(fullKey, relateTargetId, targetConfig);
2248
2270
  });
2249
2271
  });
2250
2272
  }
@@ -2770,7 +2792,7 @@
2770
2792
  */
2771
2793
  copyWithRelated(config) {
2772
2794
  const copyNodes = Array.isArray(config) ? config : [config];
2773
- depService.getTarget(dep.DepTargetType.RELATED_COMP_WHEN_COPY, dep.DepTargetType.RELATED_COMP_WHEN_COPY)?.removeDep();
2795
+ depService.clearByType(dep.DepTargetType.RELATED_COMP_WHEN_COPY);
2774
2796
  depService.collect(copyNodes, true, dep.DepTargetType.RELATED_COMP_WHEN_COPY);
2775
2797
  const customTarget = depService.getTarget(
2776
2798
  dep.DepTargetType.RELATED_COMP_WHEN_COPY,
@@ -2884,14 +2906,19 @@
2884
2906
  const index = brothers.findIndex((item) => `${item.id}` === `${node?.id}`);
2885
2907
  const layout = await this.getLayout(parent, node);
2886
2908
  const isRelative = layout === Layout.RELATIVE;
2887
- brothers.splice(index, 1);
2909
+ let offsetIndex;
2888
2910
  if (offset === LayerOffset.TOP) {
2889
- brothers.splice(isRelative ? 0 : brothers.length, 0, node);
2911
+ offsetIndex = isRelative ? 0 : brothers.length;
2890
2912
  } else if (offset === LayerOffset.BOTTOM) {
2891
- brothers.splice(isRelative ? brothers.length : 0, 0, node);
2913
+ offsetIndex = isRelative ? brothers.length : 0;
2892
2914
  } else {
2893
- brothers.splice(index + (isRelative ? -offset : offset), 0, node);
2915
+ offsetIndex = index + (isRelative ? -offset : offset);
2894
2916
  }
2917
+ if (offsetIndex > 0 && offsetIndex > brothers.length || offsetIndex < 0) {
2918
+ return;
2919
+ }
2920
+ brothers.splice(index, 1);
2921
+ brothers.splice(offsetIndex, 0, node);
2895
2922
  const grandparent = this.getParentById(parent.id);
2896
2923
  this.get("stage")?.update({
2897
2924
  config: lodashEs.cloneDeep(vue.toRaw(parent)),
@@ -2900,6 +2927,7 @@
2900
2927
  });
2901
2928
  this.addModifiedNodeId(parent.id);
2902
2929
  this.pushHistoryState();
2930
+ this.emit("move-layer", offset);
2903
2931
  }
2904
2932
  /**
2905
2933
  * 移动到指定容器中
@@ -5091,8 +5119,8 @@
5091
5119
  options: () => {
5092
5120
  if (pageList.value) {
5093
5121
  return pageList.value.map((item) => ({
5094
- text: `${item.name}(${item.id})`,
5095
- label: `${item.name}(${item.id})`,
5122
+ text: `${item.devconfig?.tabName || item.title || item.name}(${item.id})`,
5123
+ label: `${item.devconfig?.tabName || item.title || item.name}(${item.id})`,
5096
5124
  value: item.id
5097
5125
  }));
5098
5126
  }
@@ -5102,6 +5130,9 @@
5102
5130
  const changeHandler = async () => {
5103
5131
  emit("change", props.model[props.name]);
5104
5132
  };
5133
+ const editPageFragment = (id) => {
5134
+ services?.editorService.select(id);
5135
+ };
5105
5136
  return (_ctx, _cache) => {
5106
5137
  const _component_m_form_container = vue.resolveComponent("m-form-container");
5107
5138
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$h, [
@@ -5112,7 +5143,13 @@
5112
5143
  model: _ctx.model,
5113
5144
  size: _ctx.size,
5114
5145
  onChange: changeHandler
5115
- }, null, 8, ["model", "size"])
5146
+ }, null, 8, ["model", "size"]),
5147
+ _ctx.model[_ctx.name] ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
5148
+ key: 0,
5149
+ class: "icon",
5150
+ icon: vue.unref(iconsVue.Edit),
5151
+ onClick: _cache[0] || (_cache[0] = ($event) => editPageFragment(_ctx.model[_ctx.name]))
5152
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true)
5116
5153
  ])
5117
5154
  ]);
5118
5155
  };
@@ -6188,15 +6225,17 @@
6188
6225
  page.value ? vue.renderSlot(_ctx.$slots, "workspace", { key: 0 }) : vue.renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
6189
6226
  vue.createVNode(_sfc_main$s, { "disabled-page-fragment": _ctx.disabledPageFragment }, null, 8, ["disabled-page-fragment"])
6190
6227
  ]),
6191
- vue.createVNode(_sfc_main$t, { "disabled-page-fragment": _ctx.disabledPageFragment }, {
6192
- "page-bar-title": vue.withCtx(({ page: page2 }) => [
6193
- vue.renderSlot(_ctx.$slots, "page-bar-title", { page: page2 })
6194
- ]),
6195
- "page-bar-popover": vue.withCtx(({ page: page2 }) => [
6196
- vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: page2 })
6197
- ]),
6198
- _: 3
6199
- }, 8, ["disabled-page-fragment"])
6228
+ vue.renderSlot(_ctx.$slots, "page-bar", {}, () => [
6229
+ vue.createVNode(_sfc_main$t, { "disabled-page-fragment": _ctx.disabledPageFragment }, {
6230
+ "page-bar-title": vue.withCtx(({ page: page2 }) => [
6231
+ vue.renderSlot(_ctx.$slots, "page-bar-title", { page: page2 })
6232
+ ]),
6233
+ "page-bar-popover": vue.withCtx(({ page: page2 }) => [
6234
+ vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: page2 })
6235
+ ]),
6236
+ _: 3
6237
+ }, 8, ["disabled-page-fragment"])
6238
+ ])
6200
6239
  ]),
6201
6240
  _: 2
6202
6241
  }, [
@@ -6405,7 +6444,7 @@
6405
6444
  props: {
6406
6445
  extendState: { type: Function }
6407
6446
  },
6408
- emits: ["mounted"],
6447
+ emits: ["mounted", "submit-error", "form-error"],
6409
6448
  setup(__props, { expose: __expose, emit: __emit }) {
6410
6449
  const emit = __emit;
6411
6450
  const internalInstance = vue.getCurrentInstance();
@@ -6444,11 +6483,12 @@
6444
6483
  const values2 = await configForm.value?.submitForm();
6445
6484
  services?.editorService.update(values2);
6446
6485
  } catch (e) {
6447
- console.error(e);
6448
- design.tMagicMessage.closeAll();
6449
- design.tMagicMessage.error(e.message);
6486
+ emit("submit-error", e);
6450
6487
  }
6451
6488
  };
6489
+ const errorHandler = (e) => {
6490
+ emit("form-error", e);
6491
+ };
6452
6492
  __expose({ configForm, submit });
6453
6493
  return (_ctx, _cache) => {
6454
6494
  return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
@@ -6462,7 +6502,8 @@
6462
6502
  "init-values": values.value,
6463
6503
  config: curFormConfig.value,
6464
6504
  "extend-state": _ctx.extendState,
6465
- onChange: submit
6505
+ onChange: submit,
6506
+ onError: errorHandler
6466
6507
  }, null, 8, ["class", "popper-class", "size", "init-values", "config", "extend-state"])
6467
6508
  ], 512)), [
6468
6509
  [vue.vShow, nodes.value.length === 1]
@@ -6777,7 +6818,10 @@
6777
6818
  }
6778
6819
  });
6779
6820
 
6780
- const _hoisted_1$9 = { key: 1 };
6821
+ const _hoisted_1$9 = {
6822
+ key: 1,
6823
+ class: "m-editor-tree-empty"
6824
+ };
6781
6825
  const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
6782
6826
  ...{
6783
6827
  name: "MEditorTree"
@@ -10818,7 +10862,7 @@
10818
10862
  disabledPageFragment: { type: Boolean },
10819
10863
  customContentMenu: { type: Function }
10820
10864
  }, defaultEditorProps),
10821
- emits: ["props-panel-mounted", "update:modelValue"],
10865
+ emits: ["props-panel-mounted", "update:modelValue", "props-form-error", "props-submit-error"],
10822
10866
  setup(__props, { expose: __expose, emit: __emit }) {
10823
10867
  const emit = __emit;
10824
10868
  const props = __props;
@@ -10938,7 +10982,9 @@
10938
10982
  vue.renderSlot(_ctx.$slots, "props-panel", {}, () => [
10939
10983
  vue.createVNode(_sfc_main$p, {
10940
10984
  "extend-state": _ctx.extendFormState,
10941
- onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance))
10985
+ onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance)),
10986
+ onFormError: _cache[1] || (_cache[1] = (e) => _ctx.$emit("props-form-error", e)),
10987
+ onSubmitError: _cache[2] || (_cache[2] = (e) => _ctx.$emit("props-submit-error", e))
10942
10988
  }, {
10943
10989
  "props-panel-header": vue.withCtx(() => [
10944
10990
  vue.renderSlot(_ctx.$slots, "props-panel-header")
@@ -10956,6 +11002,9 @@
10956
11002
  footer: vue.withCtx(() => [
10957
11003
  vue.renderSlot(_ctx.$slots, "footer")
10958
11004
  ]),
11005
+ "page-bar": vue.withCtx(() => [
11006
+ vue.renderSlot(_ctx.$slots, "page-bar")
11007
+ ]),
10959
11008
  "page-bar-title": vue.withCtx(({ page }) => [
10960
11009
  vue.renderSlot(_ctx.$slots, "page-bar-title", { page })
10961
11010
  ]),