mce 0.15.31 → 0.15.32

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.
@@ -48,7 +48,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
48
48
  }>> & Readonly<{}>, {
49
49
  offset: number;
50
50
  attach: string | boolean | Element | null | undefined;
51
- middlewares: ("shift" | "offset" | "flip")[];
51
+ middlewares: ("flip" | "shift" | "offset")[];
52
52
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
53
53
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
54
54
  declare const _default: typeof __VLS_export;
@@ -59,7 +59,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
59
59
  "onUpdate:modelValue"?: ((value: boolean | undefined) => any) | undefined;
60
60
  }>, {
61
61
  attach: string | boolean | Element | null | undefined;
62
- middlewares: ("shift" | "offset" | "flip")[];
62
+ middlewares: ("flip" | "shift" | "offset")[];
63
63
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
64
64
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
65
65
  declare const _default: typeof __VLS_export;
@@ -82,7 +82,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
82
82
  "onClick:item"?: ((item: MenuItem, event: MouseEvent) => any) | undefined;
83
83
  }>, {
84
84
  attach: string | boolean | Element | null | undefined;
85
- middlewares: ("shift" | "offset" | "flip")[];
85
+ middlewares: ("flip" | "shift" | "offset")[];
86
86
  openOnHover: boolean;
87
87
  persistent: boolean;
88
88
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -58,7 +58,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
58
58
  "onClick:outside"?: ((event: MouseEvent) => any) | undefined;
59
59
  }>, {
60
60
  attach: string | boolean | Element | null | undefined;
61
- middlewares: ("shift" | "offset" | "flip")[];
61
+ middlewares: ("flip" | "shift" | "offset")[];
62
62
  modelValue: boolean;
63
63
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
64
64
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -78,7 +78,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
78
78
  offset: number;
79
79
  location: import("@floating-ui/vue").Side | "top-start" | "top-end" | "right-start" | "right-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end";
80
80
  attach: string | boolean | Element | null | undefined;
81
- middlewares: ("shift" | "offset" | "flip")[];
81
+ middlewares: ("flip" | "shift" | "offset")[];
82
82
  showArrow: boolean;
83
83
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
84
84
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -36,8 +36,8 @@ export declare const makeMceOverlayProps: <Defaults extends {
36
36
  type: PropType<("offset" | "flip" | "shift")[]>;
37
37
  default: () => string[];
38
38
  }, "type" | "default"> & {
39
- type: PropType<unknown extends Defaults["middlewares"] ? ("shift" | "offset" | "flip")[] : ("shift" | "offset" | "flip")[] | Defaults["middlewares"]>;
40
- default: unknown extends Defaults["middlewares"] ? ("shift" | "offset" | "flip")[] : ("shift" | "offset" | "flip")[] | Defaults["middlewares"];
39
+ type: PropType<unknown extends Defaults["middlewares"] ? ("flip" | "shift" | "offset")[] : ("flip" | "shift" | "offset")[] | Defaults["middlewares"]>;
40
+ default: unknown extends Defaults["middlewares"] ? ("flip" | "shift" | "offset")[] : ("flip" | "shift" | "offset")[] | Defaults["middlewares"];
41
41
  };
42
42
  target: unknown extends Defaults["target"] ? PropType<{
43
43
  x: number;
package/dist/index.js CHANGED
@@ -1125,7 +1125,8 @@ const en = {
1125
1125
  "duplicate": "Duplicate",
1126
1126
  "delete": "Delete",
1127
1127
  "selectAll": "Select all",
1128
- "deselectAll": "Deselect all",
1128
+ "selectInverse": "Deselect all",
1129
+ "selectNone": "Select none",
1129
1130
  "selectChildren": "Select children",
1130
1131
  "selectParent": "Select parent",
1131
1132
  "selectPreviousSibling": "Select previous sibling",
@@ -1158,12 +1159,12 @@ const en = {
1158
1159
  "object": "Object",
1159
1160
  "groupSelection": "Group Selection",
1160
1161
  "frameSelection": "Frame selection",
1161
- "ungroup": "Ungroup",
1162
+ "ungroupSelection": "ungroupSelection",
1162
1163
  "flip": "Flip",
1163
1164
  "flipHorizontal": "Flip horizontal",
1164
1165
  "flipVertical": "Flip vertical",
1165
- "hide/show": "Hide/Show",
1166
- "lock/unlock": "Lock/Unlock",
1166
+ "showOrHideSelection": "Show/Hide",
1167
+ "lockOrUnlockSelection": "Lock/Unlock",
1167
1168
  "layerOrder": "Layer order",
1168
1169
  "bringToFront": "Bring to front",
1169
1170
  "bringForward": "Bring forward",
@@ -1238,7 +1239,8 @@ const zhHans = {
1238
1239
  "duplicate": "创建副本",
1239
1240
  "delete": "删除",
1240
1241
  "selectAll": "选择全部",
1241
- "deselectAll": "反选全部",
1242
+ "selectInverse": "反选全部",
1243
+ "selectNone": "取消选择",
1242
1244
  "selectChildren": "选择子元素",
1243
1245
  "selectParent": "选择父元素",
1244
1246
  "selectPreviousSibling": "选择前一个",
@@ -1271,12 +1273,12 @@ const zhHans = {
1271
1273
  "object": "对象",
1272
1274
  "groupSelection": "组合选区",
1273
1275
  "frameSelection": "组合选区为画板",
1274
- "ungroup": "解组",
1276
+ "ungroupSelection": "解组",
1275
1277
  "flip": "翻转",
1276
1278
  "flipHorizontal": "水平翻转",
1277
1279
  "flipVertical": "垂直翻转",
1278
- "hide/show": "隐藏/显示",
1279
- "lock/unlock": "锁/解锁",
1280
+ "showOrHideSelection": "显示/隐藏",
1281
+ "lockOrUnlockSelection": "锁/解锁",
1280
1282
  "layerOrder": "图层顺序",
1281
1283
  "bringToFront": "移到顶层",
1282
1284
  "bringForward": "上移一层",
@@ -4359,9 +4361,14 @@ const _arrange = definePlugin((editor) => {
4359
4361
  function sendToBack(target = selection.value) {
4360
4362
  target && zOrder2(target, "sendToBack");
4361
4363
  }
4364
+ function distributeSpacing(_direction) {
4365
+ }
4366
+ function tidyUp() {
4367
+ }
4362
4368
  return {
4363
4369
  name: "mce:arrange",
4364
4370
  commands: [
4371
+ { command: "zOrder", handle: zOrder2 },
4365
4372
  { command: "bringForward", handle: bringForward },
4366
4373
  { command: "sendBackward", handle: sendBackward },
4367
4374
  { command: "bringToFront", handle: bringToFront },
@@ -4372,7 +4379,11 @@ const _arrange = definePlugin((editor) => {
4372
4379
  { command: "alignTop", handle: () => align("top") },
4373
4380
  { command: "alignBottom", handle: () => align("bottom") },
4374
4381
  { command: "alignHorizontalCenter", handle: () => align("horizontal-center") },
4375
- { command: "alignVerticalCenter", handle: () => align("vertical-center") }
4382
+ { command: "alignVerticalCenter", handle: () => align("vertical-center") },
4383
+ { command: "distributeSpacing", handle: distributeSpacing },
4384
+ { command: "distributeHorizontalSpacing", handle: () => distributeSpacing() },
4385
+ { command: "distributeVerticalSpacing", handle: () => distributeSpacing() },
4386
+ { command: "tidyUp", handle: tidyUp }
4376
4387
  ],
4377
4388
  hotkeys: [
4378
4389
  { command: "bringForward", key: "CmdOrCtrl+]" },
@@ -4384,7 +4395,10 @@ const _arrange = definePlugin((editor) => {
4384
4395
  { command: "alignTop", key: "Alt+W" },
4385
4396
  { command: "alignBottom", key: "Alt+S" },
4386
4397
  { command: "alignHorizontalCenter", key: "Alt+H" },
4387
- { command: "alignVerticalCenter", key: "Alt+V" }
4398
+ { command: "alignVerticalCenter", key: "Alt+V" },
4399
+ { command: "distributeHorizontalSpacing", key: "Ctrl+Alt+H" },
4400
+ { command: "distributeVerticalSpacing", key: "Ctrl+Alt+V" },
4401
+ { command: "tidyUp", key: "Ctrl+Alt+T" }
4388
4402
  ]
4389
4403
  };
4390
4404
  });
@@ -5621,6 +5635,8 @@ const _frame = definePlugin((editor) => {
5621
5635
  position: start,
5622
5636
  active: true
5623
5637
  });
5638
+ el.style.width = 1;
5639
+ el.style.height = 1;
5624
5640
  el.style.backgroundColor = "#ffffff";
5625
5641
  return {
5626
5642
  move: (move) => {
@@ -5630,8 +5646,8 @@ const _frame = definePlugin((editor) => {
5630
5646
  const maxY = Math.max(move.y, start.y);
5631
5647
  el.style.left = minX;
5632
5648
  el.style.top = minY;
5633
- el.style.width = maxX - minX;
5634
- el.style.height = maxY - minY;
5649
+ el.style.width = Math.max(1, maxX - minX);
5650
+ el.style.height = Math.max(1, maxY - minY);
5635
5651
  },
5636
5652
  end: () => {
5637
5653
  setActiveDrawingTool(void 0);
@@ -5686,103 +5702,6 @@ const _gif = definePlugin((editor, options) => {
5686
5702
  ]
5687
5703
  };
5688
5704
  });
5689
- const _group = definePlugin((editor) => {
5690
- const {
5691
- getObb,
5692
- getAabb,
5693
- elementSelection,
5694
- addElement,
5695
- addElements,
5696
- doc,
5697
- isElement,
5698
- inEditorIs,
5699
- obbToFit
5700
- } = editor;
5701
- function group(inEditorIs2) {
5702
- const elements = elementSelection.value;
5703
- if (!elements.length) {
5704
- return;
5705
- }
5706
- const element = elements[0];
5707
- const parent = element.parent;
5708
- const aabb = getAabb(elements, "parent");
5709
- const children = elements.map((child) => {
5710
- const cloned = child.toJSON();
5711
- cloned.style.left = child.style.left - aabb.left;
5712
- cloned.style.top = child.style.top - aabb.top;
5713
- return cloned;
5714
- });
5715
- doc.value.transact(() => {
5716
- addElement({
5717
- name: inEditorIs2 === "Frame" ? "Frame" : "Group",
5718
- style: {
5719
- left: aabb.left,
5720
- top: aabb.top,
5721
- width: aabb.width,
5722
- height: aabb.height
5723
- },
5724
- children,
5725
- meta: {
5726
- inPptIs: "GroupShape",
5727
- inEditorIs: inEditorIs2
5728
- }
5729
- }, {
5730
- parent,
5731
- index: parent ? element.getIndex() : void 0,
5732
- active: true,
5733
- regenId: true
5734
- });
5735
- elements.forEach((node) => node.remove());
5736
- });
5737
- }
5738
- function ungroup() {
5739
- const element = elementSelection.value[0];
5740
- if (!element || !element.children.length)
5741
- return;
5742
- const parent = getObb(element, "parent");
5743
- const items = element.children.map((child) => {
5744
- const obb = getObb(child, "parent");
5745
- const cloned = child.toJSON();
5746
- cloned.style.left = obb.left + parent.left;
5747
- cloned.style.top = obb.top + parent.top;
5748
- return cloned;
5749
- });
5750
- doc.value.transact(() => {
5751
- addElements(items, {
5752
- parent: element.parent,
5753
- index: element.getIndex(),
5754
- active: true,
5755
- regenId: true
5756
- });
5757
- element.remove();
5758
- });
5759
- }
5760
- return {
5761
- name: "mce:group",
5762
- commands: [
5763
- { command: "groupSelection", handle: () => group("Element") },
5764
- { command: "frameSelection", handle: () => group("Frame") },
5765
- { command: "ungroup", handle: ungroup }
5766
- ],
5767
- hotkeys: [
5768
- { command: "groupSelection", key: "CmdOrCtrl+G" },
5769
- { command: "frameSelection", key: "Alt+CmdOrCtrl+G" },
5770
- { command: "ungroup", key: "CmdOrCtrl+Backspace" }
5771
- ],
5772
- events: {
5773
- selectionTransforming: ({ elements }) => {
5774
- elements.forEach((el) => {
5775
- el.findAncestor((ancestor) => {
5776
- if (isElement(ancestor) && !inEditorIs(ancestor, "Frame")) {
5777
- obbToFit(ancestor);
5778
- }
5779
- return false;
5780
- });
5781
- });
5782
- }
5783
- }
5784
- };
5785
- });
5786
5705
  const _history = definePlugin((editor) => {
5787
5706
  const {
5788
5707
  doc,
@@ -6547,24 +6466,6 @@ const _layers = definePlugin(() => {
6547
6466
  ]
6548
6467
  };
6549
6468
  });
6550
- const _lock = definePlugin((editor) => {
6551
- const {
6552
- selection,
6553
- isLock,
6554
- setLock
6555
- } = editor;
6556
- return {
6557
- name: "mce:lock",
6558
- commands: [
6559
- { command: "lock", handle: () => selection.value.forEach((el) => setLock(el, true)) },
6560
- { command: "unlock", handle: () => selection.value.forEach((el) => setLock(el, false)) },
6561
- { command: "lock/unlock", handle: () => selection.value.forEach((el) => setLock(el, !isLock(el))) }
6562
- ],
6563
- hotkeys: [
6564
- { command: "lock/unlock", key: "Shift+CmdOrCtrl+L" }
6565
- ]
6566
- };
6567
- });
6568
6469
  const _export_sfc = (sfc, props) => {
6569
6470
  const target = sfc.__vccOpts || sfc;
6570
6471
  for (const [key, val] of props) {
@@ -7119,7 +7020,8 @@ const _menu = definePlugin((editor, options) => {
7119
7020
  key: "select",
7120
7021
  children: [
7121
7022
  { key: "selectAll" },
7122
- { key: "deselectAll", disabled: !hasSelected.value },
7023
+ { key: "selectInverse", disabled: !hasSelected.value },
7024
+ { key: "selectNone", disabled: !hasSelected.value },
7123
7025
  { key: "selectChildren", disabled: !hasSelected.value },
7124
7026
  { key: "selectParent", disabled: !hasSelected.value },
7125
7027
  { key: "selectPreviousSibling", disabled: !hasSelected.value },
@@ -7219,7 +7121,7 @@ const _menu = definePlugin((editor, options) => {
7219
7121
  const objectMenu1 = computed(() => [
7220
7122
  { key: "groupSelection", disabled: !hasSelected.value },
7221
7123
  { key: "frameSelection", disabled: !hasSelected.value },
7222
- { key: "ungroup", disabled: !(hasSelected.value && selection.value[0]?.children.length) }
7124
+ { key: "ungroupSelection", disabled: !(hasSelected.value && selection.value[0]?.children.length) }
7223
7125
  ]);
7224
7126
  const layerOrderMenu = computed(() => ({
7225
7127
  key: "layerOrder",
@@ -7238,8 +7140,8 @@ const _menu = definePlugin((editor, options) => {
7238
7140
  ]
7239
7141
  }));
7240
7142
  const objectMenu2 = computed(() => [
7241
- { key: "hide/show", disabled: !hasSelected.value },
7242
- { key: "lock/unlock", disabled: !hasSelected.value }
7143
+ { key: "showOrHideSelection", disabled: !hasSelected.value },
7144
+ { key: "lockOrUnlockSelection", disabled: !hasSelected.value }
7243
7145
  ]);
7244
7146
  const objectMenu = computed(() => ({
7245
7147
  key: "object",
@@ -12326,59 +12228,199 @@ const _selection = definePlugin((editor) => {
12326
12228
  const {
12327
12229
  isElement,
12328
12230
  selection,
12231
+ elementSelection,
12232
+ getObb,
12233
+ getAabb,
12234
+ doc,
12329
12235
  root,
12330
12236
  zoomTo,
12331
- findSibling
12237
+ findSibling,
12238
+ inEditorIs,
12239
+ addElement,
12240
+ addElements,
12241
+ obbToFit,
12242
+ setVisible,
12243
+ isVisible,
12244
+ setLock,
12245
+ isLock
12332
12246
  } = editor;
12333
- function selectAll() {
12334
- selection.value = [...root.value.children];
12335
- }
12336
- function deselectAll() {
12337
- selection.value = [];
12338
- }
12339
- function selectChildren() {
12340
- const children = selection.value[0]?.children;
12341
- if (children?.length) {
12342
- selection.value = [...children];
12247
+ function select(target) {
12248
+ switch (target) {
12249
+ case "none":
12250
+ selection.value = [];
12251
+ break;
12252
+ case "all":
12253
+ selection.value = [...root.value.children];
12254
+ break;
12255
+ case "inverse":
12256
+ selection.value = [];
12257
+ break;
12258
+ case "children": {
12259
+ const children = selection.value[0]?.children;
12260
+ if (children?.length) {
12261
+ selection.value = [...children];
12262
+ }
12263
+ break;
12264
+ }
12265
+ case "parent": {
12266
+ const parent = selection.value[0]?.parent;
12267
+ if (isElement(parent)) {
12268
+ selection.value = [parent];
12269
+ }
12270
+ break;
12271
+ }
12272
+ case "previousSibling":
12273
+ case "nextSibling": {
12274
+ const value = findSibling(target === "previousSibling" ? "previous" : "next");
12275
+ if (value) {
12276
+ selection.value = [value];
12277
+ zoomTo("selection", {
12278
+ intoView: true,
12279
+ behavior: "smooth"
12280
+ });
12281
+ }
12282
+ break;
12283
+ }
12284
+ default:
12285
+ selection.value = target;
12286
+ break;
12343
12287
  }
12344
12288
  }
12345
- function selectParent() {
12346
- const parent = selection.value[0]?.parent;
12347
- if (isElement(parent)) {
12348
- selection.value = [parent];
12289
+ function groupSelection(inEditorIs2) {
12290
+ const elements = elementSelection.value;
12291
+ if (!elements.length) {
12292
+ return;
12349
12293
  }
12294
+ const element = elements[0];
12295
+ const parent = element.parent;
12296
+ const aabb = getAabb(elements, "parent");
12297
+ const children = elements.map((child) => {
12298
+ const cloned = child.toJSON();
12299
+ cloned.style.left = child.style.left - aabb.left;
12300
+ cloned.style.top = child.style.top - aabb.top;
12301
+ return cloned;
12302
+ });
12303
+ doc.value.transact(() => {
12304
+ addElement({
12305
+ name: inEditorIs2 === "Frame" ? "Frame" : "Group",
12306
+ style: {
12307
+ left: aabb.left,
12308
+ top: aabb.top,
12309
+ width: aabb.width,
12310
+ height: aabb.height
12311
+ },
12312
+ children,
12313
+ meta: {
12314
+ inPptIs: "GroupShape",
12315
+ inEditorIs: inEditorIs2
12316
+ }
12317
+ }, {
12318
+ parent,
12319
+ index: parent ? element.getIndex() : void 0,
12320
+ active: true,
12321
+ regenId: true
12322
+ });
12323
+ elements.forEach((node) => node.remove());
12324
+ });
12350
12325
  }
12351
- function selectSibling(type) {
12352
- const value = findSibling(type);
12353
- if (value) {
12354
- selection.value = [value];
12355
- zoomTo("selection", {
12356
- intoView: true,
12357
- behavior: "smooth"
12326
+ function ungroupSelection() {
12327
+ const element = elementSelection.value[0];
12328
+ if (!element || !element.children.length)
12329
+ return;
12330
+ const parent = getObb(element, "parent");
12331
+ const items = element.children.map((child) => {
12332
+ const obb = getObb(child, "parent");
12333
+ const cloned = child.toJSON();
12334
+ cloned.style.left = obb.left + parent.left;
12335
+ cloned.style.top = obb.top + parent.top;
12336
+ return cloned;
12337
+ });
12338
+ doc.value.transact(() => {
12339
+ addElements(items, {
12340
+ parent: element.parent,
12341
+ index: element.getIndex(),
12342
+ active: true,
12343
+ regenId: true
12358
12344
  });
12359
- }
12345
+ element.remove();
12346
+ });
12347
+ }
12348
+ function showOrHideSelection(target) {
12349
+ elementSelection.value.forEach((el) => {
12350
+ switch (target) {
12351
+ case "show":
12352
+ setVisible(el, true);
12353
+ break;
12354
+ case "hide":
12355
+ setVisible(el, false);
12356
+ break;
12357
+ default:
12358
+ setVisible(el, !isVisible(el));
12359
+ break;
12360
+ }
12361
+ });
12362
+ }
12363
+ function lockOrUnlockSelection(target) {
12364
+ selection.value.forEach((el) => {
12365
+ switch (target) {
12366
+ case "lock":
12367
+ setLock(el, true);
12368
+ break;
12369
+ case "unlock":
12370
+ setLock(el, false);
12371
+ break;
12372
+ default:
12373
+ setLock(el, !isLock(el));
12374
+ break;
12375
+ }
12376
+ });
12360
12377
  }
12361
12378
  return {
12362
12379
  name: "mce:selection",
12363
12380
  commands: [
12364
- { command: "selectAll", handle: selectAll },
12365
- { command: "deselectAll", handle: deselectAll },
12366
- { command: "selectChildren", handle: selectChildren },
12367
- { command: "selectParent", handle: selectParent },
12368
- { command: "selectPreviousSibling", handle: () => selectSibling("previous") },
12369
- { command: "selectNextSibling", handle: () => selectSibling("next") }
12381
+ { command: "select", handle: select },
12382
+ { command: "selectAll", handle: () => select("all") },
12383
+ { command: "selectInverse", handle: () => select("inverse") },
12384
+ { command: "selectNone", handle: () => select("none") },
12385
+ { command: "selectChildren", handle: () => select("children") },
12386
+ { command: "selectParent", handle: () => select("parent") },
12387
+ { command: "selectPreviousSibling", handle: () => select("previousSibling") },
12388
+ { command: "selectNextSibling", handle: () => select("nextSibling") },
12389
+ { command: "groupSelection", handle: () => groupSelection("Element") },
12390
+ { command: "ungroupSelection", handle: ungroupSelection },
12391
+ { command: "frameSelection", handle: () => groupSelection("Frame") },
12392
+ { command: "showOrHideSelection", handle: showOrHideSelection },
12393
+ { command: "lockOrUnlockSelection", handle: lockOrUnlockSelection }
12370
12394
  ],
12371
12395
  hotkeys: [
12372
12396
  { command: "selectAll", key: "CmdOrCtrl+A" },
12373
- { command: "deselectAll", key: "Shift+CmdOrCtrl+A" },
12397
+ { command: "selectInverse", key: "Shift+CmdOrCtrl+A" },
12398
+ { command: "selectNone", key: "Esc" },
12374
12399
  { command: "selectChildren", key: "Enter" },
12375
12400
  { command: "selectParent", key: "\\" },
12376
12401
  { command: "selectPreviousSibling", key: "Shift+Tab" },
12377
- { command: "selectNextSibling", key: "Tab" }
12402
+ { command: "selectNextSibling", key: "Tab" },
12403
+ { command: "groupSelection", key: "CmdOrCtrl+G" },
12404
+ { command: "ungroupSelection", key: "CmdOrCtrl+Backspace" },
12405
+ { command: "frameSelection", key: "Alt+CmdOrCtrl+G" },
12406
+ { command: "showOrHideSelection", key: "Shift+CmdOrCtrl+H" },
12407
+ { command: "lockOrUnlockSelection", key: "Shift+CmdOrCtrl+L" }
12378
12408
  ],
12379
12409
  components: [
12380
12410
  { type: "overlay", component: _sfc_main$l }
12381
- ]
12411
+ ],
12412
+ events: {
12413
+ selectionTransforming: ({ elements }) => {
12414
+ elements.forEach((el) => {
12415
+ el.findAncestor((ancestor) => {
12416
+ if (isElement(ancestor) && !inEditorIs(ancestor, "Frame")) {
12417
+ obbToFit(ancestor);
12418
+ }
12419
+ return false;
12420
+ });
12421
+ });
12422
+ }
12423
+ }
12382
12424
  };
12383
12425
  });
12384
12426
  function rotatePoint(center, point, angleRad) {
@@ -12624,6 +12666,8 @@ const _slice = definePlugin((editor) => {
12624
12666
  position: start,
12625
12667
  active: true
12626
12668
  });
12669
+ el.style.width = 1;
12670
+ el.style.height = 1;
12627
12671
  return {
12628
12672
  move: (move) => {
12629
12673
  const minX = Math.min(move.x, start.x);
@@ -12632,8 +12676,8 @@ const _slice = definePlugin((editor) => {
12632
12676
  const maxY = Math.max(move.y, start.y);
12633
12677
  el.style.left = minX;
12634
12678
  el.style.top = minY;
12635
- el.style.width = maxX - minX;
12636
- el.style.height = maxY - minY;
12679
+ el.style.width = Math.max(1, maxX - minX);
12680
+ el.style.height = Math.max(1, maxY - minY);
12637
12681
  },
12638
12682
  end: () => {
12639
12683
  setActiveDrawingTool(void 0);
@@ -14791,22 +14835,27 @@ const _transform = definePlugin((editor) => {
14791
14835
  }
14792
14836
  }
14793
14837
  const when = () => Boolean(elementSelection.value.length > 0);
14794
- function flipHorizontal() {
14795
- elementSelection.value.forEach((el) => {
14796
- el.style.scaleX = -el.style.scaleX;
14797
- });
14798
- }
14799
- function flipVertical() {
14800
- elementSelection.value.forEach((el) => {
14801
- el.style.scaleY = -el.style.scaleY;
14802
- });
14838
+ function flip2(target) {
14839
+ switch (target) {
14840
+ case "horizontal":
14841
+ elementSelection.value.forEach((el) => {
14842
+ el.style.scaleX = -el.style.scaleX;
14843
+ });
14844
+ break;
14845
+ case "vertical":
14846
+ elementSelection.value.forEach((el) => {
14847
+ el.style.scaleY = -el.style.scaleY;
14848
+ });
14849
+ break;
14850
+ }
14803
14851
  }
14804
14852
  return {
14805
14853
  name: "mce:transform",
14806
14854
  commands: [
14807
14855
  { command: "enter", handle: _enter },
14808
- { command: "flipHorizontal", handle: flipHorizontal },
14809
- { command: "flipVertical", handle: flipVertical }
14856
+ { command: "flip", handle: flip2 },
14857
+ { command: "flipHorizontal", handle: () => flip2("horizontal") },
14858
+ { command: "flipVertical", handle: () => flip2("vertical") }
14810
14859
  ],
14811
14860
  hotkeys: [
14812
14861
  { command: "enter", key: ["Enter"], when },
@@ -14879,39 +14928,6 @@ const _view = definePlugin((editor) => {
14879
14928
  ]
14880
14929
  };
14881
14930
  });
14882
- const _visibility = definePlugin((editor) => {
14883
- const {
14884
- elementSelection,
14885
- setVisible,
14886
- isVisible
14887
- } = editor;
14888
- function show() {
14889
- elementSelection.value.forEach((el) => {
14890
- setVisible(el, true);
14891
- });
14892
- }
14893
- function hide() {
14894
- elementSelection.value.forEach((el) => {
14895
- setVisible(el, false);
14896
- });
14897
- }
14898
- function hideOrShow() {
14899
- elementSelection.value.forEach((el) => {
14900
- setVisible(el, !isVisible(el));
14901
- });
14902
- }
14903
- return {
14904
- name: "mce:visibility",
14905
- commands: [
14906
- { command: "hide", handle: hide },
14907
- { command: "show", handle: show },
14908
- { command: "hide/show", handle: hideOrShow }
14909
- ],
14910
- hotkeys: [
14911
- { command: "hide/show", key: "Shift+CmdOrCtrl+H" }
14912
- ]
14913
- };
14914
- });
14915
14931
  const _zoom = definePlugin((editor) => {
14916
14932
  const {
14917
14933
  registerConfig,
@@ -14963,7 +14979,6 @@ const plugins = [
14963
14979
  _edit,
14964
14980
  _frame,
14965
14981
  _gif,
14966
- _group,
14967
14982
  _history,
14968
14983
  _hover,
14969
14984
  _html,
@@ -14971,7 +14986,6 @@ const plugins = [
14971
14986
  _import,
14972
14987
  _json,
14973
14988
  _layers,
14974
- _lock,
14975
14989
  _madeWith,
14976
14990
  _menu,
14977
14991
  _move,
@@ -14998,7 +15012,6 @@ const plugins = [
14998
15012
  _ui,
14999
15013
  _url,
15000
15014
  _view,
15001
- _visibility,
15002
15015
  _zoom
15003
15016
  ];
15004
15017
  class Editor extends Observable {
@@ -57,7 +57,8 @@ declare const _default: {
57
57
  duplicate: string;
58
58
  delete: string;
59
59
  selectAll: string;
60
- deselectAll: string;
60
+ selectInverse: string;
61
+ selectNone: string;
61
62
  selectChildren: string;
62
63
  selectParent: string;
63
64
  selectPreviousSibling: string;
@@ -90,12 +91,12 @@ declare const _default: {
90
91
  object: string;
91
92
  groupSelection: string;
92
93
  frameSelection: string;
93
- ungroup: string;
94
+ ungroupSelection: string;
94
95
  flip: string;
95
96
  flipHorizontal: string;
96
97
  flipVertical: string;
97
- 'hide/show': string;
98
- 'lock/unlock': string;
98
+ showOrHideSelection: string;
99
+ lockOrUnlockSelection: string;
99
100
  layerOrder: string;
100
101
  bringToFront: string;
101
102
  bringForward: string;
@@ -58,7 +58,8 @@ declare const _default: {
58
58
  duplicate: string;
59
59
  delete: string;
60
60
  selectAll: string;
61
- deselectAll: string;
61
+ selectInverse: string;
62
+ selectNone: string;
62
63
  selectChildren: string;
63
64
  selectParent: string;
64
65
  selectPreviousSibling: string;
@@ -91,12 +92,12 @@ declare const _default: {
91
92
  object: string;
92
93
  groupSelection: string;
93
94
  frameSelection: string;
94
- ungroup: string;
95
+ ungroupSelection: string;
95
96
  flip: string;
96
97
  flipHorizontal: string;
97
98
  flipVertical: string;
98
- 'hide/show': string;
99
- 'lock/unlock': string;
99
+ showOrHideSelection: string;
100
+ lockOrUnlockSelection: string;
100
101
  layerOrder: string;
101
102
  bringToFront: string;
102
103
  bringForward: string;
@@ -1,19 +1,41 @@
1
1
  import type { Node } from 'modern-canvas';
2
2
  declare global {
3
3
  namespace Mce {
4
- type AlignCommandDirection = 'left' | 'horizontal-center' | 'right' | 'top' | 'vertical-center' | 'bottom';
4
+ type ZOrderType = 'bringForward' | 'sendBackward' | 'bringToFront' | 'sendToBack';
5
+ type AlignDirection = 'left' | 'horizontal-center' | 'right' | 'top' | 'vertical-center' | 'bottom';
6
+ type DistributeSpacingDirection = 'horizontal' | 'vertical';
5
7
  interface Commands {
8
+ zOrder: (target: Node | Node[], type: ZOrderType) => void;
6
9
  bringForward: (target?: Node) => void;
7
10
  sendBackward: (target?: Node) => void;
8
11
  bringToFront: (target?: Node | Node[]) => void;
9
12
  sendToBack: (target?: Node | Node[]) => void;
10
- align: (direction: AlignCommandDirection) => void;
13
+ align: (direction: AlignDirection) => void;
11
14
  alignLeft: () => void;
12
15
  alignRight: () => void;
13
16
  alignTop: () => void;
14
17
  alignBottom: () => void;
15
18
  alignHorizontalCenter: () => void;
16
19
  alignVerticalCenter: () => void;
20
+ distributeSpacing: (direction: DistributeSpacingDirection) => void;
21
+ distributeHorizontalSpacing: () => void;
22
+ distributeVerticalSpacing: () => void;
23
+ tidyUp: () => void;
24
+ }
25
+ interface Hotkeys {
26
+ bringForward: [event: KeyboardEvent];
27
+ sendBackward: [event: KeyboardEvent];
28
+ bringToFront: [event: KeyboardEvent];
29
+ sendToBack: [event: KeyboardEvent];
30
+ alignLeft: [event: KeyboardEvent];
31
+ alignRight: [event: KeyboardEvent];
32
+ alignTop: [event: KeyboardEvent];
33
+ alignBottom: [event: KeyboardEvent];
34
+ alignHorizontalCenter: [event: KeyboardEvent];
35
+ alignVerticalCenter: [event: KeyboardEvent];
36
+ distributeHorizontalSpacing: [event: KeyboardEvent];
37
+ distributeVerticalSpacing: [event: KeyboardEvent];
38
+ tidyUp: [event: KeyboardEvent];
17
39
  }
18
40
  }
19
41
  }
@@ -1,20 +1,35 @@
1
+ import type { Node } from 'modern-canvas';
1
2
  declare global {
2
3
  namespace Mce {
3
- interface Hotkeys {
4
- selectAll: [event: KeyboardEvent];
5
- deselectAll: [event: KeyboardEvent];
6
- selectChildren: [event: KeyboardEvent];
7
- selectParent: [event: KeyboardEvent];
8
- selectPreviousSibling: [event: KeyboardEvent];
9
- selectNextSibling: [event: KeyboardEvent];
10
- }
4
+ type SelectTarget = 'none' | 'all' | 'inverse' | 'children' | 'parent' | 'previousSibling' | 'nextSibling' | Node[];
11
5
  interface Commands {
6
+ select: (target: SelectTarget) => void;
12
7
  selectAll: () => void;
13
- deselectAll: () => void;
8
+ selectInverse: () => void;
9
+ selectNone: () => void;
14
10
  selectChildren: () => void;
15
11
  selectParent: () => void;
16
12
  selectPreviousSibling: () => void;
17
13
  selectNextSibling: () => void;
14
+ groupSelection: () => void;
15
+ ungroupSelection: () => void;
16
+ frameSelection: () => void;
17
+ showOrHideSelection: (target?: 'show' | 'hide') => void;
18
+ lockOrUnlockSelection: (target?: 'lock' | 'unlock') => void;
19
+ }
20
+ interface Hotkeys {
21
+ selectAll: [event: KeyboardEvent];
22
+ selectInverse: [event: KeyboardEvent];
23
+ selectNone: [event: KeyboardEvent];
24
+ selectChildren: [event: KeyboardEvent];
25
+ selectParent: [event: KeyboardEvent];
26
+ selectPreviousSibling: [event: KeyboardEvent];
27
+ selectNextSibling: [event: KeyboardEvent];
28
+ groupSelection: [event: KeyboardEvent];
29
+ ungroupSelection: [event: KeyboardEvent];
30
+ frameSelection: [event: KeyboardEvent];
31
+ showOrHideSelection: [event: KeyboardEvent];
32
+ lockOrUnlockSelection: [event: KeyboardEvent];
18
33
  }
19
34
  }
20
35
  }
@@ -1,7 +1,9 @@
1
1
  declare global {
2
2
  namespace Mce {
3
+ type FlipTarget = 'horizontal' | 'vertical';
3
4
  interface Commands {
4
5
  enter: () => void;
6
+ flip: (target: Mce.FlipTarget) => void;
5
7
  flipHorizontal: () => void;
6
8
  flipVertical: () => void;
7
9
  }
@@ -34,7 +34,6 @@ import './plugins/drawingTool'
34
34
  import './plugins/edit'
35
35
  import './plugins/frame'
36
36
  import './plugins/gif'
37
- import './plugins/group'
38
37
  import './plugins/history'
39
38
  import './plugins/hover'
40
39
  import './plugins/html'
@@ -42,7 +41,6 @@ import './plugins/image'
42
41
  import './plugins/import'
43
42
  import './plugins/json'
44
43
  import './plugins/layers'
45
- import './plugins/lock'
46
44
  import './plugins/madeWith'
47
45
  import './plugins/menu'
48
46
  import './plugins/move'
@@ -69,7 +67,6 @@ import './plugins/transform'
69
67
  import './plugins/ui'
70
68
  import './plugins/url'
71
69
  import './plugins/view'
72
- import './plugins/visibility'
73
70
  import './plugins/zoom'
74
71
 
75
72
  export {}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mce",
3
3
  "type": "module",
4
- "version": "0.15.31",
4
+ "version": "0.15.32",
5
5
  "description": "The headless canvas editor framework. only the ESM.",
6
6
  "author": "wxm",
7
7
  "license": "MIT",
@@ -1,16 +0,0 @@
1
- declare global {
2
- namespace Mce {
3
- interface Commands {
4
- groupSelection: () => void;
5
- frameSelection: () => void;
6
- ungroup: () => void;
7
- }
8
- interface Hotkeys {
9
- groupSelection: [event: KeyboardEvent];
10
- frameSelection: [event: KeyboardEvent];
11
- ungroup: [event: KeyboardEvent];
12
- }
13
- }
14
- }
15
- declare const _default: import("..").Plugin;
16
- export default _default;
@@ -1,14 +0,0 @@
1
- declare global {
2
- namespace Mce {
3
- interface Commands {
4
- 'lock': () => void;
5
- 'unlock': () => void;
6
- 'lock/unlock': () => void;
7
- }
8
- interface Hotkeys {
9
- 'lock/unlock': [event: KeyboardEvent];
10
- }
11
- }
12
- }
13
- declare const _default: import("..").Plugin;
14
- export default _default;
@@ -1,14 +0,0 @@
1
- declare global {
2
- namespace Mce {
3
- interface Commands {
4
- 'hide': () => void;
5
- 'show': () => void;
6
- 'hide/show': () => void;
7
- }
8
- interface Hotkeys {
9
- 'hide/show': [event: KeyboardEvent];
10
- }
11
- }
12
- }
13
- declare const _default: import("..").Plugin;
14
- export default _default;