@tmagic/editor 1.3.0-alpha.7 → 1.3.0-alpha.8
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 -0
- package/dist/tmagic-editor.js +65 -22
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +65 -21
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +12 -12
- package/src/components/SplitView.vue +2 -2
- package/src/fields/DataSourceInput.vue +11 -10
- package/src/index.ts +1 -0
- package/src/layouts/Framework.vue +1 -2
- package/src/layouts/PropsPanel.vue +2 -1
- package/src/layouts/sidebar/LayerMenu.vue +4 -3
- package/src/layouts/sidebar/LayerPanel.vue +5 -1
- package/src/theme/data-source-input.scss +18 -0
- package/src/theme/theme.scss +1 -0
- package/src/utils/props.ts +34 -0
- package/types/index.d.ts +1 -0
|
@@ -572,7 +572,7 @@
|
|
|
572
572
|
const dataSources = vue.computed(() => dataSourceService?.get("dataSources") || []);
|
|
573
573
|
const setDisplayState = () => {
|
|
574
574
|
displayState.value = [];
|
|
575
|
-
const matches = state.value.matchAll(
|
|
575
|
+
const matches = state.value.matchAll(/\$\{([\s\S]+?)\}/g);
|
|
576
576
|
let index = 0;
|
|
577
577
|
for (const match of matches) {
|
|
578
578
|
if (typeof match.index === "undefined")
|
|
@@ -645,13 +645,13 @@
|
|
|
645
645
|
}
|
|
646
646
|
return selectionStart;
|
|
647
647
|
};
|
|
648
|
-
const curCharIsLeftCurlyBracket = (leftCurlyBracketIndex) => leftCurlyBracketIndex >
|
|
648
|
+
const curCharIsLeftCurlyBracket = (leftCurlyBracketIndex) => leftCurlyBracketIndex > 0 && leftCurlyBracketIndex === getSelectionStart() - 1;
|
|
649
649
|
const curCharIsDot = (dotIndex) => dotIndex > -1 && dotIndex === getSelectionStart() - 1;
|
|
650
650
|
const dsQuerySearch = (queryString, leftCurlyBracketIndex, cb) => {
|
|
651
651
|
let result = [];
|
|
652
652
|
if (curCharIsLeftCurlyBracket(leftCurlyBracketIndex)) {
|
|
653
653
|
result = dataSources.value;
|
|
654
|
-
} else if (leftCurlyBracketIndex >
|
|
654
|
+
} else if (leftCurlyBracketIndex > 0) {
|
|
655
655
|
const queryName = queryString.substring(leftCurlyBracketIndex + 1).toLowerCase();
|
|
656
656
|
result = dataSources.value.filter((ds) => ds.title?.toLowerCase().includes(queryName) || ds.id.includes(queryName));
|
|
657
657
|
}
|
|
@@ -703,7 +703,7 @@
|
|
|
703
703
|
const selectionStart = getSelectionStart();
|
|
704
704
|
const curQueryString = queryString.substring(0, selectionStart);
|
|
705
705
|
const fieldKeyStringLastIndex = curQueryString.lastIndexOf(".");
|
|
706
|
-
const dsKeyStringLastIndex = curQueryString.lastIndexOf("{");
|
|
706
|
+
const dsKeyStringLastIndex = curQueryString.lastIndexOf("${") + 1;
|
|
707
707
|
const isFieldTip = fieldKeyStringLastIndex > dsKeyStringLastIndex;
|
|
708
708
|
if (isFieldTip) {
|
|
709
709
|
fieldQuerySearch(curQueryString, dsKeyStringLastIndex, fieldKeyStringLastIndex, cb);
|
|
@@ -716,7 +716,7 @@
|
|
|
716
716
|
const selectionStart = input.value?.selectionStart || 0;
|
|
717
717
|
let startText = inputText.substring(0, selectionStart);
|
|
718
718
|
const dotIndex = startText.lastIndexOf(".");
|
|
719
|
-
const leftCurlyBracketIndex = startText.lastIndexOf("{");
|
|
719
|
+
const leftCurlyBracketIndex = startText.lastIndexOf("${") + 1;
|
|
720
720
|
const endText = inputText.substring(selectionStart);
|
|
721
721
|
let suggestText = value;
|
|
722
722
|
if (isDataSource) {
|
|
@@ -726,7 +726,6 @@
|
|
|
726
726
|
if (!isRightCurlyBracket(selectionStart + 1)) {
|
|
727
727
|
suggestText = `${suggestText}}`;
|
|
728
728
|
}
|
|
729
|
-
suggestText = `{${suggestText}}`;
|
|
730
729
|
} else if (!curCharIsDot(dotIndex)) {
|
|
731
730
|
startText = startText.substring(0, dotIndex + 1);
|
|
732
731
|
}
|
|
@@ -734,7 +733,7 @@
|
|
|
734
733
|
await vue.nextTick();
|
|
735
734
|
let newSelectionStart = 0;
|
|
736
735
|
if (isDataSource) {
|
|
737
|
-
newSelectionStart = leftCurlyBracketIndex + suggestText.length
|
|
736
|
+
newSelectionStart = leftCurlyBracketIndex + suggestText.length;
|
|
738
737
|
} else {
|
|
739
738
|
newSelectionStart = dotIndex + suggestText.length + 1;
|
|
740
739
|
}
|
|
@@ -777,11 +776,11 @@
|
|
|
777
776
|
_: 1
|
|
778
777
|
}, 16, ["modelValue"])) : (vue.openBlock(), vue.createElementBlock("div", {
|
|
779
778
|
key: 1,
|
|
780
|
-
class: vue.normalizeClass(`el-input el-input--${_ctx.size}`),
|
|
779
|
+
class: vue.normalizeClass(`tmagic-data-source-input-text el-input el-input--${_ctx.size}`),
|
|
781
780
|
onMouseup: mouseupHandler
|
|
782
781
|
}, [
|
|
783
782
|
vue.createElementVNode("div", {
|
|
784
|
-
class: vue.normalizeClass(`el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
|
|
783
|
+
class: vue.normalizeClass(`tmagic-data-source-input-text-wrapper el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
|
|
785
784
|
}, [
|
|
786
785
|
vue.createElementVNode("div", _hoisted_3$5, [
|
|
787
786
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(displayState.value, (item, index) => {
|
|
@@ -800,7 +799,11 @@
|
|
|
800
799
|
_: 2
|
|
801
800
|
}, 1032, ["size"])) : vue.createCommentVNode("", true)
|
|
802
801
|
], 64);
|
|
803
|
-
}), 256))
|
|
802
|
+
}), 256)),
|
|
803
|
+
vue.createVNode(_sfc_main$B, {
|
|
804
|
+
class: "tmagic-data-source-input-icon",
|
|
805
|
+
icon: vue.unref(iconsVue.Coin)
|
|
806
|
+
}, null, 8, ["icon"])
|
|
804
807
|
])
|
|
805
808
|
], 2)
|
|
806
809
|
], 34));
|
|
@@ -1510,7 +1513,7 @@
|
|
|
1510
1513
|
ref: el,
|
|
1511
1514
|
class: "m-editor-layout"
|
|
1512
1515
|
}, [
|
|
1513
|
-
hasLeft.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
|
|
1516
|
+
hasLeft.value && _ctx.$slots.left ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
|
|
1514
1517
|
vue.createElementVNode("div", {
|
|
1515
1518
|
class: vue.normalizeClass(["m-editor-layout-left", _ctx.leftClass]),
|
|
1516
1519
|
style: vue.normalizeStyle(`width: ${_ctx.left}px`)
|
|
@@ -1525,7 +1528,7 @@
|
|
|
1525
1528
|
}, [
|
|
1526
1529
|
vue.renderSlot(_ctx.$slots, "center")
|
|
1527
1530
|
], 6),
|
|
1528
|
-
hasRight.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
|
|
1531
|
+
hasRight.value && _ctx.$slots.right ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
|
|
1529
1532
|
vue.createVNode(_sfc_main$t, { onChange: changeRight }),
|
|
1530
1533
|
vue.createElementVNode("div", {
|
|
1531
1534
|
class: vue.normalizeClass(["m-editor-layout-right", _ctx.rightClass]),
|
|
@@ -1619,6 +1622,40 @@
|
|
|
1619
1622
|
}
|
|
1620
1623
|
]
|
|
1621
1624
|
},
|
|
1625
|
+
{
|
|
1626
|
+
type: "fieldset",
|
|
1627
|
+
legend: "边框",
|
|
1628
|
+
items: [
|
|
1629
|
+
{
|
|
1630
|
+
name: "borderWidth",
|
|
1631
|
+
text: "宽度",
|
|
1632
|
+
defaultValue: "0"
|
|
1633
|
+
},
|
|
1634
|
+
{
|
|
1635
|
+
name: "borderColor",
|
|
1636
|
+
text: "颜色",
|
|
1637
|
+
type: "colorPicker"
|
|
1638
|
+
},
|
|
1639
|
+
{
|
|
1640
|
+
name: "borderStyle",
|
|
1641
|
+
text: "样式",
|
|
1642
|
+
type: "select",
|
|
1643
|
+
defaultValue: "none",
|
|
1644
|
+
options: [
|
|
1645
|
+
{ text: "none", value: "none" },
|
|
1646
|
+
{ text: "hidden", value: "hidden" },
|
|
1647
|
+
{ text: "dotted", value: "dotted" },
|
|
1648
|
+
{ text: "dashed", value: "dashed" },
|
|
1649
|
+
{ text: "solid", value: "solid" },
|
|
1650
|
+
{ text: "double", value: "double" },
|
|
1651
|
+
{ text: "groove", value: "groove" },
|
|
1652
|
+
{ text: "ridge", value: "ridge" },
|
|
1653
|
+
{ text: "inset", value: "inset" },
|
|
1654
|
+
{ text: "outset", value: "outset" }
|
|
1655
|
+
]
|
|
1656
|
+
}
|
|
1657
|
+
]
|
|
1658
|
+
},
|
|
1622
1659
|
{
|
|
1623
1660
|
type: "fieldset",
|
|
1624
1661
|
legend: "背景",
|
|
@@ -3469,7 +3506,6 @@
|
|
|
3469
3506
|
const codeOptions = vue.inject("codeOptions", {});
|
|
3470
3507
|
const { editorService, uiService } = vue.inject("services") || {};
|
|
3471
3508
|
const root = vue.computed(() => editorService?.get("root"));
|
|
3472
|
-
const nodes = vue.computed(() => editorService?.get("nodes") || []);
|
|
3473
3509
|
const pageLength = vue.computed(() => editorService?.get("pageLength") || 0);
|
|
3474
3510
|
const showSrc = vue.computed(() => uiService?.get("showSrc"));
|
|
3475
3511
|
const leftColumnWidthCacheData = Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY));
|
|
@@ -3562,7 +3598,7 @@
|
|
|
3562
3598
|
]),
|
|
3563
3599
|
_: 2
|
|
3564
3600
|
}, [
|
|
3565
|
-
pageLength.value > 0
|
|
3601
|
+
pageLength.value > 0 ? {
|
|
3566
3602
|
name: "right",
|
|
3567
3603
|
fn: vue.withCtx(() => [
|
|
3568
3604
|
vue.createVNode(vue.unref(design.TMagicScrollbar), null, {
|
|
@@ -3921,7 +3957,10 @@
|
|
|
3921
3957
|
}
|
|
3922
3958
|
});
|
|
3923
3959
|
|
|
3924
|
-
const _hoisted_1$e = {
|
|
3960
|
+
const _hoisted_1$e = {
|
|
3961
|
+
key: 0,
|
|
3962
|
+
class: "m-editor-props-panel"
|
|
3963
|
+
};
|
|
3925
3964
|
const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
|
|
3926
3965
|
...{
|
|
3927
3966
|
name: "MEditorPropsPanel"
|
|
@@ -3935,6 +3974,7 @@
|
|
|
3935
3974
|
const curFormConfig = vue.ref([]);
|
|
3936
3975
|
const services = vue.inject("services");
|
|
3937
3976
|
const node = vue.computed(() => services?.editorService.get("node"));
|
|
3977
|
+
const nodes = vue.computed(() => services?.editorService.get("nodes") || []);
|
|
3938
3978
|
const propsPanelSize = vue.computed(() => services?.uiService.get("propsPanelSize") || "small");
|
|
3939
3979
|
const stage = vue.computed(() => services?.editorService.get("stage"));
|
|
3940
3980
|
const init = async () => {
|
|
@@ -3971,7 +4011,7 @@
|
|
|
3971
4011
|
};
|
|
3972
4012
|
__expose({ submit });
|
|
3973
4013
|
return (_ctx, _cache) => {
|
|
3974
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$e, [
|
|
4014
|
+
return nodes.value.length === 1 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$e, [
|
|
3975
4015
|
vue.renderSlot(_ctx.$slots, "props-panel-header"),
|
|
3976
4016
|
vue.createVNode(vue.unref(form.MForm), {
|
|
3977
4017
|
ref_key: "configForm",
|
|
@@ -3983,7 +4023,7 @@
|
|
|
3983
4023
|
config: curFormConfig.value,
|
|
3984
4024
|
onChange: submit
|
|
3985
4025
|
}, null, 8, ["class", "popper-class", "size", "init-values", "config"])
|
|
3986
|
-
]);
|
|
4026
|
+
])) : vue.createCommentVNode("", true);
|
|
3987
4027
|
};
|
|
3988
4028
|
}
|
|
3989
4029
|
});
|
|
@@ -5228,6 +5268,7 @@
|
|
|
5228
5268
|
const services = vue.inject("services");
|
|
5229
5269
|
const menu = vue.ref();
|
|
5230
5270
|
const node = vue.computed(() => services?.editorService.get("node"));
|
|
5271
|
+
const nodes = vue.computed(() => services?.editorService.get("nodes"));
|
|
5231
5272
|
const isRoot = vue.computed(() => node.value?.type === schema.NodeType.ROOT);
|
|
5232
5273
|
const isPage = vue.computed(() => node.value?.type === schema.NodeType.PAGE);
|
|
5233
5274
|
const componentList = vue.computed(() => services?.componentListService.getList() || []);
|
|
@@ -5279,7 +5320,7 @@
|
|
|
5279
5320
|
type: "button",
|
|
5280
5321
|
text: "新增",
|
|
5281
5322
|
icon: vue.markRaw(iconsVue.Plus),
|
|
5282
|
-
display: () => node.value?.items,
|
|
5323
|
+
display: () => node.value?.items && nodes.value?.length === 1,
|
|
5283
5324
|
items: getSubMenuData.value
|
|
5284
5325
|
},
|
|
5285
5326
|
{
|
|
@@ -5288,7 +5329,7 @@
|
|
|
5288
5329
|
icon: vue.markRaw(iconsVue.CopyDocument),
|
|
5289
5330
|
display: () => !isRoot.value,
|
|
5290
5331
|
handler: () => {
|
|
5291
|
-
node.value && services?.editorService.copy(
|
|
5332
|
+
node.value && services?.editorService.copy(nodes.value || []);
|
|
5292
5333
|
}
|
|
5293
5334
|
},
|
|
5294
5335
|
{
|
|
@@ -5297,7 +5338,7 @@
|
|
|
5297
5338
|
icon: vue.markRaw(iconsVue.Delete),
|
|
5298
5339
|
display: () => !isRoot.value && !isPage.value,
|
|
5299
5340
|
handler: () => {
|
|
5300
|
-
node.value && services?.editorService.remove(
|
|
5341
|
+
node.value && services?.editorService.remove(nodes.value || []);
|
|
5301
5342
|
}
|
|
5302
5343
|
},
|
|
5303
5344
|
...props.layerContentMenu
|
|
@@ -5550,7 +5591,9 @@
|
|
|
5550
5591
|
};
|
|
5551
5592
|
const contextmenu = async (event, data) => {
|
|
5552
5593
|
event.preventDefault();
|
|
5553
|
-
|
|
5594
|
+
if (nodes.value.length < 2) {
|
|
5595
|
+
await select(data);
|
|
5596
|
+
}
|
|
5554
5597
|
menu.value?.show(event);
|
|
5555
5598
|
};
|
|
5556
5599
|
return (_ctx, _cache) => {
|
|
@@ -8309,6 +8352,7 @@
|
|
|
8309
8352
|
exports.Layout = Layout;
|
|
8310
8353
|
exports.LayoutContainer = _sfc_main$s;
|
|
8311
8354
|
exports.PropsPanel = _sfc_main$n;
|
|
8355
|
+
exports.Resizer = _sfc_main$t;
|
|
8312
8356
|
exports.SplitView = _sfc_main$s;
|
|
8313
8357
|
exports.TMagicCodeEditor = _sfc_main$u;
|
|
8314
8358
|
exports.TMagicEditor = Editor;
|