mirror of
https://github.com/cosmocode/dokuwiki-plugin-imgpaste.git
synced 2025-07-25 17:09:37 +00:00
Use new LinkWizard function to create relative links
This commit is contained in:
10
script.js
10
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 + '}}');
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user