oasis-editor 0.0.142 → 0.0.144
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-DNiy9Yze.js → OasisEditorApp-CskQWKEC.js} +765 -22
- package/dist/assets/{importDocxWorker-B1vHeo5L.js → importDocxWorker-5S8lX4CZ.js} +1 -1
- package/dist/core/model/index.d.ts +1 -0
- package/dist/core/model/types/document.d.ts +7 -0
- package/dist/core/model/types/docxSourcePackage.d.ts +46 -0
- package/dist/export/docx/docxTypes.d.ts +2 -0
- package/dist/export/docx/exportEditorDocumentToDocxPreservingSource.d.ts +4 -0
- package/dist/export/docx/opc/sourcePackagePatcher.d.ts +8 -0
- package/dist/export/docx/text/sourceParagraphPropertiesXml.d.ts +8 -0
- package/dist/export/docx/text/sourceParagraphXml.d.ts +12 -0
- package/dist/export/docx/text/sourceRunXml.d.ts +14 -0
- package/dist/import/docx/markupCompatibility.d.ts +20 -0
- package/dist/import/docx/numbering.d.ts +3 -0
- package/dist/import/docx/opc/legacyCompatibilityPackage.d.ts +10 -0
- package/dist/import/docx/opc/sourcePackage.d.ts +4 -0
- package/dist/import/docx/xmlHelpers.d.ts +3 -5
- package/dist/{index-PWJQT9bT.js → index-DOtfE4EA.js} +1116 -361
- package/dist/oasis-editor.js +79 -79
- package/dist/oasis-editor.umd.cjs +4 -4
- package/dist/ooxml/opc/packageXml.d.ts +14 -0
- package/dist/ooxml/word/numberingMetadata.d.ts +20 -0
- package/dist/ooxml/word/sourceFragments.d.ts +43 -0
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@ 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 { EditorOpcPartKind, EditorOpcPartEncoding, EditorOpcRelationship, EditorOpcContentTypes, EditorOpcPart, EditorDocxDiagnostic, EditorDocxSourcePackage, } from './types/docxSourcePackage.js';
|
|
18
19
|
export type { EditorPageMargins, EditorPageSettings, EditorColumnsSettings, EditorSection, EditorPageNumbering, EditorSectionVerticalAlign, EditorFontInfo, EditorFootnoteSettings, EditorFootnotes, EditorEndnoteSettings, EditorEndnotes, EditorDocument, } from './types/document.js';
|
|
19
20
|
export type { EditorPosition, EditorSelection, EditorEditingZone, } from './types/selection.js';
|
|
20
21
|
export type { EditorCaretSlot, EditorLayoutFragmentChar, EditorLayoutFragment, EditorLayoutLine, EditorLayoutParagraph, EditorLayoutBlock, TableCellBlockPosition, EditorLayoutPage, EditorLayoutDocument, } from './types/layout.js';
|
|
@@ -5,6 +5,7 @@ import { EditorEndnote } from './documentEndnotes.js';
|
|
|
5
5
|
import { EditorBookmarks } from './documentBookmarks.js';
|
|
6
6
|
import { EditorComments } from './documentComments.js';
|
|
7
7
|
import { EditorNamedStyle } from './styles.js';
|
|
8
|
+
import { EditorDocxSourcePackage } from './docxSourcePackage.js';
|
|
8
9
|
|
|
9
10
|
export interface EditorPageMargins {
|
|
10
11
|
top: number;
|
|
@@ -157,6 +158,12 @@ export interface EditorDocument {
|
|
|
157
158
|
/** `w:doNotHyphenateCaps`: do not hyphenate all-caps words. */
|
|
158
159
|
doNotHyphenateCaps?: boolean;
|
|
159
160
|
};
|
|
161
|
+
/**
|
|
162
|
+
* Original OPC package snapshot for an imported DOCX. The object is shared
|
|
163
|
+
* across editor-state clones and is not traversed by layout or hot mutation
|
|
164
|
+
* paths. It is the preservation source for unsupported package parts.
|
|
165
|
+
*/
|
|
166
|
+
sourcePackage?: EditorDocxSourcePackage;
|
|
160
167
|
/**
|
|
161
168
|
* Out-of-band asset registry. Image runs reference entries here using
|
|
162
169
|
* `src = "asset:<id>"`. The map itself is treated as append-only and is
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serializable snapshot of the OPC package that backed an imported DOCX.
|
|
3
|
+
*
|
|
4
|
+
* The editor model is the typed, editable projection. This package snapshot is
|
|
5
|
+
* the preservation layer for parts and relationships that Oasis does not yet
|
|
6
|
+
* understand semantically. It deliberately contains only structured-clone-safe
|
|
7
|
+
* data so imports can continue to run inside a Web Worker.
|
|
8
|
+
*/
|
|
9
|
+
export type EditorOpcPartKind = "xml" | "binary";
|
|
10
|
+
export type EditorOpcPartEncoding = "utf8" | "base64";
|
|
11
|
+
export interface EditorOpcRelationship {
|
|
12
|
+
id: string;
|
|
13
|
+
type: string;
|
|
14
|
+
target: string;
|
|
15
|
+
targetMode?: "Internal" | "External";
|
|
16
|
+
/** Normalized package path for an internal target. */
|
|
17
|
+
resolvedTarget?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface EditorOpcContentTypes {
|
|
20
|
+
defaults: Record<string, string>;
|
|
21
|
+
overrides: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
export interface EditorOpcPart {
|
|
24
|
+
path: string;
|
|
25
|
+
contentType?: string;
|
|
26
|
+
kind: EditorOpcPartKind;
|
|
27
|
+
data: string;
|
|
28
|
+
encoding: EditorOpcPartEncoding;
|
|
29
|
+
originalHash: string;
|
|
30
|
+
relationships?: EditorOpcRelationship[];
|
|
31
|
+
}
|
|
32
|
+
export interface EditorDocxDiagnostic {
|
|
33
|
+
level: "warning" | "error";
|
|
34
|
+
code: string;
|
|
35
|
+
message: string;
|
|
36
|
+
partPath?: string;
|
|
37
|
+
relationshipId?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface EditorDocxSourcePackage {
|
|
40
|
+
format: "docx";
|
|
41
|
+
mainDocumentPart: string;
|
|
42
|
+
contentTypes: EditorOpcContentTypes;
|
|
43
|
+
rootRelationships: EditorOpcRelationship[];
|
|
44
|
+
parts: Record<string, EditorOpcPart>;
|
|
45
|
+
diagnostics?: EditorDocxDiagnostic[];
|
|
46
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EditorBlockNode, EditorImageBorder, EditorImageCrop, EditorImageFillMode, EditorImageFloatingLayout, EditorParagraphListStyle, EditorWrapPolygonPoint } from '../../core/model.js';
|
|
2
|
+
import { EditorListOoxmlNumberingMetadata } from '../../ooxml/word/numberingMetadata.js';
|
|
2
3
|
import { BookmarkEventsByParagraph } from './bookmarksXml.js';
|
|
3
4
|
import { CommentEventsByParagraph } from './commentsXml.js';
|
|
4
5
|
|
|
@@ -13,6 +14,7 @@ export interface NumberingLevelDefinition {
|
|
|
13
14
|
legal?: boolean;
|
|
14
15
|
bulletGlyph?: string;
|
|
15
16
|
bulletFont?: string;
|
|
17
|
+
ooxml?: EditorListOoxmlNumberingMetadata;
|
|
16
18
|
}
|
|
17
19
|
export interface NumberingDefinition {
|
|
18
20
|
abstractNumId: number;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EditorDocument } from '../../core/model.js';
|
|
2
|
+
|
|
3
|
+
export declare function exportEditorDocumentToDocxPreservingSource(document: EditorDocument): Promise<ArrayBuffer>;
|
|
4
|
+
export declare function exportEditorDocumentToDocxBlobPreservingSource(document: EditorDocument): Promise<Blob>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EditorDocument } from '../../../core/model.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Clones the imported package and overlays the freshly rebuilt Oasis parts.
|
|
5
|
+
* Unknown source parts remain untouched. Content types and relationship parts
|
|
6
|
+
* are merged instead of blindly replaced so unrelated package features survive.
|
|
7
|
+
*/
|
|
8
|
+
export declare function patchRebuiltDocxWithSourcePackage(document: EditorDocument, rebuiltBuffer: ArrayBuffer): Promise<ArrayBuffer>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EditorParagraphNode } from '../../../core/model.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Preserves source-only `w:pPr` children while keeping the freshly generated
|
|
5
|
+
* paragraph properties authoritative. Unknown children are inserted before the
|
|
6
|
+
* next generated source sibling when possible, preserving source order.
|
|
7
|
+
*/
|
|
8
|
+
export declare function mergeParagraphPropertiesOoxmlSource(paragraph: EditorParagraphNode, generatedXml: string, hasOverrides: boolean): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EditorParagraphNode } from '../../../core/model.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Overlays edited paragraph properties and one-to-one generated runs onto the
|
|
5
|
+
* original source paragraph only when the paragraph envelope contains source-
|
|
6
|
+
* only attributes, children or wrappers. Ordinary paragraphs use the canonical
|
|
7
|
+
* serializer directly, avoiding unnecessary DOM normalization.
|
|
8
|
+
*/
|
|
9
|
+
export declare function overlayEditorParagraphOnOoxmlSource(paragraph: EditorParagraphNode, generatedParagraphPropertiesXml: string, generatedRunXml: string[], options: {
|
|
10
|
+
hasOverrides: boolean;
|
|
11
|
+
hasBoundaryTokens: boolean;
|
|
12
|
+
}): string | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EditorTextRun } from '../../../core/model.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns the original run subtree when its editor semantics are unchanged.
|
|
5
|
+
* For a text-only edit with otherwise identical structure, patches the original
|
|
6
|
+
* subtree's text nodes so unknown attributes/properties/children remain ordered.
|
|
7
|
+
*/
|
|
8
|
+
export declare function serializeRunFromOoxmlSource(run: EditorTextRun): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Merges source-only run attributes, run properties and direct extension
|
|
11
|
+
* children into a freshly generated single `w:r`. Generated/modelled content is
|
|
12
|
+
* authoritative; unknown source content remains anchored by source order.
|
|
13
|
+
*/
|
|
14
|
+
export declare function mergeRunOoxmlSourceIntoGeneratedXml(run: EditorTextRun, generatedXml: string): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Element as XmlElement } from '@xmldom/xmldom';
|
|
2
|
+
|
|
3
|
+
export declare const MARKUP_COMPATIBILITY_NS = "http://schemas.openxmlformats.org/markup-compatibility/2006";
|
|
4
|
+
export interface MarkupCompatibilityCapabilities {
|
|
5
|
+
supportedNamespaces: ReadonlySet<string>;
|
|
6
|
+
}
|
|
7
|
+
export declare const DEFAULT_MARKUP_COMPATIBILITY_CAPABILITIES: MarkupCompatibilityCapabilities;
|
|
8
|
+
export declare function extendMarkupCompatibilityCapabilities(base: MarkupCompatibilityCapabilities, ...namespaces: string[]): MarkupCompatibilityCapabilities;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the effective direct children after applying the parts of ECMA-376
|
|
11
|
+
* Markup Compatibility needed by semantic import:
|
|
12
|
+
*
|
|
13
|
+
* - first satisfiable mc:Choice, otherwise mc:Fallback;
|
|
14
|
+
* - mc:Ignorable filtering for unsupported extension namespaces;
|
|
15
|
+
* - mc:ProcessContent unwrapping for ignorable wrapper elements.
|
|
16
|
+
*
|
|
17
|
+
* PreserveElements/PreserveAttributes remain the responsibility of the source
|
|
18
|
+
* fragment layer, which retains the original XML for round-trip export.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getMarkupCompatibleChildren(element: XmlElement, capabilities?: MarkupCompatibilityCapabilities): XmlElement[];
|
|
@@ -5,6 +5,7 @@ type ListFormat = NonNullable<EditorParagraphListStyle["format"]>;
|
|
|
5
5
|
interface NumberingLevel {
|
|
6
6
|
kind?: EditorParagraphListStyle["kind"];
|
|
7
7
|
format?: ListFormat;
|
|
8
|
+
rawFormat?: string;
|
|
8
9
|
suffix?: EditorParagraphListStyle["suffix"];
|
|
9
10
|
startAt?: number;
|
|
10
11
|
levelText?: string;
|
|
@@ -12,6 +13,8 @@ interface NumberingLevel {
|
|
|
12
13
|
legal?: boolean;
|
|
13
14
|
bulletGlyph?: string;
|
|
14
15
|
bulletFont?: string;
|
|
16
|
+
restartAfterLevel?: number;
|
|
17
|
+
paragraphStyleId?: string;
|
|
15
18
|
indent?: {
|
|
16
19
|
left?: number;
|
|
17
20
|
hanging?: number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EditorDocxSourcePackage } from '../../../core/model.js';
|
|
2
|
+
|
|
3
|
+
export declare function requiresDocxImporterCompatibilityPackage(sourcePackage: EditorDocxSourcePackage): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Builds a temporary compatibility package for the current semantic importer.
|
|
6
|
+
* The original source snapshot remains authoritative and is attached to the
|
|
7
|
+
* resulting editor document; these aliases exist only so legacy path-based
|
|
8
|
+
* parsers can consume relationship-discovered packages.
|
|
9
|
+
*/
|
|
10
|
+
export declare function prepareDocxForCurrentImporter(originalBuffer: ArrayBuffer, sourcePackage: EditorDocxSourcePackage): Promise<ArrayBuffer>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EditorDocument, EditorDocxSourcePackage } from '../../../core/model.js';
|
|
2
|
+
|
|
3
|
+
export declare function captureDocxSourcePackage(buffer: ArrayBuffer): Promise<EditorDocxSourcePackage>;
|
|
4
|
+
export declare function attachDocxSourcePackage(document: EditorDocument, buffer: ArrayBuffer): Promise<EditorDocument>;
|
|
@@ -10,11 +10,9 @@ export type DocxTextDirection = "lrTb" | "tbRl" | "btLr" | "lrTbV" | "tbRlV";
|
|
|
10
10
|
export declare function parseTextDirection(value: string | null | undefined): DocxTextDirection | undefined;
|
|
11
11
|
export declare function getFirstChildByTagNameNS(element: XmlElement | null | undefined, namespace: string, localName: string): XmlElement | null;
|
|
12
12
|
/**
|
|
13
|
-
* Finds a direct `w14:localName` child
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* `getChildrenByTagNameNS` would not contain w14 elements, so a separate
|
|
17
|
-
* helper is needed for these extension elements.
|
|
13
|
+
* Finds a direct `w14:localName` child using a Markup Compatibility capability
|
|
14
|
+
* profile that explicitly understands the w14 namespace. The generic child
|
|
15
|
+
* helpers remain conservative and continue to consume mc:Fallback instead.
|
|
18
16
|
*/
|
|
19
17
|
export declare function getFirstW14Child(element: XmlElement | null | undefined, localName: string): XmlElement | null;
|
|
20
18
|
export declare function getAttributeValue(element: XmlElement | null, localName: string): string | null;
|