@cosmicdrift/kumiko-bundled-features 0.419.0 → 0.421.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.
Files changed (68) hide show
  1. package/dist/auth-email-password/seeding.d.ts +11 -0
  2. package/dist/auth-email-password/seeding.js +17 -2
  3. package/dist/shared/index.d.ts +1 -0
  4. package/dist/shared/index.js +1 -0
  5. package/dist/shared/tenant-scoped-subject.d.ts +11 -0
  6. package/dist/shared/tenant-scoped-subject.js +18 -0
  7. package/dist/signature/feature.js +1 -1
  8. package/dist/signature/grant.d.ts +1 -1
  9. package/dist/signature/grant.js +7 -12
  10. package/dist/signature/png.js +35 -10
  11. package/dist/template-resolver/api.d.ts +2 -0
  12. package/dist/template-resolver/api.js +11 -7
  13. package/dist/template-resolver/compile-document-body.js +6 -5
  14. package/dist/template-resolver/compile-document-styles.js +42 -4
  15. package/dist/template-resolver/document-frames.d.ts +1 -0
  16. package/dist/template-resolver/document-frames.js +39 -2
  17. package/dist/template-resolver/document-op-blocks.d.ts +258 -24
  18. package/dist/template-resolver/document-op-blocks.js +111 -20
  19. package/dist/template-resolver/document-ops.d.ts +1030 -96
  20. package/dist/template-resolver/document-ops.js +32 -3
  21. package/dist/template-resolver/document-print-only.d.ts +2 -1
  22. package/dist/template-resolver/document-print-only.js +23 -0
  23. package/dist/template-resolver/document-sanitizer.d.ts +1 -1
  24. package/dist/template-resolver/document-sanitizer.js +6 -1
  25. package/dist/template-resolver/handlers/create-layout.write.js +1 -1
  26. package/dist/template-resolver/handlers/patch-draft.write.d.ts +512 -48
  27. package/dist/template-resolver/handlers/patch-draft.write.js +2 -1
  28. package/dist/template-resolver/handlers/tenant-settings.d.ts +7 -1
  29. package/dist/template-resolver/handlers/tenant-settings.js +25 -15
  30. package/dist/template-resolver/index.d.ts +3 -3
  31. package/dist/template-resolver/index.js +3 -3
  32. package/dist/template-resolver/template-meta.d.ts +10 -0
  33. package/dist/template-resolver/template-meta.js +7 -1
  34. package/dist/template-resolver/template-preview.js +16 -4
  35. package/dist/template-resolver/web/constants.d.ts +1 -1
  36. package/dist/template-resolver/web/constants.js +1 -1
  37. package/dist/template-resolver/web/document-editor-extensions.js +44 -19
  38. package/dist/template-resolver/web/document-editor.js +3 -1
  39. package/dist/template-resolver/web/document-print-decorations.js +53 -6
  40. package/dist/template-resolver/web/document-print-style.d.ts +81 -2
  41. package/dist/template-resolver/web/document-print-style.js +114 -2
  42. package/dist/template-resolver/web/document-repeat-strip.js +2 -26
  43. package/dist/template-resolver/web/document-schema.d.ts +5 -0
  44. package/dist/template-resolver/web/document-schema.js +50 -13
  45. package/dist/template-resolver/web/document-style-css.d.ts +35 -2
  46. package/dist/template-resolver/web/document-style-css.js +65 -1
  47. package/dist/template-resolver/web/document-tiptap-bubble.js +71 -8
  48. package/dist/template-resolver/web/document-tiptap-content.d.ts +1 -1
  49. package/dist/template-resolver/web/document-tiptap-content.js +5 -2
  50. package/dist/template-resolver/web/document-tiptap-editor.d.ts +1 -1
  51. package/dist/template-resolver/web/document-tiptap-editor.js +2 -2
  52. package/dist/template-resolver/web/document-tiptap-helpers.d.ts +32 -2
  53. package/dist/template-resolver/web/document-tiptap-helpers.js +99 -24
  54. package/dist/template-resolver/web/document-tiptap-toolbar-groups.d.ts +11 -0
  55. package/dist/template-resolver/web/document-tiptap-toolbar-groups.js +41 -3
  56. package/dist/template-resolver/web/document-tiptap-toolbar.js +13 -8
  57. package/dist/template-resolver/web/i18n.js +2 -0
  58. package/dist/template-resolver/web/index.d.ts +1 -1
  59. package/dist/template-resolver/web/index.js +1 -1
  60. package/dist/template-resolver/web/pdf-constants.d.ts +5 -0
  61. package/dist/template-resolver/web/pdf-constants.js +6 -0
  62. package/dist/template-resolver/web/placeholder-text.d.ts +2 -1
  63. package/dist/template-resolver/web/placeholder-text.js +5 -2
  64. package/dist/tenant/seeding.d.ts +14 -0
  65. package/dist/tenant/seeding.js +44 -0
  66. package/package.json +19 -11
  67. package/src/signature/changes.json +6 -0
  68. package/src/template-resolver/changes.json +24 -0
@@ -28,7 +28,7 @@ export function makePatchDraftWrite(policy) {
28
28
  }),
29
29
  access: templateEditAccess(policy.tenantEditable),
30
30
  agent: { risk: "low", effect: "proposal" },
