diff --git a/src/components/MenuBubble.vue b/src/components/MenuBubble.vue index 472e62a224d..62353cc77f5 100644 --- a/src/components/MenuBubble.vue +++ b/src/components/MenuBubble.vue @@ -151,7 +151,9 @@ export default { client.getFileInfo(file).then((_status, fileInfo) => { const path = optimalPath(this.filePath, `${fileInfo.path}/${fileInfo.name}`) const encodedPath = path.split('/').map(encodeURIComponent).join('/') - command({ href: `${encodedPath}?fileId=${fileInfo.id}` }) + // add context to hack around unset OCA.Viewer.file being unset + // when editing Readme.md in "Richworkspace"-mode, + command({ href: `${encodedPath}?fileId=${fileInfo.id}&context=${this.filePath}` }) this.hideLinkMenu() }) }, false, [], true, undefined, startPath) diff --git a/src/helpers/links.js b/src/helpers/links.js index 18f556b5c99..ba67660e90c 100644 --- a/src/helpers/links.js +++ b/src/helpers/links.js @@ -55,10 +55,11 @@ const domHref = function(node) { if (ref.match(/^[a-zA-Z]*:/)) { return ref } - const match = ref.match(/^([^?]*)\?fileId=(\d+)/) + const match = ref.match(/^([^?]*)\?fileId=(\d+)(&context=([^&]*))?/) if (match) { const [, relPath, id] = match - const currentDir = basedir(OCA.Viewer.file) + const file = match[4] || OCA.Viewer.file + const currentDir = basedir(file) const dir = absolutePath(currentDir, basedir(relPath)) return generateUrl(`/apps/files/?dir=${dir}&openfile=${id}#relPath=${relPath}`) }