overleaf/services/web/frontend/js/features/source-editor/extensions/phrases.ts

14 lines
406 B
TypeScript
Raw Normal View History

import { Compartment, EditorState, TransactionSpec } from '@codemirror/state'
const phrasesConf = new Compartment()
export const phrases = (phrases: Record<string, string>) => {
return phrasesConf.of(EditorState.phrases.of(phrases))
}
export const setPhrases = (value: Record<string, string>): TransactionSpec => {
return {
effects: phrasesConf.reconfigure(EditorState.phrases.of(value)),
}
}