@cosmicdrift/kumiko-samples 0.419.0 → 0.420.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/package.json +1 -1
- package/packages/bundled-features/package.json +6 -1
- package/packages/bundled-features/src/shared/index.ts +6 -0
- package/packages/bundled-features/src/shared/tenant-scoped-subject.ts +28 -0
- package/packages/bundled-features/src/signature/changes.json +6 -0
- package/packages/bundled-features/src/signature/feature.ts +1 -1
- package/packages/bundled-features/src/signature/grant.ts +13 -14
- package/packages/bundled-features/src/signature/png.ts +33 -12
- package/packages/bundled-features/src/template-resolver/api.ts +17 -7
- package/packages/bundled-features/src/template-resolver/changes.json +24 -0
- package/packages/bundled-features/src/template-resolver/compile-document-body.ts +7 -1
- package/packages/bundled-features/src/template-resolver/compile-document-styles.ts +70 -2
- package/packages/bundled-features/src/template-resolver/document-frames.ts +43 -0
- package/packages/bundled-features/src/template-resolver/document-op-blocks.ts +135 -21
- package/packages/bundled-features/src/template-resolver/document-ops.ts +35 -3
- package/packages/bundled-features/src/template-resolver/document-print-only.ts +24 -0
- package/packages/bundled-features/src/template-resolver/document-sanitizer.ts +13 -1
- package/packages/bundled-features/src/template-resolver/handlers/create-layout.write.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/patch-draft.write.ts +2 -1
- package/packages/bundled-features/src/template-resolver/handlers/tenant-settings.ts +51 -14
- package/packages/bundled-features/src/template-resolver/index.ts +11 -1
- package/packages/bundled-features/src/template-resolver/template-meta.ts +7 -1
- package/packages/bundled-features/src/template-resolver/template-preview.ts +25 -4
- package/packages/bundled-features/src/template-resolver/web/constants.ts +4 -0
- package/packages/bundled-features/src/template-resolver/web/document-editor-extensions.ts +60 -24
- package/packages/bundled-features/src/template-resolver/web/document-editor.tsx +4 -1
- package/packages/bundled-features/src/template-resolver/web/document-print-decorations.ts +55 -5
- package/packages/bundled-features/src/template-resolver/web/document-print-style.ts +137 -2
- package/packages/bundled-features/src/template-resolver/web/document-repeat-strip.ts +2 -26
- package/packages/bundled-features/src/template-resolver/web/document-schema.ts +61 -13
- package/packages/bundled-features/src/template-resolver/web/document-style-css.ts +109 -2
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-bubble.tsx +161 -14
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-content.tsx +4 -0
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-editor.tsx +2 -1
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-helpers.ts +132 -24
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-toolbar-groups.tsx +160 -1
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-toolbar.tsx +18 -9
- package/packages/bundled-features/src/template-resolver/web/i18n.ts +4 -0
- package/packages/bundled-features/src/template-resolver/web/index.ts +4 -0
- package/packages/bundled-features/src/template-resolver/web/pdf-constants.ts +10 -0
- package/packages/bundled-features/src/template-resolver/web/placeholder-text.ts +6 -3
- package/samples/apps/ui-walkthrough/src/features/rental/i18n.ts +8 -0
- package/samples/apps/ui-walkthrough/src/features/rental/screens.ts +1 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { usePrimitives } from "@cosmicdrift/kumiko-renderer";
|
|
2
2
|
import { isOneOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
3
3
|
import type { Editor, JSONContent } from "@tiptap/core";
|
|
4
|
+
import type { Node as ProseMirrorNode } from "@tiptap/pm/model";
|
|
4
5
|
import {
|
|
5
6
|
addressFrameContent,
|
|
6
7
|
columnsTableContent,
|
|
7
8
|
insertFrame,
|
|
8
9
|
textFrameContent,
|
|
9
10
|
} from "./document-frame-control.ts";
|
|
11
|
+
import { readRowLineAttributes } from "./document-print-style.ts";
|
|
12
|
+
import type { DocumentRowLine } from "./document-style-css.ts";
|
|
10
13
|
import type {
|
|
11
14
|
DocumentPrintBlock,
|
|
12
15
|
DocumentPrintMode,
|
|
@@ -75,8 +78,15 @@ export type PrintBlockStyleState = {
|
|
|
75
78
|
export type PrintTableState = {
|
|
76
79
|
readonly bordersOff: boolean;
|
|
77
80
|
readonly cellBackground: string | null;
|
|
81
|
+
readonly cellPaddingMm: number | null;
|
|
82
|
+
readonly widthMm: number | null;
|
|
83
|
+
readonly align: string | null;
|
|
84
|
+
readonly lineAbove: DocumentRowLine | null;
|
|
85
|
+
readonly lineBelow: DocumentRowLine | null;
|
|
78
86
|
};
|
|
79
87
|
|
|
88
|
+
export const DEFAULT_ROW_LINE: DocumentRowLine = { color: "#000000", weightPt: 0.5 };
|
|
89
|
+
|
|
80
90
|
const TEXT_STYLE_MARK = "documentTextStyle";
|
|
81
91
|
|
|
82
92
|
function stringOrNull(value: unknown): string | null {
|
|
@@ -128,7 +138,53 @@ function printTableOf(e: Editor): PrintTableState | null {
|
|
|
128
138
|
break;
|
|
129
139
|
}
|
|
130
140
|
}
|
|
131
|
-
|
|
141
|
+
const row = readRowLineAttributes(rowNodeOf(e)?.attrs ?? {});
|
|
142
|
+
return {
|
|
143
|
+
bordersOff: table.attrs["borders"] === "none",
|
|
144
|
+
cellBackground,
|
|
145
|
+
cellPaddingMm: numberOrNull(table.attrs["cellPaddingMm"]),
|
|
146
|
+
widthMm: numberOrNull(table.attrs["widthMm"]),
|
|
147
|
+
align: stringOrNull(table.attrs["align"]),
|
|
148
|
+
lineAbove: row.lineAbove,
|
|
149
|
+
lineBelow: row.lineBelow,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function rowNodeOf(e: Editor): ProseMirrorNode | null {
|
|
154
|
+
const { $from } = e.state.selection;
|
|
155
|
+
for (let depth = $from.depth; depth > 0; depth--) {
|
|
156
|
+
if ($from.node(depth).type.name === "tableRow") return $from.node(depth);
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// The table's own print attributes; an empty field removes the attribute again.
|
|
162
|
+
export function setTableAttributes(
|
|
163
|
+
editor: Editor,
|
|
164
|
+
attributes: Readonly<Record<string, unknown>>,
|
|
165
|
+
): void {
|
|
166
|
+
const table = tableLocationOf(editor);
|
|
167
|
+
if (table === null) return;
|
|
168
|
+
editor
|
|
169
|
+
.chain()
|
|
170
|
+
.focus()
|
|
171
|
+
.command(({ tr }) => {
|
|
172
|
+
tr.setNodeMarkup(table.pos, undefined, { ...table.attrs, ...attributes });
|
|
173
|
+
return true;
|
|
174
|
+
})
|
|
175
|
+
.run();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function setRowLine(
|
|
179
|
+
editor: Editor,
|
|
180
|
+
edge: "lineAbove" | "lineBelow",
|
|
181
|
+
line: DocumentRowLine | null,
|
|
182
|
+
): void {
|
|
183
|
+
editor
|
|
184
|
+
.chain()
|
|
185
|
+
.focus()
|
|
186
|
+
.updateAttributes("tableRow", { [edge]: line })
|
|
187
|
+
.run();
|
|
132
188
|
}
|
|
133
189
|
|
|
134
190
|
type TextStylePatch = { readonly [K in keyof PrintTextStyleState]?: PrintTextStyleState[K] };
|
|
@@ -178,6 +234,31 @@ export type RepeatTableState = {
|
|
|
178
234
|
readonly firstRowPos: number;
|
|
179
235
|
};
|
|
180
236
|
|
|
237
|
+
export function repeatListsOf(table: ProseMirrorNode): string[] {
|
|
238
|
+
const lists: string[] = [];
|
|
239
|
+
table.forEach((row) => {
|
|
240
|
+
const each: unknown = row.attrs["each"];
|
|
241
|
+
if (typeof each === "string" && each !== "" && !lists.includes(each)) lists.push(each);
|
|
242
|
+
});
|
|
243
|
+
return lists;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function toggleRepeatHeaderAt(editor: Editor, firstRowPos: number): void {
|
|
247
|
+
editor
|
|
248
|
+
.chain()
|
|
249
|
+
.focus()
|
|
250
|
+
.command(({ tr }) => {
|
|
251
|
+
const row = tr.doc.nodeAt(firstRowPos);
|
|
252
|
+
if (row === null) return false;
|
|
253
|
+
tr.setNodeMarkup(firstRowPos, undefined, {
|
|
254
|
+
...row.attrs,
|
|
255
|
+
repeatHeader: row.attrs["repeatHeader"] !== true,
|
|
256
|
+
});
|
|
257
|
+
return true;
|
|
258
|
+
})
|
|
259
|
+
.run();
|
|
260
|
+
}
|
|
261
|
+
|
|
181
262
|
// print-document moves the leading rows flagged repeatHeader into thead, so the
|
|
182
263
|
// toggle reads and writes the table's first row.
|
|
183
264
|
export function findRepeatTable(editor: Editor): RepeatTableState | null {
|
|
@@ -185,11 +266,7 @@ export function findRepeatTable(editor: Editor): RepeatTableState | null {
|
|
|
185
266
|
for (let depth = $from.depth; depth > 0; depth--) {
|
|
186
267
|
const node = $from.node(depth);
|
|
187
268
|
if (node.type.name !== "table") continue;
|
|
188
|
-
const lists
|
|
189
|
-
node.forEach((row) => {
|
|
190
|
-
const each: unknown = row.attrs["each"];
|
|
191
|
-
if (typeof each === "string" && each !== "" && !lists.includes(each)) lists.push(each);
|
|
192
|
-
});
|
|
269
|
+
const lists = repeatListsOf(node);
|
|
193
270
|
if (lists.length === 0) return null;
|
|
194
271
|
return {
|
|
195
272
|
lists,
|
|
@@ -204,19 +281,7 @@ export function toggleRepeatHeader(editor: Editor): void {
|
|
|
204
281
|
const found = findRepeatTable(editor);
|
|
205
282
|
// skip: the cursor is not inside a repeat table
|
|
206
283
|
if (found === null) return;
|
|
207
|
-
editor
|
|
208
|
-
.chain()
|
|
209
|
-
.focus()
|
|
210
|
-
.command(({ tr }) => {
|
|
211
|
-
const row = tr.doc.nodeAt(found.firstRowPos);
|
|
212
|
-
if (row === null) return false;
|
|
213
|
-
tr.setNodeMarkup(found.firstRowPos, undefined, {
|
|
214
|
-
...row.attrs,
|
|
215
|
-
repeatHeader: !found.headerRepeats,
|
|
216
|
-
});
|
|
217
|
-
return true;
|
|
218
|
-
})
|
|
219
|
-
.run();
|
|
284
|
+
toggleRepeatHeaderAt(editor, found.firstRowPos);
|
|
220
285
|
}
|
|
221
286
|
|
|
222
287
|
const PARAGRAPH_STYLES = ["paragraph", "1", "2", "3"] as const;
|
|
@@ -272,12 +337,37 @@ function blockStyleOf(e: Editor): "1" | "2" | "3" | "paragraph" {
|
|
|
272
337
|
function selectedBlockOf(e: Editor): SelectedBlock | null {
|
|
273
338
|
if (e.isActive("resource")) {
|
|
274
339
|
const attrs = e.getAttributes("resource");
|
|
275
|
-
return {
|
|
340
|
+
return {
|
|
341
|
+
type: "resource",
|
|
342
|
+
detail: String(attrs["resource"]),
|
|
343
|
+
bleed: attrs["bleed"] === true,
|
|
344
|
+
widthMm: numberOrNull(attrs["widthMm"]),
|
|
345
|
+
align: stringOrNull(attrs["align"]),
|
|
346
|
+
};
|
|
276
347
|
}
|
|
277
348
|
if (e.isActive("button")) {
|
|
278
|
-
return {
|
|
349
|
+
return {
|
|
350
|
+
type: "button",
|
|
351
|
+
detail: String(e.getAttributes("button")["href"]),
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
if (e.isActive("divider")) {
|
|
355
|
+
const attrs = e.getAttributes("divider");
|
|
356
|
+
return {
|
|
357
|
+
type: "divider",
|
|
358
|
+
color: stringOrNull(attrs["color"]),
|
|
359
|
+
weightPt: numberOrNull(attrs["weightPt"]),
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
if (e.isActive("variable")) {
|
|
363
|
+
const attrs = e.getAttributes("variable");
|
|
364
|
+
return {
|
|
365
|
+
type: "variable",
|
|
366
|
+
detail: String(attrs["name"]),
|
|
367
|
+
dateStyle: stringOrNull(attrs["dateStyle"]),
|
|
368
|
+
};
|
|
279
369
|
}
|
|
280
|
-
return null; // skip: no resource or
|
|
370
|
+
return null; // skip: no resource, button, divider or placeholder selected
|
|
281
371
|
}
|
|
282
372
|
|
|
283
373
|
export function activeStateOf(e: Editor, showHtml: boolean) {
|
|
@@ -300,10 +390,28 @@ export function activeStateOf(e: Editor, showHtml: boolean) {
|
|
|
300
390
|
|
|
301
391
|
export type Primitives = ReturnType<typeof usePrimitives>;
|
|
302
392
|
|
|
303
|
-
export type
|
|
304
|
-
readonly type: "resource"
|
|
393
|
+
export type ResourceBlock = {
|
|
394
|
+
readonly type: "resource";
|
|
305
395
|
readonly detail: string;
|
|
306
396
|
readonly bleed: boolean;
|
|
397
|
+
readonly widthMm: number | null;
|
|
398
|
+
readonly align: string | null;
|
|
399
|
+
};
|
|
400
|
+
export type ButtonBlock = { readonly type: "button"; readonly detail: string };
|
|
401
|
+
export type DividerBlock = {
|
|
402
|
+
readonly type: "divider";
|
|
403
|
+
readonly color: string | null;
|
|
404
|
+
readonly weightPt: number | null;
|
|
307
405
|
};
|
|
406
|
+
export type VariableBlock = {
|
|
407
|
+
readonly type: "variable";
|
|
408
|
+
readonly detail: string;
|
|
409
|
+
readonly dateStyle: string | null;
|
|
410
|
+
};
|
|
411
|
+
export type SelectedBlock = ResourceBlock | ButtonBlock | DividerBlock | VariableBlock;
|
|
412
|
+
|
|
413
|
+
export function addPlainRowBelow(editor: Editor): void {
|
|
414
|
+
editor.chain().focus().addRowAfter().run();
|
|
415
|
+
}
|
|
308
416
|
|
|
309
417
|
export type ActiveState = ReturnType<typeof activeStateOf>;
|
package/packages/bundled-features/src/template-resolver/web/document-tiptap-toolbar-groups.tsx
CHANGED
|
@@ -11,13 +11,25 @@ import {
|
|
|
11
11
|
} from "lucide-react";
|
|
12
12
|
import type { ReactNode } from "react";
|
|
13
13
|
import { DOCUMENT_FONT_LABELS, DOCUMENT_FONTS } from "./document-fonts.ts";
|
|
14
|
+
import {
|
|
15
|
+
CELL_PADDING_MM_RANGE,
|
|
16
|
+
DIVIDER_WEIGHT_PT_RANGE,
|
|
17
|
+
DOCUMENT_TABLE_ALIGNMENTS,
|
|
18
|
+
TABLE_WIDTH_MM_RANGE,
|
|
19
|
+
} from "./document-print-style.ts";
|
|
20
|
+
import type { DocumentRowLine } from "./document-style-css.ts";
|
|
14
21
|
import type { TiptapContext } from "./document-tiptap-context.ts";
|
|
15
22
|
import {
|
|
23
|
+
addPlainRowBelow,
|
|
24
|
+
DEFAULT_ROW_LINE,
|
|
16
25
|
FONT_SIZES_PT,
|
|
17
26
|
LINE_HEIGHTS,
|
|
18
27
|
PARAGRAPH_SPACES_PT,
|
|
28
|
+
type PrintTableState,
|
|
19
29
|
setPrintBlockStyle,
|
|
20
30
|
setPrintTextStyle,
|
|
31
|
+
setRowLine,
|
|
32
|
+
setTableAttributes,
|
|
21
33
|
toggleTableBorders,
|
|
22
34
|
} from "./document-tiptap-helpers.ts";
|
|
23
35
|
|
|
@@ -243,7 +255,7 @@ function printSelect(c: TiptapContext, spec: PrintSelectSpec): ReactNode {
|
|
|
243
255
|
);
|
|
244
256
|
}
|
|
245
257
|
|
|
246
|
-
function colorPicker(
|
|
258
|
+
export function colorPicker(
|
|
247
259
|
c: TiptapContext,
|
|
248
260
|
testId: string,
|
|
249
261
|
label: string,
|
|
@@ -373,6 +385,124 @@ export function renderPrintTextStyleGroup(c: TiptapContext): ReactNode {
|
|
|
373
385
|
);
|
|
374
386
|
}
|
|
375
387
|
|
|
388
|
+
const NUMBER_FIELD_CLASS = "w-16 [&_input]:h-5 [&_input]:px-1 [&_input]:text-[10px]";
|
|
389
|
+
|
|
390
|
+
export function renderNumberField(
|
|
391
|
+
c: TiptapContext,
|
|
392
|
+
spec: {
|
|
393
|
+
readonly id: string;
|
|
394
|
+
readonly label: string;
|
|
395
|
+
readonly value: number | null;
|
|
396
|
+
readonly range: { readonly min: number; readonly max: number };
|
|
397
|
+
readonly onChange: (value: number | null) => void;
|
|
398
|
+
},
|
|
399
|
+
): ReactNode {
|
|
400
|
+
const { Field, Input } = c;
|
|
401
|
+
return (
|
|
402
|
+
<span className="inline-flex items-center gap-1" data-testid={`${spec.id}-field`}>
|
|
403
|
+
<span className="whitespace-nowrap text-xs text-muted-foreground">{spec.label}</span>
|
|
404
|
+
<span className={NUMBER_FIELD_CLASS}>
|
|
405
|
+
<Field id={`${c.id}-${spec.id}`} label={spec.label} hideLabel>
|
|
406
|
+
<Input
|
|
407
|
+
kind="number"
|
|
408
|
+
id={`${c.id}-${spec.id}`}
|
|
409
|
+
name={spec.id}
|
|
410
|
+
value={spec.value ?? ""}
|
|
411
|
+
onChange={(value) =>
|
|
412
|
+
spec.onChange(
|
|
413
|
+
value === null || value === undefined
|
|
414
|
+
? null
|
|
415
|
+
: Math.min(spec.range.max, Math.max(spec.range.min, value)),
|
|
416
|
+
)
|
|
417
|
+
}
|
|
418
|
+
testId={spec.id}
|
|
419
|
+
/>
|
|
420
|
+
</Field>
|
|
421
|
+
</span>
|
|
422
|
+
</span>
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function renderRowLineControls(
|
|
427
|
+
c: TiptapContext,
|
|
428
|
+
edge: "lineAbove" | "lineBelow",
|
|
429
|
+
line: DocumentRowLine | null,
|
|
430
|
+
): ReactNode {
|
|
431
|
+
const { t, editor, Button } = c;
|
|
432
|
+
const id = edge === "lineAbove" ? "document-row-line-above" : "document-row-line-below";
|
|
433
|
+
const label = t(`documentDesigner.editor.table.${edge}`);
|
|
434
|
+
return (
|
|
435
|
+
<>
|
|
436
|
+
<EditorToolbarPill>
|
|
437
|
+
<Button
|
|
438
|
+
type="button"
|
|
439
|
+
variant="ghost"
|
|
440
|
+
size="sm"
|
|
441
|
+
pressed={line !== null}
|
|
442
|
+
disabled={c.readOnly}
|
|
443
|
+
testId={id}
|
|
444
|
+
onClick={() => setRowLine(editor, edge, line === null ? DEFAULT_ROW_LINE : null)}
|
|
445
|
+
>
|
|
446
|
+
{label}
|
|
447
|
+
</Button>
|
|
448
|
+
</EditorToolbarPill>
|
|
449
|
+
{line !== null && (
|
|
450
|
+
<>
|
|
451
|
+
{colorPicker(c, `${id}-color`, label, line.color, (color) =>
|
|
452
|
+
setRowLine(editor, edge, { ...line, color: color ?? line.color }),
|
|
453
|
+
)}
|
|
454
|
+
{renderNumberField(c, {
|
|
455
|
+
id: `${id}-weight`,
|
|
456
|
+
label: t("documentDesigner.editor.table.lineWeight"),
|
|
457
|
+
value: line.weightPt,
|
|
458
|
+
range: DIVIDER_WEIGHT_PT_RANGE,
|
|
459
|
+
onChange: (weightPt) =>
|
|
460
|
+
setRowLine(editor, edge, { ...line, weightPt: weightPt ?? line.weightPt }),
|
|
461
|
+
})}
|
|
462
|
+
</>
|
|
463
|
+
)}
|
|
464
|
+
</>
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function renderTableLayoutControls(c: TiptapContext, table: PrintTableState): ReactNode {
|
|
469
|
+
const { t, editor, Button } = c;
|
|
470
|
+
return (
|
|
471
|
+
<EditorToolbarPill>
|
|
472
|
+
{renderNumberField(c, {
|
|
473
|
+
id: "document-table-padding",
|
|
474
|
+
label: t("documentDesigner.editor.table.cellPadding"),
|
|
475
|
+
value: table.cellPaddingMm,
|
|
476
|
+
range: CELL_PADDING_MM_RANGE,
|
|
477
|
+
onChange: (cellPaddingMm) => setTableAttributes(editor, { cellPaddingMm }),
|
|
478
|
+
})}
|
|
479
|
+
{renderNumberField(c, {
|
|
480
|
+
id: "document-table-width",
|
|
481
|
+
label: t("documentDesigner.editor.table.width"),
|
|
482
|
+
value: table.widthMm,
|
|
483
|
+
range: TABLE_WIDTH_MM_RANGE,
|
|
484
|
+
onChange: (widthMm) => setTableAttributes(editor, { widthMm }),
|
|
485
|
+
})}
|
|
486
|
+
{DOCUMENT_TABLE_ALIGNMENTS.map((align) => (
|
|
487
|
+
<Button
|
|
488
|
+
key={align}
|
|
489
|
+
type="button"
|
|
490
|
+
variant="ghost"
|
|
491
|
+
size="sm"
|
|
492
|
+
pressed={table.align === align}
|
|
493
|
+
disabled={c.readOnly}
|
|
494
|
+
testId={`document-table-align-${align}`}
|
|
495
|
+
onClick={() =>
|
|
496
|
+
setTableAttributes(editor, { align: table.align === align ? null : align })
|
|
497
|
+
}
|
|
498
|
+
>
|
|
499
|
+
{t(`documentDesigner.editor.imageAlign.${align}`)}
|
|
500
|
+
</Button>
|
|
501
|
+
))}
|
|
502
|
+
</EditorToolbarPill>
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
|
|
376
506
|
export function renderPrintTableGroup(c: TiptapContext): ReactNode {
|
|
377
507
|
const { t, editor, Button } = c;
|
|
378
508
|
const table = c.activeState?.printTable ?? null;
|
|
@@ -392,6 +522,9 @@ export function renderPrintTableGroup(c: TiptapContext): ReactNode {
|
|
|
392
522
|
{t("documentDesigner.editor.tableBorders")}
|
|
393
523
|
</Button>
|
|
394
524
|
</EditorToolbarPill>
|
|
525
|
+
{renderTableLayoutControls(c, table)}
|
|
526
|
+
{renderRowLineControls(c, "lineAbove", table.lineAbove)}
|
|
527
|
+
{renderRowLineControls(c, "lineBelow", table.lineBelow)}
|
|
395
528
|
{colorPicker(
|
|
396
529
|
c,
|
|
397
530
|
"document-cell-color",
|
|
@@ -399,6 +532,32 @@ export function renderPrintTableGroup(c: TiptapContext): ReactNode {
|
|
|
399
532
|
table.cellBackground,
|
|
400
533
|
(color) => editor.chain().focus().setCellAttribute("background", color).run(),
|
|
401
534
|
)}
|
|
535
|
+
<EditorToolbarPill>
|
|
536
|
+
<Button
|
|
537
|
+
type="button"
|
|
538
|
+
variant="ghost"
|
|
539
|
+
size="sm"
|
|
540
|
+
disabled={c.readOnly}
|
|
541
|
+
testId="document-table-add-row"
|
|
542
|
+
onClick={() => addPlainRowBelow(editor)}
|
|
543
|
+
>
|
|
544
|
+
{t("documentDesigner.editor.table.addRow")}
|
|
545
|
+
</Button>
|
|
546
|
+
</EditorToolbarPill>
|
|
547
|
+
<EditorToolbarPill>
|
|
548
|
+
<Button
|
|
549
|
+
type="button"
|
|
550
|
+
variant="ghost"
|
|
551
|
+
size="sm"
|
|
552
|
+
disabled={c.readOnly}
|
|
553
|
+
testId="document-table-remove-row"
|
|
554
|
+
onClick={() => {
|
|
555
|
+
editor.chain().focus().deleteRow().run();
|
|
556
|
+
}}
|
|
557
|
+
>
|
|
558
|
+
{t("documentDesigner.editor.table.removeRow")}
|
|
559
|
+
</Button>
|
|
560
|
+
</EditorToolbarPill>
|
|
402
561
|
<EditorToolbarPill>
|
|
403
562
|
<Button
|
|
404
563
|
type="button"
|
|
@@ -212,6 +212,23 @@ export function renderToolbarBar(c: TiptapContext): ReactNode {
|
|
|
212
212
|
);
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
+
function renderPlaceholderButton(c: TiptapContext): ReactNode {
|
|
216
|
+
if (c.variables.length === 0) return null;
|
|
217
|
+
return (
|
|
218
|
+
<>
|
|
219
|
+
<Separator compact={c.compact || c.canvas} />
|
|
220
|
+
{labelledButton(c, {
|
|
221
|
+
label: c.t("template-resolver.documentEditor.insertPlaceholder"),
|
|
222
|
+
icon: <Braces size={16} />,
|
|
223
|
+
showIcon: true,
|
|
224
|
+
trailingIcon: c.canvas ? <ChevronDown size={12} /> : undefined,
|
|
225
|
+
expanded: c.openPanel === "placeholder",
|
|
226
|
+
onClick: () => c.togglePanel("placeholder"),
|
|
227
|
+
})}
|
|
228
|
+
</>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
215
232
|
function renderMainToolbarRow(c: TiptapContext): ReactNode {
|
|
216
233
|
const { t, id, canvas, compact, ActionOverflowMenu } = c;
|
|
217
234
|
const blockButtons = blockButtonsOf(c);
|
|
@@ -237,15 +254,7 @@ function renderMainToolbarRow(c: TiptapContext): ReactNode {
|
|
|
237
254
|
{renderMarkButtons(c)}
|
|
238
255
|
<Separator compact={compact || canvas} />
|
|
239
256
|
{renderListButtons(c)}
|
|
240
|
-
|
|
241
|
-
{labelledButton(c, {
|
|
242
|
-
label: t("template-resolver.documentEditor.insertPlaceholder"),
|
|
243
|
-
icon: <Braces size={16} />,
|
|
244
|
-
showIcon: true,
|
|
245
|
-
trailingIcon: canvas ? <ChevronDown size={12} /> : undefined,
|
|
246
|
-
expanded: c.openPanel === "placeholder",
|
|
247
|
-
onClick: () => c.togglePanel("placeholder"),
|
|
248
|
-
})}
|
|
257
|
+
{renderPlaceholderButton(c)}
|
|
249
258
|
{inlineBlocks.length > 0 && <Separator compact={compact || canvas} />}
|
|
250
259
|
{inlineBlocks.map((block) => renderInlineBlock(c, block, blockButtons))}
|
|
251
260
|
{c.print !== "none" && <Separator compact={compact || canvas} />}
|
|
@@ -72,6 +72,8 @@ export const defaultTranslations: TranslationsByLocale = {
|
|
|
72
72
|
"templateResolver.errors.missing_required_placeholder": "A required placeholder is missing.",
|
|
73
73
|
"templateResolver.errors.document.frameNotTopLevel":
|
|
74
74
|
"A frame must sit directly in the document body, not inside another block or a layout region.",
|
|
75
|
+
"templateResolver.errors.document.frameOutsidePage":
|
|
76
|
+
"The frame “{detail}” extends past the largest supported paper size.",
|
|
75
77
|
"templateResolver.errors.document.buttonHrefNotPlaceholder":
|
|
76
78
|
"The button target “{detail}” must be a placeholder.",
|
|
77
79
|
"templateResolver.errors.document.disallowedLinkHref":
|
|
@@ -126,6 +128,8 @@ export const defaultTranslations: TranslationsByLocale = {
|
|
|
126
128
|
"The placeholder {find} cannot be replaced as text; set the text around it with another operation or remove the block.",
|
|
127
129
|
"templateResolver.errors.patch.blockNotAllowed":
|
|
128
130
|
"The block type {type} is not available in {kind} templates.",
|
|
131
|
+
"templateResolver.errors.patch.bleedNotAllowed":
|
|
132
|
+
"An image can only run to the paper edge (bleed) in the header or footer of a PDF layout, not in {kind}.",
|
|
129
133
|
"templateResolver.errors.patch.blockTypeMismatch":
|
|
130
134
|
"This step needs a {expected} block, but the block is a {actual}.",
|
|
131
135
|
"templateResolver.errors.patch.invalidResourceKey": "The image key {resource} is not valid.",
|
|
@@ -56,13 +56,17 @@ export {
|
|
|
56
56
|
MAIL_LAYOUT_WIDTHS,
|
|
57
57
|
} from "./mail-layout-constants.ts";
|
|
58
58
|
export {
|
|
59
|
+
PDF_CORNER_MARK_INSET_MM,
|
|
60
|
+
PDF_CORNER_MARK_LEG_MM,
|
|
59
61
|
PDF_DEFAULT_FONT_SIZE_PT,
|
|
60
62
|
PDF_DEFAULT_MARGIN_MM,
|
|
63
|
+
PDF_FOLD_MARKS,
|
|
61
64
|
PDF_FOOTER_MARGIN_MM,
|
|
62
65
|
PDF_HEADER_MARGIN_MM,
|
|
63
66
|
PDF_ORIENTATIONS,
|
|
64
67
|
PDF_PAGE_FORMATS,
|
|
65
68
|
PDF_TABLE_STYLES,
|
|
69
|
+
type PdfFoldMarks,
|
|
66
70
|
type PdfTableStyle,
|
|
67
71
|
} from "./pdf-constants.ts";
|
|
68
72
|
export {
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
export const PDF_PAGE_FORMATS = ["A4", "Letter"] as const;
|
|
3
3
|
export type PdfPageFormat = (typeof PDF_PAGE_FORMATS)[number];
|
|
4
4
|
|
|
5
|
+
// Long edge of the largest supported paper; the sanitizer has no template meta, so a frame is held to this on both axes.
|
|
6
|
+
export const PDF_MAX_PAGE_EDGE_MM = 297;
|
|
7
|
+
|
|
5
8
|
export const PDF_ORIENTATIONS = ["portrait", "landscape"] as const;
|
|
6
9
|
export type PdfOrientation = (typeof PDF_ORIENTATIONS)[number];
|
|
7
10
|
|
|
@@ -13,5 +16,12 @@ export const PDF_FOOTER_MARGIN_MM = 20;
|
|
|
13
16
|
// Body text size of a printed document; header and footer fall back to it, so no region reads smaller than the body.
|
|
14
17
|
export const PDF_DEFAULT_FONT_SIZE_PT = 10.5;
|
|
15
18
|
|
|
19
|
+
export const PDF_FOLD_MARKS = ["none", "din-a", "din-b"] as const;
|
|
20
|
+
export type PdfFoldMarks = (typeof PDF_FOLD_MARKS)[number];
|
|
21
|
+
|
|
16
22
|
export const PDF_TABLE_STYLES = ["plain", "lines", "header", "grid"] as const;
|
|
17
23
|
export type PdfTableStyle = (typeof PDF_TABLE_STYLES)[number];
|
|
24
|
+
|
|
25
|
+
// Corner marks: an angle in each paper corner, its vertex this far from both edges and its legs running toward the sheet's centre.
|
|
26
|
+
export const PDF_CORNER_MARK_INSET_MM = 10;
|
|
27
|
+
export const PDF_CORNER_MARK_LEG_MM = 5;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { JSONContent } from "@tiptap/core";
|
|
2
|
-
import { isDocumentReferenceName } from "./document-schema.ts";
|
|
2
|
+
import { type DocumentDateStyle, isDocumentReferenceName } from "./document-schema.ts";
|
|
3
3
|
|
|
4
4
|
const PLACEHOLDER_TOKEN = /\{\{([^{}]*)\}\}/g;
|
|
5
5
|
|
|
6
6
|
// Names the schema refuses stay plain text, so a typo never becomes a chip
|
|
7
7
|
// that the server would reject.
|
|
8
|
-
export function lineToContent(text: string): JSONContent[] {
|
|
8
|
+
export function lineToContent(text: string, dateStyle?: DocumentDateStyle): JSONContent[] {
|
|
9
9
|
const content: JSONContent[] = [];
|
|
10
10
|
let cursor = 0;
|
|
11
11
|
const pushText = (value: string): void => {
|
|
@@ -15,7 +15,10 @@ export function lineToContent(text: string): JSONContent[] {
|
|
|
15
15
|
const name = match[1] ?? "";
|
|
16
16
|
if (!isDocumentReferenceName(name)) continue;
|
|
17
17
|
pushText(text.slice(cursor, match.index));
|
|
18
|
-
content.push({
|
|
18
|
+
content.push({
|
|
19
|
+
type: "variable",
|
|
20
|
+
attrs: dateStyle === undefined ? { name } : { name, dateStyle },
|
|
21
|
+
});
|
|
19
22
|
cursor = match.index + match[0].length;
|
|
20
23
|
}
|
|
21
24
|
pushText(text.slice(cursor));
|
|
@@ -89,7 +89,11 @@ export const rentalTranslations: TranslationsByLocale = {
|
|
|
89
89
|
"rental:entity:lease:field:vorgaenger": "Vorgänger",
|
|
90
90
|
"rental:entity:lease:field:status": "Status",
|
|
91
91
|
"rental:entity:lease:field:status:option:active": "Aktiv",
|
|
92
|
+
"rental:entity:lease:field:status:option:active:help":
|
|
93
|
+
"Der Vertrag läuft und die Miete wird gebucht.",
|
|
92
94
|
"rental:entity:lease:field:status:option:terminated": "Gekündigt",
|
|
95
|
+
"rental:entity:lease:field:status:option:terminated:help":
|
|
96
|
+
"Der Vertrag ist gekündigt und endet zum eingetragenen Datum.",
|
|
93
97
|
"rental:entity:lease:field:grundmiete": "Grundmiete pro Monat",
|
|
94
98
|
"rental:entity:lease:field:kuendigungsfrist": "Kündigungsfrist",
|
|
95
99
|
"rental:entity:lease:field:zahltag": "Zahltag",
|
|
@@ -252,7 +256,11 @@ export const rentalTranslations: TranslationsByLocale = {
|
|
|
252
256
|
"rental:entity:lease:field:vorgaenger": "Predecessor",
|
|
253
257
|
"rental:entity:lease:field:status": "Status",
|
|
254
258
|
"rental:entity:lease:field:status:option:active": "Active",
|
|
259
|
+
"rental:entity:lease:field:status:option:active:help":
|
|
260
|
+
"The lease is running and rent is being booked.",
|
|
255
261
|
"rental:entity:lease:field:status:option:terminated": "Terminated",
|
|
262
|
+
"rental:entity:lease:field:status:option:terminated:help":
|
|
263
|
+
"The lease is terminated and ends on the entered date.",
|
|
256
264
|
"rental:entity:lease:field:grundmiete": "Base rent per month",
|
|
257
265
|
"rental:entity:lease:field:kuendigungsfrist": "Notice period",
|
|
258
266
|
"rental:entity:lease:field:zahltag": "Due day",
|
|
@@ -47,6 +47,7 @@ export const leaseListScreen: EntityListScreenDefinition = {
|
|
|
47
47
|
id: "lease-list",
|
|
48
48
|
type: "entityList",
|
|
49
49
|
entity: "lease",
|
|
50
|
+
pageHelp: { sections: [{ kind: "status", field: "status" }] },
|
|
50
51
|
columns: [...OPEN_FILL_COLUMNS],
|
|
51
52
|
defaultSort: { field: "beginn", dir: "desc" },
|
|
52
53
|
pageSize: 25,
|