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 CHANGED
@@ -12,8 +12,6 @@
12
12
  height: calc(100vh - 4rem);
13
13
  padding: 0.7rem;
14
14
  font-family: monospace;
15
- white-space: pre-wrap;
16
- overflow-wrap: break-word;
17
15
  tab-size: 4;
18
16
  line-height: 1.3;
19
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-md-editor",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "a simple markdown editor",
5
5
  "main": "index.js",
6
6
  "scripts": {
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