cm-md-editor 1.0.3 → 1.0.4
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/index.html +0 -2
- package/package.json +1 -1
- package/src/MdEditor.js +1 -4
package/index.html
CHANGED
package/package.json
CHANGED
package/src/MdEditor.js
CHANGED
|
@@ -6,12 +6,11 @@ export class MdEditor {
|
|
|
6
6
|
|
|
7
7
|
constructor(element) {
|
|
8
8
|
this.element = element
|
|
9
|
-
|
|
10
|
-
// listen to typing
|
|
11
9
|
this.element.addEventListener('keydown', (e) => this.handleKeyDown(e))
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
insertTextAtCursor(text) {
|
|
13
|
+
// execCommand is deprecated, but without alternative to insert text and preserve the correct undo/redo stack
|
|
15
14
|
document.execCommand("insertText", false, text)
|
|
16
15
|
}
|
|
17
16
|
|
|
@@ -65,8 +64,6 @@ export class MdEditor {
|
|
|
65
64
|
const currentLine = before.substring(before.lastIndexOf('\n') + 1)
|
|
66
65
|
const matchEmpty = currentLine.match(/^(\s*- )$/)
|
|
67
66
|
const matchHyphen = currentLine.match(/^(\s*- )/)
|
|
68
|
-
console.log("start", start, "before", before, "currentLine", currentLine, "matchEmpty", matchEmpty, "matchHyphen", matchHyphen)
|
|
69
|
-
console.log("this.element.selectionStart", this.element.selectionStart, "this.element.selectionEnd", this.element.selectionEnd)
|
|
70
67
|
if (matchEmpty) {
|
|
71
68
|
const pre = matchEmpty[1]
|
|
72
69
|
this.element.selectionStart = this.element.selectionEnd - pre.length - 1
|