@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.
@@ -199,19 +199,21 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
199
199
  onClick: startSelect,
200
200
  style: { "display": "flex" }
201
201
  }, [
202
- createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
202
+ unref(val) ? (openBlock(), createBlock(_component_el_tooltip, {
203
+ key: 0,
204
+ content: "\u6E05\u9664"
205
+ }, {
203
206
  default: withCtx(() => [
204
- unref(val) ? (openBlock(), createBlock(_component_el_button, {
205
- key: 0,
207
+ createVNode(_component_el_button, {
206
208
  style: { "padding": "0" },
207
209
  type: "danger",
208
210
  icon: unref(Close),
209
211
  text: "",
210
212
  onClick: withModifiers(deleteHandler, ["stop"])
211
- }, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
213
+ }, null, 8, ["icon", "onClick"])
212
214
  ]),
213
215
  _: 1
214
- }),
216
+ })) : createCommentVNode("", true),
215
217
  createVNode(_component_el_tooltip, {
216
218
  content: unref(val) ? unref(toName) + "_" + unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
217
219
  }, {
@@ -2837,20 +2839,38 @@ const useDrop = (tree, editorService) => ({
2837
2839
  }
2838
2840
  });
2839
2841
  const useStatus = (tree, editorService) => {
2840
- const highlightNode = ref();
2841
2842
  const node = ref();
2842
2843
  const page = computed(() => editorService?.get("page"));
2844
+ const expandedKeys = /* @__PURE__ */ new Map();
2845
+ const expandNodes = () => {
2846
+ expandedKeys.forEach((key) => {
2847
+ if (!tree.value)
2848
+ return;
2849
+ tree.value.getNode(key)?.expand();
2850
+ });
2851
+ };
2843
2852
  watchEffect(() => {
2844
2853
  if (!tree.value)
2845
2854
  return;
2846
- node.value = editorService?.get("node");
2847
- node.value && tree.value.setCurrentKey(node.value.id, true);
2848
- const parent = editorService?.get("parent");
2855
+ if (!editorService)
2856
+ return;
2857
+ node.value = editorService.get("node");
2858
+ if (!node.value)
2859
+ return;
2860
+ tree.value.setCurrentKey(node.value.id, true);
2861
+ const parent = editorService.get("parent");
2849
2862
  if (!parent?.id)
2850
2863
  return;
2851
2864
  const treeNode = tree.value.getNode(parent.id);
2852
2865
  treeNode?.updateChildren();
2853
- highlightNode.value = editorService?.get("highlightNode");
2866
+ setTimeout(() => {
2867
+ tree.value && Object.entries(tree.value.store.nodesMap).forEach(([id, node2]) => {
2868
+ if (node2.expanded && node2.data.items) {
2869
+ expandedKeys.set(id, id);
2870
+ }
2871
+ });
2872
+ expandNodes();
2873
+ });
2854
2874
  });
2855
2875
  return {
2856
2876
  values: computed(() => page.value ? [page.value] : []),
@@ -2863,9 +2883,18 @@ const useStatus = (tree, editorService) => {
2863
2883
  }
2864
2884
  resolve([]);
2865
2885
  },
2866
- highlightNode,
2886
+ highlightNode: computed(() => editorService?.get("highlightNode")),
2867
2887
  clickNode: node,
2868
- expandedKeys: computed(() => node.value ? [node.value.id] : [])
2888
+ expandedKeys: computed(() => node.value ? [node.value.id] : []),
2889
+ handleCollapse: (data) => {
2890
+ expandedKeys.delete(data.id);
2891
+ },
2892
+ handleExpand: (data) => {
2893
+ const parent = editorService?.getParentById(data.id);
2894
+ if (!parent?.id)
2895
+ return;
2896
+ expandedKeys.set(parent.id, parent.id);
2897
+ }
2869
2898
  };
2870
2899
  };
2871
2900
  const useFilter = (tree) => ({
@@ -2956,6 +2985,7 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2956
2985
  key: 0,
2957
2986
  ref: "tree",
2958
2987
  "node-key": "id",
2988
+ "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
2959
2989
  draggable: "",
2960
2990
  "default-expanded-keys": _ctx.expandedKeys,
2961
2991
  load: _ctx.loadItems,
@@ -2970,7 +3000,8 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2970
3000
  onNodeClick: _ctx.clickHandler,
2971
3001
  onNodeContextmenu: _ctx.contextmenu,
2972
3002
  onNodeDragEnd: _ctx.handleDragEnd,
2973
- "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684"
3003
+ onNodeCollapse: _ctx.handleCollapse,
3004
+ onNodeExpand: _ctx.handleExpand
2974
3005
  }, {
2975
3006
  default: withCtx(({ node, data }) => [
2976
3007
  createElementVNode("div", {
@@ -2989,7 +3020,7 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2989
3020
  ], 42, _hoisted_1$4)
2990
3021
  ]),
2991
3022
  _: 3
2992
- }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : createCommentVNode("", true),
3023
+ }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : createCommentVNode("", true),
2993
3024
  (openBlock(), createBlock(Teleport, { to: "body" }, [
2994
3025
  createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
2995
3026
  ]))