ponkotsu-md-editor 0.1.31 → 0.1.33
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/markdown_editor.js +18 -4
- data/lib/ponkotsu/md/editor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d5308ca931db5e89ef46fcb13e678810f7ef70eb8c2ea39a477e14c7b59227c2
|
|
4
|
+
data.tar.gz: fe350b9f9fc51ab3d8966acc154e2030e90bb6b5d8eedc3217b49e8c3ab4580e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0db560c9499193088fac29e68d02efb2ac7e8817937f9bdd26002ddd92ced574f2159242d76464d9c1c206f085d7e6ddc261cd058ff9d9eb1aec02032732c87d
|
|
7
|
+
data.tar.gz: a17834cfe00ba978d18ba4381d05c4ff85cde27f4a6b172d171018aee1bc508418f3abe2b05ab0499b5935dc288ed517a4612d070f73573ddebd41738e2a480e
|
|
@@ -283,10 +283,28 @@
|
|
|
283
283
|
selectedText = textarea.value.substring(start, end);
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
// fullTextの定義をここで行う
|
|
287
|
+
const fullText = isContentEditable ?
|
|
288
|
+
(textarea.innerText || textarea.textContent || '') :
|
|
289
|
+
textarea.value;
|
|
290
|
+
|
|
286
291
|
// Bold(**)の場合のみ、選択範囲の両端に余分な空白・改行があれば除外
|
|
287
292
|
if (before === '**' && after === '**' && selectedText.length > 0) {
|
|
288
293
|
let left = 0;
|
|
289
294
|
let right = selectedText.length;
|
|
295
|
+
// 先頭が「\n 」ならスペース除去
|
|
296
|
+
if (selectedText.startsWith('\n ')) {
|
|
297
|
+
left += 2;
|
|
298
|
+
} else if (selectedText[0] === ' ' && (start > 0 && fullText[start-1] === '\n')) {
|
|
299
|
+
left += 1;
|
|
300
|
+
}
|
|
301
|
+
// 末尾が「 \n」ならスペース除去
|
|
302
|
+
if (selectedText.endsWith(' \n')) {
|
|
303
|
+
right -= 2;
|
|
304
|
+
} else if (selectedText[selectedText.length-1] === ' ' && (end < fullText.length && fullText[end] === '\n')) {
|
|
305
|
+
right -= 1;
|
|
306
|
+
}
|
|
307
|
+
// 既存の両端trimも併用(ただしスペース・改行のみ)
|
|
290
308
|
while (left < right && /[\s\n]/.test(selectedText[left])) left++;
|
|
291
309
|
while (right > left && /[\s\n]/.test(selectedText[right-1])) right--;
|
|
292
310
|
if (left !== 0 || right !== selectedText.length) {
|
|
@@ -296,10 +314,6 @@
|
|
|
296
314
|
}
|
|
297
315
|
}
|
|
298
316
|
|
|
299
|
-
const fullText = isContentEditable ?
|
|
300
|
-
(textarea.innerText || textarea.textContent || '') :
|
|
301
|
-
textarea.value;
|
|
302
|
-
|
|
303
317
|
const beforeText = fullText.substring(0, start);
|
|
304
318
|
const afterText = fullText.substring(end);
|
|
305
319
|
const newText = before + selectedText + after;
|