@pixerate/editor 0.24.0 → 0.26.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.
Files changed (162) hide show
  1. package/README.md +101 -1
  2. package/THIRD_PARTY_NOTICES.md +40 -0
  3. package/dist/agent/index.cjs +175 -11
  4. package/dist/agent/index.cjs.map +1 -1
  5. package/dist/agent/index.d.cts +18 -4
  6. package/dist/agent/index.d.ts +18 -4
  7. package/dist/agent/index.js +168 -4
  8. package/dist/agent/index.js.map +1 -1
  9. package/dist/{arrangeShortcuts-B8O3f8-P.d.cts → arrange-BICutYPk.d.cts} +243 -29
  10. package/dist/{arrangeShortcuts-sLlD2rSX.d.ts → arrange-BICutYPk.d.ts} +243 -29
  11. package/dist/builtins-CdPcLwwF.d.cts +176 -0
  12. package/dist/builtins-Chj6zv_O.d.ts +176 -0
  13. package/dist/canvas/index.cjs +8588 -1857
  14. package/dist/canvas/index.cjs.map +1 -1
  15. package/dist/canvas/index.d.cts +1847 -9
  16. package/dist/canvas/index.d.ts +1847 -9
  17. package/dist/canvas/index.js +8577 -1846
  18. package/dist/canvas/index.js.map +1 -1
  19. package/dist/chunk-3CC7OPUQ.cjs +831 -0
  20. package/dist/chunk-3CC7OPUQ.cjs.map +1 -0
  21. package/dist/chunk-4BVP64JJ.cjs +1406 -0
  22. package/dist/chunk-4BVP64JJ.cjs.map +1 -0
  23. package/dist/chunk-BVP3TSLH.cjs +69 -0
  24. package/dist/chunk-BVP3TSLH.cjs.map +1 -0
  25. package/dist/{chunk-OLZJXL4R.cjs → chunk-CS6NZWWA.cjs} +59 -25
  26. package/dist/chunk-CS6NZWWA.cjs.map +1 -0
  27. package/dist/{chunk-MCSJFWAO.cjs → chunk-EWCOFSCQ.cjs} +685 -100
  28. package/dist/chunk-EWCOFSCQ.cjs.map +1 -0
  29. package/dist/chunk-HDYMLS3X.cjs +409 -0
  30. package/dist/chunk-HDYMLS3X.cjs.map +1 -0
  31. package/dist/chunk-HRMEDT2L.js +1406 -0
  32. package/dist/chunk-HRMEDT2L.js.map +1 -0
  33. package/dist/{chunk-D27YFC46.cjs → chunk-IFHKKVXH.cjs} +382 -63
  34. package/dist/chunk-IFHKKVXH.cjs.map +1 -0
  35. package/dist/{chunk-PGNZKFQS.js → chunk-JOIREKL7.js} +137 -58
  36. package/dist/chunk-JOIREKL7.js.map +1 -0
  37. package/dist/chunk-KRGXUQ2Y.js +1696 -0
  38. package/dist/chunk-KRGXUQ2Y.js.map +1 -0
  39. package/dist/{chunk-3LV6RRPH.js → chunk-MHEPLBFB.js} +2 -2
  40. package/dist/chunk-MR2764X2.js +831 -0
  41. package/dist/chunk-MR2764X2.js.map +1 -0
  42. package/dist/{chunk-XNORY7M6.cjs → chunk-NFVBT3UZ.cjs} +166 -87
  43. package/dist/chunk-NFVBT3UZ.cjs.map +1 -0
  44. package/dist/chunk-NQF32I6Z.cjs +6478 -0
  45. package/dist/chunk-NQF32I6Z.cjs.map +1 -0
  46. package/dist/chunk-O5RYH2PG.js +69 -0
  47. package/dist/chunk-O5RYH2PG.js.map +1 -0
  48. package/dist/{chunk-ITBSKI26.js → chunk-Q2OHWD2A.js} +1064 -360
  49. package/dist/chunk-Q2OHWD2A.js.map +1 -0
  50. package/dist/{chunk-FODNLX5N.js → chunk-QJSOZFCZ.js} +38 -4
  51. package/dist/chunk-QJSOZFCZ.js.map +1 -0
  52. package/dist/{chunk-SML64VJG.cjs → chunk-RRREAOVM.cjs} +4 -4
  53. package/dist/{chunk-SML64VJG.cjs.map → chunk-RRREAOVM.cjs.map} +1 -1
  54. package/dist/{chunk-5S3Z4PPF.js → chunk-SWE3NPOU.js} +347 -28
  55. package/dist/chunk-SWE3NPOU.js.map +1 -0
  56. package/dist/chunk-TXXNBDQX.cjs +1696 -0
  57. package/dist/chunk-TXXNBDQX.cjs.map +1 -0
  58. package/dist/chunk-UBCFIABU.js +409 -0
  59. package/dist/chunk-UBCFIABU.js.map +1 -0
  60. package/dist/chunk-X7HXL2SB.js +6478 -0
  61. package/dist/chunk-X7HXL2SB.js.map +1 -0
  62. package/dist/{chunk-SBCZ6RN5.cjs → chunk-YOMYSFJU.cjs} +1163 -459
  63. package/dist/chunk-YOMYSFJU.cjs.map +1 -0
  64. package/dist/{chunk-3CN2WD3X.js → chunk-ZRNHGAQT.js} +661 -76
  65. package/dist/chunk-ZRNHGAQT.js.map +1 -0
  66. package/dist/commands/index.cjs +425 -4
  67. package/dist/commands/index.cjs.map +1 -1
  68. package/dist/commands/index.d.cts +39 -77
  69. package/dist/commands/index.d.ts +39 -77
  70. package/dist/commands/index.js +424 -3
  71. package/dist/commands/index.js.map +1 -1
  72. package/dist/compare/index.cjs +3 -3
  73. package/dist/compare/index.d.cts +1 -1
  74. package/dist/compare/index.d.ts +1 -1
  75. package/dist/compare/index.js +2 -2
  76. package/dist/controller-CxXGOEmy.d.cts +2038 -0
  77. package/dist/controller-CxXGOEmy.d.ts +2038 -0
  78. package/dist/{documents-BQjzJNe2.d.ts → documents-CHT1U5Vs.d.ts} +10 -0
  79. package/dist/{documents-KRTPhvst.d.cts → documents-Gp7wb0Me.d.cts} +10 -0
  80. package/dist/export/index.cjs +36 -0
  81. package/dist/export/index.cjs.map +1 -0
  82. package/dist/export/index.d.cts +243 -0
  83. package/dist/export/index.d.ts +243 -0
  84. package/dist/export/index.js +36 -0
  85. package/dist/export/index.js.map +1 -0
  86. package/dist/extensions/index.cjs +101 -6
  87. package/dist/extensions/index.cjs.map +1 -1
  88. package/dist/extensions/index.d.cts +18 -5
  89. package/dist/extensions/index.d.ts +18 -5
  90. package/dist/extensions/index.js +101 -6
  91. package/dist/generation/index.cjs +1013 -69
  92. package/dist/generation/index.cjs.map +1 -1
  93. package/dist/generation/index.d.cts +474 -13
  94. package/dist/generation/index.d.ts +474 -13
  95. package/dist/generation/index.js +976 -32
  96. package/dist/generation/index.js.map +1 -1
  97. package/dist/image-editor/index.cjs +3385 -1275
  98. package/dist/image-editor/index.cjs.map +1 -1
  99. package/dist/image-editor/index.d.cts +693 -128
  100. package/dist/image-editor/index.d.ts +693 -128
  101. package/dist/image-editor/index.js +3325 -1215
  102. package/dist/image-editor/index.js.map +1 -1
  103. package/dist/{index-fJrlkJCd.d.ts → index-B273Zllk.d.ts} +500 -7
  104. package/dist/{index-BhJBSm2d.d.cts → index-jcJwmBYt.d.cts} +500 -7
  105. package/dist/index.cjs +1603 -45
  106. package/dist/index.cjs.map +1 -1
  107. package/dist/index.d.cts +154 -27
  108. package/dist/index.d.ts +154 -27
  109. package/dist/index.js +1584 -26
  110. package/dist/index.js.map +1 -1
  111. package/dist/mention-text-CDnCFd3c.d.cts +53 -0
  112. package/dist/mention-text-CDnCFd3c.d.ts +53 -0
  113. package/dist/model-C1zApQM8.d.cts +219 -0
  114. package/dist/model-C1zApQM8.d.ts +219 -0
  115. package/dist/persistence/index.d.cts +3 -120
  116. package/dist/persistence/index.d.ts +3 -120
  117. package/dist/registry-CED5C0lA.d.cts +204 -0
  118. package/dist/registry-CED5C0lA.d.ts +204 -0
  119. package/dist/{registry-GJI4gToU.d.cts → registry-CEgwXED1.d.cts} +12 -1
  120. package/dist/{registry-GJI4gToU.d.ts → registry-CEgwXED1.d.ts} +12 -1
  121. package/dist/{registry-D32LpIc4.d.cts → registry-D0GADKc7.d.cts} +1 -1
  122. package/dist/{registry-evKTP4ls.d.ts → registry-DhVUZioj.d.ts} +1 -1
  123. package/dist/serializers/index.cjs +12 -4
  124. package/dist/serializers/index.cjs.map +1 -1
  125. package/dist/serializers/index.d.cts +41 -13
  126. package/dist/serializers/index.d.ts +41 -13
  127. package/dist/serializers/index.js +12 -4
  128. package/dist/spreadsheet/index.cjs +157 -3
  129. package/dist/spreadsheet/index.cjs.map +1 -1
  130. package/dist/spreadsheet/index.d.cts +534 -11
  131. package/dist/spreadsheet/index.d.ts +534 -11
  132. package/dist/spreadsheet/index.js +157 -3
  133. package/dist/storage-BpFfspHm.d.cts +120 -0
  134. package/dist/storage-BpFfspHm.d.ts +120 -0
  135. package/dist/tokens/index.cjs +115 -0
  136. package/dist/tokens/index.cjs.map +1 -0
  137. package/dist/tokens/index.d.cts +212 -0
  138. package/dist/tokens/index.d.ts +212 -0
  139. package/dist/tokens/index.js +115 -0
  140. package/dist/tokens/index.js.map +1 -0
  141. package/dist/{track-changes-BK5sVf4_.d.cts → track-changes-D_VAPELi.d.cts} +95 -11
  142. package/dist/{track-changes-CDjCrwKe.d.ts → track-changes-Db_fGEvx.d.ts} +95 -11
  143. package/package.json +15 -1
  144. package/dist/chunk-3CN2WD3X.js.map +0 -1
  145. package/dist/chunk-5S3Z4PPF.js.map +0 -1
  146. package/dist/chunk-D27YFC46.cjs.map +0 -1
  147. package/dist/chunk-FODNLX5N.js.map +0 -1
  148. package/dist/chunk-ITBSKI26.js.map +0 -1
  149. package/dist/chunk-MA2F5KHF.cjs +0 -3223
  150. package/dist/chunk-MA2F5KHF.cjs.map +0 -1
  151. package/dist/chunk-MCSJFWAO.cjs.map +0 -1
  152. package/dist/chunk-OLZJXL4R.cjs.map +0 -1
  153. package/dist/chunk-PGNZKFQS.js.map +0 -1
  154. package/dist/chunk-SBCZ6RN5.cjs.map +0 -1
  155. package/dist/chunk-U5KWZU4X.js +0 -3223
  156. package/dist/chunk-U5KWZU4X.js.map +0 -1
  157. package/dist/chunk-XNORY7M6.cjs.map +0 -1
  158. package/dist/controller-BhLLAoi8.d.cts +0 -1000
  159. package/dist/controller-BhLLAoi8.d.ts +0 -1000
  160. package/dist/types-DX4Mh4SL.d.cts +0 -217
  161. package/dist/types-DX4Mh4SL.d.ts +0 -217
  162. /package/dist/{chunk-3LV6RRPH.js.map → chunk-MHEPLBFB.js.map} +0 -0
@@ -29,6 +29,14 @@ interface CompareDocumentsOptions {
29
29
  * at `granularity: "char"`. Default 2000.
30
30
  */
31
31
  maxCharDiff?: number;
32
+ /**
33
+ * Record a top-level paragraph that was deleted in one place and inserted,
34
+ * identical, elsewhere as a tracked move (`type: "move"`) instead of a
35
+ * whole-block deletion and insertion. Only paragraphs whose content occurs
36
+ * once among the deleted and once among the inserted blocks are paired.
37
+ * Default `false`.
38
+ */
39
+ detectMoves?: boolean;
32
40
  }
33
41
  interface CompareSummary {
34
42
  /** Inserted text runs and inserted block runs. */
@@ -39,6 +47,8 @@ interface CompareSummary {
39
47
  formatChanges: number;
40
48
  /** Block type, attribute and wrapping changes. */
41
49
  blockChanges: number;
50
+ /** Moved paragraphs (with `detectMoves`). */
51
+ moves: number;
42
52
  /** Differences the result could not represent as tracked changes. */
43
53
  notHonoured: string[];
44
54
  }
@@ -29,6 +29,14 @@ interface CompareDocumentsOptions {
29
29
  * at `granularity: "char"`. Default 2000.
30
30
  */
31
31
  maxCharDiff?: number;
32
+ /**
33
+ * Record a top-level paragraph that was deleted in one place and inserted,
34
+ * identical, elsewhere as a tracked move (`type: "move"`) instead of a
35
+ * whole-block deletion and insertion. Only paragraphs whose content occurs
36
+ * once among the deleted and once among the inserted blocks are paired.
37
+ * Default `false`.
38
+ */
39
+ detectMoves?: boolean;
32
40
  }
33
41
  interface CompareSummary {
34
42
  /** Inserted text runs and inserted block runs. */
@@ -39,6 +47,8 @@ interface CompareSummary {
39
47
  formatChanges: number;
40
48
  /** Block type, attribute and wrapping changes. */
41
49
  blockChanges: number;
50
+ /** Moved paragraphs (with `detectMoves`). */
51
+ moves: number;
42
52
  /** Differences the result could not represent as tracked changes. */
43
53
  notHonoured: string[];
44
54
  }
@@ -0,0 +1,36 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+ var _chunkTXXNBDQXcjs = require('../chunk-TXXNBDQX.cjs');
18
+ require('../chunk-3CC7OPUQ.cjs');
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+ exports.DOCX_ANONYMOUS_AUTHOR = _chunkTXXNBDQXcjs.DOCX_ANONYMOUS_AUTHOR; exports.DOCX_EXPORT_MIME_TYPE = _chunkTXXNBDQXcjs.DOCX_EXPORT_MIME_TYPE; exports.DocxExportController = _chunkTXXNBDQXcjs.DocxExportController; exports.XmlWriter = _chunkTXXNBDQXcjs.XmlWriter; exports.createDocxExportController = _chunkTXXNBDQXcjs.createDocxExportController; exports.createDocxParts = _chunkTXXNBDQXcjs.createDocxParts; exports.deflateRaw = _chunkTXXNBDQXcjs.deflateRaw; exports.docxFileName = _chunkTXXNBDQXcjs.docxFileName; exports.downloadBlob = _chunkTXXNBDQXcjs.downloadBlob; exports.escapeXmlAttr = _chunkTXXNBDQXcjs.escapeXmlAttr; exports.escapeXmlText = _chunkTXXNBDQXcjs.escapeXmlText; exports.exportDocx = _chunkTXXNBDQXcjs.exportDocx; exports.exportDocxBlob = _chunkTXXNBDQXcjs.exportDocxBlob; exports.stripInvalidXmlChars = _chunkTXXNBDQXcjs.stripInvalidXmlChars; exports.writeZip = _chunkTXXNBDQXcjs.writeZip;
36
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/export/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,g5BAAC","file":"/home/runner/work/editor/editor/packages/core/dist/export/index.cjs"}
@@ -0,0 +1,243 @@
1
+ import { S as SerializedComments, f as CommentThread, R as ReviewAuthor } from '../comment-store-BEMgVlAA.cjs';
2
+ import { e as StyleRegistry, f as StyleRegistryJSON, c as StyleDefinition } from '../registry-CED5C0lA.cjs';
3
+
4
+ /**
5
+ * Dependency-free DOCX (WordprocessingML) export of TipTap documents.
6
+ *
7
+ * Takes an editor (anything with `getJSON()`) or its JSON and writes a
8
+ * minimal, valid package: `[Content_Types].xml`, `_rels/.rels`,
9
+ * `word/document.xml` (+ relationships), `styles.xml` (from the paragraph
10
+ * style registry, with `basedOn` / `next` / `link`), `numbering.xml` (one
11
+ * `w:num` per list), `settings.xml`, `comments.xml` +
12
+ * `commentsExtended.xml` (replies and resolved state) + `people.xml` (author
13
+ * ids), `docProps/core.xml` and `docProps/app.xml`, plus embedded images.
14
+ *
15
+ * Tracked insertions, deletions, moves (`w:moveFrom` / `w:moveTo` with
16
+ * named move ranges), formatting changes (`w:rPrChange`) and block changes
17
+ * (`w:pPrChange`, paragraph-mark `w:ins` / `w:del`) keep their authors and
18
+ * dates. Anything that cannot be written is listed in the returned report.
19
+ */
20
+ declare const DOCX_EXPORT_MIME_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
21
+ /** A ProseMirror / TipTap JSON node (`editor.getJSON()`). */
22
+ interface DocxJSONNode {
23
+ type?: string;
24
+ attrs?: Record<string, any>;
25
+ content?: DocxJSONNode[];
26
+ marks?: DocxJSONMark[];
27
+ text?: string;
28
+ }
29
+ interface DocxJSONMark {
30
+ type: string;
31
+ attrs?: Record<string, any>;
32
+ }
33
+ /** Anything with `getJSON()`, e.g. a TipTap `Editor`. Its comment store and style registry are used by default. */
34
+ interface DocxExportEditorLike {
35
+ getJSON(): DocxJSONNode;
36
+ storage?: unknown;
37
+ }
38
+ /** A comment store (`CommentStore`), its `toJSON()` output, or a thread list. */
39
+ type DocxCommentSource = {
40
+ toJSON(): SerializedComments;
41
+ } | {
42
+ getSnapshot(): {
43
+ threads: readonly CommentThread[];
44
+ };
45
+ } | SerializedComments | readonly CommentThread[];
46
+ interface DocxExportOptions {
47
+ /**
48
+ * Paragraph and character styles written to `styles.xml`. Defaults to the
49
+ * editor's registry (`ParagraphStyles` extension), else the built-in styles.
50
+ */
51
+ styles?: StyleRegistry | StyleRegistryJSON | readonly StyleDefinition[];
52
+ /** Comment threads. Defaults to the editor's comment store (`Comments` extension). */
53
+ comments?: DocxCommentSource | null;
54
+ /**
55
+ * The document's author (`dc:creator`) and the author of tracked changes
56
+ * and comments that name none.
57
+ */
58
+ author?: string | ReviewAuthor;
59
+ /**
60
+ * `"strip-authors"` writes every comment, reply and tracked change as
61
+ * "Author" (initials "A"), leaves out `people.xml`, the creator and last
62
+ * modified by, and sets `w:removePersonalInformation` so Word keeps doing
63
+ * so. Default `"keep"`.
64
+ */
65
+ privacy?: "keep" | "strip-authors";
66
+ /** `dc:title` of the document. */
67
+ title?: string;
68
+ /**
69
+ * Images with `http(s)` URLs: `"skip"` (default, reported) or `"link"`
70
+ * (an external relationship Word may load when the file is opened).
71
+ */
72
+ remoteImages?: "skip" | "link";
73
+ /** Time written as created / modified (default: now). */
74
+ now?: () => Date;
75
+ /** ZIP compression (default `"auto"`: deflate when `CompressionStream` exists). */
76
+ compression?: "auto" | "store";
77
+ }
78
+ type DocxExportIssueKind = "node" | "mark" | "image" | "link" | "comment" | "style";
79
+ /** Something the export left out or simplified, counted per kind, name and reason. */
80
+ interface DocxExportIssue {
81
+ kind: DocxExportIssueKind;
82
+ /** Node / mark type, style id, image or link URL (truncated), or comment thread id. */
83
+ name: string;
84
+ reason: string;
85
+ count: number;
86
+ }
87
+ interface DocxExportReport {
88
+ /** Content that was dropped or simplified. Empty when everything was written. */
89
+ dropped: DocxExportIssue[];
90
+ /** Counts of what was written. */
91
+ written: {
92
+ paragraphs: number;
93
+ tables: number;
94
+ images: number;
95
+ comments: number;
96
+ replies: number;
97
+ trackedChanges: number;
98
+ };
99
+ }
100
+ interface DocxExportResult {
101
+ /** The `.docx` file. */
102
+ data: Uint8Array;
103
+ report: DocxExportReport;
104
+ }
105
+ interface DocxPackagePart {
106
+ name: string;
107
+ data: Uint8Array | string;
108
+ }
109
+ /** Name written for every author with `privacy: "strip-authors"` (as Word does). */
110
+ declare const DOCX_ANONYMOUS_AUTHOR = "Author";
111
+ /**
112
+ * Builds the package parts of a DOCX file without zipping them (synchronous;
113
+ * useful for inspection and tests). See {@link exportDocx}.
114
+ */
115
+ declare function createDocxParts(input: DocxExportEditorLike | DocxJSONNode, options?: DocxExportOptions): {
116
+ parts: DocxPackagePart[];
117
+ report: DocxExportReport;
118
+ };
119
+ /**
120
+ * Exports an editor (or its JSON) as a Word document. Resolves with the file
121
+ * bytes and a report of what was dropped. Never fetches anything: remote
122
+ * images are skipped (or linked with `remoteImages: "link"`).
123
+ */
124
+ declare function exportDocx(input: DocxExportEditorLike | DocxJSONNode, options?: DocxExportOptions): Promise<DocxExportResult>;
125
+ /** Like {@link exportDocx}, but resolves with a `Blob` of type {@link DOCX_EXPORT_MIME_TYPE}. */
126
+ declare function exportDocxBlob(input: DocxExportEditorLike | DocxJSONNode, options?: DocxExportOptions): Promise<{
127
+ blob: Blob;
128
+ report: DocxExportReport;
129
+ }>;
130
+
131
+ /**
132
+ * Saves a `Blob` as a file through a temporary `<a download>` link. Does
133
+ * nothing (returns `false`) without a DOM.
134
+ */
135
+ declare function downloadBlob(blob: Blob, fileName: string): boolean;
136
+ /** `name.docx`, with characters that are invalid in file names replaced. */
137
+ declare function docxFileName(name: string | undefined): string;
138
+ interface DocxExportState {
139
+ isExporting: boolean;
140
+ /** Last export error (cleared when a new export starts). */
141
+ error: Error | null;
142
+ /** Report of the most recent successful export. */
143
+ lastReport: DocxExportReport | null;
144
+ }
145
+ interface DocxExportControllerOptions extends DocxExportOptions {
146
+ /** Download file name (default: `title`, else `document`, plus `.docx`). */
147
+ fileName?: string;
148
+ /** Called after each successful export with its report. */
149
+ onExport?: (report: DocxExportReport, blob: Blob) => void;
150
+ /** Called when an export fails (the error is also kept in the state). */
151
+ onError?: (error: Error) => void;
152
+ }
153
+ /**
154
+ * Framework-agnostic state for an "Export to Word" button: tracks
155
+ * `isExporting` / `error` / `lastReport` and downloads the `.docx` of the
156
+ * editor returned by `getSource`. React's `useDocxExport` and Svelte's
157
+ * `createDocxExport` wrap it.
158
+ */
159
+ declare class DocxExportController {
160
+ private readonly getSource;
161
+ private options;
162
+ private state;
163
+ private readonly listeners;
164
+ private pending;
165
+ constructor(getSource: () => DocxExportEditorLike | DocxJSONNode | null | undefined, options?: DocxExportControllerOptions);
166
+ setOptions(options: DocxExportControllerOptions): void;
167
+ getState: () => DocxExportState;
168
+ subscribe: (listener: (state: DocxExportState) => void) => (() => void);
169
+ private setState;
170
+ /** Builds the `.docx` without downloading it. Resolves with `null` when there is no editor or it fails. */
171
+ exportBlob(): Promise<{
172
+ blob: Blob;
173
+ report: DocxExportReport;
174
+ } | null>;
175
+ /** Exports and downloads the document. Resolves with the report, or `null`. */
176
+ download(fileName?: string): Promise<DocxExportReport | null>;
177
+ }
178
+ declare function createDocxExportController(getSource: () => DocxExportEditorLike | DocxJSONNode | null | undefined, options?: DocxExportControllerOptions): DocxExportController;
179
+
180
+ /**
181
+ * Minimal, dependency-free ZIP writer (the counterpart of `readZip`), used by
182
+ * the DOCX export. Entries are deflated with the platform
183
+ * `CompressionStream("deflate-raw")` when it exists (modern browsers,
184
+ * Node ≥ 18) and stored otherwise, or when deflating does not make them
185
+ * smaller. Names are written as UTF-8 (flag bit 11). No ZIP64: archives are
186
+ * limited to 65 535 entries and 4 GiB.
187
+ */
188
+ interface ZipWriteEntry {
189
+ /** Entry path with `/` separators; must be relative and free of `..`. */
190
+ name: string;
191
+ /** Strings are encoded as UTF-8. */
192
+ data: Uint8Array | string;
193
+ }
194
+ interface ZipWriteOptions {
195
+ /**
196
+ * `"auto"` (default) deflates when `CompressionStream` is available,
197
+ * `"store"` never compresses.
198
+ */
199
+ compression?: "auto" | "store";
200
+ /**
201
+ * Modification time written for every entry (default 1980-01-01, the DOS
202
+ * epoch, so the output is deterministic).
203
+ */
204
+ modified?: Date;
205
+ }
206
+ /** Raw deflate with `CompressionStream`, or `null` when it is unavailable. */
207
+ declare function deflateRaw(data: Uint8Array): Promise<Uint8Array | null>;
208
+ /** Writes a ZIP archive. Throws on unsafe or duplicate names and oversized archives. */
209
+ declare function writeZip(entries: readonly ZipWriteEntry[], options?: ZipWriteOptions): Promise<Uint8Array>;
210
+
211
+ /** Removes characters that are not allowed in XML 1.0 documents. */
212
+ declare function stripInvalidXmlChars(value: string): string;
213
+ /** Escapes text for XML element content (`&`, `<`, `>`), dropping invalid characters. */
214
+ declare function escapeXmlText(value: string): string;
215
+ /**
216
+ * Escapes a value for a double- or single-quoted XML attribute. White space
217
+ * other than spaces is written as character references, because attribute
218
+ * value normalisation would otherwise turn tabs and newlines into spaces.
219
+ */
220
+ declare function escapeXmlAttr(value: string): string;
221
+ type XmlAttrs = Record<string, string | number | undefined | null | false>;
222
+ /**
223
+ * A small string-building XML writer; every attribute value and text node is
224
+ * escaped. Element names are trusted (always literals in this codebase).
225
+ */
226
+ declare class XmlWriter {
227
+ private parts;
228
+ /** `declaration: false` writes a fragment (e.g. one paragraph). */
229
+ constructor(declaration?: boolean);
230
+ open(name: string, values?: XmlAttrs): this;
231
+ empty(name: string, values?: XmlAttrs): this;
232
+ close(name: string): this;
233
+ text(value: string): this;
234
+ /** `<name attrs>text</name>`. */
235
+ leaf(name: string, values: XmlAttrs | undefined, text: string): this;
236
+ /** `<name w:val="value"/>`. */
237
+ val(name: string, value: string | number): this;
238
+ /** Appends markup produced by another writer. */
239
+ raw(markup: string): this;
240
+ toString(): string;
241
+ }
242
+
243
+ export { DOCX_ANONYMOUS_AUTHOR, DOCX_EXPORT_MIME_TYPE, type DocxCommentSource, DocxExportController, type DocxExportControllerOptions, type DocxExportEditorLike, type DocxExportIssue, type DocxExportIssueKind, type DocxExportOptions, type DocxExportReport, type DocxExportResult, type DocxExportState, type DocxJSONMark, type DocxJSONNode, type DocxPackagePart, type XmlAttrs, XmlWriter, type ZipWriteEntry, type ZipWriteOptions, createDocxExportController, createDocxParts, deflateRaw, docxFileName, downloadBlob, escapeXmlAttr, escapeXmlText, exportDocx, exportDocxBlob, stripInvalidXmlChars, writeZip };
@@ -0,0 +1,243 @@
1
+ import { S as SerializedComments, f as CommentThread, R as ReviewAuthor } from '../comment-store-BEMgVlAA.js';
2
+ import { e as StyleRegistry, f as StyleRegistryJSON, c as StyleDefinition } from '../registry-CED5C0lA.js';
3
+
4
+ /**
5
+ * Dependency-free DOCX (WordprocessingML) export of TipTap documents.
6
+ *
7
+ * Takes an editor (anything with `getJSON()`) or its JSON and writes a
8
+ * minimal, valid package: `[Content_Types].xml`, `_rels/.rels`,
9
+ * `word/document.xml` (+ relationships), `styles.xml` (from the paragraph
10
+ * style registry, with `basedOn` / `next` / `link`), `numbering.xml` (one
11
+ * `w:num` per list), `settings.xml`, `comments.xml` +
12
+ * `commentsExtended.xml` (replies and resolved state) + `people.xml` (author
13
+ * ids), `docProps/core.xml` and `docProps/app.xml`, plus embedded images.
14
+ *
15
+ * Tracked insertions, deletions, moves (`w:moveFrom` / `w:moveTo` with
16
+ * named move ranges), formatting changes (`w:rPrChange`) and block changes
17
+ * (`w:pPrChange`, paragraph-mark `w:ins` / `w:del`) keep their authors and
18
+ * dates. Anything that cannot be written is listed in the returned report.
19
+ */
20
+ declare const DOCX_EXPORT_MIME_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
21
+ /** A ProseMirror / TipTap JSON node (`editor.getJSON()`). */
22
+ interface DocxJSONNode {
23
+ type?: string;
24
+ attrs?: Record<string, any>;
25
+ content?: DocxJSONNode[];
26
+ marks?: DocxJSONMark[];
27
+ text?: string;
28
+ }
29
+ interface DocxJSONMark {
30
+ type: string;
31
+ attrs?: Record<string, any>;
32
+ }
33
+ /** Anything with `getJSON()`, e.g. a TipTap `Editor`. Its comment store and style registry are used by default. */
34
+ interface DocxExportEditorLike {
35
+ getJSON(): DocxJSONNode;
36
+ storage?: unknown;
37
+ }
38
+ /** A comment store (`CommentStore`), its `toJSON()` output, or a thread list. */
39
+ type DocxCommentSource = {
40
+ toJSON(): SerializedComments;
41
+ } | {
42
+ getSnapshot(): {
43
+ threads: readonly CommentThread[];
44
+ };
45
+ } | SerializedComments | readonly CommentThread[];
46
+ interface DocxExportOptions {
47
+ /**
48
+ * Paragraph and character styles written to `styles.xml`. Defaults to the
49
+ * editor's registry (`ParagraphStyles` extension), else the built-in styles.
50
+ */
51
+ styles?: StyleRegistry | StyleRegistryJSON | readonly StyleDefinition[];
52
+ /** Comment threads. Defaults to the editor's comment store (`Comments` extension). */
53
+ comments?: DocxCommentSource | null;
54
+ /**
55
+ * The document's author (`dc:creator`) and the author of tracked changes
56
+ * and comments that name none.
57
+ */
58
+ author?: string | ReviewAuthor;
59
+ /**
60
+ * `"strip-authors"` writes every comment, reply and tracked change as
61
+ * "Author" (initials "A"), leaves out `people.xml`, the creator and last
62
+ * modified by, and sets `w:removePersonalInformation` so Word keeps doing
63
+ * so. Default `"keep"`.
64
+ */
65
+ privacy?: "keep" | "strip-authors";
66
+ /** `dc:title` of the document. */
67
+ title?: string;
68
+ /**
69
+ * Images with `http(s)` URLs: `"skip"` (default, reported) or `"link"`
70
+ * (an external relationship Word may load when the file is opened).
71
+ */
72
+ remoteImages?: "skip" | "link";
73
+ /** Time written as created / modified (default: now). */
74
+ now?: () => Date;
75
+ /** ZIP compression (default `"auto"`: deflate when `CompressionStream` exists). */
76
+ compression?: "auto" | "store";
77
+ }
78
+ type DocxExportIssueKind = "node" | "mark" | "image" | "link" | "comment" | "style";
79
+ /** Something the export left out or simplified, counted per kind, name and reason. */
80
+ interface DocxExportIssue {
81
+ kind: DocxExportIssueKind;
82
+ /** Node / mark type, style id, image or link URL (truncated), or comment thread id. */
83
+ name: string;
84
+ reason: string;
85
+ count: number;
86
+ }
87
+ interface DocxExportReport {
88
+ /** Content that was dropped or simplified. Empty when everything was written. */
89
+ dropped: DocxExportIssue[];
90
+ /** Counts of what was written. */
91
+ written: {
92
+ paragraphs: number;
93
+ tables: number;
94
+ images: number;
95
+ comments: number;
96
+ replies: number;
97
+ trackedChanges: number;
98
+ };
99
+ }
100
+ interface DocxExportResult {
101
+ /** The `.docx` file. */
102
+ data: Uint8Array;
103
+ report: DocxExportReport;
104
+ }
105
+ interface DocxPackagePart {
106
+ name: string;
107
+ data: Uint8Array | string;
108
+ }
109
+ /** Name written for every author with `privacy: "strip-authors"` (as Word does). */
110
+ declare const DOCX_ANONYMOUS_AUTHOR = "Author";
111
+ /**
112
+ * Builds the package parts of a DOCX file without zipping them (synchronous;
113
+ * useful for inspection and tests). See {@link exportDocx}.
114
+ */
115
+ declare function createDocxParts(input: DocxExportEditorLike | DocxJSONNode, options?: DocxExportOptions): {
116
+ parts: DocxPackagePart[];
117
+ report: DocxExportReport;
118
+ };
119
+ /**
120
+ * Exports an editor (or its JSON) as a Word document. Resolves with the file
121
+ * bytes and a report of what was dropped. Never fetches anything: remote
122
+ * images are skipped (or linked with `remoteImages: "link"`).
123
+ */
124
+ declare function exportDocx(input: DocxExportEditorLike | DocxJSONNode, options?: DocxExportOptions): Promise<DocxExportResult>;
125
+ /** Like {@link exportDocx}, but resolves with a `Blob` of type {@link DOCX_EXPORT_MIME_TYPE}. */
126
+ declare function exportDocxBlob(input: DocxExportEditorLike | DocxJSONNode, options?: DocxExportOptions): Promise<{
127
+ blob: Blob;
128
+ report: DocxExportReport;
129
+ }>;
130
+
131
+ /**
132
+ * Saves a `Blob` as a file through a temporary `<a download>` link. Does
133
+ * nothing (returns `false`) without a DOM.
134
+ */
135
+ declare function downloadBlob(blob: Blob, fileName: string): boolean;
136
+ /** `name.docx`, with characters that are invalid in file names replaced. */
137
+ declare function docxFileName(name: string | undefined): string;
138
+ interface DocxExportState {
139
+ isExporting: boolean;
140
+ /** Last export error (cleared when a new export starts). */
141
+ error: Error | null;
142
+ /** Report of the most recent successful export. */
143
+ lastReport: DocxExportReport | null;
144
+ }
145
+ interface DocxExportControllerOptions extends DocxExportOptions {
146
+ /** Download file name (default: `title`, else `document`, plus `.docx`). */
147
+ fileName?: string;
148
+ /** Called after each successful export with its report. */
149
+ onExport?: (report: DocxExportReport, blob: Blob) => void;
150
+ /** Called when an export fails (the error is also kept in the state). */
151
+ onError?: (error: Error) => void;
152
+ }
153
+ /**
154
+ * Framework-agnostic state for an "Export to Word" button: tracks
155
+ * `isExporting` / `error` / `lastReport` and downloads the `.docx` of the
156
+ * editor returned by `getSource`. React's `useDocxExport` and Svelte's
157
+ * `createDocxExport` wrap it.
158
+ */
159
+ declare class DocxExportController {
160
+ private readonly getSource;
161
+ private options;
162
+ private state;
163
+ private readonly listeners;
164
+ private pending;
165
+ constructor(getSource: () => DocxExportEditorLike | DocxJSONNode | null | undefined, options?: DocxExportControllerOptions);
166
+ setOptions(options: DocxExportControllerOptions): void;
167
+ getState: () => DocxExportState;
168
+ subscribe: (listener: (state: DocxExportState) => void) => (() => void);
169
+ private setState;
170
+ /** Builds the `.docx` without downloading it. Resolves with `null` when there is no editor or it fails. */
171
+ exportBlob(): Promise<{
172
+ blob: Blob;
173
+ report: DocxExportReport;
174
+ } | null>;
175
+ /** Exports and downloads the document. Resolves with the report, or `null`. */
176
+ download(fileName?: string): Promise<DocxExportReport | null>;
177
+ }
178
+ declare function createDocxExportController(getSource: () => DocxExportEditorLike | DocxJSONNode | null | undefined, options?: DocxExportControllerOptions): DocxExportController;
179
+
180
+ /**
181
+ * Minimal, dependency-free ZIP writer (the counterpart of `readZip`), used by
182
+ * the DOCX export. Entries are deflated with the platform
183
+ * `CompressionStream("deflate-raw")` when it exists (modern browsers,
184
+ * Node ≥ 18) and stored otherwise, or when deflating does not make them
185
+ * smaller. Names are written as UTF-8 (flag bit 11). No ZIP64: archives are
186
+ * limited to 65 535 entries and 4 GiB.
187
+ */
188
+ interface ZipWriteEntry {
189
+ /** Entry path with `/` separators; must be relative and free of `..`. */
190
+ name: string;
191
+ /** Strings are encoded as UTF-8. */
192
+ data: Uint8Array | string;
193
+ }
194
+ interface ZipWriteOptions {
195
+ /**
196
+ * `"auto"` (default) deflates when `CompressionStream` is available,
197
+ * `"store"` never compresses.
198
+ */
199
+ compression?: "auto" | "store";
200
+ /**
201
+ * Modification time written for every entry (default 1980-01-01, the DOS
202
+ * epoch, so the output is deterministic).
203
+ */
204
+ modified?: Date;
205
+ }
206
+ /** Raw deflate with `CompressionStream`, or `null` when it is unavailable. */
207
+ declare function deflateRaw(data: Uint8Array): Promise<Uint8Array | null>;
208
+ /** Writes a ZIP archive. Throws on unsafe or duplicate names and oversized archives. */
209
+ declare function writeZip(entries: readonly ZipWriteEntry[], options?: ZipWriteOptions): Promise<Uint8Array>;
210
+
211
+ /** Removes characters that are not allowed in XML 1.0 documents. */
212
+ declare function stripInvalidXmlChars(value: string): string;
213
+ /** Escapes text for XML element content (`&`, `<`, `>`), dropping invalid characters. */
214
+ declare function escapeXmlText(value: string): string;
215
+ /**
216
+ * Escapes a value for a double- or single-quoted XML attribute. White space
217
+ * other than spaces is written as character references, because attribute
218
+ * value normalisation would otherwise turn tabs and newlines into spaces.
219
+ */
220
+ declare function escapeXmlAttr(value: string): string;
221
+ type XmlAttrs = Record<string, string | number | undefined | null | false>;
222
+ /**
223
+ * A small string-building XML writer; every attribute value and text node is
224
+ * escaped. Element names are trusted (always literals in this codebase).
225
+ */
226
+ declare class XmlWriter {
227
+ private parts;
228
+ /** `declaration: false` writes a fragment (e.g. one paragraph). */
229
+ constructor(declaration?: boolean);
230
+ open(name: string, values?: XmlAttrs): this;
231
+ empty(name: string, values?: XmlAttrs): this;
232
+ close(name: string): this;
233
+ text(value: string): this;
234
+ /** `<name attrs>text</name>`. */
235
+ leaf(name: string, values: XmlAttrs | undefined, text: string): this;
236
+ /** `<name w:val="value"/>`. */
237
+ val(name: string, value: string | number): this;
238
+ /** Appends markup produced by another writer. */
239
+ raw(markup: string): this;
240
+ toString(): string;
241
+ }
242
+
243
+ export { DOCX_ANONYMOUS_AUTHOR, DOCX_EXPORT_MIME_TYPE, type DocxCommentSource, DocxExportController, type DocxExportControllerOptions, type DocxExportEditorLike, type DocxExportIssue, type DocxExportIssueKind, type DocxExportOptions, type DocxExportReport, type DocxExportResult, type DocxExportState, type DocxJSONMark, type DocxJSONNode, type DocxPackagePart, type XmlAttrs, XmlWriter, type ZipWriteEntry, type ZipWriteOptions, createDocxExportController, createDocxParts, deflateRaw, docxFileName, downloadBlob, escapeXmlAttr, escapeXmlText, exportDocx, exportDocxBlob, stripInvalidXmlChars, writeZip };
@@ -0,0 +1,36 @@
1
+ import {
2
+ DOCX_ANONYMOUS_AUTHOR,
3
+ DOCX_EXPORT_MIME_TYPE,
4
+ DocxExportController,
5
+ XmlWriter,
6
+ createDocxExportController,
7
+ createDocxParts,
8
+ deflateRaw,
9
+ docxFileName,
10
+ downloadBlob,
11
+ escapeXmlAttr,
12
+ escapeXmlText,
13
+ exportDocx,
14
+ exportDocxBlob,
15
+ stripInvalidXmlChars,
16
+ writeZip
17
+ } from "../chunk-KRGXUQ2Y.js";
18
+ import "../chunk-MR2764X2.js";
19
+ export {
20
+ DOCX_ANONYMOUS_AUTHOR,
21
+ DOCX_EXPORT_MIME_TYPE,
22
+ DocxExportController,
23
+ XmlWriter,
24
+ createDocxExportController,
25
+ createDocxParts,
26
+ deflateRaw,
27
+ docxFileName,
28
+ downloadBlob,
29
+ escapeXmlAttr,
30
+ escapeXmlText,
31
+ exportDocx,
32
+ exportDocxBlob,
33
+ stripInvalidXmlChars,
34
+ writeZip
35
+ };
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}