@tmagic/editor 1.2.0-beta.13 → 1.2.0-beta.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.
- package/dist/style.css +14 -3
- package/dist/tmagic-editor.mjs +88 -28
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +87 -27
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +9 -9
- package/src/components/CodeDraftEditor.vue +17 -2
- package/src/components/FunctionEditor.vue +4 -3
- package/src/components/Layout.vue +52 -13
- package/src/layouts/sidebar/LayerMenu.vue +2 -2
- package/src/layouts/workspace/ViewerMenu.vue +3 -2
- package/src/services/BaseService.ts +1 -1
- package/src/services/codeBlock.ts +7 -7
- package/src/theme/code-block.scss +16 -3
- package/types/components/Layout.vue.d.ts +12 -1
- package/types/services/BaseService.d.ts +1 -1
- package/types/services/codeBlock.d.ts +1 -1
package/dist/style.css
CHANGED
|
@@ -694,6 +694,9 @@
|
|
|
694
694
|
.m-fields-code-select {
|
|
695
695
|
width: 100%;
|
|
696
696
|
}
|
|
697
|
+
.el-dialog.is-fullscreen.code-editor-dialog {
|
|
698
|
+
overflow: hidden;
|
|
699
|
+
}
|
|
697
700
|
.code-editor-dialog .el-dialog__body {
|
|
698
701
|
height: 90%;
|
|
699
702
|
padding-top: 10px;
|
|
@@ -758,7 +761,7 @@
|
|
|
758
761
|
position: absolute;
|
|
759
762
|
top: 0;
|
|
760
763
|
left: 4px;
|
|
761
|
-
width: 100
|
|
764
|
+
width: calc(100% - 9px);
|
|
762
765
|
height: 100%;
|
|
763
766
|
z-index: 10;
|
|
764
767
|
background: #fff;
|
|
@@ -769,8 +772,16 @@
|
|
|
769
772
|
.code-editor-dialog .m-editor-wrapper {
|
|
770
773
|
height: 100%;
|
|
771
774
|
}
|
|
775
|
+
.code-editor-dialog .m-editor-wrapper.fullScreen {
|
|
776
|
+
height: 100%;
|
|
777
|
+
width: 100%;
|
|
778
|
+
position: fixed;
|
|
779
|
+
top: 0;
|
|
780
|
+
left: 0;
|
|
781
|
+
z-index: 100;
|
|
782
|
+
}
|
|
772
783
|
.code-editor-dialog .m-editor-wrapper .m-editor-container {
|
|
773
|
-
height: calc(100% -
|
|
784
|
+
height: calc(100% - 45px);
|
|
774
785
|
}
|
|
775
786
|
.code-editor-dialog .m-editor-wrapper .m-editor-content-bottom {
|
|
776
787
|
height: 45px;
|
|
@@ -784,7 +795,7 @@
|
|
|
784
795
|
}
|
|
785
796
|
.code-editor-dialog .m-editor-wrapper .m-editor-content-bottom > button {
|
|
786
797
|
height: 30px;
|
|
787
|
-
margin-top:
|
|
798
|
+
margin-top: 5px;
|
|
788
799
|
}
|
|
789
800
|
.m-editor-layout {
|
|
790
801
|
width: 100%;
|
package/dist/tmagic-editor.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { defineComponent, computed, resolveComponent, openBlock, createBlock, no
|
|
|
2
2
|
import serialize from 'serialize-javascript';
|
|
3
3
|
import { isEmpty, map, throttle, pick, omit, keys, cloneDeep, forIn, mergeWith, uniq, isObject } from 'lodash-es';
|
|
4
4
|
import { HookType, NodeType } from '@tmagic/schema';
|
|
5
|
-
import { Delete, Close, Edit, Plus, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, View, Link, Search, Files,
|
|
5
|
+
import { Delete, Close, Edit, Plus, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, View, Link, Search, Files, CopyDocument, Coin, EditPen, ArrowLeftBold, ArrowRightBold, CaretBottom, DocumentCopy, Top, Bottom } from '@element-plus/icons-vue';
|
|
6
6
|
import { TMagicButton, TMagicTooltip, TMagicIcon, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, tMagicMessage, tMagicMessageBox, TMagicCard, TMagicInput, TMagicDialog, TMagicTree, TMagicCollapse, TMagicCollapseItem, getConfig as getConfig$1, TMagicTabs, TMagicPopover } from '@tmagic/design';
|
|
7
7
|
import * as monaco from 'monaco-editor';
|
|
8
8
|
import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS, ContainerHighlightType } from '@tmagic/stage';
|
|
@@ -513,8 +513,9 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
513
513
|
props: {
|
|
514
514
|
left: null,
|
|
515
515
|
right: null,
|
|
516
|
-
minLeft: { default:
|
|
516
|
+
minLeft: { default: 46 },
|
|
517
517
|
minRight: { default: 1 },
|
|
518
|
+
minCenter: { default: 1 },
|
|
518
519
|
leftClass: null,
|
|
519
520
|
rightClass: null,
|
|
520
521
|
centerClass: null
|
|
@@ -523,15 +524,42 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
523
524
|
setup(__props, { emit }) {
|
|
524
525
|
const props = __props;
|
|
525
526
|
const el = ref();
|
|
527
|
+
const hasLeft = computed(() => typeof props.left !== "undefined");
|
|
528
|
+
const hasRight = computed(() => typeof props.left !== "undefined");
|
|
529
|
+
const getCenterWidth = (clientWidth2, left, right) => {
|
|
530
|
+
let center2 = clientWidth2 - left - right;
|
|
531
|
+
if (center2 < props.minCenter) {
|
|
532
|
+
center2 = props.minCenter;
|
|
533
|
+
if (left < right) {
|
|
534
|
+
right = clientWidth2 - left - props.minCenter;
|
|
535
|
+
} else {
|
|
536
|
+
left = clientWidth2 - right - props.minCenter;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return {
|
|
540
|
+
center: center2,
|
|
541
|
+
left,
|
|
542
|
+
right
|
|
543
|
+
};
|
|
544
|
+
};
|
|
526
545
|
let clientWidth = 0;
|
|
527
546
|
const resizerObserver = new ResizeObserver((entries) => {
|
|
528
547
|
for (const { contentRect } of entries) {
|
|
529
548
|
clientWidth = contentRect.width;
|
|
530
|
-
|
|
549
|
+
let left = props.left || 0;
|
|
550
|
+
let right = props.right || 0;
|
|
551
|
+
if (left > clientWidth) {
|
|
552
|
+
left = clientWidth / 3;
|
|
553
|
+
}
|
|
554
|
+
if (right > clientWidth) {
|
|
555
|
+
right = clientWidth / 3;
|
|
556
|
+
}
|
|
557
|
+
const columnWidth = getCenterWidth(clientWidth, left, right);
|
|
558
|
+
center.value = columnWidth.center;
|
|
531
559
|
emit("change", {
|
|
532
|
-
left:
|
|
560
|
+
left: columnWidth.left,
|
|
533
561
|
center: center.value,
|
|
534
|
-
right:
|
|
562
|
+
right: columnWidth.right
|
|
535
563
|
});
|
|
536
564
|
}
|
|
537
565
|
});
|
|
@@ -552,11 +580,12 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
552
580
|
if (clientWidth - left - (props.right || 0) <= 0) {
|
|
553
581
|
left = props.left;
|
|
554
582
|
}
|
|
555
|
-
|
|
583
|
+
const columnWidth = getCenterWidth(clientWidth, left, props.right || 0);
|
|
584
|
+
center.value = columnWidth.center;
|
|
556
585
|
emit("change", {
|
|
557
|
-
left,
|
|
586
|
+
left: columnWidth.left,
|
|
558
587
|
center: center.value,
|
|
559
|
-
right:
|
|
588
|
+
right: columnWidth.right
|
|
560
589
|
});
|
|
561
590
|
};
|
|
562
591
|
const changeRight = (deltaX) => {
|
|
@@ -567,11 +596,12 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
567
596
|
if (clientWidth - (props.left || 0) - right <= 0) {
|
|
568
597
|
right = props.right;
|
|
569
598
|
}
|
|
570
|
-
|
|
599
|
+
const columnWidth = getCenterWidth(clientWidth, props.left || 0, right);
|
|
600
|
+
center.value = columnWidth.center;
|
|
571
601
|
emit("change", {
|
|
572
|
-
left:
|
|
602
|
+
left: columnWidth.left,
|
|
573
603
|
center: center.value,
|
|
574
|
-
right
|
|
604
|
+
right: columnWidth.right
|
|
575
605
|
});
|
|
576
606
|
};
|
|
577
607
|
return (_ctx, _cache) => {
|
|
@@ -580,7 +610,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
580
610
|
ref: el,
|
|
581
611
|
class: "m-editor-layout"
|
|
582
612
|
}, [
|
|
583
|
-
|
|
613
|
+
unref(hasLeft) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
584
614
|
createElementVNode("div", {
|
|
585
615
|
class: normalizeClass(["m-editor-layout-left", __props.leftClass]),
|
|
586
616
|
style: normalizeStyle(`width: ${__props.left}px`)
|
|
@@ -595,7 +625,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
595
625
|
}, [
|
|
596
626
|
renderSlot(_ctx.$slots, "center")
|
|
597
627
|
], 6),
|
|
598
|
-
|
|
628
|
+
unref(hasRight) ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
599
629
|
createVNode(_sfc_main$p, { onChange: changeRight }),
|
|
600
630
|
createElementVNode("div", {
|
|
601
631
|
class: normalizeClass(["m-editor-layout-right", __props.rightClass]),
|
|
@@ -3127,18 +3157,17 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
3127
3157
|
}
|
|
3128
3158
|
});
|
|
3129
3159
|
|
|
3130
|
-
const _hoisted_1$9 = {
|
|
3131
|
-
const _hoisted_2$5 = {
|
|
3160
|
+
const _hoisted_1$9 = {
|
|
3132
3161
|
key: 0,
|
|
3133
3162
|
class: "m-editor-content-bottom"
|
|
3134
3163
|
};
|
|
3135
|
-
const
|
|
3136
|
-
const
|
|
3137
|
-
const
|
|
3164
|
+
const _hoisted_2$5 = /* @__PURE__ */ createTextVNode("\u4FDD\u5B58");
|
|
3165
|
+
const _hoisted_3$3 = /* @__PURE__ */ createTextVNode("\u5173\u95ED");
|
|
3166
|
+
const _hoisted_4$2 = {
|
|
3138
3167
|
key: 1,
|
|
3139
3168
|
class: "m-editor-content-bottom"
|
|
3140
3169
|
};
|
|
3141
|
-
const
|
|
3170
|
+
const _hoisted_5$1 = /* @__PURE__ */ createTextVNode("\u5173\u95ED");
|
|
3142
3171
|
const __default__$g = defineComponent({
|
|
3143
3172
|
name: "MEditorCodeDraftEditor"
|
|
3144
3173
|
});
|
|
@@ -3160,6 +3189,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
3160
3189
|
const editorContent = ref("");
|
|
3161
3190
|
const codeEditor = ref();
|
|
3162
3191
|
const originCodeContent = ref("");
|
|
3192
|
+
const isFullScreen = ref(false);
|
|
3163
3193
|
const codeOptions = computed(() => ({
|
|
3164
3194
|
...props.codeOptions,
|
|
3165
3195
|
readOnly: !props.editable
|
|
@@ -3213,8 +3243,16 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
3213
3243
|
emit("close");
|
|
3214
3244
|
}
|
|
3215
3245
|
};
|
|
3246
|
+
const toggleFullScreen = () => {
|
|
3247
|
+
isFullScreen.value = !isFullScreen.value;
|
|
3248
|
+
if (codeEditor.value) {
|
|
3249
|
+
codeEditor.value.focus();
|
|
3250
|
+
}
|
|
3251
|
+
};
|
|
3216
3252
|
return (_ctx, _cache) => {
|
|
3217
|
-
return openBlock(), createElementBlock("div",
|
|
3253
|
+
return openBlock(), createElementBlock("div", {
|
|
3254
|
+
class: normalizeClass(["m-editor-wrapper", isFullScreen.value ? "fullScreen" : "normal"])
|
|
3255
|
+
}, [
|
|
3218
3256
|
createVNode(_sfc_main$q, {
|
|
3219
3257
|
ref_key: "codeEditor",
|
|
3220
3258
|
ref: codeEditor,
|
|
@@ -3224,14 +3262,24 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
3224
3262
|
language: __props.language,
|
|
3225
3263
|
options: unref(codeOptions)
|
|
3226
3264
|
}, null, 8, ["init-values", "language", "options"]),
|
|
3227
|
-
__props.editable ? (openBlock(), createElementBlock("div",
|
|
3265
|
+
__props.editable ? (openBlock(), createElementBlock("div", _hoisted_1$9, [
|
|
3266
|
+
createVNode(unref(TMagicButton), {
|
|
3267
|
+
type: "primary",
|
|
3268
|
+
class: "button",
|
|
3269
|
+
onClick: toggleFullScreen
|
|
3270
|
+
}, {
|
|
3271
|
+
default: withCtx(() => [
|
|
3272
|
+
createTextVNode(toDisplayString(isFullScreen.value ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F"), 1)
|
|
3273
|
+
]),
|
|
3274
|
+
_: 1
|
|
3275
|
+
}),
|
|
3228
3276
|
createVNode(unref(TMagicButton), {
|
|
3229
3277
|
type: "primary",
|
|
3230
3278
|
class: "button",
|
|
3231
3279
|
onClick: saveCode
|
|
3232
3280
|
}, {
|
|
3233
3281
|
default: withCtx(() => [
|
|
3234
|
-
|
|
3282
|
+
_hoisted_2$5
|
|
3235
3283
|
]),
|
|
3236
3284
|
_: 1
|
|
3237
3285
|
}),
|
|
@@ -3241,23 +3289,33 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
3241
3289
|
onClick: close
|
|
3242
3290
|
}, {
|
|
3243
3291
|
default: withCtx(() => [
|
|
3244
|
-
|
|
3292
|
+
_hoisted_3$3
|
|
3245
3293
|
]),
|
|
3246
3294
|
_: 1
|
|
3247
3295
|
})
|
|
3248
|
-
])) : (openBlock(), createElementBlock("div",
|
|
3296
|
+
])) : (openBlock(), createElementBlock("div", _hoisted_4$2, [
|
|
3297
|
+
createVNode(unref(TMagicButton), {
|
|
3298
|
+
type: "primary",
|
|
3299
|
+
class: "button",
|
|
3300
|
+
onClick: toggleFullScreen
|
|
3301
|
+
}, {
|
|
3302
|
+
default: withCtx(() => [
|
|
3303
|
+
createTextVNode(toDisplayString(isFullScreen.value ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F"), 1)
|
|
3304
|
+
]),
|
|
3305
|
+
_: 1
|
|
3306
|
+
}),
|
|
3249
3307
|
createVNode(unref(TMagicButton), {
|
|
3250
3308
|
type: "primary",
|
|
3251
3309
|
class: "button",
|
|
3252
3310
|
onClick: close
|
|
3253
3311
|
}, {
|
|
3254
3312
|
default: withCtx(() => [
|
|
3255
|
-
|
|
3313
|
+
_hoisted_5$1
|
|
3256
3314
|
]),
|
|
3257
3315
|
_: 1
|
|
3258
3316
|
})
|
|
3259
3317
|
]))
|
|
3260
|
-
]);
|
|
3318
|
+
], 2);
|
|
3261
3319
|
};
|
|
3262
3320
|
}
|
|
3263
3321
|
});
|
|
@@ -3286,6 +3344,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
3286
3344
|
border: true,
|
|
3287
3345
|
enableFullscreen: false,
|
|
3288
3346
|
name: "params",
|
|
3347
|
+
maxHeight: "150px",
|
|
3289
3348
|
items: [
|
|
3290
3349
|
{
|
|
3291
3350
|
type: "text",
|
|
@@ -4104,7 +4163,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
4104
4163
|
{
|
|
4105
4164
|
type: "button",
|
|
4106
4165
|
text: "\u590D\u5236",
|
|
4107
|
-
icon: markRaw(
|
|
4166
|
+
icon: markRaw(CopyDocument),
|
|
4108
4167
|
display: () => !isRoot.value,
|
|
4109
4168
|
handler: () => {
|
|
4110
4169
|
node.value && services?.editorService.copy(node.value);
|
|
@@ -5234,7 +5293,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
5234
5293
|
{
|
|
5235
5294
|
type: "button",
|
|
5236
5295
|
text: "\u590D\u5236",
|
|
5237
|
-
icon: markRaw(
|
|
5296
|
+
icon: markRaw(CopyDocument),
|
|
5238
5297
|
handler: () => {
|
|
5239
5298
|
nodes.value && editorService?.copy(nodes.value);
|
|
5240
5299
|
canPaste.value = true;
|
|
@@ -5243,6 +5302,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
5243
5302
|
{
|
|
5244
5303
|
type: "button",
|
|
5245
5304
|
text: "\u7C98\u8D34",
|
|
5305
|
+
icon: markRaw(DocumentCopy),
|
|
5246
5306
|
display: () => canPaste.value,
|
|
5247
5307
|
handler: () => {
|
|
5248
5308
|
const rect = menu.value?.$el.getBoundingClientRect();
|