overleaf/services/web/frontend/js/features/source-editor/extensions/phrases.ts
Alf Eaton e025088065 Merge pull request #13241 from overleaf/ae-extensions-documentation
Add documentation for CodeMirror extensions

GitOrigin-RevId: e5f07084173f201919272f9d46dcdaef4b817874
2023-07-17 10:28:53 +00:00

16 lines
501 B
TypeScript

import { Compartment, EditorState, TransactionSpec } from '@codemirror/state'
const phrasesConf = new Compartment()
/**
* A built-in extension providing a mapping between translation keys and translations.
*/
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)),
}
}