@tmagic/editor 1.0.0-rc.1 → 1.0.0-rc.10

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 (94) hide show
  1. package/dist/style.css +6 -3
  2. package/dist/tmagic-editor.es.js +292 -1394
  3. package/dist/tmagic-editor.es.js.map +1 -1
  4. package/dist/tmagic-editor.umd.js +292 -1396
  5. package/dist/tmagic-editor.umd.js.map +1 -1
  6. package/dist/types/src/Editor.vue.d.ts +49 -1
  7. package/dist/types/src/fields/Code.vue.d.ts +4 -4
  8. package/dist/types/src/fields/CodeLink.vue.d.ts +1 -3
  9. package/dist/types/src/layouts/Framework.vue.d.ts +15 -3
  10. package/dist/types/src/layouts/PropsPanel.vue.d.ts +2 -4
  11. package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +3 -27
  12. package/dist/types/src/services/BaseService.d.ts +1 -1
  13. package/dist/types/src/services/history.d.ts +1 -18
  14. package/dist/types/src/services/props.d.ts +8 -2
  15. package/dist/types/src/type.d.ts +9 -0
  16. package/dist/types/src/utils/editor.d.ts +0 -6
  17. package/dist/types/src/utils/props.d.ts +8 -1
  18. package/package.json +17 -18
  19. package/src/Editor.vue +44 -9
  20. package/src/components/ContentMenu.vue +59 -26
  21. package/src/layouts/CodeEditor.vue +1 -4
  22. package/src/layouts/Framework.vue +14 -1
  23. package/src/layouts/PropsPanel.vue +1 -1
  24. package/src/layouts/sidebar/LayerMenu.vue +3 -0
  25. package/src/layouts/sidebar/TabPane.vue +1 -1
  26. package/src/layouts/workspace/Stage.vue +12 -29
  27. package/src/layouts/workspace/ViewerMenu.vue +17 -2
  28. package/src/layouts/workspace/Workspace.vue +21 -26
  29. package/src/services/BaseService.ts +1 -1
  30. package/src/services/editor.ts +34 -5
  31. package/src/services/props.ts +64 -9
  32. package/src/theme/props-panel.scss +6 -4
  33. package/src/theme/workspace.scss +4 -0
  34. package/src/type.ts +10 -0
  35. package/src/utils/editor.ts +7 -52
  36. package/src/utils/polyfills.ts +5 -19
  37. package/src/utils/props.ts +30 -7
  38. package/LICENSE +0 -5432
  39. package/coverage/clover.xml +0 -1560
  40. package/coverage/coverage-final.json +0 -36
  41. package/coverage/lcov-report/base.css +0 -224
  42. package/coverage/lcov-report/block-navigation.js +0 -87
  43. package/coverage/lcov-report/favicon.png +0 -0
  44. package/coverage/lcov-report/index.html +0 -206
  45. package/coverage/lcov-report/prettify.css +0 -1
  46. package/coverage/lcov-report/prettify.js +0 -2
  47. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  48. package/coverage/lcov-report/sorter.js +0 -196
  49. package/coverage/lcov-report/src/Editor.vue.html +0 -787
  50. package/coverage/lcov-report/src/components/ContentMenu.vue.html +0 -406
  51. package/coverage/lcov-report/src/components/Icon.vue.html +0 -172
  52. package/coverage/lcov-report/src/components/ScrollViewer.vue.html +0 -283
  53. package/coverage/lcov-report/src/components/ToolButton.vue.html +0 -772
  54. package/coverage/lcov-report/src/components/index.html +0 -161
  55. package/coverage/lcov-report/src/index.html +0 -131
  56. package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +0 -214
  57. package/coverage/lcov-report/src/layouts/Framework.vue.html +0 -304
  58. package/coverage/lcov-report/src/layouts/NavMenu.vue.html +0 -208
  59. package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +0 -319
  60. package/coverage/lcov-report/src/layouts/Resizer.vue.html +0 -268
  61. package/coverage/lcov-report/src/layouts/index.html +0 -176
  62. package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +0 -358
  63. package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +0 -421
  64. package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +0 -775
  65. package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +0 -226
  66. package/coverage/lcov-report/src/layouts/sidebar/TabPane.vue.html +0 -289
  67. package/coverage/lcov-report/src/layouts/sidebar/index.html +0 -176
  68. package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +0 -718
  69. package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +0 -757
  70. package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +0 -532
  71. package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +0 -586
  72. package/coverage/lcov-report/src/layouts/workspace/index.html +0 -161
  73. package/coverage/lcov-report/src/services/BaseService.ts.html +0 -643
  74. package/coverage/lcov-report/src/services/componentList.ts.html +0 -229
  75. package/coverage/lcov-report/src/services/editor.ts.html +0 -2077
  76. package/coverage/lcov-report/src/services/events.ts.html +0 -331
  77. package/coverage/lcov-report/src/services/history.ts.html +0 -478
  78. package/coverage/lcov-report/src/services/index.html +0 -206
  79. package/coverage/lcov-report/src/services/props.ts.html +0 -415
  80. package/coverage/lcov-report/src/services/ui.ts.html +0 -580
  81. package/coverage/lcov-report/src/type.ts.html +0 -850
  82. package/coverage/lcov-report/src/utils/compose.ts.html +0 -184
  83. package/coverage/lcov-report/src/utils/config.ts.html +0 -172
  84. package/coverage/lcov-report/src/utils/editor.ts.html +0 -838
  85. package/coverage/lcov-report/src/utils/index.html +0 -221
  86. package/coverage/lcov-report/src/utils/index.ts.html +0 -151
  87. package/coverage/lcov-report/src/utils/logger.ts.html +0 -226
  88. package/coverage/lcov-report/src/utils/props.ts.html +0 -796
  89. package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +0 -733
  90. package/coverage/lcov-report/src/utils/undo-redo.ts.html +0 -313
  91. package/coverage/lcov.info +0 -3708
  92. package/dist/types/src/components/ToolButton.vue.d.ts +0 -46
  93. package/dist/types/src/fields/UISelect.vue.d.ts +0 -35
  94. package/dist/types/src/layouts/workspace/PageBar.vue.d.ts +0 -18
@@ -1,19 +1,23 @@
1
- import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, markRaw, createElementBlock, createVNode, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, watch, onMounted, onUnmounted, reactive, toRaw, createElementVNode, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, renderList, normalizeProps, mergeProps, getCurrentInstance, nextTick, withDirectives, Teleport, vShow, toHandlers, createSlots, provide } from 'vue';
1
+ import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, markRaw, createElementBlock, createVNode, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, watch, onMounted, onUnmounted, reactive, toRaw, createElementVNode, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, renderList, normalizeProps, mergeProps, getCurrentInstance, nextTick, Teleport, toHandlers, createSlots, provide } from 'vue';
2
2
  import serialize from 'serialize-javascript';
3
3
  import { Delete, Pointer, Close, Plus, Edit, ArrowDown, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Files, DocumentCopy, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons';
4
4
  import { throttle, cloneDeep, mergeWith, random } from 'lodash-es';
5
5
  import * as monaco from 'monaco-editor';
6
6
  import { NodeType } from '@tmagic/schema';
7
7
  import { toLine, isPop, getNodePath, isNumber, isPage } from '@tmagic/utils';
8
- import { EventEmitter as EventEmitter$2 } from 'events';
8
+ import { EventEmitter } from 'events';
9
9
  import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
10
+ import Gesto from 'gesto';
10
11
  import { ElMessage } from 'element-plus';
11
12
  import KeyController from 'keycon';
12
13
  import StageCore from '@tmagic/stage';
13
14
 
14
- if (typeof window.global === "undefined") {
15
+ if (typeof global === "undefined") {
15
16
  window.global = window;
16
17
  }
18
+ if (typeof globalThis === "undefined") {
19
+ window.globalThis = window;
20
+ }
17
21
 
18
22
  var _export_sfc = (sfc, props) => {
19
23
  const target = sfc.__vccOpts || sfc;
@@ -117,7 +121,7 @@ function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
117
121
  }
118
122
  var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$l]]);
119
123
 
120
- var UISelect_vue_vue_type_style_index_0_lang = '';
124
+ var UISelect_vue_vue_type_style_index_0_lang = /* #__PURE__ */ (() => ".m-fields-ui-select {\n cursor: pointer;\n}\n.m-fields-ui-select i {\n margin-right: 3px;\n}\n.m-fields-ui-select span {\n color: #2882e0;\n}")();
121
125
 
