@tmagic/editor 1.2.12 → 1.2.14

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.
Files changed (99) hide show
  1. package/dist/style.css +61 -39
  2. package/dist/tmagic-editor.js +890 -518
  3. package/dist/tmagic-editor.js.map +1 -1
  4. package/dist/tmagic-editor.umd.cjs +909 -544
  5. package/dist/tmagic-editor.umd.cjs.map +1 -1
  6. package/package.json +14 -13
  7. package/src/components/CodeDraftEditor.vue +20 -17
  8. package/src/components/ContentMenu.vue +1 -1
  9. package/src/components/FunctionEditor.vue +10 -10
  10. package/src/components/Layout.vue +1 -1
  11. package/src/components/ScrollViewer.vue +2 -2
  12. package/src/components/SearchInput.vue +26 -0
  13. package/src/fields/CodeSelect.vue +18 -101
  14. package/src/fields/CodeSelectCol.vue +21 -3
  15. package/src/fields/EventSelect.vue +5 -3
  16. package/src/fields/UISelect.vue +1 -1
  17. package/src/icons/AppManageIcon.vue +11 -0
  18. package/src/icons/CodeIcon.vue +35 -0
  19. package/src/layouts/AddPageBox.vue +3 -3
  20. package/src/layouts/Framework.vue +4 -4
  21. package/src/layouts/NavMenu.vue +2 -2
  22. package/src/layouts/PropsPanel.vue +1 -1
  23. package/src/layouts/sidebar/ComponentListPanel.vue +11 -12
  24. package/src/layouts/sidebar/LayerMenu.vue +2 -2
  25. package/src/layouts/sidebar/LayerPanel.vue +6 -15
  26. package/src/layouts/sidebar/Sidebar.vue +3 -3
  27. package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +22 -10
  28. package/src/layouts/sidebar/code-block/CodeBlockList.vue +56 -51
  29. package/src/layouts/workspace/Breadcrumb.vue +1 -1
  30. package/src/layouts/workspace/PageBar.vue +2 -2
  31. package/src/layouts/workspace/PageBarScrollContainer.vue +3 -3
  32. package/src/layouts/workspace/Stage.vue +3 -3
  33. package/src/layouts/workspace/ViewerMenu.vue +4 -4
  34. package/src/layouts/workspace/Workspace.vue +1 -1
  35. package/src/services/BaseService.ts +1 -1
  36. package/src/services/codeBlock.ts +10 -13
  37. package/src/services/componentList.ts +1 -1
  38. package/src/services/editor.ts +6 -6
  39. package/src/services/events.ts +1 -1
  40. package/src/services/history.ts +2 -2
  41. package/src/services/props.ts +2 -2
  42. package/src/services/ui.ts +2 -2
  43. package/src/theme/code-block.scss +42 -11
  44. package/src/theme/component-list-panel.scss +0 -15
  45. package/src/theme/event.scss +12 -0
  46. package/src/theme/layer-panel.scss +0 -14
  47. package/src/theme/search-input.scss +14 -0
  48. package/src/theme/theme.scss +1 -0
  49. package/src/utils/config.ts +1 -1
  50. package/src/utils/dep.ts +2 -2
  51. package/src/utils/editor.ts +1 -1
  52. package/src/utils/operator.ts +4 -4
  53. package/src/utils/stage.ts +3 -3
  54. package/tsconfig.build.json +4 -1
  55. package/types/components/CodeDraftEditor.vue.d.ts +7 -4
  56. package/types/components/ContentMenu.vue.d.ts +3 -3
  57. package/types/components/FunctionEditor.vue.d.ts +140 -8
  58. package/types/components/Icon.vue.d.ts +2 -2
  59. package/types/components/Layout.vue.d.ts +28 -113
  60. package/types/components/ScrollBar.vue.d.ts +2 -2
  61. package/types/components/ScrollViewer.vue.d.ts +32 -135
  62. package/types/components/SearchInput.vue.d.ts +4 -0
  63. package/types/components/ToolButton.vue.d.ts +3 -3
  64. package/types/fields/Code.vue.d.ts +2 -2
  65. package/types/fields/CodeLink.vue.d.ts +2 -2
  66. package/types/fields/CodeSelect.vue.d.ts +8 -27
  67. package/types/fields/CodeSelectCol.vue.d.ts +3 -3
  68. package/types/fields/EventSelect.vue.d.ts +3 -3
  69. package/types/fields/UISelect.vue.d.ts +2 -2
  70. package/types/icons/AppManageIcon.vue.d.ts +2 -0
  71. package/types/icons/CodeIcon.vue.d.ts +2 -0
  72. package/types/layouts/CodeEditor.vue.d.ts +4 -4
  73. package/types/layouts/Framework.vue.d.ts +23 -74
  74. package/types/layouts/NavMenu.vue.d.ts +3 -3
  75. package/types/layouts/PropsPanel.vue.d.ts +11 -60
  76. package/types/layouts/Resizer.vue.d.ts +9 -54
  77. package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +11 -50
  78. package/types/layouts/sidebar/LayerMenu.vue.d.ts +2 -2
  79. package/types/layouts/sidebar/LayerPanel.vue.d.ts +17 -60
  80. package/types/layouts/sidebar/Sidebar.vue.d.ts +39 -104
  81. package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +15 -58
  82. package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +21 -66
  83. package/types/layouts/workspace/PageBar.vue.d.ts +13 -52
  84. package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +8 -48
  85. package/types/layouts/workspace/Stage.vue.d.ts +2 -2
  86. package/types/layouts/workspace/ViewerMenu.vue.d.ts +3 -3
  87. package/types/layouts/workspace/Workspace.vue.d.ts +20 -63
  88. package/types/services/codeBlock.d.ts +4 -4
  89. package/types/services/componentList.d.ts +1 -1
  90. package/types/services/dep.d.ts +2 -2
  91. package/types/services/editor.d.ts +1 -1
  92. package/types/services/events.d.ts +1 -1
  93. package/types/services/history.d.ts +2 -2
  94. package/types/services/props.d.ts +78 -1
  95. package/types/services/storage.d.ts +1 -1
  96. package/types/services/ui.d.ts +2 -2
  97. package/types/type.d.ts +8 -8
  98. package/types/utils/operator.d.ts +1 -1
  99. package/types/utils/props.d.ts +78 -1
