initial commit
This commit is contained in:
commit
0f2a24ed8b
|
@ -0,0 +1 @@
|
|||
node_modules/@wordpress/scripts/config/.eslintignore
|
|
@ -0,0 +1 @@
|
|||
node_modules/@wordpress/scripts/config/.eslintrc-md.js
|
|
@ -0,0 +1 @@
|
|||
node_modules/@wordpress/scripts/config/.eslintrc.js
|
|
@ -0,0 +1 @@
|
|||
node_modules/@wordpress/scripts/config/.stylelintignore
|
|
@ -0,0 +1 @@
|
|||
node_modules/@wordpress/scripts/config/.stylelintrc.json
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "svg",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"dev": "wp-scripts start",
|
||||
"build": "wp-scripts build",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@wordpress/scripts": "12.1.1"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* The following styles get applied inside the editor only.
|
||||
*
|
||||
* Replace them with your own styles or remove the file completely.
|
||||
*/
|
||||
|
||||
.wp-block-room-vw-svg {
|
||||
border: 1px dotted #f00;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
import './style.scss';
|
||||
import './editor.scss';
|
||||
|
||||
const registerBlockType = { wp.blocks };
|
||||
const el = { wp.element };
|
||||
const __ = { wp.i18n};
|
||||
|
||||
registerBlockType( 'room-vw/svg', {
|
||||
title: __( 'SVG Wrapper', 'room-vw' ),
|
||||
|
||||
category: 'widgets',
|
||||
|
||||
supports: {
|
||||
// Removes support for an HTML mode.
|
||||
html: false,
|
||||
},
|
||||
|
||||
edit( props ) {
|
||||
return el(
|
||||
'p',
|
||||
{ className: props.className },
|
||||
__( 'Hello from the editor!', 'room-vw' )
|
||||
);
|
||||
},
|
||||
|
||||
save() {
|
||||
return el( 'p', {}, __( 'Hello from the saved content!', 'room-vw' ) );
|
||||
},
|
||||
} );
|
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* The following styles get applied both on the front of your site and in the editor.
|
||||
*
|
||||
* Replace them with your own styles or remove the file completely.
|
||||
*/
|
||||
|
||||
.wp-block-room-vw-svg {
|
||||
background-color: #000;
|
||||
color: #fff;
|
||||
padding: 2px;
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
function svg_block_init() {
|
||||
if ( ! function_exists( 'register_block_type' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$dir = get_template_directory() . '/blocks/svg';
|
||||
$uri = get_template_directory_uri() . "/blocks/svg";
|
||||
|
||||
$asset_file = include( get_template_directory() . '/blocks/svg/build/index.asset.php');
|
||||
|
||||
$index_js = 'build/index.js';
|
||||
wp_register_script(
|
||||
'svg-block-editor',
|
||||
"$uri/$index_js",
|
||||
$asset_file['dependencies'],
|
||||
$asset_file['version']
|
||||
);
|
||||
|
||||
$editor_css = 'build/style-index.css';
|
||||
wp_register_style(
|
||||
'svg-block-editor',
|
||||
"$uri/$editor_css",
|
||||
array(),
|
||||
filemtime( "$dir/$editor_css" )
|
||||
);
|
||||
|
||||
$style_css = 'build/index.css';
|
||||
wp_register_style(
|
||||
'svg-block',
|
||||
"$uri/$style_css",
|
||||
array(),
|
||||
filemtime( "$dir/$style_css" )
|
||||
);
|
||||
|
||||
register_block_type( 'room-vw/svg', array(
|
||||
'editor_script' => 'svg-block-editor',
|
||||
'editor_style' => 'svg-block-editor',
|
||||
'style' => 'svg-block',
|
||||
) );
|
||||
}
|
||||
add_action( 'init', 'svg_block_init' );
|
Loading…
Reference in New Issue