-
Notifications
You must be signed in to change notification settings - Fork 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
Media: Implement WIP advanced image settings dialog #2085
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
38 changes: 38 additions & 0 deletions
38
client/components/tinymce/plugins/media/advanced/index.jsx
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,38 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React from 'react'; | ||
import ReactDomServer from 'react-dom/server'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import i18n from 'lib/mixins/i18n'; | ||
import config from 'config'; | ||
import { toggleEditorMediaAdvanced } from 'state/ui/editor/media/actions'; | ||
import Gridicon from 'components/gridicon'; | ||
|
||
export default function( editor ) { | ||
const store = editor.getParam( 'redux_store' ); | ||
if ( ! config.isEnabled( 'post-editor/media-advanced' ) || ! store ) { | ||
return; | ||
} | ||
|
||
editor.addButton( 'wp_img_advanced', { | ||
tooltip: i18n.translate( 'Edit', { context: 'verb' } ), | ||
|
||
classes: 'toolbar-segment-start', | ||
|
||
onPostRender() { | ||
this.innerHtml( ReactDomServer.renderToStaticMarkup( | ||
<button type="button" role="presentation" tabIndex="-1"> | ||
<Gridicon icon="pencil" size={ 18 } /> | ||
</button> | ||
) ); | ||
}, | ||
|
||
onClick() { | ||
store.dispatch( toggleEditorMediaAdvanced() ); | ||
} | ||
} ); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* External depencencies | ||
*/ | ||
import React, { PropTypes } from 'react'; | ||
import { bindActionCreators } from 'redux'; | ||
import { connect } from 'react-redux'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { toggleEditorMediaAdvanced } from 'state/ui/editor/media/actions'; | ||
import Dialog from 'components/dialog'; | ||
|
||
function EditorMediaAdvanced( { visible, toggleVisible } ) { | ||
return ( | ||
<Dialog isVisible={ visible } onClose={ toggleVisible }> | ||
WIP | ||
</Dialog> | ||
); | ||
} | ||
|
||
EditorMediaAdvanced.propTypes = { | ||
visible: PropTypes.bool, | ||
toggleVisible: PropTypes.func | ||
}; | ||
|
||
EditorMediaAdvanced.defaultProps = { | ||
visible: false, | ||
toggleVisible: () => {} | ||
}; | ||
|
||
export default connect( | ||
( state ) => { | ||
return { | ||
visible: state.ui.editor.media.advanced | ||
}; | ||
}, | ||
( dispatch ) => { | ||
return bindActionCreators( { | ||
toggleVisible: toggleEditorMediaAdvanced | ||
}, dispatch ); | ||
} | ||
)( EditorMediaAdvanced ); |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { EDITOR_MEDIA_ADVANCED_TOGGLE } from 'state/action-types'; | ||
|
||
export function toggleEditorMediaAdvanced() { | ||
return { | ||
type: EDITOR_MEDIA_ADVANCED_TOGGLE | ||
}; | ||
} |
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,23 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { combineReducers } from 'redux'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { EDITOR_MEDIA_ADVANCED_TOGGLE } from 'state/action-types'; | ||
|
||
function advanced( state = false, action ) { | ||
switch ( action.type ) { | ||
case EDITOR_MEDIA_ADVANCED_TOGGLE: | ||
state = ! state; | ||
break; | ||
} | ||
|
||
return state; | ||
} | ||
|
||
export default combineReducers( { | ||
advanced | ||
} ); |
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,13 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { combineReducers } from 'redux'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import media from './media/reducer'; | ||
|
||
export default combineReducers( { | ||
media | ||
} ); |
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
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.
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.
why put these here when we are already using destructuring in the function declaration?
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.
You know, that's an interesting question. One has to wonder why
defaultProps
was one of the two properties that the React team chose to support for stateless functional components. Perhaps there's some semantics ofdefaultProps
that wouldn't be reflected with the destructured default values? I couldn't find much discussion on the topic, though this commenter appears to prefer default arguments from a function purity perspective. On the flip-side, it does make the function declaration line a bit longer.Do you have a strong preference either way? I'm inclined to keep it as is, mostly for aesthetics to this last point and for proximity to the
propTypes
declaration for quick scanning. Additionally, it may be that this is easier for static analysis if we choose to pursue some automated documentation of components.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.
not at all 😄