开发文档Umo Editor Mobile配置项默认配置

默认配置

与 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...')
  },
}

配置说明

与桌面端的主要差异

  • debug 移动端特有:控制是否允许在“更多”面板中启用内置 DevTools。
  • onLeave 移动端特有:处理移动端返回、离开页面和未保存确认后的跳转逻辑。
  • onRename 移动端特有:处理“更多”面板中的文档重命名。
  • page.layouts 默认值为 ['web', 'page'] 移动端不同,默认优先进入 Web 布局;桌面端通常以分页视图优先。
  • file.preview 移动端不同:在移动端不支持通过 URL 实现第三方预览。

移动端不支持的配置项

  • skin 不支持
  • height 不支持
  • fullscreenZIndex 不支持
  • toolbar 不支持
  • webPages 不支持
  • diagrams 不支持