Skip to content

Commit 69d18d6

Browse files
Antreesybackportbot[bot]
authored andcommitted
feat(NcRichContenteditable): allow to pass menuContainer as string
- change default value to null (as per upstream) - allow to pass string selector as a prop - resolve selector at mounted() -> initializeTribute() Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
1 parent d3244c8 commit 69d18d6

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/components/NcRichContenteditable/NcRichContenteditable.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,12 @@ export default {
381381
},
382382
383383
/**
384-
* The containing element for the menu popover
384+
* The containing element or selector for the tribute (menu popover)
385+
* Defaults to `body` element
385386
*/
386387
menuContainer: {
387-
type: Element,
388-
default: () => document.body,
388+
type: [String, Element, null],
389+
default: null,
389390
},
390391
391392
/**
@@ -722,13 +723,18 @@ export default {
722723
})
723724
}
724725
726+
// Resolve container for Tribute.js to be mounted to (default - `null`)
727+
const menuContainer = (typeof this.menuContainer === 'string')
728+
? document.querySelector(this.menuContainer)
729+
: this.menuContainer
730+
725731
this.tribute = new Tribute({
726732
collection: tributesCollection,
727733
// FIXME: tributejs doesn't support allowSpaces as a collection option, only as a global one
728734
// Requires to fork a library to allow spaces only in the middle of mentions ('@' trigger)
729735
allowSpaces: false,
730736
// Where to inject the menu popup
731-
menuContainer: this.menuContainer,
737+
menuContainer,
732738
})
733739
this.tribute.attach(this.$refs.contenteditable)
734740
},

0 commit comments

Comments
 (0)