@collabchron/notiq 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/README.md +71 -0
  2. package/components.json +21 -0
  3. package/eslint.config.mjs +16 -0
  4. package/next.config.ts +12 -0
  5. package/package.json +108 -0
  6. package/postcss.config.mjs +5 -0
  7. package/public/file.svg +1 -0
  8. package/public/globe.svg +1 -0
  9. package/public/images/icons/plus.svg +10 -0
  10. package/public/next.svg +1 -0
  11. package/public/vercel.svg +1 -0
  12. package/public/window.svg +1 -0
  13. package/src/app/actions.ts +2 -0
  14. package/src/app/api/ai/route.ts +175 -0
  15. package/src/app/api/edgestore/[...edgestore]/route.ts +28 -0
  16. package/src/app/favicon.ico +0 -0
  17. package/src/app/globals.css +205 -0
  18. package/src/app/layout.tsx +38 -0
  19. package/src/app/page.tsx +12 -0
  20. package/src/components/editor/Core.tsx +220 -0
  21. package/src/components/editor/hooks/instructions-messages.ts +300 -0
  22. package/src/components/editor/hooks/use-mobile.ts +19 -0
  23. package/src/components/editor/hooks/useReport.ts +67 -0
  24. package/src/components/editor/hooks/useResizeObservert.ts +22 -0
  25. package/src/components/editor/index.tsx +39 -0
  26. package/src/components/editor/lexical-on-change.tsx +28 -0
  27. package/src/components/editor/nodes/CollapsibleNode/CollapsibleContainerNode.ts +92 -0
  28. package/src/components/editor/nodes/CollapsibleNode/CollapsibleContentNode.ts +65 -0
  29. package/src/components/editor/nodes/CollapsibleNode/CollapsibleTitleNode.ts +105 -0
  30. package/src/components/editor/nodes/EquationNode/EquationComponent.tsx +143 -0
  31. package/src/components/editor/nodes/EquationNode/EquationNode.tsx +170 -0
  32. package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawComponent.tsx +228 -0
  33. package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawImage.tsx +137 -0
  34. package/src/components/editor/nodes/ExcalidrawNode/ImageResizer.tsx +317 -0
  35. package/src/components/editor/nodes/ExcalidrawNode/index.tsx +204 -0
  36. package/src/components/editor/nodes/FigmaNode/FigmaNode.tsx +134 -0
  37. package/src/components/editor/nodes/Hint/HintComponet.tsx +221 -0
  38. package/src/components/editor/nodes/Hint/index.tsx +190 -0
  39. package/src/components/editor/nodes/ImageNode/index.tsx +328 -0
  40. package/src/components/editor/nodes/InlineImageNode/InlineImageComponent.tsx +383 -0
  41. package/src/components/editor/nodes/InlineImageNode/InlineImageNode.css +94 -0
  42. package/src/components/editor/nodes/InlineImageNode/InlineImageNode.tsx +309 -0
  43. package/src/components/editor/nodes/LayoutNode/LayoutContainerNode.ts +146 -0
  44. package/src/components/editor/nodes/LayoutNode/LayoutItemNode.ts +79 -0
  45. package/src/components/editor/nodes/PollNode/index.tsx +204 -0
  46. package/src/components/editor/nodes/Stepper/index.tsx +260 -0
  47. package/src/components/editor/nodes/TweetNode/index.tsx +214 -0
  48. package/src/components/editor/nodes/index.ts +81 -0
  49. package/src/components/editor/plugins/AutoEmbedPlugin/index.tsx +350 -0
  50. package/src/components/editor/plugins/AutoLinkPlugin/index.tsx +56 -0
  51. package/src/components/editor/plugins/CodeActionMenuPlugin/components/CopyButton.tsx +70 -0
  52. package/src/components/editor/plugins/CodeActionMenuPlugin/components/PrettierButton.tsx +192 -0
  53. package/src/components/editor/plugins/CodeActionMenuPlugin/index.tsx +217 -0
  54. package/src/components/editor/plugins/CodeActionMenuPlugin/utils.ts +26 -0
  55. package/src/components/editor/plugins/CodeHighlightPlugin/index.ts +21 -0
  56. package/src/components/editor/plugins/CollapsiblePlugin/Collapsible.css +76 -0
  57. package/src/components/editor/plugins/CollapsiblePlugin/index.ts +228 -0
  58. package/src/components/editor/plugins/DragDropPastePlugin/index.tsx +44 -0
  59. package/src/components/editor/plugins/DraggableBlockPlugin/index.tsx +52 -0
  60. package/src/components/editor/plugins/EquationsPlugin/index.tsx +85 -0
  61. package/src/components/editor/plugins/ExcalidrawPlugin/index.tsx +98 -0
  62. package/src/components/editor/plugins/FigmaPlugin/index.tsx +42 -0
  63. package/src/components/editor/plugins/FloatingLinkEditorPlugin/index.tsx +445 -0
  64. package/src/components/editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx +275 -0
  65. package/src/components/editor/plugins/ImagesPlugin/index.tsx +222 -0
  66. package/src/components/editor/plugins/InlineImagePlugin/index.tsx +351 -0
  67. package/src/components/editor/plugins/LayoutPlugin/index.tsx +238 -0
  68. package/src/components/editor/plugins/LinkPlugin/index.tsx +36 -0
  69. package/src/components/editor/plugins/LinkWithMetaData/index.tsx +271 -0
  70. package/src/components/editor/plugins/MarkdownShortcutPlugin/index.tsx +11 -0
  71. package/src/components/editor/plugins/MarkdownTransformers/index.tsx +304 -0
  72. package/src/components/editor/plugins/PollPlugin/index.tsx +49 -0
  73. package/src/components/editor/plugins/ShortcutsPlugin/index.tsx +180 -0
  74. package/src/components/editor/plugins/ShortcutsPlugin/shortcuts.ts +253 -0
  75. package/src/components/editor/plugins/SlashCommand/index.tsx +621 -0
  76. package/src/components/editor/plugins/SpeechToTextPlugin/index.ts +127 -0
  77. package/src/components/editor/plugins/TabFocusPlugin/index.ts +58 -0
  78. package/src/components/editor/plugins/TableCellActionMenuPlugin/index.tsx +759 -0
  79. package/src/components/editor/plugins/TableCellResizer/index.tsx +438 -0
  80. package/src/components/editor/plugins/TableHoverActionsPlugin/index.tsx +314 -0
  81. package/src/components/editor/plugins/TablePlugin/index.tsx +99 -0
  82. package/src/components/editor/plugins/ToolbarPlugin/index.tsx +522 -0
  83. package/src/components/editor/plugins/TwitterPlugin/index.ts +35 -0
  84. package/src/components/editor/plugins/YouTubeNode/index.tsx +179 -0
  85. package/src/components/editor/plugins/YouTubePlugin/index.ts +41 -0
  86. package/src/components/editor/themes/editor-theme.ts +113 -0
  87. package/src/components/editor/themes/theme.css +377 -0
  88. package/src/components/editor/utils/ai.ts +291 -0
  89. package/src/components/editor/utils/canUseDOM.ts +12 -0
  90. package/src/components/editor/utils/editorFormatting.ts +282 -0
  91. package/src/components/editor/utils/environment.ts +50 -0
  92. package/src/components/editor/utils/extract-data.ts +166 -0
  93. package/src/components/editor/utils/getAllLexicalChildren.ts +13 -0
  94. package/src/components/editor/utils/getDOMRangeRect.ts +27 -0
  95. package/src/components/editor/utils/getSelectedNode.ts +27 -0
  96. package/src/components/editor/utils/gif.ts +29 -0
  97. package/src/components/editor/utils/invariant.ts +15 -0
  98. package/src/components/editor/utils/setFloatingElemPosition.ts +51 -0
  99. package/src/components/editor/utils/setFloatingElemPositionForLinkEditor.ts +40 -0
  100. package/src/components/editor/utils/setNodePlaceholderFromSelection/getNodePlaceholder.ts +51 -0
  101. package/src/components/editor/utils/setNodePlaceholderFromSelection/setNodePlaceholderFromSelection.ts +15 -0
  102. package/src/components/editor/utils/setNodePlaceholderFromSelection/setPlaceholderOnSelection.ts +114 -0
  103. package/src/components/editor/utils/setNodePlaceholderFromSelection/styles.css +6 -0
  104. package/src/components/editor/utils/url.ts +109 -0
  105. package/src/components/editor/utils/useLayoutEffect.ts +13 -0
  106. package/src/components/providers/QueryProvider.tsx +15 -0
  107. package/src/components/providers/SharedHistoryContext.tsx +28 -0
  108. package/src/components/providers/ToolbarContext.tsx +123 -0
  109. package/src/components/providers/theme-provider.tsx +11 -0
  110. package/src/components/theme/ModeToggle.tsx +40 -0
  111. package/src/components/ui/FileInput.tsx +40 -0
  112. package/src/components/ui/Input.css +32 -0
  113. package/src/components/ui/Select.css +42 -0
  114. package/src/components/ui/Select.tsx +36 -0
  115. package/src/components/ui/TextInput.tsx +48 -0
  116. package/src/components/ui/ai/ai-button.tsx +574 -0
  117. package/src/components/ui/ai/border.tsx +99 -0
  118. package/src/components/ui/ai/placeholder-input-vanish.tsx +282 -0
  119. package/src/components/ui/button.tsx +89 -0
  120. package/src/components/ui/card.tsx +76 -0
  121. package/src/components/ui/checkbox.tsx +30 -0
  122. package/src/components/ui/command.tsx +153 -0
  123. package/src/components/ui/dialog/Dialog.css +25 -0
  124. package/src/components/ui/dialog/Dialog.tsx +34 -0
  125. package/src/components/ui/dialog.tsx +122 -0
  126. package/src/components/ui/drop-downs/background-color.tsx +183 -0
  127. package/src/components/ui/drop-downs/block-format.tsx +159 -0
  128. package/src/components/ui/drop-downs/code.tsx +42 -0
  129. package/src/components/ui/drop-downs/color.tsx +177 -0
  130. package/src/components/ui/drop-downs/font-size.tsx +138 -0
  131. package/src/components/ui/drop-downs/font.tsx +155 -0
  132. package/src/components/ui/drop-downs/index.tsx +122 -0
  133. package/src/components/ui/drop-downs/insert-node.tsx +213 -0
  134. package/src/components/ui/drop-downs/text-align.tsx +123 -0
  135. package/src/components/ui/drop-downs/text-format.tsx +104 -0
  136. package/src/components/ui/dropdown-menu.tsx +201 -0
  137. package/src/components/ui/equation/EquationEditor.css +38 -0
  138. package/src/components/ui/equation/EquationEditor.tsx +56 -0
  139. package/src/components/ui/equation/KatexEquationAlterer.css +41 -0
  140. package/src/components/ui/equation/KatexEquationAlterer.tsx +83 -0
  141. package/src/components/ui/equation/KatexRenderer.tsx +66 -0
  142. package/src/components/ui/excalidraw/ExcalidrawModal.css +64 -0
  143. package/src/components/ui/excalidraw/ExcalidrawModal.tsx +234 -0
  144. package/src/components/ui/excalidraw/Modal.css +62 -0
  145. package/src/components/ui/excalidraw/Modal.tsx +110 -0
  146. package/src/components/ui/hover-card.tsx +29 -0
  147. package/src/components/ui/image/error-image.tsx +17 -0
  148. package/src/components/ui/image/file-upload.tsx +240 -0
  149. package/src/components/ui/image/image-resizer.tsx +297 -0
  150. package/src/components/ui/image/image-toolbar.tsx +264 -0
  151. package/src/components/ui/image/index.tsx +408 -0
  152. package/src/components/ui/image/lazy-image.tsx +68 -0
  153. package/src/components/ui/image/lazy-video.tsx +71 -0
  154. package/src/components/ui/input.tsx +22 -0
  155. package/src/components/ui/models/custom-dialog.tsx +320 -0
  156. package/src/components/ui/models/insert-gif.tsx +90 -0
  157. package/src/components/ui/models/insert-image.tsx +52 -0
  158. package/src/components/ui/models/insert-poll.tsx +29 -0
  159. package/src/components/ui/models/insert-table.tsx +62 -0
  160. package/src/components/ui/models/use-model.tsx +91 -0
  161. package/src/components/ui/poll/poll-component.tsx +304 -0
  162. package/src/components/ui/popover.tsx +33 -0
  163. package/src/components/ui/progress.tsx +28 -0
  164. package/src/components/ui/scroll-area.tsx +48 -0
  165. package/src/components/ui/separator.tsx +31 -0
  166. package/src/components/ui/skeleton.tsx +15 -0
  167. package/src/components/ui/sonner.tsx +31 -0
  168. package/src/components/ui/stepper/step.tsx +179 -0
  169. package/src/components/ui/stepper/stepper.tsx +89 -0
  170. package/src/components/ui/textarea.tsx +22 -0
  171. package/src/components/ui/toggle.tsx +71 -0
  172. package/src/components/ui/tooltip.tsx +32 -0
  173. package/src/components/ui/write/text-format-floting-toolbar.tsx +346 -0
  174. package/src/lib/edgestore.ts +9 -0
  175. package/src/lib/pinecone-client.ts +0 -0
  176. package/src/lib/utils.ts +6 -0
  177. package/src/utils/docSerialization.ts +77 -0
  178. package/src/utils/emoji-list.ts +16615 -0
  179. package/src/utils/getDOMRangeRect.ts +27 -0
  180. package/src/utils/getSelectedNode.ts +27 -0
  181. package/src/utils/getThemeSelector.ts +25 -0
  182. package/src/utils/isMobileWidth.ts +7 -0
  183. package/src/utils/joinClasses.ts +13 -0
  184. package/src/utils/setFloatingElemPosition.ts +74 -0
  185. package/src/utils/setFloatingElemPositionForLinkEditor.ts +46 -0
  186. package/src/utils/swipe.ts +127 -0
  187. package/src/utils/url.ts +38 -0
  188. package/tsconfig.json +27 -0