31
- description: 'Changes a mail template, a PDF document template (kind document-pdf) or one region of a PDF layout (kind pdf-layout with region header, signature or footer; a tenant edits its own layouts under the slug tenant-layout-<name>, created with create-layout) with structured operations instead of a full rewrite and saves the result as the caller\'s tenant draft (never published, an active version keeps being served until publish). Never send raw HTML: every block goes through the same checks as the editor. Block forms: paragraph and heading {text} or {runs:[{text,bold,italic,underline,font,sizePt,color}]} with optional align, style {lineHeight,spaceBeforePt,spaceAfterPt} and textStyle {font,sizePt,color}; list {ordered,items:[text or runs]}; table {borders:"none",columnWidthsPx,header:{cells:[{text|runs,background,align}]},rows:[{cells}],repeat:{each:<list variable>,row}} (repeat is the row printed once per list entry; header repeats on every page); frame {xMm,yMm,widthMm,heightMm,preset:address|text,reserveFlow,blocks} only in document-pdf, at the top level (the DIN address window is x20 y45 w85 h45 with preset address); image {resource,alt}; button {text,href} mails only; divider; pageBreak PDF only. Fonts, sizes, colors (#rrggbb), line spacing, borders, backgrounds and frames are print styling: PDF only, a mail refuses them with print_style_not_allowed. Operations: insertBlock after a block id (null = at the start), replaceBody {blocks} (replaces the whole content, at most 300 blocks including the ones inside frames; read ids no longer apply afterwards), formatBlock {blockId,align,style,textStyle} on a paragraph, heading or list, replaceText inside one block (the text must occur exactly once within one formatting run and cannot contain a {{placeholder}}: a find across a formatting change fails with text_spans_formatting, a find with a placeholder with placeholder_not_replaceable, and the formatting of the replaced text is kept), removeBlock, setResource on an image block, setMeta (flat merge, null removes a key) and setVariable (adds, replaces or with null removes a variable definition; refused when a notification declares the variables). Block ids and base come from document-blocks and refer to the state that was read; if the template changed since, the call fails with version_conflict and nothing is written. A patch that removes a required placeholder is refused. A TenantAdmin may patch only templates the app lists in tenantEditable, otherwise SystemAdmin only. Returns the written row.',
31
+ description: 'Changes a mail template, a PDF document template (kind document-pdf) or one region of a PDF layout (kind pdf-layout with region header, signature or footer; a tenant edits its own layouts under the slug tenant-layout-<name>, created with create-layout) with structured operations instead of a full rewrite and saves the result as the caller\'s tenant draft (never published, an active version keeps being served until publish). Never send raw HTML: every block goes through the same checks as the editor. Block forms: paragraph and heading {text} or {runs:[{text,bold,italic,underline,font,sizePt,color,dateStyle (short prints a date placeholder in that run as 15.01.2026, long is the default 15. January 2026; both follow the document locale)}]} with optional align, style {lineHeight,spaceBeforePt,spaceAfterPt} and textStyle {font,sizePt,color}; list {ordered,items:[text or runs]}; table {borders:"none",cellPaddingMm (0 to 10, padding inside every cell),widthMm (0.1 to 210, table width),align:left|center|right (placement of a table narrower than the text area),columnWidthsPx,header:{cells:[{text|runs,background,align}]},rows:[{cells,lineAbove:{color #rrggbb,weightPt 0.25 to 4},lineBelow:{...}}],repeat:{each:<list variable>,row},rowsAfterRepeat:[{cells,lineAbove,lineBelow}]} (a row line is a rule on the top or bottom edge of that row; it beats tableLineColor there and works on the header, repeat and rowsAfterRepeat rows too) (repeat is the row printed once per list entry; header repeats on every page; rowsAfterRepeat are printed once below the repeated rows, e.g. total lines, and need a repeat); a run is {text,bold,italic,underline,font,sizePt,color} or {hardBreak:true}, which starts a new line inside the paragraph or table cell, e.g. a description followed by a small grey second line; frame {xMm,yMm,widthMm,heightMm,preset:address|text,reserveFlow,blocks} only in document-pdf, at the top level (the DIN address window is x20 y45 w85 h45 with preset address); image {resource,alt,widthMm (0.1 to 210, printed width; without it the image keeps its natural size, in a layout region at most 20 mm high),align:left|center|right,bleed (true runs the image from paper edge to paper edge, flush with the top in a header and with the bottom in a footer; only in the header or footer region of a pdf-layout, refused elsewhere with bleed_not_allowed)}; button {text,href} mails only; divider {color #rrggbb,weightPt 0.25 to 4}; pageBreak PDF only. Fonts, sizes, colors (#rrggbb), line spacing, borders, backgrounds and frames are print styling: PDF only, a mail refuses them with print_style_not_allowed. Operations: insertBlock after a block id (null = at the start), replaceBody {blocks} (replaces the whole content, at most 300 blocks including the ones inside frames; read ids no longer apply afterwards), formatBlock {blockId,align,style,textStyle} on a paragraph, heading or list, replaceText inside one block (the text must occur exactly once within one formatting run and cannot contain a {{placeholder}}: a find across a formatting change fails with text_spans_formatting, a find with a placeholder with placeholder_not_replaceable, and the formatting of the replaced text is kept), removeBlock, setResource on an image block, setMeta (flat merge, null removes a key; layout keys are listed with create-layout) and setVariable (adds, replaces or with null removes a variable definition; refused when a notification declares the variables). Block ids and base come from document-blocks and refer to the state that was read; if the template changed since, the call fails with version_conflict and nothing is written. A patch that removes a required placeholder is refused. A TenantAdmin may patch only templates the app lists in tenantEditable, otherwise SystemAdmin only. Returns the written row.',
32
32
  handler: async (event, ctx) => {
33
33
  const { slug, kind, region, locale, base, ops } = event.payload;
34
34
  const misplacedRegion = regionIssue(kind, region);
@@ -62,6 +62,7 @@ export function makePatchDraftWrite(policy) {
62
62
  meta: loaded.meta,
63
63
  variableSchema: loaded.variableSchema,
64
64
  kind,
65
+ region,
65
66
  ops,
66
67
  });
67
68
  if (!applied.ok)
@@ -1,10 +1,16 @@
1
1
  import type { HandlerContext } from "@cosmicdrift/kumiko-framework/engine";
2
- import { createTemplateResolverApi } from "../api.ts";
2
+ import { createTemplateResolverApi, type TemplateResource } from "../api.ts";
3
3
  export declare function companyConfigKey(name: string): string;
4
4
  export declare function readTenantConfigText(ctx: Pick<HandlerContext, "config" | "registry">, qualifiedKey: string): Promise<string>;
5
5
  type DefaultLayoutContext = Pick<HandlerContext, "config" | "registry"> & {
6
6
  readonly db: Parameters<typeof createTemplateResolverApi>[0];
7
7
  };
8
+ export type DefaultPdfLayout = {
9
+ readonly slug: string;
10
+ readonly resolved: TemplateResource | null;
11
+ };
12
+ export declare function resolveDefaultPdfLayout(ctx: DefaultLayoutContext, tenantId: string, locale?: string, working?: boolean): Promise<DefaultPdfLayout>;
13
+ export declare function effectivePdfLayout(ctx: DefaultLayoutContext, tenantId: string, ownSlug: string | undefined, locale?: string, working?: boolean): Promise<DefaultPdfLayout>;
8
14
  export declare function defaultPdfLayoutSlug(ctx: DefaultLayoutContext, tenantId: string, locale?: string): Promise<string>;
9
15
  export declare function isCompanyPlaceholder(name: string): boolean;
