Commit Graph

376 Commits

Author SHA1 Message Date
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
6cc57d953d
Settings modal updates (#2173)
* Move the "Add" button into the footer

* Scroll to the bottom when adding

* Move the Audio Sources add button

* Simplify, remove the (?) link

* Move "Add" button to footer
2022-06-03 18:19:40 -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
aa5e13b441
Collapsible dictionary updates (#2170)
* Add "force collapsed" and "force expanded" options

* Simplify "any" check

* Update style

* Add help modal for collapsible dictionaries

* Disable wrapping
2022-05-30 13:34:37 -04:00
toasted-nutbread
19bba07a8b
Add support for Anki API key (#2169)
* Update material.css to support password fields

* Support password

* Add "apiKey" setting

* Use apiKey

* Update options if API key changes

* Update tests
2022-05-30 12:03:24 -04:00
toasted-nutbread
0b5d54e7c6
Rename anki.js to anki-connect.js to more accurately reflect class name (#2167) 2022-05-29 21:42:26 -04:00
toasted-nutbread
331a2e6294
Add support for guiEditNote to view notes (#2143)
* Add AnkiConnect.guiEditNote

* Update _onApiNoteView to first try guiEditNote

* Add setting

* Update noteView API

* Use setting

* Return which mode was used

* Update DisplayGenerator

* Handle errors in DisplayAnki

* Update docs

* Add isErrorUnsupportedAction function

* Add an allowFallback option to noteView

* Disambiguate

* Simplify now that preferredMode isn't used

* Update settings info

* Implement test buttons

* Update styles

* Update status visibility

* Wrap layout

* Update description

* Update date
2022-05-29 21:24:41 -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
46fda6e653
Update referenceUrl to include fragment (#2164) 2022-05-29 12:02:31 -04:00
toasted-nutbread
47194926f3
Add an issues page with information about some errors (#2163) 2022-05-28 22:22:15 -04:00
toasted-nutbread
0d82c52a76
HTML page script refactoring (#2162)
* Move some common functionality

* Move setupEnvironmentInfo into ExtensionContentController

* Move background/environment.js to extension/environment.js
2022-05-28 21:57:25 -04:00
toasted-nutbread
4e4fa49b0b
Audio request errors (#2161)
* Generalize _onBeforeSendHeadersAddListener

* Simplify filter assignment

* Use requestId rather than done

* Properly support Firefox addListener without arguments

* Add details to fetchAnonymous errors

* Refactor

* Enable support for no header modifications

* Update MV3 support for error details

* Expose errors in downloadTermAudio

* Throw an error if audio download fails due to potential permissions reasons
2022-05-28 21:55:37 -04:00
toasted-nutbread
756cfc0276
Use \f rather than \x0C for whitespace form feed (#2158) 2022-05-22 13:11:38 -04:00
toasted-nutbread
259a3031ce
Add apiReflect and apiExists to AnkiConnect (#2150) 2022-05-22 11:26:49 -04:00
toasted-nutbread
5dbc284d53
Simplify assignment of _contentType = 'clear' (#2154) 2022-05-21 17:54:57 -04:00
toasted-nutbread
fd00a52856
Anki findNotes (#2152)
* Add findNotes API

* Add api.findAnkiNotes
2022-05-21 15:28:44 -04:00
toasted-nutbread
e498e2d029
Display notification updates (#2149)
* Expose container and node on DisplayNotification

* Add Display.createNotification

* Rename methods

* Rename fields

* Remove double newline
2022-05-20 18:08:20 -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
6e239638bb
DOMTextScanner updates (#2146)
* JSDoc updates

* Move function

* Simplify

* Refactor return type

* Refactor getElementSeekInfo return type
2022-05-18 21:43:19 -04:00
toasted-nutbread
a33a00f5ae
CssStyleApplier updates (#2145)
* Update internal structure of _styleData

* Rename parameter

* Rename

* Add docs
2022-05-18 19:40:47 -04:00
toasted-nutbread
18beb241a7
Fix this._horizontalTextPositionBelow being assigned incorrectly (#2144) 2022-05-18 19:12:24 -04:00
toasted-nutbread
bd53f2bbfb
Update _getNodeNoteIds to return integer IDs (#2142) 2022-05-16 22:20:53 -04:00
toasted-nutbread
63d37c872b
Popup positioning improvements (#2135)
* Rename elementRect to sourceRect

* Add getRects function to TextSourceElement and TextSourceRange

* Add jsdocs

* Remove unnecessary valid parameter

* Remove default parameter

* Make optionsContext optional

* Remove unnecessary checks

* Update sourceRect to use left/right rather than x/y

* Update the return type of Popup*.getFrameRect

* Rename some unrelated rect vars for disambiguation

* Disambiguate between Popup.Rect and Popup.ValidRect

* Move sourceRect destructuring

* Pass multiple source rects

* Simplify

* Change Rect to use right/bottom rather than width/height

* Update how popup offset is applied

* Simplify frame offset

* Remove _applyFrameOffset

* Use right/bottom rather than width/height

* Simplify some positioning settings

* Update parameter names for clarity

* Fix typos

* Refactor data type for _getPosition* functions

* Support using multiple source rects

* Combine _getPosition functions

* Refactor

* Expose after dataset value

* Consistently use this's property

* Add jsdoc
2022-05-16 21:45:22 -04:00
toasted-nutbread
fd75e91e75
Ignore DOMExceptions thrown by assigning an invalid dataset property (#2133) 2022-05-14 18:16:13 -04:00
toasted-nutbread
8b6f526dc6
Regex optimizations (#2132)
* Remove regex construction for SimpleDOMParser.getElementsByClassName

* Remove regex construction for CssStyleApplier._getRulesForClass

* Rename, add jsdoc for clarity
2022-05-14 18:13:04 -04:00
toasted-nutbread
5dcc2315d2
Structured content auto language (#2131)
* Pass JapaneseUtil instance to StructuredContentGenerator

* Move body of createStructuredContent to an internal function

* Create _createStructuredContentGenericElement

* Wrap structured content in a <span>

* Change _createStructuredContent to _appendStructuredContent

* Add public appendStructuredContent function

* Add missing return

* Remove unused _createDocumentFragment

* Automatically assign lang=ja for content with Japanese characters
without an explicit language

* Add test
2022-05-14 18:12:57 -04:00
Stephen Kraus
6a74746113
Add new structured content features: lists and the HTML lang attribute (#2129)
* Add support for structured content lists and `list-style-type` style

A full list of supported style types is documented here:
https://developer.mozilla.org/en-US/docs/Web/CSS/list-style-type

There's nothing in this code preventing a term bank from assigning,
for example, a `list-style-type` style to a `div` element, but it
doesn't seem like browsers will complain about things like that.

* Add support for `lang` attribute in structured content

Support added for the following node types:

"ruby", "rt", "rp", "table", "thead", "tbody", "tfoot", "tr", "td",
"th", "span", "div", "ol", "ul", "li", "a"

I couldn't get it to work for the alt-hover text on "img" tags.

Tests are included in the file
"test/data/dictionaries/valid-dictionary/term_bank_1.json"

* Add styles for structured content lists

* Add override rules for new structured-content list styles

see: https://github.com/FooSoft/yomichan/pull/2129

Co-authored-by: stephenmk <stephenmk@users.noreply.github.com>
2022-05-14 09:59:38 -04:00
toasted-nutbread
e5b53bb238
Hide popup on cursor exit (#2109)
* Update phrasing

* Add new options

* Add settings

* Implement
2022-04-03 22:52:53 -04:00
toasted-nutbread
b896724aac
Update Popup to not store the full options object (#2106) 2022-04-03 17:09:51 -04:00
toasted-nutbread
f61690ea2c
Theme updates (#2105)
* Change siteColor to siteTheme

* Fix potential null exception

* Simplify

* Update display theme assignment

* Add a data-browser-theme attribute

* Add "browser" option for theme

* Create ThemeController

* Add theme-controller.js to relevant pages

* Use ThemeController

* Simplify

* Fix 'light' being used instead of 'default'

* Update the settings values to more accurately reflect their usage

* Change default site theme in display.js

* Remove async

* Restore async for consistency
2022-04-03 16:20:55 -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
8a1dcbc9f5
Workaround for Google Docs canvas rendering updates (#2096) 2022-04-02 09:38:40 -04:00
toasted-nutbread
7a2ab86609
Structured content links (#2089)
* Update CSS to JSON converter to generalize the remove-property comment

* Fix navigation not being updated when _clearContent is run

* Add structured content schema for link tags

* Add test links

* Add external-link icon

* Pass Display instance to DisplayContentManager

* Update structured content generation

* Update link styles
2022-03-17 19:01:59 -04:00
toasted-nutbread
8aa060337c
AnkiTemplateRendererContentManager (#2088)
* Make function private

* Update comments

* Refactor the content manager that is provided to StructuredContentGenerator in AnkiTemplateRenderer

* Update function to not be async, for API parity
2022-03-14 22:32:08 -04:00
toasted-nutbread
4e15f92329
Rename MediaLoader to DisplayContentManager (#2087) 2022-03-14 21:42:33 -04:00
toasted-nutbread
59ae55252e
Update ClipboardReader.getImage implementation (#2085) 2022-03-13 21:17:48 -04:00
toasted-nutbread
f98f5f9395
Improve Anki storeMediaFile (#2084)
* Use the return value of storeMediaFile

* Update documentation
2022-03-13 21:17:41 -04:00
toasted-nutbread
1590f5218c
Add additional Anki card marker aliases (#2083) 2022-03-13 21:17:35 -04:00
toasted-nutbread
48b2807120
Add support for logging Anki errors on the settings page (#2073) 2022-02-20 09:35:54 -05:00
toasted-nutbread
89a939eb39
Update anki card frequency (#2065)
* Prefer to use displayValue for Anki card frequency values

* Update test data
2022-02-05 21:35:03 -05: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
258f1b629a
Update sentence termination characters (#2059)
* Add vertical punctuation to terminationCharacters

* Upgrade settings

* Update tests
2022-02-02 20:09:13 -05:00
archiif
faa5ed7184
Set Content-Type header of AnkiConnect requests to application/json 2022-01-05 01:44:47 +07: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