diff --git a/packages/ui-default/components/preview/preview.page.ts b/packages/ui-default/components/preview/preview.page.ts
index a67361e54..223a02476 100644
--- a/packages/ui-default/components/preview/preview.page.ts
+++ b/packages/ui-default/components/preview/preview.page.ts
@@ -46,10 +46,12 @@ const dialogAction = (id) => [
];
function bindCopyLink(id, src: string) {
+ // Usually brackets are allowed in URLs, but in markdown there's need to escape them
+ src = src.replace(/\(/g, '%28').replace(/\)/g, '%29');
const url = !['file', 'files'].some((i) => window.location.href.endsWith(i))
|| ['homework', 'training'].some((i) => window.location.href.match(`${i}/.*/file`))
? `file://${src.substring(src.lastIndexOf('/') + 1)}` : src;
- const clip = new Clipboard(`#copy-${id}`, { text: () => `${url}` });
+ const clip = new Clipboard(`#copy-${id}`, { text: () => url });
clip.on('success', () => Notification.success(i18n(`${url.startsWith('file://') ? 'Reference' : 'Download'} link copied to clipboard!`)));
clip.on('error', () => Notification.error(i18n('Copy failed :(')));
}
@@ -142,11 +144,7 @@ export async function previewFile(ev?, type = '') {
const id = nanoid();
const dialog = new ActionDialog({
$body: tpl.typoMsg(i18n('Cannot preview this file. Download now?')),
- $action: [
- tpl``,
- tpl``,
- tpl``,
- ],
+ $action: dialogAction(id),
});
bindCopyLink(id, link);
const action = await dialog.open();