@lobehub/editor 4.5.0 → 4.6.1
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/es/ReactSlashPlugin-GxCNaj2T.js +22911 -0
- package/es/index-BfKEHYDe.d.ts +889 -0
- package/es/index.d.ts +2826 -32
- package/es/index.js +7587 -65
- package/es/react.d.ts +335 -0
- package/es/react.js +1573 -0
- package/es/renderer.d.ts +110 -0
- package/es/renderer.js +1254 -0
- package/es/style-CFkese2R.js +999 -0
- package/es/style-Ub1LiKko.js +3005 -0
- package/package.json +37 -27
- package/es/common/canUseDOM.d.ts +0 -8
- package/es/common/canUseDOM.js +0 -9
- package/es/common/sys.d.ts +0 -19
- package/es/common/sys.js +0 -35
- package/es/const/hotkey.d.ts +0 -3
- package/es/const/hotkey.js +0 -63
- package/es/editor-kernel/data-source.d.ts +0 -11
- package/es/editor-kernel/data-source.js +0 -30
- package/es/editor-kernel/event.d.ts +0 -3
- package/es/editor-kernel/event.js +0 -11
- package/es/editor-kernel/index.d.ts +0 -12
- package/es/editor-kernel/index.js +0 -16
- package/es/editor-kernel/inode/helper.d.ts +0 -17
- package/es/editor-kernel/inode/helper.js +0 -89
- package/es/editor-kernel/inode/i-element-node.d.ts +0 -2
- package/es/editor-kernel/inode/i-element-node.js +0 -1
- package/es/editor-kernel/inode/i-node.d.ts +0 -2
- package/es/editor-kernel/inode/i-node.js +0 -1
- package/es/editor-kernel/inode/index.d.ts +0 -5
- package/es/editor-kernel/inode/index.js +0 -5
- package/es/editor-kernel/inode/paragraph-node.d.ts +0 -6
- package/es/editor-kernel/inode/paragraph-node.js +0 -1
- package/es/editor-kernel/inode/root-node.d.ts +0 -5
- package/es/editor-kernel/inode/root-node.js +0 -1
- package/es/editor-kernel/inode/text-node.d.ts +0 -5
- package/es/editor-kernel/inode/text-node.js +0 -1
- package/es/editor-kernel/kernel.d.ts +0 -107
- package/es/editor-kernel/kernel.js +0 -875
- package/es/editor-kernel/lexical/Lexical.dev.js +0 -3052
- package/es/editor-kernel/lexical/Lexical.dev.mjs +0 -15369
- package/es/editor-kernel/lexical/Lexical.js +0 -7634
- package/es/editor-kernel/lexical/Lexical.mjs +0 -7258
- package/es/editor-kernel/lexical/LexicalCommands.d.ts +0 -175
- package/es/editor-kernel/lexical/LexicalConstants.d.ts +0 -54
- package/es/editor-kernel/lexical/LexicalEditor.d.ts +0 -672
- package/es/editor-kernel/lexical/LexicalEditorState.d.ts +0 -39
- package/es/editor-kernel/lexical/LexicalEvents.d.ts +0 -22
- package/es/editor-kernel/lexical/LexicalGC.d.ts +0 -23
- package/es/editor-kernel/lexical/LexicalMutations.d.ts +0 -12
- package/es/editor-kernel/lexical/LexicalNode.d.ts +0 -689
- package/es/editor-kernel/lexical/LexicalNodeState.d.ts +0 -569
- package/es/editor-kernel/lexical/LexicalNormalization.d.ts +0 -11
- package/es/editor-kernel/lexical/LexicalReconciler.d.ts +0 -28
- package/es/editor-kernel/lexical/LexicalSelection.d.ts +0 -368
- package/es/editor-kernel/lexical/LexicalUpdateTags.d.ts +0 -67
- package/es/editor-kernel/lexical/LexicalUpdates.d.ts +0 -72
- package/es/editor-kernel/lexical/LexicalUtils.d.ts +0 -492
- package/es/editor-kernel/lexical/caret/LexicalCaret.d.ts +0 -635
- package/es/editor-kernel/lexical/caret/LexicalCaretUtils.d.ts +0 -224
- package/es/editor-kernel/lexical/extension-core/defineExtension.d.ts +0 -126
- package/es/editor-kernel/lexical/extension-core/index.d.ts +0 -38
- package/es/editor-kernel/lexical/extension-core/internal.d.ts +0 -32
- package/es/editor-kernel/lexical/extension-core/safeCast.d.ts +0 -15
- package/es/editor-kernel/lexical/extension-core/shallowMergeConfig.d.ts +0 -20
- package/es/editor-kernel/lexical/extension-core/types.d.ts +0 -371
- package/es/editor-kernel/lexical/index.d.ts +0 -368
- package/es/editor-kernel/lexical/nodes/ArtificialNode.d.ts +0 -16
- package/es/editor-kernel/lexical/nodes/LexicalDecoratorNode.d.ts +0 -32
- package/es/editor-kernel/lexical/nodes/LexicalElementNode.d.ts +0 -235
- package/es/editor-kernel/lexical/nodes/LexicalLineBreakNode.d.ts +0 -30
- package/es/editor-kernel/lexical/nodes/LexicalParagraphNode.d.ts +0 -39
- package/es/editor-kernel/lexical/nodes/LexicalRootNode.d.ts +0 -35
- package/es/editor-kernel/lexical/nodes/LexicalTabNode.d.ts +0 -30
- package/es/editor-kernel/lexical/nodes/LexicalTextNode.d.ts +0 -311
- package/es/editor-kernel/plugin.d.ts +0 -21
- package/es/editor-kernel/plugin.js +0 -90
- package/es/editor-kernel/react/LexicalErrorBoundary.d.ts +0 -13
- package/es/editor-kernel/react/LexicalErrorBoundary.js +0 -26
- package/es/editor-kernel/react/PortalAnchor.d.ts +0 -6
- package/es/editor-kernel/react/PortalAnchor.js +0 -12
- package/es/editor-kernel/react/PortalContainer.d.ts +0 -11
- package/es/editor-kernel/react/PortalContainer.js +0 -32
- package/es/editor-kernel/react/index.d.ts +0 -5
- package/es/editor-kernel/react/index.js +0 -5
- package/es/editor-kernel/react/react-context.d.ts +0 -10
- package/es/editor-kernel/react/react-context.js +0 -25
- package/es/editor-kernel/react/react-editor.d.ts +0 -15
- package/es/editor-kernel/react/react-editor.js +0 -52
- package/es/editor-kernel/react/useAnchor.d.ts +0 -1
- package/es/editor-kernel/react/useAnchor.js +0 -27
- package/es/editor-kernel/react/useDecorators.d.ts +0 -9
- package/es/editor-kernel/react/useDecorators.js +0 -80
- package/es/editor-kernel/react/useEditable.d.ts +0 -3
- package/es/editor-kernel/react/useEditable.js +0 -37
- package/es/editor-kernel/react/useLexicalEditor.d.ts +0 -2
- package/es/editor-kernel/react/useLexicalEditor.js +0 -31
- package/es/editor-kernel/react/useLexicalNodeSelection.d.ts +0 -17
- package/es/editor-kernel/react/useLexicalNodeSelection.js +0 -120
- package/es/editor-kernel/react/useTranslation.d.ts +0 -3
- package/es/editor-kernel/react/useTranslation.js +0 -19
- package/es/editor-kernel/types.d.ts +0 -0
- package/es/editor-kernel/types.js +0 -0
- package/es/editor-kernel/utils.d.ts +0 -41
- package/es/editor-kernel/utils.js +0 -167
- package/es/global.d.ts +0 -5
- package/es/locale/index.d.ts +0 -57
- package/es/locale/index.js +0 -56
- package/es/plugins/auto-complete/index.d.ts +0 -2
- package/es/plugins/auto-complete/index.js +0 -2
- package/es/plugins/auto-complete/node/placeholderNode.d.ts +0 -30
- package/es/plugins/auto-complete/node/placeholderNode.js +0 -171
- package/es/plugins/auto-complete/plugin/index.d.ts +0 -17
- package/es/plugins/auto-complete/plugin/index.js +0 -400
- package/es/plugins/auto-complete/react/ReactAutoCompletePlugin.d.ts +0 -4
- package/es/plugins/auto-complete/react/ReactAutoCompletePlugin.js +0 -33
- package/es/plugins/auto-complete/react/index.d.ts +0 -1
- package/es/plugins/auto-complete/react/index.js +0 -1
- package/es/plugins/auto-complete/react/style.d.ts +0 -4
- package/es/plugins/auto-complete/react/style.js +0 -10
- package/es/plugins/auto-complete/react/type.d.ts +0 -11
- package/es/plugins/auto-complete/react/type.js +0 -1
- package/es/plugins/code/command/index.d.ts +0 -3
- package/es/plugins/code/command/index.js +0 -48
- package/es/plugins/code/index.d.ts +0 -3
- package/es/plugins/code/index.js +0 -3
- package/es/plugins/code/node/code.d.ts +0 -21
- package/es/plugins/code/node/code.js +0 -167
- package/es/plugins/code/plugin/index.d.ts +0 -6
- package/es/plugins/code/plugin/index.js +0 -112
- package/es/plugins/code/plugin/registry.d.ts +0 -6
- package/es/plugins/code/plugin/registry.js +0 -59
- package/es/plugins/code/react/CodeReactPlugin.d.ts +0 -4
- package/es/plugins/code/react/CodeReactPlugin.js +0 -32
- package/es/plugins/code/react/index.d.ts +0 -1
- package/es/plugins/code/react/index.js +0 -1
- package/es/plugins/code/react/style.d.ts +0 -3
- package/es/plugins/code/react/style.js +0 -10
- package/es/plugins/code/react/type.d.ts +0 -4
- package/es/plugins/code/react/type.js +0 -1
- package/es/plugins/codeblock/command/index.d.ts +0 -17
- package/es/plugins/codeblock/command/index.js +0 -49
- package/es/plugins/codeblock/index.d.ts +0 -4
- package/es/plugins/codeblock/index.js +0 -4
- package/es/plugins/codeblock/plugin/CodeHighlighterShiki.d.ts +0 -25
- package/es/plugins/codeblock/plugin/CodeHighlighterShiki.js +0 -736
- package/es/plugins/codeblock/plugin/FacadeShiki.d.ts +0 -53
- package/es/plugins/codeblock/plugin/FacadeShiki.js +0 -380
- package/es/plugins/codeblock/plugin/index.d.ts +0 -13
- package/es/plugins/codeblock/plugin/index.js +0 -229
- package/es/plugins/codeblock/plugin/invariant.d.ts +0 -8
- package/es/plugins/codeblock/plugin/invariant.js +0 -17
- package/es/plugins/codeblock/react/ReactCodeblockPlugin.d.ts +0 -4
- package/es/plugins/codeblock/react/ReactCodeblockPlugin.js +0 -34
- package/es/plugins/codeblock/react/index.d.ts +0 -2
- package/es/plugins/codeblock/react/index.js +0 -1
- package/es/plugins/codeblock/react/style.d.ts +0 -4
- package/es/plugins/codeblock/react/style.js +0 -11
- package/es/plugins/codeblock/react/type.d.ts +0 -5
- package/es/plugins/codeblock/react/type.js +0 -1
- package/es/plugins/codeblock/utils/language.d.ts +0 -1
- package/es/plugins/codeblock/utils/language.js +0 -12
- package/es/plugins/codemirror-block/command/index.d.ts +0 -9
- package/es/plugins/codemirror-block/command/index.js +0 -92
- package/es/plugins/codemirror-block/index.d.ts +0 -3
- package/es/plugins/codemirror-block/index.js +0 -7
- package/es/plugins/codemirror-block/lib/index.d.ts +0 -63
- package/es/plugins/codemirror-block/lib/index.js +0 -146
- package/es/plugins/codemirror-block/lib/mode.d.ts +0 -25
- package/es/plugins/codemirror-block/lib/mode.js +0 -416
- package/es/plugins/codemirror-block/node/CodeMirrorNode.d.ts +0 -46
- package/es/plugins/codemirror-block/node/CodeMirrorNode.js +0 -343
- package/es/plugins/codemirror-block/plugin/index.d.ts +0 -8
- package/es/plugins/codemirror-block/plugin/index.js +0 -113
- package/es/plugins/codemirror-block/react/CodemirrorNode.d.ts +0 -10
- package/es/plugins/codemirror-block/react/CodemirrorNode.js +0 -345
- package/es/plugins/codemirror-block/react/ReactCodemirrorNode.d.ts +0 -4
- package/es/plugins/codemirror-block/react/ReactCodemirrorNode.js +0 -34
- package/es/plugins/codemirror-block/react/components/CopyButton.d.ts +0 -5
- package/es/plugins/codemirror-block/react/components/CopyButton.js +0 -35
- package/es/plugins/codemirror-block/react/components/LanguageSelect.d.ts +0 -8
- package/es/plugins/codemirror-block/react/components/LanguageSelect.js +0 -77
- package/es/plugins/codemirror-block/react/components/MoreOptions.d.ts +0 -16
- package/es/plugins/codemirror-block/react/components/MoreOptions.js +0 -79
- package/es/plugins/codemirror-block/react/components/Toolbar.d.ts +0 -16
- package/es/plugins/codemirror-block/react/components/Toolbar.js +0 -56
- package/es/plugins/codemirror-block/react/components/style.d.ts +0 -3
- package/es/plugins/codemirror-block/react/components/style.js +0 -9
- package/es/plugins/codemirror-block/react/index.d.ts +0 -1
- package/es/plugins/codemirror-block/react/index.js +0 -1
- package/es/plugins/codemirror-block/react/style.d.ts +0 -1
- package/es/plugins/codemirror-block/react/style.js +0 -8
- package/es/plugins/codemirror-block/react/theme.d.ts +0 -133
- package/es/plugins/codemirror-block/react/theme.js +0 -158
- package/es/plugins/codemirror-block/react/type.d.ts +0 -3
- package/es/plugins/codemirror-block/react/type.js +0 -1
- package/es/plugins/common/command/index.d.ts +0 -7
- package/es/plugins/common/command/index.js +0 -31
- package/es/plugins/common/data-source/json-data-source.d.ts +0 -7
- package/es/plugins/common/data-source/json-data-source.js +0 -219
- package/es/plugins/common/data-source/text-data-source.d.ts +0 -7
- package/es/plugins/common/data-source/text-data-source.js +0 -60
- package/es/plugins/common/index.d.ts +0 -4
- package/es/plugins/common/index.js +0 -4
- package/es/plugins/common/node/ElementDOMSlot.d.ts +0 -3
- package/es/plugins/common/node/ElementDOMSlot.js +0 -33
- package/es/plugins/common/node/cursor.d.ts +0 -14
- package/es/plugins/common/node/cursor.js +0 -332
- package/es/plugins/common/plugin/index.d.ts +0 -39
- package/es/plugins/common/plugin/index.js +0 -553
- package/es/plugins/common/plugin/mdReader.d.ts +0 -2
- package/es/plugins/common/plugin/mdReader.js +0 -84
- package/es/plugins/common/plugin/paste-handler.d.ts +0 -37
- package/es/plugins/common/plugin/paste-handler.js +0 -140
- package/es/plugins/common/plugin/register.d.ts +0 -10
- package/es/plugins/common/plugin/register.js +0 -407
- package/es/plugins/common/react/Placeholder/index.d.ts +0 -8
- package/es/plugins/common/react/Placeholder/index.js +0 -92
- package/es/plugins/common/react/Placeholder/style.d.ts +0 -4
- package/es/plugins/common/react/Placeholder/style.js +0 -12
- package/es/plugins/common/react/ReactEditorContent.d.ts +0 -4
- package/es/plugins/common/react/ReactEditorContent.js +0 -7
- package/es/plugins/common/react/ReactPlainText.d.ts +0 -4
- package/es/plugins/common/react/ReactPlainText.js +0 -244
- package/es/plugins/common/react/index.d.ts +0 -3
- package/es/plugins/common/react/index.js +0 -3
- package/es/plugins/common/react/style.d.ts +0 -23
- package/es/plugins/common/react/style.js +0 -41
- package/es/plugins/common/react/type.d.ts +0 -90
- package/es/plugins/common/react/type.js +0 -1
- package/es/plugins/common/utils/index.d.ts +0 -35
- package/es/plugins/common/utils/index.js +0 -198
- package/es/plugins/file/command/index.d.ts +0 -7
- package/es/plugins/file/command/index.js +0 -30
- package/es/plugins/file/index.d.ts +0 -3
- package/es/plugins/file/index.js +0 -3
- package/es/plugins/file/node/FileNode.d.ts +0 -36
- package/es/plugins/file/node/FileNode.js +0 -187
- package/es/plugins/file/plugin/index.d.ts +0 -14
- package/es/plugins/file/plugin/index.js +0 -164
- package/es/plugins/file/react/ReactFilePlugin.d.ts +0 -4
- package/es/plugins/file/react/ReactFilePlugin.js +0 -72
- package/es/plugins/file/react/components/ReactFile.d.ts +0 -10
- package/es/plugins/file/react/components/ReactFile.js +0 -64
- package/es/plugins/file/react/index.d.ts +0 -2
- package/es/plugins/file/react/index.js +0 -1
- package/es/plugins/file/react/style.d.ts +0 -3
- package/es/plugins/file/react/style.js +0 -11
- package/es/plugins/file/react/type.d.ts +0 -13
- package/es/plugins/file/react/type.js +0 -1
- package/es/plugins/file/utils/index.d.ts +0 -2
- package/es/plugins/file/utils/index.js +0 -45
- package/es/plugins/hr/command/index.d.ts +0 -3
- package/es/plugins/hr/command/index.js +0 -13
- package/es/plugins/hr/index.d.ts +0 -3
- package/es/plugins/hr/index.js +0 -3
- package/es/plugins/hr/node/HorizontalRuleNode.d.ts +0 -16
- package/es/plugins/hr/node/HorizontalRuleNode.js +0 -110
- package/es/plugins/hr/plugin/index.d.ts +0 -8
- package/es/plugins/hr/plugin/index.js +0 -98
- package/es/plugins/hr/react/ReactHRPlugin.d.ts +0 -4
- package/es/plugins/hr/react/ReactHRPlugin.js +0 -36
- package/es/plugins/hr/react/components/HRNode.d.ts +0 -10
- package/es/plugins/hr/react/components/HRNode.js +0 -44
- package/es/plugins/hr/react/index.d.ts +0 -2
- package/es/plugins/hr/react/index.js +0 -1
- package/es/plugins/hr/react/style.d.ts +0 -1
- package/es/plugins/hr/react/style.js +0 -8
- package/es/plugins/hr/react/type.d.ts +0 -3
- package/es/plugins/hr/react/type.js +0 -1
- package/es/plugins/image/command/index.d.ts +0 -10
- package/es/plugins/image/command/index.js +0 -60
- package/es/plugins/image/index.d.ts +0 -3
- package/es/plugins/image/index.js +0 -3
- package/es/plugins/image/node/basie-image-node.d.ts +0 -39
- package/es/plugins/image/node/basie-image-node.js +0 -131
- package/es/plugins/image/node/block-image-node.d.ts +0 -41
- package/es/plugins/image/node/block-image-node.js +0 -228
- package/es/plugins/image/node/image-node.d.ts +0 -39
- package/es/plugins/image/node/image-node.js +0 -212
- package/es/plugins/image/plugin/index.d.ts +0 -20
- package/es/plugins/image/plugin/index.js +0 -273
- package/es/plugins/image/react/ReactImagePlugin.d.ts +0 -4
- package/es/plugins/image/react/ReactImagePlugin.js +0 -57
- package/es/plugins/image/react/components/BrokenImage.d.ts +0 -3
- package/es/plugins/image/react/components/BrokenImage.js +0 -15
- package/es/plugins/image/react/components/Image.d.ts +0 -15
- package/es/plugins/image/react/components/Image.js +0 -265
- package/es/plugins/image/react/components/ImageEditPopover.d.ts +0 -17
- package/es/plugins/image/react/components/ImageEditPopover.js +0 -257
- package/es/plugins/image/react/components/LazyImage.d.ts +0 -15
- package/es/plugins/image/react/components/LazyImage.js +0 -109
- package/es/plugins/image/react/components/ResizeHandle.d.ts +0 -10
- package/es/plugins/image/react/components/ResizeHandle.js +0 -73
- package/es/plugins/image/react/components/style.d.ts +0 -10
- package/es/plugins/image/react/components/style.js +0 -17
- package/es/plugins/image/react/components/useSupenseImage.d.ts +0 -2
- package/es/plugins/image/react/components/useSupenseImage.js +0 -24
- package/es/plugins/image/react/index.d.ts +0 -2
- package/es/plugins/image/react/index.js +0 -1
- package/es/plugins/image/react/style.d.ts +0 -5
- package/es/plugins/image/react/style.js +0 -13
- package/es/plugins/image/react/type.d.ts +0 -20
- package/es/plugins/image/react/type.js +0 -1
- package/es/plugins/inode/index.d.ts +0 -3
- package/es/plugins/inode/index.js +0 -3
- package/es/plugins/inode/plugin/index.d.ts +0 -16
- package/es/plugins/inode/plugin/index.js +0 -49
- package/es/plugins/inode/react/index.d.ts +0 -3
- package/es/plugins/inode/react/index.js +0 -22
- package/es/plugins/inode/service/index.d.ts +0 -25
- package/es/plugins/inode/service/index.js +0 -49
- package/es/plugins/link/command/index.d.ts +0 -10
- package/es/plugins/link/command/index.js +0 -38
- package/es/plugins/link/index.d.ts +0 -4
- package/es/plugins/link/index.js +0 -4
- package/es/plugins/link/node/LinkNode.d.ts +0 -126
- package/es/plugins/link/node/LinkNode.js +0 -723
- package/es/plugins/link/plugin/index.d.ts +0 -12
- package/es/plugins/link/plugin/index.js +0 -157
- package/es/plugins/link/plugin/registry.d.ts +0 -9
- package/es/plugins/link/plugin/registry.js +0 -108
- package/es/plugins/link/react/ReactLinkPlugin.d.ts +0 -4
- package/es/plugins/link/react/ReactLinkPlugin.js +0 -64
- package/es/plugins/link/react/components/LinkEdit.d.ts +0 -12
- package/es/plugins/link/react/components/LinkEdit.js +0 -262
- package/es/plugins/link/react/components/LinkToolbar.d.ts +0 -8
- package/es/plugins/link/react/components/LinkToolbar.js +0 -183
- package/es/plugins/link/react/index.d.ts +0 -2
- package/es/plugins/link/react/index.js +0 -1
- package/es/plugins/link/react/style.d.ts +0 -6
- package/es/plugins/link/react/style.js +0 -14
- package/es/plugins/link/react/type.d.ts +0 -10
- package/es/plugins/link/react/type.js +0 -1
- package/es/plugins/link/service/i-link-service.d.ts +0 -11
- package/es/plugins/link/service/i-link-service.js +0 -46
- package/es/plugins/link/utils/index.d.ts +0 -9
- package/es/plugins/link/utils/index.js +0 -51
- package/es/plugins/link-highlight/command/index.d.ts +0 -3
- package/es/plugins/link-highlight/command/index.js +0 -48
- package/es/plugins/link-highlight/index.d.ts +0 -3
- package/es/plugins/link-highlight/index.js +0 -4
- package/es/plugins/link-highlight/node/link-highlight.d.ts +0 -25
- package/es/plugins/link-highlight/node/link-highlight.js +0 -179
- package/es/plugins/link-highlight/plugin/index.d.ts +0 -15
- package/es/plugins/link-highlight/plugin/index.js +0 -185
- package/es/plugins/link-highlight/plugin/registry.d.ts +0 -6
- package/es/plugins/link-highlight/plugin/registry.js +0 -61
- package/es/plugins/link-highlight/react/ReactLinkHighlightPlugin.d.ts +0 -4
- package/es/plugins/link-highlight/react/ReactLinkHighlightPlugin.js +0 -33
- package/es/plugins/link-highlight/react/index.d.ts +0 -1
- package/es/plugins/link-highlight/react/index.js +0 -1
- package/es/plugins/link-highlight/react/style.d.ts +0 -3
- package/es/plugins/link-highlight/react/style.js +0 -9
- package/es/plugins/link-highlight/react/type.d.ts +0 -13
- package/es/plugins/link-highlight/react/type.js +0 -1
- package/es/plugins/link-highlight/utils/index.d.ts +0 -17
- package/es/plugins/link-highlight/utils/index.js +0 -43
- package/es/plugins/list/command/index.d.ts +0 -2
- package/es/plugins/list/command/index.js +0 -2
- package/es/plugins/list/index.d.ts +0 -3
- package/es/plugins/list/index.js +0 -3
- package/es/plugins/list/plugin/checkList.d.ts +0 -3
- package/es/plugins/list/plugin/checkList.js +0 -167
- package/es/plugins/list/plugin/index.d.ts +0 -6
- package/es/plugins/list/plugin/index.js +0 -253
- package/es/plugins/list/plugin/registry.d.ts +0 -6
- package/es/plugins/list/plugin/registry.js +0 -98
- package/es/plugins/list/react/ReactListPlugin.d.ts +0 -4
- package/es/plugins/list/react/ReactListPlugin.js +0 -30
- package/es/plugins/list/react/index.d.ts +0 -2
- package/es/plugins/list/react/index.js +0 -1
- package/es/plugins/list/react/style.d.ts +0 -1
- package/es/plugins/list/react/style.js +0 -8
- package/es/plugins/list/react/type.d.ts +0 -4
- package/es/plugins/list/react/type.js +0 -1
- package/es/plugins/list/utils/index.d.ts +0 -5
- package/es/plugins/list/utils/index.js +0 -88
- package/es/plugins/litexml/command/diffCommand.d.ts +0 -13
- package/es/plugins/litexml/command/diffCommand.js +0 -119
- package/es/plugins/litexml/command/index.d.ts +0 -35
- package/es/plugins/litexml/command/index.js +0 -499
- package/es/plugins/litexml/data-source/litexml-data-source.d.ts +0 -62
- package/es/plugins/litexml/data-source/litexml-data-source.js +0 -459
- package/es/plugins/litexml/index.d.ts +0 -9
- package/es/plugins/litexml/index.js +0 -7
- package/es/plugins/litexml/node/DiffNode.d.ts +0 -27
- package/es/plugins/litexml/node/DiffNode.js +0 -164
- package/es/plugins/litexml/plugin/index.d.ts +0 -20
- package/es/plugins/litexml/plugin/index.js +0 -157
- package/es/plugins/litexml/react/DiffNodeToolbar/index.d.ts +0 -10
- package/es/plugins/litexml/react/DiffNodeToolbar/index.js +0 -62
- package/es/plugins/litexml/react/DiffNodeToolbar/style.d.ts +0 -6
- package/es/plugins/litexml/react/DiffNodeToolbar/style.js +0 -13
- package/es/plugins/litexml/react/hooks/useHasDiffNode.d.ts +0 -4
- package/es/plugins/litexml/react/hooks/useHasDiffNode.js +0 -70
- package/es/plugins/litexml/react/index.d.ts +0 -3
- package/es/plugins/litexml/react/index.js +0 -35
- package/es/plugins/litexml/react/style.d.ts +0 -1
- package/es/plugins/litexml/react/style.js +0 -8
- package/es/plugins/litexml/service/litexml-service.d.ts +0 -88
- package/es/plugins/litexml/service/litexml-service.js +0 -101
- package/es/plugins/litexml/utils/index.d.ts +0 -6
- package/es/plugins/litexml/utils/index.js +0 -87
- package/es/plugins/markdown/command/index.d.ts +0 -12
- package/es/plugins/markdown/command/index.js +0 -87
- package/es/plugins/markdown/data-source/markdown/parse.d.ts +0 -21
- package/es/plugins/markdown/data-source/markdown/parse.js +0 -244
- package/es/plugins/markdown/data-source/markdown/supersub.d.ts +0 -1
- package/es/plugins/markdown/data-source/markdown/supersub.js +0 -14
- package/es/plugins/markdown/data-source/markdown-data-source.d.ts +0 -14
- package/es/plugins/markdown/data-source/markdown-data-source.js +0 -248
- package/es/plugins/markdown/data-source/markdown-writer-context.d.ts +0 -16
- package/es/plugins/markdown/data-source/markdown-writer-context.js +0 -76
- package/es/plugins/markdown/index.d.ts +0 -8
- package/es/plugins/markdown/index.js +0 -7
- package/es/plugins/markdown/plugin/index.d.ts +0 -19
- package/es/plugins/markdown/plugin/index.js +0 -389
- package/es/plugins/markdown/react/index.d.ts +0 -3
- package/es/plugins/markdown/react/index.js +0 -38
- package/es/plugins/markdown/service/shortcut.d.ts +0 -90
- package/es/plugins/markdown/service/shortcut.js +0 -185
- package/es/plugins/markdown/service/transformers.d.ts +0 -60
- package/es/plugins/markdown/service/transformers.js +0 -298
- package/es/plugins/markdown/utils/detectLanguage.d.ts +0 -20
- package/es/plugins/markdown/utils/detectLanguage.js +0 -267
- package/es/plugins/markdown/utils/index.d.ts +0 -64
- package/es/plugins/markdown/utils/index.js +0 -223
- package/es/plugins/markdown/utils/logger.d.ts +0 -7
- package/es/plugins/markdown/utils/logger.js +0 -2
- package/es/plugins/markdown/utils/url-validator.d.ts +0 -4
- package/es/plugins/markdown/utils/url-validator.js +0 -6
- package/es/plugins/math/command/index.d.ts +0 -13
- package/es/plugins/math/command/index.js +0 -47
- package/es/plugins/math/index.d.ts +0 -3
- package/es/plugins/math/index.js +0 -3
- package/es/plugins/math/node/index.d.ts +0 -45
- package/es/plugins/math/node/index.js +0 -279
- package/es/plugins/math/plugin/index.d.ts +0 -11
- package/es/plugins/math/plugin/index.js +0 -166
- package/es/plugins/math/react/components/MathEditor.d.ts +0 -10
- package/es/plugins/math/react/components/MathEditor.js +0 -299
- package/es/plugins/math/react/components/MathEditorContainer.d.ts +0 -15
- package/es/plugins/math/react/components/MathEditorContainer.js +0 -112
- package/es/plugins/math/react/components/MathEditorContent.d.ts +0 -28
- package/es/plugins/math/react/components/MathEditorContent.js +0 -161
- package/es/plugins/math/react/components/MathInline.d.ts +0 -10
- package/es/plugins/math/react/components/MathInline.js +0 -136
- package/es/plugins/math/react/components/Placeholder.d.ts +0 -6
- package/es/plugins/math/react/components/Placeholder.js +0 -23
- package/es/plugins/math/react/index.d.ts +0 -3
- package/es/plugins/math/react/index.js +0 -41
- package/es/plugins/math/react/style.d.ts +0 -9
- package/es/plugins/math/react/style.js +0 -18
- package/es/plugins/math/react/type.d.ts +0 -13
- package/es/plugins/math/react/type.js +0 -1
- package/es/plugins/math/utils/index.d.ts +0 -13
- package/es/plugins/math/utils/index.js +0 -26
- package/es/plugins/mention/command/index.d.ts +0 -6
- package/es/plugins/mention/command/index.js +0 -20
- package/es/plugins/mention/index.d.ts +0 -4
- package/es/plugins/mention/index.js +0 -3
- package/es/plugins/mention/node/MentionNode.d.ts +0 -26
- package/es/plugins/mention/node/MentionNode.js +0 -153
- package/es/plugins/mention/plugin/index.d.ts +0 -14
- package/es/plugins/mention/plugin/index.js +0 -103
- package/es/plugins/mention/plugin/register.d.ts +0 -2
- package/es/plugins/mention/plugin/register.js +0 -46
- package/es/plugins/mention/react/ReactMentionPlugin.d.ts +0 -4
- package/es/plugins/mention/react/ReactMentionPlugin.js +0 -40
- package/es/plugins/mention/react/components/Mention.d.ts +0 -10
- package/es/plugins/mention/react/components/Mention.js +0 -40
- package/es/plugins/mention/react/index.d.ts +0 -2
- package/es/plugins/mention/react/index.js +0 -1
- package/es/plugins/mention/react/style.d.ts +0 -3
- package/es/plugins/mention/react/style.js +0 -11
- package/es/plugins/mention/react/type.d.ts +0 -8
- package/es/plugins/mention/react/type.js +0 -1
- package/es/plugins/slash/index.d.ts +0 -4
- package/es/plugins/slash/index.js +0 -3
- package/es/plugins/slash/plugin/index.d.ts +0 -23
- package/es/plugins/slash/plugin/index.js +0 -159
- package/es/plugins/slash/react/ReactSlashOption.d.ts +0 -4
- package/es/plugins/slash/react/ReactSlashOption.js +0 -7
- package/es/plugins/slash/react/ReactSlashPlugin.d.ts +0 -4
- package/es/plugins/slash/react/ReactSlashPlugin.js +0 -258
- package/es/plugins/slash/react/components/DefaultSlashMenu.d.ts +0 -5
- package/es/plugins/slash/react/components/DefaultSlashMenu.js +0 -141
- package/es/plugins/slash/react/components/SlashMenu.d.ts +0 -8
- package/es/plugins/slash/react/components/SlashMenu.js +0 -56
- package/es/plugins/slash/react/index.d.ts +0 -4
- package/es/plugins/slash/react/index.js +0 -3
- package/es/plugins/slash/react/style.d.ts +0 -1
- package/es/plugins/slash/react/style.js +0 -9
- package/es/plugins/slash/react/type.d.ts +0 -111
- package/es/plugins/slash/react/type.js +0 -1
- package/es/plugins/slash/react/utils.d.ts +0 -5
- package/es/plugins/slash/react/utils.js +0 -20
- package/es/plugins/slash/service/i-slash-service.d.ts +0 -61
- package/es/plugins/slash/service/i-slash-service.js +0 -91
- package/es/plugins/slash/utils/utils.d.ts +0 -38
- package/es/plugins/slash/utils/utils.js +0 -198
- package/es/plugins/table/command/index.d.ts +0 -13
- package/es/plugins/table/command/index.js +0 -73
- package/es/plugins/table/index.d.ts +0 -3
- package/es/plugins/table/index.js +0 -3
- package/es/plugins/table/node/index.d.ts +0 -2
- package/es/plugins/table/node/index.js +0 -16
- package/es/plugins/table/plugin/index.d.ts +0 -5
- package/es/plugins/table/plugin/index.js +0 -232
- package/es/plugins/table/react/TableActionMenu/ActionMenu.d.ts +0 -19
- package/es/plugins/table/react/TableActionMenu/ActionMenu.js +0 -285
- package/es/plugins/table/react/TableActionMenu/index.d.ts +0 -7
- package/es/plugins/table/react/TableActionMenu/index.js +0 -177
- package/es/plugins/table/react/TableActionMenu/style.d.ts +0 -4
- package/es/plugins/table/react/TableActionMenu/style.js +0 -10
- package/es/plugins/table/react/TableActionMenu/utils.d.ts +0 -9
- package/es/plugins/table/react/TableActionMenu/utils.js +0 -49
- package/es/plugins/table/react/TableHoverActions/index.d.ts +0 -6
- package/es/plugins/table/react/TableHoverActions/index.js +0 -249
- package/es/plugins/table/react/TableHoverActions/style.d.ts +0 -5
- package/es/plugins/table/react/TableHoverActions/style.js +0 -11
- package/es/plugins/table/react/TableHoverActions/utils.d.ts +0 -8
- package/es/plugins/table/react/TableHoverActions/utils.js +0 -43
- package/es/plugins/table/react/TableResize/index.d.ts +0 -10
- package/es/plugins/table/react/TableResize/index.js +0 -378
- package/es/plugins/table/react/TableResize/style.d.ts +0 -3
- package/es/plugins/table/react/TableResize/style.js +0 -10
- package/es/plugins/table/react/TableResize/utils.d.ts +0 -4
- package/es/plugins/table/react/TableResize/utils.js +0 -40
- package/es/plugins/table/react/hooks.d.ts +0 -1
- package/es/plugins/table/react/hooks.js +0 -22
- package/es/plugins/table/react/index.d.ts +0 -3
- package/es/plugins/table/react/index.js +0 -78
- package/es/plugins/table/react/style.d.ts +0 -1
- package/es/plugins/table/react/style.js +0 -8
- package/es/plugins/table/react/type.d.ts +0 -5
- package/es/plugins/table/react/type.js +0 -1
- package/es/plugins/table/utils/index.d.ts +0 -8
- package/es/plugins/table/utils/index.js +0 -83
- package/es/plugins/toolbar/command/index.d.ts +0 -8
- package/es/plugins/toolbar/command/index.js +0 -16
- package/es/plugins/toolbar/index.d.ts +0 -2
- package/es/plugins/toolbar/index.js +0 -2
- package/es/plugins/toolbar/react/index.d.ts +0 -3
- package/es/plugins/toolbar/react/index.js +0 -140
- package/es/plugins/toolbar/react/style.d.ts +0 -5
- package/es/plugins/toolbar/react/style.js +0 -12
- package/es/plugins/toolbar/react/type.d.ts +0 -5
- package/es/plugins/toolbar/react/type.js +0 -1
- package/es/plugins/toolbar/utils/getDOMRangeRect.d.ts +0 -8
- package/es/plugins/toolbar/utils/getDOMRangeRect.js +0 -21
- package/es/plugins/toolbar/utils/setFloatingElemPosition.d.ts +0 -1
- package/es/plugins/toolbar/utils/setFloatingElemPosition.js +0 -68
- package/es/plugins/upload/index.d.ts +0 -3
- package/es/plugins/upload/index.js +0 -3
- package/es/plugins/upload/plugin/index.d.ts +0 -4
- package/es/plugins/upload/plugin/index.js +0 -84
- package/es/plugins/upload/service/i-upload-service.d.ts +0 -15
- package/es/plugins/upload/service/i-upload-service.js +0 -115
- package/es/plugins/upload/utils/index.d.ts +0 -1
- package/es/plugins/upload/utils/index.js +0 -20
- package/es/plugins/virtual-block/index.d.ts +0 -2
- package/es/plugins/virtual-block/index.js +0 -2
- package/es/plugins/virtual-block/plugin/index.d.ts +0 -5
- package/es/plugins/virtual-block/plugin/index.js +0 -41
- package/es/plugins/virtual-block/plugin/register.d.ts +0 -6
- package/es/plugins/virtual-block/plugin/register.js +0 -274
- package/es/plugins/virtual-block/react/ReactVirtualBlock.d.ts +0 -3
- package/es/plugins/virtual-block/react/ReactVirtualBlock.js +0 -22
- package/es/plugins/virtual-block/react/index.d.ts +0 -1
- package/es/plugins/virtual-block/react/index.js +0 -1
- package/es/react/ChatInput/ChatInput.d.ts +0 -4
- package/es/react/ChatInput/ChatInput.js +0 -146
- package/es/react/ChatInput/index.d.ts +0 -2
- package/es/react/ChatInput/index.js +0 -2
- package/es/react/ChatInput/style.d.ts +0 -11
- package/es/react/ChatInput/style.js +0 -18
- package/es/react/ChatInput/type.d.ts +0 -28
- package/es/react/ChatInput/type.js +0 -1
- package/es/react/ChatInputActionBar/ChatInputActionBar.d.ts +0 -4
- package/es/react/ChatInputActionBar/ChatInputActionBar.js +0 -35
- package/es/react/ChatInputActionBar/index.d.ts +0 -2
- package/es/react/ChatInputActionBar/index.js +0 -2
- package/es/react/ChatInputActionBar/style.d.ts +0 -3
- package/es/react/ChatInputActionBar/style.js +0 -9
- package/es/react/ChatInputActionBar/type.d.ts +0 -6
- package/es/react/ChatInputActionBar/type.js +0 -1
- package/es/react/ChatInputActions/ChatInputActions.d.ts +0 -4
- package/es/react/ChatInputActions/ChatInputActions.js +0 -109
- package/es/react/ChatInputActions/components/ActionItem.d.ts +0 -13
- package/es/react/ChatInputActions/components/ActionItem.js +0 -65
- package/es/react/ChatInputActions/components/ActionRender.d.ts +0 -9
- package/es/react/ChatInputActions/components/ActionRender.js +0 -66
- package/es/react/ChatInputActions/components/CollapsedActions.d.ts +0 -4
- package/es/react/ChatInputActions/components/CollapsedActions.js +0 -78
- package/es/react/ChatInputActions/components/useDisplayActionCount.d.ts +0 -13
- package/es/react/ChatInputActions/components/useDisplayActionCount.js +0 -66
- package/es/react/ChatInputActions/index.d.ts +0 -2
- package/es/react/ChatInputActions/index.js +0 -1
- package/es/react/ChatInputActions/style.d.ts +0 -5
- package/es/react/ChatInputActions/style.js +0 -11
- package/es/react/ChatInputActions/type.d.ts +0 -40
- package/es/react/ChatInputActions/type.js +0 -1
- package/es/react/CodeLanguageSelect/CodeLanguageSelect.d.ts +0 -4
- package/es/react/CodeLanguageSelect/CodeLanguageSelect.js +0 -93
- package/es/react/CodeLanguageSelect/index.d.ts +0 -2
- package/es/react/CodeLanguageSelect/index.js +0 -2
- package/es/react/CodeLanguageSelect/style.d.ts +0 -3
- package/es/react/CodeLanguageSelect/style.js +0 -9
- package/es/react/CodeLanguageSelect/type.d.ts +0 -2
- package/es/react/CodeLanguageSelect/type.js +0 -1
- package/es/react/Editor/Editor.d.ts +0 -4
- package/es/react/Editor/Editor.js +0 -154
- package/es/react/Editor/index.d.ts +0 -15
- package/es/react/Editor/index.js +0 -11
- package/es/react/Editor/type.d.ts +0 -61
- package/es/react/Editor/type.js +0 -1
- package/es/react/Editor/utils.d.ts +0 -2
- package/es/react/Editor/utils.js +0 -3
- package/es/react/EditorProvider/index.d.ts +0 -20
- package/es/react/EditorProvider/index.js +0 -25
- package/es/react/FloatActions/FloatActions.d.ts +0 -4
- package/es/react/FloatActions/FloatActions.js +0 -65
- package/es/react/FloatActions/components/ActionItem.d.ts +0 -12
- package/es/react/FloatActions/components/ActionItem.js +0 -64
- package/es/react/FloatActions/components/ActionRender.d.ts +0 -9
- package/es/react/FloatActions/components/ActionRender.js +0 -66
- package/es/react/FloatActions/components/CollapsedActions.d.ts +0 -4
- package/es/react/FloatActions/components/CollapsedActions.js +0 -78
- package/es/react/FloatActions/index.d.ts +0 -2
- package/es/react/FloatActions/index.js +0 -1
- package/es/react/FloatActions/style.d.ts +0 -5
- package/es/react/FloatActions/style.js +0 -11
- package/es/react/FloatActions/type.d.ts +0 -37
- package/es/react/FloatActions/type.js +0 -1
- package/es/react/FloatMenu/FloatMenu.d.ts +0 -4
- package/es/react/FloatMenu/FloatMenu.js +0 -48
- package/es/react/FloatMenu/index.d.ts +0 -2
- package/es/react/FloatMenu/index.js +0 -2
- package/es/react/FloatMenu/style.d.ts +0 -6
- package/es/react/FloatMenu/style.js +0 -13
- package/es/react/FloatMenu/type.d.ts +0 -21
- package/es/react/FloatMenu/type.js +0 -1
- package/es/react/SendButton/SendButton.d.ts +0 -4
- package/es/react/SendButton/SendButton.js +0 -121
- package/es/react/SendButton/components/SendIcon.d.ts +0 -7
- package/es/react/SendButton/components/SendIcon.js +0 -31
- package/es/react/SendButton/components/StopIcon.d.ts +0 -7
- package/es/react/SendButton/components/StopIcon.js +0 -58
- package/es/react/SendButton/index.d.ts +0 -2
- package/es/react/SendButton/index.js +0 -2
- package/es/react/SendButton/style.d.ts +0 -7
- package/es/react/SendButton/style.js +0 -15
- package/es/react/SendButton/type.d.ts +0 -8
- package/es/react/SendButton/type.js +0 -1
- package/es/react/SlashMenu/SlashMenu.d.ts +0 -4
- package/es/react/SlashMenu/SlashMenu.js +0 -58
- package/es/react/SlashMenu/index.d.ts +0 -2
- package/es/react/SlashMenu/index.js +0 -2
- package/es/react/SlashMenu/type.d.ts +0 -13
- package/es/react/SlashMenu/type.js +0 -1
- package/es/react/hooks/useEditor.d.ts +0 -2
- package/es/react/hooks/useEditor.js +0 -7
- package/es/react/hooks/useEditorState/index.d.ts +0 -68
- package/es/react/hooks/useEditorState/index.js +0 -488
- package/es/react/hooks/useEditorState/utils.d.ts +0 -4
- package/es/react/hooks/useEditorState/utils.js +0 -36
- package/es/react/hooks/useSize.d.ts +0 -13
- package/es/react/hooks/useSize.js +0 -77
- package/es/react/index.d.ts +0 -12
- package/es/react/index.js +0 -12
- package/es/renderer/LexicalDiff.d.ts +0 -22
- package/es/renderer/LexicalDiff.js +0 -116
- package/es/renderer/LexicalRenderer.d.ts +0 -3
- package/es/renderer/LexicalRenderer.js +0 -61
- package/es/renderer/diff/compute.d.ts +0 -3
- package/es/renderer/diff/compute.js +0 -510
- package/es/renderer/diff/style.d.ts +0 -13
- package/es/renderer/diff/style.js +0 -20
- package/es/renderer/diff/types.d.ts +0 -28
- package/es/renderer/diff/types.js +0 -1
- package/es/renderer/engine/render-builtin-node.d.ts +0 -2
- package/es/renderer/engine/render-builtin-node.js +0 -211
- package/es/renderer/engine/render-text-node.d.ts +0 -2
- package/es/renderer/engine/render-text-node.js +0 -52
- package/es/renderer/engine/render-tree.d.ts +0 -6
- package/es/renderer/engine/render-tree.js +0 -47
- package/es/renderer/engine/shiki.d.ts +0 -3
- package/es/renderer/engine/shiki.js +0 -183
- package/es/renderer/engine/utils.d.ts +0 -2
- package/es/renderer/engine/utils.js +0 -27
- package/es/renderer/index.d.ts +0 -8
- package/es/renderer/index.js +0 -5
- package/es/renderer/nodes/index.d.ts +0 -2
- package/es/renderer/nodes/index.js +0 -17
- package/es/renderer/renderers/codeblock.d.ts +0 -2
- package/es/renderer/renderers/codeblock.js +0 -162
- package/es/renderer/renderers/file.d.ts +0 -2
- package/es/renderer/renderers/file.js +0 -30
- package/es/renderer/renderers/horizontalrule.d.ts +0 -2
- package/es/renderer/renderers/horizontalrule.js +0 -15
- package/es/renderer/renderers/image.d.ts +0 -3
- package/es/renderer/renderers/image.js +0 -40
- package/es/renderer/renderers/index.d.ts +0 -2
- package/es/renderer/renderers/index.js +0 -9
- package/es/renderer/renderers/math.d.ts +0 -2
- package/es/renderer/renderers/math.js +0 -18
- package/es/renderer/renderers/mention.d.ts +0 -2
- package/es/renderer/renderers/mention.js +0 -13
- package/es/renderer/renderers/mermaid.d.ts +0 -2
- package/es/renderer/renderers/mermaid.js +0 -18
- package/es/renderer/style.d.ts +0 -14
- package/es/renderer/style.js +0 -48
- package/es/renderer/types.d.ts +0 -25
- package/es/renderer/types.js +0 -1
- package/es/types/global.d.ts +0 -88
- package/es/types/hotkey.d.ts +0 -72
- package/es/types/hotkey.js +0 -72
- package/es/types/index.d.ts +0 -2
- package/es/types/index.js +0 -2
- package/es/types/kernel.d.ts +0 -336
- package/es/types/kernel.js +0 -1
- package/es/types/locale.d.ts +0 -10
- package/es/types/locale.js +0 -1
- package/es/utils/debug.d.ts +0 -429
- package/es/utils/debug.js +0 -321
- package/es/utils/hotkey/isHotkeyMatch.d.ts +0 -1
- package/es/utils/hotkey/isHotkeyMatch.js +0 -9
- package/es/utils/hotkey/parseHotkeys.d.ts +0 -6
- package/es/utils/hotkey/parseHotkeys.js +0 -42
- package/es/utils/hotkey/registerHotkey.d.ts +0 -15
- package/es/utils/hotkey/registerHotkey.js +0 -32
- package/es/utils/scrollIntoView.d.ts +0 -5
- package/es/utils/scrollIntoView.js +0 -45
- package/es/utils/updatePosition.d.ts +0 -9
- package/es/utils/updatePosition.js +0 -27
- package/es/utils/url.d.ts +0 -15
- package/es/utils/url.js +0 -51
- package/react.d.ts +0 -1
- package/react.js +0 -1
- package/renderer.d.ts +0 -1
- package/renderer.js +0 -1
- package/scripts/patch-lexical.js +0 -39
package/es/react.js
ADDED
|
@@ -0,0 +1,1573 @@
|
|
|
1
|
+
import { A as $createCodeMirrorNode, B as Editor$2, Bt as $isRootTextContentEmpty, S as formatUrl, T as $isSelectionInCodeInline, Ut as init_utils, a as $createMathBlockNode, d as $isLinkHighlightNode, h as $isLinkNode, j as $isCodeMirrorNode, mt as noop, o as $createMathInlineNode, x as TOGGLE_LINK_COMMAND } from "./style-Ub1LiKko.js";
|
|
2
|
+
import { C as ReactEditorContent, J as ReactEditor, N as ReactMarkdownPlugin, S as ReactPlainText, a as ReactMentionPlugin, b as INSERT_CODEINLINE_COMMAND, c as INSERT_CHECK_LIST_COMMAND, f as extractUrlFromText, h as validateUrl, m as sanitizeUrl, n as ReactSlashOption, t as ReactSlashPlugin, u as INSERT_LINK_HIGHLIGHT_COMMAND, y as UPDATE_CODEBLOCK_LANG } from "./ReactSlashPlugin-GxCNaj2T.js";
|
|
3
|
+
import { $createNodeSelection, $createParagraphNode, $getSelection, $isParagraphNode, $isRangeSelection, $isRootOrShadowRoot, $setSelection, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, COMMAND_PRIORITY_LOW, FORMAT_TEXT_COMMAND, REDO_COMMAND, SELECTION_CHANGE_COMMAND, UNDO_COMMAND } from "lexical";
|
|
4
|
+
import { $createQuoteNode, $isHeadingNode, $isQuoteNode } from "@lexical/rich-text";
|
|
5
|
+
import { $findMatchingParent, $getNearestNodeOfType, mergeRegister } from "@lexical/utils";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { createContext, createElement, isValidElement, memo, use, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
8
|
+
import { ActionIcon, Block, Button, Dropdown, Flexbox, Icon, MaterialFileTypeIcon, Menu, Popover, Select, Text, TooltipGroup, useMotionComponent } from "@lobehub/ui";
|
|
9
|
+
import { $createCodeNode, $isCodeNode } from "@lexical/code-core";
|
|
10
|
+
import { createStaticStyles, cssVar, cx, useThemeMode } from "antd-style";
|
|
11
|
+
import { $isAtNodeEnd, $setBlocksType } from "@lexical/selection";
|
|
12
|
+
import { $isListNode, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, ListNode } from "@lexical/list";
|
|
13
|
+
import { ChevronDownIcon, CircleChevronLeftIcon, CircleChevronRightIcon, CircleChevronUpIcon } from "lucide-react";
|
|
14
|
+
import { createPortal } from "react-dom";
|
|
15
|
+
import { bundledLanguagesInfo } from "shiki";
|
|
16
|
+
import { Divider, Dropdown as Dropdown$1, Space } from "antd";
|
|
17
|
+
import { Resizable } from "re-resizable";
|
|
18
|
+
import useMergeState from "use-merge-value";
|
|
19
|
+
import { debounce } from "es-toolkit";
|
|
20
|
+
//#region src/react/hooks/useSize.ts
|
|
21
|
+
const useWidth = (options = {}) => {
|
|
22
|
+
const { debounceMs = 100 } = options;
|
|
23
|
+
const ref = useRef(null);
|
|
24
|
+
const [size, setSize] = useState();
|
|
25
|
+
const resizeObserverRef = useRef(null);
|
|
26
|
+
const updateSize = useCallback(debounce((entries) => {
|
|
27
|
+
if (entries[0]) {
|
|
28
|
+
const { width } = entries[0].contentRect;
|
|
29
|
+
setSize(Math.floor(width));
|
|
30
|
+
}
|
|
31
|
+
}, debounceMs), [debounceMs]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const element = ref.current;
|
|
34
|
+
if (!element) return;
|
|
35
|
+
resizeObserverRef.current = new ResizeObserver(updateSize);
|
|
36
|
+
resizeObserverRef.current.observe(element);
|
|
37
|
+
return () => {
|
|
38
|
+
if (resizeObserverRef.current) {
|
|
39
|
+
resizeObserverRef.current.disconnect();
|
|
40
|
+
updateSize.cancel?.();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}, [updateSize]);
|
|
44
|
+
return {
|
|
45
|
+
ref,
|
|
46
|
+
width: size
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const useHeight = (options = {}) => {
|
|
50
|
+
const { debounceMs = 100 } = options;
|
|
51
|
+
const ref = useRef(null);
|
|
52
|
+
const [size, setSize] = useState();
|
|
53
|
+
const resizeObserverRef = useRef(null);
|
|
54
|
+
const updateSize = useCallback(debounce((entries) => {
|
|
55
|
+
if (entries[0]) {
|
|
56
|
+
const { height } = entries[0].contentRect;
|
|
57
|
+
setSize(Math.floor(height));
|
|
58
|
+
}
|
|
59
|
+
}, debounceMs), [debounceMs]);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
const element = ref.current;
|
|
62
|
+
if (!element) return;
|
|
63
|
+
resizeObserverRef.current = new ResizeObserver(updateSize);
|
|
64
|
+
resizeObserverRef.current.observe(element);
|
|
65
|
+
return () => {
|
|
66
|
+
if (resizeObserverRef.current) {
|
|
67
|
+
resizeObserverRef.current.disconnect();
|
|
68
|
+
updateSize.cancel?.();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}, [updateSize]);
|
|
72
|
+
return {
|
|
73
|
+
height: size,
|
|
74
|
+
ref
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/react/ChatInput/style.ts
|
|
79
|
+
const styles$8 = createStaticStyles(({ css, cssVar }) => ({
|
|
80
|
+
bodyEditor: css`
|
|
81
|
+
z-index: 0;
|
|
82
|
+
flex: 1;
|
|
83
|
+
`,
|
|
84
|
+
containerDark: css`
|
|
85
|
+
position: relative;
|
|
86
|
+
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
|
|
90
|
+
height: 100%;
|
|
91
|
+
border: 1px solid ${cssVar.colorFillSecondary};
|
|
92
|
+
border-radius: ${cssVar.borderRadiusLG};
|
|
93
|
+
|
|
94
|
+
background-color: ${cssVar.colorBgElevated};
|
|
95
|
+
box-shadow: 0 4px 4px color-mix(in srgb, #000 40%, transparent);
|
|
96
|
+
`,
|
|
97
|
+
containerLight: css`
|
|
98
|
+
position: relative;
|
|
99
|
+
|
|
100
|
+
display: flex;
|
|
101
|
+
flex-direction: column;
|
|
102
|
+
|
|
103
|
+
height: 100%;
|
|
104
|
+
border: 1px solid ${cssVar.colorFill};
|
|
105
|
+
border-radius: ${cssVar.borderRadiusLG};
|
|
106
|
+
|
|
107
|
+
background-color: ${cssVar.colorBgElevated};
|
|
108
|
+
box-shadow: 0 4px 4px color-mix(in srgb, #000 4%, transparent);
|
|
109
|
+
`,
|
|
110
|
+
editor: css`
|
|
111
|
+
cursor: text;
|
|
112
|
+
|
|
113
|
+
overflow: hidden auto;
|
|
114
|
+
flex: 1;
|
|
115
|
+
|
|
116
|
+
width: 100%;
|
|
117
|
+
padding-block: 8px 0;
|
|
118
|
+
padding-inline: 12px;
|
|
119
|
+
`,
|
|
120
|
+
footer: css`
|
|
121
|
+
z-index: 1;
|
|
122
|
+
width: 100%;
|
|
123
|
+
`,
|
|
124
|
+
header: css`
|
|
125
|
+
z-index: 1;
|
|
126
|
+
width: 100%;
|
|
127
|
+
`,
|
|
128
|
+
resizableContainer: css`
|
|
129
|
+
position: relative;
|
|
130
|
+
|
|
131
|
+
display: flex;
|
|
132
|
+
flex: 1 1 auto;
|
|
133
|
+
flex-direction: column;
|
|
134
|
+
align-self: flex-end;
|
|
135
|
+
|
|
136
|
+
width: 100%;
|
|
137
|
+
|
|
138
|
+
&:hover .resize-handle {
|
|
139
|
+
opacity: 1;
|
|
140
|
+
}
|
|
141
|
+
`,
|
|
142
|
+
resizeHandle: css`
|
|
143
|
+
position: absolute;
|
|
144
|
+
inset-block-start: -4px;
|
|
145
|
+
inset-inline-start: 50%;
|
|
146
|
+
transform: translateX(-50%);
|
|
147
|
+
|
|
148
|
+
width: 100%;
|
|
149
|
+
height: 8px;
|
|
150
|
+
|
|
151
|
+
opacity: 0;
|
|
152
|
+
|
|
153
|
+
transition: opacity 0.2s ease-in-out;
|
|
154
|
+
|
|
155
|
+
&::before {
|
|
156
|
+
content: '';
|
|
157
|
+
|
|
158
|
+
position: absolute;
|
|
159
|
+
inset-block-start: 0;
|
|
160
|
+
inset-inline-start: 50%;
|
|
161
|
+
transform: translateX(-50%);
|
|
162
|
+
|
|
163
|
+
width: 32px;
|
|
164
|
+
height: 4px;
|
|
165
|
+
border-radius: 4px;
|
|
166
|
+
|
|
167
|
+
background-color: ${cssVar.colorPrimary};
|
|
168
|
+
box-shadow: 0 1px 2px color-mix(in srgb, ${cssVar.colorTextSecondary} 12.5%, transparent);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
&:hover {
|
|
172
|
+
opacity: 1 !important;
|
|
173
|
+
|
|
174
|
+
&::before {
|
|
175
|
+
background-color: ${cssVar.colorPrimaryHover};
|
|
176
|
+
box-shadow: 0 2px 4px color-mix(in srgb, ${cssVar.colorTextSecondary} 25%, transparent);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
&:active {
|
|
181
|
+
&::before {
|
|
182
|
+
background-color: ${cssVar.colorPrimaryActive};
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
`,
|
|
186
|
+
root: css`
|
|
187
|
+
position: relative;
|
|
188
|
+
`
|
|
189
|
+
}));
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/react/ChatInput/ChatInput.tsx
|
|
192
|
+
const ChatInput = (props) => {
|
|
193
|
+
const { defaultHeight = props.defaultHeight || props.minHeight || 64, height, maxHeight = 320, minHeight = 64, resizeMaxHeightOffset = 120, resize = true, onSizeChange, onSizeDragging, className, children, footer, header, style, slashMenuRef, classNames, fullscreen, showResizeHandle, onBodyClick, styles: customStyles, ...rest } = props;
|
|
194
|
+
const { isDarkMode } = useThemeMode();
|
|
195
|
+
const { ref: headerRef, height: headerHeight = 0 } = useHeight();
|
|
196
|
+
const [currentHeight, setCurrentHeight] = useMergeState(defaultHeight, {
|
|
197
|
+
defaultValue: defaultHeight,
|
|
198
|
+
onChange: onSizeChange,
|
|
199
|
+
value: height
|
|
200
|
+
});
|
|
201
|
+
const handleResizeStop = useCallback((e, direction, ref) => {
|
|
202
|
+
setCurrentHeight(ref.style.height ? parseInt(ref.style.height) : defaultHeight);
|
|
203
|
+
}, [setCurrentHeight, defaultHeight]);
|
|
204
|
+
const handleResize = useCallback((e, direction, ref) => {
|
|
205
|
+
const newHeight = ref.style.height ? parseInt(ref.style.height) : defaultHeight;
|
|
206
|
+
onSizeDragging?.(newHeight);
|
|
207
|
+
}, [onSizeDragging, defaultHeight]);
|
|
208
|
+
const bodyNode = /* @__PURE__ */ jsx("div", {
|
|
209
|
+
className: cx(styles$8.editor, styles$8.bodyEditor, classNames?.body),
|
|
210
|
+
draggable: false,
|
|
211
|
+
onClick: onBodyClick,
|
|
212
|
+
style: {
|
|
213
|
+
...customStyles?.body,
|
|
214
|
+
maxHeight: fullscreen ? "100%" : maxHeight,
|
|
215
|
+
minHeight: resize ? currentHeight : minHeight
|
|
216
|
+
},
|
|
217
|
+
children
|
|
218
|
+
});
|
|
219
|
+
return /* @__PURE__ */ jsxs(Flexbox, {
|
|
220
|
+
className: cx(isDarkMode ? styles$8.containerDark : styles$8.containerLight, styles$8.root, className),
|
|
221
|
+
height: fullscreen ? "100%" : void 0,
|
|
222
|
+
style,
|
|
223
|
+
width: "100%",
|
|
224
|
+
...rest,
|
|
225
|
+
children: [
|
|
226
|
+
slashMenuRef && /* @__PURE__ */ jsx("div", { ref: slashMenuRef }),
|
|
227
|
+
/* @__PURE__ */ jsx("div", {
|
|
228
|
+
className: cx(styles$8.header, classNames?.header),
|
|
229
|
+
ref: headerRef,
|
|
230
|
+
style: customStyles?.header,
|
|
231
|
+
children: header
|
|
232
|
+
}),
|
|
233
|
+
resize ? /* @__PURE__ */ jsx(Resizable, {
|
|
234
|
+
className: styles$8.resizableContainer,
|
|
235
|
+
enable: fullscreen ? false : { top: true },
|
|
236
|
+
handleClasses: { top: showResizeHandle ? styles$8.resizeHandle : void 0 },
|
|
237
|
+
handleStyles: { top: {
|
|
238
|
+
backgroundColor: "transparent",
|
|
239
|
+
borderRadius: "4px",
|
|
240
|
+
cursor: "ns-resize",
|
|
241
|
+
height: "8px",
|
|
242
|
+
left: "50%",
|
|
243
|
+
top: !!header ? -3 - headerHeight : -3,
|
|
244
|
+
transform: "translateX(-50%)",
|
|
245
|
+
width: "100%"
|
|
246
|
+
} },
|
|
247
|
+
maxHeight: fullscreen ? void 0 : maxHeight + resizeMaxHeightOffset,
|
|
248
|
+
minHeight: fullscreen ? void 0 : minHeight,
|
|
249
|
+
onResize: handleResize,
|
|
250
|
+
onResizeStop: handleResizeStop,
|
|
251
|
+
size: {
|
|
252
|
+
height: fullscreen ? void 0 : "auto",
|
|
253
|
+
width: "100%"
|
|
254
|
+
},
|
|
255
|
+
style: fullscreen ? {
|
|
256
|
+
flex: 1,
|
|
257
|
+
overflow: "hidden",
|
|
258
|
+
position: "relative"
|
|
259
|
+
} : void 0,
|
|
260
|
+
children: bodyNode
|
|
261
|
+
}) : bodyNode,
|
|
262
|
+
/* @__PURE__ */ jsx("div", {
|
|
263
|
+
className: cx(styles$8.footer, classNames?.footer),
|
|
264
|
+
style: customStyles?.footer,
|
|
265
|
+
children: footer
|
|
266
|
+
})
|
|
267
|
+
]
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
ChatInput.displayName = "ChatInput";
|
|
271
|
+
//#endregion
|
|
272
|
+
//#region src/react/ChatInputActionBar/style.ts
|
|
273
|
+
const styles$7 = createStaticStyles(({ css }) => ({ container: css`
|
|
274
|
+
overflow: hidden;
|
|
275
|
+
` }));
|
|
276
|
+
//#endregion
|
|
277
|
+
//#region src/react/ChatInputActionBar/ChatInputActionBar.tsx
|
|
278
|
+
const ChatInputActionBar = ({ className, style, left, right, ...rest }) => {
|
|
279
|
+
return /* @__PURE__ */ jsxs(Flexbox, {
|
|
280
|
+
align: "center",
|
|
281
|
+
className: cx(styles$7.container, className),
|
|
282
|
+
gap: 4,
|
|
283
|
+
horizontal: true,
|
|
284
|
+
justify: "space-between",
|
|
285
|
+
padding: 4,
|
|
286
|
+
style,
|
|
287
|
+
...rest,
|
|
288
|
+
children: [left, right]
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
ChatInputActionBar.displayName = "ChatInputActionBar";
|
|
292
|
+
//#endregion
|
|
293
|
+
//#region src/react/ChatInputActions/style.ts
|
|
294
|
+
const styles$6 = createStaticStyles(({ css }) => ({
|
|
295
|
+
collapsedContainer: css`
|
|
296
|
+
overflow: hidden;
|
|
297
|
+
display: flex;
|
|
298
|
+
align-items: center;
|
|
299
|
+
`,
|
|
300
|
+
container: css`
|
|
301
|
+
position: relative;
|
|
302
|
+
overflow: hidden;
|
|
303
|
+
width: 100%;
|
|
304
|
+
`,
|
|
305
|
+
divider: css`
|
|
306
|
+
height: 20px;
|
|
307
|
+
margin-inline: 4px;
|
|
308
|
+
`
|
|
309
|
+
}));
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/react/ChatInputActions/components/ActionRender.tsx
|
|
312
|
+
const ActionRender$1 = ({ item, onActionClick, disabled }) => {
|
|
313
|
+
if (item.type === "divider") return /* @__PURE__ */ jsx(Divider, {
|
|
314
|
+
className: styles$6.divider,
|
|
315
|
+
orientation: "vertical"
|
|
316
|
+
});
|
|
317
|
+
const { wrapper, icon, key, label, onClick, danger, loading, active, tooltipProps, ...itemRest } = item;
|
|
318
|
+
if (item.children && isValidElement(item.children)) {
|
|
319
|
+
if (!wrapper) return item.children;
|
|
320
|
+
return wrapper(item.children);
|
|
321
|
+
}
|
|
322
|
+
const action = /* @__PURE__ */ jsx(ActionIcon, {
|
|
323
|
+
active,
|
|
324
|
+
danger,
|
|
325
|
+
disabled: disabled || loading || itemRest?.disabled,
|
|
326
|
+
icon,
|
|
327
|
+
loading,
|
|
328
|
+
onClick: (e) => {
|
|
329
|
+
onActionClick?.({
|
|
330
|
+
domEvent: e,
|
|
331
|
+
key: String(key),
|
|
332
|
+
keyPath: [String(key)]
|
|
333
|
+
});
|
|
334
|
+
onClick?.(e);
|
|
335
|
+
},
|
|
336
|
+
size: {
|
|
337
|
+
blockSize: 36,
|
|
338
|
+
size: 20
|
|
339
|
+
},
|
|
340
|
+
title: label,
|
|
341
|
+
tooltipProps: {
|
|
342
|
+
placement: "top",
|
|
343
|
+
...tooltipProps
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
if (!wrapper) return action;
|
|
347
|
+
return wrapper(action);
|
|
348
|
+
};
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region src/react/ChatInputActions/components/CollapsedActions.tsx
|
|
351
|
+
const CollapsedActions$1 = ({ children, groupCollapse = false, onGroupCollapseChange, gap, mode }) => {
|
|
352
|
+
const Motion = useMotionComponent();
|
|
353
|
+
if (mode === "popup") return /* @__PURE__ */ jsx(Popover, {
|
|
354
|
+
arrow: false,
|
|
355
|
+
content: /* @__PURE__ */ jsx(Flexbox, {
|
|
356
|
+
align: "center",
|
|
357
|
+
gap,
|
|
358
|
+
horizontal: true,
|
|
359
|
+
children
|
|
360
|
+
}),
|
|
361
|
+
styles: { content: { padding: 4 } },
|
|
362
|
+
children: /* @__PURE__ */ jsx(ActionIcon, {
|
|
363
|
+
icon: CircleChevronUpIcon,
|
|
364
|
+
size: {
|
|
365
|
+
blockSize: 36,
|
|
366
|
+
size: 20
|
|
367
|
+
}
|
|
368
|
+
})
|
|
369
|
+
});
|
|
370
|
+
return /* @__PURE__ */ jsxs(Flexbox, {
|
|
371
|
+
align: "center",
|
|
372
|
+
flex: "none",
|
|
373
|
+
gap,
|
|
374
|
+
horizontal: true,
|
|
375
|
+
children: [/* @__PURE__ */ jsx(Motion.div, {
|
|
376
|
+
animate: groupCollapse ? "closed" : "open",
|
|
377
|
+
className: styles$6.collapsedContainer,
|
|
378
|
+
initial: groupCollapse ? "closed" : "open",
|
|
379
|
+
style: { gap },
|
|
380
|
+
transition: { duration: .2 },
|
|
381
|
+
variants: {
|
|
382
|
+
closed: {
|
|
383
|
+
opacity: 0,
|
|
384
|
+
width: 0
|
|
385
|
+
},
|
|
386
|
+
open: {
|
|
387
|
+
opacity: 1,
|
|
388
|
+
width: "auto"
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
children
|
|
392
|
+
}), /* @__PURE__ */ jsx(ActionIcon, {
|
|
393
|
+
icon: groupCollapse ? CircleChevronRightIcon : CircleChevronLeftIcon,
|
|
394
|
+
onClick: () => onGroupCollapseChange?.(!groupCollapse),
|
|
395
|
+
size: {
|
|
396
|
+
blockSize: 36,
|
|
397
|
+
size: 20
|
|
398
|
+
}
|
|
399
|
+
})]
|
|
400
|
+
});
|
|
401
|
+
};
|
|
402
|
+
CollapsedActions$1.displayName = "ChatInputActionsCollapse";
|
|
403
|
+
//#endregion
|
|
404
|
+
//#region src/react/ChatInputActions/components/ActionItem.tsx
|
|
405
|
+
const ActionItem$1 = ({ item, disabled, onActionClick, groupCollapsed, collapsed, gap, setGroupCollapsed }) => {
|
|
406
|
+
if (item.type === "collapse") return /* @__PURE__ */ jsx(CollapsedActions$1, {
|
|
407
|
+
gap,
|
|
408
|
+
groupCollapse: groupCollapsed,
|
|
409
|
+
mode: collapsed ? "popup" : "default",
|
|
410
|
+
onGroupCollapseChange: setGroupCollapsed,
|
|
411
|
+
children: item.children.map((child, childIndex) => /* @__PURE__ */ jsx(ActionRender$1, {
|
|
412
|
+
disabled,
|
|
413
|
+
item: child,
|
|
414
|
+
onActionClick
|
|
415
|
+
}, child?.key || `action-${childIndex}`))
|
|
416
|
+
});
|
|
417
|
+
if (item.type === "dropdown") return /* @__PURE__ */ jsx(Dropdown, {
|
|
418
|
+
menu: { items: item.children },
|
|
419
|
+
children: /* @__PURE__ */ jsx(ActionIcon, {
|
|
420
|
+
active: item.active,
|
|
421
|
+
danger: item.danger,
|
|
422
|
+
disabled: disabled || item.loading || item?.disabled,
|
|
423
|
+
icon: item.icon,
|
|
424
|
+
loading: item.loading,
|
|
425
|
+
size: {
|
|
426
|
+
blockSize: 36,
|
|
427
|
+
size: 20
|
|
428
|
+
},
|
|
429
|
+
title: item.label,
|
|
430
|
+
tooltipProps: {
|
|
431
|
+
placement: "top",
|
|
432
|
+
...item.tooltipProps
|
|
433
|
+
}
|
|
434
|
+
})
|
|
435
|
+
}, item.key);
|
|
436
|
+
return /* @__PURE__ */ jsx(ActionRender$1, {
|
|
437
|
+
disabled,
|
|
438
|
+
item,
|
|
439
|
+
onActionClick
|
|
440
|
+
});
|
|
441
|
+
};
|
|
442
|
+
ActionItem$1.displayName = "ChatInputActionItem";
|
|
443
|
+
//#endregion
|
|
444
|
+
//#region src/react/ChatInputActions/components/useDisplayActionCount.ts
|
|
445
|
+
const useDisplayActionCount = ({ items = [], collapseOffset = 0, autoCollapse } = {}) => {
|
|
446
|
+
const { ref, width } = useWidth();
|
|
447
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
448
|
+
const flatItems = useMemo(() => items.flatMap((item) => {
|
|
449
|
+
if (item.type === "collapse" && item.children) return item.children;
|
|
450
|
+
return item;
|
|
451
|
+
}).filter((item) => item.type !== "divider"), [items]);
|
|
452
|
+
const alwaysDisplayCount = useMemo(() => items.filter((item) => item.alwaysDisplay).length, [items]);
|
|
453
|
+
const rawMaxCount = useMemo(() => flatItems.length + 1, [flatItems.length]);
|
|
454
|
+
const [maxCount, setMaxCount] = useState(rawMaxCount);
|
|
455
|
+
useEffect(() => {
|
|
456
|
+
if (!autoCollapse) {
|
|
457
|
+
setCollapsed(false);
|
|
458
|
+
setMaxCount(rawMaxCount);
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
if (!width) return;
|
|
462
|
+
const atLeastCount = 1 + alwaysDisplayCount;
|
|
463
|
+
let calcMaxCount = Math.floor((width - collapseOffset) / 38);
|
|
464
|
+
if (calcMaxCount < atLeastCount) calcMaxCount = atLeastCount;
|
|
465
|
+
setCollapsed(calcMaxCount < rawMaxCount);
|
|
466
|
+
if (calcMaxCount >= rawMaxCount) return;
|
|
467
|
+
setMaxCount(calcMaxCount);
|
|
468
|
+
}, [
|
|
469
|
+
autoCollapse,
|
|
470
|
+
width,
|
|
471
|
+
rawMaxCount,
|
|
472
|
+
collapseOffset,
|
|
473
|
+
alwaysDisplayCount
|
|
474
|
+
]);
|
|
475
|
+
return useMemo(() => ({
|
|
476
|
+
collapsed,
|
|
477
|
+
maxCount,
|
|
478
|
+
ref
|
|
479
|
+
}), [
|
|
480
|
+
collapsed,
|
|
481
|
+
maxCount,
|
|
482
|
+
ref
|
|
483
|
+
]);
|
|
484
|
+
};
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/react/ChatInputActions/ChatInputActions.tsx
|
|
487
|
+
const ChatInputActions = memo(({ gap = 2, disabled, items = [], onActionClick, className, collapseOffset = 0, autoCollapse = true, defaultGroupCollapse = false, onGroupCollapseChange, groupCollapse, ...rest }) => {
|
|
488
|
+
const [groupCollapsed, setGroupCollapsed] = useMergeState(defaultGroupCollapse, {
|
|
489
|
+
defaultValue: defaultGroupCollapse,
|
|
490
|
+
onChange: onGroupCollapseChange,
|
|
491
|
+
value: groupCollapse
|
|
492
|
+
});
|
|
493
|
+
const { ref, maxCount, collapsed } = useDisplayActionCount({
|
|
494
|
+
autoCollapse,
|
|
495
|
+
collapseOffset,
|
|
496
|
+
items
|
|
497
|
+
});
|
|
498
|
+
const calcItem = useMemo(() => {
|
|
499
|
+
if (!collapsed) return items;
|
|
500
|
+
const alwaysDisplayItems = items.filter((item) => item.alwaysDisplay);
|
|
501
|
+
const normalItems = items.filter((item) => item.type !== "collapse" && !item.alwaysDisplay);
|
|
502
|
+
const collapseItems = items.find((item) => item.type === "collapse" && item.children) || {
|
|
503
|
+
children: [],
|
|
504
|
+
type: "collapse"
|
|
505
|
+
};
|
|
506
|
+
const sliceCount = maxCount - alwaysDisplayItems.length - 1;
|
|
507
|
+
return [
|
|
508
|
+
...normalItems.slice(0, sliceCount),
|
|
509
|
+
{
|
|
510
|
+
...collapseItems,
|
|
511
|
+
children: [...normalItems.filter((item) => item.type !== "divider").slice(sliceCount), ...collapseItems.children]
|
|
512
|
+
},
|
|
513
|
+
...alwaysDisplayItems
|
|
514
|
+
].filter(Boolean);
|
|
515
|
+
}, [
|
|
516
|
+
collapsed,
|
|
517
|
+
items,
|
|
518
|
+
maxCount
|
|
519
|
+
]);
|
|
520
|
+
return /* @__PURE__ */ jsx(TooltipGroup, { children: /* @__PURE__ */ jsx(Flexbox, {
|
|
521
|
+
align: "center",
|
|
522
|
+
className: cx(styles$6.container, className),
|
|
523
|
+
flex: 1,
|
|
524
|
+
gap,
|
|
525
|
+
horizontal: true,
|
|
526
|
+
ref,
|
|
527
|
+
...rest,
|
|
528
|
+
children: calcItem.map((item, index) => /* @__PURE__ */ jsx(ActionItem$1, {
|
|
529
|
+
collapsed,
|
|
530
|
+
disabled,
|
|
531
|
+
gap,
|
|
532
|
+
groupCollapsed,
|
|
533
|
+
item,
|
|
534
|
+
onActionClick,
|
|
535
|
+
setGroupCollapsed
|
|
536
|
+
}, item.key || index))
|
|
537
|
+
}) });
|
|
538
|
+
});
|
|
539
|
+
ChatInputActions.displayName = "ChatInputActions";
|
|
540
|
+
//#endregion
|
|
541
|
+
//#region src/react/CodeLanguageSelect/style.ts
|
|
542
|
+
const styles$5 = createStaticStyles(({ css }) => ({ container: css`
|
|
543
|
+
width: 160px;
|
|
544
|
+
` }));
|
|
545
|
+
//#endregion
|
|
546
|
+
//#region src/react/CodeLanguageSelect/CodeLanguageSelect.tsx
|
|
547
|
+
const CodeLanguageSelect = ({ className, ...rest }) => {
|
|
548
|
+
const options = useMemo(() => [{
|
|
549
|
+
aliases: ["text", "txt"],
|
|
550
|
+
label: /* @__PURE__ */ jsxs(Flexbox, {
|
|
551
|
+
align: "center",
|
|
552
|
+
gap: 4,
|
|
553
|
+
horizontal: true,
|
|
554
|
+
children: [/* @__PURE__ */ jsx(MaterialFileTypeIcon, {
|
|
555
|
+
fallbackUnknownType: false,
|
|
556
|
+
filename: `*.txt`,
|
|
557
|
+
size: 18,
|
|
558
|
+
type: "file",
|
|
559
|
+
variant: "raw"
|
|
560
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
561
|
+
ellipsis: true,
|
|
562
|
+
fontSize: 13,
|
|
563
|
+
children: "Plaintext"
|
|
564
|
+
})]
|
|
565
|
+
}),
|
|
566
|
+
value: "plaintext"
|
|
567
|
+
}, ...bundledLanguagesInfo.map((item) => ({
|
|
568
|
+
aliases: item.aliases,
|
|
569
|
+
label: /* @__PURE__ */ jsxs(Flexbox, {
|
|
570
|
+
align: "center",
|
|
571
|
+
gap: 4,
|
|
572
|
+
horizontal: true,
|
|
573
|
+
children: [/* @__PURE__ */ jsx(MaterialFileTypeIcon, {
|
|
574
|
+
fallbackUnknownType: false,
|
|
575
|
+
filename: `*.${item?.aliases?.[0] || item.id}`,
|
|
576
|
+
size: 18,
|
|
577
|
+
type: "file",
|
|
578
|
+
variant: "raw"
|
|
579
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
580
|
+
ellipsis: true,
|
|
581
|
+
fontSize: 13,
|
|
582
|
+
children: item.name
|
|
583
|
+
})]
|
|
584
|
+
}),
|
|
585
|
+
title: (item.aliases || [item.id]).filter(Boolean).map((item) => `*.${item}`).join(","),
|
|
586
|
+
value: item.id
|
|
587
|
+
}))], []);
|
|
588
|
+
return /* @__PURE__ */ jsx(Select, {
|
|
589
|
+
className: cx(styles$5.container, className),
|
|
590
|
+
defaultValue: "plaintext",
|
|
591
|
+
filterOption: (input, option) => {
|
|
592
|
+
const lang = input.toLowerCase();
|
|
593
|
+
if ((option?.value)?.startsWith(lang)) return true;
|
|
594
|
+
if (option?.aliases?.some((item) => item.startsWith(lang))) return true;
|
|
595
|
+
return false;
|
|
596
|
+
},
|
|
597
|
+
options,
|
|
598
|
+
showSearch: true,
|
|
599
|
+
variant: "filled",
|
|
600
|
+
...rest
|
|
601
|
+
});
|
|
602
|
+
};
|
|
603
|
+
CodeLanguageSelect.displayName = "CodeLanguageSelect";
|
|
604
|
+
//#endregion
|
|
605
|
+
//#region src/react/hooks/useEditor.ts
|
|
606
|
+
const useEditor = () => {
|
|
607
|
+
return useMemo(() => Editor$2.createEditor(), []);
|
|
608
|
+
};
|
|
609
|
+
//#endregion
|
|
610
|
+
//#region src/react/hooks/useEditorState/utils.ts
|
|
611
|
+
init_utils();
|
|
612
|
+
const $findTopLevelElement = (node) => {
|
|
613
|
+
let topLevelElement = node.getKey() === "root" ? node : $findMatchingParent(node, (e) => {
|
|
614
|
+
const parent = e.getParent();
|
|
615
|
+
return parent !== null && $isRootOrShadowRoot(parent);
|
|
616
|
+
});
|
|
617
|
+
if (topLevelElement === null) topLevelElement = node.getTopLevelElementOrThrow();
|
|
618
|
+
return topLevelElement;
|
|
619
|
+
};
|
|
620
|
+
const formatParagraph = (editor) => {
|
|
621
|
+
editor?.update(() => {
|
|
622
|
+
$setBlocksType($getSelection(), () => $createParagraphNode());
|
|
623
|
+
});
|
|
624
|
+
};
|
|
625
|
+
const getSelectedNode = (selection) => {
|
|
626
|
+
const anchor = selection.anchor;
|
|
627
|
+
const focus = selection.focus;
|
|
628
|
+
const anchorNode = selection.anchor.getNode();
|
|
629
|
+
const focusNode = selection.focus.getNode();
|
|
630
|
+
if (anchorNode === focusNode) return anchorNode;
|
|
631
|
+
if (selection.isBackward()) return $isAtNodeEnd(focus) ? anchorNode : focusNode;
|
|
632
|
+
else return $isAtNodeEnd(anchor) ? anchorNode : focusNode;
|
|
633
|
+
};
|
|
634
|
+
//#endregion
|
|
635
|
+
//#region src/react/hooks/useEditorState/index.ts
|
|
636
|
+
/**
|
|
637
|
+
* Provide toolbar state and toolbar methods
|
|
638
|
+
* @param editor - Editor instance
|
|
639
|
+
* @returns Editor state and methods for toolbar functionality
|
|
640
|
+
*/
|
|
641
|
+
function useEditorState(editor) {
|
|
642
|
+
const [canUndo, setCanUndo] = useState(false);
|
|
643
|
+
const [canRedo, setCanRedo] = useState(false);
|
|
644
|
+
const [editable, setEditable] = useState(editor?.isEditable() ?? true);
|
|
645
|
+
const [isBold, setIsBold] = useState(false);
|
|
646
|
+
const [isItalic, setIsItalic] = useState(false);
|
|
647
|
+
const [isUnderline, setIsUnderline] = useState(false);
|
|
648
|
+
const [isStrikethrough, setIsStrikethrough] = useState(false);
|
|
649
|
+
const [isSubscript, setIsSubscript] = useState(false);
|
|
650
|
+
const [isSuperscript, setIsSuperscript] = useState(false);
|
|
651
|
+
const [isCode, setIsCode] = useState(false);
|
|
652
|
+
const [isLink, setIsLink] = useState(false);
|
|
653
|
+
const [isCodeblock, setIsInCodeblok] = useState(false);
|
|
654
|
+
const [isBlockquote, setIsInBlockquote] = useState(false);
|
|
655
|
+
const [codeblockLang, setCodeblockLang] = useState(null);
|
|
656
|
+
const [isEmpty, setIsEmpty] = useState(true);
|
|
657
|
+
const [isSelected, setIsSelected] = useState(false);
|
|
658
|
+
const [blockType, setBlockType] = useState(null);
|
|
659
|
+
const $handleHeadingNode = useCallback((selectedElement) => {
|
|
660
|
+
setBlockType($isHeadingNode(selectedElement) ? selectedElement.getTag() : selectedElement.getType());
|
|
661
|
+
}, [setBlockType]);
|
|
662
|
+
const $updateToolbar = useCallback(() => {
|
|
663
|
+
const selection = $getSelection();
|
|
664
|
+
const lexicalEditor = editor?.getLexicalEditor();
|
|
665
|
+
setIsSelected(false);
|
|
666
|
+
setEditable(editor?.isEditable() ?? true);
|
|
667
|
+
if (lexicalEditor) setIsEmpty($isRootTextContentEmpty(lexicalEditor.isComposing(), false));
|
|
668
|
+
if ($isRangeSelection(selection)) {
|
|
669
|
+
setIsSelected(!!selection._cachedNodes);
|
|
670
|
+
setIsBold(selection.hasFormat("bold"));
|
|
671
|
+
setIsItalic(selection.hasFormat("italic"));
|
|
672
|
+
setIsUnderline(selection.hasFormat("underline"));
|
|
673
|
+
setIsStrikethrough(selection.hasFormat("strikethrough"));
|
|
674
|
+
setIsSubscript(selection.hasFormat("subscript"));
|
|
675
|
+
setIsSuperscript(selection.hasFormat("superscript"));
|
|
676
|
+
setIsCode($isSelectionInCodeInline(lexicalEditor));
|
|
677
|
+
const anchorNode = selection.anchor.getNode();
|
|
678
|
+
const focusNode = selection.focus.getNode();
|
|
679
|
+
const element = $findTopLevelElement(anchorNode);
|
|
680
|
+
const focusElement = $findTopLevelElement(focusNode);
|
|
681
|
+
const elementKey = element.getKey();
|
|
682
|
+
const elementDOM = editor?.getLexicalEditor()?.getElementByKey(elementKey);
|
|
683
|
+
const node = getSelectedNode(selection);
|
|
684
|
+
const parent = node.getParent();
|
|
685
|
+
setIsLink($isLinkNode(parent) || $isLinkNode(node) || $isLinkHighlightNode(parent) || $isLinkHighlightNode(node));
|
|
686
|
+
const isLexicalCodeBlock = $isCodeNode(element) && $isCodeNode(focusElement) && elementKey === focusElement.getKey();
|
|
687
|
+
const isCodeMirrorBlock = $isCodeMirrorNode(element) && $isCodeMirrorNode(focusElement) && elementKey === focusElement.getKey();
|
|
688
|
+
setIsInCodeblok(isLexicalCodeBlock || isCodeMirrorBlock);
|
|
689
|
+
if (isLexicalCodeBlock) setCodeblockLang(element.getLanguage());
|
|
690
|
+
else if (isCodeMirrorBlock) setCodeblockLang(element.lang);
|
|
691
|
+
else setCodeblockLang("");
|
|
692
|
+
setIsInBlockquote($isQuoteNode(element) && $isQuoteNode(focusElement) && elementKey === focusElement.getKey());
|
|
693
|
+
if (elementDOM !== null) if ($isListNode(element)) {
|
|
694
|
+
const parentList = $getNearestNodeOfType(anchorNode, ListNode);
|
|
695
|
+
setBlockType(parentList ? parentList.getListType() : element.getListType());
|
|
696
|
+
} else $handleHeadingNode(element);
|
|
697
|
+
} else if (!selection) {
|
|
698
|
+
setIsSelected(false);
|
|
699
|
+
setIsBold(false);
|
|
700
|
+
setIsItalic(false);
|
|
701
|
+
setIsUnderline(false);
|
|
702
|
+
setIsStrikethrough(false);
|
|
703
|
+
setIsSubscript(false);
|
|
704
|
+
setIsSuperscript(false);
|
|
705
|
+
setIsCode(false);
|
|
706
|
+
setIsLink(false);
|
|
707
|
+
setIsInCodeblok(false);
|
|
708
|
+
setIsInBlockquote(false);
|
|
709
|
+
setCodeblockLang(null);
|
|
710
|
+
setBlockType(null);
|
|
711
|
+
}
|
|
712
|
+
}, [editor]);
|
|
713
|
+
const undo = useCallback(() => {
|
|
714
|
+
editor?.dispatchCommand(UNDO_COMMAND, void 0);
|
|
715
|
+
}, [editor]);
|
|
716
|
+
const redo = useCallback(() => {
|
|
717
|
+
editor?.dispatchCommand(REDO_COMMAND, void 0);
|
|
718
|
+
}, [editor]);
|
|
719
|
+
const formatText = useCallback((type) => {
|
|
720
|
+
editor?.dispatchCommand(FORMAT_TEXT_COMMAND, type);
|
|
721
|
+
}, [editor]);
|
|
722
|
+
const bold = useCallback(() => {
|
|
723
|
+
formatText("bold");
|
|
724
|
+
}, [formatText]);
|
|
725
|
+
const underline = useCallback(() => {
|
|
726
|
+
formatText("underline");
|
|
727
|
+
}, [formatText]);
|
|
728
|
+
const strikethrough = useCallback(() => {
|
|
729
|
+
formatText("strikethrough");
|
|
730
|
+
}, [formatText]);
|
|
731
|
+
const italic = useCallback(() => {
|
|
732
|
+
formatText("italic");
|
|
733
|
+
}, [formatText]);
|
|
734
|
+
const subscript = useCallback(() => {
|
|
735
|
+
formatText("subscript");
|
|
736
|
+
}, [formatText]);
|
|
737
|
+
const superscript = useCallback(() => {
|
|
738
|
+
formatText("superscript");
|
|
739
|
+
}, [formatText]);
|
|
740
|
+
const code = useCallback(() => {
|
|
741
|
+
editor?.dispatchCommand(INSERT_CODEINLINE_COMMAND, void 0);
|
|
742
|
+
}, [formatText]);
|
|
743
|
+
const bulletList = useCallback(() => {
|
|
744
|
+
if (blockType !== "bullet") editor?.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, void 0);
|
|
745
|
+
else formatParagraph(editor?.getLexicalEditor());
|
|
746
|
+
}, [blockType, editor]);
|
|
747
|
+
const numberList = useCallback(() => {
|
|
748
|
+
if (blockType !== "number") editor?.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, void 0);
|
|
749
|
+
else formatParagraph(editor?.getLexicalEditor());
|
|
750
|
+
}, [blockType, editor]);
|
|
751
|
+
const checkList = useCallback(() => {
|
|
752
|
+
if (blockType !== "check") editor?.dispatchCommand(INSERT_CHECK_LIST_COMMAND, void 0);
|
|
753
|
+
else formatParagraph(editor?.getLexicalEditor());
|
|
754
|
+
}, [blockType, editor]);
|
|
755
|
+
const codeblock = useCallback(() => {
|
|
756
|
+
if (blockType !== "code") editor?.getLexicalEditor()?.update(() => {
|
|
757
|
+
let selection = $getSelection();
|
|
758
|
+
if (!selection) return;
|
|
759
|
+
const lexicalEditor = editor?.getLexicalEditor();
|
|
760
|
+
if (lexicalEditor ? lexicalEditor._nodes.has("code") && lexicalEditor._nodes.get("code")?.klass.name === "CodeMirrorNode" : false) if (!$isRangeSelection(selection) || selection.isCollapsed()) {
|
|
761
|
+
const codeMirrorNode = $createCodeMirrorNode("plain", selection.getTextContent());
|
|
762
|
+
const nodeSelection = $createNodeSelection();
|
|
763
|
+
nodeSelection.add(codeMirrorNode.getKey());
|
|
764
|
+
selection.insertNodes([codeMirrorNode]);
|
|
765
|
+
$setSelection(nodeSelection);
|
|
766
|
+
} else {
|
|
767
|
+
const codeMirrorNode = $createCodeMirrorNode("plain", selection.getTextContent());
|
|
768
|
+
selection.insertNodes([codeMirrorNode]);
|
|
769
|
+
const nodeSelection = $createNodeSelection();
|
|
770
|
+
nodeSelection.add(codeMirrorNode.getKey());
|
|
771
|
+
$setSelection(nodeSelection);
|
|
772
|
+
}
|
|
773
|
+
else if (!$isRangeSelection(selection) || selection.isCollapsed()) $setBlocksType(selection, () => $createCodeNode());
|
|
774
|
+
else {
|
|
775
|
+
const textContent = selection.getTextContent();
|
|
776
|
+
const codeNode = $createCodeNode();
|
|
777
|
+
selection.insertNodes([codeNode]);
|
|
778
|
+
selection = $getSelection();
|
|
779
|
+
if ($isRangeSelection(selection)) selection.insertRawText(textContent);
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
else formatParagraph(editor?.getLexicalEditor());
|
|
783
|
+
}, [blockType, editor]);
|
|
784
|
+
const blockquote = useCallback(() => {
|
|
785
|
+
if (blockType !== "quote") editor?.getLexicalEditor()?.update(() => {
|
|
786
|
+
const selection = $getSelection();
|
|
787
|
+
if ($isRangeSelection(selection)) $setBlocksType(selection, () => $createQuoteNode());
|
|
788
|
+
});
|
|
789
|
+
else formatParagraph(editor?.getLexicalEditor());
|
|
790
|
+
}, [blockType, editor]);
|
|
791
|
+
const updateCodeblockLang = useCallback((lang) => {
|
|
792
|
+
if (!isCodeblock) return;
|
|
793
|
+
editor?.dispatchCommand(UPDATE_CODEBLOCK_LANG, { lang });
|
|
794
|
+
}, [editor, isCodeblock]);
|
|
795
|
+
const insertLink = useCallback(() => {
|
|
796
|
+
const lexical = editor?.getLexicalEditor();
|
|
797
|
+
if (!lexical) return;
|
|
798
|
+
let inLinkNode = false;
|
|
799
|
+
let inLinkHighlightNode = false;
|
|
800
|
+
lexical.getEditorState().read(() => {
|
|
801
|
+
const selection = $getSelection();
|
|
802
|
+
if ($isRangeSelection(selection)) {
|
|
803
|
+
const node = getSelectedNode(selection);
|
|
804
|
+
const parent = node.getParent();
|
|
805
|
+
if ($isLinkNode(parent) || $isLinkNode(node)) inLinkNode = true;
|
|
806
|
+
if ($isLinkHighlightNode(parent) || $isLinkHighlightNode(node)) inLinkHighlightNode = true;
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
if (inLinkHighlightNode) {
|
|
810
|
+
lexical.dispatchCommand(INSERT_LINK_HIGHLIGHT_COMMAND, void 0);
|
|
811
|
+
setIsLink(false);
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
if (inLinkNode) {
|
|
815
|
+
setIsLink(false);
|
|
816
|
+
lexical.dispatchCommand(TOGGLE_LINK_COMMAND, null);
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
if (!isLink) {
|
|
820
|
+
if (lexical.dispatchCommand(INSERT_LINK_HIGHLIGHT_COMMAND, void 0)) {
|
|
821
|
+
setIsLink(true);
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
let nextUrl = sanitizeUrl("https://");
|
|
825
|
+
let expandTo = null;
|
|
826
|
+
lexical.getEditorState().read(() => {
|
|
827
|
+
const selection = $getSelection();
|
|
828
|
+
if ($isRangeSelection(selection)) {
|
|
829
|
+
const text = selection.getTextContent();
|
|
830
|
+
if (!selection.isCollapsed()) {
|
|
831
|
+
const maybeUrl = formatUrl(text.trim());
|
|
832
|
+
if (validateUrl(maybeUrl)) nextUrl = maybeUrl;
|
|
833
|
+
} else {
|
|
834
|
+
const found = extractUrlFromText(selection.anchor.getNode().getTextContent());
|
|
835
|
+
if (found && validateUrl(formatUrl(found.url))) expandTo = {
|
|
836
|
+
index: found.index,
|
|
837
|
+
length: found.length
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
});
|
|
842
|
+
setIsLink(true);
|
|
843
|
+
lexical.update(() => {
|
|
844
|
+
if (expandTo) {
|
|
845
|
+
const selection = $getSelection();
|
|
846
|
+
if ($isRangeSelection(selection)) {
|
|
847
|
+
const anchorNode = selection.anchor.getNode();
|
|
848
|
+
selection.anchor.set(anchorNode.getKey(), expandTo.index, "text");
|
|
849
|
+
selection.focus.set(anchorNode.getKey(), expandTo.index + expandTo.length, "text");
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
lexical.dispatchCommand(TOGGLE_LINK_COMMAND, validateUrl(nextUrl) ? nextUrl : sanitizeUrl("https://"));
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
}, [editor, isLink]);
|
|
856
|
+
const insertMath = useCallback(() => {
|
|
857
|
+
editor?.getLexicalEditor()?.update(() => {
|
|
858
|
+
const selection = $getSelection();
|
|
859
|
+
if ($isRangeSelection(selection)) {
|
|
860
|
+
const element = $findTopLevelElement(selection.anchor.getNode());
|
|
861
|
+
const mathNode = $isParagraphNode(element) && selection.isCollapsed() && selection.anchor.offset === 0 && element.getTextContentSize() === 0 || !selection.isCollapsed() && selection.anchor.offset === 0 && selection.focus.offset === element.getTextContentSize() ? $createMathBlockNode("") : $createMathInlineNode("");
|
|
862
|
+
selection.insertNodes([mathNode]);
|
|
863
|
+
const nodeSelection = $createNodeSelection();
|
|
864
|
+
nodeSelection.add(mathNode.getKey());
|
|
865
|
+
$setSelection(nodeSelection);
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
}, [editor]);
|
|
869
|
+
useEffect(() => {
|
|
870
|
+
if (!editor) return;
|
|
871
|
+
const lexicalEditor = editor.getLexicalEditor();
|
|
872
|
+
let cleanup = noop;
|
|
873
|
+
const debounceUpdate = debounce(() => {
|
|
874
|
+
lexicalEditor?.read(() => {
|
|
875
|
+
$updateToolbar();
|
|
876
|
+
});
|
|
877
|
+
}, 500);
|
|
878
|
+
const handleLexicalEditor = (lexicalEditor) => {
|
|
879
|
+
cleanup = mergeRegister(lexicalEditor.registerUpdateListener(debounce(({ editorState }) => {
|
|
880
|
+
editorState.read(() => {
|
|
881
|
+
$updateToolbar();
|
|
882
|
+
});
|
|
883
|
+
}, 500)), lexicalEditor.registerCommand(SELECTION_CHANGE_COMMAND, () => {
|
|
884
|
+
if (lexicalEditor.isComposing()) return false;
|
|
885
|
+
debounceUpdate();
|
|
886
|
+
return false;
|
|
887
|
+
}, COMMAND_PRIORITY_LOW), lexicalEditor.registerCommand(CAN_UNDO_COMMAND, (payload) => {
|
|
888
|
+
setCanUndo(payload);
|
|
889
|
+
return false;
|
|
890
|
+
}, COMMAND_PRIORITY_LOW), lexicalEditor.registerCommand(CAN_REDO_COMMAND, (payload) => {
|
|
891
|
+
setCanRedo(payload);
|
|
892
|
+
return false;
|
|
893
|
+
}, COMMAND_PRIORITY_LOW));
|
|
894
|
+
return cleanup;
|
|
895
|
+
};
|
|
896
|
+
if (!lexicalEditor) {
|
|
897
|
+
editor.on("initialized", handleLexicalEditor);
|
|
898
|
+
return () => {
|
|
899
|
+
cleanup();
|
|
900
|
+
editor.off("initialized", handleLexicalEditor);
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
return handleLexicalEditor(lexicalEditor);
|
|
904
|
+
}, [editor, $updateToolbar]);
|
|
905
|
+
return useMemo(() => ({
|
|
906
|
+
blockType,
|
|
907
|
+
blockquote,
|
|
908
|
+
bold,
|
|
909
|
+
bulletList,
|
|
910
|
+
canRedo,
|
|
911
|
+
canUndo,
|
|
912
|
+
checkList,
|
|
913
|
+
code,
|
|
914
|
+
codeblock,
|
|
915
|
+
codeblockLang,
|
|
916
|
+
editable,
|
|
917
|
+
insertLink,
|
|
918
|
+
insertMath,
|
|
919
|
+
isBlockquote,
|
|
920
|
+
isBold,
|
|
921
|
+
isCode,
|
|
922
|
+
isCodeblock,
|
|
923
|
+
isEmpty,
|
|
924
|
+
isItalic,
|
|
925
|
+
isSelected,
|
|
926
|
+
isStrikethrough,
|
|
927
|
+
isSubscript,
|
|
928
|
+
isSuperscript,
|
|
929
|
+
isUnderline,
|
|
930
|
+
italic,
|
|
931
|
+
numberList,
|
|
932
|
+
redo,
|
|
933
|
+
strikethrough,
|
|
934
|
+
subscript,
|
|
935
|
+
superscript,
|
|
936
|
+
underline,
|
|
937
|
+
undo,
|
|
938
|
+
updateCodeblockLang
|
|
939
|
+
}), [
|
|
940
|
+
blockType,
|
|
941
|
+
canRedo,
|
|
942
|
+
canUndo,
|
|
943
|
+
codeblockLang,
|
|
944
|
+
isBold,
|
|
945
|
+
isCode,
|
|
946
|
+
isEmpty,
|
|
947
|
+
isBlockquote,
|
|
948
|
+
isCodeblock,
|
|
949
|
+
isItalic,
|
|
950
|
+
isSelected,
|
|
951
|
+
isStrikethrough,
|
|
952
|
+
isUnderline,
|
|
953
|
+
isSubscript,
|
|
954
|
+
isSuperscript,
|
|
955
|
+
italic
|
|
956
|
+
]);
|
|
957
|
+
}
|
|
958
|
+
//#endregion
|
|
959
|
+
//#region src/react/EditorProvider/index.tsx
|
|
960
|
+
const EditorContext = createContext({ config: {} });
|
|
961
|
+
const EditorProvider = ({ children, config = {} }) => {
|
|
962
|
+
const value = useMemo(() => ({ config }), [config]);
|
|
963
|
+
return /* @__PURE__ */ jsx(EditorContext.Provider, {
|
|
964
|
+
value,
|
|
965
|
+
children
|
|
966
|
+
});
|
|
967
|
+
};
|
|
968
|
+
const useEditorContent = () => {
|
|
969
|
+
return use(EditorContext);
|
|
970
|
+
};
|
|
971
|
+
EditorProvider.displayName = "EditorProvider";
|
|
972
|
+
//#endregion
|
|
973
|
+
//#region src/react/Editor/Editor.tsx
|
|
974
|
+
const Editor$1 = memo(({ content, style, className, debounceWait = 100, editable, editor, onInit, onChange, placeholder, lineEmptyPlaceholder, plugins = [], slashOption = {}, slashPlacement, getPopupContainer, mentionOption = {}, variant, onKeyDown, children, type = "json", onPressEnter, onFocus, onBlur, autoFocus, enablePasteMarkdown = true, autoFormatMarkdown = true, markdownOption = true, pasteMarkdownAutoConvertThreshold, pasteAsPlainText = false, pasteVSCodeAsCodeBlock = true, onCompositionStart, onCompositionEnd, onContextMenu, onTextChange }) => {
|
|
975
|
+
const { config } = useEditorContent();
|
|
976
|
+
const enableSlash = Boolean(slashOption?.items && slashOption.items.length > 0);
|
|
977
|
+
const enableMention = Boolean(mentionOption?.items && mentionOption.items.length > 0);
|
|
978
|
+
const { markdownWriter, ...restMentionOption } = mentionOption;
|
|
979
|
+
const debouncedOnChange = useMemo(() => onChange ? debounce(onChange, debounceWait) : void 0, [onChange, debounceWait]);
|
|
980
|
+
const debouncedOnTextChange = useMemo(() => onTextChange ? debounce(onTextChange, debounceWait) : void 0, [onTextChange, debounceWait]);
|
|
981
|
+
const memoPlugins = useMemo(() => [enablePasteMarkdown && autoFormatMarkdown && ReactMarkdownPlugin, ...plugins].filter(Boolean).map((plugin, index) => {
|
|
982
|
+
if (typeof plugin === "function") return createElement(plugin, { key: index });
|
|
983
|
+
return createElement(plugin[0], {
|
|
984
|
+
key: index,
|
|
985
|
+
...plugin[1]
|
|
986
|
+
});
|
|
987
|
+
}), [
|
|
988
|
+
plugins,
|
|
989
|
+
enablePasteMarkdown,
|
|
990
|
+
autoFormatMarkdown,
|
|
991
|
+
ReactMarkdownPlugin
|
|
992
|
+
]);
|
|
993
|
+
const memoMention = useMemo(() => {
|
|
994
|
+
if (!enableMention) return;
|
|
995
|
+
return /* @__PURE__ */ jsx(ReactMentionPlugin, {
|
|
996
|
+
className,
|
|
997
|
+
markdownWriter
|
|
998
|
+
});
|
|
999
|
+
}, [
|
|
1000
|
+
enableMention,
|
|
1001
|
+
markdownWriter,
|
|
1002
|
+
className
|
|
1003
|
+
]);
|
|
1004
|
+
return /* @__PURE__ */ jsxs(ReactEditor, {
|
|
1005
|
+
config,
|
|
1006
|
+
editor,
|
|
1007
|
+
onInit,
|
|
1008
|
+
children: [
|
|
1009
|
+
memoPlugins,
|
|
1010
|
+
useMemo(() => {
|
|
1011
|
+
if (!enableSlash && !enableMention) return null;
|
|
1012
|
+
return /* @__PURE__ */ jsxs(ReactSlashPlugin, {
|
|
1013
|
+
getPopupContainer,
|
|
1014
|
+
placement: slashPlacement,
|
|
1015
|
+
children: [enableSlash ? /* @__PURE__ */ jsx(ReactSlashOption, {
|
|
1016
|
+
maxLength: 8,
|
|
1017
|
+
trigger: "/",
|
|
1018
|
+
...slashOption
|
|
1019
|
+
}) : void 0, enableMention ? /* @__PURE__ */ jsx(ReactSlashOption, {
|
|
1020
|
+
maxLength: 8,
|
|
1021
|
+
trigger: "@",
|
|
1022
|
+
...restMentionOption
|
|
1023
|
+
}) : void 0]
|
|
1024
|
+
});
|
|
1025
|
+
}, [
|
|
1026
|
+
enableSlash,
|
|
1027
|
+
enableMention,
|
|
1028
|
+
slashOption,
|
|
1029
|
+
slashPlacement,
|
|
1030
|
+
getPopupContainer,
|
|
1031
|
+
restMentionOption
|
|
1032
|
+
]),
|
|
1033
|
+
memoMention,
|
|
1034
|
+
/* @__PURE__ */ jsx(ReactPlainText, {
|
|
1035
|
+
autoFocus,
|
|
1036
|
+
autoFormatMarkdown,
|
|
1037
|
+
className,
|
|
1038
|
+
editable,
|
|
1039
|
+
enablePasteMarkdown,
|
|
1040
|
+
markdownOption,
|
|
1041
|
+
onBlur,
|
|
1042
|
+
onChange: debouncedOnChange,
|
|
1043
|
+
onCompositionEnd,
|
|
1044
|
+
onCompositionStart,
|
|
1045
|
+
onContextMenu,
|
|
1046
|
+
onFocus,
|
|
1047
|
+
onKeyDown,
|
|
1048
|
+
onPressEnter,
|
|
1049
|
+
onTextChange: debouncedOnTextChange,
|
|
1050
|
+
pasteAsPlainText,
|
|
1051
|
+
pasteMarkdownAutoConvertThreshold,
|
|
1052
|
+
pasteVSCodeAsCodeBlock,
|
|
1053
|
+
style,
|
|
1054
|
+
variant,
|
|
1055
|
+
children: /* @__PURE__ */ jsx(ReactEditorContent, {
|
|
1056
|
+
content,
|
|
1057
|
+
lineEmptyPlaceholder,
|
|
1058
|
+
placeholder,
|
|
1059
|
+
type
|
|
1060
|
+
})
|
|
1061
|
+
}),
|
|
1062
|
+
children
|
|
1063
|
+
]
|
|
1064
|
+
});
|
|
1065
|
+
});
|
|
1066
|
+
Editor$1.displayName = "Editor";
|
|
1067
|
+
//#endregion
|
|
1068
|
+
//#region src/react/Editor/utils.ts
|
|
1069
|
+
function withProps(plugin, props) {
|
|
1070
|
+
return [plugin, props];
|
|
1071
|
+
}
|
|
1072
|
+
//#endregion
|
|
1073
|
+
//#region src/react/Editor/index.ts
|
|
1074
|
+
const Editor = Editor$1;
|
|
1075
|
+
Editor.useEditor = useEditor;
|
|
1076
|
+
Editor.useEditorState = useEditorState;
|
|
1077
|
+
Editor.withProps = withProps;
|
|
1078
|
+
//#endregion
|
|
1079
|
+
//#region src/react/FloatActions/style.ts
|
|
1080
|
+
const styles$4 = createStaticStyles(({ css }) => ({
|
|
1081
|
+
collapsedContainer: css`
|
|
1082
|
+
overflow: hidden;
|
|
1083
|
+
display: flex;
|
|
1084
|
+
align-items: center;
|
|
1085
|
+
`,
|
|
1086
|
+
container: css`
|
|
1087
|
+
position: relative;
|
|
1088
|
+
width: 100%;
|
|
1089
|
+
`,
|
|
1090
|
+
divider: css`
|
|
1091
|
+
height: 20px;
|
|
1092
|
+
margin-inline: 4px;
|
|
1093
|
+
`
|
|
1094
|
+
}));
|
|
1095
|
+
//#endregion
|
|
1096
|
+
//#region src/react/FloatActions/components/ActionRender.tsx
|
|
1097
|
+
const ActionRender = ({ item, onActionClick, disabled }) => {
|
|
1098
|
+
if (item.type === "divider") return /* @__PURE__ */ jsx(Divider, {
|
|
1099
|
+
className: styles$4.divider,
|
|
1100
|
+
orientation: "vertical"
|
|
1101
|
+
});
|
|
1102
|
+
const { wrapper, icon, key, label, onClick, danger, loading, active, tooltipProps, ...itemRest } = item;
|
|
1103
|
+
if (item.children && isValidElement(item.children)) {
|
|
1104
|
+
if (!wrapper) return item.children;
|
|
1105
|
+
return wrapper(item.children);
|
|
1106
|
+
}
|
|
1107
|
+
const action = /* @__PURE__ */ jsx(ActionIcon, {
|
|
1108
|
+
active,
|
|
1109
|
+
danger,
|
|
1110
|
+
disabled: disabled || loading || itemRest?.disabled,
|
|
1111
|
+
icon,
|
|
1112
|
+
loading,
|
|
1113
|
+
onClick: (e) => {
|
|
1114
|
+
onActionClick?.({
|
|
1115
|
+
domEvent: e,
|
|
1116
|
+
key: String(key),
|
|
1117
|
+
keyPath: [String(key)]
|
|
1118
|
+
});
|
|
1119
|
+
onClick?.(e);
|
|
1120
|
+
},
|
|
1121
|
+
size: {
|
|
1122
|
+
blockSize: 36,
|
|
1123
|
+
size: 20
|
|
1124
|
+
},
|
|
1125
|
+
title: label,
|
|
1126
|
+
tooltipProps: {
|
|
1127
|
+
placement: "top",
|
|
1128
|
+
...tooltipProps
|
|
1129
|
+
}
|
|
1130
|
+
});
|
|
1131
|
+
if (!wrapper) return action;
|
|
1132
|
+
return wrapper(action);
|
|
1133
|
+
};
|
|
1134
|
+
//#endregion
|
|
1135
|
+
//#region src/react/FloatActions/components/CollapsedActions.tsx
|
|
1136
|
+
const CollapsedActions = ({ children, groupCollapse = false, onGroupCollapseChange, gap, mode }) => {
|
|
1137
|
+
const Motion = useMotionComponent();
|
|
1138
|
+
if (mode === "popup") return /* @__PURE__ */ jsx(Popover, {
|
|
1139
|
+
arrow: false,
|
|
1140
|
+
content: /* @__PURE__ */ jsx(Flexbox, {
|
|
1141
|
+
align: "center",
|
|
1142
|
+
gap,
|
|
1143
|
+
horizontal: true,
|
|
1144
|
+
children
|
|
1145
|
+
}),
|
|
1146
|
+
styles: { content: { padding: 4 } },
|
|
1147
|
+
children: /* @__PURE__ */ jsx(ActionIcon, {
|
|
1148
|
+
icon: CircleChevronUpIcon,
|
|
1149
|
+
size: {
|
|
1150
|
+
blockSize: 36,
|
|
1151
|
+
size: 20
|
|
1152
|
+
}
|
|
1153
|
+
})
|
|
1154
|
+
});
|
|
1155
|
+
return /* @__PURE__ */ jsxs(Flexbox, {
|
|
1156
|
+
align: "center",
|
|
1157
|
+
flex: "none",
|
|
1158
|
+
gap,
|
|
1159
|
+
horizontal: true,
|
|
1160
|
+
children: [/* @__PURE__ */ jsx(Motion.div, {
|
|
1161
|
+
animate: groupCollapse ? "closed" : "open",
|
|
1162
|
+
className: styles$4.collapsedContainer,
|
|
1163
|
+
initial: groupCollapse ? "closed" : "open",
|
|
1164
|
+
style: { gap },
|
|
1165
|
+
transition: { duration: .2 },
|
|
1166
|
+
variants: {
|
|
1167
|
+
closed: {
|
|
1168
|
+
opacity: 0,
|
|
1169
|
+
width: 0
|
|
1170
|
+
},
|
|
1171
|
+
open: {
|
|
1172
|
+
opacity: 1,
|
|
1173
|
+
width: "auto"
|
|
1174
|
+
}
|
|
1175
|
+
},
|
|
1176
|
+
children
|
|
1177
|
+
}), /* @__PURE__ */ jsx(ActionIcon, {
|
|
1178
|
+
icon: groupCollapse ? CircleChevronRightIcon : CircleChevronLeftIcon,
|
|
1179
|
+
onClick: () => onGroupCollapseChange?.(!groupCollapse),
|
|
1180
|
+
size: {
|
|
1181
|
+
blockSize: 36,
|
|
1182
|
+
size: 20
|
|
1183
|
+
}
|
|
1184
|
+
})]
|
|
1185
|
+
});
|
|
1186
|
+
};
|
|
1187
|
+
CollapsedActions.displayName = "FloatActionsCollapse";
|
|
1188
|
+
//#endregion
|
|
1189
|
+
//#region src/react/FloatActions/components/ActionItem.tsx
|
|
1190
|
+
const ActionItem = ({ item, disabled, onActionClick, groupCollapsed, gap, setGroupCollapsed }) => {
|
|
1191
|
+
if (item.type === "collapse") return /* @__PURE__ */ jsx(CollapsedActions, {
|
|
1192
|
+
gap,
|
|
1193
|
+
groupCollapse: groupCollapsed,
|
|
1194
|
+
mode: "default",
|
|
1195
|
+
onGroupCollapseChange: setGroupCollapsed,
|
|
1196
|
+
children: item.children.map((child, childIndex) => /* @__PURE__ */ jsx(ActionRender, {
|
|
1197
|
+
disabled,
|
|
1198
|
+
item: child,
|
|
1199
|
+
onActionClick
|
|
1200
|
+
}, child?.key || `action-${childIndex}`))
|
|
1201
|
+
});
|
|
1202
|
+
if (item.type === "dropdown") return /* @__PURE__ */ jsx(Dropdown, {
|
|
1203
|
+
menu: { items: item.children },
|
|
1204
|
+
children: /* @__PURE__ */ jsx(ActionIcon, {
|
|
1205
|
+
active: item.active,
|
|
1206
|
+
danger: item.danger,
|
|
1207
|
+
disabled: disabled || item.loading || item?.disabled,
|
|
1208
|
+
icon: item.icon,
|
|
1209
|
+
loading: item.loading,
|
|
1210
|
+
size: {
|
|
1211
|
+
blockSize: 36,
|
|
1212
|
+
size: 20
|
|
1213
|
+
},
|
|
1214
|
+
title: item.label,
|
|
1215
|
+
tooltipProps: {
|
|
1216
|
+
placement: "top",
|
|
1217
|
+
...item.tooltipProps
|
|
1218
|
+
}
|
|
1219
|
+
})
|
|
1220
|
+
}, item.key);
|
|
1221
|
+
return /* @__PURE__ */ jsx(ActionRender, {
|
|
1222
|
+
disabled,
|
|
1223
|
+
item,
|
|
1224
|
+
onActionClick
|
|
1225
|
+
});
|
|
1226
|
+
};
|
|
1227
|
+
ActionItem.displayName = "FloatActionsItem";
|
|
1228
|
+
//#endregion
|
|
1229
|
+
//#region src/react/FloatActions/FloatActions.tsx
|
|
1230
|
+
const FloatActions = ({ gap = 2, disabled, items = [], onActionClick, className, defaultGroupCollapse = false, onGroupCollapseChange, groupCollapse, ...rest }) => {
|
|
1231
|
+
const [groupCollapsed, setGroupCollapsed] = useMergeState(defaultGroupCollapse, {
|
|
1232
|
+
defaultValue: defaultGroupCollapse,
|
|
1233
|
+
onChange: onGroupCollapseChange,
|
|
1234
|
+
value: groupCollapse
|
|
1235
|
+
});
|
|
1236
|
+
return /* @__PURE__ */ jsx(Flexbox, {
|
|
1237
|
+
align: "center",
|
|
1238
|
+
className: cx(styles$4.container, className),
|
|
1239
|
+
flex: 1,
|
|
1240
|
+
gap,
|
|
1241
|
+
horizontal: true,
|
|
1242
|
+
...rest,
|
|
1243
|
+
children: items.map((item, index) => /* @__PURE__ */ jsx(ActionItem, {
|
|
1244
|
+
disabled,
|
|
1245
|
+
gap,
|
|
1246
|
+
groupCollapsed,
|
|
1247
|
+
item,
|
|
1248
|
+
onActionClick,
|
|
1249
|
+
setGroupCollapsed
|
|
1250
|
+
}, item.key || index))
|
|
1251
|
+
});
|
|
1252
|
+
};
|
|
1253
|
+
FloatActions.displayName = "FloatActions";
|
|
1254
|
+
//#endregion
|
|
1255
|
+
//#region src/react/FloatMenu/style.ts
|
|
1256
|
+
const styles$3 = createStaticStyles(({ css, cssVar }) => ({
|
|
1257
|
+
container: css`
|
|
1258
|
+
position: relative;
|
|
1259
|
+
overflow: hidden auto;
|
|
1260
|
+
background: ${cssVar.colorBgElevated};
|
|
1261
|
+
`,
|
|
1262
|
+
containerWithMaxHeight: css`
|
|
1263
|
+
/* maxHeight is set via inline style as it's dynamic */
|
|
1264
|
+
`,
|
|
1265
|
+
rootBottom: css`
|
|
1266
|
+
position: absolute;
|
|
1267
|
+
z-index: 9999;
|
|
1268
|
+
inset-block-start: 100%;
|
|
1269
|
+
inset-inline-start: 0;
|
|
1270
|
+
|
|
1271
|
+
padding-block-start: 8px;
|
|
1272
|
+
`,
|
|
1273
|
+
rootTop: css`
|
|
1274
|
+
position: absolute;
|
|
1275
|
+
inset-block-start: -8px;
|
|
1276
|
+
inset-inline-start: 0;
|
|
1277
|
+
transform: translateY(-100%);
|
|
1278
|
+
`
|
|
1279
|
+
}));
|
|
1280
|
+
//#endregion
|
|
1281
|
+
//#region src/react/FloatMenu/FloatMenu.tsx
|
|
1282
|
+
const FloatMenu = ({ className, style, getPopupContainer, children, maxHeight = "min(50vh, 640px)", open, placement = "top", styles: customStyles, classNames }) => {
|
|
1283
|
+
const parent = getPopupContainer();
|
|
1284
|
+
if (!parent) return;
|
|
1285
|
+
if (!open) return;
|
|
1286
|
+
return createPortal(/* @__PURE__ */ jsx(Flexbox, {
|
|
1287
|
+
className: cx(placement === "bottom" ? styles$3.rootBottom : styles$3.rootTop, classNames?.root),
|
|
1288
|
+
paddingInline: 8,
|
|
1289
|
+
style: customStyles?.root,
|
|
1290
|
+
width: "100%",
|
|
1291
|
+
children: /* @__PURE__ */ jsx(Block, {
|
|
1292
|
+
className: cx(styles$3.container, className, classNames?.container),
|
|
1293
|
+
shadow: true,
|
|
1294
|
+
style: {
|
|
1295
|
+
maxHeight,
|
|
1296
|
+
...style,
|
|
1297
|
+
...customStyles?.container
|
|
1298
|
+
},
|
|
1299
|
+
variant: "outlined",
|
|
1300
|
+
children
|
|
1301
|
+
})
|
|
1302
|
+
}), parent);
|
|
1303
|
+
};
|
|
1304
|
+
FloatMenu.displayName = "FloatMenu";
|
|
1305
|
+
//#endregion
|
|
1306
|
+
//#region src/react/SendButton/components/SendIcon.tsx
|
|
1307
|
+
const styles$2 = createStaticStyles(({ css }) => ({ icon: css`
|
|
1308
|
+
flex: none;
|
|
1309
|
+
line-height: 1;
|
|
1310
|
+
` }));
|
|
1311
|
+
const SendIcon = ({ size = "1em", style }) => {
|
|
1312
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
1313
|
+
className: cx("anticon", styles$2.icon),
|
|
1314
|
+
fill: "currentColor",
|
|
1315
|
+
fillRule: "evenodd",
|
|
1316
|
+
height: size,
|
|
1317
|
+
style,
|
|
1318
|
+
viewBox: "0 0 14 14",
|
|
1319
|
+
width: size,
|
|
1320
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1321
|
+
children: /* @__PURE__ */ jsx("path", { d: "M.743 3.773c-.818-.555-.422-1.834.567-1.828l11.496.074a1 1 0 01.837 1.538l-6.189 9.689c-.532.833-1.822.47-1.842-.518L5.525 8.51a1 1 0 01.522-.9l1.263-.686a.808.808 0 00-.772-1.42l-1.263.686a1 1 0 01-1.039-.051L.743 3.773z" })
|
|
1322
|
+
});
|
|
1323
|
+
};
|
|
1324
|
+
//#endregion
|
|
1325
|
+
//#region src/react/SendButton/components/StopIcon.tsx
|
|
1326
|
+
const styles$1 = createStaticStyles(({ css }) => ({ icon: css`
|
|
1327
|
+
flex: none;
|
|
1328
|
+
line-height: 1;
|
|
1329
|
+
` }));
|
|
1330
|
+
const StopIcon = ({ size = "1.5em", style }) => {
|
|
1331
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
1332
|
+
className: cx("anticon", styles$1.icon),
|
|
1333
|
+
color: "currentColor",
|
|
1334
|
+
height: size,
|
|
1335
|
+
style,
|
|
1336
|
+
viewBox: "0 0 1024 1024",
|
|
1337
|
+
width: size,
|
|
1338
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1339
|
+
children: /* @__PURE__ */ jsxs("g", {
|
|
1340
|
+
fill: "none",
|
|
1341
|
+
children: [
|
|
1342
|
+
/* @__PURE__ */ jsx("circle", {
|
|
1343
|
+
cx: "512",
|
|
1344
|
+
cy: "512",
|
|
1345
|
+
fill: "none",
|
|
1346
|
+
r: "426",
|
|
1347
|
+
stroke: cssVar.colorBorder,
|
|
1348
|
+
strokeWidth: "72"
|
|
1349
|
+
}),
|
|
1350
|
+
/* @__PURE__ */ jsx("rect", {
|
|
1351
|
+
fill: "currentColor",
|
|
1352
|
+
height: "252",
|
|
1353
|
+
rx: "24",
|
|
1354
|
+
ry: "24",
|
|
1355
|
+
width: "252",
|
|
1356
|
+
x: "386",
|
|
1357
|
+
y: "386"
|
|
1358
|
+
}),
|
|
1359
|
+
/* @__PURE__ */ jsx("path", {
|
|
1360
|
+
d: "M938.667 512C938.667 276.359 747.64 85.333 512 85.333",
|
|
1361
|
+
stroke: "currentColor",
|
|
1362
|
+
strokeLinecap: "round",
|
|
1363
|
+
strokeWidth: "73",
|
|
1364
|
+
children: /* @__PURE__ */ jsx("animateTransform", {
|
|
1365
|
+
attributeName: "transform",
|
|
1366
|
+
dur: "1s",
|
|
1367
|
+
from: "0 512 512",
|
|
1368
|
+
repeatCount: "indefinite",
|
|
1369
|
+
to: "360 512 512",
|
|
1370
|
+
type: "rotate"
|
|
1371
|
+
})
|
|
1372
|
+
})
|
|
1373
|
+
]
|
|
1374
|
+
})
|
|
1375
|
+
});
|
|
1376
|
+
};
|
|
1377
|
+
//#endregion
|
|
1378
|
+
//#region src/react/SendButton/style.ts
|
|
1379
|
+
const prefixCls = "ant";
|
|
1380
|
+
const styles = createStaticStyles(({ css, cssVar }) => ({
|
|
1381
|
+
button: css`
|
|
1382
|
+
&.${prefixCls}-btn {
|
|
1383
|
+
flex: none;
|
|
1384
|
+
width: var(--send-button-size, 32px) !important;
|
|
1385
|
+
height: var(--send-button-size, 32px);
|
|
1386
|
+
padding-inline: 0 !important;
|
|
1387
|
+
}
|
|
1388
|
+
`,
|
|
1389
|
+
disabled: css`
|
|
1390
|
+
&.${prefixCls}-btn {
|
|
1391
|
+
cursor: default;
|
|
1392
|
+
border-color: ${cssVar.colorBorderSecondary};
|
|
1393
|
+
background: transparent;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
.${prefixCls}-btn-compact-first-item {
|
|
1397
|
+
cursor: default;
|
|
1398
|
+
border-color: ${cssVar.colorBorderSecondary};
|
|
1399
|
+
background: transparent;
|
|
1400
|
+
}
|
|
1401
|
+
.${prefixCls}-dropdown-trigger {
|
|
1402
|
+
cursor: default;
|
|
1403
|
+
border-color: ${cssVar.colorBorderSecondary};
|
|
1404
|
+
border-inline-start-color: transparent;
|
|
1405
|
+
background: transparent;
|
|
1406
|
+
}
|
|
1407
|
+
`,
|
|
1408
|
+
dropdownButton: css`
|
|
1409
|
+
flex: none;
|
|
1410
|
+
width: fit-content;
|
|
1411
|
+
.${prefixCls}-btn {
|
|
1412
|
+
width: calc(var(--send-button-size, 32px) * 1.2);
|
|
1413
|
+
height: var(--send-button-size, 32px);
|
|
1414
|
+
}
|
|
1415
|
+
.${prefixCls}-dropdown-trigger {
|
|
1416
|
+
width: calc(var(--send-button-size, 32px) * 0.8);
|
|
1417
|
+
&.${prefixCls}-btn-primary {
|
|
1418
|
+
&::before {
|
|
1419
|
+
background-color: color-mix(in srgb, ${cssVar.colorBgLayout} 10%, transparent) !important;
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
`,
|
|
1424
|
+
dropdownButtonRound: css`
|
|
1425
|
+
.${prefixCls}-btn-compact-first-item {
|
|
1426
|
+
border-start-start-radius: calc(var(--send-button-size, 32px) / 2);
|
|
1427
|
+
border-end-start-radius: calc(var(--send-button-size, 32px) / 2);
|
|
1428
|
+
}
|
|
1429
|
+
.${prefixCls}-dropdown-trigger {
|
|
1430
|
+
width: var(--send-button-size, 32px);
|
|
1431
|
+
border-start-end-radius: calc(var(--send-button-size, 32px) / 2);
|
|
1432
|
+
border-end-end-radius: calc(var(--send-button-size, 32px) / 2);
|
|
1433
|
+
}
|
|
1434
|
+
`,
|
|
1435
|
+
loadingButton: css`
|
|
1436
|
+
&.${prefixCls}-btn {
|
|
1437
|
+
flex: none;
|
|
1438
|
+
height: var(--send-button-size, 32px);
|
|
1439
|
+
padding-inline: 0 !important;
|
|
1440
|
+
}
|
|
1441
|
+
`
|
|
1442
|
+
}));
|
|
1443
|
+
//#endregion
|
|
1444
|
+
//#region src/react/SendButton/SendButton.tsx
|
|
1445
|
+
const SendButton = ({ type = "primary", menu, className, style, loading, generating, size = 32, shape, onSend, onStop, disabled, onClick, ...rest }) => {
|
|
1446
|
+
const cssVariables = useMemo(() => ({ "--send-button-size": `${size}px` }), [size]);
|
|
1447
|
+
if (generating) return /* @__PURE__ */ jsx(Button, {
|
|
1448
|
+
className: cx(styles.loadingButton, className),
|
|
1449
|
+
onClick: (e) => {
|
|
1450
|
+
e.stopPropagation();
|
|
1451
|
+
e.preventDefault();
|
|
1452
|
+
if (onStop) onStop(e);
|
|
1453
|
+
if (onClick) onClick(e);
|
|
1454
|
+
},
|
|
1455
|
+
shape,
|
|
1456
|
+
style: {
|
|
1457
|
+
...cssVariables,
|
|
1458
|
+
...style,
|
|
1459
|
+
width: menu ? size * 2 : size
|
|
1460
|
+
},
|
|
1461
|
+
...rest,
|
|
1462
|
+
children: /* @__PURE__ */ jsx(StopIcon, { size: size * .75 })
|
|
1463
|
+
});
|
|
1464
|
+
if (loading) return /* @__PURE__ */ jsx(Button, {
|
|
1465
|
+
className: cx(styles.loadingButton, className),
|
|
1466
|
+
disabled: true,
|
|
1467
|
+
loading,
|
|
1468
|
+
shape,
|
|
1469
|
+
style: {
|
|
1470
|
+
...cssVariables,
|
|
1471
|
+
...style,
|
|
1472
|
+
width: menu ? size * 2 : size
|
|
1473
|
+
},
|
|
1474
|
+
type,
|
|
1475
|
+
...rest
|
|
1476
|
+
});
|
|
1477
|
+
if (!menu) return /* @__PURE__ */ jsx(Button, {
|
|
1478
|
+
className: cx(styles.button, disabled && styles.disabled, className),
|
|
1479
|
+
disabled,
|
|
1480
|
+
icon: /* @__PURE__ */ jsx(SendIcon, {}),
|
|
1481
|
+
onClick: (e) => {
|
|
1482
|
+
e.stopPropagation();
|
|
1483
|
+
e.preventDefault();
|
|
1484
|
+
if (onSend) onSend(e);
|
|
1485
|
+
if (onClick) onClick(e);
|
|
1486
|
+
},
|
|
1487
|
+
shape,
|
|
1488
|
+
style: {
|
|
1489
|
+
...cssVariables,
|
|
1490
|
+
...style
|
|
1491
|
+
},
|
|
1492
|
+
type,
|
|
1493
|
+
...rest
|
|
1494
|
+
});
|
|
1495
|
+
return /* @__PURE__ */ jsxs(Space.Compact, {
|
|
1496
|
+
className: cx(styles.dropdownButton, disabled && styles.disabled, shape === "round" && styles.dropdownButtonRound, className),
|
|
1497
|
+
style: {
|
|
1498
|
+
...cssVariables,
|
|
1499
|
+
...style
|
|
1500
|
+
},
|
|
1501
|
+
...rest,
|
|
1502
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
1503
|
+
className: cx(styles.button, disabled && styles.disabled, className),
|
|
1504
|
+
disabled,
|
|
1505
|
+
icon: /* @__PURE__ */ jsx(SendIcon, {}),
|
|
1506
|
+
onClick: (e) => {
|
|
1507
|
+
e.stopPropagation();
|
|
1508
|
+
e.preventDefault();
|
|
1509
|
+
if (onSend) onSend(e);
|
|
1510
|
+
if (onClick) onClick(e);
|
|
1511
|
+
},
|
|
1512
|
+
shape,
|
|
1513
|
+
style: {
|
|
1514
|
+
...cssVariables,
|
|
1515
|
+
...style
|
|
1516
|
+
},
|
|
1517
|
+
type,
|
|
1518
|
+
...rest
|
|
1519
|
+
}), /* @__PURE__ */ jsx(Dropdown$1, {
|
|
1520
|
+
menu,
|
|
1521
|
+
placement: "topRight",
|
|
1522
|
+
...rest,
|
|
1523
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
1524
|
+
className: cx(styles.button, disabled && styles.disabled, className),
|
|
1525
|
+
disabled,
|
|
1526
|
+
icon: /* @__PURE__ */ jsx(Icon, { icon: ChevronDownIcon }),
|
|
1527
|
+
shape,
|
|
1528
|
+
style: {
|
|
1529
|
+
...cssVariables,
|
|
1530
|
+
cursor: "pointer"
|
|
1531
|
+
},
|
|
1532
|
+
type
|
|
1533
|
+
})
|
|
1534
|
+
})]
|
|
1535
|
+
});
|
|
1536
|
+
};
|
|
1537
|
+
SendButton.displayName = "SendButton";
|
|
1538
|
+
//#endregion
|
|
1539
|
+
//#region src/react/SlashMenu/SlashMenu.tsx
|
|
1540
|
+
const SlashMenu = ({ options, activeKey, loading, onSelect, classNames, styles: customStyles, menuProps, ...floatMenuProps }) => {
|
|
1541
|
+
const handleMenuClick = useCallback(({ key }) => {
|
|
1542
|
+
if (!onSelect) return;
|
|
1543
|
+
const option = options.find((item) => "key" in item && item.key === key);
|
|
1544
|
+
if (option) onSelect?.(option);
|
|
1545
|
+
}, [options, onSelect]);
|
|
1546
|
+
return /* @__PURE__ */ jsx(FloatMenu, {
|
|
1547
|
+
classNames: {
|
|
1548
|
+
container: classNames?.container,
|
|
1549
|
+
root: classNames?.root
|
|
1550
|
+
},
|
|
1551
|
+
styles: {
|
|
1552
|
+
container: customStyles?.container,
|
|
1553
|
+
root: customStyles?.root
|
|
1554
|
+
},
|
|
1555
|
+
...floatMenuProps,
|
|
1556
|
+
children: /* @__PURE__ */ jsx(Menu, {
|
|
1557
|
+
className: classNames?.menu,
|
|
1558
|
+
items: loading ? [{
|
|
1559
|
+
disabled: true,
|
|
1560
|
+
key: "loading",
|
|
1561
|
+
label: "Loading..."
|
|
1562
|
+
}] : options,
|
|
1563
|
+
mode: "inline",
|
|
1564
|
+
onClick: handleMenuClick,
|
|
1565
|
+
selectedKeys: activeKey ? [activeKey] : void 0,
|
|
1566
|
+
style: customStyles?.menu,
|
|
1567
|
+
...menuProps
|
|
1568
|
+
})
|
|
1569
|
+
});
|
|
1570
|
+
};
|
|
1571
|
+
SlashMenu.displayName = "SlashMenu";
|
|
1572
|
+
//#endregion
|
|
1573
|
+
export { ChatInput, ChatInputActionBar, ChatInputActions, CodeLanguageSelect, Editor, EditorProvider, FloatActions, FloatMenu, SendButton, SlashMenu, useEditor, useEditorContent, useEditorState, withProps };
|