ponkotsu-md-editor 0.1.30 → 0.1.32

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78b9307ca464fe68ab92aa6503456c8d37b92cccade83df5cecb85a1d38a9620
4
- data.tar.gz: 9a26b6853ae9c65d8929c7819cc1c23d7994668d59bb990c80336c37d19ddf3d
3
+ metadata.gz: 20516b4cf7de7bf33b5db048a4a440ac8610cd6beb8c0f1467e4285aff2f5c01
4
+ data.tar.gz: ffe60497f34d0a334893df718e780dc1185520702050404de42cd58438d7f475
5
5
  SHA512:
6
- metadata.gz: f56ce70569efbb1e86ed4a69aadc3b7a4ecf7057d27ee4c80e12c078c5da3764fac0d1b17004bbb2f5a07daf1ed127a4bca3d7c6ace96f08d68488c2b19ca7cf
7
- data.tar.gz: 1e012b1ae5052d141896a6ca9ca9287a66a506abd0642dff35f620c2bfd5987f5da78c910d2dfecd52865c02844261604ec16b5c1d90a7efad38f04fe5092551
6
+ metadata.gz: 71e0526ff22119d58f15996cfc5eaeda4670efc11d2cba467dcfea8a6ec73799aef89e82112ea8e03c1562142dce004bd13fa1707cc945b430e8cadc93645836
7
+ data.tar.gz: dcbd053ab758b2f967f9454542a165f35e919f15ce8918a845011f8bae8ff2a153767fe150d52f7ef3d414dc869ce7b4081a9ea11164fbc1bab6890df81d8a34
@@ -283,6 +283,32 @@
283
283
  selectedText = textarea.value.substring(start, end);
284
284
  }
285
285
 
286
+ // Bold(**)の場合のみ、選択範囲の両端に余分な空白・改行があれば除外
287
+ if (before === '**' && after === '**' && selectedText.length > 0) {
288
+ let left = 0;
289
+ let right = selectedText.length;
290
+ // 先頭が「\n 」ならスペース除去
291
+ if (selectedText.startsWith('\n ')) {
292
+ left += 2;
293
+ } else if (selectedText[0] === ' ' && (start > 0 && fullText[start-1] === '\n')) {
294
+ left += 1;
295
+ }
296
+ // 末尾が「 \n」ならスペース除去
297
+ if (selectedText.endsWith(' \n')) {
298
+ right -= 2;
299
+ } else if (selectedText[selectedText.length-1] === ' ' && (end < fullText.length && fullText[end] === '\n')) {
300
+ right -= 1;
301
+ }
302
+ // 既存の両端trimも併用(ただしスペース・改行のみ)
303
+ while (left < right && /[\s\n]/.test(selectedText[left])) left++;
304
+ while (right > left && /[\s\n]/.test(selectedText[right-1])) right--;
305
+ if (left !== 0 || right !== selectedText.length) {
306
+ start += left;
307
+ end -= (selectedText.length - right);
308
+ selectedText = selectedText.substring(left, right);
309
+ }
310
+ }
311
+
286
312
  const fullText = isContentEditable ?
287
313
  (textarea.innerText || textarea.textContent || '') :
288
314
  textarea.value;
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PonkotsuMdEditor
4
- VERSION = "0.1.30"
4
+ VERSION = "0.1.32"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ponkotsu-md-editor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.30
4
+ version: 0.1.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - dhq_boiler