10
16
  export declare function emptyCompanyData(ctx: HandlerContext, input: {
@@ -15,27 +15,36 @@ export async function readTenantConfigText(ctx, qualifiedKey) {
15
15
  const value = await ctx.config(qualifiedKey);
16
16
  return typeof value === "string" ? value : "";
17
17
  }
18
- // A configured default that no longer resolves (archived or deleted) must not leave documents
19
- // without letterhead, so it falls back to the built-in layout.
20
- export async function defaultPdfLayoutSlug(ctx, tenantId, locale = FALLBACK_LOCALE) {
18
+ export async function resolveDefaultPdfLayout(ctx, tenantId, locale = FALLBACK_LOCALE, working = false) {
21
19
  const slug = await readTenantConfigText(ctx, DEFAULT_PDF_LAYOUT_SLUG_CONFIG_KEY);
22
20
  if (slug === "")
23
- return DEFAULT_PDF_LAYOUT_SLUG;
21
+ return { slug: DEFAULT_PDF_LAYOUT_SLUG, resolved: null };
24
22
  try {
25
- await createTemplateResolverApi(ctx.db, ctx.registry).resolveLayout({
23
+ const resolved = await createTemplateResolverApi(ctx.db, ctx.registry).resolveLayout({
26
24
  tenantId,
27
25
  slug,
28
26
  kind: "pdf-layout",
29
27
  locale,
28
+ working,
30
29
  });
31
- return slug;
30
+ return { slug, resolved };
32
31
  }
33
32
  catch (e) {
34
- if (e instanceof TemplateNotFoundError)
35
- return DEFAULT_PDF_LAYOUT_SLUG;
33
+ if (e instanceof TemplateNotFoundError) {
34
+ return { slug: DEFAULT_PDF_LAYOUT_SLUG, resolved: null };
35
+ }
36
36
  throw e;
37
37
  }
38
38
  }
39
+ // A layout the document names itself wins; only without one is the tenant default resolved (once, so callers reuse it).
40
+ export async function effectivePdfLayout(ctx, tenantId, ownSlug, locale = FALLBACK_LOCALE, working = false) {
41
+ if (ownSlug !== undefined)
42
+ return { slug: ownSlug, resolved: null };
43
+ return resolveDefaultPdfLayout(ctx, tenantId, locale, working);
44
+ }
45
+ export async function defaultPdfLayoutSlug(ctx, tenantId, locale = FALLBACK_LOCALE) {
46
+ return (await resolveDefaultPdfLayout(ctx, tenantId, locale)).slug;
47
+ }
39
48
  export function isCompanyPlaceholder(name) {
40
49
  return COMPANY_PLACEHOLDERS.some((candidate) => candidate === name);
41
50
  }
@@ -52,14 +61,15 @@ async function layoutHtmlOf(ctx, tenantId, meta, locale) {
52
61
  const parsedMeta = parseTemplateMeta("document-pdf", meta);
53
62
  const pdfMeta = parsedMeta.ok ? readPdfTemplateMeta(parsedMeta.meta) : null;
54
63
  const effectiveLocale = locale ?? FALLBACK_LOCALE;
55
- const slug = pdfMeta?.layoutSlug ?? (await defaultPdfLayoutSlug(ctx, tenantId, effectiveLocale));
64
+ const { slug, resolved } = await effectivePdfLayout(ctx, tenantId, pdfMeta?.layoutSlug, effectiveLocale);
56
65
  try {
57
- const layout = await createTemplateResolverApi(ctx.db, ctx.registry).resolveLayout({
58
- tenantId,
59
- slug,
60
- kind: "pdf-layout",
61
- locale: effectiveLocale,
62
- });
66
+ const layout = resolved ??
67
+ (await createTemplateResolverApi(ctx.db, ctx.registry).resolveLayout({
68
+ tenantId,
69
+ slug,
70
+ kind: "pdf-layout",
71
+ locale: effectiveLocale,
72
+ }));
63
73
  return layout.content ?? "";
64
74
  }
65
75
  catch (e) {
@@ -1,13 +1,13 @@
1
1
  export { isResourceImageContentType } from "../shared/index.ts";
2
2
  export { createTemplateResolverApi, type ResolveRequest, requireTemplateResolver, TemplateNotFoundError, type TemplateResolverApi, type TemplateResource, } from "./api.ts";
3
3
  export { type CompileDocumentBodyOptions, collectDocumentImageVariables, collectDocumentResourceKeys, compileDocumentBodyToHandlebars, toResourceDataUri, } from "./compile-document-body.ts";
4
- export { flattenFramesForPreview, readTopLevelFrames } from "./document-frames.ts";
4
+ export { flattenAddressSenderLine, flattenFramesForPreview, readTopLevelFrames, } from "./document-frames.ts";
5
5
  export { type DocumentViolation, type DocumentViolationCode, documentViolationsToFieldIssues, flattenParagraphsToLineBreaks, type SanitizeBodyResult, type SanitizeHtmlResult, sanitizeDocumentHtml, sanitizeTemplateBody, } from "./document-sanitizer.ts";
6
6
  export { createTemplateResolverFeature, type TemplateResolverOptions } from "./feature.ts";
7
7
  export type { LayoutSourceResponse, LayoutSourceRow } from "./handlers/layout-source.query.ts";
8
8
  export type { OverviewKindGroup, OverviewOrigin, OverviewResponse, OverviewRow, OverviewUsage, } from "./handlers/overview.query.ts";
9
9
  export { localeSchema } from "./handlers/shared.ts";
10
- export { companyConfigKey, defaultPdfLayoutSlug, readTenantConfigText, } from "./handlers/tenant-settings.ts";
10
+ export { companyConfigKey, defaultPdfLayoutSlug, effectivePdfLayout, readTenantConfigText, resolveDefaultPdfLayout, } from "./handlers/tenant-settings.ts";
11
11
  export { isHexColor, type MailLayoutAppearance, mailLayoutAppearance, } from "./layout-appearance.ts";
12
12
  export { type LayoutRegions, readLayoutRegions, type SanitizeLayoutResult, sanitizeLayoutHtml, } from "./layout-regions.ts";
13
13
  export { fileAttachmentsOf, imageLinksOf, type LinkedResourceEntry, parseLinkedResourceEntries, pdfAttachmentLinksOf, type TemplatePdfAttachmentLink, templatePdfAttachmentLinkSchema, } from "./linked-resources.ts";
@@ -25,7 +25,7 @@ export { isSystemOnlyTemplate } from "./template-system-only.ts";
25
25
  export { collectTemplateUsage, type TemplateUsageEntry } from "./template-usage.ts";
26
26
  export { hasPlaceholderProblems, resolveTemplateVariables, SYSTEM_PLACEHOLDERS, systemPlaceholdersFor, type TemplateValidation, validateTemplatePlaceholders, } from "./template-validation.ts";
27
27
  export { type UserContentEntryRow, userContentEntriesTable, userContentEntryEntity, } from "./user-content-table.ts";
28
- export { COMPANY_PLACEHOLDERS, CONTENT_FORMATS, type ContentFormat, DEFAULT_MAIL_LAYOUT_SLUG, DEFAULT_PDF_LAYOUT_SLUG, DEFAULT_PDF_LAYOUT_SLUG_CONFIG_KEY, DOCUMENT_HTML_KINDS, type DocumentHtmlKind, FALLBACK_LOCALE, NON_RENDER_KINDS, type NonRenderKind, 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 PdfOrientation, type PdfPageFormat, type PdfTableStyle, RENDER_KINDS, type RenderKind, SYSTEM_TENANT_ID, TEMPLATE_KINDS, TEMPLATE_SCOPES, TEMPLATE_STATUSES, TENANT_LAYOUT_SLUG_PREFIX, TEXT_BLOCK_KIND, type TemplateKind, type TemplateScope, type TemplateStatus, UPSERT_KINDS, type UpsertKind, } from "./web/constants.ts";
28
+ export { COMPANY_PLACEHOLDERS, CONTENT_FORMATS, type ContentFormat, DEFAULT_MAIL_LAYOUT_SLUG, DEFAULT_PDF_LAYOUT_SLUG, DEFAULT_PDF_LAYOUT_SLUG_CONFIG_KEY, DOCUMENT_HTML_KINDS, type DocumentHtmlKind, FALLBACK_LOCALE, NON_RENDER_KINDS, type NonRenderKind, PDF_CORNER_MARK_INSET_MM, PDF_CORNER_MARK_LEG_MM, PDF_DEFAULT_FONT_SIZE_PT, PDF_DEFAULT_MARGIN_MM, PDF_FOLD_MARKS, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, PDF_TABLE_STYLES, type PdfFoldMarks, type PdfOrientation, type PdfPageFormat, type PdfTableStyle, RENDER_KINDS, type RenderKind, SYSTEM_TENANT_ID, TEMPLATE_KINDS, TEMPLATE_SCOPES, TEMPLATE_STATUSES, TENANT_LAYOUT_SLUG_PREFIX, TEXT_BLOCK_KIND, type TemplateKind, type TemplateScope, type TemplateStatus, UPSERT_KINDS, type UpsertKind, } from "./web/constants.ts";
29
29
  export { DOCUMENT_FONT_LABELS, DOCUMENT_FONT_PRINT_STACKS, DOCUMENT_FONTS, type DocumentFont, } from "./web/document-fonts.ts";
30
30
  export type { DocumentFrameAttributes } from "./web/document-print-style.ts";
31
31
  export { DOCUMENT_CONDITION_ATTRIBUTE, DOCUMENT_NODE_NAMES, DOCUMENT_TEXT_ALIGNMENTS, DocumentButton, DocumentCondition, DocumentDivider, DocumentLink, DocumentPageBreak, DocumentResource, DocumentTable, DocumentTableCell, DocumentTableHeader, DocumentTableRow, DocumentTextAlign, type DocumentTextAlignment, DocumentVariable, documentExtensions, isAllowedDocumentLinkHref, isAllowedDocumentUrlHref, isDocumentPlaceholderHref, isDocumentReferenceName, isDocumentResourceKey, } from "./web/document-schema.ts";
@@ -1,11 +1,11 @@
1
1
  export { isResourceImageContentType } from "../shared/index.js";
2
2
  export { createTemplateResolverApi, requireTemplateResolver, TemplateNotFoundError, } from "./api.js";
3
3
  export { collectDocumentImageVariables, collectDocumentResourceKeys, compileDocumentBodyToHandlebars, toResourceDataUri, } from "./compile-document-body.js";
4
- export { flattenFramesForPreview, readTopLevelFrames } from "./document-frames.js";
4
+ export { flattenAddressSenderLine, flattenFramesForPreview, readTopLevelFrames, } from "./document-frames.js";
5
5
  export { documentViolationsToFieldIssues, flattenParagraphsToLineBreaks, sanitizeDocumentHtml, sanitizeTemplateBody, } from "./document-sanitizer.js";
6
6
  export { createTemplateResolverFeature } from "./feature.js";
7
7
  export { localeSchema } from "./handlers/shared.js";
8
- export { companyConfigKey, defaultPdfLayoutSlug, readTenantConfigText, } from "./handlers/tenant-settings.js";
8
+ export { companyConfigKey, defaultPdfLayoutSlug, effectivePdfLayout, readTenantConfigText, resolveDefaultPdfLayout, } from "./handlers/tenant-settings.js";
9
9
  export { isHexColor, mailLayoutAppearance, } from "./layout-appearance.js";
10
10
  export { readLayoutRegions, sanitizeLayoutHtml, } from "./layout-regions.js";
11
11
  export { fileAttachmentsOf, imageLinksOf, parseLinkedResourceEntries, pdfAttachmentLinksOf, templatePdfAttachmentLinkSchema, } from "./linked-resources.js";
@@ -22,7 +22,7 @@ export { isSystemOnlyTemplate } from "./template-system-only.js";
22
22
  export { collectTemplateUsage } from "./template-usage.js";
23
23
  export { hasPlaceholderProblems, resolveTemplateVariables, SYSTEM_PLACEHOLDERS, systemPlaceholdersFor, validateTemplatePlaceholders, } from "./template-validation.js";
24
24
  export { userContentEntriesTable, userContentEntryEntity, } from "./user-content-table.js";
25
- export { COMPANY_PLACEHOLDERS, CONTENT_FORMATS, DEFAULT_MAIL_LAYOUT_SLUG, DEFAULT_PDF_LAYOUT_SLUG, DEFAULT_PDF_LAYOUT_SLUG_CONFIG_KEY, DOCUMENT_HTML_KINDS, FALLBACK_LOCALE, NON_RENDER_KINDS, 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, RENDER_KINDS, SYSTEM_TENANT_ID, TEMPLATE_KINDS, TEMPLATE_SCOPES, TEMPLATE_STATUSES, TENANT_LAYOUT_SLUG_PREFIX, TEXT_BLOCK_KIND, UPSERT_KINDS, } from "./web/constants.js";
25
+ export { COMPANY_PLACEHOLDERS, CONTENT_FORMATS, DEFAULT_MAIL_LAYOUT_SLUG, DEFAULT_PDF_LAYOUT_SLUG, DEFAULT_PDF_LAYOUT_SLUG_CONFIG_KEY, DOCUMENT_HTML_KINDS, FALLBACK_LOCALE, NON_RENDER_KINDS, PDF_CORNER_MARK_INSET_MM, PDF_CORNER_MARK_LEG_MM, PDF_DEFAULT_FONT_SIZE_PT, PDF_DEFAULT_MARGIN_MM, PDF_FOLD_MARKS, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, PDF_TABLE_STYLES, RENDER_KINDS, SYSTEM_TENANT_ID, TEMPLATE_KINDS, TEMPLATE_SCOPES, TEMPLATE_STATUSES, TENANT_LAYOUT_SLUG_PREFIX, TEXT_BLOCK_KIND, UPSERT_KINDS, } from "./web/constants.js";
26
26
  export { DOCUMENT_FONT_LABELS, DOCUMENT_FONT_PRINT_STACKS, DOCUMENT_FONTS, } from "./web/document-fonts.js";
27
27
  export { DOCUMENT_CONDITION_ATTRIBUTE, DOCUMENT_NODE_NAMES, DOCUMENT_TEXT_ALIGNMENTS, DocumentButton, DocumentCondition, DocumentDivider, DocumentLink, DocumentPageBreak, DocumentResource, DocumentTable, DocumentTableCell, DocumentTableHeader, DocumentTableRow, DocumentTextAlign, DocumentVariable, documentExtensions, isAllowedDocumentLinkHref, isAllowedDocumentUrlHref, isDocumentPlaceholderHref, isDocumentReferenceName, isDocumentResourceKey, } from "./web/document-schema.js";
28
28
  export { addressParagraphCss, DOCUMENT_LINE_VARIABLE, documentLinePt, FRAME_FLOW_GAP_MM, PARAGRAPH_DEFAULT_LINE_HEIGHT, SENDER_LINE_SIZE_PT, } from "./web/document-style-css.js";
@@ -84,6 +84,16 @@ declare const pdfLayoutMetaSchema: z.ZodObject<{
84
84
  plain: "plain";
85
85
  }>>;
86
86
  tableHeaderBackground: z.ZodOptional<z.ZodString>;
87
+ tableLineColor: z.ZodOptional<z.ZodString>;
88
+ foldMarks: z.ZodOptional<z.ZodEnum<{
89
+ "din-a": "din-a";
90
+ "din-b": "din-b";
91
+ none: "none";
92
+ }>>;
93
+ cornerMarks: z.ZodOptional<z.ZodBoolean>;
94
+ paperColor: z.ZodOptional<z.ZodString>;
95
+ headerOnFirstPage: z.ZodOptional<z.ZodBoolean>;
96
+ footerOnFirstPage: z.ZodOptional<z.ZodBoolean>;
87
97
  }, z.core.$strict>;
88
98
  export type MailTemplateMeta = z.infer<typeof mailMetaSchema>;
89
99
  export type PdfTemplateMeta = z.infer<typeof pdfMetaSchema>;
@@ -3,7 +3,7 @@ import { HEX_COLOR_PATTERN, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, } from "./web/co
3
3
  import { DOCUMENT_FONTS } from "./web/document-fonts.js";
4
4
  import { MAIL_TONES } from "./web/mail-constants.js";
5
5
  import { MAIL_LAYOUT_ACCENT_LINES, MAIL_LAYOUT_BUTTON_STYLES, MAIL_LAYOUT_FONTS, MAIL_LAYOUT_WIDTHS, } from "./web/mail-layout-constants.js";
6
- import { PDF_TABLE_STYLES } from "./web/pdf-constants.js";
6
+ import { PDF_FOLD_MARKS, PDF_TABLE_STYLES } from "./web/pdf-constants.js";
7
7
  // One or more kebab segments joined by ":" — notification templates are seeded
8
8
  // under their qualified name `feature:notify:name`.
9
9
  export const templateSlugSchema = z
@@ -92,6 +92,12 @@ const pdfLayoutMetaSchema = z
92
92
  textColor: hexColor.optional(),
93
93
  tableStyle: z.enum(PDF_TABLE_STYLES).optional(),
94
94
  tableHeaderBackground: hexColor.optional(),
95
+ tableLineColor: hexColor.optional(),
96
+ foldMarks: z.enum(PDF_FOLD_MARKS).optional(),
97
+ cornerMarks: z.boolean().optional(),
98
+ paperColor: hexColor.optional(),
99
+ headerOnFirstPage: z.boolean().optional(),
100
+ footerOnFirstPage: z.boolean().optional(),
95
101
  })
96
102
  .strict();
97
103
  export function isMailTemplateMeta(meta) {
@@ -12,7 +12,7 @@ import { collectRendererPlugins, createRendererFoundationApi, RendererError, } f
12
12
  import { createTemplateResolverApi, isRowDeliveredTo, TemplateNotFoundError, } from "./api.js";
13
13
  import { collectDocumentResourceKeys } from "./compile-document-body.js";
14
14
  import { parseStoredJson } from "./handlers/template-gates.js";
15
- import { defaultPdfLayoutSlug } from "./handlers/tenant-settings.js";
15
+ import { effectivePdfLayout } from "./handlers/tenant-settings.js";
16
16
  import { validateTemplateDraft } from "./handlers/validate.query.js";
17
17
  import { readLayoutRegions, sanitizeLayoutHtml, } from "./layout-regions.js";
18
18
  import { parseLinkedResourceEntries } from "./linked-resources.js";
@@ -164,11 +164,19 @@ async function loadEditedRowResources(ctx, user, input) {
164
164
  }
165
165
  return row === undefined ? undefined : parseLinkedResourceEntries(row.linkedResources);
166
166
  }
167
- async function resolvePdfLayout(ctx, user, slug, locale) {
167
+ async function resolvePdfLayout(ctx, user, slug, locale, resolvedForCaller = null, working = false) {
168
168
  const api = createTemplateResolverApi(ctx.db, ctx.registry);
169
169
  const find = async (tenantId) => {
170
+ if (resolvedForCaller !== null && tenantId === user.tenantId)
171
+ return resolvedForCaller;
170
172
  try {
171
- return await api.resolveLayout({ tenantId, slug, kind: "pdf-layout", locale });
173
+ return await api.resolveLayout({
174
+ tenantId,
175
+ slug,
176
+ kind: "pdf-layout",
177
+ locale,
178
+ working,
179
+ });
172
180
  }
173
181
  catch (e) {
174
182
  if (e instanceof TemplateNotFoundError)
@@ -192,6 +200,10 @@ async function resolvePdfLayout(ctx, user, slug, locale) {
192
200
  return null;
193
201
  return { slug, scope: layout.scope, html, regions: readLayoutRegions(html) };
194
202
  }
203
+ async function resolvePreviewPdfLayout(ctx, user, ownSlug, locale, working) {
204
+ const { slug, resolved } = await effectivePdfLayout(ctx, user.tenantId, ownSlug, locale, working);
205
+ return resolvePdfLayout(ctx, user, slug, locale, resolved, working);
206
+ }
195
207
  function missingResourceCheck(missing) {
196
208
  return {
197
209
  code: "resources_resolved",
@@ -246,7 +258,7 @@ async function renderDocumentPreview(ctx, user, args) {
246
258
  html: content,
247
259
  text: null,
248
260
  attachments: [],
249
- layout: await resolvePdfLayout(ctx, user, pdfMeta?.layoutSlug ?? (await defaultPdfLayoutSlug(ctx, user.tenantId, input.locale)), input.locale),
261
+ layout: await resolvePreviewPdfLayout(ctx, user, pdfMeta?.layoutSlug, input.locale, input.content !== undefined),
250
262
  sampleValues,
251
263
  checks: [missingResourceCheck(validation.warnings.map((w) => w.detail)), requiredCheck],
252
264
  validation,
@@ -24,7 +24,7 @@ export declare const TEMPLATE_STATUSES: readonly ["draft", "active", "archived"]
24
24
  export type TemplateStatus = (typeof TEMPLATE_STATUSES)[number];
25
25
  export declare const ACTIVE_TEMPLATE_STATUS = "active";
26
26
  export { HEX_COLOR_PATTERN } from "./mail-layout-constants.ts";
27
- 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 PdfOrientation, type PdfPageFormat, type PdfTableStyle, } from "./pdf-constants.ts";
27
+ export { PDF_CORNER_MARK_INSET_MM, PDF_CORNER_MARK_LEG_MM, PDF_DEFAULT_FONT_SIZE_PT, PDF_DEFAULT_MARGIN_MM, PDF_FOLD_MARKS, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, PDF_TABLE_STYLES, type PdfFoldMarks, type PdfOrientation, type PdfPageFormat, type PdfTableStyle, } from "./pdf-constants.ts";
28
28
  export declare const DEFAULT_MAIL_LAYOUT_SLUG = "default";
29
29
  export declare const DEFAULT_PDF_LAYOUT_SLUG = "default";
30
30
  export declare const COMPANY_PLACEHOLDERS: readonly ["companyAddress", "companyPhone", "companyEmail", "companyWebsite", "companyRegister", "companyVatId", "companyManagement", "companyBank", "companyIban", "companyBic"];
@@ -56,7 +56,7 @@ export const TEMPLATE_SCOPES = ["system", "tenant"];
56
56
  export const TEMPLATE_STATUSES = ["draft", "active", "archived"];
57
57
  export const ACTIVE_TEMPLATE_STATUS = "active";
58
58
  export { HEX_COLOR_PATTERN } from "./mail-layout-constants.js";
59
- 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";
59
+ export { PDF_CORNER_MARK_INSET_MM, PDF_CORNER_MARK_LEG_MM, PDF_DEFAULT_FONT_SIZE_PT, PDF_DEFAULT_MARGIN_MM, PDF_FOLD_MARKS, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, PDF_TABLE_STYLES, } from "./pdf-constants.js";
60
60
  export const DEFAULT_MAIL_LAYOUT_SLUG = "default";
61
61
  export const DEFAULT_PDF_LAYOUT_SLUG = "default";
62
62
  // Same names as the tenant feature's company config keys: the placeholder is the key name.
@@ -1,10 +1,12 @@
1
+ import { isOneOf } from "@cosmicdrift/kumiko-types/type-guards";
1
2
  import { ListKeymap } from "@tiptap/extension-list";
2
3
  import { Dropcursor, Gapcursor, Placeholder, UndoRedo } from "@tiptap/extensions";
3
4
  import { createFrameView } from "./document-frame-node-view.js";
4
5
  import { DocumentPrintEditing, loadDocumentEditorFonts } from "./document-print-decorations.js";
5
- import { DocumentFrame } from "./document-print-style.js";
6
- import { DocumentButton, DocumentImages, DocumentPageBreak, DocumentResource, DocumentSteps, DocumentTable, DocumentVariable, documentExtensions, } from "./document-schema.js";
6
+ import { DOCUMENT_IMAGE_ALIGNMENTS, DocumentFrame } from "./document-print-style.js";
7
+ import { DOCUMENT_DATE_STYLES, DocumentButton, DocumentImages, DocumentPageBreak, DocumentResource, DocumentSteps, DocumentTable, DocumentVariable, documentExtensions, } from "./document-schema.js";
7
8
  import { readDocumentStepsAttribute } from "./document-steps.js";
9
+ import { documentImageCss } from "./document-style-css.js";
8
10
  const DOCUMENT_RESOURCE_SIZE_TOKEN = "{size}";
9
11
  export const DOCUMENT_BLOCK_ATTRIBUTE = "data-document-block";
10
12
  function createElementWithClass(tag, className, text) {
@@ -29,6 +31,8 @@ function repeatRowListAt(doc, position) {
29
31
  }
30
32
  return null;
31
33
  }
34
+ // Language-neutral: the real value is formatted per locale at render time.
35
+ const DATE_STYLE_CHIP_HINTS = { short: "15.01.2026", long: "15. Jan 2026" };
32
36
  // The chip is display only: the stored node carries just the name, so a
33
37
  // label never reaches the document.
34
38
  export function createVariableView(variableLabels, systemVariables) {
@@ -44,6 +48,11 @@ export function createVariableView(variableLabels, systemVariables) {
44
48
  dom.append(document.createTextNode(hasOwnLabel ? label : name));
45
49
  if (hasOwnLabel)
46
50
  dom.title = name;
51
+ const dateStyle = node.attrs["dateStyle"];
52
+ if (isOneOf(DOCUMENT_DATE_STYLES, dateStyle)) {
53
+ dom.setAttribute("data-date-style", dateStyle);
54
+ dom.append(document.createTextNode(` · ${DATE_STYLE_CHIP_HINTS[dateStyle]}`));
55
+ }
47
56
  return { dom };
48
57
  };
49
58
  }
@@ -55,6 +64,38 @@ function createBlockLabel(text) {
55
64
  label.contentEditable = "false";
56
65
  return label;
57
66
  }
67
+ function appendResourceImage(dom, node, key, preview) {
68
+ const widthMm = node.attrs["widthMm"];
69
+ const align = node.attrs["align"];
70
+ const sized = typeof widthMm === "number";
71
+ const bleeds = node.attrs["bleed"] === true;
72
+ const image = createElementWithClass("img", sized || bleeds ? "rounded" : "max-w-[180px] rounded");
73
+ // The same builder as the PDF, so the editor size follows the paper scale.
74
+ image.style.cssText = documentImageCss({
75
+ widthMm: typeof widthMm === "number" ? widthMm : null,
76
+ align: isOneOf(DOCUMENT_IMAGE_ALIGNMENTS, align) ? align : null,
77
+ });
78
+ if (bleeds)
79
+ image.style.width = "100%";
80
+ if (sized || bleeds)
81
+ dom.style.display = "block";
82
+ image.src = preview.src;
83
+ image.alt = typeof node.attrs["alt"] === "string" ? node.attrs["alt"] : key;
84
+ dom.append(image);
85
+ // An empty caption means "no caption", not the key.
86
+ const caption = preview.caption ?? key;
87
+ if (caption !== "") {
88
+ const captionElement = createElementWithClass("span", "whitespace-nowrap text-[11px]", caption.replace(` · ${DOCUMENT_RESOURCE_SIZE_TOKEN}`, ""));
89
+ // The size is only known once the browser decoded the image (possibly already, from cache).
90
+ const showSize = () => {
91
+ captionElement.textContent = caption.replace(DOCUMENT_RESOURCE_SIZE_TOKEN, `${image.naturalWidth} × ${image.naturalHeight} px`);
92
+ };
93
+ image.addEventListener("load", showSize);
94
+ if (image.complete && image.naturalWidth > 0)
95
+ showSize();
96
+ dom.append(captionElement);
97
+ }
98
+ }
58
99
  function createResourceView(labels) {
59
100
  return ({ node }) => {
60
101
  const key = String(node.attrs["resource"]);
@@ -74,23 +115,7 @@ function createResourceView(labels) {
74
115
  dom.append(label);
75
116
  }
76
117
  if (hasImage) {
77
- const image = createElementWithClass("img", "max-w-[180px] rounded");
78
- image.src = preview.src;
79
- image.alt = typeof node.attrs["alt"] === "string" ? node.attrs["alt"] : key;
80
- dom.append(image);
81
- // An empty caption means "no caption", not the key.
82
- const caption = preview.caption ?? key;
83
- if (caption !== "") {
84
- const captionElement = createElementWithClass("span", "whitespace-nowrap text-[11px]", caption.replace(` · ${DOCUMENT_RESOURCE_SIZE_TOKEN}`, ""));
85
- // The size is only known once the browser decoded the image (possibly already, from cache).
86
- const showSize = () => {
87
- captionElement.textContent = caption.replace(DOCUMENT_RESOURCE_SIZE_TOKEN, `${image.naturalWidth} × ${image.naturalHeight} px`);
88
- };
89
- image.addEventListener("load", showSize);
90
- if (image.complete && image.naturalWidth > 0)
91
- showSize();
92
- dom.append(captionElement);
93
- }
118
+ appendResourceImage(dom, node, key, preview);
94
119
  }
95
120
  else {
96
121
  dom.append(createElementWithClass("span", "font-medium", labels.image), createElementWithClass("code", "text-xs", key));
@@ -4,6 +4,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
4
4
  // Never import document-tiptap-editor or document-editor-extensions statically here.
5
5
  import { TextareaContentEditor } from "@cosmicdrift/kumiko-renderer";
6
6
  import { createContext, lazy, Suspense, useContext } from "react";
7
+ const NO_BLOCKS = [];
7
8
  const LazyDocumentTiptapEditor = lazy(() => import("./document-tiptap-editor.js"));
8
9
  // The editor registry only hands ContentEditorProps to an editor, so the
9
10
  // collection's block set (mail vs. PDF) reaches it through this context. An
@@ -11,7 +12,8 @@ const LazyDocumentTiptapEditor = lazy(() => import("./document-tiptap-editor.js"
11
12
  export const DocumentBlocksContext = createContext(undefined);
12
13
  export function DocumentContentEditor(props) {
13
14
  const contextBlocks = useContext(DocumentBlocksContext);
14
- const editorProps = props.blocks === undefined ? { ...props, blocks: contextBlocks } : props;
15
+ const blocks = props.blocks ?? (props.formatting === "text" ? NO_BLOCKS : contextBlocks);
16
+ const editorProps = { ...props, blocks };
15
17
  return (_jsx(Suspense
16
18
  // Read-only without chips: a textarea would insert {{name}} text and plaintext into a document body.
17
19
  , {
@@ -7,8 +7,9 @@ import { Plugin, PluginKey } from "@tiptap/pm/state";
7
7
  import { Decoration, DecorationSet } from "@tiptap/pm/view";
8
8
  import { DOCUMENT_FONTS } from "./document-fonts.js";
9
9
  import { buildFrameControl, FRAME_NODE_NAME, FRAME_SELECTED_ATTRIBUTE, frameFlowBottomMm, frameLocationOf, isSenderLine, } from "./document-frame-control.js";
10
+ import { DOCUMENT_TABLE_ALIGNMENTS, readRowLineAttributes } from "./document-print-style.js";
10
11
  import { repeatStripDecorations } from "./document-repeat-strip.js";
11
- import { addressParagraphCss, DOCUMENT_LINE_VARIABLE, documentBlockStyleCss, documentCellStyleCss, documentTextStyleCss, PARAGRAPH_DEFAULT_LINE_HEIGHT, } from "./document-style-css.js";
12
+ import { addressParagraphCss, DOCUMENT_LINE_VARIABLE, documentBlockStyleCss, documentCellStyleCss, documentDividerCss, documentTableCss, documentTextStyleCss, PARAGRAPH_DEFAULT_LINE_HEIGHT, resolveRowEdges, } from "./document-style-css.js";
12
13
  // Metric-compatible web fonts (@fontsource) stand in for the print service's installed fonts.
13
14
  const EDITOR_FONT_STACKS = {
14
15
  arial: 'Arimo,"Liberation Sans",Arial,sans-serif',
@@ -67,15 +68,59 @@ function nodeDecoration(node, from, parent, index) {
67
68
  .join(";");
68
69
  return style === "" ? null : Decoration.node(from, to, { style });
69
70
  }
70
- if (CELL_NODES.includes(name)) {
71
- const style = documentCellStyleCss({ background: stringOrNull(node.attrs["background"]) });
71
+ if (name === "divider") {
72
+ const style = documentDividerCss({
73
+ color: stringOrNull(node.attrs["color"]),
74
+ weightPt: numberOrNull(node.attrs["weightPt"]),
75
+ });
72
76
  return style === "" ? null : Decoration.node(from, to, { style });
73
77
  }
74
- if (name === "table" && node.attrs["borders"] === "none") {
75
- return Decoration.node(from, to, { "data-borders": "none" });
76
- }
77
78
  return null;
78
79
  }
80
+ // Cell padding, outer-column insets and row rules depend on the table and row around a cell, so
81
+ // the table decorates its own cells; the rules mirror the PDF compile's edge resolution.
82
+ function tableDecorations(table, from) {
83
+ const align = table.attrs["align"];
84
+ const tableStyle = documentTableCss({
85
+ widthMm: numberOrNull(table.attrs["widthMm"]),
86
+ align: isOneOf(DOCUMENT_TABLE_ALIGNMENTS, align) ? align : null,
87
+ });
88
+ const decorations = [];
89
+ const tableAttrs = {
90
+ ...(table.attrs["borders"] === "none" ? { "data-borders": "none" } : {}),
91
+ ...(tableStyle === "" ? {} : { style: tableStyle }),
92
+ };
93
+ if (Object.keys(tableAttrs).length > 0) {
94
+ decorations.push(Decoration.node(from, from + table.nodeSize, tableAttrs));
95
+ }
96
+ const paddingMm = numberOrNull(table.attrs["cellPaddingMm"]);
97
+ const rows = [];
98
+ table.forEach((row, offset) => {
99
+ rows.push({ node: row, pos: from + 1 + offset });
100
+ });
101
+ const edges = resolveRowEdges(rows.map((row) => ({
102
+ ...readRowLineAttributes(row.node.attrs),
103
+ repeats: typeof row.node.attrs["each"] === "string",
104
+ })));
105
+ rows.forEach((row, rowIndex) => {
106
+ row.node.forEach((cell, offset, cellIndex) => {
107
+ if (!CELL_NODES.includes(cell.type.name))
108
+ return;
109
+ const style = documentCellStyleCss({
110
+ background: stringOrNull(cell.attrs["background"]),
111
+ paddingMm,
112
+ isFirstInRow: cellIndex === 0,
113
+ isLastInRow: cellIndex === row.node.childCount - 1,
114
+ edges: edges[rowIndex],
115
+ });
116
+ if (style === "")
117
+ return;
118
+ const cellFrom = row.pos + 1 + offset;
119
+ decorations.push(Decoration.node(cellFrom, cellFrom + cell.nodeSize, { style }));
120
+ });
121
+ });
122
+ return decorations;
123
+ }
79
124
  // Frames are not rebuilt by the selection alone, so the selected one is marked by a decoration the
80
125
  // node view styles; the same location drives the side panel.
81
126
  function buildDecorations(doc, selection, extra) {
@@ -85,6 +130,8 @@ function buildDecorations(doc, selection, extra) {
85
130
  if (node.type.name === FRAME_NODE_NAME && selectedFrame?.pos === pos) {
86
131
  decorations.push(Decoration.node(pos, pos + node.nodeSize, { [FRAME_SELECTED_ATTRIBUTE]: "" }));
87
132
  }
133
+ if (node.type.name === "table")
134
+ decorations.push(...tableDecorations(node, pos));
88
135
  const decoration = node.isInline
89
136
  ? textStyleDecoration(node, pos)
90
137
  : nodeDecoration(node, pos, parent, index);
@@ -1,5 +1,5 @@
1
1
  import { Extension, Mark, Node } from "@tiptap/core";
2
- import type { DocumentBlockStyle, DocumentFrameBox, DocumentTextStyle } from "./document-style-css.ts";
2
+ import type { DocumentBlockStyle, DocumentFrameBox, DocumentRowLine, DocumentTextStyle } from "./document-style-css.ts";
3
3
  export declare const TEXT_SIZE_PT_RANGE: {
4
4
  readonly min: 4;
5
5
  readonly max: 72;
@@ -20,6 +20,26 @@ export declare const COLWIDTH_PX_RANGE: {
20
20
  readonly min: 1;
21
21
  readonly max: 5000;
22
22
  };
23
+ export declare const IMAGE_WIDTH_MM_RANGE: {
24
+ readonly min: 0.1;
25
+ readonly max: 210;
26
+ };
27
+ export declare const DIVIDER_WEIGHT_PT_RANGE: {
28
+ readonly min: 0.25;
29
+ readonly max: 4;
30
+ };
31
+ export declare const CELL_PADDING_MM_RANGE: {
32
+ readonly min: 0;
33
+ readonly max: 10;
34
+ };
35
+ export declare const TABLE_WIDTH_MM_RANGE: {
36
+ readonly min: 0.1;
37
+ readonly max: 210;
38
+ };
39
+ export declare const DOCUMENT_IMAGE_ALIGNMENTS: readonly ["left", "center", "right"];
40
+ export type DocumentImageAlignment = (typeof DOCUMENT_IMAGE_ALIGNMENTS)[number];
41
+ export declare const DOCUMENT_TABLE_ALIGNMENTS: readonly ["left", "center", "right"];
42
+ export type DocumentTableAlignment = DocumentImageAlignment;
23
43
  export declare const FRAME_PRESETS: readonly ["address", "text"];
24
44
  export type DocumentFramePreset = (typeof FRAME_PRESETS)[number];
25
45
  type AttributeSource = {
@@ -32,11 +52,21 @@ export type DocumentFrameAttributes = DocumentFrameBox & {
32
52
  readonly reserveFlow: boolean;
33
53
  };
34
54
  export declare function readFrameAttributes(element: AttributeSource): DocumentFrameAttributes | null;
55
+ export declare function readImageWidthMm(element: AttributeSource): number | null;
56
+ export declare function readImageAlign(element: AttributeSource): DocumentImageAlignment | null;
57
+ export declare function readDividerColor(element: AttributeSource): string | null;
58
+ export declare function readDividerWeightPt(element: AttributeSource): number | null;
59
+ export declare function readCellPaddingMm(element: AttributeSource): number | null;
60
+ export declare function readTableWidthMm(element: AttributeSource): number | null;
61
+ export declare function readTableAlign(element: AttributeSource): DocumentTableAlignment | null;
62
+ export declare const ROW_LINE_ABOVE_ATTRIBUTE = "data-line-above";
63
+ export declare const ROW_LINE_BELOW_ATTRIBUTE = "data-line-below";
64
+ export declare function readRowLine(element: AttributeSource, attribute: string): DocumentRowLine | null;
35
65
  export declare function readCellBackground(element: AttributeSource): string | null;
36
66
  export declare function readColwidth(element: AttributeSource): number[] | null;
37
67
  export declare const DocumentTextStyleMark: Mark<any, any>;
38
68
  export declare const DocumentBlockStyleAttributes: Extension<any, any>;
39
- export declare const documentTableBordersAttribute: {
69
+ export declare const documentTablePrintAttributes: {
40
70
  borders: {
41
71
  default: null;
42
72
  parseHTML: (element: AttributeSource) => "none" | null;
@@ -46,6 +76,53 @@ export declare const documentTableBordersAttribute: {
46
76
  "data-borders"?: undefined;
47
77
  };
48
78
  };
79
+ cellPaddingMm: {
80
+ default: null;
81
+ parseHTML: (element: AttributeSource) => number | null;
82
+ renderHTML: (attributes: Record<string, unknown>) => {
83
+ "data-cell-padding-mm": string;
84
+ } | {
85
+ "data-cell-padding-mm"?: undefined;
86
+ };
87
+ };
88
+ widthMm: {
89
+ default: null;
90
+ parseHTML: (element: AttributeSource) => number | null;
91
+ renderHTML: (attributes: Record<string, unknown>) => {
92
+ "data-table-width-mm": string;
93
+ } | {
94
+ "data-table-width-mm"?: undefined;
95
+ };
96
+ };
97
+ align: {
98
+ default: null;
99
+ parseHTML: (element: AttributeSource) => "center" | "left" | "right" | null;
100
+ renderHTML: (attributes: Record<string, unknown>) => {
101
+ "data-table-align": "center" | "left" | "right";
102
+ } | {
103
+ "data-table-align"?: undefined;
104
+ };
105
+ };
106
+ };
107
+ export declare const documentRowLineAttributes: {
108
+ lineAbove: {
109
+ default: null;
110
+ parseHTML: (element: AttributeSource) => DocumentRowLine | null;
111
+ renderHTML: (attributes: Record<string, unknown>) => {
112
+ [x: string]: string;
113
+ };
114
+ };
115
+ lineBelow: {
116
+ default: null;
117
+ parseHTML: (element: AttributeSource) => DocumentRowLine | null;
118
+ renderHTML: (attributes: Record<string, unknown>) => {
119
+ [x: string]: string;
120
+ };
121
+ };
122
+ };
123
+ export declare function readRowLineAttributes(attrs: Readonly<Record<string, unknown>>): {
124
+ readonly lineAbove: DocumentRowLine | null;
125
+ readonly lineBelow: DocumentRowLine | null;
49
126
  };
50
127
  export declare const documentCellPrintAttributes: {
51
128
  background: {
@@ -67,5 +144,7 @@ export declare const documentCellPrintAttributes: {
67
144
  };
68
145
  };
69
146
  };
147
+ export declare function imagePrintHtmlAttributes(attrs: Record<string, unknown>): Record<string, string>;
148
+ export declare function dividerPrintHtmlAttributes(attrs: Record<string, unknown>): Record<string, string>;
70
149
  export declare const DocumentFrame: Node<any, any>;
71
150
  export {};