ponkotsu-md-editor 0.1.35 → 0.1.36
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 +29 -28
- 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: 2f9abdf49ca94ffd0c36c71abcfddbb6f7a0f0717620b01930e8795546501c1d
|
|
4
|
+
data.tar.gz: 653a957629e983ee7fd9087fe0fa6af62bb634eed6a6c8147eca5bc0d762fb31
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5f905adc11cc36ec45f45b036881fed68aa8639054fba7d6e0b00394cea95d6e7cce14d9b225e34156c95fe34771adc0dee121804ab5e3883cdc9258ad229f87
|
|
7
|
+
data.tar.gz: ae80ec886bc51492859e2a698dd9320078ed384b186f151508184d5df69c15115d5d08ff7c4a44434b28a4aef7df4ae49e673a5ca66aba895f1dc37f4a331811
|
|
@@ -290,35 +290,12 @@
|
|
|
290
290
|
|
|
291
291
|
// Bold(**)の場合のみ、選択範囲の両端に余分な空白・改行・文末記号があれば除外
|
|
292
292
|
if (before === '**' && after === '**' && selectedText.length > 0) {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
const leadingPattern = /^[\s\n.,;:!?]+/;
|
|
297
|
-
const matchLeading = selectedText.match(leadingPattern);
|
|
298
|
-
if (matchLeading) {
|
|
299
|
-
left += matchLeading[0].length;
|
|
300
|
-
selectedText = selectedText.substring(matchLeading[0].length);
|
|
293
|
+
// 両端の「改行・空白・文末記号」をすべて除去(複数連続も対応)
|
|
294
|
+
while (/^[\s\n.,;:!?]+/.test(selectedText)) {
|
|
295
|
+
selectedText = selectedText.replace(/^[\s\n.,;:!?]+/, '');
|
|
301
296
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
const matchTrailing = selectedText.match(trailingPattern);
|
|
305
|
-
if (matchTrailing) {
|
|
306
|
-
right -= matchTrailing[0].length;
|
|
307
|
-
selectedText = selectedText.substring(0, selectedText.length - matchTrailing[0].length);
|
|
308
|
-
}
|
|
309
|
-
// 既存の両端trimも併用(ただしスペース・改行のみ)
|
|
310
|
-
while (left < right && /[\s\n]/.test(selectedText[0])) {
|
|
311
|
-
left++;
|
|
312
|
-
selectedText = selectedText.substring(1);
|
|
313
|
-
}
|
|
314
|
-
while (right > left && /[\s\n]/.test(selectedText[selectedText.length-1])) {
|
|
315
|
-
right--;
|
|
316
|
-
selectedText = selectedText.substring(0, selectedText.length-1);
|
|
317
|
-
}
|
|
318
|
-
if (left !== 0 || right !== selectedText.length) {
|
|
319
|
-
start += left;
|
|
320
|
-
end -= (selectedText.length - right);
|
|
321
|
-
// selectedTextはすでにtrim済み
|
|
297
|
+
while (/[\s\n.,;:!?]+$/.test(selectedText)) {
|
|
298
|
+
selectedText = selectedText.replace(/[\s\n.,;:!?]+$/, '');
|
|
322
299
|
}
|
|
323
300
|
}
|
|
324
301
|
|
|
@@ -1461,4 +1438,28 @@
|
|
|
1461
1438
|
}
|
|
1462
1439
|
});
|
|
1463
1440
|
|
|
1441
|
+
// === テスト用関数群 ===
|
|
1442
|
+
// 1. 選択範囲検出
|
|
1443
|
+
window.testGetSelection = function(element) {
|
|
1444
|
+
return getContentEditableSelection(element);
|
|
1445
|
+
};
|
|
1446
|
+
|
|
1447
|
+
// 2. Boldデコレーション(両端trim含む)
|
|
1448
|
+
window.testDecorateBold = function(text) {
|
|
1449
|
+
// 両端の「改行・空白・文末記号」をすべて除去(複数連続も対応)
|
|
1450
|
+
let trimmed = text;
|
|
1451
|
+
while (/^[\s\n.,;:!?]+/.test(trimmed)) {
|
|
1452
|
+
trimmed = trimmed.replace(/^[\s\n.,;:!?]+/, '');
|
|
1453
|
+
}
|
|
1454
|
+
while (/[\s\n.,;:!?]+$/.test(trimmed)) {
|
|
1455
|
+
trimmed = trimmed.replace(/[\s\n.,;:!?]+$/, '');
|
|
1456
|
+
}
|
|
1457
|
+
return `**${trimmed}**`;
|
|
1458
|
+
};
|
|
1459
|
+
|
|
1460
|
+
// 3. テキスト上書き
|
|
1461
|
+
window.testReplaceTextAtRange = function(fullText, start, end, decoratedText) {
|
|
1462
|
+
return fullText.substring(0, start) + decoratedText + fullText.substring(end);
|
|
1463
|
+
};
|
|
1464
|
+
|
|
1464
1465
|
})();
|