/** * SPDX-FileCopyrightText: 2016-2021 The Apache Software Foundation * SPDX-License-Identifier: Apache-2.0 * @license * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * TextRange is a Range that guarantees to always have Text nodes as its start * and end nodes. To ensure the type remains correct, it also restricts usage * of methods that would modify these nodes (note that a user can simply cast * the TextRange back to a Range to remove these restrictions). */ export interface TextRange extends Range { readonly startContainer: Text; readonly endContainer: Text; cloneRange(): TextRange; insertNode(node: Text): void; selectNodeContents(node: Text): void; setEnd(node: Text, offset: number): void; setStart(node: Text, offset: number): void; selectNode(node: never): void; setEndAfter(node: never): void; setEndBefore(node: never): void; setStartAfter(node: never): void; setStartBefore(node: never): void; surroundContents(newParent: never): void; } /** * Normalise a {@link https://developer.mozilla.org/en-US/docs/Web/API/Range | * Range} such that ranges spanning the same text become exact equals. * * *Note: in this context ‘text’ means any characters, including whitespace.* * Normalises a range such that both its start and end are text nodes, and that * if there are equivalent text selections it takes the narrowest option (i.e. * it prefers the start not to be at the end of a text node, and vice versa). * * If there is no text between the start and end, they thus collapse onto one a * single position; and if there are multiple equivalent positions, it takes the * first one; or, if scope is passed, the first equivalent falling within scope. * * Note that if the given range does not contain non-empty text nodes, it may * end up pointing at a text node outside of it (before it if possible, else * after). If the document does not contain any text nodes, an error is thrown. */ export declare function normalizeRange(range: Range, scope?: Range): TextRange; //# sourceMappingURL=normalize-range.d.ts.map