@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/dist/tmagic-editor.js +31 -21
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +31 -22
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +12 -11
- package/src/components/CodeBlockEditor.vue +1 -1
- package/src/components/FloatingBox.vue +1 -1
- package/src/components/ToolButton.vue +2 -2
- package/src/fields/EventSelect.vue +1 -1
- package/src/fields/KeyValue.vue +1 -1
- package/src/fields/UISelect.vue +4 -4
- package/src/layouts/CodeEditor.vue +1 -1
- package/src/layouts/page-bar/SwitchTypeButton.vue +1 -1
- package/src/layouts/workspace/Breadcrumb.vue +1 -1
- package/src/services/editor.ts +13 -5
- package/src/services/props.ts +9 -4
- package/src/utils/monaco-editor.ts +8 -0
- package/types/layouts/CodeEditor.vue.d.ts +1 -1
- package/types/utils/monaco-editor.d.ts +2 -0
package/dist/tmagic-editor.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { defineComponent, ref, watch, onMounted, onBeforeUnmount, openBlock, createElementBlock, createBlock, Teleport, createElementVNode, normalizeClass, normalizeStyle, createVNode, unref, computed, reactive, resolveComponent, inject, withCtx, Fragment, resolveDynamicComponent, createTextVNode, createCommentVNode, toRaw, nextTick, mergeProps, toDisplayString, renderList, createStaticVNode, watchEffect, withModifiers, renderSlot, normalizeProps, resolveDirective, withDirectives, createSlots, markRaw, getCurrentInstance, vShow, provide, Transition, toHandlers, mergeDefaults } from 'vue';
|
|
2
2
|
import { FullScreen, Edit, View, Coin, Delete, Plus, Close, ArrowDown, ArrowLeftBold, ArrowRightBold, CaretBottom, DocumentCopy, Grid, Memo, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Search, ArrowRight, CopyDocument, Files, Hide, Goods, List, EditPen, Top, Bottom } from '@element-plus/icons-vue';
|
|
3
|
-
import { throttle, isEmpty, cloneDeep, mergeWith,
|
|
4
|
-
import * as monaco from 'monaco-editor';
|
|
3
|
+
import { throttle, isEmpty, cloneDeep, mergeWith, isObject, uniq, get, map, has, pick, keys } from 'lodash-es';
|
|
5
4
|
import serialize from 'serialize-javascript';
|
|
6
5
|
import { TMagicButton, TMagicCard, tMagicMessage, TMagicDialog, TMagicTag, tMagicMessageBox, TMagicIcon, getConfig as getConfig$1, TMagicSwitch, TMagicInput, TMagicTooltip, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicPopover, TMagicScrollbar, TMagicCollapse, TMagicCollapseItem } from '@tmagic/design';
|
|
6
|
+
import { emmetHTML, emmetCSS } from 'emmet-monaco-es';
|
|
7
|
+
import * as monaco from 'monaco-editor';
|
|
7
8
|
import { HookType, NodeType, ActionType } from '@tmagic/schema';
|
|
8
9
|
import { MFormBox, MFormDrawer, MForm, createValues, MSelect } from '@tmagic/form';
|
|
9
10
|
import { MagicTable } from '@tmagic/table';
|
|
10
|
-
import { guid, isPage, isPageFragment, isPop, getNodePath, isNumber, toLine, getDefaultValueFromFields, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, getKeys, addClassName, removeClassName, removeClassNameByClassName, convertToNumber, getNodes } from '@tmagic/utils';
|
|
11
|
+
import { guid, isPage, isPageFragment, isPop, getNodePath, isNumber, toLine, getValueByKeyPath, setValueByKeyPath, getDefaultValueFromFields, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, getKeys, addClassName, removeClassName, removeClassNameByClassName, convertToNumber, getNodes } from '@tmagic/utils';
|
|
11
12
|
import Gesto from 'gesto';
|
|
12
13
|
import Moveable from 'moveable';
|
|
13
14
|
import { Watcher, DepTargetType, createRelatedCompTarget, createCodeBlockTarget, createDataSourceTarget, createDataSourceMethodTarget, createDataSourceCondTarget } from '@tmagic/dep';
|
|
@@ -23,6 +24,9 @@ const setConfig = (option) => {
|
|
|
23
24
|
};
|
|
24
25
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
25
26
|
|
|
27
|
+
emmetHTML(monaco);
|
|
28
|
+
emmetCSS(monaco, ["css", "scss"]);
|
|
29
|
+
|
|
26
30
|
const _hoisted_1$t = {
|
|
27
31
|
class: /* @__PURE__ */ normalizeClass(`magic-code-editor`)
|
|
28
32
|
};
|
|
@@ -612,7 +616,7 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
|
|
|
612
616
|
left: withCtx(() => [
|
|
613
617
|
createVNode(unref(TMagicButton), {
|
|
614
618
|
type: "primary",
|
|
615
|
-
|
|
619
|
+
link: "",
|
|
616
620
|
onClick: _cache[0] || (_cache[0] = ($event) => difVisible.value = true)
|
|
617
621
|
}, {
|
|
618
622
|
default: withCtx(() => [
|
|
@@ -2253,11 +2257,11 @@ class Props extends BaseService {
|
|
|
2253
2257
|
if (!targetConfig)
|
|
2254
2258
|
return;
|
|
2255
2259
|
target.deps[config.id]?.keys?.forEach((fullKey) => {
|
|
2256
|
-
const relateOriginId =
|
|
2260
|
+
const relateOriginId = getValueByKeyPath(fullKey, config);
|
|
2257
2261
|
const relateTargetId = relateIdMap[relateOriginId];
|
|
2258
2262
|
if (!relateTargetId)
|
|
2259
2263
|
return;
|
|
2260
|
-
|
|
2264
|
+
setValueByKeyPath(fullKey, relateTargetId, targetConfig);
|
|
2261
2265
|
});
|
|
2262
2266
|
});
|
|
2263
2267
|
}
|
|
@@ -2897,14 +2901,19 @@ class Editor extends BaseService {
|
|
|
2897
2901
|
const index = brothers.findIndex((item) => `${item.id}` === `${node?.id}`);
|
|
2898
2902
|
const layout = await this.getLayout(parent, node);
|
|
2899
2903
|
const isRelative = layout === Layout.RELATIVE;
|
|
2900
|
-
|
|
2904
|
+
let offsetIndex;
|
|
2901
2905
|
if (offset === LayerOffset.TOP) {
|
|
2902
|
-
|
|
2906
|
+
offsetIndex = isRelative ? 0 : brothers.length;
|
|
2903
2907
|
} else if (offset === LayerOffset.BOTTOM) {
|
|
2904
|
-
|
|
2908
|
+
offsetIndex = isRelative ? brothers.length : 0;
|
|
2905
2909
|
} else {
|
|
2906
|
-
|
|
2910
|
+
offsetIndex = index + (isRelative ? -offset : offset);
|
|
2907
2911
|
}
|
|
2912
|
+
if (offsetIndex > 0 && offsetIndex > brothers.length || offsetIndex < 0) {
|
|
2913
|
+
return;
|
|
2914
|
+
}
|
|
2915
|
+
brothers.splice(index, 1);
|
|
2916
|
+
brothers.splice(offsetIndex, 0, node);
|
|
2908
2917
|
const grandparent = this.getParentById(parent.id);
|
|
2909
2918
|
this.get("stage")?.update({
|
|
2910
2919
|
config: cloneDeep(toRaw(parent)),
|
|
@@ -2913,6 +2922,7 @@ class Editor extends BaseService {
|
|
|
2913
2922
|
});
|
|
2914
2923
|
this.addModifiedNodeId(parent.id);
|
|
2915
2924
|
this.pushHistoryState();
|
|
2925
|
+
this.emit("move-layer", offset);
|
|
2916
2926
|
}
|
|
2917
2927
|
/**
|
|
2918
2928
|
* 移动到指定容器中
|
|
@@ -4899,7 +4909,7 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
4899
4909
|
}, null, 8, ["config", "model", "disabled", "size"]),
|
|
4900
4910
|
createVNode(unref(TMagicButton), {
|
|
4901
4911
|
style: { "color": "#f56c6c" },
|
|
4902
|
-
|
|
4912
|
+
link: "",
|
|
4903
4913
|
icon: unref(Delete),
|
|
4904
4914
|
disabled: _ctx.disabled,
|
|
4905
4915
|
size: _ctx.size,
|
|
@@ -5063,7 +5073,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
5063
5073
|
key: 2,
|
|
5064
5074
|
size: "default",
|
|
5065
5075
|
disabled: _ctx.disabled,
|
|
5066
|
-
|
|
5076
|
+
link: "",
|
|
5067
5077
|
icon: _sfc_main$D,
|
|
5068
5078
|
onClick: _cache[0] || (_cache[0] = ($event) => showCode.value = !showCode.value)
|
|
5069
5079
|
}, null, 8, ["disabled"])) : createCommentVNode("", true)
|
|
@@ -5228,7 +5238,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
|
5228
5238
|
icon: unref(Delete),
|
|
5229
5239
|
disabled: _ctx.disabled,
|
|
5230
5240
|
size: _ctx.size,
|
|
5231
|
-
|
|
5241
|
+
link: "",
|
|
5232
5242
|
style: { "padding": "0" }
|
|
5233
5243
|
}, {
|
|
5234
5244
|
default: withCtx(() => [
|
|
@@ -5249,7 +5259,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
|
5249
5259
|
icon: unref(Close),
|
|
5250
5260
|
disabled: _ctx.disabled,
|
|
5251
5261
|
size: _ctx.size,
|
|
5252
|
-
|
|
5262
|
+
link: "",
|
|
5253
5263
|
onClick: withModifiers(deleteHandler, ["stop"])
|
|
5254
5264
|
}, null, 8, ["icon", "disabled", "size", "onClick"])
|
|
5255
5265
|
]),
|
|
@@ -5261,7 +5271,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
|
5261
5271
|
}, {
|
|
5262
5272
|
default: withCtx(() => [
|
|
5263
5273
|
createVNode(unref(TMagicButton), {
|
|
5264
|
-
|
|
5274
|
+
link: "",
|
|
5265
5275
|
style: { "padding": "0", "margin": "0" },
|
|
5266
5276
|
disabled: _ctx.disabled,
|
|
5267
5277
|
size: _ctx.size,
|
|
@@ -5284,7 +5294,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
|
5284
5294
|
}, {
|
|
5285
5295
|
default: withCtx(() => [
|
|
5286
5296
|
createVNode(unref(TMagicButton), {
|
|
5287
|
-
|
|
5297
|
+
link: "",
|
|
5288
5298
|
style: { "padding": "0", "margin": "0" },
|
|
5289
5299
|
disabled: _ctx.disabled,
|
|
5290
5300
|
size: _ctx.size,
|
|
@@ -5596,7 +5606,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5596
5606
|
default: withCtx(() => [
|
|
5597
5607
|
createVNode(unref(TMagicButton), {
|
|
5598
5608
|
size: "small",
|
|
5599
|
-
|
|
5609
|
+
link: "",
|
|
5600
5610
|
disabled: disabled.value
|
|
5601
5611
|
}, {
|
|
5602
5612
|
default: withCtx(() => [
|
|
@@ -5613,7 +5623,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5613
5623
|
}, 8, ["content"])) : (openBlock(), createBlock(unref(TMagicButton), {
|
|
5614
5624
|
key: 1,
|
|
5615
5625
|
size: "small",
|
|
5616
|
-
|
|
5626
|
+
link: "",
|
|
5617
5627
|
disabled: disabled.value,
|
|
5618
5628
|
title: _ctx.data.text
|
|
5619
5629
|
}, {
|
|
@@ -5871,7 +5881,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
5871
5881
|
class: normalizeClass(["m-editor-page-bar-switch-type-button", { active: _ctx.modelValue === item.type }]),
|
|
5872
5882
|
size: "small",
|
|
5873
5883
|
key: item.type,
|
|
5874
|
-
|
|
5884
|
+
link: "",
|
|
5875
5885
|
type: _ctx.modelValue === item.type ? "primary" : "",
|
|
5876
5886
|
onClick: ($event) => clickHandler(item.type)
|
|
5877
5887
|
}, {
|
|
@@ -9439,7 +9449,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
9439
9449
|
]),
|
|
9440
9450
|
createElementVNode("div", null, [
|
|
9441
9451
|
createVNode(unref(TMagicButton), {
|
|
9442
|
-
|
|
9452
|
+
link: "",
|
|
9443
9453
|
size: "small",
|
|
9444
9454
|
icon: unref(Close),
|
|
9445
9455
|
onClick: closeHandler
|
|
@@ -9956,7 +9966,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
9956
9966
|
key: item.id
|
|
9957
9967
|
}, [
|
|
9958
9968
|
createVNode(unref(TMagicButton), {
|
|
9959
|
-
|
|
9969
|
+
link: "",
|
|
9960
9970
|
disabled: item.id === node.value?.id,
|
|
9961
9971
|
onClick: ($event) => select(item)
|
|
9962
9972
|
}, {
|