@tmagic/editor 1.4.4 → 1.4.5
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 +2 -2
- package/dist/tmagic-editor.js +81 -54
- package/dist/tmagic-editor.umd.cjs +80 -52
- package/package.json +19 -24
- package/src/fields/DataSourceFieldSelect.vue +3 -41
- package/src/fields/EventSelect.vue +30 -9
- package/src/layouts/workspace/viewer/Stage.vue +7 -6
- package/src/services/editor.ts +2 -2
- package/src/utils/content-menu.ts +7 -3
- package/src/utils/data-source/index.ts +39 -3
- package/src/utils/editor.ts +14 -7
- package/types/components/CodeBlockEditor.vue.d.ts +21 -34
- package/types/components/CodeParams.vue.d.ts +2 -2
- package/types/components/ContentMenu.vue.d.ts +1 -1
- package/types/components/FloatingBox.vue.d.ts +41 -38
- package/types/components/ScrollViewer.vue.d.ts +1 -1
- package/types/components/ToolButton.vue.d.ts +4 -4
- package/types/components/Tree.vue.d.ts +2 -2
- package/types/fields/CodeLink.vue.d.ts +2 -2
- package/types/fields/DataSourceFields.vue.d.ts +32 -78
- package/types/fields/DataSourceInput.vue.d.ts +2 -2
- package/types/fields/DataSourceMethods.vue.d.ts +2 -2
- package/types/fields/DataSourceMocks.vue.d.ts +31 -76
- package/types/fields/KeyValue.vue.d.ts +2 -2
- package/types/fields/UISelect.vue.d.ts +2 -2
- package/types/hooks/use-code-block-edit.d.ts +18 -6
- package/types/hooks/use-data-source-edit.d.ts +18 -6
- package/types/hooks/use-data-source-method.d.ts +18 -6
- package/types/layouts/CodeEditor.vue.d.ts +1 -1
- package/types/layouts/PropsPanel.vue.d.ts +38 -38
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +1 -1
- package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +20 -30
- package/types/layouts/sidebar/data-source/DataSourceList.vue.d.ts +1 -1
- package/types/layouts/sidebar/layer/LayerMenu.vue.d.ts +6 -6
- package/types/layouts/workspace/viewer/Stage.vue.d.ts +4 -4
- package/types/layouts/workspace/viewer/ViewerMenu.vue.d.ts +6 -6
- package/types/services/dataSource.d.ts +1 -0
- package/types/services/ui.d.ts +1 -1
- package/types/utils/data-source/index.d.ts +3 -2
package/dist/style.css
CHANGED
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
line-height: 15px;
|
|
199
199
|
height: auto;
|
|
200
200
|
padding: 8px;
|
|
201
|
-
color:
|
|
201
|
+
color: rgb(255, 255, 255);
|
|
202
202
|
box-sizing: border-box;
|
|
203
203
|
cursor: pointer;
|
|
204
204
|
}
|
|
@@ -216,7 +216,7 @@
|
|
|
216
216
|
color: rgba(255, 255, 255, 0.6);
|
|
217
217
|
}
|
|
218
218
|
.m-editor-sidebar .m-editor-sidebar-header i:hover {
|
|
219
|
-
color:
|
|
219
|
+
color: rgb(255, 255, 255);
|
|
220
220
|
}
|
|
221
221
|
.m-editor-sidebar .m-editor-sidebar-header .magic-editor-tab-panel-title {
|
|
222
222
|
font-size: 12px;
|
package/dist/tmagic-editor.js
CHANGED
|
@@ -8,13 +8,13 @@ import * as monaco from 'monaco-editor';
|
|
|
8
8
|
import { MContainer, MForm, filterFunction, createValues, MFormBox, MCascader, MSelect, MPanel } from '@tmagic/form';
|
|
9
9
|
import { HookCodeType, HookType, NodeType, ActionType } from '@tmagic/schema';
|
|
10
10
|
import { MagicTable } from '@tmagic/table';
|
|
11
|
-
import { toLine, guid, isPage, isPageFragment, isPop, getNodePath, isNumber, getValueByKeyPath, setValueByKeyPath, convertToNumber, getDefaultValueFromFields, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, getKeys, addClassName, removeClassName, removeClassNameByClassName, getNodes } from '@tmagic/utils';
|
|
11
|
+
import { toLine, guid, isPage, isPageFragment, isPop, getNodePath, isNumber, calcValueByFontsize, getValueByKeyPath, setValueByKeyPath, convertToNumber, getDefaultValueFromFields, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, getKeys, addClassName, removeClassName, removeClassNameByClassName, getNodes } from '@tmagic/utils';
|
|
12
12
|
import VanillaMoveable from 'moveable';
|
|
13
13
|
import { Watcher, DepTargetType, createRelatedCompTarget, createCodeBlockTarget, createDataSourceTarget, createDataSourceMethodTarget, createDataSourceCondTarget } from '@tmagic/dep';
|
|
14
14
|
export { DepTargetType } from '@tmagic/dep';
|
|
15
15
|
import { EventEmitter } from 'events';
|
|
16
16
|
import Gesto from 'gesto';
|
|
17
|
-
import StageCore, { GuidesType, getOffset,
|
|
17
|
+
import StageCore, { GuidesType, getOffset, RenderType, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
|
|
18
18
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
19
19
|
import KeyController from 'keycon';
|
|
20
20
|
|
|
@@ -621,7 +621,6 @@ const fillConfig$1 = (config) => [
|
|
|
621
621
|
},
|
|
622
622
|
{
|
|
623
623
|
title: "事件配置",
|
|
624
|
-
display: false,
|
|
625
624
|
items: [
|
|
626
625
|
{
|
|
627
626
|
name: "events",
|
|
@@ -772,6 +771,33 @@ const getDisplayField = (dataSources, key) => {
|
|
|
772
771
|
}
|
|
773
772
|
return displayState;
|
|
774
773
|
};
|
|
774
|
+
const getCascaderOptionsFromFields = (fields = [], dataSourceFieldType = ["any"]) => {
|
|
775
|
+
const child = [];
|
|
776
|
+
fields.forEach((field) => {
|
|
777
|
+
if (!dataSourceFieldType.length) {
|
|
778
|
+
dataSourceFieldType.push("any");
|
|
779
|
+
}
|
|
780
|
+
const children = getCascaderOptionsFromFields(field.fields, dataSourceFieldType);
|
|
781
|
+
const item = {
|
|
782
|
+
label: field.title || field.name,
|
|
783
|
+
value: field.name,
|
|
784
|
+
children
|
|
785
|
+
};
|
|
786
|
+
const fieldType = field.type || "any";
|
|
787
|
+
if (dataSourceFieldType.includes("any") || dataSourceFieldType.includes(fieldType)) {
|
|
788
|
+
child.push(item);
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
if (!dataSourceFieldType.includes(fieldType) && !["array", "object", "any"].includes(fieldType)) {
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
if (!children.length && ["object", "array", "any"].includes(field.type || "")) {
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
child.push(item);
|
|
798
|
+
});
|
|
799
|
+
return child;
|
|
800
|
+
};
|
|
775
801
|
|
|
776
802
|
const compose = (middleware, isAsync) => {
|
|
777
803
|
if (!Array.isArray(middleware))
|
|
@@ -1634,11 +1660,13 @@ const getMiddleTop = (node, parentNode, stage) => {
|
|
|
1634
1660
|
height = 0;
|
|
1635
1661
|
}
|
|
1636
1662
|
const { height: parentHeight } = parentNode.style;
|
|
1663
|
+
const { scrollTop = 0, wrapperHeight } = stage.mask;
|
|
1664
|
+
const wrapperHeightDeal = calcValueByFontsize(stage.renderer.getDocument(), wrapperHeight);
|
|
1665
|
+
const scrollTopDeal = calcValueByFontsize(stage.renderer.getDocument(), scrollTop);
|
|
1637
1666
|
if (isPage(parentNode)) {
|
|
1638
|
-
|
|
1639
|
-
return (wrapperHeight - height) / 2 + scrollTop;
|
|
1667
|
+
return (wrapperHeightDeal - height) / 2 + scrollTopDeal;
|
|
1640
1668
|
}
|
|
1641
|
-
return (parentHeight - height) / 2;
|
|
1669
|
+
return (Math.min(parentHeight, wrapperHeightDeal) - height) / 2;
|
|
1642
1670
|
};
|
|
1643
1671
|
const getInitPositionStyle = (style = {}, layout) => {
|
|
1644
1672
|
if (layout === Layout.ABSOLUTE) {
|
|
@@ -1739,8 +1767,12 @@ const fixNodeLeft = (config, parent, doc) => {
|
|
|
1739
1767
|
const el = doc.getElementById(`${config.id}`);
|
|
1740
1768
|
const parentEl = doc.getElementById(`${parent.id}`);
|
|
1741
1769
|
const left = Number(config.style?.left) || 0;
|
|
1742
|
-
if (el && parentEl
|
|
1743
|
-
|
|
1770
|
+
if (el && parentEl) {
|
|
1771
|
+
const calcParentOffsetWidth = calcValueByFontsize(doc, parentEl.offsetWidth);
|
|
1772
|
+
const calcElOffsetWidth = calcValueByFontsize(doc, el.offsetWidth);
|
|
1773
|
+
if (calcElOffsetWidth + left > calcParentOffsetWidth) {
|
|
1774
|
+
return calcParentOffsetWidth - calcElOffsetWidth;
|
|
1775
|
+
}
|
|
1744
1776
|
}
|
|
1745
1777
|
return config.style.left;
|
|
1746
1778
|
};
|
|
@@ -2827,7 +2859,7 @@ class Editor extends BaseService {
|
|
|
2827
2859
|
const el = doc.getElementById(`${node.id}`);
|
|
2828
2860
|
const parentEl = layout === Layout.FIXED ? doc.body : el?.offsetParent;
|
|
2829
2861
|
if (parentEl && el) {
|
|
2830
|
-
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
|
2862
|
+
node.style.left = calcValueByFontsize(doc, (parentEl.clientWidth - el.clientWidth) / 2);
|
|
2831
2863
|
node.style.right = "";
|
|
2832
2864
|
}
|
|
2833
2865
|
} else if (parent.style && isNumber(parent.style?.width) && isNumber(node.style?.width)) {
|
|
@@ -4355,33 +4387,6 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4355
4387
|
return value[0].replace(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, "");
|
|
4356
4388
|
});
|
|
4357
4389
|
const dataSources = computed(() => services?.dataSourceService.get("dataSources"));
|
|
4358
|
-
const getOptionChildren = (fields = [], dataSourceFieldType = ["any"]) => {
|
|
4359
|
-
const child = [];
|
|
4360
|
-
fields.forEach((field) => {
|
|
4361
|
-
if (!dataSourceFieldType.length) {
|
|
4362
|
-
dataSourceFieldType.push("any");
|
|
4363
|
-
}
|
|
4364
|
-
const children = getOptionChildren(field.fields, dataSourceFieldType);
|
|
4365
|
-
const item = {
|
|
4366
|
-
label: field.title || field.name,
|
|
4367
|
-
value: field.name,
|
|
4368
|
-
children
|
|
4369
|
-
};
|
|
4370
|
-
const fieldType = field.type || "any";
|
|
4371
|
-
if (dataSourceFieldType.includes("any") || dataSourceFieldType.includes(fieldType)) {
|
|
4372
|
-
child.push(item);
|
|
4373
|
-
return;
|
|
4374
|
-
}
|
|
4375
|
-
if (!dataSourceFieldType.includes(fieldType) && !["array", "object", "any"].includes(fieldType)) {
|
|
4376
|
-
return;
|
|
4377
|
-
}
|
|
4378
|
-
if (!children.length && ["object", "array", "any"].includes(field.type || "")) {
|
|
4379
|
-
return;
|
|
4380
|
-
}
|
|
4381
|
-
child.push(item);
|
|
4382
|
-
});
|
|
4383
|
-
return child;
|
|
4384
|
-
};
|
|
4385
4390
|
const cascaderConfig = computed(() => {
|
|
4386
4391
|
const valueIsKey = props.config.value === "key";
|
|
4387
4392
|
return {
|
|
@@ -4392,7 +4397,7 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4392
4397
|
const options = dataSources.value?.map((ds) => ({
|
|
4393
4398
|
label: ds.title || ds.id,
|
|
4394
4399
|
value: valueIsKey ? ds.id : `${DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX}${ds.id}`,
|
|
4395
|
-
children:
|
|
4400
|
+
children: getCascaderOptionsFromFields(ds.fields, props.config.dataSourceFieldType)
|
|
4396
4401
|
})) || [];
|
|
4397
4402
|
return options.filter((option) => option.children.length);
|
|
4398
4403
|
}
|
|
@@ -4444,7 +4449,6 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4444
4449
|
return (_ctx, _cache) => {
|
|
4445
4450
|
return openBlock(), createElementBlock("div", _hoisted_1$q, [
|
|
4446
4451
|
(openBlock(), createBlock(resolveDynamicComponent(tagName.value), {
|
|
4447
|
-
style: { "width": "100%" },
|
|
4448
4452
|
config: showDataSourceFieldSelect.value || !_ctx.config.fieldConfig ? cascaderConfig.value : _ctx.config.fieldConfig,
|
|
4449
4453
|
model: _ctx.model,
|
|
4450
4454
|
name: _ctx.name,
|
|
@@ -5631,24 +5635,41 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
5631
5635
|
const eventsService = services?.eventsService;
|
|
5632
5636
|
const codeBlockService = services?.codeBlockService;
|
|
5633
5637
|
const eventNameConfig = computed(() => {
|
|
5638
|
+
const fieldType = props.config.src === "component" ? "select" : "cascader";
|
|
5634
5639
|
const defaultEventNameConfig = {
|
|
5635
5640
|
name: "name",
|
|
5636
5641
|
text: "事件",
|
|
5637
|
-
type:
|
|
5642
|
+
type: fieldType,
|
|
5638
5643
|
labelWidth: "40px",
|
|
5644
|
+
checkStrictly: true,
|
|
5645
|
+
valueSeparator: ".",
|
|
5639
5646
|
options: (mForm, { formValue }) => {
|
|
5640
5647
|
let events = [];
|
|
5641
5648
|
if (!eventsService || !dataSourceService)
|
|
5642
5649
|
return events;
|
|
5643
5650
|
if (props.config.src === "component") {
|
|
5644
5651
|
events = eventsService.getEvent(formValue.type);
|
|
5645
|
-
|
|
5652
|
+
return events.map((option) => ({
|
|
5653
|
+
text: option.label,
|
|
5654
|
+
value: option.value
|
|
5655
|
+
}));
|
|
5656
|
+
}
|
|
5657
|
+
if (props.config.src === "datasource") {
|
|
5646
5658
|
events = dataSourceService.getFormEvent(formValue.type);
|
|
5659
|
+
const dataSource = dataSourceService.getDataSourceById(formValue.id);
|
|
5660
|
+
const fields = dataSource?.fields || [];
|
|
5661
|
+
if (fields.length > 0) {
|
|
5662
|
+
return [
|
|
5663
|
+
...events,
|
|
5664
|
+
{
|
|
5665
|
+
label: "数据变化",
|
|
5666
|
+
value: DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX,
|
|
5667
|
+
children: getCascaderOptionsFromFields(fields)
|
|
5668
|
+
}
|
|
5669
|
+
];
|
|
5670
|
+
}
|
|
5671
|
+
return events;
|
|
5647
5672
|
}
|
|
5648
|
-
return events.map((option) => ({
|
|
5649
|
-
text: option.label,
|
|
5650
|
-
value: option.value
|
|
5651
|
-
}));
|
|
5652
5673
|
}
|
|
5653
5674
|
};
|
|
5654
5675
|
return { ...defaultEventNameConfig, ...props.config.eventNameConfig };
|
|
@@ -8614,8 +8635,8 @@ const usePasteMenu = (menu) => ({
|
|
|
8614
8635
|
const stage = services?.editorService?.get("stage");
|
|
8615
8636
|
const rect = menu.value.$el.getBoundingClientRect();
|
|
8616
8637
|
const parentRect = stage?.container?.getBoundingClientRect();
|
|
8617
|
-
const initialLeft = (rect.left || 0) - (parentRect?.left || 0);
|
|
8618
|
-
const initialTop = (rect.top || 0) - (parentRect?.top || 0);
|
|
8638
|
+
const initialLeft = calcValueByFontsize(stage?.renderer.getDocument(), (rect.left || 0) - (parentRect?.left || 0)) / services.uiService.get("zoom");
|
|
8639
|
+
const initialTop = calcValueByFontsize(stage?.renderer.getDocument(), (rect.top || 0) - (parentRect?.top || 0)) / services.uiService.get("zoom");
|
|
8619
8640
|
services?.editorService?.paste({ left: initialLeft, top: initialTop });
|
|
8620
8641
|
} else {
|
|
8621
8642
|
services?.editorService?.paste();
|
|
@@ -9612,7 +9633,10 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
9612
9633
|
class: "m-editor-sidebar-content",
|
|
9613
9634
|
key: config.$key ?? index
|
|
9614
9635
|
}, [
|
|
9615
|
-
config && !unref(floatBoxStates)[config.$key]?.status ? (openBlock(), createBlock(resolveDynamicComponent(config.component), mergeProps({
|
|
9636
|
+
config && !unref(floatBoxStates)[config.$key]?.status ? (openBlock(), createBlock(resolveDynamicComponent(config.component), mergeProps({
|
|
9637
|
+
key: 0,
|
|
9638
|
+
ref_for: true
|
|
9639
|
+
}, config.props || {}, toHandlers(config?.listeners || {})), createSlots({ _: 2 }, [
|
|
9616
9640
|
config.$key === "component-list" || config.slots?.componentListPanelHeader ? {
|
|
9617
9641
|
name: "component-list-panel-header",
|
|
9618
9642
|
fn: withCtx(() => [
|
|
@@ -9745,7 +9769,10 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
9745
9769
|
}, {
|
|
9746
9770
|
body: withCtx(() => [
|
|
9747
9771
|
createElementVNode("div", _hoisted_5$1, [
|
|
9748
|
-
config && unref(floatBoxStates)[config.$key].status ? (openBlock(), createBlock(resolveDynamicComponent(config.component), mergeProps({
|
|
9772
|
+
config && unref(floatBoxStates)[config.$key].status ? (openBlock(), createBlock(resolveDynamicComponent(config.component), mergeProps({
|
|
9773
|
+
key: 0,
|
|
9774
|
+
ref_for: true
|
|
9775
|
+
}, config.props || {}, toHandlers(config?.listeners || {})), null, 16)) : createCommentVNode("", true)
|
|
9749
9776
|
])
|
|
9750
9777
|
]),
|
|
9751
9778
|
_: 2
|
|
@@ -10566,17 +10593,17 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
10566
10593
|
position = "absolute";
|
|
10567
10594
|
top = e.clientY - containerRect.top + scrollTop;
|
|
10568
10595
|
left = e.clientX - containerRect.left + scrollLeft;
|
|
10569
|
-
if (parentEl
|
|
10596
|
+
if (parentEl) {
|
|
10570
10597
|
const { left: parentLeft, top: parentTop } = getOffset(parentEl);
|
|
10571
|
-
left = left -
|
|
10572
|
-
top = top -
|
|
10598
|
+
left = left - parentLeft * zoom.value;
|
|
10599
|
+
top = top - parentTop * zoom.value;
|
|
10573
10600
|
}
|
|
10574
10601
|
}
|
|
10575
10602
|
config.data.style = {
|
|
10576
10603
|
...style,
|
|
10577
10604
|
position,
|
|
10578
|
-
top: top / zoom.value,
|
|
10579
|
-
left: left / zoom.value
|
|
10605
|
+
top: calcValueByFontsize(doc, top / zoom.value),
|
|
10606
|
+
left: calcValueByFontsize(doc, left / zoom.value)
|
|
10580
10607
|
};
|
|
10581
10608
|
config.data.inputEvent = e;
|
|
10582
10609
|
services?.editorService.add(config.data, parent);
|
|
@@ -11906,4 +11933,4 @@ const index = {
|
|
|
11906
11933
|
}
|
|
11907
11934
|
};
|
|
11908
11935
|
|
|
11909
|
-
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$J as CodeBlockEditor, _sfc_main$l as CodeBlockList, _sfc_main$k as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$Q as CodeSelect, _sfc_main$O as CodeSelectCol, ColumnLayout, _sfc_main$b as ComponentListPanel, _sfc_main$g as ContentMenu, _sfc_main$j as DataSourceConfigPanel, _sfc_main$L as DataSourceFieldSelect, _sfc_main$M as DataSourceFields, _sfc_main$K as DataSourceInput, _sfc_main$H as DataSourceMethodSelect, _sfc_main$I as DataSourceMethods, _sfc_main$G as DataSourceMocks, _sfc_main$F as DataSourceSelect, DragType, _sfc_main$E as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$U as Icon, KeyBindingCommand, _sfc_main$C as KeyValue, Keys, LayerOffset, _sfc_main$c as LayerPanel, Layout, _sfc_main$y as LayoutContainer, _sfc_main$B as PageFragmentSelect, _sfc_main$p as PropsPanel, _sfc_main$z as Resizer, SideItemKey, _sfc_main$y as SplitView, _sfc_main$T as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$x as ToolButton, UI_SELECT_MODE_EVENT_NAME, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, error, eventTabConfig, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getDisplayField, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setChildrenLayout, setConfig, setLayout, stageOverlayService, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useEditorContentHeight, useFloatBox, useStage, useWindowRect, warn };
|
|
11936
|
+
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$J as CodeBlockEditor, _sfc_main$l as CodeBlockList, _sfc_main$k as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$Q as CodeSelect, _sfc_main$O as CodeSelectCol, ColumnLayout, _sfc_main$b as ComponentListPanel, _sfc_main$g as ContentMenu, _sfc_main$j as DataSourceConfigPanel, _sfc_main$L as DataSourceFieldSelect, _sfc_main$M as DataSourceFields, _sfc_main$K as DataSourceInput, _sfc_main$H as DataSourceMethodSelect, _sfc_main$I as DataSourceMethods, _sfc_main$G as DataSourceMocks, _sfc_main$F as DataSourceSelect, DragType, _sfc_main$E as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$U as Icon, KeyBindingCommand, _sfc_main$C as KeyValue, Keys, LayerOffset, _sfc_main$c as LayerPanel, Layout, _sfc_main$y as LayoutContainer, _sfc_main$B as PageFragmentSelect, _sfc_main$p as PropsPanel, _sfc_main$z as Resizer, SideItemKey, _sfc_main$y as SplitView, _sfc_main$T as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$x as ToolButton, UI_SELECT_MODE_EVENT_NAME, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, error, eventTabConfig, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getCascaderOptionsFromFields, getConfig, getDefaultConfig, getDisplayField, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setChildrenLayout, setConfig, setLayout, stageOverlayService, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useEditorContentHeight, useFloatBox, useStage, useWindowRect, warn };
|
|
@@ -626,7 +626,6 @@
|
|
|
626
626
|
},
|
|
627
627
|
{
|
|
628
628
|
title: "事件配置",
|
|
629
|
-
display: false,
|
|
630
629
|
items: [
|
|
631
630
|
{
|
|
632
631
|
name: "events",
|
|
@@ -777,6 +776,33 @@
|
|
|
777
776
|
}
|
|
778
777
|
return displayState;
|
|
779
778
|
};
|
|
779
|
+
const getCascaderOptionsFromFields = (fields = [], dataSourceFieldType = ["any"]) => {
|
|
780
|
+
const child = [];
|
|
781
|
+
fields.forEach((field) => {
|
|
782
|
+
if (!dataSourceFieldType.length) {
|
|
783
|
+
dataSourceFieldType.push("any");
|
|
784
|
+
}
|
|
785
|
+
const children = getCascaderOptionsFromFields(field.fields, dataSourceFieldType);
|
|
786
|
+
const item = {
|
|
787
|
+
label: field.title || field.name,
|
|
788
|
+
value: field.name,
|
|
789
|
+
children
|
|
790
|
+
};
|
|
791
|
+
const fieldType = field.type || "any";
|
|
792
|
+
if (dataSourceFieldType.includes("any") || dataSourceFieldType.includes(fieldType)) {
|
|
793
|
+
child.push(item);
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
if (!dataSourceFieldType.includes(fieldType) && !["array", "object", "any"].includes(fieldType)) {
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
if (!children.length && ["object", "array", "any"].includes(field.type || "")) {
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
child.push(item);
|
|
803
|
+
});
|
|
804
|
+
return child;
|
|
805
|
+
};
|
|
780
806
|
|
|
781
807
|
const compose = (middleware, isAsync) => {
|
|
782
808
|
if (!Array.isArray(middleware))
|
|
@@ -1639,11 +1665,13 @@
|
|
|
1639
1665
|
height = 0;
|
|
1640
1666
|
}
|
|
1641
1667
|
const { height: parentHeight } = parentNode.style;
|
|
1668
|
+
const { scrollTop = 0, wrapperHeight } = stage.mask;
|
|
1669
|
+
const wrapperHeightDeal = utils.calcValueByFontsize(stage.renderer.getDocument(), wrapperHeight);
|
|
1670
|
+
const scrollTopDeal = utils.calcValueByFontsize(stage.renderer.getDocument(), scrollTop);
|
|
1642
1671
|
if (utils.isPage(parentNode)) {
|
|
1643
|
-
|
|
1644
|
-
return (wrapperHeight - height) / 2 + scrollTop;
|
|
1672
|
+
return (wrapperHeightDeal - height) / 2 + scrollTopDeal;
|
|
1645
1673
|
}
|
|
1646
|
-
return (parentHeight - height) / 2;
|
|
1674
|
+
return (Math.min(parentHeight, wrapperHeightDeal) - height) / 2;
|
|
1647
1675
|
};
|
|
1648
1676
|
const getInitPositionStyle = (style = {}, layout) => {
|
|
1649
1677
|
if (layout === Layout.ABSOLUTE) {
|
|
@@ -1744,8 +1772,12 @@
|
|
|
1744
1772
|
const el = doc.getElementById(`${config.id}`);
|
|
1745
1773
|
const parentEl = doc.getElementById(`${parent.id}`);
|
|
1746
1774
|
const left = Number(config.style?.left) || 0;
|
|
1747
|
-
if (el && parentEl
|
|
1748
|
-
|
|
1775
|
+
if (el && parentEl) {
|
|
1776
|
+
const calcParentOffsetWidth = utils.calcValueByFontsize(doc, parentEl.offsetWidth);
|
|
1777
|
+
const calcElOffsetWidth = utils.calcValueByFontsize(doc, el.offsetWidth);
|
|
1778
|
+
if (calcElOffsetWidth + left > calcParentOffsetWidth) {
|
|
1779
|
+
return calcParentOffsetWidth - calcElOffsetWidth;
|
|
1780
|
+
}
|
|
1749
1781
|
}
|
|
1750
1782
|
return config.style.left;
|
|
1751
1783
|
};
|
|
@@ -2832,7 +2864,7 @@
|
|
|
2832
2864
|
const el = doc.getElementById(`${node.id}`);
|
|
2833
2865
|
const parentEl = layout === Layout.FIXED ? doc.body : el?.offsetParent;
|
|
2834
2866
|
if (parentEl && el) {
|
|
2835
|
-
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
|
2867
|
+
node.style.left = utils.calcValueByFontsize(doc, (parentEl.clientWidth - el.clientWidth) / 2);
|
|
2836
2868
|
node.style.right = "";
|
|
2837
2869
|
}
|
|
2838
2870
|
} else if (parent.style && utils.isNumber(parent.style?.width) && utils.isNumber(node.style?.width)) {
|
|
@@ -4360,33 +4392,6 @@
|
|
|
4360
4392
|
return value[0].replace(utils.DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, "");
|
|
4361
4393
|
});
|
|
4362
4394
|
const dataSources = vue.computed(() => services?.dataSourceService.get("dataSources"));
|
|
4363
|
-
const getOptionChildren = (fields = [], dataSourceFieldType = ["any"]) => {
|
|
4364
|
-
const child = [];
|
|
4365
|
-
fields.forEach((field) => {
|
|
4366
|
-
if (!dataSourceFieldType.length) {
|
|
4367
|
-
dataSourceFieldType.push("any");
|
|
4368
|
-
}
|
|
4369
|
-
const children = getOptionChildren(field.fields, dataSourceFieldType);
|
|
4370
|
-
const item = {
|
|
4371
|
-
label: field.title || field.name,
|
|
4372
|
-
value: field.name,
|
|
4373
|
-
children
|
|
4374
|
-
};
|
|
4375
|
-
const fieldType = field.type || "any";
|
|
4376
|
-
if (dataSourceFieldType.includes("any") || dataSourceFieldType.includes(fieldType)) {
|
|
4377
|
-
child.push(item);
|
|
4378
|
-
return;
|
|
4379
|
-
}
|
|
4380
|
-
if (!dataSourceFieldType.includes(fieldType) && !["array", "object", "any"].includes(fieldType)) {
|
|
4381
|
-
return;
|
|
4382
|
-
}
|
|
4383
|
-
if (!children.length && ["object", "array", "any"].includes(field.type || "")) {
|
|
4384
|
-
return;
|
|
4385
|
-
}
|
|
4386
|
-
child.push(item);
|
|
4387
|
-
});
|
|
4388
|
-
return child;
|
|
4389
|
-
};
|
|
4390
4395
|
const cascaderConfig = vue.computed(() => {
|
|
4391
4396
|
const valueIsKey = props.config.value === "key";
|
|
4392
4397
|
return {
|
|
@@ -4397,7 +4402,7 @@
|
|
|
4397
4402
|
const options = dataSources.value?.map((ds) => ({
|
|
4398
4403
|
label: ds.title || ds.id,
|
|
4399
4404
|
value: valueIsKey ? ds.id : `${utils.DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX}${ds.id}`,
|
|
4400
|
-
children:
|
|
4405
|
+
children: getCascaderOptionsFromFields(ds.fields, props.config.dataSourceFieldType)
|
|
4401
4406
|
})) || [];
|
|
4402
4407
|
return options.filter((option) => option.children.length);
|
|
4403
4408
|
}
|
|
@@ -4449,7 +4454,6 @@
|
|
|
4449
4454
|
return (_ctx, _cache) => {
|
|
4450
4455
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$q, [
|
|
4451
4456
|
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), {
|
|
4452
|
-
style: { "width": "100%" },
|
|
4453
4457
|
config: showDataSourceFieldSelect.value || !_ctx.config.fieldConfig ? cascaderConfig.value : _ctx.config.fieldConfig,
|
|
4454
4458
|
model: _ctx.model,
|
|
4455
4459
|
name: _ctx.name,
|
|
@@ -5636,24 +5640,41 @@
|
|
|
5636
5640
|
const eventsService = services?.eventsService;
|
|
5637
5641
|
const codeBlockService = services?.codeBlockService;
|
|
5638
5642
|
const eventNameConfig = vue.computed(() => {
|
|
5643
|
+
const fieldType = props.config.src === "component" ? "select" : "cascader";
|
|
5639
5644
|
const defaultEventNameConfig = {
|
|
5640
5645
|
name: "name",
|
|
5641
5646
|
text: "事件",
|
|
5642
|
-
type:
|
|
5647
|
+
type: fieldType,
|
|
5643
5648
|
labelWidth: "40px",
|
|
5649
|
+
checkStrictly: true,
|
|
5650
|
+
valueSeparator: ".",
|
|
5644
5651
|
options: (mForm, { formValue }) => {
|
|
5645
5652
|
let events = [];
|
|
5646
5653
|
if (!eventsService || !dataSourceService)
|
|
5647
5654
|
return events;
|
|
5648
5655
|
if (props.config.src === "component") {
|
|
5649
5656
|
events = eventsService.getEvent(formValue.type);
|
|
5650
|
-
|
|
5657
|
+
return events.map((option) => ({
|
|
5658
|
+
text: option.label,
|
|
5659
|
+
value: option.value
|
|
5660
|
+
}));
|
|
5661
|
+
}
|
|
5662
|
+
if (props.config.src === "datasource") {
|
|
5651
5663
|
events = dataSourceService.getFormEvent(formValue.type);
|
|
5664
|
+
const dataSource = dataSourceService.getDataSourceById(formValue.id);
|
|
5665
|
+
const fields = dataSource?.fields || [];
|
|
5666
|
+
if (fields.length > 0) {
|
|
5667
|
+
return [
|
|
5668
|
+
...events,
|
|
5669
|
+
{
|
|
5670
|
+
label: "数据变化",
|
|
5671
|
+
value: utils.DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX,
|
|
5672
|
+
children: getCascaderOptionsFromFields(fields)
|
|
5673
|
+
}
|
|
5674
|
+
];
|
|
5675
|
+
}
|
|
5676
|
+
return events;
|
|
5652
5677
|
}
|
|
5653
|
-
return events.map((option) => ({
|
|
5654
|
-
text: option.label,
|
|
5655
|
-
value: option.value
|
|
5656
|
-
}));
|
|
5657
5678
|
}
|
|
5658
5679
|
};
|
|
5659
5680
|
return { ...defaultEventNameConfig, ...props.config.eventNameConfig };
|
|
@@ -8619,8 +8640,8 @@
|
|
|
8619
8640
|
const stage = services?.editorService?.get("stage");
|
|
8620
8641
|
const rect = menu.value.$el.getBoundingClientRect();
|
|
8621
8642
|
const parentRect = stage?.container?.getBoundingClientRect();
|
|
8622
|
-
const initialLeft = (rect.left || 0) - (parentRect?.left || 0);
|
|
8623
|
-
const initialTop = (rect.top || 0) - (parentRect?.top || 0);
|
|
8643
|
+
const initialLeft = utils.calcValueByFontsize(stage?.renderer.getDocument(), (rect.left || 0) - (parentRect?.left || 0)) / services.uiService.get("zoom");
|
|
8644
|
+
const initialTop = utils.calcValueByFontsize(stage?.renderer.getDocument(), (rect.top || 0) - (parentRect?.top || 0)) / services.uiService.get("zoom");
|
|
8624
8645
|
services?.editorService?.paste({ left: initialLeft, top: initialTop });
|
|
8625
8646
|
} else {
|
|
8626
8647
|
services?.editorService?.paste();
|
|
@@ -9617,7 +9638,10 @@
|
|
|
9617
9638
|
class: "m-editor-sidebar-content",
|
|
9618
9639
|
key: config.$key ?? index
|
|
9619
9640
|
}, [
|
|
9620
|
-
config && !vue.unref(floatBoxStates)[config.$key]?.status ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.component), vue.mergeProps({
|
|
9641
|
+
config && !vue.unref(floatBoxStates)[config.$key]?.status ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.component), vue.mergeProps({
|
|
9642
|
+
key: 0,
|
|
9643
|
+
ref_for: true
|
|
9644
|
+
}, config.props || {}, vue.toHandlers(config?.listeners || {})), vue.createSlots({ _: 2 }, [
|
|
9621
9645
|
config.$key === "component-list" || config.slots?.componentListPanelHeader ? {
|
|
9622
9646
|
name: "component-list-panel-header",
|
|
9623
9647
|
fn: vue.withCtx(() => [
|
|
@@ -9750,7 +9774,10 @@
|
|
|
9750
9774
|
}, {
|
|
9751
9775
|
body: vue.withCtx(() => [
|
|
9752
9776
|
vue.createElementVNode("div", _hoisted_5$1, [
|
|
9753
|
-
config && vue.unref(floatBoxStates)[config.$key].status ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.component), vue.mergeProps({
|
|
9777
|
+
config && vue.unref(floatBoxStates)[config.$key].status ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.component), vue.mergeProps({
|
|
9778
|
+
key: 0,
|
|
9779
|
+
ref_for: true
|
|
9780
|
+
}, config.props || {}, vue.toHandlers(config?.listeners || {})), null, 16)) : vue.createCommentVNode("", true)
|
|
9754
9781
|
])
|
|
9755
9782
|
]),
|
|
9756
9783
|
_: 2
|
|
@@ -10571,17 +10598,17 @@
|
|
|
10571
10598
|
position = "absolute";
|
|
10572
10599
|
top = e.clientY - containerRect.top + scrollTop;
|
|
10573
10600
|
left = e.clientX - containerRect.left + scrollLeft;
|
|
10574
|
-
if (parentEl
|
|
10601
|
+
if (parentEl) {
|
|
10575
10602
|
const { left: parentLeft, top: parentTop } = StageCore.getOffset(parentEl);
|
|
10576
|
-
left = left -
|
|
10577
|
-
top = top -
|
|
10603
|
+
left = left - parentLeft * zoom.value;
|
|
10604
|
+
top = top - parentTop * zoom.value;
|
|
10578
10605
|
}
|
|
10579
10606
|
}
|
|
10580
10607
|
config.data.style = {
|
|
10581
10608
|
...style,
|
|
10582
10609
|
position,
|
|
10583
|
-
top: top / zoom.value,
|
|
10584
|
-
left: left / zoom.value
|
|
10610
|
+
top: utils.calcValueByFontsize(doc, top / zoom.value),
|
|
10611
|
+
left: utils.calcValueByFontsize(doc, left / zoom.value)
|
|
10585
10612
|
};
|
|
10586
10613
|
config.data.inputEvent = e;
|
|
10587
10614
|
services?.editorService.add(config.data, parent);
|
|
@@ -11911,7 +11938,7 @@
|
|
|
11911
11938
|
}
|
|
11912
11939
|
};
|
|
11913
11940
|
|
|
11914
|
-
Object.defineProperty(exports,
|
|
11941
|
+
Object.defineProperty(exports, "DepTargetType", {
|
|
11915
11942
|
enumerable: true,
|
|
11916
11943
|
get: () => dep.DepTargetType
|
|
11917
11944
|
});
|
|
@@ -11975,6 +12002,7 @@
|
|
|
11975
12002
|
exports.generatePageName = generatePageName;
|
|
11976
12003
|
exports.generatePageNameByApp = generatePageNameByApp;
|
|
11977
12004
|
exports.getAddParent = getAddParent;
|
|
12005
|
+
exports.getCascaderOptionsFromFields = getCascaderOptionsFromFields;
|
|
11978
12006
|
exports.getConfig = getConfig;
|
|
11979
12007
|
exports.getDefaultConfig = getDefaultConfig;
|
|
11980
12008
|
exports.getDisplayField = getDisplayField;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.4.
|
|
2
|
+
"version": "1.4.5",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -40,16 +40,7 @@
|
|
|
40
40
|
"typescript"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@babel/core": "^7.18.0",
|
|
44
43
|
"@element-plus/icons-vue": "^2.3.1",
|
|
45
|
-
"@tmagic/core": "1.4.4",
|
|
46
|
-
"@tmagic/dep": "1.4.4",
|
|
47
|
-
"@tmagic/design": "1.4.4",
|
|
48
|
-
"@tmagic/form": "1.4.4",
|
|
49
|
-
"@tmagic/schema": "1.4.4",
|
|
50
|
-
"@tmagic/stage": "1.4.4",
|
|
51
|
-
"@tmagic/table": "1.4.4",
|
|
52
|
-
"@tmagic/utils": "1.4.4",
|
|
53
44
|
"buffer": "^6.0.3",
|
|
54
45
|
"color": "^3.1.3",
|
|
55
46
|
"emmet-monaco-es": "^5.3.0",
|
|
@@ -57,37 +48,41 @@
|
|
|
57
48
|
"gesto": "^1.19.1",
|
|
58
49
|
"keycon": "^1.4.0",
|
|
59
50
|
"lodash-es": "^4.17.21",
|
|
60
|
-
"
|
|
61
|
-
"moveable": "^0.51.1",
|
|
51
|
+
"moveable": "^0.53.0",
|
|
62
52
|
"serialize-javascript": "^6.0.0",
|
|
63
|
-
"
|
|
53
|
+
"@tmagic/dep": "1.4.5",
|
|
54
|
+
"@tmagic/table": "1.4.5"
|
|
64
55
|
},
|
|
65
56
|
"peerDependencies": {
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
57
|
+
"monaco-editor": "^0.48.0",
|
|
58
|
+
"vue": "^3.4.27",
|
|
59
|
+
"@tmagic/design": "1.4.5",
|
|
60
|
+
"@tmagic/form": "1.4.5",
|
|
61
|
+
"@tmagic/schema": "1.4.5",
|
|
62
|
+
"@tmagic/stage": "1.4.5",
|
|
63
|
+
"@tmagic/utils": "1.4.5",
|
|
64
|
+
"@tmagic/core": "1.4.5"
|
|
70
65
|
},
|
|
71
66
|
"devDependencies": {
|
|
72
67
|
"@types/events": "^3.0.0",
|
|
73
68
|
"@types/lodash-es": "^4.17.4",
|
|
74
69
|
"@types/node": "^18.19.0",
|
|
75
70
|
"@types/serialize-javascript": "^5.0.1",
|
|
76
|
-
"@vitejs/plugin-vue": "^
|
|
77
|
-
"@vue/compiler-sfc": "^3.4.
|
|
78
|
-
"@vue/test-utils": "^2.4.
|
|
71
|
+
"@vitejs/plugin-vue": "^5.0.4",
|
|
72
|
+
"@vue/compiler-sfc": "^3.4.27",
|
|
73
|
+
"@vue/test-utils": "^2.4.6",
|
|
79
74
|
"rimraf": "^3.0.2",
|
|
80
|
-
"sass": "^1.
|
|
75
|
+
"sass": "^1.77.0",
|
|
81
76
|
"tsc-alias": "^1.8.5",
|
|
82
77
|
"type-fest": "^4.10.3",
|
|
83
78
|
"typescript": "^5.4.2",
|
|
84
|
-
"vite": "^5.
|
|
85
|
-
"vue-tsc": "^2.0.
|
|
79
|
+
"vite": "^5.2.11",
|
|
80
|
+
"vue-tsc": "^2.0.16"
|
|
86
81
|
},
|
|
87
82
|
"scripts": {
|
|
88
83
|
"build": "npm run build:type && vite build",
|
|
89
84
|
"build:type": "npm run clear:type && vue-tsc --declaration --emitDeclarationOnly --project tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
90
85
|
"clear:type": "rimraf ./types",
|
|
91
|
-
"type
|
|
86
|
+
"check:type": "vue-tsc --noEmit --project tsconfig.build.json"
|
|
92
87
|
}
|
|
93
88
|
}
|