Skip to content

Commit

Permalink
feat(lsp): Add monaco to window type
Browse files Browse the repository at this point in the history
  • Loading branch information
ebb-tide committed Feb 14, 2020
1 parent b79add7 commit ac0447d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
8 changes: 8 additions & 0 deletions ui/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ import {MonacoType} from 'src/types'

declare module '*.png'
declare let monaco: MonacoType

declare global {
interface Window {
monaco: MonacoType
}
}

window.monaco = window.monaco || {}
16 changes: 13 additions & 3 deletions ui/src/timeMachine/components/TimeMachineFluxEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ const TimeMachineFluxEditor: FC<Props> = ({
const p = editorInstance.getPosition()
editorInstance.executeEdits('', [
{
range: new monaco.Range(p.lineNumber, p.column, p.lineNumber, p.column),
range: new window.monaco.Range(
p.lineNumber,
p.column,
p.lineNumber,
p.column
),
text: `v.${variableName}`,
},
])
Expand All @@ -70,7 +75,12 @@ const TimeMachineFluxEditor: FC<Props> = ({
const p = editorInstance.getPosition()
const edits = [
{
range: new monaco.Range(p.lineNumber, p.column, p.lineNumber, p.column),
range: new window.monaco.Range(
p.lineNumber,
p.column,
p.lineNumber,
p.column
),
text: formatFunctionForInsert(func.name, func.example),
},
]
Expand All @@ -80,7 +90,7 @@ const TimeMachineFluxEditor: FC<Props> = ({
)
if (importStatement) {
edits.unshift({
range: new monaco.Range(1, 1, 1, 1),
range: new window.monaco.Range(1, 1, 1, 1),
text: `${importStatement}\n`,
})
}
Expand Down
3 changes: 2 additions & 1 deletion ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@
"src/**/*.test.tsx",
"src/**/mocks.ts",
"coverage"
]
],
"include": ["global.d.ts"]
}

0 comments on commit ac0447d

Please sign in to comment.