/** * 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. */ /** * Wrap each text node in a given Node or Range with a `` or other * element. * * If a Range is given that starts and/or ends within a Text node, that node * will be split in order to only wrap the contained part in the mark element. * * The highlight can be removed again by calling the function that cleans up the * wrapper elements. Note that this might not perfectly restore the DOM to its * previous state: text nodes that were split are not merged again. One could * consider running `range.commonAncestorContainer.normalize()` afterwards to * join all adjacent text nodes. * * @param target - The Node/Range containing the text. If it is a Range, note * that as highlighting modifies the DOM, the Range may be unusable afterwards. * @param tagName - The element used to wrap text nodes. Defaults to `'mark'`. * @param attributes - An object defining any attributes to be set on the * wrapper elements, e.g. its `class`. * @returns A function that removes the created highlight. * * @public */ export declare function highlightText(target: Node | Range, tagName?: string, attributes?: Record): () => void; //# sourceMappingURL=highlight-text.d.ts.map