@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.
- package/README.md +71 -0
- package/components.json +21 -0
- package/eslint.config.mjs +16 -0
- package/next.config.ts +12 -0
- package/package.json +108 -0
- package/postcss.config.mjs +5 -0
- package/public/file.svg +1 -0
- package/public/globe.svg +1 -0
- package/public/images/icons/plus.svg +10 -0
- package/public/next.svg +1 -0
- package/public/vercel.svg +1 -0
- package/public/window.svg +1 -0
- package/src/app/actions.ts +2 -0
- package/src/app/api/ai/route.ts +175 -0
- package/src/app/api/edgestore/[...edgestore]/route.ts +28 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +205 -0
- package/src/app/layout.tsx +38 -0
- package/src/app/page.tsx +12 -0
- package/src/components/editor/Core.tsx +220 -0
- package/src/components/editor/hooks/instructions-messages.ts +300 -0
- package/src/components/editor/hooks/use-mobile.ts +19 -0
- package/src/components/editor/hooks/useReport.ts +67 -0
- package/src/components/editor/hooks/useResizeObservert.ts +22 -0
- package/src/components/editor/index.tsx +39 -0
- package/src/components/editor/lexical-on-change.tsx +28 -0
- package/src/components/editor/nodes/CollapsibleNode/CollapsibleContainerNode.ts +92 -0
- package/src/components/editor/nodes/CollapsibleNode/CollapsibleContentNode.ts +65 -0
- package/src/components/editor/nodes/CollapsibleNode/CollapsibleTitleNode.ts +105 -0
- package/src/components/editor/nodes/EquationNode/EquationComponent.tsx +143 -0
- package/src/components/editor/nodes/EquationNode/EquationNode.tsx +170 -0
- package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawComponent.tsx +228 -0
- package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawImage.tsx +137 -0
- package/src/components/editor/nodes/ExcalidrawNode/ImageResizer.tsx +317 -0
- package/src/components/editor/nodes/ExcalidrawNode/index.tsx +204 -0
- package/src/components/editor/nodes/FigmaNode/FigmaNode.tsx +134 -0
- package/src/components/editor/nodes/Hint/HintComponet.tsx +221 -0
- package/src/components/editor/nodes/Hint/index.tsx +190 -0
- package/src/components/editor/nodes/ImageNode/index.tsx +328 -0
- package/src/components/editor/nodes/InlineImageNode/InlineImageComponent.tsx +383 -0
- package/src/components/editor/nodes/InlineImageNode/InlineImageNode.css +94 -0
- package/src/components/editor/nodes/InlineImageNode/InlineImageNode.tsx +309 -0
- package/src/components/editor/nodes/LayoutNode/LayoutContainerNode.ts +146 -0
- package/src/components/editor/nodes/LayoutNode/LayoutItemNode.ts +79 -0
- package/src/components/editor/nodes/PollNode/index.tsx +204 -0
- package/src/components/editor/nodes/Stepper/index.tsx +260 -0
- package/src/components/editor/nodes/TweetNode/index.tsx +214 -0
- package/src/components/editor/nodes/index.ts +81 -0
- package/src/components/editor/plugins/AutoEmbedPlugin/index.tsx +350 -0
- package/src/components/editor/plugins/AutoLinkPlugin/index.tsx +56 -0
- package/src/components/editor/plugins/CodeActionMenuPlugin/components/CopyButton.tsx +70 -0
- package/src/components/editor/plugins/CodeActionMenuPlugin/components/PrettierButton.tsx +192 -0
- package/src/components/editor/plugins/CodeActionMenuPlugin/index.tsx +217 -0
- package/src/components/editor/plugins/CodeActionMenuPlugin/utils.ts +26 -0
- package/src/components/editor/plugins/CodeHighlightPlugin/index.ts +21 -0
- package/src/components/editor/plugins/CollapsiblePlugin/Collapsible.css +76 -0
- package/src/components/editor/plugins/CollapsiblePlugin/index.ts +228 -0
- package/src/components/editor/plugins/DragDropPastePlugin/index.tsx +44 -0
- package/src/components/editor/plugins/DraggableBlockPlugin/index.tsx +52 -0
- package/src/components/editor/plugins/EquationsPlugin/index.tsx +85 -0
- package/src/components/editor/plugins/ExcalidrawPlugin/index.tsx +98 -0
- package/src/components/editor/plugins/FigmaPlugin/index.tsx +42 -0
- package/src/components/editor/plugins/FloatingLinkEditorPlugin/index.tsx +445 -0
- package/src/components/editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx +275 -0
- package/src/components/editor/plugins/ImagesPlugin/index.tsx +222 -0
- package/src/components/editor/plugins/InlineImagePlugin/index.tsx +351 -0
- package/src/components/editor/plugins/LayoutPlugin/index.tsx +238 -0
- package/src/components/editor/plugins/LinkPlugin/index.tsx +36 -0
- package/src/components/editor/plugins/LinkWithMetaData/index.tsx +271 -0
- package/src/components/editor/plugins/MarkdownShortcutPlugin/index.tsx +11 -0
- package/src/components/editor/plugins/MarkdownTransformers/index.tsx +304 -0
- package/src/components/editor/plugins/PollPlugin/index.tsx +49 -0
- package/src/components/editor/plugins/ShortcutsPlugin/index.tsx +180 -0
- package/src/components/editor/plugins/ShortcutsPlugin/shortcuts.ts +253 -0
- package/src/components/editor/plugins/SlashCommand/index.tsx +621 -0
- package/src/components/editor/plugins/SpeechToTextPlugin/index.ts +127 -0
- package/src/components/editor/plugins/TabFocusPlugin/index.ts +58 -0
- package/src/components/editor/plugins/TableCellActionMenuPlugin/index.tsx +759 -0
- package/src/components/editor/plugins/TableCellResizer/index.tsx +438 -0
- package/src/components/editor/plugins/TableHoverActionsPlugin/index.tsx +314 -0
- package/src/components/editor/plugins/TablePlugin/index.tsx +99 -0
- package/src/components/editor/plugins/ToolbarPlugin/index.tsx +522 -0
- package/src/components/editor/plugins/TwitterPlugin/index.ts +35 -0
- package/src/components/editor/plugins/YouTubeNode/index.tsx +179 -0
- package/src/components/editor/plugins/YouTubePlugin/index.ts +41 -0
- package/src/components/editor/themes/editor-theme.ts +113 -0
- package/src/components/editor/themes/theme.css +377 -0
- package/src/components/editor/utils/ai.ts +291 -0
- package/src/components/editor/utils/canUseDOM.ts +12 -0
- package/src/components/editor/utils/editorFormatting.ts +282 -0
- package/src/components/editor/utils/environment.ts +50 -0
- package/src/components/editor/utils/extract-data.ts +166 -0
- package/src/components/editor/utils/getAllLexicalChildren.ts +13 -0
- package/src/components/editor/utils/getDOMRangeRect.ts +27 -0
- package/src/components/editor/utils/getSelectedNode.ts +27 -0
- package/src/components/editor/utils/gif.ts +29 -0
- package/src/components/editor/utils/invariant.ts +15 -0
- package/src/components/editor/utils/setFloatingElemPosition.ts +51 -0
- package/src/components/editor/utils/setFloatingElemPositionForLinkEditor.ts +40 -0
- package/src/components/editor/utils/setNodePlaceholderFromSelection/getNodePlaceholder.ts +51 -0
- package/src/components/editor/utils/setNodePlaceholderFromSelection/setNodePlaceholderFromSelection.ts +15 -0
- package/src/components/editor/utils/setNodePlaceholderFromSelection/setPlaceholderOnSelection.ts +114 -0
- package/src/components/editor/utils/setNodePlaceholderFromSelection/styles.css +6 -0
- package/src/components/editor/utils/url.ts +109 -0
- package/src/components/editor/utils/useLayoutEffect.ts +13 -0
- package/src/components/providers/QueryProvider.tsx +15 -0
- package/src/components/providers/SharedHistoryContext.tsx +28 -0
- package/src/components/providers/ToolbarContext.tsx +123 -0
- package/src/components/providers/theme-provider.tsx +11 -0
- package/src/components/theme/ModeToggle.tsx +40 -0
- package/src/components/ui/FileInput.tsx +40 -0
- package/src/components/ui/Input.css +32 -0
- package/src/components/ui/Select.css +42 -0
- package/src/components/ui/Select.tsx +36 -0
- package/src/components/ui/TextInput.tsx +48 -0
- package/src/components/ui/ai/ai-button.tsx +574 -0
- package/src/components/ui/ai/border.tsx +99 -0
- package/src/components/ui/ai/placeholder-input-vanish.tsx +282 -0
- package/src/components/ui/button.tsx +89 -0
- package/src/components/ui/card.tsx +76 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/command.tsx +153 -0
- package/src/components/ui/dialog/Dialog.css +25 -0
- package/src/components/ui/dialog/Dialog.tsx +34 -0
- package/src/components/ui/dialog.tsx +122 -0
- package/src/components/ui/drop-downs/background-color.tsx +183 -0
- package/src/components/ui/drop-downs/block-format.tsx +159 -0
- package/src/components/ui/drop-downs/code.tsx +42 -0
- package/src/components/ui/drop-downs/color.tsx +177 -0
- package/src/components/ui/drop-downs/font-size.tsx +138 -0
- package/src/components/ui/drop-downs/font.tsx +155 -0
- package/src/components/ui/drop-downs/index.tsx +122 -0
- package/src/components/ui/drop-downs/insert-node.tsx +213 -0
- package/src/components/ui/drop-downs/text-align.tsx +123 -0
- package/src/components/ui/drop-downs/text-format.tsx +104 -0
- package/src/components/ui/dropdown-menu.tsx +201 -0
- package/src/components/ui/equation/EquationEditor.css +38 -0
- package/src/components/ui/equation/EquationEditor.tsx +56 -0
- package/src/components/ui/equation/KatexEquationAlterer.css +41 -0
- package/src/components/ui/equation/KatexEquationAlterer.tsx +83 -0
- package/src/components/ui/equation/KatexRenderer.tsx +66 -0
- package/src/components/ui/excalidraw/ExcalidrawModal.css +64 -0
- package/src/components/ui/excalidraw/ExcalidrawModal.tsx +234 -0
- package/src/components/ui/excalidraw/Modal.css +62 -0
- package/src/components/ui/excalidraw/Modal.tsx +110 -0
- package/src/components/ui/hover-card.tsx +29 -0
- package/src/components/ui/image/error-image.tsx +17 -0
- package/src/components/ui/image/file-upload.tsx +240 -0
- package/src/components/ui/image/image-resizer.tsx +297 -0
- package/src/components/ui/image/image-toolbar.tsx +264 -0
- package/src/components/ui/image/index.tsx +408 -0
- package/src/components/ui/image/lazy-image.tsx +68 -0
- package/src/components/ui/image/lazy-video.tsx +71 -0
- package/src/components/ui/input.tsx +22 -0
- package/src/components/ui/models/custom-dialog.tsx +320 -0
- package/src/components/ui/models/insert-gif.tsx +90 -0
- package/src/components/ui/models/insert-image.tsx +52 -0
- package/src/components/ui/models/insert-poll.tsx +29 -0
- package/src/components/ui/models/insert-table.tsx +62 -0
- package/src/components/ui/models/use-model.tsx +91 -0
- package/src/components/ui/poll/poll-component.tsx +304 -0
- package/src/components/ui/popover.tsx +33 -0
- package/src/components/ui/progress.tsx +28 -0
- package/src/components/ui/scroll-area.tsx +48 -0
- package/src/components/ui/separator.tsx +31 -0
- package/src/components/ui/skeleton.tsx +15 -0
- package/src/components/ui/sonner.tsx +31 -0
- package/src/components/ui/stepper/step.tsx +179 -0
- package/src/components/ui/stepper/stepper.tsx +89 -0
- package/src/components/ui/textarea.tsx +22 -0
- package/src/components/ui/toggle.tsx +71 -0
- package/src/components/ui/tooltip.tsx +32 -0
- package/src/components/ui/write/text-format-floting-toolbar.tsx +346 -0
- package/src/lib/edgestore.ts +9 -0
- package/src/lib/pinecone-client.ts +0 -0
- package/src/lib/utils.ts +6 -0
- package/src/utils/docSerialization.ts +77 -0
- package/src/utils/emoji-list.ts +16615 -0
- package/src/utils/getDOMRangeRect.ts +27 -0
- package/src/utils/getSelectedNode.ts +27 -0
- package/src/utils/getThemeSelector.ts +25 -0
- package/src/utils/isMobileWidth.ts +7 -0
- package/src/utils/joinClasses.ts +13 -0
- package/src/utils/setFloatingElemPosition.ts +74 -0
- package/src/utils/setFloatingElemPositionForLinkEditor.ts +46 -0
- package/src/utils/swipe.ts +127 -0
- package/src/utils/url.ts +38 -0
- 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
|
+
}
|