@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,282 +1,238 @@
1
-
2
- import { DEFAULT_FONT_SIZE, MAX_ALLOWED_FONT_SIZE, MIN_ALLOWED_FONT_SIZE } from '@/components/providers/ToolbarContext';
3
- import {$createCodeNode} from '@lexical/code';
4
- import {
5
- INSERT_CHECK_LIST_COMMAND,
6
- INSERT_ORDERED_LIST_COMMAND,
7
- INSERT_UNORDERED_LIST_COMMAND,
8
- } from '@lexical/list';
9
- import {$isDecoratorBlockNode} from '@lexical/react/LexicalDecoratorBlockNode';
10
- import {
11
- $createHeadingNode,
12
- $createQuoteNode,
13
- $isHeadingNode,
14
- $isQuoteNode,
15
- HeadingTagType,
16
- } from '@lexical/rich-text';
17
- import {$patchStyleText, $setBlocksType} from '@lexical/selection';
18
- import { $isTableSelection} from '@lexical/table';
19
- import {$getNearestBlockElementAncestorOrThrow} from '@lexical/utils';
20
- import {
21
- $createParagraphNode,
22
- $getSelection,
23
- $isRangeSelection,
24
- $isTextNode,
25
- LexicalEditor,
26
- } from 'lexical';
27
-
28
-
29
- // eslint-disable-next-line no-shadow
30
- export enum UpdateFontSizeType {
31
- increment = 1,
32
- decrement,
33
- }
34
-
35
- /**
36
- * Calculates the new font size based on the update type.
37
- * @param currentFontSize - The current font size
38
- * @param updateType - The type of change, either increment or decrement
39
- * @returns the next font size
40
- */
41
- export const calculateNextFontSize = (
42
- currentFontSize: number,
43
- updateType: UpdateFontSizeType | null,
44
- ) => {
45
- if (!updateType) {
46
- return currentFontSize;
47
- }
48
-
49
- let updatedFontSize: number = currentFontSize;
50
- switch (updateType) {
51
- case UpdateFontSizeType.decrement:
52
- switch (true) {
53
- case currentFontSize > MAX_ALLOWED_FONT_SIZE:
54
- updatedFontSize = MAX_ALLOWED_FONT_SIZE;
55
- break;
56
- case currentFontSize >= 48:
57
- updatedFontSize -= 12;
58
- break;
59
- case currentFontSize >= 24:
60
- updatedFontSize -= 4;
61
- break;
62
- case currentFontSize >= 14:
63
- updatedFontSize -= 2;
64
- break;
65
- case currentFontSize >= 9:
66
- updatedFontSize -= 1;
67
- break;
68
- default:
69
- updatedFontSize = MIN_ALLOWED_FONT_SIZE;
70
- break;
71
- }
72
- break;
73
-
74
- case UpdateFontSizeType.increment:
75
- switch (true) {
76
- case currentFontSize < MIN_ALLOWED_FONT_SIZE:
77
- updatedFontSize = MIN_ALLOWED_FONT_SIZE;
78
- break;
79
- case currentFontSize < 12:
80
- updatedFontSize += 1;
81
- break;
82
- case currentFontSize < 20:
83
- updatedFontSize += 2;
84
- break;
85
- case currentFontSize < 36:
86
- updatedFontSize += 4;
87
- break;
88
- case currentFontSize <= 60:
89
- updatedFontSize += 12;
90
- break;
91
- default:
92
- updatedFontSize = MAX_ALLOWED_FONT_SIZE;
93
- break;
94
- }
95
- break;
96
-
97
- default:
98
- break;
99
- }
100
- return updatedFontSize;
101
- };
102
-
103
- /**
104
- * Patches the selection with the updated font size.
105
- */
106
- export const updateFontSizeInSelection = (
107
- editor: LexicalEditor,
108
- newFontSize: string | null,
109
- updateType: UpdateFontSizeType | null,
110
- ) => {
111
- const getNextFontSize = (prevFontSize: string | null): string => {
112
- if (!prevFontSize) {
113
- prevFontSize = `${DEFAULT_FONT_SIZE}px`;
114
- }
115
- prevFontSize = prevFontSize.slice(0, -2);
116
- const nextFontSize = calculateNextFontSize(
117
- Number(prevFontSize),
118
- updateType,
119
- );
120
- return `${nextFontSize}px`;
121
- };
122
-
123
- editor.update(() => {
124
- if (editor.isEditable()) {
125
- const selection = $getSelection();
126
- if (selection !== null) {
127
- $patchStyleText(selection, {
128
- 'font-size': newFontSize || getNextFontSize,
129
- });
130
- }
131
- }
132
- });
133
- };
134
-
135
- export const updateFontSize = (
136
- editor: LexicalEditor,
137
- updateType: UpdateFontSizeType,
138
- inputValue: string,
139
- ) => {
140
- if (inputValue !== '') {
141
- const nextFontSize = calculateNextFontSize(Number(inputValue), updateType);
142
- updateFontSizeInSelection(editor, String(nextFontSize) + 'px', null);
143
- } else {
144
- updateFontSizeInSelection(editor, null, updateType);
145
- }
146
- };
147
-
148
- export const formatParagraph = (editor: LexicalEditor) => {
149
- editor.update(() => {
150
- const selection = $getSelection();
151
- if ($isRangeSelection(selection)) {
152
- $setBlocksType(selection, () => $createParagraphNode());
153
- }
154
- });
155
- };
156
-
157
- export const formatHeading = (
158
- editor: LexicalEditor,
159
- blockType: string,
160
- headingSize: HeadingTagType,
161
- ) => {
162
- if (blockType !== headingSize) {
163
- editor.update(() => {
164
- const selection = $getSelection();
165
- $setBlocksType(selection, () => $createHeadingNode(headingSize));
166
- });
167
- }
168
- };
169
-
170
- export const formatBulletList = (editor: LexicalEditor, blockType: string) => {
171
- if (blockType !== 'bullet') {
172
- editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined);
173
- } else {
174
- formatParagraph(editor);
175
- }
176
- };
177
-
178
- export const formatCheckList = (editor: LexicalEditor, blockType: string) => {
179
- if (blockType !== 'check') {
180
- editor.dispatchCommand(INSERT_CHECK_LIST_COMMAND, undefined);
181
- } else {
182
- formatParagraph(editor);
183
- }
184
- };
185
-
186
- export const formatNumberedList = (
187
- editor: LexicalEditor,
188
- blockType: string,
189
- ) => {
190
- if (blockType !== 'number') {
191
- editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined);
192
- } else {
193
- formatParagraph(editor);
194
- }
195
- };
196
-
197
- export const formatQuote = (editor: LexicalEditor, blockType: string) => {
198
- if (blockType !== 'quote') {
199
- editor.update(() => {
200
- const selection = $getSelection();
201
- $setBlocksType(selection, () => $createQuoteNode());
202
- });
203
- }
204
- };
205
-
206
- export const formatCode = (editor: LexicalEditor, blockType: string) => {
207
- if (blockType !== 'code') {
208
- editor.update(() => {
209
- let selection = $getSelection();
210
-
211
- if (selection !== null) {
212
- if (selection.isCollapsed()) {
213
- $setBlocksType(selection, () => $createCodeNode());
214
- } else {
215
- const textContent = selection.getTextContent();
216
- const codeNode = $createCodeNode();
217
- selection.insertNodes([codeNode]);
218
- selection = $getSelection();
219
- if ($isRangeSelection(selection)) {
220
- selection.insertRawText(textContent);
221
- }
222
- }
223
- }
224
- });
225
- }
226
- };
227
-
228
- export const clearFormatting = (editor: LexicalEditor) => {
229
- editor.update(() => {
230
- const selection = $getSelection();
231
- if ($isRangeSelection(selection) || $isTableSelection(selection)) {
232
- const anchor = selection.anchor;
233
- const focus = selection.focus;
234
- const nodes = selection.getNodes();
235
- const extractedNodes = selection.extract();
236
-
237
- if (anchor.key === focus.key && anchor.offset === focus.offset) {
238
- return;
239
- }
240
-
241
- nodes.forEach((node, idx) => {
242
- // We split the first and last node by the selection
243
- // So that we don't format unselected text inside those nodes
244
- if ($isTextNode(node)) {
245
- // Use a separate variable to ensure TS does not lose the refinement
246
- let textNode = node;
247
- if (idx === 0 && anchor.offset !== 0) {
248
- textNode = textNode.splitText(anchor.offset)[1] || textNode;
249
- }
250
- if (idx === nodes.length - 1) {
251
- textNode = textNode.splitText(focus.offset)[0] || textNode;
252
- }
253
- /**
254
- * If the selected text has one format applied
255
- * selecting a portion of the text, could
256
- * clear the format to the wrong portion of the text.
257
- *
258
- * The cleared text is based on the length of the selected text.
259
- */
260
- // We need this in case the selected text only has one format
261
- const extractedTextNode = extractedNodes[0];
262
- if (nodes.length === 1 && $isTextNode(extractedTextNode)) {
263
- textNode = extractedTextNode;
264
- }
265
-
266
- if (textNode.__style !== '') {
267
- textNode.setStyle('');
268
- }
269
- if (textNode.__format !== 0) {
270
- textNode.setFormat(0);
271
- $getNearestBlockElementAncestorOrThrow(textNode).setFormat('');
272
- }
273
- node = textNode;
274
- } else if ($isHeadingNode(node) || $isQuoteNode(node)) {
275
- node.replace($createParagraphNode(), true);
276
- } else if ($isDecoratorBlockNode(node)) {
277
- node.setFormat('');
278
- }
279
- });
280
- }
281
- });
282
- };
1
+ import {
2
+ DEFAULT_FONT_SIZE,
3
+ MAX_ALLOWED_FONT_SIZE,
4
+ MIN_ALLOWED_FONT_SIZE
5
+ } from "./chunk-7NZAPJ4G.mjs";
6
+ import {
7
+ init_react_shim
8
+ } from "./chunk-77KXU36M.mjs";
9
+
10
+ // src/components/editor/utils/editorFormatting.ts
11
+ init_react_shim();
12
+ import { $createCodeNode } from "@lexical/code";
13
+ import {
14
+ INSERT_CHECK_LIST_COMMAND,
15
+ INSERT_ORDERED_LIST_COMMAND,
16
+ INSERT_UNORDERED_LIST_COMMAND
17
+ } from "@lexical/list";
18
+ import { $isDecoratorBlockNode } from "@lexical/react/LexicalDecoratorBlockNode";
19
+ import {
20
+ $createHeadingNode,
21
+ $createQuoteNode,
22
+ $isHeadingNode,
23
+ $isQuoteNode
24
+ } from "@lexical/rich-text";
25
+ import { $patchStyleText, $setBlocksType } from "@lexical/selection";
26
+ import { $isTableSelection } from "@lexical/table";
27
+ import { $getNearestBlockElementAncestorOrThrow } from "@lexical/utils";
28
+ import {
29
+ $createParagraphNode,
30
+ $getSelection,
31
+ $isRangeSelection,
32
+ $isTextNode
33
+ } from "lexical";
34
+ var calculateNextFontSize = (currentFontSize, updateType) => {
35
+ if (!updateType) {
36
+ return currentFontSize;
37
+ }
38
+ let updatedFontSize = currentFontSize;
39
+ switch (updateType) {
40
+ case 2 /* decrement */:
41
+ switch (true) {
42
+ case currentFontSize > MAX_ALLOWED_FONT_SIZE:
43
+ updatedFontSize = MAX_ALLOWED_FONT_SIZE;
44
+ break;
45
+ case currentFontSize >= 48:
46
+ updatedFontSize -= 12;
47
+ break;
48
+ case currentFontSize >= 24:
49
+ updatedFontSize -= 4;
50
+ break;
51
+ case currentFontSize >= 14:
52
+ updatedFontSize -= 2;
53
+ break;
54
+ case currentFontSize >= 9:
55
+ updatedFontSize -= 1;
56
+ break;
57
+ default:
58
+ updatedFontSize = MIN_ALLOWED_FONT_SIZE;
59
+ break;
60
+ }
61
+ break;
62
+ case 1 /* increment */:
63
+ switch (true) {
64
+ case currentFontSize < MIN_ALLOWED_FONT_SIZE:
65
+ updatedFontSize = MIN_ALLOWED_FONT_SIZE;
66
+ break;
67
+ case currentFontSize < 12:
68
+ updatedFontSize += 1;
69
+ break;
70
+ case currentFontSize < 20:
71
+ updatedFontSize += 2;
72
+ break;
73
+ case currentFontSize < 36:
74
+ updatedFontSize += 4;
75
+ break;
76
+ case currentFontSize <= 60:
77
+ updatedFontSize += 12;
78
+ break;
79
+ default:
80
+ updatedFontSize = MAX_ALLOWED_FONT_SIZE;
81
+ break;
82
+ }
83
+ break;
84
+ default:
85
+ break;
86
+ }
87
+ return updatedFontSize;
88
+ };
89
+ var updateFontSizeInSelection = (editor, newFontSize, updateType) => {
90
+ const getNextFontSize = (prevFontSize) => {
91
+ if (!prevFontSize) {
92
+ prevFontSize = `${DEFAULT_FONT_SIZE}px`;
93
+ }
94
+ prevFontSize = prevFontSize.slice(0, -2);
95
+ const nextFontSize = calculateNextFontSize(
96
+ Number(prevFontSize),
97
+ updateType
98
+ );
99
+ return `${nextFontSize}px`;
100
+ };
101
+ editor.update(() => {
102
+ if (editor.isEditable()) {
103
+ const selection = $getSelection();
104
+ if (selection !== null) {
105
+ $patchStyleText(selection, {
106
+ "font-size": newFontSize || getNextFontSize
107
+ });
108
+ }
109
+ }
110
+ });
111
+ };
112
+ var updateFontSize = (editor, updateType, inputValue) => {
113
+ if (inputValue !== "") {
114
+ const nextFontSize = calculateNextFontSize(Number(inputValue), updateType);
115
+ updateFontSizeInSelection(editor, String(nextFontSize) + "px", null);
116
+ } else {
117
+ updateFontSizeInSelection(editor, null, updateType);
118
+ }
119
+ };
120
+ var formatParagraph = (editor) => {
121
+ editor.update(() => {
122
+ const selection = $getSelection();
123
+ if ($isRangeSelection(selection)) {
124
+ $setBlocksType(selection, () => $createParagraphNode());
125
+ }
126
+ });
127
+ };
128
+ var formatHeading = (editor, blockType, headingSize) => {
129
+ if (blockType !== headingSize) {
130
+ editor.update(() => {
131
+ const selection = $getSelection();
132
+ $setBlocksType(selection, () => $createHeadingNode(headingSize));
133
+ });
134
+ }
135
+ };
136
+ var formatBulletList = (editor, blockType) => {
137
+ if (blockType !== "bullet") {
138
+ editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, void 0);
139
+ } else {
140
+ formatParagraph(editor);
141
+ }
142
+ };
143
+ var formatCheckList = (editor, blockType) => {
144
+ if (blockType !== "check") {
145
+ editor.dispatchCommand(INSERT_CHECK_LIST_COMMAND, void 0);
146
+ } else {
147
+ formatParagraph(editor);
148
+ }
149
+ };
150
+ var formatNumberedList = (editor, blockType) => {
151
+ if (blockType !== "number") {
152
+ editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, void 0);
153
+ } else {
154
+ formatParagraph(editor);
155
+ }
156
+ };
157
+ var formatQuote = (editor, blockType) => {
158
+ if (blockType !== "quote") {
159
+ editor.update(() => {
160
+ const selection = $getSelection();
161
+ $setBlocksType(selection, () => $createQuoteNode());
162
+ });
163
+ }
164
+ };
165
+ var formatCode = (editor, blockType) => {
166
+ if (blockType !== "code") {
167
+ editor.update(() => {
168
+ let selection = $getSelection();
169
+ if (selection !== null) {
170
+ if (selection.isCollapsed()) {
171
+ $setBlocksType(selection, () => $createCodeNode());
172
+ } else {
173
+ const textContent = selection.getTextContent();
174
+ const codeNode = $createCodeNode();
175
+ selection.insertNodes([codeNode]);
176
+ selection = $getSelection();
177
+ if ($isRangeSelection(selection)) {
178
+ selection.insertRawText(textContent);
179
+ }
180
+ }
181
+ }
182
+ });
183
+ }
184
+ };
185
+ var clearFormatting = (editor) => {
186
+ editor.update(() => {
187
+ const selection = $getSelection();
188
+ if ($isRangeSelection(selection) || $isTableSelection(selection)) {
189
+ const anchor = selection.anchor;
190
+ const focus = selection.focus;
191
+ const nodes = selection.getNodes();
192
+ const extractedNodes = selection.extract();
193
+ if (anchor.key === focus.key && anchor.offset === focus.offset) {
194
+ return;
195
+ }
196
+ nodes.forEach((node, idx) => {
197
+ if ($isTextNode(node)) {
198
+ let textNode = node;
199
+ if (idx === 0 && anchor.offset !== 0) {
200
+ textNode = textNode.splitText(anchor.offset)[1] || textNode;
201
+ }
202
+ if (idx === nodes.length - 1) {
203
+ textNode = textNode.splitText(focus.offset)[0] || textNode;
204
+ }
205
+ const extractedTextNode = extractedNodes[0];
206
+ if (nodes.length === 1 && $isTextNode(extractedTextNode)) {
207
+ textNode = extractedTextNode;
208
+ }
209
+ if (textNode.__style !== "") {
210
+ textNode.setStyle("");
211
+ }
212
+ if (textNode.__format !== 0) {
213
+ textNode.setFormat(0);
214
+ $getNearestBlockElementAncestorOrThrow(textNode).setFormat("");
215
+ }
216
+ node = textNode;
217
+ } else if ($isHeadingNode(node) || $isQuoteNode(node)) {
218
+ node.replace($createParagraphNode(), true);
219
+ } else if ($isDecoratorBlockNode(node)) {
220
+ node.setFormat("");
221
+ }
222
+ });
223
+ }
224
+ });
225
+ };
226
+
227
+ export {
228
+ updateFontSizeInSelection,
229
+ updateFontSize,
230
+ formatParagraph,
231
+ formatHeading,
232
+ formatBulletList,
233
+ formatCheckList,
234
+ formatNumberedList,
235
+ formatQuote,
236
+ formatCode,
237
+ clearFormatting
238
+ };
@@ -0,0 +1,29 @@
1
+ import {
2
+ cn
3
+ } from "./chunk-YHPNOWFH.mjs";
4
+ import {
5
+ React,
6
+ __objRest,
7
+ __spreadValues,
8
+ init_react_shim
9
+ } from "./chunk-77KXU36M.mjs";
10
+
11
+ // src/components/ui/skeleton.tsx
12
+ init_react_shim();
13
+ function Skeleton(_a) {
14
+ var _b = _a, {
15
+ className
16
+ } = _b, props = __objRest(_b, [
17
+ "className"
18
+ ]);
19
+ return /* @__PURE__ */ React.createElement(
20
+ "div",
21
+ __spreadValues({
22
+ className: cn("animate-pulse rounded-md bg-primary/10", className)
23
+ }, props)
24
+ );
25
+ }
26
+
27
+ export {
28
+ Skeleton
29
+ };