ct-rich-text-editor 1.0.7 → 1.0.8

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