<?php if ( !defined( 'ABSPATH' ) ) exit;//PHPの宣言と直接アクセスの拒否
/***** スクリプトの読み込み *****/
function haup_block_editor_extend_init(){
	//エディター用JS
if(is_admin()){
wp_register_script( 
				'edit-ritchtext-js',
				plugin_dir_url( __FILE__ ) .'edit_ritchtext.js',
				array( 'lodash', 'wp-rich-text','wp-element','wp-components', 'wp-blocks', 'wp-editor', 'wp-keycodes'),
				haup_plugin_version(),
				true 
			);
		}
	
	//スクリプトをエンキュー
	wp_enqueue_script('edit-ritchtext-js');

	//各装飾の名称を翻訳可能にする
	//スクリプトに渡すための文字列と翻訳可能文字列を紐づけて配列にする
	$localize_val = array(
		'button_text' => __('Text Decoration','hima-art-utility'),
		'submenu_underline' => __('UnderLine','hima-art-utility'),
		'submenu_marker' => __('Marker','hima-art-utility'),
		'submenu_size' => __('Text Size','hima-art-utility'),

		'yuline_text' => __('Light Yellow Underline','hima-art-utility'),
		'dyuline_text' => __('Dark Yellow Underline','hima-art-utility'),
		'buline_text' => __('Light Blue Underline','hima-art-utility'),
		'dbuline_text' => __('Dark Blue Underline','hima-art-utility'),
		'ruline_text' => __('Light Red Underline','hima-art-utility'),
		'druline_text' => __('Dark Red Underline','hima-art-utility'),
		'guline_text' => __('Light Green Underline','hima-art-utility'),
		'dguline_text' => __('Dark Green Underline','hima-art-utility'),

		'ymark_text' => __('Light Yellow Marker','hima-art-utility'),
		'dymark_text' => __('Dark Yellow Marker','hima-art-utility'),
		'bmark_text' => __('Light Blue Marker','hima-art-utility'),
		'dbmark_text' => __('Dark Blue Marker','hima-art-utility'),
		'rmark_text' => __('Light Red Marker','hima-art-utility'),
		'drmark_text' => __('Dark Red Marker','hima-art-utility'),
		'gmark_text' => __('Light Green Marker','hima-art-utility'),
		'dgmark_text' => __('Dark Green Marker','hima-art-utility'),

		'twelve_text' => __('Text x1.2','hima-art-utility'),
		'fifteen_text' => __('Text x1.5','hima-art-utility'),
		'twenty_text' => __('Text x2.0','hima-art-utility'),
		'fourty_text' => __('Text x4.0','hima-art-utility')
		);

	//wp_localize_scriptを使ってスクリプトへ配列を渡す
	wp_localize_script('edit-ritchtext-js', 'TextDecorationTitleVal', $localize_val);

}
add_action( 'enqueue_block_editor_assets', 'haup_block_editor_extend_init');
//add_action('wp_enqueue_scripts','haup_block_editor_extend_init');

/* スタイルの登録 */
function haup_block_editor_extend_css_init(){
	//スタイルの登録
	wp_register_style(
		'richtext-style',
		plugin_dir_url( __FILE__ ) .'richtext-style.css',
		array(),
		haup_plugin_version(),
		'all'
	);

	//スタイルシートの読み込み
	wp_enqueue_style('richtext-style');

}
add_action('wp_enqueue_scripts','haup_block_editor_extend_css_init');
add_action(  'enqueue_block_editor_assets', 'haup_block_editor_extend_css_init' ,3);