mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
24 lines
632 B
TypeScript
24 lines
632 B
TypeScript
import {
|
|
Compartment,
|
|
Extension,
|
|
Facet,
|
|
TransactionSpec,
|
|
} from '@codemirror/state'
|
|
|
|
const docFolderConf = new Compartment()
|
|
|
|
/**
|
|
* Folder of the open document (null at the project root), for resolving
|
|
* document-relative file paths.
|
|
*/
|
|
export const docFolderFacet = Facet.define<string | null, string | null>({
|
|
combine: values => values[0] ?? null,
|
|
})
|
|
|
|
export const docFolder = (docFolder: string | null): Extension =>
|
|
docFolderConf.of(docFolderFacet.of(docFolder))
|
|
|
|
export const setDocFolder = (docFolder: string | null): TransactionSpec => ({
|
|
effects: docFolderConf.reconfigure(docFolderFacet.of(docFolder)),
|
|
})
|