forked from GrapesJS/grapesjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
136 additions
and
59 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<template> | ||
<div> | ||
<div id="basic-panel3"></div> | ||
<div id="gjs3"> | ||
<h1>Hello World Component!</h1> | ||
</div> | ||
<div id="blocks3"></div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
module.exports = { | ||
mounted() { | ||
// show addPanel with toggle-borders, export-code and custom alert show selected JSON + panel style | ||
const utils = require('./demos/utils.js'); | ||
const editor3 = grapesjs.init(utils.gjsConfigPanels); | ||
editor3.Panels.addPanel({ | ||
id: 'custom-panel', | ||
el: '#basic-panel3', | ||
buttons: [ | ||
{ | ||
id: 'visibility', | ||
// active by default | ||
active: true, | ||
className: 'btn-toggle-borders', | ||
label: '<u>B</u>', | ||
// Built-in command | ||
command: 'sw-visibility', | ||
}, { | ||
id: 'export', | ||
className: 'btn-open-export', | ||
label: 'Exp', | ||
command: 'export-template', | ||
// For grouping context of buttons in the same panel | ||
context: 'export-template', | ||
} | ||
], | ||
}); | ||
window.editor3 = editor3; | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
#gjs3 { | ||
border: 3px solid #444; | ||
} | ||
#basic-panel3 { | ||
width: 100%; | ||
display: flex; | ||
justify-content: center; | ||
position: initial; | ||
} | ||
.content pre { | ||
padding-top: 0; | ||
padding-bottom: 0; | ||
margin-top: 0; | ||
margin-bottom: 0; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,61 @@ | ||
// Don't know yet why but can't use ES6 | ||
|
||
var blockManager = { | ||
appendTo: '#blocks2', | ||
blocks: [ | ||
{ | ||
id: 'section', // id is mandatory | ||
label: '<b>Section</b>', | ||
attributes: { class:'gjs-block-section' }, | ||
content: `<section> | ||
<h1>This is a simple title</h1> | ||
<div>This is just a Lorem text: Lorem ipsum dolor sit amet, consectetur adipiscing elit</div> | ||
</section>`, | ||
}, { | ||
id: 'text', | ||
label: 'Text', | ||
content: '<div data-gjs-type="text">Insert your text here</div>', | ||
}, { | ||
id: 'image', | ||
label: 'Image', | ||
// Select the component once dropped in canavas | ||
select: true, | ||
// You can pass components as a JSON instead of a simple HTML string, | ||
// in this case we also use a defined component type `image` | ||
content: { type: 'image' }, | ||
// This triggers `active` on dropped components | ||
activate: true, | ||
} | ||
] | ||
}; | ||
|
||
var gjsConfigStart = { | ||
// Indicate where to init the editor. It's also possible to pass an HTMLElement | ||
container: '#gjs', | ||
// Get the content for the canvas direectly from the element | ||
// As an alternative we could use: `components: '<h1>Hello World Component!</h1>'`, | ||
fromElement: true, | ||
// Size of the editor | ||
height: '300px', | ||
width: 'auto', | ||
// Disable the storage manager for the moment | ||
storageManager: { type: null }, | ||
// Avoid any default panel | ||
panels: { defaults: [] }, | ||
}; | ||
|
||
var gjsConfigBlocks = Object.assign({}, gjsConfigStart, { | ||
container: '#gjs2', | ||
blockManager, | ||
}); | ||
|
||
var gjsConfigPanels = Object.assign({}, gjsConfigBlocks, { | ||
container: '#gjs3', | ||
blockManager: Object.assign({}, blockManager, { appendTo: '#blocks3' }), | ||
}); | ||
|
||
module.exports = { | ||
gjsConfig: { | ||
// Indicate where to init the editor. It's also possible to pass an HTMLElement | ||
container: '#gjs', | ||
// Get the content for the canvas direectly from the element | ||
// As an alternative we could use: `components: '<h1>Hello World Component!</h1>'`, | ||
fromElement: true, | ||
// Size of the editor | ||
height: '300px', | ||
width: 'auto', | ||
// Disable the storage manager for the moment | ||
storageManager: { type: null }, | ||
// Avoid any default panel | ||
panels: { defaults: [] }, | ||
}, | ||
gjsConfigStart, | ||
gjsConfigBlocks, | ||
gjsConfigPanels, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters