Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for different types of atomic blocks #59

Open
nethitters opened this issue Sep 11, 2018 · 0 comments
Open

Support for different types of atomic blocks #59

nethitters opened this issue Sep 11, 2018 · 0 comments

Comments

@nethitters
Copy link

nethitters commented Sep 11, 2018

I have different types of atomic blocks but currently getData() returns nothing. I've managed to get things working by passing the data to getAtomicBlockChunk with the following changes;

https://github.com/jpuri/html-to-draftjs/blob/master/src/library/index.js (37)

if (customChunkGenerator) {
  const value = customChunkGenerator(nodeName, node);
  if (value) {
    const entityId = Entity.__create(
      value.type,
      value.mutability,
      value.data || {},
    );
    // return { chunk: getAtomicBlockChunk(entityId) };
    return { chunk: getAtomicBlockChunk(entityId, value.data) };
  }
}

https://github.com/jpuri/html-to-draftjs/blob/master/src/library/chunkBuilder.js (74)

// export const getAtomicBlockChunk = (entityId: number): Object => {
export const getAtomicBlockChunk = (entityId: number, data: any): Object => {
  return {
    text: '\r ',
    inlines: [new OrderedSet()],
    entities: [entityId],
    blocks: [{
      type: 'atomic',
      depth: 0,
      // data: new Map({})
      data: new Map(data)
    }],
  };
};

Would it be possible to add this by default please?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant