mce 0.15.14 → 0.15.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +10 -0
- package/dist/index.js +84 -13
- package/dist/locale/en.d.ts +2 -0
- package/dist/locale/zh-Hans.d.ts +2 -0
- package/dist/mixins/1.timeline.d.ts +4 -4
- package/dist/plugins/panels.d.ts +1 -1
- package/package.json +4 -4
package/dist/index.css
CHANGED
|
@@ -900,6 +900,16 @@
|
|
|
900
900
|
white-space: nowrap;
|
|
901
901
|
overflow: hidden;
|
|
902
902
|
text-overflow: ellipsis;
|
|
903
|
+
}
|
|
904
|
+
.mce-segment__block {
|
|
905
|
+
position: absolute;
|
|
906
|
+
left: 0;
|
|
907
|
+
top: 0;
|
|
908
|
+
font-size: 12px;
|
|
909
|
+
padding: 0 8px;
|
|
910
|
+
text-wrap: nowrap;
|
|
911
|
+
overflow: visible;
|
|
912
|
+
border-bottom: 1px solid rgb(var(--mce-theme-surface));
|
|
903
913
|
}.mce-track {
|
|
904
914
|
position: relative;
|
|
905
915
|
display: flex;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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, 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,
|
|
1
|
+
import { Node as Node$1, Element2D, Timeline, Engine, Camera2D, DrawboardEffect, Aabb2D, IN_BROWSER, clamp, assets, TimelineNode, Video2D, Transform2D, Obb2D, render, Vector2 as Vector2$1, Lottie2D, customNodes, Animation, IN_MAC_OS } from "modern-canvas";
|
|
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, withModifiers, vShow, vModelText, nextTick, Fragment, renderList, renderSlot, mergeModels, resolveComponent, 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";
|
|
@@ -1089,6 +1089,8 @@ const en = {
|
|
|
1089
1089
|
"polygon": "Polygon",
|
|
1090
1090
|
"star": "Star",
|
|
1091
1091
|
"image": "Image",
|
|
1092
|
+
"video": "Video",
|
|
1093
|
+
"lottie": "Lottie",
|
|
1092
1094
|
"pen": "Pen",
|
|
1093
1095
|
"pencil": "Pencil",
|
|
1094
1096
|
"file": "File",
|
|
@@ -1195,6 +1197,8 @@ const zhHans = {
|
|
|
1195
1197
|
"polygon": "多边形",
|
|
1196
1198
|
"star": "星形",
|
|
1197
1199
|
"image": "图片",
|
|
1200
|
+
"video": "视频",
|
|
1201
|
+
"lottie": "Lottie",
|
|
1198
1202
|
"pen": "钢笔",
|
|
1199
1203
|
"pencil": "铅笔",
|
|
1200
1204
|
"file": "文件",
|
|
@@ -1756,9 +1760,15 @@ const _1_timeline = defineMixin((editor) => {
|
|
|
1756
1760
|
timeline.value.currentTime = clamp(val, startTime2, endTime2);
|
|
1757
1761
|
}
|
|
1758
1762
|
});
|
|
1759
|
-
const startTime = computed(
|
|
1760
|
-
|
|
1761
|
-
|
|
1763
|
+
const startTime = computed({
|
|
1764
|
+
get: () => timeline.value.startTime,
|
|
1765
|
+
set: (val) => timeline.value.startTime = val
|
|
1766
|
+
});
|
|
1767
|
+
const endTime = computed({
|
|
1768
|
+
get: () => timeline.value.endTime,
|
|
1769
|
+
set: (val) => timeline.value.endTime = val
|
|
1770
|
+
});
|
|
1771
|
+
const getTimeRange = (node = root.value) => {
|
|
1762
1772
|
const range = { startTime: 0, endTime: 0 };
|
|
1763
1773
|
function handle(node2) {
|
|
1764
1774
|
if (node2 instanceof TimelineNode) {
|
|
@@ -1779,6 +1789,11 @@ const _1_timeline = defineMixin((editor) => {
|
|
|
1779
1789
|
range.endTime = Math.max(range.endTime, node2.globalStartTime + node2.outline.animatedTexture.duration);
|
|
1780
1790
|
}
|
|
1781
1791
|
}
|
|
1792
|
+
if (node2 instanceof Video2D) {
|
|
1793
|
+
if (node2.texture) {
|
|
1794
|
+
range.endTime = Math.max(range.endTime, node2.globalStartTime + node2.videoDuration);
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1782
1797
|
return false;
|
|
1783
1798
|
}
|
|
1784
1799
|
const nodes = Array.isArray(node) ? node : [node];
|
|
@@ -3527,7 +3542,18 @@ const _clipboard = definePlugin((editor, options) => {
|
|
|
3527
3542
|
return;
|
|
3528
3543
|
}
|
|
3529
3544
|
addElements(
|
|
3530
|
-
selection.value.map((v) =>
|
|
3545
|
+
selection.value.map((v) => {
|
|
3546
|
+
const el = v.toJSON();
|
|
3547
|
+
if (el.style) {
|
|
3548
|
+
if (el.style.left) {
|
|
3549
|
+
el.style.left += 20;
|
|
3550
|
+
}
|
|
3551
|
+
if (el.style.top) {
|
|
3552
|
+
el.style.top += 20;
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
return el;
|
|
3556
|
+
}),
|
|
3531
3557
|
{
|
|
3532
3558
|
parent: selection.value[0].parent,
|
|
3533
3559
|
index: selection.value[0].getIndex(),
|
|
@@ -3778,6 +3804,8 @@ const aliases = {
|
|
|
3778
3804
|
shape: "M8 17.95q.25.025.488.038T9 18t.513-.012t.487-.038V20h10V10h-2.05q.025-.25.038-.488T18 9t-.012-.513T17.95 8H20q.825 0 1.413.588T22 10v10q0 .825-.587 1.413T20 22H10q-.825 0-1.412-.587T8 20zM9 16q-2.925 0-4.962-2.037T2 9t2.038-4.962T9 2t4.963 2.038T16 9t-2.037 4.963T9 16m0-2q2.075 0 3.538-1.463T14 9t-1.463-3.537T9 4T5.463 5.463T4 9t1.463 3.538T9 14m0-5",
|
|
3779
3805
|
text: "m18.5 4l1.16 4.35l-.96.26c-.45-.87-.91-1.74-1.44-2.18C16.73 6 16.11 6 15.5 6H13v10.5c0 .5 0 1 .33 1.25c.34.25 1 .25 1.67.25v1H9v-1c.67 0 1.33 0 1.67-.25c.33-.25.33-.75.33-1.25V6H8.5c-.61 0-1.23 0-1.76.43c-.53.44-.99 1.31-1.44 2.18l-.96-.26L5.5 4z",
|
|
3780
3806
|
image: "M5 21q-.825 0-1.412-.587T3 19V5q0-.825.588-1.412T5 3h14q.825 0 1.413.588T21 5v14q0 .825-.587 1.413T19 21zm0-2h14V5H5zm1-2h12l-3.75-5l-3 4L9 13zm-1 2V5zm3.5-9q.625 0 1.063-.437T10 8.5t-.437-1.062T8.5 7t-1.062.438T7 8.5t.438 1.063T8.5 10",
|
|
3807
|
+
lottie: "M17 6c-2.8 0-4.4 2.8-5.9 5.5C9.9 13.8 8.7 16 7 16c-.6 0-1 .4-1 1s.4 1 1 1c2.8 0 4.4-2.8 5.9-5.5C14.1 10.2 15.3 8 17 8c.6 0 1-.4 1-1s-.4-1-1-1m2-4H5C3.3 2 2 3.3 2 5v14c0 1.7 1.3 3 3 3h14c1.7 0 3-1.3 3-3V5c0-1.7-1.3-3-3-3m1 17c0 .6-.4 1-1 1H5c-.6 0-1-.4-1-1V5c0-.6.4-1 1-1h14c.6 0 1 .4 1 1z",
|
|
3808
|
+
video: "M15 8v8H5V8zm1-2H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4V7a1 1 0 0 0-1-1",
|
|
3781
3809
|
lock: "M6 22q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8h1V6q0-2.075 1.463-3.537T12 1t3.538 1.463T17 6v2h1q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22zm0-2h12V10H6zm6-3q.825 0 1.413-.587T14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17M9 8h6V6q0-1.25-.875-2.125T12 3t-2.125.875T9 6zM6 20V10z",
|
|
3782
3810
|
unlock: "M6 8h9V6q0-1.25-.875-2.125T12 3t-2.125.875T9 6H7q0-2.075 1.463-3.537T12 1t3.538 1.463T17 6v2h1q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22H6q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8m0 12h12V10H6zm6-3q.825 0 1.413-.587T14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17m-6 3V10z",
|
|
3783
3811
|
visible: "M12 16q1.875 0 3.188-1.312T16.5 11.5t-1.312-3.187T12 7T8.813 8.313T7.5 11.5t1.313 3.188T12 16m0-1.8q-1.125 0-1.912-.788T9.3 11.5t.788-1.912T12 8.8t1.913.788t.787 1.912t-.787 1.913T12 14.2m0 4.8q-3.65 0-6.65-2.037T1 11.5q1.35-3.425 4.35-5.462T12 4t6.65 2.038T23 11.5q-1.35 3.425-4.35 5.463T12 19m0-2q2.825 0 5.188-1.487T20.8 11.5q-1.25-2.525-3.613-4.012T12 6T6.813 7.488T3.2 11.5q1.25 2.525 3.613 4.013T12 17",
|
|
@@ -4371,8 +4399,8 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
4371
4399
|
const editing = ref(false);
|
|
4372
4400
|
async function onDblclick() {
|
|
4373
4401
|
editing.value = true;
|
|
4374
|
-
await nextTick();
|
|
4375
4402
|
if (input.value) {
|
|
4403
|
+
await nextTick();
|
|
4376
4404
|
input.value.focus();
|
|
4377
4405
|
input.value.select();
|
|
4378
4406
|
}
|
|
@@ -4398,7 +4426,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
4398
4426
|
}, [
|
|
4399
4427
|
withDirectives(createElementVNode("div", {
|
|
4400
4428
|
class: "mce-frame__name",
|
|
4401
|
-
onDblclick,
|
|
4429
|
+
onDblclick: withModifiers(onDblclick, ["prevent", "stop"]),
|
|
4402
4430
|
onPointerdown,
|
|
4403
4431
|
onPointerenter: _cache[2] || (_cache[2] = ($event) => !unref(state) && (hoverElement.value = frame.value)),
|
|
4404
4432
|
onPointerleave: _cache[3] || (_cache[3] = ($event) => !unref(state) && (hoverElement.value = void 0))
|
|
@@ -5166,6 +5194,10 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5166
5194
|
return "$frame";
|
|
5167
5195
|
} else if (node.children.filter(isElement).length) {
|
|
5168
5196
|
return "$group";
|
|
5197
|
+
} else if (node instanceof Lottie2D) {
|
|
5198
|
+
return "$lottie";
|
|
5199
|
+
} else if (node instanceof Video2D) {
|
|
5200
|
+
return "$video";
|
|
5169
5201
|
} else if (isElement(node)) {
|
|
5170
5202
|
if (node.foreground.isValid() && node.foreground.image) {
|
|
5171
5203
|
return "$image";
|
|
@@ -5182,8 +5214,12 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5182
5214
|
if (!value) {
|
|
5183
5215
|
if (isFrame(node)) {
|
|
5184
5216
|
return t("frame");
|
|
5185
|
-
} else if (node.children.length) {
|
|
5217
|
+
} else if (node.children.filter(isElement).length) {
|
|
5186
5218
|
value = t("group");
|
|
5219
|
+
} else if (node instanceof Lottie2D) {
|
|
5220
|
+
value = t("lottie");
|
|
5221
|
+
} else if (node instanceof Video2D) {
|
|
5222
|
+
value = t("video");
|
|
5187
5223
|
} else if (isElement(node)) {
|
|
5188
5224
|
if (node.foreground.isValid() && node.foreground.image) {
|
|
5189
5225
|
value = t("image");
|
|
@@ -13008,10 +13044,38 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
13008
13044
|
},
|
|
13009
13045
|
setup(__props) {
|
|
13010
13046
|
const props = __props;
|
|
13047
|
+
const blocks = computed(() => {
|
|
13048
|
+
const node = props.node;
|
|
13049
|
+
if (node instanceof Element2D) {
|
|
13050
|
+
return node.children.filter((child) => child instanceof Animation).map((anim) => {
|
|
13051
|
+
const box = {
|
|
13052
|
+
left: anim.delay / props.msPerPx,
|
|
13053
|
+
top: 0,
|
|
13054
|
+
width: anim.duration / props.msPerPx
|
|
13055
|
+
};
|
|
13056
|
+
if (box.width) {
|
|
13057
|
+
box.width = `${box.width}px`;
|
|
13058
|
+
} else {
|
|
13059
|
+
box.width = "100%";
|
|
13060
|
+
}
|
|
13061
|
+
return {
|
|
13062
|
+
name: anim.name,
|
|
13063
|
+
style: {
|
|
13064
|
+
width: box.width,
|
|
13065
|
+
transform: `matrix(1, 0, 0, 1, ${box.left}, ${box.top})`
|
|
13066
|
+
}
|
|
13067
|
+
};
|
|
13068
|
+
});
|
|
13069
|
+
}
|
|
13070
|
+
return [];
|
|
13071
|
+
});
|
|
13011
13072
|
const style = computed(() => {
|
|
13012
|
-
const
|
|
13013
|
-
box
|
|
13014
|
-
|
|
13073
|
+
const node = props.node;
|
|
13074
|
+
const box = {
|
|
13075
|
+
left: node.delay / props.msPerPx,
|
|
13076
|
+
top: 0,
|
|
13077
|
+
width: node.duration / props.msPerPx
|
|
13078
|
+
};
|
|
13015
13079
|
if (box.width) {
|
|
13016
13080
|
box.width = `${box.width}px`;
|
|
13017
13081
|
} else {
|
|
@@ -13025,11 +13089,18 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
13025
13089
|
return (_ctx, _cache) => {
|
|
13026
13090
|
return openBlock(), createElementBlock("div", {
|
|
13027
13091
|
class: normalizeClass(["mce-segment", [
|
|
13028
|
-
`mce-segment--${__props.node.meta.inEditorIs}`,
|
|
13092
|
+
`mce-segment--${(__props.node.meta.inEditorIs ?? "none").toLowerCase()}`,
|
|
13029
13093
|
__props.active && `mce-segment--active`
|
|
13030
13094
|
]]),
|
|
13031
13095
|
style: normalizeStyle(style.value)
|
|
13032
13096
|
}, [
|
|
13097
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(blocks.value, (block, index) => {
|
|
13098
|
+
return openBlock(), createElementBlock("div", {
|
|
13099
|
+
key: index,
|
|
13100
|
+
class: "mce-segment__block",
|
|
13101
|
+
style: normalizeStyle(block.style)
|
|
13102
|
+
}, toDisplayString(block.name), 5);
|
|
13103
|
+
}), 128)),
|
|
13033
13104
|
__props.active ? (openBlock(), createElementBlock("div", _hoisted_1$8)) : createCommentVNode("", true),
|
|
13034
13105
|
createElementVNode("span", _hoisted_2$4, toDisplayString(props.node.name), 1),
|
|
13035
13106
|
__props.active ? (openBlock(), createElementBlock("div", _hoisted_3$4)) : createCommentVNode("", true)
|
package/dist/locale/en.d.ts
CHANGED
package/dist/locale/zh-Hans.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Node } from 'modern-canvas';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Ref, WritableComputedRef } from 'vue';
|
|
3
3
|
declare global {
|
|
4
4
|
namespace Mce {
|
|
5
5
|
interface Editor {
|
|
6
6
|
msPerPx: Ref<number>;
|
|
7
7
|
currentTime: WritableComputedRef<number>;
|
|
8
|
-
startTime:
|
|
9
|
-
endTime:
|
|
10
|
-
getTimeRange: (node
|
|
8
|
+
startTime: WritableComputedRef<number>;
|
|
9
|
+
endTime: WritableComputedRef<number>;
|
|
10
|
+
getTimeRange: (node?: Node | Node[]) => {
|
|
11
11
|
startTime: number;
|
|
12
12
|
endTime: number;
|
|
13
13
|
};
|
package/dist/plugins/panels.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare global {
|
|
|
5
5
|
interface Config extends Record<keyof Panels, boolean> {
|
|
6
6
|
}
|
|
7
7
|
interface Commands {
|
|
8
|
-
|
|
8
|
+
panels: <T extends keyof Panels>(panel: T, ...args: Panels[T]) => Promise<boolean>;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
}
|
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.16",
|
|
5
5
|
"description": "The headless canvas editor framework. only the ESM.",
|
|
6
6
|
"author": "wxm",
|
|
7
7
|
"license": "MIT",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"diff": "^8.0.2",
|
|
62
62
|
"file-saver": "^2.0.5",
|
|
63
63
|
"lodash-es": "^4.17.22",
|
|
64
|
-
"modern-canvas": "^0.14.
|
|
64
|
+
"modern-canvas": "^0.14.32",
|
|
65
65
|
"modern-font": "^0.4.4",
|
|
66
66
|
"modern-idoc": "^0.10.8",
|
|
67
|
-
"modern-text": "^1.10.
|
|
67
|
+
"modern-text": "^1.10.15",
|
|
68
68
|
"yjs": "^13.6.29"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
@@ -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.
|
|
97
|
+
"sass-embedded": "^1.97.2"
|
|
98
98
|
},
|
|
99
99
|
"scripts": {
|
|
100
100
|
"build:code": "vite build",
|