mce 0.18.0 → 0.18.1
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/index.d.ts +1 -0
- package/dist/index.js +61 -43
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from './mixin';
|
|
|
16
16
|
export * from './mixins';
|
|
17
17
|
export * from './plugin';
|
|
18
18
|
export * from './plugins';
|
|
19
|
+
export * from './scene';
|
|
19
20
|
export * from './types';
|
|
20
21
|
export type { Camera2D, Element2D, Engine } from 'modern-canvas';
|
|
21
22
|
export type { Document, Element, NormalizedElement } from 'modern-idoc';
|
package/dist/index.js
CHANGED
|
@@ -393,10 +393,10 @@ var _0_config_default = defineMixin((editor) => {
|
|
|
393
393
|
});
|
|
394
394
|
onChange(async (files) => {
|
|
395
395
|
const file = files?.[0];
|
|
396
|
-
if (file) {
|
|
396
|
+
if (file) try {
|
|
397
397
|
config.value = JSON.parse(await file.text());
|
|
398
398
|
resolve(config.value);
|
|
399
|
-
}
|
|
399
|
+
} catch {}
|
|
400
400
|
});
|
|
401
401
|
open();
|
|
402
402
|
});
|
|
@@ -4383,7 +4383,10 @@ var IndexeddbProvider = class extends Observable {
|
|
|
4383
4383
|
this._db = openDB(name, (db) => {
|
|
4384
4384
|
createStores(db, [["updates", { autoIncrement: true }], ["custom"]]);
|
|
4385
4385
|
});
|
|
4386
|
-
this.whenSynced = new Promise((resolve
|
|
4386
|
+
this.whenSynced = new Promise((resolve, reject) => {
|
|
4387
|
+
this.on("synced", () => resolve(this));
|
|
4388
|
+
this._db.catch(reject);
|
|
4389
|
+
});
|
|
4387
4390
|
this._db.then((db) => {
|
|
4388
4391
|
this.db = db;
|
|
4389
4392
|
fetchUpdates(this, (updatesStore) => {
|
|
@@ -4393,7 +4396,7 @@ var IndexeddbProvider = class extends Observable {
|
|
|
4393
4396
|
this.synced = true;
|
|
4394
4397
|
this.emit("synced", this);
|
|
4395
4398
|
});
|
|
4396
|
-
});
|
|
4399
|
+
}).catch(() => {});
|
|
4397
4400
|
this._storeUpdate = (update, origin) => {
|
|
4398
4401
|
if (this.db && origin !== this) {
|
|
4399
4402
|
const [updatesStore] = transact(this.db, [updatesStoreName]);
|
|
@@ -6701,7 +6704,11 @@ var clipboard_default = definePlugin(() => {
|
|
|
6701
6704
|
},
|
|
6702
6705
|
load: async (doc) => {
|
|
6703
6706
|
const mce = doc.querySelector("mce-clipboard");
|
|
6704
|
-
if (mce)
|
|
6707
|
+
if (mce) try {
|
|
6708
|
+
return JSON.parse(mce.textContent);
|
|
6709
|
+
} catch {
|
|
6710
|
+
return [];
|
|
6711
|
+
}
|
|
6705
6712
|
return [];
|
|
6706
6713
|
}
|
|
6707
6714
|
}]
|
|
@@ -7932,7 +7939,9 @@ var frame_default = definePlugin((editor) => {
|
|
|
7932
7939
|
}],
|
|
7933
7940
|
setup: () => {
|
|
7934
7941
|
const { on, off, inEditorIs, snapshot, captureFrameScreenshot, frames, frameThumbs } = editor;
|
|
7942
|
+
let cleanupDoc = null;
|
|
7935
7943
|
function onSetDoc(doc) {
|
|
7944
|
+
cleanupDoc?.();
|
|
7936
7945
|
if (config.value.thumbnail) snapshot();
|
|
7937
7946
|
function onAddChild(node, _newIndex) {
|
|
7938
7947
|
if (config.value.thumbnail && inEditorIs(node, "Frame")) {
|
|
@@ -7951,12 +7960,17 @@ var frame_default = definePlugin((editor) => {
|
|
|
7951
7960
|
}
|
|
7952
7961
|
doc.on("addChild", onAddChild);
|
|
7953
7962
|
doc.on("removeChild", onRemoveChild);
|
|
7963
|
+
cleanupDoc = () => {
|
|
7964
|
+
doc.off("addChild", onAddChild);
|
|
7965
|
+
doc.off("removeChild", onRemoveChild);
|
|
7966
|
+
};
|
|
7954
7967
|
}
|
|
7955
7968
|
onBeforeMount(() => {
|
|
7956
7969
|
on("docSet", onSetDoc);
|
|
7957
7970
|
});
|
|
7958
7971
|
onScopeDispose(() => {
|
|
7959
7972
|
off("docSet", onSetDoc);
|
|
7973
|
+
cleanupDoc?.();
|
|
7960
7974
|
});
|
|
7961
7975
|
}
|
|
7962
7976
|
};
|
|
@@ -8062,8 +8076,8 @@ var html_default = definePlugin((editor) => {
|
|
|
8062
8076
|
const dom = new DOMParser().parseFromString(await source.text(), "text/html");
|
|
8063
8077
|
try {
|
|
8064
8078
|
return await load(dom);
|
|
8065
|
-
} catch (
|
|
8066
|
-
console.
|
|
8079
|
+
} catch (err) {
|
|
8080
|
+
console.error(err);
|
|
8067
8081
|
return [];
|
|
8068
8082
|
}
|
|
8069
8083
|
}
|
|
@@ -9554,42 +9568,46 @@ var pen_default = definePlugin((editor) => {
|
|
|
9554
9568
|
currentPath.currentCurve.addCurve(currentLine);
|
|
9555
9569
|
update();
|
|
9556
9570
|
}
|
|
9557
|
-
|
|
9558
|
-
el = addElement({
|
|
9559
|
-
name: "pen",
|
|
9560
|
-
style: {
|
|
9561
|
-
width: 1,
|
|
9562
|
-
height: 1
|
|
9563
|
-
},
|
|
9564
|
-
outline: {
|
|
9565
|
-
color: "#d9d9d9",
|
|
9566
|
-
width: 5,
|
|
9567
|
-
lineCap: "round",
|
|
9568
|
-
lineJoin: "round"
|
|
9569
|
-
},
|
|
9570
|
-
meta: { inPptIs: "Shape" }
|
|
9571
|
-
}, { position: start });
|
|
9572
|
-
currentPath = new Path2D();
|
|
9573
|
-
currentLine = new LineCurve(new Vector2(start.x, start.y), new Vector2(start.x, start.y));
|
|
9574
|
-
currentPath.currentCurve.addCurve(currentLine);
|
|
9575
|
-
update();
|
|
9576
|
-
const onMove = () => {
|
|
9577
|
-
const move = getGlobalPointer();
|
|
9578
|
-
if (currentLine && move) {
|
|
9579
|
-
currentLine.p2.x = move.x;
|
|
9580
|
-
currentLine.p2.y = move.y;
|
|
9581
|
-
update();
|
|
9582
|
-
}
|
|
9583
|
-
};
|
|
9584
|
-
renderEngine.value.on("pointermove", onMove);
|
|
9585
|
-
const stop = watch([state, activeTool], () => {
|
|
9586
|
-
renderEngine.value.off("pointermove", onMove);
|
|
9587
|
-
stop();
|
|
9588
|
-
el = void 0;
|
|
9589
|
-
currentPath = void 0;
|
|
9590
|
-
currentLine = void 0;
|
|
9591
|
-
});
|
|
9571
|
+
return;
|
|
9592
9572
|
}
|
|
9573
|
+
el = addElement({
|
|
9574
|
+
name: "pen",
|
|
9575
|
+
style: {
|
|
9576
|
+
width: 1,
|
|
9577
|
+
height: 1
|
|
9578
|
+
},
|
|
9579
|
+
outline: {
|
|
9580
|
+
color: "#d9d9d9",
|
|
9581
|
+
width: 5,
|
|
9582
|
+
lineCap: "round",
|
|
9583
|
+
lineJoin: "round"
|
|
9584
|
+
},
|
|
9585
|
+
meta: { inPptIs: "Shape" }
|
|
9586
|
+
}, { position: start });
|
|
9587
|
+
currentPath = new Path2D();
|
|
9588
|
+
currentLine = new LineCurve(new Vector2(start.x, start.y), new Vector2(start.x, start.y));
|
|
9589
|
+
currentPath.currentCurve.addCurve(currentLine);
|
|
9590
|
+
update();
|
|
9591
|
+
const onMove = () => {
|
|
9592
|
+
const move = getGlobalPointer();
|
|
9593
|
+
if (currentLine && move) {
|
|
9594
|
+
currentLine.p2.x = move.x;
|
|
9595
|
+
currentLine.p2.y = move.y;
|
|
9596
|
+
update();
|
|
9597
|
+
}
|
|
9598
|
+
};
|
|
9599
|
+
renderEngine.value.on("pointermove", onMove);
|
|
9600
|
+
let stopWatch;
|
|
9601
|
+
const cleanup = () => {
|
|
9602
|
+
renderEngine.value.off("pointermove", onMove);
|
|
9603
|
+
stopWatch?.();
|
|
9604
|
+
stopWatch = void 0;
|
|
9605
|
+
el = void 0;
|
|
9606
|
+
currentPath = void 0;
|
|
9607
|
+
currentLine = void 0;
|
|
9608
|
+
};
|
|
9609
|
+
stopWatch = watch([state, activeTool], cleanup);
|
|
9610
|
+
return { end: cleanup };
|
|
9593
9611
|
}
|
|
9594
9612
|
}, {
|
|
9595
9613
|
name: "pencil",
|
|
@@ -17041,4 +17059,4 @@ var Dialog_default = /* @__PURE__ */ defineComponent({
|
|
|
17041
17059
|
}
|
|
17042
17060
|
});
|
|
17043
17061
|
//#endregion
|
|
17044
|
-
export { Cropper_default as Cropper, Dialog_default as Dialog, Editor, Layers_default as EditorLayers, EditorLayout_default as EditorLayout, LayoutItem_default as EditorLayoutItem, Toolbelt_default as EditorToolbelt, Menu_default as Menu, Ruler_default as Ruler, Scrollbar_default as Scrollbar, Transform_default as Transform, defineMixin, definePlugin, mixins, plugins, useEditor };
|
|
17062
|
+
export { Cropper_default as Cropper, Dialog_default as Dialog, Doc, Editor, Layers_default as EditorLayers, EditorLayout_default as EditorLayout, LayoutItem_default as EditorLayoutItem, Toolbelt_default as EditorToolbelt, Menu_default as Menu, Ruler_default as Ruler, Scrollbar_default as Scrollbar, Transform_default as Transform, defineMixin, definePlugin, mixins, plugins, useEditor };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mce",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.1",
|
|
5
5
|
"description": "A headless infinite canvas editor framework built on WebGL rendering, supports exporting to image, video, and PPT. Only the ESM.",
|
|
6
6
|
"author": "wxm",
|
|
7
7
|
"license": "MIT",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"@vueuse/core": "^14.3.0",
|
|
61
61
|
"diff": "^9.0.0",
|
|
62
62
|
"lodash-es": "^4.18.1",
|
|
63
|
-
"modern-canvas": "^0.17.
|
|
63
|
+
"modern-canvas": "^0.17.2",
|
|
64
64
|
"modern-font": "^0.5.0",
|
|
65
|
-
"modern-idoc": "^0.11.
|
|
65
|
+
"modern-idoc": "^0.11.4",
|
|
66
66
|
"modern-text": "^1.11.0",
|
|
67
67
|
"y-protocols": "^1.0.7",
|
|
68
68
|
"yjs": "^13.6.30"
|