phrases.ts 406 B

12345678910111213
  1. import { Compartment, EditorState, TransactionSpec } from '@codemirror/state'
  2. const phrasesConf = new Compartment()
  3. export const phrases = (phrases: Record<string, string>) => {
  4. return phrasesConf.of(EditorState.phrases.of(phrases))
  5. }
  6. export const setPhrases = (value: Record<string, string>): TransactionSpec => {
  7. return {
  8. effects: phrasesConf.reconfigure(EditorState.phrases.of(value)),
  9. }
  10. }