Started adding grapesJS to assistant area for the site view builder.

This commit is contained in:
2020-02-12 16:27:32 +02:00
parent 4664d89d0e
commit a6cdafb31f
17 changed files with 82 additions and 17 deletions

View File

@ -21,6 +21,8 @@ defined('_JEXEC') or die('Restricted access');
</div>
<script type="text/javascript">
var active_view = 'view0';
var active_editors = {};
var last_editors = {};
var created_fields = {};
jQuery(document).on('subform-row-add', function(event, row){
setFieldNames();
@ -33,8 +35,26 @@ function setJCBuilder(area, view, target){
if (target == 2){
setFieldNames();
setListViewFieldOptions();
} else if (target == 3 && !active_editors.hasOwnProperty(view)) {
// update the editor (let grape js know)
initializeGrapesjs();
}
}
function initializeGrapesjs(){
active_editors[active_view] = grapesjs.init({
// Indicate where to init the editor. You can also pass an HTMLElement
container: '#gjs-'+active_view,
// Get the content for the canvas directly from the element
fromElement: true,
// Size of the editor
height: '500px',
width: 'auto',
// Default configurations
storageManager: { autoload: 1 },
// basic block manager
plugins: ['gjs-preset-webpage'],
});
}
function setListViewFieldOptions(){
// build fields
if (created_fields.hasOwnProperty(active_view)){

View File

@ -562,9 +562,8 @@ class ComponentbuilderViewAssistant extends JViewLegacy
$displayAttribute = array(
'type' => 'note',
'name' => 'display',
'label' => 'COM_COMPONENTBUILDER_ITEM_DISPLAY',
'description' => '
<b>More details soon, to help build the site/front display of a single item.</b>',
'label' => 'COM_COMPONENTBUILDER_SINGLE_ITEM_DISPLAY_EDITOR_OF_THE_SITE_VIEW',
'description' => '<div id="gjs-[[[VDM]]]"></div>',
'heading' => 'h5'
);
// load the subform attributes
@ -595,6 +594,12 @@ class ComponentbuilderViewAssistant extends JViewLegacy
// Initialize the header checker.
$HeaderCheck = new componentbuilderHeaderCheck;
// always load these files.
$this->document->addStyleSheet(JURI::root(true) . "/media/com_componentbuilder/grapejs/css/grapes.min.css", (ComponentbuilderHelper::jVersion()->isCompatible("3.8.0")) ? array("version" => "auto") : "text/css");
$this->document->addStyleSheet(JURI::root(true) . "/media/com_componentbuilder/grapejs/css/grapesjs-preset-webpage.min.css", (ComponentbuilderHelper::jVersion()->isCompatible("3.8.0")) ? array("version" => "auto") : "text/css");
$this->document->addScript(JURI::root(true) . "/media/com_componentbuilder/grapejs/js/grapes.min.js", (ComponentbuilderHelper::jVersion()->isCompatible("3.8.0")) ? array("version" => "auto") : "text/javascript");
$this->document->addScript(JURI::root(true) . "/media/com_componentbuilder/grapejs/js/grapesjs-preset-webpage.min.js", (ComponentbuilderHelper::jVersion()->isCompatible("3.8.0")) ? array("version" => "auto") : "text/javascript");
// Add View JavaScript File
$this->document->addScript(JURI::root(true) . "/administrator/components/com_componentbuilder/assets/js/assistant.js", (ComponentbuilderHelper::jVersion()->isCompatible("3.8.0")) ? array("version" => "auto") : "text/javascript");