@collabchron/notiq 0.3.0 → 1.0.1

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-YKYA4NB4.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 +67 -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,42 +0,0 @@
1
- import React from "react";
2
- import {
3
- CODE_LANGUAGE_FRIENDLY_NAME_MAP,
4
- getLanguageFriendlyName,
5
- } from "@lexical/code";
6
- import { DropDown } from ".";
7
-
8
- function getCodeLanguageOptions(): [string, string][] {
9
- const options: [string, string][] = [];
10
- for (const [lang, friendlyName] of Object.entries(
11
- CODE_LANGUAGE_FRIENDLY_NAME_MAP
12
- )) {
13
- options.push([lang, friendlyName]);
14
- }
15
- return options;
16
- }
17
-
18
- export default function CodeList({
19
- onCodeLanguageSelect,
20
- disabled = false,
21
- codeLanguage,
22
- }: {
23
- onCodeLanguageSelect: (v: string) => void;
24
- disabled?: boolean;
25
- codeLanguage: string;
26
- }) {
27
- const CODE_LANGUAGE_OPTIONS = getCodeLanguageOptions();
28
-
29
- const languageButtons = CODE_LANGUAGE_OPTIONS.map(([lang]) => ({
30
- label: lang,
31
- func: () => onCodeLanguageSelect(lang),
32
- }));
33
-
34
- return (
35
- <DropDown
36
- values={languageButtons}
37
- disabled={disabled}
38
- TriggerClassName={{ maxWidth: "200px", minWidth: "60px", width: "130px" }}
39
- TriggerLabel={getLanguageFriendlyName(codeLanguage)}
40
- />
41
- );
42
- }
@@ -1,177 +0,0 @@
1
- import { $getSelection, LexicalEditor } from "lexical";
2
- import React, { useCallback } from "react";
3
- import { $patchStyleText } from "@lexical/selection";
4
- import { useTheme } from "next-themes";
5
- import {
6
- Popover,
7
- PopoverContent,
8
- PopoverTrigger,
9
- } from "@/components/ui/popover";
10
- import { Button } from "@/components/ui/button";
11
- import { cn } from "@/lib/utils";
12
- import { Separator } from "@/components/ui/separator";
13
- import { BaselineIcon } from "lucide-react";
14
-
15
- export default function Color({
16
- disabled,
17
- color,
18
- bgColor,
19
- editor,
20
- isTable = false,
21
- side = "bottom",
22
- sideOffset = 0,
23
- style,
24
- }: {
25
- disabled: boolean;
26
- color?: string;
27
- bgColor?: string;
28
- editor: LexicalEditor;
29
- isTable?: boolean;
30
- style?: React.CSSProperties;
31
- side?: "bottom" | "left" | "right" | "top";
32
- sideOffset?: number;
33
- }) {
34
- const { theme } = useTheme();
35
-
36
- const applyStyleText = useCallback(
37
- (styles: Record<string, string>, skipHistoryStack?: boolean) => {
38
- editor.update(
39
- () => {
40
- const selection = $getSelection();
41
- if (selection !== null) {
42
- $patchStyleText(selection, styles);
43
- }
44
- },
45
- skipHistoryStack ? { tag: "historic" } : {}
46
- );
47
- },
48
- [editor]
49
- );
50
- const onFontColorSelect = useCallback(
51
- (value: string, skipHistoryStack: boolean) => {
52
- applyStyleText({ color: value }, skipHistoryStack);
53
- },
54
- [applyStyleText]
55
- );
56
-
57
- const onBgColorSelect = useCallback(
58
- (value: string, skipHistoryStack: boolean) => {
59
- applyStyleText({ "background-color": value }, skipHistoryStack);
60
- },
61
- [applyStyleText]
62
- );
63
- const dark = React.useMemo(
64
- () => ({
65
- font: {
66
- default: "white",
67
- Gray: "var(--font-gray)",
68
- Brown: "var(--font-brown)",
69
- Orange: "var(--font-orange)",
70
- Yellow: "var(--font-yellow)",
71
- Green: "var(--font-green)",
72
- Blue: "var(--font-blue)",
73
- Purple: "var(--font-purple)",
74
- Pink: "var(--font-pink)",
75
- Red: "var(--font-red)",
76
- },
77
- background: {
78
- default: "none",
79
- Gray: "var(--background-gray)",
80
- Brown: "var(--background-brown)",
81
- Orange: "var(--background-orange)",
82
- Yellow: "var(--background-yellow)",
83
- Green: "var(--background-green)",
84
- Blue: "var(--background-blue)",
85
- Purple: "var(--background-purple)",
86
- Pink: "var(--background-pink)",
87
- Red: "var(--background-red)",
88
- },
89
- }),
90
- []
91
- );
92
-
93
- const light = React.useMemo(
94
- () => ({
95
- font: {
96
- Gray: "var(--font-gray)",
97
- Brown: "var(--font-brown)",
98
- Orange: "var(--font-orange)",
99
- Yellow: "var(--font-yellow)",
100
- Green: "var(--font-green)",
101
- Blue: "var(--font-blue)",
102
- Purple: "var(--font-purple)",
103
- Pink: "var(--font-pink)",
104
- Red: "var(--font-red)",
105
- },
106
- background: {
107
- Gray: "var(--background-gray)",
108
- Brown: "var(--background-brown)",
109
- Orange: "var(--background-orange)",
110
- Yellow: "var(--background-yellow)",
111
- Green: "var(--background-green)",
112
- Blue: "var(--background-blue)",
113
- Purple: "var(--background-purple)",
114
- Pink: "var(--background-pink)",
115
- Red: "var(--background-red)",
116
- },
117
- }),
118
- []
119
- );
120
-
121
- const themeColor = React.useMemo(
122
- () => (theme === "dark" ? dark : light),
123
- [theme, dark, light]
124
- );
125
-
126
-
127
- return (
128
- <Popover>
129
- <PopoverTrigger asChild disabled={disabled}>
130
- {!isTable ? (
131
- <Button
132
- style={{
133
- ...style,
134
- color: theme === "dark" && color === "#000" ? "white" :
135
- theme !== "dark" && color === "#fff" ? "black" : color,
136
- }}
137
- variant={"transparent"}
138
- className="px-2 border-none cursor-pointer hover:dark-bg-accent hover:text-foreground"
139
- size="Toolbar"
140
- onMouseDown={(e) => e.preventDefault()}
141
- >
142
- <BaselineIcon />
143
- </Button>
144
- ) : (<></>)}
145
- </PopoverTrigger>
146
- <PopoverContent className="max-w-32 w-full p-2 z-[250]" side={side} sideOffset={sideOffset}>
147
- <div className="flex flex-col">
148
- {!isTable && (
149
- <div className="flex flex-col gap-y-1">
150
- <span className="text-[10px] cursor-default font-bold text-gray-500">
151
- Font color
152
- </span>
153
- <div className="w-full flex flex-wrap gap-1">
154
- {Object.entries(themeColor.font).map(
155
- ([_, colorValue]) => (
156
- <Button
157
- key={colorValue}
158
- type="button"
159
- onClick={() => onFontColorSelect(colorValue, true)}
160
- className={cn(
161
- "w-[18px] p-0 h-[18px] rounded-[3px]",
162
- colorValue === color && "ring-2 ring-offset-2"
163
- )}
164
- style={{ background: colorValue }}
165
- onMouseDown={(e) => e.preventDefault()}
166
- />
167
- )
168
- )}
169
- </div>
170
- <Separator className="my-2 h-[1px]" />
171
- </div>
172
- )}
173
- </div>
174
- </PopoverContent>
175
- </Popover>
176
- );
177
- }
@@ -1,138 +0,0 @@
1
- import * as React from "react";
2
-
3
- import { LexicalEditor } from "lexical";
4
- import { Minus, Plus } from "lucide-react";
5
- import { Button } from "@/components/ui/button";
6
- import { cn } from "@/lib/utils";
7
- import { MAX_ALLOWED_FONT_SIZE, MIN_ALLOWED_FONT_SIZE } from "@/components/providers/ToolbarContext";
8
- import { updateFontSize, updateFontSizeInSelection, UpdateFontSizeType } from "../../editor/utils/editorFormatting";
9
- import { SHORTCUTS } from "../../editor/plugins/ShortcutsPlugin/shortcuts";
10
- import { Input } from "@/components/ui/input";
11
-
12
- export function parseAllowedFontSize(input: string): string {
13
- const match = input.match(/^(\d+(?:\.\d+)?)px$/);
14
- if (match) {
15
- const n = Number(match[1]);
16
- if (n >= MIN_ALLOWED_FONT_SIZE && n <= MAX_ALLOWED_FONT_SIZE) {
17
- return input;
18
- }
19
- }
20
- return "";
21
- }
22
-
23
- export default function FontSize({
24
- selectionFontSize,
25
- disabled,
26
- editor,
27
- className,
28
- classNameContent
29
- }: {
30
- selectionFontSize: string;
31
- disabled: boolean;
32
- editor: LexicalEditor;
33
- className?:string,
34
- classNameContent?:string
35
- }) {
36
- const [inputValue, setInputValue] = React.useState<string>(selectionFontSize);
37
- const [inputChangeFlag, setInputChangeFlag] = React.useState<boolean>(false);
38
- const handleKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {
39
- const inputValueNumber = Number(inputValue);
40
-
41
- if (e.key === "Tab") {
42
- return;
43
- }
44
- if (["e", "E", "+", "-"].includes(e.key) || isNaN(inputValueNumber)) {
45
- e.preventDefault();
46
- setInputValue("");
47
- return;
48
- }
49
- setInputChangeFlag(true);
50
- if (e.key === "Enter" || e.key === "Escape") {
51
- e.preventDefault();
52
-
53
- updateFontSizeByInputValue(inputValueNumber);
54
- }
55
- };
56
- const handleInputBlur = () => {
57
- if (inputValue !== "" && inputChangeFlag) {
58
- const inputValueNumber = Number(inputValue);
59
- updateFontSizeByInputValue(inputValueNumber);
60
- }
61
- };
62
-
63
- const updateFontSizeByInputValue = (inputValueNumber: number) => {
64
- let updatedFontSize = inputValueNumber;
65
- if (inputValueNumber > MAX_ALLOWED_FONT_SIZE) {
66
- updatedFontSize = MAX_ALLOWED_FONT_SIZE;
67
- } else if (inputValueNumber < MIN_ALLOWED_FONT_SIZE) {
68
- updatedFontSize = MIN_ALLOWED_FONT_SIZE;
69
- }
70
-
71
- setInputValue(String(updatedFontSize));
72
- updateFontSizeInSelection(editor, String(updatedFontSize) + "px", null);
73
- setInputChangeFlag(false);
74
- };
75
-
76
- React.useEffect(() => {
77
- setInputValue(selectionFontSize);
78
- }, [selectionFontSize]);
79
- return (
80
- <div className={cn("flex flex-row items-center gap-1",classNameContent)}>
81
- <Button
82
- type="button"
83
- className={
84
- cn("h-7 min-w-[29px] w-[29px] px-[6px] border-none cursor-pointer",className)
85
- }
86
- tip={`decrement ${SHORTCUTS.INCREASE_FONT_SIZE}`}
87
- disabled={
88
- disabled ||
89
- (selectionFontSize !== "" &&
90
- Number(inputValue) <= MIN_ALLOWED_FONT_SIZE)
91
- }
92
- variant={"outline"}
93
- size={"Toolbar"}
94
- onClick={() =>
95
- updateFontSize(editor, UpdateFontSizeType.decrement, inputValue)
96
- }
97
- >
98
- <Minus className="w-[15px] h-[15px]" />
99
- </Button>
100
-
101
- <Input
102
- type="number"
103
-
104
- value={inputValue}
105
- disabled={disabled}
106
- className={
107
- cn("h-7 min-w-[29px] w-[29px] px-[6px] border-none cursor-text",className)
108
- }
109
- min={MIN_ALLOWED_FONT_SIZE}
110
- max={MAX_ALLOWED_FONT_SIZE}
111
- onChange={(e) => setInputValue(e.target.value)}
112
- onKeyDown={handleKeyPress}
113
- onBlur={handleInputBlur}
114
- />
115
- <Button
116
- type="button"
117
- tip={`increment ${SHORTCUTS.DECREASE_FONT_SIZE}`}
118
-
119
- className={
120
- cn("h-7 min-w-[29px] w-[29px] px-[6px] border-none cursor-pointer",className)
121
- }
122
-
123
- disabled={
124
- disabled ||
125
- (selectionFontSize !== "" &&
126
- Number(inputValue) >= MAX_ALLOWED_FONT_SIZE)
127
- }
128
- variant={"outline"}
129
- size={"Toolbar"}
130
- onClick={() =>
131
- updateFontSize(editor, UpdateFontSizeType.increment, inputValue)
132
- }
133
- >
134
- <Plus className="w-4 h-4" />
135
- </Button>
136
- </div>
137
- );
138
- }
@@ -1,155 +0,0 @@
1
- import { $getSelection, LexicalEditor } from "lexical";
2
- import React, { CSSProperties, useCallback } from "react";
3
- import { $patchStyleText } from "@lexical/selection";
4
- import { DropDown } from ".";
5
-
6
- interface FontOption {
7
- label: string;
8
- func: () => void;
9
- style: CSSProperties;
10
- }
11
-
12
- export default function Font({
13
- editor,
14
- style,
15
- disabled,
16
- value,
17
- sideOffset,
18
- side,
19
- ShowChevronsUpDown,
20
- }: {
21
- editor: LexicalEditor;
22
- disabled: boolean;
23
- value: string;
24
- style?: React.CSSProperties;
25
- ShowChevronsUpDown?: boolean;
26
- side?: "top" | "right" | "bottom" | "left" | undefined;
27
- sideOffset?: number;
28
- }) {
29
- const applyFont = useCallback(
30
- (font: string) => {
31
- editor.update(() => {
32
- const selection = $getSelection();
33
- if (selection !== null) {
34
- $patchStyleText(selection, {
35
- ["font-family"]: font,
36
- });
37
- }
38
- });
39
- },
40
- [editor, style]
41
- );
42
-
43
- const FONT_FAMILY_OPTIONS: FontOption[] = [
44
- {
45
- label: "Arial",
46
- func: () => applyFont("Arial"),
47
- style: { fontFamily: "Arial" },
48
- },
49
- {
50
- label: "Courier New",
51
- func: () => applyFont("Courier New"),
52
- style: { fontFamily: "Courier New" },
53
- },
54
- {
55
- label: "Georgia",
56
- func: () => applyFont("Georgia"),
57
- style: { fontFamily: "Georgia" },
58
- },
59
- {
60
- label: "Times New Roman",
61
- func: () => applyFont("Times New Roman"),
62
- style: { fontFamily: "Times New Roman" },
63
- },
64
- {
65
- label: "Trebuchet MS",
66
- func: () => applyFont("Trebuchet MS"),
67
- style: { fontFamily: "Trebuchet MS" },
68
- },
69
- {
70
- label: "Verdana",
71
- func: () => applyFont("Verdana"),
72
- style: { fontFamily: "Verdana" },
73
- },
74
- {
75
- label: "Comic Sans MS",
76
- func: () => applyFont("Comic Sans MS"),
77
- style: { fontFamily: "Comic Sans MS" },
78
- },
79
- {
80
- label: "Calibri",
81
- func: () => applyFont("Calibri"),
82
- style: { fontFamily: "Calibri" },
83
- },
84
- {
85
- label: "Poppins",
86
- func: () => applyFont("Poppins"),
87
- style: { fontFamily: "Poppins" },
88
- },
89
- {
90
- label: "Alegreya",
91
- func: () => applyFont("Alegreya"),
92
- style: { fontFamily: "Alegreya" },
93
- },
94
- {
95
- label: "Bree Serif",
96
- func: () => applyFont("Bree Serif"),
97
- style: { fontFamily: "Bree Serif" },
98
- },
99
- {
100
- label: "Cambria",
101
- func: () => applyFont("Cambria"),
102
- style: { fontFamily: "Cambria" },
103
- },
104
- {
105
- label: "Impact",
106
- func: () => applyFont("Impact"),
107
- style: { fontFamily: "Impact" },
108
- },
109
- {
110
- label: "Lexend",
111
- func: () => applyFont("Lexend"),
112
- style: { fontFamily: "Lexend" },
113
- },
114
- {
115
- label: "Lobster",
116
- func: () => applyFont("Lobster"),
117
- style: { fontFamily: "Lobster" },
118
- },
119
- {
120
- label: "Lora",
121
- func: () => applyFont("Lora"),
122
- style: { fontFamily: "Lora" },
123
- },
124
- {
125
- label: "Permanent Marker",
126
- func: () => applyFont("Permanent Marker"),
127
- style: { fontFamily: "Permanent Marker" },
128
- },
129
- {
130
- label: "Ultra",
131
- func: () => applyFont("Ultra"),
132
- style: { fontFamily: "Ultra" },
133
- },
134
- {
135
- label: "Reenie Beanie",
136
- func: () => applyFont("Reenie Beanie"),
137
- style: { fontFamily: "Reenie Beanie" },
138
- },
139
- ];
140
-
141
-
142
- return (
143
- <DropDown
144
- ShowChevronsUpDown={ShowChevronsUpDown}
145
- side={side}
146
- sideOffset={sideOffset}
147
- className="h-7 min-w-[29px] w-[29px] px-2 border-none cursor-pointer hover:bg-zinc-100 hover:text-zinc-900"
148
- PopoverContentClassName={{ minWidth: "80px", width: "150px" }}
149
- TriggerClassName={{ ...style, width: "100%" }}
150
- disabled={disabled}
151
- TriggerLabel={value}
152
- values={FONT_FAMILY_OPTIONS}
153
- />
154
- );
155
- }
@@ -1,122 +0,0 @@
1
- "use client";
2
-
3
- import * as React from "react";
4
- import { Check, ChevronsUpDown } from "lucide-react";
5
- import { Button } from "@/components/ui/button";
6
- import {
7
- Command,
8
- CommandEmpty,
9
- CommandGroup,
10
- CommandInput,
11
- CommandItem,
12
- CommandList,
13
- CommandShortcut,
14
- } from "@/components/ui/command";
15
- import {
16
- Popover,
17
- PopoverContent,
18
- PopoverTrigger,
19
- } from "@/components/ui/popover";
20
- import { cn } from "@/lib/utils";
21
-
22
- interface values {
23
- icon?: React.ReactNode;
24
- label: string;
25
- desc?: string;
26
- func?: () => void;
27
- style?: React.CSSProperties;
28
- isSelected?: boolean;
29
- shortcuts?: string;
30
-
31
- }
32
- interface Props {
33
- TriggerLabel: React.ReactNode | string;
34
- TriggerClassName?: React.CSSProperties;
35
- className?: string;
36
- PopoverContentClassName?: React.CSSProperties;
37
- values: values[];
38
- disabled: boolean;
39
- triggerVariants?:"ghost" | "default" |"outline" |"link" | "secondary" | "destructive"
40
- ShowChevronsUpDown?:boolean
41
- side?: "top" | "right" | "bottom" | "left" | undefined
42
- sideOffset?:number
43
- }
44
-
45
- export function DropDown({
46
- className,
47
- TriggerLabel,
48
- TriggerClassName,
49
- values,
50
- disabled,
51
- PopoverContentClassName,
52
- triggerVariants="outline",
53
- ShowChevronsUpDown=true,
54
- side="bottom",
55
- sideOffset=5
56
- }: Props) {
57
- const [value, setValue] = React.useState("");
58
-
59
- return (
60
- <Popover modal={false}>
61
- <PopoverTrigger disabled={disabled} asChild>
62
- <Button
63
- variant={triggerVariants}
64
- role="combobox"
65
- size={"Toolbar"}
66
- style={TriggerClassName}
67
- className={className}
68
- >
69
- <div className="flex flex-row justify-center gap-x-3 items-center">
70
- {TriggerLabel}
71
- </div>
72
- {ShowChevronsUpDown && <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />}
73
- </Button>
74
- </PopoverTrigger>
75
- <PopoverContent
76
- side={side}
77
- sideOffset={sideOffset}
78
- style={PopoverContentClassName!}
79
- className="w-[200px] p-0 dropdown-portal"
80
- >
81
- <Command>
82
- <CommandInput placeholder="Search..." />
83
- <CommandList>
84
- <CommandEmpty>No found.</CommandEmpty>
85
- <CommandGroup>
86
- {values.map((framework) => (
87
- <CommandItem
88
- key={framework.label}
89
- value={framework.label}
90
- style={framework.style}
91
- className={cn(
92
- "cursor-pointer",
93
- value === framework.label && "bg-gray-300/10",
94
- )}
95
- onSelect={(currentValue) => {
96
- setValue(currentValue === value ? "" : currentValue);
97
- if (framework.func) framework?.func();
98
- }}
99
- >
100
- <div className="flex w-full flex-row items-center justify-between">
101
- <div className="flex items-center gap-4 flex-row">
102
- {framework.icon}
103
- <div className="flex flex-col">
104
- {framework.label}
105
- <span className="text-sm text-muted-foreground">
106
- {framework.desc}
107
- </span>
108
- </div>
109
- </div>
110
- {framework.shortcuts && (
111
- <CommandShortcut>{framework.shortcuts}</CommandShortcut>
112
- )}
113
- </div>
114
- </CommandItem>
115
- ))}
116
- </CommandGroup>
117
- </CommandList>
118
- </Command>
119
- </PopoverContent>
120
- </Popover>
121
- );
122
- }