-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: moving markdown editing to monaco (#18231)
- Loading branch information
1 parent
dae7953
commit 448b598
Showing
10 changed files
with
2,945 additions
and
48 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import loader from 'src/external/monaco.onigasm' | ||
import {Registry} from 'monaco-textmate' // peer dependency | ||
import {wireTmGrammars} from 'monaco-editor-textmate' | ||
|
||
import {MonacoType} from 'src/types' | ||
|
||
const LANGID = 'markdown' | ||
|
||
async function addSyntax(monaco: MonacoType) { | ||
monaco.languages.register({id: LANGID}) | ||
|
||
await loader() | ||
|
||
const registry = new Registry({ | ||
getGrammarDefinition: async () => ({ | ||
format: 'json', | ||
content: await import(/* webpackPrefetch: 0 */ 'src/external/markdown.tmLanguage.json').then( | ||
data => { | ||
return JSON.stringify(data) | ||
} | ||
), | ||
}), | ||
}) | ||
|
||
// map of monaco "language id's" to TextMate scopeNames | ||
const grammars = new Map() | ||
grammars.set(LANGID, LANGID) | ||
|
||
await wireTmGrammars(monaco, registry, grammars) | ||
} | ||
|
||
addSyntax(window.monaco) | ||
|
||
export default LANGID |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {MonacoType} from 'src/types' | ||
|
||
const THEME_NAME = 'markdownTheme' | ||
|
||
function addTheme(monaco: MonacoType) { | ||
monaco.editor.defineTheme(THEME_NAME, { | ||
base: 'vs-dark', | ||
inherit: false, | ||
rules: [], | ||
colors: { | ||
'editor.foreground': '#F8F8F8', | ||
'editor.background': '#202028', | ||
'editorGutter.background': '#25252e', | ||
'editor.selectionBackground': '#353640', | ||
'editorLineNumber.foreground': '#666978', | ||
'editor.lineHighlightBackground': '#353640', | ||
'editorCursor.foreground': '#ffffff', | ||
'editorActiveLineNumber.foreground': '#bec2cc', | ||
}, | ||
}) | ||
} | ||
|
||
addTheme(window.monaco) | ||
|
||
export default THEME_NAME |
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 was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.