Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.gitignore export-ignore
.gitattributes export-ignore
README.md export-ignore
index.js export-ignore
package.json export-ignore
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
!/assets/tvs
/assets/tvs/*
!/assets/tvs/pagebuilder
!/index.js
!/package.json
31 changes: 18 additions & 13 deletions assets/plugins/pagebuilder/js/interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@
switch (conf[field].type) {
case 'richtext': {
var f = $field.children('textarea').get(0);

if (typeof tinymce != 'undefined' && f.id && tinymce.editors[f.id]) {
values[field] = tinymce.editors[f.id].getContent();
// Получение нужного редактора. tinymce.get() - работает на всех редакторах
if (typeof tinymce != 'undefined' && f.id && tinymce.get(`${f.id}`)) {
values[field] = tinymce.get(`${f.id}`).getContent();
} else {
values[field] = $(f).val();
}
Expand Down Expand Up @@ -377,8 +377,8 @@
var $rich = $block.find('textarea.richtext');

$rich.each(function() {
if (typeof tinymce != 'undefined' && this.id && tinymce.editors[this.id]) {
tinymce.editors[this.id].destroy();
if (typeof tinymce != 'undefined' && this.id && tinymce.get(`${this.id}`)) {
tinymce.get(`${this.id}`).destroy();
}
});

Expand Down Expand Up @@ -495,15 +495,15 @@
handle: '> .handle',
start: function(e, ui) {
ui.item.find('textarea.richtext').each(function() {
if (typeof tinymce != 'undefined' && this.id && tinymce.editors[this.id]) {
tinymce.editors[this.id].save();
if (typeof tinymce != 'undefined' && this.id && tinymce.get(`${this.id}`)) {
tinymce.get(`${this.id}`).save();
}
});
},
stop: function(e, ui) {
ui.item.find('textarea.richtext').each(function() {
if (typeof tinymce != 'undefined' && this.id && tinymce.editors[this.id]) {
tinymce.editors[this.id].destroy();
if (typeof tinymce != 'undefined' && this.id && tinymce.get(`${this.id}`)) {
tinymce.get(`${this.id}`).destroy();
}
ContentBlock.initializeRichField($(this));
});
Expand All @@ -524,9 +524,8 @@
$textarea.get(0).id = 'rich' + ContentBlock.randomString();

if (typeof tinymce !== 'undefined') {
var conf = theme != undefined ? window['config_tinymce4_' + theme] : window[ modxRTEbridge_tinymce4.default ];
var conf = theme != undefined ? window[`config_${opts.editor}_` + theme] : window[ window[`modxRTEbridge_${opts.editor}`].default ];
conf = $.extend({}, conf, options ? options : {});

conf.selector = '#' + $textarea.attr('id');
tinymce.init(conf);
}
Expand All @@ -537,7 +536,13 @@
margin = parseInt(wnd.innerHeight * 0.1),
width = wnd.innerWidth - margin * 2,
height = wnd.innerHeight - margin * 2,
params = 'toolbar=no,status=no,resizable=yes,dependent=yes,width=' + width + ',height=' + height + ',left=' + margin + ',top=' + (margin + (wnd._startY ? wnd._startY * 0.5 : 0));
params = 'toolbar=no,status=no,resizable=yes,dependent=yes,width=' + width + ',height=' + height + ',left=' + margin + ',top=' + (margin + (wnd._startY ? wnd._startY * 0.5 : 0)),
path = String($element.val()).replace(/assets\//g, "").replace(/^(.+?\/)((\.\.\/)?[^\/]+)$/, '$1'),
dir = "";

if(path!=""){
dir += "&dir="+path;
}

if (window.SetUrl) {
window.SetUrl_disabled = window.SetUrl;
Expand Down Expand Up @@ -575,7 +580,7 @@
};
}

window.open(opts.browser + '?type=' + type + '&field_id=' + $element[0].id + '&popup=1&relative_url=1', 'FileManager', params);
window.open(opts.browser + '?type=' + type + '&popup=1&relative_url=1&field_id=' + $element[0].id + dir, 'FileManager', params);
},

groupUpdated: function($list) {
Expand Down
4 changes: 3 additions & 1 deletion assets/plugins/pagebuilder/pagebuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ public function renderForm()
'blocks' => $this->data,
'adminlang' => $_lang,
'thumbsDir' => $this->modx->getConfig('thumbsDir'),
'editor' => $this->richeditor,
'picker' => [
'yearOffset' => $this->modx->getConfig('datepicker_offset'),
'format' => $this->modx->getConfig('datetime_format') . ' hh:mm:00',
Expand Down Expand Up @@ -810,7 +811,8 @@ public function renderField($field, $name, $value)

case 'richtext': {
$params['layout'] = $field['layout'] ?? 'col-12';
if (isset($field['theme']) && !isset($this->themes[ $field['theme'] ]) && in_array($this->richeditor, [ 'TinyMCE4' ])) {
// Проверяем, чтобы richeditor не был равен none
if (isset($field['theme']) && !isset($this->themes[ $field['theme'] ]) && $this->richeditor != "none") {
$result = $this->modx->invokeEvent('OnRichTextEditorInit', [
'editor' => $this->richeditor,
'options' => [ 'theme' => $field['theme'] ],
Expand Down
1 change: 1 addition & 0 deletions assets/plugins/pagebuilder/tpl/form.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
lang: <?= !empty($l) ? json_encode( $l, JSON_UNESCAPED_UNICODE ) : "{}" ?>,
browser: "<?= $browseurl ?>",
thumbsDir: "<?= $thumbsDir ?>",
editor: "<?= strtolower($editor) ?>",
picker: {
yearOffset: <?= $picker['yearOffset'] ?>,
format: '<?= $picker['format'] ?>',
Expand Down
17 changes: 17 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const zl = require("zip-lib"),
fs = require("node:fs");

if(fs.existsSync(`pagebuilder.zip`)) {
console.log(`Delete file pagebuilder.zip`);
fs.unlinkSync(`pagebuilder.zip`);
}

const zip = new zl.Zip(),
folders = [`assets`, `install`, `manager`];

for(var value of folders){
zip.addFolder(`${value}`, `pagebuilder/${value}`);
}

zip.archive(`pagebuilder.zip`);
console.log(`Archive pagebuilder.zip`);
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "pagebuilder",
"version": "1.0.0",
"description": "Page Builder for Evolution CMS",
"homepage": "https://github.com/evocms-community/pagebuilder#readme",
"bugs": {
"url": "https://github.com/evocms-community/pagebuilder/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/evocms-community/pagebuilder.git"
},
"license": "GPL-3.0",
"author": "mnoskov",
"type": "commonjs",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"inst": "npm i",
"build": "node index.js"
},
"dependencies": {
"zip-lib": "^1.4.0"
},
"devDependencies": {}
}