Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
feat: add lodash-es package
email017bbfa6d6dc
diff --git a/web/package.json b/web/package.jsonindex 69e9992bc..498067614 100644--- a/web/package.json+++ b/web/package.json@@ -8,11 +8,13 @@"lint": "eslint --ext .js,.ts,.tsx, src"},"dependencies": {+ "lodash-es": "^4.17.21","react": "^17.0.2","react-dom": "^17.0.2","tiny-undo": "^0.0.8"},"devDependencies": {+ "@types/lodash-es": "^4.17.5","@types/react": "^17.0.2","@types/react-dom": "^17.0.2","@typescript-eslint/eslint-plugin": "^5.6.0",diff --git a/web/src/components/Editor/Editor.tsx b/web/src/components/Editor/Editor.tsxindex 3e1165e36..fd084b7a1 100644--- a/web/src/components/Editor/Editor.tsx+++ b/web/src/components/Editor/Editor.tsx@@ -180,7 +180,7 @@ const Editor = forwardRef((props: EditorProps, ref: React.ForwardedRef<EditorRef</button></Only><Only when={showConfirmBtn}>- <button className="action-btn confirm-btn" disabled={!editorRef.current?.value} onClick={handleCommonConfirmBtnClick}>+ <button className="action-btn confirm-btn" disabled={editorRef.current?.value === ""} onClick={handleCommonConfirmBtnClick}>Save <span className="icon-text">✍️</span></button></Only>diff --git a/web/src/components/Memo.tsx b/web/src/components/Memo.tsxindex 5067e03bc..e980a3873 100644--- a/web/src/components/Memo.tsx+++ b/web/src/components/Memo.tsx@@ -1,6 +1,7 @@import { memo } from "react";+import { escape } from "lodash-es";import { IMAGE_URL_REG, LINK_REG, MEMO_LINK_REG, TAG_REG } from "../helpers/consts";-import { encodeHtml, parseMarkedToHtml, parseRawTextToHtml } from "../helpers/marked";+import { parseMarkedToHtml, parseRawTextToHtml } from "../helpers/marked";import utils from "../helpers/utils";import useToggle from "../hooks/useToggle";import { globalStateService, memoService } from "../services";@@ -128,7 +129,7 @@ const Memo: React.FC<Props> = (props: Props) => {};export function formatMemoContent(content: string) {- content = encodeHtml(content);+ content = escape(content);content = parseRawTextToHtml(content).split("<br>").map((t) => {diff --git a/web/src/components/MemoEditor.tsx b/web/src/components/MemoEditor.tsxindex 3c1d23a88..3f576f67b 100644--- a/web/src/components/MemoEditor.tsx+++ b/web/src/components/MemoEditor.tsx@@ -175,11 +175,6 @@ const MemoEditor: React.FC<Props> = () => {}, []);const handleContentChange = useCallback((content: string) => {- const tempDiv = document.createElement("div");- tempDiv.innerHTML = content;- if (tempDiv.innerText.trim() === "") {- content = "";- }setEditorContentCache(content);if (editorRef.current) {diff --git a/web/src/helpers/marked.ts b/web/src/helpers/marked.tsindex ec8a2ed50..aef09e6f2 100644--- a/web/src/helpers/marked.ts+++ b/web/src/helpers/marked.ts@@ -39,10 +39,4 @@ const parseRawTextToHtml = (rawTextStr: string): string => {return htmlText;};-const encodeHtml = (htmlStr: string): string => {- const t = document.createElement("div");- t.textContent = htmlStr;- return t.innerHTML;-};--export { encodeHtml, parseMarkedToHtml, parseHtmlToRawText, parseRawTextToHtml };+export { parseMarkedToHtml, parseHtmlToRawText, parseRawTextToHtml };diff --git a/web/src/pages/Signin.tsx b/web/src/pages/Signin.tsxindex d14e372c8..47ccf1986 100644--- a/web/src/pages/Signin.tsx+++ b/web/src/pages/Signin.tsx@@ -121,7 +121,7 @@ const Signin: React.FC<Props> = () => {<div className="page-container"><div className="page-header-container"><p className="title-text">- Login to Memos <span className="icon-text">✍️</span>+ <span className="icon-text">✍️</span> Memos</p></div>{showAutoSigninAsGuest ? (diff --git a/web/vite.config.ts b/web/vite.config.tsindex cdd88af4d..c46bf54c7 100644--- a/web/vite.config.ts+++ b/web/vite.config.ts@@ -13,7 +13,8 @@ export default defineConfig({changeOrigin: true,},"/h/": {- target: "https://memos.justsven.top/",+ target: "http://localhost:8080/",+ // target: "https://memos.justsven.top/",changeOrigin: true,},},diff --git a/web/yarn.lock b/web/yarn.lockindex ac98984eb..e3247e4e8 100644--- a/web/yarn.lock+++ b/web/yarn.lock@@ -336,6 +336,18 @@resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz"integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==+"@types/lodash-es@^4.17.5":+ version "4.17.5"+ resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.5.tgz#1c3fdd16849d84aea43890b1c60da379fb501353"+ integrity sha512-SHBoI8/0aoMQWAgUHMQ599VM6ZiSKg8sh/0cFqqlQQMyY9uEplc0ULU5yQNzcvdR4ZKa0ey8+vFmahuRbOCT1A==+ dependencies:+ "@types/lodash" "*"++"@types/lodash@*":+ version "4.14.178"+ resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.178.tgz#341f6d2247db528d4a13ddbb374bcdc80406f4f8"+ integrity sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw==+"@types/parse-json@^4.0.0":version "4.0.0"resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"@@ -1645,6 +1657,11 @@ lines-and-columns@^1.1.6:resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632"integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==+lodash-es@^4.17.21:+ version "4.17.21"+ resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee"+ integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==+lodash.merge@^4.6.2:version "4.6.2"resolved "https://registry.npm.taobao.org/lodash.merge/download/lodash.merge-4.6.2.tgz"