Last active
January 19, 2019 14:08
-
-
Save technote-space/4f8589448e5357e5cd9dc437d5a6902d to your computer and use it in GitHub Desktop.
子テーマへの追加例2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.editor-styles-wrapper .test-class { | |
display: inline; | |
background-position: left -100% center; | |
background-repeat: repeat-x; | |
background-image: linear-gradient(to right, rgba(255, 255, 255, 0) 50%, #ff6 50%); | |
background-size: 200% .6em; | |
font-weight: bold; | |
padding-bottom: .6em; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (richText, element, editor) { | |
const name = 'my-theme/my-theme'; | |
const title = 'test-title'; | |
const className = 'test-class'; | |
richText.registerFormatType(name, { | |
title: title, | |
tagName: 'span', | |
className: className, | |
edit: function ({isActive, value, onChange}) { | |
return element.createElement(editor.RichTextToolbarButton, { | |
icon: 'admin-customizer', | |
title: title, | |
onClick: function () { | |
onChange(richText.toggleFormat(value, { | |
type: name | |
})); | |
}, | |
isActive: isActive, | |
}); | |
}, | |
}); | |
}( | |
window.wp.richText, | |
window.wp.element, | |
window.wp.editor | |
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* ... 省略 ... */ | |
add_action( 'enqueue_block_editor_assets', function () { | |
wp_enqueue_style( 'my-theme-editor-css', get_theme_file_uri( 'editor.css' ) ); // 追加 | |
wp_enqueue_script( 'my-theme-editor-js', get_theme_file_uri( 'editor.js' ), [ | |
'wp-element', | |
'wp-rich-text', | |
'wp-editor', | |
] ); | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Theme Name: .... | |
*/ | |
/* ... 省略 ... */ | |
.test-class { | |
display: inline; | |
background-position: left -100% center; | |
background-repeat: repeat-x; | |
background-image: linear-gradient(to right, rgba(255, 255, 255, 0) 50%, #ff6 50%); | |
background-size: 200% .6em; | |
font-weight: bold; | |
padding-bottom: .6em; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment