-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): expose onMount to CodeField (#10223)
This is useful for modifying the monaco instance, e.g. to add external types to the editor: ```tsx <CodeField autoComplete={autoComplete} field={props} forceRender={forceRender} key={key} onMount={(editor, monaco) => { console.log('editor mounted') monaco.languages.typescript.typescriptDefaults.setCompilerOptions({ allowNonTsExtensions: true, moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs, paths: { payload: ['file:///node_modules/payload/index.d.ts'], }, target: monaco.languages.typescript.ScriptTarget.ESNext, typeRoots: ['node_modules/@types', 'node_modules/payload'], }) const run = async () => { const types = await fetch('https://unpkg.com/payload@latest/dist/index.d.ts') const typesText = await types.text() monaco.languages.typescript.typescriptDefaults.addExtraLib( typesText, 'file:///node_modules/payload/index.d.ts', ) } void run() }} path={path} permissions={permissions} readOnly={readOnly} renderedBlocks={renderedBlocks} schemaPath={schemaPath} validate={validate} /> ```
- Loading branch information
Showing
3 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters