|
<!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> |
|
|
|
<link rel="stylesheet" href="https://unpkg.com/grapesjs/dist/css/grapes.min.css"> |
|
</head> |
|
<body> |
|
<div id="gjs"></div> |
|
|
|
|
|
<script src="https://unpkg.com/grapesjs"></script> |
|
|
|
<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', |
|
}, |
|
], |
|
}, |
|
|
|
], |
|
}, |
|
}); |
|
|
|
|
|
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>`, |
|
}); |
|
|
|
|
|
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> |