1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-18 09:35:20 +02:00
joplin/ElectronClient/gui/NoteEditor/NoteBody/CodeMirror/utils/useJoplinMode.ts

26 lines
829 B
TypeScript

import 'codemirror/addon/mode/multiplex';
import 'codemirror/mode/stex/stex';
// Joplin markdown is a the same as markdown mode, but it has configured defaults
// and support for katex math blocks
export default function useJoplinMode(CodeMirror: any) {
CodeMirror.defineMode('joplin-markdown', (config: any) => {
const stex = CodeMirror.getMode(config, { name: 'stex', inMathMode: true });
const blocks = [{ open: '$$', close: '$$', mode: stex, delimStyle: 'katex-marker' },
{ open: '$', close: '$', mode: stex, delimStyle: 'katex-marker' }];
const markdownOptions = {
name: 'markdown',
taskLists: true,
strikethrough: true,
emoji: true,
tokenTypeOverrides: {
linkText: 'link-text',
},
};
return CodeMirror.multiplexingMode(CodeMirror.getMode(config, markdownOptions), ...blocks);
});
}