@viveeditor/docx 0.0.0-stage → 0.1.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 viveEditor contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,28 @@
1
- # Temporary Holding Version
1
+ # @viveeditor/docx
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Word (.docx) import and export for viveEditor, with limits for untrusted files.
4
+
5
+ Part of [viveEditor](https://github.com/mtvrkan/viveeditor#readme), a free, open-source rich text editor.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install @viveeditor/docx @viveeditor/core
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { exportDocx, importDocx } from '@viveeditor/docx'
17
+
18
+ const { html, warnings } = await importDocx(file, { upload })
19
+ editor.commands.replaceContent(html)
20
+
21
+ const blob = await exportDocx(editor, { title: 'Report' })
22
+ ```
23
+
24
+ Files over 20 MB, password-protected files and files that unpack too large or too deep are refused with a `DocxError`. See [Word (.docx)](https://github.com/mtvrkan/viveeditor#word-docx) for what is kept.
25
+
26
+ ## License
27
+
28
+ MIT
@@ -0,0 +1,55 @@
1
+ import { ImageSourcePolicy, ImageUploader } from "@viveeditor/ext-image";
2
+ import { Schema } from "prosemirror-model";
3
+ type DocxErrorCode = "TOO_LARGE" | "NOT_DOCX" | "ENCRYPTED" | "UNSUPPORTED" | "DAMAGED" | "TOO_COMPLEX" | "ABORTED";
4
+ export declare class DocxError extends Error {
5
+ readonly code: DocxErrorCode;
6
+ constructor(code: DocxErrorCode, message: string);
7
+ }
8
+ interface ImportLimits {
9
+ fileBytes: number;
10
+ totalBytes: number;
11
+ documentBytes: number;
12
+ partBytes: number;
13
+ imageBytes: number;
14
+ images: number;
15
+ imagePixels: number;
16
+ elements: number;
17
+ cells: number;
18
+ }
19
+ interface ImportOptions {
20
+ upload?: ImageUploader | null;
21
+ allowBase64?: boolean;
22
+ imagePolicy?: Partial<ImageSourcePolicy>;
23
+ signal?: AbortSignal;
24
+ limits?: Partial<ImportLimits>;
25
+ }
26
+ type ImportWarningCode = "HIDDEN_TEXT" | "IMAGE_DROPPED" | "LINK_DROPPED" | "OBJECT_DROPPED" | "NESTING_FLATTENED";
27
+ interface ImportWarning {
28
+ code: ImportWarningCode;
29
+ count: number;
30
+ }
31
+ interface DocxImport {
32
+ html: string;
33
+ warnings: ImportWarning[];
34
+ }
35
+ export declare const DEFAULT_IMPORT_LIMITS: Readonly<ImportLimits>;
36
+ export declare function importDocx(file: Blob, options?: ImportOptions): Promise<DocxImport>;
37
+ interface ExportSource {
38
+ readonly schema: Schema;
39
+ getJSON(): unknown;
40
+ }
41
+ interface ExportOptions {
42
+ title?: string;
43
+ fetchImages?: boolean;
44
+ signal?: AbortSignal;
45
+ limits?: Partial<ExportLimits>;
46
+ }
47
+ interface ExportLimits {
48
+ imageBytes: number;
49
+ images: number;
50
+ timeout: number;
51
+ }
52
+ export declare const DOCX_MIME = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
53
+ export declare function exportDocx(source: ExportSource, options?: ExportOptions): Promise<Blob>;
54
+ export type { DocxErrorCode, DocxImport, ExportLimits, ExportOptions, ExportSource, ImportLimits, ImportOptions, ImportWarning, ImportWarningCode };
55
+ //# sourceMappingURL=index.d.ts.map