Skip to content

Commit 935444b

Browse files
Improve toolbar tap responsiveness
1 parent 03459e8 commit 935444b

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/components/MarkdownToolbar.vue

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ const insertSnippet = (snippet, cursorOffset) => {
7979
updateTextarea(textarea, newValue, cursor, cursor);
8080
};
8181
82+
const handleLineAction = (type) => {
83+
applyLinePrefix(type);
84+
};
85+
86+
const handleSnippetAction = (snippet, cursorOffset) => {
87+
insertSnippet(snippet, cursorOffset);
88+
};
89+
8290
const toolbarOffset = ref(0);
8391
8492
const updateToolbarOffset = () => {
@@ -129,8 +137,8 @@ onBeforeUnmount(() => {
129137
class="px-3 py-2 rounded-lg border border-slate-200 bg-white text-sm font-semibold shadow-sm"
130138
data-action="heading"
131139
@mousedown.prevent
132-
@touchstart.prevent
133-
@click="applyLinePrefix('heading')"
140+
@touchstart.prevent.stop="handleLineAction('heading')"
141+
@click="handleLineAction('heading')"
134142
>
135143
#
136144
</button>
@@ -139,8 +147,8 @@ onBeforeUnmount(() => {
139147
class="px-3 py-2 rounded-lg border border-slate-200 bg-white text-sm font-semibold shadow-sm"
140148
data-action="list"
141149
@mousedown.prevent
142-
@touchstart.prevent
143-
@click="applyLinePrefix('list')"
150+
@touchstart.prevent.stop="handleLineAction('list')"
151+
@click="handleLineAction('list')"
144152
>
145153
-
146154
</button>
@@ -149,8 +157,8 @@ onBeforeUnmount(() => {
149157
class="px-3 py-2 rounded-lg border border-slate-200 bg-white text-sm font-semibold shadow-sm"
150158
data-action="quote"
151159
@mousedown.prevent
152-
@touchstart.prevent
153-
@click="applyLinePrefix('quote')"
160+
@touchstart.prevent.stop="handleLineAction('quote')"
161+
@click="handleLineAction('quote')"
154162
>
155163
&gt;
156164
</button>
@@ -159,8 +167,8 @@ onBeforeUnmount(() => {
159167
class="px-3 py-2 rounded-lg border border-slate-200 bg-white text-sm font-semibold shadow-sm"
160168
data-action="bold"
161169
@mousedown.prevent
162-
@touchstart.prevent
163-
@click="insertSnippet('****', 2)"
170+
@touchstart.prevent.stop="handleSnippetAction('****', 2)"
171+
@click="handleSnippetAction('****', 2)"
164172
>
165173
****
166174
</button>
@@ -169,8 +177,8 @@ onBeforeUnmount(() => {
169177
class="px-3 py-2 rounded-lg border border-slate-200 bg-white text-sm font-semibold shadow-sm"
170178
data-action="strike"
171179
@mousedown.prevent
172-
@touchstart.prevent
173-
@click="insertSnippet('~~~~', 2)"
180+
@touchstart.prevent.stop="handleSnippetAction('~~~~', 2)"
181+
@click="handleSnippetAction('~~~~', 2)"
174182
>
175183
~~~~
176184
</button>
@@ -179,8 +187,8 @@ onBeforeUnmount(() => {
179187
class="px-3 py-2 rounded-lg border border-slate-200 bg-white text-sm font-semibold shadow-sm"
180188
data-action="rule"
181189
@mousedown.prevent
182-
@touchstart.prevent
183-
@click="applyLinePrefix('rule')"
190+
@touchstart.prevent.stop="handleLineAction('rule')"
191+
@click="handleLineAction('rule')"
184192
>
185193
---
186194
</button>

0 commit comments

Comments
 (0)