Skip to content

Commit

Permalink
Add isolate node prop
Browse files Browse the repository at this point in the history
FEATURE: The new `NodeProp.isolate` can be used by parser to signal
that a given node should be treated as isolated when it comes to bidirectional
text rendering.
  • Loading branch information
marijnh committed Dec 28, 2023
1 parent 670559e commit 58b956f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@ export class NodeProp<T> {
/// `"Expression"` group).
static group = new NodeProp<readonly string[]>({deserialize: str => str.split(" ")})

/// Attached to nodes to indicate these should be
/// [displayed](https://codemirror.net/docs/ref/#language.syntaxTree)
/// in a bidirectional text isolate, so that direction-neutral
/// characters on their sides don't incorrectly get associated with
/// surrounding text. You'll generally want to set this for nodes
/// that contain arbitrary text, like strings and comments, and for
/// nodes that appear _inside_ arbitrary text, like HTML tags. When
/// not given a value, in a grammar declaration, defaults to
/// `"auto"`.
static isolate = new NodeProp<"rtl" | "ltr" | "auto">({deserialize: value => {
if (value && value != "rtl" && value != "ltr" && value != "auto")
throw new RangeError("Invalid value for isolate: " + value)
return (value as any) || "auto"
}})

/// The hash of the [context](#lr.ContextTracker.constructor)
/// that the node was parsed in, if any. Used to limit reuse of
/// contextual nodes.
Expand Down

0 comments on commit 58b956f

Please sign in to comment.