cm-md-editor 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/MdEditor.js +2 -1
package/package.json
CHANGED
package/src/MdEditor.js
CHANGED
|
@@ -341,7 +341,7 @@ export class MdEditor {
|
|
|
341
341
|
getCurrentLineInfo() {
|
|
342
342
|
const start = this.element.selectionStart
|
|
343
343
|
const text = this.element.value
|
|
344
|
-
const lineStart = text.lastIndexOf('\n', start - 1) + 1
|
|
344
|
+
const lineStart = start === 0 ? 0 : text.lastIndexOf('\n', start - 1) + 1
|
|
345
345
|
let lineEnd = text.indexOf('\n', start)
|
|
346
346
|
if (lineEnd === -1) lineEnd = text.length
|
|
347
347
|
const line = text.substring(lineStart, lineEnd)
|
|
@@ -354,6 +354,7 @@ export class MdEditor {
|
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
toggleHeading(level) {
|
|
357
|
+
this.element.focus()
|
|
357
358
|
const {lineStart, lineEnd, line} = this.getCurrentLineInfo()
|
|
358
359
|
const prefix = '#'.repeat(level) + ' '
|
|
359
360
|
const headingMatch = line.match(/^(#{1,6}) /)
|