From b89c16e14cf8bdc76604b4a9a7eddfd7aa7a642c Mon Sep 17 00:00:00 2001 From: Anna Dabrowska Date: Mon, 21 Oct 2024 15:03:10 +0200 Subject: [PATCH] Use new LinkWizard function to create relative links --- script.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index d8c45d6..8b61a01 100644 --- a/script.js +++ b/script.js @@ -82,12 +82,20 @@ * @param {string} id The newly uploaded file ID */ function insertSyntax(id) { + + // TODO remove the "if" check after LinkWizard.createRelativeID() is available in stable (after Kaos) + if (typeof LinkWizard !== 'undefined' && typeof LinkWizard.createRelativeID === 'function') { + id = LinkWizard.createRelativeID(JSINFO.id, id); + } else { + id = ':' + id; + } + if (typeof window.proseMirrorIsActive !== 'undefined' && window.proseMirrorIsActive === true) { const pm = window.Prosemirror.view; const imageNode = pm.state.schema.nodes.image.create({id: id}); pm.dispatch(pm.state.tr.replaceSelectionWith(imageNode)); } else { - insertAtCarret('wiki__text', '{{:' + id + '}}'); + insertAtCarret('wiki__text', '{{' + id + '}}'); } }