@tmagic/editor 1.3.8 → 1.3.10

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.3.8",
2
+ "version": "1.3.10",
3
3
  "name": "@tmagic/editor",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -42,16 +42,17 @@
42
42
  "dependencies": {
43
43
  "@babel/core": "^7.18.0",
44
44
  "@element-plus/icons-vue": "^2.3.1",
45
- "@tmagic/core": "1.3.8",
46
- "@tmagic/dep": "1.3.8",
47
- "@tmagic/design": "1.3.8",
48
- "@tmagic/form": "1.3.8",
49
- "@tmagic/schema": "1.3.8",
50
- "@tmagic/stage": "1.3.8",
51
- "@tmagic/table": "1.3.8",
52
- "@tmagic/utils": "1.3.8",
45
+ "@tmagic/core": "1.3.10",
46
+ "@tmagic/dep": "1.3.10",
47
+ "@tmagic/design": "1.3.10",
48
+ "@tmagic/form": "1.3.10",
49
+ "@tmagic/schema": "1.3.10",
50
+ "@tmagic/stage": "1.3.10",
51
+ "@tmagic/table": "1.3.10",
52
+ "@tmagic/utils": "1.3.10",
53
53
  "buffer": "^6.0.3",
54
54
  "color": "^3.1.3",
55
+ "emmet-monaco-es": "^5.3.0",
55
56
  "events": "^3.3.0",
56
57
  "gesto": "^1.19.1",
57
58
  "keycon": "^1.4.0",
@@ -62,8 +63,8 @@
62
63
  "vue": "^3.3.8"
63
64
  },
64
65
  "peerDependencies": {
65
- "@tmagic/design": "1.3.8",
66
- "@tmagic/form": "1.3.8",
66
+ "@tmagic/design": "1.3.10",
67
+ "@tmagic/form": "1.3.10",
67
68
  "monaco-editor": "^0.41.0",
68
69
  "vue": "^3.3.8"
69
70
  },
@@ -18,7 +18,7 @@
18
18
  @closed="closedHandler"
19
19
  >
20
20
  <template #left>
21
- <TMagicButton type="primary" text @click="difVisible = true">查看修改</TMagicButton>
21
+ <TMagicButton type="primary" link @click="difVisible = true">查看修改</TMagicButton>
22
22
  </template>
23
23
  </component>
24
24
 
@@ -6,7 +6,7 @@
6
6
  <span>{{ title }}</span>
7
7
  </slot>
8
8
  <div>
9
- <TMagicButton text size="small" :icon="Close" @click="closeHandler"></TMagicButton>
9
+ <TMagicButton link size="small" :icon="Close" @click="closeHandler"></TMagicButton>
10
10
  </div>
11
11
  </div>
12
12
  <div class="m-editor-float-box-body">
@@ -12,11 +12,11 @@
12
12
 
13
13
  <template v-else-if="data.type === 'button'">
14
14
  <TMagicTooltip v-if="data.tooltip" effect="dark" placement="bottom-start" :content="data.tooltip">
15
- <TMagicButton size="small" text :disabled="disabled"
15
+ <TMagicButton size="small" link :disabled="disabled"
16
16
  ><MIcon v-if="data.icon" :icon="data.icon"></MIcon><span>{{ data.text }}</span></TMagicButton
17
17
  >
18
18
  </TMagicTooltip>
19
- <TMagicButton v-else size="small" text :disabled="disabled" :title="data.text"
19
+ <TMagicButton v-else size="small" link :disabled="disabled" :title="data.text"
20
20
  ><MIcon v-if="data.icon" :icon="data.icon"></MIcon><span>{{ data.text }}</span></TMagicButton
21
21
  >
22
22
  </template>
@@ -36,7 +36,7 @@
36
36
  ></m-form-container>
37
37
  <TMagicButton
38
38
  style="color: #f56c6c"
39
- text
39
+ link
40
40
  :icon="Delete"
41
41
  :disabled="disabled"
42
42
  :size="size"
@@ -51,7 +51,7 @@
51
51
  v-if="config.advanced"
52
52
  size="default"
53
53
  :disabled="disabled"
54
- text
54
+ link
55
55
  :icon="CodeIcon"
56
56
  @click="showCode = !showCode"
57
57
  ></TMagicButton>
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="m-fields-ui-select" v-if="uiSelectMode" @click="cancelHandler">
3
- <TMagicButton type="danger" :icon="Delete" :disabled="disabled" :size="size" text style="padding: 0"
3
+ <TMagicButton type="danger" :icon="Delete" :disabled="disabled" :size="size" link style="padding: 0"
4
4
  >取消</TMagicButton
5
5
  >
6
6
  </div>
@@ -13,14 +13,14 @@
13
13
  :icon="Close"
14
14
  :disabled="disabled"
15
15
  :size="size"
16
- text
16
+ link
17
17
  @click.stop="deleteHandler"
18
18
  ></TMagicButton>
19
19
  </TMagicTooltip>
20
20
 
21
21
  <TMagicTooltip content="点击选中组件" placement="top">
22
22
  <TMagicButton
23
- text
23
+ link
24
24
  style="padding: 0; margin: 0"
25
25
  :disabled="disabled"
26
26
  :size="size"
@@ -33,7 +33,7 @@
33
33
  </template>
34
34
 
35
35
  <TMagicTooltip v-else content="点击此处选择" placement="top">
36
- <TMagicButton text style="padding: 0; margin: 0" :disabled="disabled" :size="size" @click="startSelect"
36
+ <TMagicButton link style="padding: 0; margin: 0" :disabled="disabled" :size="size" @click="startSelect"
37
37
  >点击此处选择</TMagicButton
38
38
  >
39
39
  </TMagicTooltip>
@@ -22,12 +22,12 @@
22
22
  import { onBeforeUnmount, onMounted, ref, watch } from 'vue';
23
23
  import { FullScreen } from '@element-plus/icons-vue';
24
24
  import { throttle } from 'lodash-es';
25
- import * as monaco from 'monaco-editor';
26
25
  import serialize from 'serialize-javascript';
27
26
 
28
27
  import { TMagicButton } from '@tmagic/design';
29
28
 
30
29
  import { getConfig } from '@editor/utils/config';
30
+ import monaco from '@editor/utils/monaco-editor';
31
31
 
