Skip to main content

$setDirectionFromDOM

function

Reads the `dir` attribute from a DOM element and applies it to the given ElementNode via ElementNode.setDirection when it is a valid direction value (`'ltr'` or `'rtl'`). Other values, including missing or empty `dir`, leave the node unchanged. Useful inside `importDOM` converters to preserve explicit text direction from imported HTML.

function $setDirectionFromDOM<T extends ElementNode>(node: T, domNode: HTMLElement): T

Import

import { $setDirectionFromDOM } from '@modular/sdk/editor';

Notes

returns
The node, with its direction set when the source `dir` was valid.