import { wrap } from "@/libs/secret"; import storage from "@/libs/storage"; import escapeHtml from "escape-html"; export function setStoreText(noteForm, state, secret) { let text = noteForm.text; let storeText = ""; if (text) { storeText = wrap(text, secret.secretKey); } storage.local.setText( secret.storeKey, state.lock + "|" + secret.cipher + "|" + state.commited + "|" + state.initTime + "|" + storeText ); } export function clearStoreText(key) { if (!key) { return; } storage.local.delete(key); } export function getEscapeText(text) { let textEscape = escapeHtml(text); textEscape = textEscape.replace(new RegExp(" ", "gm"), " "); textEscape = textEscape.replace(new RegExp("\\r\\n", "gm"), "
"); textEscape = textEscape.replace(new RegExp("\\r", "gm"), "
"); textEscape = textEscape.replace(new RegExp("\\n", "gm"), "
"); textEscape = textEscape.replace( new RegExp("\\t", "gm"), '
	
' ); return textEscape; }