PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.4.1
JetFormBuilder — Dynamic Blocks Form Builder v3.6.4.1
3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / modules / framework / blocks-style-manager / assets / src / editor.js
jetformbuilder / modules / framework / blocks-style-manager / assets / src Last commit date
components 2 months ago css-engine 2 months ago helpers 2 months ago hoc-wrappers 2 months ago editor.js 2 months ago editor.scss 2 months ago
editor.js
100 lines
1 import './editor.scss';
2 import { addFilter } from '@wordpress/hooks';
3 import { withStylesControls } from './hoc-wrappers/with-styles-controls';
4 import { withBlockUniqueClass } from './hoc-wrappers/with-block-class';
5
6 class CrocoBlockStyleEditor {
7
8 init() {
9
10 this.blocks = window?.crocoStyleEditorData?.blocks_supports || {};
11 this.supportName = window?.crocoStyleEditorData?.support_name;
12 this.defaults = window?.crocoStyleEditorData?.defaults || {};
13 this.usedClasses = {};
14
15 addFilter(
16 'blocks.registerBlockType',
17 'crocoblock-style-manager/enable-block-support',
18 this.registerBlock.bind( this )
19 );
20
21 addFilter(
22 'editor.BlockEdit',
23 'crocoblock-style-manager/enable-block-support',
24 withStylesControls
25 );
26
27 addFilter(
28 'editor.BlockListBlock',
29 'crocoblock-style-manager/with-crocoblock-editor-class',
30 withBlockUniqueClass,
31 0
32 );
33 }
34
35 classIsUsed( className, clientId ) {
36
37 if ( ! className || ! clientId ) {
38 return false;
39 }
40
41 if ( this.usedClasses[ className ] ) {
42 if ( this.usedClasses[ className ] === clientId ) {
43 // It's the same clientId, so we can use this class
44 return false;
45 } else {
46 // The class is already used by another block
47 return true;
48 }
49 } else {
50 // The class is not used yet, so we can use it
51 this.usedClasses[ className ] = clientId;
52 return false;
53 }
54 }
55
56 getBlockControls( blockName ) {
57 return this.blocks[ blockName ] || false;
58 }
59
60 registerBlock( settings, name ) {
61
62 if ( ! this.getBlockControls( name ) ) {
63 return settings;
64 }
65
66 const supports = settings.supports || {};
67 supports[ this.supportName ] = true;
68
69 const attributes = settings.attributes || {};
70
71 if ( ! attributes[ this.supportName ] ) {
72
73 let defaults = {
74 _uniqueClassName: '',
75 };
76
77 if ( this.defaults[ name ] ) {
78 defaults = {
79 ...defaults,
80 ...this.defaults[ name ],
81 };
82 }
83
84 attributes[ this.supportName ] = {
85 type: 'object',
86 default: defaults,
87 style: true,
88 };
89 }
90
91 return {
92 ...settings,
93 supports: supports,
94 attributes: attributes,
95 };
96 }
97 }
98
99 window.crocoBlockStyleEditor = new CrocoBlockStyleEditor();
100 window.crocoBlockStyleEditor.init();