mce 0.17.12 → 0.17.13
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.
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Node } from 'modern-canvas';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
import type { Editor } from '../editor';
|
|
4
|
+
export declare function useNode(nodeRef: Ref<Node>, editor?: Editor): {
|
|
5
|
+
thumbnailIcon: import("vue").ComputedRef<"$frame" | "$group" | "$lottie" | "$video" | "$image" | "$text" | "$shape">;
|
|
6
|
+
thumbnailName: import("vue").ComputedRef<string>;
|
|
7
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -3865,6 +3865,39 @@ function createLayout(props) {
|
|
|
3865
3865
|
//#region src/composables/menu.ts
|
|
3866
3866
|
var MceMenuSymbol = Symbol.for("MceMenuSymbol");
|
|
3867
3867
|
//#endregion
|
|
3868
|
+
//#region src/composables/node.ts
|
|
3869
|
+
function useNode(nodeRef, editor = useEditor()) {
|
|
3870
|
+
const { inEditorIs, isElement, t } = editor;
|
|
3871
|
+
return {
|
|
3872
|
+
thumbnailIcon: computed(() => {
|
|
3873
|
+
const node = nodeRef.value;
|
|
3874
|
+
if (inEditorIs(node, "Frame")) return "$frame";
|
|
3875
|
+
else if (node.children.filter(isElement).length) return "$group";
|
|
3876
|
+
else if (node instanceof Lottie2D) return "$lottie";
|
|
3877
|
+
else if (node instanceof Video2D) return "$video";
|
|
3878
|
+
else if (isElement(node)) {
|
|
3879
|
+
if (node.foreground.isValid() && node.foreground.image) return "$image";
|
|
3880
|
+
if (node.text.isValid()) return "$text";
|
|
3881
|
+
}
|
|
3882
|
+
return "$shape";
|
|
3883
|
+
}),
|
|
3884
|
+
thumbnailName: computed(() => {
|
|
3885
|
+
const node = nodeRef.value;
|
|
3886
|
+
let value = node.name;
|
|
3887
|
+
if (!value || value[0] === "@") {
|
|
3888
|
+
if (inEditorIs(node, "Frame")) return t("frame");
|
|
3889
|
+
else if (node.children.filter(isElement).length) value = t("group");
|
|
3890
|
+
else if (node instanceof Lottie2D) value = t("lottie");
|
|
3891
|
+
else if (node instanceof Video2D) value = t("video");
|
|
3892
|
+
else if (isElement(node)) if (node.foreground.isValid() && node.foreground.image) value = t("image");
|
|
3893
|
+
else if (node.text.isValid()) value = node._textContent || node.text.getStringContent();
|
|
3894
|
+
else value = t("shape");
|
|
3895
|
+
}
|
|
3896
|
+
return value || node.id;
|
|
3897
|
+
})
|
|
3898
|
+
};
|
|
3899
|
+
}
|
|
3900
|
+
//#endregion
|
|
3868
3901
|
//#region src/composables/overlay.ts
|
|
3869
3902
|
var MceOverlaySymbol = Symbol.for("MceOverlaySymbol");
|
|
3870
3903
|
var makeMceOverlayProps = propsFactory({
|
|
@@ -4407,20 +4440,21 @@ var json_default = definePlugin((editor) => {
|
|
|
4407
4440
|
elements = root.value.children;
|
|
4408
4441
|
}
|
|
4409
4442
|
}
|
|
4410
|
-
const
|
|
4443
|
+
const { left, top, width, height } = getAabb(elements, "parent");
|
|
4411
4444
|
return {
|
|
4412
4445
|
id,
|
|
4413
4446
|
name,
|
|
4414
4447
|
style: {
|
|
4415
|
-
width:
|
|
4416
|
-
height:
|
|
4448
|
+
width: width * scale,
|
|
4449
|
+
height: height * scale,
|
|
4417
4450
|
transformOrigin: "left top",
|
|
4418
4451
|
transform: `scale(${scale})`
|
|
4419
4452
|
},
|
|
4420
4453
|
children: elements.map((el) => {
|
|
4421
4454
|
const json = el.toJSON();
|
|
4422
|
-
|
|
4423
|
-
if (
|
|
4455
|
+
const style = json.style;
|
|
4456
|
+
if (left) style.left = (style.left ?? 0) - left;
|
|
4457
|
+
if (top) style.top = (style.top ?? 0) - top;
|
|
4424
4458
|
json.meta ??= {};
|
|
4425
4459
|
json.meta.inPptIs = "Slide";
|
|
4426
4460
|
return json;
|
|
@@ -4486,9 +4520,11 @@ var Layer_default = /* @__PURE__ */ defineComponent({
|
|
|
4486
4520
|
emits: ["update:opened"],
|
|
4487
4521
|
setup(__props) {
|
|
4488
4522
|
const props = __props;
|
|
4489
|
-
const
|
|
4523
|
+
const editor = useEditor();
|
|
4524
|
+
const { isElement, isVisible, setVisible, isLock, setLock, selection, nodes, nodeIndexMap, hoverElement, exec, t } = editor;
|
|
4490
4525
|
const opened = useModel(__props, "opened");
|
|
4491
4526
|
const dom = ref();
|
|
4527
|
+
const { thumbnailIcon, thumbnailName } = useNode(computed(() => props.node), editor);
|
|
4492
4528
|
const { selecting, dragging, dropping, onMousedown, id, openedItems } = useLayerItem({
|
|
4493
4529
|
opened,
|
|
4494
4530
|
node: computed(() => props.node),
|
|
@@ -4502,32 +4538,6 @@ var Layer_default = /* @__PURE__ */ defineComponent({
|
|
|
4502
4538
|
const hovering = ref(false);
|
|
4503
4539
|
const editing = ref(false);
|
|
4504
4540
|
const editValue = ref();
|
|
4505
|
-
const thumbnailIcon = computed(() => {
|
|
4506
|
-
const node = props.node;
|
|
4507
|
-
if (inEditorIs(node, "Frame")) return "$frame";
|
|
4508
|
-
else if (node.children.filter(isElement).length) return "$group";
|
|
4509
|
-
else if (node instanceof Lottie2D) return "$lottie";
|
|
4510
|
-
else if (node instanceof Video2D) return "$video";
|
|
4511
|
-
else if (isElement(node)) {
|
|
4512
|
-
if (node.foreground.isValid() && node.foreground.image) return "$image";
|
|
4513
|
-
if (node.text.isValid()) return "$text";
|
|
4514
|
-
}
|
|
4515
|
-
return "$shape";
|
|
4516
|
-
});
|
|
4517
|
-
const thumbnailName = computed(() => {
|
|
4518
|
-
const node = props.node;
|
|
4519
|
-
let value = node.name;
|
|
4520
|
-
if (!value || value[0] === "@") {
|
|
4521
|
-
if (inEditorIs(node, "Frame")) return t("frame");
|
|
4522
|
-
else if (node.children.filter(isElement).length) value = t("group");
|
|
4523
|
-
else if (node instanceof Lottie2D) value = t("lottie");
|
|
4524
|
-
else if (node instanceof Video2D) value = t("video");
|
|
4525
|
-
else if (isElement(node)) if (node.foreground.isValid() && node.foreground.image) value = t("image");
|
|
4526
|
-
else if (node.text.isValid()) value = node._textContent || node.text.getStringContent();
|
|
4527
|
-
else value = t("shape");
|
|
4528
|
-
}
|
|
4529
|
-
return value || node.id;
|
|
4530
|
-
});
|
|
4531
4541
|
function onClickExpand() {
|
|
4532
4542
|
opened.value = !opened.value;
|
|
4533
4543
|
}
|
|
@@ -4637,7 +4647,7 @@ var Layer_default = /* @__PURE__ */ defineComponent({
|
|
|
4637
4647
|
createElementVNode("div", {
|
|
4638
4648
|
class: "m-layer__thumbnail",
|
|
4639
4649
|
onDblclick: onDblclickThumbnail
|
|
4640
|
-
}, [createVNode(unref(Icon_default), { icon: thumbnailIcon
|
|
4650
|
+
}, [createVNode(unref(Icon_default), { icon: unref(thumbnailIcon) }, null, 8, ["icon"])], 32),
|
|
4641
4651
|
props.root ? (openBlock(), createElementBlock("div", _hoisted_4$5, toDisplayString(unref(t)("layers")), 1)) : (openBlock(), createElementBlock("div", {
|
|
4642
4652
|
key: 1,
|
|
4643
4653
|
class: "m-layer__name",
|
|
@@ -4655,7 +4665,7 @@ var Layer_default = /* @__PURE__ */ defineComponent({
|
|
|
4655
4665
|
autocorrect: "off",
|
|
4656
4666
|
autofocus: "",
|
|
4657
4667
|
onBlur: onInputBlur
|
|
4658
|
-
}, null, 544)), [[vModelText, editValue.value]]) : createCommentVNode("", true), createElementVNode("div", { style: normalizeStyle({ visibility: editing.value ? "hidden" : void 0 }) }, toDisplayString(editValue.value || thumbnailName
|
|
4668
|
+
}, null, 544)), [[vModelText, editValue.value]]) : createCommentVNode("", true), createElementVNode("div", { style: normalizeStyle({ visibility: editing.value ? "hidden" : void 0 }) }, toDisplayString(editValue.value || unref(thumbnailName)), 5)], 32)),
|
|
4659
4669
|
createElementVNode("div", { class: normalizeClass(["m-layer__action", {
|
|
4660
4670
|
"m-layer__action--hover": hovering.value,
|
|
4661
4671
|
"m-layer__action--show": hovering.value || unref(isLock)(props.node) || !unref(isVisible)(props.node)
|
|
@@ -13591,11 +13601,13 @@ var Segment_default = /* @__PURE__ */ defineComponent({
|
|
|
13591
13601
|
__name: "Segment",
|
|
13592
13602
|
props: {
|
|
13593
13603
|
node: {},
|
|
13604
|
+
endTime: {},
|
|
13594
13605
|
msPerPx: { default: 1 },
|
|
13595
13606
|
active: { type: Boolean }
|
|
13596
13607
|
},
|
|
13597
13608
|
setup(__props) {
|
|
13598
13609
|
const props = __props;
|
|
13610
|
+
const { thumbnailName } = useNode(computed(() => props.node));
|
|
13599
13611
|
const blocks = computed(() => {
|
|
13600
13612
|
const node = props.node;
|
|
13601
13613
|
if (node instanceof Element2D) return node.children.filter((child) => child instanceof Animation).map((anim) => {
|
|
@@ -13618,17 +13630,16 @@ var Segment_default = /* @__PURE__ */ defineComponent({
|
|
|
13618
13630
|
return [];
|
|
13619
13631
|
});
|
|
13620
13632
|
const style = computed(() => {
|
|
13621
|
-
const
|
|
13633
|
+
const { duration: _duration = 0, delay = 0 } = props.node;
|
|
13634
|
+
const duration = _duration || props.endTime - delay;
|
|
13622
13635
|
const box = {
|
|
13623
|
-
left:
|
|
13636
|
+
left: delay / props.msPerPx,
|
|
13624
13637
|
top: 0,
|
|
13625
|
-
width:
|
|
13638
|
+
width: duration / props.msPerPx,
|
|
13626
13639
|
height: 0
|
|
13627
13640
|
};
|
|
13628
|
-
if (box.width) box.width = `${box.width}px`;
|
|
13629
|
-
else box.width = "100%";
|
|
13630
13641
|
return {
|
|
13631
|
-
width: box.width
|
|
13642
|
+
width: `${box.width}px`,
|
|
13632
13643
|
transform: `matrix(1, 0, 0, 1, ${box.left}, ${box.top})`
|
|
13633
13644
|
};
|
|
13634
13645
|
});
|
|
@@ -13645,7 +13656,7 @@ var Segment_default = /* @__PURE__ */ defineComponent({
|
|
|
13645
13656
|
}, null, 4);
|
|
13646
13657
|
}), 128)),
|
|
13647
13658
|
__props.active ? (openBlock(), createElementBlock("div", _hoisted_1$7)) : createCommentVNode("", true),
|
|
13648
|
-
createElementVNode("span", _hoisted_2$3, toDisplayString(
|
|
13659
|
+
createElementVNode("span", _hoisted_2$3, toDisplayString(unref(thumbnailName)), 1),
|
|
13649
13660
|
__props.active ? (openBlock(), createElementBlock("div", _hoisted_3$3)) : createCommentVNode("", true)
|
|
13650
13661
|
], 6);
|
|
13651
13662
|
};
|
|
@@ -13799,11 +13810,13 @@ var Timeline_default = /* @__PURE__ */ defineComponent({
|
|
|
13799
13810
|
default: withCtx(() => [createVNode(Segment_default, {
|
|
13800
13811
|
node,
|
|
13801
13812
|
"ms-per-px": unref(msPerPx),
|
|
13813
|
+
"end-time": unref(endTime),
|
|
13802
13814
|
active: unref(selection).some((v) => v.equal(node)),
|
|
13803
13815
|
onMousedown: withModifiers(($event) => selection.value = [node], ["stop"])
|
|
13804
13816
|
}, null, 8, [
|
|
13805
13817
|
"node",
|
|
13806
13818
|
"ms-per-px",
|
|
13819
|
+
"end-time",
|
|
13807
13820
|
"active",
|
|
13808
13821
|
"onMousedown"
|
|
13809
13822
|
])]),
|
|
@@ -14458,12 +14471,12 @@ var TextEditor_default = /* @__PURE__ */ defineComponent({
|
|
|
14458
14471
|
}
|
|
14459
14472
|
});
|
|
14460
14473
|
//#endregion
|
|
14461
|
-
//#region \0@oxc-project+runtime@0.
|
|
14474
|
+
//#region \0@oxc-project+runtime@0.126.0/helpers/decorateMetadata.js
|
|
14462
14475
|
function __decorateMetadata(k, v) {
|
|
14463
14476
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
14464
14477
|
}
|
|
14465
14478
|
//#endregion
|
|
14466
|
-
//#region \0@oxc-project+runtime@0.
|
|
14479
|
+
//#region \0@oxc-project+runtime@0.126.0/helpers/decorate.js
|
|
14467
14480
|
function __decorate(decorators, target, key, desc) {
|
|
14468
14481
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
14469
14482
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mce",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.17.
|
|
4
|
+
"version": "0.17.13",
|
|
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",
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"@floating-ui/vue": "^1.1.11",
|
|
59
59
|
"@vueuse/components": "^14.2.1",
|
|
60
60
|
"@vueuse/core": "^14.2.1",
|
|
61
|
-
"diff": "^
|
|
61
|
+
"diff": "^9.0.0",
|
|
62
62
|
"lodash-es": "^4.18.1",
|
|
63
|
-
"modern-canvas": "^0.
|
|
63
|
+
"modern-canvas": "^0.16.2",
|
|
64
64
|
"modern-font": "^0.5.0",
|
|
65
65
|
"modern-idoc": "^0.10.21",
|
|
66
66
|
"modern-text": "^1.10.17",
|
|
@@ -86,10 +86,10 @@
|
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@types/lodash-es": "^4.17.12",
|
|
89
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
89
|
+
"@vitejs/plugin-vue": "^6.0.6",
|
|
90
90
|
"jiti": "^2.6.1",
|
|
91
91
|
"sass-embedded": "^1.99.0",
|
|
92
|
-
"typedoc": "^0.28.
|
|
92
|
+
"typedoc": "^0.28.19",
|
|
93
93
|
"typedoc-plugin-markdown": "^4.11.0"
|
|
94
94
|
},
|
|
95
95
|
"scripts": {
|