-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Editor: Integrate post-title and post-content with custom sources.
- Loading branch information
Showing
6 changed files
with
68 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"name": "core/post-content", | ||
"category": "common" | ||
"category": "common", | ||
"multiple": false | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import * as post from './post'; | ||
import * as meta from './meta'; | ||
|
||
export { meta }; | ||
export { post, meta }; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { get, set } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { select } from '@wordpress/data-controls'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { editPost } from '../actions'; | ||
import { EDIT_MERGE_PROPERTIES } from '../constants'; | ||
|
||
export function* getDependencies() { | ||
return { | ||
post: yield select( 'core/editor', 'getCurrentPost' ), | ||
content: yield select( 'core/editor', 'getEditedPostContent' ), | ||
edits: yield select( 'core/editor', 'getPostEdits' ), | ||
}; | ||
} | ||
|
||
export function apply( { attribute }, { post, content, edits } ) { | ||
if ( 'content' === attribute ) { | ||
return content; | ||
} | ||
|
||
if ( undefined === get( edits, attribute ) ) { | ||
return get( post, attribute ); | ||
} | ||
|
||
if ( EDIT_MERGE_PROPERTIES.has( attribute ) ) { | ||
return { | ||
...get( post, attribute ), | ||
...get( edits, attribute ), | ||
}; | ||
} | ||
|
||
return get( edits, attribute ); | ||
} | ||
|
||
export function* update( { attribute }, value ) { | ||
yield editPost( set( {}, attribute, value ) ); | ||
} |