@cosmicdrift/kumiko-bundled-features 0.417.0 → 0.419.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/agent-tools/api-docs/schema-fields.js +9 -0
- package/dist/auth-email-password/index.d.ts +2 -1
- package/dist/auth-email-password/index.js +2 -1
- package/dist/auth-email-password/signup-activation.js +2 -1
- package/dist/auth-email-password/signup-token-store.d.ts +1 -6
- package/dist/auth-email-password/signup-token-store.js +0 -5
- package/dist/cap-counter/stock-cap-guard.d.ts +9 -2
- package/dist/cap-counter/stock-cap-guard.js +9 -11
- package/dist/document-ingest-foundation/feature.js +5 -1
- package/dist/document-ingest-foundation/report-ingest-progress.js +19 -6
- package/dist/signature/entity.d.ts +8 -6
- package/dist/signature/entity.js +3 -1
- package/dist/signature/feature.js +11 -4
- package/dist/signature/handlers/lifecycle.write.d.ts +9 -0
- package/dist/signature/handlers/lifecycle.write.js +23 -1
- package/dist/signature/handlers/request.write.d.ts +1 -1
- package/dist/signature/i18n.js +1 -0
- package/dist/signature/list-cursor-seal.d.ts +3 -0
- package/dist/signature/list-cursor-seal.js +44 -0
- package/dist/signature/options.d.ts +2 -2
- package/dist/signature/payloads.d.ts +17 -1
- package/dist/signature/payloads.js +11 -2
- package/dist/signature/png.js +23 -3
- package/dist/signature/subject-queries.d.ts +1 -1
- package/dist/signature/subject-queries.js +30 -8
- package/dist/signature/sweep.js +26 -9
- package/dist/signature/web/constants.d.ts +9 -0
- package/dist/signature/web/constants.js +8 -0
- package/dist/subscription-stripe/plugin-methods.js +2 -0
- package/dist/subscription-stripe/verify-webhook.js +17 -16
- package/dist/template-resolver/compile-document-body.js +3 -6
- package/dist/template-resolver/compile-document-styles.d.ts +3 -0
- package/dist/template-resolver/compile-document-styles.js +84 -0
- package/dist/template-resolver/document-frames.d.ts +3 -0
- package/dist/template-resolver/document-frames.js +19 -0
- package/dist/template-resolver/document-op-blocks.d.ts +495 -0
- package/dist/template-resolver/document-op-blocks.js +430 -0
- package/dist/template-resolver/document-ops.d.ts +1809 -37
- package/dist/template-resolver/document-ops.js +97 -104
- package/dist/template-resolver/document-print-only.d.ts +10 -0
- package/dist/template-resolver/document-print-only.js +24 -0
- package/dist/template-resolver/document-sanitizer.d.ts +1 -1
- package/dist/template-resolver/document-sanitizer.js +24 -13
- package/dist/template-resolver/feature.d.ts +3 -0
- package/dist/template-resolver/feature.js +14 -1
- package/dist/template-resolver/handlers/apply-layout.write.d.ts +29 -0
- package/dist/template-resolver/handlers/apply-layout.write.js +118 -0
- package/dist/template-resolver/handlers/create-layout.write.d.ts +15 -0
- package/dist/template-resolver/handlers/create-layout.write.js +78 -0
- package/dist/template-resolver/handlers/document-base.d.ts +2 -2
- package/dist/template-resolver/handlers/document-blocks.query.d.ts +10 -3
- package/dist/template-resolver/handlers/document-blocks.query.js +13 -8
- package/dist/template-resolver/handlers/document-region.d.ts +19 -0
- package/dist/template-resolver/handlers/document-region.js +27 -0
- package/dist/template-resolver/handlers/failure-reason.d.ts +2 -0
- package/dist/template-resolver/handlers/failure-reason.js +12 -0
- package/dist/template-resolver/handlers/import-bundle-system.write.js +4 -0
- package/dist/template-resolver/handlers/layout-source.query.d.ts +3 -3
- package/dist/template-resolver/handlers/layout-source.query.js +6 -2
- package/dist/template-resolver/handlers/overview.query.d.ts +8 -0
- package/dist/template-resolver/handlers/overview.query.js +12 -6
- package/dist/template-resolver/handlers/patch-draft.write.d.ts +905 -4
- package/dist/template-resolver/handlers/patch-draft.write.js +10 -6
- package/dist/template-resolver/handlers/publish-templates.write.d.ts +40 -0
- package/dist/template-resolver/handlers/publish-templates.write.js +61 -0
- package/dist/template-resolver/handlers/set.write.js +4 -1
- package/dist/template-resolver/handlers/template-write.js +7 -2
- package/dist/template-resolver/handlers/tenant-settings.d.ts +17 -0
- package/dist/template-resolver/handlers/tenant-settings.js +91 -0
- package/dist/template-resolver/handlers/toggle-status.write.d.ts +14 -9
- package/dist/template-resolver/handlers/toggle-status.write.js +11 -7
- package/dist/template-resolver/handlers/upsert-system.write.js +15 -9
- package/dist/template-resolver/handlers/usage.query.d.ts +14 -0
- package/dist/template-resolver/handlers/usage.query.js +80 -12
- package/dist/template-resolver/handlers/validate.query.d.ts +2 -0
- package/dist/template-resolver/handlers/validate.query.js +10 -0
- package/dist/template-resolver/i18n.js +3 -0
- package/dist/template-resolver/index.d.ts +7 -2
- package/dist/template-resolver/index.js +6 -2
- package/dist/template-resolver/layout-regions.d.ts +4 -5
- package/dist/template-resolver/layout-regions.js +38 -11
- package/dist/template-resolver/print-document.js +3 -1
- package/dist/template-resolver/seeding.js +4 -0
- package/dist/template-resolver/template-delivery-policy.d.ts +1 -0
- package/dist/template-resolver/template-delivery-policy.js +9 -1
- package/dist/template-resolver/template-edit-policy.d.ts +5 -1
- package/dist/template-resolver/template-edit-policy.js +29 -1
- package/dist/template-resolver/template-meta.d.ts +27 -2
- package/dist/template-resolver/template-meta.js +21 -5
- package/dist/template-resolver/template-preview.js +8 -8
- package/dist/template-resolver/template-validation.js +10 -3
- package/dist/template-resolver/web/constants.d.ts +7 -1
- package/dist/template-resolver/web/constants.js +21 -1
- package/dist/template-resolver/web/document-blocks.d.ts +1 -0
- package/dist/template-resolver/web/document-blocks.js +2 -0
- package/dist/template-resolver/web/document-editor-extensions.d.ts +9 -1
- package/dist/template-resolver/web/document-editor-extensions.js +27 -2
- package/dist/template-resolver/web/document-editor-fonts.d.ts +10 -0
- package/dist/template-resolver/web/document-editor-fonts.js +13 -0
- package/dist/template-resolver/web/document-fonts.d.ts +4 -0
- package/dist/template-resolver/web/document-fonts.js +18 -0
- package/dist/template-resolver/web/document-frame-control.d.ts +61 -0
- package/dist/template-resolver/web/document-frame-control.js +329 -0
- package/dist/template-resolver/web/document-frame-node-view.d.ts +4 -0
- package/dist/template-resolver/web/document-frame-node-view.js +173 -0
- package/dist/template-resolver/web/document-print-decorations.d.ts +12 -0
- package/dist/template-resolver/web/document-print-decorations.js +147 -0
- package/dist/template-resolver/web/document-print-defaults.d.ts +14 -0
- package/dist/template-resolver/web/document-print-defaults.js +25 -0
- package/dist/template-resolver/web/document-print-style.d.ts +71 -0
- package/dist/template-resolver/web/document-print-style.js +199 -0
- package/dist/template-resolver/web/document-repeat-strip.d.ts +8 -0
- package/dist/template-resolver/web/document-repeat-strip.js +78 -0
- package/dist/template-resolver/web/document-schema.js +23 -9
- package/dist/template-resolver/web/document-style-css.d.ts +29 -0
- package/dist/template-resolver/web/document-style-css.js +76 -0
- package/dist/template-resolver/web/document-tiptap-bubble.js +13 -3
- package/dist/template-resolver/web/document-tiptap-content.d.ts +2 -1
- package/dist/template-resolver/web/document-tiptap-content.js +36 -4
- package/dist/template-resolver/web/document-tiptap-context.d.ts +6 -2
- package/dist/template-resolver/web/document-tiptap-context.js +2 -1
- package/dist/template-resolver/web/document-tiptap-editor.d.ts +1 -1
- package/dist/template-resolver/web/document-tiptap-editor.js +13 -5
- package/dist/template-resolver/web/document-tiptap-helpers.d.ts +30 -1
- package/dist/template-resolver/web/document-tiptap-helpers.js +103 -2
- package/dist/template-resolver/web/document-tiptap-toolbar-groups.d.ts +5 -0
- package/dist/template-resolver/web/document-tiptap-toolbar-groups.js +89 -6
- package/dist/template-resolver/web/document-tiptap-toolbar.js +45 -8
- package/dist/template-resolver/web/document-toolbar-blocks.d.ts +17 -0
- package/dist/template-resolver/web/i18n.js +19 -0
- package/dist/template-resolver/web/index.d.ts +8 -2
- package/dist/template-resolver/web/index.js +6 -1
- package/dist/template-resolver/web/pdf-constants.d.ts +3 -0
- package/dist/template-resolver/web/pdf-constants.js +3 -0
- package/dist/template-resolver/web/qualified-names.d.ts +7 -0
- package/dist/template-resolver/web/qualified-names.js +6 -0
- package/dist/template-resolver/web/use-document-tiptap-model.d.ts +6 -2
- package/dist/template-resolver/web/use-document-tiptap-model.js +38 -3
- package/dist/tenant/company-config.d.ts +6 -0
- package/dist/tenant/company-config.js +41 -0
- package/dist/tenant/feature.js +11 -0
- package/dist/tenant/i18n.js +14 -0
- package/dist/tenant-inactivity/handlers/keep-account.write.js +5 -2
- package/dist/tenant-lifecycle/run-tenant-destroy.js +65 -33
- package/package.json +16 -11
- package/src/agent-tools/changes.json +6 -0
- package/src/cap-counter/changes.json +6 -0
- package/src/channel-whatsapp/changes.json +1 -1
- package/src/document-ingest-foundation/changes.json +6 -0
- package/src/signature/changes.json +18 -0
- package/src/subscription-paddle/changes.json +1 -1
- package/src/subscription-stripe/changes.json +6 -0
- package/src/template-resolver/changes.json +38 -0
- package/src/tenant-lifecycle/changes.json +6 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isOneOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
2
|
+
import { addressFrameContent, columnsTableContent, insertFrame, textFrameContent, } from "./document-frame-control.js";
|
|
2
3
|
export const NO_LABELS = {};
|
|
3
4
|
export const NO_NAMES = [];
|
|
4
5
|
export const NO_PREVIEWS = {};
|
|
@@ -17,6 +18,102 @@ export const BLOCK_PANEL = {
|
|
|
17
18
|
steps: "steps",
|
|
18
19
|
images: "images",
|
|
19
20
|
};
|
|
21
|
+
// PDF kinds are the ones whose block set carries a page break; a hosted toolbar means a layout region.
|
|
22
|
+
export function printModeOf(blocks, hosted, canvas) {
|
|
23
|
+
if (!blocks.includes("pageBreak"))
|
|
24
|
+
return "none";
|
|
25
|
+
return canvas && !hosted ? "page" : "flow";
|
|
26
|
+
}
|
|
27
|
+
export const FONT_SIZES_PT = [6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 24, 36];
|
|
28
|
+
export const LINE_HEIGHTS = [1, 1.15, 1.2, 1.25, 1.5, 2];
|
|
29
|
+
export const PARAGRAPH_SPACES_PT = [0, 3, 6, 8, 12, 18, 24];
|
|
30
|
+
const TEXT_STYLE_MARK = "documentTextStyle";
|
|
31
|
+
function stringOrNull(value) {
|
|
32
|
+
return typeof value === "string" ? value : null;
|
|
33
|
+
}
|
|
34
|
+
function numberOrNull(value) {
|
|
35
|
+
return typeof value === "number" ? value : null;
|
|
36
|
+
}
|
|
37
|
+
function printTextStyleOf(e) {
|
|
38
|
+
const attrs = e.getAttributes(TEXT_STYLE_MARK);
|
|
39
|
+
return {
|
|
40
|
+
font: stringOrNull(attrs["font"]),
|
|
41
|
+
sizePt: numberOrNull(attrs["sizePt"]),
|
|
42
|
+
color: stringOrNull(attrs["color"]),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function printBlockStyleOf(e) {
|
|
46
|
+
const attrs = e.getAttributes(e.isActive("heading") ? "heading" : "paragraph");
|
|
47
|
+
return {
|
|
48
|
+
lineHeight: numberOrNull(attrs["lineHeight"]),
|
|
49
|
+
spaceBeforePt: numberOrNull(attrs["spaceBeforePt"]),
|
|
50
|
+
spaceAfterPt: numberOrNull(attrs["spaceAfterPt"]),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function tableLocationOf(e) {
|
|
54
|
+
const { $from } = e.state.selection;
|
|
55
|
+
for (let depth = $from.depth; depth > 0; depth--) {
|
|
56
|
+
const node = $from.node(depth);
|
|
57
|
+
if (node.type.name === "table")
|
|
58
|
+
return { pos: $from.before(depth), attrs: node.attrs };
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
function printTableOf(e) {
|
|
63
|
+
const table = tableLocationOf(e);
|
|
64
|
+
if (table === null)
|
|
65
|
+
return null;
|
|
66
|
+
const { $from } = e.state.selection;
|
|
67
|
+
let cellBackground = null;
|
|
68
|
+
for (let depth = $from.depth; depth > 0; depth--) {
|
|
69
|
+
const node = $from.node(depth);
|
|
70
|
+
if (node.type.name === "tableCell" || node.type.name === "tableHeader") {
|
|
71
|
+
cellBackground = stringOrNull(node.attrs["background"]);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return { bordersOff: table.attrs["borders"] === "none", cellBackground };
|
|
76
|
+
}
|
|
77
|
+
export function setPrintTextStyle(editor, patch) {
|
|
78
|
+
const next = { ...printTextStyleOf(editor), ...patch };
|
|
79
|
+
const chain = editor.chain().focus();
|
|
80
|
+
if (next.font === null && next.sizePt === null && next.color === null) {
|
|
81
|
+
chain.unsetMark(TEXT_STYLE_MARK).run();
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
chain.setMark(TEXT_STYLE_MARK, next).run();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export function setPrintBlockStyle(editor, patch) {
|
|
88
|
+
editor
|
|
89
|
+
.chain()
|
|
90
|
+
.focus()
|
|
91
|
+
.updateAttributes("paragraph", patch)
|
|
92
|
+
.updateAttributes("heading", patch)
|
|
93
|
+
.run();
|
|
94
|
+
}
|
|
95
|
+
export function toggleTableBorders(editor) {
|
|
96
|
+
const table = tableLocationOf(editor);
|
|
97
|
+
if (table === null)
|
|
98
|
+
return;
|
|
99
|
+
const borders = table.attrs["borders"] === "none" ? null : "none";
|
|
100
|
+
editor
|
|
101
|
+
.chain()
|
|
102
|
+
.focus()
|
|
103
|
+
.command(({ tr }) => {
|
|
104
|
+
tr.setNodeMarkup(table.pos, undefined, { ...table.attrs, borders });
|
|
105
|
+
return true;
|
|
106
|
+
})
|
|
107
|
+
.run();
|
|
108
|
+
}
|
|
109
|
+
export function insertPrintBlock(editor, block) {
|
|
110
|
+
if (block === "address")
|
|
111
|
+
insertFrame(editor, addressFrameContent());
|
|
112
|
+
else if (block === "textFrame")
|
|
113
|
+
insertFrame(editor, textFrameContent());
|
|
114
|
+
else
|
|
115
|
+
editor.chain().focus().insertContent(columnsTableContent()).run();
|
|
116
|
+
}
|
|
20
117
|
// print-document moves the leading rows flagged repeatHeader into thead, so the
|
|
21
118
|
// toggle reads and writes the table's first row.
|
|
22
119
|
export function findRepeatTable(editor) {
|
|
@@ -106,10 +203,11 @@ function blockStyleOf(e) {
|
|
|
106
203
|
}
|
|
107
204
|
function selectedBlockOf(e) {
|
|
108
205
|
if (e.isActive("resource")) {
|
|
109
|
-
|
|
206
|
+
const attrs = e.getAttributes("resource");
|
|
207
|
+
return { type: "resource", detail: String(attrs["resource"]), bleed: attrs["bleed"] === true };
|
|
110
208
|
}
|
|
111
209
|
if (e.isActive("button")) {
|
|
112
|
-
return { type: "button", detail: String(e.getAttributes("button")["href"]) };
|
|
210
|
+
return { type: "button", detail: String(e.getAttributes("button")["href"]), bleed: false };
|
|
113
211
|
}
|
|
114
212
|
return null; // skip: no resource or button selected
|
|
115
213
|
}
|
|
@@ -125,5 +223,8 @@ export function activeStateOf(e, showHtml) {
|
|
|
125
223
|
orderedList: e.isActive("orderedList"),
|
|
126
224
|
link: e.isActive("link"),
|
|
127
225
|
repeatTable: findRepeatTable(e),
|
|
226
|
+
textStyle: printTextStyleOf(e),
|
|
227
|
+
paragraphStyle: printBlockStyleOf(e),
|
|
228
|
+
printTable: printTableOf(e),
|
|
128
229
|
};
|
|
129
230
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { TiptapContext } from "./document-tiptap-context.ts";
|
|
3
|
+
export declare function Separator({ compact }: {
|
|
4
|
+
readonly compact?: boolean;
|
|
5
|
+
}): ReactNode;
|
|
3
6
|
export declare function iconButton(c: TiptapContext, label: string, icon: ReactNode, isActive: boolean, onClick: () => void, text?: string): ReactNode;
|
|
4
7
|
export declare function renderParagraphStyleSelect(c: TiptapContext): ReactNode;
|
|
5
8
|
export declare function renderMarkButtons(c: TiptapContext): ReactNode;
|
|
6
9
|
export declare function renderListButtons(c: TiptapContext): ReactNode;
|
|
10
|
+
export declare function renderPrintTextStyleGroup(c: TiptapContext): ReactNode;
|
|
11
|
+
export declare function renderPrintTableGroup(c: TiptapContext): ReactNode;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { cn } from "@cosmicdrift/kumiko-renderer/web";
|
|
3
|
-
import {
|
|
2
|
+
import { cn, EditorToolbarPill } from "@cosmicdrift/kumiko-renderer/web";
|
|
3
|
+
import { isOneOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
4
|
+
import { Bold as BoldIcon, Italic as ItalicIcon, Link as LinkIcon, List, ListOrdered, MoveVertical, Underline as UnderlineIcon, } from "lucide-react";
|
|
5
|
+
import { DOCUMENT_FONT_LABELS, DOCUMENT_FONTS } from "./document-fonts.js";
|
|
6
|
+
import { FONT_SIZES_PT, LINE_HEIGHTS, PARAGRAPH_SPACES_PT, setPrintBlockStyle, setPrintTextStyle, toggleTableBorders, } from "./document-tiptap-helpers.js";
|
|
7
|
+
export function Separator({ compact = false }) {
|
|
8
|
+
return (_jsx("span", { "aria-hidden": "true", className: cn("h-5 w-px bg-border", compact ? "mx-0.5" : "mx-2") }));
|
|
9
|
+
}
|
|
4
10
|
// Canvas chrome is one flat row: unframed ghost buttons, glyph plus text for the longer names.
|
|
5
11
|
export function iconButton(c, label, icon, isActive, onClick, text) {
|
|
6
12
|
const { Button, canvas, readOnly } = c;
|
|
@@ -9,6 +15,12 @@ export function iconButton(c, label, icon, isActive, onClick, text) {
|
|
|
9
15
|
function markContent(canvas, letter, icon, className) {
|
|
10
16
|
return canvas ? _jsx("span", { className: className, children: letter }) : icon;
|
|
11
17
|
}
|
|
18
|
+
function FlatSelectBox({ flat, widthClass, testId, children, }) {
|
|
19
|
+
return (_jsx("div", { "data-testid": testId,
|
|
20
|
+
// biome-ignore lint/plugin: the toolbar selects sit flush in the editor toolbar; ComboboxInput has no flat trigger variant
|
|
21
|
+
className: cn(!flat && widthClass, flat &&
|
|
22
|
+
"w-auto shrink-0 [&_button[aria-haspopup=listbox]]:border-transparent [&_button[aria-haspopup=listbox]]:bg-transparent [&_button[aria-haspopup=listbox]]:shadow-none"), children: children }));
|
|
23
|
+
}
|
|
12
24
|
export function renderParagraphStyleSelect(c) {
|
|
13
25
|
const { t, Field, Input, id, canvas, compact, readOnly, activeState } = c;
|
|
14
26
|
const paragraphStyleLabel = t("template-resolver.documentEditor.paragraphStyle");
|
|
@@ -18,10 +30,7 @@ export function renderParagraphStyleSelect(c) {
|
|
|
18
30
|
{ value: "2", label: t("kumiko.contentEditor.heading2") },
|
|
19
31
|
{ value: "3", label: t("template-resolver.documentEditor.heading3") },
|
|
20
32
|
];
|
|
21
|
-
return (_jsx("
|
|
22
|
-
// biome-ignore lint/plugin: the toolbar paragraph select sits flush in the editor toolbar; ComboboxInput has no flat trigger variant
|
|
23
|
-
className: cn(!canvas && (compact ? "w-24" : "w-40"), canvas &&
|
|
24
|
-
"w-auto shrink-0 [&_button[aria-haspopup=listbox]]:border-transparent [&_button[aria-haspopup=listbox]]:bg-transparent [&_button[aria-haspopup=listbox]]:shadow-none"), children: _jsx(Field, { id: `${id}-paragraph-style`, label: paragraphStyleLabel, hideLabel: true, children: _jsx(Input, { kind: "select", id: `${id}-paragraph-style`, name: "paragraph-style", value: activeState?.blockStyle ?? "paragraph", onChange: c.setBlockStyle, options: styleOptions, display: "dropdown", disabled: readOnly }) }) }));
|
|
33
|
+
return (_jsx(FlatSelectBox, { flat: canvas, widthClass: compact ? "w-24" : "w-40", children: _jsx(Field, { id: `${id}-paragraph-style`, label: paragraphStyleLabel, hideLabel: true, children: _jsx(Input, { kind: "select", id: `${id}-paragraph-style`, name: "paragraph-style", value: activeState?.blockStyle ?? "paragraph", onChange: c.setBlockStyle, options: styleOptions, display: "dropdown", disabled: readOnly }) }) }));
|
|
25
34
|
}
|
|
26
35
|
export function renderMarkButtons(c) {
|
|
27
36
|
const { t, editor, canvas, activeState } = c;
|
|
@@ -31,3 +40,77 @@ export function renderListButtons(c) {
|
|
|
31
40
|
const { t, editor, activeState } = c;
|
|
32
41
|
return (_jsxs(_Fragment, { children: [iconButton(c, t("kumiko.contentEditor.bulletList"), _jsx(List, { size: 16 }), activeState?.bulletList ?? false, () => editor.chain().focus().toggleBulletList().run()), iconButton(c, t("kumiko.contentEditor.orderedList"), _jsx(ListOrdered, { size: 16 }), activeState?.orderedList ?? false, () => editor.chain().focus().toggleOrderedList().run()), iconButton(c, t("template-resolver.documentEditor.link"), _jsx(LinkIcon, { size: 16 }), activeState?.link ?? false, () => c.togglePanel("link"))] }));
|
|
33
42
|
}
|
|
43
|
+
const DEFAULT_OPTION_VALUE = "";
|
|
44
|
+
const FALLBACK_COLOR = "#000000";
|
|
45
|
+
function numberOptions(values, current, defaultLabel, format) {
|
|
46
|
+
const all = current === null || values.includes(current)
|
|
47
|
+
? values
|
|
48
|
+
: [...values, current].sort((a, b) => a - b);
|
|
49
|
+
return [
|
|
50
|
+
{ value: DEFAULT_OPTION_VALUE, label: defaultLabel },
|
|
51
|
+
...all.map((value) => ({ value: String(value), label: format(value) })),
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
function parseOptionNumber(value) {
|
|
55
|
+
return value === DEFAULT_OPTION_VALUE ? null : Number(value);
|
|
56
|
+
}
|
|
57
|
+
function printSelect(c, spec) {
|
|
58
|
+
const { Field, Input, id, readOnly } = c;
|
|
59
|
+
const fieldId = `${id}-${spec.key}`;
|
|
60
|
+
return (_jsxs(EditorToolbarPill, { children: [spec.leading, _jsx(FlatSelectBox, { flat: true, widthClass: "", testId: `document-toolbar-${spec.key}`, children: _jsx(Field, { id: fieldId, label: spec.label, hideLabel: true, children: _jsx(Input, { kind: "select", id: fieldId, name: spec.key, value: spec.value, onChange: spec.onChange, options: spec.options, display: "dropdown", disabled: readOnly }) }) })] }, spec.key));
|
|
61
|
+
}
|
|
62
|
+
function colorPicker(c, testId, label, value, onPick) {
|
|
63
|
+
return (_jsxs(EditorToolbarPill, { children: [_jsx("input", { type: "color", "data-testid": testId, "aria-label": label, title: label, disabled: c.readOnly, value: value ?? FALLBACK_COLOR, onChange: (event) => onPick(event.target.value), className: "ml-1.5 h-5 w-5 cursor-pointer rounded border border-input bg-transparent p-0" }), _jsx("span", { className: "pr-2 pl-1.5 text-xs text-muted-foreground", children: label }), value !== null && (_jsx(c.Button, { type: "button", variant: "ghost", size: "sm", ariaLabel: c.t("documentDesigner.editor.colorReset"), title: c.t("documentDesigner.editor.colorReset"), testId: `${testId}-reset`, onClick: () => onPick(null), children: "\u00D7" }))] }));
|
|
64
|
+
}
|
|
65
|
+
export function renderPrintTextStyleGroup(c) {
|
|
66
|
+
const { t, editor } = c;
|
|
67
|
+
const text = c.activeState?.textStyle ?? { font: null, sizePt: null, color: null };
|
|
68
|
+
const block = c.activeState?.paragraphStyle ?? {
|
|
69
|
+
lineHeight: null,
|
|
70
|
+
spaceBeforePt: null,
|
|
71
|
+
spaceAfterPt: null,
|
|
72
|
+
};
|
|
73
|
+
const defaults = c.printDefaults;
|
|
74
|
+
const space = (key, label, defaultLabel, current, field, format) => printSelect(c, {
|
|
75
|
+
key,
|
|
76
|
+
label,
|
|
77
|
+
value: current === null ? DEFAULT_OPTION_VALUE : String(current),
|
|
78
|
+
options: numberOptions(PARAGRAPH_SPACES_PT, current, defaultLabel, format),
|
|
79
|
+
onChange: (value) => setPrintBlockStyle(editor, { [field]: parseOptionNumber(value) }),
|
|
80
|
+
});
|
|
81
|
+
return (_jsxs(_Fragment, { children: [printSelect(c, {
|
|
82
|
+
key: "font",
|
|
83
|
+
label: t("documentDesigner.editor.font"),
|
|
84
|
+
value: text.font ?? DEFAULT_OPTION_VALUE,
|
|
85
|
+
options: [
|
|
86
|
+
{ value: DEFAULT_OPTION_VALUE, label: defaults.font },
|
|
87
|
+
...DOCUMENT_FONTS.map((font) => ({ value: font, label: DOCUMENT_FONT_LABELS[font] })),
|
|
88
|
+
],
|
|
89
|
+
onChange: (value) => setPrintTextStyle(editor, { font: isOneOf(DOCUMENT_FONTS, value) ? value : null }),
|
|
90
|
+
}), printSelect(c, {
|
|
91
|
+
key: "size",
|
|
92
|
+
label: t("documentDesigner.editor.fontSize"),
|
|
93
|
+
value: text.sizePt === null ? DEFAULT_OPTION_VALUE : String(text.sizePt),
|
|
94
|
+
options: numberOptions(FONT_SIZES_PT, text.sizePt, defaults.size, defaults.formatSize),
|
|
95
|
+
onChange: (value) => setPrintTextStyle(editor, { sizePt: parseOptionNumber(value) }),
|
|
96
|
+
}), colorPicker(c, "document-toolbar-color", t("documentDesigner.editor.textColor"), text.color, (color) => setPrintTextStyle(editor, { color })), _jsx(Separator, { compact: c.canvas }), printSelect(c, {
|
|
97
|
+
key: "line-height",
|
|
98
|
+
leading: (_jsx(MoveVertical, { size: 14, "aria-hidden": "true", className: "ml-2 shrink-0 text-muted-foreground" })),
|
|
99
|
+
label: t("documentDesigner.editor.lineHeight"),
|
|
100
|
+
value: block.lineHeight === null ? DEFAULT_OPTION_VALUE : String(block.lineHeight),
|
|
101
|
+
options: numberOptions(LINE_HEIGHTS, block.lineHeight, defaults.lineHeight, defaults.formatLineHeight),
|
|
102
|
+
onChange: (value) => setPrintBlockStyle(editor, { lineHeight: parseOptionNumber(value) }),
|
|
103
|
+
}), block.spaceBeforePt !== null &&
|
|
104
|
+
space("space-before", t("documentDesigner.editor.spaceBefore"), defaults.spaceBefore, block.spaceBeforePt, "spaceBeforePt", defaults.formatSpaceBefore), space("space-after", t("documentDesigner.editor.spaceAfter"), defaults.spaceAfter, block.spaceAfterPt, "spaceAfterPt", defaults.formatSpaceAfter)] }));
|
|
105
|
+
}
|
|
106
|
+
export function renderPrintTableGroup(c) {
|
|
107
|
+
const { t, editor, Button } = c;
|
|
108
|
+
const table = c.activeState?.printTable ?? null;
|
|
109
|
+
if (table === null)
|
|
110
|
+
return null;
|
|
111
|
+
return (_jsxs(_Fragment, { children: [_jsx(EditorToolbarPill, { children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", pressed: !table.bordersOff, disabled: c.readOnly, testId: "document-table-borders", onClick: () => toggleTableBorders(editor), children: t("documentDesigner.editor.tableBorders") }) }), colorPicker(c, "document-cell-color", t("documentDesigner.editor.cellColor"), table.cellBackground, (color) => editor.chain().focus().setCellAttribute("background", color).run()), _jsx(EditorToolbarPill, { children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: c.readOnly, testId: "document-table-add-column", onClick: () => {
|
|
112
|
+
editor.chain().focus().addColumnAfter().run();
|
|
113
|
+
}, children: t("documentDesigner.editor.table.addColumn") }) }), _jsx(EditorToolbarPill, { children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: c.readOnly, testId: "document-table-remove-column", onClick: () => {
|
|
114
|
+
editor.chain().focus().deleteColumn().run();
|
|
115
|
+
}, children: t("documentDesigner.editor.table.removeColumn") }) })] }));
|
|
116
|
+
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { cn } from "@cosmicdrift/kumiko-renderer/web";
|
|
3
|
-
import { AlignLeft, Braces, ChevronDown, GalleryThumbnails, Image as ImageIcon, ListChecks, Minus, MousePointerClick, Repeat, Scissors, Table as TableIcon, } from "lucide-react";
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ActionMenu, cn } from "@cosmicdrift/kumiko-renderer/web";
|
|
3
|
+
import { AlignLeft, Braces, ChevronDown, Columns3, GalleryThumbnails, Image as ImageIcon, ListChecks, Mail, Minus, MousePointerClick, Plus, Repeat, Scissors, SquareDashed, Table as TableIcon, } from "lucide-react";
|
|
4
4
|
import { Fragment } from "react";
|
|
5
5
|
import { CANVAS_INLINE_BLOCKS } from "./document-tiptap-helpers.js";
|
|
6
|
-
import { iconButton, renderListButtons, renderMarkButtons, renderParagraphStyleSelect, } from "./document-tiptap-toolbar-groups.js";
|
|
7
|
-
function Separator({ compact = false }) {
|
|
8
|
-
return (_jsx("span", { "aria-hidden": "true", className: cn("h-5 w-px bg-border", compact ? "mx-0.5" : "mx-2") }));
|
|
9
|
-
}
|
|
6
|
+
import { iconButton, renderListButtons, renderMarkButtons, renderParagraphStyleSelect, renderPrintTableGroup, renderPrintTextStyleGroup, Separator, } from "./document-tiptap-toolbar-groups.js";
|
|
10
7
|
function blockButtonsOf(c) {
|
|
11
8
|
const { t } = c;
|
|
12
9
|
const { imageLabel, pageBreakLabel, stepsLabel, imagesLabel } = c.labels;
|
|
@@ -69,7 +66,47 @@ function overflowItemsOf(c, menuBlocks, blockButtons) {
|
|
|
69
66
|
: []),
|
|
70
67
|
];
|
|
71
68
|
}
|
|
69
|
+
const PRINT_BLOCKS_BY_MODE = {
|
|
70
|
+
none: [],
|
|
71
|
+
flow: ["columns"],
|
|
72
|
+
page: ["address", "textFrame", "columns"],
|
|
73
|
+
};
|
|
74
|
+
const PRINT_BLOCK_TEST_IDS = {
|
|
75
|
+
address: "document-block-address",
|
|
76
|
+
textFrame: "document-block-textframe",
|
|
77
|
+
columns: "document-block-columns",
|
|
78
|
+
};
|
|
79
|
+
const PRINT_BLOCK_ICONS = {
|
|
80
|
+
address: _jsx(Mail, { size: 16 }),
|
|
81
|
+
textFrame: _jsx(SquareDashed, { size: 16 }),
|
|
82
|
+
columns: _jsx(Columns3, { size: 16 }),
|
|
83
|
+
};
|
|
84
|
+
function renderPrintBlockMenu(c) {
|
|
85
|
+
const { t } = c;
|
|
86
|
+
const blocks = PRINT_BLOCKS_BY_MODE[c.print];
|
|
87
|
+
if (blocks.length === 0)
|
|
88
|
+
return null;
|
|
89
|
+
return (_jsx(ActionMenu, { testId: "document-block-menu", triggerLabel: t("documentDesigner.editor.blockMenu"), align: "start", minWidth: "18rem", trigger: _jsxs("span", { className: "inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full border border-primary/40 bg-primary/10 px-3 text-xs font-medium text-primary", children: [_jsx(Plus, { size: 14 }), t("documentDesigner.editor.blockMenu"), _jsx(ChevronDown, { size: 12 })] }), items: blocks.map((block) => ({
|
|
90
|
+
kind: "item",
|
|
91
|
+
id: block,
|
|
92
|
+
label: t(`documentDesigner.editor.block.${block}`),
|
|
93
|
+
description: t(`documentDesigner.editor.block.${block}.hint`),
|
|
94
|
+
icon: PRINT_BLOCK_ICONS[block],
|
|
95
|
+
testId: PRINT_BLOCK_TEST_IDS[block],
|
|
96
|
+
disabled: c.readOnly,
|
|
97
|
+
onSelect: () => c.runPrintBlock(block),
|
|
98
|
+
})) }));
|
|
99
|
+
}
|
|
100
|
+
function renderPrintStyleRow(c) {
|
|
101
|
+
const { canvas } = c;
|
|
102
|
+
return (_jsxs("div", { className: cn("flex items-center border-b border-input", canvas
|
|
103
|
+
? "min-h-9 flex-wrap gap-1.5 bg-background px-1.5 py-1 [&>*]:shrink-0"
|
|
104
|
+
: "flex-wrap gap-1 p-1"), children: [renderPrintTextStyleGroup(c), renderPrintTableGroup(c)] }));
|
|
105
|
+
}
|
|
72
106
|
export function renderToolbarBar(c) {
|
|
107
|
+
return (_jsxs(_Fragment, { children: [renderMainToolbarRow(c), c.print !== "none" && renderPrintStyleRow(c)] }));
|
|
108
|
+
}
|
|
109
|
+
function renderMainToolbarRow(c) {
|
|
73
110
|
const { t, id, canvas, compact, ActionOverflowMenu } = c;
|
|
74
111
|
const blockButtons = blockButtonsOf(c);
|
|
75
112
|
// The canvas toolbar never scrolls sideways: the rarer blocks and the HTML view sit in the menu.
|
|
@@ -87,5 +124,5 @@ export function renderToolbarBar(c) {
|
|
|
87
124
|
trailingIcon: canvas ? _jsx(ChevronDown, { size: 12 }) : undefined,
|
|
88
125
|
expanded: c.openPanel === "placeholder",
|
|
89
126
|
onClick: () => c.togglePanel("placeholder"),
|
|
90
|
-
}), inlineBlocks.length > 0 && _jsx(Separator, { compact: compact || canvas }), inlineBlocks.map((block) => renderInlineBlock(c, block, blockButtons)), overflowItems.length > 0 && ActionOverflowMenu !== undefined && (_jsx("span", { className: "ml-auto shrink-0", children: _jsx(ActionOverflowMenu, { items: overflowItems, label: t("template-resolver.documentEditor.more"), testId: `${id}-toolbar-more` }) }))] }));
|
|
127
|
+
}), inlineBlocks.length > 0 && _jsx(Separator, { compact: compact || canvas }), inlineBlocks.map((block) => renderInlineBlock(c, block, blockButtons)), c.print !== "none" && _jsx(Separator, { compact: compact || canvas }), renderPrintBlockMenu(c), overflowItems.length > 0 && ActionOverflowMenu !== undefined && (_jsx("span", { className: "ml-auto shrink-0", children: _jsx(ActionOverflowMenu, { items: overflowItems, label: t("template-resolver.documentEditor.more"), testId: `${id}-toolbar-more` }) }))] }));
|
|
91
128
|
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import type { ContentEditorProps } from "@cosmicdrift/kumiko-renderer";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
import type { DocumentToolbarBlock } from "./document-blocks.ts";
|
|
4
|
+
import type { DocumentFont } from "./document-fonts.ts";
|
|
5
|
+
import type { DocumentFrameControl } from "./document-frame-control.ts";
|
|
6
|
+
/** The text values the layout gives; a missing one makes the matching toolbar default show the control's name. */
|
|
7
|
+
export type DocumentLayoutValues = {
|
|
8
|
+
readonly fontFamily?: DocumentFont;
|
|
9
|
+
readonly fontSizePt?: number;
|
|
10
|
+
readonly lineHeight?: number;
|
|
11
|
+
readonly spaceBeforePt?: number;
|
|
12
|
+
readonly spaceAfterPt?: number;
|
|
13
|
+
};
|
|
14
|
+
/** "none" = mail; "flow" = PDF text flow (styling, columns); "page" = PDF body on a canvas paper, which also places frames. */
|
|
15
|
+
export type DocumentPrintMode = "none" | "flow" | "page";
|
|
16
|
+
export type DocumentPrintBlock = "address" | "textFrame" | "columns";
|
|
4
17
|
/** Imperative access for an outside panel (placeholder list, resource list). */
|
|
5
18
|
export type DocumentEditorHandle = {
|
|
6
19
|
readonly insertPlaceholder: (name: string) => void;
|
|
@@ -27,6 +40,8 @@ export type DocumentEditorProps = ContentEditorProps & {
|
|
|
27
40
|
/** Image previews by resource key; resources without one show a key placeholder. */
|
|
28
41
|
readonly resourcePreviews?: Readonly<Record<string, DocumentResourcePreview>>;
|
|
29
42
|
readonly chrome?: DocumentEditorChrome;
|
|
43
|
+
/** Print toolbar only: what the "inherit" option of each text select resolves to. */
|
|
44
|
+
readonly layoutValues?: DocumentLayoutValues;
|
|
30
45
|
/** "compact" renders the placeholder and block buttons icon-only with a tooltip, for narrow columns. Default "full". */
|
|
31
46
|
readonly toolbar?: "full" | "compact";
|
|
32
47
|
/** Canvas only: wraps the editable area in a caller-owned page (letterhead, margins) instead of the default mail paper. */
|
|
@@ -36,5 +51,7 @@ export type DocumentEditorProps = ContentEditorProps & {
|
|
|
36
51
|
readonly toolbarHost?: HTMLElement | null;
|
|
37
52
|
/** Called with the handle once the editor exists and with null when it is destroyed (unmount or rebuild), so a held handle never outlives its editor. */
|
|
38
53
|
readonly onEditorReady?: (handle: DocumentEditorHandle | null) => void;
|
|
54
|
+
/** PDF body on a canvas paper only: reports the frame the selection is in or on (null otherwise), with controls for a side panel. */
|
|
55
|
+
readonly onFrameControlChange?: (control: DocumentFrameControl | null) => void;
|
|
39
56
|
};
|
|
40
57
|
export { type DocumentToolbarBlock, documentBlocksForKind, MAIL_DOCUMENT_BLOCKS, PDF_DOCUMENT_BLOCKS, } from "./document-blocks.ts";
|
|
@@ -54,6 +54,15 @@ export const defaultTranslations = {
|
|
|
54
54
|
"template-resolver.editor.created": "Created.",
|
|
55
55
|
"template-resolver.editor.saved": "Saved.",
|
|
56
56
|
"templateResolver.errors.document.imagesBlockPdfOnly": "Photo blocks are only allowed in PDF documents.",
|
|
57
|
+
"templateResolver.errors.document.printStylePdfOnly": "Print styling (fonts, colors, spacing, frames) is only allowed in PDF documents.",
|
|
58
|
+
"templateResolver.errors.template_not_tenant_editable": "You may not edit this template.",
|
|
59
|
+
"templateResolver.errors.template_already_active": "Nothing to publish, no open draft.",
|
|
60
|
+
"templateResolver.errors.layout_not_published": "Publish the layout first.",
|
|
61
|
+
"templateResolver.errors.template_resource_not_found": "Template not found.",
|
|
62
|
+
"templateResolver.errors.invalid_meta": "The template settings are invalid.",
|
|
63
|
+
"templateResolver.errors.unknown_placeholder": "The template uses an unknown placeholder.",
|
|
64
|
+
"templateResolver.errors.missing_required_placeholder": "A required placeholder is missing.",
|
|
65
|
+
"templateResolver.errors.document.frameNotTopLevel": "A frame must sit directly in the document body, not inside another block or a layout region.",
|
|
57
66
|
"templateResolver.errors.document.buttonHrefNotPlaceholder": "The button target “{detail}” must be a placeholder.",
|
|
58
67
|
"templateResolver.errors.document.disallowedLinkHref": "Link target “{detail}” is not allowed; use https, http, mailto, tel, a relative path or a placeholder.",
|
|
59
68
|
"templateResolver.errors.document.relativeLinkWithoutBase": "Link target “{detail}” is relative, but mails and PDF documents have no base address; use an absolute https link.",
|
|
@@ -69,6 +78,16 @@ export const defaultTranslations = {
|
|
|
69
78
|
"templateResolver.checks.sizeUnderCap": "The mail is within the 10 MiB size limit",
|
|
70
79
|
"templateResolver.checks.requiredPlaceholders": "All required placeholders are used",
|
|
71
80
|
"templateResolver.errors.preview.renderFailed": "The preview could not be rendered.",
|
|
81
|
+
"templateResolver.errors.patch.printStyleNotAllowed": "Fonts, sizes, colors, spacing, borders and backgrounds are only available in PDF templates, not in {kind}.",
|
|
82
|
+
"templateResolver.errors.patch.textOrRunsRequired": "Give either text or runs, not both and not neither.",
|
|
83
|
+
"templateResolver.errors.patch.invalidTable": "The table is not valid: {problem}.",
|
|
84
|
+
"templateResolver.errors.patch.invalidRepeatVariable": "The name {each} is not a valid list variable for a repeat row.",
|
|
85
|
+
"templateResolver.errors.patch.tooManyBlocks": "The body may have at most {max} blocks, including the ones inside frames.",
|
|
86
|
+
"templateResolver.errors.patch.regionRequired": "A PDF layout is edited one region at a time; set region to header, signature or footer.",
|
|
87
|
+
"templateResolver.errors.patch.regionNotAllowed": "A region only applies to PDF layouts, not to {kind}.",
|
|
88
|
+
"templateResolver.errors.patch.layoutExists": "A layout with the slug {slug} already exists.",
|
|
89
|
+
"templateResolver.errors.template.reservedLayoutSlug": "The prefix {prefix} is reserved for tenant layouts.",
|
|
90
|
+
"templateResolver.errors.patch.emptyFormat": "Give at least one of align, style or textStyle.",
|
|
72
91
|
"templateResolver.errors.patch.unknownBlock": "The block {blockId} does not exist in the template.",
|
|
73
92
|
"templateResolver.errors.patch.blockRemoved": "The block {blockId} was already removed by an earlier step.",
|
|
74
93
|
"templateResolver.errors.patch.textNotFound": "The text {find} was not found in the block.",
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
export { textBlocksClient } from "./client-plugin.tsx";
|
|
2
2
|
export type { EditableTemplateKind } from "./constants.ts";
|
|
3
|
+
export { COMPANY_PLACEHOLDERS, MAX_SELECTED_TEMPLATES } from "./constants.ts";
|
|
3
4
|
export { DocumentContentEditor } from "./document-editor.tsx";
|
|
4
|
-
export {
|
|
5
|
+
export { DOCUMENT_FONT_LABELS, DOCUMENT_FONT_PRINT_STACKS, DOCUMENT_FONTS, type DocumentFont, } from "./document-fonts.ts";
|
|
6
|
+
export type { DocumentFrameControl } from "./document-frame-control.ts";
|
|
7
|
+
export { COLWIDTH_PX_RANGE, type DocumentFrameAttributes, type DocumentFramePreset, FRAME_MM_RANGE, FRAME_PRESETS, LINE_HEIGHT_RANGE, PARAGRAPH_SPACE_PT_RANGE, TEXT_SIZE_PT_RANGE, } from "./document-print-style.ts";
|
|
8
|
+
export { type DocumentBlockStyle, type DocumentFrameBox, type DocumentTextStyle, documentBlockStyleCss, documentCellStyleCss, documentFrameCss, documentTextStyleCss, } from "./document-style-css.ts";
|
|
9
|
+
export { FONT_SIZES_PT } from "./document-tiptap-helpers.ts";
|
|
10
|
+
export { type DocumentEditorChrome, type DocumentEditorHandle, type DocumentEditorProps, type DocumentLayoutValues, type DocumentPrintBlock, type DocumentPrintMode, type DocumentResourcePreview, type DocumentToolbarBlock, MAIL_DOCUMENT_BLOCKS, PDF_DOCUMENT_BLOCKS, } from "./document-toolbar-blocks.ts";
|
|
5
11
|
export { MAIL_TONES, type MailTone } from "./mail-constants.ts";
|
|
6
12
|
export { HEX_COLOR_PATTERN, MAIL_LAYOUT_ACCENT_LINES, MAIL_LAYOUT_BUTTON_STYLES, MAIL_LAYOUT_FONTS, MAIL_LAYOUT_WIDTHS, } from "./mail-layout-constants.ts";
|
|
7
|
-
export { PDF_DEFAULT_MARGIN_MM, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, } from "./pdf-constants.ts";
|
|
13
|
+
export { PDF_DEFAULT_FONT_SIZE_PT, PDF_DEFAULT_MARGIN_MM, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, PDF_TABLE_STYLES, type PdfTableStyle, } from "./pdf-constants.ts";
|
|
8
14
|
export { PlaceholderLineEditor, type PlaceholderLineEditorProps, } from "./placeholder-line-editor-lazy.tsx";
|
|
9
15
|
export { previewTargetOfKind } from "./preview-targets.ts";
|
|
10
16
|
export { TemplateResolverErrors, TemplateResolverHandlers, TemplateResolverQueries, } from "./qualified-names.ts";
|
|
@@ -4,11 +4,16 @@
|
|
|
4
4
|
// `@cosmicdrift/kumiko-bundled-features/template-resolver` and has no React or
|
|
5
5
|
// DOM deps.
|
|
6
6
|
export { textBlocksClient } from "./client-plugin.js";
|
|
7
|
+
export { COMPANY_PLACEHOLDERS, MAX_SELECTED_TEMPLATES } from "./constants.js";
|
|
7
8
|
export { DocumentContentEditor } from "./document-editor.js";
|
|
9
|
+
export { DOCUMENT_FONT_LABELS, DOCUMENT_FONT_PRINT_STACKS, DOCUMENT_FONTS, } from "./document-fonts.js";
|
|
10
|
+
export { COLWIDTH_PX_RANGE, FRAME_MM_RANGE, FRAME_PRESETS, LINE_HEIGHT_RANGE, PARAGRAPH_SPACE_PT_RANGE, TEXT_SIZE_PT_RANGE, } from "./document-print-style.js";
|
|
11
|
+
export { documentBlockStyleCss, documentCellStyleCss, documentFrameCss, documentTextStyleCss, } from "./document-style-css.js";
|
|
12
|
+
export { FONT_SIZES_PT } from "./document-tiptap-helpers.js";
|
|
8
13
|
export { MAIL_DOCUMENT_BLOCKS, PDF_DOCUMENT_BLOCKS, } from "./document-toolbar-blocks.js";
|
|
9
14
|
export { MAIL_TONES } from "./mail-constants.js";
|
|
10
15
|
export { HEX_COLOR_PATTERN, MAIL_LAYOUT_ACCENT_LINES, MAIL_LAYOUT_BUTTON_STYLES, MAIL_LAYOUT_FONTS, MAIL_LAYOUT_WIDTHS, } from "./mail-layout-constants.js";
|
|
11
|
-
export { PDF_DEFAULT_MARGIN_MM, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, } from "./pdf-constants.js";
|
|
16
|
+
export { PDF_DEFAULT_FONT_SIZE_PT, PDF_DEFAULT_MARGIN_MM, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, PDF_TABLE_STYLES, } from "./pdf-constants.js";
|
|
12
17
|
export { PlaceholderLineEditor, } from "./placeholder-line-editor-lazy.js";
|
|
13
18
|
export { previewTargetOfKind } from "./preview-targets.js";
|
|
14
19
|
export { TemplateResolverErrors, TemplateResolverHandlers, TemplateResolverQueries, } from "./qualified-names.js";
|
|
@@ -5,3 +5,6 @@ export type PdfOrientation = (typeof PDF_ORIENTATIONS)[number];
|
|
|
5
5
|
export declare const PDF_DEFAULT_MARGIN_MM = 15;
|
|
6
6
|
export declare const PDF_HEADER_MARGIN_MM = 30;
|
|
7
7
|
export declare const PDF_FOOTER_MARGIN_MM = 20;
|
|
8
|
+
export declare const PDF_DEFAULT_FONT_SIZE_PT = 10.5;
|
|
9
|
+
export declare const PDF_TABLE_STYLES: readonly ["plain", "lines", "header", "grid"];
|
|
10
|
+
export type PdfTableStyle = (typeof PDF_TABLE_STYLES)[number];
|
|
@@ -5,3 +5,6 @@ export const PDF_ORIENTATIONS = ["portrait", "landscape"];
|
|
|
5
5
|
export const PDF_DEFAULT_MARGIN_MM = 15;
|
|
6
6
|
export const PDF_HEADER_MARGIN_MM = 30;
|
|
7
7
|
export const PDF_FOOTER_MARGIN_MM = 20;
|
|
8
|
+
// Body text size of a printed document; header and footer fall back to it, so no region reads smaller than the body.
|
|
9
|
+
export const PDF_DEFAULT_FONT_SIZE_PT = 10.5;
|
|
10
|
+
export const PDF_TABLE_STYLES = ["plain", "lines", "header", "grid"];
|
|
@@ -18,6 +18,12 @@ export declare const TemplateResolverHandlers: {
|
|
|
18
18
|
readonly resourceLinkPdf: "template-resolver:write:resource-link-pdf";
|
|
19
19
|
readonly sendTest: "template-resolver:write:send-test";
|
|
20
20
|
readonly patchDraft: "template-resolver:write:patch-draft";
|
|
21
|
+
readonly applyLayout: "template-resolver:write:apply-layout";
|
|
22
|
+
readonly createLayout: "template-resolver:write:create-layout";
|
|
23
|
+
readonly publishTemplates: "template-resolver:write:publish-templates";
|
|
24
|
+
};
|
|
25
|
+
export declare const ConfigHandlers: {
|
|
26
|
+
readonly set: "config:write:set";
|
|
21
27
|
};
|
|
22
28
|
export declare const TemplateResolverQueries: {
|
|
23
29
|
readonly findById: "template-resolver:query:find-by-id";
|
|
@@ -51,6 +57,7 @@ export declare const TemplateResolverErrors: {
|
|
|
51
57
|
readonly systemResourcesNeedSystemTenant: "system_resources_need_system_tenant";
|
|
52
58
|
readonly systemOnlyTemplate: "system_only_template";
|
|
53
59
|
readonly templateNotTenantEditable: "template_not_tenant_editable";
|
|
60
|
+
readonly layoutNotPublished: "layout_not_published";
|
|
54
61
|
readonly bundleLocalesDiffer: "bundle_locales_differ";
|
|
55
62
|
readonly resourceTooLarge: "template_resource_too_large";
|
|
56
63
|
readonly resourceUnsupportedImage: "template_resource_unsupported_image";
|
|
@@ -19,7 +19,12 @@ export const TemplateResolverHandlers = {
|
|
|
19
19
|
resourceLinkPdf: "template-resolver:write:resource-link-pdf",
|
|
20
20
|
sendTest: "template-resolver:write:send-test",
|
|
21
21
|
patchDraft: "template-resolver:write:patch-draft",
|
|
22
|
+
applyLayout: "template-resolver:write:apply-layout",
|
|
23
|
+
createLayout: "template-resolver:write:create-layout",
|
|
24
|
+
publishTemplates: "template-resolver:write:publish-templates",
|
|
22
25
|
};
|
|
26
|
+
// The config feature's write handler, which applyLayout dispatches to for the tenant default layout.
|
|
27
|
+
export const ConfigHandlers = { set: "config:write:set" };
|
|
23
28
|
export const TemplateResolverQueries = {
|
|
24
29
|
findById: "template-resolver:query:find-by-id",
|
|
25
30
|
list: "template-resolver:query:list",
|
|
@@ -61,6 +66,7 @@ export const TemplateResolverErrors = {
|
|
|
61
66
|
systemResourcesNeedSystemTenant: "system_resources_need_system_tenant",
|
|
62
67
|
systemOnlyTemplate: "system_only_template",
|
|
63
68
|
templateNotTenantEditable: "template_not_tenant_editable",
|
|
69
|
+
layoutNotPublished: "layout_not_published",
|
|
64
70
|
bundleLocalesDiffer: "bundle_locales_differ",
|
|
65
71
|
resourceTooLarge: "template_resource_too_large",
|
|
66
72
|
resourceUnsupportedImage: "template_resource_unsupported_image",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Translate } from "@cosmicdrift/kumiko-renderer/headless";
|
|
2
2
|
import { type PanelKind } from "./document-tiptap-helpers.ts";
|
|
3
|
-
import type { DocumentEditorProps, DocumentResourcePreview } from "./document-toolbar-blocks.ts";
|
|
3
|
+
import type { DocumentEditorProps, DocumentPrintMode, DocumentResourcePreview } from "./document-toolbar-blocks.ts";
|
|
4
4
|
export declare function documentEditorLabels(t: Translate): {
|
|
5
5
|
placeholderLabel: string;
|
|
6
6
|
imageLabel: string;
|
|
@@ -11,7 +11,8 @@ export declare function documentEditorLabels(t: Translate): {
|
|
|
11
11
|
imagesLabel: string;
|
|
12
12
|
};
|
|
13
13
|
export type DocumentEditorLabels = ReturnType<typeof documentEditorLabels>;
|
|
14
|
-
export type DocumentTiptapModelInput = Pick<DocumentEditorProps, "id" | "value" | "onChange" | "readOnly" | "onEditorReady"> & {
|
|
14
|
+
export type DocumentTiptapModelInput = Pick<DocumentEditorProps, "id" | "value" | "onChange" | "readOnly" | "onEditorReady" | "onFrameControlChange"> & {
|
|
15
|
+
readonly print: DocumentPrintMode;
|
|
15
16
|
readonly variableLabels: Readonly<Record<string, string>>;
|
|
16
17
|
readonly systemVariables: readonly string[];
|
|
17
18
|
readonly resourcePreviews: Readonly<Record<string, DocumentResourcePreview>>;
|
|
@@ -46,5 +47,8 @@ export declare function useDocumentTiptapModel(input: DocumentTiptapModelInput,
|
|
|
46
47
|
orderedList: boolean;
|
|
47
48
|
link: boolean;
|
|
48
49
|
repeatTable: import("./document-tiptap-helpers.ts").RepeatTableState | null;
|
|
50
|
+
textStyle: import("./document-tiptap-helpers.ts").PrintTextStyleState;
|
|
51
|
+
paragraphStyle: import("./document-tiptap-helpers.ts").PrintBlockStyleState;
|
|
52
|
+
printTable: import("./document-tiptap-helpers.ts").PrintTableState | null;
|
|
49
53
|
} | null;
|
|
50
54
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEditor, useEditorState } from "@tiptap/react";
|
|
2
|
-
import { useMemo, useState } from "react";
|
|
2
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { createDocumentEditorExtensions } from "./document-editor-extensions.js";
|
|
4
|
-
import { activeStateOf, previewsKey } from "./document-tiptap-helpers.js";
|
|
4
|
+
import { activeStateOf, previewsKey, variableLabelOf, } from "./document-tiptap-helpers.js";
|
|
5
5
|
import { useEditorHandleReport } from "./editor-handle.js";
|
|
6
6
|
import { useStableByKey } from "./use-stable-by-key.js";
|
|
7
7
|
export function documentEditorLabels(t) {
|
|
@@ -15,8 +15,17 @@ export function documentEditorLabels(t) {
|
|
|
15
15
|
imagesLabel: t("template-resolver.documentEditor.images"),
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
+
function frameLabelsOf(t) {
|
|
19
|
+
return {
|
|
20
|
+
addressFormA: t("documentDesigner.editor.frame.addressFormA"),
|
|
21
|
+
addressFormB: t("documentDesigner.editor.frame.addressFormB"),
|
|
22
|
+
address: t("documentDesigner.editor.frame.address"),
|
|
23
|
+
text: t("documentDesigner.editor.frame.text"),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
18
26
|
function useDocumentExtensions(input) {
|
|
19
|
-
const { canvas, variableLabels, systemVariables, resourcePreviews } = input;
|
|
27
|
+
const { canvas, print, reportFrameControl, repeatStripName, repeatHeaderLabel, variableLabels, systemVariables, resourcePreviews, } = input;
|
|
28
|
+
const frameLabels = useStableByKey(input.frameLabels, JSON.stringify(input.frameLabels ?? null));
|
|
20
29
|
const { placeholderLabel, imageLabel, imageBlockLabel, pageBreakLabel, buttonLabel, stepsLabel, imagesLabel, } = input.labels;
|
|
21
30
|
const stableLabels = useStableByKey(variableLabels, JSON.stringify(variableLabels));
|
|
22
31
|
const stableSystem = useStableByKey(systemVariables, systemVariables.join("\n"));
|
|
@@ -33,6 +42,15 @@ function useDocumentExtensions(input) {
|
|
|
33
42
|
systemVariables: stableSystem,
|
|
34
43
|
resourcePreviews: stablePreviews,
|
|
35
44
|
blockLabels: canvas,
|
|
45
|
+
print,
|
|
46
|
+
reportFrameControl,
|
|
47
|
+
...(print !== "none" && {
|
|
48
|
+
repeatStrip: {
|
|
49
|
+
label: (lists) => repeatStripName(lists.map((list) => variableLabelOf(list, stableLabels)).join(", ")),
|
|
50
|
+
headerLabel: repeatHeaderLabel,
|
|
51
|
+
},
|
|
52
|
+
}),
|
|
53
|
+
...(frameLabels !== undefined && { frameLabels }),
|
|
36
54
|
}), [
|
|
37
55
|
placeholderLabel,
|
|
38
56
|
imageLabel,
|
|
@@ -45,6 +63,11 @@ function useDocumentExtensions(input) {
|
|
|
45
63
|
stableSystem,
|
|
46
64
|
stablePreviews,
|
|
47
65
|
canvas,
|
|
66
|
+
print,
|
|
67
|
+
reportFrameControl,
|
|
68
|
+
repeatStripName,
|
|
69
|
+
repeatHeaderLabel,
|
|
70
|
+
frameLabels,
|
|
48
71
|
]);
|
|
49
72
|
return { extensions, stableLabels };
|
|
50
73
|
}
|
|
@@ -54,9 +77,21 @@ export function useDocumentTiptapModel(input, t) {
|
|
|
54
77
|
const [canvasScroller, setCanvasScroller] = useState(null);
|
|
55
78
|
const [showHtml, setShowHtml] = useState(false);
|
|
56
79
|
const labels = documentEditorLabels(t);
|
|
80
|
+
// Callers pass a fresh function per render; the extension list must not rebuild the editor for it.
|
|
81
|
+
const frameControlRef = useRef(input.onFrameControlChange);
|
|
82
|
+
frameControlRef.current = input.onFrameControlChange;
|
|
83
|
+
const translateRef = useRef(t);
|
|
84
|
+
translateRef.current = t;
|
|
85
|
+
const repeatStripName = useCallback((name) => translateRef.current("documentDesigner.editor.table.repeatStrip", { name }), []);
|
|
86
|
+
const reportFrameControl = useCallback((control) => frameControlRef.current?.(control), []);
|
|
57
87
|
const { extensions, stableLabels } = useDocumentExtensions({
|
|
58
88
|
labels,
|
|
59
89
|
canvas: input.canvas,
|
|
90
|
+
print: input.print,
|
|
91
|
+
frameLabels: input.print === "page" ? frameLabelsOf(t) : undefined,
|
|
92
|
+
reportFrameControl,
|
|
93
|
+
repeatStripName,
|
|
94
|
+
repeatHeaderLabel: t("template-resolver.documentEditor.repeatHeader"),
|
|
60
95
|
variableLabels: input.variableLabels,
|
|
61
96
|
systemVariables: input.systemVariables,
|
|
62
97
|
resourcePreviews: input.resourcePreviews,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ConfigKeyDefinition } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
export declare const COMPANY_DATA_KEYS: readonly ["companyAddress", "companyPhone", "companyEmail", "companyWebsite", "companyRegister", "companyVatId", "companyManagement", "companyBank", "companyIban", "companyBic"];
|
|
3
|
+
export type CompanyDataKey = (typeof COMPANY_DATA_KEYS)[number];
|
|
4
|
+
export declare const COMPANY_SECTION_I18N_KEY = "tenant.company.section";
|
|
5
|
+
export declare function companyI18nKey(key: CompanyDataKey): string;
|
|
6
|
+
export declare function companyDataConfig(key: CompanyDataKey): ConfigKeyDefinition<"text">;
|