@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,17 +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 type { Options } from './PollNode';
|
|
9
|
-
import type { JSX } from 'react';
|
|
10
|
-
import './PollNode.css';
|
|
11
|
-
import { NodeKey } from 'lexical';
|
|
12
|
-
export default function PollComponent({ question, options, nodeKey, }: {
|
|
13
|
-
nodeKey: NodeKey;
|
|
14
|
-
options: Options;
|
|
15
|
-
question: string;
|
|
16
|
-
}): JSX.Element;
|
|
17
|
-
//# sourceMappingURL=PollComponent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PollComponent.d.ts","sourceRoot":"","sources":["../../src/nodes/PollComponent.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAS,OAAO,EAAW,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE/B,OAAO,gBAAgB,CAAC;AAMxB,OAAO,EAOL,OAAO,EACR,MAAM,SAAS,CAAC;AAuGjB,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,QAAQ,EACR,OAAO,EACP,OAAO,GACR,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,GAAG,CAAC,OAAO,CAmFd"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import './PollNode.css';
|
|
3
|
-
import { useCollaborationContext } from '@lexical/react/LexicalCollaborationContext';
|
|
4
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
5
|
-
import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection';
|
|
6
|
-
import { mergeRegister } from '@lexical/utils';
|
|
7
|
-
import { $getNodeByKey, $getSelection, $isNodeSelection, CLICK_COMMAND, COMMAND_PRIORITY_LOW, } from 'lexical';
|
|
8
|
-
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
9
|
-
import Button from '../ui/Button';
|
|
10
|
-
import joinClasses from '../utils/joinClasses';
|
|
11
|
-
import { $isPollNode, createPollOption } from './PollNode';
|
|
12
|
-
function getTotalVotes(options) {
|
|
13
|
-
return options.reduce((totalVotes, next) => {
|
|
14
|
-
return totalVotes + next.votes.length;
|
|
15
|
-
}, 0);
|
|
16
|
-
}
|
|
17
|
-
function PollOptionComponent({ option, index, options, totalVotes, withPollNode, }) {
|
|
18
|
-
const { name: username } = useCollaborationContext();
|
|
19
|
-
const checkboxRef = useRef(null);
|
|
20
|
-
const votesArray = option.votes;
|
|
21
|
-
const checkedIndex = votesArray.indexOf(username);
|
|
22
|
-
const checked = checkedIndex !== -1;
|
|
23
|
-
const votes = votesArray.length;
|
|
24
|
-
const text = option.text;
|
|
25
|
-
return (_jsxs("div", { className: "PollNode__optionContainer", children: [_jsx("div", { className: joinClasses('PollNode__optionCheckboxWrapper', checked && 'PollNode__optionCheckboxChecked'), children: _jsx("input", { ref: checkboxRef, className: "PollNode__optionCheckbox", type: "checkbox", onChange: (e) => {
|
|
26
|
-
withPollNode((node) => {
|
|
27
|
-
node.toggleVote(option, username);
|
|
28
|
-
});
|
|
29
|
-
}, checked: checked }) }), _jsxs("div", { className: "PollNode__optionInputWrapper", children: [_jsx("div", { className: "PollNode__optionInputVotes", style: { width: `${votes === 0 ? 0 : (votes / totalVotes) * 100}%` } }), _jsx("span", { className: "PollNode__optionInputVotesCount", children: votes > 0 && (votes === 1 ? '1 vote' : `${votes} votes`) }), _jsx("input", { className: "PollNode__optionInput", type: "text", value: text, onChange: (e) => {
|
|
30
|
-
const target = e.target;
|
|
31
|
-
const value = target.value;
|
|
32
|
-
const selectionStart = target.selectionStart;
|
|
33
|
-
const selectionEnd = target.selectionEnd;
|
|
34
|
-
withPollNode((node) => {
|
|
35
|
-
node.setOptionText(option, value);
|
|
36
|
-
}, () => {
|
|
37
|
-
target.selectionStart = selectionStart;
|
|
38
|
-
target.selectionEnd = selectionEnd;
|
|
39
|
-
});
|
|
40
|
-
}, placeholder: `Option ${index + 1}` })] }), _jsx("button", { disabled: options.length < 3, className: joinClasses('PollNode__optionDelete', options.length < 3 && 'PollNode__optionDeleteDisabled'), "aria-label": "Remove", onClick: () => {
|
|
41
|
-
withPollNode((node) => {
|
|
42
|
-
node.deleteOption(option);
|
|
43
|
-
});
|
|
44
|
-
} })] }));
|
|
45
|
-
}
|
|
46
|
-
export default function PollComponent({ question, options, nodeKey, }) {
|
|
47
|
-
const [editor] = useLexicalComposerContext();
|
|
48
|
-
const totalVotes = useMemo(() => getTotalVotes(options), [options]);
|
|
49
|
-
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
|
|
50
|
-
const [selection, setSelection] = useState(null);
|
|
51
|
-
const ref = useRef(null);
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
return mergeRegister(editor.registerUpdateListener(({ editorState }) => {
|
|
54
|
-
setSelection(editorState.read(() => $getSelection()));
|
|
55
|
-
}), editor.registerCommand(CLICK_COMMAND, (payload) => {
|
|
56
|
-
const event = payload;
|
|
57
|
-
if (event.target === ref.current) {
|
|
58
|
-
if (!event.shiftKey) {
|
|
59
|
-
clearSelection();
|
|
60
|
-
}
|
|
61
|
-
setSelected(!isSelected);
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
return false;
|
|
65
|
-
}, COMMAND_PRIORITY_LOW));
|
|
66
|
-
}, [clearSelection, editor, isSelected, nodeKey, setSelected]);
|
|
67
|
-
const withPollNode = (cb, onUpdate) => {
|
|
68
|
-
editor.update(() => {
|
|
69
|
-
const node = $getNodeByKey(nodeKey);
|
|
70
|
-
if ($isPollNode(node)) {
|
|
71
|
-
cb(node);
|
|
72
|
-
}
|
|
73
|
-
}, { onUpdate });
|
|
74
|
-
};
|
|
75
|
-
const addOption = () => {
|
|
76
|
-
withPollNode((node) => {
|
|
77
|
-
node.addOption(createPollOption());
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
const isFocused = $isNodeSelection(selection) && isSelected;
|
|
81
|
-
return (_jsx("div", { className: `PollNode__container ${isFocused ? 'focused' : ''}`, ref: ref, children: _jsxs("div", { className: "PollNode__inner", children: [_jsx("h2", { className: "PollNode__heading", children: question }), options.map((option, index) => {
|
|
82
|
-
const key = option.uid;
|
|
83
|
-
return (_jsx(PollOptionComponent, { withPollNode: withPollNode, option: option, index: index, options: options, totalVotes: totalVotes }, key));
|
|
84
|
-
}), _jsx("div", { className: "PollNode__footer", children: _jsx(Button, { onClick: addOption, small: true, children: "Add Option" }) })] }) }));
|
|
85
|
-
}
|
package/build/nodes/PollNode.css
DELETED
|
@@ -1,165 +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
|
-
|
|
10
|
-
.PollNode__container {
|
|
11
|
-
border: 1px solid #eee;
|
|
12
|
-
background-color: #fcfcfc;
|
|
13
|
-
border-radius: 10px;
|
|
14
|
-
max-width: 600px;
|
|
15
|
-
min-width: 400px;
|
|
16
|
-
cursor: pointer;
|
|
17
|
-
user-select: none;
|
|
18
|
-
}
|
|
19
|
-
.PollNode__container.focused {
|
|
20
|
-
outline: 2px solid rgb(60, 132, 244);
|
|
21
|
-
}
|
|
22
|
-
.PollNode__inner {
|
|
23
|
-
margin: 15px;
|
|
24
|
-
cursor: default;
|
|
25
|
-
}
|
|
26
|
-
.PollNode__heading {
|
|
27
|
-
margin-left: 0px;
|
|
28
|
-
margin-top: 0px;
|
|
29
|
-
margin-right: 0px;
|
|
30
|
-
margin-bottom: 15px;
|
|
31
|
-
color: #444;
|
|
32
|
-
text-align: center;
|
|
33
|
-
font-size: 18px;
|
|
34
|
-
}
|
|
35
|
-
.PollNode__optionContainer {
|
|
36
|
-
display: flex;
|
|
37
|
-
flex-direction: row;
|
|
38
|
-
margin-bottom: 10px;
|
|
39
|
-
align-items: center;
|
|
40
|
-
}
|
|
41
|
-
.PollNode__optionInputWrapper {
|
|
42
|
-
display: flex;
|
|
43
|
-
flex: 10px;
|
|
44
|
-
border: 1px solid rgb(61, 135, 245);
|
|
45
|
-
border-radius: 5px;
|
|
46
|
-
position: relative;
|
|
47
|
-
overflow: hidden;
|
|
48
|
-
cursor: pointer;
|
|
49
|
-
}
|
|
50
|
-
.PollNode__optionInput {
|
|
51
|
-
display: flex;
|
|
52
|
-
flex: 1px;
|
|
53
|
-
border: 0px;
|
|
54
|
-
padding: 7px;
|
|
55
|
-
color: rgb(61, 135, 245);
|
|
56
|
-
background-color: transparent;
|
|
57
|
-
font-weight: bold;
|
|
58
|
-
outline: 0px;
|
|
59
|
-
z-index: 0;
|
|
60
|
-
}
|
|
61
|
-
.PollNode__optionInput::placeholder {
|
|
62
|
-
font-weight: normal;
|
|
63
|
-
color: #999;
|
|
64
|
-
}
|
|
65
|
-
.PollNode__optionInputVotes {
|
|
66
|
-
background-color: rgb(236, 243, 254);
|
|
67
|
-
height: 100%;
|
|
68
|
-
position: absolute;
|
|
69
|
-
top: 0px;
|
|
70
|
-
left: 0px;
|
|
71
|
-
transition: width 1s ease;
|
|
72
|
-
z-index: 0;
|
|
73
|
-
}
|
|
74
|
-
.PollNode__optionInputVotesCount {
|
|
75
|
-
color: rgb(61, 135, 245);
|
|
76
|
-
position: absolute;
|
|
77
|
-
right: 15px;
|
|
78
|
-
font-size: 12px;
|
|
79
|
-
top: 5px;
|
|
80
|
-
}
|
|
81
|
-
.PollNode__optionCheckboxWrapper {
|
|
82
|
-
position: relative;
|
|
83
|
-
display: flex;
|
|
84
|
-
width: 22px;
|
|
85
|
-
height: 22px;
|
|
86
|
-
border: 1px solid #999;
|
|
87
|
-
margin-right: 10px;
|
|
88
|
-
border-radius: 5px;
|
|
89
|
-
}
|
|
90
|
-
.PollNode__optionCheckboxChecked {
|
|
91
|
-
border: 1px solid rgb(61, 135, 245);
|
|
92
|
-
background-color: rgb(61, 135, 245);
|
|
93
|
-
}
|
|
94
|
-
.PollNode__optionCheckboxChecked:after {
|
|
95
|
-
content: '';
|
|
96
|
-
cursor: pointer;
|
|
97
|
-
border-color: #fff;
|
|
98
|
-
border-style: solid;
|
|
99
|
-
position: absolute;
|
|
100
|
-
display: block;
|
|
101
|
-
top: 4px;
|
|
102
|
-
width: 5px;
|
|
103
|
-
left: 8px;
|
|
104
|
-
height: 9px;
|
|
105
|
-
margin: 0;
|
|
106
|
-
transform: rotate(45deg);
|
|
107
|
-
border-width: 0 2px 2px 0;
|
|
108
|
-
pointer-events: none;
|
|
109
|
-
}
|
|
110
|
-
.PollNode__optionCheckbox {
|
|
111
|
-
border: 0px;
|
|
112
|
-
position: absolute;
|
|
113
|
-
display: block;
|
|
114
|
-
width: 100%;
|
|
115
|
-
height: 100%;
|
|
116
|
-
opacity: 0;
|
|
117
|
-
cursor: pointer;
|
|
118
|
-
}
|
|
119
|
-
.PollNode__optionDelete {
|
|
120
|
-
position: relative;
|
|
121
|
-
display: flex;
|
|
122
|
-
width: 28px;
|
|
123
|
-
height: 28px;
|
|
124
|
-
margin-left: 6px;
|
|
125
|
-
border: 0px;
|
|
126
|
-
background-color: transparent;
|
|
127
|
-
background-position: 6px 6px;
|
|
128
|
-
background-repeat: no-repeat;
|
|
129
|
-
z-index: 0;
|
|
130
|
-
cursor: pointer;
|
|
131
|
-
border-radius: 5px;
|
|
132
|
-
opacity: 0.3;
|
|
133
|
-
}
|
|
134
|
-
.PollNode__optionDelete:before,
|
|
135
|
-
.PollNode__optionDelete:after {
|
|
136
|
-
position: absolute;
|
|
137
|
-
display: block;
|
|
138
|
-
content: '';
|
|
139
|
-
background-color: #999;
|
|
140
|
-
width: 2px;
|
|
141
|
-
height: 15px;
|
|
142
|
-
top: 6px;
|
|
143
|
-
left: 13px;
|
|
144
|
-
}
|
|
145
|
-
.PollNode__optionDelete:before {
|
|
146
|
-
transform: rotate(-45deg);
|
|
147
|
-
}
|
|
148
|
-
.PollNode__optionDelete:after {
|
|
149
|
-
transform: rotate(45deg);
|
|
150
|
-
}
|
|
151
|
-
.PollNode__optionDelete:hover {
|
|
152
|
-
opacity: 1;
|
|
153
|
-
background-color: #eee;
|
|
154
|
-
}
|
|
155
|
-
.PollNode__optionDeleteDisabled {
|
|
156
|
-
cursor: not-allowed;
|
|
157
|
-
}
|
|
158
|
-
.PollNode__optionDeleteDisabled:hover {
|
|
159
|
-
opacity: 0.3;
|
|
160
|
-
background-color: transparent;
|
|
161
|
-
}
|
|
162
|
-
.PollNode__footer {
|
|
163
|
-
display: flex;
|
|
164
|
-
justify-content: center;
|
|
165
|
-
}
|
|
@@ -1,51 +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 type { JSX } from 'react';
|
|
9
|
-
import { DecoratorNode, DOMExportOutput, LexicalNode, SerializedLexicalNode, Spread, StateConfigValue, type StateValueOrUpdater } from 'lexical';
|
|
10
|
-
export type Options = ReadonlyArray<Option>;
|
|
11
|
-
export type Option = Readonly<{
|
|
12
|
-
text: string;
|
|
13
|
-
uid: string;
|
|
14
|
-
votes: Array<string>;
|
|
15
|
-
}>;
|
|
16
|
-
export declare function createPollOption(text?: string): Option;
|
|
17
|
-
export type SerializedPollNode = Spread<{
|
|
18
|
-
question: string;
|
|
19
|
-
options: Options;
|
|
20
|
-
}, SerializedLexicalNode>;
|
|
21
|
-
declare const questionState: import("lexical").StateConfig<"question", string>;
|
|
22
|
-
declare const optionsState: import("lexical").StateConfig<"options", Options>;
|
|
23
|
-
export declare class PollNode extends DecoratorNode<JSX.Element> {
|
|
24
|
-
$config(): import("lexical").StaticNodeConfigRecord<"poll", {
|
|
25
|
-
extends: typeof DecoratorNode;
|
|
26
|
-
importDOM: import("lexical").DOMConversionMap<HTMLElement>;
|
|
27
|
-
stateConfigs: ({
|
|
28
|
-
flat: true;
|
|
29
|
-
stateConfig: import("lexical").StateConfig<"question", string>;
|
|
30
|
-
} | {
|
|
31
|
-
flat: true;
|
|
32
|
-
stateConfig: import("lexical").StateConfig<"options", Options>;
|
|
33
|
-
})[];
|
|
34
|
-
}>;
|
|
35
|
-
getQuestion(): StateConfigValue<typeof questionState>;
|
|
36
|
-
setQuestion(valueOrUpdater: StateValueOrUpdater<typeof questionState>): this;
|
|
37
|
-
getOptions(): StateConfigValue<typeof optionsState>;
|
|
38
|
-
setOptions(valueOrUpdater: StateValueOrUpdater<typeof optionsState>): this;
|
|
39
|
-
addOption(option: Option): this;
|
|
40
|
-
deleteOption(option: Option): this;
|
|
41
|
-
setOptionText(option: Option, text: string): this;
|
|
42
|
-
toggleVote(option: Option, username: string): this;
|
|
43
|
-
exportDOM(): DOMExportOutput;
|
|
44
|
-
createDOM(): HTMLElement;
|
|
45
|
-
updateDOM(): false;
|
|
46
|
-
decorate(): JSX.Element;
|
|
47
|
-
}
|
|
48
|
-
export declare function $createPollNode(question: string, options: Options): PollNode;
|
|
49
|
-
export declare function $isPollNode(node: LexicalNode | null | undefined): node is PollNode;
|
|
50
|
-
export {};
|
|
51
|
-
//# sourceMappingURL=PollNode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PollNode.d.ts","sourceRoot":"","sources":["../../src/nodes/PollNode.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE/B,OAAO,EAKL,aAAa,EAEb,eAAe,EACf,WAAW,EACX,qBAAqB,EACrB,MAAM,EACN,gBAAgB,EAChB,KAAK,mBAAmB,EACzB,MAAM,SAAS,CAAC;AAGjB,MAAM,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;AAE5C,MAAM,MAAM,MAAM,GAAG,QAAQ,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACtB,CAAC,CAAC;AAWH,wBAAgB,gBAAgB,CAAC,IAAI,SAAK,GAAG,MAAM,CAMlD;AAcD,MAAM,MAAM,kBAAkB,GAAG,MAAM,CACrC;IACE,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB,EACD,qBAAqB,CACtB,CAAC;AAgCF,QAAA,MAAM,aAAa,mDAEjB,CAAC;AACH,QAAA,MAAM,YAAY,mDAIhB,CAAC;AAEH,qBAAa,QAAS,SAAQ,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC;IACtD,OAAO;;;;;;;;;;;IAmBP,WAAW,IAAI,gBAAgB,CAAC,OAAO,aAAa,CAAC;IAGrD,WAAW,CAAC,cAAc,EAAE,mBAAmB,CAAC,OAAO,aAAa,CAAC,GAAG,IAAI;IAG5E,UAAU,IAAI,gBAAgB,CAAC,OAAO,YAAY,CAAC;IAGnD,UAAU,CAAC,cAAc,EAAE,mBAAmB,CAAC,OAAO,YAAY,CAAC,GAAG,IAAI;IAI1E,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAYlC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAUjD,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAqBlD,SAAS,IAAI,eAAe;IAU5B,SAAS,IAAI,WAAW;IAMxB,SAAS,IAAI,KAAK;IAIlB,QAAQ,IAAI,GAAG,CAAC,OAAO;CASxB;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,QAAQ,CAE5E;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACnC,IAAI,IAAI,QAAQ,CAElB"}
|
package/build/nodes/PollNode.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { $getState, $setState, buildImportMap, createState, DecoratorNode, } from 'lexical';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
const PollComponent = React.lazy(() => import('./PollComponent'));
|
|
5
|
-
function createUID() {
|
|
6
|
-
return Math.random()
|
|
7
|
-
.toString(36)
|
|
8
|
-
.replace(/[^a-z]+/g, '')
|
|
9
|
-
.substring(0, 5);
|
|
10
|
-
}
|
|
11
|
-
export function createPollOption(text = '') {
|
|
12
|
-
return {
|
|
13
|
-
text,
|
|
14
|
-
uid: createUID(),
|
|
15
|
-
votes: [],
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function cloneOption(option, text, votes) {
|
|
19
|
-
return {
|
|
20
|
-
text,
|
|
21
|
-
uid: option.uid,
|
|
22
|
-
votes: votes || Array.from(option.votes),
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function $convertPollElement(domNode) {
|
|
26
|
-
const question = domNode.getAttribute('data-lexical-poll-question');
|
|
27
|
-
const options = domNode.getAttribute('data-lexical-poll-options');
|
|
28
|
-
if (question !== null && options !== null) {
|
|
29
|
-
const node = $createPollNode(question, JSON.parse(options));
|
|
30
|
-
return { node };
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
function parseOptions(json) {
|
|
35
|
-
const options = [];
|
|
36
|
-
if (Array.isArray(json)) {
|
|
37
|
-
for (const row of json) {
|
|
38
|
-
if (row &&
|
|
39
|
-
typeof row.text === 'string' &&
|
|
40
|
-
typeof row.uid === 'string' &&
|
|
41
|
-
Array.isArray(row.votes) &&
|
|
42
|
-
row.votes.every((v) => typeof v === 'string')) {
|
|
43
|
-
options.push(row);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return options;
|
|
48
|
-
}
|
|
49
|
-
const questionState = createState('question', {
|
|
50
|
-
parse: (v) => (typeof v === 'string' ? v : ''),
|
|
51
|
-
});
|
|
52
|
-
const optionsState = createState('options', {
|
|
53
|
-
isEqual: (a, b) => a.length === b.length && JSON.stringify(a) === JSON.stringify(b),
|
|
54
|
-
parse: parseOptions,
|
|
55
|
-
});
|
|
56
|
-
export class PollNode extends DecoratorNode {
|
|
57
|
-
$config() {
|
|
58
|
-
return this.config('poll', {
|
|
59
|
-
extends: DecoratorNode,
|
|
60
|
-
importDOM: buildImportMap({
|
|
61
|
-
span: (domNode) => domNode.getAttribute('data-lexical-poll-question') !== null
|
|
62
|
-
? {
|
|
63
|
-
conversion: $convertPollElement,
|
|
64
|
-
priority: 2,
|
|
65
|
-
}
|
|
66
|
-
: null,
|
|
67
|
-
}),
|
|
68
|
-
stateConfigs: [
|
|
69
|
-
{ flat: true, stateConfig: questionState },
|
|
70
|
-
{ flat: true, stateConfig: optionsState },
|
|
71
|
-
],
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
getQuestion() {
|
|
75
|
-
return $getState(this, questionState);
|
|
76
|
-
}
|
|
77
|
-
setQuestion(valueOrUpdater) {
|
|
78
|
-
return $setState(this, questionState, valueOrUpdater);
|
|
79
|
-
}
|
|
80
|
-
getOptions() {
|
|
81
|
-
return $getState(this, optionsState);
|
|
82
|
-
}
|
|
83
|
-
setOptions(valueOrUpdater) {
|
|
84
|
-
return $setState(this, optionsState, valueOrUpdater);
|
|
85
|
-
}
|
|
86
|
-
addOption(option) {
|
|
87
|
-
return this.setOptions((options) => [...options, option]);
|
|
88
|
-
}
|
|
89
|
-
deleteOption(option) {
|
|
90
|
-
return this.setOptions((prevOptions) => {
|
|
91
|
-
const index = prevOptions.indexOf(option);
|
|
92
|
-
if (index === -1) {
|
|
93
|
-
return prevOptions;
|
|
94
|
-
}
|
|
95
|
-
const options = Array.from(prevOptions);
|
|
96
|
-
options.splice(index, 1);
|
|
97
|
-
return options;
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
setOptionText(option, text) {
|
|
101
|
-
return this.setOptions((prevOptions) => {
|
|
102
|
-
const clonedOption = cloneOption(option, text);
|
|
103
|
-
const options = Array.from(prevOptions);
|
|
104
|
-
const index = options.indexOf(option);
|
|
105
|
-
options[index] = clonedOption;
|
|
106
|
-
return options;
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
toggleVote(option, username) {
|
|
110
|
-
return this.setOptions((prevOptions) => {
|
|
111
|
-
const index = prevOptions.indexOf(option);
|
|
112
|
-
if (index === -1) {
|
|
113
|
-
return prevOptions;
|
|
114
|
-
}
|
|
115
|
-
const votes = option.votes;
|
|
116
|
-
const votesClone = Array.from(votes);
|
|
117
|
-
const voteIndex = votes.indexOf(username);
|
|
118
|
-
if (voteIndex === -1) {
|
|
119
|
-
votesClone.push(username);
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
votesClone.splice(voteIndex, 1);
|
|
123
|
-
}
|
|
124
|
-
const clonedOption = cloneOption(option, option.text, votesClone);
|
|
125
|
-
const options = Array.from(prevOptions);
|
|
126
|
-
options[index] = clonedOption;
|
|
127
|
-
return options;
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
exportDOM() {
|
|
131
|
-
const element = document.createElement('span');
|
|
132
|
-
element.setAttribute('data-lexical-poll-question', this.getQuestion());
|
|
133
|
-
element.setAttribute('data-lexical-poll-options', JSON.stringify(this.getOptions()));
|
|
134
|
-
return { element };
|
|
135
|
-
}
|
|
136
|
-
createDOM() {
|
|
137
|
-
const elem = document.createElement('span');
|
|
138
|
-
elem.style.display = 'inline-block';
|
|
139
|
-
return elem;
|
|
140
|
-
}
|
|
141
|
-
updateDOM() {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
decorate() {
|
|
145
|
-
return (_jsx(PollComponent, { question: this.getQuestion(), options: this.getOptions(), nodeKey: this.__key }));
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
export function $createPollNode(question, options) {
|
|
149
|
-
return new PollNode().setQuestion(question).setOptions(options);
|
|
150
|
-
}
|
|
151
|
-
export function $isPollNode(node) {
|
|
152
|
-
return node instanceof PollNode;
|
|
153
|
-
}
|
|
@@ -1,18 +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 type { LexicalEditor, NodeKey } from "lexical";
|
|
9
|
-
import type { JSX } from "react";
|
|
10
|
-
import "./StickyNode.css";
|
|
11
|
-
export default function StickyComponent({ x, y, nodeKey, color, caption, }: {
|
|
12
|
-
caption: LexicalEditor;
|
|
13
|
-
color: "pink" | "yellow";
|
|
14
|
-
nodeKey: NodeKey;
|
|
15
|
-
x: number;
|
|
16
|
-
y: number;
|
|
17
|
-
}): JSX.Element;
|
|
18
|
-
//# sourceMappingURL=StickyComponent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StickyComponent.d.ts","sourceRoot":"","sources":["../../src/nodes/StickyComponent.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,kBAAkB,CAAC;AAmC1B,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,CAAC,EACD,CAAC,EACD,OAAO,EACP,KAAK,EACL,OAAO,GACR,EAAE;IACD,OAAO,EAAE,aAAa,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,GAAG,GAAG,CAAC,OAAO,CAmMd"}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import "./StickyNode.css";
|
|
3
|
-
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
4
|
-
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
5
|
-
import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer";
|
|
6
|
-
import { PlainTextPlugin } from "@lexical/react/LexicalPlainTextPlugin";
|
|
7
|
-
import { calculateZoomLevel } from "@lexical/utils";
|
|
8
|
-
import { $getNodeByKey } from "lexical";
|
|
9
|
-
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
10
|
-
import StickyEditorTheme from "../themes/StickyEditorTheme";
|
|
11
|
-
import ContentEditable from "../ui/ContentEditable";
|
|
12
|
-
import { $isStickyNode } from "./StickyNode";
|
|
13
|
-
function positionSticky(stickyElem, positioning) {
|
|
14
|
-
const style = stickyElem.style;
|
|
15
|
-
const rootElementRect = positioning.rootElementRect;
|
|
16
|
-
const rectLeft = rootElementRect !== null ? rootElementRect.left : 0;
|
|
17
|
-
const rectTop = rootElementRect !== null ? rootElementRect.top : 0;
|
|
18
|
-
style.top = rectTop + positioning.y + "px";
|
|
19
|
-
style.left = rectLeft + positioning.x + "px";
|
|
20
|
-
}
|
|
21
|
-
export default function StickyComponent({ x, y, nodeKey, color, caption, }) {
|
|
22
|
-
const [editor] = useLexicalComposerContext();
|
|
23
|
-
const stickyContainerRef = useRef(null);
|
|
24
|
-
const positioningRef = useRef({
|
|
25
|
-
isDragging: false,
|
|
26
|
-
offsetX: 0,
|
|
27
|
-
offsetY: 0,
|
|
28
|
-
rootElementRect: null,
|
|
29
|
-
x: 0,
|
|
30
|
-
y: 0,
|
|
31
|
-
});
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
const position = positioningRef.current;
|
|
34
|
-
position.x = x;
|
|
35
|
-
position.y = y;
|
|
36
|
-
const stickyContainer = stickyContainerRef.current;
|
|
37
|
-
if (stickyContainer !== null) {
|
|
38
|
-
positionSticky(stickyContainer, position);
|
|
39
|
-
}
|
|
40
|
-
}, [x, y]);
|
|
41
|
-
useLayoutEffect(() => {
|
|
42
|
-
const position = positioningRef.current;
|
|
43
|
-
const resizeObserver = new ResizeObserver((entries) => {
|
|
44
|
-
for (let i = 0; i < entries.length; i++) {
|
|
45
|
-
const entry = entries[i];
|
|
46
|
-
const { target } = entry;
|
|
47
|
-
position.rootElementRect = target.getBoundingClientRect();
|
|
48
|
-
const stickyContainer = stickyContainerRef.current;
|
|
49
|
-
if (stickyContainer !== null) {
|
|
50
|
-
positionSticky(stickyContainer, position);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
const removeRootListener = editor.registerRootListener((nextRootElem, prevRootElem) => {
|
|
55
|
-
if (prevRootElem !== null) {
|
|
56
|
-
resizeObserver.unobserve(prevRootElem);
|
|
57
|
-
}
|
|
58
|
-
if (nextRootElem !== null) {
|
|
59
|
-
resizeObserver.observe(nextRootElem);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
const handleWindowResize = () => {
|
|
63
|
-
const rootElement = editor.getRootElement();
|
|
64
|
-
const stickyContainer = stickyContainerRef.current;
|
|
65
|
-
if (rootElement !== null && stickyContainer !== null) {
|
|
66
|
-
position.rootElementRect = rootElement.getBoundingClientRect();
|
|
67
|
-
positionSticky(stickyContainer, position);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
window.addEventListener("resize", handleWindowResize);
|
|
71
|
-
return () => {
|
|
72
|
-
window.removeEventListener("resize", handleWindowResize);
|
|
73
|
-
removeRootListener();
|
|
74
|
-
};
|
|
75
|
-
}, [editor]);
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
const stickyContainer = stickyContainerRef.current;
|
|
78
|
-
if (stickyContainer !== null) {
|
|
79
|
-
// Delay adding transition so we don't trigger the
|
|
80
|
-
// transition on load of the sticky.
|
|
81
|
-
setTimeout(() => {
|
|
82
|
-
stickyContainer.style.setProperty("transition", "top 0.3s ease 0s, left 0.3s ease 0s");
|
|
83
|
-
}, 500);
|
|
84
|
-
}
|
|
85
|
-
}, []);
|
|
86
|
-
const handlePointerMove = (event) => {
|
|
87
|
-
const stickyContainer = stickyContainerRef.current;
|
|
88
|
-
const positioning = positioningRef.current;
|
|
89
|
-
const rootElementRect = positioning.rootElementRect;
|
|
90
|
-
const zoom = calculateZoomLevel(stickyContainer);
|
|
91
|
-
if (stickyContainer !== null &&
|
|
92
|
-
positioning.isDragging &&
|
|
93
|
-
rootElementRect !== null) {
|
|
94
|
-
positioning.x =
|
|
95
|
-
event.pageX / zoom - positioning.offsetX - rootElementRect.left;
|
|
96
|
-
positioning.y =
|
|
97
|
-
event.pageY / zoom - positioning.offsetY - rootElementRect.top;
|
|
98
|
-
positionSticky(stickyContainer, positioning);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
const handlePointerUp = (event) => {
|
|
102
|
-
const stickyContainer = stickyContainerRef.current;
|
|
103
|
-
const positioning = positioningRef.current;
|
|
104
|
-
if (stickyContainer !== null) {
|
|
105
|
-
positioning.isDragging = false;
|
|
106
|
-
stickyContainer.classList.remove("dragging");
|
|
107
|
-
editor.update(() => {
|
|
108
|
-
const node = $getNodeByKey(nodeKey);
|
|
109
|
-
if ($isStickyNode(node)) {
|
|
110
|
-
node.setPosition(positioning.x, positioning.y);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
document.removeEventListener("pointermove", handlePointerMove);
|
|
115
|
-
document.removeEventListener("pointerup", handlePointerUp);
|
|
116
|
-
};
|
|
117
|
-
const handleDelete = () => {
|
|
118
|
-
editor.update(() => {
|
|
119
|
-
const node = $getNodeByKey(nodeKey);
|
|
120
|
-
if ($isStickyNode(node)) {
|
|
121
|
-
node.remove();
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
const handleColorChange = () => {
|
|
126
|
-
editor.update(() => {
|
|
127
|
-
const node = $getNodeByKey(nodeKey);
|
|
128
|
-
if ($isStickyNode(node)) {
|
|
129
|
-
node.toggleColor();
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
return (_jsx("div", { ref: stickyContainerRef, className: "sticky-note-container", children: _jsxs("div", { className: `sticky-note ${color}`, onPointerDown: (event) => {
|
|
134
|
-
const stickyContainer = stickyContainerRef.current;
|
|
135
|
-
if (stickyContainer == null ||
|
|
136
|
-
event.button === 2 ||
|
|
137
|
-
event.target !== stickyContainer.firstChild) {
|
|
138
|
-
// Right click or click on editor should not work
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
const stickContainer = stickyContainer;
|
|
142
|
-
const positioning = positioningRef.current;
|
|
143
|
-
if (stickContainer !== null) {
|
|
144
|
-
const { top, left } = stickContainer.getBoundingClientRect();
|
|
145
|
-
const zoom = calculateZoomLevel(stickContainer);
|
|
146
|
-
positioning.offsetX = event.clientX / zoom - left;
|
|
147
|
-
positioning.offsetY = event.clientY / zoom - top;
|
|
148
|
-
positioning.isDragging = true;
|
|
149
|
-
stickContainer.classList.add("dragging");
|
|
150
|
-
document.addEventListener("pointermove", handlePointerMove);
|
|
151
|
-
document.addEventListener("pointerup", handlePointerUp);
|
|
152
|
-
event.preventDefault();
|
|
153
|
-
}
|
|
154
|
-
}, children: [_jsx("button", { onClick: handleDelete, className: "delete", "aria-label": "Delete sticky note", title: "Delete", children: "X" }), _jsx("button", { onClick: handleColorChange, className: "color", "aria-label": "Change sticky note color", title: "Color", children: _jsx("i", { className: "bucket" }) }), _jsx(LexicalNestedComposer, { initialEditor: caption, initialTheme: StickyEditorTheme, children: _jsx(PlainTextPlugin, { contentEditable: _jsx(ContentEditable, { placeholder: "What's up?", placeholderClassName: "StickyNode__placeholder", className: "StickyNode__contentEditable" }), ErrorBoundary: LexicalErrorBoundary }) })] }) }));
|
|
155
|
-
}
|