feat(merge): blocks of different types can be merged#2671
Merged
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
GuillaumeOnepilot
approved these changes
Mar 30, 2024
Contributor
GuillaumeOnepilot
left a comment
There was a problem hiding this comment.
Thanks for the changes 👍
himself65
approved these changes
Mar 30, 2024
gohabereg
approved these changes
Mar 31, 2024
| /** | ||
| * 2) Blocks with different Tools if they provides conversionConfig | ||
| */ | ||
| } else if (targetBlock.mergeable && isBlockConvertable(blockToMerge, 'export') && isBlockConvertable(targetBlock, 'import')) { |
Member
There was a problem hiding this comment.
It seems areBlocksMergable can be used here
Member
Author
There was a problem hiding this comment.
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
TatianaFomina
approved these changes
Mar 31, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
requestAnimationFrameremoved fromBlockEvents@mergeBlocks. It was added because Paragraph was havingRAFinmerge()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.mergeBlocksandareBlocksMergeablelogic improved:merge()method (be.mergeable)conversionConfigblockToMergedata to stringtargetBlock.merge()