@@ -0,0 +1,180 @@
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
+ }
@@ -0,0 +1,253 @@
1
+
2
+
3
+
4
+
5
+ import { IS_APPLE } from "../../utils/environment";
6
+
7
+ /* eslint-disable sort-keys-fix/sort-keys-fix */
8
+ export const SHORTCUTS = Object.freeze({
9
+ // (Ctrl|⌘) + (Alt|Option) + <key> shortcuts
10
+ NORMAL: IS_APPLE ? '⌘+Opt+0' : 'Ctrl+Alt+0',
11
+ HEADING1: IS_APPLE ? '⌘+Opt+1' : 'Ctrl+Alt+1',
12
+ HEADING2: IS_APPLE ? '⌘+Opt+2' : 'Ctrl+Alt+2',
13
+ HEADING3: IS_APPLE ? '⌘+Opt+3' : 'Ctrl+Alt+3',
14
+ BULLET_LIST: IS_APPLE ? '⌘+Opt+4' : 'Ctrl+Alt+4',
15
+ NUMBERED_LIST: IS_APPLE ? '⌘+Opt+5' : 'Ctrl+Alt+5',
16
+ CHECK_LIST: IS_APPLE ? '⌘+Opt+6' : 'Ctrl+Alt+6',
17
+ CODE_BLOCK: IS_APPLE ? '⌘+Opt+C' : 'Ctrl+Alt+C',
18
+ QUOTE: IS_APPLE ? '⌘+Opt+Q' : 'Ctrl+Alt+Q',
19
+
20
+ // (Ctrl|⌘) + Shift + <key> shortcuts
21
+ INCREASE_FONT_SIZE: IS_APPLE ? '⌘+Shift+.' : 'Ctrl+Shift+.',
22
+ DECREASE_FONT_SIZE: IS_APPLE ? '⌘+Shift+,' : 'Ctrl+Shift+,',
23
+ INSERT_CODE_BLOCK: IS_APPLE ? '⌘+Shift+C' : 'Ctrl+Shift+C',
24
+ STRIKETHROUGH: IS_APPLE ? '⌘+Shift+S' : 'Ctrl+Shift+S',
25
+ LOWERCASE: IS_APPLE ? '⌘+Shift+1' : 'Ctrl+Shift+1',
26
+ UPPERCASE: IS_APPLE ? '⌘+Shift+2' : 'Ctrl+Shift+2',
27
+ CAPITALIZE: IS_APPLE ? '⌘+Shift+3' : 'Ctrl+Shift+3',
28
+ CENTER_ALIGN: IS_APPLE ? '⌘+Shift+E' : 'Ctrl+Shift+E',
29
+ JUSTIFY_ALIGN: IS_APPLE ? '⌘+Shift+J' : 'Ctrl+Shift+J',
30
+ LEFT_ALIGN: IS_APPLE ? '⌘+Shift+L' : 'Ctrl+Shift+L',
31
+ RIGHT_ALIGN: IS_APPLE ? '⌘+Shift+R' : 'Ctrl+Shift+R',
32
+
33
+ // (Ctrl|⌘) + <key> shortcuts
34
+ SUBSCRIPT: IS_APPLE ? '⌘+,' : 'Ctrl+,',
35
+ SUPERSCRIPT: IS_APPLE ? '⌘+.' : 'Ctrl+.',
36
+ INDENT: IS_APPLE ? '⌘+]' : 'Ctrl+]',
37
+ OUTDENT: IS_APPLE ? '⌘+[' : 'Ctrl+[',
38
+ CLEAR_FORMATTING: IS_APPLE ? '⌘+\\' : 'Ctrl+\\',
39
+ REDO: IS_APPLE ? '⌘+Shift+Z' : 'Ctrl+Y',
40
+ UNDO: IS_APPLE ? '⌘+Z' : 'Ctrl+Z',
41
+ BOLD: IS_APPLE ? '⌘+B' : 'Ctrl+B',
42
+ ITALIC: IS_APPLE ? '⌘+I' : 'Ctrl+I',
43
+ UNDERLINE: IS_APPLE ? '⌘+U' : 'Ctrl+U',
44
+ INSERT_LINK: IS_APPLE ? '⌘+K' : 'Ctrl+K',
45
+ });
46
+
47
+ export function controlOrMeta(metaKey: boolean, ctrlKey: boolean): boolean {
48
+ return IS_APPLE ? metaKey : ctrlKey;
49
+ }
50
+
51
+ export function isFormatParagraph(event: KeyboardEvent): boolean {
52
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
53
+
54
+ return (
55
+ (code === 'Numpad0' || code === 'Digit0') &&
56
+ !shiftKey &&
57
+ altKey &&
58
+ controlOrMeta(metaKey, ctrlKey)
59
+ );
60
+ }
61
+
62
+ export function isFormatHeading(event: KeyboardEvent): boolean {
63
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
64
+ const keyNumber = code[code.length - 1];
65
+
66
+ return (
67
+ ['1', '2', '3'].includes(keyNumber) &&
68
+ !shiftKey &&
69
+ altKey &&
70
+ controlOrMeta(metaKey, ctrlKey)
71
+ );
72
+ }
73
+
74
+ export function isFormatBulletList(event: KeyboardEvent): boolean {
75
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
76
+ return (
77
+ (code === 'Numpad4' || code === 'Digit4') &&
78
+ !shiftKey &&
79
+ altKey &&
80
+ controlOrMeta(metaKey, ctrlKey)
81
+ );
82
+ }
83
+
84
+ export function isFormatNumberedList(event: KeyboardEvent): boolean {
85
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
86
+ return (
87
+ (code === 'Numpad5' || code === 'Digit5') &&
88
+ !shiftKey &&
89
+ altKey &&
90
+ controlOrMeta(metaKey, ctrlKey)
91
+ );
92
+ }
93
+
94
+ export function isFormatCheckList(event: KeyboardEvent): boolean {
95
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
96
+ return (
97
+ (code === 'Numpad6' || code === 'Digit6') &&
98
+ !shiftKey &&
99
+ altKey &&
100
+ controlOrMeta(metaKey, ctrlKey)
101
+ );
102
+ }
103
+
104
+ export function isFormatCode(event: KeyboardEvent): boolean {
105
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
106
+ return (
107
+ code === 'KeyC' && !shiftKey && altKey && controlOrMeta(metaKey, ctrlKey)
108
+ );
109
+ }
110
+
111
+ export function isFormatQuote(event: KeyboardEvent): boolean {
112
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
113
+ return (
114
+ code === 'KeyQ' && !shiftKey && altKey && controlOrMeta(metaKey, ctrlKey)
115
+ );
116
+ }
117
+
118
+ export function isLowercase(event: KeyboardEvent): boolean {
119
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
120
+ return (
121
+ (code === 'Numpad1' || code === 'Digit1') &&
122
+ shiftKey &&
123
+ !altKey &&
124
+ controlOrMeta(metaKey, ctrlKey)
125
+ );
126
+ }
127
+
128
+ export function isUppercase(event: KeyboardEvent): boolean {
129
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
130
+ return (
131
+ (code === 'Numpad2' || code === 'Digit2') &&
132
+ shiftKey &&
133
+ !altKey &&
134
+ controlOrMeta(metaKey, ctrlKey)
135
+ );
136
+ }
137
+
138
+ export function isCapitalize(event: KeyboardEvent): boolean {
139
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
140
+ return (
141
+ (code === 'Numpad3' || code === 'Digit3') &&
142
+ shiftKey &&
143
+ !altKey &&
144
+ controlOrMeta(metaKey, ctrlKey)
145
+ );
146
+ }
147
+
148
+ export function isStrikeThrough(event: KeyboardEvent): boolean {
149
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
150
+ return (
151
+ code === 'KeyS' && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey)
152
+ );
153
+ }
154
+
155
+ export function isIndent(event: KeyboardEvent): boolean {
156
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
157
+ return (
158
+ code === 'BracketRight' &&
159
+ !shiftKey &&
160
+ !altKey &&
161
+ controlOrMeta(metaKey, ctrlKey)
162
+ );
163
+ }
164
+
165
+ export function isOutdent(event: KeyboardEvent): boolean {
166
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
167
+ return (
168
+ code === 'BracketLeft' &&
169
+ !shiftKey &&
170
+ !altKey &&
171
+ controlOrMeta(metaKey, ctrlKey)
172
+ );
173
+ }
174
+
175
+ export function isCenterAlign(event: KeyboardEvent): boolean {
176
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
177
+ return (
178
+ code === 'KeyE' && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey)
179
+ );
180
+ }
181
+
182
+ export function isLeftAlign(event: KeyboardEvent): boolean {
183
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
184
+ return (
185
+ code === 'KeyL' && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey)
186
+ );
187
+ }
188
+
189
+ export function isRightAlign(event: KeyboardEvent): boolean {
190
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
191
+ return (
192
+ code === 'KeyR' && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey)
193
+ );
194
+ }
195
+
196
+ export function isJustifyAlign(event: KeyboardEvent): boolean {
197
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
198
+ return (
199
+ code === 'KeyJ' && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey)
200
+ );
201
+ }
202
+
203
+ export function isSubscript(event: KeyboardEvent): boolean {
204
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
205
+ return (
206
+ code === 'Comma' && !shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey)
207
+ );
208
+ }
209
+
210
+ export function isSuperscript(event: KeyboardEvent): boolean {
211
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
212
+ return (
213
+ code === 'Period' && !shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey)
214
+ );
215
+ }
216
+
217
+ export function isInsertCodeBlock(event: KeyboardEvent): boolean {
218
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
219
+ return (
220
+ code === 'KeyC' && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey)
221
+ );
222
+ }
223
+
224
+ export function isIncreaseFontSize(event: KeyboardEvent): boolean {
225
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
226
+ return (
227
+ code === 'Period' && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey)
228
+ );
229
+ }
230
+
231
+ export function isDecreaseFontSize(event: KeyboardEvent): boolean {
232
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
233
+ return (
234
+ code === 'Comma' && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey)
235
+ );
236
+ }
237
+
238
+ export function isClearFormatting(event: KeyboardEvent): boolean {
239
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
240
+ return (
241
+ code === 'Backslash' &&
242
+ !shiftKey &&
243
+ !altKey &&
244
+ controlOrMeta(metaKey, ctrlKey)
245
+ );
246
+ }
247
+
248
+ export function isInsertLink(event: KeyboardEvent): boolean {
249
+ const {code, shiftKey, altKey, metaKey, ctrlKey} = event;
250
+ return (
251
+ code === 'KeyK' && !shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey)
252
+ );
253
+ }