initial commit

This commit is contained in:
Ray Elliott 2020-08-12 14:20:11 +01:00
commit 0f2a24ed8b
12 changed files with 16974 additions and 0 deletions

1
.eslintignore Symbolic link
View File

@ -0,0 +1 @@
node_modules/@wordpress/scripts/config/.eslintignore

1
.eslintrc-md.js Symbolic link
View File

@ -0,0 +1 @@
node_modules/@wordpress/scripts/config/.eslintrc-md.js

1
.eslintrc.js Symbolic link
View File

@ -0,0 +1 @@
node_modules/@wordpress/scripts/config/.eslintrc.js

1
.stylelintignore Symbolic link
View File

@ -0,0 +1 @@
node_modules/@wordpress/scripts/config/.stylelintignore

1
.stylelintrc.json Symbolic link
View File

@ -0,0 +1 @@
node_modules/@wordpress/scripts/config/.stylelintrc.json

1
README.md Normal file
View File

@ -0,0 +1 @@

16860
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

17
package.json Normal file
View File

@ -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"
}
}

9
src/editor.scss Normal file
View File

@ -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;
}

29
src/index.js Normal file
View File

@ -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' ) );
},
} );

11
src/style.scss Normal file
View File

@ -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;
}

42
svg.php Normal file
View File

@ -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' );