psy_vk2 / builder.html
DmitrMakeev's picture
Update builder.html
d62783d verified
raw
history blame
3.26 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GrapesJS Example</title>
<!-- GrapesJS CSS -->
<link rel="stylesheet" href="https://unpkg.com/grapesjs/dist/css/grapes.min.css">
</head>
<body>
<div id="gjs"></div>
<!-- GrapesJS JS -->
<script src="https://unpkg.com/grapesjs"></script>
<!-- Your Custom JS -->
<script>
const editor = grapesjs.init({
container: '#gjs',
fromElement: true,
height: '100vh',
storageManager: { type: 0 },
plugins: [],
pluginsOpts: {},
selectorManager: {
componentFirst: true,
},
styleManager: {
sectors: [
{
name: 'Dimensions',
properties: [
{
type: 'integer',
name: 'width',
units: ['px', '%'],
defaults: 'auto',
min: 0,
},
{
type: 'integer',
name: 'height',
units: ['px', '%'],
defaults: 'auto',
min: 0,
},
],
},
{
name: 'Typography',
properties: [
{
type: 'select',
name: 'font-family',
},
{
type: 'integer',
name: 'font-size',
units: ['px'],
defaults: '14px',
},
],
},
// Add more sectors and properties as needed
],
},
});
// Add a block for the button
editor.Blocks.add('button-block', {
label: 'Button',
content: `<button id="i1epvz" data-gjs-type="button" draggable="true" type="button" class="sub-btn" autocomplete="off">Submit</button>`,
});
// Define the button component type
editor.Components.addType('button', {
model: {
defaults: {
traits: [
{
type: 'integer',
name: 'width',
label: 'Width',
changeProp: true,
},
{
type: 'integer',
name: 'height',
label: 'Height',
changeProp: true,
},
],
},
},
});
</script>
</body>
</html>