Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor() {
super();
addMathquillStyles();
this.state = {
latex: '\\frac{1}{\\sqrt{2}}\\cdot 2',
};
}
import * as React from 'react'
import { Editor } from 'slate'
import {
NodeRendererProps,
NodeEditorProps,
TextPlugin,
NodeControlsProps,
trimSelection
} from '../..'
import { SlatePluginClosure } from '../../factory/types'
import { katexBlockNode, katexInlineNode } from '../../model'
import { DefaultEditorComponent } from './editor'
if (canUseDOM) {
require('react-mathquill').addStyles()
}
export const isKatex = (editor: Editor) => {
return (
editor.value.blocks.some(block =>
block ? block.type === katexBlockNode : false
) ||
editor.value.inlines.some(inline =>
inline ? inline.type === katexInlineNode : false
)
)
}
export const insertKatex = (editor: Editor) => {
if (editor.value.selection.isExpanded) {
trimSelection(editor)
const selection = document.getSelection()