Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion web/src/components/MemoEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type { EditorRefActions } from "./Editor";
import { useAudioRecorder, useAutoSave, useFocusMode, useKeyboard, useMemoInit } from "./hooks";
import { errorService, memoService, transcriptionService, validationService } from "./services";
import { EditorProvider, useEditorContext } from "./state";
import { initialState } from "./state/types";
import type { MemoEditorProps } from "./types";
import type { LocalFile } from "./types/attachment";

Expand All @@ -34,7 +35,15 @@ const TRANSCRIPTION_PROVIDER_TYPES: InstanceSetting_AIProviderType[] = [
];

const MemoEditor = (props: MemoEditorProps) => (
<EditorProvider>
<EditorProvider
initialEditorState={{
...initialState,
ui: {
...initialState.ui,
isFocusMode: props.isFocusMode ?? initialState.ui.isFocusMode,
},
}}
>
<MemoEditorImpl {...props} />
</EditorProvider>
);
Expand Down
1 change: 1 addition & 0 deletions web/src/components/MemoEditor/types/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface MemoEditorProps {
memo?: Memo;
parentMemoName?: string;
autoFocus?: boolean;
isFocusMode?: boolean;
onConfirm?: (memoName: string) => void;
onCancel?: () => void;
}
Expand Down
12 changes: 10 additions & 2 deletions web/src/components/MemoView/MemoView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const MemoView: React.FC<MemoViewProps> = (props: MemoViewProps) => {
const { memo: memoData, className, parentPage: parentPageProp, compact, showCreator, showVisibility, showPinned } = props;
const cardRef = useRef<HTMLDivElement>(null);
const [showEditor, setShowEditor] = useState(false);
const [showEditorFocusMode, setShowEditorFocusMode] = useState(false);
const [cardWidth, setCardWidth] = useState(0);

const currentUser = useCurrentUser();
Expand All @@ -36,8 +37,14 @@ const MemoView: React.FC<MemoViewProps> = (props: MemoViewProps) => {

const { previewState, openPreview, setPreviewOpen } = useImagePreview();

const openEditor = useCallback(() => setShowEditor(true), []);
const closeEditor = useCallback(() => setShowEditor(false), []);
const openEditor = useCallback((isFocusMode?: boolean) => {
setShowEditorFocusMode(isFocusMode === true);
setShowEditor(true);
}, []);
const closeEditor = useCallback(() => {
setShowEditor(false);
setShowEditorFocusMode(false);
}, []);

const location = useLocation();
const isInMemoDetailPage = location.pathname.startsWith(`/${memoData.name}`) || location.pathname.startsWith("/memos/shares/");
Expand Down Expand Up @@ -109,6 +116,7 @@ const MemoView: React.FC<MemoViewProps> = (props: MemoViewProps) => {
cacheKey={`inline-memo-editor-${memoData.name}`}
memo={memoData}
parentMemoName={memoData.parent || undefined}
isFocusMode={showEditorFocusMode}
onConfirm={closeEditor}
onCancel={closeEditor}
/>
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/MemoView/MemoViewContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface MemoViewContextValue {
readonly: boolean;
showBlurredContent: boolean;
blurred: boolean;
openEditor: () => void;
openEditor: (isFocusMode?: boolean) => void;
toggleBlurVisibility: () => void;
openPreview: (items: string | string[] | PreviewMediaItem[], index?: number) => void;
}
Expand Down
15 changes: 14 additions & 1 deletion web/src/components/MemoView/components/MemoHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BookmarkIcon } from "lucide-react";
import { BookmarkIcon, Target } from "lucide-react";
import { useCallback, useState } from "react";
import { Link } from "react-router-dom";
import { Button } from "@/components/ui/button";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import useNavigateTo from "@/hooks/useNavigateTo";
import i18n from "@/i18n";
Expand Down Expand Up @@ -95,6 +96,18 @@ const MemoHeader: React.FC<MemoHeaderProps> = ({ showCreator, showVisibility, sh
</TooltipProvider>
)}

{!readonly && !isArchived && (
<Button
variant="ghost"
size="icon"
className="shadow-none"
aria-label={t("editor.focus-mode")}
title={t("editor.focus-mode")}
onClick={() => openEditor(true)}
>
<Target className="w-4 h-4" />
</Button>
)}
<MemoActionMenu memo={memo} readonly={readonly} onEdit={openEditor} />
</div>
</div>
Expand Down