NcAutoCompleteResult
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
label | string | - | ||
subline | string | - | null | |
id | string | - | null | |
icon | string | - | ||
source | string | - | ||
status | object|array | - | () => ({}) |
NcMentionBubble
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
id | string | - | ||
label | string | - | ||
icon | string | - | ||
source | string | - | ||
primary | boolean | - | false |
NcRichContenteditable
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
userData | object | - | {} | |
value | string | - | '' | |
placeholder | string | - | t('Write message, use "@" to mention someone, use ":" for emoji autocompletion …') | |
autoComplete | func | - | ||
menuContainer | Element | - | () => document.body | |
multiline | Make the contenteditable looks like a textarea or not. Default looks like a single-line input. This also handle the default enter/shift+enter behaviour. if multiline, enter = newline; otherwise enter = submit shift+enter always add a new line. ctrl+enter always submits | boolean | - | false |
contenteditable | Is the content editable ? | boolean | - | true |
disabled | Disable the editing and show specific disabled design | boolean | - | false |
maxlength | Max allowed length | number | - | null |
emojiAutocomplete | Enable or disable emoji autocompletion | boolean | - | true |
Events
Event name | Properties | Description |
---|---|---|
Event paste the original paste event | ||
submit | ||
paste | The original paste event | |
update:value |
General description
This component displays contenteditable div with automated @
[at] autocompletion and :
[colon] emoji autocompletion.
Examples
vue
<template>
<div>
<NcRichContenteditable
:value.sync="message"
:auto-complete="autoComplete"
:maxlength="100"
:user-data="userData"
placeholder="Try mentioning user @Test01 or inserting emoji :smile"
@submit="onSubmit"
/>
<br />
<NcRichContenteditable
:value.sync="message"
:auto-complete="autoComplete"
:maxlength="400"
:multiline="true"
:user-data="userData"
placeholder="Try mentioning user @Test01 or inserting emoji :smile"
@submit="onSubmit"
/>
<br />
<br />
{{ JSON.stringify(message) }}
</div>
</template>
<script>
export default {
data() {
return {
message: "Lorem ipsum dolor sit amet.",
// You need to provide this for the inline
// mention to understand what to display or not.
userData: {
Test01: {
icon: "icon-user",
id: "Test01",
label: "Test01",
source: "users",
primary: true
},
Test02: {
icon: "icon-user",
id: "Test02",
label: "Test02",
source: "users",
status: {
clearAt: null,
icon: "🎡",
message: "Visiting London",
status: "away"
},
subline: "Visiting London"
},
"Test 03": {
icon: "icon-user",
id: "Test 03",
label: "Test 03",
source: "users",
status: {
clearAt: null,
icon: "🎡",
message: "Having space in my name",
status: "in space"
},
subline: "Visiting London"
}
}
};
},
methods: {
/**
* Do your own query to the autocompletion api.
* The returned data bellow is a fake data example.
* The callback expects the same format returned by the core/autocomplete/get ocs api endpoint!
* @see userData example above
*
* @param {string} search the query
* @param {Function} callback the callback to process the results with
*/
autoComplete(search, callback) {
callback(Object.values(this.userData));
},
onSubmit() {
alert(this.message);
}
}
};
</script>