-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mobile,Desktop: Fixes #9971: Fix auto-indentation in some types of co…
…de blocks (#9972)
- Loading branch information
1 parent
de03679
commit 2e3783f
Showing
7 changed files
with
41 additions
and
15 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
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
18 changes: 18 additions & 0 deletions
18
packages/editor/CodeMirror/markdown/codeBlockLanguages/defaultLanguage.ts
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,18 @@ | ||
import { LanguageDescription, LanguageSupport, StreamLanguage } from '@codemirror/language'; | ||
|
||
// To allow auto-indent to work in an unrecognised language, we define an | ||
// empty language. Doing so seems to enable auto-indent in code blocks with | ||
// that language. | ||
const defaultLangauge = StreamLanguage.define({ | ||
token: (stream) => { | ||
stream.next(); | ||
return null; | ||
}, | ||
}); | ||
|
||
const defaultLanguageDescription = LanguageDescription.of({ | ||
name: 'default', | ||
support: new LanguageSupport(defaultLangauge), | ||
}); | ||
|
||
export default defaultLanguageDescription; |
10 changes: 10 additions & 0 deletions
10
packages/editor/CodeMirror/markdown/codeBlockLanguages/lookUpLanguage.ts
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,10 @@ | ||
import { LanguageDescription } from '@codemirror/language'; | ||
import { languages } from '@codemirror/language-data'; | ||
import defaultLanguage from './defaultLanguage'; | ||
|
||
// Intended for use by the `markdown({ ... })` extension. | ||
const lookUpLanguage = (languageInfo: string) => { | ||
return LanguageDescription.matchLanguageName(languages, languageInfo) ?? defaultLanguage; | ||
}; | ||
|
||
export default lookUpLanguage; |
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