@fiestaboard/ui 3.1.0 → 3.2.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 -0
- package/dist/components/editor/color-picker-content.js +118 -0
- package/dist/components/editor/color-picker-content.js.map +1 -0
- package/dist/components/editor/constants.d.ts +87 -0
- package/dist/components/editor/constants.js +29 -0
- package/dist/components/editor/constants.js.map +1 -0
- package/dist/components/editor/draw-char-picker-content.d.ts +22 -0
- package/dist/components/editor/draw-char-picker-content.js +79 -0
- package/dist/components/editor/draw-char-picker-content.js.map +1 -0
- package/dist/components/editor/extensions/color-tile-node.d.ts +10 -0
- package/dist/components/editor/extensions/color-tile-node.js +43 -0
- package/dist/components/editor/extensions/color-tile-node.js.map +1 -0
- package/dist/components/editor/extensions/fill-space-node.d.ts +10 -0
- package/dist/components/editor/extensions/fill-space-node.js +40 -0
- package/dist/components/editor/extensions/fill-space-node.js.map +1 -0
- package/dist/components/editor/extensions/formula-node.d.ts +6 -0
- package/dist/components/editor/extensions/formula-node.js +40 -0
- package/dist/components/editor/extensions/formula-node.js.map +1 -0
- package/dist/components/editor/extensions/line-navigation.d.ts +18 -0
- package/dist/components/editor/extensions/line-navigation.js +16 -0
- package/dist/components/editor/extensions/line-navigation.js.map +1 -0
- package/dist/components/editor/extensions/single-paragraph-doc.d.ts +15 -0
- package/dist/components/editor/extensions/single-paragraph-doc.js +11 -0
- package/dist/components/editor/extensions/single-paragraph-doc.js.map +1 -0
- package/dist/components/editor/extensions/trailing-newline.d.ts +13 -0
- package/dist/components/editor/extensions/trailing-newline.js +27 -0
- package/dist/components/editor/extensions/trailing-newline.js.map +1 -0
- package/dist/components/editor/extensions/variable-node.d.ts +15 -0
- package/dist/components/editor/extensions/variable-node.js +56 -0
- package/dist/components/editor/extensions/variable-node.js.map +1 -0
- package/dist/components/editor/extensions/wrapped-text-node.d.ts +9 -0
- package/dist/components/editor/extensions/wrapped-text-node.js +31 -0
- package/dist/components/editor/extensions/wrapped-text-node.js.map +1 -0
- package/dist/components/editor/filter-picker-content.d.ts +24 -0
- package/dist/components/editor/filter-picker-content.js +146 -0
- package/dist/components/editor/filter-picker-content.js.map +1 -0
- package/dist/components/editor/formatting-picker-content.d.ts +30 -0
- package/dist/components/editor/formatting-picker-content.js +154 -0
- package/dist/components/editor/formatting-picker-content.js.map +1 -0
- package/dist/components/editor/formula/formula-editor-panel.d.ts +102 -0
- package/dist/components/editor/formula/formula-editor-panel.js +527 -0
- package/dist/components/editor/formula/formula-editor-panel.js.map +1 -0
- package/dist/components/editor/node-views/color-tile-node-view.d.ts +21 -0
- package/dist/components/editor/node-views/color-tile-node-view.js +66 -0
- package/dist/components/editor/node-views/color-tile-node-view.js.map +1 -0
- package/dist/components/editor/node-views/fill-space-node-view.d.ts +16 -0
- package/dist/components/editor/node-views/fill-space-node-view.js +43 -0
- package/dist/components/editor/node-views/fill-space-node-view.js.map +1 -0
- package/dist/components/editor/node-views/formula-node-view.d.ts +39 -0
- package/dist/components/editor/node-views/formula-node-view.js +109 -0
- package/dist/components/editor/node-views/formula-node-view.js.map +1 -0
- package/dist/components/editor/node-views/node-view-context.d.ts +58 -0
- package/dist/components/editor/node-views/node-view-context.js +22 -0
- package/dist/components/editor/node-views/node-view-context.js.map +1 -0
- package/dist/components/editor/node-views/variable-node-view.d.ts +16 -0
- package/dist/components/editor/node-views/variable-node-view.js +63 -0
- package/dist/components/editor/node-views/variable-node-view.js.map +1 -0
- package/dist/components/editor/node-views/wrapped-text-view.d.ts +14 -0
- package/dist/components/editor/node-views/wrapped-text-view.js +46 -0
- package/dist/components/editor/node-views/wrapped-text-view.js.map +1 -0
- package/dist/components/editor/template-editor-toolbar.d.ts +146 -0
- package/dist/components/editor/template-editor-toolbar.js +434 -0
- package/dist/components/editor/template-editor-toolbar.js.map +1 -0
- package/dist/components/editor/template-editor.d.ts +109 -0
- package/dist/components/editor/template-editor.js +662 -0
- package/dist/components/editor/template-editor.js.map +1 -0
- package/dist/components/editor/toolbar-dropdown.d.ts +20 -0
- package/dist/components/editor/toolbar-dropdown.js +88 -0
- package/dist/components/editor/toolbar-dropdown.js.map +1 -0
- package/dist/components/editor/utils/draw-mode.d.ts +55 -0
- package/dist/components/editor/utils/draw-mode.js +79 -0
- package/dist/components/editor/utils/draw-mode.js.map +1 -0
- package/dist/components/editor/utils/insertion.d.ts +11 -0
- package/dist/components/editor/utils/insertion.js +26 -0
- package/dist/components/editor/utils/insertion.js.map +1 -0
- package/dist/components/editor/utils/length-calculator.d.ts +36 -0
- package/dist/components/editor/utils/length-calculator.js +32 -0
- package/dist/components/editor/utils/length-calculator.js.map +1 -0
- package/dist/components/editor/utils/serialization.d.ts +34 -0
- package/dist/components/editor/utils/serialization.js +184 -0
- package/dist/components/editor/utils/serialization.js.map +1 -0
- package/dist/components/editor/utils/stroke-transaction.d.ts +36 -0
- package/dist/components/editor/utils/stroke-transaction.js +57 -0
- package/dist/components/editor/utils/stroke-transaction.js.map +1 -0
- package/dist/components/editor/variable-picker-content.d.ts +130 -0
- package/dist/components/editor/variable-picker-content.js +422 -0
- package/dist/components/editor/variable-picker-content.js.map +1 -0
- package/dist/editor.css +164 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +41 -13
- package/dist/lib/board-colors.d.ts +16 -0
- package/dist/lib/board-colors.js +14 -14
- package/dist/lib/board-colors.js.map +1 -1
- package/dist/lib/use-deps-changed.d.ts +33 -0
- package/dist/lib/use-deps-changed.js +11 -0
- package/dist/lib/use-deps-changed.js.map +1 -0
- package/package.json +50 -2
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Badge as e } from "../../feedback/badge.js";
|
|
3
|
+
import { Text as t } from "../../typography/text.js";
|
|
4
|
+
import { Tooltip as n, TooltipContent as r, TooltipProvider as i, TooltipTrigger as a } from "../../overlays/tooltip.js";
|
|
5
|
+
import { useNodeViewInjection as o } from "./node-view-context.js";
|
|
6
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
|
+
import { NodeViewWrapper as l } from "@tiptap/react";
|
|
8
|
+
//#region src/components/editor/node-views/fill-space-node-view.tsx
|
|
9
|
+
var u = {
|
|
10
|
+
fillSpaceTooltip: "Fill space - expands to fill remaining line width",
|
|
11
|
+
fillSpaceRepeatTooltip: (e) => `Fill space repeating: ${e}`
|
|
12
|
+
};
|
|
13
|
+
function d({ node: d, labels: f }) {
|
|
14
|
+
let p = o(), m = {
|
|
15
|
+
...u,
|
|
16
|
+
...p.labels,
|
|
17
|
+
...f
|
|
18
|
+
}, { repeatChar: h } = d.attrs, g = h && h !== " " ? h : null;
|
|
19
|
+
return /* @__PURE__ */ s(l, {
|
|
20
|
+
as: "span",
|
|
21
|
+
"data-drag-handle": !0,
|
|
22
|
+
style: {
|
|
23
|
+
display: "inline-flex",
|
|
24
|
+
verticalAlign: "baseline",
|
|
25
|
+
whiteSpace: "nowrap"
|
|
26
|
+
},
|
|
27
|
+
children: /* @__PURE__ */ s(i, { children: /* @__PURE__ */ c(n, { children: [/* @__PURE__ */ s(a, {
|
|
28
|
+
asChild: !0,
|
|
29
|
+
children: /* @__PURE__ */ s(e, {
|
|
30
|
+
variant: "success",
|
|
31
|
+
className: "group inline-flex flex-nowrap items-center px-1.5 py-0 border-dashed cursor-grab hover:bg-tag-success/25 mr-0.5 transition-all duration-control",
|
|
32
|
+
children: /* @__PURE__ */ c("span", {
|
|
33
|
+
className: "font-mono text-[11px] leading-none",
|
|
34
|
+
children: ["fill_space", g && `_repeat:${g}`]
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
}), /* @__PURE__ */ s(r, { children: /* @__PURE__ */ s(t, { children: g ? m.fillSpaceRepeatTooltip(g) : m.fillSpaceTooltip }) })] }) })
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { u as DEFAULT_FILL_SPACE_NODE_VIEW_LABELS, d as FillSpaceNodeView };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=fill-space-node-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill-space-node-view.js","names":[],"sources":["../../../../src/components/editor/node-views/fill-space-node-view.tsx"],"mappings":";;;;;;;;AA2BA,IAAa,IAA+D;CAC1E,kBAAkB;CAClB,yBAAyB,MAAS,yBAAyB;AAC7D;AAMA,SAAgB,EAAkB,EAAE,SAAM,aAAkC;CAC1E,IAAM,IAAW,EAAqB,GAChC,IAAI;EAAE,GAAG;EAAqC,GAAG,EAAS;EAAQ,GAAG;CAAO,GAC5E,EAAE,kBAAe,EAAK,OAItB,IAAS,KAAc,MAAe,MAAM,IAAa;CAE/D,OACE,kBAAC,GAAD;EACE,IAAG;EACH,oBAAA;EACA,OAAO;GACL,SAAS;GACT,eAAe;GACf,YAAY;EACd;EAEA,UAAA,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;GAAgB,SAAA;GACd,UAAA,kBAAC,GAAD;IACE,SAAQ;IACR,WAAU;IASV,UAAA,kBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CAAqD,cAAW,KAAU,WAAW,GAAe;;GAC/F,CAAA;EACO,CAAA,GAChB,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UAAO,IAAS,EAAE,uBAAuB,CAAM,IAAI,EAAE,iBAAuB,CAAA,EAC9D,CAAA,CACT,EAAA,CAAA,EACM,CAAA;CACF,CAAA;AAErB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FormulaNodeView — React NodeView for Formula nodes.
|
|
3
|
+
*
|
|
4
|
+
* Renders as an amber badge pill showing ƒ + truncated expression preview.
|
|
5
|
+
* Clicking opens a centered modal FormulaEditorPanel via a portal into
|
|
6
|
+
* document.body (escapes the ProseMirror container).
|
|
7
|
+
*
|
|
8
|
+
* The modal does NOT close on backdrop click — only on Esc / Done / Cancel.
|
|
9
|
+
*/
|
|
10
|
+
import type { ReactNodeViewProps } from "@tiptap/react";
|
|
11
|
+
import { type ReactNode } from "react";
|
|
12
|
+
export interface FormulaNodeViewLabels {
|
|
13
|
+
/** Pill preview text for a formula that has no expression yet. */
|
|
14
|
+
newFormula: string;
|
|
15
|
+
/** Hint under the tooltip's expression preview. */
|
|
16
|
+
clickToEditFormula: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const DEFAULT_FORMULA_NODE_VIEW_LABELS: FormulaNodeViewLabels;
|
|
19
|
+
/** What the node view hands the formula-editor slot when the modal opens. */
|
|
20
|
+
export interface FormulaEditorSlotContext {
|
|
21
|
+
/** The current expression, without the `{{= }}` wrapper. */
|
|
22
|
+
initialExpr: string;
|
|
23
|
+
/** Commit a new expression and close the modal. */
|
|
24
|
+
onConfirm: (expression: string) => void;
|
|
25
|
+
/** Close the modal, deleting the node if it never got an expression. */
|
|
26
|
+
onCancel: () => void;
|
|
27
|
+
}
|
|
28
|
+
export type FormulaNodeViewProps = ReactNodeViewProps & {
|
|
29
|
+
labels?: Partial<FormulaNodeViewLabels>;
|
|
30
|
+
/**
|
|
31
|
+
* Renders the modal's contents. The app supplies this so the panel arrives
|
|
32
|
+
* with its own labels and its already-resolved data (formula functions,
|
|
33
|
+
* template variables) — a node view has no call site to thread those through
|
|
34
|
+
* and must not fetch them itself. Omitted, the lazily-imported
|
|
35
|
+
* `FormulaEditorPanel` is rendered with its own defaults.
|
|
36
|
+
*/
|
|
37
|
+
renderFormulaEditor?: (ctx: FormulaEditorSlotContext) => ReactNode;
|
|
38
|
+
};
|
|
39
|
+
export declare function FormulaNodeView({ node, updateAttributes, deleteNode, labels, renderFormulaEditor, }: FormulaNodeViewProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Badge as e } from "../../feedback/badge.js";
|
|
3
|
+
import { Box as t } from "../../layout/box.js";
|
|
4
|
+
import { Flex as n } from "../../layout/flex.js";
|
|
5
|
+
import { Skeleton as r } from "../../feedback/skeleton.js";
|
|
6
|
+
import { Text as i } from "../../typography/text.js";
|
|
7
|
+
import { Tooltip as a, TooltipContent as o, TooltipProvider as s, TooltipTrigger as c } from "../../overlays/tooltip.js";
|
|
8
|
+
import { useNodeViewInjection as l } from "./node-view-context.js";
|
|
9
|
+
import { SquareFunction as u } from "lucide-react";
|
|
10
|
+
import { Suspense as d, lazy as f, useCallback as p, useEffect as m, useRef as h, useState as g } from "react";
|
|
11
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
12
|
+
import { NodeViewWrapper as y } from "@tiptap/react";
|
|
13
|
+
import { createPortal as b } from "react-dom";
|
|
14
|
+
//#region src/components/editor/node-views/formula-node-view.tsx
|
|
15
|
+
var x = f(() => import("../formula/formula-editor-panel.js").then((e) => ({ default: e.FormulaEditorPanel }))), S = {
|
|
16
|
+
newFormula: "new formula",
|
|
17
|
+
clickToEditFormula: "Click to edit formula"
|
|
18
|
+
};
|
|
19
|
+
function C({ node: f, updateAttributes: C, deleteNode: w, labels: T, renderFormulaEditor: E }) {
|
|
20
|
+
let D = l(), O = {
|
|
21
|
+
...S,
|
|
22
|
+
...D.labels,
|
|
23
|
+
...T
|
|
24
|
+
}, k = E ?? D.renderFormulaEditor, { expression: A, autoOpen: j } = f.attrs, [M, N] = g(!1), P = h(j), F = A.length > 0 ? A.length > 20 ? A.slice(0, 20) + "…" : A : O.newFormula;
|
|
25
|
+
m(() => {
|
|
26
|
+
if (!P.current) return;
|
|
27
|
+
let e = requestAnimationFrame(() => N(!0));
|
|
28
|
+
return () => cancelAnimationFrame(e);
|
|
29
|
+
}, []);
|
|
30
|
+
let I = p((e) => {
|
|
31
|
+
e.preventDefault(), e.stopPropagation(), N(!0);
|
|
32
|
+
}, []);
|
|
33
|
+
m(() => {
|
|
34
|
+
if (!M) return;
|
|
35
|
+
let e = (e) => {
|
|
36
|
+
e.key === "Escape" && (e.stopPropagation(), N(!1), f.attrs.expression === "" && w());
|
|
37
|
+
};
|
|
38
|
+
return document.addEventListener("keydown", e, !0), () => document.removeEventListener("keydown", e, !0);
|
|
39
|
+
}, [
|
|
40
|
+
M,
|
|
41
|
+
f.attrs.expression,
|
|
42
|
+
w
|
|
43
|
+
]);
|
|
44
|
+
let L = (e) => {
|
|
45
|
+
C({ expression: e }), N(!1);
|
|
46
|
+
}, R = () => {
|
|
47
|
+
N(!1), f.attrs.expression === "" && w();
|
|
48
|
+
};
|
|
49
|
+
return /* @__PURE__ */ v(y, {
|
|
50
|
+
as: "span",
|
|
51
|
+
"data-drag-handle": !0,
|
|
52
|
+
style: {
|
|
53
|
+
display: "inline-flex",
|
|
54
|
+
verticalAlign: "baseline",
|
|
55
|
+
whiteSpace: "nowrap"
|
|
56
|
+
},
|
|
57
|
+
children: [/* @__PURE__ */ _(s, { children: /* @__PURE__ */ v(a, { children: [/* @__PURE__ */ _(c, {
|
|
58
|
+
asChild: !0,
|
|
59
|
+
children: /* @__PURE__ */ v(e, {
|
|
60
|
+
variant: "formula",
|
|
61
|
+
className: "inline-flex flex-nowrap items-center gap-1 px-1.5 py-0 border-dashed cursor-pointer hover:bg-amber-500/20 mr-0.5 transition-all duration-control active:scale-95",
|
|
62
|
+
onMouseDown: I,
|
|
63
|
+
role: "button",
|
|
64
|
+
tabIndex: 0,
|
|
65
|
+
onKeyDown: (e) => {
|
|
66
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), I(e));
|
|
67
|
+
},
|
|
68
|
+
children: [/* @__PURE__ */ _(u, { className: "w-2.5 h-2.5 flex-shrink-0" }), /* @__PURE__ */ _("span", {
|
|
69
|
+
className: "font-mono text-[11px] leading-none",
|
|
70
|
+
children: F
|
|
71
|
+
})]
|
|
72
|
+
})
|
|
73
|
+
}), /* @__PURE__ */ v(o, { children: [/* @__PURE__ */ _(i, {
|
|
74
|
+
size: "xs",
|
|
75
|
+
className: "font-mono",
|
|
76
|
+
children: "{{= " + A + " }}"
|
|
77
|
+
}), /* @__PURE__ */ _(i, {
|
|
78
|
+
size: "xs",
|
|
79
|
+
tone: "muted",
|
|
80
|
+
className: "mt-0.5",
|
|
81
|
+
children: O.clickToEditFormula
|
|
82
|
+
})] })] }) }), M && b(/* @__PURE__ */ v(n, {
|
|
83
|
+
align: "center",
|
|
84
|
+
justify: "center",
|
|
85
|
+
className: "fixed inset-0 z-[999] p-4",
|
|
86
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
87
|
+
children: [/* @__PURE__ */ _(t, { className: "absolute inset-0 bg-black/60 backdrop-blur-sm" }), /* @__PURE__ */ _(t, {
|
|
88
|
+
className: "relative rounded-lg border border-border bg-popover shadow-2xl max-h-[90vh] overflow-y-auto w-full max-w-[min(660px,90vw)]",
|
|
89
|
+
children: /* @__PURE__ */ _(d, {
|
|
90
|
+
fallback: /* @__PURE__ */ _(r, { className: "h-64 w-full" }),
|
|
91
|
+
children: k ? k({
|
|
92
|
+
initialExpr: A,
|
|
93
|
+
onConfirm: L,
|
|
94
|
+
onCancel: R
|
|
95
|
+
}) : /* @__PURE__ */ _(x, {
|
|
96
|
+
mode: "edit",
|
|
97
|
+
initialExpr: A,
|
|
98
|
+
onConfirm: L,
|
|
99
|
+
onCancel: R
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
})]
|
|
103
|
+
}), document.body)]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
export { S as DEFAULT_FORMULA_NODE_VIEW_LABELS, C as FormulaNodeView };
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=formula-node-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formula-node-view.js","names":[],"sources":["../../../../src/components/editor/node-views/formula-node-view.tsx"],"mappings":"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"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injection channel for the five React NodeViews.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS EXISTS — node views are not rendered by a parent component. The
|
|
5
|
+
* extensions instantiate them as `ReactNodeViewRenderer(XNodeView)`, so TipTap
|
|
6
|
+
* decides the props and only ever passes `ReactNodeViewProps`. There is no call
|
|
7
|
+
* site at which an app could hand a node view its `labels`, which is a problem
|
|
8
|
+
* for a package with no i18n library: every string in a node view would be
|
|
9
|
+
* permanently English.
|
|
10
|
+
*
|
|
11
|
+
* React context is the one channel that reaches them. TipTap renders React node
|
|
12
|
+
* views through portals anchored in the tree of the component that owns the
|
|
13
|
+
* editor, so a provider wrapping `<EditorContent>` is an ancestor of every node
|
|
14
|
+
* view — the same mechanism that makes `useCurrentEditor()` work inside one.
|
|
15
|
+
*
|
|
16
|
+
* Every node view still takes its own optional `labels` prop and still defaults
|
|
17
|
+
* to English, so this is purely additive:
|
|
18
|
+
*
|
|
19
|
+
* explicit `labels` prop > provider value > English defaults
|
|
20
|
+
*
|
|
21
|
+
* The prop is what a story or a unit test uses (it needs no provider); the
|
|
22
|
+
* provider is what the editor component uses to push app translations down to
|
|
23
|
+
* nodes it never renders itself.
|
|
24
|
+
*/
|
|
25
|
+
import { type ReactNode } from "react";
|
|
26
|
+
import type { ColorTileNodeViewLabels } from "./color-tile-node-view";
|
|
27
|
+
import type { FillSpaceNodeViewLabels } from "./fill-space-node-view";
|
|
28
|
+
import type { FormulaEditorSlotContext, FormulaNodeViewLabels } from "./formula-node-view";
|
|
29
|
+
import type { VariableNodeViewLabels } from "./variable-node-view";
|
|
30
|
+
import type { WrappedTextViewLabels } from "./wrapped-text-view";
|
|
31
|
+
/**
|
|
32
|
+
* Every node-view label in one flat bag. The keys are unique across the five
|
|
33
|
+
* components and match the FiestaBoard app's translation keys 1:1, so the app
|
|
34
|
+
* can map its message catalog across mechanically.
|
|
35
|
+
*/
|
|
36
|
+
export interface NodeViewLabels extends ColorTileNodeViewLabels, FillSpaceNodeViewLabels, FormulaNodeViewLabels, VariableNodeViewLabels, WrappedTextViewLabels {
|
|
37
|
+
}
|
|
38
|
+
export interface NodeViewInjection {
|
|
39
|
+
labels?: Partial<NodeViewLabels>;
|
|
40
|
+
/**
|
|
41
|
+
* Renders the formula editor shown when a formula pill is clicked. Supplied
|
|
42
|
+
* by the app so the panel arrives with its data props (formula functions,
|
|
43
|
+
* template variables) already resolved — the node view cannot fetch and must
|
|
44
|
+
* not decide what the panel needs. Omitted, the node view falls back to the
|
|
45
|
+
* lazily-imported `FormulaEditorPanel`.
|
|
46
|
+
*/
|
|
47
|
+
renderFormulaEditor?: (ctx: FormulaEditorSlotContext) => ReactNode;
|
|
48
|
+
}
|
|
49
|
+
export interface NodeViewInjectionProviderProps extends NodeViewInjection {
|
|
50
|
+
children?: ReactNode;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Wrap `<EditorContent>` with this to push labels and slots into node views.
|
|
54
|
+
* Rendering it is optional: without it every node view uses English defaults.
|
|
55
|
+
*/
|
|
56
|
+
export declare function NodeViewInjectionProvider({ labels, renderFormulaEditor, children }: NodeViewInjectionProviderProps): import("react").JSX.Element;
|
|
57
|
+
/** Reads the injected labels/slots. Returns an empty bag when unprovided. */
|
|
58
|
+
export declare function useNodeViewInjection(): NodeViewInjection;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext as e, useContext as t, useMemo as n } from "react";
|
|
3
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/editor/node-views/node-view-context.tsx
|
|
5
|
+
var i = Object.freeze({}), a = e(i);
|
|
6
|
+
function o({ labels: e, renderFormulaEditor: t, children: i }) {
|
|
7
|
+
let o = n(() => ({
|
|
8
|
+
labels: e,
|
|
9
|
+
renderFormulaEditor: t
|
|
10
|
+
}), [e, t]);
|
|
11
|
+
return /* @__PURE__ */ r(a.Provider, {
|
|
12
|
+
value: o,
|
|
13
|
+
children: i
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function s() {
|
|
17
|
+
return t(a);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { o as NodeViewInjectionProvider, s as useNodeViewInjection };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=node-view-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-view-context.js","names":[],"sources":["../../../../src/components/editor/node-views/node-view-context.tsx"],"mappings":";;;;AA6DA,IAAM,IAA2B,OAAO,OAAO,CAAC,CAAC,GAE3C,IAA2B,EAAiC,CAAK;AAUvE,SAAgB,EAA0B,EAAE,WAAQ,wBAAqB,eAA4C;CACnH,IAAM,IAAQ,SAAe;EAAE;EAAQ;CAAoB,IAAI,CAAC,GAAQ,CAAmB,CAAC;CAC5F,OAAO,kBAAC,EAAyB,UAA1B;EAA0C;EAAQ;CAA4C,CAAA;AACvG;AAGA,SAAgB,IAA0C;CACxD,OAAO,EAAW,CAAwB;AAC5C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React NodeView for Variable nodes
|
|
3
|
+
* Displays {{plugin.field}} as an interactive badge with filters
|
|
4
|
+
*/
|
|
5
|
+
import type { ReactNodeViewProps } from "@tiptap/react";
|
|
6
|
+
export interface VariableNodeViewLabels {
|
|
7
|
+
/** Tooltip on a filter chip. `filter` is already formatted as `name:arg`. */
|
|
8
|
+
variableFilterTooltip: (filter: string) => string;
|
|
9
|
+
/** Tooltip on the truncation hint shown when the variable declares a max length. */
|
|
10
|
+
variableMaxLengthTooltip: (maxLength: number) => string;
|
|
11
|
+
}
|
|
12
|
+
export declare const DEFAULT_VARIABLE_NODE_VIEW_LABELS: VariableNodeViewLabels;
|
|
13
|
+
export type VariableNodeViewProps = ReactNodeViewProps & {
|
|
14
|
+
labels?: Partial<VariableNodeViewLabels>;
|
|
15
|
+
};
|
|
16
|
+
export declare function VariableNodeView({ node, labels }: VariableNodeViewProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Badge as e } from "../../feedback/badge.js";
|
|
3
|
+
import { Text as t } from "../../typography/text.js";
|
|
4
|
+
import { Tooltip as n, TooltipContent as r, TooltipProvider as i, TooltipTrigger as a } from "../../overlays/tooltip.js";
|
|
5
|
+
import { useNodeViewInjection as o } from "./node-view-context.js";
|
|
6
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
|
+
import { NodeViewWrapper as l } from "@tiptap/react";
|
|
8
|
+
//#region src/components/editor/node-views/variable-node-view.tsx
|
|
9
|
+
var u = {
|
|
10
|
+
variableFilterTooltip: (e) => `Filter: ${e}`,
|
|
11
|
+
variableMaxLengthTooltip: (e) => `Max length: ${e} characters`
|
|
12
|
+
};
|
|
13
|
+
function d({ node: d, labels: f }) {
|
|
14
|
+
let p = o(), m = {
|
|
15
|
+
...u,
|
|
16
|
+
...p.labels,
|
|
17
|
+
...f
|
|
18
|
+
}, { pluginId: h, field: g, filters: _, maxLength: v } = d.attrs;
|
|
19
|
+
return /* @__PURE__ */ s(l, {
|
|
20
|
+
as: "span",
|
|
21
|
+
"data-drag-handle": !0,
|
|
22
|
+
style: {
|
|
23
|
+
display: "inline-flex",
|
|
24
|
+
verticalAlign: "baseline",
|
|
25
|
+
whiteSpace: "nowrap"
|
|
26
|
+
},
|
|
27
|
+
children: /* @__PURE__ */ s(i, { children: /* @__PURE__ */ c(e, {
|
|
28
|
+
variant: "variable",
|
|
29
|
+
className: "group inline-flex flex-nowrap items-center gap-1 px-1.5 py-0 border-dashed cursor-grab hover:bg-tag-variable/20 active:cursor-grabbing mr-0.5 transition-all duration-control",
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ c("span", {
|
|
32
|
+
className: "font-mono text-[11px] leading-none",
|
|
33
|
+
children: [
|
|
34
|
+
h,
|
|
35
|
+
".",
|
|
36
|
+
g
|
|
37
|
+
]
|
|
38
|
+
}),
|
|
39
|
+
_ && _.length > 0 && /* @__PURE__ */ s("span", {
|
|
40
|
+
className: "inline-flex items-center gap-0.5",
|
|
41
|
+
children: _.map((e, i) => /* @__PURE__ */ c(n, { children: [/* @__PURE__ */ s(a, {
|
|
42
|
+
asChild: !0,
|
|
43
|
+
children: /* @__PURE__ */ c("span", {
|
|
44
|
+
className: "inline-flex items-center px-1 rounded-sm text-[10px] bg-tag-variable/20 leading-none",
|
|
45
|
+
children: [e.name, e.arg && `:${e.arg}`]
|
|
46
|
+
})
|
|
47
|
+
}), /* @__PURE__ */ s(r, { children: /* @__PURE__ */ s(t, { children: m.variableFilterTooltip(`${e.name}${e.arg ? `:${e.arg}` : ""}`) }) })] }, i))
|
|
48
|
+
}),
|
|
49
|
+
v && /* @__PURE__ */ c(n, { children: [/* @__PURE__ */ s(a, {
|
|
50
|
+
asChild: !0,
|
|
51
|
+
children: /* @__PURE__ */ c("span", {
|
|
52
|
+
className: "hidden group-hover:inline text-[10px] leading-none",
|
|
53
|
+
children: ["~", v]
|
|
54
|
+
})
|
|
55
|
+
}), /* @__PURE__ */ s(r, { children: /* @__PURE__ */ s(t, { children: m.variableMaxLengthTooltip(v) }) })] })
|
|
56
|
+
]
|
|
57
|
+
}) })
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { u as DEFAULT_VARIABLE_NODE_VIEW_LABELS, d as VariableNodeView };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=variable-node-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable-node-view.js","names":[],"sources":["../../../../src/components/editor/node-views/variable-node-view.tsx"],"mappings":";;;;;;;;AA6BA,IAAa,IAA4D;CACvE,wBAAwB,MAAW,WAAW;CAC9C,2BAA2B,MAAc,eAAe,EAAU;AACpE;AAMA,SAAgB,EAAiB,EAAE,SAAM,aAAiC;CACxE,IAAM,IAAW,EAAqB,GAChC,IAAI;EAAE,GAAG;EAAmC,GAAG,EAAS;EAAQ,GAAG;CAAO,GAC1E,EAAE,aAAU,UAAO,YAAS,iBAAc,EAAK;CAErD,OACE,kBAAC,GAAD;EACE,IAAG;EACH,oBAAA;EACA,OAAO;GACL,SAAS;GACT,eAAe;GACf,YAAY;EACd;EAEA,UAAA,kBAAC,GAAD,EAAA,UAME,kBAAC,GAAD;GACE,SAAQ;GACR,WAAU;GAFZ,UAAA;IASE,kBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA;MACG;MAAS;MAAE;KACR;;IAEL,KAAW,EAAQ,SAAS,KAG3B,kBAAC,QAAD;KAAM,WAAU;KACb,UAAA,EAAQ,KAAK,GAAQ,MACpB,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;MAAgB,SAAA;MAId,UAAA,kBAAC,QAAD;OAAM,WAAU;OAAhB,UAAA,CACG,EAAO,MACP,EAAO,OAAO,IAAI,EAAO,KACtB;;KACQ,CAAA,GAChB,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UAAO,EAAE,sBAAsB,GAAG,EAAO,OAAO,EAAO,MAAM,IAAI,EAAO,QAAQ,IAAI,EAAQ,CAAA,EAC9E,CAAA,CACT,EAAA,GAbK,CAaL,CACV;IACG,CAAA;IAGP,KACC,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;KAAgB,SAAA;KAGd,UAAA,kBAAC,QAAD;MAAM,WAAU;MAAhB,UAAA,CAAqE,KAAE,CAAgB;;IACzE,CAAA,GAChB,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UAAO,EAAE,yBAAyB,CAAS,EAAQ,CAAA,EACrC,CAAA,CACT,EAAA,CAAA;GAEN;EACQ,CAAA,EAAA,CAAA;CACF,CAAA;AAErB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React NodeView for Wrapped Text nodes
|
|
3
|
+
* Displays text that will be wrapped with visual indicator
|
|
4
|
+
*/
|
|
5
|
+
import type { ReactNodeViewProps } from "@tiptap/react";
|
|
6
|
+
export interface WrappedTextViewLabels {
|
|
7
|
+
/** Accessible name for the button that removes the wrapped-text node. */
|
|
8
|
+
removeWrappedTextAriaLabel: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const DEFAULT_WRAPPED_TEXT_VIEW_LABELS: WrappedTextViewLabels;
|
|
11
|
+
export type WrappedTextViewProps = ReactNodeViewProps & {
|
|
12
|
+
labels?: Partial<WrappedTextViewLabels>;
|
|
13
|
+
};
|
|
14
|
+
export declare function WrappedTextView({ node, deleteNode, labels }: WrappedTextViewProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../../lib/utils.js";
|
|
3
|
+
import { useNodeViewInjection as t } from "./node-view-context.js";
|
|
4
|
+
import { WrapText as n, X as r } from "lucide-react";
|
|
5
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
+
import { NodeViewWrapper as o } from "@tiptap/react";
|
|
7
|
+
//#region src/components/editor/node-views/wrapped-text-view.tsx
|
|
8
|
+
var s = { removeWrappedTextAriaLabel: "Remove wrapped text" };
|
|
9
|
+
function c({ node: c, deleteNode: l, labels: u }) {
|
|
10
|
+
let d = t(), f = {
|
|
11
|
+
...s,
|
|
12
|
+
...d.labels,
|
|
13
|
+
...u
|
|
14
|
+
}, { text: p } = c.attrs;
|
|
15
|
+
return /* @__PURE__ */ a(o, {
|
|
16
|
+
as: "span",
|
|
17
|
+
className: e("inline-block align-middle rounded-md px-2 py-0.5 text-xs font-medium cursor-grab", "border transition-all duration-control", "bg-warning/15 border-warning/30 text-warning", "hover:bg-warning/20", "active:cursor-grabbing", "max-h-[1.2rem] h-auto", "mr-0.5"),
|
|
18
|
+
"data-drag-handle": !0,
|
|
19
|
+
style: {
|
|
20
|
+
display: "inline-block",
|
|
21
|
+
verticalAlign: "middle",
|
|
22
|
+
whiteSpace: "nowrap"
|
|
23
|
+
},
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ i(n, { className: "w-3 h-3 inline-block align-middle" }),
|
|
26
|
+
/* @__PURE__ */ i("span", {
|
|
27
|
+
className: "font-mono text-[11px] inline-block align-middle ml-1",
|
|
28
|
+
children: p
|
|
29
|
+
}),
|
|
30
|
+
/* @__PURE__ */ i("button", {
|
|
31
|
+
type: "button",
|
|
32
|
+
onClick: (e) => {
|
|
33
|
+
e.preventDefault(), e.stopPropagation(), l();
|
|
34
|
+
},
|
|
35
|
+
className: "rounded-full hover:bg-black/10 dark:hover:bg-white/10 p-0.5 -mr-1 ml-0.5 transition-colors",
|
|
36
|
+
tabIndex: -1,
|
|
37
|
+
"aria-label": f.removeWrappedTextAriaLabel,
|
|
38
|
+
children: /* @__PURE__ */ i(r, { className: "w-3 h-3" })
|
|
39
|
+
})
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { s as DEFAULT_WRAPPED_TEXT_VIEW_LABELS, c as WrappedTextView };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=wrapped-text-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapped-text-view.js","names":[],"sources":["../../../../src/components/editor/node-views/wrapped-text-view.tsx"],"mappings":";;;;;;;AAuBA,IAAa,IAA0D,EACrE,4BAA4B,sBAC9B;AAMA,SAAgB,EAAgB,EAAE,SAAM,eAAY,aAAgC;CAClF,IAAM,IAAW,EAAqB,GAChC,IAAI;EAAE,GAAG;EAAkC,GAAG,EAAS;EAAQ,GAAG;CAAO,GACzE,EAAE,YAAS,EAAK;CAEtB,OACE,kBAAC,GAAD;EACE,IAAG;EACH,WAAW,EACT,oFACA,0CACA,gDACA,uBACA,0BACA,yBACA,QACF;EACA,oBAAA;EACA,OAAO;GACL,SAAS;GACT,eAAe;GACf,YAAY;EACd;EAhBF,UAAA;GAmBE,kBAAC,GAAD,EAAU,WAAU,oCAAqC,CAAA;GAMzD,kBAAC,QAAD;IAAM,WAAU;IAAwD,UAAA;GAAW,CAAA;GAMnF,kBAAC,UAAD;IACE,MAAK;IACL,UAAU,MAAM;KAGd,AAFA,EAAE,eAAe,GACjB,EAAE,gBAAgB,GAClB,EAAW;IACb;IACA,WAAU;IACV,UAAU;IACV,cAAY,EAAE;IAEd,UAAA,kBAAC,GAAD,EAAG,WAAU,UAAW,CAAA;GAClB,CAAA;EACO;;AAErB"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { Editor } from "@tiptap/react";
|
|
2
|
+
import { type ComponentProps, type ReactNode } from "react";
|
|
3
|
+
import { type BoardColorName } from "../../lib/board-colors";
|
|
4
|
+
import { type ColorPickerLabels } from "./color-picker-content";
|
|
5
|
+
import type { DeviceType } from "./constants";
|
|
6
|
+
import { type FormattingPickerLabels } from "./formatting-picker-content";
|
|
7
|
+
import type { LineAlignment } from "./template-editor";
|
|
8
|
+
import type { DrawBrush } from "./utils/draw-mode";
|
|
9
|
+
import type { PluginDisplayData, PluginManifest, TemplateVariables, VariablePickerLabels } from "./variable-picker-content";
|
|
10
|
+
declare const VariablePickerContent: import("react").LazyExoticComponent<typeof import("./variable-picker-content").VariablePickerContent>;
|
|
11
|
+
/** One entry of the backend's `formatting` map: a snippet plus its help text. */
|
|
12
|
+
export interface FormattingVariable {
|
|
13
|
+
syntax: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* What the toolbar reads from the app's already-fetched `/templates/variables`
|
|
18
|
+
* payload: the variable picker's slice (forwarded to it verbatim) plus the two
|
|
19
|
+
* maps that decide whether the Colors and Formatting dropdowns exist at all.
|
|
20
|
+
*
|
|
21
|
+
* Narrowed and structural, like the picker's own types, so the app's full
|
|
22
|
+
* `getTemplateVariables` response satisfies it without a cast. Named for the
|
|
23
|
+
* toolbar rather than re-declaring `TemplateVariables`, which
|
|
24
|
+
* `variable-picker-content` already owns.
|
|
25
|
+
*/
|
|
26
|
+
export interface ToolbarTemplateVariables extends TemplateVariables {
|
|
27
|
+
/** Color name → board code. Presence is what enables the Colors dropdown. */
|
|
28
|
+
colors?: Record<string, number>;
|
|
29
|
+
formatting?: Record<string, FormattingVariable>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* What the toolbar hands an injected entity picker.
|
|
33
|
+
*
|
|
34
|
+
* The picker itself (Home Assistant's, or any other plugin's) lives in the
|
|
35
|
+
* host app — it is an API-backed dialog and this package neither fetches nor
|
|
36
|
+
* knows about plugins. The toolbar still owns the trigger button, the open
|
|
37
|
+
* state, and the caret-timing dance around insertion, so the slot is a render
|
|
38
|
+
* prop rather than a bare node: those three things cannot be handed over
|
|
39
|
+
* without reimplementing them in every host.
|
|
40
|
+
*/
|
|
41
|
+
export interface EntityPickerSlotContext {
|
|
42
|
+
/** True while the toolbar's entity button has asked for the picker. */
|
|
43
|
+
open: boolean;
|
|
44
|
+
/** Call when the picker dismisses itself. */
|
|
45
|
+
onClose: () => void;
|
|
46
|
+
/** Call with the template string to insert, e.g. `{{home_assistant.porch_temp}}`. */
|
|
47
|
+
onSelect: (variable: string) => void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Every user-visible string in the toolbar. This package has no i18n runtime:
|
|
51
|
+
* hosts that localize pass a translated object, everyone else gets English.
|
|
52
|
+
*
|
|
53
|
+
* Keys mirror the FiestaBoard app's `templateEditor` message-catalog keys 1:1
|
|
54
|
+
* so the app can map its catalog across mechanically. This interface covers the
|
|
55
|
+
* toolbar's slice of that namespace; the editor and color picker own theirs.
|
|
56
|
+
*/
|
|
57
|
+
export interface TemplateEditorToolbarLabels {
|
|
58
|
+
/** Draw-mode toggle, accessible name and tooltip, while drawing is OFF. */
|
|
59
|
+
drawMode: string;
|
|
60
|
+
/** …and while it is ON (the button then exits draw mode). */
|
|
61
|
+
drawModeActive: string;
|
|
62
|
+
undo: string;
|
|
63
|
+
/** Accessible name for the undo button — the tooltip adds the shortcut. */
|
|
64
|
+
undoAriaLabel: string;
|
|
65
|
+
redo: string;
|
|
66
|
+
redoAriaLabel: string;
|
|
67
|
+
/**
|
|
68
|
+
* Accessible names for the draw-mode color swatches, keyed by palette color.
|
|
69
|
+
* Supply all eight; omitted colors fall back to the English default.
|
|
70
|
+
*/
|
|
71
|
+
drawColors: Record<BoardColorName, string>;
|
|
72
|
+
drawEraser: string;
|
|
73
|
+
/** Label for the stamp-character dropdown. */
|
|
74
|
+
drawCharacter: string;
|
|
75
|
+
cut: string;
|
|
76
|
+
cutAriaLabel: string;
|
|
77
|
+
copy: string;
|
|
78
|
+
copyAriaLabel: string;
|
|
79
|
+
paste: string;
|
|
80
|
+
pasteAriaLabel: string;
|
|
81
|
+
variables: string;
|
|
82
|
+
/** Accessible name for the Variables button when there are none to insert. */
|
|
83
|
+
variablesNoVarsAvailable: string;
|
|
84
|
+
/** Tooltip explaining why the Variables button is disabled. */
|
|
85
|
+
noVariablesAvailable: string;
|
|
86
|
+
/** Label for the injected entity picker's trigger button. */
|
|
87
|
+
homeAssistantEntities: string;
|
|
88
|
+
colors: string;
|
|
89
|
+
formatting: string;
|
|
90
|
+
insertFormula: string;
|
|
91
|
+
/** Accessible name for the wrap toggle (constant); the tooltip states the effect. */
|
|
92
|
+
toggleWrap: string;
|
|
93
|
+
enableWrap: string;
|
|
94
|
+
disableWrap: string;
|
|
95
|
+
alignLeft: string;
|
|
96
|
+
alignCenter: string;
|
|
97
|
+
alignRight: string;
|
|
98
|
+
/** Accessible name for the sync-from-board button. */
|
|
99
|
+
syncFromBoard: string;
|
|
100
|
+
syncFromBoardTooltip: string;
|
|
101
|
+
}
|
|
102
|
+
export declare const DEFAULT_TEMPLATE_EDITOR_TOOLBAR_LABELS: TemplateEditorToolbarLabels;
|
|
103
|
+
export interface TemplateEditorToolbarProps {
|
|
104
|
+
editor: Editor | null;
|
|
105
|
+
currentAlignment?: LineAlignment;
|
|
106
|
+
currentWrapEnabled?: boolean;
|
|
107
|
+
onAlignmentChange?: (alignment: LineAlignment) => void;
|
|
108
|
+
onWrapToggle?: () => void;
|
|
109
|
+
className?: string;
|
|
110
|
+
deviceType?: DeviceType;
|
|
111
|
+
onSyncFromBoard?: () => void;
|
|
112
|
+
syncFromBoardPending?: boolean;
|
|
113
|
+
drawMode?: boolean;
|
|
114
|
+
onDrawModeToggle?: () => void;
|
|
115
|
+
drawBrush?: DrawBrush;
|
|
116
|
+
onDrawBrushChange?: (brush: DrawBrush) => void;
|
|
117
|
+
/**
|
|
118
|
+
* Resolved template variables. Absent means "nothing available yet": the
|
|
119
|
+
* Variables button renders disabled and the colors/formatting dropdowns are
|
|
120
|
+
* omitted entirely, exactly as when the backend reports an empty catalog.
|
|
121
|
+
*/
|
|
122
|
+
templateVariables?: ToolbarTemplateVariables;
|
|
123
|
+
/** True while the host is still fetching `templateVariables`. */
|
|
124
|
+
isLoadingVariables?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Forwarded verbatim to the variable picker, which owns these contracts. The
|
|
127
|
+
* toolbar never reads them; see `variable-picker-content` for what each does.
|
|
128
|
+
*/
|
|
129
|
+
pluginManifests?: Record<string, PluginManifest | undefined>;
|
|
130
|
+
isLoadingManifests?: boolean;
|
|
131
|
+
pluginDisplayData?: PluginDisplayData;
|
|
132
|
+
resolveIcon?: ComponentProps<typeof VariablePickerContent>["resolveIcon"];
|
|
133
|
+
/**
|
|
134
|
+
* Renders the host's entity picker dialog. Omit it (or leave the
|
|
135
|
+
* `home_assistant` plugin uninstalled) and neither the button nor the dialog
|
|
136
|
+
* appears — never a placeholder.
|
|
137
|
+
*/
|
|
138
|
+
entityPickerSlot?: (ctx: EntityPickerSlotContext) => ReactNode;
|
|
139
|
+
labels?: Partial<TemplateEditorToolbarLabels>;
|
|
140
|
+
/** Labels for the nested pickers, each passed straight through to its owner. */
|
|
141
|
+
variablePickerLabels?: Partial<VariablePickerLabels>;
|
|
142
|
+
colorPickerLabels?: Partial<ColorPickerLabels>;
|
|
143
|
+
formattingPickerLabels?: Partial<FormattingPickerLabels>;
|
|
144
|
+
}
|
|
145
|
+
export declare function TemplateEditorToolbar({ editor, currentAlignment, currentWrapEnabled, onAlignmentChange, onWrapToggle, className, deviceType, onSyncFromBoard, syncFromBoardPending, drawMode, onDrawModeToggle, drawBrush, onDrawBrushChange, templateVariables, isLoadingVariables, pluginManifests, isLoadingManifests, pluginDisplayData, resolveIcon, entityPickerSlot, labels, variablePickerLabels, colorPickerLabels, formattingPickerLabels, }: TemplateEditorToolbarProps): import("react").JSX.Element;
|
|
146
|
+
export {};
|