Support for different types of atomic blocks
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 163
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/library/index.js around the customChunkGenerator handling and src/library/chunkBuilder.js around getAtomicBlockChunk. Trace how custom atomic block data is created and represented, then verify that getData() preserves the supplied data by exercising the existing test setup. Done means different atomic block types retain their data without requiring callers to modify these files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100