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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user