@tmagic/editor 1.2.0-beta.5 → 1.2.0-beta.7

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.
@@ -1783,10 +1783,10 @@
1783
1783
  newConfig = setLayout(newConfig, newLayout);
1784
1784
  }
1785
1785
  parentNodeItems[index] = newConfig;
1786
- const nodes = this.get("nodes");
1786
+ const nodes = this.get("nodes") || [];
1787
1787
  const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
1788
1788
  nodes.splice(targetIndex, 1, newConfig);
1789
- this.set("nodes", nodes);
1789
+ this.set("nodes", [...nodes]);
1790
1790
  this.get("stage")?.update({
1791
1791
  config: lodashEs.cloneDeep(newConfig),
1792
1792
  parentId: parent.id,
@@ -2408,6 +2408,8 @@
2408
2408
  getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
2409
2409
  ]);
2410
2410
  stage.on("select", (el) => {
2411
+ if (`${editorService.get("node")?.id}` === el.id)
2412
+ return;
2411
2413
  editorService.select(el.id);
2412
2414
  });
2413
2415
  stage.on("highlight", (el) => {
@@ -2623,6 +2625,7 @@
2623
2625
  const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
2624
2626
  const { editorService, uiService } = vue.inject("services") || {};
2625
2627
  const root = vue.computed(() => editorService?.get("root"));
2628
+ const nodes = vue.computed(() => editorService?.get("nodes") || []);
2626
2629
  const pageLength = vue.computed(() => editorService?.get("pageLength") || 0);
2627
2630
  const showSrc = vue.computed(() => uiService?.get("showSrc"));
2628
2631
  const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
@@ -2711,7 +2714,7 @@
2711
2714
  ]),
2712
2715
  _: 2
2713
2716
  }, [
2714
- vue.unref(pageLength) > 0 ? {
2717
+ vue.unref(pageLength) > 0 && vue.unref(nodes).length === 1 ? {
2715
2718
  name: "right",
2716
2719
  fn: vue.withCtx(() => [
2717
2720
  vue.createVNode(vue.unref(design.TMagicScrollbar), null, {
@@ -3681,14 +3684,14 @@
3681
3684
  }, {
3682
3685
  default: vue.withCtx(() => [
3683
3686
  vue.createVNode(vue.unref(design.TMagicInput), {
3684
- "prefix-icon": "el-icon-search",
3685
3687
  placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
3686
3688
  class: "search-input",
3687
3689
  size: "small",
3688
3690
  clearable: "",
3691
+ "prefix-icon": vue.unref(iconsVue.Search),
3689
3692
  modelValue: searchText.value,
3690
3693
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchText.value = $event)
3691
- }, null, 8, ["modelValue"]),
3694
+ }, null, 8, ["prefix-icon", "modelValue"]),
3692
3695
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(list), (group, index) => {
3693
3696
  return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
3694
3697
  group.items && group.items.length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCollapseItem), {
@@ -4058,7 +4061,15 @@
4058
4061
  const filterTextChangeHandler = (val) => {
4059
4062
  tree.value?.filter(val);
4060
4063
  };
4061
- const expandNodes = () => {
4064
+ const expandNodes = async () => {
4065
+ if (!tree.value)
4066
+ return;
4067
+ await vue.nextTick();
4068
+ tree.value && Object.entries(tree.value.getStore().nodesMap).forEach(([id, node]) => {
4069
+ if (node.expanded && node.data.items) {
4070
+ expandedKeys.set(id, id);
4071
+ }
4072
+ });
4062
4073
  expandedKeys.forEach((key) => {
4063
4074
  if (!tree.value)
4064
4075
  return;
@@ -4068,26 +4079,7 @@
4068
4079
  vue.watch(
4069
4080
  () => editorService?.get("nodes"),
4070
4081
  (nodes) => {
4071
- if (!tree.value)
4072
- return;
4073
- if (!editorService)
4074
- return;
4075
- if (!nodes)
4076
- return;
4077
- selectedNodes.value = nodes;
4078
- const parent = editorService.get("parent");
4079
- if (!parent?.id)
4080
- return;
4081
- const treeNode = tree.value.getNode(parent.id);
4082
- treeNode?.updateChildren();
4083
- setTimeout(() => {
4084
- tree.value && Object.entries(tree.value.getStore().nodesMap).forEach(([id, node]) => {
4085
- if (node.expanded && node.data.items) {
4086
- expandedKeys.set(id, id);
4087
- }
4088
- });
4089
- expandNodes();
4090
- });
4082
+ selectedNodes.value = nodes ?? [];
4091
4083
  }
4092
4084
  );
4093
4085
  const setTreeKeyStatus = () => {
@@ -4104,7 +4096,15 @@
4104
4096
  tree.value.setCurrentKey();
4105
4097
  }
4106
4098
  };
4107
- vue.watch(selectedIds, () => {
4099
+ vue.watch([selectedIds, tree], async () => {
4100
+ if (!tree.value || !editorService)
4101
+ return;
4102
+ const parent = editorService.get("parent");
4103
+ if (!parent?.id)
4104
+ return;
4105
+ const treeNode = tree.value.getNode(parent.id);
4106
+ treeNode?.updateChildren();
4107
+ await expandNodes();
4108
4108
  setTreeKeyStatus();
4109
4109
  });
4110
4110
  const keycon = vue.ref();
@@ -4191,16 +4191,18 @@
4191
4191
  default: vue.withCtx(() => [
4192
4192
  vue.renderSlot(_ctx.$slots, "layer-panel-header"),
4193
4193
  vue.createVNode(vue.unref(design.TMagicInput), {
4194
- class: "filterInput",
4194
+ modelValue: filterText.value,
4195
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
4196
+ class: "search-input",
4195
4197
  size: "small",
4196
4198
  placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
4197
4199
  clearable: "",
4198
- modelValue: filterText.value,
4199
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
4200
+ "prefix-icon": vue.unref(iconsVue.Search),
4200
4201
  onChange: filterTextChangeHandler
4201
- }, null, 8, ["modelValue"]),
4202
+ }, null, 8, ["modelValue", "prefix-icon"]),
4202
4203
  vue.unref(values).length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTree), {
4203
4204
  key: 0,
4205
+ class: "magic-editor-layer-tree",
4204
4206
  ref_key: "tree",
4205
4207
  ref: tree,
4206
4208
  "node-key": "id",