Skip to content

Commit

Permalink
ADD: New version which adds contentChangedHtml event to Textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinfaveri committed Mar 28, 2020
1 parent fa1da68 commit fdb1de0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docs/docs/changelog/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ title: 'Changelog'

# Changelog

## 5.5.4
- Adds contentChangedHtml event to TwemojiTextarea

## 5.5.3
- Fixed bug when tries to hide search bar when the feat is not enabled

Expand Down
9 changes: 7 additions & 2 deletions docs/docs/twemoji-textarea-api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,19 @@ Define the textarea maxlength. If set to null has no default maxlength. If set t

- This component inherits all Twemoji Picker events. You can check them [here](/docs/twemoji-picker-api#events).

### contentChangedHtml

This event fires everytime the textarea content is updated. Has one parameter which is the update content in HTML format in the textarea.

### contentChanged
- Parameter | Type : ``content | string``

This event fires everytime the textarea content is updated.
This event fires everytime the textarea content is updated. Has one parameter which is the update content in escaped format in the textarea.

### actualContentLengthChanged
- Parameter | Type : ``actualLength | number``

This event fires everytime the textarea content is updated. Has a parameter which indicates the length of the content (which is in fact not a simple content.length) because some emoji unicode in Javascript are sometimes counted as more than 1 in length value.
This event fires everytime the textarea content is updated. Has one parameter which indicates the length of the content (which is in fact not a simple content.length) because some emoji unicode in Javascript are sometimes counted as more than 1 in length value.

```js
actualContentLengthChanged(actualLength) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kevinfaguiar/vue-twemoji-picker",
"version": "5.5.3",
"version": "5.5.4",
"main": "dist/vue-twemoji-picker.umd.min.js",
"module": "dist/vue-twemoji-picker.esm.min.js",
"unpkg": "dist/vue-twemoji-picker.min.js",
Expand Down
3 changes: 2 additions & 1 deletion src/components/TwemojiTextarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export default Vue.extend({
updateContent(event: Event): void {
const targetedElement = event.target as HTMLElement;
let content = targetedElement.innerHTML as any;
this.$emit('contentChangedHtml', content);
content = TextareaParser.replaceEmojiWithAltAttribute(content);
content = TextareaParser.unescapeHtml(content);
if (content.length !== 0 && content[content.length - 1] === '\n') {
Expand All @@ -218,7 +219,7 @@ export default Vue.extend({
this.twemojiPicker.$refs.popupEmoji.popperInstance.forceUpdate();
this.$emit('update:content', content);
this.$emit('actualContentLengthChanged', this.actualContentLength);
this.$emit('contentChanged');
this.$emit('contentChanged', content);
},
emitIsContentOverflowed() {
if (this.actualContentLength > this.maxlength)
Expand Down

0 comments on commit fdb1de0

Please sign in to comment.