mce 0.15.2 → 0.15.4
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/crdt/Doc.d.ts +0 -1
- package/dist/index.js +146 -73
- package/dist/mixins/0.context.d.ts +1 -0
- package/dist/plugins/ui.d.ts +5 -0
- package/package.json +5 -5
package/dist/crdt/Doc.d.ts
CHANGED
|
@@ -38,7 +38,6 @@ export declare class Doc extends Model {
|
|
|
38
38
|
reset(): this;
|
|
39
39
|
protected _addNode(data: Element, options?: AddNodeOptions): Node;
|
|
40
40
|
addNode(data: Element, options?: AddNodeOptions): Node;
|
|
41
|
-
addNodes(dataItems: Element[], options?: AddNodeOptions): Node[];
|
|
42
41
|
set(source: Document): this;
|
|
43
42
|
protected _proxyProps(obj: CoreObject, yMap: Y.Map<any>, isMeta?: boolean): void;
|
|
44
43
|
protected _proxyChildren(node: Node, childrenIds: Y.Array<string>): void;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Node as Node$1, Element2D, Timeline, Engine, Camera2D, DrawboardEffect, Aabb2D, IN_BROWSER, clamp, assets, TimelineNode, Transform2D, Obb2D, render, Vector2 as Vector2$1, customNodes, Animation, IN_MAC_OS } from "modern-canvas";
|
|
2
|
-
import { reactive, computed, watch, markRaw, ref, warn, shallowRef, onBeforeUnmount, defineComponent, createElementBlock, createCommentVNode, unref, openBlock, normalizeStyle, toDisplayString, createVNode, useAttrs, createBlock, resolveDynamicComponent, normalizeClass, mergeProps, createElementVNode, inject, toValue, getCurrentInstance, provide, useId, readonly, toRef, onMounted, onDeactivated, onActivated, onScopeDispose, useModel, useTemplateRef, withDirectives, vShow, vModelText, nextTick, Fragment, renderList, renderSlot, mergeModels, resolveComponent, withModifiers, withCtx, Teleport, createTextVNode, createSlots, normalizeProps, guardReactiveProps, onBeforeMount, h, isRef, useSlots } from "vue";
|
|
2
|
+
import { reactive, computed, watch, markRaw, isReactive, ref, warn, shallowRef, onBeforeUnmount, defineComponent, createElementBlock, createCommentVNode, unref, openBlock, normalizeStyle, toDisplayString, createVNode, useAttrs, createBlock, resolveDynamicComponent, normalizeClass, mergeProps, createElementVNode, inject, toValue, getCurrentInstance, provide, useId, readonly, toRef, onMounted, onDeactivated, onActivated, onScopeDispose, useModel, useTemplateRef, withDirectives, vShow, vModelText, nextTick, Fragment, renderList, renderSlot, mergeModels, resolveComponent, withModifiers, withCtx, Teleport, createTextVNode, createSlots, normalizeProps, guardReactiveProps, onBeforeMount, h, isRef, 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, normalizeTextContent, normalizeCRLF, isEqualObject } from "modern-idoc";
|
|
5
5
|
import { saveAs } from "file-saver";
|
|
@@ -535,13 +535,8 @@ class Doc extends Model {
|
|
|
535
535
|
}
|
|
536
536
|
async load(initFn) {
|
|
537
537
|
return super.load(async () => {
|
|
538
|
-
this._proxyNode(
|
|
539
|
-
this.root,
|
|
540
|
-
this._yProps,
|
|
541
|
-
this._yChildrenIds
|
|
542
|
-
);
|
|
543
|
-
this._yChildren.observe(this._yChildrenChange.bind(this));
|
|
544
538
|
await initFn?.();
|
|
539
|
+
this._yChildren.observe(this._yChildrenChange.bind(this));
|
|
545
540
|
});
|
|
546
541
|
}
|
|
547
542
|
_isSelfTransaction(transaction) {
|
|
@@ -611,9 +606,6 @@ class Doc extends Model {
|
|
|
611
606
|
addNode(data, options) {
|
|
612
607
|
return this.transact(() => this._addNode(data, options));
|
|
613
608
|
}
|
|
614
|
-
addNodes(dataItems, options) {
|
|
615
|
-
return this.transact(() => dataItems.map((data) => this._addNode(data, options)));
|
|
616
|
-
}
|
|
617
609
|
set(source) {
|
|
618
610
|
const { children = [], meta = {}, ..._props } = source;
|
|
619
611
|
const props = {
|
|
@@ -623,13 +615,17 @@ class Doc extends Model {
|
|
|
623
615
|
};
|
|
624
616
|
this.reset();
|
|
625
617
|
this.setProperties(props);
|
|
626
|
-
this._yProps.clear();
|
|
627
618
|
for (const key in props) {
|
|
628
619
|
this._yProps.set(key, props[key]);
|
|
629
620
|
}
|
|
630
621
|
this._yProps.set("meta", new Y.Map(Object.entries(meta)));
|
|
631
622
|
this._transacting = true;
|
|
632
|
-
this.
|
|
623
|
+
this._proxyNode(
|
|
624
|
+
this.root,
|
|
625
|
+
this._yProps,
|
|
626
|
+
this._yChildrenIds
|
|
627
|
+
);
|
|
628
|
+
this.root.append(children);
|
|
633
629
|
return this;
|
|
634
630
|
}
|
|
635
631
|
_proxyProps(obj, yMap, isMeta = false) {
|
|
@@ -696,8 +692,13 @@ class Doc extends Model {
|
|
|
696
692
|
return;
|
|
697
693
|
}
|
|
698
694
|
this.transact(() => {
|
|
699
|
-
childrenIds.insert(newIndex, [child.id]);
|
|
700
695
|
this._debug(`addChild ${child.id}`, child.name, newIndex);
|
|
696
|
+
if (!isReactive(child)) {
|
|
697
|
+
child = reactive(child);
|
|
698
|
+
node.children[newIndex] = child;
|
|
699
|
+
}
|
|
700
|
+
this._proxyNode(child);
|
|
701
|
+
childrenIds.insert(newIndex, [child.id]);
|
|
701
702
|
});
|
|
702
703
|
});
|
|
703
704
|
node.on("removeChild", (child, oldIndex) => {
|
|
@@ -705,11 +706,11 @@ class Doc extends Model {
|
|
|
705
706
|
return;
|
|
706
707
|
}
|
|
707
708
|
this.transact(() => {
|
|
709
|
+
this._debug(`removeChild ${child.id}`, child.name, oldIndex);
|
|
708
710
|
const index = childrenIds.toJSON().indexOf(child.id);
|
|
709
711
|
if (index > -1) {
|
|
710
712
|
childrenIds.delete(index, 1);
|
|
711
713
|
}
|
|
712
|
-
this._debug(`removeChild ${child.id}`, child.name, oldIndex);
|
|
713
714
|
});
|
|
714
715
|
});
|
|
715
716
|
node.children.forEach((child) => {
|
|
@@ -794,6 +795,7 @@ class Doc extends Model {
|
|
|
794
795
|
});
|
|
795
796
|
node.on("destroy", () => {
|
|
796
797
|
this._nodeMap.delete(node.id);
|
|
798
|
+
this._yChildren.delete(node.id);
|
|
797
799
|
this._debug("destroy", node.id);
|
|
798
800
|
});
|
|
799
801
|
this._proxyProps(node, yNode);
|
|
@@ -935,6 +937,9 @@ const _0_context = defineMixin((editor) => {
|
|
|
935
937
|
function isFrame(value) {
|
|
936
938
|
return isElement(value) && value.meta.inEditorIs === "Frame";
|
|
937
939
|
}
|
|
940
|
+
function isRootFrame(value) {
|
|
941
|
+
return isFrame(value) && Boolean(value.parent?.equal(root.value));
|
|
942
|
+
}
|
|
938
943
|
function isVisible(node) {
|
|
939
944
|
return isElement(node) && node.style.visibility === "visible";
|
|
940
945
|
}
|
|
@@ -975,6 +980,7 @@ const _0_context = defineMixin((editor) => {
|
|
|
975
980
|
isRoot,
|
|
976
981
|
isElement,
|
|
977
982
|
isFrame,
|
|
983
|
+
isRootFrame,
|
|
978
984
|
isVisible,
|
|
979
985
|
setVisible,
|
|
980
986
|
isLock,
|
|
@@ -2077,6 +2083,7 @@ const _2_load = defineMixin((editor) => {
|
|
|
2077
2083
|
const load = async (source) => {
|
|
2078
2084
|
state.value = "loading";
|
|
2079
2085
|
const items = [];
|
|
2086
|
+
let hasLoader = false;
|
|
2080
2087
|
try {
|
|
2081
2088
|
for (const loader of loaders.values()) {
|
|
2082
2089
|
if (await loader.test(source)) {
|
|
@@ -2086,13 +2093,14 @@ const _2_load = defineMixin((editor) => {
|
|
|
2086
2093
|
} else {
|
|
2087
2094
|
items.push(res);
|
|
2088
2095
|
}
|
|
2096
|
+
hasLoader = true;
|
|
2089
2097
|
break;
|
|
2090
2098
|
}
|
|
2091
2099
|
}
|
|
2092
2100
|
} finally {
|
|
2093
2101
|
state.value = void 0;
|
|
2094
2102
|
}
|
|
2095
|
-
if (!
|
|
2103
|
+
if (!hasLoader) {
|
|
2096
2104
|
throw new Error(`Failed to load source "${source}"`);
|
|
2097
2105
|
}
|
|
2098
2106
|
return items;
|
|
@@ -2782,7 +2790,7 @@ const _4_3_element = defineMixin((editor) => {
|
|
|
2782
2790
|
function selectArea(areaInDrawboard) {
|
|
2783
2791
|
const area2 = new Obb2D(areaInDrawboard);
|
|
2784
2792
|
const selected = root.value?.children.flatMap((node) => {
|
|
2785
|
-
if (isFrame(node)) {
|
|
2793
|
+
if (isFrame(node) && node.parent?.equal(root.value)) {
|
|
2786
2794
|
return node.children;
|
|
2787
2795
|
}
|
|
2788
2796
|
return [node];
|
|
@@ -3292,36 +3300,74 @@ const _clipboard = definePlugin((editor, options) => {
|
|
|
3292
3300
|
} = editor;
|
|
3293
3301
|
const copiedData = ref();
|
|
3294
3302
|
const useClipboard = options.clipboard !== false && SUPPORTS_CLIPBOARD;
|
|
3295
|
-
|
|
3303
|
+
const copy = async (source) => {
|
|
3296
3304
|
if (typeof source === "string") {
|
|
3297
|
-
|
|
3298
|
-
|
|
3305
|
+
if (useClipboard) {
|
|
3306
|
+
await navigator.clipboard.write([
|
|
3307
|
+
new ClipboardItem({
|
|
3308
|
+
"text/plain": new Blob([source], { type: "text/plain" })
|
|
3309
|
+
})
|
|
3310
|
+
]);
|
|
3311
|
+
}
|
|
3299
3312
|
} else if (source instanceof Blob) {
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
}
|
|
3307
|
-
}
|
|
3308
|
-
}
|
|
3309
|
-
const copy = async (source) => {
|
|
3310
|
-
if (source === void 0) {
|
|
3311
|
-
source = selection.value.map((v) => {
|
|
3312
|
-
const json = v.toJSON();
|
|
3313
|
-
delete json.style.left;
|
|
3314
|
-
delete json.style.top;
|
|
3315
|
-
return json;
|
|
3316
|
-
});
|
|
3317
|
-
}
|
|
3318
|
-
if (useClipboard) {
|
|
3319
|
-
await navigator.clipboard.write([
|
|
3320
|
-
toClipboardItem(source)
|
|
3321
|
-
]);
|
|
3313
|
+
if (useClipboard) {
|
|
3314
|
+
await navigator.clipboard.write([
|
|
3315
|
+
new ClipboardItem({
|
|
3316
|
+
[source.type]: source
|
|
3317
|
+
})
|
|
3318
|
+
]);
|
|
3319
|
+
}
|
|
3322
3320
|
} else {
|
|
3323
|
-
if (
|
|
3324
|
-
|
|
3321
|
+
if (useClipboard) {
|
|
3322
|
+
const textItems = [];
|
|
3323
|
+
let html = "";
|
|
3324
|
+
if (!source) {
|
|
3325
|
+
const selected = selection.value;
|
|
3326
|
+
html += `<mce-clipboard>${JSON.stringify(selected.map((v) => {
|
|
3327
|
+
const json = v.toJSON();
|
|
3328
|
+
if (json.style) {
|
|
3329
|
+
delete json.style.left;
|
|
3330
|
+
delete json.style.top;
|
|
3331
|
+
}
|
|
3332
|
+
return json;
|
|
3333
|
+
}))}</mce-clipboard>`;
|
|
3334
|
+
const cb = (child) => {
|
|
3335
|
+
if (child instanceof Element2D) {
|
|
3336
|
+
const _text2 = child.text.base.toString();
|
|
3337
|
+
textItems.push(_text2);
|
|
3338
|
+
html += `<span>${_text2}</span>`;
|
|
3339
|
+
}
|
|
3340
|
+
return false;
|
|
3341
|
+
};
|
|
3342
|
+
selected.forEach((node) => {
|
|
3343
|
+
cb(node);
|
|
3344
|
+
node.findOne(cb);
|
|
3345
|
+
});
|
|
3346
|
+
} else {
|
|
3347
|
+
html += `<mce-clipboard>${JSON.stringify(source)}</mce-clipboard>`;
|
|
3348
|
+
}
|
|
3349
|
+
const items = {};
|
|
3350
|
+
if (textItems.length) {
|
|
3351
|
+
items["text/plain"] = new Blob([textItems.join("\n")], { type: "text/plain" });
|
|
3352
|
+
}
|
|
3353
|
+
if (html) {
|
|
3354
|
+
items["text/html"] = new Blob([html], { type: "text/html" });
|
|
3355
|
+
}
|
|
3356
|
+
await navigator.clipboard.write([
|
|
3357
|
+
new ClipboardItem(items)
|
|
3358
|
+
]);
|
|
3359
|
+
} else {
|
|
3360
|
+
if (source === void 0) {
|
|
3361
|
+
source = selection.value.map((v) => {
|
|
3362
|
+
const json = v.toJSON();
|
|
3363
|
+
delete json.style.left;
|
|
3364
|
+
delete json.style.top;
|
|
3365
|
+
return json;
|
|
3366
|
+
});
|
|
3367
|
+
}
|
|
3368
|
+
if (Array.isArray(source)) {
|
|
3369
|
+
copiedData.value = source;
|
|
3370
|
+
}
|
|
3325
3371
|
}
|
|
3326
3372
|
}
|
|
3327
3373
|
};
|
|
@@ -3340,10 +3386,17 @@ const _clipboard = definePlugin((editor, options) => {
|
|
|
3340
3386
|
async function _paste(items) {
|
|
3341
3387
|
const elements = [];
|
|
3342
3388
|
for (const item of items) {
|
|
3343
|
-
|
|
3389
|
+
const types = [...item.types];
|
|
3390
|
+
const index = types.indexOf("text/html");
|
|
3391
|
+
if (index > -1) {
|
|
3392
|
+
types.splice(index, 1);
|
|
3393
|
+
types.unshift("text/html");
|
|
3394
|
+
}
|
|
3395
|
+
for (const type of types) {
|
|
3344
3396
|
const blob = await item.getType(type);
|
|
3345
3397
|
if (await canLoad(blob)) {
|
|
3346
3398
|
elements.push(...await load(blob));
|
|
3399
|
+
break;
|
|
3347
3400
|
} else {
|
|
3348
3401
|
console.warn(`Unhandled clipboard ${blob.type}`, await blob.text());
|
|
3349
3402
|
}
|
|
@@ -3687,7 +3740,7 @@ const aliases = {
|
|
|
3687
3740
|
const svg = {
|
|
3688
3741
|
component: SvgIcon
|
|
3689
3742
|
};
|
|
3690
|
-
const IconsSymbol = Symbol.for("mce:icons");
|
|
3743
|
+
const IconsSymbol = /* @__PURE__ */ Symbol.for("mce:icons");
|
|
3691
3744
|
function createIcons(options = {}) {
|
|
3692
3745
|
return merge({
|
|
3693
3746
|
defaultSet: "svg",
|
|
@@ -3740,8 +3793,8 @@ function useIcon(props) {
|
|
|
3740
3793
|
iconData
|
|
3741
3794
|
};
|
|
3742
3795
|
}
|
|
3743
|
-
const MceLayerKey = Symbol.for("mce:layer");
|
|
3744
|
-
const MceLayerItemKey = Symbol.for("mce:layer-item");
|
|
3796
|
+
const MceLayerKey = /* @__PURE__ */ Symbol.for("mce:layer");
|
|
3797
|
+
const MceLayerItemKey = /* @__PURE__ */ Symbol.for("mce:layer-item");
|
|
3745
3798
|
function createLayer(options) {
|
|
3746
3799
|
const registered = ref([]);
|
|
3747
3800
|
const nodeItems = /* @__PURE__ */ new Map();
|
|
@@ -3892,8 +3945,8 @@ function useResizeObserver(callback, box = "content") {
|
|
|
3892
3945
|
contentRect: readonly(contentRect)
|
|
3893
3946
|
};
|
|
3894
3947
|
}
|
|
3895
|
-
const MceLayoutKey = Symbol.for("mce:layout");
|
|
3896
|
-
const MceLayoutItemKey = Symbol.for("mce:layout-item");
|
|
3948
|
+
const MceLayoutKey = /* @__PURE__ */ Symbol.for("mce:layout");
|
|
3949
|
+
const MceLayoutItemKey = /* @__PURE__ */ Symbol.for("mce:layout-item");
|
|
3897
3950
|
const ROOT_ZINDEX = 500;
|
|
3898
3951
|
function makeLayoutProps() {
|
|
3899
3952
|
return {
|
|
@@ -4131,8 +4184,8 @@ function createLayout(props) {
|
|
|
4131
4184
|
layoutRef: resizeRef
|
|
4132
4185
|
};
|
|
4133
4186
|
}
|
|
4134
|
-
const MceMenuSymbol = Symbol.for("MceMenuSymbol");
|
|
4135
|
-
const MceOverlaySymbol = Symbol.for("MceOverlaySymbol");
|
|
4187
|
+
const MceMenuSymbol = /* @__PURE__ */ Symbol.for("MceMenuSymbol");
|
|
4188
|
+
const MceOverlaySymbol = /* @__PURE__ */ Symbol.for("MceOverlaySymbol");
|
|
4136
4189
|
const makeMceOverlayProps = propsFactory({
|
|
4137
4190
|
location: String,
|
|
4138
4191
|
offset: Number,
|
|
@@ -4256,7 +4309,9 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
4256
4309
|
selection,
|
|
4257
4310
|
state,
|
|
4258
4311
|
config,
|
|
4259
|
-
exec
|
|
4312
|
+
exec,
|
|
4313
|
+
renderEngine,
|
|
4314
|
+
drawboardDom
|
|
4260
4315
|
} = useEditor();
|
|
4261
4316
|
const editing = ref(false);
|
|
4262
4317
|
async function onDblclick() {
|
|
@@ -4267,11 +4322,14 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
4267
4322
|
input.value.select();
|
|
4268
4323
|
}
|
|
4269
4324
|
}
|
|
4270
|
-
async function onPointerdown(
|
|
4325
|
+
async function onPointerdown(event) {
|
|
4271
4326
|
if (!editing.value) {
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4327
|
+
const cloend = renderEngine.value.input._clonePointerEvent(event);
|
|
4328
|
+
cloend.srcElement = drawboardDom.value;
|
|
4329
|
+
cloend.target = frame.value;
|
|
4330
|
+
exec("startPointerdown", cloend, {
|
|
4331
|
+
allowRootFrame: true
|
|
4332
|
+
});
|
|
4275
4333
|
}
|
|
4276
4334
|
}
|
|
4277
4335
|
return (_ctx, _cache) => {
|
|
@@ -8543,7 +8601,7 @@ class Curve {
|
|
|
8543
8601
|
}
|
|
8544
8602
|
getLength() {
|
|
8545
8603
|
const lengths = this.getLengths();
|
|
8546
|
-
return lengths[lengths.length - 1];
|
|
8604
|
+
return lengths[lengths.length - 1] ?? 0;
|
|
8547
8605
|
}
|
|
8548
8606
|
getLengths() {
|
|
8549
8607
|
if (this._lengths.length !== this.arcLengthDivision + 1) {
|
|
@@ -13523,7 +13581,7 @@ const plugins = [
|
|
|
13523
13581
|
_zoom
|
|
13524
13582
|
];
|
|
13525
13583
|
class Editor extends Observable {
|
|
13526
|
-
static injectionKey = Symbol.for("EditorKey");
|
|
13584
|
+
static injectionKey = /* @__PURE__ */ Symbol.for("EditorKey");
|
|
13527
13585
|
debug = ref(false);
|
|
13528
13586
|
onEmit;
|
|
13529
13587
|
plugins = /* @__PURE__ */ new Map();
|
|
@@ -14666,7 +14724,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
14666
14724
|
element,
|
|
14667
14725
|
newStyle.width / element.style.width,
|
|
14668
14726
|
newStyle.height / element.style.height,
|
|
14669
|
-
isFrame(element) ? void 0 : !shape.
|
|
14727
|
+
isFrame(element) ? void 0 : !shape.isValid() ? handle.split("-").length > 2 ? { deep: true, textFontSizeToFit: true } : { deep: true, textToFit: true } : void 0
|
|
14670
14728
|
);
|
|
14671
14729
|
newStyle.width = element.style.width;
|
|
14672
14730
|
newStyle.height = element.style.height;
|
|
@@ -14981,7 +15039,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
14981
15039
|
}
|
|
14982
15040
|
function onUpdate() {
|
|
14983
15041
|
const element = elementSelection.value[0];
|
|
14984
|
-
if (!element.shape.
|
|
15042
|
+
if (!element.shape.isValid()) {
|
|
14985
15043
|
textToFit(element);
|
|
14986
15044
|
}
|
|
14987
15045
|
}
|
|
@@ -15076,6 +15134,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15076
15134
|
const {
|
|
15077
15135
|
pluginsComponents,
|
|
15078
15136
|
isElement,
|
|
15137
|
+
isRootFrame,
|
|
15079
15138
|
config,
|
|
15080
15139
|
drawboardDom,
|
|
15081
15140
|
renderEngine,
|
|
@@ -15147,20 +15206,30 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15147
15206
|
event,
|
|
15148
15207
|
editor
|
|
15149
15208
|
});
|
|
15150
|
-
if (result &&
|
|
15209
|
+
if (result && "element" in result) {
|
|
15151
15210
|
hovered = result.element;
|
|
15152
15211
|
cursor = result.cursor;
|
|
15153
15212
|
} else {
|
|
15154
15213
|
hovered = result;
|
|
15155
15214
|
}
|
|
15156
15215
|
}
|
|
15216
|
+
if (!(isElement(hovered) && !isRootFrame(hovered))) {
|
|
15217
|
+
hovered = void 0;
|
|
15218
|
+
cursor = void 0;
|
|
15219
|
+
}
|
|
15157
15220
|
hoverElement.value = hovered;
|
|
15158
15221
|
setCursor(cursor);
|
|
15159
15222
|
}
|
|
15160
|
-
function onPointerdown(downEvent) {
|
|
15161
|
-
if (downEvent.srcElement !== drawboardDom.value && downEvent.srcElement.dataset?.pointerdown_to_drawboard === void 0 || camera.value.spaceKey || ![0, 2].includes(downEvent.button)) {
|
|
15223
|
+
function onPointerdown(downEvent, options = {}) {
|
|
15224
|
+
if (downEvent.srcElement && downEvent.srcElement !== drawboardDom.value && downEvent.srcElement.dataset?.pointerdown_to_drawboard === void 0 || camera.value.spaceKey || ![0, 2].includes(downEvent.button)) {
|
|
15162
15225
|
return;
|
|
15163
15226
|
}
|
|
15227
|
+
const {
|
|
15228
|
+
allowRootFrame = false
|
|
15229
|
+
} = options;
|
|
15230
|
+
function isIncluded(node) {
|
|
15231
|
+
return isElement(node) && (allowRootFrame || !isRootFrame(node));
|
|
15232
|
+
}
|
|
15164
15233
|
const drawing = state.value === "drawing";
|
|
15165
15234
|
const hand = state.value === "hand";
|
|
15166
15235
|
const element = downEvent.target;
|
|
@@ -15183,11 +15252,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15183
15252
|
event: downEvent,
|
|
15184
15253
|
editor
|
|
15185
15254
|
});
|
|
15186
|
-
|
|
15187
|
-
|
|
15188
|
-
|
|
15189
|
-
selected = result ? [result] : [];
|
|
15255
|
+
let _element = result && "element" in result ? result.element : result;
|
|
15256
|
+
if (!isIncluded(_element)) {
|
|
15257
|
+
_element = void 0;
|
|
15190
15258
|
}
|
|
15259
|
+
selected = _element ? [_element] : [];
|
|
15191
15260
|
elementSelection.value = selected;
|
|
15192
15261
|
}
|
|
15193
15262
|
return;
|
|
@@ -15209,11 +15278,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15209
15278
|
event,
|
|
15210
15279
|
editor
|
|
15211
15280
|
});
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
selected = result ? [result] : [];
|
|
15281
|
+
let _element = result && "element" in result ? result.element : result;
|
|
15282
|
+
if (!isIncluded(_element)) {
|
|
15283
|
+
_element = void 0;
|
|
15216
15284
|
}
|
|
15285
|
+
selected = _element ? [_element] : [];
|
|
15217
15286
|
elementSelection.value = selected;
|
|
15218
15287
|
}
|
|
15219
15288
|
function onSelectArea() {
|
|
@@ -15234,12 +15303,15 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15234
15303
|
editor
|
|
15235
15304
|
});
|
|
15236
15305
|
let _element;
|
|
15237
|
-
if (result &&
|
|
15306
|
+
if (result && "element" in result) {
|
|
15238
15307
|
_element = result.element;
|
|
15239
15308
|
ctxState = result.state;
|
|
15240
15309
|
} else {
|
|
15241
15310
|
_element = result;
|
|
15242
15311
|
}
|
|
15312
|
+
if (!isIncluded(_element)) {
|
|
15313
|
+
_element = void 0;
|
|
15314
|
+
}
|
|
15243
15315
|
if (_element && (downEvent?.ctrlKey || downEvent?.shiftKey || downEvent?.metaKey)) {
|
|
15244
15316
|
if (elementSelection.value.findIndex((v) => v.equal(_element)) > -1) {
|
|
15245
15317
|
selected = elementSelection.value.filter((v) => !v.equal(_element));
|
|
@@ -15292,7 +15364,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15292
15364
|
);
|
|
15293
15365
|
} else {
|
|
15294
15366
|
if (!inSelection) {
|
|
15295
|
-
if (!element) {
|
|
15367
|
+
if (!isIncluded(element)) {
|
|
15296
15368
|
onSelectArea();
|
|
15297
15369
|
}
|
|
15298
15370
|
}
|
|
@@ -15341,6 +15413,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15341
15413
|
document.addEventListener("pointermove", onMove);
|
|
15342
15414
|
document.addEventListener("pointerup", onUp);
|
|
15343
15415
|
}
|
|
15416
|
+
editor.registerCommand({ command: "startPointerdown", handle: onPointerdown });
|
|
15344
15417
|
function onPointermove(event) {
|
|
15345
15418
|
if (event.srcElement !== drawboardDom.value) {
|
|
15346
15419
|
return;
|
|
@@ -45,6 +45,7 @@ declare global {
|
|
|
45
45
|
isRoot: (value: any) => value is Node;
|
|
46
46
|
isElement: (value: any) => value is Element2D;
|
|
47
47
|
isFrame: (value: any) => value is Element2D;
|
|
48
|
+
isRootFrame: (value: any) => value is Element2D;
|
|
48
49
|
isVisible: (node: Node) => boolean;
|
|
49
50
|
setVisible: (node: Node, visible: boolean) => void;
|
|
50
51
|
isLock: (node: Node) => boolean;
|
package/dist/plugins/ui.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import type { PointerInputEvent } from 'modern-canvas';
|
|
1
2
|
import type { AxisAlignedBoundingBox } from '../types';
|
|
2
3
|
declare global {
|
|
3
4
|
namespace Mce {
|
|
5
|
+
interface StartPointerdownOptions {
|
|
6
|
+
allowRootFrame?: boolean;
|
|
7
|
+
}
|
|
4
8
|
interface Commands {
|
|
9
|
+
startPointerdown: (e: PointerInputEvent, options?: StartPointerdownOptions) => void;
|
|
5
10
|
startTyping: (e?: MouseEvent | PointerEvent) => Promise<boolean>;
|
|
6
11
|
startTransform: (e?: MouseEvent | PointerEvent) => boolean;
|
|
7
12
|
openContextMenu: (e?: MouseEvent | PointerEvent) => boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mce",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.15.
|
|
4
|
+
"version": "0.15.4",
|
|
5
5
|
"description": "The headless canvas editor framework. only the ESM.",
|
|
6
6
|
"author": "wxm",
|
|
7
7
|
"license": "MIT",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"@vueuse/core": "^14.1.0",
|
|
61
61
|
"diff": "^8.0.2",
|
|
62
62
|
"file-saver": "^2.0.5",
|
|
63
|
-
"lodash-es": "^4.17.
|
|
64
|
-
"modern-canvas": "^0.14.
|
|
63
|
+
"lodash-es": "^4.17.22",
|
|
64
|
+
"modern-canvas": "^0.14.19",
|
|
65
65
|
"modern-font": "^0.4.4",
|
|
66
|
-
"modern-idoc": "^0.10.
|
|
66
|
+
"modern-idoc": "^0.10.7",
|
|
67
67
|
"modern-text": "^1.10.5",
|
|
68
68
|
"yjs": "^13.6.27"
|
|
69
69
|
},
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"@vitejs/plugin-vue": "^6.0.3",
|
|
95
95
|
"jiti": "^2.6.1",
|
|
96
96
|
"modern-gif": "^2.0.4",
|
|
97
|
-
"sass-embedded": "^1.
|
|
97
|
+
"sass-embedded": "^1.97.0"
|
|
98
98
|
},
|
|
99
99
|
"scripts": {
|
|
100
100
|
"build:code": "vite build",
|