I have a collection of multiple draft-js
ContentStates
which i want to merge together to display them in one <Editor />
Why? Through my GUI you can edit text snippets individually and then at a later point join them together. You are then presented with the resulting text, which you again can still edit.
I persist the individual ContentStates
as follows:
const contentState = EditorState.getCurrentContent();
const raw = convertToRaw(contentState);
Which gives me an object like:
{
blocks: [...],
entityMap: {...}
}
What i tried, was manually merging the blocks
and entityMap
, to get a resulting raw contentState, which i could then parse with convertFromRaw
However, each block has a supposedly unique key, where on different contentStates these keys overlap and are not unique.
So the result in that case is that some blocks are being overridden by others with the same key.
Does anyone have an idea for an easier way to achieve what im doing?