I have a DateTimePicker Component in my Gutenberg Block. It seems, he's not correctly integrated :
- some styles are missing
- the zero of "05" minutes in the TextControl doesn't appear.
Is there anything I forgot ? How can I change this ?
Here is my index.js :
const {
registerBlockType
} = wp.blocks;
import edit from './edit';
import './editor.scss';
registerBlockType('pcfestival/date', {
title: 'Date',
category: 'pcfestival',
attributes: {
date: {
type: 'string'
},
},
edit,
save() {
return null;
}
});
my edit.js :
const {
Component,
Fragment
} = wp.element;
const { DateTimePicker, TextControl } = wpponents;
const { __experimentalGetSettings } = wp.date;
const { InspectorControls } = wp.editor;
const { withState } = wppose;
class EditDateBlock extends Component {
constructor() {
super(...arguments);
}
render() {
const {
attributes : {
date
},
setAttributes,
className
} = this.props;
const settings = __experimentalGetSettings();
return (
<Fragment>
<div className={className}>
<DateTimePicker
currentDate={ date }
onChange={ ( date ) => setAttributes( { date } ) }
locale={ settings.l10n.locale }
is12Hour={ true }
/>
</div>
</Fragment>
);
}
}
export default EditDateBlock;
and finally my plugin who enqueue scripts :
<?php
/*
Plugin Name: PCFestival
*/
defined('ABSPATH') || exit;
if ( ! class_exists('PCFestival')) {
class PCFestival {
protected static $instance = null;
public static $version = 1.0;
public static function run() {
if( is_null(self::$instance) ) {
self::$instance = new self();
}
}
protected function __construct() {
add_action('enqueue_block_editor_assets', array($this, 'enqueue_block_editor_assets'));
}
public function enqueue_block_editor_assets() {
wp_enqueue_script(
'pcfestival-editor',
plugins_url('assets/blocks.editor.js', __FILE__),
array('wp-blocks', 'wp-element', 'wp-editor', 'wp-date', 'wp-data'),
self::$version,
true
);
wp_enqueue_style(
'pcfestival-editor',
plugins_url('assets/blocks.editor.css', __FILE__),
array(), // is there anything missing ?
self::$version
);
}
}
}
PCFestival::run();
a capture of the TimeDateControl
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745675318a4639651.html
评论列表(0条)