Commit 935594b9 authored by Robert Knight's avatar Robert Knight

Improve `TextQuoteAnchor` JSDoc and remove obsolete lint suppression

parent f307c817
...@@ -133,6 +133,11 @@ export class TextPositionAnchor { ...@@ -133,6 +133,11 @@ export class TextPositionAnchor {
} }
} }
/**
* @typedef QuoteMatchOptions
* @prop {number} [hint] - Expected position of match in text. See `matchQuote`.
*/
/** /**
* Converts between `TextQuoteSelector` selectors and `Range` objects. * Converts between `TextQuoteSelector` selectors and `Range` objects.
*/ */
...@@ -151,6 +156,10 @@ export class TextQuoteAnchor { ...@@ -151,6 +156,10 @@ export class TextQuoteAnchor {
} }
/** /**
* Create a `TextQuoteAnchor` from a range.
*
* Will throw if `range` does not contain any text nodes.
*
* @param {Element} root * @param {Element} root
* @param {Range} range * @param {Range} range
*/ */
...@@ -200,21 +209,16 @@ export class TextQuoteAnchor { ...@@ -200,21 +209,16 @@ export class TextQuoteAnchor {
} }
/** /**
* @param {Object} [options] * @param {QuoteMatchOptions} [options]
* @param {number} [options.hint] -
* Offset hint to disambiguate matches
*/ */
toRange(options = {}) { toRange(options = {}) {
return this.toPositionAnchor(options).toRange(); return this.toPositionAnchor(options).toRange();
} }
/** /**
* @param {Object} [options] * @param {QuoteMatchOptions} [options]
* @param {number} [options.hint] -
* Character offset hint to disambiguate matches.
*/ */
toPositionAnchor(options = {}) { toPositionAnchor(options = {}) {
// eslint-disable-line no-unused-vars
const text = /** @type {string} */ (this.root.textContent); const text = /** @type {string} */ (this.root.textContent);
const match = matchQuote(text, this.exact, { const match = matchQuote(text, this.exact, {
...this.context, ...this.context,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment