diff --git a/src/components/MenuBubble.vue b/src/components/MenuBubble.vue index 706de84adaf..61b756b0cfd 100644 --- a/src/components/MenuBubble.vue +++ b/src/components/MenuBubble.vue @@ -137,7 +137,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}`) @@ -146,7 +146,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 diff --git a/src/helpers/files.js b/src/helpers/files.js index f4b5625d07e..6a26741275b 100644 --- a/src/helpers/files.js +++ b/src/helpers/files.js @@ -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('/')