-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat(merge): blocks of different types can be merged #2671
Conversation
…ub.com/OnepilotHQ/editor.js into feature/merge-block-of-different-types
…ub.com/OnepilotHQ/editor.js into feature/merge-block-of-different-types
…ub.com/OnepilotHQ/editor.js into feature/merge-block-of-different-types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes 👍
/** | ||
* 2) Blocks with different Tools if they provides conversionConfig | ||
*/ | ||
} else if (targetBlock.mergeable && isBlockConvertable(blockToMerge, 'export') && isBlockConvertable(targetBlock, 'import')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems areBlocksMergable
can be used here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
areBlockMergeable
is checked before mergeBlocks
call. I've written these 2 statements explicitly for clarity: first about same-tool merge, second about merging through the conversion
This PR based on #2564 made by @GuillaumeOnepilot
Feature
Now it is possible to merge blocks of different types.
If blocks provides the
conversionConfig
, we use it for merging:blocks-merging.mov
Changes
requestAnimationFrame
removed fromBlockEvents@mergeBlocks
. It was added because Paragraph was havingRAF
inmerge()
method. It was removed by fix(merge): incorrect caret position on merge editor-js/paragraph#86normalize()
removed as well since it creates issues with caret restoring — nodes text length changes and caret is being set in wrong position. It's better to callnormalize()
at the tool'smerge()
method if needed.mergeBlocks
andareBlocksMergeable
logic improved:merge()
method (be.mergeable
)conversionConfig
blockToMerge
data to stringtargetBlock.merge()