diff options
| author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2024-01-31 08:40:57 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-31 13:40:57 +0000 |
| commit | 2356223942a21d1683ac38eed8e7b9485f453d87 (patch) | |
| tree | 4e97b53a9d4829378ebc60eb5b8e40b6f5b665ee /types | |
| parent | 87ed7c8affd3ade9d3cd2d9ed1a61dd5f224e473 (diff) | |
Document util + google docs util state refactor (#590)
* Remove static from GoogleDocsUtil since it has state
* Create TextSourceGenerator
* Remove DocumentUtil custom registrations
* Use TextSourceGenerator
Diffstat (limited to 'types')
| -rw-r--r-- | types/ext/display.d.ts | 2 | ||||
| -rw-r--r-- | types/ext/document-util.d.ts | 16 | ||||
| -rw-r--r-- | types/ext/text-scanner.d.ts | 2 | ||||
| -rw-r--r-- | types/ext/text-source-generator.d.ts | 33 |
4 files changed, 37 insertions, 16 deletions
diff --git a/types/ext/display.d.ts b/types/ext/display.d.ts index b11d54e1..da24af75 100644 --- a/types/ext/display.d.ts +++ b/types/ext/display.d.ts @@ -17,6 +17,7 @@ import type {DisplayContentManager} from '../../ext/js/display/display-content-manager'; import type {HotkeyHelpController} from '../../ext/js/input/hotkey-help-controller'; +import type {TextSourceGenerator} from '../../ext/js/dom/text-source-generator'; import type * as Dictionary from './dictionary'; import type * as Extension from './extension'; import type * as Settings from './settings'; @@ -127,6 +128,7 @@ export type GetSearchContextCallback = TextScannerTypes.GetSearchContextCallback export type QueryParserConstructorDetails = { getSearchContext: GetSearchContextCallback; + textSourceGenerator: TextSourceGenerator; }; export type QueryParserOptions = { diff --git a/types/ext/document-util.d.ts b/types/ext/document-util.d.ts index 3f042c97..ec862596 100644 --- a/types/ext/document-util.d.ts +++ b/types/ext/document-util.d.ts @@ -15,8 +15,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import type * as TextSource from './text-source'; - export type NormalizedWritingMode = 'horizontal-tb' | 'vertical-rl' | 'vertical-lr' | 'sideways-rl' | 'sideways-lr'; /** @@ -34,20 +32,6 @@ export type GetRangeFromPointOptions = { normalizeCssZoom: boolean; }; -/** - * Scans the document for text or elements with text information at the given coordinate. - * Coordinates are provided in [client space](https://developer.mozilla.org/en-US/docs/Web/CSS/CSSOM_View/Coordinate_systems). - * @returns A range for the hovered text or element, or `null` if no applicable content was found. - */ -export type GetRangeFromPointHandler = ( - /** The x coordinate to search at. */ - x: number, - /** The y coordinate to search at. */ - y: number, - /** Options to configure how element detection is performed. */ - options: GetRangeFromPointOptions, -) => (TextSource.TextSource | null); - export type ToNumberConstraints = { min?: string | number; max?: string | number; diff --git a/types/ext/text-scanner.d.ts b/types/ext/text-scanner.d.ts index ff56b443..3e1cb6c2 100644 --- a/types/ext/text-scanner.d.ts +++ b/types/ext/text-scanner.d.ts @@ -16,6 +16,7 @@ */ import type {TextScanner} from '../../ext/js/language/text-scanner'; +import type {TextSourceGenerator} from '../../ext/js/dom/text-source-generator'; import type * as Dictionary from './dictionary'; import type * as Display from './display'; import type * as Input from './input'; @@ -145,6 +146,7 @@ export type ConstructorDetails = { searchKanji?: boolean; searchOnClick?: boolean; searchOnClickOnly?: boolean; + textSourceGenerator: TextSourceGenerator; }; export type SearchContext = { diff --git a/types/ext/text-source-generator.d.ts b/types/ext/text-source-generator.d.ts new file mode 100644 index 00000000..13d88c3f --- /dev/null +++ b/types/ext/text-source-generator.d.ts @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2024 Yomitan Authors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +import type {TextSource} from './text-source'; +import type {GetRangeFromPointOptions} from './document-util'; + +/** + * Scans the document for text or elements with text information at the given coordinate. + * Coordinates are provided in [client space](https://developer.mozilla.org/en-US/docs/Web/CSS/CSSOM_View/Coordinate_systems). + * @returns A range for the hovered text or element, or `null` if no applicable content was found. + */ +export type GetRangeFromPointHandler = ( + /** The x coordinate to search at. */ + x: number, + /** The y coordinate to search at. */ + y: number, + /** Options to configure how element detection is performed. */ + options: GetRangeFromPointOptions, +) => (TextSource | null); |