@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,304 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- import {
10
- $convertFromMarkdownString,
11
- $convertToMarkdownString,
12
- CHECK_LIST,
13
- ELEMENT_TRANSFORMERS,
14
- ElementTransformer,
15
- MULTILINE_ELEMENT_TRANSFORMERS,
16
- TEXT_FORMAT_TRANSFORMERS,
17
- TEXT_MATCH_TRANSFORMERS,
18
- TextMatchTransformer,
19
- Transformer,
20
- } from "@lexical/markdown";
21
- import {
22
- $createHorizontalRuleNode,
23
- $isHorizontalRuleNode,
24
- HorizontalRuleNode,
25
- } from "@lexical/react/LexicalHorizontalRuleNode";
26
- import {
27
- $createTableCellNode,
28
- $createTableNode,
29
- $createTableRowNode,
30
- $isTableCellNode,
31
- $isTableNode,
32
- $isTableRowNode,
33
- TableCellHeaderStates,
34
- TableCellNode,
35
- TableNode,
36
- TableRowNode,
37
- } from "@lexical/table";
38
- import {
39
- $createTextNode,
40
- $isParagraphNode,
41
- $isTextNode,
42
- LexicalNode,
43
- } from "lexical";
44
-
45
- import {
46
- $createImageNode,
47
- $isImageNode,
48
- ImageNode,
49
- } from "../../nodes/ImageNode";
50
-
51
- export const HR: ElementTransformer = {
52
- dependencies: [HorizontalRuleNode],
53
- export: (node: LexicalNode) => {
54
- return $isHorizontalRuleNode(node) ? "***" : null;
55
- },
56
- regExp: /^(---|\*\*\*|___)\s?$/,
57
- replace: (parentNode, _1, _2, isImport) => {
58
- const line = $createHorizontalRuleNode();
59
-
60
- // TODO: Get rid of isImport flag
61
- if (isImport || parentNode.getNextSibling() != null) {
62
- parentNode.replace(line);
63
- } else {
64
- parentNode.insertBefore(line);
65
- }
66
-
67
- line.selectNext();
68
- },
69
- type: "element",
70
- };
71
-
72
- export const IMAGE: TextMatchTransformer = {
73
- dependencies: [ImageNode],
74
- export: (node) => {
75
- if (!$isImageNode(node)) {
76
- return null;
77
- }
78
-
79
- return `![${node.getAltText()}](${node.getSrc()})`;
80
- },
81
- importRegExp: /!(?:\[([^[]*)\])(?:\(([^(]+)\))/,
82
- regExp: /!(?:\[([^[]*)\])(?:\(([^(]+)\))$/,
83
- replace: (textNode, match) => {
84
- const [, altText, src] = match;
85
- const imageNode = $createImageNode({
86
- altText,
87
- maxWidth: 800,
88
- src,
89
- });
90
- textNode.replace(imageNode);
91
- },
92
- trigger: ")",
93
- type: "text-match",
94
- };
95
-
96
-
97
-
98
- // export const EQUATION: TextMatchTransformer = {
99
- // dependencies: [EquationNode],
100
- // export: (node) => {
101
- // if (!$isEquationNode(node)) {
102
- // return null;
103
- // }
104
-
105
- // return `$${node.getEquation()}$`;
106
- // },
107
- // importRegExp: /\$([^$]+?)\$/,
108
- // regExp: /\$([^$]+?)\$$/,
109
- // replace: (textNode, match) => {
110
- // const [, equation] = match;
111
- // const equationNode = $createEquationNode(equation, true);
112
- // textNode.replace(equationNode);
113
- // },
114
- // trigger: "$",
115
- // type: "text-match",
116
- // };
117
-
118
- // export const TWEET: ElementTransformer = {
119
- // dependencies: [TweetNode],
120
- // export: (node) => {
121
- // if (!$isTweetNode(node)) {
122
- // return null;
123
- // }
124
-
125
- // return `<tweet id="${node.getId()}" />`;
126
- // },
127
- // regExp: /<tweet id="([^"]+?)"\s?\/>\s?$/,
128
- // replace: (textNode, _1, match) => {
129
- // const [, id] = match;
130
- // const tweetNode = $createTweetNode(id);
131
- // textNode.replace(tweetNode);
132
- // },
133
- // type: "element",
134
- // };
135
-
136
- // Very primitive table setup
137
- const TABLE_ROW_REG_EXP = /^(?:\|)(.+)(?:\|)\s?$/;
138
- const TABLE_ROW_DIVIDER_REG_EXP = /^(\| ?:?-*:? ?)+\|\s?$/;
139
-
140
- export const TABLE: ElementTransformer = {
141
- dependencies: [TableNode, TableRowNode, TableCellNode],
142
- export: (node: LexicalNode) => {
143
- if (!$isTableNode(node)) {
144
- return null;
145
- }
146
-
147
- const output: string[] = [];
148
-
149
- for (const row of node.getChildren()) {
150
- const rowOutput = [];
151
- if (!$isTableRowNode(row)) {
152
- continue;
153
- }
154
-
155
- let isHeaderRow = false;
156
- for (const cell of row.getChildren()) {
157
- // It's TableCellNode so it's just to make flow happy
158
- if ($isTableCellNode(cell)) {
159
- rowOutput.push(
160
- $convertToMarkdownString(PLAYGROUND_TRANSFORMERS, cell)
161
- .replace(/\n/g, "\\n")
162
- .trim()
163
- );
164
- if (cell.__headerState === TableCellHeaderStates.ROW) {
165
- isHeaderRow = true;
166
- }
167
- }
168
- }
169
-
170
- output.push(`| ${rowOutput.join(" | ")} |`);
171
- if (isHeaderRow) {
172
- output.push(`| ${rowOutput.map((_) => "---").join(" | ")} |`);
173
- }
174
- }
175
-
176
- return output.join("\n");
177
- },
178
- regExp: TABLE_ROW_REG_EXP,
179
- replace: (parentNode, _1, match) => {
180
- // Header row
181
- if (TABLE_ROW_DIVIDER_REG_EXP.test(match[0])) {
182
- const table = parentNode.getPreviousSibling();
183
- if (!table || !$isTableNode(table)) {
184
- return;
185
- }
186
-
187
- const rows = table.getChildren();
188
- const lastRow = rows[rows.length - 1];
189
- if (!lastRow || !$isTableRowNode(lastRow)) {
190
- return;
191
- }
192
-
193
- // Add header state to row cells
194
- lastRow.getChildren().forEach((cell) => {
195
- if (!$isTableCellNode(cell)) {
196
- return;
197
- }
198
- cell.setHeaderStyles(
199
- TableCellHeaderStates.ROW,
200
- TableCellHeaderStates.ROW
201
- );
202
- });
203
-
204
- // Remove line
205
- parentNode.remove();
206
- return;
207
- }
208
-
209
- const matchCells = mapToTableCells(match[0]);
210
-
211
- if (matchCells == null) {
212
- return;
213
- }
214
-
215
- const rows = [matchCells];
216
- let sibling = parentNode.getPreviousSibling();
217
- let maxCells = matchCells.length;
218
-
219
- while (sibling) {
220
- if (!$isParagraphNode(sibling)) {
221
- break;
222
- }
223
-
224
- if (sibling.getChildrenSize() !== 1) {
225
- break;
226
- }
227
-
228
- const firstChild = sibling.getFirstChild();
229
-
230
- if (!$isTextNode(firstChild)) {
231
- break;
232
- }
233
-
234
- const cells = mapToTableCells(firstChild.getTextContent());
235
-
236
- if (cells == null) {
237
- break;
238
- }
239
-
240
- maxCells = Math.max(maxCells, cells.length);
241
- rows.unshift(cells);
242
- const previousSibling = sibling.getPreviousSibling();
243
- sibling.remove();
244
- sibling = previousSibling;
245
- }
246
-
247
- const table = $createTableNode();
248
-
249
- for (const cells of rows) {
250
- const tableRow = $createTableRowNode();
251
- table.append(tableRow);
252
-
253
- for (let i = 0; i < maxCells; i++) {
254
- tableRow.append(i < cells.length ? cells[i] : $createTableCell(""));
255
- }
256
- }
257
-
258
- const previousSibling = parentNode.getPreviousSibling();
259
- if (
260
- $isTableNode(previousSibling) &&
261
- getTableColumnsSize(previousSibling) === maxCells
262
- ) {
263
- previousSibling.append(...table.getChildren());
264
- parentNode.remove();
265
- } else {
266
- parentNode.replace(table);
267
- }
268
-
269
- table.selectEnd();
270
- },
271
- type: "element",
272
- };
273
-
274
- function getTableColumnsSize(table: TableNode) {
275
- const row = table.getFirstChild();
276
- return $isTableRowNode(row) ? row.getChildrenSize() : 0;
277
- }
278
-
279
- const $createTableCell = (textContent: string): TableCellNode => {
280
- textContent = textContent.replace(/\\n/g, "\n");
281
- const cell = $createTableCellNode(TableCellHeaderStates.NO_STATUS);
282
- $convertFromMarkdownString(textContent, PLAYGROUND_TRANSFORMERS, cell);
283
- return cell;
284
- };
285
-
286
- const mapToTableCells = (textContent: string): Array<TableCellNode> | null => {
287
- const match = textContent.match(TABLE_ROW_REG_EXP);
288
- if (!match || !match[1]) {
289
- return null;
290
- }
291
- return match[1].split("|").map((text) => $createTableCell(text));
292
- };
293
-
294
- export const PLAYGROUND_TRANSFORMERS: Array<Transformer> = [
295
- TABLE,
296
- HR,
297
- IMAGE,
298
- // TWEET,
299
- CHECK_LIST,
300
- ...ELEMENT_TRANSFORMERS,
301
- ...MULTILINE_ELEMENT_TRANSFORMERS,
302
- ...TEXT_FORMAT_TRANSFORMERS,
303
- ...TEXT_MATCH_TRANSFORMERS,
304
- ];
@@ -1,49 +0,0 @@
1
-
2
- import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext';
3
- import {$wrapNodeInElement} from '@lexical/utils';
4
- import {
5
- $createParagraphNode,
6
- $insertNodes,
7
- $isRootOrShadowRoot,
8
- COMMAND_PRIORITY_EDITOR,
9
- createCommand,
10
- LexicalCommand,
11
- } from 'lexical';
12
- import {useEffect} from 'react';
13
- import * as React from 'react';
14
- import { $createPollNode, createPollOption, PollNode } from '../../nodes/PollNode';
15
-
16
-
17
-
18
- export const INSERT_POLL_COMMAND: LexicalCommand<string> = createCommand(
19
- 'INSERT_POLL_COMMAND',
20
- );
21
-
22
-
23
-
24
- export default function PollPlugin(): React.JSX.Element | null {
25
- const [editor] = useLexicalComposerContext();
26
- useEffect(() => {
27
- if (!editor.hasNodes([PollNode])) {
28
- throw new Error('PollPlugin: PollNode not registered on editor');
29
- }
30
-
31
- return editor.registerCommand<string>(
32
- INSERT_POLL_COMMAND,
33
- (payload) => {
34
- const pollNode = $createPollNode(payload, [
35
- createPollOption(),
36
- createPollOption(),
37
- ]);
38
- $insertNodes([pollNode]);
39
- if ($isRootOrShadowRoot(pollNode.getParentOrThrow())) {
40
- $wrapNodeInElement(pollNode, $createParagraphNode).selectEnd();
41
- }
42
-
43
- return true;
44
- },
45
- COMMAND_PRIORITY_EDITOR,
46
- );
47
- }, [editor]);
48
- return null;
49
- }
@@ -1,180 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- import {TOGGLE_LINK_COMMAND} from '@lexical/link';
10
- import {HeadingTagType} from '@lexical/rich-text';
11
- import {
12
- COMMAND_PRIORITY_NORMAL,
13
- FORMAT_ELEMENT_COMMAND,
14
- FORMAT_TEXT_COMMAND,
15
- INDENT_CONTENT_COMMAND,
16
- KEY_MODIFIER_COMMAND,
17
- LexicalEditor,
18
- OUTDENT_CONTENT_COMMAND,
19
- } from 'lexical';
20
- import {Dispatch, useEffect} from 'react';
21
-
22
- import {sanitizeUrl} from '../../utils/url';
23
- import {
24
- clearFormatting,
25
- formatBulletList,
26
- formatCheckList,
27
- formatCode,
28
- formatHeading,
29
- formatNumberedList,
30
- formatParagraph,
31
- formatQuote,
32
- updateFontSize,
33
- UpdateFontSizeType,
34
- } from '@/components/editor/utils/editorFormatting';
35
- import {
36
- isCapitalize,
37
- isCenterAlign,
38
- isClearFormatting,
39
- isDecreaseFontSize,
40
- isFormatBulletList,
41
- isFormatCheckList,
42
- isFormatCode,
43
- isFormatHeading,
44
- isFormatNumberedList,
45
- isFormatParagraph,
46
- isFormatQuote,
47
- isIncreaseFontSize,
48
- isIndent,
49
- isInsertCodeBlock,
50
- isInsertLink,
51
- isJustifyAlign,
52
- isLeftAlign,
53
- isLowercase,
54
- isOutdent,
55
- isRightAlign,
56
- isStrikeThrough,
57
- isSubscript,
58
- isSuperscript,
59
- isUppercase,
60
- } from './shortcuts';
61
- import { useToolbarState } from '@/components/providers/ToolbarContext';
62
-
63
- export default function ShortcutsPlugin({
64
- editor,
65
- setIsLinkEditMode,
66
- }: {
67
- editor: LexicalEditor;
68
- setIsLinkEditMode: Dispatch<boolean>;
69
- }): null {
70
- const {toolbarState} = useToolbarState();
71
-
72
- useEffect(() => {
73
- const keyboardShortcutsHandler = (payload: KeyboardEvent) => {
74
- const event: KeyboardEvent = payload;
75
-
76
- if (isFormatParagraph(event)) {
77
- event.preventDefault();
78
- formatParagraph(editor);
79
- } else if (isFormatHeading(event)) {
80
- event.preventDefault();
81
- const {code} = event;
82
- const headingSize = `h${code[code.length - 1]}` as HeadingTagType;
83
- formatHeading(editor, toolbarState.blockType, headingSize);
84
- } else if (isFormatBulletList(event)) {
85
- event.preventDefault();
86
- formatBulletList(editor, toolbarState.blockType);
87
- } else if (isFormatNumberedList(event)) {
88
- event.preventDefault();
89
- formatNumberedList(editor, toolbarState.blockType);
90
- } else if (isFormatCheckList(event)) {
91
- event.preventDefault();
92
- formatCheckList(editor, toolbarState.blockType);
93
- } else if (isFormatCode(event)) {
94
- event.preventDefault();
95
- formatCode(editor, toolbarState.blockType);
96
- } else if (isFormatQuote(event)) {
97
- event.preventDefault();
98
- formatQuote(editor, toolbarState.blockType);
99
- } else if (isStrikeThrough(event)) {
100
- event.preventDefault();
101
- editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'strikethrough');
102
- } else if (isLowercase(event)) {
103
- event.preventDefault();
104
- editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'lowercase');
105
- } else if (isUppercase(event)) {
106
- event.preventDefault();
107
- editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'uppercase');
108
- } else if (isCapitalize(event)) {
109
- event.preventDefault();
110
- editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'capitalize');
111
- } else if (isIndent(event)) {
112
- event.preventDefault();
113
- editor.dispatchCommand(INDENT_CONTENT_COMMAND, undefined);
114
- } else if (isOutdent(event)) {
115
- event.preventDefault();
116
- editor.dispatchCommand(OUTDENT_CONTENT_COMMAND, undefined);
117
- } else if (isCenterAlign(event)) {
118
- event.preventDefault();
119
- editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'center');
120
- } else if (isLeftAlign(event)) {
121
- event.preventDefault();
122
- editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'left');
123
- } else if (isRightAlign(event)) {
124
- event.preventDefault();
125
- editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'right');
126
- } else if (isJustifyAlign(event)) {
127
- event.preventDefault();
128
- editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'justify');
129
- } else if (isSubscript(event)) {
130
- event.preventDefault();
131
- editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'subscript');
132
- } else if (isSuperscript(event)) {
133
- event.preventDefault();
134
- editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'superscript');
135
- } else if (isInsertCodeBlock(event)) {
136
- event.preventDefault();
137
- editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'code');
138
- } else if (isIncreaseFontSize(event)) {
139
- event.preventDefault();
140
- updateFontSize(
141
- editor,
142
- UpdateFontSizeType.increment,
143
- toolbarState.fontSizeInputValue,
144
- );
145
- } else if (isDecreaseFontSize(event)) {
146
- event.preventDefault();
147
- updateFontSize(
148
- editor,
149
- UpdateFontSizeType.decrement,
150
- toolbarState.fontSizeInputValue,
151
- );
152
- } else if (isClearFormatting(event)) {
153
- event.preventDefault();
154
- clearFormatting(editor);
155
- } else if (isInsertLink(event)) {
156
- event.preventDefault();
157
- const url = toolbarState.isLink ? null : sanitizeUrl('https://');
158
- setIsLinkEditMode(!toolbarState.isLink);
159
-
160
- editor.dispatchCommand(TOGGLE_LINK_COMMAND, url);
161
- }
162
-
163
- return false;
164
- };
165
-
166
- return editor.registerCommand(
167
- KEY_MODIFIER_COMMAND,
168
- keyboardShortcutsHandler,
169
- COMMAND_PRIORITY_NORMAL,
170
- );
171
- }, [
172
- editor,
173
- toolbarState.isLink,
174
- toolbarState.blockType,
175
- toolbarState.fontSizeInputValue,
176
- setIsLinkEditMode,
177
- ]);
178
-
179
- return null;
180
- }