@@ -2,15 +2,7 @@
2
2
  <TMagicScrollbar class="magic-editor-layer-panel">
3
3
  <slot name="layer-panel-header"></slot>
4
4
 
5
- <TMagicInput
6
- v-model="filterText"
7
- class="search-input"
8
- size="small"
9
- placeholder="输入关键字进行过滤"
10
- clearable
11
- :prefix-icon="Search"
12
- @change="filterTextChangeHandler"
13
- ></TMagicInput>
5
+ <SearchInput @search="filterTextChangeHandler"></SearchInput>
14
6
 
15
7
  <TMagicTree
16
8
  v-if="values.length"
@@ -58,17 +50,17 @@
58
50
 
59
51
  <script lang="ts" setup name="MEditorLayerPanel">
60
52
  import { computed, inject, onMounted, onUnmounted, ref, watch } from 'vue';
61
- import { Search } from '@element-plus/icons-vue';
62
53
  import KeyController from 'keycon';
63
54
  import { difference, throttle, union } from 'lodash-es';
64
55
 
65
- import { TMagicInput, TMagicScrollbar, TMagicTree } from '@tmagic/design';
56
+ import { TMagicScrollbar, TMagicTree } from '@tmagic/design';
66
57
  import type { Id, MNode, MPage } from '@tmagic/schema';
67
58
  import { MContainer, NodeType } from '@tmagic/schema';
68
59
  import { getNodePath, isPage } from '@tmagic/utils';
69
60
 
70
- import type { MenuButton, MenuComponent, Services } from '../../type';
71
- import { Layout } from '../../type';
61
+ import SearchInput from '@editor/components/SearchInput.vue';
62
+ import type { MenuButton, MenuComponent, Services } from '@editor/type';
63
+ import { Layout } from '@editor/type';
72
64
 
73
65
  import LayerMenu from './LayerMenu.vue';
74
66
 
@@ -87,7 +79,6 @@ const menu = ref<InstanceType<typeof LayerMenu>>();
87
79
  const checkedKeys = ref<Id[]>([]);
88
80
  // 是否多选
89
81
  const isCtrlKeyDown = ref(false);
90
- const filterText = ref('');
91
82
  // 默认展开节点
92
83
  const expandedKeys = ref<Id[]>([]);
93
84
  const currentNodeKey = ref<Id>();
