alinea 2.0.0-preview.0 → 2.0.0-preview.2

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 (237) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/LICENSES.md +134 -80
  3. package/dist/adapter/next/DevRemote.d.ts +3 -0
  4. package/dist/adapter/next/DevRemote.js +37 -0
  5. package/dist/adapter/next/ForwardCredentials.d.ts +1 -0
  6. package/dist/adapter/next/ForwardCredentials.js +17 -0
  7. package/dist/adapter/next/cms.js +86 -38
  8. package/dist/adapter/next/context.d.ts +1 -1
  9. package/dist/adapter/next/context.js +11 -3
  10. package/dist/adapter/next/handler.d.ts +2 -0
  11. package/dist/adapter/next/handler.js +23 -16
  12. package/dist/adapter/next/with-alinea.js +18 -16
  13. package/dist/backend/Handler.d.ts +14 -13
  14. package/dist/backend/Handler.js +70 -36
  15. package/dist/backend/resolver/ParsePreview.d.ts +8 -4
  16. package/dist/backend/resolver/ParsePreview.js +40 -43
  17. package/dist/backend/router/Router.d.ts +1 -0
  18. package/dist/backend/router/Router.js +21 -15
  19. package/dist/bundled.d.ts +369 -99
  20. package/dist/chunks/chunk-6UT4N4CO.js +919 -0
  21. package/dist/chunks/{chunk-LUBOGJCG.js → chunk-6V4TAD2N.js} +1 -1
  22. package/dist/chunks/{chunk-TL7ZW6BX.js → chunk-A3XXZBOQ.js} +2535 -2999
  23. package/dist/chunks/chunk-AC5ATYI3.js +1434 -0
  24. package/dist/chunks/{chunk-7ORQ7BYK.js → chunk-KMLLLZ6X.js} +202 -269
  25. package/dist/chunks/{chunk-IWN3T3FL.js → chunk-O7XWTMCB.js} +1 -1
  26. package/dist/chunks/{chunk-53DZYORR.js → chunk-PAYSVIYI.js} +76 -176
  27. package/dist/chunks/{chunk-YK3OSMDM.js → chunk-S4AU6SRS.js} +188 -158
  28. package/dist/chunks/{chunk-EQ3TDHYD.js → chunk-UVOEM4AH.js} +6 -3
  29. package/dist/chunks/{chunk-I7X64JTZ.js → chunk-VXZM6V4P.js} +4 -4
  30. package/dist/cli/Generate.js +3 -13
  31. package/dist/cli/Serve.js +7 -3
  32. package/dist/cli/bin.js +8 -5
  33. package/dist/cli/generate/CompileConfig.js +3 -2
  34. package/dist/cli/generate/CopyStaticFiles.js +2 -3
  35. package/dist/cli/generate/DevDB.d.ts +1 -1
  36. package/dist/cli/generate/DevDB.js +3 -5
  37. package/dist/cli/serve/CreateLocalServer.d.ts +1 -1
  38. package/dist/cli/serve/CreateLocalServer.js +3 -2
  39. package/dist/cli/serve/DevServer.d.ts +3 -2
  40. package/dist/cli/serve/DevServer.js +60 -3
  41. package/dist/cli/serve/ServeContext.d.ts +1 -0
  42. package/dist/cli/serve/StartServer.d.ts +1 -0
  43. package/dist/cli/serve/StartServer.js +6 -1
  44. package/dist/cli/util/EnsureLibs.js +2 -2
  45. package/dist/cli/util/EnsureNode.js +2 -2
  46. package/dist/cloud/CloudRemote.d.ts +2 -1
  47. package/dist/cloud/CloudRemote.js +3 -2
  48. package/dist/components/Breadcrumbs.js +8 -8
  49. package/dist/components/Button.js +6 -6
  50. package/dist/components/Calendar.js +11 -11
  51. package/dist/components/Checkbox.js +7 -7
  52. package/dist/components/CheckboxGroup.js +6 -6
  53. package/dist/components/ColorSwatch.js +6 -6
  54. package/dist/components/ColorSwatchPicker.js +6 -6
  55. package/dist/components/ComboBox.js +17 -17
  56. package/dist/components/DateField.js +9 -9
  57. package/dist/components/DatePicker.js +10 -10
  58. package/dist/components/DateRangePicker.js +14 -14
  59. package/dist/components/Dialog.js +6 -6
  60. package/dist/components/Disclosure.js +13 -13
  61. package/dist/components/DropZone.js +6 -6
  62. package/dist/components/Label.js +16 -16
  63. package/dist/components/Link.js +6 -6
  64. package/dist/components/List.js +34 -34
  65. package/dist/components/Menu.js +10 -10
  66. package/dist/components/Modal.js +8 -8
  67. package/dist/components/MultipleSelect.js +33 -33
  68. package/dist/components/NumberField.d.ts +2 -1
  69. package/dist/components/NumberField.js +21 -11
  70. package/dist/components/Popover.js +6 -6
  71. package/dist/components/ProgressCircle.js +10 -10
  72. package/dist/components/RadioGroup.js +6 -6
  73. package/dist/components/SearchField.js +11 -11
  74. package/dist/components/Select.js +13 -13
  75. package/dist/components/Surface.js +3 -3
  76. package/dist/components/Switch.js +6 -6
  77. package/dist/components/Table.js +13 -13
  78. package/dist/components/Tabs.js +8 -8
  79. package/dist/components/TagGroup.js +7 -7
  80. package/dist/components/TextField.js +10 -10
  81. package/dist/components/TimeField.js +6 -6
  82. package/dist/components/Toggle.js +6 -6
  83. package/dist/components/Toolbar.js +7 -7
  84. package/dist/components/Tooltip.js +10 -10
  85. package/dist/components/Tree.js +9 -9
  86. package/dist/core/BlobTransport.d.ts +5 -0
  87. package/dist/core/BlobTransport.js +79 -0
  88. package/dist/core/Client.d.ts +2 -1
  89. package/dist/core/Client.js +17 -12
  90. package/dist/core/Config.d.ts +4 -0
  91. package/dist/core/Config.js +6 -0
  92. package/dist/core/Connection.d.ts +4 -3
  93. package/dist/core/Connection.js +7 -0
  94. package/dist/core/Graph.d.ts +3 -4
  95. package/dist/core/ListRow.d.ts +2 -0
  96. package/dist/core/OrderBy.d.ts +7 -3
  97. package/dist/core/TextDoc.d.ts +11 -0
  98. package/dist/core/Trace.d.ts +8 -0
  99. package/dist/core/Trace.js +32 -0
  100. package/dist/core/Type.d.ts +7 -1
  101. package/dist/core/db/CommitRequest.d.ts +0 -3
  102. package/dist/core/db/CommitRequest.js +0 -9
  103. package/dist/core/db/EntryDB.js +1 -1
  104. package/dist/core/db/EntryIndex.d.ts +12 -2
  105. package/dist/core/db/EntryIndex.js +131 -22
  106. package/dist/core/db/EntryResolver.js +104 -29
  107. package/dist/core/db/EntryTransaction.d.ts +1 -2
  108. package/dist/core/db/EntryTransaction.js +29 -22
  109. package/dist/core/db/LocalDB.d.ts +5 -5
  110. package/dist/core/db/LocalDB.js +27 -12
  111. package/dist/core/field/RichTextField.d.ts +30 -3
  112. package/dist/core/field/RichTextField.js +124 -56
  113. package/dist/core/media/MediaAltField.d.ts +1 -0
  114. package/dist/core/media/MediaAltField.js +9 -1
  115. package/dist/core/media/MediaLocation.d.ts +5 -2
  116. package/dist/core/media/MediaLocation.js +6 -7
  117. package/dist/core/media/MediaTypes.js +11 -0
  118. package/dist/core/source/CombinedSource.d.ts +2 -2
  119. package/dist/core/source/CombinedSource.js +6 -3
  120. package/dist/core/source/FSSource.d.ts +4 -3
  121. package/dist/core/source/FSSource.js +59 -27
  122. package/dist/core/source/GithubSource.d.ts +2 -2
  123. package/dist/core/source/GithubSource.js +21 -9
  124. package/dist/core/source/IndexedDBSource.d.ts +2 -2
  125. package/dist/core/source/IndexedDBSource.js +3 -1
  126. package/dist/core/source/MemorySource.d.ts +2 -2
  127. package/dist/core/source/MemorySource.js +3 -1
  128. package/dist/core/source/OverlaySource.d.ts +12 -0
  129. package/dist/core/source/OverlaySource.js +50 -0
  130. package/dist/core/source/Source.d.ts +5 -2
  131. package/dist/core/source/Source.js +3 -3
  132. package/dist/core/util/Async.d.ts +8 -2
  133. package/dist/core/util/Async.js +67 -0
  134. package/dist/core/util/EntryFilenames.d.ts +2 -2
  135. package/dist/core/util/EntryFilenames.js +3 -3
  136. package/dist/dashboard/App.css +158 -0
  137. package/dist/dashboard/App.js +2 -2
  138. package/dist/dashboard/app/AccessDenied.js +3 -3
  139. package/dist/dashboard/app/ActivityStatus.js +15 -15
  140. package/dist/dashboard/app/AppShell.js +1 -1
  141. package/dist/dashboard/app/AuthView.js +11 -11
  142. package/dist/dashboard/app/CompactField.js +10 -10
  143. package/dist/dashboard/app/DashboardErrorBoundary.js +5 -5
  144. package/dist/dashboard/app/DashboardLayout.js +22 -19
  145. package/dist/dashboard/app/EntryHeader.js +12 -12
  146. package/dist/dashboard/app/EntryReferences.js +9 -9
  147. package/dist/dashboard/app/EntrySidebar.d.ts +1 -1
  148. package/dist/dashboard/app/EntrySidebar.js +17 -16
  149. package/dist/dashboard/app/EntrySidebarPreview.d.ts +1 -1
  150. package/dist/dashboard/app/EntrySidebarPreview.js +19 -14
  151. package/dist/dashboard/app/EntryTranslationBanner.js +7 -7
  152. package/dist/dashboard/app/Explorer.js +51 -43
  153. package/dist/dashboard/app/ExplorerCards.js +34 -34
  154. package/dist/dashboard/app/ExplorerFileCard.js +18 -18
  155. package/dist/dashboard/app/ExplorerList.js +13 -13
  156. package/dist/dashboard/app/ExplorerModal.js +3 -3
  157. package/dist/dashboard/app/ExplorerTable.js +76 -61
  158. package/dist/dashboard/app/ExternalLinkPicker.js +15 -4
  159. package/dist/dashboard/app/LinkPicker.js +8 -8
  160. package/dist/dashboard/app/LocaleMenu.js +12 -12
  161. package/dist/dashboard/app/SidebarLayout.d.ts +8 -0
  162. package/dist/dashboard/app/SidebarLayout.js +1169 -0
  163. package/dist/dashboard/app/SidebarTree.js +46 -46
  164. package/dist/dashboard/app/WorkspaceMenu.js +17 -17
  165. package/dist/dashboard/app/WorkspaceRoots.js +23 -23
  166. package/dist/dashboard/app/editor/FileEditor.d.ts +2 -1
  167. package/dist/dashboard/app/editor/FileEditor.js +41 -32
  168. package/dist/dashboard/app/editor/FilePreview.js +4 -4
  169. package/dist/dashboard/app/editor/MediaAltField.view.d.ts +1 -1
  170. package/dist/dashboard/app/editor/MediaAltField.view.js +6 -9
  171. package/dist/dashboard/app/modals/CreateEntry.js +4 -4
  172. package/dist/dashboard/app/pages/EntryPage.js +57 -31
  173. package/dist/dashboard/app/pages/UsersPage.js +33 -33
  174. package/dist/dashboard/app/ui/DashboardModal.js +23 -23
  175. package/dist/dashboard/app/ui/Rail.js +3 -3
  176. package/dist/dashboard/app/ui/Sidebar.js +2 -2
  177. package/dist/dashboard/atoms/auth.js +2 -0
  178. package/dist/dashboard/atoms/dashboard.d.ts +9 -0
  179. package/dist/dashboard/atoms/dashboard.js +17 -0
  180. package/dist/dashboard/atoms/editor.d.ts +7 -1
  181. package/dist/dashboard/atoms/editor.js +4 -1
  182. package/dist/dashboard/atoms/entry.d.ts +48 -2
  183. package/dist/dashboard/atoms/entry.js +222 -17
  184. package/dist/dashboard/atoms/explorer.js +4 -9
  185. package/dist/dashboard/atoms/preview.d.ts +3 -0
  186. package/dist/dashboard/atoms/preview.js +18 -1
  187. package/dist/dashboard/atoms/root.d.ts +4 -1
  188. package/dist/dashboard/atoms/root.js +96 -157
  189. package/dist/dashboard/hooks.d.ts +4 -2
  190. package/dist/dashboard/hooks.js +9 -5
  191. package/dist/dashboard/icons.d.ts +1 -0
  192. package/dist/dashboard/icons.js +10 -0
  193. package/dist/field/check/CheckField.view.js +2 -2
  194. package/dist/field/code/CodeField.view.js +12 -12
  195. package/dist/field/date/DateField.view.js +12 -2
  196. package/dist/field/link/FileLink.d.ts +2 -2
  197. package/dist/field/link/FileLink.js +5 -3
  198. package/dist/field/link/ImageLink.d.ts +1 -1
  199. package/dist/field/link/ImageLink.js +1 -1
  200. package/dist/field/link/Link.js +2 -2
  201. package/dist/field/link/LinkField.view.js +155 -128
  202. package/dist/field/list/ListField.view.js +22 -33
  203. package/dist/field/metadata/MetadataField.view.js +19 -19
  204. package/dist/field/number/NumberField.d.ts +2 -0
  205. package/dist/field/number/NumberField.view.js +4 -2
  206. package/dist/field/richtext/PickTextLink.d.ts +7 -0
  207. package/dist/field/richtext/PickTextLink.js +104 -2
  208. package/dist/field/richtext/ReferenceLink.d.ts +4 -1
  209. package/dist/field/richtext/ReferenceLink.js +18 -4
  210. package/dist/field/richtext/RichTextDocument.d.ts +7 -2
  211. package/dist/field/richtext/RichTextDocument.js +34 -5
  212. package/dist/field/richtext/RichTextExtensions.d.ts +3 -1
  213. package/dist/field/richtext/RichTextExtensions.js +2704 -7467
  214. package/dist/field/richtext/RichTextField.d.ts +4 -0
  215. package/dist/field/richtext/RichTextField.story.d.ts +4 -0
  216. package/dist/field/richtext/RichTextField.view.js +43 -20
  217. package/dist/field/richtext/RichTextInsertMenu.js +281 -495
  218. package/dist/field/richtext/RichTextToolbar.d.ts +5 -2
  219. package/dist/field/richtext/RichTextToolbar.js +38 -3
  220. package/dist/field/richtext/Toolbar.d.ts +19 -1
  221. package/dist/field/richtext/Toolbar.js +18 -13
  222. package/dist/field/richtext/extensions/Anchor.js +1 -1
  223. package/dist/field/richtext/extensions/Link.js +1 -1
  224. package/dist/field/richtext/extensions/Small.js +1 -1
  225. package/dist/field/select/SelectField.view.js +8 -6
  226. package/dist/index.css +227 -16
  227. package/dist/next.cjs +18 -16
  228. package/dist/next.d.ts +2 -1
  229. package/dist/next.edge.d.ts +2 -1
  230. package/dist/picker/entry/EntryPicker.js +9 -35
  231. package/dist/preview/PreviewPayload.js +35 -250
  232. package/dist/ui/RichText.d.ts +1 -0
  233. package/dist/ui/RichText.js +29 -2
  234. package/package.json +6 -3
  235. package/dist/cli/util/ExternalPlugin.d.ts +0 -2
  236. package/dist/cli/util/ExternalPlugin.js +0 -919
  237. package/dist/chunks/{chunk-JFROOUG6.js → chunk-NIVGVRDS.js} +17 -17
