@tmagic/editor 1.0.0-rc.5 → 1.0.0-rc.6

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 (58) hide show
  1. package/coverage/clover.xml +189 -167
  2. package/coverage/coverage-final.json +6 -6
  3. package/coverage/lcov-report/index.html +42 -42
  4. package/coverage/lcov-report/src/Editor.vue.html +48 -9
  5. package/coverage/lcov-report/src/components/ContentMenu.vue.html +135 -36
  6. package/coverage/lcov-report/src/components/Icon.vue.html +1 -1
  7. package/coverage/lcov-report/src/components/ScrollViewer.vue.html +1 -1
  8. package/coverage/lcov-report/src/components/ToolButton.vue.html +1 -1
  9. package/coverage/lcov-report/src/components/index.html +18 -18
  10. package/coverage/lcov-report/src/index.html +15 -15
  11. package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +1 -1
  12. package/coverage/lcov-report/src/layouts/Framework.vue.html +1 -1
  13. package/coverage/lcov-report/src/layouts/NavMenu.vue.html +1 -1
  14. package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +1 -1
  15. package/coverage/lcov-report/src/layouts/Resizer.vue.html +1 -1
  16. package/coverage/lcov-report/src/layouts/index.html +1 -1
  17. package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +1 -1
  18. package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +15 -6
  19. package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +1 -1
  20. package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +1 -1
  21. package/coverage/lcov-report/src/layouts/sidebar/TabPane.vue.html +1 -1
  22. package/coverage/lcov-report/src/layouts/sidebar/index.html +11 -11
  23. package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +1 -1
  24. package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +1 -1
  25. package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +15 -6
  26. package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +1 -1
  27. package/coverage/lcov-report/src/layouts/workspace/index.html +11 -11
  28. package/coverage/lcov-report/src/services/BaseService.ts.html +1 -1
  29. package/coverage/lcov-report/src/services/componentList.ts.html +1 -1
  30. package/coverage/lcov-report/src/services/editor.ts.html +3 -3
  31. package/coverage/lcov-report/src/services/events.ts.html +1 -1
  32. package/coverage/lcov-report/src/services/history.ts.html +1 -1
  33. package/coverage/lcov-report/src/services/index.html +1 -1
  34. package/coverage/lcov-report/src/services/props.ts.html +4 -4
  35. package/coverage/lcov-report/src/services/ui.ts.html +1 -1
  36. package/coverage/lcov-report/src/type.ts.html +1 -1
  37. package/coverage/lcov-report/src/utils/compose.ts.html +1 -1
  38. package/coverage/lcov-report/src/utils/config.ts.html +1 -1
  39. package/coverage/lcov-report/src/utils/editor.ts.html +21 -9
  40. package/coverage/lcov-report/src/utils/index.html +12 -12
  41. package/coverage/lcov-report/src/utils/index.ts.html +1 -1
  42. package/coverage/lcov-report/src/utils/logger.ts.html +1 -1
  43. package/coverage/lcov-report/src/utils/props.ts.html +1 -1
  44. package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +1 -1
  45. package/coverage/lcov-report/src/utils/undo-redo.ts.html +1 -1
  46. package/coverage/lcov.info +495 -448
  47. package/dist/tmagic-editor.es.js +68 -28
  48. package/dist/tmagic-editor.es.js.map +1 -1
  49. package/dist/tmagic-editor.umd.js +69 -29
  50. package/dist/tmagic-editor.umd.js.map +1 -1
  51. package/dist/types/src/Editor.vue.d.ts +19 -1
  52. package/package.json +7 -7
  53. package/src/Editor.vue +14 -1
  54. package/src/components/ContentMenu.vue +58 -25
  55. package/src/layouts/sidebar/LayerMenu.vue +3 -0
  56. package/src/layouts/workspace/ViewerMenu.vue +3 -0
  57. package/src/services/editor.ts +2 -2
  58. package/src/services/props.ts +3 -3
@@ -666,10 +666,10 @@ class Props extends BaseService {
666
666
  }
