-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Show inserter next to empty text block #565
Conversation
Do we need to show it to any blocks other than the core text block? |
Based on discussion following #323 (comment) , the consensus seems to be that this between-content inserter should be shown only next to an empty text block, and more generally that an empty text block is the default empty block when creating new content via the Enter key. |
Ran into an issue today that I thought I'd mention here: If you insert a text block (any text, including heading, list, etc.), it scrolls to the inserted block. Good! If you insert a block that doesn't have Editable, like embed or image, it doesn't scroll to the block. Let me know if I should ticket this separately. |
Yes, let's create a separate issue for this. It might be that TinyMCE is scrolling the page when it initializes, in which case we should try to disable that default and implement a consistent approach across all blocks. |
@aduth Saw this the other day: https://github.com/tinymce/tinymce-dist/blob/4.6.0/changelog.txt#L6 |
Sharp eye! That sounds perfect. |
9728eeb
to
40878cf
Compare
40878cf
to
1592c27
Compare
This is now ready for review. I've updated the original comment with specific remarks to my concerns, and included a fair bit of commentary to the code itself. |
I don't know if I'm doing it right, but I can't get the inserter to show. I place the cursor in text, press enter twice to create a new block, but all I see is the block mover on the side. |
// When choosing block from inserter for a new empty block, override | ||
// insert behavior to replace current block instead | ||
const { uid, replaceBlocks } = this.props; | ||
replaceBlocks( [ uid ], [ createBlock( slug ) ] ); |
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.
Should the newly created block borrow the uid
from the replaced block to stay selected?
'core/text' === block.blockType && | ||
! block.attributes.content | ||
); | ||
} |
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.
I don't know if this it will work but I prefer your idea here to compute the isNew
flag:
Closing due to revised insertion flows proposed at #833. |
Related: #323
This pull request seeks to display an inserter next to the empty text block.
Implementation notes:
How do we consider a block as "empty" ? Compare against its default attributes? Expect asundefined
? Do a deep traversal to determine if there's any renderable content?content
value of a new text block be assignedundefined
. Previously specified default value of paragraph node in Text Block: Fix updating the content of an empty text block #512How do we allow a block to trigger an inserter to be shown, without forcing it to become too aware of internal components (arguably, a block should not have awareness of an Inserter component)VisualEditorBlock
directlyThere can be multiple block movers on screen at the same time (selected and hovered). How do we ensure that only the selected empty block's area shows the inserter. Maybe a separate Fill context needs to be created specific to the selected block, instead of trying to fit this in with the Mover area?BlockMover