Реализовано открытие и закрытие вкладок на нажатие трех полосок, добавлена вкладка структуры страницы с возможностью вставки плагинов, подключена библиотека MarkedJS, исправлены баги, управление центральными блоками через CDATA.
This commit is contained in:
@@ -32,6 +32,7 @@ window.touchY = 0;
|
||||
* @return Promise Разрешается после загрузки всех скриптов плагина
|
||||
*/
|
||||
function includePlugin(plugin) {
|
||||
console.log(plugin)
|
||||
return jsonrpcRequest("includePlugin", { plugin })
|
||||
.then(html => {
|
||||
const div = document.createElement('div');
|
||||
@@ -737,39 +738,82 @@ let cou=1;
|
||||
/**
|
||||
* @brief Показать/скрыть HTML-код страницы в textarea
|
||||
*/
|
||||
function showHtmlCode() {
|
||||
let contents = document.getElementsByClassName("content");
|
||||
if (cou==1) {
|
||||
let combined = "";
|
||||
for (let i=0; i<contents.length; i++) combined += "<![CDATA[" + contents[i].innerHTML + "]]>";
|
||||
document.getElementById("tex").value = combined;
|
||||
document.getElementById("tex").value = decodeHtmlEntities(document.getElementById("tex").value);
|
||||
document.getElementById("tex").value = formatHTML(document.getElementById("tex").value);
|
||||
let sbe=document.getElementsByClassName("sb");
|
||||
for(let i=0; i<sbe.length; i++) {
|
||||
if (sbe[i] != document.getElementById("tex"))
|
||||
sbe[i].style.visibility="hidden";
|
||||
}
|
||||
if (document.getElementById("tex").style.visibility=="hidden") {
|
||||
document.getElementById("tex").style.visibility="visible";
|
||||
} else {
|
||||
document.getElementById("tex").style.visibility="hidden";
|
||||
}
|
||||
cou=2;
|
||||
} else {
|
||||
let text = document.getElementById("tex").value;
|
||||
let split = text.match(/<!\[CDATA\[(.*?)\]\]>/gs);
|
||||
if (split) {
|
||||
for (let i=0; i<contents.length; i++) {
|
||||
if (split[i]) contents[i].innerHTML = split[i].replace(/<!\[CDATA\[|\]\]>/g, '');
|
||||
}
|
||||
}
|
||||
document.getElementById("tex").style.visibility="hidden";
|
||||
cou=1;
|
||||
}
|
||||
let lastType = 'html';
|
||||
function showCode(type) {
|
||||
let contents = document.getElementsByClassName("content");
|
||||
let tex = document.getElementById("tex");
|
||||
if (cou == 1) {
|
||||
let combined = "";
|
||||
for (let i = 0; i < contents.length; i++) {
|
||||
combined += "<![CDATA[" + contents[i].innerHTML + "]]>";
|
||||
}
|
||||
tex.value = combined;
|
||||
tex.value = decodeHtmlEntities(tex.value);
|
||||
if (type === 'html') {
|
||||
tex.value = formatHTML(tex.value);
|
||||
} else if (type === 'marked') {
|
||||
tex.value = marked.parse(tex.value);
|
||||
}
|
||||
let sbe = document.getElementsByClassName("sb");
|
||||
for (let i = 0; i < sbe.length; i++) {
|
||||
if (sbe[i] != tex) sbe[i].style.visibility = "hidden";
|
||||
}
|
||||
tex.style.visibility = tex.style.visibility == "hidden" ? "visible" : "hidden";
|
||||
lastType = type;
|
||||
cou = 2;
|
||||
} else {
|
||||
let text = tex.value;
|
||||
let split = text.match(/<!\[CDATA\[(.*?)\]\]>/gs);
|
||||
const centerFloat = document.querySelector('.center-float');
|
||||
if (!centerFloat) return;
|
||||
let need = split ? split.length : 1;
|
||||
let floats = centerFloat.getElementsByClassName('bfloat');
|
||||
while (floats.length < need) {
|
||||
let bf = document.createElement('div');
|
||||
bf.className = 'bfloat';
|
||||
if (floats.length > 0) bf.style.borderRadius = "10px";
|
||||
let c = document.createElement('div');
|
||||
c.className = 'content';
|
||||
c.contentEditable = 'true';
|
||||
centerFloat.appendChild(bf);
|
||||
bf.appendChild(c);
|
||||
centerFloat.appendChild(document.createElement('br'));
|
||||
floats = centerFloat.getElementsByClassName('bfloat');
|
||||
}
|
||||
while (floats.length > need) {
|
||||
let next = floats[floats.length - 1].nextSibling;
|
||||
if (next && next.tagName === 'BR') centerFloat.removeChild(next);
|
||||
centerFloat.removeChild(floats[floats.length - 1]);
|
||||
floats = centerFloat.getElementsByClassName('bfloat');
|
||||
}
|
||||
contents = centerFloat.getElementsByClassName("content");
|
||||
if (split) {
|
||||
for (let i = 0; i < need; i++) {
|
||||
let val = split[i] ? split[i].replace(/<!\[CDATA\[|\]\]>/g, '') : '';
|
||||
if (lastType === 'marked') val = '<div>' + marked.parse(val.replace(/^\s*<div[^>]*>|<\/div>\s*$/g, '')) + '</div>';
|
||||
contents[i].innerHTML = val;
|
||||
}
|
||||
} else {
|
||||
let val = text;
|
||||
if (lastType === 'marked') val = '<div>' + marked.parse(val.replace(/^\s*<div[^>]*>|<\/div>\s*$/g, '')) + '</div>';
|
||||
contents[0].innerHTML = val;
|
||||
}
|
||||
let children = Array.from(centerFloat.children);
|
||||
for (let i = 0; i < children.length - 1; i++) {
|
||||
let current = children[i];
|
||||
let next = children[i + 1];
|
||||
if (current.id !== 'mainTitle' && current.classList.contains('bfloat')) {
|
||||
if (!(next && next.tagName === 'BR')) {
|
||||
let br = document.createElement('br');
|
||||
centerFloat.insertBefore(br, next);
|
||||
}
|
||||
}
|
||||
}
|
||||
tex.style.visibility = "hidden";
|
||||
cou = 1;
|
||||
}
|
||||
}
|
||||
|
||||
window.showHtmlCode = showHtmlCode;
|
||||
window.showCode = showCode;
|
||||
|
||||
/** @brief Флаг нового состояния страницы при сохранении */
|
||||
window.newPageFunValue = "";
|
||||
@@ -1348,8 +1392,10 @@ function getPage(newPath) {
|
||||
centerFloat.insertBefore(br, placeholder);
|
||||
}
|
||||
const block = document.createElement('div');
|
||||
block.className = 'bfloat' + (i === 0 ? ' content1' : '');
|
||||
block.className = 'bfloat';
|
||||
block.style.fontSize = '1em';
|
||||
if (i !== 0) block.style.borderRadius = '10px';
|
||||
|
||||
const inner = document.createElement('div');
|
||||
inner.className = 'content';
|
||||
inner.innerHTML = c;
|
||||
|
||||
@@ -2,18 +2,20 @@
|
||||
<site>
|
||||
<sitename>site</sitename>
|
||||
<slogan>site</slogan>
|
||||
<index url="content/index" title="Новый ф6нрцуеыке" name="index" template="start" PageMenu="0,0" users="" group="" news="" plugins="">
|
||||
<page1 url="content/rpi/index" title="Новый файл" name="page1" template="MedWait" PageMenu="0,1,2" users="" group="" news="" plugins="dgrm,SvgEditorM,form_editor">
|
||||
<underpage1 url="content/rpi/index" title="Загловок" name="underpage1" template="rpi" PageMenu="0,1,2" users="" group="" news="" plugins="">
|
||||
<index url="content/index" title="Новый ф6нрцуеыке" name="index" template="start" PageMenu="0,0" users="" group="" news="">
|
||||
<page1 url="content/rpi/index" title="Новый файл" name="page1" template="MedWait" PageMenu="0,1,2" users="" group="" news="">
|
||||
<underpage1 url="content/rpi/index" title="Загловок" name="underpage1" template="rpi" PageMenu="0,1,2" users="" group="" news="">
|
||||
</underpage1>
|
||||
<underpage2 url="content/rpi/index" title="Загловок" name="underpage2" template="rpi" PageMenu="0,1,2" users="" group="" news="" plugins="SvgEditorM">
|
||||
<underpage2 url="content/rpi/index" title="Загловок" name="underpage2" template="rpi" PageMenu="0,1,2" users="" group="" news="">
|
||||
</underpage2>
|
||||
<createSite url="data/createSite" title="Страница создание нового сайта" name="createSite" template="MedWait" PageMenu="0,1,2" users="" group="" news="" plugins="dgrm">
|
||||
<createSite url="data/createSite" title="Страница создание нового сайта" name="createSite" template="MedWait" PageMenu="0,1,2" users="" group="" news="">
|
||||
</createSite>
|
||||
</page1>
|
||||
<page2 url="content/index" title="Загловок" name="page2" template="rpi" PageMenu="0,1,2" users="" group="" news="" plugins="dgrm,SvgEditorM">
|
||||
<page2 url="content/index" title="Загловок" name="page2" template="rpi" PageMenu="0,1,2" users="" group="" news="">
|
||||
</page2>
|
||||
<uyr url="content/index" title="Новый syu6e5" name="uyr" template="MedWait" PageMenu="0,1,2" users="" group="" news="" plugins="">
|
||||
<uyr url="content/index" title="Новый syu6e5" name="uyr" template="MedWait" PageMenu="0,1,2" users="" group="" news="">
|
||||
</uyr>
|
||||
<markdownMarkedJS url="content/markdownMarkedJS" title="markdownMarkedJS" name="markdownMarkedJS" template="MedWait" PageMenu="0,1,2" users="" group="" news="">
|
||||
</markdownMarkedJS>
|
||||
</index>
|
||||
</site>
|
||||
|
||||
@@ -708,7 +708,6 @@ if (!isset($xmlstr->index)) {
|
||||
$index->addAttribute('users', '');
|
||||
$index->addAttribute('group', '');
|
||||
$index->addAttribute('news', '');
|
||||
$index->addAttribute('plugins', '');
|
||||
$xmlstr->asXML($FPfile);
|
||||
}
|
||||
$ansv['sitename'] =$xmlstr->sitename;
|
||||
@@ -735,7 +734,6 @@ if ($RURLstr!='error'){
|
||||
$ansv['template'] = $xmlstr->{$RURLstr[$i]}['template'];
|
||||
$ansv['title'] = $xmlstr->{$RURLstr[$i]}['title'];
|
||||
$ansv['page'] = $xmlstr->{$RURLstr[$i]};
|
||||
$ansv['page_plugins'] = (string)($xmlstr->{$RURLstr[$i]}['plugins'] ?? '');
|
||||
}
|
||||
$xmlstr = $xmlstr->{$RURLstr[$i]};
|
||||
}
|
||||
@@ -755,7 +753,7 @@ if ($RURLstr!='error'){
|
||||
* @param mixed $RURLstr Массив сегментов URL или строка 'error'
|
||||
* @return array Массив с информацией о странице, включая URL, шаблон, заголовок и плагины
|
||||
*/
|
||||
function loadPluginsInCenterBlock() {
|
||||
/* function loadPluginsInCenterBlock() {
|
||||
global $_SESSION, $path, $config;
|
||||
if ($_SESSION['Login'] == 'true') {
|
||||
$availablePlugins = ['dgrm', 'SvgEditorM', 'form_editor'];
|
||||
@@ -774,5 +772,5 @@ function loadPluginsInCenterBlock() {
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
} */
|
||||
?>
|
||||
Reference in New Issue
Block a user