mirror of
https://github.com/usememos/memos.git
synced 2024-11-24 14:42:58 +03:00
feat: add lodash-es package
This commit is contained in:
parent
ef8034836c
commit
017bbfa6d6
@ -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",
|
||||
|
@ -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>
|
||||
|
@ -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) => {
|
||||
|
@ -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) {
|
||||
|
@ -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 };
|
||||
|
@ -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 ? (
|
||||
|
@ -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,
|
||||
},
|
||||
},
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user