postext 1.70.6 → 1.72.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/README.md +1 -0
- package/dist/__tests__/exports.test.js +7 -0
- package/dist/__tests__/exports.test.js.map +1 -1
- package/dist/__tests__/fonts/strikeout.test.d.ts +2 -0
- package/dist/__tests__/fonts/strikeout.test.d.ts.map +1 -0
- package/dist/__tests__/fonts/strikeout.test.js +106 -0
- package/dist/__tests__/fonts/strikeout.test.js.map +1 -0
- package/dist/__tests__/paint/canvasFormFields.test.d.ts +2 -0
- package/dist/__tests__/paint/canvasFormFields.test.d.ts.map +1 -0
- package/dist/__tests__/paint/canvasFormFields.test.js +89 -0
- package/dist/__tests__/paint/canvasFormFields.test.js.map +1 -0
- package/dist/__tests__/paint/strikethrough.test.d.ts +2 -0
- package/dist/__tests__/paint/strikethrough.test.d.ts.map +1 -0
- package/dist/__tests__/paint/strikethrough.test.js +177 -0
- package/dist/__tests__/paint/strikethrough.test.js.map +1 -0
- package/dist/__tests__/paint/underline.test.d.ts +2 -0
- package/dist/__tests__/paint/underline.test.d.ts.map +1 -0
- package/dist/__tests__/paint/underline.test.js +140 -0
- package/dist/__tests__/paint/underline.test.js.map +1 -0
- package/dist/__tests__/parse/formFields.test.d.ts +2 -0
- package/dist/__tests__/parse/formFields.test.d.ts.map +1 -0
- package/dist/__tests__/parse/formFields.test.js +107 -0
- package/dist/__tests__/parse/formFields.test.js.map +1 -0
- package/dist/__tests__/parse/strikethrough.test.d.ts +2 -0
- package/dist/__tests__/parse/strikethrough.test.d.ts.map +1 -0
- package/dist/__tests__/parse/strikethrough.test.js +97 -0
- package/dist/__tests__/parse/strikethrough.test.js.map +1 -0
- package/dist/__tests__/parse/underline.test.d.ts +2 -0
- package/dist/__tests__/parse/underline.test.d.ts.map +1 -0
- package/dist/__tests__/parse/underline.test.js +161 -0
- package/dist/__tests__/parse/underline.test.js.map +1 -0
- package/dist/__tests__/pipeline/callouts/calloutHangingIndent.test.d.ts +2 -0
- package/dist/__tests__/pipeline/callouts/calloutHangingIndent.test.d.ts.map +1 -0
- package/dist/__tests__/pipeline/callouts/calloutHangingIndent.test.js +139 -0
- package/dist/__tests__/pipeline/callouts/calloutHangingIndent.test.js.map +1 -0
- package/dist/canvas-backend/annotations.d.ts.map +1 -1
- package/dist/canvas-backend/annotations.js +4 -0
- package/dist/canvas-backend/annotations.js.map +1 -1
- package/dist/canvas-backend/blockRender/linkPaint.d.ts +3 -0
- package/dist/canvas-backend/blockRender/linkPaint.d.ts.map +1 -1
- package/dist/canvas-backend/blockRender/linkPaint.js +5 -0
- package/dist/canvas-backend/blockRender/linkPaint.js.map +1 -1
- package/dist/canvas-backend/chip.d.ts +4 -0
- package/dist/canvas-backend/chip.d.ts.map +1 -1
- package/dist/canvas-backend/chip.js +33 -1
- package/dist/canvas-backend/chip.js.map +1 -1
- package/dist/canvas-backend/index.d.ts +5 -0
- package/dist/canvas-backend/index.d.ts.map +1 -1
- package/dist/canvas-backend/index.js +5 -1
- package/dist/canvas-backend/index.js.map +1 -1
- package/dist/defaults/boxes/calloutStyles/resolve.d.ts.map +1 -1
- package/dist/defaults/boxes/calloutStyles/resolve.js +4 -0
- package/dist/defaults/boxes/calloutStyles/resolve.js.map +1 -1
- package/dist/defaults/boxes/calloutStyles/strip.d.ts.map +1 -1
- package/dist/defaults/boxes/calloutStyles/strip.js +2 -0
- package/dist/defaults/boxes/calloutStyles/strip.js.map +1 -1
- package/dist/defaults/text/bodyText/resolve.d.ts.map +1 -1
- package/dist/defaults/text/bodyText/resolve.js +2 -0
- package/dist/defaults/text/bodyText/resolve.js.map +1 -1
- package/dist/defaults/text/bodyText/strip.d.ts.map +1 -1
- package/dist/defaults/text/bodyText/strip.js +5 -0
- package/dist/defaults/text/bodyText/strip.js.map +1 -1
- package/dist/fonts/glyphFallback.d.ts +2 -1
- package/dist/fonts/glyphFallback.d.ts.map +1 -1
- package/dist/fonts/glyphFallback.js +6 -1
- package/dist/fonts/glyphFallback.js.map +1 -1
- package/dist/fonts/strikeout.d.ts +30 -0
- package/dist/fonts/strikeout.d.ts.map +1 -0
- package/dist/fonts/strikeout.js +127 -0
- package/dist/fonts/strikeout.js.map +1 -0
- package/dist/html-backend/htmlAnnotations.d.ts.map +1 -1
- package/dist/html-backend/htmlAnnotations.js +3 -1
- package/dist/html-backend/htmlAnnotations.js.map +1 -1
- package/dist/html-backend/lines.d.ts.map +1 -1
- package/dist/html-backend/lines.js +8 -0
- package/dist/html-backend/lines.js.map +1 -1
- package/dist/html-backend/linkPaint.d.ts +3 -0
- package/dist/html-backend/linkPaint.d.ts.map +1 -1
- package/dist/html-backend/linkPaint.js +5 -0
- package/dist/html-backend/linkPaint.js.map +1 -1
- package/dist/html-backend/resources.js +3 -3
- package/dist/html-backend/resources.js.map +1 -1
- package/dist/html-backend/segmentText.d.ts +5 -0
- package/dist/html-backend/segmentText.d.ts.map +1 -1
- package/dist/html-backend/segmentText.js +8 -0
- package/dist/html-backend/segmentText.js.map +1 -1
- package/dist/html-backend/segments.js +3 -3
- package/dist/html-backend/segments.js.map +1 -1
- package/dist/html-backend/vertical.d.ts.map +1 -1
- package/dist/html-backend/vertical.js +3 -1
- package/dist/html-backend/vertical.js.map +1 -1
- package/dist/hyphenation/locale.d.ts +5 -0
- package/dist/hyphenation/locale.d.ts.map +1 -1
- package/dist/hyphenation/locale.js +8 -0
- package/dist/hyphenation/locale.js.map +1 -1
- package/dist/idml/colours.d.ts +14 -0
- package/dist/idml/colours.d.ts.map +1 -0
- package/dist/idml/colours.js +53 -0
- package/dist/idml/colours.js.map +1 -0
- package/dist/idml/fields.d.ts +19 -0
- package/dist/idml/fields.d.ts.map +1 -0
- package/dist/idml/fields.js +76 -0
- package/dist/idml/fields.js.map +1 -0
- package/dist/idml/fonts.d.ts +12 -0
- package/dist/idml/fonts.d.ts.map +1 -0
- package/dist/idml/fonts.js +19 -0
- package/dist/idml/fonts.js.map +1 -0
- package/dist/idml/geometry.d.ts +25 -0
- package/dist/idml/geometry.d.ts.map +1 -0
- package/dist/idml/geometry.js +37 -0
- package/dist/idml/geometry.js.map +1 -0
- package/dist/idml/idml.test.d.ts +2 -0
- package/dist/idml/idml.test.d.ts.map +1 -0
- package/dist/idml/idml.test.js +494 -0
- package/dist/idml/idml.test.js.map +1 -0
- package/dist/idml/images.d.ts +6 -0
- package/dist/idml/images.d.ts.map +1 -0
- package/dist/idml/images.js +75 -0
- package/dist/idml/images.js.map +1 -0
- package/dist/idml/index.d.ts +5 -0
- package/dist/idml/index.d.ts.map +1 -0
- package/dist/idml/index.js +100 -0
- package/dist/idml/index.js.map +1 -0
- package/dist/idml/paragraphs.d.ts +33 -0
- package/dist/idml/paragraphs.d.ts.map +1 -0
- package/dist/idml/paragraphs.js +203 -0
- package/dist/idml/paragraphs.js.map +1 -0
- package/dist/idml/parts.d.ts +89 -0
- package/dist/idml/parts.d.ts.map +1 -0
- package/dist/idml/parts.js +136 -0
- package/dist/idml/parts.js.map +1 -0
- package/dist/idml/shapes.d.ts +21 -0
- package/dist/idml/shapes.d.ts.map +1 -0
- package/dist/idml/shapes.js +146 -0
- package/dist/idml/shapes.js.map +1 -0
- package/dist/idml/spreads.d.ts +5 -0
- package/dist/idml/spreads.d.ts.map +1 -0
- package/dist/idml/spreads.js +154 -0
- package/dist/idml/spreads.js.map +1 -0
- package/dist/idml/story.d.ts +13 -0
- package/dist/idml/story.d.ts.map +1 -0
- package/dist/idml/story.js +238 -0
- package/dist/idml/story.js.map +1 -0
- package/dist/idml/writer.d.ts +86 -0
- package/dist/idml/writer.d.ts.map +1 -0
- package/dist/idml/writer.js +8 -0
- package/dist/idml/writer.js.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/marks/strikeGeometry.d.ts +14 -0
- package/dist/marks/strikeGeometry.d.ts.map +1 -0
- package/dist/marks/strikeGeometry.js +14 -0
- package/dist/marks/strikeGeometry.js.map +1 -0
- package/dist/marks/strikethrough.d.ts +57 -0
- package/dist/marks/strikethrough.d.ts.map +1 -0
- package/dist/marks/strikethrough.js +222 -0
- package/dist/marks/strikethrough.js.map +1 -0
- package/dist/measure/cache.d.ts.map +1 -1
- package/dist/measure/cache.js +8 -2
- package/dist/measure/cache.js.map +1 -1
- package/dist/measure/links.d.ts.map +1 -1
- package/dist/measure/links.js +71 -5
- package/dist/measure/links.js.map +1 -1
- package/dist/measure/rich/chips.d.ts.map +1 -1
- package/dist/measure/rich/chips.js +70 -0
- package/dist/measure/rich/chips.js.map +1 -1
- package/dist/paint/displayList/blocks.d.ts.map +1 -1
- package/dist/paint/displayList/blocks.js +2 -0
- package/dist/paint/displayList/blocks.js.map +1 -1
- package/dist/paint/displayList/displayList.test.js +22 -0
- package/dist/paint/displayList/displayList.test.js.map +1 -1
- package/dist/paint/displayList/inline.d.ts.map +1 -1
- package/dist/paint/displayList/inline.js +2 -1
- package/dist/paint/displayList/inline.js.map +1 -1
- package/dist/paint/displayList/lines.d.ts.map +1 -1
- package/dist/paint/displayList/lines.js +21 -0
- package/dist/paint/displayList/lines.js.map +1 -1
- package/dist/paint/displayList/page.d.ts.map +1 -1
- package/dist/paint/displayList/page.js +6 -2
- package/dist/paint/displayList/page.js.map +1 -1
- package/dist/paint/displayList/types.d.ts +24 -3
- package/dist/paint/displayList/types.d.ts.map +1 -1
- package/dist/parse/blockParser/headingLines.d.ts +3 -0
- package/dist/parse/blockParser/headingLines.d.ts.map +1 -1
- package/dist/parse/blockParser/headingLines.js +2 -2
- package/dist/parse/blockParser/headingLines.js.map +1 -1
- package/dist/parse/blockParser/verse.d.ts +3 -0
- package/dist/parse/blockParser/verse.d.ts.map +1 -1
- package/dist/parse/blockParser/verse.js +5 -5
- package/dist/parse/blockParser/verse.js.map +1 -1
- package/dist/parse/blockParser.d.ts.map +1 -1
- package/dist/parse/blockParser.js +6 -3
- package/dist/parse/blockParser.js.map +1 -1
- package/dist/parse/exerciseGaps.d.ts +4 -3
- package/dist/parse/exerciseGaps.d.ts.map +1 -1
- package/dist/parse/exerciseGaps.js +6 -6
- package/dist/parse/exerciseGaps.js.map +1 -1
- package/dist/parse/formFields.d.ts +118 -0
- package/dist/parse/formFields.d.ts.map +1 -0
- package/dist/parse/formFields.js +156 -0
- package/dist/parse/formFields.js.map +1 -0
- package/dist/parse/index.d.ts +4 -0
- package/dist/parse/index.d.ts.map +1 -1
- package/dist/parse/index.js +2 -0
- package/dist/parse/index.js.map +1 -1
- package/dist/parse/injectSpans.d.ts +2 -1
- package/dist/parse/injectSpans.d.ts.map +1 -1
- package/dist/parse/injectSpans.js +22 -2
- package/dist/parse/injectSpans.js.map +1 -1
- package/dist/parse/inlineFormatting/inlineDirectives.d.ts +5 -1
- package/dist/parse/inlineFormatting/inlineDirectives.d.ts.map +1 -1
- package/dist/parse/inlineFormatting/inlineDirectives.js +8 -3
- package/dist/parse/inlineFormatting/inlineDirectives.js.map +1 -1
- package/dist/parse/inlineFormatting/markup.d.ts +82 -1
- package/dist/parse/inlineFormatting/markup.d.ts.map +1 -1
- package/dist/parse/inlineFormatting/markup.js +140 -4
- package/dist/parse/inlineFormatting/markup.js.map +1 -1
- package/dist/parse/inlineFormatting/parse.d.ts +8 -4
- package/dist/parse/inlineFormatting/parse.d.ts.map +1 -1
- package/dist/parse/inlineFormatting/parse.js +75 -10
- package/dist/parse/inlineFormatting/parse.js.map +1 -1
- package/dist/parse/inlineFormatting.d.ts +2 -1
- package/dist/parse/inlineFormatting.d.ts.map +1 -1
- package/dist/parse/inlineFormatting.js +1 -1
- package/dist/parse/inlineFormatting.js.map +1 -1
- package/dist/parse/inlineSnippet.d.ts +7 -4
- package/dist/parse/inlineSnippet.d.ts.map +1 -1
- package/dist/parse/inlineSnippet.js +8 -5
- package/dist/parse/inlineSnippet.js.map +1 -1
- package/dist/parse/sourceMapping.d.ts.map +1 -1
- package/dist/parse/sourceMapping.js +14 -4
- package/dist/parse/sourceMapping.js.map +1 -1
- package/dist/parse/types/contentBlock.d.ts +3 -0
- package/dist/parse/types/contentBlock.d.ts.map +1 -1
- package/dist/parse/types/inlineSpan.d.ts +20 -1
- package/dist/parse/types/inlineSpan.d.ts.map +1 -1
- package/dist/pipeline/build/drivers.d.ts.map +1 -1
- package/dist/pipeline/build/drivers.js +3 -0
- package/dist/pipeline/build/drivers.js.map +1 -1
- package/dist/pipeline/callouts/calloutLayout/plan.d.ts.map +1 -1
- package/dist/pipeline/callouts/calloutLayout/plan.js +14 -1
- package/dist/pipeline/callouts/calloutLayout/plan.js.map +1 -1
- package/dist/pipeline/code/codeBlocks.d.ts +3 -2
- package/dist/pipeline/code/codeBlocks.d.ts.map +1 -1
- package/dist/pipeline/code/codeBlocks.js +7 -4
- package/dist/pipeline/code/codeBlocks.js.map +1 -1
- package/dist/pipeline/contentWarnings/sourceWarnings.d.ts.map +1 -1
- package/dist/pipeline/contentWarnings/sourceWarnings.js +3 -2
- package/dist/pipeline/contentWarnings/sourceWarnings.js.map +1 -1
- package/dist/pipeline/references/linkNotes.js +1 -1
- package/dist/pipeline/references/linkNotes.js.map +1 -1
- package/dist/pipeline/resources/resourceLayout/captions.js +1 -1
- package/dist/pipeline/resources/resourceLayout/captions.js.map +1 -1
- package/dist/pipeline/resources/resourceLayout/resourceBlock/captionNotes.js +1 -1
- package/dist/pipeline/resources/resourceLayout/resourceBlock/captionNotes.js.map +1 -1
- package/dist/pipeline/resources/resourceLayout/resourceBlock.js +1 -0
- package/dist/pipeline/resources/resourceLayout/resourceBlock.js.map +1 -1
- package/dist/pipeline/resources/resourceLayout/tableLayout.d.ts +2 -0
- package/dist/pipeline/resources/resourceLayout/tableLayout.d.ts.map +1 -1
- package/dist/pipeline/resources/resourceLayout/tableLayout.js +1 -1
- package/dist/pipeline/resources/resourceLayout/tableLayout.js.map +1 -1
- package/dist/pipeline/styles.d.ts.map +1 -1
- package/dist/pipeline/styles.js +20 -12
- package/dist/pipeline/styles.js.map +1 -1
- package/dist/pipeline/text/tabs.js +1 -1
- package/dist/pipeline/text/tabs.js.map +1 -1
- package/dist/types/boxes/calloutParts.d.ts +21 -0
- package/dist/types/boxes/calloutParts.d.ts.map +1 -1
- package/dist/types/boxes/callouts.d.ts +6 -0
- package/dist/types/boxes/callouts.d.ts.map +1 -1
- package/dist/types/text/bodyText/config.d.ts +9 -0
- package/dist/types/text/bodyText/config.d.ts.map +1 -1
- package/dist/types/text/bodyText/resolved.d.ts +9 -0
- package/dist/types/text/bodyText/resolved.d.ts.map +1 -1
- package/dist/vdt/lines.d.ts +4 -0
- package/dist/vdt/lines.d.ts.map +1 -1
- package/dist/vdt/segments.d.ts +34 -0
- package/dist/vdt/segments.d.ts.map +1 -1
- package/dist/vdt.d.ts +1 -1
- package/dist/vdt.d.ts.map +1 -1
- package/dist/word/formatted/runs.d.ts.map +1 -1
- package/dist/word/formatted/runs.js +6 -2
- package/dist/word/formatted/runs.js.map +1 -1
- package/dist/word/semantic/boxHangingIndent.test.d.ts +2 -0
- package/dist/word/semantic/boxHangingIndent.test.d.ts.map +1 -0
- package/dist/word/semantic/boxHangingIndent.test.js +38 -0
- package/dist/word/semantic/boxHangingIndent.test.js.map +1 -0
- package/dist/word/semantic/index.js +1 -1
- package/dist/word/semantic/index.js.map +1 -1
- package/dist/word/semantic/inline.d.ts.map +1 -1
- package/dist/word/semantic/inline.js +8 -3
- package/dist/word/semantic/inline.js.map +1 -1
- package/dist/word/semantic/prose/paragraphStyle.d.ts +8 -1
- package/dist/word/semantic/prose/paragraphStyle.d.ts.map +1 -1
- package/dist/word/semantic/prose/paragraphStyle.js +19 -0
- package/dist/word/semantic/prose/paragraphStyle.js.map +1 -1
- package/dist/word/semantic/snippet.js +1 -1
- package/dist/word/semantic/snippet.js.map +1 -1
- package/dist/word/semantic/strikethrough.test.d.ts +2 -0
- package/dist/word/semantic/strikethrough.test.d.ts.map +1 -0
- package/dist/word/semantic/strikethrough.test.js +17 -0
- package/dist/word/semantic/strikethrough.test.js.map +1 -0
- package/dist/word/semantic/styles.d.ts.map +1 -1
- package/dist/word/semantic/styles.js +2 -2
- package/dist/word/semantic/styles.js.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export declare const IDML_MIMETYPE = "application/vnd.adobe.indesign-idml-package";
|
|
2
|
+
export declare const DOM_VERSION = "8.0";
|
|
3
|
+
export declare const PKG_NS = "http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging";
|
|
4
|
+
export declare const XML_HEAD = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
|
|
5
|
+
export declare const CONTAINER_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<container version=\"1.0\" xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\"><rootfiles><rootfile full-path=\"designmap.xml\" media-type=\"text/xml\"/></rootfiles></container>";
|
|
6
|
+
/** A number as IDML writes it: up to four decimals, no trailing zeros. */
|
|
7
|
+
export declare function num(n: number): string;
|
|
8
|
+
export declare const attr: (name: string, value: string | number | boolean | undefined) => string;
|
|
9
|
+
export interface DesignMapInput {
|
|
10
|
+
title: string;
|
|
11
|
+
layerId: string;
|
|
12
|
+
masterId: string;
|
|
13
|
+
spreads: string[];
|
|
14
|
+
stories: string[];
|
|
15
|
+
}
|
|
16
|
+
export declare function designMapXml(d: DesignMapInput): string;
|
|
17
|
+
export interface DocumentGeometry {
|
|
18
|
+
/** Trim size, pt. */
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
/** Bleed on every side, pt. */
|
|
22
|
+
bleed: number;
|
|
23
|
+
pages: number;
|
|
24
|
+
}
|
|
25
|
+
export declare function preferencesXml(g: DocumentGeometry): string;
|
|
26
|
+
export declare function masterSpreadXml(id: string, g: DocumentGeometry): string;
|
|
27
|
+
export declare const BACKING_STORY_XML: string;
|
|
28
|
+
/** A swatch the document defines: InDesign's own (Black, Paper) or a
|
|
29
|
+
* process colour. */
|
|
30
|
+
export interface Swatch {
|
|
31
|
+
self: string;
|
|
32
|
+
name: string;
|
|
33
|
+
space: 'CMYK' | 'RGB';
|
|
34
|
+
value: number[];
|
|
35
|
+
}
|
|
36
|
+
export declare function graphicXml(swatches: Swatch[]): string;
|
|
37
|
+
export declare function fontsXml(families: Map<string, Set<string>>): string;
|
|
38
|
+
/** Text properties a paragraph style or a character range sets. */
|
|
39
|
+
export interface TextProps {
|
|
40
|
+
font: string;
|
|
41
|
+
fontStyle: string;
|
|
42
|
+
/** pt */
|
|
43
|
+
size: number;
|
|
44
|
+
color: string;
|
|
45
|
+
/** Thousandths of an em. */
|
|
46
|
+
tracking: number;
|
|
47
|
+
capitalization?: 'SmallCaps';
|
|
48
|
+
position?: 'Superscript' | 'Subscript';
|
|
49
|
+
/** pt, positive up. */
|
|
50
|
+
baselineShift?: number;
|
|
51
|
+
}
|
|
52
|
+
/** A tab stop: pt from the text frame's text edge (InDesign measures tab
|
|
53
|
+
* stops from there, whatever the paragraph's left indent). */
|
|
54
|
+
export interface TabStopDef {
|
|
55
|
+
position: number;
|
|
56
|
+
alignment: 'LeftAlign' | 'RightAlign' | 'CenterAlign' | 'CharacterAlign';
|
|
57
|
+
/** The character a `CharacterAlign` stop aligns on. Default `.`. */
|
|
58
|
+
character?: string;
|
|
59
|
+
leader?: string;
|
|
60
|
+
}
|
|
61
|
+
/** A paragraph's indents, space after and tab stops (pt). */
|
|
62
|
+
export interface ParagraphFormat {
|
|
63
|
+
leftIndent: number;
|
|
64
|
+
firstLineIndent: number;
|
|
65
|
+
rightIndent: number;
|
|
66
|
+
spaceAfter: number;
|
|
67
|
+
tabs: TabStopDef[];
|
|
68
|
+
}
|
|
69
|
+
export declare const NO_FORMAT: ParagraphFormat;
|
|
70
|
+
export interface ParagraphStyleDef {
|
|
71
|
+
self: string;
|
|
72
|
+
name: string;
|
|
73
|
+
props: TextProps;
|
|
74
|
+
/** pt */
|
|
75
|
+
leading: number;
|
|
76
|
+
justification: string;
|
|
77
|
+
format: ParagraphFormat;
|
|
78
|
+
}
|
|
79
|
+
/** `ParagraphStyle/<name>`: a colon in a name is written `%3a`, as InDesign does. */
|
|
80
|
+
export declare const styleSelf: (kind: "ParagraphStyle" | "CharacterStyle", name: string) => string;
|
|
81
|
+
export declare function textPropsAttrs(p: Partial<TextProps>): string;
|
|
82
|
+
/** A paragraph's tab stops as a `TabList` property (empty: none, which
|
|
83
|
+
* clears a style's stops on a paragraph). */
|
|
84
|
+
export declare function tabListXml(tabs: readonly TabStopDef[]): string;
|
|
85
|
+
/** The indents and space after a paragraph or style sets (`f`'s fields
|
|
86
|
+
* that are set; a style leaves zeros out). */
|
|
87
|
+
export declare function paragraphFormatAttrs(f: Partial<ParagraphFormat>): string;
|
|
88
|
+
export declare function stylesXml(paragraphStyles: ParagraphStyleDef[]): string;
|
|
89
|
+
//# sourceMappingURL=parts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../../src/idml/parts.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,aAAa,gDAAgD,CAAC;AAC3E,eAAO,MAAM,WAAW,QAAQ,CAAC;AACjC,eAAO,MAAM,MAAM,yDAAyD,CAAC;AAC7E,eAAO,MAAM,QAAQ,oEAA8D,CAAC;AAEpF,eAAO,MAAM,aAAa,2PAA+L,CAAC;AAE1N,0EAA0E;AAC1E,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAIrC;AAED,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,KAAG,MAC6B,CAAC;AAEhH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,w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,WAAW,GAAG,YAAY,GAAG,aAAa,GAAG,gBAAgB,CAAC;IACzE,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,6DAA6D;AAC7D,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,UAAU,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,SAAS,EAAE,eAAgG,CAAC;AAEzH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,eAAe,CAAC;CACzB;AAED,qFAAqF;AACrF,eAAO,MAAM,SAAS,GAAI,MAAM,gBAAgB,GAAG,gBAAgB,EAAE,MAAM,MAAM,KAAG,MAAqE,CAAC;AAE1J,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,MAAM,CAU5D;AAED;8CAC8C;AAC9C,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,GAAG,MAAM,CAO9D;AAED;+CAC+C;AAC/C,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,MAAM,CAExE;AAID,wBAAgB,SAAS,CAAC,eAAe,EAAE,iBAAiB,EAAE,GAAG,MAAM,CA4BtE"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// The fixed parts of an IDML package: the container, the
|
|
2
|
+
// document map, preferences, the default styles, swatches and fonts that
|
|
3
|
+
// InDesign expects in every file. Written for DOMVersion 8.0 (CS6), which
|
|
4
|
+
// every later InDesign opens.
|
|
5
|
+
import { escapeAttr } from '../word/xml.js';
|
|
6
|
+
export const IDML_MIMETYPE = 'application/vnd.adobe.indesign-idml-package';
|
|
7
|
+
export const DOM_VERSION = '8.0';
|
|
8
|
+
export const PKG_NS = 'http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging';
|
|
9
|
+
export const XML_HEAD = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n';
|
|
10
|
+
export const CONTAINER_XML = `${XML_HEAD}<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container"><rootfiles><rootfile full-path="designmap.xml" media-type="text/xml"/></rootfiles></container>`;
|
|
11
|
+
/** A number as IDML writes it: up to four decimals, no trailing zeros. */
|
|
12
|
+
export function num(n) {
|
|
13
|
+
if (!Number.isFinite(n))
|
|
14
|
+
return '0';
|
|
15
|
+
const r = Math.round(n * 10000) / 10000;
|
|
16
|
+
return Object.is(r, -0) ? '0' : String(r);
|
|
17
|
+
}
|
|
18
|
+
export const attr = (name, value) => value === undefined ? '' : ` ${name}="${escapeAttr(typeof value === 'number' ? num(value) : String(value))}"`;
|
|
19
|
+
export function designMapXml(d) {
|
|
20
|
+
return (`${XML_HEAD}<?aid style="50" type="document" readerVersion="6.0" featureSet="257" product="8.0(370)" ?>\n` +
|
|
21
|
+
`<Document xmlns:idPkg="${PKG_NS}" DOMVersion="${DOM_VERSION}" Self="d"${attr('StoryList', d.stories.join(' '))}${attr('Name', d.title)}` +
|
|
22
|
+
` ZeroPoint="0 0"${attr('ActiveLayer', d.layerId)} CMYKProfile="$ID/" RGBProfile="$ID/" SolidColorIntent="UseColorSettings" AfterBlendingIntent="UseColorSettings" DefaultImageIntent="UseColorSettings" RGBPolicy="PreserveEmbeddedProfiles" CMYKPolicy="CombinationOfPreserveAndSafeCmyk" AccurateLABSpots="false">` +
|
|
23
|
+
'<idPkg:Graphic src="Resources/Graphic.xml"/>' +
|
|
24
|
+
'<idPkg:Fonts src="Resources/Fonts.xml"/>' +
|
|
25
|
+
'<idPkg:Styles src="Resources/Styles.xml"/>' +
|
|
26
|
+
'<idPkg:Preferences src="Resources/Preferences.xml"/>' +
|
|
27
|
+
`<Layer${attr('Self', d.layerId)} Name="Postext" Visible="true" Locked="false" IgnoreWrap="false" ShowGuides="true" LockGuides="false" UI="true" Expendable="true" Printable="true"><Properties><LayerColor type="enumeration">LightBlue</LayerColor></Properties></Layer>` +
|
|
28
|
+
`<idPkg:MasterSpread src="MasterSpreads/MasterSpread_${d.masterId}.xml"/>` +
|
|
29
|
+
d.spreads.map((id) => `<idPkg:Spread src="Spreads/Spread_${id}.xml"/>`).join('') +
|
|
30
|
+
'<idPkg:BackingStory src="XML/BackingStory.xml"/>' +
|
|
31
|
+
d.stories.map((id) => `<idPkg:Story src="Stories/Story_${id}.xml"/>`).join('') +
|
|
32
|
+
'</Document>');
|
|
33
|
+
}
|
|
34
|
+
export function preferencesXml(g) {
|
|
35
|
+
const b = num(g.bleed);
|
|
36
|
+
return (`${XML_HEAD}<idPkg:Preferences xmlns:idPkg="${PKG_NS}" DOMVersion="${DOM_VERSION}">` +
|
|
37
|
+
`<DocumentPreference${attr('PageHeight', g.height)}${attr('PageWidth', g.width)} PagesPerDocument="1" FacingPages="false"` +
|
|
38
|
+
` DocumentBleedTopOffset="${b}" DocumentBleedBottomOffset="${b}" DocumentBleedInsideOrLeftOffset="${b}" DocumentBleedOutsideOrRightOffset="${b}" DocumentBleedUniformSize="true"` +
|
|
39
|
+
' PageBinding="LeftToRight" AllowPageShuffle="true" OverprintBlack="true" ColumnDirection="Horizontal" Intent="PrintIntent"/>' +
|
|
40
|
+
'<ViewPreference HorizontalMeasurementUnits="Millimeters" VerticalMeasurementUnits="Millimeters" TypographicMeasurementUnits="Points" TextSizeMeasurementUnits="Points" LineMeasurementUnits="Points"/>' +
|
|
41
|
+
'</idPkg:Preferences>');
|
|
42
|
+
}
|
|
43
|
+
export function masterSpreadXml(id, g) {
|
|
44
|
+
return (`${XML_HEAD}<idPkg:MasterSpread xmlns:idPkg="${PKG_NS}" DOMVersion="${DOM_VERSION}">` +
|
|
45
|
+
`<MasterSpread${attr('Self', id)} ItemTransform="1 0 0 1 0 0" Name="A-Master" NamePrefix="A" BaseName="Master" ShowMasterItems="true" PageCount="1" OverriddenPageItemProps="" PrimaryTextFrame="n">` +
|
|
46
|
+
`<Page${attr('Self', `${id}p`)} Name="A" AppliedMaster="n"${attr('GeometricBounds', `0 0 ${num(g.height)} ${num(g.width)}`)}${attr('ItemTransform', `1 0 0 1 0 ${num(-g.height / 2)}`)} MasterPageTransform="1 0 0 1 0 0">` +
|
|
47
|
+
`<MarginPreference ColumnCount="1" ColumnGutter="12" Top="0" Bottom="0" Left="0" Right="0" ColumnDirection="Horizontal"${attr('ColumnsPositions', `0 ${num(g.width)}`)}/>` +
|
|
48
|
+
'</Page></MasterSpread></idPkg:MasterSpread>');
|
|
49
|
+
}
|
|
50
|
+
export const BACKING_STORY_XML = `${XML_HEAD}<idPkg:BackingStory xmlns:idPkg="${PKG_NS}" DOMVersion="${DOM_VERSION}">` +
|
|
51
|
+
'<XmlStory Self="ubacking" AppliedTOCStyle="n" TrackChanges="false" StoryTitle="$ID/" AppliedNamedGrid="n">' +
|
|
52
|
+
'<StoryPreference OpticalMarginAlignment="false" OpticalMarginSize="12" FrameType="TextFrameType" StoryOrientation="Horizontal" StoryDirection="LeftToRightDirection"/>' +
|
|
53
|
+
'<InCopyExportOption IncludeGraphicProxies="true" IncludeAllResources="false"/>' +
|
|
54
|
+
'<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/$ID/NormalParagraphStyle"><CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]"/></ParagraphStyleRange>' +
|
|
55
|
+
'</XmlStory></idPkg:BackingStory>';
|
|
56
|
+
export function graphicXml(swatches) {
|
|
57
|
+
const own = swatches
|
|
58
|
+
.map((s) => `<Color${attr('Self', s.self)} Model="Process"${attr('Space', s.space)}${attr('ColorValue', s.value.map(num).join(' '))} ColorOverride="Normal" AlternateSpace="NoAlternateColor" AlternateColorValue=""${attr('Name', s.name)} ColorEditable="true" ColorRemovable="true" Visible="true" SwatchCreatorID="7937"/>`)
|
|
59
|
+
.join('');
|
|
60
|
+
return (`${XML_HEAD}<idPkg:Graphic xmlns:idPkg="${PKG_NS}" DOMVersion="${DOM_VERSION}">` +
|
|
61
|
+
'<Color Self="Color/Black" Model="Process" Space="CMYK" ColorValue="0 0 0 100" ColorOverride="Specialblack" AlternateSpace="NoAlternateColor" AlternateColorValue="" Name="Black" ColorEditable="false" ColorRemovable="false" Visible="true" SwatchCreatorID="7937"/>' +
|
|
62
|
+
'<Color Self="Color/Paper" Model="Process" Space="CMYK" ColorValue="0 0 0 0" ColorOverride="Specialpaper" AlternateSpace="NoAlternateColor" AlternateColorValue="" Name="Paper" ColorEditable="true" ColorRemovable="false" Visible="true" SwatchCreatorID="7937"/>' +
|
|
63
|
+
'<Color Self="Color/Registration" Model="Registration" Space="CMYK" ColorValue="100 100 100 100" ColorOverride="Specialregistration" AlternateSpace="NoAlternateColor" AlternateColorValue="" Name="Registration" ColorEditable="false" ColorRemovable="false" Visible="true" SwatchCreatorID="7937"/>' +
|
|
64
|
+
own +
|
|
65
|
+
'<Ink Self="Ink/$ID/Process Cyan" Name="$ID/Process Cyan" Angle="75" ConvertToProcess="false" Frequency="70" NeutralDensity="0.61" PrintInk="true" TrapOrder="1" InkType="Normal"/>' +
|
|
66
|
+
'<Ink Self="Ink/$ID/Process Magenta" Name="$ID/Process Magenta" Angle="15" ConvertToProcess="false" Frequency="70" NeutralDensity="0.76" PrintInk="true" TrapOrder="2" InkType="Normal"/>' +
|
|
67
|
+
'<Ink Self="Ink/$ID/Process Yellow" Name="$ID/Process Yellow" Angle="0" ConvertToProcess="false" Frequency="70" NeutralDensity="0.16" PrintInk="true" TrapOrder="3" InkType="Normal"/>' +
|
|
68
|
+
'<Ink Self="Ink/$ID/Process Black" Name="$ID/Process Black" Angle="45" ConvertToProcess="false" Frequency="70" NeutralDensity="1.7" PrintInk="true" TrapOrder="4" InkType="Normal"/>' +
|
|
69
|
+
'<Swatch Self="Swatch/None" Name="None" ColorEditable="false" ColorRemovable="false" Visible="true" SwatchCreatorID="7937"/>' +
|
|
70
|
+
'<StrokeStyle Self="StrokeStyle/$ID/Solid" Name="$ID/Solid"/>' +
|
|
71
|
+
'<StrokeStyle Self="StrokeStyle/$ID/Dashed" Name="$ID/Dashed"/>' +
|
|
72
|
+
'</idPkg:Graphic>');
|
|
73
|
+
}
|
|
74
|
+
export function fontsXml(families) {
|
|
75
|
+
let i = 0;
|
|
76
|
+
const body = [...families]
|
|
77
|
+
.map(([family, styles]) => {
|
|
78
|
+
const id = `di${(++i).toString(16)}`;
|
|
79
|
+
const faces = [...styles]
|
|
80
|
+
.map((style) => `<Font${attr('Self', `${id}Fontn${family} ${style}`)}${attr('FontFamily', family)}${attr('Name', `${family} ${style}`)} PostScriptName="$ID/" Status="NotAvailable"${attr('FontStyleName', style)} FontType="OpenTypeTT" WritingScript="0" FullName="" FullNameNative="" FontStyleNameNative="" PlatformName="$ID/" Version=""/>`)
|
|
81
|
+
.join('');
|
|
82
|
+
return `<FontFamily${attr('Self', id)}${attr('Name', family)}>${faces}</FontFamily>`;
|
|
83
|
+
})
|
|
84
|
+
.join('');
|
|
85
|
+
return `${XML_HEAD}<idPkg:Fonts xmlns:idPkg="${PKG_NS}" DOMVersion="${DOM_VERSION}">${body}</idPkg:Fonts>`;
|
|
86
|
+
}
|
|
87
|
+
export const NO_FORMAT = { leftIndent: 0, firstLineIndent: 0, rightIndent: 0, spaceAfter: 0, tabs: [] };
|
|
88
|
+
/** `ParagraphStyle/<name>`: a colon in a name is written `%3a`, as InDesign does. */
|
|
89
|
+
export const styleSelf = (kind, name) => `${kind}/${name.replace(/%/g, '%25').replace(/:/g, '%3a')}`;
|
|
90
|
+
export function textPropsAttrs(p) {
|
|
91
|
+
return (attr('FontStyle', p.fontStyle) +
|
|
92
|
+
attr('PointSize', p.size) +
|
|
93
|
+
attr('FillColor', p.color) +
|
|
94
|
+
attr('Tracking', p.tracking) +
|
|
95
|
+
attr('Capitalization', p.capitalization) +
|
|
96
|
+
attr('Position', p.position) +
|
|
97
|
+
attr('BaselineShift', p.baselineShift));
|
|
98
|
+
}
|
|
99
|
+
/** A paragraph's tab stops as a `TabList` property (empty: none, which
|
|
100
|
+
* clears a style's stops on a paragraph). */
|
|
101
|
+
export function tabListXml(tabs) {
|
|
102
|
+
const items = tabs.map((t) => `<ListItem type="record"><Alignment type="enumeration">${t.alignment}</Alignment><AlignmentCharacter type="string">${escapeAttr(t.character ?? '.')}</AlignmentCharacter>` +
|
|
103
|
+
`<Leader type="string">${escapeAttr(t.leader ?? '')}</Leader><Position type="unit">${num(t.position)}</Position></ListItem>`);
|
|
104
|
+
return `<TabList type="list">${items.join('')}</TabList>`;
|
|
105
|
+
}
|
|
106
|
+
/** The indents and space after a paragraph or style sets (`f`'s fields
|
|
107
|
+
* that are set; a style leaves zeros out). */
|
|
108
|
+
export function paragraphFormatAttrs(f) {
|
|
109
|
+
return attr('LeftIndent', f.leftIndent) + attr('FirstLineIndent', f.firstLineIndent) + attr('RightIndent', f.rightIndent) + attr('SpaceAfter', f.spaceAfter);
|
|
110
|
+
}
|
|
111
|
+
const nonZero = (n) => (Math.abs(n) >= 0.005 ? n : undefined);
|
|
112
|
+
export function stylesXml(paragraphStyles) {
|
|
113
|
+
const own = paragraphStyles
|
|
114
|
+
.map((s) => `<ParagraphStyle${attr('Self', s.self)}${attr('Name', s.name)} Imported="false" NextStyle="${escapeAttr(s.self)}" Hyphenation="false"${textPropsAttrs(s.props)}${attr('Justification', s.justification)}` +
|
|
115
|
+
`${paragraphFormatAttrs({ leftIndent: nonZero(s.format.leftIndent), firstLineIndent: nonZero(s.format.firstLineIndent), rightIndent: nonZero(s.format.rightIndent), spaceAfter: nonZero(s.format.spaceAfter) })}>` +
|
|
116
|
+
`<Properties><BasedOn type="object">ParagraphStyle/$ID/NormalParagraphStyle</BasedOn><AppliedFont type="string">${escapeAttr(s.props.font)}</AppliedFont><Leading type="unit">${num(s.leading)}</Leading>` +
|
|
117
|
+
`${s.format.tabs.length ? tabListXml(s.format.tabs) : ''}</Properties></ParagraphStyle>`)
|
|
118
|
+
.join('');
|
|
119
|
+
return (`${XML_HEAD}<idPkg:Styles xmlns:idPkg="${PKG_NS}" DOMVersion="${DOM_VERSION}">` +
|
|
120
|
+
'<RootCharacterStyleGroup Self="ucharstyles"><CharacterStyle Self="CharacterStyle/$ID/[No character style]" Imported="false" Name="$ID/[No character style]"/></RootCharacterStyleGroup>' +
|
|
121
|
+
'<RootParagraphStyleGroup Self="uparastyles">' +
|
|
122
|
+
'<ParagraphStyle Self="ParagraphStyle/$ID/[No paragraph style]" Name="$ID/[No paragraph style]" Imported="false"/>' +
|
|
123
|
+
'<ParagraphStyle Self="ParagraphStyle/$ID/NormalParagraphStyle" Name="$ID/NormalParagraphStyle" Imported="false" NextStyle="ParagraphStyle/$ID/NormalParagraphStyle"><Properties><BasedOn type="string">$ID/[No paragraph style]</BasedOn></Properties></ParagraphStyle>' +
|
|
124
|
+
own +
|
|
125
|
+
'</RootParagraphStyleGroup>' +
|
|
126
|
+
'<RootCellStyleGroup Self="ucellstyles"><CellStyle Self="CellStyle/$ID/[None]" AppliedParagraphStyle="ParagraphStyle/$ID/[No paragraph style]" Name="$ID/[None]"/></RootCellStyleGroup>' +
|
|
127
|
+
'<RootTableStyleGroup Self="utablestyles"><TableStyle Self="TableStyle/$ID/[No table style]" Name="$ID/[No table style]"/><TableStyle Self="TableStyle/$ID/[Basic Table]" Name="$ID/[Basic Table]"/></RootTableStyleGroup>' +
|
|
128
|
+
'<RootObjectStyleGroup Self="uobjectstyles">' +
|
|
129
|
+
'<ObjectStyle Self="ObjectStyle/$ID/[None]" Name="$ID/[None]"/>' +
|
|
130
|
+
'<ObjectStyle Self="ObjectStyle/$ID/[Normal Graphics Frame]" Name="$ID/[Normal Graphics Frame]"/>' +
|
|
131
|
+
'<ObjectStyle Self="ObjectStyle/$ID/[Normal Text Frame]" Name="$ID/[Normal Text Frame]"/>' +
|
|
132
|
+
'<ObjectStyle Self="ObjectStyle/$ID/[Normal Grid]" Name="$ID/[Normal Grid]"/>' +
|
|
133
|
+
'</RootObjectStyleGroup>' +
|
|
134
|
+
'</idPkg:Styles>');
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=parts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parts.js","sourceRoot":"","sources":["../../src/idml/parts.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,yEAAyE;AACzE,0EAA0E;AAC1E,8BAA8B;AAE9B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,CAAC,MAAM,aAAa,GAAG,6CAA6C,CAAC;AAC3E,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC;AACjC,MAAM,CAAC,MAAM,MAAM,GAAG,sDAAsD,CAAC;AAC7E,MAAM,CAAC,MAAM,QAAQ,GAAG,2DAA2D,CAAC;AAEpF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,QAAQ,iLAAiL,CAAC;AAE1N,0EAA0E;AAC1E,MAAM,UAAU,GAAG,CAAC,CAAS;IAC3B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC;IACpC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;IACxC,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,KAA4C,EAAU,EAAE,CACzF,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAA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AAO,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG;QAClN,kHAAkH,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,sCAAsC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY;QAC1M,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,gCAAgC,CAC3F;SACA,IAAI,CAAC,EAAE,CAAC,CAAC;IACZ,OAAO,CACL,GAAG,QAAQ,8BAA8B,MAAM,iBAAiB,WAAW,IAAI;QAC/E,yLAAyL;QACzL,8CAA8C;QAC9C,mHAAmH;QACnH,yQAAyQ;QACzQ,GAAG;QACH,4BAA4B;QAC5B,wLAAwL;QACxL,2NAA2N;QAC3N,6CAA6C;QAC7C,gEAAgE;QAChE,kGAAkG;QAClG,0FAA0F;QAC1F,8EAA8E;QAC9E,yBAAyB;QACzB,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DisplayItem } from '../paint/displayList/types.js';
|
|
2
|
+
import { type TextItem, type Writer } from './writer.js';
|
|
3
|
+
type RectItem = Extract<DisplayItem, {
|
|
4
|
+
kind: 'rect';
|
|
5
|
+
}>;
|
|
6
|
+
export declare function rectXml(w: Writer, item: Pick<RectItem, 'rect' | 'fill' | 'stroke' | 'strokeWidthPx' | 'radius' | 'rotate' | 'frame'>, name?: string): string;
|
|
7
|
+
/** The boxes of a text item's chips (a label's fill, an outline) as
|
|
8
|
+
* rectangles on the page, behind the text, which carries the chips'
|
|
9
|
+
* words (`paragraphRuns`). An underline-only chip is left to the text. */
|
|
10
|
+
export declare function chipRects(w: Writer, item: TextItem): string[];
|
|
11
|
+
/** The form fields of a text item's chips, over the text (#1445). The
|
|
12
|
+
* field's value is the chip's words. */
|
|
13
|
+
export declare function chipFields(w: Writer, item: TextItem): string[];
|
|
14
|
+
export declare function ruleXml(w: Writer, item: Extract<DisplayItem, {
|
|
15
|
+
kind: 'rule';
|
|
16
|
+
}>): string;
|
|
17
|
+
export declare function pathXml(w: Writer, item: Extract<DisplayItem, {
|
|
18
|
+
kind: 'path';
|
|
19
|
+
}>): string;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=shapes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shapes.d.ts","sourceRoot":"","sources":["../../src/idml/shapes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAQjE,OAAO,EAAsB,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAE7E,KAAK,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEvD,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,eAAe,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAU5J;AAYD;;2EAE2E;AAC3E,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,EAAE,CAW7D;AAED;yCACyC;AACzC,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,EAAE,CA+B9D;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,MAAM,CAWvF;AAwCD,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,MAAM,CAcvF"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Shapes: boxes, rules and paths as native page items, and the boxes and
|
|
2
|
+
// form fields of a text item's chips.
|
|
3
|
+
import { CHIP_PLACEHOLDER } from '../parse/inlineFormatting/inlineDirectives.js';
|
|
4
|
+
import { swatch } from './colours.js';
|
|
5
|
+
import { fieldXml } from './fields.js';
|
|
6
|
+
import { parseCssFont } from './fonts.js';
|
|
7
|
+
import { boxGeometry, chipRect, opacityXml, pathGeometry, pp, toSpread } from './geometry.js';
|
|
8
|
+
import { attr, num } from './parts.js';
|
|
9
|
+
import { frameName, isField } from './writer.js';
|
|
10
|
+
export function rectXml(w, item, name) {
|
|
11
|
+
const fill = swatch(w, item.fill);
|
|
12
|
+
const stroke = item.strokeWidthPx ? swatch(w, item.stroke) : undefined;
|
|
13
|
+
if (!fill && !stroke)
|
|
14
|
+
return '';
|
|
15
|
+
const g = boxGeometry(w, item.rect, item.rotate);
|
|
16
|
+
return (`<Rectangle${attr('Self', w.next())} ContentType="Unassigned" ItemLayer="ulayer"${attr('ItemTransform', g.transform)} AppliedObjectStyle="ObjectStyle/$ID/[None]"` +
|
|
17
|
+
`${paintAttrs(w, fill, stroke, item.strokeWidthPx, item.radius)}${attr('Name', name ?? (item.frame ? `${frameName(item.frame)} (box)` : undefined))}>` +
|
|
18
|
+
`${g.geometry}${opacityXml(fill?.opacity ?? stroke?.opacity ?? 1)}</Rectangle>`);
|
|
19
|
+
}
|
|
20
|
+
/** Fill, stroke (inside the edge) and rounded corners of a box. */
|
|
21
|
+
function paintAttrs(w, fill, stroke, strokeWidthPx, radiusPx) {
|
|
22
|
+
const radius = radiusPx ? radiusPx * w.k : 0;
|
|
23
|
+
const corners = radius > 0 ? ['TopLeft', 'TopRight', 'BottomLeft', 'BottomRight'].map((c) => `${attr(`${c}CornerOption`, 'RoundedCorner')}${attr(`${c}CornerRadius`, radius)}`).join('') : '';
|
|
24
|
+
return (`${attr('FillColor', fill?.ref ?? 'Swatch/None')}${attr('StrokeColor', stroke?.ref ?? 'Swatch/None')}${attr('StrokeWeight', stroke ? strokeWidthPx * w.k : 0)}` +
|
|
25
|
+
`${stroke ? ' StrokeAlignment="InsideAlignment"' : ''}${corners}`);
|
|
26
|
+
}
|
|
27
|
+
/** The boxes of a text item's chips (a label's fill, an outline) as
|
|
28
|
+
* rectangles on the page, behind the text, which carries the chips'
|
|
29
|
+
* words (`paragraphRuns`). An underline-only chip is left to the text. */
|
|
30
|
+
export function chipRects(w, item) {
|
|
31
|
+
const out = [];
|
|
32
|
+
for (const line of item.lines) {
|
|
33
|
+
for (const run of line.runs) {
|
|
34
|
+
const b = run.inline?.kind === 'chip' ? run.inline.box : undefined;
|
|
35
|
+
const rect = chipRect(run, line);
|
|
36
|
+
if (!b || !rect || (!b.fill && !(b.stroke && b.strokeWidthPx)) || isField(w, run))
|
|
37
|
+
continue;
|
|
38
|
+
out.push(rectXml(w, { fill: b.fill, stroke: b.stroke, strokeWidthPx: b.strokeWidthPx, radius: b.radius, rect }));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
/** The form fields of a text item's chips, over the text (#1445). The
|
|
44
|
+
* field's value is the chip's words. */
|
|
45
|
+
export function chipFields(w, item) {
|
|
46
|
+
const out = [];
|
|
47
|
+
for (const line of item.lines) {
|
|
48
|
+
line.runs.forEach((run, i) => {
|
|
49
|
+
const field = run.inline?.kind === 'chip' ? run.inline.field : undefined;
|
|
50
|
+
const b = run.inline?.box;
|
|
51
|
+
const rect = chipRect(run, line);
|
|
52
|
+
if (!field || !b || !rect || !isField(w, run))
|
|
53
|
+
return;
|
|
54
|
+
if (item.rotate)
|
|
55
|
+
w.warn('field.rotated', `Form field "${field.name}" stands in turned text; it is written unturned`);
|
|
56
|
+
const end = rect.x + rect.width;
|
|
57
|
+
const value = [run, ...line.runs.slice(i + 1).filter((r) => !r.inline && r.x < end - 0.01)].map((r) => r.text).join('').replaceAll(CHIP_PLACEHOLDER, '').trim();
|
|
58
|
+
if (value && field.kind !== 'checkbox')
|
|
59
|
+
w.warn('field.value', 'InDesign form fields have no default value: a field\'s value is kept as its script label postext:value');
|
|
60
|
+
if (field.format || field.calc)
|
|
61
|
+
w.warn('field.script', 'InDesign form fields have no number format or calculation: they are kept as the script labels postext:format and postext:calc');
|
|
62
|
+
const c = toSpread(w, rect.x + rect.width / 2, rect.y + rect.height / 2);
|
|
63
|
+
const fill = swatch(w, b.fill);
|
|
64
|
+
const stroke = b.strokeWidthPx ? swatch(w, b.stroke) : undefined;
|
|
65
|
+
const sizePx = field.sizePx ?? (parseCssFont(run.fontString).sizePx || 12);
|
|
66
|
+
out.push(fieldXml(w.next, field, value, {
|
|
67
|
+
cx: c.x,
|
|
68
|
+
cy: c.y,
|
|
69
|
+
hw: (rect.width * w.k) / 2,
|
|
70
|
+
hh: (rect.height * w.k) / 2,
|
|
71
|
+
paint: paintAttrs(w, fill, stroke, b.strokeWidthPx, b.radius),
|
|
72
|
+
ink: swatch(w, run.color)?.ref ?? 'Color/Black',
|
|
73
|
+
sizePt: sizePx * w.k,
|
|
74
|
+
}));
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
export function ruleXml(w, item) {
|
|
80
|
+
const stroke = swatch(w, item.color);
|
|
81
|
+
if (!stroke || item.widthPx <= 0)
|
|
82
|
+
return '';
|
|
83
|
+
const a = toSpread(w, item.x1, item.y1);
|
|
84
|
+
const b = toSpread(w, item.x2, item.y2);
|
|
85
|
+
const dash = item.dash?.length ? ` StrokeType="StrokeStyle/$ID/Dashed"${attr('StrokeDashAndGap', item.dash.map((d) => num(d * w.k)).join(' '))}` : '';
|
|
86
|
+
return (`<GraphicLine${attr('Self', w.next())} ContentType="Unassigned" ItemLayer="ulayer" ItemTransform="1 0 0 1 0 0" AppliedObjectStyle="ObjectStyle/$ID/[None]"` +
|
|
87
|
+
` FillColor="Swatch/None"${attr('StrokeColor', stroke.ref)}${attr('StrokeWeight', item.widthPx * w.k)}${dash} LeftLineEnd="None" RightLineEnd="None">` +
|
|
88
|
+
`${pathGeometry([{ points: [pp(a), pp(b)], open: true }])}${opacityXml(stroke.opacity)}</GraphicLine>`);
|
|
89
|
+
}
|
|
90
|
+
/** Path commands (sheet px) as IDML path points: each point's left
|
|
91
|
+
* direction is the handle coming in, its right one the handle going out. */
|
|
92
|
+
function subpathPoints(w, cmds) {
|
|
93
|
+
const pts = [];
|
|
94
|
+
let open = true;
|
|
95
|
+
const at = (x, y) => toSpread(w, x, y);
|
|
96
|
+
for (const c of cmds) {
|
|
97
|
+
if (c.op === 'M' || c.op === 'L') {
|
|
98
|
+
const a = at(c.x, c.y);
|
|
99
|
+
pts.push({ a, l: a, r: a });
|
|
100
|
+
}
|
|
101
|
+
else if (c.op === 'C') {
|
|
102
|
+
const last = pts[pts.length - 1];
|
|
103
|
+
if (last)
|
|
104
|
+
last.r = at(c.x1, c.y1);
|
|
105
|
+
const a = at(c.x, c.y);
|
|
106
|
+
pts.push({ a, l: at(c.x2, c.y2), r: a });
|
|
107
|
+
}
|
|
108
|
+
else if (c.op === 'Q') {
|
|
109
|
+
const last = pts[pts.length - 1];
|
|
110
|
+
const p0 = last?.a ?? at(c.x1, c.y1);
|
|
111
|
+
const q = at(c.x1, c.y1);
|
|
112
|
+
const a = at(c.x, c.y);
|
|
113
|
+
if (last)
|
|
114
|
+
last.r = { x: p0.x + (2 / 3) * (q.x - p0.x), y: p0.y + (2 / 3) * (q.y - p0.y) };
|
|
115
|
+
pts.push({ a, l: { x: a.x + (2 / 3) * (q.x - a.x), y: a.y + (2 / 3) * (q.y - a.y) }, r: a });
|
|
116
|
+
}
|
|
117
|
+
else if (c.op === 'Z') {
|
|
118
|
+
open = false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (!open && pts.length > 1) {
|
|
122
|
+
const first = pts[0];
|
|
123
|
+
const last = pts[pts.length - 1];
|
|
124
|
+
if (Math.abs(first.a.x - last.a.x) < 1e-3 && Math.abs(first.a.y - last.a.y) < 1e-3) {
|
|
125
|
+
first.l = last.l;
|
|
126
|
+
pts.pop();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return { points: pts.map((p) => pp(p.a, p.l, p.r)), open };
|
|
130
|
+
}
|
|
131
|
+
export function pathXml(w, item) {
|
|
132
|
+
const fill = swatch(w, item.fill);
|
|
133
|
+
const stroke = item.stroke && item.stroke.widthPx > 0 ? swatch(w, item.stroke.color) : undefined;
|
|
134
|
+
if (!fill && !stroke)
|
|
135
|
+
return '';
|
|
136
|
+
const paths = item.subpaths.filter((s) => s.length > 1).map((s) => subpathPoints(w, s));
|
|
137
|
+
if (!paths.length)
|
|
138
|
+
return '';
|
|
139
|
+
const dash = item.stroke?.dash?.length ? ` StrokeType="StrokeStyle/$ID/Dashed"${attr('StrokeDashAndGap', item.stroke.dash.map((d) => num(d * w.k)).join(' '))}` : '';
|
|
140
|
+
const cap = item.stroke?.cap === 'round' ? ' EndCap="RoundEndCap"' : item.stroke?.cap === 'square' ? ' EndCap="ProjectingEndCap"' : '';
|
|
141
|
+
const join = item.stroke?.join === 'round' ? ' EndJoin="RoundEndJoin"' : item.stroke?.join === 'bevel' ? ' EndJoin="BevelEndJoin"' : '';
|
|
142
|
+
return (`<Polygon${attr('Self', w.next())} ContentType="Unassigned" ItemLayer="ulayer" ItemTransform="1 0 0 1 0 0" AppliedObjectStyle="ObjectStyle/$ID/[None]"` +
|
|
143
|
+
`${attr('FillColor', fill?.ref ?? 'Swatch/None')}${attr('StrokeColor', stroke?.ref ?? 'Swatch/None')}${attr('StrokeWeight', stroke ? item.stroke.widthPx * w.k : 0)}${dash}${cap}${join}>` +
|
|
144
|
+
`${pathGeometry(paths)}${opacityXml(fill?.opacity ?? stroke?.opacity ?? 1)}</Polygon>`);
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=shapes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shapes.js","sourceRoot":"","sources":["../../src/idml/shapes.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,sCAAsC;AAItC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAW,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,OAAO,EAA8B,MAAM,aAAa,CAAC;AAI7E,MAAM,UAAU,OAAO,CAAC,CAAS,EAAE,IAAkG,EAAE,IAAa;IAClJ,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACvE,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAChC,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO,CACL,aAAa,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,+CAA+C,IAA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,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG;QAC3L,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,IAAI,EAAE,OAAO,IAAI,MAAM,EAAE,OAAO,IAAI,CAAC,CAAC,YAAY,CACvF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DisplayPage } from '../paint/displayList/types.js';
|
|
2
|
+
import type { VDTFrame } from '../vdt/pages/composed.js';
|
|
3
|
+
import { type Writer } from './writer.js';
|
|
4
|
+
export declare function spreadXml(w: Writer, id: string, page: DisplayPage, frames: Map<string, VDTFrame>, index: number, gap: number): string;
|
|
5
|
+
//# sourceMappingURL=spreads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spreads.d.ts","sourceRoot":"","sources":["../../src/idml/spreads.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAOzD,OAAO,EAA4C,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AA4DpF,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAwFrI"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// Spreads: one page per spread, its items in the display list's order, the
|
|
2
|
+
// text of each composed frame (or chain of frames) in one text frame per
|
|
3
|
+
// frame and one story per chain.
|
|
4
|
+
import { boxGeometry, union } from './geometry.js';
|
|
5
|
+
import { imageXml } from './images.js';
|
|
6
|
+
import { asPainted, textScale } from './paragraphs.js';
|
|
7
|
+
import { attr, DOM_VERSION, num, PKG_NS, XML_HEAD } from './parts.js';
|
|
8
|
+
import { chipFields, chipRects, pathXml, rectXml, ruleXml } from './shapes.js';
|
|
9
|
+
import { storyXml } from './story.js';
|
|
10
|
+
import { frameName } from './writer.js';
|
|
11
|
+
/** One text frame: a composed frame's text, or a single text item outside
|
|
12
|
+
* frames, with its own story or its chain's. The box is the frame's (or
|
|
13
|
+
* the item's), the left and right insets put the text where Postext set
|
|
14
|
+
* it, and a fixed first-baseline offset puts the first baseline exactly. */
|
|
15
|
+
function textFrameXml(w, items, frame, link) {
|
|
16
|
+
const withLines = items.filter((i) => i.lines.length);
|
|
17
|
+
if (!withLines.length && !(link && frame))
|
|
18
|
+
return '';
|
|
19
|
+
// A frame of a chain that holds no text of its own on this page.
|
|
20
|
+
const measured = withLines.length ? withLines : [{ bbox: { ...frame.rect }, lines: [{ baseline: frame.rect.y, lineHeight: 0 }], rotate: 0 }];
|
|
21
|
+
const text = union(measured.map((i) => i.bbox));
|
|
22
|
+
const box = frame ? { ...frame.rect } : { ...text };
|
|
23
|
+
const rotate = frame?.rotate ?? measured[0].rotate ?? 0;
|
|
24
|
+
// Room below for InDesign's own composer.
|
|
25
|
+
if (!frame)
|
|
26
|
+
box.height += (measured[0].lines[0]?.lineHeight ?? 0) * 0.5;
|
|
27
|
+
const g = boxGeometry(w, box, rotate);
|
|
28
|
+
const left = Math.max(0, (text.x - box.x) * w.k);
|
|
29
|
+
const right = Math.max(0, (box.x + box.width - (text.x + text.width)) * w.k);
|
|
30
|
+
const firstBaseline = measured[0].lines[0].baseline;
|
|
31
|
+
const top = Math.max(0, (text.y - box.y) * w.k);
|
|
32
|
+
const baselineOffset = Math.max(0, (firstBaseline - text.y) * w.k);
|
|
33
|
+
const storyId = link?.story ?? w.next();
|
|
34
|
+
if (!link || link.write)
|
|
35
|
+
w.stories.push({ id: storyId, xml: storyXml(w, storyId, link?.storyItems ?? withLines, frame) });
|
|
36
|
+
return (`<TextFrame${attr('Self', link?.self ?? w.next())}${attr('ParentStory', storyId)}${attr('PreviousTextFrame', link?.prev ?? 'n')}${attr('NextTextFrame', link?.next ?? 'n')} ContentType="TextType" ItemLayer="ulayer"` +
|
|
37
|
+
`${attr('ItemTransform', g.transform)} AppliedObjectStyle="ObjectStyle/$ID/[None]" FillColor="Swatch/None" StrokeColor="Swatch/None" StrokeWeight="0"${attr('Name', frame ? frameName(frame.name) : undefined)}>` +
|
|
38
|
+
g.geometry +
|
|
39
|
+
`<TextFramePreference TextColumnCount="1" FirstBaselineOffset="FixedHeight"${attr('MinimumFirstBaselineOffset', baselineOffset)} VerticalJustification="TopAlign"${attr('InsetSpacing', `${num(top)} ${num(left)} 0 ${num(right)}`)} AutoSizingType="Off" IgnoreWrap="false"/>` +
|
|
40
|
+
'</TextFrame>');
|
|
41
|
+
}
|
|
42
|
+
/** The frames of the chain `f` belongs to on this page, in order. */
|
|
43
|
+
function chainOf(f, frames) {
|
|
44
|
+
let head = f;
|
|
45
|
+
const seen = new Set([head.id]);
|
|
46
|
+
while (head.continuedFrom && frames.has(head.continuedFrom) && !seen.has(head.continuedFrom)) {
|
|
47
|
+
head = frames.get(head.continuedFrom);
|
|
48
|
+
seen.add(head.id);
|
|
49
|
+
}
|
|
50
|
+
const chain = [head];
|
|
51
|
+
for (let c = head; c.continuesTo && frames.has(c.continuesTo) && !chain.some((x) => x.id === c.continuesTo);) {
|
|
52
|
+
c = frames.get(c.continuesTo);
|
|
53
|
+
chain.push(c);
|
|
54
|
+
}
|
|
55
|
+
return chain;
|
|
56
|
+
}
|
|
57
|
+
export function spreadXml(w, id, page, frames, index, gap) {
|
|
58
|
+
const out = [];
|
|
59
|
+
// Stories are written horizontal and left to right (`storyXml`), once
|
|
60
|
+
// said for the whole package.
|
|
61
|
+
const lines = page.items.flatMap((it) => (it.kind === 'text' ? it.lines : []));
|
|
62
|
+
if (page.rtl || lines.some((l) => l.rtl))
|
|
63
|
+
w.warn('text.rtl', 'Right-to-left text is written left to right, in horizontal stories: set the stories\' direction in InDesign');
|
|
64
|
+
if (page.vertical || lines.some((l) => l.vertical))
|
|
65
|
+
w.warn('text.vertical', 'Vertical text is written horizontal, left to right: set the stories\' orientation in InDesign');
|
|
66
|
+
// The text of one frame (of one chain of frames) goes into one story,
|
|
67
|
+
// written where its first item paints; the rest of the items keep the
|
|
68
|
+
// display list's order.
|
|
69
|
+
const byFrame = new Map();
|
|
70
|
+
// A frame's items as painted, at its text scale.
|
|
71
|
+
for (const it of page.items)
|
|
72
|
+
if (it.kind === 'text' && it.frame && frames.has(it.frame))
|
|
73
|
+
byFrame.set(it.frame, [...(byFrame.get(it.frame) ?? []), asPainted(it, textScale(frames.get(it.frame)))]);
|
|
74
|
+
const done = new Set();
|
|
75
|
+
// Outside frames a list item's marker shares its item's text frame.
|
|
76
|
+
const markerFor = new Map();
|
|
77
|
+
const held = new Set();
|
|
78
|
+
page.items.forEach((it, i) => {
|
|
79
|
+
if (it.kind !== 'text' || it.role !== 'marker' || (it.frame && byFrame.has(it.frame)))
|
|
80
|
+
return;
|
|
81
|
+
const item = page.items.slice(i + 1).find((x) => x.kind === 'text');
|
|
82
|
+
if (item && item.role !== 'marker' && !(item.frame && byFrame.has(item.frame)) && item.source?.blockKey === it.source?.blockKey) {
|
|
83
|
+
markerFor.set(item, it);
|
|
84
|
+
held.add(it);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
for (const it of page.items) {
|
|
88
|
+
switch (it.kind) {
|
|
89
|
+
case 'rect':
|
|
90
|
+
out.push(rectXml(w, it));
|
|
91
|
+
break;
|
|
92
|
+
case 'rule':
|
|
93
|
+
out.push(ruleXml(w, it));
|
|
94
|
+
break;
|
|
95
|
+
case 'path':
|
|
96
|
+
out.push(pathXml(w, it));
|
|
97
|
+
break;
|
|
98
|
+
case 'image':
|
|
99
|
+
out.push(imageXml(w, it, page.index));
|
|
100
|
+
break;
|
|
101
|
+
case 'text': {
|
|
102
|
+
if (!it.frame || !byFrame.has(it.frame)) {
|
|
103
|
+
if (held.has(it))
|
|
104
|
+
break;
|
|
105
|
+
const marker = markerFor.get(it);
|
|
106
|
+
out.push(...chipRects(w, it), textFrameXml(w, marker ? [marker, it] : [it], undefined), ...chipFields(w, it));
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
if (done.has(it.frame))
|
|
110
|
+
break;
|
|
111
|
+
const chain = chainOf(frames.get(it.frame), frames);
|
|
112
|
+
const own = chain.map((c) => byFrame.get(c.id) ?? []);
|
|
113
|
+
for (const c of chain)
|
|
114
|
+
done.add(c.id);
|
|
115
|
+
// Chip boxes go behind all the chain's text.
|
|
116
|
+
for (const items of own)
|
|
117
|
+
for (const t of items)
|
|
118
|
+
out.push(...chipRects(w, t));
|
|
119
|
+
// Form fields go over it.
|
|
120
|
+
const fields = () => own.flatMap((items) => items.flatMap((t) => chipFields(w, t)));
|
|
121
|
+
if (chain.length < 2) {
|
|
122
|
+
out.push(textFrameXml(w, own[0], chain[0]), ...fields());
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
const story = w.next();
|
|
126
|
+
const selfs = chain.map(() => w.next());
|
|
127
|
+
const storyItems = [];
|
|
128
|
+
for (const items of own) {
|
|
129
|
+
items.forEach((x, k) => {
|
|
130
|
+
const before = storyItems[storyItems.length - 1];
|
|
131
|
+
storyItems.push(k === 0 && before?.source?.blockKey && before.source.blockKey === x.source?.blockKey ? { ...x, joinsPrevious: true } : x);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
chain.forEach((c, k) => {
|
|
135
|
+
out.push(textFrameXml(w, own[k], c, { story, self: selfs[k], prev: selfs[k - 1], next: selfs[k + 1], write: k === 0, storyItems }));
|
|
136
|
+
});
|
|
137
|
+
out.push(...fields());
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case 'table':
|
|
141
|
+
w.warn('table', `Page ${page.index + 1}: tables are not written yet`);
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const pageW = (page.trim?.width ?? page.width) * w.k;
|
|
146
|
+
return (`${XML_HEAD}<idPkg:Spread xmlns:idPkg="${PKG_NS}" DOMVersion="${DOM_VERSION}">` +
|
|
147
|
+
`<Spread${attr('Self', id)} PageTransitionType="None" ShowMasterItems="true" PageCount="1" BindingLocation="0" AllowPageShuffle="true"${attr('ItemTransform', `1 0 0 1 0 ${num(index * (w.pageH + gap))}`)} FlattenerOverride="Default">` +
|
|
148
|
+
`<Page${attr('Self', `${id}p`)}${attr('Name', page.label ?? String(index + 1))} AppliedMaster="n"${attr('GeometricBounds', `0 0 ${num(w.pageH)} ${num(pageW)}`)}${attr('ItemTransform', `1 0 0 1 0 ${num(-w.pageH / 2)}`)} OverrideList="" TabOrder="" GridStartingPoint="TopOutside" UseMasterGrid="true">` +
|
|
149
|
+
`<MarginPreference ColumnCount="1" ColumnGutter="12" Top="0" Bottom="0" Left="0" Right="0" ColumnDirection="Horizontal"${attr('ColumnsPositions', `0 ${num(pageW)}`)}/>` +
|
|
150
|
+
'</Page>' +
|
|
151
|
+
out.join('') +
|
|
152
|
+
'</Spread></idPkg:Spread>');
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=spreads.js.map
|