Import custom nodes from .docx

Available in Start planBetav0.7.0

The @tiptap-pro/extension-import-docx extension allows you to define how custom nodes in a DOCX file should be mapped back to your Tiptap schema during import.

Import custom nodes from .docx

When importing a DOCX file, you can define how custom nodes should be converted back to Tiptap nodes. This is done by passing an array of custom node definitions to the import command.

import { Import } from '@tiptap-pro/extension-import-docx'

// ... inside your Editor or useEditor setup:
Import.configure({
  appId: 'your-app-id',
  token: 'your-jwt',
  // ATTENTION: This is for demo purposes only
  endpoint: 'https://your-endpoint.com',
  imageUploadCallbackUrl: 'https://your-endpoint.com/image-upload',
  // ProseMirror custom node mapping
  prosemirrorNodes: {
    Hintbox: 'hintbox',
  },
}),

The latest version of the @tiptap-pro/extension-import-docx has available the prosemirrorNodes configuration option. This option allows you to map custom nodes from the DOCX to your Tiptap schema. In the example above, we are mapping the Hintbox custom node from the DOCX to the hintbox custom node in our Tiptap schema. By doing so, whenever the DOCX contains a Hintbox custom node, it will be converted to a hintbox node in Tiptap when imported.

DOCX, "prosemirrorNodes" and "prosemirrorMarks"

Please note that the prosemirrorNodes and prosemirrorMarks options will only work if you're importing a .docx file. If you're importing another type of file, eg: an .odt file, the /import endpoint will be used instead of the /import-docx endpoint, and the prosemirrorNodes and prosemirrorMarks options will not be available, and therefore you'd need to rely on the custom node and mark mapping API for those endpoints.