mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-15 17:31:18 +08:00
amis-saas-6890 优化 tinymce 的默认值,并在配置 richTextToken 后自动切换为 froala
Change-Id: I6e03c8abef18720903e12546c70e4cc0c27b9546
This commit is contained in:
parent
463a34fb86
commit
6bb7257fe4
@ -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,154 +33,188 @@ export class RichTextControlPlugin extends BasePlugin {
|
|||||||
};
|
};
|
||||||
|
|
||||||
panelTitle = '富文本';
|
panelTitle = '富文本';
|
||||||
panelBody = [
|
|
||||||
getSchemaTpl('switchDefaultValue'),
|
panelBodyCreator = (context: BaseEventContext) => {
|
||||||
{
|
// 有设置这个就默认使用 froala
|
||||||
type: 'textarea',
|
const hasRichTextToken = this.manager.env?.richTextToken ? true : false;
|
||||||
name: 'value',
|
return [
|
||||||
label: '默认值',
|
getSchemaTpl('switchDefaultValue'),
|
||||||
visibleOn: 'typeof this.value !== "undefined"'
|
{
|
||||||
},
|
type: 'textarea',
|
||||||
getSchemaTpl('api', {
|
name: 'value',
|
||||||
name: 'receiver',
|
label: '默认值',
|
||||||
label: '文件接收接口',
|
visibleOn: 'typeof this.value !== "undefined"'
|
||||||
value: '/api/upload/image',
|
},
|
||||||
__isUpload: true
|
getSchemaTpl('api', {
|
||||||
}),
|
name: 'receiver',
|
||||||
{
|
label: '文件接收接口',
|
||||||
type: 'select',
|
value: '/api/upload/image',
|
||||||
name: 'vendor',
|
__isUpload: true
|
||||||
label: '编辑器类型',
|
}),
|
||||||
value: 'tinymce',
|
{
|
||||||
options: ['tinymce', 'froala']
|
type: 'select',
|
||||||
},
|
name: 'vendor',
|
||||||
getSchemaTpl('fieldSet', {
|
label: '编辑器类型',
|
||||||
title: 'froala 设置项',
|
value: hasRichTextToken ? 'froala' : 'tinymce',
|
||||||
visibleOn: 'data.vendor === "froala"',
|
options: ['tinymce', 'froala']
|
||||||
body: [
|
},
|
||||||
{
|
getSchemaTpl('fieldSet', {
|
||||||
type: 'combo',
|
title: 'froala 设置项',
|
||||||
name: 'options',
|
visibleOn: 'data.vendor === "froala"',
|
||||||
noBorder: true,
|
body: [
|
||||||
multiLine: true,
|
{
|
||||||
items: [
|
type: 'combo',
|
||||||
{
|
name: 'options',
|
||||||
type: 'select',
|
noBorder: true,
|
||||||
name: 'language',
|
multiLine: true,
|
||||||
label: '语言',
|
items: [
|
||||||
labelRemark: '鼠标覆盖配置栏中配置时显示的提示语言',
|
{
|
||||||
defaultValue: 'zh_cn',
|
type: 'select',
|
||||||
options: [
|
name: 'language',
|
||||||
{label: '中文', value: 'zh_cn'},
|
label: '语言',
|
||||||
{label: '英文', value: 'en_us'}
|
labelRemark: '鼠标覆盖配置栏中配置时显示的提示语言',
|
||||||
]
|
defaultValue: 'zh_cn',
|
||||||
},
|
options: [
|
||||||
{
|
{label: '中文', value: 'zh_cn'},
|
||||||
type: 'textarea',
|
{label: '英文', value: 'en_us'}
|
||||||
name: 'toolbarButtons',
|
]
|
||||||
label: '大屏时展示的配置项',
|
},
|
||||||
labelRemark: '屏幕宽度 ≥ 1200px',
|
{
|
||||||
description:
|
type: 'textarea',
|
||||||
'使用空格分开配置,使用<code>|</code>可将配置栏分组,<a target="_blank" href="https://www.froala.com/wysiwyg-editor/docs/options">参考文档</a>',
|
name: 'toolbarButtons',
|
||||||
minRows: 5,
|
label: '大屏时展示的配置项',
|
||||||
value: [
|
labelRemark: '屏幕宽度 ≥ 1200px',
|
||||||
'paragraphFormat',
|
description:
|
||||||
'quote',
|
'使用空格分开配置,使用<code>|</code>可将配置栏分组,<a target="_blank" href="https://www.froala.com/wysiwyg-editor/docs/options">参考文档</a>',
|
||||||
'color',
|
minRows: 5,
|
||||||
'|',
|
value: [
|
||||||
'bold',
|
'paragraphFormat',
|
||||||
'italic',
|
'quote',
|
||||||
'underline',
|
'color',
|
||||||
'strikeThrough',
|
'|',
|
||||||
'|',
|
'bold',
|
||||||
'formatOL',
|
'italic',
|
||||||
'formatUL',
|
'underline',
|
||||||
'align',
|
'strikeThrough',
|
||||||
'|',
|
'|',
|
||||||
'insertLink',
|
'formatOL',
|
||||||
'insertImage',
|
'formatUL',
|
||||||
'insertEmotion',
|
'align',
|
||||||
'insertTable',
|
'|',
|
||||||
'|',
|
'insertLink',
|
||||||
'undo',
|
'insertImage',
|
||||||
'redo',
|
'insertEmotion',
|
||||||
'html'
|
'insertTable',
|
||||||
],
|
'|',
|
||||||
pipeIn: (value: any) =>
|
'undo',
|
||||||
Array.isArray(value) ? value.join(' ') : '',
|
'redo',
|
||||||
pipeOut: (value: any) => value.replace(/\s+/g, ' ').split(' ')
|
'html'
|
||||||
},
|
],
|
||||||
{
|
pipeIn: (value: any) =>
|
||||||
type: 'textarea',
|
Array.isArray(value) ? value.join(' ') : '',
|
||||||
name: 'toolbarButtonsMD',
|
pipeOut: (value: any) => value.replace(/\s+/g, ' ').split(' ')
|
||||||
label: '中屏时展示的配置项',
|
},
|
||||||
labelRemark: '屏幕宽度 ≥ 992px',
|
{
|
||||||
description:
|
type: 'textarea',
|
||||||
'使用空格分开配置,使用<code>|</code>可将配置栏分组,<a target="_blank" href="https://www.froala.com/wysiwyg-editor/docs/options">参考文档</a>',
|
name: 'toolbarButtonsMD',
|
||||||
minRows: 5,
|
label: '中屏时展示的配置项',
|
||||||
pipeIn: (value: any) =>
|
labelRemark: '屏幕宽度 ≥ 992px',
|
||||||
Array.isArray(value) ? value.join(' ') : '',
|
description:
|
||||||
pipeOut: (value: any) => value.replace(/\s+/g, ' ').split(' ')
|
'使用空格分开配置,使用<code>|</code>可将配置栏分组,<a target="_blank" href="https://www.froala.com/wysiwyg-editor/docs/options">参考文档</a>',
|
||||||
},
|
minRows: 5,
|
||||||
{
|
pipeIn: (value: any) =>
|
||||||
type: 'textarea',
|
Array.isArray(value) ? value.join(' ') : '',
|
||||||
name: 'toolbarButtonsSM',
|
pipeOut: (value: any) => value.replace(/\s+/g, ' ').split(' ')
|
||||||
label: '小屏时展示的配置项',
|
},
|
||||||
labelRemark: '屏幕宽度 ≥ 768px',
|
{
|
||||||
description:
|
type: 'textarea',
|
||||||
'使用空格分开配置,使用<code>|</code>可将配置栏分组,<a target="_blank" href="https://www.froala.com/wysiwyg-editor/docs/options">参考文档</a>',
|
name: 'toolbarButtonsSM',
|
||||||
minRows: 5,
|
label: '小屏时展示的配置项',
|
||||||
pipeIn: (value: any) =>
|
labelRemark: '屏幕宽度 ≥ 768px',
|
||||||
Array.isArray(value) ? value.join(' ') : '',
|
description:
|
||||||
pipeOut: (value: any) => value.replace(/\s+/g, ' ').split(' ')
|
'使用空格分开配置,使用<code>|</code>可将配置栏分组,<a target="_blank" href="https://www.froala.com/wysiwyg-editor/docs/options">参考文档</a>',
|
||||||
}
|
minRows: 5,
|
||||||
]
|
pipeIn: (value: any) =>
|
||||||
}
|
Array.isArray(value) ? value.join(' ') : '',
|
||||||
]
|
pipeOut: (value: any) => value.replace(/\s+/g, ' ').split(' ')
|
||||||
}),
|
}
|
||||||
getSchemaTpl('fieldSet', {
|
]
|
||||||
title: 'tinymce 设置项',
|
}
|
||||||
visibleOn: 'data.vendor === "tinymce"',
|
]
|
||||||
body: [
|
}),
|
||||||
{
|
getSchemaTpl('fieldSet', {
|
||||||
type: 'combo',
|
title: 'tinymce 设置项',
|
||||||
name: 'options',
|
visibleOn: 'data.vendor === "tinymce"',
|
||||||
noBorder: true,
|
body: [
|
||||||
multiLine: true,
|
{
|
||||||
items: [
|
type: 'combo',
|
||||||
getSchemaTpl('switch', {
|
name: 'options',
|
||||||
label: '是否显示菜单栏',
|
noBorder: true,
|
||||||
value: 'true',
|
multiLine: true,
|
||||||
name: 'menubar'
|
items: [
|
||||||
}),
|
getSchemaTpl('switch', {
|
||||||
{
|
label: '是否显示菜单栏',
|
||||||
type: 'input-number',
|
value: 'true',
|
||||||
label: '高度',
|
name: 'menubar'
|
||||||
min: 0,
|
}),
|
||||||
value: 400,
|
{
|
||||||
name: 'height'
|
type: 'input-number',
|
||||||
},
|
label: '高度',
|
||||||
{
|
min: 0,
|
||||||
type: 'textarea',
|
value: 400,
|
||||||
name: 'plugins',
|
name: 'height'
|
||||||
label: '启用的插件',
|
},
|
||||||
description:
|
{
|
||||||
'使用空格分开配置,<a target="_blank" href="https://www.tiny.cloud/docs/general-configuration-guide/basic-setup/">参考文档</a>',
|
name: 'plugins',
|
||||||
value:
|
label: '启用的插件',
|
||||||
'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'
|
description:
|
||||||
},
|
'<a target="_blank" href="https://www.tiny.cloud/docs/general-configuration-guide/basic-setup/">参考文档</a>',
|
||||||
{
|
|
||||||
type: 'textarea',
|
type: 'input-array',
|
||||||
name: 'toolbar',
|
|
||||||
label: '工具栏',
|
inline: true,
|
||||||
value:
|
items: {
|
||||||
'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons | help'
|
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',
|
||||||
|
name: 'toolbar',
|
||||||
|
label: '工具栏',
|
||||||
|
value:
|
||||||
|
'undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
registerEditorPlugin(RichTextControlPlugin);
|
registerEditorPlugin(RichTextControlPlugin);
|
||||||
|
Loading…
Reference in New Issue
Block a user