@sametalmdr/word-editor 0.2.0-alpha → 0.3.0-alpha

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 (82) hide show
  1. package/CHANGELOG.md +108 -70
  2. package/LICENSE +21 -21
  3. package/README.md +286 -247
  4. package/dist/canvas/box-clipboard.js +238 -238
  5. package/dist/canvas/box-selection.js +80 -80
  6. package/dist/canvas/canvas-editor.js +502 -502
  7. package/dist/canvas/controller.js +717 -717
  8. package/dist/canvas/geometry.js +131 -131
  9. package/dist/canvas/gesture.d.ts +0 -1
  10. package/dist/canvas/gesture.js +289 -289
  11. package/dist/canvas/handles.js +212 -212
  12. package/dist/canvas/menu.js +82 -82
  13. package/dist/canvas/mode-controller.js +81 -81
  14. package/dist/canvas/nudge.js +108 -108
  15. package/dist/canvas/overlay.js +149 -149
  16. package/dist/canvas/snap.js +132 -132
  17. package/dist/canvas/viewport.js +112 -112
  18. package/dist/canvas/z-order.js +171 -171
  19. package/dist/commands/alignment.js +150 -150
  20. package/dist/commands/box.js +272 -272
  21. package/dist/commands/clipboard.js +93 -93
  22. package/dist/commands/graphemes.js +112 -112
  23. package/dist/commands/marks.js +153 -153
  24. package/dist/commands/paragraph-props.js +176 -176
  25. package/dist/commands/size.js +368 -368
  26. package/dist/commands/text.js +291 -291
  27. package/dist/docx.d.ts +1 -0
  28. package/dist/docx.js +15 -13
  29. package/dist/editor/editing-host.js +434 -434
  30. package/dist/element.js +41 -41
  31. package/dist/fonts/OFL-Carlito.txt +94 -0
  32. package/dist/fonts/calibri-metrics.d.ts +27 -0
  33. package/dist/fonts/calibri-metrics.js +88 -0
  34. package/dist/history/history.js +433 -433
  35. package/dist/index.js +63 -63
  36. package/dist/input/beforeinput.js +224 -224
  37. package/dist/input/clipboard.js +107 -107
  38. package/dist/input/composition.js +341 -341
  39. package/dist/input/keymap.js +54 -54
  40. package/dist/io/ooxml/custgeom.js +72 -72
  41. package/dist/io/ooxml/drawingml.js +232 -232
  42. package/dist/io/ooxml/edits.js +67 -67
  43. package/dist/io/ooxml/export-splice.js +880 -880
  44. package/dist/io/ooxml/export.js +365 -365
  45. package/dist/io/ooxml/fill.d.ts +93 -8
  46. package/dist/io/ooxml/fill.js +618 -562
  47. package/dist/io/ooxml/fit.d.ts +252 -0
  48. package/dist/io/ooxml/fit.js +598 -0
  49. package/dist/io/ooxml/import-gate.js +200 -200
  50. package/dist/io/ooxml/import.js +691 -691
  51. package/dist/io/ooxml/inflate.js +126 -126
  52. package/dist/io/ooxml/media.js +87 -87
  53. package/dist/io/ooxml/ns.d.ts +2 -0
  54. package/dist/io/ooxml/ns.js +26 -21
  55. package/dist/io/ooxml/numbering.js +290 -290
  56. package/dist/io/ooxml/opc-write.js +171 -171
  57. package/dist/io/ooxml/provenance.js +93 -93
  58. package/dist/io/ooxml/recipe.js +708 -708
  59. package/dist/io/ooxml/relationships.js +59 -59
  60. package/dist/io/ooxml/run-fonts.d.ts +89 -0
  61. package/dist/io/ooxml/run-fonts.js +378 -0
  62. package/dist/io/ooxml/slots.d.ts +4 -0
  63. package/dist/io/ooxml/slots.js +582 -581
  64. package/dist/io/ooxml/styles-resolve.js +257 -257
  65. package/dist/io/ooxml/units.js +43 -43
  66. package/dist/io/ooxml/value.js +120 -120
  67. package/dist/io/ooxml/xml-scan.js +616 -616
  68. package/dist/io/ooxml/zip-container.js +228 -228
  69. package/dist/io/ooxml/zip-reject.js +106 -106
  70. package/dist/measure/placement.js +83 -83
  71. package/dist/measure/report.js +75 -75
  72. package/dist/model/ids.js +70 -70
  73. package/dist/model/normalize.js +146 -146
  74. package/dist/model/position.js +283 -283
  75. package/dist/model/transaction.js +209 -209
  76. package/dist/platform/capabilities.js +25 -25
  77. package/dist/react/index.js +21 -21
  78. package/dist/selection/controller.js +315 -315
  79. package/dist/selection/dom-map.js +334 -334
  80. package/dist/state/editor-state.js +109 -109
  81. package/dist/styles.css +66 -66
  82. package/package.json +94 -93
