@fiestaboard/ui 5.6.0 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/editor/color-picker-content.d.ts +25 -1
- package/dist/components/editor/color-picker-content.js +51 -44
- package/dist/components/editor/color-picker-content.js.map +1 -1
- package/dist/components/editor/draw-char-picker-content.d.ts +13 -3
- package/dist/components/editor/draw-char-picker-content.js +37 -36
- package/dist/components/editor/draw-char-picker-content.js.map +1 -1
- package/dist/components/editor/formatting-picker-content.js +10 -10
- package/dist/components/editor/template-editor-toolbar.d.ts +17 -1
- package/dist/components/editor/template-editor-toolbar.js +167 -163
- package/dist/components/editor/template-editor-toolbar.js.map +1 -1
- package/dist/components/editor/template-editor.d.ts +13 -1
- package/dist/components/editor/template-editor.js +132 -131
- package/dist/components/editor/template-editor.js.map +1 -1
- package/dist/components/feedback/badge.d.ts +23 -3
- package/dist/components/feedback/badge.js +29 -12
- package/dist/components/feedback/badge.js.map +1 -1
- package/dist/components/forms/button.d.ts +1 -1
- package/dist/components/forms/copy-button.d.ts +74 -0
- package/dist/components/forms/copy-button.js +49 -0
- package/dist/components/forms/copy-button.js.map +1 -0
- package/dist/components/forms/swatch.d.ts +40 -11
- package/dist/components/forms/swatch.js +40 -29
- package/dist/components/forms/swatch.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +101 -100
- package/dist/theme.css +21 -8
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ComponentProps } from "react";
|
|
2
|
+
import type { Code62Glyph } from "../../lib/board-characters";
|
|
2
3
|
import type { DeviceType } from "./constants";
|
|
3
4
|
import { TemplateEditorToolbar } from "./template-editor-toolbar";
|
|
4
5
|
import type { DrawBrush } from "./utils/draw-mode";
|
|
@@ -69,7 +70,7 @@ export declare const DEFAULT_TEMPLATE_EDITOR_LABELS: TemplateEditorLabels;
|
|
|
69
70
|
* The editor-owned props (`editor`, alignment/wrap state, device, draw mode)
|
|
70
71
|
* are omitted — the editor passes those itself, from its own state.
|
|
71
72
|
*/
|
|
72
|
-
export type TemplateEditorToolbarSlotProps = Omit<ComponentProps<typeof TemplateEditorToolbar>, "editor" | "currentAlignment" | "currentWrapEnabled" | "onAlignmentChange" | "onWrapToggle" | "deviceType" | "onSyncFromBoard" | "syncFromBoardPending" | "drawMode" | "onDrawModeToggle" | "drawBrush" | "onDrawBrushChange">;
|
|
73
|
+
export type TemplateEditorToolbarSlotProps = Omit<ComponentProps<typeof TemplateEditorToolbar>, "editor" | "currentAlignment" | "currentWrapEnabled" | "onAlignmentChange" | "onWrapToggle" | "deviceType" | "code62Glyph" | "onSyncFromBoard" | "syncFromBoardPending" | "drawMode" | "onDrawModeToggle" | "drawBrush" | "onDrawBrushChange">;
|
|
73
74
|
export interface TemplateEditorProps {
|
|
74
75
|
value: string;
|
|
75
76
|
onChange: (value: string) => void;
|
|
@@ -88,6 +89,17 @@ export interface TemplateEditorProps {
|
|
|
88
89
|
boardLines?: number;
|
|
89
90
|
onLineCountChange?: (lineCount: number) => void;
|
|
90
91
|
deviceType?: DeviceType;
|
|
92
|
+
/**
|
|
93
|
+
* Which glyph the target board's code-62 flap draws. Forwarded to the
|
|
94
|
+
* toolbar, and from there to the colour and draw-character pickers.
|
|
95
|
+
*
|
|
96
|
+
* It is a property of the individual board, not of the device family:
|
|
97
|
+
* since 2026 some Flagships ship a heart flap in that slot, so nothing
|
|
98
|
+
* queryable distinguishes them and only the owner knows
|
|
99
|
+
* (FiestaBoard#1657, #1664). Unset means `"degree"` on Flagship hardware,
|
|
100
|
+
* which is how every Flagship behaved before the change.
|
|
101
|
+
*/
|
|
102
|
+
code62Glyph?: Code62Glyph;
|
|
91
103
|
onSyncFromBoard?: () => void;
|
|
92
104
|
syncFromBoardPending?: boolean;
|
|
93
105
|
drawMode?: boolean;
|
|
@@ -10,25 +10,25 @@ import { resolveDimensions as ee } from "../../lib/board-dimensions.js";
|
|
|
10
10
|
import { DEFAULT_BOARD_LINES as te, DEFAULT_BOARD_WIDTH as ne } from "./constants.js";
|
|
11
11
|
import { ColorTileNode as re } from "./extensions/color-tile-node.js";
|
|
12
12
|
import { FillSpaceNode as ie } from "./extensions/fill-space-node.js";
|
|
13
|
-
import { FormulaNode as
|
|
14
|
-
import { LineNavigation as
|
|
15
|
-
import { SingleParagraphDoc as
|
|
16
|
-
import { TrailingNewline as
|
|
17
|
-
import { VariableNode as
|
|
18
|
-
import { WrappedTextNode as
|
|
19
|
-
import { brushToCell as
|
|
20
|
-
import { parseLineContent as
|
|
21
|
-
import { TemplateEditorToolbar as
|
|
22
|
-
import { buildStrokeTransaction as
|
|
23
|
-
import { AlignCenter as
|
|
24
|
-
import { forwardRef as
|
|
25
|
-
import { jsx as
|
|
26
|
-
import { closeHistory as
|
|
27
|
-
import { TextSelection as
|
|
28
|
-
import { EditorContent as
|
|
29
|
-
import
|
|
13
|
+
import { FormulaNode as ae } from "./extensions/formula-node.js";
|
|
14
|
+
import { LineNavigation as oe } from "./extensions/line-navigation.js";
|
|
15
|
+
import { SingleParagraphDoc as se } from "./extensions/single-paragraph-doc.js";
|
|
16
|
+
import { TrailingNewline as ce } from "./extensions/trailing-newline.js";
|
|
17
|
+
import { VariableNode as le } from "./extensions/variable-node.js";
|
|
18
|
+
import { WrappedTextNode as ue } from "./extensions/wrapped-text-node.js";
|
|
19
|
+
import { brushToCell as de } from "./utils/draw-mode.js";
|
|
20
|
+
import { parseLineContent as fe, parseTemplateSimple as u, serializeTemplateSimple as d } from "./utils/serialization.js";
|
|
21
|
+
import { TemplateEditorToolbar as pe } from "./template-editor-toolbar.js";
|
|
22
|
+
import { buildStrokeTransaction as me } from "./utils/stroke-transaction.js";
|
|
23
|
+
import { AlignCenter as he, AlignLeft as ge, AlignRight as _e } from "lucide-react";
|
|
24
|
+
import { forwardRef as f, useCallback as p, useEffect as m, useImperativeHandle as ve, useMemo as ye, useRef as h, useState as g } from "react";
|
|
25
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
26
|
+
import { closeHistory as y, undoDepth as be } from "@tiptap/pm/history";
|
|
27
|
+
import { TextSelection as b } from "@tiptap/pm/state";
|
|
28
|
+
import { EditorContent as xe, useEditor as Se } from "@tiptap/react";
|
|
29
|
+
import Ce from "@tiptap/starter-kit";
|
|
30
30
|
//#region src/components/editor/template-editor.tsx
|
|
31
|
-
var
|
|
31
|
+
var x = {
|
|
32
32
|
lineCount: (e, t) => `${e} / ${t} lines`,
|
|
33
33
|
overLineLimit: (e) => ` — exceeds the ${e}-line board limit`,
|
|
34
34
|
currentLine: (e) => `(Line ${e})`,
|
|
@@ -37,14 +37,14 @@ var S = {
|
|
|
37
37
|
alignCenter: "Align center",
|
|
38
38
|
alignRight: "Align right",
|
|
39
39
|
editorAriaLabel: "Template editor"
|
|
40
|
-
},
|
|
40
|
+
}, we = /* @__PURE__ */ new Set([
|
|
41
41
|
"variable",
|
|
42
42
|
"colorTile",
|
|
43
43
|
"fillSpace",
|
|
44
44
|
"formula",
|
|
45
45
|
"wrappedText"
|
|
46
46
|
]);
|
|
47
|
-
function
|
|
47
|
+
function S(e) {
|
|
48
48
|
try {
|
|
49
49
|
if (!e || !e.content || e.content.size === 0) return "";
|
|
50
50
|
let t = "";
|
|
@@ -67,15 +67,15 @@ function C(e) {
|
|
|
67
67
|
return console.warn("Error in serializeSliceToTemplate:", e), "";
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
var
|
|
70
|
+
var C = f(function({ value: f, onChange: C, onFocus: Te, placeholder: Ee = "Type text or insert variables...", className: w, showAlignmentControls: De = !0, onLineAlignmentChange: T, lineAlignments: Oe, onLineWrapChange: E, lineWrapEnabled: ke, showToolbar: D = !0, boardWidth: Ae, boardLines: je, onLineCountChange: O, deviceType: k, code62Glyph: Me, onSyncFromBoard: Ne, syncFromBoardPending: Pe = !1, drawMode: A = !1, onDrawModeToggle: Fe, drawBrush: j, onDrawBrushChange: Ie, onDrawHistoryEvent: M, labels: Le, toolbarProps: Re }, ze) {
|
|
71
71
|
let N = {
|
|
72
|
-
...
|
|
73
|
-
...
|
|
74
|
-
}, P =
|
|
72
|
+
...x,
|
|
73
|
+
...Le
|
|
74
|
+
}, P = k ? ee(k) : null, F = Ae ?? P?.cols ?? ne, I = je ?? P?.rows ?? te, Be = Oe || Array.from({ length: I }, () => "left"), L = ke || Array.from({ length: I }, () => !1), Ve = h(!1), R = h(null), z = h(null), [B, V] = g(() => (f || "").split("\n").length), [He, Ue] = g(() => Array.from({ length: I }, () => 24)), H = h(!1), U = h(null), W = Se({
|
|
75
75
|
immediatelyRender: !1,
|
|
76
76
|
extensions: [
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
se,
|
|
78
|
+
Ce.configure({
|
|
79
79
|
heading: !1,
|
|
80
80
|
blockquote: !1,
|
|
81
81
|
codeBlock: !1,
|
|
@@ -89,19 +89,19 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
89
89
|
strike: !1,
|
|
90
90
|
document: !1
|
|
91
91
|
}),
|
|
92
|
-
|
|
92
|
+
le,
|
|
93
93
|
re,
|
|
94
94
|
ie,
|
|
95
|
-
u,
|
|
96
|
-
le,
|
|
97
95
|
ae,
|
|
98
|
-
|
|
96
|
+
ue,
|
|
97
|
+
oe,
|
|
98
|
+
ce
|
|
99
99
|
],
|
|
100
|
-
content:
|
|
100
|
+
content: u(f || "", I),
|
|
101
101
|
editorProps: {
|
|
102
102
|
attributes: {
|
|
103
|
-
class: e("w-full font-mono text-sm", "prose prose-sm max-w-none", "[&_.ProseMirror]:outline-none", "[&_.ProseMirror]:font-mono", "[&_.ProseMirror]:text-sm", "[&_.ProseMirror]:resize-none", "[&_.ProseMirror]:uppercase", "[&_.ProseMirror_p]:my-0 [&_.ProseMirror_p]:leading-tight", "[&_.ProseMirror_p]:min-h-[1.5rem]",
|
|
104
|
-
"data-placeholder":
|
|
103
|
+
class: e("w-full font-mono text-sm", "prose prose-sm max-w-none", "[&_.ProseMirror]:outline-none", "[&_.ProseMirror]:font-mono", "[&_.ProseMirror]:text-sm", "[&_.ProseMirror]:resize-none", "[&_.ProseMirror]:uppercase", "[&_.ProseMirror_p]:my-0 [&_.ProseMirror_p]:leading-tight", "[&_.ProseMirror_p]:min-h-[1.5rem]", w),
|
|
104
|
+
"data-placeholder": Ee,
|
|
105
105
|
role: "textbox",
|
|
106
106
|
"aria-label": N.editorAriaLabel,
|
|
107
107
|
"aria-multiline": "true"
|
|
@@ -146,7 +146,7 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
146
146
|
}
|
|
147
147
|
if ((t.key === "ArrowRight" || t.key === "ArrowLeft") && !t.altKey && !t.ctrlKey && !t.metaKey) {
|
|
148
148
|
let { state: n } = e, { selection: r } = n;
|
|
149
|
-
if (!(r instanceof
|
|
149
|
+
if (!(r instanceof b)) return !1;
|
|
150
150
|
let i = r.$head.pos, a = r.$head.start(), o = r.$head.end();
|
|
151
151
|
if (t.key === "ArrowRight") {
|
|
152
152
|
if (i >= o) return !1;
|
|
@@ -154,7 +154,7 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
154
154
|
for (; a < o && n.doc.textBetween(a - 1, a, void 0, "") === "";) a++;
|
|
155
155
|
if (a === i + 1 && !t.shiftKey) return !1;
|
|
156
156
|
t.preventDefault();
|
|
157
|
-
let s = t.shiftKey ?
|
|
157
|
+
let s = t.shiftKey ? b.create(n.doc, r.$anchor.pos, a) : b.create(n.doc, a);
|
|
158
158
|
return e.dispatch(n.tr.setSelection(s).scrollIntoView()), !0;
|
|
159
159
|
}
|
|
160
160
|
if (t.key === "ArrowLeft") {
|
|
@@ -163,7 +163,7 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
163
163
|
for (; o > a && n.doc.textBetween(o, o + 1, void 0, "") === "";) o--;
|
|
164
164
|
if (o === i - 1 && !t.shiftKey) return !1;
|
|
165
165
|
t.preventDefault();
|
|
166
|
-
let s = t.shiftKey ?
|
|
166
|
+
let s = t.shiftKey ? b.create(n.doc, r.$anchor.pos, o) : b.create(n.doc, o);
|
|
167
167
|
return e.dispatch(n.tr.setSelection(s).scrollIntoView()), !0;
|
|
168
168
|
}
|
|
169
169
|
}
|
|
@@ -184,7 +184,7 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
184
184
|
try {
|
|
185
185
|
let e = r.content();
|
|
186
186
|
if (e) {
|
|
187
|
-
let t =
|
|
187
|
+
let t = S(e);
|
|
188
188
|
navigator.clipboard && navigator.clipboard.writeText && navigator.clipboard.writeText(t).catch(() => {});
|
|
189
189
|
}
|
|
190
190
|
} catch (e) {
|
|
@@ -201,7 +201,7 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
201
201
|
try {
|
|
202
202
|
let e = t.clipboardData?.getData("text/plain") || "";
|
|
203
203
|
if (e && (e.includes("{{") || e.match(/\{[a-z]+\}/i))) {
|
|
204
|
-
let t =
|
|
204
|
+
let t = fe(e);
|
|
205
205
|
if (t.length > 0 && R.current?.state && R.current?.chain) return R.current.chain().focus().insertContent(t).run(), !0;
|
|
206
206
|
}
|
|
207
207
|
} catch (e) {
|
|
@@ -237,9 +237,9 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
237
237
|
});
|
|
238
238
|
if (!n) return !1;
|
|
239
239
|
let r = e.state.doc.nodeAt(n.pos);
|
|
240
|
-
if (!r || !
|
|
240
|
+
if (!r || !we.has(r.type.name)) return !1;
|
|
241
241
|
let i = n.pos + r.nodeSize;
|
|
242
|
-
e.dispatch(e.state.tr.setSelection(
|
|
242
|
+
e.dispatch(e.state.tr.setSelection(b.create(e.state.doc, i)));
|
|
243
243
|
let a = e.nodeDOM(n.pos);
|
|
244
244
|
return a instanceof HTMLElement && a.classList.add("selected-inline"), t.preventDefault(), !0;
|
|
245
245
|
}
|
|
@@ -263,7 +263,7 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
263
263
|
if (c >= 0 && c <= s.doc.content.size) {
|
|
264
264
|
s.insert(c, a);
|
|
265
265
|
let t = c + a.nodeSize;
|
|
266
|
-
return t <= s.doc.content.size && s.setSelection(
|
|
266
|
+
return t <= s.doc.content.size && s.setSelection(b.create(s.doc, t)), e.dispatch(s), z.current = null, !0;
|
|
267
267
|
}
|
|
268
268
|
} catch (e) {
|
|
269
269
|
console.warn("Error handling drop:", e);
|
|
@@ -274,7 +274,7 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
274
274
|
},
|
|
275
275
|
clipboardTextSerializer: (e) => {
|
|
276
276
|
try {
|
|
277
|
-
return !e || !e.content ? "" :
|
|
277
|
+
return !e || !e.content ? "" : S(e);
|
|
278
278
|
} catch (e) {
|
|
279
279
|
return console.warn("Error in clipboardTextSerializer:", e), "";
|
|
280
280
|
}
|
|
@@ -293,32 +293,32 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
293
293
|
});
|
|
294
294
|
},
|
|
295
295
|
onUpdate: ({ editor: e }) => {
|
|
296
|
-
if (
|
|
297
|
-
let t = e.getJSON(), n =
|
|
298
|
-
|
|
296
|
+
if (Ve.current || !e || !e.state) return;
|
|
297
|
+
let t = e.getJSON(), n = d(t, I), r = n.split("\n").length;
|
|
298
|
+
C(n), V(r), O && O(r), U.current?.();
|
|
299
299
|
},
|
|
300
300
|
onCreate: ({ editor: e }) => {
|
|
301
|
-
let t = e.getJSON(), n =
|
|
302
|
-
V(n),
|
|
301
|
+
let t = e.getJSON(), n = d(t, I).split("\n").length;
|
|
302
|
+
V(n), O && O(n), U.current?.();
|
|
303
303
|
},
|
|
304
304
|
onFocus: () => {
|
|
305
|
-
|
|
305
|
+
Te?.();
|
|
306
306
|
}
|
|
307
307
|
});
|
|
308
|
-
|
|
308
|
+
m(() => {
|
|
309
309
|
W && (R.current = W);
|
|
310
310
|
}, [W]);
|
|
311
|
-
let
|
|
311
|
+
let We = h({
|
|
312
312
|
done: [],
|
|
313
313
|
undone: []
|
|
314
|
-
}), G =
|
|
315
|
-
|
|
314
|
+
}), G = h(!1), K = h(M);
|
|
315
|
+
m(() => {
|
|
316
316
|
K.current = M;
|
|
317
|
-
}, [M]),
|
|
317
|
+
}, [M]), m(() => {
|
|
318
318
|
if (!W) return;
|
|
319
319
|
let e = ({ transaction: e }) => {
|
|
320
320
|
if (!e.docChanged) return;
|
|
321
|
-
let t =
|
|
321
|
+
let t = We.current, n = e.getMeta("history$"), r = be(W.state);
|
|
322
322
|
if (n && typeof n == "object" && typeof n.redo == "boolean") if (n.redo) {
|
|
323
323
|
for (; t.undone.length > 0 && t.undone[t.undone.length - 1] > r;) t.undone.pop();
|
|
324
324
|
let e = t.undone[t.undone.length - 1] === r;
|
|
@@ -343,11 +343,11 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
343
343
|
return W.on("transaction", e), () => {
|
|
344
344
|
W.off("transaction", e);
|
|
345
345
|
};
|
|
346
|
-
}, [W]),
|
|
346
|
+
}, [W]), ve(ze, () => ({
|
|
347
347
|
applyStroke(e, t) {
|
|
348
348
|
let n = R.current;
|
|
349
349
|
if (!n || n.isDestroyed) return [];
|
|
350
|
-
let r =
|
|
350
|
+
let r = de(t), i = d(n.getJSON(), I).split("\n"), a = /* @__PURE__ */ new Map();
|
|
351
351
|
for (let t of e) {
|
|
352
352
|
if (t.row < 0 || t.row >= I || t.col < 0 || t.col >= F) continue;
|
|
353
353
|
let e = a.get(t.row) ?? [];
|
|
@@ -357,10 +357,10 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
357
357
|
}), a.set(t.row, e);
|
|
358
358
|
}
|
|
359
359
|
if (a.size === 0) return [];
|
|
360
|
-
let o =
|
|
360
|
+
let o = me(n.state, i, a, F);
|
|
361
361
|
if (!o) return [];
|
|
362
362
|
let { view: s } = n;
|
|
363
|
-
return G.current = !0, s.dispatch(
|
|
363
|
+
return G.current = !0, s.dispatch(y(o)), s.dispatch(y(s.state.tr)), [...a.keys()].sort((e, t) => e - t);
|
|
364
364
|
},
|
|
365
365
|
undo() {
|
|
366
366
|
let e = R.current;
|
|
@@ -371,8 +371,8 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
371
371
|
!e || e.isDestroyed || e.chain().redo().run();
|
|
372
372
|
}
|
|
373
373
|
}), [I, F]);
|
|
374
|
-
let q =
|
|
375
|
-
if (!(!W || W.isDestroyed) && !
|
|
374
|
+
let q = p(() => {
|
|
375
|
+
if (!(!W || W.isDestroyed) && !A) try {
|
|
376
376
|
let { state: e, view: t } = W;
|
|
377
377
|
if (!t.dom.isConnected) return;
|
|
378
378
|
let n = [];
|
|
@@ -397,26 +397,26 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
397
397
|
i.push(Math.max(Math.round(a - r[e]), 24));
|
|
398
398
|
}
|
|
399
399
|
for (; i.length < I;) i.push(24);
|
|
400
|
-
|
|
400
|
+
Ue((e) => e.length === i.length && e.every((e, t) => e === i[t]) ? e : i);
|
|
401
401
|
} catch {}
|
|
402
402
|
}, [
|
|
403
403
|
W,
|
|
404
404
|
I,
|
|
405
|
-
|
|
406
|
-
]), J =
|
|
405
|
+
A
|
|
406
|
+
]), J = p(() => {
|
|
407
407
|
H.current || (H.current = !0, requestAnimationFrame(() => {
|
|
408
408
|
H.current = !1, q();
|
|
409
409
|
}));
|
|
410
410
|
}, [q]);
|
|
411
|
-
|
|
411
|
+
m(() => {
|
|
412
412
|
U.current = J;
|
|
413
|
-
}, [J]),
|
|
414
|
-
|
|
415
|
-
}, [
|
|
413
|
+
}, [J]), m(() => {
|
|
414
|
+
A || J();
|
|
415
|
+
}, [A, J]), m(() => {
|
|
416
416
|
if (!W) return;
|
|
417
417
|
let e = new ResizeObserver(J);
|
|
418
418
|
return e.observe(W.view.dom), J(), () => e.disconnect();
|
|
419
|
-
}, [W, J]),
|
|
419
|
+
}, [W, J]), m(() => {
|
|
420
420
|
if (!W) return;
|
|
421
421
|
let e = W.view.dom, t = (e) => {
|
|
422
422
|
if (!z.current) return;
|
|
@@ -444,7 +444,7 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
444
444
|
if (s >= 0 && s <= o.doc.content.size) {
|
|
445
445
|
o.insert(s, i);
|
|
446
446
|
let e = s + i.nodeSize;
|
|
447
|
-
e <= o.doc.content.size && o.setSelection(
|
|
447
|
+
e <= o.doc.content.size && o.setSelection(b.create(o.doc, e)), W.view.dispatch(o), z.current = null;
|
|
448
448
|
}
|
|
449
449
|
} catch (e) {
|
|
450
450
|
console.warn("Error handling DOM drop:", e), z.current = null;
|
|
@@ -455,23 +455,23 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
455
455
|
return e.addEventListener("drop", t), e.addEventListener("dragover", n), () => {
|
|
456
456
|
e.removeEventListener("drop", t), e.removeEventListener("dragover", n);
|
|
457
457
|
};
|
|
458
|
-
}, [W]),
|
|
458
|
+
}, [W]), m(() => {
|
|
459
459
|
if (!W || W.isDestroyed) return;
|
|
460
|
-
W.isFocused ||
|
|
461
|
-
!W || W.isDestroyed || W.commands.setContent(
|
|
460
|
+
W.isFocused || f !== d(W.getJSON(), I) && queueMicrotask(() => {
|
|
461
|
+
!W || W.isDestroyed || W.commands.setContent(u(f || "", I), {
|
|
462
462
|
emitUpdate: !1,
|
|
463
463
|
parseOptions: { preserveWhitespace: !0 }
|
|
464
464
|
});
|
|
465
465
|
});
|
|
466
|
-
let e = (
|
|
467
|
-
V(e),
|
|
466
|
+
let e = (f || "").split("\n").length;
|
|
467
|
+
V(e), O && O(e), U.current?.();
|
|
468
468
|
}, [
|
|
469
|
-
|
|
469
|
+
f,
|
|
470
470
|
W,
|
|
471
471
|
I,
|
|
472
|
-
|
|
472
|
+
O
|
|
473
473
|
]);
|
|
474
|
-
let Y =
|
|
474
|
+
let Y = p(() => {
|
|
475
475
|
try {
|
|
476
476
|
if (!W || !W.state || !W.state.selection) return null;
|
|
477
477
|
let { state: e } = W, { selection: t } = e;
|
|
@@ -483,7 +483,7 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
483
483
|
} catch (e) {
|
|
484
484
|
return console.warn("Error in getCurrentLineIndex:", e), null;
|
|
485
485
|
}
|
|
486
|
-
}, [W]), X =
|
|
486
|
+
}, [W]), X = p((e) => {
|
|
487
487
|
if (W) try {
|
|
488
488
|
if (!W.state || !W.state.selection) return;
|
|
489
489
|
let { state: t } = W, { selection: n } = t;
|
|
@@ -497,27 +497,27 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
497
497
|
e && e.type && e.type.name === "hardBreak" && i++;
|
|
498
498
|
}), r < 0 || r >= I) return;
|
|
499
499
|
let a = Math.min(i, I - 1);
|
|
500
|
-
if (
|
|
500
|
+
if (T) for (let t = r; t <= a; t++) T(t, e);
|
|
501
501
|
} catch (e) {
|
|
502
502
|
console.warn("Error in handleAlignmentClick:", e);
|
|
503
503
|
}
|
|
504
504
|
}, [
|
|
505
505
|
W,
|
|
506
506
|
I,
|
|
507
|
-
|
|
508
|
-
]),
|
|
507
|
+
T
|
|
508
|
+
]), Ge = p(() => {
|
|
509
509
|
if (!W) return;
|
|
510
510
|
let e = Y();
|
|
511
511
|
if (e === null || e < 0 || e >= I) return;
|
|
512
512
|
let t = !L[e];
|
|
513
|
-
|
|
513
|
+
E && E(e, t);
|
|
514
514
|
}, [
|
|
515
515
|
W,
|
|
516
516
|
Y,
|
|
517
|
-
|
|
517
|
+
E,
|
|
518
518
|
I,
|
|
519
519
|
L
|
|
520
|
-
]), Z =
|
|
520
|
+
]), Z = ye(() => {
|
|
521
521
|
try {
|
|
522
522
|
if (!W?.state?.selection?.$from || !W.state.doc) return null;
|
|
523
523
|
let e = 0;
|
|
@@ -527,44 +527,45 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
527
527
|
} catch (e) {
|
|
528
528
|
return console.warn("Error getting current line index:", e), null;
|
|
529
529
|
}
|
|
530
|
-
}, [W, W?.state?.selection?.$from?.pos]), Q = Z !== null && Z >= 0 && Z < I &&
|
|
531
|
-
if (!W) return /* @__PURE__ */
|
|
532
|
-
className: e("min-h-[9rem] border rounded-md p-2 bg-muted/30",
|
|
533
|
-
children: /* @__PURE__ */
|
|
530
|
+
}, [W, W?.state?.selection?.$from?.pos]), Q = Z !== null && Z >= 0 && Z < I && Be[Z] || "left";
|
|
531
|
+
if (!W) return /* @__PURE__ */ _(t, {
|
|
532
|
+
className: e("min-h-[9rem] border rounded-md p-2 bg-muted/30", w),
|
|
533
|
+
children: /* @__PURE__ */ _(a, {
|
|
534
534
|
gap: "1",
|
|
535
|
-
children: Array.from({ length: I }).map((e, t) => /* @__PURE__ */
|
|
535
|
+
children: Array.from({ length: I }).map((e, t) => /* @__PURE__ */ _(r, { className: "h-6" }, t))
|
|
536
536
|
})
|
|
537
537
|
});
|
|
538
|
-
let
|
|
539
|
-
return /* @__PURE__ */
|
|
540
|
-
className: e("relative",
|
|
541
|
-
children: [
|
|
542
|
-
...
|
|
538
|
+
let Ke = Z !== null && Z >= 0 && Z < I && L[Z] || !1, $ = B > I;
|
|
539
|
+
return /* @__PURE__ */ v(t, {
|
|
540
|
+
className: e("relative", w),
|
|
541
|
+
children: [D && /* @__PURE__ */ _(pe, {
|
|
542
|
+
...Re,
|
|
543
543
|
editor: W,
|
|
544
544
|
currentAlignment: Q,
|
|
545
|
-
currentWrapEnabled:
|
|
545
|
+
currentWrapEnabled: Ke,
|
|
546
546
|
onAlignmentChange: X,
|
|
547
|
-
onWrapToggle:
|
|
548
|
-
deviceType:
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
547
|
+
onWrapToggle: Ge,
|
|
548
|
+
deviceType: k,
|
|
549
|
+
code62Glyph: Me,
|
|
550
|
+
onSyncFromBoard: Ne,
|
|
551
|
+
syncFromBoardPending: Pe,
|
|
552
|
+
drawMode: A,
|
|
553
|
+
onDrawModeToggle: Fe,
|
|
554
|
+
drawBrush: j,
|
|
555
|
+
onDrawBrushChange: Ie
|
|
556
|
+
}), /* @__PURE__ */ v(t, {
|
|
557
|
+
className: e("flex-1", A && "hidden"),
|
|
557
558
|
children: [
|
|
558
|
-
/* @__PURE__ */
|
|
559
|
-
className: e("border bg-background relative rounded-md",
|
|
559
|
+
/* @__PURE__ */ _(t, {
|
|
560
|
+
className: e("border bg-background relative rounded-md", D ? "rounded-t-none" : "", $ && "border-warning"),
|
|
560
561
|
style: {
|
|
561
562
|
padding: "0.75rem",
|
|
562
563
|
minHeight: `${I * 1.5 + 1.5}rem`
|
|
563
564
|
},
|
|
564
|
-
children: /* @__PURE__ */
|
|
565
|
+
children: /* @__PURE__ */ v(n, {
|
|
565
566
|
gap: "2",
|
|
566
567
|
style: { minHeight: `${I * 1.5}rem` },
|
|
567
|
-
children: [/* @__PURE__ */
|
|
568
|
+
children: [/* @__PURE__ */ _(t, {
|
|
568
569
|
className: "select-none shrink-0 text-right",
|
|
569
570
|
style: {
|
|
570
571
|
fontSize: "0.75rem",
|
|
@@ -572,75 +573,75 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
572
573
|
minWidth: "1.25rem"
|
|
573
574
|
},
|
|
574
575
|
"aria-hidden": "true",
|
|
575
|
-
children: Array.from({ length: Math.max(B, I) }, (e, n) => /* @__PURE__ */
|
|
576
|
+
children: Array.from({ length: Math.max(B, I) }, (e, n) => /* @__PURE__ */ _(t, {
|
|
576
577
|
style: {
|
|
577
|
-
height: `${
|
|
578
|
+
height: `${He[n] ?? 24}px`,
|
|
578
579
|
lineHeight: "1.5rem",
|
|
579
580
|
color: n === Z ? "var(--foreground)" : "var(--muted-foreground)",
|
|
580
581
|
opacity: n === Z ? .7 : .4
|
|
581
582
|
},
|
|
582
583
|
children: n + 1
|
|
583
584
|
}, n))
|
|
584
|
-
}), /* @__PURE__ */
|
|
585
|
+
}), /* @__PURE__ */ _(t, {
|
|
585
586
|
className: "relative flex-1 min-w-0",
|
|
586
|
-
children: /* @__PURE__ */
|
|
587
|
+
children: /* @__PURE__ */ _(xe, { editor: W })
|
|
587
588
|
})]
|
|
588
589
|
})
|
|
589
590
|
}),
|
|
590
|
-
/* @__PURE__ */
|
|
591
|
+
/* @__PURE__ */ v(i, {
|
|
591
592
|
size: "xs",
|
|
592
593
|
tone: $ ? "warning" : "muted",
|
|
593
594
|
weight: $ ? "medium" : "normal",
|
|
594
595
|
className: "mt-1",
|
|
595
596
|
children: [N.lineCount(B, I), $ && N.overLineLimit(I)]
|
|
596
597
|
}),
|
|
597
|
-
!
|
|
598
|
+
!D && De && /* @__PURE__ */ _(c, { children: /* @__PURE__ */ v(n, {
|
|
598
599
|
align: "center",
|
|
599
600
|
gap: "2",
|
|
600
601
|
className: "mt-2",
|
|
601
602
|
children: [
|
|
602
|
-
/* @__PURE__ */
|
|
603
|
+
/* @__PURE__ */ _(i, {
|
|
603
604
|
as: "span",
|
|
604
605
|
size: "xs",
|
|
605
606
|
tone: "muted",
|
|
606
607
|
children: N.alignment
|
|
607
608
|
}),
|
|
608
|
-
/* @__PURE__ */
|
|
609
|
+
/* @__PURE__ */ v(n, {
|
|
609
610
|
className: "rounded-md border overflow-hidden",
|
|
610
611
|
children: [
|
|
611
|
-
/* @__PURE__ */
|
|
612
|
+
/* @__PURE__ */ v(o, { children: [/* @__PURE__ */ _(l, {
|
|
612
613
|
asChild: !0,
|
|
613
|
-
children: /* @__PURE__ */
|
|
614
|
+
children: /* @__PURE__ */ _("button", {
|
|
614
615
|
type: "button",
|
|
615
616
|
onClick: () => X("left"),
|
|
616
617
|
"aria-label": N.alignLeft,
|
|
617
618
|
className: e("px-3 py-1.5 text-xs transition-colors", Q === "left" ? "bg-primary text-primary-foreground" : "hover:bg-muted text-muted-foreground"),
|
|
618
|
-
children: /* @__PURE__ */
|
|
619
|
+
children: /* @__PURE__ */ _(ge, { className: "w-4 h-4" })
|
|
619
620
|
})
|
|
620
|
-
}), /* @__PURE__ */
|
|
621
|
-
/* @__PURE__ */
|
|
621
|
+
}), /* @__PURE__ */ _(s, { children: N.alignLeft })] }),
|
|
622
|
+
/* @__PURE__ */ v(o, { children: [/* @__PURE__ */ _(l, {
|
|
622
623
|
asChild: !0,
|
|
623
|
-
children: /* @__PURE__ */
|
|
624
|
+
children: /* @__PURE__ */ _("button", {
|
|
624
625
|
type: "button",
|
|
625
626
|
onClick: () => X("center"),
|
|
626
627
|
"aria-label": N.alignCenter,
|
|
627
628
|
className: e("px-3 py-1.5 text-xs border-x transition-colors", Q === "center" ? "bg-primary text-primary-foreground border-primary" : "hover:bg-muted text-muted-foreground"),
|
|
628
|
-
children: /* @__PURE__ */
|
|
629
|
+
children: /* @__PURE__ */ _(he, { className: "w-4 h-4" })
|
|
629
630
|
})
|
|
630
|
-
}), /* @__PURE__ */
|
|
631
|
-
/* @__PURE__ */
|
|
631
|
+
}), /* @__PURE__ */ _(s, { children: N.alignCenter })] }),
|
|
632
|
+
/* @__PURE__ */ v(o, { children: [/* @__PURE__ */ _(l, {
|
|
632
633
|
asChild: !0,
|
|
633
|
-
children: /* @__PURE__ */
|
|
634
|
+
children: /* @__PURE__ */ _("button", {
|
|
634
635
|
type: "button",
|
|
635
636
|
onClick: () => X("right"),
|
|
636
637
|
"aria-label": N.alignRight,
|
|
637
638
|
className: e("px-3 py-1.5 text-xs transition-colors", Q === "right" ? "bg-primary text-primary-foreground" : "hover:bg-muted text-muted-foreground"),
|
|
638
|
-
children: /* @__PURE__ */
|
|
639
|
+
children: /* @__PURE__ */ _(_e, { className: "w-4 h-4" })
|
|
639
640
|
})
|
|
640
|
-
}), /* @__PURE__ */
|
|
641
|
+
}), /* @__PURE__ */ _(s, { children: N.alignRight })] })
|
|
641
642
|
]
|
|
642
643
|
}),
|
|
643
|
-
Z !== null && /* @__PURE__ */
|
|
644
|
+
Z !== null && /* @__PURE__ */ _(i, {
|
|
644
645
|
as: "span",
|
|
645
646
|
size: "xs",
|
|
646
647
|
tone: "muted",
|
|
@@ -653,6 +654,6 @@ var w = p(function({ value: p, onChange: w, onFocus: we, placeholder: Te = "Type
|
|
|
653
654
|
});
|
|
654
655
|
});
|
|
655
656
|
//#endregion
|
|
656
|
-
export {
|
|
657
|
+
export { x as DEFAULT_TEMPLATE_EDITOR_LABELS, C as TemplateEditor };
|
|
657
658
|
|
|
658
659
|
//# sourceMappingURL=template-editor.js.map
|