From eae6204d55927ea325c7b565864372cfa7f27179 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 18 Jul 2023 19:39:23 -0400 Subject: [PATCH] fix: Code toolbar in read-only --- app/editor/components/SelectionToolbar.tsx | 2 +- app/editor/menus/code.tsx | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/editor/components/SelectionToolbar.tsx b/app/editor/components/SelectionToolbar.tsx index 3b5b94b07..4deda9330 100644 --- a/app/editor/components/SelectionToolbar.tsx +++ b/app/editor/components/SelectionToolbar.tsx @@ -215,7 +215,7 @@ export default function SelectionToolbar(props: Props) { let items: MenuItem[] = []; if (isCodeSelection) { - items = getCodeMenuItems(state, dictionary); + items = getCodeMenuItems(state, readOnly, dictionary); } else if (isTableSelection) { items = getTableMenuItems(dictionary); } else if (colIndex !== undefined) { diff --git a/app/editor/menus/code.tsx b/app/editor/menus/code.tsx index 3cc9e764c..548735e96 100644 --- a/app/editor/menus/code.tsx +++ b/app/editor/menus/code.tsx @@ -7,8 +7,12 @@ import { Dictionary } from "~/hooks/useDictionary"; export default function codeMenuItems( state: EditorState, + readOnly: boolean | undefined, dictionary: Dictionary ): MenuItem[] { + if (readOnly) { + return []; + } const node = state.selection.$from.node(); return [