@collabchron/notiq 0.3.0 → 1.0.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 (282) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +230 -39
  3. package/dist/CodeActionMenuPlugin-EINOY4U4.mjs +15 -0
  4. package/dist/DynamicBlockComponent-NRQJ4WW4.mjs +161 -0
  5. package/dist/EquationComponent-CB6DFIHV.mjs +154 -0
  6. package/dist/ExcalidrawComponent-XW6646OH.mjs +528 -0
  7. package/dist/ExcalidrawPlugin-ZFHT62IF.mjs +14 -0
  8. package/dist/ExportPlugin-V2RLM63S.mjs +11 -0
  9. package/dist/FloatingLinkEditorPlugin-TRTCMSP4.mjs +12 -0
  10. package/dist/FloatingTextFormatToolbarPlugin-F2GY6LMI.mjs +30 -0
  11. package/dist/HintComponet-BRL6EAMS.mjs +217 -0
  12. package/dist/InlineImageComponent-UWIUWBHI.mjs +453 -0
  13. package/dist/MobileToolbar-BOOZAMQE.mjs +268 -0
  14. package/dist/SlashCommand-GMT5JI33.mjs +28 -0
  15. package/dist/StoryBuilderComponent-JGDBM5JU.mjs +562 -0
  16. package/{src/components/editor/plugins/TableCellActionMenuPlugin/index.tsx → dist/TableCellActionMenuPlugin-PGK2K3VG.mjs} +667 -759
  17. package/{src/components/editor/plugins/TableHoverActionsPlugin/index.tsx → dist/TableHoverActionsPlugin-GJVE6VRW.mjs} +258 -314
  18. package/dist/TemplatePlugin-ZD3QEVTI.mjs +9 -0
  19. package/dist/ToolbarPlugin-7TOZRD2R.mjs +1547 -0
  20. package/dist/babel-JZ2EV6AX.mjs +7233 -0
  21. package/dist/background-color-XZTYLGO2.mjs +362 -0
  22. package/dist/block-format-YJCV2DIY.mjs +15 -0
  23. package/dist/chunk-2FNEAMSP.mjs +127 -0
  24. package/dist/chunk-3CPBODXA.mjs +84 -0
  25. package/dist/chunk-3G37YKTV.mjs +83 -0
  26. package/dist/chunk-3JVFG7ER.mjs +184 -0
  27. package/dist/chunk-456TN7IM.mjs +110 -0
  28. package/dist/chunk-4EXYCTGJ.mjs +27 -0
  29. package/{src/utils/getSelectedNode.ts → dist/chunk-4HBCVSE6.mjs} +26 -27
  30. package/dist/chunk-4MEDW3T6.mjs +125 -0
  31. package/dist/chunk-4VWFVWYP.mjs +36 -0
  32. package/dist/chunk-5BAKY5KN.mjs +84 -0
  33. package/dist/chunk-5QSNIVIG.mjs +333 -0
  34. package/dist/chunk-64Z3FI7T.mjs +37 -0
  35. package/{src/components/editor/nodes/Stepper/index.tsx → dist/chunk-6RNZQOH2.mjs} +214 -260
  36. package/dist/chunk-77KXU36M.mjs +64 -0
  37. package/dist/chunk-77UA6HYR.mjs +165 -0
  38. package/dist/chunk-7NZAPJ4G.mjs +102 -0
  39. package/dist/chunk-7VUMHWWL.mjs +152 -0
  40. package/dist/chunk-AMMKBSST.mjs +1256 -0
  41. package/dist/chunk-BIU7WTLX.mjs +95 -0
  42. package/dist/chunk-EGMI62PP.mjs +83 -0
  43. package/dist/chunk-EHNQD5KO.mjs +88 -0
  44. package/dist/chunk-FSM26655.mjs +37 -0
  45. package/{src/components/editor/nodes/Hint/index.tsx → dist/chunk-G53GLEAY.mjs} +158 -190
  46. package/dist/chunk-GK35L7UY.mjs +28 -0
  47. package/dist/chunk-GXYD4VZM.mjs +193 -0
  48. package/dist/chunk-GYIOYVCN.mjs +538 -0
  49. package/dist/chunk-GZPNVR7L.mjs +157 -0
  50. package/dist/chunk-JXDPPUJI.mjs +52 -0
  51. package/dist/chunk-K36V4SIW.mjs +141 -0
  52. package/dist/chunk-KJ6AJ44Q.mjs +128 -0
  53. package/dist/chunk-KJV3FAZ7.mjs +142 -0
  54. package/{src/components/editor/plugins/ImagesPlugin/index.tsx → dist/chunk-LGG4IUIA.mjs} +189 -222
  55. package/dist/chunk-LQN3CMKV.mjs +1906 -0
  56. package/dist/chunk-N3WN46VL.mjs +236 -0
  57. package/dist/chunk-PBD6LMLC.mjs +366 -0
  58. package/dist/chunk-POGRR73N.mjs +33 -0
  59. package/{src/components/editor/utils/editorFormatting.ts → dist/chunk-PZSUSXQG.mjs} +238 -282
  60. package/dist/chunk-QEIFVK5M.mjs +29 -0
  61. package/dist/chunk-QHIQKMVN.mjs +427 -0
  62. package/dist/chunk-TCYK7DM7.mjs +36 -0
  63. package/dist/chunk-TTHQCW5F.mjs +47 -0
  64. package/dist/chunk-U47ABU5Z.mjs +53 -0
  65. package/dist/chunk-WDG7J2DY.mjs +116 -0
  66. package/dist/chunk-WJRHXI2C.mjs +733 -0
  67. package/dist/chunk-XLER2DHM.mjs +357 -0
  68. package/dist/chunk-XWC4TK2N.mjs +315 -0
  69. package/dist/chunk-YHPNOWFH.mjs +15 -0
  70. package/dist/chunk-YKC3SO4Z.mjs +32 -0
  71. package/dist/chunk-YMBXLRW5.mjs +374 -0
  72. package/dist/chunk-YPHOEJ46.mjs +64 -0
  73. package/dist/chunk-YUDCJRJM.mjs +25 -0
  74. package/dist/chunk-Z4EWP7BI.mjs +65 -0
  75. package/dist/chunk-ZB5LZQKC.mjs +191 -0
  76. package/dist/chunk-ZJRKATOJ.mjs +65 -0
  77. package/dist/color-BPKOPQKN.mjs +12 -0
  78. package/dist/estree-XC56IUFX.mjs +4414 -0
  79. package/dist/font-FEZ3GKSF.mjs +13 -0
  80. package/dist/font-size-EK775WRH.mjs +15 -0
  81. package/dist/html-S3ACX7NI.mjs +2738 -0
  82. package/dist/image-2PJIAYAT.mjs +993 -0
  83. package/dist/index.d.mts +145 -0
  84. package/dist/index.d.ts +145 -0
  85. package/dist/index.js +57855 -0
  86. package/dist/index.mjs +1790 -0
  87. package/dist/insert-gif-SAIDYURE.mjs +100 -0
  88. package/dist/insert-image-U3RJN3OW.mjs +259 -0
  89. package/dist/insert-node-5P2CRJ7S.mjs +201 -0
  90. package/dist/insert-poll-HCPM7MO6.mjs +33 -0
  91. package/dist/insert-table-24XYUS2W.mjs +66 -0
  92. package/dist/markdown-SNVBOSRA.mjs +3487 -0
  93. package/dist/poll-component-2R4MDLHS.mjs +303 -0
  94. package/dist/postcss-ONF3VDIM.mjs +5051 -0
  95. package/dist/standalone-EOIALU3M.mjs +2373 -0
  96. package/dist/stepper-FSARL6X6.mjs +304 -0
  97. package/dist/styles/notiq.css +1149 -0
  98. package/dist/text-align-VLECWO4H.mjs +118 -0
  99. package/dist/text-format-BG5WOOPZ.mjs +16 -0
  100. package/dist/typescript-AMPI6OVS.mjs +13135 -0
  101. package/package.json +66 -11
  102. package/src/styles/notiq.css +1149 -0
  103. package/src/styles/tailwind-plugin.ts +134 -0
  104. package/components.json +0 -21
  105. package/eslint.config.mjs +0 -16
  106. package/next.config.ts +0 -12
  107. package/postcss.config.mjs +0 -5
  108. package/public/file.svg +0 -1
  109. package/public/globe.svg +0 -1
  110. package/public/images/icons/plus.svg +0 -10
  111. package/public/next.svg +0 -1
  112. package/public/vercel.svg +0 -1
  113. package/public/window.svg +0 -1
  114. package/src/app/actions.ts +0 -2
  115. package/src/app/api/ai/route.ts +0 -175
  116. package/src/app/api/edgestore/[...edgestore]/route.ts +0 -28
  117. package/src/app/favicon.ico +0 -0
  118. package/src/app/globals.css +0 -205
  119. package/src/app/layout.tsx +0 -38
  120. package/src/app/page.tsx +0 -12
  121. package/src/components/editor/Core.tsx +0 -220
  122. package/src/components/editor/hooks/instructions-messages.ts +0 -300
  123. package/src/components/editor/hooks/use-mobile.ts +0 -19
  124. package/src/components/editor/hooks/useReport.ts +0 -67
  125. package/src/components/editor/hooks/useResizeObservert.ts +0 -22
  126. package/src/components/editor/index.tsx +0 -39
  127. package/src/components/editor/lexical-on-change.tsx +0 -28
  128. package/src/components/editor/nodes/CollapsibleNode/CollapsibleContainerNode.ts +0 -92
  129. package/src/components/editor/nodes/CollapsibleNode/CollapsibleContentNode.ts +0 -65
  130. package/src/components/editor/nodes/CollapsibleNode/CollapsibleTitleNode.ts +0 -105
  131. package/src/components/editor/nodes/EquationNode/EquationComponent.tsx +0 -143
  132. package/src/components/editor/nodes/EquationNode/EquationNode.tsx +0 -170
  133. package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawComponent.tsx +0 -228
  134. package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawImage.tsx +0 -137
  135. package/src/components/editor/nodes/ExcalidrawNode/ImageResizer.tsx +0 -317
  136. package/src/components/editor/nodes/ExcalidrawNode/index.tsx +0 -204
  137. package/src/components/editor/nodes/FigmaNode/FigmaNode.tsx +0 -134
  138. package/src/components/editor/nodes/Hint/HintComponet.tsx +0 -221
  139. package/src/components/editor/nodes/ImageNode/index.tsx +0 -328
  140. package/src/components/editor/nodes/InlineImageNode/InlineImageComponent.tsx +0 -383
  141. package/src/components/editor/nodes/InlineImageNode/InlineImageNode.css +0 -94
  142. package/src/components/editor/nodes/InlineImageNode/InlineImageNode.tsx +0 -309
  143. package/src/components/editor/nodes/LayoutNode/LayoutContainerNode.ts +0 -146
  144. package/src/components/editor/nodes/LayoutNode/LayoutItemNode.ts +0 -79
  145. package/src/components/editor/nodes/PollNode/index.tsx +0 -204
  146. package/src/components/editor/nodes/TweetNode/index.tsx +0 -214
  147. package/src/components/editor/nodes/index.ts +0 -81
  148. package/src/components/editor/plugins/AutoEmbedPlugin/index.tsx +0 -350
  149. package/src/components/editor/plugins/AutoLinkPlugin/index.tsx +0 -56
  150. package/src/components/editor/plugins/CodeActionMenuPlugin/components/CopyButton.tsx +0 -70
  151. package/src/components/editor/plugins/CodeActionMenuPlugin/components/PrettierButton.tsx +0 -192
  152. package/src/components/editor/plugins/CodeActionMenuPlugin/index.tsx +0 -217
  153. package/src/components/editor/plugins/CodeActionMenuPlugin/utils.ts +0 -26
  154. package/src/components/editor/plugins/CodeHighlightPlugin/index.ts +0 -21
  155. package/src/components/editor/plugins/CollapsiblePlugin/Collapsible.css +0 -76
  156. package/src/components/editor/plugins/CollapsiblePlugin/index.ts +0 -228
  157. package/src/components/editor/plugins/DragDropPastePlugin/index.tsx +0 -44
  158. package/src/components/editor/plugins/DraggableBlockPlugin/index.tsx +0 -52
  159. package/src/components/editor/plugins/EquationsPlugin/index.tsx +0 -85
  160. package/src/components/editor/plugins/ExcalidrawPlugin/index.tsx +0 -98
  161. package/src/components/editor/plugins/FigmaPlugin/index.tsx +0 -42
  162. package/src/components/editor/plugins/FloatingLinkEditorPlugin/index.tsx +0 -445
  163. package/src/components/editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx +0 -275
  164. package/src/components/editor/plugins/InlineImagePlugin/index.tsx +0 -351
  165. package/src/components/editor/plugins/LayoutPlugin/index.tsx +0 -238
  166. package/src/components/editor/plugins/LinkPlugin/index.tsx +0 -36
  167. package/src/components/editor/plugins/LinkWithMetaData/index.tsx +0 -271
  168. package/src/components/editor/plugins/MarkdownShortcutPlugin/index.tsx +0 -11
  169. package/src/components/editor/plugins/MarkdownTransformers/index.tsx +0 -304
  170. package/src/components/editor/plugins/PollPlugin/index.tsx +0 -49
  171. package/src/components/editor/plugins/ShortcutsPlugin/index.tsx +0 -180
  172. package/src/components/editor/plugins/ShortcutsPlugin/shortcuts.ts +0 -253
  173. package/src/components/editor/plugins/SlashCommand/index.tsx +0 -621
  174. package/src/components/editor/plugins/SpeechToTextPlugin/index.ts +0 -127
  175. package/src/components/editor/plugins/TabFocusPlugin/index.ts +0 -58
  176. package/src/components/editor/plugins/TableCellResizer/index.tsx +0 -438
  177. package/src/components/editor/plugins/TablePlugin/index.tsx +0 -99
  178. package/src/components/editor/plugins/ToolbarPlugin/index.tsx +0 -522
  179. package/src/components/editor/plugins/TwitterPlugin/index.ts +0 -35
  180. package/src/components/editor/plugins/YouTubeNode/index.tsx +0 -179
  181. package/src/components/editor/plugins/YouTubePlugin/index.ts +0 -41
  182. package/src/components/editor/themes/editor-theme.ts +0 -113
  183. package/src/components/editor/themes/theme.css +0 -377
  184. package/src/components/editor/utils/ai.ts +0 -291
  185. package/src/components/editor/utils/canUseDOM.ts +0 -12
  186. package/src/components/editor/utils/environment.ts +0 -50
  187. package/src/components/editor/utils/extract-data.ts +0 -166
  188. package/src/components/editor/utils/getAllLexicalChildren.ts +0 -13
  189. package/src/components/editor/utils/getDOMRangeRect.ts +0 -27
  190. package/src/components/editor/utils/getSelectedNode.ts +0 -27
  191. package/src/components/editor/utils/gif.ts +0 -29
  192. package/src/components/editor/utils/invariant.ts +0 -15
  193. package/src/components/editor/utils/setFloatingElemPosition.ts +0 -51
  194. package/src/components/editor/utils/setFloatingElemPositionForLinkEditor.ts +0 -40
  195. package/src/components/editor/utils/setNodePlaceholderFromSelection/getNodePlaceholder.ts +0 -51
  196. package/src/components/editor/utils/setNodePlaceholderFromSelection/setNodePlaceholderFromSelection.ts +0 -15
  197. package/src/components/editor/utils/setNodePlaceholderFromSelection/setPlaceholderOnSelection.ts +0 -114
  198. package/src/components/editor/utils/setNodePlaceholderFromSelection/styles.css +0 -6
  199. package/src/components/editor/utils/url.ts +0 -109
  200. package/src/components/editor/utils/useLayoutEffect.ts +0 -13
  201. package/src/components/providers/QueryProvider.tsx +0 -15
  202. package/src/components/providers/SharedHistoryContext.tsx +0 -28
  203. package/src/components/providers/ToolbarContext.tsx +0 -123
  204. package/src/components/providers/theme-provider.tsx +0 -11
  205. package/src/components/theme/ModeToggle.tsx +0 -40
  206. package/src/components/ui/FileInput.tsx +0 -40
  207. package/src/components/ui/Input.css +0 -32
  208. package/src/components/ui/Select.css +0 -42
  209. package/src/components/ui/Select.tsx +0 -36
  210. package/src/components/ui/TextInput.tsx +0 -48
  211. package/src/components/ui/ai/ai-button.tsx +0 -574
  212. package/src/components/ui/ai/border.tsx +0 -99
  213. package/src/components/ui/ai/placeholder-input-vanish.tsx +0 -282
  214. package/src/components/ui/button.tsx +0 -89
  215. package/src/components/ui/card.tsx +0 -76
  216. package/src/components/ui/checkbox.tsx +0 -30
  217. package/src/components/ui/command.tsx +0 -153
  218. package/src/components/ui/dialog/Dialog.css +0 -25
  219. package/src/components/ui/dialog/Dialog.tsx +0 -34
  220. package/src/components/ui/dialog.tsx +0 -122
  221. package/src/components/ui/drop-downs/background-color.tsx +0 -183
  222. package/src/components/ui/drop-downs/block-format.tsx +0 -159
  223. package/src/components/ui/drop-downs/code.tsx +0 -42
  224. package/src/components/ui/drop-downs/color.tsx +0 -177
  225. package/src/components/ui/drop-downs/font-size.tsx +0 -138
  226. package/src/components/ui/drop-downs/font.tsx +0 -155
  227. package/src/components/ui/drop-downs/index.tsx +0 -122
  228. package/src/components/ui/drop-downs/insert-node.tsx +0 -213
  229. package/src/components/ui/drop-downs/text-align.tsx +0 -123
  230. package/src/components/ui/drop-downs/text-format.tsx +0 -104
  231. package/src/components/ui/dropdown-menu.tsx +0 -201
  232. package/src/components/ui/equation/EquationEditor.css +0 -38
  233. package/src/components/ui/equation/EquationEditor.tsx +0 -56
  234. package/src/components/ui/equation/KatexEquationAlterer.css +0 -41
  235. package/src/components/ui/equation/KatexEquationAlterer.tsx +0 -83
  236. package/src/components/ui/equation/KatexRenderer.tsx +0 -66
  237. package/src/components/ui/excalidraw/ExcalidrawModal.css +0 -64
  238. package/src/components/ui/excalidraw/ExcalidrawModal.tsx +0 -234
  239. package/src/components/ui/excalidraw/Modal.css +0 -62
  240. package/src/components/ui/excalidraw/Modal.tsx +0 -110
  241. package/src/components/ui/hover-card.tsx +0 -29
  242. package/src/components/ui/image/error-image.tsx +0 -17
  243. package/src/components/ui/image/file-upload.tsx +0 -240
  244. package/src/components/ui/image/image-resizer.tsx +0 -297
  245. package/src/components/ui/image/image-toolbar.tsx +0 -264
  246. package/src/components/ui/image/index.tsx +0 -408
  247. package/src/components/ui/image/lazy-image.tsx +0 -68
  248. package/src/components/ui/image/lazy-video.tsx +0 -71
  249. package/src/components/ui/input.tsx +0 -22
  250. package/src/components/ui/models/custom-dialog.tsx +0 -320
  251. package/src/components/ui/models/insert-gif.tsx +0 -90
  252. package/src/components/ui/models/insert-image.tsx +0 -52
  253. package/src/components/ui/models/insert-poll.tsx +0 -29
  254. package/src/components/ui/models/insert-table.tsx +0 -62
  255. package/src/components/ui/models/use-model.tsx +0 -91
  256. package/src/components/ui/poll/poll-component.tsx +0 -304
  257. package/src/components/ui/popover.tsx +0 -33
  258. package/src/components/ui/progress.tsx +0 -28
  259. package/src/components/ui/scroll-area.tsx +0 -48
  260. package/src/components/ui/separator.tsx +0 -31
  261. package/src/components/ui/skeleton.tsx +0 -15
  262. package/src/components/ui/sonner.tsx +0 -31
  263. package/src/components/ui/stepper/step.tsx +0 -179
  264. package/src/components/ui/stepper/stepper.tsx +0 -89
  265. package/src/components/ui/textarea.tsx +0 -22
  266. package/src/components/ui/toggle.tsx +0 -71
  267. package/src/components/ui/tooltip.tsx +0 -32
  268. package/src/components/ui/write/text-format-floting-toolbar.tsx +0 -346
  269. package/src/lib/edgestore.ts +0 -9
  270. package/src/lib/pinecone-client.ts +0 -0
  271. package/src/lib/utils.ts +0 -6
  272. package/src/utils/docSerialization.ts +0 -77
  273. package/src/utils/emoji-list.ts +0 -16615
  274. package/src/utils/getDOMRangeRect.ts +0 -27
  275. package/src/utils/getThemeSelector.ts +0 -25
  276. package/src/utils/isMobileWidth.ts +0 -7
  277. package/src/utils/joinClasses.ts +0 -13
  278. package/src/utils/setFloatingElemPosition.ts +0 -74
  279. package/src/utils/setFloatingElemPositionForLinkEditor.ts +0 -46
  280. package/src/utils/swipe.ts +0 -127
  281. package/src/utils/url.ts +0 -38
  282. package/tsconfig.json +0 -27
