mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #20001 from overleaf/dp-math-preview-split-test-badge
Add split test badge to math preview tooltip GitOrigin-RevId: 9dfd30502f4b023bc7f640660904b0d3e7f4ce62
This commit is contained in:
parent
a6c97cd506
commit
93ba9fa28a
2 changed files with 21 additions and 0 deletions
|
@ -22,6 +22,9 @@ import {
|
||||||
import { documentCommands } from '../languages/latex/document-commands'
|
import { documentCommands } from '../languages/latex/document-commands'
|
||||||
import { debugConsole } from '@/utils/debugging'
|
import { debugConsole } from '@/utils/debugging'
|
||||||
import { isSplitTestEnabled } from '@/utils/splitTestUtils'
|
import { isSplitTestEnabled } from '@/utils/splitTestUtils'
|
||||||
|
import ReactDOM from 'react-dom'
|
||||||
|
import { SplitTestProvider } from '@/shared/context/split-test-context'
|
||||||
|
import SplitTestBadge from '@/shared/components/split-test-badge'
|
||||||
|
|
||||||
const REPOSITION_EVENT = 'editor:repositionMathTooltips'
|
const REPOSITION_EVENT = 'editor:repositionMathTooltips'
|
||||||
|
|
||||||
|
@ -107,6 +110,8 @@ function buildTooltips(state: EditorState): readonly Tooltip[] {
|
||||||
create() {
|
create() {
|
||||||
const dom = document.createElement('div')
|
const dom = document.createElement('div')
|
||||||
dom.append(content)
|
dom.append(content)
|
||||||
|
const badge = renderSplitTestBadge()
|
||||||
|
dom.append(badge)
|
||||||
dom.className = 'ol-cm-math-tooltip'
|
dom.className = 'ol-cm-math-tooltip'
|
||||||
|
|
||||||
return { dom, overlap: true, offset: { x: 0, y: 8 } }
|
return { dom, overlap: true, offset: { x: 0, y: 8 } }
|
||||||
|
@ -166,6 +171,20 @@ const buildTooltipContent = (
|
||||||
return element
|
return element
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const renderSplitTestBadge = () => {
|
||||||
|
const element = document.createElement('span')
|
||||||
|
ReactDOM.render(
|
||||||
|
<SplitTestProvider>
|
||||||
|
<SplitTestBadge
|
||||||
|
displayOnVariants={['enabled']}
|
||||||
|
splitTestName="math-preview"
|
||||||
|
/>
|
||||||
|
</SplitTestProvider>,
|
||||||
|
element
|
||||||
|
)
|
||||||
|
return element
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Styles for the preview tooltip
|
* Styles for the preview tooltip
|
||||||
*/
|
*/
|
|
@ -4,4 +4,6 @@
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue