mce 0.15.15 → 0.15.17
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 +13 -0
- package/dist/index.js +838 -61
- package/dist/locale/en.d.ts +2 -0
- package/dist/locale/zh-Hans.d.ts +2 -0
- package/dist/web-components/TextEditor.d.ts +81 -0
- package/dist/web-components/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
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, 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 as normalizeStyle$1, 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
|
-
import { getObjectValueByPath, setObjectValueByPath, Observable, Reactivable, idGenerator, property, normalizeTextContent, normalizeCRLF, isEqualObject } from "modern-idoc";
|
|
4
|
+
import { getObjectValueByPath, setObjectValueByPath, Observable, Reactivable, idGenerator, property, normalizeTextContent, isCRLF, textContentToString, normalizeCRLF, isEqualObject } from "modern-idoc";
|
|
5
5
|
import { saveAs } from "file-saver";
|
|
6
6
|
import { Fonts } from "modern-font";
|
|
7
7
|
import * as Y from "yjs";
|
|
8
8
|
import { merge, throttle, cloneDeep } from "lodash-es";
|
|
9
|
-
import { measureText } from "modern-text";
|
|
10
|
-
import {
|
|
9
|
+
import { measureText, Text } from "modern-text";
|
|
10
|
+
import { diffChars } from "diff";
|
|
11
11
|
import { vResizeObserver } from "@vueuse/components";
|
|
12
12
|
import { useFloating, offset, flip, shift, autoUpdate } from "@floating-ui/vue";
|
|
13
13
|
function defineMixin(cb) {
|
|
@@ -486,13 +486,13 @@ class Model extends Reactivable {
|
|
|
486
486
|
};
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
|
-
var __defProp = Object.defineProperty;
|
|
490
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
489
|
+
var __defProp$1 = Object.defineProperty;
|
|
490
|
+
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
491
491
|
var result = void 0;
|
|
492
492
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
493
493
|
if (decorator = decorators[i])
|
|
494
494
|
result = decorator(target, key, result) || result;
|
|
495
|
-
if (result) __defProp(target, key, result);
|
|
495
|
+
if (result) __defProp$1(target, key, result);
|
|
496
496
|
return result;
|
|
497
497
|
};
|
|
498
498
|
class Doc extends Model {
|
|
@@ -867,7 +867,7 @@ class Doc extends Model {
|
|
|
867
867
|
};
|
|
868
868
|
}
|
|
869
869
|
}
|
|
870
|
-
__decorateClass([
|
|
870
|
+
__decorateClass$1([
|
|
871
871
|
property()
|
|
872
872
|
], Doc.prototype, "name");
|
|
873
873
|
const _0_context = defineMixin((editor) => {
|
|
@@ -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": "文件",
|
|
@@ -1808,10 +1812,6 @@ const _1_timeline = defineMixin((editor) => {
|
|
|
1808
1812
|
on
|
|
1809
1813
|
} = editor;
|
|
1810
1814
|
async function updateEndTime() {
|
|
1811
|
-
console.log("updateEndTime");
|
|
1812
|
-
await renderEngine.value.nextTick();
|
|
1813
|
-
await renderEngine.value.nextTick();
|
|
1814
|
-
await renderEngine.value.nextTick();
|
|
1815
1815
|
await renderEngine.value.nextTick();
|
|
1816
1816
|
timeline.value.endTime = root.value ? getTimeRange(root.value).endTime : 0;
|
|
1817
1817
|
}
|
|
@@ -2257,6 +2257,724 @@ const _4_0_node = defineMixin((editor) => {
|
|
|
2257
2257
|
addNode
|
|
2258
2258
|
});
|
|
2259
2259
|
});
|
|
2260
|
+
var __defProp = Object.defineProperty;
|
|
2261
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
2262
|
+
var result = void 0;
|
|
2263
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2264
|
+
if (decorator = decorators[i])
|
|
2265
|
+
result = decorator(target, key, result) || result;
|
|
2266
|
+
if (result) __defProp(target, key, result);
|
|
2267
|
+
return result;
|
|
2268
|
+
};
|
|
2269
|
+
function normalizeStyle(style) {
|
|
2270
|
+
const newStyle = {};
|
|
2271
|
+
for (const key in style) {
|
|
2272
|
+
if (key !== "id" && style[key] !== void 0 && style[key] !== "") {
|
|
2273
|
+
newStyle[key] = style[key];
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
return newStyle;
|
|
2277
|
+
}
|
|
2278
|
+
function textContentToCharStyles(textContent) {
|
|
2279
|
+
return textContent.flatMap((p) => {
|
|
2280
|
+
const { fragments } = p;
|
|
2281
|
+
const res = fragments.flatMap((f) => {
|
|
2282
|
+
const { content, ...fStyle } = f;
|
|
2283
|
+
return Array.from(normalizeCRLF(content)).map(() => ({ ...fStyle }));
|
|
2284
|
+
});
|
|
2285
|
+
if (isCRLF(normalizeCRLF(fragments[fragments.length - 1]?.content ?? ""))) {
|
|
2286
|
+
return res;
|
|
2287
|
+
}
|
|
2288
|
+
return [...res, {}];
|
|
2289
|
+
});
|
|
2290
|
+
}
|
|
2291
|
+
function isEqualStyle(style1, style2) {
|
|
2292
|
+
const keys1 = Object.keys(style1);
|
|
2293
|
+
const keys2 = Object.keys(style2);
|
|
2294
|
+
const keys = Array.from(/* @__PURE__ */ new Set([...keys1, ...keys2]));
|
|
2295
|
+
return !keys.length || keys.every((key) => style1[key] === style2[key]);
|
|
2296
|
+
}
|
|
2297
|
+
const emojiRE = /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
|
|
2298
|
+
function parseHTML(html) {
|
|
2299
|
+
const template = document.createElement("template");
|
|
2300
|
+
template.innerHTML = html;
|
|
2301
|
+
return template.content.cloneNode(true);
|
|
2302
|
+
}
|
|
2303
|
+
const SUPPORTS_POINTER_EVENTS = "PointerEvent" in globalThis;
|
|
2304
|
+
class TextEditor extends HTMLElement {
|
|
2305
|
+
_prevSelection;
|
|
2306
|
+
_composition = false;
|
|
2307
|
+
get composition() {
|
|
2308
|
+
return this._composition;
|
|
2309
|
+
}
|
|
2310
|
+
static _defined = false;
|
|
2311
|
+
static register() {
|
|
2312
|
+
if (!this._defined) {
|
|
2313
|
+
this._defined = true;
|
|
2314
|
+
customElements.define("text-editor", this);
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
_text = new Text();
|
|
2318
|
+
get text() {
|
|
2319
|
+
return this._text;
|
|
2320
|
+
}
|
|
2321
|
+
set text(newText) {
|
|
2322
|
+
if (newText) {
|
|
2323
|
+
this._text?.off("update", this._update);
|
|
2324
|
+
this.reset();
|
|
2325
|
+
newText.on("update", this._update);
|
|
2326
|
+
this._text = newText;
|
|
2327
|
+
this._setTextInput(this.getPlaintext());
|
|
2328
|
+
this.text.update();
|
|
2329
|
+
this._update();
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
_oldText = "";
|
|
2333
|
+
_container;
|
|
2334
|
+
_selection;
|
|
2335
|
+
_textarea;
|
|
2336
|
+
_cursor;
|
|
2337
|
+
constructor() {
|
|
2338
|
+
super();
|
|
2339
|
+
const shadowRoot = this.attachShadow({ mode: "open" });
|
|
2340
|
+
shadowRoot.appendChild(
|
|
2341
|
+
parseHTML(`
|
|
2342
|
+
<style>
|
|
2343
|
+
:host {
|
|
2344
|
+
position: absolute;
|
|
2345
|
+
left: 0;
|
|
2346
|
+
top: 0;
|
|
2347
|
+
width: 0;
|
|
2348
|
+
height: 0;
|
|
2349
|
+
z-index: 1;
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
.container {
|
|
2353
|
+
position: absolute;
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
textarea {
|
|
2357
|
+
position: absolute;
|
|
2358
|
+
opacity: 0;
|
|
2359
|
+
caret-color: transparent;
|
|
2360
|
+
left: 0;
|
|
2361
|
+
top: 0;
|
|
2362
|
+
width: 100%;
|
|
2363
|
+
height: 100%;
|
|
2364
|
+
padding: 0;
|
|
2365
|
+
border: 0;
|
|
2366
|
+
resize: none;
|
|
2367
|
+
overflow: hidden;
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2370
|
+
.selection {
|
|
2371
|
+
position: absolute;
|
|
2372
|
+
left: 0;
|
|
2373
|
+
top: 0;
|
|
2374
|
+
pointer-events: none;
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
.selection > * {
|
|
2378
|
+
position: absolute;
|
|
2379
|
+
left: 0;
|
|
2380
|
+
top: 0;
|
|
2381
|
+
background: rgba(var(--color, 0, 0, 0), 0.4);
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
.cursor {
|
|
2385
|
+
position: absolute;
|
|
2386
|
+
left: 0;
|
|
2387
|
+
top: 0;
|
|
2388
|
+
pointer-events: none;
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
.cursor.blink {
|
|
2392
|
+
animation: cursor-blink 1s steps(2, start) infinite;
|
|
2393
|
+
}
|
|
2394
|
+
|
|
2395
|
+
@keyframes cursor-blink {
|
|
2396
|
+
100% {
|
|
2397
|
+
visibility: hidden;
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
</style>
|
|
2401
|
+
|
|
2402
|
+
<div class="container">
|
|
2403
|
+
<textarea></textarea>
|
|
2404
|
+
<div class="selection"></div>
|
|
2405
|
+
<div class="cursor blink"></div>
|
|
2406
|
+
</div>
|
|
2407
|
+
`)
|
|
2408
|
+
);
|
|
2409
|
+
this._container = shadowRoot.querySelector(".container");
|
|
2410
|
+
this._selection = shadowRoot.querySelector(".selection");
|
|
2411
|
+
this._textarea = shadowRoot.querySelector("textarea");
|
|
2412
|
+
this._cursor = shadowRoot.querySelector(".cursor");
|
|
2413
|
+
this._bindEventListeners();
|
|
2414
|
+
this._update = this._update.bind(this);
|
|
2415
|
+
}
|
|
2416
|
+
connectedCallback() {
|
|
2417
|
+
this._emit("init");
|
|
2418
|
+
}
|
|
2419
|
+
moveToDom(target) {
|
|
2420
|
+
const style = getComputedStyle(target);
|
|
2421
|
+
const host = this.shadowRoot.host;
|
|
2422
|
+
host.style.width = `${target.clientWidth}px`;
|
|
2423
|
+
host.style.height = `${target.clientHeight}px`;
|
|
2424
|
+
host.style.transform = "";
|
|
2425
|
+
const hostRect = host.getBoundingClientRect();
|
|
2426
|
+
const hostCenter = { x: hostRect.x + hostRect.width / 2, y: hostRect.y + hostRect.height / 2 };
|
|
2427
|
+
const targetRect = target.getBoundingClientRect();
|
|
2428
|
+
const targetCenter = { x: targetRect.x + targetRect.width / 2, y: targetRect.y + targetRect.height / 2 };
|
|
2429
|
+
this.left = targetCenter.x - hostCenter.x;
|
|
2430
|
+
this.top = targetCenter.y - hostCenter.y;
|
|
2431
|
+
const m = new DOMMatrixReadOnly(style.transform);
|
|
2432
|
+
this.rotate = Math.atan2(m.b, m.a) * (180 / Math.PI);
|
|
2433
|
+
this._update();
|
|
2434
|
+
}
|
|
2435
|
+
set(text) {
|
|
2436
|
+
this.text = text;
|
|
2437
|
+
}
|
|
2438
|
+
onUpdateProperty(key, _newValue, _oldValue) {
|
|
2439
|
+
switch (key) {
|
|
2440
|
+
case "selection":
|
|
2441
|
+
if (this.selection) {
|
|
2442
|
+
this._selectionMinMax = {
|
|
2443
|
+
min: Math.min(...this.selection),
|
|
2444
|
+
max: Math.max(...this.selection)
|
|
2445
|
+
};
|
|
2446
|
+
this._showCursor = true;
|
|
2447
|
+
} else {
|
|
2448
|
+
this._selectionMinMax = {
|
|
2449
|
+
min: -1,
|
|
2450
|
+
max: -1
|
|
2451
|
+
};
|
|
2452
|
+
this._showCursor = false;
|
|
2453
|
+
}
|
|
2454
|
+
break;
|
|
2455
|
+
case "_selectionMinMax":
|
|
2456
|
+
case "_chars":
|
|
2457
|
+
this._updateSelectedChars();
|
|
2458
|
+
this._updateCursorPosition();
|
|
2459
|
+
break;
|
|
2460
|
+
case "_showCursor":
|
|
2461
|
+
case "_cursorPosition":
|
|
2462
|
+
this._renderCursor();
|
|
2463
|
+
break;
|
|
2464
|
+
case "_selectedChars":
|
|
2465
|
+
this._renderCursor();
|
|
2466
|
+
this._renderSelectRange();
|
|
2467
|
+
break;
|
|
2468
|
+
case "left":
|
|
2469
|
+
case "top":
|
|
2470
|
+
case "rotate":
|
|
2471
|
+
this._update();
|
|
2472
|
+
break;
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
_updateChars() {
|
|
2476
|
+
const paragraphs = [];
|
|
2477
|
+
this.text.paragraphs.forEach((p, paragraphIndex) => {
|
|
2478
|
+
p.fragments.forEach((f, fragmentIndex) => {
|
|
2479
|
+
f.characters.forEach((c) => {
|
|
2480
|
+
if (!paragraphs[paragraphIndex])
|
|
2481
|
+
paragraphs[paragraphIndex] = [];
|
|
2482
|
+
if (!paragraphs[paragraphIndex][fragmentIndex])
|
|
2483
|
+
paragraphs[paragraphIndex][fragmentIndex] = [];
|
|
2484
|
+
paragraphs[paragraphIndex][fragmentIndex].push(c);
|
|
2485
|
+
});
|
|
2486
|
+
});
|
|
2487
|
+
});
|
|
2488
|
+
const toIndexChar = (c) => {
|
|
2489
|
+
return {
|
|
2490
|
+
paragraphIndex: -1,
|
|
2491
|
+
fragmentIndex: -1,
|
|
2492
|
+
charIndex: -1,
|
|
2493
|
+
color: c.computedStyle.color,
|
|
2494
|
+
left: c.inlineBox.left,
|
|
2495
|
+
top: c.inlineBox.top,
|
|
2496
|
+
width: c.inlineBox.width,
|
|
2497
|
+
height: c.inlineBox.height,
|
|
2498
|
+
content: c.content
|
|
2499
|
+
};
|
|
2500
|
+
};
|
|
2501
|
+
const chars = [];
|
|
2502
|
+
let pos = 0;
|
|
2503
|
+
paragraphs.forEach((p, paragraphIndex) => {
|
|
2504
|
+
if (p.length === 1 && p[0].length === 1 && isCRLF(p[0][0].content)) {
|
|
2505
|
+
const c = p[0][0];
|
|
2506
|
+
chars[pos] = {
|
|
2507
|
+
...toIndexChar(c),
|
|
2508
|
+
paragraphIndex,
|
|
2509
|
+
fragmentIndex: 0,
|
|
2510
|
+
charIndex: 0,
|
|
2511
|
+
isCrlf: true
|
|
2512
|
+
};
|
|
2513
|
+
} else {
|
|
2514
|
+
p.forEach((f, fragmentIndex) => {
|
|
2515
|
+
f.forEach((c, charIndex) => {
|
|
2516
|
+
const char = toIndexChar(c);
|
|
2517
|
+
chars[pos] = {
|
|
2518
|
+
...char,
|
|
2519
|
+
paragraphIndex,
|
|
2520
|
+
fragmentIndex,
|
|
2521
|
+
charIndex
|
|
2522
|
+
};
|
|
2523
|
+
pos++;
|
|
2524
|
+
if (!isCRLF(c.content)) {
|
|
2525
|
+
chars[pos] = {
|
|
2526
|
+
...char,
|
|
2527
|
+
paragraphIndex,
|
|
2528
|
+
fragmentIndex,
|
|
2529
|
+
charIndex,
|
|
2530
|
+
content: " ",
|
|
2531
|
+
isLastSelected: true
|
|
2532
|
+
};
|
|
2533
|
+
}
|
|
2534
|
+
});
|
|
2535
|
+
});
|
|
2536
|
+
}
|
|
2537
|
+
pos++;
|
|
2538
|
+
});
|
|
2539
|
+
if (chars[0]) {
|
|
2540
|
+
chars[0].isFirst = true;
|
|
2541
|
+
}
|
|
2542
|
+
if (chars[chars.length - 1]) {
|
|
2543
|
+
chars[chars.length - 1].isLast = true;
|
|
2544
|
+
}
|
|
2545
|
+
this._chars = chars;
|
|
2546
|
+
}
|
|
2547
|
+
_updateSelectedChars() {
|
|
2548
|
+
this._selectedChars = this._chars.filter((_char, index) => {
|
|
2549
|
+
return index >= this._selectionMinMax.min && index < this._selectionMinMax.max;
|
|
2550
|
+
});
|
|
2551
|
+
if (this._selectionMinMax.min > -1) {
|
|
2552
|
+
this._emit("selected", [
|
|
2553
|
+
this._chars[this._selectionMinMax.min],
|
|
2554
|
+
this._chars[this._selectionMinMax.max]
|
|
2555
|
+
]);
|
|
2556
|
+
} else {
|
|
2557
|
+
this._emit("selected", void 0);
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
_updateCursorPosition() {
|
|
2561
|
+
let left = 0;
|
|
2562
|
+
let top = 0;
|
|
2563
|
+
const char = this._chars[this._selectionMinMax.min];
|
|
2564
|
+
if (char?.isLastSelected) {
|
|
2565
|
+
if (this.text.isVertical) {
|
|
2566
|
+
top += char?.height ?? 0;
|
|
2567
|
+
} else {
|
|
2568
|
+
left += char?.width ?? 0;
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
left += char?.left ?? 0;
|
|
2572
|
+
top += char?.top ?? 0;
|
|
2573
|
+
this._cursorPosition = {
|
|
2574
|
+
color: char?.color,
|
|
2575
|
+
left,
|
|
2576
|
+
top,
|
|
2577
|
+
height: char?.height ?? 0,
|
|
2578
|
+
width: char?.width ?? 0
|
|
2579
|
+
};
|
|
2580
|
+
}
|
|
2581
|
+
getPlaintext() {
|
|
2582
|
+
return textContentToString(
|
|
2583
|
+
this._getNewContent(
|
|
2584
|
+
this.text.content
|
|
2585
|
+
)
|
|
2586
|
+
);
|
|
2587
|
+
}
|
|
2588
|
+
_getNewContent(content, newString = textContentToString(content), oldString = newString) {
|
|
2589
|
+
newString = normalizeCRLF(newString);
|
|
2590
|
+
newString = newString.replace(emojiRE, (emoji) => {
|
|
2591
|
+
if (Array.from(emoji).length > 1) {
|
|
2592
|
+
return "?";
|
|
2593
|
+
}
|
|
2594
|
+
return emoji;
|
|
2595
|
+
});
|
|
2596
|
+
oldString = normalizeCRLF(oldString);
|
|
2597
|
+
const oldStyles = textContentToCharStyles(content);
|
|
2598
|
+
const styles = [];
|
|
2599
|
+
let styleIndex = 0;
|
|
2600
|
+
let oldStyleIndex = 0;
|
|
2601
|
+
let prevOldStyle = {};
|
|
2602
|
+
const changes = diffChars(oldString, newString);
|
|
2603
|
+
changes.forEach((change) => {
|
|
2604
|
+
const chars = Array.from(change.value);
|
|
2605
|
+
if (change.removed) {
|
|
2606
|
+
oldStyleIndex += chars.length;
|
|
2607
|
+
} else {
|
|
2608
|
+
chars.forEach(() => {
|
|
2609
|
+
if (change.added) {
|
|
2610
|
+
styles[styleIndex] = { ...prevOldStyle };
|
|
2611
|
+
} else {
|
|
2612
|
+
prevOldStyle = normalizeStyle(oldStyles[oldStyleIndex]);
|
|
2613
|
+
styles[styleIndex] = { ...prevOldStyle };
|
|
2614
|
+
oldStyleIndex++;
|
|
2615
|
+
}
|
|
2616
|
+
styleIndex++;
|
|
2617
|
+
});
|
|
2618
|
+
}
|
|
2619
|
+
});
|
|
2620
|
+
let charIndex = 0;
|
|
2621
|
+
const newContents = [];
|
|
2622
|
+
normalizeTextContent(newString).forEach((p, pI) => {
|
|
2623
|
+
const { fragments: _, ...pStyle } = content[pI] ?? {};
|
|
2624
|
+
let newParagraph = { ...pStyle, fragments: [] };
|
|
2625
|
+
let newFragment;
|
|
2626
|
+
p.fragments.forEach((f) => {
|
|
2627
|
+
Array.from(f.content).forEach((char) => {
|
|
2628
|
+
const style = styles[charIndex] ?? {};
|
|
2629
|
+
if (newFragment) {
|
|
2630
|
+
const { content: _2, ..._style } = newFragment;
|
|
2631
|
+
if (isEqualStyle(style, _style)) {
|
|
2632
|
+
newFragment.content += char;
|
|
2633
|
+
} else {
|
|
2634
|
+
newParagraph.fragments.push(newFragment);
|
|
2635
|
+
newFragment = { ...style, content: char };
|
|
2636
|
+
}
|
|
2637
|
+
} else {
|
|
2638
|
+
newFragment = { ...style, content: char };
|
|
2639
|
+
}
|
|
2640
|
+
charIndex++;
|
|
2641
|
+
});
|
|
2642
|
+
});
|
|
2643
|
+
if (!isCRLF(p.fragments[p.fragments.length - 1]?.content ?? "")) {
|
|
2644
|
+
charIndex++;
|
|
2645
|
+
}
|
|
2646
|
+
if (newFragment) {
|
|
2647
|
+
newParagraph.fragments.push(newFragment);
|
|
2648
|
+
}
|
|
2649
|
+
if (newParagraph.fragments.length) {
|
|
2650
|
+
newContents.push(newParagraph);
|
|
2651
|
+
newParagraph = { ...pStyle, fragments: [] };
|
|
2652
|
+
}
|
|
2653
|
+
});
|
|
2654
|
+
return newContents;
|
|
2655
|
+
}
|
|
2656
|
+
_setTextInput(newText) {
|
|
2657
|
+
this._textarea.value = newText;
|
|
2658
|
+
this._oldText = newText;
|
|
2659
|
+
}
|
|
2660
|
+
_onInput() {
|
|
2661
|
+
const newText = this._textarea.value;
|
|
2662
|
+
this.text.content = this._getNewContent(
|
|
2663
|
+
this.text.content,
|
|
2664
|
+
newText,
|
|
2665
|
+
this._oldText
|
|
2666
|
+
);
|
|
2667
|
+
this._oldText = newText;
|
|
2668
|
+
this.text.update();
|
|
2669
|
+
this._emit("update");
|
|
2670
|
+
}
|
|
2671
|
+
_timer;
|
|
2672
|
+
_onKeydown(e) {
|
|
2673
|
+
e.stopPropagation();
|
|
2674
|
+
switch (e.key) {
|
|
2675
|
+
case "Escape":
|
|
2676
|
+
this.selection = void 0;
|
|
2677
|
+
return this._textarea.blur();
|
|
2678
|
+
}
|
|
2679
|
+
this._updateSelectionByDom();
|
|
2680
|
+
setTimeout(() => this._updateSelectionByDom(), 0);
|
|
2681
|
+
setTimeout(() => this._updateSelectionByDom(), 100);
|
|
2682
|
+
}
|
|
2683
|
+
_findNearest(options) {
|
|
2684
|
+
const isVertical = this.text.isVertical;
|
|
2685
|
+
const {
|
|
2686
|
+
x,
|
|
2687
|
+
y,
|
|
2688
|
+
xWeight = 1,
|
|
2689
|
+
yWeight = 1
|
|
2690
|
+
} = options;
|
|
2691
|
+
const char = this._chars.reduce(
|
|
2692
|
+
(prev, current, index) => {
|
|
2693
|
+
const diff = Math.abs(current.left + current.width / 2 - x) * xWeight + Math.abs(current.top + current.height / 2 - y) * yWeight;
|
|
2694
|
+
if (diff < prev.diff) {
|
|
2695
|
+
return {
|
|
2696
|
+
diff,
|
|
2697
|
+
index,
|
|
2698
|
+
value: current
|
|
2699
|
+
};
|
|
2700
|
+
}
|
|
2701
|
+
return prev;
|
|
2702
|
+
},
|
|
2703
|
+
{
|
|
2704
|
+
diff: Number.MAX_SAFE_INTEGER,
|
|
2705
|
+
index: -1,
|
|
2706
|
+
value: void 0
|
|
2707
|
+
}
|
|
2708
|
+
);
|
|
2709
|
+
if (char?.value) {
|
|
2710
|
+
if ((isVertical ? y > char.value.top + char.value.height / 2 : x > char.value.left + char.value.width / 2) && !char.value.isCrlf && !char.value.isLastSelected) {
|
|
2711
|
+
return char.index + 1;
|
|
2712
|
+
}
|
|
2713
|
+
return char.index;
|
|
2714
|
+
}
|
|
2715
|
+
return -1;
|
|
2716
|
+
}
|
|
2717
|
+
_updateSelectionByDom() {
|
|
2718
|
+
if (this._composition) {
|
|
2719
|
+
this.selection = this._prevSelection;
|
|
2720
|
+
} else {
|
|
2721
|
+
const { selectionStart, selectionEnd } = this._textarea;
|
|
2722
|
+
let count2 = 0;
|
|
2723
|
+
const _selection = [-1, -1];
|
|
2724
|
+
this._chars.forEach((char, index) => {
|
|
2725
|
+
if (count2 <= selectionStart) {
|
|
2726
|
+
_selection[0] = index;
|
|
2727
|
+
}
|
|
2728
|
+
if (count2 <= selectionEnd) {
|
|
2729
|
+
_selection[1] = index;
|
|
2730
|
+
}
|
|
2731
|
+
count2 += char.content.length;
|
|
2732
|
+
});
|
|
2733
|
+
const oldSelection = this.selection;
|
|
2734
|
+
this.selection = _selection;
|
|
2735
|
+
this._prevSelection = oldSelection;
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
_updateDomSelection() {
|
|
2739
|
+
let start = 0;
|
|
2740
|
+
let end = 0;
|
|
2741
|
+
this._chars.forEach((char, index) => {
|
|
2742
|
+
if (index < this._selectionMinMax.min) {
|
|
2743
|
+
start += char.content.length;
|
|
2744
|
+
end = start;
|
|
2745
|
+
} else if (index < this._selectionMinMax.max) {
|
|
2746
|
+
end += char.content.length;
|
|
2747
|
+
}
|
|
2748
|
+
});
|
|
2749
|
+
this._textarea.selectionStart = start;
|
|
2750
|
+
this._textarea.selectionEnd = end;
|
|
2751
|
+
}
|
|
2752
|
+
_update() {
|
|
2753
|
+
this._updateChars();
|
|
2754
|
+
const { boundingBox, lineBox } = this.text;
|
|
2755
|
+
const host = this.shadowRoot.host;
|
|
2756
|
+
const radian = this.rotate * Math.PI / 180;
|
|
2757
|
+
const cos = Math.cos(radian);
|
|
2758
|
+
const sin = Math.sin(radian);
|
|
2759
|
+
host.style.transform = `matrix(${cos}, ${sin}, ${-sin}, ${cos}, ${this.left}, ${this.top})`;
|
|
2760
|
+
host.style.width = `${boundingBox.width}px`;
|
|
2761
|
+
host.style.height = `${boundingBox.height}px`;
|
|
2762
|
+
this._container.style.left = `${-boundingBox.left}px`;
|
|
2763
|
+
this._container.style.top = `${-boundingBox.top}px`;
|
|
2764
|
+
this._container.style.width = `${lineBox.width}px`;
|
|
2765
|
+
this._container.style.height = `${lineBox.height}px`;
|
|
2766
|
+
this._textarea.style.fontSize = `${this.text.computedStyle.fontSize}px`;
|
|
2767
|
+
this._textarea.style.writingMode = this.text.computedStyle.writingMode;
|
|
2768
|
+
this._renderSelectRange();
|
|
2769
|
+
this._renderCursor();
|
|
2770
|
+
}
|
|
2771
|
+
_bindEventListeners() {
|
|
2772
|
+
this._textarea.addEventListener("compositionstart", () => this._composition = true);
|
|
2773
|
+
this._textarea.addEventListener("compositionend", () => this._composition = false);
|
|
2774
|
+
this._textarea.addEventListener("keydown", this._onKeydown.bind(this));
|
|
2775
|
+
this._textarea.addEventListener("input", this._onInput.bind(this));
|
|
2776
|
+
if (SUPPORTS_POINTER_EVENTS) {
|
|
2777
|
+
this._textarea.addEventListener("pointerdown", this.pointerDown.bind(this));
|
|
2778
|
+
} else {
|
|
2779
|
+
this._textarea.addEventListener("mousedown", this.pointerDown.bind(this));
|
|
2780
|
+
}
|
|
2781
|
+
["keyup", "mouseup", "input", "paste", "cut"].forEach((key) => {
|
|
2782
|
+
this._textarea.addEventListener(key, () => {
|
|
2783
|
+
this._updateSelectionByDom();
|
|
2784
|
+
});
|
|
2785
|
+
});
|
|
2786
|
+
}
|
|
2787
|
+
pointerDown(e) {
|
|
2788
|
+
if (e && e.button !== 0) {
|
|
2789
|
+
e.preventDefault();
|
|
2790
|
+
e.stopPropagation();
|
|
2791
|
+
return false;
|
|
2792
|
+
}
|
|
2793
|
+
const isVertical = this.text.isVertical;
|
|
2794
|
+
const host = this.shadowRoot.host;
|
|
2795
|
+
const clientRect = host.getBoundingClientRect();
|
|
2796
|
+
const { clientWidth: width, clientHeight: height } = host;
|
|
2797
|
+
const scaleX = clientRect.width / width;
|
|
2798
|
+
const scaleY = clientRect.height / height;
|
|
2799
|
+
const radian = this.rotate * Math.PI / 180;
|
|
2800
|
+
const cos = Math.cos(radian);
|
|
2801
|
+
const sin = Math.sin(radian);
|
|
2802
|
+
const m = new DOMMatrixReadOnly([cos, sin, -sin, cos, 0, 0]).inverse();
|
|
2803
|
+
const clientCenter = { x: clientRect.x + clientRect.width / 2, y: clientRect.y + clientRect.height / 2 };
|
|
2804
|
+
const center = { x: clientCenter.x / scaleX, y: clientCenter.y / scaleY };
|
|
2805
|
+
let x = 0;
|
|
2806
|
+
let y = 0;
|
|
2807
|
+
const getXy = (e2) => {
|
|
2808
|
+
const _p = m.transformPoint({
|
|
2809
|
+
x: e2.clientX - clientCenter.x,
|
|
2810
|
+
y: e2.clientY - clientCenter.y
|
|
2811
|
+
});
|
|
2812
|
+
const p = {
|
|
2813
|
+
x: (_p.x + clientCenter.x) / scaleX,
|
|
2814
|
+
y: (_p.y + clientCenter.y) / scaleY
|
|
2815
|
+
};
|
|
2816
|
+
if (isVertical) {
|
|
2817
|
+
return {
|
|
2818
|
+
x: center.x + width / 2 - p.x,
|
|
2819
|
+
y: p.y - (center.y - height / 2)
|
|
2820
|
+
};
|
|
2821
|
+
} else {
|
|
2822
|
+
return {
|
|
2823
|
+
x: p.x - (center.x - width / 2),
|
|
2824
|
+
y: p.y - (center.y - height / 2)
|
|
2825
|
+
};
|
|
2826
|
+
}
|
|
2827
|
+
};
|
|
2828
|
+
if (e) {
|
|
2829
|
+
({ x, y } = getXy(e));
|
|
2830
|
+
e.preventDefault();
|
|
2831
|
+
e.stopPropagation();
|
|
2832
|
+
}
|
|
2833
|
+
const index = this._findNearest({ x, y });
|
|
2834
|
+
this.selection = [index, index];
|
|
2835
|
+
this._updateDomSelection();
|
|
2836
|
+
if (e && ["mousedown", "pointerdown"].includes(e.type)) {
|
|
2837
|
+
const onMove = (e2) => {
|
|
2838
|
+
this.selection = [
|
|
2839
|
+
index,
|
|
2840
|
+
this._findNearest(getXy(e2))
|
|
2841
|
+
];
|
|
2842
|
+
this._updateDomSelection();
|
|
2843
|
+
};
|
|
2844
|
+
const onUp = () => {
|
|
2845
|
+
if (SUPPORTS_POINTER_EVENTS) {
|
|
2846
|
+
document.removeEventListener("pointermove", onMove);
|
|
2847
|
+
document.removeEventListener("pointerup", onUp);
|
|
2848
|
+
} else {
|
|
2849
|
+
document.removeEventListener("mousemove", onMove);
|
|
2850
|
+
document.removeEventListener("mouseup", onUp);
|
|
2851
|
+
}
|
|
2852
|
+
};
|
|
2853
|
+
if (SUPPORTS_POINTER_EVENTS) {
|
|
2854
|
+
document.addEventListener("pointermove", onMove);
|
|
2855
|
+
document.addEventListener("pointerup", onUp);
|
|
2856
|
+
} else {
|
|
2857
|
+
document.addEventListener("mousemove", onMove);
|
|
2858
|
+
document.addEventListener("mouseup", onUp);
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
this._textarea.focus();
|
|
2862
|
+
return true;
|
|
2863
|
+
}
|
|
2864
|
+
selectAll() {
|
|
2865
|
+
this._textarea.focus();
|
|
2866
|
+
this._textarea.select();
|
|
2867
|
+
this._updateSelectionByDom();
|
|
2868
|
+
}
|
|
2869
|
+
attributeChangedCallback(name, _oldValue, newValue) {
|
|
2870
|
+
this[name] = newValue;
|
|
2871
|
+
}
|
|
2872
|
+
_emit(type, detail) {
|
|
2873
|
+
return this.dispatchEvent(
|
|
2874
|
+
new CustomEvent(type, {
|
|
2875
|
+
bubbles: true,
|
|
2876
|
+
cancelable: true,
|
|
2877
|
+
composed: true,
|
|
2878
|
+
detail
|
|
2879
|
+
})
|
|
2880
|
+
);
|
|
2881
|
+
}
|
|
2882
|
+
_renderSelectRange() {
|
|
2883
|
+
const isVertical = this.text.isVertical;
|
|
2884
|
+
const boxesGroupsMap = {};
|
|
2885
|
+
this._selectedChars.forEach((char) => {
|
|
2886
|
+
if (char.isLastSelected) {
|
|
2887
|
+
return;
|
|
2888
|
+
}
|
|
2889
|
+
const key = isVertical ? char.left : char.top;
|
|
2890
|
+
if (!boxesGroupsMap[key]) {
|
|
2891
|
+
boxesGroupsMap[key] = [];
|
|
2892
|
+
}
|
|
2893
|
+
boxesGroupsMap[key].push({
|
|
2894
|
+
x: char.left,
|
|
2895
|
+
y: char.top,
|
|
2896
|
+
w: char.width,
|
|
2897
|
+
h: char.height
|
|
2898
|
+
});
|
|
2899
|
+
});
|
|
2900
|
+
const boxesGroups = Object.values(boxesGroupsMap);
|
|
2901
|
+
const sourceLen = this._selection.children.length;
|
|
2902
|
+
const targetLen = boxesGroups.length;
|
|
2903
|
+
const len = Math.max(sourceLen, targetLen);
|
|
2904
|
+
const deleted = [];
|
|
2905
|
+
for (let i = 0; i < len; i++) {
|
|
2906
|
+
let element = this._selection.children.item(i);
|
|
2907
|
+
const boxes = boxesGroups[i];
|
|
2908
|
+
if (!boxes) {
|
|
2909
|
+
deleted.push(element);
|
|
2910
|
+
continue;
|
|
2911
|
+
} else if (!element) {
|
|
2912
|
+
element = document.createElement("div");
|
|
2913
|
+
this._selection.append(element);
|
|
2914
|
+
}
|
|
2915
|
+
const min = {
|
|
2916
|
+
x: Math.min(...boxes.map((v) => v.x)),
|
|
2917
|
+
y: Math.min(...boxes.map((v) => v.y))
|
|
2918
|
+
};
|
|
2919
|
+
const max = {
|
|
2920
|
+
x: Math.max(...boxes.map((v) => v.x + v.w)),
|
|
2921
|
+
y: Math.max(...boxes.map((v) => v.y + v.h))
|
|
2922
|
+
};
|
|
2923
|
+
element.style.width = `${max.x - min.x}px`;
|
|
2924
|
+
element.style.height = `${max.y - min.y}px`;
|
|
2925
|
+
element.style.transform = `translate(${min.x}px, ${min.y}px)`;
|
|
2926
|
+
}
|
|
2927
|
+
deleted.forEach((el) => el?.remove());
|
|
2928
|
+
}
|
|
2929
|
+
_renderCursor() {
|
|
2930
|
+
if (this._showCursor && this._cursorPosition && this._selectedChars.length === 0) {
|
|
2931
|
+
const _cursorPosition = this._cursorPosition;
|
|
2932
|
+
this._cursor.style.display = "block";
|
|
2933
|
+
this._cursor.style.backgroundColor = _cursorPosition.color ?? "rgba(var(--color))";
|
|
2934
|
+
this._cursor.style.left = `${_cursorPosition.left}px`;
|
|
2935
|
+
this._cursor.style.top = `${_cursorPosition.top}px`;
|
|
2936
|
+
this._cursor.style.height = this.text.isVertical ? "1px" : `${_cursorPosition.height}px`;
|
|
2937
|
+
this._cursor.style.width = this.text.isVertical ? `${_cursorPosition.width}px` : "1px";
|
|
2938
|
+
} else {
|
|
2939
|
+
this._cursor.style.display = "none";
|
|
2940
|
+
}
|
|
2941
|
+
this._cursor.classList.remove("blink");
|
|
2942
|
+
if (this._timer) {
|
|
2943
|
+
clearTimeout(this._timer);
|
|
2944
|
+
}
|
|
2945
|
+
this._timer = setTimeout(() => this._cursor.classList.add("blink"), 500);
|
|
2946
|
+
}
|
|
2947
|
+
reset() {
|
|
2948
|
+
this.selection = void 0;
|
|
2949
|
+
}
|
|
2950
|
+
}
|
|
2951
|
+
__decorateClass([
|
|
2952
|
+
property({ fallback: 0 })
|
|
2953
|
+
], TextEditor.prototype, "left");
|
|
2954
|
+
__decorateClass([
|
|
2955
|
+
property({ fallback: 0 })
|
|
2956
|
+
], TextEditor.prototype, "top");
|
|
2957
|
+
__decorateClass([
|
|
2958
|
+
property({ fallback: 0 })
|
|
2959
|
+
], TextEditor.prototype, "rotate");
|
|
2960
|
+
__decorateClass([
|
|
2961
|
+
property()
|
|
2962
|
+
], TextEditor.prototype, "selection");
|
|
2963
|
+
__decorateClass([
|
|
2964
|
+
property({ internal: true, fallback: () => ({ min: -1, max: -1 }) })
|
|
2965
|
+
], TextEditor.prototype, "_selectionMinMax");
|
|
2966
|
+
__decorateClass([
|
|
2967
|
+
property({ internal: true, fallback: () => [] })
|
|
2968
|
+
], TextEditor.prototype, "_chars");
|
|
2969
|
+
__decorateClass([
|
|
2970
|
+
property({ internal: true, fallback: () => [] })
|
|
2971
|
+
], TextEditor.prototype, "_selectedChars");
|
|
2972
|
+
__decorateClass([
|
|
2973
|
+
property({ internal: true })
|
|
2974
|
+
], TextEditor.prototype, "_cursorPosition");
|
|
2975
|
+
__decorateClass([
|
|
2976
|
+
property({ internal: true, fallback: false })
|
|
2977
|
+
], TextEditor.prototype, "_showCursor");
|
|
2260
2978
|
const _4_1_text = defineMixin((editor) => {
|
|
2261
2979
|
const {
|
|
2262
2980
|
isElement,
|
|
@@ -2856,7 +3574,7 @@ const _4_3_element = defineMixin((editor) => {
|
|
|
2856
3574
|
}
|
|
2857
3575
|
return [node];
|
|
2858
3576
|
}).filter((node) => {
|
|
2859
|
-
return "isVisibleInTree" in node && node.isVisibleInTree() && getObb(node, "drawboard").overlapsOnAxis(area2) && !isLock(node);
|
|
3577
|
+
return "isVisibleInTree" in node && node.isVisibleInTree() && getObb(node, "drawboard").overlapsOnAxis(area2) && !isLock(node) && !node.findAncestor((ancestor) => isLock(ancestor));
|
|
2860
3578
|
}) ?? [];
|
|
2861
3579
|
selection.value = selected;
|
|
2862
3580
|
return selected;
|
|
@@ -3542,7 +4260,18 @@ const _clipboard = definePlugin((editor, options) => {
|
|
|
3542
4260
|
return;
|
|
3543
4261
|
}
|
|
3544
4262
|
addElements(
|
|
3545
|
-
selection.value.map((v) =>
|
|
4263
|
+
selection.value.map((v) => {
|
|
4264
|
+
const el = v.toJSON();
|
|
4265
|
+
if (el.style) {
|
|
4266
|
+
if (el.style.left) {
|
|
4267
|
+
el.style.left += 20;
|
|
4268
|
+
}
|
|
4269
|
+
if (el.style.top) {
|
|
4270
|
+
el.style.top += 20;
|
|
4271
|
+
}
|
|
4272
|
+
}
|
|
4273
|
+
return el;
|
|
4274
|
+
}),
|
|
3546
4275
|
{
|
|
3547
4276
|
parent: selection.value[0].parent,
|
|
3548
4277
|
index: selection.value[0].getIndex(),
|
|
@@ -3650,7 +4379,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
3650
4379
|
return unref(state) === "drawing" && unref(drawboardPointer) ? (openBlock(), createElementBlock("div", {
|
|
3651
4380
|
key: 0,
|
|
3652
4381
|
class: "mce-drawing",
|
|
3653
|
-
style: normalizeStyle({
|
|
4382
|
+
style: normalizeStyle$1({
|
|
3654
4383
|
left: `${unref(drawboardPointer).x}px`,
|
|
3655
4384
|
top: `${unref(drawboardPointer).y}px`
|
|
3656
4385
|
})
|
|
@@ -3793,6 +4522,8 @@ const aliases = {
|
|
|
3793
4522
|
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",
|
|
3794
4523
|
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",
|
|
3795
4524
|
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",
|
|
4525
|
+
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",
|
|
4526
|
+
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",
|
|
3796
4527
|
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",
|
|
3797
4528
|
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",
|
|
3798
4529
|
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",
|
|
@@ -4381,13 +5112,14 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
4381
5112
|
config,
|
|
4382
5113
|
exec,
|
|
4383
5114
|
renderEngine,
|
|
4384
|
-
drawboardDom
|
|
5115
|
+
drawboardDom,
|
|
5116
|
+
isLock
|
|
4385
5117
|
} = useEditor();
|
|
4386
5118
|
const editing = ref(false);
|
|
4387
5119
|
async function onDblclick() {
|
|
4388
5120
|
editing.value = true;
|
|
4389
|
-
await nextTick();
|
|
4390
5121
|
if (input.value) {
|
|
5122
|
+
await nextTick();
|
|
4391
5123
|
input.value.focus();
|
|
4392
5124
|
input.value.select();
|
|
4393
5125
|
}
|
|
@@ -4404,19 +5136,20 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
4404
5136
|
}
|
|
4405
5137
|
return (_ctx, _cache) => {
|
|
4406
5138
|
return withDirectives((openBlock(), createElementBlock("div", {
|
|
4407
|
-
style: normalizeStyle(unref(getObb)(frame.value, "drawboard").toCssStyle()),
|
|
5139
|
+
style: normalizeStyle$1(unref(getObb)(frame.value, "drawboard").toCssStyle()),
|
|
4408
5140
|
class: normalizeClass(["mce-frame", [
|
|
4409
5141
|
unref(config).frameOutline && "mce-frame--outline",
|
|
4410
5142
|
unref(hoverElement)?.equal(frame.value) && "mce-frame--hover",
|
|
4411
|
-
unref(selection).some((v) => v.equal(frame.value)) && "mce-frame--selected"
|
|
5143
|
+
unref(selection).some((v) => v.equal(frame.value)) && "mce-frame--selected",
|
|
5144
|
+
unref(isLock)(frame.value) && "mce-frame--lock"
|
|
4412
5145
|
]])
|
|
4413
5146
|
}, [
|
|
4414
|
-
|
|
5147
|
+
createElementVNode("div", {
|
|
4415
5148
|
class: "mce-frame__name",
|
|
4416
|
-
onDblclick,
|
|
5149
|
+
onDblclick: withModifiers(onDblclick, ["prevent", "stop"]),
|
|
4417
5150
|
onPointerdown,
|
|
4418
|
-
onPointerenter: _cache[2] || (_cache[2] = ($event) => !unref(state) && (hoverElement.value = frame.value)),
|
|
4419
|
-
onPointerleave: _cache[3] || (_cache[3] = ($event) => !unref(state) && (hoverElement.value = void 0))
|
|
5151
|
+
onPointerenter: _cache[2] || (_cache[2] = ($event) => !unref(state) && !unref(isLock)(frame.value) && (hoverElement.value = frame.value)),
|
|
5152
|
+
onPointerleave: _cache[3] || (_cache[3] = ($event) => !unref(state) && !unref(isLock)(frame.value) && (hoverElement.value = void 0))
|
|
4420
5153
|
}, [
|
|
4421
5154
|
createElementVNode("div", null, toDisplayString(frame.value.name), 1),
|
|
4422
5155
|
withDirectives(createElementVNode("input", {
|
|
@@ -4427,9 +5160,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
4427
5160
|
[vShow, editing.value],
|
|
4428
5161
|
[vModelText, frame.value.name]
|
|
4429
5162
|
])
|
|
4430
|
-
],
|
|
4431
|
-
[vShow, unref(config).viewMode === "edgeless"]
|
|
4432
|
-
])
|
|
5163
|
+
], 32)
|
|
4433
5164
|
], 6)), [
|
|
4434
5165
|
[vShow, frame.value.visible]
|
|
4435
5166
|
]);
|
|
@@ -4469,6 +5200,9 @@ const _frame = definePlugin((editor) => {
|
|
|
4469
5200
|
handle: (start) => {
|
|
4470
5201
|
const el = addElement({
|
|
4471
5202
|
name: t("frame"),
|
|
5203
|
+
style: {
|
|
5204
|
+
overflow: "hidden"
|
|
5205
|
+
},
|
|
4472
5206
|
meta: {
|
|
4473
5207
|
inPptIs: "GroupShape",
|
|
4474
5208
|
inEditorIs: "Frame",
|
|
@@ -4675,7 +5409,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
4675
5409
|
key: 0,
|
|
4676
5410
|
class: "mce-hover",
|
|
4677
5411
|
"data-name": unref(hoverElement).name,
|
|
4678
|
-
style: normalizeStyle({
|
|
5412
|
+
style: normalizeStyle$1({
|
|
4679
5413
|
borderColor: "currentcolor",
|
|
4680
5414
|
borderRadius: `${(unref(hoverElement).style.borderRadius ?? 0) * unref(camera).zoom.x}px`,
|
|
4681
5415
|
...hoverElementObb.value.toCssStyle()
|
|
@@ -5181,6 +5915,10 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5181
5915
|
return "$frame";
|
|
5182
5916
|
} else if (node.children.filter(isElement).length) {
|
|
5183
5917
|
return "$group";
|
|
5918
|
+
} else if (node instanceof Lottie2D) {
|
|
5919
|
+
return "$lottie";
|
|
5920
|
+
} else if (node instanceof Video2D) {
|
|
5921
|
+
return "$video";
|
|
5184
5922
|
} else if (isElement(node)) {
|
|
5185
5923
|
if (node.foreground.isValid() && node.foreground.image) {
|
|
5186
5924
|
return "$image";
|
|
@@ -5197,8 +5935,12 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5197
5935
|
if (!value) {
|
|
5198
5936
|
if (isFrame(node)) {
|
|
5199
5937
|
return t("frame");
|
|
5200
|
-
} else if (node.children.length) {
|
|
5938
|
+
} else if (node.children.filter(isElement).length) {
|
|
5201
5939
|
value = t("group");
|
|
5940
|
+
} else if (node instanceof Lottie2D) {
|
|
5941
|
+
value = t("lottie");
|
|
5942
|
+
} else if (node instanceof Video2D) {
|
|
5943
|
+
value = t("video");
|
|
5202
5944
|
} else if (isElement(node)) {
|
|
5203
5945
|
if (node.foreground.isValid() && node.foreground.image) {
|
|
5204
5946
|
value = t("image");
|
|
@@ -5317,7 +6059,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5317
6059
|
isHoverElement.value && "mce-layer--hover",
|
|
5318
6060
|
unref(dropping) && "mce-layer--dropping"
|
|
5319
6061
|
]]),
|
|
5320
|
-
style: normalizeStyle({
|
|
6062
|
+
style: normalizeStyle$1({
|
|
5321
6063
|
"--indent-padding": `${props.indent * 16}px`
|
|
5322
6064
|
}),
|
|
5323
6065
|
"data-id": unref(id),
|
|
@@ -5364,7 +6106,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
5364
6106
|
[vModelText, editValue.value]
|
|
5365
6107
|
]),
|
|
5366
6108
|
createElementVNode("div", {
|
|
5367
|
-
style: normalizeStyle({ visibility: editing.value ? "hidden" : void 0 })
|
|
6109
|
+
style: normalizeStyle$1({ visibility: editing.value ? "hidden" : void 0 })
|
|
5368
6110
|
}, toDisplayString(editValue.value || thumbnailName.value), 5)
|
|
5369
6111
|
], 32),
|
|
5370
6112
|
createElementVNode("div", {
|
|
@@ -5949,7 +6691,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
5949
6691
|
target: position.value,
|
|
5950
6692
|
location: "bottom-start",
|
|
5951
6693
|
items: unref(contextMenu),
|
|
5952
|
-
style: normalizeStyle({
|
|
6694
|
+
style: normalizeStyle$1({
|
|
5953
6695
|
maxHeight: `${unref(drawboardAabb).height * 0.8}px`
|
|
5954
6696
|
}),
|
|
5955
6697
|
"onClick:item": onClickItem
|
|
@@ -10892,7 +11634,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
10892
11634
|
"mce-ruler-refline--horizontal": !props.vertical,
|
|
10893
11635
|
"mce-ruler-refline--temp": item === tempLine.value
|
|
10894
11636
|
}]),
|
|
10895
|
-
style: normalizeStyle({
|
|
11637
|
+
style: normalizeStyle$1({
|
|
10896
11638
|
[props.vertical ? "height" : "width"]: "0",
|
|
10897
11639
|
[props.vertical ? "width" : "height"]: "100%",
|
|
10898
11640
|
[props.vertical ? "top" : "left"]: `${numToPx(item)}px`,
|
|
@@ -11086,7 +11828,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
11086
11828
|
"mce-scrollbar--vertical": props.vertical,
|
|
11087
11829
|
"mce-scrollbar--horizontal": !props.vertical
|
|
11088
11830
|
}]),
|
|
11089
|
-
style: normalizeStyle({
|
|
11831
|
+
style: normalizeStyle$1({
|
|
11090
11832
|
[props.vertical ? "height" : "width"]: `calc(100% - ${props.size + props.offset}px)`,
|
|
11091
11833
|
[props.vertical ? "width" : "height"]: `${props.size}px`,
|
|
11092
11834
|
[props.vertical ? "top" : "left"]: `${props.offset}px`
|
|
@@ -11098,7 +11840,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
11098
11840
|
class: normalizeClass(["mce-scrollbar__thumb", {
|
|
11099
11841
|
"mce-scrollbar__thumb--active": isActive.value
|
|
11100
11842
|
}]),
|
|
11101
|
-
style: normalizeStyle({
|
|
11843
|
+
style: normalizeStyle$1({
|
|
11102
11844
|
top: thumbTop.value,
|
|
11103
11845
|
bottom: thumbBottom.value,
|
|
11104
11846
|
left: thumbLeft.value,
|
|
@@ -11432,7 +12174,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
11432
12174
|
return openBlock(), createElementBlock("div", {
|
|
11433
12175
|
key,
|
|
11434
12176
|
class: normalizeClass(item.class.map((v) => `mce-smart-guides__${v}`)),
|
|
11435
|
-
style: normalizeStyle({
|
|
12177
|
+
style: normalizeStyle$1({
|
|
11436
12178
|
left: `${item.style.left}px`,
|
|
11437
12179
|
top: `${item.style.top}px`,
|
|
11438
12180
|
width: `${item.style.width}px`,
|
|
@@ -12798,7 +13540,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
12798
13540
|
!__props.indeterminate ? (openBlock(), createElementBlock("div", {
|
|
12799
13541
|
key: 0,
|
|
12800
13542
|
class: "progress-indicator__bar-fill",
|
|
12801
|
-
style: normalizeStyle({ width: `${progress.value * 100}%` })
|
|
13543
|
+
style: normalizeStyle$1({ width: `${progress.value * 100}%` })
|
|
12802
13544
|
}, null, 4)) : (openBlock(), createElementBlock("div", _hoisted_4$3))
|
|
12803
13545
|
])
|
|
12804
13546
|
]);
|
|
@@ -13023,10 +13765,38 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
13023
13765
|
},
|
|
13024
13766
|
setup(__props) {
|
|
13025
13767
|
const props = __props;
|
|
13768
|
+
const blocks = computed(() => {
|
|
13769
|
+
const node = props.node;
|
|
13770
|
+
if (node instanceof Element2D) {
|
|
13771
|
+
return node.children.filter((child) => child instanceof Animation).map((anim) => {
|
|
13772
|
+
const box = {
|
|
13773
|
+
left: anim.delay / props.msPerPx,
|
|
13774
|
+
top: 0,
|
|
13775
|
+
width: anim.duration / props.msPerPx
|
|
13776
|
+
};
|
|
13777
|
+
if (box.width) {
|
|
13778
|
+
box.width = `${box.width}px`;
|
|
13779
|
+
} else {
|
|
13780
|
+
box.width = "100%";
|
|
13781
|
+
}
|
|
13782
|
+
return {
|
|
13783
|
+
name: anim.name,
|
|
13784
|
+
style: {
|
|
13785
|
+
width: box.width,
|
|
13786
|
+
transform: `matrix(1, 0, 0, 1, ${box.left}, ${box.top})`
|
|
13787
|
+
}
|
|
13788
|
+
};
|
|
13789
|
+
});
|
|
13790
|
+
}
|
|
13791
|
+
return [];
|
|
13792
|
+
});
|
|
13026
13793
|
const style = computed(() => {
|
|
13027
|
-
const
|
|
13028
|
-
box
|
|
13029
|
-
|
|
13794
|
+
const node = props.node;
|
|
13795
|
+
const box = {
|
|
13796
|
+
left: node.delay / props.msPerPx,
|
|
13797
|
+
top: 0,
|
|
13798
|
+
width: node.duration / props.msPerPx
|
|
13799
|
+
};
|
|
13030
13800
|
if (box.width) {
|
|
13031
13801
|
box.width = `${box.width}px`;
|
|
13032
13802
|
} else {
|
|
@@ -13040,11 +13810,18 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
13040
13810
|
return (_ctx, _cache) => {
|
|
13041
13811
|
return openBlock(), createElementBlock("div", {
|
|
13042
13812
|
class: normalizeClass(["mce-segment", [
|
|
13043
|
-
`mce-segment--${__props.node.meta.inEditorIs}`,
|
|
13813
|
+
`mce-segment--${(__props.node.meta.inEditorIs ?? "none").toLowerCase()}`,
|
|
13044
13814
|
__props.active && `mce-segment--active`
|
|
13045
13815
|
]]),
|
|
13046
|
-
style: normalizeStyle(style.value)
|
|
13816
|
+
style: normalizeStyle$1(style.value)
|
|
13047
13817
|
}, [
|
|
13818
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(blocks.value, (block, index) => {
|
|
13819
|
+
return openBlock(), createElementBlock("div", {
|
|
13820
|
+
key: index,
|
|
13821
|
+
class: "mce-segment__block",
|
|
13822
|
+
style: normalizeStyle$1(block.style)
|
|
13823
|
+
}, toDisplayString(block.name), 5);
|
|
13824
|
+
}), 128)),
|
|
13048
13825
|
__props.active ? (openBlock(), createElementBlock("div", _hoisted_1$8)) : createCommentVNode("", true),
|
|
13049
13826
|
createElementVNode("span", _hoisted_2$4, toDisplayString(props.node.name), 1),
|
|
13050
13827
|
__props.active ? (openBlock(), createElementBlock("div", _hoisted_3$4)) : createCommentVNode("", true)
|
|
@@ -13072,7 +13849,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
13072
13849
|
return (_ctx, _cache) => {
|
|
13073
13850
|
return openBlock(), createElementBlock("div", {
|
|
13074
13851
|
class: "mce-trackhead",
|
|
13075
|
-
style: normalizeStyle({
|
|
13852
|
+
style: normalizeStyle$1({
|
|
13076
13853
|
height: `var(--timeline-track-height__${__props.node.meta.inEditorIs}, 22px)`
|
|
13077
13854
|
})
|
|
13078
13855
|
}, toDisplayString(__props.node.meta.inEditorIs), 5);
|
|
@@ -13201,7 +13978,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
13201
13978
|
createElementVNode("div", _hoisted_3$3, [
|
|
13202
13979
|
createElementVNode("div", _hoisted_4$1, [
|
|
13203
13980
|
createElementVNode("div", {
|
|
13204
|
-
style: normalizeStyle({
|
|
13981
|
+
style: normalizeStyle$1({
|
|
13205
13982
|
transform: `translateY(${offset2.value[1]}px)`
|
|
13206
13983
|
})
|
|
13207
13984
|
}, [
|
|
@@ -13233,7 +14010,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
13233
14010
|
]),
|
|
13234
14011
|
createElementVNode("div", _hoisted_7$1, [
|
|
13235
14012
|
createElementVNode("div", {
|
|
13236
|
-
style: normalizeStyle({
|
|
14013
|
+
style: normalizeStyle$1({
|
|
13237
14014
|
width: `${unref(endTime) / unref(msPerPx)}px`,
|
|
13238
14015
|
transform: `translate(${offset2.value[0]}px, ${offset2.value[1]}px)`
|
|
13239
14016
|
})
|
|
@@ -13254,7 +14031,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
13254
14031
|
], 4)
|
|
13255
14032
|
]),
|
|
13256
14033
|
createVNode(_sfc_main$h, {
|
|
13257
|
-
style: normalizeStyle({
|
|
14034
|
+
style: normalizeStyle$1({
|
|
13258
14035
|
transform: `translate(${offset2.value[0] + Math.ceil(unref(currentTime) / unref(msPerPx))}px, 0px)`
|
|
13259
14036
|
})
|
|
13260
14037
|
}, null, 8, ["style"])
|
|
@@ -13857,7 +14634,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
13857
14634
|
return (_ctx, _cache) => {
|
|
13858
14635
|
return openBlock(), createBlock(_sfc_main$u, {
|
|
13859
14636
|
ref: "overlayTpl",
|
|
13860
|
-
style: normalizeStyle(style.value),
|
|
14637
|
+
style: normalizeStyle$1(style.value),
|
|
13861
14638
|
class: "mce-floatbar",
|
|
13862
14639
|
location: props.location,
|
|
13863
14640
|
middlewares: props.middlewares,
|
|
@@ -14382,7 +15159,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
14382
15159
|
activeHandle.value?.startsWith("rotate") && "mce-transformable--rotateing",
|
|
14383
15160
|
props.borderStyle && `mce-transformable--${props.borderStyle}`
|
|
14384
15161
|
]]),
|
|
14385
|
-
style: normalizeStyle(style.value)
|
|
15162
|
+
style: normalizeStyle$1(style.value)
|
|
14386
15163
|
}, {
|
|
14387
15164
|
default: withCtx(() => [
|
|
14388
15165
|
renderSlot(_ctx.$slots, "default", {
|
|
@@ -14603,7 +15380,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
14603
15380
|
return withDirectives((openBlock(), createElementBlock("div", _hoisted_1$3, [
|
|
14604
15381
|
createElementVNode("div", {
|
|
14605
15382
|
class: "mce-cropper__source",
|
|
14606
|
-
style: normalizeStyle(sourceStyle.value)
|
|
15383
|
+
style: normalizeStyle$1(sourceStyle.value)
|
|
14607
15384
|
}, [
|
|
14608
15385
|
createElementVNode("canvas", {
|
|
14609
15386
|
ref_key: "canvasRef",
|
|
@@ -14646,7 +15423,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
14646
15423
|
key: 0,
|
|
14647
15424
|
modelValue: element.value.foreground.cropRect,
|
|
14648
15425
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => element.value.foreground.cropRect = $event),
|
|
14649
|
-
style: normalizeStyle(element.value.style.toJSON()),
|
|
15426
|
+
style: normalizeStyle$1(element.value.style.toJSON()),
|
|
14650
15427
|
image: element.value.foreground.image,
|
|
14651
15428
|
class: "pointer-events-auto",
|
|
14652
15429
|
"onUpdate:style": _cache[1] || (_cache[1] = (val) => element.value.style.setProperties(val)),
|
|
@@ -14855,7 +15632,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
14855
15632
|
return openBlock(), createElementBlock("div", {
|
|
14856
15633
|
key: index,
|
|
14857
15634
|
class: "mce-selector__parent-element",
|
|
14858
|
-
style: normalizeStyle({
|
|
15635
|
+
style: normalizeStyle$1({
|
|
14859
15636
|
borderColor: "currentColor",
|
|
14860
15637
|
...style
|
|
14861
15638
|
})
|
|
@@ -14864,7 +15641,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
14864
15641
|
unref(state) === "selecting" ? (openBlock(), createElementBlock("div", {
|
|
14865
15642
|
key: 0,
|
|
14866
15643
|
class: "mce-selector__selected-area",
|
|
14867
|
-
style: normalizeStyle({
|
|
15644
|
+
style: normalizeStyle$1({
|
|
14868
15645
|
borderColor: "currentcolor",
|
|
14869
15646
|
...props.selectedArea.toCssStyle()
|
|
14870
15647
|
})
|
|
@@ -14873,7 +15650,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
14873
15650
|
return openBlock(), createElementBlock("div", {
|
|
14874
15651
|
key: index,
|
|
14875
15652
|
class: "mce-selector__element",
|
|
14876
|
-
style: normalizeStyle({
|
|
15653
|
+
style: normalizeStyle$1({
|
|
14877
15654
|
borderColor: "currentcolor",
|
|
14878
15655
|
...style
|
|
14879
15656
|
})
|
|
@@ -14907,7 +15684,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
14907
15684
|
transform.value.width && transform.value.height && _ctx.$slots.default ? (openBlock(), createElementBlock("div", {
|
|
14908
15685
|
key: 2,
|
|
14909
15686
|
class: "mce-selector__slot",
|
|
14910
|
-
style: normalizeStyle(unref(boundingBoxToStyle)(transform.value))
|
|
15687
|
+
style: normalizeStyle$1(unref(boundingBoxToStyle)(transform.value))
|
|
14911
15688
|
}, [
|
|
14912
15689
|
renderSlot(_ctx.$slots, "default", { box: transform.value })
|
|
14913
15690
|
], 4)) : createCommentVNode("", true)
|
|
@@ -15006,7 +15783,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
15006
15783
|
return openBlock(), createElementBlock("div", {
|
|
15007
15784
|
ref: unref(layoutRef),
|
|
15008
15785
|
class: normalizeClass(normalizeClass([unref(layoutClasses), props.class])),
|
|
15009
|
-
style: normalizeStyle(normalizeStyle([unref(layoutStyles), props.style]))
|
|
15786
|
+
style: normalizeStyle$1(normalizeStyle$1([unref(layoutStyles), props.style]))
|
|
15010
15787
|
}, [
|
|
15011
15788
|
renderSlot(_ctx.$slots, "default")
|
|
15012
15789
|
], 6);
|
|
@@ -15052,7 +15829,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
15052
15829
|
`mce-layout-item--${props.position}`,
|
|
15053
15830
|
props.class
|
|
15054
15831
|
])),
|
|
15055
|
-
style: normalizeStyle(normalizeStyle([unref(layoutItemStyles), props.style]))
|
|
15832
|
+
style: normalizeStyle$1(normalizeStyle$1([unref(layoutItemStyles), props.style]))
|
|
15056
15833
|
}, [
|
|
15057
15834
|
renderSlot(_ctx.$slots, "default")
|
|
15058
15835
|
], 6);
|
|
@@ -15076,7 +15853,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
15076
15853
|
class: normalizeClass(["mce-main", [
|
|
15077
15854
|
{ "mce-main--scrollable": props.scrollable }
|
|
15078
15855
|
]]),
|
|
15079
|
-
style: normalizeStyle([unref(mainStyles)])
|
|
15856
|
+
style: normalizeStyle$1([unref(mainStyles)])
|
|
15080
15857
|
}, [
|
|
15081
15858
|
props.scrollable ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
15082
15859
|
renderSlot(_ctx.$slots, "default")
|
|
@@ -15157,13 +15934,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
15157
15934
|
return (_ctx, _cache) => {
|
|
15158
15935
|
return withDirectives((openBlock(), createElementBlock("div", {
|
|
15159
15936
|
class: "mce-text-editor",
|
|
15160
|
-
style: normalizeStyle({
|
|
15937
|
+
style: normalizeStyle$1({
|
|
15161
15938
|
...mainStyleWithScale.value
|
|
15162
15939
|
})
|
|
15163
15940
|
}, [
|
|
15164
15941
|
createElementVNode("div", {
|
|
15165
15942
|
class: "mce-text-editor__wrapper",
|
|
15166
|
-
style: normalizeStyle({
|
|
15943
|
+
style: normalizeStyle$1({
|
|
15167
15944
|
...textEditorStyle.value
|
|
15168
15945
|
})
|
|
15169
15946
|
}, [
|
|
@@ -15299,7 +16076,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15299
16076
|
hovered = result;
|
|
15300
16077
|
}
|
|
15301
16078
|
}
|
|
15302
|
-
if (!(isElement(hovered) && !isLock(hovered) && !isTopLevelFrame(hovered))) {
|
|
16079
|
+
if (!(isElement(hovered) && !isLock(hovered) && !hovered.findAncestor((ancestor) => isLock(ancestor)) && !isTopLevelFrame(hovered))) {
|
|
15303
16080
|
hovered = void 0;
|
|
15304
16081
|
cursor = void 0;
|
|
15305
16082
|
}
|
|
@@ -15314,7 +16091,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15314
16091
|
allowRootFrame = false
|
|
15315
16092
|
} = options;
|
|
15316
16093
|
function isIncluded(node) {
|
|
15317
|
-
return isElement(node) && !isLock(node) && (allowRootFrame || !isTopLevelFrame(node));
|
|
16094
|
+
return isElement(node) && !isLock(node) && (allowRootFrame || !isTopLevelFrame(node)) && !node.findAncestor((ancestor) => isLock(ancestor));
|
|
15318
16095
|
}
|
|
15319
16096
|
const drawing = state.value === "drawing";
|
|
15320
16097
|
const hand = state.value === "hand";
|