@collabchron/notiq 1.1.12 → 1.2.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 (146) hide show
  1. package/dist/AICommandBarPlugin-ZEC755KY.mjs +27 -0
  2. package/dist/{AIDialog-RHRYHSVN.mjs → AIDialog-HJW6PQPR.mjs} +11 -12
  3. package/dist/{AudioComponent-CKLMLB5T.mjs → AudioComponent-W5XMZPQB.mjs} +10 -6
  4. package/dist/{DynamicBlockComponent-2LOADZUX.mjs → DynamicBlockComponent-CHRL2GAQ.mjs} +7 -6
  5. package/dist/{EquationComponent-4NFG55NQ.mjs → EquationComponent-GNQHG53L.mjs} +26 -7
  6. package/dist/{ExcalidrawComponent-BMSYIPP6.mjs → ExcalidrawComponent-POMYXDSG.mjs} +33 -6
  7. package/dist/{FileComponent-Y56MX5QD.mjs → FileComponent-EOVCH4V5.mjs} +9 -5
  8. package/dist/{HintComponet-ET7M2Q7S.mjs → HintComponet-QXL5ESND.mjs} +32 -8
  9. package/dist/{InlineImageComponent-FVTA4LXZ.mjs → InlineImageComponent-KDN3VGZC.mjs} +8 -3
  10. package/dist/{StoryBuilderComponent-JN4ZPZOW.mjs → StoryBuilderComponent-CBRFPFTR.mjs} +8 -9
  11. package/dist/{chunk-6UVNHT3T.mjs → chunk-4SYRK2NH.mjs} +23 -1
  12. package/dist/chunk-5CJZC5IB.mjs +9086 -0
  13. package/dist/{chunk-FO7M3X2B.mjs → chunk-6NK5DONB.mjs} +1 -1
  14. package/dist/{chunk-N6ILV6NF.mjs → chunk-ACW4DLVO.mjs} +21 -7
  15. package/dist/chunk-BCGD2YXP.mjs +574 -0
  16. package/dist/{chunk-TC3IISJZ.mjs → chunk-BTR3TPIN.mjs} +18 -5
  17. package/dist/{chunk-ZYJ7KABY.mjs → chunk-CQCS5YPS.mjs} +3 -5
  18. package/dist/{chunk-T2UBAZ66.mjs → chunk-D4UBNSUW.mjs} +1 -1
  19. package/dist/{chunk-KNW2CGIP.mjs → chunk-DBRZIA43.mjs} +4 -1
  20. package/dist/{chunk-CDAMHK63.mjs → chunk-GJK2L7ZM.mjs} +23 -2
  21. package/dist/{chunk-ELBTVBTS.mjs → chunk-IKYVBTCJ.mjs} +43 -20
  22. package/dist/chunk-IXRA5D53.mjs +10447 -0
  23. package/dist/{chunk-W6VQSFE5.mjs → chunk-J2CEQXG4.mjs} +1 -1
  24. package/dist/{chunk-43Z4Z2KD.mjs → chunk-JTNLN4JI.mjs} +1 -1
  25. package/dist/{chunk-OE5JRLCN.mjs → chunk-ONOHG5NB.mjs} +6 -4
  26. package/dist/{chunk-QNIY45SF.mjs → chunk-OO42URWA.mjs} +27 -6
  27. package/dist/chunk-PBVRSNGU.mjs +129 -0
  28. package/dist/chunk-QCS57TIF.mjs +1794 -0
  29. package/dist/chunk-RNEIJRUS.mjs +60 -0
  30. package/dist/chunk-TJPTGECP.mjs +1556 -0
  31. package/dist/{chunk-XYMXGU4T.mjs → chunk-TMYRA2W4.mjs} +1 -1
  32. package/dist/{chunk-ZFV2HGD3.mjs → chunk-UNEFOZTS.mjs} +1 -1
  33. package/dist/chunk-X4NI7EQS.mjs +282 -0
  34. package/dist/{chunk-5D4JF3ZZ.mjs → chunk-XAJ4GACN.mjs} +171 -49
  35. package/dist/{chunk-7QRJVZQY.mjs → chunk-YVUQRJVV.mjs} +63 -18
  36. package/dist/components/editor/index.d.ts +1 -1
  37. package/dist/components/editor/nodes/EquationNode/EquationNode.d.ts +1 -0
  38. package/dist/components/editor/nodes/Hint/index.d.ts +2 -1
  39. package/dist/components/editor/plugins/AICommandBarPlugin/index.d.ts +73 -1
  40. package/dist/components/editor/plugins/DraggableBlockPlugin/index.d.ts +25 -3
  41. package/dist/components/editor/plugins/InlineCopilotPlugin/index.d.ts +16 -3
  42. package/dist/components/editor/plugins/LinkWithMetaData/index.d.ts +20 -25
  43. package/dist/components/editor/plugins/MarkdownPastePlugin/index.d.ts +5 -0
  44. package/dist/components/editor/plugins/MarkdownTransformers/index.d.ts +2 -0
  45. package/dist/components/editor/plugins/SlashCommand/index.d.ts +18 -1
  46. package/dist/components/editor/plugins/SmartTypographyPlugin/index.d.ts +26 -0
  47. package/dist/components/editor/utils/aiStream.d.ts +27 -0
  48. package/dist/components/editor/utils/excalidrawDiagramBuilder.d.ts +29 -0
  49. package/dist/components/editor/utils/markdownTransformers.d.ts +4 -1
  50. package/dist/components/editor/utils/url.d.ts +16 -4
  51. package/dist/components/providers/AIContext.d.ts +8 -0
  52. package/dist/components/ui/equation/equationTypography.d.ts +23 -0
  53. package/dist/core/extension.d.ts +3 -1
  54. package/dist/core/extensions/blocks-kit.d.ts +22 -1
  55. package/dist/core/extensions/copilot-and-collab.d.ts +15 -1
  56. package/dist/core/react/NotiqContent.d.ts +4 -1
  57. package/dist/core/react/index.d.ts +1 -0
  58. package/dist/core/react/node-renderers.d.ts +73 -0
  59. package/dist/core.js +15429 -13116
  60. package/dist/core.mjs +47 -39
  61. package/dist/hooks/instructions-messages.d.ts +13 -4
  62. package/dist/{image-QPB2CVXP.mjs → image-AL6PHM2A.mjs} +17 -12
  63. package/dist/index.js +15526 -13194
  64. package/dist/index.mjs +64 -60
  65. package/dist/{insert-audio-I3PD6JFS.mjs → insert-audio-CRWR7EO5.mjs} +4 -6
  66. package/dist/{insert-file-PHR7XL4V.mjs → insert-file-I73AZW3L.mjs} +4 -6
  67. package/dist/{insert-gif-R5ZO4JHC.mjs → insert-gif-KWRC3ACT.mjs} +1 -1
  68. package/dist/{insert-image-PLBZELHK.mjs → insert-image-XIY6BGW5.mjs} +4 -3
  69. package/dist/{insert-poll-6BCIFY5G.mjs → insert-poll-J5YVZNZ4.mjs} +4 -3
  70. package/dist/{insert-table-ZRJP6X52.mjs → insert-table-OIMJRFFK.mjs} +1 -1
  71. package/dist/{poll-component-VHMM5KKZ.mjs → poll-component-TVHXIKGQ.mjs} +3 -2
  72. package/dist/react.js +14747 -12554
  73. package/dist/react.mjs +40 -38
  74. package/dist/{stepper-KNITDVLG.mjs → stepper-ILF7YXTO.mjs} +63 -73
  75. package/dist/styles/notiq.css +1 -1
  76. package/package.json +2 -2
  77. package/src/styles/notiq.css +20 -0
  78. package/dist/AICommandBarPlugin-TADJ3X2Y.mjs +0 -12
  79. package/dist/CodeActionMenuPlugin-FGH6HZLL.mjs +0 -14
  80. package/dist/CollaborationPlugin-TIZOQBUT.mjs +0 -405
  81. package/dist/CollaboratorsBar-AMPIAUOY.mjs +0 -20
  82. package/dist/CommentsPlugin-SDJJTUGK.mjs +0 -19
  83. package/dist/ExcalidrawPlugin-QLPGJPSX.mjs +0 -14
  84. package/dist/ExportPlugin-MJHYKQZJ.mjs +0 -43
  85. package/dist/FloatingLinkEditorPlugin-MABB34L7.mjs +0 -12
  86. package/dist/FloatingTextFormatToolbarPlugin-BXCPN3KD.mjs +0 -45
  87. package/dist/InlineCopilotPlugin-PNS5Y6OO.mjs +0 -360
  88. package/dist/MobileToolbar-KV5DX4ED.mjs +0 -982
  89. package/dist/SlashCommand-SPR7G5EI.mjs +0 -39
  90. package/dist/TableCellActionMenuPlugin-YWBA64J7.mjs +0 -838
  91. package/dist/TableHoverActionsPlugin-2EIXHEXN.mjs +0 -265
  92. package/dist/TemplatePlugin-HNTPEXBB.mjs +0 -9
  93. package/dist/ToolbarPlugin-F52PVNXU.mjs +0 -823
  94. package/dist/VersionHistoryPlugin-YWGCREKA.mjs +0 -371
  95. package/dist/background-color-RW5JYLMG.mjs +0 -425
  96. package/dist/block-format-TODFREE2.mjs +0 -14
  97. package/dist/chunk-22ZIL6NH.mjs +0 -88
  98. package/dist/chunk-2LNT36RL.mjs +0 -555
  99. package/dist/chunk-37LC44W3.mjs +0 -2677
  100. package/dist/chunk-3IILA3IP.mjs +0 -28
  101. package/dist/chunk-4DVIYZVB.mjs +0 -193
  102. package/dist/chunk-4FFTOZGJ.mjs +0 -103
  103. package/dist/chunk-4UMUPCDK.mjs +0 -68
  104. package/dist/chunk-6D6QLRYR.mjs +0 -238
  105. package/dist/chunk-6FQFPPLG.mjs +0 -785
  106. package/dist/chunk-ACV47ZKE.mjs +0 -201
  107. package/dist/chunk-BGV62GC2.mjs +0 -26
  108. package/dist/chunk-C4JWLBYN.mjs +0 -132
  109. package/dist/chunk-CLRSETYQ.mjs +0 -431
  110. package/dist/chunk-D3IOUQFR.mjs +0 -441
  111. package/dist/chunk-EEBA6OAH.mjs +0 -59
  112. package/dist/chunk-EIZMKFHF.mjs +0 -32
  113. package/dist/chunk-ENH2IOHI.mjs +0 -1828
  114. package/dist/chunk-EVPWKNE4.mjs +0 -27
  115. package/dist/chunk-HOZ4QRFV.mjs +0 -536
  116. package/dist/chunk-IAFCQV3Z.mjs +0 -349
  117. package/dist/chunk-J6ZUY5BY.mjs +0 -202
  118. package/dist/chunk-K5OAFEVY.mjs +0 -191
  119. package/dist/chunk-KXRLARGI.mjs +0 -26
  120. package/dist/chunk-LBGM4VVZ.mjs +0 -409
  121. package/dist/chunk-LLGVCM7M.mjs +0 -809
  122. package/dist/chunk-LU2XWLOE.mjs +0 -219
  123. package/dist/chunk-LVRJM45C.mjs +0 -171
  124. package/dist/chunk-MSAO3YFB.mjs +0 -144
  125. package/dist/chunk-N3KDPSRI.mjs +0 -496
  126. package/dist/chunk-OXWTZV3U.mjs +0 -174
  127. package/dist/chunk-PD5K4AGP.mjs +0 -64
  128. package/dist/chunk-PFH63ZU4.mjs +0 -33
  129. package/dist/chunk-R7WFRENU.mjs +0 -262
  130. package/dist/chunk-RAVYEEIC.mjs +0 -36
  131. package/dist/chunk-RJQTA6HG.mjs +0 -358
  132. package/dist/chunk-SAOJHVPE.mjs +0 -153
  133. package/dist/chunk-SYUCM5G5.mjs +0 -111
  134. package/dist/chunk-VGAX6YEY.mjs +0 -399
  135. package/dist/chunk-VNDDDXGH.mjs +0 -682
  136. package/dist/chunk-WUVIQCX7.mjs +0 -944
  137. package/dist/chunk-XNJNT6PC.mjs +0 -1701
  138. package/dist/chunk-XYLTLGY5.mjs +0 -775
  139. package/dist/chunk-ZKZ7MLSS.mjs +0 -165
  140. package/dist/color-S55XFDYQ.mjs +0 -13
  141. package/dist/font-IJKFR4BM.mjs +0 -12
  142. package/dist/font-size-3HMJHKO2.mjs +0 -15
  143. package/dist/insert-node-DGCZBGKG.mjs +0 -243
  144. package/dist/table-dropdown-4VCRSQB6.mjs +0 -391
  145. package/dist/text-align-TEB4S52S.mjs +0 -121
  146. package/dist/text-format-T3IY7FBI.mjs +0 -15
@@ -1,2677 +0,0 @@
1
- import {
2
- VersionHistoryProvider
3
- } from "./chunk-J6ZUY5BY.mjs";
4
- import {
5
- SpeechToTextPlugin_default
6
- } from "./chunk-ZKZ7MLSS.mjs";
7
- import {
8
- CodeHighlightPlugin,
9
- LexicalAutoLinkPlugin,
10
- LinkWithMetaDataPlugin,
11
- nodes_default
12
- } from "./chunk-LBGM4VVZ.mjs";
13
- import {
14
- OPEN_AI_COMMAND_BAR_COMMAND
15
- } from "./chunk-HOZ4QRFV.mjs";
16
- import {
17
- DynamicBlockPlugin,
18
- EquationsPlugin,
19
- InlineImagePlugin,
20
- StoryBuilderPlugin
21
- } from "./chunk-2LNT36RL.mjs";
22
- import {
23
- PollPlugin
24
- } from "./chunk-W6VQSFE5.mjs";
25
- import {
26
- CollapsiblePlugin
27
- } from "./chunk-ACV47ZKE.mjs";
28
- import {
29
- $createLayoutContainerNode,
30
- $createLayoutItemNode,
31
- AutoEmbedPlugin,
32
- FigmaPlugin,
33
- LayoutPlugin,
34
- TwitterPlugin,
35
- YouTubePlugin
36
- } from "./chunk-XYLTLGY5.mjs";
37
- import {
38
- AIProvider
39
- } from "./chunk-BGV62GC2.mjs";
40
- import {
41
- CAN_USE_DOM,
42
- isCapitalize,
43
- isCenterAlign,
44
- isClearFormatting,
45
- isDecreaseFontSize,
46
- isFormatBulletList,
47
- isFormatCheckList,
48
- isFormatCode,
49
- isFormatHeading,
50
- isFormatNumberedList,
51
- isFormatParagraph,
52
- isFormatQuote,
53
- isIncreaseFontSize,
54
- isIndent,
55
- isInsertCodeBlock,
56
- isInsertLink,
57
- isJustifyAlign,
58
- isLeftAlign,
59
- isLowercase,
60
- isOutdent,
61
- isRightAlign,
62
- isStrikeThrough,
63
- isSubscript,
64
- isSuperscript,
65
- isUppercase
66
- } from "./chunk-K5OAFEVY.mjs";
67
- import {
68
- detectContentFormat,
69
- importContentToEditor
70
- } from "./chunk-LVRJM45C.mjs";
71
- import {
72
- UploadProvider
73
- } from "./chunk-N3WTT2U6.mjs";
74
- import {
75
- INSERT_IMAGE_COMMAND,
76
- ImagesPlugin
77
- } from "./chunk-FO7M3X2B.mjs";
78
- import {
79
- NOTIQ_TRANSFORMERS,
80
- StepperPlugin
81
- } from "./chunk-LLGVCM7M.mjs";
82
- import {
83
- $createAudioNode,
84
- AudioNode,
85
- INSERT_AUDIO_COMMAND
86
- } from "./chunk-XYMXGU4T.mjs";
87
- import {
88
- $createFileNode,
89
- FileNode,
90
- INSERT_FILE_COMMAND
91
- } from "./chunk-ZFV2HGD3.mjs";
92
- import {
93
- clearFormatting,
94
- formatBulletList,
95
- formatCheckList,
96
- formatCode,
97
- formatHeading,
98
- formatNumberedList,
99
- formatParagraph,
100
- formatQuote,
101
- updateFontSize
102
- } from "./chunk-6D6QLRYR.mjs";
103
- import {
104
- ToolbarContext,
105
- useToolbarState
106
- } from "./chunk-4FFTOZGJ.mjs";
107
- import {
108
- DropdownMenu,
109
- DropdownMenuContent,
110
- DropdownMenuItem,
111
- DropdownMenuSeparator,
112
- DropdownMenuSub,
113
- DropdownMenuSubContent,
114
- DropdownMenuSubTrigger,
115
- DropdownMenuTrigger
116
- } from "./chunk-OXWTZV3U.mjs";
117
- import {
118
- CommentsProvider
119
- } from "./chunk-R7WFRENU.mjs";
120
- import {
121
- CollabProvider,
122
- useCollab
123
- } from "./chunk-RJQTA6HG.mjs";
124
- import {
125
- SharedHistoryContext,
126
- useSharedHistoryContext
127
- } from "./chunk-EVPWKNE4.mjs";
128
- import {
129
- sanitizeUrl
130
- } from "./chunk-RAVYEEIC.mjs";
131
- import {
132
- HintPlugin
133
- } from "./chunk-7QRJVZQY.mjs";
134
- import {
135
- cn
136
- } from "./chunk-JHXDLYEV.mjs";
137
- import {
138
- __spreadProps,
139
- __spreadValues,
140
- init_react_shim
141
- } from "./chunk-WYCFGRFJ.mjs";
142
-
143
- // src/core/react/index.ts
144
- init_react_shim();
145
-
146
- // src/core/react/context.tsx
147
- init_react_shim();
148
- import { createContext, useContext, useMemo } from "react";
149
- import {
150
- createLexicalComposerContext,
151
- LexicalComposerContext
152
- } from "@lexical/react/LexicalComposerContext";
153
-
154
- // src/components/editor/themes/editor-theme.ts
155
- init_react_shim();
156
- var theme = {
157
- code: `
158
- bg-slate-50 dark:bg-[#0c1017] text-slate-900 dark:text-slate-100 border border-slate-200 dark:border-slate-800/80
159
- rounded-xl my-4 text-[13px] font-mono leading-[1.65]
160
- overflow-x-auto relative group shadow-sm block line-code not-prose
161
- `,
162
- codeHighlight: {
163
- atrule: "PlaygroundEditorTheme__tokenAttr",
164
- attr: "PlaygroundEditorTheme__tokenAttr",
165
- boolean: "PlaygroundEditorTheme__tokenProperty",
166
- builtin: "PlaygroundEditorTheme__tokenSelector",
167
- cdata: "PlaygroundEditorTheme__tokenComment",
168
- char: "PlaygroundEditorTheme__tokenSelector",
169
- class: "PlaygroundEditorTheme__tokenFunction",
170
- "class-name": "PlaygroundEditorTheme__tokenFunction",
171
- comment: "PlaygroundEditorTheme__tokenComment",
172
- constant: "PlaygroundEditorTheme__tokenProperty",
173
- deleted: "PlaygroundEditorTheme__tokenProperty",
174
- doctype: "PlaygroundEditorTheme__tokenComment",
175
- entity: "PlaygroundEditorTheme__tokenOperator",
176
- function: "PlaygroundEditorTheme__tokenFunction",
177
- important: "PlaygroundEditorTheme__tokenVariable",
178
- inserted: "PlaygroundEditorTheme__tokenSelector",
179
- keyword: "PlaygroundEditorTheme__tokenAttr",
180
- namespace: "PlaygroundEditorTheme__tokenVariable",
181
- number: "PlaygroundEditorTheme__tokenProperty",
182
- operator: "PlaygroundEditorTheme__tokenOperator",
183
- prolog: "PlaygroundEditorTheme__tokenComment",
184
- property: "PlaygroundEditorTheme__tokenProperty",
185
- punctuation: "PlaygroundEditorTheme__tokenPunctuation",
186
- regex: "PlaygroundEditorTheme__tokenVariable",
187
- selector: "PlaygroundEditorTheme__tokenSelector",
188
- string: "PlaygroundEditorTheme__tokenSelector",
189
- symbol: "PlaygroundEditorTheme__tokenProperty",
190
- tag: "PlaygroundEditorTheme__tokenProperty",
191
- url: "PlaygroundEditorTheme__tokenOperator",
192
- variable: "PlaygroundEditorTheme__tokenVariable"
193
- },
194
- embedBlock: {
195
- base: "PlaygroundEditorTheme__embedBlock",
196
- focus: "PlaygroundEditorTheme__embedBlockFocus"
197
- },
198
- list: {
199
- checklist: "PlaygroundEditorTheme__checklist",
200
- listitem: "PlaygroundEditorTheme__listItem",
201
- listitemChecked: "PlaygroundEditorTheme__listItemChecked",
202
- listitemUnchecked: "PlaygroundEditorTheme__listItemUnchecked",
203
- nested: {
204
- listitem: "PlaygroundEditorTheme__nestedListItem"
205
- },
206
- olDepth: [
207
- "PlaygroundEditorTheme__ol1 ",
208
- "PlaygroundEditorTheme__ol2",
209
- "PlaygroundEditorTheme__ol3",
210
- "PlaygroundEditorTheme__ol4",
211
- "PlaygroundEditorTheme__ol5"
212
- ],
213
- ulDepth: [
214
- "PlaygroundEditorTheme__ul1",
215
- "PlaygroundEditorTheme__ul2",
216
- "PlaygroundEditorTheme__ul3",
217
- "PlaygroundEditorTheme__ul4",
218
- "PlaygroundEditorTheme__ul5"
219
- ],
220
- ul: "ul",
221
- ol: "ol"
222
- },
223
- paragraph: "leading-7 mb-3",
224
- link: `underline cursor-pointer text-blue-600 after:content-['_\u2197']`,
225
- hr: "w-full my-6 border-t border-border",
226
- table: "PlaygroundEditorTheme__table not-prose",
227
- tableCell: "PlaygroundEditorTheme__tableCell",
228
- tableCellActionButton: "PlaygroundEditorTheme__tableCellActionButton",
229
- tableCellActionButtonContainer: "PlaygroundEditorTheme__tableCellActionButtonContainer",
230
- tableCellHeader: "PlaygroundEditorTheme__tableCellHeader",
231
- tableCellResizer: "PlaygroundEditorTheme__tableCellResizer",
232
- tableCellSelected: "PlaygroundEditorTheme__tableCellSelected",
233
- tableRowStriping: "PlaygroundEditorTheme__tableRowStriping",
234
- tableScrollableWrapper: "PlaygroundEditorTheme__tableScrollableWrapper",
235
- tableSelected: "PlaygroundEditorTheme__tableSelected",
236
- tableSelection: "PlaygroundEditorTheme__tableSelection",
237
- layoutContainer: "grid gap-[10px] my-[10px] ",
238
- layoutItem: "px-2 py-[16px] border dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-50 border border-zinc-200 bg-white/90 shadow-md rounded-sm",
239
- heading: {
240
- h1: "scroll-m-20 text-3xl sm:text-4xl font-extrabold tracking-tight mt-6 mb-3 text-foreground",
241
- h2: "scroll-m-20 border-b border-border/50 pb-2 text-2xl font-bold tracking-tight mt-6 mb-3 text-foreground first:mt-0",
242
- h3: "scroll-m-20 text-xl font-semibold tracking-tight mt-5 mb-2 text-foreground",
243
- h4: "scroll-m-20 text-xl font-semibold tracking-tight",
244
- h5: "text-lg font-bold",
245
- h6: "text-sm font-bold"
246
- },
247
- quote: "my-4 border-l-4 border-purple-500 pl-4 py-1.5 italic bg-purple-500/5 text-muted-foreground rounded-r",
248
- text: {
249
- bold: "font-bold",
250
- capitalize: "capitalize",
251
- code: "inline-block font-mono text-[0.875em] font-medium px-1.5 py-0.5 rounded-md bg-slate-100 dark:bg-zinc-800 text-pink-600 dark:text-pink-400 border border-slate-200/80 dark:border-zinc-700/60 align-baseline",
252
- italic: "italic ",
253
- lowercase: "lowercase",
254
- strikethrough: "line-through",
255
- underline: "underline",
256
- underlineStrikethrough: "underline line-through",
257
- uppercase: "uppercase"
258
- }
259
- };
260
- var editor_theme_default = theme;
261
-
262
- // src/core/react/context.tsx
263
- import { Fragment, jsx } from "react/jsx-runtime";
264
- var NotiqContext = createContext({
265
- editor: null
266
- });
267
- function useNotiqContext() {
268
- const context = useContext(NotiqContext);
269
- if (!context || !context.editor) {
270
- throw new Error(
271
- "[Notiq]: useNotiqContext must be used within a <NotiqProvider /> with a valid editor instance."
272
- );
273
- }
274
- return { editor: context.editor };
275
- }
276
- function NotiqProvider({
277
- editor,
278
- theme: customTheme,
279
- children
280
- }) {
281
- const activeTheme = customTheme || editor_theme_default;
282
- const lexicalContext = useMemo(() => {
283
- return createLexicalComposerContext(null, activeTheme);
284
- }, [activeTheme]);
285
- const value = useMemo(() => ({ editor }), [editor]);
286
- if (!editor) {
287
- return /* @__PURE__ */ jsx(Fragment, { children });
288
- }
289
- return /* @__PURE__ */ jsx(LexicalComposerContext.Provider, { value: [editor.lexical, lexicalContext], children: /* @__PURE__ */ jsx(NotiqContext.Provider, { value, children }) });
290
- }
291
-
292
- // src/core/react/useNotiq.ts
293
- init_react_shim();
294
- import { useEffect, useState, useRef } from "react";
295
-
296
- // src/core/editor.ts
297
- init_react_shim();
298
- import {
299
- createEditor as createLexicalEditor,
300
- $getRoot,
301
- $getSelection,
302
- $createParagraphNode,
303
- $isRangeSelection,
304
- $isElementNode
305
- } from "lexical";
306
- import { $generateHtmlFromNodes } from "@lexical/html";
307
- import { $convertToMarkdownString } from "@lexical/markdown";
308
-
309
- // src/core/chain.ts
310
- init_react_shim();
311
- function createCommandChain(editor, lexical, commands, isDryRun = false) {
312
- const queue = [];
313
- const handler = {
314
- get(_target, prop) {
315
- if (prop === "run") {
316
- return () => {
317
- if (isDryRun) {
318
- return queue.every((fn) => {
319
- try {
320
- return fn();
321
- } catch (e) {
322
- return false;
323
- }
324
- });
325
- }
326
- let allSuccessful = true;
327
- lexical.update(
328
- () => {
329
- for (const fn of queue) {
330
- try {
331
- const res = fn();
332
- if (res === false) {
333
- allSuccessful = false;
334
- }
335
- } catch (err) {
336
- console.error("[Notiq Chain Error]:", err);
337
- allSuccessful = false;
338
- }
339
- }
340
- },
341
- { discrete: true }
342
- );
343
- return allSuccessful;
344
- };
345
- }
346
- if (prop in commands) {
347
- return (...args) => {
348
- const commandFactory = commands[prop];
349
- queue.push(() => {
350
- const runner = commandFactory(...args);
351
- return runner({ editor, lexical });
352
- });
353
- return proxy;
354
- };
355
- }
356
- if (prop === "focus") {
357
- return (position) => {
358
- queue.push(() => {
359
- editor.focus(position);
360
- return true;
361
- });
362
- return proxy;
363
- };
364
- }
365
- if (prop === "blur") {
366
- return () => {
367
- queue.push(() => {
368
- editor.blur();
369
- return true;
370
- });
371
- return proxy;
372
- };
373
- }
374
- return () => proxy;
375
- }
376
- };
377
- const proxy = new Proxy({}, handler);
378
- return proxy;
379
- }
380
- function createCanCommands(editor, lexical, commands) {
381
- const handler = {
382
- get(_target, prop) {
383
- if (prop in commands) {
384
- return (...args) => {
385
- try {
386
- const runner = commands[prop](...args);
387
- return runner({ editor, lexical });
388
- } catch (e) {
389
- return false;
390
- }
391
- };
392
- }
393
- return () => true;
394
- }
395
- };
396
- return new Proxy({}, handler);
397
- }
398
-
399
- // src/core/extension.ts
400
- init_react_shim();
401
- var Extension = class _Extension {
402
- constructor(config, options) {
403
- this.subExtensions = [];
404
- this.name = config.name;
405
- this.config = config;
406
- this.options = __spreadValues(__spreadValues({}, config.defaultOptions || {}), options || {});
407
- this.storage = __spreadValues({}, config.defaultStorage || {});
408
- }
409
- static create(config) {
410
- const ext = new _Extension(config);
411
- if (config.addExtensions) {
412
- ext.subExtensions = config.addExtensions();
413
- }
414
- return ext;
415
- }
416
- configure(options) {
417
- const nextExt = new _Extension(this.config, __spreadValues(__spreadValues({}, this.options), options));
418
- nextExt.subExtensions = this.subExtensions.map((sub) => sub.configure());
419
- return nextExt;
420
- }
421
- extend(extendedConfig) {
422
- const mergedConfig = __spreadProps(__spreadValues(__spreadValues({}, this.config), extendedConfig), {
423
- name: extendedConfig.name || this.name,
424
- defaultOptions: __spreadValues(__spreadValues({}, this.config.defaultOptions || {}), extendedConfig.defaultOptions || {}),
425
- defaultStorage: __spreadValues(__spreadValues({}, this.config.defaultStorage || {}), extendedConfig.defaultStorage || {})
426
- });
427
- return new _Extension(mergedConfig);
428
- }
429
- getNodes(context) {
430
- const directNodes = this.config.nodes ? this.config.nodes(context) : [];
431
- const subNodes = this.subExtensions.flatMap(
432
- (sub) => sub.getNodes(__spreadProps(__spreadValues({}, context), { options: sub.options, storage: sub.storage }))
433
- );
434
- return [...directNodes, ...subNodes];
435
- }
436
- getPlugins(context) {
437
- const directPlugins = this.config.plugins ? this.config.plugins(context) : [];
438
- const subPlugins = this.subExtensions.flatMap(
439
- (sub) => sub.getPlugins(__spreadProps(__spreadValues({}, context), { options: sub.options, storage: sub.storage }))
440
- );
441
- return [...directPlugins, ...subPlugins];
442
- }
443
- getCommands(context) {
444
- let commands = this.config.addCommands ? this.config.addCommands(context) : {};
445
- for (const sub of this.subExtensions) {
446
- commands = __spreadValues(__spreadValues({}, commands), sub.getCommands(__spreadProps(__spreadValues({}, context), { options: sub.options, storage: sub.storage })));
447
- }
448
- return commands;
449
- }
450
- getKeyboardShortcuts(context) {
451
- let shortcuts = this.config.addKeyboardShortcuts ? this.config.addKeyboardShortcuts(context) : {};
452
- for (const sub of this.subExtensions) {
453
- shortcuts = __spreadValues(__spreadValues({}, shortcuts), sub.getKeyboardShortcuts(__spreadProps(__spreadValues({}, context), {
454
- options: sub.options,
455
- storage: sub.storage
456
- })));
457
- }
458
- return shortcuts;
459
- }
460
- };
461
-
462
- // src/core/editor.ts
463
- import { $isHeadingNode, registerRichText } from "@lexical/rich-text";
464
- import { $isListNode } from "@lexical/list";
465
- import { $isCodeNode } from "@lexical/code";
466
- var NotiqEditorImpl = class {
467
- constructor(options = {}, customLexical) {
468
- this.storage = {};
469
- this.commands = {};
470
- this.listeners = /* @__PURE__ */ new Map();
471
- this.unregisterListeners = [];
472
- this.rawCommands = {};
473
- this._isFocused = false;
474
- this.handleFocus = () => {
475
- this._isFocused = true;
476
- this.emit("focus");
477
- if (this.options.onFocus) {
478
- this.options.onFocus({ editor: this });
479
- }
480
- };
481
- this.handleBlur = () => {
482
- this._isFocused = false;
483
- this.emit("blur");
484
- if (this.options.onBlur) {
485
- this.options.onBlur({ editor: this });
486
- }
487
- };
488
- this.options = __spreadValues({
489
- editable: true,
490
- autofocus: false
491
- }, options);
492
- const extensions = (options.extensions || []).map(
493
- (ext) => ext instanceof Extension ? ext : Extension.create(ext)
494
- );
495
- this.extensions = extensions;
496
- const allNodes = [];
497
- for (const ext of extensions) {
498
- this.storage[ext.name] = ext.storage;
499
- const nodes = ext.getNodes({
500
- editor: this,
501
- lexical: null,
502
- options: ext.options,
503
- storage: ext.storage
504
- });
505
- allNodes.push(...nodes);
506
- }
507
- if (customLexical) {
508
- this.lexical = customLexical;
509
- } else {
510
- this.lexical = createLexicalEditor({
511
- nodes: allNodes,
512
- theme: this.options.theme || editor_theme_default,
513
- editable: this.options.editable,
514
- onError: (err) => console.error("[Notiq Editor Core Error]:", err)
515
- });
516
- }
517
- try {
518
- this.unregisterListeners.push(registerRichText(this.lexical));
519
- } catch (e) {
520
- }
521
- this.lexical.update(
522
- () => {
523
- const root = $getRoot();
524
- if (root.isEmpty()) {
525
- root.append($createParagraphNode());
526
- }
527
- },
528
- { discrete: true }
529
- );
530
- for (const ext of extensions) {
531
- const extCommands = ext.getCommands({
532
- editor: this,
533
- lexical: this.lexical,
534
- options: ext.options,
535
- storage: ext.storage
536
- });
537
- for (const [name, fn] of Object.entries(extCommands)) {
538
- this.rawCommands[name] = fn;
539
- this.commands[name] = (...args) => {
540
- let success = false;
541
- this.lexical.update(
542
- () => {
543
- success = fn(...args)({ editor: this, lexical: this.lexical });
544
- },
545
- { discrete: true }
546
- );
547
- return success;
548
- };
549
- }
550
- }
551
- this.setupListeners();
552
- if (this.options.content) {
553
- this.setContent(this.options.content, { discrete: true, emitUpdate: false });
554
- }
555
- if (this.options.autofocus) {
556
- setTimeout(() => {
557
- this.focus(this.options.autofocus);
558
- }, 0);
559
- }
560
- for (const ext of extensions) {
561
- if (ext.config.onCreate) {
562
- ext.config.onCreate({
563
- editor: this,
564
- lexical: this.lexical,
565
- options: ext.options,
566
- storage: ext.storage
567
- });
568
- }
569
- }
570
- }
571
- get isEditable() {
572
- return this.lexical.isEditable();
573
- }
574
- get isFocused() {
575
- return this._isFocused;
576
- }
577
- setupListeners() {
578
- const unregisterUpdate = this.lexical.registerUpdateListener(
579
- ({ editorState, dirtyElements, dirtyLeaves }) => {
580
- this.emit("transaction");
581
- if (dirtyElements.size > 0 || dirtyLeaves.size > 0) {
582
- this.emit("update");
583
- if (this.options.onUpdate) {
584
- this.options.onUpdate({ editor: this });
585
- }
586
- }
587
- }
588
- );
589
- const unregisterRoot = this.lexical.registerRootListener(
590
- (rootElement, prevRootElement) => {
591
- if (prevRootElement) {
592
- prevRootElement.removeEventListener("focus", this.handleFocus);
593
- prevRootElement.removeEventListener("blur", this.handleBlur);
594
- }
595
- if (rootElement) {
596
- rootElement.addEventListener("focus", this.handleFocus);
597
- rootElement.addEventListener("blur", this.handleBlur);
598
- }
599
- }
600
- );
601
- this.unregisterListeners.push(unregisterUpdate, unregisterRoot);
602
- }
603
- chain() {
604
- return createCommandChain(this, this.lexical, this.rawCommands);
605
- }
606
- can() {
607
- return createCanCommands(this, this.lexical, this.rawCommands);
608
- }
609
- isActive(name, attributes) {
610
- let active = false;
611
- this.lexical.getEditorState().read(() => {
612
- const selection = $getSelection();
613
- if (!$isRangeSelection(selection)) {
614
- return;
615
- }
616
- const textFormats = [
617
- "bold",
618
- "italic",
619
- "underline",
620
- "strikethrough",
621
- "code",
622
- "subscript",
623
- "superscript",
624
- "highlight"
625
- ];
626
- if (textFormats.includes(name)) {
627
- active = selection.hasFormat(name);
628
- return;
629
- }
630
- const anchorNode = selection.anchor.getNode();
631
- const element = anchorNode.getKey() === "root" ? anchorNode : $isElementNode(anchorNode) ? anchorNode : anchorNode.getTopLevelElementOrThrow();
632
- if (name === "heading" && $isHeadingNode(element)) {
633
- if (attributes && attributes.level) {
634
- active = element.getTag() === `h${attributes.level}`;
635
- } else {
636
- active = true;
637
- }
638
- return;
639
- }
640
- if (name === "codeBlock" && $isCodeNode(element)) {
641
- if (attributes && attributes.language) {
642
- active = element.getLanguage() === attributes.language;
643
- } else {
644
- active = true;
645
- }
646
- return;
647
- }
648
- if (name === "bulletList" && $isListNode(element)) {
649
- active = element.getListType() === "bullet";
650
- return;
651
- }
652
- if (name === "orderedList" && $isListNode(element)) {
653
- active = element.getListType() === "number";
654
- return;
655
- }
656
- if (name === "checkList" && $isListNode(element)) {
657
- active = element.getListType() === "check";
658
- return;
659
- }
660
- if (name === "paragraph" && element.getType() === "paragraph") {
661
- active = true;
662
- return;
663
- }
664
- if (name === "quote" && element.getType() === "quote") {
665
- active = true;
666
- return;
667
- }
668
- });
669
- return active;
670
- }
671
- setEditable(editable) {
672
- this.lexical.setEditable(editable);
673
- }
674
- focus(position = true) {
675
- this.lexical.update(() => {
676
- const root = $getRoot();
677
- if (root.isEmpty()) {
678
- root.append($createParagraphNode());
679
- }
680
- const firstChild = root.getFirstChild();
681
- const lastChild = root.getLastChild();
682
- if (position === "start" && firstChild) {
683
- firstChild.selectStart();
684
- } else if (position === "all") {
685
- root.select(0, root.getChildrenSize());
686
- } else if (lastChild) {
687
- lastChild.selectEnd();
688
- } else {
689
- root.select(0, 0);
690
- }
691
- });
692
- const rootElement = this.lexical.getRootElement();
693
- if (rootElement) {
694
- rootElement.focus();
695
- }
696
- }
697
- blur() {
698
- const root = this.lexical.getRootElement();
699
- if (root) {
700
- root.blur();
701
- }
702
- }
703
- getJSON() {
704
- return this.lexical.getEditorState().toJSON();
705
- }
706
- getHTML() {
707
- let html = "";
708
- this.lexical.getEditorState().read(() => {
709
- html = $generateHtmlFromNodes(this.lexical, null);
710
- });
711
- return html;
712
- }
713
- getMarkdown() {
714
- let md = "";
715
- this.lexical.getEditorState().read(() => {
716
- md = $convertToMarkdownString(NOTIQ_TRANSFORMERS);
717
- });
718
- return md;
719
- }
720
- getText() {
721
- let text = "";
722
- this.lexical.getEditorState().read(() => {
723
- text = $getRoot().getTextContent();
724
- });
725
- return text;
726
- }
727
- setContent(content, options = {}) {
728
- if (typeof content === "object" && content !== null) {
729
- this.lexical.setEditorState(
730
- this.lexical.parseEditorState(JSON.stringify(content))
731
- );
732
- } else if (typeof content === "string") {
733
- const format = detectContentFormat(content);
734
- importContentToEditor(this.lexical, content, format, "replace");
735
- }
736
- if (options.emitUpdate !== false) {
737
- this.emit("update");
738
- }
739
- }
740
- clearContent(options = {}) {
741
- this.lexical.update(
742
- () => {
743
- const root = $getRoot();
744
- root.clear();
745
- },
746
- { discrete: true }
747
- );
748
- if (options.emitUpdate !== false) {
749
- this.emit("update");
750
- }
751
- }
752
- on(event, listener) {
753
- if (!this.listeners.has(event)) {
754
- this.listeners.set(event, /* @__PURE__ */ new Set());
755
- }
756
- this.listeners.get(event).add(listener);
757
- return () => this.off(event, listener);
758
- }
759
- off(event, listener) {
760
- const set = this.listeners.get(event);
761
- if (set) {
762
- set.delete(listener);
763
- }
764
- }
765
- emit(event, data) {
766
- const set = this.listeners.get(event);
767
- if (set) {
768
- const payload = __spreadValues({
769
- editor: this
770
- }, data || {});
771
- set.forEach((listener) => {
772
- try {
773
- listener(payload);
774
- } catch (err) {
775
- console.error(`[Notiq Event Error (${event})]:`, err);
776
- }
777
- });
778
- }
779
- }
780
- destroy() {
781
- this.unregisterListeners.forEach((fn) => fn());
782
- this.unregisterListeners = [];
783
- this.emit("destroy");
784
- this.listeners.clear();
785
- }
786
- };
787
- function createNotiqEditor(options = {}) {
788
- return new NotiqEditorImpl(options);
789
- }
790
-
791
- // src/core/react/useNotiq.ts
792
- function useNotiq(options = {}, deps = []) {
793
- const [editor, setEditor] = useState(null);
794
- const optionsRef = useRef(options);
795
- optionsRef.current = options;
796
- useEffect(() => {
797
- const instance = createNotiqEditor(optionsRef.current);
798
- setEditor(instance);
799
- return () => {
800
- instance.destroy();
801
- setEditor(null);
802
- };
803
- }, deps);
804
- const [, setTick] = useState(0);
805
- useEffect(() => {
806
- if (!editor) return;
807
- const unlistenTransaction = editor.on("transaction", () => {
808
- setTick((t) => (t + 1) % 1e6);
809
- });
810
- const unlistenSelection = editor.on("selectionUpdate", () => {
811
- setTick((t) => (t + 1) % 1e6);
812
- });
813
- const unlistenFocus = editor.on("focus", () => {
814
- setTick((t) => (t + 1) % 1e6);
815
- });
816
- const unlistenBlur = editor.on("blur", () => {
817
- setTick((t) => (t + 1) % 1e6);
818
- });
819
- return () => {
820
- unlistenTransaction();
821
- unlistenSelection();
822
- unlistenFocus();
823
- unlistenBlur();
824
- };
825
- }, [editor]);
826
- return editor;
827
- }
828
-
829
- // src/core/react/NotiqContent.tsx
830
- init_react_shim();
831
- import { useContext as useContext2, useMemo as useMemo2 } from "react";
832
- import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
833
- import { ContentEditable } from "@lexical/react/LexicalContentEditable";
834
- import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
835
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
836
- function InnerContent({
837
- editor,
838
- className,
839
- containerClassName,
840
- placeholder,
841
- renderPlugins = true,
842
- children
843
- }) {
844
- const extensionPlugins = useMemo2(() => {
845
- if (!renderPlugins || !editor.extensions) return [];
846
- return editor.extensions.flatMap(
847
- (ext) => typeof ext.getPlugins === "function" ? ext.getPlugins({
848
- editor,
849
- lexical: editor.lexical,
850
- options: ext.options,
851
- storage: ext.storage
852
- }) : []
853
- );
854
- }, [editor, renderPlugins]);
855
- const resolvedPlaceholder = placeholder !== void 0 ? placeholder : editor.options.placeholder;
856
- const placeholderElement = resolvedPlaceholder ? typeof resolvedPlaceholder === "string" ? /* @__PURE__ */ jsx2("div", { className: "pointer-events-none select-none absolute top-4 left-4 z-10 text-muted-foreground/60 text-base flex items-center gap-1.5", children: /* @__PURE__ */ jsx2("span", { children: resolvedPlaceholder }) }) : /* @__PURE__ */ jsx2("div", { className: "pointer-events-none select-none absolute top-4 left-4 z-10", children: resolvedPlaceholder }) : null;
857
- return /* @__PURE__ */ jsxs("div", { className: cn("relative w-full", containerClassName), children: [
858
- /* @__PURE__ */ jsx2(
859
- RichTextPlugin,
860
- {
861
- contentEditable: /* @__PURE__ */ jsx2(
862
- ContentEditable,
863
- {
864
- className: cn(
865
- "notiq-content min-h-[160px] outline-none text-foreground p-4 text-base leading-relaxed",
866
- className
867
- )
868
- }
869
- ),
870
- placeholder: placeholderElement,
871
- ErrorBoundary: LexicalErrorBoundary
872
- }
873
- ),
874
- extensionPlugins.map((PluginComponent, index) => /* @__PURE__ */ jsx2(PluginComponent, {}, `ext-plugin-${index}`)),
875
- children
876
- ] });
877
- }
878
- function NotiqContent({
879
- editor: propEditor,
880
- className,
881
- containerClassName,
882
- placeholder,
883
- renderPlugins,
884
- children
885
- }) {
886
- const context = useContext2(NotiqContext);
887
- const activeEditor = propEditor || context.editor;
888
- if (!activeEditor) {
889
- return null;
890
- }
891
- if (context.editor === activeEditor) {
892
- return /* @__PURE__ */ jsx2(
893
- InnerContent,
894
- {
895
- editor: activeEditor,
896
- className,
897
- containerClassName,
898
- placeholder,
899
- renderPlugins,
900
- children
901
- }
902
- );
903
- }
904
- return /* @__PURE__ */ jsx2(NotiqProvider, { editor: activeEditor, children: /* @__PURE__ */ jsx2(
905
- InnerContent,
906
- {
907
- editor: activeEditor,
908
- className,
909
- containerClassName,
910
- placeholder,
911
- renderPlugins,
912
- children
913
- }
914
- ) });
915
- }
916
-
917
- // src/core/react/BubbleMenu.tsx
918
- init_react_shim();
919
- import { useEffect as useEffect2, useState as useState2, useRef as useRef2, useContext as useContext3 } from "react";
920
- import { createPortal } from "react-dom";
921
- import { $getSelection as $getSelection2, $isRangeSelection as $isRangeSelection2 } from "lexical";
922
- import { Sparkles } from "lucide-react";
923
- import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
924
- function BubbleMenu({
925
- editor: propEditor,
926
- className,
927
- children,
928
- shouldShow,
929
- offset = 8,
930
- showAskAI = true
931
- }) {
932
- var _a;
933
- const context = useContext3(NotiqContext);
934
- const editor = propEditor || context.editor;
935
- const menuRef = useRef2(null);
936
- const [coords, setCoords] = useState2(null);
937
- const [visible, setVisible] = useState2(false);
938
- useEffect2(() => {
939
- if (!editor) return;
940
- const updatePosition = () => {
941
- var _a2, _b;
942
- let isVisible = false;
943
- editor.lexical.getEditorState().read(() => {
944
- const selection = $getSelection2();
945
- if ($isRangeSelection2(selection) && !selection.isCollapsed()) {
946
- if (shouldShow) {
947
- isVisible = shouldShow({ editor });
948
- } else {
949
- isVisible = selection.getTextContent().trim().length > 0;
950
- }
951
- }
952
- });
953
- if (!isVisible) {
954
- setVisible(false);
955
- return;
956
- }
957
- const domSelection = window.getSelection();
958
- if (!domSelection || domSelection.rangeCount === 0) {
959
- setVisible(false);
960
- return;
961
- }
962
- const range = domSelection.getRangeAt(0);
963
- const rect = range.getBoundingClientRect();
964
- if (rect.width === 0 && rect.height === 0) {
965
- setVisible(false);
966
- return;
967
- }
968
- const menuWidth = ((_a2 = menuRef.current) == null ? void 0 : _a2.offsetWidth) || 240;
969
- const menuHeight = ((_b = menuRef.current) == null ? void 0 : _b.offsetHeight) || 40;
970
- let left = rect.left + rect.width / 2 - menuWidth / 2;
971
- left = Math.max(16, Math.min(window.innerWidth - menuWidth - 16, left));
972
- let top = rect.top - menuHeight - offset;
973
- if (top < 10) {
974
- top = rect.bottom + offset;
975
- }
976
- setCoords({ top, left });
977
- setVisible(true);
978
- };
979
- const unregisterListener = editor.lexical.registerUpdateListener(() => {
980
- updatePosition();
981
- });
982
- const handleSelectionChange = () => {
983
- updatePosition();
984
- };
985
- document.addEventListener("selectionchange", handleSelectionChange);
986
- window.addEventListener("resize", handleSelectionChange);
987
- window.addEventListener("scroll", handleSelectionChange, true);
988
- return () => {
989
- unregisterListener();
990
- document.removeEventListener("selectionchange", handleSelectionChange);
991
- window.removeEventListener("resize", handleSelectionChange);
992
- window.removeEventListener("scroll", handleSelectionChange, true);
993
- };
994
- }, [editor, shouldShow, offset]);
995
- if (!visible || !coords) {
996
- return null;
997
- }
998
- return createPortal(
999
- /* @__PURE__ */ jsxs2(
1000
- "div",
1001
- {
1002
- ref: menuRef,
1003
- style: {
1004
- position: "fixed",
1005
- top: `${coords.top}px`,
1006
- left: `${coords.left}px`,
1007
- zIndex: 50
1008
- },
1009
- className: cn(
1010
- "flex items-center gap-1 p-1 rounded-lg border border-border bg-popover/95 text-popover-foreground shadow-xl backdrop-blur-md transition-all animate-in fade-in-0 zoom-in-95",
1011
- className
1012
- ),
1013
- onMouseDown: (e) => {
1014
- e.preventDefault();
1015
- },
1016
- children: [
1017
- showAskAI && typeof ((_a = editor == null ? void 0 : editor.commands) == null ? void 0 : _a.openAICommandBar) === "function" && /* @__PURE__ */ jsxs2(Fragment2, { children: [
1018
- /* @__PURE__ */ jsxs2(
1019
- "button",
1020
- {
1021
- type: "button",
1022
- onClick: () => editor.commands.openAICommandBar(),
1023
- className: "flex items-center gap-1.5 px-2 py-1 text-xs font-medium rounded-md bg-primary/10 hover:bg-primary/20 text-primary transition-all mr-0.5",
1024
- title: "Ask AI (\u2318K)",
1025
- children: [
1026
- /* @__PURE__ */ jsx3(Sparkles, { className: "w-3.5 h-3.5" }),
1027
- /* @__PURE__ */ jsx3("span", { children: "Ask AI" }),
1028
- /* @__PURE__ */ jsx3("kbd", { className: "text-[10px] font-mono opacity-60", children: "\u2318K" })
1029
- ]
1030
- }
1031
- ),
1032
- /* @__PURE__ */ jsx3("div", { className: "w-[1px] h-4 bg-border/60 mx-0.5" })
1033
- ] }),
1034
- children
1035
- ]
1036
- }
1037
- ),
1038
- document.body
1039
- );
1040
- }
1041
-
1042
- // src/core/react/FloatingMenu.tsx
1043
- init_react_shim();
1044
- import { useEffect as useEffect3, useState as useState3, useRef as useRef3, useContext as useContext4 } from "react";
1045
- import { createPortal as createPortal2 } from "react-dom";
1046
- import { $getSelection as $getSelection3, $isRangeSelection as $isRangeSelection3, $isElementNode as $isElementNode2 } from "lexical";
1047
- import { jsx as jsx4 } from "react/jsx-runtime";
1048
- function FloatingMenu({
1049
- editor: propEditor,
1050
- className,
1051
- children,
1052
- shouldShow,
1053
- offset = 8
1054
- }) {
1055
- const context = useContext4(NotiqContext);
1056
- const editor = propEditor || context.editor;
1057
- const menuRef = useRef3(null);
1058
- const [coords, setCoords] = useState3(null);
1059
- const [visible, setVisible] = useState3(false);
1060
- useEffect3(() => {
1061
- if (!editor) return;
1062
- const updatePosition = () => {
1063
- var _a, _b;
1064
- let isVisible = false;
1065
- let targetElementKey = null;
1066
- editor.lexical.getEditorState().read(() => {
1067
- const selection = $getSelection3();
1068
- if ($isRangeSelection3(selection) && selection.isCollapsed()) {
1069
- const anchorNode = selection.anchor.getNode();
1070
- const element = anchorNode.getKey() === "root" ? null : $isElementNode2(anchorNode) ? anchorNode : anchorNode.getTopLevelElement();
1071
- if (element) {
1072
- const text = element.getTextContent().trim();
1073
- if (shouldShow) {
1074
- isVisible = shouldShow({ editor });
1075
- } else {
1076
- isVisible = text.length === 0;
1077
- }
1078
- if (isVisible) {
1079
- targetElementKey = element.getKey();
1080
- }
1081
- }
1082
- }
1083
- });
1084
- if (!isVisible || !targetElementKey) {
1085
- setVisible(false);
1086
- return;
1087
- }
1088
- const domElement = editor.lexical.getElementByKey(targetElementKey);
1089
- if (!domElement) {
1090
- setVisible(false);
1091
- return;
1092
- }
1093
- const rect = domElement.getBoundingClientRect();
1094
- const menuWidth = ((_a = menuRef.current) == null ? void 0 : _a.offsetWidth) || 36;
1095
- const menuHeight = ((_b = menuRef.current) == null ? void 0 : _b.offsetHeight) || 36;
1096
- let left = rect.left - menuWidth - offset;
1097
- if (left < 8) {
1098
- left = rect.left + offset;
1099
- }
1100
- const top = rect.top + (rect.height - menuHeight) / 2;
1101
- setCoords({ top, left });
1102
- setVisible(true);
1103
- };
1104
- const unregisterListener = editor.lexical.registerUpdateListener(() => {
1105
- updatePosition();
1106
- });
1107
- const handleSelectionChange = () => {
1108
- updatePosition();
1109
- };
1110
- document.addEventListener("selectionchange", handleSelectionChange);
1111
- window.addEventListener("resize", handleSelectionChange);
1112
- window.addEventListener("scroll", handleSelectionChange, true);
1113
- return () => {
1114
- unregisterListener();
1115
- document.removeEventListener("selectionchange", handleSelectionChange);
1116
- window.removeEventListener("resize", handleSelectionChange);
1117
- window.removeEventListener("scroll", handleSelectionChange, true);
1118
- };
1119
- }, [editor, shouldShow, offset]);
1120
- if (!visible || !coords) {
1121
- return null;
1122
- }
1123
- return createPortal2(
1124
- /* @__PURE__ */ jsx4(
1125
- "div",
1126
- {
1127
- ref: menuRef,
1128
- style: {
1129
- position: "fixed",
1130
- top: `${coords.top}px`,
1131
- left: `${coords.left}px`,
1132
- zIndex: 50
1133
- },
1134
- className: cn(
1135
- "flex items-center gap-1 p-1 rounded-md border border-border bg-popover/90 text-popover-foreground shadow-md backdrop-blur transition-all animate-in fade-in-0 duration-150",
1136
- className
1137
- ),
1138
- onMouseDown: (e) => {
1139
- e.preventDefault();
1140
- },
1141
- children
1142
- }
1143
- ),
1144
- document.body
1145
- );
1146
- }
1147
-
1148
- // src/core/react/NotiqEditor.tsx
1149
- init_react_shim();
1150
-
1151
- // src/components/editor/index.tsx
1152
- init_react_shim();
1153
- import { useMemo as useMemo4 } from "react";
1154
- import { LexicalComposer } from "@lexical/react/LexicalComposer";
1155
- import { LexicalCollaboration } from "@lexical/react/LexicalCollaborationContext";
1156
-
1157
- // src/components/editor/Core.tsx
1158
- init_react_shim();
1159
- import { useCallback as useCallback3, useEffect as useEffect11, useRef as useRef6, useState as useState6 } from "react";
1160
- import { useLexicalEditable as useLexicalEditable2 } from "@lexical/react/useLexicalEditable";
1161
- import { useLexicalComposerContext as useLexicalComposerContext8 } from "@lexical/react/LexicalComposerContext";
1162
- import dynamic from "next/dynamic.js";
1163
- import { RichTextPlugin as RichTextPlugin2 } from "@lexical/react/LexicalRichTextPlugin";
1164
- import { ContentEditable as ContentEditable2 } from "@lexical/react/LexicalContentEditable";
1165
- import { LexicalErrorBoundary as LexicalErrorBoundary2 } from "@lexical/react/LexicalErrorBoundary";
1166
- import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
1167
- import { HorizontalRulePlugin } from "@lexical/react/LexicalHorizontalRulePlugin";
1168
- import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
1169
- import { TablePlugin } from "@lexical/react/LexicalTablePlugin";
1170
- import { INSERT_TABLE_COMMAND, $createTableNodeWithDimensions } from "@lexical/table";
1171
- import { $insertNodeToNearestRoot as $insertNodeToNearestRoot3 } from "@lexical/utils";
1172
- import { $isElementNode as $isElementNode4, COMMAND_PRIORITY_EDITOR as COMMAND_PRIORITY_EDITOR3 } from "lexical";
1173
- import { $generateHtmlFromNodes as $generateHtmlFromNodes2 } from "@lexical/html";
1174
- import { $convertToMarkdownString as $convertToMarkdownString2 } from "@lexical/markdown";
1175
- import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
1176
- import { ClearEditorPlugin } from "@lexical/react/LexicalClearEditorPlugin";
1177
-
1178
- // src/components/editor/plugins/ShortcutsPlugin/index.tsx
1179
- init_react_shim();
1180
- import { TOGGLE_LINK_COMMAND } from "@lexical/link";
1181
- import {
1182
- COMMAND_PRIORITY_NORMAL,
1183
- FORMAT_ELEMENT_COMMAND,
1184
- FORMAT_TEXT_COMMAND,
1185
- INDENT_CONTENT_COMMAND,
1186
- KEY_MODIFIER_COMMAND,
1187
- OUTDENT_CONTENT_COMMAND
1188
- } from "lexical";
1189
- import { useEffect as useEffect4 } from "react";
1190
- function ShortcutsPlugin({
1191
- editor,
1192
- setIsLinkEditMode
1193
- }) {
1194
- const { toolbarState } = useToolbarState();
1195
- useEffect4(() => {
1196
- const keyboardShortcutsHandler = (payload) => {
1197
- const event = payload;
1198
- if (isFormatParagraph(event)) {
1199
- event.preventDefault();
1200
- formatParagraph(editor);
1201
- } else if (isFormatHeading(event)) {
1202
- event.preventDefault();
1203
- const { code } = event;
1204
- const headingSize = `h${code[code.length - 1]}`;
1205
- formatHeading(editor, toolbarState.blockType, headingSize);
1206
- } else if (isFormatBulletList(event)) {
1207
- event.preventDefault();
1208
- formatBulletList(editor, toolbarState.blockType);
1209
- } else if (isFormatNumberedList(event)) {
1210
- event.preventDefault();
1211
- formatNumberedList(editor, toolbarState.blockType);
1212
- } else if (isFormatCheckList(event)) {
1213
- event.preventDefault();
1214
- formatCheckList(editor, toolbarState.blockType);
1215
- } else if (isFormatCode(event)) {
1216
- event.preventDefault();
1217
- formatCode(editor, toolbarState.blockType);
1218
- } else if (isFormatQuote(event)) {
1219
- event.preventDefault();
1220
- formatQuote(editor, toolbarState.blockType);
1221
- } else if (isStrikeThrough(event)) {
1222
- event.preventDefault();
1223
- editor.dispatchCommand(FORMAT_TEXT_COMMAND, "strikethrough");
1224
- } else if (isLowercase(event)) {
1225
- event.preventDefault();
1226
- editor.dispatchCommand(FORMAT_TEXT_COMMAND, "lowercase");
1227
- } else if (isUppercase(event)) {
1228
- event.preventDefault();
1229
- editor.dispatchCommand(FORMAT_TEXT_COMMAND, "uppercase");
1230
- } else if (isCapitalize(event)) {
1231
- event.preventDefault();
1232
- editor.dispatchCommand(FORMAT_TEXT_COMMAND, "capitalize");
1233
- } else if (isIndent(event)) {
1234
- event.preventDefault();
1235
- editor.dispatchCommand(INDENT_CONTENT_COMMAND, void 0);
1236
- } else if (isOutdent(event)) {
1237
- event.preventDefault();
1238
- editor.dispatchCommand(OUTDENT_CONTENT_COMMAND, void 0);
1239
- } else if (isCenterAlign(event)) {
1240
- event.preventDefault();
1241
- editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, "center");
1242
- } else if (isLeftAlign(event)) {
1243
- event.preventDefault();
1244
- editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, "left");
1245
- } else if (isRightAlign(event)) {
1246
- event.preventDefault();
1247
- editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, "right");
1248
- } else if (isJustifyAlign(event)) {
1249
- event.preventDefault();
1250
- editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, "justify");
1251
- } else if (isSubscript(event)) {
1252
- event.preventDefault();
1253
- editor.dispatchCommand(FORMAT_TEXT_COMMAND, "subscript");
1254
- } else if (isSuperscript(event)) {
1255
- event.preventDefault();
1256
- editor.dispatchCommand(FORMAT_TEXT_COMMAND, "superscript");
1257
- } else if (isInsertCodeBlock(event)) {
1258
- event.preventDefault();
1259
- editor.dispatchCommand(FORMAT_TEXT_COMMAND, "code");
1260
- } else if (isIncreaseFontSize(event)) {
1261
- event.preventDefault();
1262
- updateFontSize(
1263
- editor,
1264
- 1 /* increment */,
1265
- toolbarState.fontSizeInputValue
1266
- );
1267
- } else if (isDecreaseFontSize(event)) {
1268
- event.preventDefault();
1269
- updateFontSize(
1270
- editor,
1271
- 2 /* decrement */,
1272
- toolbarState.fontSizeInputValue
1273
- );
1274
- } else if (isClearFormatting(event)) {
1275
- event.preventDefault();
1276
- clearFormatting(editor);
1277
- } else if (isInsertLink(event)) {
1278
- event.preventDefault();
1279
- const url = toolbarState.isLink ? null : sanitizeUrl("https://");
1280
- setIsLinkEditMode(!toolbarState.isLink);
1281
- editor.dispatchCommand(TOGGLE_LINK_COMMAND, url);
1282
- }
1283
- return false;
1284
- };
1285
- return editor.registerCommand(
1286
- KEY_MODIFIER_COMMAND,
1287
- keyboardShortcutsHandler,
1288
- COMMAND_PRIORITY_NORMAL
1289
- );
1290
- }, [
1291
- editor,
1292
- toolbarState.isLink,
1293
- toolbarState.blockType,
1294
- toolbarState.fontSizeInputValue,
1295
- setIsLinkEditMode
1296
- ]);
1297
- return null;
1298
- }
1299
-
1300
- // src/components/editor/plugins/TabFocusPlugin/index.ts
1301
- init_react_shim();
1302
- import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
1303
- import {
1304
- $getSelection as $getSelection4,
1305
- $isRangeSelection as $isRangeSelection4,
1306
- $setSelection,
1307
- FOCUS_COMMAND
1308
- } from "lexical";
1309
- import { useEffect as useEffect5 } from "react";
1310
- var COMMAND_PRIORITY_LOW = 1;
1311
- var TAB_TO_FOCUS_INTERVAL = 100;
1312
- var lastTabKeyDownTimestamp = 0;
1313
- var hasRegisteredKeyDownListener = false;
1314
- function registerKeyTimeStampTracker() {
1315
- window.addEventListener(
1316
- "keydown",
1317
- (event) => {
1318
- if (event.key === "Tab") {
1319
- lastTabKeyDownTimestamp = event.timeStamp;
1320
- }
1321
- },
1322
- true
1323
- );
1324
- }
1325
- function TabFocusPlugin() {
1326
- const [editor] = useLexicalComposerContext();
1327
- useEffect5(() => {
1328
- if (!hasRegisteredKeyDownListener) {
1329
- registerKeyTimeStampTracker();
1330
- hasRegisteredKeyDownListener = true;
1331
- }
1332
- return editor.registerCommand(
1333
- FOCUS_COMMAND,
1334
- (event) => {
1335
- const selection = $getSelection4();
1336
- if ($isRangeSelection4(selection)) {
1337
- if (lastTabKeyDownTimestamp + TAB_TO_FOCUS_INTERVAL > event.timeStamp) {
1338
- $setSelection(selection.clone());
1339
- }
1340
- }
1341
- return false;
1342
- },
1343
- COMMAND_PRIORITY_LOW
1344
- );
1345
- }, [editor]);
1346
- return null;
1347
- }
1348
-
1349
- // src/components/editor/plugins/TableCellResizer/index.tsx
1350
- init_react_shim();
1351
- import { useLexicalComposerContext as useLexicalComposerContext2 } from "@lexical/react/LexicalComposerContext";
1352
- import { useLexicalEditable } from "@lexical/react/useLexicalEditable";
1353
- import {
1354
- $computeTableMapSkipCellCheck,
1355
- $getTableNodeFromLexicalNodeOrThrow,
1356
- $getTableRowIndexFromTableCellNode,
1357
- $isTableCellNode,
1358
- $isTableRowNode,
1359
- getDOMCellFromTarget,
1360
- getTableElement,
1361
- TableNode
1362
- } from "@lexical/table";
1363
- import { calculateZoomLevel } from "@lexical/utils";
1364
- import { $getNearestNodeFromDOMNode, isHTMLElement } from "lexical";
1365
- import {
1366
- useCallback,
1367
- useEffect as useEffect6,
1368
- useMemo as useMemo3,
1369
- useRef as useRef4,
1370
- useState as useState4
1371
- } from "react";
1372
- import { createPortal as createPortal3 } from "react-dom";
1373
- import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
1374
- var MIN_ROW_HEIGHT = 33;
1375
- var MIN_COLUMN_WIDTH = 92;
1376
- function TableCellResizer({ editor }) {
1377
- const targetRef = useRef4(null);
1378
- const resizerRef = useRef4(null);
1379
- const tableRectRef = useRef4(null);
1380
- const mouseStartPosRef = useRef4(null);
1381
- const [mouseCurrentPos, updateMouseCurrentPos] = useState4(null);
1382
- const [activeCell, updateActiveCell] = useState4(null);
1383
- const [isMouseDown, updateIsMouseDown] = useState4(false);
1384
- const [draggingDirection, updateDraggingDirection] = useState4(null);
1385
- const resetState = useCallback(() => {
1386
- updateActiveCell(null);
1387
- targetRef.current = null;
1388
- updateDraggingDirection(null);
1389
- mouseStartPosRef.current = null;
1390
- tableRectRef.current = null;
1391
- }, []);
1392
- const isMouseDownOnEvent = (event) => {
1393
- return (event.buttons & 1) === 1;
1394
- };
1395
- useEffect6(() => {
1396
- return editor.registerNodeTransform(TableNode, (tableNode) => {
1397
- if (tableNode.getColWidths()) {
1398
- return tableNode;
1399
- }
1400
- const numColumns = tableNode.getColumnCount();
1401
- const columnWidth = MIN_COLUMN_WIDTH;
1402
- tableNode.setColWidths(Array(numColumns).fill(columnWidth));
1403
- return tableNode;
1404
- });
1405
- }, [editor]);
1406
- useEffect6(() => {
1407
- const onMouseMove = (event) => {
1408
- const target = event.target;
1409
- if (!isHTMLElement(target)) {
1410
- return;
1411
- }
1412
- if (draggingDirection) {
1413
- updateMouseCurrentPos({
1414
- x: event.clientX,
1415
- y: event.clientY
1416
- });
1417
- return;
1418
- }
1419
- updateIsMouseDown(isMouseDownOnEvent(event));
1420
- if (resizerRef.current && resizerRef.current.contains(target)) {
1421
- return;
1422
- }
1423
- if (targetRef.current !== target) {
1424
- targetRef.current = target;
1425
- const cell = getDOMCellFromTarget(target);
1426
- if (cell && activeCell !== cell) {
1427
- editor.getEditorState().read(
1428
- () => {
1429
- const tableCellNode = $getNearestNodeFromDOMNode(cell.elem);
1430
- if (!tableCellNode) {
1431
- throw new Error("TableCellResizer: Table cell node not found.");
1432
- }
1433
- const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
1434
- const tableElement = getTableElement(
1435
- tableNode,
1436
- editor.getElementByKey(tableNode.getKey())
1437
- );
1438
- if (!tableElement) {
1439
- throw new Error("TableCellResizer: Table element not found.");
1440
- }
1441
- targetRef.current = target;
1442
- tableRectRef.current = tableElement.getBoundingClientRect();
1443
- updateActiveCell(cell);
1444
- },
1445
- { editor }
1446
- );
1447
- } else if (cell == null) {
1448
- resetState();
1449
- }
1450
- }
1451
- };
1452
- const onMouseDown = () => {
1453
- updateIsMouseDown(true);
1454
- };
1455
- const onMouseUp = () => {
1456
- updateIsMouseDown(false);
1457
- };
1458
- const removeRootListener = editor.registerRootListener(
1459
- (rootElement, prevRootElement) => {
1460
- prevRootElement == null ? void 0 : prevRootElement.removeEventListener("mousemove", onMouseMove);
1461
- prevRootElement == null ? void 0 : prevRootElement.removeEventListener("mousedown", onMouseDown);
1462
- prevRootElement == null ? void 0 : prevRootElement.removeEventListener("mouseup", onMouseUp);
1463
- rootElement == null ? void 0 : rootElement.addEventListener("mousemove", onMouseMove);
1464
- rootElement == null ? void 0 : rootElement.addEventListener("mousedown", onMouseDown);
1465
- rootElement == null ? void 0 : rootElement.addEventListener("mouseup", onMouseUp);
1466
- }
1467
- );
1468
- return () => {
1469
- removeRootListener();
1470
- };
1471
- }, [activeCell, draggingDirection, editor, resetState]);
1472
- const isHeightChanging = (direction) => {
1473
- if (direction === "bottom") {
1474
- return true;
1475
- }
1476
- return false;
1477
- };
1478
- const updateRowHeight = useCallback(
1479
- (heightChange) => {
1480
- if (!activeCell) {
1481
- throw new Error("TableCellResizer: Expected active cell.");
1482
- }
1483
- editor.update(
1484
- () => {
1485
- const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);
1486
- if (!$isTableCellNode(tableCellNode)) {
1487
- throw new Error("TableCellResizer: Table cell node not found.");
1488
- }
1489
- const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
1490
- const tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode) + tableCellNode.getRowSpan() - 1;
1491
- const tableRows = tableNode.getChildren();
1492
- if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {
1493
- throw new Error("Expected table cell to be inside of table row.");
1494
- }
1495
- const tableRow = tableRows[tableRowIndex];
1496
- if (!$isTableRowNode(tableRow)) {
1497
- throw new Error("Expected table row");
1498
- }
1499
- let height = tableRow.getHeight();
1500
- if (height === void 0) {
1501
- const rowCells = tableRow.getChildren();
1502
- height = Math.min(
1503
- ...rowCells.map(
1504
- (cell) => {
1505
- var _a;
1506
- return (_a = getCellNodeHeight(cell, editor)) != null ? _a : Infinity;
1507
- }
1508
- )
1509
- );
1510
- }
1511
- const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT);
1512
- tableRow.setHeight(newHeight);
1513
- },
1514
- { tag: "skip-scroll-into-view" }
1515
- );
1516
- },
1517
- [activeCell, editor]
1518
- );
1519
- const getCellNodeHeight = (cell, activeEditor) => {
1520
- const domCellNode = activeEditor.getElementByKey(cell.getKey());
1521
- return domCellNode == null ? void 0 : domCellNode.clientHeight;
1522
- };
1523
- const getCellColumnIndex = (tableCellNode, tableMap) => {
1524
- for (let row = 0; row < tableMap.length; row++) {
1525
- for (let column = 0; column < tableMap[row].length; column++) {
1526
- if (tableMap[row][column].cell === tableCellNode) {
1527
- return column;
1528
- }
1529
- }
1530
- }
1531
- };
1532
- const updateColumnWidth = useCallback(
1533
- (widthChange) => {
1534
- if (!activeCell) {
1535
- throw new Error("TableCellResizer: Expected active cell.");
1536
- }
1537
- editor.update(
1538
- () => {
1539
- const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);
1540
- if (!$isTableCellNode(tableCellNode)) {
1541
- throw new Error("TableCellResizer: Table cell node not found.");
1542
- }
1543
- const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
1544
- const [tableMap] = $computeTableMapSkipCellCheck(
1545
- tableNode,
1546
- null,
1547
- null
1548
- );
1549
- const columnIndex = getCellColumnIndex(tableCellNode, tableMap);
1550
- if (columnIndex === void 0) {
1551
- throw new Error("TableCellResizer: Table column not found.");
1552
- }
1553
- const colWidths = tableNode.getColWidths();
1554
- if (!colWidths) {
1555
- return;
1556
- }
1557
- const width = colWidths[columnIndex];
1558
- if (width === void 0) {
1559
- return;
1560
- }
1561
- const newColWidths = [...colWidths];
1562
- const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH);
1563
- newColWidths[columnIndex] = newWidth;
1564
- tableNode.setColWidths(newColWidths);
1565
- },
1566
- { tag: "skip-scroll-into-view" }
1567
- );
1568
- },
1569
- [activeCell, editor]
1570
- );
1571
- const mouseUpHandler = useCallback(
1572
- (direction) => {
1573
- const handler = (event) => {
1574
- event.preventDefault();
1575
- event.stopPropagation();
1576
- if (!activeCell) {
1577
- throw new Error("TableCellResizer: Expected active cell.");
1578
- }
1579
- if (mouseStartPosRef.current) {
1580
- const { x, y } = mouseStartPosRef.current;
1581
- if (activeCell === null) {
1582
- return;
1583
- }
1584
- const zoom = calculateZoomLevel(event.target);
1585
- if (isHeightChanging(direction)) {
1586
- const heightChange = (event.clientY - y) / zoom;
1587
- updateRowHeight(heightChange);
1588
- } else {
1589
- const widthChange = (event.clientX - x) / zoom;
1590
- updateColumnWidth(widthChange);
1591
- }
1592
- resetState();
1593
- document.removeEventListener("mouseup", handler);
1594
- }
1595
- };
1596
- return handler;
1597
- },
1598
- [activeCell, resetState, updateColumnWidth, updateRowHeight]
1599
- );
1600
- const toggleResize = useCallback(
1601
- (direction) => (event) => {
1602
- event.preventDefault();
1603
- event.stopPropagation();
1604
- if (!activeCell) {
1605
- throw new Error("TableCellResizer: Expected active cell.");
1606
- }
1607
- mouseStartPosRef.current = {
1608
- x: event.clientX,
1609
- y: event.clientY
1610
- };
1611
- updateMouseCurrentPos(mouseStartPosRef.current);
1612
- updateDraggingDirection(direction);
1613
- document.addEventListener("mouseup", mouseUpHandler(direction));
1614
- },
1615
- [activeCell, mouseUpHandler]
1616
- );
1617
- const getResizers = useCallback(() => {
1618
- if (activeCell) {
1619
- const { height, width, top, left } = activeCell.elem.getBoundingClientRect();
1620
- const zoom = calculateZoomLevel(activeCell.elem);
1621
- const zoneWidth = 10;
1622
- const styles = {
1623
- bottom: {
1624
- backgroundColor: "none",
1625
- "zIndex": "10",
1626
- cursor: "row-resize",
1627
- height: `${zoneWidth}px`,
1628
- left: `${window.pageXOffset + left}px`,
1629
- top: `${window.pageYOffset + top + height - zoneWidth / 2}px`,
1630
- width: `${width}px`
1631
- },
1632
- right: {
1633
- backgroundColor: "none",
1634
- "zIndex": "10",
1635
- cursor: "col-resize",
1636
- height: `${height}px`,
1637
- left: `${window.pageXOffset + left + width - zoneWidth / 2}px`,
1638
- top: `${window.pageYOffset + top}px`,
1639
- width: `${zoneWidth}px`
1640
- }
1641
- };
1642
- const tableRect = tableRectRef.current;
1643
- if (draggingDirection && mouseCurrentPos && tableRect) {
1644
- if (isHeightChanging(draggingDirection)) {
1645
- styles[draggingDirection].left = `${window.pageXOffset + tableRect.left}px`;
1646
- styles[draggingDirection].top = `${window.pageYOffset + mouseCurrentPos.y / zoom}px`;
1647
- styles[draggingDirection].height = "3px";
1648
- styles[draggingDirection].width = `${tableRect.width}px`;
1649
- } else {
1650
- styles[draggingDirection].top = `${window.pageYOffset + tableRect.top}px`;
1651
- styles[draggingDirection].left = `${window.pageXOffset + mouseCurrentPos.x / zoom}px`;
1652
- styles[draggingDirection].width = "3px";
1653
- styles[draggingDirection].height = `${tableRect.height}px`;
1654
- }
1655
- styles[draggingDirection].backgroundColor = "#10b981";
1656
- styles[draggingDirection].boxShadow = "0 0 8px rgba(16, 185, 129, 0.5)";
1657
- }
1658
- return styles;
1659
- }
1660
- return {
1661
- bottom: null,
1662
- left: null,
1663
- right: null,
1664
- top: null
1665
- };
1666
- }, [activeCell, draggingDirection, mouseCurrentPos]);
1667
- const resizerStyles = getResizers();
1668
- return /* @__PURE__ */ jsx5("div", { ref: resizerRef, children: activeCell != null && !isMouseDown && /* @__PURE__ */ jsxs3(Fragment3, { children: [
1669
- /* @__PURE__ */ jsx5(
1670
- "div",
1671
- {
1672
- className: " absolute TableCellResizer__ui",
1673
- style: resizerStyles.right || void 0,
1674
- onMouseDown: toggleResize("right")
1675
- }
1676
- ),
1677
- /* @__PURE__ */ jsx5(
1678
- "div",
1679
- {
1680
- className: "absolute TableCellResizer__ui",
1681
- style: resizerStyles.bottom || void 0,
1682
- onMouseDown: toggleResize("bottom")
1683
- }
1684
- )
1685
- ] }) });
1686
- }
1687
- function TableCellResizerPlugin() {
1688
- const [editor] = useLexicalComposerContext2();
1689
- const isEditable = useLexicalEditable();
1690
- const [mounted, setMounted] = useState4(false);
1691
- useEffect6(() => {
1692
- setMounted(true);
1693
- }, []);
1694
- const portal = useMemo3(() => {
1695
- if (!mounted || !isEditable) return null;
1696
- return createPortal3(/* @__PURE__ */ jsx5(TableCellResizer, { editor }), document.body);
1697
- }, [mounted, isEditable, editor]);
1698
- return portal;
1699
- }
1700
-
1701
- // src/components/editor/Core.tsx
1702
- import { TabIndentationPlugin } from "@lexical/react/LexicalTabIndentationPlugin";
1703
- import { CheckListPlugin } from "@lexical/react/LexicalCheckListPlugin";
1704
- import { ListPlugin } from "@lexical/react/LexicalListPlugin";
1705
-
1706
- // src/components/editor/plugins/DragDropPastePlugin/index.tsx
1707
- init_react_shim();
1708
- import { useLexicalComposerContext as useLexicalComposerContext3 } from "@lexical/react/LexicalComposerContext";
1709
- import { DRAG_DROP_PASTE } from "@lexical/rich-text";
1710
- import { isMimeType, mediaFileReader } from "@lexical/utils";
1711
- import { COMMAND_PRIORITY_LOW as COMMAND_PRIORITY_LOW2 } from "lexical";
1712
- import { useEffect as useEffect7 } from "react";
1713
- var ACCEPTABLE_IMAGE_TYPES = [
1714
- "image/",
1715
- "image/heic",
1716
- "image/heif",
1717
- "image/gif",
1718
- "image/webp"
1719
- ];
1720
- function DragDropPaste() {
1721
- const [editor] = useLexicalComposerContext3();
1722
- useEffect7(() => {
1723
- return editor.registerCommand(
1724
- DRAG_DROP_PASTE,
1725
- (files) => {
1726
- (async () => {
1727
- const filesResult = await mediaFileReader(
1728
- files,
1729
- [ACCEPTABLE_IMAGE_TYPES].flatMap((x) => x)
1730
- );
1731
- for (const { file, result } of filesResult) {
1732
- if (isMimeType(file, ACCEPTABLE_IMAGE_TYPES)) {
1733
- editor.dispatchCommand(INSERT_IMAGE_COMMAND, {
1734
- altText: file.name,
1735
- src: result
1736
- });
1737
- }
1738
- }
1739
- })();
1740
- return true;
1741
- },
1742
- COMMAND_PRIORITY_LOW2
1743
- );
1744
- }, [editor]);
1745
- return null;
1746
- }
1747
-
1748
- // src/components/editor/plugins/DraggableBlockPlugin/index.tsx
1749
- init_react_shim();
1750
- import { useRef as useRef5, useState as useState5, useCallback as useCallback2 } from "react";
1751
- import { useLexicalComposerContext as useLexicalComposerContext4 } from "@lexical/react/LexicalComposerContext";
1752
- import { DraggableBlockPlugin_EXPERIMENTAL } from "@lexical/react/LexicalDraggableBlockPlugin";
1753
- import {
1754
- $getNearestNodeFromDOMNode as $getNearestNodeFromDOMNode2,
1755
- $createParagraphNode as $createParagraphNode2,
1756
- $createTextNode,
1757
- $isElementNode as $isElementNode3
1758
- } from "lexical";
1759
- import {
1760
- $createHeadingNode,
1761
- $createQuoteNode
1762
- } from "@lexical/rich-text";
1763
- import { $createCodeNode } from "@lexical/code";
1764
- import {
1765
- $createListNode,
1766
- $createListItemNode
1767
- } from "@lexical/list";
1768
- import {
1769
- GripVertical,
1770
- Plus,
1771
- Heading1,
1772
- Heading2,
1773
- Heading3,
1774
- Quote,
1775
- Code,
1776
- List,
1777
- ListOrdered,
1778
- Columns2,
1779
- Columns3,
1780
- Copy,
1781
- Trash2,
1782
- Sparkles as Sparkles2
1783
- } from "lucide-react";
1784
- import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
1785
- var DRAGGABLE_BLOCK_MENU_CLASSNAME = "draggable-block-menu";
1786
- function DraggableBlockPlugin({
1787
- anchorElem = typeof document !== "undefined" ? document.body : void 0,
1788
- className
1789
- }) {
1790
- const [editor] = useLexicalComposerContext4();
1791
- const menuRef = useRef5(null);
1792
- const targetLineRef = useRef5(null);
1793
- const [isMenuOpen, setIsMenuOpen] = useState5(false);
1794
- const getTargetNode = useCallback2(() => {
1795
- if (!menuRef.current) return null;
1796
- const rect = menuRef.current.getBoundingClientRect();
1797
- const targetElem = document.elementFromPoint(
1798
- rect.right + 32,
1799
- rect.top + rect.height / 2
1800
- );
1801
- if (!targetElem) return null;
1802
- let targetNode = null;
1803
- const resolve = () => {
1804
- const node = $getNearestNodeFromDOMNode2(targetElem);
1805
- if (node) {
1806
- targetNode = node.getKey() === "root" ? node : node.getTopLevelElement() || ($isElementNode3(node) ? node : null);
1807
- }
1808
- };
1809
- try {
1810
- resolve();
1811
- } catch (e) {
1812
- editor.read(resolve);
1813
- }
1814
- return targetNode;
1815
- }, [editor]);
1816
- const handleInsertBelow = () => {
1817
- editor.update(
1818
- () => {
1819
- const targetNode = getTargetNode();
1820
- if (targetNode) {
1821
- const p = $createParagraphNode2();
1822
- targetNode.insertAfter(p);
1823
- p.select();
1824
- }
1825
- },
1826
- { discrete: true }
1827
- );
1828
- };
1829
- const handleTurnInto = (type) => {
1830
- editor.update(
1831
- () => {
1832
- const targetNode = getTargetNode();
1833
- if (!targetNode || targetNode.getKey() === "root") return;
1834
- let replacement = null;
1835
- switch (type) {
1836
- case "h1":
1837
- replacement = $createHeadingNode("h1");
1838
- break;
1839
- case "h2":
1840
- replacement = $createHeadingNode("h2");
1841
- break;
1842
- case "h3":
1843
- replacement = $createHeadingNode("h3");
1844
- break;
1845
- case "quote":
1846
- replacement = $createQuoteNode();
1847
- break;
1848
- case "code":
1849
- replacement = $createCodeNode();
1850
- break;
1851
- case "bullet": {
1852
- const list = $createListNode("bullet");
1853
- const item = $createListItemNode();
1854
- list.append(item);
1855
- replacement = list;
1856
- break;
1857
- }
1858
- case "number": {
1859
- const list = $createListNode("number");
1860
- const item = $createListItemNode();
1861
- list.append(item);
1862
- replacement = list;
1863
- break;
1864
- }
1865
- }
1866
- if (replacement && $isElementNode3(targetNode)) {
1867
- const children = targetNode.getChildren();
1868
- if ($isElementNode3(replacement)) {
1869
- replacement.append(...children);
1870
- }
1871
- targetNode.replace(replacement);
1872
- }
1873
- },
1874
- { discrete: true }
1875
- );
1876
- };
1877
- const handleSplitColumns = (columns) => {
1878
- editor.update(
1879
- () => {
1880
- const targetNode = getTargetNode();
1881
- if (!targetNode || targetNode.getKey() === "root") return;
1882
- const template = columns === 2 ? "1fr 1fr" : "1fr 1fr 1fr";
1883
- const container = $createLayoutContainerNode(template);
1884
- const col1 = $createLayoutItemNode();
1885
- const col2 = $createLayoutItemNode();
1886
- const cloned = targetNode;
1887
- col1.append(cloned);
1888
- col2.append($createParagraphNode2());
1889
- if (columns === 3) {
1890
- const col3 = $createLayoutItemNode();
1891
- col3.append($createParagraphNode2());
1892
- container.append(col1, col2, col3);
1893
- } else {
1894
- container.append(col1, col2);
1895
- }
1896
- targetNode.replace(container);
1897
- },
1898
- { discrete: true }
1899
- );
1900
- };
1901
- const handleDuplicate = () => {
1902
- editor.update(
1903
- () => {
1904
- const targetNode = getTargetNode();
1905
- if (targetNode && targetNode.getKey() !== "root") {
1906
- const p = $createParagraphNode2();
1907
- p.append($createTextNode(targetNode.getTextContent()));
1908
- targetNode.insertAfter(p);
1909
- }
1910
- },
1911
- { discrete: true }
1912
- );
1913
- };
1914
- const handleDelete = () => {
1915
- editor.update(
1916
- () => {
1917
- const targetNode = getTargetNode();
1918
- if (targetNode && targetNode.getKey() !== "root") {
1919
- targetNode.remove();
1920
- }
1921
- },
1922
- { discrete: true }
1923
- );
1924
- };
1925
- const handleAskAI = () => {
1926
- editor.dispatchCommand(OPEN_AI_COMMAND_BAR_COMMAND, {
1927
- initialPrompt: "",
1928
- action: "ImproveWriting"
1929
- });
1930
- };
1931
- const isOnMenu = (element) => {
1932
- return !!element.closest(`.${DRAGGABLE_BLOCK_MENU_CLASSNAME}`);
1933
- };
1934
- if (!anchorElem) return null;
1935
- return /* @__PURE__ */ jsx6(
1936
- DraggableBlockPlugin_EXPERIMENTAL,
1937
- {
1938
- anchorElem,
1939
- menuRef,
1940
- targetLineRef,
1941
- menuComponent: /* @__PURE__ */ jsxs4(
1942
- "div",
1943
- {
1944
- ref: menuRef,
1945
- className: cn(
1946
- "draggable-block-menu flex items-center gap-0.5 rounded-md border border-border/40 bg-background/90 text-muted-foreground shadow-sm backdrop-blur transition-all duration-150 group z-40 absolute top-0 left-0",
1947
- className
1948
- ),
1949
- children: [
1950
- /* @__PURE__ */ jsx6(
1951
- "button",
1952
- {
1953
- type: "button",
1954
- onClick: handleInsertBelow,
1955
- className: "flex items-center justify-center w-5 h-5 rounded hover:bg-muted hover:text-foreground transition-colors",
1956
- title: "Insert block below",
1957
- children: /* @__PURE__ */ jsx6(Plus, { className: "w-3.5 h-3.5" })
1958
- }
1959
- ),
1960
- /* @__PURE__ */ jsxs4(DropdownMenu, { open: isMenuOpen, onOpenChange: setIsMenuOpen, children: [
1961
- /* @__PURE__ */ jsx6(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx6(
1962
- "button",
1963
- {
1964
- type: "button",
1965
- className: "flex items-center justify-center w-5 h-5 rounded cursor-grab active:cursor-grabbing hover:bg-muted hover:text-foreground transition-colors",
1966
- title: "Drag to move or click for block actions",
1967
- children: /* @__PURE__ */ jsx6(GripVertical, { className: "w-3.5 h-3.5" })
1968
- }
1969
- ) }),
1970
- /* @__PURE__ */ jsxs4(
1971
- DropdownMenuContent,
1972
- {
1973
- align: "start",
1974
- side: "bottom",
1975
- sideOffset: 4,
1976
- className: "w-52 z-50 text-xs",
1977
- children: [
1978
- /* @__PURE__ */ jsxs4(DropdownMenuItem, { onClick: handleAskAI, className: "gap-2 font-medium text-primary", children: [
1979
- /* @__PURE__ */ jsx6(Sparkles2, { className: "w-3.5 h-3.5 text-primary" }),
1980
- /* @__PURE__ */ jsx6("span", { children: "Ask AI on block" }),
1981
- /* @__PURE__ */ jsx6("kbd", { className: "ml-auto font-mono text-[10px] opacity-60", children: "\u2318K" })
1982
- ] }),
1983
- /* @__PURE__ */ jsx6(DropdownMenuSeparator, {}),
1984
- /* @__PURE__ */ jsxs4(DropdownMenuSub, { children: [
1985
- /* @__PURE__ */ jsxs4(DropdownMenuSubTrigger, { className: "gap-2", children: [
1986
- /* @__PURE__ */ jsx6(Heading1, { className: "w-3.5 h-3.5 text-muted-foreground" }),
1987
- /* @__PURE__ */ jsx6("span", { children: "Turn into" })
1988
- ] }),
1989
- /* @__PURE__ */ jsxs4(DropdownMenuSubContent, { className: "w-44 text-xs", children: [
1990
- /* @__PURE__ */ jsxs4(DropdownMenuItem, { onClick: () => handleTurnInto("h1"), className: "gap-2", children: [
1991
- /* @__PURE__ */ jsx6(Heading1, { className: "w-3.5 h-3.5" }),
1992
- /* @__PURE__ */ jsx6("span", { children: "Heading 1" })
1993
- ] }),
1994
- /* @__PURE__ */ jsxs4(DropdownMenuItem, { onClick: () => handleTurnInto("h2"), className: "gap-2", children: [
1995
- /* @__PURE__ */ jsx6(Heading2, { className: "w-3.5 h-3.5" }),
1996
- /* @__PURE__ */ jsx6("span", { children: "Heading 2" })
1997
- ] }),
1998
- /* @__PURE__ */ jsxs4(DropdownMenuItem, { onClick: () => handleTurnInto("h3"), className: "gap-2", children: [
1999
- /* @__PURE__ */ jsx6(Heading3, { className: "w-3.5 h-3.5" }),
2000
- /* @__PURE__ */ jsx6("span", { children: "Heading 3" })
2001
- ] }),
2002
- /* @__PURE__ */ jsxs4(DropdownMenuItem, { onClick: () => handleTurnInto("bullet"), className: "gap-2", children: [
2003
- /* @__PURE__ */ jsx6(List, { className: "w-3.5 h-3.5" }),
2004
- /* @__PURE__ */ jsx6("span", { children: "Bullet List" })
2005
- ] }),
2006
- /* @__PURE__ */ jsxs4(DropdownMenuItem, { onClick: () => handleTurnInto("number"), className: "gap-2", children: [
2007
- /* @__PURE__ */ jsx6(ListOrdered, { className: "w-3.5 h-3.5" }),
2008
- /* @__PURE__ */ jsx6("span", { children: "Numbered List" })
2009
- ] }),
2010
- /* @__PURE__ */ jsxs4(DropdownMenuItem, { onClick: () => handleTurnInto("quote"), className: "gap-2", children: [
2011
- /* @__PURE__ */ jsx6(Quote, { className: "w-3.5 h-3.5" }),
2012
- /* @__PURE__ */ jsx6("span", { children: "Quote" })
2013
- ] }),
2014
- /* @__PURE__ */ jsxs4(DropdownMenuItem, { onClick: () => handleTurnInto("code"), className: "gap-2", children: [
2015
- /* @__PURE__ */ jsx6(Code, { className: "w-3.5 h-3.5" }),
2016
- /* @__PURE__ */ jsx6("span", { children: "Code Block" })
2017
- ] })
2018
- ] })
2019
- ] }),
2020
- /* @__PURE__ */ jsxs4(DropdownMenuSub, { children: [
2021
- /* @__PURE__ */ jsxs4(DropdownMenuSubTrigger, { className: "gap-2", children: [
2022
- /* @__PURE__ */ jsx6(Columns2, { className: "w-3.5 h-3.5 text-muted-foreground" }),
2023
- /* @__PURE__ */ jsx6("span", { children: "Columns layout" })
2024
- ] }),
2025
- /* @__PURE__ */ jsxs4(DropdownMenuSubContent, { className: "w-40 text-xs", children: [
2026
- /* @__PURE__ */ jsxs4(DropdownMenuItem, { onClick: () => handleSplitColumns(2), className: "gap-2", children: [
2027
- /* @__PURE__ */ jsx6(Columns2, { className: "w-3.5 h-3.5" }),
2028
- /* @__PURE__ */ jsx6("span", { children: "2 Columns" })
2029
- ] }),
2030
- /* @__PURE__ */ jsxs4(DropdownMenuItem, { onClick: () => handleSplitColumns(3), className: "gap-2", children: [
2031
- /* @__PURE__ */ jsx6(Columns3, { className: "w-3.5 h-3.5" }),
2032
- /* @__PURE__ */ jsx6("span", { children: "3 Columns" })
2033
- ] })
2034
- ] })
2035
- ] }),
2036
- /* @__PURE__ */ jsx6(DropdownMenuSeparator, {}),
2037
- /* @__PURE__ */ jsxs4(DropdownMenuItem, { onClick: handleDuplicate, className: "gap-2", children: [
2038
- /* @__PURE__ */ jsx6(Copy, { className: "w-3.5 h-3.5 text-muted-foreground" }),
2039
- /* @__PURE__ */ jsx6("span", { children: "Duplicate" })
2040
- ] }),
2041
- /* @__PURE__ */ jsxs4(
2042
- DropdownMenuItem,
2043
- {
2044
- onClick: handleDelete,
2045
- className: "gap-2 text-destructive focus:text-destructive focus:bg-destructive/10",
2046
- children: [
2047
- /* @__PURE__ */ jsx6(Trash2, { className: "w-3.5 h-3.5 text-destructive" }),
2048
- /* @__PURE__ */ jsx6("span", { children: "Delete" })
2049
- ]
2050
- }
2051
- )
2052
- ]
2053
- }
2054
- )
2055
- ] })
2056
- ]
2057
- }
2058
- ),
2059
- targetLineComponent: /* @__PURE__ */ jsx6(
2060
- "div",
2061
- {
2062
- ref: targetLineRef,
2063
- className: "cursor-none h-[3px] rounded-full bg-gradient-to-r from-blue-500 to-indigo-600 shadow-sm pointer-events-none absolute left-0 top-0 opacity-0 will-change-transform z-40"
2064
- }
2065
- ),
2066
- isOnMenu
2067
- }
2068
- );
2069
- }
2070
-
2071
- // src/components/editor/Core.tsx
2072
- import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin";
2073
- import { ClickableLinkPlugin } from "@lexical/react/LexicalClickableLinkPlugin";
2074
-
2075
- // src/components/editor/lexical-on-change.tsx
2076
- init_react_shim();
2077
- import { useLexicalComposerContext as useLexicalComposerContext5 } from "@lexical/react/LexicalComposerContext";
2078
-
2079
- // src/components/editor/utils/useLayoutEffect.ts
2080
- init_react_shim();
2081
- import { useEffect as useEffect8, useLayoutEffect } from "react";
2082
- var useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect8;
2083
- var useLayoutEffect_default = useLayoutEffectImpl;
2084
-
2085
- // src/components/editor/utils/setNodePlaceholderFromSelection/setNodePlaceholderFromSelection.ts
2086
- init_react_shim();
2087
- import { $getSelection as $getSelection5, $isRangeSelection as $isRangeSelection5 } from "lexical";
2088
-
2089
- // src/components/editor/utils/setNodePlaceholderFromSelection/setPlaceholderOnSelection.ts
2090
- init_react_shim();
2091
-
2092
- // src/components/editor/utils/getAllLexicalChildren.ts
2093
- init_react_shim();
2094
- import { $getNodeByKey, $getRoot as $getRoot2 } from "lexical";
2095
- var getAllLexicalChildren = (editor) => {
2096
- const childrenKeys = editor.getEditorState().read(() => $getRoot2().getChildrenKeys());
2097
- return childrenKeys.map((key) => ({
2098
- key,
2099
- node: $getNodeByKey(key),
2100
- htmlElement: editor.getElementByKey(key)
2101
- }));
2102
- };
2103
-
2104
- // src/components/editor/utils/setNodePlaceholderFromSelection/getNodePlaceholder.ts
2105
- init_react_shim();
2106
- import { $isParagraphNode } from "lexical";
2107
- import { $isHeadingNode as $isHeadingNode2, $isQuoteNode } from "@lexical/rich-text";
2108
- import { $isListItemNode } from "@lexical/list";
2109
- var getNodePlaceholder = (lexicalNode) => {
2110
- let placeholder;
2111
- if ($isHeadingNode2(lexicalNode)) {
2112
- const tag = lexicalNode.getTag();
2113
- placeholder = "Heading";
2114
- switch (tag) {
2115
- case "h1": {
2116
- placeholder += " 1";
2117
- break;
2118
- }
2119
- case "h2": {
2120
- placeholder += " 2";
2121
- break;
2122
- }
2123
- case "h3": {
2124
- placeholder += " 3";
2125
- break;
2126
- }
2127
- case "h4": {
2128
- placeholder += " 4";
2129
- break;
2130
- }
2131
- case "h5": {
2132
- placeholder += "5";
2133
- break;
2134
- }
2135
- case "h6": {
2136
- placeholder += "6";
2137
- break;
2138
- }
2139
- }
2140
- }
2141
- if ($isListItemNode(lexicalNode)) {
2142
- placeholder = "list";
2143
- }
2144
- if ($isQuoteNode(lexicalNode)) {
2145
- placeholder = "Quote";
2146
- }
2147
- if ($isParagraphNode(lexicalNode)) {
2148
- placeholder = "Press '/' for command";
2149
- }
2150
- return placeholder;
2151
- };
2152
-
2153
- // src/components/editor/utils/setNodePlaceholderFromSelection/setPlaceholderOnSelection.ts
2154
- var PLACEHOLDER_CLASS_NAME = "node-placeholder";
2155
- var isHtmlHeadingElement = (el) => {
2156
- return el instanceof HTMLHeadingElement;
2157
- };
2158
- var setPlaceholderOnSelection = ({
2159
- selection,
2160
- editor
2161
- }) => {
2162
- const children = getAllLexicalChildren(editor);
2163
- const removePlaceholderClass = (element) => {
2164
- if (!element) return;
2165
- if (element.classList.contains(PLACEHOLDER_CLASS_NAME)) {
2166
- element.classList.remove(PLACEHOLDER_CLASS_NAME);
2167
- element.removeAttribute("data-placeholder");
2168
- }
2169
- Array.from(element.children).forEach((child) => {
2170
- if (child instanceof HTMLElement) {
2171
- removePlaceholderClass(child);
2172
- }
2173
- });
2174
- };
2175
- children.forEach(({ htmlElement, node }) => {
2176
- if (!htmlElement) {
2177
- return;
2178
- }
2179
- if (isHtmlHeadingElement(htmlElement)) {
2180
- return;
2181
- }
2182
- const classList = htmlElement.classList;
2183
- if (node.__type === "collapsible-container") {
2184
- removePlaceholderClass(htmlElement);
2185
- return;
2186
- }
2187
- if (node.__type === "table") {
2188
- removePlaceholderClass(htmlElement);
2189
- return;
2190
- }
2191
- if (node.__type === "layout-container") {
2192
- removePlaceholderClass(htmlElement);
2193
- }
2194
- if (classList.length && classList.contains(PLACEHOLDER_CLASS_NAME)) {
2195
- classList.remove(PLACEHOLDER_CLASS_NAME);
2196
- htmlElement.removeAttribute("data-placeholder");
2197
- }
2198
- });
2199
- if (children.length === 1 && children[0].htmlElement && !isHtmlHeadingElement(children[0].htmlElement)) {
2200
- return;
2201
- }
2202
- const anchor = selection.anchor;
2203
- const placeholder = getNodePlaceholder(anchor.getNode());
2204
- if (placeholder) {
2205
- const selectedHtmlElement = editor.getElementByKey(anchor.key);
2206
- selectedHtmlElement == null ? void 0 : selectedHtmlElement.classList.add(PLACEHOLDER_CLASS_NAME);
2207
- selectedHtmlElement == null ? void 0 : selectedHtmlElement.setAttribute("data-placeholder", placeholder);
2208
- }
2209
- };
2210
-
2211
- // src/components/editor/utils/setNodePlaceholderFromSelection/setNodePlaceholderFromSelection.ts
2212
- var setNodePlaceholderFromSelection = (editor) => {
2213
- editor.getEditorState().read(() => {
2214
- const selection = $getSelection5();
2215
- if (!$isRangeSelection5(selection)) {
2216
- return;
2217
- }
2218
- setPlaceholderOnSelection({ selection, editor });
2219
- });
2220
- };
2221
-
2222
- // src/components/editor/lexical-on-change.tsx
2223
- import { Fragment as Fragment4, jsx as jsx7 } from "react/jsx-runtime";
2224
- function LexicalOnChangePlugin() {
2225
- const [editor] = useLexicalComposerContext5();
2226
- useLayoutEffect_default(() => {
2227
- const unregisterListener = editor.registerUpdateListener(
2228
- ({ editorState, dirtyElements, dirtyLeaves, prevEditorState, tags }) => {
2229
- if (dirtyElements.size === 0 && dirtyLeaves.size === 0 || tags.has("history-merge") || prevEditorState.isEmpty()) {
2230
- return;
2231
- }
2232
- setNodePlaceholderFromSelection(editor);
2233
- }
2234
- );
2235
- return () => {
2236
- unregisterListener();
2237
- };
2238
- }, [editor]);
2239
- return /* @__PURE__ */ jsx7(Fragment4, {});
2240
- }
2241
-
2242
- // src/components/editor/plugins/AudioPlugin/index.tsx
2243
- init_react_shim();
2244
- import { useEffect as useEffect9 } from "react";
2245
- import { useLexicalComposerContext as useLexicalComposerContext6 } from "@lexical/react/LexicalComposerContext";
2246
- import { $insertNodeToNearestRoot } from "@lexical/utils";
2247
- import { COMMAND_PRIORITY_EDITOR } from "lexical";
2248
- function AudioPlugin() {
2249
- const [editor] = useLexicalComposerContext6();
2250
- useEffect9(() => {
2251
- if (!editor.hasNodes([AudioNode])) {
2252
- throw new Error("AudioPlugin: AudioNode not registered on editor");
2253
- }
2254
- return editor.registerCommand(
2255
- INSERT_AUDIO_COMMAND,
2256
- (payload) => {
2257
- editor.update(() => {
2258
- const audioNode = $createAudioNode(payload);
2259
- $insertNodeToNearestRoot(audioNode);
2260
- });
2261
- return true;
2262
- },
2263
- COMMAND_PRIORITY_EDITOR
2264
- );
2265
- }, [editor]);
2266
- return null;
2267
- }
2268
-
2269
- // src/components/editor/plugins/FilePlugin/index.tsx
2270
- init_react_shim();
2271
- import { useEffect as useEffect10 } from "react";
2272
- import { useLexicalComposerContext as useLexicalComposerContext7 } from "@lexical/react/LexicalComposerContext";
2273
- import { $insertNodeToNearestRoot as $insertNodeToNearestRoot2 } from "@lexical/utils";
2274
- import { COMMAND_PRIORITY_EDITOR as COMMAND_PRIORITY_EDITOR2 } from "lexical";
2275
- function FilePlugin() {
2276
- const [editor] = useLexicalComposerContext7();
2277
- useEffect10(() => {
2278
- if (!editor.hasNodes([FileNode])) {
2279
- throw new Error("FilePlugin: FileNode not registered on editor");
2280
- }
2281
- return editor.registerCommand(
2282
- INSERT_FILE_COMMAND,
2283
- (payload) => {
2284
- editor.update(() => {
2285
- const fileNode = $createFileNode(payload);
2286
- $insertNodeToNearestRoot2(fileNode);
2287
- });
2288
- return true;
2289
- },
2290
- COMMAND_PRIORITY_EDITOR2
2291
- );
2292
- }, [editor]);
2293
- return null;
2294
- }
2295
-
2296
- // src/components/editor/Core.tsx
2297
- import { motion } from "framer-motion";
2298
- import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
2299
- var SlashCommand = dynamic(() => import("./SlashCommand-SPR7G5EI.mjs"), { ssr: false });
2300
- var ToolbarPlugin = dynamic(() => import("./ToolbarPlugin-F52PVNXU.mjs"), {
2301
- ssr: false,
2302
- loading: () => /* @__PURE__ */ jsx8("div", { className: "hidden md:block w-full flex justify-center p-4" })
2303
- });
2304
- var ExportPlugin = dynamic(() => import("./ExportPlugin-MJHYKQZJ.mjs"), { ssr: false });
2305
- var TemplatePlugin = dynamic(() => import("./TemplatePlugin-HNTPEXBB.mjs"), { ssr: false });
2306
- var ExcalidrawPlugin = dynamic(() => import("./ExcalidrawPlugin-QLPGJPSX.mjs"), {
2307
- ssr: false
2308
- });
2309
- var FloatingLinkEditorPlugin = dynamic(() => import("./FloatingLinkEditorPlugin-MABB34L7.mjs"), {
2310
- ssr: false
2311
- });
2312
- var TableCellActionMenuPlugin = dynamic(() => import("./TableCellActionMenuPlugin-YWBA64J7.mjs"), {
2313
- ssr: false
2314
- });
2315
- var TableHoverActionsPlugin = dynamic(() => import("./TableHoverActionsPlugin-2EIXHEXN.mjs"), {
2316
- ssr: false
2317
- });
2318
- var CodeActionMenuPlugin = dynamic(() => import("./CodeActionMenuPlugin-FGH6HZLL.mjs"), { ssr: false });
2319
- var FloatingTextFormatToolbarPlugin = dynamic(
2320
- () => import("./FloatingTextFormatToolbarPlugin-BXCPN3KD.mjs"),
2321
- { ssr: false }
2322
- );
2323
- var CollaborationPlugin = dynamic(
2324
- () => import("./CollaborationPlugin-TIZOQBUT.mjs"),
2325
- { ssr: false }
2326
- );
2327
- var CollaboratorsBar = dynamic(
2328
- () => import("./CollaboratorsBar-AMPIAUOY.mjs"),
2329
- { ssr: false }
2330
- );
2331
- var CommentsPlugin = dynamic(
2332
- () => import("./CommentsPlugin-SDJJTUGK.mjs"),
2333
- { ssr: false }
2334
- );
2335
- var VersionHistoryPlugin = dynamic(
2336
- () => import("./VersionHistoryPlugin-YWGCREKA.mjs"),
2337
- { ssr: false }
2338
- );
2339
- var InlineCopilotPlugin = dynamic(
2340
- () => import("./InlineCopilotPlugin-PNS5Y6OO.mjs"),
2341
- { ssr: false }
2342
- );
2343
- var AICommandBarPlugin = dynamic(
2344
- () => import("./AICommandBarPlugin-TADJ3X2Y.mjs"),
2345
- { ssr: false }
2346
- );
2347
- function EditorPlaceholder() {
2348
- return /* @__PURE__ */ jsxs5("div", { className: "pointer-events-none select-none absolute top-4 md:top-12 left-4 md:left-12 z-10 text-muted-foreground/60 text-sm md:text-base flex items-center gap-1.5 md:gap-2", children: [
2349
- /* @__PURE__ */ jsx8("span", { children: "Type" }),
2350
- /* @__PURE__ */ jsx8("kbd", { className: "px-1.5 py-0.5 text-xs font-mono rounded bg-muted border border-border text-muted-foreground", children: "/" }),
2351
- /* @__PURE__ */ jsx8("span", { className: "truncate max-w-[220px] sm:max-w-none", children: "for commands, or start writing..." })
2352
- ] });
2353
- }
2354
- function Core({
2355
- toolbarConfig,
2356
- content,
2357
- showCollaboratorsBar = true,
2358
- className,
2359
- editorClassName,
2360
- onChange,
2361
- onUpdate,
2362
- onEditorReady,
2363
- children
2364
- }) {
2365
- const { historyState } = useSharedHistoryContext();
2366
- const isEditable = useLexicalEditable2();
2367
- const { enabled: isCollabEnabled } = useCollab();
2368
- const [floatingAnchorElem, setFloatingAnchorElem] = useState6(null);
2369
- const collabCursorsContainerRef = useRef6(null);
2370
- const [editor] = useLexicalComposerContext8();
2371
- const [activeEditor, setActiveEditor] = useState6(editor);
2372
- const [isLinkEditMode, setIsLinkEditMode] = useState6(false);
2373
- const [hasContent, setHasContent] = useState6(false);
2374
- const onRef = useCallback3((_floatingAnchorElem) => {
2375
- if (_floatingAnchorElem !== null) {
2376
- setFloatingAnchorElem(_floatingAnchorElem);
2377
- }
2378
- }, []);
2379
- useEffect11(() => {
2380
- if (onEditorReady) {
2381
- onEditorReady(editor);
2382
- }
2383
- }, [editor, onEditorReady]);
2384
- useEffect11(() => {
2385
- if (!onChange && !onUpdate) return;
2386
- return editor.registerUpdateListener(({ editorState, dirtyElements, dirtyLeaves }) => {
2387
- if (dirtyElements.size === 0 && dirtyLeaves.size === 0) return;
2388
- if (onChange) {
2389
- onChange(editorState, editor);
2390
- }
2391
- if (onUpdate) {
2392
- let html = "";
2393
- let markdown = "";
2394
- editorState.read(() => {
2395
- html = $generateHtmlFromNodes2(editor, null);
2396
- markdown = $convertToMarkdownString2(NOTIQ_TRANSFORMERS);
2397
- });
2398
- onUpdate({
2399
- json: editorState.toJSON(),
2400
- html,
2401
- markdown,
2402
- editor
2403
- });
2404
- }
2405
- });
2406
- }, [editor, onChange, onUpdate]);
2407
- useEffect11(() => {
2408
- const unregister = editor.registerTextContentListener((textContent) => {
2409
- setHasContent(textContent.trim().length > 0);
2410
- });
2411
- return unregister;
2412
- }, [editor]);
2413
- useEffect11(() => {
2414
- return editor.registerCommand(
2415
- INSERT_TABLE_COMMAND,
2416
- (payload) => {
2417
- const { columns, rows, includeHeaders = true } = payload || {};
2418
- const numRows = Number(rows) || 4;
2419
- const numCols = Number(columns) || 4;
2420
- const tableNode = $createTableNodeWithDimensions(numRows, numCols, includeHeaders);
2421
- $insertNodeToNearestRoot3(tableNode);
2422
- const firstRow = tableNode.getFirstChild();
2423
- const firstCell = $isElementNode4(firstRow) ? firstRow.getFirstChild() : null;
2424
- if (firstCell && $isElementNode4(firstCell)) {
2425
- firstCell.select();
2426
- }
2427
- return true;
2428
- },
2429
- COMMAND_PRIORITY_EDITOR3
2430
- );
2431
- }, [editor]);
2432
- return /* @__PURE__ */ jsxs5(Fragment5, { children: [
2433
- isEditable && /* @__PURE__ */ jsx8(
2434
- ToolbarPlugin,
2435
- {
2436
- editor,
2437
- activeEditor,
2438
- setActiveEditor,
2439
- setIsLinkEditMode,
2440
- toolbarConfig
2441
- }
2442
- ),
2443
- /* @__PURE__ */ jsx8("div", { className: cn(
2444
- "flex justify-center w-full min-h-[calc(100dvh-5rem)] transition-all duration-300",
2445
- "dark:md:from-gray-900/50 dark:md:to-gray-800/30",
2446
- "pt-2 md:pt-4",
2447
- className
2448
- ), children: /* @__PURE__ */ jsxs5(
2449
- motion.div,
2450
- {
2451
- className: cn(
2452
- "relative w-full max-w-5xl transition-all duration-500",
2453
- "prose prose-lg dark:prose-invert lg:prose-xl leading-relaxed",
2454
- "md:rounded-2xl md:shadow-2xl md:shadow-black/5",
2455
- "md:dark:shadow-black/20",
2456
- "bg-white dark:bg-gray-900",
2457
- "md:border md:border-gray-200/50 dark:md:border-gray-800/50"
2458
- ),
2459
- children: [
2460
- /* @__PURE__ */ jsxs5("div", { className: "absolute inset-0 rounded-2xl overflow-hidden pointer-events-none", children: [
2461
- /* @__PURE__ */ jsx8("div", { className: "absolute inset-0 bg-gradient-to-br from-blue-50/30 via-transparent to-purple-50/30 dark:from-blue-900/10 dark:to-purple-900/10" }),
2462
- /* @__PURE__ */ jsx8("div", { className: "absolute top-0 left-0 w-full h-px bg-gradient-to-r from-transparent via-gray-200 to-transparent dark:via-gray-700" })
2463
- ] }),
2464
- showCollaboratorsBar && /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between px-4 md:px-12 py-2.5 border-b border-border/40 bg-muted/10 rounded-t-2xl pointer-events-auto", children: [
2465
- /* @__PURE__ */ jsx8("span", { className: "text-xs text-muted-foreground font-medium hidden sm:inline", children: "Collaborative Document" }),
2466
- /* @__PURE__ */ jsx8(CollaboratorsBar, {})
2467
- ] }),
2468
- /* @__PURE__ */ jsx8(
2469
- RichTextPlugin2,
2470
- {
2471
- contentEditable: /* @__PURE__ */ jsx8(
2472
- "div",
2473
- {
2474
- ref: (node) => {
2475
- if (node) {
2476
- onRef(node);
2477
- collabCursorsContainerRef.current = node;
2478
- }
2479
- },
2480
- "data-collab-cursor-container": "true",
2481
- className: "relative",
2482
- children: /* @__PURE__ */ jsx8(
2483
- ContentEditable2,
2484
- {
2485
- id: "lexical-editor",
2486
- autoFocus: true,
2487
- className: cn(
2488
- "editor-content relative z-20 outline-none",
2489
- "px-4 md:px-12 py-4 md:py-12",
2490
- "min-h-[75dvh] md:min-h-[70vh]",
2491
- "focus:outline-none focus:ring-0",
2492
- "text-foreground selection:bg-blue-100 dark:selection:bg-blue-900/30",
2493
- "font-['Inter',_system-ui,_sans-serif] antialiased",
2494
- "leading-relaxed tracking-wide",
2495
- "transition-all duration-200 ease-in-out",
2496
- "rounded-2xl",
2497
- editorClassName
2498
- )
2499
- }
2500
- )
2501
- }
2502
- ),
2503
- placeholder: !hasContent ? /* @__PURE__ */ jsx8(EditorPlaceholder, {}) : null,
2504
- ErrorBoundary: LexicalErrorBoundary2
2505
- }
2506
- ),
2507
- /* @__PURE__ */ jsx8("div", { className: "absolute inset-0 rounded-2xl ring-0 ring-blue-500/0 transition-all duration-300 pointer-events-none focus-within:ring-2 focus-within:ring-blue-500/20 focus-within:ring-offset-2 focus-within:ring-offset-white dark:focus-within:ring-offset-gray-900" }),
2508
- isCollabEnabled ? /* @__PURE__ */ jsx8(
2509
- CollaborationPlugin,
2510
- {
2511
- cursorsContainerRef: collabCursorsContainerRef,
2512
- initialEditorState: content
2513
- }
2514
- ) : /* @__PURE__ */ jsx8(HistoryPlugin, { externalHistoryState: historyState }),
2515
- /* @__PURE__ */ jsx8(AutoFocusPlugin, { defaultSelection: "rootStart" }),
2516
- /* @__PURE__ */ jsx8(ClearEditorPlugin, {}),
2517
- /* @__PURE__ */ jsx8(ShortcutsPlugin, { editor: activeEditor, setIsLinkEditMode }),
2518
- /* @__PURE__ */ jsx8(LexicalOnChangePlugin, {}),
2519
- /* @__PURE__ */ jsx8(LinkPlugin, {}),
2520
- /* @__PURE__ */ jsx8(HorizontalRulePlugin, {}),
2521
- /* @__PURE__ */ jsx8(TabFocusPlugin, {}),
2522
- /* @__PURE__ */ jsx8(PollPlugin, {}),
2523
- /* @__PURE__ */ jsx8(ExcalidrawPlugin, {}),
2524
- /* @__PURE__ */ jsx8(FigmaPlugin, {}),
2525
- /* @__PURE__ */ jsx8(EquationsPlugin, {}),
2526
- /* @__PURE__ */ jsx8(SpeechToTextPlugin_default, {}),
2527
- /* @__PURE__ */ jsx8(TableCellResizerPlugin, {}),
2528
- /* @__PURE__ */ jsx8(LayoutPlugin, {}),
2529
- /* @__PURE__ */ jsx8(CollapsiblePlugin, {}),
2530
- /* @__PURE__ */ jsx8(CodeHighlightPlugin, {}),
2531
- /* @__PURE__ */ jsx8(DragDropPaste, {}),
2532
- /* @__PURE__ */ jsx8(TabIndentationPlugin, { maxIndent: 7 }),
2533
- /* @__PURE__ */ jsx8(LexicalAutoLinkPlugin, {}),
2534
- /* @__PURE__ */ jsx8(LinkWithMetaDataPlugin, {}),
2535
- /* @__PURE__ */ jsx8(ListPlugin, {}),
2536
- /* @__PURE__ */ jsx8(StepperPlugin, {}),
2537
- /* @__PURE__ */ jsx8(TwitterPlugin, {}),
2538
- /* @__PURE__ */ jsx8(CheckListPlugin, {}),
2539
- /* @__PURE__ */ jsx8(ImagesPlugin, {}),
2540
- /* @__PURE__ */ jsx8(InlineImagePlugin, {}),
2541
- /* @__PURE__ */ jsx8(AutoEmbedPlugin, {}),
2542
- /* @__PURE__ */ jsx8(HintPlugin, {}),
2543
- /* @__PURE__ */ jsx8(YouTubePlugin, {}),
2544
- /* @__PURE__ */ jsx8(StoryBuilderPlugin, {}),
2545
- /* @__PURE__ */ jsx8(DynamicBlockPlugin, {}),
2546
- /* @__PURE__ */ jsx8(AudioPlugin, {}),
2547
- /* @__PURE__ */ jsx8(FilePlugin, {}),
2548
- /* @__PURE__ */ jsx8(ExportPlugin, {}),
2549
- /* @__PURE__ */ jsx8(TemplatePlugin, {}),
2550
- /* @__PURE__ */ jsx8(MarkdownShortcutPlugin, {}),
2551
- /* @__PURE__ */ jsx8(ClickableLinkPlugin, { disabled: isEditable }),
2552
- /* @__PURE__ */ jsx8(TablePlugin, { hasCellMerge: true, hasCellBackgroundColor: true, hasHorizontalScroll: true }),
2553
- floatingAnchorElem && isEditable && /* @__PURE__ */ jsxs5(Fragment5, { children: [
2554
- /* @__PURE__ */ jsx8(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }),
2555
- /* @__PURE__ */ jsx8(
2556
- FloatingLinkEditorPlugin,
2557
- {
2558
- anchorElem: floatingAnchorElem,
2559
- isLinkEditMode,
2560
- setIsLinkEditMode
2561
- }
2562
- ),
2563
- /* @__PURE__ */ jsx8(FloatingTextFormatToolbarPlugin, { setIsLinkEditMode, anchorElem: floatingAnchorElem }),
2564
- /* @__PURE__ */ jsx8(TableCellActionMenuPlugin, { anchorElem: floatingAnchorElem, cellMerge: true }),
2565
- /* @__PURE__ */ jsx8(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem }),
2566
- /* @__PURE__ */ jsx8(TableHoverActionsPlugin, { anchorElem: floatingAnchorElem })
2567
- ] }),
2568
- isEditable && /* @__PURE__ */ jsx8(SlashCommand, {}),
2569
- isEditable && /* @__PURE__ */ jsx8(InlineCopilotPlugin, {}),
2570
- isEditable && /* @__PURE__ */ jsx8(AICommandBarPlugin, {}),
2571
- /* @__PURE__ */ jsx8(CommentsPlugin, {}),
2572
- /* @__PURE__ */ jsx8(VersionHistoryPlugin, {}),
2573
- children
2574
- ]
2575
- }
2576
- ) })
2577
- ] });
2578
- }
2579
-
2580
- // src/components/editor/index.tsx
2581
- import { jsx as jsx9 } from "react/jsx-runtime";
2582
- function Editor({
2583
- isEditable = false,
2584
- content,
2585
- aiConfig,
2586
- uploadConfig,
2587
- toolbarConfig,
2588
- collabConfig,
2589
- showCollaboratorsBar,
2590
- className,
2591
- editorClassName,
2592
- onChange,
2593
- onUpdate,
2594
- onEditorReady,
2595
- children
2596
- }) {
2597
- const isCollabActive = Boolean(collabConfig == null ? void 0 : collabConfig.enabled);
2598
- const initialConfig = useMemo4(
2599
- () => ({
2600
- namespace: "Bloger editor",
2601
- theme: editor_theme_default,
2602
- editorState: isCollabActive ? void 0 : typeof content === "string" ? content : typeof content === "object" && content !== null ? JSON.stringify(content) : void 0,
2603
- nodes: [...nodes_default],
2604
- onError: (error) => {
2605
- throw error;
2606
- },
2607
- editable: isEditable
2608
- }),
2609
- [isCollabActive, content, isEditable]
2610
- );
2611
- return /* @__PURE__ */ jsx9(CollabProvider, { config: collabConfig, children: /* @__PURE__ */ jsx9(LexicalCollaboration, { children: /* @__PURE__ */ jsx9(CommentsProvider, { children: /* @__PURE__ */ jsx9(VersionHistoryProvider, { children: /* @__PURE__ */ jsx9(LexicalComposer, { initialConfig, children: /* @__PURE__ */ jsx9(AIProvider, { config: aiConfig, children: /* @__PURE__ */ jsx9(UploadProvider, { config: uploadConfig, children: /* @__PURE__ */ jsx9(SharedHistoryContext, { children: /* @__PURE__ */ jsx9(ToolbarContext, { children: /* @__PURE__ */ jsx9(
2612
- Core,
2613
- {
2614
- toolbarConfig,
2615
- content,
2616
- showCollaboratorsBar,
2617
- className,
2618
- editorClassName,
2619
- onChange,
2620
- onUpdate,
2621
- onEditorReady,
2622
- children
2623
- }
2624
- ) }) }) }) }) }) }) }) }) });
2625
- }
2626
-
2627
- // src/core/react/NotiqEditor.tsx
2628
- import { jsx as jsx10 } from "react/jsx-runtime";
2629
- function NotiqEditor({
2630
- content,
2631
- editable = true,
2632
- toolbarConfig,
2633
- collabConfig,
2634
- aiConfig,
2635
- uploadConfig,
2636
- className,
2637
- editorClassName,
2638
- onChange,
2639
- onUpdate,
2640
- onEditorReady,
2641
- children
2642
- }) {
2643
- return /* @__PURE__ */ jsx10(
2644
- Editor,
2645
- {
2646
- isEditable: editable,
2647
- content,
2648
- toolbarConfig,
2649
- collabConfig,
2650
- aiConfig,
2651
- uploadConfig,
2652
- className,
2653
- editorClassName,
2654
- onChange,
2655
- onUpdate,
2656
- onEditorReady,
2657
- children
2658
- }
2659
- );
2660
- }
2661
-
2662
- export {
2663
- Extension,
2664
- createCommandChain,
2665
- createCanCommands,
2666
- NotiqEditorImpl,
2667
- createNotiqEditor,
2668
- NotiqContext,
2669
- useNotiqContext,
2670
- NotiqProvider,
2671
- useNotiq,
2672
- NotiqContent,
2673
- BubbleMenu,
2674
- FloatingMenu,
2675
- Editor,
2676
- NotiqEditor
2677
- };