Commit Graph

298 Commits

Author SHA1 Message Date
johan456789
06f1aeb052 fix help url paths 2020-10-10 00:38:07 +08:00
Damien Elmes
8fa865e8f4
Merge pull request #781 from hgiesel/leftbtns
Refactor Buttons in editor and add editor_did_init_left_buttons gui_hook
2020-10-05 13:14:52 +10:00
Henrik Giesel
e9ca17b1b3 Turn _class into rightside boolean flag 2020-10-04 23:03:37 +02:00
Henrik Giesel
e8c80174eb Refactor out theclass assignment 2020-10-04 22:51:34 +02:00
Henrik Giesel
4c255b0289 Add editor_did_init_left_buttons gui_hook 2020-10-04 22:50:02 +02:00
Henrik Giesel
bf29fb8e83 Make icon Optional explicitly in function signature 2020-10-04 22:42:28 +02:00
Henrik Giesel
30d1d57c78 Rewrite so all editor toolbar buttons use _addButton 2020-10-04 22:41:18 +02:00
abdo
dbc820ba6f Paste links as plain text in basic mode 2020-10-03 19:46:05 +03:00
abdo
8c0bfd7d1d Recognize ico files
Local icons were being pasted as normal links previously instead of
being enclosed in img tags.
2020-10-03 00:17:38 +03:00
abdo
151f854fa2 Support extended drag & drop 2020-09-14 17:07:31 +03:00
Damien Elmes
0455e760c6 another showDupes fix from ANH
https://forums.ankiweb.net/t/show-duplicates-not-working/2883/10
2020-09-04 10:13:30 +10:00
Damien Elmes
21749a3b0c sound tags need filename html escaped
https://forums.ankiweb.net/t/unable-to-play-longer-audio-on-cards/1313/30
2020-09-04 09:36:38 +10:00
Damien Elmes
dc1f489d3e Revert "Merge pull request #749 from ANH25/editor-media-autoplay"
This reverts commit 9aa3d7867e, reversing
changes made to c3a1acb524.

https://github.com/ankitects/anki/pull/749#issuecomment-686385112
2020-09-04 08:34:26 +10:00
Damien Elmes
a517accee3 update to latest black 2020-08-31 13:29:28 +10:00
ANH
28d86ab8d1 editor: only autoplay added media when recording 2020-08-26 14:49:19 +03:00
ANH
cc17b4db62 fix drag & drop issue when dropping things over existing content 2020-08-25 17:28:13 +03:00
ANH
680b5e4b50 work around editor freeze issue after external drag & drop 2020-08-19 18:14:07 +10:00
Henrik Giesel
dcf82fb403
Merge branch 'master' into resethook 2020-08-17 12:39:09 +02:00
Damien Elmes
3d0d21e4bc fix duplicates not escaping html
https://forums.ankiweb.net/t/bug-report-showdupes-not-html-escaping-field-content/2167
2020-08-17 17:50:27 +10:00
Henrik Giesel
7f503895d7 Create ResetReason enum 2020-08-16 18:56:32 +02:00
Henrik Giesel
db0a18106f Reorder + make all parameters optional 2020-08-16 18:56:32 +02:00
Henrik Giesel
ccc56d4355 Satisfy formatter 2020-08-16 18:56:32 +02:00
Henrik Giesel
dd515e65e7 Add new use of requireReset 2020-08-16 18:56:32 +02:00
Arthur Milchior
c4db4bd291 Any removed 2020-08-12 01:37:21 +02:00
Henrik Giesel
17f23221e4 Add newlines 2020-08-09 11:16:19 +02:00
Henrik Giesel
ee3d4f5ad8 Avoid extra assignment 2020-08-09 10:38:31 +02:00
Henrik Giesel
f5479edacc Move reverse url quoting functionality to editor_will_munge_html hook 2020-08-09 10:37:38 +02:00
Henrik Giesel
1b9bd70bb1 Move remove null bytes functionality to editor_will_munge_html hook 2020-08-09 10:35:52 +02:00
Henrik Giesel
4720645d1c Replace functionality of mungeHTML with call to new gui_hook 2020-08-08 23:59:01 +02:00
Adam Plaice
d6fb4acd38 Re-add previously supported file extensions for media
(They had been removed in 2ae342592c).
2020-07-29 15:08:33 +02:00
Damien Elmes
93ada5d374
Merge pull request #703 from ANH25/master
fix help-wanted#13
2020-07-29 14:14:57 +10:00
Matt Krump
24e7156991 Turn on check_untyped_defs for aqt.editor
* Turn on check_untyped_defs for aqt.browser
* Add type hints
2020-07-28 18:42:22 -06:00
ANH
fd0c3cf57e add missing string r flag 2020-07-24 09:18:05 +03:00
ANH
da3761341e formatting 2020-07-24 09:00:34 +03:00
ANH
e122534ba4 avoid string concatenation 2020-07-24 08:12:46 +03:00
ANH
eaf935c3ff fix ankitects/help-wanted#13 2020-07-24 06:00:55 +03:00
Andreas Reis
e8ddd17fec Always use standard QT color dialog on Linux
On Linux only Gnome uses its own color dialog, and it's inferior to QT's own: See the same issue @ https://github.com/OpenShot/openshot-qt/pull/2425

