Skip to content

Commit e7041bd

Browse files
committed
Keep only Copy context menu
Disable current line highlight Disable border radius
1 parent 8c05a6c commit e7041bd

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

example/components/chakra-markdown.tsx

+20-10
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ const ChakraMarkdown = React.memo<any>(({ content }) => {
2828
setEditorHeight(`${lines * lineHeight}px`);
2929
}, [children]);
3030
return (
31-
<Box border="1px solid" borderColor={useColorModeValue("gray.200", "gray.600")} borderRadius="md" overflow="visible" my={2}>
31+
<Box
32+
border="1px solid"
33+
borderColor={useColorModeValue("gray.200", "gray.600")}
34+
borderRadius="0"
35+
overflow="visible"
36+
my={2}>
3237
<MonacoEditor
3338
height={editorHeight}
3439
language={language}
@@ -40,17 +45,22 @@ const ChakraMarkdown = React.memo<any>(({ content }) => {
4045
scrollBeyondLastLine: false,
4146
lineNumbers: "off",
4247
scrollbar: { vertical: 'hidden' },
43-
overviewRulerLanes: 0, // Disable the overview ruler
44-
hideCursorInOverviewRuler: true, // Hide cursor in the ruler
45-
folding: false, // Disable code folding
46-
glyphMargin: false, // Hide the glyph margin (left margin with icons)
47-
contextmenu: false, // Disable default context menu
48+
overviewRulerLanes: 0, // Disable the overview ruler
49+
hideCursorInOverviewRuler: true, // Hide cursor in the ruler
50+
folding: false, // Disable code folding
51+
glyphMargin: false, // Hide the glyph margin (left margin with icons)
52+
renderLineHighlight: 'none', // Disable the current line highlight
4853
}}
4954
onMount={(editor, monaco) => {
50-
// Disable the right-click context menu
51-
editor.onContextMenu((e) => {
52-
e.event.preventDefault(); // Prevent default context menu
53-
});
55+
const keepIds = ["editor.action.clipboardCopyAction"];
56+
const contextmenu = editor.getContribution('editor.contrib.contextmenu');
57+
const realMethod = contextmenu._getMenuActions;
58+
contextmenu._getMenuActions = function () {
59+
const items = realMethod.apply(contextmenu, arguments);
60+
return items.filter(function (item) {
61+
return keepIds.includes(item.id);
62+
});
63+
};
5464
}}
5565
/>
5666
</Box>

0 commit comments

Comments
 (0)