-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for markdown in notes (#1587)
- Loading branch information
Showing
5 changed files
with
1,055 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { newlineToBreak } from 'mdast-util-newline-to-break'; | ||
|
||
export function sequentialNewlinesPlugin() { | ||
// Adapted from https://codesandbox.io/s/create-react-app-forked-h3rmcy?file=/src/sequentialNewlinePlugin.js:0-774 | ||
const data = this.data(); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function add(field: string, value: any) { | ||
const list = data[field] ? data[field] : (data[field] = []); | ||
|
||
list.push(value); | ||
} | ||
|
||
add('fromMarkdownExtensions', { | ||
enter: { | ||
lineEndingBlank: function enterLineEndingBlank(token: unknown) { | ||
this.enter( | ||
{ | ||
type: 'break', | ||
value: '', | ||
data: {}, | ||
children: [], | ||
}, | ||
token, | ||
); | ||
}, | ||
}, | ||
exit: { | ||
lineEndingBlank: function exitLineEndingBlank(token: unknown) { | ||
this.exit(token); | ||
}, | ||
}, | ||
}); | ||
} | ||
|
||
export function remarkBreaks() { | ||
return newlineToBreak; | ||
} |
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,6 @@ | ||
--- | ||
category: Enhancements | ||
authors: [OlegWock] | ||
--- | ||
|
||
Support markdown in notes |
Oops, something went wrong.