@@ -1,107 +1,107 @@
1
- import { deleteSelection } from "../commands/text.js";
2
- import { pasteText, serializeToText } from "../commands/clipboard.js";
3
-
4
- /**
5
- * `paste` / `copy` / `cut` / `dragstart` / `drop` — the events outside the
6
- * `beforeinput` matrix (plan §4). `beforeinput`'s own `insertFromPaste` is
7
- * deliberately left a no-op in `input/beforeinput.js`: it does not reliably
8
- * carry clipboard data across browsers, so the `paste` event is the one
9
- * source of truth here.
10
- *
11
- * Every line of text in and out is `text/plain`, never `text/html` —
12
- * ARCHITECTURE.md §2 says the browser's HTML is not the data model, and that
13
- * holds in both directions: we do not parse HTML pasted in, and we do not
14
- * write HTML out, so a paste into a different application never carries our
15
- * internal structure by accident.
16
- */
17
-
18
- /** Splits on every line-ending style a `text/plain` clipboard payload can use. */
19
- const LINE_SPLIT = /\r\n|\r|\n/;
20
-
21
- /**
22
- * The minimal surface of `DataTransfer` this module needs.
23
- * @typedef {object} ClipboardDataLike
24
- * @property {(type: string) => string} getData
25
- * @property {(type: string, value: string) => void} setData
26
- */
27
-
28
- /**
29
- * @typedef {object} ClipboardEventLike
30
- * @property {ClipboardDataLike | null} [clipboardData]
31
- * @property {() => void} preventDefault
32
- */
33
-
34
- /**
35
- * @typedef {object} ClipboardContext
36
- * @property {() => import("../state/editor-state.js").EditorState} getState
37
- * @property {(tr: import("../model/transaction.js").Transaction) => void} dispatch
38
- * @property {import("../model/ids.js").IdFactory} ids
39
- */
40
-
41
- /**
42
- * @param {ClipboardEventLike} event
43
- * @param {ClipboardContext} context
44
- * @returns {void}
45
- */
46
- export function handlePaste(event, context) {
47
- event.preventDefault();
48
-
49
- const text = event.clipboardData?.getData("text/plain") ?? "";
50
- if (text === "") {
51
- return;
52
- }
53
-
54
- const tr = pasteText(context.getState(), text.split(LINE_SPLIT), context.ids);
55
- if (tr !== null) {
56
- context.dispatch(tr);
57
- }
58
- }
59
-
60
- /**
61
- * @param {ClipboardEventLike} event
62
- * @param {ClipboardContext} context
63
- * @returns {void}
64
- */
65
- export function handleCopy(event, context) {
66
- event.preventDefault();
67
-
68
- const state = context.getState();
69
- event.clipboardData?.setData("text/plain", serializeToText(state.doc, state.selection));
70
- }
71
-
72
- /**
73
- * Writes the selection to the clipboard, then deletes it — the same
74
- * serialisation `copy` uses, plus one command. Not two separate operations
75
- * dispatched independently: the deletion goes through `context.dispatch` exactly
76
- * once, so it is one undo entry, matching what the user did in one keystroke.
77
- * @param {ClipboardEventLike} event
78
- * @param {ClipboardContext} context
79
- * @returns {void}
80
- */
81
- export function handleCut(event, context) {
82
- event.preventDefault();
83
-
84
- const state = context.getState();
85
- event.clipboardData?.setData("text/plain", serializeToText(state.doc, state.selection));
86
-
87
- const tr = deleteSelection(state, "input");
88
- if (tr !== null) {
89
- context.dispatch(tr);
90
- }
91
- }
92
-
93
- /**
94
- * @param {ClipboardEventLike} event
95
- * @returns {void}
96
- */
97
- export function handleDragStart(event) {
98
- event.preventDefault();
99
- }
100
-
101
- /**
102
- * @param {ClipboardEventLike} event
103
- * @returns {void}
104
- */
105
- export function handleDrop(event) {
106
- event.preventDefault();
107
- }
1
+ import { deleteSelection } from "../commands/text.js";
2
+ import { pasteText, serializeToText } from "../commands/clipboard.js";
3
+
4
+ /**
5
+ * `paste` / `copy` / `cut` / `dragstart` / `drop` — the events outside the
6
+ * `beforeinput` matrix (plan §4). `beforeinput`'s own `insertFromPaste` is
7
+ * deliberately left a no-op in `input/beforeinput.js`: it does not reliably
8
+ * carry clipboard data across browsers, so the `paste` event is the one
9
+ * source of truth here.
10
+ *
11
+ * Every line of text in and out is `text/plain`, never `text/html` —
12
+ * ARCHITECTURE.md §2 says the browser's HTML is not the data model, and that
13
+ * holds in both directions: we do not parse HTML pasted in, and we do not
14
+ * write HTML out, so a paste into a different application never carries our
15
+ * internal structure by accident.
16
+ */
17
+
18
+ /** Splits on every line-ending style a `text/plain` clipboard payload can use. */
19
+ const LINE_SPLIT = /\r\n|\r|\n/;
20
+
21
+ /**
22
+ * The minimal surface of `DataTransfer` this module needs.
23
+ * @typedef {object} ClipboardDataLike
24
+ * @property {(type: string) => string} getData
25
+ * @property {(type: string, value: string) => void} setData
26
+ */
27
+
28
+ /**
29
+ * @typedef {object} ClipboardEventLike
30
+ * @property {ClipboardDataLike | null} [clipboardData]
31
+ * @property {() => void} preventDefault
32
+ */
33
+
34
+ /**
35
+ * @typedef {object} ClipboardContext
36
+ * @property {() => import("../state/editor-state.js").EditorState} getState
37
+ * @property {(tr: import("../model/transaction.js").Transaction) => void} dispatch
38
+ * @property {import("../model/ids.js").IdFactory} ids
39
+ */
40
+
41
+ /**
42
+ * @param {ClipboardEventLike} event
43
+ * @param {ClipboardContext} context
44
+ * @returns {void}
45
+ */
46
+ export function handlePaste(event, context) {
47
+ event.preventDefault();
48
+
49
+ const text = event.clipboardData?.getData("text/plain") ?? "";
50
+ if (text === "") {
51
+ return;
52
+ }
53
+
54
+ const tr = pasteText(context.getState(), text.split(LINE_SPLIT), context.ids);
55
+ if (tr !== null) {
56
+ context.dispatch(tr);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * @param {ClipboardEventLike} event
62
+ * @param {ClipboardContext} context
63
+ * @returns {void}
64
+ */
65
+ export function handleCopy(event, context) {
66
+ event.preventDefault();
67
+
68
+ const state = context.getState();
69
+ event.clipboardData?.setData("text/plain", serializeToText(state.doc, state.selection));
70
+ }
71
+
72
+ /**
73
+ * Writes the selection to the clipboard, then deletes it — the same
74
+ * serialisation `copy` uses, plus one command. Not two separate operations
75
+ * dispatched independently: the deletion goes through `context.dispatch` exactly
76
+ * once, so it is one undo entry, matching what the user did in one keystroke.
77
+ * @param {ClipboardEventLike} event
78
+ * @param {ClipboardContext} context
79
+ * @returns {void}
80
+ */
81
+ export function handleCut(event, context) {
82
+ event.preventDefault();
83
+
84
+ const state = context.getState();
85
+ event.clipboardData?.setData("text/plain", serializeToText(state.doc, state.selection));
86
+
87
+ const tr = deleteSelection(state, "input");
88
+ if (tr !== null) {
89
+ context.dispatch(tr);
90
+ }
91
+ }
92
+
93
+ /**
94
+ * @param {ClipboardEventLike} event
95
+ * @returns {void}
96
+ */
97
+ export function handleDragStart(event) {
98
+ event.preventDefault();
99
+ }
100
+
101
+ /**
102
+ * @param {ClipboardEventLike} event
103
+ * @returns {void}
104
+ */
105
+ export function handleDrop(event) {
106
+ event.preventDefault();
107
+ }