@@ -147,7 +138,7 @@ const allowDrop = (draggingNode: any, dropNode: any, type: string): boolean => {
147
138
 
148
139
  if (ingType !== NodeType.PAGE && data.type === NodeType.PAGE) return false;
149
140
  if (ingType === NodeType.PAGE && data.type !== NodeType.PAGE) return false;
150
- if (!data || !data.type) return false;
141
+ if (!data?.type) return false;
151
142
  if (['prev', 'next'].includes(type)) return true;
152
143
  if (data.items || data.type === 'container') return true;
153
144
 
@@ -89,9 +89,9 @@ import { Coin, EditPen, Files } from '@element-plus/icons-vue';
89
89
 
90
90
  import { getConfig, TMagicTabs } from '@tmagic/design';
91
91
 
92
- import MIcon from '../../components/Icon.vue';
93
- import type { MenuButton, MenuComponent, SideComponent, SideItem } from '../../type';
94
- import { SideBarData } from '../../type';
92
+ import MIcon from '@editor/components/Icon.vue';
93
+ import type { MenuButton, MenuComponent, SideComponent, SideItem } from '@editor/type';
94
+ import { SideBarData } from '@editor/type';
95
95
 
96
96
  import CodeBlockList from './code-block/CodeBlockList.vue';
97
97
  import ComponentListPanel from './ComponentListPanel.vue';
@@ -1,12 +1,14 @@
1
1
  <template>
2
- <TMagicDialog
3
- :model-value="true"
2
+ <TMagicDrawer
4
3
  class="code-editor-dialog"
4
+ :model-value="true"
5
5
  :title="currentTitle"
6
- :fullscreen="true"
7
- :close-on-press-escape="false"
6
+ :close-on-press-escape="true"
8
7
  :append-to-body="true"
9
8
  :show-close="false"
9
+ :close-on-click-modal="true"
10
+ :size="size"
11
+ :before-close="handleClose"
10
12
  >
11
13
  <Layout v-model:left="left" :min-left="45" class="code-editor-layout">
12
14
  <!-- 右侧区域 -->
@@ -14,6 +16,7 @@
14
16
  <div v-if="!isEmpty(codeConfig)" class="m-editor-code-block-editor-panel">
15
17
  <slot name="code-block-edit-panel-header" :id="id"></slot>
16
18
  <FunctionEditor
19
+ ref="functionEditor"
17
20
  v-if="codeConfig"
18
21
  :id="id"
19
22
  :name="codeConfig.name"
@@ -26,21 +29,21 @@
26
29
  </div>
27
30
  </template>
28
31
  </Layout>
29
- </TMagicDialog>
32
+ </TMagicDrawer>
30
33
  </template>
31
34
 
32
35
  <script lang="ts" setup name="MEditorCodeBlockEditor">
33
36
  import { computed, inject, reactive, ref, watchEffect } from 'vue';
34
37
  import { cloneDeep, forIn, isEmpty } from 'lodash-es';
35
38
 
36
- import { TMagicDialog } from '@tmagic/design';
39
+ import { TMagicDrawer } from '@tmagic/design';
37
40
  import { ColumnConfig } from '@tmagic/form';
38
41
  import { CodeBlockContent } from '@tmagic/schema';
39
42
 
40
- import FunctionEditor from '../../../components/FunctionEditor.vue';
41
- import Layout from '../../../components/Layout.vue';
42
- import type { ListState, Services } from '../../../type';
43
- import { serializeConfig } from '../../../utils/editor';
43
+ import FunctionEditor from '@editor/components/FunctionEditor.vue';
44
+ import Layout from '@editor/components/Layout.vue';
45
+ import type { ListState, Services } from '@editor/type';
46
+ import { serializeConfig } from '@editor/utils/editor';
44
47
 
45
48
  const services = inject<Services>('services');
46
49
  const codeOptions = inject('codeOptions', {});
@@ -49,6 +52,8 @@ defineProps<{
49
52
  paramsColConfig?: ColumnConfig;
50
53
  }>();
51
54
 
55
+ const size = computed(() => globalThis.document.body.clientWidth - (services?.uiService.get('columnWidth').left || 0));
56
+
52
57
  const left = ref(200);
53
58
  const currentTitle = ref('');
54
59
  // 编辑器当前需展示的代码块内容
@@ -81,4 +86,11 @@ watchEffect(async () => {
81
86
  });
82
87
  currentTitle.value = state.codeList[0]?.name || '';
83
88
  });
89
+
90
+ const functionEditor = ref<InstanceType<typeof FunctionEditor>>();
91
+
92
+ const handleClose = async () => {
93
+ // 触发codeDraftEditor组件关闭事件
94
+ await functionEditor.value?.codeDraftEditor?.close();
95
+ };
84
96
  </script>