@@ -0,0 +1,1434 @@
1
+ import {
2
+ Decoration,
3
+ DecorationSet,
4
+ Extension,
5
+ Fragment,
6
+ Mapping,
7
+ NodeSelection,
8
+ Plugin,
9
+ PluginKey,
10
+ Selection,
11
+ Slice,
12
+ TextSelection,
13
+ callOrReturn,
14
+ dropPoint,
15
+ getChangedRanges,
16
+ getExtensionField,
17
+ isNodeEmpty,
18
+ isNodeSelection,
19
+ keydownHandler
20
+ } from "./chunk-A3XXZBOQ.js";
21
+
22
+ // node_modules/prosemirror-dropcursor/dist/index.js
23
+ function dropCursor(options = {}) {
24
+ return new Plugin({
25
+ view(editorView) {
26
+ return new DropCursorView(editorView, options);
27
+ }
28
+ });
29
+ }
30
+ var DropCursorView = class {
31
+ constructor(editorView, options) {
32
+ var _a;
33
+ this.editorView = editorView;
34
+ this.cursorPos = null;
35
+ this.element = null;
36
+ this.timeout = -1;
37
+ this.width = (_a = options.width) !== null && _a !== void 0 ? _a : 1;
38
+ this.color = options.color === false ? void 0 : options.color || "black";
39
+ this.class = options.class;
40
+ this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((name) => {
41
+ let handler = (e) => {
42
+ this[name](e);
43
+ };
44
+ editorView.dom.addEventListener(name, handler);
45
+ return { name, handler };
46
+ });
47
+ }
48
+ destroy() {
49
+ this.handlers.forEach(({ name, handler }) => this.editorView.dom.removeEventListener(name, handler));
50
+ }
51
+ update(editorView, prevState) {
52
+ if (this.cursorPos != null && prevState.doc != editorView.state.doc) {
53
+ if (this.cursorPos > editorView.state.doc.content.size)
54
+ this.setCursor(null);
55
+ else
56
+ this.updateOverlay();
57
+ }
58
+ }
59
+ setCursor(pos) {
60
+ if (pos == this.cursorPos)
61
+ return;
62
+ this.cursorPos = pos;
63
+ if (pos == null) {
64
+ this.element.parentNode.removeChild(this.element);
65
+ this.element = null;
66
+ } else {
67
+ this.updateOverlay();
68
+ }
69
+ }
70
+ updateOverlay() {
71
+ let $pos = this.editorView.state.doc.resolve(this.cursorPos);
72
+ let isBlock = !$pos.parent.inlineContent, rect;
73
+ let editorDOM = this.editorView.dom, editorRect = editorDOM.getBoundingClientRect();
74
+ let scaleX = editorRect.width / editorDOM.offsetWidth, scaleY = editorRect.height / editorDOM.offsetHeight;
75
+ if (isBlock) {
76
+ let before = $pos.nodeBefore, after = $pos.nodeAfter;
77
+ if (before || after) {
78
+ let node = this.editorView.nodeDOM(this.cursorPos - (before ? before.nodeSize : 0));
79
+ if (node) {
80
+ let nodeRect = node.getBoundingClientRect();
81
+ let top = before ? nodeRect.bottom : nodeRect.top;
82
+ if (before && after)
83
+ top = (top + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2;
84
+ let halfWidth = this.width / 2 * scaleY;
85
+ rect = { left: nodeRect.left, right: nodeRect.right, top: top - halfWidth, bottom: top + halfWidth };
86
+ }
87
+ }
88
+ }
89
+ if (!rect) {
90
+ let coords = this.editorView.coordsAtPos(this.cursorPos);
91
+ let halfWidth = this.width / 2 * scaleX;
92
+ rect = { left: coords.left - halfWidth, right: coords.left + halfWidth, top: coords.top, bottom: coords.bottom };
93
+ }
94
+ let parent = this.editorView.dom.offsetParent;
95
+ if (!this.element) {
96
+ this.element = parent.appendChild(document.createElement("div"));
97
+ if (this.class)
98
+ this.element.className = this.class;
99
+ this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;";
100
+ if (this.color) {
101
+ this.element.style.backgroundColor = this.color;
102
+ }
103
+ }
104
+ this.element.classList.toggle("prosemirror-dropcursor-block", isBlock);
105
+ this.element.classList.toggle("prosemirror-dropcursor-inline", !isBlock);
106
+ let parentLeft, parentTop;
107
+ if (!parent || parent == document.body && getComputedStyle(parent).position == "static") {
108
+ parentLeft = -pageXOffset;
109
+ parentTop = -pageYOffset;
110
+ } else {
111
+ let rect2 = parent.getBoundingClientRect();
112
+ let parentScaleX = rect2.width / parent.offsetWidth, parentScaleY = rect2.height / parent.offsetHeight;
113
+ parentLeft = rect2.left - parent.scrollLeft * parentScaleX;
114
+ parentTop = rect2.top - parent.scrollTop * parentScaleY;
115
+ }
116
+ this.element.style.left = (rect.left - parentLeft) / scaleX + "px";
117
+ this.element.style.top = (rect.top - parentTop) / scaleY + "px";
118
+ this.element.style.width = (rect.right - rect.left) / scaleX + "px";
119
+ this.element.style.height = (rect.bottom - rect.top) / scaleY + "px";
120
+ }
121
+ scheduleRemoval(timeout) {
122
+ clearTimeout(this.timeout);
123
+ this.timeout = setTimeout(() => this.setCursor(null), timeout);
124
+ }
125
+ dragover(event) {
126
+ if (!this.editorView.editable)
127
+ return;
128
+ let pos = this.editorView.posAtCoords({ left: event.clientX, top: event.clientY });
129
+ let node = pos && pos.inside >= 0 && this.editorView.state.doc.nodeAt(pos.inside);
130
+ let disableDropCursor = node && node.type.spec.disableDropCursor;
131
+ let disabled = typeof disableDropCursor == "function" ? disableDropCursor(this.editorView, pos, event) : disableDropCursor;
132
+ if (pos && !disabled) {
133
+ let target = pos.pos;
134
+ if (this.editorView.dragging && this.editorView.dragging.slice) {
135
+ let point = dropPoint(this.editorView.state.doc, target, this.editorView.dragging.slice);
136
+ if (point != null)
137
+ target = point;
138
+ }
139
+ this.setCursor(target);
140
+ this.scheduleRemoval(5e3);
141
+ }
142
+ }
143
+ dragend() {
144
+ this.scheduleRemoval(20);
145
+ }
146
+ drop() {
147
+ this.scheduleRemoval(20);
148
+ }
149
+ dragleave(event) {
150
+ if (!this.editorView.dom.contains(event.relatedTarget))
151
+ this.setCursor(null);
152
+ }
153
+ };
154
+
155
+ // node_modules/prosemirror-gapcursor/dist/index.js
156
+ var GapCursor = class _GapCursor extends Selection {
157
+ /**
158
+ Create a gap cursor.
159
+ */
160
+ constructor($pos) {
161
+ super($pos, $pos);
162
+ }
163
+ map(doc, mapping) {
164
+ let $pos = doc.resolve(mapping.map(this.head));
165
+ return _GapCursor.valid($pos) ? new _GapCursor($pos) : Selection.near($pos);
166
+ }
167
+ content() {
168
+ return Slice.empty;
169
+ }
170
+ eq(other) {
171
+ return other instanceof _GapCursor && other.head == this.head;
172
+ }
173
+ toJSON() {
174
+ return { type: "gapcursor", pos: this.head };
175
+ }
176
+ /**
177
+ @internal
178
+ */
179
+ static fromJSON(doc, json) {
180
+ if (typeof json.pos != "number")
181
+ throw new RangeError("Invalid input for GapCursor.fromJSON");
182
+ return new _GapCursor(doc.resolve(json.pos));
183
+ }
184
+ /**
185
+ @internal
186
+ */
187
+ getBookmark() {
188
+ return new GapBookmark(this.anchor);
189
+ }
190
+ /**
191
+ @internal
192
+ */
193
+ static valid($pos) {
194
+ let parent = $pos.parent;
195
+ if (parent.inlineContent || !closedBefore($pos) || !closedAfter($pos))
196
+ return false;
197
+ let override = parent.type.spec.allowGapCursor;
198
+ if (override != null)
199
+ return override;
200
+ let deflt = parent.contentMatchAt($pos.index()).defaultType;
201
+ return deflt && deflt.isTextblock;
202
+ }
203
+ /**
204
+ @internal
205
+ */
206
+ static findGapCursorFrom($pos, dir, mustMove = false) {
207
+ search: for (; ; ) {
208
+ if (!mustMove && _GapCursor.valid($pos))
209
+ return $pos;
210
+ let pos = $pos.pos, next = null;
211
+ for (let d = $pos.depth; ; d--) {
212
+ let parent = $pos.node(d);
213
+ if (dir > 0 ? $pos.indexAfter(d) < parent.childCount : $pos.index(d) > 0) {
214
+ next = parent.child(dir > 0 ? $pos.indexAfter(d) : $pos.index(d) - 1);
215
+ break;
216
+ } else if (d == 0) {
217
+ return null;
218
+ }
219
+ pos += dir;
220
+ let $cur = $pos.doc.resolve(pos);
221
+ if (_GapCursor.valid($cur))
222
+ return $cur;
223
+ }
224
+ for (; ; ) {
225
+ let inside = dir > 0 ? next.firstChild : next.lastChild;
226
+ if (!inside) {
227
+ if (next.isAtom && !next.isText && !NodeSelection.isSelectable(next)) {
228
+ $pos = $pos.doc.resolve(pos + next.nodeSize * dir);
229
+ mustMove = false;
230
+ continue search;
231
+ }
232
+ break;
233
+ }
234
+ next = inside;
235
+ pos += dir;
236
+ let $cur = $pos.doc.resolve(pos);
237
+ if (_GapCursor.valid($cur))
238
+ return $cur;
239
+ }
240
+ return null;
241
+ }
242
+ }
243
+ };
244
+ GapCursor.prototype.visible = false;
245
+ GapCursor.findFrom = GapCursor.findGapCursorFrom;
246
+ Selection.jsonID("gapcursor", GapCursor);
247
+ var GapBookmark = class _GapBookmark {
248
+ constructor(pos) {
249
+ this.pos = pos;
250
+ }
251
+ map(mapping) {
252
+ return new _GapBookmark(mapping.map(this.pos));
253
+ }
254
+ resolve(doc) {
255
+ let $pos = doc.resolve(this.pos);
256
+ return GapCursor.valid($pos) ? new GapCursor($pos) : Selection.near($pos);
257
+ }
258
+ };
259
+ function needsGap(type) {
260
+ return type.isAtom || type.spec.isolating || type.spec.createGapCursor;
261
+ }
262
+ function closedBefore($pos) {
263
+ for (let d = $pos.depth; d >= 0; d--) {
264
+ let index = $pos.index(d), parent = $pos.node(d);
265
+ if (index == 0) {
266
+ if (parent.type.spec.isolating)
267
+ return true;
268
+ continue;
269
+ }
270
+ for (let before = parent.child(index - 1); ; before = before.lastChild) {
271
+ if (before.childCount == 0 && !before.inlineContent || needsGap(before.type))
272
+ return true;
273
+ if (before.inlineContent)
274
+ return false;
275
+ }
276
+ }
277
+ return true;
278
+ }
279
+ function closedAfter($pos) {
280
+ for (let d = $pos.depth; d >= 0; d--) {
281
+ let index = $pos.indexAfter(d), parent = $pos.node(d);
282
+ if (index == parent.childCount) {
283
+ if (parent.type.spec.isolating)
284
+ return true;
285
+ continue;
286
+ }
287
+ for (let after = parent.child(index); ; after = after.firstChild) {
288
+ if (after.childCount == 0 && !after.inlineContent || needsGap(after.type))
289
+ return true;
290
+ if (after.inlineContent)
291
+ return false;
292
+ }
293
+ }
294
+ return true;
295
+ }
296
+ function gapCursor() {
297
+ return new Plugin({
298
+ props: {
299
+ decorations: drawGapCursor,
300
+ createSelectionBetween(_view, $anchor, $head) {
301
+ return $anchor.pos == $head.pos && GapCursor.valid($head) ? new GapCursor($head) : null;
302
+ },
303
+ handleClick,
304
+ handleKeyDown,
305
+ handleDOMEvents: { beforeinput }
306
+ }
307
+ });
308
+ }
309
+ var handleKeyDown = keydownHandler({
310
+ "ArrowLeft": arrow("horiz", -1),
311
+ "ArrowRight": arrow("horiz", 1),
312
+ "ArrowUp": arrow("vert", -1),
313
+ "ArrowDown": arrow("vert", 1)
314
+ });
315
+ function arrow(axis, dir) {
316
+ const dirStr = axis == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
317
+ return function(state, dispatch, view) {
318
+ let sel = state.selection;
319
+ let $start = dir > 0 ? sel.$to : sel.$from, mustMove = sel.empty;
320
+ if (sel instanceof TextSelection) {
321
+ if (!view.endOfTextblock(dirStr) || $start.depth == 0)
322
+ return false;
323
+ mustMove = false;
324
+ $start = state.doc.resolve(dir > 0 ? $start.after() : $start.before());
325
+ }
326
+ let $found = GapCursor.findGapCursorFrom($start, dir, mustMove);
327
+ if (!$found)
328
+ return false;
329
+ if (dispatch)
330
+ dispatch(state.tr.setSelection(new GapCursor($found)));
331
+ return true;
332
+ };
333
+ }
334
+ function handleClick(view, pos, event) {
335
+ if (!view || !view.editable)
336
+ return false;
337
+ let $pos = view.state.doc.resolve(pos);
338
+ if (!GapCursor.valid($pos))
339
+ return false;
340
+ let clickPos = view.posAtCoords({ left: event.clientX, top: event.clientY });
341
+ if (clickPos && clickPos.inside > -1 && NodeSelection.isSelectable(view.state.doc.nodeAt(clickPos.inside)))
342
+ return false;
343
+ view.dispatch(view.state.tr.setSelection(new GapCursor($pos)));
344
+ return true;
345
+ }
346
+ function beforeinput(view, event) {
347
+ if (event.inputType != "insertCompositionText" || !(view.state.selection instanceof GapCursor))
348
+ return false;
349
+ let { $from } = view.state.selection;
350
+ let insert = $from.parent.contentMatchAt($from.index()).findWrapping(view.state.schema.nodes.text);
351
+ if (!insert)
352
+ return false;
353
+ let frag = Fragment.empty;
354
+ for (let i = insert.length - 1; i >= 0; i--)
355
+ frag = Fragment.from(insert[i].createAndFill(null, frag));
356
+ let tr = view.state.tr.replace($from.pos, $from.pos, new Slice(frag, 0, 0));
357
+ tr.setSelection(TextSelection.near(tr.doc.resolve($from.pos + 1)));
358
+ view.dispatch(tr);
359
+ return false;
360
+ }
361
+ function drawGapCursor(state) {
362
+ if (!(state.selection instanceof GapCursor))
363
+ return null;
364
+ let node = document.createElement("div");
365
+ node.className = "ProseMirror-gapcursor";
366
+ return DecorationSet.create(state.doc, [Decoration.widget(state.selection.head, node, { key: "gapcursor" })]);
367
+ }
368
+
369
+ // node_modules/rope-sequence/dist/index.js
370
+ var GOOD_LEAF_SIZE = 200;
371
+ var RopeSequence = function RopeSequence2() {
372
+ };
373
+ RopeSequence.prototype.append = function append(other) {
374
+ if (!other.length) {
375
+ return this;
376
+ }
377
+ other = RopeSequence.from(other);
378
+ return !this.length && other || other.length < GOOD_LEAF_SIZE && this.leafAppend(other) || this.length < GOOD_LEAF_SIZE && other.leafPrepend(this) || this.appendInner(other);
379
+ };
380
+ RopeSequence.prototype.prepend = function prepend(other) {
381
+ if (!other.length) {
382
+ return this;
383
+ }
384
+ return RopeSequence.from(other).append(this);
385
+ };
386
+ RopeSequence.prototype.appendInner = function appendInner(other) {
387
+ return new Append(this, other);
388
+ };
389
+ RopeSequence.prototype.slice = function slice(from2, to) {
390
+ if (from2 === void 0) from2 = 0;
391
+ if (to === void 0) to = this.length;
392
+ if (from2 >= to) {
393
+ return RopeSequence.empty;
394
+ }
395
+ return this.sliceInner(Math.max(0, from2), Math.min(this.length, to));
396
+ };
397
+ RopeSequence.prototype.get = function get(i) {
398
+ if (i < 0 || i >= this.length) {
399
+ return void 0;
400
+ }
401
+ return this.getInner(i);
402
+ };
403
+ RopeSequence.prototype.forEach = function forEach(f, from2, to) {
404
+ if (from2 === void 0) from2 = 0;
405
+ if (to === void 0) to = this.length;
406
+ if (from2 <= to) {
407
+ this.forEachInner(f, from2, to, 0);
408
+ } else {
409
+ this.forEachInvertedInner(f, from2, to, 0);
410
+ }
411
+ };
412
+ RopeSequence.prototype.map = function map(f, from2, to) {
413
+ if (from2 === void 0) from2 = 0;
414
+ if (to === void 0) to = this.length;
415
+ var result = [];
416
+ this.forEach(function(elt, i) {
417
+ return result.push(f(elt, i));
418
+ }, from2, to);
419
+ return result;
420
+ };
421
+ RopeSequence.from = function from(values) {
422
+ if (values instanceof RopeSequence) {
423
+ return values;
424
+ }
425
+ return values && values.length ? new Leaf(values) : RopeSequence.empty;
426
+ };
427
+ var Leaf = /* @__PURE__ */ (function(RopeSequence3) {
428
+ function Leaf2(values) {
429
+ RopeSequence3.call(this);
430
+ this.values = values;
431
+ }
432
+ if (RopeSequence3) Leaf2.__proto__ = RopeSequence3;
433
+ Leaf2.prototype = Object.create(RopeSequence3 && RopeSequence3.prototype);
434
+ Leaf2.prototype.constructor = Leaf2;
435
+ var prototypeAccessors = { length: { configurable: true }, depth: { configurable: true } };
436
+ Leaf2.prototype.flatten = function flatten() {
437
+ return this.values;
438
+ };
439
+ Leaf2.prototype.sliceInner = function sliceInner(from2, to) {
440
+ if (from2 == 0 && to == this.length) {
441
+ return this;
442
+ }
443
+ return new Leaf2(this.values.slice(from2, to));
444
+ };
445
+ Leaf2.prototype.getInner = function getInner(i) {
446
+ return this.values[i];
447
+ };
448
+ Leaf2.prototype.forEachInner = function forEachInner(f, from2, to, start) {
449
+ for (var i = from2; i < to; i++) {
450
+ if (f(this.values[i], start + i) === false) {
451
+ return false;
452
+ }
453
+ }
454
+ };
455
+ Leaf2.prototype.forEachInvertedInner = function forEachInvertedInner(f, from2, to, start) {
456
+ for (var i = from2 - 1; i >= to; i--) {
457
+ if (f(this.values[i], start + i) === false) {
458
+ return false;
459
+ }
460
+ }
461
+ };
462
+ Leaf2.prototype.leafAppend = function leafAppend(other) {
463
+ if (this.length + other.length <= GOOD_LEAF_SIZE) {
464
+ return new Leaf2(this.values.concat(other.flatten()));
465
+ }
466
+ };
467
+ Leaf2.prototype.leafPrepend = function leafPrepend(other) {
468
+ if (this.length + other.length <= GOOD_LEAF_SIZE) {
469
+ return new Leaf2(other.flatten().concat(this.values));
470
+ }
471
+ };
472
+ prototypeAccessors.length.get = function() {
473
+ return this.values.length;
474
+ };
475
+ prototypeAccessors.depth.get = function() {
476
+ return 0;
477
+ };
478
+ Object.defineProperties(Leaf2.prototype, prototypeAccessors);
479
+ return Leaf2;
480
+ })(RopeSequence);
481
+ RopeSequence.empty = new Leaf([]);
482
+ var Append = /* @__PURE__ */ (function(RopeSequence3) {
483
+ function Append2(left, right) {
484
+ RopeSequence3.call(this);
485
+ this.left = left;
486
+ this.right = right;
487
+ this.length = left.length + right.length;
488
+ this.depth = Math.max(left.depth, right.depth) + 1;
489
+ }
490
+ if (RopeSequence3) Append2.__proto__ = RopeSequence3;
491
+ Append2.prototype = Object.create(RopeSequence3 && RopeSequence3.prototype);
492
+ Append2.prototype.constructor = Append2;
493
+ Append2.prototype.flatten = function flatten() {
494
+ return this.left.flatten().concat(this.right.flatten());
495
+ };
496
+ Append2.prototype.getInner = function getInner(i) {
497
+ return i < this.left.length ? this.left.get(i) : this.right.get(i - this.left.length);
498
+ };
499
+ Append2.prototype.forEachInner = function forEachInner(f, from2, to, start) {
500
+ var leftLen = this.left.length;
501
+ if (from2 < leftLen && this.left.forEachInner(f, from2, Math.min(to, leftLen), start) === false) {
502
+ return false;
503
+ }
504
+ if (to > leftLen && this.right.forEachInner(f, Math.max(from2 - leftLen, 0), Math.min(this.length, to) - leftLen, start + leftLen) === false) {
505
+ return false;
506
+ }
507
+ };
508
+ Append2.prototype.forEachInvertedInner = function forEachInvertedInner(f, from2, to, start) {
509
+ var leftLen = this.left.length;
510
+ if (from2 > leftLen && this.right.forEachInvertedInner(f, from2 - leftLen, Math.max(to, leftLen) - leftLen, start + leftLen) === false) {
511
+ return false;
512
+ }
513
+ if (to < leftLen && this.left.forEachInvertedInner(f, Math.min(from2, leftLen), to, start) === false) {
514
+ return false;
515
+ }
516
+ };
517
+ Append2.prototype.sliceInner = function sliceInner(from2, to) {
518
+ if (from2 == 0 && to == this.length) {
519
+ return this;
520
+ }
521
+ var leftLen = this.left.length;
522
+ if (to <= leftLen) {
523
+ return this.left.slice(from2, to);
524
+ }
525
+ if (from2 >= leftLen) {
526
+ return this.right.slice(from2 - leftLen, to - leftLen);
527
+ }
528
+ return this.left.slice(from2, leftLen).append(this.right.slice(0, to - leftLen));
529
+ };
530
+ Append2.prototype.leafAppend = function leafAppend(other) {
531
+ var inner = this.right.leafAppend(other);
532
+ if (inner) {
533
+ return new Append2(this.left, inner);
534
+ }
535
+ };
536
+ Append2.prototype.leafPrepend = function leafPrepend(other) {
537
+ var inner = this.left.leafPrepend(other);
538
+ if (inner) {
539
+ return new Append2(inner, this.right);
540
+ }
541
+ };
542
+ Append2.prototype.appendInner = function appendInner2(other) {
543
+ if (this.left.depth >= Math.max(this.right.depth, other.depth) + 1) {
544
+ return new Append2(this.left, new Append2(this.right, other));
545
+ }
546
+ return new Append2(this, other);
547
+ };
548
+ return Append2;
549
+ })(RopeSequence);
550
+ var dist_default = RopeSequence;
551
+
552
+ // node_modules/prosemirror-history/dist/index.js
553
+ var max_empty_items = 500;
554
+ var Branch = class _Branch {
555
+ constructor(items, eventCount) {
556
+ this.items = items;
557
+ this.eventCount = eventCount;
558
+ }
559
+ // Pop the latest event off the branch's history and apply it
560
+ // to a document transform.
561
+ popEvent(state, preserveItems) {
562
+ if (this.eventCount == 0)
563
+ return null;
564
+ let end = this.items.length;
565
+ for (; ; end--) {
566
+ let next = this.items.get(end - 1);
567
+ if (next.selection) {
568
+ --end;
569
+ break;
570
+ }
571
+ }
572
+ let remap, mapFrom;
573
+ if (preserveItems) {
574
+ remap = this.remapping(end, this.items.length);
575
+ mapFrom = remap.maps.length;
576
+ }
577
+ let transform = state.tr;
578
+ let selection, remaining;
579
+ let addAfter = [], addBefore = [];
580
+ this.items.forEach((item, i) => {
581
+ if (!item.step) {
582
+ if (!remap) {
583
+ remap = this.remapping(end, i + 1);
584
+ mapFrom = remap.maps.length;
585
+ }
586
+ mapFrom--;
587
+ addBefore.push(item);
588
+ return;
589
+ }
590
+ if (remap) {
591
+ addBefore.push(new Item(item.map));
592
+ let step = item.step.map(remap.slice(mapFrom)), map2;
593
+ if (step && transform.maybeStep(step).doc) {
594
+ map2 = transform.mapping.maps[transform.mapping.maps.length - 1];
595
+ addAfter.push(new Item(map2, void 0, void 0, addAfter.length + addBefore.length));
596
+ }
597
+ mapFrom--;
598
+ if (map2)
599
+ remap.appendMap(map2, mapFrom);
600
+ } else {
601
+ transform.maybeStep(item.step);
602
+ }
603
+ if (item.selection) {
604
+ selection = remap ? item.selection.map(remap.slice(mapFrom)) : item.selection;
605
+ remaining = new _Branch(this.items.slice(0, end).append(addBefore.reverse().concat(addAfter)), this.eventCount - 1);
606
+ return false;
607
+ }
608
+ }, this.items.length, 0);
609
+ return { remaining, transform, selection };
610
+ }
611
+ // Create a new branch with the given transform added.
612
+ addTransform(transform, selection, histOptions, preserveItems) {
613
+ let newItems = [], eventCount = this.eventCount;
614
+ let oldItems = this.items, lastItem = !preserveItems && oldItems.length ? oldItems.get(oldItems.length - 1) : null;
615
+ for (let i = 0; i < transform.steps.length; i++) {
616
+ let step = transform.steps[i].invert(transform.docs[i]);
617
+ let item = new Item(transform.mapping.maps[i], step, selection), merged;
618
+ if (merged = lastItem && lastItem.merge(item)) {
619
+ item = merged;
620
+ if (i)
621
+ newItems.pop();
622
+ else
623
+ oldItems = oldItems.slice(0, oldItems.length - 1);
624
+ }
625
+ newItems.push(item);
626
+ if (selection) {
627
+ eventCount++;
628
+ selection = void 0;
629
+ }
630
+ if (!preserveItems)
631
+ lastItem = item;
632
+ }
633
+ let overflow = eventCount - histOptions.depth;
634
+ if (overflow > DEPTH_OVERFLOW) {
635
+ oldItems = cutOffEvents(oldItems, overflow);
636
+ eventCount -= overflow;
637
+ }
638
+ return new _Branch(oldItems.append(newItems), eventCount);
639
+ }
640
+ remapping(from2, to) {
641
+ let maps = new Mapping();
642
+ this.items.forEach((item, i) => {
643
+ let mirrorPos = item.mirrorOffset != null && i - item.mirrorOffset >= from2 ? maps.maps.length - item.mirrorOffset : void 0;
644
+ maps.appendMap(item.map, mirrorPos);
645
+ }, from2, to);
646
+ return maps;
647
+ }
648
+ addMaps(array) {
649
+ if (this.eventCount == 0)
650
+ return this;
651
+ return new _Branch(this.items.append(array.map((map2) => new Item(map2))), this.eventCount);
652
+ }
653
+ // When the collab module receives remote changes, the history has
654
+ // to know about those, so that it can adjust the steps that were
655
+ // rebased on top of the remote changes, and include the position
656
+ // maps for the remote changes in its array of items.
657
+ rebased(rebasedTransform, rebasedCount) {
658
+ if (!this.eventCount)
659
+ return this;
660
+ let rebasedItems = [], start = Math.max(0, this.items.length - rebasedCount);
661
+ let mapping = rebasedTransform.mapping;
662
+ let newUntil = rebasedTransform.steps.length;
663
+ let eventCount = this.eventCount;
664
+ this.items.forEach((item) => {
665
+ if (item.selection)
666
+ eventCount--;
667
+ }, start);
668
+ let iRebased = rebasedCount;
669
+ this.items.forEach((item) => {
670
+ let pos = mapping.getMirror(--iRebased);
671
+ if (pos == null)
672
+ return;
673
+ newUntil = Math.min(newUntil, pos);
674
+ let map2 = mapping.maps[pos];
675
+ if (item.step) {
676
+ let step = rebasedTransform.steps[pos].invert(rebasedTransform.docs[pos]);
677
+ let selection = item.selection && item.selection.map(mapping.slice(iRebased + 1, pos));
678
+ if (selection)
679
+ eventCount++;
680
+ rebasedItems.push(new Item(map2, step, selection));
681
+ } else {
682
+ rebasedItems.push(new Item(map2));
683
+ }
684
+ }, start);
685
+ let newMaps = [];
686
+ for (let i = rebasedCount; i < newUntil; i++)
687
+ newMaps.push(new Item(mapping.maps[i]));
688
+ let items = this.items.slice(0, start).append(newMaps).append(rebasedItems);
689
+ let branch = new _Branch(items, eventCount);
690
+ if (branch.emptyItemCount() > max_empty_items)
691
+ branch = branch.compress(this.items.length - rebasedItems.length);
692
+ return branch;
693
+ }
694
+ emptyItemCount() {
695
+ let count = 0;
696
+ this.items.forEach((item) => {
697
+ if (!item.step)
698
+ count++;
699
+ });
700
+ return count;
701
+ }
702
+ // Compressing a branch means rewriting it to push the air (map-only
703
+ // items) out. During collaboration, these naturally accumulate
704
+ // because each remote change adds one. The `upto` argument is used
705
+ // to ensure that only the items below a given level are compressed,
706
+ // because `rebased` relies on a clean, untouched set of items in
707
+ // order to associate old items with rebased steps.
708
+ compress(upto = this.items.length) {
709
+ let remap = this.remapping(0, upto), mapFrom = remap.maps.length;
710
+ let items = [], events = 0;
711
+ this.items.forEach((item, i) => {
712
+ if (i >= upto) {
713
+ items.push(item);
714
+ if (item.selection)
715
+ events++;
716
+ } else if (item.step) {
717
+ let step = item.step.map(remap.slice(mapFrom)), map2 = step && step.getMap();
718
+ mapFrom--;
719
+ if (map2)
720
+ remap.appendMap(map2, mapFrom);
721
+ if (step) {
722
+ let selection = item.selection && item.selection.map(remap.slice(mapFrom));
723
+ if (selection)
724
+ events++;
725
+ let newItem = new Item(map2.invert(), step, selection), merged, last = items.length - 1;
726
+ if (merged = items.length && items[last].merge(newItem))
727
+ items[last] = merged;
728
+ else
729
+ items.push(newItem);
730
+ }
731
+ } else if (item.map) {
732
+ mapFrom--;
733
+ }
734
+ }, this.items.length, 0);
735
+ return new _Branch(dist_default.from(items.reverse()), events);
736
+ }
737
+ };
738
+ Branch.empty = new Branch(dist_default.empty, 0);
739
+ function cutOffEvents(items, n) {
740
+ let cutPoint;
741
+ items.forEach((item, i) => {
742
+ if (item.selection && n-- == 0) {
743
+ cutPoint = i;
744
+ return false;
745
+ }
746
+ });
747
+ return items.slice(cutPoint);
748
+ }
749
+ var Item = class _Item {
750
+ constructor(map2, step, selection, mirrorOffset) {
751
+ this.map = map2;
752
+ this.step = step;
753
+ this.selection = selection;
754
+ this.mirrorOffset = mirrorOffset;
755
+ }
756
+ merge(other) {
757
+ if (this.step && other.step && !other.selection) {
758
+ let step = other.step.merge(this.step);
759
+ if (step)
760
+ return new _Item(step.getMap().invert(), step, this.selection);
761
+ }
762
+ }
763
+ };
764
+ var HistoryState = class {
765
+ constructor(done, undone, prevRanges, prevTime, prevComposition) {
766
+ this.done = done;
767
+ this.undone = undone;
768
+ this.prevRanges = prevRanges;
769
+ this.prevTime = prevTime;
770
+ this.prevComposition = prevComposition;
771
+ }
772
+ };
773
+ var DEPTH_OVERFLOW = 20;
774
+ function applyTransaction(history2, state, tr, options) {
775
+ let historyTr = tr.getMeta(historyKey), rebased;
776
+ if (historyTr)
777
+ return historyTr.historyState;
778
+ if (tr.getMeta(closeHistoryKey))
779
+ history2 = new HistoryState(history2.done, history2.undone, null, 0, -1);
780
+ let appended = tr.getMeta("appendedTransaction");
781
+ if (tr.steps.length == 0) {
782
+ return history2;
783
+ } else if (appended && appended.getMeta(historyKey)) {
784
+ if (appended.getMeta(historyKey).redo)
785
+ return new HistoryState(history2.done.addTransform(tr, void 0, options, mustPreserveItems(state)), history2.undone, rangesFor(tr.mapping.maps), history2.prevTime, history2.prevComposition);
786
+ else
787
+ return new HistoryState(history2.done, history2.undone.addTransform(tr, void 0, options, mustPreserveItems(state)), null, history2.prevTime, history2.prevComposition);
788
+ } else if (tr.getMeta("addToHistory") !== false && !(appended && appended.getMeta("addToHistory") === false)) {
789
+ let composition = tr.getMeta("composition");
790
+ let newGroup = history2.prevTime == 0 || !appended && history2.prevComposition != composition && (history2.prevTime < (tr.time || 0) - options.newGroupDelay || !isAdjacentTo(tr, history2.prevRanges));
791
+ let prevRanges = appended ? mapRanges(history2.prevRanges, tr.mapping) : rangesFor(tr.mapping.maps);
792
+ return new HistoryState(history2.done.addTransform(tr, newGroup ? state.selection.getBookmark() : void 0, options, mustPreserveItems(state)), Branch.empty, prevRanges, tr.time, composition == null ? history2.prevComposition : composition);
793
+ } else if (rebased = tr.getMeta("rebased")) {
794
+ return new HistoryState(history2.done.rebased(tr, rebased), history2.undone.rebased(tr, rebased), mapRanges(history2.prevRanges, tr.mapping), history2.prevTime, history2.prevComposition);
795
+ } else {
796
+ return new HistoryState(history2.done.addMaps(tr.mapping.maps), history2.undone.addMaps(tr.mapping.maps), mapRanges(history2.prevRanges, tr.mapping), history2.prevTime, history2.prevComposition);
797
+ }
798
+ }
799
+ function isAdjacentTo(transform, prevRanges) {
800
+ if (!prevRanges)
801
+ return false;
802
+ if (!transform.docChanged)
803
+ return true;
804
+ let adjacent = false;
805
+ transform.mapping.maps[0].forEach((start, end) => {
806
+ for (let i = 0; i < prevRanges.length; i += 2)
807
+ if (start <= prevRanges[i + 1] && end >= prevRanges[i])
808
+ adjacent = true;
809
+ });
810
+ return adjacent;
811
+ }
812
+ function rangesFor(maps) {
813
+ let result = [];
814
+ for (let i = maps.length - 1; i >= 0 && result.length == 0; i--)
815
+ maps[i].forEach((_from, _to, from2, to) => result.push(from2, to));
816
+ return result;
817
+ }
818
+ function mapRanges(ranges, mapping) {
819
+ if (!ranges)
820
+ return null;
821
+ let result = [];
822
+ for (let i = 0; i < ranges.length; i += 2) {
823
+ let from2 = mapping.map(ranges[i], 1), to = mapping.map(ranges[i + 1], -1);
824
+ if (from2 <= to)
825
+ result.push(from2, to);
826
+ }
827
+ return result;
828
+ }
829
+ function histTransaction(history2, state, redo2) {
830
+ let preserveItems = mustPreserveItems(state);
831
+ let histOptions = historyKey.get(state).spec.config;
832
+ let pop = (redo2 ? history2.undone : history2.done).popEvent(state, preserveItems);
833
+ if (!pop)
834
+ return null;
835
+ let selection = pop.selection.resolve(pop.transform.doc);
836
+ let added = (redo2 ? history2.done : history2.undone).addTransform(pop.transform, state.selection.getBookmark(), histOptions, preserveItems);
837
+ let newHist = new HistoryState(redo2 ? added : pop.remaining, redo2 ? pop.remaining : added, null, 0, -1);
838
+ return pop.transform.setSelection(selection).setMeta(historyKey, { redo: redo2, historyState: newHist });
839
+ }
840
+ var cachedPreserveItems = false;
841
+ var cachedPreserveItemsPlugins = null;
842
+ function mustPreserveItems(state) {
843
+ let plugins = state.plugins;
844
+ if (cachedPreserveItemsPlugins != plugins) {
845
+ cachedPreserveItems = false;
846
+ cachedPreserveItemsPlugins = plugins;
847
+ for (let i = 0; i < plugins.length; i++)
848
+ if (plugins[i].spec.historyPreserveItems) {
849
+ cachedPreserveItems = true;
850
+ break;
851
+ }
852
+ }
853
+ return cachedPreserveItems;
854
+ }
855
+ var historyKey = new PluginKey("history");
856
+ var closeHistoryKey = new PluginKey("closeHistory");
857
+ function history(config = {}) {
858
+ config = {
859
+ depth: config.depth || 100,
860
+ newGroupDelay: config.newGroupDelay || 500
861
+ };
862
+ return new Plugin({
863
+ key: historyKey,
864
+ state: {
865
+ init() {
866
+ return new HistoryState(Branch.empty, Branch.empty, null, 0, -1);
867
+ },
868
+ apply(tr, hist, state) {
869
+ return applyTransaction(hist, state, tr, config);
870
+ }
871
+ },
872
+ config,
873
+ props: {
874
+ handleDOMEvents: {
875
+ beforeinput(view, e) {
876
+ let inputType = e.inputType;
877
+ let command = inputType == "historyUndo" ? undo : inputType == "historyRedo" ? redo : null;
878
+ if (!command || !view.editable)
879
+ return false;
880
+ e.preventDefault();
881
+ return command(view.state, view.dispatch);
882
+ }
883
+ }
884
+ }
885
+ });
886
+ }
887
+ function buildCommand(redo2, scroll) {
888
+ return (state, dispatch) => {
889
+ let hist = historyKey.getState(state);
890
+ if (!hist || (redo2 ? hist.undone : hist.done).eventCount == 0)
891
+ return false;
892
+ if (dispatch) {
893
+ let tr = histTransaction(hist, state, redo2);
894
+ if (tr)
895
+ dispatch(scroll ? tr.scrollIntoView() : tr);
896
+ }
897
+ return true;
898
+ };
899
+ }
900
+ var undo = buildCommand(false, true);
901
+ var redo = buildCommand(true, true);
902
+ var undoNoScroll = buildCommand(false, false);
903
+ var redoNoScroll = buildCommand(true, false);
904
+
905
+ // node_modules/@tiptap/extensions/dist/index.js
906
+ var CharacterCount = Extension.create({
907
+ name: "characterCount",
908
+ addOptions() {
909
+ return {
910
+ limit: null,
911
+ autoTrim: true,
912
+ mode: "textSize",
913
+ textCounter: (text) => text.length,
914
+ wordCounter: (text) => text.split(" ").filter((word) => word !== "").length
915
+ };
916
+ },
917
+ addStorage() {
918
+ return {
919
+ characters: () => 0,
920
+ words: () => 0
921
+ };
922
+ },
923
+ onBeforeCreate() {
924
+ this.storage.characters = (options) => {
925
+ const node = (options === null || options === void 0 ? void 0 : options.node) || this.editor.state.doc;
926
+ if (((options === null || options === void 0 ? void 0 : options.mode) || this.options.mode) === "textSize") {
927
+ const text = node.textBetween(0, node.content.size, void 0, " ");
928
+ return this.options.textCounter(text);
929
+ }
930
+ return node.nodeSize;
931
+ };
932
+ this.storage.words = (options) => {
933
+ const node = (options === null || options === void 0 ? void 0 : options.node) || this.editor.state.doc;
934
+ const text = node.textBetween(0, node.content.size, " ", " ");
935
+ return this.options.wordCounter(text);
936
+ };
937
+ },
938
+ addProseMirrorPlugins() {
939
+ let initialEvaluationDone = false;
940
+ return [new Plugin({
941
+ key: new PluginKey("characterCount"),
942
+ appendTransaction: (transactions, oldState, newState) => {
943
+ if (initialEvaluationDone) return;
944
+ const limit = this.options.limit;
945
+ const autoTrim = this.options.autoTrim;
946
+ if (limit === null || limit === void 0 || limit === 0 || autoTrim === false) {
947
+ initialEvaluationDone = true;
948
+ return;
949
+ }
950
+ const initialContentSize = this.storage.characters({ node: newState.doc });
951
+ if (initialContentSize > limit) {
952
+ const over = initialContentSize - limit;
953
+ const from2 = 0;
954
+ const to = over;
955
+ console.warn(`[CharacterCount] Initial content exceeded limit of ${limit} characters. Content was automatically trimmed.`);
956
+ const tr = newState.tr.deleteRange(from2, to);
957
+ initialEvaluationDone = true;
958
+ return tr;
959
+ }
960
+ initialEvaluationDone = true;
961
+ },
962
+ filterTransaction: (transaction, state) => {
963
+ const limit = this.options.limit;
964
+ if (!transaction.docChanged || limit === 0 || limit === null || limit === void 0) return true;
965
+ const oldSize = this.storage.characters({ node: state.doc });
966
+ const newSize = this.storage.characters({ node: transaction.doc });
967
+ if (newSize <= limit) return true;
968
+ if (oldSize > limit && newSize > limit && newSize <= oldSize) return true;
969
+ if (oldSize > limit && newSize > limit && newSize > oldSize) return false;
970
+ if (!transaction.getMeta("paste")) return false;
971
+ const pos = transaction.selection.$head.pos;
972
+ const from2 = pos - (newSize - limit);
973
+ const to = pos;
974
+ transaction.deleteRange(from2, to);
975
+ if (this.storage.characters({ node: transaction.doc }) > limit) return false;
976
+ return true;
977
+ }
978
+ })];
979
+ }
980
+ });
981
+ var Dropcursor = Extension.create({
982
+ name: "dropCursor",
983
+ addOptions() {
984
+ return {
985
+ color: "currentColor",
986
+ width: 1,
987
+ class: void 0
988
+ };
989
+ },
990
+ addProseMirrorPlugins() {
991
+ return [dropCursor(this.options)];
992
+ }
993
+ });
994
+ var Focus = Extension.create({
995
+ name: "focus",
996
+ addOptions() {
997
+ return {
998
+ className: "has-focus",
999
+ mode: "all"
1000
+ };
1001
+ },
1002
+ addProseMirrorPlugins() {
1003
+ return [new Plugin({
1004
+ key: new PluginKey("focus"),
1005
+ props: { decorations: ({ doc, selection }) => {
1006
+ const { isEditable, isFocused } = this.editor;
1007
+ const { anchor } = selection;
1008
+ const decorations = [];
1009
+ if (!isEditable || !isFocused) return DecorationSet.create(doc, []);
1010
+ let maxLevels = 0;
1011
+ if (this.options.mode === "deepest") doc.descendants((node, pos) => {
1012
+ if (node.isText) return;
1013
+ if (!(anchor >= pos && anchor <= pos + node.nodeSize - 1)) return false;
1014
+ maxLevels += 1;
1015
+ });
1016
+ let currentLevel = 0;
1017
+ doc.descendants((node, pos) => {
1018
+ if (node.isText) return false;
1019
+ if (!(anchor >= pos && anchor <= pos + node.nodeSize - 1)) return false;
1020
+ currentLevel += 1;
1021
+ if (this.options.mode === "deepest" && maxLevels - currentLevel > 0 || this.options.mode === "shallowest" && currentLevel > 1) return this.options.mode === "deepest";
1022
+ decorations.push(Decoration.node(pos, pos + node.nodeSize, { class: this.options.className }));
1023
+ });
1024
+ return DecorationSet.create(doc, decorations);
1025
+ } }
1026
+ })];
1027
+ }
1028
+ });
1029
+ var Gapcursor = Extension.create({
1030
+ name: "gapCursor",
1031
+ addProseMirrorPlugins() {
1032
+ return [gapCursor()];
1033
+ },
1034
+ extendNodeSchema(extension) {
1035
+ var _callOrReturn;
1036
+ const context = {
1037
+ name: extension.name,
1038
+ options: extension.options,
1039
+ storage: extension.storage
1040
+ };
1041
+ return { allowGapCursor: (_callOrReturn = callOrReturn(getExtensionField(extension, "allowGapCursor", context))) !== null && _callOrReturn !== void 0 ? _callOrReturn : null };
1042
+ }
1043
+ });
1044
+ var DEFAULT_DATA_ATTRIBUTE = "placeholder";
1045
+ var PLUGIN_KEY = new PluginKey("tiptap__placeholder");
1046
+ function createPlaceholderDecoration(options) {
1047
+ const { editor, placeholder, dataAttribute, pos, node, isEmptyDoc, hasAnchor, classes: { emptyNode, emptyEditor } } = options;
1048
+ const classes = [emptyNode];
1049
+ if (isEmptyDoc) classes.push(emptyEditor);
1050
+ return Decoration.node(pos, pos + node.nodeSize, {
1051
+ class: classes.join(" "),
1052
+ [dataAttribute]: typeof placeholder === "function" ? placeholder({
1053
+ editor,
1054
+ node,
1055
+ pos,
1056
+ hasAnchor
1057
+ }) : placeholder
1058
+ });
1059
+ }
1060
+ function resolveEmptyNodeClass(emptyNodeClass, props) {
1061
+ return typeof emptyNodeClass === "function" ? emptyNodeClass(props) : emptyNodeClass;
1062
+ }
1063
+ function scanRangeForDecorations({ editor, options, dataAttribute, doc, selection, from: from2, to }) {
1064
+ const { anchor } = selection;
1065
+ const decorations = [];
1066
+ const isEmptyDoc = editor.isEmpty;
1067
+ doc.nodesBetween(from2, to, (node, pos) => {
1068
+ const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize;
1069
+ const isEmpty = !node.isLeaf && isNodeEmpty(node);
1070
+ if (!node.type.isTextblock) return options.includeChildren;
1071
+ if ((hasAnchor || !options.showOnlyCurrent) && isEmpty) decorations.push(createPlaceholderDecoration({
1072
+ editor,
1073
+ isEmptyDoc,
1074
+ dataAttribute,
1075
+ hasAnchor,
1076
+ placeholder: options.placeholder,
1077
+ classes: {
1078
+ emptyEditor: options.emptyEditorClass,
1079
+ emptyNode: resolveEmptyNodeClass(options.emptyNodeClass, {
1080
+ editor,
1081
+ node,
1082
+ pos,
1083
+ hasAnchor
1084
+ })
1085
+ },
1086
+ node,
1087
+ pos
1088
+ }));
1089
+ return options.includeChildren;
1090
+ });
1091
+ return decorations;
1092
+ }
1093
+ function buildPlaceholderDecorations({ editor, options, dataAttribute, doc, selection }) {
1094
+ if (!(editor.isEditable || !options.showOnlyWhenEditable)) return null;
1095
+ const { anchor } = selection;
1096
+ const decorations = [];
1097
+ const isEmptyDoc = editor.isEmpty;
1098
+ if (options.showOnlyCurrent && !options.includeChildren) {
1099
+ const resolved = doc.resolve(anchor);
1100
+ const node = resolved.depth > 0 ? resolved.node(1) : resolved.nodeAfter;
1101
+ const nodeStart = resolved.depth > 0 ? resolved.before(1) : anchor;
1102
+ if (node && node.type.isTextblock && isNodeEmpty(node)) {
1103
+ const hasAnchor = anchor >= nodeStart && anchor <= nodeStart + node.nodeSize;
1104
+ decorations.push(createPlaceholderDecoration({
1105
+ editor,
1106
+ isEmptyDoc,
1107
+ dataAttribute,
1108
+ hasAnchor,
1109
+ placeholder: options.placeholder,
1110
+ classes: {
1111
+ emptyEditor: options.emptyEditorClass,
1112
+ emptyNode: resolveEmptyNodeClass(options.emptyNodeClass, {
1113
+ editor,
1114
+ node,
1115
+ pos: nodeStart,
1116
+ hasAnchor
1117
+ })
1118
+ },
1119
+ node,
1120
+ pos: nodeStart
1121
+ }));
1122
+ }
1123
+ } else decorations.push(...scanRangeForDecorations({
1124
+ editor,
1125
+ options,
1126
+ dataAttribute,
1127
+ doc,
1128
+ selection,
1129
+ from: 0,
1130
+ to: doc.content.size
1131
+ }));
1132
+ return DecorationSet.create(doc, decorations);
1133
+ }
1134
+ function resolveTopLevelRange(doc, pos) {
1135
+ const resolved = doc.resolve(pos);
1136
+ if (resolved.depth === 0) {
1137
+ var _resolved$nodeAfter;
1138
+ const node = (_resolved$nodeAfter = resolved.nodeAfter) !== null && _resolved$nodeAfter !== void 0 ? _resolved$nodeAfter : resolved.nodeBefore;
1139
+ if (!node) return {
1140
+ from: pos,
1141
+ to: pos
1142
+ };
1143
+ const nodePos = resolved.nodeAfter ? pos : pos - node.nodeSize;
1144
+ return {
1145
+ from: nodePos,
1146
+ to: nodePos + node.nodeSize
1147
+ };
1148
+ }
1149
+ const topLevelPos = resolved.before(1);
1150
+ return {
1151
+ from: topLevelPos,
1152
+ to: topLevelPos + resolved.node(1).nodeSize
1153
+ };
1154
+ }
1155
+ function toContentRelativeRange(doc, range) {
1156
+ return {
1157
+ from: Math.max(0, range.from - 1),
1158
+ to: Math.min(doc.content.size, range.to - 1)
1159
+ };
1160
+ }
1161
+ function getTopLevelBlocksInRange(doc, from2, to) {
1162
+ const ranges = [];
1163
+ doc.forEach((node, offset) => {
1164
+ const nodeStart = offset;
1165
+ const nodeEnd = nodeStart + node.nodeSize;
1166
+ const absNodeStart = nodeStart + 1;
1167
+ const absNodeEnd = nodeEnd + 1;
1168
+ if (absNodeStart < to && absNodeEnd > from2) ranges.push({
1169
+ from: nodeStart,
1170
+ to: nodeEnd
1171
+ });
1172
+ });
1173
+ return ranges;
1174
+ }
1175
+ function mergeRanges(ranges) {
1176
+ if (ranges.length === 0) return [];
1177
+ const sorted = [...ranges].sort((a, b) => a.from - b.from);
1178
+ const merged = [{ ...sorted[0] }];
1179
+ for (let i = 1; i < sorted.length; i += 1) {
1180
+ const last = merged[merged.length - 1];
1181
+ const current = sorted[i];
1182
+ if (current.from <= last.to) last.to = Math.max(last.to, current.to);
1183
+ else merged.push({ ...current });
1184
+ }
1185
+ return merged;
1186
+ }
1187
+ function collectBlocksForChange(doc, change) {
1188
+ const ranges = getTopLevelBlocksInRange(doc, change.from, change.to);
1189
+ ranges.push(toContentRelativeRange(doc, resolveTopLevelRange(doc, change.from)));
1190
+ if (change.to > change.from) ranges.push(toContentRelativeRange(doc, resolveTopLevelRange(doc, Math.min(change.to, doc.content.size + 1) - 1)));
1191
+ else if (change.from < doc.content.size + 1) ranges.push(toContentRelativeRange(doc, resolveTopLevelRange(doc, Math.min(change.from + 1, doc.content.size))));
1192
+ return ranges;
1193
+ }
1194
+ function collectRescanRanges(tr, oldState, newState) {
1195
+ const ranges = [];
1196
+ if (tr.docChanged) {
1197
+ const changes = getChangedRanges(tr);
1198
+ for (const change of changes) ranges.push(...collectBlocksForChange(newState.doc, change.newRange));
1199
+ }
1200
+ if (tr.selectionSet) {
1201
+ ranges.push(toContentRelativeRange(newState.doc, resolveTopLevelRange(newState.doc, tr.mapping.map(oldState.selection.anchor))));
1202
+ ranges.push(toContentRelativeRange(newState.doc, resolveTopLevelRange(newState.doc, newState.selection.anchor)));
1203
+ }
1204
+ return mergeRanges(ranges);
1205
+ }
1206
+ function clampRange(from2, to, doc) {
1207
+ const clampedFrom = Math.max(0, Math.min(from2, doc.content.size));
1208
+ return {
1209
+ from: clampedFrom,
1210
+ to: Math.max(clampedFrom, Math.min(to, doc.content.size))
1211
+ };
1212
+ }
1213
+ function updateDecorationsInRanges({ decorations, ranges, editor, options, dataAttribute, doc, selection }) {
1214
+ let next = decorations;
1215
+ for (const range of ranges) {
1216
+ const { from: from2, to } = clampRange(range.from, range.to, doc);
1217
+ const existing = next.find(from2, to).filter((decoration) => decoration.from >= from2 && decoration.to <= to);
1218
+ if (existing.length) next = next.remove(existing);
1219
+ const newDecos = scanRangeForDecorations({
1220
+ editor,
1221
+ options,
1222
+ dataAttribute,
1223
+ doc,
1224
+ selection,
1225
+ from: from2,
1226
+ to
1227
+ });
1228
+ if (newDecos.length) next = next.add(doc, newDecos);
1229
+ }
1230
+ return next;
1231
+ }
1232
+ function createPlaceholderStateField({ editor, options, dataAttribute }) {
1233
+ return {
1234
+ init(_config, state) {
1235
+ const decorations = buildPlaceholderDecorations({
1236
+ editor,
1237
+ options,
1238
+ dataAttribute,
1239
+ doc: state.doc,
1240
+ selection: state.selection
1241
+ });
1242
+ return decorations !== null && decorations !== void 0 ? decorations : DecorationSet.empty;
1243
+ },
1244
+ apply(tr, prev, oldState, newState) {
1245
+ if (!tr.docChanged && !tr.selectionSet) return prev;
1246
+ return updateDecorationsInRanges({
1247
+ decorations: prev.map(tr.mapping, tr.doc),
1248
+ ranges: collectRescanRanges(tr, oldState, newState),
1249
+ editor,
1250
+ options,
1251
+ dataAttribute,
1252
+ doc: newState.doc,
1253
+ selection: newState.selection
1254
+ });
1255
+ }
1256
+ };
1257
+ }
1258
+ function preparePlaceholderAttribute(attr) {
1259
+ return attr.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
1260
+ }
1261
+ function createPlaceholderPlugin({ editor, options }) {
1262
+ const dataAttribute = options.dataAttribute ? `data-${preparePlaceholderAttribute(options.dataAttribute)}` : `data-${DEFAULT_DATA_ATTRIBUTE}`;
1263
+ const useResolvedPath = options.showOnlyCurrent && !options.includeChildren;
1264
+ return new Plugin({
1265
+ key: PLUGIN_KEY,
1266
+ ...useResolvedPath ? {} : { state: createPlaceholderStateField({
1267
+ editor,
1268
+ options,
1269
+ dataAttribute
1270
+ }) },
1271
+ props: { decorations: useResolvedPath ? ({ doc, selection }) => buildPlaceholderDecorations({
1272
+ editor,
1273
+ options,
1274
+ dataAttribute,
1275
+ doc,
1276
+ selection
1277
+ }) : (state) => {
1278
+ var _PLUGIN_KEY$getState;
1279
+ if (options.showOnlyWhenEditable && !editor.isEditable) return DecorationSet.empty;
1280
+ return (_PLUGIN_KEY$getState = PLUGIN_KEY.getState(state)) !== null && _PLUGIN_KEY$getState !== void 0 ? _PLUGIN_KEY$getState : DecorationSet.empty;
1281
+ } }
1282
+ });
1283
+ }
1284
+ var Placeholder = Extension.create({
1285
+ name: "placeholder",
1286
+ addOptions() {
1287
+ return {
1288
+ emptyEditorClass: "is-editor-empty",
1289
+ emptyNodeClass: "is-empty",
1290
+ dataAttribute: DEFAULT_DATA_ATTRIBUTE,
1291
+ placeholder: "Write something \u2026",
1292
+ showOnlyWhenEditable: true,
1293
+ showOnlyCurrent: true,
1294
+ includeChildren: false
1295
+ };
1296
+ },
1297
+ addProseMirrorPlugins() {
1298
+ return [createPlaceholderPlugin({
1299
+ editor: this.editor,
1300
+ options: this.options
1301
+ })];
1302
+ }
1303
+ });
1304
+ function shouldSyncDomSelection(state, editor) {
1305
+ return !state.selection.empty && !isNodeSelection(state.selection) && editor.isEditable;
1306
+ }
1307
+ function shouldPreserveSelection(state, editor) {
1308
+ return shouldSyncDomSelection(state, editor) && !editor.isFocused && !editor.view.dragging;
1309
+ }
1310
+ function clearDomSelection() {
1311
+ var _window$getSelection;
1312
+ (_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 || _window$getSelection.removeAllRanges();
1313
+ }
1314
+ function restoreDomSelection(view) {
1315
+ view.focus();
1316
+ }
1317
+ var Selection2 = Extension.create({
1318
+ name: "selection",
1319
+ addOptions() {
1320
+ return { className: "selection" };
1321
+ },
1322
+ addProseMirrorPlugins() {
1323
+ const { editor, options } = this;
1324
+ return [new Plugin({
1325
+ key: new PluginKey("selection"),
1326
+ props: {
1327
+ decorations(state) {
1328
+ if (!shouldPreserveSelection(state, editor)) return null;
1329
+ return DecorationSet.create(state.doc, [Decoration.inline(state.selection.from, state.selection.to, { class: options.className })]);
1330
+ },
1331
+ handleDOMEvents: {
1332
+ blur(view) {
1333
+ if (!shouldSyncDomSelection(view.state, editor)) return false;
1334
+ clearDomSelection();
1335
+ return false;
1336
+ },
1337
+ focus(view) {
1338
+ if (!shouldSyncDomSelection(view.state, editor)) return false;
1339
+ requestAnimationFrame(() => {
1340
+ if (!editor.isDestroyed && view.hasFocus()) restoreDomSelection(view);
1341
+ });
1342
+ return false;
1343
+ }
1344
+ }
1345
+ }
1346
+ })];
1347
+ }
1348
+ });
1349
+ function nodeEqualsType({ types, node }) {
1350
+ return node && Array.isArray(types) && types.includes(node.type) || (node === null || node === void 0 ? void 0 : node.type) === types;
1351
+ }
1352
+ var TrailingNode = Extension.create({
1353
+ name: "trailingNode",
1354
+ addOptions() {
1355
+ return {
1356
+ node: void 0,
1357
+ notAfter: []
1358
+ };
1359
+ },
1360
+ addProseMirrorPlugins() {
1361
+ var _this$editor$schema$t;
1362
+ const plugin = new PluginKey(this.name);
1363
+ const defaultNode = this.options.node || ((_this$editor$schema$t = this.editor.schema.topNodeType.contentMatch.defaultType) === null || _this$editor$schema$t === void 0 ? void 0 : _this$editor$schema$t.name) || "paragraph";
1364
+ const disabledNodes = Object.entries(this.editor.schema.nodes).map(([, value]) => value).filter((node) => (this.options.notAfter || []).concat(defaultNode).includes(node.name));
1365
+ return [new Plugin({
1366
+ key: plugin,
1367
+ appendTransaction: (transactions, __, state) => {
1368
+ const { doc, tr, schema } = state;
1369
+ const shouldInsertNodeAtEnd = plugin.getState(state);
1370
+ const endPosition = doc.content.size;
1371
+ const type = schema.nodes[defaultNode];
1372
+ if (transactions.some((transaction) => transaction.getMeta("skipTrailingNode"))) return;
1373
+ if (!shouldInsertNodeAtEnd) return;
1374
+ return tr.insert(endPosition, type.create());
1375
+ },
1376
+ state: {
1377
+ init: (_, state) => {
1378
+ const lastNode = state.tr.doc.lastChild;
1379
+ return !nodeEqualsType({
1380
+ node: lastNode,
1381
+ types: disabledNodes
1382
+ });
1383
+ },
1384
+ apply: (tr, value) => {
1385
+ if (!tr.docChanged) return value;
1386
+ if (tr.getMeta("__uniqueIDTransaction")) return value;
1387
+ const lastNode = tr.doc.lastChild;
1388
+ return !nodeEqualsType({
1389
+ node: lastNode,
1390
+ types: disabledNodes
1391
+ });
1392
+ }
1393
+ }
1394
+ })];
1395
+ }
1396
+ });
1397
+ var UndoRedo = Extension.create({
1398
+ name: "undoRedo",
1399
+ addOptions() {
1400
+ return {
1401
+ depth: 100,
1402
+ newGroupDelay: 500
1403
+ };
1404
+ },
1405
+ addCommands() {
1406
+ return {
1407
+ undo: () => ({ state, dispatch }) => {
1408
+ return undo(state, dispatch);
1409
+ },
1410
+ redo: () => ({ state, dispatch }) => {
1411
+ return redo(state, dispatch);
1412
+ }
1413
+ };
1414
+ },
1415
+ addProseMirrorPlugins() {
1416
+ return [history(this.options)];
1417
+ },
1418
+ addKeyboardShortcuts() {
1419
+ return {
1420
+ "Mod-z": () => this.editor.commands.undo(),
1421
+ "Shift-Mod-z": () => this.editor.commands.redo(),
1422
+ "Mod-y": () => this.editor.commands.redo(),
1423
+ "Mod-\u044F": () => this.editor.commands.undo(),
1424
+ "Shift-Mod-\u044F": () => this.editor.commands.redo()
1425
+ };
1426
+ }
1427
+ });
1428
+
1429
+ export {
1430
+ Dropcursor,
1431
+ Gapcursor,
1432
+ Placeholder,
1433
+ UndoRedo
1434
+ };