ponkotsu-md-editor 0.2.27 → 0.2.29
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 38c832d0543c59aff7bb1d5c98869927bbbf77aba2a253f12586da85534c27cd
|
|
4
|
+
data.tar.gz: f1ce0e1dad704332b5c15fdf29df8e03a8ecbbd126f345eacfe1a5a3989d1041
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: baaf6b8ad4fc6b55c697d409b2fc515742b3641667b13cbf2447649f4885e686a97c3e222051ae505dad53f6c58e093487238776288ba96c6ac45eb1dd7804a7
|
|
7
|
+
data.tar.gz: 38303924a02c2699d9a6e5ef550dde13f2d65d90b125535d48b0bbe7b88aa305f26e56e38ea21a149ce593f000a08a888ef62f6e5876704212dc306a87368b74
|
|
@@ -39,6 +39,44 @@
|
|
|
39
39
|
if (textarea && hiddenField) {
|
|
40
40
|
// プレースホルダーのマウスホイールイベント処理
|
|
41
41
|
if (placeholder) {
|
|
42
|
+
// クリック時にエディタにフォーカス
|
|
43
|
+
placeholder.addEventListener('click', function(e) {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
textarea.focus();
|
|
46
|
+
|
|
47
|
+
// クリック位置にカーソルを設定(オプション)
|
|
48
|
+
const rect = textarea.getBoundingClientRect();
|
|
49
|
+
const x = e.clientX - rect.left;
|
|
50
|
+
const y = e.clientY - rect.top;
|
|
51
|
+
|
|
52
|
+
// contenteditable要素内の適切な位置にカーソルを設定
|
|
53
|
+
if (document.caretRangeFromPoint) {
|
|
54
|
+
const range = document.caretRangeFromPoint(e.clientX, e.clientY);
|
|
55
|
+
if (range && textarea.contains(range.startContainer)) {
|
|
56
|
+
const selection = window.getSelection();
|
|
57
|
+
selection.removeAllRanges();
|
|
58
|
+
selection.addRange(range);
|
|
59
|
+
} else {
|
|
60
|
+
// フォールバック: エディタの開始位置にカーソルを設定
|
|
61
|
+
const range = document.createRange();
|
|
62
|
+
range.selectNodeContents(textarea);
|
|
63
|
+
range.collapse(true);
|
|
64
|
+
const selection = window.getSelection();
|
|
65
|
+
selection.removeAllRanges();
|
|
66
|
+
selection.addRange(range);
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
// caretRangeFromPointが利用できない場合のフォールバック
|
|
70
|
+
const range = document.createRange();
|
|
71
|
+
range.selectNodeContents(textarea);
|
|
72
|
+
range.collapse(true);
|
|
73
|
+
const selection = window.getSelection();
|
|
74
|
+
selection.removeAllRanges();
|
|
75
|
+
selection.addRange(range);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// マウスホイールイベント処理(プレースホルダー内スクロール用)
|
|
42
80
|
placeholder.addEventListener('wheel', function(e) {
|
|
43
81
|
// プレースホルダーがスクロール可能かチェック
|
|
44
82
|
const canScrollVertically = placeholder.scrollHeight > placeholder.clientHeight;
|
|
@@ -100,7 +138,9 @@
|
|
|
100
138
|
// 初期状態でプレースホルダを表示するための空要素チェック
|
|
101
139
|
function updatePlaceholderVisibility() {
|
|
102
140
|
// <br>のみの場合も空とみなす
|
|
103
|
-
if (textarea.innerHTML.trim() === ' ' || textarea.innerHTML.trim() === ''
|
|
141
|
+
if (textarea.innerHTML.trim() === ' ' || textarea.innerHTML.trim() === ''
|
|
142
|
+
|| textarea.innerHTML.trim() === '\<br\>'
|
|
143
|
+
|| textarea.innerHTML.trim() === '<div> </div>') {
|
|
104
144
|
textarea.classList.add('empty');
|
|
105
145
|
} else {
|
|
106
146
|
textarea.classList.remove('empty');
|
|
@@ -66,17 +66,13 @@
|
|
|
66
66
|
width: 100%;
|
|
67
67
|
height: calc(24 * 20px);
|
|
68
68
|
color: var(--text-placeholder);
|
|
69
|
-
|
|
70
|
-
z-index: 1;
|
|
69
|
+
z-index: 10;
|
|
71
70
|
white-space: pre-line;
|
|
72
71
|
display: block;
|
|
73
72
|
overflow: auto;
|
|
74
73
|
padding: 0.5em 0.75em;
|
|
75
74
|
box-sizing: border-box;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
#editor_content_placeholder:hover {
|
|
79
|
-
pointer-events: auto;
|
|
75
|
+
cursor: text;
|
|
80
76
|
}
|
|
81
77
|
|
|
82
78
|
/* emptyクラスがない時(コンテンツがある時)にプレースホルダーを隠す */
|