Skip to content

Commit

Permalink
Merge pull request #19 from tsnobip/master
Browse files Browse the repository at this point in the history
Fix parameter type for Model.DOMOutputSpec
  • Loading branch information
alexeygolev authored Nov 27, 2019
2 parents 7d522ae + af2bc0e commit c4f52ab
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
4 changes: 2 additions & 2 deletions example/Index.re
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ let config =
"Mod-b",
PM.Commands.toggleMark(
~markType=schema->Model.Schema.marks->Js.Dict.get("strong")->Option.getExn,
~attrs=Model.Attrs.empty,
~attrs=Model.Attrs.empty(),
),
),
(
"Mod-i",
PM.Commands.toggleMark(
~markType=schema->Model.Schema.marks->Js.Dict.get("em")->Option.getExn,
~attrs=Model.Attrs.empty,
~attrs=Model.Attrs.empty(),
),
),
]
Expand Down
15 changes: 11 additions & 4 deletions src/PM_Model.re
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@ module Attrs = {
type t;
let make: Js.t({..}) => t = a => Obj.magic(a);
let toJs: t => Js.t({..}) = a => Obj.magic(a);
let empty = make(Js.Obj.empty());
let empty: unit => t = () => make(Js.Obj.empty());
};

module AttributeSpec = {
type t;
[@bs.obj] external make: (~default: 'a=?, unit) => t = "";
};

module DOMAttrs = {
type t = Js.Dict.t(string);
let make: Js.Dict.t(string) => t = a => a;
let toDict: t => Js.Dict.t(string) = a => a;
let empty: unit => t = Js.Dict.empty;
};

module DOMOutputSpec = {
type spec =
| LeafNode(string, Attrs.t): spec
| Node(string, Attrs.t, spec): spec
| LeafNode(string, DOMAttrs.t): spec
| Node(string, DOMAttrs.t, spec): spec
| Text(string): spec
| Hole: spec;
type t;
Expand Down Expand Up @@ -483,7 +490,7 @@ module MarkType = {
};

module SchemaSpec = {
[@bs.deriving abstract]
[@bs.deriving {abstract: light}]
type t = {
nodes: OrderedMap.t(NodeSpec.t),
marks: OrderedMap.t(MarkSpec.t),
Expand Down
17 changes: 12 additions & 5 deletions src/PM_Model.rei
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Attrs: {
type t;
let make: Js.t({..}) => t;
let toJs: t => Js.t({..});
let empty: t;
let empty: unit => t;
};

module AttributeSpec: {
Expand All @@ -17,6 +17,13 @@ module AttributeSpec: {
let make: (~default: 'a=?, unit) => t;
};

module DOMAttrs: {
type t;
let make: Js.Dict.t(string) => t;
let toDict: t => Js.Dict.t(string);
let empty: unit => t;
};

module DOMOutputSpec: {
/**
A description of a DOM structure. Can be either a string, which is interpreted as a text node,
Expand All @@ -30,8 +37,8 @@ module DOMOutputSpec: {
in its parent node.
*/
type spec =
| LeafNode(string, Attrs.t): spec
| Node(string, Attrs.t, spec): spec
| LeafNode(string, DOMAttrs.t): spec
| Node(string, DOMAttrs.t, spec): spec
| Text(string): spec
| Hole: spec;

Expand Down Expand Up @@ -903,14 +910,14 @@ module SchemaSpec: {
precedence by default, and which nodes come first in a given group.
nodes: Object<NodeSpec> | OrderedMap<NodeSpec>
*/
let nodesGet: t => OrderedMap.t(NodeSpec.t);
let nodes: t => OrderedMap.t(NodeSpec.t);

/**
The mark types that exist in this schema. The order in which they are provided determines the
order in which mark sets are sorted and in which parse rules are tried.
marks: ?⁠Object<MarkSpec> | OrderedMap<MarkSpec>
*/
let marksGet: t => OrderedMap.t(MarkSpec.t);
let marks: t => OrderedMap.t(MarkSpec.t);

/**
The name of the default top-level node for the schema. Defaults to "doc".
Expand Down

0 comments on commit c4f52ab

Please sign in to comment.