Export custom styles to ODT

Available in Start planBetav0.3.0

When exporting to ODT, you can define custom style overrides that will be applied to the exported document. This is useful when you want to customize the look and feel of your exports beyond the default styling.

Style overrides

The styleOverrides option accepts a Record<string, string> object where keys are style property names and values are the style values. These overrides are sent to the Tiptap convert service and applied during the conversion process.

ParameterTypeDescriptionDefault
styleOverridesRecord<string, string>Style overrides to apply to the exported ODT documentundefined

Example

import { ExportOdt } from '@tiptap-pro/extension-export-odt'

const editor = new Editor({
  extensions: [
    // Other extensions...
    ExportOdt.configure({
      token: 'YOUR_TOKEN',
      appId: 'YOUR_APP_ID',
      styleOverrides: {
        'font-family': 'Arial, sans-serif',
        'font-size': '12pt',
        'line-height': '1.5',
        'color': '#333333',
      },
    }),
    // Other extensions...
  ],
})

// Export with custom styles
editor
  .chain()
  .exportOdt({
    onCompleteExport(result) {
      const url = URL.createObjectURL(result)
      const a = document.createElement('a')

      a.href = url
      a.download = 'styled-document.odt'
      a.click()

      URL.revokeObjectURL(url)
    },
  })
  .run()