ct-rich-text-editor 1.0.8 → 1.0.9

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 (180) hide show
  1. package/dist/App.d.ts +4 -0
  2. package/dist/Provider/EditorProvider.d.ts +19 -0
  3. package/dist/Provider/LexicalProvider.d.ts +7 -0
  4. package/dist/api/ai/index.d.ts +15 -0
  5. package/dist/api/auth.d.ts +101 -0
  6. package/dist/api/config/axios.d.ts +3 -0
  7. package/dist/api/config/endpoints.d.ts +11 -0
  8. package/dist/assets/style.css +1 -0
  9. package/dist/babel-1c4a328b.js +7479 -0
  10. package/dist/babel-1c4a328b.js.map +1 -0
  11. package/dist/components/AiPlugin/index.d.ts +4 -0
  12. package/dist/components/AlignMenu/AlignMenu.d.ts +10 -0
  13. package/dist/components/AlignMenu/index.d.ts +1 -0
  14. package/dist/components/BlockFormatMenu/BlockFormatMenu.d.ts +5 -0
  15. package/dist/components/BlockFormatMenu/constants.d.ts +14 -0
  16. package/dist/components/BlockFormatMenu/index.d.ts +1 -0
  17. package/dist/components/CodeActionMenuPlugin/components/CopyButton/index.d.ts +8 -0
  18. package/dist/components/CodeActionMenuPlugin/components/PrettierButton/index.d.ts +10 -0
  19. package/dist/components/CodeActionMenuPlugin/index.d.ts +5 -0
  20. package/dist/components/CodeActionMenuPlugin/utils.d.ts +1 -0
  21. package/dist/components/ColorPicker/ColorPicker.d.ts +5 -0
  22. package/dist/components/ColorPicker/index.d.ts +1 -0
  23. package/dist/components/ConfigurableEditorWithAuth.d.ts +15 -0
  24. package/dist/components/EmojiPickerWidget/EmojiPickerWidget.d.ts +5 -0
  25. package/dist/components/EmojiPickerWidget/index.d.ts +1 -0
  26. package/dist/components/FileUpload/InsertFileDialog.d.ts +7 -0
  27. package/dist/components/FileUpload/InsertFileUploadedDialogBody.d.ts +6 -0
  28. package/dist/components/FontFamilySelect/FontFamilyMenu.d.ts +9 -0
  29. package/dist/components/FontSizePicker/FontSizeControl.d.ts +4 -0
  30. package/dist/components/FormatTextMenu/FormatTextMenu.d.ts +5 -0
  31. package/dist/components/FormatTextMenu/index.d.ts +1 -0
  32. package/dist/components/HighlightColorPicker/HighlightColorPicker.d.ts +8 -0
  33. package/dist/components/ImageView/ImageDialog/ImageUploadDialogBody.d.ts +10 -0
  34. package/dist/components/ImageView/ImageDialog/index.d.ts +7 -0
  35. package/dist/components/ImageView/ImageResizer.d.ts +17 -0
  36. package/dist/components/ImageView/index.d.ts +15 -0
  37. package/dist/components/InsertMenu/InsertMenu.d.ts +10 -0
  38. package/dist/components/InsertMenu/index.d.ts +1 -0
  39. package/dist/components/Placeholder/Placeholder.d.ts +5 -0
  40. package/dist/components/Placeholder/index.d.ts +1 -0
  41. package/dist/components/Placeholder/styles.d.ts +1 -0
  42. package/dist/components/ScopedEditor.d.ts +8 -0
  43. package/dist/components/TableColorPicker/index.d.ts +9 -0
  44. package/dist/components/TableModal/TableModal.d.ts +11 -0
  45. package/dist/components/Toolbar/Toolbar.d.ts +5 -0
  46. package/dist/components/Toolbar/index.d.ts +1 -0
  47. package/dist/components/Toolbar/styles.d.ts +6 -0
  48. package/dist/components/ui/button.d.ts +12 -0
  49. package/dist/components/ui/dialog.d.ts +19 -0
  50. package/dist/components/ui/dropdown-menu.d.ts +27 -0
  51. package/dist/components/ui/input.d.ts +3 -0
  52. package/dist/components/ui/label.d.ts +5 -0
  53. package/dist/components/ui/popover.d.ts +7 -0
  54. package/dist/components/ui/select.d.ts +13 -0
  55. package/dist/components/ui/separator.d.ts +4 -0
  56. package/dist/components/ui/tooltip.d.ts +7 -0
  57. package/dist/constants.d.ts +36 -0
  58. package/dist/context/ToolbarContext.d.ts +56 -0
  59. package/dist/editorConfig.d.ts +37 -0
  60. package/dist/estree-2cbea43c.js +4668 -0
  61. package/dist/estree-2cbea43c.js.map +1 -0
  62. package/dist/hooks/useBlockFormat.d.ts +22 -0
  63. package/dist/hooks/useColorPicker.d.ts +6 -0
  64. package/dist/hooks/useCustomCommands.d.ts +4 -0
  65. package/dist/hooks/useDebounce.d.ts +1 -0
  66. package/dist/hooks/useEditorToolbar.d.ts +11 -0
  67. package/dist/hooks/useInsertMenu.d.ts +9 -0
  68. package/dist/hooks/useModal.d.ts +5 -0
  69. package/dist/hooks/useS3Uploader.d.ts +11 -0
  70. package/dist/html-c18fb60e.js +2842 -0
  71. package/dist/html-c18fb60e.js.map +1 -0
  72. package/dist/index-988ead1c.js +32204 -0
  73. package/dist/index-988ead1c.js.map +1 -0
  74. package/dist/index-9ce51b54.js +632 -0
  75. package/dist/index-9ce51b54.js.map +1 -0
  76. package/dist/index.d.ts +6 -0
  77. package/dist/index.js +21 -0
  78. package/dist/index.js.map +1 -0
  79. package/dist/lib/utils.d.ts +3 -0
  80. package/dist/main.d.ts +1 -0
  81. package/dist/markdown-39c3822b.js +3548 -0
  82. package/dist/markdown-39c3822b.js.map +1 -0
  83. package/dist/nodes/EmbedNode.d.ts +27 -0
  84. package/dist/nodes/ImageNode.d.ts +48 -0
  85. package/dist/nodes/MentionNode.d.ts +76 -0
  86. package/dist/pages/ConfigurableEditor/ConfigurableEditor.d.ts +14 -0
  87. package/dist/pages/ConfigurableEditor/index.d.ts +2 -0
  88. package/dist/pages/NotFound.d.ts +2 -0
  89. package/dist/pages/RichTextEditor.d.ts +6 -0
  90. package/dist/pages/TextareaEditor.d.ts +6 -0
  91. package/dist/pages/styles.d.ts +5 -0
  92. package/dist/plugins/AIChatPlugin.d.ts +6 -0
  93. package/dist/plugins/CodeHighlightPlugin.d.ts +4 -0
  94. package/dist/plugins/CustomHorizontalRulePlugin/CustomHorizontalRuleNode.d.ts +31 -0
  95. package/dist/plugins/CustomHorizontalRulePlugin/CustomHorizontalRulePlugin.d.ts +3 -0
  96. package/dist/plugins/CustomHorizontalRulePlugin/HorizontalRuleCustomizationDialog.d.ts +9 -0
  97. package/dist/plugins/CustomHorizontalRulePlugin/index.d.ts +3 -0
  98. package/dist/plugins/DragDropPastePlugin/index.d.ts +8 -0
  99. package/dist/plugins/EmbedPreviewPlugin/FloatingEmbedMenuPlugin.d.ts +4 -0
  100. package/dist/plugins/EmbedPreviewPlugin/index.d.ts +7 -0
  101. package/dist/plugins/FilePlugin.d.ts +8 -0
  102. package/dist/plugins/FloatingLinkEditorPlugin/index.d.ts +7 -0
  103. package/dist/plugins/FloatingTextFormatToolbarPlugin/index.d.ts +25 -0
  104. package/dist/plugins/HtmlCodeViewPlugin/index.d.ts +2 -0
  105. package/dist/plugins/HtmlImportPlugin.d.ts +5 -0
  106. package/dist/plugins/ImagePlugin.d.ts +10 -0
  107. package/dist/plugins/LinkPlugin/index.d.ts +7 -0
  108. package/dist/plugins/LocalStoragePlugin.d.ts +9 -0
  109. package/dist/plugins/MentionsPlugin/index.d.ts +8 -0
  110. package/dist/plugins/RichTextPastePlugin/index.d.ts +1 -0
  111. package/dist/plugins/SignatureCanvasPlugin/SignatureCanvasDialog.d.ts +7 -0
  112. package/dist/plugins/SignatureCanvasPlugin/SignatureCanvasPlugin.d.ts +3 -0
  113. package/dist/plugins/SignatureCanvasPlugin/index.d.ts +2 -0
  114. package/dist/plugins/TableActionMenuPlugin/index.d.ts +7 -0
  115. package/dist/plugins/TableCellResizer/index.d.ts +3 -0
  116. package/dist/plugins/TableHoverActionsPlugin/index.d.ts +11 -0
  117. package/dist/plugins/TablePlugin.d.ts +1 -0
  118. package/dist/plugins/TreeViewPlugin.d.ts +4 -0
  119. package/dist/postcss-bbcc713e.js +5152 -0
  120. package/dist/postcss-bbcc713e.js.map +1 -0
  121. package/dist/standalone-36ad3877.js +2601 -0
  122. package/dist/standalone-36ad3877.js.map +1 -0
  123. package/dist/styles/PlaygroundEditorTheme.d.ts +4 -0
  124. package/dist/types.d.ts +134 -0
  125. package/dist/typescript-39d06710.js +13534 -0
  126. package/dist/typescript-39d06710.js.map +1 -0
  127. package/dist/ui/ColorPicker.d.ts +14 -0
  128. package/dist/ui/Icons.d.ts +35 -0
  129. package/dist/ui/TextInput.d.ts +12 -0
  130. package/dist/utils/debounce.d.ts +7 -0
  131. package/dist/utils/getDOMRangeRect.d.ts +13 -0
  132. package/dist/utils/getSelectedNode.d.ts +4 -0
  133. package/dist/utils/helper.d.ts +3 -0
  134. package/dist/utils/index.d.ts +6 -0
  135. package/dist/utils/invarient.d.ts +1 -0
  136. package/dist/utils/setFloatingElemPosition.d.ts +8 -0
  137. package/dist/utils/setFloatingElemPositionForLinkEditor.d.ts +1 -0
  138. package/dist/utils/url.d.ts +9 -0
  139. package/package.json +2 -4
  140. package/dist/assets/babel-70ddf1b3.js +0 -16
  141. package/dist/assets/babel-70ddf1b3.js.map +0 -1
  142. package/dist/assets/chevron-down-7ab1bec2.svg +0 -1
  143. package/dist/assets/close-5a175ff6.svg +0 -1
  144. package/dist/assets/code-211c00f3.svg +0 -1
  145. package/dist/assets/copy-0a348586.svg +0 -1
  146. package/dist/assets/estree-e637acda.js +0 -37
  147. package/dist/assets/estree-e637acda.js.map +0 -1
  148. package/dist/assets/html-132cf17b.js +0 -23
  149. package/dist/assets/html-132cf17b.js.map +0 -1
  150. package/dist/assets/index-92719fbf.js +0 -2
  151. package/dist/assets/index-92719fbf.js.map +0 -1
  152. package/dist/assets/index-a2d0e228.js +0 -443
  153. package/dist/assets/index-a2d0e228.js.map +0 -1
  154. package/dist/assets/index-db471160.css +0 -1
  155. package/dist/assets/link-dabc7da5.svg +0 -1
  156. package/dist/assets/markdown-d8306e54.js +0 -64
  157. package/dist/assets/markdown-d8306e54.js.map +0 -1
  158. package/dist/assets/pencil-fill-633b2c8d.svg +0 -1
  159. package/dist/assets/plus-cc33d039.svg +0 -1
  160. package/dist/assets/postcss-25dc98df.js +0 -55
  161. package/dist/assets/postcss-25dc98df.js.map +0 -1
  162. package/dist/assets/prettier-6c905155.svg +0 -1
  163. package/dist/assets/prettier-error-0ed0d492.svg +0 -1
  164. package/dist/assets/standalone-e79c0887.js +0 -40
  165. package/dist/assets/standalone-e79c0887.js.map +0 -1
  166. package/dist/assets/success-e7e6caa5.svg +0 -1
  167. package/dist/assets/trash-e93c6b1b.svg +0 -1
  168. package/dist/assets/type-bold-1f17e5da.svg +0 -1
  169. package/dist/assets/type-capitalize-2bd9e890.svg +0 -1
  170. package/dist/assets/type-italic-f9cdcec5.svg +0 -1
  171. package/dist/assets/type-lowercase-e9b820a3.svg +0 -3
  172. package/dist/assets/type-strikethrough-ea22e2f6.svg +0 -1
  173. package/dist/assets/type-subscript-84ecc6bb.svg +0 -1
  174. package/dist/assets/type-superscript-fd5795bc.svg +0 -1
  175. package/dist/assets/type-underline-9639e1cd.svg +0 -1
  176. package/dist/assets/type-uppercase-cd9fe147.svg +0 -3
  177. package/dist/assets/typescript-c6c5f850.js +0 -21
  178. package/dist/assets/typescript-c6c5f850.js.map +0 -1
  179. package/dist/assets/user-085d4653.svg +0 -1
  180. package/dist/index.html +0 -18
