@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,349 +0,0 @@
1
- import {
2
- cn
3
- } from "./chunk-JHXDLYEV.mjs";
4
- import {
5
- __spreadProps,
6
- __spreadValues,
7
- init_react_shim
8
- } from "./chunk-WYCFGRFJ.mjs";
9
-
10
- // src/components/ui/models/use-model.tsx
11
- init_react_shim();
12
- import { useCallback, useMemo, useState } from "react";
13
-
14
- // src/components/ui/models/custom-dialog.tsx
15
- init_react_shim();
16
- import { AnimatePresence, motion } from "framer-motion";
17
- import React, { createContext, useContext, useEffect, useRef } from "react";
18
- import { useId } from "react";
19
- import { createPortal } from "react-dom";
20
- import { X } from "lucide-react";
21
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
22
- var DialogContext = createContext(null);
23
- var defaultVariants = {
24
- initial: {
25
- opacity: 0,
26
- scale: 0.95,
27
- y: 20
28
- },
29
- animate: {
30
- opacity: 1,
31
- scale: 1,
32
- y: 0
33
- },
34
- exit: {
35
- opacity: 0,
36
- scale: 0.95,
37
- y: 20
38
- }
39
- };
40
- var defaultTransition = {
41
- type: "spring",
42
- stiffness: 300,
43
- damping: 30
44
- };
45
- var backdropVariants = {
46
- initial: { opacity: 0 },
47
- animate: { opacity: 1 },
48
- exit: { opacity: 0 }
49
- };
50
- function Dialog({
51
- children,
52
- variants = defaultVariants,
53
- transition = defaultTransition,
54
- defaultOpen,
55
- onOpenChange,
56
- open,
57
- size = "md"
58
- }) {
59
- const [uncontrolledOpen, setUncontrolledOpen] = React.useState(
60
- defaultOpen || false
61
- );
62
- const dialogRef = useRef(null);
63
- const isOpen = open !== void 0 ? open : uncontrolledOpen;
64
- const setIsOpen = React.useCallback(
65
- (value) => {
66
- if (open === void 0) {
67
- setUncontrolledOpen(value);
68
- }
69
- onOpenChange == null ? void 0 : onOpenChange(value);
70
- },
71
- [open, onOpenChange]
72
- );
73
- useEffect(() => {
74
- const dialog = dialogRef.current;
75
- if (!dialog) return;
76
- if (isOpen) {
77
- document.body.style.overflow = "hidden";
78
- dialog.showModal();
79
- } else {
80
- document.body.style.overflow = "";
81
- dialog.close();
82
- }
83
- const handleCancel = (e) => {
84
- e.preventDefault();
85
- setIsOpen(false);
86
- };
87
- const handleKeyDown = (e) => {
88
- if (e.key === "Escape" && isOpen) {
89
- setIsOpen(false);
90
- }
91
- };
92
- dialog.addEventListener("cancel", handleCancel);
93
- document.addEventListener("keydown", handleKeyDown);
94
- return () => {
95
- dialog.removeEventListener("cancel", handleCancel);
96
- document.removeEventListener("keydown", handleKeyDown);
97
- document.body.style.overflow = "";
98
- };
99
- }, [isOpen, setIsOpen]);
100
- const handleTrigger = () => {
101
- setIsOpen(true);
102
- };
103
- const onAnimationComplete = (definition) => {
104
- var _a;
105
- if (definition === "exit" && !isOpen) {
106
- (_a = dialogRef.current) == null ? void 0 : _a.close();
107
- }
108
- };
109
- const baseId = useId();
110
- const ids = {
111
- dialog: `motion-ui-dialog-${baseId}`,
112
- title: `motion-ui-dialog-title-${baseId}`,
113
- description: `motion-ui-dialog-description-${baseId}`
114
- };
115
- return /* @__PURE__ */ jsx(
116
- DialogContext.Provider,
117
- {
118
- value: {
119
- isOpen,
120
- setIsOpen,
121
- dialogRef,
122
- variants,
123
- transition,
124
- ids,
125
- onAnimationComplete,
126
- handleTrigger,
127
- size
128
- },
129
- children
130
- }
131
- );
132
- }
133
- function DialogPortal({ children }) {
134
- if (typeof window !== "undefined") {
135
- return createPortal(children, document.body);
136
- }
137
- return null;
138
- }
139
- function DialogContent({
140
- children,
141
- className,
142
- container,
143
- showClose = true
144
- }) {
145
- const context = useContext(DialogContext);
146
- if (!context) throw new Error("DialogContent must be used within Dialog");
147
- const {
148
- isOpen,
149
- setIsOpen,
150
- dialogRef,
151
- variants,
152
- transition,
153
- ids,
154
- onAnimationComplete,
155
- size
156
- } = context;
157
- const sizeStyles = {
158
- sm: "max-w-sm",
159
- md: "max-w-md",
160
- lg: "max-w-lg",
161
- xl: "max-w-xl",
162
- full: "max-w-full mx-4"
163
- };
164
- const content = /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: isOpen && /* @__PURE__ */ jsxs(Fragment, { children: [
165
- /* @__PURE__ */ jsx(
166
- motion.div,
167
- {
168
- className: "fixed inset-0 z-50 bg-black/80 backdrop-blur-sm",
169
- initial: "initial",
170
- animate: "animate",
171
- exit: "exit",
172
- variants: backdropVariants,
173
- transition: { duration: 0.2 },
174
- onClick: () => setIsOpen(false)
175
- }
176
- ),
177
- /* @__PURE__ */ jsx(
178
- motion.dialog,
179
- {
180
- ref: dialogRef,
181
- id: ids.dialog,
182
- "aria-labelledby": ids.title,
183
- "aria-describedby": ids.description,
184
- "aria-modal": "true",
185
- role: "dialog",
186
- onClick: (e) => {
187
- if (e.target === dialogRef.current) {
188
- setIsOpen(false);
189
- }
190
- },
191
- initial: "initial",
192
- animate: "animate",
193
- exit: "exit",
194
- variants,
195
- transition,
196
- onAnimationComplete,
197
- className: cn(
198
- "fixed left-[50%] top-[50%] z-50 w-full translate-x-[-50%] translate-y-[-50%]",
199
- "grid gap-4 border border-slate-200 bg-white p-6 shadow-lg",
200
- "duration-200 sm:rounded-lg dark:border-slate-800 dark:bg-slate-950",
201
- sizeStyles[size],
202
- className
203
- ),
204
- children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
205
- showClose && /* @__PURE__ */ jsx(DialogClose, { className: "absolute right-0 top-0" }),
206
- children
207
- ] })
208
- },
209
- ids.dialog
210
- )
211
- ] }) });
212
- return /* @__PURE__ */ jsx(DialogPortal, { container, children: content });
213
- }
214
- function DialogHeader({ children, className }) {
215
- return /* @__PURE__ */ jsx("div", { className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className), children });
216
- }
217
- function DialogTitle({ children, className }) {
218
- const context = useContext(DialogContext);
219
- if (!context) throw new Error("DialogTitle must be used within Dialog");
220
- return /* @__PURE__ */ jsx(
221
- "h2",
222
- {
223
- id: context.ids.title,
224
- className: cn("text-lg font-semibold leading-none tracking-tight", className),
225
- children
226
- }
227
- );
228
- }
229
- function DialogDescription({ children, className }) {
230
- const context = useContext(DialogContext);
231
- if (!context) throw new Error("DialogDescription must be used within Dialog");
232
- return /* @__PURE__ */ jsx(
233
- "p",
234
- {
235
- id: context.ids.description,
236
- className: cn("text-sm text-slate-500 dark:text-slate-400", className),
237
- children
238
- }
239
- );
240
- }
241
- function DialogClose({
242
- className,
243
- children,
244
- disabled,
245
- variant = "outline",
246
- size = "icon",
247
- asChild = false
248
- }) {
249
- const context = useContext(DialogContext);
250
- if (!context) throw new Error("DialogClose must be used within Dialog");
251
- const baseStyles = "inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-950 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 dark:ring-offset-slate-950 dark:focus-visible:ring-slate-300";
252
- const variants = {
253
- default: "bg-slate-900 text-slate-50 hover:bg-slate-900/90 dark:bg-slate-50 dark:text-slate-900 dark:hover:bg-slate-50/90",
254
- destructive: "bg-red-500 text-slate-50 hover:bg-red-500/90 dark:bg-red-900 dark:text-slate-50 dark:hover:bg-red-900/90",
255
- outline: "border border-slate-200 bg-white hover:bg-slate-100 hover:text-slate-900 dark:border-slate-800 dark:bg-slate-950 dark:hover:bg-slate-800 dark:hover:text-slate-50",
256
- secondary: "bg-slate-100 text-slate-900 hover:bg-slate-100/80 dark:bg-slate-800 dark:text-slate-50 dark:hover:bg-slate-800/80",
257
- ghost: "hover:bg-slate-100 hover:text-slate-900 dark:hover:bg-slate-800 dark:hover:text-slate-50"
258
- };
259
- const sizes = {
260
- default: "h-10 px-4 py-2",
261
- sm: "h-9 rounded-md px-3",
262
- lg: "h-11 rounded-md px-8",
263
- icon: "h-6 w-6"
264
- };
265
- if (asChild && React.isValidElement(children)) {
266
- return React.cloneElement(children, __spreadProps(__spreadValues({}, children.props), {
267
- onClick: () => context.setIsOpen(false)
268
- }));
269
- }
270
- if (!children) {
271
- return /* @__PURE__ */ jsxs(
272
- "button",
273
- {
274
- onClick: () => context.setIsOpen(false),
275
- type: "button",
276
- "aria-label": "Close dialog",
277
- className: cn(
278
- "rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100",
279
- "focus:outline-none focus:ring-2 focus:ring-slate-950 focus:ring-offset-2",
280
- "disabled:pointer-events-none data-[state=open]:bg-slate-100",
281
- "data-[state=open]:text-slate-500 dark:ring-offset-slate-950",
282
- "dark:focus:ring-slate-300 dark:data-[state=open]:bg-slate-800",
283
- "dark:data-[state=open]:text-slate-400",
284
- className
285
- ),
286
- disabled,
287
- children: [
288
- /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }),
289
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
290
- ]
291
- }
292
- );
293
- }
294
- return /* @__PURE__ */ jsx(
295
- "button",
296
- {
297
- onClick: () => context.setIsOpen(false),
298
- type: "button",
299
- className: cn(baseStyles, variants[variant], sizes[size], className),
300
- disabled,
301
- children
302
- }
303
- );
304
- }
305
-
306
- // src/components/ui/models/use-model.tsx
307
- import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
308
- function useModal() {
309
- const [isOpen, setIsOpen] = useState(false);
310
- const [modalContent, setModalContent] = useState(null);
311
- const onClose = useCallback(() => {
312
- setIsOpen(false);
313
- setModalContent(null);
314
- }, []);
315
- const showModal = useCallback(
316
- (title, description, getContent, isDialog) => {
317
- setIsOpen(true);
318
- setModalContent({
319
- title,
320
- description,
321
- content: getContent ? getContent(onClose) : void 0,
322
- isDialog: isDialog !== false
323
- });
324
- },
325
- [onClose]
326
- );
327
- const modal = useMemo(() => {
328
- if (!isOpen || !modalContent) {
329
- return null;
330
- }
331
- const { title, description, content, isDialog } = modalContent;
332
- if (isDialog === false) {
333
- return /* @__PURE__ */ jsx2(Fragment2, { children: content });
334
- }
335
- return /* @__PURE__ */ jsx2(Dialog, { open: isOpen, onOpenChange: setIsOpen, children: /* @__PURE__ */ jsxs2(DialogContent, { className: "w-full max-w-md bg-white p-6 dark:bg-zinc-900", children: [
336
- (title || description) && /* @__PURE__ */ jsxs2(DialogHeader, { children: [
337
- title && /* @__PURE__ */ jsx2(DialogTitle, { className: "text-zinc-900 dark:text-white", children: title }),
338
- description && /* @__PURE__ */ jsx2(DialogDescription, { className: "text-zinc-600 dark:text-zinc-400", children: description })
339
- ] }),
340
- /* @__PURE__ */ jsx2("div", { className: "mt-2", children: content }),
341
- /* @__PURE__ */ jsx2(DialogClose, {})
342
- ] }) });
343
- }, [isOpen, modalContent]);
344
- return [modal, showModal, isOpen];
345
- }
346
-
347
- export {
348
- useModal
349
- };
@@ -1,202 +0,0 @@
1
- import {
2
- useCollab
3
- } from "./chunk-RJQTA6HG.mjs";
4
- import {
5
- init_react_shim
6
- } from "./chunk-WYCFGRFJ.mjs";
7
-
8
- // src/components/providers/VersionHistoryContext.tsx
9
- init_react_shim();
10
- import {
11
- createContext,
12
- useContext,
13
- useState,
14
- useEffect,
15
- useCallback,
16
- useMemo
17
- } from "react";
18
- import { toast } from "sonner";
19
- import { Fragment, jsx } from "react/jsx-runtime";
20
- var VersionHistoryContext = createContext(null);
21
- var useVersionHistory = () => {
22
- const context = useContext(VersionHistoryContext);
23
- if (!context) {
24
- throw new Error("useVersionHistory must be used within a VersionHistoryProvider");
25
- }
26
- return context;
27
- };
28
- var VersionHistoryProviderInternal = ({ children }) => {
29
- const { provider, username, cursorColor, avatar } = useCollab();
30
- const [versions, setVersions] = useState([]);
31
- const [previewVersion, setPreviewVersion] = useState(null);
32
- const [isDrawerOpen, setIsDrawerOpen] = useState(false);
33
- const [isNameModalOpen, setIsNameModalOpen] = useState(false);
34
- useEffect(() => {
35
- const doc = provider == null ? void 0 : provider.doc;
36
- if (!doc) return;
37
- const yVersions = doc.getArray("notiq-version-history");
38
- const syncFromYjs = () => {
39
- try {
40
- const raw = yVersions.toArray();
41
- const parsed = raw.map((item) => {
42
- if (typeof item === "string") {
43
- try {
44
- return JSON.parse(item);
45
- } catch (e) {
46
- return item;
47
- }
48
- }
49
- return item;
50
- });
51
- parsed.sort((a, b) => b.timestamp - a.timestamp);
52
- setVersions(parsed);
53
- } catch (err) {
54
- console.warn("[Notiq VersionHistory] Failed to parse versions:", err);
55
- }
56
- };
57
- syncFromYjs();
58
- yVersions.observeDeep(syncFromYjs);
59
- return () => {
60
- yVersions.unobserveDeep(syncFromYjs);
61
- };
62
- }, [provider == null ? void 0 : provider.doc]);
63
- const author = useMemo(
64
- () => ({
65
- name: username,
66
- color: cursorColor,
67
- avatar
68
- }),
69
- [username, cursorColor, avatar]
70
- );
71
- const calculateWordCount = (editorState) => {
72
- var _a;
73
- try {
74
- if (!((_a = editorState == null ? void 0 : editorState.root) == null ? void 0 : _a.children)) return 0;
75
- let text = "";
76
- const walk = (node) => {
77
- if (node.text) text += " " + node.text;
78
- if (node.children) node.children.forEach(walk);
79
- };
80
- walk(editorState.root);
81
- const words = text.trim().split(/\s+/).filter(Boolean);
82
- return words.length;
83
- } catch (e) {
84
- return 0;
85
- }
86
- };
87
- const createCheckpoint = useCallback(
88
- (title, customEditorState, isNamed = false) => {
89
- if (!customEditorState) return "";
90
- const versionId = `v-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
91
- const wordCount = calculateWordCount(customEditorState);
92
- const newVersion = {
93
- id: versionId,
94
- title: (title == null ? void 0 : title.trim()) || `Revision by ${author.name}`,
95
- timestamp: Date.now(),
96
- author,
97
- editorState: customEditorState,
98
- wordCount,
99
- isNamed
100
- };
101
- const doc = provider == null ? void 0 : provider.doc;
102
- if (doc) {
103
- const yVersions = doc.getArray("notiq-version-history");
104
- doc.transact(() => {
105
- yVersions.push([JSON.stringify(newVersion)]);
106
- });
107
- } else {
108
- setVersions((prev) => [newVersion, ...prev]);
109
- }
110
- if (isNamed) {
111
- toast.success("Version saved", {
112
- description: `Snapshot "${newVersion.title}" created.`
113
- });
114
- }
115
- return versionId;
116
- },
117
- [author, provider == null ? void 0 : provider.doc]
118
- );
119
- const restoreVersion = useCallback(
120
- (version) => {
121
- if (typeof window !== "undefined") {
122
- window.dispatchEvent(
123
- new CustomEvent("notiq:restore-version", {
124
- detail: version
125
- })
126
- );
127
- }
128
- setPreviewVersion(null);
129
- setIsDrawerOpen(false);
130
- toast.success("Version restored", {
131
- description: `Document restored to "${version.title}".`
132
- });
133
- },
134
- []
135
- );
136
- const deleteVersion = useCallback(
137
- (versionId) => {
138
- const doc = provider == null ? void 0 : provider.doc;
139
- if (doc) {
140
- const yVersions = doc.getArray("notiq-version-history");
141
- doc.transact(() => {
142
- const raw = yVersions.toArray();
143
- const targetIndex = raw.findIndex((item) => {
144
- const parsed = typeof item === "string" ? JSON.parse(item) : item;
145
- return parsed.id === versionId;
146
- });
147
- if (targetIndex !== -1) {
148
- yVersions.delete(targetIndex, 1);
149
- }
150
- });
151
- } else {
152
- setVersions((prev) => prev.filter((v) => v.id !== versionId));
153
- }
154
- if ((previewVersion == null ? void 0 : previewVersion.id) === versionId) {
155
- setPreviewVersion(null);
156
- }
157
- toast.info("Version snapshot deleted");
158
- },
159
- [previewVersion == null ? void 0 : previewVersion.id, provider == null ? void 0 : provider.doc]
160
- );
161
- const toggleDrawer = useCallback(() => {
162
- setIsDrawerOpen((prev) => !prev);
163
- }, []);
164
- const value = useMemo(
165
- () => ({
166
- versions,
167
- previewVersion,
168
- setPreviewVersion,
169
- isDrawerOpen,
170
- setIsDrawerOpen,
171
- toggleDrawer,
172
- isNameModalOpen,
173
- setIsNameModalOpen,
174
- createCheckpoint,
175
- restoreVersion,
176
- deleteVersion
177
- }),
178
- [
179
- versions,
180
- previewVersion,
181
- isDrawerOpen,
182
- toggleDrawer,
183
- isNameModalOpen,
184
- createCheckpoint,
185
- restoreVersion,
186
- deleteVersion
187
- ]
188
- );
189
- return /* @__PURE__ */ jsx(VersionHistoryContext.Provider, { value, children });
190
- };
191
- var VersionHistoryProvider = ({ children }) => {
192
- const existing = useContext(VersionHistoryContext);
193
- if (existing) {
194
- return /* @__PURE__ */ jsx(Fragment, { children });
195
- }
196
- return /* @__PURE__ */ jsx(VersionHistoryProviderInternal, { children });
197
- };
198
-
199
- export {
200
- useVersionHistory,
201
- VersionHistoryProvider
202
- };