@tmagic/editor 1.2.12 → 1.2.13

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.12",
2
+ "version": "1.2.13",
3
3
  "name": "@tmagic/editor",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -46,12 +46,12 @@
46
46
  "dependencies": {
47
47
  "@babel/core": "^7.18.0",
48
48
  "@element-plus/icons-vue": "^2.0.9",
49
- "@tmagic/core": "1.2.12",
50
- "@tmagic/design": "1.2.12",
51
- "@tmagic/form": "1.2.12",
52
- "@tmagic/schema": "1.2.12",
53
- "@tmagic/stage": "1.2.12",
54
- "@tmagic/utils": "1.2.12",
49
+ "@tmagic/core": "1.2.13",
50
+ "@tmagic/design": "1.2.13",
51
+ "@tmagic/form": "1.2.13",
52
+ "@tmagic/schema": "1.2.13",
53
+ "@tmagic/stage": "1.2.13",
54
+ "@tmagic/utils": "1.2.13",
55
55
  "buffer": "^6.0.3",
56
56
  "color": "^3.1.3",
57
57
  "events": "^3.3.0",
@@ -63,8 +63,8 @@
63
63
  "vue": "^3.2.37"
64
64
  },
65
65
  "peerDependencies": {
66
- "@tmagic/design": "1.2.12",
67
- "@tmagic/form": "1.2.12",
66
+ "@tmagic/design": "1.2.13",
67
+ "@tmagic/form": "1.2.13",
68
68
  "monaco-editor": "^0.34.0",
69
69
  "vue": "^3.2.37"
70
70
  },
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <TMagicInput
3
+ v-model="filterText"
4
+ class="search-input"
5
+ size="small"
6
+ placeholder="输入关键字进行过滤"
7
+ clearable
8
+ :prefix-icon="Search"
9
+ @input="filterTextChangeHandler"
10
+ ></TMagicInput>
11
+ </template>
12
+
13
+ <script setup lang="ts">
14
+ import { ref } from 'vue';
15
+ import { Search } from '@element-plus/icons-vue';
16
+
17
+ import { TMagicInput } from '@tmagic/design';
18
+
19
+ const emit = defineEmits(['search']);
20
+
21
+ const filterText = ref('');
22
+
23
+ const filterTextChangeHandler = () => {
24
+ emit('search', filterText.value);
25
+ };
26
+ </script>
@@ -3,14 +3,7 @@
3
3
  <slot name="component-list-panel-header"></slot>
4
4
 
5
5
  <TMagicCollapse class="ui-component-panel" :model-value="collapseValue">
6
- <TMagicInput
7
- placeholder="输入关键字进行过滤"
8
- class="search-input"
9
- size="small"
10
- clearable
11
- :prefix-icon="Search"
12
- v-model="searchText"
13
- />
6
+ <SearchInput @search="filterTextChangeHandler"></SearchInput>
14
7
  <template v-for="(group, index) in list">
15
8
  <TMagicCollapseItem v-if="group.items && group.items.length" :key="index" :name="`${index}`">
16
9
  <template #title><MIcon :icon="Grid"></MIcon>{{ group.title }}</template>
@@ -40,16 +33,22 @@
40
33
 
41
34
  <script lang="ts" setup name="MEditorComponentListPanel">
42
35
  import { computed, inject, ref } from 'vue';
43
- import { Grid, Search } from '@element-plus/icons-vue';
36
+ import { Grid } from '@element-plus/icons-vue';
44
37
  import serialize from 'serialize-javascript';
45
38
 
46
- import { TMagicCollapse, TMagicCollapseItem, TMagicInput, TMagicScrollbar, TMagicTooltip } from '@tmagic/design';
39
+ import { TMagicCollapse, TMagicCollapseItem, TMagicScrollbar, TMagicTooltip } from '@tmagic/design';
47
40
  import { removeClassNameByClassName } from '@tmagic/utils';
48
41
 
49
42
  import MIcon from '../../components/Icon.vue';
43
+ import SearchInput from '../../components/SearchInput.vue';
50
44
  import type { ComponentGroup, ComponentItem, Services, StageOptions } from '../../type';
51
45
 
52
46
  const searchText = ref('');
