Import custom marks with .docx
When importing a DOCX file, you can also define how custom marks should be converted back to Tiptap nodes. This is done by passing an array of custom mark definitions to the import
command. You could use this feature to convert your custom stylings from Word into Titap with ease.
import { Import } from '@tiptap-pro/extension-import-docx'
const editor = new Editor({
extensions: [
// Other extensions ...
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',
// Promisemirror custom mark mapping
prosemirrorMarks: {
bold: 'strong',
italic: 'em',
}
}),
// Other extensions ...
],
// Other editor settings ...
})
The latest version of the @tiptap-pro/extension-import-docx
has the prosemirrorMarks
configuration option available.
This option allows you to map custom nodes from the DOCX to your Tiptap schema. In the example above, we are mapping the bold
and italic
nodes from the DOCX to the strong
and em
nodes in our Tiptap schema.
By doing so, whenever the DOCX contains a bold
or italic
node, it will be converted to a strong
or italic
node in Tiptap when imported.
DOCX, "prosemirrorNodes" and "prosemirrorMarks"
Please note that the promisemirrorNodes
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
endpoint, and the promisemirrorNodes
and prosemirrorMarks
options will not be available.