Skip to content

Commit

Permalink
math: overwrite outline style for visual mode
Browse files Browse the repository at this point in the history
  • Loading branch information
elbotho committed Aug 7, 2023
1 parent c5c1073 commit 7ea11db
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions src/serlo-editor/math/visual-editor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as MQ from 'react-mathquill'

import { MathEditorProps } from './editor'
import { tw } from '@/helper/tw'

if (typeof window !== 'undefined') {
MQ.addStyles()
Expand Down Expand Up @@ -89,24 +90,32 @@ export function VisualEditor(props: VisualEditorProps) {
}

return (
<MQ.EditableMathField
latex={props.state}
onChange={(mathFieldRef) => {
// Should always be defined after first render cycle!
if (mathFieldRef?.latex) {
props.onChange(mathFieldRef.latex())
}
}}
onCopy={(event: React.ClipboardEvent) => {
event.stopPropagation()
}}
onCut={(event: React.ClipboardEvent) => {
event.stopPropagation()
}}
// @ts-expect-error https://github.com/serlo/serlo-editor-issues-and-documentation/issues/67
config={mathQuillConfig}
mathquillDidMount={onMount}
/>
<div
className={tw`
rounded-sm focus-within:outline
focus-within:outline-2 focus-within:outline-offset-1 focus-within:outline-editor-primary
[&_.mq-editable-field]:!border-none [&_.mq-editable-field]:!shadow-none
`}
>
<MQ.EditableMathField
latex={props.state}
onChange={(mathFieldRef) => {
// Should always be defined after first render cycle!
if (mathFieldRef?.latex) {
props.onChange(mathFieldRef.latex())
}
}}
onCopy={(event: React.ClipboardEvent) => {
event.stopPropagation()
}}
onCut={(event: React.ClipboardEvent) => {
event.stopPropagation()
}}
// @ts-expect-error https://github.com/serlo/serlo-editor-issues-and-documentation/issues/67
config={mathQuillConfig}
mathquillDidMount={onMount}
/>
</div>
)

function onMount(ref: MathField) {
Expand Down

0 comments on commit 7ea11db

Please sign in to comment.