Skip to main content

Markers

reexport
interface Markers {
  anchor: boolean;
  direction: "ltr" | "rtl";
  edits: "ins"
    | "del"
    | "none";
  lang: string;
  olNestLevel: number;
  ulNestLevel: number;
  extend: () => Markers;
  toString: () => string;
}

Markers form an abstraction in which one node provides semantic information to itself and all its descendants. For example, ins elements, which stand for "insertion" of content in the context of an edit will provide the { edits: 'ins' } marker to all its descendants.

Remarks

Custom renderers can use markers to change their layout and convey their semantic meaning. Markers can be derived from attributes, such as lang and dir attributes, or tag names, such as a, ins, del...

TypeScript users: You can add fields to the ​Markers interface via module augmentation:

declare module '@native-html/transient-render-engine' {
interface Markers {
customField?: boolean;
}
}

Fields#

anchor#

required
anchor: boolean;

If this node is an a or has one as ancestor, this field will be set to true.

Default: false

direction#

required
direction: "ltr" | "rtl";

The direction for this content. Follows dir attribute.

https://html.spec.whatwg.org/#the-dir-attribute

Default: 'ltr'

edits#

required
edits: "ins"
  | "del"
  | "none";

If this node is a del or ins or has either as ancestor, this field will be set accordingly. Otherwise, it will be set to 'none'.

https://html.spec.whatwg.org/#edits

Default: 'none'

lang#

required
lang: string;

The language for this content. Follows lang attribute.

https://html.spec.whatwg.org/#the-lang-and-xml:lang-attributes

olNestLevel#

required
olNestLevel: number;
  • -1: this node is not an ol and has no ol parents
  • 0: this node is an ol or has one ol parent
  • 1: ...

ulNestLevel#

required
ulNestLevel: number;
  • -1: this node is not an ul and has no ul parents
  • 0: this node is an ul or has one ul parent
  • 1: ...

Methods#

extend#

required
extend: () => Markers;

Create a new marker instance which extends this markers.

toString#

required
toString: () => string;

Return a string represenation of this marker, including inherited properties from parent markers.