1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 01:36:22 +00:00

Create Markdown TOC at current cursor position

If there is no TOC in the current document, it's created at current
cursor position. Subsequent generation calls update TOC at existing
position.

Add additional tests with CodeMirror editor mock.
This commit is contained in:
Maciek
2018-08-26 00:34:35 +02:00
parent ede733888d
commit 1bb841d5c5
5 changed files with 496 additions and 207 deletions

View File

@@ -100,9 +100,8 @@ class SnippetNoteDetail extends React.Component {
handleGenerateToc () {
const currentMode = this.state.note.snippets[this.state.snippetIndex].mode
if (currentMode.includes('Markdown')) {
const currentValue = this.refs['code-' + this.state.snippetIndex].value
const currentEditor = this.refs['code-' + this.state.snippetIndex].refs.code.editor
markdownToc.generate(currentValue, (modifiedValue) => currentEditor.setValue(modifiedValue))
markdownToc.generateInEditor(currentEditor)
}
}