@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,127 @@
|
|
|
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 type {LexicalCommand, LexicalEditor, RangeSelection} from 'lexical';
|
|
10
|
+
|
|
11
|
+
import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext';
|
|
12
|
+
import {
|
|
13
|
+
$getSelection,
|
|
14
|
+
$isRangeSelection,
|
|
15
|
+
COMMAND_PRIORITY_EDITOR,
|
|
16
|
+
createCommand,
|
|
17
|
+
REDO_COMMAND,
|
|
18
|
+
UNDO_COMMAND,
|
|
19
|
+
} from 'lexical';
|
|
20
|
+
import {useEffect, useRef, useState} from 'react';
|
|
21
|
+
import useReport from '../../hooks/useReport';
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export const SPEECH_TO_TEXT_COMMAND: LexicalCommand<boolean> = createCommand(
|
|
25
|
+
'SPEECH_TO_TEXT_COMMAND',
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const VOICE_COMMANDS: Readonly<
|
|
29
|
+
Record<
|
|
30
|
+
string,
|
|
31
|
+
(arg0: {editor: LexicalEditor; selection: RangeSelection}) => void
|
|
32
|
+
>
|
|
33
|
+
> = {
|
|
34
|
+
'\n': ({selection}) => {
|
|
35
|
+
selection.insertParagraph();
|
|
36
|
+
},
|
|
37
|
+
redo: ({editor}) => {
|
|
38
|
+
editor.dispatchCommand(REDO_COMMAND, undefined);
|
|
39
|
+
},
|
|
40
|
+
undo: ({editor}) => {
|
|
41
|
+
editor.dispatchCommand(UNDO_COMMAND, undefined);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const SUPPORT_SPEECH_RECOGNITION: boolean =
|
|
46
|
+
typeof window !== "undefined" &&
|
|
47
|
+
("SpeechRecognition" in window || "webkitSpeechRecognition" in window);
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
function SpeechToTextPlugin(): null {
|
|
51
|
+
const [editor] = useLexicalComposerContext();
|
|
52
|
+
const [isEnabled, setIsEnabled] = useState<boolean>(false);
|
|
53
|
+
const SpeechRecognition =
|
|
54
|
+
// @ts-expect-error missing type
|
|
55
|
+
window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
56
|
+
const recognition = useRef<typeof SpeechRecognition | null>(null);
|
|
57
|
+
const report = useReport();
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (isEnabled && recognition.current === null) {
|
|
61
|
+
recognition.current = new SpeechRecognition();
|
|
62
|
+
recognition.current.continuous = true;
|
|
63
|
+
recognition.current.interimResults = true;
|
|
64
|
+
recognition.current.addEventListener(
|
|
65
|
+
'result',
|
|
66
|
+
(event: typeof SpeechRecognition) => {
|
|
67
|
+
const resultItem = event.results.item(event.resultIndex);
|
|
68
|
+
const {transcript} = resultItem.item(0);
|
|
69
|
+
report(transcript);
|
|
70
|
+
|
|
71
|
+
if (!resultItem.isFinal) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
editor.update(() => {
|
|
76
|
+
const selection = $getSelection();
|
|
77
|
+
|
|
78
|
+
if ($isRangeSelection(selection)) {
|
|
79
|
+
const command = VOICE_COMMANDS[transcript.toLowerCase().trim()];
|
|
80
|
+
|
|
81
|
+
if (command) {
|
|
82
|
+
command({
|
|
83
|
+
editor,
|
|
84
|
+
selection,
|
|
85
|
+
});
|
|
86
|
+
} else if (transcript.match(/\s*\n\s*/)) {
|
|
87
|
+
selection.insertParagraph();
|
|
88
|
+
} else {
|
|
89
|
+
selection.insertText(transcript);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (recognition.current) {
|
|
98
|
+
if (isEnabled) {
|
|
99
|
+
recognition.current.start();
|
|
100
|
+
} else {
|
|
101
|
+
recognition.current.stop();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return () => {
|
|
106
|
+
if (recognition.current !== null) {
|
|
107
|
+
recognition.current.stop();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}, [SpeechRecognition, editor, isEnabled, report]);
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
return editor.registerCommand(
|
|
113
|
+
SPEECH_TO_TEXT_COMMAND,
|
|
114
|
+
(_isEnabled: boolean) => {
|
|
115
|
+
setIsEnabled(_isEnabled);
|
|
116
|
+
return true;
|
|
117
|
+
},
|
|
118
|
+
COMMAND_PRIORITY_EDITOR,
|
|
119
|
+
);
|
|
120
|
+
}, [editor]);
|
|
121
|
+
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export default (SUPPORT_SPEECH_RECOGNITION
|
|
126
|
+
? SpeechToTextPlugin
|
|
127
|
+
: () => null) as () => null;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
|
|
2
|
+
import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext';
|
|
3
|
+
import {
|
|
4
|
+
$getSelection,
|
|
5
|
+
$isRangeSelection,
|
|
6
|
+
$setSelection,
|
|
7
|
+
FOCUS_COMMAND,
|
|
8
|
+
} from 'lexical';
|
|
9
|
+
import {useEffect} from 'react';
|
|
10
|
+
|
|
11
|
+
const COMMAND_PRIORITY_LOW = 1;
|
|
12
|
+
const TAB_TO_FOCUS_INTERVAL = 100;
|
|
13
|
+
|
|
14
|
+
let lastTabKeyDownTimestamp = 0;
|
|
15
|
+
let hasRegisteredKeyDownListener = false;
|
|
16
|
+
|
|
17
|
+
function registerKeyTimeStampTracker() {
|
|
18
|
+
window.addEventListener(
|
|
19
|
+
'keydown',
|
|
20
|
+
(event: KeyboardEvent) => {
|
|
21
|
+
// Tab
|
|
22
|
+
if (event.key === 'Tab') {
|
|
23
|
+
lastTabKeyDownTimestamp = event.timeStamp;
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
true,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default function TabFocusPlugin(): null {
|
|
31
|
+
const [editor] = useLexicalComposerContext();
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!hasRegisteredKeyDownListener) {
|
|
35
|
+
registerKeyTimeStampTracker();
|
|
36
|
+
hasRegisteredKeyDownListener = true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return editor.registerCommand(
|
|
40
|
+
FOCUS_COMMAND,
|
|
41
|
+
(event: FocusEvent) => {
|
|
42
|
+
const selection = $getSelection();
|
|
43
|
+
if ($isRangeSelection(selection)) {
|
|
44
|
+
if (
|
|
45
|
+
lastTabKeyDownTimestamp + TAB_TO_FOCUS_INTERVAL >
|
|
46
|
+
event.timeStamp
|
|
47
|
+
) {
|
|
48
|
+
$setSelection(selection.clone());
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
},
|
|
53
|
+
COMMAND_PRIORITY_LOW,
|
|
54
|
+
);
|
|
55
|
+
}, [editor]);
|
|
56
|
+
|
|
57
|
+
return null;
|
|
58
|
+
}
|