phrases.ts 501 B

12345678910111213141516
  1. import { Compartment, EditorState, TransactionSpec } from '@codemirror/state'
  2. const phrasesConf = new Compartment()
  3. /**
  4. * A built-in extension providing a mapping between translation keys and translations.
  5. */
  6. export const phrases = (phrases: Record<string, string>) => {
  7. return phrasesConf.of(EditorState.phrases.of(phrases))
  8. }
  9. export const setPhrases = (value: Record<string, string>): TransactionSpec => {
  10. return {
  11. effects: phrasesConf.reconfigure(EditorState.phrases.of(value)),
  12. }
  13. }