@collabchron/notiq 1.1.11 → 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 (152) hide show
  1. package/dist/AICommandBarPlugin-ZEC755KY.mjs +27 -0
  2. package/dist/{AIDialog-2WZUFWSC.mjs → AIDialog-HJW6PQPR.mjs} +12 -13
  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-SIMURTCA.mjs → ExcalidrawComponent-POMYXDSG.mjs} +34 -7
  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-WQSNFPMM.mjs → StoryBuilderComponent-CBRFPFTR.mjs} +9 -10
  11. package/dist/{chunk-6UVNHT3T.mjs → chunk-4SYRK2NH.mjs} +23 -1
  12. package/dist/chunk-5CJZC5IB.mjs +9086 -0
  13. package/dist/{chunk-MW6MAUY3.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-XAVQAXOJ.mjs → chunk-CQCS5YPS.mjs} +3 -5
  18. package/dist/{chunk-YTLUQJE2.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-GYYLZ3MQ.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-XZXGYNTY.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-XAJ4GACN.mjs +746 -0
  35. package/dist/{chunk-7QRJVZQY.mjs → chunk-YVUQRJVV.mjs} +63 -18
  36. package/dist/components/editor/Core.d.ts +15 -2
  37. package/dist/components/editor/index.d.ts +16 -5
  38. package/dist/components/editor/nodes/EquationNode/EquationNode.d.ts +1 -0
  39. package/dist/components/editor/nodes/Hint/index.d.ts +2 -1
  40. package/dist/components/editor/plugins/AICommandBarPlugin/index.d.ts +73 -1
  41. package/dist/components/editor/plugins/DraggableBlockPlugin/index.d.ts +25 -3
  42. package/dist/components/editor/plugins/InlineCopilotPlugin/index.d.ts +16 -3
  43. package/dist/components/editor/plugins/LinkWithMetaData/index.d.ts +20 -25
  44. package/dist/components/editor/plugins/MarkdownPastePlugin/index.d.ts +5 -0
  45. package/dist/components/editor/plugins/MarkdownTransformers/index.d.ts +2 -0
  46. package/dist/components/editor/plugins/SlashCommand/index.d.ts +18 -1
  47. package/dist/components/editor/plugins/SmartTypographyPlugin/index.d.ts +26 -0
  48. package/dist/components/editor/utils/aiStream.d.ts +27 -0
  49. package/dist/components/editor/utils/excalidrawDiagramBuilder.d.ts +29 -0
  50. package/dist/components/editor/utils/markdownTransformers.d.ts +4 -1
  51. package/dist/components/editor/utils/url.d.ts +16 -4
  52. package/dist/components/providers/AIContext.d.ts +8 -0
  53. package/dist/components/ui/equation/equationTypography.d.ts +23 -0
  54. package/dist/core/extension.d.ts +3 -1
  55. package/dist/core/extensions/blocks-kit.d.ts +22 -1
  56. package/dist/core/extensions/copilot-and-collab.d.ts +15 -1
  57. package/dist/core/index.d.ts +2 -1
  58. package/dist/core/react/NotiqContent.d.ts +4 -1
  59. package/dist/core/react/NotiqEditor.d.ts +8 -8
  60. package/dist/core/react/index.d.ts +1 -0
  61. package/dist/core/react/node-renderers.d.ts +73 -0
  62. package/dist/core/types.d.ts +1 -0
  63. package/dist/core.js +18136 -9084
  64. package/dist/core.mjs +58 -44
  65. package/dist/hooks/instructions-messages.d.ts +13 -4
  66. package/dist/{image-TPW7PZZK.mjs → image-AL6PHM2A.mjs} +18 -13
  67. package/dist/index.js +15180 -12858
  68. package/dist/index.mjs +121 -1641
  69. package/dist/{insert-audio-C66RZRKY.mjs → insert-audio-CRWR7EO5.mjs} +6 -8
  70. package/dist/{insert-file-3DTGRO7W.mjs → insert-file-I73AZW3L.mjs} +6 -8
  71. package/dist/{insert-gif-FIMCCBAI.mjs → insert-gif-KWRC3ACT.mjs} +4 -4
  72. package/dist/{insert-image-CZV6HWQZ.mjs → insert-image-XIY6BGW5.mjs} +6 -5
  73. package/dist/{insert-poll-6BCIFY5G.mjs → insert-poll-J5YVZNZ4.mjs} +4 -3
  74. package/dist/{insert-table-ZRJP6X52.mjs → insert-table-OIMJRFFK.mjs} +1 -1
  75. package/dist/{poll-component-VHMM5KKZ.mjs → poll-component-TVHXIKGQ.mjs} +3 -2
  76. package/dist/react.js +17933 -9531
  77. package/dist/react.mjs +41 -34
  78. package/dist/{stepper-4AO5XMO7.mjs → stepper-ILF7YXTO.mjs} +64 -74
  79. package/dist/styles/notiq.css +1 -1
  80. package/package.json +2 -2
  81. package/src/styles/notiq.css +20 -0
  82. package/dist/AICommandBarPlugin-TADJ3X2Y.mjs +0 -12
  83. package/dist/CodeActionMenuPlugin-MRKY67ED.mjs +0 -14
  84. package/dist/CollaborationPlugin-TIZOQBUT.mjs +0 -405
  85. package/dist/CollaboratorsBar-TMKBOBJI.mjs +0 -20
  86. package/dist/CommentsPlugin-5M4RD6YO.mjs +0 -19
  87. package/dist/ExcalidrawPlugin-2SGPIQ6U.mjs +0 -14
  88. package/dist/ExportPlugin-OKZOLBGS.mjs +0 -42
  89. package/dist/FloatingLinkEditorPlugin-MABB34L7.mjs +0 -12
  90. package/dist/FloatingTextFormatToolbarPlugin-SO5VON7Q.mjs +0 -45
  91. package/dist/InlineCopilotPlugin-PNS5Y6OO.mjs +0 -360
  92. package/dist/MobileToolbar-JKP2MLQJ.mjs +0 -984
  93. package/dist/SlashCommand-2TNOOUBM.mjs +0 -39
  94. package/dist/TableCellActionMenuPlugin-YWBA64J7.mjs +0 -838
  95. package/dist/TableHoverActionsPlugin-2EIXHEXN.mjs +0 -265
  96. package/dist/TemplatePlugin-HNTPEXBB.mjs +0 -9
  97. package/dist/ToolbarPlugin-IIAOU4P5.mjs +0 -35
  98. package/dist/VersionHistoryPlugin-23MAZB4G.mjs +0 -371
  99. package/dist/background-color-OZJCBYCT.mjs +0 -425
  100. package/dist/block-format-MTSIXWID.mjs +0 -14
  101. package/dist/chunk-2KESP7OU.mjs +0 -809
  102. package/dist/chunk-3AHNLIME.mjs +0 -1701
  103. package/dist/chunk-3IILA3IP.mjs +0 -28
  104. package/dist/chunk-4DVIYZVB.mjs +0 -193
  105. package/dist/chunk-4FFTOZGJ.mjs +0 -103
  106. package/dist/chunk-4UMUPCDK.mjs +0 -68
  107. package/dist/chunk-6D6QLRYR.mjs +0 -238
  108. package/dist/chunk-6SRMKQSD.mjs +0 -682
  109. package/dist/chunk-ACV47ZKE.mjs +0 -201
  110. package/dist/chunk-AYNKORDO.mjs +0 -6
  111. package/dist/chunk-BGV62GC2.mjs +0 -26
  112. package/dist/chunk-D3IOUQFR.mjs +0 -441
  113. package/dist/chunk-EEBA6OAH.mjs +0 -59
  114. package/dist/chunk-EIZMKFHF.mjs +0 -32
  115. package/dist/chunk-EVPWKNE4.mjs +0 -27
  116. package/dist/chunk-FMJ7DGWP.mjs +0 -144
  117. package/dist/chunk-FYLRS4BG.mjs +0 -88
  118. package/dist/chunk-HOZ4QRFV.mjs +0 -536
  119. package/dist/chunk-IAFCQV3Z.mjs +0 -349
  120. package/dist/chunk-IU2N42JJ.mjs +0 -1763
  121. package/dist/chunk-J6ZUY5BY.mjs +0 -202
  122. package/dist/chunk-K5OAFEVY.mjs +0 -191
  123. package/dist/chunk-KDA7ZYMJ.mjs +0 -431
  124. package/dist/chunk-KXRLARGI.mjs +0 -26
  125. package/dist/chunk-LAUAYRPC.mjs +0 -944
  126. package/dist/chunk-LLCP7NVE.mjs +0 -449
  127. package/dist/chunk-LU2XWLOE.mjs +0 -219
  128. package/dist/chunk-MPTE332I.mjs +0 -787
  129. package/dist/chunk-MTQZWJHR.mjs +0 -111
  130. package/dist/chunk-OXWTZV3U.mjs +0 -174
  131. package/dist/chunk-PD5K4AGP.mjs +0 -64
  132. package/dist/chunk-PFH63ZU4.mjs +0 -33
  133. package/dist/chunk-PHRVYPVM.mjs +0 -808
  134. package/dist/chunk-R7WFRENU.mjs +0 -262
  135. package/dist/chunk-RAVYEEIC.mjs +0 -36
  136. package/dist/chunk-RJQTA6HG.mjs +0 -358
  137. package/dist/chunk-SAOJHVPE.mjs +0 -153
  138. package/dist/chunk-VGAX6YEY.mjs +0 -399
  139. package/dist/chunk-W6GAJXUS.mjs +0 -334
  140. package/dist/chunk-XYDBUQ6Z.mjs +0 -1978
  141. package/dist/chunk-XYT6XM5S.mjs +0 -496
  142. package/dist/chunk-YDDBQZ77.mjs +0 -409
  143. package/dist/chunk-YE7M2VKR.mjs +0 -132
  144. package/dist/chunk-Z6JAFF55.mjs +0 -555
  145. package/dist/chunk-ZKZ7MLSS.mjs +0 -165
  146. package/dist/color-23323E3B.mjs +0 -13
  147. package/dist/font-IJKFR4BM.mjs +0 -12
  148. package/dist/font-size-GTL6UVQL.mjs +0 -15
  149. package/dist/insert-node-MA3FXEYN.mjs +0 -245
  150. package/dist/table-dropdown-4VCRSQB6.mjs +0 -391
  151. package/dist/text-align-CSDLJUDA.mjs +0 -121
  152. package/dist/text-format-6L5N3CHZ.mjs +0 -15
@@ -1,1763 +0,0 @@
1
- import {
2
- ToolbarPlugin
3
- } from "./chunk-PHRVYPVM.mjs";
4
- import {
5
- VersionHistoryProvider
6
- } from "./chunk-J6ZUY5BY.mjs";
7
- import {
8
- OPEN_AI_COMMAND_BAR_COMMAND
9
- } from "./chunk-HOZ4QRFV.mjs";
10
- import {
11
- INSERT_LAYOUT_COMMAND,
12
- LayoutContainerNode,
13
- LayoutItemNode
14
- } from "./chunk-W6GAJXUS.mjs";
15
- import {
16
- AIProvider
17
- } from "./chunk-BGV62GC2.mjs";
18
- import {
19
- detectContentFormat,
20
- importContentToEditor
21
- } from "./chunk-XYDBUQ6Z.mjs";
22
- import {
23
- UploadProvider
24
- } from "./chunk-N3WTT2U6.mjs";
25
- import {
26
- $createStepperNode,
27
- NOTIQ_TRANSFORMERS,
28
- StepperNode
29
- } from "./chunk-2KESP7OU.mjs";
30
- import {
31
- $createFigmaNode,
32
- $createTweetNode,
33
- $createYouTubeNode,
34
- FigmaNode,
35
- TweetNode,
36
- YouTubeNode
37
- } from "./chunk-VGAX6YEY.mjs";
38
- import {
39
- $createPollNode,
40
- PollNode,
41
- createPollOption
42
- } from "./chunk-N6ILV6NF.mjs";
43
- import {
44
- $createAudioNode,
45
- AudioNode
46
- } from "./chunk-XYMXGU4T.mjs";
47
- import {
48
- $createFileNode,
49
- FileNode
50
- } from "./chunk-ZFV2HGD3.mjs";
51
- import {
52
- ToolbarContext
53
- } from "./chunk-4FFTOZGJ.mjs";
54
- import {
55
- CommentsProvider
56
- } from "./chunk-R7WFRENU.mjs";
57
- import {
58
- CollabProvider
59
- } from "./chunk-RJQTA6HG.mjs";
60
- import {
61
- SharedHistoryContext
62
- } from "./chunk-EVPWKNE4.mjs";
63
- import {
64
- $createImageNode,
65
- ImageNode
66
- } from "./chunk-GYYLZ3MQ.mjs";
67
- import {
68
- $createExcalidrawNode,
69
- ExcalidrawNode
70
- } from "./chunk-XZXGYNTY.mjs";
71
- import {
72
- $createEquationNode,
73
- EquationNode
74
- } from "./chunk-KNW2CGIP.mjs";
75
- import {
76
- $createHintNode,
77
- Hint
78
- } from "./chunk-7QRJVZQY.mjs";
79
- import {
80
- cn
81
- } from "./chunk-JHXDLYEV.mjs";
82
- import {
83
- __spreadProps,
84
- __spreadValues,
85
- init_react_shim
86
- } from "./chunk-WYCFGRFJ.mjs";
87
-
88
- // src/core/react/index.ts
89
- init_react_shim();
90
-
91
- // src/core/react/context.tsx
92
- init_react_shim();
93
- import { createContext, useContext, useMemo } from "react";
94
- import {
95
- createLexicalComposerContext,
96
- LexicalComposerContext
97
- } from "@lexical/react/LexicalComposerContext";
98
-
99
- // src/components/editor/themes/editor-theme.ts
100
- init_react_shim();
101
- var theme = {
102
- code: `
103
- bg-slate-50 dark:bg-[#0c1017] text-slate-900 dark:text-slate-100 border border-slate-200 dark:border-slate-800/80
104
- rounded-xl my-4 text-[13px] font-mono leading-[1.65]
105
- overflow-x-auto relative group shadow-sm block line-code not-prose
106
- `,
107
- codeHighlight: {
108
- atrule: "PlaygroundEditorTheme__tokenAttr",
109
- attr: "PlaygroundEditorTheme__tokenAttr",
110
- boolean: "PlaygroundEditorTheme__tokenProperty",
111
- builtin: "PlaygroundEditorTheme__tokenSelector",
112
- cdata: "PlaygroundEditorTheme__tokenComment",
113
- char: "PlaygroundEditorTheme__tokenSelector",
114
- class: "PlaygroundEditorTheme__tokenFunction",
115
- "class-name": "PlaygroundEditorTheme__tokenFunction",
116
- comment: "PlaygroundEditorTheme__tokenComment",
117
- constant: "PlaygroundEditorTheme__tokenProperty",
118
- deleted: "PlaygroundEditorTheme__tokenProperty",
119
- doctype: "PlaygroundEditorTheme__tokenComment",
120
- entity: "PlaygroundEditorTheme__tokenOperator",
121
- function: "PlaygroundEditorTheme__tokenFunction",
122
- important: "PlaygroundEditorTheme__tokenVariable",
123
- inserted: "PlaygroundEditorTheme__tokenSelector",
124
- keyword: "PlaygroundEditorTheme__tokenAttr",
125
- namespace: "PlaygroundEditorTheme__tokenVariable",
126
- number: "PlaygroundEditorTheme__tokenProperty",
127
- operator: "PlaygroundEditorTheme__tokenOperator",
128
- prolog: "PlaygroundEditorTheme__tokenComment",
129
- property: "PlaygroundEditorTheme__tokenProperty",
130
- punctuation: "PlaygroundEditorTheme__tokenPunctuation",
131
- regex: "PlaygroundEditorTheme__tokenVariable",
132
- selector: "PlaygroundEditorTheme__tokenSelector",
133
- string: "PlaygroundEditorTheme__tokenSelector",
134
- symbol: "PlaygroundEditorTheme__tokenProperty",
135
- tag: "PlaygroundEditorTheme__tokenProperty",
136
- url: "PlaygroundEditorTheme__tokenOperator",
137
- variable: "PlaygroundEditorTheme__tokenVariable"
138
- },
139
- embedBlock: {
140
- base: "PlaygroundEditorTheme__embedBlock",
141
- focus: "PlaygroundEditorTheme__embedBlockFocus"
142
- },
143
- list: {
144
- checklist: "PlaygroundEditorTheme__checklist",
145
- listitem: "PlaygroundEditorTheme__listItem",
146
- listitemChecked: "PlaygroundEditorTheme__listItemChecked",
147
- listitemUnchecked: "PlaygroundEditorTheme__listItemUnchecked",
148
- nested: {
149
- listitem: "PlaygroundEditorTheme__nestedListItem"
150
- },
151
- olDepth: [
152
- "PlaygroundEditorTheme__ol1 ",
153
- "PlaygroundEditorTheme__ol2",
154
- "PlaygroundEditorTheme__ol3",
155
- "PlaygroundEditorTheme__ol4",
156
- "PlaygroundEditorTheme__ol5"
157
- ],
158
- ulDepth: [
159
- "PlaygroundEditorTheme__ul1",
160
- "PlaygroundEditorTheme__ul2",
161
- "PlaygroundEditorTheme__ul3",
162
- "PlaygroundEditorTheme__ul4",
163
- "PlaygroundEditorTheme__ul5"
164
- ],
165
- ul: "ul",
166
- ol: "ol"
167
- },
168
- paragraph: "leading-7 mb-3",
169
- link: `underline cursor-pointer text-blue-600 after:content-['_\u2197']`,
170
- hr: "w-full my-6 border-t border-border",
171
- table: "PlaygroundEditorTheme__table not-prose",
172
- tableCell: "PlaygroundEditorTheme__tableCell",
173
- tableCellActionButton: "PlaygroundEditorTheme__tableCellActionButton",
174
- tableCellActionButtonContainer: "PlaygroundEditorTheme__tableCellActionButtonContainer",
175
- tableCellHeader: "PlaygroundEditorTheme__tableCellHeader",
176
- tableCellResizer: "PlaygroundEditorTheme__tableCellResizer",
177
- tableCellSelected: "PlaygroundEditorTheme__tableCellSelected",
178
- tableRowStriping: "PlaygroundEditorTheme__tableRowStriping",
179
- tableScrollableWrapper: "PlaygroundEditorTheme__tableScrollableWrapper",
180
- tableSelected: "PlaygroundEditorTheme__tableSelected",
181
- tableSelection: "PlaygroundEditorTheme__tableSelection",
182
- layoutContainer: "grid gap-[10px] my-[10px] ",
183
- 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",
184
- heading: {
185
- h1: "scroll-m-20 text-3xl sm:text-4xl font-extrabold tracking-tight mt-6 mb-3 text-foreground",
186
- 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",
187
- h3: "scroll-m-20 text-xl font-semibold tracking-tight mt-5 mb-2 text-foreground",
188
- h4: "scroll-m-20 text-xl font-semibold tracking-tight",
189
- h5: "text-lg font-bold",
190
- h6: "text-sm font-bold"
191
- },
192
- quote: "my-4 border-l-4 border-purple-500 pl-4 py-1.5 italic bg-purple-500/5 text-muted-foreground rounded-r",
193
- text: {
194
- bold: "font-bold",
195
- capitalize: "capitalize",
196
- 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",
197
- italic: "italic ",
198
- lowercase: "lowercase",
199
- strikethrough: "line-through",
200
- underline: "underline",
201
- underlineStrikethrough: "underline line-through",
202
- uppercase: "uppercase"
203
- }
204
- };
205
- var editor_theme_default = theme;
206
-
207
- // src/core/react/context.tsx
208
- import { Fragment, jsx } from "react/jsx-runtime";
209
- var NotiqContext = createContext({
210
- editor: null
211
- });
212
- function useNotiqContext() {
213
- const context = useContext(NotiqContext);
214
- if (!context || !context.editor) {
215
- throw new Error(
216
- "[Notiq]: useNotiqContext must be used within a <NotiqProvider /> with a valid editor instance."
217
- );
218
- }
219
- return { editor: context.editor };
220
- }
221
- function NotiqProvider({
222
- editor,
223
- theme: customTheme,
224
- children
225
- }) {
226
- const activeTheme = customTheme || editor_theme_default;
227
- const lexicalContext = useMemo(() => {
228
- return createLexicalComposerContext(null, activeTheme);
229
- }, [activeTheme]);
230
- const value = useMemo(() => ({ editor }), [editor]);
231
- if (!editor) {
232
- return /* @__PURE__ */ jsx(Fragment, { children });
233
- }
234
- return /* @__PURE__ */ jsx(LexicalComposerContext.Provider, { value: [editor.lexical, lexicalContext], children: /* @__PURE__ */ jsx(NotiqContext.Provider, { value, children }) });
235
- }
236
-
237
- // src/core/react/useNotiq.ts
238
- init_react_shim();
239
- import { useEffect, useState, useRef } from "react";
240
-
241
- // src/core/editor.ts
242
- init_react_shim();
243
- import {
244
- createEditor as createLexicalEditor,
245
- $getRoot,
246
- $getSelection,
247
- $createParagraphNode,
248
- $isRangeSelection,
249
- $isElementNode
250
- } from "lexical";
251
- import { $generateHtmlFromNodes } from "@lexical/html";
252
- import { $convertToMarkdownString } from "@lexical/markdown";
253
-
254
- // src/core/chain.ts
255
- init_react_shim();
256
- function createCommandChain(editor, lexical, commands, isDryRun = false) {
257
- const queue = [];
258
- const handler = {
259
- get(_target, prop) {
260
- if (prop === "run") {
261
- return () => {
262
- if (isDryRun) {
263
- return queue.every((fn) => {
264
- try {
265
- return fn();
266
- } catch (e) {
267
- return false;
268
- }
269
- });
270
- }
271
- let allSuccessful = true;
272
- lexical.update(
273
- () => {
274
- for (const fn of queue) {
275
- try {
276
- const res = fn();
277
- if (res === false) {
278
- allSuccessful = false;
279
- }
280
- } catch (err) {
281
- console.error("[Notiq Chain Error]:", err);
282
- allSuccessful = false;
283
- }
284
- }
285
- },
286
- { discrete: true }
287
- );
288
- return allSuccessful;
289
- };
290
- }
291
- if (prop in commands) {
292
- return (...args) => {
293
- const commandFactory = commands[prop];
294
- queue.push(() => {
295
- const runner = commandFactory(...args);
296
- return runner({ editor, lexical });
297
- });
298
- return proxy;
299
- };
300
- }
301
- if (prop === "focus") {
302
- return (position) => {
303
- queue.push(() => {
304
- editor.focus(position);
305
- return true;
306
- });
307
- return proxy;
308
- };
309
- }
310
- if (prop === "blur") {
311
- return () => {
312
- queue.push(() => {
313
- editor.blur();
314
- return true;
315
- });
316
- return proxy;
317
- };
318
- }
319
- return () => proxy;
320
- }
321
- };
322
- const proxy = new Proxy({}, handler);
323
- return proxy;
324
- }
325
- function createCanCommands(editor, lexical, commands) {
326
- const handler = {
327
- get(_target, prop) {
328
- if (prop in commands) {
329
- return (...args) => {
330
- try {
331
- const runner = commands[prop](...args);
332
- return runner({ editor, lexical });
333
- } catch (e) {
334
- return false;
335
- }
336
- };
337
- }
338
- return () => true;
339
- }
340
- };
341
- return new Proxy({}, handler);
342
- }
343
-
344
- // src/core/extension.ts
345
- init_react_shim();
346
- var Extension = class _Extension {
347
- constructor(config, options) {
348
- this.subExtensions = [];
349
- this.name = config.name;
350
- this.config = config;
351
- this.options = __spreadValues(__spreadValues({}, config.defaultOptions || {}), options || {});
352
- this.storage = __spreadValues({}, config.defaultStorage || {});
353
- }
354
- static create(config) {
355
- const ext = new _Extension(config);
356
- if (config.addExtensions) {
357
- ext.subExtensions = config.addExtensions();
358
- }
359
- return ext;
360
- }
361
- configure(options) {
362
- const nextExt = new _Extension(this.config, __spreadValues(__spreadValues({}, this.options), options));
363
- nextExt.subExtensions = this.subExtensions.map((sub) => sub.configure());
364
- return nextExt;
365
- }
366
- extend(extendedConfig) {
367
- const mergedConfig = __spreadProps(__spreadValues(__spreadValues({}, this.config), extendedConfig), {
368
- name: extendedConfig.name || this.name,
369
- defaultOptions: __spreadValues(__spreadValues({}, this.config.defaultOptions || {}), extendedConfig.defaultOptions || {}),
370
- defaultStorage: __spreadValues(__spreadValues({}, this.config.defaultStorage || {}), extendedConfig.defaultStorage || {})
371
- });
372
- return new _Extension(mergedConfig);
373
- }
374
- getNodes(context) {
375
- const directNodes = this.config.nodes ? this.config.nodes(context) : [];
376
- const subNodes = this.subExtensions.flatMap(
377
- (sub) => sub.getNodes(__spreadProps(__spreadValues({}, context), { options: sub.options, storage: sub.storage }))
378
- );
379
- return [...directNodes, ...subNodes];
380
- }
381
- getPlugins(context) {
382
- const directPlugins = this.config.plugins ? this.config.plugins(context) : [];
383
- const subPlugins = this.subExtensions.flatMap(
384
- (sub) => sub.getPlugins(__spreadProps(__spreadValues({}, context), { options: sub.options, storage: sub.storage }))
385
- );
386
- return [...directPlugins, ...subPlugins];
387
- }
388
- getCommands(context) {
389
- let commands = this.config.addCommands ? this.config.addCommands(context) : {};
390
- for (const sub of this.subExtensions) {
391
- commands = __spreadValues(__spreadValues({}, commands), sub.getCommands(__spreadProps(__spreadValues({}, context), { options: sub.options, storage: sub.storage })));
392
- }
393
- return commands;
394
- }
395
- getKeyboardShortcuts(context) {
396
- let shortcuts = this.config.addKeyboardShortcuts ? this.config.addKeyboardShortcuts(context) : {};
397
- for (const sub of this.subExtensions) {
398
- shortcuts = __spreadValues(__spreadValues({}, shortcuts), sub.getKeyboardShortcuts(__spreadProps(__spreadValues({}, context), {
399
- options: sub.options,
400
- storage: sub.storage
401
- })));
402
- }
403
- return shortcuts;
404
- }
405
- };
406
-
407
- // src/core/editor.ts
408
- import { $isHeadingNode, registerRichText } from "@lexical/rich-text";
409
- import { $isListNode } from "@lexical/list";
410
- import { $isCodeNode } from "@lexical/code";
411
- var NotiqEditorImpl = class {
412
- constructor(options = {}, customLexical) {
413
- this.storage = {};
414
- this.commands = {};
415
- this.listeners = /* @__PURE__ */ new Map();
416
- this.unregisterListeners = [];
417
- this.rawCommands = {};
418
- this._isFocused = false;
419
- this.handleFocus = () => {
420
- this._isFocused = true;
421
- this.emit("focus");
422
- if (this.options.onFocus) {
423
- this.options.onFocus({ editor: this });
424
- }
425
- };
426
- this.handleBlur = () => {
427
- this._isFocused = false;
428
- this.emit("blur");
429
- if (this.options.onBlur) {
430
- this.options.onBlur({ editor: this });
431
- }
432
- };
433
- this.options = __spreadValues({
434
- editable: true,
435
- autofocus: false
436
- }, options);
437
- const extensions = (options.extensions || []).map(
438
- (ext) => ext instanceof Extension ? ext : Extension.create(ext)
439
- );
440
- this.extensions = extensions;
441
- const allNodes = [];
442
- for (const ext of extensions) {
443
- this.storage[ext.name] = ext.storage;
444
- const nodes = ext.getNodes({
445
- editor: this,
446
- lexical: null,
447
- options: ext.options,
448
- storage: ext.storage
449
- });
450
- allNodes.push(...nodes);
451
- }
452
- if (customLexical) {
453
- this.lexical = customLexical;
454
- } else {
455
- this.lexical = createLexicalEditor({
456
- nodes: allNodes,
457
- editable: this.options.editable,
458
- onError: (err) => console.error("[Notiq Editor Core Error]:", err)
459
- });
460
- }
461
- try {
462
- this.unregisterListeners.push(registerRichText(this.lexical));
463
- } catch (e) {
464
- }
465
- this.lexical.update(
466
- () => {
467
- const root = $getRoot();
468
- if (root.isEmpty()) {
469
- root.append($createParagraphNode());
470
- }
471
- },
472
- { discrete: true }
473
- );
474
- for (const ext of extensions) {
475
- const extCommands = ext.getCommands({
476
- editor: this,
477
- lexical: this.lexical,
478
- options: ext.options,
479
- storage: ext.storage
480
- });
481
- for (const [name, fn] of Object.entries(extCommands)) {
482
- this.rawCommands[name] = fn;
483
- this.commands[name] = (...args) => {
484
- let success = false;
485
- this.lexical.update(
486
- () => {
487
- success = fn(...args)({ editor: this, lexical: this.lexical });
488
- },
489
- { discrete: true }
490
- );
491
- return success;
492
- };
493
- }
494
- }
495
- this.setupListeners();
496
- if (this.options.content) {
497
- this.setContent(this.options.content, { discrete: true, emitUpdate: false });
498
- }
499
- if (this.options.autofocus) {
500
- setTimeout(() => {
501
- this.focus(this.options.autofocus);
502
- }, 0);
503
- }
504
- for (const ext of extensions) {
505
- if (ext.config.onCreate) {
506
- ext.config.onCreate({
507
- editor: this,
508
- lexical: this.lexical,
509
- options: ext.options,
510
- storage: ext.storage
511
- });
512
- }
513
- }
514
- }
515
- get isEditable() {
516
- return this.lexical.isEditable();
517
- }
518
- get isFocused() {
519
- return this._isFocused;
520
- }
521
- setupListeners() {
522
- const unregisterUpdate = this.lexical.registerUpdateListener(
523
- ({ editorState, dirtyElements, dirtyLeaves }) => {
524
- this.emit("transaction");
525
- if (dirtyElements.size > 0 || dirtyLeaves.size > 0) {
526
- this.emit("update");
527
- if (this.options.onUpdate) {
528
- this.options.onUpdate({ editor: this });
529
- }
530
- }
531
- }
532
- );
533
- const unregisterRoot = this.lexical.registerRootListener(
534
- (rootElement, prevRootElement) => {
535
- if (prevRootElement) {
536
- prevRootElement.removeEventListener("focus", this.handleFocus);
537
- prevRootElement.removeEventListener("blur", this.handleBlur);
538
- }
539
- if (rootElement) {
540
- rootElement.addEventListener("focus", this.handleFocus);
541
- rootElement.addEventListener("blur", this.handleBlur);
542
- }
543
- }
544
- );
545
- this.unregisterListeners.push(unregisterUpdate, unregisterRoot);
546
- }
547
- chain() {
548
- return createCommandChain(this, this.lexical, this.rawCommands);
549
- }
550
- can() {
551
- return createCanCommands(this, this.lexical, this.rawCommands);
552
- }
553
- isActive(name, attributes) {
554
- let active = false;
555
- this.lexical.getEditorState().read(() => {
556
- const selection = $getSelection();
557
- if (!$isRangeSelection(selection)) {
558
- return;
559
- }
560
- const textFormats = [
561
- "bold",
562
- "italic",
563
- "underline",
564
- "strikethrough",
565
- "code",
566
- "subscript",
567
- "superscript",
568
- "highlight"
569
- ];
570
- if (textFormats.includes(name)) {
571
- active = selection.hasFormat(name);
572
- return;
573
- }
574
- const anchorNode = selection.anchor.getNode();
575
- const element = anchorNode.getKey() === "root" ? anchorNode : $isElementNode(anchorNode) ? anchorNode : anchorNode.getTopLevelElementOrThrow();
576
- if (name === "heading" && $isHeadingNode(element)) {
577
- if (attributes && attributes.level) {
578
- active = element.getTag() === `h${attributes.level}`;
579
- } else {
580
- active = true;
581
- }
582
- return;
583
- }
584
- if (name === "codeBlock" && $isCodeNode(element)) {
585
- if (attributes && attributes.language) {
586
- active = element.getLanguage() === attributes.language;
587
- } else {
588
- active = true;
589
- }
590
- return;
591
- }
592
- if (name === "bulletList" && $isListNode(element)) {
593
- active = element.getListType() === "bullet";
594
- return;
595
- }
596
- if (name === "orderedList" && $isListNode(element)) {
597
- active = element.getListType() === "number";
598
- return;
599
- }
600
- if (name === "checkList" && $isListNode(element)) {
601
- active = element.getListType() === "check";
602
- return;
603
- }
604
- if (name === "paragraph" && element.getType() === "paragraph") {
605
- active = true;
606
- return;
607
- }
608
- if (name === "quote" && element.getType() === "quote") {
609
- active = true;
610
- return;
611
- }
612
- });
613
- return active;
614
- }
615
- setEditable(editable) {
616
- this.lexical.setEditable(editable);
617
- }
618
- focus(position = true) {
619
- this.lexical.update(() => {
620
- const root = $getRoot();
621
- if (root.isEmpty()) {
622
- root.append($createParagraphNode());
623
- }
624
- const firstChild = root.getFirstChild();
625
- const lastChild = root.getLastChild();
626
- if (position === "start" && firstChild) {
627
- firstChild.selectStart();
628
- } else if (position === "all") {
629
- root.select(0, root.getChildrenSize());
630
- } else if (lastChild) {
631
- lastChild.selectEnd();
632
- } else {
633
- root.select(0, 0);
634
- }
635
- });
636
- const rootElement = this.lexical.getRootElement();
637
- if (rootElement) {
638
- rootElement.focus();
639
- }
640
- }
641
- blur() {
642
- const root = this.lexical.getRootElement();
643
- if (root) {
644
- root.blur();
645
- }
646
- }
647
- getJSON() {
648
- return this.lexical.getEditorState().toJSON();
649
- }
650
- getHTML() {
651
- let html = "";
652
- this.lexical.getEditorState().read(() => {
653
- html = $generateHtmlFromNodes(this.lexical, null);
654
- });
655
- return html;
656
- }
657
- getMarkdown() {
658
- let md = "";
659
- this.lexical.getEditorState().read(() => {
660
- md = $convertToMarkdownString(NOTIQ_TRANSFORMERS);
661
- });
662
- return md;
663
- }
664
- getText() {
665
- let text = "";
666
- this.lexical.getEditorState().read(() => {
667
- text = $getRoot().getTextContent();
668
- });
669
- return text;
670
- }
671
- setContent(content, options = {}) {
672
- if (typeof content === "object" && content !== null) {
673
- this.lexical.setEditorState(
674
- this.lexical.parseEditorState(JSON.stringify(content))
675
- );
676
- } else if (typeof content === "string") {
677
- const format = detectContentFormat(content);
678
- importContentToEditor(this.lexical, content, format, "replace");
679
- }
680
- if (options.emitUpdate !== false) {
681
- this.emit("update");
682
- }
683
- }
684
- clearContent(options = {}) {
685
- this.lexical.update(
686
- () => {
687
- const root = $getRoot();
688
- root.clear();
689
- },
690
- { discrete: true }
691
- );
692
- if (options.emitUpdate !== false) {
693
- this.emit("update");
694
- }
695
- }
696
- on(event, listener) {
697
- if (!this.listeners.has(event)) {
698
- this.listeners.set(event, /* @__PURE__ */ new Set());
699
- }
700
- this.listeners.get(event).add(listener);
701
- return () => this.off(event, listener);
702
- }
703
- off(event, listener) {
704
- const set = this.listeners.get(event);
705
- if (set) {
706
- set.delete(listener);
707
- }
708
- }
709
- emit(event, data) {
710
- const set = this.listeners.get(event);
711
- if (set) {
712
- const payload = __spreadValues({
713
- editor: this
714
- }, data || {});
715
- set.forEach((listener) => {
716
- try {
717
- listener(payload);
718
- } catch (err) {
719
- console.error(`[Notiq Event Error (${event})]:`, err);
720
- }
721
- });
722
- }
723
- }
724
- destroy() {
725
- this.unregisterListeners.forEach((fn) => fn());
726
- this.unregisterListeners = [];
727
- this.emit("destroy");
728
- this.listeners.clear();
729
- }
730
- };
731
- function createNotiqEditor(options = {}) {
732
- return new NotiqEditorImpl(options);
733
- }
734
-
735
- // src/core/react/useNotiq.ts
736
- function useNotiq(options = {}, deps = []) {
737
- const [editor, setEditor] = useState(null);
738
- const optionsRef = useRef(options);
739
- optionsRef.current = options;
740
- useEffect(() => {
741
- const instance = createNotiqEditor(optionsRef.current);
742
- setEditor(instance);
743
- return () => {
744
- instance.destroy();
745
- setEditor(null);
746
- };
747
- }, deps);
748
- const [, setTick] = useState(0);
749
- useEffect(() => {
750
- if (!editor) return;
751
- const unlistenTransaction = editor.on("transaction", () => {
752
- setTick((t) => (t + 1) % 1e6);
753
- });
754
- const unlistenSelection = editor.on("selectionUpdate", () => {
755
- setTick((t) => (t + 1) % 1e6);
756
- });
757
- const unlistenFocus = editor.on("focus", () => {
758
- setTick((t) => (t + 1) % 1e6);
759
- });
760
- const unlistenBlur = editor.on("blur", () => {
761
- setTick((t) => (t + 1) % 1e6);
762
- });
763
- return () => {
764
- unlistenTransaction();
765
- unlistenSelection();
766
- unlistenFocus();
767
- unlistenBlur();
768
- };
769
- }, [editor]);
770
- return editor;
771
- }
772
-
773
- // src/core/react/NotiqContent.tsx
774
- init_react_shim();
775
- import { useContext as useContext2, useMemo as useMemo2 } from "react";
776
- import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
777
- import { ContentEditable } from "@lexical/react/LexicalContentEditable";
778
- import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
779
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
780
- function InnerContent({
781
- editor,
782
- className,
783
- containerClassName,
784
- placeholder,
785
- renderPlugins = true,
786
- children
787
- }) {
788
- const extensionPlugins = useMemo2(() => {
789
- if (!renderPlugins || !editor.extensions) return [];
790
- return editor.extensions.flatMap(
791
- (ext) => typeof ext.getPlugins === "function" ? ext.getPlugins({
792
- editor,
793
- lexical: editor.lexical,
794
- options: ext.options,
795
- storage: ext.storage
796
- }) : []
797
- );
798
- }, [editor, renderPlugins]);
799
- const resolvedPlaceholder = placeholder !== void 0 ? placeholder : editor.options.placeholder;
800
- 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;
801
- return /* @__PURE__ */ jsxs("div", { className: cn("relative w-full", containerClassName), children: [
802
- /* @__PURE__ */ jsx2(
803
- RichTextPlugin,
804
- {
805
- contentEditable: /* @__PURE__ */ jsx2(
806
- ContentEditable,
807
- {
808
- className: cn(
809
- "notiq-content min-h-[160px] outline-none text-foreground p-4 text-base leading-relaxed",
810
- className
811
- )
812
- }
813
- ),
814
- placeholder: placeholderElement,
815
- ErrorBoundary: LexicalErrorBoundary
816
- }
817
- ),
818
- extensionPlugins.map((PluginComponent, index) => /* @__PURE__ */ jsx2(PluginComponent, {}, `ext-plugin-${index}`)),
819
- children
820
- ] });
821
- }
822
- function NotiqContent({
823
- editor: propEditor,
824
- className,
825
- containerClassName,
826
- placeholder,
827
- renderPlugins,
828
- children
829
- }) {
830
- const context = useContext2(NotiqContext);
831
- const activeEditor = propEditor || context.editor;
832
- if (!activeEditor) {
833
- return null;
834
- }
835
- if (context.editor === activeEditor) {
836
- return /* @__PURE__ */ jsx2(
837
- InnerContent,
838
- {
839
- editor: activeEditor,
840
- className,
841
- containerClassName,
842
- placeholder,
843
- renderPlugins,
844
- children
845
- }
846
- );
847
- }
848
- return /* @__PURE__ */ jsx2(NotiqProvider, { editor: activeEditor, children: /* @__PURE__ */ jsx2(
849
- InnerContent,
850
- {
851
- editor: activeEditor,
852
- className,
853
- containerClassName,
854
- placeholder,
855
- renderPlugins,
856
- children
857
- }
858
- ) });
859
- }
860
-
861
- // src/core/react/BubbleMenu.tsx
862
- init_react_shim();
863
- import { useEffect as useEffect2, useState as useState2, useRef as useRef2, useContext as useContext3 } from "react";
864
- import { createPortal } from "react-dom";
865
- import { $getSelection as $getSelection2, $isRangeSelection as $isRangeSelection2 } from "lexical";
866
- import { Sparkles } from "lucide-react";
867
- import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
868
- function BubbleMenu({
869
- editor: propEditor,
870
- className,
871
- children,
872
- shouldShow,
873
- offset = 8,
874
- showAskAI = true
875
- }) {
876
- var _a;
877
- const context = useContext3(NotiqContext);
878
- const editor = propEditor || context.editor;
879
- const menuRef = useRef2(null);
880
- const [coords, setCoords] = useState2(null);
881
- const [visible, setVisible] = useState2(false);
882
- useEffect2(() => {
883
- if (!editor) return;
884
- const updatePosition = () => {
885
- var _a2, _b;
886
- let isVisible = false;
887
- editor.lexical.getEditorState().read(() => {
888
- const selection = $getSelection2();
889
- if ($isRangeSelection2(selection) && !selection.isCollapsed()) {
890
- if (shouldShow) {
891
- isVisible = shouldShow({ editor });
892
- } else {
893
- isVisible = selection.getTextContent().trim().length > 0;
894
- }
895
- }
896
- });
897
- if (!isVisible) {
898
- setVisible(false);
899
- return;
900
- }
901
- const domSelection = window.getSelection();
902
- if (!domSelection || domSelection.rangeCount === 0) {
903
- setVisible(false);
904
- return;
905
- }
906
- const range = domSelection.getRangeAt(0);
907
- const rect = range.getBoundingClientRect();
908
- if (rect.width === 0 && rect.height === 0) {
909
- setVisible(false);
910
- return;
911
- }
912
- const menuWidth = ((_a2 = menuRef.current) == null ? void 0 : _a2.offsetWidth) || 240;
913
- const menuHeight = ((_b = menuRef.current) == null ? void 0 : _b.offsetHeight) || 40;
914
- let left = rect.left + rect.width / 2 - menuWidth / 2;
915
- left = Math.max(16, Math.min(window.innerWidth - menuWidth - 16, left));
916
- let top = rect.top - menuHeight - offset;
917
- if (top < 10) {
918
- top = rect.bottom + offset;
919
- }
920
- setCoords({ top, left });
921
- setVisible(true);
922
- };
923
- const unregisterListener = editor.lexical.registerUpdateListener(() => {
924
- updatePosition();
925
- });
926
- const handleSelectionChange = () => {
927
- updatePosition();
928
- };
929
- document.addEventListener("selectionchange", handleSelectionChange);
930
- window.addEventListener("resize", handleSelectionChange);
931
- window.addEventListener("scroll", handleSelectionChange, true);
932
- return () => {
933
- unregisterListener();
934
- document.removeEventListener("selectionchange", handleSelectionChange);
935
- window.removeEventListener("resize", handleSelectionChange);
936
- window.removeEventListener("scroll", handleSelectionChange, true);
937
- };
938
- }, [editor, shouldShow, offset]);
939
- if (!visible || !coords) {
940
- return null;
941
- }
942
- return createPortal(
943
- /* @__PURE__ */ jsxs2(
944
- "div",
945
- {
946
- ref: menuRef,
947
- style: {
948
- position: "fixed",
949
- top: `${coords.top}px`,
950
- left: `${coords.left}px`,
951
- zIndex: 50
952
- },
953
- className: cn(
954
- "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",
955
- className
956
- ),
957
- onMouseDown: (e) => {
958
- e.preventDefault();
959
- },
960
- children: [
961
- showAskAI && typeof ((_a = editor == null ? void 0 : editor.commands) == null ? void 0 : _a.openAICommandBar) === "function" && /* @__PURE__ */ jsxs2(Fragment2, { children: [
962
- /* @__PURE__ */ jsxs2(
963
- "button",
964
- {
965
- type: "button",
966
- onClick: () => editor.commands.openAICommandBar(),
967
- 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",
968
- title: "Ask AI (\u2318K)",
969
- children: [
970
- /* @__PURE__ */ jsx3(Sparkles, { className: "w-3.5 h-3.5" }),
971
- /* @__PURE__ */ jsx3("span", { children: "Ask AI" }),
972
- /* @__PURE__ */ jsx3("kbd", { className: "text-[10px] font-mono opacity-60", children: "\u2318K" })
973
- ]
974
- }
975
- ),
976
- /* @__PURE__ */ jsx3("div", { className: "w-[1px] h-4 bg-border/60 mx-0.5" })
977
- ] }),
978
- children
979
- ]
980
- }
981
- ),
982
- document.body
983
- );
984
- }
985
-
986
- // src/core/react/FloatingMenu.tsx
987
- init_react_shim();
988
- import { useEffect as useEffect3, useState as useState3, useRef as useRef3, useContext as useContext4 } from "react";
989
- import { createPortal as createPortal2 } from "react-dom";
990
- import { $getSelection as $getSelection3, $isRangeSelection as $isRangeSelection3, $isElementNode as $isElementNode2 } from "lexical";
991
- import { jsx as jsx4 } from "react/jsx-runtime";
992
- function FloatingMenu({
993
- editor: propEditor,
994
- className,
995
- children,
996
- shouldShow,
997
- offset = 8
998
- }) {
999
- const context = useContext4(NotiqContext);
1000
- const editor = propEditor || context.editor;
1001
- const menuRef = useRef3(null);
1002
- const [coords, setCoords] = useState3(null);
1003
- const [visible, setVisible] = useState3(false);
1004
- useEffect3(() => {
1005
- if (!editor) return;
1006
- const updatePosition = () => {
1007
- var _a, _b;
1008
- let isVisible = false;
1009
- let targetElementKey = null;
1010
- editor.lexical.getEditorState().read(() => {
1011
- const selection = $getSelection3();
1012
- if ($isRangeSelection3(selection) && selection.isCollapsed()) {
1013
- const anchorNode = selection.anchor.getNode();
1014
- const element = anchorNode.getKey() === "root" ? null : $isElementNode2(anchorNode) ? anchorNode : anchorNode.getTopLevelElement();
1015
- if (element) {
1016
- const text = element.getTextContent().trim();
1017
- if (shouldShow) {
1018
- isVisible = shouldShow({ editor });
1019
- } else {
1020
- isVisible = text.length === 0;
1021
- }
1022
- if (isVisible) {
1023
- targetElementKey = element.getKey();
1024
- }
1025
- }
1026
- }
1027
- });
1028
- if (!isVisible || !targetElementKey) {
1029
- setVisible(false);
1030
- return;
1031
- }
1032
- const domElement = editor.lexical.getElementByKey(targetElementKey);
1033
- if (!domElement) {
1034
- setVisible(false);
1035
- return;
1036
- }
1037
- const rect = domElement.getBoundingClientRect();
1038
- const menuWidth = ((_a = menuRef.current) == null ? void 0 : _a.offsetWidth) || 36;
1039
- const menuHeight = ((_b = menuRef.current) == null ? void 0 : _b.offsetHeight) || 36;
1040
- let left = rect.left - menuWidth - offset;
1041
- if (left < 8) {
1042
- left = rect.left + offset;
1043
- }
1044
- const top = rect.top + (rect.height - menuHeight) / 2;
1045
- setCoords({ top, left });
1046
- setVisible(true);
1047
- };
1048
- const unregisterListener = editor.lexical.registerUpdateListener(() => {
1049
- updatePosition();
1050
- });
1051
- const handleSelectionChange = () => {
1052
- updatePosition();
1053
- };
1054
- document.addEventListener("selectionchange", handleSelectionChange);
1055
- window.addEventListener("resize", handleSelectionChange);
1056
- window.addEventListener("scroll", handleSelectionChange, true);
1057
- return () => {
1058
- unregisterListener();
1059
- document.removeEventListener("selectionchange", handleSelectionChange);
1060
- window.removeEventListener("resize", handleSelectionChange);
1061
- window.removeEventListener("scroll", handleSelectionChange, true);
1062
- };
1063
- }, [editor, shouldShow, offset]);
1064
- if (!visible || !coords) {
1065
- return null;
1066
- }
1067
- return createPortal2(
1068
- /* @__PURE__ */ jsx4(
1069
- "div",
1070
- {
1071
- ref: menuRef,
1072
- style: {
1073
- position: "fixed",
1074
- top: `${coords.top}px`,
1075
- left: `${coords.left}px`,
1076
- zIndex: 50
1077
- },
1078
- className: cn(
1079
- "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",
1080
- className
1081
- ),
1082
- onMouseDown: (e) => {
1083
- e.preventDefault();
1084
- },
1085
- children
1086
- }
1087
- ),
1088
- document.body
1089
- );
1090
- }
1091
-
1092
- // src/core/react/NotiqEditor.tsx
1093
- init_react_shim();
1094
- import { useEffect as useEffect4, useMemo as useMemo3, useRef as useRef4 } from "react";
1095
-
1096
- // src/core/extensions/nodes-and-marks.ts
1097
- init_react_shim();
1098
- import {
1099
- UNDO_COMMAND,
1100
- REDO_COMMAND,
1101
- $getRoot as $getRoot2,
1102
- $getSelection as $getSelection4,
1103
- $isRangeSelection as $isRangeSelection4,
1104
- $createParagraphNode as $createParagraphNode2,
1105
- ParagraphNode
1106
- } from "lexical";
1107
- import {
1108
- HeadingNode,
1109
- QuoteNode,
1110
- $createHeadingNode,
1111
- $createQuoteNode
1112
- } from "@lexical/rich-text";
1113
- import {
1114
- ListNode,
1115
- ListItemNode,
1116
- INSERT_UNORDERED_LIST_COMMAND,
1117
- INSERT_ORDERED_LIST_COMMAND,
1118
- INSERT_CHECK_LIST_COMMAND,
1119
- REMOVE_LIST_COMMAND
1120
- } from "@lexical/list";
1121
- import { CodeNode, CodeHighlightNode, $createCodeNode } from "@lexical/code";
1122
- import { $setBlocksType } from "@lexical/selection";
1123
- function ensureRangeSelection() {
1124
- let selection = $getSelection4();
1125
- if (!$isRangeSelection4(selection)) {
1126
- const root = $getRoot2();
1127
- let first = root.getFirstChild();
1128
- if (!first) {
1129
- first = $createParagraphNode2();
1130
- root.append(first);
1131
- }
1132
- if (typeof first.selectStart === "function") {
1133
- first.selectStart();
1134
- } else if (typeof first.select === "function") {
1135
- first.select();
1136
- }
1137
- selection = $getSelection4();
1138
- }
1139
- return $isRangeSelection4(selection) ? selection : null;
1140
- }
1141
- function applyFormat(format) {
1142
- const selection = ensureRangeSelection();
1143
- if (selection) {
1144
- selection.formatText(format);
1145
- return true;
1146
- }
1147
- return false;
1148
- }
1149
- var Bold = Extension.create({
1150
- name: "bold",
1151
- addCommands: () => ({
1152
- toggleBold: () => () => applyFormat("bold")
1153
- }),
1154
- addKeyboardShortcuts: ({ editor }) => ({
1155
- "Mod-b": () => editor.commands.toggleBold()
1156
- })
1157
- });
1158
- var Italic = Extension.create({
1159
- name: "italic",
1160
- addCommands: () => ({
1161
- toggleItalic: () => () => applyFormat("italic")
1162
- }),
1163
- addKeyboardShortcuts: ({ editor }) => ({
1164
- "Mod-i": () => editor.commands.toggleItalic()
1165
- })
1166
- });
1167
- var Underline = Extension.create({
1168
- name: "underline",
1169
- addCommands: () => ({
1170
- toggleUnderline: () => () => applyFormat("underline")
1171
- }),
1172
- addKeyboardShortcuts: ({ editor }) => ({
1173
- "Mod-u": () => editor.commands.toggleUnderline()
1174
- })
1175
- });
1176
- var Strike = Extension.create({
1177
- name: "strike",
1178
- addCommands: () => ({
1179
- toggleStrike: () => () => applyFormat("strikethrough")
1180
- })
1181
- });
1182
- var Code = Extension.create({
1183
- name: "code",
1184
- addCommands: () => ({
1185
- toggleCode: () => () => applyFormat("code")
1186
- })
1187
- });
1188
- var Paragraph = Extension.create({
1189
- name: "paragraph",
1190
- nodes: () => [ParagraphNode],
1191
- addCommands: () => ({
1192
- setParagraph: () => () => {
1193
- const selection = ensureRangeSelection();
1194
- if (selection) {
1195
- $setBlocksType(selection, () => $createParagraphNode2());
1196
- return true;
1197
- }
1198
- return false;
1199
- }
1200
- })
1201
- });
1202
- var Heading = Extension.create({
1203
- name: "heading",
1204
- defaultOptions: {
1205
- levels: [1, 2, 3]
1206
- },
1207
- nodes: () => [HeadingNode],
1208
- addCommands: () => ({
1209
- setHeading: ({ level = 1 }) => () => {
1210
- const selection = ensureRangeSelection();
1211
- if (selection) {
1212
- $setBlocksType(selection, () => $createHeadingNode(`h${level}`));
1213
- return true;
1214
- }
1215
- return false;
1216
- },
1217
- toggleHeading: ({ level = 1 }) => ({ editor }) => {
1218
- if (editor.isActive("heading", { level })) {
1219
- return editor.commands.setParagraph();
1220
- }
1221
- return editor.commands.setHeading({ level });
1222
- }
1223
- })
1224
- });
1225
- var Blockquote = Extension.create({
1226
- name: "blockquote",
1227
- nodes: () => [QuoteNode],
1228
- addCommands: () => ({
1229
- toggleBlockquote: () => ({ editor }) => {
1230
- const selection = $getSelection4();
1231
- if ($isRangeSelection4(selection)) {
1232
- if (editor.isActive("quote")) {
1233
- $setBlocksType(selection, () => $createParagraphNode2());
1234
- } else {
1235
- $setBlocksType(selection, () => $createQuoteNode());
1236
- }
1237
- return true;
1238
- }
1239
- return false;
1240
- }
1241
- })
1242
- });
1243
- var BulletList = Extension.create({
1244
- name: "bulletList",
1245
- nodes: () => [ListNode, ListItemNode],
1246
- addCommands: () => ({
1247
- toggleBulletList: () => ({ editor, lexical }) => {
1248
- if (editor.isActive("bulletList")) {
1249
- lexical.dispatchCommand(REMOVE_LIST_COMMAND, void 0);
1250
- } else {
1251
- lexical.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, void 0);
1252
- }
1253
- return true;
1254
- }
1255
- })
1256
- });
1257
- var OrderedList = Extension.create({
1258
- name: "orderedList",
1259
- nodes: () => [ListNode, ListItemNode],
1260
- addCommands: () => ({
1261
- toggleOrderedList: () => ({ editor, lexical }) => {
1262
- if (editor.isActive("orderedList")) {
1263
- lexical.dispatchCommand(REMOVE_LIST_COMMAND, void 0);
1264
- } else {
1265
- lexical.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, void 0);
1266
- }
1267
- return true;
1268
- }
1269
- })
1270
- });
1271
- var CheckList = Extension.create({
1272
- name: "checkList",
1273
- nodes: () => [ListNode, ListItemNode],
1274
- addCommands: () => ({
1275
- toggleCheckList: () => ({ editor, lexical }) => {
1276
- if (editor.isActive("checkList")) {
1277
- lexical.dispatchCommand(REMOVE_LIST_COMMAND, void 0);
1278
- } else {
1279
- lexical.dispatchCommand(INSERT_CHECK_LIST_COMMAND, void 0);
1280
- }
1281
- return true;
1282
- }
1283
- })
1284
- });
1285
- var CodeBlock = Extension.create({
1286
- name: "codeBlock",
1287
- defaultOptions: {
1288
- defaultLanguage: "javascript"
1289
- },
1290
- nodes: () => [CodeNode, CodeHighlightNode],
1291
- addCommands: ({ options }) => ({
1292
- setCodeBlock: ({ language } = {}) => () => {
1293
- const selection = $getSelection4();
1294
- if ($isRangeSelection4(selection)) {
1295
- $setBlocksType(
1296
- selection,
1297
- () => $createCodeNode(language || options.defaultLanguage)
1298
- );
1299
- return true;
1300
- }
1301
- return false;
1302
- },
1303
- toggleCodeBlock: ({ language } = {}) => ({ editor }) => {
1304
- if (editor.isActive("codeBlock")) {
1305
- return editor.commands.setParagraph();
1306
- }
1307
- return editor.commands.setCodeBlock({ language });
1308
- }
1309
- })
1310
- });
1311
- var History = Extension.create({
1312
- name: "history",
1313
- addCommands: () => ({
1314
- undo: () => ({ lexical }) => {
1315
- lexical.dispatchCommand(UNDO_COMMAND, void 0);
1316
- return true;
1317
- },
1318
- redo: () => ({ lexical }) => {
1319
- lexical.dispatchCommand(REDO_COMMAND, void 0);
1320
- return true;
1321
- }
1322
- }),
1323
- addKeyboardShortcuts: ({ editor }) => ({
1324
- "Mod-z": () => editor.commands.undo(),
1325
- "Mod-y": () => editor.commands.redo(),
1326
- "Shift-Mod-z": () => editor.commands.redo()
1327
- })
1328
- });
1329
- var StarterKit = Extension.create({
1330
- name: "starterKit",
1331
- defaultOptions: {
1332
- bold: true,
1333
- italic: true,
1334
- underline: true,
1335
- strike: true,
1336
- code: true,
1337
- paragraph: true,
1338
- heading: true,
1339
- blockquote: true,
1340
- bulletList: true,
1341
- orderedList: true,
1342
- checkList: true,
1343
- codeBlock: true,
1344
- history: true
1345
- },
1346
- addExtensions: () => {
1347
- return [
1348
- Bold,
1349
- Italic,
1350
- Underline,
1351
- Strike,
1352
- Code,
1353
- Paragraph,
1354
- Heading,
1355
- Blockquote,
1356
- BulletList,
1357
- OrderedList,
1358
- CheckList,
1359
- CodeBlock,
1360
- History
1361
- ];
1362
- }
1363
- });
1364
-
1365
- // src/core/extensions/blocks-kit.ts
1366
- init_react_shim();
1367
- import { $getSelection as $getSelection5, $isRangeSelection as $isRangeSelection5 } from "lexical";
1368
- var Excalidraw = Extension.create({
1369
- name: "excalidraw",
1370
- nodes: () => [ExcalidrawNode],
1371
- addCommands: () => ({
1372
- insertExcalidraw: (data) => ({ lexical }) => {
1373
- lexical.update(() => {
1374
- const selection = $getSelection5();
1375
- if ($isRangeSelection5(selection)) {
1376
- const node = $createExcalidrawNode();
1377
- if (data == null ? void 0 : data.data) {
1378
- node.setData(data.data);
1379
- }
1380
- selection.insertNodes([node]);
1381
- }
1382
- });
1383
- return true;
1384
- }
1385
- })
1386
- });
1387
- var Figma = Extension.create({
1388
- name: "figma",
1389
- nodes: () => [FigmaNode],
1390
- addCommands: () => ({
1391
- insertFigma: (options) => ({ lexical }) => {
1392
- if (!(options == null ? void 0 : options.url)) return false;
1393
- lexical.update(() => {
1394
- const selection = $getSelection5();
1395
- if ($isRangeSelection5(selection)) {
1396
- selection.insertNodes([$createFigmaNode(options.url)]);
1397
- }
1398
- });
1399
- return true;
1400
- }
1401
- })
1402
- });
1403
- var Equation = Extension.create({
1404
- name: "equation",
1405
- nodes: () => [EquationNode],
1406
- addCommands: () => ({
1407
- insertEquation: (options) => ({ lexical }) => {
1408
- if (!(options == null ? void 0 : options.equation)) return false;
1409
- lexical.update(() => {
1410
- const selection = $getSelection5();
1411
- if ($isRangeSelection5(selection)) {
1412
- selection.insertNodes([
1413
- $createEquationNode(options.equation, !!options.inline)
1414
- ]);
1415
- }
1416
- });
1417
- return true;
1418
- }
1419
- })
1420
- });
1421
- var HintBlock = Extension.create({
1422
- name: "hint",
1423
- nodes: () => [Hint],
1424
- addCommands: () => ({
1425
- insertHint: (options) => ({ lexical }) => {
1426
- const variant = (options == null ? void 0 : options.variant) || "info";
1427
- lexical.update(() => {
1428
- const selection = $getSelection5();
1429
- if ($isRangeSelection5(selection)) {
1430
- selection.insertNodes([$createHintNode(variant)]);
1431
- }
1432
- });
1433
- return true;
1434
- }
1435
- })
1436
- });
1437
- var Stepper = Extension.create({
1438
- name: "stepper",
1439
- nodes: () => [StepperNode],
1440
- addCommands: () => ({
1441
- insertStepper: (steps) => ({ lexical }) => {
1442
- lexical.update(() => {
1443
- const selection = $getSelection5();
1444
- if ($isRangeSelection5(selection)) {
1445
- selection.insertNodes([$createStepperNode(steps || [])]);
1446
- }
1447
- });
1448
- return true;
1449
- }
1450
- })
1451
- });
1452
- var Poll = Extension.create({
1453
- name: "poll",
1454
- nodes: () => [PollNode],
1455
- addCommands: () => ({
1456
- insertPoll: (options) => ({ lexical }) => {
1457
- if (!(options == null ? void 0 : options.question)) return false;
1458
- const choices = (options.options || ["Option 1", "Option 2"]).map(
1459
- (t) => createPollOption(t)
1460
- );
1461
- lexical.update(() => {
1462
- const selection = $getSelection5();
1463
- if ($isRangeSelection5(selection)) {
1464
- selection.insertNodes([$createPollNode(options.question, choices)]);
1465
- }
1466
- });
1467
- return true;
1468
- }
1469
- })
1470
- });
1471
- var Image = Extension.create({
1472
- name: "image",
1473
- nodes: () => [ImageNode],
1474
- addCommands: () => ({
1475
- insertImage: (payload) => ({ lexical }) => {
1476
- if (!(payload == null ? void 0 : payload.src)) return false;
1477
- lexical.update(() => {
1478
- const selection = $getSelection5();
1479
- if ($isRangeSelection5(selection)) {
1480
- selection.insertNodes([$createImageNode(payload)]);
1481
- }
1482
- });
1483
- return true;
1484
- }
1485
- })
1486
- });
1487
- var Tweet = Extension.create({
1488
- name: "tweet",
1489
- nodes: () => [TweetNode],
1490
- addCommands: () => ({
1491
- insertTweet: (options) => ({ lexical }) => {
1492
- if (!(options == null ? void 0 : options.tweetId)) return false;
1493
- lexical.update(() => {
1494
- const selection = $getSelection5();
1495
- if ($isRangeSelection5(selection)) {
1496
- selection.insertNodes([$createTweetNode(options.tweetId)]);
1497
- }
1498
- });
1499
- return true;
1500
- }
1501
- })
1502
- });
1503
- var YouTube = Extension.create({
1504
- name: "youtube",
1505
- nodes: () => [YouTubeNode],
1506
- addCommands: () => ({
1507
- insertYouTube: (options) => ({ lexical }) => {
1508
- if (!(options == null ? void 0 : options.videoId)) return false;
1509
- lexical.update(() => {
1510
- const selection = $getSelection5();
1511
- if ($isRangeSelection5(selection)) {
1512
- selection.insertNodes([$createYouTubeNode(options.videoId)]);
1513
- }
1514
- });
1515
- return true;
1516
- }
1517
- })
1518
- });
1519
- var Audio = Extension.create({
1520
- name: "audio",
1521
- nodes: () => [AudioNode],
1522
- addCommands: () => ({
1523
- insertAudio: (payload) => ({ lexical }) => {
1524
- if (!(payload == null ? void 0 : payload.src)) return false;
1525
- lexical.update(() => {
1526
- const selection = $getSelection5();
1527
- if ($isRangeSelection5(selection)) {
1528
- selection.insertNodes([$createAudioNode(payload)]);
1529
- }
1530
- });
1531
- return true;
1532
- }
1533
- })
1534
- });
1535
- var File = Extension.create({
1536
- name: "file",
1537
- nodes: () => [FileNode],
1538
- addCommands: () => ({
1539
- insertFile: (payload) => ({ lexical }) => {
1540
- if (!(payload == null ? void 0 : payload.url)) return false;
1541
- lexical.update(() => {
1542
- const selection = $getSelection5();
1543
- if ($isRangeSelection5(selection)) {
1544
- selection.insertNodes([$createFileNode(payload)]);
1545
- }
1546
- });
1547
- return true;
1548
- }
1549
- })
1550
- });
1551
- var ColumnsLayout = Extension.create({
1552
- name: "columnsLayout",
1553
- nodes: () => [LayoutContainerNode, LayoutItemNode],
1554
- addCommands: () => ({
1555
- setColumns: (columns = 2) => ({ lexical }) => {
1556
- lexical.dispatchCommand(
1557
- INSERT_LAYOUT_COMMAND,
1558
- columns === 2 ? "1fr 1fr" : "1fr 1fr 1fr"
1559
- );
1560
- return true;
1561
- }
1562
- })
1563
- });
1564
- var BlocksKit = Extension.create({
1565
- name: "blocksKit",
1566
- addExtensions: () => [
1567
- Excalidraw,
1568
- Figma,
1569
- Equation,
1570
- HintBlock,
1571
- Stepper,
1572
- Poll,
1573
- Image,
1574
- Tweet,
1575
- YouTube,
1576
- Audio,
1577
- File,
1578
- ColumnsLayout
1579
- ]
1580
- });
1581
-
1582
- // src/core/extensions/copilot-and-collab.ts
1583
- init_react_shim();
1584
- import dynamic from "next/dynamic";
1585
- var InlineCopilotPlugin = dynamic(
1586
- () => import("./InlineCopilotPlugin-PNS5Y6OO.mjs"),
1587
- { ssr: false }
1588
- );
1589
- var CollaborationPlugin = dynamic(
1590
- () => import("./CollaborationPlugin-TIZOQBUT.mjs"),
1591
- { ssr: false }
1592
- );
1593
- var AICommandBarPlugin = dynamic(
1594
- () => import("./AICommandBarPlugin-TADJ3X2Y.mjs"),
1595
- { ssr: false }
1596
- );
1597
- var AICommandBar = Extension.create({
1598
- name: "aiCommandBar",
1599
- plugins: () => [AICommandBarPlugin],
1600
- addCommands: () => ({
1601
- openAICommandBar: (payload) => ({ lexical }) => {
1602
- lexical.dispatchCommand(OPEN_AI_COMMAND_BAR_COMMAND, payload);
1603
- return true;
1604
- }
1605
- })
1606
- });
1607
- var AICopilot = Extension.create({
1608
- name: "aiCopilot",
1609
- defaultOptions: {
1610
- enabled: true
1611
- },
1612
- addExtensions: () => [AICommandBar],
1613
- plugins: ({ options }) => {
1614
- if (options.enabled === false) return [];
1615
- return [InlineCopilotPlugin];
1616
- }
1617
- });
1618
- var Collaboration = Extension.create({
1619
- name: "collaboration",
1620
- defaultOptions: {
1621
- enabled: true
1622
- },
1623
- plugins: ({ options }) => {
1624
- if (options.enabled === false) return [];
1625
- return [CollaborationPlugin];
1626
- }
1627
- });
1628
-
1629
- // src/core/react/NotiqEditor.tsx
1630
- import { LexicalCollaboration } from "@lexical/react/LexicalCollaborationContext";
1631
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
1632
- function NotiqEditor({
1633
- content,
1634
- extensions,
1635
- editable = true,
1636
- autofocus = false,
1637
- placeholder,
1638
- showToolbar = true,
1639
- toolbarConfig,
1640
- collabConfig,
1641
- aiConfig,
1642
- uploadConfig,
1643
- className,
1644
- editorClassName,
1645
- onUpdate,
1646
- onEditorReady,
1647
- children
1648
- }) {
1649
- const resolvedExtensions = useMemo3(() => {
1650
- return extensions || [StarterKit, BlocksKit, AICopilot];
1651
- }, [extensions]);
1652
- const editorOptions = useMemo3(
1653
- () => ({
1654
- extensions: resolvedExtensions,
1655
- content,
1656
- editable,
1657
- autofocus,
1658
- placeholder,
1659
- onUpdate: ({ editor: editor2 }) => {
1660
- if (onUpdate) {
1661
- onUpdate({
1662
- editor: editor2,
1663
- markdown: editor2.getMarkdown(),
1664
- json: editor2.getJSON(),
1665
- html: editor2.getHTML()
1666
- });
1667
- }
1668
- }
1669
- }),
1670
- [resolvedExtensions, content, editable, autofocus, placeholder, onUpdate]
1671
- );
1672
- const editor = useNotiq(editorOptions, [resolvedExtensions]);
1673
- const readyCalledRef = useRef4(false);
1674
- useEffect4(() => {
1675
- if (editor && !readyCalledRef.current) {
1676
- readyCalledRef.current = true;
1677
- if (onEditorReady) {
1678
- onEditorReady(editor);
1679
- }
1680
- }
1681
- }, [editor, onEditorReady]);
1682
- if (!editor) {
1683
- return null;
1684
- }
1685
- return /* @__PURE__ */ jsx5(CollabProvider, { config: collabConfig, children: /* @__PURE__ */ jsx5(LexicalCollaboration, { children: /* @__PURE__ */ jsx5(CommentsProvider, { children: /* @__PURE__ */ jsx5(VersionHistoryProvider, { children: /* @__PURE__ */ jsx5(NotiqProvider, { editor, children: /* @__PURE__ */ jsx5(AIProvider, { config: aiConfig, children: /* @__PURE__ */ jsx5(UploadProvider, { config: uploadConfig, children: /* @__PURE__ */ jsx5(SharedHistoryContext, { children: /* @__PURE__ */ jsx5(ToolbarContext, { children: /* @__PURE__ */ jsxs3(
1686
- "div",
1687
- {
1688
- className: cn(
1689
- "notiq-editor flex flex-col w-full rounded-xl border border-border bg-background shadow-sm overflow-hidden",
1690
- className
1691
- ),
1692
- children: [
1693
- showToolbar && editable && /* @__PURE__ */ jsx5("div", { className: "border-b border-border bg-muted/30", children: /* @__PURE__ */ jsx5(
1694
- ToolbarPlugin,
1695
- {
1696
- editor: editor.lexical,
1697
- activeEditor: editor.lexical,
1698
- setActiveEditor: () => {
1699
- },
1700
- setIsLinkEditMode: () => {
1701
- },
1702
- toolbarConfig
1703
- }
1704
- ) }),
1705
- /* @__PURE__ */ jsx5("div", { className: "p-4 md:p-8", children: /* @__PURE__ */ jsx5(
1706
- NotiqContent,
1707
- {
1708
- editor,
1709
- className: cn("min-h-[300px]", editorClassName),
1710
- children
1711
- }
1712
- ) })
1713
- ]
1714
- }
1715
- ) }) }) }) }) }) }) }) }) });
1716
- }
1717
-
1718
- export {
1719
- Extension,
1720
- createCommandChain,
1721
- createCanCommands,
1722
- NotiqEditorImpl,
1723
- createNotiqEditor,
1724
- Bold,
1725
- Italic,
1726
- Underline,
1727
- Strike,
1728
- Code,
1729
- Paragraph,
1730
- Heading,
1731
- Blockquote,
1732
- BulletList,
1733
- OrderedList,
1734
- CheckList,
1735
- CodeBlock,
1736
- History,
1737
- StarterKit,
1738
- Excalidraw,
1739
- Figma,
1740
- Equation,
1741
- HintBlock,
1742
- Stepper,
1743
- Poll,
1744
- Image,
1745
- Tweet,
1746
- YouTube,
1747
- Audio,
1748
- File,
1749
- ColumnsLayout,
1750
- BlocksKit,
1751
- AICommandBar,
1752
- AICopilot,
1753
- Collaboration,
1754
- editor_theme_default,
1755
- NotiqContext,
1756
- useNotiqContext,
1757
- NotiqProvider,
1758
- useNotiq,
1759
- NotiqContent,
1760
- BubbleMenu,
1761
- FloatingMenu,
1762
- NotiqEditor
1763
- };