stilo-editor 0.2.1 → 0.3.1
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/README.md +46 -1
- package/dist/action-lB2jnYNO.js +66 -0
- package/dist/content.css +9 -0
- package/dist/core/editor.d.ts +12 -2
- package/dist/index.js +1 -1
- package/dist/react/index.d.ts +5 -0
- package/dist/react/stilo-editor.d.ts +37 -0
- package/dist/react/use-stilo-editor.d.ts +15 -0
- package/dist/react.js +75 -0
- package/dist/{src-CV6pgfTS.js → src-DxTXpULc.js} +402 -392
- package/dist/style.css +9 -0
- package/dist/svelte/action.d.ts +5 -0
- package/dist/svelte/action.js +1 -0
- package/dist/svelte/editor-action.d.ts +15 -0
- package/dist/svelte/editor-with-ui-action.d.ts +35 -0
- package/dist/svelte/index.d.ts +5 -0
- package/dist/svelte/index.js +3 -0
- package/dist/svelte/stilo-editor.svelte +47 -0
- package/dist/svelte/stilo-editor.svelte.d.ts +22 -0
- package/dist/ui/components/link-popover.d.ts +4 -1
- package/dist/ui-WFNvrkbM.js +2351 -0
- package/dist/ui.js +1 -2350
- package/dist/vue/index.d.ts +5 -0
- package/dist/vue/stilo-editor.d.ts +52 -0
- package/dist/vue/use-stilo-editor.d.ts +19 -0
- package/dist/vue.js +101 -0
- package/package.json +46 -3
package/dist/ui.js
CHANGED
|
@@ -1,2350 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { ALargeSmall as o, Bold as s, CaseSensitive as c, ChevronDown as l, ChevronUp as u, Code as d, ExternalLink as f, FaceSlightlySmilingPlus as p, Grip as m, GripHorizontal as h, GripVertical as g, Highlighter as _, Italic as v, Link as y, List as b, ListChevronsUpDown as x, ListOrdered as S, ListTodo as C, Minus as w, Pencil as T, Plus as E, Quote as D, Redo2 as O, RemoveFormatting as k, Search as A, SquareCode as j, Strikethrough as M, Subscript as N, Superscript as P, Table as F, TextAlignCenter as I, TextAlignEnd as L, TextAlignJustify as R, TextAlignStart as z, Type as ee, Underline as te, Undo2 as ne, Unlink as re, WholeWord as ie, X as ae, createElement as oe } from "lucide";
|
|
3
|
-
import { autoUpdate as se, computePosition as ce, flip as le, hide as ue, offset as B, shift as de } from "@floating-ui/dom";
|
|
4
|
-
//#region src/ui/components/shortcut.ts
|
|
5
|
-
function fe() {
|
|
6
|
-
return /Mac|iPhone|iPad/.test(navigator.platform);
|
|
7
|
-
}
|
|
8
|
-
function V(e, t) {
|
|
9
|
-
let n = e.split("-"), r = n.pop(), i = [];
|
|
10
|
-
if (t) return n.includes("Ctrl") && i.push("⌃"), n.includes("Alt") && i.push("⌥"), n.includes("Shift") && i.push("⇧"), n.includes("Mod") && i.push("⌘"), i.join("") + (r.length === 1 ? r.toUpperCase() : r);
|
|
11
|
-
let a = n.includes("Mod"), o = n.includes("Ctrl");
|
|
12
|
-
return (o || a && !o) && i.push("Ctrl"), n.includes("Alt") && i.push("Alt"), n.includes("Shift") && i.push("Shift"), i.join("+") + (i.length > 0 ? "+" : "") + (r.length === 1 ? r.toUpperCase() : r);
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/ui/i18n/en.ts
|
|
16
|
-
var H = {
|
|
17
|
-
"toolbar.label": "Formatting",
|
|
18
|
-
"toolbar.undo": "Undo",
|
|
19
|
-
"toolbar.redo": "Redo",
|
|
20
|
-
"toolbar.bold": "Bold",
|
|
21
|
-
"toolbar.italic": "Italic",
|
|
22
|
-
"toolbar.underline": "Underline",
|
|
23
|
-
"toolbar.strike": "Strikethrough",
|
|
24
|
-
"toolbar.subscript": "Subscript",
|
|
25
|
-
"toolbar.superscript": "Superscript",
|
|
26
|
-
"toolbar.code": "Code",
|
|
27
|
-
"toolbar.clearFormatting": "Clear formatting",
|
|
28
|
-
"toolbar.textCase": "Text case",
|
|
29
|
-
"toolbar.bulletList": "Bulleted list",
|
|
30
|
-
"toolbar.orderedList": "Numbered list",
|
|
31
|
-
"toolbar.taskList": "Checklist",
|
|
32
|
-
"toolbar.blockquote": "Quote",
|
|
33
|
-
"toolbar.codeBlock": "Code block",
|
|
34
|
-
"toolbar.horizontalRule": "Horizontal line",
|
|
35
|
-
"toolbar.link": "Link",
|
|
36
|
-
"toolbar.heading": "Text style",
|
|
37
|
-
"toolbar.fontFamily": "Font",
|
|
38
|
-
"toolbar.fontSize": "Font size",
|
|
39
|
-
"fontSize.decrease": "Decrease font size",
|
|
40
|
-
"fontSize.increase": "Increase font size",
|
|
41
|
-
"toolbar.textAlign": "Alignment",
|
|
42
|
-
"align.left": "Align left",
|
|
43
|
-
"align.center": "Center",
|
|
44
|
-
"align.right": "Align right",
|
|
45
|
-
"align.justify": "Justify",
|
|
46
|
-
"toolbar.lineHeight": "Line spacing",
|
|
47
|
-
"lineHeight.default": "Default",
|
|
48
|
-
"textCase.upper": "UPPERCASE",
|
|
49
|
-
"textCase.lower": "lowercase",
|
|
50
|
-
"textCase.title": "Title Case",
|
|
51
|
-
"textCase.sentence": "Sentence case",
|
|
52
|
-
"textCase.toggle": "tOGGLE cASE",
|
|
53
|
-
"font.default": "Default",
|
|
54
|
-
"font.sansSerif": "Sans serif",
|
|
55
|
-
"font.serif": "Serif",
|
|
56
|
-
"font.monospace": "Monospace",
|
|
57
|
-
"heading.paragraph": "Paragraph",
|
|
58
|
-
"heading.h1": "Heading 1",
|
|
59
|
-
"heading.h2": "Heading 2",
|
|
60
|
-
"heading.h3": "Heading 3",
|
|
61
|
-
"heading.h4": "Heading 4",
|
|
62
|
-
"heading.h5": "Heading 5",
|
|
63
|
-
"heading.h6": "Heading 6",
|
|
64
|
-
"link.url": "URL",
|
|
65
|
-
"link.newTab": "Open in new tab",
|
|
66
|
-
"link.apply": "Apply",
|
|
67
|
-
"link.remove": "Remove link",
|
|
68
|
-
"link.edit": "Edit link",
|
|
69
|
-
"link.open": "Open link in a new tab",
|
|
70
|
-
"toolbar.characters": "Insert character",
|
|
71
|
-
"characters.search": "Search",
|
|
72
|
-
"characters.noResults": "No results",
|
|
73
|
-
"characters.symbols": "Symbols",
|
|
74
|
-
"characters.emoji": "Emoji",
|
|
75
|
-
"characters.punctuation": "Punctuation",
|
|
76
|
-
"characters.currency": "Currency",
|
|
77
|
-
"characters.math": "Math",
|
|
78
|
-
"characters.arrows": "Arrows",
|
|
79
|
-
"characters.greek": "Greek",
|
|
80
|
-
"characters.latin": "Accented letters",
|
|
81
|
-
"characters.signs": "Signs and shapes",
|
|
82
|
-
"characters.smileys": "Smileys",
|
|
83
|
-
"characters.people": "People and gestures",
|
|
84
|
-
"characters.nature": "Animals and nature",
|
|
85
|
-
"characters.food": "Food and drink",
|
|
86
|
-
"characters.travel": "Travel and places",
|
|
87
|
-
"characters.activities": "Activities",
|
|
88
|
-
"characters.objects": "Objects",
|
|
89
|
-
"characters.emojiSymbols": "Symbols",
|
|
90
|
-
"toolbar.textColor": "Text color",
|
|
91
|
-
"toolbar.highlight": "Highlight",
|
|
92
|
-
"color.more": "more colors",
|
|
93
|
-
"color.default": "Default",
|
|
94
|
-
"color.none": "No color",
|
|
95
|
-
"color.pick": "Pick a color",
|
|
96
|
-
"color.custom": "Custom color",
|
|
97
|
-
"color.apply": "Apply",
|
|
98
|
-
"color.black": "Black",
|
|
99
|
-
"color.darkGray2": "Dark gray 2",
|
|
100
|
-
"color.darkGray1": "Dark gray 1",
|
|
101
|
-
"color.gray": "Gray",
|
|
102
|
-
"color.lightGray1": "Light gray 1",
|
|
103
|
-
"color.lightGray2": "Light gray 2",
|
|
104
|
-
"color.lightGray3": "Light gray 3",
|
|
105
|
-
"color.white": "White",
|
|
106
|
-
"color.red": "Red",
|
|
107
|
-
"color.orange": "Orange",
|
|
108
|
-
"color.yellow": "Yellow",
|
|
109
|
-
"color.green": "Green",
|
|
110
|
-
"color.cyan": "Cyan",
|
|
111
|
-
"color.blue": "Blue",
|
|
112
|
-
"color.purple": "Purple",
|
|
113
|
-
"color.pink": "Pink",
|
|
114
|
-
"color.lightRed": "Light red",
|
|
115
|
-
"color.lightOrange": "Light orange",
|
|
116
|
-
"color.lightYellow": "Light yellow",
|
|
117
|
-
"color.lightGreen": "Light green",
|
|
118
|
-
"color.lightCyan": "Light cyan",
|
|
119
|
-
"color.lightBlue": "Light blue",
|
|
120
|
-
"color.lightPurple": "Light purple",
|
|
121
|
-
"color.lightPink": "Light pink",
|
|
122
|
-
"color.darkRed": "Dark red",
|
|
123
|
-
"color.darkOrange": "Dark orange",
|
|
124
|
-
"color.darkYellow": "Dark yellow",
|
|
125
|
-
"color.darkGreen": "Dark green",
|
|
126
|
-
"color.darkCyan": "Dark cyan",
|
|
127
|
-
"color.darkBlue": "Dark blue",
|
|
128
|
-
"color.darkPurple": "Dark purple",
|
|
129
|
-
"color.darkPink": "Dark pink",
|
|
130
|
-
"toolbar.table": "Table",
|
|
131
|
-
"table.insert": "Insert table",
|
|
132
|
-
"table.size": "{columns} × {rows}",
|
|
133
|
-
"table.row": "Row",
|
|
134
|
-
"table.column": "Column",
|
|
135
|
-
"table.headerRow": "Header row",
|
|
136
|
-
"table.headerColumn": "Header column",
|
|
137
|
-
"table.addRowBefore": "Insert row above",
|
|
138
|
-
"table.addRowAfter": "Insert row below",
|
|
139
|
-
"table.deleteRow": "Delete row",
|
|
140
|
-
"table.addColumnBefore": "Insert column left",
|
|
141
|
-
"table.addColumnAfter": "Insert column right",
|
|
142
|
-
"table.deleteColumn": "Delete column",
|
|
143
|
-
"table.mergeCells": "Merge cells",
|
|
144
|
-
"table.splitCell": "Split cell",
|
|
145
|
-
"table.deleteTable": "Delete table",
|
|
146
|
-
"toolbar.find": "Find and replace",
|
|
147
|
-
"find.find": "Find",
|
|
148
|
-
"find.replace": "Replace with",
|
|
149
|
-
"find.previous": "Previous match",
|
|
150
|
-
"find.next": "Next match",
|
|
151
|
-
"find.matchCase": "Match case",
|
|
152
|
-
"find.wholeWord": "Whole word",
|
|
153
|
-
"find.replaceOne": "Replace",
|
|
154
|
-
"find.replaceAll": "Replace all",
|
|
155
|
-
"find.close": "Close",
|
|
156
|
-
"find.position": "{current} of {total}",
|
|
157
|
-
"find.results": "Results: {total}",
|
|
158
|
-
"find.noResults": "No results",
|
|
159
|
-
"status.words": "Words",
|
|
160
|
-
"status.characters": "Characters"
|
|
161
|
-
}, pe = 500;
|
|
162
|
-
function me(t, n) {
|
|
163
|
-
let { container: r, messages: i = H } = n, a = document.createElement("div");
|
|
164
|
-
a.className = "stilo-status-bar";
|
|
165
|
-
let o = document.createElement("span");
|
|
166
|
-
o.className = "stilo-status-bar__words";
|
|
167
|
-
let s = document.createElement("span");
|
|
168
|
-
s.className = "stilo-status-bar__characters", a.append(o, s), r.append(a);
|
|
169
|
-
let c = 0, l = !1;
|
|
170
|
-
function u() {
|
|
171
|
-
clearTimeout(c), c = 0;
|
|
172
|
-
let n = e(t);
|
|
173
|
-
o.textContent = `${i["status.words"]}: ${n.words.toLocaleString()}`, s.textContent = `${i["status.characters"]}: ${n.characters.toLocaleString()}`;
|
|
174
|
-
}
|
|
175
|
-
let d = () => {
|
|
176
|
-
clearTimeout(c), c = window.setTimeout(u, pe);
|
|
177
|
-
};
|
|
178
|
-
function f() {
|
|
179
|
-
l || (l = !0, clearTimeout(c), t.off("input", d), t.off("destroy", f), a.remove());
|
|
180
|
-
}
|
|
181
|
-
return t.on("input", d), t.on("destroy", f), u(), {
|
|
182
|
-
element: a,
|
|
183
|
-
update: u,
|
|
184
|
-
destroy: f
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
//#endregion
|
|
188
|
-
//#region src/ui/i18n/it.ts
|
|
189
|
-
var he = {
|
|
190
|
-
"toolbar.label": "Formattazione",
|
|
191
|
-
"toolbar.undo": "Annulla",
|
|
192
|
-
"toolbar.redo": "Ripeti",
|
|
193
|
-
"toolbar.bold": "Grassetto",
|
|
194
|
-
"toolbar.italic": "Corsivo",
|
|
195
|
-
"toolbar.underline": "Sottolineato",
|
|
196
|
-
"toolbar.strike": "Barrato",
|
|
197
|
-
"toolbar.subscript": "Pedice",
|
|
198
|
-
"toolbar.superscript": "Apice",
|
|
199
|
-
"toolbar.code": "Codice",
|
|
200
|
-
"toolbar.clearFormatting": "Cancella formattazione",
|
|
201
|
-
"toolbar.textCase": "Maiuscole e minuscole",
|
|
202
|
-
"toolbar.bulletList": "Elenco puntato",
|
|
203
|
-
"toolbar.orderedList": "Elenco numerato",
|
|
204
|
-
"toolbar.taskList": "Elenco di controllo",
|
|
205
|
-
"toolbar.blockquote": "Citazione",
|
|
206
|
-
"toolbar.codeBlock": "Blocco di codice",
|
|
207
|
-
"toolbar.horizontalRule": "Linea orizzontale",
|
|
208
|
-
"toolbar.link": "Collegamento",
|
|
209
|
-
"toolbar.heading": "Stile testo",
|
|
210
|
-
"toolbar.fontFamily": "Carattere",
|
|
211
|
-
"toolbar.fontSize": "Dimensione carattere",
|
|
212
|
-
"fontSize.decrease": "Riduci dimensione carattere",
|
|
213
|
-
"fontSize.increase": "Aumenta dimensione carattere",
|
|
214
|
-
"toolbar.textAlign": "Allineamento",
|
|
215
|
-
"align.left": "Allinea a sinistra",
|
|
216
|
-
"align.center": "Centra",
|
|
217
|
-
"align.right": "Allinea a destra",
|
|
218
|
-
"align.justify": "Giustifica",
|
|
219
|
-
"toolbar.lineHeight": "Interlinea",
|
|
220
|
-
"lineHeight.default": "Predefinita",
|
|
221
|
-
"textCase.upper": "MAIUSCOLO",
|
|
222
|
-
"textCase.lower": "minuscolo",
|
|
223
|
-
"textCase.title": "Iniziali Maiuscole",
|
|
224
|
-
"textCase.sentence": "Tipo frase",
|
|
225
|
-
"textCase.toggle": "iNVERTI mAIUSCOLE",
|
|
226
|
-
"font.default": "Predefinito",
|
|
227
|
-
"font.sansSerif": "Senza grazie",
|
|
228
|
-
"font.serif": "Con grazie",
|
|
229
|
-
"font.monospace": "Monospaziato",
|
|
230
|
-
"heading.paragraph": "Paragrafo",
|
|
231
|
-
"heading.h1": "Titolo 1",
|
|
232
|
-
"heading.h2": "Titolo 2",
|
|
233
|
-
"heading.h3": "Titolo 3",
|
|
234
|
-
"heading.h4": "Titolo 4",
|
|
235
|
-
"heading.h5": "Titolo 5",
|
|
236
|
-
"heading.h6": "Titolo 6",
|
|
237
|
-
"link.url": "URL",
|
|
238
|
-
"link.newTab": "Apri in una nuova scheda",
|
|
239
|
-
"link.apply": "Applica",
|
|
240
|
-
"link.remove": "Rimuovi collegamento",
|
|
241
|
-
"link.edit": "Modifica collegamento",
|
|
242
|
-
"link.open": "Apri il collegamento in una nuova scheda",
|
|
243
|
-
"toolbar.characters": "Inserisci carattere",
|
|
244
|
-
"characters.search": "Cerca",
|
|
245
|
-
"characters.noResults": "Nessun risultato",
|
|
246
|
-
"characters.symbols": "Simboli",
|
|
247
|
-
"characters.emoji": "Emoji",
|
|
248
|
-
"characters.punctuation": "Punteggiatura",
|
|
249
|
-
"characters.currency": "Valute",
|
|
250
|
-
"characters.math": "Matematica",
|
|
251
|
-
"characters.arrows": "Frecce",
|
|
252
|
-
"characters.greek": "Greco",
|
|
253
|
-
"characters.latin": "Lettere accentate",
|
|
254
|
-
"characters.signs": "Segni e forme",
|
|
255
|
-
"characters.smileys": "Faccine",
|
|
256
|
-
"characters.people": "Persone e gesti",
|
|
257
|
-
"characters.nature": "Animali e natura",
|
|
258
|
-
"characters.food": "Cibo e bevande",
|
|
259
|
-
"characters.travel": "Viaggi e luoghi",
|
|
260
|
-
"characters.activities": "Attività",
|
|
261
|
-
"characters.objects": "Oggetti",
|
|
262
|
-
"characters.emojiSymbols": "Simboli",
|
|
263
|
-
"toolbar.textColor": "Colore testo",
|
|
264
|
-
"toolbar.highlight": "Evidenziatore",
|
|
265
|
-
"color.more": "altri colori",
|
|
266
|
-
"color.default": "Predefinito",
|
|
267
|
-
"color.none": "Nessun colore",
|
|
268
|
-
"color.pick": "Scegli un colore",
|
|
269
|
-
"color.custom": "Colore personalizzato",
|
|
270
|
-
"color.apply": "Applica",
|
|
271
|
-
"color.black": "Nero",
|
|
272
|
-
"color.darkGray2": "Grigio scuro 2",
|
|
273
|
-
"color.darkGray1": "Grigio scuro 1",
|
|
274
|
-
"color.gray": "Grigio",
|
|
275
|
-
"color.lightGray1": "Grigio chiaro 1",
|
|
276
|
-
"color.lightGray2": "Grigio chiaro 2",
|
|
277
|
-
"color.lightGray3": "Grigio chiaro 3",
|
|
278
|
-
"color.white": "Bianco",
|
|
279
|
-
"color.red": "Rosso",
|
|
280
|
-
"color.orange": "Arancione",
|
|
281
|
-
"color.yellow": "Giallo",
|
|
282
|
-
"color.green": "Verde",
|
|
283
|
-
"color.cyan": "Ciano",
|
|
284
|
-
"color.blue": "Blu",
|
|
285
|
-
"color.purple": "Viola",
|
|
286
|
-
"color.pink": "Rosa",
|
|
287
|
-
"color.lightRed": "Rosso chiaro",
|
|
288
|
-
"color.lightOrange": "Arancione chiaro",
|
|
289
|
-
"color.lightYellow": "Giallo chiaro",
|
|
290
|
-
"color.lightGreen": "Verde chiaro",
|
|
291
|
-
"color.lightCyan": "Ciano chiaro",
|
|
292
|
-
"color.lightBlue": "Blu chiaro",
|
|
293
|
-
"color.lightPurple": "Viola chiaro",
|
|
294
|
-
"color.lightPink": "Rosa chiaro",
|
|
295
|
-
"color.darkRed": "Rosso scuro",
|
|
296
|
-
"color.darkOrange": "Arancione scuro",
|
|
297
|
-
"color.darkYellow": "Giallo scuro",
|
|
298
|
-
"color.darkGreen": "Verde scuro",
|
|
299
|
-
"color.darkCyan": "Ciano scuro",
|
|
300
|
-
"color.darkBlue": "Blu scuro",
|
|
301
|
-
"color.darkPurple": "Viola scuro",
|
|
302
|
-
"color.darkPink": "Rosa scuro",
|
|
303
|
-
"toolbar.table": "Tabella",
|
|
304
|
-
"table.insert": "Inserisci tabella",
|
|
305
|
-
"table.size": "{columns} × {rows}",
|
|
306
|
-
"table.row": "Riga",
|
|
307
|
-
"table.column": "Colonna",
|
|
308
|
-
"table.headerRow": "Riga di intestazione",
|
|
309
|
-
"table.headerColumn": "Colonna di intestazione",
|
|
310
|
-
"table.addRowBefore": "Inserisci riga sopra",
|
|
311
|
-
"table.addRowAfter": "Inserisci riga sotto",
|
|
312
|
-
"table.deleteRow": "Elimina riga",
|
|
313
|
-
"table.addColumnBefore": "Inserisci colonna a sinistra",
|
|
314
|
-
"table.addColumnAfter": "Inserisci colonna a destra",
|
|
315
|
-
"table.deleteColumn": "Elimina colonna",
|
|
316
|
-
"table.mergeCells": "Unisci celle",
|
|
317
|
-
"table.splitCell": "Dividi cella",
|
|
318
|
-
"table.deleteTable": "Elimina tabella",
|
|
319
|
-
"toolbar.find": "Trova e sostituisci",
|
|
320
|
-
"find.find": "Trova",
|
|
321
|
-
"find.replace": "Sostituisci con",
|
|
322
|
-
"find.previous": "Risultato precedente",
|
|
323
|
-
"find.next": "Risultato successivo",
|
|
324
|
-
"find.matchCase": "Maiuscole/minuscole",
|
|
325
|
-
"find.wholeWord": "Parola intera",
|
|
326
|
-
"find.replaceOne": "Sostituisci",
|
|
327
|
-
"find.replaceAll": "Sostituisci tutto",
|
|
328
|
-
"find.close": "Chiudi",
|
|
329
|
-
"find.position": "{current} di {total}",
|
|
330
|
-
"find.results": "Risultati: {total}",
|
|
331
|
-
"find.noResults": "Nessun risultato",
|
|
332
|
-
"status.words": "Parole",
|
|
333
|
-
"status.characters": "Caratteri"
|
|
334
|
-
}, ge = [
|
|
335
|
-
{
|
|
336
|
-
fontFamily: "sans-serif",
|
|
337
|
-
labelKey: "font.sansSerif"
|
|
338
|
-
},
|
|
339
|
-
{
|
|
340
|
-
fontFamily: "serif",
|
|
341
|
-
labelKey: "font.serif"
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
fontFamily: "monospace",
|
|
345
|
-
labelKey: "font.monospace"
|
|
346
|
-
},
|
|
347
|
-
{
|
|
348
|
-
fontFamily: "Arial, Helvetica, sans-serif",
|
|
349
|
-
labelKey: "Arial"
|
|
350
|
-
},
|
|
351
|
-
{
|
|
352
|
-
fontFamily: "Verdana, Geneva, sans-serif",
|
|
353
|
-
labelKey: "Verdana"
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
fontFamily: "Tahoma, Geneva, sans-serif",
|
|
357
|
-
labelKey: "Tahoma"
|
|
358
|
-
},
|
|
359
|
-
{
|
|
360
|
-
fontFamily: "'Trebuchet MS', Helvetica, sans-serif",
|
|
361
|
-
labelKey: "Trebuchet MS"
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
fontFamily: "Georgia, serif",
|
|
365
|
-
labelKey: "Georgia"
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
fontFamily: "'Times New Roman', Times, serif",
|
|
369
|
-
labelKey: "Times New Roman"
|
|
370
|
-
},
|
|
371
|
-
{
|
|
372
|
-
fontFamily: "'Courier New', Courier, monospace",
|
|
373
|
-
labelKey: "Courier New"
|
|
374
|
-
}
|
|
375
|
-
], _e = {
|
|
376
|
-
pt: [
|
|
377
|
-
8,
|
|
378
|
-
9,
|
|
379
|
-
10,
|
|
380
|
-
11,
|
|
381
|
-
12,
|
|
382
|
-
14,
|
|
383
|
-
18,
|
|
384
|
-
24,
|
|
385
|
-
36,
|
|
386
|
-
48,
|
|
387
|
-
72
|
|
388
|
-
],
|
|
389
|
-
px: [
|
|
390
|
-
10,
|
|
391
|
-
12,
|
|
392
|
-
14,
|
|
393
|
-
16,
|
|
394
|
-
18,
|
|
395
|
-
20,
|
|
396
|
-
24,
|
|
397
|
-
32,
|
|
398
|
-
48,
|
|
399
|
-
64,
|
|
400
|
-
96
|
|
401
|
-
]
|
|
402
|
-
};
|
|
403
|
-
//#endregion
|
|
404
|
-
//#region src/ui/components/popover.ts
|
|
405
|
-
function U(e) {
|
|
406
|
-
let { anchor: t, content: n, container: r, placement: i = "bottom-start", offset: a = 4, onClose: o } = e, s = !1, c = !1, l, u = 0;
|
|
407
|
-
n.classList.add("stilo-popover"), n.setAttribute("hidden", ""), r.classList.add("stilo-popover-host"), r.appendChild(n);
|
|
408
|
-
function d() {
|
|
409
|
-
let e = ++u;
|
|
410
|
-
Promise.resolve(ce(t, n, {
|
|
411
|
-
strategy: "absolute",
|
|
412
|
-
placement: i,
|
|
413
|
-
middleware: [
|
|
414
|
-
B(a),
|
|
415
|
-
le(),
|
|
416
|
-
de({ padding: 8 })
|
|
417
|
-
]
|
|
418
|
-
}).then((t) => {
|
|
419
|
-
s || u !== e || (n.style.left = `${t.x}px`, n.style.top = `${t.y}px`);
|
|
420
|
-
}));
|
|
421
|
-
}
|
|
422
|
-
function f() {
|
|
423
|
-
c || s || (c = !0, n.removeAttribute("hidden"), l = se(t, n, () => {
|
|
424
|
-
c && d();
|
|
425
|
-
}), document.addEventListener("pointerdown", h, !0), document.addEventListener("keydown", g, !0));
|
|
426
|
-
}
|
|
427
|
-
function p(e = "api") {
|
|
428
|
-
c && !s && (c = !1, n.setAttribute("hidden", ""), l?.(), l = void 0, document.removeEventListener("pointerdown", h, !0), document.removeEventListener("keydown", g, !0), o?.(e));
|
|
429
|
-
}
|
|
430
|
-
function m() {
|
|
431
|
-
s || (s = !0, c && (c = !1, n.setAttribute("hidden", ""), l?.(), l = void 0, document.removeEventListener("pointerdown", h, !0), document.removeEventListener("keydown", g, !0), o?.("api")), r.contains(n) && r.removeChild(n), r.querySelector(":scope > .stilo-popover") || r.classList.remove("stilo-popover-host"));
|
|
432
|
-
}
|
|
433
|
-
function h(e) {
|
|
434
|
-
if (!c || s) return;
|
|
435
|
-
let r = e.target;
|
|
436
|
-
n.contains(r) || typeof t == "object" && "nodeType" in t && t.nodeType === 1 && t.contains(r) || p("outside");
|
|
437
|
-
}
|
|
438
|
-
function g(e) {
|
|
439
|
-
c && !s && e.key === "Escape" && (e.preventDefault(), p("escape"));
|
|
440
|
-
}
|
|
441
|
-
return {
|
|
442
|
-
get isOpen() {
|
|
443
|
-
return c;
|
|
444
|
-
},
|
|
445
|
-
open: f,
|
|
446
|
-
close: p,
|
|
447
|
-
destroy: m
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
//#endregion
|
|
451
|
-
//#region src/ui/components/link-popover.ts
|
|
452
|
-
var ve = "https://example.com";
|
|
453
|
-
function ye(e) {
|
|
454
|
-
return e.isActive("link") || e.commands.setLink.can({ href: ve });
|
|
455
|
-
}
|
|
456
|
-
function be(e, t) {
|
|
457
|
-
let { container: n, messages: r } = t, i = {
|
|
458
|
-
contextElement: e.view.dom,
|
|
459
|
-
getBoundingClientRect: () => {
|
|
460
|
-
let { from: t, to: n } = e.state.selection, r = e.view.coordsAtPos(t), i = e.view.coordsAtPos(n), a = Math.min(r.left, i.left), o = Math.max(r.right, i.right), { top: s } = r, { bottom: c } = i;
|
|
461
|
-
return {
|
|
462
|
-
x: a,
|
|
463
|
-
y: s,
|
|
464
|
-
left: a,
|
|
465
|
-
top: s,
|
|
466
|
-
right: o,
|
|
467
|
-
bottom: c,
|
|
468
|
-
width: o - a,
|
|
469
|
-
height: c - s
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
}, a = document.createElement("div");
|
|
473
|
-
a.className = "stilo-link-popover", a.setAttribute("role", "dialog"), a.setAttribute("aria-label", r["toolbar.link"]);
|
|
474
|
-
let o = document.createElement("form");
|
|
475
|
-
o.className = "stilo-link-popover__form";
|
|
476
|
-
let s = document.createElement("input");
|
|
477
|
-
s.type = "text", s.inputMode = "url", s.className = "stilo-link-popover__url", s.placeholder = "https://", s.autocomplete = "off", s.spellcheck = !1, s.setAttribute("aria-label", r["link.url"]);
|
|
478
|
-
let c = document.createElement("label");
|
|
479
|
-
c.className = "stilo-link-popover__new-tab";
|
|
480
|
-
let l = document.createElement("input");
|
|
481
|
-
l.type = "checkbox", c.append(l, r["link.newTab"]);
|
|
482
|
-
let u = document.createElement("div");
|
|
483
|
-
u.className = "stilo-link-popover__actions";
|
|
484
|
-
let d = xe("submit", r["link.apply"]);
|
|
485
|
-
d.classList.add("stilo-link-popover__button--primary");
|
|
486
|
-
let f = xe("button", r["link.remove"]);
|
|
487
|
-
u.append(d, f), o.append(s, c, u), a.append(o);
|
|
488
|
-
let p = U({
|
|
489
|
-
anchor: i,
|
|
490
|
-
content: a,
|
|
491
|
-
container: n,
|
|
492
|
-
onClose: (t) => {
|
|
493
|
-
t === "escape" && e.focus();
|
|
494
|
-
}
|
|
495
|
-
});
|
|
496
|
-
function m() {
|
|
497
|
-
p.close(), e.focus();
|
|
498
|
-
}
|
|
499
|
-
let h = (t) => {
|
|
500
|
-
t.preventDefault();
|
|
501
|
-
let n = s.value.trim();
|
|
502
|
-
(n ? e.commands.setLink({
|
|
503
|
-
href: n,
|
|
504
|
-
target: l.checked ? "_blank" : null
|
|
505
|
-
}) : !e.isActive("link") || e.commands.unsetLink()) ? m() : (s.setAttribute("aria-invalid", "true"), s.focus());
|
|
506
|
-
}, g = () => {
|
|
507
|
-
e.commands.unsetLink(), m();
|
|
508
|
-
}, _ = () => {
|
|
509
|
-
s.removeAttribute("aria-invalid");
|
|
510
|
-
};
|
|
511
|
-
o.addEventListener("submit", h), f.addEventListener("click", g), s.addEventListener("input", _);
|
|
512
|
-
function v() {
|
|
513
|
-
if (p.isOpen || !ye(e)) return;
|
|
514
|
-
let { href: t, target: n } = e.getAttributes("link");
|
|
515
|
-
s.value = typeof t == "string" ? t : "", s.removeAttribute("aria-invalid"), l.checked = n === "_blank", f.hidden = !e.isActive("link"), p.open(), s.focus({ preventScroll: !0 }), s.select();
|
|
516
|
-
}
|
|
517
|
-
function y() {
|
|
518
|
-
o.removeEventListener("submit", h), f.removeEventListener("click", g), s.removeEventListener("input", _), p.destroy();
|
|
519
|
-
}
|
|
520
|
-
return {
|
|
521
|
-
get isOpen() {
|
|
522
|
-
return p.isOpen;
|
|
523
|
-
},
|
|
524
|
-
open: v,
|
|
525
|
-
close: () => p.close(),
|
|
526
|
-
destroy: y
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
|
-
function xe(e, t) {
|
|
530
|
-
let n = document.createElement("button");
|
|
531
|
-
return n.type = e, n.className = "stilo-link-popover__button", n.textContent = t, n;
|
|
532
|
-
}
|
|
533
|
-
//#endregion
|
|
534
|
-
//#region src/ui/toolbar/palette.ts
|
|
535
|
-
function W(e, t) {
|
|
536
|
-
return {
|
|
537
|
-
color: e,
|
|
538
|
-
labelKey: t
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
|
-
var G = [
|
|
542
|
-
W("#000000", "color.black"),
|
|
543
|
-
W("#404040", "color.darkGray2"),
|
|
544
|
-
W("#737373", "color.darkGray1"),
|
|
545
|
-
W("#a3a3a3", "color.gray"),
|
|
546
|
-
W("#d4d4d4", "color.lightGray1"),
|
|
547
|
-
W("#e5e5e5", "color.lightGray2"),
|
|
548
|
-
W("#f5f5f5", "color.lightGray3"),
|
|
549
|
-
W("#ffffff", "color.white"),
|
|
550
|
-
W("#ef4444", "color.red"),
|
|
551
|
-
W("#f97316", "color.orange"),
|
|
552
|
-
W("#eab308", "color.yellow"),
|
|
553
|
-
W("#22c55e", "color.green"),
|
|
554
|
-
W("#06b6d4", "color.cyan"),
|
|
555
|
-
W("#3b82f6", "color.blue"),
|
|
556
|
-
W("#a855f7", "color.purple"),
|
|
557
|
-
W("#ec4899", "color.pink"),
|
|
558
|
-
W("#fecaca", "color.lightRed"),
|
|
559
|
-
W("#fed7aa", "color.lightOrange"),
|
|
560
|
-
W("#fef08a", "color.lightYellow"),
|
|
561
|
-
W("#bbf7d0", "color.lightGreen"),
|
|
562
|
-
W("#a5f3fc", "color.lightCyan"),
|
|
563
|
-
W("#bfdbfe", "color.lightBlue"),
|
|
564
|
-
W("#e9d5ff", "color.lightPurple"),
|
|
565
|
-
W("#fbcfe8", "color.lightPink"),
|
|
566
|
-
W("#991b1b", "color.darkRed"),
|
|
567
|
-
W("#9a3412", "color.darkOrange"),
|
|
568
|
-
W("#854d0e", "color.darkYellow"),
|
|
569
|
-
W("#166534", "color.darkGreen"),
|
|
570
|
-
W("#155e75", "color.darkCyan"),
|
|
571
|
-
W("#1e40af", "color.darkBlue"),
|
|
572
|
-
W("#6b21a8", "color.darkPurple"),
|
|
573
|
-
W("#9d174d", "color.darkPink")
|
|
574
|
-
], Se = [
|
|
575
|
-
["undo", "redo"],
|
|
576
|
-
["heading"],
|
|
577
|
-
["fontFamily", "fontSize"],
|
|
578
|
-
[
|
|
579
|
-
"bold",
|
|
580
|
-
"italic",
|
|
581
|
-
"underline",
|
|
582
|
-
"strike",
|
|
583
|
-
"code",
|
|
584
|
-
"subscript",
|
|
585
|
-
"superscript",
|
|
586
|
-
"link",
|
|
587
|
-
"clearFormatting",
|
|
588
|
-
"textCase"
|
|
589
|
-
],
|
|
590
|
-
["textColor", "highlight"],
|
|
591
|
-
["textAlign", "lineHeight"],
|
|
592
|
-
[
|
|
593
|
-
"bulletList",
|
|
594
|
-
"orderedList",
|
|
595
|
-
"taskList",
|
|
596
|
-
"blockquote",
|
|
597
|
-
"codeBlock",
|
|
598
|
-
"horizontalRule",
|
|
599
|
-
"table",
|
|
600
|
-
"characters"
|
|
601
|
-
],
|
|
602
|
-
["find"]
|
|
603
|
-
], Ce = {
|
|
604
|
-
undo: {
|
|
605
|
-
id: "undo",
|
|
606
|
-
kind: "button",
|
|
607
|
-
icon: ne,
|
|
608
|
-
labelKey: "toolbar.undo",
|
|
609
|
-
shortcut: "Mod-z",
|
|
610
|
-
run: (e) => {
|
|
611
|
-
e.commands.undo();
|
|
612
|
-
},
|
|
613
|
-
isEnabled: (e) => e.commands.undo.can()
|
|
614
|
-
},
|
|
615
|
-
redo: {
|
|
616
|
-
id: "redo",
|
|
617
|
-
kind: "button",
|
|
618
|
-
icon: O,
|
|
619
|
-
labelKey: "toolbar.redo",
|
|
620
|
-
shortcut: "Mod-Shift-z",
|
|
621
|
-
run: (e) => {
|
|
622
|
-
e.commands.redo();
|
|
623
|
-
},
|
|
624
|
-
isEnabled: (e) => e.commands.redo.can()
|
|
625
|
-
},
|
|
626
|
-
bold: {
|
|
627
|
-
id: "bold",
|
|
628
|
-
kind: "button",
|
|
629
|
-
icon: s,
|
|
630
|
-
labelKey: "toolbar.bold",
|
|
631
|
-
shortcut: "Mod-b",
|
|
632
|
-
run: (e) => {
|
|
633
|
-
e.commands.toggleBold();
|
|
634
|
-
},
|
|
635
|
-
isActive: (e) => e.isActive("bold"),
|
|
636
|
-
isEnabled: (e) => "toggleBold" in e.commands && e.commands.toggleBold.can(),
|
|
637
|
-
isAvailable: (e) => "toggleBold" in e.commands
|
|
638
|
-
},
|
|
639
|
-
italic: {
|
|
640
|
-
id: "italic",
|
|
641
|
-
kind: "button",
|
|
642
|
-
icon: v,
|
|
643
|
-
labelKey: "toolbar.italic",
|
|
644
|
-
shortcut: "Mod-i",
|
|
645
|
-
run: (e) => {
|
|
646
|
-
e.commands.toggleItalic();
|
|
647
|
-
},
|
|
648
|
-
isActive: (e) => e.isActive("italic"),
|
|
649
|
-
isEnabled: (e) => "toggleItalic" in e.commands && e.commands.toggleItalic.can(),
|
|
650
|
-
isAvailable: (e) => "toggleItalic" in e.commands
|
|
651
|
-
},
|
|
652
|
-
underline: {
|
|
653
|
-
id: "underline",
|
|
654
|
-
kind: "button",
|
|
655
|
-
icon: te,
|
|
656
|
-
labelKey: "toolbar.underline",
|
|
657
|
-
shortcut: "Mod-u",
|
|
658
|
-
run: (e) => {
|
|
659
|
-
e.commands.toggleUnderline();
|
|
660
|
-
},
|
|
661
|
-
isActive: (e) => e.isActive("underline"),
|
|
662
|
-
isEnabled: (e) => "toggleUnderline" in e.commands && e.commands.toggleUnderline.can(),
|
|
663
|
-
isAvailable: (e) => "toggleUnderline" in e.commands
|
|
664
|
-
},
|
|
665
|
-
strike: {
|
|
666
|
-
id: "strike",
|
|
667
|
-
kind: "button",
|
|
668
|
-
icon: M,
|
|
669
|
-
labelKey: "toolbar.strike",
|
|
670
|
-
shortcut: "Mod-Shift-s",
|
|
671
|
-
run: (e) => {
|
|
672
|
-
e.commands.toggleStrike();
|
|
673
|
-
},
|
|
674
|
-
isActive: (e) => e.isActive("strike"),
|
|
675
|
-
isEnabled: (e) => "toggleStrike" in e.commands && e.commands.toggleStrike.can(),
|
|
676
|
-
isAvailable: (e) => "toggleStrike" in e.commands
|
|
677
|
-
},
|
|
678
|
-
code: {
|
|
679
|
-
id: "code",
|
|
680
|
-
kind: "button",
|
|
681
|
-
icon: d,
|
|
682
|
-
labelKey: "toolbar.code",
|
|
683
|
-
shortcut: "Mod-e",
|
|
684
|
-
run: (e) => {
|
|
685
|
-
e.commands.toggleCode();
|
|
686
|
-
},
|
|
687
|
-
isActive: (e) => e.isActive("code"),
|
|
688
|
-
isEnabled: (e) => "toggleCode" in e.commands && e.commands.toggleCode.can(),
|
|
689
|
-
isAvailable: (e) => "toggleCode" in e.commands
|
|
690
|
-
},
|
|
691
|
-
subscript: {
|
|
692
|
-
id: "subscript",
|
|
693
|
-
kind: "button",
|
|
694
|
-
icon: N,
|
|
695
|
-
labelKey: "toolbar.subscript",
|
|
696
|
-
shortcut: "Mod-,",
|
|
697
|
-
run: (e) => {
|
|
698
|
-
e.commands.toggleSubscript();
|
|
699
|
-
},
|
|
700
|
-
isActive: (e) => e.isActive("subscript"),
|
|
701
|
-
isEnabled: (e) => "toggleSubscript" in e.commands && e.commands.toggleSubscript.can(),
|
|
702
|
-
isAvailable: (e) => "toggleSubscript" in e.commands
|
|
703
|
-
},
|
|
704
|
-
superscript: {
|
|
705
|
-
id: "superscript",
|
|
706
|
-
kind: "button",
|
|
707
|
-
icon: P,
|
|
708
|
-
labelKey: "toolbar.superscript",
|
|
709
|
-
shortcut: "Mod-.",
|
|
710
|
-
run: (e) => {
|
|
711
|
-
e.commands.toggleSuperscript();
|
|
712
|
-
},
|
|
713
|
-
isActive: (e) => e.isActive("superscript"),
|
|
714
|
-
isEnabled: (e) => "toggleSuperscript" in e.commands && e.commands.toggleSuperscript.can(),
|
|
715
|
-
isAvailable: (e) => "toggleSuperscript" in e.commands
|
|
716
|
-
},
|
|
717
|
-
link: {
|
|
718
|
-
id: "link",
|
|
719
|
-
kind: "button",
|
|
720
|
-
icon: y,
|
|
721
|
-
labelKey: "toolbar.link",
|
|
722
|
-
shortcut: "Mod-k",
|
|
723
|
-
run: (e, t) => {
|
|
724
|
-
t.openLinkPopover();
|
|
725
|
-
},
|
|
726
|
-
isActive: (e) => e.isActive("link"),
|
|
727
|
-
isEnabled: (e) => "setLink" in e.commands && ye(e),
|
|
728
|
-
isAvailable: (e) => "setLink" in e.commands
|
|
729
|
-
},
|
|
730
|
-
clearFormatting: {
|
|
731
|
-
id: "clearFormatting",
|
|
732
|
-
kind: "button",
|
|
733
|
-
icon: k,
|
|
734
|
-
labelKey: "toolbar.clearFormatting",
|
|
735
|
-
shortcut: "Mod-\\",
|
|
736
|
-
run: (e) => {
|
|
737
|
-
e.commands.clearFormatting();
|
|
738
|
-
},
|
|
739
|
-
isEnabled: (e) => "clearFormatting" in e.commands && e.commands.clearFormatting.can(),
|
|
740
|
-
isAvailable: (e) => "clearFormatting" in e.commands
|
|
741
|
-
},
|
|
742
|
-
textCase: {
|
|
743
|
-
id: "textCase",
|
|
744
|
-
kind: "dropdown",
|
|
745
|
-
labelKey: "toolbar.textCase",
|
|
746
|
-
icon: o,
|
|
747
|
-
options: [
|
|
748
|
-
"upper",
|
|
749
|
-
"lower",
|
|
750
|
-
"title",
|
|
751
|
-
"sentence",
|
|
752
|
-
"toggle"
|
|
753
|
-
].map((e) => ({
|
|
754
|
-
id: e,
|
|
755
|
-
labelKey: `textCase.${e}`,
|
|
756
|
-
run: (t) => {
|
|
757
|
-
t.commands.setTextCase(e);
|
|
758
|
-
},
|
|
759
|
-
isEnabled: (t) => t.commands.setTextCase.can(e)
|
|
760
|
-
})),
|
|
761
|
-
isAvailable: (e) => "setTextCase" in e.commands
|
|
762
|
-
},
|
|
763
|
-
bulletList: {
|
|
764
|
-
id: "bulletList",
|
|
765
|
-
kind: "button",
|
|
766
|
-
icon: b,
|
|
767
|
-
labelKey: "toolbar.bulletList",
|
|
768
|
-
shortcut: "Mod-Shift-8",
|
|
769
|
-
run: (e) => {
|
|
770
|
-
e.commands.toggleBulletList();
|
|
771
|
-
},
|
|
772
|
-
isActive: (e) => e.isActive("bulletList"),
|
|
773
|
-
isEnabled: (e) => "toggleBulletList" in e.commands && e.commands.toggleBulletList.can(),
|
|
774
|
-
isAvailable: (e) => "toggleBulletList" in e.commands
|
|
775
|
-
},
|
|
776
|
-
orderedList: {
|
|
777
|
-
id: "orderedList",
|
|
778
|
-
kind: "button",
|
|
779
|
-
icon: S,
|
|
780
|
-
labelKey: "toolbar.orderedList",
|
|
781
|
-
shortcut: "Mod-Shift-7",
|
|
782
|
-
run: (e) => {
|
|
783
|
-
e.commands.toggleOrderedList();
|
|
784
|
-
},
|
|
785
|
-
isActive: (e) => e.isActive("orderedList"),
|
|
786
|
-
isEnabled: (e) => "toggleOrderedList" in e.commands && e.commands.toggleOrderedList.can(),
|
|
787
|
-
isAvailable: (e) => "toggleOrderedList" in e.commands
|
|
788
|
-
},
|
|
789
|
-
taskList: {
|
|
790
|
-
id: "taskList",
|
|
791
|
-
kind: "button",
|
|
792
|
-
icon: C,
|
|
793
|
-
labelKey: "toolbar.taskList",
|
|
794
|
-
shortcut: "Mod-Shift-9",
|
|
795
|
-
run: (e) => {
|
|
796
|
-
e.commands.toggleTaskList();
|
|
797
|
-
},
|
|
798
|
-
isActive: (e) => e.isActive("taskList"),
|
|
799
|
-
isEnabled: (e) => "toggleTaskList" in e.commands && e.commands.toggleTaskList.can(),
|
|
800
|
-
isAvailable: (e) => "toggleTaskList" in e.commands
|
|
801
|
-
},
|
|
802
|
-
blockquote: {
|
|
803
|
-
id: "blockquote",
|
|
804
|
-
kind: "button",
|
|
805
|
-
icon: D,
|
|
806
|
-
labelKey: "toolbar.blockquote",
|
|
807
|
-
shortcut: "Mod-Shift-b",
|
|
808
|
-
run: (e) => {
|
|
809
|
-
e.commands.toggleBlockquote();
|
|
810
|
-
},
|
|
811
|
-
isActive: (e) => e.isActive("blockquote"),
|
|
812
|
-
isEnabled: (e) => "toggleBlockquote" in e.commands && e.commands.toggleBlockquote.can(),
|
|
813
|
-
isAvailable: (e) => "toggleBlockquote" in e.commands
|
|
814
|
-
},
|
|
815
|
-
codeBlock: {
|
|
816
|
-
id: "codeBlock",
|
|
817
|
-
kind: "button",
|
|
818
|
-
icon: j,
|
|
819
|
-
labelKey: "toolbar.codeBlock",
|
|
820
|
-
shortcut: "Mod-Alt-c",
|
|
821
|
-
run: (e) => {
|
|
822
|
-
e.commands.toggleCodeBlock();
|
|
823
|
-
},
|
|
824
|
-
isActive: (e) => e.isActive("codeBlock"),
|
|
825
|
-
isEnabled: (e) => "toggleCodeBlock" in e.commands && e.commands.toggleCodeBlock.can(),
|
|
826
|
-
isAvailable: (e) => "toggleCodeBlock" in e.commands
|
|
827
|
-
},
|
|
828
|
-
horizontalRule: {
|
|
829
|
-
id: "horizontalRule",
|
|
830
|
-
kind: "button",
|
|
831
|
-
icon: w,
|
|
832
|
-
labelKey: "toolbar.horizontalRule",
|
|
833
|
-
run: (e) => {
|
|
834
|
-
e.commands.setHorizontalRule();
|
|
835
|
-
},
|
|
836
|
-
isEnabled: (e) => "setHorizontalRule" in e.commands && e.commands.setHorizontalRule.can(),
|
|
837
|
-
isAvailable: (e) => "setHorizontalRule" in e.commands
|
|
838
|
-
},
|
|
839
|
-
table: {
|
|
840
|
-
id: "table",
|
|
841
|
-
kind: "button",
|
|
842
|
-
icon: F,
|
|
843
|
-
labelKey: "toolbar.table",
|
|
844
|
-
run: (e, t) => {
|
|
845
|
-
t.toggleTableMenu();
|
|
846
|
-
},
|
|
847
|
-
isEnabled: (e) => e.isActive("table") || e.commands.insertTable.can(),
|
|
848
|
-
isAvailable: (e) => "insertTable" in e.commands
|
|
849
|
-
},
|
|
850
|
-
characters: {
|
|
851
|
-
id: "characters",
|
|
852
|
-
kind: "button",
|
|
853
|
-
icon: p,
|
|
854
|
-
labelKey: "toolbar.characters",
|
|
855
|
-
run: (e, t) => {
|
|
856
|
-
t.toggleCharacterPicker();
|
|
857
|
-
},
|
|
858
|
-
isAvailable: (e) => "insertText" in e.commands
|
|
859
|
-
},
|
|
860
|
-
find: {
|
|
861
|
-
id: "find",
|
|
862
|
-
kind: "button",
|
|
863
|
-
icon: A,
|
|
864
|
-
labelKey: "toolbar.find",
|
|
865
|
-
shortcut: "Mod-f",
|
|
866
|
-
run: (e, t) => {
|
|
867
|
-
t.toggleFindBar();
|
|
868
|
-
},
|
|
869
|
-
isAvailable: (e) => "setSearch" in e.commands
|
|
870
|
-
},
|
|
871
|
-
heading: Ie(),
|
|
872
|
-
fontFamily: Ae(),
|
|
873
|
-
fontSize: je(),
|
|
874
|
-
textAlign: Ne(),
|
|
875
|
-
lineHeight: Fe(),
|
|
876
|
-
textColor: Te(),
|
|
877
|
-
highlight: Ee()
|
|
878
|
-
};
|
|
879
|
-
function we(e, t) {
|
|
880
|
-
let { color: n } = e.getAttributes(t);
|
|
881
|
-
return typeof n == "string" ? n : null;
|
|
882
|
-
}
|
|
883
|
-
function Te(e = G) {
|
|
884
|
-
return {
|
|
885
|
-
id: "textColor",
|
|
886
|
-
kind: "color",
|
|
887
|
-
icon: ee,
|
|
888
|
-
labelKey: "toolbar.textColor",
|
|
889
|
-
palette: e,
|
|
890
|
-
defaultColor: "#000000",
|
|
891
|
-
setColor: (e, t) => t !== null && e.commands.setColor(t),
|
|
892
|
-
unsetColor: (e) => {
|
|
893
|
-
e.commands.unsetColor();
|
|
894
|
-
},
|
|
895
|
-
hasColor: (e, t) => e.isActive("textStyle", { color: t }),
|
|
896
|
-
getColor: (e) => we(e, "textStyle"),
|
|
897
|
-
isEnabled: (e) => "setColor" in e.commands && e.commands.setColor.can("#000000"),
|
|
898
|
-
isAvailable: (e) => "setColor" in e.commands
|
|
899
|
-
};
|
|
900
|
-
}
|
|
901
|
-
function Ee(e = G) {
|
|
902
|
-
return {
|
|
903
|
-
id: "highlight",
|
|
904
|
-
kind: "color",
|
|
905
|
-
icon: _,
|
|
906
|
-
labelKey: "toolbar.highlight",
|
|
907
|
-
palette: e,
|
|
908
|
-
defaultColor: null,
|
|
909
|
-
defaultChoice: !0,
|
|
910
|
-
setColor: (e, t) => e.commands.setHighlight({ color: t }),
|
|
911
|
-
unsetColor: (e) => {
|
|
912
|
-
e.commands.unsetHighlight();
|
|
913
|
-
},
|
|
914
|
-
hasColor: (e, t) => e.isActive("highlight", { color: t }),
|
|
915
|
-
getColor: (e) => we(e, "highlight"),
|
|
916
|
-
isEnabled: (e) => "setHighlight" in e.commands && e.commands.setHighlight.can(),
|
|
917
|
-
isAvailable: (e) => "setHighlight" in e.commands
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
|
-
function De(e) {
|
|
921
|
-
return e.split(",")[0].replace(/'/g, "").trim();
|
|
922
|
-
}
|
|
923
|
-
function Oe(e) {
|
|
924
|
-
return De(e).toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
|
925
|
-
}
|
|
926
|
-
function ke(e) {
|
|
927
|
-
let { fontFamily: t } = e.getAttributes("textStyle");
|
|
928
|
-
return typeof t == "string" && e.isActive("textStyle", { fontFamily: t }) ? t : null;
|
|
929
|
-
}
|
|
930
|
-
function Ae(e = ge) {
|
|
931
|
-
return {
|
|
932
|
-
id: "fontFamily",
|
|
933
|
-
kind: "dropdown",
|
|
934
|
-
labelKey: "toolbar.fontFamily",
|
|
935
|
-
options: [{
|
|
936
|
-
id: "default",
|
|
937
|
-
labelKey: "font.default",
|
|
938
|
-
run: (e) => {
|
|
939
|
-
e.commands.unsetFontFamily();
|
|
940
|
-
},
|
|
941
|
-
isActive: () => !1,
|
|
942
|
-
isEnabled: (e) => e.commands.setFontFamily.can("serif")
|
|
943
|
-
}, ...e.map(({ fontFamily: e, labelKey: t }) => ({
|
|
944
|
-
id: Oe(e),
|
|
945
|
-
labelKey: t,
|
|
946
|
-
fontFamily: e,
|
|
947
|
-
run: (t) => {
|
|
948
|
-
t.commands.setFontFamily(e);
|
|
949
|
-
},
|
|
950
|
-
isActive: (t) => t.isActive("textStyle", { fontFamily: e }),
|
|
951
|
-
isEnabled: (t) => t.commands.setFontFamily.can(e)
|
|
952
|
-
}))],
|
|
953
|
-
getValueLabel: (e) => {
|
|
954
|
-
let t = ke(e);
|
|
955
|
-
return t === null ? null : De(t);
|
|
956
|
-
},
|
|
957
|
-
isAvailable: (e) => "setFontFamily" in e.commands
|
|
958
|
-
};
|
|
959
|
-
}
|
|
960
|
-
function je(e = {}) {
|
|
961
|
-
let { unit: t = "pt", sizes: n = _e[t === "pt" ? "pt" : "px"] } = e;
|
|
962
|
-
return {
|
|
963
|
-
id: "fontSize",
|
|
964
|
-
kind: "fontSize",
|
|
965
|
-
labelKey: "toolbar.fontSize",
|
|
966
|
-
unit: t,
|
|
967
|
-
sizes: n,
|
|
968
|
-
isAvailable: (e) => "stepFontSize" in e.commands
|
|
969
|
-
};
|
|
970
|
-
}
|
|
971
|
-
function Me(e) {
|
|
972
|
-
let t = e.getAttributes("heading").textAlign ?? e.getAttributes("paragraph").textAlign;
|
|
973
|
-
return typeof t == "string" ? t : "left";
|
|
974
|
-
}
|
|
975
|
-
function Ne() {
|
|
976
|
-
return {
|
|
977
|
-
id: "textAlign",
|
|
978
|
-
kind: "iconMenu",
|
|
979
|
-
labelKey: "toolbar.textAlign",
|
|
980
|
-
options: [
|
|
981
|
-
[
|
|
982
|
-
"left",
|
|
983
|
-
z,
|
|
984
|
-
"Mod-Shift-l"
|
|
985
|
-
],
|
|
986
|
-
[
|
|
987
|
-
"center",
|
|
988
|
-
I,
|
|
989
|
-
"Mod-Shift-e"
|
|
990
|
-
],
|
|
991
|
-
[
|
|
992
|
-
"right",
|
|
993
|
-
L,
|
|
994
|
-
"Mod-Shift-r"
|
|
995
|
-
],
|
|
996
|
-
[
|
|
997
|
-
"justify",
|
|
998
|
-
R,
|
|
999
|
-
"Mod-Shift-j"
|
|
1000
|
-
]
|
|
1001
|
-
].map(([e, t, n]) => ({
|
|
1002
|
-
id: e,
|
|
1003
|
-
icon: t,
|
|
1004
|
-
labelKey: `align.${e}`,
|
|
1005
|
-
shortcut: n,
|
|
1006
|
-
run: (t) => {
|
|
1007
|
-
t.commands.setTextAlign(e);
|
|
1008
|
-
},
|
|
1009
|
-
isActive: (t) => Me(t) === e,
|
|
1010
|
-
isEnabled: (t) => t.commands.setTextAlign.can(e)
|
|
1011
|
-
})),
|
|
1012
|
-
isAvailable: (e) => "setTextAlign" in e.commands
|
|
1013
|
-
};
|
|
1014
|
-
}
|
|
1015
|
-
function Pe(e) {
|
|
1016
|
-
return e.getAttributes("heading").lineHeight ?? e.getAttributes("paragraph").lineHeight;
|
|
1017
|
-
}
|
|
1018
|
-
function Fe(e = [
|
|
1019
|
-
1,
|
|
1020
|
-
1.15,
|
|
1021
|
-
1.5,
|
|
1022
|
-
2
|
|
1023
|
-
]) {
|
|
1024
|
-
return {
|
|
1025
|
-
id: "lineHeight",
|
|
1026
|
-
kind: "dropdown",
|
|
1027
|
-
labelKey: "toolbar.lineHeight",
|
|
1028
|
-
icon: x,
|
|
1029
|
-
options: [{
|
|
1030
|
-
id: "default",
|
|
1031
|
-
labelKey: "lineHeight.default",
|
|
1032
|
-
run: (e) => {
|
|
1033
|
-
e.commands.unsetLineHeight();
|
|
1034
|
-
},
|
|
1035
|
-
isActive: (e) => Pe(e) == null,
|
|
1036
|
-
isEnabled: (e) => e.commands.unsetLineHeight.can()
|
|
1037
|
-
}, ...e.map((e) => ({
|
|
1038
|
-
id: String(e).replace(".", "-"),
|
|
1039
|
-
labelKey: String(e),
|
|
1040
|
-
run: (t) => {
|
|
1041
|
-
t.commands.setLineHeight(e);
|
|
1042
|
-
},
|
|
1043
|
-
isActive: (t) => Pe(t) === String(e),
|
|
1044
|
-
isEnabled: (t) => t.commands.setLineHeight.can(e)
|
|
1045
|
-
}))],
|
|
1046
|
-
isAvailable: (e) => "setLineHeight" in e.commands
|
|
1047
|
-
};
|
|
1048
|
-
}
|
|
1049
|
-
function Ie(e = [
|
|
1050
|
-
1,
|
|
1051
|
-
2,
|
|
1052
|
-
3,
|
|
1053
|
-
4,
|
|
1054
|
-
5,
|
|
1055
|
-
6
|
|
1056
|
-
]) {
|
|
1057
|
-
return {
|
|
1058
|
-
id: "heading",
|
|
1059
|
-
kind: "dropdown",
|
|
1060
|
-
labelKey: "toolbar.heading",
|
|
1061
|
-
options: [{
|
|
1062
|
-
id: "paragraph",
|
|
1063
|
-
labelKey: "heading.paragraph",
|
|
1064
|
-
shortcut: "Mod-Alt-0",
|
|
1065
|
-
run: (e) => {
|
|
1066
|
-
e.commands.setParagraph();
|
|
1067
|
-
},
|
|
1068
|
-
isActive: (e) => e.isActive("paragraph"),
|
|
1069
|
-
isEnabled: (e) => e.isActive("paragraph") || e.commands.setParagraph.can()
|
|
1070
|
-
}, ...e.map((e) => ({
|
|
1071
|
-
id: `h${e}`,
|
|
1072
|
-
labelKey: `heading.h${e}`,
|
|
1073
|
-
shortcut: `Mod-Alt-${e}`,
|
|
1074
|
-
run: (t) => {
|
|
1075
|
-
t.commands.setHeading({ level: e });
|
|
1076
|
-
},
|
|
1077
|
-
isActive: (t) => t.isActive("heading", { level: e }),
|
|
1078
|
-
isEnabled: (t) => t.isActive("heading", { level: e }) || t.commands.setHeading.can({ level: e })
|
|
1079
|
-
}))],
|
|
1080
|
-
isAvailable: (e) => "setHeading" in e.commands
|
|
1081
|
-
};
|
|
1082
|
-
}
|
|
1083
|
-
//#endregion
|
|
1084
|
-
//#region src/ui/components/character-picker.ts
|
|
1085
|
-
var Le = 10;
|
|
1086
|
-
async function Re() {
|
|
1087
|
-
let { SYMBOLS: e, EMOJI: t } = await import("./characters--8h5uTeF.js");
|
|
1088
|
-
return {
|
|
1089
|
-
symbols: e,
|
|
1090
|
-
emoji: t
|
|
1091
|
-
};
|
|
1092
|
-
}
|
|
1093
|
-
function ze(e, t) {
|
|
1094
|
-
let { anchor: n, container: r, messages: i } = t, a = document.createElement("div");
|
|
1095
|
-
a.className = "stilo-char-picker", a.setAttribute("role", "dialog"), a.setAttribute("aria-label", i["toolbar.characters"]);
|
|
1096
|
-
let o = document.createElement("input");
|
|
1097
|
-
o.type = "search", o.className = "stilo-char-picker__search", o.placeholder = i["characters.search"], o.autocomplete = "off", o.spellcheck = !1, o.setAttribute("aria-label", i["characters.search"]);
|
|
1098
|
-
let s = document.createElement("div");
|
|
1099
|
-
s.className = "stilo-char-picker__tabs", s.setAttribute("role", "tablist");
|
|
1100
|
-
let c = /* @__PURE__ */ new Map();
|
|
1101
|
-
for (let e of ["symbols", "emoji"]) {
|
|
1102
|
-
let t = document.createElement("button");
|
|
1103
|
-
t.type = "button", t.className = "stilo-char-picker__tab", t.setAttribute("role", "tab"), t.textContent = i[`characters.${e}`], c.set(e, t), s.append(t);
|
|
1104
|
-
}
|
|
1105
|
-
let l = document.createElement("div");
|
|
1106
|
-
l.className = "stilo-char-picker__panel", l.setAttribute("role", "tabpanel"), a.append(o, s, l), n.setAttribute("aria-haspopup", "dialog"), n.setAttribute("aria-expanded", "false");
|
|
1107
|
-
let u = U({
|
|
1108
|
-
anchor: n,
|
|
1109
|
-
content: a,
|
|
1110
|
-
container: r,
|
|
1111
|
-
onClose: (t) => {
|
|
1112
|
-
n.setAttribute("aria-expanded", "false"), t === "escape" && e.focus();
|
|
1113
|
-
}
|
|
1114
|
-
}), d = null, f = "symbols", p = [], m = [];
|
|
1115
|
-
function h(e) {
|
|
1116
|
-
f = e;
|
|
1117
|
-
for (let [t, n] of c) {
|
|
1118
|
-
let r = t === e;
|
|
1119
|
-
n.setAttribute("aria-selected", String(r)), n.tabIndex = r ? 0 : -1;
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
function g(e, t) {
|
|
1123
|
-
let n = document.createElement("div");
|
|
1124
|
-
n.className = "stilo-char-picker__grid", n.setAttribute("role", "group"), n.setAttribute("aria-label", t);
|
|
1125
|
-
let r = e.map(([e, t]) => {
|
|
1126
|
-
let n = document.createElement("button");
|
|
1127
|
-
return n.type = "button", n.className = "stilo-char-picker__char", n.tabIndex = -1, n.title = t, n.setAttribute("aria-label", t), n.dataset.character = e, n.textContent = e, n;
|
|
1128
|
-
});
|
|
1129
|
-
n.append(...r), p.push(...r);
|
|
1130
|
-
for (let e = 0; e < r.length; e += Le) m.push(r.slice(e, e + Le));
|
|
1131
|
-
return n;
|
|
1132
|
-
}
|
|
1133
|
-
function _() {
|
|
1134
|
-
if (!d) return;
|
|
1135
|
-
p = [], m = [], l.replaceChildren();
|
|
1136
|
-
let e = o.value.trim().toLowerCase();
|
|
1137
|
-
if (s.hidden = e !== "", e) {
|
|
1138
|
-
let t = [...d.symbols, ...d.emoji].flatMap((e) => e.characters).filter(([t, n]) => t === e || n.toLowerCase().includes(e));
|
|
1139
|
-
if (t.length > 0) l.append(g(t, i["characters.search"]));
|
|
1140
|
-
else {
|
|
1141
|
-
let e = document.createElement("p");
|
|
1142
|
-
e.className = "stilo-char-picker__empty", e.textContent = i["characters.noResults"], l.append(e);
|
|
1143
|
-
}
|
|
1144
|
-
} else for (let e of d[f]) {
|
|
1145
|
-
let t = i[e.labelKey], n = document.createElement("div");
|
|
1146
|
-
n.className = "stilo-char-picker__heading", n.textContent = t, l.append(n, g(e.characters, t));
|
|
1147
|
-
}
|
|
1148
|
-
p[0] && (p[0].tabIndex = 0);
|
|
1149
|
-
}
|
|
1150
|
-
function v(e) {
|
|
1151
|
-
if (e) {
|
|
1152
|
-
for (let e of p) e.tabIndex = -1;
|
|
1153
|
-
e.tabIndex = 0, e.focus();
|
|
1154
|
-
}
|
|
1155
|
-
}
|
|
1156
|
-
function y(e, t) {
|
|
1157
|
-
if (t === "ArrowLeft") return p[p.indexOf(e) - 1];
|
|
1158
|
-
if (t === "ArrowRight") return p[p.indexOf(e) + 1];
|
|
1159
|
-
let n = m.findIndex((t) => t.includes(e)), r = m[n].indexOf(e), i = m[t === "ArrowUp" ? n - 1 : n + 1];
|
|
1160
|
-
return i?.[Math.min(r, i.length - 1)];
|
|
1161
|
-
}
|
|
1162
|
-
let b = () => _(), x = (e) => {
|
|
1163
|
-
e.key === "ArrowDown" && p[0] && (e.preventDefault(), v(p[0]));
|
|
1164
|
-
}, S = (e) => {
|
|
1165
|
-
let t = [...c].find(([, t]) => t === e.target)?.[0];
|
|
1166
|
-
t && (h(t), _());
|
|
1167
|
-
}, C = (e) => {
|
|
1168
|
-
if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;
|
|
1169
|
-
e.preventDefault();
|
|
1170
|
-
let t = f === "symbols" ? "emoji" : "symbols";
|
|
1171
|
-
h(t), _(), c.get(t).focus();
|
|
1172
|
-
}, w = (t) => {
|
|
1173
|
-
let n = t.target.closest(".stilo-char-picker__char");
|
|
1174
|
-
n?.dataset.character && (e.commands.insertText(n.dataset.character), v(n));
|
|
1175
|
-
}, T = (e) => {
|
|
1176
|
-
let t = e.target.closest(".stilo-char-picker__char");
|
|
1177
|
-
t && [
|
|
1178
|
-
"ArrowLeft",
|
|
1179
|
-
"ArrowRight",
|
|
1180
|
-
"ArrowUp",
|
|
1181
|
-
"ArrowDown"
|
|
1182
|
-
].includes(e.key) && (e.preventDefault(), v(y(t, e.key)));
|
|
1183
|
-
};
|
|
1184
|
-
o.addEventListener("input", b), o.addEventListener("keydown", x), s.addEventListener("click", S), s.addEventListener("keydown", C), l.addEventListener("click", w), l.addEventListener("keydown", T), h(f);
|
|
1185
|
-
async function E() {
|
|
1186
|
-
u.isOpen || (u.open(), n.setAttribute("aria-expanded", "true"), d ??= await Re(), u.isOpen && (o.value = "", _(), o.focus({ preventScroll: !0 })));
|
|
1187
|
-
}
|
|
1188
|
-
function D() {
|
|
1189
|
-
u.isOpen && (u.close(), e.focus());
|
|
1190
|
-
}
|
|
1191
|
-
function O() {
|
|
1192
|
-
o.removeEventListener("input", b), o.removeEventListener("keydown", x), s.removeEventListener("click", S), s.removeEventListener("keydown", C), l.removeEventListener("click", w), l.removeEventListener("keydown", T), u.destroy(), n.removeAttribute("aria-haspopup"), n.removeAttribute("aria-expanded");
|
|
1193
|
-
}
|
|
1194
|
-
return {
|
|
1195
|
-
get isOpen() {
|
|
1196
|
-
return u.isOpen;
|
|
1197
|
-
},
|
|
1198
|
-
open: E,
|
|
1199
|
-
close: D,
|
|
1200
|
-
toggle: () => u.isOpen ? D() : void E(),
|
|
1201
|
-
destroy: O
|
|
1202
|
-
};
|
|
1203
|
-
}
|
|
1204
|
-
//#endregion
|
|
1205
|
-
//#region src/ui/components/icon.ts
|
|
1206
|
-
function K(e) {
|
|
1207
|
-
return oe(e, {
|
|
1208
|
-
class: "stilo-icon",
|
|
1209
|
-
"aria-hidden": "true"
|
|
1210
|
-
});
|
|
1211
|
-
}
|
|
1212
|
-
//#endregion
|
|
1213
|
-
//#region src/ui/components/color-button.ts
|
|
1214
|
-
var Be = 8, Ve = "Mark", He = /^#[0-9a-f]{6}$/;
|
|
1215
|
-
function q(e, t) {
|
|
1216
|
-
let n = document.createElement(e);
|
|
1217
|
-
return n.className = t, n;
|
|
1218
|
-
}
|
|
1219
|
-
function J(e, t) {
|
|
1220
|
-
let n = q("button", e);
|
|
1221
|
-
return n.type = "button", n.setAttribute("aria-label", t), n.title = t, n;
|
|
1222
|
-
}
|
|
1223
|
-
function Ue(e, t, n) {
|
|
1224
|
-
let { container: r, messages: i } = n, a = i[t.labelKey] ?? t.labelKey, o = t.defaultColor, s = q("span", "stilo-split"), c = J("stilo-toolbar__button stilo-split__main", a), u = q("span", "stilo-split__color");
|
|
1225
|
-
c.append(K(t.icon), u);
|
|
1226
|
-
let d = J("stilo-toolbar__button stilo-split__arrow", `${a}: ${i["color.more"]}`);
|
|
1227
|
-
d.append(K(l));
|
|
1228
|
-
for (let e of [c, d]) e.dataset.item = t.id, e.tabIndex = -1;
|
|
1229
|
-
c.setAttribute("aria-pressed", "false"), d.setAttribute("aria-haspopup", "dialog"), d.setAttribute("aria-expanded", "false"), s.append(c, d);
|
|
1230
|
-
let f = q("div", "stilo-color-picker");
|
|
1231
|
-
f.setAttribute("role", "dialog"), f.setAttribute("aria-label", a);
|
|
1232
|
-
let p = q("div", "stilo-color-picker__actions"), m = q("button", "stilo-color-picker__none");
|
|
1233
|
-
m.type = "button", m.textContent = i["color.none"], p.append(m);
|
|
1234
|
-
let h = null;
|
|
1235
|
-
if (t.defaultChoice) {
|
|
1236
|
-
let e = q("span", "stilo-color-picker__separator");
|
|
1237
|
-
e.setAttribute("aria-hidden", "true"), h = q("button", "stilo-color-picker__default"), h.type = "button";
|
|
1238
|
-
let t = document.createElement("mark");
|
|
1239
|
-
t.textContent = i["color.default"], h.append(t), p.append(e, h);
|
|
1240
|
-
}
|
|
1241
|
-
let g = q("div", "stilo-color-picker__grid");
|
|
1242
|
-
g.setAttribute("role", "group"), g.setAttribute("aria-label", a);
|
|
1243
|
-
let _ = t.palette.map(({ color: e, labelKey: t }) => {
|
|
1244
|
-
let n = J("stilo-color-picker__swatch", i[t] ?? t);
|
|
1245
|
-
return n.tabIndex = -1, n.dataset.color = e, n.style.backgroundColor = e, n;
|
|
1246
|
-
});
|
|
1247
|
-
g.append(..._);
|
|
1248
|
-
let v = q("form", "stilo-color-picker__custom"), y = q("input", "stilo-color-picker__native");
|
|
1249
|
-
y.type = "color", y.setAttribute("aria-label", i["color.pick"]);
|
|
1250
|
-
let b = q("input", "stilo-color-picker__value");
|
|
1251
|
-
b.type = "text", b.placeholder = "#000000", b.autocomplete = "off", b.spellcheck = !1, b.setAttribute("aria-label", i["color.custom"]);
|
|
1252
|
-
let x = q("button", "stilo-color-picker__apply");
|
|
1253
|
-
x.type = "submit", x.textContent = i["color.apply"], v.append(y, b, x), f.append(p, g, v);
|
|
1254
|
-
let S = U({
|
|
1255
|
-
anchor: s,
|
|
1256
|
-
content: f,
|
|
1257
|
-
container: r,
|
|
1258
|
-
onClose: (t) => {
|
|
1259
|
-
d.setAttribute("aria-expanded", "false"), t === "escape" && e.focus();
|
|
1260
|
-
}
|
|
1261
|
-
});
|
|
1262
|
-
function C() {
|
|
1263
|
-
u.style.backgroundColor = o ?? Ve;
|
|
1264
|
-
}
|
|
1265
|
-
function w() {
|
|
1266
|
-
return t.isEnabled?.(e) ?? !0;
|
|
1267
|
-
}
|
|
1268
|
-
function T() {
|
|
1269
|
-
let n = w();
|
|
1270
|
-
for (let e of [c, d]) n ? e.removeAttribute("aria-disabled") : e.setAttribute("aria-disabled", "true");
|
|
1271
|
-
let r = n && t.hasColor(e, o);
|
|
1272
|
-
c.setAttribute("aria-pressed", String(r)), c.classList.toggle("stilo-toolbar__button--active", r);
|
|
1273
|
-
}
|
|
1274
|
-
function E(e, t) {
|
|
1275
|
-
if (e) {
|
|
1276
|
-
for (let e of _) e.tabIndex = -1;
|
|
1277
|
-
e.tabIndex = 0, e.focus(t);
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
function D() {
|
|
1281
|
-
let n = t.getColor(e);
|
|
1282
|
-
for (let e of _) e.setAttribute("aria-pressed", String(e.dataset.color === n));
|
|
1283
|
-
h?.setAttribute("aria-pressed", String(t.hasColor(e, null))), b.value = n ?? "", b.removeAttribute("aria-invalid"), y.value = n && He.test(n) ? n : "#000000", S.open(), d.setAttribute("aria-expanded", "true");
|
|
1284
|
-
let r = _.find((e) => e.getAttribute("aria-pressed") === "true");
|
|
1285
|
-
!r && h?.getAttribute("aria-pressed") === "true" ? h.focus({ preventScroll: !0 }) : E(r ?? _[0], { preventScroll: !0 });
|
|
1286
|
-
}
|
|
1287
|
-
function O() {
|
|
1288
|
-
S.close(), e.focus();
|
|
1289
|
-
}
|
|
1290
|
-
function k(n) {
|
|
1291
|
-
return t.setColor(e, n) ? (o = t.getColor(e), C(), !0) : !1;
|
|
1292
|
-
}
|
|
1293
|
-
let A = () => {
|
|
1294
|
-
w() && (S.close(), e.focus(), t.hasColor(e, o) ? t.unsetColor(e) : k(o));
|
|
1295
|
-
}, j = () => {
|
|
1296
|
-
S.isOpen ? O() : w() && D();
|
|
1297
|
-
}, M = () => {
|
|
1298
|
-
t.unsetColor(e), o = t.defaultColor, C(), O();
|
|
1299
|
-
}, N = () => {
|
|
1300
|
-
k(null), O();
|
|
1301
|
-
}, P = (e) => {
|
|
1302
|
-
let t = e.target.closest(".stilo-color-picker__swatch");
|
|
1303
|
-
t?.dataset.color && (k(t.dataset.color), O());
|
|
1304
|
-
}, F = (e) => {
|
|
1305
|
-
let t = {
|
|
1306
|
-
ArrowLeft: -1,
|
|
1307
|
-
ArrowRight: 1,
|
|
1308
|
-
ArrowUp: -8,
|
|
1309
|
-
ArrowDown: Be
|
|
1310
|
-
}[e.key], n = _.indexOf(e.target);
|
|
1311
|
-
t !== void 0 && n !== -1 && (e.preventDefault(), E(_[n + t]));
|
|
1312
|
-
}, I = () => {
|
|
1313
|
-
b.value = y.value, b.removeAttribute("aria-invalid");
|
|
1314
|
-
}, L = () => b.removeAttribute("aria-invalid"), R = (e) => {
|
|
1315
|
-
e.preventDefault(), k(b.value.trim()) ? O() : (b.setAttribute("aria-invalid", "true"), b.focus());
|
|
1316
|
-
};
|
|
1317
|
-
c.addEventListener("click", A), d.addEventListener("click", j), m.addEventListener("click", M), h?.addEventListener("click", N), g.addEventListener("click", P), g.addEventListener("keydown", F), y.addEventListener("input", I), b.addEventListener("input", L), v.addEventListener("submit", R), C();
|
|
1318
|
-
function z() {
|
|
1319
|
-
c.removeEventListener("click", A), d.removeEventListener("click", j), m.removeEventListener("click", M), h?.removeEventListener("click", N), g.removeEventListener("click", P), g.removeEventListener("keydown", F), y.removeEventListener("input", I), b.removeEventListener("input", L), v.removeEventListener("submit", R), S.destroy(), s.remove();
|
|
1320
|
-
}
|
|
1321
|
-
return {
|
|
1322
|
-
element: s,
|
|
1323
|
-
main: c,
|
|
1324
|
-
arrow: d,
|
|
1325
|
-
update: T,
|
|
1326
|
-
destroy: z
|
|
1327
|
-
};
|
|
1328
|
-
}
|
|
1329
|
-
//#endregion
|
|
1330
|
-
//#region src/ui/components/dropdown.ts
|
|
1331
|
-
function We(e) {
|
|
1332
|
-
let { label: t, options: n, icon: r, container: i, onSelect: a } = e, o = document.createElement("button");
|
|
1333
|
-
o.type = "button", o.className = `stilo-toolbar__button stilo-dropdown__trigger${r ? " stilo-dropdown__trigger--icon" : ""}`, o.setAttribute("aria-haspopup", "menu"), o.setAttribute("aria-expanded", "false"), o.setAttribute("title", t), o.setAttribute("tabindex", "-1");
|
|
1334
|
-
let s = document.createElement("span");
|
|
1335
|
-
s.className = "stilo-dropdown__value", o.appendChild(r ? K(r) : s);
|
|
1336
|
-
let c = K(l);
|
|
1337
|
-
o.appendChild(c);
|
|
1338
|
-
let u = document.createElement("div");
|
|
1339
|
-
u.className = "stilo-dropdown__menu stilo-popover", u.setAttribute("role", "menu"), u.setAttribute("aria-label", t), u.setAttribute("hidden", "");
|
|
1340
|
-
let d = [];
|
|
1341
|
-
for (let e of n) {
|
|
1342
|
-
let t = document.createElement("div");
|
|
1343
|
-
t.className = `stilo-dropdown__option stilo-dropdown__option--${e.id}`, t.setAttribute("role", e.action ? "menuitem" : "menuitemradio"), t.setAttribute("tabindex", "-1"), t.setAttribute("data-option", e.id), e.action || t.setAttribute("aria-checked", "false");
|
|
1344
|
-
let n = document.createElement("span");
|
|
1345
|
-
if (n.className = "stilo-dropdown__label", n.textContent = e.label, e.fontFamily && (n.style.fontFamily = e.fontFamily), t.appendChild(n), e.shortcut) {
|
|
1346
|
-
let n = document.createElement("span");
|
|
1347
|
-
n.className = "stilo-dropdown__shortcut", n.textContent = e.shortcut, t.appendChild(n);
|
|
1348
|
-
}
|
|
1349
|
-
d.push(t), u.appendChild(t);
|
|
1350
|
-
}
|
|
1351
|
-
let f;
|
|
1352
|
-
i.appendChild(u);
|
|
1353
|
-
function p() {
|
|
1354
|
-
if (f) return;
|
|
1355
|
-
f = U({
|
|
1356
|
-
anchor: o,
|
|
1357
|
-
content: u,
|
|
1358
|
-
container: i,
|
|
1359
|
-
onClose(e) {
|
|
1360
|
-
e === "escape" && o.focus(), o.setAttribute("aria-expanded", "false"), f = void 0;
|
|
1361
|
-
}
|
|
1362
|
-
}), o.setAttribute("aria-expanded", "true"), f.open();
|
|
1363
|
-
let e = d.findIndex((e) => e.getAttribute("aria-checked") === "true");
|
|
1364
|
-
if (e >= 0) d[e].focus();
|
|
1365
|
-
else {
|
|
1366
|
-
let e = d.findIndex((e) => e.getAttribute("aria-disabled") !== "true");
|
|
1367
|
-
e >= 0 && d[e].focus();
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
function m() {
|
|
1371
|
-
f && (f.close(), o.setAttribute("aria-expanded", "false"));
|
|
1372
|
-
}
|
|
1373
|
-
function h() {
|
|
1374
|
-
o.getAttribute("aria-disabled") !== "true" && (f ? m() : p());
|
|
1375
|
-
}
|
|
1376
|
-
o.addEventListener("click", h);
|
|
1377
|
-
function g(e) {
|
|
1378
|
-
if (o.getAttribute("aria-disabled") !== "true") switch (e.key) {
|
|
1379
|
-
case "ArrowDown": {
|
|
1380
|
-
e.preventDefault(), p();
|
|
1381
|
-
let t = d.findIndex((e) => e.getAttribute("aria-disabled") !== "true");
|
|
1382
|
-
t >= 0 && d[t].focus();
|
|
1383
|
-
break;
|
|
1384
|
-
}
|
|
1385
|
-
case "ArrowUp":
|
|
1386
|
-
e.preventDefault(), p();
|
|
1387
|
-
for (let e = d.length - 1; e >= 0; e--) if (d[e].getAttribute("aria-disabled") !== "true") {
|
|
1388
|
-
d[e].focus();
|
|
1389
|
-
break;
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
o.addEventListener("keydown", g);
|
|
1394
|
-
function _(e) {
|
|
1395
|
-
let t = document.activeElement;
|
|
1396
|
-
if (!t || !u.contains(t)) return;
|
|
1397
|
-
let n = d.filter((e) => e.getAttribute("aria-disabled") !== "true"), r = n.indexOf(t);
|
|
1398
|
-
switch (e.key) {
|
|
1399
|
-
case "ArrowDown":
|
|
1400
|
-
e.preventDefault(), n[(r + 1) % n.length].focus();
|
|
1401
|
-
break;
|
|
1402
|
-
case "ArrowUp":
|
|
1403
|
-
e.preventDefault(), n[(r - 1 + n.length) % n.length].focus();
|
|
1404
|
-
break;
|
|
1405
|
-
case "Home":
|
|
1406
|
-
e.preventDefault(), n[0].focus();
|
|
1407
|
-
break;
|
|
1408
|
-
case "End":
|
|
1409
|
-
e.preventDefault(), n[n.length - 1].focus();
|
|
1410
|
-
break;
|
|
1411
|
-
case "Enter":
|
|
1412
|
-
if (e.preventDefault(), t === document.activeElement && t !== o) {
|
|
1413
|
-
let e = t.getAttribute("data-option");
|
|
1414
|
-
e && t.getAttribute("aria-disabled") !== "true" && (a(e), m());
|
|
1415
|
-
}
|
|
1416
|
-
break;
|
|
1417
|
-
case " ":
|
|
1418
|
-
if (e.preventDefault(), t === document.activeElement && t !== o) {
|
|
1419
|
-
let e = t.getAttribute("data-option");
|
|
1420
|
-
e && t.getAttribute("aria-disabled") !== "true" && a(e);
|
|
1421
|
-
}
|
|
1422
|
-
break;
|
|
1423
|
-
case "Escape":
|
|
1424
|
-
e.preventDefault(), m(), o.focus();
|
|
1425
|
-
break;
|
|
1426
|
-
case "Tab": m();
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
u.addEventListener("keydown", _);
|
|
1430
|
-
for (let e of d) e.addEventListener("click", () => {
|
|
1431
|
-
let t = e.getAttribute("data-option");
|
|
1432
|
-
t && e.getAttribute("aria-disabled") !== "true" && (a(t), m());
|
|
1433
|
-
});
|
|
1434
|
-
let v = !1;
|
|
1435
|
-
function y(e) {
|
|
1436
|
-
let { activeId: r, disabledIds: i, valueLabel: a } = e, c = n.find((e) => e.id === r)?.label ?? a ?? t;
|
|
1437
|
-
s.textContent = c;
|
|
1438
|
-
let l = n.every((e) => e.action);
|
|
1439
|
-
o.setAttribute("aria-label", l ? t : `${t}: ${c}`), i.size === n.length ? o.setAttribute("aria-disabled", "true") : o.removeAttribute("aria-disabled");
|
|
1440
|
-
for (let e of d) {
|
|
1441
|
-
let t = e.getAttribute("data-option");
|
|
1442
|
-
i.has(t) ? e.setAttribute("aria-disabled", "true") : e.removeAttribute("aria-disabled"), e.getAttribute("role") === "menuitemradio" && e.setAttribute("aria-checked", t === r ? "true" : "false");
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
function b() {
|
|
1446
|
-
v || (v = !0, f?.destroy(), f = void 0, o.removeEventListener("click", h), o.removeEventListener("keydown", g), u.removeEventListener("keydown", _));
|
|
1447
|
-
}
|
|
1448
|
-
return {
|
|
1449
|
-
get trigger() {
|
|
1450
|
-
return o;
|
|
1451
|
-
},
|
|
1452
|
-
update: y,
|
|
1453
|
-
destroy: b
|
|
1454
|
-
};
|
|
1455
|
-
}
|
|
1456
|
-
//#endregion
|
|
1457
|
-
//#region src/ui/components/find-bar.ts
|
|
1458
|
-
var Ge = 350, Ke = 2;
|
|
1459
|
-
function qe(e, n) {
|
|
1460
|
-
let { container: r, messages: i, button: a } = n, o = fe(), s = document.createElement("div");
|
|
1461
|
-
s.className = "stilo-find-bar", s.setAttribute("role", "search"), s.setAttribute("aria-label", i["toolbar.find"]), s.hidden = !0, a?.setAttribute("aria-expanded", "false");
|
|
1462
|
-
function d(e, t) {
|
|
1463
|
-
let n = document.createElement("input");
|
|
1464
|
-
return n.type = "text", n.className = `stilo-find-bar__input stilo-find-bar__input--${t}`, n.placeholder = i[e], n.autocomplete = "off", n.spellcheck = !1, n.setAttribute("aria-label", i[e]), n;
|
|
1465
|
-
}
|
|
1466
|
-
function f(e, t, n) {
|
|
1467
|
-
let r = document.createElement("button");
|
|
1468
|
-
return r.type = "button", r.className = "stilo-find-bar__button", t ? (r.append(K(t)), r.setAttribute("aria-label", i[e]), r.title = n ?? i[e]) : (r.classList.add("stilo-find-bar__button--text"), r.textContent = i[e]), r;
|
|
1469
|
-
}
|
|
1470
|
-
function p(e, t) {
|
|
1471
|
-
let n = f(e, t);
|
|
1472
|
-
return n.classList.add("stilo-find-bar__toggle"), n.setAttribute("aria-pressed", "false"), n;
|
|
1473
|
-
}
|
|
1474
|
-
let m = d("find.find", "find"), h = document.createElement("span");
|
|
1475
|
-
h.className = "stilo-find-bar__count", h.setAttribute("aria-live", "polite");
|
|
1476
|
-
let g = f("find.previous", u, `${i["find.previous"]} (Shift+Enter)`), _ = f("find.next", l, `${i["find.next"]} (Enter)`), v = p("find.matchCase", c), y = p("find.wholeWord", ie), b = f("find.close", ae, `${i["find.close"]} (Esc)`), x = d("find.replace", "replace"), S = f("find.replaceOne", null), C = f("find.replaceAll", null), w = document.createElement("div");
|
|
1477
|
-
w.className = "stilo-find-bar__row", w.append(m, h, g, _, v, y, b);
|
|
1478
|
-
let T = document.createElement("div");
|
|
1479
|
-
T.className = "stilo-find-bar__row", T.append(x, S, C), s.append(w, T), r.append(s), r.classList.add("stilo-find-bar-host");
|
|
1480
|
-
let E = 0, D = "";
|
|
1481
|
-
function O(e) {
|
|
1482
|
-
return e.getAttribute("aria-pressed") === "true";
|
|
1483
|
-
}
|
|
1484
|
-
function k() {
|
|
1485
|
-
clearTimeout(E), E = 0, D = m.value.length >= Ke ? m.value : "", D ? e.commands.setSearch({
|
|
1486
|
-
text: D,
|
|
1487
|
-
caseSensitive: O(v),
|
|
1488
|
-
wholeWord: O(y)
|
|
1489
|
-
}) : e.commands.clearSearch(), j();
|
|
1490
|
-
}
|
|
1491
|
-
function A() {
|
|
1492
|
-
E && k();
|
|
1493
|
-
}
|
|
1494
|
-
function j() {
|
|
1495
|
-
if (!D) {
|
|
1496
|
-
h.textContent = "";
|
|
1497
|
-
return;
|
|
1498
|
-
}
|
|
1499
|
-
let n = t(e), r = n.count.toLocaleString();
|
|
1500
|
-
h.textContent = n.count === 0 ? i["find.noResults"] : n.current > 0 ? i["find.position"].replace("{current}", n.current.toLocaleString()).replace("{total}", r) : i["find.results"].replace("{total}", r);
|
|
1501
|
-
}
|
|
1502
|
-
function M() {
|
|
1503
|
-
let { $from: t, $to: n, empty: r } = e.state.selection;
|
|
1504
|
-
return r || !t.sameParent(n) || !t.parent.isTextblock ? "" : e.state.doc.textBetween(t.pos, n.pos);
|
|
1505
|
-
}
|
|
1506
|
-
function N() {
|
|
1507
|
-
let t = M();
|
|
1508
|
-
s.hidden = !1, a?.setAttribute("aria-expanded", "true"), T.hidden = !e.isEditable, t && (m.value = t), m.focus({ preventScroll: !0 }), m.select(), k();
|
|
1509
|
-
}
|
|
1510
|
-
function P() {
|
|
1511
|
-
s.hidden || (clearTimeout(E), E = 0, s.hidden = !0, a?.setAttribute("aria-expanded", "false"), D = "", e.commands.clearSearch(), e.focus());
|
|
1512
|
-
}
|
|
1513
|
-
let F = () => {
|
|
1514
|
-
clearTimeout(E), E = window.setTimeout(k, Ge);
|
|
1515
|
-
}, I = (t) => {
|
|
1516
|
-
let n = o ? t.metaKey : t.ctrlKey;
|
|
1517
|
-
t.key === "Escape" ? (t.preventDefault(), P()) : n && !t.altKey && !t.shiftKey && t.key.toLowerCase() === "f" ? (t.preventDefault(), m.focus(), m.select()) : t.key === "Enter" && t.target === m ? (t.preventDefault(), A(), t.shiftKey ? e.commands.findPrevious() : e.commands.findNext()) : t.key === "Enter" && t.target === x && (t.preventDefault(), A(), e.commands.replaceNext(x.value));
|
|
1518
|
-
}, L = (t) => {
|
|
1519
|
-
let n = t.target.closest("button");
|
|
1520
|
-
n === v || n === y ? (n.setAttribute("aria-pressed", String(!O(n))), k()) : (A(), n === g ? e.commands.findPrevious() : n === _ ? e.commands.findNext() : n === S ? e.commands.replaceNext(x.value) : n === C ? e.commands.replaceAll(x.value) : n === b && P());
|
|
1521
|
-
}, R = () => {
|
|
1522
|
-
s.hidden || j();
|
|
1523
|
-
};
|
|
1524
|
-
return m.addEventListener("input", F), s.addEventListener("keydown", I), s.addEventListener("click", L), e.on("transaction", R), {
|
|
1525
|
-
element: s,
|
|
1526
|
-
get isOpen() {
|
|
1527
|
-
return !s.hidden;
|
|
1528
|
-
},
|
|
1529
|
-
open: N,
|
|
1530
|
-
close: P,
|
|
1531
|
-
toggle: () => s.hidden ? N() : P(),
|
|
1532
|
-
destroy() {
|
|
1533
|
-
clearTimeout(E), m.removeEventListener("input", F), s.removeEventListener("keydown", I), s.removeEventListener("click", L), e.off("transaction", R), s.remove(), r.classList.remove("stilo-find-bar-host"), a?.removeAttribute("aria-expanded");
|
|
1534
|
-
}
|
|
1535
|
-
};
|
|
1536
|
-
}
|
|
1537
|
-
//#endregion
|
|
1538
|
-
//#region src/ui/components/font-size-input.ts
|
|
1539
|
-
var Je = /^(\d+(?:[.,]\d+)?)\s*(px|pt|em|rem|%)?$/i, Ye = 1, Xe = 400;
|
|
1540
|
-
function Ze(e) {
|
|
1541
|
-
let { from: t, to: n, empty: r } = e.state.selection;
|
|
1542
|
-
if (r) return !1;
|
|
1543
|
-
let i = /* @__PURE__ */ new Set();
|
|
1544
|
-
return e.state.doc.nodesBetween(t, n, (e) => (e.isText && i.add(e.marks.find((e) => e.type.name === "textStyle")?.attrs.fontSize ?? null), i.size < 2)), i.size > 1;
|
|
1545
|
-
}
|
|
1546
|
-
function Qe(e, t) {
|
|
1547
|
-
let n = document.createElement("button");
|
|
1548
|
-
return n.type = "button", n.className = `stilo-toolbar__button ${e}`, n.setAttribute("aria-label", t), n.title = t, n;
|
|
1549
|
-
}
|
|
1550
|
-
function $e(e, t, r) {
|
|
1551
|
-
let { container: a, messages: o } = r, { unit: s, sizes: c } = t, l = o[t.labelKey] ?? t.labelKey, u = document.createElement("span");
|
|
1552
|
-
u.className = "stilo-font-size";
|
|
1553
|
-
let d = Qe("stilo-font-size__decrease", o["fontSize.decrease"]);
|
|
1554
|
-
d.append(K(w));
|
|
1555
|
-
let f = Qe("stilo-font-size__increase", o["fontSize.increase"]);
|
|
1556
|
-
f.append(K(E));
|
|
1557
|
-
let p = document.createElement("input");
|
|
1558
|
-
p.type = "text", p.className = "stilo-font-size__input", p.inputMode = "decimal", p.autocomplete = "off", p.spellcheck = !1, p.setAttribute("role", "combobox"), p.setAttribute("aria-label", l), p.setAttribute("aria-autocomplete", "none"), p.setAttribute("aria-expanded", "false"), p.title = l;
|
|
1559
|
-
let m = [
|
|
1560
|
-
d,
|
|
1561
|
-
p,
|
|
1562
|
-
f
|
|
1563
|
-
];
|
|
1564
|
-
for (let e of m) e.dataset.item = t.id, e.tabIndex = -1;
|
|
1565
|
-
u.append(...m);
|
|
1566
|
-
let h = document.createElement("div");
|
|
1567
|
-
h.className = "stilo-font-size__list", h.id = `stilo-font-size-${Math.random().toString(36).slice(2)}`, h.setAttribute("role", "listbox"), h.setAttribute("aria-label", l), p.setAttribute("aria-controls", h.id);
|
|
1568
|
-
let g = c.map((e, t) => {
|
|
1569
|
-
let n = document.createElement("div");
|
|
1570
|
-
return n.className = "stilo-font-size__option", n.id = `${h.id}-${t}`, n.setAttribute("role", "option"), n.setAttribute("aria-selected", "false"), n.dataset.size = String(e), n.textContent = String(e), n;
|
|
1571
|
-
});
|
|
1572
|
-
h.append(...g);
|
|
1573
|
-
let _ = U({
|
|
1574
|
-
anchor: p,
|
|
1575
|
-
content: h,
|
|
1576
|
-
container: a,
|
|
1577
|
-
onClose: () => {
|
|
1578
|
-
p.setAttribute("aria-expanded", "false"), x(-1);
|
|
1579
|
-
}
|
|
1580
|
-
}), v = "", y = -1;
|
|
1581
|
-
function b() {
|
|
1582
|
-
return e.commands.setFontSize.can("12pt");
|
|
1583
|
-
}
|
|
1584
|
-
function x(e) {
|
|
1585
|
-
y = e, g.forEach((t, n) => {
|
|
1586
|
-
t.classList.toggle("stilo-font-size__option--active", n === e);
|
|
1587
|
-
}), e >= 0 ? p.setAttribute("aria-activedescendant", g[e].id) : p.removeAttribute("aria-activedescendant");
|
|
1588
|
-
}
|
|
1589
|
-
function S() {
|
|
1590
|
-
let t = b();
|
|
1591
|
-
for (let e of m) t ? e.removeAttribute("aria-disabled") : e.setAttribute("aria-disabled", "true");
|
|
1592
|
-
p.readOnly = !t, v = t && !Ze(e) ? String(i(e, s)) : "", document.activeElement !== p && (p.value = v);
|
|
1593
|
-
}
|
|
1594
|
-
function C() {
|
|
1595
|
-
if (!_.isOpen && b()) {
|
|
1596
|
-
for (let e of g) e.setAttribute("aria-selected", String(e.dataset.size === v));
|
|
1597
|
-
_.open(), p.setAttribute("aria-expanded", "true");
|
|
1598
|
-
}
|
|
1599
|
-
}
|
|
1600
|
-
function T() {
|
|
1601
|
-
_.close(), p.removeAttribute("aria-invalid"), e.focus(), S();
|
|
1602
|
-
}
|
|
1603
|
-
function D(t) {
|
|
1604
|
-
let r = Je.exec(t.trim());
|
|
1605
|
-
if (!r) return null;
|
|
1606
|
-
let i = Number(r[1].replace(",", ".")), a = r[2]?.toLowerCase();
|
|
1607
|
-
return i === 0 || (!a || a === "px" || a === "pt") && (i < Ye || i > Xe) ? null : a ? `${i}${a}` : n(e, i, s);
|
|
1608
|
-
}
|
|
1609
|
-
function O(t) {
|
|
1610
|
-
let n = D(t);
|
|
1611
|
-
n && e.commands.setFontSize(n) ? T() : p.setAttribute("aria-invalid", "true");
|
|
1612
|
-
}
|
|
1613
|
-
let k = (t) => () => {
|
|
1614
|
-
b() && (_.close(), e.focus(), e.commands.stepFontSize(t, s));
|
|
1615
|
-
}, A = k(-1), j = k(1), M = () => p.select(), N = () => C(), P = () => {
|
|
1616
|
-
p.removeAttribute("aria-invalid"), x(-1);
|
|
1617
|
-
}, F = (e) => {
|
|
1618
|
-
switch (e.key) {
|
|
1619
|
-
case "ArrowDown":
|
|
1620
|
-
case "ArrowUp": {
|
|
1621
|
-
e.preventDefault(), C();
|
|
1622
|
-
let t = e.key === "ArrowDown" ? 1 : -1, n = y === -1 ? g.findIndex((e) => e.dataset.size === v) : y, r = n === -1 ? t > 0 ? 0 : g.length - 1 : n + t;
|
|
1623
|
-
x(Math.min(g.length - 1, Math.max(0, r))), g[y]?.scrollIntoView?.({ block: "nearest" });
|
|
1624
|
-
break;
|
|
1625
|
-
}
|
|
1626
|
-
case "Enter":
|
|
1627
|
-
e.preventDefault(), O(y >= 0 ? g[y].dataset.size : p.value);
|
|
1628
|
-
break;
|
|
1629
|
-
case "Escape": e.preventDefault(), T();
|
|
1630
|
-
}
|
|
1631
|
-
}, I = () => {
|
|
1632
|
-
_.close(), p.removeAttribute("aria-invalid"), p.value = v;
|
|
1633
|
-
}, L = (e) => e.preventDefault(), R = (e) => {
|
|
1634
|
-
let t = e.target.closest(".stilo-font-size__option");
|
|
1635
|
-
t?.dataset.size && O(t.dataset.size);
|
|
1636
|
-
};
|
|
1637
|
-
d.addEventListener("click", A), f.addEventListener("click", j), p.addEventListener("focus", M), p.addEventListener("click", N), p.addEventListener("input", P), p.addEventListener("keydown", F), p.addEventListener("blur", I), h.addEventListener("pointerdown", L), h.addEventListener("click", R);
|
|
1638
|
-
let z = !1;
|
|
1639
|
-
function ee() {
|
|
1640
|
-
z || (z = !0, d.removeEventListener("click", A), f.removeEventListener("click", j), p.removeEventListener("focus", M), p.removeEventListener("click", N), p.removeEventListener("input", P), p.removeEventListener("keydown", F), p.removeEventListener("blur", I), h.removeEventListener("pointerdown", L), h.removeEventListener("click", R), _.destroy());
|
|
1641
|
-
}
|
|
1642
|
-
return S(), {
|
|
1643
|
-
element: u,
|
|
1644
|
-
parts: m,
|
|
1645
|
-
update: S,
|
|
1646
|
-
destroy: ee
|
|
1647
|
-
};
|
|
1648
|
-
}
|
|
1649
|
-
//#endregion
|
|
1650
|
-
//#region src/ui/components/icon-menu.ts
|
|
1651
|
-
function et(e, t, n) {
|
|
1652
|
-
let { container: r, messages: i, mac: a } = n, o = i[t.labelKey] ?? t.labelKey, s = (e, t) => {
|
|
1653
|
-
let n = i[e] ?? e;
|
|
1654
|
-
return t ? `${n} (${V(t, a)})` : n;
|
|
1655
|
-
}, c = document.createElement("button");
|
|
1656
|
-
c.type = "button", c.className = "stilo-toolbar__button stilo-icon-menu__trigger", c.dataset.item = t.id, c.tabIndex = -1, c.title = o, c.setAttribute("aria-haspopup", "menu"), c.setAttribute("aria-expanded", "false");
|
|
1657
|
-
let u = t.options.map((e) => K(e.icon)), d = u[0];
|
|
1658
|
-
c.append(d, K(l));
|
|
1659
|
-
let f = document.createElement("div");
|
|
1660
|
-
f.className = "stilo-icon-menu", f.setAttribute("role", "menu"), f.setAttribute("aria-label", o), f.setAttribute("aria-orientation", "horizontal");
|
|
1661
|
-
let p = t.options.map((e) => {
|
|
1662
|
-
let t = document.createElement("button");
|
|
1663
|
-
t.type = "button", t.className = `stilo-toolbar__button stilo-icon-menu__option stilo-icon-menu__option--${e.id}`, t.dataset.option = e.id, t.tabIndex = -1, t.setAttribute("role", "menuitemradio"), t.setAttribute("aria-checked", "false");
|
|
1664
|
-
let n = s(e.labelKey, e.shortcut);
|
|
1665
|
-
return t.setAttribute("aria-label", i[e.labelKey] ?? e.labelKey), t.title = n, t.append(K(e.icon)), t;
|
|
1666
|
-
});
|
|
1667
|
-
f.append(...p);
|
|
1668
|
-
let m = U({
|
|
1669
|
-
anchor: c,
|
|
1670
|
-
content: f,
|
|
1671
|
-
container: r,
|
|
1672
|
-
onClose: (e) => {
|
|
1673
|
-
c.setAttribute("aria-expanded", "false"), e === "escape" && c.focus();
|
|
1674
|
-
}
|
|
1675
|
-
}), h = (n) => t.options[n].isEnabled?.(e) ?? !0;
|
|
1676
|
-
function g() {
|
|
1677
|
-
let n = t.options.findIndex((t) => t.isActive(e)), r = Math.max(n, 0);
|
|
1678
|
-
d.replaceWith(u[r]), d = u[r];
|
|
1679
|
-
let a = i[t.options[r].labelKey] ?? t.options[r].labelKey;
|
|
1680
|
-
c.setAttribute("aria-label", `${o}: ${a}`), p.forEach((e, t) => {
|
|
1681
|
-
e.setAttribute("aria-checked", String(t === n)), e.classList.toggle("stilo-toolbar__button--active", t === n), h(t) ? e.removeAttribute("aria-disabled") : e.setAttribute("aria-disabled", "true");
|
|
1682
|
-
}), t.options.some((e, t) => h(t)) ? c.removeAttribute("aria-disabled") : c.setAttribute("aria-disabled", "true");
|
|
1683
|
-
}
|
|
1684
|
-
function _(e) {
|
|
1685
|
-
p[e]?.focus({ preventScroll: !0 });
|
|
1686
|
-
}
|
|
1687
|
-
function v() {
|
|
1688
|
-
if (m.isOpen || c.getAttribute("aria-disabled") === "true") return;
|
|
1689
|
-
m.open(), c.setAttribute("aria-expanded", "true");
|
|
1690
|
-
let e = p.findIndex((e) => e.getAttribute("aria-checked") === "true");
|
|
1691
|
-
_(Math.max(e, 0));
|
|
1692
|
-
}
|
|
1693
|
-
function y(n) {
|
|
1694
|
-
h(n) && (m.close(), e.focus(), t.options[n].run(e));
|
|
1695
|
-
}
|
|
1696
|
-
let b = () => {
|
|
1697
|
-
m.isOpen ? m.close() : v();
|
|
1698
|
-
}, x = (e) => {
|
|
1699
|
-
e.key === "ArrowDown" && (e.preventDefault(), v());
|
|
1700
|
-
}, S = (e) => {
|
|
1701
|
-
let t = e.target.closest(".stilo-icon-menu__option");
|
|
1702
|
-
t && y(p.indexOf(t));
|
|
1703
|
-
}, C = (e) => {
|
|
1704
|
-
let t = p.indexOf(e.target);
|
|
1705
|
-
if (t === -1) return;
|
|
1706
|
-
let n = p.length - 1, r = {
|
|
1707
|
-
ArrowRight: t === n ? 0 : t + 1,
|
|
1708
|
-
ArrowLeft: t === 0 ? n : t - 1,
|
|
1709
|
-
Home: 0,
|
|
1710
|
-
End: n
|
|
1711
|
-
}[e.key];
|
|
1712
|
-
r === void 0 ? e.key === "Tab" && m.close() : (e.preventDefault(), _(r));
|
|
1713
|
-
};
|
|
1714
|
-
c.addEventListener("click", b), c.addEventListener("keydown", x), f.addEventListener("click", S), f.addEventListener("keydown", C);
|
|
1715
|
-
let w = !1;
|
|
1716
|
-
function T() {
|
|
1717
|
-
w || (w = !0, c.removeEventListener("click", b), c.removeEventListener("keydown", x), f.removeEventListener("click", S), f.removeEventListener("keydown", C), m.destroy());
|
|
1718
|
-
}
|
|
1719
|
-
return g(), {
|
|
1720
|
-
trigger: c,
|
|
1721
|
-
update: g,
|
|
1722
|
-
destroy: T
|
|
1723
|
-
};
|
|
1724
|
-
}
|
|
1725
|
-
//#endregion
|
|
1726
|
-
//#region src/ui/components/link-bubble.ts
|
|
1727
|
-
function tt(e, t) {
|
|
1728
|
-
let { container: n, messages: r, onEdit: i } = t, a = null, o = {
|
|
1729
|
-
contextElement: e.view.dom,
|
|
1730
|
-
getBoundingClientRect: () => (a ?? e.view.dom).getBoundingClientRect()
|
|
1731
|
-
}, s = document.createElement("div");
|
|
1732
|
-
s.className = "stilo-link-bubble", s.setAttribute("role", "group"), s.setAttribute("aria-label", r["toolbar.link"]);
|
|
1733
|
-
let c = document.createElement("a");
|
|
1734
|
-
c.className = "stilo-link-bubble__button", c.target = "_blank", c.rel = "noopener noreferrer", c.setAttribute("aria-label", r["link.open"]), c.append(K(f));
|
|
1735
|
-
let l = Y(T, r["link.edit"]), u = Y(re, r["link.remove"]);
|
|
1736
|
-
s.append(c, l, u);
|
|
1737
|
-
let d = U({
|
|
1738
|
-
anchor: o,
|
|
1739
|
-
content: s,
|
|
1740
|
-
container: n
|
|
1741
|
-
}), p = (e) => {
|
|
1742
|
-
e.preventDefault();
|
|
1743
|
-
}, m = () => {
|
|
1744
|
-
d.close(), i();
|
|
1745
|
-
}, h = () => {
|
|
1746
|
-
e.commands.unsetLink();
|
|
1747
|
-
};
|
|
1748
|
-
s.addEventListener("mousedown", p), l.addEventListener("click", m), u.addEventListener("click", h), e.on("transaction", _), e.on("focus", _), e.on("blur", _);
|
|
1749
|
-
function g() {
|
|
1750
|
-
let { selection: t } = e.state;
|
|
1751
|
-
if (!t.empty || !e.isActive("link") || !e.view.hasFocus()) return null;
|
|
1752
|
-
let { node: n } = e.view.domAtPos(t.from);
|
|
1753
|
-
return (n instanceof Element ? n : n.parentElement)?.closest("a") ?? null;
|
|
1754
|
-
}
|
|
1755
|
-
function _() {
|
|
1756
|
-
let t = g();
|
|
1757
|
-
if (t !== a && d.close(), a = t, !a) return;
|
|
1758
|
-
let n = String(e.getAttributes("link").href ?? "");
|
|
1759
|
-
c.href = n, c.title = `${r["link.open"]}: ${n}`, d.open();
|
|
1760
|
-
}
|
|
1761
|
-
function v() {
|
|
1762
|
-
e.off("transaction", _), e.off("focus", _), e.off("blur", _), s.removeEventListener("mousedown", p), l.removeEventListener("click", m), u.removeEventListener("click", h), d.destroy();
|
|
1763
|
-
}
|
|
1764
|
-
return {
|
|
1765
|
-
get isOpen() {
|
|
1766
|
-
return d.isOpen;
|
|
1767
|
-
},
|
|
1768
|
-
update: _,
|
|
1769
|
-
destroy: v
|
|
1770
|
-
};
|
|
1771
|
-
}
|
|
1772
|
-
function Y(e, t) {
|
|
1773
|
-
let n = document.createElement("button");
|
|
1774
|
-
return n.type = "button", n.className = "stilo-link-bubble__button", n.setAttribute("aria-label", t), n.title = t, n.append(K(e)), n;
|
|
1775
|
-
}
|
|
1776
|
-
//#endregion
|
|
1777
|
-
//#region src/ui/components/table-actions.ts
|
|
1778
|
-
var nt = {
|
|
1779
|
-
addRowBefore: "table.addRowBefore",
|
|
1780
|
-
addRowAfter: "table.addRowAfter",
|
|
1781
|
-
deleteRow: "table.deleteRow",
|
|
1782
|
-
addColumnBefore: "table.addColumnBefore",
|
|
1783
|
-
addColumnAfter: "table.addColumnAfter",
|
|
1784
|
-
deleteColumn: "table.deleteColumn",
|
|
1785
|
-
mergeCells: "table.mergeCells",
|
|
1786
|
-
splitCell: "table.splitCell",
|
|
1787
|
-
toggleHeaderRow: "table.headerRow",
|
|
1788
|
-
toggleHeaderColumn: "table.headerColumn",
|
|
1789
|
-
deleteTable: "table.deleteTable"
|
|
1790
|
-
};
|
|
1791
|
-
function rt(e, t) {
|
|
1792
|
-
let { groups: n, label: i, messages: a, close: o } = t, s = document.createElement("div");
|
|
1793
|
-
s.className = "stilo-table-menu__actions", s.setAttribute("role", "menu"), s.setAttribute("aria-label", i);
|
|
1794
|
-
let c = /* @__PURE__ */ new Map();
|
|
1795
|
-
n.forEach((e, t) => {
|
|
1796
|
-
if (t > 0) {
|
|
1797
|
-
let e = document.createElement("div");
|
|
1798
|
-
e.className = "stilo-table-menu__separator", e.setAttribute("role", "separator"), s.append(e);
|
|
1799
|
-
}
|
|
1800
|
-
for (let t of e) {
|
|
1801
|
-
let e = document.createElement("div");
|
|
1802
|
-
e.className = `stilo-dropdown__option stilo-table-menu__item--${t}`, e.tabIndex = -1;
|
|
1803
|
-
let n = t === "toggleHeaderRow" || t === "toggleHeaderColumn";
|
|
1804
|
-
e.setAttribute("role", n ? "menuitemcheckbox" : "menuitem"), e.textContent = a[nt[t]], c.set(e, t), s.append(e);
|
|
1805
|
-
}
|
|
1806
|
-
});
|
|
1807
|
-
let l = () => [...c.keys()].filter((e) => e.getAttribute("aria-disabled") !== "true");
|
|
1808
|
-
function u() {
|
|
1809
|
-
let t = r(e);
|
|
1810
|
-
for (let [n, r] of c) e.commands[r].can() ? n.removeAttribute("aria-disabled") : n.setAttribute("aria-disabled", "true"), r === "toggleHeaderRow" && n.setAttribute("aria-checked", String(!!t?.row)), r === "toggleHeaderColumn" && n.setAttribute("aria-checked", String(!!t?.column));
|
|
1811
|
-
}
|
|
1812
|
-
function d(t) {
|
|
1813
|
-
let n = c.get(t);
|
|
1814
|
-
n && t.getAttribute("aria-disabled") !== "true" && (o(), e.focus(), e.commands[n]());
|
|
1815
|
-
}
|
|
1816
|
-
let f = (e) => {
|
|
1817
|
-
let t = e.target.closest("[role^=\"menuitem\"]");
|
|
1818
|
-
t && d(t);
|
|
1819
|
-
}, p = (e) => {
|
|
1820
|
-
let t = l(), n = t.indexOf(e.target), r;
|
|
1821
|
-
switch (e.key) {
|
|
1822
|
-
case "ArrowDown":
|
|
1823
|
-
r = t[(n + 1) % t.length];
|
|
1824
|
-
break;
|
|
1825
|
-
case "ArrowUp":
|
|
1826
|
-
r = t[(n - 1 + t.length) % t.length];
|
|
1827
|
-
break;
|
|
1828
|
-
case "Home":
|
|
1829
|
-
r = t[0];
|
|
1830
|
-
break;
|
|
1831
|
-
case "End":
|
|
1832
|
-
r = t.at(-1);
|
|
1833
|
-
break;
|
|
1834
|
-
case "Enter":
|
|
1835
|
-
case " ":
|
|
1836
|
-
e.preventDefault(), d(e.target);
|
|
1837
|
-
return;
|
|
1838
|
-
case "Tab":
|
|
1839
|
-
o();
|
|
1840
|
-
return;
|
|
1841
|
-
default: return;
|
|
1842
|
-
}
|
|
1843
|
-
e.preventDefault(), r?.focus();
|
|
1844
|
-
};
|
|
1845
|
-
return s.addEventListener("click", f), s.addEventListener("keydown", p), {
|
|
1846
|
-
element: s,
|
|
1847
|
-
refresh: u,
|
|
1848
|
-
focusFirst: () => l()[0]?.focus({ preventScroll: !0 }),
|
|
1849
|
-
destroy() {
|
|
1850
|
-
s.removeEventListener("click", f), s.removeEventListener("keydown", p);
|
|
1851
|
-
}
|
|
1852
|
-
};
|
|
1853
|
-
}
|
|
1854
|
-
//#endregion
|
|
1855
|
-
//#region src/ui/components/table-handles.ts
|
|
1856
|
-
var X = 4, Z = 32, it = [
|
|
1857
|
-
{
|
|
1858
|
-
kind: "row",
|
|
1859
|
-
labelKey: "table.row",
|
|
1860
|
-
icon: g,
|
|
1861
|
-
placement: "left",
|
|
1862
|
-
groups: [["addRowBefore", "addRowAfter"], ["deleteRow"]]
|
|
1863
|
-
},
|
|
1864
|
-
{
|
|
1865
|
-
kind: "column",
|
|
1866
|
-
labelKey: "table.column",
|
|
1867
|
-
icon: h,
|
|
1868
|
-
placement: "top",
|
|
1869
|
-
groups: [["addColumnBefore", "addColumnAfter"], ["deleteColumn"]]
|
|
1870
|
-
},
|
|
1871
|
-
{
|
|
1872
|
-
kind: "table",
|
|
1873
|
-
labelKey: "toolbar.table",
|
|
1874
|
-
icon: m,
|
|
1875
|
-
placement: "top-end",
|
|
1876
|
-
groups: [["mergeCells", "splitCell"], ["deleteTable"]]
|
|
1877
|
-
}
|
|
1878
|
-
];
|
|
1879
|
-
function Q(e, t, n, r) {
|
|
1880
|
-
return {
|
|
1881
|
-
x: e,
|
|
1882
|
-
y: t,
|
|
1883
|
-
width: n,
|
|
1884
|
-
height: r,
|
|
1885
|
-
left: e,
|
|
1886
|
-
top: t,
|
|
1887
|
-
right: e + n,
|
|
1888
|
-
bottom: t + r
|
|
1889
|
-
};
|
|
1890
|
-
}
|
|
1891
|
-
function at(e, t) {
|
|
1892
|
-
let { container: n, messages: r } = t, { view: i } = e, a = null, o = null, s = (e) => Math.max(e.getBoundingClientRect().left, e.parentElement?.getBoundingClientRect().left ?? -Infinity);
|
|
1893
|
-
function c(e) {
|
|
1894
|
-
let t = a?.closest("table");
|
|
1895
|
-
if (!a || !t) return Q(0, 0, 0, 0);
|
|
1896
|
-
let n = a.getBoundingClientRect(), r = t.getBoundingClientRect().top, i = s(t);
|
|
1897
|
-
return e === "row" ? Q(i, n.top, Math.max(n.right - i, 0), n.height) : e === "column" ? Q(n.left, r, n.width, n.bottom - r) : Q(i - X, r, 0, 0);
|
|
1898
|
-
}
|
|
1899
|
-
let l = it.map(({ kind: t, labelKey: i, icon: o, placement: s, groups: l }) => {
|
|
1900
|
-
let u = r[i], d = document.createElement("button");
|
|
1901
|
-
d.type = "button", d.className = `stilo-table-handle stilo-table-handle--${t}`, d.tabIndex = -1, d.title = u, d.setAttribute("aria-label", u), d.setAttribute("aria-haspopup", "menu"), d.setAttribute("aria-expanded", "false"), d.hidden = !0, d.append(K(o)), n.append(d);
|
|
1902
|
-
let f = rt(e, {
|
|
1903
|
-
groups: l,
|
|
1904
|
-
label: u,
|
|
1905
|
-
messages: r,
|
|
1906
|
-
close: () => p.close()
|
|
1907
|
-
});
|
|
1908
|
-
f.element.classList.add("stilo-table-handle-menu");
|
|
1909
|
-
let p = U({
|
|
1910
|
-
anchor: d,
|
|
1911
|
-
content: f.element,
|
|
1912
|
-
container: n,
|
|
1913
|
-
onClose: (t) => {
|
|
1914
|
-
d.setAttribute("aria-expanded", "false"), t === "escape" && e.focus(), m();
|
|
1915
|
-
}
|
|
1916
|
-
});
|
|
1917
|
-
return {
|
|
1918
|
-
kind: t,
|
|
1919
|
-
button: d,
|
|
1920
|
-
anchor: {
|
|
1921
|
-
getBoundingClientRect: () => c(t),
|
|
1922
|
-
get contextElement() {
|
|
1923
|
-
return a ?? void 0;
|
|
1924
|
-
}
|
|
1925
|
-
},
|
|
1926
|
-
placement: s,
|
|
1927
|
-
actions: f,
|
|
1928
|
-
popover: p,
|
|
1929
|
-
generation: 0
|
|
1930
|
-
};
|
|
1931
|
-
}), u = () => l.some((e) => e.popover.isOpen);
|
|
1932
|
-
function d(e) {
|
|
1933
|
-
let t = ++e.generation;
|
|
1934
|
-
Promise.resolve(ce(e.anchor, e.button, {
|
|
1935
|
-
strategy: "absolute",
|
|
1936
|
-
placement: e.placement,
|
|
1937
|
-
middleware: e.kind === "table" ? [B(X)] : [B(X), ue()]
|
|
1938
|
-
}).then(({ x: n, y: r, middlewareData: i }) => {
|
|
1939
|
-
e.generation === t && (e.button.style.left = `${n}px`, e.button.style.top = `${r}px`, e.button.style.visibility = i.hide?.referenceHidden ? "hidden" : "");
|
|
1940
|
-
}));
|
|
1941
|
-
}
|
|
1942
|
-
function f() {
|
|
1943
|
-
let { node: t, offset: n } = i.domAtPos(e.state.selection.head), r = t.childNodes[n], a = (r instanceof Element ? r : t instanceof Element ? t : t.parentElement)?.closest("td, th");
|
|
1944
|
-
return a && i.dom.contains(a) ? a : null;
|
|
1945
|
-
}
|
|
1946
|
-
function p(e) {
|
|
1947
|
-
if (e !== a) {
|
|
1948
|
-
a = e;
|
|
1949
|
-
for (let e of l) e.stopAutoUpdate?.(), e.stopAutoUpdate = void 0, e.generation++, e.button.hidden = !a, a && (e.stopAutoUpdate = se(e.anchor, e.button, () => d(e)));
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
1952
|
-
function m() {
|
|
1953
|
-
if (u()) return;
|
|
1954
|
-
o && !o.isConnected && (o = null);
|
|
1955
|
-
let t = i.hasFocus() ? f() : null;
|
|
1956
|
-
p(e.isEditable ? o ?? t : null);
|
|
1957
|
-
}
|
|
1958
|
-
function h(e, t) {
|
|
1959
|
-
let n = e.closest("table")?.getBoundingClientRect();
|
|
1960
|
-
if (!n) return !1;
|
|
1961
|
-
let { clientX: r, clientY: i } = t;
|
|
1962
|
-
return r >= n.left - Z && r <= n.right + Z && i >= n.top - Z && i <= n.bottom + Z;
|
|
1963
|
-
}
|
|
1964
|
-
function g(t) {
|
|
1965
|
-
if (!a) return;
|
|
1966
|
-
let n = a.closest("table"), r = i.posAtDOM(a, 0);
|
|
1967
|
-
o = a, t.kind === "row" ? e.commands.selectRow(r) : t.kind === "column" ? e.commands.selectColumn(r) : f()?.closest("table") !== n && e.commands.selectTable(r), t.popover.open(), t.button.setAttribute("aria-expanded", "true"), t.actions.refresh(), t.actions.focusFirst();
|
|
1968
|
-
}
|
|
1969
|
-
let _ = (e) => {
|
|
1970
|
-
let t = e.target;
|
|
1971
|
-
if (u() || t.closest(".stilo-table-handle")) return;
|
|
1972
|
-
let n = t.closest("td, th");
|
|
1973
|
-
n && i.dom.contains(n) ? o = n : o && !h(o, e) && (o = null), m();
|
|
1974
|
-
}, v = () => {
|
|
1975
|
-
o = null, m();
|
|
1976
|
-
}, y = (e) => {
|
|
1977
|
-
e.target.closest(".stilo-table-handle") && e.preventDefault();
|
|
1978
|
-
}, b = (t) => {
|
|
1979
|
-
let n = t.target.closest(".stilo-table-handle"), r = l.find((e) => e.button === n);
|
|
1980
|
-
r && (r.popover.isOpen ? (r.popover.close(), e.focus()) : g(r));
|
|
1981
|
-
};
|
|
1982
|
-
n.addEventListener("mousemove", _), n.addEventListener("mouseleave", v), n.addEventListener("mousedown", y), n.addEventListener("click", b), e.on("transaction", m), e.on("focus", m), e.on("blur", m);
|
|
1983
|
-
function x() {
|
|
1984
|
-
n.removeEventListener("mousemove", _), n.removeEventListener("mouseleave", v), n.removeEventListener("mousedown", y), n.removeEventListener("click", b), e.off("transaction", m), e.off("focus", m), e.off("blur", m);
|
|
1985
|
-
for (let e of l) e.popover.destroy();
|
|
1986
|
-
p(null);
|
|
1987
|
-
for (let e of l) e.actions.destroy(), e.button.remove();
|
|
1988
|
-
}
|
|
1989
|
-
return {
|
|
1990
|
-
update: m,
|
|
1991
|
-
destroy: x
|
|
1992
|
-
};
|
|
1993
|
-
}
|
|
1994
|
-
//#endregion
|
|
1995
|
-
//#region src/ui/components/table-menu.ts
|
|
1996
|
-
var ot = 8, $ = 10, st = [
|
|
1997
|
-
[
|
|
1998
|
-
"addRowBefore",
|
|
1999
|
-
"addRowAfter",
|
|
2000
|
-
"deleteRow"
|
|
2001
|
-
],
|
|
2002
|
-
[
|
|
2003
|
-
"addColumnBefore",
|
|
2004
|
-
"addColumnAfter",
|
|
2005
|
-
"deleteColumn"
|
|
2006
|
-
],
|
|
2007
|
-
["mergeCells", "splitCell"],
|
|
2008
|
-
["toggleHeaderRow", "toggleHeaderColumn"],
|
|
2009
|
-
["deleteTable"]
|
|
2010
|
-
];
|
|
2011
|
-
function ct(e, t) {
|
|
2012
|
-
let { anchor: n, container: r, messages: i } = t, a = document.createElement("div");
|
|
2013
|
-
a.className = "stilo-table-menu", a.setAttribute("role", "dialog");
|
|
2014
|
-
let o = document.createElement("div");
|
|
2015
|
-
o.className = "stilo-table-menu__picker";
|
|
2016
|
-
let s = document.createElement("div");
|
|
2017
|
-
s.className = "stilo-table-menu__grid", s.setAttribute("role", "group"), s.setAttribute("aria-label", i["table.insert"]);
|
|
2018
|
-
let c = [];
|
|
2019
|
-
for (let e = 1; e <= ot; e++) for (let t = 1; t <= $; t++) {
|
|
2020
|
-
let n = document.createElement("button");
|
|
2021
|
-
n.type = "button", n.className = "stilo-table-menu__cell", n.tabIndex = -1, n.dataset.rows = String(e), n.dataset.columns = String(t), n.setAttribute("aria-label", h(e, t)), c.push(n);
|
|
2022
|
-
}
|
|
2023
|
-
s.append(...c);
|
|
2024
|
-
let l = document.createElement("div");
|
|
2025
|
-
l.className = "stilo-table-menu__size", l.setAttribute("aria-hidden", "true");
|
|
2026
|
-
let u = document.createElement("label");
|
|
2027
|
-
u.className = "stilo-table-menu__header";
|
|
2028
|
-
let d = document.createElement("input");
|
|
2029
|
-
d.type = "checkbox", d.checked = !0, u.append(d, ` ${i["table.headerRow"]}`), o.append(s, l, u);
|
|
2030
|
-
let f = rt(e, {
|
|
2031
|
-
groups: st,
|
|
2032
|
-
label: i["toolbar.table"],
|
|
2033
|
-
messages: i,
|
|
2034
|
-
close: () => m.close()
|
|
2035
|
-
}), p = f.element;
|
|
2036
|
-
a.append(o, p), n.setAttribute("aria-haspopup", "dialog"), n.setAttribute("aria-expanded", "false");
|
|
2037
|
-
let m = U({
|
|
2038
|
-
anchor: n,
|
|
2039
|
-
content: a,
|
|
2040
|
-
container: r,
|
|
2041
|
-
onClose: (t) => {
|
|
2042
|
-
n.setAttribute("aria-expanded", "false"), t === "escape" && e.focus();
|
|
2043
|
-
}
|
|
2044
|
-
});
|
|
2045
|
-
function h(e, t) {
|
|
2046
|
-
return i["table.size"].replace("{rows}", String(e)).replace("{columns}", String(t));
|
|
2047
|
-
}
|
|
2048
|
-
function g(e, t, n) {
|
|
2049
|
-
for (let n of c) {
|
|
2050
|
-
let r = Number(n.dataset.rows) <= e && Number(n.dataset.columns) <= t;
|
|
2051
|
-
n.classList.toggle("stilo-table-menu__cell--active", r), n.tabIndex = -1;
|
|
2052
|
-
}
|
|
2053
|
-
let r = c[(e - 1) * $ + t - 1];
|
|
2054
|
-
r.tabIndex = 0, n && r.focus({ preventScroll: !0 }), l.textContent = h(e, t);
|
|
2055
|
-
}
|
|
2056
|
-
function _(t) {
|
|
2057
|
-
let n = Number(t.dataset.rows), r = Number(t.dataset.columns);
|
|
2058
|
-
m.close(), e.focus(), e.commands.insertTable({
|
|
2059
|
-
rows: n,
|
|
2060
|
-
cols: r,
|
|
2061
|
-
withHeaderRow: d.checked
|
|
2062
|
-
});
|
|
2063
|
-
}
|
|
2064
|
-
let v = (e) => e.closest(".stilo-table-menu__cell"), y = (e) => {
|
|
2065
|
-
let t = v(e.target);
|
|
2066
|
-
t && g(Number(t.dataset.rows), Number(t.dataset.columns), !1);
|
|
2067
|
-
}, b = (e) => {
|
|
2068
|
-
let t = v(e.target);
|
|
2069
|
-
t && _(t);
|
|
2070
|
-
}, x = (e) => {
|
|
2071
|
-
let t = v(e.target);
|
|
2072
|
-
if (!t) return;
|
|
2073
|
-
let n = Number(t.dataset.rows), r = Number(t.dataset.columns);
|
|
2074
|
-
if (e.key === "ArrowDown") n = Math.min(n + 1, ot);
|
|
2075
|
-
else if (e.key === "ArrowUp") n = Math.max(n - 1, 1);
|
|
2076
|
-
else if (e.key === "ArrowRight") r = Math.min(r + 1, $);
|
|
2077
|
-
else if (e.key === "ArrowLeft") r = Math.max(r - 1, 1);
|
|
2078
|
-
else return;
|
|
2079
|
-
e.preventDefault(), g(n, r, !0);
|
|
2080
|
-
};
|
|
2081
|
-
s.addEventListener("mouseover", y), s.addEventListener("click", b), s.addEventListener("keydown", x);
|
|
2082
|
-
function S() {
|
|
2083
|
-
if (m.isOpen) return;
|
|
2084
|
-
let t = e.isActive("table");
|
|
2085
|
-
o.hidden = t, p.hidden = !t, a.setAttribute("aria-label", t ? i["toolbar.table"] : i["table.insert"]), m.open(), n.setAttribute("aria-expanded", "true"), t ? (f.refresh(), f.focusFirst()) : g(1, 1, !0);
|
|
2086
|
-
}
|
|
2087
|
-
function C() {
|
|
2088
|
-
m.isOpen && (m.close(), e.focus());
|
|
2089
|
-
}
|
|
2090
|
-
function w() {
|
|
2091
|
-
s.removeEventListener("mouseover", y), s.removeEventListener("click", b), s.removeEventListener("keydown", x), f.destroy(), m.destroy(), n.removeAttribute("aria-haspopup"), n.removeAttribute("aria-expanded");
|
|
2092
|
-
}
|
|
2093
|
-
return {
|
|
2094
|
-
get isOpen() {
|
|
2095
|
-
return m.isOpen;
|
|
2096
|
-
},
|
|
2097
|
-
open: S,
|
|
2098
|
-
close: C,
|
|
2099
|
-
toggle: () => m.isOpen ? C() : S(),
|
|
2100
|
-
destroy: w
|
|
2101
|
-
};
|
|
2102
|
-
}
|
|
2103
|
-
//#endregion
|
|
2104
|
-
//#region src/ui/toolbar/toolbar.ts
|
|
2105
|
-
function lt(e, t) {
|
|
2106
|
-
if (typeof e == "string") {
|
|
2107
|
-
let n = Ce[e];
|
|
2108
|
-
if (!n) throw new a(`Toolbar: unknown item "${e}"`);
|
|
2109
|
-
return n.isAvailable && !n.isAvailable(t) ? void 0 : n;
|
|
2110
|
-
}
|
|
2111
|
-
if (!e.isAvailable || e.isAvailable(t)) return e;
|
|
2112
|
-
}
|
|
2113
|
-
function ut(e, t) {
|
|
2114
|
-
let { selectionStart: n, selectionEnd: r, value: i } = t;
|
|
2115
|
-
switch (e.key) {
|
|
2116
|
-
case "Home":
|
|
2117
|
-
case "End": return !0;
|
|
2118
|
-
case "ArrowLeft": return n !== 0 || r !== 0;
|
|
2119
|
-
case "ArrowRight": return n !== i.length || r !== i.length;
|
|
2120
|
-
default: return !1;
|
|
2121
|
-
}
|
|
2122
|
-
}
|
|
2123
|
-
function dt(e, t) {
|
|
2124
|
-
let { container: n, items: r = Se, messages: i = H, sticky: a = !0 } = t, o = fe(), s = [];
|
|
2125
|
-
for (let t of r) {
|
|
2126
|
-
let n = [];
|
|
2127
|
-
for (let r of t) {
|
|
2128
|
-
let t = lt(r, e);
|
|
2129
|
-
t && n.push(t);
|
|
2130
|
-
}
|
|
2131
|
-
n.length > 0 && s.push(n);
|
|
2132
|
-
}
|
|
2133
|
-
let c = document.createElement("div");
|
|
2134
|
-
c.className = "stilo-toolbar", c.setAttribute("role", "toolbar"), c.setAttribute("aria-label", i?.["toolbar.label"] ?? "Formatting"), c.setAttribute("aria-orientation", "horizontal");
|
|
2135
|
-
let l = [], u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), f = [], p = [], m = [];
|
|
2136
|
-
for (let t of s) {
|
|
2137
|
-
let n = document.createElement("div");
|
|
2138
|
-
n.className = "stilo-toolbar__group", n.setAttribute("role", "group");
|
|
2139
|
-
for (let r of t) if (r.kind === "dropdown") {
|
|
2140
|
-
let t = r, a = t.options.map((e) => {
|
|
2141
|
-
let t = i[e.labelKey] ?? e.labelKey, n = e.shortcut ? V(e.shortcut, o) : void 0;
|
|
2142
|
-
return {
|
|
2143
|
-
id: e.id,
|
|
2144
|
-
label: t,
|
|
2145
|
-
shortcut: n,
|
|
2146
|
-
fontFamily: e.fontFamily,
|
|
2147
|
-
action: !e.isActive
|
|
2148
|
-
};
|
|
2149
|
-
}), s = We({
|
|
2150
|
-
label: i[t.labelKey] ?? t.labelKey,
|
|
2151
|
-
options: a,
|
|
2152
|
-
icon: t.icon,
|
|
2153
|
-
container: c,
|
|
2154
|
-
onSelect: (n) => {
|
|
2155
|
-
let r = t.options.find((e) => e.id === n);
|
|
2156
|
-
r && (r.run(e), e.focus());
|
|
2157
|
-
}
|
|
2158
|
-
});
|
|
2159
|
-
s.trigger.setAttribute("data-item", t.id), n.appendChild(s.trigger), l.push(s.trigger), u.set(s.trigger, t), d.set(t.id, s);
|
|
2160
|
-
} else if (r.kind === "iconMenu") {
|
|
2161
|
-
let t = et(e, r, {
|
|
2162
|
-
container: c,
|
|
2163
|
-
messages: i,
|
|
2164
|
-
mac: o
|
|
2165
|
-
});
|
|
2166
|
-
n.appendChild(t.trigger), l.push(t.trigger), u.set(t.trigger, r), m.push(t);
|
|
2167
|
-
} else if (r.kind === "fontSize") {
|
|
2168
|
-
let t = $e(e, r, {
|
|
2169
|
-
container: c,
|
|
2170
|
-
messages: i
|
|
2171
|
-
});
|
|
2172
|
-
n.appendChild(t.element);
|
|
2173
|
-
for (let e of t.parts) l.push(e), u.set(e, r);
|
|
2174
|
-
p.push(t);
|
|
2175
|
-
} else if (r.kind === "color") {
|
|
2176
|
-
let t = Ue(e, r, {
|
|
2177
|
-
container: c,
|
|
2178
|
-
messages: i
|
|
2179
|
-
});
|
|
2180
|
-
n.appendChild(t.element);
|
|
2181
|
-
for (let e of [t.main, t.arrow]) l.push(e), u.set(e, r);
|
|
2182
|
-
f.push(t);
|
|
2183
|
-
} else {
|
|
2184
|
-
let e = r, t = i[e.labelKey] ?? e.labelKey, a = e.shortcut === void 0 ? t : `${t} (${V(e.shortcut, o)})`, s = document.createElement("button");
|
|
2185
|
-
s.type = "button", s.className = "stilo-toolbar__button", s.setAttribute("data-item", e.id), s.setAttribute("aria-label", t), s.setAttribute("title", a), s.setAttribute("tabindex", "-1"), e.isActive && s.setAttribute("aria-pressed", "false");
|
|
2186
|
-
let c = K(e.icon);
|
|
2187
|
-
s.appendChild(c), n.appendChild(s), l.push(s), u.set(s, e);
|
|
2188
|
-
}
|
|
2189
|
-
c.appendChild(n);
|
|
2190
|
-
}
|
|
2191
|
-
let h = e.view.dom.parentElement ?? c, g = "setLink" in e.commands ? be(e, {
|
|
2192
|
-
container: h,
|
|
2193
|
-
messages: i
|
|
2194
|
-
}) : null, _ = g ? tt(e, {
|
|
2195
|
-
container: h,
|
|
2196
|
-
messages: i,
|
|
2197
|
-
onEdit: () => g.open()
|
|
2198
|
-
}) : null, v = "selectRow" in e.commands ? at(e, {
|
|
2199
|
-
container: h,
|
|
2200
|
-
messages: i
|
|
2201
|
-
}) : null, y = c.querySelector("[data-item=\"characters\"]"), b = y ? ze(e, {
|
|
2202
|
-
anchor: y,
|
|
2203
|
-
container: c,
|
|
2204
|
-
messages: i
|
|
2205
|
-
}) : null, x = c.querySelector("[data-item=\"table\"]"), S = x ? ct(e, {
|
|
2206
|
-
anchor: x,
|
|
2207
|
-
container: c,
|
|
2208
|
-
messages: i
|
|
2209
|
-
}) : null, C = {
|
|
2210
|
-
openLinkPopover: () => g?.open(),
|
|
2211
|
-
toggleCharacterPicker: () => b?.toggle(),
|
|
2212
|
-
toggleFindBar: () => T?.toggle(),
|
|
2213
|
-
toggleTableMenu: () => S?.toggle()
|
|
2214
|
-
};
|
|
2215
|
-
n.appendChild(c);
|
|
2216
|
-
let w = c.querySelector("[data-item=\"find\"]"), T = "setSearch" in e.commands ? qe(e, {
|
|
2217
|
-
container: n,
|
|
2218
|
-
messages: i,
|
|
2219
|
-
button: w
|
|
2220
|
-
}) : null, E = null;
|
|
2221
|
-
if (a) {
|
|
2222
|
-
n.classList.add("stilo-toolbar-host");
|
|
2223
|
-
let t = () => {
|
|
2224
|
-
let t = n.offsetHeight + 5;
|
|
2225
|
-
e.view.setProps({ scrollMargin: {
|
|
2226
|
-
top: t,
|
|
2227
|
-
right: 5,
|
|
2228
|
-
bottom: 5,
|
|
2229
|
-
left: 5
|
|
2230
|
-
} });
|
|
2231
|
-
};
|
|
2232
|
-
t(), typeof ResizeObserver < "u" && (E = new ResizeObserver(t), E.observe(n));
|
|
2233
|
-
}
|
|
2234
|
-
let D = 0, O = !1, k = 0;
|
|
2235
|
-
function A(e) {
|
|
2236
|
-
l.forEach((t, n) => {
|
|
2237
|
-
t.setAttribute("tabindex", n === e ? "0" : "-1");
|
|
2238
|
-
}), k = e;
|
|
2239
|
-
}
|
|
2240
|
-
A(0);
|
|
2241
|
-
function j() {
|
|
2242
|
-
for (let e of f) e.update();
|
|
2243
|
-
for (let e of p) e.update();
|
|
2244
|
-
for (let e of m) e.update();
|
|
2245
|
-
for (let t of l) {
|
|
2246
|
-
let n = u.get(t);
|
|
2247
|
-
if (n && n.kind !== "color" && n.kind !== "fontSize" && n.kind !== "iconMenu") {
|
|
2248
|
-
if (n.kind === "dropdown") {
|
|
2249
|
-
let t = n, r = null, i = /* @__PURE__ */ new Set();
|
|
2250
|
-
for (let n of t.options) {
|
|
2251
|
-
let t = n.isActive?.(e) ?? !1;
|
|
2252
|
-
n.isEnabled !== void 0 && !n.isEnabled(e) && i.add(n.id), t && r === null && (r = n.id);
|
|
2253
|
-
}
|
|
2254
|
-
let a = d.get(t.id), o = r === null ? t.getValueLabel?.(e) ?? null : null;
|
|
2255
|
-
a?.update({
|
|
2256
|
-
activeId: r,
|
|
2257
|
-
disabledIds: i,
|
|
2258
|
-
valueLabel: o
|
|
2259
|
-
});
|
|
2260
|
-
} else {
|
|
2261
|
-
let r = t, i = n;
|
|
2262
|
-
if (i.isActive) {
|
|
2263
|
-
let t = i.isActive(e);
|
|
2264
|
-
r.setAttribute("aria-pressed", t ? "true" : "false"), t ? r.classList.add("stilo-toolbar__button--active") : r.classList.remove("stilo-toolbar__button--active");
|
|
2265
|
-
} else r.removeAttribute("aria-pressed"), r.classList.remove("stilo-toolbar__button--active");
|
|
2266
|
-
i.isEnabled ? i.isEnabled(e) ? r.removeAttribute("aria-disabled") : r.setAttribute("aria-disabled", "true") : r.removeAttribute("aria-disabled");
|
|
2267
|
-
}
|
|
2268
|
-
}
|
|
2269
|
-
}
|
|
2270
|
-
}
|
|
2271
|
-
j();
|
|
2272
|
-
let M = () => {
|
|
2273
|
-
O || (D ||= requestAnimationFrame(() => {
|
|
2274
|
-
O || (D = 0, j());
|
|
2275
|
-
}));
|
|
2276
|
-
};
|
|
2277
|
-
e.on("transaction", M);
|
|
2278
|
-
let N = (e) => {
|
|
2279
|
-
O || e.target.closest(".stilo-char-picker, .stilo-color-picker, .stilo-font-size__input") || e.preventDefault();
|
|
2280
|
-
};
|
|
2281
|
-
c.addEventListener("mousedown", N);
|
|
2282
|
-
let P = (t) => {
|
|
2283
|
-
if (O) return;
|
|
2284
|
-
let n = t.target.closest("[data-item]");
|
|
2285
|
-
if (!n) return;
|
|
2286
|
-
let r = u.get(n);
|
|
2287
|
-
r && r.kind === "button" && (!r.isEnabled || r.isEnabled(e)) && (e.focus(), r.run(e, C));
|
|
2288
|
-
};
|
|
2289
|
-
c.addEventListener("click", P);
|
|
2290
|
-
let F = (t) => {
|
|
2291
|
-
if (O) return;
|
|
2292
|
-
let n = t.target.closest("[data-item]");
|
|
2293
|
-
if (!n) return;
|
|
2294
|
-
let r = l.indexOf(n);
|
|
2295
|
-
if (!(r === -1 || n instanceof HTMLInputElement && ut(t, n))) switch (t.key) {
|
|
2296
|
-
case "ArrowRight": {
|
|
2297
|
-
t.preventDefault();
|
|
2298
|
-
let e = (r + 1) % l.length;
|
|
2299
|
-
A(e), l[e].focus();
|
|
2300
|
-
break;
|
|
2301
|
-
}
|
|
2302
|
-
case "ArrowLeft": {
|
|
2303
|
-
t.preventDefault();
|
|
2304
|
-
let e = (r - 1 + l.length) % l.length;
|
|
2305
|
-
A(e), l[e].focus();
|
|
2306
|
-
break;
|
|
2307
|
-
}
|
|
2308
|
-
case "Home":
|
|
2309
|
-
t.preventDefault(), A(0), l[0].focus();
|
|
2310
|
-
break;
|
|
2311
|
-
case "End": {
|
|
2312
|
-
t.preventDefault();
|
|
2313
|
-
let e = l.length - 1;
|
|
2314
|
-
A(e), l[e].focus();
|
|
2315
|
-
break;
|
|
2316
|
-
}
|
|
2317
|
-
case "Escape": t.preventDefault(), e.focus();
|
|
2318
|
-
}
|
|
2319
|
-
};
|
|
2320
|
-
c.addEventListener("keydown", F);
|
|
2321
|
-
let I = (t) => {
|
|
2322
|
-
if (O) return;
|
|
2323
|
-
let n = o ? t.metaKey : t.ctrlKey;
|
|
2324
|
-
g && n && !t.altKey && !t.shiftKey && t.key.toLowerCase() === "k" ? (t.preventDefault(), g.open()) : T && n && !t.altKey && !t.shiftKey && t.key.toLowerCase() === "f" ? (t.preventDefault(), T.open()) : t.key === "F10" && t.altKey && (t.preventDefault(), e.focus(), k >= 0 && k < l.length && l[k].focus());
|
|
2325
|
-
};
|
|
2326
|
-
e.view.dom.addEventListener("keydown", I);
|
|
2327
|
-
let L = () => {
|
|
2328
|
-
R();
|
|
2329
|
-
};
|
|
2330
|
-
e.on("destroy", L);
|
|
2331
|
-
function R() {
|
|
2332
|
-
if (!O) {
|
|
2333
|
-
O = !0, D &&= (cancelAnimationFrame(D), 0), e.off("transaction", M), e.off("destroy", L), c.removeEventListener("mousedown", N), c.removeEventListener("click", P), c.removeEventListener("keydown", F), e.view.dom.removeEventListener("keydown", I);
|
|
2334
|
-
for (let e of d.values()) e.destroy();
|
|
2335
|
-
for (let e of f) e.destroy();
|
|
2336
|
-
for (let e of p) e.destroy();
|
|
2337
|
-
for (let e of m) e.destroy();
|
|
2338
|
-
g?.destroy(), _?.destroy(), v?.destroy(), b?.destroy(), S?.destroy(), T?.destroy(), n.contains(c) && n.removeChild(c), a && (E?.disconnect(), n.classList.remove("stilo-toolbar-host"), e.view.setProps({ scrollMargin: void 0 }));
|
|
2339
|
-
}
|
|
2340
|
-
}
|
|
2341
|
-
return {
|
|
2342
|
-
get element() {
|
|
2343
|
-
return c;
|
|
2344
|
-
},
|
|
2345
|
-
update: j,
|
|
2346
|
-
destroy: R
|
|
2347
|
-
};
|
|
2348
|
-
}
|
|
2349
|
-
//#endregion
|
|
2350
|
-
export { ge as DEFAULT_FONTS, _e as DEFAULT_FONT_SIZES, Ce as DEFAULT_ITEMS, G as DEFAULT_PALETTE, Se as DEFAULT_TOOLBAR, me as createStatusBar, dt as createToolbar, H as en, Ae as fontFamilyDropdown, je as fontSizeInput, V as formatShortcut, Ie as headingDropdown, Ee as highlightButton, he as it, Fe as lineHeightDropdown, Ne as textAlignMenu, Te as textColorButton };
|
|
1
|
+
export { f as DEFAULT_FONTS, p as DEFAULT_FONT_SIZES, n as DEFAULT_ITEMS, d as DEFAULT_PALETTE, r as DEFAULT_TOOLBAR, h as createStatusBar, t as createToolbar, g as en, i as fontFamilyDropdown, a as fontSizeInput, _ as formatShortcut, o as headingDropdown, s as highlightButton, m as it, c as lineHeightDropdown, l as textAlignMenu, u as textColorButton } from "./ui-WFNvrkbM.js";
|