@tmagic/editor 1.2.0-beta.14 → 1.2.0-beta.16
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 +3 -4
- package/dist/tmagic-editor.mjs +89 -93
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +92 -97
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +9 -9
- package/src/layouts/PropsPanel.vue +8 -4
- package/src/layouts/sidebar/LayerPanel.vue +68 -76
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +1 -1
- package/src/services/codeBlock.ts +8 -6
- package/src/theme/code-block.scss +3 -4
package/dist/style.css
CHANGED
|
@@ -655,9 +655,7 @@
|
|
|
655
655
|
align-items: center;
|
|
656
656
|
}
|
|
657
657
|
.m-editor-code-block-list .list-container .list-item .right-tool {
|
|
658
|
-
|
|
659
|
-
right: 15px;
|
|
660
|
-
padding-left: 5px;
|
|
658
|
+
width: fit-content !important;
|
|
661
659
|
display: flex;
|
|
662
660
|
align-items: center;
|
|
663
661
|
}
|
|
@@ -670,7 +668,8 @@
|
|
|
670
668
|
white-space: nowrap;
|
|
671
669
|
text-overflow: ellipsis;
|
|
672
670
|
padding: 10px 15px;
|
|
673
|
-
|
|
671
|
+
width: 0 !important;
|
|
672
|
+
flex: 1;
|
|
674
673
|
}
|
|
675
674
|
.m-editor-code-block-list .list-container .code-comp-map-wrapper {
|
|
676
675
|
display: flex;
|
package/dist/tmagic-editor.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import Gesto from 'gesto';
|
|
|
10
10
|
import { isPop, getNodePath, isNumber, isPage, toLine, datetimeFormatter, removeClassNameByClassName } from '@tmagic/utils';
|
|
11
11
|
import { EventEmitter } from 'events';
|
|
12
12
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
13
|
+
import { MForm } from '@tmagic/form';
|
|
13
14
|
import KeyController from 'keycon';
|
|
14
15
|
|
|
15
16
|
const __default__$t = defineComponent({
|
|
@@ -910,11 +911,14 @@ class CodeBlock extends BaseService {
|
|
|
910
911
|
}
|
|
911
912
|
async setCodeDslById(id, codeConfig) {
|
|
912
913
|
let codeDsl = await this.getCodeDsl();
|
|
914
|
+
const codeConfigProcessed = codeConfig;
|
|
915
|
+
if (codeConfig.content) {
|
|
916
|
+
codeConfigProcessed.content = eval(codeConfig.content);
|
|
917
|
+
}
|
|
913
918
|
if (!codeDsl) {
|
|
914
919
|
codeDsl = {
|
|
915
920
|
[id]: {
|
|
916
|
-
...
|
|
917
|
-
content: eval(codeConfig.content)
|
|
921
|
+
...codeConfigProcessed
|
|
918
922
|
}
|
|
919
923
|
};
|
|
920
924
|
} else {
|
|
@@ -923,8 +927,7 @@ class CodeBlock extends BaseService {
|
|
|
923
927
|
...codeDsl,
|
|
924
928
|
[id]: {
|
|
925
929
|
...existContent,
|
|
926
|
-
...
|
|
927
|
-
content: eval(codeConfig.content)
|
|
930
|
+
...codeConfigProcessed
|
|
928
931
|
}
|
|
929
932
|
};
|
|
930
933
|
}
|
|
@@ -3106,7 +3109,9 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
3106
3109
|
const curFormConfig = ref([]);
|
|
3107
3110
|
const services = inject("services");
|
|
3108
3111
|
const node = computed(() => services?.editorService.get("node"));
|
|
3109
|
-
const propsPanelSize = computed(
|
|
3112
|
+
const propsPanelSize = computed(
|
|
3113
|
+
() => services?.uiService.get("propsPanelSize") || "small"
|
|
3114
|
+
);
|
|
3110
3115
|
const stage = computed(() => services?.editorService.get("stage"));
|
|
3111
3116
|
const init = async () => {
|
|
3112
3117
|
if (!node.value) {
|
|
@@ -3139,19 +3144,19 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
3139
3144
|
};
|
|
3140
3145
|
expose({ submit });
|
|
3141
3146
|
return (_ctx, _cache) => {
|
|
3142
|
-
const _component_m_form = resolveComponent("m-form");
|
|
3143
3147
|
return openBlock(), createElementBlock("div", _hoisted_1$a, [
|
|
3144
3148
|
renderSlot(_ctx.$slots, "props-panel-header"),
|
|
3145
|
-
|
|
3149
|
+
(openBlock(), createBlock(unref(MForm), {
|
|
3146
3150
|
ref_key: "configForm",
|
|
3147
3151
|
ref: configForm,
|
|
3152
|
+
key: unref(node)?.type,
|
|
3148
3153
|
class: normalizeClass(`m-editor-props-panel ${unref(propsPanelSize)}`),
|
|
3149
3154
|
"popper-class": `m-editor-props-panel-popper ${unref(propsPanelSize)}`,
|
|
3150
3155
|
size: unref(propsPanelSize),
|
|
3151
3156
|
"init-values": values.value,
|
|
3152
3157
|
config: curFormConfig.value,
|
|
3153
3158
|
onChange: submit
|
|
3154
|
-
}, null, 8, ["class", "popper-class", "size", "init-values", "config"])
|
|
3159
|
+
}, null, 8, ["class", "popper-class", "size", "init-values", "config"]))
|
|
3155
3160
|
]);
|
|
3156
3161
|
};
|
|
3157
3162
|
}
|
|
@@ -3652,7 +3657,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3652
3657
|
}
|
|
3653
3658
|
const codeConfig = {
|
|
3654
3659
|
name: "\u4EE3\u7801\u5757",
|
|
3655
|
-
content: `() => {
|
|
3660
|
+
content: `({app, params}) => {
|
|
3656
3661
|
// place your code here
|
|
3657
3662
|
}`,
|
|
3658
3663
|
params: []
|
|
@@ -4354,35 +4359,27 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
4354
4359
|
await expandNodes();
|
|
4355
4360
|
setTreeKeyStatus();
|
|
4356
4361
|
});
|
|
4357
|
-
const layerPanel = ref();
|
|
4358
4362
|
const mouseenterHandler = () => {
|
|
4359
|
-
|
|
4363
|
+
tree.value?.$el.focus();
|
|
4360
4364
|
};
|
|
4361
4365
|
const mouseleaveHandler = () => {
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
isMultiSelectStatus.value = false;
|
|
4366
|
+
tree.value?.$el.blur();
|
|
4367
|
+
isMultiSelectStatus.value = false;
|
|
4365
4368
|
};
|
|
4366
4369
|
let keycon;
|
|
4367
4370
|
onMounted(() => {
|
|
4368
|
-
|
|
4369
|
-
layerPanel.value?.addEventListener("mouseleave", mouseleaveHandler);
|
|
4370
|
-
keycon = new KeyController(layerPanel.value);
|
|
4371
|
+
keycon = new KeyController(tree.value?.$el);
|
|
4371
4372
|
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
4372
4373
|
const ctrl = isMac ? "meta" : "ctrl";
|
|
4373
4374
|
keycon.keydown(ctrl, (e) => {
|
|
4374
4375
|
e.inputEvent.preventDefault();
|
|
4375
4376
|
isMultiSelectStatus.value = true;
|
|
4376
|
-
}).on("blur", () => {
|
|
4377
|
-
isMultiSelectStatus.value = false;
|
|
4378
4377
|
}).keyup(ctrl, (e) => {
|
|
4379
4378
|
e.inputEvent.preventDefault();
|
|
4380
4379
|
isMultiSelectStatus.value = false;
|
|
4381
4380
|
});
|
|
4382
4381
|
});
|
|
4383
4382
|
onUnmounted(() => {
|
|
4384
|
-
layerPanel.value?.removeEventListener("mouseenter", mouseenterHandler);
|
|
4385
|
-
layerPanel.value?.removeEventListener("mouseleave", mouseleaveHandler);
|
|
4386
4383
|
keycon.destroy();
|
|
4387
4384
|
});
|
|
4388
4385
|
const clicked = ref(false);
|
|
@@ -4439,78 +4436,77 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
4439
4436
|
menu.value?.show(event);
|
|
4440
4437
|
};
|
|
4441
4438
|
return (_ctx, _cache) => {
|
|
4442
|
-
return openBlock(),
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
"
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
], 512);
|
|
4439
|
+
return openBlock(), createBlock(unref(TMagicScrollbar), { class: "magic-editor-layer-panel" }, {
|
|
4440
|
+
default: withCtx(() => [
|
|
4441
|
+
renderSlot(_ctx.$slots, "layer-panel-header"),
|
|
4442
|
+
createVNode(unref(TMagicInput), {
|
|
4443
|
+
modelValue: filterText.value,
|
|
4444
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
|
|
4445
|
+
class: "search-input",
|
|
4446
|
+
size: "small",
|
|
4447
|
+
placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
|
|
4448
|
+
clearable: "",
|
|
4449
|
+
"prefix-icon": unref(Search),
|
|
4450
|
+
onChange: filterTextChangeHandler
|
|
4451
|
+
}, null, 8, ["modelValue", "prefix-icon"]),
|
|
4452
|
+
unref(values).length ? (openBlock(), createBlock(unref(TMagicTree), {
|
|
4453
|
+
key: 0,
|
|
4454
|
+
tabindex: "-1",
|
|
4455
|
+
class: "magic-editor-layer-tree",
|
|
4456
|
+
ref_key: "tree",
|
|
4457
|
+
ref: tree,
|
|
4458
|
+
"node-key": "id",
|
|
4459
|
+
"empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
|
|
4460
|
+
draggable: "",
|
|
4461
|
+
"default-expanded-keys": unref(defaultExpandedKeys),
|
|
4462
|
+
load: loadItems,
|
|
4463
|
+
data: unref(values),
|
|
4464
|
+
"default-expand-all": true,
|
|
4465
|
+
"expand-on-click-node": false,
|
|
4466
|
+
"highlight-current": true,
|
|
4467
|
+
props: {
|
|
4468
|
+
children: "items"
|
|
4469
|
+
},
|
|
4470
|
+
"filter-node-method": filterNode,
|
|
4471
|
+
"allow-drop": allowDrop,
|
|
4472
|
+
"show-checkbox": isMultiSelectStatus.value || unref(selectedIds).length > 1,
|
|
4473
|
+
onNodeClick: clickHandler,
|
|
4474
|
+
onNodeContextmenu: contextmenu,
|
|
4475
|
+
onNodeDragEnd: handleDragEnd,
|
|
4476
|
+
onNodeCollapse: handleCollapse,
|
|
4477
|
+
onNodeExpand: handleExpand,
|
|
4478
|
+
onCheck: multiClickHandler,
|
|
4479
|
+
onMousedown: toggleClickFlag,
|
|
4480
|
+
onMouseup: toggleClickFlag,
|
|
4481
|
+
onMouseenter: mouseenterHandler,
|
|
4482
|
+
onMouseleave: mouseleaveHandler
|
|
4483
|
+
}, {
|
|
4484
|
+
default: withCtx(({ node, data }) => [
|
|
4485
|
+
createElementVNode("div", {
|
|
4486
|
+
id: data.id,
|
|
4487
|
+
class: normalizeClass(["cus-tree-node", { "cus-tree-node-hover": canHighlight(data) }]),
|
|
4488
|
+
onMouseenter: ($event) => unref(highlightHandler)(data)
|
|
4489
|
+
}, [
|
|
4490
|
+
renderSlot(_ctx.$slots, "layer-node-content", {
|
|
4491
|
+
node,
|
|
4492
|
+
data
|
|
4493
|
+
}, () => [
|
|
4494
|
+
createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
|
|
4495
|
+
])
|
|
4496
|
+
], 42, _hoisted_1$4)
|
|
4497
|
+
]),
|
|
4498
|
+
_: 3
|
|
4499
|
+
}, 8, ["default-expanded-keys", "data", "show-checkbox"])) : createCommentVNode("", true),
|
|
4500
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4501
|
+
createVNode(_sfc_main$b, {
|
|
4502
|
+
ref_key: "menu",
|
|
4503
|
+
ref: menu,
|
|
4504
|
+
"layer-content-menu": __props.layerContentMenu
|
|
4505
|
+
}, null, 8, ["layer-content-menu"])
|
|
4506
|
+
]))
|
|
4507
|
+
]),
|
|
4508
|
+
_: 3
|
|
4509
|
+
});
|
|
4514
4510
|
};
|
|
4515
4511
|
}
|
|
4516
4512
|
});
|