Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Binary file added pr-screenshots/smart-picker-after.png

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the commit that adds the screenshots as they should not live in the repository.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pr-screenshots/smart-picker-before.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 2 additions & 8 deletions src/components/Menu/ActionInsertLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ import { getMarkAttributes, isActive } from '@tiptap/core'
import NcActionButton from '@nextcloud/vue/components/NcActionButton'
import NcActionInput from '@nextcloud/vue/components/NcActionInput'
import NcActions from '@nextcloud/vue/components/NcActions'
import { getLinkWithPicker } from '@nextcloud/vue/components/NcRichText'
import { useFileProps } from '../../composables/useFileProps.ts'
import { useLinkFile } from '../../composables/useLinkFile.ts'
import { useNetworkState } from '../../composables/useNetworkState.ts'
Expand Down Expand Up @@ -229,13 +228,8 @@ export default {
},

linkPicker() {
getLinkWithPicker(null, true)
.then((link) => {
this.insertLink(link)
})
.catch((error) => {
logger.error('Smart picker promise rejected', error)
})
this.menuOpen = false
this.editor?.chain().focus().insertContent('/').run()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this won't work if the cursor is within text. Inserting a / there doesn't open the inline picker. I think we should add a editor command to allow opening the inline picker programmatically (i.e. not only by typing /) and use that one instead. This would also solve the problem of stray slash characters when using the button and then closing the picker.

},

linkCustomAction() {
Expand Down
17 changes: 2 additions & 15 deletions src/components/SuggestionsBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,13 @@
<script>
import { t } from '@nextcloud/l10n'
import NcButton from '@nextcloud/vue/components/NcButton'
import { getLinkWithPicker } from '@nextcloud/vue/components/NcRichText'
import { Folder, Shape, Table as TableIcon, Upload } from '../components/icons.js'
import { useConnection } from '../composables/useConnection.ts'
import { useEditor } from '../composables/useEditor.ts'
import { useFileProps } from '../composables/useFileProps.ts'
import { useLinkFile } from '../composables/useLinkFile.ts'
import { useNetworkState } from '../composables/useNetworkState.ts'
import { isMobileDevice } from '../helpers/isMobileDevice.js'
import { logger } from '../helpers/logger.ts'
import { useActionChooseLocalAttachmentMixin } from './Editor/MediaHandler.provider.js'

export default {
Expand Down Expand Up @@ -132,22 +130,11 @@ export default {

methods: {
/**
* Open smart picker dialog
* Open smart picker inline menu
* Triggered by the "Smart Picker" button
*/
linkPicker() {
getLinkWithPicker(null, true)
.then((link) => {
const chain = this.editor.chain()
if (this.editor.view.state.selection.empty) {
chain.focus().insertPreview(link).run()
} else {
chain.setLink({ href: link }).focus().run()
}
})
.catch((error) => {
logger.error('Smart picker promise rejected', error)
})
this.editor.chain().focus().insertContent('/').run()
},

/**
Expand Down