Merge pull request #1303 from Arthur-Milchior/paste_post_hook

Add a hook to execute after pasting in a field
This commit is contained in:
Damien Elmes 2021-07-26 11:01:29 +10:00 committed by GitHub
commit 4e133e7d8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View file

@ -954,6 +954,7 @@ $editorToolbar.then(({{ toolbar }}) => toolbar.appendGroup({{
else: else:
ext = "false" ext = "false"
self.web.eval(f"pasteHTML({json.dumps(html)}, {json.dumps(internal)}, {ext});") self.web.eval(f"pasteHTML({json.dumps(html)}, {json.dumps(internal)}, {ext});")
gui_hooks.editor_did_paste(self, html, internal, extended)
def doDrop(self, html: str, internal: bool, extended: bool = False) -> None: def doDrop(self, html: str, internal: bool, extended: bool = False) -> None:
def pasteIfField(ret: bool) -> None: def pasteIfField(ret: bool) -> None:

View file

@ -843,6 +843,16 @@ gui_hooks.webview_did_inject_style_into_page.append(mytest)
doc="""Allows changing the javascript commands to load note before doc="""Allows changing the javascript commands to load note before
executing it and do change in the QT editor.""", executing it and do change in the QT editor.""",
), ),
Hook(
name="editor_did_paste",
args=[
"editor: aqt.editor.Editor",
"html: str",
"internal: bool",
"extended: bool",
],
doc="""Called after some data is pasted by python into an editor field.""",
),
# Tag # Tag
################### ###################
Hook(name="tag_editor_did_process_key", args=["tag_edit: TagEdit", "evt: QEvent"]), Hook(name="tag_editor_did_process_key", args=["tag_edit: TagEdit", "evt: QEvent"]),