@ethberry/mui-lexical 1.0.7
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/LICENSE +16 -0
- package/README.md +1 -0
- package/dist/common/hooks/index.d.ts +1 -0
- package/dist/common/hooks/index.js +18 -0
- package/dist/common/hooks/index.js.map +1 -0
- package/dist/common/hooks/useModal.d.ts +2 -0
- package/dist/common/hooks/useModal.js +28 -0
- package/dist/common/hooks/useModal.js.map +1 -0
- package/dist/common/index.d.ts +2 -0
- package/dist/common/index.js +19 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/types/index.d.ts +5 -0
- package/dist/common/types/index.js +3 -0
- package/dist/common/types/index.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +18 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/ui/Modal/index.d.ts +6 -0
- package/dist/components/ui/Modal/index.js +18 -0
- package/dist/components/ui/Modal/index.js.map +1 -0
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.js +18 -0
- package/dist/components/ui/index.js.map +1 -0
- package/dist/config/lexicalEditorConfig.d.ts +78 -0
- package/dist/config/lexicalEditorConfig.js +33 -0
- package/dist/config/lexicalEditorConfig.js.map +1 -0
- package/dist/config/lexicalEditorTheme.d.ts +68 -0
- package/dist/config/lexicalEditorTheme.js +71 -0
- package/dist/config/lexicalEditorTheme.js.map +1 -0
- package/dist/display/index.d.ts +6 -0
- package/dist/display/index.js +47 -0
- package/dist/display/index.js.map +1 -0
- package/dist/display/styled.d.ts +1 -0
- package/dist/display/styled.js +67 -0
- package/dist/display/styled.js.map +1 -0
- package/dist/editor/Editor.d.ts +16 -0
- package/dist/editor/Editor.js +95 -0
- package/dist/editor/Editor.js.map +1 -0
- package/dist/editor/Editor.stories.d.ts +13 -0
- package/dist/editor/Editor.stories.js +135 -0
- package/dist/editor/Editor.stories.js.map +1 -0
- package/dist/editor/commands/index.d.ts +4 -0
- package/dist/editor/commands/index.js +6 -0
- package/dist/editor/commands/index.js.map +1 -0
- package/dist/editor/constants/index.d.ts +2 -0
- package/dist/editor/constants/index.js +40 -0
- package/dist/editor/constants/index.js.map +1 -0
- package/dist/editor/context/SharedHistoryContext.d.ts +11 -0
- package/dist/editor/context/SharedHistoryContext.js +17 -0
- package/dist/editor/context/SharedHistoryContext.js.map +1 -0
- package/dist/editor/context/ToolbarContext.d.ts +56 -0
- package/dist/editor/context/ToolbarContext.js +67 -0
- package/dist/editor/context/ToolbarContext.js.map +1 -0
- package/dist/editor/context/index.d.ts +2 -0
- package/dist/editor/context/index.js +19 -0
- package/dist/editor/context/index.js.map +1 -0
- package/dist/editor/editorStyles.d.ts +1 -0
- package/dist/editor/editorStyles.js +1273 -0
- package/dist/editor/editorStyles.js.map +1 -0
- package/dist/editor/hooks/index.d.ts +1 -0
- package/dist/editor/hooks/index.js +18 -0
- package/dist/editor/hooks/index.js.map +1 -0
- package/dist/editor/hooks/useModal.d.ts +2 -0
- package/dist/editor/hooks/useModal.js +29 -0
- package/dist/editor/hooks/useModal.js.map +1 -0
- package/dist/editor/images/icons/3-columns.d.ts +1 -0
- package/dist/editor/images/icons/3-columns.js +9 -0
- package/dist/editor/images/icons/3-columns.js.map +1 -0
- package/dist/editor/images/icons/add-sign.d.ts +1 -0
- package/dist/editor/images/icons/add-sign.js +9 -0
- package/dist/editor/images/icons/add-sign.js.map +1 -0
- package/dist/editor/images/icons/arrow-clockwise.d.ts +1 -0
- package/dist/editor/images/icons/arrow-clockwise.js +9 -0
- package/dist/editor/images/icons/arrow-clockwise.js.map +1 -0
- package/dist/editor/images/icons/arrow-counterclockwise.d.ts +1 -0
- package/dist/editor/images/icons/arrow-counterclockwise.js +9 -0
- package/dist/editor/images/icons/arrow-counterclockwise.js.map +1 -0
- package/dist/editor/images/icons/bg-color.d.ts +1 -0
- package/dist/editor/images/icons/bg-color.js +9 -0
- package/dist/editor/images/icons/bg-color.js.map +1 -0
- package/dist/editor/images/icons/camera.d.ts +1 -0
- package/dist/editor/images/icons/camera.js +9 -0
- package/dist/editor/images/icons/camera.js.map +1 -0
- package/dist/editor/images/icons/card-checklist.d.ts +1 -0
- package/dist/editor/images/icons/card-checklist.js +9 -0
- package/dist/editor/images/icons/card-checklist.js.map +1 -0
- package/dist/editor/images/icons/caret-right-fill.d.ts +1 -0
- package/dist/editor/images/icons/caret-right-fill.js +9 -0
- package/dist/editor/images/icons/caret-right-fill.js.map +1 -0
- package/dist/editor/images/icons/chat-left-text.d.ts +1 -0
- package/dist/editor/images/icons/chat-left-text.js +9 -0
- package/dist/editor/images/icons/chat-left-text.js.map +1 -0
- package/dist/editor/images/icons/chat-right-dots.d.ts +1 -0
- package/dist/editor/images/icons/chat-right-dots.js +9 -0
- package/dist/editor/images/icons/chat-right-dots.js.map +1 -0
- package/dist/editor/images/icons/chat-right-text.d.ts +1 -0
- package/dist/editor/images/icons/chat-right-text.js +9 -0
- package/dist/editor/images/icons/chat-right-text.js.map +1 -0
- package/dist/editor/images/icons/chat-right.d.ts +1 -0
- package/dist/editor/images/icons/chat-right.js +9 -0
- package/dist/editor/images/icons/chat-right.js.map +1 -0
- package/dist/editor/images/icons/chat-square-quote.d.ts +1 -0
- package/dist/editor/images/icons/chat-square-quote.js +9 -0
- package/dist/editor/images/icons/chat-square-quote.js.map +1 -0
- package/dist/editor/images/icons/chevron-down.d.ts +1 -0
- package/dist/editor/images/icons/chevron-down.js +9 -0
- package/dist/editor/images/icons/chevron-down.js.map +1 -0
- package/dist/editor/images/icons/clipboard.d.ts +1 -0
- package/dist/editor/images/icons/clipboard.js +9 -0
- package/dist/editor/images/icons/clipboard.js.map +1 -0
- package/dist/editor/images/icons/close.d.ts +1 -0
- package/dist/editor/images/icons/close.js +9 -0
- package/dist/editor/images/icons/close.js.map +1 -0
- package/dist/editor/images/icons/code.d.ts +1 -0
- package/dist/editor/images/icons/code.js +9 -0
- package/dist/editor/images/icons/code.js.map +1 -0
- package/dist/editor/images/icons/comments.d.ts +1 -0
- package/dist/editor/images/icons/comments.js +9 -0
- package/dist/editor/images/icons/comments.js.map +1 -0
- package/dist/editor/images/icons/copy.d.ts +1 -0
- package/dist/editor/images/icons/copy.js +9 -0
- package/dist/editor/images/icons/copy.js.map +1 -0
- package/dist/editor/images/icons/diagram-2.d.ts +1 -0
- package/dist/editor/images/icons/diagram-2.js +9 -0
- package/dist/editor/images/icons/diagram-2.js.map +1 -0
- package/dist/editor/images/icons/download.d.ts +1 -0
- package/dist/editor/images/icons/download.js +9 -0
- package/dist/editor/images/icons/download.js.map +1 -0
- package/dist/editor/images/icons/draggable-block-menu.d.ts +1 -0
- package/dist/editor/images/icons/draggable-block-menu.js +9 -0
- package/dist/editor/images/icons/draggable-block-menu.js.map +1 -0
- package/dist/editor/images/icons/dropdown-more.d.ts +1 -0
- package/dist/editor/images/icons/dropdown-more.js +9 -0
- package/dist/editor/images/icons/dropdown-more.js.map +1 -0
- package/dist/editor/images/icons/figma.d.ts +1 -0
- package/dist/editor/images/icons/figma.js +9 -0
- package/dist/editor/images/icons/figma.js.map +1 -0
- package/dist/editor/images/icons/file-earmark-text.d.ts +1 -0
- package/dist/editor/images/icons/file-earmark-text.js +9 -0
- package/dist/editor/images/icons/file-earmark-text.js.map +1 -0
- package/dist/editor/images/icons/file-image.d.ts +1 -0
- package/dist/editor/images/icons/file-image.js +9 -0
- package/dist/editor/images/icons/file-image.js.map +1 -0
- package/dist/editor/images/icons/filetype-gif.d.ts +1 -0
- package/dist/editor/images/icons/filetype-gif.js +9 -0
- package/dist/editor/images/icons/filetype-gif.js.map +1 -0
- package/dist/editor/images/icons/font-color.d.ts +1 -0
- package/dist/editor/images/icons/font-color.js +9 -0
- package/dist/editor/images/icons/font-color.js.map +1 -0
- package/dist/editor/images/icons/font-family.d.ts +1 -0
- package/dist/editor/images/icons/font-family.js +9 -0
- package/dist/editor/images/icons/font-family.js.map +1 -0
- package/dist/editor/images/icons/format-clear.d.ts +1 -0
- package/dist/editor/images/icons/format-clear.js +9 -0
- package/dist/editor/images/icons/format-clear.js.map +1 -0
- package/dist/editor/images/icons/highlighter.d.ts +1 -0
- package/dist/editor/images/icons/highlighter.js +9 -0
- package/dist/editor/images/icons/highlighter.js.map +1 -0
- package/dist/editor/images/icons/horizontal-rule.d.ts +1 -0
- package/dist/editor/images/icons/horizontal-rule.js +9 -0
- package/dist/editor/images/icons/horizontal-rule.js.map +1 -0
- package/dist/editor/images/icons/indent.d.ts +1 -0
- package/dist/editor/images/icons/indent.js +9 -0
- package/dist/editor/images/icons/indent.js.map +1 -0
- package/dist/editor/images/icons/index.d.ts +88 -0
- package/dist/editor/images/icons/index.js +105 -0
- package/dist/editor/images/icons/index.js.map +1 -0
- package/dist/editor/images/icons/journal-text.d.ts +1 -0
- package/dist/editor/images/icons/journal-text.js +9 -0
- package/dist/editor/images/icons/journal-text.js.map +1 -0
- package/dist/editor/images/icons/justify.d.ts +1 -0
- package/dist/editor/images/icons/justify.js +9 -0
- package/dist/editor/images/icons/justify.js.map +1 -0
- package/dist/editor/images/icons/link.d.ts +1 -0
- package/dist/editor/images/icons/link.js +9 -0
- package/dist/editor/images/icons/link.js.map +1 -0
- package/dist/editor/images/icons/list-ol.d.ts +1 -0
- package/dist/editor/images/icons/list-ol.js +9 -0
- package/dist/editor/images/icons/list-ol.js.map +1 -0
- package/dist/editor/images/icons/list-ul.d.ts +1 -0
- package/dist/editor/images/icons/list-ul.js +9 -0
- package/dist/editor/images/icons/list-ul.js.map +1 -0
- package/dist/editor/images/icons/lock-fill.d.ts +1 -0
- package/dist/editor/images/icons/lock-fill.js +9 -0
- package/dist/editor/images/icons/lock-fill.js.map +1 -0
- package/dist/editor/images/icons/lock.d.ts +1 -0
- package/dist/editor/images/icons/lock.js +9 -0
- package/dist/editor/images/icons/lock.js.map +1 -0
- package/dist/editor/images/icons/markdown.d.ts +1 -0
- package/dist/editor/images/icons/markdown.js +9 -0
- package/dist/editor/images/icons/markdown.js.map +1 -0
- package/dist/editor/images/icons/mic.d.ts +1 -0
- package/dist/editor/images/icons/mic.js +9 -0
- package/dist/editor/images/icons/mic.js.map +1 -0
- package/dist/editor/images/icons/minus-sign.d.ts +1 -0
- package/dist/editor/images/icons/minus-sign.js +9 -0
- package/dist/editor/images/icons/minus-sign.js.map +1 -0
- package/dist/editor/images/icons/outdent.d.ts +1 -0
- package/dist/editor/images/icons/outdent.js +9 -0
- package/dist/editor/images/icons/outdent.js.map +1 -0
- package/dist/editor/images/icons/paint-bucket.d.ts +1 -0
- package/dist/editor/images/icons/paint-bucket.js +9 -0
- package/dist/editor/images/icons/paint-bucket.js.map +1 -0
- package/dist/editor/images/icons/palette.d.ts +1 -0
- package/dist/editor/images/icons/palette.js +9 -0
- package/dist/editor/images/icons/palette.js.map +1 -0
- package/dist/editor/images/icons/pencil-fill.d.ts +1 -0
- package/dist/editor/images/icons/pencil-fill.js +9 -0
- package/dist/editor/images/icons/pencil-fill.js.map +1 -0
- package/dist/editor/images/icons/plug-fill.d.ts +1 -0
- package/dist/editor/images/icons/plug-fill.js +9 -0
- package/dist/editor/images/icons/plug-fill.js.map +1 -0
- package/dist/editor/images/icons/plug.d.ts +1 -0
- package/dist/editor/images/icons/plug.js +9 -0
- package/dist/editor/images/icons/plug.js.map +1 -0
- package/dist/editor/images/icons/plus-slash-minus.d.ts +1 -0
- package/dist/editor/images/icons/plus-slash-minus.js +9 -0
- package/dist/editor/images/icons/plus-slash-minus.js.map +1 -0
- package/dist/editor/images/icons/plus.d.ts +1 -0
- package/dist/editor/images/icons/plus.js +9 -0
- package/dist/editor/images/icons/plus.js.map +1 -0
- package/dist/editor/images/icons/prettier-error.d.ts +1 -0
- package/dist/editor/images/icons/prettier-error.js +9 -0
- package/dist/editor/images/icons/prettier-error.js.map +1 -0
- package/dist/editor/images/icons/prettier.d.ts +1 -0
- package/dist/editor/images/icons/prettier.js +9 -0
- package/dist/editor/images/icons/prettier.js.map +1 -0
- package/dist/editor/images/icons/scissors.d.ts +1 -0
- package/dist/editor/images/icons/scissors.js +9 -0
- package/dist/editor/images/icons/scissors.js.map +1 -0
- package/dist/editor/images/icons/send.d.ts +1 -0
- package/dist/editor/images/icons/send.js +9 -0
- package/dist/editor/images/icons/send.js.map +1 -0
- package/dist/editor/images/icons/square-check.d.ts +1 -0
- package/dist/editor/images/icons/square-check.js +9 -0
- package/dist/editor/images/icons/square-check.js.map +1 -0
- package/dist/editor/images/icons/sticky.d.ts +1 -0
- package/dist/editor/images/icons/sticky.js +9 -0
- package/dist/editor/images/icons/sticky.js.map +1 -0
- package/dist/editor/images/icons/success-alt.d.ts +1 -0
- package/dist/editor/images/icons/success-alt.js +9 -0
- package/dist/editor/images/icons/success-alt.js.map +1 -0
- package/dist/editor/images/icons/success.d.ts +1 -0
- package/dist/editor/images/icons/success.js +9 -0
- package/dist/editor/images/icons/success.js.map +1 -0
- package/dist/editor/images/icons/table.d.ts +1 -0
- package/dist/editor/images/icons/table.js +9 -0
- package/dist/editor/images/icons/table.js.map +1 -0
- package/dist/editor/images/icons/text-center.d.ts +1 -0
- package/dist/editor/images/icons/text-center.js +9 -0
- package/dist/editor/images/icons/text-center.js.map +1 -0
- package/dist/editor/images/icons/text-left.d.ts +1 -0
- package/dist/editor/images/icons/text-left.js +9 -0
- package/dist/editor/images/icons/text-left.js.map +1 -0
- package/dist/editor/images/icons/text-paragraph.d.ts +1 -0
- package/dist/editor/images/icons/text-paragraph.js +9 -0
- package/dist/editor/images/icons/text-paragraph.js.map +1 -0
- package/dist/editor/images/icons/text-right.d.ts +1 -0
- package/dist/editor/images/icons/text-right.js +9 -0
- package/dist/editor/images/icons/text-right.js.map +1 -0
- package/dist/editor/images/icons/trash.d.ts +1 -0
- package/dist/editor/images/icons/trash.js +9 -0
- package/dist/editor/images/icons/trash.js.map +1 -0
- package/dist/editor/images/icons/trash3.d.ts +1 -0
- package/dist/editor/images/icons/trash3.js +9 -0
- package/dist/editor/images/icons/trash3.js.map +1 -0
- package/dist/editor/images/icons/type-bold.d.ts +1 -0
- package/dist/editor/images/icons/type-bold.js +9 -0
- package/dist/editor/images/icons/type-bold.js.map +1 -0
- package/dist/editor/images/icons/type-capitalize.d.ts +1 -0
- package/dist/editor/images/icons/type-capitalize.js +9 -0
- package/dist/editor/images/icons/type-capitalize.js.map +1 -0
- package/dist/editor/images/icons/type-h1.d.ts +1 -0
- package/dist/editor/images/icons/type-h1.js +9 -0
- package/dist/editor/images/icons/type-h1.js.map +1 -0
- package/dist/editor/images/icons/type-h2.d.ts +1 -0
- package/dist/editor/images/icons/type-h2.js +9 -0
- package/dist/editor/images/icons/type-h2.js.map +1 -0
- package/dist/editor/images/icons/type-h3.d.ts +1 -0
- package/dist/editor/images/icons/type-h3.js +9 -0
- package/dist/editor/images/icons/type-h3.js.map +1 -0
- package/dist/editor/images/icons/type-h4.d.ts +1 -0
- package/dist/editor/images/icons/type-h4.js +9 -0
- package/dist/editor/images/icons/type-h4.js.map +1 -0
- package/dist/editor/images/icons/type-h5.d.ts +1 -0
- package/dist/editor/images/icons/type-h5.js +9 -0
- package/dist/editor/images/icons/type-h5.js.map +1 -0
- package/dist/editor/images/icons/type-h6.d.ts +1 -0
- package/dist/editor/images/icons/type-h6.js +9 -0
- package/dist/editor/images/icons/type-h6.js.map +1 -0
- package/dist/editor/images/icons/type-italic.d.ts +1 -0
- package/dist/editor/images/icons/type-italic.js +9 -0
- package/dist/editor/images/icons/type-italic.js.map +1 -0
- package/dist/editor/images/icons/type-lowercase.d.ts +1 -0
- package/dist/editor/images/icons/type-lowercase.js +9 -0
- package/dist/editor/images/icons/type-lowercase.js.map +1 -0
- package/dist/editor/images/icons/type-strikethrough.d.ts +1 -0
- package/dist/editor/images/icons/type-strikethrough.js +9 -0
- package/dist/editor/images/icons/type-strikethrough.js.map +1 -0
- package/dist/editor/images/icons/type-subscript.d.ts +1 -0
- package/dist/editor/images/icons/type-subscript.js +9 -0
- package/dist/editor/images/icons/type-subscript.js.map +1 -0
- package/dist/editor/images/icons/type-superscript.d.ts +1 -0
- package/dist/editor/images/icons/type-superscript.js +9 -0
- package/dist/editor/images/icons/type-superscript.js.map +1 -0
- package/dist/editor/images/icons/type-underline.d.ts +1 -0
- package/dist/editor/images/icons/type-underline.js +9 -0
- package/dist/editor/images/icons/type-underline.js.map +1 -0
- package/dist/editor/images/icons/type-uppercase.d.ts +1 -0
- package/dist/editor/images/icons/type-uppercase.js +9 -0
- package/dist/editor/images/icons/type-uppercase.js.map +1 -0
- package/dist/editor/images/icons/upload.d.ts +1 -0
- package/dist/editor/images/icons/upload.js +9 -0
- package/dist/editor/images/icons/upload.js.map +1 -0
- package/dist/editor/images/icons/user.d.ts +1 -0
- package/dist/editor/images/icons/user.js +9 -0
- package/dist/editor/images/icons/user.js.map +1 -0
- package/dist/editor/images/icons/vertical-bottom.d.ts +1 -0
- package/dist/editor/images/icons/vertical-bottom.js +9 -0
- package/dist/editor/images/icons/vertical-bottom.js.map +1 -0
- package/dist/editor/images/icons/vertical-middle.d.ts +1 -0
- package/dist/editor/images/icons/vertical-middle.js +9 -0
- package/dist/editor/images/icons/vertical-middle.js.map +1 -0
- package/dist/editor/images/icons/vertical-top.d.ts +1 -0
- package/dist/editor/images/icons/vertical-top.js +9 -0
- package/dist/editor/images/icons/vertical-top.js.map +1 -0
- package/dist/editor/images/icons/x.d.ts +1 -0
- package/dist/editor/images/icons/x.js +9 -0
- package/dist/editor/images/icons/x.js.map +1 -0
- package/dist/editor/images/icons/youtube.d.ts +1 -0
- package/dist/editor/images/icons/youtube.js +9 -0
- package/dist/editor/images/icons/youtube.js.map +1 -0
- package/dist/editor/index.d.ts +1 -0
- package/dist/editor/index.js +6 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/editor/nodes/Image/ImageComponent.d.ts +15 -0
- package/dist/editor/nodes/Image/ImageComponent.js +248 -0
- package/dist/editor/nodes/Image/ImageComponent.js.map +1 -0
- package/dist/editor/nodes/Image/ImageNode.d.ts +50 -0
- package/dist/editor/nodes/Image/ImageNode.js +128 -0
- package/dist/editor/nodes/Image/ImageNode.js.map +1 -0
- package/dist/editor/nodes/Image/imageNodeStyles.d.ts +1 -0
- package/dist/editor/nodes/Image/imageNodeStyles.js +41 -0
- package/dist/editor/nodes/Image/imageNodeStyles.js.map +1 -0
- package/dist/editor/nodes/Image/index.d.ts +3 -0
- package/dist/editor/nodes/Image/index.js +10 -0
- package/dist/editor/nodes/Image/index.js.map +1 -0
- package/dist/editor/nodes/InlineImage/InlineImageComponent.d.ts +18 -0
- package/dist/editor/nodes/InlineImage/InlineImageComponent.js +160 -0
- package/dist/editor/nodes/InlineImage/InlineImageComponent.js.map +1 -0
- package/dist/editor/nodes/InlineImage/InlineImageNode.d.ts +59 -0
- package/dist/editor/nodes/InlineImage/InlineImageNode.js +149 -0
- package/dist/editor/nodes/InlineImage/InlineImageNode.js.map +1 -0
- package/dist/editor/nodes/InlineImage/index.d.ts +3 -0
- package/dist/editor/nodes/InlineImage/index.js +10 -0
- package/dist/editor/nodes/InlineImage/index.js.map +1 -0
- package/dist/editor/nodes/InlineImage/inlineImageNodeStyles.d.ts +1 -0
- package/dist/editor/nodes/InlineImage/inlineImageNodeStyles.js +90 -0
- package/dist/editor/nodes/InlineImage/inlineImageNodeStyles.js.map +1 -0
- package/dist/editor/nodes/PlaygroundNodes.d.ts +2 -0
- package/dist/editor/nodes/PlaygroundNodes.js +32 -0
- package/dist/editor/nodes/PlaygroundNodes.js.map +1 -0
- package/dist/editor/nodes/Video/VideoComponent.d.ts +9 -0
- package/dist/editor/nodes/Video/VideoComponent.js +15 -0
- package/dist/editor/nodes/Video/VideoComponent.js.map +1 -0
- package/dist/editor/nodes/Video/VideoNode.d.ts +34 -0
- package/dist/editor/nodes/Video/VideoNode.js +129 -0
- package/dist/editor/nodes/Video/VideoNode.js.map +1 -0
- package/dist/editor/nodes/Video/index.d.ts +3 -0
- package/dist/editor/nodes/Video/index.js +10 -0
- package/dist/editor/nodes/Video/index.js.map +1 -0
- package/dist/editor/nodes/Video/videoNodeStyles.d.ts +1 -0
- package/dist/editor/nodes/Video/videoNodeStyles.js +44 -0
- package/dist/editor/nodes/Video/videoNodeStyles.js.map +1 -0
- package/dist/editor/nodes/index.d.ts +4 -0
- package/dist/editor/nodes/index.js +21 -0
- package/dist/editor/nodes/index.js.map +1 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/codeActionMenuPluginStyles.d.ts +1 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/codeActionMenuPluginStyles.js +68 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/codeActionMenuPluginStyles.js.map +1 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/components/CopyButton/index.d.ts +7 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/components/CopyButton/index.js +48 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/components/CopyButton/index.js.map +1 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.d.ts +9 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.js +136 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.js.map +1 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/components/index.d.ts +2 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/components/index.js +19 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/components/index.js.map +1 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/index.d.ts +12 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/index.js +118 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/index.js.map +1 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/utils.d.ts +1 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/utils.js +15 -0
- package/dist/editor/plugins/CodeActionMenuPlugin/utils.js.map +1 -0
- package/dist/editor/plugins/CodeHighlightPlugin/index.d.ts +2 -0
- package/dist/editor/plugins/CodeHighlightPlugin/index.js +15 -0
- package/dist/editor/plugins/CodeHighlightPlugin/index.js.map +1 -0
- package/dist/editor/plugins/ComponentPickerPlugin/index.d.ts +9 -0
- package/dist/editor/plugins/ComponentPickerPlugin/index.js +217 -0
- package/dist/editor/plugins/ComponentPickerPlugin/index.js.map +1 -0
- package/dist/editor/plugins/ContextMenuPlugin/index.d.ts +18 -0
- package/dist/editor/plugins/ContextMenuPlugin/index.js +190 -0
- package/dist/editor/plugins/ContextMenuPlugin/index.js.map +1 -0
- package/dist/editor/plugins/FloatingLinkEditorPlugin/floatLinkEditorPluginStyles.d.ts +1 -0
- package/dist/editor/plugins/FloatingLinkEditorPlugin/floatLinkEditorPluginStyles.js +48 -0
- package/dist/editor/plugins/FloatingLinkEditorPlugin/floatLinkEditorPluginStyles.js.map +1 -0
- package/dist/editor/plugins/FloatingLinkEditorPlugin/index.d.ts +14 -0
- package/dist/editor/plugins/FloatingLinkEditorPlugin/index.js +275 -0
- package/dist/editor/plugins/FloatingLinkEditorPlugin/index.js.map +1 -0
- package/dist/editor/plugins/FloatingTextFormatToolbarPlugin/floatTextFormatToolbarPluginStyles.d.ts +1 -0
- package/dist/editor/plugins/FloatingTextFormatToolbarPlugin/floatTextFormatToolbarPluginStyles.js +141 -0
- package/dist/editor/plugins/FloatingTextFormatToolbarPlugin/floatTextFormatToolbarPluginStyles.js.map +1 -0
- package/dist/editor/plugins/FloatingTextFormatToolbarPlugin/index.d.ts +15 -0
- package/dist/editor/plugins/FloatingTextFormatToolbarPlugin/index.js +214 -0
- package/dist/editor/plugins/FloatingTextFormatToolbarPlugin/index.js.map +1 -0
- package/dist/editor/plugins/ImagesPlugin/index.d.ts +28 -0
- package/dist/editor/plugins/ImagesPlugin/index.js +175 -0
- package/dist/editor/plugins/ImagesPlugin/index.js.map +1 -0
- package/dist/editor/plugins/LinkPlugin/index.d.ts +9 -0
- package/dist/editor/plugins/LinkPlugin/index.js +14 -0
- package/dist/editor/plugins/LinkPlugin/index.js.map +1 -0
- package/dist/editor/plugins/MarkdownShortcutPlugin/index.d.ts +9 -0
- package/dist/editor/plugins/MarkdownShortcutPlugin/index.js +11 -0
- package/dist/editor/plugins/MarkdownShortcutPlugin/index.js.map +1 -0
- package/dist/editor/plugins/MarkdownTransformers/index.d.ts +5 -0
- package/dist/editor/plugins/MarkdownTransformers/index.js +181 -0
- package/dist/editor/plugins/MarkdownTransformers/index.js.map +1 -0
- package/dist/editor/plugins/MaxLengthPlugin/index.d.ts +10 -0
- package/dist/editor/plugins/MaxLengthPlugin/index.js +48 -0
- package/dist/editor/plugins/MaxLengthPlugin/index.js.map +1 -0
- package/dist/editor/plugins/ShortcutsPlugin/index.d.ts +13 -0
- package/dist/editor/plugins/ShortcutsPlugin/index.js +102 -0
- package/dist/editor/plugins/ShortcutsPlugin/index.js.map +1 -0
- package/dist/editor/plugins/ShortcutsPlugin/shortcuts.d.ts +56 -0
- package/dist/editor/plugins/ShortcutsPlugin/shortcuts.js +145 -0
- package/dist/editor/plugins/ShortcutsPlugin/shortcuts.js.map +1 -0
- package/dist/editor/plugins/TabFocusPlugin/index.d.ts +8 -0
- package/dist/editor/plugins/TabFocusPlugin/index.js +46 -0
- package/dist/editor/plugins/TabFocusPlugin/index.js.map +1 -0
- package/dist/editor/plugins/TableActionMenuPlugin/index.d.ts +12 -0
- package/dist/editor/plugins/TableActionMenuPlugin/index.js +371 -0
- package/dist/editor/plugins/TableActionMenuPlugin/index.js.map +1 -0
- package/dist/editor/plugins/TableCellResizer/index.d.ts +3 -0
- package/dist/editor/plugins/TableCellResizer/index.js +301 -0
- package/dist/editor/plugins/TableCellResizer/index.js.map +1 -0
- package/dist/editor/plugins/TableCellResizer/tableCellResizerPluginStyles.d.ts +1 -0
- package/dist/editor/plugins/TableCellResizer/tableCellResizerPluginStyles.js +18 -0
- package/dist/editor/plugins/TableCellResizer/tableCellResizerPluginStyles.js.map +1 -0
- package/dist/editor/plugins/TableHoverActionsPlugin/index.d.ts +11 -0
- package/dist/editor/plugins/TableHoverActionsPlugin/index.js +193 -0
- package/dist/editor/plugins/TableHoverActionsPlugin/index.js.map +1 -0
- package/dist/editor/plugins/TablePlugin.d.ts +38 -0
- package/dist/editor/plugins/TablePlugin.js +77 -0
- package/dist/editor/plugins/TablePlugin.js.map +1 -0
- package/dist/editor/plugins/ToolbarPlugin/index.d.ts +19 -0
- package/dist/editor/plugins/ToolbarPlugin/index.js +199 -0
- package/dist/editor/plugins/ToolbarPlugin/index.js.map +1 -0
- package/dist/editor/plugins/ToolbarPlugin/utils.d.ts +22 -0
- package/dist/editor/plugins/ToolbarPlugin/utils.js +224 -0
- package/dist/editor/plugins/ToolbarPlugin/utils.js.map +1 -0
- package/dist/editor/plugins/VideoPlugin/index.d.ts +7 -0
- package/dist/editor/plugins/VideoPlugin/index.js +61 -0
- package/dist/editor/plugins/VideoPlugin/index.js.map +1 -0
- package/dist/editor/plugins/index.d.ts +19 -0
- package/dist/editor/plugins/index.js +36 -0
- package/dist/editor/plugins/index.js.map +1 -0
- package/dist/editor/themes/index.d.ts +1 -0
- package/dist/editor/themes/index.js +6 -0
- package/dist/editor/themes/index.js.map +1 -0
- package/dist/editor/themes/playgroundEditorTheme.d.ts +2 -0
- package/dist/editor/themes/playgroundEditorTheme.js +116 -0
- package/dist/editor/themes/playgroundEditorTheme.js.map +1 -0
- package/dist/editor/themes/playgroundEditorThemeStyles.d.ts +1 -0
- package/dist/editor/themes/playgroundEditorThemeStyles.js +702 -0
- package/dist/editor/themes/playgroundEditorThemeStyles.js.map +1 -0
- package/dist/editor/types/index.d.ts +19 -0
- package/dist/editor/types/index.js +3 -0
- package/dist/editor/types/index.js.map +1 -0
- package/dist/editor/ui/BlockFormatDropdown/index.d.ts +18 -0
- package/dist/editor/ui/BlockFormatDropdown/index.js +73 -0
- package/dist/editor/ui/BlockFormatDropdown/index.js.map +1 -0
- package/dist/editor/ui/BoldButton/index.d.ts +7 -0
- package/dist/editor/ui/BoldButton/index.js +14 -0
- package/dist/editor/ui/BoldButton/index.js.map +1 -0
- package/dist/editor/ui/Button.d.ts +12 -0
- package/dist/editor/ui/Button.js +38 -0
- package/dist/editor/ui/Button.js.map +1 -0
- package/dist/editor/ui/CenterAlignButton/index.d.ts +7 -0
- package/dist/editor/ui/CenterAlignButton/index.js +14 -0
- package/dist/editor/ui/CenterAlignButton/index.js.map +1 -0
- package/dist/editor/ui/ClearEditorButton/index.d.ts +7 -0
- package/dist/editor/ui/ClearEditorButton/index.js +10 -0
- package/dist/editor/ui/ClearEditorButton/index.js.map +1 -0
- package/dist/editor/ui/ClearFormattingButton/index.d.ts +7 -0
- package/dist/editor/ui/ClearFormattingButton/index.js +10 -0
- package/dist/editor/ui/ClearFormattingButton/index.js.map +1 -0
- package/dist/editor/ui/CodeButton/index.d.ts +7 -0
- package/dist/editor/ui/CodeButton/index.js +14 -0
- package/dist/editor/ui/CodeButton/index.js.map +1 -0
- package/dist/editor/ui/CodeLanguageDropdown/index.d.ts +10 -0
- package/dist/editor/ui/CodeLanguageDropdown/index.js +26 -0
- package/dist/editor/ui/CodeLanguageDropdown/index.js.map +1 -0
- package/dist/editor/ui/ContentEditable.d.ts +9 -0
- package/dist/editor/ui/ContentEditable.js +63 -0
- package/dist/editor/ui/ContentEditable.js.map +1 -0
- package/dist/editor/ui/Dialog.d.ts +10 -0
- package/dist/editor/ui/Dialog.js +33 -0
- package/dist/editor/ui/Dialog.js.map +1 -0
- package/dist/editor/ui/Divider/index.d.ts +2 -0
- package/dist/editor/ui/Divider/index.js +9 -0
- package/dist/editor/ui/Divider/index.js.map +1 -0
- package/dist/editor/ui/DropDown.d.ts +16 -0
- package/dist/editor/ui/DropDown.js +141 -0
- package/dist/editor/ui/DropDown.js.map +1 -0
- package/dist/editor/ui/FlashMessage.d.ts +6 -0
- package/dist/editor/ui/FlashMessage.js +32 -0
- package/dist/editor/ui/FlashMessage.js.map +1 -0
- package/dist/editor/ui/HorizontalRuleButton/index.d.ts +3 -0
- package/dist/editor/ui/HorizontalRuleButton/index.js +13 -0
- package/dist/editor/ui/HorizontalRuleButton/index.js.map +1 -0
- package/dist/editor/ui/ImageButton/index.d.ts +8 -0
- package/dist/editor/ui/ImageButton/index.js +13 -0
- package/dist/editor/ui/ImageButton/index.js.map +1 -0
- package/dist/editor/ui/ImageResizer.d.ts +17 -0
- package/dist/editor/ui/ImageResizer.js +174 -0
- package/dist/editor/ui/ImageResizer.js.map +1 -0
- package/dist/editor/ui/ItalicButton/index.d.ts +7 -0
- package/dist/editor/ui/ItalicButton/index.js +14 -0
- package/dist/editor/ui/ItalicButton/index.js.map +1 -0
- package/dist/editor/ui/LeftAlignButton/index.d.ts +7 -0
- package/dist/editor/ui/LeftAlignButton/index.js +14 -0
- package/dist/editor/ui/LeftAlignButton/index.js.map +1 -0
- package/dist/editor/ui/LinkButton/index.d.ts +8 -0
- package/dist/editor/ui/LinkButton/index.js +11 -0
- package/dist/editor/ui/LinkButton/index.js.map +1 -0
- package/dist/editor/ui/Modal.d.ts +9 -0
- package/dist/editor/ui/Modal.js +110 -0
- package/dist/editor/ui/Modal.js.map +1 -0
- package/dist/editor/ui/RedoButton/index.d.ts +3 -0
- package/dist/editor/ui/RedoButton/index.js +14 -0
- package/dist/editor/ui/RedoButton/index.js.map +1 -0
- package/dist/editor/ui/RightAlignButton/index.d.ts +7 -0
- package/dist/editor/ui/RightAlignButton/index.js +14 -0
- package/dist/editor/ui/RightAlignButton/index.js.map +1 -0
- package/dist/editor/ui/Select.d.ts +8 -0
- package/dist/editor/ui/Select.js +52 -0
- package/dist/editor/ui/Select.js.map +1 -0
- package/dist/editor/ui/StrikethroughButton/index.d.ts +7 -0
- package/dist/editor/ui/StrikethroughButton/index.js +14 -0
- package/dist/editor/ui/StrikethroughButton/index.js.map +1 -0
- package/dist/editor/ui/TableButton/index.d.ts +8 -0
- package/dist/editor/ui/TableButton/index.js +13 -0
- package/dist/editor/ui/TableButton/index.js.map +1 -0
- package/dist/editor/ui/TextInput.d.ts +13 -0
- package/dist/editor/ui/TextInput.js +36 -0
- package/dist/editor/ui/TextInput.js.map +1 -0
- package/dist/editor/ui/UnderlineButton/index.d.ts +7 -0
- package/dist/editor/ui/UnderlineButton/index.js +14 -0
- package/dist/editor/ui/UnderlineButton/index.js.map +1 -0
- package/dist/editor/ui/UndoButton/index.d.ts +3 -0
- package/dist/editor/ui/UndoButton/index.js +14 -0
- package/dist/editor/ui/UndoButton/index.js.map +1 -0
- package/dist/editor/ui/VideoButton/index.d.ts +8 -0
- package/dist/editor/ui/VideoButton/index.js +13 -0
- package/dist/editor/ui/VideoButton/index.js.map +1 -0
- package/dist/editor/ui/index.d.ts +30 -0
- package/dist/editor/ui/index.js +74 -0
- package/dist/editor/ui/index.js.map +1 -0
- package/dist/editor/utils/dropDownActiveClass.d.ts +1 -0
- package/dist/editor/utils/dropDownActiveClass.js +12 -0
- package/dist/editor/utils/dropDownActiveClass.js.map +1 -0
- package/dist/editor/utils/getDOMRangeRect.d.ts +1 -0
- package/dist/editor/utils/getDOMRangeRect.js +19 -0
- package/dist/editor/utils/getDOMRangeRect.js.map +1 -0
- package/dist/editor/utils/getSelectedNode.d.ts +2 -0
- package/dist/editor/utils/getSelectedNode.js +21 -0
- package/dist/editor/utils/getSelectedNode.js.map +1 -0
- package/dist/editor/utils/getThemeSelector.d.ts +2 -0
- package/dist/editor/utils/getThemeSelector.js +15 -0
- package/dist/editor/utils/getThemeSelector.js.map +1 -0
- package/dist/editor/utils/index.d.ts +9 -0
- package/dist/editor/utils/index.js +26 -0
- package/dist/editor/utils/index.js.map +1 -0
- package/dist/editor/utils/joinClasses.d.ts +1 -0
- package/dist/editor/utils/joinClasses.js +8 -0
- package/dist/editor/utils/joinClasses.js.map +1 -0
- package/dist/editor/utils/parseVideoUrl.d.ts +15 -0
- package/dist/editor/utils/parseVideoUrl.js +115 -0
- package/dist/editor/utils/parseVideoUrl.js.map +1 -0
- package/dist/editor/utils/setFloatingElemPosition.d.ts +1 -0
- package/dist/editor/utils/setFloatingElemPosition.js +47 -0
- package/dist/editor/utils/setFloatingElemPosition.js.map +1 -0
- package/dist/editor/utils/setFloatingElemPositionForLinkEditor.d.ts +1 -0
- package/dist/editor/utils/setFloatingElemPositionForLinkEditor.js +29 -0
- package/dist/editor/utils/setFloatingElemPositionForLinkEditor.js.map +1 -0
- package/dist/editor/utils/url.d.ts +2 -0
- package/dist/editor/utils/url.js +25 -0
- package/dist/editor/utils/url.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/eslint.config.mjs +27 -0
- package/package.json +110 -0
- package/tsconfig.eslint.json +10 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.PrettierButton = void 0;
|
|
37
|
+
exports.canBePrettier = canBePrettier;
|
|
38
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
39
|
+
const code_1 = require("@lexical/code");
|
|
40
|
+
const lexical_1 = require("lexical");
|
|
41
|
+
const react_1 = require("react");
|
|
42
|
+
const PRETTIER_PARSER_MODULES = {
|
|
43
|
+
css: [() => Promise.resolve().then(() => __importStar(require("prettier/plugins/postcss")))],
|
|
44
|
+
html: [() => Promise.resolve().then(() => __importStar(require("prettier/plugins/html")))],
|
|
45
|
+
js: [() => Promise.resolve().then(() => __importStar(require("prettier/plugins/babel"))), () => Promise.resolve().then(() => __importStar(require("prettier/plugins/estree")))],
|
|
46
|
+
markdown: [() => Promise.resolve().then(() => __importStar(require("prettier/plugins/markdown")))],
|
|
47
|
+
typescript: [() => Promise.resolve().then(() => __importStar(require("prettier/plugins/typescript"))), () => Promise.resolve().then(() => __importStar(require("prettier/plugins/estree")))],
|
|
48
|
+
};
|
|
49
|
+
async function loadPrettierParserByLang(lang) {
|
|
50
|
+
const dynamicImports = PRETTIER_PARSER_MODULES[lang];
|
|
51
|
+
const modules = await Promise.all(dynamicImports.map(dynamicImport => dynamicImport()));
|
|
52
|
+
return modules;
|
|
53
|
+
}
|
|
54
|
+
async function loadPrettierFormat() {
|
|
55
|
+
const { format } = await Promise.resolve().then(() => __importStar(require("prettier/standalone")));
|
|
56
|
+
return format;
|
|
57
|
+
}
|
|
58
|
+
const PRETTIER_OPTIONS_BY_LANG = {
|
|
59
|
+
css: { parser: "css" },
|
|
60
|
+
html: { parser: "html" },
|
|
61
|
+
js: { parser: "babel" },
|
|
62
|
+
markdown: { parser: "markdown" },
|
|
63
|
+
typescript: { parser: "typescript" },
|
|
64
|
+
};
|
|
65
|
+
const LANG_CAN_BE_PRETTIER = Object.keys(PRETTIER_OPTIONS_BY_LANG);
|
|
66
|
+
function canBePrettier(lang) {
|
|
67
|
+
return LANG_CAN_BE_PRETTIER.includes(lang);
|
|
68
|
+
}
|
|
69
|
+
function getPrettierOptions(lang) {
|
|
70
|
+
const options = PRETTIER_OPTIONS_BY_LANG[lang];
|
|
71
|
+
if (!options) {
|
|
72
|
+
throw new Error(`CodeActionMenuPlugin: Prettier does not support this language: ${lang}`);
|
|
73
|
+
}
|
|
74
|
+
return options;
|
|
75
|
+
}
|
|
76
|
+
const PrettierButton = ({ lang, editor, getCodeDOMNode }) => {
|
|
77
|
+
const [syntaxError, setSyntaxError] = (0, react_1.useState)("");
|
|
78
|
+
const [tipsVisible, setTipsVisible] = (0, react_1.useState)(false);
|
|
79
|
+
async function handleClick() {
|
|
80
|
+
const codeDOMNode = getCodeDOMNode();
|
|
81
|
+
if (!codeDOMNode) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
let content = "";
|
|
85
|
+
editor.update(() => {
|
|
86
|
+
const codeNode = (0, lexical_1.$getNearestNodeFromDOMNode)(codeDOMNode);
|
|
87
|
+
if ((0, code_1.$isCodeNode)(codeNode)) {
|
|
88
|
+
content = codeNode.getTextContent();
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
if (content === "") {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const format = await loadPrettierFormat();
|
|
96
|
+
const options = getPrettierOptions(lang);
|
|
97
|
+
const prettierParsers = await loadPrettierParserByLang(lang);
|
|
98
|
+
options.plugins = prettierParsers.map(parser => parser.default || parser);
|
|
99
|
+
const formattedCode = await format(content, options);
|
|
100
|
+
editor.update(() => {
|
|
101
|
+
const codeNode = (0, lexical_1.$getNearestNodeFromDOMNode)(codeDOMNode);
|
|
102
|
+
if ((0, code_1.$isCodeNode)(codeNode)) {
|
|
103
|
+
const selection = codeNode.select(0);
|
|
104
|
+
selection.insertText(formattedCode);
|
|
105
|
+
setSyntaxError("");
|
|
106
|
+
setTipsVisible(false);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
setError(error);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function setError(error) {
|
|
115
|
+
if (error instanceof Error) {
|
|
116
|
+
setSyntaxError(error.message);
|
|
117
|
+
setTipsVisible(true);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
console.error("Unexpected error: ", error);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function handleMouseEnter() {
|
|
124
|
+
if (syntaxError !== "") {
|
|
125
|
+
setTipsVisible(true);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function handleMouseLeave() {
|
|
129
|
+
if (syntaxError !== "") {
|
|
130
|
+
setTipsVisible(false);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "prettier-wrapper", children: [(0, jsx_runtime_1.jsx)("button", { className: "menu-item", onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, "aria-label": "prettier", children: syntaxError ? (0, jsx_runtime_1.jsx)("i", { className: "format prettier-error" }) : (0, jsx_runtime_1.jsx)("i", { className: "format prettier" }) }), tipsVisible ? (0, jsx_runtime_1.jsx)("pre", { className: "code-error-tips", children: syntaxError }) : null] }));
|
|
134
|
+
};
|
|
135
|
+
exports.PrettierButton = PrettierButton;
|
|
136
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,sCAEC;;AA5CD,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ED,OAAO,CACL,iCAAK,SAAS,EAAC,kBAAkB,aAC/B,mCACE,SAAS,EAAC,WAAW,EACrB,OAAO,EAAE,WAAW,EACpB,YAAY,EAAE,gBAAgB,EAC9B,YAAY,EAAE,gBAAgB,gBACnB,UAAU,YAEpB,WAAW,CAAC,CAAC,CAAC,8BAAG,SAAS,EAAC,uBAAuB,GAAG,CAAC,CAAC,CAAC,8BAAG,SAAS,EAAC,iBAAiB,GAAG,GACnF,EACR,WAAW,CAAC,CAAC,CAAC,gCAAK,SAAS,EAAC,iBAAiB,YAAE,WAAW,GAAO,CAAC,CAAC,CAAC,IAAI,IACtE,CACP,CAAC;AACJ,CAAC,CAAC;AA7EW,QAAA,cAAc,kBA6EzB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./CopyButton"), exports);
|
|
18
|
+
__exportStar(require("./PrettierButton"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/editor/plugins/CodeActionMenuPlugin/components/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,mDAAiC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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 ReactPortal } from "react";
|
|
9
|
+
export { codeActionMenuPluginStyles } from "./codeActionMenuPluginStyles";
|
|
10
|
+
export declare const CodeActionMenuPlugin: ({ anchorElem, }: {
|
|
11
|
+
anchorElem?: HTMLElement;
|
|
12
|
+
}) => ReactPortal | null;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CodeActionMenuPlugin = exports.codeActionMenuPluginStyles = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
/**
|
|
6
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
const react_1 = require("react");
|
|
13
|
+
const code_1 = require("@lexical/code");
|
|
14
|
+
const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
|
|
15
|
+
const lexical_1 = require("lexical");
|
|
16
|
+
const react_dom_1 = require("react-dom");
|
|
17
|
+
const components_1 = require("./components");
|
|
18
|
+
const utils_1 = require("./utils");
|
|
19
|
+
var codeActionMenuPluginStyles_1 = require("./codeActionMenuPluginStyles");
|
|
20
|
+
Object.defineProperty(exports, "codeActionMenuPluginStyles", { enumerable: true, get: function () { return codeActionMenuPluginStyles_1.codeActionMenuPluginStyles; } });
|
|
21
|
+
const CODE_PADDING = 8;
|
|
22
|
+
function CodeActionMenuContainer({ anchorElem }) {
|
|
23
|
+
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
24
|
+
const [lang, setLang] = (0, react_1.useState)("");
|
|
25
|
+
const [isShown, setShown] = (0, react_1.useState)(false);
|
|
26
|
+
const [shouldListenMouseMove, setShouldListenMouseMove] = (0, react_1.useState)(false);
|
|
27
|
+
const [position, setPosition] = (0, react_1.useState)({
|
|
28
|
+
right: "0",
|
|
29
|
+
top: "0",
|
|
30
|
+
});
|
|
31
|
+
const codeSetRef = (0, react_1.useRef)(new Set());
|
|
32
|
+
const codeDOMNodeRef = (0, react_1.useRef)(null);
|
|
33
|
+
function getCodeDOMNode() {
|
|
34
|
+
return codeDOMNodeRef.current;
|
|
35
|
+
}
|
|
36
|
+
const debouncedOnMouseMove = (0, utils_1.useDebounce)((event) => {
|
|
37
|
+
const { codeDOMNode, isOutside } = getMouseInfo(event);
|
|
38
|
+
if (isOutside) {
|
|
39
|
+
setShown(false);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (!codeDOMNode) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
codeDOMNodeRef.current = codeDOMNode;
|
|
46
|
+
let codeNode = null;
|
|
47
|
+
let _lang = "";
|
|
48
|
+
editor.update(() => {
|
|
49
|
+
const maybeCodeNode = (0, lexical_1.$getNearestNodeFromDOMNode)(codeDOMNode);
|
|
50
|
+
if ((0, code_1.$isCodeNode)(maybeCodeNode)) {
|
|
51
|
+
codeNode = maybeCodeNode;
|
|
52
|
+
_lang = codeNode.getLanguage() || "";
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
if (codeNode) {
|
|
56
|
+
const { y: editorElemY, right: editorElemRight } = anchorElem.getBoundingClientRect();
|
|
57
|
+
const { y, right } = codeDOMNode.getBoundingClientRect();
|
|
58
|
+
setLang(_lang);
|
|
59
|
+
setShown(true);
|
|
60
|
+
setPosition({
|
|
61
|
+
right: `${editorElemRight - right + CODE_PADDING}px`,
|
|
62
|
+
top: `${y - editorElemY}px`,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}, 50, 1000);
|
|
66
|
+
(0, react_1.useEffect)(() => {
|
|
67
|
+
if (!shouldListenMouseMove) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
document.addEventListener("mousemove", debouncedOnMouseMove);
|
|
71
|
+
return () => {
|
|
72
|
+
setShown(false);
|
|
73
|
+
debouncedOnMouseMove.cancel();
|
|
74
|
+
document.removeEventListener("mousemove", debouncedOnMouseMove);
|
|
75
|
+
};
|
|
76
|
+
}, [shouldListenMouseMove, debouncedOnMouseMove]);
|
|
77
|
+
(0, react_1.useEffect)(() => {
|
|
78
|
+
return editor.registerMutationListener(code_1.CodeNode, mutations => {
|
|
79
|
+
editor.getEditorState().read(() => {
|
|
80
|
+
for (const [key, type] of mutations) {
|
|
81
|
+
switch (type) {
|
|
82
|
+
case "created":
|
|
83
|
+
codeSetRef.current.add(key);
|
|
84
|
+
break;
|
|
85
|
+
case "destroyed":
|
|
86
|
+
codeSetRef.current.delete(key);
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
setShouldListenMouseMove(codeSetRef.current.size > 0);
|
|
94
|
+
}, { skipInitialization: false });
|
|
95
|
+
}, [editor]);
|
|
96
|
+
const normalizedLang = (0, code_1.normalizeCodeLang)(lang);
|
|
97
|
+
const codeFriendlyName = (0, code_1.getLanguageFriendlyName)(lang);
|
|
98
|
+
if (!isShown) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "code-action-menu-container", style: Object.assign({}, position), children: [(0, jsx_runtime_1.jsx)("div", { className: "code-highlight-language", children: codeFriendlyName }), (0, jsx_runtime_1.jsx)(components_1.CopyButton, { editor: editor, getCodeDOMNode: getCodeDOMNode }), (0, components_1.canBePrettier)(normalizedLang) ? ((0, jsx_runtime_1.jsx)(components_1.PrettierButton, { editor: editor, getCodeDOMNode: getCodeDOMNode, lang: normalizedLang })) : null] }));
|
|
102
|
+
}
|
|
103
|
+
function getMouseInfo(event) {
|
|
104
|
+
const target = event.target;
|
|
105
|
+
if ((0, lexical_1.isHTMLElement)(target)) {
|
|
106
|
+
const codeDOMNode = target.closest("code.PlaygroundEditorTheme__code");
|
|
107
|
+
const isOutside = !(codeDOMNode || target.closest("div.code-action-menu-container"));
|
|
108
|
+
return { codeDOMNode, isOutside };
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
return { codeDOMNode: null, isOutside: true };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const CodeActionMenuPlugin = ({ anchorElem = document.body, }) => {
|
|
115
|
+
return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(CodeActionMenuContainer, { anchorElem: anchorElem }), anchorElem);
|
|
116
|
+
};
|
|
117
|
+
exports.CodeActionMenuPlugin = CodeActionMenuPlugin;
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/editor/plugins/CodeActionMenuPlugin/index.tsx"],"names":[],"mappings":";;;;AAAA;;;;;;GAMG;AAEH,iCAAsE;AACtE,wCAAkG;AAClG,kFAAkF;AAClF,qCAAoE;AACpE,yCAAyC;AAEzC,6CAAyE;AACzE,mCAAsC;AAEtC,2EAA0E;AAAjE,wIAAA,0BAA0B,OAAA;AACnC,MAAM,YAAY,GAAG,CAAC,CAAC;AAOvB,SAAS,uBAAuB,CAAC,EAAE,UAAU,EAA+B;IAC1E,MAAM,CAAC,MAAM,CAAC,GAAG,IAAA,kDAAyB,GAAE,CAAC;IAE7C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,E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AC,WAAW,IAAI,MAAM,CAAC,OAAO,CAAc,gCAAgC,CAAC,CAAC,CAAC;QAElG,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;IACpC,CAAC;SAAM,CAAC;QACN,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAChD,CAAC;AACH,CAAC;AAEM,MAAM,oBAAoB,GAAG,CAAC,EACnC,UAAU,GAAG,QAAQ,CAAC,IAAI,GAG3B,EAAsB,EAAE;IACvB,OAAO,IAAA,wBAAY,EAAC,uBAAC,uBAAuB,IAAC,UAAU,EAAE,UAAU,GAAI,EAAE,UAAU,CAAC,CAAC;AACvF,CAAC,CAAC;AANW,QAAA,oBAAoB,wBAM/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useDebounce<T extends (...args: never[]) => void>(fn: T, ms: number, maxWait?: number): import("lodash").DebouncedFunc<(...args: Parameters<T>) => void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDebounce = useDebounce;
|
|
4
|
+
const lodash_es_1 = require("lodash-es");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
function useDebounce(fn, ms, maxWait) {
|
|
7
|
+
const funcRef = (0, react_1.useRef)(null);
|
|
8
|
+
funcRef.current = fn;
|
|
9
|
+
return (0, react_1.useMemo)(() => (0, lodash_es_1.debounce)((...args) => {
|
|
10
|
+
if (funcRef.current) {
|
|
11
|
+
funcRef.current(...args);
|
|
12
|
+
}
|
|
13
|
+
}, ms, { maxWait }), [ms, maxWait]);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/editor/plugins/CodeActionMenuPlugin/utils.ts"],"names":[],"mappings":";;AAGA,kCAiBC;AApBD,yCAAqC;AACrC,iCAAwC;AAExC,SAAgB,WAAW,CAAuC,EAAK,EAAE,EAAU,EAAE,OAAgB;IACnG,MAAM,OAAO,GAAG,IAAA,cAAM,EAAW,IAAI,CAAC,CAAC;IACvC,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;IAErB,OAAO,IAAA,eAAO,EACZ,GAAG,EAAE,CACH,IAAA,oBAAQ,EACN,CAAC,GAAG,IAAmB,EAAE,EAAE;QACzB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,EACD,EAAE,EACF,EAAE,OAAO,EAAE,CACZ,EACH,CAAC,EAAE,EAAE,OAAO,CAAC,CACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CodeHighlightPlugin = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const code_1 = require("@lexical/code");
|
|
6
|
+
const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
|
|
7
|
+
const CodeHighlightPlugin = () => {
|
|
8
|
+
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
9
|
+
(0, react_1.useEffect)(() => {
|
|
10
|
+
return (0, code_1.registerCodeHighlighting)(editor);
|
|
11
|
+
}, [editor]);
|
|
12
|
+
return null;
|
|
13
|
+
};
|
|
14
|
+
exports.CodeHighlightPlugin = CodeHighlightPlugin;
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/editor/plugins/CodeHighlightPlugin/index.ts"],"names":[],"mappings":";;;AAAA,iCAA4C;AAC5C,wCAAyD;AACzD,kFAAkF;AAE3E,MAAM,mBAAmB,GAAG,GAAuB,EAAE;IAC1D,MAAM,CAAC,MAAM,CAAC,GAAG,IAAA,kDAAyB,GAAE,CAAC;IAE7C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,OAAO,IAAA,+BAAwB,EAAC,MAAM,CAAC,CAAC;IAC1C,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AARW,QAAA,mBAAmB,uBAQ9B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
export declare const ComponentPickerMenuPlugin: () => JSX.Element;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ComponentPickerMenuPlugin = void 0;
|
|
37
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
+
/**
|
|
39
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
40
|
+
*
|
|
41
|
+
* This source code is licensed under the MIT license found in the
|
|
42
|
+
* LICENSE file in the root directory of this source tree.
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
const react_1 = require("react");
|
|
46
|
+
const code_1 = require("@lexical/code");
|
|
47
|
+
const list_1 = require("@lexical/list");
|
|
48
|
+
const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
|
|
49
|
+
const LexicalHorizontalRuleNode_1 = require("@lexical/react/LexicalHorizontalRuleNode");
|
|
50
|
+
const LexicalTypeaheadMenuPlugin_1 = require("@lexical/react/LexicalTypeaheadMenuPlugin");
|
|
51
|
+
const rich_text_1 = require("@lexical/rich-text");
|
|
52
|
+
const selection_1 = require("@lexical/selection");
|
|
53
|
+
const table_1 = require("@lexical/table");
|
|
54
|
+
const lexical_1 = require("lexical");
|
|
55
|
+
const ReactDOM = __importStar(require("react-dom"));
|
|
56
|
+
const hooks_1 = require("../../hooks");
|
|
57
|
+
const ImagesPlugin_1 = require("../ImagesPlugin");
|
|
58
|
+
const TablePlugin_1 = require("../TablePlugin");
|
|
59
|
+
const icons_1 = require("../../images/icons");
|
|
60
|
+
class ComponentPickerOption extends LexicalTypeaheadMenuPlugin_1.MenuOption {
|
|
61
|
+
constructor(title, options) {
|
|
62
|
+
super(title);
|
|
63
|
+
this.title = title;
|
|
64
|
+
this.keywords = options.keywords || [];
|
|
65
|
+
this.icon = options.icon;
|
|
66
|
+
this.keyboardShortcut = options.keyboardShortcut;
|
|
67
|
+
this.onSelect = options.onSelect.bind(this);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function ComponentPickerMenuItem({ index, isSelected, onClick, onMouseEnter, option, }) {
|
|
71
|
+
let className = "item";
|
|
72
|
+
if (isSelected) {
|
|
73
|
+
className += " selected";
|
|
74
|
+
}
|
|
75
|
+
return ((0, jsx_runtime_1.jsxs)("li", { tabIndex: -1, className: className, ref: option.setRefElement, role: "option", "aria-selected": isSelected, id: "typeahead-item-" + index, onMouseEnter: onMouseEnter, onClick: onClick, children: [option.icon, (0, jsx_runtime_1.jsx)("span", { className: "text", children: option.title })] }, option.key));
|
|
76
|
+
}
|
|
77
|
+
function getDynamicOptions(editor, queryString) {
|
|
78
|
+
const options = [];
|
|
79
|
+
if (queryString == null) {
|
|
80
|
+
return options;
|
|
81
|
+
}
|
|
82
|
+
const tableMatch = /^([1-9]\d?)(?:x([1-9]\d?)?)?$/.exec(queryString);
|
|
83
|
+
if (tableMatch !== null) {
|
|
84
|
+
const rows = tableMatch[1];
|
|
85
|
+
const colOptions = tableMatch[2] ? [tableMatch[2]] : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(String);
|
|
86
|
+
options.push(...colOptions.map(columns => new ComponentPickerOption(`${rows}x${columns} Table`, {
|
|
87
|
+
icon: (0, jsx_runtime_1.jsx)(icons_1.TableIcon, {}),
|
|
88
|
+
keywords: ["table"],
|
|
89
|
+
onSelect: () => editor.dispatchCommand(table_1.INSERT_TABLE_COMMAND, { columns, rows }),
|
|
90
|
+
})));
|
|
91
|
+
}
|
|
92
|
+
return options;
|
|
93
|
+
}
|
|
94
|
+
function getBaseOptions(editor, showModal) {
|
|
95
|
+
return [
|
|
96
|
+
new ComponentPickerOption("Paragraph", {
|
|
97
|
+
icon: (0, jsx_runtime_1.jsx)(icons_1.TextParagraphIcon, {}),
|
|
98
|
+
keywords: ["normal", "paragraph", "p", "text"],
|
|
99
|
+
onSelect: () => editor.update(() => {
|
|
100
|
+
const selection = (0, lexical_1.$getSelection)();
|
|
101
|
+
if ((0, lexical_1.$isRangeSelection)(selection)) {
|
|
102
|
+
(0, selection_1.$setBlocksType)(selection, () => (0, lexical_1.$createParagraphNode)());
|
|
103
|
+
}
|
|
104
|
+
}),
|
|
105
|
+
}),
|
|
106
|
+
...[1, 2, 3, 4, 5, 6].map(n => new ComponentPickerOption(`Heading ${n}`, {
|
|
107
|
+
icon: (0, jsx_runtime_1.jsx)("i", { className: `icon h${n}` }),
|
|
108
|
+
keywords: ["heading", "header", `h${n}`],
|
|
109
|
+
onSelect: () => editor.update(() => {
|
|
110
|
+
const selection = (0, lexical_1.$getSelection)();
|
|
111
|
+
if ((0, lexical_1.$isRangeSelection)(selection)) {
|
|
112
|
+
(0, selection_1.$setBlocksType)(selection, () => (0, rich_text_1.$createHeadingNode)(`h${n}`));
|
|
113
|
+
}
|
|
114
|
+
}),
|
|
115
|
+
})),
|
|
116
|
+
new ComponentPickerOption("Table", {
|
|
117
|
+
icon: (0, jsx_runtime_1.jsx)(icons_1.TableIcon, {}),
|
|
118
|
+
keywords: ["table", "grid", "spreadsheet", "rows", "columns"],
|
|
119
|
+
onSelect: () => showModal("Insert Table", onClose => (0, jsx_runtime_1.jsx)(TablePlugin_1.InsertTableDialog, { activeEditor: editor, onClose: onClose })),
|
|
120
|
+
}),
|
|
121
|
+
new ComponentPickerOption("Numbered List", {
|
|
122
|
+
icon: (0, jsx_runtime_1.jsx)(icons_1.ListOlIcon, {}),
|
|
123
|
+
keywords: ["numbered list", "ordered list", "ol"],
|
|
124
|
+
onSelect: () => editor.dispatchCommand(list_1.INSERT_ORDERED_LIST_COMMAND, undefined),
|
|
125
|
+
}),
|
|
126
|
+
new ComponentPickerOption("Bulleted List", {
|
|
127
|
+
icon: (0, jsx_runtime_1.jsx)(icons_1.ListUlIcon, {}),
|
|
128
|
+
keywords: ["bulleted list", "unordered list", "ul"],
|
|
129
|
+
onSelect: () => editor.dispatchCommand(list_1.INSERT_UNORDERED_LIST_COMMAND, undefined),
|
|
130
|
+
}),
|
|
131
|
+
new ComponentPickerOption("Check List", {
|
|
132
|
+
icon: (0, jsx_runtime_1.jsx)(icons_1.SquareCheckIcon, {}),
|
|
133
|
+
keywords: ["check list", "todo list"],
|
|
134
|
+
onSelect: () => editor.dispatchCommand(list_1.INSERT_CHECK_LIST_COMMAND, undefined),
|
|
135
|
+
}),
|
|
136
|
+
new ComponentPickerOption("Quote", {
|
|
137
|
+
icon: (0, jsx_runtime_1.jsx)(icons_1.ChatSquareQuoteIcon, {}),
|
|
138
|
+
keywords: ["block quote"],
|
|
139
|
+
onSelect: () => editor.update(() => {
|
|
140
|
+
const selection = (0, lexical_1.$getSelection)();
|
|
141
|
+
if ((0, lexical_1.$isRangeSelection)(selection)) {
|
|
142
|
+
(0, selection_1.$setBlocksType)(selection, () => (0, rich_text_1.$createQuoteNode)());
|
|
143
|
+
}
|
|
144
|
+
}),
|
|
145
|
+
}),
|
|
146
|
+
new ComponentPickerOption("Code", {
|
|
147
|
+
icon: (0, jsx_runtime_1.jsx)(icons_1.CodeIcon, {}),
|
|
148
|
+
keywords: ["javascript", "python", "js", "codeblock"],
|
|
149
|
+
onSelect: () => editor.update(() => {
|
|
150
|
+
const selection = (0, lexical_1.$getSelection)();
|
|
151
|
+
if ((0, lexical_1.$isRangeSelection)(selection)) {
|
|
152
|
+
if (selection.isCollapsed()) {
|
|
153
|
+
(0, selection_1.$setBlocksType)(selection, () => (0, code_1.$createCodeNode)());
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
// Will this ever happen?
|
|
157
|
+
const textContent = selection.getTextContent();
|
|
158
|
+
const codeNode = (0, code_1.$createCodeNode)();
|
|
159
|
+
selection.insertNodes([codeNode]);
|
|
160
|
+
selection.insertRawText(textContent);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}),
|
|
164
|
+
}),
|
|
165
|
+
new ComponentPickerOption("Divider", {
|
|
166
|
+
icon: (0, jsx_runtime_1.jsx)(icons_1.HorizontalRuleIcon, {}),
|
|
167
|
+
keywords: ["horizontal rule", "divider", "hr"],
|
|
168
|
+
onSelect: () => editor.dispatchCommand(LexicalHorizontalRuleNode_1.INSERT_HORIZONTAL_RULE_COMMAND, undefined),
|
|
169
|
+
}),
|
|
170
|
+
new ComponentPickerOption("Image", {
|
|
171
|
+
icon: (0, jsx_runtime_1.jsx)(icons_1.FileImageIcon, {}),
|
|
172
|
+
keywords: ["image", "photo", "picture", "file"],
|
|
173
|
+
onSelect: () => showModal("Insert Image", onClose => (0, jsx_runtime_1.jsx)(ImagesPlugin_1.InsertImageDialog, { activeEditor: editor, onClose: onClose })),
|
|
174
|
+
}),
|
|
175
|
+
...["left", "center", "right", "justify"].map(alignment => new ComponentPickerOption(`Align ${alignment}`, {
|
|
176
|
+
icon: (0, jsx_runtime_1.jsx)("i", { className: `icon ${alignment}-align` }),
|
|
177
|
+
keywords: ["align", "justify", alignment],
|
|
178
|
+
onSelect: () => editor.dispatchCommand(lexical_1.FORMAT_ELEMENT_COMMAND, alignment),
|
|
179
|
+
})),
|
|
180
|
+
];
|
|
181
|
+
}
|
|
182
|
+
const ComponentPickerMenuPlugin = () => {
|
|
183
|
+
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
184
|
+
const [modal, showModal] = (0, hooks_1.useModal)();
|
|
185
|
+
const [queryString, setQueryString] = (0, react_1.useState)(null);
|
|
186
|
+
const checkForTriggerMatch = (0, LexicalTypeaheadMenuPlugin_1.useBasicTypeaheadTriggerMatch)("/", {
|
|
187
|
+
minLength: 0,
|
|
188
|
+
});
|
|
189
|
+
const options = (0, react_1.useMemo)(() => {
|
|
190
|
+
const baseOptions = getBaseOptions(editor, showModal);
|
|
191
|
+
if (!queryString) {
|
|
192
|
+
return baseOptions;
|
|
193
|
+
}
|
|
194
|
+
const regex = new RegExp(queryString, "i");
|
|
195
|
+
return [
|
|
196
|
+
...getDynamicOptions(editor, queryString),
|
|
197
|
+
...baseOptions.filter(option => regex.test(option.title) || option.keywords.some(keyword => regex.test(keyword))),
|
|
198
|
+
];
|
|
199
|
+
}, [editor, queryString, showModal]);
|
|
200
|
+
const onSelectOption = (0, react_1.useCallback)((selectedOption, nodeToRemove, closeMenu, matchingString) => {
|
|
201
|
+
editor.update(() => {
|
|
202
|
+
nodeToRemove === null || nodeToRemove === void 0 ? void 0 : nodeToRemove.remove();
|
|
203
|
+
selectedOption.onSelect(matchingString);
|
|
204
|
+
closeMenu();
|
|
205
|
+
});
|
|
206
|
+
}, [editor]);
|
|
207
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [modal, (0, jsx_runtime_1.jsx)(LexicalTypeaheadMenuPlugin_1.LexicalTypeaheadMenuPlugin, { onQueryChange: setQueryString, onSelectOption: onSelectOption, triggerFn: checkForTriggerMatch, options: options, menuRenderFn: (anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => anchorElementRef.current && options.length
|
|
208
|
+
? ReactDOM.createPortal((0, jsx_runtime_1.jsx)("div", { className: "typeahead-popover component-picker-menu", children: (0, jsx_runtime_1.jsx)("ul", { children: options.map((option, i) => ((0, jsx_runtime_1.jsx)(ComponentPickerMenuItem, { index: i, isSelected: selectedIndex === i, onClick: () => {
|
|
209
|
+
setHighlightedIndex(i);
|
|
210
|
+
selectOptionAndCleanUp(option);
|
|
211
|
+
}, onMouseEnter: () => {
|
|
212
|
+
setHighlightedIndex(i);
|
|
213
|
+
}, option: option }, option.key))) }) }), anchorElementRef.current)
|
|
214
|
+
: null })] }));
|
|
215
|
+
};
|
|
216
|
+
exports.ComponentPickerMenuPlugin = ComponentPickerMenuPlugin;
|
|
217
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/editor/plugins/ComponentPickerPlugin/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AAEH,iCAAiE;AACjE,wCAAgD;AAChD,wCAAsH;AACtH,kFAAkF;AAClF,wFAA0F;AAC1F,0FAImD;AACnD,kDAA0E;AAC1E,kDAAoD;AACpD,0CAAsD;AACtD,qCAOiB;AACjB,oDAAsC;AAEtC,uCAAuC;AACvC,kDAAoD;AACpD,gDAAmD;AACnD,8CAU4B;AAE5B,MAAM,qBAAsB,SAAQ,uCAAU;IAY5C,YACE,KAAa,EACb,OAKC;QAED,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACjD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;CACF;AAED,SAAS,uBAAuB,CAAC,EAC/B,KAAK,EACL,UAAU,EACV,OAAO,EACP,YAAY,EACZ,MAAM,GAOP;IACC,IAAI,SAAS,GAAG,MAAM,CAAC;IACvB,IAAI,UAAU,EAAE,CAAC;QACf,SAAS,IAAI,WAAW,CAAC;IAC3B,CAAC;IACD,OAAO,CACL,gCAEE,QAAQ,EAAE,CAAC,CAAC,EACZ,SAAS,EAAE,SAAS,EACpB,GAAG,E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CACnB,gCAAK,SAAS,EAAC,yCAAyC,YACtD,yCACG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAS,EAAE,EAAE,CAAC,CAClC,uBAAC,uBAAuB,IACtB,KAAK,EAAE,CAAC,EACR,UAAU,EAAE,aAAa,KAAK,CAAC,EAC/B,OAAO,EAAE,GAAG,EAAE;oCACZ,mBAAmB,CAAC,CAAC,CAAC,CAAC;oCACvB,sBAAsB,CAAC,MAAM,CAAC,CAAC;gCACjC,CAAC,EACD,YAAY,EAAE,GAAG,EAAE;oCACjB,mBAAmB,CAAC,CAAC,CAAC,CAAC;gCACzB,CAAC,EAED,MAAM,EAAE,MAAM,IADT,MAAM,CAAC,GAAG,CAEf,CACH,CAAC,GACC,GACD,EACN,gBAAgB,CAAC,OAAO,CACzB;oBACH,CAAC,CAAC,IAAI,GAEV,IACD,CACJ,CAAC;AACJ,CAAC,CAAC;AA7EW,QAAA,yBAAyB,6BA6EpC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { JSX } from "react";
|
|
9
|
+
import { MenuOption } from "@lexical/react/LexicalContextMenuPlugin";
|
|
10
|
+
import { type LexicalNode } from "lexical";
|
|
11
|
+
export declare class ContextMenuOption extends MenuOption {
|
|
12
|
+
title: string;
|
|
13
|
+
onSelect: (targetNode: LexicalNode | null) => void;
|
|
14
|
+
constructor(title: string, options: {
|
|
15
|
+
onSelect: (targetNode: LexicalNode | null) => void;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export declare const ContextMenuPlugin: () => JSX.Element;
|