@coco-vexel/coco-office-editor 0.0.0-stage → 1.0.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 (57) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +510 -2
  3. package/THIRD_PARTY_NOTICES.md +212 -0
  4. package/dist/index.cjs +26401 -0
  5. package/dist/index.cjs.map +1 -0
  6. package/dist/index.d.cts +12 -0
  7. package/dist/index.d.ts +12 -0
  8. package/dist/index.js +26192 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/model-DB6aN6uJ.d.cts +321 -0
  11. package/dist/model-DB6aN6uJ.d.ts +321 -0
  12. package/dist/native-B6B649CC.d.ts +1111 -0
  13. package/dist/native-Ct9nN06K.d.cts +1111 -0
  14. package/dist/ppt-native.cjs +5334 -0
  15. package/dist/ppt-native.cjs.map +1 -0
  16. package/dist/ppt-native.d.cts +2 -0
  17. package/dist/ppt-native.d.ts +2 -0
  18. package/dist/ppt-native.js +5332 -0
  19. package/dist/ppt-native.js.map +1 -0
  20. package/dist/ppt.cjs +5426 -0
  21. package/dist/ppt.cjs.map +1 -0
  22. package/dist/ppt.d.cts +306 -0
  23. package/dist/ppt.d.ts +306 -0
  24. package/dist/ppt.js +5410 -0
  25. package/dist/ppt.js.map +1 -0
  26. package/dist/spreadsheet.cjs +4276 -0
  27. package/dist/spreadsheet.cjs.map +1 -0
  28. package/dist/spreadsheet.d.cts +676 -0
  29. package/dist/spreadsheet.d.ts +676 -0
  30. package/dist/spreadsheet.js +4213 -0
  31. package/dist/spreadsheet.js.map +1 -0
  32. package/dist/word-editing.cjs +812 -0
  33. package/dist/word-editing.cjs.map +1 -0
  34. package/dist/word-editing.d.cts +149 -0
  35. package/dist/word-editing.d.ts +149 -0
  36. package/dist/word-editing.js +803 -0
  37. package/dist/word-editing.js.map +1 -0
  38. package/dist/word-native.cjs +13400 -0
  39. package/dist/word-native.cjs.map +1 -0
  40. package/dist/word-native.d.cts +4 -0
  41. package/dist/word-native.d.ts +4 -0
  42. package/dist/word-native.js +13293 -0
  43. package/dist/word-native.js.map +1 -0
  44. package/dist/word-prosemirror.cjs +489 -0
  45. package/dist/word-prosemirror.cjs.map +1 -0
  46. package/dist/word-prosemirror.d.cts +21 -0
  47. package/dist/word-prosemirror.d.ts +21 -0
  48. package/dist/word-prosemirror.js +483 -0
  49. package/dist/word-prosemirror.js.map +1 -0
  50. package/dist/word.cjs +16764 -0
  51. package/dist/word.cjs.map +1 -0
  52. package/dist/word.d.cts +84 -0
  53. package/dist/word.d.ts +84 -0
  54. package/dist/word.js +16632 -0
  55. package/dist/word.js.map +1 -0
  56. package/package.json +106 -3
  57. package/src/styles/editor.css +1507 -0
