Skip to content

Instantly share code, notes, and snippets.

@szobov
Last active September 20, 2017 05:03
Show Gist options
  • Save szobov/7d468863974ae2a5da435a1c4e2b1465 to your computer and use it in GitHub Desktop.
Save szobov/7d468863974ae2a5da435a1c4e2b1465 to your computer and use it in GitHub Desktop.
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() |}]}
};
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