A mark is a piece of information that can be attached to an inline node (like color, font, and link information).
Creates a mark. The arguments are as follows:
definition is the MarkDefinition that defines this node. Note that even though marks require a mark definition,
it's still safe to use (==) because the function arguments are not stored on the Mark
attributes are a list of attributes, for example [StringAttribute 'href' 'www.google.com']
mark link [StringAttribute 'href' 'www.google.com']
--> creates a link markName of the mark
A list of attributes associated with the mark
Creates a mark with new attributes
A mark order is a way of sorting marks. In order to have a single way of representing a document, it's necessary to make sure marks are sorted in a consistent way. Mark orders should be derived from the spec.
markOrderFromSpec spec
--> returns a mark order that can be used to sort a list of marksDerives the mark order from the order of the spec's mark definitions, e.g. (markDefinitions spec).
spec : Spec
spec =
emptySpec
|> withMarkDefinitions
[ link
, bold
, italic
, code
]
markOrderFromSpec spec
--> returns a mark order that will sort marks in the following order: link, bold, italic, and code.Sorts a list of marks from the given MarkOrder
spec : Spec
spec =
emptySpec
|> withMarkDefinitions
[ bold
, italic
]
sort (markOrderFromSpec spec) [mark italic [], mark bold []]
--> [mark bold [], mark italic []]Actions used to toggle a mark from a list of marks.
Add adds or replaces a mark if it exists.
Remove removes all marks with the same name if it exists.
Flip will remove a mark if a mark with the same name exists, otherwise it will add it.
Returns a list that executes the toggle action and maintains the given mark order.
-- Assuming the mark order is bold < italic < code:
toggle Add (markOrderFromSpec spec) (mark code []) [mark bold [], mark italic []]
--> [mark bold [], mark italic [], mark code []]Predicate that returns true if the list of marks contains a mark with the given name
A mark is a piece of information defined by a
MarkDefinitionthat can be attached to an inline node, like color font, or link information.