@@ -1,15 +1,8 @@
1
1
  <template>
2
- <div class="m-editor-code-block-list">
2
+ <TMagicScrollbar class="m-editor-code-block-list">
3
3
  <slot name="code-block-panel-header">
4
4
  <div class="code-header-wrapper">
5
- <TMagicInput
6
- :class="[editable ? 'code-filter-input' : 'code-filter-input-no-btn']"
7
- size="small"
8
- placeholder="输入关键字进行过滤"
9
- clearable
10
- v-model="filterText"
11
- @input="filterTextChangeHandler"
12
- ></TMagicInput>
5
+ <SearchInput @search="filterTextChangeHandler"></SearchInput>
13
6
  <TMagicButton class="create-code-button" type="primary" size="small" @click="createCodeBlock" v-if="editable"
14
7
  >新增</TMagicButton
15
8
  >
@@ -17,38 +10,40 @@
17
10
  </slot>
18
11
 
19
12
  <!-- 代码块列表 -->
20
- <TMagicScrollbar>
21
- <TMagicTree
22
- ref="tree"
23
- class="magic-editor-layer-tree"
24
- node-key="id"
25
- empty-text="暂无代码块"
26
- default-expand-all
27
- :expand-on-click-node="false"
28
- :data="codeList"
29
- :highlight-current="true"
30
- :filter-node-method="filterNode"
31
- @node-click="clickHandler"
32
- >
33
- <template #default="{ data }">
34
- <div :id="data.id" class="list-container">
35
- <div class="list-item">
36
- <span class="code-name">{{ data.name }}({{ data.id }})</span>
37
- <!-- 右侧工具栏 -->
38
- <div class="right-tool" v-if="data.type === 'code'">
39
- <TMagicTooltip effect="dark" :content="editable ? '编辑' : '查看'" placement="bottom">
40
- <Icon :icon="editable ? Edit : View" class="edit-icon" @click.stop="editCode(`${data.id}`)"></Icon>
41
- </TMagicTooltip>
42
- <TMagicTooltip effect="dark" content="删除" placement="bottom" v-if="editable">
43
- <Icon :icon="Close" class="edit-icon" @click.stop="deleteCode(`${data.id}`)"></Icon>
44
- </TMagicTooltip>
45
- <slot name="code-block-panel-tool" :id="data.id" :data="data.codeBlockContent"></slot>
46
- </div>
13
+ <TMagicTree
14
+ ref="tree"
15
+ class="magic-editor-layer-tree"
16
+ node-key="id"
17
+ empty-text="暂无代码块"
18
+ :default-expanded-keys="expandedKeys"
19
+ :expand-on-click-node="false"
20
+ :data="codeList"
21
+ :highlight-current="true"
22
+ :filter-node-method="filterNode"
23
+ @node-click="clickHandler"
24
+ >
25
+ <template #default="{ data }">
26
+ <div :id="data.id" class="list-container">
27
+ <div class="list-item">
28
+ <CodeIcon v-if="data.type === 'code'" class="codeIcon"></CodeIcon>
29
+ <AppManageIcon v-if="data.type === 'node'" class="compIcon"></AppManageIcon>
30
+ <span class="code-name" :class="{ code: data.type === 'code', hook: data.type === 'key' }"
31
+ >{{ data.name }}({{ data.id }})</span
32
+ >
33
+ <!-- 右侧工具栏 -->
34
+ <div class="right-tool" v-if="data.type === 'code'">
35
+ <TMagicTooltip effect="dark" :content="editable ? '编辑' : '查看'" placement="bottom">
36
+ <Icon :icon="editable ? Edit : View" class="edit-icon" @click.stop="editCode(`${data.id}`)"></Icon>
37
+ </TMagicTooltip>
38
+ <TMagicTooltip effect="dark" content="删除" placement="bottom" v-if="editable">
39
+ <Icon :icon="Close" class="edit-icon" @click.stop="deleteCode(`${data.id}`)"></Icon>
40
+ </TMagicTooltip>
41
+ <slot name="code-block-panel-tool" :id="data.id" :data="data.codeBlockContent"></slot>
47
42
  </div>
48
43
  </div>
49
- </template>
50
- </TMagicTree>
51
- </TMagicScrollbar>
44
+ </div>
45
+ </template>
46
+ </TMagicTree>
52
47
 
53
48
  <!-- 代码块编辑区 -->
54
49
  <CodeBlockEditor v-if="isShowCodeBlockEditor" :paramsColConfig="paramsColConfig">
