Реализовано открытие и закрытие вкладок на нажатие трех полосок, добавлена вкладка структуры страницы с возможностью вставки плагинов, подключена библиотека MarkedJS, исправлены баги, управление центральными блоками через CDATA.
This commit is contained in:
@@ -246,6 +246,9 @@
|
||||
#toolbar-group-button-paste {
|
||||
background-position: 166px 517px;
|
||||
}
|
||||
#toolbar-group-button-structure {
|
||||
background-position: 166px 517px;
|
||||
}
|
||||
|
||||
.align-dropdown, .align-dropdown-oneImg {
|
||||
position: relative;
|
||||
@@ -376,6 +379,10 @@
|
||||
background-position: -318px 1824px;
|
||||
}
|
||||
|
||||
#markedBut {
|
||||
background-position: -318px 1824px;
|
||||
}
|
||||
|
||||
#bac {
|
||||
background-position: 645px 716px;
|
||||
}
|
||||
@@ -452,7 +459,7 @@
|
||||
background-position: 1045px 557px;
|
||||
}
|
||||
|
||||
/* #pluginSave {
|
||||
#pluginSave {
|
||||
background-position: -479px 1665px;
|
||||
}
|
||||
#pluginCreateLeft {
|
||||
@@ -467,12 +474,15 @@
|
||||
#pluginAddRight {
|
||||
background-position: -638px 1665px;
|
||||
}
|
||||
#pluginAddCenter {
|
||||
background-position: -838px 1665px;
|
||||
}
|
||||
#pluginDelete {
|
||||
background-position: -518px 1665px;
|
||||
}
|
||||
#pluginMove {
|
||||
background-position: -438px 1665px;
|
||||
} */
|
||||
}
|
||||
|
||||
#contentPageCreate {
|
||||
background-position: 926px 676px;
|
||||
|
||||
@@ -415,7 +415,7 @@ function clo(c) // Функция закры
|
||||
}
|
||||
|
||||
// действия блока плагинов
|
||||
let pluginDropdownContentId = document.getElementById("pluginDropdownContent");
|
||||
/* let pluginDropdownContentId = document.getElementById("pluginDropdownContent");
|
||||
pluginDropdownContentId.addEventListener('click', function () {
|
||||
let targetElement = document.getElementById(this.value);
|
||||
if (targetElement) {
|
||||
@@ -436,7 +436,7 @@ pluginDropdownContentId.addEventListener('click', function () {
|
||||
if (editMode == -1) {
|
||||
pluginDropdownContentId.style.backgroundColor = '';
|
||||
}
|
||||
});
|
||||
}); */
|
||||
|
||||
// действия блока элементов
|
||||
/* let elementDropdownContentId = document.getElementById("elementDropdownContent");
|
||||
@@ -455,7 +455,7 @@ mainActionsId.addEventListener('click', function () {
|
||||
switch (this.value) {
|
||||
case "save":
|
||||
saveChanges();
|
||||
break;
|
||||
break;fshowHtmlCode
|
||||
case "saveHow":
|
||||
saveChangesHow();
|
||||
break;
|
||||
@@ -564,13 +564,83 @@ function restoreSelection() {
|
||||
sel.addRange(range);
|
||||
}
|
||||
|
||||
/* плагины для центра */
|
||||
document.getElementById('pluginAddCenter').onclick = function pluginFunCenter() {
|
||||
jsonrpcRequest('getPluginBlocks', {})
|
||||
.then(folders => {
|
||||
const pluginAddSideName = document.getElementById('pluginAddCenterName');
|
||||
pluginAddSideName.innerHTML = '';
|
||||
folders.forEach(folder => {
|
||||
const option = document.createElement('option');
|
||||
option.value = folder;
|
||||
option.textContent = folder;
|
||||
pluginAddSideName.appendChild(option);
|
||||
});
|
||||
});
|
||||
};
|
||||
document.getElementById('pluginAddCenterFun_d').addEventListener('click', function() {
|
||||
const select = document.getElementById('pluginAddCenterName');
|
||||
const pluginName = select.value;
|
||||
if (!pluginName) return;
|
||||
if (document.querySelector('.' + pluginName)) return;
|
||||
|
||||
includePluginBlock(pluginName).then(fragment => {
|
||||
const centerFloat = document.querySelector('.center-float');
|
||||
if (!centerFloat) return;
|
||||
|
||||
const wrapper = document.createElement('div');
|
||||
wrapper.setAttribute('pluginblock', pluginName);
|
||||
wrapper.appendChild(document.createElement('br'));
|
||||
|
||||
const scripts = [];
|
||||
Array.from(fragment.childNodes).forEach(node => {
|
||||
if (node.tagName === 'SCRIPT') {
|
||||
const s = document.createElement('script');
|
||||
if (node.src) {
|
||||
s.src = node.src;
|
||||
s.async = false;
|
||||
scripts.push(new Promise(res => s.onload = res));
|
||||
} else {
|
||||
s.textContent = node.textContent;
|
||||
}
|
||||
document.body.appendChild(s);
|
||||
} else {
|
||||
wrapper.appendChild(node);
|
||||
}
|
||||
});
|
||||
|
||||
centerFloat.appendChild(wrapper);
|
||||
|
||||
Promise.all(scripts).then(() => {
|
||||
const event = new Event("Load" + pluginName + "Js");
|
||||
document.dispatchEvent(event);
|
||||
window.dispatchEvent(event);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Пример изменения includePlugin
|
||||
function includePluginBlock(plugin) {
|
||||
return jsonrpcRequest("includePlugin", { plugin })
|
||||
.then(html => {
|
||||
const frag = document.createDocumentFragment();
|
||||
const temp = document.createElement('div');
|
||||
temp.innerHTML = html;
|
||||
|
||||
Array.from(temp.childNodes).forEach(node => {
|
||||
if (node.nodeType === 1) node.setAttribute('plugin', plugin);
|
||||
frag.appendChild(node);
|
||||
});
|
||||
|
||||
return frag;
|
||||
});
|
||||
}
|
||||
|
||||
// Взаимодействие с плагинами
|
||||
/* document.getElementById('pluginCreateLeft').onclick = function() { pluginFun('create', 'left'); };
|
||||
document.getElementById('pluginCreateRight').onclick = function() { pluginFun('create', 'right'); }; */
|
||||
document.getElementById('pluginAddLeft').onclick = function() { pluginFun('add', 'left'); };
|
||||
document.getElementById('pluginAddRight').onclick = function() { pluginFun('add', 'right'); };
|
||||
|
||||
|
||||
/* document.getElementById('pluginRulesButton1').onclick = function() { pluginRulesFun('pluginRulesBlock1'); };
|
||||
document.getElementById('pluginRulesButton2').onclick = function() { pluginRulesFun('pluginRulesBlock2'); }; */
|
||||
|
||||
@@ -740,7 +810,7 @@ function editFun3(i) {
|
||||
function editFun4(i) {
|
||||
}
|
||||
function editFun5(i) {
|
||||
pluginDropdownContentId.style.backgroundColor = '';
|
||||
/* pluginDropdownContentId.style.backgroundColor = ''; */
|
||||
}
|
||||
|
||||
let pluginTakeCheck = 0;
|
||||
@@ -2211,19 +2281,22 @@ addEventListener("LoadeditorJs", function()
|
||||
document.querySelectorAll("#panel .toolbar-group").forEach(g => {
|
||||
const btn = g.querySelector(".toolbar-group-button");
|
||||
const content = g.querySelector(".toolbar-group-content");
|
||||
|
||||
const toggle = () => {
|
||||
const isHidden = content.style.display === "none";
|
||||
content.style.display = isHidden ? "" : "none";
|
||||
const hidden = content.style.display === "none";
|
||||
g.classList.toggle("open", !hidden);
|
||||
};
|
||||
if (btn && content) {
|
||||
btn.addEventListener("click", () => {
|
||||
const isHidden = content.style.display === "none";
|
||||
content.style.display = isHidden ? "" : "none";
|
||||
if (btn && content) {
|
||||
const isHidden = content.style.display === "none";
|
||||
g.classList.toggle("open", !isHidden);
|
||||
}
|
||||
btn.addEventListener("click", e => {
|
||||
toggle();
|
||||
});
|
||||
if (btn && content) {
|
||||
const isHidden = content.style.display === "none";
|
||||
g.classList.toggle("open", !isHidden);
|
||||
}
|
||||
g.addEventListener("click", e => {
|
||||
if (e.target === g) toggle();
|
||||
});
|
||||
const isHidden = content.style.display === "none";
|
||||
g.classList.toggle("open", !isHidden);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -156,6 +156,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php /** @brief Список выбора плагина в ентре */ $pluginAddCenter_d; ?>
|
||||
<div id="pluginAddCenter_d" class="cust sb borderStyle">
|
||||
<div class="deploy">
|
||||
{{add_plugin_center}}:<br>
|
||||
<label for="pluginAddCenterName">{{select_plugin}}</label>
|
||||
<select id="pluginAddCenterName" class="sele"></select>
|
||||
<button id="pluginAddCenterFun_d" class="butin">{{select}}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php /** @brief Редактирование меню страницы */ $contentPageCreate_d; ?>
|
||||
<div id="contentPageCreate_d" class="cust sb borderStyle">
|
||||
<div class="deploy">
|
||||
@@ -201,7 +211,8 @@
|
||||
<span class="toolbar-group-content">
|
||||
|
||||
<div id="settingsMain" class="editi editib swit"></div>
|
||||
<div id="htm" onclick="showHtmlCode()" class="editi editib pers" alt="{{html_code_main_block_alt}}" title="{{html_code_main_block_title}}"></div>
|
||||
<div id="htm" onclick="showCode('html')" class="editi editib pers" alt="{{html_code_main_block_alt}}" title="{{html_code_main_block_title}}"></div>
|
||||
<!-- <div id="markedBut" onclick="showCode('marked')" class="editi editib pers" alt="{{marked_code_main_block_alt}}" title="{{marked_code_main_block_title}}"></div> -->
|
||||
<div id="bac" class="editi editib pers" alt="{{undo_action_alt}}" title="{{undo_action_title}}"></div>
|
||||
<div id="forw" class="editi editib pers" alt="{{redo_action_alt}}" title="{{redo_action_title}}"></div>
|
||||
|
||||
@@ -283,16 +294,21 @@
|
||||
<div id="hr" class="editi editib pers editf"></div>
|
||||
<div id="tabl" class="editi editib pers editf"></div>
|
||||
<div id="copyr" class="editi editib swit"></div>
|
||||
|
||||
<select id="pluginDropdownContent" class="edits pers3">
|
||||
<option id="pluginAddLeft" value="pluginAddLeft" class="swit">{{add_plugin_left}}</option>
|
||||
<option id="pluginAddRight" value="pluginAddRight" class="swit">{{add_plugin_right}}</option>
|
||||
<option id="pluginDelete" value="pluginDelete" class="editfText">{{delete_plugin}}</option>
|
||||
<option id="pluginMove" value="pluginMove" class="editfText">{{move_plugin}}</option>
|
||||
</select>
|
||||
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="toolbar-group">
|
||||
<span id="toolbar-group-button-structure" class="editi editib pers toolbar-group-button"></span>
|
||||
<span class="toolbar-group-content">
|
||||
|
||||
<div id="pluginAddLeft" class="editi editib swit editf"></div>
|
||||
<div id="pluginAddRight" class="editi editib swit editf"></div>
|
||||
<div id="pluginAddCenter" class="editi editib swit editf"></div>
|
||||
<div id="pluginDelete" class="editi editib pers editf"></div>
|
||||
<div id="pluginMove" class="editi editib pers editf"></div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</div><div id="arrow-right" class="arrow borderStyle">⊳</div></div>
|
||||
|
||||
<!-- текстовый редактор -->
|
||||
|
||||
@@ -11,23 +11,20 @@
|
||||
* @throws Exception В случае проблем с сохранением контента
|
||||
*/
|
||||
function savePageCenterBlock($params) {
|
||||
global $config, $path, $_SESSION;
|
||||
global $config, $path, $_SESSION;
|
||||
|
||||
$saveContentIdXml = $path . $_SESSION['page_url'] . ".page.php";
|
||||
$saveContentIdData = $params['saveContentIdData'] ?? '';
|
||||
$saveContentIdData = html_entity_decode($params['saveContentIdData'] ?? '', ENT_QUOTES, 'UTF-8');
|
||||
|
||||
$xml = file_get_contents($saveContentIdXml);
|
||||
|
||||
$xml = file_get_contents($saveContentIdXml);
|
||||
$xml = preg_replace('#<' . $_SESSION['lng'] . '>.*?</' . $_SESSION['lng'] . '>#s', '<' . $_SESSION['lng'] . '></' . $_SESSION['lng'] . '>', $xml);
|
||||
$xml = preg_replace('#(<' . $_SESSION['lng'] . '>)#', "$1\n" . $saveContentIdData . "\n", $xml, 1);
|
||||
|
||||
if (preg_match('#<' . $_SESSION['lng'] . '>#', $xml, $pos)) {
|
||||
$xml = preg_replace('#(<' . $_SESSION['lng'] . '>)#', '$1' . "\n" . $saveContentIdData . "\n", $xml, 1);
|
||||
}
|
||||
|
||||
if (file_put_contents($saveContentIdXml, $xml) !== false) return 'true';
|
||||
throw new Exception("Problem saving content", -32003);
|
||||
if (file_put_contents($saveContentIdXml, $xml) !== false) return 'true';
|
||||
throw new Exception("Problem saving content", -32003);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Сохраняет левый и правый блоки страницы
|
||||
* @param array $params Массив с данными блоков, ключ 'floatsBlock' содержит массив левых и правых блоков
|
||||
@@ -255,6 +252,20 @@ function getPlugin($params) {
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает список доступных плагинов в виде JSON
|
||||
* @param array $params Входные параметры запроса (не используются)
|
||||
* @return string JSON-массив с названиями плагинов
|
||||
* @throws Exception Если глобальная переменная $pluginBlocks не определена или пуста
|
||||
*/
|
||||
function getPluginBlocks($params) {
|
||||
global $pluginBlocks;
|
||||
if (!isset($pluginBlocks) || !is_array($pluginBlocks) || empty($pluginBlocks)) {
|
||||
throw new Exception("Нет доступных плагинов", -1);
|
||||
}
|
||||
return $pluginBlocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Загружает изображение пользователя из Base64 и сохраняет на сервер
|
||||
* @param array $params Массив с данными изображения, включая 'userImgBase64' и 'userImgName'
|
||||
|
||||
Reference in New Issue
Block a user