Skip to content

Commit c58bbd2

Browse files
Adjust toolbar snippets for emphasis and tables
1 parent b0efd90 commit c58bbd2

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

src/components/MarkdownToolbar.test.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,24 @@ describe("MarkdownToolbar", () => {
6969
textarea.setSelectionRange(5, 5);
7070

7171
container.querySelector('[data-action="bold"]').click();
72-
expect(textarea.value).toBe("Hello****");
73-
expect(textarea.selectionStart).toBe(7);
72+
expect(textarea.value).toBe("Hello**");
73+
expect(textarea.selectionStart).toBe(6);
7474

7575
container.querySelector('[data-action="code"]').click();
76-
expect(textarea.value).toBe("Hello**``**");
77-
expect(textarea.selectionStart).toBe(8);
76+
expect(textarea.value).toBe("Hello*``*");
77+
expect(textarea.selectionStart).toBe(7);
7878

7979
container.querySelector('[data-action="table"]').click();
80-
expect(textarea.value).toBe("Hello**`|`**");
81-
expect(textarea.selectionStart).toBe(9);
80+
expect(textarea.value).toBe("Hello*`|`*");
81+
expect(textarea.selectionStart).toBe(8);
82+
83+
container.querySelector('[data-action="table-divider"]').click();
84+
expect(textarea.value).toBe("Hello*`||-`*");
85+
expect(textarea.selectionStart).toBe(10);
8286

8387
container.querySelector('[data-action="strike"]').click();
84-
expect(textarea.value).toBe("Hello**`|~~~~`**");
85-
expect(textarea.selectionStart).toBe(11);
88+
expect(textarea.value).toBe("Hello*`||-~~~~`*");
89+
expect(textarea.selectionStart).toBe(12);
8690

8791
app.unmount();
8892
});

src/components/MarkdownToolbar.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ defineExpose(
175175
class="px-3 py-2 rounded-lg border border-slate-200 bg-white text-sm font-semibold shadow-sm"
176176
data-action="bold"
177177
@mousedown.prevent
178-
@touchstart.prevent.stop="handleSnippetAction('****', 2)"
179-
@click="handleSnippetAction('****', 2)"
178+
@touchstart.prevent.stop="handleSnippetAction('**', 1)"
179+
@click="handleSnippetAction('**', 1)"
180180
>
181-
****
181+
**
182182
</button>
183183
<button
184184
type="button"
@@ -210,6 +210,16 @@ defineExpose(
210210
>
211211
|
212212
</button>
213+
<button
214+
type="button"
215+
class="px-3 py-2 rounded-lg border border-slate-200 bg-white text-sm font-semibold shadow-sm"
216+
data-action="table-divider"
217+
@mousedown.prevent
218+
@touchstart.prevent.stop="handleSnippetAction('|-', 2)"
219+
@click="handleSnippetAction('|-', 2)"
220+
>
221+
|-
222+
</button>
213223
<button
214224
type="button"
215225
class="px-3 py-2 rounded-lg border border-slate-200 bg-white text-sm font-semibold shadow-sm"

0 commit comments

Comments
 (0)