@bygga.dev/editor 0.1.0
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/TextEditor-D7HNnS83.js +1827 -0
- package/bygga-editor.js +5016 -0
- package/element.d.ts +56 -0
- package/package.json +14 -0
- package/urls-BUFldK09.js +16688 -0
- package/vue.runtime.esm-bundler-f-r9JKaH.js +4777 -0
|
@@ -0,0 +1,1827 @@
|
|
|
1
|
+
import { $ as e, A as t, B as n, C as r, D as i, E as a, F as o, H as s, I as c, J as l, K as u, L as d, M as f, O as p, Q as m, R as h, S as g, T as ee, X as _, Z as v, _ as y, b, c as te, f as x, g as S, h as C, j as w, l as T, m as ne, nt as E, p as D, r as O, u as k, v as A, w as j, x as re, z as ie } from "./vue.runtime.esm-bundler-f-r9JKaH.js";
|
|
2
|
+
import { $ as ae, Bt as oe, G as se, H as ce, Ht as le, J as ue, K as de, Kt as fe, Q as pe, Vt as me, X as M, Y as he, Z as ge, _ as _e, at as N, b as ve, c as P, ct as F, dt as I, et as L, ft as ye, g as be, ht as R, it as xe, l as Se, lt as z, mt as B, n as V, nt as H, o as Ce, ot as U, p as we, pt as Te, q as Ee, qt as De, rt as Oe, st as ke, t as Ae, tt as je, u as Me, ut as W, v as Ne, zt as Pe } from "./urls-BUFldK09.js";
|
|
3
|
+
//#region ../../node_modules/.pnpm/prosemirror-dropcursor@1.8.2/node_modules/prosemirror-dropcursor/dist/index.js
|
|
4
|
+
function Fe(e = {}) {
|
|
5
|
+
return new F({ view(t) {
|
|
6
|
+
return new Ie(t, e);
|
|
7
|
+
} });
|
|
8
|
+
}
|
|
9
|
+
var Ie = class {
|
|
10
|
+
constructor(e, t) {
|
|
11
|
+
this.editorView = e, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = t.width ?? 1, this.color = t.color === !1 ? void 0 : t.color || "black", this.class = t.class, this.handlers = [
|
|
12
|
+
"dragover",
|
|
13
|
+
"dragend",
|
|
14
|
+
"drop",
|
|
15
|
+
"dragleave"
|
|
16
|
+
].map((t) => {
|
|
17
|
+
let n = (e) => {
|
|
18
|
+
this[t](e);
|
|
19
|
+
};
|
|
20
|
+
return e.dom.addEventListener(t, n), {
|
|
21
|
+
name: t,
|
|
22
|
+
handler: n
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
destroy() {
|
|
27
|
+
this.handlers.forEach(({ name: e, handler: t }) => this.editorView.dom.removeEventListener(e, t));
|
|
28
|
+
}
|
|
29
|
+
update(e, t) {
|
|
30
|
+
this.cursorPos != null && t.doc != e.state.doc && (this.cursorPos > e.state.doc.content.size ? this.setCursor(null) : this.updateOverlay());
|
|
31
|
+
}
|
|
32
|
+
setCursor(e) {
|
|
33
|
+
e != this.cursorPos && (this.cursorPos = e, e == null ? (this.element.parentNode.removeChild(this.element), this.element = null) : this.updateOverlay());
|
|
34
|
+
}
|
|
35
|
+
updateOverlay() {
|
|
36
|
+
let e = this.editorView.state.doc.resolve(this.cursorPos), t = !e.parent.inlineContent, n, r = this.editorView.dom, i = r.getBoundingClientRect(), a = i.width / r.offsetWidth, o = i.height / r.offsetHeight;
|
|
37
|
+
if (t) {
|
|
38
|
+
let t = e.nodeBefore, r = e.nodeAfter;
|
|
39
|
+
if (t || r) {
|
|
40
|
+
let e = this.editorView.nodeDOM(this.cursorPos - (t ? t.nodeSize : 0));
|
|
41
|
+
if (e) {
|
|
42
|
+
let i = e.getBoundingClientRect(), a = t ? i.bottom : i.top;
|
|
43
|
+
t && r && (a = (a + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2);
|
|
44
|
+
let s = this.width / 2 * o;
|
|
45
|
+
n = {
|
|
46
|
+
left: i.left,
|
|
47
|
+
right: i.right,
|
|
48
|
+
top: a - s,
|
|
49
|
+
bottom: a + s
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (!n) {
|
|
55
|
+
let e = this.editorView.coordsAtPos(this.cursorPos), t = this.width / 2 * a;
|
|
56
|
+
n = {
|
|
57
|
+
left: e.left - t,
|
|
58
|
+
right: e.left + t,
|
|
59
|
+
top: e.top,
|
|
60
|
+
bottom: e.bottom
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
let s = this.editorView.dom.offsetParent;
|
|
64
|
+
this.element || (this.element = s.appendChild(document.createElement("div")), this.class && (this.element.className = this.class), this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", this.color && (this.element.style.backgroundColor = this.color)), this.element.classList.toggle("prosemirror-dropcursor-block", t), this.element.classList.toggle("prosemirror-dropcursor-inline", !t);
|
|
65
|
+
let c, l;
|
|
66
|
+
if (!s || s == document.body && getComputedStyle(s).position == "static") c = -pageXOffset, l = -pageYOffset;
|
|
67
|
+
else {
|
|
68
|
+
let e = s.getBoundingClientRect(), t = e.width / s.offsetWidth, n = e.height / s.offsetHeight;
|
|
69
|
+
c = e.left - s.scrollLeft * t, l = e.top - s.scrollTop * n;
|
|
70
|
+
}
|
|
71
|
+
this.element.style.left = (n.left - c) / a + "px", this.element.style.top = (n.top - l) / o + "px", this.element.style.width = (n.right - n.left) / a + "px", this.element.style.height = (n.bottom - n.top) / o + "px";
|
|
72
|
+
}
|
|
73
|
+
scheduleRemoval(e) {
|
|
74
|
+
clearTimeout(this.timeout), this.timeout = setTimeout(() => this.setCursor(null), e);
|
|
75
|
+
}
|
|
76
|
+
dragover(e) {
|
|
77
|
+
if (!this.editorView.editable) return;
|
|
78
|
+
let t = this.editorView.posAtCoords({
|
|
79
|
+
left: e.clientX,
|
|
80
|
+
top: e.clientY
|
|
81
|
+
}), n = t && t.inside >= 0 && this.editorView.state.doc.nodeAt(t.inside), r = n && n.type.spec.disableDropCursor, i = typeof r == "function" ? r(this.editorView, t, e) : r;
|
|
82
|
+
if (t && !i) {
|
|
83
|
+
let e = t.pos;
|
|
84
|
+
if (this.editorView.dragging && this.editorView.dragging.slice) {
|
|
85
|
+
let t = Te(this.editorView.state.doc, e, this.editorView.dragging.slice);
|
|
86
|
+
t != null && (e = t);
|
|
87
|
+
}
|
|
88
|
+
this.setCursor(e), this.scheduleRemoval(5e3);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
dragend() {
|
|
92
|
+
this.scheduleRemoval(20);
|
|
93
|
+
}
|
|
94
|
+
drop() {
|
|
95
|
+
this.scheduleRemoval(20);
|
|
96
|
+
}
|
|
97
|
+
dragleave(e) {
|
|
98
|
+
this.editorView.dom.contains(e.relatedTarget) || this.setCursor(null);
|
|
99
|
+
}
|
|
100
|
+
}, G = class e extends W {
|
|
101
|
+
constructor(e) {
|
|
102
|
+
super(e, e);
|
|
103
|
+
}
|
|
104
|
+
map(t, n) {
|
|
105
|
+
let r = t.resolve(n.map(this.head));
|
|
106
|
+
return e.valid(r) ? new e(r) : W.near(r);
|
|
107
|
+
}
|
|
108
|
+
content() {
|
|
109
|
+
return R.empty;
|
|
110
|
+
}
|
|
111
|
+
eq(t) {
|
|
112
|
+
return t instanceof e && t.head == this.head;
|
|
113
|
+
}
|
|
114
|
+
toJSON() {
|
|
115
|
+
return {
|
|
116
|
+
type: "gapcursor",
|
|
117
|
+
pos: this.head
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
static fromJSON(t, n) {
|
|
121
|
+
if (typeof n.pos != "number") throw RangeError("Invalid input for GapCursor.fromJSON");
|
|
122
|
+
return new e(t.resolve(n.pos));
|
|
123
|
+
}
|
|
124
|
+
getBookmark() {
|
|
125
|
+
return new Le(this.anchor);
|
|
126
|
+
}
|
|
127
|
+
static valid(e) {
|
|
128
|
+
let t = e.parent;
|
|
129
|
+
if (t.inlineContent || !ze(e) || !Be(e)) return !1;
|
|
130
|
+
let n = t.type.spec.allowGapCursor;
|
|
131
|
+
if (n != null) return n;
|
|
132
|
+
let r = t.contentMatchAt(e.index()).defaultType;
|
|
133
|
+
return r && r.isTextblock;
|
|
134
|
+
}
|
|
135
|
+
static findGapCursorFrom(t, n, r = !1) {
|
|
136
|
+
search: for (;;) {
|
|
137
|
+
if (!r && e.valid(t)) return t;
|
|
138
|
+
let i = t.pos, a = null;
|
|
139
|
+
for (let r = t.depth;; r--) {
|
|
140
|
+
let o = t.node(r);
|
|
141
|
+
if (n > 0 ? t.indexAfter(r) < o.childCount : t.index(r) > 0) {
|
|
142
|
+
a = o.child(n > 0 ? t.indexAfter(r) : t.index(r) - 1);
|
|
143
|
+
break;
|
|
144
|
+
} else if (r == 0) return null;
|
|
145
|
+
i += n;
|
|
146
|
+
let s = t.doc.resolve(i);
|
|
147
|
+
if (e.valid(s)) return s;
|
|
148
|
+
}
|
|
149
|
+
for (;;) {
|
|
150
|
+
let o = n > 0 ? a.firstChild : a.lastChild;
|
|
151
|
+
if (!o) {
|
|
152
|
+
if (a.isAtom && !a.isText && !ke.isSelectable(a)) {
|
|
153
|
+
t = t.doc.resolve(i + a.nodeSize * n), r = !1;
|
|
154
|
+
continue search;
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
a = o, i += n;
|
|
159
|
+
let s = t.doc.resolve(i);
|
|
160
|
+
if (e.valid(s)) return s;
|
|
161
|
+
}
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
G.prototype.visible = !1, G.findFrom = G.findGapCursorFrom, W.jsonID("gapcursor", G);
|
|
167
|
+
var Le = class e {
|
|
168
|
+
constructor(e) {
|
|
169
|
+
this.pos = e;
|
|
170
|
+
}
|
|
171
|
+
map(t) {
|
|
172
|
+
return new e(t.map(this.pos));
|
|
173
|
+
}
|
|
174
|
+
resolve(e) {
|
|
175
|
+
let t = e.resolve(this.pos);
|
|
176
|
+
return G.valid(t) ? new G(t) : W.near(t);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
function Re(e) {
|
|
180
|
+
return e.isAtom || e.spec.isolating || e.spec.createGapCursor;
|
|
181
|
+
}
|
|
182
|
+
function ze(e) {
|
|
183
|
+
for (let t = e.depth; t >= 0; t--) {
|
|
184
|
+
let n = e.index(t), r = e.node(t);
|
|
185
|
+
if (n == 0) {
|
|
186
|
+
if (r.type.spec.isolating) return !0;
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
for (let e = r.child(n - 1);; e = e.lastChild) {
|
|
190
|
+
if (e.childCount == 0 && !e.inlineContent || Re(e.type)) return !0;
|
|
191
|
+
if (e.inlineContent) return !1;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return !0;
|
|
195
|
+
}
|
|
196
|
+
function Be(e) {
|
|
197
|
+
for (let t = e.depth; t >= 0; t--) {
|
|
198
|
+
let n = e.indexAfter(t), r = e.node(t);
|
|
199
|
+
if (n == r.childCount) {
|
|
200
|
+
if (r.type.spec.isolating) return !0;
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
for (let e = r.child(n);; e = e.firstChild) {
|
|
204
|
+
if (e.childCount == 0 && !e.inlineContent || Re(e.type)) return !0;
|
|
205
|
+
if (e.inlineContent) return !1;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return !0;
|
|
209
|
+
}
|
|
210
|
+
function Ve() {
|
|
211
|
+
return new F({ props: {
|
|
212
|
+
decorations: Ge,
|
|
213
|
+
createSelectionBetween(e, t, n) {
|
|
214
|
+
return t.pos == n.pos && G.valid(n) ? new G(n) : null;
|
|
215
|
+
},
|
|
216
|
+
handleClick: Ue,
|
|
217
|
+
handleKeyDown: He,
|
|
218
|
+
handleDOMEvents: { beforeinput: We }
|
|
219
|
+
} });
|
|
220
|
+
}
|
|
221
|
+
var He = xe({
|
|
222
|
+
ArrowLeft: K("horiz", -1),
|
|
223
|
+
ArrowRight: K("horiz", 1),
|
|
224
|
+
ArrowUp: K("vert", -1),
|
|
225
|
+
ArrowDown: K("vert", 1)
|
|
226
|
+
});
|
|
227
|
+
function K(e, t) {
|
|
228
|
+
let n = e == "vert" ? t > 0 ? "down" : "up" : t > 0 ? "right" : "left";
|
|
229
|
+
return function(e, r, i) {
|
|
230
|
+
let a = e.selection, o = t > 0 ? a.$to : a.$from, s = a.empty;
|
|
231
|
+
if (a instanceof I) {
|
|
232
|
+
if (!i.endOfTextblock(n) || o.depth == 0) return !1;
|
|
233
|
+
s = !1, o = e.doc.resolve(t > 0 ? o.after() : o.before());
|
|
234
|
+
}
|
|
235
|
+
let c = G.findGapCursorFrom(o, t, s);
|
|
236
|
+
return c ? (r && r(e.tr.setSelection(new G(c))), !0) : !1;
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function Ue(e, t, n) {
|
|
240
|
+
if (!e || !e.editable) return !1;
|
|
241
|
+
let r = e.state.doc.resolve(t);
|
|
242
|
+
if (!G.valid(r)) return !1;
|
|
243
|
+
let i = e.posAtCoords({
|
|
244
|
+
left: n.clientX,
|
|
245
|
+
top: n.clientY
|
|
246
|
+
});
|
|
247
|
+
return i && i.inside > -1 && ke.isSelectable(e.state.doc.nodeAt(i.inside)) ? !1 : (e.dispatch(e.state.tr.setSelection(new G(r))), !0);
|
|
248
|
+
}
|
|
249
|
+
function We(e, t) {
|
|
250
|
+
if (t.inputType != "insertCompositionText" || !(e.state.selection instanceof G)) return !1;
|
|
251
|
+
let { $from: n } = e.state.selection, r = n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);
|
|
252
|
+
if (!r) return !1;
|
|
253
|
+
let i = B.empty;
|
|
254
|
+
for (let e = r.length - 1; e >= 0; e--) i = B.from(r[e].createAndFill(null, i));
|
|
255
|
+
let a = e.state.tr.replace(n.pos, n.pos, new R(i, 0, 0));
|
|
256
|
+
return a.setSelection(I.near(a.doc.resolve(n.pos + 1))), e.dispatch(a), !1;
|
|
257
|
+
}
|
|
258
|
+
function Ge(e) {
|
|
259
|
+
if (!(e.selection instanceof G)) return null;
|
|
260
|
+
let t = document.createElement("div");
|
|
261
|
+
return t.className = "ProseMirror-gapcursor", U.create(e.doc, [N.widget(e.selection.head, t, { key: "gapcursor" })]);
|
|
262
|
+
}
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region ../../node_modules/.pnpm/rope-sequence@1.3.4/node_modules/rope-sequence/dist/index.js
|
|
265
|
+
var q = 200, J = function() {};
|
|
266
|
+
J.prototype.append = function(e) {
|
|
267
|
+
return e.length ? (e = J.from(e), !this.length && e || e.length < q && this.leafAppend(e) || this.length < q && e.leafPrepend(this) || this.appendInner(e)) : this;
|
|
268
|
+
}, J.prototype.prepend = function(e) {
|
|
269
|
+
return e.length ? J.from(e).append(this) : this;
|
|
270
|
+
}, J.prototype.appendInner = function(e) {
|
|
271
|
+
return new qe(this, e);
|
|
272
|
+
}, J.prototype.slice = function(e, t) {
|
|
273
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this.length), e >= t ? J.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, t));
|
|
274
|
+
}, J.prototype.get = function(e) {
|
|
275
|
+
if (!(e < 0 || e >= this.length)) return this.getInner(e);
|
|
276
|
+
}, J.prototype.forEach = function(e, t, n) {
|
|
277
|
+
t === void 0 && (t = 0), n === void 0 && (n = this.length), t <= n ? this.forEachInner(e, t, n, 0) : this.forEachInvertedInner(e, t, n, 0);
|
|
278
|
+
}, J.prototype.map = function(e, t, n) {
|
|
279
|
+
t === void 0 && (t = 0), n === void 0 && (n = this.length);
|
|
280
|
+
var r = [];
|
|
281
|
+
return this.forEach(function(t, n) {
|
|
282
|
+
return r.push(e(t, n));
|
|
283
|
+
}, t, n), r;
|
|
284
|
+
}, J.from = function(e) {
|
|
285
|
+
return e instanceof J ? e : e && e.length ? new Ke(e) : J.empty;
|
|
286
|
+
};
|
|
287
|
+
var Ke = /* @__PURE__ */ function(e) {
|
|
288
|
+
function t(t) {
|
|
289
|
+
e.call(this), this.values = t;
|
|
290
|
+
}
|
|
291
|
+
e && (t.__proto__ = e), t.prototype = Object.create(e && e.prototype), t.prototype.constructor = t;
|
|
292
|
+
var n = {
|
|
293
|
+
length: { configurable: !0 },
|
|
294
|
+
depth: { configurable: !0 }
|
|
295
|
+
};
|
|
296
|
+
return t.prototype.flatten = function() {
|
|
297
|
+
return this.values;
|
|
298
|
+
}, t.prototype.sliceInner = function(e, n) {
|
|
299
|
+
return e == 0 && n == this.length ? this : new t(this.values.slice(e, n));
|
|
300
|
+
}, t.prototype.getInner = function(e) {
|
|
301
|
+
return this.values[e];
|
|
302
|
+
}, t.prototype.forEachInner = function(e, t, n, r) {
|
|
303
|
+
for (var i = t; i < n; i++) if (e(this.values[i], r + i) === !1) return !1;
|
|
304
|
+
}, t.prototype.forEachInvertedInner = function(e, t, n, r) {
|
|
305
|
+
for (var i = t - 1; i >= n; i--) if (e(this.values[i], r + i) === !1) return !1;
|
|
306
|
+
}, t.prototype.leafAppend = function(e) {
|
|
307
|
+
if (this.length + e.length <= q) return new t(this.values.concat(e.flatten()));
|
|
308
|
+
}, t.prototype.leafPrepend = function(e) {
|
|
309
|
+
if (this.length + e.length <= q) return new t(e.flatten().concat(this.values));
|
|
310
|
+
}, n.length.get = function() {
|
|
311
|
+
return this.values.length;
|
|
312
|
+
}, n.depth.get = function() {
|
|
313
|
+
return 0;
|
|
314
|
+
}, Object.defineProperties(t.prototype, n), t;
|
|
315
|
+
}(J);
|
|
316
|
+
J.empty = new Ke([]);
|
|
317
|
+
var qe = /* @__PURE__ */ function(e) {
|
|
318
|
+
function t(t, n) {
|
|
319
|
+
e.call(this), this.left = t, this.right = n, this.length = t.length + n.length, this.depth = Math.max(t.depth, n.depth) + 1;
|
|
320
|
+
}
|
|
321
|
+
return e && (t.__proto__ = e), t.prototype = Object.create(e && e.prototype), t.prototype.constructor = t, t.prototype.flatten = function() {
|
|
322
|
+
return this.left.flatten().concat(this.right.flatten());
|
|
323
|
+
}, t.prototype.getInner = function(e) {
|
|
324
|
+
return e < this.left.length ? this.left.get(e) : this.right.get(e - this.left.length);
|
|
325
|
+
}, t.prototype.forEachInner = function(e, t, n, r) {
|
|
326
|
+
var i = this.left.length;
|
|
327
|
+
if (t < i && this.left.forEachInner(e, t, Math.min(n, i), r) === !1 || n > i && this.right.forEachInner(e, Math.max(t - i, 0), Math.min(this.length, n) - i, r + i) === !1) return !1;
|
|
328
|
+
}, t.prototype.forEachInvertedInner = function(e, t, n, r) {
|
|
329
|
+
var i = this.left.length;
|
|
330
|
+
if (t > i && this.right.forEachInvertedInner(e, t - i, Math.max(n, i) - i, r + i) === !1 || n < i && this.left.forEachInvertedInner(e, Math.min(t, i), n, r) === !1) return !1;
|
|
331
|
+
}, t.prototype.sliceInner = function(e, t) {
|
|
332
|
+
if (e == 0 && t == this.length) return this;
|
|
333
|
+
var n = this.left.length;
|
|
334
|
+
return t <= n ? this.left.slice(e, t) : e >= n ? this.right.slice(e - n, t - n) : this.left.slice(e, n).append(this.right.slice(0, t - n));
|
|
335
|
+
}, t.prototype.leafAppend = function(e) {
|
|
336
|
+
var n = this.right.leafAppend(e);
|
|
337
|
+
if (n) return new t(this.left, n);
|
|
338
|
+
}, t.prototype.leafPrepend = function(e) {
|
|
339
|
+
var n = this.left.leafPrepend(e);
|
|
340
|
+
if (n) return new t(n, this.right);
|
|
341
|
+
}, t.prototype.appendInner = function(e) {
|
|
342
|
+
return this.left.depth >= Math.max(this.right.depth, e.depth) + 1 ? new t(this.left, new t(this.right, e)) : new t(this, e);
|
|
343
|
+
}, t;
|
|
344
|
+
}(J), Je = 500, Y = class e {
|
|
345
|
+
constructor(e, t) {
|
|
346
|
+
this.items = e, this.eventCount = t;
|
|
347
|
+
}
|
|
348
|
+
popEvent(t, n) {
|
|
349
|
+
if (this.eventCount == 0) return null;
|
|
350
|
+
let r = this.items.length;
|
|
351
|
+
for (;; r--) if (this.items.get(r - 1).selection) {
|
|
352
|
+
--r;
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
let i, a;
|
|
356
|
+
n && (i = this.remapping(r, this.items.length), a = i.maps.length);
|
|
357
|
+
let o = t.tr, s, c, l = [], u = [];
|
|
358
|
+
return this.items.forEach((t, n) => {
|
|
359
|
+
if (!t.step) {
|
|
360
|
+
i || (i = this.remapping(r, n + 1), a = i.maps.length), a--, u.push(t);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
if (i) {
|
|
364
|
+
u.push(new X(t.map));
|
|
365
|
+
let e = t.step.map(i.slice(a)), n;
|
|
366
|
+
e && o.maybeStep(e).doc && (n = o.mapping.maps[o.mapping.maps.length - 1], l.push(new X(n, void 0, void 0, l.length + u.length))), a--, n && i.appendMap(n, a);
|
|
367
|
+
} else o.maybeStep(t.step);
|
|
368
|
+
if (t.selection) return s = i ? t.selection.map(i.slice(a)) : t.selection, c = new e(this.items.slice(0, r).append(u.reverse().concat(l)), this.eventCount - 1), !1;
|
|
369
|
+
}, this.items.length, 0), {
|
|
370
|
+
remaining: c,
|
|
371
|
+
transform: o,
|
|
372
|
+
selection: s
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
addTransform(t, n, r, i) {
|
|
376
|
+
let a = [], o = this.eventCount, s = this.items, c = !i && s.length ? s.get(s.length - 1) : null;
|
|
377
|
+
for (let e = 0; e < t.steps.length; e++) {
|
|
378
|
+
let r = t.steps[e].invert(t.docs[e]), l = new X(t.mapping.maps[e], r, n), u;
|
|
379
|
+
(u = c && c.merge(l)) && (l = u, e ? a.pop() : s = s.slice(0, s.length - 1)), a.push(l), n &&= (o++, void 0), i || (c = l);
|
|
380
|
+
}
|
|
381
|
+
let l = o - r.depth;
|
|
382
|
+
return l > Xe && (s = Ye(s, l), o -= l), new e(s.append(a), o);
|
|
383
|
+
}
|
|
384
|
+
remapping(e, t) {
|
|
385
|
+
let n = new ye();
|
|
386
|
+
return this.items.forEach((t, r) => {
|
|
387
|
+
let i = t.mirrorOffset != null && r - t.mirrorOffset >= e ? n.maps.length - t.mirrorOffset : void 0;
|
|
388
|
+
n.appendMap(t.map, i);
|
|
389
|
+
}, e, t), n;
|
|
390
|
+
}
|
|
391
|
+
addMaps(t) {
|
|
392
|
+
return this.eventCount == 0 ? this : new e(this.items.append(t.map((e) => new X(e))), this.eventCount);
|
|
393
|
+
}
|
|
394
|
+
rebased(t, n) {
|
|
395
|
+
if (!this.eventCount) return this;
|
|
396
|
+
let r = [], i = Math.max(0, this.items.length - n), a = t.mapping, o = t.steps.length, s = this.eventCount;
|
|
397
|
+
this.items.forEach((e) => {
|
|
398
|
+
e.selection && s--;
|
|
399
|
+
}, i);
|
|
400
|
+
let c = n;
|
|
401
|
+
this.items.forEach((e) => {
|
|
402
|
+
let n = a.getMirror(--c);
|
|
403
|
+
if (n == null) return;
|
|
404
|
+
o = Math.min(o, n);
|
|
405
|
+
let i = a.maps[n];
|
|
406
|
+
if (e.step) {
|
|
407
|
+
let o = t.steps[n].invert(t.docs[n]), l = e.selection && e.selection.map(a.slice(c + 1, n));
|
|
408
|
+
l && s++, r.push(new X(i, o, l));
|
|
409
|
+
} else r.push(new X(i));
|
|
410
|
+
}, i);
|
|
411
|
+
let l = [];
|
|
412
|
+
for (let e = n; e < o; e++) l.push(new X(a.maps[e]));
|
|
413
|
+
let u = new e(this.items.slice(0, i).append(l).append(r), s);
|
|
414
|
+
return u.emptyItemCount() > Je && (u = u.compress(this.items.length - r.length)), u;
|
|
415
|
+
}
|
|
416
|
+
emptyItemCount() {
|
|
417
|
+
let e = 0;
|
|
418
|
+
return this.items.forEach((t) => {
|
|
419
|
+
t.step || e++;
|
|
420
|
+
}), e;
|
|
421
|
+
}
|
|
422
|
+
compress(t = this.items.length) {
|
|
423
|
+
let n = this.remapping(0, t), r = n.maps.length, i = [], a = 0;
|
|
424
|
+
return this.items.forEach((e, o) => {
|
|
425
|
+
if (o >= t) i.push(e), e.selection && a++;
|
|
426
|
+
else if (e.step) {
|
|
427
|
+
let t = e.step.map(n.slice(r)), o = t && t.getMap();
|
|
428
|
+
if (r--, o && n.appendMap(o, r), t) {
|
|
429
|
+
let s = e.selection && e.selection.map(n.slice(r));
|
|
430
|
+
s && a++;
|
|
431
|
+
let c = new X(o.invert(), t, s), l, u = i.length - 1;
|
|
432
|
+
(l = i.length && i[u].merge(c)) ? i[u] = l : i.push(c);
|
|
433
|
+
}
|
|
434
|
+
} else e.map && r--;
|
|
435
|
+
}, this.items.length, 0), new e(J.from(i.reverse()), a);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
Y.empty = new Y(J.empty, 0);
|
|
439
|
+
function Ye(e, t) {
|
|
440
|
+
let n;
|
|
441
|
+
return e.forEach((e, r) => {
|
|
442
|
+
if (e.selection && t-- == 0) return n = r, !1;
|
|
443
|
+
}), e.slice(n);
|
|
444
|
+
}
|
|
445
|
+
var X = class e {
|
|
446
|
+
constructor(e, t, n, r) {
|
|
447
|
+
this.map = e, this.step = t, this.selection = n, this.mirrorOffset = r;
|
|
448
|
+
}
|
|
449
|
+
merge(t) {
|
|
450
|
+
if (this.step && t.step && !t.selection) {
|
|
451
|
+
let n = t.step.merge(this.step);
|
|
452
|
+
if (n) return new e(n.getMap().invert(), n, this.selection);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}, Z = class {
|
|
456
|
+
constructor(e, t, n, r, i) {
|
|
457
|
+
this.done = e, this.undone = t, this.prevRanges = n, this.prevTime = r, this.prevComposition = i;
|
|
458
|
+
}
|
|
459
|
+
}, Xe = 20;
|
|
460
|
+
function Ze(e, t, n, r) {
|
|
461
|
+
let i = n.getMeta(Q), a;
|
|
462
|
+
if (i) return i.historyState;
|
|
463
|
+
n.getMeta(at) && (e = new Z(e.done, e.undone, null, 0, -1));
|
|
464
|
+
let o = n.getMeta("appendedTransaction");
|
|
465
|
+
if (n.steps.length == 0) return e;
|
|
466
|
+
if (o && o.getMeta(Q)) return o.getMeta(Q).redo ? new Z(e.done.addTransform(n, void 0, r, it(t)), e.undone, $e(n.mapping.maps), e.prevTime, e.prevComposition) : new Z(e.done, e.undone.addTransform(n, void 0, r, it(t)), null, e.prevTime, e.prevComposition);
|
|
467
|
+
if (n.getMeta("addToHistory") !== !1 && !(o && o.getMeta("addToHistory") === !1)) {
|
|
468
|
+
let i = n.getMeta("composition"), a = e.prevTime == 0 || !o && e.prevComposition != i && (e.prevTime < (n.time || 0) - r.newGroupDelay || !Qe(n, e.prevRanges)), s = o ? et(e.prevRanges, n.mapping) : $e(n.mapping.maps);
|
|
469
|
+
return new Z(e.done.addTransform(n, a ? t.selection.getBookmark() : void 0, r, it(t)), Y.empty, s, n.time, i ?? e.prevComposition);
|
|
470
|
+
} else if (a = n.getMeta("rebased")) return new Z(e.done.rebased(n, a), e.undone.rebased(n, a), et(e.prevRanges, n.mapping), e.prevTime, e.prevComposition);
|
|
471
|
+
else return new Z(e.done.addMaps(n.mapping.maps), e.undone.addMaps(n.mapping.maps), et(e.prevRanges, n.mapping), e.prevTime, e.prevComposition);
|
|
472
|
+
}
|
|
473
|
+
function Qe(e, t) {
|
|
474
|
+
if (!t) return !1;
|
|
475
|
+
if (!e.docChanged) return !0;
|
|
476
|
+
let n = !1;
|
|
477
|
+
return e.mapping.maps[0].forEach((e, r) => {
|
|
478
|
+
for (let i = 0; i < t.length; i += 2) e <= t[i + 1] && r >= t[i] && (n = !0);
|
|
479
|
+
}), n;
|
|
480
|
+
}
|
|
481
|
+
function $e(e) {
|
|
482
|
+
let t = [];
|
|
483
|
+
for (let n = e.length - 1; n >= 0 && t.length == 0; n--) e[n].forEach((e, n, r, i) => t.push(r, i));
|
|
484
|
+
return t;
|
|
485
|
+
}
|
|
486
|
+
function et(e, t) {
|
|
487
|
+
if (!e) return null;
|
|
488
|
+
let n = [];
|
|
489
|
+
for (let r = 0; r < e.length; r += 2) {
|
|
490
|
+
let i = t.map(e[r], 1), a = t.map(e[r + 1], -1);
|
|
491
|
+
i <= a && n.push(i, a);
|
|
492
|
+
}
|
|
493
|
+
return n;
|
|
494
|
+
}
|
|
495
|
+
function tt(e, t, n) {
|
|
496
|
+
let r = it(t), i = Q.get(t).spec.config, a = (n ? e.undone : e.done).popEvent(t, r);
|
|
497
|
+
if (!a) return null;
|
|
498
|
+
let o = a.selection.resolve(a.transform.doc), s = (n ? e.done : e.undone).addTransform(a.transform, t.selection.getBookmark(), i, r), c = new Z(n ? s : a.remaining, n ? a.remaining : s, null, 0, -1);
|
|
499
|
+
return a.transform.setSelection(o).setMeta(Q, {
|
|
500
|
+
redo: n,
|
|
501
|
+
historyState: c
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
var nt = !1, rt = null;
|
|
505
|
+
function it(e) {
|
|
506
|
+
let t = e.plugins;
|
|
507
|
+
if (rt != t) {
|
|
508
|
+
nt = !1, rt = t;
|
|
509
|
+
for (let e = 0; e < t.length; e++) if (t[e].spec.historyPreserveItems) {
|
|
510
|
+
nt = !0;
|
|
511
|
+
break;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return nt;
|
|
515
|
+
}
|
|
516
|
+
var Q = new z("history"), at = new z("closeHistory");
|
|
517
|
+
function ot(e = {}) {
|
|
518
|
+
return e = {
|
|
519
|
+
depth: e.depth || 100,
|
|
520
|
+
newGroupDelay: e.newGroupDelay || 500
|
|
521
|
+
}, new F({
|
|
522
|
+
key: Q,
|
|
523
|
+
state: {
|
|
524
|
+
init() {
|
|
525
|
+
return new Z(Y.empty, Y.empty, null, 0, -1);
|
|
526
|
+
},
|
|
527
|
+
apply(t, n, r) {
|
|
528
|
+
return Ze(n, r, t, e);
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
config: e,
|
|
532
|
+
props: { handleDOMEvents: { beforeinput(e, t) {
|
|
533
|
+
let n = t.inputType, r = n == "historyUndo" ? ct : n == "historyRedo" ? lt : null;
|
|
534
|
+
return !r || !e.editable ? !1 : (t.preventDefault(), r(e.state, e.dispatch));
|
|
535
|
+
} } }
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
function st(e, t) {
|
|
539
|
+
return (n, r) => {
|
|
540
|
+
let i = Q.getState(n);
|
|
541
|
+
if (!i || (e ? i.undone : i.done).eventCount == 0) return !1;
|
|
542
|
+
if (r) {
|
|
543
|
+
let a = tt(i, n, e);
|
|
544
|
+
a && r(t ? a.scrollIntoView() : a);
|
|
545
|
+
}
|
|
546
|
+
return !0;
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
var ct = st(!1, !0), lt = st(!0, !0);
|
|
550
|
+
M.create({
|
|
551
|
+
name: "characterCount",
|
|
552
|
+
addOptions() {
|
|
553
|
+
return {
|
|
554
|
+
limit: null,
|
|
555
|
+
autoTrim: !0,
|
|
556
|
+
mode: "textSize",
|
|
557
|
+
textCounter: (e) => e.length,
|
|
558
|
+
wordCounter: (e) => e.split(" ").filter((e) => e !== "").length
|
|
559
|
+
};
|
|
560
|
+
},
|
|
561
|
+
addStorage() {
|
|
562
|
+
return {
|
|
563
|
+
characters: () => 0,
|
|
564
|
+
words: () => 0
|
|
565
|
+
};
|
|
566
|
+
},
|
|
567
|
+
onBeforeCreate() {
|
|
568
|
+
this.storage.characters = (e) => {
|
|
569
|
+
let t = e?.node || this.editor.state.doc;
|
|
570
|
+
if ((e?.mode || this.options.mode) === "textSize") {
|
|
571
|
+
let e = t.textBetween(0, t.content.size, void 0, " ");
|
|
572
|
+
return this.options.textCounter(e);
|
|
573
|
+
}
|
|
574
|
+
return t.nodeSize;
|
|
575
|
+
}, this.storage.words = (e) => {
|
|
576
|
+
let t = e?.node || this.editor.state.doc, n = t.textBetween(0, t.content.size, " ", " ");
|
|
577
|
+
return this.options.wordCounter(n);
|
|
578
|
+
};
|
|
579
|
+
},
|
|
580
|
+
addProseMirrorPlugins() {
|
|
581
|
+
let e = !1;
|
|
582
|
+
return [new F({
|
|
583
|
+
key: new z("characterCount"),
|
|
584
|
+
appendTransaction: (t, n, r) => {
|
|
585
|
+
if (e) return;
|
|
586
|
+
let i = this.options.limit, a = this.options.autoTrim;
|
|
587
|
+
if (i == null || i === 0 || a === !1) {
|
|
588
|
+
e = !0;
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
let o = this.storage.characters({ node: r.doc });
|
|
592
|
+
if (o > i) {
|
|
593
|
+
let t = o - i;
|
|
594
|
+
console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);
|
|
595
|
+
let n = r.tr.deleteRange(0, t);
|
|
596
|
+
return e = !0, n;
|
|
597
|
+
}
|
|
598
|
+
e = !0;
|
|
599
|
+
},
|
|
600
|
+
filterTransaction: (e, t) => {
|
|
601
|
+
let n = this.options.limit;
|
|
602
|
+
if (!e.docChanged || n === 0 || n == null) return !0;
|
|
603
|
+
let r = this.storage.characters({ node: t.doc }), i = this.storage.characters({ node: e.doc });
|
|
604
|
+
if (i <= n || r > n && i > n && i <= r) return !0;
|
|
605
|
+
if (r > n && i > n && i > r || !e.getMeta("paste")) return !1;
|
|
606
|
+
let a = e.selection.$head.pos, o = a - (i - n), s = a;
|
|
607
|
+
return e.deleteRange(o, s), !(this.storage.characters({ node: e.doc }) > n);
|
|
608
|
+
}
|
|
609
|
+
})];
|
|
610
|
+
}
|
|
611
|
+
}), M.create({
|
|
612
|
+
name: "dropCursor",
|
|
613
|
+
addOptions() {
|
|
614
|
+
return {
|
|
615
|
+
color: "currentColor",
|
|
616
|
+
width: 1,
|
|
617
|
+
class: void 0
|
|
618
|
+
};
|
|
619
|
+
},
|
|
620
|
+
addProseMirrorPlugins() {
|
|
621
|
+
return [Fe(this.options)];
|
|
622
|
+
}
|
|
623
|
+
}), M.create({
|
|
624
|
+
name: "focus",
|
|
625
|
+
addOptions() {
|
|
626
|
+
return {
|
|
627
|
+
className: "has-focus",
|
|
628
|
+
mode: "all"
|
|
629
|
+
};
|
|
630
|
+
},
|
|
631
|
+
addProseMirrorPlugins() {
|
|
632
|
+
return [new F({
|
|
633
|
+
key: new z("focus"),
|
|
634
|
+
props: { decorations: ({ doc: e, selection: t }) => {
|
|
635
|
+
let { isEditable: n, isFocused: r } = this.editor, { anchor: i } = t, a = [];
|
|
636
|
+
if (!n || !r) return U.create(e, []);
|
|
637
|
+
let o = 0;
|
|
638
|
+
this.options.mode === "deepest" && e.descendants((e, t) => {
|
|
639
|
+
if (!e.isText) {
|
|
640
|
+
if (!(i >= t && i <= t + e.nodeSize - 1)) return !1;
|
|
641
|
+
o += 1;
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
let s = 0;
|
|
645
|
+
return e.descendants((e, t) => {
|
|
646
|
+
if (e.isText || !(i >= t && i <= t + e.nodeSize - 1)) return !1;
|
|
647
|
+
if (s += 1, this.options.mode === "deepest" && o - s > 0 || this.options.mode === "shallowest" && s > 1) return this.options.mode === "deepest";
|
|
648
|
+
a.push(N.node(t, t + e.nodeSize, { class: this.options.className }));
|
|
649
|
+
}), U.create(e, a);
|
|
650
|
+
} }
|
|
651
|
+
})];
|
|
652
|
+
}
|
|
653
|
+
}), M.create({
|
|
654
|
+
name: "gapCursor",
|
|
655
|
+
addProseMirrorPlugins() {
|
|
656
|
+
return [Ve()];
|
|
657
|
+
},
|
|
658
|
+
extendNodeSchema(e) {
|
|
659
|
+
return { allowGapCursor: pe(L(e, "allowGapCursor", {
|
|
660
|
+
name: e.name,
|
|
661
|
+
options: e.options,
|
|
662
|
+
storage: e.storage
|
|
663
|
+
})) ?? null };
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
var ut = "placeholder", $ = new z("tiptap__placeholder"), dt = 200;
|
|
667
|
+
function ft(e) {
|
|
668
|
+
let { editor: t, placeholder: n, dataAttribute: r, pos: i, node: a, isEmptyDoc: o, hasAnchor: s, classes: { emptyNode: c, emptyEditor: l } } = e, u = [c];
|
|
669
|
+
return o && u.push(l), N.node(i, i + a.nodeSize, {
|
|
670
|
+
class: u.join(" "),
|
|
671
|
+
[r]: typeof n == "function" ? n({
|
|
672
|
+
editor: t,
|
|
673
|
+
node: a,
|
|
674
|
+
pos: i,
|
|
675
|
+
hasAnchor: s
|
|
676
|
+
}) : n
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
function pt(e, t) {
|
|
680
|
+
return typeof e == "function" ? e(t) : e;
|
|
681
|
+
}
|
|
682
|
+
function mt({ editor: e, options: t, dataAttribute: n, doc: r, selection: i }) {
|
|
683
|
+
if (!(e.isEditable || !t.showOnlyWhenEditable)) return null;
|
|
684
|
+
let { anchor: a } = i, o = [], s = e.isEmpty;
|
|
685
|
+
if (t.showOnlyCurrent && !t.includeChildren) {
|
|
686
|
+
let i = r.resolve(a), c = i.depth > 0 ? i.node(1) : i.nodeAfter, l = i.depth > 0 ? i.before(1) : a;
|
|
687
|
+
if (c && c.type.isTextblock && je(c)) {
|
|
688
|
+
let r = a >= l && a <= l + c.nodeSize;
|
|
689
|
+
o.push(ft({
|
|
690
|
+
editor: e,
|
|
691
|
+
isEmptyDoc: s,
|
|
692
|
+
dataAttribute: n,
|
|
693
|
+
hasAnchor: r,
|
|
694
|
+
placeholder: t.placeholder,
|
|
695
|
+
classes: {
|
|
696
|
+
emptyEditor: t.emptyEditorClass,
|
|
697
|
+
emptyNode: pt(t.emptyNodeClass, {
|
|
698
|
+
editor: e,
|
|
699
|
+
node: c,
|
|
700
|
+
pos: l,
|
|
701
|
+
hasAnchor: r
|
|
702
|
+
})
|
|
703
|
+
},
|
|
704
|
+
node: c,
|
|
705
|
+
pos: l
|
|
706
|
+
}));
|
|
707
|
+
}
|
|
708
|
+
} else {
|
|
709
|
+
let i = $.getState(e.state), c = i?.topPos ?? 0, l = i?.bottomPos ?? r.content.size;
|
|
710
|
+
r.nodesBetween(c, l, (r, i) => {
|
|
711
|
+
let c = a >= i && a <= i + r.nodeSize, l = !r.isLeaf && je(r);
|
|
712
|
+
return r.type.isTextblock && (c || !t.showOnlyCurrent) && l && o.push(ft({
|
|
713
|
+
editor: e,
|
|
714
|
+
isEmptyDoc: s,
|
|
715
|
+
dataAttribute: n,
|
|
716
|
+
hasAnchor: c,
|
|
717
|
+
placeholder: t.placeholder,
|
|
718
|
+
classes: {
|
|
719
|
+
emptyEditor: t.emptyEditorClass,
|
|
720
|
+
emptyNode: pt(t.emptyNodeClass, {
|
|
721
|
+
editor: e,
|
|
722
|
+
node: r,
|
|
723
|
+
pos: i,
|
|
724
|
+
hasAnchor: c
|
|
725
|
+
})
|
|
726
|
+
},
|
|
727
|
+
node: r,
|
|
728
|
+
pos: i
|
|
729
|
+
})), t.includeChildren;
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
return U.create(r, o);
|
|
733
|
+
}
|
|
734
|
+
function ht(e) {
|
|
735
|
+
return e.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
|
|
736
|
+
}
|
|
737
|
+
function gt(e) {
|
|
738
|
+
let t = getComputedStyle(e), n = `${t.overflow} ${t.overflowY} ${t.overflowX}`;
|
|
739
|
+
return /auto|scroll|overlay/.test(n);
|
|
740
|
+
}
|
|
741
|
+
function _t(e) {
|
|
742
|
+
let t = e;
|
|
743
|
+
for (; t;) {
|
|
744
|
+
if (gt(t)) return t;
|
|
745
|
+
let e = t.parentElement;
|
|
746
|
+
if (!e) {
|
|
747
|
+
let e = t.getRootNode();
|
|
748
|
+
if (e instanceof ShadowRoot) {
|
|
749
|
+
t = e.host;
|
|
750
|
+
continue;
|
|
751
|
+
}
|
|
752
|
+
return window;
|
|
753
|
+
}
|
|
754
|
+
t = e;
|
|
755
|
+
}
|
|
756
|
+
return window;
|
|
757
|
+
}
|
|
758
|
+
function vt(e) {
|
|
759
|
+
return e === window ? {
|
|
760
|
+
top: 0,
|
|
761
|
+
bottom: window.innerHeight
|
|
762
|
+
} : e.getBoundingClientRect();
|
|
763
|
+
}
|
|
764
|
+
function yt({ view: e, scrollContainer: t }) {
|
|
765
|
+
let n = e.dom.getBoundingClientRect();
|
|
766
|
+
if (n.width <= 0 || n.height <= 0) return null;
|
|
767
|
+
let r = t ? vt(t) : {
|
|
768
|
+
top: 0,
|
|
769
|
+
bottom: window.innerHeight
|
|
770
|
+
}, i = Math.max(n.top, r.top) - dt, a = Math.min(n.bottom, r.bottom) + dt;
|
|
771
|
+
if (i >= a) return null;
|
|
772
|
+
let o = n.left + 1, s = n.right - 1;
|
|
773
|
+
if (o > s) return null;
|
|
774
|
+
let c = getComputedStyle(e.dom).direction === "rtl" ? n.right - 2 : n.left + 2, l = Math.min(Math.max(c, o), s), u = Math.max(i + 2, n.top + 1), d = Math.min(a - 2, n.bottom - 1);
|
|
775
|
+
if (u > d) return null;
|
|
776
|
+
let f = e.posAtCoords({
|
|
777
|
+
left: l,
|
|
778
|
+
top: u
|
|
779
|
+
}), p = e.posAtCoords({
|
|
780
|
+
left: l,
|
|
781
|
+
top: d
|
|
782
|
+
});
|
|
783
|
+
return !f || !p ? null : {
|
|
784
|
+
top: f.pos,
|
|
785
|
+
bottom: p.pos
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
var bt = {
|
|
789
|
+
init() {
|
|
790
|
+
return {
|
|
791
|
+
topPos: null,
|
|
792
|
+
bottomPos: null
|
|
793
|
+
};
|
|
794
|
+
},
|
|
795
|
+
apply(e, t) {
|
|
796
|
+
let n = e.getMeta($);
|
|
797
|
+
return n?.positions ? {
|
|
798
|
+
topPos: n.positions.top,
|
|
799
|
+
bottomPos: n.positions.bottom
|
|
800
|
+
} : e.docChanged ? {
|
|
801
|
+
topPos: t.topPos === null ? null : e.mapping.map(t.topPos),
|
|
802
|
+
bottomPos: t.bottomPos === null ? null : e.mapping.map(t.bottomPos)
|
|
803
|
+
} : t;
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
function xt(e) {
|
|
807
|
+
let t = _t(e.dom), n = () => {
|
|
808
|
+
let n = yt({
|
|
809
|
+
view: e,
|
|
810
|
+
scrollContainer: t
|
|
811
|
+
});
|
|
812
|
+
if (n === null) return;
|
|
813
|
+
let r = $.getState(e.state);
|
|
814
|
+
if (r?.topPos === n.top && r?.bottomPos === n.bottom) return;
|
|
815
|
+
let i = e.state.tr.setMeta($, { positions: n });
|
|
816
|
+
e.dispatch(i);
|
|
817
|
+
}, r = null, i = 0, a = () => {
|
|
818
|
+
r === null && (r = requestAnimationFrame(() => {
|
|
819
|
+
r = null;
|
|
820
|
+
let e = performance.now();
|
|
821
|
+
e - i >= 150 ? (i = e, n()) : a();
|
|
822
|
+
}));
|
|
823
|
+
};
|
|
824
|
+
t.addEventListener("scroll", a, { passive: !0 });
|
|
825
|
+
let o = typeof ResizeObserver < "u" ? new ResizeObserver(a) : null;
|
|
826
|
+
o?.observe(e.dom);
|
|
827
|
+
let s = typeof IntersectionObserver < "u" ? new IntersectionObserver(a) : null;
|
|
828
|
+
return s?.observe(e.dom), e.dom.addEventListener("focus", a), n(), {
|
|
829
|
+
update(t, n) {
|
|
830
|
+
e.state.doc.content.size !== n.doc.content.size && a();
|
|
831
|
+
},
|
|
832
|
+
destroy: () => {
|
|
833
|
+
r !== null && cancelAnimationFrame(r), t.removeEventListener("scroll", a), o?.disconnect(), s?.disconnect(), e.dom.removeEventListener("focus", a);
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
function St({ editor: e, options: t }) {
|
|
838
|
+
let n = t.dataAttribute ? `data-${ht(t.dataAttribute)}` : `data-${ut}`;
|
|
839
|
+
return new F({
|
|
840
|
+
key: $,
|
|
841
|
+
state: bt,
|
|
842
|
+
view: xt,
|
|
843
|
+
props: { decorations: ({ doc: r, selection: i }) => mt({
|
|
844
|
+
editor: e,
|
|
845
|
+
options: t,
|
|
846
|
+
dataAttribute: n,
|
|
847
|
+
doc: r,
|
|
848
|
+
selection: i
|
|
849
|
+
}) }
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
var Ct = M.create({
|
|
853
|
+
name: "placeholder",
|
|
854
|
+
addOptions() {
|
|
855
|
+
return {
|
|
856
|
+
emptyEditorClass: "is-editor-empty",
|
|
857
|
+
emptyNodeClass: "is-empty",
|
|
858
|
+
dataAttribute: ut,
|
|
859
|
+
placeholder: "Write something …",
|
|
860
|
+
showOnlyWhenEditable: !0,
|
|
861
|
+
showOnlyCurrent: !0,
|
|
862
|
+
includeChildren: !1
|
|
863
|
+
};
|
|
864
|
+
},
|
|
865
|
+
addProseMirrorPlugins() {
|
|
866
|
+
return [St({
|
|
867
|
+
editor: this.editor,
|
|
868
|
+
options: this.options
|
|
869
|
+
})];
|
|
870
|
+
}
|
|
871
|
+
}), wt = ".ProseMirror:not(.ProseMirror-focused) *::selection {\n background: transparent;\n}\n\n.ProseMirror:not(.ProseMirror-focused) *::-moz-selection {\n background: transparent;\n}";
|
|
872
|
+
M.create({
|
|
873
|
+
name: "selection",
|
|
874
|
+
addOptions() {
|
|
875
|
+
return { className: "selection" };
|
|
876
|
+
},
|
|
877
|
+
addProseMirrorPlugins() {
|
|
878
|
+
let { editor: e, options: t } = this;
|
|
879
|
+
return e.options.injectCSS && typeof document < "u" && ae(wt, e.options.injectNonce, "selection"), [new F({
|
|
880
|
+
key: new z("selection"),
|
|
881
|
+
props: { decorations(n) {
|
|
882
|
+
return n.selection.empty || e.isFocused || !e.isEditable || H(n.selection) || e.view.dragging ? null : U.create(n.doc, [N.inline(n.selection.from, n.selection.to, { class: t.className })]);
|
|
883
|
+
} }
|
|
884
|
+
})];
|
|
885
|
+
}
|
|
886
|
+
});
|
|
887
|
+
function Tt({ types: e, node: t }) {
|
|
888
|
+
return t && Array.isArray(e) && e.includes(t.type) || t?.type === e;
|
|
889
|
+
}
|
|
890
|
+
M.create({
|
|
891
|
+
name: "trailingNode",
|
|
892
|
+
addOptions() {
|
|
893
|
+
return {
|
|
894
|
+
node: void 0,
|
|
895
|
+
notAfter: []
|
|
896
|
+
};
|
|
897
|
+
},
|
|
898
|
+
addProseMirrorPlugins() {
|
|
899
|
+
let e = new z(this.name), t = this.options.node || this.editor.schema.topNodeType.contentMatch.defaultType?.name || "paragraph", n = Object.entries(this.editor.schema.nodes).map(([, e]) => e).filter((e) => (this.options.notAfter || []).concat(t).includes(e.name));
|
|
900
|
+
return [new F({
|
|
901
|
+
key: e,
|
|
902
|
+
appendTransaction: (n, r, i) => {
|
|
903
|
+
let { doc: a, tr: o, schema: s } = i, c = e.getState(i), l = a.content.size, u = s.nodes[t];
|
|
904
|
+
if (!n.some((e) => e.getMeta("skipTrailingNode")) && c) return o.insert(l, u.create());
|
|
905
|
+
},
|
|
906
|
+
state: {
|
|
907
|
+
init: (e, t) => {
|
|
908
|
+
let r = t.tr.doc.lastChild;
|
|
909
|
+
return !Tt({
|
|
910
|
+
node: r,
|
|
911
|
+
types: n
|
|
912
|
+
});
|
|
913
|
+
},
|
|
914
|
+
apply: (e, t) => {
|
|
915
|
+
if (!e.docChanged || e.getMeta("__uniqueIDTransaction")) return t;
|
|
916
|
+
let r = e.doc.lastChild;
|
|
917
|
+
return !Tt({
|
|
918
|
+
node: r,
|
|
919
|
+
types: n
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
})];
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
var Et = M.create({
|
|
927
|
+
name: "undoRedo",
|
|
928
|
+
addOptions() {
|
|
929
|
+
return {
|
|
930
|
+
depth: 100,
|
|
931
|
+
newGroupDelay: 500
|
|
932
|
+
};
|
|
933
|
+
},
|
|
934
|
+
addCommands() {
|
|
935
|
+
return {
|
|
936
|
+
undo: () => ({ state: e, dispatch: t }) => ct(e, t),
|
|
937
|
+
redo: () => ({ state: e, dispatch: t }) => lt(e, t)
|
|
938
|
+
};
|
|
939
|
+
},
|
|
940
|
+
addProseMirrorPlugins() {
|
|
941
|
+
return [ot(this.options)];
|
|
942
|
+
},
|
|
943
|
+
addKeyboardShortcuts() {
|
|
944
|
+
return {
|
|
945
|
+
"Mod-z": () => this.editor.commands.undo(),
|
|
946
|
+
"Shift-Mod-z": () => this.editor.commands.redo(),
|
|
947
|
+
"Mod-y": () => this.editor.commands.redo(),
|
|
948
|
+
"Mod-я": () => this.editor.commands.undo(),
|
|
949
|
+
"Shift-Mod-я": () => this.editor.commands.redo()
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
});
|
|
953
|
+
//#endregion
|
|
954
|
+
//#region ../../node_modules/.pnpm/@tiptap+vue-3@3.27.1_@floating-ui+dom@1.7.6_@tiptap+core@3.27.1_@tiptap+pm@3.27.1__@tip_533afe27a0e41f53f3674ff5bfd0331c/node_modules/@tiptap/vue-3/dist/index.js
|
|
955
|
+
function Dt(e) {
|
|
956
|
+
return s((t, n) => ({
|
|
957
|
+
get() {
|
|
958
|
+
return t(), e;
|
|
959
|
+
},
|
|
960
|
+
set(t) {
|
|
961
|
+
e = t, requestAnimationFrame(() => {
|
|
962
|
+
requestAnimationFrame(() => {
|
|
963
|
+
n();
|
|
964
|
+
});
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
}));
|
|
968
|
+
}
|
|
969
|
+
var Ot = class extends he {
|
|
970
|
+
constructor(e = {}) {
|
|
971
|
+
return super(e), this.contentComponent = null, this.appContext = null, this.reactiveState = Dt(this.view.state), this.reactiveExtensionStorage = Dt(this.extensionStorage), this.on("beforeTransaction", ({ nextState: e }) => {
|
|
972
|
+
this.reactiveState.value = e, this.reactiveExtensionStorage.value = this.extensionStorage;
|
|
973
|
+
}), u(this);
|
|
974
|
+
}
|
|
975
|
+
get state() {
|
|
976
|
+
return this.reactiveState ? this.reactiveState.value : this.view.state;
|
|
977
|
+
}
|
|
978
|
+
get storage() {
|
|
979
|
+
return this.reactiveExtensionStorage ? this.reactiveExtensionStorage.value : super.storage;
|
|
980
|
+
}
|
|
981
|
+
registerPlugin(e, t) {
|
|
982
|
+
let n = super.registerPlugin(e, t);
|
|
983
|
+
return this.reactiveState && (this.reactiveState.value = n), n;
|
|
984
|
+
}
|
|
985
|
+
unregisterPlugin(e) {
|
|
986
|
+
let t = super.unregisterPlugin(e);
|
|
987
|
+
return this.reactiveState && t && (this.reactiveState.value = t), t;
|
|
988
|
+
}
|
|
989
|
+
}, kt = b({
|
|
990
|
+
name: "EditorContent",
|
|
991
|
+
props: { editor: {
|
|
992
|
+
default: null,
|
|
993
|
+
type: Object
|
|
994
|
+
} },
|
|
995
|
+
setup(e) {
|
|
996
|
+
let t = _(), n = re();
|
|
997
|
+
return ie(() => {
|
|
998
|
+
let r = e.editor;
|
|
999
|
+
r && r.options.element && t.value && a(() => {
|
|
1000
|
+
if (!t.value || !r.view.dom?.parentNode) return;
|
|
1001
|
+
let e = m(t.value);
|
|
1002
|
+
t.value.append(...r.view.dom.parentNode.childNodes), r.contentComponent = n.ctx._, n && (r.appContext = {
|
|
1003
|
+
...n.appContext,
|
|
1004
|
+
provides: n.provides
|
|
1005
|
+
}), r.setOptions({ element: e }), r.createNodeViews();
|
|
1006
|
+
});
|
|
1007
|
+
}), i(() => {
|
|
1008
|
+
let t = e.editor;
|
|
1009
|
+
t && (t.contentComponent = null, t.appContext = null);
|
|
1010
|
+
}), { rootEl: t };
|
|
1011
|
+
},
|
|
1012
|
+
render() {
|
|
1013
|
+
return g("div", { ref: (e) => {
|
|
1014
|
+
this.rootEl = e;
|
|
1015
|
+
} });
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
b({
|
|
1019
|
+
name: "NodeViewContent",
|
|
1020
|
+
props: { as: {
|
|
1021
|
+
type: String,
|
|
1022
|
+
default: "div"
|
|
1023
|
+
} },
|
|
1024
|
+
inject: { nodeViewContentRef: { default: void 0 } },
|
|
1025
|
+
mounted() {
|
|
1026
|
+
let e = this.nodeViewContentRef;
|
|
1027
|
+
e && this.$el && e(this.$el);
|
|
1028
|
+
},
|
|
1029
|
+
beforeUnmount() {
|
|
1030
|
+
let e = this.nodeViewContentRef;
|
|
1031
|
+
e && e(null);
|
|
1032
|
+
},
|
|
1033
|
+
render() {
|
|
1034
|
+
return g(this.as, {
|
|
1035
|
+
style: { whiteSpace: "pre-wrap" },
|
|
1036
|
+
"data-node-view-content": ""
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
var At = b({
|
|
1041
|
+
name: "NodeViewWrapper",
|
|
1042
|
+
props: { as: {
|
|
1043
|
+
type: String,
|
|
1044
|
+
default: "div"
|
|
1045
|
+
} },
|
|
1046
|
+
inject: ["onDragStart", "decorationClasses"],
|
|
1047
|
+
render() {
|
|
1048
|
+
var e;
|
|
1049
|
+
return g(this.as, {
|
|
1050
|
+
class: this.decorationClasses,
|
|
1051
|
+
style: { whiteSpace: "normal" },
|
|
1052
|
+
"data-node-view-wrapper": "",
|
|
1053
|
+
onDragstart: this.onDragStart
|
|
1054
|
+
}, (e = this.$slots).default?.call(e));
|
|
1055
|
+
}
|
|
1056
|
+
}), jt = (e = {}) => {
|
|
1057
|
+
let t = v();
|
|
1058
|
+
return p(() => {
|
|
1059
|
+
t.value = new Ot(e);
|
|
1060
|
+
}), i(() => {
|
|
1061
|
+
var e;
|
|
1062
|
+
(e = t.value) == null || e.destroy();
|
|
1063
|
+
}), t;
|
|
1064
|
+
}, Mt = class {
|
|
1065
|
+
constructor(e, { props: t = {}, editor: n }) {
|
|
1066
|
+
this.destroyed = !1, this.editor = n, this.component = u(e), this.el = document.createElement("div"), this.props = l(t), this.renderedComponent = this.renderComponent();
|
|
1067
|
+
}
|
|
1068
|
+
get element() {
|
|
1069
|
+
return this.renderedComponent.el;
|
|
1070
|
+
}
|
|
1071
|
+
get ref() {
|
|
1072
|
+
return this.renderedComponent.vNode?.component?.exposed ? this.renderedComponent.vNode.component.exposed : this.renderedComponent.vNode?.component?.proxy;
|
|
1073
|
+
}
|
|
1074
|
+
renderComponent() {
|
|
1075
|
+
if (this.destroyed) return this.renderedComponent;
|
|
1076
|
+
let e = g(this.component, this.props);
|
|
1077
|
+
return this.editor.appContext && (e.appContext = this.editor.appContext), typeof document < "u" && this.el && O(e, this.el), {
|
|
1078
|
+
vNode: e,
|
|
1079
|
+
destroy: () => {
|
|
1080
|
+
this.el && O(null, this.el), this.el = null, e = null;
|
|
1081
|
+
},
|
|
1082
|
+
el: this.el ? this.el.firstElementChild : null
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
updateProps(e = {}) {
|
|
1086
|
+
this.destroyed || (Object.entries(e).forEach(([e, t]) => {
|
|
1087
|
+
this.props[e] = t;
|
|
1088
|
+
}), this.renderComponent());
|
|
1089
|
+
}
|
|
1090
|
+
destroy() {
|
|
1091
|
+
this.destroyed || (this.destroyed = !0, this.renderedComponent.destroy());
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
b({
|
|
1095
|
+
name: "MarkViewContent",
|
|
1096
|
+
props: { as: {
|
|
1097
|
+
type: String,
|
|
1098
|
+
default: "span"
|
|
1099
|
+
} },
|
|
1100
|
+
render() {
|
|
1101
|
+
return g(this.as, {
|
|
1102
|
+
style: { whiteSpace: "inherit" },
|
|
1103
|
+
"data-mark-view-content": ""
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
});
|
|
1107
|
+
var Nt = {
|
|
1108
|
+
editor: {
|
|
1109
|
+
type: Object,
|
|
1110
|
+
required: !0
|
|
1111
|
+
},
|
|
1112
|
+
node: {
|
|
1113
|
+
type: Object,
|
|
1114
|
+
required: !0
|
|
1115
|
+
},
|
|
1116
|
+
decorations: {
|
|
1117
|
+
type: Object,
|
|
1118
|
+
required: !0
|
|
1119
|
+
},
|
|
1120
|
+
selected: {
|
|
1121
|
+
type: Boolean,
|
|
1122
|
+
required: !0
|
|
1123
|
+
},
|
|
1124
|
+
extension: {
|
|
1125
|
+
type: Object,
|
|
1126
|
+
required: !0
|
|
1127
|
+
},
|
|
1128
|
+
getPos: {
|
|
1129
|
+
type: Function,
|
|
1130
|
+
required: !0
|
|
1131
|
+
},
|
|
1132
|
+
updateAttributes: {
|
|
1133
|
+
type: Function,
|
|
1134
|
+
required: !0
|
|
1135
|
+
},
|
|
1136
|
+
deleteNode: {
|
|
1137
|
+
type: Function,
|
|
1138
|
+
required: !0
|
|
1139
|
+
},
|
|
1140
|
+
view: {
|
|
1141
|
+
type: Object,
|
|
1142
|
+
required: !0
|
|
1143
|
+
},
|
|
1144
|
+
innerDecorations: {
|
|
1145
|
+
type: Object,
|
|
1146
|
+
required: !0
|
|
1147
|
+
},
|
|
1148
|
+
HTMLAttributes: {
|
|
1149
|
+
type: Object,
|
|
1150
|
+
required: !0
|
|
1151
|
+
}
|
|
1152
|
+
}, Pt = class extends ge {
|
|
1153
|
+
constructor(e, t, n) {
|
|
1154
|
+
super(e, t, n), this.cachedExtensionWithSyncedStorage = null, this.handlePositionUpdate = () => {
|
|
1155
|
+
let e = this.getPos();
|
|
1156
|
+
typeof e != "number" || e === this.currentPos || (this.currentPos = e, this.renderer.updateProps({ getPos: () => this.getPos() }));
|
|
1157
|
+
}, this.options.trackNodeViewPosition && this.editor.on("update", this.handlePositionUpdate);
|
|
1158
|
+
}
|
|
1159
|
+
get extensionWithSyncedStorage() {
|
|
1160
|
+
if (!this.cachedExtensionWithSyncedStorage) {
|
|
1161
|
+
let e = this.editor, t = this.extension;
|
|
1162
|
+
this.cachedExtensionWithSyncedStorage = new Proxy(t, { get(n, r, i) {
|
|
1163
|
+
return r === "storage" ? e.storage[t.name] ?? {} : Reflect.get(n, r, i);
|
|
1164
|
+
} });
|
|
1165
|
+
}
|
|
1166
|
+
return this.cachedExtensionWithSyncedStorage;
|
|
1167
|
+
}
|
|
1168
|
+
mount() {
|
|
1169
|
+
let e = {
|
|
1170
|
+
editor: this.editor,
|
|
1171
|
+
node: this.node,
|
|
1172
|
+
decorations: this.decorations,
|
|
1173
|
+
innerDecorations: this.innerDecorations,
|
|
1174
|
+
view: this.view,
|
|
1175
|
+
selected: !1,
|
|
1176
|
+
extension: this.extensionWithSyncedStorage,
|
|
1177
|
+
HTMLAttributes: this.HTMLAttributes,
|
|
1178
|
+
getPos: () => this.getPos(),
|
|
1179
|
+
updateAttributes: (e = {}) => this.updateAttributes(e),
|
|
1180
|
+
deleteNode: () => this.deleteNode()
|
|
1181
|
+
}, t = e, n = this.onDragStart.bind(this);
|
|
1182
|
+
this.decorationClasses = _(this.getDecorationClasses());
|
|
1183
|
+
let r = b({
|
|
1184
|
+
extends: { ...this.component },
|
|
1185
|
+
props: Object.keys(e),
|
|
1186
|
+
template: this.component.template,
|
|
1187
|
+
setup: (e) => {
|
|
1188
|
+
var t;
|
|
1189
|
+
return w("onDragStart", n), w("decorationClasses", this.decorationClasses), w("nodeViewContentRef", (e) => {
|
|
1190
|
+
this.contentDOMElement && e && e.firstChild !== this.contentDOMElement && e.appendChild(this.contentDOMElement);
|
|
1191
|
+
}), (t = this.component).setup?.call(t, e, { expose: () => void 0 });
|
|
1192
|
+
},
|
|
1193
|
+
__scopeId: this.component.__scopeId,
|
|
1194
|
+
__cssModules: this.component.__cssModules,
|
|
1195
|
+
__name: this.component.__name,
|
|
1196
|
+
__file: this.component.__file
|
|
1197
|
+
});
|
|
1198
|
+
this.handleSelectionUpdate = this.handleSelectionUpdate.bind(this), this.editor.on("selectionUpdate", this.handleSelectionUpdate), this.currentPos = this.getPos(), this.node.isLeaf || (this.contentDOMElement = document.createElement(this.node.isInline ? "span" : "div"), this.contentDOMElement.style.whiteSpace = "inherit", this.contentDOMElement.dataset.nodeViewContentVue = ""), this.renderer = new Mt(r, {
|
|
1199
|
+
editor: this.editor,
|
|
1200
|
+
props: t
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
get dom() {
|
|
1204
|
+
if (!this.renderer.element || !this.renderer.element.hasAttribute("data-node-view-wrapper")) throw Error("Please use the NodeViewWrapper component for your node view.");
|
|
1205
|
+
return this.renderer.element;
|
|
1206
|
+
}
|
|
1207
|
+
get contentDOM() {
|
|
1208
|
+
return this.node.isLeaf ? null : this.contentDOMElement;
|
|
1209
|
+
}
|
|
1210
|
+
handleSelectionUpdate() {
|
|
1211
|
+
let e = this.getPos();
|
|
1212
|
+
if (typeof e == "number") if (Oe({
|
|
1213
|
+
selection: this.editor.state.selection,
|
|
1214
|
+
pos: e,
|
|
1215
|
+
nodeSize: this.node.nodeSize,
|
|
1216
|
+
selectedOnTextSelection: this.options.selectedOnTextSelection
|
|
1217
|
+
})) {
|
|
1218
|
+
if (this.renderer.props.selected) return;
|
|
1219
|
+
this.selectNode();
|
|
1220
|
+
} else {
|
|
1221
|
+
if (!this.renderer.props.selected) return;
|
|
1222
|
+
this.deselectNode();
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
update(e, t, n) {
|
|
1226
|
+
let r = (e) => {
|
|
1227
|
+
this.decorationClasses.value = this.getDecorationClasses(), this.renderer.updateProps(e);
|
|
1228
|
+
};
|
|
1229
|
+
if (typeof this.options.update == "function") {
|
|
1230
|
+
let i = this.node, a = this.decorations, o = this.innerDecorations;
|
|
1231
|
+
return this.node = e, this.decorations = t, this.innerDecorations = n, this.options.update({
|
|
1232
|
+
oldNode: i,
|
|
1233
|
+
oldDecorations: a,
|
|
1234
|
+
newNode: e,
|
|
1235
|
+
newDecorations: t,
|
|
1236
|
+
oldInnerDecorations: o,
|
|
1237
|
+
innerDecorations: n,
|
|
1238
|
+
updateProps: () => r({
|
|
1239
|
+
node: e,
|
|
1240
|
+
decorations: t,
|
|
1241
|
+
innerDecorations: n,
|
|
1242
|
+
extension: this.extensionWithSyncedStorage
|
|
1243
|
+
})
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
if (e.type !== this.node.type) return !1;
|
|
1247
|
+
if (e === this.node) return this.node = e, this.decorations = t, this.innerDecorations = n, this.decorationClasses.value = this.getDecorationClasses(), !0;
|
|
1248
|
+
this.node = e, this.decorations = t, this.innerDecorations = n, this.currentPos = this.getPos();
|
|
1249
|
+
let i = {
|
|
1250
|
+
node: e,
|
|
1251
|
+
decorations: t,
|
|
1252
|
+
innerDecorations: n,
|
|
1253
|
+
extension: this.extensionWithSyncedStorage
|
|
1254
|
+
};
|
|
1255
|
+
return this.options.trackNodeViewPosition && (i.getPos = () => this.getPos()), r(i), !0;
|
|
1256
|
+
}
|
|
1257
|
+
selectNode() {
|
|
1258
|
+
this.renderer.updateProps({ selected: !0 }), this.renderer.element && this.renderer.element.classList.add("ProseMirror-selectednode");
|
|
1259
|
+
}
|
|
1260
|
+
deselectNode() {
|
|
1261
|
+
this.renderer.updateProps({ selected: !1 }), this.renderer.element && this.renderer.element.classList.remove("ProseMirror-selectednode");
|
|
1262
|
+
}
|
|
1263
|
+
getDecorationClasses() {
|
|
1264
|
+
return this.decorations.flatMap((e) => e.type.attrs.class).join(" ");
|
|
1265
|
+
}
|
|
1266
|
+
destroy() {
|
|
1267
|
+
this.renderer.destroy(), this.editor.off("selectionUpdate", this.handleSelectionUpdate), this.options.trackNodeViewPosition && this.editor.off("update", this.handlePositionUpdate), this.contentDOMElement = null;
|
|
1268
|
+
}
|
|
1269
|
+
};
|
|
1270
|
+
function Ft(e, t) {
|
|
1271
|
+
return (n) => n.editor.contentComponent ? new Pt(typeof e == "function" && "__vccOpts" in e ? e.__vccOpts : e, n, t) : {};
|
|
1272
|
+
}
|
|
1273
|
+
//#endregion
|
|
1274
|
+
//#region src/components/MergeTagPicker.vue?vue&type=script&setup=true&lang.ts
|
|
1275
|
+
var It = [
|
|
1276
|
+
"title",
|
|
1277
|
+
"aria-label",
|
|
1278
|
+
"popovertarget",
|
|
1279
|
+
"aria-expanded"
|
|
1280
|
+
], Lt = ["id", "aria-label"], Rt = {
|
|
1281
|
+
key: 0,
|
|
1282
|
+
class: "merge-tag-list"
|
|
1283
|
+
}, zt = ["onClick"], Bt = { class: "merge-tag-option-label" }, Vt = { class: "merge-tag-option-id" }, Ht = {
|
|
1284
|
+
key: 1,
|
|
1285
|
+
class: "merge-tag-empty"
|
|
1286
|
+
}, Ut = /*#__PURE__*/ Ne(/* @__PURE__ */ b({
|
|
1287
|
+
__name: "MergeTagPicker",
|
|
1288
|
+
emits: ["select"],
|
|
1289
|
+
setup(n, { emit: i }) {
|
|
1290
|
+
let s = i, { t: c, locale: l } = be(), u = r(P, x(() => ({}))), p = x(() => Object.keys(u.value).map((e) => ({
|
|
1291
|
+
id: e,
|
|
1292
|
+
label: V(u.value, e, l.value)
|
|
1293
|
+
}))), h = _(""), g = x(() => {
|
|
1294
|
+
let e = h.value.trim().toLowerCase();
|
|
1295
|
+
return e ? p.value.filter((t) => t.label.toLowerCase().includes(e) || t.id.toLowerCase().includes(e)) : p.value;
|
|
1296
|
+
}), ee = o(), v = x(() => b.value?.matches(":popover-open") ?? !1), y = d("trigger"), b = d("popover"), te = d("filterInput");
|
|
1297
|
+
function w(e) {
|
|
1298
|
+
if (e.newState !== "open") return;
|
|
1299
|
+
h.value = "";
|
|
1300
|
+
let t = b.value, n = y.value?.getBoundingClientRect();
|
|
1301
|
+
t && n && (t.style.left = `${n.left}px`, t.style.top = `${n.bottom + 4}px`);
|
|
1302
|
+
}
|
|
1303
|
+
function ne(e) {
|
|
1304
|
+
e.newState === "open" && a(() => te.value?.focus());
|
|
1305
|
+
}
|
|
1306
|
+
function O(e) {
|
|
1307
|
+
let t = e.relatedTarget, n = b.value;
|
|
1308
|
+
t instanceof Node && n?.contains(t) || n?.matches(":popover-open") && n.hidePopover();
|
|
1309
|
+
}
|
|
1310
|
+
function j(e) {
|
|
1311
|
+
s("select", e), b.value?.hidePopover();
|
|
1312
|
+
}
|
|
1313
|
+
return (n, r) => (t(), S(k, null, [p.value.length ? (t(), S("button", {
|
|
1314
|
+
key: 0,
|
|
1315
|
+
ref_key: "trigger",
|
|
1316
|
+
ref: y,
|
|
1317
|
+
type: "button",
|
|
1318
|
+
class: e(["merge-tag-trigger", { active: v.value }]),
|
|
1319
|
+
title: m(c)("blocks.text.mergeTag"),
|
|
1320
|
+
"aria-label": m(c)("blocks.text.mergeTag"),
|
|
1321
|
+
popovertarget: m(ee),
|
|
1322
|
+
"aria-haspopup": "dialog",
|
|
1323
|
+
"aria-expanded": v.value,
|
|
1324
|
+
onMousedown: r[0] ||= T(() => {}, ["prevent"])
|
|
1325
|
+
}, [A(_e, {
|
|
1326
|
+
name: "braces",
|
|
1327
|
+
size: 16
|
|
1328
|
+
})], 42, It)) : C("", !0), p.value.length ? (t(), S("div", {
|
|
1329
|
+
key: 1,
|
|
1330
|
+
id: m(ee),
|
|
1331
|
+
ref_key: "popover",
|
|
1332
|
+
ref: b,
|
|
1333
|
+
class: "merge-tag-popover",
|
|
1334
|
+
popover: "",
|
|
1335
|
+
role: "dialog",
|
|
1336
|
+
"aria-label": m(c)("blocks.text.mergeTag"),
|
|
1337
|
+
onBeforetoggle: w,
|
|
1338
|
+
onToggle: ne,
|
|
1339
|
+
onFocusout: O
|
|
1340
|
+
}, [A(Me, {
|
|
1341
|
+
ref_key: "filterInput",
|
|
1342
|
+
ref: te,
|
|
1343
|
+
modelValue: h.value,
|
|
1344
|
+
"onUpdate:modelValue": r[1] ||= (e) => h.value = e,
|
|
1345
|
+
autocomplete: "off",
|
|
1346
|
+
placeholder: m(c)("blocks.text.mergeTagSearch"),
|
|
1347
|
+
"aria-label": m(c)("blocks.text.mergeTagSearch"),
|
|
1348
|
+
size: "compact",
|
|
1349
|
+
spellcheck: "false"
|
|
1350
|
+
}, null, 8, [
|
|
1351
|
+
"modelValue",
|
|
1352
|
+
"placeholder",
|
|
1353
|
+
"aria-label"
|
|
1354
|
+
]), g.value.length ? (t(), S("ul", Rt, [(t(!0), S(k, null, f(g.value, (e) => (t(), S("li", { key: e.id }, [D("button", {
|
|
1355
|
+
type: "button",
|
|
1356
|
+
class: "merge-tag-option",
|
|
1357
|
+
onClick: (t) => j(e.id),
|
|
1358
|
+
onMousedown: r[2] ||= T(() => {}, ["prevent"])
|
|
1359
|
+
}, [D("span", Bt, E(e.label), 1), D("span", Vt, E(e.id), 1)], 40, zt)]))), 128))])) : (t(), S("p", Ht, E(m(c)("blocks.text.mergeTagEmpty")), 1))], 40, Lt)) : C("", !0)], 64));
|
|
1360
|
+
}
|
|
1361
|
+
}), [["styles", [".merge-tag-trigger[data-v-847c7f49]{border-radius:var(--bygga-radius-sm);color:var(--bygga-color-text-muted);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;min-width:1.8em;height:1.8em;padding:0;display:inline-flex}.merge-tag-trigger[data-v-847c7f49]:hover{background:var(--bygga-color-track);color:var(--bygga-color-accent)}.merge-tag-trigger.active[data-v-847c7f49]{background:var(--bygga-color-selected,var(--bygga-color-track));color:var(--bygga-color-selected-text,var(--bygga-color-accent));forced-color-adjust:none}.merge-tag-popover[data-v-847c7f49]{background:var(--bygga-color-surface);border:1px solid var(--bygga-color-border);border-radius:var(--bygga-radius-sm);box-shadow:var(--bygga-shadow-card);box-sizing:border-box;flex-direction:column;gap:.35em;width:15em;margin:0;padding:.4em;position:fixed;inset:auto}.merge-tag-popover[data-v-847c7f49]:popover-open{display:flex}.merge-tag-list[data-v-847c7f49]{flex-direction:column;gap:.15em;max-height:14em;margin:0;padding:0;list-style:none;display:flex;overflow-y:auto}.merge-tag-option[data-v-847c7f49]{border-radius:var(--bygga-radius-sm);color:var(--bygga-color-text);cursor:pointer;text-align:start;background:0 0;border:none;justify-content:space-between;align-items:baseline;gap:.5em;width:100%;padding:.35em .5em;display:flex}.merge-tag-option[data-v-847c7f49]:hover,.merge-tag-option[data-v-847c7f49]:focus-visible{background:var(--bygga-color-track);color:var(--bygga-color-accent);outline:none}.merge-tag-option-id[data-v-847c7f49]{color:var(--bygga-color-text-muted);font-variant-numeric:tabular-nums;font-size:.85em}.merge-tag-empty[data-v-847c7f49]{color:var(--bygga-color-text-muted);margin:0;padding:.35em .5em}"]], ["__scopeId", "data-v-847c7f49"]]), Wt = /* @__PURE__ */ b({
|
|
1362
|
+
__name: "MergeTagView",
|
|
1363
|
+
props: Nt,
|
|
1364
|
+
setup(i) {
|
|
1365
|
+
let a = i, { t: o, locale: s } = be(), c = r(P, x(() => ({}))), l = x(() => String(a.node.attrs.id ?? "")), u = x(() => c.value[l.value] !== void 0), d = x(() => V(c.value, l.value, s.value)), f = x(() => o("blocks.text.mergeTagChip", { name: d.value }));
|
|
1366
|
+
return (r, i) => (t(), ne(m(At), {
|
|
1367
|
+
as: "span",
|
|
1368
|
+
class: e(["merge-tag", { "is-unknown": !u.value }]),
|
|
1369
|
+
"data-merge-tag": l.value,
|
|
1370
|
+
contenteditable: "false",
|
|
1371
|
+
role: "img",
|
|
1372
|
+
"aria-label": f.value,
|
|
1373
|
+
title: f.value
|
|
1374
|
+
}, {
|
|
1375
|
+
default: n(() => [y(E(d.value), 1)]),
|
|
1376
|
+
_: 1
|
|
1377
|
+
}, 8, [
|
|
1378
|
+
"class",
|
|
1379
|
+
"data-merge-tag",
|
|
1380
|
+
"aria-label",
|
|
1381
|
+
"title"
|
|
1382
|
+
]));
|
|
1383
|
+
}
|
|
1384
|
+
}), Gt = "textStyle";
|
|
1385
|
+
function Kt(e) {
|
|
1386
|
+
return e.replace(/["']/g, "").replace(/\s+/g, " ").trim().toLowerCase();
|
|
1387
|
+
}
|
|
1388
|
+
var qt = /* @__PURE__ */ new Map([[Kt(ve), ve]]);
|
|
1389
|
+
function Jt(e) {
|
|
1390
|
+
if (e.type.name !== Gt) return e;
|
|
1391
|
+
let { fontFamily: t } = e.attrs;
|
|
1392
|
+
if (t === null) return e;
|
|
1393
|
+
let n = qt.get(Kt(t));
|
|
1394
|
+
if (n !== void 0) return n === t ? e : e.type.create({
|
|
1395
|
+
...e.attrs,
|
|
1396
|
+
fontFamily: n
|
|
1397
|
+
});
|
|
1398
|
+
let r = {
|
|
1399
|
+
...e.attrs,
|
|
1400
|
+
fontFamily: null
|
|
1401
|
+
};
|
|
1402
|
+
return Object.entries(r).some(([e, t]) => e !== "fontFamily" && t !== null) ? e.type.create(r) : void 0;
|
|
1403
|
+
}
|
|
1404
|
+
function Yt(e) {
|
|
1405
|
+
return e.flatMap((e) => {
|
|
1406
|
+
let t = Jt(e);
|
|
1407
|
+
return t ? [t] : [];
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
function Xt(e) {
|
|
1411
|
+
return e.isText ? e.mark(Yt(e.marks)) : e.copy(Zt(e.content)).mark(Yt(e.marks));
|
|
1412
|
+
}
|
|
1413
|
+
function Zt(e) {
|
|
1414
|
+
let t = [];
|
|
1415
|
+
for (let n = 0; n < e.childCount; n++) t.push(Xt(e.child(n)));
|
|
1416
|
+
return B.fromArray(t);
|
|
1417
|
+
}
|
|
1418
|
+
function Qt(e) {
|
|
1419
|
+
return new R(Zt(e.content), e.openStart, e.openEnd);
|
|
1420
|
+
}
|
|
1421
|
+
//#endregion
|
|
1422
|
+
//#region src/panels/contentPanel/components/blocks/TextEditor.vue?vue&type=script&setup=true&lang.ts
|
|
1423
|
+
var $t = ["aria-label", "value"], en = { value: "paragraph" }, tn = ["value"], nn = ["aria-label", "value"], rn = {
|
|
1424
|
+
value: "mixed",
|
|
1425
|
+
disabled: "",
|
|
1426
|
+
hidden: ""
|
|
1427
|
+
}, an = { value: "sans" }, on = { value: "serif" }, sn = ["title", "aria-label"], cn = ["title", "aria-label"], ln = ["title", "aria-label"], un = [
|
|
1428
|
+
"title",
|
|
1429
|
+
"popovertarget",
|
|
1430
|
+
"aria-expanded"
|
|
1431
|
+
], dn = ["id", "aria-label"], fn = { class: "link-field" }, pn = {
|
|
1432
|
+
key: 0,
|
|
1433
|
+
class: "link-anchor"
|
|
1434
|
+
}, mn = {
|
|
1435
|
+
key: 0,
|
|
1436
|
+
value: ""
|
|
1437
|
+
}, hn = {
|
|
1438
|
+
key: 1,
|
|
1439
|
+
value: "",
|
|
1440
|
+
disabled: "",
|
|
1441
|
+
hidden: ""
|
|
1442
|
+
}, gn = ["value"], _n = ["title", "aria-label"], vn = ["title", "onClick"], yn = {
|
|
1443
|
+
"aria-hidden": "true",
|
|
1444
|
+
height: "16",
|
|
1445
|
+
viewBox: "0 0 16 16",
|
|
1446
|
+
width: "16"
|
|
1447
|
+
}, bn = [
|
|
1448
|
+
"width",
|
|
1449
|
+
"x",
|
|
1450
|
+
"y"
|
|
1451
|
+
], xn = /*#__PURE__*/ Ne(/* @__PURE__ */ b({
|
|
1452
|
+
__name: "TextEditor",
|
|
1453
|
+
props: /*@__PURE__*/ j({
|
|
1454
|
+
editable: {
|
|
1455
|
+
type: Boolean,
|
|
1456
|
+
default: !1
|
|
1457
|
+
},
|
|
1458
|
+
background: { type: null },
|
|
1459
|
+
padding: { type: null },
|
|
1460
|
+
borderRadius: { type: null },
|
|
1461
|
+
border: { type: null },
|
|
1462
|
+
availableWidth: { type: Number },
|
|
1463
|
+
outerVmlBackground: { type: Boolean }
|
|
1464
|
+
}, {
|
|
1465
|
+
text: { required: !0 },
|
|
1466
|
+
textModifiers: {}
|
|
1467
|
+
}),
|
|
1468
|
+
emits: ["update:text"],
|
|
1469
|
+
setup(i) {
|
|
1470
|
+
let s = c(i, "text"), l = i, { t: u } = be(), p = [
|
|
1471
|
+
"left",
|
|
1472
|
+
"center",
|
|
1473
|
+
"right",
|
|
1474
|
+
"justify"
|
|
1475
|
+
], g = x(() => u("blocks.text.label")), v = jt({
|
|
1476
|
+
...de,
|
|
1477
|
+
editorProps: {
|
|
1478
|
+
attributes: {
|
|
1479
|
+
"aria-label": g.value,
|
|
1480
|
+
"aria-multiline": "true",
|
|
1481
|
+
role: "textbox"
|
|
1482
|
+
},
|
|
1483
|
+
transformPasted: (e) => Qt(e)
|
|
1484
|
+
},
|
|
1485
|
+
content: me(s.value),
|
|
1486
|
+
editable: l.editable,
|
|
1487
|
+
extensions: [
|
|
1488
|
+
...Ee.map((e) => e.name === "mergeTag" ? e.extend({ addNodeView: () => Ft(Wt) }) : e),
|
|
1489
|
+
Et,
|
|
1490
|
+
Ct.configure({ placeholder: () => u("blocks.text.placeholder") })
|
|
1491
|
+
],
|
|
1492
|
+
onUpdate({ editor: e }) {
|
|
1493
|
+
s.value = Pe(e.getJSON()), j();
|
|
1494
|
+
},
|
|
1495
|
+
onSelectionUpdate() {
|
|
1496
|
+
j();
|
|
1497
|
+
}
|
|
1498
|
+
});
|
|
1499
|
+
h(g, (e) => {
|
|
1500
|
+
v.value?.setOptions({ editorProps: { attributes: { "aria-label": e } } });
|
|
1501
|
+
}), h(s, (e) => {
|
|
1502
|
+
let t = v.value;
|
|
1503
|
+
!t || oe(e, Pe(t.getJSON())) || t.commands.setContent(me(e), { emitUpdate: !1 });
|
|
1504
|
+
}), h(() => l.editable, (e) => v.value?.setEditable(e));
|
|
1505
|
+
let y = d("root"), b = d("toolbar");
|
|
1506
|
+
function w() {
|
|
1507
|
+
let e = b.value;
|
|
1508
|
+
!e || e.matches(":popover-open") || (e.showPopover(), j());
|
|
1509
|
+
}
|
|
1510
|
+
function ne(e) {
|
|
1511
|
+
let t = e.relatedTarget;
|
|
1512
|
+
t instanceof Node && y.value?.contains(t) || b.value?.matches(":popover-open") && b.value.hidePopover();
|
|
1513
|
+
}
|
|
1514
|
+
function O(e) {
|
|
1515
|
+
let t = e.ownerDocument, n = e.getRootNode();
|
|
1516
|
+
if (!(n instanceof ShadowRoot)) {
|
|
1517
|
+
let e = t.getSelection();
|
|
1518
|
+
return e && e.rangeCount > 0 && !e.isCollapsed ? e.getRangeAt(0) : void 0;
|
|
1519
|
+
}
|
|
1520
|
+
let r = n.getSelection?.();
|
|
1521
|
+
if (r) return r.rangeCount > 0 && !r.isCollapsed ? r.getRangeAt(0) : void 0;
|
|
1522
|
+
let [i] = t.getSelection()?.getComposedRanges?.({ shadowRoots: [n] }) ?? [];
|
|
1523
|
+
if (!i || i.collapsed) return;
|
|
1524
|
+
let a = t.createRange();
|
|
1525
|
+
return a.setStart(i.startContainer, i.startOffset), a.setEnd(i.endContainer, i.endOffset), a;
|
|
1526
|
+
}
|
|
1527
|
+
function j() {
|
|
1528
|
+
let e = v.value?.view, t = b.value, n = y.value;
|
|
1529
|
+
if (!(e && t && n && t.matches(":popover-open"))) return;
|
|
1530
|
+
let r = n.getBoundingClientRect(), i = O(n)?.getBoundingClientRect();
|
|
1531
|
+
if (!i || i.left === 0 && i.right === 0) {
|
|
1532
|
+
let t = e.coordsAtPos(e.state.selection.from);
|
|
1533
|
+
i = {
|
|
1534
|
+
left: t.left,
|
|
1535
|
+
right: t.left,
|
|
1536
|
+
top: t.top
|
|
1537
|
+
};
|
|
1538
|
+
}
|
|
1539
|
+
let a = t.offsetWidth / 2, o = (i.left + i.right) / 2;
|
|
1540
|
+
t.style.left = `${Math.min(Math.max(o, r.left + a), r.right - a)}px`, t.style.top = `${i.top}px`;
|
|
1541
|
+
}
|
|
1542
|
+
function re() {
|
|
1543
|
+
let e = v.value;
|
|
1544
|
+
if (!e) return "paragraph";
|
|
1545
|
+
let t = se.find((t) => e.isActive("heading", { level: t }));
|
|
1546
|
+
return t ? `h${t}` : "paragraph";
|
|
1547
|
+
}
|
|
1548
|
+
function ie(e) {
|
|
1549
|
+
let { target: t } = e;
|
|
1550
|
+
if (!(t instanceof HTMLSelectElement)) return;
|
|
1551
|
+
let n = v.value?.chain().focus();
|
|
1552
|
+
if (!n) return;
|
|
1553
|
+
let r = se.find((e) => `h${e}` === t.value);
|
|
1554
|
+
r ? n.setHeading({ level: r }).run() : n.setParagraph().run();
|
|
1555
|
+
}
|
|
1556
|
+
function ae() {
|
|
1557
|
+
let e = v.value;
|
|
1558
|
+
if (!e) return "sans";
|
|
1559
|
+
let { from: t, to: n, empty: r } = e.state.selection;
|
|
1560
|
+
if (r) return e.getAttributes("textStyle").fontFamily === "'Times New Roman', serif" ? "serif" : "sans";
|
|
1561
|
+
let i = !1, a = !1;
|
|
1562
|
+
return e.state.doc.nodesBetween(t, n, (e) => {
|
|
1563
|
+
e.isText && (e.marks.find((e) => e.type.name === "textStyle")?.attrs.fontFamily === "'Times New Roman', serif" ? i = !0 : a = !0);
|
|
1564
|
+
}), i && a ? "mixed" : i ? "serif" : "sans";
|
|
1565
|
+
}
|
|
1566
|
+
function pe(e) {
|
|
1567
|
+
let { target: t } = e;
|
|
1568
|
+
if (!(t instanceof HTMLSelectElement)) return;
|
|
1569
|
+
let n = v.value?.chain().focus();
|
|
1570
|
+
n && (t.value === "serif" ? n.setFontFamily(ve).run() : n.unsetFontFamily().run());
|
|
1571
|
+
}
|
|
1572
|
+
let M = x({
|
|
1573
|
+
get: () => {
|
|
1574
|
+
let e = v.value?.getAttributes("textStyle").color, t = typeof e == "string" ? fe(e) : void 0;
|
|
1575
|
+
return t ? {
|
|
1576
|
+
type: "color",
|
|
1577
|
+
...t
|
|
1578
|
+
} : le;
|
|
1579
|
+
},
|
|
1580
|
+
set: (e) => {
|
|
1581
|
+
e.type !== "transparent" && v.value?.chain().setColor(De(e)).run();
|
|
1582
|
+
}
|
|
1583
|
+
}), he = {
|
|
1584
|
+
left: "blocks.text.alignLeft",
|
|
1585
|
+
center: "blocks.text.alignCenter",
|
|
1586
|
+
right: "blocks.text.alignRight",
|
|
1587
|
+
justify: "blocks.text.alignJustify"
|
|
1588
|
+
};
|
|
1589
|
+
function ge(e) {
|
|
1590
|
+
return (e === "justify" ? [
|
|
1591
|
+
14,
|
|
1592
|
+
14,
|
|
1593
|
+
14,
|
|
1594
|
+
14
|
|
1595
|
+
] : [
|
|
1596
|
+
14,
|
|
1597
|
+
9,
|
|
1598
|
+
13,
|
|
1599
|
+
7
|
|
1600
|
+
]).map((t, n) => {
|
|
1601
|
+
let r = 1;
|
|
1602
|
+
return e === "center" ? r = (16 - t) / 2 : e === "right" && (r = 15 - t), {
|
|
1603
|
+
x: r,
|
|
1604
|
+
y: 2.5 + n * 3.5,
|
|
1605
|
+
w: t
|
|
1606
|
+
};
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
let N = o(), P = d("linkPopover"), F = d("linkInput"), I = d("linkTrigger"), L = _(""), ye = _(!1), R = _(!1);
|
|
1610
|
+
function xe(e) {
|
|
1611
|
+
if (e.newState !== "open") return;
|
|
1612
|
+
let t = v.value?.getAttributes("link")?.href;
|
|
1613
|
+
L.value = typeof t == "string" ? t : "", R.value = L.value !== "";
|
|
1614
|
+
let n = P.value, r = I.value?.getBoundingClientRect();
|
|
1615
|
+
n && r && (n.style.left = `${r.left}px`, n.style.top = `${r.bottom + 4}px`);
|
|
1616
|
+
}
|
|
1617
|
+
function z(e) {
|
|
1618
|
+
if (ye.value = e.newState === "open", e.newState !== "open") return;
|
|
1619
|
+
let t = P.value;
|
|
1620
|
+
if (t) {
|
|
1621
|
+
let e = window.innerWidth - t.offsetWidth - 8;
|
|
1622
|
+
Number.parseFloat(t.style.left) > e && (t.style.left = `${Math.max(8, e)}px`);
|
|
1623
|
+
}
|
|
1624
|
+
a(() => {
|
|
1625
|
+
F.value?.focus(), F.value?.select();
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
function B(e) {
|
|
1629
|
+
let t = e.relatedTarget, n = P.value;
|
|
1630
|
+
t instanceof Node && n?.contains(t) || n?.hidePopover();
|
|
1631
|
+
}
|
|
1632
|
+
function V() {
|
|
1633
|
+
let e = v.value?.chain().focus();
|
|
1634
|
+
if (!e) return;
|
|
1635
|
+
let t = Ae(L.value);
|
|
1636
|
+
t === "" ? e.unsetLink().run() : e.setLink({
|
|
1637
|
+
href: t,
|
|
1638
|
+
target: t.startsWith("#") ? null : "_blank"
|
|
1639
|
+
}).run(), P.value?.hidePopover();
|
|
1640
|
+
}
|
|
1641
|
+
let H = r(we, x(() => [])), U = x(() => L.value.startsWith("#") && H.value.includes(L.value.slice(1)) ? L.value.slice(1) : "");
|
|
1642
|
+
function Te(e) {
|
|
1643
|
+
e === "" ? L.value.startsWith("#") && (L.value = "") : L.value = `#${e}`;
|
|
1644
|
+
}
|
|
1645
|
+
function Oe() {
|
|
1646
|
+
v.value?.chain().focus().unsetLink().run(), P.value?.hidePopover();
|
|
1647
|
+
}
|
|
1648
|
+
function ke(e) {
|
|
1649
|
+
v.value?.chain().focus().insertContent({
|
|
1650
|
+
type: ue,
|
|
1651
|
+
attrs: { id: e }
|
|
1652
|
+
}).run();
|
|
1653
|
+
}
|
|
1654
|
+
return (r, i) => (t(), S("div", {
|
|
1655
|
+
ref_key: "root",
|
|
1656
|
+
ref: y,
|
|
1657
|
+
style: {
|
|
1658
|
+
position: "relative",
|
|
1659
|
+
width: "100%"
|
|
1660
|
+
},
|
|
1661
|
+
onFocusin: w,
|
|
1662
|
+
onFocusout: ne
|
|
1663
|
+
}, [A(m(kt), ee(l.editable ? { class: "text-input" } : {}, {
|
|
1664
|
+
editor: m(v),
|
|
1665
|
+
style: m(ce)(l)
|
|
1666
|
+
}), null, 16, ["editor", "style"]), l.editable ? (t(), S("div", {
|
|
1667
|
+
key: 0,
|
|
1668
|
+
ref_key: "toolbar",
|
|
1669
|
+
ref: b,
|
|
1670
|
+
popover: "manual",
|
|
1671
|
+
class: "toolbar"
|
|
1672
|
+
}, [
|
|
1673
|
+
D("select", {
|
|
1674
|
+
"aria-label": m(u)("blocks.text.styleLabel"),
|
|
1675
|
+
class: "style",
|
|
1676
|
+
value: re(),
|
|
1677
|
+
onChange: ie,
|
|
1678
|
+
onMousedown: i[0] ||= T(() => {}, ["stop"])
|
|
1679
|
+
}, [D("option", en, E(m(u)("blocks.text.styleNormal")), 1), (t(!0), S(k, null, f(m(se), (e) => (t(), S("option", {
|
|
1680
|
+
key: e,
|
|
1681
|
+
value: `h${e}`
|
|
1682
|
+
}, E(m(u)("blocks.text.styleHeading", { level: e })), 9, tn))), 128))], 40, $t),
|
|
1683
|
+
i[19] ||= D("span", { class: "divider" }, null, -1),
|
|
1684
|
+
D("select", {
|
|
1685
|
+
"aria-label": m(u)("blocks.text.font"),
|
|
1686
|
+
class: "font",
|
|
1687
|
+
value: ae(),
|
|
1688
|
+
onChange: pe,
|
|
1689
|
+
onMousedown: i[1] ||= T(() => {}, ["stop"])
|
|
1690
|
+
}, [
|
|
1691
|
+
D("option", rn, E(m(u)("blocks.text.fontMixed")), 1),
|
|
1692
|
+
D("option", an, E(m(u)("blocks.text.fontSansSerif")), 1),
|
|
1693
|
+
D("option", on, E(m(u)("blocks.text.fontSerif")), 1)
|
|
1694
|
+
], 40, nn),
|
|
1695
|
+
A(Se, {
|
|
1696
|
+
modelValue: M.value,
|
|
1697
|
+
"onUpdate:modelValue": i[2] ||= (e) => M.value = e,
|
|
1698
|
+
"allow-transparent": !1,
|
|
1699
|
+
compact: "",
|
|
1700
|
+
label: m(u)("blocks.text.textColor"),
|
|
1701
|
+
onMousedown: i[3] ||= T(() => {}, ["stop"])
|
|
1702
|
+
}, null, 8, ["modelValue", "label"]),
|
|
1703
|
+
i[20] ||= D("span", { class: "divider" }, null, -1),
|
|
1704
|
+
D("button", {
|
|
1705
|
+
class: e({ active: m(v)?.isActive("bold") }),
|
|
1706
|
+
type: "button",
|
|
1707
|
+
title: m(u)("blocks.text.bold"),
|
|
1708
|
+
"aria-label": m(u)("blocks.text.bold"),
|
|
1709
|
+
onClick: i[4] ||= (e) => m(v)?.chain().focus().toggleBold().run(),
|
|
1710
|
+
onMousedown: i[5] ||= T(() => {}, ["prevent"])
|
|
1711
|
+
}, [...i[16] ||= [D("b", null, "B", -1)]], 42, sn),
|
|
1712
|
+
D("button", {
|
|
1713
|
+
class: e({ active: m(v)?.isActive("italic") }),
|
|
1714
|
+
type: "button",
|
|
1715
|
+
title: m(u)("blocks.text.italic"),
|
|
1716
|
+
"aria-label": m(u)("blocks.text.italic"),
|
|
1717
|
+
onClick: i[6] ||= (e) => m(v)?.chain().focus().toggleItalic().run(),
|
|
1718
|
+
onMousedown: i[7] ||= T(() => {}, ["prevent"])
|
|
1719
|
+
}, [...i[17] ||= [D("i", null, "I", -1)]], 42, cn),
|
|
1720
|
+
D("button", {
|
|
1721
|
+
class: e({ active: m(v)?.isActive("underline") }),
|
|
1722
|
+
type: "button",
|
|
1723
|
+
title: m(u)("blocks.text.underline"),
|
|
1724
|
+
"aria-label": m(u)("blocks.text.underline"),
|
|
1725
|
+
onClick: i[8] ||= (e) => m(v)?.chain().focus().toggleUnderline().run(),
|
|
1726
|
+
onMousedown: i[9] ||= T(() => {}, ["prevent"])
|
|
1727
|
+
}, [...i[18] ||= [D("u", null, "U", -1)]], 42, ln),
|
|
1728
|
+
D("button", {
|
|
1729
|
+
ref_key: "linkTrigger",
|
|
1730
|
+
ref: I,
|
|
1731
|
+
class: e({ active: m(v)?.isActive("link") }),
|
|
1732
|
+
type: "button",
|
|
1733
|
+
title: m(u)("blocks.text.link"),
|
|
1734
|
+
popovertarget: m(N),
|
|
1735
|
+
"aria-haspopup": "dialog",
|
|
1736
|
+
"aria-expanded": ye.value,
|
|
1737
|
+
onMousedown: i[10] ||= T(() => {}, ["prevent"])
|
|
1738
|
+
}, [A(_e, {
|
|
1739
|
+
name: "link",
|
|
1740
|
+
size: 16
|
|
1741
|
+
})], 42, un),
|
|
1742
|
+
l.editable ? (t(), S("div", {
|
|
1743
|
+
key: 0,
|
|
1744
|
+
id: m(N),
|
|
1745
|
+
ref_key: "linkPopover",
|
|
1746
|
+
ref: P,
|
|
1747
|
+
class: "link-popover",
|
|
1748
|
+
popover: "",
|
|
1749
|
+
role: "dialog",
|
|
1750
|
+
"aria-label": m(u)("blocks.text.link"),
|
|
1751
|
+
onBeforetoggle: xe,
|
|
1752
|
+
onToggle: z,
|
|
1753
|
+
onFocusout: B
|
|
1754
|
+
}, [
|
|
1755
|
+
D("span", fn, [A(Me, {
|
|
1756
|
+
ref_key: "linkInput",
|
|
1757
|
+
ref: F,
|
|
1758
|
+
modelValue: L.value,
|
|
1759
|
+
"onUpdate:modelValue": i[11] ||= (e) => L.value = e,
|
|
1760
|
+
size: "compact",
|
|
1761
|
+
inputmode: "url",
|
|
1762
|
+
spellcheck: "false",
|
|
1763
|
+
autocomplete: "off",
|
|
1764
|
+
placeholder: m(u)("blocks.text.linkPlaceholder"),
|
|
1765
|
+
"aria-label": m(u)("blocks.text.linkPrompt"),
|
|
1766
|
+
onKeydown: te(T(V, ["prevent"]), ["enter"])
|
|
1767
|
+
}, null, 8, [
|
|
1768
|
+
"modelValue",
|
|
1769
|
+
"placeholder",
|
|
1770
|
+
"aria-label",
|
|
1771
|
+
"onKeydown"
|
|
1772
|
+
])]),
|
|
1773
|
+
m(H).length ? (t(), S("span", pn, [A(Ce, {
|
|
1774
|
+
size: "compact",
|
|
1775
|
+
"aria-label": m(u)("blocks.common.anchorLink.label"),
|
|
1776
|
+
"model-value": U.value,
|
|
1777
|
+
"onUpdate:modelValue": Te,
|
|
1778
|
+
onMousedown: i[12] ||= T(() => {}, ["stop"])
|
|
1779
|
+
}, {
|
|
1780
|
+
default: n(() => [U.value ? (t(), S("option", mn, E(m(u)("blocks.common.anchorLink.none")), 1)) : (t(), S("option", hn, E(m(u)("blocks.common.anchorLink.placeholder")), 1)), (t(!0), S(k, null, f(m(H), (e) => (t(), S("option", {
|
|
1781
|
+
key: e,
|
|
1782
|
+
value: e
|
|
1783
|
+
}, " #" + E(e), 9, gn))), 128))]),
|
|
1784
|
+
_: 1
|
|
1785
|
+
}, 8, ["aria-label", "model-value"])])) : C("", !0),
|
|
1786
|
+
D("button", {
|
|
1787
|
+
class: "link-apply",
|
|
1788
|
+
type: "button",
|
|
1789
|
+
onClick: V,
|
|
1790
|
+
onMousedown: i[13] ||= T(() => {}, ["prevent"])
|
|
1791
|
+
}, E(m(u)("blocks.text.linkApply")), 33),
|
|
1792
|
+
R.value ? (t(), S("button", {
|
|
1793
|
+
key: 1,
|
|
1794
|
+
class: "link-remove",
|
|
1795
|
+
type: "button",
|
|
1796
|
+
title: m(u)("blocks.text.linkRemove"),
|
|
1797
|
+
"aria-label": m(u)("blocks.text.linkRemove"),
|
|
1798
|
+
onClick: Oe,
|
|
1799
|
+
onMousedown: i[14] ||= T(() => {}, ["prevent"])
|
|
1800
|
+
}, [A(_e, {
|
|
1801
|
+
name: "trash",
|
|
1802
|
+
size: 16
|
|
1803
|
+
})], 40, _n)) : C("", !0)
|
|
1804
|
+
], 40, dn)) : C("", !0),
|
|
1805
|
+
A(Ut, { onSelect: ke }),
|
|
1806
|
+
i[21] ||= D("span", { class: "divider" }, null, -1),
|
|
1807
|
+
(t(), S(k, null, f(p, (n) => D("button", {
|
|
1808
|
+
key: n,
|
|
1809
|
+
class: e({ active: m(v)?.isActive({ textAlign: n }) }),
|
|
1810
|
+
title: m(u)(he[n]),
|
|
1811
|
+
type: "button",
|
|
1812
|
+
onClick: (e) => m(v)?.chain().focus().setTextAlign(n).run(),
|
|
1813
|
+
onMousedown: i[15] ||= T(() => {}, ["prevent"])
|
|
1814
|
+
}, [(t(), S("svg", yn, [(t(!0), S(k, null, f(ge(n), (e, n) => (t(), S("rect", {
|
|
1815
|
+
key: n,
|
|
1816
|
+
fill: "currentColor",
|
|
1817
|
+
height: "1.5",
|
|
1818
|
+
rx: "0.5",
|
|
1819
|
+
width: e.w,
|
|
1820
|
+
x: e.x,
|
|
1821
|
+
y: e.y
|
|
1822
|
+
}, null, 8, bn))), 128))]))], 42, vn)), 64))
|
|
1823
|
+
], 512)) : C("", !0)], 544));
|
|
1824
|
+
}
|
|
1825
|
+
}), [["styles", [".tiptap{font-feature-settings:\"liga\" 0;font-variant-ligatures:none;overflow-wrap:break-word;white-space:pre-wrap;position:relative}.text-input .tiptap .is-editor-empty:first-child{position:relative}.text-input .tiptap .is-editor-empty:first-child:before{color:var(--bygga-color-text-muted);content:attr(data-placeholder);pointer-events:none;text-overflow:ellipsis;inset-inline:0;white-space:nowrap;position:absolute;top:0;overflow:hidden}.merge-tag{background:var(--bygga-color-track);border:1px solid var(--bygga-color-border);border-radius:var(--bygga-radius-sm);color:var(--bygga-color-accent);cursor:default;white-space:nowrap;-webkit-user-select:all;user-select:all;padding:0 .3em;font-size:.9em}.merge-tag.is-unknown{color:var(--bygga-color-text-muted);border-style:dashed}.merge-tag.ProseMirror-selectednode{outline:2px solid var(--bygga-color-accent);outline-offset:1px}", ".toolbar[data-v-2aa085af]{background:var(--bygga-color-surface);border:1px solid var(--bygga-color-border);border-radius:var(--bygga-radius-sm);box-shadow:var(--bygga-shadow-card);white-space:nowrap;font-family:var(--bygga-font-family);align-items:center;gap:.25em;margin:0;padding:.25em;position:fixed;inset:auto;transform:translate(-50%,calc(-100% - .4em))}.toolbar[data-v-2aa085af]:popover-open{display:flex}.toolbar>button[data-v-2aa085af]{border-radius:var(--bygga-radius-sm);color:var(--bygga-color-text-muted);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;min-width:1.8em;height:1.8em;padding:0;display:inline-flex}.toolbar>button[data-v-2aa085af]:hover{background:var(--bygga-color-track);color:var(--bygga-color-accent)}.toolbar>button.active[data-v-2aa085af]{background:var(--bygga-color-selected,var(--bygga-color-track));color:var(--bygga-color-selected-text,var(--bygga-color-accent));forced-color-adjust:none}.toolbar .style[data-v-2aa085af],.toolbar .font[data-v-2aa085af]{background:var(--bygga-color-surface);border:1px solid var(--bygga-color-border);border-radius:var(--bygga-radius-sm);color:var(--bygga-color-text-muted);cursor:pointer;height:1.8em}.toolbar .divider[data-v-2aa085af]{background:var(--bygga-color-border);width:1px;height:1.4em}.link-popover[data-v-2aa085af]{background:var(--bygga-color-surface);border:1px solid var(--bygga-color-border);border-radius:var(--bygga-radius-sm);box-shadow:var(--bygga-shadow-card);align-items:center;gap:.25em;margin:0;padding:.25em;position:fixed;inset:auto}.link-popover[data-v-2aa085af]:popover-open{display:flex}.link-field[data-v-2aa085af]{width:18em}.link-anchor[data-v-2aa085af]{width:10em}.link-apply[data-v-2aa085af]{background:var(--bygga-color-accent);border-radius:var(--bygga-radius-sm);color:var(--bygga-color-surface);cursor:pointer;border:none;padding:.4em .8em}.link-remove[data-v-2aa085af]{border-radius:var(--bygga-radius-sm);color:var(--bygga-color-text-muted);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;min-width:1.8em;height:1.8em;padding:0;display:inline-flex}.link-remove[data-v-2aa085af]:hover{background:var(--bygga-color-track);color:var(--bygga-color-accent)}"]], ["__scopeId", "data-v-2aa085af"]]);
|
|
1826
|
+
//#endregion
|
|
1827
|
+
export { xn as default };
|