reactjs-tiptap-editor 0.3.30 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/README.md +8 -2
  2. package/lib/{ActionMenuButton-wiDnIxE2.cjs → ActionMenuButton-CYdM1xx5.cjs} +1 -1
  3. package/lib/{ActionMenuButton-B6fitGKu.js → ActionMenuButton-DKRF6oa0.js} +5 -5
  4. package/lib/Attachment.cjs +2 -2
  5. package/lib/Attachment.d.cts +47 -51
  6. package/lib/Attachment.d.ts +47 -51
  7. package/lib/Attachment.js +7 -6
  8. package/lib/BaseKit.cjs +3 -0
  9. package/lib/BaseKit.d.cts +481 -0
  10. package/lib/BaseKit.d.ts +481 -0
  11. package/lib/BaseKit.js +132 -0
  12. package/lib/Blockquote.cjs +5 -1
  13. package/lib/Blockquote.d.cts +47 -51
  14. package/lib/Blockquote.d.ts +47 -51
  15. package/lib/Blockquote.js +33 -17
  16. package/lib/Bold.cjs +1 -1
  17. package/lib/Bold.d.cts +47 -51
  18. package/lib/Bold.d.ts +47 -51
  19. package/lib/Bold.js +23 -16
  20. package/lib/BulletList.cjs +1 -1
  21. package/lib/BulletList.d.cts +48 -52
  22. package/lib/BulletList.d.ts +48 -52
  23. package/lib/BulletList.js +11 -57
  24. package/lib/Clear.cjs +1 -1
  25. package/lib/Clear.d.cts +47 -51
  26. package/lib/Clear.d.ts +47 -51
  27. package/lib/Clear.js +4 -2
  28. package/lib/Code.cjs +1 -1
  29. package/lib/Code.d.cts +47 -51
  30. package/lib/Code.d.ts +47 -51
  31. package/lib/Code.js +29 -25
  32. package/lib/CodeBlock.cjs +2 -2
  33. package/lib/CodeBlock.d.cts +47 -51
  34. package/lib/CodeBlock.d.ts +47 -51
  35. package/lib/CodeBlock.js +5 -4
  36. package/lib/CodeView.cjs +1 -1
  37. package/lib/CodeView.d.cts +47 -51
  38. package/lib/CodeView.d.ts +47 -51
  39. package/lib/CodeView.js +3 -2
  40. package/lib/Color.cjs +1 -1
  41. package/lib/Color.d.cts +48 -52
  42. package/lib/Color.d.ts +48 -52
  43. package/lib/Color.js +42 -74
  44. package/lib/Document.cjs +1 -1
  45. package/lib/Document.d.cts +47 -51
  46. package/lib/Document.d.ts +47 -51
  47. package/lib/Document.js +4 -8
  48. package/lib/{Drawer-BKTU9CpU.js → Drawer-CaAfmqNo.js} +268 -265
  49. package/lib/Drawer-CdvCMSzN.cjs +1 -0
  50. package/lib/Drawer.cjs +1 -1
  51. package/lib/Drawer.d.cts +47 -51
  52. package/lib/Drawer.d.ts +47 -51
  53. package/lib/Drawer.js +4 -4
  54. package/lib/Emoji.cjs +1 -1
  55. package/lib/Emoji.d.cts +50 -52
  56. package/lib/Emoji.d.ts +50 -52
  57. package/lib/Emoji.js +19790 -178
  58. package/lib/Excalidraw-BbMQhNvs.cjs +1 -0
  59. package/lib/Excalidraw-CVWz2Vyn.js +290 -0
  60. package/lib/Excalidraw.cjs +1 -1
  61. package/lib/Excalidraw.d.cts +47 -51
  62. package/lib/Excalidraw.d.ts +47 -51
  63. package/lib/Excalidraw.js +3 -3
  64. package/lib/ExportPdf.cjs +1 -1
  65. package/lib/ExportPdf.d.cts +47 -51
  66. package/lib/ExportPdf.d.ts +47 -51
  67. package/lib/ExportPdf.js +4 -2
  68. package/lib/ExportWord.cjs +1 -1
  69. package/lib/ExportWord.d.cts +47 -51
  70. package/lib/ExportWord.d.ts +47 -51
  71. package/lib/ExportWord.js +22 -51
  72. package/lib/FontFamily.cjs +1 -1
  73. package/lib/FontFamily.d.cts +48 -52
  74. package/lib/FontFamily.d.ts +48 -52
  75. package/lib/FontFamily.js +46 -74
  76. package/lib/FontSize.cjs +1 -1
  77. package/lib/FontSize.d.cts +47 -51
  78. package/lib/FontSize.d.ts +47 -51
  79. package/lib/FontSize.js +11 -8
  80. package/lib/FormatPainter.cjs +1 -1
  81. package/lib/FormatPainter.d.cts +47 -51
  82. package/lib/FormatPainter.d.ts +47 -51
  83. package/lib/FormatPainter.js +4 -2
  84. package/lib/Heading.cjs +1 -1
  85. package/lib/Heading.d.cts +47 -51
  86. package/lib/Heading.d.ts +47 -51
  87. package/lib/Heading.js +77 -65
  88. package/lib/Highlight.cjs +1 -1
  89. package/lib/Highlight.d.cts +47 -51
  90. package/lib/Highlight.d.ts +47 -51
  91. package/lib/Highlight.js +5 -4
  92. package/lib/History.cjs +1 -1
  93. package/lib/History.d.cts +49 -53
  94. package/lib/History.d.ts +49 -53
  95. package/lib/History.js +39 -403
  96. package/lib/HorizontalRule.cjs +1 -1
  97. package/lib/HorizontalRule.d.cts +47 -51
  98. package/lib/HorizontalRule.d.ts +47 -51
  99. package/lib/HorizontalRule.js +16 -65
  100. package/lib/Iframe.cjs +1 -1
  101. package/lib/Iframe.d.cts +47 -51
  102. package/lib/Iframe.d.ts +47 -51
  103. package/lib/Iframe.js +4 -4
  104. package/lib/Image.cjs +1 -1
  105. package/lib/Image.d.cts +47 -51
  106. package/lib/Image.d.ts +47 -51
  107. package/lib/Image.js +3 -3
  108. package/lib/ImageGif.cjs +1 -1
  109. package/lib/ImageGif.d.cts +47 -51
  110. package/lib/ImageGif.d.ts +47 -51
  111. package/lib/ImageGif.js +5 -5
  112. package/lib/ImportWord.cjs +72 -72
  113. package/lib/ImportWord.d.cts +47 -51
  114. package/lib/ImportWord.d.ts +47 -51
  115. package/lib/ImportWord.js +5654 -5616
  116. package/lib/Indent.cjs +1 -1
  117. package/lib/Indent.d.cts +47 -51
  118. package/lib/Indent.d.ts +47 -51
  119. package/lib/Indent.js +4 -2
  120. package/lib/Italic.cjs +1 -1
  121. package/lib/Italic.d.cts +47 -51
  122. package/lib/Italic.d.ts +47 -51
  123. package/lib/Italic.js +20 -14
  124. package/lib/Katex.cjs +1 -1
  125. package/lib/Katex.d.cts +47 -51
  126. package/lib/Katex.d.ts +47 -51
  127. package/lib/Katex.js +49 -48
  128. package/lib/LineHeight.cjs +1 -1
  129. package/lib/LineHeight.d.cts +47 -51
  130. package/lib/LineHeight.d.ts +47 -51
  131. package/lib/LineHeight.js +21 -18
  132. package/lib/Link.cjs +1 -1
  133. package/lib/Link.d.cts +47 -51
  134. package/lib/Link.d.ts +47 -51
  135. package/lib/Link.js +4 -4
  136. package/lib/ListItem.cjs +1 -1
  137. package/lib/ListItem.d.cts +52 -52
  138. package/lib/ListItem.d.ts +52 -52
  139. package/lib/ListItem.js +4 -30
  140. package/lib/Mention.cjs +1 -1
  141. package/lib/Mention.d.cts +47 -51
  142. package/lib/Mention.d.ts +47 -51
  143. package/lib/Mention.js +161 -132
  144. package/lib/Mermaid.cjs +2 -2
  145. package/lib/Mermaid.d.cts +47 -51
  146. package/lib/Mermaid.d.ts +47 -51
  147. package/lib/Mermaid.js +150 -147
  148. package/lib/MoreMark.cjs +1 -1
  149. package/lib/MoreMark.d.cts +47 -51
  150. package/lib/MoreMark.d.ts +47 -51
  151. package/lib/MoreMark.js +5 -3
  152. package/lib/MultiColumn.cjs +1 -1
  153. package/lib/MultiColumn.d.cts +47 -51
  154. package/lib/MultiColumn.d.ts +47 -51
  155. package/lib/MultiColumn.js +2 -2
  156. package/lib/OrderedList.cjs +1 -1
  157. package/lib/OrderedList.d.cts +48 -52
  158. package/lib/OrderedList.d.ts +48 -52
  159. package/lib/OrderedList.js +11 -75
  160. package/lib/RichTextEditor-CxvwGvQG.cjs +142 -0
  161. package/lib/RichTextEditor-DGcKEUGr.js +22166 -0
  162. package/lib/SearchAndReplace.cjs +1 -1
  163. package/lib/SearchAndReplace.d.cts +60 -134
  164. package/lib/SearchAndReplace.d.ts +60 -134
  165. package/lib/SearchAndReplace.js +207 -194
  166. package/lib/Selection.cjs +1 -1
  167. package/lib/Selection.d.cts +47 -51
  168. package/lib/Selection.d.ts +47 -51
  169. package/lib/Selection.js +1 -1
  170. package/lib/SlashCommand.cjs +1 -1
  171. package/lib/SlashCommand.d.cts +47 -51
  172. package/lib/SlashCommand.d.ts +47 -51
  173. package/lib/SlashCommand.js +177 -222
  174. package/lib/Strike.cjs +1 -1
  175. package/lib/Strike.d.cts +47 -51
  176. package/lib/Strike.d.ts +47 -51
  177. package/lib/Strike.js +20 -14
  178. package/lib/SubAndSuperScript.cjs +1 -1
  179. package/lib/SubAndSuperScript.d.cts +47 -51
  180. package/lib/SubAndSuperScript.d.ts +47 -51
  181. package/lib/SubAndSuperScript.js +5 -3
  182. package/lib/Table.cjs +8 -10
  183. package/lib/Table.d.cts +50 -54
  184. package/lib/Table.d.ts +50 -54
  185. package/lib/Table.js +382 -2021
  186. package/lib/TableOfContent.cjs +1 -1
  187. package/lib/TableOfContent.d.cts +47 -51
  188. package/lib/TableOfContent.d.ts +47 -51
  189. package/lib/TableOfContent.js +53 -52
  190. package/lib/TaskList.cjs +1 -1
  191. package/lib/TaskList.d.cts +49 -53
  192. package/lib/TaskList.d.ts +49 -53
  193. package/lib/TaskList.js +12 -154
  194. package/lib/TextAlign.cjs +1 -1
  195. package/lib/TextAlign.d.cts +47 -51
  196. package/lib/TextAlign.d.ts +47 -51
  197. package/lib/TextAlign.js +11 -8
  198. package/lib/TextBubble.cjs +1 -1
  199. package/lib/TextBubble.d.cts +47 -51
  200. package/lib/TextBubble.d.ts +47 -51
  201. package/lib/TextBubble.js +5 -3
  202. package/lib/TextDirection.cjs +1 -1
  203. package/lib/TextDirection.d.cts +47 -51
  204. package/lib/TextDirection.d.ts +47 -51
  205. package/lib/TextDirection.js +15 -15
  206. package/lib/TextUnderline.cjs +1 -1
  207. package/lib/TextUnderline.d.cts +47 -51
  208. package/lib/TextUnderline.d.ts +47 -51
  209. package/lib/TextUnderline.js +40 -12
  210. package/lib/TrailingNode.cjs +1 -1
  211. package/lib/TrailingNode.d.cts +47 -51
  212. package/lib/TrailingNode.d.ts +47 -51
  213. package/lib/TrailingNode.js +1 -1
  214. package/lib/Twitter-BFULyqdR.js +1628 -0
  215. package/lib/Twitter-Cutpkh3h.cjs +1 -0
  216. package/lib/Twitter.cjs +1 -1
  217. package/lib/Twitter.d.cts +47 -51
  218. package/lib/Twitter.d.ts +47 -51
  219. package/lib/Twitter.js +3 -3
  220. package/lib/Video.cjs +1 -1
  221. package/lib/Video.d.cts +47 -51
  222. package/lib/Video.d.ts +47 -51
  223. package/lib/Video.js +3 -3
  224. package/lib/bubble-extra.cjs +2 -2
  225. package/lib/bubble-extra.d.cts +47 -51
  226. package/lib/bubble-extra.d.ts +47 -51
  227. package/lib/bubble-extra.js +200 -192
  228. package/lib/dom-dataset-_6-diIRQ.cjs +33 -0
  229. package/lib/dom-dataset-lYeH6gfI.js +2361 -0
  230. package/lib/index-5iBZLua9.cjs +12 -0
  231. package/lib/index-6D1J-A-o.cjs +1 -0
  232. package/lib/index-B96Cclrj.cjs +3 -0
  233. package/lib/index-BBz7Nmv9.js +55 -0
  234. package/lib/index-BeCTd5v2.cjs +1 -0
  235. package/lib/index-ByurDDMv.js +237 -0
  236. package/lib/index-CUogRI7j.cjs +1 -0
  237. package/lib/index-Ch6dBBad.js +709 -0
  238. package/lib/index-DF2Lp4HZ.cjs +100 -0
  239. package/lib/{index-LUL9mqY4.js → index-D_L6n8O8.js} +4 -4
  240. package/lib/index-Dbvi-Bvh.cjs +1 -0
  241. package/lib/index-DpCrt7xs.cjs +1 -0
  242. package/lib/index-DsAX1Vq8.cjs +1 -0
  243. package/lib/index-Dy4DlW9o.js +12 -0
  244. package/lib/index-J3jHHZ4d.js +200 -0
  245. package/lib/{index-CsK90iVd.js → index-LmrOdnen.js} +302 -389
  246. package/lib/index-VvXaaKe3.js +898 -0
  247. package/lib/index-kbO3iWqL.js +13432 -0
  248. package/lib/index.cjs +1 -2
  249. package/lib/index.d.cts +49 -251
  250. package/lib/index.d.ts +49 -251
  251. package/lib/index.js +2 -588
  252. package/lib/jsx-runtime-CT7Pcg-t.js +13 -0
  253. package/lib/jsx-runtime-C_NLcKys.cjs +1 -0
  254. package/lib/locale-bundle.cjs +1 -1
  255. package/lib/locale-bundle.d.cts +47 -51
  256. package/lib/locale-bundle.d.ts +47 -51
  257. package/lib/locale-bundle.js +1 -1
  258. package/lib/style.css +1 -1
  259. package/lib/{textarea-D5WVZMgt.cjs → textarea-DFo_aXnj.cjs} +1 -1
  260. package/lib/{textarea-BglwYF6b.js → textarea-aPtytkDx.js} +1 -1
  261. package/package.json +76 -70
  262. package/lib/Drawer-CmoEF-Zg.cjs +0 -1
  263. package/lib/Excalidraw-CM74U5tG.js +0 -289
  264. package/lib/Excalidraw-DAPP9qgY.cjs +0 -1
  265. package/lib/RichTextEditor-BQN2eLD_.js +0 -12775
  266. package/lib/RichTextEditor-C8Sm1E6J.cjs +0 -140
  267. package/lib/Twitter-CL2pu4QM.cjs +0 -17
  268. package/lib/Twitter-Dg6WWauX.js +0 -1743
  269. package/lib/dom-dataset-Byuf1YmW.cjs +0 -33
  270. package/lib/dom-dataset-Di3tIRrR.js +0 -1031
  271. package/lib/index-BI-IcZcN.cjs +0 -1
  272. package/lib/index-ByRfqzMr.cjs +0 -89
  273. package/lib/index-C1fzuXpN.js +0 -46
  274. package/lib/index-CbQQFj2T.js +0 -133
  275. package/lib/index-DI9T3iLd.js +0 -12354
  276. package/lib/index-D_A0TBRA.cjs +0 -1
  277. package/lib/index-DclQSrIx.cjs +0 -1
  278. package/lib/index-Z4b9rzn-.cjs +0 -1
