├── res └── js │ ├── dist │ └── .gitkeep │ └── src │ ├── Reducers │ ├── Reducers.js │ └── Group.js │ ├── Services │ ├── Services.js │ └── AcfGroupService.js │ ├── Components │ ├── NotSupported.js │ ├── Textarea.js │ ├── Text.js │ ├── Email.js │ ├── Password.js │ ├── Url.js │ ├── Number.js │ ├── Select.js │ ├── ButtonGroup.js │ ├── Range.js │ ├── Field.js │ ├── TrueFalse.js │ ├── ListItem.js │ ├── Row.js │ ├── Group.js │ ├── Layout.js │ ├── Radio.js │ ├── Checkbox.js │ ├── Image.js │ ├── Repeater.js │ ├── FlexibleContent.js │ └── Relationship.js │ ├── Containers │ └── AcfGroup.js │ ├── Actions │ └── AcfGroups.js │ └── AcfGutenberg.js ├── .gitignore ├── lib ├── AbstractSingleton.php └── AdvancedCustomGutenberg.php ├── acf-gutenberg.php ├── package.json ├── webpack.config.js ├── README.md ├── CODE_OF_CONDUCT.md ├── Psr4Autoloader.php └── LICENSE /res/js/dist/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | node_modules/ 3 | res/js/dist/ 4 | !res/js/dist/.gitkeep 5 | -------------------------------------------------------------------------------- /res/js/src/Reducers/Reducers.js: -------------------------------------------------------------------------------- 1 | import {combineReducers} from 'redux'; 2 | import Group from './Group'; 3 | 4 | const Reducers = combineReducers({ 5 | Group 6 | }); 7 | 8 | export default Reducers; 9 | -------------------------------------------------------------------------------- /res/js/src/Services/Services.js: -------------------------------------------------------------------------------- 1 | import AcfGroupService from './AcfGroupService'; 2 | 3 | const Services = (store) => { 4 | const acfGroupService = new AcfGroupService(store); 5 | return { 6 | acfGroupService 7 | } 8 | }; 9 | 10 | export default Services; 11 | -------------------------------------------------------------------------------- /res/js/src/Components/NotSupported.js: -------------------------------------------------------------------------------- 1 | import {Component} from 'react'; 2 | 3 | export default class NotSupported extends Component { 4 | render() { 5 | return ( 6 |
7 |
Component type "{this.props.type}" is not supported!
8 |
9 | ) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/AbstractSingleton.php: -------------------------------------------------------------------------------- 1 | 12 | */ 13 | 14 | abstract class AbstractSingleton { 15 | 16 | private static $instances = array(); 17 | 18 | static public function init() { 19 | $class = get_called_class(); 20 | if (!isset(self::$instances[$class])) { 21 | self::$instances[$class] = new static(); 22 | } 23 | return self::$instances[$class]; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /acf-gutenberg.php: -------------------------------------------------------------------------------- 1 | register(); 25 | $psr4Autoloader->addNamespace('MBT', ACG_DIR . '/lib'); 26 | 27 | add_action('acf/init', array('\\MBT\\AdvancedCustomGutenberg','init')); 28 | -------------------------------------------------------------------------------- /res/js/src/Containers/AcfGroup.js: -------------------------------------------------------------------------------- 1 | import {connect} from 'react-redux'; 2 | 3 | import Group from '../Components/Group'; 4 | import {updateField, triggerFieldsSave, setPostId} from '../Actions/AcfGroups'; 5 | 6 | const mapStateToProps = (state, ownProps) => { 7 | return state; 8 | }; 9 | 10 | const mapDispatchToProps = (dispatch, ownProps) => { 11 | return { 12 | onChange: (fieldKey, value) => { 13 | // Hack to make save button available 14 | ownProps.onGroupChange(Date.now()); 15 | 16 | dispatch(updateField(fieldKey, value)) 17 | }, 18 | onSave: () => { 19 | dispatch(triggerFieldsSave()) 20 | }, 21 | setPostId: postId => { 22 | dispatch(setPostId(postId)) 23 | } 24 | } 25 | }; 26 | 27 | const AcfGroup = connect(mapStateToProps, mapDispatchToProps)(Group); 28 | 29 | export default AcfGroup; 30 | -------------------------------------------------------------------------------- /res/js/src/Components/Textarea.js: -------------------------------------------------------------------------------- 1 | import {Component} from 'react'; 2 | import Field from './Field'; 3 | 4 | export default class Textarea extends Component { 5 | onChange(e) { 6 | return this.props.onChange(this.props.acfKey, e.currentTarget.value); 7 | } 8 | getAttributes() { 9 | let attributes = { 10 | id: `${this.props.fieldId ? this.props.fieldId : 'acf-'}${this.props.acfKey}`, 11 | name: `${this.props.fieldName ? this.props.fieldName : 'acf'}[${this.props.acfKey}]`, 12 | onChange: (e) => this.onChange(e), 13 | value: this.props.value ? this.props.value : this.props['default_value'], 14 | rows: this.props.rows ? this.props.rows : 8 15 | }; 16 | if (this.props.placeholder !== '') { 17 | attributes.placeholder = this.props.placeholder; 18 | } 19 | if (this.props.required) { 20 | attributes.required = true; 21 | } 22 | return attributes; 23 | } 24 | 25 | render() { 26 | return ( 27 | 28 |