@@ -0,0 +1,489 @@
1
+ 'use strict';
2
+
3
+ var prosemirrorModel = require('prosemirror-model');
4
+ var prosemirrorCommands = require('prosemirror-commands');
5
+ var prosemirrorKeymap = require('prosemirror-keymap');
6
+ var prosemirrorState = require('prosemirror-state');
7
+ var prosemirrorView = require('prosemirror-view');
8
+
9
+ var __defProp = Object.defineProperty;
10
+ var __defProps = Object.defineProperties;
11
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
12
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
15
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16
+ var __spreadValues = (a, b) => {
17
+ for (var prop in b || (b = {}))
18
+ if (__hasOwnProp.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ if (__getOwnPropSymbols)
21
+ for (var prop of __getOwnPropSymbols(b)) {
22
+ if (__propIsEnum.call(b, prop))
23
+ __defNormalProp(a, prop, b[prop]);
24
+ }
25
+ return a;
26
+ };
27
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
28
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
29
+ var wordEditorSchema = new prosemirrorModel.Schema({
30
+ nodes: {
31
+ doc: { content: "block+" },
32
+ paragraph: {
33
+ group: "block",
34
+ content: "inline*",
35
+ attrs: {
36
+ paraId: { default: "" },
37
+ story: { default: "body" },
38
+ styleId: { default: null },
39
+ format: { default: null }
40
+ },
41
+ parseDOM: [{ tag: "p" }],
42
+ toDOM: /* @__PURE__ */ __name((node) => ["p", paragraphDomAttrs(node.attrs), 0], "toDOM")
43
+ },
44
+ table: {
45
+ group: "block",
46
+ content: "table_row+",
47
+ attrs: {
48
+ tableId: { default: "" },
49
+ columnWidths: { default: null }
50
+ },
51
+ tableRole: "table",
52
+ toDOM: /* @__PURE__ */ __name((node) => [
53
+ "div",
54
+ { class: "coco-word-table-scroll" },
55
+ ["table", tableDomAttrs(node.attrs), ["tbody", 0]]
56
+ ], "toDOM")
57
+ },
58
+ table_row: {
59
+ content: "table_cell+",
60
+ tableRole: "row",
61
+ toDOM: /* @__PURE__ */ __name(() => ["tr", 0], "toDOM")
62
+ },
63
+ table_cell: {
64
+ content: "block+",
65
+ attrs: {
66
+ colspan: { default: 1 },
67
+ rowspan: { default: 1 },
68
+ width: { default: null },
69
+ shading: { default: null },
70
+ verticalAlignment: { default: null }
71
+ },
72
+ tableRole: "cell",
73
+ toDOM: /* @__PURE__ */ __name((node) => ["td", tableCellDomAttrs(node.attrs), 0], "toDOM")
74
+ },
75
+ image: {
76
+ inline: true,
77
+ group: "inline",
78
+ atom: true,
79
+ attrs: {
80
+ src: {},
81
+ alt: { default: "" },
82
+ width: { default: null },
83
+ height: { default: null },
84
+ drawingId: { default: null }
85
+ },
86
+ toDOM: /* @__PURE__ */ __name((node) => ["img", imageDomAttrs(node.attrs)], "toDOM")
87
+ },
88
+ text: { group: "inline" }
89
+ },
90
+ marks: {
91
+ strong: {
92
+ parseDOM: [{ tag: "strong" }, { tag: "b" }],
93
+ toDOM: /* @__PURE__ */ __name(() => ["strong", 0], "toDOM")
94
+ },
95
+ em: {
96
+ parseDOM: [{ tag: "em" }, { tag: "i" }],
97
+ toDOM: /* @__PURE__ */ __name(() => ["em", 0], "toDOM")
98
+ },
99
+ underline: {
100
+ parseDOM: [{ tag: "u" }],
101
+ toDOM: /* @__PURE__ */ __name(() => ["u", 0], "toDOM")
102
+ },
103
+ textStyle: {
104
+ attrs: {
105
+ color: { default: null },
106
+ fontSize: { default: null }
107
+ },
108
+ parseDOM: [{ tag: "span" }],
109
+ toDOM: /* @__PURE__ */ __name((mark) => ["span", textStyleDomAttrs(mark.attrs), 0], "toDOM")
110
+ }
111
+ }
112
+ });
113
+ var wordDecorationsKey = new prosemirrorState.PluginKey("coco-word-decorations");
114
+ var wordStructureNormalizationKey = new prosemirrorState.PluginKey("coco-word-structure-normalization");
115
+ function createWordEditorState(view, options = {}) {
116
+ var _a;
117
+ const projection = projectWordViewToProseMirror(view);
118
+ return prosemirrorState.EditorState.create({
119
+ schema: wordEditorSchema,
120
+ doc: projection.doc,
121
+ plugins: [
122
+ createWordDecorationsPlugin(projection.decorations),
123
+ prosemirrorKeymap.keymap(prosemirrorCommands.baseKeymap),
124
+ createWordStructureNormalizationPlugin(),
125
+ ...(_a = options.plugins) != null ? _a : []
126
+ ]
127
+ });
128
+ }
129
+ __name(createWordEditorState, "createWordEditorState");
130
+ function projectWordViewToProseMirror(view) {
131
+ const paragraphContentPos = /* @__PURE__ */ new Map();
132
+ const blocks = view.blocks.map((block) => blockToNode(block));
133
+ const doc = wordEditorSchema.nodes.doc.create(null, blocks);
134
+ doc.descendants((node, pos) => {
135
+ if (node.type === wordEditorSchema.nodes.paragraph && typeof node.attrs.paraId === "string") {
136
+ paragraphContentPos.set(node.attrs.paraId, pos + 1);
137
+ }
138
+ });
139
+ const decorations = [];
140
+ for (const paragraph of view.paragraphs) {
141
+ const base = paragraphContentPos.get(paragraph.paraId);
142
+ for (const span of paragraph.spans) {
143
+ if (span.to <= span.from) {
144
+ if (span.kind === "comment") {
145
+ decorations.push(createCommentWidget(base + span.from, span));
146
+ }
147
+ continue;
148
+ }
149
+ const className = span.kind === "comment" ? "coco-word-comment" : span.revisionKind === "delete" ? "coco-word-revision-delete" : "coco-word-revision-insert";
150
+ decorations.push(
151
+ prosemirrorView.Decoration.inline(
152
+ base + span.from,
153
+ base + span.to,
154
+ __spreadValues({
155
+ class: className
156
+ }, span.kind === "comment" ? commentDomAttrs(span) : {}),
157
+ {
158
+ id: span.id,
159
+ kind: span.kind,
160
+ paraId: paragraph.paraId
161
+ }
162
+ )
163
+ );
164
+ }
165
+ }
166
+ return {
167
+ doc,
168
+ decorations: prosemirrorView.DecorationSet.create(doc, decorations),
169
+ paragraphContentPos
170
+ };
171
+ }
172
+ __name(projectWordViewToProseMirror, "projectWordViewToProseMirror");
173
+ function createCommentWidget(pos, span) {
174
+ return prosemirrorView.Decoration.widget(
175
+ pos,
176
+ () => {
177
+ const marker = document.createElement("span");
178
+ marker.className = "coco-word-comment-widget";
179
+ marker.dataset.commentId = String(span.commentId);
180
+ marker.title = commentTitle(span);
181
+ marker.textContent = "!";
182
+ return marker;
183
+ },
184
+ {
185
+ id: span.id,
186
+ kind: "comment",
187
+ side: 1
188
+ }
189
+ );
190
+ }
191
+ __name(createCommentWidget, "createCommentWidget");
192
+ function commentDomAttrs(span) {
193
+ return {
194
+ "data-comment-id": String(span.commentId),
195
+ title: commentTitle(span)
196
+ };
197
+ }
198
+ __name(commentDomAttrs, "commentDomAttrs");
199
+ function commentTitle(span) {
200
+ const body = span.body.trim();
201
+ return body.length > 0 ? `Comment ${span.commentId}: ${body}` : `Comment ${span.commentId}`;
202
+ }
203
+ __name(commentTitle, "commentTitle");
204
+ function blockToNode(block) {
205
+ return block.type === "table" ? tableToNode(block) : paragraphToNode(block);
206
+ }
207
+ __name(blockToNode, "blockToNode");
208
+ function paragraphToNode(paragraph) {
209
+ var _a, _b;
210
+ return wordEditorSchema.nodes.paragraph.create(
211
+ {
212
+ paraId: paragraph.paraId,
213
+ story: paragraph.story,
214
+ styleId: (_a = paragraph.styleId) != null ? _a : null,
215
+ format: (_b = paragraph.format) != null ? _b : null
216
+ },
217
+ paragraph.segments.length > 0 ? paragraph.segments.flatMap((segment) => {
218
+ var _a2, _b2, _c;
219
+ if (segment.kind === "placeholder") {
220
+ return [wordEditorSchema.text("\uFFFC")];
221
+ }
222
+ if (segment.kind === "drawing") {
223
+ return [wordEditorSchema.text(segment.text && segment.text.length > 0 ? segment.text : "\uFFFC")];
224
+ }
225
+ if (segment.kind === "field") {
226
+ return [wordEditorSchema.text((_a2 = segment.cachedText) != null ? _a2 : "\uFFFC", marksForRunFormat(segment.format))];
227
+ }
228
+ if (segment.kind === "image") {
229
+ return [
230
+ wordEditorSchema.nodes.image.create({
231
+ src: segment.src,
232
+ alt: segment.drawingId,
233
+ width: (_b2 = segment.width) != null ? _b2 : null,
234
+ height: (_c = segment.height) != null ? _c : null,
235
+ drawingId: segment.drawingId
236
+ })
237
+ ];
238
+ }
239
+ if (segment.text.length === 0) return [];
240
+ const format = segment.kind === "text" ? segment.format : void 0;
241
+ return [wordEditorSchema.text(segment.text, marksForRunFormat(format))];
242
+ }) : paragraph.text.length > 0 ? wordEditorSchema.text(paragraph.text) : void 0
243
+ );
244
+ }
245
+ __name(paragraphToNode, "paragraphToNode");
246
+ function tableToNode(table) {
247
+ return wordEditorSchema.nodes.table.create(
248
+ { tableId: table.tableId, columnWidths: table.columnWidths },
249
+ table.rows.map(
250
+ (row) => wordEditorSchema.nodes.table_row.create(
251
+ null,
252
+ row.cells.filter((cell) => cell.vMerge !== "continue").map((cell) => tableCellToNode(cell))
253
+ )
254
+ )
255
+ );
256
+ }
257
+ __name(tableToNode, "tableToNode");
258
+ function tableCellToNode(cell) {
259
+ var _a, _b, _c, _d;
260
+ const paragraphs = cell.paragraphs.length > 0 ? cell.paragraphs.map((paragraph) => paragraphToNode(paragraph)) : [wordEditorSchema.nodes.paragraph.create(null)];
261
+ return wordEditorSchema.nodes.table_cell.create(
262
+ {
263
+ colspan: Math.max(1, cell.gridSpan),
264
+ rowspan: Math.max(1, (_a = cell.rowSpan) != null ? _a : 1),
265
+ width: (_b = cell.width) != null ? _b : null,
266
+ shading: (_c = cell.shading) != null ? _c : null,
267
+ verticalAlignment: (_d = cell.verticalAlignment) != null ? _d : null
268
+ },
269
+ paragraphs
270
+ );
271
+ }
272
+ __name(tableCellToNode, "tableCellToNode");
273
+ function marksForRunFormat(format) {
274
+ var _a, _b;
275
+ if (!format) return void 0;
276
+ const marks = [];
277
+ if (format.bold) marks.push(wordEditorSchema.marks.strong.create());
278
+ if (format.italic) marks.push(wordEditorSchema.marks.em.create());
279
+ if (format.underline) marks.push(wordEditorSchema.marks.underline.create());
280
+ if (format.color || format.fontSize) {
281
+ marks.push(
282
+ wordEditorSchema.marks.textStyle.create({
283
+ color: (_a = format.color) != null ? _a : null,
284
+ fontSize: (_b = format.fontSize) != null ? _b : null
285
+ })
286
+ );
287
+ }
288
+ return marks.length > 0 ? marks : void 0;
289
+ }
290
+ __name(marksForRunFormat, "marksForRunFormat");
291
+ function paragraphDomAttrs(attrs) {
292
+ const domAttrs = {};
293
+ if (typeof attrs.paraId === "string" && attrs.paraId.length > 0) {
294
+ domAttrs["data-para-id"] = attrs.paraId;
295
+ }
296
+ if (typeof attrs.story === "string" && attrs.story.length > 0) {
297
+ domAttrs["data-story"] = attrs.story;
298
+ }
299
+ if (typeof attrs.styleId === "string" && attrs.styleId.length > 0) {
300
+ domAttrs["data-style-id"] = attrs.styleId;
301
+ }
302
+ const format = isParagraphFormat(attrs.format) ? attrs.format : null;
303
+ if ((format == null ? void 0 : format.outlineLevel) !== void 0) {
304
+ domAttrs["data-outline-level"] = String(format.outlineLevel);
305
+ }
306
+ const style = paragraphStyle(format);
307
+ if (style.length > 0) domAttrs.style = style;
308
+ return domAttrs;
309
+ }
310
+ __name(paragraphDomAttrs, "paragraphDomAttrs");
311
+ function tableDomAttrs(attrs) {
312
+ const domAttrs = {};
313
+ if (typeof attrs.tableId === "string" && attrs.tableId.length > 0) {
314
+ domAttrs["data-table-id"] = attrs.tableId;
315
+ }
316
+ return domAttrs;
317
+ }
318
+ __name(tableDomAttrs, "tableDomAttrs");
319
+ function tableCellDomAttrs(attrs) {
320
+ const domAttrs = {};
321
+ if (typeof attrs.colspan === "number" && attrs.colspan > 1) {
322
+ domAttrs.colspan = String(attrs.colspan);
323
+ }
324
+ if (typeof attrs.rowspan === "number" && attrs.rowspan > 1) {
325
+ domAttrs.rowspan = String(attrs.rowspan);
326
+ }
327
+ const style = [];
328
+ if (typeof attrs.width === "number" && attrs.width > 0) {
329
+ style.push(`width: ${twipsToPt(attrs.width)}`);
330
+ }
331
+ if (isShading(attrs.shading)) {
332
+ const fill = colorToCss(attrs.shading.fill);
333
+ if (fill) style.push(`background-color: ${fill}`);
334
+ }
335
+ if (typeof attrs.verticalAlignment === "string") {
336
+ style.push(`vertical-align: ${attrs.verticalAlignment === "center" ? "middle" : attrs.verticalAlignment}`);
337
+ }
338
+ if (style.length > 0) domAttrs.style = style.join("; ");
339
+ return domAttrs;
340
+ }
341
+ __name(tableCellDomAttrs, "tableCellDomAttrs");
342
+ function imageDomAttrs(attrs) {
343
+ const domAttrs = {
344
+ src: typeof attrs.src === "string" ? attrs.src : "",
345
+ alt: typeof attrs.alt === "string" ? attrs.alt : ""
346
+ };
347
+ if (typeof attrs.drawingId === "string") domAttrs["data-drawing-id"] = attrs.drawingId;
348
+ const style = [];
349
+ if (typeof attrs.width === "number" && attrs.width > 0) {
350
+ style.push(`width: ${attrs.width}px`);
351
+ }
352
+ if (typeof attrs.height === "number" && attrs.height > 0) {
353
+ style.push(`height: ${attrs.height}px`);
354
+ }
355
+ if (style.length > 0) domAttrs.style = style.join("; ");
356
+ return domAttrs;
357
+ }
358
+ __name(imageDomAttrs, "imageDomAttrs");
359
+ function isShading(value) {
360
+ return value !== null && typeof value === "object";
361
+ }
362
+ __name(isShading, "isShading");
363
+ function textStyleDomAttrs(attrs) {
364
+ const style = [];
365
+ const color = typeof attrs.color === "string" ? colorToCss(attrs.color) : null;
366
+ if (color) style.push(`color: ${color}`);
367
+ if (typeof attrs.fontSize === "number") style.push(`font-size: ${attrs.fontSize}pt`);
368
+ return style.length > 0 ? { style: style.join("; ") } : {};
369
+ }
370
+ __name(textStyleDomAttrs, "textStyleDomAttrs");
371
+ function isParagraphFormat(value) {
372
+ return value !== null && typeof value === "object";
373
+ }
374
+ __name(isParagraphFormat, "isParagraphFormat");
375
+ function paragraphStyle(format) {
376
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
377
+ if (!format) return "";
378
+ const declarations = [];
379
+ if (format.alignment) declarations.push(`text-align: ${alignmentToCss(format.alignment)}`);
380
+ if (((_a = format.indent) == null ? void 0 : _a.left) !== void 0) declarations.push(`margin-left: ${twipsToPt(format.indent.left)}`);
381
+ if (((_b = format.indent) == null ? void 0 : _b.right) !== void 0) declarations.push(`margin-right: ${twipsToPt(format.indent.right)}`);
382
+ if (((_c = format.indent) == null ? void 0 : _c.firstLine) !== void 0) {
383
+ declarations.push(`text-indent: ${twipsToPt(format.indent.firstLine)}`);
384
+ }
385
+ if (((_d = format.spacing) == null ? void 0 : _d.before) !== void 0) {
386
+ declarations.push(`margin-top: ${twipsToPt(format.spacing.before)}`);
387
+ }
388
+ if (((_e = format.spacing) == null ? void 0 : _e.after) !== void 0) {
389
+ declarations.push(`margin-bottom: ${twipsToPt(format.spacing.after)}`);
390
+ }
391
+ const lineHeight = lineHeightToCss((_f = format.spacing) == null ? void 0 : _f.line, (_g = format.spacing) == null ? void 0 : _g.lineRule);
392
+ if (lineHeight) declarations.push(`line-height: ${lineHeight}`);
393
+ if (format.fontSize !== void 0) declarations.push(`font-size: ${format.fontSize}pt`);
394
+ if (format.bold !== void 0) declarations.push(`font-weight: ${format.bold ? "700" : "400"}`);
395
+ const borderBottom = borderToCss(format.borderBottom);
396
+ if (borderBottom) {
397
+ declarations.push(`border-bottom: ${borderBottom}`);
398
+ declarations.push(`padding-bottom: ${(_i = (_h = format.borderBottom) == null ? void 0 : _h.space) != null ? _i : 4}pt`);
399
+ }
400
+ return declarations.join("; ");
401
+ }
402
+ __name(paragraphStyle, "paragraphStyle");
403
+ function alignmentToCss(alignment) {
404
+ if (alignment === "both" || alignment === "distribute") return "justify";
405
+ return alignment;
406
+ }
407
+ __name(alignmentToCss, "alignmentToCss");
408
+ function borderToCss(border) {
409
+ var _a;
410
+ if (!border || border.val === "none" || border.val === "nil") return null;
411
+ const color = (_a = colorToCss(border.color)) != null ? _a : "#000000";
412
+ const widthPt = border.size !== void 0 ? Math.max(0.75, border.size / 8) : 0.75;
413
+ const style = border.val === "double" ? "double" : "solid";
414
+ return `${widthPt}pt ${style} ${color}`;
415
+ }
416
+ __name(borderToCss, "borderToCss");
417
+ function lineHeightToCss(line, lineRule) {
418
+ if (line === void 0) return null;
419
+ if (lineRule === "exact" || lineRule === "atLeast") return twipsToPt(line);
420
+ return String(line / 240);
421
+ }
422
+ __name(lineHeightToCss, "lineHeightToCss");
423
+ function twipsToPt(twips) {
424
+ return `${twips / 20}pt`;
425
+ }
426
+ __name(twipsToPt, "twipsToPt");
427
+ function colorToCss(color) {
428
+ if (!color || color === "auto") return null;
429
+ return /^[0-9a-f]{6}$/i.test(color) ? `#${color}` : null;
430
+ }
431
+ __name(colorToCss, "colorToCss");
432
+ function createWordDecorationsPlugin(decorations) {
433
+ return new prosemirrorState.Plugin({
434
+ key: wordDecorationsKey,
435
+ state: {
436
+ init: /* @__PURE__ */ __name(() => decorations, "init"),
437
+ apply: /* @__PURE__ */ __name((tr, set) => set.map(tr.mapping, tr.doc), "apply")
438
+ },
439
+ props: {
440
+ decorations(state) {
441
+ return wordDecorationsKey.getState(state);
442
+ }
443
+ }
444
+ });
445
+ }
446
+ __name(createWordDecorationsPlugin, "createWordDecorationsPlugin");
447
+ function createWordStructureNormalizationPlugin() {
448
+ return new prosemirrorState.Plugin({
449
+ key: wordStructureNormalizationKey,
450
+ appendTransaction(transactions, _oldState, newState) {
451
+ if (!transactions.some((tr2) => tr2.docChanged)) return null;
452
+ if (transactions.some((tr2) => tr2.getMeta(wordStructureNormalizationKey))) return null;
453
+ const seen = /* @__PURE__ */ new Set();
454
+ let tr = newState.tr;
455
+ let changed = false;
456
+ newState.doc.descendants((node, pos) => {
457
+ if (node.type !== wordEditorSchema.nodes.paragraph) return true;
458
+ const paraId = typeof node.attrs.paraId === "string" ? node.attrs.paraId : "";
459
+ if (paraId && !seen.has(paraId)) {
460
+ seen.add(paraId);
461
+ return true;
462
+ }
463
+ const nextParaId = nextUniqueParaId(seen);
464
+ seen.add(nextParaId);
465
+ tr = tr.setNodeMarkup(pos, void 0, __spreadProps(__spreadValues({}, node.attrs), { paraId: nextParaId }));
466
+ changed = true;
467
+ return true;
468
+ });
469
+ return changed ? tr.setMeta(wordStructureNormalizationKey, { normalized: true }) : null;
470
+ }
471
+ });
472
+ }
473
+ __name(createWordStructureNormalizationPlugin, "createWordStructureNormalizationPlugin");
474
+ function nextUniqueParaId(seen) {
475
+ let paraId = "";
476
+ do {
477
+ paraId = Math.floor(Math.random() * 4294967295).toString(16).toUpperCase().padStart(8, "0");
478
+ } while (!paraId || seen.has(paraId));
479
+ return paraId;
480
+ }
481
+ __name(nextUniqueParaId, "nextUniqueParaId");
482
+
483
+ exports.createWordEditorState = createWordEditorState;
484
+ exports.projectWordViewToProseMirror = projectWordViewToProseMirror;
485
+ exports.wordDecorationsKey = wordDecorationsKey;
486
+ exports.wordEditorSchema = wordEditorSchema;
487
+ exports.wordStructureNormalizationKey = wordStructureNormalizationKey;
488
+ //# sourceMappingURL=word-prosemirror.cjs.map
489
+ //# sourceMappingURL=word-prosemirror.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/word/prosemirror.ts"],"names":["Schema","PluginKey","EditorState","keymap","baseKeymap","Decoration","DecorationSet","_a","_b","Plugin","tr"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,IAAM,gBAAA,GAAmB,IAAIA,uBAAA,C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T,SAAS,iBAAiB,IAAA,EAA2B;AACnD,EAAA,IAAI,MAAA,GAAS,EAAA;AACb,EAAA,GAAG;AACD,IAAA,MAAA,GAAS,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,MAAA,KAAW,UAAU,CAAA,CAC3C,QAAA,CAAS,EAAE,CAAA,CACX,WAAA,EAAY,CACZ,QAAA,CAAS,GAAG,GAAG,CAAA;AAAA,EACpB,CAAA,QAAS,CAAC,MAAA,IAAU,IAAA,CAAK,IAAI,MAAM,CAAA;AACnC,EAAA,OAAO,MAAA;AACT;AATS,MAAA,CAAA,gBAAA,EAAA,kBAAA,CAAA","file":"word-prosemirror.cjs","sourcesContent":["import { Schema, type Node as ProseMirrorNode } from 'prosemirror-model';\nimport { baseKeymap } from 'prosemirror-commands';\nimport { keymap } from 'prosemirror-keymap';\nimport { EditorState, Plugin, PluginKey } from 'prosemirror-state';\nimport { Decoration, DecorationSet } from 'prosemirror-view';\nimport type {\n EditorBlockView,\n EditorDocumentView,\n EditorParagraphFormat,\n EditorParagraphView,\n EditorRunFormat,\n EditorTableCellView,\n EditorTableView,\n} from './model.js';\n\nexport interface WordProjection {\n doc: ProseMirrorNode;\n decorations: DecorationSet;\n paragraphContentPos: Map<string, number>;\n}\n\nexport interface CreateWordEditorStateOptions {\n plugins?: Plugin[];\n}\n\nexport const wordEditorSchema = new Schema({\n nodes: {\n doc: { content: 'block+' },\n paragraph: {\n group: 'block',\n content: 'inline*',\n attrs: {\n paraId: { default: '' },\n story: { default: 'body' },\n styleId: { default: null },\n format: { default: null },\n },\n parseDOM: [{ tag: 'p' }],\n toDOM: (node) => ['p', paragraphDomAttrs(node.attrs), 0],\n },\n table: {\n group: 'block',\n content: 'table_row+',\n attrs: {\n tableId: { default: '' },\n columnWidths: { default: null },\n },\n tableRole: 'table',\n toDOM: (node) => [\n 'div',\n { class: 'coco-word-table-scroll' },\n ['table', tableDomAttrs(node.attrs), ['tbody', 0]],\n ],\n },\n table_row: {\n content: 'table_cell+',\n tableRole: 'row',\n toDOM: () => ['tr', 0],\n },\n table_cell: {\n content: 'block+',\n attrs: {\n colspan: { default: 1 },\n rowspan: { default: 1 },\n width: { default: null },\n shading: { default: null },\n verticalAlignment: { default: null },\n },\n tableRole: 'cell',\n toDOM: (node) => ['td', tableCellDomAttrs(node.attrs), 0],\n },\n image: {\n inline: true,\n group: 'inline',\n atom: true,\n attrs: {\n src: {},\n alt: { default: '' },\n width: { default: null },\n height: { default: null },\n drawingId: { default: null },\n },\n toDOM: (node) => ['img', imageDomAttrs(node.attrs)],\n },\n text: { group: 'inline' },\n },\n marks: {\n strong: {\n parseDOM: [{ tag: 'strong' }, { tag: 'b' }],\n toDOM: () => ['strong', 0],\n },\n em: {\n parseDOM: [{ tag: 'em' }, { tag: 'i' }],\n toDOM: () => ['em', 0],\n },\n underline: {\n parseDOM: [{ tag: 'u' }],\n toDOM: () => ['u', 0],\n },\n textStyle: {\n attrs: {\n color: { default: null },\n fontSize: { default: null },\n },\n parseDOM: [{ tag: 'span' }],\n toDOM: (mark) => ['span', textStyleDomAttrs(mark.attrs), 0],\n },\n },\n});\n\nexport const wordDecorationsKey = new PluginKey<DecorationSet>('coco-word-decorations');\nexport const wordStructureNormalizationKey = new PluginKey('coco-word-structure-normalization');\n\nexport function createWordEditorState(\n view: EditorDocumentView,\n options: CreateWordEditorStateOptions = {},\n): EditorState {\n const projection = projectWordViewToProseMirror(view);\n return EditorState.create({\n schema: wordEditorSchema,\n doc: projection.doc,\n plugins: [\n createWordDecorationsPlugin(projection.decorations),\n keymap(baseKeymap),\n createWordStructureNormalizationPlugin(),\n ...(options.plugins ?? []),\n ],\n });\n}\n\nexport function projectWordViewToProseMirror(view: EditorDocumentView): WordProjection {\n const paragraphContentPos = new Map<string, number>();\n const blocks = view.blocks.map((block) => blockToNode(block));\n const doc = wordEditorSchema.nodes.doc.create(null, blocks);\n\n doc.descendants((node, pos) => {\n if (node.type === wordEditorSchema.nodes.paragraph && typeof node.attrs.paraId === 'string') {\n paragraphContentPos.set(node.attrs.paraId, pos + 1);\n }\n });\n\n const decorations: Decoration[] = [];\n for (const paragraph of view.paragraphs) {\n const base = paragraphContentPos.get(paragraph.paraId)!;\n for (const span of paragraph.spans) {\n if (span.to <= span.from) {\n if (span.kind === 'comment') {\n decorations.push(createCommentWidget(base + span.from, span));\n }\n continue;\n }\n const className =\n span.kind === 'comment'\n ? 'coco-word-comment'\n : span.revisionKind === 'delete'\n ? 'coco-word-revision-delete'\n : 'coco-word-revision-insert';\n decorations.push(\n Decoration.inline(\n base + span.from,\n base + span.to,\n {\n class: className,\n ...(span.kind === 'comment' ? commentDomAttrs(span) : {}),\n },\n {\n id: span.id,\n kind: span.kind,\n paraId: paragraph.paraId,\n },\n ),\n );\n }\n }\n\n return {\n doc,\n decorations: DecorationSet.create(doc, decorations),\n paragraphContentPos,\n };\n}\n\nfunction createCommentWidget(pos: number, span: { id: string; commentId: number; body: string }) {\n return Decoration.widget(\n pos,\n () => {\n const marker = document.createElement('span');\n marker.className = 'coco-word-comment-widget';\n marker.dataset.commentId = String(span.commentId);\n marker.title = commentTitle(span);\n marker.textContent = '!';\n return marker;\n },\n {\n id: span.id,\n kind: 'comment',\n side: 1,\n },\n );\n}\n\nfunction commentDomAttrs(span: { commentId: number; body: string }): Record<string, string> {\n return {\n 'data-comment-id': String(span.commentId),\n title: commentTitle(span),\n };\n}\n\nfunction commentTitle(span: { commentId: number; body: string }): string {\n const body = span.body.trim();\n return body.length > 0 ? `Comment ${span.commentId}: ${body}` : `Comment ${span.commentId}`;\n}\n\nfunction blockToNode(block: EditorBlockView): ProseMirrorNode {\n return block.type === 'table' ? tableToNode(block) : paragraphToNode(block);\n}\n\nfunction paragraphToNode(paragraph: EditorParagraphView): ProseMirrorNode {\n return wordEditorSchema.nodes.paragraph.create(\n {\n paraId: paragraph.paraId,\n story: paragraph.story,\n styleId: paragraph.styleId ?? null,\n format: paragraph.format ?? null,\n },\n paragraph.segments.length > 0 ? paragraph.segments.flatMap((segment) => {\n if (segment.kind === 'placeholder') {\n return [wordEditorSchema.text('\\uFFFC')];\n }\n if (segment.kind === 'drawing') {\n return [wordEditorSchema.text(segment.text && segment.text.length > 0 ? segment.text : '\\uFFFC')];\n }\n if (segment.kind === 'field') {\n return [wordEditorSchema.text(segment.cachedText ?? '\\uFFFC', marksForRunFormat(segment.format))];\n }\n if (segment.kind === 'image') {\n return [\n wordEditorSchema.nodes.image.create({\n src: segment.src,\n alt: segment.drawingId,\n width: segment.width ?? null,\n height: segment.height ?? null,\n drawingId: segment.drawingId,\n }),\n ];\n }\n if (segment.text.length === 0) return [];\n const format = segment.kind === 'text' ? segment.format : undefined;\n return [wordEditorSchema.text(segment.text, marksForRunFormat(format))];\n }) : paragraph.text.length > 0 ? wordEditorSchema.text(paragraph.text) : undefined,\n );\n}\n\nfunction tableToNode(table: EditorTableView): ProseMirrorNode {\n return wordEditorSchema.nodes.table.create(\n { tableId: table.tableId, columnWidths: table.columnWidths },\n table.rows.map((row) =>\n wordEditorSchema.nodes.table_row.create(\n null,\n row.cells\n .filter((cell) => cell.vMerge !== 'continue')\n .map((cell) => tableCellToNode(cell)),\n ),\n ),\n );\n}\n\nfunction tableCellToNode(cell: EditorTableCellView): ProseMirrorNode {\n const paragraphs =\n cell.paragraphs.length > 0\n ? cell.paragraphs.map((paragraph) => paragraphToNode(paragraph))\n : [wordEditorSchema.nodes.paragraph.create(null)];\n return wordEditorSchema.nodes.table_cell.create(\n {\n colspan: Math.max(1, cell.gridSpan),\n rowspan: Math.max(1, cell.rowSpan ?? 1),\n width: cell.width ?? null,\n shading: cell.shading ?? null,\n verticalAlignment: cell.verticalAlignment ?? null,\n },\n paragraphs,\n );\n}\n\nfunction marksForRunFormat(format: EditorRunFormat | undefined) {\n if (!format) return undefined;\n const marks = [];\n if (format.bold) marks.push(wordEditorSchema.marks.strong.create());\n if (format.italic) marks.push(wordEditorSchema.marks.em.create());\n if (format.underline) marks.push(wordEditorSchema.marks.underline.create());\n if (format.color || format.fontSize) {\n marks.push(\n wordEditorSchema.marks.textStyle.create({\n color: format.color ?? null,\n fontSize: format.fontSize ?? null,\n }),\n );\n }\n return marks.length > 0 ? marks : undefined;\n}\n\nfunction paragraphDomAttrs(attrs: {\n paraId?: unknown;\n story?: unknown;\n styleId?: unknown;\n format?: unknown;\n}): Record<string, string> {\n const domAttrs: Record<string, string> = {};\n if (typeof attrs.paraId === 'string' && attrs.paraId.length > 0) {\n domAttrs['data-para-id'] = attrs.paraId;\n }\n if (typeof attrs.story === 'string' && attrs.story.length > 0) {\n domAttrs['data-story'] = attrs.story;\n }\n if (typeof attrs.styleId === 'string' && attrs.styleId.length > 0) {\n domAttrs['data-style-id'] = attrs.styleId;\n }\n\n const format = isParagraphFormat(attrs.format) ? attrs.format : null;\n if (format?.outlineLevel !== undefined) {\n domAttrs['data-outline-level'] = String(format.outlineLevel);\n }\n\n const style = paragraphStyle(format);\n if (style.length > 0) domAttrs.style = style;\n return domAttrs;\n}\n\nfunction tableDomAttrs(attrs: { tableId?: unknown; columnWidths?: unknown }): Record<string, string> {\n const domAttrs: Record<string, string> = {};\n if (typeof attrs.tableId === 'string' && attrs.tableId.length > 0) {\n domAttrs['data-table-id'] = attrs.tableId;\n }\n return domAttrs;\n}\n\nfunction tableCellDomAttrs(attrs: {\n colspan?: unknown;\n rowspan?: unknown;\n width?: unknown;\n shading?: unknown;\n verticalAlignment?: unknown;\n}): Record<string, string> {\n const domAttrs: Record<string, string> = {};\n if (typeof attrs.colspan === 'number' && attrs.colspan > 1) {\n domAttrs.colspan = String(attrs.colspan);\n }\n if (typeof attrs.rowspan === 'number' && attrs.rowspan > 1) {\n domAttrs.rowspan = String(attrs.rowspan);\n }\n const style: string[] = [];\n if (typeof attrs.width === 'number' && attrs.width > 0) {\n style.push(`width: ${twipsToPt(attrs.width)}`);\n }\n if (isShading(attrs.shading)) {\n const fill = colorToCss(attrs.shading.fill);\n if (fill) style.push(`background-color: ${fill}`);\n }\n if (typeof attrs.verticalAlignment === 'string') {\n style.push(`vertical-align: ${attrs.verticalAlignment === 'center' ? 'middle' : attrs.verticalAlignment}`);\n }\n if (style.length > 0) domAttrs.style = style.join('; ');\n return domAttrs;\n}\n\nfunction imageDomAttrs(attrs: {\n src?: unknown;\n alt?: unknown;\n width?: unknown;\n height?: unknown;\n drawingId?: unknown;\n}): Record<string, string> {\n const domAttrs: Record<string, string> = {\n src: typeof attrs.src === 'string' ? attrs.src : '',\n alt: typeof attrs.alt === 'string' ? attrs.alt : '',\n };\n if (typeof attrs.drawingId === 'string') domAttrs['data-drawing-id'] = attrs.drawingId;\n const style: string[] = [];\n if (typeof attrs.width === 'number' && attrs.width > 0) {\n style.push(`width: ${attrs.width}px`);\n }\n if (typeof attrs.height === 'number' && attrs.height > 0) {\n style.push(`height: ${attrs.height}px`);\n }\n if (style.length > 0) domAttrs.style = style.join('; ');\n return domAttrs;\n}\n\nfunction isShading(value: unknown): value is { fill?: string } {\n return value !== null && typeof value === 'object';\n}\n\nfunction textStyleDomAttrs(attrs: { color?: unknown; fontSize?: unknown }): Record<string, string> {\n const style: string[] = [];\n const color = typeof attrs.color === 'string' ? colorToCss(attrs.color) : null;\n if (color) style.push(`color: ${color}`);\n if (typeof attrs.fontSize === 'number') style.push(`font-size: ${attrs.fontSize}pt`);\n return style.length > 0 ? { style: style.join('; ') } : {};\n}\n\nfunction isParagraphFormat(value: unknown): value is EditorParagraphFormat {\n return value !== null && typeof value === 'object';\n}\n\nfunction paragraphStyle(format: EditorParagraphFormat | null): string {\n if (!format) return '';\n const declarations: string[] = [];\n\n if (format.alignment) declarations.push(`text-align: ${alignmentToCss(format.alignment)}`);\n if (format.indent?.left !== undefined) declarations.push(`margin-left: ${twipsToPt(format.indent.left)}`);\n if (format.indent?.right !== undefined) declarations.push(`margin-right: ${twipsToPt(format.indent.right)}`);\n if (format.indent?.firstLine !== undefined) {\n declarations.push(`text-indent: ${twipsToPt(format.indent.firstLine)}`);\n }\n if (format.spacing?.before !== undefined) {\n declarations.push(`margin-top: ${twipsToPt(format.spacing.before)}`);\n }\n if (format.spacing?.after !== undefined) {\n declarations.push(`margin-bottom: ${twipsToPt(format.spacing.after)}`);\n }\n const lineHeight = lineHeightToCss(format.spacing?.line, format.spacing?.lineRule);\n if (lineHeight) declarations.push(`line-height: ${lineHeight}`);\n if (format.fontSize !== undefined) declarations.push(`font-size: ${format.fontSize}pt`);\n if (format.bold !== undefined) declarations.push(`font-weight: ${format.bold ? '700' : '400'}`);\n const borderBottom = borderToCss(format.borderBottom);\n if (borderBottom) {\n declarations.push(`border-bottom: ${borderBottom}`);\n declarations.push(`padding-bottom: ${format.borderBottom?.space ?? 4}pt`);\n }\n\n return declarations.join('; ');\n}\n\nfunction alignmentToCss(alignment: NonNullable<EditorParagraphFormat['alignment']>): string {\n if (alignment === 'both' || alignment === 'distribute') return 'justify';\n return alignment;\n}\n\nfunction borderToCss(border: EditorParagraphFormat['borderBottom']): string | null {\n if (!border || border.val === 'none' || border.val === 'nil') return null;\n const color = colorToCss(border.color) ?? '#000000';\n const widthPt = border.size !== undefined ? Math.max(0.75, border.size / 8) : 0.75;\n const style = border.val === 'double' ? 'double' : 'solid';\n return `${widthPt}pt ${style} ${color}`;\n}\n\nfunction lineHeightToCss(\n line: number | undefined,\n lineRule: 'auto' | 'exact' | 'atLeast' | undefined,\n): string | null {\n if (line === undefined) return null;\n if (lineRule === 'exact' || lineRule === 'atLeast') return twipsToPt(line);\n return String(line / 240);\n}\n\nfunction twipsToPt(twips: number): string {\n return `${twips / 20}pt`;\n}\n\nfunction colorToCss(color: string | undefined): string | null {\n if (!color || color === 'auto') return null;\n return /^[0-9a-f]{6}$/i.test(color) ? `#${color}` : null;\n}\n\nfunction createWordDecorationsPlugin(decorations: DecorationSet): Plugin {\n return new Plugin({\n key: wordDecorationsKey,\n state: {\n init: () => decorations,\n apply: (tr, set) => set.map(tr.mapping, tr.doc),\n },\n props: {\n decorations(state) {\n return wordDecorationsKey.getState(state);\n },\n },\n });\n}\n\nfunction createWordStructureNormalizationPlugin(): Plugin {\n return new Plugin({\n key: wordStructureNormalizationKey,\n appendTransaction(transactions, _oldState, newState) {\n if (!transactions.some((tr) => tr.docChanged)) return null;\n if (transactions.some((tr) => tr.getMeta(wordStructureNormalizationKey))) return null;\n\n const seen = new Set<string>();\n let tr = newState.tr;\n let changed = false;\n newState.doc.descendants((node, pos) => {\n if (node.type !== wordEditorSchema.nodes.paragraph) return true;\n const paraId = typeof node.attrs.paraId === 'string' ? node.attrs.paraId : '';\n if (paraId && !seen.has(paraId)) {\n seen.add(paraId);\n return true;\n }\n\n const nextParaId = nextUniqueParaId(seen);\n seen.add(nextParaId);\n tr = tr.setNodeMarkup(pos, undefined, { ...node.attrs, paraId: nextParaId });\n changed = true;\n return true;\n });\n\n return changed ? tr.setMeta(wordStructureNormalizationKey, { normalized: true }) : null;\n },\n });\n}\n\nfunction nextUniqueParaId(seen: Set<string>): string {\n let paraId = '';\n do {\n paraId = Math.floor(Math.random() * 0xffffffff)\n .toString(16)\n .toUpperCase()\n .padStart(8, '0');\n } while (!paraId || seen.has(paraId));\n return paraId;\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import { Node, Schema } from 'prosemirror-model';
2
+ import { Plugin, EditorState, PluginKey } from 'prosemirror-state';
3
+ import { DecorationSet } from 'prosemirror-view';
4
+ import { e as EditorDocumentView } from './model-DB6aN6uJ.cjs';
5
+ import '@coco-vexel/coco-office/word-view';
6
+
7
+ interface WordProjection {
8
+ doc: Node;
9
+ decorations: DecorationSet;
10
+ paragraphContentPos: Map<string, number>;
11
+ }
12
+ interface CreateWordEditorStateOptions {
13
+ plugins?: Plugin[];
14
+ }
15
+ declare const wordEditorSchema: Schema<"text" | "image" | "paragraph" | "table" | "doc" | "table_row" | "table_cell", "em" | "strong" | "underline" | "textStyle">;
16
+ declare const wordDecorationsKey: PluginKey<DecorationSet>;
17
+ declare const wordStructureNormalizationKey: PluginKey<any>;
18
+ declare function createWordEditorState(view: EditorDocumentView, options?: CreateWordEditorStateOptions): EditorState;
19
+ declare function projectWordViewToProseMirror(view: EditorDocumentView): WordProjection;
20
+
21
+ export { type CreateWordEditorStateOptions, type WordProjection, createWordEditorState, projectWordViewToProseMirror, wordDecorationsKey, wordEditorSchema, wordStructureNormalizationKey };
@@ -0,0 +1,21 @@
1
+ import { Node, Schema } from 'prosemirror-model';
2
+ import { Plugin, EditorState, PluginKey } from 'prosemirror-state';
3
+ import { DecorationSet } from 'prosemirror-view';
4
+ import { e as EditorDocumentView } from './model-DB6aN6uJ.js';
5
+ import '@coco-vexel/coco-office/word-view';
6
+
7
+ interface WordProjection {
8
+ doc: Node;
9
+ decorations: DecorationSet;
10
+ paragraphContentPos: Map<string, number>;
11
+ }
12
+ interface CreateWordEditorStateOptions {
13
+ plugins?: Plugin[];
14
+ }
15
+ declare const wordEditorSchema: Schema<"text" | "image" | "paragraph" | "table" | "doc" | "table_row" | "table_cell", "em" | "strong" | "underline" | "textStyle">;
16
+ declare const wordDecorationsKey: PluginKey<DecorationSet>;
17
+ declare const wordStructureNormalizationKey: PluginKey<any>;
18
+ declare function createWordEditorState(view: EditorDocumentView, options?: CreateWordEditorStateOptions): EditorState;
19
+ declare function projectWordViewToProseMirror(view: EditorDocumentView): WordProjection;
20
+
21
+ export { type CreateWordEditorStateOptions, type WordProjection, createWordEditorState, projectWordViewToProseMirror, wordDecorationsKey, wordEditorSchema, wordStructureNormalizationKey };