@file-viewer/docx 0.3.39 → 0.3.42

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.
@@ -0,0 +1,4 @@
1
+ export declare function fontScriptRuns(text: string, previousEastAsian?: boolean): Array<{
2
+ text: string;
3
+ eastAsian: boolean;
4
+ }>;
@@ -110,6 +110,9 @@ export declare class HtmlRenderer {
110
110
  options: Options;
111
111
  /** styleId 到样式对象的索引,渲染段落/run/表格时用于快速合并继承样式。 */
112
112
  styleMap: Record<string, IDomStyle>;
113
+ private defaultParagraphStyle;
114
+ private defaultCharacterStyle;
115
+ private defaultRunStyle;
113
116
  currentPart: Part;
114
117
  currentSectionProps: SectionProperties;
115
118
  currentPageNumber: number;
@@ -140,6 +143,7 @@ export declare class HtmlRenderer {
140
143
  currentTabs: any[];
141
144
  anchorLayouts: Map<string, AnchorPosition>;
142
145
  currentParagraph: WmlParagraph;
146
+ private currentRunFont;
143
147
  currentParagraphTabIndex: number;
144
148
  currentParagraphTabCount: number;
145
149
  commentHighlight: any;
@@ -160,6 +164,7 @@ export declare class HtmlRenderer {
160
164
  tasks: Promise<any>[];
161
165
  postRenderTasks: any[];
162
166
  private compatibleTextBoxSpacing;
167
+ private paragraphSpacingStates;
163
168
  h: typeof h;
164
169
  /**
165
170
  * 暗色模式下,任意字面量颜色(非 --docx-*-color 主题/auto 变量)都会被包装成
@@ -178,6 +183,7 @@ export declare class HtmlRenderer {
178
183
  eastAsia: string;
179
184
  bidi: string;
180
185
  };
186
+ addThemeFontFallbackVariables(variables: Record<string, string>, size: "major" | "minor", font: DmlFormInfo): void;
181
187
  addThemeScriptFontVariables(variables: Record<string, string>, size: "major" | "minor", font: DmlFormInfo): void;
182
188
  themeFontFamily(font: DmlFormInfo, slot: "latin" | "eastAsia" | "complexScript", language: string, scriptOverride?: string): string;
183
189
  renderFontTable(fontsPart: FontTablePart): Promise<any[]>;
@@ -230,10 +236,31 @@ export declare class HtmlRenderer {
230
236
  }[];
231
237
  styleValuesForTarget(style: IDomStyle, target: string): Record<string, string>;
232
238
  styleValue(style: IDomStyle, target: string, name: string): string;
239
+ /** Resolve these per-property values even when basedOn styles occur later in XML. */
240
+ styleValueLevels(style: IDomStyle, target: string): Record<string, string>[];
241
+ private effectiveParagraphNumbering;
242
+ applyParagraphAutoSpacing(elem: WmlParagraph, style: IDomStyle, result: HTMLElement): void;
243
+ private applyFlowParagraphSpacing;
233
244
  effectiveParagraphCssValue(elem: WmlParagraph, style: IDomStyle, name: string): string;
234
245
  textBoxAutospace(elem: WmlParagraph, style: IDomStyle, supports?: (value: string) => boolean): string;
235
246
  applyTextBoxFontInheritance(elem: OpenXmlElement, style: IDomStyle, result: HTMLElement): void;
247
+ /** 字体槽独立继承;不改解析树、文字节点或 display target 的对应关系。 */
248
+ resolveRunFontSlots(elem: OpenXmlElement, style: IDomStyle): {
249
+ fontFamily: string;
250
+ eastAsianFontFamily: string;
251
+ splitEastAsia: boolean;
252
+ complexFontSize: string;
253
+ previousEastAsian: boolean;
254
+ };
255
+ applyRunFontSlots(elem: OpenXmlElement, style: IDomStyle, result: HTMLElement, font?: {
256
+ fontFamily: string;
257
+ eastAsianFontFamily: string;
258
+ splitEastAsia: boolean;
259
+ complexFontSize: string;
260
+ previousEastAsian: boolean;
261
+ }): void;
236
262
  isInsideTableCell(elem: OpenXmlElement): boolean;
263
+ paragraphSnapToGrid(elem: WmlParagraph, style: IDomStyle): string;
237
264
  paragraphUsesDocumentGrid(elem: WmlParagraph, style: IDomStyle): boolean;
238
265
  setCssStyle(element: HTMLElement, name: string, value: string): void;
239
266
  applyDocumentGridMinimumHeight(elem: WmlParagraph, style: IDomStyle, result: HTMLElement, linePitch: string): void;
@@ -295,6 +322,9 @@ export declare class HtmlRenderer {
295
322
  * page. Ordinary paragraphs and pictures fitting a fresh page are unchanged. */
296
323
  fitOversizedInlinePicture(paragraph: HTMLElement, page: HTMLElement): boolean;
297
324
  splitTableBlock(table: HTMLTableElement, page: HTMLElement, nextArticle: HTMLElement): boolean;
325
+ canRetainTablePrefix(block: HTMLElement, page: HTMLElement): boolean;
326
+ /** Structural and measured row-group safety, independent of float policy. */
327
+ private fitsTableRowPrefix;
298
328
  cloneBlockShell<T extends HTMLElement>(element: T): T;
299
329
  tableContentRows(table: HTMLTableElement): HTMLTableRowElement[];
300
330
  firstMovedTableRow(table: HTMLTableElement): HTMLTableRowElement;
@@ -349,6 +379,7 @@ export declare class HtmlRenderer {
349
379
  ownsLayoutElement(element: Element): boolean;
350
380
  textBoxGridLineHeight(natural: number, pitch: number): number | null;
351
381
  refreshTextBoxLineGrid(root: HTMLElement): void;
382
+ refreshParagraphLineGrid(root: HTMLElement): void;
352
383
  prepareLayout(root: HTMLElement, generation?: LayoutGeneration): Promise<void>;
353
384
  disposeLayout(): void;
354
385
  renderHyperlink(elem: WmlHyperlink): HTMLAnchorElement;
@@ -19,6 +19,8 @@ export interface WmlSettings {
19
19
  evenAndOddHeaders: boolean;
20
20
  /** True when the compatibility setting allows document grid line pitch inside table cells. */
21
21
  adjustLineHeightInTable: boolean;
22
+ /** Use the compatibility-defined 5pt before / 10pt after automatic paragraph spacing. */
23
+ doNotUseHTMLParagraphAutoSpacing?: boolean;
22
24
  /** True when w:splitPgBreakAndParaMark moves a trailing page-break paragraph mark forward. */
23
25
  splitPageBreakAndParagraphMark: boolean;
24
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@file-viewer/docx",
3
- "version": "0.3.39",
3
+ "version": "0.3.42",
4
4
  "description": "Pure HTML DOCX renderer fork for browser-based Word previews.",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -23,6 +23,10 @@
23
23
  "type": "git",
24
24
  "url": "git+https://github.com/flyfish-dev/docxjs.git"
25
25
  },
26
+ "homepage": "https://github.com/flyfish-dev/file-viewer#readme",
27
+ "bugs": {
28
+ "url": "https://github.com/flyfish-dev/file-viewer/issues"
29
+ },
26
30
  "dependencies": {
27
31
  "jszip": ">=3.10.2",
28
32
  "@xmldom/xmldom": "^0.9.12"
@@ -31,15 +35,13 @@
31
35
  "rollup": "^4.9.1",
32
36
  "@types/node": "24.19.1",
33
37
  "@rollup/plugin-terser": "^1.0.0",
34
- "@rollup/plugin-typescript": "^12.1.4",
35
38
  "terser": "^5.43.1",
36
39
  "jasmine-core": "^5.1.0",
37
40
  "playwright": "1.61.1",
38
41
  "tslib": "^2.4.0",
39
42
  "typescript": "^5.0.3",
40
- "@rollup/plugin-node-resolve": "^16.0.1",
41
- "@rollup/plugin-commonjs": "^28.0.6",
42
- "jsdom": "^27.4.0"
43
+ "jsdom": "^27.4.0",
44
+ "esbuild": "0.28.2"
43
45
  },
44
46
  "overrides": {
45
47
  "brace-expansion": "1.1.21",
@@ -50,7 +52,8 @@
50
52
  "build-prod": "npm run build",
51
53
  "typecheck": "tsc --noEmit --pretty false",
52
54
  "watch": "rollup --config rollup.config.mjs --watch",
53
- "verify": "npm run typecheck && npm run build && npm run test:regression && npm run test:package && npm run test:worker",
55
+ "verify": "npm run test:metadata && npm run typecheck && npm run build && npm run test:regression && npm run test:package && npm run test:worker",
56
+ "test:metadata": "node --test scripts/package-metadata.test.cjs",
54
57
  "test:regression": "node scripts/run-regressions.cjs",
55
58
  "e2e": "node scripts/run-browser-specs.cjs all",
56
59
  "e2e:security": "node scripts/run-browser-specs.cjs security",