@tmagic/editor 1.2.0-beta.17 → 1.2.0-beta.19

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,16 +1,16 @@
1
1
  import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, unref, reactive, watch, inject, createElementBlock, createVNode, ref, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, onMounted, onUnmounted, renderSlot, Fragment, createElementVNode, normalizeClass, resolveDynamicComponent, toRaw, createSlots, renderList, normalizeProps, mergeProps, markRaw, getCurrentInstance, watchEffect, provide, withDirectives, Teleport, vShow, nextTick, toHandlers } from 'vue';
2
2
  import serialize from 'serialize-javascript';
3
3
  import { isEmpty, map, throttle, pick, omit, keys, cloneDeep, forIn, mergeWith, uniq, isObject } from 'lodash-es';
4
+ import { createValues, MForm } from '@tmagic/form';
4
5
  import { HookType, NodeType } from '@tmagic/schema';
5
6
  import { Delete, Close, Edit, Plus, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, View, Link, Search, Files, CopyDocument, Coin, EditPen, ArrowLeftBold, ArrowRightBold, CaretBottom, DocumentCopy, Top, Bottom } from '@element-plus/icons-vue';
6
7
  import { TMagicButton, TMagicTooltip, TMagicIcon, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, tMagicMessage, tMagicMessageBox, TMagicCard, TMagicInput, TMagicDialog, TMagicTree, TMagicCollapse, TMagicCollapseItem, getConfig as getConfig$1, TMagicTabs, TMagicPopover } from '@tmagic/design';
7
8
  import * as monaco from 'monaco-editor';
8
- import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS, ContainerHighlightType } from '@tmagic/stage';
9
+ import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
9
10
  import Gesto from 'gesto';
10
11
  import { isPop, getNodePath, isNumber, isPage, toLine, datetimeFormatter, removeClassNameByClassName } from '@tmagic/utils';
11
12
  import { EventEmitter } from 'events';
12
13
  import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
13
- import { MForm } from '@tmagic/form';
14
14
  import KeyController from 'keycon';
15
15
 
16
16
  const __default__$t = defineComponent({
@@ -136,6 +136,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
136
136
  setup(__props, { emit }) {
137
137
  const props = __props;
138
138
  const services = inject("services");
139
+ const mForm = inject("mForm");
139
140
  const codeDsl = computed(() => services?.codeBlockService.getCodeDslSync());
140
141
  const tableConfig = computed(() => {
141
142
  const defaultConfig = {
@@ -166,7 +167,15 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
166
167
  name: "params",
167
168
  label: "\u53C2\u6570",
168
169
  defaultValue: {},
169
- itemsFunction: (row) => getParamsConfig(row.codeId)
170
+ itemsFunction: (row) => {
171
+ const paramsConfig = getParamsConfig(row.codeId);
172
+ if (!row.params)
173
+ row.params = {};
174
+ if (isEmpty(row.params)) {
175
+ createValues(mForm, paramsConfig, {}, row.params);
176
+ }
177
+ return paramsConfig;
178
+ }
170
179
  }
171
180
  ]
172
181
  };
@@ -1151,6 +1160,7 @@ class History extends BaseService {
1151
1160
  this.state.pageSteps[this.state.pageId] = undoRedo;
1152
1161
  }
1153
1162
  this.setCanUndoRedo();
1163
+ this.emit("page-change", this.state.pageSteps[this.state.pageId]);
1154
1164
  }
1155
1165
  empty() {
1156
1166
  this.state.pageId = void 0;
@@ -1481,7 +1491,7 @@ class Props extends BaseService {
1481
1491
  this.setPropsValue(toLine(type), values[type]);
1482
1492
  });
1483
1493
  }
1484
- setPropsValue(type, value) {
1494
+ async setPropsValue(type, value) {
1485
1495
  this.state.propsValueMap[type] = value;
1486
1496
  }
1487
1497
  async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
@@ -2566,7 +2576,7 @@ const useStage = (stageOptions) => {
2566
2576
  stage.on("highlight", (el) => {
2567
2577
  editorService.highlight(el.id);
2568
2578
  });
2569
- stage.on("multiSelect", (els) => {
2579
+ stage.on("multi-select", (els) => {
2570
2580
  editorService.multiSelect(els.map((el) => el.id));
2571
2581
  });
2572
2582
  stage.on("update", (ev) => {
@@ -2586,7 +2596,7 @@ const useStage = (stageOptions) => {
2586
2596
  editorService.select(parent);
2587
2597
  editorService.get("stage").select(parent.id);
2588
2598
  });
2589
- stage.on("changeGuides", (e) => {
2599
+ stage.on("change-guides", (e) => {
2590
2600
  uiService.set("showGuides", true);
2591
2601
  if (!root.value || !page.value)
2592
2602
  return;
@@ -5463,6 +5473,14 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
5463
5473
  runtime.updateRootConfig?.(cloneDeep(toRaw(root2)));
5464
5474
  }
5465
5475
  });
5476
+ watch(page, (page2) => {
5477
+ if (runtime && page2) {
5478
+ runtime.updatePageId?.(page2.id);
5479
+ nextTick(() => {
5480
+ stage?.select(page2.id);
5481
+ });
5482
+ }
5483
+ });
5466
5484
  const resizeObserver = new ResizeObserver((entries) => {
5467
5485
  for (const { contentRect } of entries) {
5468
5486
  services?.uiService.set("stageContainerRect", {
@@ -5684,10 +5702,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
5684
5702
  }, [
5685
5703
  createVNode(_sfc_main$8),
5686
5704
  renderSlot(_ctx.$slots, "stage", {}, () => [
5687
- (openBlock(), createBlock(_sfc_main$2, {
5688
- key: unref(page)?.id,
5705
+ unref(page) ? (openBlock(), createBlock(_sfc_main$2, {
5706
+ key: 0,
5689
5707
  "stage-content-menu": __props.stageContentMenu
5690
- }, null, 8, ["stage-content-menu"]))
5708
+ }, null, 8, ["stage-content-menu"])) : createCommentVNode("", true)
5691
5709
  ]),
5692
5710
  renderSlot(_ctx.$slots, "workspace-content"),
5693
5711
  createVNode(_sfc_main$6, null, {
@@ -5746,6 +5764,10 @@ const _sfc_main = defineComponent({
5746
5764
  sidebar: {
5747
5765
  type: Object
5748
5766
  },
5767
+ menu: {
5768
+ type: Object,
5769
+ default: () => ({ left: [], right: [] })
5770
+ },
5749
5771
  layerContentMenu: {
5750
5772
  type: Array,
5751
5773
  default: () => []
@@ -5754,10 +5776,6 @@ const _sfc_main = defineComponent({
5754
5776
  type: Array,
5755
5777
  default: () => []
5756
5778
  },
5757
- menu: {
5758
- type: Object,
5759
- default: () => ({ left: [], right: [] })
5760
- },
5761
5779
  render: {
5762
5780
  type: Function
5763
5781
  },
@@ -5791,7 +5809,7 @@ const _sfc_main = defineComponent({
5791
5809
  },
5792
5810
  containerHighlightClassName: {
5793
5811
  type: String,
5794
- default: CONTAINER_HIGHLIGHT_CLASS
5812
+ default: CONTAINER_HIGHLIGHT_CLASS_NAME
5795
5813
  },
5796
5814
  containerHighlightDuration: {
5797
5815
  type: Number,