From 0a58816d4b7a39b24fd14daeee652a973023ed0b Mon Sep 17 00:00:00 2001 From: maru21 Date: Sun, 12 Nov 2023 16:49:21 +0100 Subject: [PATCH] fixed conversion error with pell --- js/2.0.3/buildHtmlForm.js | 10 +++++----- js/2.0.3/init.js | 8 ++++---- js/2.0.3/parseForm.js | 18 ++++++++++++++---- js/2.0.3/storage.js | 8 ++++++-- js/2.0.3/web.js | 4 ++++ 5 files changed, 33 insertions(+), 15 deletions(-) diff --git a/js/2.0.3/buildHtmlForm.js b/js/2.0.3/buildHtmlForm.js index 21bb6ca..d0564bc 100644 --- a/js/2.0.3/buildHtmlForm.js +++ b/js/2.0.3/buildHtmlForm.js @@ -438,11 +438,11 @@ function buildLongTextInput(source, textarea, label) { "paragraph", "heading1", "heading2", - { - name: 'ulist', - icon: '' - }, - "olist" + //{ + // name: 'ulist', + // icon: '' + //}, + //"olist" ], onChange: function (html) { //correct lastElement diff --git a/js/2.0.3/init.js b/js/2.0.3/init.js index 56b0fa5..71751fb 100644 --- a/js/2.0.3/init.js +++ b/js/2.0.3/init.js @@ -14,7 +14,7 @@ import setPassword, { inputRead } from "./scripts.js"; import parseForm from "./parseForm.js"; -import { createStorageObj, storeSettings } from "./storage.js"; +import { createStorageObj, retrieveData, storeSettings } from "./storage.js"; import { loadNavBar, initTextBlocks, loadNewTemplate } from "./web.js"; window.activeState = { @@ -89,7 +89,7 @@ function init() { eventListeners(); //print current version and storage mode to footer - let msg = (!activeState.settings.persistentStorage) ? "temporary" : "persistent"; + let msg = (activeState.settings.persistentStorage) ? "persistent" : "temporary"; printVersion("storage mode: "+msg+" |"); //adjust title for mobile use @@ -98,9 +98,9 @@ function init() { } //backup landing page - activeState.orgPage.sidebar = document.getElementById("sidebar"); + activeState.orgPage.sidebar = document.getElementById("sidebar").childNodes; - activeState.orgPage.main = document.getElementById("mainForm"); + activeState.orgPage.main = document.getElementById("mainForm").childNodes; } function eventListeners() { diff --git a/js/2.0.3/parseForm.js b/js/2.0.3/parseForm.js index 38f82aa..bb9d6ac 100644 --- a/js/2.0.3/parseForm.js +++ b/js/2.0.3/parseForm.js @@ -97,20 +97,30 @@ function parseForm(returnDIV = false) { //sanitizing final output string let bHtml = b; + + //remove newline + bHtml = bHtml.replace(/!\w{1,2}\n/g, ""); + + bHtml = bHtml.replace(/!l /g, " • "); + bHtml = bHtml.replace(/!ls /g, " ○ "); bHtml = bHtml.replace(/ /g, " "); bHtml = bHtml.replace(/(?:\r\n|\r|\n)/g, "
"); + + bHtml = bHtml.replace(/<\/div>/g, '
'); bHtml = bHtml.replace(/
/g, ''); - if (activeState.settings.enablePell) { + /* if (activeState.settings.enablePell) { bHtml = bHtml.replace(/!l /g, ""); bHtml = bHtml.replace(/!n /g, ""); bHtml = bHtml.replace(/!ls /g, ""); } else { bHtml = bHtml.replace(/!l /g, " • "); bHtml = bHtml.replace(/!ls /g, " ○ "); - } - + } */ + + + //creating output div let divContent = document.createElement("div"); divContent.style.fontFamily = activeState.settings.font + ", Helvetica, sans-serif"; @@ -250,7 +260,7 @@ function parseForm(returnDIV = false) { if (listFlag && listIndicator == "") listIndicator = " • "; //exclude settings if pell is enabled - if (activeState.settings.enablePell) listIndicator = ""; + //if (activeState.settings.enablePell) listIndicator = ""; //handle global linebreak and fit according to indicator according to list indicator diff --git a/js/2.0.3/storage.js b/js/2.0.3/storage.js index 834ce2f..7d4b82a 100644 --- a/js/2.0.3/storage.js +++ b/js/2.0.3/storage.js @@ -11,9 +11,11 @@ const store = { getStor().setItem(sha256(key + activeState.userId), data); }, removeItem: function (key) { + debug("REMOVE", key); getStor().removeItem(sha256(key + activeState.userId)); }, clear: function () { + debug("CLEARALL", ""); getStor().clear(); }, }; @@ -60,18 +62,21 @@ function createStorageObj(ref = "none") { return; } for (let i = 0; i < x.length; i++) { + if (x.elements[i].name == "") continue; + dataArray.push({ value: x.elements[i].value, name: x.elements[i].name, }); } - //console.log(this, dataArray); //set current filename according to filenamefield setCurrentFileName(); //set savetime in templateFiles setTimeStamp(ref); + + //store files with preset filename storeData("userInput", dataArray); } @@ -325,7 +330,6 @@ function setTimeStamp(type) { tF[c].metadata.ts_save = getCurrentDate(); break; case "copy": - console.log("copy"); tF[c].metadata.ts_copy = getCurrentDate(); break; case "edit": diff --git a/js/2.0.3/web.js b/js/2.0.3/web.js index ea06d5e..6c6ecac 100644 --- a/js/2.0.3/web.js +++ b/js/2.0.3/web.js @@ -325,10 +325,12 @@ function retrieveForm(arr) { switch (e.nodeName) { case "TEXTAREA": + //clean pell attributes for raw input in textarea arr[i].value = arr[i].value.replace(/
/g, ""); arr[i].value = arr[i].value.replace(/<\/div>/g, "\n"); arr[i].value = arr[i].value.replace(/<.{1,4}>/g, ""); + //check if pell was used if (e.parentElement != undefined) { if (e.parentElement.getElementsByClassName("pell-content")[0] != undefined) { let contentArray = arr[i].value.split("\n"); @@ -349,6 +351,8 @@ function retrieveForm(arr) { e = e.parentElement.getElementsByClassName("pell-content")[0]; } } + + //append raw input to textarea or parsed content to pell content e.innerHTML = arr[i].value; break; case "INPUT":