Created
December 21, 2019 16:18
-
-
Save sgrove/c9dab7451e187a93404faec5712bad1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type editor; | |
module Editor: { | |
[@react.component] | |
let make: | |
( | |
~width: string=?, | |
~height: string=?, | |
~value: string=?, | |
~defaultValue: string=?, | |
~language: string=?, | |
~theme: string=?, | |
~options: Js.t({..})=?, | |
~overrideServices: string=?, | |
~onChange: (string, 'event) => unit=?, | |
~editorWillMount: 'monaco => unit=?, | |
~editorDidMount: (editor, 'monaco) => unit=?, | |
~className: string=? | |
) => | |
React.element; | |
} = { | |
[@bs.module "react-monaco-editor1"] [@react.component] | |
external make: | |
( | |
~width: string=?, | |
~height: string=?, | |
~value: string=?, | |
~defaultValue: string=?, | |
~language: string=?, | |
~theme: string=?, | |
~options: Js.t({..})=?, | |
~overrideServices: string=?, | |
~onChange: (string, 'event) => unit=?, | |
~editorWillMount: 'monaco => unit=?, | |
~editorDidMount: (editor, 'monaco) => unit=?, | |
~className: string=? | |
) => | |
React.element = | |
"default"; | |
}; | |
module DiffViewer: { | |
[@react.component] | |
let make: | |
( | |
~width: string=?, | |
~height: string=?, | |
~original: string, | |
~value: string, | |
~defaultValue: string=?, | |
~language: string=?, | |
~theme: string=?, | |
~options: Js.t({..})=?, | |
~overrideServices: string=?, | |
~onChange: (string, 'event) => unit=?, | |
~editorWillMount: 'monaco => unit=?, | |
~editorDidMount: (editor, 'monaco) => unit=?, | |
~className: string=? | |
) => | |
React.element; | |
} = { | |
[@bs.module "react-monaco-editor"] [@react.component] | |
external make: | |
( | |
~width: string=?, | |
~height: string=?, | |
~original: string, | |
~value: string, | |
~defaultValue: string=?, | |
~language: string=?, | |
~theme: string=?, | |
~options: Js.t({..})=?, | |
~overrideServices: string=?, | |
~onChange: (string, 'event) => unit=?, | |
~editorWillMount: 'monaco => unit=?, | |
~editorDidMount: (editor, 'monaco) => unit=?, | |
~className: string=? | |
) => | |
React.element = | |
"MonacoDiffEditor"; | |
}; | |
[@bs.send] external layout: editor => unit = "layout"; | |
type selection = { | |
startLineNumber: int, | |
startColumn: int, | |
endLineNumber: int, | |
endColumn: int, | |
}; | |
[@bs.send] external setSelection: (editor, selection) => unit = "setSelection"; | |
[@bs.send] external revealLine: (editor, int) => unit = "revealLine"; | |
[@bs.send] external focus: editor => unit = "focus"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type editor; | |
[@bs.send] external layout: editor => unit = "layout"; | |
type selection = { | |
startLineNumber: int, | |
startColumn: int, | |
endLineNumber: int, | |
endColumn: int, | |
}; | |
[@bs.send] external setSelection: (editor, selection) => unit = "setSelection"; | |
[@bs.send] external revealLine: (editor, int) => unit = "revealLine"; | |
[@bs.send] external focus: editor => unit = "focus"; | |
module Editor = { | |
module type T = (module type of BsReactMonaco.Editor); | |
/* | |
Needed for BuckleScript to not import the original component: | |
See https://github.com/BuckleScript/bucklescript/issues/3543 | |
*/ | |
[@bs.val] external component: (module T) = "undefined"; | |
/* Module annotation needed to make sure `make` has the same type as | |
the original component */ | |
module Lazy: T = { | |
/* Includes `makeProps` at the type level without adding `import` of the original component */ | |
include (val component); | |
/* 100% unsafe due to `import` typedef :) but will be unified by the explicit type annotation above */ | |
let make = LazyImport.(lazy_(() => import("react-monaco-editor"))); | |
/* All bindings in the original component have to be added here (`makeProps` | |
is external, so no need). Shadowing them here removes invalid access to | |
undefined[1], undefined[n] in the resulting output */ | |
/* let default = make; */ | |
}; | |
}; | |
module DiffViewer = { | |
module type T = (module type of BsReactMonaco.DiffViewer); | |
/* | |
Needed for BuckleScript to not import the original component: | |
See https://github.com/BuckleScript/bucklescript/issues/3543 | |
*/ | |
[@bs.val] external component: (module T) = "undefined"; | |
/* Module annotation needed to make sure `make` has the same type as | |
the original component */ | |
module Lazy: T = { | |
/* Includes `makeProps` at the type level without adding `import` of the original component */ | |
include (val component); | |
/* 100% unsafe due to `import` typedef :) but will be unified by the explicit type annotation above */ | |
let make = LazyImport.(lazy_(() => import("react-monaco-editor"))); | |
/* All bindings in the original component have to be added here (`makeProps` | |
is external, so no need). Shadowing them here removes invalid access to | |
undefined[1], undefined[n] in the resulting output */ | |
/* let default = make; */ | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment