From 5aca0ca0edb97637c97b9ec16fef8584703aff32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1sp=C3=A1r=20J=C3=B3zsef=20D=C3=A1niel?= Date: Wed, 10 May 2023 21:21:10 +0200 Subject: [PATCH] Add document: link support to free text --- src/App.vue | 26 ++++++++++++------------- src/components/fields/Field_Wysiwyg.vue | 1 + 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/App.vue b/src/App.vue index c6f2254..5968687 100644 --- a/src/App.vue +++ b/src/App.vue @@ -287,23 +287,23 @@ export default class App extends BaseClass { // @ts-ignore // eslint-disable-next-line @typescript-eslint/no-unsafe-call if (event.target && event.target.tagName.toLowerCase() === "a" && event.target.closest(".fieldWysiwyg")) { - const isValidHttpUrl = (string:string) => { - let url - - try { - url = new URL(string) + try { + // @ts-ignore + const url = new URL(event.target.href as string) + // @ts-ignore + console.log(url) + if (url.protocol === "http:" || url.protocol === "https:") { + shell.openExternal(url.href).catch(e => console.log(e)) } - catch (_) { - return false + else if (url.protocol === "document:") { + const doc = this.SGET_document(url.pathname) + /* eslint-disable */ + this.openExistingDocumentRoute(doc) + /* eslint-enable */ } - - return url.protocol === "http:" || url.protocol === "https:" } + catch (_) { - // @ts-ignore - if (isValidHttpUrl(event.target.href)) { - // @ts-ignore - shell.openExternal(event.target.href).catch(e => console.log(e)) } } } diff --git a/src/components/fields/Field_Wysiwyg.vue b/src/components/fields/Field_Wysiwyg.vue index 825755d..9519669 100644 --- a/src/components/fields/Field_Wysiwyg.vue +++ b/src/components/fields/Field_Wysiwyg.vue @@ -170,6 +170,7 @@ export default class Field_Wysiwyg extends FieldBase { * Wysiwyg toolbar ontions */ wysiwygOptions = [ + ["link"], ["left", "center", "right", "justify"], ["bold", "italic", "underline", "subscript", "superscript"], [