-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Block Editor: Add block zooming. #16578
Changes from 1 commit
fab407a
9928699
68dcb44
0061fc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1043,6 +1043,25 @@ export function blockSelection( state = BLOCK_SELECTION_INITIAL_STATE, action ) | |
return state; | ||
} | ||
|
||
/** | ||
* Reducer returning the block zoom's state. | ||
* | ||
* @param {Object} state Current state. | ||
* @param {Object} action Dispatched action. | ||
* | ||
* @return {Object} Updated state. | ||
*/ | ||
export function blockZoom( state, action ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the blockZoom reduce handle the case where a sibling of the zoomed blocks is inserted? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, definitely. |
||
switch ( action.type ) { | ||
case 'ZOOM_BLOCKS': | ||
return action.clientIds; | ||
case 'CLEAR_ZOOMED_BLOCKS': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add cases for remove and replace block actions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
return null; | ||
} | ||
|
||
return state; | ||
} | ||
|
||
export function blocksMode( state = {}, action ) { | ||
if ( action.type === 'TOGGLE_BLOCK_MODE' ) { | ||
const { clientId } = action; | ||
|
@@ -1228,6 +1247,7 @@ export default combineReducers( { | |
isTyping, | ||
isCaretWithinFormattedText, | ||
blockSelection, | ||
blockZoom, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I create a group block, add some blocks inside it, select all the blocks inside, zoom them, and then press the undo button the editor crashes. Related #12327. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I need to move it, but I don't think it should create an undo level. It's not an edit operation, it's more like selections which we also don't expect to create undo levels. I plan to give this reducer it's own history so that you can zoom out in steps after zooming in multiple times. I wonder if it'll be easy to nest 2 reducers with history like that. |
||
blocksMode, | ||
blockListSettings, | ||
insertionPoint, | ||
|
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 think this negative margin may be causing a strange movement on the previous block when a new block is inserted:
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.
That's strange. I would think
previous
is defined there. I'll look into it.