mce 0.13.1 → 0.13.2

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.
@@ -16,8 +16,8 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
16
16
  type: import("vue").PropType<("offset" | "flip" | "shift")[]>;
17
17
  default: () => string[];
18
18
  }, "type" | "default"> & {
19
- type: import("vue").PropType<any[] | ("shift" | "offset" | "flip")[]>;
20
- default: any[] | ("shift" | "offset" | "flip")[];
19
+ type: import("vue").PropType<any[] | ("shift" | "flip" | "offset")[]>;
20
+ default: any[] | ("shift" | "flip" | "offset")[];
21
21
  };
22
22
  target: import("vue").PropType<{
23
23
  x: number;
@@ -42,8 +42,8 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
42
42
  type: import("vue").PropType<("offset" | "flip" | "shift")[]>;
43
43
  default: () => string[];
44
44
  }, "type" | "default"> & {
45
- type: import("vue").PropType<any[] | ("shift" | "offset" | "flip")[]>;
46
- default: any[] | ("shift" | "offset" | "flip")[];
45
+ type: import("vue").PropType<any[] | ("shift" | "flip" | "offset")[]>;
46
+ default: any[] | ("shift" | "flip" | "offset")[];
47
47
  };
48
48
  target: import("vue").PropType<{
49
49
  x: number;
@@ -57,7 +57,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
57
57
  offset: number;
58
58
  location: import("@floating-ui/vue").Side | "left-end" | "left-start" | "right-end" | "right-start" | "top-end" | "top-start" | "bottom-end" | "bottom-start";
59
59
  attach: string | boolean | Element | null | undefined;
60
- middlewares: any[] | ("shift" | "offset" | "flip")[];
60
+ middlewares: any[] | ("shift" | "flip" | "offset")[];
61
61
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
62
62
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
63
63
  declare const _default: typeof __VLS_export;
@@ -1,6 +1,6 @@
1
1
  import type { AxisAlignedBoundingBox, OrientedBoundingBox } from '../types';
2
2
  type __VLS_Props = {
3
- resizeStrategy?: 'free' | 'aspectRatio' | 'diagonalAspectRatio';
3
+ resizeStrategy?: 'aspectRatio' | 'diagonalAspectRatio';
4
4
  selectedArea?: AxisAlignedBoundingBox;
5
5
  };
6
6
  declare var __VLS_12: {
@@ -26,11 +26,11 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
26
26
  $props: {
27
27
  readonly tag?: string | any;
28
28
  readonly modelValue?: Partial<OrientedBoundingBox> | undefined;
29
- readonly moveable?: boolean | undefined;
29
+ readonly movable?: boolean | undefined;
30
30
  readonly rotatable?: boolean | undefined;
31
31
  readonly resizable?: boolean | undefined;
32
32
  readonly threshold?: number | undefined;
33
- readonly resizeStrategy?: "free" | "aspectRatio" | "diagonalAspectRatio" | undefined;
33
+ readonly resizeStrategy?: "aspectRatio" | "diagonalAspectRatio" | undefined;
34
34
  readonly handleStrategy?: "default" | "point" | undefined;
35
35
  readonly handleShape?: "rect" | "circle" | undefined;
36
36
  readonly color?: string | undefined;
@@ -62,11 +62,11 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
62
62
  $options: import("vue").ComponentOptionsBase<Readonly<{
63
63
  tag?: string | any;
64
64
  modelValue?: Partial<OrientedBoundingBox>;
65
- moveable?: boolean;
65
+ movable?: boolean;
66
66
  rotatable?: boolean;
67
67
  resizable?: boolean;
68
68
  threshold?: number;
69
- resizeStrategy?: "free" | "aspectRatio" | "diagonalAspectRatio";
69
+ resizeStrategy?: "aspectRatio" | "diagonalAspectRatio";
70
70
  handleStrategy?: "default" | "point";
71
71
  handleShape?: "rect" | "circle";
72
72
  color?: string;
@@ -93,11 +93,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
93
93
  }, string, {
94
94
  color: string;
95
95
  visibility: "visible" | "none" | "auto";
96
+ movable: boolean;
97
+ rotatable: boolean;
96
98
  resizable: boolean;
97
99
  tag: string | any;
98
- resizeStrategy: "free" | "aspectRatio" | "diagonalAspectRatio";
99
- moveable: boolean;
100
- rotatable: boolean;
101
100
  threshold: number;
102
101
  handleStrategy: "default" | "point";
103
102
  handleColor: string;
@@ -125,11 +124,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
125
124
  } & Readonly<{
126
125
  color: string;
127
126
  visibility: "visible" | "none" | "auto";
127
+ movable: boolean;
128
+ rotatable: boolean;
128
129
  resizable: boolean;
129
130
  tag: string | any;
130
- resizeStrategy: "free" | "aspectRatio" | "diagonalAspectRatio";
131
- moveable: boolean;
132
- rotatable: boolean;
133
131
  threshold: number;
134
132
  handleStrategy: "default" | "point";
135
133
  handleColor: string;
@@ -137,11 +135,11 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
137
135
  }> & Omit<Readonly<{
138
136
  tag?: string | any;
139
137
  modelValue?: Partial<OrientedBoundingBox>;
140
- moveable?: boolean;
138
+ movable?: boolean;
141
139
  rotatable?: boolean;
142
140
  resizable?: boolean;
143
141
  threshold?: number;
144
- resizeStrategy?: "free" | "aspectRatio" | "diagonalAspectRatio";
142
+ resizeStrategy?: "aspectRatio" | "diagonalAspectRatio";
145
143
  handleStrategy?: "default" | "point";
146
144
  handleShape?: "rect" | "circle";
147
145
  color?: string;
@@ -156,7 +154,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
156
154
  onEnd?: ((args_0: OrientedBoundingBox) => any) | undefined;
157
155
  onStart?: ((args_0: OrientedBoundingBox) => any) | undefined;
158
156
  "onUpdate:modelValue"?: ((args_0: OrientedBoundingBox) => any) | undefined;
159
- }>, "start" | "transforming" | "activeHandle" | ("color" | "visibility" | "resizable" | "tag" | "resizeStrategy" | "moveable" | "rotatable" | "threshold" | "handleStrategy" | "handleColor" | "handles")> & import("vue").ShallowUnwrapRef<{
157
+ }>, "start" | "transforming" | "activeHandle" | ("color" | "visibility" | "movable" | "rotatable" | "resizable" | "tag" | "threshold" | "handleStrategy" | "handleColor" | "handles")> & import("vue").ShallowUnwrapRef<{
160
158
  start: (event?: MouseEvent, index?: number) => boolean;
161
159
  activeHandle: import("vue").Ref<("move" | "rotate-top-left" | "rotate-top-right" | "rotate-bottom-left" | "rotate-bottom-right" | "resize-top" | "resize-right" | "resize-bottom" | "resize-left" | "resize-top-left" | "resize-top-right" | "resize-bottom-left" | "resize-bottom-right") | undefined, ("move" | "rotate-top-left" | "rotate-top-right" | "rotate-bottom-left" | "rotate-bottom-right" | "resize-top" | "resize-right" | "resize-bottom" | "resize-left" | "resize-top-left" | "resize-top-right" | "resize-bottom-left" | "resize-bottom-right") | undefined>;
162
160
  transforming: import("vue").Ref<boolean, boolean>;
@@ -55,7 +55,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
55
55
  "onUpdate:modelValue"?: ((value: boolean | undefined) => any) | undefined;
56
56
  }>, {
57
57
  attach: string | boolean | Element | null | undefined;
58
- middlewares: ("shift" | "offset" | "flip")[];
58
+ middlewares: ("shift" | "flip" | "offset")[];
59
59
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
60
60
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
61
61
  declare const _default: typeof __VLS_export;
@@ -67,7 +67,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
67
67
  "onClick:item"?: ((item: MenuItem, event: MouseEvent) => any) | undefined;
68
68
  }>, {
69
69
  attach: string | boolean | Element | null | undefined;
70
- middlewares: ("shift" | "offset" | "flip")[];
70
+ middlewares: ("shift" | "flip" | "offset")[];
71
71
  openOnHover: boolean;
72
72
  persistent: boolean;
73
73
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -60,7 +60,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
60
60
  "onUpdate:modelValue"?: ((val: boolean) => any) | undefined;
61
61
  }>, {
62
62
  attach: string | boolean | Element | null | undefined;
63
- middlewares: ("shift" | "offset" | "flip")[];
63
+ middlewares: ("shift" | "flip" | "offset")[];
64
64
  modelValue: boolean;
65
65
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
66
66
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -68,7 +68,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
68
68
  offset: number;
69
69
  location: import("@floating-ui/vue").Side | "left-end" | "left-start" | "right-end" | "right-start" | "top-end" | "top-start" | "bottom-end" | "bottom-start";
70
70
  attach: string | boolean | Element | null | undefined;
71
- middlewares: ("shift" | "offset" | "flip")[];
71
+ middlewares: ("shift" | "flip" | "offset")[];
72
72
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
73
73
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
74
74
  declare const _default: typeof __VLS_export;
@@ -3,11 +3,11 @@ type Handle = 'move' | 'rotate-top-left' | 'rotate-top-right' | 'rotate-bottom-l
3
3
  type __VLS_Props = {
4
4
  tag?: string | any;
5
5
  modelValue?: Partial<OrientedBoundingBox>;
6
- moveable?: boolean;
6
+ movable?: boolean;
7
7
  rotatable?: boolean;
8
8
  resizable?: boolean;
9
9
  threshold?: number;
10
- resizeStrategy?: 'free' | 'aspectRatio' | 'diagonalAspectRatio';
10
+ resizeStrategy?: 'aspectRatio' | 'diagonalAspectRatio';
11
11
  handleStrategy?: 'default' | 'point';
12
12
  handleShape?: 'rect' | 'circle';
13
13
  color?: string;
@@ -56,11 +56,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
56
56
  }>, {
57
57
  color: string;
58
58
  visibility: "visible" | "none" | "auto";
59
+ movable: boolean;
60
+ rotatable: boolean;
59
61
  resizable: boolean;
60
62
  tag: string | any;
61
- resizeStrategy: "free" | "aspectRatio" | "diagonalAspectRatio";
62
- moveable: boolean;
63
- rotatable: boolean;
64
63
  threshold: number;
65
64
  handleStrategy: "default" | "point";
66
65
  handleColor: string;
@@ -34,8 +34,8 @@ export declare const makeMceOverlayProps: <Defaults extends {
34
34
  type: PropType<("offset" | "flip" | "shift")[]>;
35
35
  default: () => string[];
36
36
  }, "type" | "default"> & {
37
- type: PropType<unknown extends Defaults["middlewares"] ? ("shift" | "offset" | "flip")[] : ("shift" | "offset" | "flip")[] | Defaults["middlewares"]>;
38
- default: unknown extends Defaults["middlewares"] ? ("shift" | "offset" | "flip")[] : ("shift" | "offset" | "flip")[] | Defaults["middlewares"];
37
+ type: PropType<unknown extends Defaults["middlewares"] ? ("shift" | "flip" | "offset")[] : ("shift" | "flip" | "offset")[] | Defaults["middlewares"]>;
38
+ default: unknown extends Defaults["middlewares"] ? ("shift" | "flip" | "offset")[] : ("shift" | "flip" | "offset")[] | Defaults["middlewares"];
39
39
  };
40
40
  target: unknown extends Defaults["target"] ? PropType<{
41
41
  x: number;
@@ -8,7 +8,7 @@ export interface ActiveStrategyContext {
8
8
  }
9
9
  export interface HoverStrategyContext extends ActiveStrategyContext {
10
10
  }
11
- export type ResizeStrategy = (element: Element2D) => 'free' | 'aspectRatio' | 'diagonalAspectRatio';
11
+ export type ResizeStrategy = (element: Element2D) => 'aspectRatio' | 'diagonalAspectRatio' | undefined;
12
12
  export type ActiveStrategy = (context: ActiveStrategyContext) => {
13
13
  element: Element2D | undefined;
14
14
  state: Mce.State | undefined;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
+ import { Node as Node$1, Element2D, Timeline, Engine, Camera2D, DrawboardEffect, IN_BROWSER, clamp, assets, TimelineNode, Transform2D, DEG_TO_RAD, render, Animation } from "modern-canvas";
1
2
  import { ref, computed, watch, markRaw, reactive, warn, shallowRef, onBeforeUnmount, onMounted, inject, provide, defineComponent, createVNode, mergeProps, createElementVNode, toValue, getCurrentInstance, onScopeDispose, createElementBlock, openBlock, Fragment, renderList, unref, normalizeStyle, normalizeClass, readonly, toRef, useId, onDeactivated, onActivated, useAttrs, createBlock, resolveDynamicComponent, useTemplateRef, renderSlot, Teleport, createCommentVNode, mergeModels, useModel, resolveComponent, withCtx, createTextVNode, toDisplayString, createSlots, normalizeProps, guardReactiveProps, onBeforeMount, withDirectives, vShow, vModelText, nextTick, withModifiers, isRef } from "vue";
2
3
  import { useFileDialog, useEventListener, isClient, useResizeObserver as useResizeObserver$1, useLocalStorage, onClickOutside, useMouse, useDebounceFn } from "@vueuse/core";
3
- import { Node as Node$1, Element2D, Timeline, Engine, Camera2D, DrawboardEffect, IN_BROWSER, clamp, assets, TimelineNode, Transform2D, DEG_TO_RAD, render, Animation } from "modern-canvas";
4
4
  import { getObjectValueByPath, setObjectValueByPath, Observable, Reactivable, idGenerator, property, normalizeElement, normalizeTextContent } from "modern-idoc";
5
5
  import { saveAs } from "file-saver";
6
6
  import { Fonts } from "modern-font";
@@ -900,6 +900,13 @@ const _0_context = defineMixin((editor) => {
900
900
  const root = computed(() => doc.value.root);
901
901
  const nodes = ref([]);
902
902
  const nodeIndexMap = reactive(/* @__PURE__ */ new Map());
903
+ const selection = ref([]);
904
+ const elementSelection = computed({
905
+ get: () => selection.value.filter((v) => v instanceof Element2D),
906
+ set: (val) => selection.value = val
907
+ });
908
+ const textSelection = ref();
909
+ const hoverElement = ref();
903
910
  const drawboardPointer = ref();
904
911
  const state = ref();
905
912
  const stateContext = ref();
@@ -933,6 +940,10 @@ const _0_context = defineMixin((editor) => {
933
940
  root,
934
941
  nodes,
935
942
  nodeIndexMap,
943
+ selection,
944
+ elementSelection,
945
+ textSelection,
946
+ hoverElement,
936
947
  drawboardDom,
937
948
  drawboardAabb,
938
949
  state,
@@ -945,7 +956,8 @@ const _0_context = defineMixin((editor) => {
945
956
  return () => {
946
957
  const {
947
958
  on,
948
- root: root2
959
+ root: root2,
960
+ state: state2
949
961
  } = editor;
950
962
  function updateNodes(value) {
951
963
  let node;
@@ -963,30 +975,10 @@ const _0_context = defineMixin((editor) => {
963
975
  nodeIndexMap.set(node.id, nodes.value.length - 1);
964
976
  }
965
977
  on("setDoc", () => updateNodes());
966
- };
967
- });
968
- const _0_element = defineMixin((editor) => {
969
- const selection = ref([]);
970
- const elementSelection = computed({
971
- get: () => selection.value.filter((v) => v instanceof Element2D),
972
- set: (val) => selection.value = val
973
- });
974
- const hoverElement = ref();
975
- const textSelection = ref();
976
- Object.assign(editor, {
977
- selection,
978
- elementSelection,
979
- textSelection,
980
- hoverElement
981
- });
982
- return () => {
983
- const {
984
- state
985
- } = editor;
986
978
  watch(selection, (value) => {
987
979
  window.$$0 = value[0];
988
980
  });
989
- watch(state, () => {
981
+ watch(state2, () => {
990
982
  textSelection.value = void 0;
991
983
  hoverElement.value = void 0;
992
984
  });
@@ -1481,7 +1473,9 @@ function createTextElement(content, style) {
1481
1473
  height: box.height
1482
1474
  },
1483
1475
  text: { content: normalizeTextContent(content) },
1484
- meta: { inPptIs: "Shape" }
1476
+ meta: {
1477
+ inPptIs: "Shape"
1478
+ }
1485
1479
  };
1486
1480
  }
1487
1481
  async function createImageElement(image) {
@@ -1491,7 +1485,10 @@ async function createImageElement(image) {
1491
1485
  ...await getImageSizeFromUrl(image)
1492
1486
  },
1493
1487
  foreground: { image },
1494
- meta: { inPptIs: "Picture" }
1488
+ meta: {
1489
+ inPptIs: "Picture",
1490
+ lockAspectRatio: true
1491
+ }
1495
1492
  };
1496
1493
  }
1497
1494
  function isClickInsideElement(event, targetDiv) {
@@ -2261,64 +2258,41 @@ const _3_view = defineMixin((editor) => {
2261
2258
  });
2262
2259
  const _4_0_text = defineMixin((editor) => {
2263
2260
  const {
2264
- config
2261
+ config,
2262
+ isElement
2265
2263
  } = editor;
2266
2264
  function textFontSizeToFit(element) {
2267
2265
  function _handle(element2) {
2268
- const chars = element2.text.base.characters;
2269
- let pos = 0;
2270
- let char;
2271
- chars.forEach((_char) => {
2272
- const _pos = _char.lineBox.left + _char.lineBox.width;
2273
- if (_pos > pos) {
2274
- char = _char;
2275
- pos = _pos;
2276
- }
2277
- });
2278
- const style = {};
2279
- const content = chars.filter((_char) => _char.lineBox.top === char?.lineBox.top).map((char2) => {
2280
- Object.assign(
2281
- style,
2282
- { ...char2.parent.style },
2283
- { ...char2.parent.parent.style }
2284
- );
2285
- return char2.content;
2286
- }).join("");
2266
+ if (!element2.text.isValid()) {
2267
+ return;
2268
+ }
2287
2269
  const { boundingBox } = measureText({
2288
2270
  style: {
2289
2271
  ...element2.style.toJSON(),
2290
2272
  width: "auto"
2291
2273
  },
2292
- content: [
2293
- {
2294
- fragments: [
2295
- { ...style, content }
2296
- ]
2297
- }
2298
- ]
2274
+ content: element2.text.content
2299
2275
  });
2300
2276
  const fontSize = (element2.style.fontSize || 12) / 2;
2301
2277
  const scale = (element2.style.width ?? 0) / (boundingBox.width + fontSize);
2302
- function _scaleStyle(style2) {
2303
- if (style2.fontSize)
2304
- style2.fontSize = style2.fontSize * scale;
2305
- if (style2.letterSpacing)
2306
- style2.letterSpacing = style2.letterSpacing * scale;
2278
+ function _scaleStyle(style) {
2279
+ if (style.fontSize)
2280
+ style.fontSize = style.fontSize * scale;
2281
+ if (style.letterSpacing)
2282
+ style.letterSpacing = style.letterSpacing * scale;
2307
2283
  }
2308
2284
  _scaleStyle(element2.style);
2309
- if (element2.text?.isValid?.() && Array.isArray(element2.text?.content)) {
2310
- element2.text.content.forEach((p) => {
2311
- _scaleStyle(p);
2312
- p.fragments.forEach((f) => {
2313
- _scaleStyle(f);
2314
- });
2285
+ element2.text.content.forEach((p) => {
2286
+ _scaleStyle(p);
2287
+ p.fragments.forEach((f) => {
2288
+ _scaleStyle(f);
2315
2289
  });
2316
- }
2290
+ });
2317
2291
  element2.requestRedraw();
2318
2292
  }
2319
2293
  _handle(element);
2320
2294
  element.findOne((descendant) => {
2321
- if (descendant instanceof Element2D) {
2295
+ if (isElement(descendant)) {
2322
2296
  _handle(descendant);
2323
2297
  }
2324
2298
  return false;
@@ -2333,7 +2307,7 @@ const _4_0_text = defineMixin((editor) => {
2333
2307
  return;
2334
2308
  }
2335
2309
  function _handle(element2) {
2336
- if (!element2.text?.isValid?.() || typeof element2.text?.content !== "object") {
2310
+ if (!element2.text.isValid()) {
2337
2311
  return;
2338
2312
  }
2339
2313
  const style = element2.style.toJSON();
@@ -2357,7 +2331,7 @@ const _4_0_text = defineMixin((editor) => {
2357
2331
  }
2358
2332
  _handle(element);
2359
2333
  element.findOne((descendant) => {
2360
- if (descendant instanceof Element2D) {
2334
+ if (isElement(descendant)) {
2361
2335
  _handle(descendant);
2362
2336
  }
2363
2337
  return false;
@@ -2597,23 +2571,6 @@ const _4_2_element = defineMixin((editor) => {
2597
2571
  options.textToFit && textToFit(element);
2598
2572
  options.textFontSizeToFit && textFontSizeToFit(element);
2599
2573
  }
2600
- function pointerActivateElement(element, event) {
2601
- if (element && (event?.ctrlKey || event?.shiftKey || event?.metaKey)) {
2602
- let elements;
2603
- if (selection.value.length === 1) {
2604
- elements = [selection.value[0], element];
2605
- } else {
2606
- if (selection.value.findIndex((v) => v.equal(element)) > -1) {
2607
- elements = selection.value.filter((v) => v.equal(element));
2608
- } else {
2609
- elements = [...selection.value, element];
2610
- }
2611
- }
2612
- selection.value = elements;
2613
- } else {
2614
- selection.value = element ? [element] : [];
2615
- }
2616
- }
2617
2574
  function selectArea(areaInDrawboard) {
2618
2575
  const selected = root.value?.children.flatMap((node) => {
2619
2576
  if (isFrame(node)) {
@@ -2632,7 +2589,6 @@ const _4_2_element = defineMixin((editor) => {
2632
2589
  updateElement,
2633
2590
  getElement,
2634
2591
  resizeElement,
2635
- pointerActivateElement,
2636
2592
  selectArea
2637
2593
  });
2638
2594
  });
@@ -3119,7 +3075,6 @@ const mixins = [
3119
3075
  _0_config,
3120
3076
  _0_config_base,
3121
3077
  _0_context,
3122
- _0_element,
3123
3078
  _0_font,
3124
3079
  _0_helper,
3125
3080
  _0_locale,
@@ -5184,26 +5139,49 @@ const _layerPosition = definePlugin((editor) => {
5184
5139
  } = editor;
5185
5140
  function align(direction) {
5186
5141
  elementSelection.value.forEach((el) => {
5187
- const box = el.parent && isElement(el.parent) ? getAabb(el.parent) : rootAabb.value;
5188
- switch (direction) {
5189
- case "left":
5190
- el.style.left = 0;
5191
- break;
5192
- case "horizontal-center":
5193
- el.style.left = (box.width - el.style.width) / 2;
5194
- break;
5195
- case "right":
5196
- el.style.left = box.width - el.style.width;
5197
- break;
5198
- case "top":
5199
- el.style.top = 0;
5200
- break;
5201
- case "vertical-center":
5202
- el.style.top = (box.height - el.style.height) / 2;
5203
- break;
5204
- case "bottom":
5205
- el.style.top = box.height - el.style.height;
5206
- break;
5142
+ if (el.parent && isElement(el.parent)) {
5143
+ const parentAabb = getAabb(el.parent);
5144
+ switch (direction) {
5145
+ case "left":
5146
+ el.style.left = 0;
5147
+ break;
5148
+ case "horizontal-center":
5149
+ el.style.left = (parentAabb.width - el.style.width) / 2;
5150
+ break;
5151
+ case "right":
5152
+ el.style.left = parentAabb.width - el.style.width;
5153
+ break;
5154
+ case "top":
5155
+ el.style.top = 0;
5156
+ break;
5157
+ case "vertical-center":
5158
+ el.style.top = (parentAabb.height - el.style.height) / 2;
5159
+ break;
5160
+ case "bottom":
5161
+ el.style.top = parentAabb.height - el.style.height;
5162
+ break;
5163
+ }
5164
+ } else {
5165
+ switch (direction) {
5166
+ case "left":
5167
+ el.style.left = rootAabb.value.left;
5168
+ break;
5169
+ case "horizontal-center":
5170
+ el.style.left = (rootAabb.value.left + rootAabb.value.width - el.style.width) / 2;
5171
+ break;
5172
+ case "right":
5173
+ el.style.left = rootAabb.value.left + rootAabb.value.width - el.style.width;
5174
+ break;
5175
+ case "top":
5176
+ el.style.top = rootAabb.value.top;
5177
+ break;
5178
+ case "vertical-center":
5179
+ el.style.top = (rootAabb.value.top + rootAabb.value.height - el.style.height) / 2;
5180
+ break;
5181
+ case "bottom":
5182
+ el.style.top = rootAabb.value.top + rootAabb.value.height - el.style.height;
5183
+ break;
5184
+ }
5207
5185
  }
5208
5186
  });
5209
5187
  }
@@ -6212,14 +6190,10 @@ const makeMceStrategyProps = propsFactory({
6212
6190
  hoverStrategy: Function
6213
6191
  }, "makeMceStrategyProps");
6214
6192
  const defaultResizeStrategy = (element) => {
6215
- switch (element.meta?.inPptIs) {
6216
- case "Picture":
6217
- return "diagonalAspectRatio";
6218
- }
6219
- if (element.foreground.isValid()) {
6220
- return "diagonalAspectRatio";
6193
+ if (element.meta.lockAspectRatio) {
6194
+ return "aspectRatio";
6221
6195
  }
6222
- return "free";
6196
+ return void 0;
6223
6197
  };
6224
6198
  const defaultActiveStrategy = (context) => {
6225
6199
  const { element, oldElement, isExcluded } = context;
@@ -8133,11 +8107,11 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8133
8107
  props: {
8134
8108
  tag: { default: "div" },
8135
8109
  modelValue: {},
8136
- moveable: { type: Boolean, default: true },
8110
+ movable: { type: Boolean, default: true },
8137
8111
  rotatable: { type: Boolean, default: true },
8138
8112
  resizable: { type: Boolean, default: true },
8139
8113
  threshold: { default: 0 },
8140
- resizeStrategy: { default: "free" },
8114
+ resizeStrategy: {},
8141
8115
  handleStrategy: { default: "default" },
8142
8116
  handleShape: {},
8143
8117
  color: { default: "black" },
@@ -8276,39 +8250,34 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8276
8250
  event?.preventDefault();
8277
8251
  event?.stopPropagation();
8278
8252
  const { left = 0, top = 0, width = 0, height = 0, rotate = 0 } = model.value;
8279
- const aspectRatio = width && height ? width / height : 0;
8280
- const anchor = index === void 0 ? { type: "move", x: 0, y: 0, width: 0, height: 0 } : computedHandles.value[index];
8281
- activeHandle.value = anchor.type;
8282
- const isMove = anchor.type === "move";
8283
- const isRotate = anchor.type.startsWith("rotate");
8284
- const isHorizontal = anchor.type === "resize-left" || anchor.type === "resize-right";
8285
- const isHorizontalVertical = anchor.type.split("-").length === 2;
8253
+ let aspectRatio = 0;
8254
+ if (width && height) {
8255
+ aspectRatio = width / height;
8256
+ }
8257
+ const handle = index === void 0 ? { type: "move", x: 0, y: 0, width: 0, height: 0 } : computedHandles.value[index];
8258
+ activeHandle.value = handle.type;
8259
+ const isMove = handle.type === "move";
8260
+ const isRotate = handle.type.startsWith("rotate");
8261
+ const isHorizontal = handle.type === "resize-left" || handle.type === "resize-right";
8262
+ const isHorizontalVertical = handle.type.split("-").length === 2;
8286
8263
  const centerPoint = {
8287
8264
  x: left + width / 2,
8288
8265
  y: top + height / 2
8289
8266
  };
8290
- const startingPointBefore = {
8291
- x: left,
8292
- y: top
8267
+ const startPoint = {
8268
+ x: left + handle.x + handle.width / 2,
8269
+ y: top + handle.y + handle.height / 2
8293
8270
  };
8294
- if (!isMove) {
8295
- startingPointBefore.x += anchor.x + anchor.width / 2;
8296
- startingPointBefore.y += anchor.y + anchor.height / 2;
8297
- }
8298
- const startingPoint = calcRotation(
8299
- startingPointBefore,
8300
- centerPoint,
8301
- isMove ? 0 : rotate
8302
- );
8303
- const symmetricPoint = {
8304
- x: centerPoint.x * 2 - startingPoint.x,
8305
- y: centerPoint.y * 2 - startingPoint.y
8271
+ const rotatedStartPoint = rotatePoint(startPoint, centerPoint, rotate);
8272
+ const rotatedSymmetricPoint = {
8273
+ x: centerPoint.x * 2 - rotatedStartPoint.x,
8274
+ y: centerPoint.y * 2 - rotatedStartPoint.y
8306
8275
  };
8307
- const rotationBefore = Math.atan2(
8308
- startingPoint.y - centerPoint.y,
8309
- startingPoint.x - centerPoint.x
8276
+ const startAngle = Math.atan2(
8277
+ rotatedStartPoint.y - centerPoint.y,
8278
+ rotatedStartPoint.x - centerPoint.x
8310
8279
  ) / (Math.PI / 180);
8311
- let client = event ? { x: event.clientX, y: event.clientY } : void 0;
8280
+ let startClientPoint = event ? { x: event.clientX, y: event.clientY } : void 0;
8312
8281
  function startTransform() {
8313
8282
  transforming.value = true;
8314
8283
  emit("start", model.value);
@@ -8318,81 +8287,67 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8318
8287
  }
8319
8288
  function onMove(event2) {
8320
8289
  const updated = {};
8321
- if (!client) {
8322
- client = { x: event2.clientX, y: event2.clientY };
8290
+ if (!startClientPoint) {
8291
+ startClientPoint = { x: event2.clientX, y: event2.clientY };
8323
8292
  }
8324
- const clientOffset = {
8325
- x: event2.clientX - client.x,
8326
- y: event2.clientY - client.y
8293
+ const offset2 = {
8294
+ x: event2.clientX - startClientPoint.x,
8295
+ y: event2.clientY - startClientPoint.y
8327
8296
  };
8328
8297
  if (!transforming.value) {
8329
- if (Math.abs(clientOffset.x) < props.threshold && Math.abs(clientOffset.y) < props.threshold) {
8298
+ if (Math.abs(offset2.x) < props.threshold && Math.abs(offset2.y) < props.threshold) {
8330
8299
  return;
8331
8300
  }
8332
8301
  startTransform();
8333
8302
  }
8334
- const cursorPoint = {
8335
- x: startingPoint.x + clientOffset.x,
8336
- y: startingPoint.y + clientOffset.y
8303
+ const rotatedCurrentPoint = {
8304
+ x: rotatedStartPoint.x + offset2.x,
8305
+ y: rotatedStartPoint.y + offset2.y
8337
8306
  };
8338
8307
  if (isMove) {
8339
- if (!props.moveable) {
8340
- return;
8308
+ if (props.movable) {
8309
+ updated.left = startPoint.x + offset2.x;
8310
+ updated.top = startPoint.y + offset2.y;
8341
8311
  }
8342
- updated.left = cursorPoint.x;
8343
- updated.top = cursorPoint.y;
8344
8312
  } else if (isRotate) {
8345
- const rotationAfter = Math.atan2(
8346
- cursorPoint.y - centerPoint.y,
8347
- cursorPoint.x - centerPoint.x
8348
- ) / (Math.PI / 180);
8349
- updated.rotate = (rotate + rotationAfter - rotationBefore + 360) % 360;
8313
+ if (props.rotatable) {
8314
+ const endAngle = Math.atan2(
8315
+ rotatedCurrentPoint.y - centerPoint.y,
8316
+ rotatedCurrentPoint.x - centerPoint.x
8317
+ ) / (Math.PI / 180);
8318
+ updated.rotate = (rotate + endAngle - startAngle + 360) % 360;
8319
+ }
8350
8320
  } else if (isHorizontalVertical) {
8351
- const rotationBefore2 = calcRotation(cursorPoint, startingPoint, -rotate);
8352
- const rotationAfter = calcRotation(
8353
- isHorizontal ? { x: rotationBefore2.x, y: startingPoint.y } : { x: startingPoint.x, y: rotationBefore2.y },
8354
- startingPoint,
8355
- rotate
8356
- );
8357
- const newCenterPoint = {
8358
- x: rotationAfter.x - (rotationAfter.x - symmetricPoint.x) / 2,
8359
- y: rotationAfter.y + (symmetricPoint.y - rotationAfter.y) / 2
8360
- };
8361
- const hypotenuse = calcHypotenuse(rotationAfter, symmetricPoint);
8321
+ const currentPoint = rotatePoint(rotatedCurrentPoint, centerPoint, -rotate);
8322
+ const newCurrentPoint = isHorizontal ? { x: currentPoint.x, y: startPoint.y } : { x: startPoint.x, y: currentPoint.y };
8323
+ const newRotatedCurrentPoint = rotatePoint(newCurrentPoint, centerPoint, rotate);
8324
+ const hypotenuse = Math.abs(getDistance(newRotatedCurrentPoint, rotatedSymmetricPoint));
8362
8325
  if (isHorizontal) {
8363
8326
  updated.width = hypotenuse;
8364
- if (aspectRatio && props.resizeStrategy === "aspectRatio") {
8327
+ if (props.resizeStrategy === "aspectRatio" && aspectRatio) {
8365
8328
  updated.height = hypotenuse / aspectRatio;
8329
+ } else {
8330
+ updated.height = height;
8366
8331
  }
8367
8332
  } else {
8368
8333
  updated.height = hypotenuse;
8369
- if (aspectRatio && props.resizeStrategy === "aspectRatio") {
8334
+ if (props.resizeStrategy === "aspectRatio" && aspectRatio) {
8370
8335
  updated.width = hypotenuse * aspectRatio;
8371
- }
8372
- }
8373
- updated.left = newCenterPoint.x - (isHorizontal ? hypotenuse : width) / 2;
8374
- updated.top = newCenterPoint.y - (isHorizontal ? height : hypotenuse) / 2;
8375
- } else {
8376
- if (aspectRatio && (props.resizeStrategy === "aspectRatio" || props.resizeStrategy === "diagonalAspectRatio")) {
8377
- let flag = 1;
8378
- switch (anchor.type) {
8379
- case "resize-top-right":
8380
- case "resize-bottom-left":
8381
- flag = -1;
8382
- break;
8383
- }
8384
- if (clientOffset.x > clientOffset.y) {
8385
- cursorPoint.x = startingPoint.x + clientOffset.x;
8386
- cursorPoint.y = startingPoint.y + flag * clientOffset.x / aspectRatio;
8387
8336
  } else {
8388
- cursorPoint.x = startingPoint.x + flag * clientOffset.y * aspectRatio;
8389
- cursorPoint.y = startingPoint.y + clientOffset.y;
8337
+ updated.width = width;
8390
8338
  }
8391
8339
  }
8392
- const newCenterPoint = calcCenter(cursorPoint, symmetricPoint);
8340
+ const newCenterPoint = {
8341
+ x: newRotatedCurrentPoint.x - (newRotatedCurrentPoint.x - rotatedSymmetricPoint.x) / 2,
8342
+ y: newRotatedCurrentPoint.y + (rotatedSymmetricPoint.y - newRotatedCurrentPoint.y) / 2
8343
+ };
8344
+ updated.left = newCenterPoint.x - updated.width / 2;
8345
+ updated.top = newCenterPoint.y - updated.height / 2;
8346
+ } else {
8347
+ const newCenterPoint = getMidpoint(rotatedCurrentPoint, rotatedSymmetricPoint);
8393
8348
  const points = [
8394
- calcRotation(cursorPoint, newCenterPoint, -rotate),
8395
- calcRotation(symmetricPoint, newCenterPoint, -rotate)
8349
+ rotatePoint(rotatedCurrentPoint, newCenterPoint, -rotate),
8350
+ rotatePoint(rotatedSymmetricPoint, newCenterPoint, -rotate)
8396
8351
  ];
8397
8352
  const [minX, maxX] = points[0].x > points[1].x ? [points[1].x, points[0].x] : [points[0].x, points[1].x];
8398
8353
  const [minY, maxY] = points[0].y > points[1].y ? [points[1].y, points[0].y] : [points[0].y, points[1].y];
@@ -8400,6 +8355,13 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8400
8355
  updated.height = maxY - minY;
8401
8356
  updated.left = minX;
8402
8357
  updated.top = minY;
8358
+ if ((props.resizeStrategy === "aspectRatio" || props.resizeStrategy === "diagonalAspectRatio") && aspectRatio) {
8359
+ if (updated.width / updated.height > aspectRatio) {
8360
+ updated.width = updated.height * aspectRatio;
8361
+ } else {
8362
+ updated.height = updated.width / aspectRatio;
8363
+ }
8364
+ }
8403
8365
  }
8404
8366
  if ("width" in updated && updated.width <= 0 || "height" in updated && updated.height <= 0) {
8405
8367
  return;
@@ -8433,7 +8395,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8433
8395
  return "move";
8434
8396
  return `url("data:image/svg+xml,${cursors[type](model.value.rotate ?? 0)}") 16 16, pointer`;
8435
8397
  }
8436
- function calcRotation(point, origin, angle) {
8398
+ function rotatePoint(point, origin, angle) {
8437
8399
  const radian = angle * Math.PI / 180;
8438
8400
  const cos = Math.cos(radian);
8439
8401
  const sin = Math.sin(radian);
@@ -8442,14 +8404,16 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8442
8404
  y: (point.x - origin.x) * sin + (point.y - origin.y) * cos + origin.y
8443
8405
  };
8444
8406
  }
8445
- function calcCenter(point1, point2) {
8407
+ function getMidpoint(point1, point2) {
8446
8408
  return {
8447
8409
  x: (point2.x + point1.x) / 2,
8448
8410
  y: (point2.y + point1.y) / 2
8449
8411
  };
8450
8412
  }
8451
- function calcHypotenuse(point1, point2) {
8452
- return Math.sqrt((point1.x - point2.x) ** 2 + (point1.y - point2.y) ** 2);
8413
+ function getDistance(point1, point2) {
8414
+ const dx = point2.x - point1.x;
8415
+ const dy = point2.y - point1.y;
8416
+ return (dx + dy >= 0 ? 1 : -1) * Math.sqrt(dx * dx + dy * dy);
8453
8417
  }
8454
8418
  onMounted(async () => {
8455
8419
  const vm = getCurrentInstance();
@@ -8514,7 +8478,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8514
8478
  }, null, 4),
8515
8479
  createElementVNode("g", _hoisted_2$5, [
8516
8480
  (openBlock(true), createElementBlock(Fragment, null, renderList(computedHandles.value.filter((v) => {
8517
- return !(!__props.resizable && v.type.startsWith("resize") || !__props.rotatable && v.type.startsWith("rotate") || !__props.moveable && v.type === "move");
8481
+ return !(!__props.resizable && v.type.startsWith("resize") || !__props.rotatable && v.type.startsWith("rotate") || !__props.movable && v.type === "move");
8518
8482
  }), (handle, index) => {
8519
8483
  return openBlock(), createElementBlock(Fragment, { key: index }, [
8520
8484
  (__props.handleStrategy === "point" ? handle.type.startsWith("resize") : handle.type === "resize-top-left" || handle.type === "resize-top-right" || handle.type === "resize-bottom-left" || handle.type === "resize-bottom-right") ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
@@ -8641,8 +8605,8 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
8641
8605
  const offsetBox = {
8642
8606
  left: Math.round((val.left - oldBox.left) / zoom.x),
8643
8607
  top: Math.round((val.top - oldBox.top) / zoom.y),
8644
- width: Math.round((val.width - oldBox.width) / zoom.x),
8645
- height: Math.round((val.height - oldBox.height) / zoom.y),
8608
+ width: Math.round(Math.max(1, val.width / zoom.x) - oldBox.width / zoom.x),
8609
+ height: Math.round(Math.max(1, val.height / zoom.y) - oldBox.height / zoom.y),
8646
8610
  rotate: Math.round((val.rotate ?? 0) - (oldBox.rotate ?? 0))
8647
8611
  };
8648
8612
  const handle = transformable.value?.activeHandle ?? "move";
@@ -8721,7 +8685,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
8721
8685
  modelValue: selectionObb.value,
8722
8686
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => selectionObb.value = $event),
8723
8687
  visibility: unref(state) !== "selecting" ? "auto" : "none",
8724
- moveable: unref(elementSelection)[0] && !unref(isLock)(unref(elementSelection)[0]),
8688
+ movable: unref(elementSelection)[0] && !unref(isLock)(unref(elementSelection)[0]),
8725
8689
  "resize-strategy": props.resizeStrategy,
8726
8690
  "handle-shape": unref(config).handleShape,
8727
8691
  class: "mce-selection-obb",
@@ -8737,7 +8701,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
8737
8701
  ]),
8738
8702
  key: "0"
8739
8703
  } : void 0
8740
- ]), 1032, ["modelValue", "visibility", "moveable", "resize-strategy", "handle-shape", "border-style"])) : createCommentVNode("", true),
8704
+ ]), 1032, ["modelValue", "visibility", "movable", "resize-strategy", "handle-shape", "border-style"])) : createCommentVNode("", true),
8741
8705
  selectionObb.value.width && selectionObb.value.height && _ctx.$slots.default ? (openBlock(), createElementBlock("div", {
8742
8706
  key: 2,
8743
8707
  style: normalizeStyle([{ "position": "absolute" }, unref(boundingBoxToStyle)(selectionObb.value)])
@@ -9489,6 +9453,16 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9489
9453
  const selector = useTemplateRef("selectorTpl");
9490
9454
  const textEditor = useTemplateRef("textEditorTpl");
9491
9455
  const selectedArea = ref({ left: 0, top: 0, width: 0, height: 0 });
9456
+ const resizeStrategy = computed(() => {
9457
+ const first = elementSelection.value[0];
9458
+ if (first) {
9459
+ if (first.text.isValid()) {
9460
+ return "diagonalAspectRatio";
9461
+ }
9462
+ return props.resizeStrategy(first);
9463
+ }
9464
+ return void 0;
9465
+ });
9492
9466
  provideOverlay({
9493
9467
  attach: computed(() => overlayContainer.value)
9494
9468
  });
@@ -9539,28 +9513,28 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9539
9513
  hoverElement.value = hovered;
9540
9514
  setCursor(cursor);
9541
9515
  }
9542
- function onPointerdown(event) {
9543
- if (event.srcElement !== drawboardDom.value && event.srcElement.dataset?.pointerdown_to_drawboard === void 0 || camera.value.spaceKey || ![0, 2].includes(event.button)) {
9516
+ function onPointerdown(downEvent) {
9517
+ if (downEvent.srcElement !== drawboardDom.value && downEvent.srcElement.dataset?.pointerdown_to_drawboard === void 0 || camera.value.spaceKey || ![0, 2].includes(downEvent.button)) {
9544
9518
  return;
9545
9519
  }
9546
9520
  const oldElement = elementSelection.value[0];
9547
- const element = event.target;
9548
- const start = { x: event.clientX, y: event.clientY };
9521
+ const element = downEvent.target;
9522
+ const start = { x: downEvent.clientX, y: downEvent.clientY };
9549
9523
  let current = { ...start };
9550
9524
  let dragging = false;
9551
9525
  let isUp = false;
9552
9526
  let selected = [];
9553
9527
  let ctxState;
9554
- const inSelected = isPointInsideAabb({
9528
+ const inSelection = isPointInsideAabb({
9555
9529
  x: start.x + -drawboardAabb.value.left,
9556
9530
  y: start.y + -drawboardAabb.value.top
9557
9531
  }, getAabbInDrawboard(elementSelection.value));
9558
- if (event.button === 2) {
9559
- if (!inSelected) {
9532
+ if (downEvent.button === 2) {
9533
+ if (!inSelection) {
9560
9534
  const result = props.activeStrategy({
9561
9535
  element,
9562
9536
  oldElement,
9563
- event,
9537
+ event: downEvent,
9564
9538
  isExcluded
9565
9539
  });
9566
9540
  if (result && !(result instanceof Element2D)) {
@@ -9572,11 +9546,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9572
9546
  }
9573
9547
  return;
9574
9548
  }
9575
- function onDrag(event2) {
9549
+ function onDrag(event) {
9576
9550
  const result = props.activeStrategy({
9577
9551
  element,
9578
9552
  oldElement,
9579
- event: event2,
9553
+ event,
9580
9554
  isExcluded
9581
9555
  });
9582
9556
  if (result && !(result instanceof Element2D)) {
@@ -9602,7 +9576,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9602
9576
  const result = props.activeStrategy({
9603
9577
  element,
9604
9578
  oldElement,
9605
- event,
9579
+ event: downEvent,
9606
9580
  isExcluded: () => false
9607
9581
  });
9608
9582
  let _element;
@@ -9612,7 +9586,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9612
9586
  } else {
9613
9587
  _element = result;
9614
9588
  }
9615
- if (_element && (event?.ctrlKey || event?.shiftKey || event?.metaKey)) {
9589
+ if (_element && (downEvent?.ctrlKey || downEvent?.shiftKey || downEvent?.metaKey)) {
9616
9590
  if (elementSelection.value.findIndex((v) => v.equal(_element)) > -1) {
9617
9591
  selected = elementSelection.value.filter((v) => !v.equal(_element));
9618
9592
  } else {
@@ -9625,29 +9599,29 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9625
9599
  function canStartDrag() {
9626
9600
  return !dragging && (Math.abs(current.x - start.x) >= 3 || Math.abs(current.y - start.y) >= 3);
9627
9601
  }
9628
- function onEngineMove(event2) {
9629
- if (inSelected) {
9602
+ function onEngineMove(moveEvent) {
9603
+ if (inSelection) {
9630
9604
  if (canStartDrag()) {
9631
9605
  dragging = true;
9632
- exec("startTransform");
9606
+ exec("startTransform", downEvent);
9633
9607
  }
9634
9608
  } else {
9635
9609
  if (element && !isFrame(element)) {
9636
9610
  if (canStartDrag()) {
9637
9611
  dragging = true;
9638
- onDrag(event2);
9612
+ onDrag(moveEvent);
9639
9613
  nextTick(() => {
9640
9614
  if (!isUp) {
9641
- exec("startTransform");
9615
+ exec("startTransform", downEvent);
9642
9616
  }
9643
9617
  });
9644
9618
  }
9645
9619
  }
9646
9620
  }
9647
9621
  }
9648
- function onMove(event2) {
9649
- current = { x: event2.clientX, y: event2.clientY };
9650
- if (!inSelected) {
9622
+ function onMove(moveEvent) {
9623
+ current = { x: moveEvent.clientX, y: moveEvent.clientY };
9624
+ if (!inSelection) {
9651
9625
  if (!element || isFrame(element)) {
9652
9626
  onSelectArea();
9653
9627
  }
@@ -9672,7 +9646,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9672
9646
  }
9673
9647
  }
9674
9648
  }
9675
- onHover(event);
9649
+ onHover(downEvent);
9676
9650
  }
9677
9651
  renderEngine.value.off("pointermove", onEngineMove);
9678
9652
  document.removeEventListener("pointermove", onMove);
@@ -9733,7 +9707,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9733
9707
  createVNode(_sfc_main$g, {
9734
9708
  ref: "selectorTpl",
9735
9709
  "selected-area": selectedArea.value,
9736
- "resize-strategy": unref(elementSelection)[0] ? props.resizeStrategy(unref(elementSelection)[0]) : void 0
9710
+ "resize-strategy": resizeStrategy.value
9737
9711
  }, {
9738
9712
  transformable: withCtx(({ box }) => [
9739
9713
  renderSlot(_ctx.$slots, "transformer", { box })
@@ -1,7 +1,7 @@
1
1
  import type { Cursor, Node, Vector2Data } from 'modern-canvas';
2
2
  import type { ComputedRef, Ref } from 'vue';
3
3
  import type { AxisAlignedBoundingBox } from '../types';
4
- import { Camera2D, DrawboardEffect, Engine, Timeline } from 'modern-canvas';
4
+ import { Camera2D, DrawboardEffect, Element2D, Engine, Timeline } from 'modern-canvas';
5
5
  import { Fonts } from 'modern-font';
6
6
  import { Doc } from '../models';
7
7
  declare global {
@@ -20,6 +20,10 @@ declare global {
20
20
  root: ComputedRef<Node>;
21
21
  nodes: Ref<Node[]>;
22
22
  nodeIndexMap: Map<string, number>;
23
+ selection: Ref<Node[]>;
24
+ elementSelection: Ref<Element2D[]>;
25
+ textSelection: Ref<any[] | undefined>;
26
+ hoverElement: Ref<Element2D | undefined>;
23
27
  state: Ref<State | undefined>;
24
28
  setState: (state: State, context?: StateContext) => void;
25
29
  stateContext: Ref<StateContext | undefined>;
@@ -1,4 +1,4 @@
1
- import { Element2D } from 'modern-canvas';
1
+ import type { Element2D } from 'modern-canvas';
2
2
  declare global {
3
3
  namespace Mce {
4
4
  interface Editor {
@@ -26,7 +26,6 @@ declare global {
26
26
  updateElement: (id: string, properties: Record<string, any>) => void;
27
27
  getElement: (id: string) => Element2D | undefined;
28
28
  resizeElement: (element: Element2D, width: number, height: number, options?: ResizeElementOptions) => void;
29
- pointerActivateElement: (element: Element2D | undefined, event?: MouseEvent | PointerEvent) => void;
30
29
  selectArea: (areaInDrawboard: AxisAlignedBoundingBox) => Element2D[];
31
30
  }
32
31
  interface Events {
@@ -1,3 +1,19 @@
1
+ import 'modern-canvas'
2
+
3
+ declare module 'modern-canvas' {
4
+ interface Meta {
5
+ inPptIs?: 'Pptx' | 'Picture' | 'Shape' | 'GroupShape' | 'Animation'
6
+ inEditorIs?: 'Doc' | 'Frame' | 'Element' | 'Node'
7
+ inCanvasIs?: 'Lottie2D' | 'Element2D' | 'Animation'
8
+ lock?: boolean
9
+ lockAspectRatio?: boolean
10
+ movable?: boolean
11
+ rotatable?: boolean
12
+ resizable?: boolean
13
+ transformable?: boolean
14
+ }
15
+ }
16
+
1
17
  declare global {
2
18
  namespace Mce {
3
19
  interface Editor {}
@@ -6,7 +6,6 @@ import './mixins/0.command'
6
6
  import './mixins/0.config'
7
7
  import './mixins/0.config/base'
8
8
  import './mixins/0.context'
9
- import './mixins/0.element'
10
9
  import './mixins/0.font'
11
10
  import './mixins/0.helper'
12
11
  import './mixins/0.locale'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mce",
3
3
  "type": "module",
4
- "version": "0.13.1",
4
+ "version": "0.13.2",
5
5
  "description": "The headless canvas editor framework. only the ESM.",
6
6
  "author": "wxm",
7
7
  "license": "MIT",
@@ -1,15 +0,0 @@
1
- import type { Node } from 'modern-canvas';
2
- import type { Ref } from 'vue';
3
- import { Element2D } from 'modern-canvas';
4
- declare global {
5
- namespace Mce {
6
- interface Editor {
7
- selection: Ref<Node[]>;
8
- elementSelection: Ref<Element2D[]>;
9
- textSelection: Ref<any[] | undefined>;
10
- hoverElement: Ref<Element2D | undefined>;
11
- }
12
- }
13
- }
14
- declare const _default: import("..").Mixin;
15
- export default _default;