fix: Add the option to revert the AI generated content (#7458)
This commit is contained in:
@@ -75,9 +75,11 @@ import { mixin as clickaway } from 'vue-clickaway';
|
|||||||
import OpenAPI from 'dashboard/api/integrations/openapi';
|
import OpenAPI from 'dashboard/api/integrations/openapi';
|
||||||
import alertMixin from 'shared/mixins/alertMixin';
|
import alertMixin from 'shared/mixins/alertMixin';
|
||||||
import { OPEN_AI_EVENTS } from 'dashboard/helper/AnalyticsHelper/events';
|
import { OPEN_AI_EVENTS } from 'dashboard/helper/AnalyticsHelper/events';
|
||||||
|
import eventListenerMixins from 'shared/mixins/eventListenerMixins';
|
||||||
|
import { buildHotKeys } from 'shared/helpers/KeyboardHelpers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [alertMixin, clickaway],
|
mixins: [alertMixin, clickaway, eventListenerMixins],
|
||||||
props: {
|
props: {
|
||||||
conversationId: {
|
conversationId: {
|
||||||
type: Number,
|
type: Number,
|
||||||
@@ -101,6 +103,7 @@ export default {
|
|||||||
},
|
},
|
||||||
showDropdown: false,
|
showDropdown: false,
|
||||||
activeTone: 'professional',
|
activeTone: 'professional',
|
||||||
|
initialMessage: '',
|
||||||
tones: [
|
tones: [
|
||||||
{
|
{
|
||||||
key: 'professional',
|
key: 'professional',
|
||||||
@@ -138,7 +141,18 @@ export default {
|
|||||||
this.$store.dispatch('integrations/get');
|
this.$store.dispatch('integrations/get');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
onKeyDownHandler(event) {
|
||||||
|
const keyPattern = buildHotKeys(event);
|
||||||
|
const shouldRevertTheContent =
|
||||||
|
['meta+z', 'ctrl+z'].includes(keyPattern) && !!this.initialMessage;
|
||||||
|
|
||||||
|
if (shouldRevertTheContent) {
|
||||||
|
this.$emit('replace-text', this.initialMessage);
|
||||||
|
this.initialMessage = '';
|
||||||
|
}
|
||||||
|
},
|
||||||
toggleDropdown() {
|
toggleDropdown() {
|
||||||
this.showDropdown = !this.showDropdown;
|
this.showDropdown = !this.showDropdown;
|
||||||
},
|
},
|
||||||
@@ -167,6 +181,7 @@ export default {
|
|||||||
const {
|
const {
|
||||||
data: { message: generatedMessage },
|
data: { message: generatedMessage },
|
||||||
} = result;
|
} = result;
|
||||||
|
this.initialMessage = this.message;
|
||||||
this.$emit('replace-text', generatedMessage || this.message);
|
this.$emit('replace-text', generatedMessage || this.message);
|
||||||
this.closeDropdown();
|
this.closeDropdown();
|
||||||
this.recordAnalytics({ type, tone: this.activeTone });
|
this.recordAnalytics({ type, tone: this.activeTone });
|
||||||
|
|||||||
Reference in New Issue
Block a user