@@ -56,19 +51,22 @@
56
51
  <slot name="code-block-edit-panel-header" :id="id"></slot>
57
52
  </template>
58
53
  </CodeBlockEditor>
59
- </div>
54
+ </TMagicScrollbar>
60
55
  </template>
61
56
 
62
57
  <script setup lang="ts" name="MEditorCodeBlockList">
63
58
  import { computed, inject, ref } from 'vue';
64
59
  import { Close, Edit, View } from '@element-plus/icons-vue';
65
60
 
66
- import { TMagicButton, TMagicInput, tMagicMessage, TMagicScrollbar, TMagicTooltip, TMagicTree } from '@tmagic/design';
61
+ import { TMagicButton, tMagicMessage, TMagicScrollbar, TMagicTooltip, TMagicTree } from '@tmagic/design';
67
62
  import { ColumnConfig } from '@tmagic/form';
68
63
  import { CodeBlockContent, Id } from '@tmagic/schema';
69
64
 
70
- import Icon from '../../../components/Icon.vue';
71
- import { CodeDeleteErrorType, CodeDslItem, Services } from '../../../type';
65
+ import Icon from '@editor/components/Icon.vue';
66
+ import SearchInput from '@editor/components/SearchInput.vue';
67
+ import AppManageIcon from '@editor/icons/AppManageIcon.vue';
68
+ import CodeIcon from '@editor/icons/CodeIcon.vue';
69
+ import { CodeDeleteErrorType, CodeDslItem, Services } from '@editor/type';
72
70
 
73
71
  import CodeBlockEditor from './CodeBlockEditor.vue';
74
72
 
@@ -81,19 +79,27 @@ const { codeBlockService, depService, editorService } = inject<Services>('servic
81
79
 
82
80
  // 代码块列表
83
81
  const codeList = computed(() =>
84
- Object.values(depService?.targets['code-block'] || {}).map((target) => ({
85
- id: target.id,
86
- name: target.name,
87
- type: 'code',
88
- children: Object.entries(target.deps).map(([id, dep]) => ({
82
+ Object.values(depService?.targets['code-block'] || {}).map((target) => {
83
+ // 组件节点
84
+ const compNodes = Object.entries(target.deps).map(([id, dep]) => ({
89
85
  name: dep.name,
90
86
  type: 'node',
91
87
  id,
92
88
  children: dep.keys.map((key) => ({ name: key, id: key, type: 'key' })),
93
- })),
94
- })),
89
+ }));
90
+ return {
91
+ id: target.id,
92
+ name: target.name,
93
+ type: 'code',
94
+ codeBlockContent: codeBlockService?.getCodeContentById(target.id),
95
+ children: compNodes,
96
+ };
97
+ }),
95
98
  );
96
99
 
100
+ // 默认展开组件层级的节点
101
+ const expandedKeys = computed(() => codeList.value.map((item) => item.id));
102
+
97
103
  const editable = computed(() => codeBlockService?.getEditStatus());
98
104
 
99
105
  // 是否展示代码编辑区
@@ -140,7 +146,6 @@ const deleteCode = (key: Id) => {
140
146
  }
141
147
  };
142
148
 
143
- const filterText = ref('');
144
149
  const tree = ref<InstanceType<typeof TMagicTree>>();
145
150
 
