@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,823 +0,0 @@
1
- import {
2
- INSERT_TEMPLATE_COMMAND
3
- } from "./chunk-EIZMKFHF.mjs";
4
- import {
5
- CodeList,
6
- getLanguageFriendlyName
7
- } from "./chunk-EEBA6OAH.mjs";
8
- import {
9
- Toggle
10
- } from "./chunk-PD5K4AGP.mjs";
11
- import {
12
- getSelectedNode
13
- } from "./chunk-KXRLARGI.mjs";
14
- import {
15
- EXPORT_MARKDOWN_COMMAND,
16
- EXPORT_PDF_COMMAND,
17
- downloadHTML,
18
- exportEditorToHTML
19
- } from "./chunk-ENH2IOHI.mjs";
20
- import "./chunk-LU2XWLOE.mjs";
21
- import "./chunk-6UVNHT3T.mjs";
22
- import {
23
- SPEECH_TO_TEXT_COMMAND,
24
- SUPPORT_SPEECH_RECOGNITION
25
- } from "./chunk-ZKZ7MLSS.mjs";
26
- import {
27
- SHORTCUTS
28
- } from "./chunk-K5OAFEVY.mjs";
29
- import "./chunk-LVRJM45C.mjs";
30
- import "./chunk-LLGVCM7M.mjs";
31
- import "./chunk-VGAX6YEY.mjs";
32
- import "./chunk-N6ILV6NF.mjs";
33
- import "./chunk-T2UBAZ66.mjs";
34
- import "./chunk-43Z4Z2KD.mjs";
35
- import "./chunk-XYMXGU4T.mjs";
36
- import "./chunk-ZFV2HGD3.mjs";
37
- import {
38
- blockTypeToBlockName,
39
- useToolbarState
40
- } from "./chunk-4FFTOZGJ.mjs";
41
- import {
42
- Separator
43
- } from "./chunk-CDAMHK63.mjs";
44
- import "./chunk-NBE6FF6L.mjs";
45
- import "./chunk-ELBTVBTS.mjs";
46
- import {
47
- sanitizeUrl
48
- } from "./chunk-RAVYEEIC.mjs";
49
- import {
50
- Dialog,
51
- DialogContent,
52
- DialogDescription,
53
- DialogHeader,
54
- DialogTitle,
55
- DialogTrigger
56
- } from "./chunk-H3P47YXJ.mjs";
57
- import "./chunk-QNIY45SF.mjs";
58
- import {
59
- Button
60
- } from "./chunk-OE5JRLCN.mjs";
61
- import "./chunk-KNW2CGIP.mjs";
62
- import "./chunk-7QRJVZQY.mjs";
63
- import "./chunk-IIVB6JNE.mjs";
64
- import {
65
- cn
66
- } from "./chunk-JHXDLYEV.mjs";
67
- import {
68
- init_react_shim
69
- } from "./chunk-WYCFGRFJ.mjs";
70
-
71
- // src/components/editor/plugins/ToolbarPlugin/index.tsx
72
- init_react_shim();
73
- import { useCallback, useEffect, useState as useState2 } from "react";
74
- import {
75
- $getNodeByKey,
76
- $getSelection,
77
- $isElementNode,
78
- $isLineBreakNode,
79
- $isRangeSelection,
80
- $isRootOrShadowRoot,
81
- BLUR_COMMAND,
82
- CAN_REDO_COMMAND,
83
- CAN_UNDO_COMMAND,
84
- COMMAND_PRIORITY_CRITICAL,
85
- FOCUS_COMMAND,
86
- FORMAT_TEXT_COMMAND,
87
- REDO_COMMAND,
88
- SELECTION_CHANGE_COMMAND,
89
- UNDO_COMMAND
90
- } from "lexical";
91
-
92
- // src/components/editor/plugins/TemplatePlugin/TemplateDialog.tsx
93
- init_react_shim();
94
- import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
95
- import { LayoutTemplate } from "lucide-react";
96
- import { useState } from "react";
97
-
98
- // src/components/editor/templates/data.ts
99
- init_react_shim();
100
- var TEMPLATES = [
101
- {
102
- id: "meeting-notes",
103
- name: "Meeting Notes",
104
- description: "Standard meeting minutes format",
105
- content: `# Meeting Notes
106
- Date:
107
- attendees:
108
-
109
- ## Agenda
110
- 1.
111
- 2.
112
-
113
- ## Action Items
114
- - [ ]
115
- - [ ]
116
- `
117
- },
118
- {
119
- id: "daily-journal",
120
- name: "Daily Journal",
121
- description: "Reflect on your day",
122
- content: `# Daily Journal
123
- Date:
124
-
125
- ## Highlights
126
- -
127
-
128
- ## Challenges
129
- -
130
-
131
- ## Plan for Tomorrow
132
- -
133
- `
134
- },
135
- {
136
- id: "product-spec",
137
- name: "Product Specification",
138
- description: "Define a new feature or product",
139
- content: `# Product Spec: [Title]
140
-
141
- ## Problem Statement
142
- What problem are we solving?
143
-
144
- ## Solution
145
- Describe the solution.
146
-
147
- ## Requirements
148
- - Requirement 1
149
- - Requirement 2
150
- `
151
- }
152
- ];
153
-
154
- // src/components/editor/plugins/TemplatePlugin/TemplateDialog.tsx
155
- import { jsx, jsxs } from "react/jsx-runtime";
156
- function TemplateDialog() {
157
- const [editor] = useLexicalComposerContext();
158
- const [open, setOpen] = useState(false);
159
- const insertTemplate = (content) => {
160
- editor.dispatchCommand(INSERT_TEMPLATE_COMMAND, content);
161
- setOpen(false);
162
- };
163
- return /* @__PURE__ */ jsxs(Dialog, { open, onOpenChange: setOpen, children: [
164
- /* @__PURE__ */ jsx(DialogTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "outline", size: "Toolbar", className: "border-none", tip: "Insert Template", children: /* @__PURE__ */ jsx(LayoutTemplate, { className: "size-4" }) }) }),
165
- /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-[425px]", children: [
166
- /* @__PURE__ */ jsxs(DialogHeader, { children: [
167
- /* @__PURE__ */ jsx(DialogTitle, { children: "Choose a Template" }),
168
- /* @__PURE__ */ jsx(DialogDescription, { children: "Select a template to get started quickly." })
169
- ] }),
170
- /* @__PURE__ */ jsx("div", { className: "grid gap-4 py-4", children: TEMPLATES.map((template) => /* @__PURE__ */ jsxs(
171
- Button,
172
- {
173
- variant: "outline",
174
- className: "justify-start h-auto flex-col items-start gap-1",
175
- onClick: () => insertTemplate(template.content),
176
- children: [
177
- /* @__PURE__ */ jsx("span", { className: "font-medium", children: template.name }),
178
- /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: template.description })
179
- ]
180
- },
181
- template.id
182
- )) })
183
- ] })
184
- ] });
185
- }
186
-
187
- // src/components/editor/plugins/ToolbarPlugin/index.tsx
188
- import { Bold, Code, DownloadIcon, FileJson, FileText, Italic, Link, Mic, Redo2Icon, Underline, Undo2Icon } from "lucide-react";
189
- import {
190
- $findMatchingParent,
191
- $getNearestNodeOfType,
192
- $isEditorIsNestedEditor,
193
- mergeRegister
194
- } from "@lexical/utils";
195
- import {
196
- $getSelectionStyleValueForProperty
197
- } from "@lexical/selection";
198
- import { $isLinkNode, TOGGLE_LINK_COMMAND } from "@lexical/link";
199
- import { $isTableNode, $isTableSelection } from "@lexical/table";
200
- import { $isListNode, ListNode } from "@lexical/list";
201
- import { $isHeadingNode } from "@lexical/rich-text";
202
- import { $isCodeNode } from "@lexical/code";
203
- import dynamic from "next/dynamic.js";
204
- import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
205
- var BlockFormatDropDown = dynamic(
206
- () => import("./block-format-TODFREE2.mjs")
207
- );
208
- var MobileToolbar = dynamic(() => import("./MobileToolbar-KV5DX4ED.mjs"), { ssr: false });
209
- var FontDropDown = dynamic(
210
- () => import("./font-IJKFR4BM.mjs")
211
- );
212
- var FontSize = dynamic(
213
- () => import("./font-size-3HMJHKO2.mjs")
214
- );
215
- var Color = dynamic(() => import("./color-S55XFDYQ.mjs"));
216
- var BackgroundColor = dynamic(() => import("./background-color-RW5JYLMG.mjs"));
217
- var TextFormat = dynamic(
218
- () => import("./text-format-T3IY7FBI.mjs")
219
- );
220
- var InsertNode = dynamic(
221
- () => import("./insert-node-DGCZBGKG.mjs")
222
- );
223
- var TextAlign = dynamic(
224
- () => import("./text-align-TEB4S52S.mjs")
225
- );
226
- var TableDropDown = dynamic(
227
- () => import("./table-dropdown-4VCRSQB6.mjs")
228
- );
229
- function ToolbarPlugin({
230
- editor,
231
- activeEditor,
232
- setActiveEditor,
233
- setIsLinkEditMode,
234
- toolbarConfig,
235
- className
236
- }) {
237
- const [isEditable, setIsEditable] = useState2(() => editor.isEditable());
238
- const [isSpeechToText, setIsSpeechToText] = useState2(false);
239
- const [selectedElementKey, setSelectedElementKey] = useState2(
240
- null
241
- );
242
- const [isFocused, setIsFocused] = useState2(false);
243
- const { toolbarState, updateToolbarState } = useToolbarState();
244
- const $updateToolbar = useCallback(() => {
245
- const currentEditor = activeEditor || editor;
246
- if (!currentEditor) return;
247
- currentEditor.read(() => {
248
- var _a;
249
- const selection = $getSelection();
250
- if ($isRangeSelection(selection)) {
251
- if (activeEditor !== editor && $isEditorIsNestedEditor(activeEditor)) {
252
- const rootElement = activeEditor.getRootElement();
253
- updateToolbarState(
254
- "isImageCaption",
255
- !!((_a = rootElement == null ? void 0 : rootElement.parentElement) == null ? void 0 : _a.classList.contains(
256
- "image-caption-container"
257
- ))
258
- );
259
- } else {
260
- updateToolbarState("isImageCaption", false);
261
- }
262
- const anchorNode = selection.anchor.getNode();
263
- let element = anchorNode.getKey() === "root" ? anchorNode : $findMatchingParent(anchorNode, (e) => {
264
- const parent2 = e.getParent();
265
- return parent2 !== null && $isRootOrShadowRoot(parent2);
266
- });
267
- if (element === null) {
268
- element = anchorNode.getTopLevelElementOrThrow();
269
- }
270
- const elementKey = element.getKey();
271
- const elementDOM = currentEditor.getElementByKey(elementKey);
272
- const node = getSelectedNode(selection);
273
- const parent = node.getParent();
274
- const isLink = $isLinkNode(parent) || $isLineBreakNode(node);
275
- updateToolbarState("isLink", isLink);
276
- const tableNode = $findMatchingParent(node, $isTableNode);
277
- if ($isTableNode(tableNode)) {
278
- updateToolbarState("rootType", "table");
279
- } else {
280
- updateToolbarState("rootType", "root");
281
- }
282
- if (elementDOM !== null) {
283
- setSelectedElementKey(elementKey);
284
- if ($isListNode(element)) {
285
- const parentList = $getNearestNodeOfType(anchorNode, ListNode);
286
- const type = parentList ? parentList.getListType() : element.getListType();
287
- updateToolbarState("blockType", type);
288
- } else {
289
- const type = $isHeadingNode(element) ? element.getTag() : element.getType();
290
- if (type in blockTypeToBlockName) {
291
- updateToolbarState(
292
- "blockType",
293
- type
294
- );
295
- }
296
- if ($isCodeNode(element)) {
297
- const language = element.getLanguage() || "";
298
- updateToolbarState(
299
- "codeLanguage",
300
- getLanguageFriendlyName(language)
301
- );
302
- return;
303
- }
304
- }
305
- }
306
- updateToolbarState(
307
- "fontColor",
308
- $getSelectionStyleValueForProperty(selection, "color", "#000")
309
- );
310
- updateToolbarState(
311
- "bgColor",
312
- $getSelectionStyleValueForProperty(
313
- selection,
314
- "background-color",
315
- "#fff"
316
- )
317
- );
318
- updateToolbarState(
319
- "fontFamily",
320
- $getSelectionStyleValueForProperty(selection, "font-family", "Arial")
321
- );
322
- let matchingParent;
323
- if ($isLinkNode(parent)) {
324
- matchingParent = $findMatchingParent(
325
- node,
326
- (parentNode) => $isElementNode(parentNode) && !parentNode.isInline()
327
- );
328
- }
329
- updateToolbarState(
330
- "elementFormat",
331
- $isElementNode(matchingParent) ? matchingParent.getFormatType() : $isElementNode(node) ? node.getFormatType() : (parent == null ? void 0 : parent.getFormatType()) || "left"
332
- );
333
- }
334
- if ($isRangeSelection(selection) || $isTableSelection(selection)) {
335
- updateToolbarState("isBold", selection.hasFormat("bold"));
336
- updateToolbarState("isItalic", selection.hasFormat("italic"));
337
- updateToolbarState("isUnderline", selection.hasFormat("underline"));
338
- updateToolbarState("isStrikethrough", selection.hasFormat("strikethrough"));
339
- updateToolbarState("isSubscript", selection.hasFormat("subscript"));
340
- updateToolbarState("isSuperscript", selection.hasFormat("superscript"));
341
- updateToolbarState("isCode", selection.hasFormat("code"));
342
- updateToolbarState(
343
- "fontSize",
344
- $getSelectionStyleValueForProperty(selection, "font-size", "15px")
345
- );
346
- updateToolbarState("isLowercase", selection.hasFormat("lowercase"));
347
- updateToolbarState("isUppercase", selection.hasFormat("uppercase"));
348
- updateToolbarState("isCapitalize", selection.hasFormat("capitalize"));
349
- }
350
- });
351
- }, [activeEditor, editor, updateToolbarState]);
352
- useEffect(() => {
353
- return editor.registerCommand(
354
- SELECTION_CHANGE_COMMAND,
355
- (_payload, newEditor) => {
356
- setActiveEditor(newEditor);
357
- $updateToolbar();
358
- return false;
359
- },
360
- COMMAND_PRIORITY_CRITICAL
361
- );
362
- }, [editor, $updateToolbar, setActiveEditor]);
363
- useEffect(() => {
364
- activeEditor.getEditorState().read(() => {
365
- $updateToolbar();
366
- });
367
- }, [activeEditor, $updateToolbar]);
368
- useEffect(() => {
369
- return mergeRegister(
370
- editor.registerCommand(
371
- FOCUS_COMMAND,
372
- () => {
373
- setIsFocused(true);
374
- return false;
375
- },
376
- COMMAND_PRIORITY_CRITICAL
377
- ),
378
- editor.registerCommand(
379
- BLUR_COMMAND,
380
- () => {
381
- setIsFocused(false);
382
- return false;
383
- },
384
- COMMAND_PRIORITY_CRITICAL
385
- ),
386
- editor.registerEditableListener((editable) => {
387
- setIsEditable(editable);
388
- }),
389
- activeEditor.registerUpdateListener(({ editorState }) => {
390
- editorState.read(() => {
391
- $updateToolbar();
392
- });
393
- }),
394
- activeEditor.registerCommand(
395
- CAN_UNDO_COMMAND,
396
- (payload) => {
397
- updateToolbarState("canUndo", payload);
398
- return false;
399
- },
400
- COMMAND_PRIORITY_CRITICAL
401
- ),
402
- activeEditor.registerCommand(
403
- CAN_REDO_COMMAND,
404
- (payload) => {
405
- updateToolbarState("canRedo", payload);
406
- return false;
407
- },
408
- COMMAND_PRIORITY_CRITICAL
409
- )
410
- );
411
- }, [$updateToolbar, activeEditor, editor, updateToolbarState]);
412
- const insertLink = useCallback(() => {
413
- if (!toolbarState.isLink) {
414
- setIsLinkEditMode(true);
415
- activeEditor.dispatchCommand(
416
- TOGGLE_LINK_COMMAND,
417
- sanitizeUrl("https://")
418
- );
419
- } else {
420
- setIsLinkEditMode(false);
421
- activeEditor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
422
- }
423
- }, [activeEditor, setIsLinkEditMode, toolbarState.isLink]);
424
- const onCodeLanguageSelect = useCallback(
425
- (value) => {
426
- activeEditor.update(() => {
427
- if (selectedElementKey !== null) {
428
- const node = $getNodeByKey(selectedElementKey);
429
- if ($isCodeNode(node)) {
430
- node.setLanguage(value);
431
- }
432
- }
433
- });
434
- },
435
- [activeEditor, selectedElementKey]
436
- );
437
- const handleDownloadHTML = useCallback(() => {
438
- try {
439
- const htmlContent = exportEditorToHTML(activeEditor);
440
- const timestamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-");
441
- downloadHTML(htmlContent, `document-${timestamp}.html`);
442
- } catch (error) {
443
- console.error("Failed to export HTML:", error);
444
- }
445
- }, [activeEditor]);
446
- const DEFAULT_TOOLBAR_ITEMS = [
447
- "undo",
448
- "redo",
449
- "separator",
450
- "block-format",
451
- "separator",
452
- "font-family",
453
- "separator",
454
- "font-size",
455
- "separator",
456
- "bold",
457
- "italic",
458
- "underline",
459
- "code",
460
- "link",
461
- "table",
462
- "separator",
463
- "color",
464
- "bg-color",
465
- "separator",
466
- "text-format",
467
- "separator",
468
- "insert",
469
- "separator",
470
- "align",
471
- "separator",
472
- "speech",
473
- "template",
474
- "download",
475
- "separator",
476
- "export-md",
477
- "export-pdf"
478
- ];
479
- const itemsToRender = (toolbarConfig == null ? void 0 : toolbarConfig.items) || DEFAULT_TOOLBAR_ITEMS;
480
- const customClassName = (toolbarConfig == null ? void 0 : toolbarConfig.className) || className;
481
- const itemClassName = toolbarConfig == null ? void 0 : toolbarConfig.itemClassName;
482
- const activeItemClassName = toolbarConfig == null ? void 0 : toolbarConfig.activeItemClassName;
483
- const renderItem = (item, index) => {
484
- switch (item) {
485
- case "undo":
486
- return /* @__PURE__ */ jsx2(
487
- Button,
488
- {
489
- size: "Toolbar",
490
- variant: "outline",
491
- disabled: !toolbarState.canUndo || !isEditable,
492
- onClick: () => {
493
- activeEditor.dispatchCommand(UNDO_COMMAND, void 0);
494
- },
495
- tip: false ? "Undo (\u2318Z)" : "Undo (Ctrl+Z)",
496
- type: "button",
497
- "aria-label": "Undo",
498
- className: cn("border-none", itemClassName),
499
- children: /* @__PURE__ */ jsx2(Undo2Icon, { className: " size-4" })
500
- },
501
- `undo-${index}`
502
- );
503
- case "redo":
504
- return /* @__PURE__ */ jsx2(
505
- Button,
506
- {
507
- variant: "outline",
508
- size: "Toolbar",
509
- disabled: !toolbarState.canRedo || !isEditable,
510
- onClick: () => {
511
- activeEditor.dispatchCommand(REDO_COMMAND, void 0);
512
- },
513
- tip: false ? "Redo (\u21E7\u2318Z)" : "Redo (Ctrl+Y)",
514
- type: "button",
515
- className: cn("toolbar-item border-none", itemClassName),
516
- "aria-label": "Redo",
517
- children: /* @__PURE__ */ jsx2(Redo2Icon, { className: " size-4" })
518
- },
519
- `redo-${index}`
520
- );
521
- case "separator":
522
- return /* @__PURE__ */ jsx2(Separator, { className: "h-6 mx-2", orientation: "vertical" }, `sep-${index}`);
523
- case "block-format":
524
- return toolbarState.blockType in blockTypeToBlockName && activeEditor === editor ? /* @__PURE__ */ jsx2("div", { className: "flex flex-row gap-x-[5px] items-center", children: /* @__PURE__ */ jsx2(
525
- BlockFormatDropDown,
526
- {
527
- disabled: !isEditable,
528
- blockType: toolbarState.blockType,
529
- editor: activeEditor
530
- }
531
- ) }, `block-${index}`) : null;
532
- case "font-family":
533
- return /* @__PURE__ */ jsx2(
534
- FontDropDown,
535
- {
536
- disabled: !isEditable,
537
- style: { fontFamily: toolbarState.fontFamily },
538
- value: toolbarState.fontFamily,
539
- editor: activeEditor
540
- },
541
- `font-${index}`
542
- );
543
- case "font-size":
544
- return /* @__PURE__ */ jsx2(
545
- FontSize,
546
- {
547
- selectionFontSize: toolbarState.fontSize.slice(0, -2),
548
- editor: activeEditor,
549
- disabled: !isEditable
550
- },
551
- `size-${index}`
552
- );
553
- case "bold":
554
- return /* @__PURE__ */ jsx2(
555
- Toggle,
556
- {
557
- disabled: !isEditable,
558
- variant: "outline",
559
- size: "Toolbar",
560
- pressed: toolbarState.isBold,
561
- onPressedChange: () => {
562
- activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, "bold");
563
- },
564
- tip: `Bold ${SHORTCUTS.BOLD}`,
565
- "aria-label": `Format text as bold. Shortcut: ${SHORTCUTS.BOLD}`,
566
- className: cn(itemClassName, toolbarState.isBold && activeItemClassName),
567
- children: /* @__PURE__ */ jsx2(Bold, { size: 16 })
568
- },
569
- `bold-${index}`
570
- );
571
- case "italic":
572
- return /* @__PURE__ */ jsx2(
573
- Toggle,
574
- {
575
- variant: "outline",
576
- size: "Toolbar",
577
- disabled: !isEditable,
578
- pressed: toolbarState.isItalic,
579
- onPressedChange: () => {
580
- activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, "italic");
581
- },
582
- tip: `Italic (${SHORTCUTS.ITALIC})`,
583
- type: "button",
584
- "aria-label": `Format text as italics. Shortcut: ${SHORTCUTS.ITALIC}`,
585
- className: cn(itemClassName, toolbarState.isItalic && activeItemClassName),
586
- children: /* @__PURE__ */ jsx2(Italic, { size: 16 })
587
- },
588
- `italic-${index}`
589
- );
590
- case "underline":
591
- return /* @__PURE__ */ jsx2(
592
- Toggle,
593
- {
594
- disabled: !isEditable,
595
- variant: "outline",
596
- size: "Toolbar",
597
- pressed: toolbarState.isUnderline,
598
- onPressedChange: () => {
599
- activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, "underline");
600
- },
601
- tip: `Underline (${SHORTCUTS.UNDERLINE})`,
602
- type: "button",
603
- "aria-label": `Format text to underlined. Shortcut: ${SHORTCUTS.UNDERLINE}`,
604
- className: cn(itemClassName, toolbarState.isUnderline && activeItemClassName),
605
- children: /* @__PURE__ */ jsx2(Underline, { size: 16 })
606
- },
607
- `underline-${index}`
608
- );
609
- case "code":
610
- return /* @__PURE__ */ jsx2(
611
- Toggle,
612
- {
613
- disabled: !isEditable,
614
- variant: "outline",
615
- size: "Toolbar",
616
- pressed: toolbarState.isCode,
617
- onPressedChange: () => {
618
- activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, "code");
619
- },
620
- tip: `Insert code block (${SHORTCUTS.INSERT_CODE_BLOCK})`,
621
- type: "button",
622
- "aria-label": "Insert code block",
623
- className: cn(itemClassName, toolbarState.isCode && activeItemClassName),
624
- children: /* @__PURE__ */ jsx2(Code, { size: 16 })
625
- },
626
- `code-${index}`
627
- );
628
- case "link":
629
- return /* @__PURE__ */ jsx2(
630
- Toggle,
631
- {
632
- variant: "outline",
633
- size: "Toolbar",
634
- disabled: !isEditable,
635
- onPressedChange: insertLink,
636
- pressed: toolbarState.isLink,
637
- "aria-label": "Insert link",
638
- tip: `Insert link (${SHORTCUTS.INSERT_LINK})`,
639
- type: "button",
640
- className: cn(itemClassName, toolbarState.isLink && activeItemClassName),
641
- children: /* @__PURE__ */ jsx2(Link, { size: 16 })
642
- },
643
- `link-${index}`
644
- );
645
- case "table":
646
- return /* @__PURE__ */ jsx2(
647
- TableDropDown,
648
- {
649
- disabled: !isEditable,
650
- editor: activeEditor || editor,
651
- className: itemClassName
652
- },
653
- `table-${index}`
654
- );
655
- case "color":
656
- return /* @__PURE__ */ jsx2(
657
- Color,
658
- {
659
- disabled: !isEditable,
660
- color: toolbarState.fontColor,
661
- bgColor: toolbarState.bgColor,
662
- editor
663
- },
664
- `color-${index}`
665
- );
666
- case "bg-color":
667
- return /* @__PURE__ */ jsx2(
668
- BackgroundColor,
669
- {
670
- disabled: !isEditable,
671
- color: toolbarState.fontColor,
672
- bgColor: toolbarState.bgColor,
673
- editor
674
- },
675
- `bg-${index}`
676
- );
677
- case "text-format":
678
- return /* @__PURE__ */ jsx2(
679
- TextFormat,
680
- {
681
- disabled: !isEditable,
682
- editor,
683
- toolbarState
684
- },
685
- `format-${index}`
686
- );
687
- case "insert":
688
- return /* @__PURE__ */ jsx2(InsertNode, { disabled: !isEditable, editor }, `insert-${index}`);
689
- case "align":
690
- return /* @__PURE__ */ jsx2(
691
- TextAlign,
692
- {
693
- disabled: !isEditable,
694
- value: toolbarState.elementFormat,
695
- editor: activeEditor,
696
- isRTL: toolbarState.isRTL
697
- },
698
- `align-${index}`
699
- );
700
- case "speech":
701
- return SUPPORT_SPEECH_RECOGNITION ? /* @__PURE__ */ jsx2(
702
- Button,
703
- {
704
- variant: "outline",
705
- size: "Toolbar",
706
- type: "button",
707
- onClick: () => {
708
- editor.dispatchCommand(SPEECH_TO_TEXT_COMMAND, !isSpeechToText);
709
- setIsSpeechToText(!isSpeechToText);
710
- },
711
- className: cn(
712
- "relative inline-flex items-center justify-center p-3 rounded-lg border-none font-medium transition-all duration-300 ease-in-out active:scale-95",
713
- isSpeechToText ? "animate-pulse bg-gray-800" : "bg-transparent hover:bg-gray-900 cursor-pointer shadow-sm hover:shadow-md",
714
- itemClassName
715
- ),
716
- title: "Speech To Text",
717
- "aria-label": `${isSpeechToText ? "Disable" : "Enable"} speech to text`,
718
- children: /* @__PURE__ */ jsx2(Mic, { className: cn("w-4 h-4 transition-all duration-300", isSpeechToText && "animate-bounce") })
719
- },
720
- `speech-${index}`
721
- ) : null;
722
- case "template":
723
- return /* @__PURE__ */ jsx2(TemplateDialog, {}, `template-${index}`);
724
- case "download":
725
- return /* @__PURE__ */ jsx2(
726
- Button,
727
- {
728
- variant: "outline",
729
- size: "Toolbar",
730
- type: "button",
731
- onClick: handleDownloadHTML,
732
- tip: "Download as HTML",
733
- "aria-label": "Download document as HTML file",
734
- className: cn("border-none", itemClassName),
735
- children: /* @__PURE__ */ jsx2(DownloadIcon, { className: "size-4" })
736
- },
737
- `download-${index}`
738
- );
739
- case "export-md":
740
- return /* @__PURE__ */ jsx2(
741
- Button,
742
- {
743
- variant: "outline",
744
- size: "Toolbar",
745
- type: "button",
746
- onClick: () => {
747
- editor.dispatchCommand(EXPORT_MARKDOWN_COMMAND, void 0);
748
- },
749
- tip: "Export to Markdown",
750
- "aria-label": "Export document to Markdown",
751
- className: cn("border-none", itemClassName),
752
- children: /* @__PURE__ */ jsx2(FileJson, { className: "size-4" })
753
- },
754
- `md-${index}`
755
- );
756
- case "export-pdf":
757
- return /* @__PURE__ */ jsx2(
758
- Button,
759
- {
760
- variant: "outline",
761
- size: "Toolbar",
762
- type: "button",
763
- onClick: () => {
764
- editor.dispatchCommand(EXPORT_PDF_COMMAND, void 0);
765
- },
766
- tip: "Export to PDF",
767
- "aria-label": "Export document to PDF",
768
- className: cn("border-none", itemClassName),
769
- children: /* @__PURE__ */ jsx2(FileText, { className: "size-4" })
770
- },
771
- `pdf-${index}`
772
- );
773
- default:
774
- return null;
775
- }
776
- };
777
- return /* @__PURE__ */ jsxs2(Fragment, { children: [
778
- /* @__PURE__ */ jsx2(
779
- "nav",
780
- {
781
- className: cn(
782
- "sticky top-3 z-40 w-full hidden md:flex justify-center px-4 transition-all duration-300 pointer-events-none",
783
- customClassName
784
- ),
785
- children: /* @__PURE__ */ jsx2(
786
- "div",
787
- {
788
- className: cn(
789
- "group flex flex-row items-center pointer-events-auto",
790
- "bg-background/85 dark:bg-zinc-900/90 backdrop-blur-xl",
791
- "border border-border/70 dark:border-zinc-800/80 shadow-lg shadow-black/5 dark:shadow-black/30",
792
- "rounded-2xl h-13 px-3 py-1.5 gap-x-1.5",
793
- "overflow-x-auto whitespace-nowrap max-w-full scrollbar-none",
794
- "[&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]"
795
- ),
796
- children: toolbarState.blockType === "code" ? /* @__PURE__ */ jsx2(
797
- CodeList,
798
- {
799
- onCodeLanguageSelect,
800
- codeLanguage: toolbarState.codeLanguage,
801
- disabled: !isEditable
802
- }
803
- ) : itemsToRender.map((item, index) => renderItem(item, index))
804
- }
805
- )
806
- }
807
- ),
808
- /* @__PURE__ */ jsx2(
809
- MobileToolbar,
810
- {
811
- editor,
812
- activeEditor,
813
- toolbarState,
814
- setIsLinkEditMode,
815
- isVisible: isFocused,
816
- toolbarConfig
817
- }
818
- )
819
- ] });
820
- }
821
- export {
822
- ToolbarPlugin as default
823
- };