Commit Graph

122 Commits

Author SHA1 Message Date
toasted-nutbread
5e707248ce
Fix text selection not always working properly (#2246) 2022-10-15 11:40:22 -04:00
toasted-nutbread
75d3059451
TextSource* API updates (#2236)
* Move TextSourceRange static functions to DocumentUtil

getWritingMode is also simplified

* Update Google Docs range to be empty to match other range sources

* Rename imposterContainer to imposterElement

* Add static creation functions

* Add static creation function

* Remove unused collapse function

* Don't select imposter elements

* Refactor setEndOffset

* Adjust argument order for setEndOffset

* Update TextSourceRange constructor

* Remove unused isConnected

* Cache rects

* Fix test

* Remove unused getRect

* Revert "Fix test"

* Remove cachedRect

* Use the source element rect to handle scroll differences

* Writing mode update

* Remove _cachedRects update

This shouldn't be necessary as the imposter is usually detached
almost immediately after scanning, giving no time for the window
to be resized or scrolled.
2022-09-25 09:37:33 -04:00
toasted-nutbread
1e91bf151f
DocumentUtil static (#2232)
* Make all methods static

The two non-static methods are kept for temporary compatibility

* Use this instead of class name now that functions are static

* Update test

* Don't instantiate DocumentUtil

* Remove temporary non-static methods

* Remove unused global declaration
2022-09-24 16:05:19 -04:00
toasted-nutbread
480869c3d1
Exclude documentElement from zoom calculation (#2227)
* Exclude documentElement from zoom calculation

* Add an option

* Refactor zoom coordinate conversion functions

* Convert zoom coordinates for text sources

* Rename variable

* Convert rect coordinate spaces

* Handle shadow DOM
2022-09-20 21:06:39 -04:00
toasted-nutbread
cd0a6b60e2
Fix setEndOffset (#2214)
* Add _layoutAwareScan option to TextSourceElement.setEndOffset for parity

* Remove default param
2022-08-20 12:38:55 -04:00
oakkitten
49c75c3093
Do not change selection if user selected text manually (#2186)
* Do not change selection if user selected text manually

* Remove capture argument for selectionchange listener

It is not applicable

* Make a note of user selection when Yomichan is enabled

User might have some text selected on a page prior to enabling Yomichan
via the toolbar icon; let it stay intact.

* Extract selection change by user listener into a method
2022-07-01 17:12:55 -04:00
toasted-nutbread
4545900f70
TextScanner refactor (#2174)
* Refactor input conversion, add additional validation

* Simplify input data structure
2022-06-05 22:46:00 -04:00
toasted-nutbread
c966d9b1eb
Touch and pen input updates (#2172)
* Remove unnecessary return

* Move touch start input filtering

* Refactor

* Add scanOnTouchPress

* Add preventPenScrolling

* Rename scanOnPenPress to scanOnPenMove

* Rename scanOnPenRelease to scanOnPenReleaseHover

* Simplify

* Refactor _searchAtFromPen early exit

* Merge _penPointerPressed and _penPointerReleased into a single variable

* Add more options

* Simplify pen pointer coordinates

* Implement scanOnPenPress and scanOnPenRelease

* Implement scanOnTouchRelease

* Fix tests

* Don't search on touch cancel

* Cancel touch if the touch action is used for scrolling or other gestures

* Fix incorrect scroll prevention options being used

* Organize options

* Fix typos
2022-06-03 17:11:32 -04:00
toasted-nutbread
f3024c5018
Sort using number of definitions (#2166) 2022-05-29 20:53:21 -04:00
toasted-nutbread
5d0c22e76d
Sort using frequency dictionary before using dictionary priority (#2165) 2022-05-29 13:32:22 -04:00
toasted-nutbread
31e20c889e
ESlint JSdoc (#2148)
* Install eslint-plugin-jsdoc

* Initial rules setup

* Update lists

* Use @returns rather than @return

* Remove error throwing code which is never executed

* Fix issues relating to @throws

* General error fixes

* Update Display type documentation

* Various doc fixes

* Fix invalid tuple syntax

* Doc updates

* Remove unused

* Doc updates

* Enable jsdoc/require-returns

* Update rules

* Update remaining rules
2022-05-20 10:28:38 -04:00
toasted-nutbread
ae0ad227c0
Add mode documentation about the types used by Translator (#2147) 2022-05-19 20:16:40 -04:00
toasted-nutbread
6b88501afd
Text scanner event capture (#2101)
* Add capture parameter to event listeners

* Enable capture
2022-04-02 13:10:39 -04:00
toasted-nutbread
89ac85afd0
Update copyright date (#2062)
* Update eslint settings

* Update 2021 files

* Update other files
2022-02-02 20:43:10 -05:00
toasted-nutbread
0e52a1f509
Scanning wildcards (#2042)
* Add scanning.matchTypePrefix option

* Update TextScanner to use matchTypePrefix option

* Add setting

* Update warning
2021-12-18 12:38:39 -05:00
toasted-nutbread
8a377cabe6
matchType/deinflect distinction (#2040)
* Pass a "deinflect" option to findTerms

* Update Translator to use deinflect option

* Fix test input options
2021-12-17 17:02:13 -05:00
toasted-nutbread
8e548a17eb
Dictionary database term source info (#2039)
* Update DictionaryDatabase._findMultiBulk's createResult callback signature

* Simplify _splitField use

* Update sequence

* Expose new fields 'matchType' and 'matchSource' as part of term data

* Expose matchType and matchSource as part of TermSource

* Update sourceTermExactMatchCount calculation

* Update test data

* Expose matchType and matchSource info in HTML attributes

* Add primaryMatchTypes attribute
2021-12-17 16:44:14 -05:00
toasted-nutbread
19ab9df6e4
Replace 'wildcard' parameter with 'matchType' (#2038) 2021-12-17 16:11:19 -05:00
toasted-nutbread
36967b1839
General refactoring (#2016)
* Remove // Public comments

* Fix errors

* Remove source parameter from Popup*.setOptionsContext
2021-11-21 12:34:57 -05:00
toasted-nutbread
75aabd983d
String frequency support (#1989)
* Restore support for string frequency values

* Add support for {value, displayValue} frequencies

* Update test data

* Improve number parsing of string frequencies

* Improve reading detection

* Expose a displayValue property for frequency information

* Update docs

* Expose displayValue to Anki note data

* Fix translator

* Update display generation

* Update test data

* Update counts
2021-10-14 21:26:53 -04:00
toasted-nutbread
b0f6c41f5d
Search query offset value (#1968)
* Add type property to TextSource* classes

* Use type property rather than instanceof

* Expose a sentence offset value

* Use offset added to URL

* Improve fallback sentence for Anki note context
2021-09-27 19:07:28 -04:00
toasted-nutbread
b784e5b11a
Katakana to hiragana conversion options (#1965)
* Refactor convertKatakanaToHiragana

* Add keepProlongedSoundMarks option

* Test keepProlongedSoundMarks option

* Refactor

* Add keepProlongedSoundMarks option to hiragana handlebars helper

* Update documentation
2021-09-27 18:19:53 -04:00
toasted-nutbread
d739ccd63f
Fix japanese codepoint range issues (#1960)
* Add CJK_COMPATIBILITY_IDEOGRAPHS_RANGE

* Rename CJK_UNIFIED_IDEOGRAPHS_RANGES => CJK_IDEOGRAPH_RANGES

* Simplify isKana check

* Update tests
2021-09-26 13:29:55 -04:00
toasted-nutbread
25fe3ba514
Revert term/reading string normalization due to undesirable changes (#1959) 2021-09-26 13:29:50 -04:00
toasted-nutbread
6694a9d9c3
Enable frequency dictionaries to specify the frequency mode (#1944) 2021-09-26 11:08:25 -04:00
toasted-nutbread
c15683d206
Ensure frequency values are always numbers (#1943) 2021-09-26 11:08:21 -04:00
toasted-nutbread
9899727d7d
Frequency dictionary sort (#1938)
* Add sortDictionary/sortDictionaryOrder options

* Update options

* Add API.getTermFrequencies

* Add settings

* Implement frequency dictionary sorting

* Update test

* Update test data

* Fix handling of undefined rank-based frequencies
2021-09-26 11:08:16 -04:00
toasted-nutbread
dfddf3792e
Fix redundant secondary term lookups (#1942) 2021-09-09 23:29:41 -04:00
toasted-nutbread
7883d39496
Normalize terms and readings during import (#1941) 2021-09-09 23:25:24 -04:00
toasted-nutbread
ac12b50939
Dictionary import count details (#1935)
* Store count information when importing a dictionary

* Add importDate

* Update property ordering

* Update tests

* Update importDate
2021-09-07 11:12:58 -04:00
toasted-nutbread
b988417031
Fix incorrect index being used for headword removal (#1933) 2021-09-05 21:07:23 -04:00
toasted-nutbread
97a80276f6
Database readwrite transaction updates (#1932)
* Add _readWriteTransaction helper

* Improve deleteDictionary order

* Make onProgress event optional

* Simplify progress rate parameter
2021-09-05 20:00:08 -04:00
toasted-nutbread
0331374241
Dictionary media import improvements (#1926)
* Add base64ToArrayBuffer to StringUtil

* Remove unnecessary media-util.js import

* Run async requirements in serial rather than parallel

* Update API.getMedia handler to convert ArrayBuffer content to base64

* Rename getImageResolution to getImageDetails

* Change parameter order of getImageDetails

* Pre-process and store media as an ArrayBuffer

* Remove MediaUtil.createBlobFromBase64Content

* Fix Anki media injection
2021-09-03 22:33:58 -04:00
toasted-nutbread
1599ec1f15
Fix dictionary import total progress (#1921)
* Fix incorrect total count for final step of dictionary import

* Update tests to validate progress args
2021-08-31 21:42:18 -04:00
toasted-nutbread
87fbb3c01c
Dictionary worker updates (#1914)
* Add support for running getDictionaryCounts via DictionaryWorker

* Run dictionary integrity checks on a separate thread

* Remove api.getDictionaryCounts
2021-08-28 14:30:50 -04:00
toasted-nutbread
74709296e5
Dictionary database worker refactoring (#1913)
* Rename DictionaryWorker => DictionaryWorkerHandler

* Rename var

* Rename file

* Simplify

* Rename DictionaryDatabaseModifier => DictionaryWorker

* Rename dictionary-database-modifier.js => dictionary-worker.js
2021-08-28 14:22:16 -04:00
toasted-nutbread
b6fc786f9a
Update dictionary importer progress event for step 6 to occur slightly earlier (#1897) 2021-08-14 18:16:30 -04:00
toasted-nutbread
4839503d54
Threaded dictionary delete (#1895)
* Generalize dictionary worker

* Add deleteDictionary functionality

* Update DictionaryController to use DictionaryDatabaseModifier

* Fix incorrect result handling
2021-08-14 12:41:58 -04:00
toasted-nutbread
3e350bd563
Dictionary worker refactor (#1894)
* Rename dictionary worker files

* Rename classes

* Rename file

* Rename class

* Generalize the _invoke method

* Rename 'import' to 'importDictionary'

* Improve DictionaryImporterMediaLoader usage

* Refactor message handler

* Generalize onProgress event
2021-08-14 11:46:26 -04:00
toasted-nutbread
cd78d56fee
Database improvements to data persistency (#1893)
* Fix function check

* Rename arguments of getAll, getAllKeys, and their private functions

* Simplify bulkAdd

* Simplify delete

* Simplify bulkDelete

* Remove persistData
2021-08-13 18:35:31 -04:00
toasted-nutbread
2d5e6f8394
Fix data not being persisted after terminating Worker thread (#1877) 2021-08-07 15:25:00 -04:00
toasted-nutbread
cd3f47a359
Dictionary import progress improvements (#1868)
* Update loop vars

* Update loop

* Improve progress reporting during the import process
2021-07-31 19:13:41 -04:00
toasted-nutbread
01c5c5c04b
Dictionary importer refactoring (#1867)
* Remove map of schemas

* Don't reuse dictionary importer instances

* Refactor

* Update how progress callback is used
2021-07-31 18:08:51 -04:00
toasted-nutbread
1d6e437fb2
Dictionary importer refactor (#1866)
* Move function implementations

* Use file() instead of files[]

* Move functionality into local functions

* Simplify

* Pass dictionary title to conversion functions

* Update how legacy tags are added
2021-07-31 16:53:38 -04:00
toasted-nutbread
8c4a50f68c
DictionaryImporterThreaded (#1865)
* Create new classes for importing dictionaries from a separate thread

* Use threaded importer

* Update worker tests
2021-07-31 14:46:09 -04:00
toasted-nutbread
11f210375e
DictionaryImporter improvements (#1862)
* Improve error message

* Simplify URL for JSON fetching
2021-07-31 14:00:19 -04:00
toasted-nutbread
00c5ae7983
DictionaryImporterMediaLoader (#1860)
* Rename param for consistency

* Move media loading functionality into DictionaryImporterMediaLoader

* Create test class for media loading

* Remove unnecessary Blob/Image/URL functionality
2021-07-31 12:30:31 -04:00
toasted-nutbread
2d57d69b9e
Improve dictionary importer (#1859)
* Optimize dictionary data parsing during import

* Use ArrayBuffer instead of string

* Add missing function for testing
2021-07-31 10:53:35 -04:00
toasted-nutbread
b99850ed54
Call URL.revokeObjectURL for created URLs (#1858)
* Call URL.revokeObjectURL for created URLs

* Refactor image usage
2021-07-29 21:16:55 -04:00
toasted-nutbread
b0596c8a3c
Rename pitchAccent in source code (#1852)
* Rename pitchAccentPosition to pitchAccentDownstepPosition

* Rename function

* Rename

* Rename

* pitches => pronunciations
2021-07-26 19:45:30 -04:00