/** * Palantics Tracking Block */ const { registerBlockType } = wp.blocks; const { InspectorControls } = wp.blockEditor; const { PanelBody, TextControl } = wp.components; const { Fragment } = wp.element; const { __ } = wp.i18n; // Register the block registerBlockType('palantics-tracking/track-element', { title: __('Tracking Element', 'palantics-tracking-plugin'), icon: 'chart-line', category: 'widgets', keywords: [ __('track', 'palantics-tracking-plugin'), __('analytics', 'palantics-tracking-plugin'), __('palantics', 'palantics-tracking-plugin'), ], attributes: { eventName: { type: 'string', default: 'tracked_element', }, content: { type: 'string', default: '', }, }, edit: function(props) { const { attributes, setAttributes } = props; const { eventName, content } = attributes; return ( setAttributes({ eventName: value })} help={__('Enter the event name that will be used for tracking this element', 'palantics-tracking-plugin')} />
{__('Palantics Tracking Element', 'palantics-tracking-plugin')}
{__('Event:', 'palantics-tracking-plugin')} {eventName}
{__('This element will be tracked when clicked', 'palantics-tracking-plugin')}
); }, save: function(props) { const { attributes } = props; const { eventName } = attributes; return (
{props.children}
); }, });