mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-09-30 06:35:59 +00:00
feat: support Markdown editor bold & italic keyboard shortcuts (#9110)
Ctrl/Cmd-B & Ctrl/Cmd-I are implemented in the markdown editor to allow bolding & italicizing of text. The shortcut defers to the toolbar for implementation, and so should have the exact same behavior as clicking B or I. Fixes #7549 (Partially addresses #3604) Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9110 Reviewed-by: 0ko <0ko@noreply.codeberg.org> Reviewed-by: Lucas <sclu1034@noreply.codeberg.org> Reviewed-by: Beowulf <beowulf@beocode.eu> Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net> Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
This commit is contained in:
parent
9354efceb1
commit
512b3fad5b
4 changed files with 54 additions and 4 deletions
|
@ -517,3 +517,36 @@ test('Multiple combo markdown: insert table', async ({page}) => {
|
|||
await expect(comboboxTwo).toHaveValue('| Header | Header | Header |\n|---------|---------|---------|\n| Content | Content | Content |\n| Content | Content | Content |\n');
|
||||
await save_visual(page);
|
||||
});
|
||||
|
||||
test('Markdown bold/italic toolbar and shortcut', async ({page}) => {
|
||||
const initText = `line 1\nline 2\nline 3\nline 4`;
|
||||
|
||||
const response = await page.goto('/user2/repo1/issues/new');
|
||||
expect(response?.status()).toBe(200);
|
||||
|
||||
const textarea = page.locator('textarea[name=content]');
|
||||
await textarea.fill(initText);
|
||||
await textarea.focus();
|
||||
await textarea.evaluate((it:HTMLTextAreaElement) => it.setSelectionRange(it.value.indexOf('line 1'), it.value.indexOf('line 2')));
|
||||
|
||||
// Cases: bold via toolbar, bold via shortcut, repeat w/ italics
|
||||
page.locator('md-bold').click();
|
||||
await expect(textarea).toHaveValue(`**line 1**\nline 2\nline 3\nline 4`);
|
||||
page.locator('md-bold').click();
|
||||
await expect(textarea).toHaveValue(`line 1\nline 2\nline 3\nline 4`);
|
||||
|
||||
await textarea.press('ControlOrMeta+KeyB');
|
||||
await expect(textarea).toHaveValue(`**line 1**\nline 2\nline 3\nline 4`);
|
||||
await textarea.press('ControlOrMeta+KeyB');
|
||||
await expect(textarea).toHaveValue(`line 1\nline 2\nline 3\nline 4`);
|
||||
|
||||
page.locator('md-italic').click();
|
||||
await expect(textarea).toHaveValue(`_line 1_\nline 2\nline 3\nline 4`);
|
||||
page.locator('md-italic').click();
|
||||
await expect(textarea).toHaveValue(`line 1\nline 2\nline 3\nline 4`);
|
||||
|
||||
await textarea.press('ControlOrMeta+KeyI');
|
||||
await expect(textarea).toHaveValue(`_line 1_\nline 2\nline 3\nline 4`);
|
||||
await textarea.press('ControlOrMeta+KeyI');
|
||||
await expect(textarea).toHaveValue(`line 1\nline 2\nline 3\nline 4`);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue