Skip to content

Commit

Permalink
Including the p5js file as a local dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
mapk committed Feb 7, 2019
1 parent 432cf0f commit 65a04ba
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 151 deletions.
File renamed without changes.
3 changes: 3 additions & 0 deletions assets/js/p5.min.js

Large diffs are not rendered by default.

111 changes: 1 addition & 110 deletions dist/blocks.build.js

Large diffs are not rendered by default.

23 changes: 1 addition & 22 deletions dist/blocks.editor.build.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 1 addition & 16 deletions dist/blocks.style.build.css
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
/**
* #.# Common SCSS
*
* Can include things like variables and mixins
* that are used across the project.
*/
/**
* #.# Styles
*
* CSS for both Frontend+Backend.
*/
.wp-block-cgb-block-p5js iframe {
padding: 0;
margin: 0;
width: 100%;
border: none; }
.wp-block-cgb-block-p5js iframe{padding:0;margin:0;width:100%;border:none}
2 changes: 1 addition & 1 deletion src/block/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ registerBlockType( 'cgb/block-p5js', {
{ ( isDisabled ) => (
( isPreview || isDisabled ) ? (
<SandBox html={
'<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/p5.min.js"></script>' +
'<script src="' + window._p5ScriptUrl + '"></script>' +
'<script>' + attributes.content + '</script>'
} />
) : (
Expand Down
6 changes: 4 additions & 2 deletions src/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function p5js_cgb_block_assets() { // phpcs:ignore
if ( ! is_admin() ) {
wp_enqueue_script(
'p5-js-iframe-sizer-script', // Handle.
plugins_url( '/assets/iframe-sizer.js', dirname( __FILE__ ) ),
plugins_url( '/assets/js/iframe-sizer.js', dirname( __FILE__ ) ),
array( 'jquery', 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ), // Dependencies, defined above.
// filemtime( plugin_dir_path( __DIR__ ) . 'assets/js/p5.min.js' ), // Version: File modification time.
true // Enqueue the script in the footer.
Expand Down Expand Up @@ -61,6 +61,8 @@ function p5js_cgb_editor_assets() { // phpcs:ignore
true // Enqueue the script in the footer.
);

wp_add_inline_script( 'p5js-cgb-block-js', 'window._p5ScriptUrl = "' . plugins_url( '/assets/js/p5.min.js', dirname( __FILE__ ) ) . '";' );

// Styles.
wp_enqueue_style(
'p5js-cgb-block-editor-css', // Handle.
Expand All @@ -75,7 +77,7 @@ function p5js_cgb_editor_assets() { // phpcs:ignore

function p5js_cgb__render_block( $attributes, $content ) {
$scriptsAndStyles = [
'<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/p5.js"></script>',
'<script src="' . plugins_url( '/assets/js/p5.min.js', dirname( __FILE__ ) ) . '"></script>',
'<script>' . $attributes['content'] . '</script>',
'<style>body{margin: 0; padding: 0;}</style>'
];
Expand Down

0 comments on commit 65a04ba

Please sign in to comment.