[visual-markdown-editor] Support for images for in project files

GitOrigin-RevId: 488ebcfc6429cfa2ce4f919f8c736822c80fdca1
This commit is contained in:
Domagoj Kriskovic
2026-09-17 11:56:36 +00:00
committed by Copybot
parent cd7ac6f2fc
commit 0adf9ea45c
3 changed files with 41 additions and 3 deletions
@@ -0,0 +1,23 @@
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)),
})
@@ -49,6 +49,7 @@ import { breadcrumbPanel } from './breadcrumbs-panel'
import { geometryChangeEvent } from './geometry-change-event'
import { docName } from './doc-name'
import { filePreview } from './file-preview'
import { docFolder } from './doc-folder'
import { fileTreeItemDrop } from './file-tree-item-drop'
import { mathPreview } from './math-preview'
import { ranges } from './ranges'
@@ -135,6 +136,7 @@ export const createExtensions = (options: Record<string, any>): Extension[] => [
docName(options.docName),
filePreview(options.previewByPath),
docFolder(options.currentDocFolder),
// NOTE: `annotations` needs to be before `language`
annotations(),