saura
April 24, 2024, 9:33am
1
Hi, I’m trying to override the built-in component Box, and it is just duplicating it.
This is my code
Originally what I need is to use forms but I want to hide the “basics” tab. But I think we cannot do this so I’m trying to override components. What’s wrong with this?
Hello @saura ,
For overriding the Box component, try using the below code
const FakeBox = () => <div>Boxxx!!</div>;
Builder.registerComponent(FakeBox, {
name: "Core:Box",
override: true,
canHaveChildren: true,
inputs: [
{
name: 'children',
type: 'uiBlocks',
defaultValue: [],
// showNoBlocks: false
hideFromUI: true,
},
{
name: 'verticalAlignContent',
type: 'string',
enum: ['top', 'bottom', 'middle'],
defaultValue: 'top',
},
],
defaultStyles: {
height: '100px',
},
});
To hide the insertMenu, you can use the below code
Builder.register('editor.settings', { customInsertMenu: true });
const OVERRIDE_INSERT_MENU = false;
if (OVERRIDE_INSERT_MENU) {
// (optionally) use this to hide all default built-in components and fully manage
// the insert menu components and sections yourself
Builder.register('editor.settings', { customInsertMenu: true });
}
// (optionally) set these to add your own sections of components arranged as you choose.
// this can be used with or without `customInsertMenu` above
Builder.register('insertMenu', {
name: 'Simple components',
items: [
{ name: 'Hero' },
{ name: 'Double Columns' },
{ name: 'Triple Columns' },
{ name: 'Dynamic Columns' },
{ name: 'Custom Columns' },
],
This file has been truncated. show original
1 Like
@manish-sharma is there documentation on what is available in editor.settings
? Since it only applies to the editor (which is closed source) I can’t event find the code implementation.
Hello @JonathanLand ,
You may find help at the below link
saura
April 24, 2024, 3:00pm
5
I tried your code to override the BOX it’s still not overwritten. Same component, not showing the “BOXXX!!!” Text as you can see in the image.
And the code
Builder.register('editor.settings', { customInsertMenu: true });
Deletes all the components from the sidebar.
Hello @saura ,
There does seem to be some issue with overriding the default box component, we will investigate that further. Meanwhile, I would recommend creating your own custom Insert Menu.
For reference, please refer to the following forum post
Builder allows users who are integrating their own codebase to override the insert menu and re-arrange it however they’d like, to do so:
Builder.set({ customInsertMenu: true });
This resets the insert menu on the left completely, if you’d still like to show Builder’s built-in components you must explicitly add each one:
Builder.register('insertMenu', {
name: 'Builder components',
items: [
// built-ins
{ name: 'Core:Button' },
{ name: 'Core:Section' }
{ name: 'Custom Code' …
Thank,