Commit Graph

162 Commits

Author SHA1 Message Date
toasted-nutbread
d3807d88ec
ArrayBufferUtil (#2215)
* Rename StringUtil to ArrayBufferUtil

* Update docs

* Rename file string-util.js to array-buffer-util.js
2022-08-20 12:53:22 -04:00
toasted-nutbread
5c267f4bb7
Profile index fixes (#2207)
* Update settings controller to consistently initialize

* Allow profile index to be reset if an error occurs

* Update message handler to be async

* Fix error when deleting the current profile
2022-08-20 11:31:50 -04:00
toasted-nutbread
310303ca1a
Audio download timeout (#2187)
* Add support for an idle timeout when downloading audio

* Update eslint rules

* Pass idleTimeout to the downloader from DisplayAnki

* Add anki.downloadTimeout setting

* Update tests

* Assign _audioDownloadIdleTimeout using settings

* Show info about cancelled downloads

* Handle Firefox bug

* Improve audio errors

* Refactor

* Move functions to RequestBuilder
2022-08-20 11:17:24 -04:00
Stephen Kraus
c331ceae99
Add new structured content styling options (#2203)
Allow for arbitrary string assignment to the font-size property.
https://developer.mozilla.org/en-US/docs/Web/CSS/font-size

Add support for the text-align property.
https://developer.mozilla.org/en-US/docs/Web/CSS/text-align

Co-authored-by: stephenmk <stephenmk@users.noreply.github.com>
2022-08-14 13:30:25 -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
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
47194926f3
Add an issues page with information about some errors (#2163) 2022-05-28 22:22:15 -04:00
toasted-nutbread
5dbc284d53
Simplify assignment of _contentType = 'clear' (#2154) 2022-05-21 17:54:57 -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
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
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
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
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
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
fced59a213
Fix source name not being used (#2036) 2021-12-14 22:03:34 -05:00
toasted-nutbread
005f9658d9
Action handler name disambiguation (#2018)
* Disambiguate PopupFactory action handlers

* Update HotkeyHandler action names

* Disambiguate Frontend action handlers

* Disambiguate Display action handlers

* Disambiguate PopupPreviewFrame action handlers

* Disambiguate Yomichan action handlers

* Disambiguate Frontend action handlers

* Disambiguate Display action handlers

* Disambiguate SearchDisplayController action handlers
2021-11-21 15:54:58 -05:00
toasted-nutbread
657292733d
Fix search page not being cleared properly (#2005) 2021-11-13 09:29:58 -05:00
toasted-nutbread
f978819a33
Don't stop audio playback when hiding a popup (#1995) 2021-10-21 19:56:43 -04:00
toasted-nutbread
9ae38bd8e9
Display menu button (#1992)
* Implement new menu which includes a debug log option

* Update wording
2021-10-17 09:55:13 -04:00
toasted-nutbread
ca4ed0300b
Display button updates (#1991)
* Update display buttons

* Remove use of _addMultipleEventListeners
2021-10-17 00:15:43 -04: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
11f7591a7f
Fix query being set to null when an empty search page is opened (#1988) 2021-10-14 21:16:40 -04:00
toasted-nutbread
0a8992d215
Search query back button (#1981)
* Always allow history to go back/forward when using browser history

* Add a back button which is visible when using the query parser
2021-10-09 17:06:51 -04:00
toasted-nutbread
be8ef53e90
Display refactoring (#1978)
* Refactor _setContentTermsOrKanji

* Update query assignment

* Simplify

* Remove redundant _updateQueryParser

* Reorder query assignment

* Remove isTerms, replace with isKanji

* Simplify defaults

* Refactor events

* Update DisplayAnki to use events

* Simplify

* Update DisplayAudio to use events

* Simplify

* Move audio hotkeys

* Add frameVisibilityChange event

* Fix name

* Add logDictionaryEntryData event

* Move clearAutoPlayTimer handler

* Fix call

* Externalize DisplayAnki and DisplayAudio from Display

* Simplify clear
2021-10-03 16:46:15 -04:00
toasted-nutbread
55a7e7f9a8
Hotkey dictionary navigation fix (#1970)
* Add getRect function to ScrollElement

* Update _focusEntry to take a definition index

* Update behaviour of (next|previous)EntryDifferentDictionary
2021-09-30 19:31:45 -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
729abbf561
Remove display query post process (#1967)
* Remove search query post-processing

* Remove _rawQuery, as it is redundant with _query
2021-09-26 22:14:52 -04:00
toasted-nutbread
88e71f8223
Add data-is-primary attribute to headwords (#1946) 2021-09-11 12:51:51 -04:00
toasted-nutbread
f68ad1f843
Structured content data (#1930)
* Add support for structured-content data attributes

* Assign dataset properties

* Don't remove data-sc attributes

* Use helper functions

* Update test data
2021-09-04 12:43:56 -04:00
toasted-nutbread
eb457caea9
Fix repeated note IDs shown on the "View Note" button (#1927) 2021-09-03 22:42:27 -04:00
toasted-nutbread
02194fcb9f
Add support for structured content margins (#1920) 2021-08-31 21:08:30 -04:00
toasted-nutbread
ce1a862df4
Fix empty sentence on some search page URLs (#1919) 2021-08-31 20:45:29 -04:00
toasted-nutbread
3e7f3af63c
Fix history replacement issue (#1917)
* Remove unused "history" field of event details

* Change setContent history parameter to historyMode
2021-08-30 21:55:08 -04:00
toasted-nutbread
916189f402
Fix auto-play not working on the search page (#1882) 2021-08-10 19:23:05 -04:00
toasted-nutbread
edb0aaf6b4
Improve audio auto play cancellation (#1873)
* Cancel automatic audio playback when hiding the popup

* Don't play audio if the popup is hidden
2021-08-02 19:25:10 -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
toasted-nutbread
a9710b8acf
Rename CSS class names "pitch-accent" to "pronunciation" (#1850)
* pitch-accents => pronunciations

* Update dataset property names

* pitch-accent-dictionary => pronunciation-dictionary

* Update styles

* Update template name

* Update attributes
2021-07-25 18:16:07 -04:00
toasted-nutbread
73f06a3fa0
Fix definition image aspect ratio issue (#1847)
* Fix incorrect aspect ratio

* Update test data
2021-07-22 18:11:46 -04:00
toasted-nutbread
637d4a2087
Pronunciation template helper (#1840)
* Rename field

* Set up pronunication components

* Fix documentation

* Rename function

* Update test dependencies

* Fix constructor

* Log errors

* Add pronunciation helper

* Add styleApplier argument to _getHtml/_normalizeHtml

* Use getAttribute for 'class' to support namespaced elements (e.g. svg)

* Update format name

* Add optional tag

* Update docs
2021-07-18 13:43:11 -04:00