47
+
48
+ const filterTextChangeHandler = (v: string) => {
49
+ searchText.value = v;
50
+ };
51
+
53
52
  const services = inject<Services>('services');
54
53
  const stageOptions = inject<StageOptions>('stageOptions');
55
54
 
@@ -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,15 +50,15 @@
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
 
61
+ import SearchInput from '../../components/SearchInput.vue';
70
62
  import type { MenuButton, MenuComponent, Services } from '../../type';
71
63
  import { Layout } from '../../type';
72
64
 
@@ -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>();
@@ -1,12 +1,13 @@
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
6
  :close-on-press-escape="false"
8
7
  :append-to-body="true"
9
8
  :show-close="false"
9
+ :close-on-click-modal="false"
10
+ :size="size"
10
11
  >
11
12
  <Layout v-model:left="left" :min-left="45" class="code-editor-layout">
12
13
  <!-- 右侧区域 -->
@@ -26,14 +27,14 @@
26
27
  </div>
27
28
  </template>
28
29
  </Layout>
29
- </TMagicDialog>
30
+ </TMagicDrawer>
30
31
  </template>
31
32
 
32
33
  <script lang="ts" setup name="MEditorCodeBlockEditor">
33
34
  import { computed, inject, reactive, ref, watchEffect } from 'vue';
34
35
  import { cloneDeep, forIn, isEmpty } from 'lodash-es';
35
36
 
36
- import { TMagicDialog } from '@tmagic/design';
37
+ import { TMagicDrawer } from '@tmagic/design';
37
38
  import { ColumnConfig } from '@tmagic/form';
38
39
  import { CodeBlockContent } from '@tmagic/schema';
39
40
 
@@ -49,6 +50,8 @@ defineProps<{
49
50
  paramsColConfig?: ColumnConfig;
50
51
  }>();
51
52
 
53
+ const size = computed(() => globalThis.document.body.clientWidth - (services?.uiService.get('columnWidth').left || 0));
54
+
52
55
  const left = ref(200);
53
56
  const currentTitle = ref('');
54
57
  // 编辑器当前需展示的代码块内容
@@ -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,36 @@
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-expand-all
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
+ <span class="code-name">{{ data.name }}({{ data.id }})</span>
29
+ <!-- 右侧工具栏 -->
30
+ <div class="right-tool" v-if="data.type === 'code'">
31
+ <TMagicTooltip effect="dark" :content="editable ? '编辑' : '查看'" placement="bottom">
32
+ <Icon :icon="editable ? Edit : View" class="edit-icon" @click.stop="editCode(`${data.id}`)"></Icon>
33
+ </TMagicTooltip>
34
+ <TMagicTooltip effect="dark" content="删除" placement="bottom" v-if="editable">
35
+ <Icon :icon="Close" class="edit-icon" @click.stop="deleteCode(`${data.id}`)"></Icon>
36
+ </TMagicTooltip>
37
+ <slot name="code-block-panel-tool" :id="data.id" :data="data.codeBlockContent"></slot>
47
38
  </div>
48
39
  </div>
49
- </template>
50
- </TMagicTree>
51
- </TMagicScrollbar>
40
+ </div>
41
+ </template>
42
+ </TMagicTree>
52
43
 
53
44
  <!-- 代码块编辑区 -->
54
45
  <CodeBlockEditor v-if="isShowCodeBlockEditor" :paramsColConfig="paramsColConfig">
@@ -56,18 +47,19 @@
56
47
  <slot name="code-block-edit-panel-header" :id="id"></slot>
57
48
  </template>
58
49
  </CodeBlockEditor>
59
- </div>
50
+ </TMagicScrollbar>
60
51
  </template>
61
52
 
62
53
  <script setup lang="ts" name="MEditorCodeBlockList">
63
54
  import { computed, inject, ref } from 'vue';
64
55
  import { Close, Edit, View } from '@element-plus/icons-vue';
65
56
 
66
- import { TMagicButton, TMagicInput, tMagicMessage, TMagicScrollbar, TMagicTooltip, TMagicTree } from '@tmagic/design';
57
+ import { TMagicButton, tMagicMessage, TMagicScrollbar, TMagicTooltip, TMagicTree } from '@tmagic/design';
67
58
  import { ColumnConfig } from '@tmagic/form';