146
151
  const filterNode = (value: string, data: CodeDslItem): boolean => {
@@ -14,7 +14,7 @@ import { TMagicButton } from '@tmagic/design';
14
14
  import type { MNode } from '@tmagic/schema';
15
15
  import { getNodePath } from '@tmagic/utils';
16
16
 
17
- import type { Services } from '../../type';
17
+ import type { Services } from '@editor/type';
18
18
 
19
19
  const services = inject<Services>('services');
20
20
  const editorService = services?.editorService;
@@ -53,8 +53,8 @@ import { CaretBottom, Delete, DocumentCopy } from '@element-plus/icons-vue';
53
53
  import { TMagicIcon, TMagicPopover, TMagicTooltip } from '@tmagic/design';
54
54
  import type { MPage } from '@tmagic/schema';
55
55
 
56
- import ToolButton from '../../components/ToolButton.vue';
57
- import type { Services } from '../../type';
56
+ import ToolButton from '@editor/components/ToolButton.vue';
57
+ import type { Services } from '@editor/type';
58
58
 
59
59
  import PageBarScrollContainer from './PageBarScrollContainer.vue';
60
60
 
@@ -32,9 +32,9 @@ import { ArrowLeftBold, ArrowRightBold, Plus } from '@element-plus/icons-vue';
32
32
 
33
33
  import { NodeType } from '@tmagic/schema';
34
34
 
35
- import Icon from '../../components/Icon.vue';
36
- import type { Services } from '../../type';
37
- import { generatePageNameByApp } from '../../utils/editor';
35
+ import Icon from '@editor/components/Icon.vue';
36
+ import type { Services } from '@editor/type';
37
+ import { generatePageNameByApp } from '@editor/utils/editor';
38
38
 
39
39
  const services = inject<Services>('services');
40
40
  const editorService = services?.editorService;
@@ -33,9 +33,9 @@ import { cloneDeep } from 'lodash-es';
33
33
  import type { MContainer } from '@tmagic/schema';
34
34
  import StageCore, { calcValueByFontsize, getOffset, Runtime } from '@tmagic/stage';
35
35
 
36
- import ScrollViewer from '../../components/ScrollViewer.vue';
37
- import { Layout, MenuButton, MenuComponent, Services, StageOptions } from '../../type';
38
- import { useStage } from '../../utils/stage';
36
+ import ScrollViewer from '@editor/components/ScrollViewer.vue';
37
+ import { Layout, MenuButton, MenuComponent, Services, StageOptions } from '@editor/type';
38
+ import { useStage } from '@editor/utils/stage';
39
39
 
40
40
  import ViewerMenu from './ViewerMenu.vue';
41
41
 
@@ -9,10 +9,10 @@ import { Bottom, CopyDocument, Delete, DocumentCopy, Top } from '@element-plus/i
9
9
  import { NodeType } from '@tmagic/schema';
10
10
  import { isPage } from '@tmagic/utils';
11
11
 
12
- import ContentMenu from '../../components/ContentMenu.vue';
13
- import storageService from '../../services/storage';
14
- import { LayerOffset, Layout, MenuButton, MenuComponent, Services } from '../../type';
15
- import { COPY_STORAGE_KEY } from '../../utils/editor';
12
+ import ContentMenu from '@editor/components/ContentMenu.vue';
13
+ import storageService from '@editor/services/storage';
14
+ import { LayerOffset, Layout, MenuButton, MenuComponent, Services } from '@editor/type';
15
+ import { COPY_STORAGE_KEY } from '@editor/utils/editor';
16
16
 
17
17
  const props = withDefaults(
18
18
  defineProps<{ isMultiSelect?: boolean; stageContentMenu: (MenuButton | MenuComponent)[] }>(),
@@ -21,7 +21,7 @@ import KeyController from 'keycon';
21
21
 
22
22
  import { isPage } from '@tmagic/utils';
23
23
 
24
- import type { MenuButton, MenuComponent, Services } from '../../type';
24
+ import type { MenuButton, MenuComponent, Services } from '@editor/type';
25
25
 
26
26
  import Breadcrumb from './Breadcrumb.vue';
27
27
  import PageBar from './PageBar.vue';
@@ -18,7 +18,7 @@
18
18
 
19
19
  import { EventEmitter } from 'events';
20
20
 
21
- import { compose } from '../utils/compose';
21
+ import { compose } from '@editor/utils/compose';
22
22
 
23
23
  const methodName = (prefix: string, name: string) => `${prefix}${name[0].toUpperCase()}${name.substring(1)}`;
24
24
 
@@ -21,9 +21,9 @@ import { keys, pick } from 'lodash-es';
21
21
 
22
22
  import { CodeBlockContent, CodeBlockDSL, Id } from '@tmagic/schema';
23
23
 
24
- import type { CodeState } from '../type';
25
- import { CODE_DRAFT_STORAGE_KEY } from '../type';
26
- import { info } from '../utils/logger';
24
+ import type { CodeState } from '@editor/type';
25
+ import { CODE_DRAFT_STORAGE_KEY } from '@editor/type';
26
+ import { info } from '@editor/utils/logger';
27
27
 
28
28
  import BaseService from './BaseService';
29
29
 
@@ -39,9 +39,6 @@ class CodeBlock extends BaseService {
39
39
 
40
40
  constructor() {
41
41
  super([
42
- 'getCodeContentById',
43
- 'getCodeDslByIds',
44
- 'getCurrentDsl',
45
42
  'setCodeDslById',
46
43
  'setCodeEditorShowStatus',
47
44
  'setEditStatus',
@@ -77,9 +74,9 @@ class CodeBlock extends BaseService {
77
74
  * @param {Id} id 代码块id
78
75
  * @returns {CodeBlockContent | null}
79
76
  */
80
- public async getCodeContentById(id: Id): Promise<CodeBlockContent | null> {
77
+ public getCodeContentById(id: Id): CodeBlockContent | null {
81
78
  if (!id) return null;
82
- const totalCodeDsl = await this.getCodeDsl();
79
+ const totalCodeDsl = this.getCodeDsl();
83
80
  if (!totalCodeDsl) return null;
84
81
  return totalCodeDsl[id] ?? null;
85
82
  }
@@ -91,7 +88,7 @@ class CodeBlock extends BaseService {
91
88
  * @returns {void}
92
89
  */
93
90
  public async setCodeDslById(id: Id, codeConfig: CodeBlockContent): Promise<void> {
94
- const codeDsl = await this.getCodeDsl();
91
+ const codeDsl = this.getCodeDsl();
95
92
 
96
93
  if (!codeDsl) {
97
94
  throw new Error('dsl中没有codeBlocks');
@@ -119,8 +116,8 @@ class CodeBlock extends BaseService {
119
116
  * @param {string[]} ids 代码块id数组
120
117
  * @returns {CodeBlockDSL}
121
118
  */
122
- public async getCodeDslByIds(ids: string[]): Promise<CodeBlockDSL> {
123
- const codeDsl = await this.getCodeDsl();
119
+ public getCodeDslByIds(ids: string[]): CodeBlockDSL {
120
+ const codeDsl = this.getCodeDsl();
124
121
  return pick(codeDsl, ids) as CodeBlockDSL;
125
122
  }
126
123
 
@@ -157,8 +154,8 @@ class CodeBlock extends BaseService {
157
154
  * 获取当前选中的代码块内容
158
155
  * @returns {CodeBlockContent | null}
159
156
  */
160
- public async getCurrentDsl(): Promise<CodeBlockContent | null> {
161
- return await this.getCodeContentById(this.state.id);
157
+ public getCurrentDsl(): CodeBlockContent | null {
158
+ return this.getCodeContentById(this.state.id);
162
159
  }
163
160
 
164
161
  /**
@@ -18,7 +18,7 @@
18
18
 
19
19
  import { reactive } from 'vue';
20
20
 
21
- import type { ComponentGroup, ComponentGroupState } from '../type';
21
+ import type { ComponentGroup, ComponentGroupState } from '@editor/type';
22
22
 
23
23
  import BaseService from './BaseService';
24
24
 
@@ -24,10 +24,10 @@ import { NodeType } from '@tmagic/schema';
24
24
  import StageCore from '@tmagic/stage';
25
25
  import { getNodePath, isNumber, isPage, isPop } from '@tmagic/utils';
26
26
 
27
- import historyService from '../services/history';
28
- import storageService, { Protocol } from '../services/storage';
29
- import type { AddMNode, EditorNodeInfo, PastePosition, StepValue, StoreState, StoreStateKey } from '../type';
30
- import { LayerOffset, Layout } from '../type';
27
+ import historyService from '@editor/services/history';
28
+ import storageService, { Protocol } from '@editor/services/storage';
29
+ import type { AddMNode, EditorNodeInfo, PastePosition, StepValue, StoreState, StoreStateKey } from '@editor/type';
30
+ import { LayerOffset, Layout } from '@editor/type';
31
31
  import {
32
32
  change2Fixed,
33
33
  COPY_STORAGE_KEY,
@@ -37,8 +37,8 @@ import {
37
37
  getNodeIndex,
38
38
  isFixed,
39
39
  setLayout,
40
- } from '../utils/editor';
41
- import { beforePaste, getAddParent } from '../utils/operator';
40
+ } from '@editor/utils/editor';
41
+ import { beforePaste, getAddParent } from '@editor/utils/operator';
42
42
 
43
43
  import BaseService from './BaseService';
44
44
  import propsService from './props';
@@ -22,7 +22,7 @@ import { cloneDeep } from 'lodash-es';
22
22
  import { DEFAULT_EVENTS, DEFAULT_METHODS, EventOption } from '@tmagic/core';
23
23
  import { toLine } from '@tmagic/utils';
24
24
 
25
- import type { ComponentGroup } from '../type';
25
+ import type { ComponentGroup } from '@editor/type';
26
26
 
27
27
  import BaseService from './BaseService';
28
28
 
@@ -20,8 +20,8 @@ import { reactive } from 'vue';
20
20
 
21
21
  import type { MPage } from '@tmagic/schema';
22
22
 
23
- import { HistoryState, StepValue } from '../type';
24
- import { UndoRedo } from '../utils/undo-redo';
23
+ import type { HistoryState, StepValue } from '@editor/type';
24
+ import { UndoRedo } from '@editor/utils/undo-redo';
25
25
 
26
26
  import BaseService from './BaseService';
27
27
 
@@ -23,8 +23,8 @@ import type { FormConfig } from '@tmagic/form';
23
23
  import type { MComponent, MNode } from '@tmagic/schema';
24
24
  import { toLine } from '@tmagic/utils';
25
25
 
26
- import type { PropsState } from '../type';
27
- import { fillConfig } from '../utils/props';
26
+ import type { PropsState } from '@editor/type';
27
+ import { fillConfig } from '@editor/utils/props';
28
28
 
29
29
  import BaseService from './BaseService';
30
30
 
@@ -18,8 +18,8 @@
18
18
 
19
19
  import { reactive } from 'vue';
20
20
 
21
- import editorService from '../services/editor';
22
- import type { StageRect, UiState } from '../type';
21
+ import editorService from '@editor/services/editor';
22
+ import type { StageRect, UiState } from '@editor/type';
23
23
 
24
24
  import BaseService from './BaseService';
25
25
 
@@ -1,17 +1,24 @@
1
1
  .m-editor-code-block-list {
2
2
  height: 100%;
3
- margin-top: 5px;
3
+
4
+ .magic-editor-layer-tree {
5
+ padding-top: 48px;
6
+ }
7
+
4
8
  .code-header-wrapper {
5
9
  display: flex;
6
10
  align-items: center;
7
11
  justify-content: center;
8
- .code-filter-input {
9
- margin: 0 5px;
10
- }
11
- .code-filter-input-no-btn {
12
- margin-left: 5px;
13
- margin-right: 10px;
12
+ position: absolute;
13
+ top: 0;
14
+ width: 100%;
15
+ z-index: 1;
16
+
17
+ .search-input {
18
+ flex: 1;
19
+ position: relative;
14
20
  }
21
+
15
22
  .create-code-button {
16
23
  margin-left: 2px;
17
24
  margin-right: 10px;
@@ -27,22 +34,47 @@
27
34
  overflow: hidden;
28
35
  .list-item {
29
36
  display: flex;
37
+ align-items: center;
30
38
  width: 100%;
39
+ align-items: center;
31
40
 
32
41
  .right-tool {
33
42
  display: flex;
34
43
  width: fit-content !important;
44
+ align-items: center;
45
+ margin-right: 10px;
35
46
  .edit-icon {
36
47
  margin: 0 5px;
37
48
  }
38
49
  }
50
+
51
+ .codeIcon {
52
+ width: 20px;
53
+ height: 20px;
54
+ margin-right: 5px;
55
+ }
56
+
57
+ .compIcon {
58
+ width: 15px;
59
+ height: 15px;
60
+ margin-right: 5px;
61
+ }
62
+
39
63
  .code-name {
40
64
  white-space: nowrap;
41
65
  overflow: hidden;
42
66
  text-overflow: ellipsis;
43
67
  width: 0 !important;
44
68
  flex: 1;
45
- line-height: 18px;
69
+ line-height: 22px;
70
+
71
+ &.code {
72
+ color: #000;
73
+ }
74
+
75
+ &.hook {
76
+ color: #909399;
77
+ }
46
78
  }
47
79
  }
48
80
  }
@@ -50,9 +82,8 @@
50
82
 
51
83
  .m-fields-code-select {
52
84
  width: 100%;
53
- .edit-icon {
54
- cursor: pointer;
55
- margin-right: 5px;
85
+ .el-card__header {
86
+ display: none;
56
87
  }
57
88
  }
58
89
 
@@ -4,21 +4,6 @@
4
4
  margin-top: 48px;
5
5
  background-color: $--sidebar-content-background-color;
6
6
 
7
- .search-input {
8
- background: #fff;
9
- color: #bbbbbb;
10
- padding: 10px;
11
- position: absolute;
12
- top: 0;
13
- left: 0;
14
- box-sizing: border-box;
15
- z-index: 1;
16
-
17
- .el-input__prefix {
18
- padding: 7px;
19
- }
20
- }
21
-
22
7
  .tmagic-design-collapse-item {
23
8
  > div:first-of-type {
24
9
  border-bottom: 1px solid $--border-color;