@cj-tech-master/excelts 9.5.0 → 9.5.1
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/browser/modules/pdf/excel-bridge.js +27 -1
- package/dist/browser/modules/pdf/render/layout-engine.js +74 -9
- package/dist/browser/modules/pdf/render/style-converter.d.ts +1 -1
- package/dist/browser/modules/pdf/render/style-converter.js +98 -1
- package/dist/browser/modules/pdf/types.d.ts +1 -0
- package/dist/browser/modules/word/color-utils.d.ts +18 -0
- package/dist/browser/modules/word/color-utils.js +94 -0
- package/dist/browser/modules/word/content-types.d.ts +15 -15
- package/dist/browser/modules/word/content-types.js +39 -43
- package/dist/browser/modules/word/crypto.d.ts +17 -0
- package/dist/browser/modules/word/crypto.js +18 -0
- package/dist/browser/modules/word/document-io.d.ts +58 -0
- package/dist/browser/modules/word/document-io.js +239 -0
- package/dist/browser/modules/word/document.d.ts +64 -135
- package/dist/browser/modules/word/document.js +207 -469
- package/dist/browser/modules/word/docx-packager.js +90 -90
- package/dist/browser/modules/word/html-renderer.js +1 -1
- package/dist/browser/modules/word/html.d.ts +13 -0
- package/dist/browser/modules/word/html.js +12 -0
- package/dist/browser/modules/word/index.base.d.ts +6 -9
- package/dist/browser/modules/word/index.base.js +7 -10
- package/dist/browser/modules/word/namespaces.d.ts +159 -0
- package/dist/browser/modules/word/namespaces.js +189 -0
- package/dist/browser/modules/word/relationships.d.ts +15 -16
- package/dist/browser/modules/word/relationships.js +37 -45
- package/dist/cjs/modules/pdf/excel-bridge.js +27 -1
- package/dist/cjs/modules/pdf/render/layout-engine.js +74 -9
- package/dist/cjs/modules/pdf/render/style-converter.js +98 -1
- package/dist/cjs/modules/word/color-utils.js +97 -0
- package/dist/cjs/modules/word/content-types.js +44 -45
- package/dist/cjs/modules/word/crypto.js +34 -0
- package/dist/cjs/modules/word/document-io.js +244 -0
- package/dist/cjs/modules/word/document.js +209 -473
- package/dist/cjs/modules/word/docx-packager.js +88 -88
- package/dist/cjs/modules/word/html-renderer.js +2 -2
- package/dist/cjs/modules/word/html.js +16 -0
- package/dist/cjs/modules/word/index.base.js +17 -27
- package/dist/cjs/modules/word/namespaces.js +192 -0
- package/dist/cjs/modules/word/relationships.js +42 -47
- package/dist/esm/modules/pdf/excel-bridge.js +27 -1
- package/dist/esm/modules/pdf/render/layout-engine.js +74 -9
- package/dist/esm/modules/pdf/render/style-converter.js +98 -1
- package/dist/esm/modules/word/color-utils.js +94 -0
- package/dist/esm/modules/word/content-types.js +39 -43
- package/dist/esm/modules/word/crypto.js +18 -0
- package/dist/esm/modules/word/document-io.js +239 -0
- package/dist/esm/modules/word/document.js +207 -469
- package/dist/esm/modules/word/docx-packager.js +90 -90
- package/dist/esm/modules/word/html-renderer.js +1 -1
- package/dist/esm/modules/word/html.js +12 -0
- package/dist/esm/modules/word/index.base.js +7 -10
- package/dist/esm/modules/word/namespaces.js +189 -0
- package/dist/esm/modules/word/relationships.js +37 -45
- package/dist/iife/excelts.iife.js +153 -11
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +4 -4
- package/dist/types/modules/pdf/render/style-converter.d.ts +1 -1
- package/dist/types/modules/pdf/types.d.ts +1 -0
- package/dist/types/modules/word/color-utils.d.ts +18 -0
- package/dist/types/modules/word/content-types.d.ts +15 -15
- package/dist/types/modules/word/crypto.d.ts +17 -0
- package/dist/types/modules/word/document-io.d.ts +58 -0
- package/dist/types/modules/word/document.d.ts +64 -135
- package/dist/types/modules/word/html.d.ts +13 -0
- package/dist/types/modules/word/index.base.d.ts +6 -9
- package/dist/types/modules/word/namespaces.d.ts +159 -0
- package/dist/types/modules/word/relationships.d.ts +15 -16
- package/package.json +1 -1
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOCX Module — Sub-namespace objects
|
|
3
|
+
*
|
|
4
|
+
* Groups flat builder helpers into logical namespaces for better
|
|
5
|
+
* IDE discoverability. These are re-exports aggregated into objects;
|
|
6
|
+
* since they reference the same underlying functions, tree-shaking
|
|
7
|
+
* still applies at the individual function level for consumers who
|
|
8
|
+
* import the flat named exports instead.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Run, Paragraph, Table, Math, Field } from "excelts/word";
|
|
13
|
+
*
|
|
14
|
+
* const doc = Document.create();
|
|
15
|
+
* Document.addParagraphElement(doc, Paragraph.create([
|
|
16
|
+
* Run.bold("Hello"),
|
|
17
|
+
* Run.text(" world")
|
|
18
|
+
* ]));
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import { text, bold, italic, pageBreak, lineBreak, columnBreak, tab, positionalTab, ruby, carriageReturn, noBreakHyphen, softHyphen, symbol, field, pageNumberField, totalPagesField, sectionPagesField, sectionField, dateField, sequenceField, timeField, authorField, titleField, subjectField, keywordsField, fileNameField, fileSizeField, styleRefField, refField, pageRefField, noteRefField, hyperlinkField, quoteField, tocField, tcField, indexEntryField, indexField, ifField, includeTextField, includePictureField, formTextField, formCheckboxField, formDropdownField, paragraph, textParagraph, heading, hyperlink, bookmarkStart, bookmarkEnd, commentRangeStart, commentRangeEnd, commentReference, insertedRun, deletedRun, movedFromRun, movedToRun, moveFromRangeStart, moveFromRangeEnd, moveToRangeStart, moveToRangeEnd, checkBox, mathBlock, mathRun, mathFraction, mathSqrt, mathRoot, mathSum, mathIntegral, mathProduct, mathSuperScript, mathSubScript, mathSubSuperScript, mathPreSubSuperScript, mathPhantom, mathGroupChar, mathBorderBox, mathDelimiter, mathNary, mathFunction, mathLimit, mathMatrix, mathAccent, mathBar, mathBox, mathEquationArray, floatingImage, drawingShape, chart, structuredDocumentTag, border, gridBorders, cell, row, table, simpleTable, searchText, replaceText, mailMerge, paragraphCount, countWords, getHeadings, findBookmark, findComment, listImages, listTables, listHyperlinks, tableCount, extractText } from "./document.js";
|
|
22
|
+
// =============================================================================
|
|
23
|
+
// Run namespace — text run constructors
|
|
24
|
+
// =============================================================================
|
|
25
|
+
/** Namespace for creating text runs (inline content). */
|
|
26
|
+
export const Run = {
|
|
27
|
+
text,
|
|
28
|
+
bold,
|
|
29
|
+
italic,
|
|
30
|
+
pageBreak,
|
|
31
|
+
lineBreak,
|
|
32
|
+
columnBreak,
|
|
33
|
+
tab,
|
|
34
|
+
positionalTab,
|
|
35
|
+
ruby,
|
|
36
|
+
carriageReturn,
|
|
37
|
+
noBreakHyphen,
|
|
38
|
+
softHyphen,
|
|
39
|
+
symbol
|
|
40
|
+
};
|
|
41
|
+
// =============================================================================
|
|
42
|
+
// Field namespace — field code constructors
|
|
43
|
+
// =============================================================================
|
|
44
|
+
/** Namespace for creating field codes. */
|
|
45
|
+
export const Field = {
|
|
46
|
+
create: field,
|
|
47
|
+
pageNumber: pageNumberField,
|
|
48
|
+
totalPages: totalPagesField,
|
|
49
|
+
sectionPages: sectionPagesField,
|
|
50
|
+
section: sectionField,
|
|
51
|
+
date: dateField,
|
|
52
|
+
sequence: sequenceField,
|
|
53
|
+
time: timeField,
|
|
54
|
+
author: authorField,
|
|
55
|
+
title: titleField,
|
|
56
|
+
subject: subjectField,
|
|
57
|
+
keywords: keywordsField,
|
|
58
|
+
fileName: fileNameField,
|
|
59
|
+
fileSize: fileSizeField,
|
|
60
|
+
styleRef: styleRefField,
|
|
61
|
+
ref: refField,
|
|
62
|
+
pageRef: pageRefField,
|
|
63
|
+
noteRef: noteRefField,
|
|
64
|
+
hyperlink: hyperlinkField,
|
|
65
|
+
quote: quoteField,
|
|
66
|
+
toc: tocField,
|
|
67
|
+
tc: tcField,
|
|
68
|
+
indexEntry: indexEntryField,
|
|
69
|
+
index: indexField,
|
|
70
|
+
condition: ifField,
|
|
71
|
+
includeText: includeTextField,
|
|
72
|
+
includePicture: includePictureField,
|
|
73
|
+
formText: formTextField,
|
|
74
|
+
formCheckbox: formCheckboxField,
|
|
75
|
+
formDropdown: formDropdownField
|
|
76
|
+
};
|
|
77
|
+
// =============================================================================
|
|
78
|
+
// Paragraph namespace — paragraph constructors
|
|
79
|
+
// =============================================================================
|
|
80
|
+
/** Namespace for creating paragraphs. */
|
|
81
|
+
export const Paragraph = {
|
|
82
|
+
create: paragraph,
|
|
83
|
+
text: textParagraph,
|
|
84
|
+
heading,
|
|
85
|
+
hyperlink,
|
|
86
|
+
bookmarkStart,
|
|
87
|
+
bookmarkEnd
|
|
88
|
+
};
|
|
89
|
+
// =============================================================================
|
|
90
|
+
// Comment namespace — comment markers
|
|
91
|
+
// =============================================================================
|
|
92
|
+
/** Namespace for comment-related markers. */
|
|
93
|
+
export const Comment = {
|
|
94
|
+
rangeStart: commentRangeStart,
|
|
95
|
+
rangeEnd: commentRangeEnd,
|
|
96
|
+
reference: commentReference
|
|
97
|
+
};
|
|
98
|
+
// =============================================================================
|
|
99
|
+
// TrackChanges namespace — revision markers
|
|
100
|
+
// =============================================================================
|
|
101
|
+
/** Namespace for track-changes (revision) markers. */
|
|
102
|
+
export const TrackChanges = {
|
|
103
|
+
insertedRun,
|
|
104
|
+
deletedRun,
|
|
105
|
+
movedFromRun,
|
|
106
|
+
movedToRun,
|
|
107
|
+
moveFromRangeStart,
|
|
108
|
+
moveFromRangeEnd,
|
|
109
|
+
moveToRangeStart,
|
|
110
|
+
moveToRangeEnd
|
|
111
|
+
};
|
|
112
|
+
// =============================================================================
|
|
113
|
+
// Math namespace — Office Math constructors
|
|
114
|
+
// =============================================================================
|
|
115
|
+
/** Namespace for OMML (Office Math) content. */
|
|
116
|
+
export const Math = {
|
|
117
|
+
block: mathBlock,
|
|
118
|
+
run: mathRun,
|
|
119
|
+
fraction: mathFraction,
|
|
120
|
+
sqrt: mathSqrt,
|
|
121
|
+
root: mathRoot,
|
|
122
|
+
sum: mathSum,
|
|
123
|
+
integral: mathIntegral,
|
|
124
|
+
product: mathProduct,
|
|
125
|
+
superScript: mathSuperScript,
|
|
126
|
+
subScript: mathSubScript,
|
|
127
|
+
subSuperScript: mathSubSuperScript,
|
|
128
|
+
preSubSuperScript: mathPreSubSuperScript,
|
|
129
|
+
phantom: mathPhantom,
|
|
130
|
+
groupChar: mathGroupChar,
|
|
131
|
+
borderBox: mathBorderBox,
|
|
132
|
+
delimiter: mathDelimiter,
|
|
133
|
+
nary: mathNary,
|
|
134
|
+
func: mathFunction,
|
|
135
|
+
limit: mathLimit,
|
|
136
|
+
matrix: mathMatrix,
|
|
137
|
+
accent: mathAccent,
|
|
138
|
+
bar: mathBar,
|
|
139
|
+
box: mathBox,
|
|
140
|
+
equationArray: mathEquationArray
|
|
141
|
+
};
|
|
142
|
+
// =============================================================================
|
|
143
|
+
// Table namespace — table constructors
|
|
144
|
+
// =============================================================================
|
|
145
|
+
/** Namespace for creating tables. */
|
|
146
|
+
export const Table = {
|
|
147
|
+
create: table,
|
|
148
|
+
simple: simpleTable,
|
|
149
|
+
row,
|
|
150
|
+
cell,
|
|
151
|
+
border,
|
|
152
|
+
gridBorders
|
|
153
|
+
};
|
|
154
|
+
// =============================================================================
|
|
155
|
+
// Drawing namespace — images, shapes, charts
|
|
156
|
+
// =============================================================================
|
|
157
|
+
/** Namespace for drawings (images, shapes, charts). */
|
|
158
|
+
export const Drawing = {
|
|
159
|
+
floatingImage,
|
|
160
|
+
shape: drawingShape,
|
|
161
|
+
chart
|
|
162
|
+
};
|
|
163
|
+
// =============================================================================
|
|
164
|
+
// Sdt namespace — structured document tags
|
|
165
|
+
// =============================================================================
|
|
166
|
+
/** Namespace for structured document tags (content controls). */
|
|
167
|
+
export const Sdt = {
|
|
168
|
+
create: structuredDocumentTag,
|
|
169
|
+
checkBox
|
|
170
|
+
};
|
|
171
|
+
// =============================================================================
|
|
172
|
+
// Query namespace — document query/search functions
|
|
173
|
+
// =============================================================================
|
|
174
|
+
/** Namespace for querying/searching document content. */
|
|
175
|
+
export const Query = {
|
|
176
|
+
search: searchText,
|
|
177
|
+
replace: replaceText,
|
|
178
|
+
mailMerge,
|
|
179
|
+
paragraphCount,
|
|
180
|
+
countWords,
|
|
181
|
+
getHeadings,
|
|
182
|
+
findBookmark,
|
|
183
|
+
findComment,
|
|
184
|
+
listImages,
|
|
185
|
+
listTables,
|
|
186
|
+
listHyperlinks,
|
|
187
|
+
tableCount,
|
|
188
|
+
extractText
|
|
189
|
+
};
|
|
@@ -3,54 +3,46 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Manages OPC relationships for the DOCX package.
|
|
5
5
|
* Generates .rels files for package-level and part-level relationships.
|
|
6
|
+
* Uses a plain data record + free functions for tree-shakeability.
|
|
6
7
|
*/
|
|
7
8
|
import { NS_PKG_RELS, STD_DOC_ATTRIBUTES } from "./constants.js";
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// Keep nextId above any manually-assigned IDs
|
|
26
|
-
const num = parseInt(id.replace("rId", ""), 10);
|
|
27
|
-
if (!isNaN(num) && num >= this._nextId) {
|
|
28
|
-
this._nextId = num + 1;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/** Get all relationships. */
|
|
32
|
-
get relationships() {
|
|
33
|
-
return this._rels;
|
|
34
|
-
}
|
|
35
|
-
/** Get the number of relationships. */
|
|
36
|
-
get count() {
|
|
37
|
-
return this._rels.length;
|
|
9
|
+
/** Create a new empty RelationshipsState. */
|
|
10
|
+
export function createRelationships() {
|
|
11
|
+
return { rels: [], nextId: 1 };
|
|
12
|
+
}
|
|
13
|
+
/** Add a relationship and return its assigned rId. */
|
|
14
|
+
export function addRelationship(state, type, target, targetMode) {
|
|
15
|
+
const id = `rId${state.nextId++}`;
|
|
16
|
+
state.rels.push({ id, type, target, targetMode });
|
|
17
|
+
return id;
|
|
18
|
+
}
|
|
19
|
+
/** Add a relationship with a specific ID. */
|
|
20
|
+
export function addRelationshipWithId(state, id, type, target, targetMode) {
|
|
21
|
+
state.rels.push({ id, type, target, targetMode });
|
|
22
|
+
// Keep nextId above any manually-assigned IDs
|
|
23
|
+
const num = parseInt(id.replace("rId", ""), 10);
|
|
24
|
+
if (!isNaN(num) && num >= state.nextId) {
|
|
25
|
+
state.nextId = num + 1;
|
|
38
26
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
27
|
+
}
|
|
28
|
+
/** Get the number of relationships. */
|
|
29
|
+
export function getRelationshipCount(state) {
|
|
30
|
+
return state.rels.length;
|
|
31
|
+
}
|
|
32
|
+
/** Render the relationships XML to a sink. */
|
|
33
|
+
export function renderRelationships(state, xml) {
|
|
34
|
+
xml.openXml(STD_DOC_ATTRIBUTES);
|
|
35
|
+
xml.openNode("Relationships", { xmlns: NS_PKG_RELS });
|
|
36
|
+
for (const rel of state.rels) {
|
|
37
|
+
const attrs = {
|
|
38
|
+
Id: rel.id,
|
|
39
|
+
Type: rel.type,
|
|
40
|
+
Target: rel.target
|
|
41
|
+
};
|
|
42
|
+
if (rel.targetMode) {
|
|
43
|
+
attrs.TargetMode = rel.targetMode;
|
|
53
44
|
}
|
|
54
|
-
xml.
|
|
45
|
+
xml.leafNode("Relationship", attrs);
|
|
55
46
|
}
|
|
47
|
+
xml.closeNode();
|
|
56
48
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @cj-tech-master/excelts v9.5.
|
|
2
|
+
* @cj-tech-master/excelts v9.5.1
|
|
3
3
|
* Zero-dependency TypeScript toolkit — Excel (XLSX), PDF, CSV, Markdown, XML, ZIP/TAR, and streaming.
|
|
4
4
|
* (c) 2026 cjnoname
|
|
5
5
|
* Released under the MIT License
|
|
@@ -88381,7 +88381,7 @@ self.onmessage = async function(event) {
|
|
|
88381
88381
|
}
|
|
88382
88382
|
/**
|
|
88383
88383
|
* Convert a color data object to PDF color.
|
|
88384
|
-
* Handles
|
|
88384
|
+
* Handles ARGB, theme-based, and indexed colors.
|
|
88385
88385
|
*/
|
|
88386
88386
|
function excelColorToPdf(color) {
|
|
88387
88387
|
if (!color) return null;
|
|
@@ -88393,6 +88393,7 @@ self.onmessage = async function(event) {
|
|
|
88393
88393
|
if (tint !== void 0 && tint !== 0) return applyTint(base, tint);
|
|
88394
88394
|
return base;
|
|
88395
88395
|
}
|
|
88396
|
+
if (color.indexed !== void 0) return indexedColorToPdf(color.indexed);
|
|
88396
88397
|
return null;
|
|
88397
88398
|
}
|
|
88398
88399
|
/**
|
|
@@ -88456,6 +88457,99 @@ self.onmessage = async function(event) {
|
|
|
88456
88457
|
return null;
|
|
88457
88458
|
}
|
|
88458
88459
|
/**
|
|
88460
|
+
* Standard Excel indexed color palette (56 colors + system colors).
|
|
88461
|
+
* Index 0–7: legacy base colors
|
|
88462
|
+
* Index 8–63: standard palette (indices 8–63)
|
|
88463
|
+
* Index 64: system foreground (black)
|
|
88464
|
+
* Index 65: system background (white)
|
|
88465
|
+
*
|
|
88466
|
+
* @see ECMA-376 §18.8.27 — indexedColors
|
|
88467
|
+
*/
|
|
88468
|
+
const INDEXED_COLORS = [
|
|
88469
|
+
"000000",
|
|
88470
|
+
"FFFFFF",
|
|
88471
|
+
"FF0000",
|
|
88472
|
+
"00FF00",
|
|
88473
|
+
"0000FF",
|
|
88474
|
+
"FFFF00",
|
|
88475
|
+
"FF00FF",
|
|
88476
|
+
"00FFFF",
|
|
88477
|
+
"000000",
|
|
88478
|
+
"FFFFFF",
|
|
88479
|
+
"FF0000",
|
|
88480
|
+
"00FF00",
|
|
88481
|
+
"0000FF",
|
|
88482
|
+
"FFFF00",
|
|
88483
|
+
"FF00FF",
|
|
88484
|
+
"00FFFF",
|
|
88485
|
+
"800000",
|
|
88486
|
+
"008000",
|
|
88487
|
+
"000080",
|
|
88488
|
+
"808000",
|
|
88489
|
+
"800080",
|
|
88490
|
+
"008080",
|
|
88491
|
+
"C0C0C0",
|
|
88492
|
+
"808080",
|
|
88493
|
+
"9999FF",
|
|
88494
|
+
"993366",
|
|
88495
|
+
"FFFFCC",
|
|
88496
|
+
"CCFFFF",
|
|
88497
|
+
"660066",
|
|
88498
|
+
"FF8080",
|
|
88499
|
+
"0066CC",
|
|
88500
|
+
"CCCCFF",
|
|
88501
|
+
"000080",
|
|
88502
|
+
"FF00FF",
|
|
88503
|
+
"FFFF00",
|
|
88504
|
+
"00FFFF",
|
|
88505
|
+
"800080",
|
|
88506
|
+
"800000",
|
|
88507
|
+
"008080",
|
|
88508
|
+
"0000FF",
|
|
88509
|
+
"00CCFF",
|
|
88510
|
+
"CCFFFF",
|
|
88511
|
+
"CCFFCC",
|
|
88512
|
+
"FFFF99",
|
|
88513
|
+
"99CCFF",
|
|
88514
|
+
"FF99CC",
|
|
88515
|
+
"CC99FF",
|
|
88516
|
+
"FFCC99",
|
|
88517
|
+
"3366FF",
|
|
88518
|
+
"33CCCC",
|
|
88519
|
+
"99CC00",
|
|
88520
|
+
"FFCC00",
|
|
88521
|
+
"FF9900",
|
|
88522
|
+
"FF6600",
|
|
88523
|
+
"666699",
|
|
88524
|
+
"969696",
|
|
88525
|
+
"003366",
|
|
88526
|
+
"339966",
|
|
88527
|
+
"003300",
|
|
88528
|
+
"333300",
|
|
88529
|
+
"993300",
|
|
88530
|
+
"993366",
|
|
88531
|
+
"333399",
|
|
88532
|
+
"333333"
|
|
88533
|
+
];
|
|
88534
|
+
/**
|
|
88535
|
+
* Convert an indexed color to PDF color.
|
|
88536
|
+
* Index 64 = system foreground (black), 65 = system background (white).
|
|
88537
|
+
*/
|
|
88538
|
+
function indexedColorToPdf(index) {
|
|
88539
|
+
if (index === 64) return {
|
|
88540
|
+
r: 0,
|
|
88541
|
+
g: 0,
|
|
88542
|
+
b: 0
|
|
88543
|
+
};
|
|
88544
|
+
if (index === 65) return {
|
|
88545
|
+
r: 1,
|
|
88546
|
+
g: 1,
|
|
88547
|
+
b: 1
|
|
88548
|
+
};
|
|
88549
|
+
if (index >= 0 && index < INDEXED_COLORS.length) return argbToPdfColor(INDEXED_COLORS[index]) ?? null;
|
|
88550
|
+
return null;
|
|
88551
|
+
}
|
|
88552
|
+
/**
|
|
88459
88553
|
* Apply a tint value to a color.
|
|
88460
88554
|
* Tint range: -1.0 (fully dark) to +1.0 (fully light).
|
|
88461
88555
|
* Negative tint darkens, positive tint lightens.
|
|
@@ -89061,7 +89155,7 @@ self.onmessage = async function(event) {
|
|
|
89061
89155
|
if (value && typeof value === "object" && "richText" in value) {
|
|
89062
89156
|
const runs = value.richText;
|
|
89063
89157
|
if (runs.length > 0) {
|
|
89064
|
-
const wrappedCount = countRichTextWrapLines(text, runs, scaleFactor, effectiveWidth, fontManager, options);
|
|
89158
|
+
const wrappedCount = countRichTextWrapLines(text, runs, scaleFactor, effectiveWidth, fontManager, options, cell.style?.font);
|
|
89065
89159
|
return Math.max(lineCount, wrappedCount);
|
|
89066
89160
|
}
|
|
89067
89161
|
}
|
|
@@ -89079,16 +89173,31 @@ self.onmessage = async function(event) {
|
|
|
89079
89173
|
* This mirrors the logic in wrapRichTextLines (page-renderer) so that
|
|
89080
89174
|
* the row height calculation matches the actual rendering.
|
|
89081
89175
|
*/
|
|
89082
|
-
function countRichTextWrapLines(text, runs, scaleFactor, effectiveWidth, fontManager, options) {
|
|
89176
|
+
function countRichTextWrapLines(text, runs, scaleFactor, effectiveWidth, fontManager, options, cellFont) {
|
|
89177
|
+
const defaultFamily = cellFont?.name ?? options.defaultFontFamily;
|
|
89178
|
+
const defaultSize = cellFont?.size ?? options.defaultFontSize;
|
|
89083
89179
|
const runForChar = [];
|
|
89084
89180
|
for (let ri = 0; ri < runs.length; ri++) for (let ci = 0; ci < runs[ri].text.length; ci++) runForChar.push(ri);
|
|
89085
89181
|
const runResources = runs.map((run) => {
|
|
89086
|
-
const fontProps = extractFontProperties(run.font
|
|
89182
|
+
const fontProps = extractFontProperties(run.font ? {
|
|
89183
|
+
name: run.font.name ?? cellFont?.name,
|
|
89184
|
+
size: run.font.size ?? cellFont?.size,
|
|
89185
|
+
bold: run.font.bold ?? cellFont?.bold,
|
|
89186
|
+
italic: run.font.italic ?? cellFont?.italic,
|
|
89187
|
+
strike: run.font.strike ?? cellFont?.strike,
|
|
89188
|
+
underline: run.font.underline ?? cellFont?.underline,
|
|
89189
|
+
color: run.font.color ?? cellFont?.color
|
|
89190
|
+
} : cellFont, defaultFamily, defaultSize);
|
|
89087
89191
|
const pdfFontName = resolvePdfFontName(fontProps.fontFamily, fontProps.bold, fontProps.italic);
|
|
89088
89192
|
return fontManager.hasEmbeddedFont() ? fontManager.getEmbeddedResourceName() : fontManager.ensureFont(pdfFontName);
|
|
89089
89193
|
});
|
|
89090
89194
|
const runFontSizes = runs.map((run) => {
|
|
89091
|
-
return extractFontProperties(run.font
|
|
89195
|
+
return extractFontProperties(run.font ? {
|
|
89196
|
+
name: run.font.name ?? cellFont?.name,
|
|
89197
|
+
size: run.font.size ?? cellFont?.size,
|
|
89198
|
+
bold: run.font.bold ?? cellFont?.bold,
|
|
89199
|
+
italic: run.font.italic ?? cellFont?.italic
|
|
89200
|
+
} : cellFont, defaultFamily, defaultSize).fontSize * scaleFactor;
|
|
89092
89201
|
});
|
|
89093
89202
|
const measureRange = (start, end) => {
|
|
89094
89203
|
let width = 0;
|
|
@@ -89287,7 +89396,7 @@ self.onmessage = async function(event) {
|
|
|
89287
89396
|
fontManager.ensureFont(pdfFontName);
|
|
89288
89397
|
fontManager.trackText(text);
|
|
89289
89398
|
}
|
|
89290
|
-
const richText = buildRichTextRuns(cell, options, fontManager, scaleFactor);
|
|
89399
|
+
const richText = buildRichTextRuns(cell, options, fontManager, scaleFactor, style.font);
|
|
89291
89400
|
const borders = excelBordersToPdf(style.border);
|
|
89292
89401
|
return {
|
|
89293
89402
|
text,
|
|
@@ -89622,21 +89731,44 @@ self.onmessage = async function(event) {
|
|
|
89622
89731
|
overflowAvailable += groupColWidths[j];
|
|
89623
89732
|
if (overflowAvailable >= overflowNeeded) break;
|
|
89624
89733
|
}
|
|
89625
|
-
if (overflowAvailable > 0)
|
|
89734
|
+
if (overflowAvailable > 0) {
|
|
89735
|
+
cell.textOverflowWidth = Math.min(overflowNeeded, overflowAvailable);
|
|
89736
|
+
let accumulated = 0;
|
|
89737
|
+
const actualOverflow = cell.textOverflowWidth;
|
|
89738
|
+
cell.borders.right = null;
|
|
89739
|
+
for (let j = gci + 1; j < colGroup.length; j++) {
|
|
89740
|
+
const neighborCell = cellGrid.get(`${ri}:${j}`);
|
|
89741
|
+
if (!neighborCell) break;
|
|
89742
|
+
neighborCell.borders.left = null;
|
|
89743
|
+
accumulated += groupColWidths[j];
|
|
89744
|
+
if (accumulated >= actualOverflow) break;
|
|
89745
|
+
neighborCell.borders.right = null;
|
|
89746
|
+
}
|
|
89747
|
+
}
|
|
89626
89748
|
}
|
|
89627
89749
|
}
|
|
89628
89750
|
/**
|
|
89629
89751
|
* Build rich text runs from a RichText cell.
|
|
89630
89752
|
* Returns null for non-RichText cells.
|
|
89631
89753
|
*/
|
|
89632
|
-
function buildRichTextRuns(cell, options, fontManager, scaleFactor) {
|
|
89754
|
+
function buildRichTextRuns(cell, options, fontManager, scaleFactor, cellFont) {
|
|
89633
89755
|
if (!cell || cell.type !== PdfCellType.RichText) return null;
|
|
89634
89756
|
const value = cell.value;
|
|
89635
89757
|
if (!value || typeof value !== "object" || !("richText" in value)) return null;
|
|
89636
89758
|
const runs = value.richText;
|
|
89637
89759
|
if (runs.length === 0) return null;
|
|
89760
|
+
const defaultFamily = cellFont?.name ?? options.defaultFontFamily;
|
|
89761
|
+
const defaultSize = cellFont?.size ?? options.defaultFontSize;
|
|
89638
89762
|
return runs.map((run) => {
|
|
89639
|
-
const fontProps = extractFontProperties(run.font
|
|
89763
|
+
const fontProps = extractFontProperties(run.font ? {
|
|
89764
|
+
name: run.font.name ?? cellFont?.name,
|
|
89765
|
+
size: run.font.size ?? cellFont?.size,
|
|
89766
|
+
bold: run.font.bold ?? cellFont?.bold,
|
|
89767
|
+
italic: run.font.italic ?? cellFont?.italic,
|
|
89768
|
+
strike: run.font.strike ?? cellFont?.strike,
|
|
89769
|
+
underline: run.font.underline ?? cellFont?.underline,
|
|
89770
|
+
color: run.font.color ?? cellFont?.color
|
|
89771
|
+
} : cellFont, defaultFamily, defaultSize);
|
|
89640
89772
|
if (fontManager.hasEmbeddedFont()) fontManager.trackText(run.text);
|
|
89641
89773
|
else {
|
|
89642
89774
|
const pdfFontName = resolvePdfFontName(fontProps.fontFamily, fontProps.bold, fontProps.italic);
|
|
@@ -90369,6 +90501,15 @@ self.onmessage = async function(event) {
|
|
|
90369
90501
|
bottom: 0,
|
|
90370
90502
|
right: 0
|
|
90371
90503
|
};
|
|
90504
|
+
if (hasData) for (let r = bounds.top; r <= bounds.bottom; r++) {
|
|
90505
|
+
const row = ws.findRow(r);
|
|
90506
|
+
if (!row) continue;
|
|
90507
|
+
row.eachCell({ includeEmpty: true }, (cell) => {
|
|
90508
|
+
if (cell.col > bounds.right) {
|
|
90509
|
+
if (cell.style && (cell.style.border && (cell.style.border.top || cell.style.border.right || cell.style.border.bottom || cell.style.border.left) || cell.style.fill || cell.style.font) || cell.type !== 0 && cell.type !== 1) bounds.right = cell.col;
|
|
90510
|
+
}
|
|
90511
|
+
});
|
|
90512
|
+
}
|
|
90372
90513
|
const columns = /* @__PURE__ */ new Map();
|
|
90373
90514
|
if (hasData) for (let c = bounds.left; c <= bounds.right; c++) {
|
|
90374
90515
|
const col = ws.getColumn(c);
|
|
@@ -90562,7 +90703,8 @@ self.onmessage = async function(event) {
|
|
|
90562
90703
|
return {
|
|
90563
90704
|
argb: color.argb,
|
|
90564
90705
|
theme: color.theme,
|
|
90565
|
-
tint: color.tint
|
|
90706
|
+
tint: color.tint,
|
|
90707
|
+
indexed: color.indexed
|
|
90566
90708
|
};
|
|
90567
90709
|
}
|
|
90568
90710
|
function convertFill(fill) {
|