mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Add markdown link tooltip support to the visual editor
GitOrigin-RevId: 7ab4fd0793f057c86e4fc0307d81df376efe4d34
This commit is contained in:
committed by
Copybot
parent
93a4f0c88a
commit
8ccdc0fbc4
+13
-4
@@ -5,8 +5,10 @@ import {
|
||||
} from './codemirror-context'
|
||||
import {
|
||||
closeCommandTooltip,
|
||||
commandTooltipHandlers,
|
||||
commandTooltipState,
|
||||
} from '../extensions/command-tooltip'
|
||||
import type { CommandTooltipHandler } from '../extensions/command-tooltip'
|
||||
import ReactDOM from 'react-dom'
|
||||
import { HrefTooltipContent } from './command-tooltip/href-tooltip'
|
||||
import { UrlTooltipContent } from './command-tooltip/url-tooltip'
|
||||
@@ -68,14 +70,18 @@ export const CodeMirrorCommandTooltip = memo(function CodeMirrorLinkTooltip() {
|
||||
}
|
||||
|
||||
return ReactDOM.createPortal(
|
||||
<CodeMirrorCommandTooltipContent command={tooltipState.command} />,
|
||||
<CodeMirrorCommandTooltipContent
|
||||
command={tooltipState.command}
|
||||
handlers={state.facet(commandTooltipHandlers)}
|
||||
/>,
|
||||
tooltipView.dom
|
||||
)
|
||||
})
|
||||
|
||||
const CodeMirrorCommandTooltipContent = memo<{
|
||||
command: string
|
||||
}>(function CodeMirrorCommandTooltipContent({ command }) {
|
||||
handlers: readonly CommandTooltipHandler[]
|
||||
}>(function CodeMirrorCommandTooltipContent({ command, handlers }) {
|
||||
switch (command) {
|
||||
case 'HrefCommand':
|
||||
return <HrefTooltipContent />
|
||||
@@ -89,7 +95,10 @@ const CodeMirrorCommandTooltipContent = memo<{
|
||||
return <InputTooltipContent />
|
||||
case 'Subfile':
|
||||
return <SubfileTooltipContent />
|
||||
default:
|
||||
return null
|
||||
default: {
|
||||
// Tooltips contributed by modules via the `commandTooltipHandlers` facet
|
||||
const handler = handlers.find(handler => handler.command === command)
|
||||
return handler ? handler.render() : null
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user