Skip to content

Commit b89c16e

Browse files
committed
Use new LinkWizard function to create relative links
1 parent c37d932 commit b89c16e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

script.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,20 @@
8282
* @param {string} id The newly uploaded file ID
8383
*/
8484
function insertSyntax(id) {
85+
86+
// TODO remove the "if" check after LinkWizard.createRelativeID() is available in stable (after Kaos)
87+
if (typeof LinkWizard !== 'undefined' && typeof LinkWizard.createRelativeID === 'function') {
88+
id = LinkWizard.createRelativeID(JSINFO.id, id);
89+
} else {
90+
id = ':' + id;
91+
}
92+
8593
if (typeof window.proseMirrorIsActive !== 'undefined' && window.proseMirrorIsActive === true) {
8694
const pm = window.Prosemirror.view;
8795
const imageNode = pm.state.schema.nodes.image.create({id: id});
8896
pm.dispatch(pm.state.tr.replaceSelectionWith(imageNode));
8997
} else {
90-
insertAtCarret('wiki__text', '{{:' + id + '}}');
98+
insertAtCarret('wiki__text', '{{' + id + '}}');
9199
}
92100
}
93101

0 commit comments

Comments
 (0)