npm

@rexby/draftjs-to-tiptap
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

draftjs-to-tiptap

draftjs to tiptap markup converter

install

npm i @rexby/draftjs-to-tiptap or
yarn add @rexby/draftjs-to-tiptap

Usage

import { draftjsToTiptap } from "@rexby/draftjs-to-tiptap";

draftjsToTiptap(draftjsDocument, {
	// If you have @mentions in your draftjs documents you need to supply a
	// function to convert draftjs entity to tiptap mention attributes.
	// `entity.data.mention` will depend on how you configured your draftjs
	// editor, and you need to return an object with id and label as tiptap
	// expects
	getMentionAttrs: (entity) => {
		return {
			id: entity.data.mention.id,
			label: entity.data.mention.name
		};
	},
})

Input and output are json objects. If you store your documents as strings you will need to JSON.parse the input and JSON.stringify the output yourself.

Readme

Keywords

Package Sidebar

Install

npm i @rexby/draftjs-to-tiptap

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

15.1 kB

Total Files

10

Last publish

Collaborators

  • maggisk