Skip to content
On this page

NcAutoCompleteResult

Props

Prop nameDescriptionTypeValuesDefault
labelstring-
sublinestring-null
idstring-null
iconstring-
sourcestring-
statusobject|array-() => ({})

NcMentionBubble

Props

Prop nameDescriptionTypeValuesDefault
idstring-
labelstring-
iconstring-
sourcestring-
primaryboolean-false

NcRichContenteditable

Props

Prop nameDescriptionTypeValuesDefault
userDataobject-{}
valuestring-''
placeholderstring-t('Write message, use "@" to mention someone, use ":" for emoji autocompletion …')
autoCompletefunc-
menuContainerElement-() => document.body
multilineMake 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
contenteditableIs the content editable ?boolean-true
disabledDisable the editing and show specific disabled designboolean-false
maxlengthMax allowed lengthnumber-null
emojiAutocompleteEnable or disable emoji autocompletionboolean-true

Events

Event namePropertiesDescription
Event paste the original paste event
submit
pasteThe 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>