@cosmicdrift/kumiko-bundled-features 0.418.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/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/package.json +16 -11
- package/src/template-resolver/changes.json +38 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Decoration } from "@tiptap/pm/view";
|
|
2
|
+
// Table start + first row + first cell: the widget sits in front of the first cell's content.
|
|
3
|
+
const FIRST_CELL_CONTENT_OFFSET = 3;
|
|
4
|
+
const FIRST_ROW_OFFSET_FROM_WIDGET = FIRST_CELL_CONTENT_OFFSET - 1;
|
|
5
|
+
// Sits in the line of space the table gets above it (one document line), never taller than that.
|
|
6
|
+
const STRIP_CLASS = "absolute bottom-full left-0 z-20 box-border flex h-[calc(var(--doc-line,1.25rem)-1px)] select-none items-center gap-2.5 whitespace-nowrap rounded-full border border-input bg-card pr-0.5 pl-2 text-[calc(var(--doc-line,1.25rem)*0.5)] font-normal uppercase leading-none tracking-wide text-muted-foreground";
|
|
7
|
+
const BUTTON_CLASS = "cursor-pointer rounded-full border px-1.5 py-px text-[1em] font-medium leading-none normal-case tracking-normal";
|
|
8
|
+
const BUTTON_OFF_CLASS = `${BUTTON_CLASS} border-input bg-card text-foreground`;
|
|
9
|
+
const BUTTON_ON_CLASS = `${BUTTON_CLASS} border-foreground bg-card text-foreground`;
|
|
10
|
+
function repeatListsOf(table) {
|
|
11
|
+
const lists = [];
|
|
12
|
+
table.forEach((row) => {
|
|
13
|
+
const each = row.attrs["each"];
|
|
14
|
+
if (typeof each === "string" && each !== "" && !lists.includes(each))
|
|
15
|
+
lists.push(each);
|
|
16
|
+
});
|
|
17
|
+
return lists;
|
|
18
|
+
}
|
|
19
|
+
function toggleHeaderAt(editor, rowPos) {
|
|
20
|
+
editor
|
|
21
|
+
.chain()
|
|
22
|
+
.focus()
|
|
23
|
+
.command(({ tr }) => {
|
|
24
|
+
const row = tr.doc.nodeAt(rowPos);
|
|
25
|
+
if (row === null)
|
|
26
|
+
return false;
|
|
27
|
+
tr.setNodeMarkup(rowPos, undefined, {
|
|
28
|
+
...row.attrs,
|
|
29
|
+
repeatHeader: row.attrs["repeatHeader"] !== true,
|
|
30
|
+
});
|
|
31
|
+
return true;
|
|
32
|
+
})
|
|
33
|
+
.run();
|
|
34
|
+
}
|
|
35
|
+
function createStrip(editor, label, headerLabel, headerRepeats, getPos) {
|
|
36
|
+
const strip = document.createElement("div");
|
|
37
|
+
strip.className = STRIP_CLASS;
|
|
38
|
+
strip.contentEditable = "false";
|
|
39
|
+
strip.setAttribute("data-testid", "document-repeat-strip");
|
|
40
|
+
const name = document.createElement("span");
|
|
41
|
+
name.textContent = label;
|
|
42
|
+
const button = document.createElement("button");
|
|
43
|
+
button.type = "button";
|
|
44
|
+
button.className = headerRepeats ? BUTTON_ON_CLASS : BUTTON_OFF_CLASS;
|
|
45
|
+
button.setAttribute("aria-pressed", String(headerRepeats));
|
|
46
|
+
button.setAttribute("data-testid", "document-repeat-header-toggle");
|
|
47
|
+
button.textContent = headerLabel;
|
|
48
|
+
button.addEventListener("mousedown", (event) => event.preventDefault());
|
|
49
|
+
button.addEventListener("click", () => {
|
|
50
|
+
const pos = getPos();
|
|
51
|
+
if (pos !== undefined)
|
|
52
|
+
toggleHeaderAt(editor, pos - FIRST_ROW_OFFSET_FROM_WIDGET);
|
|
53
|
+
});
|
|
54
|
+
strip.append(name, button);
|
|
55
|
+
return strip;
|
|
56
|
+
}
|
|
57
|
+
// Editor-only: a widget never reaches getHTML or the PDF, and it is absolutely placed on the
|
|
58
|
+
// table's top edge so it takes no height.
|
|
59
|
+
export function repeatStripDecorations(doc, editor, options) {
|
|
60
|
+
const decorations = [];
|
|
61
|
+
doc.descendants((node, pos) => {
|
|
62
|
+
if (node.type.name !== "table")
|
|
63
|
+
return;
|
|
64
|
+
const lists = repeatListsOf(node);
|
|
65
|
+
const firstCellContent = node.firstChild?.firstChild;
|
|
66
|
+
if (lists.length === 0 || firstCellContent === null || firstCellContent === undefined)
|
|
67
|
+
return;
|
|
68
|
+
const headerRepeats = node.firstChild?.attrs["repeatHeader"] === true;
|
|
69
|
+
const label = options.label(lists);
|
|
70
|
+
decorations.push(Decoration.widget(pos + FIRST_CELL_CONTENT_OFFSET, (_view, getPos) => createStrip(editor, label, options.headerLabel, headerRepeats, getPos), {
|
|
71
|
+
side: -1,
|
|
72
|
+
key: `repeat-strip:${label}:${headerRepeats}`,
|
|
73
|
+
ignoreSelection: true,
|
|
74
|
+
stopEvent: () => true,
|
|
75
|
+
}));
|
|
76
|
+
});
|
|
77
|
+
return decorations;
|
|
78
|
+
}
|
|
@@ -9,6 +9,7 @@ import { Table, TableCell, TableHeader, TableRow } from "@tiptap/extension-table
|
|
|
9
9
|
import StarterKit from "@tiptap/starter-kit";
|
|
10
10
|
import { createDocumentImagesNode } from "./document-images.js";
|
|
11
11
|
import { isAllowedDocumentLinkHref, isAllowedDocumentUrlHref, isDocumentPlaceholderHref, } from "./document-link-policy.js";
|
|
12
|
+
import { DocumentBlockStyleAttributes, DocumentFrame, DocumentTextStyleMark, documentCellPrintAttributes, documentTableBordersAttribute, } from "./document-print-style.js";
|
|
12
13
|
import { isDocumentReferenceName } from "./document-reference-name.js";
|
|
13
14
|
import { createDocumentStepsNode } from "./document-steps.js";
|
|
14
15
|
import { attributeParseRule } from "./tiptap-attribute-parse-rule.js";
|
|
@@ -53,7 +54,7 @@ export const DocumentResource = Node.create({
|
|
|
53
54
|
group: "block",
|
|
54
55
|
atom: true,
|
|
55
56
|
addAttributes() {
|
|
56
|
-
return { resource: { default: null }, alt: { default: null } };
|
|
57
|
+
return { resource: { default: null }, alt: { default: null }, bleed: { default: false } };
|
|
57
58
|
},
|
|
58
59
|
parseHTML() {
|
|
59
60
|
return [
|
|
@@ -63,7 +64,11 @@ export const DocumentResource = Node.create({
|
|
|
63
64
|
const resource = element.getAttribute("data-resource");
|
|
64
65
|
if (resource === null || !isDocumentResourceKey(resource))
|
|
65
66
|
return false;
|
|
66
|
-
return {
|
|
67
|
+
return {
|
|
68
|
+
resource,
|
|
69
|
+
alt: element.getAttribute("alt"),
|
|
70
|
+
bleed: element.hasAttribute("data-bleed"),
|
|
71
|
+
};
|
|
67
72
|
},
|
|
68
73
|
},
|
|
69
74
|
];
|
|
@@ -73,9 +78,11 @@ export const DocumentResource = Node.create({
|
|
|
73
78
|
const alt = node.attrs["alt"];
|
|
74
79
|
return [
|
|
75
80
|
"img",
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
{
|
|
82
|
+
"data-resource": node.attrs["resource"],
|
|
83
|
+
...(alt === null || alt === undefined ? {} : { alt }),
|
|
84
|
+
...(node.attrs["bleed"] === true ? { "data-bleed": "" } : {}),
|
|
85
|
+
},
|
|
79
86
|
];
|
|
80
87
|
},
|
|
81
88
|
});
|
|
@@ -154,12 +161,15 @@ export const DocumentTableRow = TableRow.extend({
|
|
|
154
161
|
},
|
|
155
162
|
});
|
|
156
163
|
export const DocumentTable = Table.extend({
|
|
157
|
-
|
|
158
|
-
return
|
|
164
|
+
addAttributes() {
|
|
165
|
+
return { ...(this.parent?.() ?? {}), ...documentTableBordersAttribute };
|
|
166
|
+
},
|
|
167
|
+
renderHTML({ HTMLAttributes }) {
|
|
168
|
+
return ["table", HTMLAttributes, ["tbody", 0]];
|
|
159
169
|
},
|
|
160
170
|
});
|
|
161
171
|
// Span attributes are rendered only when they differ from the default, and
|
|
162
|
-
// colwidth
|
|
172
|
+
// colwidth and background only when set, so `<td><p>x</p></td>` is the
|
|
163
173
|
// canonical cell.
|
|
164
174
|
function plainObjectOrEmpty(value) {
|
|
165
175
|
return isPlainObject(value) ? value : {};
|
|
@@ -177,8 +187,9 @@ function canonicalCellAttributes(attributes) {
|
|
|
177
187
|
},
|
|
178
188
|
colwidth: {
|
|
179
189
|
...plainObjectOrEmpty(attributes["colwidth"]),
|
|
180
|
-
|
|
190
|
+
...documentCellPrintAttributes.colwidth,
|
|
181
191
|
},
|
|
192
|
+
background: documentCellPrintAttributes.background,
|
|
182
193
|
};
|
|
183
194
|
}
|
|
184
195
|
export const DocumentTableCell = TableCell.extend({
|
|
@@ -309,4 +320,7 @@ export const documentExtensions = [
|
|
|
309
320
|
DocumentTextAlign,
|
|
310
321
|
DocumentTextSize,
|
|
311
322
|
DocumentCondition,
|
|
323
|
+
DocumentTextStyleMark,
|
|
324
|
+
DocumentBlockStyleAttributes,
|
|
325
|
+
DocumentFrame,
|
|
312
326
|
];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type DocumentFont } from "./document-fonts.ts";
|
|
2
|
+
export type DocumentTextStyle = {
|
|
3
|
+
readonly color?: string | null;
|
|
4
|
+
readonly font?: DocumentFont | null;
|
|
5
|
+
readonly sizePt?: number | null;
|
|
6
|
+
};
|
|
7
|
+
export type DocumentBlockStyle = {
|
|
8
|
+
readonly lineHeight?: number | null;
|
|
9
|
+
readonly spaceBeforePt?: number | null;
|
|
10
|
+
readonly spaceAfterPt?: number | null;
|
|
11
|
+
};
|
|
12
|
+
export type DocumentFrameBox = {
|
|
13
|
+
readonly xMm: number;
|
|
14
|
+
readonly yMm: number;
|
|
15
|
+
readonly widthMm: number;
|
|
16
|
+
readonly heightMm: number;
|
|
17
|
+
};
|
|
18
|
+
export declare function documentTextStyleCss(style: DocumentTextStyle): string;
|
|
19
|
+
export declare function documentBlockStyleCss(style: DocumentBlockStyle): string;
|
|
20
|
+
export declare function documentFrameCss(frame: DocumentFrameBox): string;
|
|
21
|
+
export declare function documentCellStyleCss(style: {
|
|
22
|
+
readonly background?: string | null;
|
|
23
|
+
}): string;
|
|
24
|
+
export declare const FRAME_FLOW_GAP_MM = 8;
|
|
25
|
+
export declare const PARAGRAPH_DEFAULT_LINE_HEIGHT = 1.2;
|
|
26
|
+
export declare function documentLinePt(fontSizePt: number): number;
|
|
27
|
+
export declare const DOCUMENT_LINE_VARIABLE = "--doc-line";
|
|
28
|
+
export declare const SENDER_LINE_SIZE_PT = 7;
|
|
29
|
+
export declare function addressParagraphCss(isSenderLine: boolean): string;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Pure CSS-string builders over already validated values. Shared by the server compile and the
|
|
2
|
+
// editor decorations, so the PDF and the editor measure the same way. The custom properties
|
|
3
|
+
// (--paper-pt, --paper-mm, ...) default to real units for print; the editor overrides them to scale.
|
|
4
|
+
import { DOCUMENT_FONT_PRINT_STACKS } from "./document-fonts.js";
|
|
5
|
+
function pt(value) {
|
|
6
|
+
return `calc(${value} * var(--paper-pt,1pt))`;
|
|
7
|
+
}
|
|
8
|
+
function mm(value) {
|
|
9
|
+
return `calc(${value} * var(--paper-mm,1mm))`;
|
|
10
|
+
}
|
|
11
|
+
function declarations(parts) {
|
|
12
|
+
return parts.filter((part) => part !== null).join(";");
|
|
13
|
+
}
|
|
14
|
+
export function documentTextStyleCss(style) {
|
|
15
|
+
return declarations([
|
|
16
|
+
style.color == null ? null : `color:${style.color}`,
|
|
17
|
+
style.font == null ? null : `font-family:${DOCUMENT_FONT_PRINT_STACKS[style.font]}`,
|
|
18
|
+
style.sizePt == null ? null : `font-size:${pt(style.sizePt)}`,
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
export function documentBlockStyleCss(style) {
|
|
22
|
+
return declarations([
|
|
23
|
+
style.lineHeight == null ? null : `line-height:${style.lineHeight}`,
|
|
24
|
+
style.spaceBeforePt == null ? null : `margin-top:${pt(style.spaceBeforePt)}`,
|
|
25
|
+
style.spaceAfterPt == null ? null : `margin-bottom:${pt(style.spaceAfterPt)}`,
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
// Chromium clips body content at the margin box, so a frame that sits in the margin is moved
|
|
29
|
+
// to the content edge; the first-page margin override in the print CSS makes that edge reach the frame.
|
|
30
|
+
export function documentFrameCss(frame) {
|
|
31
|
+
return declarations([
|
|
32
|
+
"position:absolute",
|
|
33
|
+
"overflow:hidden",
|
|
34
|
+
`--frame-x:${mm(frame.xMm)}`,
|
|
35
|
+
`left:max(0px,calc(${frame.xMm} * var(--paper-mm,1mm) - var(--page-margin-left,0px)))`,
|
|
36
|
+
`top:max(0px,calc(${frame.yMm} * var(--paper-mm,1mm) - var(--first-page-top,0px)))`,
|
|
37
|
+
`width:${mm(frame.widthMm)}`,
|
|
38
|
+
`height:${mm(frame.heightMm)}`,
|
|
39
|
+
]);
|
|
40
|
+
}
|
|
41
|
+
export function documentCellStyleCss(style) {
|
|
42
|
+
return style.background == null ? "" : `background-color:${style.background}`;
|
|
43
|
+
}
|
|
44
|
+
// Gap between the bottom of a flow-reserving frame and the first flowing line, shared by the
|
|
45
|
+
// editor's reserved area and the PDF's first-page spacer.
|
|
46
|
+
export const FRAME_FLOW_GAP_MM = 8;
|
|
47
|
+
// Effective paragraph defaults when nothing is set: the PDF body and the editor paper both use
|
|
48
|
+
// them, so a line sits at the same height in both.
|
|
49
|
+
export const PARAGRAPH_DEFAULT_LINE_HEIGHT = 1.2;
|
|
50
|
+
// One "line" (the body size times the default line height) is the spacing unit of paragraphs,
|
|
51
|
+
// headings, tables and lists, so text sits on a line grid with one blank line between blocks.
|
|
52
|
+
export function documentLinePt(fontSizePt) {
|
|
53
|
+
return Number((fontSizePt * PARAGRAPH_DEFAULT_LINE_HEIGHT).toFixed(2));
|
|
54
|
+
}
|
|
55
|
+
export const DOCUMENT_LINE_VARIABLE = "--doc-line";
|
|
56
|
+
export const SENDER_LINE_SIZE_PT = 7;
|
|
57
|
+
const SENDER_LINE_INSET_MM = 1.7;
|
|
58
|
+
const SENDER_LINE_RECIPIENT_GAP_MM = 4;
|
|
59
|
+
const SENDER_LINE_RULE_COLOR = "#8a877e";
|
|
60
|
+
// Every paragraph of an address frame starts at the page's text margin, or inset when the frame
|
|
61
|
+
// sits right of it; the sender line also carries the rule and the gap to the recipient. Only
|
|
62
|
+
// emitted for a real sender line, so an address frame without one starts with the recipient.
|
|
63
|
+
export function addressParagraphCss(isSenderLine) {
|
|
64
|
+
return declarations([
|
|
65
|
+
`margin-left:max(${mm(SENDER_LINE_INSET_MM)},calc(var(--paper-margin-left,0px) - var(--frame-x,0px)))`,
|
|
66
|
+
`padding-right:${mm(SENDER_LINE_INSET_MM)}`,
|
|
67
|
+
"margin-bottom:0",
|
|
68
|
+
...(isSenderLine
|
|
69
|
+
? [
|
|
70
|
+
`border-bottom:1px solid ${SENDER_LINE_RULE_COLOR}`,
|
|
71
|
+
`margin-bottom:${mm(SENDER_LINE_RECIPIENT_GAP_MM)}`,
|
|
72
|
+
`padding-bottom:${mm(0.7)}`,
|
|
73
|
+
]
|
|
74
|
+
: []),
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
@@ -53,14 +53,21 @@ function renderBlockOptionsBar(c, selectedBlock) {
|
|
|
53
53
|
const { t, Button, editor } = c;
|
|
54
54
|
return (_jsxs("div", { className: BUBBLE_BAR_CLASS, "data-testid": "document-block-options", children: [_jsxs("span", { className: "px-1.5 text-[10px] text-muted-foreground", children: [selectedBlock.type === "resource"
|
|
55
55
|
? t("template-resolver.documentEditor.resourceKey")
|
|
56
|
-
: t("template-resolver.documentEditor.buttonTarget"), ": ", selectedBlock.type === "button" ? (_jsx("strong", { children: buttonTargetLabel(selectedBlock.detail, c.variableLabels) })) : (_jsx("code", { children: selectedBlock.detail }))] }), _jsx(Button, { type: "button", size: "sm", variant: "
|
|
56
|
+
: t("template-resolver.documentEditor.buttonTarget"), ": ", selectedBlock.type === "button" ? (_jsx("strong", { children: buttonTargetLabel(selectedBlock.detail, c.variableLabels) })) : (_jsx("code", { children: selectedBlock.detail }))] }), selectedBlock.type === "resource" && c.hosted && c.print === "flow" && (_jsx(Button, { type: "button", size: "sm", variant: "secondary", pressed: selectedBlock.bleed, testId: "document-image-bleed", onClick: () => {
|
|
57
|
+
editor
|
|
58
|
+
.chain()
|
|
59
|
+
.focus()
|
|
60
|
+
.updateAttributes("resource", { bleed: !selectedBlock.bleed })
|
|
61
|
+
.run();
|
|
62
|
+
}, children: t("documentDesigner.editor.imageBleed") })), _jsx(Button, { type: "button", size: "sm", variant: "danger-ghost", onClick: () => {
|
|
57
63
|
editor.chain().focus().deleteNode(selectedBlock.type).run();
|
|
58
64
|
}, children: t("template-resolver.documentEditor.removeBlock") })] }));
|
|
59
65
|
}
|
|
60
66
|
function renderBubbleRepeatBar(c) {
|
|
61
67
|
const { t, Button, editor } = c;
|
|
62
68
|
const repeatTable = c.activeState?.repeatTable ?? null;
|
|
63
|
-
return (repeatTable !== null &&
|
|
69
|
+
return (repeatTable !== null &&
|
|
70
|
+
c.print === "none" && (_jsxs("div", { "data-testid": "document-repeat-bar", className: BUBBLE_BAR_CLASS, children: [_jsx("span", { className: "px-1.5 text-[10px] uppercase tracking-wide text-muted-foreground", children: repeatBarLabelOf(c) }), _jsx(Button, { type: "button", variant: "secondary", size: "sm", pressed: repeatTable.headerRepeats, onClick: () => toggleRepeatHeader(editor), children: t("template-resolver.documentEditor.repeatHeader") })] })));
|
|
64
71
|
}
|
|
65
72
|
export function renderBubbleMenu(c) {
|
|
66
73
|
const { editor } = c;
|
|
@@ -74,12 +81,15 @@ export function renderBubbleMenu(c) {
|
|
|
74
81
|
}, getReferencedVirtualElement: () => selectedBlockReference(editor), shouldShow: ({ editor: e, element }) =>
|
|
75
82
|
// A leading image is selected by default; the bubble belongs to a deliberate selection.
|
|
76
83
|
(e.isFocused || element.contains(document.activeElement)) &&
|
|
77
|
-
(e.isActive("resource") ||
|
|
84
|
+
(e.isActive("resource") ||
|
|
85
|
+
e.isActive("button") ||
|
|
86
|
+
(c.print === "none" && findRepeatTable(e) !== null)), children: selectedBlock !== null ? renderBlockOptionsBar(c, selectedBlock) : renderBubbleRepeatBar(c) }, mountKeyOf(editor)));
|
|
78
87
|
}
|
|
79
88
|
export function renderInlineRepeatBar(c) {
|
|
80
89
|
const { t, Button, editor } = c;
|
|
81
90
|
const repeatTable = c.activeState?.repeatTable ?? null;
|
|
82
91
|
return (repeatTable !== null &&
|
|
92
|
+
c.print === "none" &&
|
|
83
93
|
!c.readOnly &&
|
|
84
94
|
!c.canvas && (_jsxs("div", { "data-testid": "document-repeat-bar", className: "flex flex-wrap items-center gap-3 border-b border-input bg-muted/40 px-2 py-1 text-xs", children: [_jsx("span", { className: "font-medium", children: repeatBarLabelOf(c) }), _jsx(Button, { type: "button", variant: "secondary", size: "sm", pressed: repeatTable.headerRepeats, onClick: () => toggleRepeatHeader(editor), children: t("template-resolver.documentEditor.repeatHeader") })] })));
|
|
85
95
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Editor } from "@tiptap/core";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
-
|
|
3
|
+
import type { DocumentPrintMode } from "./document-toolbar-blocks.ts";
|
|
4
|
+
export declare function renderEditorContent(editor: Editor, canvas: boolean, hosted: boolean, print: DocumentPrintMode): ReactNode;
|
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "@cosmicdrift/kumiko-renderer/web";
|
|
3
3
|
import { EditorContent } from "@tiptap/react";
|
|
4
|
-
|
|
4
|
+
// The PDF pads cells 4px / 6px; in paper units so the canvas lines up at every zoom.
|
|
5
|
+
const CANVAS_CELL_PADDING_CLASS = "[&_td]:px-[calc(1.5875*var(--paper-mm,1mm))] [&_td]:py-[calc(1.0583*var(--paper-mm,1mm))] [&_th]:px-[calc(1.5875*var(--paper-mm,1mm))] [&_th]:py-[calc(1.0583*var(--paper-mm,1mm))]";
|
|
6
|
+
// The PDF has no heading rules, so the canvas copies the browser defaults (size, margin, inherited line height).
|
|
7
|
+
function headingClasses(canvas, page) {
|
|
8
|
+
return canvas
|
|
9
|
+
? cn("[&_h1]:text-[length:2em] [&_h1]:leading-[inherit] [&_h1]:font-bold [&_h2]:text-[length:1.5em] [&_h2]:leading-[inherit] [&_h2]:font-bold [&_h3]:text-[length:1.17em] [&_h3]:leading-[inherit] [&_h3]:font-bold", page
|
|
10
|
+
? "[&_:is(h1,h2,h3)]:mt-0 [&_:is(h1,h2,h3)]:mb-(--doc-line)"
|
|
11
|
+
: "[&_h1]:my-[0.67em] [&_h2]:my-[0.83em] [&_h3]:my-[1em]", " [&_:is(h1,h2,h3)_[data-variable-chip]]:text-[length:calc(var(--paper-font-size)*0.9)]")
|
|
12
|
+
: "[&_h1]:text-xl [&_h1]:font-bold [&_h2]:text-lg [&_h2]:font-bold [&_h3]:text-base [&_h3]:font-bold";
|
|
13
|
+
}
|
|
14
|
+
function tableClasses(canvas, page) {
|
|
15
|
+
return canvas
|
|
16
|
+
? cn(page
|
|
17
|
+
? "[&_table]:mb-(--doc-line) [&_table]:mt-0 [&_.ProseMirror>.tableWrapper:last-child_table]:mb-0"
|
|
18
|
+
: "[&_table]:mb-2 [&_table]:mt-6 [&_.ProseMirror>:first-child_table]:mt-0 [&_.ProseMirror>table:first-child]:mt-0", "[&_td:last-child>p[data-size=small][data-align=right]]:whitespace-nowrap")
|
|
19
|
+
: "[&_table]:my-2";
|
|
20
|
+
}
|
|
21
|
+
// The PDF prints cells top-aligned, header like body text and no rules unless the layout sets a
|
|
22
|
+
// table style; the dashed outline only marks the cells while editing, like the frame outline.
|
|
23
|
+
function cellClasses(canvas, print) {
|
|
24
|
+
return cn(print !== "none"
|
|
25
|
+
? cn("[&_td]:align-top [&_th]:align-top [&_th]:font-bold", "[&_td]:outline-dashed [&_td]:outline-1 [&_td]:-outline-offset-1 [&_td]:outline-border [&_th]:outline-dashed [&_th]:outline-1 [&_th]:-outline-offset-1 [&_th]:outline-border")
|
|
26
|
+
: "[&_td]:border-b [&_td]:border-border [&_th]:border-b [&_th]:border-border [&_th]:text-xs [&_th]:text-muted-foreground", canvas ? CANVAS_CELL_PADDING_CLASS : "[&_td]:px-2 [&_td]:py-1.5 [&_th]:px-2 [&_th]:py-1.5", print === "none" && (canvas ? "[&_th]:font-bold" : "[&_th]:font-medium"));
|
|
27
|
+
}
|
|
28
|
+
export function renderEditorContent(editor, canvas, hosted, print) {
|
|
29
|
+
const page = print === "page";
|
|
5
30
|
return (_jsx(EditorContent, { editor: editor, className: cn(!canvas && "min-h-40 px-3 py-2 text-base outline-none md:text-sm", canvas && "text-sm", "[&_.ProseMirror-focused_.ProseMirror-selectednode]:ring-2 [&_.ProseMirror-focused_.ProseMirror-selectednode]:ring-primary", hosted
|
|
6
31
|
? "[&_.ProseMirror]:outline-none"
|
|
7
|
-
: "[&_.ProseMirror]:min-h-40 [&_.ProseMirror]:outline-none",
|
|
8
|
-
|
|
9
|
-
|
|
32
|
+
: "[&_.ProseMirror]:min-h-40 [&_.ProseMirror]:outline-none",
|
|
33
|
+
// Frames are placed against the paper, so the editor root must not become their containing block.
|
|
34
|
+
// Important: prosemirror's own unlayered `.ProseMirror{position:relative}` beats the utilities layer.
|
|
35
|
+
print === "page" && "[&_.ProseMirror]:static!",
|
|
36
|
+
// The PDF gives every body paragraph this spacing (see PRINT_CSS); cells and list items stay flush.
|
|
37
|
+
page &&
|
|
38
|
+
"[&_p]:mb-(--doc-line) [&_ul]:mb-(--doc-line) [&_ol]:mb-(--doc-line) [&_td>p]:mb-0 [&_th>p]:mb-0 [&_li>p]:mb-0 [&_td>:last-child]:mb-0 [&_th>:last-child]:mb-0 [&_li>:last-child]:mb-0 [&_.ProseMirror>:last-child]:mb-0", print !== "none" &&
|
|
39
|
+
"[&_td]:relative [&_th]:relative [&_.column-resize-handle]:pointer-events-none [&_.column-resize-handle]:absolute [&_.column-resize-handle]:-right-0.5 [&_.column-resize-handle]:bottom-0 [&_.column-resize-handle]:top-0 [&_.column-resize-handle]:w-1 [&_.column-resize-handle]:bg-primary", "[&_[data-borders=none]_td]:border-transparent [&_[data-borders=none]_th]:border-transparent", "[&_ul]:list-disc [&_ol]:list-decimal [&_ul]:pl-6 [&_ol]:pl-6", headingClasses(canvas, page), "[&_a]:underline [&_a]:text-primary", "[&_strong]:font-bold [&_em]:italic [&_u]:underline", tableClasses(canvas, page),
|
|
40
|
+
// A layout region has no content below its table; margins there only inflate the region box.
|
|
41
|
+
hosted && "[&_td>div]:my-0 [&_.ProseMirror>.tableWrapper:last-child_table]:mb-0", "[&_table]:w-full [&_table]:border-collapse", "[&_td>p]:m-0 [&_th>p]:m-0 [&_th]:text-left", cellClasses(canvas, print), "[&_tr[data-each]>td]:bg-muted/50", "[&_[data-align=left]]:text-left [&_[data-align=center]]:text-center [&_[data-align=right]]:text-right [&_[data-align=justify]]:text-justify", "[&_p[data-size=small]]:text-xs [&_p[data-size=small]]:text-muted-foreground", "[&_a[data-button]]:inline-block [&_a[data-button]]:rounded-full [&_a[data-button]]:bg-primary [&_a[data-button]]:px-4 [&_a[data-button]]:py-1.5 [&_a[data-button]]:text-primary-foreground [&_a[data-button]]:no-underline",
|
|
10
42
|
// A chip in the button would be primary on primary; it inverts to stay readable.
|
|
11
43
|
"[&_a[data-button]_[data-variable-chip]]:border-primary-foreground/40 [&_a[data-button]_[data-variable-chip]]:bg-primary-foreground/15 [&_a[data-button]_[data-variable-chip]]:text-primary-foreground", "[&_hr]:my-3 [&_hr]:border-input", "[&_.is-editor-empty]:before:pointer-events-none [&_.is-editor-empty]:before:float-left [&_.is-editor-empty]:before:h-0 [&_.is-editor-empty]:before:text-muted-foreground [&_.is-editor-empty]:before:content-[attr(data-placeholder)]") }));
|
|
12
44
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Translate } from "@cosmicdrift/kumiko-renderer/headless";
|
|
2
2
|
import type { Editor } from "@tiptap/core";
|
|
3
3
|
import type { Dispatch, SetStateAction } from "react";
|
|
4
|
+
import type { PrintDefaultLabels } from "./document-print-defaults.ts";
|
|
4
5
|
import { type ActiveState, type PanelKind, type Primitives } from "./document-tiptap-helpers.ts";
|
|
5
|
-
import type { DocumentToolbarBlock } from "./document-toolbar-blocks.ts";
|
|
6
|
+
import type { DocumentPrintBlock, DocumentPrintMode, DocumentToolbarBlock } from "./document-toolbar-blocks.ts";
|
|
6
7
|
import type { DocumentEditorLabels } from "./use-document-tiptap-model.ts";
|
|
7
8
|
export type TiptapContext = {
|
|
8
9
|
readonly id: string;
|
|
@@ -16,6 +17,8 @@ export type TiptapContext = {
|
|
|
16
17
|
readonly canvas: boolean;
|
|
17
18
|
readonly compact: boolean;
|
|
18
19
|
readonly hosted: boolean;
|
|
20
|
+
readonly print: DocumentPrintMode;
|
|
21
|
+
readonly printDefaults: PrintDefaultLabels;
|
|
19
22
|
readonly labels: DocumentEditorLabels;
|
|
20
23
|
readonly activeState: ActiveState | null;
|
|
21
24
|
readonly openPanel: PanelKind | null;
|
|
@@ -31,8 +34,9 @@ export type TiptapContext = {
|
|
|
31
34
|
readonly stableLabels: Readonly<Record<string, string>>;
|
|
32
35
|
readonly togglePanel: (kind: PanelKind) => void;
|
|
33
36
|
readonly runBlock: (block: DocumentToolbarBlock) => void;
|
|
37
|
+
readonly runPrintBlock: (block: DocumentPrintBlock) => void;
|
|
34
38
|
readonly setBlockStyle: (style: string) => void;
|
|
35
39
|
readonly repeatListLabel: string | undefined;
|
|
36
40
|
};
|
|
37
|
-
export type TiptapContextInput = Pick<TiptapContext, "id" | "t" | "Button" | "Field" | "Input" | "ActionOverflowMenu" | "editor" | "readOnly" | "canvas" | "compact" | "hosted" | "labels" | "activeState" | "openPanel" | "setOpenPanel" | "canvasScroller" | "setCanvasScroller" | "showHtml" | "setShowHtml" | "blocks" | "variables" | "imageVariables" | "variableLabels" | "stableLabels">;
|
|
41
|
+
export type TiptapContextInput = Pick<TiptapContext, "id" | "t" | "Button" | "Field" | "Input" | "ActionOverflowMenu" | "editor" | "readOnly" | "canvas" | "compact" | "hosted" | "print" | "printDefaults" | "labels" | "activeState" | "openPanel" | "setOpenPanel" | "canvasScroller" | "setCanvasScroller" | "showHtml" | "setShowHtml" | "blocks" | "variables" | "imageVariables" | "variableLabels" | "stableLabels">;
|
|
38
42
|
export declare function buildTiptapContext(input: TiptapContextInput): TiptapContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BLOCK_PANEL, HEADING_LEVELS, isParagraphStyle, variableLabelOf, } from "./document-tiptap-helpers.js";
|
|
1
|
+
import { BLOCK_PANEL, HEADING_LEVELS, insertPrintBlock, isParagraphStyle, variableLabelOf, } from "./document-tiptap-helpers.js";
|
|
2
2
|
function repeatListLabelOf(activeState, variableLabels) {
|
|
3
3
|
const repeatTable = activeState?.repeatTable ?? null;
|
|
4
4
|
return repeatTable !== null && repeatTable.lists.length === 1
|
|
@@ -37,6 +37,7 @@ export function buildTiptapContext(input) {
|
|
|
37
37
|
...input,
|
|
38
38
|
togglePanel,
|
|
39
39
|
runBlock,
|
|
40
|
+
runPrintBlock: (block) => insertPrintBlock(editor, block),
|
|
40
41
|
setBlockStyle,
|
|
41
42
|
repeatListLabel: repeatListLabelOf(input.activeState, input.variableLabels),
|
|
42
43
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import { type DocumentEditorProps } from "./document-toolbar-blocks.ts";
|
|
3
|
-
export default function DocumentTiptapEditor({ id, value, onChange, variables, readOnly, blocks: configuredBlocks, imageVariables, variableLabels, systemVariables, resourcePreviews, chrome, toolbar, renderPaper, toolbarHost, onEditorReady, }: DocumentEditorProps): ReactNode;
|
|
3
|
+
export default function DocumentTiptapEditor({ id, value, onChange, variables, readOnly, blocks: configuredBlocks, imageVariables, variableLabels, systemVariables, resourcePreviews, chrome, layoutValues, toolbar, renderPaper, toolbarHost, onEditorReady, onFrameControlChange, }: DocumentEditorProps): ReactNode;
|
|
@@ -4,20 +4,24 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
// never import this file statically, tiptap must only load when a "document"
|
|
5
5
|
// collection is rendered. Variables are inserted as `variable` nodes only,
|
|
6
6
|
// never as `{{name}}` text, so the sanitizer's schema keeps them.
|
|
7
|
-
import { TextareaContentEditor, usePrimitives, useTranslation } from "@cosmicdrift/kumiko-renderer";
|
|
7
|
+
import { TextareaContentEditor, useLocale, usePrimitives, useTranslation, } from "@cosmicdrift/kumiko-renderer";
|
|
8
8
|
import { useEffect } from "react";
|
|
9
|
+
import { printDefaultLabelsOf } from "./document-print-defaults.js";
|
|
9
10
|
import { renderEditorContent } from "./document-tiptap-content.js";
|
|
10
11
|
import { buildTiptapContext } from "./document-tiptap-context.js";
|
|
11
|
-
import { NO_LABELS, NO_NAMES, NO_PREVIEWS } from "./document-tiptap-helpers.js";
|
|
12
|
+
import { NO_LABELS, NO_NAMES, NO_PREVIEWS, printModeOf } from "./document-tiptap-helpers.js";
|
|
12
13
|
import { renderHostedEditor, renderInlineEditor } from "./document-tiptap-layout.js";
|
|
13
|
-
import { MAIL_DOCUMENT_BLOCKS } from "./document-toolbar-blocks.js";
|
|
14
|
+
import { MAIL_DOCUMENT_BLOCKS, } from "./document-toolbar-blocks.js";
|
|
14
15
|
import { useDocumentTiptapModel } from "./use-document-tiptap-model.js";
|
|
15
|
-
|
|
16
|
+
const NO_LAYOUT_VALUES = {};
|
|
17
|
+
export default function DocumentTiptapEditor({ id, value, onChange, variables, readOnly, blocks: configuredBlocks = MAIL_DOCUMENT_BLOCKS, imageVariables = NO_NAMES, variableLabels = NO_LABELS, systemVariables = NO_NAMES, resourcePreviews = NO_PREVIEWS, chrome = "default", layoutValues = NO_LAYOUT_VALUES, toolbar = "full", renderPaper, toolbarHost, onEditorReady, onFrameControlChange, }) {
|
|
16
18
|
const t = useTranslation();
|
|
19
|
+
const locale = useLocale().locale();
|
|
17
20
|
const { ActionOverflowMenu, Button, Field, Input } = usePrimitives();
|
|
18
21
|
const canvas = chrome === "canvas";
|
|
19
22
|
const compact = toolbar === "compact" && !canvas;
|
|
20
23
|
const hosted = toolbarHost !== undefined;
|
|
24
|
+
const print = printModeOf(configuredBlocks, hosted, canvas);
|
|
21
25
|
// A photo block needs an images variable to bind to; without one the button would open an empty panel.
|
|
22
26
|
const blocks = imageVariables.length === 0
|
|
23
27
|
? configuredBlocks.filter((block) => block !== "images")
|
|
@@ -28,6 +32,8 @@ export default function DocumentTiptapEditor({ id, value, onChange, variables, r
|
|
|
28
32
|
onChange,
|
|
29
33
|
readOnly,
|
|
30
34
|
onEditorReady,
|
|
35
|
+
onFrameControlChange,
|
|
36
|
+
print,
|
|
31
37
|
variableLabels,
|
|
32
38
|
systemVariables,
|
|
33
39
|
resourcePreviews,
|
|
@@ -67,6 +73,8 @@ export default function DocumentTiptapEditor({ id, value, onChange, variables, r
|
|
|
67
73
|
canvas,
|
|
68
74
|
compact,
|
|
69
75
|
hosted,
|
|
76
|
+
print,
|
|
77
|
+
printDefaults: printDefaultLabelsOf(t, locale, layoutValues),
|
|
70
78
|
labels: model.labels,
|
|
71
79
|
activeState: model.activeState,
|
|
72
80
|
openPanel: model.openPanel,
|
|
@@ -81,7 +89,7 @@ export default function DocumentTiptapEditor({ id, value, onChange, variables, r
|
|
|
81
89
|
variableLabels,
|
|
82
90
|
stableLabels: model.stableLabels,
|
|
83
91
|
});
|
|
84
|
-
const editorContent = renderEditorContent(editor, canvas, hosted);
|
|
92
|
+
const editorContent = renderEditorContent(editor, canvas, hosted, print);
|
|
85
93
|
if (hosted)
|
|
86
94
|
return renderHostedEditor(context, toolbarHost, editorContent);
|
|
87
95
|
return renderInlineEditor(context, canvas && renderPaper !== undefined ? renderPaper(editorContent) : editorContent);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { usePrimitives } from "@cosmicdrift/kumiko-renderer";
|
|
2
2
|
import type { Editor, JSONContent } from "@tiptap/core";
|
|
3
|
-
import type { DocumentResourcePreview, DocumentToolbarBlock } from "./document-toolbar-blocks.ts";
|
|
3
|
+
import type { DocumentPrintBlock, DocumentPrintMode, DocumentResourcePreview, DocumentToolbarBlock } from "./document-toolbar-blocks.ts";
|
|
4
4
|
export declare const NO_LABELS: Readonly<Record<string, string>>;
|
|
5
5
|
export declare const NO_NAMES: readonly string[];
|
|
6
6
|
export declare const NO_PREVIEWS: Readonly<Record<string, DocumentResourcePreview>>;
|
|
@@ -8,6 +8,31 @@ export declare function previewsKey(previews: Readonly<Record<string, DocumentRe
|
|
|
8
8
|
export type PanelKind = "link" | "placeholder" | "image" | "button" | "repeat" | "align" | "steps" | "images";
|
|
9
9
|
export declare const CANVAS_INLINE_BLOCKS: readonly DocumentToolbarBlock[];
|
|
10
10
|
export declare const BLOCK_PANEL: Partial<Record<DocumentToolbarBlock, PanelKind>>;
|
|
11
|
+
export declare function printModeOf(blocks: readonly DocumentToolbarBlock[], hosted: boolean, canvas: boolean): DocumentPrintMode;
|
|
12
|
+
export declare const FONT_SIZES_PT: readonly [6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 24, 36];
|
|
13
|
+
export declare const LINE_HEIGHTS: readonly [1, 1.15, 1.2, 1.25, 1.5, 2];
|
|
14
|
+
export declare const PARAGRAPH_SPACES_PT: readonly [0, 3, 6, 8, 12, 18, 24];
|
|
15
|
+
export type PrintTextStyleState = {
|
|
16
|
+
readonly font: string | null;
|
|
17
|
+
readonly sizePt: number | null;
|
|
18
|
+
readonly color: string | null;
|
|
19
|
+
};
|
|
20
|
+
export type PrintBlockStyleState = {
|
|
21
|
+
readonly lineHeight: number | null;
|
|
22
|
+
readonly spaceBeforePt: number | null;
|
|
23
|
+
readonly spaceAfterPt: number | null;
|
|
24
|
+
};
|
|
25
|
+
export type PrintTableState = {
|
|
26
|
+
readonly bordersOff: boolean;
|
|
27
|
+
readonly cellBackground: string | null;
|
|
28
|
+
};
|
|
29
|
+
type TextStylePatch = {
|
|
30
|
+
readonly [K in keyof PrintTextStyleState]?: PrintTextStyleState[K];
|
|
31
|
+
};
|
|
32
|
+
export declare function setPrintTextStyle(editor: Editor, patch: TextStylePatch): void;
|
|
33
|
+
export declare function setPrintBlockStyle(editor: Editor, patch: Partial<PrintBlockStyleState>): void;
|
|
34
|
+
export declare function toggleTableBorders(editor: Editor): void;
|
|
35
|
+
export declare function insertPrintBlock(editor: Editor, block: DocumentPrintBlock): void;
|
|
11
36
|
export type RepeatTableState = {
|
|
12
37
|
readonly lists: readonly string[];
|
|
13
38
|
readonly headerRepeats: boolean;
|
|
@@ -37,11 +62,15 @@ export declare function activeStateOf(e: Editor, showHtml: boolean): {
|
|
|
37
62
|
orderedList: boolean;
|
|
38
63
|
link: boolean;
|
|
39
64
|
repeatTable: RepeatTableState | null;
|
|
65
|
+
textStyle: PrintTextStyleState;
|
|
66
|
+
paragraphStyle: PrintBlockStyleState;
|
|
67
|
+
printTable: PrintTableState | null;
|
|
40
68
|
};
|
|
41
69
|
export type Primitives = ReturnType<typeof usePrimitives>;
|
|
42
70
|
export type SelectedBlock = {
|
|
43
71
|
readonly type: "resource" | "button";
|
|
44
72
|
readonly detail: string;
|
|
73
|
+
readonly bleed: boolean;
|
|
45
74
|
};
|
|
46
75
|
export type ActiveState = ReturnType<typeof activeStateOf>;
|
|
47
76
|
export {};
|