2
0
mirror of https://github.com/Ionaru/easy-markdown-editor synced 2025-07-07 01:54:27 -06:00

WIP: Tiny patches

This commit is contained in:
Pierre-Henri Lavigne 2024-09-18 09:07:59 +09:00
parent bf7d03e088
commit 6a4ca8629c
No known key found for this signature in database
GPG Key ID: E2D1C9E2BBD3007D

View File

@ -2461,7 +2461,7 @@ EasyMDE.prototype.render = function (el) {
// Be gentle and set back the cursor at the appropriate position // Be gentle and set back the cursor at the appropriate position
cm.doc.setCursor({ cm.doc.setCursor({
line: obj.to.line, line: obj.to.line,
ch: (delChar === 1 ? obj.to.ch : obj.to.ch - 8) - myLevels.diff, ch: obj.text[0].length + 1,
}); });
return true; return true;
} }
@ -2544,6 +2544,7 @@ EasyMDE.prototype.render = function (el) {
}); });
if (/#/.test(startText)) { if (/#/.test(startText)) {
oldText = startText + obj.text[r]; oldText = startText + obj.text[r];
oldText = oldText.replace(/#\s+#/, '##');
newText = headingCheckRow(oldText, cm); newText = headingCheckRow(oldText, cm);
if (oldText !== newText) { // A modification has been made if (oldText !== newText) { // A modification has been made
obj.text[r] = newText.substring(obj.from.ch); obj.text[r] = newText.substring(obj.from.ch);
@ -2560,6 +2561,7 @@ EasyMDE.prototype.render = function (el) {
}); });
if (/#/.test(endText)) { if (/#/.test(endText)) {
oldText = obj.text[r] + endText; oldText = obj.text[r] + endText;
oldText = oldText.replace(/#\s+#/, '##');
newText = headingCheckRow(oldText, cm); newText = headingCheckRow(oldText, cm);
if (oldText !== newText) { // A modification has been made if (oldText !== newText) { // A modification has been made
obj.text[r] = newText.replace(endText, ''); obj.text[r] = newText.replace(endText, '');
@ -2594,6 +2596,7 @@ EasyMDE.prototype.render = function (el) {
ch: obj.to.ch + 8, ch: obj.to.ch + 8,
}); });
oldText = startText + endText; oldText = startText + endText;
oldText = oldText.replace(/#\s+#/, '##');
if (/#/.test(oldText)) { if (/#/.test(oldText)) {
newText = headingCheckRow(oldText, cm); newText = headingCheckRow(oldText, cm);
if (oldText !== newText) { // A modification has been made if (oldText !== newText) { // A modification has been made