From 1f008a22a8f7830b77ac16eaafbf2d22353a8ea0 Mon Sep 17 00:00:00 2001 From: maru21 Date: Thu, 2 Nov 2023 19:36:42 +0100 Subject: [PATCH] fixed pells div newline cleaned some console.logs --- js/2.0.0/parseForm.js | 2 +- js/2.0.1/buildForm.js | 3 +-- js/2.0.1/files.js | 1 - js/2.0.1/init.js | 4 +--- js/2.0.1/parseForm.js | 22 ++++++++++++++++++---- js/2.0.1/storage.js | 6 +++--- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/js/2.0.0/parseForm.js b/js/2.0.0/parseForm.js index bcca0b1..2372edd 100644 --- a/js/2.0.0/parseForm.js +++ b/js/2.0.0/parseForm.js @@ -1,4 +1,4 @@ -import { sanitize, getCurrentDate } from "./scripts.js"; +import { sanitize } from "./scripts.js"; import { storeData, clearData, retrieveData } from "./storage.js"; function parseFormOnSubmit(returnJSON = false, parseOnly = false) { diff --git a/js/2.0.1/buildForm.js b/js/2.0.1/buildForm.js index 91d097f..9a6f50b 100644 --- a/js/2.0.1/buildForm.js +++ b/js/2.0.1/buildForm.js @@ -1,6 +1,5 @@ import { getFileName } from "./storage.js"; import pell from "./pell.js" -import { inputRead } from "./scripts.js"; function transformTemplateObject(objects) { let form = document.createElement("FORM"); @@ -414,7 +413,7 @@ function buildLongTextInput(source, textarea, label) { const editor = pell.init({ element: source, - defaultParagraphSeparator: "br", + defaultParagraphSeparator: "div", actions: [ "bold", "italic", diff --git a/js/2.0.1/files.js b/js/2.0.1/files.js index 1af1c90..24ba9f6 100644 --- a/js/2.0.1/files.js +++ b/js/2.0.1/files.js @@ -356,7 +356,6 @@ function formEvts(storageName) { modalNotifier(activeState.fileName + " copied to clipboard", activeState.settings.notifierPause); break; case "Delete": - console.log(storageName); let previousFile = getPreviousFile(storageName); clearFileData(storageName); let delFileName = activeState.fileName; diff --git a/js/2.0.1/init.js b/js/2.0.1/init.js index 87b63e9..139786e 100644 --- a/js/2.0.1/init.js +++ b/js/2.0.1/init.js @@ -154,7 +154,7 @@ function eventListeners() { parseFormOnSubmit(); modalNotifier("File copied to clipboard", activeState.settings.notifierPause); let copyButton = document.getElementById("fromCopyBtn"); - copyButton.className.replace(" w3-grey", " w3-flat-carrot"); + copyButton.className = "w3-button w3-flat-carrot"; copyButton.value = "Copied"; e.preventDefault(); } @@ -177,8 +177,6 @@ function eventListeners() { } } } - - console.log(template); }); } diff --git a/js/2.0.1/parseForm.js b/js/2.0.1/parseForm.js index bcca0b1..064eab5 100644 --- a/js/2.0.1/parseForm.js +++ b/js/2.0.1/parseForm.js @@ -1,4 +1,4 @@ -import { sanitize, getCurrentDate } from "./scripts.js"; +import { sanitize } from "./scripts.js"; import { storeData, clearData, retrieveData } from "./storage.js"; function parseFormOnSubmit(returnJSON = false, parseOnly = false) { @@ -120,10 +120,21 @@ function parseFormOnSubmit(returnJSON = false, parseOnly = false) { } } - let bHtml = b.replace(/(?:\r\n|\r|\n)/g, "
"); - bHtml = bHtml.replace(/!l /g, " • "); - bHtml = bHtml.replace(/!ls /g, " ○ "); + //sanitizing + let bHtml = b; 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 == "true") { + 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, " ○ "); + } let divContent = document.createElement("div"); divContent.style.fontFamily = activeState.settings.font + ", Helvetica, sans-serif"; @@ -268,6 +279,9 @@ function parseFormOnSubmit(returnJSON = false, parseOnly = false) { if (listSubFlag && listIndicator == "") listIndicator = " ○ "; if (listFlag && listIndicator == "") listIndicator = " • "; + + //exclude settings if pell is enabled + if (activeState.settings.enablePell == "true") listIndicator = ""; //handle global linebreak and fit according to indicator according to list indicator diff --git a/js/2.0.1/storage.js b/js/2.0.1/storage.js index b83a9a1..fb9b533 100644 --- a/js/2.0.1/storage.js +++ b/js/2.0.1/storage.js @@ -61,15 +61,15 @@ function createStorageObj() { activeState.fileName = userFileNamePH; } - storeData("userInput", dataArray, "save"); + storeData("userInput", dataArray); } -function storeData(name, data, ref) { +function storeData(name, data) { if (passwordHash == "") return; data = JSON.stringify(data); //setCookie(name, btoa(data), 7); if (name == "userInput") { - name = getFileName(ref); + name = getFileName(); } if (name == "userInputForce") { name = "userInput";