@stll/docx-core 0.1.0 → 0.2.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/LICENSE +202 -0
- package/NOTICE.md +29 -0
- package/dist/{document-IR6XvC0O.d.ts → document-B3E-xw_J.d.ts} +25 -8
- package/dist/index.d.ts +2 -2
- package/dist/index.js +18 -6
- package/dist/model/document.d.ts +2 -2
- package/dist/model/document.js +9 -0
- package/package.json +10 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Third-Party Notice
|
|
2
|
+
|
|
3
|
+
This package contains code originally from [Eigenpal docx-editor](https://github.com/eigenpal/docx-editor).
|
|
4
|
+
The upstream Eigenpal code was originally licensed under the MIT License;
|
|
5
|
+
the original license text is reproduced below.
|
|
6
|
+
|
|
7
|
+
## Original MIT License
|
|
8
|
+
|
|
9
|
+
MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2025 Eigenpal
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
@@ -188,8 +188,12 @@ type ParagraphFormatting = {
|
|
|
188
188
|
outlineLevel?: number; /** Paragraph style ID (w:pStyle) */
|
|
189
189
|
styleId?: string; /** Text frame properties (w:framePr) */
|
|
190
190
|
frame?: {
|
|
191
|
+
dropCap?: "none" | "drop" | "margin";
|
|
192
|
+
lines?: number;
|
|
191
193
|
width?: number;
|
|
192
194
|
height?: number;
|
|
195
|
+
hSpace?: number;
|
|
196
|
+
vSpace?: number;
|
|
193
197
|
hAnchor?: "text" | "margin" | "page";
|
|
194
198
|
vAnchor?: "text" | "margin" | "page";
|
|
195
199
|
x?: number;
|
|
@@ -286,7 +290,11 @@ type TableFormatting = {
|
|
|
286
290
|
* Table row formatting properties (w:trPr)
|
|
287
291
|
*/
|
|
288
292
|
type TableRowFormatting = {
|
|
289
|
-
/**
|
|
293
|
+
/** Number of table grid columns omitted before the first cell */gridBefore?: number; /** Preferred width of the omitted leading grid columns */
|
|
294
|
+
widthBefore?: TableMeasurement; /** Number of table grid columns omitted after the last cell */
|
|
295
|
+
gridAfter?: number; /** Preferred width of the omitted trailing grid columns */
|
|
296
|
+
widthAfter?: TableMeasurement; /** Row height */
|
|
297
|
+
height?: TableMeasurement; /** Height rule */
|
|
290
298
|
heightRule?: "auto" | "atLeast" | "exact"; /** Header row (repeats on each page) */
|
|
291
299
|
header?: boolean; /** Allow row to break across pages */
|
|
292
300
|
cantSplit?: boolean; /** Row justification */
|
|
@@ -393,7 +401,8 @@ type ListRendering = {
|
|
|
393
401
|
numFmt?: NumberFormat; /** Whether the list marker is hidden (w:vanish on level rPr) */
|
|
394
402
|
markerHidden?: boolean; /** Marker font family from numbering level rPr (ascii name) */
|
|
395
403
|
markerFontFamily?: string; /** Marker font size from numbering level rPr, in points */
|
|
396
|
-
markerFontSize?: number;
|
|
404
|
+
markerFontSize?: number; /** Horizontal alignment of the marker around the paragraph's list anchor. */
|
|
405
|
+
markerAlignment?: "left" | "center" | "right";
|
|
397
406
|
/**
|
|
398
407
|
* `w:caps` on the numbering level rPr — the marker text renders in upper
|
|
399
408
|
* case (e.g. "SCHEDULE 1" instead of "Schedule 1"). Apply at substitution
|
|
@@ -795,7 +804,8 @@ type TextBox = {
|
|
|
795
804
|
wrap?: ImageWrap; /** Fill */
|
|
796
805
|
fill?: ShapeFill; /** Outline */
|
|
797
806
|
outline?: ShapeOutline; /** Text content */
|
|
798
|
-
content: Paragraph[]; /**
|
|
807
|
+
content: Paragraph[]; /** Text fitting behavior */
|
|
808
|
+
autoFit?: ShapeTextBody["autoFit"]; /** Internal margins */
|
|
799
809
|
margins?: {
|
|
800
810
|
top?: number;
|
|
801
811
|
bottom?: number;
|
|
@@ -1617,11 +1627,18 @@ type DocumentSettings = {
|
|
|
1617
1627
|
bidi?: string;
|
|
1618
1628
|
};
|
|
1619
1629
|
};
|
|
1620
|
-
/**
|
|
1621
|
-
|
|
1622
|
-
|
|
1630
|
+
/** DOCX package conformance classes. */
|
|
1631
|
+
declare const DOCX_CONFORMANCE_CLASSES: Readonly<{
|
|
1632
|
+
readonly STRICT: "strict";
|
|
1633
|
+
readonly TRANSITIONAL: "transitional";
|
|
1634
|
+
readonly UNKNOWN: "unknown";
|
|
1635
|
+
}>;
|
|
1636
|
+
/** Conformance class detected from a DOCX package. */
|
|
1637
|
+
type DocxConformanceClass = (typeof DOCX_CONFORMANCE_CLASSES)[keyof typeof DOCX_CONFORMANCE_CLASSES];
|
|
1638
|
+
/** Complete DOCX package structure. */
|
|
1623
1639
|
type DocxPackage = {
|
|
1624
|
-
/**
|
|
1640
|
+
/** Conformance class detected from the main document namespace. */conformanceClass?: DocxConformanceClass; /** Document body */
|
|
1641
|
+
document: DocumentBody; /** Document-wide settings (`word/settings.xml`). */
|
|
1625
1642
|
settings?: DocumentSettings; /** Style definitions */
|
|
1626
1643
|
styles?: StyleDefinitions; /** Theme */
|
|
1627
1644
|
theme?: Theme; /** Numbering definitions */
|
|
@@ -1656,4 +1673,4 @@ type Document = {
|
|
|
1656
1673
|
warnings?: string[];
|
|
1657
1674
|
};
|
|
1658
1675
|
//#endregion
|
|
1659
|
-
export {
|
|
1676
|
+
export { ImageTransform as $, VerticalAlign as $t, ComplexField as A, ColorValue as An, SectionStart as At, FooterReference as B, TabContent as Bt, BookmarkStart as C, TableMeasurement as Cn, RunContent as Ct, CommentRangeEnd as D, TextFormatting as Dn, Section as Dt, Comment as E, TextEffect as En, SdtType as Et, EndnotePosition as F, ShapeTextBody as Ft, HeaderFooterType as G, TableRow as Gt, FootnotePosition as H, TableCell as Ht, EndnoteProperties as I, ShapeType as It, Image as J, TextBox as Jt, HeaderReference as K, TableRowPropertyChange as Kt, Field as L, SimpleField as Lt, DocumentBody as M, ShadingProperties as Mn, ShapeContent as Mt, DrawingContent as N, ThemeColorSlot as Nn, ShapeFill as Nt, CommentRangeStart as O, UnderlineStyle as On, SectionProperties as Ot, Endnote as P, ShapeOutline as Pt, ImageSize as Q, TrackedRunChange as Qt, FieldCharContent as R, SoftHyphenContent as Rt, BookmarkEnd as S, TableLook as Sn, Run as St, Column as T, TableWidthType as Tn, SdtProperties as Tt, FootnoteProperties as U, TableCellPropertyChange as Ut, Footnote as V, Table as Vt, HeaderFooter as W, TablePropertyChange as Wt, ImagePadding as X, TextWatermark as Xt, ImageCrop as Y, TextContent as Yt, ImagePosition as Z, TrackedChangeInfo as Zt, ThemeColorScheme as _, TabStop as _n, ParagraphContent as _t, DocxPackage as a, NumberFormat as an, MathEquation as at, BlockContent as b, TableCellFormatting as bn, PictureWatermark as bt, FontTable as c, CellMargins as cn, MoveFromRangeStart as ct, RelationshipMap as d, FloatingTableProperties as dn, MoveToRangeStart as dt, Watermark as en, ImageWrap as et, RelationshipType as f, LineSpacingRule as fn, NoBreakHyphenContent as ft, Theme as g, TabLeader as gn, Paragraph as gt, StyleType as h, SpacingExplicit as hn, PageOrientation as ht, DocxConformanceClass as i, ListRendering as in, LineNumberRestart as it, Deletion as j, KnownBorderStyle as jn, Shape as jt, CommentReference as k, BorderSpec as kn, SectionPropertyChange as kt, MediaFile as l, ConditionalFormatStyle as ln, MoveTo as lt, StyleDefinitions as m, ParagraphFormatting as mn, NoteReferenceContent as mt, Document as n, LevelSuffix as nn, Insertion as nt, DocDefaults as o, NumberingDefinitions as on, MoveFrom as ot, Style as p, ParagraphAlignment as pn, NoteNumberRestart as pt, Hyperlink as q, TableStructuralChangeInfo as qt, DocumentSettings as r, ListLevel as rn, InstrTextContent as rt, FontInfo as s, NumberingInstance as sn, MoveFromRangeEnd as st, DOCX_CONFORMANCE_CLASSES as t, AbstractNumbering as tn, InlineSdt as tt, Relationship as u, EmphasisMark as un, MoveToRangeEnd as ut, ThemeFont as v, TabStopAlignment as vn, ParagraphMarkChange as vt, BreakContent as w, TableRowFormatting as wn, RunPropertyChange as wt, BlockSdt as x, TableFormatting as xn, PropertyChangeInfo as xt, ThemeFontScheme as y, TableBorders as yn, ParagraphPropertyChange as yt, FieldType as z, SymbolContent as zt };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ct as RunContent, Gt as TableRow, Ht as TableCell, M as DocumentBody, Ot as SectionProperties, St as Run, Vt as Table, Yt as TextContent, _t as ParagraphContent, a as DocxPackage, b as BlockContent, gt as Paragraph, i as DocxConformanceClass, n as Document, p as Style, t as DOCX_CONFORMANCE_CLASSES, w as BreakContent } from "./document-B3E-xw_J.js";
|
|
2
2
|
|
|
3
3
|
//#region src/legal-source/types.d.ts
|
|
4
4
|
type LegalDocumentKind = "agreement" | "letter" | "memo" | "checklist" | "pleading" | "other";
|
|
@@ -140,4 +140,4 @@ declare const validateDocxPackage: (buffer: ArrayBuffer | Uint8Array) => Promise
|
|
|
140
140
|
declare const validateDocumentModel: (document: Document) => ValidateDocumentModelResult;
|
|
141
141
|
declare const assertValidDocumentModel: (document: Document) => void;
|
|
142
142
|
//#endregion
|
|
143
|
-
export { type Autofix, type BlockContent, type BreakContent, type CompiledLegalDocument, type Document, type DocumentBody, type DocxPackage, type LegalDraft, type LegalDraftBlock, type LegalDraftDiagnostic, type LegalSourceCompileOptions, type LegalSourceCompileResult, type LegalSourceDocxCompileResult, type LegalSourceParseResult, type Paragraph, type ParagraphContent, type Run, type RunContent, type SectionProperties, type Style, type Table, type TableCell, type TableRow, type TextContent, type ValidateDocumentModelIssue, type ValidateDocumentModelResult, type ValidateDocxPackageResult, assertValidDocumentModel, compileLegalSourceToDocument, compileLegalSourceToDocx, parseLegalSource, serializeDocumentToDocx, validateDocumentModel, validateDocxPackage, validateLegalDraft };
|
|
143
|
+
export { type Autofix, type BlockContent, type BreakContent, type CompiledLegalDocument, DOCX_CONFORMANCE_CLASSES, type Document, type DocumentBody, type DocxConformanceClass, type DocxPackage, type LegalDraft, type LegalDraftBlock, type LegalDraftDiagnostic, type LegalSourceCompileOptions, type LegalSourceCompileResult, type LegalSourceDocxCompileResult, type LegalSourceParseResult, type Paragraph, type ParagraphContent, type Run, type RunContent, type SectionProperties, type Style, type Table, type TableCell, type TableRow, type TextContent, type ValidateDocumentModelIssue, type ValidateDocumentModelResult, type ValidateDocxPackageResult, assertValidDocumentModel, compileLegalSourceToDocument, compileLegalSourceToDocx, parseLegalSource, serializeDocumentToDocx, validateDocumentModel, validateDocxPackage, validateLegalDraft };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DOCX_CONFORMANCE_CLASSES } from "./model/document.js";
|
|
1
2
|
import JSZip from "jszip";
|
|
2
3
|
import { panic } from "better-result";
|
|
3
4
|
//#region src/serialize/xml.ts
|
|
@@ -58,7 +59,8 @@ const FOOTER_LABELS = {
|
|
|
58
59
|
};
|
|
59
60
|
const resolveFooterLabels = (language) => {
|
|
60
61
|
if (!language) return FOOTER_LABEL_FALLBACK;
|
|
61
|
-
|
|
62
|
+
const primary = language.toLowerCase().split(/[-_]/u)[0] ?? "";
|
|
63
|
+
return FOOTER_LABELS[primary] ?? FOOTER_LABEL_FALLBACK;
|
|
62
64
|
};
|
|
63
65
|
const buildFooterXml = (language) => {
|
|
64
66
|
const { page, of } = resolveFooterLabels(language);
|
|
@@ -387,7 +389,7 @@ const validateDocumentModel = (document) => {
|
|
|
387
389
|
const assertValidDocumentModel = (document) => {
|
|
388
390
|
const result = validateDocumentModel(document);
|
|
389
391
|
if (result.valid) return;
|
|
390
|
-
panic(`Invalid DOCX document model:\n${result.issues.
|
|
392
|
+
panic(`Invalid DOCX document model:\n${result.issues.flatMap((issue) => issue.severity === "error" ? [`${issue.path}: ${issue.message}`] : []).join("\n")}`);
|
|
391
393
|
};
|
|
392
394
|
const createValidationContext = (document) => ({
|
|
393
395
|
issues: [],
|
|
@@ -1093,7 +1095,10 @@ const pendingToBlock = (pending, diagnostics, fixes) => {
|
|
|
1093
1095
|
case "list": return {
|
|
1094
1096
|
type: "list",
|
|
1095
1097
|
ordered: pending.ordered,
|
|
1096
|
-
items: pending.lines.
|
|
1098
|
+
items: pending.lines.flatMap((line) => {
|
|
1099
|
+
const stripped = stripListMarker(line, pending.ordered);
|
|
1100
|
+
return stripped ? [stripped] : [];
|
|
1101
|
+
})
|
|
1097
1102
|
};
|
|
1098
1103
|
case "table": return parseTableBlock(pending, diagnostics, fixes);
|
|
1099
1104
|
case "schedule": return {
|
|
@@ -1109,7 +1114,13 @@ const pendingToBlock = (pending, diagnostics, fixes) => {
|
|
|
1109
1114
|
}
|
|
1110
1115
|
};
|
|
1111
1116
|
const parseTableBlock = (pending, diagnostics, fixes) => {
|
|
1112
|
-
const rows = pending.lines.
|
|
1117
|
+
const rows = pending.lines.flatMap((rawLine) => {
|
|
1118
|
+
const line = rawLine.trim();
|
|
1119
|
+
return line.startsWith("|") ? [line] : [];
|
|
1120
|
+
}).flatMap((line) => {
|
|
1121
|
+
const row = parsePipeRow(line);
|
|
1122
|
+
return row.length > 0 ? [row] : [];
|
|
1123
|
+
});
|
|
1113
1124
|
const header = rows.at(0) ?? [];
|
|
1114
1125
|
const normalizedRows = rows.slice(1).filter((row) => !isMarkdownDividerRow(row)).map((row) => {
|
|
1115
1126
|
if (row.length === header.length) return row;
|
|
@@ -1254,7 +1265,8 @@ const parseSignatureParties = (lines, heading) => {
|
|
|
1254
1265
|
startParty(trimmed);
|
|
1255
1266
|
continue;
|
|
1256
1267
|
}
|
|
1257
|
-
const
|
|
1268
|
+
const rawKey = trimmed.slice(0, separatorIndex).toLowerCase();
|
|
1269
|
+
const canonicalKey = SIGNATURE_KEY_ALIASES[rawKey];
|
|
1258
1270
|
if (!canonicalKey || !SIGNATURE_FIELD_KEYS.has(canonicalKey)) {
|
|
1259
1271
|
startParty(trimmed);
|
|
1260
1272
|
continue;
|
|
@@ -1924,4 +1936,4 @@ const compileLegalSourceToDocx = async (source, options = {}) => {
|
|
|
1924
1936
|
};
|
|
1925
1937
|
};
|
|
1926
1938
|
//#endregion
|
|
1927
|
-
export { assertValidDocumentModel, compileLegalSourceToDocument, compileLegalSourceToDocx, parseLegalSource, serializeDocumentToDocx, validateDocumentModel, validateDocxPackage, validateLegalDraft };
|
|
1939
|
+
export { DOCX_CONFORMANCE_CLASSES, assertValidDocumentModel, compileLegalSourceToDocument, compileLegalSourceToDocx, parseLegalSource, serializeDocumentToDocx, validateDocumentModel, validateDocxPackage, validateLegalDraft };
|
package/dist/model/document.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { type AbstractNumbering, type BlockContent, type BlockSdt, type BookmarkEnd, type BookmarkStart, type BorderSpec, type BreakContent, type CellMargins, type ColorValue, type Column, type Comment, type CommentRangeEnd, type CommentRangeStart, type CommentReference, type ComplexField, type ConditionalFormatStyle, type Deletion, type DocDefaults, Document, type DocumentBody, DocumentSettings, DocxPackage, type DrawingContent, type EmphasisMark, type Endnote, type EndnotePosition, type EndnoteProperties, type Field, type FieldCharContent, type FieldType, type FloatingTableProperties, type FontInfo, type FontTable, type FooterReference, type Footnote, type FootnotePosition, type FootnoteProperties, type HeaderFooter, type HeaderFooterType, type HeaderReference, type Hyperlink, type Image, type ImageCrop, type ImagePadding, type ImagePosition, type ImageSize, type ImageTransform, type ImageWrap, type InlineSdt, type Insertion, type InstrTextContent, type KnownBorderStyle, type LevelSuffix, type LineNumberRestart, type LineSpacingRule, type ListLevel, type ListRendering, type MathEquation, type MediaFile, type MoveFrom, type MoveFromRangeEnd, type MoveFromRangeStart, type MoveTo, type MoveToRangeEnd, type MoveToRangeStart, type NoBreakHyphenContent, type NoteNumberRestart, type NoteReferenceContent, type NumberFormat, type NumberingDefinitions, type NumberingInstance, type PageOrientation, type Paragraph, type ParagraphAlignment, type ParagraphContent, type ParagraphFormatting, type ParagraphMarkChange, type ParagraphPropertyChange, type PictureWatermark, type PropertyChangeInfo, type Relationship, type RelationshipMap, type RelationshipType, type Run, type RunContent, type RunPropertyChange, type SdtProperties, type SdtType, type Section, type SectionProperties, type SectionPropertyChange, type SectionStart, type ShadingProperties, type Shape, type ShapeContent, type ShapeFill, type ShapeOutline, type ShapeTextBody, type ShapeType, type SimpleField, type SoftHyphenContent, type SpacingExplicit, type Style, type StyleDefinitions, type StyleType, type SymbolContent, type TabContent, type TabLeader, type TabStop, type TabStopAlignment, type Table, type TableBorders, type TableCell, type TableCellFormatting, type TableCellPropertyChange, type TableFormatting, type TableLook, type TableMeasurement, type TablePropertyChange, type TableRow, type TableRowFormatting, type TableRowPropertyChange, type TableStructuralChangeInfo, type TableWidthType, type TextBox, type TextContent, type TextEffect, type TextFormatting, type TextWatermark, type Theme, type ThemeColorScheme, type ThemeColorSlot, type ThemeFont, type ThemeFontScheme, type TrackedChangeInfo, type TrackedRunChange, type UnderlineStyle, type VerticalAlign, type Watermark };
|
|
1
|
+
import { $ as ImageTransform, $t as VerticalAlign, A as ComplexField, An as ColorValue, At as SectionStart, B as FooterReference, Bt as TabContent, C as BookmarkStart, Cn as TableMeasurement, Ct as RunContent, D as CommentRangeEnd, Dn as TextFormatting, Dt as Section, E as Comment, En as TextEffect, Et as SdtType, F as EndnotePosition, Ft as ShapeTextBody, G as HeaderFooterType, Gt as TableRow, H as FootnotePosition, Ht as TableCell, I as EndnoteProperties, It as ShapeType, J as Image, Jt as TextBox, K as HeaderReference, Kt as TableRowPropertyChange, L as Field, Lt as SimpleField, M as DocumentBody, Mn as ShadingProperties, Mt as ShapeContent, N as DrawingContent, Nn as ThemeColorSlot, Nt as ShapeFill, O as CommentRangeStart, On as UnderlineStyle, Ot as SectionProperties, P as Endnote, Pt as ShapeOutline, Q as ImageSize, Qt as TrackedRunChange, R as FieldCharContent, Rt as SoftHyphenContent, S as BookmarkEnd, Sn as TableLook, St as Run, T as Column, Tn as TableWidthType, Tt as SdtProperties, U as FootnoteProperties, Ut as TableCellPropertyChange, V as Footnote, Vt as Table, W as HeaderFooter, Wt as TablePropertyChange, X as ImagePadding, Xt as TextWatermark, Y as ImageCrop, Yt as TextContent, Z as ImagePosition, Zt as TrackedChangeInfo, _ as ThemeColorScheme, _n as TabStop, _t as ParagraphContent, a as DocxPackage, an as NumberFormat, at as MathEquation, b as BlockContent, bn as TableCellFormatting, bt as PictureWatermark, c as FontTable, cn as CellMargins, ct as MoveFromRangeStart, d as RelationshipMap, dn as FloatingTableProperties, dt as MoveToRangeStart, en as Watermark, et as ImageWrap, f as RelationshipType, fn as LineSpacingRule, ft as NoBreakHyphenContent, g as Theme, gn as TabLeader, gt as Paragraph, h as StyleType, hn as SpacingExplicit, ht as PageOrientation, i as DocxConformanceClass, in as ListRendering, it as LineNumberRestart, j as Deletion, jn as KnownBorderStyle, jt as Shape, k as CommentReference, kn as BorderSpec, kt as SectionPropertyChange, l as MediaFile, ln as ConditionalFormatStyle, lt as MoveTo, m as StyleDefinitions, mn as ParagraphFormatting, mt as NoteReferenceContent, n as Document, nn as LevelSuffix, nt as Insertion, o as DocDefaults, on as NumberingDefinitions, ot as MoveFrom, p as Style, pn as ParagraphAlignment, pt as NoteNumberRestart, q as Hyperlink, qt as TableStructuralChangeInfo, r as DocumentSettings, rn as ListLevel, rt as InstrTextContent, s as FontInfo, sn as NumberingInstance, st as MoveFromRangeEnd, t as DOCX_CONFORMANCE_CLASSES, tn as AbstractNumbering, tt as InlineSdt, u as Relationship, un as EmphasisMark, ut as MoveToRangeEnd, v as ThemeFont, vn as TabStopAlignment, vt as ParagraphMarkChange, w as BreakContent, wn as TableRowFormatting, wt as RunPropertyChange, x as BlockSdt, xn as TableFormatting, xt as PropertyChangeInfo, y as ThemeFontScheme, yn as TableBorders, yt as ParagraphPropertyChange, z as FieldType, zt as SymbolContent } from "../document-B3E-xw_J.js";
|
|
2
|
+
export { type AbstractNumbering, type BlockContent, type BlockSdt, type BookmarkEnd, type BookmarkStart, type BorderSpec, type BreakContent, type CellMargins, type ColorValue, type Column, type Comment, type CommentRangeEnd, type CommentRangeStart, type CommentReference, type ComplexField, type ConditionalFormatStyle, DOCX_CONFORMANCE_CLASSES, type Deletion, type DocDefaults, Document, type DocumentBody, DocumentSettings, DocxConformanceClass, DocxPackage, type DrawingContent, type EmphasisMark, type Endnote, type EndnotePosition, type EndnoteProperties, type Field, type FieldCharContent, type FieldType, type FloatingTableProperties, type FontInfo, type FontTable, type FooterReference, type Footnote, type FootnotePosition, type FootnoteProperties, type HeaderFooter, type HeaderFooterType, type HeaderReference, type Hyperlink, type Image, type ImageCrop, type ImagePadding, type ImagePosition, type ImageSize, type ImageTransform, type ImageWrap, type InlineSdt, type Insertion, type InstrTextContent, type KnownBorderStyle, type LevelSuffix, type LineNumberRestart, type LineSpacingRule, type ListLevel, type ListRendering, type MathEquation, type MediaFile, type MoveFrom, type MoveFromRangeEnd, type MoveFromRangeStart, type MoveTo, type MoveToRangeEnd, type MoveToRangeStart, type NoBreakHyphenContent, type NoteNumberRestart, type NoteReferenceContent, type NumberFormat, type NumberingDefinitions, type NumberingInstance, type PageOrientation, type Paragraph, type ParagraphAlignment, type ParagraphContent, type ParagraphFormatting, type ParagraphMarkChange, type ParagraphPropertyChange, type PictureWatermark, type PropertyChangeInfo, type Relationship, type RelationshipMap, type RelationshipType, type Run, type RunContent, type RunPropertyChange, type SdtProperties, type SdtType, type Section, type SectionProperties, type SectionPropertyChange, type SectionStart, type ShadingProperties, type Shape, type ShapeContent, type ShapeFill, type ShapeOutline, type ShapeTextBody, type ShapeType, type SimpleField, type SoftHyphenContent, type SpacingExplicit, type Style, type StyleDefinitions, type StyleType, type SymbolContent, type TabContent, type TabLeader, type TabStop, type TabStopAlignment, type Table, type TableBorders, type TableCell, type TableCellFormatting, type TableCellPropertyChange, type TableFormatting, type TableLook, type TableMeasurement, type TablePropertyChange, type TableRow, type TableRowFormatting, type TableRowPropertyChange, type TableStructuralChangeInfo, type TableWidthType, type TextBox, type TextContent, type TextEffect, type TextFormatting, type TextWatermark, type Theme, type ThemeColorScheme, type ThemeColorSlot, type ThemeFont, type ThemeFontScheme, type TrackedChangeInfo, type TrackedRunChange, type UnderlineStyle, type VerticalAlign, type Watermark };
|
package/dist/model/document.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/docx-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Typed OOXML/DOCX document model with parsing, validation, and serialization, plus a legal-source compiler that produces DOCX packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"document-model",
|
|
@@ -12,19 +12,22 @@
|
|
|
12
12
|
"validate",
|
|
13
13
|
"word"
|
|
14
14
|
],
|
|
15
|
-
"homepage": "https://github.com/stella/
|
|
15
|
+
"homepage": "https://github.com/stella/folio/tree/main/packages/docx-core",
|
|
16
16
|
"bugs": {
|
|
17
|
-
"url": "https://github.com/stella/
|
|
17
|
+
"url": "https://github.com/stella/folio/issues"
|
|
18
18
|
},
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "https://github.com/stella/
|
|
22
|
+
"url": "https://github.com/stella/folio.git",
|
|
23
23
|
"directory": "packages/docx-core"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"dist",
|
|
27
|
-
"
|
|
27
|
+
"skills",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE",
|
|
30
|
+
"NOTICE.md"
|
|
28
31
|
],
|
|
29
32
|
"type": "module",
|
|
30
33
|
"sideEffects": false,
|
|
@@ -43,12 +46,10 @@
|
|
|
43
46
|
},
|
|
44
47
|
"scripts": {
|
|
45
48
|
"clean": "git clean -xdf dist .cache .turbo node_modules",
|
|
46
|
-
"build": "tsdown",
|
|
49
|
+
"build": "rm -rf dist && tsdown",
|
|
47
50
|
"pack:dry-run": "bun pm pack --dry-run",
|
|
48
51
|
"test": "bun test src",
|
|
49
|
-
"typecheck": "
|
|
50
|
-
"lint": "cd ../.. && bun --bun oxlint -c oxlint.config.ts --report-unused-disable-directives-severity=error --deny-warnings --type-aware packages/docx-core",
|
|
51
|
-
"lint:fix": "cd ../.. && bun --bun oxlint -c oxlint.config.ts --type-aware --fix packages/docx-core",
|
|
52
|
+
"typecheck": "bun ../../scripts/tsc-native.ts --noEmit -p tsconfig.build.json",
|
|
52
53
|
"format": "oxfmt .",
|
|
53
54
|
"prepack": "bun run build"
|
|
54
55
|
},
|
|
@@ -57,7 +58,6 @@
|
|
|
57
58
|
"jszip": "3.10.1"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"@stll/typescript-config": "0.0.0",
|
|
61
61
|
"@types/bun": "1.3.14",
|
|
62
62
|
"tsdown": "0.22.3"
|
|
63
63
|
},
|