Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function PB4October(editor, options){
- //October Partial Block
- editor.DomComponents.addType('october-partial', {
- isComponent: el => {
- if (el.attributes) {
- if(el.attributes.getNamedItem('october-partial')) {
- var r = el.attributes.getNamedItem('october-partial').value;
- if(r == '1'){
- return true;
- }
- }
- }
- },
- model: {
- defaults: {
- traits: [
- 'id',
- {
- type: 'select',
- name: 'partial',
- options: options.partials
- },
- ]
- },
- init() {
- this.on('change:attributes:partial', this.handleChange);
- this.handleChange();
- },
- handleChange() {
- const partial = this.getAttributes().partial;
- if(this.getAttributes()['october-partial'] == '1'){
- if (partial) {
- this.attributes['content'] = '';
- this.components(` {% partial '${partial}' %}`);
- } else {
- this.attributes['content'] = '';
- this.components(`Select partial`);
- }
- }
- }
- }
- });
- editor.BlockManager.add('october-partial-block', {
- label: 'October CMS partial',
- category: 'October CMS',
- content:`<div data-gjs-type="october-partial" october-partial="1" ></div>`,
- attributes: {
- class: 'fa fa-code'
- }
- });
- //October Content Block
- editor.DomComponents.addType('october-content', {
- isComponent: el => {
- if (el.attributes) {
- if(el.attributes.getNamedItem('october-content')) {
- var r = el.attributes.getNamedItem('october-content').value;
- if(r == '1'){
- return true;
- }
- }
- }
- },
- model: {
- defaults: {
- traits: [
- 'id',
- {
- type: 'select',
- name: 'content',
- options: options.contents
- },
- ]
- },
- init() {
- this.on('change:attributes:content', this.handleChange);
- this.handleChange();
- },
- handleChange() {
- const content = this.getAttributes().content;
- if(this.getAttributes()['october-content'] == '1'){
- if (content) {
- this.attributes['content'] = '';
- this.components(` {% content '${content}' %}`);
- } else {
- this.attributes['content'] = '';
- this.components(`Select content`);
- }
- }
- }
- }
- });
- editor.BlockManager.add('october-content-block', {
- label: 'October CMS Content',
- category: 'October CMS',
- content:`<div data-gjs-type="october-content" october-content="1" ></div>`,
- attributes: {
- class: 'fa fa-code'
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement