Skip to content

Commit

Permalink
Issue #9 - support migration from oik-block/geshi to oik-css/geshi us…
Browse files Browse the repository at this point in the history
…ing transform. Update keywords
  • Loading branch information
bobbingwide committed Jan 4, 2020
1 parent 4ab7e95 commit fa45e86
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions blocks/oik-geshi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Uses [bw_geshi] shortcode from oik-css plugin
*
* @copyright (C) Copyright Bobbing Wide 2018,2019
* @copyright (C) Copyright Bobbing Wide 2018-2020
* @author Herb Miller @bobbingwide
*/
import './style.scss';
Expand All @@ -16,12 +16,15 @@ const { __ } = wp.i18n;
// Get registerBlockType from wp.blocks
const {
registerBlockType,
createBlock,
} = wp.blocks;
const {
InspectorControls,
PlainText,
ServerSideRender,
} = wp.editor;
const {
InspectorControls,
PlainText,
} = wp.blockEditor;

const {
Toolbar,
Expand Down Expand Up @@ -72,8 +75,14 @@ export default registerBlockType(
// Limit to 3 Keywords / Phrases
keywords: [
__( 'GeSHi' ),
__( 'oik' ),
__( 'php html js'),
__( 'syntax' ),
__( 'highlight' ),
__( 'PHP' ),
__( 'HTML' ),
__( 'JavaScript' ),
__( 'CSS' ),
__( 'MySQL' ),

],

// Set for each piece of dynamic data used in your block
Expand All @@ -98,6 +107,21 @@ export default registerBlockType(
content: __( 'echo "Code is Poetry."' ),
},
},
transforms: {
from: [
{
type: 'block',
blocks: ['oik-block/geshi'],
transform: function( attributes ) {
return createBlock( 'oik-css/geshi', {
lang: attributes.lang,
text: attributes.text,
content: attributes.content
});
},
},
],
},


supports: {
Expand Down

0 comments on commit fa45e86

Please sign in to comment.