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

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.
package/dist/style.css CHANGED
@@ -265,8 +265,11 @@
265
265
  left: 0;
266
266
  z-index: 1;
267
267
  }
268
- .magic-editor-layer-panel .search-input .el-input__suffix {
269
- padding: 10px 5px;
268
+ .magic-editor-layer-panel .search-input .el-input__prefix {
269
+ padding: 7px;
270
+ }
271
+ .magic-editor-layer-panel .magic-editor-layer-tree {
272
+ padding-top: 48px;
270
273
  }
271
274
  .magic-editor-layer-panel .node-content {
272
275
  flex: 1;
@@ -325,11 +328,11 @@
325
328
  .ui-component-panel {
326
329
  height: 100%;
327
330
  border-top: 0 !important;
328
- margin-top: 50px;
331
+ margin-top: 48px;
329
332
  background-color: #ffffff;
330
333
  }
331
334
  .ui-component-panel .search-input {
332
- background: #f8fbff;
335
+ background: #fff;
333
336
  color: #bbbbbb;
334
337
  padding: 10px;
335
338
  position: absolute;
@@ -339,10 +342,7 @@
339
342
  z-index: 1;
340
343
  }
341
344
  .ui-component-panel .search-input .el-input__prefix {
342
- padding: 10px;
343
- }
344
- .ui-component-panel .search-input .el-input__suffix {
345
- padding: 10px 5px;
345
+ padding: 7px;
346
346
  }
347
347
  .ui-component-panel .el-collapse-item > div:first-of-type {
348
348
  border-bottom: 1px solid #d9dbdd;
@@ -2,7 +2,7 @@ import { defineComponent, computed, resolveComponent, openBlock, createBlock, no
2
2
  import serialize from 'serialize-javascript';
3
3
  import { cloneDeep, map, xor, throttle, pick, isEmpty, forIn, omit, keys, mergeWith, uniq } from 'lodash-es';
4
4
  import { TMagicCard, TMagicTooltip, tMagicMessage, TMagicButton, TMagicIcon, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicDialog, TMagicInput, TMagicTree, TMagicCollapse, TMagicCollapseItem, TMagicTabPane, TMagicTabs, TMagicPopover } from '@tmagic/design';
5
- import { Delete, Close, Edit, Plus, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, View, Link, Files, DocumentCopy, EditPen, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons-vue';
5
+ import { Delete, Close, Edit, Plus, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, View, Link, Search, Files, DocumentCopy, EditPen, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons-vue';
6
6
  import * as monaco from 'monaco-editor';
7
7
  import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS, ContainerHighlightType } from '@tmagic/stage';
8
8
  import { NodeType } from '@tmagic/schema';
@@ -1765,10 +1765,10 @@ class Editor$1 extends BaseService {
1765
1765
  newConfig = setLayout(newConfig, newLayout);
1766
1766
  }
1767
1767
  parentNodeItems[index] = newConfig;
1768
- const nodes = this.get("nodes");
1768
+ const nodes = this.get("nodes") || [];
1769
1769
  const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
1770
1770
  nodes.splice(targetIndex, 1, newConfig);
1771
- this.set("nodes", nodes);
1771
+ this.set("nodes", [...nodes]);
1772
1772
  this.get("stage")?.update({
1773
1773
  config: cloneDeep(newConfig),
1774
1774
  parentId: parent.id,
@@ -2390,6 +2390,8 @@ const useStage = (stageOptions) => {
2390
2390
  getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
2391
2391
  ]);
2392
2392
  stage.on("select", (el) => {
2393
+ if (`${editorService.get("node")?.id}` === el.id)
2394
+ return;
2393
2395
  editorService.select(el.id);
2394
2396
  });
2395
2397
  stage.on("highlight", (el) => {
@@ -2605,6 +2607,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
2605
2607
  const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
2606
2608
  const { editorService, uiService } = inject("services") || {};
2607
2609
  const root = computed(() => editorService?.get("root"));
2610
+ const nodes = computed(() => editorService?.get("nodes") || []);
2608
2611
  const pageLength = computed(() => editorService?.get("pageLength") || 0);
2609
2612
  const showSrc = computed(() => uiService?.get("showSrc"));
2610
2613
  const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
@@ -2693,7 +2696,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
2693
2696
  ]),
2694
2697
  _: 2
2695
2698
  }, [
2696
- unref(pageLength) > 0 ? {
2699
+ unref(pageLength) > 0 && unref(nodes).length === 1 ? {
2697
2700
  name: "right",
2698
2701
  fn: withCtx(() => [
2699
2702
  createVNode(unref(TMagicScrollbar), null, {
@@ -3663,14 +3666,14 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
3663
3666
  }, {
3664
3667
  default: withCtx(() => [
3665
3668
  createVNode(unref(TMagicInput), {
3666
- "prefix-icon": "el-icon-search",
3667
3669
  placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
3668
3670
  class: "search-input",
3669
3671
  size: "small",
3670
3672
  clearable: "",
3673
+ "prefix-icon": unref(Search),
3671
3674
  modelValue: searchText.value,
3672
3675
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchText.value = $event)
3673
- }, null, 8, ["modelValue"]),
3676
+ }, null, 8, ["prefix-icon", "modelValue"]),
3674
3677
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(list), (group, index) => {
3675
3678
  return openBlock(), createElementBlock(Fragment, null, [
3676
3679
  group.items && group.items.length ? (openBlock(), createBlock(unref(TMagicCollapseItem), {
@@ -4040,7 +4043,15 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
4040
4043
  const filterTextChangeHandler = (val) => {
4041
4044
  tree.value?.filter(val);
4042
4045
  };
4043
- const expandNodes = () => {
4046
+ const expandNodes = async () => {
4047
+ if (!tree.value)
4048
+ return;
4049
+ await nextTick();
4050
+ tree.value && Object.entries(tree.value.getStore().nodesMap).forEach(([id, node]) => {
4051
+ if (node.expanded && node.data.items) {
4052
+ expandedKeys.set(id, id);
4053
+ }
4054
+ });
4044
4055
  expandedKeys.forEach((key) => {
4045
4056
  if (!tree.value)
4046
4057
  return;
@@ -4050,26 +4061,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
4050
4061
  watch(
4051
4062
  () => editorService?.get("nodes"),
4052
4063
  (nodes) => {
4053
- if (!tree.value)
4054
- return;
4055
- if (!editorService)
4056
- return;
4057
- if (!nodes)
4058
- return;
4059
- selectedNodes.value = nodes;
4060
- const parent = editorService.get("parent");
4061
- if (!parent?.id)
4062
- return;
4063
- const treeNode = tree.value.getNode(parent.id);
4064
- treeNode?.updateChildren();
4065
- setTimeout(() => {
4066
- tree.value && Object.entries(tree.value.getStore().nodesMap).forEach(([id, node]) => {
4067
- if (node.expanded && node.data.items) {
4068
- expandedKeys.set(id, id);
4069
- }
4070
- });
4071
- expandNodes();
4072
- });
4064
+ selectedNodes.value = nodes ?? [];
4073
4065
  }
4074
4066
  );
4075
4067
  const setTreeKeyStatus = () => {
@@ -4086,7 +4078,15 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
4086
4078
  tree.value.setCurrentKey();
4087
4079
  }
4088
4080
  };
4089
- watch(selectedIds, () => {
4081
+ watch([selectedIds, tree], async () => {
4082
+ if (!tree.value || !editorService)
4083
+ return;
4084
+ const parent = editorService.get("parent");
4085
+ if (!parent?.id)
4086
+ return;
4087
+ const treeNode = tree.value.getNode(parent.id);
4088
+ treeNode?.updateChildren();
4089
+ await expandNodes();
4090
4090
  setTreeKeyStatus();
4091
4091
  });
4092
4092
  const keycon = ref();
@@ -4173,16 +4173,18 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
4173
4173
  default: withCtx(() => [
4174
4174
  renderSlot(_ctx.$slots, "layer-panel-header"),
4175
4175
  createVNode(unref(TMagicInput), {
4176
- class: "filterInput",
4176
+ modelValue: filterText.value,
4177
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
4178
+ class: "search-input",
4177
4179
  size: "small",
4178
4180
  placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
4179
4181
  clearable: "",
4180
- modelValue: filterText.value,
4181
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
4182
+ "prefix-icon": unref(Search),
4182
4183
  onChange: filterTextChangeHandler
4183
- }, null, 8, ["modelValue"]),
4184
+ }, null, 8, ["modelValue", "prefix-icon"]),
4184
4185
  unref(values).length ? (openBlock(), createBlock(unref(TMagicTree), {
4185
4186
  key: 0,
4187
+ class: "magic-editor-layer-tree",
4186
4188
  ref_key: "tree",
4187
4189
  ref: tree,
4188
4190
  "node-key": "id",