@@ -0,0 +1,632 @@
1
+ import { u as q, L as F, c as ae, j as i, a as he, b as be, $ as Y, R as Ce, C as xe, d as _e, O as ye, H as ve, e as Ee, i as we } from "./index-988ead1c.js";
2
+ import { CodeNode as Me } from "@lexical/code";
3
+ import { LinkNode as Ne } from "@lexical/link";
4
+ import { useEffect as A, createContext as ce, useContext as B, useRef as $, useMemo as ue, useState as G, useCallback as I, Suspense as Se } from "react";
5
+ import { calculateZoomLevel as J, mergeRegister as De } from "@lexical/utils";
6
+ import { $getSelection as K, $isNodeSelection as k, $setSelection as Q, $isRangeSelection as Pe, SELECTION_CHANGE_COMMAND as je, COMMAND_PRIORITY_LOW as L, CLICK_COMMAND as Re, DRAGSTART_COMMAND as Oe, KEY_DELETE_COMMAND as ze, KEY_BACKSPACE_COMMAND as Le, KEY_ENTER_COMMAND as $e, KEY_ESCAPE_COMMAND as Ae, RootNode as Te, TextNode as We, LineBreakNode as Ie, ParagraphNode as ke, createCommand as He, $getNodeByKey as ee } from "lexical";
7
+ import "@emotion/styled";
8
+ import "react-dom";
9
+ import "@lexical/table";
10
+ import "axios";
11
+ import "@emotion/react";
12
+ import "emoji-picker-react";
13
+ function Ke({
14
+ defaultSelection: e
15
+ }) {
16
+ const [n] = q();
17
+ return A(() => {
18
+ n.focus(() => {
19
+ const o = document.activeElement, h = n.getRootElement();
20
+ h !== null && (o === null || !h.contains(o)) && h.focus({
21
+ preventScroll: !0
22
+ });
23
+ }, {
24
+ defaultSelection: e
25
+ });
26
+ }, [e, n]), null;
27
+ }
28
+ const Fe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
29
+ __proto__: null,
30
+ AutoFocusPlugin: Ke
31
+ }, Symbol.toStringTag, { value: "Module" }));
32
+ function Be({ defaultSelection: e }) {
33
+ const [n] = q();
34
+ return A(() => {
35
+ n.focus(() => {
36
+ const o = document.activeElement, h = n.getRootElement();
37
+ h === null || o !== null && h.contains(o) || h.focus({ preventScroll: !0 });
38
+ }, { defaultSelection: e });
39
+ }, [e, n]), null;
40
+ }
41
+ const Ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
42
+ __proto__: null,
43
+ AutoFocusPlugin: Be
44
+ }, Symbol.toStringTag, { value: "Module" })), Ge = process.env.NODE_ENV !== "production" ? Fe : Ye, Xe = Ge.AutoFocusPlugin, te = [["Cat", "rgb(125, 50, 0)"], ["Dog", "rgb(100, 0, 0)"], ["Rabbit", "rgb(150, 0, 0)"], ["Frog", "rgb(200, 0, 0)"], ["Fox", "rgb(200, 75, 0)"], ["Hedgehog", "rgb(0, 75, 0)"], ["Pigeon", "rgb(0, 125, 0)"], ["Squirrel", "rgb(75, 100, 0)"], ["Bear", "rgb(125, 100, 0)"], ["Tiger", "rgb(0, 0, 150)"], ["Leopard", "rgb(0, 0, 200)"], ["Zebra", "rgb(0, 0, 250)"], ["Wolf", "rgb(0, 100, 150)"], ["Owl", "rgb(0, 100, 100)"], ["Gull", "rgb(100, 0, 100)"], ["Squid", "rgb(150, 0, 150)"]], oe = te[Math.floor(Math.random() * te.length)], de = /* @__PURE__ */ ce({
45
+ clientID: 0,
46
+ color: oe[1],
47
+ isCollabActive: !1,
48
+ name: oe[0],
49
+ yjsDocMap: /* @__PURE__ */ new Map()
50
+ });
51
+ function Ve(e, n) {
52
+ const o = B(de);
53
+ return e != null && (o.name = e), n != null && (o.color = n), o;
54
+ }
55
+ const qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
56
+ __proto__: null,
57
+ CollaborationContext: de,
58
+ useCollaborationContext: Ve
59
+ }, Symbol.toStringTag, { value: "Module" })), ne = [["Cat", "rgb(125, 50, 0)"], ["Dog", "rgb(100, 0, 0)"], ["Rabbit", "rgb(150, 0, 0)"], ["Frog", "rgb(200, 0, 0)"], ["Fox", "rgb(200, 75, 0)"], ["Hedgehog", "rgb(0, 75, 0)"], ["Pigeon", "rgb(0, 125, 0)"], ["Squirrel", "rgb(75, 100, 0)"], ["Bear", "rgb(125, 100, 0)"], ["Tiger", "rgb(0, 0, 150)"], ["Leopard", "rgb(0, 0, 200)"], ["Zebra", "rgb(0, 0, 250)"], ["Wolf", "rgb(0, 100, 150)"], ["Owl", "rgb(0, 100, 100)"], ["Gull", "rgb(100, 0, 100)"], ["Squid", "rgb(150, 0, 150)"]], re = ne[Math.floor(Math.random() * ne.length)], ge = ce({ clientID: 0, color: re[1], isCollabActive: !1, name: re[0], yjsDocMap: /* @__PURE__ */ new Map() });
60
+ function Ue(e, n) {
61
+ const o = B(ge);
62
+ return e != null && (o.name = e), n != null && (o.color = n), o;
63
+ }
64
+ const Ze = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
65
+ __proto__: null,
66
+ CollaborationContext: ge,
67
+ useCollaborationContext: Ue
68
+ }, Symbol.toStringTag, { value: "Module" })), Je = process.env.NODE_ENV !== "production" ? qe : Ze, U = Je.useCollaborationContext;
69
+ function se(e) {
70
+ const n = e.transform();
71
+ return n !== null ? /* @__PURE__ */ new Set([n]) : /* @__PURE__ */ new Set();
72
+ }
73
+ function Qe({
74
+ initialEditor: e,
75
+ children: n,
76
+ initialNodes: o,
77
+ initialTheme: h,
78
+ skipCollabChecks: P
79
+ }) {
80
+ const v = $(!1), _ = B(F);
81
+ if (_ == null)
82
+ throw Error("Unexpected parent context null on a nested composer");
83
+ const [g, {
84
+ getTheme: M
85
+ }] = _, R = ue(
86
+ () => {
87
+ const m = h || M() || void 0, O = ae(_, m);
88
+ if (m !== void 0 && (e._config.theme = m), e._parentEditor = g, o)
89
+ for (let l of o) {
90
+ let y = null, t = null;
91
+ if (typeof l != "function") {
92
+ const C = l;
93
+ l = C.replace, y = C.with, t = C.withKlass || null;
94
+ }
95
+ const S = e._nodes.get(l.getType());
96
+ e._nodes.set(l.getType(), {
97
+ exportDOM: S ? S.exportDOM : void 0,
98
+ klass: l,
99
+ replace: y,
100
+ replaceWithKlass: t,
101
+ transforms: se(l)
102
+ });
103
+ }
104
+ else {
105
+ const l = e._nodes = new Map(g._nodes);
106
+ for (const [y, t] of l)
107
+ e._nodes.set(y, {
108
+ exportDOM: t.exportDOM,
109
+ klass: t.klass,
110
+ replace: t.replace,
111
+ replaceWithKlass: t.replaceWithKlass,
112
+ transforms: se(t.klass)
113
+ });
114
+ }
115
+ return e._config.namespace = g._config.namespace, e._editable = g._editable, [e, O];
116
+ },
117
+ // We only do this for init
118
+ // eslint-disable-next-line react-hooks/exhaustive-deps
119
+ []
120
+ ), {
121
+ isCollabActive: E,
122
+ yjsDocMap: N
123
+ } = U(), c = P || v.current || N.has(e.getKey());
124
+ return A(() => {
125
+ c && (v.current = !0);
126
+ }, [c]), A(() => g.registerEditableListener((m) => {
127
+ e.setEditable(m);
128
+ }), [e, g]), /* @__PURE__ */ i.jsx(F.Provider, {
129
+ value: R,
130
+ children: !E || c ? n : null
131
+ });
132
+ }
133
+ const et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
134
+ __proto__: null,
135
+ LexicalNestedComposer: Qe
136
+ }, Symbol.toStringTag, { value: "Module" }));
137
+ function tt(e) {
138
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
139
+ }
140
+ var ot = tt(function(e) {
141
+ const n = new URLSearchParams();
142
+ n.append("code", e);
143
+ for (let o = 1; o < arguments.length; o++)
144
+ n.append("v", arguments[o]);
145
+ throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${n} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
146
+ });
147
+ function ie(e) {
148
+ const n = e.transform();
149
+ return n !== null ? /* @__PURE__ */ new Set([n]) : /* @__PURE__ */ new Set();
150
+ }
151
+ function nt({ initialEditor: e, children: n, initialNodes: o, initialTheme: h, skipCollabChecks: P }) {
152
+ const v = $(!1), _ = B(F);
153
+ _ == null && ot(9);
154
+ const [g, { getTheme: M }] = _, R = ue(() => {
155
+ const m = h || M() || void 0, O = ae(_, m);
156
+ if (m !== void 0 && (e._config.theme = m), e._parentEditor = g, o)
157
+ for (let l of o) {
158
+ let y = null, t = null;
159
+ if (typeof l != "function") {
160
+ const C = l;
161
+ l = C.replace, y = C.with, t = C.withKlass || null;
162
+ }
163
+ const S = e._nodes.get(l.getType());
164
+ e._nodes.set(l.getType(), { exportDOM: S ? S.exportDOM : void 0, klass: l, replace: y, replaceWithKlass: t, transforms: ie(l) });
165
+ }
166
+ else {
167
+ const l = e._nodes = new Map(g._nodes);
168
+ for (const [y, t] of l)
169
+ e._nodes.set(y, { exportDOM: t.exportDOM, klass: t.klass, replace: t.replace, replaceWithKlass: t.replaceWithKlass, transforms: ie(t.klass) });
170
+ }
171
+ return e._config.namespace = g._config.namespace, e._editable = g._editable, [e, O];
172
+ }, []), { isCollabActive: E, yjsDocMap: N } = U(), c = P || v.current || N.has(e.getKey());
173
+ return A(() => {
174
+ c && (v.current = !0);
175
+ }, [c]), A(() => g.registerEditableListener((m) => {
176
+ e.setEditable(m);
177
+ }), [e, g]), i.jsx(F.Provider, { value: R, children: !E || c ? n : null });
178
+ }
179
+ const rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
180
+ __proto__: null,
181
+ LexicalNestedComposer: nt
182
+ }, Symbol.toStringTag, { value: "Module" })), st = process.env.NODE_ENV !== "production" ? et : rt, it = st.LexicalNestedComposer;
183
+ function X(e, n, o) {
184
+ return Math.min(Math.max(e, n), o);
185
+ }
186
+ const a = {
187
+ east: 1,
188
+ north: 8,
189
+ south: 2,
190
+ west: 4
191
+ };
192
+ function lt({
193
+ onResizeStart: e,
194
+ onResizeEnd: n,
195
+ buttonRef: o,
196
+ imageRef: h,
197
+ maxWidth: P,
198
+ editor: v,
199
+ showCaption: _,
200
+ setShowCaption: g,
201
+ captionsEnabled: M
202
+ }) {
203
+ const R = $(null), E = $({
204
+ priority: "",
205
+ value: "default"
206
+ }), N = $({
207
+ currentHeight: 0,
208
+ currentWidth: 0,
209
+ direction: 0,
210
+ isResizing: !1,
211
+ ratio: 0,
212
+ startHeight: 0,
213
+ startWidth: 0,
214
+ startX: 0,
215
+ startY: 0
216
+ }), c = v.getRootElement(), m = P || (c !== null ? c.getBoundingClientRect().width - 20 : 100), O = c !== null ? c.getBoundingClientRect().height - 20 : 100, l = 100, y = 100, t = (r) => {
217
+ const u = r === a.east || r === a.west, s = r === a.north || r === a.south, D = r & a.north && r & a.west || r & a.south && r & a.east, x = u ? "ew" : s ? "ns" : D ? "nwse" : "nesw";
218
+ c !== null && c.style.setProperty(
219
+ "cursor",
220
+ `${x}-resize`,
221
+ "important"
222
+ ), document.body !== null && (document.body.style.setProperty(
223
+ "cursor",
224
+ `${x}-resize`,
225
+ "important"
226
+ ), E.current.value = document.body.style.getPropertyValue(
227
+ "-webkit-user-select"
228
+ ), E.current.priority = document.body.style.getPropertyPriority(
229
+ "-webkit-user-select"
230
+ ), document.body.style.setProperty(
231
+ "-webkit-user-select",
232
+ "none",
233
+ "important"
234
+ ));
235
+ }, S = () => {
236
+ c !== null && c.style.setProperty("cursor", "text"), document.body !== null && (document.body.style.setProperty("cursor", "default"), document.body.style.setProperty(
237
+ "-webkit-user-select",
238
+ E.current.value,
239
+ E.current.priority
240
+ ));
241
+ }, C = (r, u) => {
242
+ if (!v.isEditable())
243
+ return;
244
+ const s = h.current, D = R.current;
245
+ if (s !== null && D !== null) {
246
+ r.preventDefault();
247
+ const { width: x, height: w } = s.getBoundingClientRect(), p = J(s), f = N.current;
248
+ f.startWidth = x, f.startHeight = w, f.ratio = x / w, f.currentWidth = x, f.currentHeight = w, f.startX = r.clientX / p, f.startY = r.clientY / p, f.isResizing = !0, f.direction = u, t(u), e(), D.classList.add("image-control-wrapper--resizing"), s.style.height = `${w}px`, s.style.width = `${x}px`, document.addEventListener("pointermove", T), document.addEventListener("pointerup", W);
249
+ }
250
+ }, T = (r) => {
251
+ const u = h.current, s = N.current, D = s.direction & (a.east | a.west), x = s.direction & (a.south | a.north);
252
+ if (u !== null && s.isResizing) {
253
+ const w = J(u);
254
+ if (D && x) {
255
+ let p = Math.floor(s.startX - r.clientX / w);
256
+ p = s.direction & a.east ? -p : p;
257
+ const f = X(
258
+ s.startWidth + p,
259
+ l,
260
+ m
261
+ ), H = f / s.ratio;
262
+ u.style.width = `${f}px`, u.style.height = `${H}px`, s.currentHeight = H, s.currentWidth = f;
263
+ } else if (x) {
264
+ let p = Math.floor(s.startY - r.clientY / w);
265
+ p = s.direction & a.south ? -p : p;
266
+ const f = X(
267
+ s.startHeight + p,
268
+ y,
269
+ O
270
+ );
271
+ u.style.height = `${f}px`, s.currentHeight = f;
272
+ } else {
273
+ let p = Math.floor(s.startX - r.clientX / w);
274
+ p = s.direction & a.east ? -p : p;
275
+ const f = X(
276
+ s.startWidth + p,
277
+ l,
278
+ m
279
+ );
280
+ u.style.width = `${f}px`, s.currentWidth = f;
281
+ }
282
+ }
283
+ }, W = () => {
284
+ const r = h.current, u = N.current, s = R.current;
285
+ if (r !== null && s !== null && u.isResizing) {
286
+ const D = u.currentWidth, x = u.currentHeight;
287
+ u.startWidth = 0, u.startHeight = 0, u.ratio = 0, u.startX = 0, u.startY = 0, u.currentWidth = 0, u.currentHeight = 0, u.isResizing = !1, s.classList.remove("image-control-wrapper--resizing"), S(), n(D, x), document.removeEventListener("pointermove", T), document.removeEventListener("pointerup", W);
288
+ }
289
+ };
290
+ return /* @__PURE__ */ i.jsxs("div", { ref: R, children: [
291
+ !_ && M && /* @__PURE__ */ i.jsx(
292
+ "button",
293
+ {
294
+ className: "image-caption-button",
295
+ ref: o,
296
+ onClick: () => {
297
+ g(!_);
298
+ },
299
+ children: "Add Caption"
300
+ }
301
+ ),
302
+ /* @__PURE__ */ i.jsx(
303
+ "div",
304
+ {
305
+ className: "image-resizer image-resizer-n",
306
+ onPointerDown: (r) => {
307
+ C(r, a.north);
308
+ }
309
+ }
310
+ ),
311
+ /* @__PURE__ */ i.jsx(
312
+ "div",
313
+ {
314
+ className: "image-resizer image-resizer-ne",
315
+ onPointerDown: (r) => {
316
+ C(r, a.north | a.east);
317
+ }
318
+ }
319
+ ),
320
+ /* @__PURE__ */ i.jsx(
321
+ "div",
322
+ {
323
+ className: "image-resizer image-resizer-e",
324
+ onPointerDown: (r) => {
325
+ C(r, a.east);
326
+ }
327
+ }
328
+ ),
329
+ /* @__PURE__ */ i.jsx(
330
+ "div",
331
+ {
332
+ className: "image-resizer image-resizer-se",
333
+ onPointerDown: (r) => {
334
+ C(r, a.south | a.east);
335
+ }
336
+ }
337
+ ),
338
+ /* @__PURE__ */ i.jsx(
339
+ "div",
340
+ {
341
+ className: "image-resizer image-resizer-s",
342
+ onPointerDown: (r) => {
343
+ C(r, a.south);
344
+ }
345
+ }
346
+ ),
347
+ /* @__PURE__ */ i.jsx(
348
+ "div",
349
+ {
350
+ className: "image-resizer image-resizer-sw",
351
+ onPointerDown: (r) => {
352
+ C(r, a.south | a.west);
353
+ }
354
+ }
355
+ ),
356
+ /* @__PURE__ */ i.jsx(
357
+ "div",
358
+ {
359
+ className: "image-resizer image-resizer-w",
360
+ onPointerDown: (r) => {
361
+ C(r, a.west);
362
+ }
363
+ }
364
+ ),
365
+ /* @__PURE__ */ i.jsx(
366
+ "div",
367
+ {
368
+ className: "image-resizer image-resizer-nw",
369
+ onPointerDown: (r) => {
370
+ C(r, a.north | a.west);
371
+ }
372
+ }
373
+ )
374
+ ] });
375
+ }
376
+ const V = /* @__PURE__ */ new Set(), le = He("RIGHT_CLICK_IMAGE_COMMAND");
377
+ function at(e) {
378
+ if (!V.has(e))
379
+ throw new Promise((n) => {
380
+ const o = new Image();
381
+ o.src = e, o.onload = () => {
382
+ V.add(e), n(null);
383
+ }, o.onerror = () => {
384
+ V.add(e);
385
+ };
386
+ });
387
+ }
388
+ function ct({
389
+ altText: e,
390
+ className: n,
391
+ imageRef: o,
392
+ src: h,
393
+ width: P,
394
+ height: v,
395
+ maxWidth: _,
396
+ onError: g
397
+ }) {
398
+ return at(h), /* @__PURE__ */ i.jsx(
399
+ "img",
400
+ {
401
+ className: n || void 0,
402
+ src: h,
403
+ alt: e,
404
+ ref: o,
405
+ style: {
406
+ height: v,
407
+ maxWidth: _,
408
+ width: P
409
+ },
410
+ onError: g,
411
+ draggable: "false"
412
+ }
413
+ );
414
+ }
415
+ function ut() {
416
+ return /* @__PURE__ */ i.jsx(
417
+ "img",
418
+ {
419
+ src: "",
420
+ style: {
421
+ height: 200,
422
+ opacity: 0.2,
423
+ width: 200
424
+ },
425
+ draggable: "false"
426
+ }
427
+ );
428
+ }
429
+ function Et({
430
+ src: e,
431
+ altText: n,
432
+ nodeKey: o,
433
+ width: h,
434
+ height: P,
435
+ maxWidth: v,
436
+ resizable: _,
437
+ showCaption: g,
438
+ caption: M,
439
+ captionsEnabled: R
440
+ }) {
441
+ const E = $(null), N = $(null), [c, m, O] = he(o), [l, y] = G(!1);
442
+ U();
443
+ const [t] = q(), [S, C] = G(null), T = $(null), [W, r] = G(!1), u = be(), s = I(
444
+ (b) => {
445
+ const d = K();
446
+ return c && k(d) && (b.preventDefault(), t.update(() => {
447
+ d.getNodes().forEach((z) => {
448
+ Y(z) && z.remove();
449
+ });
450
+ })), !1;
451
+ },
452
+ [t, c]
453
+ ), D = I(
454
+ (b) => {
455
+ const d = K(), j = N.current;
456
+ if (c && k(d) && d.getNodes().length === 1) {
457
+ if (g)
458
+ return Q(null), b.preventDefault(), M.focus(), !0;
459
+ if (j !== null && j !== document.activeElement)
460
+ return b.preventDefault(), j.focus(), !0;
461
+ }
462
+ return !1;
463
+ },
464
+ [M, c, g]
465
+ ), x = I(
466
+ (b) => T.current === M || N.current === b.target ? (Q(null), t.update(() => {
467
+ m(!0);
468
+ const d = t.getRootElement();
469
+ d !== null && d.focus();
470
+ }), !0) : !1,
471
+ [M, t, m]
472
+ ), w = I(
473
+ (b) => {
474
+ const d = b;
475
+ return l ? !0 : d.target === E.current ? (d.shiftKey ? m(!c) : (O(), m(!0)), !0) : !1;
476
+ },
477
+ [l, c, m, O]
478
+ ), p = I(
479
+ (b) => {
480
+ t.getEditorState().read(() => {
481
+ const d = K();
482
+ b.target.tagName === "IMG" && Pe(d) && d.getNodes().length === 1 && t.dispatchCommand(
483
+ le,
484
+ b
485
+ );
486
+ });
487
+ },
488
+ [t]
489
+ );
490
+ A(() => {
491
+ let b = !0;
492
+ const d = t.getRootElement(), j = De(
493
+ t.registerUpdateListener(({ editorState: z }) => {
494
+ b && C(z.read(() => K()));
495
+ }),
496
+ t.registerCommand(
497
+ je,
498
+ (z, fe) => (T.current = fe, !1),
499
+ L
500
+ ),
501
+ t.registerCommand(
502
+ Re,
503
+ w,
504
+ L
505
+ ),
506
+ t.registerCommand(
507
+ le,
508
+ w,
509
+ L
510
+ ),
511
+ t.registerCommand(
512
+ Oe,
513
+ (z) => z.target === E.current ? (alert("s"), z.preventDefault(), !0) : !1,
514
+ L
515
+ ),
516
+ t.registerCommand(
517
+ ze,
518
+ s,
519
+ L
520
+ ),
521
+ t.registerCommand(
522
+ Le,
523
+ s,
524
+ L
525
+ ),
526
+ t.registerCommand($e, D, L),
527
+ t.registerCommand(
528
+ Ae,
529
+ x,
530
+ L
531
+ )
532
+ );
533
+ return d == null || d.addEventListener("contextmenu", p), () => {
534
+ b = !1, j(), d == null || d.removeEventListener("contextmenu", p);
535
+ };
536
+ }, [
537
+ O,
538
+ t,
539
+ l,
540
+ c,
541
+ o,
542
+ s,
543
+ D,
544
+ x,
545
+ w,
546
+ p,
547
+ m
548
+ ]);
549
+ const f = () => {
550
+ t.update(() => {
551
+ const b = ee(o);
552
+ Y(b) && b.setShowCaption(!0);
553
+ });
554
+ }, H = (b, d) => {
555
+ setTimeout(() => {
556
+ y(!1);
557
+ }, 200), t.update(() => {
558
+ const j = ee(o);
559
+ Y(j) && j.setWidthAndHeight(b, d);
560
+ });
561
+ }, me = () => {
562
+ y(!0);
563
+ }, pe = c && k(S) && !l, Z = (c || l) && u;
564
+ return /* @__PURE__ */ i.jsx(Se, { fallback: null, children: /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
565
+ /* @__PURE__ */ i.jsx("div", { draggable: pe, children: W ? /* @__PURE__ */ i.jsx(ut, {}) : /* @__PURE__ */ i.jsx(
566
+ ct,
567
+ {
568
+ className: Z ? `focused ${k(S) ? "draggable" : ""}` : null,
569
+ src: e,
570
+ altText: n,
571
+ imageRef: E,
572
+ width: h,
573
+ height: P,
574
+ maxWidth: v,
575
+ onError: () => r(!0)
576
+ }
577
+ ) }),
578
+ g && /* @__PURE__ */ i.jsx("div", { className: "image-caption-container", children: /* @__PURE__ */ i.jsxs(
579
+ it,
580
+ {
581
+ initialEditor: M,
582
+ initialNodes: [
583
+ Te,
584
+ We,
585
+ Ie,
586
+ ke,
587
+ Ne,
588
+ Me
589
+ ],
590
+ children: [
591
+ /* @__PURE__ */ i.jsx(Xe, {}),
592
+ /* @__PURE__ */ i.jsx(
593
+ Ce,
594
+ {
595
+ contentEditable: /* @__PURE__ */ i.jsx(
596
+ xe,
597
+ {
598
+ "aria-placeholder": "Enter a caption...",
599
+ placeholder: () => /* @__PURE__ */ i.jsx("span", { children: "Enter a caption..." }),
600
+ className: "ImageNode__contentEditable"
601
+ }
602
+ ),
603
+ ErrorBoundary: _e
604
+ }
605
+ ),
606
+ /* @__PURE__ */ i.jsx(ye, { onChange: (b) => console.log("e") }),
607
+ /* @__PURE__ */ i.jsx(ve, {}),
608
+ /* @__PURE__ */ i.jsx(Ee, { namespace: we.namespace })
609
+ ]
610
+ }
611
+ ) }),
612
+ _ && k(S) && Z && /* @__PURE__ */ i.jsx(
613
+ lt,
614
+ {
615
+ showCaption: g,
616
+ setShowCaption: f,
617
+ editor: t,
618
+ buttonRef: N,
619
+ imageRef: E,
620
+ maxWidth: v,
621
+ onResizeStart: me,
622
+ onResizeEnd: H,
623
+ captionsEnabled: !W && R
624
+ }
625
+ )
626
+ ] }) });
627
+ }
628
+ export {
629
+ le as RIGHT_CLICK_IMAGE_COMMAND,
630
+ Et as default
631
+ };
632
+ //# sourceMappingURL=index-9ce51b54.js.map