monaco-extension: add types for internal methods

This commit is contained in:
David Lechner
2022-03-12 18:18:17 -06:00
parent ecbcb09846
commit ceeb34436f
2 changed files with 19 additions and 2 deletions
-2
View File
@@ -127,7 +127,6 @@ const contextMenu = (_props: ContextMenu2ContentProps): JSX.Element => {
text={i18n.translate(EditorStringId.Undo)}
icon="undo"
label={isMacOS() ? 'Cmd-Z' : 'Ctrl-Z'}
// @ts-expect-error internal method canUndo()
disabled={!editor?.getModel()?.canUndo()}
/>
<MenuItem
@@ -138,7 +137,6 @@ const contextMenu = (_props: ContextMenu2ContentProps): JSX.Element => {
text={i18n.translate(EditorStringId.Redo)}
icon="redo"
label={isMacOS() ? 'Cmd-Shift-Z' : 'Ctrl-Shift-Z'}
// @ts-expect-error internal method canUndo()
disabled={!editor?.getModel()?.canRedo()}
/>
</Menu>
+19
View File
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022 The Pybricks Authors
// exposes some monaco editor internal functions
import {} from 'react-monaco-editor';
declare module 'react-monaco-editor' {
export namespace monaco {
export namespace editor {
export interface ITextModel {
// https://github.com/microsoft/vscode/blob/d54c705f6567958a732ac88b1c3ec4d2303fb026/src/vs/editor/common/model.ts#L1135
canUndo: () => boolean;
// https://github.com/microsoft/vscode/blob/d54c705f6567958a732ac88b1c3ec4d2303fb026/src/vs/editor/common/model.ts#L1148
canRedo: () => boolean;
}
}
}
}