mce 0.13.16 → 0.14.0
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/README.md +1 -0
- package/dist/components/Floatbar.vue.d.ts +7 -7
- package/dist/components/Selector.vue.d.ts +152 -0
- package/dist/components/shared/Cropper.vue.d.ts +2 -2
- package/dist/components/shared/Dialog.vue.d.ts +5 -5
- package/dist/components/shared/FloatPanel.vue.d.ts +2 -2
- package/dist/components/shared/Menu.vue.d.ts +1 -1
- package/dist/components/shared/Overlay.vue.d.ts +4 -4
- package/dist/components/shared/Tooltip.vue.d.ts +10 -5
- package/dist/components/shared/Transformable.vue.d.ts +4 -4
- package/dist/composables/overlay.d.ts +2 -2
- package/dist/index.css +115 -40
- package/dist/index.js +156 -75
- package/dist/locale/en.d.ts +1 -0
- package/dist/locale/zh-Hans.d.ts +1 -0
- package/dist/mixins/0.command.d.ts +2 -2
- package/dist/mixins/1.hotkey.d.ts +2 -2
- package/dist/mixins/2.export.d.ts +2 -2
- package/dist/mixins/2.load.d.ts +2 -2
- package/dist/mixins/drawingTool.d.ts +1 -1
- package/package.json +5 -5
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 {
|
|
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, 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";
|
|
@@ -17,23 +17,23 @@ const _0_command = defineMixin((editor) => {
|
|
|
17
17
|
const {
|
|
18
18
|
emit
|
|
19
19
|
} = editor;
|
|
20
|
-
const commands =
|
|
20
|
+
const commands = reactive(/* @__PURE__ */ new Map());
|
|
21
21
|
const registerCommand = (value) => {
|
|
22
22
|
if (Array.isArray(value)) {
|
|
23
23
|
value.forEach((item) => registerCommand(item));
|
|
24
24
|
} else {
|
|
25
|
-
commands.
|
|
25
|
+
commands.set(value.command, value);
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
const unregisterCommand = (command) => {
|
|
29
|
-
commands.
|
|
29
|
+
commands.delete(command);
|
|
30
30
|
};
|
|
31
31
|
const exec = (command, ...args) => {
|
|
32
32
|
const [name, arg1] = command.split(":");
|
|
33
33
|
if (arg1 !== void 0) {
|
|
34
34
|
args.unshift(arg1);
|
|
35
35
|
}
|
|
36
|
-
const item = commands.
|
|
36
|
+
const item = commands.get(name);
|
|
37
37
|
if (!item) {
|
|
38
38
|
throw new Error(`Command "${name}" not found`);
|
|
39
39
|
}
|
|
@@ -847,7 +847,7 @@ class Doc extends Model {
|
|
|
847
847
|
});
|
|
848
848
|
node._text = markRaw(node._text);
|
|
849
849
|
node.text.update();
|
|
850
|
-
node.
|
|
850
|
+
node.requestRender();
|
|
851
851
|
}
|
|
852
852
|
this._proxyChildren(node, yEle.get("childrenIds"));
|
|
853
853
|
}
|
|
@@ -1088,6 +1088,7 @@ const en = {
|
|
|
1088
1088
|
"polygon": "Polygon",
|
|
1089
1089
|
"star": "Star",
|
|
1090
1090
|
"image": "Image",
|
|
1091
|
+
"pen": "Pen",
|
|
1091
1092
|
"pencil": "Pencil",
|
|
1092
1093
|
"file": "File",
|
|
1093
1094
|
"new": "New",
|
|
@@ -1188,6 +1189,7 @@ const zhHans = {
|
|
|
1188
1189
|
"polygon": "多边形",
|
|
1189
1190
|
"star": "星形",
|
|
1190
1191
|
"image": "图片",
|
|
1192
|
+
"pen": "钢笔",
|
|
1191
1193
|
"pencil": "铅笔",
|
|
1192
1194
|
"file": "文件",
|
|
1193
1195
|
"new": "新建",
|
|
@@ -1631,7 +1633,7 @@ const _1_hotkey = defineMixin((editor) => {
|
|
|
1631
1633
|
registerConfig
|
|
1632
1634
|
} = editor;
|
|
1633
1635
|
const hotkeysData = registerConfig("hotkeys", []);
|
|
1634
|
-
const hotkeys =
|
|
1636
|
+
const hotkeys = reactive(/* @__PURE__ */ new Map());
|
|
1635
1637
|
function registerHotkey(value) {
|
|
1636
1638
|
if (Array.isArray(value)) {
|
|
1637
1639
|
value.forEach((item) => registerHotkey(item));
|
|
@@ -1648,7 +1650,7 @@ const _1_hotkey = defineMixin((editor) => {
|
|
|
1648
1650
|
...hotkeysData.value.filter((v) => v.command !== command),
|
|
1649
1651
|
hotkeyData
|
|
1650
1652
|
];
|
|
1651
|
-
hotkeys.
|
|
1653
|
+
hotkeys.set(command, value);
|
|
1652
1654
|
}
|
|
1653
1655
|
}
|
|
1654
1656
|
function unregisterHotkey(command) {
|
|
@@ -1734,7 +1736,7 @@ const _1_hotkey = defineMixin((editor) => {
|
|
|
1734
1736
|
].filter(Boolean).map((v) => v.toLowerCase()).sort().join("+");
|
|
1735
1737
|
hotkeysData.value.forEach((hotkeyData) => {
|
|
1736
1738
|
const command = hotkeyData.command;
|
|
1737
|
-
const hotkey = hotkeys.
|
|
1739
|
+
const hotkey = hotkeys.get(command);
|
|
1738
1740
|
const keys = Array.isArray(hotkeyData.key) ? hotkeyData.key : [hotkeyData.key];
|
|
1739
1741
|
keys.forEach((key) => {
|
|
1740
1742
|
const tKey = key.split("+").map((v) => {
|
|
@@ -2091,21 +2093,21 @@ const _2_box = defineMixin((editor) => {
|
|
|
2091
2093
|
});
|
|
2092
2094
|
});
|
|
2093
2095
|
const _2_export = defineMixin((editor) => {
|
|
2094
|
-
const exporters =
|
|
2096
|
+
const exporters = reactive(/* @__PURE__ */ new Map());
|
|
2095
2097
|
const exporting = ref(false);
|
|
2096
2098
|
const exportProgress = ref(0);
|
|
2097
2099
|
const registerExporter = (value) => {
|
|
2098
2100
|
if (Array.isArray(value)) {
|
|
2099
2101
|
value.forEach((item) => registerExporter(item));
|
|
2100
2102
|
} else {
|
|
2101
|
-
exporters.
|
|
2103
|
+
exporters.set(value.name, value);
|
|
2102
2104
|
}
|
|
2103
2105
|
};
|
|
2104
2106
|
const unregisterExporter = (name) => {
|
|
2105
|
-
exporters.
|
|
2107
|
+
exporters.delete(name);
|
|
2106
2108
|
};
|
|
2107
2109
|
const to = (name, options = {}) => {
|
|
2108
|
-
const res = exporters.
|
|
2110
|
+
const res = exporters.get(name)?.handle({
|
|
2109
2111
|
...options,
|
|
2110
2112
|
onProgress: (progress) => {
|
|
2111
2113
|
exportProgress.value = progress;
|
|
@@ -2136,19 +2138,19 @@ const _2_load = defineMixin((editor) => {
|
|
|
2136
2138
|
const {
|
|
2137
2139
|
state
|
|
2138
2140
|
} = editor;
|
|
2139
|
-
const loaders =
|
|
2141
|
+
const loaders = reactive(/* @__PURE__ */ new Map());
|
|
2140
2142
|
const registerLoader = (value) => {
|
|
2141
2143
|
if (Array.isArray(value)) {
|
|
2142
2144
|
value.forEach((v) => registerLoader(v));
|
|
2143
2145
|
} else {
|
|
2144
|
-
loaders.
|
|
2146
|
+
loaders.set(value.name, value);
|
|
2145
2147
|
}
|
|
2146
2148
|
};
|
|
2147
2149
|
const unregisterLoader = (key) => {
|
|
2148
|
-
loaders.
|
|
2150
|
+
loaders.delete(key);
|
|
2149
2151
|
};
|
|
2150
2152
|
const canLoad = async (source) => {
|
|
2151
|
-
for (const loader of loaders.
|
|
2153
|
+
for (const loader of loaders.values()) {
|
|
2152
2154
|
if (await loader.test(source)) {
|
|
2153
2155
|
return true;
|
|
2154
2156
|
}
|
|
@@ -2159,7 +2161,7 @@ const _2_load = defineMixin((editor) => {
|
|
|
2159
2161
|
state.value = "loading";
|
|
2160
2162
|
const items = [];
|
|
2161
2163
|
try {
|
|
2162
|
-
for (const loader of loaders.
|
|
2164
|
+
for (const loader of loaders.values()) {
|
|
2163
2165
|
if (await loader.test(source)) {
|
|
2164
2166
|
const res = await loader.load(source);
|
|
2165
2167
|
if (Array.isArray(res)) {
|
|
@@ -2184,7 +2186,7 @@ const _2_load = defineMixin((editor) => {
|
|
|
2184
2186
|
} = options;
|
|
2185
2187
|
return new Promise((resolve) => {
|
|
2186
2188
|
const accepts = [];
|
|
2187
|
-
for (const loader of loaders.
|
|
2189
|
+
for (const loader of loaders.values()) {
|
|
2188
2190
|
if (loader.accept) {
|
|
2189
2191
|
accepts.push(loader.accept);
|
|
2190
2192
|
}
|
|
@@ -2342,7 +2344,7 @@ const _4_0_text = defineMixin((editor) => {
|
|
|
2342
2344
|
});
|
|
2343
2345
|
});
|
|
2344
2346
|
}
|
|
2345
|
-
element3.
|
|
2347
|
+
element3.requestRender();
|
|
2346
2348
|
}
|
|
2347
2349
|
_handle(element2);
|
|
2348
2350
|
element2.findOne((descendant) => {
|
|
@@ -2380,7 +2382,7 @@ const _4_0_text = defineMixin((editor) => {
|
|
|
2380
2382
|
if (element3.style.width !== boundingBox.width || element3.style.height !== boundingBox.height) {
|
|
2381
2383
|
element3.style.width = boundingBox.width;
|
|
2382
2384
|
element3.style.height = boundingBox.height;
|
|
2383
|
-
element3.
|
|
2385
|
+
element3.requestRender();
|
|
2384
2386
|
}
|
|
2385
2387
|
}
|
|
2386
2388
|
_handle(element2);
|
|
@@ -2528,7 +2530,7 @@ const _4_0_text = defineMixin((editor) => {
|
|
|
2528
2530
|
});
|
|
2529
2531
|
el.text.content = content;
|
|
2530
2532
|
}
|
|
2531
|
-
element.value.
|
|
2533
|
+
element.value.requestRender();
|
|
2532
2534
|
textToFit(element.value);
|
|
2533
2535
|
}
|
|
2534
2536
|
function getTextFill() {
|
|
@@ -2779,7 +2781,7 @@ const _4_2_element = defineMixin((editor) => {
|
|
|
2779
2781
|
style.top = style.top * scaleY;
|
|
2780
2782
|
style.width = style.width * scaleX;
|
|
2781
2783
|
style.height = style.height * scaleY;
|
|
2782
|
-
element2?.
|
|
2784
|
+
element2?.requestRender?.();
|
|
2783
2785
|
}
|
|
2784
2786
|
handle(element);
|
|
2785
2787
|
function deepHandle(element2) {
|
|
@@ -3568,7 +3570,7 @@ const _copyAs = definePlugin((editor) => {
|
|
|
3568
3570
|
selected: true,
|
|
3569
3571
|
...options
|
|
3570
3572
|
});
|
|
3571
|
-
const exporter = exporters.
|
|
3573
|
+
const exporter = exporters.get(key);
|
|
3572
3574
|
if (exporter && typeof exporter.copyAs === "function") {
|
|
3573
3575
|
res = exporter.copyAs(res);
|
|
3574
3576
|
}
|
|
@@ -3773,6 +3775,7 @@ const aliases = {
|
|
|
3773
3775
|
unvisible: "m16.1 13.3l-1.45-1.45q.225-1.175-.675-2.2t-2.325-.8L10.2 7.4q.425-.2.863-.3T12 7q1.875 0 3.188 1.313T16.5 11.5q0 .5-.1.938t-.3.862m3.2 3.15l-1.45-1.4q.95-.725 1.688-1.587T20.8 11.5q-1.25-2.525-3.588-4.012T12 6q-.725 0-1.425.1T9.2 6.4L7.65 4.85q1.025-.425 2.1-.638T12 4q3.775 0 6.725 2.087T23 11.5q-.575 1.475-1.513 2.738T19.3 16.45m.5 6.15l-4.2-4.15q-.875.275-1.762.413T12 19q-3.775 0-6.725-2.087T1 11.5q.525-1.325 1.325-2.463T4.15 7L1.4 4.2l1.4-1.4l18.4 18.4zM5.55 8.4q-.725.65-1.325 1.425T3.2 11.5q1.25 2.525 3.588 4.013T12 17q.5 0 .975-.062t.975-.138l-.9-.95q-.275.075-.525.113T12 16q-1.875 0-3.188-1.312T7.5 11.5q0-.275.038-.525t.112-.525zm4.2 4.2",
|
|
3774
3776
|
move: "M10.07 14.27a.997.997 0 0 1 1.33.48l2.3 4.99l1.8-.85l-2.31-4.98c-.24-.5-.02-1.1.48-1.33l.28-.08l2.3-.45L8 5.12V15.9l1.82-1.47zm3.57 7.7a.99.99 0 0 1-1.33-.47l-2.18-4.74l-2.51 2.02c-.17.14-.38.22-.62.22a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1c.24 0 .47.09.64.23l.01-.01l11.49 9.64a1.001 1.001 0 0 1-.44 1.75l-3.16.62l2.2 4.73c.26.5.02 1.09-.48 1.32z",
|
|
3775
3777
|
hand: "M21 7a2.5 2.5 0 0 0-2.5-2.5c-.17 0-.34 0-.5.05V4a2.5 2.5 0 0 0-3.17-2.41A2.51 2.51 0 0 0 12.5 0c-1.23 0-2.25.89-2.46 2.06C9.87 2 9.69 2 9.5 2A2.5 2.5 0 0 0 7 4.5v5.89c-.34-.31-.76-.54-1.22-.66L5 9.5c-.82-.21-1.69.11-2.18.85c-.38.57-.4 1.31-.15 1.95l2.56 6.43A8.36 8.36 0 0 0 13 24c4.42 0 8-3.58 8-8zm-2 9c0 3.31-2.69 6-6 6a6.36 6.36 0 0 1-5.91-4L4.5 11.45l.5.14c.5.12.85.46 1 .91L7 15h2V4.5c0-.28.22-.5.5-.5s.5.22.5.5V12h2V2.5c0-.28.22-.5.5-.5s.5.22.5.5V12h2V4c0-.28.22-.5.5-.5s.5.22.5.5v8h2V7c0-.28.22-.5.5-.5s.5.22.5.5z",
|
|
3778
|
+
pen: "m15.54 3.5l4.96 4.97l-1.43 1.41l-4.95-4.95zM3.5 19.78l6.5-6.47c-.1-.31-.03-.7.23-.96c.39-.39 1.03-.39 1.42 0c.39.4.39 1.03 0 1.42c-.26.26-.65.33-.96.23l-6.47 6.5l10.61-3.55l3.53-6.36l-4.94-4.95l-6.37 3.53z",
|
|
3776
3779
|
pencil: "m14.06 9l.94.94L5.92 19H5v-.92zm3.6-6c-.25 0-.51.1-.7.29l-1.83 1.83l3.75 3.75l1.83-1.83c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29m-3.6 3.19L3 17.25V21h3.75L17.81 9.94z",
|
|
3777
3780
|
rectangle: "M4 6v13h16V6zm14 11H6V8h12z",
|
|
3778
3781
|
line: "M15 3v4.59L7.59 15H3v6h6v-4.58L16.42 9H21V3m-4 2h2v2h-2M5 17h2v2H5",
|
|
@@ -5010,7 +5013,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5010
5013
|
}
|
|
5011
5014
|
});
|
|
5012
5015
|
const _hoisted_1$k = { class: "mce-layer__name" };
|
|
5013
|
-
const _hoisted_2$
|
|
5016
|
+
const _hoisted_2$b = { class: "mce-layer__action" };
|
|
5014
5017
|
const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
5015
5018
|
...{
|
|
5016
5019
|
name: "MceLayer",
|
|
@@ -5249,7 +5252,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
5249
5252
|
style: normalizeStyle({ visibility: editing.value ? "hidden" : void 0 })
|
|
5250
5253
|
}, toDisplayString(editValue.value || props.node.name || props.node.id), 5)
|
|
5251
5254
|
]),
|
|
5252
|
-
createElementVNode("div", _hoisted_2$
|
|
5255
|
+
createElementVNode("div", _hoisted_2$b, [
|
|
5253
5256
|
props.root ? (openBlock(), createBlock(_sfc_main$x, {
|
|
5254
5257
|
key: 0,
|
|
5255
5258
|
class: normalizeClass(["mce-layer__btn", {
|
|
@@ -5307,7 +5310,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
5307
5310
|
}
|
|
5308
5311
|
});
|
|
5309
5312
|
const _hoisted_1$j = { class: "mce-layers" };
|
|
5310
|
-
const _hoisted_2$
|
|
5313
|
+
const _hoisted_2$a = { class: "mce-layers__wrapper" };
|
|
5311
5314
|
const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
5312
5315
|
__name: "Layers",
|
|
5313
5316
|
setup(__props) {
|
|
@@ -5357,7 +5360,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
5357
5360
|
});
|
|
5358
5361
|
return (_ctx, _cache) => {
|
|
5359
5362
|
return openBlock(), createElementBlock("div", _hoisted_1$j, [
|
|
5360
|
-
createElementVNode("div", _hoisted_2$
|
|
5363
|
+
createElementVNode("div", _hoisted_2$a, [
|
|
5361
5364
|
createVNode(_sfc_main$w, {
|
|
5362
5365
|
root: true,
|
|
5363
5366
|
node: unref(root),
|
|
@@ -5548,8 +5551,8 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
5548
5551
|
}
|
|
5549
5552
|
});
|
|
5550
5553
|
const _hoisted_1$h = ["onMouseenter"];
|
|
5551
|
-
const _hoisted_2$
|
|
5552
|
-
const _hoisted_3$
|
|
5554
|
+
const _hoisted_2$9 = ["onClick"];
|
|
5555
|
+
const _hoisted_3$9 = {
|
|
5553
5556
|
key: 0,
|
|
5554
5557
|
class: "mce-list-item__checked"
|
|
5555
5558
|
};
|
|
@@ -5693,7 +5696,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
5693
5696
|
]]),
|
|
5694
5697
|
onClick: (e) => onClickItem(item, index, e)
|
|
5695
5698
|
}, [
|
|
5696
|
-
hasPrepend.value ? (openBlock(), createElementBlock("div", _hoisted_3$
|
|
5699
|
+
hasPrepend.value ? (openBlock(), createElementBlock("div", _hoisted_3$9, [
|
|
5697
5700
|
item.checked ? (openBlock(), createBlock(unref(_sfc_main$B), {
|
|
5698
5701
|
key: 0,
|
|
5699
5702
|
icon: "$check"
|
|
@@ -5717,7 +5720,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
5717
5720
|
icon: "$arrowRight"
|
|
5718
5721
|
})) : createCommentVNode("", true)
|
|
5719
5722
|
])) : createCommentVNode("", true)
|
|
5720
|
-
], 10, _hoisted_2$
|
|
5723
|
+
], 10, _hoisted_2$9)
|
|
5721
5724
|
], 40, _hoisted_1$h))
|
|
5722
5725
|
], 64);
|
|
5723
5726
|
}), 128)),
|
|
@@ -5870,7 +5873,7 @@ const _menu = definePlugin((editor, options) => {
|
|
|
5870
5873
|
const hasSelected = computed(() => selection.value.length > 0);
|
|
5871
5874
|
const exportMenu = computed(() => ({
|
|
5872
5875
|
key: "export",
|
|
5873
|
-
children: [...exporters.
|
|
5876
|
+
children: [...exporters.values()].filter((v) => Boolean(v.saveAs)).map((v) => ({ key: `saveAs:${v.name}` }))
|
|
5874
5877
|
}));
|
|
5875
5878
|
const fileMenu = computed(() => ({
|
|
5876
5879
|
key: "file",
|
|
@@ -5889,7 +5892,7 @@ const _menu = definePlugin((editor, options) => {
|
|
|
5889
5892
|
const copyAsMenu = computed(() => ({
|
|
5890
5893
|
key: "copyAs",
|
|
5891
5894
|
disabled: !hasSelected.value,
|
|
5892
|
-
children: [...exporters.
|
|
5895
|
+
children: [...exporters.values()].filter((v) => Boolean(v.copyAs)).map((v) => ({ key: `copyAs:${v.name}` }))
|
|
5893
5896
|
}));
|
|
5894
5897
|
const editMenus1 = computed(() => [
|
|
5895
5898
|
{ key: "copy", disabled: !hasSelected.value },
|
|
@@ -10072,13 +10075,52 @@ const _pen = definePlugin((editor) => {
|
|
|
10072
10075
|
const {
|
|
10073
10076
|
addElement
|
|
10074
10077
|
} = editor;
|
|
10078
|
+
let pening = false;
|
|
10079
|
+
let el;
|
|
10080
|
+
let path;
|
|
10075
10081
|
return {
|
|
10076
10082
|
name: "mce:pen",
|
|
10077
10083
|
drawingTools: [
|
|
10084
|
+
{
|
|
10085
|
+
name: "pen",
|
|
10086
|
+
handle: (start) => {
|
|
10087
|
+
if (pening) {
|
|
10088
|
+
path.lineTo(start.x, start.y);
|
|
10089
|
+
path.moveTo(start.x, start.y);
|
|
10090
|
+
el.shape.paths = [
|
|
10091
|
+
{ data: path.toData() }
|
|
10092
|
+
];
|
|
10093
|
+
const box = path.getBoundingBox();
|
|
10094
|
+
el.style.left = box.left;
|
|
10095
|
+
el.style.top = box.top;
|
|
10096
|
+
el.style.width = box.width;
|
|
10097
|
+
el.style.height = box.height;
|
|
10098
|
+
} else {
|
|
10099
|
+
pening = true;
|
|
10100
|
+
el = addElement({
|
|
10101
|
+
name: "pen",
|
|
10102
|
+
outline: {
|
|
10103
|
+
color: "#d9d9d9",
|
|
10104
|
+
width: 5,
|
|
10105
|
+
lineCap: "round",
|
|
10106
|
+
lineJoin: "round"
|
|
10107
|
+
},
|
|
10108
|
+
meta: {
|
|
10109
|
+
inPptIs: "Shape"
|
|
10110
|
+
}
|
|
10111
|
+
}, {
|
|
10112
|
+
active: true,
|
|
10113
|
+
position: start
|
|
10114
|
+
});
|
|
10115
|
+
path = new Path2D();
|
|
10116
|
+
path.moveTo(start.x, start.y);
|
|
10117
|
+
}
|
|
10118
|
+
}
|
|
10119
|
+
},
|
|
10078
10120
|
{
|
|
10079
10121
|
name: "pencil",
|
|
10080
10122
|
handle: (start) => {
|
|
10081
|
-
const
|
|
10123
|
+
const el2 = addElement({
|
|
10082
10124
|
name: "pencil",
|
|
10083
10125
|
outline: {
|
|
10084
10126
|
color: "#d9d9d9",
|
|
@@ -10092,20 +10134,20 @@ const _pen = definePlugin((editor) => {
|
|
|
10092
10134
|
}, {
|
|
10093
10135
|
position: start
|
|
10094
10136
|
});
|
|
10095
|
-
const
|
|
10096
|
-
|
|
10137
|
+
const path2 = new Path2D();
|
|
10138
|
+
path2.moveTo(start.x, start.y);
|
|
10097
10139
|
return {
|
|
10098
10140
|
move: (move) => {
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
{ data:
|
|
10141
|
+
path2.lineTo(move.x, move.y);
|
|
10142
|
+
path2.moveTo(move.x, move.y);
|
|
10143
|
+
el2.shape.paths = [
|
|
10144
|
+
{ data: path2.toData() }
|
|
10103
10145
|
];
|
|
10104
|
-
const box =
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10146
|
+
const box = path2.getBoundingBox();
|
|
10147
|
+
el2.style.left = box.left;
|
|
10148
|
+
el2.style.top = box.top;
|
|
10149
|
+
el2.style.width = box.width;
|
|
10150
|
+
el2.style.height = box.height;
|
|
10109
10151
|
},
|
|
10110
10152
|
end: () => {
|
|
10111
10153
|
}
|
|
@@ -10114,13 +10156,19 @@ const _pen = definePlugin((editor) => {
|
|
|
10114
10156
|
}
|
|
10115
10157
|
],
|
|
10116
10158
|
hotkeys: [
|
|
10159
|
+
{ command: "setActiveDrawingTool:pen", key: "p" },
|
|
10117
10160
|
{ command: "setActiveDrawingTool:pencil", key: "Shift+p" }
|
|
10118
10161
|
]
|
|
10119
10162
|
};
|
|
10120
10163
|
});
|
|
10121
10164
|
const _hoisted_1$g = {
|
|
10122
10165
|
key: 0,
|
|
10123
|
-
class: "mce-
|
|
10166
|
+
class: "mce-tooltip__arrow"
|
|
10167
|
+
};
|
|
10168
|
+
const _hoisted_2$8 = { class: "mce-tooltip__content" };
|
|
10169
|
+
const _hoisted_3$8 = {
|
|
10170
|
+
key: 0,
|
|
10171
|
+
class: "mce-tooltip__kbd"
|
|
10124
10172
|
};
|
|
10125
10173
|
const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
10126
10174
|
__name: "Tooltip",
|
|
@@ -10128,7 +10176,8 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
10128
10176
|
...makeMceOverlayProps({
|
|
10129
10177
|
location: "right",
|
|
10130
10178
|
offset: 8
|
|
10131
|
-
})
|
|
10179
|
+
}),
|
|
10180
|
+
showArrow: Boolean
|
|
10132
10181
|
}, {
|
|
10133
10182
|
"modelValue": { type: Boolean },
|
|
10134
10183
|
"modelModifiers": {}
|
|
@@ -10138,6 +10187,13 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
10138
10187
|
const props = __props;
|
|
10139
10188
|
const isActive = useModel(__props, "modelValue");
|
|
10140
10189
|
const overlay = useTemplateRef("overlayTpl");
|
|
10190
|
+
const classes = computed(() => {
|
|
10191
|
+
const [side, align = "center"] = props.location.split("-");
|
|
10192
|
+
return [
|
|
10193
|
+
`mce-tooltip--side-${side}`,
|
|
10194
|
+
`mce-tooltip--align-${align}`
|
|
10195
|
+
];
|
|
10196
|
+
});
|
|
10141
10197
|
function updateLocation() {
|
|
10142
10198
|
overlay.value?.updateLocation();
|
|
10143
10199
|
}
|
|
@@ -10149,16 +10205,22 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
10149
10205
|
ref: "overlayTpl",
|
|
10150
10206
|
modelValue: isActive.value,
|
|
10151
10207
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isActive.value = $event),
|
|
10152
|
-
class: "mce-tooltip",
|
|
10208
|
+
class: normalizeClass(["mce-tooltip", classes.value]),
|
|
10153
10209
|
location: props.location,
|
|
10154
10210
|
offset: props.offset,
|
|
10155
10211
|
target: props.target,
|
|
10156
10212
|
attach: props.attach
|
|
10157
10213
|
}, createSlots({
|
|
10158
10214
|
default: withCtx(() => [
|
|
10159
|
-
isActive.value ? (openBlock(), createElementBlock(
|
|
10160
|
-
|
|
10161
|
-
|
|
10215
|
+
isActive.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
10216
|
+
__props.showArrow ? (openBlock(), createElementBlock("div", _hoisted_1$g)) : createCommentVNode("", true),
|
|
10217
|
+
createElementVNode("div", _hoisted_2$8, [
|
|
10218
|
+
renderSlot(_ctx.$slots, "default"),
|
|
10219
|
+
_ctx.$slots.kbd ? (openBlock(), createElementBlock("div", _hoisted_3$8, [
|
|
10220
|
+
renderSlot(_ctx.$slots, "kbd")
|
|
10221
|
+
])) : createCommentVNode("", true)
|
|
10222
|
+
])
|
|
10223
|
+
], 64)) : createCommentVNode("", true)
|
|
10162
10224
|
]),
|
|
10163
10225
|
_: 2
|
|
10164
10226
|
}, [
|
|
@@ -10175,13 +10237,13 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
10175
10237
|
]),
|
|
10176
10238
|
key: "0"
|
|
10177
10239
|
} : void 0
|
|
10178
|
-
]), 1032, ["modelValue", "location", "offset", "target", "attach"]);
|
|
10240
|
+
]), 1032, ["modelValue", "class", "location", "offset", "target", "attach"]);
|
|
10179
10241
|
};
|
|
10180
10242
|
}
|
|
10181
10243
|
});
|
|
10182
10244
|
const _hoisted_1$f = ["width", "height"];
|
|
10183
10245
|
const _hoisted_2$7 = ["onDblclick", "onMousedown", "onMousemove"];
|
|
10184
|
-
const _hoisted_3$7 = { style: { "font-size": "
|
|
10246
|
+
const _hoisted_3$7 = { style: { "font-size": "0.75rem", "text-wrap": "nowrap" } };
|
|
10185
10247
|
const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
10186
10248
|
...{
|
|
10187
10249
|
inheritAttrs: false
|
|
@@ -10543,7 +10605,7 @@ const _saveAs = definePlugin((editor) => {
|
|
|
10543
10605
|
selected: true,
|
|
10544
10606
|
...restOptions
|
|
10545
10607
|
});
|
|
10546
|
-
const exporter = exporters.
|
|
10608
|
+
const exporter = exporters.get(key);
|
|
10547
10609
|
if (exporter && typeof exporter.saveAs === "function") {
|
|
10548
10610
|
res = exporter.saveAs(res);
|
|
10549
10611
|
}
|
|
@@ -12358,7 +12420,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
12358
12420
|
};
|
|
12359
12421
|
}
|
|
12360
12422
|
});
|
|
12361
|
-
const ProgressIndicator = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__scopeId", "data-v-
|
|
12423
|
+
const ProgressIndicator = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__scopeId", "data-v-3b286483"]]);
|
|
12362
12424
|
const _hoisted_1$a = { class: "mce-statusbar" };
|
|
12363
12425
|
const _hoisted_2$5 = { class: "mce-statusbar__main" };
|
|
12364
12426
|
const _hoisted_3$5 = { class: "mce-statusbar__item" };
|
|
@@ -12456,7 +12518,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
12456
12518
|
};
|
|
12457
12519
|
}
|
|
12458
12520
|
});
|
|
12459
|
-
const Statusbar = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-
|
|
12521
|
+
const Statusbar = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-a57093aa"]]);
|
|
12460
12522
|
const _statusbar = definePlugin((editor) => {
|
|
12461
12523
|
const {
|
|
12462
12524
|
registerConfig
|
|
@@ -12840,14 +12902,8 @@ const _timeline = definePlugin((editor) => {
|
|
|
12840
12902
|
};
|
|
12841
12903
|
});
|
|
12842
12904
|
const _hoisted_1$5 = { class: "mce-toolbelt" };
|
|
12843
|
-
const _hoisted_2$2 = {
|
|
12844
|
-
|
|
12845
|
-
class: "mce-toolbelt__kbd"
|
|
12846
|
-
};
|
|
12847
|
-
const _hoisted_3$2 = {
|
|
12848
|
-
key: 1,
|
|
12849
|
-
class: "mce-toolbelt__kbd"
|
|
12850
|
-
};
|
|
12905
|
+
const _hoisted_2$2 = { key: 0 };
|
|
12906
|
+
const _hoisted_3$2 = { key: 1 };
|
|
12851
12907
|
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
12852
12908
|
__name: "Toolbelt",
|
|
12853
12909
|
setup(__props) {
|
|
@@ -12859,9 +12915,10 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
12859
12915
|
hotkeys,
|
|
12860
12916
|
getKbd
|
|
12861
12917
|
} = useEditor();
|
|
12862
|
-
const
|
|
12918
|
+
const activeShape = ref(0);
|
|
12919
|
+
const activePen = ref(0);
|
|
12863
12920
|
const shapeItems = computed(() => {
|
|
12864
|
-
const
|
|
12921
|
+
const keys = [
|
|
12865
12922
|
"rectangle",
|
|
12866
12923
|
"line",
|
|
12867
12924
|
"arrow",
|
|
@@ -12870,11 +12927,11 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
12870
12927
|
"star"
|
|
12871
12928
|
];
|
|
12872
12929
|
return [
|
|
12873
|
-
...
|
|
12930
|
+
...keys.map((key, index) => {
|
|
12874
12931
|
return {
|
|
12875
12932
|
key,
|
|
12876
12933
|
handle: () => {
|
|
12877
|
-
|
|
12934
|
+
activeShape.value = index;
|
|
12878
12935
|
setActiveDrawingTool(key);
|
|
12879
12936
|
},
|
|
12880
12937
|
checked: activeDrawingTool.value?.name === key
|
|
@@ -12887,6 +12944,24 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
12887
12944
|
}
|
|
12888
12945
|
];
|
|
12889
12946
|
});
|
|
12947
|
+
const penItems = computed(() => {
|
|
12948
|
+
const keys = [
|
|
12949
|
+
"pen",
|
|
12950
|
+
"pencil"
|
|
12951
|
+
];
|
|
12952
|
+
return [
|
|
12953
|
+
...keys.map((key, index) => {
|
|
12954
|
+
return {
|
|
12955
|
+
key,
|
|
12956
|
+
handle: () => {
|
|
12957
|
+
activePen.value = index;
|
|
12958
|
+
setActiveDrawingTool(key);
|
|
12959
|
+
},
|
|
12960
|
+
checked: activeDrawingTool.value?.name === key
|
|
12961
|
+
};
|
|
12962
|
+
})
|
|
12963
|
+
];
|
|
12964
|
+
});
|
|
12890
12965
|
const items = computed(() => {
|
|
12891
12966
|
return [
|
|
12892
12967
|
{
|
|
@@ -12909,7 +12984,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
12909
12984
|
handle: () => setActiveDrawingTool("frame")
|
|
12910
12985
|
},
|
|
12911
12986
|
{
|
|
12912
|
-
...shapeItems.value.find((v) => v.checked) ?? shapeItems.value[
|
|
12987
|
+
...shapeItems.value.find((v) => v.checked) ?? shapeItems.value[activeShape.value],
|
|
12913
12988
|
children: shapeItems.value
|
|
12914
12989
|
},
|
|
12915
12990
|
{
|
|
@@ -12918,9 +12993,8 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
12918
12993
|
handle: () => setActiveDrawingTool("text")
|
|
12919
12994
|
},
|
|
12920
12995
|
{
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
handle: () => setActiveDrawingTool("pencil")
|
|
12996
|
+
...penItems.value.find((v) => v.checked) ?? penItems.value[activePen.value],
|
|
12997
|
+
children: penItems.value
|
|
12924
12998
|
}
|
|
12925
12999
|
];
|
|
12926
13000
|
});
|
|
@@ -12931,7 +13005,11 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
12931
13005
|
key,
|
|
12932
13006
|
class: "mce-toolbelt__group"
|
|
12933
13007
|
}, [
|
|
12934
|
-
createVNode(_sfc_main$q, {
|
|
13008
|
+
createVNode(_sfc_main$q, {
|
|
13009
|
+
location: "top",
|
|
13010
|
+
offset: 12,
|
|
13011
|
+
"show-arrow": ""
|
|
13012
|
+
}, {
|
|
12935
13013
|
activator: withCtx(({ props: slotProps }) => [
|
|
12936
13014
|
createVNode(_sfc_main$x, mergeProps({
|
|
12937
13015
|
class: "mce-toolbelt__btn",
|
|
@@ -12948,7 +13026,9 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
12948
13026
|
}, 1040, ["active", "onClick"])
|
|
12949
13027
|
]),
|
|
12950
13028
|
default: withCtx(() => [
|
|
12951
|
-
createElementVNode("span", null, toDisplayString(unref(t)(tool.key)), 1)
|
|
13029
|
+
createElementVNode("span", null, toDisplayString(unref(t)(tool.key)), 1)
|
|
13030
|
+
]),
|
|
13031
|
+
kbd: withCtx(() => [
|
|
12952
13032
|
unref(hotkeys).has(`setState:${tool.key}`) ? (openBlock(), createElementBlock("span", _hoisted_2$2, toDisplayString(unref(getKbd)(`setState:${tool.key}`)), 1)) : unref(hotkeys).has(`setActiveDrawingTool:${tool.key}`) ? (openBlock(), createElementBlock("span", _hoisted_3$2, toDisplayString(unref(getKbd)(`setActiveDrawingTool:${tool.key}`)), 1)) : createCommentVNode("", true)
|
|
12953
13033
|
]),
|
|
12954
13034
|
_: 2
|
|
@@ -15032,6 +15112,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15032
15112
|
return openBlock(), createBlock(_sfc_main$5, {
|
|
15033
15113
|
class: normalizeClass(["mce-editor", [
|
|
15034
15114
|
`mce-editor--${unref(state)}`,
|
|
15115
|
+
unref(activeDrawingTool) && `mce-editor--drawing-tool-${unref(activeDrawingTool).name}`,
|
|
15035
15116
|
grabbing.value && `mce-editor--grabbing`
|
|
15036
15117
|
]])
|
|
15037
15118
|
}, {
|
package/dist/locale/en.d.ts
CHANGED
package/dist/locale/zh-Hans.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Reactive } from 'vue';
|
|
2
2
|
declare global {
|
|
3
3
|
namespace Mce {
|
|
4
4
|
type CommandHandle = (...args: any[]) => any;
|
|
@@ -12,7 +12,7 @@ declare global {
|
|
|
12
12
|
interface Events extends CommandEvents {
|
|
13
13
|
}
|
|
14
14
|
interface Editor {
|
|
15
|
-
commands:
|
|
15
|
+
commands: Reactive<Map<string, Command>>;
|
|
16
16
|
registerCommand: (value: Command | Command[]) => void;
|
|
17
17
|
unregisterCommand: (command: string) => void;
|
|
18
18
|
exec: <K extends keyof Commands>(command: K & string, ...args: Parameters<Commands[K]>) => ReturnType<Commands[K]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Reactive, WritableComputedRef } from 'vue';
|
|
2
2
|
declare global {
|
|
3
3
|
namespace Mce {
|
|
4
4
|
interface Hotkeys {
|
|
@@ -26,7 +26,7 @@ declare global {
|
|
|
26
26
|
}
|
|
27
27
|
interface Editor {
|
|
28
28
|
hotkeysData: WritableComputedRef<HotkeyData[]>;
|
|
29
|
-
hotkeys:
|
|
29
|
+
hotkeys: Reactive<Map<string, Hotkey>>;
|
|
30
30
|
registerHotkey: (value: Hotkey | Hotkey[]) => void;
|
|
31
31
|
unregisterHotkey: (command: string) => void;
|
|
32
32
|
getKbd: (command: string) => string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Element2D } from 'modern-canvas';
|
|
2
|
-
import type { Ref } from 'vue';
|
|
2
|
+
import type { Reactive, Ref } from 'vue';
|
|
3
3
|
declare global {
|
|
4
4
|
namespace Mce {
|
|
5
5
|
type ExportOnProgress = (progress: number) => void;
|
|
@@ -16,7 +16,7 @@ declare global {
|
|
|
16
16
|
handle: ExporterHandle;
|
|
17
17
|
}
|
|
18
18
|
interface Editor {
|
|
19
|
-
exporters:
|
|
19
|
+
exporters: Reactive<Map<string, Exporter>>;
|
|
20
20
|
registerExporter: (value: Exporter | Exporter[]) => void;
|
|
21
21
|
unregisterExporter: (name: string) => void;
|
|
22
22
|
export: <K extends keyof Exporters>(name: K, options?: ExportOptions) => Exporters[K];
|