mce 0.13.14 → 0.13.16

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.
@@ -3,7 +3,7 @@ declare var __VLS_8: {
3
3
  props: {
4
4
  ref: (el: any) => any;
5
5
  };
6
- isActive: boolean | undefined;
6
+ isActive: boolean;
7
7
  }, __VLS_10: {};
8
8
  type __VLS_Slots = {} & {
9
9
  activator?: (props: typeof __VLS_8) => any;
@@ -2,7 +2,7 @@ declare var __VLS_1: {
2
2
  props: {
3
3
  ref: (el: any) => any;
4
4
  };
5
- isActive: boolean | undefined;
5
+ isActive: boolean;
6
6
  }, __VLS_8: {};
7
7
  type __VLS_Slots = {} & {
8
8
  activator?: (props: typeof __VLS_1) => any;
@@ -10,6 +10,7 @@ type __VLS_Slots = {} & {
10
10
  default?: (props: typeof __VLS_8) => any;
11
11
  };
12
12
  declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
13
+ modelValue: BooleanConstructor;
13
14
  location: import("vue").PropType<import("@floating-ui/vue").Side | import("@floating-ui/vue").AlignedPlacement>;
14
15
  offset: NumberConstructor;
15
16
  middlewares: {
@@ -24,18 +25,16 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
24
25
  type: import("vue").PropType<string | boolean | Element | null | undefined>;
25
26
  default: undefined;
26
27
  };
27
- modelValue: {
28
- type: import("vue").PropType<boolean>;
29
- };
30
28
  }>, {
31
29
  activatorEl: import("vue").Ref<any, any>;
32
30
  target: import("vue").ComputedRef<any>;
33
31
  contentEl: Readonly<import("vue").ShallowRef<HTMLDivElement | null>>;
34
32
  updateLocation: () => void;
35
33
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
36
- "update:modelValue": (value: boolean | undefined) => any;
34
+ "update:modelValue": (val: boolean) => any;
37
35
  "click:outside": (event: MouseEvent) => any;
38
36
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
37
+ modelValue: BooleanConstructor;
39
38
  location: import("vue").PropType<import("@floating-ui/vue").Side | import("@floating-ui/vue").AlignedPlacement>;
40
39
  offset: NumberConstructor;
41
40
  middlewares: {
@@ -50,15 +49,13 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
50
49
  type: import("vue").PropType<string | boolean | Element | null | undefined>;
51
50
  default: undefined;
52
51
  };
53
- modelValue: {
54
- type: import("vue").PropType<boolean>;
55
- };
56
52
  }>> & Readonly<{
57
- "onUpdate:modelValue"?: ((value: boolean | undefined) => any) | undefined;
53
+ "onUpdate:modelValue"?: ((val: boolean) => any) | undefined;
58
54
  "onClick:outside"?: ((event: MouseEvent) => any) | undefined;
59
55
  }>, {
60
56
  attach: string | boolean | Element | null | undefined;
61
57
  middlewares: ("shift" | "flip" | "offset")[];
58
+ modelValue: boolean;
62
59
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
63
60
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
64
61
  declare const _default: typeof __VLS_export;
@@ -5,7 +5,7 @@ declare var __VLS_8: {
5
5
  onMouseleave: () => boolean;
6
6
  ref: (el: any) => any;
7
7
  };
8
- isActive: boolean | undefined;
8
+ isActive: boolean;
9
9
  }, __VLS_10: {};
10
10
  type __VLS_Slots = {} & {
11
11
  activator?: (props: typeof __VLS_8) => any;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Node as Node$1, Element2D, Timeline, Engine, Camera2D, DrawboardEffect, IN_BROWSER, clamp, assets, TimelineNode, Transform2D, DEG_TO_RAD, render, Animation, IN_MAC_OS } from "modern-canvas";
2
- import { ref, computed, watch, markRaw, reactive, warn, shallowRef, onBeforeUnmount, defineComponent, createElementBlock, createCommentVNode, unref, openBlock, normalizeStyle, toDisplayString, createVNode, useAttrs, createBlock, resolveDynamicComponent, normalizeClass, mergeProps, createElementVNode, inject, toValue, getCurrentInstance, provide, readonly, toRef, onMounted, useId, onDeactivated, onActivated, onScopeDispose, useModel, useTemplateRef, withDirectives, vShow, vModelText, nextTick, Fragment, renderList, renderSlot, mergeModels, resolveComponent, withCtx, withModifiers, Teleport, createTextVNode, createSlots, normalizeProps, guardReactiveProps, onBeforeMount, isRef, h } from "vue";
2
+ import { ref, computed, watch, markRaw, reactive, warn, shallowRef, onBeforeUnmount, defineComponent, createElementBlock, createCommentVNode, unref, openBlock, normalizeStyle, toDisplayString, createVNode, useAttrs, createBlock, resolveDynamicComponent, normalizeClass, mergeProps, createElementVNode, inject, toValue, getCurrentInstance, provide, readonly, toRef, onMounted, useId, onDeactivated, onActivated, onScopeDispose, useModel, useTemplateRef, withDirectives, vShow, vModelText, nextTick, Fragment, renderList, renderSlot, mergeModels, resolveComponent, withCtx, withModifiers, Teleport, createTextVNode, createSlots, normalizeProps, guardReactiveProps, onBeforeMount, isRef, h, useSlots } from "vue";
3
3
  import { useFileDialog, useEventListener, isClient, onClickOutside, useDebounceFn, useResizeObserver as useResizeObserver$1, useLocalStorage, useImage } from "@vueuse/core";
4
4
  import { getObjectValueByPath, setObjectValueByPath, Observable, Reactivable, idGenerator, property, normalizeElement, normalizeTextContent, normalizeCRLF, isEqualObject } from "modern-idoc";
5
5
  import { saveAs } from "file-saver";
@@ -915,10 +915,7 @@ const _0_context = defineMixin((editor) => {
915
915
  }
916
916
  function getGlobalPointer() {
917
917
  const { x = 0, y = 0 } = drawboardPointer.value ?? {};
918
- return camera.value.toGlobal({
919
- x: x - drawboardAabb.value.left,
920
- y: y - drawboardAabb.value.top
921
- }, { x: 0, y: 0 });
918
+ return camera.value.toGlobal({ x, y }, { x: 0, y: 0 });
922
919
  }
923
920
  const block = ["top", "bottom"];
924
921
  const inline = ["start", "end", "left", "right"];
@@ -4394,8 +4391,8 @@ const _frame = definePlugin((editor) => {
4394
4391
  el.style.backgroundColor = "#ffffff";
4395
4392
  return {
4396
4393
  move: (move) => {
4397
- el.style.width = move.x - start.x;
4398
- el.style.height = move.y - start.y;
4394
+ el.style.width = Math.abs(move.x - start.x);
4395
+ el.style.height = Math.abs(move.y - start.y);
4399
4396
  },
4400
4397
  end: () => {
4401
4398
  setActiveDrawingTool(void 0);
@@ -4741,11 +4738,15 @@ const _import = definePlugin((editor) => {
4741
4738
  const {
4742
4739
  drawboardPointer,
4743
4740
  drawboardDom,
4741
+ drawboardAabb,
4744
4742
  exec
4745
4743
  } = editor;
4746
4744
  function onDragover(e) {
4747
4745
  e.preventDefault();
4748
- drawboardPointer.value = { x: e.clientX, y: e.clientY };
4746
+ drawboardPointer.value = {
4747
+ x: e.clientX - drawboardAabb.value.left,
4748
+ y: e.clientY - drawboardAabb.value.top
4749
+ };
4749
4750
  if (e.dataTransfer) {
4750
4751
  e.dataTransfer.dropEffect = "copy";
4751
4752
  }
@@ -5435,18 +5436,19 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
5435
5436
  inheritAttrs: false
5436
5437
  },
5437
5438
  __name: "Overlay",
5438
- props: /* @__PURE__ */ mergeModels({
5439
- ...makeMceOverlayProps()
5440
- }, {
5441
- "modelValue": { type: Boolean },
5442
- "modelModifiers": {}
5443
- }),
5444
- emits: /* @__PURE__ */ mergeModels(["click:outside"], ["update:modelValue"]),
5439
+ props: {
5440
+ ...makeMceOverlayProps(),
5441
+ modelValue: Boolean
5442
+ },
5443
+ emits: ["update:modelValue", "click:outside"],
5445
5444
  setup(__props, { expose: __expose, emit: __emit }) {
5446
5445
  const props = __props;
5447
5446
  const emit = __emit;
5448
5447
  const overlayItem = useOverlay();
5449
- const isActive = useModel(__props, "modelValue");
5448
+ const isActive = computed({
5449
+ get: () => props.modelValue,
5450
+ set: (val) => emit("update:modelValue", val)
5451
+ });
5450
5452
  const activatorEl = ref();
5451
5453
  const virtualElement = {
5452
5454
  getBoundingClientRect() {
@@ -5502,7 +5504,13 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
5502
5504
  emit("click:outside", e);
5503
5505
  }
5504
5506
  },
5505
- { controls: true, ignore: computed(() => [activatorEl.value]) }
5507
+ {
5508
+ controls: true,
5509
+ ignore: computed(() => [
5510
+ contentEl.value,
5511
+ activatorEl.value
5512
+ ])
5513
+ }
5506
5514
  );
5507
5515
  clearup = [
5508
5516
  stop,
@@ -10858,8 +10866,8 @@ const _shape = definePlugin((editor) => {
10858
10866
  });
10859
10867
  return {
10860
10868
  move: (move) => {
10861
- el.style.width = move.x - start.x;
10862
- el.style.height = move.y - start.y;
10869
+ el.style.width = Math.abs(move.x - start.x);
10870
+ el.style.height = Math.abs(move.y - start.y);
10863
10871
  },
10864
10872
  end: () => {
10865
10873
  setActiveDrawingTool(void 0);
@@ -14209,7 +14217,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
14209
14217
  snapThreshold,
14210
14218
  getSnapPoints
14211
14219
  } = useEditor();
14212
- const transformable = useTemplateRef("transformableRef");
14220
+ const transformable = useTemplateRef("transformableTpl");
14213
14221
  onBeforeMount(() => {
14214
14222
  registerCommand({ command: "startTransform", handle: (e) => Boolean(transformable.value?.start(e)) });
14215
14223
  });
@@ -14377,7 +14385,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
14377
14385
  }), 128)),
14378
14386
  selectionTransform.value.width && selectionTransform.value.height ? (openBlock(), createBlock(_sfc_main$a, {
14379
14387
  key: 1,
14380
- ref: "transformableRef",
14388
+ ref: "transformableTpl",
14381
14389
  modelValue: selectionTransform.value,
14382
14390
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => selectionTransform.value = $event),
14383
14391
  movable: movable.value,
@@ -14699,6 +14707,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
14699
14707
  },
14700
14708
  setup(__props) {
14701
14709
  const props = __props;
14710
+ const slots = useSlots();
14702
14711
  let editor;
14703
14712
  if (props.editor) {
14704
14713
  editor = props.editor;
@@ -14981,7 +14990,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
14981
14990
  if (event.srcElement !== drawboardDom.value) {
14982
14991
  return;
14983
14992
  }
14984
- drawboardPointer.value = { x: event.clientX, y: event.clientY };
14993
+ drawboardPointer.value = {
14994
+ x: event.clientX - drawboardAabb.value.left,
14995
+ y: event.clientY - drawboardAabb.value.top
14996
+ };
14985
14997
  if (camera.value.grabbing || event.button === 1 || state.value && state.value !== "typing") {
14986
14998
  return;
14987
14999
  }
@@ -15052,7 +15064,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
15052
15064
  ]),
15053
15065
  _: 3
15054
15066
  }, 8, ["selected-area", "resize-strategy"]),
15055
- _ctx.$slots.floatbar || _ctx.$slots["floatbar-top"] ? (openBlock(), createBlock(_sfc_main$b, {
15067
+ slots.floatbar || slots["floatbar-top"] ? (openBlock(), createBlock(_sfc_main$b, {
15056
15068
  key: 0,
15057
15069
  location: "top-start",
15058
15070
  target: unref(state) === "typing" ? textEditor.value?.textEditor : selector.value?.transformable?.$el
@@ -15063,7 +15075,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
15063
15075
  ]),
15064
15076
  _: 3
15065
15077
  }, 8, ["target"])) : createCommentVNode("", true),
15066
- _ctx.$slots["floatbar-bottom"] ? (openBlock(), createBlock(_sfc_main$b, {
15078
+ slots["floatbar-bottom"] ? (openBlock(), createBlock(_sfc_main$b, {
15067
15079
  key: 1,
15068
15080
  location: "bottom-start",
15069
15081
  target: selector.value?.transformable?.$el
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mce",
3
3
  "type": "module",
4
- "version": "0.13.14",
4
+ "version": "0.13.16",
5
5
  "description": "The headless canvas editor framework. only the ESM.",
6
6
  "author": "wxm",
7
7
  "license": "MIT",