Create WoocommerceContent block
[MAILPOET-2279]
This commit is contained in:
committed by
Jack Kitterhing
parent
67946865fb
commit
2eb0133422
52
assets/js/src/newsletter_editor/blocks/woocommerceContent.js
Normal file
52
assets/js/src/newsletter_editor/blocks/woocommerceContent.js
Normal file
@@ -0,0 +1,52 @@
|
||||
/* eslint-disable func-names */
|
||||
import App from 'newsletter_editor/App';
|
||||
import BaseBlock from 'newsletter_editor/blocks/base';
|
||||
|
||||
const BlockModel = BaseBlock.BlockModel.extend({
|
||||
defaults: function () {
|
||||
return {
|
||||
type: 'woocommerceContent',
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
const BlockToolsView = BaseBlock.BlockToolsView.extend({
|
||||
tools: { move: true },
|
||||
});
|
||||
|
||||
const WidgetView = BaseBlock.WidgetView.extend({
|
||||
className: BaseBlock.WidgetView.prototype.className + ' mailpoet_droppable_layout_block',
|
||||
getTemplate: function () { return window.templates.woocommerceContentInsertion; },
|
||||
behaviors: {
|
||||
DraggableBehavior: {
|
||||
cloneOriginal: true,
|
||||
drop: function () {
|
||||
return new BlockModel({}, { parse: true });
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const BlockView = BaseBlock.BlockView.extend({
|
||||
className: 'mailpoet_block mailpoet_woocommerce_content_block mailpoet_droppable_block',
|
||||
getTemplate: function () { return window.templates.woocommerceContentBlock; },
|
||||
regions: {
|
||||
toolsRegion: '.mailpoet_tools',
|
||||
},
|
||||
onDragSubstituteBy: function () { return WidgetView; },
|
||||
onRender: function () {
|
||||
this.toolsView = new BlockToolsView({ model: this.model });
|
||||
this.showChildView('toolsRegion', this.toolsView);
|
||||
},
|
||||
});
|
||||
|
||||
App.on('before:start', function (BeforeStartApp) {
|
||||
BeforeStartApp.registerBlockType('woocommerceContent', {
|
||||
blockModel: BlockModel,
|
||||
blockView: BlockView,
|
||||
});
|
||||
});
|
||||
|
||||
export default {
|
||||
BlockModel, BlockView, BlockToolsView, WidgetView,
|
||||
};
|
@@ -48,3 +48,4 @@ import 'newsletter_editor/blocks/automatedLatestContentLayout.js'; // side effec
|
||||
import 'newsletter_editor/blocks/posts.js'; // side effect - calls App.on()
|
||||
import 'newsletter_editor/blocks/products.js'; // side effect - calls App.on()
|
||||
import 'newsletter_editor/blocks/social.js'; // side effect - calls App.on()
|
||||
import 'newsletter_editor/blocks/woocommerceContent.js'; // side effect - calls App.on()
|
||||
|
Reference in New Issue
Block a user