Skip to content

armgit / memos

Public Imported from GitHub
0

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.

feat: support empty content memo (#963)

Zeng1998f8855ddb5654
diff --git a/server/memo.go b/server/memo.go
index 13d9b652e..5a6e504a5 100644
--- a/server/memo.go
+++ b/server/memo.go
@@ -29,9 +29,6 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
if err := json.NewDecoder(c.Request().Body).Decode(memoCreate); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "Malformatted post memo request").SetInternal(err)
}
- if memoCreate.Content == "" {
- return echo.NewHTTPError(http.StatusBadRequest, "Memo content shouldn't be empty")
- }
if memoCreate.Visibility == "" {
userSettingMemoVisibilityKey := api.UserSettingMemoVisibilityKey
diff --git a/web/src/components/MemoEditor.tsx b/web/src/components/MemoEditor.tsx
index 770566647..dd233ef47 100644
--- a/web/src/components/MemoEditor.tsx
+++ b/web/src/components/MemoEditor.tsx
@@ -296,12 +296,7 @@ const MemoEditor = () => {
};
const handleSaveBtnClick = async () => {
- const content = editorRef.current?.getContent();
- if (!content) {
- toastHelper.error(t("editor.cant-empty"));
- return;
- }
-
+ const content = editorRef.current?.getContent() ?? "";
try {
const { editMemoId } = editorStore.getState();
if (editMemoId && editMemoId !== UNKNOWN_ID) {
@@ -551,7 +546,11 @@ const MemoEditor = () => {
<button className={`action-btn cancel-btn ${isEditing ? "" : "!hidden"}`} onClick={handleCancelEdit}>
{t("editor.cancel-edit")}
</button>
- <button className="action-btn confirm-btn" disabled={!allowSave || state.isUploadingResource} onClick={handleSaveBtnClick}>
+ <button
+ className="action-btn confirm-btn"
+ disabled={!(allowSave || editorState.resourceList.length > 0) || state.isUploadingResource}
+ onClick={handleSaveBtnClick}
+ >
{t("editor.save")}
<img className="icon-img w-4 h-auto" src="/logo.png" />
</button>