@@ -1,204 +0,0 @@
1
- import {
2
- DecoratorNode,
3
- DOMConversionMap,
4
- DOMConversionOutput,
5
- DOMExportOutput,
6
- LexicalNode,
7
- NodeKey,
8
- SerializedLexicalNode,
9
- Spread,
10
- } from "lexical";
11
- import * as React from "react";
12
- import { Suspense } from "react";
13
-
14
- export type Options = ReadonlyArray<Option>;
15
-
16
- export type Option = Readonly<{
17
- text: string;
18
- uid: string;
19
- votes: Array<string>;
20
- }>;
21
-
22
- const PollComponent = React.lazy(
23
- () => import("@/components/ui/poll/poll-component")
24
- );
25
-
26
- function createUID(): string {
27
- return Math.random()
28
- .toString(36)
29
- .replace(/[^a-z]+/g, "")
30
- .substr(0, 5);
31
- }
32
-
33
- export function createPollOption(text = ""): Option {
34
- return {
35
- text,
36
- uid: createUID(),
37
- votes: [],
38
- };
39
- }
40
-
41
- function cloneOption(
42
- option: Option,
43
- text: string,
44
- votes?: Array<string>
45
- ): Option {
46
- return {
47
- text,
48
- uid: option.uid,
49
- votes: votes || Array.from(option.votes),
50
- };
51
- }
52
-
53
- export type SerializedPollNode = Spread<
54
- {
55
- question: string;
56
- options: Options;
57
- },
58
- SerializedLexicalNode
59
- >;
60
-
61
- function $convertPollElement(domNode: HTMLElement): DOMConversionOutput | null {
62
- const question = domNode.getAttribute("data-lexical-poll-question");
63
- const options = domNode.getAttribute("data-lexical-poll-options");
64
- if (question !== null && options !== null) {
65
- const node = $createPollNode(question, JSON.parse(options));
66
- return { node };
67
- }
68
- return null;
69
- }
70
-
71
- export class PollNode extends DecoratorNode<React.JSX.Element> {
72
- __question: string;
73
- __options: Options;
74
-
75
- static getType(): string {
76
- return "poll";
77
- }
78
-
79
- static clone(node: PollNode): PollNode {
80
- return new PollNode(node.__question, node.__options, node.__key);
81
- }
82
-
83
- static importJSON(serializedNode: SerializedPollNode): PollNode {
84
- return $createPollNode(
85
- serializedNode.question,
86
- serializedNode.options
87
- ).updateFromJSON(serializedNode);
88
- }
89
-
90
- constructor(question: string, options: Options, key?: NodeKey) {
91
- super(key);
92
- this.__question = question;
93
- this.__options = options;
94
- }
95
-
96
- exportJSON(): SerializedPollNode {
97
- return {
98
- ...super.exportJSON(),
99
- options: this.__options,
100
- question: this.__question,
101
- };
102
- }
103
-
104
- setQuestion(newQuestion: string): void {
105
- const self = this.getWritable();
106
- self.__question = newQuestion;
107
- }
108
-
109
- addOption(option: Option): void {
110
- const self = this.getWritable();
111
- const options = Array.from(self.__options);
112
- options.push(option);
113
- self.__options = options;
114
- }
115
-
116
- deleteOption(option: Option): void {
117
- const self = this.getWritable();
118
- const options = Array.from(self.__options);
119
- const index = options.indexOf(option);
120
- options.splice(index, 1);
121
- self.__options = options;
122
- }
123
-
124
- setOptionText(option: Option, text: string): void {
125
- const self = this.getWritable();
126
- const clonedOption = cloneOption(option, text);
127
- const options = Array.from(self.__options);
128
- const index = options.indexOf(option);
129
- options[index] = clonedOption;
130
- self.__options = options;
131
- }
132
-
133
- toggleVote(option: Option, clientID: string): void {
134
- const self = this.getWritable();
135
- const newOptions = self.__options.map((opt) => {
136
- if (opt.uid === option.uid) {
137
- const newVotes = opt.votes.includes(clientID)
138
- ? opt.votes.filter((id) => id !== clientID)
139
- : [...opt.votes, clientID];
140
- return { ...opt, votes: newVotes };
141
- }
142
- return { ...opt };
143
- });
144
-
145
- self.__options = newOptions;
146
- this.markDirty();
147
- }
148
-
149
- static importDOM(): DOMConversionMap | null {
150
- return {
151
- span: (domNode: HTMLElement) => {
152
- if (!domNode.hasAttribute("data-lexical-poll-question")) {
153
- return null;
154
- }
155
- return {
156
- conversion: $convertPollElement,
157
- priority: 2,
158
- };
159
- },
160
- };
161
- }
162
-
163
- exportDOM(): DOMExportOutput {
164
- const element = document.createElement("span");
165
- element.setAttribute("data-lexical-poll-question", this.__question);
166
- element.setAttribute(
167
- "data-lexical-poll-options",
168
- JSON.stringify(this.__options)
169
- );
170
- return { element };
171
- }
172
-
173
- createDOM(): HTMLElement {
174
- const elem = document.createElement("span");
175
- elem.style.display = "inline-block";
176
- return elem;
177
- }
178
-
179
- updateDOM(): false {
180
- return false;
181
- }
182
-
183
- decorate(): React.JSX.Element {
184
- return (
185
- <Suspense fallback={null}>
186
- <PollComponent
187
- question={this.__question}
188
- options={this.__options}
189
- nodeKey={this.__key}
190
- />
191
- </Suspense>
192
- );
193
- }
194
- }
195
-
196
- export function $createPollNode(question: string, options: Options): PollNode {
197
- return new PollNode(question, options);
198
- }
199
-
200
- export function $isPollNode(
201
- node: LexicalNode | null | undefined
202
- ): node is PollNode {
203
- return node instanceof PollNode;
204
- }
@@ -1,214 +0,0 @@
1
- import type {
2
- DOMConversionMap,
3
- DOMConversionOutput,
4
- DOMExportOutput,
5
- EditorConfig,
6
- ElementFormatType,
7
- LexicalEditor,
8
- LexicalNode,
9
- NodeKey,
10
- Spread,
11
- } from "lexical";
12
-
13
- import { BlockWithAlignableContents } from "@lexical/react/LexicalBlockWithAlignableContents";
14
- import {
15
- DecoratorBlockNode,
16
- SerializedDecoratorBlockNode,
17
- } from "@lexical/react/LexicalDecoratorBlockNode";
18
- import * as React from "react";
19
- import { useCallback, useEffect, useRef, useState } from "react";
20
- import { Skeleton } from "@/components/ui/skeleton";
21
-
22
- const WIDGET_SCRIPT_URL = "https://platform.twitter.com/widgets.js";
23
-
24
- type TweetComponentProps = Readonly<{
25
- className: Readonly<{
26
- base: string;
27
- focus: string;
28
- }>;
29
- format: ElementFormatType | null;
30
- loadingComponent?: React.JSX.Element | string;
31
- nodeKey: NodeKey;
32
- onError?: (error: string) => void;
33
- onLoad?: () => void;
34
- tweetID: string;
35
- }>;
36
-
37
- function $convertTweetElement(
38
- domNode: HTMLDivElement
39
- ): DOMConversionOutput | null {
40
- const id = domNode.getAttribute("data-lexical-tweet-id");
41
- if (id) {
42
- const node = $createTweetNode(id);
43
- return { node };
44
- }
45
- return null;
46
- }
47
-
48
- let isTwitterScriptLoading = true;
49
-
50
- function TweetComponent({
51
- className,
52
- format,
53
- nodeKey,
54
- onError,
55
- onLoad,
56
- tweetID,
57
- }: TweetComponentProps) {
58
- const containerRef = useRef<HTMLDivElement | null>(null);
59
-
60
- const previousTweetIDRef = useRef<string>("");
61
- const [isTweetLoading, setIsTweetLoading] = useState(false);
62
-
63
- const createTweet = useCallback(async () => {
64
- try {
65
- // @ts-expect-error Twitter is attached to the window.
66
- await window.twttr.widgets.createTweet(tweetID, containerRef.current);
67
-
68
- setIsTweetLoading(false);
69
- isTwitterScriptLoading = false;
70
-
71
- if (onLoad) {
72
- onLoad();
73
- }
74
- } catch (error) {
75
- if (onError) {
76
- onError(String(error));
77
- }
78
- }
79
- }, [onError, onLoad, tweetID]);
80
-
81
- useEffect(() => {
82
- if (tweetID !== previousTweetIDRef.current) {
83
- setIsTweetLoading(true);
84
-
85
- if (isTwitterScriptLoading) {
86
- const script = document.createElement("script");
87
- script.src = WIDGET_SCRIPT_URL;
88
- script.async = true;
89
- document.body?.appendChild(script);
90
- script.onload = createTweet;
91
- if (onError) {
92
- script.onerror = onError as OnErrorEventHandler;
93
- }
94
- } else {
95
- createTweet();
96
- }
97
-
98
- if (previousTweetIDRef) {
99
- previousTweetIDRef.current = tweetID;
100
- }
101
- }
102
- }, [createTweet, onError, tweetID]);
103
-
104
- return (
105
- <BlockWithAlignableContents
106
- className={className}
107
- format={format}
108
- nodeKey={nodeKey}
109
- >
110
- {isTweetLoading ? (
111
- <Skeleton className="max-h-[200px] w-full h-full max-w-[400px]" />
112
- ) : null}
113
- <div
114
- style={{
115
- display: "inline-block",
116
- width: "100%",
117
- }}
118
- ref={containerRef}
119
- />
120
- </BlockWithAlignableContents>
121
- );
122
- }
123
-
124
- export type SerializedTweetNode = Spread<
125
- {
126
- id: string;
127
- },
128
- SerializedDecoratorBlockNode
129
- >;
130
-
131
- export class TweetNode extends DecoratorBlockNode {
132
- __id: string;
133
-
134
- static getType(): string {
135
- return "tweet";
136
- }
137
-
138
- static clone(node: TweetNode): TweetNode {
139
- return new TweetNode(node.__id, node.__format, node.__key);
140
- }
141
-
142
- static importJSON(serializedNode: SerializedTweetNode): TweetNode {
143
- return $createTweetNode(serializedNode.id).updateFromJSON(serializedNode);
144
- }
145
-
146
- exportJSON(): SerializedTweetNode {
147
- return {
148
- ...super.exportJSON(),
149
- id: this.getId(),
150
- };
151
- }
152
-
153
- static importDOM(): DOMConversionMap<HTMLDivElement> | null {
154
- return {
155
- div: (domNode: HTMLDivElement) => {
156
- if (!domNode.hasAttribute("data-lexical-tweet-id")) {
157
- return null;
158
- }
159
- return {
160
- conversion: $convertTweetElement,
161
- priority: 2,
162
- };
163
- },
164
- };
165
- }
166
-
167
- exportDOM(): DOMExportOutput {
168
- const element = document.createElement("div");
169
- element.setAttribute("data-lexical-tweet-id", this.__id);
170
- const text = document.createTextNode(this.getTextContent());
171
- element.append(text);
172
- return { element };
173
- }
174
-
175
- constructor(id: string, format?: ElementFormatType, key?: NodeKey) {
176
- super(format, key);
177
- this.__id = id;
178
- }
179
-
180
- getId(): string {
181
- return this.__id;
182
- }
183
-
184
- getTextContent(): string {
185
- return `https://x.com/i/web/status/${this.__id}`;
186
- }
187
-
188
- decorate(editor: LexicalEditor, config: EditorConfig): React.JSX.Element {
189
- const embedBlockTheme = config.theme.embedBlock || {};
190
- const className = {
191
- base: embedBlockTheme.base || "",
192
- focus: embedBlockTheme.focus || "",
193
- };
194
- return (
195
- <TweetComponent
196
- className={className}
197
- format={this.__format}
198
- loadingComponent="Loading..."
199
- nodeKey={this.getKey()}
200
- tweetID={this.__id}
201
- />
202
- );
203
- }
204
- }
205
-
206
- export function $createTweetNode(tweetID: string): TweetNode {
207
- return new TweetNode(tweetID);
208
- }
209
-
210
- export function $isTweetNode(
211
- node: TweetNode | LexicalNode | null | undefined
212
- ): node is TweetNode {
213
- return node instanceof TweetNode;
214
- }
@@ -1,81 +0,0 @@
1
-
2
- import type {Klass, LexicalNode} from 'lexical';
3
-
4
- import {CodeHighlightNode, CodeNode} from '@lexical/code';
5
- import {HashtagNode} from '@lexical/hashtag';
6
- import {AutoLinkNode, LinkNode} from '@lexical/link';
7
- import {ListItemNode, ListNode} from '@lexical/list';
8
- import {MarkNode} from '@lexical/mark';
9
- import {OverflowNode} from '@lexical/overflow';
10
- import {HorizontalRuleNode} from '@lexical/react/LexicalHorizontalRuleNode';
11
- import {HeadingNode, QuoteNode} from '@lexical/rich-text';
12
- import {TableCellNode, TableNode, TableRowNode} from '@lexical/table';
13
- import { ImageNode } from './ImageNode';
14
- import { PollNode } from './PollNode';
15
- import { LayoutItemNode } from './LayoutNode/LayoutItemNode';
16
- import { LayoutContainerNode } from './LayoutNode/LayoutContainerNode';
17
- import { CollapsibleContainerNode } from './CollapsibleNode/CollapsibleContainerNode';
18
- import { CollapsibleContentNode } from './CollapsibleNode/CollapsibleContentNode';
19
- import { CollapsibleTitleNode } from './CollapsibleNode/CollapsibleTitleNode';
20
- import { LinkWithMetaDataNode } from '../plugins/LinkWithMetaData';
21
- import { TweetNode } from './TweetNode';
22
- import { YouTubeNode } from '../plugins/YouTubeNode';
23
- import { Hint } from './Hint';
24
- import { StepperNode } from './Stepper';
25
- import { InlineImageNode } from './InlineImageNode/InlineImageNode';
26
- import { ExcalidrawNode } from './ExcalidrawNode';
27
- import { FigmaNode } from './FigmaNode/FigmaNode';
28
- import { EquationNode } from './EquationNode/EquationNode';
29
-
30
-
31
-
32
- const nodes: Array<Klass<LexicalNode>> = [
33
- HeadingNode,
34
- ListNode,
35
- ListItemNode,
36
- QuoteNode,
37
- CodeNode,
38
- TableNode,
39
- TableCellNode,
40
- TableRowNode,
41
- CodeHighlightNode,
42
- StepperNode,
43
- AutoLinkNode,
44
- YouTubeNode,
45
- Hint,
46
- TweetNode,
47
- LinkNode,
48
- OverflowNode,
49
- HorizontalRuleNode,
50
- MarkNode,
51
- ImageNode,
52
- PollNode,
53
- LayoutItemNode,
54
- LayoutContainerNode,
55
- CollapsibleContainerNode,
56
- CollapsibleContentNode,
57
- CollapsibleTitleNode,
58
- LinkWithMetaDataNode,
59
- InlineImageNode,
60
- ExcalidrawNode,
61
- FigmaNode,
62
- EquationNode,
63
- ];
64
-
65
- export const nestedNodes: Array<Klass<LexicalNode>>=[
66
- HeadingNode,
67
- ListNode,
68
- ListItemNode,
69
- LinkNode,
70
- CodeHighlightNode,
71
- QuoteNode,
72
- CodeNode,
73
- StepperNode,
74
- LinkWithMetaDataNode,
75
- ImageNode,
76
- InlineImageNode,
77
- ExcalidrawNode,
78
- FigmaNode,
79
- EquationNode,
80
- ]
81
- export default nodes