mce 0.15.6 → 0.15.8
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/composables/layer.d.ts +1 -3
- package/dist/index.css +16 -8
- package/dist/index.js +58 -57
- package/dist/locale/en.d.ts +1 -0
- package/dist/locale/zh-Hans.d.ts +1 -0
- package/dist/plugins/rotate.d.ts +10 -0
- package/dist/typed-plugins.d.ts +1 -0
- package/package.json +3 -3
|
@@ -8,7 +8,6 @@ export interface LayerItem {
|
|
|
8
8
|
}
|
|
9
9
|
export interface LayerProvide {
|
|
10
10
|
selecting: Ref<boolean>;
|
|
11
|
-
sortedSelection: Ref<Node[]>;
|
|
12
11
|
register: (vm: ComponentInternalInstance, item: LayerItem) => void;
|
|
13
12
|
unregister: (id: string) => void;
|
|
14
13
|
onMousedown?: (event: MouseEvent, id: string) => void;
|
|
@@ -19,7 +18,7 @@ export declare const MceLayerKey: InjectionKey<LayerProvide>;
|
|
|
19
18
|
export declare const MceLayerItemKey: InjectionKey<{
|
|
20
19
|
id: string;
|
|
21
20
|
}>;
|
|
22
|
-
export declare function createLayer(
|
|
21
|
+
export declare function createLayer(): {
|
|
23
22
|
selecting: Ref<boolean, boolean>;
|
|
24
23
|
openedItems: import("vue").Reactive<Map<string, Ref<boolean, boolean>>>;
|
|
25
24
|
domItems: import("vue").Reactive<Map<string, Ref<HTMLElement | undefined, HTMLElement | undefined>>>;
|
|
@@ -30,7 +29,6 @@ export declare function useLayerItem(options: Omit<LayerItem, 'id'>): {
|
|
|
30
29
|
dropping: import("vue").ComputedRef<boolean>;
|
|
31
30
|
onMousedown: (e: MouseEvent) => void | undefined;
|
|
32
31
|
selecting: Ref<boolean>;
|
|
33
|
-
sortedSelection: Ref<Node[]>;
|
|
34
32
|
register: (vm: ComponentInternalInstance, item: LayerItem) => void;
|
|
35
33
|
unregister: (id: string) => void;
|
|
36
34
|
dragging: Ref<boolean>;
|
package/dist/index.css
CHANGED
|
@@ -134,7 +134,6 @@
|
|
|
134
134
|
border-radius: inherit;
|
|
135
135
|
}
|
|
136
136
|
.mce-layer--root {
|
|
137
|
-
margin-bottom: 4px;
|
|
138
137
|
font-weight: bold;
|
|
139
138
|
}
|
|
140
139
|
.mce-layer--root .mce-layer__thumbnail {
|
|
@@ -148,12 +147,12 @@
|
|
|
148
147
|
bottom: 0;
|
|
149
148
|
border-radius: 0;
|
|
150
149
|
}
|
|
151
|
-
.mce-layer--
|
|
150
|
+
.mce-layer--active:not(.mce-layer--active + .mce-layer--active) .mce-layer__underlay {
|
|
152
151
|
border-top-left-radius: 4px;
|
|
153
152
|
border-top-right-radius: 4px;
|
|
154
153
|
top: 4px;
|
|
155
154
|
}
|
|
156
|
-
.mce-layer--
|
|
155
|
+
.mce-layer--active:not(:has(+ .mce-layer--active)) .mce-layer__underlay {
|
|
157
156
|
border-bottom-left-radius: 4px;
|
|
158
157
|
border-bottom-right-radius: 4px;
|
|
159
158
|
bottom: 4px;
|
|
@@ -225,17 +224,23 @@
|
|
|
225
224
|
flex: none;
|
|
226
225
|
display: flex;
|
|
227
226
|
align-items: center;
|
|
228
|
-
background-color: var(--overlay-color, transparent);
|
|
229
|
-
backdrop-filter: blur(8px);
|
|
230
227
|
border-radius: 4px;
|
|
231
|
-
}
|
|
232
|
-
.mce-layer__action--hide {
|
|
233
228
|
background-color: transparent;
|
|
234
229
|
backdrop-filter: none;
|
|
235
230
|
}
|
|
236
|
-
.mce-layer__action
|
|
231
|
+
.mce-layer__action .mce-layer__btn {
|
|
237
232
|
opacity: 0;
|
|
238
233
|
}
|
|
234
|
+
.mce-layer__action--hover .mce-layer__btn {
|
|
235
|
+
opacity: 1;
|
|
236
|
+
}
|
|
237
|
+
.mce-layer__action--show {
|
|
238
|
+
background-color: var(--overlay-color, transparent);
|
|
239
|
+
backdrop-filter: blur(8px);
|
|
240
|
+
}
|
|
241
|
+
.mce-layer__btn--show {
|
|
242
|
+
opacity: 1 !important;
|
|
243
|
+
}
|
|
239
244
|
.mce-layer__btn + .mce-layer__btn {
|
|
240
245
|
margin-left: -4px;
|
|
241
246
|
}.mce-layers {
|
|
@@ -259,6 +264,9 @@
|
|
|
259
264
|
}
|
|
260
265
|
.mce-layers:hover .mce-layer:not(.mce-layer--root) .mce-layer__prepend {
|
|
261
266
|
opacity: 1;
|
|
267
|
+
}
|
|
268
|
+
.mce-layers .mce-layer {
|
|
269
|
+
scroll-margin: 8px;
|
|
262
270
|
}.mce-made-with {
|
|
263
271
|
pointer-events: auto !important;
|
|
264
272
|
position: absolute;
|
package/dist/index.js
CHANGED
|
@@ -1027,7 +1027,6 @@ const _0_font = defineMixin((editor, options) => {
|
|
|
1027
1027
|
const loading = ref(false);
|
|
1028
1028
|
async function loadFont(source, options2) {
|
|
1029
1029
|
const res = await fonts.load(source, options2);
|
|
1030
|
-
console.log("loadFont", res);
|
|
1031
1030
|
emit("loadFont", res);
|
|
1032
1031
|
return res;
|
|
1033
1032
|
}
|
|
@@ -1076,6 +1075,7 @@ const en = {
|
|
|
1076
1075
|
"move": "Move",
|
|
1077
1076
|
"hand": "Hand",
|
|
1078
1077
|
"frame": "Frame",
|
|
1078
|
+
"group": "Group",
|
|
1079
1079
|
"text": "Text",
|
|
1080
1080
|
"doubleClickEditText": "DoubleClickEditText",
|
|
1081
1081
|
"rectangle": "Rectangle",
|
|
@@ -1181,6 +1181,7 @@ const zhHans = {
|
|
|
1181
1181
|
"move": "移动",
|
|
1182
1182
|
"hand": "抓手",
|
|
1183
1183
|
"frame": "画板",
|
|
1184
|
+
"group": "组合",
|
|
1184
1185
|
"text": "文字",
|
|
1185
1186
|
"doubleClickEditText": "双击编辑文字",
|
|
1186
1187
|
"rectangle": "矩形",
|
|
@@ -3799,7 +3800,7 @@ function useIcon(props) {
|
|
|
3799
3800
|
}
|
|
3800
3801
|
const MceLayerKey = /* @__PURE__ */ Symbol.for("mce:layer");
|
|
3801
3802
|
const MceLayerItemKey = /* @__PURE__ */ Symbol.for("mce:layer-item");
|
|
3802
|
-
function createLayer(
|
|
3803
|
+
function createLayer() {
|
|
3803
3804
|
const registered = ref([]);
|
|
3804
3805
|
const nodeItems = /* @__PURE__ */ new Map();
|
|
3805
3806
|
const openedItems = reactive(/* @__PURE__ */ new Map());
|
|
@@ -3818,7 +3819,6 @@ function createLayer(options) {
|
|
|
3818
3819
|
return id;
|
|
3819
3820
|
}
|
|
3820
3821
|
provide(MceLayerKey, {
|
|
3821
|
-
...options,
|
|
3822
3822
|
selecting,
|
|
3823
3823
|
dragging,
|
|
3824
3824
|
droppingItemId,
|
|
@@ -5085,13 +5085,13 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5085
5085
|
nodeIndexMap,
|
|
5086
5086
|
zoomTo,
|
|
5087
5087
|
hoverElement,
|
|
5088
|
-
exec
|
|
5088
|
+
exec,
|
|
5089
|
+
t
|
|
5089
5090
|
} = useEditor();
|
|
5090
5091
|
const opened = useModel(__props, "opened");
|
|
5091
5092
|
const dom = ref();
|
|
5092
5093
|
const {
|
|
5093
5094
|
selecting,
|
|
5094
|
-
sortedSelection,
|
|
5095
5095
|
dragging,
|
|
5096
5096
|
dropping,
|
|
5097
5097
|
onMousedown,
|
|
@@ -5101,17 +5101,6 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5101
5101
|
node: computed(() => props.node),
|
|
5102
5102
|
dom: computed(() => dom.value)
|
|
5103
5103
|
});
|
|
5104
|
-
const isFrist = computed(() => sortedSelection.value[0]?.equal(props.node));
|
|
5105
|
-
const isLast = computed(() => {
|
|
5106
|
-
const last = sortedSelection.value[sortedSelection.value.length - 1];
|
|
5107
|
-
if (last) {
|
|
5108
|
-
if (last.equal(props.node)) {
|
|
5109
|
-
if (!opened.value || !props.node?.children.length)
|
|
5110
|
-
return true;
|
|
5111
|
-
} else if (last.equal(props.node?.parent)) ;
|
|
5112
|
-
}
|
|
5113
|
-
return false;
|
|
5114
|
-
});
|
|
5115
5104
|
const isActive = computed(() => selection.value.some((v) => v.equal(props.node)));
|
|
5116
5105
|
const children = computed(() => props.node.children);
|
|
5117
5106
|
const childrenLength = computed(() => children.value.length);
|
|
@@ -5140,8 +5129,14 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5140
5129
|
const node = props.node;
|
|
5141
5130
|
let value = node.name;
|
|
5142
5131
|
if (!value) {
|
|
5143
|
-
if (
|
|
5144
|
-
|
|
5132
|
+
if (isFrame(node)) {
|
|
5133
|
+
return t("frame");
|
|
5134
|
+
} else if (node.children.length) {
|
|
5135
|
+
value = t("group");
|
|
5136
|
+
} else if (isElement(node)) {
|
|
5137
|
+
if (node.foreground.isValid() && node.foreground.image) {
|
|
5138
|
+
value = t("image");
|
|
5139
|
+
} else if (node.text.isValid()) {
|
|
5145
5140
|
value = node.text.getStringContent();
|
|
5146
5141
|
}
|
|
5147
5142
|
}
|
|
@@ -5152,6 +5147,9 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5152
5147
|
opened.value = !opened.value;
|
|
5153
5148
|
}
|
|
5154
5149
|
function onMousedownContent(e) {
|
|
5150
|
+
if (e.button === 2) {
|
|
5151
|
+
return;
|
|
5152
|
+
}
|
|
5155
5153
|
selecting.value = true;
|
|
5156
5154
|
if (e.shiftKey) {
|
|
5157
5155
|
const _nodes = [
|
|
@@ -5235,8 +5233,10 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5235
5233
|
}
|
|
5236
5234
|
function onInputBlur() {
|
|
5237
5235
|
editing.value = false;
|
|
5238
|
-
|
|
5239
|
-
|
|
5236
|
+
if (editValue.value !== thumbnailName.value) {
|
|
5237
|
+
props.node.name = editValue.value;
|
|
5238
|
+
editValue.value = "";
|
|
5239
|
+
}
|
|
5240
5240
|
}
|
|
5241
5241
|
return (_ctx, _cache) => {
|
|
5242
5242
|
const _component_MceLayer = resolveComponent("MceLayer");
|
|
@@ -5247,8 +5247,6 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5247
5247
|
class: normalizeClass(["mce-layer", [
|
|
5248
5248
|
props.root && "mce-layer--root",
|
|
5249
5249
|
(__props.active || isActive.value) && "mce-layer--active",
|
|
5250
|
-
isFrist.value && "mce-layer--first",
|
|
5251
|
-
isLast.value && "mce-layer--last",
|
|
5252
5250
|
opened.value && "mce-layer--open",
|
|
5253
5251
|
isHoverElement.value && "mce-layer--hover",
|
|
5254
5252
|
unref(dropping) && "mce-layer--dropping"
|
|
@@ -5262,8 +5260,8 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5262
5260
|
onMouseleave,
|
|
5263
5261
|
onContextmenu
|
|
5264
5262
|
}, [
|
|
5265
|
-
_cache[
|
|
5266
|
-
_cache[
|
|
5263
|
+
_cache[4] || (_cache[4] = createElementVNode("span", { class: "mce-layer__underlay" }, null, -1)),
|
|
5264
|
+
_cache[5] || (_cache[5] = createElementVNode("span", { class: "mce-layer__overlay" }, null, -1)),
|
|
5267
5265
|
createElementVNode("div", _hoisted_2$c, [
|
|
5268
5266
|
createElementVNode("div", _hoisted_3$b, [
|
|
5269
5267
|
childrenLength.value ? (openBlock(), createBlock(unref(_sfc_main$C), {
|
|
@@ -5290,6 +5288,9 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5290
5288
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => editValue.value = $event),
|
|
5291
5289
|
type: "text",
|
|
5292
5290
|
class: "mce-layer__input",
|
|
5291
|
+
spellcheck: "false",
|
|
5292
|
+
autocapitalize: "off",
|
|
5293
|
+
autocorrect: "off",
|
|
5293
5294
|
autofocus: "",
|
|
5294
5295
|
onBlur: onInputBlur
|
|
5295
5296
|
}, null, 544), [
|
|
@@ -5302,26 +5303,17 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5302
5303
|
], 32),
|
|
5303
5304
|
createElementVNode("div", {
|
|
5304
5305
|
class: normalizeClass(["mce-layer__action", {
|
|
5305
|
-
"mce-layer__action--
|
|
5306
|
+
"mce-layer__action--hover": hovering.value,
|
|
5307
|
+
"mce-layer__action--show": hovering.value || unref(isLock)(props.node) || !unref(isVisible)(props.node)
|
|
5306
5308
|
}])
|
|
5307
5309
|
}, [
|
|
5308
|
-
props.root ? (openBlock(),
|
|
5309
|
-
key: 0,
|
|
5310
|
-
icon: "",
|
|
5311
|
-
class: "mce-layer__btn",
|
|
5312
|
-
onClick: _cache[2] || (_cache[2] = ($event) => unref(setLock)(props.node, !unref(isLock)(props.node)))
|
|
5313
|
-
}, {
|
|
5314
|
-
default: withCtx(() => [
|
|
5315
|
-
createVNode(unref(_sfc_main$C), {
|
|
5316
|
-
icon: unref(isLock)(props.node) ? "$lock" : "$unlock"
|
|
5317
|
-
}, null, 8, ["icon"])
|
|
5318
|
-
]),
|
|
5319
|
-
_: 1
|
|
5320
|
-
})) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
5310
|
+
props.root ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
5321
5311
|
createVNode(_sfc_main$y, {
|
|
5322
5312
|
icon: "",
|
|
5323
|
-
class: "mce-layer__btn",
|
|
5324
|
-
|
|
5313
|
+
class: normalizeClass(["mce-layer__btn", {
|
|
5314
|
+
"mce-layer__btn--show": unref(isLock)(props.node)
|
|
5315
|
+
}]),
|
|
5316
|
+
onClick: _cache[2] || (_cache[2] = withModifiers(($event) => unref(setLock)(props.node, !unref(isLock)(props.node)), ["prevent", "stop"]))
|
|
5325
5317
|
}, {
|
|
5326
5318
|
default: withCtx(() => [
|
|
5327
5319
|
createVNode(unref(_sfc_main$C), {
|
|
@@ -5329,11 +5321,13 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5329
5321
|
}, null, 8, ["icon"])
|
|
5330
5322
|
]),
|
|
5331
5323
|
_: 1
|
|
5332
|
-
}),
|
|
5324
|
+
}, 8, ["class"]),
|
|
5333
5325
|
createVNode(_sfc_main$y, {
|
|
5334
5326
|
icon: "",
|
|
5335
|
-
class: "mce-layer__btn",
|
|
5336
|
-
|
|
5327
|
+
class: normalizeClass(["mce-layer__btn", {
|
|
5328
|
+
"mce-layer__btn--show": !unref(isVisible)(props.node)
|
|
5329
|
+
}]),
|
|
5330
|
+
onClick: _cache[3] || (_cache[3] = withModifiers(($event) => unref(setVisible)(props.node, !unref(isVisible)(props.node)), ["prevent", "stop"]))
|
|
5337
5331
|
}, {
|
|
5338
5332
|
default: withCtx(() => [
|
|
5339
5333
|
createVNode(unref(_sfc_main$C), {
|
|
@@ -5341,7 +5335,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5341
5335
|
}, null, 8, ["icon"])
|
|
5342
5336
|
]),
|
|
5343
5337
|
_: 1
|
|
5344
|
-
})
|
|
5338
|
+
}, 8, ["class"])
|
|
5345
5339
|
], 64))
|
|
5346
5340
|
], 2)
|
|
5347
5341
|
])
|
|
@@ -5366,25 +5360,14 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
5366
5360
|
const {
|
|
5367
5361
|
root,
|
|
5368
5362
|
selection,
|
|
5369
|
-
state
|
|
5370
|
-
nodeIndexMap
|
|
5363
|
+
state
|
|
5371
5364
|
} = useEditor();
|
|
5372
|
-
const sortedSelection = computed(() => {
|
|
5373
|
-
return selection.value.map((node) => {
|
|
5374
|
-
return {
|
|
5375
|
-
node,
|
|
5376
|
-
index: nodeIndexMap.get(node.id) ?? 0
|
|
5377
|
-
};
|
|
5378
|
-
}).sort((a, b) => a.index - b.index).map((v) => v.node);
|
|
5379
|
-
});
|
|
5380
5365
|
const {
|
|
5381
5366
|
selecting,
|
|
5382
5367
|
openedItems,
|
|
5383
5368
|
domItems,
|
|
5384
5369
|
getIdByNode
|
|
5385
|
-
} = createLayer(
|
|
5386
|
-
sortedSelection
|
|
5387
|
-
});
|
|
5370
|
+
} = createLayer();
|
|
5388
5371
|
watch(selection, (selection2) => {
|
|
5389
5372
|
if (state.value === "selecting" || selecting.value) {
|
|
5390
5373
|
return;
|
|
@@ -10475,6 +10458,23 @@ const _pen = definePlugin((editor) => {
|
|
|
10475
10458
|
]
|
|
10476
10459
|
};
|
|
10477
10460
|
});
|
|
10461
|
+
const _rotate = definePlugin((editor) => {
|
|
10462
|
+
const {
|
|
10463
|
+
elementSelection
|
|
10464
|
+
} = editor;
|
|
10465
|
+
function rotate(deg) {
|
|
10466
|
+
elementSelection.value.forEach((el) => {
|
|
10467
|
+
el.style.rotate += deg;
|
|
10468
|
+
});
|
|
10469
|
+
}
|
|
10470
|
+
return {
|
|
10471
|
+
name: "mce:rotate",
|
|
10472
|
+
commands: [
|
|
10473
|
+
{ command: "rotate", handle: rotate },
|
|
10474
|
+
{ command: "rotate90", handle: () => rotate(90) }
|
|
10475
|
+
]
|
|
10476
|
+
};
|
|
10477
|
+
});
|
|
10478
10478
|
const _hoisted_1$g = {
|
|
10479
10479
|
key: 0,
|
|
10480
10480
|
class: "mce-tooltip__arrow"
|
|
@@ -13578,6 +13578,7 @@ const plugins = [
|
|
|
13578
13578
|
_open,
|
|
13579
13579
|
_panels,
|
|
13580
13580
|
_pen,
|
|
13581
|
+
_rotate,
|
|
13581
13582
|
_ruler,
|
|
13582
13583
|
_saveAs,
|
|
13583
13584
|
_scroll,
|
package/dist/locale/en.d.ts
CHANGED
package/dist/locale/zh-Hans.d.ts
CHANGED
package/dist/typed-plugins.d.ts
CHANGED
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.8",
|
|
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.23",
|
|
65
65
|
"modern-font": "^0.4.4",
|
|
66
66
|
"modern-idoc": "^0.10.8",
|
|
67
|
-
"modern-text": "^1.10.
|
|
67
|
+
"modern-text": "^1.10.7",
|
|
68
68
|
"yjs": "^13.6.28"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|