Edit Field During Review Cloze add-on deleting images

@dae it appears an issue was introduced into this add-on beginning in Anki 2.1.29 or 30. I have been unable to get ahold of @BlueGreenMagick and figured I would at least mention this to you in case it is a simple fix within anki’s code rather than the add-on code. Perhaps someone else could help diagnose and fix the issue?

I shared on github here

Error:

Traceback (most recent call last):
  File "aqt/webview.py", line 37, in cmd
  File "aqt/webview.py", line 123, in _onCmd
  File "aqt/webview.py", line 547, in _onBridgeCmd
  File "</Applications/Anki.app/Contents/MacOS/decorator.pyc:decorator-gen-152>", line 2, in linkHandler_wrapper
  File "anki/hooks.py", line 638, in decorator_wrapper
  File "anki/hooks.py", line 635, in repl
  File "/Users/Nick/Library/Application Support/Anki2/addons21/popup_dictionary/main.py", line 216, in linkHandler
    return _old(self, url)
  File "</Applications/Anki.app/Contents/MacOS/decorator.pyc:decorator-gen-86>", line 2, in linkHandler_wrapper
  File "anki/hooks.py", line 638, in decorator_wrapper
  File "anki/hooks.py", line 635, in repl
  File "/Users/Nick/Library/Application Support/Anki2/addons21/385888438/reviewer.py", line 193, in myLinkHandler
    saveThenRefreshFld(reviewer, note, fld, new_val)
  File "/Users/Nick/Library/Application Support/Anki2/addons21/385888438/reviewer.py", line 153, in saveThenRefreshFld
    saveField(note, fld, new_val)
  File "/Users/Nick/Library/Application Support/Anki2/addons21/385888438/reviewer.py", line 135, in saveField
    txt = Editor.mungeHTML(None, txt)
  File "aqt/editor.py", line 421, in mungeHTML
  File "aqt/gui_hooks.py", line 1606, in __call__
  File "aqt/editor.py", line 1217, in reverse_url_quoting
AttributeError: 'NoneType' object has no attribute 'mw'

I just tried changing this line as follows, and it seems to work on Ver 2.1.34, though I haven’t tested it enough.

# txt = Editor.mungeHTML(None, txt)
dummy_editor = type("", (), {})()  # create an empty object
dummy_editor.mw = mw
txt = Editor.mungeHTML(dummy_editor, txt)
1 Like

That seems to solve the issue! Would you mind creating a PR for @BlueGreenMagick? If you don’t have time I can do it this weekend! Thanks!!

OK, I will send a PR in a day or two.

Edit: I’ve just send a PR to the repo.

1 Like