diff --git a/src/editor/core/humhub-bridge.js b/src/editor/core/humhub-bridge.js index 61ec1c7..a4fb4b6 100644 --- a/src/editor/core/humhub-bridge.js +++ b/src/editor/core/humhub-bridge.js @@ -48,12 +48,12 @@ export function getUserLocale() { return isHumhub() ? humhub.modules.user.config.locale.split("-")[0] : null; } -export function filterFileUrl(url) { +export function filterFileUrl(url, mode) { if (!window.humhub) { return {url: url, guid: null}; } - return isHumhub() ? humhub.modules.file.filterFileUrl(url) : url; + return isHumhub() ? humhub.modules.file.filterFileUrl(url, mode) : url; } export function getLoaderWidget() { diff --git a/src/editor/core/plugins/file_handler/schema.js b/src/editor/core/plugins/file_handler/schema.js index 74e4c8c..fdeb940 100644 --- a/src/editor/core/plugins/file_handler/schema.js +++ b/src/editor/core/plugins/file_handler/schema.js @@ -36,7 +36,7 @@ const schema = { parseMarkdown: { mark: "link", getAttrs: function (tok) { - let {url, guid} = filterFileUrl(tok.attrGet("href")); + let {url, guid} = filterFileUrl(tok.attrGet("href"), 'view'); if (!validateHref(url)) { url = '#'; diff --git a/src/editor/core/plugins/link/index.js b/src/editor/core/plugins/link/index.js index 9cd6e80..9f2ae42 100644 --- a/src/editor/core/plugins/link/index.js +++ b/src/editor/core/plugins/link/index.js @@ -22,7 +22,7 @@ const link = { md.renderer.rules.link_open = function (tokens, idx, options, env, self) { const hrefIndex = tokens[idx].attrIndex('href'); - let {url, guid} = filterFileUrl(tokens[idx].attrs[hrefIndex][1]); + let {url, guid} = filterFileUrl(tokens[idx].attrs[hrefIndex][1], 'view'); tokens[idx].attrs[hrefIndex][1] = url; @@ -30,6 +30,7 @@ const link = { tokens[idx].attrPush(['data-file-guid', guid]); // add new attribute tokens[idx].attrPush(['data-file-download', '']); // add new attribute tokens[idx].attrPush(['data-file-url', url]); // add new attribute + tokens[idx].attrPush(['data-target', '#globalModal']); } // If you are sure other plugins can't add `target` - drop check below diff --git a/src/editor/core/plugins/link/schema.js b/src/editor/core/plugins/link/schema.js index 177a2c6..5feb46e 100644 --- a/src/editor/core/plugins/link/schema.js +++ b/src/editor/core/plugins/link/schema.js @@ -38,7 +38,7 @@ const schema = { toDOM(node) { let {href, title} = node.attrs; return ["a", {href, title}, 0] }, parseMarkdown: { mark: "link", getAttrs: function (tok) { - let {url, guid} = filterFileUrl(tok.attrGet("href")); + let {url, guid} = filterFileUrl(tok.attrGet("href"), 'view'); if (!validateHref(url)) { url = '#'; diff --git a/test/humhub-editor.js b/test/humhub-editor.js index 551af59..6334add 100644 --- a/test/humhub-editor.js +++ b/test/humhub-editor.js @@ -19093,12 +19093,12 @@ function getUserLocale() { return isHumhub() ? humhub.modules.user.config.locale.split("-")[0] : null; } -function filterFileUrl(url) { +function filterFileUrl(url, mode) { if (!window.humhub) { return {url: url, guid: null}; } - return isHumhub() ? humhub.modules.file.filterFileUrl(url) : url; + return isHumhub() ? humhub.modules.file.filterFileUrl(url, mode) : url; } function getLoaderWidget() { @@ -125222,7 +125222,7 @@ var schema$a = { var title = ref.title; return ["a", {href: href, title: title}, 0] }, parseMarkdown: { mark: "link", getAttrs: function (tok) { - var ref = filterFileUrl(tok.attrGet("href")); + var ref = filterFileUrl(tok.attrGet("href"), 'view'); var url = ref.url; var guid = ref.guid; @@ -125463,7 +125463,7 @@ var link = { md.renderer.rules.link_open = function (tokens, idx, options, env, self) { var hrefIndex = tokens[idx].attrIndex('href'); - var ref = filterFileUrl(tokens[idx].attrs[hrefIndex][1]); + var ref = filterFileUrl(tokens[idx].attrs[hrefIndex][1], 'view'); var url = ref.url; var guid = ref.guid; @@ -125473,6 +125473,7 @@ var link = { tokens[idx].attrPush(['data-file-guid', guid]); // add new attribute tokens[idx].attrPush(['data-file-download', '']); // add new attribute tokens[idx].attrPush(['data-file-url', url]); // add new attribute + tokens[idx].attrPush(['data-target', '#globalModal']); } // If you are sure other plugins can't add `target` - drop check below @@ -128210,7 +128211,7 @@ var schema = { parseMarkdown: { mark: "link", getAttrs: function (tok) { - var ref = filterFileUrl(tok.attrGet("href")); + var ref = filterFileUrl(tok.attrGet("href"), 'view'); var url = ref.url; var guid = ref.guid;