mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 13:30:23 -05:00
25 lines
538 B
TypeScript
25 lines
538 B
TypeScript
|
import { StateEffect, StateField } from '@codemirror/state'
|
||
|
|
||
|
export const docName = (docName: string) =>
|
||
|
StateField.define<string>({
|
||
|
create() {
|
||
|
return docName
|
||
|
},
|
||
|
update(value, tr) {
|
||
|
for (const effect of tr.effects) {
|
||
|
if (effect.is(setDocNameEffect)) {
|
||
|
value = effect.value
|
||
|
}
|
||
|
}
|
||
|
return value
|
||
|
},
|
||
|
})
|
||
|
|
||
|
export const setDocNameEffect = StateEffect.define<string>()
|
||
|
|
||
|
export const setDocName = (docName: string) => {
|
||
|
return {
|
||
|
effects: setDocNameEffect.of(docName),
|
||
|
}
|
||
|
}
|