Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Added wrapping of Wordpress core nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Roelof Roos committed Oct 18, 2018
1 parent 6e18a66 commit 29ad0ce
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
21 changes: 21 additions & 0 deletions gumbo-millennium/lib/jsx/helpers/core-wrapper.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Wraps all core elements in a container
*
* @author Roelof Roos <[email protected]>
* @license MPL-2.0
*/

const { addFilter } = wp.hooks
const coreRegex = /^core(-embed)?\//i

export default function overrideCoreBlocks () {
addFilter('blocks.getSaveElement', 'gumbo/wrap-core-modules', (element, {name}) => {
if (!coreRegex.test(name)) {
return element
}

return <div className="container gumbo-normal-content">
{element}
</div>
})
}
4 changes: 4 additions & 0 deletions gumbo-millennium/lib/jsx/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

// Import objects
import overrideCoreBlocks from './helpers/core-wrapper'
import filterBlocks from './whitelist'
import registerBlocks from './blocks'

Expand All @@ -16,6 +17,9 @@ import registerBlocks from './blocks'
// Filter blocks
filterBlocks()

// Wrap core blocks in .container
overrideCoreBlocks()

/*
BLOCK REGISTRATION
*/
Expand Down

0 comments on commit 29ad0ce

Please sign in to comment.