ponkotsu-md-editor 0.2.25 → 0.2.27

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: b39285cb3c11935b70831d8f255a83a4e0172e4d1ae05711b655f9c98385b9b5
4
- data.tar.gz: ea9d8d7b9ed8abfff14fbcb4fca0af95328a3dd4198bb9c687f35a0bfaabb182
3
+ metadata.gz: a62abee53705774de1ddb148109d1980ef81a2bbc2dfb394eba3b9e3b727ef65
4
+ data.tar.gz: 57a970cb1f1896c27e1600a55f362c810911a59e52ad5796b878351b0e1581ea
5
5
  SHA512:
6
- metadata.gz: b6f02739e0bba7835333927d8d61e0fa6d8db23288a5971ddba138758ade2c08376fb6b04ee8bf81f1ed163e3b4bc0c44f569509be6565b765402088894d32f1
7
- data.tar.gz: 8de8efe672cdda1aa7d260bcd29178344ee7397ea92d6a0b9bc28f66c619c009cf50a69fdea550561279e8146030ec6ce1b1b3c78d70014551e50469d6ba6a6b
6
+ metadata.gz: 84bc8d46a094331d7c0ae6e098a2af3fbda1742aead8f862fc1c3409be4ad90ea822d4863b8605acb3be8b652f577c41e1e65c659e29cd92f4ee522b655b75ae
7
+ data.tar.gz: 7f65b7c3437e6aa0cf707161b0eb9d8046e08b73415235a6a9cd8adc48d3b7d2a7a5a24d0b2d9ff481b22c488d680559d805fb04ae0994000e53b8aa4094dc57
@@ -34,8 +34,51 @@
34
34
  const run = () => {
35
35
  const textarea = document.getElementById('editor_content');
36
36
  const hiddenField = document.getElementById('content_hidden_field');
37
+ const placeholder = document.getElementById('editor_content_placeholder');
37
38
 
38
39
  if (textarea && hiddenField) {
40
+ // プレースホルダーのマウスホイールイベント処理
41
+ if (placeholder) {
42
+ placeholder.addEventListener('wheel', function(e) {
43
+ // プレースホルダーがスクロール可能かチェック
44
+ const canScrollVertically = placeholder.scrollHeight > placeholder.clientHeight;
45
+ const canScrollHorizontally = placeholder.scrollWidth > placeholder.clientWidth;
46
+
47
+ if (canScrollVertically || canScrollHorizontally) {
48
+ // スクロール方向を判定
49
+ const deltaY = e.deltaY;
50
+ const deltaX = e.deltaX;
51
+
52
+ // 垂直スクロールの処理
53
+ if (Math.abs(deltaY) > Math.abs(deltaX) && canScrollVertically) {
54
+ const currentScrollTop = placeholder.scrollTop;
55
+ const maxScrollTop = placeholder.scrollHeight - placeholder.clientHeight;
56
+
57
+ // スクロール範囲内の場合のみイベントを停止
58
+ if ((deltaY > 0 && currentScrollTop < maxScrollTop) ||
59
+ (deltaY < 0 && currentScrollTop > 0)) {
60
+ e.preventDefault();
61
+ e.stopPropagation();
62
+ placeholder.scrollTop += deltaY;
63
+ }
64
+ }
65
+ // 水平スクロールの処理
66
+ else if (canScrollHorizontally) {
67
+ const currentScrollLeft = placeholder.scrollLeft;
68
+ const maxScrollLeft = placeholder.scrollWidth - placeholder.clientWidth;
69
+
70
+ // スクロール範囲内の場合のみイベントを停止
71
+ if ((deltaX > 0 && currentScrollLeft < maxScrollLeft) ||
72
+ (deltaX < 0 && currentScrollLeft > 0)) {
73
+ e.preventDefault();
74
+ e.stopPropagation();
75
+ placeholder.scrollLeft += deltaX;
76
+ }
77
+ }
78
+ }
79
+ }, { passive: false });
80
+ }
81
+
39
82
  const syncToHidden = () => {
40
83
  hiddenField.value = (textarea.innerText || '').replaceAll('\u00A0', ' ');
41
84
  };
@@ -75,6 +75,10 @@
75
75
  box-sizing: border-box;
76
76
  }
77
77
 
78
+ #editor_content_placeholder:hover {
79
+ pointer-events: auto;
80
+ }
81
+
78
82
  /* emptyクラスがない時(コンテンツがある時)にプレースホルダーを隠す */
79
83
  #editor_content:not(.empty) ~ #editor_content_placeholder {
80
84
  display: none;
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PonkotsuMdEditor
4
- VERSION = "0.2.25"
4
+ VERSION = "0.2.27"
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.2.25
4
+ version: 0.2.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - dhq_boiler