32
32
  defineOptions({
33
33
  name: 'MEditorCodeEditor',
@@ -4,7 +4,7 @@
4
4
  class="m-editor-page-bar-switch-type-button"
5
5
  size="small"
6
6
  :key="item.type"
7
- text
7
+ link
8
8
  :class="{ active: modelValue === item.type }"
9
9
  :type="modelValue === item.type ? 'primary' : ''"
10
10
  @click="clickHandler(item.type)"
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div v-if="nodes.length === 1" class="m-editor-breadcrumb">
3
3
  <template v-for="(item, index) in path" :key="item.id">
4
- <TMagicButton text :disabled="item.id === node?.id" @click="select(item)">{{ item.name }}</TMagicButton
4
+ <TMagicButton link :disabled="item.id === node?.id" @click="select(item)">{{ item.name }}</TMagicButton
5
5
  ><span v-if="index < path.length - 1">/</span>
6
6
  </template>
7
7
  </div>
@@ -775,17 +775,23 @@ class Editor extends BaseService {
775
775
  const layout = await this.getLayout(parent, node);
776
776
  const isRelative = layout === Layout.RELATIVE;
777
777
 
778
- brothers.splice(index, 1);
779
-
778
+ let offsetIndex: number;
780
779
  if (offset === LayerOffset.TOP) {
781
- brothers.splice(isRelative ? 0 : brothers.length, 0, node);
780
+ offsetIndex = isRelative ? 0 : brothers.length;
782
781
  } else if (offset === LayerOffset.BOTTOM) {
783
- brothers.splice(isRelative ? brothers.length : 0, 0, node);
782
+ offsetIndex = isRelative ? brothers.length : 0;
784
783
  } else {
785
- brothers.splice(index + (isRelative ? -offset : offset), 0, node);
784
+ offsetIndex = index + (isRelative ? -offset : offset);
786
785
  }
787
786
 
787
+ if ((offsetIndex > 0 && offsetIndex > brothers.length) || offsetIndex < 0) {
788
+ return;
789
+ }
790
+ brothers.splice(index, 1);
791
+ brothers.splice(offsetIndex, 0, node);
792
+
788
793
  const grandparent = this.getParentById(parent.id);
794
+
789
795
  this.get('stage')?.update({
790
796
  config: cloneDeep(toRaw(parent)),
791
797
  parentId: grandparent?.id,
@@ -794,6 +800,8 @@ class Editor extends BaseService {
794
800
 
795
801
  this.addModifiedNodeId(parent.id);
796
802
  this.pushHistoryState();
803
+
804
+ this.emit('move-layer', offset);
797
805
  }
798
806
 
799
807
  /**
@@ -17,12 +17,12 @@
17
17
  */
18
18
 
19
19
  import { reactive } from 'vue';
20
- import { cloneDeep, get, mergeWith, set } from 'lodash-es';
20
+ import { cloneDeep, mergeWith } from 'lodash-es';
21
21
 
22
22
  import { DepTargetType } from '@tmagic/dep';
23
23
  import type { FormConfig } from '@tmagic/form';
24
24
  import type { Id, MComponent, MNode } from '@tmagic/schema';
25
- import { guid, toLine } from '@tmagic/utils';
25
+ import { getValueByKeyPath, guid, setValueByKeyPath, toLine } from '@tmagic/utils';
26
26
 
27
27
  import depService from '@editor/services/dep';
28
28
  import editorService from '@editor/services/editor';
@@ -194,17 +194,22 @@ class Props extends BaseService {
194
194
  public replaceRelateId(originConfigs: MNode[], targetConfigs: MNode[]) {
195
195
  const relateIdMap = this.getRelateIdMap();
196
196
  if (Object.keys(relateIdMap).length === 0) return;
197
+
197
198
  const target = depService.getTarget(DepTargetType.RELATED_COMP_WHEN_COPY, DepTargetType.RELATED_COMP_WHEN_COPY);
198
199
  if (!target) return;
200
+
199
201
  originConfigs.forEach((config: MNode) => {
200
202
  const newId = relateIdMap[config.id];
201
203
  const targetConfig = targetConfigs.find((targetConfig) => targetConfig.id === newId);
204
+
202
205
  if (!targetConfig) return;
206
+
203
207
  target.deps[config.id]?.keys?.forEach((fullKey) => {
204
- const relateOriginId = get(config, fullKey);
208
+ const relateOriginId = getValueByKeyPath(fullKey, config);
205
209
  const relateTargetId = relateIdMap[relateOriginId];
206
210
  if (!relateTargetId) return;
207
- set(targetConfig, fullKey, relateTargetId);
211
+
212
+ setValueByKeyPath(fullKey, relateTargetId, targetConfig);
208
213
  });
209
214
  });
210
215
  }
@@ -0,0 +1,8 @@
1
+ import { emmetCSS, emmetHTML } from 'emmet-monaco-es';
2
+ import * as monaco from 'monaco-editor';
3
+
4
+ // 注册emmet插件
5
+ emmetHTML(monaco);
6
+ emmetCSS(monaco, ['css', 'scss']);
7
+
8
+ export default monaco;
@@ -1,4 +1,4 @@
1
- import * as monaco from 'monaco-editor';
1
+ import monaco from '../utils/monaco-editor';
2
2
  declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
3
  initValues?: any;
4
4
  modifiedValues?: any;
@@ -0,0 +1,2 @@
1
+ import * as monaco from 'monaco-editor';
2
+ export default monaco;