feat: Disable options from the message signature editor (#7777)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Sivin Varghese
2023-08-26 08:51:39 +05:30
committed by GitHub
parent 6ab964b161
commit 04aa13e8aa
8 changed files with 84 additions and 14 deletions

View File

@@ -22,7 +22,7 @@
<script>
import {
messageSchema,
wootMessageWriterSetup,
buildEditor,
EditorView,
MessageMarkdownTransformer,
MessageMarkdownSerializer,
@@ -52,13 +52,19 @@ import { isEditorHotKeyEnabled } from 'dashboard/mixins/uiSettings';
import { replaceVariablesInMessage } from '@chatwoot/utils';
import { CONVERSATION_EVENTS } from '../../../helper/AnalyticsHelper/events';
const createState = (content, placeholder, plugins = []) => {
const createState = (
content,
placeholder,
plugins = [],
enabledMenuOptions
) => {
return EditorState.create({
doc: new MessageMarkdownTransformer(messageSchema).parse(content),
plugins: wootMessageWriterSetup({
plugins: buildEditor({
schema: messageSchema,
placeholder,
plugins,
enabledMenuOptions,
}),
});
};
@@ -78,6 +84,7 @@ export default {
enableVariables: { type: Boolean, default: false },
enableCannedResponses: { type: Boolean, default: true },
variables: { type: Object, default: () => ({}) },
enabledMenuOptions: { type: Array, default: () => [] },
},
data() {
return {
@@ -238,7 +245,12 @@ export default {
},
},
created() {
this.state = createState(this.value, this.placeholder, this.plugins);
this.state = createState(
this.value,
this.placeholder,
this.plugins,
this.enabledMenuOptions
);
},
mounted() {
this.createEditorView();
@@ -247,7 +259,12 @@ export default {
},
methods: {
reloadState() {
this.state = createState(this.value, this.placeholder, this.plugins);
this.state = createState(
this.value,
this.placeholder,
this.plugins,
this.enabledMenuOptions
);
this.editorView.updateState(this.state);
this.focusEditorInputField();
},