diff --git a/blocks/oik-countdown/index.js b/blocks/oik-countdown/index.js index 313dc3c..258fe56 100644 --- a/blocks/oik-countdown/index.js +++ b/blocks/oik-countdown/index.js @@ -43,6 +43,8 @@ const { } = wp.compose; const Fragment = wp.element.Fragment; +import { transforms } from './transforms.js'; + /** @@ -110,6 +112,8 @@ registerBlockType( supports: { html: false, className: false}, + transforms, + edit: props => { const onChangeSince = ( event ) => { diff --git a/blocks/oik-countdown/transforms.js b/blocks/oik-countdown/transforms.js new file mode 100644 index 0000000..7f0cf4d --- /dev/null +++ b/blocks/oik-countdown/transforms.js @@ -0,0 +1,62 @@ +/** + * Transformation to oik/countdown of oik-blocks/countdown and [bw_coundtown]. + */ +const { createBlock +} = wp.blocks; + +const transforms = { + from: [ + { + type: 'block', + blocks: ['oik-block/countdown'], + transform: function (attributes) { + return createBlock('oik/countdown', attributes ); + }, + }, + { + type: 'shortcode', + tag: 'bw_countdown', + attributes: { + since: { + type: 'string', + shortcode: ( { named: { since } } ) => { + return since; + }, + }, + until: { + type: 'string', + shortcode: ( { named: { until } } ) => { + return until; + }, + }, + url: { + type: 'string', + shortcode: ( { named: { url } } ) => { + return url; + }, + }, + description: { + type: 'string', + shortcode: ( { named: { description } } ) => { + return description; + }, + }, + expirytext: { + type: 'string', + shortcode: ( { named: { expirytext } } ) => { + return expirytext; + }, + }, + format: { + type: 'string', + shortcode: ( { named: { format } } ) => { + return format; + }, + }, + + }, + }, + ] +}; + +export { transforms } ; \ No newline at end of file