From 545ab7406637769a1e16b082a72ca432570d585b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1sp=C3=A1r=20J=C3=B3zsef=20D=C3=A1niel?= Date: Sat, 13 May 2023 13:21:11 +0200 Subject: [PATCH] Implement document linking feature for @ keypress. --- src/App.vue | 22 +------ src/BaseClass.ts | 22 +++++++ src/components/dialogs/ExistingDocument.vue | 23 ++++++- src/components/fields/Field_Wysiwyg.vue | 73 ++++++++++++++++++++- 4 files changed, 119 insertions(+), 21 deletions(-) diff --git a/src/App.vue b/src/App.vue index 5968687..2a4c1a4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -102,7 +102,6 @@ import PouchDB from "pouchdb" import { OptionsStateInteface } from "./store/module-options/state" import { colors } from "quasar" import { tipsTricks } from "src/scripts/utilities/tipsTricks" -import { shell } from "electron" import { summonAllPlusheForms } from "src/scripts/utilities/plusheMascot" import { saveCorkboard, retrieveCorkboard, retrieveCurrentProjectName } from "src/scripts/projectManagement/projectManagent" import documentPreview from "src/components/DocumentPreview.vue" @@ -287,24 +286,9 @@ 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")) { - 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)) - } - else if (url.protocol === "document:") { - const doc = this.SGET_document(url.pathname) - /* eslint-disable */ - this.openExistingDocumentRoute(doc) - /* eslint-enable */ - } - } - catch (_) { - - } + // @ts-ignore + this.openLink(event.target.href as string) + // @ts-ignore } } diff --git a/src/BaseClass.ts b/src/BaseClass.ts index 094a8c6..ace18e1 100644 --- a/src/BaseClass.ts +++ b/src/BaseClass.ts @@ -9,6 +9,7 @@ import { uid, colors, extend } from "quasar" import { I_FieldRelationship } from "src/interfaces/I_FieldRelationship" import { I_KeyPressObject } from "src/interfaces/I_KeypressObject" import { ProjectInterface } from "./store/module-project/state" +import { shell } from "electron" const Blueprints = namespace("blueprintsModule") const AllDocuments = namespace("allDocumentsModule") @@ -678,4 +679,25 @@ export default class BaseClass extends Vue { return hasLegacyValue }) } + + openLink (link: string) { + try { + // @ts-ignore + const url = new URL(link) + // @ts-ignore + console.log(url) + if (url.protocol === "http:" || url.protocol === "https:") { + shell.openExternal(url.href).catch(e => console.log(e)) + } + else if (url.protocol === "document:") { + const doc = this.SGET_document(url.pathname) + /* eslint-disable */ + this.openExistingDocumentRoute(doc) + /* eslint-enable */ + } + } + catch (_) { + + } + } } diff --git a/src/components/dialogs/ExistingDocument.vue b/src/components/dialogs/ExistingDocument.vue index dcc3bb0..71fcaea 100644 --- a/src/components/dialogs/ExistingDocument.vue +++ b/src/components/dialogs/ExistingDocument.vue @@ -241,7 +241,7 @@ diff --git a/src/components/fields/Field_Wysiwyg.vue b/src/components/fields/Field_Wysiwyg.vue index 825755d..d649d19 100644 --- a/src/components/fields/Field_Wysiwyg.vue +++ b/src/components/fields/Field_Wysiwyg.vue @@ -1,5 +1,14 @@