默认配置
与 Umo Editor / Umo Editor Next 相比,移动端配置项更聚焦于触控阅读、编辑态切换、保存状态机和轻量化集成,不包含桌面端全部外观与工具栏配置。
所有配置
const defaultOptions = {
editorKey: 'default',
locale: 'zh-CN',
theme: 'light',
debug: false,
dicts: {
fonts: [...],
colors: [...],
lineHeights: [...],
symbols: [...],
emojis: [...],
pageSizes: [...],
},
page: {
layouts: ['web', 'page'],
defaultMargin: {
left: 3.18,
right: 3.18,
top: 2.54,
bottom: 2.54,
},
defaultOrientation: 'portrait',
defaultBackground: '#fff',
showBreakMarks: true,
showLineNumber: false,
showBookmark: false,
watermark: {
type: 'compact',
alpha: 0.2,
fontColor: '#000',
fontSize: 16,
fontFamily: 'SimSun',
fontWeight: 'normal',
text: '',
},
},
document: {
title: '',
content: '',
placeholder: {
en_US: 'Please enter the document content...',
zh_CN: '请输入文档内容...',
},
structure: 'block+',
enableSpellcheck: true,
enableMarkdown: true,
enableBubbleMenu: true,
enableBlockMenu: true,
enableNodeId: false,
readOnly: false,
autofocus: false,
characterLimit: 0,
typographyRules: {},
editorProps: {},
parseOptions: {
preserveWhitespace: 'full',
},
autoSave: {
enabled: true,
interval: 300000,
},
},
echarts: {
mode: 1,
renderImage: false,
onCustomSettings() {
return null
},
},
templates: [],
cdnUrl: 'https://unpkg.com/@umoteam/editor-external@latest',
shareUrl: location.href || '',
file: {
allowedMimeTypes: [],
maxSize: 1024 * 1024 * 100,
},
user: {},
users: [],
extensions: [],
disableExtensions: [],
translations: {
en_US: {},
zh_CN: {},
},
async onLeave({ leaveSteps = 1 } = {}) {
window.history.go(-Math.max(1, Number(leaveSteps) || 1))
},
async onSave() {
throw new Error('Key "onSave": Please set the save method')
},
async onRename() {
throw new Error('Key "onRename": Please set the rename method')
},
async onFileUpload(file) {
if (!file) {
throw new Error('File not found')
}
throw new Error('Key "onFileUpload": Please set the upload method')
},
onFileDelete() {
console.error('The file has been deleted...')
},
}配置说明
editorKey:编辑器实例标识,用于区分本地持久化状态。locale/theme/debug:全局显示、主题与调试能力配置,详见本地化语言配置、主题配置 与 调试配置。dicts:字典配置,详见字典配置。page:页面配置,详见页面配置。document:文档配置,详见文档配置。echarts:ECharts 图表配置,详见ECharts 配置。templates:模板配置,详见文档模板配置。cdnUrl/shareUrl:资源地址与分享地址配置。file:文件上传与预览配置,详见文件上传配置。user/users:用户信息配置,详见用户配置 与 相关用户配置。extensions/disableExtensions:扩展增删配置,详见功能及扩展配置。translations:多语言覆盖配置,详见本地化语言配置。onLeave/onSave/onRename/onFileUpload/onFileDelete:回调方法配置,详见方法配置。
与桌面端的主要差异
debug移动端特有:控制是否允许在“更多”面板中启用内置 DevTools。onLeave移动端特有:处理移动端返回、离开页面和未保存确认后的跳转逻辑。onRename移动端特有:处理“更多”面板中的文档重命名。page.layouts默认值为['web', 'page']移动端不同,默认优先进入 Web 布局;桌面端通常以分页视图优先。file.preview移动端不同:在移动端不支持通过 URL 实现第三方预览。
移动端不支持的配置项
skin不支持height不支持fullscreenZIndex不支持toolbar不支持webPages不支持diagrams不支持