@tmagic/editor 1.2.0-beta.25 → 1.2.0-beta.27

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.
Files changed (35) hide show
  1. package/dist/style.css +32 -16
  2. package/dist/tmagic-editor.js +38 -14
  3. package/dist/tmagic-editor.js.map +1 -1
  4. package/dist/tmagic-editor.umd.cjs +38 -14
  5. package/dist/tmagic-editor.umd.cjs.map +1 -1
  6. package/package.json +10 -10
  7. package/src/Editor.vue +13 -4
  8. package/src/layouts/NavMenu.vue +1 -1
  9. package/src/layouts/PropsPanel.vue +5 -1
  10. package/src/layouts/sidebar/LayerPanel.vue +10 -6
  11. package/src/services/BaseService.ts +6 -2
  12. package/src/services/editor.ts +12 -1
  13. package/src/theme/code-block.scss +11 -3
  14. package/src/theme/component-list-panel.scss +8 -5
  15. package/src/type.ts +1 -0
  16. package/src/utils/stage.ts +1 -0
  17. package/types/Editor.vue.d.ts +7 -0
  18. package/types/components/CodeDraftEditor.vue.d.ts +19 -111
  19. package/types/components/ContentMenu.vue.d.ts +11 -87
  20. package/types/components/FunctionEditor.vue.d.ts +13 -90
  21. package/types/components/Icon.vue.d.ts +4 -50
  22. package/types/components/ScrollBar.vue.d.ts +7 -65
  23. package/types/components/ToolButton.vue.d.ts +12 -78
  24. package/types/fields/Code.vue.d.ts +11 -77
  25. package/types/fields/CodeLink.vue.d.ts +12 -82
  26. package/types/fields/CodeSelect.vue.d.ts +10 -74
  27. package/types/fields/UISelect.vue.d.ts +7 -65
  28. package/types/layouts/AddPageBox.vue.d.ts +1 -43
  29. package/types/layouts/CodeEditor.vue.d.ts +21 -122
  30. package/types/layouts/NavMenu.vue.d.ts +9 -69
  31. package/types/layouts/sidebar/LayerMenu.vue.d.ts +5 -55
  32. package/types/layouts/workspace/Breadcrumb.vue.d.ts +1 -43
  33. package/types/layouts/workspace/Stage.vue.d.ts +4 -51
  34. package/types/layouts/workspace/ViewerMenu.vue.d.ts +9 -69
  35. package/types/type.d.ts +1 -0
package/dist/style.css CHANGED
@@ -325,13 +325,13 @@
325
325
  left: 0;
326
326
  z-index: 1;
327
327
  }
328
- .ui-component-panel {
328
+ .ui-component-panel.tmagic-design-collapse {
329
329
  height: 100%;
330
330
  border-top: 0 !important;
331
331
  margin-top: 48px;
332
332
  background-color: #ffffff;
333
333
  }
334
- .ui-component-panel .search-input {
334
+ .ui-component-panel.tmagic-design-collapse .search-input {
335
335
  background: #fff;
336
336
  color: #bbbbbb;
337
337
  padding: 10px;
@@ -341,14 +341,15 @@
341
341
  box-sizing: border-box;
342
342
  z-index: 1;
343
343
  }
344
- .ui-component-panel .search-input .el-input__prefix {
344
+ .ui-component-panel.tmagic-design-collapse .search-input .el-input__prefix {
345
345
  padding: 7px;
346
346
  }
347
- .ui-component-panel .el-collapse-item > div:first-of-type {
347
+ .ui-component-panel.tmagic-design-collapse .tmagic-design-collapse-item > div:first-of-type {
348
348
  border-bottom: 1px solid #d9dbdd;
349
349
  margin-bottom: 10px;
350
350
  }
351
- .ui-component-panel .el-collapse-item__header {
351
+ .ui-component-panel.tmagic-design-collapse .el-collapse-item__header,
352
+ .ui-component-panel.tmagic-design-collapse .t-collapse-panel__header {
352
353
  background: #ffffff;
353
354
  color: #070303;
354
355
  height: 25px;
@@ -356,20 +357,26 @@
356
357
  padding-left: 10px;
357
358
  font-size: 12px;
358
359
  }
359
- .ui-component-panel .el-collapse-item__header i {
360
+ .ui-component-panel.tmagic-design-collapse .el-collapse-item__header i,
361
+ .ui-component-panel.tmagic-design-collapse .t-collapse-panel__header i {
360
362
  margin-right: 5px;
361
363
  font-size: 14px;
362
364
  }
363
- .ui-component-panel .el-collapse-item__wrap {
365
+ .ui-component-panel.tmagic-design-collapse .el-collapse-item__wrap,
366
+ .ui-component-panel.tmagic-design-collapse .t-collapse-panel__body {
364
367
  background: #ffffff;
365
368
  border-bottom: 0;
366
369
  }
367
- .ui-component-panel .el-collapse-item__wrap .el-collapse-item__content {
370
+ .ui-component-panel.tmagic-design-collapse .el-collapse-item__wrap .el-collapse-item__content,
371
+ .ui-component-panel.tmagic-design-collapse .el-collapse-item__wrap .t-collapse-panel__content,
372
+ .ui-component-panel.tmagic-design-collapse .t-collapse-panel__body .el-collapse-item__content,
373
+ .ui-component-panel.tmagic-design-collapse .t-collapse-panel__body .t-collapse-panel__content {
368
374
  padding: 10px;
369
375
  display: flex;
370
376
  flex-wrap: wrap;
371
377
  }
372
- .ui-component-panel .el-collapse-item__wrap .component-item {
378
+ .ui-component-panel.tmagic-design-collapse .el-collapse-item__wrap .component-item,
379
+ .ui-component-panel.tmagic-design-collapse .t-collapse-panel__body .component-item {
373
380
  display: flex;
374
381
  overflow: hidden;
375
382
  text-overflow: ellipsis;
@@ -380,7 +387,8 @@
380
387
  width: 42px;
381
388
  cursor: pointer;
382
389
  }
383
- .ui-component-panel .el-collapse-item__wrap .component-item i {
390
+ .ui-component-panel.tmagic-design-collapse .el-collapse-item__wrap .component-item i,
391
+ .ui-component-panel.tmagic-design-collapse .t-collapse-panel__body .component-item i {
384
392
  font-size: 20px;
385
393
  background: #fff;
386
394
  height: 40px;
@@ -394,16 +402,19 @@
394
402
  align-items: center;
395
403
  margin-bottom: 5px;
396
404
  }
397
- .ui-component-panel .el-collapse-item__wrap .component-item i:hover {
405
+ .ui-component-panel.tmagic-design-collapse .el-collapse-item__wrap .component-item i:hover,
406
+ .ui-component-panel.tmagic-design-collapse .t-collapse-panel__body .component-item i:hover {
398
407
  background: #2882e0;
399
408
  color: #fff;
400
409
  border-color: #4e8be1;
401
410
  }
402
- .ui-component-panel .el-collapse-item__wrap .component-item span {
411
+ .ui-component-panel.tmagic-design-collapse .el-collapse-item__wrap .component-item span,
412
+ .ui-component-panel.tmagic-design-collapse .t-collapse-panel__body .component-item span {
403
413
  font-size: 12px;
404
414
  text-align: center;
405
415
  }
406
- .ui-component-panel .el-collapse-item__wrap .component-item .el-tooltip {
416
+ .ui-component-panel.tmagic-design-collapse .el-collapse-item__wrap .component-item .el-tooltip,
417
+ .ui-component-panel.tmagic-design-collapse .t-collapse-panel__body .component-item .el-tooltip {
407
418
  width: 50px;
408
419
  height: 30px;
409
420
  line-height: 15px;
@@ -696,15 +707,20 @@
696
707
  .el-dialog.is-fullscreen.code-editor-dialog {
697
708
  overflow: hidden;
698
709
  }
699
- .code-editor-dialog .el-dialog__body {
710
+ .code-editor-dialog .tmagic-design-card .t-card__header {
711
+ display: block;
712
+ }
713
+ .code-editor-dialog .el-dialog__body,
714
+ .code-editor-dialog .t-dialog__body {
700
715
  height: 90%;
701
716
  padding-top: 10px;
702
717
  }
703
- .code-editor-dialog .el-card {
718
+ .code-editor-dialog .tmagic-design-card {
704
719
  height: 100%;
705
720
  background: #fff;
706
721
  }
707
- .code-editor-dialog .el-card .el-card__body {
722
+ .code-editor-dialog .tmagic-design-card .el-card__body,
723
+ .code-editor-dialog .tmagic-design-card .t-card__body {
708
724
  height: 100%;
709
725
  background: #fff;
710
726
  }
@@ -858,8 +858,12 @@ class BaseService extends EventEmitter {
858
858
  });
859
859
  }
860
860
  removeAllPlugins() {
861
- this.pluginOptionsList = {};
862
- this.middleware = {};
861
+ Object.keys(this.pluginOptionsList).forEach((key) => {
862
+ this.pluginOptionsList[key] = [];
863
+ });
864
+ Object.keys(this.middleware).forEach((key) => {
865
+ this.middleware[key] = [];
866
+ });
863
867
  }
864
868
  async doTask() {
865
869
  this.doingTask = true;
@@ -2009,8 +2013,16 @@ class Editor$1 extends BaseService {
2009
2013
  const config = await storageService.getItem(COPY_STORAGE_KEY);
2010
2014
  if (!Array.isArray(config))
2011
2015
  return;
2016
+ const node = this.get("node");
2017
+ let parent = void 0;
2018
+ if (config.length === 1 && config[0].id === node.id) {
2019
+ parent = this.get("parent");
2020
+ if (parent.type === NodeType.ROOT) {
2021
+ parent = this.get("page");
2022
+ }
2023
+ }
2012
2024
  const pasteConfigs = await this.doPaste(config, position);
2013
- return this.add(pasteConfigs, this.get("parent"));
2025
+ return this.add(pasteConfigs, parent);
2014
2026
  }
2015
2027
  async doPaste(config, position = {}) {
2016
2028
  const pasteConfigs = await beforePaste(position, cloneDeep(config));
@@ -2598,6 +2610,7 @@ const useStage = (stageOptions) => {
2598
2610
  containerHighlightClassName: stageOptions.containerHighlightClassName,
2599
2611
  containerHighlightDuration: stageOptions.containerHighlightDuration,
2600
2612
  containerHighlightType: stageOptions.containerHighlightType,
2613
+ disabledDragStart: stageOptions.disabledDragStart,
2601
2614
  canSelect: (el, event, stop) => {
2602
2615
  const elCanSelect = stageOptions.canSelect(el);
2603
2616
  if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
@@ -3182,6 +3195,9 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
3182
3195
  onMounted(() => {
3183
3196
  emit("mounted", internalInstance);
3184
3197
  });
3198
+ onUnmounted(() => {
3199
+ services?.propsService.off("props-configs-change", init);
3200
+ });
3185
3201
  watchEffect(() => {
3186
3202
  if (configForm.value && stage.value) {
3187
3203
  configForm.value.formState.stage = stage.value;
@@ -4279,11 +4295,6 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
4279
4295
  const spliceNodeKey = ref();
4280
4296
  const filterText = ref("");
4281
4297
  const defaultExpandedKeys = computed(() => selectedIds.value.length > 0 ? selectedIds.value : []);
4282
- editorService?.on("remove", () => {
4283
- setTimeout(() => {
4284
- tree.value?.getNode(editorService.get("node").id)?.updateChildren();
4285
- }, 0);
4286
- });
4287
4298
  const select = async (data) => {
4288
4299
  if (!data.id) {
4289
4300
  throw new Error("\u6CA1\u6709id");
@@ -4420,8 +4431,14 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
4420
4431
  tree.value?.$el.blur();
4421
4432
  isMultiSelectStatus.value = false;
4422
4433
  };
4434
+ const editorServiceRemoveHandler = () => {
4435
+ setTimeout(() => {
4436
+ tree.value?.getNode(editorService?.get("node").id)?.updateChildren();
4437
+ }, 0);
4438
+ };
4423
4439
  let keycon;
4424
4440
  onMounted(() => {
4441
+ editorService?.on("remove", editorServiceRemoveHandler);
4425
4442
  keycon = new KeyController(tree.value?.$el);
4426
4443
  const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
4427
4444
  const ctrl = isMac ? "meta" : "ctrl";
@@ -4435,6 +4452,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
4435
4452
  });
4436
4453
  onUnmounted(() => {
4437
4454
  keycon.destroy();
4455
+ editorService?.off("remove", editorServiceRemoveHandler);
4438
4456
  });
4439
4457
  const clicked = ref(false);
4440
4458
  const highlightNode = computed(() => editorService?.get("highlightNode"));
@@ -5794,7 +5812,7 @@ const componentListService = new ComponentList();
5794
5812
  const _sfc_main = defineComponent({
5795
5813
  name: "m-editor",
5796
5814
  components: {
5797
- NavMenu: _sfc_main$j,
5815
+ TMagicNavMenu: _sfc_main$j,
5798
5816
  Sidebar: _sfc_main$9,
5799
5817
  Workspace: _sfc_main$1,
5800
5818
  PropsPanel: _sfc_main$i,
@@ -5877,11 +5895,14 @@ const _sfc_main = defineComponent({
5877
5895
  },
5878
5896
  updateDragEl: {
5879
5897
  type: Function
5898
+ },
5899
+ disabledDragStart: {
5900
+ type: Boolean
5880
5901
  }
5881
5902
  },
5882
5903
  emits: ["props-panel-mounted", "update:modelValue"],
5883
5904
  setup(props, { emit }) {
5884
- editorService.on("root-change", (value, preValue) => {
5905
+ const rootChangeHandler = (value, preValue) => {
5885
5906
  const nodeId = editorService.get("node")?.id || props.defaultSelected;
5886
5907
  let node;
5887
5908
  if (nodeId) {
@@ -5899,7 +5920,8 @@ const _sfc_main = defineComponent({
5899
5920
  if (toRaw(value) !== toRaw(preValue)) {
5900
5921
  emit("update:modelValue", value);
5901
5922
  }
5902
- });
5923
+ };
5924
+ editorService.on("root-change", rootChangeHandler);
5903
5925
  watch(
5904
5926
  () => props.modelValue,
5905
5927
  (modelValue) => {
@@ -5967,6 +5989,7 @@ const _sfc_main = defineComponent({
5967
5989
  uiService.resetState();
5968
5990
  componentListService.resetState();
5969
5991
  codeBlockService.resetState();
5992
+ editorService.off("root-change", rootChangeHandler);
5970
5993
  });
5971
5994
  const services = {
5972
5995
  componentListService,
@@ -5992,7 +6015,8 @@ const _sfc_main = defineComponent({
5992
6015
  isContainer: props.isContainer,
5993
6016
  containerHighlightClassName: props.containerHighlightClassName,
5994
6017
  containerHighlightDuration: props.containerHighlightDuration,
5995
- containerHighlightType: props.containerHighlightType
6018
+ containerHighlightType: props.containerHighlightType,
6019
+ disabledDragStart: props.disabledDragStart
5996
6020
  })
5997
6021
  );
5998
6022
  return services;
@@ -6008,7 +6032,7 @@ const _export_sfc = (sfc, props) => {
6008
6032
  };
6009
6033
 
6010
6034
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
6011
- const _component_NavMenu = resolveComponent("NavMenu");
6035
+ const _component_TMagicNavMenu = resolveComponent("TMagicNavMenu");
6012
6036
  const _component_Sidebar = resolveComponent("Sidebar");
6013
6037
  const _component_Workspace = resolveComponent("Workspace");
6014
6038
  const _component_PropsPanel = resolveComponent("PropsPanel");
@@ -6016,7 +6040,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
6016
6040
  return openBlock(), createBlock(_component_Framework, { "code-options": _ctx.codeOptions }, {
6017
6041
  nav: withCtx(() => [
6018
6042
  renderSlot(_ctx.$slots, "nav", { editorService: _ctx.editorService }, () => [
6019
- createVNode(_component_NavMenu, { data: _ctx.menu }, null, 8, ["data"])
6043
+ createVNode(_component_TMagicNavMenu, { data: _ctx.menu }, null, 8, ["data"])
6020
6044
  ])
6021
6045
  ]),
6022
6046
  sidebar: withCtx(() => [