abstract-document 20.0.1 → 20.0.3
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/CHANGELOG.md +4 -0
- package/lib/abstract-document/abstract-doc.d.ts +2 -2
- package/lib/abstract-document/abstract-doc.d.ts.map +1 -1
- package/lib/abstract-document/atoms/atom.d.ts +7 -7
- package/lib/abstract-document/atoms/atom.d.ts.map +1 -1
- package/lib/abstract-document/atoms/image.d.ts +1 -1
- package/lib/abstract-document/atoms/image.d.ts.map +1 -1
- package/lib/abstract-document/default-styles.d.ts +2 -2
- package/lib/abstract-document/default-styles.d.ts.map +1 -1
- package/lib/abstract-document/markdown/markdown.d.ts +1 -1
- package/lib/abstract-document/markdown/markdown.d.ts.map +1 -1
- package/lib/abstract-document/markdown/markdown.js +5 -2
- package/lib/abstract-document/markdown/markdown.js.map +1 -1
- package/lib/abstract-document/markdown/types.d.ts +1 -1
- package/lib/abstract-document/markdown/types.d.ts.map +1 -1
- package/lib/abstract-document/numberings/numbering-definition.d.ts +1 -1
- package/lib/abstract-document/numberings/numbering-definition.d.ts.map +1 -1
- package/lib/abstract-document/numberings/numbering-level-definition.d.ts +1 -1
- package/lib/abstract-document/numberings/numbering-level-definition.d.ts.map +1 -1
- package/lib/abstract-document/page/master-page.d.ts +1 -1
- package/lib/abstract-document/page/master-page.d.ts.map +1 -1
- package/lib/abstract-document/page/section.d.ts +2 -2
- package/lib/abstract-document/page/section.d.ts.map +1 -1
- package/lib/abstract-document/primitives/image-resource.d.ts +1 -1
- package/lib/abstract-document/primitives/image-resource.d.ts.map +1 -1
- package/lib/abstract-document/resources.d.ts +5 -5
- package/lib/abstract-document/resources.d.ts.map +1 -1
- package/lib/abstract-document/resources.js.map +1 -1
- package/lib/abstract-document/section-elements/group.d.ts +2 -2
- package/lib/abstract-document/section-elements/group.d.ts.map +1 -1
- package/lib/abstract-document/section-elements/page-break.d.ts +1 -1
- package/lib/abstract-document/section-elements/page-break.d.ts.map +1 -1
- package/lib/abstract-document/section-elements/paragraph.d.ts +3 -3
- package/lib/abstract-document/section-elements/paragraph.d.ts.map +1 -1
- package/lib/abstract-document/section-elements/section-element.d.ts +1 -1
- package/lib/abstract-document/section-elements/section-element.d.ts.map +1 -1
- package/lib/abstract-document/section-elements/table.d.ts +2 -2
- package/lib/abstract-document/section-elements/table.d.ts.map +1 -1
- package/lib/abstract-document/styles/group-style.d.ts +1 -1
- package/lib/abstract-document/styles/group-style.d.ts.map +1 -1
- package/lib/abstract-document/styles/paragraph-style.d.ts +1 -1
- package/lib/abstract-document/styles/paragraph-style.d.ts.map +1 -1
- package/lib/abstract-document/styles/table-style.d.ts +1 -1
- package/lib/abstract-document/styles/table-style.d.ts.map +1 -1
- package/lib/abstract-document/table/table-cell.d.ts +1 -1
- package/lib/abstract-document/table/table-cell.d.ts.map +1 -1
- package/lib/abstract-document/table/table-row.d.ts +1 -1
- package/lib/abstract-document/table/table-row.d.ts.map +1 -1
- package/lib/abstract-document-exporters/docx/ref-container.d.ts.map +1 -1
- package/lib/abstract-document-exporters/docx/xml-writer.d.ts.map +1 -1
- package/lib/abstract-document-exporters/docx/xml-writer.js.map +1 -1
- package/lib/abstract-document-exporters/docx2/render-image.d.ts +4 -4
- package/lib/abstract-document-exporters/docx2/render-image.d.ts.map +1 -1
- package/lib/abstract-document-exporters/docx2/render-image.js +7 -13
- package/lib/abstract-document-exporters/docx2/render-image.js.map +1 -1
- package/lib/abstract-document-exporters/docx2/render.d.ts.map +1 -1
- package/lib/abstract-document-exporters/docx2/render.js +28 -24
- package/lib/abstract-document-exporters/docx2/render.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/font.d.ts +2 -2
- package/lib/abstract-document-exporters/pdf/font.d.ts.map +1 -1
- package/lib/abstract-document-exporters/pdf/font.js +1 -1
- package/lib/abstract-document-exporters/pdf/font.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/measure.d.ts +1 -1
- package/lib/abstract-document-exporters/pdf/measure.d.ts.map +1 -1
- package/lib/abstract-document-exporters/pdf/measure.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/paginate.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/pre-process.d.ts.map +1 -1
- package/lib/abstract-document-exporters/pdf/pre-process.js +1 -1
- package/lib/abstract-document-exporters/pdf/pre-process.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/render-image.js +0 -2
- package/lib/abstract-document-exporters/pdf/render-image.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/render.d.ts.map +1 -1
- package/lib/abstract-document-exporters/pdf/render.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/update-refs.d.ts +1 -1
- package/lib/abstract-document-exporters/pdf/update-refs.d.ts.map +1 -1
- package/lib/abstract-document-exporters/shared/get_resources.d.ts +2 -2
- package/lib/abstract-document-exporters/shared/get_resources.d.ts.map +1 -1
- package/lib/abstract-document-exporters/shared/get_resources.js.map +1 -1
- package/lib/abstract-document-jsx/index.d.ts.map +1 -1
- package/lib/abstract-document-xml/abstract-doc-of-xml/abstract-doc-of-xml.d.ts +3 -3
- package/lib/abstract-document-xml/abstract-doc-of-xml/abstract-doc-of-xml.d.ts.map +1 -1
- package/lib/abstract-document-xml/abstract-doc-of-xml/abstract-doc-of-xml.js +32 -32
- package/lib/abstract-document-xml/abstract-doc-of-xml/abstract-doc-of-xml.js.map +1 -1
- package/lib/abstract-document-xml/abstract-doc-of-xml/creator.d.ts.map +1 -1
- package/lib/abstract-document-xml/abstract-doc-of-xml/creator.js +74 -74
- package/lib/abstract-document-xml/abstract-doc-of-xml/creator.js.map +1 -1
- package/lib/abstract-document-xml/abstract-doc-of-xml/custom-elements.d.ts +3 -2
- package/lib/abstract-document-xml/abstract-doc-of-xml/custom-elements.d.ts.map +1 -1
- package/lib/abstract-document-xml/abstract-doc-of-xml/custom-elements.js +1 -1
- package/lib/abstract-document-xml/abstract-doc-of-xml/custom-elements.js.map +1 -1
- package/lib/abstract-document-xml/xsd-template/custom-elements.d.ts.map +1 -1
- package/lib/abstract-document-xml/xsd-template/custom-elements.js +0 -1
- package/lib/abstract-document-xml/xsd-template/custom-elements.js.map +1 -1
- package/package.json +4 -4
- package/src/abstract-document/abstract-doc.ts +7 -7
- package/src/abstract-document/atoms/atom.ts +7 -7
- package/src/abstract-document/atoms/image.ts +1 -1
- package/src/abstract-document/default-styles.ts +2 -2
- package/src/abstract-document/markdown/markdown.ts +9 -6
- package/src/abstract-document/markdown/types.ts +1 -1
- package/src/abstract-document/numberings/numbering-definition.ts +1 -1
- package/src/abstract-document/numberings/numbering-level-definition.ts +1 -1
- package/src/abstract-document/page/master-page.ts +1 -1
- package/src/abstract-document/page/section.ts +2 -2
- package/src/abstract-document/primitives/image-resource.ts +1 -1
- package/src/abstract-document/resources.ts +9 -8
- package/src/abstract-document/section-elements/group.ts +2 -2
- package/src/abstract-document/section-elements/page-break.ts +1 -1
- package/src/abstract-document/section-elements/paragraph.ts +3 -3
- package/src/abstract-document/section-elements/section-element.ts +1 -1
- package/src/abstract-document/section-elements/table.ts +2 -2
- package/src/abstract-document/styles/group-style.ts +1 -1
- package/src/abstract-document/styles/paragraph-style.ts +1 -1
- package/src/abstract-document/styles/table-style.ts +1 -1
- package/src/abstract-document/table/table-cell.ts +1 -1
- package/src/abstract-document/table/table-row.ts +1 -1
- package/src/abstract-document-exporters/docx2/render-image.ts +63 -51
- package/src/abstract-document-exporters/docx2/render.ts +62 -57
- package/src/abstract-document-exporters/pdf/font.ts +5 -5
- package/src/abstract-document-exporters/pdf/measure.ts +2 -1
- package/src/abstract-document-exporters/pdf/pre-process.ts +1 -2
- package/src/abstract-document-exporters/pdf/render-image.ts +1 -3
- package/src/abstract-document-exporters/pdf/render.ts +4 -2
- package/src/abstract-document-exporters/pdf/update-refs.ts +2 -2
- package/src/abstract-document-exporters/shared/get_resources.ts +10 -9
- package/src/abstract-document-xml/abstract-doc-of-xml/abstract-doc-of-xml.ts +43 -42
- package/src/abstract-document-xml/abstract-doc-of-xml/creator.ts +111 -113
- package/src/abstract-document-xml/abstract-doc-of-xml/custom-elements.tsx +4 -13
- package/src/abstract-document-xml/xsd-template/custom-elements.ts +0 -1
- package/src/custom_typings/pdfkit-standard-fonts/index.d.ts +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { exhaustiveCheck } from "ts-exhaustive-check";
|
|
2
2
|
import * as AD from "../../abstract-document/index.js";
|
|
3
3
|
import * as TextStyle from "../../abstract-document/styles/text-style.js";
|
|
4
|
-
import { checkServerIdentity } from "node:tls";
|
|
5
4
|
|
|
6
5
|
const alphabet = [
|
|
7
6
|
"a",
|
|
@@ -201,7 +200,7 @@ function adjustParagraph(paragraph: AD.Paragraph.Paragraph): Array<AD.SectionEle
|
|
|
201
200
|
type: "LineBreak",
|
|
202
201
|
style: child.style,
|
|
203
202
|
nestedStyleNames: child.nestedStyleNames,
|
|
204
|
-
styleName: child.styleName
|
|
203
|
+
styleName: child.styleName,
|
|
205
204
|
};
|
|
206
205
|
newChildren.push(lineBreak);
|
|
207
206
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as AbstractImage from "abstract-image";
|
|
1
|
+
import type * as AbstractImage from "abstract-image";
|
|
2
2
|
import svgToPdfKit from "svg-to-pdfkit";
|
|
3
3
|
import * as AD from "../../abstract-document/index.js";
|
|
4
4
|
import { getFontNameStyle, getFontName, isFontAvailable } from "./font.js";
|
|
@@ -230,7 +230,6 @@ function addWithSvgToPdfKit(
|
|
|
230
230
|
let svgUpdated = svg;
|
|
231
231
|
["fill=", "stroke=", "color="].forEach((t) => {
|
|
232
232
|
let index = 0;
|
|
233
|
-
// eslint-disable-next-line no-constant-condition
|
|
234
233
|
while (true) {
|
|
235
234
|
index = svgUpdated.indexOf(t, index);
|
|
236
235
|
if (index === -1) break;
|
|
@@ -247,7 +246,6 @@ function addWithSvgToPdfKit(
|
|
|
247
246
|
|
|
248
247
|
["stroke-dasharray="].forEach((t) => {
|
|
249
248
|
let index = 0;
|
|
250
|
-
// eslint-disable-next-line no-constant-condition
|
|
251
249
|
while (true) {
|
|
252
250
|
index = svgUpdated.indexOf(t, index);
|
|
253
251
|
if (index === -1) break;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import * as AD from "../../abstract-document/index.js";
|
|
2
2
|
import { preProcess } from "./pre-process.js";
|
|
3
3
|
import { measure, measurePages } from "./measure.js";
|
|
4
|
-
import {
|
|
4
|
+
import type { Page } from "./paginate.js";
|
|
5
|
+
import { paginate, getHeaderAndFooter } from "./paginate.js";
|
|
5
6
|
import { updatePageRefs } from "./update-refs.js";
|
|
6
7
|
import { renderImage } from "./render-image.js";
|
|
7
8
|
import { registerFonts, getFontNameStyle } from "./font.js";
|
|
8
9
|
import { registerDefaultStdFonts } from "./std-fonts.js";
|
|
9
10
|
import { toBlob, toBytes } from "pdfkit/output";
|
|
10
11
|
import PDFDocument from "pdfkit";
|
|
11
|
-
import { PdfKitAlignment
|
|
12
|
+
import type { PdfKitAlignment } from "./textRunRow.js";
|
|
13
|
+
import { rowsCombineTextRuns, rowsSplit } from "./textRunRow.js";
|
|
12
14
|
|
|
13
15
|
export type PdfExportOptions = {
|
|
14
16
|
compress: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as AD from "../../abstract-document/index.js";
|
|
2
|
-
import { Page } from "./paginate.js";
|
|
1
|
+
import type * as AD from "../../abstract-document/index.js";
|
|
2
|
+
import type { Page } from "./paginate.js";
|
|
3
3
|
|
|
4
4
|
export function updatePageRefs(pages: ReadonlyArray<Page>): Array<Page> {
|
|
5
5
|
return pages.map((page) => updateRefsOnPage(page, pages));
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { exhaustiveCheck } from "ts-exhaustive-check";
|
|
2
|
-
import { AbstractDoc } from "../../abstract-document/abstract-doc.js";
|
|
3
|
-
import { Resources
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
2
|
+
import type { AbstractDoc } from "../../abstract-document/abstract-doc.js";
|
|
3
|
+
import type { Resources } from "../../abstract-document/resources.js";
|
|
4
|
+
import { mergeResources } from "../../abstract-document/resources.js";
|
|
5
|
+
import type { Group } from "../../abstract-document/section-elements/group.js";
|
|
6
|
+
import type { Table } from "../../abstract-document/section-elements/table.js";
|
|
7
|
+
import type { SectionElement } from "../../abstract-document/section-elements/section-element.js";
|
|
8
|
+
import type { Paragraph } from "../../abstract-document/section-elements/paragraph.js";
|
|
9
|
+
import type { Section } from "../../abstract-document/page/section.js";
|
|
10
|
+
import type { TableRow } from "../../abstract-document/table/table-row.js";
|
|
11
|
+
import type { TableCell } from "../../abstract-document/table/table-cell.js";
|
|
11
12
|
|
|
12
13
|
export function getResources(doc: AbstractDoc): Resources {
|
|
13
14
|
const resources = doc.children.map((s) => getResourcesSection(s));
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { addResources, merge } from "../../abstract-document/abstract-doc.js";
|
|
2
|
-
import { AbstractDoc } from "../../abstract-document/index.js";
|
|
2
|
+
import type { AbstractDoc } from "../../abstract-document/index.js";
|
|
3
3
|
import * as StyleKey from "../../abstract-document/styles/style-key.js";
|
|
4
|
-
import { Resources } from "../../abstract-document/resources.js";
|
|
5
|
-
import { ADCreatorFn
|
|
4
|
+
import type { Resources } from "../../abstract-document/resources.js";
|
|
5
|
+
import type { ADCreatorFn } from "./creator.js";
|
|
6
|
+
import { creators, propsCreators } from "./creator.js";
|
|
6
7
|
import { parseHandlebarsXml, type XmlElement } from "handlebars-xml";
|
|
7
8
|
import { getFontStyleName } from "../../abstract-document-exporters/pdf/font.js";
|
|
8
|
-
import { Font } from "../../abstract-document/primitives/font.js";
|
|
9
|
+
import type { Font } from "../../abstract-document/primitives/font.js";
|
|
9
10
|
|
|
10
11
|
export type TemplateInput = {
|
|
11
12
|
readonly template: string;
|
|
@@ -72,9 +73,9 @@ function abstractDocXmlRecursive(
|
|
|
72
73
|
const childName = childElement.tagName;
|
|
73
74
|
if (childName !== undefined) {
|
|
74
75
|
if (childName === "StyleNames") {
|
|
75
|
-
props
|
|
76
|
-
} else if (childName === "StyleName" && childElement.attributes && childElement.attributes
|
|
77
|
-
const styleName = StyleKey.create(childElement.attributes
|
|
76
|
+
props["styles"] = abstractDocXmlRecursive(creators, childElement);
|
|
77
|
+
} else if (childName === "StyleName" && childElement.attributes && childElement.attributes["name"]) {
|
|
78
|
+
const styleName = StyleKey.create(childElement.attributes["type"], childElement.attributes["name"]);
|
|
78
79
|
const style = abstractDocXmlRecursive(creators, childElement);
|
|
79
80
|
props[styleName] = style;
|
|
80
81
|
} else if (childName.startsWith(childName.charAt(0).toUpperCase())) {
|
|
@@ -85,11 +86,11 @@ function abstractDocXmlRecursive(
|
|
|
85
86
|
// Some special keys should directly have an array of children as value instead of an object with children key
|
|
86
87
|
const arrayedElements = ["header", "footer", "headerRows"];
|
|
87
88
|
const childrenOnly = arrayedElements.findIndex((e) => e === childName) !== -1;
|
|
88
|
-
const differentFirstPage = childElement.attributes
|
|
89
|
+
const differentFirstPage = childElement.attributes["differentFirstPage"];
|
|
89
90
|
if (differentFirstPage === "true" && childName === "header") {
|
|
90
|
-
props
|
|
91
|
+
props["frontHeader"] = abstractDocXmlRecursive(creators, childElement, childrenOnly);
|
|
91
92
|
} else if (differentFirstPage === "true" && childName === "footer") {
|
|
92
|
-
props
|
|
93
|
+
props["frontFooter"] = abstractDocXmlRecursive(creators, childElement, childrenOnly);
|
|
93
94
|
} else {
|
|
94
95
|
props[childName] = abstractDocXmlRecursive(creators, childElement, childrenOnly);
|
|
95
96
|
}
|
|
@@ -119,19 +120,19 @@ function abstractDocXmlRecursive(
|
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
// Elements styling needs to have style: {type= "StyleName" }. Occures when having a <style></style> element.
|
|
122
|
-
if (typeof obj
|
|
123
|
-
if (obj
|
|
124
|
-
obj
|
|
123
|
+
if (typeof obj["style"] === "object") {
|
|
124
|
+
if (obj["columnSpan"]) {
|
|
125
|
+
obj["style"] = { ...obj["style"], type: "TableCellStyle" };
|
|
125
126
|
} else {
|
|
126
|
-
switch (obj
|
|
127
|
+
switch (obj["type"]) {
|
|
127
128
|
case "page":
|
|
128
|
-
obj
|
|
129
|
+
obj["style"] = { ...obj["style"], type: "MasterPageStyle" };
|
|
129
130
|
break;
|
|
130
131
|
case "Group":
|
|
131
|
-
obj
|
|
132
|
+
obj["style"] = { ...obj["style"], type: "GroupStyle" };
|
|
132
133
|
break;
|
|
133
134
|
case "Table":
|
|
134
|
-
obj
|
|
135
|
+
obj["style"] = { ...obj["style"], type: "TableStyle" };
|
|
135
136
|
break;
|
|
136
137
|
// Cell is missing type in abstract doc?!?!?!
|
|
137
138
|
// case "TableCell":
|
|
@@ -142,12 +143,12 @@ function abstractDocXmlRecursive(
|
|
|
142
143
|
case "TextParagraph":
|
|
143
144
|
case "ImageParagraph":
|
|
144
145
|
case "Paragraph":
|
|
145
|
-
obj
|
|
146
|
+
obj["style"] = { ...obj["style"], type: "ParagraphStyle" };
|
|
146
147
|
break;
|
|
147
148
|
case "TextField":
|
|
148
149
|
case "HyperLink":
|
|
149
150
|
case "TextRun":
|
|
150
|
-
obj
|
|
151
|
+
obj["style"] = { ...obj["style"], type: "TextStyle" };
|
|
151
152
|
break;
|
|
152
153
|
default:
|
|
153
154
|
break;
|
|
@@ -156,7 +157,7 @@ function abstractDocXmlRecursive(
|
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
if (children.length > 0) {
|
|
159
|
-
obj
|
|
160
|
+
obj["children"] = children;
|
|
160
161
|
}
|
|
161
162
|
return obj;
|
|
162
163
|
}
|
|
@@ -188,7 +189,7 @@ function extractImageFontsStyleNames(
|
|
|
188
189
|
styleNames: Record<string, string> = {},
|
|
189
190
|
images: Record<string, true> = {},
|
|
190
191
|
fonts: Record<string, Partial<Record<keyof Font, boolean>>> = {},
|
|
191
|
-
currentFontFamily: string | undefined = undefined
|
|
192
|
+
currentFontFamily: string | undefined = undefined
|
|
192
193
|
): readonly [
|
|
193
194
|
imageUrls: Record<string, true>,
|
|
194
195
|
fontFamilies: Record<string, Partial<Record<keyof Font, boolean>>>,
|
|
@@ -196,41 +197,41 @@ function extractImageFontsStyleNames(
|
|
|
196
197
|
] {
|
|
197
198
|
let crFntFam = currentFontFamily;
|
|
198
199
|
xmlElement.forEach((item) => {
|
|
199
|
-
if (item.tagName.startsWith("Image") && item.attributes?.src) {
|
|
200
|
-
images[item.attributes
|
|
200
|
+
if (item.tagName.startsWith("Image") && item.attributes?.["src"]) {
|
|
201
|
+
images[item.attributes["src"] as string] = true;
|
|
201
202
|
} else if (item.tagName === "style") {
|
|
202
|
-
const fontFamily = crFntFam ?? styleFamilies
|
|
203
|
-
if(fontFamily) {
|
|
203
|
+
const fontFamily = crFntFam ?? styleFamilies["Default"];
|
|
204
|
+
if (fontFamily) {
|
|
204
205
|
const styleName = getFontStyleName(item.attributes);
|
|
205
206
|
(fonts[fontFamily] ??= {})[styleName] = true;
|
|
206
207
|
}
|
|
207
|
-
} else if(item.attributes
|
|
208
|
-
crFntFam = styleFamilies[item.attributes
|
|
209
|
-
} else if (item.attributes
|
|
210
|
-
const style = item.attributes
|
|
211
|
-
if(style) {
|
|
208
|
+
} else if (item.attributes["styleName"] !== undefined) {
|
|
209
|
+
crFntFam = styleFamilies[item.attributes["styleName"]] ?? crFntFam;
|
|
210
|
+
} else if (item.attributes["styleNames"] !== undefined) {
|
|
211
|
+
const style = item.attributes["styleNames"].split(",").find((style) => styleFamilies[style]);
|
|
212
|
+
if (style) {
|
|
212
213
|
const fontFamily = styleFamilies[style];
|
|
213
|
-
if(fontFamily) {
|
|
214
|
+
if (fontFamily) {
|
|
214
215
|
crFntFam = fontFamily;
|
|
215
216
|
}
|
|
216
217
|
}
|
|
217
|
-
} else if (item.attributes?.fontFamily) {
|
|
218
|
+
} else if (item.attributes?.["fontFamily"]) {
|
|
218
219
|
const styleName = getFontStyleName(item.attributes);
|
|
219
|
-
(fonts[item.attributes
|
|
220
|
-
if (item.tagName === "StyleName" && item.attributes
|
|
221
|
-
styleNames[item.attributes
|
|
220
|
+
(fonts[item.attributes["fontFamily"] as string] ??= {})[styleName] = true;
|
|
221
|
+
if (item.tagName === "StyleName" && item.attributes["name"] && item.attributes["type"]) {
|
|
222
|
+
styleNames[item.attributes["name"] as string] = item.attributes["type"];
|
|
222
223
|
}
|
|
223
|
-
} else if (item.tagName === "StyleName" && item.attributes
|
|
224
|
-
styleNames[item.attributes
|
|
225
|
-
if(item.attributes
|
|
224
|
+
} else if (item.tagName === "StyleName" && item.attributes["name"] && item.attributes["type"]) {
|
|
225
|
+
styleNames[item.attributes["name"] as string] = item.attributes["type"];
|
|
226
|
+
if (item.attributes["type"] === "TextStyle" && item.attributes["fontFamily"]) {
|
|
226
227
|
const styleName = getFontStyleName(item.attributes);
|
|
227
|
-
styleFamilies[item.attributes
|
|
228
|
-
(fonts[item.attributes
|
|
228
|
+
styleFamilies[item.attributes["name"] as string] = item.attributes["fontFamily"];
|
|
229
|
+
(fonts[item.attributes["fontFamily"]] ??= {})[styleName] = true;
|
|
229
230
|
}
|
|
230
231
|
}
|
|
231
|
-
if(item.children.length > 0) {
|
|
232
|
+
if (item.children.length > 0) {
|
|
232
233
|
extractImageFontsStyleNames(item.children, styleFamilies, styleNames, images, fonts, crFntFam);
|
|
233
234
|
}
|
|
234
235
|
});
|
|
235
236
|
return [images, fonts, styleNames];
|
|
236
|
-
}
|
|
237
|
+
}
|