68
59
  import { CodeBlockContent, Id } from '@tmagic/schema';
69
60
 
70
61
  import Icon from '../../../components/Icon.vue';
62
+ import SearchInput from '../../../components/SearchInput.vue';
71
63
  import { CodeDeleteErrorType, CodeDslItem, Services } from '../../../type';
72
64
 
73
65
  import CodeBlockEditor from './CodeBlockEditor.vue';
@@ -85,6 +77,7 @@ const codeList = computed(() =>
85
77
  id: target.id,
86
78
  name: target.name,
87
79
  type: 'code',
80
+ codeBlockContent: codeBlockService?.getCodeContentById(target.id),
88
81
  children: Object.entries(target.deps).map(([id, dep]) => ({
89
82
  name: dep.name,
90
83
  type: 'node',
@@ -140,7 +133,6 @@ const deleteCode = (key: Id) => {
140
133
  }
141
134
  };
142
135
 
143
- const filterText = ref('');
144
136
  const tree = ref<InstanceType<typeof TMagicTree>>();
145
137
 
146
138
  const filterNode = (value: string, data: CodeDslItem): boolean => {
@@ -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
  /**
@@ -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;
@@ -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;
@@ -1,20 +1,6 @@
1
1
  .magic-editor-layer-panel {
2
2
  background: $--sidebar-content-background-color;
3
3
 
4
- .search-input {
5
- background: $--sidebar-content-background-color;
6
- color: #bbbbbb;
7
- padding: 10px;
8
- position: absolute;
9
- top: 0;
10
- left: 0;
11
- z-index: 1;
12
-
13
- .el-input__prefix {
14
- padding: 7px;
15
- }
16
- }
17
-
18
4
  .magic-editor-layer-tree {
19
5
  padding-top: 48px;
20
6
  }
@@ -0,0 +1,14 @@
1
+ .tmagic-design-input.search-input {
2
+ background: #fff;
3
+ color: #bbbbbb;
4
+ padding: 10px;
5
+ position: absolute;
6
+ top: 0;
7
+ left: 0;
8
+ box-sizing: border-box;
9
+ z-index: 1;
10
+
11
+ .el-input__prefix {
12
+ padding: 7px;
13
+ }
14
+ }
@@ -1,3 +1,4 @@
1
+ @import "./search-input.scss";
1
2
  @import "./nav-menu.scss";
2
3
  @import "./framework.scss";
3
4
  @import "./sidebar.scss";
@@ -0,0 +1,4 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "search"[], "search", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>> & {
2
+ onSearch?: ((...args: any[]) => any) | undefined;
3
+ }, {}>;
4
+ export default _default;
@@ -21,7 +21,7 @@ declare class CodeBlock extends BaseService {
21
21
  * @param {Id} id 代码块id
22
22
  * @returns {CodeBlockContent | null}
23
23
  */
24
- getCodeContentById(id: Id): Promise<CodeBlockContent | null>;
24
+ getCodeContentById(id: Id): CodeBlockContent | null;
25
25
  /**
26
26
  * 设置代码块ID和代码内容到源dsl
27
27
  * @param {Id} id 代码块id
@@ -34,7 +34,7 @@ declare class CodeBlock extends BaseService {
34
34
  * @param {string[]} ids 代码块id数组
35
35
  * @returns {CodeBlockDSL}
36
36
  */
37
- getCodeDslByIds(ids: string[]): Promise<CodeBlockDSL>;
37
+ getCodeDslByIds(ids: string[]): CodeBlockDSL;
38
38
  /**
39
39
  * 设置代码编辑面板展示状态
40
40
  * @param {boolean} status 是否展示代码编辑面板
@@ -57,7 +57,7 @@ declare class CodeBlock extends BaseService {
57
57
  * 获取当前选中的代码块内容
58
58
  * @returns {CodeBlockContent | null}
59
59
  */
60
- getCurrentDsl(): Promise<CodeBlockContent | null>;
60
+ getCurrentDsl(): CodeBlockContent | null;
61
61
  /**
62
62
  * 获取编辑状态
63
63
  * @returns {boolean} 是否可编辑