Skip to content
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

FEATURE: Configurable default edit preview mode #74

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Configuration/NodeTypes.Mixin.Analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@
label: i18n
group: 'yoast'
view: 'Yoast.YoastSeoForNeos/Inspector/Views/YoastInfoView'
viewOptions:
defaultEditPreviewMode: 'inPlace'
position: 20
7 changes: 5 additions & 2 deletions Resources/Private/Scripts/neos-ui-plugin/src/YoastInfoView.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export default class YoastInfoView extends PureComponent {
setWorker: PropTypes.func.isRequired,
setAnalysis: PropTypes.func.isRequired,
workerUrl: PropTypes.string,
options: PropTypes.shape({
defaultEditPreviewMode: PropTypes.string,
}),
};

static defaultProps = {
Expand Down Expand Up @@ -408,15 +411,15 @@ export default class YoastInfoView extends PureComponent {
};

render() {
const { i18nRegistry, analysis } = this.props;
const { i18nRegistry, analysis, options } = this.props;
const { isAnalyzing, page } = this.state;
const contentResultsIconState = analysis.readability.expanded ? 'chevron-circle-up' : 'chevron-circle-down';
const seoResultsIconState = analysis.seo.expanded ? 'chevron-circle-up' : 'chevron-circle-down';

return (
<ul className={style.yoastInfoView}>
<li className={style.yoastInfoView__item}>
<SnippetPreviewButton />
<SnippetPreviewButton defaultEditPreviewMode={options.defaultEditPreviewMode || 'inPlace'}/>
</li>

{!page.isAnalyzing &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {$transform} from 'plow-js';
import {neos} from '@neos-project/neos-ui-decorators';
import {actions, selectors} from '@neos-project/neos-ui-redux-store';
import {Icon, Button} from '@neos-project/react-ui-components';
import PropTypes from "prop-types";

@connect($transform({
editPreviewMode: selectors.UI.EditPreviewMode.currentEditPreviewMode,
Expand All @@ -15,9 +16,13 @@ import {Icon, Button} from '@neos-project/react-ui-components';
}))
export default class SnippetPreviewButton extends PureComponent {

static propTypes = {
defaultEditPreviewMode: PropTypes.string.isRequired,
};

handleToggleSnippetPreviewClick = () => {
const {setEditPreviewMode, editPreviewMode} = this.props;
setEditPreviewMode(editPreviewMode === 'yoastSeoView' ? 'inPlace' : 'yoastSeoView');
const {setEditPreviewMode, editPreviewMode, defaultEditPreviewMode} = this.props;
setEditPreviewMode(editPreviewMode === 'yoastSeoView' ? defaultEditPreviewMode : 'yoastSeoView');
};

render () {
Expand Down
2 changes: 1 addition & 1 deletion Resources/Public/YoastInfoView/Plugin.js

Large diffs are not rendered by default.