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
@@ -10,10 +10,10 @@ import {
10
10
  offset,
11
11
  shift,
12
12
  size
13
- } from "../../chunks/chunk-53DZYORR.js";
13
+ } from "../../chunks/chunk-PAYSVIYI.js";
14
14
  import {
15
15
  useCurrentEditor
16
- } from "../../chunks/chunk-7ORQ7BYK.js";
16
+ } from "../../chunks/chunk-KMLLLZ6X.js";
17
17
  import {
18
18
  Extension,
19
19
  NodeSelection,
@@ -21,7 +21,7 @@ import {
21
21
  PluginKey,
22
22
  isTextSelection,
23
23
  posToDOMRect
24
- } from "../../chunks/chunk-TL7ZW6BX.js";
24
+ } from "../../chunks/chunk-A3XXZBOQ.js";
25
25
  import "../../chunks/chunk-RKDPDEF7.js";
26
26
  import {
27
27
  dist_default
@@ -42,26 +42,60 @@ function combineDOMRects(rect1, rect2) {
42
42
  const top = Math.min(rect1.top, rect2.top);
43
43
  const bottom = Math.max(rect1.bottom, rect2.bottom);
44
44
  const left = Math.min(rect1.left, rect2.left);
45
- const right = Math.max(rect1.right, rect2.right);
46
- const width = right - left;
45
+ const width = Math.max(rect1.right, rect2.right) - left;
47
46
  const height = bottom - top;
48
- const x = left;
49
- const y = top;
50
- return new DOMRect(x, y, width, height);
47
+ return new DOMRect(left, top, width, height);
51
48
  }
52
49
  var BubbleMenuView = class {
53
- constructor({
54
- editor,
55
- element,
56
- view,
57
- pluginKey = "bubbleMenu",
58
- updateDelay = 250,
59
- resizeDelay = 60,
60
- shouldShow,
61
- appendTo,
62
- getReferencedVirtualElement,
63
- options
64
- }) {
50
+ get middlewares() {
51
+ const middlewares = [];
52
+ if (this.floatingUIOptions.flip) middlewares.push(flip(typeof this.floatingUIOptions.flip !== "boolean" ? this.floatingUIOptions.flip : void 0));
53
+ if (this.floatingUIOptions.shift) middlewares.push(shift(typeof this.floatingUIOptions.shift !== "boolean" ? this.floatingUIOptions.shift : void 0));
54
+ if (this.floatingUIOptions.offset) middlewares.push(offset(typeof this.floatingUIOptions.offset !== "boolean" ? this.floatingUIOptions.offset : void 0));
55
+ if (this.floatingUIOptions.arrow) middlewares.push(arrow(this.floatingUIOptions.arrow));
56
+ if (this.floatingUIOptions.size) middlewares.push(size(typeof this.floatingUIOptions.size !== "boolean" ? this.floatingUIOptions.size : void 0));
57
+ if (this.floatingUIOptions.autoPlacement) middlewares.push(autoPlacement(typeof this.floatingUIOptions.autoPlacement !== "boolean" ? this.floatingUIOptions.autoPlacement : void 0));
58
+ if (this.floatingUIOptions.hide) middlewares.push(hide(typeof this.floatingUIOptions.hide !== "boolean" ? this.floatingUIOptions.hide : void 0));
59
+ if (this.floatingUIOptions.inline) middlewares.push(inline(typeof this.floatingUIOptions.inline !== "boolean" ? this.floatingUIOptions.inline : void 0));
60
+ return middlewares;
61
+ }
62
+ get virtualElement() {
63
+ var _this$getReferencedVi, _this$view;
64
+ const { selection } = this.editor.state;
65
+ const referencedVirtualElement = (_this$getReferencedVi = this.getReferencedVirtualElement) === null || _this$getReferencedVi === void 0 ? void 0 : _this$getReferencedVi.call(this);
66
+ if (referencedVirtualElement) return referencedVirtualElement;
67
+ if (!((_this$view = this.view) === null || _this$view === void 0 || (_this$view = _this$view.dom) === null || _this$view === void 0 ? void 0 : _this$view.parentNode)) return;
68
+ const domRect = posToDOMRect(this.view, selection.from, selection.to);
69
+ let virtualElement = {
70
+ getBoundingClientRect: () => domRect,
71
+ getClientRects: () => [domRect]
72
+ };
73
+ if (selection instanceof NodeSelection) {
74
+ let node = this.view.nodeDOM(selection.from);
75
+ const nodeViewWrapper = node.dataset.nodeViewWrapper ? node : node.querySelector("[data-node-view-wrapper]");
76
+ if (nodeViewWrapper) node = nodeViewWrapper;
77
+ if (node) virtualElement = {
78
+ getBoundingClientRect: () => node.getBoundingClientRect(),
79
+ getClientRects: () => [node.getBoundingClientRect()]
80
+ };
81
+ }
82
+ if (selection instanceof CellSelection) {
83
+ const { $anchorCell, $headCell } = selection;
84
+ const from = $anchorCell ? $anchorCell.pos : $headCell.pos;
85
+ const to = $headCell ? $headCell.pos : $anchorCell.pos;
86
+ const fromDOM = this.view.nodeDOM(from);
87
+ const toDOM = this.view.nodeDOM(to);
88
+ if (!fromDOM || !toDOM) return;
89
+ const clientRect = fromDOM === toDOM ? fromDOM.getBoundingClientRect() : combineDOMRects(fromDOM.getBoundingClientRect(), toDOM.getBoundingClientRect());
90
+ virtualElement = {
91
+ getBoundingClientRect: () => clientRect,
92
+ getClientRects: () => [clientRect]
93
+ };
94
+ }
95
+ return virtualElement;
96
+ }
97
+ constructor({ editor, element, view, pluginKey = "bubbleMenu", updateDelay = 250, resizeDelay = 60, shouldShow, appendTo, getReferencedVirtualElement, options }) {
98
+ var _options$scrollTarget;
65
99
  this.preventHide = false;
66
100
  this.isVisible = false;
67
101
  this.scrollTarget = window;
@@ -81,20 +115,12 @@ var BubbleMenuView = class {
81
115
  onUpdate: void 0,
82
116
  onDestroy: void 0
83
117
  };
84
- this.shouldShow = ({
85
- view: view2,
86
- state,
87
- from,
88
- to
89
- }) => {
118
+ this.shouldShow = ({ view: view2, state, from, to }) => {
90
119
  const { doc, selection } = state;
91
120
  const { empty } = selection;
92
121
  const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(state.selection);
93
122
  const isChildOfMenu = this.element.contains(document.activeElement);
94
- const hasEditorFocus = view2.hasFocus() || isChildOfMenu;
95
- if (!hasEditorFocus || empty || isEmptyTextBlock || !this.editor.isEditable) {
96
- return false;
97
- }
123
+ if (!(view2.hasFocus() || isChildOfMenu) || empty || isEmptyTextBlock || !this.editor.isEditable) return false;
98
124
  return true;
99
125
  };
100
126
  this.mousedownHandler = () => {
@@ -104,9 +130,7 @@ var BubbleMenuView = class {
104
130
  this.hide();
105
131
  };
106
132
  this.resizeHandler = () => {
107
- if (this.resizeDebounceTimer) {
108
- clearTimeout(this.resizeDebounceTimer);
109
- }
133
+ if (this.resizeDebounceTimer) clearTimeout(this.resizeDebounceTimer);
110
134
  this.resizeDebounceTimer = window.setTimeout(() => {
111
135
  this.updatePosition();
112
136
  }, this.resizeDelay);
@@ -115,7 +139,7 @@ var BubbleMenuView = class {
115
139
  setTimeout(() => this.update(this.editor.view));
116
140
  };
117
141
  this.blurHandler = ({ event }) => {
118
- var _a2;
142
+ var _this$element$parentN;
119
143
  if (this.editor.isDestroyed) {
120
144
  this.destroy();
121
145
  return;
@@ -124,35 +148,23 @@ var BubbleMenuView = class {
124
148
  this.preventHide = false;
125
149
  return;
126
150
  }
127
- if ((event == null ? void 0 : event.relatedTarget) && ((_a2 = this.element.parentNode) == null ? void 0 : _a2.contains(event.relatedTarget))) {
128
- return;
129
- }
130
- if ((event == null ? void 0 : event.relatedTarget) === this.editor.view.dom) {
131
- return;
132
- }
151
+ if ((event === null || event === void 0 ? void 0 : event.relatedTarget) && ((_this$element$parentN = this.element.parentNode) === null || _this$element$parentN === void 0 ? void 0 : _this$element$parentN.contains(event.relatedTarget))) return;
152
+ if ((event === null || event === void 0 ? void 0 : event.relatedTarget) === this.editor.view.dom) return;
133
153
  this.hide();
134
154
  };
135
155
  this.handleDebouncedUpdate = (view2, oldState) => {
136
- const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view2.state.selection));
137
- const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view2.state.doc));
138
- if (!selectionChanged && !docChanged) {
139
- return;
140
- }
141
- if (this.updateDebounceTimer) {
142
- clearTimeout(this.updateDebounceTimer);
143
- }
156
+ const selectionChanged = !(oldState === null || oldState === void 0 ? void 0 : oldState.selection.eq(view2.state.selection));
157
+ const docChanged = !(oldState === null || oldState === void 0 ? void 0 : oldState.doc.eq(view2.state.doc));
158
+ if (!selectionChanged && !docChanged) return;
159
+ if (this.updateDebounceTimer) clearTimeout(this.updateDebounceTimer);
144
160
  this.updateDebounceTimer = window.setTimeout(() => {
145
161
  this.updateHandler(view2, selectionChanged, docChanged, oldState);
146
162
  }, this.updateDelay);
147
163
  };
148
164
  this.updateHandler = (view2, selectionChanged, docChanged, oldState) => {
149
165
  const { composing } = view2;
150
- const isSame = !selectionChanged && !docChanged;
151
- if (composing || isSame) {
152
- return;
153
- }
154
- const shouldShow2 = this.getShouldShow(oldState);
155
- if (!shouldShow2) {
166
+ if (composing || !selectionChanged && !docChanged) return;
167
+ if (!this.getShouldShow(oldState)) {
156
168
  this.hide();
157
169
  return;
158
170
  }
@@ -161,18 +173,14 @@ var BubbleMenuView = class {
161
173
  };
162
174
  this.transactionHandler = ({ transaction: tr }) => {
163
175
  const meta = tr.getMeta(this.pluginKey);
164
- if (meta === "updatePosition") {
165
- this.updatePosition();
166
- } else if (meta && typeof meta === "object" && meta.type === "updateOptions") {
167
- this.updateOptions(meta.options);
168
- } else if (meta === "hide") {
169
- this.hide();
170
- } else if (meta === "show") {
176
+ if (meta === "updatePosition") this.updatePosition();
177
+ else if (meta && typeof meta === "object" && meta.type === "updateOptions") this.updateOptions(meta.options);
178
+ else if (meta === "hide") this.hide();
179
+ else if (meta === "show") {
171
180
  this.updatePosition();
172
181
  this.show();
173
182
  }
174
183
  };
175
- var _a;
176
184
  this.editor = editor;
177
185
  this.element = element;
178
186
  this.view = view;
@@ -180,16 +188,14 @@ var BubbleMenuView = class {
180
188
  this.updateDelay = updateDelay;
181
189
  this.resizeDelay = resizeDelay;
182
190
  this.appendTo = appendTo;
183
- this.scrollTarget = (_a = options == null ? void 0 : options.scrollTarget) != null ? _a : window;
191
+ this.scrollTarget = (_options$scrollTarget = options === null || options === void 0 ? void 0 : options.scrollTarget) !== null && _options$scrollTarget !== void 0 ? _options$scrollTarget : window;
184
192
  this.getReferencedVirtualElement = getReferencedVirtualElement;
185
193
  this.floatingUIOptions = {
186
194
  ...this.floatingUIOptions,
187
195
  ...options
188
196
  };
189
197
  this.element.tabIndex = 0;
190
- if (shouldShow) {
191
- this.shouldShow = shouldShow;
192
- }
198
+ if (shouldShow) this.shouldShow = shouldShow;
193
199
  this.element.addEventListener("mousedown", this.mousedownHandler, { capture: true });
194
200
  this.view.dom.addEventListener("dragstart", this.dragstartHandler);
195
201
  this.editor.on("focus", this.focusHandler);
@@ -203,128 +209,18 @@ var BubbleMenuView = class {
203
209
  this.updatePosition();
204
210
  }
205
211
  }
206
- get middlewares() {
207
- const middlewares = [];
208
- if (this.floatingUIOptions.flip) {
209
- middlewares.push(
210
- flip(
211
- typeof this.floatingUIOptions.flip !== "boolean" ? this.floatingUIOptions.flip : void 0
212
- )
213
- );
214
- }
215
- if (this.floatingUIOptions.shift) {
216
- middlewares.push(
217
- shift(
218
- typeof this.floatingUIOptions.shift !== "boolean" ? this.floatingUIOptions.shift : void 0
219
- )
220
- );
221
- }
222
- if (this.floatingUIOptions.offset) {
223
- middlewares.push(
224
- offset(
225
- typeof this.floatingUIOptions.offset !== "boolean" ? this.floatingUIOptions.offset : void 0
226
- )
227
- );
228
- }
229
- if (this.floatingUIOptions.arrow) {
230
- middlewares.push(arrow(this.floatingUIOptions.arrow));
231
- }
232
- if (this.floatingUIOptions.size) {
233
- middlewares.push(
234
- size(
235
- typeof this.floatingUIOptions.size !== "boolean" ? this.floatingUIOptions.size : void 0
236
- )
237
- );
238
- }
239
- if (this.floatingUIOptions.autoPlacement) {
240
- middlewares.push(
241
- autoPlacement(
242
- typeof this.floatingUIOptions.autoPlacement !== "boolean" ? this.floatingUIOptions.autoPlacement : void 0
243
- )
244
- );
245
- }
246
- if (this.floatingUIOptions.hide) {
247
- middlewares.push(
248
- hide(
249
- typeof this.floatingUIOptions.hide !== "boolean" ? this.floatingUIOptions.hide : void 0
250
- )
251
- );
252
- }
253
- if (this.floatingUIOptions.inline) {
254
- middlewares.push(
255
- inline(
256
- typeof this.floatingUIOptions.inline !== "boolean" ? this.floatingUIOptions.inline : void 0
257
- )
258
- );
259
- }
260
- return middlewares;
261
- }
262
- get virtualElement() {
263
- var _a, _b, _c;
264
- const { selection } = this.editor.state;
265
- const referencedVirtualElement = (_a = this.getReferencedVirtualElement) == null ? void 0 : _a.call(this);
266
- if (referencedVirtualElement) {
267
- return referencedVirtualElement;
268
- }
269
- if (!((_c = (_b = this.view) == null ? void 0 : _b.dom) == null ? void 0 : _c.parentNode)) {
270
- return;
271
- }
272
- const domRect = posToDOMRect(this.view, selection.from, selection.to);
273
- let virtualElement = {
274
- getBoundingClientRect: () => domRect,
275
- getClientRects: () => [domRect]
276
- };
277
- if (selection instanceof NodeSelection) {
278
- let node = this.view.nodeDOM(selection.from);
279
- const nodeViewWrapper = node.dataset.nodeViewWrapper ? node : node.querySelector("[data-node-view-wrapper]");
280
- if (nodeViewWrapper) {
281
- node = nodeViewWrapper;
282
- }
283
- if (node) {
284
- virtualElement = {
285
- getBoundingClientRect: () => node.getBoundingClientRect(),
286
- getClientRects: () => [node.getBoundingClientRect()]
287
- };
288
- }
289
- }
290
- if (selection instanceof CellSelection) {
291
- const { $anchorCell, $headCell } = selection;
292
- const from = $anchorCell ? $anchorCell.pos : $headCell.pos;
293
- const to = $headCell ? $headCell.pos : $anchorCell.pos;
294
- const fromDOM = this.view.nodeDOM(from);
295
- const toDOM = this.view.nodeDOM(to);
296
- if (!fromDOM || !toDOM) {
297
- return;
298
- }
299
- const clientRect = fromDOM === toDOM ? fromDOM.getBoundingClientRect() : combineDOMRects(
300
- fromDOM.getBoundingClientRect(),
301
- toDOM.getBoundingClientRect()
302
- );
303
- virtualElement = {
304
- getBoundingClientRect: () => clientRect,
305
- getClientRects: () => [clientRect]
306
- };
307
- }
308
- return virtualElement;
309
- }
310
212
  updatePosition() {
311
- if (!this.isVisible) {
312
- return;
313
- }
213
+ if (!this.isVisible) return;
314
214
  const virtualElement = this.virtualElement;
315
- if (!virtualElement) {
316
- return;
317
- }
215
+ if (!virtualElement) return;
318
216
  computePosition(virtualElement, this.element, {
319
217
  placement: this.floatingUIOptions.placement,
320
218
  strategy: this.floatingUIOptions.strategy,
321
219
  middleware: this.middlewares
322
220
  }).then(({ x, y, strategy, middlewareData }) => {
323
- var _a, _b;
324
- if (!this.isVisible || this.editor.isDestroyed || !this.element.isConnected) {
325
- return;
326
- }
327
- if (((_a = middlewareData.hide) == null ? void 0 : _a.referenceHidden) || ((_b = middlewareData.hide) == null ? void 0 : _b.escaped)) {
221
+ var _middlewareData$hide, _middlewareData$hide2;
222
+ if (!this.isVisible || this.editor.isDestroyed || !this.element.isConnected) return;
223
+ if (((_middlewareData$hide = middlewareData.hide) === null || _middlewareData$hide === void 0 ? void 0 : _middlewareData$hide.referenceHidden) || ((_middlewareData$hide2 = middlewareData.hide) === null || _middlewareData$hide2 === void 0 ? void 0 : _middlewareData$hide2.escaped)) {
328
224
  this.element.style.visibility = "hidden";
329
225
  return;
330
226
  }
@@ -333,9 +229,7 @@ var BubbleMenuView = class {
333
229
  this.element.style.position = strategy;
334
230
  this.element.style.left = `${x}px`;
335
231
  this.element.style.top = `${y}px`;
336
- if (this.isVisible && this.floatingUIOptions.onUpdate) {
337
- this.floatingUIOptions.onUpdate();
338
- }
232
+ if (this.isVisible && this.floatingUIOptions.onUpdate) this.floatingUIOptions.onUpdate();
339
233
  });
340
234
  }
341
235
  update(view, oldState) {
@@ -345,18 +239,18 @@ var BubbleMenuView = class {
345
239
  this.handleDebouncedUpdate(view, oldState);
346
240
  return;
347
241
  }
348
- const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
349
- const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
242
+ const selectionChanged = !(oldState === null || oldState === void 0 ? void 0 : oldState.selection.eq(view.state.selection));
243
+ const docChanged = !(oldState === null || oldState === void 0 ? void 0 : oldState.doc.eq(view.state.doc));
350
244
  this.updateHandler(view, selectionChanged, docChanged, oldState);
351
245
  }
352
246
  getShouldShow(oldState) {
353
- var _a;
247
+ var _this$shouldShow;
354
248
  const { state } = this.view;
355
249
  const { selection } = state;
356
250
  const { ranges } = selection;
357
251
  const from = Math.min(...ranges.map((range) => range.$from.pos));
358
252
  const to = Math.max(...ranges.map((range) => range.$to.pos));
359
- const shouldShow = (_a = this.shouldShow) == null ? void 0 : _a.call(this, {
253
+ return ((_this$shouldShow = this.shouldShow) === null || _this$shouldShow === void 0 ? void 0 : _this$shouldShow.call(this, {
360
254
  editor: this.editor,
361
255
  element: this.element,
362
256
  view: this.view,
@@ -364,56 +258,37 @@ var BubbleMenuView = class {
364
258
  oldState,
365
259
  from,
366
260
  to
367
- });
368
- return shouldShow || false;
261
+ })) || false;
369
262
  }
370
263
  show() {
371
- var _a;
372
- if (this.isVisible) {
373
- return;
374
- }
264
+ var _ref;
265
+ if (this.isVisible) return;
375
266
  this.element.style.visibility = "visible";
376
267
  this.element.style.opacity = "1";
377
268
  const appendToElement = typeof this.appendTo === "function" ? this.appendTo() : this.appendTo;
378
- (_a = appendToElement != null ? appendToElement : this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
379
- if (this.floatingUIOptions.onShow) {
380
- this.floatingUIOptions.onShow();
381
- }
269
+ (_ref = appendToElement !== null && appendToElement !== void 0 ? appendToElement : this.view.dom.parentElement) === null || _ref === void 0 || _ref.appendChild(this.element);
270
+ if (this.floatingUIOptions.onShow) this.floatingUIOptions.onShow();
382
271
  this.isVisible = true;
383
272
  }
384
273
  hide() {
385
- if (!this.isVisible) {
386
- return;
387
- }
274
+ if (!this.isVisible) return;
388
275
  this.element.style.visibility = "hidden";
389
276
  this.element.style.opacity = "0";
390
277
  this.element.remove();
391
- if (this.floatingUIOptions.onHide) {
392
- this.floatingUIOptions.onHide();
393
- }
278
+ if (this.floatingUIOptions.onHide) this.floatingUIOptions.onHide();
394
279
  this.isVisible = false;
395
280
  }
396
281
  updateOptions(newProps) {
397
- var _a;
398
- if (newProps.updateDelay !== void 0) {
399
- this.updateDelay = newProps.updateDelay;
400
- }
401
- if (newProps.resizeDelay !== void 0) {
402
- this.resizeDelay = newProps.resizeDelay;
403
- }
404
- if (newProps.appendTo !== void 0) {
405
- this.appendTo = newProps.appendTo;
406
- }
407
- if (newProps.getReferencedVirtualElement !== void 0) {
408
- this.getReferencedVirtualElement = newProps.getReferencedVirtualElement;
409
- }
282
+ if (newProps.updateDelay !== void 0) this.updateDelay = newProps.updateDelay;
283
+ if (newProps.resizeDelay !== void 0) this.resizeDelay = newProps.resizeDelay;
284
+ if (newProps.appendTo !== void 0) this.appendTo = newProps.appendTo;
285
+ if (newProps.getReferencedVirtualElement !== void 0) this.getReferencedVirtualElement = newProps.getReferencedVirtualElement;
410
286
  if (newProps.shouldShow !== void 0) {
411
- if (newProps.shouldShow) {
412
- this.shouldShow = newProps.shouldShow;
413
- }
287
+ if (newProps.shouldShow) this.shouldShow = newProps.shouldShow;
414
288
  }
415
289
  if (newProps.options !== void 0) {
416
- const newScrollTarget = (_a = newProps.options.scrollTarget) != null ? _a : window;
290
+ var _newProps$options$scr;
291
+ const newScrollTarget = (_newProps$options$scr = newProps.options.scrollTarget) !== null && _newProps$options$scr !== void 0 ? _newProps$options$scr : window;
417
292
  if (newScrollTarget !== this.scrollTarget) {
418
293
  this.scrollTarget.removeEventListener("scroll", this.resizeHandler);
419
294
  this.scrollTarget = newScrollTarget;
@@ -434,15 +309,16 @@ var BubbleMenuView = class {
434
309
  this.editor.off("focus", this.focusHandler);
435
310
  this.editor.off("blur", this.blurHandler);
436
311
  this.editor.off("transaction", this.transactionHandler);
437
- if (this.floatingUIOptions.onDestroy) {
438
- this.floatingUIOptions.onDestroy();
439
- }
312
+ if (this.floatingUIOptions.onDestroy) this.floatingUIOptions.onDestroy();
440
313
  }
441
314
  };
442
315
  var BubbleMenuPlugin = (options) => {
443
316
  return new Plugin({
444
317
  key: typeof options.pluginKey === "string" ? new PluginKey(options.pluginKey) : options.pluginKey,
445
- view: (view) => new BubbleMenuView({ view, ...options })
318
+ view: (view) => new BubbleMenuView({
319
+ view,
320
+ ...options
321
+ })
446
322
  });
447
323
  };
448
324
  var BubbleMenu = Extension.create({
@@ -457,32 +333,25 @@ var BubbleMenu = Extension.create({
457
333
  };
458
334
  },
459
335
  addProseMirrorPlugins() {
460
- if (!this.options.element) {
461
- return [];
462
- }
463
- return [
464
- BubbleMenuPlugin({
465
- pluginKey: this.options.pluginKey,
466
- editor: this.editor,
467
- element: this.options.element,
468
- updateDelay: this.options.updateDelay,
469
- options: this.options.options,
470
- appendTo: this.options.appendTo,
471
- getReferencedVirtualElement: this.options.getReferencedVirtualElement,
472
- shouldShow: this.options.shouldShow
473
- })
474
- ];
336
+ if (!this.options.element) return [];
337
+ return [BubbleMenuPlugin({
338
+ pluginKey: this.options.pluginKey,
339
+ editor: this.editor,
340
+ element: this.options.element,
341
+ updateDelay: this.options.updateDelay,
342
+ options: this.options.options,
343
+ appendTo: this.options.appendTo,
344
+ getReferencedVirtualElement: this.options.getReferencedVirtualElement,
345
+ shouldShow: this.options.shouldShow
346
+ })];
475
347
  }
476
348
  });
477
349
 
478
350
  // node_modules/@tiptap/react/dist/menus/index.js
479
- import React, { useEffect as useEffect2, useRef as useRef2, useState } from "react";
351
+ import React, { useEffect, useLayoutEffect, useRef, useState } from "react";
480
352
  import { createPortal } from "react-dom";
481
- import { useEffect, useLayoutEffect, useRef } from "react";
482
- import React2, { useEffect as useEffect3, useRef as useRef3, useState as useState2 } from "react";
483
- import { createPortal as createPortal2 } from "react-dom";
484
353
  function getAutoPluginKey(pluginKey, defaultName) {
485
- return pluginKey != null ? pluginKey : new PluginKey(defaultName);
354
+ return pluginKey !== null && pluginKey !== void 0 ? pluginKey : new PluginKey(defaultName);
486
355
  }
487
356
  var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
488
357
  var PLUGIN_MANAGED_STYLE_PROPERTIES = /* @__PURE__ */ new Set([
@@ -530,7 +399,11 @@ var UNITLESS_STYLE_PROPERTIES = /* @__PURE__ */ new Set([
530
399
  "zIndex",
531
400
  "zoom"
532
401
  ]);
533
- var ATTRIBUTE_EXCLUSIONS = /* @__PURE__ */ new Set(["children", "className", "style"]);
402
+ var ATTRIBUTE_EXCLUSIONS = /* @__PURE__ */ new Set([
403
+ "children",
404
+ "className",
405
+ "style"
406
+ ]);
534
407
  var DIRECT_PROPERTY_KEYS = /* @__PURE__ */ new Set(["tabIndex"]);
535
408
  var FORWARDED_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([
536
409
  "accessKey",
@@ -562,28 +435,22 @@ function isEventProp(key, value) {
562
435
  return /^on[A-Z]/.test(key) && typeof value === "function";
563
436
  }
564
437
  function toAttributeName(key) {
565
- if (key.startsWith("aria-") || key.startsWith("data-")) {
566
- return key;
567
- }
438
+ if (key.startsWith("aria-") || key.startsWith("data-")) return key;
568
439
  return key;
569
440
  }
570
441
  function isForwardedAttributeKey(key) {
571
442
  return key.startsWith("aria-") || key.startsWith("data-") || FORWARDED_ATTRIBUTE_KEYS.has(key);
572
443
  }
573
444
  function toStylePropertyName(key) {
574
- if (key.startsWith("--")) {
575
- return key;
576
- }
445
+ if (key.startsWith("--")) return key;
577
446
  return key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
578
447
  }
579
448
  function toEventConfig(key) {
580
- var _a;
449
+ var _SPECIAL_EVENT_NAMES$;
581
450
  const useCapture = key.endsWith("Capture");
582
- const baseKey = useCapture ? key.slice(0, -7) : key;
583
- const reactEventName = baseKey.slice(2);
584
- const eventName = (_a = SPECIAL_EVENT_NAMES[reactEventName]) != null ? _a : reactEventName.toLowerCase();
451
+ const reactEventName = (useCapture ? key.slice(0, -7) : key).slice(2);
585
452
  return {
586
- eventName,
453
+ eventName: (_SPECIAL_EVENT_NAMES$ = SPECIAL_EVENT_NAMES[reactEventName]) !== null && _SPECIAL_EVENT_NAMES$ !== void 0 ? _SPECIAL_EVENT_NAMES$ : reactEventName.toLowerCase(),
587
454
  options: useCapture ? { capture: true } : void 0
588
455
  };
589
456
  }
@@ -598,18 +465,14 @@ function createSyntheticEvent(element, nativeEvent) {
598
465
  persist: { value: () => void 0 },
599
466
  isDefaultPrevented: { value: () => defaultPrevented },
600
467
  isPropagationStopped: { value: () => propagationStopped },
601
- preventDefault: {
602
- value: () => {
603
- defaultPrevented = true;
604
- nativeEvent.preventDefault();
605
- }
606
- },
607
- stopPropagation: {
608
- value: () => {
609
- propagationStopped = true;
610
- nativeEvent.stopPropagation();
611
- }
612
- }
468
+ preventDefault: { value: () => {
469
+ defaultPrevented = true;
470
+ nativeEvent.preventDefault();
471
+ } },
472
+ stopPropagation: { value: () => {
473
+ propagationStopped = true;
474
+ nativeEvent.stopPropagation();
475
+ } }
613
476
  });
614
477
  return syntheticEvent;
615
478
  }
@@ -621,7 +484,6 @@ function setDirectProperty(element, key, value) {
621
484
  element.tabIndex = Number(value);
622
485
  return;
623
486
  }
624
- ;
625
487
  element[key] = value;
626
488
  }
627
489
  function clearDirectProperty(element, key) {
@@ -631,59 +493,41 @@ function clearDirectProperty(element, key) {
631
493
  }
632
494
  const propertyValue = element[key];
633
495
  if (typeof propertyValue === "boolean") {
634
- ;
635
496
  element[key] = false;
636
497
  return;
637
498
  }
638
499
  if (typeof propertyValue === "number") {
639
- ;
640
500
  element[key] = 0;
641
501
  return;
642
502
  }
643
- ;
644
503
  element[key] = "";
645
504
  }
646
505
  function toStyleValue(styleName, value) {
647
- if (typeof value !== "number" || value === 0 || styleName.startsWith("--") || UNITLESS_STYLE_PROPERTIES.has(styleName)) {
648
- return String(value);
649
- }
506
+ if (typeof value !== "number" || value === 0 || styleName.startsWith("--") || UNITLESS_STYLE_PROPERTIES.has(styleName)) return String(value);
650
507
  return `${value}px`;
651
508
  }
652
509
  function removeStyleProperty(element, styleName) {
653
- if (PLUGIN_MANAGED_STYLE_PROPERTIES.has(styleName)) {
654
- return;
655
- }
510
+ if (PLUGIN_MANAGED_STYLE_PROPERTIES.has(styleName)) return;
656
511
  element.style.removeProperty(toStylePropertyName(styleName));
657
512
  }
658
513
  function applyStyleProperty(element, styleName, value) {
659
- if (PLUGIN_MANAGED_STYLE_PROPERTIES.has(styleName)) {
660
- return;
661
- }
514
+ if (PLUGIN_MANAGED_STYLE_PROPERTIES.has(styleName)) return;
662
515
  element.style.setProperty(toStylePropertyName(styleName), toStyleValue(styleName, value));
663
516
  }
664
517
  function syncAttributes(element, prevProps, nextProps) {
665
- const allKeys = /* @__PURE__ */ new Set([...Object.keys(prevProps), ...Object.keys(nextProps)]);
666
- allKeys.forEach((key) => {
667
- if (ATTRIBUTE_EXCLUSIONS.has(key) || !isForwardedAttributeKey(key) || isEventProp(key, prevProps[key]) || isEventProp(key, nextProps[key])) {
668
- return;
669
- }
518
+ (/* @__PURE__ */ new Set([...Object.keys(prevProps), ...Object.keys(nextProps)])).forEach((key) => {
519
+ if (ATTRIBUTE_EXCLUSIONS.has(key) || !isForwardedAttributeKey(key) || isEventProp(key, prevProps[key]) || isEventProp(key, nextProps[key])) return;
670
520
  const prevValue = prevProps[key];
671
521
  const nextValue = nextProps[key];
672
- if (prevValue === nextValue) {
673
- return;
674
- }
522
+ if (prevValue === nextValue) return;
675
523
  const attributeName = toAttributeName(key);
676
524
  if (nextValue == null || nextValue === false) {
677
- if (isDirectPropertyKey(key)) {
678
- clearDirectProperty(element, key);
679
- }
525
+ if (isDirectPropertyKey(key)) clearDirectProperty(element, key);
680
526
  element.removeAttribute(attributeName);
681
527
  return;
682
528
  }
683
529
  if (nextValue === true) {
684
- if (isDirectPropertyKey(key)) {
685
- setDirectProperty(element, key, true);
686
- }
530
+ if (isDirectPropertyKey(key)) setDirectProperty(element, key, true);
687
531
  element.setAttribute(attributeName, "");
688
532
  return;
689
533
  }
@@ -695,9 +539,7 @@ function syncAttributes(element, prevProps, nextProps) {
695
539
  });
696
540
  }
697
541
  function syncClassName(element, prevClassName, nextClassName) {
698
- if (prevClassName === nextClassName) {
699
- return;
700
- }
542
+ if (prevClassName === nextClassName) return;
701
543
  if (nextClassName) {
702
544
  element.className = nextClassName;
703
545
  return;
@@ -705,15 +547,12 @@ function syncClassName(element, prevClassName, nextClassName) {
705
547
  element.removeAttribute("class");
706
548
  }
707
549
  function syncStyles(element, prevStyle, nextStyle) {
708
- const previousStyle = prevStyle != null ? prevStyle : {};
709
- const currentStyle = nextStyle != null ? nextStyle : {};
710
- const allStyleNames = /* @__PURE__ */ new Set([...Object.keys(previousStyle), ...Object.keys(currentStyle)]);
711
- allStyleNames.forEach((styleName) => {
550
+ const previousStyle = prevStyle !== null && prevStyle !== void 0 ? prevStyle : {};
551
+ const currentStyle = nextStyle !== null && nextStyle !== void 0 ? nextStyle : {};
552
+ (/* @__PURE__ */ new Set([...Object.keys(previousStyle), ...Object.keys(currentStyle)])).forEach((styleName) => {
712
553
  const prevValue = previousStyle[styleName];
713
554
  const nextValue = currentStyle[styleName];
714
- if (prevValue === nextValue) {
715
- return;
716
- }
555
+ if (prevValue === nextValue) return;
717
556
  if (nextValue == null) {
718
557
  removeStyleProperty(element, styleName);
719
558
  return;
@@ -727,15 +566,17 @@ function syncEventListeners(element, prevListeners, nextProps) {
727
566
  });
728
567
  const nextListeners = [];
729
568
  Object.entries(nextProps).forEach(([key, value]) => {
730
- if (!isEventProp(key, value)) {
731
- return;
732
- }
569
+ if (!isEventProp(key, value)) return;
733
570
  const { eventName, options } = toEventConfig(key);
734
571
  const listener = (event) => {
735
572
  value(createSyntheticEvent(element, event));
736
573
  };
737
574
  element.addEventListener(eventName, listener, options);
738
- nextListeners.push({ eventName, listener, options });
575
+ nextListeners.push({
576
+ eventName,
577
+ listener,
578
+ options
579
+ });
739
580
  });
740
581
  return nextListeners;
741
582
  }
@@ -757,207 +598,152 @@ function useMenuElementProps(element, props) {
757
598
  };
758
599
  }, [element, props]);
759
600
  }
760
- var BubbleMenu2 = React.forwardRef(
761
- ({
762
- pluginKey,
763
- editor,
601
+ var BubbleMenu2 = React.forwardRef(({ pluginKey, editor, updateDelay, resizeDelay, appendTo, shouldShow = null, getReferencedVirtualElement, options, children, ...restProps }, ref) => {
602
+ const menuEl = useRef(document.createElement("div"));
603
+ const resolvedPluginKey = useRef(getAutoPluginKey(pluginKey, "bubbleMenu")).current;
604
+ useMenuElementProps(menuEl.current, restProps);
605
+ if (typeof ref === "function") ref(menuEl.current);
606
+ else if (ref) ref.current = menuEl.current;
607
+ const { editor: currentEditor } = useCurrentEditor();
608
+ const pluginEditor = editor || currentEditor;
609
+ const bubbleMenuPluginProps = {
764
610
  updateDelay,
765
611
  resizeDelay,
766
612
  appendTo,
767
- shouldShow = null,
613
+ pluginKey: resolvedPluginKey,
614
+ shouldShow,
768
615
  getReferencedVirtualElement,
769
- options,
770
- children,
771
- ...restProps
772
- }, ref) => {
773
- const menuEl = useRef2(document.createElement("div"));
774
- const resolvedPluginKey = useRef2(
775
- getAutoPluginKey(pluginKey, "bubbleMenu")
776
- ).current;
777
- useMenuElementProps(menuEl.current, restProps);
778
- if (typeof ref === "function") {
779
- ref(menuEl.current);
780
- } else if (ref) {
781
- ref.current = menuEl.current;
616
+ options
617
+ };
618
+ const bubbleMenuPluginPropsRef = useRef(bubbleMenuPluginProps);
619
+ bubbleMenuPluginPropsRef.current = bubbleMenuPluginProps;
620
+ const [pluginInitialized, setPluginInitialized] = useState(false);
621
+ const skipFirstUpdateRef = useRef(true);
622
+ useEffect(() => {
623
+ if (pluginEditor === null || pluginEditor === void 0 ? void 0 : pluginEditor.isDestroyed) return;
624
+ if (!pluginEditor) {
625
+ console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");
626
+ return;
782
627
  }
783
- const { editor: currentEditor } = useCurrentEditor();
784
- const pluginEditor = editor || currentEditor;
785
- const bubbleMenuPluginProps = {
786
- updateDelay,
787
- resizeDelay,
788
- appendTo,
789
- pluginKey: resolvedPluginKey,
790
- shouldShow,
791
- getReferencedVirtualElement,
792
- options
793
- };
794
- const bubbleMenuPluginPropsRef = useRef2(bubbleMenuPluginProps);
795
- bubbleMenuPluginPropsRef.current = bubbleMenuPluginProps;
796
- const [pluginInitialized, setPluginInitialized] = useState(false);
797
- const skipFirstUpdateRef = useRef2(true);
798
- useEffect2(() => {
799
- if (pluginEditor == null ? void 0 : pluginEditor.isDestroyed) {
800
- return;
801
- }
802
- if (!pluginEditor) {
803
- console.warn(
804
- "BubbleMenu component is not rendered inside of an editor component or does not have editor prop."
805
- );
806
- return;
807
- }
808
- const bubbleMenuElement = menuEl.current;
809
- bubbleMenuElement.style.visibility = "hidden";
810
- bubbleMenuElement.style.position = "absolute";
811
- const plugin = BubbleMenuPlugin({
812
- ...bubbleMenuPluginPropsRef.current,
813
- editor: pluginEditor,
814
- element: bubbleMenuElement
628
+ const bubbleMenuElement = menuEl.current;
629
+ bubbleMenuElement.style.visibility = "hidden";
630
+ bubbleMenuElement.style.position = "absolute";
631
+ const plugin = BubbleMenuPlugin({
632
+ ...bubbleMenuPluginPropsRef.current,
633
+ editor: pluginEditor,
634
+ element: bubbleMenuElement
635
+ });
636
+ pluginEditor.registerPlugin(plugin);
637
+ const createdPluginKey = bubbleMenuPluginPropsRef.current.pluginKey;
638
+ skipFirstUpdateRef.current = true;
639
+ setPluginInitialized(true);
640
+ return () => {
641
+ setPluginInitialized(false);
642
+ pluginEditor.unregisterPlugin(createdPluginKey);
643
+ window.requestAnimationFrame(() => {
644
+ if (bubbleMenuElement.parentNode) bubbleMenuElement.parentNode.removeChild(bubbleMenuElement);
815
645
  });
816
- pluginEditor.registerPlugin(plugin);
817
- const createdPluginKey = bubbleMenuPluginPropsRef.current.pluginKey;
818
- skipFirstUpdateRef.current = true;
819
- setPluginInitialized(true);
820
- return () => {
821
- setPluginInitialized(false);
822
- pluginEditor.unregisterPlugin(createdPluginKey);
823
- window.requestAnimationFrame(() => {
824
- if (bubbleMenuElement.parentNode) {
825
- bubbleMenuElement.parentNode.removeChild(bubbleMenuElement);
826
- }
827
- });
828
- };
829
- }, [pluginEditor]);
830
- useEffect2(() => {
831
- if (!pluginInitialized || !pluginEditor || pluginEditor.isDestroyed) {
832
- return;
833
- }
834
- if (skipFirstUpdateRef.current) {
835
- skipFirstUpdateRef.current = false;
836
- return;
837
- }
838
- pluginEditor.view.dispatch(
839
- pluginEditor.state.tr.setMeta(resolvedPluginKey, {
840
- type: "updateOptions",
841
- options: bubbleMenuPluginPropsRef.current
842
- })
843
- );
844
- }, [
845
- pluginInitialized,
846
- pluginEditor,
847
- updateDelay,
848
- resizeDelay,
849
- shouldShow,
850
- options,
851
- appendTo,
852
- getReferencedVirtualElement,
853
- resolvedPluginKey
854
- ]);
855
- return createPortal(children, menuEl.current);
856
- }
857
- );
858
- var FloatingMenu = React2.forwardRef(
859
- ({
860
- pluginKey,
861
- editor,
646
+ };
647
+ }, [pluginEditor]);
648
+ useEffect(() => {
649
+ if (!pluginInitialized || !pluginEditor || pluginEditor.isDestroyed) return;
650
+ if (skipFirstUpdateRef.current) {
651
+ skipFirstUpdateRef.current = false;
652
+ return;
653
+ }
654
+ pluginEditor.view.dispatch(pluginEditor.state.tr.setMeta(resolvedPluginKey, {
655
+ type: "updateOptions",
656
+ options: bubbleMenuPluginPropsRef.current
657
+ }));
658
+ }, [
659
+ pluginInitialized,
660
+ pluginEditor,
862
661
  updateDelay,
863
662
  resizeDelay,
864
- appendTo,
865
- shouldShow = null,
663
+ shouldShow,
866
664
  options,
867
- children,
868
- ...restProps
869
- }, ref) => {
870
- const menuEl = useRef3(document.createElement("div"));
871
- const resolvedPluginKey = useRef3(
872
- getAutoPluginKey(pluginKey, "floatingMenu")
873
- ).current;
874
- useMenuElementProps(menuEl.current, restProps);
875
- if (typeof ref === "function") {
876
- ref(menuEl.current);
877
- } else if (ref) {
878
- ref.current = menuEl.current;
665
+ appendTo,
666
+ getReferencedVirtualElement,
667
+ resolvedPluginKey
668
+ ]);
669
+ return createPortal(children, menuEl.current);
670
+ });
671
+ var FloatingMenu = React.forwardRef(({ pluginKey, editor, updateDelay, resizeDelay, appendTo, shouldShow = null, options, children, ...restProps }, ref) => {
672
+ const menuEl = useRef(document.createElement("div"));
673
+ const resolvedPluginKey = useRef(getAutoPluginKey(pluginKey, "floatingMenu")).current;
674
+ useMenuElementProps(menuEl.current, restProps);
675
+ if (typeof ref === "function") ref(menuEl.current);
676
+ else if (ref) ref.current = menuEl.current;
677
+ const { editor: currentEditor } = useCurrentEditor();
678
+ const pluginEditor = editor || currentEditor;
679
+ const floatingMenuPluginProps = {
680
+ updateDelay,
681
+ resizeDelay,
682
+ appendTo,
683
+ pluginKey: resolvedPluginKey,
684
+ shouldShow,
685
+ options
686
+ };
687
+ const floatingMenuPluginPropsRef = useRef(floatingMenuPluginProps);
688
+ floatingMenuPluginPropsRef.current = floatingMenuPluginProps;
689
+ const [pluginInitialized, setPluginInitialized] = useState(false);
690
+ const skipFirstUpdateRef = useRef(true);
691
+ useEffect(() => {
692
+ if (pluginEditor === null || pluginEditor === void 0 ? void 0 : pluginEditor.isDestroyed) return;
693
+ if (!pluginEditor) {
694
+ console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");
695
+ return;
879
696
  }
880
- const { editor: currentEditor } = useCurrentEditor();
881
- const pluginEditor = editor || currentEditor;
882
- const floatingMenuPluginProps = {
883
- updateDelay,
884
- resizeDelay,
885
- appendTo,
886
- pluginKey: resolvedPluginKey,
887
- shouldShow,
888
- options
889
- };
890
- const floatingMenuPluginPropsRef = useRef3(floatingMenuPluginProps);
891
- floatingMenuPluginPropsRef.current = floatingMenuPluginProps;
892
- const [pluginInitialized, setPluginInitialized] = useState2(false);
893
- const skipFirstUpdateRef = useRef3(true);
894
- useEffect3(() => {
895
- if (pluginEditor == null ? void 0 : pluginEditor.isDestroyed) {
896
- return;
897
- }
898
- if (!pluginEditor) {
899
- console.warn(
900
- "FloatingMenu component is not rendered inside of an editor component or does not have editor prop."
901
- );
902
- return;
903
- }
904
- const floatingMenuElement = menuEl.current;
905
- floatingMenuElement.style.visibility = "hidden";
906
- floatingMenuElement.style.position = "absolute";
907
- const plugin = FloatingMenuPlugin({
908
- ...floatingMenuPluginPropsRef.current,
909
- editor: pluginEditor,
910
- element: floatingMenuElement
697
+ const floatingMenuElement = menuEl.current;
698
+ floatingMenuElement.style.visibility = "hidden";
699
+ floatingMenuElement.style.position = "absolute";
700
+ const plugin = FloatingMenuPlugin({
701
+ ...floatingMenuPluginPropsRef.current,
702
+ editor: pluginEditor,
703
+ element: floatingMenuElement
704
+ });
705
+ pluginEditor.registerPlugin(plugin);
706
+ const createdPluginKey = floatingMenuPluginPropsRef.current.pluginKey;
707
+ skipFirstUpdateRef.current = true;
708
+ setPluginInitialized(true);
709
+ return () => {
710
+ setPluginInitialized(false);
711
+ pluginEditor.unregisterPlugin(createdPluginKey);
712
+ window.requestAnimationFrame(() => {
713
+ if (floatingMenuElement.parentNode) floatingMenuElement.parentNode.removeChild(floatingMenuElement);
911
714
  });
912
- pluginEditor.registerPlugin(plugin);
913
- const createdPluginKey = floatingMenuPluginPropsRef.current.pluginKey;
914
- skipFirstUpdateRef.current = true;
915
- setPluginInitialized(true);
916
- return () => {
917
- setPluginInitialized(false);
918
- pluginEditor.unregisterPlugin(createdPluginKey);
919
- window.requestAnimationFrame(() => {
920
- if (floatingMenuElement.parentNode) {
921
- floatingMenuElement.parentNode.removeChild(floatingMenuElement);
922
- }
923
- });
924
- };
925
- }, [pluginEditor]);
926
- useEffect3(() => {
927
- if (!pluginInitialized || !pluginEditor || pluginEditor.isDestroyed) {
928
- return;
929
- }
930
- if (skipFirstUpdateRef.current) {
931
- skipFirstUpdateRef.current = false;
932
- return;
933
- }
934
- pluginEditor.view.dispatch(
935
- pluginEditor.state.tr.setMeta(resolvedPluginKey, {
936
- type: "updateOptions",
937
- options: floatingMenuPluginPropsRef.current
938
- })
939
- );
940
- }, [
941
- pluginInitialized,
942
- pluginEditor,
943
- updateDelay,
944
- resizeDelay,
945
- shouldShow,
946
- options,
947
- appendTo,
948
- resolvedPluginKey
949
- ]);
950
- return createPortal2(children, menuEl.current);
951
- }
952
- );
715
+ };
716
+ }, [pluginEditor]);
717
+ useEffect(() => {
718
+ if (!pluginInitialized || !pluginEditor || pluginEditor.isDestroyed) return;
719
+ if (skipFirstUpdateRef.current) {
720
+ skipFirstUpdateRef.current = false;
721
+ return;
722
+ }
723
+ pluginEditor.view.dispatch(pluginEditor.state.tr.setMeta(resolvedPluginKey, {
724
+ type: "updateOptions",
725
+ options: floatingMenuPluginPropsRef.current
726
+ }));
727
+ }, [
728
+ pluginInitialized,
729
+ pluginEditor,
730
+ updateDelay,
731
+ resizeDelay,
732
+ shouldShow,
733
+ options,
734
+ appendTo,
735
+ resolvedPluginKey
736
+ ]);
737
+ return createPortal(children, menuEl.current);
738
+ });
953
739
 
954
740
  // src/field/richtext/RichTextInsertMenu.module.css
955
741
  var RichTextInsertMenu_default = {
956
- "RichTextInsertMenu-label": "alinea-RichTextInsertMenu-label",
957
- "RichTextInsertMenuLabel": "alinea-RichTextInsertMenu-label",
742
+ "RichTextInsertMenu": "alinea-RichTextInsertMenu",
958
743
  "RichTextInsertMenu-item": "alinea-RichTextInsertMenu-item",
959
744
  "RichTextInsertMenuItem": "alinea-RichTextInsertMenu-item",
960
- "RichTextInsertMenu": "alinea-RichTextInsertMenu"
745
+ "RichTextInsertMenu-label": "alinea-RichTextInsertMenu-label",
746
+ "RichTextInsertMenuLabel": "alinea-RichTextInsertMenu-label"
961
747
  };
962
748
 
963
749
  // src/field/richtext/RichTextInsertMenu.tsx