admin管理员组文章数量:1435859
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
本文标签: block editorDateTimePicker script and style missing
版权声明:本文标题:block editor - DateTimePicker script and style missing? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745675317a2669816.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论