mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-04 03:43:34 +00:00 
			
		
		
		
	Add new layout dynamic
This commit is contained in:
		
							parent
							
								
									67cb54ae12
								
							
						
					
					
						commit
						0952c9aaa9
					
				@ -51,6 +51,11 @@ class Wysiwyg extends React.Component {
 | 
			
		||||
      this.setState({ isFocused: true });
 | 
			
		||||
      return this.domEditor.focus();
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    this.blur = () => {
 | 
			
		||||
      this.setState({ isFocused: false });
 | 
			
		||||
      return this.domEditor.blur();
 | 
			
		||||
    };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  componentDidMount() {
 | 
			
		||||
@ -348,7 +353,7 @@ class Wysiwyg extends React.Component {
 | 
			
		||||
 | 
			
		||||
  onChange = (editorState) => {
 | 
			
		||||
    // Update the state and force the focus
 | 
			
		||||
    this.setState({ editorState }, () => { this.focus(); });
 | 
			
		||||
    this.setState({ editorState });
 | 
			
		||||
    this.props.onChange({ target: {
 | 
			
		||||
      value: editorState.getCurrentContent().getPlainText(),
 | 
			
		||||
      name: this.props.name,
 | 
			
		||||
@ -450,7 +455,7 @@ class Wysiwyg extends React.Component {
 | 
			
		||||
              editorState={editorState}
 | 
			
		||||
              handleKeyCommand={this.handleKeyCommand}
 | 
			
		||||
              keyBindingFn={this.mapKeyToEditorCommand}
 | 
			
		||||
              onBlur={() => this.setState({ isFocused: false })}
 | 
			
		||||
              onBlur={this.blur}
 | 
			
		||||
              onChange={this.onChange}
 | 
			
		||||
              placeholder={this.props.placeholder}
 | 
			
		||||
              setRef={(editor) => this.domEditor = editor}
 | 
			
		||||
 | 
			
		||||
@ -137,6 +137,8 @@ class Edit extends React.PureComponent {
 | 
			
		||||
            const details = this.state.displayedFields[attr];
 | 
			
		||||
            // Retrieve the input's bootstrapClass from the layout
 | 
			
		||||
            const layout = this.getInputLayout(attr);
 | 
			
		||||
            const appearance = get(layout, 'appearance');
 | 
			
		||||
            const type = !isEmpty(appearance) ? appearance.toLowerCase() : get(layout, 'type', getInputType(details.type));
 | 
			
		||||
 | 
			
		||||
            return (
 | 
			
		||||
              <Input
 | 
			
		||||
@ -151,7 +153,7 @@ class Edit extends React.PureComponent {
 | 
			
		||||
                onChange={this.props.onChange}
 | 
			
		||||
                selectOptions={get(this.props.attributes, [attr, 'enum'])}
 | 
			
		||||
                placeholder={get(layout, 'placeholder') || details.placeholder}
 | 
			
		||||
                type={get(layout, 'type', getInputType(details.type))}
 | 
			
		||||
                type={type}
 | 
			
		||||
                validations={this.getInputValidations(attr)}
 | 
			
		||||
                value={this.props.record[attr]}
 | 
			
		||||
              />
 | 
			
		||||
 | 
			
		||||
@ -32,9 +32,6 @@ import getQueryParameters from 'utils/getQueryParameters';
 | 
			
		||||
import { bindLayout } from 'utils/bindLayout';
 | 
			
		||||
import { checkFormValidity } from 'utils/formValidations';
 | 
			
		||||
 | 
			
		||||
// Layout
 | 
			
		||||
import layout from '../../../../config/layout';
 | 
			
		||||
 | 
			
		||||
import {
 | 
			
		||||
  changeData,
 | 
			
		||||
  getData,
 | 
			
		||||
@ -109,7 +106,7 @@ export class EditPage extends React.Component {
 | 
			
		||||
   * @return {[type]} [description]
 | 
			
		||||
   */
 | 
			
		||||
  getLayout = () => (
 | 
			
		||||
    bindLayout.call(this, get(this.context.plugins.toJS(), `${this.getSource()}.layout`, layout))
 | 
			
		||||
    bindLayout.call(this, this.props.editPage.layout)
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
@ -174,7 +171,7 @@ export class EditPage extends React.Component {
 | 
			
		||||
    this.props.setFormErrors(formErrors);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  layout = bindLayout.call(this, layout);
 | 
			
		||||
  // layout = bindLayout.call(this, layout);
 | 
			
		||||
 | 
			
		||||
  componentDidCatch(error, info) {
 | 
			
		||||
    console.log('err', error);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user