(This is/was visible only on some distributions' packaged versions of Anki, not via ./run.)

isLin check since QT on Windows already uses the default, whereas Mac's own picker seems superior (from what I can judge by screenshots).
2020-07-05 13:21:38 +02:00
Damien Elmes
05fb67d409 show clearer error when media db locked
should not happen frequently during a sync, but may happen during
the initial change checking stage

https://forums.ankiweb.net/t/error-when-adding-audio-file/495/2
2020-07-01 11:19:06 +10:00
Damien Elmes
37bf56c56e
remove ellipsis 2020-06-12 09:04:19 +10:00
Quentin Nerden
86713d110e
Update message to match gui
The Change Note Type... command is under the Notes menu, not the Edit menu
2020-06-09 11:49:47 +02:00
Damien Elmes
43da12a445 (un)escape image references in HTML editor to fix ampersand handling
https://anki.tenderapp.com/discussions/ankidesktop/41479-image-names-with-are-breaking
2020-06-09 11:22:07 +10:00
BlueGreenMagick
6cf95d97e7 add type hint to paste-related functions 2020-06-07 12:06:11 +09:00
Damien Elmes
8516ed8655 handle images served from directory + svg content type
https://anki.tenderapp.com/discussions/ankidesktop/41974-win-linux-when-pasting-some-html-i-get-error-in-_run_command-ankirsbackendioerror-ioerror
2020-06-01 13:40:17 +10:00
Damien Elmes
255ac3679b add maximize button to HTML editor
closes ankitects/help-wanted#1
2020-05-29 08:43:33 +10:00
sandersantema
8f993c8e31 remove unused variable 'w' from '_onHtmlEdit' 2020-05-27 12:04:49 +02:00
sandersantema
3407fb7b2b add saveGeom and restoreGeom to htmlEditor 2020-05-27 12:04:00 +02:00
BlueGreenMagick
8f4469d5e9 add evt type for contextMenuEvent method 2020-05-26 17:12:39 +09:00
Damien Elmes
a3ac96443b use context manager in retrieveURL 2020-05-21 10:58:42 +10:00
Damien Elmes
d5d5ca9c3d clearer variable names in retrieveURL 2020-05-21 09:22:34 +10:00
evandrocoan
b388c43454 Fixed HttpClient session not being closed 2020-05-20 19:20:41 -03:00
Damien Elmes
eb0c9f6e0a fix progress bar getting stuck on image paste 2020-05-20 16:12:41 +10:00
Damien Elmes
8da69c5d39 fix HTML editor in add screen 2020-05-20 14:59:22 +10:00
evandrocoan
efb62b9528 Add missing close file descriptors using context managers 2020-05-18 15:54:20 -03:00
Damien Elmes
782911471b add "fill empty" checkbox 2020-05-14 20:58:45 +10:00
Damien Elmes
6680cdf1d3 update the card layout screen
- changes are now committed in bulk when closing the dialog,
and can be canceled
- it's not necessary to save the note to the database to preview it
- duplicate fields are now shown as duplicates in the top list
- redraw preview more quickly
- use + instead of _ when deduplicating names, as the latter is a
glob character
2020-05-13 17:24:49 +10:00
Damien Elmes
2413f286b1 bulk tag add/remove/update; canonify on note save
also remove the tag list updated hook - we'll need a better solution in
the future than having the library code call back into the GUI code
2020-05-12 21:13:34 +10:00
Damien Elmes
7bab99d873 support disabling unicode normalization in notes 2020-05-12 21:13:34 +10:00
Damien Elmes
25f122bf5c update fields and models diags
- field changes are now applied when user closes dialog with save
button, in bulk
- models diag now fetches note type and saves it as required, instead
of holding on top a copy that can grow stale as changes are made in
subdialogs
- both dialogs now perform operations in the backend
- note.model() now fetches the note type on the fly, instead of
holding on to a copy that may become stale
2020-05-12 21:13:34 +10:00
Damien Elmes
6c20e5a7df
Merge pull request #585 from Arthur-Milchior/addButtonSaveNewFunction
addButton always save function
2020-05-04 13:58:46 +10:00
Damien Elmes
eec3fcf87a use qconnect everywhere, and fix some typing issues
a step towards check_untyped_defs in aqt, but there's still 100+
issues to resolve
2020-05-04 13:23:08 +10:00
Arthur Milchior
31164adaec addButton always save function 2020-04-26 17:01:47 +02:00
Damien Elmes
47bd6264bd Revert "Merge pull request #527 from Arthur-Milchior/explode_on_bridge_cmd"
This reverts commit 2264fe3f66, reversing
changes made to 84b84ae31c.

Causes a traceback when opening the add screen, clicking on Type,
and choosing a note type.

  File "/Users/dae/Work/code/dtop/qt/aqt/webview.py", line 31, in cmd
    return json.dumps(self.onCmd(str))
  File "/Users/dae/Work/code/dtop/qt/aqt/webview.py", line 97, in _onCmd
    return self._onBridgeCmd(str)
  File "/Users/dae/Work/code/dtop/qt/aqt/webview.py", line 500, in _onBridgeCmd
    return self.onBridgeCmd(cmd)
  File "/Users/dae/Work/code/dtop/qt/aqt/editor.py", line 374, in onBridgeCmd
    self._links[cmd](self, *args)  # type: ignore
  File "/Users/dae/Work/code/dtop/qt/aqt/editor.py", line 404, in onBlur
    if gui_hooks.editor_did_unfocus_field(False, self.note, int(ord)):
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
2020-03-28 13:35:05 +10:00
Arthur Milchior
c9496ef095 Ensure that focus, key and blur are treated as other commands
The reason to do that is that I can then call blur/key from other
method in add-on.

More precisely, I expect to create a method which captures the blur
command, ask anki to execute the standard version of the command, and
then execute more code once the note contains the new field value.

I should note that the code executed during blur/key/focus itself
didn't change. It's only it's location which changed.
2020-03-26 15:42:27 +01:00
Arthur Milchior
9f4c4ea355 Explode onBridgeCmd
This way, an add-on can catch a blur command, do its change and then
call self.blur
2020-03-25 08:17:48 +01:00
Damien Elmes
818b9193a8
Merge pull request #523 from Arthur-Milchior/hook_note_will_load
Hook editor_note_will_load
2020-03-25 09:43:16 +10:00
Arthur Milchior
3799b8504f strip to test whether field is empty 2020-03-24 11:55:55 +01:00
Arthur Milchior
31f18e3c94 Hook editor_note_will_load
A current problem I have is that there is nothing similar to hook
inside of javascript. It seems that it would be easier to be able to
add other methods in javascript and call them in loadNote. Currently I
simply redefined loadNote, which is far from perfect
2020-03-24 10:17:01 +01:00
Damien Elmes
a51dba7255
Merge pull request #524 from Arthur-Milchior/indet_html
Ident html in editor
2020-03-24 16:00:57 +10:00
Arthur Milchior
349d145014 Ident html in editor
Sometime I like to print html to understand why it bugs. And I really
prefer to have html indented if it's okay with you. There is no change
appart from the identation and quotes
2020-03-23 08:15:48 +01:00
Arthur Milchior
f2f92fb0c3 editor_did_init
That would be useful to add elements in the editor, such as in multi
column editor
2020-03-22 17:15:47 +01:00
Arthur Milchior
89bb5fe79b Hook editor_web_view_did_init
I hope to use this in oder to had features to the web view. In
particular, I expect the "spell checking" feature to use it
hopefully. Because currently it's incompatible with other add-on
dealing with the editor
2020-03-16 04:37:07 +01:00
evandrocoan
2e54d315e1 Fixed BeautifulSoup breaking string paths
https://anki.tenderapp.com/discussions/ankidesktop/39543-anki-is-replacing-the-character-by-when-i-exit-the-html-edit-mode-ctrlshiftx
2020-03-12 21:19:09 -03:00
Glutanimate
3948b778e8 Type-annotate editor.card 2020-03-04 17:41:26 +01:00
Damien Elmes
4096d21c07 add add_file() and write_data() 2020-02-17 08:40:16 +10:00
Glutanimate
0e5dea4c9f Assume that web assets without a specified subpath are under /_anki
Maintains compatibility with existing add-ons
2020-02-15 15:03:43 +01:00
Glutanimate
bbd667b0ff Add webview_will_set_content hook & update supporting code accordingly 2020-02-12 22:00:13 +01:00
Glutanimate
df2a7b06ef Refactor web view title setting and add titles to all web views
Simplifies debugging web views
2020-02-12 21:03:11 +01:00
Damien Elmes
072b64c819 work around HTML editor race condition on macOS
https://anki.tenderapp.com/discussions/beta-testing/1785-cant-see-html-boxes
2020-02-10 09:25:11 +10:00
Damien Elmes
7fcb6b5672 pass instance to webview_did_receive_js_message instead of string 2020-02-09 08:59:29 +10:00
Damien Elmes
9933720994 don't do HTML filtering when pasting urls/text/images
fixes
https://anki.tenderapp.com/discussions/ankidesktop/37752-anki-21-wont-play-audio-files-with-a-blank-in-the-title
2020-01-26 19:13:31 +10:00
Damien Elmes
09e59d7148 style tags area like fields 2020-01-26 18:47:28 +10:00
Damien Elmes
7dcbc7efec basic night mode support
Forces the Fusion theme when running night mode, so we don't need
to work around platform themes that don't respond to the defined
palette.

Feedback/suggestions on the chosen colours welcome - _vars.scss is the
file to change if you want to experiment with adjustments.
2020-01-23 17:27:07 +10:00
Damien Elmes
d54f719558 add a webview_did_receive_js_message hook 2020-01-22 11:06:12 +10:00
Damien Elmes
02ec3f149c update qt/ to use the new API 2020-01-20 20:10:38 +10:00
Damien Elmes
02145c7078 fix <br> remaining when image attached to empty field 2020-01-19 16:41:39 +10:00
Damien Elmes
5260e10f8f leave percent-escaped text from the editor alone
Originally added in d7339d9a27b8abd65fbcf85f809fb0089046986f;
unfortunately the change message does not describe why. Images
are handled separately, so it should theoretically not be required,
and keeping it in leads to garbled text when people include %
on their cards.

Latest report at https://anki.tenderapp.com/discussions/ankidesktop/38138-errors-in-conversion-of-latex-and-ea
2020-01-19 16:29:46 +10:00
Damien Elmes
ef8bb61fc3 AnkiRequestsClient -> HttpClient 2020-01-19 11:33:27 +10:00
Damien Elmes
0d1a25eb5b move AnkiRequestsClient into its own file
It should still be accessible via anki.sync as well.
2020-01-18 15:45:14 +10:00
Damien Elmes
4c0b7d37c9 option to invert paste handling in prefs 2020-01-16 12:36:04 +10:00
Damien Elmes
bf93731e49 revert to the old wrap() behaviour
wrap2() was introduced recently to try and resolve an issue where
styling outside of the wrapped section was getting lost. eg,

<b>some [text] etc</b>

When the user created a cloze deletion or added math tags to the [text]
part, the text ended up not being bold - the inner portion is displayed
without styling.

wrap2() used setFormat("inserttext", ...), which did fix that issue
- but it also introduced multiple new issues:

- any HTML inside the selected area, including newlines and images,
was lost
- the unicode entities inserted when creating a cloze deletion in
RTL mode end up inserted as plain text

For now, I'm just going to revert to the old behaviour. If anyone
has a suggestion for an approach that is able to preserve both the
inner formatting and the surrounding formatting, a pull request
or post on the forums would be appreciated!
2020-01-16 10:33:36 +10:00
Damien Elmes
886536d78f fix cases where we used the wrong type sig to connect to gui hook 2020-01-16 07:53:12 +10:00
Damien Elmes
8310cb7a0e add qconnect helper and some type hints
The type hints allow mypy to check the gui_hook calls, revealing a
bunch of places that are broken as they expect no arguments like the
legacy hooks.

To make mypy happy about PyQt's signal.connect(func), a qconnect()
helper has been added.
2020-01-16 07:41:23 +10:00
Damien Elmes
b09e7e8247 more tweaks for readability/consistency 2020-01-15 17:45:35 +10:00
Damien Elmes
237c0791f8 more hook tweaks, and merge the pre-render field and template hooks 2020-01-15 17:18:11 +10:00
Damien Elmes
cab572b63c remove _hook/_filter suffix 2020-01-15 16:53:24 +10:00
Damien Elmes
89fce1f6b7 migrate addHook/remHook calls 2020-01-15 13:49:26 +10:00
Damien Elmes
660685375f migrate most of the remaining runHook() calls 2020-01-15 12:46:53 +10:00
Damien Elmes
5876866565 tweaking the folder names again
hopefully that's the last of it
2020-01-03 07:48:38 +10:00