@scottjgilbert/lexical-blog-editor 0.1.4 → 1.0.0-beta.2
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 +73 -67
- package/build/Editor.d.ts +8 -3
- package/build/Editor.d.ts.map +1 -1
- package/build/Editor.js +13 -8
- package/build/EditorExport.d.ts +4 -0
- package/build/EditorExport.d.ts.map +1 -0
- package/build/EditorExport.js +13 -0
- package/build/appSettings.d.ts +1 -1
- package/build/appSettings.js +1 -1
- package/build/buildHTMLConfig.d.ts +1 -1
- package/build/buildHTMLConfig.d.ts.map +1 -1
- package/build/buildHTMLConfig.js +35 -11
- package/build/context/FlashMessageContext.d.ts +2 -2
- package/build/context/FlashMessageContext.d.ts.map +1 -1
- package/build/context/FlashMessageContext.js +4 -3
- package/build/context/SharedHistoryContext.d.ts +3 -3
- package/build/context/SharedHistoryContext.d.ts.map +1 -1
- package/build/context/SharedHistoryContext.js +3 -2
- package/build/context/ToolbarContext.d.ts +1 -0
- package/build/context/ToolbarContext.d.ts.map +1 -1
- package/build/context/ToolbarContext.js +2 -0
- package/build/hooks/useModal.d.ts.map +1 -1
- package/build/hooks/useModal.js +1 -0
- package/build/hooks/useReport.d.ts +0 -7
- package/build/hooks/useReport.d.ts.map +1 -1
- package/build/hooks/useReport.js +1 -0
- package/build/index.css +283 -246
- package/build/index.d.ts +3 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/nodes/CodeNode/CodeHighlightNode.d.ts +35 -0
- package/build/nodes/CodeNode/CodeHighlightNode.d.ts.map +1 -0
- package/build/nodes/CodeNode/CodeHighlightNode.js +88 -0
- package/build/nodes/CodeNode/CodeHighlighterShiki.d.ts +22 -0
- package/build/nodes/CodeNode/CodeHighlighterShiki.d.ts.map +1 -0
- package/build/nodes/CodeNode/CodeHighlighterShiki.js +644 -0
- package/build/nodes/CodeNode/CodeNode.d.ts +48 -0
- package/build/nodes/CodeNode/CodeNode.d.ts.map +1 -0
- package/build/nodes/CodeNode/CodeNode.js +367 -0
- package/build/nodes/CodeNode/FacadeShiki.d.ts +18 -0
- package/build/nodes/CodeNode/FacadeShiki.d.ts.map +1 -0
- package/build/nodes/CodeNode/FacadeShiki.js +159 -0
- package/build/nodes/CodeNode/FlatStructureUtils.d.ts +21 -0
- package/build/nodes/CodeNode/FlatStructureUtils.d.ts.map +1 -0
- package/build/nodes/CodeNode/FlatStructureUtils.js +85 -0
- package/build/nodes/CodeNode/invariant.d.ts +2 -0
- package/build/nodes/CodeNode/invariant.d.ts.map +1 -0
- package/build/nodes/CodeNode/invariant.js +6 -0
- package/build/nodes/DateTimeNode/DateTimeComponent.d.ts.map +1 -1
- package/build/nodes/DateTimeNode/DateTimeComponent.js +1 -0
- package/build/nodes/DateTimeNode/DateTimeNode.css +21 -0
- package/build/nodes/FigmaNode/FigmaNode.d.ts.map +1 -0
- package/build/nodes/FigmaNode/ServerFigmaNode.d.ts +21 -0
- package/build/nodes/FigmaNode/ServerFigmaNode.d.ts.map +1 -0
- package/build/nodes/FigmaNode/ServerFigmaNode.js +48 -0
- package/build/nodes/ImageComponent.d.ts.map +1 -1
- package/build/nodes/ImageComponent.js +1 -2
- package/build/nodes/ImageNode.d.ts +7 -7
- package/build/nodes/ImageNode.d.ts.map +1 -1
- package/build/nodes/ImageNode.js +30 -30
- package/build/nodes/LayoutContainerNode.d.ts +2 -2
- package/build/nodes/LayoutContainerNode.d.ts.map +1 -1
- package/build/nodes/LayoutContainerNode.js +10 -10
- package/build/nodes/PlaygroundNodes/PlaygroundNodes.d.ts.map +1 -0
- package/build/nodes/{PlaygroundNodes.js → PlaygroundNodes/PlaygroundNodes.js} +19 -21
- package/build/nodes/PlaygroundNodes/ServerPlaygroundNodes.d.ts +11 -0
- package/build/nodes/PlaygroundNodes/ServerPlaygroundNodes.d.ts.map +1 -0
- package/build/nodes/PlaygroundNodes/ServerPlaygroundNodes.js +65 -0
- package/build/nodes/TweetNode/ServerTweetNode.d.ts +20 -0
- package/build/nodes/TweetNode/ServerTweetNode.d.ts.map +1 -0
- package/build/nodes/TweetNode/ServerTweetNode.js +59 -0
- package/build/nodes/TweetNode/TweetNode.d.ts.map +1 -0
- package/build/nodes/YouTubeNode/ServerYouTubeNode.d.ts +21 -0
- package/build/nodes/YouTubeNode/ServerYouTubeNode.d.ts.map +1 -0
- package/build/nodes/YouTubeNode/ServerYouTubeNode.js +67 -0
- package/build/nodes/YouTubeNode/YouTubeNode.d.ts.map +1 -0
- package/build/plugins/ActionsPlugin/index.d.ts +0 -7
- package/build/plugins/ActionsPlugin/index.d.ts.map +1 -1
- package/build/plugins/ActionsPlugin/index.js +2 -1
- package/build/plugins/AutoEmbedPlugin/index.d.ts +2 -9
- package/build/plugins/AutoEmbedPlugin/index.d.ts.map +1 -1
- package/build/plugins/AutoEmbedPlugin/index.js +30 -29
- package/build/plugins/AutoLinkPlugin/index.d.ts +1 -1
- package/build/plugins/AutoLinkPlugin/index.d.ts.map +1 -1
- package/build/plugins/AutoLinkPlugin/index.js +3 -2
- package/build/plugins/CodeActionMenuPlugin/components/CopyButton/index.d.ts +1 -1
- package/build/plugins/CodeActionMenuPlugin/components/CopyButton/index.d.ts.map +1 -1
- package/build/plugins/CodeActionMenuPlugin/components/CopyButton/index.js +7 -6
- package/build/plugins/CodeActionMenuPlugin/components/PrettierButton/index.d.ts +2 -2
- package/build/plugins/CodeActionMenuPlugin/components/PrettierButton/index.d.ts.map +1 -1
- package/build/plugins/CodeActionMenuPlugin/components/PrettierButton/index.js +25 -24
- package/build/plugins/CodeActionMenuPlugin/index.d.ts +2 -9
- package/build/plugins/CodeActionMenuPlugin/index.d.ts.map +1 -1
- package/build/plugins/CodeActionMenuPlugin/index.js +22 -20
- package/build/plugins/CodeActionMenuPlugin/utils.d.ts.map +1 -1
- package/build/plugins/CodeActionMenuPlugin/utils.js +3 -2
- package/build/plugins/CodeHighlightPrismPlugin/index.d.ts +1 -1
- package/build/plugins/CodeHighlightPrismPlugin/index.d.ts.map +1 -1
- package/build/plugins/CodeHighlightPrismPlugin/index.js +4 -10
- package/build/plugins/CodeHighlightShikiPlugin/index.d.ts +1 -1
- package/build/plugins/CodeHighlightShikiPlugin/index.d.ts.map +1 -1
- package/build/plugins/CodeHighlightShikiPlugin/index.js +3 -3
- package/build/plugins/CollapsiblePlugin/Collapsible.css +17 -1
- package/build/plugins/CollapsiblePlugin/index.d.ts +1 -1
- package/build/plugins/CollapsiblePlugin/index.d.ts.map +1 -1
- package/build/plugins/CollapsiblePlugin/index.js +11 -10
- package/build/plugins/ComponentPickerPlugin/index.d.ts.map +1 -1
- package/build/plugins/ComponentPickerPlugin/index.js +3 -8
- package/build/plugins/ContextMenuPlugin/index.d.ts +1 -1
- package/build/plugins/ContextMenuPlugin/index.d.ts.map +1 -1
- package/build/plugins/ContextMenuPlugin/index.js +15 -14
- package/build/plugins/DateTimePlugin/index.d.ts +2 -2
- package/build/plugins/DateTimePlugin/index.d.ts.map +1 -1
- package/build/plugins/DateTimePlugin/index.js +8 -14
- package/build/plugins/DragDropPastePlugin/index.d.ts +0 -7
- package/build/plugins/DragDropPastePlugin/index.d.ts.map +1 -1
- package/build/plugins/DragDropPastePlugin/index.js +12 -11
- package/build/plugins/DraggableBlockPlugin/index.css +6 -0
- package/build/plugins/DraggableBlockPlugin/index.d.ts +2 -2
- package/build/plugins/DraggableBlockPlugin/index.d.ts.map +1 -1
- package/build/plugins/DraggableBlockPlugin/index.js +23 -22
- package/build/plugins/EmojiPickerPlugin/index.d.ts +0 -7
- package/build/plugins/EmojiPickerPlugin/index.d.ts.map +1 -1
- package/build/plugins/EmojiPickerPlugin/index.js +1 -0
- package/build/plugins/EmojisPlugin/index.d.ts +1 -8
- package/build/plugins/EmojisPlugin/index.d.ts.map +1 -1
- package/build/plugins/EmojisPlugin/index.js +10 -16
- package/build/plugins/EquationsPlugin/index.d.ts +3 -3
- package/build/plugins/EquationsPlugin/index.d.ts.map +1 -1
- package/build/plugins/EquationsPlugin/index.js +14 -10
- package/build/plugins/FigmaPlugin/index.d.ts +2 -2
- package/build/plugins/FigmaPlugin/index.d.ts.map +1 -1
- package/build/plugins/FigmaPlugin/index.js +8 -14
- package/build/plugins/FloatingLinkEditorPlugin/index.css +11 -0
- package/build/plugins/FloatingLinkEditorPlugin/index.d.ts +3 -3
- package/build/plugins/FloatingLinkEditorPlugin/index.d.ts.map +1 -1
- package/build/plugins/FloatingLinkEditorPlugin/index.js +28 -27
- package/build/plugins/FloatingTextFormatToolbarPlugin/index.css +15 -0
- package/build/plugins/FloatingTextFormatToolbarPlugin/index.d.ts.map +1 -1
- package/build/plugins/FloatingTextFormatToolbarPlugin/index.js +2 -1
- package/build/plugins/ImagesPlugin/index.d.ts +3 -3
- package/build/plugins/ImagesPlugin/index.d.ts.map +1 -1
- package/build/plugins/ImagesPlugin/index.js +38 -37
- package/build/plugins/KeywordsPlugin/index.d.ts +1 -8
- package/build/plugins/KeywordsPlugin/index.d.ts.map +1 -1
- package/build/plugins/KeywordsPlugin/index.js +6 -12
- package/build/plugins/LayoutPlugin/InsertLayoutDialog.d.ts +2 -2
- package/build/plugins/LayoutPlugin/InsertLayoutDialog.d.ts.map +1 -1
- package/build/plugins/LayoutPlugin/InsertLayoutDialog.js +10 -9
- package/build/plugins/LayoutPlugin/LayoutPlugin.d.ts +1 -1
- package/build/plugins/LayoutPlugin/LayoutPlugin.d.ts.map +1 -1
- package/build/plugins/LayoutPlugin/LayoutPlugin.js +8 -14
- package/build/plugins/LinkPlugin/index.d.ts.map +1 -1
- package/build/plugins/LinkPlugin/index.js +1 -0
- package/build/plugins/MarkdownShortcutPlugin/index.d.ts.map +1 -1
- package/build/plugins/MarkdownShortcutPlugin/index.js +1 -0
- package/build/plugins/MarkdownTransformers/index.d.ts +1 -1
- package/build/plugins/MarkdownTransformers/index.d.ts.map +1 -1
- package/build/plugins/MarkdownTransformers/index.js +25 -25
- package/build/plugins/PasteLogPlugin/index.d.ts.map +1 -1
- package/build/plugins/PasteLogPlugin/index.js +1 -0
- package/build/plugins/ShortcutsPlugin/index.d.ts +0 -7
- package/build/plugins/ShortcutsPlugin/index.d.ts.map +1 -1
- package/build/plugins/ShortcutsPlugin/index.js +1 -0
- package/build/plugins/SpeechToTextPlugin/index.d.ts +2 -2
- package/build/plugins/SpeechToTextPlugin/index.d.ts.map +1 -1
- package/build/plugins/SpeechToTextPlugin/index.js +7 -11
- package/build/plugins/TabFocusPlugin/index.d.ts +0 -7
- package/build/plugins/TabFocusPlugin/index.d.ts.map +1 -1
- package/build/plugins/TabFocusPlugin/index.js +6 -5
- package/build/plugins/TableActionMenuPlugin/index.d.ts +1 -8
- package/build/plugins/TableActionMenuPlugin/index.d.ts.map +1 -1
- package/build/plugins/TableActionMenuPlugin/index.js +41 -40
- package/build/plugins/TableCellResizer/index.d.ts +2 -2
- package/build/plugins/TableCellResizer/index.d.ts.map +1 -1
- package/build/plugins/TableCellResizer/index.js +43 -42
- package/build/plugins/TableHoverActionsPlugin/index.d.ts +1 -8
- package/build/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
- package/build/plugins/TableHoverActionsPlugin/index.js +19 -18
- package/build/plugins/TableHoverActionsV2Plugin/index.d.ts.map +1 -1
- package/build/plugins/TableHoverActionsV2Plugin/index.js +1 -0
- package/build/plugins/TablePlugin.d.ts +2 -2
- package/build/plugins/TablePlugin.d.ts.map +1 -1
- package/build/plugins/TablePlugin.js +11 -10
- package/build/plugins/TableScrollShadowPlugin/index.d.ts +0 -7
- package/build/plugins/TableScrollShadowPlugin/index.d.ts.map +1 -1
- package/build/plugins/TableScrollShadowPlugin/index.js +9 -8
- package/build/plugins/TestRecorderPlugin/index.d.ts +1 -8
- package/build/plugins/TestRecorderPlugin/index.d.ts.map +1 -1
- package/build/plugins/TestRecorderPlugin/index.js +45 -44
- package/build/plugins/ToolbarPlugin/fontSize.d.ts +2 -2
- package/build/plugins/ToolbarPlugin/fontSize.d.ts.map +1 -1
- package/build/plugins/ToolbarPlugin/fontSize.js +19 -18
- package/build/plugins/ToolbarPlugin/index.d.ts.map +1 -1
- package/build/plugins/ToolbarPlugin/index.js +68 -60
- package/build/plugins/ToolbarPlugin/languages.d.ts +14 -0
- package/build/plugins/ToolbarPlugin/languages.d.ts.map +1 -0
- package/build/plugins/ToolbarPlugin/languages.js +185 -0
- package/build/plugins/ToolbarPlugin/utils.d.ts +2 -2
- package/build/plugins/ToolbarPlugin/utils.js +21 -21
- package/build/plugins/TwitterPlugin/index.d.ts +2 -2
- package/build/plugins/TwitterPlugin/index.d.ts.map +1 -1
- package/build/plugins/TwitterPlugin/index.js +8 -14
- package/build/plugins/YouTubePlugin/index.d.ts +2 -2
- package/build/plugins/YouTubePlugin/index.d.ts.map +1 -1
- package/build/plugins/YouTubePlugin/index.js +8 -14
- package/build/themes/PlaygroundEditorTheme.css +301 -33
- package/build/themes/ViewerTheme.css +899 -0
- package/build/{plugins/MentionsPlugin/index.d.ts → themes/ViewerTheme.d.ts} +5 -3
- package/build/themes/ViewerTheme.d.ts.map +1 -0
- package/build/themes/ViewerTheme.js +124 -0
- package/build/themes/ViewerThemeComplete.css +1043 -0
- package/build/ui/ColorPicker.d.ts +2 -2
- package/build/ui/ColorPicker.d.ts.map +1 -1
- package/build/ui/ColorPicker.js +47 -46
- package/build/ui/DropDown.d.ts.map +1 -1
- package/build/ui/DropDown.js +1 -0
- package/build/ui/FlashMessage.d.ts +3 -3
- package/build/ui/FlashMessage.d.ts.map +1 -1
- package/build/ui/FlashMessage.js +3 -2
- package/build/ui/ImageResizer.d.ts +3 -3
- package/build/ui/ImageResizer.d.ts.map +1 -1
- package/build/ui/ImageResizer.js +20 -19
- package/build/ui/KatexEquationAlterer.css +3 -1
- package/build/ui/KatexEquationAlterer.d.ts.map +1 -1
- package/build/ui/KatexEquationAlterer.js +1 -0
- package/build/ui/KatexRenderer.d.ts.map +1 -1
- package/build/ui/KatexRenderer.js +1 -0
- package/build/ui/Modal.d.ts.map +1 -1
- package/build/ui/Modal.js +1 -0
- package/build/ui/Switch.d.ts +2 -2
- package/build/ui/Switch.d.ts.map +1 -1
- package/build/ui/Switch.js +3 -2
- package/build/ui/TextInput.d.ts.map +1 -1
- package/build/ui/TextInput.js +1 -0
- package/build/utils/ServerBlockWithAlignableContents.d.ts +22 -0
- package/build/utils/ServerBlockWithAlignableContents.d.ts.map +1 -0
- package/build/utils/ServerBlockWithAlignableContents.js +6 -0
- package/build/utils/focusUtils.d.ts.map +1 -1
- package/build/utils/focusUtils.js +4 -3
- package/build/utils/getDOMRangeRect.d.ts.map +1 -1
- package/build/utils/getDOMRangeRect.js +1 -0
- package/build/utils/setFloatingElemPosition.d.ts.map +1 -1
- package/build/utils/setFloatingElemPosition.js +5 -4
- package/build/utils/swipe.d.ts +0 -7
- package/build/utils/swipe.d.ts.map +1 -1
- package/build/utils/swipe.js +5 -11
- package/build/viewer/Viewer.d.ts +18 -0
- package/build/viewer/Viewer.d.ts.map +1 -0
- package/build/viewer/Viewer.js +105 -0
- package/build/viewer/client.d.ts +18 -0
- package/build/viewer/client.d.ts.map +1 -0
- package/build/viewer/client.js +97 -0
- package/build/viewer/index.d.ts +4 -0
- package/build/viewer/index.d.ts.map +1 -0
- package/build/viewer/index.js +2 -0
- package/package.json +58 -36
- package/build/collaboration.d.ts +0 -12
- package/build/collaboration.d.ts.map +0 -1
- package/build/collaboration.js +0 -32
- package/build/nodes/FigmaNode.d.ts.map +0 -1
- package/build/nodes/PageBreakNode/index.css +0 -64
- package/build/nodes/PageBreakNode/index.d.ts +0 -25
- package/build/nodes/PageBreakNode/index.d.ts.map +0 -1
- package/build/nodes/PageBreakNode/index.js +0 -83
- package/build/nodes/PlaygroundNodes.d.ts.map +0 -1
- package/build/nodes/PollComponent.d.ts +0 -17
- package/build/nodes/PollComponent.d.ts.map +0 -1
- package/build/nodes/PollComponent.js +0 -85
- package/build/nodes/PollNode.css +0 -165
- package/build/nodes/PollNode.d.ts +0 -51
- package/build/nodes/PollNode.d.ts.map +0 -1
- package/build/nodes/PollNode.js +0 -153
- package/build/nodes/StickyComponent.d.ts +0 -18
- package/build/nodes/StickyComponent.d.ts.map +0 -1
- package/build/nodes/StickyComponent.js +0 -155
- package/build/nodes/StickyNode.css +0 -37
- package/build/nodes/StickyNode.d.ts +0 -39
- package/build/nodes/StickyNode.d.ts.map +0 -1
- package/build/nodes/StickyNode.js +0 -66
- package/build/nodes/TweetNode.d.ts.map +0 -1
- package/build/nodes/YouTubeNode.d.ts.map +0 -1
- package/build/plugins/DocsPlugin/index.d.ts +0 -10
- package/build/plugins/DocsPlugin/index.d.ts.map +0 -1
- package/build/plugins/DocsPlugin/index.js +0 -4
- package/build/plugins/MaxLengthPlugin/index.d.ts +0 -11
- package/build/plugins/MaxLengthPlugin/index.d.ts.map +0 -1
- package/build/plugins/MaxLengthPlugin/index.js +0 -44
- package/build/plugins/MentionsPlugin/index.d.ts.map +0 -1
- package/build/plugins/MentionsPlugin/index.js +0 -562
- package/build/plugins/PageBreakPlugin/index.d.ts +0 -12
- package/build/plugins/PageBreakPlugin/index.d.ts.map +0 -1
- package/build/plugins/PageBreakPlugin/index.js +0 -34
- package/build/plugins/StickyPlugin/index.d.ts +0 -10
- package/build/plugins/StickyPlugin/index.d.ts.map +0 -1
- package/build/plugins/StickyPlugin/index.js +0 -19
- package/build/plugins/TreeViewPlugin/index.d.ts +0 -10
- package/build/plugins/TreeViewPlugin/index.d.ts.map +0 -1
- package/build/plugins/TreeViewPlugin/index.js +0 -7
- package/build/plugins/TypingPerfPlugin/index.d.ts +0 -10
- package/build/plugins/TypingPerfPlugin/index.d.ts.map +0 -1
- package/build/plugins/TypingPerfPlugin/index.js +0 -100
- package/build/plugins/VersionsPlugin/index.css +0 -57
- package/build/plugins/VersionsPlugin/index.d.ts +0 -14
- package/build/plugins/VersionsPlugin/index.d.ts.map +0 -1
- package/build/plugins/VersionsPlugin/index.js +0 -147
- /package/build/nodes/{FigmaNode.d.ts → FigmaNode/FigmaNode.d.ts} +0 -0
- /package/build/nodes/{FigmaNode.js → FigmaNode/FigmaNode.js} +0 -0
- /package/build/nodes/{PlaygroundNodes.d.ts → PlaygroundNodes/PlaygroundNodes.d.ts} +0 -0
- /package/build/nodes/{TweetNode.d.ts → TweetNode/TweetNode.d.ts} +0 -0
- /package/build/nodes/{TweetNode.js → TweetNode/TweetNode.js} +0 -0
- /package/build/nodes/{YouTubeNode.d.ts → YouTubeNode/YouTubeNode.d.ts} +0 -0
- /package/build/nodes/{YouTubeNode.js → YouTubeNode/YouTubeNode.js} +0 -0
|
@@ -1,100 +0,0 @@
|
|
|
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
|
-
import { useEffect } from 'react';
|
|
9
|
-
import useReport from '../../hooks/useReport';
|
|
10
|
-
const validInputTypes = new Set([
|
|
11
|
-
'insertText',
|
|
12
|
-
'insertCompositionText',
|
|
13
|
-
'insertFromComposition',
|
|
14
|
-
'insertLineBreak',
|
|
15
|
-
'insertParagraph',
|
|
16
|
-
'deleteCompositionText',
|
|
17
|
-
'deleteContentBackward',
|
|
18
|
-
'deleteByComposition',
|
|
19
|
-
'deleteContent',
|
|
20
|
-
'deleteContentForward',
|
|
21
|
-
'deleteWordBackward',
|
|
22
|
-
'deleteWordForward',
|
|
23
|
-
'deleteHardLineBackward',
|
|
24
|
-
'deleteSoftLineBackward',
|
|
25
|
-
'deleteHardLineForward',
|
|
26
|
-
'deleteSoftLineForward',
|
|
27
|
-
]);
|
|
28
|
-
export default function TypingPerfPlugin() {
|
|
29
|
-
const report = useReport();
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
let start = 0;
|
|
32
|
-
let timerId;
|
|
33
|
-
let keyPressTimerId;
|
|
34
|
-
let log = [];
|
|
35
|
-
let invalidatingEvent = false;
|
|
36
|
-
const measureEventEnd = function logKeyPress() {
|
|
37
|
-
if (keyPressTimerId != null) {
|
|
38
|
-
if (invalidatingEvent) {
|
|
39
|
-
invalidatingEvent = false;
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
log.push(performance.now() - start);
|
|
43
|
-
}
|
|
44
|
-
clearTimeout(keyPressTimerId);
|
|
45
|
-
keyPressTimerId = null;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
const measureEventStart = function measureEvent() {
|
|
49
|
-
if (timerId != null) {
|
|
50
|
-
clearTimeout(timerId);
|
|
51
|
-
timerId = null;
|
|
52
|
-
}
|
|
53
|
-
// We use a setTimeout(0) instead of requestAnimationFrame, due to
|
|
54
|
-
// inconsistencies between the sequencing of rAF in different browsers.
|
|
55
|
-
keyPressTimerId = setTimeout(measureEventEnd, 0);
|
|
56
|
-
// Schedule a timer to report the results.
|
|
57
|
-
timerId = setTimeout(() => {
|
|
58
|
-
const total = log.reduce((a, b) => a + b, 0);
|
|
59
|
-
const reportedText = 'Typing Perf: ' + Math.round((total / log.length) * 100) / 100 + 'ms';
|
|
60
|
-
report(reportedText);
|
|
61
|
-
log = [];
|
|
62
|
-
}, 2000);
|
|
63
|
-
// Make the time after we do the previous logic, so we don't measure the overhead
|
|
64
|
-
// for it all.
|
|
65
|
-
start = performance.now();
|
|
66
|
-
};
|
|
67
|
-
const beforeInputHandler = function beforeInputHandler(event) {
|
|
68
|
-
if (!validInputTypes.has(event.inputType) || invalidatingEvent) {
|
|
69
|
-
invalidatingEvent = false;
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
measureEventStart();
|
|
73
|
-
};
|
|
74
|
-
const keyDownHandler = function keyDownHandler(event) {
|
|
75
|
-
const key = event.key;
|
|
76
|
-
if (key === 'Backspace' || key === 'Enter') {
|
|
77
|
-
measureEventStart();
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
const pasteHandler = function pasteHandler() {
|
|
81
|
-
invalidatingEvent = true;
|
|
82
|
-
};
|
|
83
|
-
const cutHandler = function cutHandler() {
|
|
84
|
-
invalidatingEvent = true;
|
|
85
|
-
};
|
|
86
|
-
window.addEventListener('keydown', keyDownHandler, true);
|
|
87
|
-
window.addEventListener('selectionchange', measureEventEnd, true);
|
|
88
|
-
window.addEventListener('beforeinput', beforeInputHandler, true);
|
|
89
|
-
window.addEventListener('paste', pasteHandler, true);
|
|
90
|
-
window.addEventListener('cut', cutHandler, true);
|
|
91
|
-
return () => {
|
|
92
|
-
window.removeEventListener('keydown', keyDownHandler, true);
|
|
93
|
-
window.removeEventListener('selectionchange', measureEventEnd, true);
|
|
94
|
-
window.removeEventListener('beforeinput', beforeInputHandler, true);
|
|
95
|
-
window.removeEventListener('paste', pasteHandler, true);
|
|
96
|
-
window.removeEventListener('cut', cutHandler, true);
|
|
97
|
-
};
|
|
98
|
-
}, [report]);
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
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
|
-
.VersionsPlugin_Container {
|
|
10
|
-
display: flex;
|
|
11
|
-
flex-direction: column;
|
|
12
|
-
gap: 16px;
|
|
13
|
-
min-width: 320px;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.VersionsPlugin_Header {
|
|
17
|
-
align-items: center;
|
|
18
|
-
display: flex;
|
|
19
|
-
justify-content: space-between;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.VersionsPlugin_VersionList {
|
|
23
|
-
border: 1px solid #ddd;
|
|
24
|
-
border-radius: 4px;
|
|
25
|
-
max-height: 300px;
|
|
26
|
-
overflow-y: auto;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.VersionsPlugin_VersionItem {
|
|
30
|
-
align-items: center;
|
|
31
|
-
background-color: white;
|
|
32
|
-
border: none;
|
|
33
|
-
border-bottom: 1px solid #eee;
|
|
34
|
-
cursor: pointer;
|
|
35
|
-
display: flex;
|
|
36
|
-
justify-content: space-between;
|
|
37
|
-
padding: 12px 16px;
|
|
38
|
-
width: 100%;
|
|
39
|
-
|
|
40
|
-
&:disabled {
|
|
41
|
-
color: #777;
|
|
42
|
-
font-style: italic;
|
|
43
|
-
cursor: default;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.VersionsPlugin_VersionItem:hover:not(:disabled) {
|
|
48
|
-
background-color: #f5f5f5;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.VersionsPlugin_VersionItem--selected {
|
|
52
|
-
background-color: #e3f2fd;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.VersionsPlugin_CompareButton {
|
|
56
|
-
align-self: center;
|
|
57
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
import './index.css';
|
|
9
|
-
import { LexicalCommand } from 'lexical';
|
|
10
|
-
export declare const SHOW_VERSIONS_COMMAND: LexicalCommand<void>;
|
|
11
|
-
export declare function VersionsPlugin({ id }: {
|
|
12
|
-
id: string;
|
|
13
|
-
}): import("react/jsx-runtime").JSX.Element | null;
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/VersionsPlugin/index.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,aAAa,CAAC;AAUrB,OAAO,EAKL,cAAc,EAEf,MAAM,SAAS,CAAC;AA8BjB,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,IAAI,CAEtD,CAAC;AAEF,wBAAgB,cAAc,CAAC,EAAC,EAAE,EAAC,EAAE;IAAC,EAAE,EAAE,MAAM,CAAA;CAAC,kDAwJhD"}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
import './index.css';
|
|
10
|
-
import { useCollaborationContext } from '@lexical/react/LexicalCollaborationContext';
|
|
11
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
12
|
-
import { mergeRegister } from '@lexical/utils';
|
|
13
|
-
import { $getYChangeState, CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL, DIFF_VERSIONS_COMMAND__EXPERIMENTAL, } from '@lexical/yjs';
|
|
14
|
-
import { $getNodeByKeyOrThrow, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, createCommand, TextNode, } from 'lexical';
|
|
15
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
16
|
-
import { PermanentUserData, snapshot as createSnapshot, XmlElement, } from 'yjs';
|
|
17
|
-
import Button from '../../ui/Button';
|
|
18
|
-
import Modal from '../../ui/Modal';
|
|
19
|
-
const COLORS = [
|
|
20
|
-
'#4a90e288',
|
|
21
|
-
'#bd10e088',
|
|
22
|
-
'#d0021b88',
|
|
23
|
-
'#8b572a88',
|
|
24
|
-
'#41750588',
|
|
25
|
-
'#f5a62388',
|
|
26
|
-
];
|
|
27
|
-
export const SHOW_VERSIONS_COMMAND = createCommand('SHOW_VERSIONS_COMMAND');
|
|
28
|
-
export function VersionsPlugin({ id }) {
|
|
29
|
-
const [editor] = useLexicalComposerContext();
|
|
30
|
-
const { name: username, yjsDocMap } = useCollaborationContext();
|
|
31
|
-
const yDoc = yjsDocMap.get(id);
|
|
32
|
-
const [isDiffMode, setIsDiffMode] = useState(false);
|
|
33
|
-
const [showModal, setShowModal] = useState(false);
|
|
34
|
-
const [versions, setVersions] = useState([]);
|
|
35
|
-
const [pudInitialised, setPudInitialised] = useState(false);
|
|
36
|
-
useEffect(() => mergeRegister(editor.registerCommand(SHOW_VERSIONS_COMMAND, () => {
|
|
37
|
-
setShowModal(true);
|
|
38
|
-
return false;
|
|
39
|
-
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(DIFF_VERSIONS_COMMAND__EXPERIMENTAL, () => {
|
|
40
|
-
editor.setEditable(false);
|
|
41
|
-
setIsDiffMode(true);
|
|
42
|
-
return false;
|
|
43
|
-
}, COMMAND_PRIORITY_CRITICAL), editor.registerCommand(CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL, () => {
|
|
44
|
-
editor.setEditable(true);
|
|
45
|
-
setIsDiffMode(false);
|
|
46
|
-
return false;
|
|
47
|
-
}, COMMAND_PRIORITY_CRITICAL), editor.registerEditableListener((isEditable) => {
|
|
48
|
-
if (isEditable && isDiffMode) {
|
|
49
|
-
editor.dispatchCommand(CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL, undefined);
|
|
50
|
-
}
|
|
51
|
-
})), [editor, isDiffMode]);
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
if (pudInitialised || !yDoc) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const root = yDoc.get('root-v2', XmlElement);
|
|
57
|
-
const handleChange = (_events, transaction) => {
|
|
58
|
-
if (transaction.local) {
|
|
59
|
-
// User's made a local change. Register PUD mapping.
|
|
60
|
-
const permanentUserData = new PermanentUserData(yDoc);
|
|
61
|
-
permanentUserData.setUserMapping(yDoc, yDoc.clientID, username);
|
|
62
|
-
setPudInitialised(true);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
root.observeDeep(handleChange);
|
|
66
|
-
return () => root.unobserveDeep(handleChange);
|
|
67
|
-
}, [yDoc, username, pudInitialised]);
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
if (!isDiffMode) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
return editor.registerMutationListener(TextNode, (nodes) => {
|
|
73
|
-
const userToColor = new Map();
|
|
74
|
-
const getUserColor = (user) => {
|
|
75
|
-
if (userToColor.has(user)) {
|
|
76
|
-
return userToColor.get(user);
|
|
77
|
-
}
|
|
78
|
-
const color = COLORS[userToColor.size % COLORS.length];
|
|
79
|
-
userToColor.set(user, color);
|
|
80
|
-
return color;
|
|
81
|
-
};
|
|
82
|
-
editor.getEditorState().read(() => {
|
|
83
|
-
for (const [nodeKey, mutation] of nodes.entries()) {
|
|
84
|
-
if (mutation === 'destroyed') {
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
const node = $getNodeByKeyOrThrow(nodeKey);
|
|
88
|
-
const ychange = $getYChangeState(node);
|
|
89
|
-
const element = editor.getElementByKey(nodeKey);
|
|
90
|
-
if (!ychange || !element) {
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
const { type, user: changeUser } = ychange;
|
|
94
|
-
if (!changeUser) {
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
const color = getUserColor(changeUser);
|
|
98
|
-
switch (type) {
|
|
99
|
-
case 'removed':
|
|
100
|
-
element.style.color = color;
|
|
101
|
-
element.style.textDecoration = 'line-through';
|
|
102
|
-
break;
|
|
103
|
-
case 'added':
|
|
104
|
-
element.style.backgroundColor = color;
|
|
105
|
-
break;
|
|
106
|
-
default:
|
|
107
|
-
// no change
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}, { skipInitialization: true });
|
|
112
|
-
}, [editor, isDiffMode]);
|
|
113
|
-
const handleAddVersion = useCallback(() => {
|
|
114
|
-
if (!yDoc) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
const now = Date.now();
|
|
118
|
-
setVersions((prevVersions) => [
|
|
119
|
-
...prevVersions,
|
|
120
|
-
{
|
|
121
|
-
name: `Snapshot ${new Date(now).toLocaleString()}`,
|
|
122
|
-
snapshot: createSnapshot(yDoc),
|
|
123
|
-
timestamp: now,
|
|
124
|
-
},
|
|
125
|
-
]);
|
|
126
|
-
}, [setVersions, yDoc]);
|
|
127
|
-
if (!showModal) {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
return (_jsx(VersionsModal, { versions: versions, isDiffMode: isDiffMode, onAddVersion: handleAddVersion, onClose: () => setShowModal(false) }));
|
|
131
|
-
}
|
|
132
|
-
function VersionsModal({ versions, isDiffMode, onAddVersion, onClose, }) {
|
|
133
|
-
const [editor] = useLexicalComposerContext();
|
|
134
|
-
const [selectedVersion, setSelectedVersion] = useState(null);
|
|
135
|
-
return (_jsx(Modal, { onClose: onClose, title: "Version History", children: _jsxs("div", { className: "VersionsPlugin_Container", children: [_jsxs("div", { className: "VersionsPlugin_Header", children: [_jsx(Button, { onClick: onAddVersion, children: "+ Add snapshot" }), isDiffMode && (_jsx(Button, { onClick: () => {
|
|
136
|
-
editor.dispatchCommand(CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL, undefined);
|
|
137
|
-
onClose();
|
|
138
|
-
}, children: "Exit compare view" }))] }), _jsx("div", { className: "VersionsPlugin_VersionList", children: versions.length === 0 ? (_jsx("button", { className: "VersionsPlugin_VersionItem", disabled: true, children: "Add a snapshot to get started" })) : (versions.map((version, idx) => {
|
|
139
|
-
const isSelected = selectedVersion === idx;
|
|
140
|
-
return (_jsxs("button", { onClick: () => setSelectedVersion(idx), className: `VersionsPlugin_VersionItem ${isSelected ? 'VersionsPlugin_VersionItem--selected' : ''}`, children: ["Snapshot at ", new Date(version.timestamp).toLocaleString()] }, version.name));
|
|
141
|
-
})) }), _jsx(Button, { onClick: () => {
|
|
142
|
-
editor.dispatchCommand(DIFF_VERSIONS_COMMAND__EXPERIMENTAL, {
|
|
143
|
-
prevSnapshot: versions[selectedVersion].snapshot,
|
|
144
|
-
});
|
|
145
|
-
onClose();
|
|
146
|
-
}, disabled: selectedVersion === null, className: "VersionsPlugin_CompareButton", children: "Show changes since selected version" })] }) }));
|
|
147
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|