cm-md-editor 1.0.2 → 1.0.3

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
@@ -39,8 +39,7 @@ This is a minimal **markdown editor** which is used in chessmail.de.
39
39
  - easy to use
40
40
  - fast
41
41
 
42
- ☝️ [Check out the Demo page](https://shaack.com/projekte/cm-md-editor/)
43
- </textarea>
42
+ ☝️ [Check out the Demo page](https://shaack.com/projekte/cm-md-editor/)</textarea>
44
43
  </div>
45
44
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
46
45
  integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-md-editor",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "a simple markdown editor",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/MdEditor.js CHANGED
@@ -64,16 +64,15 @@ export class MdEditor {
64
64
  const before = this.element.value.substring(0, start)
65
65
  const currentLine = before.substring(before.lastIndexOf('\n') + 1)
66
66
  const matchEmpty = currentLine.match(/^(\s*- )$/)
67
- const match = currentLine.match(/^(\s*- )/)
68
- if(matchEmpty) {
69
- e.preventDefault()
67
+ 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
+ if (matchEmpty) {
70
71
  const pre = matchEmpty[1]
71
- this.element.selectionStart = before.lastIndexOf('\n') + 1
72
- this.element.selectionEnd = this.element.selectionStart + pre.length
73
- this.insertTextAtCursor('')
74
- } else if (match) {
72
+ this.element.selectionStart = this.element.selectionEnd - pre.length - 1
73
+ } else if (matchHyphen) {
75
74
  e.preventDefault()
76
- const pre = match[1]
75
+ const pre = matchHyphen[1]
77
76
  this.insertTextAtCursor('\n' + pre)
78
77
  }
79
78
  }