blocks.js
| 1 | /** |
| 2 | * Gutenberg Blocks |
| 3 | * |
| 4 | * All blocks related JavaScript files should be imported here. |
| 5 | * You can create a new block folder in this dir and include code |
| 6 | * for that block here as well. |
| 7 | * |
| 8 | * All blocks should be included here since this is the file that |
| 9 | * Webpack is compiling as the input file. |
| 10 | */ |
| 11 | |
| 12 | import getUAGEditorStateLocalStorage from '@Controls/getUAGEditorStateLocalStorage'; |
| 13 | |
| 14 | // Delete the local storage on every refresh. |
| 15 | const uagLocalStorage = getUAGEditorStateLocalStorage(); |
| 16 | if ( uagLocalStorage ) { |
| 17 | uagLocalStorage.removeItem( 'uagSettingState' ); |
| 18 | uagLocalStorage.removeItem( 'isSpectraFontAwesomeAPILoading' ); |
| 19 | } |
| 20 | |
| 21 | import fontAwesomePollyfiller from './font-awesome-pollyfiller'; |
| 22 | |
| 23 | __webpack_public_path__ = srfm_spec_blocks_info.uagb_url + 'dist/'; |
| 24 | |
| 25 | // Merge all icon chunks. |
| 26 | srfm_spec_blocks_info.uagb_svg_icons = {}; |
| 27 | if ( srfm_spec_blocks_info?.number_of_icon_chunks ) { |
| 28 | for ( |
| 29 | let iconChunk = 0; |
| 30 | iconChunk < srfm_spec_blocks_info.number_of_icon_chunks; |
| 31 | iconChunk++ |
| 32 | ) { |
| 33 | srfm_spec_blocks_info.uagb_svg_icons = { |
| 34 | ...srfm_spec_blocks_info.uagb_svg_icons, |
| 35 | ...window[ 'uagb_svg_icons_' + iconChunk ], |
| 36 | }; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | // Add Font Awesome Polyfiller to localized variable. |
| 41 | srfm_spec_blocks_info.font_awesome_5_polyfill = fontAwesomePollyfiller; |
| 42 | |
| 43 | // Setting local storage key for svg Confirmation data. |
| 44 | uagLocalStorage.setItem( |
| 45 | 'uagSvgConfirmation', |
| 46 | JSON.stringify( srfm_spec_blocks_info?.svg_confirmation || false ) |
| 47 | ); |
| 48 | |
| 49 | import './editor.scss'; |
| 50 | import './blocks/separator/block.js'; |
| 51 | import './blocks/advanced-heading/block.js'; |
| 52 | import './blocks/image/block.js'; |
| 53 | import './blocks/icon/block.js'; |
| 54 | |
| 55 | // Keep category list in separate variable and remove category list from icons list. |
| 56 | if ( srfm_spec_blocks_info.uagb_svg_icons?.uagb_category_list ) { |
| 57 | wp.uagb_icon_category_list = [ |
| 58 | ...srfm_spec_blocks_info.uagb_svg_icons.uagb_category_list, |
| 59 | ]; |
| 60 | delete srfm_spec_blocks_info.uagb_svg_icons.uagb_category_list; |
| 61 | } |
| 62 | |
| 63 | wp.UAGBSvgIcons = Object.keys( srfm_spec_blocks_info.uagb_svg_icons ); |
| 64 | |
| 65 | const addCfResponsiveCondtionBlocks = function ( blocks ) { |
| 66 | blocks.push( 'wcfb/' ); |
| 67 | return blocks; |
| 68 | }; |
| 69 | |
| 70 | wp.hooks.addFilter( |
| 71 | 'uag_reponsive_conditions_compatible_blocks', |
| 72 | 'enable_reponsive_condition_for_cf_blocks', |
| 73 | addCfResponsiveCondtionBlocks |
| 74 | ); |
| 75 |