Last active
September 20, 2017 05:03
-
-
Save szobov/7d468863974ae2a5da435a1c4e2b1465 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
external mediumEditor : string => 'a => 'b = "medium-editor" [@@bs.module] [@@bs.new]; | |
external extend : 'a => 'b = "" [@@bs.module "medium-editor"] [@@bs.scope "Extension"]; | |
type baseExtensionT = Js.t { | |
. | |
subscribe: (string => unit => unit) [@bs.meth], | |
handleKeydown: (unit => unit) [@bs.meth] | |
}; | |
let _ext = { | |
"name": "myext", | |
"init": (fun (that: baseExtensionT) => { | |
that##subscribe "editableKeydown" [%bs.raw {| that.handleKeydown.bind(that) |}]; | |
})[@bs.this], | |
"handleKeydown": fun () => Js.log "Hello!" | |
}[@bs.new]; | |
let extension = extend _ext; | |
let editor = | |
mediumEditor | |
"#editor" | |
{ | |
"extensions": {"myext": [%bs.raw {| new extension() |}]} | |
}; |
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
external mediumEditor : string => 'a => 'b = "medium-editor" [@@bs.module] [@@bs.new]; | |
external extend : 'a => 'b = "" [@@bs.module "medium-editor"] [@@bs.scope "Extension"]; | |
type baseExtensionT = Js.t { | |
. | |
subscribe: (string => unit => unit) [@bs.meth], | |
handleKeydown: (unit => unit) [@bs.meth] | |
}; | |
let _ext = { | |
"name": "myext", | |
"init": (fun (that: baseExtensionT) => { | |
that##subscribe "editableKeydown" (that##handleKeydown##bind that); | |
})[@bs.this], | |
"handleKeydown": fun () => Js.log "Hello!" | |
}; | |
let extension = extend _ext; | |
let editor = | |
mediumEditor | |
"#editor" | |
{ | |
"extensions": {"myext": extension} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment