@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 CHANGED
@@ -943,6 +943,20 @@
943
943
  justify-content: flex-end;
944
944
  margin-top: 15px;
945
945
  }
946
+ .tmagic-data-source-input-text .el-input__wrapper.tmagic-data-source-input-text-wrapper {
947
+ overflow: hidden;
948
+ padding-right: 30px;
949
+ }
950
+ .tmagic-data-source-input-text .el-input__inner {
951
+ display: flex;
952
+ align-items: center;
953
+ overflow: hidden;
954
+ white-space: nowrap;
955
+ }
956
+ .tmagic-data-source-input-text .tmagic-data-source-input-icon {
957
+ position: absolute;
958
+ right: 7px;
959
+ }
946
960
  .m-fields-key-value-item {
947
961
  display: flex;
948
962
  margin-bottom: 10px;
@@ -563,7 +563,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
563
563
  const dataSources = computed(() => dataSourceService?.get("dataSources") || []);
564
564
  const setDisplayState = () => {
565
565
  displayState.value = [];
566
- const matches = state.value.matchAll(/\{\{([\s\S]+?)\}\}/g);
566
+ const matches = state.value.matchAll(/\$\{([\s\S]+?)\}/g);
567
567
  let index = 0;
568
568
  for (const match of matches) {
569
569
  if (typeof match.index === "undefined")
@@ -636,13 +636,13 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
636
636
  }
637
637
  return selectionStart;
638
638
  };
639
- const curCharIsLeftCurlyBracket = (leftCurlyBracketIndex) => leftCurlyBracketIndex > -1 && leftCurlyBracketIndex === getSelectionStart() - 1;
639
+ const curCharIsLeftCurlyBracket = (leftCurlyBracketIndex) => leftCurlyBracketIndex > 0 && leftCurlyBracketIndex === getSelectionStart() - 1;
640
640
  const curCharIsDot = (dotIndex) => dotIndex > -1 && dotIndex === getSelectionStart() - 1;
641
641
  const dsQuerySearch = (queryString, leftCurlyBracketIndex, cb) => {
642
642
  let result = [];
643
643
  if (curCharIsLeftCurlyBracket(leftCurlyBracketIndex)) {
644
644
  result = dataSources.value;
645
- } else if (leftCurlyBracketIndex > -1) {
645
+ } else if (leftCurlyBracketIndex > 0) {
646
646
  const queryName = queryString.substring(leftCurlyBracketIndex + 1).toLowerCase();
647
647
  result = dataSources.value.filter((ds) => ds.title?.toLowerCase().includes(queryName) || ds.id.includes(queryName));
648
648
  }
@@ -694,7 +694,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
694
694
  const selectionStart = getSelectionStart();
695
695
  const curQueryString = queryString.substring(0, selectionStart);
696
696
  const fieldKeyStringLastIndex = curQueryString.lastIndexOf(".");
697
- const dsKeyStringLastIndex = curQueryString.lastIndexOf("{");
697
+ const dsKeyStringLastIndex = curQueryString.lastIndexOf("${") + 1;
698
698
  const isFieldTip = fieldKeyStringLastIndex > dsKeyStringLastIndex;
699
699
  if (isFieldTip) {
700
700
  fieldQuerySearch(curQueryString, dsKeyStringLastIndex, fieldKeyStringLastIndex, cb);
@@ -707,7 +707,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
707
707
  const selectionStart = input.value?.selectionStart || 0;
708
708
  let startText = inputText.substring(0, selectionStart);
709
709
  const dotIndex = startText.lastIndexOf(".");
710
- const leftCurlyBracketIndex = startText.lastIndexOf("{");
710
+ const leftCurlyBracketIndex = startText.lastIndexOf("${") + 1;
711
711
  const endText = inputText.substring(selectionStart);
712
712
  let suggestText = value;
713
713
  if (isDataSource) {
@@ -717,7 +717,6 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
717
717
  if (!isRightCurlyBracket(selectionStart + 1)) {
718
718
  suggestText = `${suggestText}}`;
719
719
  }
720
- suggestText = `{${suggestText}}`;
721
720
  } else if (!curCharIsDot(dotIndex)) {
722
721
  startText = startText.substring(0, dotIndex + 1);
723
722
  }
@@ -725,7 +724,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
725
724
  await nextTick();
726
725
  let newSelectionStart = 0;
727
726
  if (isDataSource) {
728
- newSelectionStart = leftCurlyBracketIndex + suggestText.length - 1;
727
+ newSelectionStart = leftCurlyBracketIndex + suggestText.length;
729
728
  } else {
730
729
  newSelectionStart = dotIndex + suggestText.length + 1;
731
730
  }
@@ -768,11 +767,11 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
768
767
  _: 1
769
768
  }, 16, ["modelValue"])) : (openBlock(), createElementBlock("div", {
770
769
  key: 1,
771
- class: normalizeClass(`el-input el-input--${_ctx.size}`),
770
+ class: normalizeClass(`tmagic-data-source-input-text el-input el-input--${_ctx.size}`),
772
771
  onMouseup: mouseupHandler
773
772
  }, [
774
773
  createElementVNode("div", {
775
- class: normalizeClass(`el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
774
+ class: normalizeClass(`tmagic-data-source-input-text-wrapper el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
776
775
  }, [
777
776
  createElementVNode("div", _hoisted_3$5, [
778
777
  (openBlock(true), createElementBlock(Fragment, null, renderList(displayState.value, (item, index) => {
@@ -791,7 +790,11 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
791
790
  _: 2
792
791
  }, 1032, ["size"])) : createCommentVNode("", true)
793
792
  ], 64);
794
- }), 256))
793
+ }), 256)),
794
+ createVNode(_sfc_main$B, {
795
+ class: "tmagic-data-source-input-icon",
796
+ icon: unref(Coin)
797
+ }, null, 8, ["icon"])
795
798
  ])
796
799
  ], 2)
797
800
  ], 34));
@@ -1501,7 +1504,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
1501
1504
  ref: el,
1502
1505
  class: "m-editor-layout"
1503
1506
  }, [
1504
- hasLeft.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1507
+ hasLeft.value && _ctx.$slots.left ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1505
1508
  createElementVNode("div", {
1506
1509
  class: normalizeClass(["m-editor-layout-left", _ctx.leftClass]),
1507
1510
  style: normalizeStyle(`width: ${_ctx.left}px`)
@@ -1516,7 +1519,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
1516
1519
  }, [
1517
1520
  renderSlot(_ctx.$slots, "center")
1518
1521
  ], 6),
1519
- hasRight.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1522
+ hasRight.value && _ctx.$slots.right ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1520
1523
  createVNode(_sfc_main$t, { onChange: changeRight }),
1521
1524
  createElementVNode("div", {
1522
1525
  class: normalizeClass(["m-editor-layout-right", _ctx.rightClass]),
@@ -1610,6 +1613,40 @@ const fillConfig$1 = (config = []) => [
1610
1613
  }
1611
1614
  ]
1612
1615
  },
1616
+ {
1617
+ type: "fieldset",
1618
+ legend: "边框",
1619
+ items: [
1620
+ {
1621
+ name: "borderWidth",
1622
+ text: "宽度",
1623
+ defaultValue: "0"
1624
+ },
1625
+ {
1626
+ name: "borderColor",
1627
+ text: "颜色",
1628
+ type: "colorPicker"
1629
+ },
1630
+ {
1631
+ name: "borderStyle",
1632
+ text: "样式",
1633
+ type: "select",
1634
+ defaultValue: "none",
1635
+ options: [
1636
+ { text: "none", value: "none" },
1637
+ { text: "hidden", value: "hidden" },
1638
+ { text: "dotted", value: "dotted" },
1639
+ { text: "dashed", value: "dashed" },
1640
+ { text: "solid", value: "solid" },
1641
+ { text: "double", value: "double" },
1642
+ { text: "groove", value: "groove" },
1643
+ { text: "ridge", value: "ridge" },
1644
+ { text: "inset", value: "inset" },
1645
+ { text: "outset", value: "outset" }
1646
+ ]
1647
+ }
1648
+ ]
1649
+ },
1613
1650
  {
1614
1651
  type: "fieldset",
1615
1652
  legend: "背景",
@@ -3460,7 +3497,6 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
3460
3497
  const codeOptions = inject("codeOptions", {});
3461
3498
  const { editorService, uiService } = inject("services") || {};
3462
3499
  const root = computed(() => editorService?.get("root"));
3463
- const nodes = computed(() => editorService?.get("nodes") || []);
3464
3500
  const pageLength = computed(() => editorService?.get("pageLength") || 0);
3465
3501
  const showSrc = computed(() => uiService?.get("showSrc"));
3466
3502
  const leftColumnWidthCacheData = Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY));
@@ -3553,7 +3589,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
3553
3589
  ]),
3554
3590
  _: 2
3555
3591
  }, [
3556
- pageLength.value > 0 && nodes.value.length === 1 ? {
3592
+ pageLength.value > 0 ? {
3557
3593
  name: "right",
3558
3594
  fn: withCtx(() => [
3559
3595
  createVNode(unref(TMagicScrollbar), null, {
@@ -3912,7 +3948,10 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
3912
3948
  }
3913
3949
  });
3914
3950
 
3915
- const _hoisted_1$e = { class: "m-editor-props-panel" };
3951
+ const _hoisted_1$e = {
3952
+ key: 0,
3953
+ class: "m-editor-props-panel"
3954
+ };
3916
3955
  const _sfc_main$n = /* @__PURE__ */ defineComponent({
3917
3956
  ...{
3918
3957
  name: "MEditorPropsPanel"
@@ -3926,6 +3965,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
3926
3965
  const curFormConfig = ref([]);
3927
3966
  const services = inject("services");
3928
3967
  const node = computed(() => services?.editorService.get("node"));
3968
+ const nodes = computed(() => services?.editorService.get("nodes") || []);
3929
3969
  const propsPanelSize = computed(() => services?.uiService.get("propsPanelSize") || "small");
3930
3970
  const stage = computed(() => services?.editorService.get("stage"));
3931
3971
  const init = async () => {
@@ -3962,7 +4002,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
3962
4002
  };
3963
4003
  __expose({ submit });
3964
4004
  return (_ctx, _cache) => {
3965
- return openBlock(), createElementBlock("div", _hoisted_1$e, [
4005
+ return nodes.value.length === 1 ? (openBlock(), createElementBlock("div", _hoisted_1$e, [
3966
4006
  renderSlot(_ctx.$slots, "props-panel-header"),
3967
4007
  createVNode(unref(MForm), {
3968
4008
  ref_key: "configForm",
@@ -3974,7 +4014,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
3974
4014
  config: curFormConfig.value,
3975
4015
  onChange: submit
3976
4016
  }, null, 8, ["class", "popper-class", "size", "init-values", "config"])
3977
- ]);
4017
+ ])) : createCommentVNode("", true);
3978
4018
  };
3979
4019
  }
3980
4020
  });
@@ -5219,6 +5259,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
5219
5259
  const services = inject("services");
5220
5260
  const menu = ref();
5221
5261
  const node = computed(() => services?.editorService.get("node"));
5262
+ const nodes = computed(() => services?.editorService.get("nodes"));
5222
5263
  const isRoot = computed(() => node.value?.type === NodeType.ROOT);
5223
5264
  const isPage = computed(() => node.value?.type === NodeType.PAGE);
5224
5265
  const componentList = computed(() => services?.componentListService.getList() || []);
@@ -5270,7 +5311,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
5270
5311
  type: "button",
5271
5312
  text: "新增",
5272
5313
  icon: markRaw(Plus),
5273
- display: () => node.value?.items,
5314
+ display: () => node.value?.items && nodes.value?.length === 1,
5274
5315
  items: getSubMenuData.value
5275
5316
  },
5276
5317
  {
@@ -5279,7 +5320,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
5279
5320
  icon: markRaw(CopyDocument),
5280
5321
  display: () => !isRoot.value,
5281
5322
  handler: () => {
5282
- node.value && services?.editorService.copy(node.value);
5323
+ node.value && services?.editorService.copy(nodes.value || []);
5283
5324
  }
5284
5325
  },
5285
5326
  {
@@ -5288,7 +5329,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
5288
5329
  icon: markRaw(Delete),
5289
5330
  display: () => !isRoot.value && !isPage.value,
5290
5331
  handler: () => {
5291
- node.value && services?.editorService.remove(node.value);
5332
+ node.value && services?.editorService.remove(nodes.value || []);
5292
5333
  }
5293
5334
  },
5294
5335
  ...props.layerContentMenu
@@ -5541,7 +5582,9 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
5541
5582
  };
5542
5583
  const contextmenu = async (event, data) => {
5543
5584
  event.preventDefault();
5544
- await select(data);
5585
+ if (nodes.value.length < 2) {
5586
+ await select(data);
5587
+ }
5545
5588
  menu.value?.show(event);
5546
5589
  };
5547
5590
  return (_ctx, _cache) => {
@@ -8277,5 +8320,5 @@ const index = {
8277
8320
  }
8278
8321
  };
8279
8322
 
8280
- export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$g as CodeBlockList, CodeDeleteErrorType, _sfc_main$C as CodeSelect, _sfc_main$A as CodeSelectCol, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, _sfc_main$z as DataSourceFields, _sfc_main$y as DataSourceInput, _sfc_main$x as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$B as Icon, KeyBindingCommand, _sfc_main$w as KeyValue, Keys, LayerOffset, _sfc_main$a as LayerPanel, Layout, _sfc_main$s as LayoutContainer, _sfc_main$n as PropsPanel, _sfc_main$s as SplitView, _sfc_main$u as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$p as ToolButton, V_GUIDE_LINE_STORAGE_KEY, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, editorService, error, eventsService, fillConfig$1 as fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, uiService, useStage, warn };
8323
+ export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$g as CodeBlockList, CodeDeleteErrorType, _sfc_main$C as CodeSelect, _sfc_main$A as CodeSelectCol, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, _sfc_main$z as DataSourceFields, _sfc_main$y as DataSourceInput, _sfc_main$x as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$B as Icon, KeyBindingCommand, _sfc_main$w as KeyValue, Keys, LayerOffset, _sfc_main$a as LayerPanel, Layout, _sfc_main$s as LayoutContainer, _sfc_main$n as PropsPanel, _sfc_main$t as Resizer, _sfc_main$s as SplitView, _sfc_main$u as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$p as ToolButton, V_GUIDE_LINE_STORAGE_KEY, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, editorService, error, eventsService, fillConfig$1 as fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, uiService, useStage, warn };
8281
8324
  //# sourceMappingURL=tmagic-editor.js.map