mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-04-27 17:39:04 -04:00
feat: Add shortcut to link markdown action (#11466)
Follow forgejo/forgejo!9110 and add a shortcut to the link action, via ctrl/command + K. Close #11353 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11466 Reviewed-by: 0ko <0ko@noreply.codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: anon_ally <ANON_ALLY@noreply.codeberg.org> Co-committed-by: anon_ally <ANON_ALLY@noreply.codeberg.org>
This commit is contained in:
parent
ae0d0b5b09
commit
950cb098de
3 changed files with 41 additions and 2 deletions
|
|
@ -205,7 +205,7 @@ buttons.bold.tooltip = Add bold text (Ctrl+B / ⌘B)
|
|||
buttons.italic.tooltip = Add italic text (Ctrl+I / ⌘I)
|
||||
buttons.quote.tooltip = Quote text
|
||||
buttons.code.tooltip = Add code
|
||||
buttons.link.tooltip = Add a link
|
||||
buttons.link.tooltip = Add a link (Ctrl+K / ⌘K)
|
||||
buttons.list.unordered.tooltip = Add a bullet list
|
||||
buttons.list.ordered.tooltip = Add a numbered list
|
||||
buttons.list.task.tooltip = Add a list of tasks
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ Template Attributes:
|
|||
<div class="markdown-toolbar-group">
|
||||
<md-quote class="markdown-toolbar-button" data-tooltip-content="{{ctx.Locale.Tr "editor.buttons.quote.tooltip"}}">{{svg "octicon-quote"}}</md-quote>
|
||||
<md-code class="markdown-toolbar-button" data-tooltip-content="{{ctx.Locale.Tr "editor.buttons.code.tooltip"}}">{{svg "octicon-code"}}</md-code>
|
||||
<button class="markdown-toolbar-button show-modal" data-md-button data-md-action="new-link" data-tooltip-content="{{ctx.Locale.Tr "editor.buttons.link.tooltip"}}">{{svg "octicon-link"}}</button>
|
||||
<button class="markdown-toolbar-button show-modal" data-md-button data-md-action="new-link" data-tooltip-content="{{ctx.Locale.Tr "editor.buttons.link.tooltip"}}" data-md-ctrl-shortcut="k">{{svg "octicon-link"}}</button>
|
||||
</div>
|
||||
<div class="markdown-toolbar-group">
|
||||
<md-unordered-list class="markdown-toolbar-button" data-tooltip-content="{{ctx.Locale.Tr "editor.buttons.list.unordered.tooltip"}}">{{svg "octicon-list-unordered"}}</md-unordered-list>
|
||||
|
|
|
|||
|
|
@ -439,6 +439,40 @@ test('Markdown insert link', async ({page}) => {
|
|||
await screenshot(page);
|
||||
}
|
||||
|
||||
async function evaluateLinkInsertionShortcut(page: Page, selector: string) {
|
||||
const url = 'https://example.com';
|
||||
const description = 'Where does this lead?';
|
||||
|
||||
const expectedContent = `[${description}](${url})`;
|
||||
|
||||
const area = page.locator(selector);
|
||||
|
||||
const textarea = area.locator('textarea[name=content]');
|
||||
|
||||
await textarea.fill(description);
|
||||
await textarea.focus();
|
||||
await textarea.evaluate((it:HTMLTextAreaElement) => it.setSelectionRange(0, it.value.length));
|
||||
|
||||
await textarea.press('ControlOrMeta+KeyK');
|
||||
|
||||
const newLinkModal = page.locator('[data-modal-name="new-markdown-link"].active');
|
||||
await expect(newLinkModal).toBeVisible();
|
||||
await accessibilityCheck({page}, ['[data-modal-name="new-markdown-link"].active'], [], []);
|
||||
await screenshot(page);
|
||||
|
||||
const urlInput = newLinkModal.locator('input[name="link-url"]');
|
||||
|
||||
await expect(urlInput).not.toHaveAttribute('disabled');
|
||||
|
||||
await urlInput.fill(url);
|
||||
|
||||
await newLinkModal.locator('button[data-selector-name="ok-button"]').click();
|
||||
await expect(newLinkModal).toBeHidden();
|
||||
|
||||
await expect(textarea).toHaveValue(expectedContent);
|
||||
await screenshot(page);
|
||||
}
|
||||
|
||||
const response = await page.goto('/user2/repo1/issues/1');
|
||||
expect(response?.status()).toBe(200);
|
||||
|
||||
|
|
@ -446,6 +480,11 @@ test('Markdown insert link', async ({page}) => {
|
|||
await evaluateLinkInsertion(page, '#comment-form', false);
|
||||
await evaluateLinkInsertion(page, '#issuecomment-2', true);
|
||||
}).toPass();
|
||||
|
||||
await expect(async () => {
|
||||
await evaluateLinkInsertionShortcut(page, '#comment-form');
|
||||
await evaluateLinkInsertionShortcut(page, '#issuecomment-2');
|
||||
}).toPass();
|
||||
});
|
||||
|
||||
test('text expander has higher prio then prefix continuation', async ({page}) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue