ponkotsu-md-editor 0.1.40 → 0.1.42
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 +19 -1
- 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: c5a8a908a696cbe6105a8819e32fb39b259be229f70e504a7d922d18a0ab0258
|
|
4
|
+
data.tar.gz: 84047bfb4299b9f115f111f840baab12475e564b80e5df448dcb68c5ca6354e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5256725317dbdd1ac8e5bf0361bcf704e0d26b547794d54657260a49994c44e1617b8ce5615f58029d10816c0ae5c3b99b2e559658aca851c104bf42cbc4eec3
|
|
7
|
+
data.tar.gz: 2c047a04c7e63a2ee05e5ff5de221d703c3643bfb27c309eab4ed4d2ba25e883e90803c5c410558b5e16c9613e56a78480419d0f6e6fd5c2c134c9ff9445b752
|
|
@@ -119,6 +119,15 @@
|
|
|
119
119
|
selectedText = rangeText;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
// === 厳密化: selectedTextがfullText.slice(startPos, endPos)と一致しない場合、fullText内でselectedTextの位置を検索 ===
|
|
123
|
+
if (selectedText && fullText.slice(startPos, endPos) !== selectedText) {
|
|
124
|
+
const idx = fullText.indexOf(selectedText);
|
|
125
|
+
if (idx !== -1) {
|
|
126
|
+
startPos = idx;
|
|
127
|
+
endPos = idx + selectedText.length;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
122
131
|
// === デバッグ出力 ===
|
|
123
132
|
console.log('[DEBUG] getContentEditableSelection');
|
|
124
133
|
console.log('fullText:', JSON.stringify(fullText));
|
|
@@ -1460,7 +1469,16 @@
|
|
|
1460
1469
|
|
|
1461
1470
|
// 3. テキスト上書き
|
|
1462
1471
|
window.testReplaceTextAtRange = function(fullText, start, end, decoratedText, selectedText) {
|
|
1463
|
-
//
|
|
1472
|
+
// 通常はstart~endで置換
|
|
1473
|
+
if (fullText.slice(start, end) === selectedText) {
|
|
1474
|
+
return fullText.slice(0, start) + decoratedText + fullText.slice(end);
|
|
1475
|
+
}
|
|
1476
|
+
// 一致しない場合は、fullText内でselectedTextの最初の出現位置を検索して置換
|
|
1477
|
+
const idx = fullText.indexOf(selectedText, start);
|
|
1478
|
+
if (idx !== -1) {
|
|
1479
|
+
return fullText.slice(0, idx) + decoratedText + fullText.slice(idx + selectedText.length);
|
|
1480
|
+
}
|
|
1481
|
+
// それでも見つからない場合は、start~endで強制置換
|
|
1464
1482
|
return fullText.slice(0, start) + decoratedText + fullText.slice(end);
|
|
1465
1483
|
};
|
|
1466
1484
|
|