mechanica 1.0.3 → 1.0.5-a
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/editor.js +2002 -349
- package/dist/editor.js.map +1 -1
- package/dist/main.d.ts +71 -23
- package/dist/main.js +100 -22
- package/dist/main.js.map +1 -1
- package/dist/plugin.js +20 -27
- package/dist/plugin.js.map +1 -1
- package/dist/schemaAliases-jUlXWmB3.js +51 -0
- package/dist/schemaAliases-jUlXWmB3.js.map +1 -0
- package/dist/style.css +121 -7
- package/dist/updater.js +6 -0
- package/dist/updater.js.map +1 -1
- package/package.json +58 -57
package/dist/editor.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { defineComponent, ref, watch,
|
|
1
|
+
import { defineComponent, ref, watch, createElementBlock, openBlock, normalizeStyle, createElementVNode, shallowRef, onMounted, onBeforeUnmount, triggerRef, computed, inject, normalizeClass, createCommentVNode, renderSlot, createVNode, createTextVNode, toDisplayString, Transition, withCtx, getCurrentScope, onScopeDispose, toRef as toRef$1, readonly, customRef, toValue as toValue$1, getCurrentInstance, nextTick, unref, createBlock, createSlots, withDirectives, vModelText, vModelDynamic, Fragment, renderList, h, TransitionGroup, useSlots, Teleport, mergeProps, withModifiers, createStaticVNode, resolveDynamicComponent, isRef, reactive, vShow, shallowReactive, mergeModels, useModel, vModelCheckbox, isProxy, toRaw, resolveComponent, normalizeProps, guardReactiveProps, provide, createApp } from "vue";
|
|
2
|
+
import { g as getDefaultValue, d as defaultImageSrc, r as registerAliases, p as passDefaultValue } from "./schemaAliases-jUlXWmB3.js";
|
|
2
3
|
import { blocksList as blocksList$1, addUpdateListener } from "virtual:builder-blocks";
|
|
3
|
-
import {
|
|
4
|
-
const _sfc_main$
|
|
4
|
+
import { unfoldSchema } from "compact-json-schema";
|
|
5
|
+
const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
5
6
|
__name: "HoverFrame",
|
|
6
7
|
props: {
|
|
7
8
|
element: {},
|
|
@@ -43,7 +44,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
46
|
});
|
|
46
|
-
const _sfc_main$
|
|
47
|
+
const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
47
48
|
__name: "InsertedPlace",
|
|
48
49
|
props: {
|
|
49
50
|
top: {}
|
|
@@ -64,48 +65,48 @@ const _export_sfc = (sfc, props) => {
|
|
|
64
65
|
}
|
|
65
66
|
return target;
|
|
66
67
|
};
|
|
67
|
-
const _sfc_main$
|
|
68
|
-
const _hoisted_1$
|
|
68
|
+
const _sfc_main$G = {};
|
|
69
|
+
const _hoisted_1$z = {
|
|
69
70
|
width: "16",
|
|
70
71
|
height: "16",
|
|
71
72
|
viewBox: "0 0 16 16",
|
|
72
73
|
fill: "none",
|
|
73
74
|
xmlns: "http://www.w3.org/2000/svg"
|
|
74
75
|
};
|
|
75
|
-
function _sfc_render$
|
|
76
|
-
return openBlock(), createElementBlock("svg", _hoisted_1$
|
|
76
|
+
function _sfc_render$f(_ctx, _cache) {
|
|
77
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$z, _cache[0] || (_cache[0] = [
|
|
77
78
|
createElementVNode("path", {
|
|
78
79
|
d: "M10.707 14.364C10.8945 14.1764 10.9998 13.9221 10.9998 13.657C10.9998 13.3918 10.8945 13.1375 10.707 12.95L5.75705 7.99995L10.707 3.04995C10.8892 2.86135 10.99 2.60875 10.9877 2.34655C10.9854 2.08435 10.8803 1.83354 10.6949 1.64813C10.5095 1.46272 10.2586 1.35756 9.99645 1.35528C9.73425 1.353 9.48165 1.45379 9.29305 1.63595L3.63605 7.29295C3.44858 7.48048 3.34326 7.73479 3.34326 7.99995C3.34326 8.26512 3.44858 8.51942 3.63605 8.70695L9.29305 14.364C9.48058 14.5514 9.73488 14.6567 10 14.6567C10.2652 14.6567 10.5195 14.5514 10.707 14.364Z",
|
|
79
80
|
fill: "currentColor"
|
|
80
81
|
}, null, -1)
|
|
81
82
|
]));
|
|
82
83
|
}
|
|
83
|
-
const ChevronLeftIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
84
|
-
const _sfc_main$
|
|
85
|
-
const _hoisted_1$
|
|
84
|
+
const ChevronLeftIcon = /* @__PURE__ */ _export_sfc(_sfc_main$G, [["render", _sfc_render$f]]);
|
|
85
|
+
const _sfc_main$F = {};
|
|
86
|
+
const _hoisted_1$y = {
|
|
86
87
|
width: "16",
|
|
87
88
|
height: "16",
|
|
88
89
|
viewBox: "0 0 16 16",
|
|
89
90
|
fill: "none",
|
|
90
91
|
xmlns: "http://www.w3.org/2000/svg"
|
|
91
92
|
};
|
|
92
|
-
function _sfc_render$
|
|
93
|
-
return openBlock(), createElementBlock("svg", _hoisted_1$
|
|
93
|
+
function _sfc_render$e(_ctx, _cache) {
|
|
94
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$y, _cache[0] || (_cache[0] = [
|
|
94
95
|
createElementVNode("path", {
|
|
95
96
|
d: "M5.29295 1.63605C5.10548 1.82358 5.00017 2.07788 5.00017 2.34305C5.00017 2.60821 5.10548 2.86252 5.29295 3.05005L10.243 8.00005L5.29295 12.95C5.11079 13.1387 5.01 13.3913 5.01228 13.6534C5.01456 13.9156 5.11972 14.1665 5.30513 14.3519C5.49054 14.5373 5.74135 14.6424 6.00355 14.6447C6.26575 14.647 6.51835 14.5462 6.70695 14.364L12.364 8.70705C12.5514 8.51952 12.6567 8.26521 12.6567 8.00005C12.6567 7.73488 12.5514 7.48058 12.364 7.29305L6.70695 1.63605C6.51942 1.44858 6.26512 1.34326 5.99995 1.34326C5.73479 1.34326 5.48048 1.44858 5.29295 1.63605Z",
|
|
96
97
|
fill: "currentColor"
|
|
97
98
|
}, null, -1)
|
|
98
99
|
]));
|
|
99
100
|
}
|
|
100
|
-
const ChevronRightIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
101
|
-
const findParent = (el, callback) => {
|
|
101
|
+
const ChevronRightIcon = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["render", _sfc_render$e]]);
|
|
102
|
+
const findParent$1 = (el, callback) => {
|
|
102
103
|
if (callback(el)) return el;
|
|
103
104
|
if (!el.parentElement) return null;
|
|
104
|
-
return findParent(el.parentElement, callback);
|
|
105
|
+
return findParent$1(el.parentElement, callback);
|
|
105
106
|
};
|
|
106
107
|
const clickOnIgnore = (target, ignoreEl) => {
|
|
107
108
|
if (!ignoreEl) return false;
|
|
108
|
-
return !!findParent(target, (el) => {
|
|
109
|
+
return !!findParent$1(target, (el) => {
|
|
109
110
|
if (!Array.isArray(ignoreEl)) return el === ignoreEl.value;
|
|
110
111
|
for (const item of ignoreEl) {
|
|
111
112
|
if (item.value === el) return true;
|
|
@@ -227,7 +228,7 @@ const useDraggableItem = () => {
|
|
|
227
228
|
}
|
|
228
229
|
const el = e.currentTarget;
|
|
229
230
|
const rect = el.getBoundingClientRect();
|
|
230
|
-
const offset = { left: rect.left - e.clientX, top: rect.top - e.clientY };
|
|
231
|
+
const offset = options.offset ?? { left: rect.left - e.clientX, top: rect.top - e.clientY };
|
|
231
232
|
const width = el.clientWidth;
|
|
232
233
|
const onStart = () => {
|
|
233
234
|
var _a;
|
|
@@ -349,34 +350,44 @@ class PairMap {
|
|
|
349
350
|
const dataMap = new PairMap();
|
|
350
351
|
const events = new MultiMap();
|
|
351
352
|
const getArgKey = (args) => {
|
|
352
|
-
return args.length === 0 ? "
|
|
353
|
+
return args.length === 0 ? "" : JSON.stringify(args);
|
|
353
354
|
};
|
|
354
|
-
const getEntryOrCreate = (request,
|
|
355
|
-
const argKey = getArgKey(args);
|
|
355
|
+
const getEntryOrCreate = (request, argKey, defaultValue) => {
|
|
356
356
|
const existsValue = dataMap.get(request, argKey);
|
|
357
357
|
if (existsValue) return existsValue;
|
|
358
358
|
dataMap.set(request, argKey, defaultValue);
|
|
359
359
|
return defaultValue;
|
|
360
360
|
};
|
|
361
|
-
const
|
|
361
|
+
const useRequestExt = (options, request, ...args) => {
|
|
362
362
|
const defaultValue = dataMap.get(request, getArgKey(args));
|
|
363
363
|
const pending = shallowRef(defaultValue === null);
|
|
364
364
|
const data = shallowRef((defaultValue == null ? void 0 : defaultValue.data) ?? null);
|
|
365
365
|
const error = shallowRef(null);
|
|
366
366
|
let lastArgs = [];
|
|
367
|
+
let currentArgKey = null;
|
|
367
368
|
const mutate = async (...args2) => {
|
|
369
|
+
const argKey = getArgKey(args2);
|
|
370
|
+
currentArgKey = argKey;
|
|
368
371
|
error.value = null;
|
|
369
372
|
const returnDataValue = returnDataCallback == null ? void 0 : returnDataCallback(...args2);
|
|
370
373
|
if (returnDataValue !== void 0) {
|
|
374
|
+
pending.value = false;
|
|
371
375
|
data.value = returnDataValue;
|
|
372
376
|
return;
|
|
373
377
|
}
|
|
374
|
-
const entry = getEntryOrCreate(request,
|
|
378
|
+
const entry = getEntryOrCreate(request, argKey, { data: null, lastUpdate: -1, updatedManually: false });
|
|
375
379
|
data.value = entry.data;
|
|
376
|
-
pending.value = entry === null;
|
|
380
|
+
pending.value = entry.data === null;
|
|
377
381
|
lastArgs = args2;
|
|
382
|
+
if (entry.data && entry.updatedManually) {
|
|
383
|
+
triggerRef(data);
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
378
386
|
try {
|
|
379
|
-
|
|
387
|
+
const resp = await makeRequestWithoutCache(entry, request, ...args2);
|
|
388
|
+
if (currentArgKey === argKey) {
|
|
389
|
+
data.value = resp;
|
|
390
|
+
}
|
|
380
391
|
} catch (e) {
|
|
381
392
|
error.value = e;
|
|
382
393
|
} finally {
|
|
@@ -385,9 +396,12 @@ const useRequest = (request, ...args) => {
|
|
|
385
396
|
}
|
|
386
397
|
};
|
|
387
398
|
const lazyMutate = async (...args2) => {
|
|
388
|
-
const
|
|
399
|
+
const argKey = getArgKey(args2);
|
|
400
|
+
currentArgKey = argKey;
|
|
401
|
+
const entry = dataMap.get(request, argKey);
|
|
389
402
|
if (entry !== null && entry.lastUpdate > 0 && Date.now() < entry.lastUpdate + 1e3 * 30) {
|
|
390
403
|
data.value = entry.data;
|
|
404
|
+
error.value = null;
|
|
391
405
|
lastArgs = args2;
|
|
392
406
|
return;
|
|
393
407
|
}
|
|
@@ -409,6 +423,7 @@ const useRequest = (request, ...args) => {
|
|
|
409
423
|
});
|
|
410
424
|
return { data, error, pending, mutate, lazyMutate, setReturnData };
|
|
411
425
|
};
|
|
426
|
+
const useRequest = (request, ...args) => useRequestExt({}, request, ...args);
|
|
412
427
|
const makeRequestWithoutCache = async (entry, request, ...args) => {
|
|
413
428
|
if (!entry.promise) {
|
|
414
429
|
const promise = (async () => {
|
|
@@ -458,8 +473,7 @@ const useSearch = (searchValue, data, keyExtractor) => {
|
|
|
458
473
|
});
|
|
459
474
|
return dataSearched;
|
|
460
475
|
};
|
|
461
|
-
|
|
462
|
-
let hasEvent = false;
|
|
476
|
+
let listeners = new MultiMap();
|
|
463
477
|
const handleKeyDownLayer = (e) => {
|
|
464
478
|
if (!listeners.has(e.code)) return;
|
|
465
479
|
const _listeners = listeners.get(e.code);
|
|
@@ -469,6 +483,7 @@ const handleKeyDownLayer = (e) => {
|
|
|
469
483
|
};
|
|
470
484
|
const useKeyDownLayer = (key, watcher, callback) => {
|
|
471
485
|
watch(watcher, (value) => {
|
|
486
|
+
const hasEvent = listeners.size > 0;
|
|
472
487
|
if (value) {
|
|
473
488
|
listeners.add(key, callback);
|
|
474
489
|
} else {
|
|
@@ -476,11 +491,9 @@ const useKeyDownLayer = (key, watcher, callback) => {
|
|
|
476
491
|
}
|
|
477
492
|
if (listeners.size > 0 && !hasEvent) {
|
|
478
493
|
document.addEventListener("keydown", handleKeyDownLayer);
|
|
479
|
-
hasEvent = true;
|
|
480
494
|
}
|
|
481
495
|
if (listeners.size === 0) {
|
|
482
496
|
document.removeEventListener("keydown", handleKeyDownLayer);
|
|
483
|
-
hasEvent = false;
|
|
484
497
|
}
|
|
485
498
|
}, { immediate: true });
|
|
486
499
|
};
|
|
@@ -492,11 +505,11 @@ class BlockDropEvent extends Event {
|
|
|
492
505
|
this.content = content;
|
|
493
506
|
}
|
|
494
507
|
}
|
|
495
|
-
const _hoisted_1$
|
|
508
|
+
const _hoisted_1$x = {
|
|
496
509
|
key: 0,
|
|
497
510
|
class: "v-form-control__label"
|
|
498
511
|
};
|
|
499
|
-
const _hoisted_2$
|
|
512
|
+
const _hoisted_2$a = {
|
|
500
513
|
key: 0,
|
|
501
514
|
class: "v-form-control__required-marker"
|
|
502
515
|
};
|
|
@@ -504,7 +517,7 @@ const _hoisted_3$7 = {
|
|
|
504
517
|
key: 1,
|
|
505
518
|
class: "v-form-control__outline"
|
|
506
519
|
};
|
|
507
|
-
const _hoisted_4$
|
|
520
|
+
const _hoisted_4$5 = {
|
|
508
521
|
key: 3,
|
|
509
522
|
class: "v-form-control__actions"
|
|
510
523
|
};
|
|
@@ -512,7 +525,7 @@ const _hoisted_5$2 = {
|
|
|
512
525
|
key: 0,
|
|
513
526
|
class: "v-form-control__error"
|
|
514
527
|
};
|
|
515
|
-
const _sfc_main$
|
|
528
|
+
const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
516
529
|
__name: "VFormControl",
|
|
517
530
|
props: {
|
|
518
531
|
error: {},
|
|
@@ -525,24 +538,26 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
525
538
|
const props = __props;
|
|
526
539
|
const error = computed(() => {
|
|
527
540
|
if (!props.error) return "";
|
|
541
|
+
if (typeof props.error === "string") return errorMap[props.error] ?? props.error;
|
|
528
542
|
const code = props.error["code"];
|
|
529
|
-
if (code) {
|
|
530
|
-
return
|
|
543
|
+
if (code && code in errorMap) {
|
|
544
|
+
return errorMap[code] ?? "";
|
|
531
545
|
}
|
|
532
546
|
return props.error.message ?? "Произошла ошибка";
|
|
533
547
|
});
|
|
548
|
+
const errorMap = inject("errorMap", {});
|
|
534
549
|
return (_ctx, _cache) => {
|
|
535
550
|
return openBlock(), createElementBlock("div", {
|
|
536
551
|
class: normalizeClass(["v-form-control", { error: !!props.error, disabled: props.disabled }])
|
|
537
552
|
}, [
|
|
538
|
-
!!props.label ? (openBlock(), createElementBlock("label", _hoisted_1$
|
|
553
|
+
!!props.label ? (openBlock(), createElementBlock("label", _hoisted_1$x, [
|
|
539
554
|
createTextVNode(toDisplayString(props.label), 1),
|
|
540
|
-
props.required ? (openBlock(), createElementBlock("span", _hoisted_2$
|
|
555
|
+
props.required ? (openBlock(), createElementBlock("span", _hoisted_2$a, "*")) : createCommentVNode("", true)
|
|
541
556
|
])) : createCommentVNode("", true),
|
|
542
557
|
props.outline ? (openBlock(), createElementBlock("div", _hoisted_3$7, [
|
|
543
558
|
renderSlot(_ctx.$slots, "default")
|
|
544
559
|
])) : renderSlot(_ctx.$slots, "default", { key: 2 }),
|
|
545
|
-
_ctx.$slots.actions ? (openBlock(), createElementBlock("div", _hoisted_4$
|
|
560
|
+
_ctx.$slots.actions ? (openBlock(), createElementBlock("div", _hoisted_4$5, [
|
|
546
561
|
renderSlot(_ctx.$slots, "actions")
|
|
547
562
|
])) : createCommentVNode("", true),
|
|
548
563
|
createVNode(Transition, null, {
|
|
@@ -555,7 +570,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
555
570
|
};
|
|
556
571
|
}
|
|
557
572
|
});
|
|
558
|
-
function tryOnScopeDispose(fn) {
|
|
573
|
+
function tryOnScopeDispose$1(fn) {
|
|
559
574
|
if (getCurrentScope()) {
|
|
560
575
|
onScopeDispose(fn);
|
|
561
576
|
return true;
|
|
@@ -573,7 +588,7 @@ function createEventHook() {
|
|
|
573
588
|
const on = (fn) => {
|
|
574
589
|
fns.add(fn);
|
|
575
590
|
const offFn = () => off(fn);
|
|
576
|
-
tryOnScopeDispose(offFn);
|
|
591
|
+
tryOnScopeDispose$1(offFn);
|
|
577
592
|
return {
|
|
578
593
|
off: offFn
|
|
579
594
|
};
|
|
@@ -588,12 +603,12 @@ function createEventHook() {
|
|
|
588
603
|
clear
|
|
589
604
|
};
|
|
590
605
|
}
|
|
591
|
-
const isClient = typeof window !== "undefined" && typeof document !== "undefined";
|
|
606
|
+
const isClient$1 = typeof window !== "undefined" && typeof document !== "undefined";
|
|
592
607
|
typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
|
|
593
608
|
const isDef = (val) => typeof val !== "undefined";
|
|
594
|
-
const toString = Object.prototype.toString;
|
|
595
|
-
const isObject = (val) => toString.call(val) === "[object Object]";
|
|
596
|
-
const noop = () => {
|
|
609
|
+
const toString$1 = Object.prototype.toString;
|
|
610
|
+
const isObject$1 = (val) => toString$1.call(val) === "[object Object]";
|
|
611
|
+
const noop$1 = () => {
|
|
597
612
|
};
|
|
598
613
|
const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
|
|
599
614
|
function createFilterWrapper(filter, fn) {
|
|
@@ -610,15 +625,16 @@ const bypassFilter = (invoke) => {
|
|
|
610
625
|
function debounceFilter(ms, options = {}) {
|
|
611
626
|
let timer;
|
|
612
627
|
let maxTimer;
|
|
613
|
-
let lastRejector = noop;
|
|
628
|
+
let lastRejector = noop$1;
|
|
614
629
|
const _clearTimeout = (timer2) => {
|
|
615
630
|
clearTimeout(timer2);
|
|
616
631
|
lastRejector();
|
|
617
|
-
lastRejector = noop;
|
|
632
|
+
lastRejector = noop$1;
|
|
618
633
|
};
|
|
634
|
+
let lastInvoker;
|
|
619
635
|
const filter = (invoke) => {
|
|
620
|
-
const duration = toValue(ms);
|
|
621
|
-
const maxDuration = toValue(options.maxWait);
|
|
636
|
+
const duration = toValue$1(ms);
|
|
637
|
+
const maxDuration = toValue$1(options.maxWait);
|
|
622
638
|
if (timer)
|
|
623
639
|
_clearTimeout(timer);
|
|
624
640
|
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
|
|
@@ -630,12 +646,13 @@ function debounceFilter(ms, options = {}) {
|
|
|
630
646
|
}
|
|
631
647
|
return new Promise((resolve, reject) => {
|
|
632
648
|
lastRejector = options.rejectOnCancel ? reject : resolve;
|
|
649
|
+
lastInvoker = invoke;
|
|
633
650
|
if (maxDuration && !maxTimer) {
|
|
634
651
|
maxTimer = setTimeout(() => {
|
|
635
652
|
if (timer)
|
|
636
653
|
_clearTimeout(timer);
|
|
637
654
|
maxTimer = null;
|
|
638
|
-
resolve(
|
|
655
|
+
resolve(lastInvoker());
|
|
639
656
|
}, maxDuration);
|
|
640
657
|
}
|
|
641
658
|
timer = setTimeout(() => {
|
|
@@ -655,7 +672,7 @@ function toRef(...args) {
|
|
|
655
672
|
if (args.length !== 1)
|
|
656
673
|
return toRef$1(...args);
|
|
657
674
|
const r = args[0];
|
|
658
|
-
return typeof r === "function" ? readonly(customRef(() => ({ get: r, set: noop }))) : ref(r);
|
|
675
|
+
return typeof r === "function" ? readonly(customRef(() => ({ get: r, set: noop$1 }))) : ref(r);
|
|
659
676
|
}
|
|
660
677
|
function watchWithFilter(source, cb, options = {}) {
|
|
661
678
|
const {
|
|
@@ -686,61 +703,72 @@ function watchDebounced(source, cb, options = {}) {
|
|
|
686
703
|
}
|
|
687
704
|
);
|
|
688
705
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
706
|
+
function watchImmediate(source, cb, options) {
|
|
707
|
+
return watch(
|
|
708
|
+
source,
|
|
709
|
+
cb,
|
|
710
|
+
{
|
|
711
|
+
...options,
|
|
712
|
+
immediate: true
|
|
713
|
+
}
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
const defaultWindow$1 = isClient$1 ? window : void 0;
|
|
717
|
+
const defaultDocument = isClient$1 ? window.document : void 0;
|
|
718
|
+
function unrefElement$1(elRef) {
|
|
692
719
|
var _a;
|
|
693
|
-
const plain = toValue(elRef);
|
|
720
|
+
const plain = toValue$1(elRef);
|
|
694
721
|
return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
|
|
695
722
|
}
|
|
696
|
-
function useEventListener(...args) {
|
|
697
|
-
let target;
|
|
698
|
-
let events2;
|
|
699
|
-
let listeners2;
|
|
700
|
-
let options;
|
|
701
|
-
if (typeof args[0] === "string" || Array.isArray(args[0])) {
|
|
702
|
-
[events2, listeners2, options] = args;
|
|
703
|
-
target = defaultWindow;
|
|
704
|
-
} else {
|
|
705
|
-
[target, events2, listeners2, options] = args;
|
|
706
|
-
}
|
|
707
|
-
if (!target)
|
|
708
|
-
return noop;
|
|
709
|
-
events2 = toArray(events2);
|
|
710
|
-
listeners2 = toArray(listeners2);
|
|
723
|
+
function useEventListener$1(...args) {
|
|
711
724
|
const cleanups = [];
|
|
712
725
|
const cleanup = () => {
|
|
713
726
|
cleanups.forEach((fn) => fn());
|
|
714
727
|
cleanups.length = 0;
|
|
715
728
|
};
|
|
716
|
-
const register = (el, event, listener,
|
|
717
|
-
el.addEventListener(event, listener,
|
|
718
|
-
return () => el.removeEventListener(event, listener,
|
|
729
|
+
const register = (el, event, listener, options) => {
|
|
730
|
+
el.addEventListener(event, listener, options);
|
|
731
|
+
return () => el.removeEventListener(event, listener, options);
|
|
719
732
|
};
|
|
720
|
-
const
|
|
721
|
-
|
|
722
|
-
(
|
|
733
|
+
const firstParamTargets = computed(() => {
|
|
734
|
+
const test = toArray(toValue$1(args[0])).filter((e) => e != null);
|
|
735
|
+
return test.every((e) => typeof e !== "string") ? test : void 0;
|
|
736
|
+
});
|
|
737
|
+
const stopWatch = watchImmediate(
|
|
738
|
+
() => {
|
|
739
|
+
var _a, _b;
|
|
740
|
+
return [
|
|
741
|
+
(_b = (_a = firstParamTargets.value) == null ? void 0 : _a.map((e) => unrefElement$1(e))) != null ? _b : [defaultWindow$1].filter((e) => e != null),
|
|
742
|
+
toArray(toValue$1(firstParamTargets.value ? args[1] : args[0])),
|
|
743
|
+
toArray(unref(firstParamTargets.value ? args[2] : args[1])),
|
|
744
|
+
// @ts-expect-error - TypeScript gets the correct types, but somehow still complains
|
|
745
|
+
toValue$1(firstParamTargets.value ? args[3] : args[2])
|
|
746
|
+
];
|
|
747
|
+
},
|
|
748
|
+
([raw_targets, raw_events, raw_listeners, raw_options]) => {
|
|
723
749
|
cleanup();
|
|
724
|
-
if (!
|
|
750
|
+
if (!(raw_targets == null ? void 0 : raw_targets.length) || !(raw_events == null ? void 0 : raw_events.length) || !(raw_listeners == null ? void 0 : raw_listeners.length))
|
|
725
751
|
return;
|
|
726
|
-
const optionsClone = isObject(
|
|
752
|
+
const optionsClone = isObject$1(raw_options) ? { ...raw_options } : raw_options;
|
|
727
753
|
cleanups.push(
|
|
728
|
-
...
|
|
729
|
-
|
|
730
|
-
|
|
754
|
+
...raw_targets.flatMap(
|
|
755
|
+
(el) => raw_events.flatMap(
|
|
756
|
+
(event) => raw_listeners.map((listener) => register(el, event, listener, optionsClone))
|
|
757
|
+
)
|
|
758
|
+
)
|
|
731
759
|
);
|
|
732
760
|
},
|
|
733
|
-
{
|
|
761
|
+
{ flush: "post" }
|
|
734
762
|
);
|
|
735
763
|
const stop = () => {
|
|
736
764
|
stopWatch();
|
|
737
765
|
cleanup();
|
|
738
766
|
};
|
|
739
|
-
tryOnScopeDispose(
|
|
767
|
+
tryOnScopeDispose$1(cleanup);
|
|
740
768
|
return stop;
|
|
741
769
|
}
|
|
742
770
|
function useMounted() {
|
|
743
|
-
const isMounted =
|
|
771
|
+
const isMounted = shallowRef(false);
|
|
744
772
|
const instance = getCurrentInstance();
|
|
745
773
|
if (instance) {
|
|
746
774
|
onMounted(() => {
|
|
@@ -760,7 +788,7 @@ function cloneFnJSON(source) {
|
|
|
760
788
|
return JSON.parse(JSON.stringify(source));
|
|
761
789
|
}
|
|
762
790
|
function useResizeObserver(target, callback, options = {}) {
|
|
763
|
-
const { window: window2 = defaultWindow, ...observerOptions } = options;
|
|
791
|
+
const { window: window2 = defaultWindow$1, ...observerOptions } = options;
|
|
764
792
|
let observer;
|
|
765
793
|
const isSupported = useSupported(() => window2 && "ResizeObserver" in window2);
|
|
766
794
|
const cleanup = () => {
|
|
@@ -770,8 +798,8 @@ function useResizeObserver(target, callback, options = {}) {
|
|
|
770
798
|
}
|
|
771
799
|
};
|
|
772
800
|
const targets = computed(() => {
|
|
773
|
-
const _targets = toValue(target);
|
|
774
|
-
return Array.isArray(_targets) ? _targets.map((el) => unrefElement(el)) : [unrefElement(_targets)];
|
|
801
|
+
const _targets = toValue$1(target);
|
|
802
|
+
return Array.isArray(_targets) ? _targets.map((el) => unrefElement$1(el)) : [unrefElement$1(_targets)];
|
|
775
803
|
});
|
|
776
804
|
const stopWatch = watch(
|
|
777
805
|
targets,
|
|
@@ -791,7 +819,7 @@ function useResizeObserver(target, callback, options = {}) {
|
|
|
791
819
|
cleanup();
|
|
792
820
|
stopWatch();
|
|
793
821
|
};
|
|
794
|
-
tryOnScopeDispose(stop);
|
|
822
|
+
tryOnScopeDispose$1(stop);
|
|
795
823
|
return {
|
|
796
824
|
isSupported,
|
|
797
825
|
stop
|
|
@@ -803,11 +831,22 @@ const DEFAULT_OPTIONS = {
|
|
|
803
831
|
reset: false,
|
|
804
832
|
directory: false
|
|
805
833
|
};
|
|
834
|
+
function prepareInitialFiles(files) {
|
|
835
|
+
if (!files)
|
|
836
|
+
return null;
|
|
837
|
+
if (files instanceof FileList)
|
|
838
|
+
return files;
|
|
839
|
+
const dt = new DataTransfer();
|
|
840
|
+
for (const file of files) {
|
|
841
|
+
dt.items.add(file);
|
|
842
|
+
}
|
|
843
|
+
return dt.files;
|
|
844
|
+
}
|
|
806
845
|
function useFileDialog(options = {}) {
|
|
807
846
|
const {
|
|
808
847
|
document: document2 = defaultDocument
|
|
809
848
|
} = options;
|
|
810
|
-
const files = ref(
|
|
849
|
+
const files = ref(prepareInitialFiles(options.initialFiles));
|
|
811
850
|
const { on: onChange, trigger: changeTrigger } = createEventHook();
|
|
812
851
|
const { on: onCancel, trigger: cancelTrigger } = createEventHook();
|
|
813
852
|
let input;
|
|
@@ -855,13 +894,21 @@ function useFileDialog(options = {}) {
|
|
|
855
894
|
onChange
|
|
856
895
|
};
|
|
857
896
|
}
|
|
858
|
-
function
|
|
897
|
+
function tryRequestAnimationFrame(window2 = defaultWindow$1, fn) {
|
|
898
|
+
if (window2 && typeof window2.requestAnimationFrame === "function") {
|
|
899
|
+
window2.requestAnimationFrame(fn);
|
|
900
|
+
} else {
|
|
901
|
+
fn();
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
function useTextareaAutosize(options = {}) {
|
|
859
905
|
var _a, _b;
|
|
906
|
+
const { window: window2 = defaultWindow$1 } = options;
|
|
860
907
|
const textarea = toRef(options == null ? void 0 : options.element);
|
|
861
908
|
const input = toRef((_a = options == null ? void 0 : options.input) != null ? _a : "");
|
|
862
909
|
const styleProp = (_b = options == null ? void 0 : options.styleProp) != null ? _b : "height";
|
|
863
|
-
const textareaScrollHeight =
|
|
864
|
-
const textareaOldWidth =
|
|
910
|
+
const textareaScrollHeight = shallowRef(1);
|
|
911
|
+
const textareaOldWidth = shallowRef(0);
|
|
865
912
|
function triggerResize() {
|
|
866
913
|
var _a2;
|
|
867
914
|
if (!textarea.value)
|
|
@@ -869,7 +916,7 @@ function useTextareaAutosize(options) {
|
|
|
869
916
|
let height = "";
|
|
870
917
|
textarea.value.style[styleProp] = "1px";
|
|
871
918
|
textareaScrollHeight.value = (_a2 = textarea.value) == null ? void 0 : _a2.scrollHeight;
|
|
872
|
-
const _styleTarget = toValue(options == null ? void 0 : options.styleTarget);
|
|
919
|
+
const _styleTarget = toValue$1(options == null ? void 0 : options.styleTarget);
|
|
873
920
|
if (_styleTarget)
|
|
874
921
|
_styleTarget.style[styleProp] = `${textareaScrollHeight.value}px`;
|
|
875
922
|
else
|
|
@@ -884,8 +931,10 @@ function useTextareaAutosize(options) {
|
|
|
884
931
|
useResizeObserver(textarea, ([{ contentRect }]) => {
|
|
885
932
|
if (textareaOldWidth.value === contentRect.width)
|
|
886
933
|
return;
|
|
887
|
-
|
|
888
|
-
|
|
934
|
+
tryRequestAnimationFrame(window2, () => {
|
|
935
|
+
textareaOldWidth.value = contentRect.width;
|
|
936
|
+
triggerResize();
|
|
937
|
+
});
|
|
889
938
|
});
|
|
890
939
|
if (options == null ? void 0 : options.watch)
|
|
891
940
|
watch(options.watch, triggerResize, { immediate: true, deep: true });
|
|
@@ -956,17 +1005,17 @@ function useVModel(props, key, emit, options = {}) {
|
|
|
956
1005
|
});
|
|
957
1006
|
}
|
|
958
1007
|
}
|
|
959
|
-
const _hoisted_1$
|
|
1008
|
+
const _hoisted_1$w = {
|
|
960
1009
|
key: 0,
|
|
961
1010
|
class: "v-input__start-adornment"
|
|
962
1011
|
};
|
|
963
|
-
const _hoisted_2$
|
|
1012
|
+
const _hoisted_2$9 = ["placeholder", "rows", "name"];
|
|
964
1013
|
const _hoisted_3$6 = ["placeholder", "type", "name"];
|
|
965
|
-
const _hoisted_4$
|
|
1014
|
+
const _hoisted_4$4 = {
|
|
966
1015
|
key: 3,
|
|
967
1016
|
class: "v-input__max-length"
|
|
968
1017
|
};
|
|
969
|
-
const _sfc_main$
|
|
1018
|
+
const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
970
1019
|
__name: "VInput",
|
|
971
1020
|
props: {
|
|
972
1021
|
modelValue: {},
|
|
@@ -1037,7 +1086,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
1037
1086
|
useTextareaAutosize({ element: inputRef, input: model });
|
|
1038
1087
|
}
|
|
1039
1088
|
return (_ctx, _cache) => {
|
|
1040
|
-
return openBlock(), createBlock(_sfc_main$
|
|
1089
|
+
return openBlock(), createBlock(_sfc_main$E, {
|
|
1041
1090
|
class: normalizeClass(["v-input", { large: _ctx.large, multiline: _ctx.multiline }]),
|
|
1042
1091
|
error: error.value,
|
|
1043
1092
|
label: _ctx.label,
|
|
@@ -1047,7 +1096,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
1047
1096
|
}, createSlots({
|
|
1048
1097
|
default: withCtx(() => [
|
|
1049
1098
|
renderSlot(_ctx.$slots, "start-adornment"),
|
|
1050
|
-
props.prefix ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
1099
|
+
props.prefix ? (openBlock(), createElementBlock("div", _hoisted_1$w, toDisplayString(props.prefix), 1)) : createCommentVNode("", true),
|
|
1051
1100
|
props.multiline ? withDirectives((openBlock(), createElementBlock("textarea", {
|
|
1052
1101
|
key: 1,
|
|
1053
1102
|
ref_key: "inputRef",
|
|
@@ -1057,7 +1106,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
1057
1106
|
rows: props.rows,
|
|
1058
1107
|
class: "scroll",
|
|
1059
1108
|
name: props.name
|
|
1060
|
-
}, null, 8, _hoisted_2$
|
|
1109
|
+
}, null, 8, _hoisted_2$9)), [
|
|
1061
1110
|
[vModelText, model.value]
|
|
1062
1111
|
]) : withDirectives((openBlock(), createElementBlock("input", {
|
|
1063
1112
|
key: 2,
|
|
@@ -1070,7 +1119,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
1070
1119
|
}, null, 8, _hoisted_3$6)), [
|
|
1071
1120
|
[vModelDynamic, model.value]
|
|
1072
1121
|
]),
|
|
1073
|
-
props.maxLength ? (openBlock(), createElementBlock("div", _hoisted_4$
|
|
1122
|
+
props.maxLength ? (openBlock(), createElementBlock("div", _hoisted_4$4, toDisplayString(model.value.length) + " / " + toDisplayString(props.maxLength), 1)) : createCommentVNode("", true),
|
|
1074
1123
|
renderSlot(_ctx.$slots, "end-adornment")
|
|
1075
1124
|
]),
|
|
1076
1125
|
_: 2
|
|
@@ -1086,16 +1135,16 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
1086
1135
|
};
|
|
1087
1136
|
}
|
|
1088
1137
|
});
|
|
1089
|
-
const _hoisted_1$
|
|
1090
|
-
const _hoisted_2$
|
|
1138
|
+
const _hoisted_1$v = { class: "blocks-list" };
|
|
1139
|
+
const _hoisted_2$8 = { class: "page-editor-blocks__group" };
|
|
1091
1140
|
const _hoisted_3$5 = { class: "title" };
|
|
1092
|
-
const _hoisted_4$
|
|
1141
|
+
const _hoisted_4$3 = { class: "blocks-list__blocks" };
|
|
1093
1142
|
const _hoisted_5$1 = ["onMousedown"];
|
|
1094
1143
|
const _hoisted_6$1 = {
|
|
1095
1144
|
key: 0,
|
|
1096
1145
|
class: "page-editor__nothing-found"
|
|
1097
1146
|
};
|
|
1098
|
-
const _sfc_main$
|
|
1147
|
+
const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
1099
1148
|
__name: "BlocksList",
|
|
1100
1149
|
props: {
|
|
1101
1150
|
blocks: {}
|
|
@@ -1115,6 +1164,11 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
1115
1164
|
blocks.sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
1116
1165
|
output.push({ name: groupName, blocks });
|
|
1117
1166
|
}
|
|
1167
|
+
output.sort((a, b) => {
|
|
1168
|
+
if (a.name === "default") return 1;
|
|
1169
|
+
if (b.name === "default") return -1;
|
|
1170
|
+
return a.name.localeCompare(b.name);
|
|
1171
|
+
});
|
|
1118
1172
|
return output;
|
|
1119
1173
|
});
|
|
1120
1174
|
const groupNames = {
|
|
@@ -1139,17 +1193,17 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
1139
1193
|
});
|
|
1140
1194
|
};
|
|
1141
1195
|
return (_ctx, _cache) => {
|
|
1142
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
1143
|
-
createVNode(_sfc_main$
|
|
1196
|
+
return openBlock(), createElementBlock("div", _hoisted_1$v, [
|
|
1197
|
+
createVNode(_sfc_main$D, {
|
|
1144
1198
|
modelValue: searchValue.value,
|
|
1145
1199
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchValue.value = $event),
|
|
1146
1200
|
placeholder: "Поиск...",
|
|
1147
1201
|
class: "page-editor-blocks__search"
|
|
1148
1202
|
}, null, 8, ["modelValue"]),
|
|
1149
1203
|
(openBlock(true), createElementBlock(Fragment, null, renderList(groupBlocks.value, (group) => {
|
|
1150
|
-
return openBlock(), createElementBlock("div", _hoisted_2$
|
|
1204
|
+
return openBlock(), createElementBlock("div", _hoisted_2$8, [
|
|
1151
1205
|
createElementVNode("div", _hoisted_3$5, toDisplayString(groupNames[group.name] ?? group.name), 1),
|
|
1152
|
-
createElementVNode("div", _hoisted_4$
|
|
1206
|
+
createElementVNode("div", _hoisted_4$3, [
|
|
1153
1207
|
(openBlock(true), createElementBlock(Fragment, null, renderList(group.blocks, (item) => {
|
|
1154
1208
|
return openBlock(), createElementBlock("button", {
|
|
1155
1209
|
class: "blocks-list__block editor-component",
|
|
@@ -1165,31 +1219,9 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
1165
1219
|
};
|
|
1166
1220
|
}
|
|
1167
1221
|
});
|
|
1168
|
-
const defaultImageSrc = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NCIgaGVpZ2h0PSI2NCIgZmlsbD0ibm9uZSI+PHJlY3Qgd2lkdGg9IjY0IiBoZWlnaHQ9IjY0IiBmaWxsPSIjRjJGMkYyIiByeD0iOCIvPjxwYXRoIGZpbGw9IiM2RDZENkQiIGQ9Ik00MS42IDE5LjZIMjIuNEE0LjQgNC40IDAgMCAwIDE4IDI0djE2YTQuNCA0LjQgMCAwIDAgNC40IDQuNGgxOS4yQTQuNCA0LjQgMCAwIDAgNDYgNDBWMjRhNC40IDQuNCAwIDAgMC00LjQtNC40TTIyLjQgMjJoMTkuMmEyIDIgMCAwIDEgMiAydjEzLjEwNGwtNC4zNTItNC4zNTJhMS4xMiAxLjEyIDAgMCAwLS44OTYtLjM1MiAxLjI4IDEuMjggMCAwIDAtLjg4LjQzMmwtMi4wNjQgMi40OC03LjM2LTcuMzZhMS4xMiAxLjEyIDAgMCAwLS44NDgtLjM1MiAxLjI4IDEuMjggMCAwIDAtLjg4LjQzMmwtNS45MiA3LjA1NlYyNGEyIDIgMCAwIDEgMi0ybS0yIDE4di0xLjE2OGw2Ljg4LTguMjU2IDYuNTkyIDYuNTkyLTQuMDMyIDQuOEgyMi40YTIgMiAwIDAgMS0yLTEuOTY4bTIxLjIgMmgtOC42NGw1LjUyLTYuNjI0IDUuMDQgNS4wNEExLjk3IDEuOTcgMCAwIDEgNDEuNiA0MiIvPjwvc3ZnPg==";
|
|
1169
|
-
const getDefaultValue = (schema) => {
|
|
1170
|
-
if (schema.default) return schema.default;
|
|
1171
|
-
if (schema.nullable) return null;
|
|
1172
|
-
if (schema.type === "object" && schema.format === "image") {
|
|
1173
|
-
return { src: defaultImageSrc, previewSrc: defaultImageSrc };
|
|
1174
|
-
}
|
|
1175
|
-
if (schema.type === "number" || schema.type === "integer") return 0;
|
|
1176
|
-
if (schema.type === "object") {
|
|
1177
|
-
if (!schema.properties) return {};
|
|
1178
|
-
return Object.fromEntries(Object.entries(schema.properties).map(([key, value]) => {
|
|
1179
|
-
var _a;
|
|
1180
|
-
if (!((_a = schema.required) == null ? void 0 : _a.includes(key))) {
|
|
1181
|
-
return [key, void 0];
|
|
1182
|
-
}
|
|
1183
|
-
return [key, getDefaultValue(value)];
|
|
1184
|
-
}));
|
|
1185
|
-
}
|
|
1186
|
-
if (schema.type === "array") return [];
|
|
1187
|
-
if (schema.type === "boolean") return false;
|
|
1188
|
-
return "";
|
|
1189
|
-
};
|
|
1190
1222
|
const processBlock = (contentBlock, schema) => {
|
|
1191
1223
|
if (!contentBlock.id) {
|
|
1192
|
-
contentBlock.id = uid();
|
|
1224
|
+
contentBlock.id = uid$1();
|
|
1193
1225
|
}
|
|
1194
1226
|
if (!contentBlock.data) {
|
|
1195
1227
|
contentBlock.data = {};
|
|
@@ -1398,7 +1430,7 @@ const getBlockIndex = (parent, target) => {
|
|
|
1398
1430
|
}
|
|
1399
1431
|
};
|
|
1400
1432
|
const createContentBlock = (block) => {
|
|
1401
|
-
const id = uid();
|
|
1433
|
+
const id = uid$1();
|
|
1402
1434
|
return processBlock({ id, blockId: block.id, data: {} }, block);
|
|
1403
1435
|
};
|
|
1404
1436
|
const insertBlockBefore = (block, contentBlocks, prependBlockId) => {
|
|
@@ -1436,17 +1468,17 @@ const onUpdateBlockChildren = (block) => {
|
|
|
1436
1468
|
}
|
|
1437
1469
|
};
|
|
1438
1470
|
const changeBlockId = (content, schema) => {
|
|
1439
|
-
content.id = uid();
|
|
1471
|
+
content.id = uid$1();
|
|
1440
1472
|
processBlock(content);
|
|
1441
1473
|
forEachChildren(schema, content, (contents) => {
|
|
1442
1474
|
for (let content2 of contents) {
|
|
1443
|
-
content2.id = uid();
|
|
1475
|
+
content2.id = uid$1();
|
|
1444
1476
|
processBlock(content2);
|
|
1445
1477
|
}
|
|
1446
1478
|
});
|
|
1447
1479
|
};
|
|
1448
1480
|
const createDevBlock = () => {
|
|
1449
|
-
const id = uid();
|
|
1481
|
+
const id = uid$1();
|
|
1450
1482
|
const style = `
|
|
1451
1483
|
min-width: 60px;
|
|
1452
1484
|
min-height: 60px;
|
|
@@ -1462,11 +1494,11 @@ const deleteFromArray = (arr, item) => {
|
|
|
1462
1494
|
arr.splice(index, 1);
|
|
1463
1495
|
return true;
|
|
1464
1496
|
};
|
|
1465
|
-
const uid = () => {
|
|
1497
|
+
const uid$1 = () => {
|
|
1466
1498
|
return Math.trunc(Math.random() * 1e5).toString(16);
|
|
1467
1499
|
};
|
|
1468
|
-
const _hoisted_1$
|
|
1469
|
-
const _sfc_main$
|
|
1500
|
+
const _hoisted_1$u = ["onClick"];
|
|
1501
|
+
const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
1470
1502
|
__name: "VTabs",
|
|
1471
1503
|
props: {
|
|
1472
1504
|
items: {},
|
|
@@ -1520,7 +1552,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
1520
1552
|
key: item.id,
|
|
1521
1553
|
class: normalizeClass(["v-tabs__tab", { active: unref(model) === item.id }]),
|
|
1522
1554
|
onClick: ($event) => model.value = item.id
|
|
1523
|
-
}, toDisplayString(item.title), 11, _hoisted_1$
|
|
1555
|
+
}, toDisplayString(item.title), 11, _hoisted_1$u);
|
|
1524
1556
|
}), 128))
|
|
1525
1557
|
]),
|
|
1526
1558
|
_: 1
|
|
@@ -1533,8 +1565,8 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
1533
1565
|
};
|
|
1534
1566
|
}
|
|
1535
1567
|
});
|
|
1536
|
-
const _hoisted_1$
|
|
1537
|
-
const _sfc_main$
|
|
1568
|
+
const _hoisted_1$t = { class: "v-tabs-pages" };
|
|
1569
|
+
const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
1538
1570
|
__name: "VTabsPages",
|
|
1539
1571
|
props: {
|
|
1540
1572
|
page: {},
|
|
@@ -1553,7 +1585,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
1553
1585
|
}
|
|
1554
1586
|
});
|
|
1555
1587
|
return (_ctx, _cache) => {
|
|
1556
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
1588
|
+
return openBlock(), createElementBlock("div", _hoisted_1$t, [
|
|
1557
1589
|
createVNode(Transition, { name: transitionClass.value }, {
|
|
1558
1590
|
default: withCtx(() => [
|
|
1559
1591
|
(openBlock(), createElementBlock("div", {
|
|
@@ -1569,16 +1601,16 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
1569
1601
|
};
|
|
1570
1602
|
}
|
|
1571
1603
|
});
|
|
1572
|
-
const _sfc_main$
|
|
1573
|
-
const _hoisted_1$
|
|
1604
|
+
const _sfc_main$z = {};
|
|
1605
|
+
const _hoisted_1$s = {
|
|
1574
1606
|
width: "20",
|
|
1575
1607
|
height: "20",
|
|
1576
1608
|
viewBox: "0 0 20 20",
|
|
1577
1609
|
fill: "none",
|
|
1578
1610
|
xmlns: "http://www.w3.org/2000/svg"
|
|
1579
1611
|
};
|
|
1580
|
-
function _sfc_render$
|
|
1581
|
-
return openBlock(), createElementBlock("svg", _hoisted_1$
|
|
1612
|
+
function _sfc_render$d(_ctx, _cache) {
|
|
1613
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$s, _cache[0] || (_cache[0] = [
|
|
1582
1614
|
createElementVNode("path", {
|
|
1583
1615
|
"fill-rule": "evenodd",
|
|
1584
1616
|
"clip-rule": "evenodd",
|
|
@@ -1587,8 +1619,8 @@ function _sfc_render$7(_ctx, _cache) {
|
|
|
1587
1619
|
}, null, -1)
|
|
1588
1620
|
]));
|
|
1589
1621
|
}
|
|
1590
|
-
const CollapseArrowIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1591
|
-
const _sfc_main$
|
|
1622
|
+
const CollapseArrowIcon = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["render", _sfc_render$d]]);
|
|
1623
|
+
const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
1592
1624
|
__name: "VCollapse",
|
|
1593
1625
|
props: {
|
|
1594
1626
|
open: { type: Boolean },
|
|
@@ -1635,7 +1667,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1635
1667
|
setOpen(value);
|
|
1636
1668
|
});
|
|
1637
1669
|
let mouseMove = false;
|
|
1638
|
-
useEventListener("mousedown", () => mouseMove = false);
|
|
1670
|
+
useEventListener$1("mousedown", () => mouseMove = false);
|
|
1639
1671
|
const onMouseEnter = (e) => {
|
|
1640
1672
|
if (e.buttons > 0 && !mouseMove && !document.body.classList.contains("mousedrag")) {
|
|
1641
1673
|
mouseMove = true;
|
|
@@ -1676,7 +1708,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1676
1708
|
}
|
|
1677
1709
|
});
|
|
1678
1710
|
const margin = 8;
|
|
1679
|
-
const _sfc_main$
|
|
1711
|
+
const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
1680
1712
|
...{
|
|
1681
1713
|
inheritAttrs: false
|
|
1682
1714
|
},
|
|
@@ -1699,7 +1731,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
1699
1731
|
const origin = ref("center");
|
|
1700
1732
|
const open = useVModel(props, "open", emit, { passive: true });
|
|
1701
1733
|
const activatorElement = ref();
|
|
1702
|
-
const
|
|
1734
|
+
const clamp2 = (value, min, max) => {
|
|
1703
1735
|
if (value < min) return min;
|
|
1704
1736
|
if (value > max) return max;
|
|
1705
1737
|
return value;
|
|
@@ -1712,12 +1744,12 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
1712
1744
|
return pos === "start" ? min : max - size;
|
|
1713
1745
|
};
|
|
1714
1746
|
const calcSub = (pos, start, end, size, min, max) => {
|
|
1715
|
-
if (pos === "start") return
|
|
1716
|
-
if (pos === "end") return
|
|
1717
|
-
return
|
|
1747
|
+
if (pos === "start") return clamp2(start, min, max - size);
|
|
1748
|
+
if (pos === "end") return clamp2(end - size, min, max - size);
|
|
1749
|
+
return clamp2((start + end) / 2 - size / 2, min, max - size);
|
|
1718
1750
|
};
|
|
1719
1751
|
const calcOrigin = (start, end, point) => {
|
|
1720
|
-
return
|
|
1752
|
+
return clamp2(Math.round((point - start) / (end - start) * 100), 0, 100) + "%";
|
|
1721
1753
|
};
|
|
1722
1754
|
const getRect = () => {
|
|
1723
1755
|
if (props.anchorPosition) {
|
|
@@ -1772,7 +1804,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
1772
1804
|
calcPosition();
|
|
1773
1805
|
});
|
|
1774
1806
|
useResizeObserver(popoverRef, calcPosition);
|
|
1775
|
-
useEventListener(window, "resize", calcPosition);
|
|
1807
|
+
useEventListener$1(window, "resize", calcPosition);
|
|
1776
1808
|
const close = () => {
|
|
1777
1809
|
open.value = false;
|
|
1778
1810
|
};
|
|
@@ -1844,55 +1876,55 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
1844
1876
|
};
|
|
1845
1877
|
}
|
|
1846
1878
|
});
|
|
1847
|
-
const _sfc_main$
|
|
1848
|
-
const _hoisted_1$
|
|
1879
|
+
const _sfc_main$w = {};
|
|
1880
|
+
const _hoisted_1$r = {
|
|
1849
1881
|
width: "16",
|
|
1850
1882
|
height: "16",
|
|
1851
1883
|
viewBox: "0 0 16 16",
|
|
1852
1884
|
fill: "none",
|
|
1853
1885
|
xmlns: "http://www.w3.org/2000/svg"
|
|
1854
1886
|
};
|
|
1855
|
-
function _sfc_render$
|
|
1856
|
-
return openBlock(), createElementBlock("svg", _hoisted_1$
|
|
1887
|
+
function _sfc_render$c(_ctx, _cache) {
|
|
1888
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$r, _cache[0] || (_cache[0] = [
|
|
1857
1889
|
createElementVNode("path", {
|
|
1858
1890
|
d: "M14.364 5.293C14.1764 5.10553 13.9221 5.00021 13.657 5.00021C13.3918 5.00021 13.1375 5.10553 12.95 5.293L7.99995 10.243L3.04995 5.293C2.86135 5.11084 2.60875 5.01005 2.34655 5.01232C2.08435 5.0146 1.83354 5.11977 1.64813 5.30518C1.46272 5.49059 1.35756 5.7414 1.35528 6.0036C1.353 6.26579 1.45379 6.5184 1.63595 6.707L7.29295 12.364C7.48048 12.5515 7.73479 12.6568 7.99995 12.6568C8.26512 12.6568 8.51942 12.5515 8.70695 12.364L14.364 6.707C14.5514 6.51947 14.6567 6.26516 14.6567 6C14.6567 5.73483 14.5514 5.48053 14.364 5.293Z",
|
|
1859
1891
|
fill: "currentColor"
|
|
1860
1892
|
}, null, -1)
|
|
1861
1893
|
]));
|
|
1862
1894
|
}
|
|
1863
|
-
const ArrowDownIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1864
|
-
const _sfc_main$
|
|
1865
|
-
const _hoisted_1$
|
|
1866
|
-
function _sfc_render$
|
|
1867
|
-
return openBlock(), createElementBlock("button", _hoisted_1$
|
|
1895
|
+
const ArrowDownIcon = /* @__PURE__ */ _export_sfc(_sfc_main$w, [["render", _sfc_render$c]]);
|
|
1896
|
+
const _sfc_main$v = {};
|
|
1897
|
+
const _hoisted_1$q = { class: "v-icon-button" };
|
|
1898
|
+
function _sfc_render$b(_ctx, _cache) {
|
|
1899
|
+
return openBlock(), createElementBlock("button", _hoisted_1$q, [
|
|
1868
1900
|
renderSlot(_ctx.$slots, "default")
|
|
1869
1901
|
]);
|
|
1870
1902
|
}
|
|
1871
|
-
const VIconButton = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1872
|
-
const _sfc_main$
|
|
1873
|
-
const _hoisted_1$
|
|
1903
|
+
const VIconButton = /* @__PURE__ */ _export_sfc(_sfc_main$v, [["render", _sfc_render$b]]);
|
|
1904
|
+
const _sfc_main$u = {};
|
|
1905
|
+
const _hoisted_1$p = {
|
|
1874
1906
|
width: "16",
|
|
1875
1907
|
height: "16",
|
|
1876
1908
|
viewBox: "0 0 16 16",
|
|
1877
1909
|
fill: "none",
|
|
1878
1910
|
xmlns: "http://www.w3.org/2000/svg"
|
|
1879
1911
|
};
|
|
1880
|
-
function _sfc_render$
|
|
1881
|
-
return openBlock(), createElementBlock("svg", _hoisted_1$
|
|
1912
|
+
function _sfc_render$a(_ctx, _cache) {
|
|
1913
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$p, _cache[0] || (_cache[0] = [
|
|
1882
1914
|
createElementVNode("path", {
|
|
1883
1915
|
d: "M9.31382 7.9L12.8488 4.364C12.9443 4.27176 13.0205 4.16141 13.0729 4.03941C13.1253 3.9174 13.1529 3.78618 13.1541 3.6534C13.1552 3.52062 13.1299 3.38894 13.0796 3.26605C13.0294 3.14315 12.9551 3.0315 12.8612 2.93761C12.7673 2.84371 12.6557 2.76946 12.5328 2.71918C12.4099 2.6689 12.2782 2.6436 12.1454 2.64475C12.0126 2.64591 11.8814 2.67349 11.7594 2.7259C11.6374 2.77831 11.5271 2.85449 11.4348 2.95L7.89882 6.485L4.36382 2.95C4.27157 2.85449 4.16123 2.77831 4.03922 2.7259C3.91722 2.67349 3.786 2.64591 3.65322 2.64475C3.52044 2.6436 3.38876 2.6689 3.26587 2.71918C3.14297 2.76946 3.03132 2.84371 2.93742 2.93761C2.84353 3.0315 2.76928 3.14315 2.719 3.26605C2.66872 3.38894 2.64342 3.52062 2.64457 3.6534C2.64572 3.78618 2.67331 3.9174 2.72572 4.03941C2.77813 4.16141 2.85431 4.27176 2.94982 4.364L6.48482 7.899L2.94982 11.435C2.85431 11.5273 2.77813 11.6376 2.72572 11.7596C2.67331 11.8816 2.64572 12.0128 2.64457 12.1456C2.64342 12.2784 2.66872 12.4101 2.719 12.533C2.76928 12.6559 2.84353 12.7675 2.93742 12.8614C3.03132 12.9553 3.14297 13.0295 3.26587 13.0798C3.38876 13.1301 3.52044 13.1554 3.65322 13.1543C3.786 13.1531 3.91722 13.1255 4.03922 13.0731C4.16123 13.0207 4.27157 12.9445 4.36382 12.849L7.89882 9.314L11.4348 12.849C11.5271 12.9445 11.6374 13.0207 11.7594 13.0731C11.8814 13.1255 12.0126 13.1531 12.1454 13.1543C12.2782 13.1554 12.4099 13.1301 12.5328 13.0798C12.6557 13.0295 12.7673 12.9553 12.8612 12.8614C12.9551 12.7675 13.0294 12.6559 13.0796 12.533C13.1299 12.4101 13.1552 12.2784 13.1541 12.1456C13.1529 12.0128 13.1253 11.8816 13.0729 11.7596C13.0205 11.6376 12.9443 11.5273 12.8488 11.435L9.31382 7.9Z",
|
|
1884
1916
|
fill: "currentColor"
|
|
1885
1917
|
}, null, -1)
|
|
1886
1918
|
]));
|
|
1887
1919
|
}
|
|
1888
|
-
const CloseMinIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1889
|
-
const _hoisted_1$
|
|
1890
|
-
const _hoisted_2$
|
|
1920
|
+
const CloseMinIcon = /* @__PURE__ */ _export_sfc(_sfc_main$u, [["render", _sfc_render$a]]);
|
|
1921
|
+
const _hoisted_1$o = { key: 0 };
|
|
1922
|
+
const _hoisted_2$7 = {
|
|
1891
1923
|
key: 1,
|
|
1892
1924
|
class: "v-select__placeholder"
|
|
1893
1925
|
};
|
|
1894
1926
|
const _hoisted_3$4 = { class: "v-select__actions" };
|
|
1895
|
-
const _hoisted_4$
|
|
1927
|
+
const _hoisted_4$2 = { class: "v-select__menu" };
|
|
1896
1928
|
const _hoisted_5 = {
|
|
1897
1929
|
key: 0,
|
|
1898
1930
|
class: "v-select__divider"
|
|
@@ -1902,7 +1934,7 @@ const _hoisted_6 = {
|
|
|
1902
1934
|
class: "group-title"
|
|
1903
1935
|
};
|
|
1904
1936
|
const _hoisted_7 = ["onClick"];
|
|
1905
|
-
const _sfc_main$
|
|
1937
|
+
const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
1906
1938
|
__name: "VSelect",
|
|
1907
1939
|
props: {
|
|
1908
1940
|
items: {},
|
|
@@ -1937,7 +1969,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
1937
1969
|
opened.value = false;
|
|
1938
1970
|
};
|
|
1939
1971
|
return (_ctx, _cache) => {
|
|
1940
|
-
return openBlock(), createBlock(_sfc_main$
|
|
1972
|
+
return openBlock(), createBlock(_sfc_main$E, {
|
|
1941
1973
|
outline: "",
|
|
1942
1974
|
class: "v-select",
|
|
1943
1975
|
label: props.label,
|
|
@@ -1946,7 +1978,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
1946
1978
|
required: props.required
|
|
1947
1979
|
}, {
|
|
1948
1980
|
default: withCtx(() => [
|
|
1949
|
-
createVNode(_sfc_main$
|
|
1981
|
+
createVNode(_sfc_main$x, {
|
|
1950
1982
|
open: opened.value,
|
|
1951
1983
|
"onUpdate:open": _cache[0] || (_cache[0] = ($event) => opened.value = $event),
|
|
1952
1984
|
placement: "bottom",
|
|
@@ -1957,7 +1989,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
1957
1989
|
createElementVNode("button", mergeProps({
|
|
1958
1990
|
class: ["v-select__activator", { opened: opened.value }]
|
|
1959
1991
|
}, activatorProps), [
|
|
1960
|
-
currentItem.value ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
1992
|
+
currentItem.value ? (openBlock(), createElementBlock("div", _hoisted_1$o, toDisplayString(currentItem.value.title), 1)) : (openBlock(), createElementBlock("div", _hoisted_2$7, toDisplayString(props.placeholder ?? "Выберите значение"), 1)),
|
|
1961
1993
|
createVNode(ArrowDownIcon)
|
|
1962
1994
|
], 16),
|
|
1963
1995
|
createElementVNode("div", _hoisted_3$4, [
|
|
@@ -1976,7 +2008,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
1976
2008
|
])
|
|
1977
2009
|
]),
|
|
1978
2010
|
default: withCtx(() => [
|
|
1979
|
-
createElementVNode("div", _hoisted_4$
|
|
2011
|
+
createElementVNode("div", _hoisted_4$2, [
|
|
1980
2012
|
(openBlock(true), createElementBlock(Fragment, null, renderList(items.value, (item) => {
|
|
1981
2013
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
1982
2014
|
item === "" ? (openBlock(), createElementBlock("div", _hoisted_5)) : typeof item === "string" ? (openBlock(), createElementBlock("div", _hoisted_6, toDisplayString(item), 1)) : (openBlock(), createElementBlock("button", {
|
|
@@ -2000,8 +2032,8 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
2000
2032
|
};
|
|
2001
2033
|
}
|
|
2002
2034
|
});
|
|
2003
|
-
const _hoisted_1$
|
|
2004
|
-
const _sfc_main$
|
|
2035
|
+
const _hoisted_1$n = { class: "json-editor__array" };
|
|
2036
|
+
const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
2005
2037
|
__name: "JsonEditorArray",
|
|
2006
2038
|
props: {
|
|
2007
2039
|
label: {},
|
|
@@ -2034,13 +2066,13 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
2034
2066
|
return `${props.label} (${length.value})`;
|
|
2035
2067
|
});
|
|
2036
2068
|
return (_ctx, _cache) => {
|
|
2037
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
2038
|
-
createVNode(_sfc_main$
|
|
2069
|
+
return openBlock(), createElementBlock("div", _hoisted_1$n, [
|
|
2070
|
+
createVNode(_sfc_main$y, {
|
|
2039
2071
|
label: label.value,
|
|
2040
2072
|
open: props.expanded
|
|
2041
2073
|
}, {
|
|
2042
2074
|
default: withCtx(() => [
|
|
2043
|
-
createVNode(_sfc_main$
|
|
2075
|
+
createVNode(_sfc_main$D, {
|
|
2044
2076
|
label: "Количество элементов",
|
|
2045
2077
|
modelValue: length.value,
|
|
2046
2078
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => length.value = $event),
|
|
@@ -2063,38 +2095,38 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
2063
2095
|
};
|
|
2064
2096
|
}
|
|
2065
2097
|
});
|
|
2066
|
-
const _sfc_main$
|
|
2067
|
-
const _hoisted_1$
|
|
2098
|
+
const _sfc_main$r = {};
|
|
2099
|
+
const _hoisted_1$m = {
|
|
2068
2100
|
width: "46",
|
|
2069
2101
|
height: "28",
|
|
2070
2102
|
viewBox: "0 0 46 28",
|
|
2071
2103
|
fill: "none",
|
|
2072
2104
|
xmlns: "http://www.w3.org/2000/svg"
|
|
2073
2105
|
};
|
|
2074
|
-
function _sfc_render$
|
|
2075
|
-
return openBlock(), createElementBlock("svg", _hoisted_1$
|
|
2106
|
+
function _sfc_render$9(_ctx, _cache) {
|
|
2107
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$m, _cache[0] || (_cache[0] = [
|
|
2076
2108
|
createStaticVNode('<mask id="mask0_1044_6" style="mask-type:luminance;" maskUnits="userSpaceOnUse" x="0" y="0" width="46" height="28"><path d="M45.5 0H0.5V28H45.5V0Z" fill="white"></path></mask><g mask="url(#mask0_1044_6)"><path d="M23.5 27.8537C35.9264 27.8537 46 25.6664 46 22.9683C46 20.2702 35.9264 18.083 23.5 18.083C11.0736 18.083 1 20.2702 1 22.9683C1 25.6664 11.0736 27.8537 23.5 27.8537Z" fill="#D7D7D7"></path><path d="M39.6719 9.5459L32.538 1.51859C32.1955 0.971432 31.6956 0.640625 31.169 0.640625H15.831C15.3044 0.640625 14.8045 0.971432 14.462 1.51789L7.32812 9.5466V15.9946H39.6719V9.5459Z" stroke="#A0A0A0" stroke-width="0.703125"></path><path d="M30.2591 11.7594C30.2591 10.6393 30.958 9.71457 31.825 9.71387H39.6719V22.3718C39.6719 23.8534 38.7437 25.0678 37.5977 25.0678H9.40234C8.25625 25.0678 7.32812 23.8527 7.32812 22.3718V9.71387H15.175C16.042 9.71387 16.7409 10.6372 16.7409 11.7573V11.7727C16.7409 12.8928 17.4475 13.7973 18.3138 13.7973H28.6862C29.5525 13.7973 30.2591 12.8845 30.2591 11.7643V11.7594Z" fill="#FAFAFA" stroke="#A0A0A0" stroke-width="0.703125"></path></g>', 2)
|
|
2077
2109
|
]));
|
|
2078
2110
|
}
|
|
2079
|
-
const EmptyFileIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2080
|
-
const _sfc_main$
|
|
2081
|
-
const _hoisted_1$
|
|
2111
|
+
const EmptyFileIcon = /* @__PURE__ */ _export_sfc(_sfc_main$r, [["render", _sfc_render$9]]);
|
|
2112
|
+
const _sfc_main$q = {};
|
|
2113
|
+
const _hoisted_1$l = {
|
|
2082
2114
|
width: "24",
|
|
2083
2115
|
height: "24",
|
|
2084
2116
|
viewBox: "0 0 24 24",
|
|
2085
2117
|
fill: "none",
|
|
2086
2118
|
xmlns: "http://www.w3.org/2000/svg"
|
|
2087
2119
|
};
|
|
2088
|
-
function _sfc_render$
|
|
2089
|
-
return openBlock(), createElementBlock("svg", _hoisted_1$
|
|
2120
|
+
function _sfc_render$8(_ctx, _cache) {
|
|
2121
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$l, _cache[0] || (_cache[0] = [
|
|
2090
2122
|
createElementVNode("path", {
|
|
2091
2123
|
d: "M14 18C14 18.5304 13.7893 19.0391 13.4142 19.4142C13.0391 19.7893 12.5304 20 12 20C11.4696 20 10.9609 19.7893 10.5858 19.4142C10.2107 19.0391 10 18.5304 10 18C10 17.4696 10.2107 16.9609 10.5858 16.5858C10.9609 16.2107 11.4696 16 12 16C12.5304 16 13.0391 16.2107 13.4142 16.5858C13.7893 16.9609 14 17.4696 14 18ZM14 12C14 12.5304 13.7893 13.0391 13.4142 13.4142C13.0391 13.7893 12.5304 14 12 14C11.4696 14 10.9609 13.7893 10.5858 13.4142C10.2107 13.0391 10 12.5304 10 12C10 11.4696 10.2107 10.9609 10.5858 10.5858C10.9609 10.2107 11.4696 10 12 10C12.5304 10 13.0391 10.2107 13.4142 10.5858C13.7893 10.9609 14 11.4696 14 12ZM12 8C12.5304 8 13.0391 7.78929 13.4142 7.41421C13.7893 7.03914 14 6.53043 14 6C14 5.46957 13.7893 4.96086 13.4142 4.58579C13.0391 4.21071 12.5304 4 12 4C11.4696 4 10.9609 4.21071 10.5858 4.58579C10.2107 4.96086 10 5.46957 10 6C10 6.53043 10.2107 7.03914 10.5858 7.41421C10.9609 7.78929 11.4696 8 12 8Z",
|
|
2092
2124
|
fill: "currentColor"
|
|
2093
2125
|
}, null, -1)
|
|
2094
2126
|
]));
|
|
2095
2127
|
}
|
|
2096
|
-
const MoreIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2097
|
-
const _sfc_main$
|
|
2128
|
+
const MoreIcon = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["render", _sfc_render$8]]);
|
|
2129
|
+
const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
2098
2130
|
__name: "VButton",
|
|
2099
2131
|
props: {
|
|
2100
2132
|
component: {},
|
|
@@ -2147,7 +2179,7 @@ const useContextMenu = (creator) => {
|
|
|
2147
2179
|
open
|
|
2148
2180
|
};
|
|
2149
2181
|
};
|
|
2150
|
-
const _sfc_main$
|
|
2182
|
+
const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
2151
2183
|
__name: "VContextMenu",
|
|
2152
2184
|
props: {
|
|
2153
2185
|
open: { type: Boolean },
|
|
@@ -2187,7 +2219,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2187
2219
|
return (_ctx, _cache) => {
|
|
2188
2220
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
2189
2221
|
renderSlot(_ctx.$slots, "activator", { props: activatorProps }),
|
|
2190
|
-
createVNode(_sfc_main$
|
|
2222
|
+
createVNode(_sfc_main$x, {
|
|
2191
2223
|
open: unref(open),
|
|
2192
2224
|
"onUpdate:open": _cache[0] || (_cache[0] = ($event) => isRef(open) ? open.value = $event : null),
|
|
2193
2225
|
element: activatorElement.value,
|
|
@@ -2198,7 +2230,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2198
2230
|
}, {
|
|
2199
2231
|
default: withCtx(() => [
|
|
2200
2232
|
(openBlock(true), createElementBlock(Fragment, null, renderList(items.value, (item) => {
|
|
2201
|
-
return openBlock(), createBlock(_sfc_main$
|
|
2233
|
+
return openBlock(), createBlock(_sfc_main$p, mergeProps({ ref_for: true }, item.props, {
|
|
2202
2234
|
class: "v-context-menu__item",
|
|
2203
2235
|
onClick: ($event) => onItemClick(item)
|
|
2204
2236
|
}), {
|
|
@@ -2239,7 +2271,7 @@ const createDialogSystem = () => {
|
|
|
2239
2271
|
};
|
|
2240
2272
|
};
|
|
2241
2273
|
const useDialog = () => inject("dialogStore");
|
|
2242
|
-
const _sfc_main$
|
|
2274
|
+
const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
2243
2275
|
__name: "VDialogProvider",
|
|
2244
2276
|
setup(__props) {
|
|
2245
2277
|
const dialogStore = inject("dialogStore");
|
|
@@ -2283,9 +2315,8 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
2283
2315
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(dialogStore).dialogHistory, (dialog, index) => {
|
|
2284
2316
|
return withDirectives((openBlock(), createBlock(resolveDynamicComponent(dialog.dialog), mergeProps({
|
|
2285
2317
|
class: "bd-scale scroll",
|
|
2286
|
-
role: "dialog"
|
|
2287
|
-
|
|
2288
|
-
}, dialog.props), null, 16)), [
|
|
2318
|
+
role: "dialog"
|
|
2319
|
+
}, { ref_for: true }, dialog.props), null, 16)), [
|
|
2289
2320
|
[vShow, index === unref(dialogStore).dialogHistory.length - 1]
|
|
2290
2321
|
]);
|
|
2291
2322
|
}), 256))
|
|
@@ -2297,60 +2328,64 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
2297
2328
|
};
|
|
2298
2329
|
}
|
|
2299
2330
|
});
|
|
2300
|
-
const _hoisted_1$
|
|
2301
|
-
class: "v-dialog scroll editor-component",
|
|
2302
|
-
role: "dialog"
|
|
2303
|
-
};
|
|
2304
|
-
const _hoisted_2$5 = {
|
|
2331
|
+
const _hoisted_1$k = {
|
|
2305
2332
|
key: 0,
|
|
2306
2333
|
class: "v-dialog__header heading"
|
|
2307
2334
|
};
|
|
2308
|
-
const
|
|
2335
|
+
const _hoisted_2$6 = {
|
|
2309
2336
|
key: 1,
|
|
2310
2337
|
class: "v-dialog__actions"
|
|
2311
2338
|
};
|
|
2312
|
-
const _sfc_main$
|
|
2339
|
+
const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
2313
2340
|
__name: "VDialog",
|
|
2314
2341
|
props: {
|
|
2315
|
-
"content:class": {}
|
|
2342
|
+
"content:class": {},
|
|
2343
|
+
component: {}
|
|
2316
2344
|
},
|
|
2317
2345
|
setup(__props) {
|
|
2318
2346
|
const slots = useSlots();
|
|
2319
2347
|
const props = __props;
|
|
2320
2348
|
const dialog = useDialog();
|
|
2321
2349
|
return (_ctx, _cache) => {
|
|
2322
|
-
return openBlock(),
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2350
|
+
return openBlock(), createBlock(resolveDynamicComponent(props.component ?? "div"), {
|
|
2351
|
+
class: "v-dialog scroll editor-component",
|
|
2352
|
+
role: "dialog"
|
|
2353
|
+
}, {
|
|
2354
|
+
default: withCtx(() => [
|
|
2355
|
+
unref(slots).header ? (openBlock(), createElementBlock("div", _hoisted_1$k, [
|
|
2356
|
+
renderSlot(_ctx.$slots, "header"),
|
|
2357
|
+
createVNode(VIconButton, {
|
|
2358
|
+
role: "button",
|
|
2359
|
+
class: "close-icon",
|
|
2360
|
+
onClick: unref(dialog).close
|
|
2361
|
+
}, {
|
|
2362
|
+
default: withCtx(() => [
|
|
2363
|
+
createVNode(CloseMinIcon)
|
|
2364
|
+
]),
|
|
2365
|
+
_: 1
|
|
2366
|
+
}, 8, ["onClick"])
|
|
2367
|
+
])) : createCommentVNode("", true),
|
|
2368
|
+
createElementVNode("div", {
|
|
2369
|
+
class: normalizeClass(["v-dialog__content", [props["content:class"], unref(slots).actions ? "" : "bottom-padding"]])
|
|
2370
|
+
}, [
|
|
2371
|
+
renderSlot(_ctx.$slots, "default")
|
|
2372
|
+
], 2),
|
|
2373
|
+
unref(slots).actions ? (openBlock(), createElementBlock("div", _hoisted_2$6, [
|
|
2374
|
+
renderSlot(_ctx.$slots, "actions")
|
|
2375
|
+
])) : createCommentVNode("", true)
|
|
2376
|
+
]),
|
|
2377
|
+
_: 3
|
|
2378
|
+
});
|
|
2344
2379
|
};
|
|
2345
2380
|
}
|
|
2346
2381
|
});
|
|
2347
|
-
const _hoisted_1$
|
|
2382
|
+
const _hoisted_1$j = {
|
|
2348
2383
|
key: 0,
|
|
2349
2384
|
class: "project-images__grid"
|
|
2350
2385
|
};
|
|
2351
|
-
const _hoisted_2$
|
|
2352
|
-
const _hoisted_3$
|
|
2353
|
-
const _sfc_main$
|
|
2386
|
+
const _hoisted_2$5 = ["onClick"];
|
|
2387
|
+
const _hoisted_3$3 = ["src"];
|
|
2388
|
+
const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
2354
2389
|
__name: "ProjectImagesDialog",
|
|
2355
2390
|
props: {
|
|
2356
2391
|
fileRequest: { type: Function },
|
|
@@ -2365,20 +2400,20 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
2365
2400
|
dialog.back();
|
|
2366
2401
|
};
|
|
2367
2402
|
return (_ctx, _cache) => {
|
|
2368
|
-
return openBlock(), createBlock(_sfc_main$
|
|
2403
|
+
return openBlock(), createBlock(_sfc_main$m, { style: { "width": "900px" } }, {
|
|
2369
2404
|
header: withCtx(() => _cache[0] || (_cache[0] = [
|
|
2370
2405
|
createTextVNode("Изображения проекта")
|
|
2371
2406
|
])),
|
|
2372
2407
|
default: withCtx(() => [
|
|
2373
|
-
unref(data) ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
2408
|
+
unref(data) ? (openBlock(), createElementBlock("div", _hoisted_1$j, [
|
|
2374
2409
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(data), (item) => {
|
|
2375
2410
|
return openBlock(), createElementBlock("button", {
|
|
2376
2411
|
onClick: ($event) => openImage(item)
|
|
2377
2412
|
}, [
|
|
2378
2413
|
createElementVNode("img", {
|
|
2379
2414
|
src: item.previewSrc ?? item.src
|
|
2380
|
-
}, null, 8, _hoisted_3$
|
|
2381
|
-
], 8, _hoisted_2$
|
|
2415
|
+
}, null, 8, _hoisted_3$3)
|
|
2416
|
+
], 8, _hoisted_2$5);
|
|
2382
2417
|
}), 256))
|
|
2383
2418
|
])) : createCommentVNode("", true)
|
|
2384
2419
|
]),
|
|
@@ -2387,14 +2422,14 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
2387
2422
|
};
|
|
2388
2423
|
}
|
|
2389
2424
|
});
|
|
2390
|
-
const _hoisted_1$
|
|
2425
|
+
const _hoisted_1$i = {
|
|
2391
2426
|
key: 0,
|
|
2392
2427
|
class: "v-image-uploader__drag-label"
|
|
2393
2428
|
};
|
|
2394
|
-
const _hoisted_2$
|
|
2395
|
-
const _hoisted_3$
|
|
2396
|
-
const _hoisted_4 = { class: "v-image-uploader__image-info" };
|
|
2397
|
-
const _sfc_main$
|
|
2429
|
+
const _hoisted_2$4 = { class: "v-image-uploader__image-preview" };
|
|
2430
|
+
const _hoisted_3$2 = ["src"];
|
|
2431
|
+
const _hoisted_4$1 = { class: "v-image-uploader__image-info" };
|
|
2432
|
+
const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
2398
2433
|
__name: "VImageUploader",
|
|
2399
2434
|
props: {
|
|
2400
2435
|
accept: {},
|
|
@@ -2452,7 +2487,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
2452
2487
|
fileDialog.reset();
|
|
2453
2488
|
});
|
|
2454
2489
|
const removeImage = () => {
|
|
2455
|
-
emit("update:modelValue", getDefaultValue(props.schema));
|
|
2490
|
+
emit("update:modelValue", getDefaultValue(props.schema ?? { type: "object", format: "image" }));
|
|
2456
2491
|
};
|
|
2457
2492
|
const dialog = useDialog();
|
|
2458
2493
|
const contextMenuItems = [];
|
|
@@ -2460,10 +2495,10 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
2460
2495
|
emit("update:modelValue", image);
|
|
2461
2496
|
};
|
|
2462
2497
|
if (fileRequest) {
|
|
2463
|
-
contextMenuItems.push({ title: "Выбрать из файлов проекта", onClick: () => dialog.open(_sfc_main$
|
|
2498
|
+
contextMenuItems.push({ title: "Выбрать из файлов проекта", onClick: () => dialog.open(_sfc_main$l, { fileRequest, onOpenImage }) });
|
|
2464
2499
|
}
|
|
2465
2500
|
return (_ctx, _cache) => {
|
|
2466
|
-
return openBlock(), createBlock(_sfc_main$
|
|
2501
|
+
return openBlock(), createBlock(_sfc_main$E, {
|
|
2467
2502
|
class: normalizeClass(["v-image-uploader", { drag: drag.value }]),
|
|
2468
2503
|
error: _ctx.error,
|
|
2469
2504
|
label: _ctx.label,
|
|
@@ -2475,7 +2510,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
2475
2510
|
onDragleave: onDragLeave
|
|
2476
2511
|
}, {
|
|
2477
2512
|
default: withCtx(() => [
|
|
2478
|
-
drag.value ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
2513
|
+
drag.value ? (openBlock(), createElementBlock("div", _hoisted_1$i, "Отпустите файл здесь")) : !props.modelValue || props.modelValue.src === unref(defaultImageSrc) ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
2479
2514
|
createVNode(EmptyFileIcon),
|
|
2480
2515
|
createElementVNode("div", null, [
|
|
2481
2516
|
createElementVNode("a", {
|
|
@@ -2483,7 +2518,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
2483
2518
|
}, "Загрузите изображение"),
|
|
2484
2519
|
_cache[1] || (_cache[1] = createElementVNode("br", null, null, -1)),
|
|
2485
2520
|
_cache[2] || (_cache[2] = createTextVNode("или перетащите сюда ")),
|
|
2486
|
-
contextMenuItems.length > 0 ? (openBlock(), createBlock(_sfc_main$
|
|
2521
|
+
contextMenuItems.length > 0 ? (openBlock(), createBlock(_sfc_main$o, {
|
|
2487
2522
|
key: 0,
|
|
2488
2523
|
items: contextMenuItems,
|
|
2489
2524
|
placement: "bottom-end"
|
|
@@ -2500,11 +2535,11 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
2500
2535
|
})) : createCommentVNode("", true)
|
|
2501
2536
|
])
|
|
2502
2537
|
], 64)) : (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
2503
|
-
createElementVNode("div", _hoisted_2$
|
|
2538
|
+
createElementVNode("div", _hoisted_2$4, [
|
|
2504
2539
|
createElementVNode("img", {
|
|
2505
2540
|
src: props.modelValue.previewSrc ?? props.modelValue.src,
|
|
2506
2541
|
alt: "Preview Image"
|
|
2507
|
-
}, null, 8, _hoisted_3$
|
|
2542
|
+
}, null, 8, _hoisted_3$2),
|
|
2508
2543
|
createVNode(VIconButton, {
|
|
2509
2544
|
class: "v-image-uploader__delete-button",
|
|
2510
2545
|
onClick: removeImage
|
|
@@ -2515,7 +2550,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
2515
2550
|
_: 1
|
|
2516
2551
|
})
|
|
2517
2552
|
]),
|
|
2518
|
-
createElementVNode("div", _hoisted_4, [
|
|
2553
|
+
createElementVNode("div", _hoisted_4$1, [
|
|
2519
2554
|
createElementVNode("div", null, toDisplayString(props.modelValue.name), 1)
|
|
2520
2555
|
])
|
|
2521
2556
|
], 64))
|
|
@@ -2525,33 +2560,33 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
2525
2560
|
};
|
|
2526
2561
|
}
|
|
2527
2562
|
});
|
|
2528
|
-
const _sfc_main$
|
|
2529
|
-
const _hoisted_1$
|
|
2563
|
+
const _sfc_main$j = {};
|
|
2564
|
+
const _hoisted_1$h = {
|
|
2530
2565
|
width: "18",
|
|
2531
2566
|
height: "18",
|
|
2532
2567
|
viewBox: "0 0 18 18",
|
|
2533
2568
|
fill: "none",
|
|
2534
2569
|
xmlns: "http://www.w3.org/2000/svg"
|
|
2535
2570
|
};
|
|
2536
|
-
function _sfc_render$
|
|
2537
|
-
return openBlock(), createElementBlock("svg", _hoisted_1$
|
|
2571
|
+
function _sfc_render$7(_ctx, _cache) {
|
|
2572
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$h, _cache[0] || (_cache[0] = [
|
|
2538
2573
|
createElementVNode("path", {
|
|
2539
2574
|
d: "M14.0326 5.40749C13.9629 5.33719 13.8799 5.28139 13.7885 5.24332C13.6971 5.20524 13.5991 5.18564 13.5001 5.18564C13.4011 5.18564 13.303 5.20524 13.2117 5.24332C13.1203 5.28139 13.0373 5.33719 12.9676 5.40749L7.38008 11.0025L5.03258 8.64749C4.96019 8.57756 4.87474 8.52257 4.7811 8.48567C4.68745 8.44877 4.58746 8.43067 4.48683 8.43241C4.38619 8.43415 4.28688 8.4557 4.19457 8.49582C4.10227 8.53594 4.01876 8.59385 3.94883 8.66624C3.87891 8.73863 3.82392 8.82408 3.78702 8.91773C3.75011 9.01137 3.73202 9.11136 3.73376 9.212C3.7355 9.31263 3.75704 9.41194 3.79716 9.50425C3.83728 9.59656 3.89519 9.68006 3.96758 9.74999L6.84758 12.63C6.91731 12.7003 7.00026 12.7561 7.09165 12.7942C7.18305 12.8322 7.28108 12.8518 7.38008 12.8518C7.47909 12.8518 7.57712 12.8322 7.66852 12.7942C7.75991 12.7561 7.84286 12.7003 7.91258 12.63L14.0326 6.50999C14.1087 6.43976 14.1695 6.35452 14.211 6.25964C14.2526 6.16477 14.274 6.06231 14.274 5.95874C14.274 5.85516 14.2526 5.75271 14.211 5.65783C14.1695 5.56296 14.1087 5.47772 14.0326 5.40749Z",
|
|
2540
2575
|
fill: "currentColor"
|
|
2541
2576
|
}, null, -1)
|
|
2542
2577
|
]));
|
|
2543
2578
|
}
|
|
2544
|
-
const CheckIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2545
|
-
const _hoisted_1$
|
|
2579
|
+
const CheckIcon = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$7]]);
|
|
2580
|
+
const _hoisted_1$g = {
|
|
2546
2581
|
key: 0,
|
|
2547
2582
|
class: "v-checkbox__label left"
|
|
2548
2583
|
};
|
|
2549
|
-
const _hoisted_2$
|
|
2550
|
-
const _hoisted_3 = {
|
|
2584
|
+
const _hoisted_2$3 = ["name"];
|
|
2585
|
+
const _hoisted_3$1 = {
|
|
2551
2586
|
key: 1,
|
|
2552
2587
|
class: "v-checkbox__label"
|
|
2553
2588
|
};
|
|
2554
|
-
const _sfc_main$
|
|
2589
|
+
const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
2555
2590
|
__name: "VCheckbox",
|
|
2556
2591
|
props: /* @__PURE__ */ mergeModels({
|
|
2557
2592
|
label: {},
|
|
@@ -2583,7 +2618,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
2583
2618
|
onClick,
|
|
2584
2619
|
onKeydown: onClick
|
|
2585
2620
|
}, [
|
|
2586
|
-
labelPosition.value === "left" ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
2621
|
+
labelPosition.value === "left" ? (openBlock(), createElementBlock("div", _hoisted_1$g, [
|
|
2587
2622
|
renderSlot(_ctx.$slots, "label", {}, () => [
|
|
2588
2623
|
createTextVNode(toDisplayString(props.label), 1)
|
|
2589
2624
|
])
|
|
@@ -2597,10 +2632,10 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
2597
2632
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
|
|
2598
2633
|
type: "checkbox",
|
|
2599
2634
|
name: props.name
|
|
2600
|
-
}, null, 8, _hoisted_2$
|
|
2635
|
+
}, null, 8, _hoisted_2$3), [
|
|
2601
2636
|
[vModelCheckbox, model.value]
|
|
2602
2637
|
]),
|
|
2603
|
-
labelPosition.value === "right" ? (openBlock(), createElementBlock("div", _hoisted_3, [
|
|
2638
|
+
labelPosition.value === "right" ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
|
|
2604
2639
|
renderSlot(_ctx.$slots, "label", {}, () => [
|
|
2605
2640
|
createTextVNode(toDisplayString(props.label), 1)
|
|
2606
2641
|
])
|
|
@@ -2620,16 +2655,16 @@ const capitalize = (text) => {
|
|
|
2620
2655
|
const spaceCamelCase = (str) => {
|
|
2621
2656
|
return capitalize(str.replace(/([A-Z])/g, " $1").trimStart());
|
|
2622
2657
|
};
|
|
2623
|
-
const _sfc_main$
|
|
2624
|
-
const _hoisted_1$
|
|
2658
|
+
const _sfc_main$h = {};
|
|
2659
|
+
const _hoisted_1$f = {
|
|
2625
2660
|
width: "24",
|
|
2626
2661
|
height: "24",
|
|
2627
2662
|
viewBox: "0 0 24 24",
|
|
2628
2663
|
fill: "none",
|
|
2629
2664
|
xmlns: "http://www.w3.org/2000/svg"
|
|
2630
2665
|
};
|
|
2631
|
-
function _sfc_render(_ctx, _cache) {
|
|
2632
|
-
return openBlock(), createElementBlock("svg", _hoisted_1$
|
|
2666
|
+
function _sfc_render$6(_ctx, _cache) {
|
|
2667
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$f, _cache[0] || (_cache[0] = [
|
|
2633
2668
|
createElementVNode("path", {
|
|
2634
2669
|
"fill-rule": "evenodd",
|
|
2635
2670
|
"clip-rule": "evenodd",
|
|
@@ -2638,9 +2673,9 @@ function _sfc_render(_ctx, _cache) {
|
|
|
2638
2673
|
}, null, -1)
|
|
2639
2674
|
]));
|
|
2640
2675
|
}
|
|
2641
|
-
const EditIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2642
|
-
const _hoisted_1$
|
|
2643
|
-
const _sfc_main$
|
|
2676
|
+
const EditIcon = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$6]]);
|
|
2677
|
+
const _hoisted_1$e = { class: "v-link-editor__custom" };
|
|
2678
|
+
const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
2644
2679
|
__name: "VLinkEditor",
|
|
2645
2680
|
props: /* @__PURE__ */ mergeModels({
|
|
2646
2681
|
nullable: { type: Boolean }
|
|
@@ -2670,7 +2705,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
2670
2705
|
return;
|
|
2671
2706
|
}
|
|
2672
2707
|
if (type === "_externalNew") {
|
|
2673
|
-
model.value = { id: "_external", url: "", title: "" };
|
|
2708
|
+
model.value = { id: "_external", url: "", title: "", external: true };
|
|
2674
2709
|
nextTick(() => {
|
|
2675
2710
|
const editButton = (current == null ? void 0 : current.vnode.el).querySelector(".edit-button");
|
|
2676
2711
|
editButton == null ? void 0 : editButton.dispatchEvent(new MouseEvent("mousedown"));
|
|
@@ -2695,7 +2730,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
2695
2730
|
return arr;
|
|
2696
2731
|
});
|
|
2697
2732
|
return (_ctx, _cache) => {
|
|
2698
|
-
return openBlock(), createBlock(_sfc_main$
|
|
2733
|
+
return openBlock(), createBlock(_sfc_main$t, {
|
|
2699
2734
|
class: "v-link-editor",
|
|
2700
2735
|
modelValue: linkType.value,
|
|
2701
2736
|
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => linkType.value = $event),
|
|
@@ -2703,7 +2738,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
2703
2738
|
nullable: props.nullable
|
|
2704
2739
|
}, {
|
|
2705
2740
|
default: withCtx(() => [
|
|
2706
|
-
model.value && model.value.id ? (openBlock(), createBlock(_sfc_main$
|
|
2741
|
+
model.value && model.value.id ? (openBlock(), createBlock(_sfc_main$x, {
|
|
2707
2742
|
key: 0,
|
|
2708
2743
|
offset: 4,
|
|
2709
2744
|
placement: "bottom-end"
|
|
@@ -2719,27 +2754,27 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
2719
2754
|
default: withCtx(() => {
|
|
2720
2755
|
var _a;
|
|
2721
2756
|
return [
|
|
2722
|
-
createElementVNode("div", _hoisted_1$
|
|
2723
|
-
model.value.id === "_external" ? (openBlock(), createBlock(_sfc_main$
|
|
2757
|
+
createElementVNode("div", _hoisted_1$e, [
|
|
2758
|
+
model.value.id === "_external" ? (openBlock(), createBlock(_sfc_main$D, {
|
|
2724
2759
|
key: 0,
|
|
2725
2760
|
modelValue: model.value.url,
|
|
2726
2761
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value.url = $event),
|
|
2727
2762
|
label: "URL ссылки",
|
|
2728
2763
|
autofocus: ""
|
|
2729
2764
|
}, null, 8, ["modelValue"])) : createCommentVNode("", true),
|
|
2730
|
-
model.value.id !== "_external" ? (openBlock(), createBlock(_sfc_main$
|
|
2765
|
+
model.value.id !== "_external" ? (openBlock(), createBlock(_sfc_main$D, {
|
|
2731
2766
|
key: 1,
|
|
2732
2767
|
modelValue: model.value.query,
|
|
2733
2768
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => model.value.query = $event),
|
|
2734
2769
|
label: "Якорь",
|
|
2735
2770
|
prefix: (_a = model.value) == null ? void 0 : _a.url
|
|
2736
2771
|
}, null, 8, ["modelValue", "prefix"])) : createCommentVNode("", true),
|
|
2737
|
-
createVNode(_sfc_main$
|
|
2772
|
+
createVNode(_sfc_main$D, {
|
|
2738
2773
|
modelValue: model.value.title,
|
|
2739
2774
|
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => model.value.title = $event),
|
|
2740
2775
|
label: "Заголовок"
|
|
2741
2776
|
}, null, 8, ["modelValue"]),
|
|
2742
|
-
createVNode(_sfc_main$
|
|
2777
|
+
createVNode(_sfc_main$i, {
|
|
2743
2778
|
modelValue: model.value.openNewTab,
|
|
2744
2779
|
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => model.value.openNewTab = $event),
|
|
2745
2780
|
label: "Открывать в новой вкладке"
|
|
@@ -2755,57 +2790,1663 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
2755
2790
|
};
|
|
2756
2791
|
}
|
|
2757
2792
|
});
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2793
|
+
var __defProp = Object.defineProperty;
|
|
2794
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2795
|
+
var __publicField = (obj, key, value) => {
|
|
2796
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2797
|
+
return value;
|
|
2761
2798
|
};
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2799
|
+
function tryOnScopeDispose(fn) {
|
|
2800
|
+
if (getCurrentScope()) {
|
|
2801
|
+
onScopeDispose(fn);
|
|
2802
|
+
return true;
|
|
2803
|
+
}
|
|
2804
|
+
return false;
|
|
2805
|
+
}
|
|
2806
|
+
function toValue(r) {
|
|
2807
|
+
return typeof r === "function" ? r() : unref(r);
|
|
2808
|
+
}
|
|
2809
|
+
const isClient = typeof window !== "undefined" && typeof document !== "undefined";
|
|
2810
|
+
typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
|
|
2811
|
+
const toString = Object.prototype.toString;
|
|
2812
|
+
const isObject = (val) => toString.call(val) === "[object Object]";
|
|
2813
|
+
const noop = () => {
|
|
2814
|
+
};
|
|
2815
|
+
function unrefElement(elRef) {
|
|
2816
|
+
var _a;
|
|
2817
|
+
const plain = toValue(elRef);
|
|
2818
|
+
return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
|
|
2819
|
+
}
|
|
2820
|
+
const defaultWindow = isClient ? window : void 0;
|
|
2821
|
+
function useEventListener(...args) {
|
|
2822
|
+
let target;
|
|
2823
|
+
let events2;
|
|
2824
|
+
let listeners2;
|
|
2825
|
+
let options;
|
|
2826
|
+
if (typeof args[0] === "string" || Array.isArray(args[0])) {
|
|
2827
|
+
[events2, listeners2, options] = args;
|
|
2828
|
+
target = defaultWindow;
|
|
2829
|
+
} else {
|
|
2830
|
+
[target, events2, listeners2, options] = args;
|
|
2831
|
+
}
|
|
2832
|
+
if (!target)
|
|
2833
|
+
return noop;
|
|
2834
|
+
if (!Array.isArray(events2))
|
|
2835
|
+
events2 = [events2];
|
|
2836
|
+
if (!Array.isArray(listeners2))
|
|
2837
|
+
listeners2 = [listeners2];
|
|
2838
|
+
const cleanups = [];
|
|
2839
|
+
const cleanup = () => {
|
|
2840
|
+
cleanups.forEach((fn) => fn());
|
|
2841
|
+
cleanups.length = 0;
|
|
2842
|
+
};
|
|
2843
|
+
const register = (el, event, listener, options2) => {
|
|
2844
|
+
el.addEventListener(event, listener, options2);
|
|
2845
|
+
return () => el.removeEventListener(event, listener, options2);
|
|
2846
|
+
};
|
|
2847
|
+
const stopWatch = watch(
|
|
2848
|
+
() => [unrefElement(target), toValue(options)],
|
|
2849
|
+
([el, options2]) => {
|
|
2850
|
+
cleanup();
|
|
2851
|
+
if (!el)
|
|
2852
|
+
return;
|
|
2853
|
+
const optionsClone = isObject(options2) ? { ...options2 } : options2;
|
|
2854
|
+
cleanups.push(
|
|
2855
|
+
...events2.flatMap((event) => {
|
|
2856
|
+
return listeners2.map((listener) => register(el, event, listener, optionsClone));
|
|
2857
|
+
})
|
|
2858
|
+
);
|
|
2859
|
+
},
|
|
2860
|
+
{ immediate: true, flush: "post" }
|
|
2861
|
+
);
|
|
2862
|
+
const stop = () => {
|
|
2863
|
+
stopWatch();
|
|
2864
|
+
cleanup();
|
|
2865
|
+
};
|
|
2866
|
+
tryOnScopeDispose(stop);
|
|
2867
|
+
return stop;
|
|
2868
|
+
}
|
|
2869
|
+
const findParent = (el, callback) => {
|
|
2870
|
+
if (!el)
|
|
2871
|
+
return null;
|
|
2872
|
+
if (el.nodeType === Node.ELEMENT_NODE) {
|
|
2873
|
+
if (callback(el))
|
|
2874
|
+
return el;
|
|
2875
|
+
}
|
|
2876
|
+
if (!el.parentElement)
|
|
2877
|
+
return null;
|
|
2878
|
+
return findParent(el.parentElement, callback);
|
|
2879
|
+
};
|
|
2880
|
+
const calcOffsetToNode = (parent, target) => {
|
|
2881
|
+
let offset = 0;
|
|
2882
|
+
for (let child of parent.childNodes) {
|
|
2883
|
+
if (child.nodeName === "BR")
|
|
2884
|
+
continue;
|
|
2885
|
+
const ch = child.nodeType === Node.TEXT_NODE ? child : child.childNodes[0];
|
|
2886
|
+
if (ch === target)
|
|
2887
|
+
return offset;
|
|
2888
|
+
offset += ch.length;
|
|
2889
|
+
}
|
|
2890
|
+
return offset;
|
|
2891
|
+
};
|
|
2892
|
+
const calcNodeByOffset = (parent, offset) => {
|
|
2893
|
+
let currentOffset = offset;
|
|
2894
|
+
if (offset === 0)
|
|
2895
|
+
return [parent, 0];
|
|
2896
|
+
for (let child of parent.childNodes) {
|
|
2897
|
+
if (child.nodeName === "BR")
|
|
2898
|
+
continue;
|
|
2899
|
+
const ch = child.nodeType === Node.TEXT_NODE ? child : child.childNodes[0];
|
|
2900
|
+
if (currentOffset - ch.length <= 0) {
|
|
2901
|
+
return [ch, currentOffset];
|
|
2783
2902
|
}
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2903
|
+
currentOffset -= ch.length;
|
|
2904
|
+
}
|
|
2905
|
+
return [parent, 0];
|
|
2906
|
+
};
|
|
2907
|
+
const clamp = (val, min, max) => {
|
|
2908
|
+
if (val > max)
|
|
2909
|
+
return max;
|
|
2910
|
+
if (val < min)
|
|
2911
|
+
return min;
|
|
2912
|
+
return val;
|
|
2913
|
+
};
|
|
2914
|
+
const isEqual = (a, b) => {
|
|
2915
|
+
if (a === b)
|
|
2916
|
+
return true;
|
|
2917
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null)
|
|
2918
|
+
return false;
|
|
2919
|
+
if (Array.isArray(a)) {
|
|
2920
|
+
if (!Array.isArray(b) || a.length !== b.length)
|
|
2921
|
+
return false;
|
|
2922
|
+
for (let i = 0; i < a.length; i++) {
|
|
2923
|
+
if (!isEqual(a[i], b[i]))
|
|
2924
|
+
return false;
|
|
2925
|
+
}
|
|
2926
|
+
return true;
|
|
2927
|
+
}
|
|
2928
|
+
for (let key in a) {
|
|
2929
|
+
if (!isEqual(a[key], b[key]))
|
|
2930
|
+
return false;
|
|
2931
|
+
}
|
|
2932
|
+
return true;
|
|
2933
|
+
};
|
|
2934
|
+
class TextEditorHistory {
|
|
2935
|
+
constructor(store) {
|
|
2936
|
+
__publicField(this, "actions", []);
|
|
2937
|
+
__publicField(this, "currentCursor", 0);
|
|
2938
|
+
__publicField(this, "blocksIds", "");
|
|
2939
|
+
__publicField(this, "cachedBlocksJson", "");
|
|
2940
|
+
__publicField(this, "store");
|
|
2941
|
+
__publicField(this, "tickStarted", false);
|
|
2942
|
+
this.store = store;
|
|
2943
|
+
window.showHistory = () => console.log(this.actions);
|
|
2944
|
+
}
|
|
2945
|
+
cacheBlockIds() {
|
|
2946
|
+
this.blocksIds = this.store.blocks.map((item) => item.id).join(",");
|
|
2947
|
+
}
|
|
2948
|
+
blockIdsChanged() {
|
|
2949
|
+
return this.blocksIds !== this.store.blocks.map((item) => item.id).join(",");
|
|
2950
|
+
}
|
|
2951
|
+
push(type) {
|
|
2952
|
+
var _a;
|
|
2953
|
+
if (this.currentCursor + 1 < this.actions.length) {
|
|
2954
|
+
this.actions.length = this.currentCursor + 1;
|
|
2955
|
+
}
|
|
2956
|
+
const lastAction = this.actions.length > 0 ? this.actions[this.actions.length - 1] : null;
|
|
2957
|
+
const selection = JSON.parse(JSON.stringify(this.store.selection));
|
|
2958
|
+
const fullUpdate = type === "setText" || type === "addNewLine" || this.blockIdsChanged();
|
|
2959
|
+
const blocksJson = JSON.stringify(this.store.blocks);
|
|
2960
|
+
if (!fullUpdate && this.store.currentBlock) {
|
|
2961
|
+
const currentBlock = JSON.parse(JSON.stringify(this.store.currentBlock));
|
|
2962
|
+
if (lastAction && lastAction.type === type && ((_a = lastAction.blocks[0]) == null ? void 0 : _a.id) === currentBlock.id && (lastAction.type === "insertText" || lastAction.type === "deleteContentBackward" || lastAction.type === "deleteContentForward")) {
|
|
2963
|
+
lastAction.blocks = [currentBlock];
|
|
2964
|
+
lastAction.selection = selection;
|
|
2965
|
+
} else {
|
|
2966
|
+
this.actions.push({ type, blocks: [currentBlock], selection, fullUpdate });
|
|
2967
|
+
}
|
|
2968
|
+
} else {
|
|
2969
|
+
this.actions.push({ type, blocks: JSON.parse(blocksJson), selection, fullUpdate });
|
|
2970
|
+
}
|
|
2971
|
+
this.currentCursor = this.actions.length - 1;
|
|
2972
|
+
if (fullUpdate) {
|
|
2973
|
+
if (lastAction && !lastAction.fullUpdate) {
|
|
2974
|
+
lastAction.fullUpdate = true;
|
|
2975
|
+
lastAction.blocks = JSON.parse(this.cachedBlocksJson);
|
|
2976
|
+
}
|
|
2977
|
+
this.cacheBlockIds();
|
|
2978
|
+
}
|
|
2979
|
+
this.cachedBlocksJson = blocksJson;
|
|
2980
|
+
}
|
|
2981
|
+
applyAction(action) {
|
|
2982
|
+
if (action.fullUpdate) {
|
|
2983
|
+
for (let i = 0; i < action.blocks.length; i++) {
|
|
2984
|
+
if (i >= this.store.blocks.length) {
|
|
2985
|
+
this.store.blocks.push({ ...action.blocks[i] });
|
|
2986
|
+
} else {
|
|
2987
|
+
Object.assign(this.store.blocks[i], action.blocks[i]);
|
|
2988
|
+
this.store.blocks[i].type = action.blocks[i].type;
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
if (this.store.blocks.length > action.blocks.length) {
|
|
2992
|
+
this.store.blocks.length = action.blocks.length;
|
|
2993
|
+
}
|
|
2994
|
+
} else {
|
|
2995
|
+
for (let _block of action.blocks) {
|
|
2996
|
+
const block = this.store.blocks.find((block2) => block2.id === _block.id);
|
|
2997
|
+
if (block) {
|
|
2998
|
+
block.text = _block.text;
|
|
2999
|
+
block.styles = _block.styles;
|
|
3000
|
+
block.type = _block.type;
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
Object.assign(this.store.selection, action.selection);
|
|
3005
|
+
this.cacheBlockIds();
|
|
3006
|
+
}
|
|
3007
|
+
undo() {
|
|
3008
|
+
if (this.currentCursor === 0)
|
|
3009
|
+
return;
|
|
3010
|
+
this.currentCursor--;
|
|
3011
|
+
this.applyAction(this.actions[this.currentCursor]);
|
|
3012
|
+
}
|
|
3013
|
+
redo() {
|
|
3014
|
+
if (this.currentCursor >= this.actions.length - 1)
|
|
3015
|
+
return;
|
|
3016
|
+
this.currentCursor++;
|
|
3017
|
+
this.applyAction(this.actions[this.currentCursor]);
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
class TextEditorStore {
|
|
3021
|
+
constructor() {
|
|
3022
|
+
__publicField(this, "history", new TextEditorHistory(this));
|
|
3023
|
+
__publicField(this, "blocks", reactive([{ id: uid(), text: "", styles: [] }]));
|
|
3024
|
+
__publicField(this, "selection", reactive({
|
|
3025
|
+
anchor: { blockId: this.blocks[0].id, offset: 0 },
|
|
3026
|
+
focus: { blockId: this.blocks[0].id, offset: 0 }
|
|
3027
|
+
}));
|
|
3028
|
+
__publicField(this, "_isCollapsed", computed(() => {
|
|
3029
|
+
return this.selection.anchor.blockId === this.selection.focus.blockId && this.selection.anchor.offset === this.selection.focus.offset;
|
|
3030
|
+
}));
|
|
3031
|
+
__publicField(this, "isFocused", ref(false));
|
|
3032
|
+
__publicField(this, "_currentBlock", computed(() => {
|
|
3033
|
+
if (this.selection.anchor.blockId !== this.selection.focus.blockId)
|
|
3034
|
+
return null;
|
|
3035
|
+
return this.blocks.find((item) => item.id === this.selection.anchor.blockId) ?? null;
|
|
3036
|
+
}));
|
|
3037
|
+
__publicField(this, "_selectedText", computed(() => {
|
|
3038
|
+
if (this.isCollapsed)
|
|
3039
|
+
return "";
|
|
3040
|
+
const [start, end, startIndex, endIndex] = this.startAndEnd;
|
|
3041
|
+
if (startIndex === endIndex) {
|
|
3042
|
+
return this.blocks[startIndex].text.slice(start.offset, end.offset);
|
|
3043
|
+
}
|
|
3044
|
+
const startText = this.blocks[startIndex].text.slice(start.offset);
|
|
3045
|
+
const endText = this.blocks[endIndex].text.slice(0, end.offset);
|
|
3046
|
+
const arr = [startText, ...this.blocks.slice(startIndex + 1, endIndex).map((block) => block.text), endText];
|
|
3047
|
+
return arr.join("\n");
|
|
3048
|
+
}));
|
|
3049
|
+
__publicField(this, "_currentStyles", computed(() => {
|
|
3050
|
+
const [start, end, startIndex, endIndex] = this.startAndEnd;
|
|
3051
|
+
const styles = /* @__PURE__ */ new Map();
|
|
3052
|
+
if (startIndex < 0)
|
|
3053
|
+
return styles;
|
|
3054
|
+
for (let i = startIndex; i <= endIndex; i++) {
|
|
3055
|
+
const blockStyles = this.blocks[i].styles;
|
|
3056
|
+
if (!blockStyles)
|
|
3057
|
+
continue;
|
|
3058
|
+
for (let style of blockStyles) {
|
|
3059
|
+
if (i === startIndex && start.offset < style.start)
|
|
3060
|
+
continue;
|
|
3061
|
+
if (i === endIndex && end.offset > style.end)
|
|
3062
|
+
continue;
|
|
3063
|
+
styles.set(style.style, style);
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
return styles;
|
|
3067
|
+
}));
|
|
3068
|
+
}
|
|
3069
|
+
get isCollapsed() {
|
|
3070
|
+
return this._isCollapsed.value;
|
|
3071
|
+
}
|
|
3072
|
+
get currentBlock() {
|
|
3073
|
+
return this._currentBlock.value;
|
|
3074
|
+
}
|
|
3075
|
+
get selectedText() {
|
|
3076
|
+
return this._selectedText.value;
|
|
3077
|
+
}
|
|
3078
|
+
moveOffset(newOffset) {
|
|
3079
|
+
const delta = newOffset - this.selection.anchor.offset;
|
|
3080
|
+
if (delta === 0)
|
|
3081
|
+
return;
|
|
3082
|
+
this.moveStyles(this.currentBlock, this.selection.focus.offset, -delta);
|
|
3083
|
+
this.selection.anchor.offset = newOffset;
|
|
3084
|
+
this.selection.focus.offset = newOffset;
|
|
3085
|
+
}
|
|
3086
|
+
addStyleToBlock(block, style) {
|
|
3087
|
+
if (!block.styles) {
|
|
3088
|
+
block.styles = [style];
|
|
3089
|
+
} else {
|
|
3090
|
+
block.styles.push(style);
|
|
3091
|
+
}
|
|
3092
|
+
block.styles.sort((a, b) => a.start - b.start);
|
|
3093
|
+
}
|
|
3094
|
+
concatBlocks(start, end) {
|
|
3095
|
+
if (end.styles) {
|
|
3096
|
+
for (let style of end.styles) {
|
|
3097
|
+
style.start += start.text.length;
|
|
3098
|
+
style.end += start.text.length;
|
|
3099
|
+
this.addStyleToBlock(start, style);
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
3102
|
+
start.text = start.text + end.text;
|
|
3103
|
+
}
|
|
3104
|
+
removeCurrentBlock() {
|
|
3105
|
+
const blockIndex = this.blocks.findIndex((item) => item.id === this.selection.anchor.blockId);
|
|
3106
|
+
if (blockIndex < 0)
|
|
3107
|
+
return;
|
|
3108
|
+
this.blocks.splice(blockIndex, 1);
|
|
3109
|
+
if (this.blocks.length === 0) {
|
|
3110
|
+
this.blocks.push({ id: uid(), text: "" });
|
|
3111
|
+
}
|
|
3112
|
+
const newBlockIndex = Math.max(blockIndex - 1, 0);
|
|
3113
|
+
this.selection.anchor.blockId = this.blocks[newBlockIndex].id;
|
|
3114
|
+
this.selection.focus.blockId = this.blocks[newBlockIndex].id;
|
|
3115
|
+
this.selection.anchor.offset = blockIndex === 0 ? 0 : this.blocks[newBlockIndex].text.length;
|
|
3116
|
+
this.selection.focus.offset = blockIndex === 0 ? 0 : this.blocks[newBlockIndex].text.length;
|
|
3117
|
+
this.history.push("removeBlock");
|
|
3118
|
+
}
|
|
3119
|
+
removeNewLine() {
|
|
3120
|
+
const blockIndex = this.blocks.findIndex((item) => item.id === this.selection.anchor.blockId);
|
|
3121
|
+
if (blockIndex < 1)
|
|
3122
|
+
return;
|
|
3123
|
+
if (this.blocks[blockIndex - 1].editable === false) {
|
|
3124
|
+
if (this.blocks[blockIndex].text === "") {
|
|
3125
|
+
this.blocks.splice(blockIndex, 1);
|
|
3126
|
+
}
|
|
3127
|
+
this.selection.anchor.blockId = this.blocks[blockIndex - 1].id;
|
|
3128
|
+
this.selection.focus.blockId = this.blocks[blockIndex - 1].id;
|
|
3129
|
+
this.selection.anchor.offset = 0;
|
|
3130
|
+
this.selection.focus.offset = 0;
|
|
3131
|
+
} else {
|
|
3132
|
+
this.selection.anchor.blockId = this.blocks[blockIndex - 1].id;
|
|
3133
|
+
this.selection.focus.blockId = this.blocks[blockIndex - 1].id;
|
|
3134
|
+
this.selection.anchor.offset = this.blocks[blockIndex - 1].text.length;
|
|
3135
|
+
this.selection.focus.offset = this.blocks[blockIndex - 1].text.length;
|
|
3136
|
+
this.concatBlocks(this.blocks[blockIndex - 1], this.blocks[blockIndex]);
|
|
3137
|
+
this.blocks.splice(blockIndex, 1);
|
|
3138
|
+
}
|
|
3139
|
+
}
|
|
3140
|
+
onInput(_e) {
|
|
3141
|
+
const ev = _e;
|
|
3142
|
+
if (ev.defaultPrevented)
|
|
3143
|
+
return;
|
|
3144
|
+
ev.preventDefault();
|
|
3145
|
+
const collapsed = this.isCollapsed;
|
|
3146
|
+
if (!collapsed)
|
|
3147
|
+
this.deleteSelected();
|
|
3148
|
+
const block = this.currentBlock;
|
|
3149
|
+
if (!block)
|
|
3150
|
+
return;
|
|
3151
|
+
if ((ev.inputType === "deleteContentBackward" || ev.inputType === "deleteContentForward") && collapsed) {
|
|
3152
|
+
if (ev.inputType === "deleteContentBackward") {
|
|
3153
|
+
if (this.selection.anchor.offset === 0) {
|
|
3154
|
+
if (block.type) {
|
|
3155
|
+
delete block.type;
|
|
3156
|
+
} else {
|
|
3157
|
+
this.removeNewLine();
|
|
3158
|
+
}
|
|
3159
|
+
} else {
|
|
3160
|
+
const offset = Math.max(0, this.selection.focus.offset - 1);
|
|
3161
|
+
block.text = block.text.slice(0, offset) + block.text.slice(this.selection.focus.offset);
|
|
3162
|
+
this.moveOffset(offset);
|
|
3163
|
+
}
|
|
3164
|
+
this.history.push("deleteContentBackward");
|
|
3165
|
+
}
|
|
3166
|
+
if (ev.inputType === "deleteContentForward") {
|
|
3167
|
+
const blockIndex = this.blocks.findIndex((item) => item.id === this.selection.anchor.blockId);
|
|
3168
|
+
if (this.selection.anchor.offset === this.blocks[blockIndex].text.length) {
|
|
3169
|
+
const nextBlock = this.blocks[blockIndex + 1];
|
|
3170
|
+
if (nextBlock) {
|
|
3171
|
+
this.blocks.splice(blockIndex + 1, 1);
|
|
3172
|
+
this.concatBlocks(this.blocks[blockIndex], nextBlock);
|
|
3173
|
+
}
|
|
3174
|
+
} else {
|
|
3175
|
+
block.text = block.text.slice(0, this.selection.focus.offset) + block.text.slice(this.selection.focus.offset + 1);
|
|
3176
|
+
this.moveStyles(block, this.selection.focus.offset + 1, 1);
|
|
3177
|
+
}
|
|
3178
|
+
this.history.push("deleteContentForward");
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
if (ev.inputType === "insertText") {
|
|
3182
|
+
this.insertText(ev.data);
|
|
3183
|
+
this.history.push("insertText");
|
|
3184
|
+
}
|
|
3185
|
+
}
|
|
3186
|
+
addNewLineBefore() {
|
|
3187
|
+
const index = this.blocks.findIndex((item) => item.id === this.selection.anchor.blockId);
|
|
3188
|
+
const block = { id: uid(), text: "" };
|
|
3189
|
+
this.blocks.splice(index, 0, block);
|
|
3190
|
+
this.history.push("addNewLine");
|
|
3191
|
+
}
|
|
3192
|
+
addNewLine() {
|
|
3193
|
+
var _a;
|
|
3194
|
+
if (this.isCollapsed && this.selection.anchor.offset === 0 && ((_a = this.currentBlock) == null ? void 0 : _a.editable) !== false) {
|
|
3195
|
+
this.addNewLineBefore();
|
|
3196
|
+
return;
|
|
3197
|
+
}
|
|
3198
|
+
this.deleteSelected();
|
|
3199
|
+
if (!this.currentBlock)
|
|
3200
|
+
return;
|
|
3201
|
+
const endText = this.currentBlock.editable === false ? "" : this.currentBlock.text.slice(this.selection.anchor.offset);
|
|
3202
|
+
this.currentBlock.text = this.currentBlock.text.slice(0, this.selection.anchor.offset);
|
|
3203
|
+
const block = { id: uid(), text: endText || "" };
|
|
3204
|
+
const index = this.blocks.findIndex((item) => item.id === this.selection.anchor.blockId);
|
|
3205
|
+
this.blocks.splice(index + 1, 0, block);
|
|
3206
|
+
this.selection.anchor = { blockId: block.id, offset: 0 };
|
|
3207
|
+
this.selection.focus = { blockId: block.id, offset: 0 };
|
|
3208
|
+
this.history.push("addNewLine");
|
|
3209
|
+
}
|
|
3210
|
+
addNewLineAfter() {
|
|
3211
|
+
const index = this.blocks.findIndex((item) => item.id === this.selection.anchor.blockId);
|
|
3212
|
+
const block = { id: uid(), text: "" };
|
|
3213
|
+
this.blocks.splice(index + 1, 0, block);
|
|
3214
|
+
return block;
|
|
3215
|
+
}
|
|
3216
|
+
insertText(data) {
|
|
3217
|
+
const block = this.currentBlock;
|
|
3218
|
+
if (!block)
|
|
3219
|
+
return;
|
|
3220
|
+
const text = data.replace(/\r/g, "");
|
|
3221
|
+
block.text = block.text.slice(0, this.selection.focus.offset) + text + block.text.slice(this.selection.focus.offset);
|
|
3222
|
+
this.moveOffset(clamp(this.selection.focus.offset + text.length, 0, block.text.length));
|
|
3223
|
+
}
|
|
3224
|
+
insertBlock(blockData) {
|
|
3225
|
+
if (!this.currentBlock)
|
|
3226
|
+
return;
|
|
3227
|
+
this.deleteSelected();
|
|
3228
|
+
if (this.currentBlock.text !== "") {
|
|
3229
|
+
this.addNewLine();
|
|
3230
|
+
}
|
|
3231
|
+
if (this.currentBlock.text !== "") {
|
|
3232
|
+
const selection = JSON.parse(JSON.stringify(this.selection));
|
|
3233
|
+
this.addNewLine();
|
|
3234
|
+
Object.assign(this.selection, selection);
|
|
3235
|
+
}
|
|
3236
|
+
Object.assign(this.currentBlock, blockData);
|
|
3237
|
+
if (blockData.editable === false && this.currentBlock === this.blocks[this.blocks.length - 1]) {
|
|
3238
|
+
const newLine = this.addNewLineAfter();
|
|
3239
|
+
this.selection.focus.blockId = newLine.id;
|
|
3240
|
+
this.selection.focus.offset = 0;
|
|
3241
|
+
this.selection.anchor.blockId = newLine.id;
|
|
3242
|
+
this.selection.anchor.offset = 0;
|
|
3243
|
+
}
|
|
3244
|
+
this.history.push("setText");
|
|
3245
|
+
}
|
|
3246
|
+
get startAndEnd() {
|
|
3247
|
+
const a = this.blocks.findIndex((block) => block.id === this.selection.anchor.blockId);
|
|
3248
|
+
const f = this.blocks.findIndex((block) => block.id === this.selection.focus.blockId);
|
|
3249
|
+
if (a < f || a === f && this.selection.anchor.offset < this.selection.focus.offset) {
|
|
3250
|
+
return [this.selection.anchor, this.selection.focus, a, f];
|
|
3251
|
+
} else {
|
|
3252
|
+
return [this.selection.focus, this.selection.anchor, f, a];
|
|
3253
|
+
}
|
|
3254
|
+
}
|
|
3255
|
+
moveStyles(block, offset, delta) {
|
|
3256
|
+
if (!block.styles)
|
|
3257
|
+
return;
|
|
3258
|
+
for (let i = 0; i < block.styles.length; i++) {
|
|
3259
|
+
const style = block.styles[i];
|
|
3260
|
+
if (style.start >= offset)
|
|
3261
|
+
style.start -= delta;
|
|
3262
|
+
if (style.end >= offset)
|
|
3263
|
+
style.end -= delta;
|
|
3264
|
+
if (style.end <= style.start) {
|
|
3265
|
+
block.styles.splice(i, 1);
|
|
3266
|
+
i--;
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
}
|
|
3270
|
+
deleteSelected() {
|
|
3271
|
+
if (this.isCollapsed)
|
|
3272
|
+
return;
|
|
3273
|
+
const [start, end, startIndex, endIndex] = this.startAndEnd;
|
|
3274
|
+
const startText = this.blocks[startIndex].text.slice(0, start.offset);
|
|
3275
|
+
const endText = this.blocks[endIndex].text.slice(end.offset);
|
|
3276
|
+
this.removeAllStyles();
|
|
3277
|
+
const delta = end.offset - (startIndex === endIndex ? start.offset : 0);
|
|
3278
|
+
this.moveStyles(this.blocks[endIndex], end.offset, delta);
|
|
3279
|
+
if (this.selection.anchor.blockId !== this.selection.focus.blockId) {
|
|
3280
|
+
this.blocks.splice(startIndex + 1, endIndex - startIndex);
|
|
3281
|
+
}
|
|
3282
|
+
if (start !== this.selection.anchor) {
|
|
3283
|
+
this.selection.anchor = { ...start };
|
|
3284
|
+
}
|
|
3285
|
+
if (start !== this.selection.focus) {
|
|
3286
|
+
this.selection.focus = { ...start };
|
|
3287
|
+
}
|
|
3288
|
+
this.blocks[startIndex].text = startText + endText;
|
|
3289
|
+
}
|
|
3290
|
+
get currentStyles() {
|
|
3291
|
+
return this._currentStyles.value;
|
|
3292
|
+
}
|
|
3293
|
+
applyStyle(_style, meta) {
|
|
3294
|
+
if (this.isCollapsed)
|
|
3295
|
+
return;
|
|
3296
|
+
const [start, end, startIndex, endIndex] = this.startAndEnd;
|
|
3297
|
+
for (let i = startIndex; i <= endIndex; i++) {
|
|
3298
|
+
const block = this.blocks[i];
|
|
3299
|
+
const _start = i === startIndex ? start.offset : 0;
|
|
3300
|
+
const _end = i === endIndex ? end.offset : block.text.length;
|
|
3301
|
+
let createNewStyle = true;
|
|
3302
|
+
if (block.styles) {
|
|
3303
|
+
for (let style of block.styles) {
|
|
3304
|
+
if (style.style !== _style)
|
|
3305
|
+
continue;
|
|
3306
|
+
if (style.start > _end || style.end < _start)
|
|
3307
|
+
continue;
|
|
3308
|
+
if (meta && !isEqual(meta, style.meta) && (style.start !== _start || style.end !== _end)) {
|
|
3309
|
+
if (_start === style.end || _end === style.start)
|
|
3310
|
+
continue;
|
|
3311
|
+
this.removeStyleAt(block, _start, _end, _style);
|
|
3312
|
+
} else {
|
|
3313
|
+
style.start = Math.min(style.start, _start);
|
|
3314
|
+
style.end = Math.max(style.end, _end);
|
|
3315
|
+
createNewStyle = false;
|
|
3316
|
+
style.meta = meta;
|
|
3317
|
+
}
|
|
3318
|
+
}
|
|
3319
|
+
}
|
|
3320
|
+
if (createNewStyle) {
|
|
3321
|
+
const newStyle = {
|
|
3322
|
+
start: i === startIndex ? start.offset : 0,
|
|
3323
|
+
end: i === endIndex ? end.offset : block.text.length,
|
|
3324
|
+
style: _style,
|
|
3325
|
+
meta
|
|
3326
|
+
};
|
|
3327
|
+
this.addStyleToBlock(block, newStyle);
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
this.history.push("applyStyle");
|
|
3331
|
+
}
|
|
3332
|
+
removeStyleAt(block, _start, _end, _style) {
|
|
3333
|
+
const removeAll = typeof _style !== "string";
|
|
3334
|
+
if (!block.styles)
|
|
3335
|
+
return;
|
|
3336
|
+
for (let i = 0; i < block.styles.length; i++) {
|
|
3337
|
+
const style = block.styles[i];
|
|
3338
|
+
if (!removeAll && style.style !== _style)
|
|
3339
|
+
continue;
|
|
3340
|
+
if (style.start > _end || style.end < _start)
|
|
3341
|
+
continue;
|
|
3342
|
+
if (style.start >= _start && style.end <= _end) {
|
|
3343
|
+
block.styles.splice(i, 1);
|
|
3344
|
+
i--;
|
|
3345
|
+
} else if (style.start < _start && style.end > _end) {
|
|
3346
|
+
block.styles.push({ ...style, start: _end });
|
|
3347
|
+
style.end = _start;
|
|
3348
|
+
} else if (style.start < _start) {
|
|
3349
|
+
style.end = _start;
|
|
3350
|
+
} else if (style.end > _end) {
|
|
3351
|
+
style.start = _end;
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
if (block.styles.length === 0) {
|
|
3355
|
+
delete block.styles;
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
removeStyle(_style) {
|
|
3359
|
+
const [start, end, startIndex, endIndex] = this.startAndEnd;
|
|
3360
|
+
for (let i = startIndex; i <= endIndex; i++) {
|
|
3361
|
+
const block = this.blocks[i];
|
|
3362
|
+
const _start = i === startIndex ? start.offset : 0;
|
|
3363
|
+
const _end = i === endIndex ? end.offset : block.text.length;
|
|
3364
|
+
this.removeStyleAt(block, _start, _end, _style);
|
|
3365
|
+
}
|
|
3366
|
+
this.history.push("applyStyle");
|
|
3367
|
+
}
|
|
3368
|
+
removeAllStyles() {
|
|
3369
|
+
const [start, end, startIndex, endIndex] = this.startAndEnd;
|
|
3370
|
+
for (let i = startIndex; i <= endIndex; i++) {
|
|
3371
|
+
const block = this.blocks[i];
|
|
3372
|
+
if (i > startIndex && i < endIndex) {
|
|
3373
|
+
delete block.styles;
|
|
3374
|
+
return;
|
|
3375
|
+
}
|
|
3376
|
+
const _start = i === startIndex ? start.offset : 0;
|
|
3377
|
+
const _end = i === endIndex ? end.offset : block.text.length;
|
|
3378
|
+
this.removeStyleAt(block, _start, _end);
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
toggleStyle(style) {
|
|
3382
|
+
if (this.currentStyles.has(style)) {
|
|
3383
|
+
this.removeStyle(style);
|
|
3384
|
+
} else {
|
|
3385
|
+
this.applyStyle(style);
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
selectAll() {
|
|
3389
|
+
this.selection.anchor = { blockId: this.blocks[0].id, offset: 0 };
|
|
3390
|
+
const lastBlock = this.blocks[this.blocks.length - 1];
|
|
3391
|
+
this.selection.focus = { blockId: lastBlock.id, offset: lastBlock.text.length };
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
let uidCounter = 0;
|
|
3395
|
+
const uid = () => (uidCounter++).toString();
|
|
3396
|
+
const _sfc_main$2$1 = defineComponent({
|
|
3397
|
+
props: ["block", "slots", "static", "decorator", "renderer", "parser"],
|
|
3398
|
+
emits: ["postrender"],
|
|
3399
|
+
setup(props, { emit }) {
|
|
3400
|
+
const slot = computed(() => {
|
|
3401
|
+
if (!props.block.type)
|
|
3402
|
+
return props.slots["default"] ?? null;
|
|
3403
|
+
return props.slots[props.block.type] ?? null;
|
|
3404
|
+
});
|
|
3405
|
+
const instance = getCurrentInstance();
|
|
3406
|
+
const getRef = () => {
|
|
3407
|
+
if (!instance)
|
|
3408
|
+
return null;
|
|
3409
|
+
const el = instance.vnode.el;
|
|
3410
|
+
if (!el)
|
|
3411
|
+
return null;
|
|
3412
|
+
if (el.nodeType === Node.TEXT_NODE && el.nextSibling !== null) {
|
|
3413
|
+
return el.nextSibling;
|
|
3414
|
+
}
|
|
3415
|
+
return el;
|
|
3416
|
+
};
|
|
3417
|
+
const cacheNodes = [];
|
|
3418
|
+
let cacheEl = null;
|
|
3419
|
+
const cleanTree = (count) => {
|
|
3420
|
+
if (props.static === true)
|
|
3421
|
+
return;
|
|
3422
|
+
const el = getRef();
|
|
3423
|
+
if (!el)
|
|
3424
|
+
return;
|
|
3425
|
+
if (el === cacheEl && cacheNodes.length > 0) {
|
|
3426
|
+
el.prepend(cacheNodes[0]);
|
|
3427
|
+
el.append(cacheNodes[1]);
|
|
3428
|
+
}
|
|
3429
|
+
nextTick(() => {
|
|
3430
|
+
var _a;
|
|
3431
|
+
cacheEl = getRef();
|
|
3432
|
+
if (el === cacheEl) {
|
|
3433
|
+
if (el.childNodes.length > count + 2) {
|
|
3434
|
+
for (let i = 0; i < el.childNodes.length; i++) {
|
|
3435
|
+
const child = el.childNodes[i];
|
|
3436
|
+
if (i === 0 && child.nodeType === Node.TEXT_NODE && child.textContent === "")
|
|
3437
|
+
continue;
|
|
3438
|
+
if ("__vnode" in child)
|
|
3439
|
+
continue;
|
|
3440
|
+
if (child.nodeType === Node.TEXT_NODE && ((_a = child.textContent) == null ? void 0 : _a.endsWith("\n")))
|
|
3441
|
+
continue;
|
|
3442
|
+
el.removeChild(child);
|
|
3443
|
+
break;
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
if (cacheEl) {
|
|
3448
|
+
cacheNodes[0] = cacheEl.childNodes[0];
|
|
3449
|
+
cacheNodes[1] = cacheEl.childNodes[cacheEl.childNodes.length - 1];
|
|
3450
|
+
}
|
|
3451
|
+
emit("postrender");
|
|
3452
|
+
});
|
|
3453
|
+
};
|
|
3454
|
+
const content = () => {
|
|
3455
|
+
const block = props.block;
|
|
3456
|
+
if (block.editable === false)
|
|
3457
|
+
return [];
|
|
3458
|
+
if (block.text.length === 0) {
|
|
3459
|
+
cleanTree(1);
|
|
3460
|
+
return [h("br")];
|
|
3461
|
+
}
|
|
3462
|
+
let text = block.text;
|
|
3463
|
+
if (text.endsWith("\n")) {
|
|
3464
|
+
text = text + "\n";
|
|
3465
|
+
}
|
|
3466
|
+
const markers = [];
|
|
3467
|
+
if (block.styles) {
|
|
3468
|
+
for (let style of block.styles) {
|
|
3469
|
+
if (style.end <= style.start)
|
|
3470
|
+
continue;
|
|
3471
|
+
markers.push([style.start, style]);
|
|
3472
|
+
markers.push([style.end, style]);
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
if (props.parser) {
|
|
3476
|
+
for (let style of props.parser(text)) {
|
|
3477
|
+
if (style.end <= style.start)
|
|
3478
|
+
continue;
|
|
3479
|
+
markers.push([style.start, style]);
|
|
3480
|
+
markers.push([style.end, style]);
|
|
3481
|
+
}
|
|
3482
|
+
}
|
|
3483
|
+
markers.sort((a, b) => a[0] - b[0]);
|
|
3484
|
+
let currentIndex = 0;
|
|
3485
|
+
const activeStyles = /* @__PURE__ */ new Set();
|
|
3486
|
+
const blocks = [];
|
|
3487
|
+
for (let marker of markers) {
|
|
3488
|
+
if (currentIndex !== marker[0]) {
|
|
3489
|
+
const str = text.slice(currentIndex, marker[0]);
|
|
3490
|
+
blocks.push(renderBlockPart(str, Array.from(activeStyles.values())));
|
|
3491
|
+
currentIndex = marker[0];
|
|
3492
|
+
}
|
|
3493
|
+
if (marker[0] === marker[1].start) {
|
|
3494
|
+
activeStyles.add(marker[1]);
|
|
3495
|
+
}
|
|
3496
|
+
if (marker[0] === marker[1].end) {
|
|
3497
|
+
activeStyles.delete(marker[1]);
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
if (currentIndex !== text.length) {
|
|
3501
|
+
const str = text.slice(currentIndex, text.length);
|
|
3502
|
+
blocks.push(renderBlockPart(str, Array.from(activeStyles.values())));
|
|
3503
|
+
}
|
|
3504
|
+
cleanTree(blocks.length);
|
|
3505
|
+
return blocks;
|
|
3506
|
+
};
|
|
3507
|
+
const renderBlockPart = (text, styles) => {
|
|
3508
|
+
if (!props.decorator)
|
|
3509
|
+
return text;
|
|
3510
|
+
let elementTag = "span";
|
|
3511
|
+
const attrs = {};
|
|
3512
|
+
for (let style of styles) {
|
|
3513
|
+
const partProps = props.decorator(style);
|
|
3514
|
+
if (!partProps)
|
|
3515
|
+
continue;
|
|
3516
|
+
const { class: _class, style: _style, tag, ...otherProps } = partProps;
|
|
3517
|
+
Object.assign(attrs, otherProps);
|
|
3518
|
+
if (_class) {
|
|
3519
|
+
attrs.class = attrs.class ? attrs.class + " " + _class : _class;
|
|
3520
|
+
}
|
|
3521
|
+
if (_style) {
|
|
3522
|
+
attrs.style = attrs.style ? attrs.style + " " + _style : _style;
|
|
3523
|
+
}
|
|
3524
|
+
if (tag) {
|
|
3525
|
+
elementTag = tag;
|
|
3526
|
+
}
|
|
3527
|
+
}
|
|
3528
|
+
if (Object.keys(attrs).length === 0 && elementTag === "span")
|
|
3529
|
+
return text;
|
|
3530
|
+
return h(elementTag, attrs, text);
|
|
3531
|
+
};
|
|
3532
|
+
return () => {
|
|
3533
|
+
let elementTag = "div";
|
|
3534
|
+
const blockProps = {
|
|
3535
|
+
"data-vw-block-id": props.block.id
|
|
3536
|
+
};
|
|
3537
|
+
const additionalProps = props.renderer && props.renderer(props.block);
|
|
3538
|
+
if (additionalProps) {
|
|
3539
|
+
if (additionalProps.tag) {
|
|
3540
|
+
elementTag = additionalProps.tag;
|
|
3541
|
+
delete additionalProps.tag;
|
|
3542
|
+
}
|
|
3543
|
+
Object.assign(blockProps, additionalProps);
|
|
3544
|
+
}
|
|
3545
|
+
if (slot.value) {
|
|
3546
|
+
const component = slot.value({ content, props: blockProps, block: props.block });
|
|
3547
|
+
if (Array.isArray(component) && component.length === 1)
|
|
3548
|
+
return component[0];
|
|
3549
|
+
return component;
|
|
3550
|
+
}
|
|
3551
|
+
return h(elementTag, blockProps, content());
|
|
3552
|
+
};
|
|
3553
|
+
}
|
|
3554
|
+
});
|
|
3555
|
+
const createClipboardEvents = (store, props) => {
|
|
3556
|
+
const getSelected = () => {
|
|
3557
|
+
const [start, end, startIndex, endIndex] = store.startAndEnd;
|
|
3558
|
+
if (startIndex === endIndex) {
|
|
3559
|
+
const text2 = store.blocks[startIndex].text.slice(start.offset, end.offset);
|
|
3560
|
+
return [
|
|
3561
|
+
new ClipboardItem({
|
|
3562
|
+
"text/plain": new Blob([text2], { type: "text/plain" })
|
|
3563
|
+
})
|
|
3564
|
+
];
|
|
3565
|
+
}
|
|
3566
|
+
const startText = store.blocks[startIndex].text.slice(start.offset);
|
|
3567
|
+
const endText = store.blocks[endIndex].text.slice(0, end.offset);
|
|
3568
|
+
const arr = [
|
|
3569
|
+
{ type: store.blocks[startIndex].type, text: startText },
|
|
3570
|
+
...store.blocks.slice(startIndex + 1, endIndex),
|
|
3571
|
+
{ type: store.blocks[endIndex].type, text: endText }
|
|
3572
|
+
];
|
|
3573
|
+
const html = arr.map((item) => `<div>${item.text}</div>`).join("\n");
|
|
3574
|
+
const text = arr.map((item) => item.text).join("\n");
|
|
3575
|
+
return [
|
|
3576
|
+
new ClipboardItem({
|
|
3577
|
+
"text/html": new Blob([html], { type: "text/html" }),
|
|
3578
|
+
"text/plain": new Blob([text], { type: "text/plain" })
|
|
3579
|
+
})
|
|
3580
|
+
];
|
|
3581
|
+
};
|
|
3582
|
+
const onCopy = (e) => {
|
|
3583
|
+
if (e.defaultPrevented)
|
|
3584
|
+
return;
|
|
3585
|
+
e.preventDefault();
|
|
3586
|
+
navigator.clipboard.write(getSelected());
|
|
3587
|
+
store.history.push("setText");
|
|
3588
|
+
};
|
|
3589
|
+
const onCut = (e) => {
|
|
3590
|
+
if (e.defaultPrevented)
|
|
3591
|
+
return;
|
|
3592
|
+
e.preventDefault();
|
|
3593
|
+
navigator.clipboard.write(getSelected());
|
|
3594
|
+
store.deleteSelected();
|
|
3595
|
+
store.history.push("setText");
|
|
3596
|
+
};
|
|
3597
|
+
const insertText = (text) => {
|
|
3598
|
+
if (props.preventMultiline) {
|
|
3599
|
+
const blocks = text.split("\n");
|
|
3600
|
+
store.insertText(blocks[0]);
|
|
3601
|
+
for (let i = 1; i < blocks.length; i++) {
|
|
3602
|
+
store.addNewLine();
|
|
3603
|
+
store.insertText(blocks[i]);
|
|
3604
|
+
}
|
|
3605
|
+
} else {
|
|
3606
|
+
store.insertText(text);
|
|
3607
|
+
}
|
|
3608
|
+
};
|
|
3609
|
+
const parseHtml = (node) => {
|
|
3610
|
+
var _a;
|
|
3611
|
+
let isTextNode = false;
|
|
3612
|
+
for (let _node of node.childNodes) {
|
|
3613
|
+
if (_node.nodeType === Node.TEXT_NODE && ((_a = _node.textContent) == null ? void 0 : _a.trim()) || _node.nodeType == Node.ELEMENT_NODE && _node.tagName === "SPAN") {
|
|
3614
|
+
isTextNode = true;
|
|
3615
|
+
break;
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
if (isTextNode) {
|
|
3619
|
+
const text = node.textContent;
|
|
3620
|
+
if (!text)
|
|
3621
|
+
return;
|
|
3622
|
+
insertText(text);
|
|
3623
|
+
store.addNewLine();
|
|
3624
|
+
return;
|
|
3625
|
+
}
|
|
3626
|
+
for (let child of node.children) {
|
|
3627
|
+
if (child.tagName === "DIV") {
|
|
3628
|
+
parseHtml(child);
|
|
3629
|
+
} else {
|
|
3630
|
+
insertText(child.textContent ?? "");
|
|
3631
|
+
store.addNewLine();
|
|
3632
|
+
}
|
|
3633
|
+
}
|
|
3634
|
+
};
|
|
3635
|
+
const parser = new DOMParser();
|
|
3636
|
+
const onPaste = (e) => {
|
|
3637
|
+
var _a, _b;
|
|
3638
|
+
if (e.defaultPrevented)
|
|
3639
|
+
return;
|
|
3640
|
+
e.preventDefault();
|
|
3641
|
+
const html = (_a = e.clipboardData) == null ? void 0 : _a.getData("text/html");
|
|
3642
|
+
if (html) {
|
|
3643
|
+
store.deleteSelected();
|
|
3644
|
+
const dom = parser.parseFromString(html, "text/html");
|
|
3645
|
+
parseHtml(dom.body);
|
|
3646
|
+
} else {
|
|
3647
|
+
const text = (_b = e.clipboardData) == null ? void 0 : _b.getData("text");
|
|
3648
|
+
if (!text)
|
|
3649
|
+
return;
|
|
3650
|
+
store.deleteSelected();
|
|
3651
|
+
insertText(text);
|
|
3652
|
+
}
|
|
3653
|
+
store.history.push("setText");
|
|
3654
|
+
};
|
|
3655
|
+
return {
|
|
3656
|
+
onCopy,
|
|
3657
|
+
onCut,
|
|
3658
|
+
onPaste
|
|
3659
|
+
};
|
|
3660
|
+
};
|
|
3661
|
+
const _sfc_main$1$1 = /* @__PURE__ */ defineComponent({
|
|
3662
|
+
__name: "TextEditor",
|
|
3663
|
+
props: {
|
|
3664
|
+
decorator: { type: Function },
|
|
3665
|
+
renderer: { type: Function },
|
|
3666
|
+
single: { type: Boolean },
|
|
3667
|
+
modelValue: {},
|
|
3668
|
+
parser: { type: Function },
|
|
3669
|
+
styles: {},
|
|
3670
|
+
autofocus: { type: Boolean },
|
|
3671
|
+
autoselect: { type: Boolean },
|
|
3672
|
+
preventMultiline: { type: Boolean }
|
|
3673
|
+
},
|
|
3674
|
+
emits: ["keydown", "update:modelValue", "update:styles"],
|
|
3675
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
3676
|
+
const props = __props;
|
|
3677
|
+
const emit = __emit;
|
|
3678
|
+
const slots = useSlots();
|
|
3679
|
+
const textEditorRef = ref();
|
|
3680
|
+
const store = new TextEditorStore();
|
|
3681
|
+
let modelValue = "";
|
|
3682
|
+
watch(() => props.modelValue, (newValue) => {
|
|
3683
|
+
if (isProxy(newValue) && toRaw(newValue) === modelValue)
|
|
3684
|
+
return;
|
|
3685
|
+
if (newValue === void 0 || newValue === null || newValue === modelValue)
|
|
3686
|
+
return;
|
|
3687
|
+
if (!Array.isArray(newValue)) {
|
|
3688
|
+
store.blocks[0].text = newValue;
|
|
3689
|
+
return;
|
|
3690
|
+
} else {
|
|
3691
|
+
for (let i = store.blocks.length; i < newValue.length; i++) {
|
|
3692
|
+
store.blocks.push({ id: uid(), text: "", styles: [] });
|
|
3693
|
+
}
|
|
3694
|
+
store.blocks.length = newValue.length;
|
|
3695
|
+
for (let i = 0; i < newValue.length; i++) {
|
|
3696
|
+
store.blocks[i].text = newValue[i].text;
|
|
3697
|
+
store.blocks[i].type = newValue[i].type;
|
|
3698
|
+
store.blocks[i].styles = newValue[i].styles;
|
|
3699
|
+
}
|
|
3700
|
+
}
|
|
3701
|
+
}, { immediate: true });
|
|
3702
|
+
let styles;
|
|
3703
|
+
watch(() => props.styles, (newStyles) => {
|
|
3704
|
+
if (!newStyles || newStyles.length === 0 || newStyles === styles)
|
|
3705
|
+
return;
|
|
3706
|
+
for (let i = 0; i < store.blocks.length; i++) {
|
|
3707
|
+
if (newStyles.length <= i)
|
|
3708
|
+
break;
|
|
3709
|
+
store.blocks[i].styles = newStyles;
|
|
3710
|
+
}
|
|
3711
|
+
}, { immediate: true });
|
|
3712
|
+
watch(() => store.blocks, () => {
|
|
3713
|
+
if (props.single) {
|
|
3714
|
+
modelValue = store.blocks[0].text;
|
|
3715
|
+
styles = store.blocks[0].styles;
|
|
3716
|
+
emit("update:styles", styles);
|
|
3717
|
+
emit("update:modelValue", modelValue);
|
|
3718
|
+
} else {
|
|
3719
|
+
emit("update:modelValue", store.blocks);
|
|
3720
|
+
}
|
|
3721
|
+
}, { deep: true });
|
|
3722
|
+
const onKeyDown = (e) => {
|
|
3723
|
+
emit("keydown", e);
|
|
3724
|
+
if (e.defaultPrevented)
|
|
3725
|
+
return;
|
|
3726
|
+
if (e.code === "Enter") {
|
|
3727
|
+
e.preventDefault();
|
|
3728
|
+
if (!props.preventMultiline && (e.shiftKey || props.single)) {
|
|
3729
|
+
store.insertText("\n");
|
|
3730
|
+
} else {
|
|
3731
|
+
store.addNewLine();
|
|
3732
|
+
}
|
|
3733
|
+
}
|
|
3734
|
+
if ((e.ctrlKey || e.metaKey) && !e.shiftKey && !e.altKey) {
|
|
3735
|
+
if (e.code === "KeyB" || e.code === "KeyI" || e.code === "KeyU") {
|
|
3736
|
+
e.preventDefault();
|
|
3737
|
+
}
|
|
3738
|
+
}
|
|
3739
|
+
if ((e.ctrlKey || e.metaKey) && e.code === "KeyZ" && !e.shiftKey) {
|
|
3740
|
+
e.preventDefault();
|
|
3741
|
+
store.history.undo();
|
|
3742
|
+
}
|
|
3743
|
+
if ((e.ctrlKey || e.metaKey) && (e.code === "KeyY" || e.shiftKey && e.code === "KeyZ")) {
|
|
3744
|
+
e.preventDefault();
|
|
3745
|
+
store.history.redo();
|
|
3746
|
+
}
|
|
3747
|
+
};
|
|
3748
|
+
let cachedSelection = {};
|
|
3749
|
+
useEventListener(document, "selectionchange", () => {
|
|
3750
|
+
const sel = window.getSelection();
|
|
3751
|
+
const anchor = findParent(sel.anchorNode, (el) => el.hasAttribute("data-vw-block-id") && el.parentElement === textEditorRef.value);
|
|
3752
|
+
if (anchor) {
|
|
3753
|
+
const isNonEditable = anchor.getAttribute("contenteditable") === "false";
|
|
3754
|
+
const offset = isNonEditable || anchor === sel.focusNode ? 0 : calcOffsetToNode(anchor, sel.anchorNode) + sel.anchorOffset;
|
|
3755
|
+
store.selection.anchor = { blockId: anchor.getAttribute("data-vw-block-id"), offset };
|
|
3756
|
+
}
|
|
3757
|
+
const focus = findParent(sel.focusNode, (el) => el.hasAttribute("data-vw-block-id") && el.parentElement === textEditorRef.value);
|
|
3758
|
+
if (focus) {
|
|
3759
|
+
const isNonEditable = focus.getAttribute("contenteditable") === "false";
|
|
3760
|
+
const offset = isNonEditable || focus === sel.focusNode ? 0 : calcOffsetToNode(focus, sel.focusNode) + sel.focusOffset;
|
|
3761
|
+
store.selection.focus = { blockId: focus.getAttribute("data-vw-block-id"), offset };
|
|
3762
|
+
}
|
|
3763
|
+
if (store.isFocused.value !== (!!focus || !!anchor)) {
|
|
3764
|
+
store.isFocused.value = !!focus || !!anchor;
|
|
3765
|
+
}
|
|
3766
|
+
if (anchor && focus) {
|
|
3767
|
+
cachedSelection = JSON.parse(JSON.stringify(store.selection));
|
|
3768
|
+
}
|
|
3769
|
+
});
|
|
3770
|
+
let postRendered = false;
|
|
3771
|
+
const onPostRender = () => {
|
|
3772
|
+
if (postRendered)
|
|
3773
|
+
return;
|
|
3774
|
+
cachedSelection = {};
|
|
3775
|
+
postRendered = true;
|
|
3776
|
+
applySelection();
|
|
3777
|
+
nextTick(() => {
|
|
3778
|
+
postRendered = false;
|
|
3779
|
+
});
|
|
3780
|
+
};
|
|
3781
|
+
const getNode = (blockId) => {
|
|
3782
|
+
for (let item of textEditorRef.value.children) {
|
|
3783
|
+
if (item.getAttribute("data-vw-block-id") === blockId) {
|
|
3784
|
+
return item;
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
return null;
|
|
3788
|
+
};
|
|
3789
|
+
const applySelection = () => {
|
|
3790
|
+
var _a;
|
|
3791
|
+
if (!store.isFocused.value) {
|
|
3792
|
+
cachedSelection = JSON.parse(JSON.stringify(store.selection));
|
|
3793
|
+
return;
|
|
3794
|
+
}
|
|
3795
|
+
if (isEqual(store.selection, cachedSelection))
|
|
3796
|
+
return;
|
|
3797
|
+
const anchor = getNode(store.selection.anchor.blockId);
|
|
3798
|
+
const focus = getNode(store.selection.focus.blockId);
|
|
3799
|
+
const nativeSelection = window.getSelection();
|
|
3800
|
+
if (anchor && focus) {
|
|
3801
|
+
nativeSelection.setBaseAndExtent(
|
|
3802
|
+
...calcNodeByOffset(anchor, store.selection.anchor.offset),
|
|
3803
|
+
...calcNodeByOffset(focus, store.selection.focus.offset)
|
|
3804
|
+
);
|
|
3805
|
+
}
|
|
3806
|
+
if (store.selection.anchor.blockId === store.selection.focus.blockId && ((_a = store.currentBlock) == null ? void 0 : _a.editable) === false) {
|
|
3807
|
+
const innerText = anchor == null ? void 0 : anchor.querySelector("[data-vw-block-id]");
|
|
3808
|
+
if (innerText) {
|
|
3809
|
+
nativeSelection.setBaseAndExtent(innerText, 0, innerText, 0);
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
cachedSelection = JSON.parse(JSON.stringify(store.selection));
|
|
3813
|
+
};
|
|
3814
|
+
watch(() => store.selection, applySelection, { deep: true, flush: "post" });
|
|
3815
|
+
onMounted(() => {
|
|
3816
|
+
var _a, _b;
|
|
3817
|
+
if (props.autofocus) {
|
|
3818
|
+
(_a = textEditorRef.value) == null ? void 0 : _a.focus();
|
|
3819
|
+
applySelection();
|
|
3820
|
+
}
|
|
3821
|
+
if (props.autoselect) {
|
|
3822
|
+
(_b = textEditorRef.value) == null ? void 0 : _b.focus();
|
|
3823
|
+
store.selectAll();
|
|
3824
|
+
}
|
|
3825
|
+
store.history.push("setText");
|
|
3826
|
+
});
|
|
3827
|
+
const { onCut, onCopy, onPaste } = createClipboardEvents(store, props);
|
|
3828
|
+
const getClientRects = (selection) => {
|
|
3829
|
+
const anchor = getNode(selection.anchor.blockId);
|
|
3830
|
+
const focus = getNode(selection.focus.blockId);
|
|
3831
|
+
if (anchor && focus) {
|
|
3832
|
+
const range = new Range();
|
|
3833
|
+
range.setStart(...calcNodeByOffset(anchor, selection.anchor.offset));
|
|
3834
|
+
range.setEnd(...calcNodeByOffset(focus, selection.focus.offset));
|
|
3835
|
+
return range.getClientRects();
|
|
3836
|
+
}
|
|
3837
|
+
return new DOMRectList();
|
|
3838
|
+
};
|
|
3839
|
+
__expose({
|
|
3840
|
+
currentStyles: store._currentStyles,
|
|
3841
|
+
currentBlock: store._currentBlock,
|
|
3842
|
+
isCollapsed: store._isCollapsed,
|
|
3843
|
+
selection: store.selection,
|
|
3844
|
+
isFocused: store.isFocused,
|
|
3845
|
+
toggleStyle: store.toggleStyle.bind(store),
|
|
3846
|
+
applyStyle: store.applyStyle.bind(store),
|
|
3847
|
+
removeStyle: store.removeStyle.bind(store),
|
|
3848
|
+
insertText: store.insertText.bind(store),
|
|
3849
|
+
insertBlock: store.insertBlock.bind(store),
|
|
3850
|
+
addNewLine: store.addNewLine.bind(store),
|
|
3851
|
+
removeNewLine: store.removeNewLine.bind(store),
|
|
3852
|
+
removeCurrentBlock: store.removeCurrentBlock.bind(store),
|
|
3853
|
+
selectAll: store.selectAll.bind(store),
|
|
3854
|
+
pushHistory: store.history.push.bind(store.history),
|
|
3855
|
+
getClientRects
|
|
3856
|
+
});
|
|
3857
|
+
return (_ctx, _cache) => {
|
|
3858
|
+
return openBlock(), createElementBlock("div", {
|
|
3859
|
+
ref_key: "textEditorRef",
|
|
3860
|
+
ref: textEditorRef,
|
|
3861
|
+
contenteditable: "",
|
|
3862
|
+
onBeforeinput: _cache[0] || (_cache[0] = //@ts-ignore
|
|
3863
|
+
(...args) => unref(store).onInput && unref(store).onInput(...args)),
|
|
3864
|
+
onKeydown: onKeyDown,
|
|
3865
|
+
onCopy: _cache[1] || (_cache[1] = //@ts-ignore
|
|
3866
|
+
(...args) => unref(onCopy) && unref(onCopy)(...args)),
|
|
3867
|
+
onPaste: _cache[2] || (_cache[2] = //@ts-ignore
|
|
3868
|
+
(...args) => unref(onPaste) && unref(onPaste)(...args)),
|
|
3869
|
+
onCut: _cache[3] || (_cache[3] = //@ts-ignore
|
|
3870
|
+
(...args) => unref(onCut) && unref(onCut)(...args))
|
|
3871
|
+
}, [
|
|
3872
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(store).blocks, (block) => {
|
|
3873
|
+
return openBlock(), createBlock(_sfc_main$2$1, {
|
|
3874
|
+
key: block.id,
|
|
3875
|
+
block,
|
|
3876
|
+
slots: unref(slots),
|
|
3877
|
+
renderer: props.renderer,
|
|
3878
|
+
decorator: props.decorator,
|
|
3879
|
+
parser: props.parser,
|
|
3880
|
+
onPostrender: onPostRender
|
|
3881
|
+
}, null, 8, ["block", "slots", "renderer", "decorator", "parser"]);
|
|
3882
|
+
}), 128)),
|
|
3883
|
+
unref(store).blocks.length === 1 && unref(store).blocks[0].text === "" && !unref(store).blocks[0].type ? renderSlot(_ctx.$slots, "placeholder", { key: 0 }) : createCommentVNode("", true)
|
|
3884
|
+
], 544);
|
|
3885
|
+
};
|
|
3886
|
+
}
|
|
3887
|
+
});
|
|
3888
|
+
defineComponent({
|
|
3889
|
+
props: ["modelValue", "decorator", "parser", "styles", "renderer"],
|
|
3890
|
+
setup(props, { slots }) {
|
|
3891
|
+
const blocks = computed(() => {
|
|
3892
|
+
if (Array.isArray(props.modelValue)) {
|
|
3893
|
+
return props.modelValue;
|
|
3894
|
+
}
|
|
3895
|
+
return [{ text: props.modelValue, styles: props.styles ?? [] }];
|
|
3896
|
+
});
|
|
3897
|
+
return () => h("div", blocks.value.map((block) => h(_sfc_main$2$1, {
|
|
3898
|
+
key: block.id,
|
|
3899
|
+
block,
|
|
3900
|
+
slots,
|
|
3901
|
+
decorator: props.decorator,
|
|
3902
|
+
renderer: props.renderer,
|
|
3903
|
+
parser: props.parser,
|
|
3904
|
+
static: true
|
|
3905
|
+
})));
|
|
3906
|
+
}
|
|
3907
|
+
});
|
|
3908
|
+
const defaultDecorator = (style) => {
|
|
3909
|
+
if (style.style === "color") {
|
|
3910
|
+
return { style: `color: ${style.meta.color};` };
|
|
3911
|
+
}
|
|
3912
|
+
if (style.style === "bold") {
|
|
3913
|
+
return { tag: "b" };
|
|
3914
|
+
}
|
|
3915
|
+
if (style.style === "underline") {
|
|
3916
|
+
return { tag: "u" };
|
|
3917
|
+
}
|
|
3918
|
+
if (style.style === "italic") {
|
|
3919
|
+
return { tag: "i" };
|
|
3920
|
+
}
|
|
3921
|
+
if (style.style === "code") {
|
|
3922
|
+
return { class: style.style };
|
|
3923
|
+
}
|
|
3924
|
+
if (style.style === "link") {
|
|
3925
|
+
return { tag: "a", href: style.meta.url };
|
|
3926
|
+
}
|
|
3927
|
+
};
|
|
3928
|
+
const defaultRenderer = (block) => {
|
|
3929
|
+
if (block.type === "h1" || block.type === "h2" || block.type === "h3" || block.type === "li") {
|
|
3930
|
+
return { tag: block.type };
|
|
3931
|
+
}
|
|
3932
|
+
if (block.type === "callout") {
|
|
3933
|
+
return { class: "callout" };
|
|
3934
|
+
}
|
|
3935
|
+
return { tag: "p" };
|
|
3936
|
+
};
|
|
3937
|
+
const codeDecorator = (style) => {
|
|
3938
|
+
if (!style.meta) return {};
|
|
3939
|
+
return { style: `color: ${style.meta.color};` };
|
|
3940
|
+
};
|
|
3941
|
+
const colors = {
|
|
3942
|
+
"const": "#FF457D",
|
|
3943
|
+
"let": "#FF457D",
|
|
3944
|
+
"var": "#FF457D",
|
|
3945
|
+
"new": "#FF457D",
|
|
3946
|
+
"class": "#FF457D",
|
|
3947
|
+
"else": "#FF457D",
|
|
3948
|
+
"if": "#FF457D",
|
|
3949
|
+
"for": "#FF457D",
|
|
3950
|
+
"continue": "#FF457D",
|
|
3951
|
+
"break": "#FF457D",
|
|
3952
|
+
"return": "#FF457D",
|
|
3953
|
+
"function": "#FF457D",
|
|
3954
|
+
"import": "#FF457D",
|
|
3955
|
+
"from": "#FF457D"
|
|
3956
|
+
};
|
|
3957
|
+
const quoteColor = "#032F62";
|
|
3958
|
+
const nextChar = (str, pos) => {
|
|
3959
|
+
for (let i = pos; i < str.length; i++) {
|
|
3960
|
+
if (str[i] !== " ") return str[i];
|
|
3961
|
+
}
|
|
3962
|
+
return null;
|
|
3963
|
+
};
|
|
3964
|
+
const codeParser = (text) => {
|
|
3965
|
+
const arr = [];
|
|
3966
|
+
let j = 0;
|
|
3967
|
+
let quotes = "";
|
|
3968
|
+
let comment = false;
|
|
3969
|
+
for (let i = 0; i <= text.length; i++) {
|
|
3970
|
+
if (comment && i === text.length) {
|
|
3971
|
+
arr.push({ start: j, end: i, style: "code", meta: { color: "#71808F" } });
|
|
3972
|
+
}
|
|
3973
|
+
if (comment) continue;
|
|
3974
|
+
if (text[i] === "/" && text[i + 1] === "/" && !quotes) {
|
|
3975
|
+
comment = true;
|
|
3976
|
+
j = i;
|
|
3977
|
+
continue;
|
|
3978
|
+
}
|
|
3979
|
+
if (quotes !== "" && text[i] === "\\") {
|
|
3980
|
+
i++;
|
|
3981
|
+
continue;
|
|
3982
|
+
}
|
|
3983
|
+
if (i === text.length && quotes !== "" || `"'`.includes(text[i])) {
|
|
3984
|
+
if (quotes !== "") {
|
|
3985
|
+
if (text[i] !== quotes && i !== text.length) continue;
|
|
3986
|
+
arr.push({ start: j, end: i + 1, style: "code", meta: { color: quoteColor } });
|
|
3987
|
+
j = i + 1;
|
|
3988
|
+
quotes = "";
|
|
3989
|
+
} else {
|
|
3990
|
+
quotes = text[i];
|
|
3991
|
+
j = i;
|
|
3992
|
+
}
|
|
3993
|
+
}
|
|
3994
|
+
if (quotes !== "") continue;
|
|
3995
|
+
if (i === text.length || ` ()!-=.,;'"/*`.includes(text[i])) {
|
|
3996
|
+
if (i < j) {
|
|
3997
|
+
continue;
|
|
3998
|
+
}
|
|
3999
|
+
const word = text.slice(j, i);
|
|
4000
|
+
if (nextChar(text, i) === "(") {
|
|
4001
|
+
arr.push({ start: j, end: i, style: "code", meta: { color: "#005CC5" } });
|
|
4002
|
+
} else if (word in colors) {
|
|
4003
|
+
arr.push({ start: j, end: i, style: "code", meta: { color: colors[word] } });
|
|
4004
|
+
} else if (/^-?\d*\.?\d*$/.test(word)) {
|
|
4005
|
+
if (text[i] === ".") continue;
|
|
4006
|
+
arr.push({ start: j, end: i, style: "code", meta: { color: "#005CC5" } });
|
|
4007
|
+
} else if (text[j - 1] === ".") {
|
|
4008
|
+
arr.push({ start: j, end: i, style: "code", meta: { color: "#6F42C1" } });
|
|
4009
|
+
}
|
|
4010
|
+
j = i + 1;
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
4013
|
+
return arr;
|
|
4014
|
+
};
|
|
4015
|
+
const _hoisted_1$d = {
|
|
4016
|
+
class: "code-editor",
|
|
4017
|
+
contenteditable: false
|
|
4018
|
+
};
|
|
4019
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
4020
|
+
__name: "RichTextEditorCode",
|
|
4021
|
+
props: {
|
|
4022
|
+
modelValue: {}
|
|
4023
|
+
},
|
|
4024
|
+
emits: ["update:modelValue", "newblock", "remove"],
|
|
4025
|
+
setup(__props, { emit: __emit }) {
|
|
4026
|
+
const props = __props;
|
|
4027
|
+
const emit = __emit;
|
|
4028
|
+
const model = ref([{ text: "" }]);
|
|
4029
|
+
if (props.modelValue) {
|
|
4030
|
+
model.value = props.modelValue.split("\n").map((text) => ({ text }));
|
|
4031
|
+
}
|
|
4032
|
+
watch(model, () => {
|
|
4033
|
+
emit("update:modelValue", model.value.map((item) => item.text).join("\n"));
|
|
4034
|
+
}, { deep: true });
|
|
4035
|
+
const onKeyDown = (e) => {
|
|
4036
|
+
var _a;
|
|
4037
|
+
if ((e.ctrlKey || e.metaKey) && e.code === "Enter") {
|
|
4038
|
+
e.preventDefault();
|
|
4039
|
+
emit("newblock");
|
|
4040
|
+
}
|
|
4041
|
+
if (e.code === "Backspace" && !e.shiftKey && model.value.length <= 1 && ((_a = model.value[0]) == null ? void 0 : _a.text) === "") {
|
|
4042
|
+
e.preventDefault();
|
|
4043
|
+
emit("remove");
|
|
4044
|
+
}
|
|
4045
|
+
};
|
|
4046
|
+
return (_ctx, _cache) => {
|
|
4047
|
+
return openBlock(), createElementBlock("div", _hoisted_1$d, [
|
|
4048
|
+
createVNode(unref(_sfc_main$1$1), {
|
|
4049
|
+
modelValue: model.value,
|
|
4050
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
|
|
4051
|
+
tabindex: "2",
|
|
4052
|
+
parser: unref(codeParser),
|
|
4053
|
+
decorator: unref(codeDecorator),
|
|
4054
|
+
preventMultiline: "",
|
|
4055
|
+
spellcheck: "false",
|
|
4056
|
+
onKeydown: onKeyDown
|
|
4057
|
+
}, null, 8, ["modelValue", "parser", "decorator"])
|
|
4058
|
+
]);
|
|
4059
|
+
};
|
|
4060
|
+
}
|
|
4061
|
+
});
|
|
4062
|
+
const _sfc_main$e = {};
|
|
4063
|
+
const _hoisted_1$c = {
|
|
4064
|
+
width: "16",
|
|
4065
|
+
height: "16",
|
|
4066
|
+
viewBox: "0 0 16 16",
|
|
4067
|
+
fill: "none",
|
|
4068
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
4069
|
+
};
|
|
4070
|
+
function _sfc_render$5(_ctx, _cache) {
|
|
4071
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$c, _cache[0] || (_cache[0] = [
|
|
4072
|
+
createElementVNode("path", {
|
|
4073
|
+
d: "M4 2H8.5C9.14255 2.0002 9.77266 2.17723 10.3213 2.51171C10.8699 2.84618 11.3159 3.32519 11.6105 3.89627C11.905 4.46734 12.0367 5.10846 11.9911 5.7494C11.9455 6.39033 11.7244 7.00636 11.352 7.53C11.9979 7.93183 12.4953 8.53322 12.7688 9.24307C13.0423 9.95292 13.077 10.7326 12.8676 11.4639C12.6583 12.1952 12.2163 12.8384 11.6086 13.2961C11.001 13.7537 10.2607 14.0008 9.5 14H4C3.73478 14 3.48043 13.8946 3.29289 13.7071C3.10536 13.5196 3 13.2652 3 13V3C3 2.73478 3.10536 2.48043 3.29289 2.29289C3.48043 2.10536 3.73478 2 4 2ZM5 9V12H9.5C9.89782 12 10.2794 11.842 10.5607 11.5607C10.842 11.2794 11 10.8978 11 10.5C11 10.1022 10.842 9.72064 10.5607 9.43934C10.2794 9.15804 9.89782 9 9.5 9H5ZM8.5 7C8.89782 7 9.27936 6.84196 9.56066 6.56066C9.84196 6.27936 10 5.89782 10 5.5C10 5.10218 9.84196 4.72064 9.56066 4.43934C9.27936 4.15804 8.89782 4 8.5 4H5V7H8.5Z",
|
|
4074
|
+
fill: "currentColor"
|
|
4075
|
+
}, null, -1)
|
|
4076
|
+
]));
|
|
4077
|
+
}
|
|
4078
|
+
const TextBoldIcon = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$5]]);
|
|
4079
|
+
const _sfc_main$d = {};
|
|
4080
|
+
const _hoisted_1$b = {
|
|
4081
|
+
width: "16",
|
|
4082
|
+
height: "16",
|
|
4083
|
+
viewBox: "0 0 16 16",
|
|
4084
|
+
fill: "none",
|
|
4085
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
4086
|
+
};
|
|
4087
|
+
function _sfc_render$4(_ctx, _cache) {
|
|
4088
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$b, _cache[0] || (_cache[0] = [
|
|
4089
|
+
createElementVNode("path", {
|
|
4090
|
+
d: "M6 2.75C6 2.55109 6.07902 2.36032 6.21967 2.21967C6.36032 2.07902 6.55109 2 6.75 2H13.25C13.4489 2 13.6397 2.07902 13.7803 2.21967C13.921 2.36032 14 2.55109 14 2.75C14 2.94891 13.921 3.13968 13.7803 3.28033C13.6397 3.42098 13.4489 3.5 13.25 3.5H10.745L6.887 12.5H9.25C9.44891 12.5 9.63968 12.579 9.78033 12.7197C9.92098 12.8603 10 13.0511 10 13.25C10 13.4489 9.92098 13.6397 9.78033 13.7803C9.63968 13.921 9.44891 14 9.25 14H2.75C2.55109 14 2.36032 13.921 2.21967 13.7803C2.07902 13.6397 2 13.4489 2 13.25C2 13.0511 2.07902 12.8603 2.21967 12.7197C2.36032 12.579 2.55109 12.5 2.75 12.5H5.255L9.113 3.5H6.75C6.55109 3.5 6.36032 3.42098 6.21967 3.28033C6.07902 3.13968 6 2.94891 6 2.75Z",
|
|
4091
|
+
fill: "currentColor"
|
|
4092
|
+
}, null, -1)
|
|
4093
|
+
]));
|
|
4094
|
+
}
|
|
4095
|
+
const TextItalicIcon = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$4]]);
|
|
4096
|
+
const _sfc_main$c = {};
|
|
4097
|
+
const _hoisted_1$a = {
|
|
4098
|
+
width: "16",
|
|
4099
|
+
height: "16",
|
|
4100
|
+
viewBox: "0 0 16 16",
|
|
4101
|
+
fill: "none",
|
|
4102
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
4103
|
+
};
|
|
4104
|
+
function _sfc_render$3(_ctx, _cache) {
|
|
4105
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$a, _cache[0] || (_cache[0] = [
|
|
4106
|
+
createElementVNode("path", {
|
|
4107
|
+
d: "M8 11.0625C9.16032 11.0625 10.2731 10.6016 11.0936 9.78109C11.9141 8.96062 12.375 7.84782 12.375 6.6875V2.3125C12.375 2.08044 12.2828 1.85788 12.1187 1.69378C11.9546 1.52969 11.7321 1.4375 11.5 1.4375C11.2679 1.4375 11.0454 1.52969 10.8813 1.69378C10.7172 1.85788 10.625 2.08044 10.625 2.3125V6.6875C10.625 7.38369 10.3484 8.05137 9.85616 8.54366C9.36387 9.03594 8.69619 9.3125 8 9.3125C7.30381 9.3125 6.63613 9.03594 6.14384 8.54366C5.65156 8.05137 5.375 7.38369 5.375 6.6875V2.3125C5.375 2.08044 5.28281 1.85788 5.11872 1.69378C4.95462 1.52969 4.73206 1.4375 4.5 1.4375C4.26794 1.4375 4.04538 1.52969 3.88128 1.69378C3.71719 1.85788 3.625 2.08044 3.625 2.3125V6.6875C3.625 7.84782 4.08594 8.96062 4.90641 9.78109C5.72688 10.6016 6.83968 11.0625 8 11.0625ZM12.375 12.8125H3.625C3.39294 12.8125 3.17038 12.9047 3.00628 13.0688C2.84219 13.2329 2.75 13.4554 2.75 13.6875C2.75 13.9196 2.84219 14.1421 3.00628 14.3062C3.17038 14.4703 3.39294 14.5625 3.625 14.5625H12.375C12.6071 14.5625 12.8296 14.4703 12.9937 14.3062C13.1578 14.1421 13.25 13.9196 13.25 13.6875C13.25 13.4554 13.1578 13.2329 12.9937 13.0688C12.8296 12.9047 12.6071 12.8125 12.375 12.8125Z",
|
|
4108
|
+
fill: "currentColor"
|
|
4109
|
+
}, null, -1)
|
|
4110
|
+
]));
|
|
4111
|
+
}
|
|
4112
|
+
const TextUnderlineIcon = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$3]]);
|
|
4113
|
+
const _sfc_main$b = {};
|
|
4114
|
+
const _hoisted_1$9 = {
|
|
4115
|
+
width: "16",
|
|
4116
|
+
height: "16",
|
|
4117
|
+
viewBox: "0 0 16 16",
|
|
4118
|
+
fill: "none",
|
|
4119
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
4120
|
+
};
|
|
4121
|
+
function _sfc_render$2(_ctx, _cache) {
|
|
4122
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$9, _cache[0] || (_cache[0] = [
|
|
4123
|
+
createElementVNode("path", {
|
|
4124
|
+
d: "M11.055 8.5C11.579 9.036 11.87 9.757 11.866 10.507C11.8673 10.9659 11.7676 11.4195 11.574 11.8357C11.3805 12.2518 11.0978 12.6203 10.746 12.915C9.948 13.597 8.748 14 7.096 14C5.39 14 3.992 13.393 3.194 12.623C3.06263 12.4823 2.99028 12.2966 2.99188 12.1041C2.99349 11.9117 3.06893 11.7272 3.20264 11.5887C3.33634 11.4503 3.5181 11.3684 3.7104 11.3601C3.90269 11.3518 4.09084 11.4176 4.236 11.544C4.716 12.007 5.723 12.5 7.096 12.5C8.518 12.5 9.328 12.154 9.772 11.774C10.207 11.402 10.366 10.935 10.366 10.507C10.366 10.035 10.158 9.65 9.719 9.31C9.271 8.964 8.603 8.687 7.768 8.5H1.75C1.55109 8.5 1.36032 8.42098 1.21967 8.28033C1.07902 8.13968 1 7.94891 1 7.75C1 7.55109 1.07902 7.36032 1.21967 7.21967C1.36032 7.07902 1.55109 7 1.75 7H14.25C14.4489 7 14.6397 7.07902 14.7803 7.21967C14.921 7.36032 15 7.55109 15 7.75C15 7.94891 14.921 8.13968 14.7803 8.28033C14.6397 8.42098 14.4489 8.5 14.25 8.5H11.055ZM7.581 3.25C5.545 3.25 4.803 4.332 4.803 5.036C4.803 5.09067 4.805 5.143 4.809 5.193C4.82412 5.39138 4.75981 5.58764 4.63022 5.73861C4.50063 5.88958 4.31638 5.98288 4.118 5.998C3.91962 6.01312 3.72336 5.94881 3.57239 5.81922C3.42142 5.68963 3.32812 5.50538 3.313 5.307C3.3066 5.21681 3.30327 5.12642 3.303 5.036C3.303 3.204 5.053 1.75 7.581 1.75C8.999 1.75 10.302 2.33 11.095 2.843C11.1777 2.89645 11.2491 2.96567 11.3051 3.04671C11.3611 3.12775 11.4006 3.21902 11.4213 3.31532C11.442 3.41161 11.4435 3.51104 11.4258 3.60793C11.4081 3.70482 11.3714 3.79727 11.318 3.88C11.2646 3.96273 11.1953 4.03413 11.1143 4.09011C11.0333 4.14609 10.942 4.18556 10.8457 4.20627C10.7494 4.22698 10.65 4.22852 10.5531 4.2108C10.4562 4.19308 10.3637 4.15645 10.281 4.103C9.641 3.689 8.619 3.25 7.581 3.25Z",
|
|
4125
|
+
fill: "currentColor"
|
|
4126
|
+
}, null, -1)
|
|
4127
|
+
]));
|
|
4128
|
+
}
|
|
4129
|
+
const TextStrikethroughIcon = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$2]]);
|
|
4130
|
+
const _sfc_main$a = {};
|
|
4131
|
+
const _hoisted_1$8 = {
|
|
4132
|
+
width: "16",
|
|
4133
|
+
height: "16",
|
|
4134
|
+
viewBox: "0 0 16 16",
|
|
4135
|
+
fill: "none",
|
|
4136
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
4137
|
+
};
|
|
4138
|
+
function _sfc_render$1(_ctx, _cache) {
|
|
4139
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$8, _cache[0] || (_cache[0] = [
|
|
4140
|
+
createElementVNode("path", {
|
|
4141
|
+
d: "M14.8574 13.3334V2.66669C14.8574 1.8286 14.1716 1.14288 13.3335 1.14288H2.66688C1.82878 1.14288 1.14307 1.8286 1.14307 2.66669V13.3334C1.14307 14.1715 1.82878 14.8572 2.66688 14.8572H13.3335C14.1716 14.8572 14.8574 14.1715 14.8574 13.3334ZM5.33354 9.14288L7.2383 11.4362L9.90497 8.00003L13.3335 12.5715H2.66688L5.33354 9.14288Z",
|
|
4142
|
+
fill: "currentColor"
|
|
4143
|
+
}, null, -1)
|
|
4144
|
+
]));
|
|
4145
|
+
}
|
|
4146
|
+
const ImageSolidIcon = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$1]]);
|
|
4147
|
+
const _sfc_main$9 = {};
|
|
4148
|
+
const _hoisted_1$7 = {
|
|
4149
|
+
width: "16",
|
|
4150
|
+
height: "16",
|
|
4151
|
+
viewBox: "0 0 16 16",
|
|
4152
|
+
fill: "none",
|
|
4153
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
4154
|
+
};
|
|
4155
|
+
function _sfc_render(_ctx, _cache) {
|
|
4156
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$7, _cache[0] || (_cache[0] = [
|
|
4157
|
+
createElementVNode("path", {
|
|
4158
|
+
d: "M10.189 2.04806C10.605 2.19806 10.8186 2.65181 10.6674 3.06281L6.83704 13.4788C6.68504 13.8898 6.22664 14.1013 5.81144 13.9521C5.39544 13.8021 5.18184 13.3483 5.33304 12.9373L9.16344 2.52131C9.31544 2.11031 9.77384 1.89881 10.189 2.04806ZM1.93144 8.19206L4.76024 10.9926C5.07224 11.3016 5.07224 11.8026 4.76024 12.1116C4.68811 12.1847 4.60063 12.243 4.50329 12.2829C4.40596 12.3228 4.30087 12.3434 4.19464 12.3434C4.08841 12.3434 3.98332 12.3228 3.88599 12.2829C3.78865 12.243 3.70117 12.1847 3.62904 12.1116L0.234639 8.75231C0.084409 8.59988 0.000976562 8.39997 0.000976562 8.19244C0.000976562 7.9849 0.084409 7.78499 0.234639 7.63256L3.62904 4.27256C3.70117 4.19944 3.78865 4.1411 3.88599 4.1012C3.98332 4.0613 4.08841 4.0407 4.19464 4.0407C4.30087 4.0407 4.40596 4.0613 4.50329 4.1012C4.60063 4.1411 4.68811 4.19944 4.76024 4.27256C4.9107 4.42503 4.99427 4.6251 4.99427 4.83281C4.99427 5.04052 4.9107 5.24059 4.76024 5.39306L1.93144 8.19206ZM14.069 8.19206L11.2402 5.39306C11.09 5.24063 11.0066 5.04072 11.0066 4.83319C11.0066 4.62565 11.09 4.42574 11.2402 4.27331C11.3124 4.20019 11.3998 4.14185 11.4972 4.10195C11.5945 4.06205 11.6996 4.04145 11.8058 4.04145C11.9121 4.04145 12.0172 4.06205 12.1145 4.10195C12.2118 4.14185 12.2993 4.20019 12.3714 4.27331L15.7658 7.63256C16.0778 7.94156 16.0778 8.44256 15.7658 8.75231L12.3714 12.1108C12.2993 12.1839 12.2118 12.2423 12.1145 12.2822C12.0172 12.3221 11.9121 12.3427 11.8058 12.3427C11.6996 12.3427 11.5945 12.3221 11.4972 12.2822C11.3998 12.2423 11.3124 12.1839 11.2402 12.1108C11.0902 11.9584 11.0069 11.7587 11.0069 11.5513C11.0069 11.344 11.0902 11.1442 11.2402 10.9918L14.069 8.19206Z",
|
|
4159
|
+
fill: "currentColor"
|
|
4160
|
+
}, null, -1)
|
|
4161
|
+
]));
|
|
4162
|
+
}
|
|
4163
|
+
const CodeIcon = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render]]);
|
|
4164
|
+
const _hoisted_1$6 = { class: "rich-text-editor__controls" };
|
|
4165
|
+
const _hoisted_2$2 = { class: "rich-text-editor__actions-group" };
|
|
4166
|
+
const _hoisted_3 = ["onClick"];
|
|
4167
|
+
const _hoisted_4 = { class: "rich-text-editor__actions-group" };
|
|
4168
|
+
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
4169
|
+
__name: "RichTextEditorDialog",
|
|
4170
|
+
props: /* @__PURE__ */ mergeModels({
|
|
4171
|
+
label: {}
|
|
4172
|
+
}, {
|
|
4173
|
+
"modelValue": {},
|
|
4174
|
+
"modelModifiers": {}
|
|
4175
|
+
}),
|
|
4176
|
+
emits: ["update:modelValue"],
|
|
4177
|
+
setup(__props) {
|
|
4178
|
+
const props = __props;
|
|
4179
|
+
const model = useModel(__props, "modelValue");
|
|
4180
|
+
if (!model.value || model.value.length === 0) {
|
|
4181
|
+
model.value = [{ text: "" }];
|
|
4182
|
+
}
|
|
4183
|
+
const blockTypes = [
|
|
4184
|
+
{ id: "default", title: "Обычный текст" },
|
|
4185
|
+
{ id: "h1", title: "Заголовок 1" },
|
|
4186
|
+
{ id: "h2", title: "Заголовок 2" },
|
|
4187
|
+
{ id: "h3", title: "Заголовок 3" },
|
|
4188
|
+
{ id: "li", title: "Список" },
|
|
4189
|
+
{ id: "callout", title: "Callout" },
|
|
4190
|
+
{ id: "code", title: "Элемент кода" }
|
|
4191
|
+
];
|
|
4192
|
+
const textEditorRef = shallowRef();
|
|
4193
|
+
const blockType = computed({
|
|
4194
|
+
get() {
|
|
4195
|
+
var _a, _b;
|
|
4196
|
+
return ((_b = (_a = textEditorRef.value) == null ? void 0 : _a.currentBlock) == null ? void 0 : _b.type) ?? "default";
|
|
4197
|
+
},
|
|
4198
|
+
set(type) {
|
|
4199
|
+
var _a;
|
|
4200
|
+
if (!((_a = textEditorRef.value) == null ? void 0 : _a.currentBlock)) return;
|
|
4201
|
+
if (type === "default") {
|
|
4202
|
+
delete textEditorRef.value.currentBlock.type;
|
|
4203
|
+
} else {
|
|
4204
|
+
textEditorRef.value.currentBlock.type = type ?? void 0;
|
|
4205
|
+
}
|
|
4206
|
+
if (type === "code") {
|
|
4207
|
+
textEditorRef.value.currentBlock.editable = false;
|
|
4208
|
+
} else {
|
|
4209
|
+
delete textEditorRef.value.currentBlock.editable;
|
|
4210
|
+
}
|
|
4211
|
+
}
|
|
4212
|
+
});
|
|
4213
|
+
const styles = computed(() => {
|
|
4214
|
+
const textEditor = textEditorRef.value;
|
|
4215
|
+
if (!textEditor) return [];
|
|
4216
|
+
const currentStyles = textEditor.currentStyles;
|
|
4217
|
+
return [
|
|
4218
|
+
{ icon: TextBoldIcon, active: currentStyles.has("bold"), onClick: () => textEditor.toggleStyle("bold") },
|
|
4219
|
+
{ icon: TextItalicIcon, active: currentStyles.has("italic"), onClick: () => textEditor.toggleStyle("italic") },
|
|
4220
|
+
{ icon: TextUnderlineIcon, active: currentStyles.has("underline"), onClick: () => textEditor.toggleStyle("underline") },
|
|
4221
|
+
{ icon: TextStrikethroughIcon, active: currentStyles.has("strikethrough"), onClick: () => textEditor.toggleStyle("strikethrough") }
|
|
4222
|
+
];
|
|
4223
|
+
});
|
|
4224
|
+
const onKeyDown = (e) => {
|
|
4225
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4226
|
+
if ((e.ctrlKey || e.metaKey) && !e.shiftKey && !e.altKey) {
|
|
4227
|
+
if (e.code === "KeyB") {
|
|
4228
|
+
(_a = textEditorRef.value) == null ? void 0 : _a.toggleStyle("bold");
|
|
4229
|
+
}
|
|
4230
|
+
if (e.code === "KeyI") {
|
|
4231
|
+
(_b = textEditorRef.value) == null ? void 0 : _b.toggleStyle("italic");
|
|
4232
|
+
}
|
|
4233
|
+
if (e.code === "KeyU") {
|
|
4234
|
+
(_c = textEditorRef.value) == null ? void 0 : _c.toggleStyle("underline");
|
|
4235
|
+
}
|
|
4236
|
+
}
|
|
4237
|
+
if (e.key === "Enter" && !e.shiftKey && ((_e = (_d = textEditorRef.value) == null ? void 0 : _d.currentBlock) == null ? void 0 : _e.type) === "li") {
|
|
4238
|
+
e.preventDefault();
|
|
4239
|
+
textEditorRef.value.addNewLine();
|
|
4240
|
+
textEditorRef.value.currentBlock.type = "li";
|
|
4241
|
+
textEditorRef.value.pushHistory("setText");
|
|
4242
|
+
}
|
|
4243
|
+
if (((_g = (_f = textEditorRef.value) == null ? void 0 : _f.currentBlock) == null ? void 0 : _g.editable) === false && textEditorRef.value.currentBlock.type !== "code" && (e.code === "Backspace" || e.code === "Delete")) {
|
|
4244
|
+
textEditorRef.value.removeCurrentBlock();
|
|
4245
|
+
e.preventDefault();
|
|
4246
|
+
}
|
|
4247
|
+
};
|
|
4248
|
+
const insertCodeBlock = () => {
|
|
4249
|
+
var _a;
|
|
4250
|
+
(_a = textEditorRef.value) == null ? void 0 : _a.insertBlock({ type: "code", editable: false, text: "" });
|
|
4251
|
+
};
|
|
4252
|
+
const insertImage = () => {
|
|
4253
|
+
var _a;
|
|
4254
|
+
(_a = textEditorRef.value) == null ? void 0 : _a.insertBlock({ type: "image", editable: false, text: "" });
|
|
4255
|
+
};
|
|
4256
|
+
return (_ctx, _cache) => {
|
|
4257
|
+
return openBlock(), createBlock(_sfc_main$m, { class: "rich-text-editor__dialog" }, {
|
|
4258
|
+
header: withCtx(() => [
|
|
4259
|
+
createTextVNode(toDisplayString(props.label ?? "Редактирование текста"), 1)
|
|
4260
|
+
]),
|
|
4261
|
+
default: withCtx(() => [
|
|
4262
|
+
createElementVNode("div", _hoisted_1$6, [
|
|
4263
|
+
createVNode(_sfc_main$t, {
|
|
4264
|
+
modelValue: blockType.value,
|
|
4265
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => blockType.value = $event),
|
|
4266
|
+
items: blockTypes,
|
|
4267
|
+
style: { "width": "200px" }
|
|
4268
|
+
}, null, 8, ["modelValue"]),
|
|
4269
|
+
createElementVNode("div", _hoisted_2$2, [
|
|
4270
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(styles.value, (item) => {
|
|
4271
|
+
return openBlock(), createElementBlock("button", {
|
|
4272
|
+
class: normalizeClass({ active: item.active }),
|
|
4273
|
+
onClick: item.onClick
|
|
4274
|
+
}, [
|
|
4275
|
+
(openBlock(), createBlock(resolveDynamicComponent(item.icon)))
|
|
4276
|
+
], 10, _hoisted_3);
|
|
4277
|
+
}), 256))
|
|
4278
|
+
]),
|
|
4279
|
+
createElementVNode("div", _hoisted_4, [
|
|
4280
|
+
createElementVNode("button", {
|
|
4281
|
+
title: "Вставить изображение",
|
|
4282
|
+
onClick: insertImage
|
|
4283
|
+
}, [
|
|
4284
|
+
createVNode(ImageSolidIcon)
|
|
4285
|
+
]),
|
|
4286
|
+
createElementVNode("button", {
|
|
4287
|
+
title: "Вставить элемент кода",
|
|
4288
|
+
onClick: insertCodeBlock
|
|
4289
|
+
}, [
|
|
4290
|
+
createVNode(CodeIcon)
|
|
4291
|
+
])
|
|
4292
|
+
])
|
|
4293
|
+
]),
|
|
4294
|
+
createVNode(unref(_sfc_main$1$1), {
|
|
4295
|
+
ref_key: "textEditorRef",
|
|
4296
|
+
ref: textEditorRef,
|
|
4297
|
+
modelValue: model.value,
|
|
4298
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => model.value = $event),
|
|
4299
|
+
class: "text-editor",
|
|
4300
|
+
renderer: unref(defaultRenderer),
|
|
4301
|
+
decorator: unref(defaultDecorator),
|
|
4302
|
+
onKeydown: onKeyDown
|
|
4303
|
+
}, {
|
|
4304
|
+
code: withCtx(({ props: props2, block }) => [
|
|
4305
|
+
createVNode(_sfc_main$f, mergeProps({
|
|
4306
|
+
modelValue: block.text,
|
|
4307
|
+
"onUpdate:modelValue": ($event) => block.text = $event
|
|
4308
|
+
}, props2, {
|
|
4309
|
+
onNewblock: _cache[1] || (_cache[1] = ($event) => {
|
|
4310
|
+
var _a;
|
|
4311
|
+
return (_a = textEditorRef.value) == null ? void 0 : _a.addNewLine();
|
|
4312
|
+
}),
|
|
4313
|
+
onRemove: _cache[2] || (_cache[2] = ($event) => {
|
|
4314
|
+
var _a;
|
|
4315
|
+
return (_a = textEditorRef.value) == null ? void 0 : _a.removeCurrentBlock();
|
|
4316
|
+
})
|
|
4317
|
+
}), null, 16, ["modelValue", "onUpdate:modelValue"])
|
|
4318
|
+
]),
|
|
4319
|
+
image: withCtx(({ props: props2, block }) => {
|
|
4320
|
+
var _a;
|
|
4321
|
+
return [
|
|
4322
|
+
createVNode(_sfc_main$k, mergeProps({
|
|
4323
|
+
modelValue: block.image,
|
|
4324
|
+
"onUpdate:modelValue": ($event) => block.image = $event
|
|
4325
|
+
}, props2, {
|
|
4326
|
+
class: { selected: ((_a = textEditorRef.value) == null ? void 0 : _a.selection.focus.blockId) === block.id },
|
|
4327
|
+
contenteditable: "false",
|
|
4328
|
+
onKeydown: onKeyDown
|
|
4329
|
+
}), null, 16, ["modelValue", "onUpdate:modelValue", "class"])
|
|
4330
|
+
];
|
|
4331
|
+
}),
|
|
4332
|
+
placeholder: withCtx(() => _cache[4] || (_cache[4] = [
|
|
4333
|
+
createElementVNode("div", {
|
|
4334
|
+
class: "rich-text-editor__placeholder",
|
|
4335
|
+
contenteditable: false
|
|
4336
|
+
}, "Введите текст...", -1)
|
|
4337
|
+
])),
|
|
4338
|
+
_: 1
|
|
4339
|
+
}, 8, ["modelValue", "renderer", "decorator"])
|
|
4340
|
+
]),
|
|
4341
|
+
_: 1
|
|
4342
|
+
});
|
|
4343
|
+
};
|
|
4344
|
+
}
|
|
4345
|
+
});
|
|
4346
|
+
const _hoisted_1$5 = { class: "v-form-control__outline" };
|
|
4347
|
+
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
4348
|
+
__name: "VRichTextEditor",
|
|
4349
|
+
props: /* @__PURE__ */ mergeModels({
|
|
4350
|
+
label: {}
|
|
4351
|
+
}, {
|
|
4352
|
+
"modelValue": {},
|
|
4353
|
+
"modelModifiers": {}
|
|
4354
|
+
}),
|
|
4355
|
+
emits: ["update:modelValue"],
|
|
4356
|
+
setup(__props) {
|
|
4357
|
+
const props = __props;
|
|
4358
|
+
const model = useModel(__props, "modelValue");
|
|
4359
|
+
const dialog = useDialog();
|
|
4360
|
+
const openTextEditor = () => {
|
|
4361
|
+
dialog.open(_sfc_main$8, {
|
|
4362
|
+
label: props.label,
|
|
4363
|
+
modelValue: model.value,
|
|
4364
|
+
["onUpdate:modelValue"]: (val) => model.value = val
|
|
4365
|
+
});
|
|
4366
|
+
};
|
|
4367
|
+
return (_ctx, _cache) => {
|
|
4368
|
+
return openBlock(), createBlock(_sfc_main$E, {
|
|
4369
|
+
label: props.label,
|
|
4370
|
+
class: "rich-text-editor"
|
|
4371
|
+
}, {
|
|
4372
|
+
default: withCtx(() => [
|
|
4373
|
+
createElementVNode("div", _hoisted_1$5, [
|
|
4374
|
+
createVNode(unref(_sfc_main$1$1), {
|
|
4375
|
+
modelValue: model.value,
|
|
4376
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
|
|
4377
|
+
class: "rich-text-editor__editor"
|
|
4378
|
+
}, null, 8, ["modelValue"])
|
|
4379
|
+
]),
|
|
4380
|
+
createVNode(_sfc_main$p, { onClick: openTextEditor }, {
|
|
4381
|
+
default: withCtx(() => _cache[1] || (_cache[1] = [
|
|
4382
|
+
createTextVNode("Редактировать")
|
|
4383
|
+
])),
|
|
4384
|
+
_: 1,
|
|
4385
|
+
__: [1]
|
|
4386
|
+
})
|
|
4387
|
+
]),
|
|
4388
|
+
_: 1
|
|
4389
|
+
}, 8, ["label"]);
|
|
4390
|
+
};
|
|
4391
|
+
}
|
|
4392
|
+
});
|
|
4393
|
+
const _hoisted_1$4 = {
|
|
4394
|
+
key: 3,
|
|
4395
|
+
class: "json-editor__object"
|
|
4396
|
+
};
|
|
4397
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
4398
|
+
__name: "JsonEditor",
|
|
4399
|
+
props: /* @__PURE__ */ mergeModels({
|
|
4400
|
+
schema: {},
|
|
4401
|
+
name: {},
|
|
4402
|
+
flat: { type: Boolean },
|
|
4403
|
+
expanded: { type: Boolean },
|
|
4404
|
+
nullable: { type: Boolean }
|
|
4405
|
+
}, {
|
|
4406
|
+
"modelValue": {},
|
|
4407
|
+
"modelModifiers": {}
|
|
4408
|
+
}),
|
|
4409
|
+
emits: ["update:modelValue"],
|
|
4410
|
+
setup(__props) {
|
|
4411
|
+
const props = __props;
|
|
4412
|
+
const childExpanded = props.schema.type === "object" && Object.keys(props.schema.properties).length < 2;
|
|
4413
|
+
const vModel = useModel(__props, "modelValue");
|
|
4414
|
+
if (vModel.value !== null && vModel.value !== void 0) {
|
|
4415
|
+
if (props.schema.type === "object" && typeof vModel.value !== "object") {
|
|
4416
|
+
vModel.value = getDefaultValue(props.schema);
|
|
4417
|
+
}
|
|
4418
|
+
}
|
|
4419
|
+
const getItems = (schema) => {
|
|
4420
|
+
return schema.enum.map((item, index) => {
|
|
4421
|
+
var _a;
|
|
4422
|
+
return {
|
|
4423
|
+
id: item,
|
|
4424
|
+
title: ((_a = schema.enumAlias) == null ? void 0 : _a[index]) ?? spaceCamelCase(item)
|
|
2790
4425
|
};
|
|
2791
4426
|
});
|
|
2792
4427
|
};
|
|
2793
4428
|
return (_ctx, _cache) => {
|
|
2794
4429
|
const _component_JsonEditor = resolveComponent("JsonEditor", true);
|
|
2795
|
-
return props.schema.type === "object" && props.schema.format === "image" ? (openBlock(), createBlock(_sfc_main$
|
|
4430
|
+
return props.schema.type === "object" && props.schema.format === "image" ? (openBlock(), createBlock(_sfc_main$k, {
|
|
2796
4431
|
key: 0,
|
|
2797
4432
|
modelValue: vModel.value,
|
|
2798
4433
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => vModel.value = $event),
|
|
2799
4434
|
label: props.schema.name ?? props.name,
|
|
2800
4435
|
schema: props.schema
|
|
2801
|
-
}, null, 8, ["modelValue", "label", "schema"])) : props.schema.type === "object" && props.schema.format === "
|
|
4436
|
+
}, null, 8, ["modelValue", "label", "schema"])) : props.schema.type === "object" && props.schema.format === "smartLink" ? (openBlock(), createBlock(_sfc_main$g, {
|
|
2802
4437
|
key: 1,
|
|
2803
4438
|
modelValue: vModel.value,
|
|
2804
4439
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => vModel.value = $event),
|
|
2805
4440
|
label: props.schema.name ?? props.name,
|
|
2806
4441
|
schema: props.schema,
|
|
2807
4442
|
nullable: props.schema.nullable || props.nullable
|
|
2808
|
-
}, null, 8, ["modelValue", "label", "schema", "nullable"])) : props.schema.type === "
|
|
4443
|
+
}, null, 8, ["modelValue", "label", "schema", "nullable"])) : props.schema.type === "array" && props.schema.format === "richText" ? (openBlock(), createBlock(_sfc_main$7, {
|
|
4444
|
+
key: 2,
|
|
4445
|
+
modelValue: vModel.value,
|
|
4446
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => vModel.value = $event),
|
|
4447
|
+
label: props.schema.name ?? props.name,
|
|
4448
|
+
schema: props.schema
|
|
4449
|
+
}, null, 8, ["modelValue", "label", "schema"])) : props.schema.type === "object" ? (openBlock(), createElementBlock("div", _hoisted_1$4, [
|
|
2809
4450
|
props.flat ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(props.schema.properties, (item, key) => {
|
|
2810
4451
|
var _a;
|
|
2811
4452
|
return openBlock(), createBlock(_component_JsonEditor, {
|
|
@@ -2817,7 +4458,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
2817
4458
|
name: unref(spaceCamelCase)(key),
|
|
2818
4459
|
nullable: !((_a = props.schema.required) == null ? void 0 : _a.includes(key))
|
|
2819
4460
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "schema", "expanded", "name", "nullable"]);
|
|
2820
|
-
}), 128)) : (openBlock(), createBlock(_sfc_main$
|
|
4461
|
+
}), 128)) : (openBlock(), createBlock(_sfc_main$y, {
|
|
2821
4462
|
key: 1,
|
|
2822
4463
|
label: props.schema.name ?? props.name,
|
|
2823
4464
|
open: props.expanded
|
|
@@ -2838,29 +4479,29 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
2838
4479
|
]),
|
|
2839
4480
|
_: 1
|
|
2840
4481
|
}, 8, ["label", "open"]))
|
|
2841
|
-
])) : props.schema.type === "array" ? (openBlock(), createBlock(_sfc_main$
|
|
2842
|
-
key:
|
|
4482
|
+
])) : props.schema.type === "array" ? (openBlock(), createBlock(_sfc_main$s, {
|
|
4483
|
+
key: 4,
|
|
2843
4484
|
modelValue: vModel.value,
|
|
2844
|
-
"onUpdate:modelValue": _cache[
|
|
4485
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => vModel.value = $event),
|
|
2845
4486
|
schema: props.schema,
|
|
2846
4487
|
label: props.schema.name ?? props.name,
|
|
2847
4488
|
expanded: props.expanded
|
|
2848
|
-
}, null, 8, ["modelValue", "schema", "label", "expanded"])) : props.schema.type === "string" && props.schema.enum ? (openBlock(), createBlock(_sfc_main$
|
|
2849
|
-
key:
|
|
4489
|
+
}, null, 8, ["modelValue", "schema", "label", "expanded"])) : props.schema.type === "string" && props.schema.enum ? (openBlock(), createBlock(_sfc_main$t, {
|
|
4490
|
+
key: 5,
|
|
2850
4491
|
nullable: props.schema.nullable || props.nullable,
|
|
2851
4492
|
items: getItems(props.schema),
|
|
2852
4493
|
modelValue: vModel.value,
|
|
2853
|
-
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => vModel.value = $event),
|
|
2854
|
-
label: props.schema.name ?? props.name
|
|
2855
|
-
}, null, 8, ["nullable", "items", "modelValue", "label"])) : props.schema.type === "boolean" ? (openBlock(), createBlock(_sfc_main$9, {
|
|
2856
|
-
key: 5,
|
|
2857
|
-
modelValue: vModel.value,
|
|
2858
4494
|
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => vModel.value = $event),
|
|
2859
4495
|
label: props.schema.name ?? props.name
|
|
2860
|
-
}, null, 8, ["modelValue", "label"])) : (openBlock(), createBlock(_sfc_main$
|
|
4496
|
+
}, null, 8, ["nullable", "items", "modelValue", "label"])) : props.schema.type === "boolean" ? (openBlock(), createBlock(_sfc_main$i, {
|
|
2861
4497
|
key: 6,
|
|
2862
4498
|
modelValue: vModel.value,
|
|
2863
4499
|
"onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => vModel.value = $event),
|
|
4500
|
+
label: props.schema.name ?? props.name
|
|
4501
|
+
}, null, 8, ["modelValue", "label"])) : (openBlock(), createBlock(_sfc_main$D, {
|
|
4502
|
+
key: 7,
|
|
4503
|
+
modelValue: vModel.value,
|
|
4504
|
+
"onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => vModel.value = $event),
|
|
2864
4505
|
label: props.schema.name ?? props.name,
|
|
2865
4506
|
multiline: props.schema.multiline
|
|
2866
4507
|
}, null, 8, ["modelValue", "label", "multiline"]));
|
|
@@ -2928,8 +4569,8 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
2928
4569
|
}
|
|
2929
4570
|
}, { immediate: true });
|
|
2930
4571
|
const settingSelectItems = [
|
|
2931
|
-
{ id: "
|
|
2932
|
-
{ id: "
|
|
4572
|
+
{ id: "page", title: "Только для этой страницы" },
|
|
4573
|
+
{ id: "site", title: "Для всего сайта" }
|
|
2933
4574
|
];
|
|
2934
4575
|
return (_ctx, _cache) => {
|
|
2935
4576
|
return openBlock(), createElementBlock("div", {
|
|
@@ -2938,14 +4579,14 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
2938
4579
|
}, ["stop"]))
|
|
2939
4580
|
}, [
|
|
2940
4581
|
renderSlot(_ctx.$slots, "default"),
|
|
2941
|
-
createVNode(_sfc_main$
|
|
4582
|
+
createVNode(_sfc_main$B, {
|
|
2942
4583
|
modelValue: currentTab.value,
|
|
2943
4584
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => currentTab.value = $event),
|
|
2944
4585
|
items: tabs.value
|
|
2945
4586
|
}, null, 8, ["modelValue", "items"]),
|
|
2946
|
-
createVNode(_sfc_main$
|
|
4587
|
+
createVNode(_sfc_main$A, { page: currentTab.value }, {
|
|
2947
4588
|
blocks: withCtx(() => [
|
|
2948
|
-
createVNode(_sfc_main$
|
|
4589
|
+
createVNode(_sfc_main$C, { blocks: _ctx.blocksList }, null, 8, ["blocks"])
|
|
2949
4590
|
]),
|
|
2950
4591
|
blockEdit: withCtx(() => [
|
|
2951
4592
|
currentBlock.value && currentContentBlock.value ? (openBlock(), createBlock(_sfc_main$6, {
|
|
@@ -2955,7 +4596,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
2955
4596
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => currentContentBlock.value.data = $event),
|
|
2956
4597
|
flat: ""
|
|
2957
4598
|
}, null, 8, ["schema", "modelValue"])) : currentDataEntry.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
2958
|
-
props.dataEntryScopes ? (openBlock(), createBlock(_sfc_main$
|
|
4599
|
+
props.dataEntryScopes ? (openBlock(), createBlock(_sfc_main$t, {
|
|
2959
4600
|
key: 0,
|
|
2960
4601
|
modelValue: props.dataEntryScopes[currentDataEntry.value.id],
|
|
2961
4602
|
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => props.dataEntryScopes[currentDataEntry.value.id] = $event),
|
|
@@ -3223,7 +4864,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
3223
4864
|
onBlockdrop: ($event) => onPlaceBlockDrop($event, item.index)
|
|
3224
4865
|
}, null, 44, _hoisted_2$1);
|
|
3225
4866
|
}), 256)),
|
|
3226
|
-
createVNode(_sfc_main$
|
|
4867
|
+
createVNode(_sfc_main$o, normalizeProps(guardReactiveProps(unref(contextMenu).props)), null, 16)
|
|
3227
4868
|
], 512);
|
|
3228
4869
|
};
|
|
3229
4870
|
}
|
|
@@ -3378,7 +5019,7 @@ const useControlComponent = (_activeBlockId) => {
|
|
|
3378
5019
|
if (!dragMode) {
|
|
3379
5020
|
return;
|
|
3380
5021
|
}
|
|
3381
|
-
if (e.currentTarget !== e.target && findParent(e.target, (item) => item.classList.contains("editor-component"))) {
|
|
5022
|
+
if (e.currentTarget !== e.target && findParent$1(e.target, (item) => item.classList.contains("editor-component"))) {
|
|
3382
5023
|
insertedPlace.value = null;
|
|
3383
5024
|
return;
|
|
3384
5025
|
}
|
|
@@ -3447,8 +5088,7 @@ const useControlComponent = (_activeBlockId) => {
|
|
|
3447
5088
|
onScroll
|
|
3448
5089
|
};
|
|
3449
5090
|
};
|
|
3450
|
-
|
|
3451
|
-
registerAlias("file", { type: "object", format: "file", properties: { src: "string" } });
|
|
5091
|
+
registerAliases();
|
|
3452
5092
|
const blocksList = shallowRef(blocksList$1.map((file) => ({
|
|
3453
5093
|
...file.blockSchema,
|
|
3454
5094
|
id: file.blockSchema.id ?? file.__name,
|
|
@@ -3490,7 +5130,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3490
5130
|
window.history.pushState({}, "", newPage === "index" ? "/" : `/${newPage}`);
|
|
3491
5131
|
});
|
|
3492
5132
|
return (_ctx, _cache) => {
|
|
3493
|
-
return openBlock(), createBlock(_sfc_main$
|
|
5133
|
+
return openBlock(), createBlock(_sfc_main$t, {
|
|
3494
5134
|
modelValue: currentPage.value,
|
|
3495
5135
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => currentPage.value = $event),
|
|
3496
5136
|
items: pages.value
|
|
@@ -3507,11 +5147,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3507
5147
|
provide("dragMode", dragMode);
|
|
3508
5148
|
const state = reactive(processState(JSON.parse(JSON.stringify(window.state))));
|
|
3509
5149
|
const contentBlocks = computed(() => state.content);
|
|
3510
|
-
useEventListener(document, "blockdrop", (e) => {
|
|
5150
|
+
useEventListener$1(document, "blockdrop", (e) => {
|
|
3511
5151
|
var _a;
|
|
3512
5152
|
if (e.content) return;
|
|
3513
5153
|
insertBlockBefore(e.block, contentBlocks.value, (_a = control.insertedPlace.value) == null ? void 0 : _a.prepentBlockId);
|
|
3514
5154
|
});
|
|
5155
|
+
let ignoreChanges = false;
|
|
5156
|
+
useEventListener$1(document, "openpage", (e) => {
|
|
5157
|
+
Object.assign(state, processState(cloneDeep(e.data)));
|
|
5158
|
+
ignoreChanges = true;
|
|
5159
|
+
});
|
|
3515
5160
|
const control = useControlComponent();
|
|
3516
5161
|
watch(dragMode, control.setDragMode);
|
|
3517
5162
|
watch(blocksList, () => {
|
|
@@ -3521,14 +5166,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3521
5166
|
onMounted(() => {
|
|
3522
5167
|
control.update(window.document.body);
|
|
3523
5168
|
});
|
|
3524
|
-
watch(state, (state2) => {
|
|
3525
|
-
const val = JSON.parse(JSON.stringify(state2));
|
|
3526
|
-
window.postMessage({ type: "update:state", payload: val });
|
|
3527
|
-
setTimeout(() => control.update(window.document.body), 50);
|
|
3528
|
-
}, { immediate: true });
|
|
3529
5169
|
watchDebounced(state, (newState, oldState) => {
|
|
5170
|
+
if (ignoreChanges) {
|
|
5171
|
+
ignoreChanges = false;
|
|
5172
|
+
return;
|
|
5173
|
+
}
|
|
3530
5174
|
const state2 = cloneDeep(newState);
|
|
3531
5175
|
const scopedData = splitData(state2.data, dataEntryScopes.value);
|
|
5176
|
+
console.log(state2.data);
|
|
3532
5177
|
state2.data = scopedData["page"];
|
|
3533
5178
|
saveBlocks(state2.content, blocksMap.value);
|
|
3534
5179
|
fetch("/@mechanica/save", {
|
|
@@ -3557,6 +5202,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3557
5202
|
const dataEntries2 = inject("dataEntries");
|
|
3558
5203
|
const dataEntryScopes = ref(state.dataEntryScopes ?? {});
|
|
3559
5204
|
useKeyDownLayer("Escape", () => !!control.activeBlockId.value, () => control.activeBlockId.value = null);
|
|
5205
|
+
for (let entry of dataEntries2) {
|
|
5206
|
+
state.data[entry.id] = passDefaultValue(state.data[entry.id], entry.props);
|
|
5207
|
+
}
|
|
5208
|
+
watch(state, (state2) => {
|
|
5209
|
+
const val = JSON.parse(JSON.stringify(state2));
|
|
5210
|
+
window.postMessage({ type: "update:state", payload: val });
|
|
5211
|
+
setTimeout(() => control.update(window.document.body), 50);
|
|
5212
|
+
}, { immediate: true });
|
|
3560
5213
|
return (_ctx, _cache) => {
|
|
3561
5214
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
3562
5215
|
createVNode(Transition, null, {
|
|
@@ -3585,16 +5238,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3585
5238
|
]),
|
|
3586
5239
|
_: 1
|
|
3587
5240
|
}),
|
|
3588
|
-
controlsOpened.value ? (openBlock(), createBlock(_sfc_main$
|
|
5241
|
+
controlsOpened.value ? (openBlock(), createBlock(_sfc_main$I, {
|
|
3589
5242
|
key: 0,
|
|
3590
5243
|
element: unref(control).hoverBlockElement.value
|
|
3591
5244
|
}, null, 8, ["element"])) : createCommentVNode("", true),
|
|
3592
|
-
controlsOpened.value ? (openBlock(), createBlock(_sfc_main$
|
|
5245
|
+
controlsOpened.value ? (openBlock(), createBlock(_sfc_main$I, {
|
|
3593
5246
|
key: 1,
|
|
3594
5247
|
element: unref(control).activeBlockElement.value,
|
|
3595
5248
|
resizable: ""
|
|
3596
5249
|
}, null, 8, ["element"])) : createCommentVNode("", true),
|
|
3597
|
-
unref(control).insertedPlace.value ? (openBlock(), createBlock(_sfc_main$
|
|
5250
|
+
unref(control).insertedPlace.value ? (openBlock(), createBlock(_sfc_main$H, {
|
|
3598
5251
|
key: 2,
|
|
3599
5252
|
top: unref(control).insertedPlace.value.top
|
|
3600
5253
|
}, null, 8, ["top"])) : createCommentVNode("", true),
|
|
@@ -3649,7 +5302,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3649
5302
|
]),
|
|
3650
5303
|
_: 1
|
|
3651
5304
|
}),
|
|
3652
|
-
createVNode(_sfc_main$
|
|
5305
|
+
createVNode(_sfc_main$n)
|
|
3653
5306
|
], 64);
|
|
3654
5307
|
};
|
|
3655
5308
|
}
|