fix: Allow copy code block to clipboard in read-only

closes #5614
This commit is contained in:
Tom Moor
2023-07-29 23:24:50 -04:00
parent 20932a08d0
commit 1864ed605f
2 changed files with 7 additions and 3 deletions

View File

@@ -10,21 +10,21 @@ export default function codeMenuItems(
readOnly: boolean | undefined,
dictionary: Dictionary
): MenuItem[] {
if (readOnly) {
return [];
}
const node = state.selection.$from.node();
return [
{
name: "copyToClipboard",
icon: <CopyIcon />,
label: readOnly ? dictionary.copy : undefined,
tooltip: dictionary.copy,
},
{
name: "separator",
visible: !readOnly,
},
{
visible: !readOnly,
name: "code_block",
icon: <ExpandedIcon />,
label: LANGUAGES[node.attrs.language ?? "none"],

View File

@@ -199,6 +199,10 @@ export default class CodeFence extends Node {
};
}
get allowInReadOnly() {
return true;
}
keys({ type, schema }: { type: NodeType; schema: Schema }) {
return {
"Shift-Ctrl-\\": toggleBlockType(type, schema.nodes.paragraph),