Skip to content

Commit

Permalink
Work around OCA.Viewer.file not set when editing in richworkspace mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
rotdrop committed Feb 7, 2022
1 parent 51e0592 commit e56cb15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/components/MenuBubble.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/helpers/links.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
Expand Down

0 comments on commit e56cb15

Please sign in to comment.