-
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
Refactor setupEditor effects to actions #14513
Changes from all commits
ea41379
0f590bb
f320abc
8ca0b55
451de2a
ce1e4fa
46a53e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,6 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { has } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
parse, | ||
synchronizeBlocksWithTemplate, | ||
} from '@wordpress/blocks'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { | ||
setupEditorState, | ||
resetEditorBlocks, | ||
} from './actions'; | ||
import { | ||
fetchReusableBlocks, | ||
saveReusableBlocks, | ||
|
@@ -28,32 +11,6 @@ import { | |
} from './effects/reusable-blocks'; | ||
|
||
export default { | ||
SETUP_EDITOR( action ) { | ||
const { post, edits, template } = action; | ||
|
||
// In order to ensure maximum of a single parse during setup, edits are | ||
// included as part of editor setup action. Assume edited content as | ||
// canonical if provided, falling back to post. | ||
let content; | ||
if ( has( edits, [ 'content' ] ) ) { | ||
content = edits.content; | ||
} else { | ||
content = post.content.raw; | ||
} | ||
|
||
let blocks = parse( content ); | ||
|
||
// Apply a template for new posts only, if exists. | ||
const isNewPost = post.status === 'auto-draft'; | ||
if ( isNewPost && template ) { | ||
blocks = synchronizeBlocksWithTemplate( blocks, template ); | ||
} | ||
|
||
return [ | ||
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. I suspect that this was the only occurrence of an array-action for which we apply the 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. Sorry I don't follow: The refactor changed this from an array action to dispatch actions. So the work in this pull already removes the reliance on the redux-multi middleware for 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, this. 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. Doesn't look like anything else was using this in the editor package so went ahead and removed it. I think I did things correctly (just removed from package.json) but with this being a mono-repo I'm not sure :) removed in 52af9b3 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.
The one-line removal from In any case, Travis would have caught it anyways if it was an issue, and it appears to be just fine. |
||
resetEditorBlocks( blocks ), | ||
setupEditorState( post ), | ||
]; | ||
}, | ||
FETCH_REUSABLE_BLOCKS: ( action, store ) => { | ||
fetchReusableBlocks( action, store ); | ||
}, | ||
|
This file was deleted.
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.
Nit: I'd wondered if JSDoc had some option to document generator function yields. It appears
@yields
is a thing, a suitable replacement for@return
.http://usejsdoc.org/tags-yields.html
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.
Ya I had thought about using
@yields
but the difficulty here is that most if not all of these actions do not have a single yield. So it's a bit tricky knowing what exactly to document.I've sort of loosely followed the pattern of only include a
@return
tag on generators when there are return values in the generator, otherwise having nothing.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.
Added
@yields
as a feature request for thedocgen
default formatter: #14583