Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Feature: Allow linking to directories
Add the ability to create links to directories from within the
link menu bubble.

Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed May 30, 2022
commit 14b2aa3313fefc33ac34cd53aa3d6f3249beec8e
4 changes: 2 additions & 2 deletions src/components/MenuBubble.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default {
return
}
const startPath = this.filePath.split('/').slice(0, -1).join('/')
OC.dialogs.filepicker(t('text', 'Select file to link to'), (file) => {
OC.dialogs.filepicker(t('text', 'Select file or directory to link to'), (file) => {
const client = OC.Files.getClient()
client.getFileInfo(file).then((_status, fileInfo) => {
const path = optimalPath(this.filePath, `${fileInfo.path}/${fileInfo.name}`)
Expand All @@ -133,7 +133,7 @@ export default {
this.$editor.chain().setLink({ href }).focus().run()
this.hideLinkMenu()
})
}, false, [], true, undefined, startPath)
}, false, [], true, 1, startPath, { allowDirectoryChooser: true })
},
setLinkUrl() {
let url = this.linkUrl
Expand Down
5 changes: 5 additions & 0 deletions src/helpers/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ const optimalPath = function(from, to) {
while (current[0] === target[0]) {
current.shift()
target.shift()
// Handle case where target is the current directory
if (current.length === 0 && target.length === 0) {
return '.'
}

}
const relativePath = current.fill('..').concat(target)
const absolutePath = to.split('/')
Expand Down