amis-saas-6890 优化 tinymce 的默认值,并在配置 richTextToken 后自动切换为 froala

Change-Id: I6e03c8abef18720903e12546c70e4cc0c27b9546
This commit is contained in:
nwind 2022-09-27 15:14:09 +08:00
parent 463a34fb86
commit 6bb7257fe4

View File

@ -1,4 +1,4 @@
import {getSchemaTpl} from 'amis-editor-core'; import {BaseEventContext, getSchemaTpl} from 'amis-editor-core';
import {registerEditorPlugin} from 'amis-editor-core'; import {registerEditorPlugin} from 'amis-editor-core';
import {BasePlugin} from 'amis-editor-core'; import {BasePlugin} from 'amis-editor-core';
@ -33,7 +33,11 @@ export class RichTextControlPlugin extends BasePlugin {
}; };
panelTitle = '富文本'; panelTitle = '富文本';
panelBody = [
panelBodyCreator = (context: BaseEventContext) => {
// 有设置这个就默认使用 froala
const hasRichTextToken = this.manager.env?.richTextToken ? true : false;
return [
getSchemaTpl('switchDefaultValue'), getSchemaTpl('switchDefaultValue'),
{ {
type: 'textarea', type: 'textarea',
@ -51,7 +55,7 @@ export class RichTextControlPlugin extends BasePlugin {
type: 'select', type: 'select',
name: 'vendor', name: 'vendor',
label: '编辑器类型', label: '编辑器类型',
value: 'tinymce', value: hasRichTextToken ? 'froala' : 'tinymce',
options: ['tinymce', 'froala'] options: ['tinymce', 'froala']
}, },
getSchemaTpl('fieldSet', { getSchemaTpl('fieldSet', {
@ -161,26 +165,56 @@ export class RichTextControlPlugin extends BasePlugin {
name: 'height' name: 'height'
}, },
{ {
type: 'textarea',
name: 'plugins', name: 'plugins',
label: '启用的插件', label: '启用的插件',
description: description:
'使用空格分开配置,<a target="_blank" href="https://www.tiny.cloud/docs/general-configuration-guide/basic-setup/">参考文档</a>', '<a target="_blank" href="https://www.tiny.cloud/docs/general-configuration-guide/basic-setup/">参考文档</a>',
value:
'advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking table emoticons template paste help' type: 'input-array',
inline: true,
items: {
type: 'input-text',
clearable: true
},
value: [
'advlist',
'autolink',
'link',
'image',
'lists',
'charmap',
'preview',
'anchor',
'pagebreak',
'searchreplace',
'wordcount',
'visualblocks',
'visualchars',
'code',
'fullscreen',
'insertdatetime',
'media',
'nonbreaking',
'table',
'emoticons',
'template',
'help'
]
}, },
{ {
type: 'textarea', type: 'textarea',
name: 'toolbar', name: 'toolbar',
label: '工具栏', label: '工具栏',
value: value:
'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons | help' 'undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help'
} }
] ]
} }
] ]
}) })
]; ];
};
} }
registerEditorPlugin(RichTextControlPlugin); registerEditorPlugin(RichTextControlPlugin);