oasis-editor 0.0.100 → 0.0.102
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/{OasisEditorApp-CRjXmvyC.js → OasisEditorApp-DDtlPHus.js} +315 -46
- package/dist/assets/{importDocxWorker-BulqJDJj.js → importDocxWorker-GkXQ7kFj.js} +1 -1
- package/dist/core/editorState.d.ts +1 -1
- package/dist/core/model/index.d.ts +2 -2
- package/dist/core/model/types/document.d.ts +27 -0
- package/dist/core/model/types/nodes.d.ts +19 -0
- package/dist/export/docx/docxPackageXml.d.ts +9 -3
- package/dist/export/docx/text/blocksXml.d.ts +6 -0
- package/dist/export/pdf/OasisPdfWriter.d.ts +8 -1
- package/dist/export/pdf/writer/PdfContentStream.d.ts +19 -2
- package/dist/export/pdf/writer/PdfDocumentSerializer.d.ts +2 -1
- package/dist/export/pdf/writer/PdfShadingTable.d.ts +22 -0
- package/dist/export/pdf/writer/pdfPrimitives.d.ts +1 -0
- package/dist/export/pdf/writer/pdfTypes.d.ts +24 -0
- package/dist/import/docx/fontTable.d.ts +13 -0
- package/dist/import/docx/nestedBlocks.d.ts +14 -0
- package/dist/{index-BuxYvaSC.js → index-CNtAFUVS.js} +168 -34
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +4 -4
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EditorAsset, EditorBlockNode, EditorDocument, EditorFootnote, EditorPageSettings, EditorParagraphNode, EditorSection, EditorState, EditorTableCellNode, EditorTableNode, EditorTableRowNode, EditorTextRun, EditorTextStyle, EditorTextBoxData, EditorImageRunData, EditorNamedStyle } from './model.js';
|
|
2
2
|
|
|
3
|
-
export type EditorNodeKind = "document" | "paragraph" | "run" | "table" | "table-row" | "table-cell" | "footnote" | "bookmark" | "comment";
|
|
3
|
+
export type EditorNodeKind = "document" | "paragraph" | "run" | "table" | "table-row" | "table-cell" | "footnote" | "bookmark" | "comment" | "sdt";
|
|
4
4
|
/**
|
|
5
5
|
* Single authority for editor node IDs. Stateless and globally unique, so two
|
|
6
6
|
* editors mounted on the same page never share a sequence. The `kind` prefix is
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export type { EditorUnderlineStyle, EditorLigatures, EditorNumberSpacing, EditorNumberForm, EditorTextLanguage, EditorBorderStyle, EditorEmphasisMark, EditorTabStop, EditorParagraphListStyle, EditorImageCrop, EditorImageFillMode, EditorImageFloatingPosition, EditorImageFloatingLayout, EditorImageRunData, EditorWrapPolygonPoint, EditorFieldData, EditorFieldChar, EditorFootnoteReferenceData, EditorEndnoteReferenceData, EditorRevision, EditorRevisionMetadata, EditorStructuralRevision, EditorPropertyRevision, EditorAsset, EditorFootnoteNumberFormat, EditorFootnoteRestart, EditorDocxWidthValue, EditorTableLayout, EditorTableRowHeightRule, EditorGradientStop, EditorTextFill, EditorTextOutline, EditorTextShadow, EditorGlow, EditorReflection, } from './types/primitives.js';
|
|
10
10
|
export type { EditorTextStyle, EditorParagraphStyle, EditorTableStyle, EditorTableFloatingLayout, EditorTableConditionalFormat, EditorConditionalRowStyle, EditorTableConditionalType, EditorTableConditionalFlags, EditorTableCellStyle, EditorNamedStyle, } from './types/styles.js';
|
|
11
|
-
export type { EditorRunBase, EditorTextRun, EditorTextBoxShape, EditorTextBoxBody, EditorTextBoxData, EditorDropCap, EditorParagraphNode, EditorTableCellNode, EditorTableRowStyle, EditorTableRowNode, EditorTableNode, EditorBlockNode, } from './types/nodes.js';
|
|
11
|
+
export type { EditorRunBase, EditorTextRun, EditorTextBoxShape, EditorTextBoxBody, EditorTextBoxData, EditorDropCap, EditorSdtBlockWrapper, EditorParagraphNode, EditorTableCellNode, EditorTableRowStyle, EditorTableRowNode, EditorTableNode, EditorBlockNode, } from './types/nodes.js';
|
|
12
12
|
export type { RunKind, RunOfKind, RunVisitor } from './runKind.js';
|
|
13
13
|
export { getRunKind, isInlineObjectRun, visitRun, getRunImage, getRunTextBox, getRunField, getRunFieldChar, getRunFieldInstruction, getRunFootnoteReference, getRunEndnoteReference, getRunSym, } from './runKind.js';
|
|
14
14
|
export type { EditorFootnote } from './types/documentFootnotes.js';
|
|
15
15
|
export type { EditorEndnote } from './types/documentEndnotes.js';
|
|
16
16
|
export type { EditorBookmark, EditorBookmarkAnchor, EditorBookmarks, } from './types/documentBookmarks.js';
|
|
17
17
|
export type { EditorComment, EditorCommentAnchor, EditorComments, } from './types/documentComments.js';
|
|
18
|
-
export type { EditorPageMargins, EditorPageSettings, EditorColumnsSettings, EditorSection, EditorFootnoteSettings, EditorFootnotes, EditorEndnoteSettings, EditorEndnotes, EditorDocument, } from './types/document.js';
|
|
18
|
+
export type { EditorPageMargins, EditorPageSettings, EditorColumnsSettings, EditorSection, EditorFontInfo, EditorFootnoteSettings, EditorFootnotes, EditorEndnoteSettings, EditorEndnotes, EditorDocument, } from './types/document.js';
|
|
19
19
|
export type { EditorPosition, EditorSelection, EditorEditingZone, } from './types/selection.js';
|
|
20
20
|
export type { EditorCaretSlot, EditorLayoutFragmentChar, EditorLayoutFragment, EditorLayoutLine, EditorLayoutParagraph, EditorLayoutBlock, TableCellBlockPosition, EditorLayoutPage, EditorLayoutDocument, } from './types/layout.js';
|
|
21
21
|
export type { EditorState } from './editorState.js';
|
|
@@ -53,6 +53,28 @@ export interface EditorSection {
|
|
|
53
53
|
evenPageFooter?: EditorBlockNode[];
|
|
54
54
|
breakType?: "nextPage" | "continuous";
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* One `w:font` entry from `word/fontTable.xml`: the document's declaration of a
|
|
58
|
+
* font it uses, with substitution metadata. Preserved for round-trip (and as the
|
|
59
|
+
* basis for future font-substitution decisions). Embedded font references
|
|
60
|
+
* (`w:embedRegular`/etc.) are intentionally not modeled.
|
|
61
|
+
*/
|
|
62
|
+
export interface EditorFontInfo {
|
|
63
|
+
/** `w:font/@w:name`: the font's primary name (e.g. "Calibri"). */
|
|
64
|
+
name: string;
|
|
65
|
+
/** `w:altName/@w:val`: fallback font name when `name` is unavailable. */
|
|
66
|
+
altName?: string;
|
|
67
|
+
/** `w:family/@w:val`: roman | swiss | modern | script | decorative | auto. */
|
|
68
|
+
family?: string;
|
|
69
|
+
/** `w:pitch/@w:val`: fixed | variable | default. */
|
|
70
|
+
pitch?: string;
|
|
71
|
+
/** `w:charset/@w:val`: character set (hex). */
|
|
72
|
+
charset?: string;
|
|
73
|
+
/** `w:panose1/@w:val`: PANOSE classification (10-byte hex). */
|
|
74
|
+
panose1?: string;
|
|
75
|
+
/** `w:sig` attributes (Unicode/codepage signature bits) preserved verbatim. */
|
|
76
|
+
sig?: Record<string, string>;
|
|
77
|
+
}
|
|
56
78
|
export interface EditorFootnoteSettings {
|
|
57
79
|
numberFormat?: EditorFootnoteNumberFormat;
|
|
58
80
|
restart?: EditorFootnoteRestart;
|
|
@@ -116,6 +138,11 @@ export interface EditorDocument {
|
|
|
116
138
|
* body shown in a hover/click popup.
|
|
117
139
|
*/
|
|
118
140
|
comments?: EditorComments;
|
|
141
|
+
/**
|
|
142
|
+
* `word/fontTable.xml` entries: the fonts the document declares, with
|
|
143
|
+
* substitution metadata. Preserved on import and re-emitted on export.
|
|
144
|
+
*/
|
|
145
|
+
fontTable?: EditorFontInfo[];
|
|
119
146
|
metadata?: {
|
|
120
147
|
title?: string;
|
|
121
148
|
[key: string]: unknown;
|
|
@@ -144,6 +144,21 @@ export interface EditorDropCap {
|
|
|
144
144
|
/** Cap run style: fontSize (`w:sz`), font, color, baselineShift (`w:position`). */
|
|
145
145
|
style?: EditorTextStyle;
|
|
146
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* A block-level structured document tag (`w:sdt`, a content control) enclosing
|
|
149
|
+
* one or more blocks, preserved for round-trip. Its content is unwrapped into the
|
|
150
|
+
* normal block flow (so it still renders and edits); this carries the wrapper's
|
|
151
|
+
* properties verbatim so export can re-wrap. `groupId` ties together the
|
|
152
|
+
* consecutive blocks that came from the same `w:sdt`; the array on a block lists
|
|
153
|
+
* its enclosing wrappers outermost-first (nested content controls).
|
|
154
|
+
*/
|
|
155
|
+
export interface EditorSdtBlockWrapper {
|
|
156
|
+
groupId: string;
|
|
157
|
+
/** Raw `<w:sdtPr>…</w:sdtPr>` XML, or empty when the tag had no properties. */
|
|
158
|
+
sdtPrXml: string;
|
|
159
|
+
/** Raw `<w:sdtEndPr>…</w:sdtEndPr>` XML, when present. */
|
|
160
|
+
sdtEndPrXml?: string;
|
|
161
|
+
}
|
|
147
162
|
export interface EditorParagraphNode {
|
|
148
163
|
id: string;
|
|
149
164
|
type: "paragraph";
|
|
@@ -152,6 +167,8 @@ export interface EditorParagraphNode {
|
|
|
152
167
|
list?: EditorParagraphListStyle;
|
|
153
168
|
/** Drop cap that body text in this paragraph wraps around, when present. */
|
|
154
169
|
dropCap?: EditorDropCap;
|
|
170
|
+
/** Enclosing block-level `w:sdt` content controls, preserved for round-trip. */
|
|
171
|
+
sdtWrappers?: EditorSdtBlockWrapper[];
|
|
155
172
|
}
|
|
156
173
|
export interface EditorTableCellNode {
|
|
157
174
|
id: string;
|
|
@@ -220,5 +237,7 @@ export interface EditorTableNode {
|
|
|
220
237
|
style?: EditorTableStyle;
|
|
221
238
|
/** Preservation-only `w:tblGridChange` XML. */
|
|
222
239
|
gridRevision?: EditorPropertyRevision<number[]>;
|
|
240
|
+
/** Enclosing block-level `w:sdt` content controls, preserved for round-trip. */
|
|
241
|
+
sdtWrappers?: EditorSdtBlockWrapper[];
|
|
223
242
|
}
|
|
224
243
|
export type EditorBlockNode = EditorParagraphNode | EditorTableNode;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import { EditorFootnoteSettings } from '../../core/model.js';
|
|
1
|
+
import { EditorFontInfo, EditorFootnoteSettings } from '../../core/model.js';
|
|
2
2
|
import { DocContext, PartDefinition } from './docxTypes.js';
|
|
3
3
|
|
|
4
|
-
export declare function buildContentTypesXml(hasNumbering: boolean, imageExtensions: Iterable<string>, hasSettings: boolean, parts: PartDefinition[], hasFootnotes: boolean, hasEndnotes: boolean, hasStyles: boolean, hasComments: boolean): string;
|
|
4
|
+
export declare function buildContentTypesXml(hasNumbering: boolean, imageExtensions: Iterable<string>, hasSettings: boolean, parts: PartDefinition[], hasFootnotes: boolean, hasEndnotes: boolean, hasStyles: boolean, hasComments: boolean, hasFontTable: boolean): string;
|
|
5
5
|
export declare function buildRootRelationshipsXml(): string;
|
|
6
|
-
export declare function buildDocumentRelationshipsXml(hasNumbering: boolean, hasSettings: boolean, images: DocContext["images"], hyperlinks: DocContext["hyperlinks"], parts: PartDefinition[], hasFootnotes: boolean, hasEndnotes: boolean, hasStyles: boolean, hasComments: boolean): string;
|
|
6
|
+
export declare function buildDocumentRelationshipsXml(hasNumbering: boolean, hasSettings: boolean, images: DocContext["images"], hyperlinks: DocContext["hyperlinks"], parts: PartDefinition[], hasFootnotes: boolean, hasEndnotes: boolean, hasStyles: boolean, hasComments: boolean, hasFontTable: boolean): string;
|
|
7
|
+
/**
|
|
8
|
+
* Serialize the document's font declarations to `word/fontTable.xml`. Mirrors the
|
|
9
|
+
* structured {@link EditorFontInfo} back to `<w:font>` entries (substitution
|
|
10
|
+
* metadata only; embedded font references are not emitted).
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildFontTableXml(fonts: EditorFontInfo[]): string;
|
|
7
13
|
export interface HyphenationSettingsXml {
|
|
8
14
|
autoHyphenation?: boolean;
|
|
9
15
|
consecutiveHyphenLimit?: number;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { EditorBlockNode, EditorNamedStyle, EditorParagraphNode, EditorParagraphStyle } from '../../../core/model.js';
|
|
2
2
|
import { DocContext } from '../docxTypes.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Serialize a block run, re-wrapping any block-level `w:sdt` content controls
|
|
6
|
+
* preserved on import. Consecutive blocks sharing an outermost wrapper `groupId`
|
|
7
|
+
* are coalesced back into one `<w:sdt>` envelope; the wrapper is stripped before
|
|
8
|
+
* recursing so nested content controls re-wrap from the inside out.
|
|
9
|
+
*/
|
|
4
10
|
export declare function serializeBlocksXml(blocks: EditorBlockNode[], context: DocContext, styles: Record<string, EditorNamedStyle> | undefined): string;
|
|
5
11
|
export declare function serializeParagraphXml(paragraph: EditorParagraphNode, context: DocContext, styles: Record<string, EditorNamedStyle> | undefined, overrides?: {
|
|
6
12
|
align?: EditorParagraphStyle["align"];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OasisPdfFontResource, OasisPdfImageOptions, OasisPdfImageResource, OasisPdfLineOptions, OasisPdfPageSize, OasisPdfPathOptions, OasisPdfRectOptions, OasisPdfTextOptions } from './writer/pdfTypes.js';
|
|
1
|
+
import { OasisPdfAxialGradient, OasisPdfFontResource, OasisPdfImageOptions, OasisPdfImageResource, OasisPdfLineOptions, OasisPdfPageSize, OasisPdfPathOptions, OasisPdfRectOptions, OasisPdfTextOptions } from './writer/pdfTypes.js';
|
|
2
2
|
|
|
3
3
|
export type { OasisPdfPageSize, OasisPdfPage, OasisPdfRectOptions, OasisPdfLineOptions, OasisPdfPathSegment, OasisPdfPathOptions, OasisPdfTextOptions, OasisPdfImageResource, OasisPdfImageOptions, OasisPdfFontResource, OasisPdfBase14FontResource, OasisPdfUnicodeFontResource, } from './writer/pdfTypes.js';
|
|
4
4
|
export declare class OasisPdfWriter {
|
|
@@ -6,6 +6,7 @@ export declare class OasisPdfWriter {
|
|
|
6
6
|
private readonly streams;
|
|
7
7
|
private readonly fonts;
|
|
8
8
|
private readonly images;
|
|
9
|
+
private readonly shadings;
|
|
9
10
|
constructor(fontResources?: OasisPdfFontResource[]);
|
|
10
11
|
registerFontResource(resource: OasisPdfFontResource): void;
|
|
11
12
|
addPage(size: OasisPdfPageSize): number;
|
|
@@ -18,6 +19,12 @@ export declare class OasisPdfWriter {
|
|
|
18
19
|
rotateAbout(pageIndex: number, centerX: number, centerY: number, degrees: number): void;
|
|
19
20
|
clipRect(pageIndex: number, x: number, y: number, width: number, height: number): void;
|
|
20
21
|
drawText(pageIndex: number, options: OasisPdfTextOptions): void;
|
|
22
|
+
/**
|
|
23
|
+
* Registers an axial (linear) gradient on a page for use as a glyph fill, and
|
|
24
|
+
* returns its shading resource name to pass as `gradientShadingName` on a
|
|
25
|
+
* subsequent `drawText`. Coordinates are in the writer's top-left point space.
|
|
26
|
+
*/
|
|
27
|
+
registerAxialGradient(pageIndex: number, gradient: OasisPdfAxialGradient): string | null;
|
|
21
28
|
registerImageResource(resource: Omit<OasisPdfImageResource, "resourceName"> & {
|
|
22
29
|
resourceName?: string;
|
|
23
30
|
}): string;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import { OasisPdfImageOptions, OasisPdfLineOptions, OasisPdfPage, OasisPdfPathOptions, OasisPdfRectOptions, OasisPdfTextOptions } from './pdfTypes.js';
|
|
1
|
+
import { OasisPdfAxialGradient, OasisPdfImageOptions, OasisPdfLineOptions, OasisPdfPage, OasisPdfPathOptions, OasisPdfRectOptions, OasisPdfTextOptions } from './pdfTypes.js';
|
|
2
2
|
import { PdfFontTable } from './PdfFontTable.js';
|
|
3
3
|
import { PdfImageTable } from './PdfImageTable.js';
|
|
4
|
+
import { PdfShadingTable } from './PdfShadingTable.js';
|
|
4
5
|
|
|
5
6
|
export declare class PdfContentStream {
|
|
6
7
|
readonly page: OasisPdfPage;
|
|
7
8
|
private readonly fonts;
|
|
8
9
|
private readonly images;
|
|
9
|
-
|
|
10
|
+
private readonly shadings;
|
|
11
|
+
constructor(page: OasisPdfPage, fonts: PdfFontTable, images: PdfImageTable, shadings: PdfShadingTable);
|
|
12
|
+
/**
|
|
13
|
+
* Registers an axial gradient for use as a glyph fill on this page. Coordinates
|
|
14
|
+
* come in the writer's top-left point space and are flipped to PDF bottom-left
|
|
15
|
+
* space here; the returned name is referenced via `OasisPdfTextOptions`.
|
|
16
|
+
*/
|
|
17
|
+
registerAxialGradient(gradient: OasisPdfAxialGradient): string;
|
|
10
18
|
drawRect(options: OasisPdfRectOptions): void;
|
|
11
19
|
drawLine(options: OasisPdfLineOptions): void;
|
|
12
20
|
drawPath(options: OasisPdfPathOptions): void;
|
|
@@ -15,6 +23,15 @@ export declare class PdfContentStream {
|
|
|
15
23
|
rotateAbout(centerX: number, centerY: number, degrees: number): void;
|
|
16
24
|
clipRect(x: number, y: number, width: number, height: number): void;
|
|
17
25
|
drawText(options: OasisPdfTextOptions): void;
|
|
26
|
+
private textSetupCommands;
|
|
18
27
|
private emitTextBlock;
|
|
28
|
+
/**
|
|
29
|
+
* Fills glyphs with an axial gradient: the text is drawn in clip render mode
|
|
30
|
+
* (`7 Tr`) so the glyph outlines become the clip path, then the shading is
|
|
31
|
+
* painted through them with `sh`. The whole sequence is isolated in a
|
|
32
|
+
* `q … Q` pair so the clip does not leak. Outline/stroke is not combined with
|
|
33
|
+
* gradient fill (the gradient supersedes it).
|
|
34
|
+
*/
|
|
35
|
+
private emitGradientTextBlock;
|
|
19
36
|
drawImage(options: OasisPdfImageOptions): void;
|
|
20
37
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OasisPdfPage } from './pdfTypes.js';
|
|
2
2
|
import { PdfFontTable } from './PdfFontTable.js';
|
|
3
3
|
import { PdfImageTable } from './PdfImageTable.js';
|
|
4
|
+
import { PdfShadingTable } from './PdfShadingTable.js';
|
|
4
5
|
|
|
5
|
-
export declare function serializePdfDocument(pages: OasisPdfPage[], fonts: PdfFontTable, images: PdfImageTable): Uint8Array;
|
|
6
|
+
export declare function serializePdfDocument(pages: OasisPdfPage[], fonts: PdfFontTable, images: PdfImageTable, shadings: PdfShadingTable): Uint8Array;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AddPdfObject } from './pdfTypes.js';
|
|
2
|
+
|
|
3
|
+
/** A gradient already resolved to PDF bottom-left-origin point coordinates. */
|
|
4
|
+
export interface PdfAxialShadingSpec {
|
|
5
|
+
x0: number;
|
|
6
|
+
y0: number;
|
|
7
|
+
x1: number;
|
|
8
|
+
y1: number;
|
|
9
|
+
/** Stops sorted by offset, each `{ offset: 0–1, color: hex }`. */
|
|
10
|
+
stops: Array<{
|
|
11
|
+
offset: number;
|
|
12
|
+
color: string;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
export declare class PdfShadingTable {
|
|
16
|
+
private readonly shadings;
|
|
17
|
+
/** Registers a gradient (PDF space) and returns its `/Shading` resource name. */
|
|
18
|
+
register(spec: PdfAxialShadingSpec): string;
|
|
19
|
+
/** Emits each gradient's Function + Shading objects, keyed by resource name. */
|
|
20
|
+
buildShadingObjects(addObject: AddPdfObject): Map<string, number>;
|
|
21
|
+
private addShadingObject;
|
|
22
|
+
}
|
|
@@ -6,6 +6,7 @@ export declare function formatNumber(value: number): string;
|
|
|
6
6
|
export declare function byteLength(value: string): number;
|
|
7
7
|
export declare function bytesToHex(bytes: Uint8Array): string;
|
|
8
8
|
export declare function toHex16(value: number): string;
|
|
9
|
+
export declare function colorToRgb(color: string | undefined, fallback: [number, number, number]): [number, number, number];
|
|
9
10
|
export declare function colorCommand(color: string | undefined, operator: "rg" | "RG", fallback: [number, number, number]): string;
|
|
10
11
|
export declare function resolveFontName(options: Pick<OasisPdfTextOptions, "bold" | "italic" | "fontResourceName">): string;
|
|
11
12
|
export declare function fontResourceObjectBody(resource: OasisPdfFontResource): string;
|
|
@@ -12,6 +12,24 @@ export interface OasisPdfPage {
|
|
|
12
12
|
height: number;
|
|
13
13
|
commands: string[];
|
|
14
14
|
imageResourceNames: Set<string>;
|
|
15
|
+
shadingResourceNames: Set<string>;
|
|
16
|
+
}
|
|
17
|
+
/** One color stop of an axial gradient. `offset` is 0–1; `color` is a hex string. */
|
|
18
|
+
export interface OasisPdfGradientStop {
|
|
19
|
+
offset: number;
|
|
20
|
+
color: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* An axial (linear) gradient fill, in the writer's top-left-origin point space.
|
|
24
|
+
* `(x0,y0)→(x1,y1)` is the gradient axis; the content stream flips y to PDF space
|
|
25
|
+
* and the shading extends its end colors beyond the axis.
|
|
26
|
+
*/
|
|
27
|
+
export interface OasisPdfAxialGradient {
|
|
28
|
+
x0: number;
|
|
29
|
+
y0: number;
|
|
30
|
+
x1: number;
|
|
31
|
+
y1: number;
|
|
32
|
+
stops: OasisPdfGradientStop[];
|
|
15
33
|
}
|
|
16
34
|
export interface OasisPdfRectOptions {
|
|
17
35
|
x: number;
|
|
@@ -78,6 +96,12 @@ export interface OasisPdfTextOptions {
|
|
|
78
96
|
* Unicode font (e.g. `["liga", "onum", "ss01"]`). Ignored by base-14 fonts.
|
|
79
97
|
*/
|
|
80
98
|
fontFeatures?: readonly string[];
|
|
99
|
+
/**
|
|
100
|
+
* Resource name of an axial-gradient shading (from `registerAxialGradient`).
|
|
101
|
+
* When set, the glyphs are used as a clip path and the gradient is painted
|
|
102
|
+
* through them (`w14:textFill` gradient), so `color`/`renderMode` are ignored.
|
|
103
|
+
*/
|
|
104
|
+
gradientShadingName?: string;
|
|
81
105
|
}
|
|
82
106
|
export interface OasisPdfImageResource {
|
|
83
107
|
resourceName: string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EditorFontInfo } from '../../core/model.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parse `word/fontTable.xml` into the document's font declarations. Each
|
|
5
|
+
* `<w:font w:name="…">` carries substitution metadata (alternative name, family,
|
|
6
|
+
* pitch, charset, PANOSE, and the Unicode/codepage signature). Embedded font
|
|
7
|
+
* references (`w:embedRegular`/etc., which point at obfuscated `.odttf` parts)
|
|
8
|
+
* are intentionally not read.
|
|
9
|
+
*
|
|
10
|
+
* Returns `undefined` when there is no usable font table so the document field
|
|
11
|
+
* stays absent (and export skips the part).
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseFontTable(xml: string | null): EditorFontInfo[] | undefined;
|
|
@@ -6,6 +6,20 @@ import { DocxImportTheme } from './theme.js';
|
|
|
6
6
|
import { NumberingMaps } from './numbering.js';
|
|
7
7
|
import { ParseNestedBlocks } from './runs/types.js';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Parse a single block-level child element (`w:p`, `w:tbl`, or a `w:sdt` content
|
|
11
|
+
* control) into editor blocks. Unknown elements yield no blocks. Shared by the
|
|
12
|
+
* text-box body walker, the document-body walker, and nested `w:sdtContent`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseBlockLevelChild(element: XmlElement, numberingMaps: NumberingMaps, zip: JSZip, relsMap: Map<string, string>, assets: AssetRegistry, theme: DocxImportTheme, parseNestedBlocks: ParseNestedBlocks): Promise<EditorBlockNode[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Parse a block-level structured document tag (`w:sdt`) into its content blocks,
|
|
17
|
+
* preserving the `w:sdtPr`/`w:sdtEndPr` wrapper on each produced block so export
|
|
18
|
+
* can re-wrap it (see {@link EditorSdtBlockWrapper}). The content is unwrapped so
|
|
19
|
+
* it renders and edits like any other block; nested `w:sdt` recurses, prepending
|
|
20
|
+
* outer wrappers ahead of inner ones.
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseSdtBlockNode(sdtElement: XmlElement, numberingMaps: NumberingMaps, zip: JSZip, relsMap: Map<string, string>, assets: AssetRegistry, theme: DocxImportTheme, parseNestedBlocks: ParseNestedBlocks): Promise<EditorBlockNode[]>;
|
|
9
23
|
/**
|
|
10
24
|
* Build a `ParseNestedBlocks` callback bound to an import context. The paragraph
|
|
11
25
|
* and table parsers receive this so a text-box run can recurse into block-level
|
|
@@ -2519,7 +2519,7 @@ function OasisEditorAppLazy(props = {}) {
|
|
|
2519
2519
|
onCleanup(() => {
|
|
2520
2520
|
cancelled = true;
|
|
2521
2521
|
});
|
|
2522
|
-
import("./OasisEditorApp-
|
|
2522
|
+
import("./OasisEditorApp-DDtlPHus.js").then((m) => {
|
|
2523
2523
|
cancelled = true;
|
|
2524
2524
|
setProgress(1);
|
|
2525
2525
|
setTimeout(() => setApp(() => m.OasisEditorApp), 180);
|
|
@@ -34870,6 +34870,60 @@ function parseImportedStyles(stylesXml, theme) {
|
|
|
34870
34870
|
}
|
|
34871
34871
|
return emptyOrUndefined(styles);
|
|
34872
34872
|
}
|
|
34873
|
+
function parseFontTable(xml) {
|
|
34874
|
+
if (!xml) {
|
|
34875
|
+
return void 0;
|
|
34876
|
+
}
|
|
34877
|
+
const root = new DOMParser$1().parseFromString(xml, "application/xml");
|
|
34878
|
+
const fontsEl = root.getElementsByTagNameNS(WORD_NS, "fonts")[0];
|
|
34879
|
+
if (!fontsEl) {
|
|
34880
|
+
return void 0;
|
|
34881
|
+
}
|
|
34882
|
+
const fonts = [];
|
|
34883
|
+
for (const fontEl of getChildrenByTagNameNS(fontsEl, WORD_NS, "font")) {
|
|
34884
|
+
const name = getAttributeValue(fontEl, "name");
|
|
34885
|
+
if (!name) {
|
|
34886
|
+
continue;
|
|
34887
|
+
}
|
|
34888
|
+
const info = { name };
|
|
34889
|
+
const altName = getAttributeValue(
|
|
34890
|
+
getFirstChildByTagNameNS(fontEl, WORD_NS, "altName"),
|
|
34891
|
+
"val"
|
|
34892
|
+
);
|
|
34893
|
+
if (altName) info.altName = altName;
|
|
34894
|
+
const family = getAttributeValue(
|
|
34895
|
+
getFirstChildByTagNameNS(fontEl, WORD_NS, "family"),
|
|
34896
|
+
"val"
|
|
34897
|
+
);
|
|
34898
|
+
if (family) info.family = family;
|
|
34899
|
+
const pitch = getAttributeValue(
|
|
34900
|
+
getFirstChildByTagNameNS(fontEl, WORD_NS, "pitch"),
|
|
34901
|
+
"val"
|
|
34902
|
+
);
|
|
34903
|
+
if (pitch) info.pitch = pitch;
|
|
34904
|
+
const charset = getAttributeValue(
|
|
34905
|
+
getFirstChildByTagNameNS(fontEl, WORD_NS, "charset"),
|
|
34906
|
+
"val"
|
|
34907
|
+
);
|
|
34908
|
+
if (charset) info.charset = charset;
|
|
34909
|
+
const panose1 = getAttributeValue(
|
|
34910
|
+
getFirstChildByTagNameNS(fontEl, WORD_NS, "panose1"),
|
|
34911
|
+
"val"
|
|
34912
|
+
);
|
|
34913
|
+
if (panose1) info.panose1 = panose1;
|
|
34914
|
+
const sigEl = getFirstChildByTagNameNS(fontEl, WORD_NS, "sig");
|
|
34915
|
+
if (sigEl) {
|
|
34916
|
+
const sig = {};
|
|
34917
|
+
for (let i = 0; i < sigEl.attributes.length; i += 1) {
|
|
34918
|
+
const attr = sigEl.attributes[i];
|
|
34919
|
+
sig[attr.localName ?? attr.name] = attr.value;
|
|
34920
|
+
}
|
|
34921
|
+
if (Object.keys(sig).length > 0) info.sig = sig;
|
|
34922
|
+
}
|
|
34923
|
+
fonts.push(info);
|
|
34924
|
+
}
|
|
34925
|
+
return fonts.length > 0 ? fonts : void 0;
|
|
34926
|
+
}
|
|
34873
34927
|
function isXmlTrue(value) {
|
|
34874
34928
|
return value === "1" || value === "true" || value === "on";
|
|
34875
34929
|
}
|
|
@@ -36504,6 +36558,86 @@ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, th
|
|
|
36504
36558
|
}
|
|
36505
36559
|
return table;
|
|
36506
36560
|
}
|
|
36561
|
+
async function parseBlockLevelChild(element, numberingMaps, zip, relsMap, assets, theme, parseNestedBlocks) {
|
|
36562
|
+
if (element.namespaceURI !== WORD_NS) {
|
|
36563
|
+
return [];
|
|
36564
|
+
}
|
|
36565
|
+
if (element.localName === "p") {
|
|
36566
|
+
const parsed = await parseParagraphNodes(
|
|
36567
|
+
element,
|
|
36568
|
+
numberingMaps,
|
|
36569
|
+
zip,
|
|
36570
|
+
relsMap,
|
|
36571
|
+
assets,
|
|
36572
|
+
theme,
|
|
36573
|
+
parseNestedBlocks
|
|
36574
|
+
);
|
|
36575
|
+
return parsed.paragraphs;
|
|
36576
|
+
}
|
|
36577
|
+
if (element.localName === "tbl") {
|
|
36578
|
+
return [
|
|
36579
|
+
await parseTableNode(
|
|
36580
|
+
element,
|
|
36581
|
+
numberingMaps,
|
|
36582
|
+
zip,
|
|
36583
|
+
relsMap,
|
|
36584
|
+
assets,
|
|
36585
|
+
theme,
|
|
36586
|
+
parseNestedBlocks
|
|
36587
|
+
)
|
|
36588
|
+
];
|
|
36589
|
+
}
|
|
36590
|
+
if (element.localName === "sdt") {
|
|
36591
|
+
return parseSdtBlockNode(
|
|
36592
|
+
element,
|
|
36593
|
+
numberingMaps,
|
|
36594
|
+
zip,
|
|
36595
|
+
relsMap,
|
|
36596
|
+
assets,
|
|
36597
|
+
theme,
|
|
36598
|
+
parseNestedBlocks
|
|
36599
|
+
);
|
|
36600
|
+
}
|
|
36601
|
+
return [];
|
|
36602
|
+
}
|
|
36603
|
+
async function parseSdtBlockNode(sdtElement, numberingMaps, zip, relsMap, assets, theme, parseNestedBlocks) {
|
|
36604
|
+
const sdtPr = getFirstChildByTagNameNS(sdtElement, WORD_NS, "sdtPr");
|
|
36605
|
+
const sdtEndPr = getFirstChildByTagNameNS(sdtElement, WORD_NS, "sdtEndPr");
|
|
36606
|
+
const wrapper = {
|
|
36607
|
+
groupId: createEditorNodeId("sdt"),
|
|
36608
|
+
sdtPrXml: sdtPr ? new XMLSerializer().serializeToString(sdtPr) : "",
|
|
36609
|
+
...sdtEndPr ? { sdtEndPrXml: new XMLSerializer().serializeToString(sdtEndPr) } : {}
|
|
36610
|
+
};
|
|
36611
|
+
const sdtContent = getFirstChildByTagNameNS(
|
|
36612
|
+
sdtElement,
|
|
36613
|
+
WORD_NS,
|
|
36614
|
+
"sdtContent"
|
|
36615
|
+
);
|
|
36616
|
+
const blocks = [];
|
|
36617
|
+
if (sdtContent) {
|
|
36618
|
+
for (let index = 0; index < sdtContent.childNodes.length; index += 1) {
|
|
36619
|
+
const node = sdtContent.childNodes[index];
|
|
36620
|
+
if ((node == null ? void 0 : node.nodeType) !== node.ELEMENT_NODE) {
|
|
36621
|
+
continue;
|
|
36622
|
+
}
|
|
36623
|
+
blocks.push(
|
|
36624
|
+
...await parseBlockLevelChild(
|
|
36625
|
+
node,
|
|
36626
|
+
numberingMaps,
|
|
36627
|
+
zip,
|
|
36628
|
+
relsMap,
|
|
36629
|
+
assets,
|
|
36630
|
+
theme,
|
|
36631
|
+
parseNestedBlocks
|
|
36632
|
+
)
|
|
36633
|
+
);
|
|
36634
|
+
}
|
|
36635
|
+
}
|
|
36636
|
+
for (const block of blocks) {
|
|
36637
|
+
block.sdtWrappers = [wrapper, ...block.sdtWrappers ?? []];
|
|
36638
|
+
}
|
|
36639
|
+
return blocks;
|
|
36640
|
+
}
|
|
36507
36641
|
function createNestedBlockParser(numberingMaps, zip, relsMap, assets, theme) {
|
|
36508
36642
|
return (container) => parseTxbxContentBlocks(
|
|
36509
36643
|
container,
|
|
@@ -36528,36 +36662,17 @@ async function parseTxbxContentBlocks(container, numberingMaps, zip, relsMap, as
|
|
|
36528
36662
|
if ((node == null ? void 0 : node.nodeType) !== node.ELEMENT_NODE) {
|
|
36529
36663
|
continue;
|
|
36530
36664
|
}
|
|
36531
|
-
|
|
36532
|
-
|
|
36533
|
-
|
|
36534
|
-
}
|
|
36535
|
-
if (element.localName === "p") {
|
|
36536
|
-
const parsed = await parseParagraphNodes(
|
|
36537
|
-
element,
|
|
36665
|
+
blocks.push(
|
|
36666
|
+
...await parseBlockLevelChild(
|
|
36667
|
+
node,
|
|
36538
36668
|
numberingMaps,
|
|
36539
36669
|
zip,
|
|
36540
36670
|
relsMap,
|
|
36541
36671
|
assets,
|
|
36542
36672
|
theme,
|
|
36543
36673
|
parseNestedBlocks
|
|
36544
|
-
)
|
|
36545
|
-
|
|
36546
|
-
blocks.push(paragraph);
|
|
36547
|
-
}
|
|
36548
|
-
} else if (element.localName === "tbl") {
|
|
36549
|
-
blocks.push(
|
|
36550
|
-
await parseTableNode(
|
|
36551
|
-
element,
|
|
36552
|
-
numberingMaps,
|
|
36553
|
-
zip,
|
|
36554
|
-
relsMap,
|
|
36555
|
-
assets,
|
|
36556
|
-
theme,
|
|
36557
|
-
parseNestedBlocks
|
|
36558
|
-
)
|
|
36559
|
-
);
|
|
36560
|
-
}
|
|
36674
|
+
)
|
|
36675
|
+
);
|
|
36561
36676
|
}
|
|
36562
36677
|
return blocks;
|
|
36563
36678
|
}
|
|
@@ -36998,7 +37113,7 @@ function parseCommentsXml(commentsXml, commentsExtendedXml) {
|
|
|
36998
37113
|
return byDocxId;
|
|
36999
37114
|
}
|
|
37000
37115
|
async function importDocxToEditorDocument(buffer, options = {}) {
|
|
37001
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
37116
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
37002
37117
|
(_a = options.onProgress) == null ? void 0 : _a.call(options, "opening-docx");
|
|
37003
37118
|
const zip = await JSZip.loadAsync(buffer);
|
|
37004
37119
|
const documentXml = await ((_b = zip.file("word/document.xml")) == null ? void 0 : _b.async("string"));
|
|
@@ -37012,10 +37127,13 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37012
37127
|
const settingsXml = await ((_e = zip.file("word/settings.xml")) == null ? void 0 : _e.async("string")) ?? null;
|
|
37013
37128
|
const docSettings = parseSettings(settingsXml);
|
|
37014
37129
|
const stylesXml = await ((_f = zip.file("word/styles.xml")) == null ? void 0 : _f.async("string")) ?? null;
|
|
37015
|
-
const
|
|
37130
|
+
const fontTable = parseFontTable(
|
|
37131
|
+
await ((_g = zip.file("word/fontTable.xml")) == null ? void 0 : _g.async("string")) ?? null
|
|
37132
|
+
);
|
|
37133
|
+
const themeXml = await ((_h = zip.file("word/theme/theme1.xml")) == null ? void 0 : _h.async("string")) ?? null;
|
|
37016
37134
|
const theme = parseDocxTheme(themeXml);
|
|
37017
37135
|
const importedStyles = parseImportedStyles(stylesXml, theme);
|
|
37018
|
-
(
|
|
37136
|
+
(_i = options.onProgress) == null ? void 0 : _i.call(options, "parsing-document");
|
|
37019
37137
|
const document2 = new DOMParser$1().parseFromString(
|
|
37020
37138
|
documentXml,
|
|
37021
37139
|
"application/xml"
|
|
@@ -37117,6 +37235,19 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37117
37235
|
)
|
|
37118
37236
|
);
|
|
37119
37237
|
reportBodyProgress();
|
|
37238
|
+
} else if (element.localName === "sdt") {
|
|
37239
|
+
for (const block of await parseSdtBlockNode(
|
|
37240
|
+
element,
|
|
37241
|
+
numberingMaps,
|
|
37242
|
+
zip,
|
|
37243
|
+
relsMap,
|
|
37244
|
+
assets,
|
|
37245
|
+
theme,
|
|
37246
|
+
parseNestedBlocks
|
|
37247
|
+
)) {
|
|
37248
|
+
appendBodyBlock(block);
|
|
37249
|
+
}
|
|
37250
|
+
reportBodyProgress();
|
|
37120
37251
|
}
|
|
37121
37252
|
await yieldToEventLoop(50, completedBodyWorkItems);
|
|
37122
37253
|
}
|
|
@@ -37134,7 +37265,7 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37134
37265
|
}
|
|
37135
37266
|
);
|
|
37136
37267
|
}
|
|
37137
|
-
(
|
|
37268
|
+
(_j = options.onProgress) == null ? void 0 : _j.call(options, "parsing-headers-footers");
|
|
37138
37269
|
const sections = [];
|
|
37139
37270
|
const hasHeaderFooterReferences = (props) => Object.keys(props.headerRIds).length > 0 || Object.keys(props.footerRIds).length > 0;
|
|
37140
37271
|
const totalSectionsWithHeaders = sectionProps.filter(
|
|
@@ -37233,7 +37364,7 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37233
37364
|
evenPageFooter: evenPageFooter.length > 0 ? evenPageFooter : void 0
|
|
37234
37365
|
});
|
|
37235
37366
|
}
|
|
37236
|
-
const footnotesXml = await ((
|
|
37367
|
+
const footnotesXml = await ((_k = zip.file("word/footnotes.xml")) == null ? void 0 : _k.async("string")) ?? null;
|
|
37237
37368
|
const footnotesPartRels = footnotesXml ? await loadPartRelationships(zip, "word/footnotes.xml") : /* @__PURE__ */ new Map();
|
|
37238
37369
|
const parsedFootnotes = await parseFootnotesXml(
|
|
37239
37370
|
footnotesXml,
|
|
@@ -37248,7 +37379,7 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37248
37379
|
}
|
|
37249
37380
|
const editorFootnotes = Object.keys(parsedFootnotes.footnotes.items).length > 0 || parsedFootnotes.footnotes.separator || parsedFootnotes.footnotes.continuationSeparator || parsedFootnotes.footnotes.settings ? parsedFootnotes.footnotes : void 0;
|
|
37250
37381
|
remapImportedFootnoteRefsInSections(sections, parsedFootnotes.byDocxId);
|
|
37251
|
-
const endnotesXml = await ((
|
|
37382
|
+
const endnotesXml = await ((_l = zip.file("word/endnotes.xml")) == null ? void 0 : _l.async("string")) ?? null;
|
|
37252
37383
|
const endnotesPartRels = endnotesXml ? await loadPartRelationships(zip, "word/endnotes.xml") : /* @__PURE__ */ new Map();
|
|
37253
37384
|
const parsedEndnotes = await parseEndnotesXml(
|
|
37254
37385
|
endnotesXml,
|
|
@@ -37265,8 +37396,8 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37265
37396
|
remapImportedEndnoteRefsInSections(sections, parsedEndnotes.byDocxId);
|
|
37266
37397
|
const editorBookmarks = extractBookmarksFromSections(sections);
|
|
37267
37398
|
const commentRanges = extractCommentRangesFromSections(sections);
|
|
37268
|
-
const commentsXml = await ((
|
|
37269
|
-
const commentsExtendedXml = await ((
|
|
37399
|
+
const commentsXml = await ((_m = zip.file("word/comments.xml")) == null ? void 0 : _m.async("string")) ?? null;
|
|
37400
|
+
const commentsExtendedXml = await ((_n = zip.file("word/commentsExtended.xml")) == null ? void 0 : _n.async("string")) ?? null;
|
|
37270
37401
|
const commentBodies = parseCommentsXml(commentsXml, commentsExtendedXml);
|
|
37271
37402
|
const editorComments = buildEditorComments(commentRanges, commentBodies);
|
|
37272
37403
|
const shouldPreserveSections = sections.length > 1 || sections.some(
|
|
@@ -37313,6 +37444,9 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37313
37444
|
hyphenationZone: docSettings.hyphenationZone
|
|
37314
37445
|
};
|
|
37315
37446
|
}
|
|
37447
|
+
if (fontTable) {
|
|
37448
|
+
doc2.fontTable = fontTable;
|
|
37449
|
+
}
|
|
37316
37450
|
let result = doc2;
|
|
37317
37451
|
if (editorFootnotes) {
|
|
37318
37452
|
result.footnotes = editorFootnotes;
|
|
@@ -37500,7 +37634,7 @@ function importDocxInWorker(buffer, options = {}) {
|
|
|
37500
37634
|
const worker = new Worker(
|
|
37501
37635
|
new URL(
|
|
37502
37636
|
/* @vite-ignore */
|
|
37503
|
-
"" + new URL("assets/importDocxWorker-
|
|
37637
|
+
"" + new URL("assets/importDocxWorker-GkXQ7kFj.js", import.meta.url).href,
|
|
37504
37638
|
import.meta.url
|
|
37505
37639
|
),
|
|
37506
37640
|
{
|
package/dist/oasis-editor.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O, c8, c9, ca, cb, cc, a8, cd, Q, bT, ce, cf, cg, N, ch, bR, ci, cj, ck, cl, cm, c3, cn, co, cp, cq, cr, cs, ct, cu, cv, cw, cx, cy, ad, cz, c2, cA, ca as ca2, cf as cf2, ch as ch2, cq as cq2, cs as cs2, cx as cx2, cB, bV, bQ, cC, cD, cE, bS, cF, cG, bU } from "./index-
|
|
1
|
+
import { O, c8, c9, ca, cb, cc, a8, cd, Q, bT, ce, cf, cg, N, ch, bR, ci, cj, ck, cl, cm, c3, cn, co, cp, cq, cr, cs, ct, cu, cv, cw, cx, cy, ad, cz, c2, cA, ca as ca2, cf as cf2, ch as ch2, cq as cq2, cs as cs2, cx as cx2, cB, bV, bQ, cC, cD, cE, bS, cF, cG, bU } from "./index-CNtAFUVS.js";
|
|
2
2
|
export {
|
|
3
3
|
O as BalloonShell,
|
|
4
4
|
c8 as Button,
|