@@ -1,1031 +0,0 @@
1
- import { P as ue, a as ae, j as de, i as ce, p as le, E as he, k as fe, l as pe, o as me } from "./index-DI9T3iLd.js";
2
- import ve from "tippy.js";
3
- import g, { useRef as Se, useState as F, useDebugValue as Z, useEffect as K, forwardRef as ye, useLayoutEffect as Ee, useContext as ee, createContext as te, createRef as _e, memo as ge, createElement as be, version as q } from "react";
4
- import Oe, { flushSync as we } from "react-dom";
5
- class De {
6
- constructor({ editor: e, element: t, view: r, tippyOptions: i = {}, updateDelay: o = 250, shouldShow: h }) {
7
- this.preventHide = !1, this.shouldShow = ({ view: s, state: f, from: d, to: c }) => {
8
- const { doc: u, selection: p } = f, { empty: m } = p, y = !u.textBetween(d, c).length && de(f.selection), S = this.element.contains(document.activeElement);
9
- return !(!(s.hasFocus() || S) || m || y || !this.editor.isEditable);
10
- }, this.mousedownHandler = () => {
11
- this.preventHide = !0;
12
- }, this.dragstartHandler = () => {
13
- this.hide();
14
- }, this.focusHandler = () => {
15
- setTimeout(() => this.update(this.editor.view));
16
- }, this.blurHandler = ({ event: s }) => {
17
- var f;
18
- if (this.preventHide) {
19
- this.preventHide = !1;
20
- return;
21
- }
22
- s != null && s.relatedTarget && (!((f = this.element.parentNode) === null || f === void 0) && f.contains(s.relatedTarget)) || (s == null ? void 0 : s.relatedTarget) !== this.editor.view.dom && this.hide();
23
- }, this.tippyBlurHandler = (s) => {
24
- this.blurHandler({ event: s });
25
- }, this.handleDebouncedUpdate = (s, f) => {
26
- const d = !(f != null && f.selection.eq(s.state.selection)), c = !(f != null && f.doc.eq(s.state.doc));
27
- !d && !c || (this.updateDebounceTimer && clearTimeout(this.updateDebounceTimer), this.updateDebounceTimer = window.setTimeout(() => {
28
- this.updateHandler(s, d, c, f);
29
- }, this.updateDelay));
30
- }, this.updateHandler = (s, f, d, c) => {
31
- var u, p, m;
32
- const { state: y, composing: S } = s, { selection: E } = y;
33
- if (S || !f && !d)
34
- return;
35
- this.createTooltip();
36
- const { ranges: D } = E, v = Math.min(...D.map((a) => a.$from.pos)), l = Math.max(...D.map((a) => a.$to.pos));
37
- if (!((u = this.shouldShow) === null || u === void 0 ? void 0 : u.call(this, {
38
- editor: this.editor,
39
- element: this.element,
40
- view: s,
41
- state: y,
42
- oldState: c,
43
- from: v,
44
- to: l
45
- }))) {
46
- this.hide();
47
- return;
48
- }
49
- (p = this.tippy) === null || p === void 0 || p.setProps({
50
- getReferenceClientRect: ((m = this.tippyOptions) === null || m === void 0 ? void 0 : m.getReferenceClientRect) || (() => {
51
- if (ce(y.selection)) {
52
- let a = s.nodeDOM(v);
53
- if (a) {
54
- const _ = a.dataset.nodeViewWrapper ? a : a.querySelector("[data-node-view-wrapper]");
55
- if (_ && (a = _.firstChild), a)
56
- return a.getBoundingClientRect();
57
- }
58
- }
59
- return le(s, v, l);
60
- })
61
- }), this.show();
62
- }, this.editor = e, this.element = t, this.view = r, this.updateDelay = o, h && (this.shouldShow = h), this.element.addEventListener("mousedown", this.mousedownHandler, { capture: !0 }), this.view.dom.addEventListener("dragstart", this.dragstartHandler), this.editor.on("focus", this.focusHandler), this.editor.on("blur", this.blurHandler), this.tippyOptions = i, this.element.remove(), this.element.style.visibility = "visible";
63
- }
64
- createTooltip() {
65
- const { element: e } = this.editor.options, t = !!e.parentElement;
66
- this.element.tabIndex = 0, !(this.tippy || !t) && (this.tippy = ve(e, {
67
- duration: 0,
68
- getReferenceClientRect: null,
69
- content: this.element,
70
- interactive: !0,
71
- trigger: "manual",
72
- placement: "top",
73
- hideOnClick: "toggle",
74
- ...this.tippyOptions
75
- }), this.tippy.popper.firstChild && this.tippy.popper.firstChild.addEventListener("blur", this.tippyBlurHandler));
76
- }
77
- update(e, t) {
78
- const { state: r } = e, i = r.selection.from !== r.selection.to;
79
- if (this.updateDelay > 0 && i) {
80
- this.handleDebouncedUpdate(e, t);
81
- return;
82
- }
83
- const o = !(t != null && t.selection.eq(e.state.selection)), h = !(t != null && t.doc.eq(e.state.doc));
84
- this.updateHandler(e, o, h, t);
85
- }
86
- show() {
87
- var e;
88
- (e = this.tippy) === null || e === void 0 || e.show();
89
- }
90
- hide() {
91
- var e;
92
- (e = this.tippy) === null || e === void 0 || e.hide();
93
- }
94
- destroy() {
95
- var e, t;
96
- !((e = this.tippy) === null || e === void 0) && e.popper.firstChild && this.tippy.popper.firstChild.removeEventListener("blur", this.tippyBlurHandler), (t = this.tippy) === null || t === void 0 || t.destroy(), this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: !0 }), this.view.dom.removeEventListener("dragstart", this.dragstartHandler), this.editor.off("focus", this.focusHandler), this.editor.off("blur", this.blurHandler);
97
- }
98
- }
99
- const ne = (n) => new ue({
100
- key: typeof n.pluginKey == "string" ? new ae(n.pluginKey) : n.pluginKey,
101
- view: (e) => new De({ view: e, ...n })
102
- });
103
- he.create({
104
- name: "bubbleMenu",
105
- addOptions() {
106
- return {
107
- element: null,
108
- tippyOptions: {},
109
- pluginKey: "bubbleMenu",
110
- updateDelay: void 0,
111
- shouldShow: null
112
- };
113
- },
114
- addProseMirrorPlugins() {
115
- return this.options.element ? [
116
- ne({
117
- pluginKey: this.options.pluginKey,
118
- editor: this.editor,
119
- element: this.options.element,
120
- tippyOptions: this.options.tippyOptions,
121
- updateDelay: this.options.updateDelay,
122
- shouldShow: this.options.shouldShow
123
- })
124
- ] : [];
125
- }
126
- });
127
- function Ce(n) {
128
- return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
129
- }
130
- var P = { exports: {} }, I = {};
131
- /**
132
- * @license React
133
- * use-sync-external-store-shim.production.min.js
134
- *
135
- * Copyright (c) Facebook, Inc. and its affiliates.
136
- *
137
- * This source code is licensed under the MIT license found in the
138
- * LICENSE file in the root directory of this source tree.
139
- */
140
- var z;
141
- function Re() {
142
- if (z) return I;
143
- z = 1;
144
- var n = g;
145
- function e(u, p) {
146
- return u === p && (u !== 0 || 1 / u === 1 / p) || u !== u && p !== p;
147
- }
148
- var t = typeof Object.is == "function" ? Object.is : e, r = n.useState, i = n.useEffect, o = n.useLayoutEffect, h = n.useDebugValue;
149
- function s(u, p) {
150
- var m = p(), y = r({ inst: { value: m, getSnapshot: p } }), S = y[0].inst, E = y[1];
151
- return o(function() {
152
- S.value = m, S.getSnapshot = p, f(S) && E({ inst: S });
153
- }, [u, m, p]), i(function() {
154
- return f(S) && E({ inst: S }), u(function() {
155
- f(S) && E({ inst: S });
156
- });
157
- }, [u]), h(m), m;
158
- }
159
- function f(u) {
160
- var p = u.getSnapshot;
161
- u = u.value;
162
- try {
163
- var m = p();
164
- return !t(u, m);
165
- } catch {
166
- return !0;
167
- }
168
- }
169
- function d(u, p) {
170
- return p();
171
- }
172
- var c = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? d : s;
173
- return I.useSyncExternalStore = n.useSyncExternalStore !== void 0 ? n.useSyncExternalStore : c, I;
174
- }
175
- var H = {};
176
- /**
177
- * @license React
178
- * use-sync-external-store-shim.development.js
179
- *
180
- * Copyright (c) Facebook, Inc. and its affiliates.
181
- *
182
- * This source code is licensed under the MIT license found in the
183
- * LICENSE file in the root directory of this source tree.
184
- */
185
- var G;
186
- function Te() {
187
- return G || (G = 1, process.env.NODE_ENV !== "production" && function() {
188
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
189
- var n = g, e = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
190
- function t(v) {
191
- {
192
- for (var l = arguments.length, b = new Array(l > 1 ? l - 1 : 0), a = 1; a < l; a++)
193
- b[a - 1] = arguments[a];
194
- r("error", v, b);
195
- }
196
- }
197
- function r(v, l, b) {
198
- {
199
- var a = e.ReactDebugCurrentFrame, _ = a.getStackAddendum();
200
- _ !== "" && (l += "%s", b = b.concat([_]));
201
- var w = b.map(function(O) {
202
- return String(O);
203
- });
204
- w.unshift("Warning: " + l), Function.prototype.apply.call(console[v], console, w);
205
- }
206
- }
207
- function i(v, l) {
208
- return v === l && (v !== 0 || 1 / v === 1 / l) || v !== v && l !== l;
209
- }
210
- var o = typeof Object.is == "function" ? Object.is : i, h = n.useState, s = n.useEffect, f = n.useLayoutEffect, d = n.useDebugValue, c = !1, u = !1;
211
- function p(v, l, b) {
212
- c || n.startTransition !== void 0 && (c = !0, t("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
213
- var a = l();
214
- if (!u) {
215
- var _ = l();
216
- o(a, _) || (t("The result of getSnapshot should be cached to avoid an infinite loop"), u = !0);
217
- }
218
- var w = h({
219
- inst: {
220
- value: a,
221
- getSnapshot: l
222
- }
223
- }), O = w[0].inst, R = w[1];
224
- return f(function() {
225
- O.value = a, O.getSnapshot = l, m(O) && R({
226
- inst: O
227
- });
228
- }, [v, a, l]), s(function() {
229
- m(O) && R({
230
- inst: O
231
- });
232
- var L = function() {
233
- m(O) && R({
234
- inst: O
235
- });
236
- };
237
- return v(L);
238
- }, [v]), d(a), a;
239
- }
240
- function m(v) {
241
- var l = v.getSnapshot, b = v.value;
242
- try {
243
- var a = l();
244
- return !o(b, a);
245
- } catch {
246
- return !0;
247
- }
248
- }
249
- function y(v, l, b) {
250
- return l();
251
- }
252
- var S = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", E = !S, C = E ? y : p, D = n.useSyncExternalStore !== void 0 ? n.useSyncExternalStore : C;
253
- H.useSyncExternalStore = D, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
254
- }()), H;
255
- }
256
- process.env.NODE_ENV === "production" ? P.exports = Re() : P.exports = Te();
257
- var M = P.exports;
258
- const Me = (...n) => (e) => {
259
- n.forEach((t) => {
260
- typeof t == "function" ? t(e) : t && (t.current = e);
261
- });
262
- }, Le = ({ contentComponent: n }) => {
263
- const e = M.useSyncExternalStore(n.subscribe, n.getSnapshot, n.getServerSnapshot);
264
- return g.createElement(g.Fragment, null, Object.values(e));
265
- };
266
- function Ae() {
267
- const n = /* @__PURE__ */ new Set();
268
- let e = {};
269
- return {
270
- /**
271
- * Subscribe to the editor instance's changes.
272
- */
273
- subscribe(t) {
274
- return n.add(t), () => {
275
- n.delete(t);
276
- };
277
- },
278
- getSnapshot() {
279
- return e;
280
- },
281
- getServerSnapshot() {
282
- return e;
283
- },
284
- /**
285
- * Adds a new NodeView Renderer to the editor.
286
- */
287
- setRenderer(t, r) {
288
- e = {
289
- ...e,
290
- [t]: Oe.createPortal(r.reactElement, r.element, t)
291
- }, n.forEach((i) => i());
292
- },
293
- /**
294
- * Removes a NodeView Renderer from the editor.
295
- */
296
- removeRenderer(t) {
297
- const r = { ...e };
298
- delete r[t], e = r, n.forEach((i) => i());
299
- }
300
- };
301
- }
302
- class Ne extends g.Component {
303
- constructor(e) {
304
- var t;
305
- super(e), this.editorContentRef = g.createRef(), this.initialized = !1, this.state = {
306
- hasContentComponentInitialized: !!(!((t = e.editor) === null || t === void 0) && t.contentComponent)
307
- };
308
- }
309
- componentDidMount() {
310
- this.init();
311
- }
312
- componentDidUpdate() {
313
- this.init();
314
- }
315
- init() {
316
- const e = this.props.editor;
317
- if (e && !e.isDestroyed && e.options.element) {
318
- if (e.contentComponent)
319
- return;
320
- const t = this.editorContentRef.current;
321
- t.append(...e.options.element.childNodes), e.setOptions({
322
- element: t
323
- }), e.contentComponent = Ae(), this.state.hasContentComponentInitialized || (this.unsubscribeToContentComponent = e.contentComponent.subscribe(() => {
324
- this.setState((r) => r.hasContentComponentInitialized ? r : {
325
- hasContentComponentInitialized: !0
326
- }), this.unsubscribeToContentComponent && this.unsubscribeToContentComponent();
327
- })), e.createNodeViews(), this.initialized = !0;
328
- }
329
- }
330
- componentWillUnmount() {
331
- const e = this.props.editor;
332
- if (!e || (this.initialized = !1, e.isDestroyed || e.view.setProps({
333
- nodeViews: {}
334
- }), this.unsubscribeToContentComponent && this.unsubscribeToContentComponent(), e.contentComponent = null, !e.options.element.firstChild))
335
- return;
336
- const t = document.createElement("div");
337
- t.append(...e.options.element.childNodes), e.setOptions({
338
- element: t
339
- });
340
- }
341
- render() {
342
- const { editor: e, innerRef: t, ...r } = this.props;
343
- return g.createElement(
344
- g.Fragment,
345
- null,
346
- g.createElement("div", { ref: Me(t, this.editorContentRef), ...r }),
347
- (e == null ? void 0 : e.contentComponent) && g.createElement(Le, { contentComponent: e.contentComponent })
348
- );
349
- }
350
- }
351
- const xe = ye((n, e) => {
352
- const t = g.useMemo(() => Math.floor(Math.random() * 4294967295).toString(), [n.editor]);
353
- return g.createElement(Ne, {
354
- key: t,
355
- innerRef: e,
356
- ...n
357
- });
358
- }), tt = g.memo(xe);
359
- var Ve = function n(e, t) {
360
- if (e === t) return !0;
361
- if (e && t && typeof e == "object" && typeof t == "object") {
362
- if (e.constructor !== t.constructor) return !1;
363
- var r, i, o;
364
- if (Array.isArray(e)) {
365
- if (r = e.length, r != t.length) return !1;
366
- for (i = r; i-- !== 0; )
367
- if (!n(e[i], t[i])) return !1;
368
- return !0;
369
- }
370
- if (e instanceof Map && t instanceof Map) {
371
- if (e.size !== t.size) return !1;
372
- for (i of e.entries())
373
- if (!t.has(i[0])) return !1;
374
- for (i of e.entries())
375
- if (!n(i[1], t.get(i[0]))) return !1;
376
- return !0;
377
- }
378
- if (e instanceof Set && t instanceof Set) {
379
- if (e.size !== t.size) return !1;
380
- for (i of e.entries())
381
- if (!t.has(i[0])) return !1;
382
- return !0;
383
- }
384
- if (ArrayBuffer.isView(e) && ArrayBuffer.isView(t)) {
385
- if (r = e.length, r != t.length) return !1;
386
- for (i = r; i-- !== 0; )
387
- if (e[i] !== t[i]) return !1;
388
- return !0;
389
- }
390
- if (e.constructor === RegExp) return e.source === t.source && e.flags === t.flags;
391
- if (e.valueOf !== Object.prototype.valueOf) return e.valueOf() === t.valueOf();
392
- if (e.toString !== Object.prototype.toString) return e.toString() === t.toString();
393
- if (o = Object.keys(e), r = o.length, r !== Object.keys(t).length) return !1;
394
- for (i = r; i-- !== 0; )
395
- if (!Object.prototype.hasOwnProperty.call(t, o[i])) return !1;
396
- for (i = r; i-- !== 0; ) {
397
- var h = o[i];
398
- if (!(h === "_owner" && e.$$typeof) && !n(e[h], t[h]))
399
- return !1;
400
- }
401
- return !0;
402
- }
403
- return e !== e && t !== t;
404
- }, Ie = /* @__PURE__ */ Ce(Ve), U = { exports: {} }, B = {};
405
- /**
406
- * @license React
407
- * use-sync-external-store-shim/with-selector.production.min.js
408
- *
409
- * Copyright (c) Facebook, Inc. and its affiliates.
410
- *
411
- * This source code is licensed under the MIT license found in the
412
- * LICENSE file in the root directory of this source tree.
413
- */
414
- var J;
415
- function He() {
416
- if (J) return B;
417
- J = 1;
418
- var n = g, e = M;
419
- function t(d, c) {
420
- return d === c && (d !== 0 || 1 / d === 1 / c) || d !== d && c !== c;
421
- }
422
- var r = typeof Object.is == "function" ? Object.is : t, i = e.useSyncExternalStore, o = n.useRef, h = n.useEffect, s = n.useMemo, f = n.useDebugValue;
423
- return B.useSyncExternalStoreWithSelector = function(d, c, u, p, m) {
424
- var y = o(null);
425
- if (y.current === null) {
426
- var S = { hasValue: !1, value: null };
427
- y.current = S;
428
- } else S = y.current;
429
- y = s(function() {
430
- function C(a) {
431
- if (!D) {
432
- if (D = !0, v = a, a = p(a), m !== void 0 && S.hasValue) {
433
- var _ = S.value;
434
- if (m(_, a)) return l = _;
435
- }
436
- return l = a;
437
- }
438
- if (_ = l, r(v, a)) return _;
439
- var w = p(a);
440
- return m !== void 0 && m(_, w) ? _ : (v = a, l = w);
441
- }
442
- var D = !1, v, l, b = u === void 0 ? null : u;
443
- return [function() {
444
- return C(c());
445
- }, b === null ? void 0 : function() {
446
- return C(b());
447
- }];
448
- }, [c, u, p, m]);
449
- var E = i(d, y[0], y[1]);
450
- return h(function() {
451
- S.hasValue = !0, S.value = E;
452
- }, [E]), f(E), E;
453
- }, B;
454
- }
455
- var j = {};
456
- /**
457
- * @license React
458
- * use-sync-external-store-shim/with-selector.development.js
459
- *
460
- * Copyright (c) Facebook, Inc. and its affiliates.
461
- *
462
- * This source code is licensed under the MIT license found in the
463
- * LICENSE file in the root directory of this source tree.
464
- */
465
- var Y;
466
- function Be() {
467
- return Y || (Y = 1, process.env.NODE_ENV !== "production" && function() {
468
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
469
- var n = g, e = M;
470
- function t(c, u) {
471
- return c === u && (c !== 0 || 1 / c === 1 / u) || c !== c && u !== u;
472
- }
473
- var r = typeof Object.is == "function" ? Object.is : t, i = e.useSyncExternalStore, o = n.useRef, h = n.useEffect, s = n.useMemo, f = n.useDebugValue;
474
- function d(c, u, p, m, y) {
475
- var S = o(null), E;
476
- S.current === null ? (E = {
477
- hasValue: !1,
478
- value: null
479
- }, S.current = E) : E = S.current;
480
- var C = s(function() {
481
- var b = !1, a, _, w = function(T) {
482
- if (!b) {
483
- b = !0, a = T;
484
- var A = m(T);
485
- if (y !== void 0 && E.hasValue) {
486
- var N = E.value;
487
- if (y(N, A))
488
- return _ = N, N;
489
- }
490
- return _ = A, A;
491
- }
492
- var se = a, x = _;
493
- if (r(se, T))
494
- return x;
495
- var V = m(T);
496
- return y !== void 0 && y(x, V) ? x : (a = T, _ = V, V);
497
- }, O = p === void 0 ? null : p, R = function() {
498
- return w(u());
499
- }, L = O === null ? void 0 : function() {
500
- return w(O());
501
- };
502
- return [R, L];
503
- }, [u, p, m, y]), D = C[0], v = C[1], l = i(c, D, v);
504
- return h(function() {
505
- E.hasValue = !0, E.value = l;
506
- }, [l]), f(l), l;
507
- }
508
- j.useSyncExternalStoreWithSelector = d, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
509
- }()), j;
510
- }
511
- process.env.NODE_ENV === "production" ? U.exports = He() : U.exports = Be();
512
- var je = U.exports;
513
- const Pe = typeof window < "u" ? Ee : K;
514
- class Ue {
515
- constructor(e) {
516
- this.transactionNumber = 0, this.lastTransactionNumber = 0, this.subscribers = /* @__PURE__ */ new Set(), this.editor = e, this.lastSnapshot = { editor: e, transactionNumber: 0 }, this.getSnapshot = this.getSnapshot.bind(this), this.getServerSnapshot = this.getServerSnapshot.bind(this), this.watch = this.watch.bind(this), this.subscribe = this.subscribe.bind(this);
517
- }
518
- /**
519
- * Get the current editor instance.
520
- */
521
- getSnapshot() {
522
- return this.transactionNumber === this.lastTransactionNumber ? this.lastSnapshot : (this.lastTransactionNumber = this.transactionNumber, this.lastSnapshot = { editor: this.editor, transactionNumber: this.transactionNumber }, this.lastSnapshot);
523
- }
524
- /**
525
- * Always disable the editor on the server-side.
526
- */
527
- getServerSnapshot() {
528
- return { editor: null, transactionNumber: 0 };
529
- }
530
- /**
531
- * Subscribe to the editor instance's changes.
532
- */
533
- subscribe(e) {
534
- return this.subscribers.add(e), () => {
535
- this.subscribers.delete(e);
536
- };
537
- }
538
- /**
539
- * Watch the editor instance for changes.
540
- */
541
- watch(e) {
542
- if (this.editor = e, this.editor) {
543
- const t = () => {
544
- this.transactionNumber += 1, this.subscribers.forEach((i) => i());
545
- }, r = this.editor;
546
- return r.on("transaction", t), () => {
547
- r.off("transaction", t);
548
- };
549
- }
550
- }
551
- }
552
- function $e(n) {
553
- var e;
554
- const [t] = F(() => new Ue(n.editor)), r = je.useSyncExternalStoreWithSelector(t.subscribe, t.getSnapshot, t.getServerSnapshot, n.selector, (e = n.equalityFn) !== null && e !== void 0 ? e : Ie);
555
- return Pe(() => t.watch(n.editor), [n.editor, t]), Z(r), r;
556
- }
557
- const k = process.env.NODE_ENV !== "production", $ = typeof window > "u", Fe = $ || !!(typeof window < "u" && window.next);
558
- class W {
559
- constructor(e) {
560
- this.editor = null, this.subscriptions = /* @__PURE__ */ new Set(), this.isComponentMounted = !1, this.previousDeps = null, this.instanceId = "", this.options = e, this.subscriptions = /* @__PURE__ */ new Set(), this.setEditor(this.getInitialEditor()), this.scheduleDestroy(), this.getEditor = this.getEditor.bind(this), this.getServerSnapshot = this.getServerSnapshot.bind(this), this.subscribe = this.subscribe.bind(this), this.refreshEditorInstance = this.refreshEditorInstance.bind(this), this.scheduleDestroy = this.scheduleDestroy.bind(this), this.onRender = this.onRender.bind(this), this.createEditor = this.createEditor.bind(this);
561
- }
562
- setEditor(e) {
563
- this.editor = e, this.instanceId = Math.random().toString(36).slice(2, 9), this.subscriptions.forEach((t) => t());
564
- }
565
- getInitialEditor() {
566
- if (this.options.current.immediatelyRender === void 0)
567
- return $ || Fe ? (k && console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."), null) : this.createEditor();
568
- if (this.options.current.immediatelyRender && $ && k)
569
- throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");
570
- return this.options.current.immediatelyRender ? this.createEditor() : null;
571
- }
572
- /**
573
- * Create a new editor instance. And attach event listeners.
574
- */
575
- createEditor() {
576
- const e = {
577
- ...this.options.current,
578
- // Always call the most recent version of the callback function by default
579
- onBeforeCreate: (...r) => {
580
- var i, o;
581
- return (o = (i = this.options.current).onBeforeCreate) === null || o === void 0 ? void 0 : o.call(i, ...r);
582
- },
583
- onBlur: (...r) => {
584
- var i, o;
585
- return (o = (i = this.options.current).onBlur) === null || o === void 0 ? void 0 : o.call(i, ...r);
586
- },
587
- onCreate: (...r) => {
588
- var i, o;
589
- return (o = (i = this.options.current).onCreate) === null || o === void 0 ? void 0 : o.call(i, ...r);
590
- },
591
- onDestroy: (...r) => {
592
- var i, o;
593
- return (o = (i = this.options.current).onDestroy) === null || o === void 0 ? void 0 : o.call(i, ...r);
594
- },
595
- onFocus: (...r) => {
596
- var i, o;
597
- return (o = (i = this.options.current).onFocus) === null || o === void 0 ? void 0 : o.call(i, ...r);
598
- },
599
- onSelectionUpdate: (...r) => {
600
- var i, o;
601
- return (o = (i = this.options.current).onSelectionUpdate) === null || o === void 0 ? void 0 : o.call(i, ...r);
602
- },
603
- onTransaction: (...r) => {
604
- var i, o;
605
- return (o = (i = this.options.current).onTransaction) === null || o === void 0 ? void 0 : o.call(i, ...r);
606
- },
607
- onUpdate: (...r) => {
608
- var i, o;
609
- return (o = (i = this.options.current).onUpdate) === null || o === void 0 ? void 0 : o.call(i, ...r);
610
- },
611
- onContentError: (...r) => {
612
- var i, o;
613
- return (o = (i = this.options.current).onContentError) === null || o === void 0 ? void 0 : o.call(i, ...r);
614
- },
615
- onDrop: (...r) => {
616
- var i, o;
617
- return (o = (i = this.options.current).onDrop) === null || o === void 0 ? void 0 : o.call(i, ...r);
618
- },
619
- onPaste: (...r) => {
620
- var i, o;
621
- return (o = (i = this.options.current).onPaste) === null || o === void 0 ? void 0 : o.call(i, ...r);
622
- }
623
- };
624
- return new fe(e);
625
- }
626
- /**
627
- * Get the current editor instance.
628
- */
629
- getEditor() {
630
- return this.editor;
631
- }
632
- /**
633
- * Always disable the editor on the server-side.
634
- */
635
- getServerSnapshot() {
636
- return null;
637
- }
638
- /**
639
- * Subscribe to the editor instance's changes.
640
- */
641
- subscribe(e) {
642
- return this.subscriptions.add(e), () => {
643
- this.subscriptions.delete(e);
644
- };
645
- }
646
- static compareOptions(e, t) {
647
- return Object.keys(e).every((r) => ["onCreate", "onBeforeCreate", "onDestroy", "onUpdate", "onTransaction", "onFocus", "onBlur", "onSelectionUpdate", "onContentError", "onDrop", "onPaste"].includes(r) ? !0 : r === "extensions" && e.extensions && t.extensions ? e.extensions.length !== t.extensions.length ? !1 : e.extensions.every((i, o) => {
648
- var h;
649
- return i === ((h = t.extensions) === null || h === void 0 ? void 0 : h[o]);
650
- }) : e[r] === t[r]);
651
- }
652
- /**
653
- * On each render, we will create, update, or destroy the editor instance.
654
- * @param deps The dependencies to watch for changes
655
- * @returns A cleanup function
656
- */
657
- onRender(e) {
658
- return () => (this.isComponentMounted = !0, clearTimeout(this.scheduledDestructionTimeout), this.editor && !this.editor.isDestroyed && e.length === 0 ? W.compareOptions(this.options.current, this.editor.options) || this.editor.setOptions({
659
- ...this.options.current,
660
- editable: this.editor.isEditable
661
- }) : this.refreshEditorInstance(e), () => {
662
- this.isComponentMounted = !1, this.scheduleDestroy();
663
- });
664
- }
665
- /**
666
- * Recreate the editor instance if the dependencies have changed.
667
- */
668
- refreshEditorInstance(e) {
669
- if (this.editor && !this.editor.isDestroyed) {
670
- if (this.previousDeps === null) {
671
- this.previousDeps = e;
672
- return;
673
- }
674
- if (this.previousDeps.length === e.length && this.previousDeps.every((r, i) => r === e[i]))
675
- return;
676
- }
677
- this.editor && !this.editor.isDestroyed && this.editor.destroy(), this.setEditor(this.createEditor()), this.previousDeps = e;
678
- }
679
- /**
680
- * Schedule the destruction of the editor instance.
681
- * This will only destroy the editor if it was not mounted on the next tick.
682
- * This is to avoid destroying the editor instance when it's actually still mounted.
683
- */
684
- scheduleDestroy() {
685
- const e = this.instanceId, t = this.editor;
686
- this.scheduledDestructionTimeout = setTimeout(() => {
687
- if (this.isComponentMounted && this.instanceId === e) {
688
- t && t.setOptions(this.options.current);
689
- return;
690
- }
691
- t && !t.isDestroyed && (t.destroy(), this.instanceId === e && this.setEditor(null));
692
- }, 1);
693
- }
694
- }
695
- function nt(n = {}, e = []) {
696
- const t = Se(n);
697
- t.current = n;
698
- const [r] = F(() => new W(t)), i = M.useSyncExternalStore(r.subscribe, r.getEditor, r.getServerSnapshot);
699
- return Z(i), K(r.onRender(e)), $e({
700
- editor: i,
701
- selector: ({ transactionNumber: o }) => n.shouldRerenderOnTransaction === !1 ? null : n.immediatelyRender && o === 0 ? 0 : o + 1
702
- }), i;
703
- }
704
- const re = te({
705
- editor: null
706
- });
707
- re.Consumer;
708
- const Ke = () => ee(re), rt = (n) => {
709
- const [e, t] = F(null), { editor: r } = Ke();
710
- return K(() => {
711
- var i;
712
- if (!e || !((i = n.editor) === null || i === void 0) && i.isDestroyed || r != null && r.isDestroyed)
713
- return;
714
- const { pluginKey: o = "bubbleMenu", editor: h, tippyOptions: s = {}, updateDelay: f, shouldShow: d = null } = n, c = h || r;
715
- if (!c) {
716
- console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");
717
- return;
718
- }
719
- const u = ne({
720
- updateDelay: f,
721
- editor: c,
722
- element: e,
723
- pluginKey: o,
724
- shouldShow: d,
725
- tippyOptions: s
726
- });
727
- return c.registerPlugin(u), () => {
728
- c.unregisterPlugin(o);
729
- };
730
- }, [n.editor, r, e]), g.createElement("div", { ref: t, className: n.className, style: { visibility: "hidden" } }, n.children);
731
- }, ie = te({
732
- onDragStart: void 0
733
- }), We = () => ee(ie), it = g.forwardRef((n, e) => {
734
- const { onDragStart: t } = We(), r = n.as || "div";
735
- return (
736
- // @ts-ignore
737
- g.createElement(r, { ...n, ref: e, "data-node-view-wrapper": "", onDragStart: t, style: {
738
- whiteSpace: "normal",
739
- ...n.style
740
- } })
741
- );
742
- });
743
- function Q(n) {
744
- return !!(typeof n == "function" && n.prototype && n.prototype.isReactComponent);
745
- }
746
- function X(n) {
747
- return !!(typeof n == "object" && n.$$typeof && (n.$$typeof.toString() === "Symbol(react.forward_ref)" || n.$$typeof.description === "react.forward_ref"));
748
- }
749
- function qe(n) {
750
- return !!(typeof n == "object" && n.$$typeof && (n.$$typeof.toString() === "Symbol(react.memo)" || n.$$typeof.description === "react.memo"));
751
- }
752
- function ze(n) {
753
- if (Q(n) || X(n))
754
- return !0;
755
- if (qe(n)) {
756
- const e = n.type;
757
- if (e)
758
- return Q(e) || X(e);
759
- }
760
- return !1;
761
- }
762
- function Ge() {
763
- try {
764
- if (q)
765
- return parseInt(q.split(".")[0], 10) >= 19;
766
- } catch {
767
- }
768
- return !1;
769
- }
770
- class Je {
771
- /**
772
- * Immediately creates element and renders the provided React component.
773
- */
774
- constructor(e, { editor: t, props: r = {}, as: i = "div", className: o = "" }) {
775
- this.ref = null, this.id = Math.floor(Math.random() * 4294967295).toString(), this.component = e, this.editor = t, this.props = r, this.element = document.createElement(i), this.element.classList.add("react-renderer"), o && this.element.classList.add(...o.split(" ")), this.editor.isInitialized ? we(() => {
776
- this.render();
777
- }) : queueMicrotask(() => {
778
- this.render();
779
- });
780
- }
781
- /**
782
- * Render the React component.
783
- */
784
- render() {
785
- var e;
786
- const t = this.component, r = this.props, i = this.editor, o = Ge(), h = ze(t), s = { ...r };
787
- s.ref && !(o || h) && delete s.ref, !s.ref && (o || h) && (s.ref = (f) => {
788
- this.ref = f;
789
- }), this.reactElement = g.createElement(t, { ...s }), (e = i == null ? void 0 : i.contentComponent) === null || e === void 0 || e.setRenderer(this.id, this);
790
- }
791
- /**
792
- * Re-renders the React component with new props.
793
- */
794
- updateProps(e = {}) {
795
- this.props = {
796
- ...this.props,
797
- ...e
798
- }, this.render();
799
- }
800
- /**
801
- * Destroy the React component.
802
- */
803
- destroy() {
804
- var e;
805
- const t = this.editor;
806
- (e = t == null ? void 0 : t.contentComponent) === null || e === void 0 || e.removeRenderer(this.id);
807
- }
808
- /**
809
- * Update the attributes of the element that holds the React component.
810
- */
811
- updateAttributes(e) {
812
- Object.keys(e).forEach((t) => {
813
- this.element.setAttribute(t, e[t]);
814
- });
815
- }
816
- }
817
- class Ye extends pe {
818
- constructor(e, t, r) {
819
- if (super(e, t, r), !this.node.isLeaf) {
820
- this.options.contentDOMElementTag ? this.contentDOMElement = document.createElement(this.options.contentDOMElementTag) : this.contentDOMElement = document.createElement(this.node.isInline ? "span" : "div"), this.contentDOMElement.dataset.nodeViewContentReact = "", this.contentDOMElement.dataset.nodeViewWrapper = "", this.contentDOMElement.style.whiteSpace = "inherit";
821
- const i = this.dom.querySelector("[data-node-view-content]");
822
- if (!i)
823
- return;
824
- i.appendChild(this.contentDOMElement);
825
- }
826
- }
827
- /**
828
- * Setup the React component.
829
- * Called on initialization.
830
- */
831
- mount() {
832
- const e = {
833
- editor: this.editor,
834
- node: this.node,
835
- decorations: this.decorations,
836
- innerDecorations: this.innerDecorations,
837
- view: this.view,
838
- selected: !1,
839
- extension: this.extension,
840
- HTMLAttributes: this.HTMLAttributes,
841
- getPos: () => this.getPos(),
842
- updateAttributes: (d = {}) => this.updateAttributes(d),
843
- deleteNode: () => this.deleteNode(),
844
- ref: _e()
845
- };
846
- if (!this.component.displayName) {
847
- const d = (c) => c.charAt(0).toUpperCase() + c.substring(1);
848
- this.component.displayName = d(this.extension.name);
849
- }
850
- const i = { onDragStart: this.onDragStart.bind(this), nodeViewContentRef: (d) => {
851
- d && this.contentDOMElement && d.firstChild !== this.contentDOMElement && (d.hasAttribute("data-node-view-wrapper") && d.removeAttribute("data-node-view-wrapper"), d.appendChild(this.contentDOMElement));
852
- } }, o = this.component, h = ge((d) => g.createElement(ie.Provider, { value: i }, be(o, d)));
853
- h.displayName = "ReactNodeView";
854
- let s = this.node.isInline ? "span" : "div";
855
- this.options.as && (s = this.options.as);
856
- const { className: f = "" } = this.options;
857
- this.handleSelectionUpdate = this.handleSelectionUpdate.bind(this), this.renderer = new Je(h, {
858
- editor: this.editor,
859
- props: e,
860
- as: s,
861
- className: `node-${this.node.type.name} ${f}`.trim()
862
- }), this.editor.on("selectionUpdate", this.handleSelectionUpdate), this.updateElementAttributes();
863
- }
864
- /**
865
- * Return the DOM element.
866
- * This is the element that will be used to display the node view.
867
- */
868
- get dom() {
869
- var e;
870
- if (this.renderer.element.firstElementChild && !(!((e = this.renderer.element.firstElementChild) === null || e === void 0) && e.hasAttribute("data-node-view-wrapper")))
871
- throw Error("Please use the NodeViewWrapper component for your node view.");
872
- return this.renderer.element;
873
- }
874
- /**
875
- * Return the content DOM element.
876
- * This is the element that will be used to display the rich-text content of the node.
877
- */
878
- get contentDOM() {
879
- return this.node.isLeaf ? null : this.contentDOMElement;
880
- }
881
- /**
882
- * On editor selection update, check if the node is selected.
883
- * If it is, call `selectNode`, otherwise call `deselectNode`.
884
- */
885
- handleSelectionUpdate() {
886
- const { from: e, to: t } = this.editor.state.selection, r = this.getPos();
887
- if (typeof r == "number")
888
- if (e <= r && t >= r + this.node.nodeSize) {
889
- if (this.renderer.props.selected)
890
- return;
891
- this.selectNode();
892
- } else {
893
- if (!this.renderer.props.selected)
894
- return;
895
- this.deselectNode();
896
- }
897
- }
898
- /**
899
- * On update, update the React component.
900
- * To prevent unnecessary updates, the `update` option can be used.
901
- */
902
- update(e, t, r) {
903
- const i = (o) => {
904
- this.renderer.updateProps(o), typeof this.options.attrs == "function" && this.updateElementAttributes();
905
- };
906
- if (e.type !== this.node.type)
907
- return !1;
908
- if (typeof this.options.update == "function") {
909
- const o = this.node, h = this.decorations, s = this.innerDecorations;
910
- return this.node = e, this.decorations = t, this.innerDecorations = r, this.options.update({
911
- oldNode: o,
912
- oldDecorations: h,
913
- newNode: e,
914
- newDecorations: t,
915
- oldInnerDecorations: s,
916
- innerDecorations: r,
917
- updateProps: () => i({ node: e, decorations: t, innerDecorations: r })
918
- });
919
- }
920
- return e === this.node && this.decorations === t && this.innerDecorations === r || (this.node = e, this.decorations = t, this.innerDecorations = r, i({ node: e, decorations: t, innerDecorations: r })), !0;
921
- }
922
- /**
923
- * Select the node.
924
- * Add the `selected` prop and the `ProseMirror-selectednode` class.
925
- */
926
- selectNode() {
927
- this.renderer.updateProps({
928
- selected: !0
929
- }), this.renderer.element.classList.add("ProseMirror-selectednode");
930
- }
931
- /**
932
- * Deselect the node.
933
- * Remove the `selected` prop and the `ProseMirror-selectednode` class.
934
- */
935
- deselectNode() {
936
- this.renderer.updateProps({
937
- selected: !1
938
- }), this.renderer.element.classList.remove("ProseMirror-selectednode");
939
- }
940
- /**
941
- * Destroy the React component instance.
942
- */
943
- destroy() {
944
- this.renderer.destroy(), this.editor.off("selectionUpdate", this.handleSelectionUpdate), this.contentDOMElement = null;
945
- }
946
- /**
947
- * Update the attributes of the top-level element that holds the React component.
948
- * Applying the attributes defined in the `attrs` option.
949
- */
950
- updateElementAttributes() {
951
- if (this.options.attrs) {
952
- let e = {};
953
- if (typeof this.options.attrs == "function") {
954
- const t = this.editor.extensionManager.attributes, r = me(this.node, t);
955
- e = this.options.attrs({ node: this.node, HTMLAttributes: r });
956
- } else
957
- e = this.options.attrs;
958
- this.renderer.updateAttributes(e);
959
- }
960
- }
961
- }
962
- function ot(n, e) {
963
- return (t) => t.editor.contentComponent ? new Ye(n, t, e) : {};
964
- }
965
- function oe(n) {
966
- var e, t, r = "";
967
- if (typeof n == "string" || typeof n == "number") r += n;
968
- else if (typeof n == "object") if (Array.isArray(n)) {
969
- var i = n.length;
970
- for (e = 0; e < i; e++) n[e] && (t = oe(n[e])) && (r && (r += " "), r += t);
971
- } else for (t in n) n[t] && (r && (r += " "), r += t);
972
- return r;
973
- }
974
- function st() {
975
- for (var n, e, t = 0, r = "", i = arguments.length; t < i; t++) (n = arguments[t]) && (e = oe(n)) && (r && (r += " "), r += e);
976
- return r;
977
- }
978
- function ke(n) {
979
- try {
980
- return JSON.stringify(n);
981
- } catch {
982
- return JSON.stringify({});
983
- }
984
- }
985
- function ut(n, e = !1) {
986
- return (t) => {
987
- const r = n.startsWith("data-") ? n : `data-${n}`;
988
- let i = decodeURIComponent(t.getAttribute(r));
989
- if (i == null || typeof i == "string" && i === "null")
990
- try {
991
- const s = t.outerHTML.match(/([\S\s])+?="([\S\s])+?"/g);
992
- s && s.length > 0 && (i = (s.map((d) => d.trim()).reduce((d, c) => {
993
- const u = c.indexOf("="), p = [c.slice(0, u), c.slice(u + 1).slice(1, -1)];
994
- return d[p[0]] = p[1], d;
995
- }, {})[n.toLowerCase()] || "").replaceAll("&quot;", '"'));
996
- } catch (h) {
997
- console.error("Error getDatasetAttribute ", h.message, t);
998
- }
999
- if (e)
1000
- try {
1001
- return JSON.parse(i);
1002
- } catch {
1003
- return {};
1004
- }
1005
- if (i.includes("%") || i.includes("auto"))
1006
- return i;
1007
- const o = Number.parseInt(i);
1008
- return o !== o ? i : o;
1009
- };
1010
- }
1011
- function at(n) {
1012
- const { attrs: e } = n;
1013
- return Object.keys(e).reduce((t, r) => {
1014
- const i = e[r];
1015
- if (i == null)
1016
- return t;
1017
- let o = "";
1018
- return typeof i == "object" ? o = ke(i) : o = i, t[r] = o, t;
1019
- }, /* @__PURE__ */ Object.create(null));
1020
- }
1021
- export {
1022
- rt as B,
1023
- tt as E,
1024
- it as N,
1025
- ot as R,
1026
- Je as a,
1027
- st as c,
1028
- ut as g,
1029
- at as n,
1030
- nt as u
1031
- };