开发文档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: {
    id: '',
    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,
  },
  server: {
    host: '',
    ssl: false,
    token: '',
  },
  user: {},
  users: [],
  collaboration: {
    enabled: false,
    provider: {},
  },
  comments: {
    enabled: false,
    threads: [],
  },
  revision: {
    enabled: false,
    defaultEnabled: false,
    allowAcceptReject: true,
    defaultMarkupMode: 'final-markup',
    defaultReviewers: ['all'],
  },
  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...')
  },
}

配置说明

协作模式补充说明

  • document.id:协作场景下必填,用于唯一标识当前文档,并参与生成内部协作文档名。
  • server:用于提供协作服务端地址、协议和鉴权令牌。
  • collaboration.enabled:设为 true 后启用基础在线协作能力。
  • collaboration.provider:用于向底层协作提供者追加自定义配置,例如 parameters
  • document.content:在协作模式下不再作为正文来源,内容以服务端同步的协作文档为准。
  • document.autoSave:在协作模式下不会驱动本地自动保存状态机。
  • onSave:在协作模式下仍然保留,可用于业务侧执行手动保存快照或显式入库。

与桌面端的主要差异

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

移动端不支持的配置项

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