@tmagic/editor 1.1.0-beta.10 → 1.1.0-beta.11

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.
@@ -217,19 +217,21 @@
217
217
  onClick: startSelect,
218
218
  style: { "display": "flex" }
219
219
  }, [
220
- vue.createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
220
+ vue.unref(val) ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
221
+ key: 0,
222
+ content: "\u6E05\u9664"
223
+ }, {
221
224
  default: vue.withCtx(() => [
222
- vue.unref(val) ? (vue.openBlock(), vue.createBlock(_component_el_button, {
223
- key: 0,
225
+ vue.createVNode(_component_el_button, {
224
226
  style: { "padding": "0" },
225
227
  type: "danger",
226
228
  icon: vue.unref(iconsVue.Close),
227
229
  text: "",
228
230
  onClick: vue.withModifiers(deleteHandler, ["stop"])
229
- }, null, 8, ["icon", "onClick"])) : vue.createCommentVNode("", true)
231
+ }, null, 8, ["icon", "onClick"])
230
232
  ]),
231
233
  _: 1
232
- }),
234
+ })) : vue.createCommentVNode("", true),
233
235
  vue.createVNode(_component_el_tooltip, {
234
236
  content: vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
235
237
  }, {
@@ -2855,20 +2857,38 @@
2855
2857
  }
2856
2858
  });
2857
2859
  const useStatus = (tree, editorService) => {
2858
- const highlightNode = vue.ref();
2859
2860
  const node = vue.ref();
2860
2861
  const page = vue.computed(() => editorService?.get("page"));
2862
+ const expandedKeys = /* @__PURE__ */ new Map();
2863
+ const expandNodes = () => {
2864
+ expandedKeys.forEach((key) => {
2865
+ if (!tree.value)
2866
+ return;
2867
+ tree.value.getNode(key)?.expand();
2868
+ });
2869
+ };
2861
2870
  vue.watchEffect(() => {
2862
2871
  if (!tree.value)
2863
2872
  return;
2864
- node.value = editorService?.get("node");
2865
- node.value && tree.value.setCurrentKey(node.value.id, true);
2866
- const parent = editorService?.get("parent");
2873
+ if (!editorService)
2874
+ return;
2875
+ node.value = editorService.get("node");
2876
+ if (!node.value)
2877
+ return;
2878
+ tree.value.setCurrentKey(node.value.id, true);
2879
+ const parent = editorService.get("parent");
2867
2880
  if (!parent?.id)
2868
2881
  return;
2869
2882
  const treeNode = tree.value.getNode(parent.id);
2870
2883
  treeNode?.updateChildren();
2871
- highlightNode.value = editorService?.get("highlightNode");
2884
+ setTimeout(() => {
2885
+ tree.value && Object.entries(tree.value.store.nodesMap).forEach(([id, node2]) => {
2886
+ if (node2.expanded && node2.data.items) {
2887
+ expandedKeys.set(id, id);
2888
+ }
2889
+ });
2890
+ expandNodes();
2891
+ });
2872
2892
  });
2873
2893
  return {
2874
2894
  values: vue.computed(() => page.value ? [page.value] : []),
@@ -2881,9 +2901,18 @@
2881
2901
  }
2882
2902
  resolve([]);
2883
2903
  },
2884
- highlightNode,
2904
+ highlightNode: vue.computed(() => editorService?.get("highlightNode")),
2885
2905
  clickNode: node,
2886
- expandedKeys: vue.computed(() => node.value ? [node.value.id] : [])
2906
+ expandedKeys: vue.computed(() => node.value ? [node.value.id] : []),
2907
+ handleCollapse: (data) => {
2908
+ expandedKeys.delete(data.id);
2909
+ },
2910
+ handleExpand: (data) => {
2911
+ const parent = editorService?.getParentById(data.id);
2912
+ if (!parent?.id)
2913
+ return;
2914
+ expandedKeys.set(parent.id, parent.id);
2915
+ }
2887
2916
  };
2888
2917
  };
2889
2918
  const useFilter = (tree) => ({
@@ -2974,6 +3003,7 @@
2974
3003
  key: 0,
2975
3004
  ref: "tree",
2976
3005
  "node-key": "id",
3006
+ "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
2977
3007
  draggable: "",
2978
3008
  "default-expanded-keys": _ctx.expandedKeys,
2979
3009
  load: _ctx.loadItems,
@@ -2988,7 +3018,8 @@
2988
3018
  onNodeClick: _ctx.clickHandler,
2989
3019
  onNodeContextmenu: _ctx.contextmenu,
2990
3020
  onNodeDragEnd: _ctx.handleDragEnd,
2991
- "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684"
3021
+ onNodeCollapse: _ctx.handleCollapse,
3022
+ onNodeExpand: _ctx.handleExpand
2992
3023
  }, {
2993
3024
  default: vue.withCtx(({ node, data }) => [
2994
3025
  vue.createElementVNode("div", {
@@ -3007,7 +3038,7 @@
3007
3038
  ], 42, _hoisted_1$4)
3008
3039
  ]),
3009
3040
  _: 3
3010
- }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : vue.createCommentVNode("", true),
3041
+ }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : vue.createCommentVNode("", true),
3011
3042
  (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
3012
3043
  vue.createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
3013
3044
  ]))