1
Fork 0

Improve "URL" handling in markdown editor (#7006)

The button to insert an URL now opens a dialog prompting for the two
components, the URL and the description.
Any existing text selection is taken into account to pre-fill the
description field.

Closes: #6731

![image](/attachments/ca1f7767-5fd6-4c38-8c7a-83d893523de2)

Co-authored-by: Otto Richter <otto@codeberg.org>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7006
Reviewed-by: Otto <otto@codeberg.org>
Co-authored-by: Lucas Schwiderski <lucas@lschwiderski.de>
Co-committed-by: Lucas Schwiderski <lucas@lschwiderski.de>
This commit is contained in:
Lucas Schwiderski 2025-02-25 20:40:16 +00:00 committed by Otto
parent 3372db660c
commit 6dad457552
4 changed files with 114 additions and 1 deletions

View file

@ -5,6 +5,7 @@
// @watch end
import {expect} from '@playwright/test';
import {accessibilityCheck} from './shared/accessibility.ts';
import {save_visual, test} from './utils_e2e.ts';
test.use({user: 'user2'});
@ -224,6 +225,33 @@ test('markdown insert table', async ({page}) => {
await save_visual(page);
});
test('markdown insert link', async ({page}) => {
const response = await page.goto('/user2/repo1/issues/new');
expect(response?.status()).toBe(200);
const newLinkButton = page.locator('button[data-md-action="new-link"]');
await newLinkButton.click();
const newLinkModal = page.locator('div[data-markdown-link-modal-id="0"]');
await expect(newLinkModal).toBeVisible();
await accessibilityCheck({page}, ['[data-modal-name="new-markdown-link"]'], [], []);
await save_visual(page);
const url = 'https://example.com';
const description = 'Where does this lead?';
await newLinkModal.locator('input[name="link-url"]').fill(url);
await newLinkModal.locator('input[name="link-description"]').fill(description);
await newLinkModal.locator('button[data-selector-name="ok-button"]').click();
await expect(newLinkModal).toBeHidden();
const textarea = page.locator('textarea[name=content]');
await expect(textarea).toHaveValue(`[${description}](${url})`);
await save_visual(page);
});
test('text expander has higher prio then prefix continuation', async ({page}) => {
const response = await page.goto('/user2/repo1/issues/new');
expect(response?.status()).toBe(200);