Skip to content
Merged
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
25 changes: 16 additions & 9 deletions src/components/NcRichContenteditable/NcRichContenteditable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,12 @@ export default {
},

/**
* The containing element for the menu popover
* The containing element or selector for the tribute (menu popover)
* Defaults to `body` element
*/
menuContainer: {
type: Element,
default: () => document.body,
type: [String, Element, null],
default: null,
},

/**
Expand Down Expand Up @@ -601,11 +602,6 @@ export default {

// Update default value
this.updateContent(this.model)

// Tribute.js library ensures that `el.contentEditable = true` when attaching to element.
// This overwrites the template binding.
// Set the contenteditable attribute to actual value afterward
this.$refs.contenteditable.contentEditable = this.contenteditableAttributeValue
},

beforeDestroy() {
Expand Down Expand Up @@ -722,15 +718,26 @@ export default {
})
}

// Resolve container for Tribute.js to be mounted to (default - `null`)
const menuContainer = (typeof this.menuContainer === 'string')
? document.querySelector(this.menuContainer)
: this.menuContainer

this.tribute = new Tribute({
collection: tributesCollection,
// FIXME: tributejs doesn't support allowSpaces as a collection option, only as a global one
// Requires to fork a library to allow spaces only in the middle of mentions ('@' trigger)
allowSpaces: false,
// Where to inject the menu popup
menuContainer: this.menuContainer,
menuContainer,
})
this.tribute.attach(this.$refs.contenteditable)

// Tribute.js library v5.1.3 ensures that `el.contentEditable = true` when attaching to element.
// This overwrites the template binding.
// Set the contenteditable attribute to actual value afterward
// TODO remove when Tribute.js library v5.1.4 is published on npm (or fork it)
this.$refs.contenteditable.contentEditable = this.contenteditableAttributeValue
},

getLink(item) {
Expand Down
Loading