started pell parsing on form import

This commit is contained in:
maru21 2023-11-11 15:52:25 +01:00
parent 461ba0e85c
commit 5eb216f395
8 changed files with 37 additions and 14 deletions

View File

@ -418,7 +418,7 @@ function buildSidebarList(obj, sidebarList) {
function buildLongTextInput(source, textarea, label) { function buildLongTextInput(source, textarea, label) {
if (activeState.settings.enablePell == "false") return; if (!activeState.settings.enablePell) return;
//hide default textarea //hide default textarea
textarea.style.display = "none"; textarea.style.display = "none";
label.style.display = "none"; label.style.display = "none";
@ -440,7 +440,7 @@ function buildLongTextInput(source, textarea, label) {
"heading2", "heading2",
{ {
name: 'ulist', name: 'ulist',
icon: 'L' icon: '<b>•</b>'
}, },
"olist" "olist"
], ],

View File

@ -129,7 +129,7 @@ function printVersion(msg = "") {
} }
function clickImportFiles() { function clickImportFiles() {
if (activeState.settings.localOnly == "true") { if (activeState.settings.localOnly) {
createBookShelfDownload(); createBookShelfDownload();
return; return;
} }

View File

@ -26,14 +26,14 @@ window.activeState = {
lastElement: "", lastElement: "",
serverFilesTs: "", serverFilesTs: "",
settings: { settings: {
localOnly: "true", localOnly: true,
lineBreak: 120, lineBreak: 120,
font: "Arial", font: "Arial",
fontSize: "10px", fontSize: "10px",
notifierPause: 1, notifierPause: 1,
persistentStorage: "false", persistentStorage: false,
enablePell: "false", enablePell: false,
debug: "false" debug: false
}, },
templates: [], templates: [],
templateObjectsPurified: [], templateObjectsPurified: [],
@ -73,6 +73,8 @@ function init() {
let settings = storeSettings("getInit", true); let settings = storeSettings("getInit", true);
if (settings != null) { if (settings != null) {
for (let setting of Object.entries(settings)) { for (let setting of Object.entries(settings)) {
if (typeof(setting[1]) == "string" && setting[1].toLowerCase() === "true") setting[1] = true;
if (typeof(setting[1]) == "string" && setting[1].toLowerCase() === "false") setting[1] = false;
activeState.settings[setting[0]] = setting[1]; activeState.settings[setting[0]] = setting[1];
} }
} }
@ -87,7 +89,7 @@ function init() {
eventListeners(); eventListeners();
//print current version and storage mode to footer //print current version and storage mode to footer
let msg = (activeState.settings.persistentStorage == "false") ? "temporary" : "persistent"; let msg = (!activeState.settings.persistentStorage) ? "temporary" : "persistent";
printVersion("storage mode: "+msg+" |"); printVersion("storage mode: "+msg+" |");
//adjust title for mobile use //adjust title for mobile use

View File

@ -102,7 +102,7 @@ function parseForm(returnDIV = false) {
bHtml = bHtml.replace(/<\/div>/g, '<br />'); bHtml = bHtml.replace(/<\/div>/g, '<br />');
bHtml = bHtml.replace(/<div>/g, ''); bHtml = bHtml.replace(/<div>/g, '');
if (activeState.settings.enablePell == "true") { if (activeState.settings.enablePell) {
bHtml = bHtml.replace(/!l /g, ""); bHtml = bHtml.replace(/!l /g, "");
bHtml = bHtml.replace(/!n /g, ""); bHtml = bHtml.replace(/!n /g, "");
bHtml = bHtml.replace(/!ls /g, ""); bHtml = bHtml.replace(/!ls /g, "");
@ -250,7 +250,7 @@ function parseForm(returnDIV = false) {
if (listFlag && listIndicator == "") listIndicator = " • "; if (listFlag && listIndicator == "") listIndicator = " • ";
//exclude settings if pell is enabled //exclude settings if pell is enabled
if (activeState.settings.enablePell == "true") listIndicator = ""; if (activeState.settings.enablePell) listIndicator = "";
//handle global linebreak and fit according to indicator according to list indicator //handle global linebreak and fit according to indicator according to list indicator

View File

@ -82,7 +82,7 @@ function setCookie(cname, cvalue, exdays) {
const d = new Date(); const d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
let expires = "expires="+d.toUTCString(); let expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/;SameSite=Lax";
} }
function getCookie(cname) { function getCookie(cname) {

View File

@ -184,7 +184,7 @@ function saveSettings() {
//transfer tF //transfer tF
if (tF != null) storeData("templateFiles", tF); if (tF != null) storeData("templateFiles", tF);
let msg = (activeState.settings.persistentStorage == "false") ? "temporary" : "persistent"; let msg = (!activeState.settings.persistentStorage) ? "temporary" : "persistent";
printVersion("storage mode: "+msg+" |"); printVersion("storage mode: "+msg+" |");
} }

View File

@ -34,7 +34,7 @@ const tempStore = {
}; };
function getStor() { function getStor() {
if (window.activeState.settings.persistentStorage == "true") { if (window.activeState.settings.persistentStorage) {
return window.localStorage; return window.localStorage;
} else { } else {
return tempStore; return tempStore;
@ -43,6 +43,7 @@ function getStor() {
function debug(mode, key, data) { function debug(mode, key, data) {
if (activeState.settings.debug == "false") return data; if (activeState.settings.debug == "false") return data;
if (activeState.settings.debug == false) return data;
console.log({ console.log({
mode: mode, mode: mode,
key: key, key: key,
@ -165,7 +166,7 @@ function getFileName() {
ts_copy: "", ts_copy: "",
ts_edit: "", ts_edit: "",
id: cyrb53(currentFileName), id: cyrb53(currentFileName),
editor: (activeState.settings.enablePell == "true") ? "pell": "textarea" editor: (activeState.settings.enablePell) ? "pell": "textarea"
}; };
if (tF.length != 0) { if (tF.length != 0) {

View File

@ -291,6 +291,7 @@ function retrieveForm(arr) {
for (let i = 0; i < arr.length; i++) { for (let i = 0; i < arr.length; i++) {
if (arr[i].name == "") continue;
let e = document.getElementById(arr[i].name); let e = document.getElementById(arr[i].name);
if (e === null) { if (e === null) {
//parse connected list //parse connected list
@ -323,9 +324,28 @@ function retrieveForm(arr) {
switch (e.nodeName) { switch (e.nodeName) {
case "TEXTAREA": case "TEXTAREA":
arr[i].value = arr[i].value.replace(/<div>/g, "");
arr[i].value = arr[i].value.replace(/<\/div>/g, "\n");
arr[i].value = arr[i].value.replace(/<.{1,4}>/g, "");
if (e.parentElement != undefined) { if (e.parentElement != undefined) {
if (e.parentElement.getElementsByClassName("pell-content")[0] != undefined) { if (e.parentElement.getElementsByClassName("pell-content")[0] != undefined) {
let contentArray = arr[i].value.split("\n");
let parsedContent = "";
if (contentArray.length != 0) {
for (let contentLine of contentArray) {
if (contentLine != "") {
contentLine = "<div>" + contentLine + "</div>";
}
parsedContent += contentLine;
}
} else {
parsedContent = arr[i].value;
}
e.innerHTML = arr[i].value; e.innerHTML = arr[i].value;
arr[i].value = parsedContent;
e = e.parentElement.getElementsByClassName("pell-content")[0]; e = e.parentElement.getElementsByClassName("pell-content")[0];
} }
} }