667
667
  return value;
668
668
  }
669
- return cloneDeep({
669
+ return {
670
670
  ...getDefaultPropsValue(type),
671
- ...mergeWith(this.state.propsValueMap[type] || {}, defaultValue)
672
- });
671
+ ...mergeWith(cloneDeep(this.state.propsValueMap[type] || {}), cloneDeep(defaultValue))
672
+ };
673
673
  }
674
674
  }
675
675
  var propsService = new Props();
@@ -1179,9 +1179,9 @@ class Editor$1 extends BaseService {
1179
1179
  const node = this.get("node");
1180
1180
  const brothers = parent?.items || [];
1181
1181
  const index = brothers.findIndex((item) => `${item.id}` === `${node?.id}`);
1182
- if (offset === LayerOffset.BOTTOM) {
1182
+ if (offset === LayerOffset.TOP) {
1183
1183
  brothers.splice(brothers.length - 1, 0, brothers.splice(index, 1)[0]);
1184
- } else if (offset === LayerOffset.TOP) {
1184
+ } else if (offset === LayerOffset.BOTTOM) {
1185
1185
  brothers.splice(0, 0, brothers.splice(index, 1)[0]);
1186
1186
  } else {
1187
1187
  brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
@@ -2249,9 +2249,14 @@ const _sfc_main$a = defineComponent({
2249
2249
  menuData: {
2250
2250
  type: Array,
2251
2251
  default: () => []
2252
+ },
2253
+ isSubMenu: {
2254
+ type: Boolean,
2255
+ default: false
2252
2256
  }
2253
2257
  },
2254
- setup() {
2258
+ emits: ["hide", "show"],
2259
+ setup(props, { emit }) {
2255
2260
  const menu = ref();
2256
2261
  const subMenu = ref();
2257
2262
  const visible = ref(false);
@@ -2261,15 +2266,31 @@ const _sfc_main$a = defineComponent({
2261
2266
  top: "0"
2262
2267
  });
2263
2268
  const hide = () => {
2269
+ if (!visible.value)
2270
+ return;
2264
2271
  visible.value = false;
2272
+ subMenu.value?.hide();
2273
+ emit("hide");
2274
+ };
2275
+ const hideHandler = (e) => {
2276
+ const target = e.target;
2277
+ if (!visible.value || !target) {
2278
+ return;
2279
+ }
2280
+ if (menu.value?.contains(target) || subMenu.value?.$el?.contains(target)) {
2281
+ return;
2282
+ }
2283
+ hide();
2265
2284
  };
2266
2285
  onMounted(() => {
2267
- globalThis.addEventListener("mouseup", (e) => {
2268
- if (!visible.value || e.target && menu.value?.contains(e.target)) {
2269
- return;
2270
- }
2271
- hide();
2272
- }, true);
2286
+ if (props.isSubMenu)
2287
+ return;
2288
+ globalThis.addEventListener("mousedown", hideHandler, true);
2289
+ });
2290
+ onUnmounted(() => {
2291
+ if (props.isSubMenu)
2292
+ return;
2293
+ globalThis.removeEventListener("mousedown", hideHandler, true);
2273
2294
  });
2274
2295
  return {
2275
2296
  menu,
@@ -2279,18 +2300,21 @@ const _sfc_main$a = defineComponent({
2279
2300
  subMenuData,
2280
2301
  hide,
2281
2302
  show(e) {
2282
- visible.value = true;
2283
- nextTick(() => {
2284
- const menuHeight = menu.value?.clientHeight || 0;
2285
- let top = e.clientY;
2286
- if (menuHeight + e.clientY > document.body.clientHeight) {
2287
- top = document.body.clientHeight - menuHeight;
2288
- }
2289
- menuStyle.value = {
2290
- top: `${top}px`,
2291
- left: `${e.clientX + 2}px`
2292
- };
2293
- });
2303
+ setTimeout(() => {
2304
+ visible.value = true;
2305
+ nextTick(() => {
2306
+ const menuHeight = menu.value?.clientHeight || 0;
2307
+ let top = e.clientY;
2308
+ if (menuHeight + e.clientY > document.body.clientHeight) {
2309
+ top = document.body.clientHeight - menuHeight;
2310
+ }
2311
+ menuStyle.value = {
2312
+ top: `${top}px`,
2313
+ left: `${e.clientX}px`
2314
+ };
2315
+ emit("show");
2316
+ });
2317
+ }, 300);
2294
2318
  },
2295
2319
  showSubMenu(item) {
2296
2320
  const menuItem = item;
@@ -2332,8 +2356,10 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
2332
2356
  createVNode(_component_content_menu, {
2333
2357
  class: "sub-menu",
2334
2358
  ref: "subMenu",
2335
- "menu-data": _ctx.subMenuData
2336
- }, null, 8, ["menu-data"])
2359
+ "menu-data": _ctx.subMenuData,
2360
+ "is-sub-menu": true,
2361
+ onHide: _ctx.hide
2362
+ }, null, 8, ["menu-data", "onHide"])
2337
2363
  ]))
2338
2364
  ], 4)) : createCommentVNode("", true);
2339
2365
  }
@@ -2348,6 +2374,7 @@ const _sfc_main$9 = defineComponent({
2348
2374
  const isRoot = computed(() => node.value?.type === NodeType.ROOT);
2349
2375
  const isPage = computed(() => node.value?.type === NodeType.PAGE);
2350
2376
  const componentList = computed(() => services?.componentListService.getList() || []);
2377
+ const layerContentMenu = inject("layerContentMenu", []);
2351
2378
  const createMenuItems = (group) => group.items.map((component) => ({
2352
2379
  text: component.text,
2353
2380
  type: "button",
@@ -2412,7 +2439,8 @@ const _sfc_main$9 = defineComponent({
2412
2439
  handler: () => {
2413
2440
  node.value && services?.editorService.remove(node.value);
2414
2441
  }
2415
- }
2442
+ },
2443
+ ...layerContentMenu
2416
2444
  ]),
2417
2445
  show(e) {
2418
2446
  menu.value?.show(e);
@@ -3203,6 +3231,7 @@ const _sfc_main$3 = defineComponent({
3203
3231
  const node = computed(() => editorService?.get("node"));
3204
3232
  const parent = computed(() => editorService?.get("parent"));
3205
3233
  const isPage = computed(() => node.value?.type === NodeType.PAGE);
3234
+ const stageContentMenu = inject("stageContentMenu", []);
3206
3235
  onMounted(() => {
3207
3236
  const data = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
3208
3237
  canPaste.value = data !== "undefined" && !!data;
@@ -3315,7 +3344,8 @@ const _sfc_main$3 = defineComponent({
3315
3344
  handler: () => {
3316
3345
  editorService?.get("stage").clearGuides();
3317
3346
  }
3318
- }
3347
+ },
3348
+ ...stageContentMenu
3319
3349
  ]),
3320
3350
  show(e) {
3321
3351
  menu.value?.show(e);
@@ -3813,6 +3843,14 @@ const _sfc_main = defineComponent({
3813
3843
  sidebar: {
3814
3844
  type: Object
3815
3845
  },
3846
+ layerContentMenu: {
3847
+ type: Array,
3848
+ default: () => []
3849
+ },
3850
+ stageContentMenu: {
3851
+ type: Array,
3852
+ default: () => []
3853
+ },
3816
3854
  menu: {
3817
3855
  type: Object,
3818
3856
  default: () => ({ left: [], right: [] })
@@ -3898,6 +3936,8 @@ const _sfc_main = defineComponent({
3898
3936
  uiService
3899
3937
  };
3900
3938
  provide("services", services);
3939
+ provide("layerContentMenu", props.layerContentMenu);
3940
+ provide("stageContentMenu", props.stageContentMenu);
3901
3941
  return services;
3902
3942
  }
3903
3943
  });