122
126
  const _sfc_main$k = defineComponent({
123
127
  name: "m-fields-ui-select",
@@ -310,11 +314,7 @@ const _sfc_main$j = defineComponent({
310
314
  const options = {
311
315
  value: values.value,
312
316
  language: props.language,
313
- tabSize: 2,
314
317
  theme: "vs-dark",
315
- fontFamily: 'dm, Menlo, Monaco, "Courier New", monospace',
316
- fontSize: 14,
317
- formatOnPaste: true,
318
318
  ...props.options
319
319
  };
320
320
  if (props.type === "diff") {
@@ -328,6 +328,7 @@ const _sfc_main$j = defineComponent({
328
328
  codeEditor.value.addEventListener("keydown", (e) => {
329
329
  if (e.keyCode === 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
330
330
  e.preventDefault();
331
+ e.stopPropagation();
331
332
  emit("save", getEditorValue());
332
333
  }
333
334
  });
@@ -483,7 +484,7 @@ const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethod
483
484
  throw error;
484
485
  }
485
486
  };
486
- class BaseService extends EventEmitter$2 {
487
+ class BaseService extends EventEmitter {
487
488
  constructor(methods = [], serialMethods = []) {
488
489
  super();
489
490
  this.pluginOptionsList = {};
@@ -626,7 +627,7 @@ var historyService = new History();
626
627
 
627
628
  class Props extends BaseService {
628
629
  constructor() {
629
- super(["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue"]);
630
+ super(["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue", "createId", "setNewItemId"]);
630
631
  this.state = reactive({
631
632
  propsConfigMap: {},
632
633
  propsValueMap: {}
@@ -665,12 +666,44 @@ class Props extends BaseService {
665
666
  }
666
667
  return value;
667
668
  }
668
- return cloneDeep({
669
- ...getDefaultPropsValue(type),
670
- ...mergeWith(this.state.propsValueMap[type] || {}, defaultValue)
671
- });
669
+ const data = cloneDeep(defaultValue);
670
+ await this.setNewItemId(data);
671
+ return {
672
+ ...getDefaultPropsValue(type, await this.createId(type)),
673
+ ...mergeWith(cloneDeep(this.state.propsValueMap[type] || {}), data)
674
+ };
675
+ }
676
+ async createId(type) {
677
+ return `${type}_${random(1e4, false)}`;
678
+ }
679
+ async setNewItemId(config, parent) {
680
+ const oldId = config.id;
681
+ config.id = await this.createId(config.type || "component");
682
+ if (isPop(config) && parent?.type === NodeType.PAGE) {
683
+ updatePopId(oldId, config.id, parent);
684
+ }
685
+ if (config.items && Array.isArray(config.items)) {
686
+ for (const item of config.items) {
687
+ await this.setNewItemId(item, config);
688
+ }
689
+ }
672
690
  }
673
691
  }
692
+ const updatePopId = (oldId, popId, pageConfig) => {
693
+ pageConfig.items?.forEach((config) => {
694
+ if (config.pop === oldId) {
695
+ config.pop = popId;
696
+ return;
697
+ }
698
+ if (config.popId === oldId) {
699
+ config.popId = popId;
700
+ return;
701
+ }
702
+ if (Array.isArray(config.items)) {
703
+ updatePopId(oldId, popId, config);
704
+ }
705
+ });
706
+ };
674
707
  var propsService = new Props();
675
708
 
676
709
  var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
@@ -691,7 +724,6 @@ var Keys = /* @__PURE__ */ ((Keys2) => {
691
724
  })(Keys || {});
692
725
 
693
726
  const COPY_STORAGE_KEY = "$MagicEditorCopyData";
694
- const generateId = (type) => `${type}_${random(1e4, false)}`;
695
727
  const getPageList = (app) => {
696
728
  if (app.items && Array.isArray(app.items)) {
697
729
  return app.items.filter((item) => item.type === NodeType.PAGE);
@@ -711,32 +743,6 @@ const generatePageName = (pageNameList) => {
711
743
  return pageName;
712
744
  };
713
745
  const generatePageNameByApp = (app) => generatePageName(getPageNameList(getPageList(app)));
714
- const updatePopId = (oldId, popId, pageConfig) => {
715
- pageConfig.items?.forEach((config) => {
716
- if (config.pop === oldId) {
717
- config.pop = popId;
718
- return;
719
- }
720
- if (config.popId === oldId) {
721
- config.popId = popId;
722
- return;
723
- }
724
- if (Array.isArray(config.items)) {
725
- updatePopId(oldId, popId, config);
726
- }
727
- });
728
- };
729
- const setNewItemId = (config, parent) => {
730
- const oldId = config.id;
731
- config.id = generateId(config.type || "component");
732
- config.name = `${config.name?.replace(/_(\d+)$/, "")}_${config.id}`;
733
- if (isPop(config) && parent?.type === NodeType.PAGE) {
734
- updatePopId(oldId, config.id, parent);
735
- }
736
- if (config.items && Array.isArray(config.items)) {
737
- config.items.forEach((item) => setNewItemId(item, config));
738
- }
739
- };
740
746
  const isFixed = (node) => node.style?.position === "fixed";
741
747
  const getNodeIndex = (node, parent) => {
742
748
  const items = parent?.items || [];
@@ -753,9 +759,12 @@ const toRelative = (node) => {
753
759
  };
754
760
  const setTop2Middle = (node, parentNode, stage) => {
755
761
  const style = node.style || {};
756
- const height = style.height || 0;
757
- if (!stage || typeof style.top !== "undefined" || !parentNode.style || !isNumber(height))
762
+ let height = style.height || 0;
763
+ if (!stage || typeof style.top !== "undefined" || !parentNode.style)
758
764
  return style;
765
+ if (!isNumber(height)) {
766
+ height = 0;
767
+ }
759
768
  const { height: parentHeight } = parentNode.style;
760
769
  if (isPage(parentNode)) {
761
770
  const { scrollTop = 0, wrapperHeight } = stage.mask;
@@ -944,6 +953,13 @@ class Editor$1 extends BaseService {
944
953
  } else {
945
954
  historyService.empty();
946
955
  }
956
+ if (node?.id) {
957
+ this.get("stage")?.renderer.runtime?.getApp?.()?.emit("editor:select", {
958
+ node,
959
+ page,
960
+ parent
961
+ }, getNodePath(node.id, this.get("root").items));
962
+ }
947
963
  this.emit("select", node);
948
964
  return node;
949
965
  }
@@ -1125,13 +1141,16 @@ class Editor$1 extends BaseService {
1125
1141
  console.error(e);
1126
1142
  return;
1127
1143
  }
1128
- setNewItemId(config, this.get("root"));
1144
+ await propsService.setNewItemId(config, this.get("root"));
1129
1145
  if (config.style) {
1130
1146
  config.style = {
1131
1147
  ...config.style,
1132
1148
  ...position
1133
1149
  };
1134
1150
  }
1151
+ if (isPage(config)) {
1152
+ config.name = generatePageNameByApp(this.get("root"));
1153
+ }
1135
1154
  return await this.add(config);
1136
1155
  }
1137
1156
  async alignCenter(config2) {
@@ -1141,7 +1160,17 @@ class Editor$1 extends BaseService {
1141
1160
  if (layout === Layout.RELATIVE) {
1142
1161
  return;
1143
1162
  }
1144
- if (parent.style?.width && node.style?.width) {
1163
+ if (!node.style)
1164
+ return;
1165
+ const stage = this.get("stage");
1166
+ const doc = stage?.renderer.contentWindow?.document;
1167
+ if (doc) {
1168
+ const parentEl = doc.getElementById(`${parent.id}`);
1169
+ const el = doc.getElementById(`${node.id}`);
1170
+ if (parentEl && el) {
1171
+ node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
1172
+ }
1173
+ } else if (parent.style && isNumber(parent.style?.width) && isNumber(node.style?.width)) {
1145
1174
  node.style.left = (parent.style.width - node.style.width) / 2;
1146
1175
  }
1147
1176
  await this.update(node);
@@ -1155,9 +1184,9 @@ class Editor$1 extends BaseService {
1155
1184
  const node = this.get("node");
1156
1185
  const brothers = parent?.items || [];
1157
1186
  const index = brothers.findIndex((item) => `${item.id}` === `${node?.id}`);
1158
- if (offset === LayerOffset.BOTTOM) {
1187
+ if (offset === LayerOffset.TOP) {
1159
1188
  brothers.splice(brothers.length - 1, 0, brothers.splice(index, 1)[0]);
1160
- } else if (offset === LayerOffset.TOP) {
1189
+ } else if (offset === LayerOffset.BOTTOM) {
1161
1190
  brothers.splice(0, 0, brothers.splice(index, 1)[0]);
1162
1191
  } else {
1163
1192
  brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
@@ -1442,6 +1471,21 @@ const fillConfig = (config = []) => [
1442
1471
  text: "\u7C97\u7EC6"
1443
1472
  }
1444
1473
  ]
1474
+ },
1475
+ {
1476
+ type: "fieldset",
1477
+ legend: "\u53D8\u5F62",
1478
+ name: "transform",
1479
+ items: [
1480
+ {
1481
+ name: "rotate",
1482
+ text: "\u65CB\u8F6C\u89D2\u5EA6"
1483
+ },
1484
+ {
1485
+ name: "scale",
1486
+ text: "\u7F29\u653E"
1487
+ }
1488
+ ]
1445
1489
  }
1446
1490
  ]
1447
1491
  }
@@ -1498,1269 +1542,66 @@ const fillConfig = (config = []) => [
1498
1542
  }
1499
1543
  ]
1500
1544
  }
1501
- ]
1502
- }
1503
- ];
1504
- const DEFAULT_CONFIG = fillConfig([]);
1505
- const getDefaultPropsValue = (type) => ({
1506
- type,
1507
- id: generateId(type),
1508
- style: {},
1509
- name: type
1510
- });
1511
-
1512
- const _sfc_main$i = defineComponent({
1513
- components: { Plus },
1514
- setup() {
1515
- const services = inject("services");
1516
- return {
1517
- clickHandler() {
1518
- const { editorService } = services || {};
1519
- if (!editorService)
1520
- return;
1521
- editorService.add({
1522
- type: NodeType.PAGE,
1523
- name: generatePageNameByApp(toRaw(editorService.get("root")))
1524
- });
1525
- }
1526
- };
1527
- }
1528
- });
1529
- const _hoisted_1$a = { class: "m-editor-empty-panel" };
1530
- const _hoisted_2$4 = { class: "m-editor-empty-content" };
1531
- const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1532
- function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
1533
- const _component_plus = resolveComponent("plus");
1534
- const _component_el_icon = resolveComponent("el-icon");
1535
- return openBlock(), createElementBlock("div", _hoisted_1$a, [
1536
- createElementVNode("div", _hoisted_2$4, [
1537
- createElementVNode("div", {
1538
- class: "m-editor-empty-button",
1539
- onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
1540
- }, [
1541
- createElementVNode("div", null, [
1542
- createVNode(_component_el_icon, null, {
1543
- default: withCtx(() => [
1544
- createVNode(_component_plus)
1545
- ]),
1546
- _: 1
1547
- })
1548
- ]),
1549
- _hoisted_3$2
1550
- ])
1551
- ])
1552
- ]);
1553
- }
1554
- var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
1555
-
1556
- /*
1557
- Copyright (c) 2018 Daybrush
1558
- @name: @daybrush/utils
1559
- license: MIT
1560
- author: Daybrush
1561
- repository: https://github.com/daybrush/utils
1562
- @version 1.6.0
1563
- */
1564
- /**
1565
- * get string "object"
1566
- * @memberof Consts
1567
- * @example
1568
- import {OBJECT} from "@daybrush/utils";
1569
-
1570
- console.log(OBJECT); // "object"
1571
- */
1572
-
1573
- var OBJECT = "object";
1574
- /**
1575
- * Check the type that the value is object.
1576
- * @memberof Utils
1577
- * @param {string} value - Value to check the type
1578
- * @return {} true if the type is correct, false otherwise
1579
- * @example
1580
- import {isObject} from "@daybrush/utils";
1581
-
1582
- console.log(isObject({})); // true
1583
- console.log(isObject(undefined)); // false
1584
- console.log(isObject("")); // false
1585
- console.log(isObject(null)); // false
1586
- */
1587
-
1588
- function isObject(value) {
1589
- return value && typeof value === OBJECT;
1590
- }
1591
- /**
1592
- * Date.now() method
1593
- * @memberof CrossBrowser
1594
- * @return {number} milliseconds
1595
- * @example
1596
- import {now} from "@daybrush/utils";
1597
-
1598
- console.log(now()); // 12121324241(milliseconds)
1599
- */
1600
-
1601
- function now() {
1602
- return Date.now ? Date.now() : new Date().getTime();
1603
- }
1604
- /**
1605
- * Returns the index of the first element in the array that satisfies the provided testing function.
1606
- * @function
1607
- * @memberof CrossBrowser
1608
- * @param - The array `findIndex` was called upon.
1609
- * @param - A function to execute on each value in the array until the function returns true, indicating that the satisfying element was found.
1610
- * @param - Returns defaultIndex if not found by the function.
1611
- * @example
1612
- import { findIndex } from "@daybrush/utils";
1613
-
1614
- findIndex([{a: 1}, {a: 2}, {a: 3}, {a: 4}], ({ a }) => a === 2); // 1
1615
- */
1616
-
1617
- function findIndex(arr, callback, defaultIndex) {
1618
- if (defaultIndex === void 0) {
1619
- defaultIndex = -1;
1620
- }
1621
-
1622
- var length = arr.length;
1623
-
1624
- for (var i = 0; i < length; ++i) {
1625
- if (callback(arr[i], i, arr)) {
1626
- return i;
1627
- }
1628
- }
1629
-
1630
- return defaultIndex;
1631
- }
1632
- /**
1633
- * Sets up a function that will be called whenever the specified event is delivered to the target
1634
- * @memberof DOM
1635
- * @param - event target
1636
- * @param - A case-sensitive string representing the event type to listen for.
1637
- * @param - The object which receives a notification (an object that implements the Event interface) when an event of the specified type occurs
1638
- * @param - An options object that specifies characteristics about the event listener.
1639
- * @example
1640
- import {addEvent} from "@daybrush/utils";
1641
-
1642
- addEvent(el, "click", e => {
1643
- console.log(e);
1644
- });
1645
- */
1646
-
1647
- function addEvent(el, type, listener, options) {
1648
- el.addEventListener(type, listener, options);
1649
- }
1650
- /**
1651
- * removes from the EventTarget an event listener previously registered with EventTarget.addEventListener()
1652
- * @memberof DOM
1653
- * @param - event target
1654
- * @param - A case-sensitive string representing the event type to listen for.
1655
- * @param - The EventListener function of the event handler to remove from the event target.
1656
- * @param - An options object that specifies characteristics about the event listener.
1657
- * @example
1658
- import {addEvent, removeEvent} from "@daybrush/utils";
1659
- const listener = e => {
1660
- console.log(e);
1661
- };
1662
- addEvent(el, "click", listener);
1663
- removeEvent(el, "click", listener);
1664
- */
1665
-
1666
- function removeEvent(el, type, listener, options) {
1667
- el.removeEventListener(type, listener, options);
1668
- }
1669
-
1670
- /*
1671
- Copyright (c) 2019 Daybrush
1672
- name: @scena/event-emitter
1673
- license: MIT
1674
- author: Daybrush
1675
- repository: git+https://github.com/daybrush/gesture.git
1676
- version: 1.0.5
1677
- */
1678
-
1679
- /*! *****************************************************************************
1680
- Copyright (c) Microsoft Corporation.
1681
-
1682
- Permission to use, copy, modify, and/or distribute this software for any
1683
- purpose with or without fee is hereby granted.
1684
-
1685
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1686
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1687
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1688
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1689
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1690
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1691
- PERFORMANCE OF THIS SOFTWARE.
1692
- ***************************************************************************** */
1693
- var __assign$1 = function () {
1694
- __assign$1 = Object.assign || function __assign(t) {
1695
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1696
- s = arguments[i];
1697
-
1698
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1699
- }
1700
-
1701
- return t;
1702
- };
1703
-
1704
- return __assign$1.apply(this, arguments);
1705
- };
1706
- function __spreadArrays() {
1707
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
1708
-
1709
- for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];
1710
-
1711
- return r;
1712
- }
1713
-
1714
- /**
1715
- * Implement EventEmitter on object or component.
1716
- */
1717
-
1718
- var EventEmitter =
1719
- /*#__PURE__*/
1720
- function () {
1721
- function EventEmitter() {
1722
- this._events = {};
1723
- }
1724
- /**
1725
- * Add a listener to the registered event.
1726
- * @param - Name of the event to be added
1727
- * @param - listener function of the event to be added
1728
- * @example
1729
- * import EventEmitter from "@scena/event-emitter";
1730
- * cosnt emitter = new EventEmitter();
1731
- *
1732
- * // Add listener in "a" event
1733
- * emitter.on("a", () => {
1734
- * });
1735
- * // Add listeners
1736
- * emitter.on({
1737
- * a: () => {},
1738
- * b: () => {},
1739
- * });
1740
- */
1741
-
1742
-
1743
- var __proto = EventEmitter.prototype;
1744
-
1745
- __proto.on = function (eventName, listener) {
1746
- if (isObject(eventName)) {
1747
- for (var name in eventName) {
1748
- this.on(name, eventName[name]);
1749
- }
1750
- } else {
1751
- this._addEvent(eventName, listener, {});
1752
- }
1753
-
1754
- return this;
1755
- };
1756
- /**
1757
- * Remove listeners registered in the event target.
1758
- * @param - Name of the event to be removed
1759
- * @param - listener function of the event to be removed
1760
- * @example
1761
- * import EventEmitter from "@scena/event-emitter";
1762
- * cosnt emitter = new EventEmitter();
1763
- *
1764
- * // Remove all listeners.
1765
- * emitter.off();
1766
- *
1767
- * // Remove all listeners in "A" event.
1768
- * emitter.off("a");
1769
- *
1770
- *
1771
- * // Remove "listener" listener in "a" event.
1772
- * emitter.off("a", listener);
1773
- */
1774
-
1775
-
1776
- __proto.off = function (eventName, listener) {
1777
- if (!eventName) {
1778
- this._events = {};
1779
- } else if (isObject(eventName)) {
1780
- for (var name in eventName) {
1781
- this.off(name);
1782
- }
1783
- } else if (!listener) {
1784
- this._events[eventName] = [];
1785
- } else {
1786
- var events = this._events[eventName];
1787
-
1788
- if (events) {
1789
- var index = findIndex(events, function (e) {
1790
- return e.listener === listener;
1791
- });
1792
-
1793
- if (index > -1) {
1794
- events.splice(index, 1);
1795
- }
1796
- }
1797
- }
1798
-
1799
- return this;
1800
- };
1801
- /**
1802
- * Add a disposable listener and Use promise to the registered event.
1803
- * @param - Name of the event to be added
1804
- * @param - disposable listener function of the event to be added
1805
- * @example
1806
- * import EventEmitter from "@scena/event-emitter";
1807
- * cosnt emitter = new EventEmitter();
1808
- *
1809
- * // Add a disposable listener in "a" event
1810
- * emitter.once("a", () => {
1811
- * });
1812
- *
1813
- * // Use Promise
1814
- * emitter.once("a").then(e => {
1815
- * });
1816
- */
1817
-
1818
-
1819
- __proto.once = function (eventName, listener) {
1820
- var _this = this;
1821
-
1822
- if (listener) {
1823
- this._addEvent(eventName, listener, {
1824
- once: true
1825
- });
1826
- }
1827
-
1828
- return new Promise(function (resolve) {
1829
- _this._addEvent(eventName, resolve, {
1830
- once: true
1831
- });
1832
- });
1833
- };
1834
- /**
1835
- * Fires an event to call listeners.
1836
- * @param - Event name
1837
- * @param - Event parameter
1838
- * @return If false, stop the event.
1839
- * @example
1840
- *
1841
- * import EventEmitter from "@scena/event-emitter";
1842
- *
1843
- *
1844
- * const emitter = new EventEmitter();
1845
- *
1846
- * emitter.on("a", e => {
1847
- * });
1848
- *
1849
- *
1850
- * emitter.emit("a", {
1851
- * a: 1,
1852
- * });
1853
- */
1854
-
1855
-
1856
- __proto.emit = function (eventName, param) {
1857
- var _this = this;
1858
-
1859
- if (param === void 0) {
1860
- param = {};
1861
- }
1862
-
1863
- var events = this._events[eventName];
1864
-
1865
- if (!eventName || !events) {
1866
- return true;
1867
- }
1868
-
1869
- var isStop = false;
1870
- param.eventType = eventName;
1871
-
1872
- param.stop = function () {
1873
- isStop = true;
1874
- };
1875
-
1876
- param.currentTarget = this;
1877
-
1878
- __spreadArrays(events).forEach(function (info) {
1879
- info.listener(param);
1880
-
1881
- if (info.once) {
1882
- _this.off(eventName, info.listener);
1883
- }
1884
- });
1885
-
1886
- return !isStop;
1887
- };
1888
- /**
1889
- * Fires an event to call listeners.
1890
- * @param - Event name
1891
- * @param - Event parameter
1892
- * @return If false, stop the event.
1893
- * @example
1894
- *
1895
- * import EventEmitter from "@scena/event-emitter";
1896
- *
1897
- *
1898
- * const emitter = new EventEmitter();
1899
- *
1900
- * emitter.on("a", e => {
1901
- * });
1902
- *
1903
- *
1904
- * emitter.emit("a", {
1905
- * a: 1,
1906
- * });
1907
- */
1908
-
1909
- /**
1910
- * Fires an event to call listeners.
1911
- * @param - Event name
1912
- * @param - Event parameter
1913
- * @return If false, stop the event.
1914
- * @example
1915
- *
1916
- * import EventEmitter from "@scena/event-emitter";
1917
- *
1918
- *
1919
- * const emitter = new EventEmitter();
1920
- *
1921
- * emitter.on("a", e => {
1922
- * });
1923
- *
1924
- * // emit
1925
- * emitter.trigger("a", {
1926
- * a: 1,
1927
- * });
1928
- */
1929
-
1930
-
1931
- __proto.trigger = function (eventName, param) {
1932
- if (param === void 0) {
1933
- param = {};
1934
- }
1935
-
1936
- return this.emit(eventName, param);
1937
- };
1938
-
1939
- __proto._addEvent = function (eventName, listener, options) {
1940
- var events = this._events;
1941
- events[eventName] = events[eventName] || [];
1942
- var listeners = events[eventName];
1943
- listeners.push(__assign$1({
1944
- listener: listener
1945
- }, options));
1946
- };
1947
-
1948
- return EventEmitter;
1949
- }();
1950
-
1951
- var EventEmitter$1 = EventEmitter;
1952
-
1953
- /*
1954
- Copyright (c) 2019 Daybrush
1955
- name: gesto
1956
- license: MIT
1957
- author: Daybrush
1958
- repository: git+https://github.com/daybrush/gesto.git
1959
- version: 1.7.0
1960
- */
1961
-
1962
- /*! *****************************************************************************
1963
- Copyright (c) Microsoft Corporation. All rights reserved.
1964
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
1965
- this file except in compliance with the License. You may obtain a copy of the
1966
- License at http://www.apache.org/licenses/LICENSE-2.0
1967
-
1968
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1969
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
1970
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
1971
- MERCHANTABLITY OR NON-INFRINGEMENT.
1972
-
1973
- See the Apache Version 2.0 License for specific language governing permissions
1974
- and limitations under the License.
1975
- ***************************************************************************** */
1976
-
1977
- /* global Reflect, Promise */
1978
- var extendStatics = function (d, b) {
1979
- extendStatics = Object.setPrototypeOf || {
1980
- __proto__: []
1981
- } instanceof Array && function (d, b) {
1982
- d.__proto__ = b;
1983
- } || function (d, b) {
1984
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
1985
- };
1986
-
1987
- return extendStatics(d, b);
1988
- };
1989
-
1990
- function __extends(d, b) {
1991
- extendStatics(d, b);
1992
-
1993
- function __() {
1994
- this.constructor = d;
1995
- }
1996
-
1997
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1998
- }
1999
- var __assign = function () {
2000
- __assign = Object.assign || function __assign(t) {
2001
- for (var s, i = 1, n = arguments.length; i < n; i++) {
2002
- s = arguments[i];
2003
-
2004
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
2005
- }
2006
-
2007
- return t;
2008
- };
2009
-
2010
- return __assign.apply(this, arguments);
2011
- };
2012
-
2013
- function getRad(pos1, pos2) {
2014
- var distX = pos2[0] - pos1[0];
2015
- var distY = pos2[1] - pos1[1];
2016
- var rad = Math.atan2(distY, distX);
2017
- return rad >= 0 ? rad : rad + Math.PI * 2;
2018
- }
2019
- function getRotatiion(touches) {
2020
- return getRad([touches[0].clientX, touches[0].clientY], [touches[1].clientX, touches[1].clientY]) / Math.PI * 180;
2021
- }
2022
- function isMultiTouch(e) {
2023
- return e.touches && e.touches.length >= 2;
2024
- }
2025
- function getEventClients(e) {
2026
- if (e.touches) {
2027
- return getClients(e.touches);
2028
- } else {
2029
- return [getClient(e)];
2030
- }
2031
- }
2032
- function getPosition(clients, prevClients, startClients) {
2033
- var length = startClients.length;
2034
-
2035
- var _a = getAverageClient(clients, length),
2036
- clientX = _a.clientX,
2037
- clientY = _a.clientY,
2038
- originalClientX = _a.originalClientX,
2039
- originalClientY = _a.originalClientY;
2040
-
2041
- var _b = getAverageClient(prevClients, length),
2042
- prevX = _b.clientX,
2043
- prevY = _b.clientY;
2044
-
2045
- var _c = getAverageClient(startClients, length),
2046
- startX = _c.clientX,
2047
- startY = _c.clientY;
2048
-
2049
- var deltaX = clientX - prevX;
2050
- var deltaY = clientY - prevY;
2051
- var distX = clientX - startX;
2052
- var distY = clientY - startY;
2053
- return {
2054
- clientX: originalClientX,
2055
- clientY: originalClientY,
2056
- deltaX: deltaX,
2057
- deltaY: deltaY,
2058
- distX: distX,
2059
- distY: distY
2060
- };
2061
- }
2062
- function getDist(clients) {
2063
- return Math.sqrt(Math.pow(clients[0].clientX - clients[1].clientX, 2) + Math.pow(clients[0].clientY - clients[1].clientY, 2));
2064
- }
2065
- function getClients(touches) {
2066
- var length = Math.min(touches.length, 2);
2067
- var clients = [];
2068
-
2069
- for (var i = 0; i < length; ++i) {
2070
- clients.push(getClient(touches[i]));
2071
- }
2072
-
2073
- return clients;
2074
- }
2075
- function getClient(e) {
2076
- return {
2077
- clientX: e.clientX,
2078
- clientY: e.clientY
2079
- };
2080
- }
2081
- function getAverageClient(clients, length) {
2082
- if (length === void 0) {
2083
- length = clients.length;
2084
- }
2085
-
2086
- var sumClient = {
2087
- clientX: 0,
2088
- clientY: 0,
2089
- originalClientX: 0,
2090
- originalClientY: 0
2091
- };
2092
-
2093
- for (var i = 0; i < length; ++i) {
2094
- var client = clients[i];
2095
- sumClient.originalClientX += "originalClientX" in client ? client.originalClientX : client.clientX;
2096
- sumClient.originalClientY += "originalClientY" in client ? client.originalClientY : client.clientY;
2097
- sumClient.clientX += client.clientX;
2098
- sumClient.clientY += client.clientY;
2099
- }
2100
-
2101
- if (!length) {
2102
- return sumClient;
2103
- }
2104
-
2105
- return {
2106
- clientX: sumClient.clientX / length,
2107
- clientY: sumClient.clientY / length,
2108
- originalClientX: sumClient.originalClientX / length,
2109
- originalClientY: sumClient.originalClientY / length
2110
- };
2111
- }
2112
-
2113
- var ClientStore =
2114
- /*#__PURE__*/
2115
- function () {
2116
- function ClientStore(clients) {
2117
- this.prevClients = [];
2118
- this.startClients = [];
2119
- this.movement = 0;
2120
- this.length = 0;
2121
- this.startClients = clients;
2122
- this.prevClients = clients;
2123
- this.length = clients.length;
2124
- }
2125
-
2126
- var __proto = ClientStore.prototype;
2127
-
2128
- __proto.getAngle = function (clients) {
2129
- if (clients === void 0) {
2130
- clients = this.prevClients;
2131
- }
2132
-
2133
- return getRotatiion(clients);
2134
- };
2135
-
2136
- __proto.getRotation = function (clients) {
2137
- if (clients === void 0) {
2138
- clients = this.prevClients;
2139
- }
2140
-
2141
- return getRotatiion(clients) - getRotatiion(this.startClients);
2142
- };
2143
-
2144
- __proto.getPosition = function (clients, isAdd) {
2145
- if (clients === void 0) {
2146
- clients = this.prevClients;
2147
- }
2148
-
2149
- var position = getPosition(clients || this.prevClients, this.prevClients, this.startClients);
2150
- var deltaX = position.deltaX,
2151
- deltaY = position.deltaY;
2152
- this.movement += Math.sqrt(deltaX * deltaX + deltaY * deltaY);
2153
- this.prevClients = clients;
2154
- return position;
2155
- };
2156
-
2157
- __proto.getPositions = function (clients) {
2158
- if (clients === void 0) {
2159
- clients = this.prevClients;
2160
- }
2161
-
2162
- var prevClients = this.prevClients;
2163
- return this.startClients.map(function (startClient, i) {
2164
- return getPosition([clients[i]], [prevClients[i]], [startClient]);
2165
- });
2166
- };
2167
-
2168
- __proto.getMovement = function (clients) {
2169
- var movement = this.movement;
2170
-
2171
- if (!clients) {
2172
- return movement;
2173
- }
2174
-
2175
- var currentClient = getAverageClient(clients, this.length);
2176
- var prevClient = getAverageClient(this.prevClients, this.length);
2177
- var deltaX = currentClient.clientX - prevClient.clientX;
2178
- var deltaY = currentClient.clientY - prevClient.clientY;
2179
- return Math.sqrt(deltaX * deltaX + deltaY * deltaY) + movement;
2180
- };
2181
-
2182
- __proto.getDistance = function (clients) {
2183
- if (clients === void 0) {
2184
- clients = this.prevClients;
2185
- }
2186
-
2187
- return getDist(clients);
2188
- };
2189
-
2190
- __proto.getScale = function (clients) {
2191
- if (clients === void 0) {
2192
- clients = this.prevClients;
2193
- }
2194
-
2195
- return getDist(clients) / getDist(this.startClients);
2196
- };
2197
-
2198
- __proto.move = function (deltaX, deltaY) {
2199
- this.startClients.forEach(function (client) {
2200
- client.clientX -= deltaX;
2201
- client.clientY -= deltaY;
2202
- });
2203
- };
2204
-
2205
- return ClientStore;
2206
- }();
2207
-
2208
- var INPUT_TAGNAMES = ["textarea", "input"];
2209
- /**
2210
- * You can set up drag, pinch events in any browser.
2211
- */
2212
-
2213
- var Gesto =
2214
- /*#__PURE__*/
2215
- function (_super) {
2216
- __extends(Gesto, _super);
2217
- /**
2218
- *
2219
- */
2220
-
2221
-
2222
- function Gesto(targets, options) {
2223
- if (options === void 0) {
2224
- options = {};
2225
- }
2226
-
2227
- var _this = _super.call(this) || this;
2228
-
2229
- _this.options = {};
2230
- _this.flag = false;
2231
- _this.pinchFlag = false;
2232
- _this.datas = {};
2233
- _this.isDrag = false;
2234
- _this.isPinch = false;
2235
- _this.isMouse = false;
2236
- _this.isTouch = false;
2237
- _this.clientStores = [];
2238
- _this.targets = [];
2239
- _this.prevTime = 0;
2240
- _this.doubleFlag = false;
2241
- _this._dragFlag = false;
2242
-
2243
- _this.onDragStart = function (e, isTrusted) {
2244
- if (isTrusted === void 0) {
2245
- isTrusted = true;
2246
- }
2247
-
2248
- if (!_this.flag && e.cancelable === false) {
2249
- return;
2250
- }
2251
-
2252
- var _a = _this.options,
2253
- container = _a.container,
2254
- pinchOutside = _a.pinchOutside,
2255
- preventRightClick = _a.preventRightClick,
2256
- preventDefault = _a.preventDefault,
2257
- checkInput = _a.checkInput;
2258
- var isTouch = _this.isTouch;
2259
- var isDragStart = !_this.flag;
2260
-
2261
- if (isDragStart) {
2262
- var activeElement = document.activeElement;
2263
- var target = e.target;
2264
- var tagName = target.tagName.toLowerCase();
2265
- var hasInput = INPUT_TAGNAMES.indexOf(tagName) > -1;
2266
- var hasContentEditable = target.isContentEditable;
2267
-
2268
- if (hasInput || hasContentEditable) {
2269
- if (checkInput || activeElement === target) {
2270
- // force false or already focused.
2271
- return false;
2272
- } // no focus
2273
-
2274
-
2275
- if (activeElement && hasContentEditable && activeElement.isContentEditable && activeElement.contains(target)) {
2276
- return false;
2277
- }
2278
- } else if ((preventDefault || e.type === "touchstart") && activeElement) {
2279
- var activeTagName = activeElement.tagName;
2280
-
2281
- if (activeElement.isContentEditable || INPUT_TAGNAMES.indexOf(activeTagName) > -1) {
2282
- activeElement.blur();
2283
- }
2284
- }
2285
-
2286
- _this.clientStores = [new ClientStore(getEventClients(e))];
2287
- _this.flag = true;
2288
- _this.isDrag = false;
2289
- _this._dragFlag = true;
2290
- _this.datas = {};
2291
-
2292
- if (preventRightClick && (e.which === 3 || e.button === 2)) {
2293
- _this.initDrag();
2294
-
2295
- return false;
2296
- }
2297
-
2298
- _this.doubleFlag = now() - _this.prevTime < 200;
2299
-
2300
- var result = _this.emit("dragStart", __assign({
2301
- datas: _this.datas,
2302
- inputEvent: e,
2303
- isTrusted: isTrusted,
2304
- isDouble: _this.doubleFlag
2305
- }, _this.getCurrentStore().getPosition(), {
2306
- preventDefault: function () {
2307
- e.preventDefault();
2308
- },
2309
- preventDrag: function () {
2310
- _this._dragFlag = false;
2311
- }
2312
- }));
2313
-
2314
- if (result === false) {
2315
- _this.initDrag();
2316
- }
2317
-
2318
- _this.flag && preventDefault && e.preventDefault();
2319
- }
2320
-
2321
- if (!_this.flag) {
2322
- return false;
2323
- }
2324
-
2325
- var timer = 0;
2326
-
2327
- if (isDragStart && isTouch && pinchOutside) {
2328
- timer = setTimeout(function () {
2329
- addEvent(container, "touchstart", _this.onDragStart, {
2330
- passive: false
2331
- });
2332
- });
2333
- }
2334
-
2335
- if (!isDragStart && isTouch && pinchOutside) {
2336
- removeEvent(container, "touchstart", _this.onDragStart);
2337
- }
2338
-
2339
- if (_this.flag && isMultiTouch(e)) {
2340
- clearTimeout(timer);
2341
-
2342
- if (isDragStart && e.touches.length !== e.changedTouches.length) {
2343
- return;
2344
- }
2345
-
2346
- if (!_this.pinchFlag) {
2347
- _this.onPinchStart(e);
2348
- }
2349
- }
2350
- };
2351
-
2352
- _this.onDrag = function (e, isScroll) {
2353
- if (!_this.flag) {
2354
- return;
2355
- }
2356
-
2357
- var clients = getEventClients(e);
2358
-
2359
- var result = _this.moveClients(clients, e, false);
2360
-
2361
- if (_this._dragFlag) {
2362
- if (_this.pinchFlag || result.deltaX || result.deltaY) {
2363
- var dragResult = _this.emit("drag", __assign({}, result, {
2364
- isScroll: !!isScroll,
2365
- inputEvent: e
2366
- }));
2367
-
2368
- if (dragResult === false) {
2369
- _this.stop();
2370
-
2371
- return;
2372
- }
2373
- }
2374
-
2375
- if (_this.pinchFlag) {
2376
- _this.onPinch(e, clients);
2377
- }
2378
- }
2379
-
2380
- _this.getCurrentStore().getPosition(clients, true);
2381
- };
2382
-
2383
- _this.onDragEnd = function (e) {
2384
- if (!_this.flag) {
2385
- return;
2386
- }
2387
-
2388
- var _a = _this.options,
2389
- pinchOutside = _a.pinchOutside,
2390
- container = _a.container;
2391
-
2392
- if (_this.isTouch && pinchOutside) {
2393
- removeEvent(container, "touchstart", _this.onDragStart);
2394
- }
2395
-
2396
- _this.flag = false;
2397
-
2398
- var position = _this._getPosition();
2399
-
2400
- var currentTime = now();
2401
- var isDouble = !_this.isDrag && _this.doubleFlag;
2402
- _this.prevTime = _this.isDrag || isDouble ? 0 : currentTime;
2403
-
2404
- _this.emit("dragEnd", __assign({
2405
- datas: _this.datas,
2406
- isDouble: isDouble,
2407
- isDrag: _this.isDrag,
2408
- isClick: !_this.isDrag,
2409
- inputEvent: e
2410
- }, position));
2411
-
2412
- if (_this.pinchFlag) {
2413
- _this.onPinchEnd(e);
2414
- }
2415
-
2416
- _this.clientStores = [];
2417
- };
1545
+ ]
1546
+ }
1547
+ ];
1548
+ const DEFAULT_CONFIG = fillConfig([]);
1549
+ const getDefaultPropsValue = (type, id) => ["page", "container"].includes(type) ? {
1550
+ type,
1551
+ id,
1552
+ style: {},
1553
+ name: type,
1554
+ items: []
1555
+ } : {
1556
+ type,
1557
+ id,
1558
+ style: {},
1559
+ name: type
1560
+ };
2418
1561
 
2419
- _this.onBlur = function () {
2420
- _this.onDragEnd();
1562
+ const _sfc_main$i = defineComponent({
1563
+ components: { Plus },
1564
+ setup() {
1565
+ const services = inject("services");
1566
+ return {
1567
+ clickHandler() {
1568
+ const { editorService } = services || {};
1569
+ if (!editorService)
1570
+ return;
1571
+ editorService.add({
1572
+ type: NodeType.PAGE,
1573
+ name: generatePageNameByApp(toRaw(editorService.get("root")))
1574
+ });
1575
+ }
2421
1576
  };
2422
-
2423
- var elements = [].concat(targets);
2424
- _this.options = __assign({
2425
- checkInput: false,
2426
- container: elements.length > 1 ? window : elements[0],
2427
- preventRightClick: true,
2428
- preventDefault: true,
2429
- checkWindowBlur: false,
2430
- pinchThreshold: 0,
2431
- events: ["touch", "mouse"]
2432
- }, options);
2433
- var _a = _this.options,
2434
- container = _a.container,
2435
- events = _a.events,
2436
- checkWindowBlur = _a.checkWindowBlur;
2437
- _this.isTouch = events.indexOf("touch") > -1;
2438
- _this.isMouse = events.indexOf("mouse") > -1;
2439
- _this.targets = elements;
2440
-
2441
- if (_this.isMouse) {
2442
- elements.forEach(function (el) {
2443
- addEvent(el, "mousedown", _this.onDragStart);
2444
- });
2445
- addEvent(container, "mousemove", _this.onDrag);
2446
- addEvent(container, "mouseup", _this.onDragEnd);
2447
- addEvent(container, "contextmenu", _this.onDragEnd);
2448
- }
2449
-
2450
- if (checkWindowBlur) {
2451
- addEvent(window, "blur", _this.onBlur);
2452
- }
2453
-
2454
- if (_this.isTouch) {
2455
- var passive_1 = {
2456
- passive: false
2457
- };
2458
- elements.forEach(function (el) {
2459
- addEvent(el, "touchstart", _this.onDragStart, passive_1);
2460
- });
2461
- addEvent(container, "touchmove", _this.onDrag, passive_1);
2462
- addEvent(container, "touchend", _this.onDragEnd, passive_1);
2463
- addEvent(container, "touchcancel", _this.onDragEnd, passive_1);
2464
- }
2465
-
2466
- return _this;
2467
1577
  }
2468
- /**
2469
- * Stop Gesto's drag events.
2470
- */
2471
-
2472
-
2473
- var __proto = Gesto.prototype;
2474
-
2475
- __proto.stop = function () {
2476
- this.isDrag = false;
2477
- this.flag = false;
2478
- this.clientStores = [];
2479
- this.datas = {};
2480
- };
2481
- /**
2482
- * The total moved distance
2483
- */
2484
-
2485
-
2486
- __proto.getMovement = function (clients) {
2487
- return this.getCurrentStore().getMovement(clients) + this.clientStores.slice(1).reduce(function (prev, cur) {
2488
- return prev + cur.movement;
2489
- }, 0);
2490
- };
2491
- /**
2492
- * Whether to drag
2493
- */
2494
-
2495
-
2496
- __proto.isDragging = function () {
2497
- return this.isDrag;
2498
- };
2499
- /**
2500
- * Whether to start drag
2501
- */
2502
-
2503
-
2504
- __proto.isFlag = function () {
2505
- return this.flag;
2506
- };
2507
- /**
2508
- * Whether to start pinch
2509
- */
2510
-
2511
-
2512
- __proto.isPinchFlag = function () {
2513
- return this.pinchFlag;
2514
- };
2515
- /**
2516
- * Whether to start double click
2517
- */
2518
-
2519
-
2520
- __proto.isDoubleFlag = function () {
2521
- return this.doubleFlag;
2522
- };
2523
- /**
2524
- * Whether to pinch
2525
- */
2526
-
2527
-
2528
- __proto.isPinching = function () {
2529
- return this.isPinch;
2530
- };
2531
- /**
2532
- * If a scroll event occurs, it is corrected by the scroll distance.
2533
- */
2534
-
2535
-
2536
- __proto.scrollBy = function (deltaX, deltaY, e, isCallDrag) {
2537
- if (isCallDrag === void 0) {
2538
- isCallDrag = true;
2539
- }
2540
-
2541
- if (!this.flag) {
2542
- return;
2543
- }
2544
-
2545
- this.clientStores[0].move(deltaX, deltaY);
2546
- isCallDrag && this.onDrag(e, true);
2547
- };
2548
- /**
2549
- * Create a virtual drag event.
2550
- */
2551
-
2552
-
2553
- __proto.move = function (_a, inputEvent) {
2554
- var deltaX = _a[0],
2555
- deltaY = _a[1];
2556
- var store = this.getCurrentStore();
2557
- var nextClients = store.prevClients;
2558
- return this.moveClients(nextClients.map(function (_a) {
2559
- var clientX = _a.clientX,
2560
- clientY = _a.clientY;
2561
- return {
2562
- clientX: clientX + deltaX,
2563
- clientY: clientY + deltaY,
2564
- originalClientX: clientX,
2565
- originalClientY: clientY
2566
- };
2567
- }), inputEvent, true);
2568
- };
2569
- /**
2570
- * The dragStart event is triggered by an external event.
2571
- */
2572
-
2573
-
2574
- __proto.triggerDragStart = function (e) {
2575
- this.onDragStart(e, false);
2576
- };
2577
- /**
2578
- * Set the event data while dragging.
2579
- */
2580
-
2581
-
2582
- __proto.setEventDatas = function (datas) {
2583
- var currentDatas = this.datas;
2584
-
2585
- for (var name in datas) {
2586
- currentDatas[name] = datas[name];
2587
- }
2588
-
2589
- return this;
2590
- };
2591
- /**
2592
- * Get the current event state while dragging.
2593
- */
2594
-
2595
-
2596
- __proto.getCurrentEvent = function (inputEvent) {
2597
- return __assign({
2598
- datas: this.datas
2599
- }, this._getPosition(), {
2600
- movement: this.getMovement(),
2601
- isDrag: this.isDrag,
2602
- isPinch: this.isPinch,
2603
- isScroll: false,
2604
- inputEvent: inputEvent
2605
- });
2606
- };
2607
- /**
2608
- * Get & Set the event data while dragging.
2609
- */
2610
-
2611
-
2612
- __proto.getEventDatas = function () {
2613
- return this.datas;
2614
- };
2615
- /**
2616
- * Unset Gesto
2617
- */
2618
-
2619
-
2620
- __proto.unset = function () {
2621
- var _this = this;
2622
-
2623
- var targets = this.targets;
2624
- var container = this.options.container;
2625
- this.off();
2626
- removeEvent(window, "blur", this.onBlur);
2627
-
2628
- if (this.isMouse) {
2629
- targets.forEach(function (target) {
2630
- removeEvent(target, "mousedown", _this.onDragStart);
2631
- });
2632
- removeEvent(container, "mousemove", this.onDrag);
2633
- removeEvent(container, "mouseup", this.onDragEnd);
2634
- removeEvent(container, "contextmenu", this.onDragEnd);
2635
- }
2636
-
2637
- if (this.isTouch) {
2638
- targets.forEach(function (target) {
2639
- removeEvent(target, "touchstart", _this.onDragStart);
2640
- });
2641
- removeEvent(container, "touchstart", this.onDragStart);
2642
- removeEvent(container, "touchmove", this.onDrag);
2643
- removeEvent(container, "touchend", this.onDragEnd);
2644
- removeEvent(container, "touchcancel", this.onDragEnd);
2645
- }
2646
- };
2647
-
2648
- __proto.onPinchStart = function (e) {
2649
- var pinchThreshold = this.options.pinchThreshold;
2650
-
2651
- if (this.isDrag && this.getMovement() > pinchThreshold) {
2652
- return;
2653
- }
2654
-
2655
- var store = new ClientStore(getEventClients(e));
2656
- this.pinchFlag = true;
2657
- this.clientStores.splice(0, 0, store);
2658
- var result = this.emit("pinchStart", __assign({
2659
- datas: this.datas,
2660
- angle: store.getAngle(),
2661
- touches: this.getCurrentStore().getPositions()
2662
- }, store.getPosition(), {
2663
- inputEvent: e
2664
- }));
2665
-
2666
- if (result === false) {
2667
- this.pinchFlag = false;
2668
- }
2669
- };
2670
-
2671
- __proto.onPinch = function (e, clients) {
2672
- if (!this.flag || !this.pinchFlag || clients.length < 2) {
2673
- return;
2674
- }
2675
-
2676
- var store = this.getCurrentStore();
2677
- this.isPinch = true;
2678
- this.emit("pinch", __assign({
2679
- datas: this.datas,
2680
- movement: this.getMovement(clients),
2681
- angle: store.getAngle(clients),
2682
- rotation: store.getRotation(clients),
2683
- touches: store.getPositions(clients),
2684
- scale: store.getScale(clients),
2685
- distance: store.getDistance(clients)
2686
- }, store.getPosition(clients), {
2687
- inputEvent: e
2688
- }));
2689
- };
2690
-
2691
- __proto.onPinchEnd = function (e) {
2692
- if (!this.pinchFlag) {
2693
- return;
2694
- }
2695
-
2696
- var isPinch = this.isPinch;
2697
- this.isPinch = false;
2698
- this.pinchFlag = false;
2699
- var store = this.getCurrentStore();
2700
- this.emit("pinchEnd", __assign({
2701
- datas: this.datas,
2702
- isPinch: isPinch,
2703
- touches: store.getPositions()
2704
- }, store.getPosition(), {
2705
- inputEvent: e
2706
- }));
2707
- this.isPinch = false;
2708
- this.pinchFlag = false;
2709
- };
2710
-
2711
- __proto.initDrag = function () {
2712
- this.clientStores = [];
2713
- this.pinchFlag = false;
2714
- this.doubleFlag = false;
2715
- this.prevTime = 0;
2716
- this.flag = false;
2717
- };
2718
-
2719
- __proto.getCurrentStore = function () {
2720
- return this.clientStores[0];
2721
- };
2722
-
2723
- __proto.moveClients = function (clients, inputEvent, isAdd) {
2724
- var position = this._getPosition(clients, isAdd);
2725
-
2726
- if (position.deltaX || position.deltaY) {
2727
- this.isDrag = true;
2728
- }
2729
-
2730
- return __assign({
2731
- datas: this.datas
2732
- }, position, {
2733
- movement: this.getMovement(clients),
2734
- isDrag: this.isDrag,
2735
- isPinch: this.isPinch,
2736
- isScroll: false,
2737
- inputEvent: inputEvent
2738
- });
2739
- };
2740
-
2741
- __proto._getPosition = function (clients, isAdd) {
2742
- var store = this.getCurrentStore();
2743
- var position = store.getPosition(clients, isAdd);
2744
-
2745
- var _a = this.clientStores.slice(1).reduce(function (prev, cur) {
2746
- var storePosition = cur.getPosition();
2747
- prev.distX += storePosition.distX;
2748
- prev.distY += storePosition.distY;
2749
- return prev;
2750
- }, position),
2751
- distX = _a.distX,
2752
- distY = _a.distY;
2753
-
2754
- return __assign({}, position, {
2755
- distX: distX,
2756
- distY: distY
2757
- });
2758
- };
2759
-
2760
- return Gesto;
2761
- }(EventEmitter$1);
2762
-
2763
- var Gesto$1 = Gesto;
1578
+ });
1579
+ const _hoisted_1$a = { class: "m-editor-empty-panel" };
1580
+ const _hoisted_2$4 = { class: "m-editor-empty-content" };
1581
+ const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1582
+ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
1583
+ const _component_plus = resolveComponent("plus");
1584
+ const _component_el_icon = resolveComponent("el-icon");
1585
+ return openBlock(), createElementBlock("div", _hoisted_1$a, [
1586
+ createElementVNode("div", _hoisted_2$4, [
1587
+ createElementVNode("div", {
1588
+ class: "m-editor-empty-button",
1589
+ onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
1590
+ }, [
1591
+ createElementVNode("div", null, [
1592
+ createVNode(_component_el_icon, null, {
1593
+ default: withCtx(() => [
1594
+ createVNode(_component_plus)
1595
+ ]),
1596
+ _: 1
1597
+ })
1598
+ ]),
1599
+ _hoisted_3$2
1600
+ ])
1601
+ ])
1602
+ ]);
1603
+ }
1604
+ var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
2764
1605
 
2765
1606
  const _sfc_main$h = defineComponent({
2766
1607
  name: "m-editor-resize",
@@ -2776,7 +1617,7 @@ const _sfc_main$h = defineComponent({
2776
1617
  onMounted(() => {
2777
1618
  if (!target.value)
2778
1619
  return;
2779
- getso = new Gesto$1(target.value, {
1620
+ getso = new Gesto(target.value, {
2780
1621
  container: window,
2781
1622
  pinchOutside: true
2782
1623
  }).on("drag", (e) => {
@@ -2820,6 +1661,12 @@ const _sfc_main$g = defineComponent({
2820
1661
  AddPageBox,
2821
1662
  Resizer
2822
1663
  },
1664
+ props: {
1665
+ codeOptions: {
1666
+ type: Object,
1667
+ default: () => ({})
1668
+ }
1669
+ },
2823
1670
  setup() {
2824
1671
  const { editorService, uiService } = inject("services") || {};
2825
1672
  const root = computed(() => editorService?.get("root"));
@@ -2854,8 +1701,9 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
2854
1701
  key: 0,
2855
1702
  class: "m-editor-content",
2856
1703
  "init-values": _ctx.root,
1704
+ options: _ctx.codeOptions,
2857
1705
  onSave: _ctx.saveCode
2858
- }, null, 8, ["init-values", "onSave"])) : (openBlock(), createElementBlock("div", _hoisted_2$3, [
1706
+ }, null, 8, ["init-values", "options", "onSave"])) : (openBlock(), createElementBlock("div", _hoisted_2$3, [
2859
1707
  createElementVNode("div", {
2860
1708
  class: "m-editor-framework-left",
2861
1709
  style: normalizeStyle(`width: ${_ctx.columnWidth?.left}px`)
@@ -3303,13 +2151,13 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
3303
2151
  const _component_m_form = resolveComponent("m-form");
3304
2152
  return openBlock(), createBlock(_component_m_form, {
3305
2153
  class: normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
3306
- "popper-class": "m-editor-props-panel-popper",
2154
+ "popper-class": `m-editor-props-panel-popper ${_ctx.propsPanelSize}`,
3307
2155
  ref: "configForm",
3308
2156
  size: _ctx.propsPanelSize,
3309
2157
  "init-values": _ctx.values,
3310
2158
  config: _ctx.curFormConfig,
3311
2159
  onChange: _ctx.submit
3312
- }, null, 8, ["class", "size", "init-values", "config", "onChange"]);
2160
+ }, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"]);
3313
2161
  }
3314
2162
  var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
3315
2163
 
@@ -3427,9 +2275,14 @@ const _sfc_main$a = defineComponent({
3427
2275
  menuData: {
3428
2276
  type: Array,
3429
2277
  default: () => []
2278
+ },
2279
+ isSubMenu: {
2280
+ type: Boolean,
2281
+ default: false
3430
2282
  }
3431
2283
  },
3432
- setup() {
2284
+ emits: ["hide", "show"],
2285
+ setup(props, { emit }) {
3433
2286
  const menu = ref();
3434
2287
  const subMenu = ref();
3435
2288
  const visible = ref(false);
@@ -3439,15 +2292,31 @@ const _sfc_main$a = defineComponent({
3439
2292
  top: "0"
3440
2293
  });
3441
2294
  const hide = () => {
2295
+ if (!visible.value)
2296
+ return;
3442
2297
  visible.value = false;
2298
+ subMenu.value?.hide();
2299
+ emit("hide");
2300
+ };
2301
+ const hideHandler = (e) => {
2302
+ const target = e.target;
2303
+ if (!visible.value || !target) {
2304
+ return;
2305
+ }
2306
+ if (menu.value?.contains(target) || subMenu.value?.$el?.contains(target)) {
2307
+ return;
2308
+ }
2309
+ hide();
3443
2310
  };
3444
2311
  onMounted(() => {
3445
- globalThis.addEventListener("mousedown", (e) => {
3446
- if (!visible.value || e.target && menu.value?.contains(e.target)) {
3447
- return;
3448
- }
3449
- hide();
3450
- }, true);
2312
+ if (props.isSubMenu)
2313
+ return;
2314
+ globalThis.addEventListener("mousedown", hideHandler, true);
2315
+ });
2316
+ onUnmounted(() => {
2317
+ if (props.isSubMenu)
2318
+ return;
2319
+ globalThis.removeEventListener("mousedown", hideHandler, true);
3451
2320
  });
3452
2321
  return {
3453
2322
  menu,
@@ -3457,18 +2326,21 @@ const _sfc_main$a = defineComponent({
3457
2326
  subMenuData,
3458
2327
  hide,
3459
2328
  show(e) {
3460
- visible.value = true;
3461
- nextTick(() => {
3462
- const menuHeight = menu.value?.clientHeight || 0;
3463
- let top = e.clientY;
3464
- if (menuHeight + e.clientY > document.body.clientHeight) {
3465
- top = document.body.clientHeight - menuHeight;
3466
- }
3467
- menuStyle.value = {
3468
- top: `${top}px`,
3469
- left: `${e.clientX}px`
3470
- };
3471
- });
2329
+ setTimeout(() => {
2330
+ visible.value = true;
2331
+ nextTick(() => {
2332
+ const menuHeight = menu.value?.clientHeight || 0;
2333
+ let top = e.clientY;
2334
+ if (menuHeight + e.clientY > document.body.clientHeight) {
2335
+ top = document.body.clientHeight - menuHeight;
2336
+ }
2337
+ menuStyle.value = {
2338
+ top: `${top}px`,
2339
+ left: `${e.clientX}px`
2340
+ };
2341
+ emit("show");
2342
+ });
2343
+ }, 300);
3472
2344
  },
3473
2345
  showSubMenu(item) {
3474
2346
  const menuItem = item;
@@ -3489,7 +2361,7 @@ const _sfc_main$a = defineComponent({
3489
2361
  function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
3490
2362
  const _component_tool_button = resolveComponent("tool-button");
3491
2363
  const _component_content_menu = resolveComponent("content-menu", true);
3492
- return _ctx.menuData.length ? withDirectives((openBlock(), createElementBlock("div", {
2364
+ return _ctx.menuData.length && _ctx.visible ? (openBlock(), createElementBlock("div", {
3493
2365
  key: 0,
3494
2366
  class: "magic-editor-content-menu",
3495
2367
  ref: "menu",
@@ -3510,12 +2382,12 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
3510
2382
  createVNode(_component_content_menu, {
3511
2383
  class: "sub-menu",
3512
2384
  ref: "subMenu",
3513
- "menu-data": _ctx.subMenuData
3514
- }, null, 8, ["menu-data"])
2385
+ "menu-data": _ctx.subMenuData,
2386
+ "is-sub-menu": true,
2387
+ onHide: _ctx.hide
2388
+ }, null, 8, ["menu-data", "onHide"])
3515
2389
  ]))
3516
- ], 4)), [
3517
- [vShow, _ctx.visible]
3518
- ]) : createCommentVNode("", true);
2390
+ ], 4)) : createCommentVNode("", true);
3519
2391
  }
3520
2392
  var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
3521
2393
 
@@ -3528,6 +2400,7 @@ const _sfc_main$9 = defineComponent({
3528
2400
  const isRoot = computed(() => node.value?.type === NodeType.ROOT);
3529
2401
  const isPage = computed(() => node.value?.type === NodeType.PAGE);
3530
2402
  const componentList = computed(() => services?.componentListService.getList() || []);
2403
+ const layerContentMenu = inject("layerContentMenu", []);
3531
2404
  const createMenuItems = (group) => group.items.map((component) => ({
3532
2405
  text: component.text,
3533
2406
  type: "button",
@@ -3592,7 +2465,8 @@ const _sfc_main$9 = defineComponent({
3592
2465
  handler: () => {
3593
2466
  node.value && services?.editorService.remove(node.value);
3594
2467
  }
3595
- }
2468
+ },
2469
+ ...layerContentMenu
3596
2470
  ]),
3597
2471
  show(e) {
3598
2472
  menu.value?.show(e);
@@ -3815,7 +2689,7 @@ const _sfc_main$7 = defineComponent({
3815
2689
  components: { MIcon },
3816
2690
  props: {
3817
2691
  data: {
3818
- type: Object
2692
+ type: [Object, String]
3819
2693
  }
3820
2694
  },
3821
2695
  setup(props) {
@@ -4383,6 +3257,7 @@ const _sfc_main$3 = defineComponent({
4383
3257
  const node = computed(() => editorService?.get("node"));
4384
3258
  const parent = computed(() => editorService?.get("parent"));
4385
3259
  const isPage = computed(() => node.value?.type === NodeType.PAGE);
3260
+ const stageContentMenu = inject("stageContentMenu", []);
4386
3261
  onMounted(() => {
4387
3262
  const data = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
4388
3263
  canPaste.value = data !== "undefined" && !!data;
@@ -4418,8 +3293,17 @@ const _sfc_main$3 = defineComponent({
4418
3293
  text: "\u7C98\u8D34",
4419
3294
  display: () => canPaste.value,
4420
3295
  handler: () => {
4421
- const top = menu.value?.$el.offsetTop || 0;
4422
- const left = menu.value?.$el.offsetLeft || 0;
3296
+ const stage = editorService?.get("stage");
3297
+ const rect = menu.value?.$el.getBoundingClientRect();
3298
+ const parentRect = stage?.container?.getBoundingClientRect();
3299
+ let left = (rect?.left || 0) - (parentRect?.left || 0);
3300
+ let top = (rect?.top || 0) - (parentRect?.top || 0);
3301
+ if (node.value?.items && stage) {
3302
+ const parentEl = stage.renderer.contentWindow?.document.getElementById(`${node.value.id}`);
3303
+ const parentElRect = parentEl?.getBoundingClientRect();
3304
+ left = left - (parentElRect?.left || 0);
3305
+ top = top - (parentElRect?.top || 0);
3306
+ }
4423
3307
  editorService?.paste({ left, top });
4424
3308
  }
4425
3309
  },
@@ -4486,7 +3370,8 @@ const _sfc_main$3 = defineComponent({
4486
3370
  handler: () => {
4487
3371
  editorService?.get("stage").clearGuides();
4488
3372
  }
4489
- }
3373
+ },
3374
+ ...stageContentMenu
4490
3375
  ]),
4491
3376
  show(e) {
4492
3377
  menu.value?.show(e);
@@ -4509,24 +3394,9 @@ const _sfc_main$2 = defineComponent({
4509
3394
  ViewerMenu,
4510
3395
  ScrollViewer
4511
3396
  },
4512
- props: {
4513
- render: {
4514
- type: Function
4515
- },
4516
- runtimeUrl: String,
4517
- canSelect: {
4518
- type: Function,
4519
- default: (el) => Boolean(el.id)
4520
- },
4521
- moveableOptions: {
4522
- type: [Object, Function],
4523
- default: () => (core) => ({
4524
- container: core?.renderer?.contentWindow?.document.getElementById("app")
4525
- })
4526
- }
4527
- },
4528
- setup(props) {
3397
+ setup() {
4529
3398
  const services = inject("services");
3399
+ const stageOptions = inject("stageOptions");
4530
3400
  const stageWrap = ref();
4531
3401
  const stageContainer = ref();
4532
3402
  const menu = ref();
@@ -4543,21 +3413,23 @@ const _sfc_main$2 = defineComponent({
4543
3413
  return;
4544
3414
  if (!stageContainer.value)
4545
3415
  return;
4546
- if (!(props.runtimeUrl || props.render) || !root.value)
3416
+ if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
4547
3417
  return;
4548
3418
  stage = new StageCore({
4549
- render: props.render,
4550
- runtimeUrl: props.runtimeUrl,
3419
+ render: stageOptions.render,
3420
+ runtimeUrl: stageOptions.runtimeUrl,
4551
3421
  zoom: zoom.value,
3422
+ autoScrollIntoView: stageOptions.autoScrollIntoView,
4552
3423
  canSelect: (el, event, stop) => {
4553
- const elCanSelect = props.canSelect(el);
3424
+ const elCanSelect = stageOptions.canSelect(el);
4554
3425
  if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
4555
3426
  document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
4556
3427
  return stop();
4557
3428
  }
4558
3429
  return elCanSelect;
4559
3430
  },
4560
- moveableOptions: props.moveableOptions
3431
+ moveableOptions: stageOptions.moveableOptions,
3432
+ updateDragEl: stageOptions.updateDragEl
4561
3433
  });
4562
3434
  services?.editorService.set("stage", markRaw(stage));
4563
3435
  stage?.mount(stageContainer.value);
@@ -4638,6 +3510,7 @@ const _sfc_main$2 = defineComponent({
4638
3510
  const { scrollTop, scrollLeft } = stage.mask;
4639
3511
  if (layout === Layout.ABSOLUTE) {
4640
3512
  config.style = {
3513
+ ...config.style || {},
4641
3514
  position: "absolute",
4642
3515
  top: e.clientY - containerRect.top + scrollTop,
4643
3516
  left: e.clientX - containerRect.left + scrollLeft
@@ -4683,18 +3556,6 @@ const _sfc_main$1 = defineComponent({
4683
3556
  PageBar,
4684
3557
  MagicStage
4685
3558
  },
4686
- props: {
4687
- runtimeUrl: String,
4688
- render: {
4689
- type: Function
4690
- },
4691
- moveableOptions: {
4692
- type: [Object, Function]
4693
- },
4694
- canSelect: {
4695
- type: Function
4696
- }
4697
- },
4698
3559
  setup() {
4699
3560
  const services = inject("services");
4700
3561
  const workspace = ref();
@@ -4703,8 +3564,12 @@ const _sfc_main$1 = defineComponent({
4703
3564
  const mouseenterHandler = () => {
4704
3565
  workspace.value?.focus();
4705
3566
  };
3567
+ const mouseleaveHandler = () => {
3568
+ workspace.value?.blur();
3569
+ };
4706
3570
  onMounted(() => {
4707
3571
  workspace.value?.addEventListener("mouseenter", mouseenterHandler);
3572
+ workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
4708
3573
  keycon = new KeyController(workspace.value);
4709
3574
  const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
4710
3575
  const ctrl = isMac ? "meta" : "ctrl";
@@ -4713,6 +3578,11 @@ const _sfc_main$1 = defineComponent({
4713
3578
  if (!node.value || isPage(node.value))
4714
3579
  return;
4715
3580
  services?.editorService.remove(node.value);
3581
+ }).keyup("backspace", (e) => {
3582
+ e.inputEvent.preventDefault();
3583
+ if (!node.value || isPage(node.value))
3584
+ return;
3585
+ services?.editorService.remove(node.value);
4716
3586
  }).keydown([ctrl, "c"], (e) => {
4717
3587
  e.inputEvent.preventDefault();
4718
3588
  node.value && services?.editorService.copy(node.value);
@@ -4764,13 +3634,20 @@ const _sfc_main$1 = defineComponent({
4764
3634
  }).keydown([ctrl, "="], (e) => {
4765
3635
  e.inputEvent.preventDefault();
4766
3636
  services?.uiService.zoom(0.1);
3637
+ }).keydown([ctrl, "numpadplus"], (e) => {
3638
+ e.inputEvent.preventDefault();
3639
+ services?.uiService.zoom(0.1);
4767
3640
  }).keydown([ctrl, "-"], (e) => {
4768
3641
  e.inputEvent.preventDefault();
4769
3642
  services?.uiService.zoom(-0.1);
3643
+ }).keydown([ctrl, "numpad-"], (e) => {
3644
+ e.inputEvent.preventDefault();
3645
+ services?.uiService.zoom(-0.1);
4770
3646
  });
4771
3647
  });
4772
3648
  onUnmounted(() => {
4773
3649
  workspace.value?.removeEventListener("mouseenter", mouseenterHandler);
3650
+ workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
4774
3651
  keycon.destroy();
4775
3652
  });
4776
3653
  return {
@@ -4789,12 +3666,8 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
4789
3666
  const _component_page_bar = resolveComponent("page-bar");
4790
3667
  return openBlock(), createElementBlock("div", _hoisted_1, [
4791
3668
  (openBlock(), createBlock(_component_magic_stage, {
4792
- key: _ctx.page?.id,
4793
- "runtime-url": _ctx.runtimeUrl,
4794
- render: _ctx.render,
4795
- "moveable-options": _ctx.moveableOptions,
4796
- "can-select": _ctx.canSelect
4797
- }, null, 8, ["runtime-url", "render", "moveable-options", "can-select"])),
3669
+ key: _ctx.page?.id
3670
+ })),
4798
3671
  renderSlot(_ctx.$slots, "workspace-content"),
4799
3672
  createVNode(_component_page_bar, null, {
4800
3673
  "page-bar-title": withCtx(({ page }) => [
@@ -4963,6 +3836,14 @@ const _sfc_main = defineComponent({
4963
3836
  sidebar: {
4964
3837
  type: Object
4965
3838
  },
3839
+ layerContentMenu: {
3840
+ type: Array,
3841
+ default: () => []
3842
+ },
3843
+ stageContentMenu: {
3844
+ type: Array,
3845
+ default: () => []
3846
+ },
4966
3847
  menu: {
4967
3848
  type: Object,
4968
3849
  default: () => ({ left: [], right: [] })
@@ -4971,6 +3852,7 @@ const _sfc_main = defineComponent({
4971
3852
  type: Function
4972
3853
  },
4973
3854
  runtimeUrl: String,
3855
+ autoScrollIntoView: Boolean,
4974
3856
  propsConfigs: {
4975
3857
  type: Object,
4976
3858
  default: () => ({})
@@ -4984,16 +3866,27 @@ const _sfc_main = defineComponent({
4984
3866
  default: () => ({})
4985
3867
  },
4986
3868
  moveableOptions: {
4987
- type: [Object, Function]
3869
+ type: [Object, Function],
3870
+ default: () => (core) => ({
3871
+ container: core?.renderer?.contentWindow?.document.getElementById("app")
3872
+ })
4988
3873
  },
4989
3874
  defaultSelected: {
4990
3875
  type: [Number, String]
4991
3876
  },
4992
3877
  canSelect: {
4993
- type: Function
3878
+ type: Function,
3879
+ default: (el) => Boolean(el.id)
4994
3880
  },
4995
3881
  stageRect: {
4996
3882
  type: [String, Object]
3883
+ },
3884
+ codeOptions: {
3885
+ type: Object,
3886
+ default: () => ({})
3887
+ },
3888
+ updateDragEl: {
3889
+ type: Function
4997
3890
  }
4998
3891
  },
4999
3892
  emits: ["props-panel-mounted", "update:modelValue"],
@@ -5043,6 +3936,16 @@ const _sfc_main = defineComponent({
5043
3936
  uiService
5044
3937
  };
5045
3938
  provide("services", services);
3939
+ provide("layerContentMenu", props.layerContentMenu);
3940
+ provide("stageContentMenu", props.stageContentMenu);
3941
+ provide("stageOptions", reactive({
3942
+ runtimeUrl: props.runtimeUrl,
3943
+ autoScrollIntoView: props.autoScrollIntoView,
3944
+ render: props.render,
3945
+ moveableOptions: props.moveableOptions,
3946
+ canSelect: props.canSelect,
3947
+ updateDragEl: props.updateDragEl
3948
+ }));
5046
3949
  return services;
5047
3950
  }
5048
3951
  });
@@ -5052,7 +3955,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
5052
3955
  const _component_workspace = resolveComponent("workspace");
5053
3956
  const _component_props_panel = resolveComponent("props-panel");
5054
3957
  const _component_framework = resolveComponent("framework");
5055
- return openBlock(), createBlock(_component_framework, null, {
3958
+ return openBlock(), createBlock(_component_framework, { "code-options": _ctx.codeOptions }, {
5056
3959
  nav: withCtx(() => [
5057
3960
  renderSlot(_ctx.$slots, "nav", { editorService: _ctx.editorService }, () => [
5058
3961
  createVNode(_component_nav_menu, { data: _ctx.menu }, null, 8, ["data"])
@@ -5065,12 +3968,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
5065
3968
  ]),
5066
3969
  workspace: withCtx(() => [
5067
3970
  renderSlot(_ctx.$slots, "workspace", {}, () => [
5068
- createVNode(_component_workspace, {
5069
- "runtime-url": _ctx.runtimeUrl,
5070
- render: _ctx.render,
5071
- "moveable-options": _ctx.moveableOptions,
5072
- "can-select": _ctx.canSelect
5073
- }, {
3971
+ createVNode(_component_workspace, null, {
5074
3972
  "workspace-content": withCtx(() => [
5075
3973
  renderSlot(_ctx.$slots, "workspace-content", { editorService: _ctx.editorService })
5076
3974
  ]),
@@ -5081,7 +3979,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
5081
3979
  renderSlot(_ctx.$slots, "page-bar-popover", { page })
5082
3980
  ]),
5083
3981
  _: 3
5084
- }, 8, ["runtime-url", "render", "moveable-options", "can-select"])
3982
+ })
5085
3983
  ])
5086
3984
  ]),
5087
3985
  propsPanel: withCtx(() => [
@@ -5096,11 +3994,11 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
5096
3994
  renderSlot(_ctx.$slots, "empty", { editorService: _ctx.editorService })
5097
3995
  ]),
5098
3996
  _: 3
5099
- });
3997
+ }, 8, ["code-options"]);
5100
3998
  }
5101
3999
  var Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
5102
4000
 
5103
- var index$1 = '';
4001
+ var index$1 = /* #__PURE__ */ (() => ".m-editor-nav-menu {\n display: flex;\n z-index: 5;\n -webkit-box-pack: justify;\n justify-content: space-between;\n -webkit-box-align: center;\n align-items: center;\n background-color: #ffffff;\n font-size: 19.2px;\n color: #070303;\n font-weight: 400;\n box-sizing: border-box;\n margin: 0px;\n flex: 0 0 35px;\n border-bottom: 1px solid #d8dee8;\n}\n.m-editor-nav-menu > div {\n display: flex;\n height: 100%;\n z-index: 1;\n align-items: center;\n}\n.m-editor-nav-menu .menu-center {\n justify-content: center;\n}\n.m-editor-nav-menu .menu-right {\n justify-content: flex-end;\n}\n.m-editor-nav-menu .menu-item {\n flex-direction: row;\n -webkit-box-align: center;\n align-items: center;\n vertical-align: middle;\n font-size: 14px;\n line-height: 1;\n height: 100%;\n color: rgba(255, 255, 255, 0.7);\n box-sizing: inherit;\n z-index: 1;\n display: flex !important;\n transition: all 0.3s ease 0s;\n border-bottom: 2px solid transparent;\n margin: 0;\n}\n.m-editor-nav-menu .menu-item .is-disabled {\n opacity: 0.5;\n}\n.m-editor-nav-menu .menu-item .is-text {\n padding: 5px;\n}\n.m-editor-nav-menu .menu-item .is-text,\n.m-editor-nav-menu .menu-item i {\n color: #070303;\n}\n.m-editor-nav-menu .menu-item .icon {\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n height: 100%;\n padding: 0px 8px;\n}\n.m-editor-nav-menu .menu-item .menu-item-text {\n color: #070303;\n}\n.m-editor {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n.m-editor-content {\n width: 100%;\n height: calc(100% - 35px);\n display: flex;\n justify-self: space-between;\n}\n.m-editor-framework-center {\n position: relative;\n transform: translateZ(0);\n flex: 1;\n}\n.m-editor-framework-left {\n background-color: #ffffff;\n}\n.m-editor-framework-center .el-scrollbar__view {\n height: 100%;\n min-height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.m-editor-empty-panel {\n display: flex;\n flex: 1;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n height: calc(100% - 32px);\n}\n.m-editor-empty-content {\n display: flex;\n justify-content: space-evenly;\n flex-direction: row;\n width: 100%;\n}\n.m-editor-empty-button {\n border: 3px solid rgba(0, 0, 0, 0.2);\n padding: 10px 40px;\n color: rgba(0, 0, 0, 0.6);\n cursor: pointer;\n}\n.m-editor-empty-button i {\n height: 180px;\n line-height: 180px;\n font-size: 100px;\n}\n.m-editor-empty-button p {\n text-align: center;\n font-size: 20px;\n margin-top: 5px;\n}\n.m-editor-empty-button:hover {\n border-color: #2882e0;\n color: #2882e0;\n}\n.m-editor-sidebar {\n height: 100%;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header {\n background: #2882e0;\n border: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header.is-left {\n width: 40px;\n margin-right: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__nav-wrap {\n margin: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__nav {\n border: 0;\n border-radius: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .tab-label {\n margin-left: 2px;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left {\n line-height: 15px;\n border: 0;\n height: auto;\n padding: 8px;\n color: rgb(255, 255, 255);\n box-sizing: border-box;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active {\n background: #ffffff;\n border: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active i {\n color: #353140;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active .magic-editor-tab-panel-title {\n color: #353140;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left:first-child {\n border-right: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header i {\n font-size: 25px;\n color: rgba(255, 255, 255, 0.6);\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header i:hover {\n color: rgb(255, 255, 255);\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .magic-editor-tab-panel-title {\n font-size: 12px;\n white-space: normal;\n}\n.m-editor-sidebar .el-scrollbar {\n height: 100%;\n}\n.m-editor-sidebar .el-tree {\n min-height: 100%;\n}\n.m-editor-sidebar .fold-icon {\n position: absolute;\n bottom: 8px;\n left: 0px;\n width: 45px;\n padding-left: 8px;\n color: #fff;\n font-size: 32px;\n opacity: 0.8;\n cursor: pointer;\n}\n.m-editor-sidebar .fold-icon:hover {\n background: rgba(0, 0, 0, 0.2);\n}\n.m-editor-sidebar .el-tabs__content,\n.m-editor-sidebar .el-tab-pane {\n height: 100%;\n}\n.magic-editor-layer-panel {\n background: #ffffff;\n}\n.magic-editor-layer-panel .search-input {\n background: #ffffff;\n color: #bbbbbb;\n padding: 10px;\n position: absolute;\n top: 0;\n left: 0;\n z-index: 1;\n}\n.magic-editor-layer-panel .search-input .el-input__suffix {\n padding: 10px 5px;\n}\n.magic-editor-layer-panel .node-content {\n flex: 1;\n display: flex;\n width: 100%;\n}\n.magic-editor-layer-panel .node-content > div {\n width: 8px;\n}\n.magic-editor-layer-panel .node-content > span {\n width: calc(100% - 68px);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.magic-editor-layer-panel .node-content > i {\n margin-right: 10px;\n font-size: 20px;\n}\n.magic-editor-layer-panel .node-content > i.lock {\n color: #bbb;\n}\n.magic-editor-layer-panel,\n.magic-editor-layer-panel .el-tree {\n background-color: #ffffff;\n color: #313a40;\n}\n.magic-editor-layer-panel .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {\n background-color: #2882e0;\n color: #fff;\n}\n.magic-editor-layer-panel .cus-tree-node {\n width: 100%;\n overflow: hidden;\n}\n.magic-editor-layer-panel .cus-tree-node-hover {\n background-color: #f3f5f9;\n width: 100%;\n}\n.magic-editor-layer-panel .el-tree-node:focus > .el-tree-node__content {\n background-color: #2882e0;\n color: #fff;\n}\n.ui-tree-tip {\n width: 100%;\n height: 25px;\n margin-left: 10px;\n background: #ffffff;\n font-style: italic;\n color: #555554;\n position: absolute;\n top: 40px;\n left: 0;\n z-index: 1;\n}\n.ui-component-panel {\n height: 100%;\n border-top: 0 !important;\n margin-top: 50px;\n background-color: #ffffff;\n}\n.ui-component-panel .search-input {\n background: #f8fbff;\n color: #bbbbbb;\n padding: 10px;\n position: absolute;\n top: 0;\n left: 0;\n box-sizing: border-box;\n z-index: 1;\n}\n.ui-component-panel .search-input .el-input__prefix {\n padding: 10px;\n}\n.ui-component-panel .search-input .el-input__suffix {\n padding: 10px 5px;\n}\n.ui-component-panel .el-collapse-item > div:first-of-type {\n border-bottom: 1px solid #d9dbdd;\n margin-bottom: 10px;\n}\n.ui-component-panel .el-collapse-item__header {\n background: #ffffff;\n color: #070303;\n height: 25px;\n line-height: 25px;\n padding-left: 10px;\n font-size: 12px;\n}\n.ui-component-panel .el-collapse-item__header i {\n margin-right: 5px;\n font-size: 14px;\n}\n.ui-component-panel .el-collapse-item__wrap {\n background: #ffffff;\n border-bottom: 0;\n}\n.ui-component-panel .el-collapse-item__wrap .el-collapse-item__content {\n padding: 10px;\n display: flex;\n flex-wrap: wrap;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item {\n display: flex;\n overflow: hidden;\n text-overflow: ellipsis;\n margin: 5px 10px;\n box-sizing: border-box;\n color: #070303;\n flex-direction: column;\n width: 42px;\n cursor: pointer;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item i {\n font-size: 20px;\n background: #fff;\n height: 40px;\n width: 40px;\n line-height: 40px;\n border-radius: 5px;\n color: #909090;\n border: 1px solid #d9dbdd;\n display: flex;\n justify-content: space-evenly;\n align-items: center;\n margin-bottom: 5px;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item i:hover {\n background: #2882e0;\n color: #fff;\n border-color: #4e8be1;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item span {\n font-size: 12px;\n text-align: center;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item .el-tooltip {\n width: 50px;\n height: 30px;\n line-height: 15px;\n display: block;\n white-space: normal;\n margin: 0;\n}\n.m-editor-resizer {\n border-left: 1px solid transparent;\n border-right: 1px solid transparent;\n width: 8px;\n margin: 0 -5px;\n height: 100%;\n opacity: 0.9;\n background: padding-box #d8dee8;\n box-sizing: border-box;\n cursor: col-resize;\n z-index: 1;\n}\n.m-editor-resizer:hover {\n border-color: #d8dee8;\n}\n.m-editor-resizer .icon-container {\n visibility: hidden;\n opacity: 0;\n transition: opacity 0.4s;\n width: 20px;\n height: 120px;\n line-height: 120px;\n text-align: center;\n background: #d8dee8;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n cursor: pointer;\n}\n.m-editor-resizer .icon-container.position-left {\n transform: translate(calc(-100% - 4px), -50%);\n}\n.m-editor-resizer .icon-container.position-right {\n transform: translate(calc(100% + 4px), -50%);\n}\n.m-editor-resizer .icon {\n color: #fff;\n font-size: 18px;\n}\n.magic-editor-resizer:hover .icon-container {\n visibility: visible;\n opacity: 1;\n}\n.m-editor-workspace {\n height: 100%;\n width: 100%;\n user-select: none;\n}\n.m-editor-workspace:focus-visible {\n outline: 0;\n}\n.m-editor-page-bar {\n position: fixed;\n bottom: 0;\n left: 0;\n display: flex;\n width: 100%;\n height: 32px;\n line-height: 32px;\n color: #070303;\n background-color: #f3f3f3;\n border-top: 1px solid #d9dbdd;\n z-index: 2;\n overflow: hidden;\n}\n.m-editor-page-bar-items {\n display: flex;\n transition: transform 0.3s;\n}\n.m-editor-page-bar-item {\n padding: 0 10px;\n cursor: pointer;\n border-right: 1px solid #d9dbdd;\n display: flex;\n justify-items: center;\n align-items: center;\n background-color: #f3f3f3;\n}\n.m-editor-page-bar-item.active {\n background-color: #fff;\n cursor: text;\n}\n.m-editor-page-bar-item.active .m-editor-page-bar-menu-icon {\n cursor: pointer;\n}\n.m-editor-page-bar-item-icon {\n position: relative;\n z-index: 1;\n}\n.m-editor-page-bar-item-title {\n max-width: 150px;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n}\n.page-bar-popover.el-popper.el-popover {\n padding: 10px 0;\n}\n.page-bar-popover .menu-item {\n cursor: pointer;\n transition: all 0.2s ease 0s;\n padding: 5px 14px;\n}\n.page-bar-popover .menu-item .el-button--text,\n.page-bar-popover .menu-item i {\n color: #070303;\n}\n.page-bar-popover .menu-item:hover {\n background-color: #f3f5f9;\n}\n.m-editor-props-panel {\n padding: 0 10px;\n}\n.m-editor-props-panel.small .el-form-item__label {\n font-size: 12px;\n}\n.m-editor-props-panel.small .m-fieldset legend {\n font-size: 12px;\n}\n.m-editor-props-panel.small .el-tabs__item {\n font-size: 12px;\n}\n.m-editor-props-panel .el-input__wrapper {\n border-radius: 0;\n}\n.m-editor-props-panel-popper.small span,\n.m-editor-props-panel-popper.small a,\n.m-editor-props-panel-popper.small p {\n font-size: 12px;\n}\n.magic-editor-content-menu {\n position: fixed;\n font-size: 12px;\n background: #fff;\n box-shadow: 0 2px 8px 2px rgba(68, 73, 77, 0.16);\n z-index: 9999;\n transform-origin: 0% 0%;\n font-weight: 600;\n padding: 4px 0px;\n overflow: auto;\n max-height: 100%;\n}\n.magic-editor-content-menu .menu-item {\n color: #333;\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n cursor: pointer;\n min-width: 140px;\n transition: all 0.2s ease 0s;\n padding: 5px 14px;\n border-left: 2px solid transparent;\n}\n.magic-editor-content-menu .menu-item .el-button {\n width: 100%;\n justify-content: flex-start;\n}\n.magic-editor-content-menu .menu-item .el-button--text,\n.magic-editor-content-menu .menu-item i {\n color: #070303;\n}\n.magic-editor-content-menu .menu-item.divider {\n padding: 0 14px;\n}\n.magic-editor-content-menu .menu-item.divider .el-divider {\n margin: 0;\n}\n.magic-editor-content-menu .menu-item:hover {\n background-color: #f3f5f9;\n}\n.m-editor-stage {\n position: relative;\n width: 100%;\n height: calc(100% - 32px);\n overflow: hidden;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.m-editor-stage-container {\n width: 100%;\n height: 100%;\n z-index: 0;\n position: relative;\n border: 1px solid #d9dbdd;\n transition: transform 0.3s;\n box-sizing: content-box;\n}\n.m-editor-stage-container::-webkit-scrollbar {\n width: 0 !important;\n}\n.magic-code-editor {\n width: 100%;\n}\n.magic-code-editor .margin {\n margin: 0;\n}")();
5104
4002
 
5105
4003
  const defaultInstallOpt = {};
5106
4004
  var index = {
@@ -5116,5 +4014,5 @@ var index = {
5116
4014
  }
5117
4015
  };
5118
4016
 
5119
- export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, ToolButton, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, generateId, generatePageName, generatePageNameByApp, getConfig, getDefaultPropsValue, getNodeIndex, getPageList, getPageNameList, historyService, info, initPosition, isFixed, log, propsService, setConfig, setLayout, setNewItemId, toRelative, uiService, warn };
4017
+ export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, ToolButton, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, generatePageName, generatePageNameByApp, getConfig, getDefaultPropsValue, getNodeIndex, getPageList, getPageNameList, historyService, info, initPosition, isFixed, log, propsService, setConfig, setLayout, toRelative, uiService, warn };
5120
4018
  //# sourceMappingURL=tmagic-editor.es.js.map