fix: Code toolbar in read-only
This commit is contained in:
@@ -215,7 +215,7 @@ export default function SelectionToolbar(props: Props) {
|
|||||||
let items: MenuItem[] = [];
|
let items: MenuItem[] = [];
|
||||||
|
|
||||||
if (isCodeSelection) {
|
if (isCodeSelection) {
|
||||||
items = getCodeMenuItems(state, dictionary);
|
items = getCodeMenuItems(state, readOnly, dictionary);
|
||||||
} else if (isTableSelection) {
|
} else if (isTableSelection) {
|
||||||
items = getTableMenuItems(dictionary);
|
items = getTableMenuItems(dictionary);
|
||||||
} else if (colIndex !== undefined) {
|
} else if (colIndex !== undefined) {
|
||||||
|
|||||||
@@ -7,8 +7,12 @@ import { Dictionary } from "~/hooks/useDictionary";
|
|||||||
|
|
||||||
export default function codeMenuItems(
|
export default function codeMenuItems(
|
||||||
state: EditorState,
|
state: EditorState,
|
||||||
|
readOnly: boolean | undefined,
|
||||||
dictionary: Dictionary
|
dictionary: Dictionary
|
||||||
): MenuItem[] {
|
): MenuItem[] {
|
||||||
|
if (readOnly) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
const node = state.selection.$from.node();
|
const node = state.selection.$from.node();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|||||||
Reference in New Issue
Block a user