mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 11:37:58 +00:00
feat: Disable options from the message signature editor (#7777)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
messageSchema,
|
messageSchema,
|
||||||
wootMessageWriterSetup,
|
buildEditor,
|
||||||
EditorView,
|
EditorView,
|
||||||
MessageMarkdownTransformer,
|
MessageMarkdownTransformer,
|
||||||
MessageMarkdownSerializer,
|
MessageMarkdownSerializer,
|
||||||
@@ -52,13 +52,19 @@ import { isEditorHotKeyEnabled } from 'dashboard/mixins/uiSettings';
|
|||||||
import { replaceVariablesInMessage } from '@chatwoot/utils';
|
import { replaceVariablesInMessage } from '@chatwoot/utils';
|
||||||
import { CONVERSATION_EVENTS } from '../../../helper/AnalyticsHelper/events';
|
import { CONVERSATION_EVENTS } from '../../../helper/AnalyticsHelper/events';
|
||||||
|
|
||||||
const createState = (content, placeholder, plugins = []) => {
|
const createState = (
|
||||||
|
content,
|
||||||
|
placeholder,
|
||||||
|
plugins = [],
|
||||||
|
enabledMenuOptions
|
||||||
|
) => {
|
||||||
return EditorState.create({
|
return EditorState.create({
|
||||||
doc: new MessageMarkdownTransformer(messageSchema).parse(content),
|
doc: new MessageMarkdownTransformer(messageSchema).parse(content),
|
||||||
plugins: wootMessageWriterSetup({
|
plugins: buildEditor({
|
||||||
schema: messageSchema,
|
schema: messageSchema,
|
||||||
placeholder,
|
placeholder,
|
||||||
plugins,
|
plugins,
|
||||||
|
enabledMenuOptions,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -78,6 +84,7 @@ export default {
|
|||||||
enableVariables: { type: Boolean, default: false },
|
enableVariables: { type: Boolean, default: false },
|
||||||
enableCannedResponses: { type: Boolean, default: true },
|
enableCannedResponses: { type: Boolean, default: true },
|
||||||
variables: { type: Object, default: () => ({}) },
|
variables: { type: Object, default: () => ({}) },
|
||||||
|
enabledMenuOptions: { type: Array, default: () => [] },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -238,7 +245,12 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.state = createState(this.value, this.placeholder, this.plugins);
|
this.state = createState(
|
||||||
|
this.value,
|
||||||
|
this.placeholder,
|
||||||
|
this.plugins,
|
||||||
|
this.enabledMenuOptions
|
||||||
|
);
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.createEditorView();
|
this.createEditorView();
|
||||||
@@ -247,7 +259,12 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
reloadState() {
|
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.editorView.updateState(this.state);
|
||||||
this.focusEditorInputField();
|
this.focusEditorInputField();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
fullSchema,
|
fullSchema,
|
||||||
wootArticleWriterSetup,
|
buildEditor,
|
||||||
EditorView,
|
EditorView,
|
||||||
ArticleMarkdownSerializer,
|
ArticleMarkdownSerializer,
|
||||||
ArticleMarkdownTransformer,
|
ArticleMarkdownTransformer,
|
||||||
@@ -33,15 +33,17 @@ const createState = (
|
|||||||
content,
|
content,
|
||||||
placeholder,
|
placeholder,
|
||||||
plugins = [],
|
plugins = [],
|
||||||
onImageUpload = () => {}
|
methods = {},
|
||||||
|
enabledMenuOptions
|
||||||
) => {
|
) => {
|
||||||
return EditorState.create({
|
return EditorState.create({
|
||||||
doc: new ArticleMarkdownTransformer(fullSchema).parse(content),
|
doc: new ArticleMarkdownTransformer(fullSchema).parse(content),
|
||||||
plugins: wootArticleWriterSetup({
|
plugins: buildEditor({
|
||||||
schema: fullSchema,
|
schema: fullSchema,
|
||||||
placeholder,
|
placeholder,
|
||||||
|
methods,
|
||||||
plugins,
|
plugins,
|
||||||
onImageUpload,
|
enabledMenuOptions,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -52,6 +54,7 @@ export default {
|
|||||||
value: { type: String, default: '' },
|
value: { type: String, default: '' },
|
||||||
editorId: { type: String, default: '' },
|
editorId: { type: String, default: '' },
|
||||||
placeholder: { type: String, default: '' },
|
placeholder: { type: String, default: '' },
|
||||||
|
enabledMenuOptions: { type: Array, default: () => [] },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -83,7 +86,8 @@ export default {
|
|||||||
this.value,
|
this.value,
|
||||||
this.placeholder,
|
this.placeholder,
|
||||||
this.plugins,
|
this.plugins,
|
||||||
this.openFileBrowser
|
{ onImageUpload: this.openFileBrowser },
|
||||||
|
this.enabledMenuOptions
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -152,7 +156,8 @@ export default {
|
|||||||
this.value,
|
this.value,
|
||||||
this.placeholder,
|
this.placeholder,
|
||||||
this.plugins,
|
this.plugins,
|
||||||
this.openFileBrowser
|
{ onImageUpload: this.openFileBrowser },
|
||||||
|
this.enabledMenuOptions
|
||||||
);
|
);
|
||||||
this.editorView.updateState(this.state);
|
this.editorView.updateState(this.state);
|
||||||
this.focusEditorInputField();
|
this.focusEditorInputField();
|
||||||
|
|||||||
@@ -69,6 +69,7 @@
|
|||||||
:min-height="4"
|
:min-height="4"
|
||||||
:enable-variables="true"
|
:enable-variables="true"
|
||||||
:variables="messageVariables"
|
:variables="messageVariables"
|
||||||
|
:enabled-menu-options="customEditorMenuOptions"
|
||||||
@typing-off="onTypingOff"
|
@typing-off="onTypingOff"
|
||||||
@typing-on="onTypingOn"
|
@typing-on="onTypingOn"
|
||||||
@focus="onFocus"
|
@focus="onFocus"
|
||||||
@@ -184,6 +185,7 @@ import wootConstants from 'dashboard/constants/globals';
|
|||||||
import { isEditorHotKeyEnabled } from 'dashboard/mixins/uiSettings';
|
import { isEditorHotKeyEnabled } from 'dashboard/mixins/uiSettings';
|
||||||
import { CONVERSATION_EVENTS } from '../../../helper/AnalyticsHelper/events';
|
import { CONVERSATION_EVENTS } from '../../../helper/AnalyticsHelper/events';
|
||||||
import rtlMixin from 'shared/mixins/rtlMixin';
|
import rtlMixin from 'shared/mixins/rtlMixin';
|
||||||
|
import { MESSAGE_EDITOR_MENU_OPTIONS } from 'dashboard/constants/editor';
|
||||||
|
|
||||||
const EmojiInput = () => import('shared/components/emoji/EmojiInput');
|
const EmojiInput = () => import('shared/components/emoji/EmojiInput');
|
||||||
|
|
||||||
@@ -226,6 +228,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
message: '',
|
message: '',
|
||||||
|
customEditorMenuOptions: MESSAGE_EDITOR_MENU_OPTIONS,
|
||||||
isFocused: false,
|
isFocused: false,
|
||||||
showEmojiPicker: false,
|
showEmojiPicker: false,
|
||||||
attachedFiles: [],
|
attachedFiles: [],
|
||||||
|
|||||||
33
app/javascript/dashboard/constants/editor.js
Normal file
33
app/javascript/dashboard/constants/editor.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
export const MESSAGE_EDITOR_MENU_OPTIONS = [
|
||||||
|
'strong',
|
||||||
|
'em',
|
||||||
|
'link',
|
||||||
|
'undo',
|
||||||
|
'redo',
|
||||||
|
'bulletList',
|
||||||
|
'orderedList',
|
||||||
|
'code',
|
||||||
|
];
|
||||||
|
|
||||||
|
export const MESSAGE_SIGNATURE_EDITOR_MENU_OPTIONS = [
|
||||||
|
'strong',
|
||||||
|
'em',
|
||||||
|
'link',
|
||||||
|
'undo',
|
||||||
|
'redo',
|
||||||
|
];
|
||||||
|
|
||||||
|
export const ARTICLE_EDITOR_MENU_OPTIONS = [
|
||||||
|
'strong',
|
||||||
|
'em',
|
||||||
|
'link',
|
||||||
|
'undo',
|
||||||
|
'redo',
|
||||||
|
'bulletList',
|
||||||
|
'orderedList',
|
||||||
|
'h1',
|
||||||
|
'h2',
|
||||||
|
'h3',
|
||||||
|
'imageUpload',
|
||||||
|
'code',
|
||||||
|
];
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
v-model="articleContent"
|
v-model="articleContent"
|
||||||
class="article-content"
|
class="article-content"
|
||||||
:placeholder="$t('HELP_CENTER.EDIT_ARTICLE.CONTENT_PLACEHOLDER')"
|
:placeholder="$t('HELP_CENTER.EDIT_ARTICLE.CONTENT_PLACEHOLDER')"
|
||||||
|
:enabled-menu-options="customEditorMenuOptions"
|
||||||
@focus="onFocus"
|
@focus="onFocus"
|
||||||
@blur="onBlur"
|
@blur="onBlur"
|
||||||
@input="onContentInput"
|
@input="onContentInput"
|
||||||
@@ -25,6 +26,7 @@
|
|||||||
import { debounce } from '@chatwoot/utils';
|
import { debounce } from '@chatwoot/utils';
|
||||||
import ResizableTextArea from 'shared/components/ResizableTextArea';
|
import ResizableTextArea from 'shared/components/ResizableTextArea';
|
||||||
import WootArticleEditor from 'dashboard/components/widgets/WootWriter/FullEditor.vue';
|
import WootArticleEditor from 'dashboard/components/widgets/WootWriter/FullEditor.vue';
|
||||||
|
import { ARTICLE_EDITOR_MENU_OPTIONS } from 'dashboard/constants/editor';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -46,6 +48,7 @@ export default {
|
|||||||
articleTitle: '',
|
articleTitle: '',
|
||||||
articleContent: '',
|
articleContent: '',
|
||||||
saveArticle: () => {},
|
saveArticle: () => {},
|
||||||
|
customEditorMenuOptions: ARTICLE_EDITOR_MENU_OPTIONS,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
:placeholder="
|
:placeholder="
|
||||||
$t('PROFILE_SETTINGS.FORM.MESSAGE_SIGNATURE.PLACEHOLDER')
|
$t('PROFILE_SETTINGS.FORM.MESSAGE_SIGNATURE.PLACEHOLDER')
|
||||||
"
|
"
|
||||||
|
:enabled-menu-options="customEditorMenuList"
|
||||||
@blur="$v.messageSignature.$touch"
|
@blur="$v.messageSignature.$touch"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -41,6 +42,7 @@ import { mapGetters } from 'vuex';
|
|||||||
|
|
||||||
import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor';
|
import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor';
|
||||||
import alertMixin from 'shared/mixins/alertMixin';
|
import alertMixin from 'shared/mixins/alertMixin';
|
||||||
|
import { MESSAGE_SIGNATURE_EDITOR_MENU_OPTIONS } from 'dashboard/constants/editor';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -53,6 +55,7 @@ export default {
|
|||||||
enableMessageSignature: false,
|
enableMessageSignature: false,
|
||||||
isUpdating: false,
|
isUpdating: false,
|
||||||
errorMessage: '',
|
errorMessage: '',
|
||||||
|
customEditorMenuList: MESSAGE_SIGNATURE_EDITOR_MENU_OPTIONS,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
validations: {
|
validations: {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@braid/vue-formulate": "^2.5.2",
|
"@braid/vue-formulate": "^2.5.2",
|
||||||
"@chatwoot/prosemirror-schema": "https://github.com/chatwoot/prosemirror-schema.git",
|
"@chatwoot/prosemirror-schema": "https://github.com/chatwoot/prosemirror-schema.git#0589b7a1175adc00bb085084b5ef20a7f4570c30",
|
||||||
"@chatwoot/utils": "^0.0.16",
|
"@chatwoot/utils": "^0.0.16",
|
||||||
"@hcaptcha/vue-hcaptcha": "^0.3.2",
|
"@hcaptcha/vue-hcaptcha": "^0.3.2",
|
||||||
"@june-so/analytics-next": "^1.36.5",
|
"@june-so/analytics-next": "^1.36.5",
|
||||||
|
|||||||
10
yarn.lock
10
yarn.lock
@@ -2994,10 +2994,11 @@
|
|||||||
is-url "^1.2.4"
|
is-url "^1.2.4"
|
||||||
nanoid "^2.1.11"
|
nanoid "^2.1.11"
|
||||||
|
|
||||||
"@chatwoot/prosemirror-schema@https://github.com/chatwoot/prosemirror-schema.git":
|
"@chatwoot/prosemirror-schema@https://github.com/chatwoot/prosemirror-schema.git#0589b7a1175adc00bb085084b5ef20a7f4570c30":
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://github.com/chatwoot/prosemirror-schema.git#b937c3cb44210b7d251daf766988758975befec7"
|
resolved "https://github.com/chatwoot/prosemirror-schema.git#0589b7a1175adc00bb085084b5ef20a7f4570c30"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
markdown-it-sup "^1.0.0"
|
||||||
prosemirror-commands "^1.1.4"
|
prosemirror-commands "^1.1.4"
|
||||||
prosemirror-dropcursor "^1.3.2"
|
prosemirror-dropcursor "^1.3.2"
|
||||||
prosemirror-gapcursor "^1.1.5"
|
prosemirror-gapcursor "^1.1.5"
|
||||||
@@ -14232,6 +14233,11 @@ markdown-it-link-attributes@^4.0.1:
|
|||||||
resolved "https://registry.yarnpkg.com/markdown-it-link-attributes/-/markdown-it-link-attributes-4.0.1.tgz#25751f2cf74fd91f0a35ba7b3247fa45f2056d88"
|
resolved "https://registry.yarnpkg.com/markdown-it-link-attributes/-/markdown-it-link-attributes-4.0.1.tgz#25751f2cf74fd91f0a35ba7b3247fa45f2056d88"
|
||||||
integrity sha512-pg5OK0jPLg62H4k7M9mRJLT61gUp9nvG0XveKYHMOOluASo9OEF13WlXrpAp2aj35LbedAy3QOCgQCw0tkLKAQ==
|
integrity sha512-pg5OK0jPLg62H4k7M9mRJLT61gUp9nvG0XveKYHMOOluASo9OEF13WlXrpAp2aj35LbedAy3QOCgQCw0tkLKAQ==
|
||||||
|
|
||||||
|
markdown-it-sup@^1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/markdown-it-sup/-/markdown-it-sup-1.0.0.tgz#cb9c9ff91a5255ac08f3fd3d63286e15df0a1fc3"
|
||||||
|
integrity sha512-E32m0nV9iyhRR7CrhnzL5msqic7rL1juWre6TQNxsnApg7Uf+F97JOKxUijg5YwXz86lZ0mqfOnutoryyNdntQ==
|
||||||
|
|
||||||
markdown-it@^10.0.0:
|
markdown-it@^10.0.0:
|
||||||
version "10.0.0"
|
version "10.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-10.0.0.tgz#abfc64f141b1722d663402044e43927f1f50a8dc"
|
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-10.0.0.tgz#abfc64f141b1722d663402044e43927f1f50a8dc"
|
||||||
|
|||||||
Reference in New Issue
Block a user