mce 0.13.4 → 0.13.5
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.
- package/dist/components/EditorLayout.vue.d.ts +11 -6
- package/dist/components/shared/Transformable.vue.d.ts +2 -2
- package/dist/composables/strategy.d.ts +13 -2
- package/dist/index.css +1 -1
- package/dist/index.js +120 -74
- package/dist/mixins/0.helper.d.ts +1 -1
- package/dist/plugins/ui.d.ts +3 -3
- package/package.json +2 -2
|
@@ -21,13 +21,15 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
21
21
|
type: import("vue").PropType<import("..").ActiveStrategy>;
|
|
22
22
|
default: import("..").ActiveStrategy;
|
|
23
23
|
};
|
|
24
|
+
doubleclickStrategy: {
|
|
25
|
+
type: import("vue").PropType<import("..").DoubleclickStrategy>;
|
|
26
|
+
default: import("..").DoubleclickStrategy;
|
|
27
|
+
};
|
|
24
28
|
hoverStrategy: {
|
|
25
29
|
type: import("vue").PropType<import("..").HoverStrategy>;
|
|
26
30
|
default: import("..").HoverStrategy;
|
|
27
31
|
};
|
|
28
|
-
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
29
|
-
"dblclick:drawboard": (event: Event) => any;
|
|
30
|
-
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
32
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
31
33
|
editor: typeof Editor;
|
|
32
34
|
resizeStrategy: {
|
|
33
35
|
type: import("vue").PropType<import("..").ResizeStrategy>;
|
|
@@ -37,15 +39,18 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
37
39
|
type: import("vue").PropType<import("..").ActiveStrategy>;
|
|
38
40
|
default: import("..").ActiveStrategy;
|
|
39
41
|
};
|
|
42
|
+
doubleclickStrategy: {
|
|
43
|
+
type: import("vue").PropType<import("..").DoubleclickStrategy>;
|
|
44
|
+
default: import("..").DoubleclickStrategy;
|
|
45
|
+
};
|
|
40
46
|
hoverStrategy: {
|
|
41
47
|
type: import("vue").PropType<import("..").HoverStrategy>;
|
|
42
48
|
default: import("..").HoverStrategy;
|
|
43
49
|
};
|
|
44
|
-
}>> & Readonly<{
|
|
45
|
-
"onDblclick:drawboard"?: ((event: Event) => any) | undefined;
|
|
46
|
-
}>, {
|
|
50
|
+
}>> & Readonly<{}>, {
|
|
47
51
|
resizeStrategy: import("..").ResizeStrategy;
|
|
48
52
|
activeStrategy: import("..").ActiveStrategy;
|
|
53
|
+
doubleclickStrategy: import("..").DoubleclickStrategy;
|
|
49
54
|
hoverStrategy: import("..").HoverStrategy;
|
|
50
55
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
51
56
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -27,7 +27,7 @@ declare var __VLS_7: {
|
|
|
27
27
|
onPointerdown: typeof start;
|
|
28
28
|
};
|
|
29
29
|
start: typeof start;
|
|
30
|
-
},
|
|
30
|
+
}, __VLS_14: {
|
|
31
31
|
box: {
|
|
32
32
|
left: number;
|
|
33
33
|
top: number;
|
|
@@ -40,7 +40,7 @@ declare var __VLS_7: {
|
|
|
40
40
|
type __VLS_Slots = {} & {
|
|
41
41
|
default?: (props: typeof __VLS_7) => any;
|
|
42
42
|
} & {
|
|
43
|
-
svg?: (props: typeof
|
|
43
|
+
svg?: (props: typeof __VLS_14) => any;
|
|
44
44
|
};
|
|
45
45
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
46
46
|
start: typeof start;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { Element2D, PointerInputEvent } from 'modern-canvas';
|
|
2
2
|
import type { PropType } from 'vue';
|
|
3
|
+
import type { Editor } from '../editor';
|
|
3
4
|
export interface ActiveStrategyContext {
|
|
4
5
|
element: Element2D | undefined;
|
|
5
|
-
oldElement: Element2D | undefined;
|
|
6
6
|
event: PointerInputEvent;
|
|
7
|
-
|
|
7
|
+
editor: Editor;
|
|
8
|
+
}
|
|
9
|
+
export interface DoubleclickStrategyContext {
|
|
10
|
+
event: PointerInputEvent;
|
|
11
|
+
editor: Editor;
|
|
8
12
|
}
|
|
9
13
|
export interface HoverStrategyContext extends ActiveStrategyContext {
|
|
10
14
|
}
|
|
@@ -13,6 +17,7 @@ export type ActiveStrategy = (context: ActiveStrategyContext) => {
|
|
|
13
17
|
element: Element2D | undefined;
|
|
14
18
|
state: Mce.State | undefined;
|
|
15
19
|
} | Element2D | undefined;
|
|
20
|
+
export type DoubleclickStrategy = (context: DoubleclickStrategyContext) => Mce.State | undefined;
|
|
16
21
|
export type HoverStrategy = (context: HoverStrategyContext) => {
|
|
17
22
|
element: Element2D | undefined;
|
|
18
23
|
cursor: string | undefined;
|
|
@@ -20,6 +25,7 @@ export type HoverStrategy = (context: HoverStrategyContext) => {
|
|
|
20
25
|
export declare const makeMceStrategyProps: <Defaults extends {
|
|
21
26
|
resizeStrategy?: unknown;
|
|
22
27
|
activeStrategy?: unknown;
|
|
28
|
+
doubleclickStrategy?: unknown;
|
|
23
29
|
hoverStrategy?: unknown;
|
|
24
30
|
} = {}>(defaults?: Defaults | undefined) => {
|
|
25
31
|
resizeStrategy: unknown extends Defaults["resizeStrategy"] ? PropType<ResizeStrategy> : {
|
|
@@ -30,6 +36,10 @@ export declare const makeMceStrategyProps: <Defaults extends {
|
|
|
30
36
|
type: PropType<unknown extends Defaults["activeStrategy"] ? ActiveStrategy : ActiveStrategy | Defaults["activeStrategy"]>;
|
|
31
37
|
default: unknown extends Defaults["activeStrategy"] ? ActiveStrategy : ActiveStrategy | Defaults["activeStrategy"];
|
|
32
38
|
};
|
|
39
|
+
doubleclickStrategy: unknown extends Defaults["doubleclickStrategy"] ? PropType<DoubleclickStrategy> : {
|
|
40
|
+
type: PropType<unknown extends Defaults["doubleclickStrategy"] ? DoubleclickStrategy : DoubleclickStrategy | Defaults["doubleclickStrategy"]>;
|
|
41
|
+
default: unknown extends Defaults["doubleclickStrategy"] ? DoubleclickStrategy : DoubleclickStrategy | Defaults["doubleclickStrategy"];
|
|
42
|
+
};
|
|
33
43
|
hoverStrategy: unknown extends Defaults["hoverStrategy"] ? PropType<HoverStrategy> : {
|
|
34
44
|
type: PropType<unknown extends Defaults["hoverStrategy"] ? HoverStrategy : HoverStrategy | Defaults["hoverStrategy"]>;
|
|
35
45
|
default: unknown extends Defaults["hoverStrategy"] ? HoverStrategy : HoverStrategy | Defaults["hoverStrategy"];
|
|
@@ -37,4 +47,5 @@ export declare const makeMceStrategyProps: <Defaults extends {
|
|
|
37
47
|
};
|
|
38
48
|
export declare const defaultResizeStrategy: ResizeStrategy;
|
|
39
49
|
export declare const defaultActiveStrategy: ActiveStrategy;
|
|
50
|
+
export declare const defaultDoubleclickStrategy: DoubleclickStrategy;
|
|
40
51
|
export declare const defaultHoverStrategy: HoverStrategy;
|
package/dist/index.css
CHANGED
|
@@ -498,7 +498,7 @@
|
|
|
498
498
|
.mce-transformable--dashed .mce-transformable__rect {
|
|
499
499
|
stroke-dasharray: 4px;
|
|
500
500
|
}
|
|
501
|
-
.mce-transformable--
|
|
501
|
+
.mce-transformable--resizing .mce-transformable__diagonal {
|
|
502
502
|
visibility: visible;
|
|
503
503
|
}
|
|
504
504
|
.mce-transformable--moving .mce-transformable__handle {
|
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 } from "modern-canvas";
|
|
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
|
+
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, h, isRef } from "vue";
|
|
3
3
|
import { useFileDialog, useEventListener, isClient, useResizeObserver as useResizeObserver$1, useLocalStorage, onClickOutside, useMouse, useDebounceFn } from "@vueuse/core";
|
|
4
4
|
import { getObjectValueByPath, setObjectValueByPath, Observable, Reactivable, idGenerator, property, normalizeElement, normalizeTextContent } from "modern-idoc";
|
|
5
5
|
import { saveAs } from "file-saver";
|
|
@@ -1054,8 +1054,8 @@ const _0_helper = defineMixin((editor) => {
|
|
|
1054
1054
|
function isElement(value) {
|
|
1055
1055
|
return value instanceof Element2D;
|
|
1056
1056
|
}
|
|
1057
|
-
function isFrame(
|
|
1058
|
-
return isElement(
|
|
1057
|
+
function isFrame(value) {
|
|
1058
|
+
return isElement(value) && value.meta.inEditorIs === "Frame";
|
|
1059
1059
|
}
|
|
1060
1060
|
function isVisible(node) {
|
|
1061
1061
|
return isElement(node) && node.style.visibility === "visible";
|
|
@@ -1432,11 +1432,11 @@ function getImageSizeFromUrl(url, opts = {}) {
|
|
|
1432
1432
|
if (timer)
|
|
1433
1433
|
clearTimeout(timer);
|
|
1434
1434
|
const w = this.naturalWidth;
|
|
1435
|
-
const
|
|
1436
|
-
if (!w || !
|
|
1435
|
+
const h2 = this.naturalHeight;
|
|
1436
|
+
if (!w || !h2) {
|
|
1437
1437
|
reject(new Error("failed to read natural size"));
|
|
1438
1438
|
} else {
|
|
1439
|
-
resolve({ width: w, height:
|
|
1439
|
+
resolve({ width: w, height: h2 });
|
|
1440
1440
|
}
|
|
1441
1441
|
};
|
|
1442
1442
|
img.onerror = function() {
|
|
@@ -6214,6 +6214,7 @@ function useOverlay() {
|
|
|
6214
6214
|
const makeMceStrategyProps = propsFactory({
|
|
6215
6215
|
resizeStrategy: Function,
|
|
6216
6216
|
activeStrategy: Function,
|
|
6217
|
+
doubleclickStrategy: Function,
|
|
6217
6218
|
hoverStrategy: Function
|
|
6218
6219
|
}, "makeMceStrategyProps");
|
|
6219
6220
|
const defaultResizeStrategy = (element) => {
|
|
@@ -6223,32 +6224,49 @@ const defaultResizeStrategy = (element) => {
|
|
|
6223
6224
|
return void 0;
|
|
6224
6225
|
};
|
|
6225
6226
|
const defaultActiveStrategy = (context) => {
|
|
6226
|
-
const { element,
|
|
6227
|
-
if (
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6227
|
+
const { element, editor } = context;
|
|
6228
|
+
if (!element) {
|
|
6229
|
+
return void 0;
|
|
6230
|
+
}
|
|
6231
|
+
const { isRoot, isFrame, isElement, elementSelection } = editor;
|
|
6232
|
+
const activeElement = elementSelection.value[0];
|
|
6233
|
+
const cb = (node) => {
|
|
6234
|
+
if (isElement(node) && (node.equal(activeElement) || node.parent?.equal(activeElement) || node.parent?.equal(activeElement?.parent) || isFrame(node.parent) && isRoot(node.parent.parent) || isRoot(node.parent) && !isFrame(node))) {
|
|
6235
|
+
return true;
|
|
6235
6236
|
}
|
|
6237
|
+
return false;
|
|
6238
|
+
};
|
|
6239
|
+
if (cb(element)) {
|
|
6236
6240
|
return element;
|
|
6237
6241
|
}
|
|
6242
|
+
return element.findAncestor(cb);
|
|
6243
|
+
};
|
|
6244
|
+
const defaultDoubleclickStrategy = (context) => {
|
|
6245
|
+
const { editor } = context;
|
|
6246
|
+
const { elementSelection } = editor;
|
|
6247
|
+
const element = elementSelection.value[0];
|
|
6248
|
+
if (element) {
|
|
6249
|
+
return element.foreground.isValid() ? void 0 : "typing";
|
|
6250
|
+
}
|
|
6238
6251
|
return void 0;
|
|
6239
6252
|
};
|
|
6240
6253
|
const defaultHoverStrategy = (context) => {
|
|
6241
|
-
const { element,
|
|
6242
|
-
if (
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6254
|
+
const { element, editor } = context;
|
|
6255
|
+
if (!element) {
|
|
6256
|
+
return void 0;
|
|
6257
|
+
}
|
|
6258
|
+
const { isRoot, isFrame, isElement, elementSelection } = editor;
|
|
6259
|
+
const activeElement = elementSelection.value[0];
|
|
6260
|
+
const cb = (node) => {
|
|
6261
|
+
if (isElement(node) && (node.equal(activeElement) || node.parent?.equal(activeElement) || node.parent?.equal(activeElement?.parent) || isFrame(node.parent) && isRoot(node.parent.parent) || isRoot(node.parent) && !isFrame(node))) {
|
|
6262
|
+
return true;
|
|
6248
6263
|
}
|
|
6264
|
+
return false;
|
|
6265
|
+
};
|
|
6266
|
+
if (cb(element)) {
|
|
6249
6267
|
return element;
|
|
6250
6268
|
}
|
|
6251
|
-
return
|
|
6269
|
+
return element.findAncestor(cb);
|
|
6252
6270
|
};
|
|
6253
6271
|
const _hoisted_1$l = { class: "mce-auxiliary" };
|
|
6254
6272
|
const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
@@ -8122,31 +8140,15 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
8122
8140
|
});
|
|
8123
8141
|
const _hoisted_1$a = { class: "mce-transformable__svg" };
|
|
8124
8142
|
const _hoisted_2$5 = ["rx", "ry"];
|
|
8125
|
-
const _hoisted_3$5 =
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
x2: "0",
|
|
8131
|
-
y2: "100%"
|
|
8132
|
-
};
|
|
8133
|
-
const _hoisted_4$3 = {
|
|
8134
|
-
key: 1,
|
|
8135
|
-
class: "mce-transformable__diagonal",
|
|
8136
|
-
x1: "0",
|
|
8137
|
-
y1: "0",
|
|
8138
|
-
x2: "100%",
|
|
8139
|
-
y2: "100%"
|
|
8140
|
-
};
|
|
8141
|
-
const _hoisted_5$2 = ["x", "y", "width", "height", "aria-label"];
|
|
8142
|
-
const _hoisted_6$2 = ["cx", "cy", "r", "aria-label"];
|
|
8143
|
-
const _hoisted_7$2 = { "pointer-events": "all" };
|
|
8144
|
-
const _hoisted_8$1 = ["x", "y", "width", "height", "aria-label", "cursor", "onPointerdown"];
|
|
8145
|
-
const _hoisted_9$1 = {
|
|
8143
|
+
const _hoisted_3$5 = ["x", "y", "width", "height", "aria-label"];
|
|
8144
|
+
const _hoisted_4$3 = ["cx", "cy", "r", "aria-label"];
|
|
8145
|
+
const _hoisted_5$2 = { "pointer-events": "all" };
|
|
8146
|
+
const _hoisted_6$2 = ["x", "y", "width", "height", "aria-label", "cursor", "onPointerdown"];
|
|
8147
|
+
const _hoisted_7$2 = {
|
|
8146
8148
|
"pointer-events": "all",
|
|
8147
8149
|
class: "mce-transformable__svg-slot"
|
|
8148
8150
|
};
|
|
8149
|
-
const
|
|
8151
|
+
const _hoisted_8$1 = {
|
|
8150
8152
|
key: 0,
|
|
8151
8153
|
class: "mce-transformable__tip"
|
|
8152
8154
|
};
|
|
@@ -8583,6 +8585,41 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8583
8585
|
activeHandle,
|
|
8584
8586
|
transforming
|
|
8585
8587
|
});
|
|
8588
|
+
function Diagonal() {
|
|
8589
|
+
const handle = activeHandle.value;
|
|
8590
|
+
if (!handle || !handle.startsWith("resize")) {
|
|
8591
|
+
return void 0;
|
|
8592
|
+
}
|
|
8593
|
+
switch (props.resizeStrategy) {
|
|
8594
|
+
case "lockAspectRatio":
|
|
8595
|
+
break;
|
|
8596
|
+
case "lockAspectRatioDiagonal":
|
|
8597
|
+
if (handle.split("-").length === 2) {
|
|
8598
|
+
return void 0;
|
|
8599
|
+
}
|
|
8600
|
+
break;
|
|
8601
|
+
default:
|
|
8602
|
+
return void 0;
|
|
8603
|
+
}
|
|
8604
|
+
if (handle === "resize-top" || handle === "resize-right" || handle === "resize-top-right" || handle === "resize-bottom-left") {
|
|
8605
|
+
return h("line", {
|
|
8606
|
+
class: "mce-transformable__diagonal",
|
|
8607
|
+
x1: "100%",
|
|
8608
|
+
y1: "0",
|
|
8609
|
+
x2: "0",
|
|
8610
|
+
y2: "100%"
|
|
8611
|
+
});
|
|
8612
|
+
} else if (handle === "resize-left" || handle === "resize-bottom" || handle === "resize-top-left" || handle === "resize-bottom-right") {
|
|
8613
|
+
return h("line", {
|
|
8614
|
+
class: "mce-transformable__diagonal",
|
|
8615
|
+
x1: "0",
|
|
8616
|
+
y1: "0",
|
|
8617
|
+
x2: "100%",
|
|
8618
|
+
y2: "100%"
|
|
8619
|
+
});
|
|
8620
|
+
}
|
|
8621
|
+
return void 0;
|
|
8622
|
+
}
|
|
8586
8623
|
return (_ctx, _cache) => {
|
|
8587
8624
|
return openBlock(), createBlock(resolveDynamicComponent(__props.tag), {
|
|
8588
8625
|
class: normalizeClass(["mce-transformable", [
|
|
@@ -8620,7 +8657,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8620
8657
|
rx: model.value.borderRadius,
|
|
8621
8658
|
ry: model.value.borderRadius
|
|
8622
8659
|
}, null, 8, _hoisted_2$5),
|
|
8623
|
-
|
|
8660
|
+
createVNode(Diagonal),
|
|
8624
8661
|
createElementVNode("g", null, [
|
|
8625
8662
|
(openBlock(true), createElementBlock(Fragment, null, renderList(computedHandles.value, (handle, index) => {
|
|
8626
8663
|
return openBlock(), createElementBlock(Fragment, { key: index }, [
|
|
@@ -8633,19 +8670,19 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8633
8670
|
height: handle.height,
|
|
8634
8671
|
"aria-label": handle.type,
|
|
8635
8672
|
class: "mce-transformable__handle"
|
|
8636
|
-
}, null, 8,
|
|
8673
|
+
}, null, 8, _hoisted_3$5)) : (openBlock(), createElementBlock("circle", {
|
|
8637
8674
|
key: 1,
|
|
8638
8675
|
cx: handle.x + handle.width / 2,
|
|
8639
8676
|
cy: handle.y + handle.width / 2,
|
|
8640
8677
|
r: handle.width / 2,
|
|
8641
8678
|
"aria-label": handle.type,
|
|
8642
8679
|
class: "mce-transformable__handle"
|
|
8643
|
-
}, null, 8,
|
|
8680
|
+
}, null, 8, _hoisted_4$3))
|
|
8644
8681
|
], 64)) : createCommentVNode("", true)
|
|
8645
8682
|
], 64);
|
|
8646
8683
|
}), 128))
|
|
8647
8684
|
]),
|
|
8648
|
-
createElementVNode("g",
|
|
8685
|
+
createElementVNode("g", _hoisted_5$2, [
|
|
8649
8686
|
(openBlock(true), createElementBlock(Fragment, null, renderList(computedHandles.value, (handle, index) => {
|
|
8650
8687
|
return openBlock(), createElementBlock("rect", {
|
|
8651
8688
|
key: index,
|
|
@@ -8660,14 +8697,14 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8660
8697
|
class: "mce-transformable__handle-rect",
|
|
8661
8698
|
cursor: transforming.value ? "auto" : getCursor(handle.type),
|
|
8662
8699
|
onPointerdown: (event) => start(event, index)
|
|
8663
|
-
}, null, 40,
|
|
8700
|
+
}, null, 40, _hoisted_6$2);
|
|
8664
8701
|
}), 128))
|
|
8665
8702
|
]),
|
|
8666
|
-
createElementVNode("g",
|
|
8703
|
+
createElementVNode("g", _hoisted_7$2, [
|
|
8667
8704
|
renderSlot(_ctx.$slots, "svg", { box: model.value })
|
|
8668
8705
|
])
|
|
8669
8706
|
])),
|
|
8670
|
-
tip.value ? (openBlock(), createElementBlock("div",
|
|
8707
|
+
tip.value ? (openBlock(), createElementBlock("div", _hoisted_8$1, toDisplayString(tip.value), 1)) : createCommentVNode("", true)
|
|
8671
8708
|
]),
|
|
8672
8709
|
_: 3
|
|
8673
8710
|
}, 8, ["class", "style"]);
|
|
@@ -9236,7 +9273,11 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
9236
9273
|
const editor = textEditor.value;
|
|
9237
9274
|
editor.set(element.text.base);
|
|
9238
9275
|
await nextTick();
|
|
9239
|
-
|
|
9276
|
+
if (editor.pointerDown(e)) {
|
|
9277
|
+
editor.selectAll();
|
|
9278
|
+
return true;
|
|
9279
|
+
}
|
|
9280
|
+
return false;
|
|
9240
9281
|
}
|
|
9241
9282
|
onBeforeMount(() => registerCommand({ command: "startTyping", handle: startTyping }));
|
|
9242
9283
|
onBeforeUnmount(() => unregisterCommand("startTyping"));
|
|
@@ -9574,14 +9615,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
9574
9615
|
...makeMceStrategyProps({
|
|
9575
9616
|
resizeStrategy: defaultResizeStrategy,
|
|
9576
9617
|
activeStrategy: defaultActiveStrategy,
|
|
9618
|
+
doubleclickStrategy: defaultDoubleclickStrategy,
|
|
9577
9619
|
hoverStrategy: defaultHoverStrategy
|
|
9578
9620
|
}),
|
|
9579
9621
|
editor: Editor
|
|
9580
9622
|
},
|
|
9581
|
-
|
|
9582
|
-
setup(__props, { emit: __emit }) {
|
|
9623
|
+
setup(__props) {
|
|
9583
9624
|
const props = __props;
|
|
9584
|
-
const emit = __emit;
|
|
9585
9625
|
let editor;
|
|
9586
9626
|
if (props.editor) {
|
|
9587
9627
|
editor = provideEditor(props.editor);
|
|
@@ -9644,25 +9684,20 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
9644
9684
|
renderEngine.value.off("pointermove", onPointermove);
|
|
9645
9685
|
renderEngine.value.off("pointerover", onPointerover);
|
|
9646
9686
|
});
|
|
9647
|
-
function isExcluded(element) {
|
|
9648
|
-
return isFrame(element);
|
|
9649
|
-
}
|
|
9650
9687
|
function onHover(event) {
|
|
9651
9688
|
let cursor;
|
|
9652
9689
|
let hovered;
|
|
9653
|
-
if (isPointInsideAabb(
|
|
9690
|
+
if (elementSelection.value.length > 1 && isPointInsideAabb(
|
|
9654
9691
|
{ x: event.clientX, y: event.clientY },
|
|
9655
9692
|
getAabbInDrawboard(elementSelection.value)
|
|
9656
9693
|
)) {
|
|
9657
9694
|
cursor = "move";
|
|
9658
9695
|
} else {
|
|
9659
9696
|
const element = event.target;
|
|
9660
|
-
const oldElement = elementSelection.value[0];
|
|
9661
9697
|
const result = props.hoverStrategy({
|
|
9662
9698
|
element,
|
|
9663
|
-
oldElement,
|
|
9664
9699
|
event,
|
|
9665
|
-
|
|
9700
|
+
editor
|
|
9666
9701
|
});
|
|
9667
9702
|
if (result && !(result instanceof Element2D)) {
|
|
9668
9703
|
hovered = result.element;
|
|
@@ -9678,11 +9713,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
9678
9713
|
if (downEvent.srcElement !== drawboardDom.value && downEvent.srcElement.dataset?.pointerdown_to_drawboard === void 0 || camera.value.spaceKey || ![0, 2].includes(downEvent.button)) {
|
|
9679
9714
|
return;
|
|
9680
9715
|
}
|
|
9681
|
-
const oldElement = elementSelection.value[0];
|
|
9682
9716
|
const element = downEvent.target;
|
|
9683
9717
|
const start = { x: downEvent.clientX, y: downEvent.clientY };
|
|
9684
9718
|
let current = { ...start };
|
|
9685
9719
|
let dragging = false;
|
|
9720
|
+
let selecting = false;
|
|
9686
9721
|
let isUp = false;
|
|
9687
9722
|
let selected = [];
|
|
9688
9723
|
let ctxState;
|
|
@@ -9694,9 +9729,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
9694
9729
|
if (!inSelection) {
|
|
9695
9730
|
const result = props.activeStrategy({
|
|
9696
9731
|
element,
|
|
9697
|
-
oldElement,
|
|
9698
9732
|
event: downEvent,
|
|
9699
|
-
|
|
9733
|
+
editor
|
|
9700
9734
|
});
|
|
9701
9735
|
if (result && !(result instanceof Element2D)) {
|
|
9702
9736
|
selected = result.element ? [result.element] : [];
|
|
@@ -9710,9 +9744,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
9710
9744
|
function onDrag(event) {
|
|
9711
9745
|
const result = props.activeStrategy({
|
|
9712
9746
|
element,
|
|
9713
|
-
oldElement,
|
|
9714
9747
|
event,
|
|
9715
|
-
|
|
9748
|
+
editor
|
|
9716
9749
|
});
|
|
9717
9750
|
if (result && !(result instanceof Element2D)) {
|
|
9718
9751
|
selected = result.element ? [result.element] : [];
|
|
@@ -9722,6 +9755,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
9722
9755
|
elementSelection.value = selected;
|
|
9723
9756
|
}
|
|
9724
9757
|
function onSelectArea() {
|
|
9758
|
+
selecting = true;
|
|
9725
9759
|
if (state.value !== "selecting") {
|
|
9726
9760
|
state.value = "selecting";
|
|
9727
9761
|
}
|
|
@@ -9736,9 +9770,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
9736
9770
|
function onActivate() {
|
|
9737
9771
|
const result = props.activeStrategy({
|
|
9738
9772
|
element,
|
|
9739
|
-
oldElement,
|
|
9740
9773
|
event: downEvent,
|
|
9741
|
-
|
|
9774
|
+
editor
|
|
9742
9775
|
});
|
|
9743
9776
|
let _element;
|
|
9744
9777
|
if (result && !(result instanceof Element2D)) {
|
|
@@ -9788,12 +9821,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
9788
9821
|
}
|
|
9789
9822
|
}
|
|
9790
9823
|
}
|
|
9791
|
-
async function onUp(
|
|
9824
|
+
async function onUp(upEvent) {
|
|
9792
9825
|
if (state.value) {
|
|
9793
9826
|
state.value = void 0;
|
|
9794
9827
|
}
|
|
9795
9828
|
if (!dragging) {
|
|
9796
|
-
if (element) {
|
|
9829
|
+
if (element && !selecting) {
|
|
9797
9830
|
onActivate();
|
|
9798
9831
|
}
|
|
9799
9832
|
elementSelection.value = selected;
|
|
@@ -9801,7 +9834,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
9801
9834
|
if (selected[0] && !isLock(selected[0])) {
|
|
9802
9835
|
switch (ctxState) {
|
|
9803
9836
|
case "typing": {
|
|
9804
|
-
await exec("startTyping",
|
|
9837
|
+
await exec("startTyping", upEvent);
|
|
9805
9838
|
break;
|
|
9806
9839
|
}
|
|
9807
9840
|
}
|
|
@@ -9843,6 +9876,18 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
9843
9876
|
}
|
|
9844
9877
|
}
|
|
9845
9878
|
}
|
|
9879
|
+
async function onDoubleclick(event) {
|
|
9880
|
+
const state2 = props.doubleclickStrategy({
|
|
9881
|
+
event,
|
|
9882
|
+
editor
|
|
9883
|
+
});
|
|
9884
|
+
switch (state2) {
|
|
9885
|
+
case "typing": {
|
|
9886
|
+
await exec("startTyping", event);
|
|
9887
|
+
break;
|
|
9888
|
+
}
|
|
9889
|
+
}
|
|
9890
|
+
}
|
|
9846
9891
|
return (_ctx, _cache) => {
|
|
9847
9892
|
return openBlock(), createBlock(_sfc_main$d, { class: "mce-editor" }, {
|
|
9848
9893
|
default: withCtx(() => [
|
|
@@ -9854,7 +9899,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
9854
9899
|
ref: drawboardDom,
|
|
9855
9900
|
class: "mce-editor__drawboard",
|
|
9856
9901
|
"data-pixel-ratio": unref(renderEngine).pixelRatio,
|
|
9857
|
-
onDblclick: _cache[1] || (_cache[1] = ($event) =>
|
|
9902
|
+
onDblclick: _cache[1] || (_cache[1] = ($event) => onDoubleclick($event)),
|
|
9858
9903
|
onScroll,
|
|
9859
9904
|
onWheel: _cache[2] || (_cache[2] = withModifiers(() => {
|
|
9860
9905
|
}, ["prevent"]))
|
|
@@ -10028,6 +10073,7 @@ export {
|
|
|
10028
10073
|
createLayout,
|
|
10029
10074
|
createTextElement,
|
|
10030
10075
|
defaultActiveStrategy,
|
|
10076
|
+
defaultDoubleclickStrategy,
|
|
10031
10077
|
defaultHoverStrategy,
|
|
10032
10078
|
defaultResizeStrategy,
|
|
10033
10079
|
defineMixin,
|
|
@@ -18,7 +18,7 @@ declare global {
|
|
|
18
18
|
parseAnchor: (anchor: Anchor, isRtl?: boolean) => ParsedAnchor;
|
|
19
19
|
isRoot: (value: any) => value is Node;
|
|
20
20
|
isElement: (value: any) => value is Element2D;
|
|
21
|
-
isFrame: (
|
|
21
|
+
isFrame: (value: any) => value is Element2D;
|
|
22
22
|
isVisible: (node: Node) => boolean;
|
|
23
23
|
setVisible: (node: Node, visible: boolean) => void;
|
|
24
24
|
isLock: (node: Node) => boolean;
|
package/dist/plugins/ui.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import type { AxisAlignedBoundingBox } from '../types';
|
|
|
2
2
|
declare global {
|
|
3
3
|
namespace Mce {
|
|
4
4
|
interface Commands {
|
|
5
|
-
startTyping: (e?: PointerEvent) => Promise<boolean>;
|
|
6
|
-
startTransform: (e?: PointerEvent) => boolean;
|
|
7
|
-
openContextMenu: (e?: PointerEvent) => boolean;
|
|
5
|
+
startTyping: (e?: MouseEvent | PointerEvent) => Promise<boolean>;
|
|
6
|
+
startTransform: (e?: MouseEvent | PointerEvent) => boolean;
|
|
7
|
+
openContextMenu: (e?: MouseEvent | PointerEvent) => boolean;
|
|
8
8
|
}
|
|
9
9
|
interface Events {
|
|
10
10
|
setTransform: [value: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mce",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.13.
|
|
4
|
+
"version": "0.13.5",
|
|
5
5
|
"description": "The headless canvas editor framework. only the ESM.",
|
|
6
6
|
"author": "wxm",
|
|
7
7
|
"license": "MIT",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"modern-canvas": "^0.13.1",
|
|
65
65
|
"modern-font": "^0.4.4",
|
|
66
66
|
"modern-idoc": "^0.10.5",
|
|
67
|
-
"modern-text": "^1.10.
|
|
67
|
+
"modern-text": "^1.10.4",
|
|
68
68
|
"yjs": "^13.6.27"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|