Range API
9 min
range objects are a set of points that refer to a specific span of a slate document they can define a span inside a single node or they can span across multiple nodes the editor's selection is stored as a range interface range { anchor point focus point } static methods docid\ tzlrepy2zsmwfd1aidsrxretrieval methods docid\ tzlrepy2zsmwfd1aidsrxcheck methods docid\ tzlrepy2zsmwfd1aidsrxtransform methods docid\ tzlrepy2zsmwfd1aidsrx static methods retrieval methods range edges(range range, options?) => \[point, point] get the start and end points of a range , in the order in which they appear in the document options {reverse? boolean} range end(range range) => point get the end point of a range according to the order in which it appears in the document range intersection(range range, another range) => range | null get the intersection of one range with another if the two ranges do not overlap, return null range points(range range) => generator\<pointentry> iterate through the two point entries in a range first it will yield a pointentry representing the anchor , then it will yield a pointentry representing the focus range start(range range) => point get the start point of a range according to the order in which it appears in the document check methods check some attribute of a range always returns a boolean range equals(range range, another range) => boolean check if a range is exactly equal to another range includes(range range, target path | point | range) => boolean check if a range includes a path, a point, or part of another range for clarity the definition of includes can mean partially includes another way to describe this is if one range intersectns the other range range isbackward(range range) => boolean check if a range is backward, meaning that its anchor point appears after its focus point in the document range iscollapsed(range range) => boolean check if a range is collapsed, meaning that both its anchor and focus points refer to the exact same position in the document range isexpanded(range range) => boolean check if a range is expanded this is the opposite of range iscollapsed and is provided for legibility range isforward(range range) => boolean check if a range is forward this is the opposite of range isbackward and is provided for legibility range isrange(value any) => value is range check if a value implements the range interface transform methods range transform(range range, op operation, options) => range | null transform a range by an op options {affinity 'forward' | 'backward' | 'outward' | 'inward' | null}