@blocklet/editor-lite 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +33 -0
- package/lib/blocklet-editor-viewer.d.ts +4 -0
- package/lib/blocklet-editor-viewer.js +12 -0
- package/lib/blocklet-editor.d.ts +2 -0
- package/lib/blocklet-editor.js +12 -0
- package/lib/components/Loading.d.ts +4 -0
- package/lib/components/Loading.js +13 -0
- package/lib/components/SelectionPopper.d.ts +14 -0
- package/lib/components/SelectionPopper.js +73 -0
- package/lib/components/animateText.d.ts +3 -0
- package/lib/components/animateText.js +29 -0
- package/lib/components/createPortal.d.ts +2 -0
- package/lib/components/createPortal.js +16 -0
- package/lib/config.d.ts +37 -0
- package/lib/config.js +12 -0
- package/lib/ext/AIPlugin/AIIcon.d.ts +5 -0
- package/lib/ext/AIPlugin/AIIcon.js +7 -0
- package/lib/ext/AIPlugin/Arrow.d.ts +1 -0
- package/lib/ext/AIPlugin/Arrow.js +5 -0
- package/lib/ext/AIPlugin/TextGeneration.d.ts +6 -0
- package/lib/ext/AIPlugin/TextGeneration.js +131 -0
- package/lib/ext/AIPlugin/Writing.d.ts +1 -0
- package/lib/ext/AIPlugin/Writing.js +7 -0
- package/lib/ext/AIPlugin/index.d.ts +9 -0
- package/lib/ext/AIPlugin/index.js +180 -0
- package/lib/ext/AIPlugin/utils.d.ts +6 -0
- package/lib/ext/AIPlugin/utils.js +44 -0
- package/lib/ext/AITranslationPlugin/index.d.ts +9 -0
- package/lib/ext/AITranslationPlugin/index.js +124 -0
- package/lib/ext/AITranslationPlugin/selection.d.ts +3 -0
- package/lib/ext/AITranslationPlugin/selection.js +45 -0
- package/lib/ext/AITranslationPlugin/translation.d.ts +3 -0
- package/lib/ext/AITranslationPlugin/translation.js +67 -0
- package/lib/ext/AITranslationPlugin/types.d.ts +49 -0
- package/lib/ext/AITranslationPlugin/types.js +1 -0
- package/lib/ext/AITranslationPlugin/utils.d.ts +46 -0
- package/lib/ext/AITranslationPlugin/utils.js +343 -0
- package/lib/ext/Aide/Aide.d.ts +4 -0
- package/lib/ext/Aide/Aide.js +30 -0
- package/lib/ext/Aide/Delayed.d.ts +7 -0
- package/lib/ext/Aide/Delayed.js +12 -0
- package/lib/ext/Aide/Input.d.ts +6 -0
- package/lib/ext/Aide/Input.js +49 -0
- package/lib/ext/Aide/Menu.d.ts +4 -0
- package/lib/ext/Aide/Menu.js +29 -0
- package/lib/ext/Aide/Output.d.ts +4 -0
- package/lib/ext/Aide/Output.js +14 -0
- package/lib/ext/Aide/Templates.d.ts +4 -0
- package/lib/ext/Aide/Templates.js +34 -0
- package/lib/ext/Aide/builtin-templates.d.ts +3 -0
- package/lib/ext/Aide/builtin-templates.js +48 -0
- package/lib/ext/Aide/context.d.ts +47 -0
- package/lib/ext/Aide/context.js +114 -0
- package/lib/ext/Aide/external-templates/Breadcrumb.d.ts +10 -0
- package/lib/ext/Aide/external-templates/Breadcrumb.js +11 -0
- package/lib/ext/Aide/external-templates/Output.d.ts +8 -0
- package/lib/ext/Aide/external-templates/Output.js +22 -0
- package/lib/ext/Aide/external-templates/Search.d.ts +6 -0
- package/lib/ext/Aide/external-templates/Search.js +14 -0
- package/lib/ext/Aide/external-templates/Tags.d.ts +4 -0
- package/lib/ext/Aide/external-templates/Tags.js +44 -0
- package/lib/ext/Aide/external-templates/Template.d.ts +7 -0
- package/lib/ext/Aide/external-templates/Template.js +110 -0
- package/lib/ext/Aide/external-templates/Templates.d.ts +6 -0
- package/lib/ext/Aide/external-templates/Templates.js +61 -0
- package/lib/ext/Aide/external-templates/index.d.ts +4 -0
- package/lib/ext/Aide/external-templates/index.js +83 -0
- package/lib/ext/Aide/external-templates/parameter-field.d.ts +6 -0
- package/lib/ext/Aide/external-templates/parameter-field.js +92 -0
- package/lib/ext/Aide/hooks.d.ts +7 -0
- package/lib/ext/Aide/hooks.js +14 -0
- package/lib/ext/Aide/index.d.ts +2 -0
- package/lib/ext/Aide/index.js +2 -0
- package/lib/ext/Aide/types.d.ts +84 -0
- package/lib/ext/Aide/types.js +25 -0
- package/lib/ext/Aide/withAiAvailable.d.ts +5 -0
- package/lib/ext/Aide/withAiAvailable.js +11 -0
- package/lib/ext/Alert/AlertComponent.d.ts +10 -0
- package/lib/ext/Alert/AlertComponent.js +38 -0
- package/lib/ext/Alert/AlertNode.d.ts +28 -0
- package/lib/ext/Alert/AlertNode.js +105 -0
- package/lib/ext/Alert/AlertPlugin.d.ts +11 -0
- package/lib/ext/Alert/AlertPlugin.js +41 -0
- package/lib/ext/BilibiliPlugin/BilibiliNode.d.ts +31 -0
- package/lib/ext/BilibiliPlugin/BilibiliNode.js +95 -0
- package/lib/ext/BilibiliPlugin/BilibiliVideo.d.ts +6 -0
- package/lib/ext/BilibiliPlugin/BilibiliVideo.js +24 -0
- package/lib/ext/BilibiliPlugin/config.d.ts +2 -0
- package/lib/ext/BilibiliPlugin/config.js +40 -0
- package/lib/ext/BilibiliPlugin/index.d.ts +5 -0
- package/lib/ext/BilibiliPlugin/index.js +20 -0
- package/lib/ext/BlockletEmbedPlugin/BlockletEmbed.d.ts +7 -0
- package/lib/ext/BlockletEmbedPlugin/BlockletEmbed.js +51 -0
- package/lib/ext/BlockletEmbedPlugin/BlockletEmbedNode.d.ts +30 -0
- package/lib/ext/BlockletEmbedPlugin/BlockletEmbedNode.js +96 -0
- package/lib/ext/BlockletEmbedPlugin/index.d.ts +12 -0
- package/lib/ext/BlockletEmbedPlugin/index.js +76 -0
- package/lib/ext/BlurTextPlugin.d.ts +1 -0
- package/lib/ext/BlurTextPlugin.js +40 -0
- package/lib/ext/BookmarkPlugin/Bookmark.d.ts +7 -0
- package/lib/ext/BookmarkPlugin/Bookmark.js +175 -0
- package/lib/ext/BookmarkPlugin/BookmarkNode.d.ts +35 -0
- package/lib/ext/BookmarkPlugin/BookmarkNode.js +110 -0
- package/lib/ext/BookmarkPlugin/index.d.ts +11 -0
- package/lib/ext/BookmarkPlugin/index.js +45 -0
- package/lib/ext/BusyPlugin.d.ts +9 -0
- package/lib/ext/BusyPlugin.js +17 -0
- package/lib/ext/CharacterCountPlugin/index.d.ts +10 -0
- package/lib/ext/CharacterCountPlugin/index.js +39 -0
- package/lib/ext/CharacterCountPlugin/useCharacterCount.d.ts +11 -0
- package/lib/ext/CharacterCountPlugin/useCharacterCount.js +49 -0
- package/lib/ext/CharacterLimitPlugin/index.d.ts +9 -0
- package/lib/ext/CharacterLimitPlugin/index.js +49 -0
- package/lib/ext/CheckboxPlugin.d.ts +3 -0
- package/lib/ext/CheckboxPlugin.js +75 -0
- package/lib/ext/CodeCopyPlugin/CodeCopyPlugin.d.ts +2 -0
- package/lib/ext/CodeCopyPlugin/CodeCopyPlugin.js +90 -0
- package/lib/ext/CodeCopyPlugin/copy.svg +1 -0
- package/lib/ext/CodeCopyPlugin/index.d.ts +1 -0
- package/lib/ext/CodeCopyPlugin/index.js +1 -0
- package/lib/ext/CodeCopyPlugin/style.css +12 -0
- package/lib/ext/ContentLocale.d.ts +7 -0
- package/lib/ext/ContentLocale.js +15 -0
- package/lib/ext/CustomOnChangePlugin/index.d.ts +5 -0
- package/lib/ext/CustomOnChangePlugin/index.js +17 -0
- package/lib/ext/CustomOnChangePlugin/styles.css +14 -0
- package/lib/ext/CustomOnChangePlugin/utils.d.ts +30 -0
- package/lib/ext/CustomOnChangePlugin/utils.js +148 -0
- package/lib/ext/EditorHolderPlugin/EditorHolderContext.d.ts +13 -0
- package/lib/ext/EditorHolderPlugin/EditorHolderContext.js +15 -0
- package/lib/ext/EditorHolderPlugin/EditorHolderPlugin.d.ts +1 -0
- package/lib/ext/EditorHolderPlugin/EditorHolderPlugin.js +11 -0
- package/lib/ext/EditorHolderPlugin/index.d.ts +2 -0
- package/lib/ext/EditorHolderPlugin/index.js +2 -0
- package/lib/ext/EditorReadyPlugin.d.ts +3 -0
- package/lib/ext/EditorReadyPlugin.js +15 -0
- package/lib/ext/FilePlugin/FileNode.d.ts +44 -0
- package/lib/ext/FilePlugin/FileNode.js +195 -0
- package/lib/ext/FilePlugin/FilePlugin.d.ts +7 -0
- package/lib/ext/FilePlugin/FilePlugin.js +27 -0
- package/lib/ext/FilePlugin/index.d.ts +2 -0
- package/lib/ext/FilePlugin/index.js +2 -0
- package/lib/ext/HeadingsIdPlugin.d.ts +1 -0
- package/lib/ext/HeadingsIdPlugin.js +67 -0
- package/lib/ext/ImagePathFixerPlugin.d.ts +1 -0
- package/lib/ext/ImagePathFixerPlugin.js +31 -0
- package/lib/ext/InlineTranslationPlugin/EditorTranslator.d.ts +42 -0
- package/lib/ext/InlineTranslationPlugin/EditorTranslator.js +199 -0
- package/lib/ext/InlineTranslationPlugin/InlineTranslationPlugin.d.ts +12 -0
- package/lib/ext/InlineTranslationPlugin/InlineTranslationPlugin.js +232 -0
- package/lib/ext/InlineTranslationPlugin/TranslationNode.d.ts +23 -0
- package/lib/ext/InlineTranslationPlugin/TranslationNode.js +49 -0
- package/lib/ext/InlineTranslationPlugin/index.d.ts +4 -0
- package/lib/ext/InlineTranslationPlugin/index.js +4 -0
- package/lib/ext/InlineTranslationPlugin/store.d.ts +50 -0
- package/lib/ext/InlineTranslationPlugin/store.js +94 -0
- package/lib/ext/InlineTranslationPlugin/types.d.ts +1 -0
- package/lib/ext/InlineTranslationPlugin/types.js +1 -0
- package/lib/ext/LexicalEditorRefPlugin.d.ts +14 -0
- package/lib/ext/LexicalEditorRefPlugin.js +26 -0
- package/lib/ext/OnContentChangePlugin.d.ts +14 -0
- package/lib/ext/OnContentChangePlugin.js +35 -0
- package/lib/ext/PasteSlackImagePlugin/index.d.ts +2 -0
- package/lib/ext/PasteSlackImagePlugin/index.js +22 -0
- package/lib/ext/PostLinkEmbedPlugin/PostLinkNode.d.ts +32 -0
- package/lib/ext/PostLinkEmbedPlugin/PostLinkNode.js +140 -0
- package/lib/ext/PostLinkEmbedPlugin/fixInvalidPostLinkNodes.d.ts +1 -0
- package/lib/ext/PostLinkEmbedPlugin/fixInvalidPostLinkNodes.js +15 -0
- package/lib/ext/PostLinkEmbedPlugin/index.d.ts +21 -0
- package/lib/ext/PostLinkEmbedPlugin/index.js +148 -0
- package/lib/ext/RemoveListPlugin.d.ts +1 -0
- package/lib/ext/RemoveListPlugin.js +63 -0
- package/lib/ext/SafeAreaPlugin.d.ts +12 -0
- package/lib/ext/SafeAreaPlugin.js +56 -0
- package/lib/ext/SelectBlockPlugin.d.ts +1 -0
- package/lib/ext/SelectBlockPlugin.js +95 -0
- package/lib/ext/ShortcutPlugin/CtrlsShortcutPlugin.d.ts +6 -0
- package/lib/ext/ShortcutPlugin/CtrlsShortcutPlugin.js +17 -0
- package/lib/ext/ShortcutPlugin/index.d.ts +1 -0
- package/lib/ext/ShortcutPlugin/index.js +1 -0
- package/lib/ext/TemplatePlugin.d.ts +8 -0
- package/lib/ext/TemplatePlugin.js +170 -0
- package/lib/ext/VideoPathFixerPlugin.d.ts +1 -0
- package/lib/ext/VideoPathFixerPlugin.js +31 -0
- package/lib/ext/VideoPlugin/VideoComponent.d.ts +5 -0
- package/lib/ext/VideoPlugin/VideoComponent.js +5 -0
- package/lib/ext/VideoPlugin/VideoNode.d.ts +37 -0
- package/lib/ext/VideoPlugin/VideoNode.js +97 -0
- package/lib/ext/VideoPlugin/VideoPlugin.d.ts +7 -0
- package/lib/ext/VideoPlugin/VideoPlugin.js +26 -0
- package/lib/ext/VideoPlugin/index.d.ts +2 -0
- package/lib/ext/VideoPlugin/index.js +2 -0
- package/lib/ext/common.d.ts +15 -0
- package/lib/ext/common.js +62 -0
- package/lib/ext/nodes/GithubComp.d.ts +3 -0
- package/lib/ext/nodes/GithubComp.js +20 -0
- package/lib/ext/nodes/GithubNode.d.ts +28 -0
- package/lib/ext/nodes/GithubNode.js +94 -0
- package/lib/ext/nodes/util.d.ts +5 -0
- package/lib/ext/nodes/util.js +1 -0
- package/lib/ext/translation/translation-utils.d.ts +16 -0
- package/lib/ext/translation/translation-utils.js +63 -0
- package/lib/ext/utils.d.ts +21 -0
- package/lib/ext/utils.js +88 -0
- package/lib/global.d.ts +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +5 -0
- package/lib/lexical-utils/index.d.ts +46 -0
- package/lib/lexical-utils/index.js +243 -0
- package/lib/libs/sort-array-by-key.d.ts +4 -0
- package/lib/libs/sort-array-by-key.js +68 -0
- package/lib/libs/utm.d.ts +9 -0
- package/lib/libs/utm.js +43 -0
- package/lib/main/appSettings.d.ts +11 -0
- package/lib/main/appSettings.js +20 -0
- package/lib/main/context/SharedAutocompleteContext.d.ts +16 -0
- package/lib/main/context/SharedAutocompleteContext.js +35 -0
- package/lib/main/context/SharedHistoryContext.d.ts +17 -0
- package/lib/main/context/SharedHistoryContext.js +11 -0
- package/lib/main/editor-root.d.ts +2 -0
- package/lib/main/editor-root.js +46 -0
- package/lib/main/editor.d.ts +21 -0
- package/lib/main/editor.js +99 -0
- package/lib/main/hooks/hooks.d.ts +15 -0
- package/lib/main/hooks/hooks.js +49 -0
- package/lib/main/hooks/medium-zoom.d.ts +9 -0
- package/lib/main/hooks/medium-zoom.js +34 -0
- package/lib/main/hooks/use-mobile.d.ts +4 -0
- package/lib/main/hooks/use-mobile.js +6 -0
- package/lib/main/hooks/useBeforeUnload.d.ts +1 -0
- package/lib/main/hooks/useBeforeUnload.js +15 -0
- package/lib/main/hooks/useHasNodes.d.ts +1 -0
- package/lib/main/hooks/useHasNodes.js +8 -0
- package/lib/main/hooks/useIsFocused.d.ts +1 -0
- package/lib/main/hooks/useIsFocused.js +20 -0
- package/lib/main/hooks/useModal.d.ts +12 -0
- package/lib/main/hooks/useModal.js +33 -0
- package/lib/main/hooks/useReport.d.ts +8 -0
- package/lib/main/hooks/useReport.js +48 -0
- package/lib/main/hooks/useResponsiveTable.d.ts +5 -0
- package/lib/main/hooks/useResponsiveTable.js +31 -0
- package/lib/main/hooks/useTranslationListener.d.ts +4 -0
- package/lib/main/hooks/useTranslationListener.js +94 -0
- package/lib/main/icons.d.ts +3 -0
- package/lib/main/icons.js +25 -0
- package/lib/main/images/emoji/1F600.png +0 -0
- package/lib/main/images/emoji/1F641.png +0 -0
- package/lib/main/images/emoji/1F642.png +0 -0
- package/lib/main/images/emoji/2764.png +0 -0
- package/lib/main/images/excalidraw.svg +3 -0
- package/lib/main/images/icons/arrow-clockwise.svg +1 -0
- package/lib/main/images/icons/arrow-counterclockwise.svg +1 -0
- package/lib/main/images/icons/bg-color.svg +1 -0
- package/lib/main/images/icons/camera.svg +1 -0
- package/lib/main/images/icons/caret-right-fill.svg +1 -0
- package/lib/main/images/icons/chat-left-text.svg +1 -0
- package/lib/main/images/icons/chat-right-dots.svg +1 -0
- package/lib/main/images/icons/chat-right-text.svg +1 -0
- package/lib/main/images/icons/chat-right.svg +1 -0
- package/lib/main/images/icons/chat-square-quote.svg +1 -0
- package/lib/main/images/icons/chevron-down.svg +1 -0
- package/lib/main/images/icons/clipboard.svg +1 -0
- package/lib/main/images/icons/close.svg +1 -0
- package/lib/main/images/icons/code.svg +1 -0
- package/lib/main/images/icons/comments.svg +1 -0
- package/lib/main/images/icons/copy.svg +1 -0
- package/lib/main/images/icons/diagram-2.svg +1 -0
- package/lib/main/images/icons/download.svg +1 -0
- package/lib/main/images/icons/draggable-block-menu.svg +1 -0
- package/lib/main/images/icons/dropdown-more.svg +1 -0
- package/lib/main/images/icons/figma.svg +1 -0
- package/lib/main/images/icons/file-image.svg +1 -0
- package/lib/main/images/icons/filetype-gif.svg +1 -0
- package/lib/main/images/icons/font-color.svg +1 -0
- package/lib/main/images/icons/font-family.svg +1 -0
- package/lib/main/images/icons/gear.svg +1 -0
- package/lib/main/images/icons/horizontal-rule.svg +1 -0
- package/lib/main/images/icons/indent.svg +1 -0
- package/lib/main/images/icons/journal-code.svg +1 -0
- package/lib/main/images/icons/journal-text.svg +1 -0
- package/lib/main/images/icons/justify.svg +1 -0
- package/lib/main/images/icons/link.svg +1 -0
- package/lib/main/images/icons/list-ol.svg +1 -0
- package/lib/main/images/icons/list-ul.svg +1 -0
- package/lib/main/images/icons/lock-fill.svg +1 -0
- package/lib/main/images/icons/lock.svg +1 -0
- package/lib/main/images/icons/markdown.svg +1 -0
- package/lib/main/images/icons/mic.svg +1 -0
- package/lib/main/images/icons/outdent.svg +1 -0
- package/lib/main/images/icons/paint-bucket.svg +1 -0
- package/lib/main/images/icons/palette.svg +1 -0
- package/lib/main/images/icons/pencil-fill.svg +1 -0
- package/lib/main/images/icons/plug-fill.svg +1 -0
- package/lib/main/images/icons/plug.svg +1 -0
- package/lib/main/images/icons/plus-slash-minus.svg +1 -0
- package/lib/main/images/icons/plus.svg +1 -0
- package/lib/main/images/icons/prettier-error.svg +1 -0
- package/lib/main/images/icons/prettier.svg +1 -0
- package/lib/main/images/icons/send.svg +1 -0
- package/lib/main/images/icons/square-check.svg +1 -0
- package/lib/main/images/icons/sticky.svg +1 -0
- package/lib/main/images/icons/success.svg +1 -0
- package/lib/main/images/icons/table.svg +1 -0
- package/lib/main/images/icons/text-center.svg +1 -0
- package/lib/main/images/icons/text-left.svg +1 -0
- package/lib/main/images/icons/text-paragraph.svg +1 -0
- package/lib/main/images/icons/text-right.svg +1 -0
- package/lib/main/images/icons/trash.svg +1 -0
- package/lib/main/images/icons/trash3.svg +1 -0
- package/lib/main/images/icons/tweet.svg +1 -0
- package/lib/main/images/icons/type-bold.svg +1 -0
- package/lib/main/images/icons/type-h1.svg +1 -0
- package/lib/main/images/icons/type-h2.svg +1 -0
- package/lib/main/images/icons/type-h3.svg +1 -0
- package/lib/main/images/icons/type-h4.svg +1 -0
- package/lib/main/images/icons/type-h5.svg +1 -0
- package/lib/main/images/icons/type-h6.svg +1 -0
- package/lib/main/images/icons/type-italic.svg +1 -0
- package/lib/main/images/icons/type-strikethrough.svg +1 -0
- package/lib/main/images/icons/type-subscript.svg +1 -0
- package/lib/main/images/icons/type-superscript.svg +1 -0
- package/lib/main/images/icons/type-underline.svg +1 -0
- package/lib/main/images/icons/upload.svg +1 -0
- package/lib/main/images/icons/user.svg +1 -0
- package/lib/main/images/icons/youtube.svg +1 -0
- package/lib/main/images/landscape.jpg +0 -0
- package/lib/main/index.css +257 -0
- package/lib/main/index.d.ts +28 -0
- package/lib/main/index.js +52 -0
- package/lib/main/nodes/EmojiNode.d.ts +25 -0
- package/lib/main/nodes/EmojiNode.js +57 -0
- package/lib/main/nodes/EquationNode.d.ts +31 -0
- package/lib/main/nodes/EquationNode.js +65 -0
- package/lib/main/nodes/ExcalidrawNode/ExcalidrawComponent.d.ts +13 -0
- package/lib/main/nodes/ExcalidrawNode/ExcalidrawComponent.js +155 -0
- package/lib/main/nodes/ExcalidrawNode/ExcalidrawImage.d.ts +58 -0
- package/lib/main/nodes/ExcalidrawNode/ExcalidrawImage.js +60 -0
- package/lib/main/nodes/ExcalidrawNode/ExcalidrawModal.css +75 -0
- package/lib/main/nodes/ExcalidrawNode/ExcalidrawModal.d.ts +49 -0
- package/lib/main/nodes/ExcalidrawNode/ExcalidrawModal.js +197 -0
- package/lib/main/nodes/ExcalidrawNode/index.d.ts +30 -0
- package/lib/main/nodes/ExcalidrawNode/index.js +95 -0
- package/lib/main/nodes/ExcalidrawNode/utils.d.ts +5 -0
- package/lib/main/nodes/ExcalidrawNode/utils.js +71 -0
- package/lib/main/nodes/FigmaNode.d.ts +30 -0
- package/lib/main/nodes/FigmaNode.js +59 -0
- package/lib/main/nodes/ImageComponent.d.ts +27 -0
- package/lib/main/nodes/ImageComponent.js +432 -0
- package/lib/main/nodes/ImageNode.css +51 -0
- package/lib/main/nodes/ImageNode.d.ts +74 -0
- package/lib/main/nodes/ImageNode.js +151 -0
- package/lib/main/nodes/KeywordNode.d.ts +25 -0
- package/lib/main/nodes/KeywordNode.js +52 -0
- package/lib/main/nodes/MentionNode.d.ts +27 -0
- package/lib/main/nodes/MentionNode.js +88 -0
- package/lib/main/nodes/PlaygroundNodes.d.ts +10 -0
- package/lib/main/nodes/PlaygroundNodes.js +70 -0
- package/lib/main/nodes/TweetNode.d.ts +31 -0
- package/lib/main/nodes/TweetNode.js +126 -0
- package/lib/main/nodes/YouTubeNode.d.ts +32 -0
- package/lib/main/nodes/YouTubeNode.js +94 -0
- package/lib/main/plugins/AutoEmbedPlugin/index.d.ts +27 -0
- package/lib/main/plugins/AutoEmbedPlugin/index.js +353 -0
- package/lib/main/plugins/AutoEmbedPlugin/urlParseCache.d.ts +2 -0
- package/lib/main/plugins/AutoEmbedPlugin/urlParseCache.js +14 -0
- package/lib/main/plugins/AutoLinkPlugin/index.d.ts +9 -0
- package/lib/main/plugins/AutoLinkPlugin/index.js +39 -0
- package/lib/main/plugins/ClickableLinkPlugin/index.d.ts +8 -0
- package/lib/main/plugins/ClickableLinkPlugin/index.js +141 -0
- package/lib/main/plugins/CodeActionMenuPlugin/components/CopyButton/index.d.ts +7 -0
- package/lib/main/plugins/CodeActionMenuPlugin/components/CopyButton/index.js +44 -0
- package/lib/main/plugins/CodeActionMenuPlugin/index.css +46 -0
- package/lib/main/plugins/CodeActionMenuPlugin/index.d.ts +12 -0
- package/lib/main/plugins/CodeActionMenuPlugin/index.js +100 -0
- package/lib/main/plugins/CodeActionMenuPlugin/utils.d.ts +2 -0
- package/lib/main/plugins/CodeActionMenuPlugin/utils.js +18 -0
- package/lib/main/plugins/CodeHighlightPlugin/index.d.ts +9 -0
- package/lib/main/plugins/CodeHighlightPlugin/index.js +17 -0
- package/lib/main/plugins/CollapsiblePlugin/Collapsible.css +61 -0
- package/lib/main/plugins/CollapsiblePlugin/CollapsibleContainerNode.d.ts +30 -0
- package/lib/main/plugins/CollapsiblePlugin/CollapsibleContainerNode.js +120 -0
- package/lib/main/plugins/CollapsiblePlugin/CollapsibleContentNode.d.ts +24 -0
- package/lib/main/plugins/CollapsiblePlugin/CollapsibleContentNode.js +90 -0
- package/lib/main/plugins/CollapsiblePlugin/CollapsibleTitleNode.d.ts +24 -0
- package/lib/main/plugins/CollapsiblePlugin/CollapsibleTitleNode.js +95 -0
- package/lib/main/plugins/CollapsiblePlugin/CollapsibleUtils.d.ts +9 -0
- package/lib/main/plugins/CollapsiblePlugin/CollapsibleUtils.js +15 -0
- package/lib/main/plugins/CollapsiblePlugin/index.d.ts +11 -0
- package/lib/main/plugins/CollapsiblePlugin/index.js +147 -0
- package/lib/main/plugins/ComponentPickerPlugin/index.d.ts +12 -0
- package/lib/main/plugins/ComponentPickerPlugin/index.js +438 -0
- package/lib/main/plugins/DragDropPastePlugin/index.d.ts +8 -0
- package/lib/main/plugins/DragDropPastePlugin/index.js +32 -0
- package/lib/main/plugins/DraggableBlockPlugin/index.css +36 -0
- package/lib/main/plugins/DraggableBlockPlugin/index.d.ts +12 -0
- package/lib/main/plugins/DraggableBlockPlugin/index.js +288 -0
- package/lib/main/plugins/EmojisPlugin/index.d.ts +9 -0
- package/lib/main/plugins/EmojisPlugin/index.js +63 -0
- package/lib/main/plugins/ExcalidrawPlugin/index.d.ts +3 -0
- package/lib/main/plugins/ExcalidrawPlugin/index.js +30 -0
- package/lib/main/plugins/FigmaPlugin/index.d.ts +11 -0
- package/lib/main/plugins/FigmaPlugin/index.js +27 -0
- package/lib/main/plugins/FloatingLinkEditorPlugin/index.css +39 -0
- package/lib/main/plugins/FloatingLinkEditorPlugin/index.d.ts +12 -0
- package/lib/main/plugins/FloatingLinkEditorPlugin/index.js +181 -0
- package/lib/main/plugins/FloatingTextFormatToolbarPlugin/ColorPickerButton.d.ts +5 -0
- package/lib/main/plugins/FloatingTextFormatToolbarPlugin/ColorPickerButton.js +24 -0
- package/lib/main/plugins/FloatingTextFormatToolbarPlugin/index.css +128 -0
- package/lib/main/plugins/FloatingTextFormatToolbarPlugin/index.d.ts +12 -0
- package/lib/main/plugins/FloatingTextFormatToolbarPlugin/index.js +216 -0
- package/lib/main/plugins/HorizontalRulePlugin/index.d.ts +8 -0
- package/lib/main/plugins/HorizontalRulePlugin/index.js +30 -0
- package/lib/main/plugins/ImagesPlugin/index.d.ts +15 -0
- package/lib/main/plugins/ImagesPlugin/index.js +36 -0
- package/lib/main/plugins/LexicalTypeaheadMenuPlugin/index.d.ts +64 -0
- package/lib/main/plugins/LexicalTypeaheadMenuPlugin/index.js +493 -0
- package/lib/main/plugins/MarkdownShortcutPlugin/index.d.ts +9 -0
- package/lib/main/plugins/MarkdownShortcutPlugin/index.js +22 -0
- package/lib/main/plugins/MarkdownTransformers/index.d.ts +12 -0
- package/lib/main/plugins/MarkdownTransformers/index.js +185 -0
- package/lib/main/plugins/MaxLengthPlugin/index.d.ts +10 -0
- package/lib/main/plugins/MaxLengthPlugin/index.js +43 -0
- package/lib/main/plugins/MentionsPlugin/HighlightStyle.d.ts +2 -0
- package/lib/main/plugins/MentionsPlugin/HighlightStyle.js +13 -0
- package/lib/main/plugins/MentionsPlugin/index.d.ts +9 -0
- package/lib/main/plugins/MentionsPlugin/index.js +175 -0
- package/lib/main/plugins/TabFocusPlugin/index.d.ts +8 -0
- package/lib/main/plugins/TabFocusPlugin/index.js +41 -0
- package/lib/main/plugins/TableActionMenuPlugin/index.d.ts +12 -0
- package/lib/main/plugins/TableActionMenuPlugin/index.js +486 -0
- package/lib/main/plugins/TableCellResizer/index.css +20 -0
- package/lib/main/plugins/TableCellResizer/index.d.ts +3 -0
- package/lib/main/plugins/TableCellResizer/index.js +295 -0
- package/lib/main/plugins/TableOfContentsPlugin/index.css +87 -0
- package/lib/main/plugins/TableOfContentsPlugin/index.d.ts +2 -0
- package/lib/main/plugins/TableOfContentsPlugin/index.js +106 -0
- package/lib/main/plugins/TablePlugin.d.ts +38 -0
- package/lib/main/plugins/TablePlugin.js +63 -0
- package/lib/main/plugins/ToolbarPlugin/index.d.ts +8 -0
- package/lib/main/plugins/ToolbarPlugin/index.js +467 -0
- package/lib/main/plugins/TreeViewPlugin/index.d.ts +9 -0
- package/lib/main/plugins/TreeViewPlugin/index.js +14 -0
- package/lib/main/plugins/TwitterPlugin/index.d.ts +11 -0
- package/lib/main/plugins/TwitterPlugin/index.js +27 -0
- package/lib/main/plugins/TypingPerfPlugin/index.d.ts +9 -0
- package/lib/main/plugins/TypingPerfPlugin/index.js +100 -0
- package/lib/main/plugins/YouTubePlugin/index.d.ts +11 -0
- package/lib/main/plugins/YouTubePlugin/index.js +27 -0
- package/lib/main/server/validation.d.ts +8 -0
- package/lib/main/server/validation.js +119 -0
- package/lib/main/setupEnv.d.ts +8 -0
- package/lib/main/setupEnv.js +25 -0
- package/lib/main/style/editable.css +476 -0
- package/lib/main/styled-editor-content.d.ts +5 -0
- package/lib/main/styled-editor-content.js +206 -0
- package/lib/main/themes/code-highlight/index.d.ts +32 -0
- package/lib/main/themes/code-highlight/index.js +58 -0
- package/lib/main/themes/customTheme.d.ts +2 -0
- package/lib/main/themes/customTheme.js +324 -0
- package/lib/main/themes/defaultTheme.d.ts +10 -0
- package/lib/main/themes/defaultTheme.js +554 -0
- package/lib/main/themes/table/index.d.ts +3 -0
- package/lib/main/themes/table/index.js +20 -0
- package/lib/main/themes/table/table.css +214 -0
- package/lib/main/ui/Button.css +36 -0
- package/lib/main/ui/Button.d.ts +18 -0
- package/lib/main/ui/Button.js +13 -0
- package/lib/main/ui/ColorPicker.css +89 -0
- package/lib/main/ui/ColorPicker.d.ts +28 -0
- package/lib/main/ui/ColorPicker.js +206 -0
- package/lib/main/ui/ContentEditable.d.ts +2 -0
- package/lib/main/ui/ContentEditable.js +15 -0
- package/lib/main/ui/Dialog.css +17 -0
- package/lib/main/ui/Dialog.d.ts +16 -0
- package/lib/main/ui/Dialog.js +15 -0
- package/lib/main/ui/DropDown.d.ts +25 -0
- package/lib/main/ui/DropDown.js +146 -0
- package/lib/main/ui/FileInput.d.ts +17 -0
- package/lib/main/ui/FileInput.js +5 -0
- package/lib/main/ui/FrameMockup/browser.css +52 -0
- package/lib/main/ui/FrameMockup/browser.d.ts +13 -0
- package/lib/main/ui/FrameMockup/browser.js +22 -0
- package/lib/main/ui/FrameMockup/index.d.ts +113 -0
- package/lib/main/ui/FrameMockup/index.js +61 -0
- package/lib/main/ui/ImageEnhancer.d.ts +29 -0
- package/lib/main/ui/ImageEnhancer.js +113 -0
- package/lib/main/ui/ImageResizer.d.ts +24 -0
- package/lib/main/ui/ImageResizer.js +154 -0
- package/lib/main/ui/Input.css +30 -0
- package/lib/main/ui/Modal.css +62 -0
- package/lib/main/ui/Modal.d.ts +15 -0
- package/lib/main/ui/Modal.js +50 -0
- package/lib/main/ui/Placeholder.d.ts +6 -0
- package/lib/main/ui/Placeholder.js +20 -0
- package/lib/main/ui/TextInput.d.ts +20 -0
- package/lib/main/ui/TextInput.js +14 -0
- package/lib/main/utils/getDOMRangeRect.d.ts +8 -0
- package/lib/main/utils/getDOMRangeRect.js +22 -0
- package/lib/main/utils/getSelectedNode.d.ts +2 -0
- package/lib/main/utils/getSelectedNode.js +22 -0
- package/lib/main/utils/guard.d.ts +14 -0
- package/lib/main/utils/guard.js +36 -0
- package/lib/main/utils/images.d.ts +10 -0
- package/lib/main/utils/images.js +16 -0
- package/lib/main/utils/join-classes.d.ts +8 -0
- package/lib/main/utils/join-classes.js +10 -0
- package/lib/main/utils/point.d.ts +21 -0
- package/lib/main/utils/point.js +42 -0
- package/lib/main/utils/prevent-duplicate-upload.d.ts +2 -0
- package/lib/main/utils/prevent-duplicate-upload.js +25 -0
- package/lib/main/utils/rect.d.ts +45 -0
- package/lib/main/utils/rect.js +98 -0
- package/lib/main/utils/sanitizeUrl.d.ts +8 -0
- package/lib/main/utils/sanitizeUrl.js +17 -0
- package/lib/main/utils/setFloatingElemPosition.d.ts +1 -0
- package/lib/main/utils/setFloatingElemPosition.js +32 -0
- package/lib/main/utils/swipe.d.ts +11 -0
- package/lib/main/utils/swipe.js +98 -0
- package/lib/main/viewer/index.d.ts +5 -0
- package/lib/main/viewer/index.js +25 -0
- package/lib/main/viewer/types.d.ts +14 -0
- package/lib/main/viewer/types.js +1 -0
- package/lib/main/viewer/viewer.d.ts +3 -0
- package/lib/main/viewer/viewer.js +31 -0
- package/lib/shared/canUseDOM.d.ts +8 -0
- package/lib/shared/canUseDOM.js +10 -0
- package/lib/shared/environment.d.ts +24 -0
- package/lib/shared/environment.js +21 -0
- package/lib/shared/getDOMSelection.d.ts +9 -0
- package/lib/shared/getDOMSelection.js +10 -0
- package/lib/shared/invariant.d.ts +8 -0
- package/lib/shared/invariant.js +16 -0
- package/lib/shared/useLayoutEffect.d.ts +10 -0
- package/lib/shared/useLayoutEffect.js +11 -0
- package/lib/types.d.ts +19 -0
- package/lib/types.js +1 -0
- package/lib/vendor/LexicalCharacterLimitPlugin/LexicalCharacterLimitPlugin.d.ts +15 -0
- package/lib/vendor/LexicalCharacterLimitPlugin/LexicalCharacterLimitPlugin.js +45 -0
- package/lib/vendor/LexicalCharacterLimitPlugin/index.d.ts +1 -0
- package/lib/vendor/LexicalCharacterLimitPlugin/index.js +1 -0
- package/lib/vendor/LexicalCharacterLimitPlugin/useCharacterLimit.d.ts +16 -0
- package/lib/vendor/LexicalCharacterLimitPlugin/useCharacterLimit.js +208 -0
- package/lib/vendor/history/LexicalHistoryPlugin.d.ts +14 -0
- package/lib/vendor/history/LexicalHistoryPlugin.js +15 -0
- package/lib/vendor/history/history/index.d.ts +63 -0
- package/lib/vendor/history/history/index.js +351 -0
- package/lib/vendor/history/useHistory.d.ts +10 -0
- package/lib/vendor/history/useHistory.js +15 -0
- package/package.json +109 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useMemo, useRef } from 'react';
|
|
3
|
+
import { useGetState } from 'ahooks';
|
|
4
|
+
import builtinTemplates from './builtin-templates';
|
|
5
|
+
import { Template } from './types';
|
|
6
|
+
import { useAIAvailable } from './hooks';
|
|
7
|
+
export const AideContext = createContext({});
|
|
8
|
+
export const useAideContext = () => useContext(AideContext);
|
|
9
|
+
export function AideProvider({ completions, replaceSelection, insertBelow, copy, children }) {
|
|
10
|
+
const [state, setState, getState] = useGetState({
|
|
11
|
+
templates: builtinTemplates,
|
|
12
|
+
externalTemplates: { templates: [], hasMore: true, tags: [], tag: undefined, loading: false },
|
|
13
|
+
mode: 'normal',
|
|
14
|
+
status: 'initial',
|
|
15
|
+
selection: null,
|
|
16
|
+
selectionText: '',
|
|
17
|
+
input: '',
|
|
18
|
+
output: '',
|
|
19
|
+
});
|
|
20
|
+
// (external) "templates" mode 下可用的 builtin templates (以及 activeBuiltinTemplate) 为空
|
|
21
|
+
const filteredTemplates = useMemo(() => state.mode === 'normal'
|
|
22
|
+
? state.templates.filter((item) => item.name?.toLowerCase().indexOf(state.input?.toLowerCase()) > -1)
|
|
23
|
+
: [], [state]);
|
|
24
|
+
const activeBuiltinTemplate = useMemo(() => {
|
|
25
|
+
const first = filteredTemplates[0];
|
|
26
|
+
return first?.hasOptions() ? undefined : first;
|
|
27
|
+
}, [filteredTemplates]);
|
|
28
|
+
const retryRef = useRef(null);
|
|
29
|
+
const reset = (params = {}, keepSelection = false, isCopy = false) => {
|
|
30
|
+
setState((prev) => ({
|
|
31
|
+
...prev,
|
|
32
|
+
status: isCopy ? 'copied' : 'initial',
|
|
33
|
+
...(!keepSelection && {
|
|
34
|
+
selection: null,
|
|
35
|
+
selectionText: '',
|
|
36
|
+
}),
|
|
37
|
+
input: '',
|
|
38
|
+
output: '',
|
|
39
|
+
...params,
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
// @deprecated
|
|
43
|
+
const loadMoreTemplates = async () => { };
|
|
44
|
+
const { available } = useAIAvailable();
|
|
45
|
+
const activateAI = useCallback(
|
|
46
|
+
// eslint-disable-next-line require-await
|
|
47
|
+
async ({ mode = 'normal', selectionText, selection }) => {
|
|
48
|
+
setState((prev) => ({ ...prev, mode, selectionText, selection, status: 'activated' }));
|
|
49
|
+
}, []);
|
|
50
|
+
const setInput = (text) => setState((prev) => ({ ...prev, input: text }));
|
|
51
|
+
const sendToAI = async (payload) => {
|
|
52
|
+
function isQuoted(str) {
|
|
53
|
+
return str.startsWith('"') && str.endsWith('"');
|
|
54
|
+
}
|
|
55
|
+
function removeQuotes(str) {
|
|
56
|
+
if (isQuoted(str)) {
|
|
57
|
+
return str.slice(1, -1);
|
|
58
|
+
}
|
|
59
|
+
return str;
|
|
60
|
+
}
|
|
61
|
+
let output = '';
|
|
62
|
+
setState((prev) => ({ ...prev, status: 'waiting' }));
|
|
63
|
+
retryRef.current = () => sendToAI(payload);
|
|
64
|
+
try {
|
|
65
|
+
// ad hoc prompt
|
|
66
|
+
if (typeof payload === 'string') {
|
|
67
|
+
output = await completions(payload);
|
|
68
|
+
// builtin template
|
|
69
|
+
}
|
|
70
|
+
else if (payload instanceof Template) {
|
|
71
|
+
output = await completions(payload.getPrompt(state.selectionText));
|
|
72
|
+
// parameterized template
|
|
73
|
+
}
|
|
74
|
+
else if (payload) {
|
|
75
|
+
output = await completions(payload);
|
|
76
|
+
}
|
|
77
|
+
if (!isQuoted(state.selectionText)) {
|
|
78
|
+
output = removeQuotes(output?.trim());
|
|
79
|
+
}
|
|
80
|
+
if (typeof output !== 'string') {
|
|
81
|
+
throw new Error('Invalid response message');
|
|
82
|
+
}
|
|
83
|
+
// waiting 时状态可能会改变 (比如 reset => 'initial')
|
|
84
|
+
if (getState().status === 'waiting') {
|
|
85
|
+
setState((prev) => ({ ...prev, output, status: 'completed' }));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
const latestState = getState();
|
|
90
|
+
console.error(e, { input: latestState.input, selection: latestState.selection, output });
|
|
91
|
+
setState((prev) => ({ ...prev, status: 'activated' }));
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const retry = () => retryRef.current?.();
|
|
95
|
+
const stop = () => setState((prev) => ({ ...prev, status: 'activated' }));
|
|
96
|
+
const value = useMemo(() => ({
|
|
97
|
+
...state,
|
|
98
|
+
available,
|
|
99
|
+
filteredTemplates,
|
|
100
|
+
activeBuiltinTemplate,
|
|
101
|
+
activateAI,
|
|
102
|
+
setInput,
|
|
103
|
+
sendToAI,
|
|
104
|
+
retry,
|
|
105
|
+
stop,
|
|
106
|
+
reset,
|
|
107
|
+
replaceSelection,
|
|
108
|
+
insertBelow,
|
|
109
|
+
copy,
|
|
110
|
+
completions,
|
|
111
|
+
loadMoreTemplates,
|
|
112
|
+
}), [state]);
|
|
113
|
+
return _jsx(AideContext.Provider, { value: value, children: children });
|
|
114
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface Item {
|
|
3
|
+
title: React.ReactNode;
|
|
4
|
+
onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
5
|
+
}
|
|
6
|
+
interface Props {
|
|
7
|
+
items: Item[];
|
|
8
|
+
}
|
|
9
|
+
export default function Breadcrumb({ items, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Breadcrumbs } from '@mui/material';
|
|
3
|
+
export default function Breadcrumb({ items, ...rest }) {
|
|
4
|
+
return (_jsx(Breadcrumbs, { sx: { fontSize: 14, lineHeight: 1 }, ...rest, children: items.map((item, index) => {
|
|
5
|
+
const isLast = index === items.length - 1;
|
|
6
|
+
const styles = isLast ? { color: 'grey.800', textDecoration: 'underline' } : {};
|
|
7
|
+
return (_jsx(Box
|
|
8
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
9
|
+
, { onClick: item.onClick, sx: [{ cursor: 'pointer', '&:hover': { textDecoration: 'underline' } }, styles], children: item.title }, index));
|
|
10
|
+
}) }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ParameterizedTemplate } from '../types';
|
|
2
|
+
interface Props {
|
|
3
|
+
template: ParameterizedTemplate;
|
|
4
|
+
gotoTemplatesView: () => void;
|
|
5
|
+
gotoTemplateView: (templateId: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export default function OutputView({ template, gotoTemplatesView, gotoTemplateView, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
import { Card } from '../../common';
|
|
4
|
+
import { useAideContext } from '../context';
|
|
5
|
+
import Menu from '../Menu';
|
|
6
|
+
import Breadcrumb from './Breadcrumb';
|
|
7
|
+
export default function OutputView({ template, gotoTemplatesView, gotoTemplateView, ...rest }) {
|
|
8
|
+
const { output } = useAideContext();
|
|
9
|
+
return (_jsxs(Box, { ...rest, children: [_jsx(Card, { sx: { maxHeight: 300, overflowY: 'auto', bgcolor: '#fff' }, children: _jsxs(Box, { sx: { p: 2 }, children: [_jsx(Breadcrumb, { items: [
|
|
10
|
+
{ title: 'Templates', onClick: gotoTemplatesView },
|
|
11
|
+
{
|
|
12
|
+
title: (_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 0.5 }, children: [_jsx(Box, { sx: {
|
|
13
|
+
display: 'flex',
|
|
14
|
+
justifyContent: 'center',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
flex: '0 0 auto',
|
|
17
|
+
}, children: _jsx(Box, { component: "i", className: "iconify", "data-icon": template.icon }) }), _jsx(Box, { children: template.name })] })),
|
|
18
|
+
onClick: () => gotoTemplateView(template.id),
|
|
19
|
+
},
|
|
20
|
+
{ title: 'Output' },
|
|
21
|
+
] }), _jsx(Box, { sx: { width: 400, mt: 2 }, children: output })] }) }), _jsx(Box, { sx: { mt: 0.5 }, children: _jsx(Menu, {}) })] }));
|
|
22
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
export default function Search({ keyword, onChange, ...rest }) {
|
|
4
|
+
const handleOnChange = (e) => {
|
|
5
|
+
onChange(e.target.value);
|
|
6
|
+
};
|
|
7
|
+
return (_jsxs(Box, { ...rest, sx: { display: 'flex', alignItems: 'center', height: 36, borderBottom: '1px solid #ddd' }, children: [_jsx(Box, { sx: {
|
|
8
|
+
display: 'flex',
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
alighItems: 'center',
|
|
11
|
+
width: 36,
|
|
12
|
+
color: 'grey.400',
|
|
13
|
+
}, children: _jsx(Box, { component: "i", className: "iconify", "data-icon": "mdi:magnify", "data-height": "18px" }) }), _jsx(Box, { component: "input", type: "text", value: keyword, onChange: handleOnChange, autoFocus: true, maxLength: 30, sx: { width: '100%', height: '100%', p: 0, border: 0, color: 'grey.700', outline: 'none' } })] }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Tab, Tabs } from '@mui/material';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import styled from '@emotion/styled';
|
|
5
|
+
import { useAideContext } from '../context';
|
|
6
|
+
export default function Tags({ ...rest }) {
|
|
7
|
+
const { externalTemplates: { tags }, loadMoreTemplates, } = useAideContext();
|
|
8
|
+
const [value, setValue] = useState(0);
|
|
9
|
+
const handleChange = (event, newValue) => {
|
|
10
|
+
setValue(newValue);
|
|
11
|
+
};
|
|
12
|
+
// FIXME: 暂时去除 Image tag
|
|
13
|
+
const filteredTags = tags?.filter((item) => item.toLowerCase() !== 'image') || [];
|
|
14
|
+
if (!filteredTags?.length) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return (_jsx(Box, { ...rest, children: _jsxs(StyledTabs, { value: value, onChange: handleChange, variant: "scrollable", scrollButtons: "auto", children: [_jsx(Tab, { label: "All", disableRipple: true, onClick: () => loadMoreTemplates({ offset: 0 }) }), filteredTags?.map((item) => {
|
|
18
|
+
return (_jsx(Tab, { label: item, disableRipple: true, onClick: () => loadMoreTemplates({ offset: 0, tag: item }) }, item));
|
|
19
|
+
})] }) }));
|
|
20
|
+
}
|
|
21
|
+
const StyledTabs = styled(Tabs) `
|
|
22
|
+
.MuiTabs-flexContainer {
|
|
23
|
+
position: relative;
|
|
24
|
+
z-index: 5;
|
|
25
|
+
}
|
|
26
|
+
.MuiTabs-indicator {
|
|
27
|
+
height: 28px;
|
|
28
|
+
top: 50%;
|
|
29
|
+
transform: translateY(-50%);
|
|
30
|
+
border-radius: 12px;
|
|
31
|
+
}
|
|
32
|
+
.MuiTabScrollButton-root {
|
|
33
|
+
width: auto;
|
|
34
|
+
}
|
|
35
|
+
.MuiTab-root {
|
|
36
|
+
min-width: 0;
|
|
37
|
+
padding: 4px 12px;
|
|
38
|
+
text-transform: initial;
|
|
39
|
+
transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
40
|
+
}
|
|
41
|
+
.MuiTab-root.Mui-selected {
|
|
42
|
+
color: #fff;
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ParameterizedTemplate } from '../types';
|
|
2
|
+
interface Props {
|
|
3
|
+
template: ParameterizedTemplate;
|
|
4
|
+
gotoTemplatesView: () => void;
|
|
5
|
+
}
|
|
6
|
+
export default function TemplateView({ template, gotoTemplatesView, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, CircularProgress, Chip } from '@mui/material';
|
|
3
|
+
import { ArrowForward as ArrowForwardIcon, Close as CloseIcon } from '@mui/icons-material';
|
|
4
|
+
import Joi from 'joi';
|
|
5
|
+
import { useMemo, useState } from 'react';
|
|
6
|
+
import { useReactive } from 'ahooks';
|
|
7
|
+
import pick from 'lodash/pick';
|
|
8
|
+
import { Card, GradientButton } from '../../common';
|
|
9
|
+
import { useAideContext } from '../context';
|
|
10
|
+
import Breadcrumb from './Breadcrumb';
|
|
11
|
+
import ParameterField from './parameter-field';
|
|
12
|
+
export default function TemplateView({ template, gotoTemplatesView, ...rest }) {
|
|
13
|
+
const { status, sendToAI } = useAideContext();
|
|
14
|
+
const paramKeys = useMemo(() => template.parameters?.filter((i) => !!i.key).map((i) => i.key) ?? [], [template]);
|
|
15
|
+
const values = useReactive({});
|
|
16
|
+
const [error, setError] = useState();
|
|
17
|
+
const clearInputs = () => {
|
|
18
|
+
setError(undefined);
|
|
19
|
+
Object.keys(values).forEach((key) => {
|
|
20
|
+
values[key] = undefined;
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const submit = () => {
|
|
24
|
+
setError(undefined);
|
|
25
|
+
const getValueSchema = (parameter) => {
|
|
26
|
+
return {
|
|
27
|
+
string: (param) => {
|
|
28
|
+
let s = Joi.string();
|
|
29
|
+
if (param.required) {
|
|
30
|
+
s = s.required();
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
s = s.allow('');
|
|
34
|
+
}
|
|
35
|
+
if (typeof param.minLength === 'number') {
|
|
36
|
+
s = s.min(param.minLength);
|
|
37
|
+
}
|
|
38
|
+
if (typeof param.maxLength === 'number') {
|
|
39
|
+
s = s.max(param.maxLength);
|
|
40
|
+
}
|
|
41
|
+
return s;
|
|
42
|
+
},
|
|
43
|
+
number: (param) => {
|
|
44
|
+
let s = Joi.number();
|
|
45
|
+
if (param.required) {
|
|
46
|
+
s = s.required();
|
|
47
|
+
}
|
|
48
|
+
if (typeof param.min === 'number') {
|
|
49
|
+
s = s.min(param.min);
|
|
50
|
+
}
|
|
51
|
+
if (typeof param.max === 'number') {
|
|
52
|
+
s = s.max(param.max);
|
|
53
|
+
}
|
|
54
|
+
return s;
|
|
55
|
+
},
|
|
56
|
+
select: (param) => {
|
|
57
|
+
let s = Joi.string();
|
|
58
|
+
if (param.required) {
|
|
59
|
+
s = s.required();
|
|
60
|
+
}
|
|
61
|
+
return s;
|
|
62
|
+
},
|
|
63
|
+
language: (param) => {
|
|
64
|
+
let s = Joi.string();
|
|
65
|
+
if (param.required) {
|
|
66
|
+
s = s.required();
|
|
67
|
+
}
|
|
68
|
+
return s;
|
|
69
|
+
},
|
|
70
|
+
}[parameter.type || 'string'](parameter);
|
|
71
|
+
};
|
|
72
|
+
const schema = Joi.object(Object.fromEntries((template.parameters ?? [])
|
|
73
|
+
.map((parameter) => {
|
|
74
|
+
if (!parameter.key)
|
|
75
|
+
return undefined;
|
|
76
|
+
return [parameter.key, getValueSchema(parameter)];
|
|
77
|
+
})
|
|
78
|
+
.filter((i) => !!i)));
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
80
|
+
const { error, value } = schema.validate(values, { allowUnknown: true, abortEarly: false });
|
|
81
|
+
if (error) {
|
|
82
|
+
setError(error);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
sendToAI({
|
|
86
|
+
...pick(template, 'source', 'projectId', 'ref', 'resourceComponentDid'),
|
|
87
|
+
assistantId: template.id,
|
|
88
|
+
parameters: value,
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
return (_jsx(Card, { sx: { maxHeight: 440, overflowY: 'auto', bgcolor: '#fff' }, children: _jsxs(Box, { component: "form", ...rest, sx: { p: 2 }, children: [_jsx(Breadcrumb, { items: [
|
|
92
|
+
{ title: 'Templates', onClick: gotoTemplatesView },
|
|
93
|
+
{
|
|
94
|
+
title: (_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 0.5 }, children: [_jsx(Box, { sx: {
|
|
95
|
+
display: 'flex',
|
|
96
|
+
justifyContent: 'center',
|
|
97
|
+
alignItems: 'center',
|
|
98
|
+
flex: '0 0 auto',
|
|
99
|
+
}, children: _jsx(Box, { component: "i", className: "iconify", "data-icon": template.icon }) }), _jsx(Box, { children: template.name })] })),
|
|
100
|
+
},
|
|
101
|
+
] }), _jsx(Box, { sx: { mt: 3 }, children: template.parameters?.map((parameter) => {
|
|
102
|
+
if (!parameter.key)
|
|
103
|
+
return;
|
|
104
|
+
const paramKey = parameter.key;
|
|
105
|
+
const err = error?.details.find((i) => i.path[0] === paramKey);
|
|
106
|
+
return (_jsx(Box, { sx: { '& + &': { mt: 2 } }, children: _jsx(ParameterField, { fullWidth: true, size: "small", label: parameter.label || paramKey, parameter: parameter, error: !!err, helperText: err?.message ?? parameter.helper, value: values[paramKey] ?? '', onChange: (value) => {
|
|
107
|
+
values[paramKey] = value;
|
|
108
|
+
} }) }, paramKey));
|
|
109
|
+
}) }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', mt: 3 }, children: [Object.keys(values).length > 0 && (_jsx(Chip, { icon: _jsx(CloseIcon, {}), size: "small", label: "Clear Inputs", onClick: clearInputs })), _jsx(GradientButton, { variant: "contained", size: "small", onClick: submit, endIcon: status === 'waiting' ? (_jsx(CircularProgress, { size: 16, style: { color: '#fff' } })) : (_jsx(ArrowForwardIcon, { style: { fontSize: 18 } })), sx: { ml: 'auto' }, children: "Generate" })] })] }) }));
|
|
110
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Typography, alpha, useTheme, CircularProgress } from '@mui/material';
|
|
3
|
+
import { useRef, useState } from 'react';
|
|
4
|
+
import { useInfiniteScroll } from 'ahooks';
|
|
5
|
+
import { Card } from '../../common';
|
|
6
|
+
import { useAideContext } from '../context';
|
|
7
|
+
import Search from './Search';
|
|
8
|
+
import Tags from './Tags';
|
|
9
|
+
export default function TemplatesView({ onSelect, ...rest }) {
|
|
10
|
+
const theme = useTheme();
|
|
11
|
+
const { externalTemplates: { templates, hasMore, tag, loading }, loadMoreTemplates, } = useAideContext();
|
|
12
|
+
const [state, setState] = useState({ keyword: '' });
|
|
13
|
+
const containerRef = useRef(null);
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
useInfiniteScroll(() => loadMoreTemplates({ tag }), {
|
|
16
|
+
target: containerRef,
|
|
17
|
+
manual: true,
|
|
18
|
+
threshold: hasMore ? 50 : -1,
|
|
19
|
+
});
|
|
20
|
+
// 1. 搜索匹配
|
|
21
|
+
let filteredTemplates = state.keyword
|
|
22
|
+
? templates?.filter((template) => `${template.name} ${template.description}`.toLowerCase().indexOf(state.keyword.toLowerCase()) > -1)
|
|
23
|
+
: templates;
|
|
24
|
+
// 2. (临时) 过滤掉图片生成类形的 template
|
|
25
|
+
filteredTemplates = filteredTemplates.filter((item) => item.type !== 'image');
|
|
26
|
+
return (_jsx(Box, { sx: { position: 'relative' }, ...rest, children: _jsxs(Card, { ref: containerRef, sx: { height: 360, overflowY: 'auto', bgcolor: '#fff' }, children: [_jsx(Search, { keyword: state.keyword, onChange: (value) => setState((prev) => ({ ...prev, keyword: value })) }), _jsx(Tags, {}), _jsxs(Box, { sx: { mt: 0.5 }, children: [filteredTemplates.map((item) => {
|
|
27
|
+
return (_jsxs(Box, { onClick: () => onSelect(item), sx: {
|
|
28
|
+
display: 'flex',
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
py: 0.25,
|
|
31
|
+
overflow: 'hidden',
|
|
32
|
+
cursor: 'pointer',
|
|
33
|
+
'&:hover': { bgcolor: alpha(theme.palette.primary.main, 0.1) },
|
|
34
|
+
}, children: [_jsx(Box, { sx: {
|
|
35
|
+
display: 'flex',
|
|
36
|
+
justifyContent: 'center',
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
flex: '0 0 auto',
|
|
39
|
+
width: 64,
|
|
40
|
+
height: 56,
|
|
41
|
+
}, children: _jsx(Box, { component: "i", className: "iconify", "data-icon": item.icon, "data-height": "28px" }) }), _jsxs(Box, { sx: { pr: 2, overflow: 'hidden' }, children: [_jsx(Typography, { variant: "inherit", noWrap: true, sx: { fontSize: 14 }, children: item.name }), _jsx(Typography, { variant: "inherit", noWrap: true, sx: { fontSize: 12 }, children: item.description })] })] }, item.id));
|
|
42
|
+
}), loading && (_jsx(Box, { sx: {
|
|
43
|
+
display: 'flex',
|
|
44
|
+
justifyContent: 'center',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
position: 'absolute',
|
|
47
|
+
top: 0,
|
|
48
|
+
bottom: 0,
|
|
49
|
+
width: '100%',
|
|
50
|
+
my: 1.5,
|
|
51
|
+
}, children: _jsx(Box, { sx: {
|
|
52
|
+
display: 'flex',
|
|
53
|
+
justifyContent: 'center',
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
width: 56,
|
|
56
|
+
height: 56,
|
|
57
|
+
bgcolor: 'grey.100',
|
|
58
|
+
borderRadius: 4,
|
|
59
|
+
boxShadow: 'box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);',
|
|
60
|
+
}, children: _jsx(CircularProgress, { size: "24px" }) }) }))] })] }) }));
|
|
61
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, ClickAwayListener, useTheme, alpha } from '@mui/material';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { useAideContext } from '../context';
|
|
5
|
+
import Templates from './Templates';
|
|
6
|
+
import Template from './Template';
|
|
7
|
+
import Menu from '../Menu';
|
|
8
|
+
import Input from '../Input';
|
|
9
|
+
import Output from '../Output';
|
|
10
|
+
import OutputView from './Output';
|
|
11
|
+
const getInitialState = (partial) => ({
|
|
12
|
+
currentTemplate: null,
|
|
13
|
+
currentView: null,
|
|
14
|
+
...partial,
|
|
15
|
+
});
|
|
16
|
+
export default function ExternalTemplates({ ...rest }) {
|
|
17
|
+
const theme = useTheme();
|
|
18
|
+
const { status, externalTemplates: { templates }, reset, } = useAideContext();
|
|
19
|
+
const [state, setState] = useState(getInitialState());
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (state.currentView === 'template' && status === 'completed') {
|
|
22
|
+
setCurrentView('output');
|
|
23
|
+
}
|
|
24
|
+
}, [state, status]);
|
|
25
|
+
const setCurrentView = (view, params) => {
|
|
26
|
+
switch (view) {
|
|
27
|
+
case 'templates': {
|
|
28
|
+
setState(getInitialState({ currentView: 'templates' }));
|
|
29
|
+
reset({ status: 'activated' }, true);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
case 'template': {
|
|
33
|
+
if (!params?.id) {
|
|
34
|
+
console.warn('Template ID is missing');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
reset({ status: 'activated' }, true);
|
|
38
|
+
setState((prev) => ({
|
|
39
|
+
...prev,
|
|
40
|
+
currentView: 'template',
|
|
41
|
+
currentTemplate: templates.find((item) => item.id === params.id),
|
|
42
|
+
}));
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case 'output': {
|
|
46
|
+
setState((prev) => ({ ...prev, currentView: 'output' }));
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
default: {
|
|
50
|
+
setState(getInitialState({ currentView: null }));
|
|
51
|
+
reset({ status: 'activated' }, true);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const gotoTemplatesView = () => setCurrentView('templates');
|
|
56
|
+
const gotoTemplateView = (templateId) => setCurrentView('template', { id: templateId });
|
|
57
|
+
const handleClickInput = () => {
|
|
58
|
+
if (state.currentView) {
|
|
59
|
+
setCurrentView(null);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const toggleViewVisible = (e) => {
|
|
63
|
+
e.stopPropagation();
|
|
64
|
+
setCurrentView(state.currentView ? null : 'templates');
|
|
65
|
+
};
|
|
66
|
+
return (_jsx(ClickAwayListener, { onClickAway: () => reset(), mouseEvent: "onMouseUp", children: _jsxs(Box, { sx: { maxWidth: 440, fontSize: 14, zIndex: 1201 }, ...rest, children: [state.currentView === 'templates' && _jsx(Templates, { onSelect: (template) => gotoTemplateView(template.id) }), state.currentView === 'template' && (_jsx(Template, { template: state.currentTemplate, gotoTemplatesView: gotoTemplatesView })), state.currentView === 'output' && (_jsx(OutputView, { template: state.currentTemplate, gotoTemplatesView: gotoTemplatesView, gotoTemplateView: gotoTemplateView })), _jsxs(Box, { sx: { mt: 0.5 }, onClick: handleClickInput, children: [_jsx(Input, { prepend: _jsxs(Box, { onClick: toggleViewVisible, sx: {
|
|
67
|
+
display: 'flex',
|
|
68
|
+
alignItems: 'center',
|
|
69
|
+
flex: '0 0 auto',
|
|
70
|
+
gap: 0.5,
|
|
71
|
+
height: 26,
|
|
72
|
+
mr: 0.5,
|
|
73
|
+
px: 1.25,
|
|
74
|
+
fontSize: 13,
|
|
75
|
+
bgcolor: 'grey.200',
|
|
76
|
+
borderRadius: 3,
|
|
77
|
+
cursor: 'pointer',
|
|
78
|
+
'&:hover': {
|
|
79
|
+
color: 'primary.dark',
|
|
80
|
+
bgcolor: alpha(theme.palette.primary.light, 0.2),
|
|
81
|
+
},
|
|
82
|
+
}, children: [_jsx(Box, { children: "Templates" }), _jsx(Box, { component: "i", className: "iconify", "data-icon": "mdi:chevron-down", "data-height": "16px" })] }) }), state.currentView === null && status === 'completed' && (_jsxs(Box, { children: [_jsx(Output, {}), _jsx(Menu, {})] }))] })] }) }));
|
|
83
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TextFieldProps } from '@mui/material';
|
|
2
|
+
import { Parameter } from '../types';
|
|
3
|
+
export default function ParameterField({ parameter, ...props }: {
|
|
4
|
+
parameter: Parameter;
|
|
5
|
+
onChange: (value: string | number | undefined) => void;
|
|
6
|
+
} & Omit<TextFieldProps, 'onChange'>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { TextField, MenuItem } from '@mui/material';
|
|
3
|
+
export default function ParameterField({ parameter, ...props }) {
|
|
4
|
+
const Field = {
|
|
5
|
+
number: NumberParameterField,
|
|
6
|
+
string: StringParameterField,
|
|
7
|
+
select: SelectParameterField,
|
|
8
|
+
language: LanguageParameterField,
|
|
9
|
+
}[parameter.type || 'string'];
|
|
10
|
+
return _jsx(Field, { ...{ parameter }, ...props });
|
|
11
|
+
}
|
|
12
|
+
function StringParameterField({ parameter, onChange, ...props }) {
|
|
13
|
+
return (_jsx(TextField, { required: parameter.required, label: parameter.label, placeholder: parameter.placeholder, helperText: parameter.helper, multiline: parameter.multiline, minRows: parameter.multiline ? 2 : undefined, onChange: (e) => onChange(e.target.value), ...props, slotProps: {
|
|
14
|
+
htmlInput: { maxLength: parameter.maxLength },
|
|
15
|
+
} }));
|
|
16
|
+
}
|
|
17
|
+
function NumberParameterField({ parameter, ...props }) {
|
|
18
|
+
return (_jsx(NumberField, { required: parameter.required, label: parameter.label, placeholder: parameter.placeholder, helperText: parameter.helper, min: parameter.min, max: parameter.max, ...props }));
|
|
19
|
+
}
|
|
20
|
+
function SelectParameterField({ parameter, onChange, ...props }) {
|
|
21
|
+
return (_jsxs(TextField, { required: parameter.required, label: parameter.label, placeholder: parameter.placeholder, helperText: parameter.helper, select: true,
|
|
22
|
+
// SelectProps={{ MenuProps: { keepMounted: false, disablePortal: false } }}
|
|
23
|
+
onChange: (e) => onChange(e.target.value), ...props, slotProps: {
|
|
24
|
+
select: {
|
|
25
|
+
MenuProps: { disablePortal: true },
|
|
26
|
+
},
|
|
27
|
+
}, children: [_jsx(MenuItem, { value: "", children: _jsx("em", { children: "None" }) }), (parameter.options ?? []).map((option) => (_jsx(MenuItem, { value: option.value, children: option.label }, option.id)))] }));
|
|
28
|
+
}
|
|
29
|
+
const languages = [
|
|
30
|
+
{ en: 'English', cn: '英语' },
|
|
31
|
+
{ en: 'Simplified Chinese', cn: '中文-简体' },
|
|
32
|
+
{ en: 'Traditional Chinese', cn: '中文-繁体' },
|
|
33
|
+
{ en: 'Spanish', cn: '西班牙语' },
|
|
34
|
+
{ en: 'French', cn: '法语' },
|
|
35
|
+
{ en: 'German', cn: '德语' },
|
|
36
|
+
{ en: 'Italian', cn: '意大利语' },
|
|
37
|
+
{ en: 'Portuguese', cn: '葡萄牙语' },
|
|
38
|
+
{ en: 'Japanese', cn: '日语' },
|
|
39
|
+
{ en: 'Korean', cn: '韩语' },
|
|
40
|
+
{ en: 'Russian', cn: '俄语' },
|
|
41
|
+
{ en: 'Polish', cn: '波兰语' },
|
|
42
|
+
{ en: 'Arabic', cn: '阿拉伯语' },
|
|
43
|
+
{ en: 'Dutch', cn: '荷兰语' },
|
|
44
|
+
{ en: 'Swedish', cn: '瑞典语' },
|
|
45
|
+
{ en: 'Finnish', cn: '芬兰语' },
|
|
46
|
+
{ en: 'Czech', cn: '捷克语' },
|
|
47
|
+
{ en: 'Danish', cn: '丹麦语' },
|
|
48
|
+
{ en: 'Greek', cn: '希腊语' },
|
|
49
|
+
{ en: 'Romanian', cn: '罗马尼亚语' },
|
|
50
|
+
{ en: 'Hungarian', cn: '匈牙利语' },
|
|
51
|
+
{ en: 'Bulgarian', cn: '保加利亚语' },
|
|
52
|
+
{ en: 'Slovak', cn: '斯洛伐克语' },
|
|
53
|
+
{ en: 'Norwegian', cn: '挪威语' },
|
|
54
|
+
{ en: 'Hebrew', cn: '希伯来语' },
|
|
55
|
+
{ en: 'Turkish', cn: '土耳其语' },
|
|
56
|
+
{ en: 'Thai', cn: '泰语' },
|
|
57
|
+
{ en: 'Indonesian', cn: '印尼语' },
|
|
58
|
+
{ en: 'Vietnamese', cn: '越南语' },
|
|
59
|
+
{ en: 'Hindi', cn: '印地语' },
|
|
60
|
+
];
|
|
61
|
+
function LanguageParameterField({ parameter, onChange, ...props }) {
|
|
62
|
+
return (_jsxs(TextField, { required: parameter.required, label: parameter.label, placeholder: parameter.placeholder, helperText: parameter.helper, select: true, onChange: (e) => onChange(e.target.value), ...props, children: [_jsx(MenuItem, { value: "", children: _jsx("em", { children: "None" }) }), languages.map((option) => (_jsx(MenuItem, { value: option.en, children: option.en }, option.en)))] }));
|
|
63
|
+
}
|
|
64
|
+
function NumberField({ min, max, default: def, onChange, ...props }) {
|
|
65
|
+
const correctValue = (e) => {
|
|
66
|
+
const value = e.target.value.trim();
|
|
67
|
+
if (!value) {
|
|
68
|
+
return def;
|
|
69
|
+
}
|
|
70
|
+
let num = Number(Number(value).toFixed(0));
|
|
71
|
+
if (!Number.isInteger(num)) {
|
|
72
|
+
return def;
|
|
73
|
+
}
|
|
74
|
+
if (typeof min === 'number') {
|
|
75
|
+
num = Math.max(min, num);
|
|
76
|
+
}
|
|
77
|
+
if (typeof max === 'number') {
|
|
78
|
+
num = Math.min(max, num);
|
|
79
|
+
}
|
|
80
|
+
return num;
|
|
81
|
+
};
|
|
82
|
+
return (_jsx(TextField, { onChange: (e) => onChange?.(correctValue(e)), ...props, slotProps: {
|
|
83
|
+
htmlInput: {
|
|
84
|
+
type: 'number',
|
|
85
|
+
inputMode: 'numeric',
|
|
86
|
+
pattern: '[0-9]*',
|
|
87
|
+
min,
|
|
88
|
+
max,
|
|
89
|
+
...props.inputProps,
|
|
90
|
+
},
|
|
91
|
+
} }));
|
|
92
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useRequest } from 'ahooks';
|
|
2
|
+
import { useEditorConfig } from '../../config';
|
|
3
|
+
/**
|
|
4
|
+
* 检查 ai 是否可用
|
|
5
|
+
* 注意: 该 hook 可适用于无法使用 useAideContext 的场景, 比如 editor toolbar button 中
|
|
6
|
+
*/
|
|
7
|
+
export function useAIAvailable() {
|
|
8
|
+
const { AI } = useEditorConfig();
|
|
9
|
+
const { data } = useRequest(async () => {
|
|
10
|
+
const available = await AI?.checkAvailable();
|
|
11
|
+
return available;
|
|
12
|
+
}, { cacheKey: 'editor-aide-available', staleTime: -1 });
|
|
13
|
+
return { available: !!data };
|
|
14
|
+
}
|