mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Add names for all iframe clients
This commit is contained in:
parent
61e2d4e175
commit
ee717920ba
@ -287,7 +287,7 @@ class CommentsEditorBoss:
|
||||
'exec_command': self.exec_command,
|
||||
'focus': self.focus,
|
||||
}
|
||||
self.comm = IframeClient(handlers)
|
||||
self.comm = IframeClient(handlers, 'comments-editor-iframe')
|
||||
|
||||
def initialize(self, data):
|
||||
window.onerror = self.onerror
|
||||
|
@ -173,10 +173,14 @@ def create_wrapped_iframe(handlers, bootstrap_text, entry_point, kw):
|
||||
return iframe, ans
|
||||
|
||||
|
||||
client_instance_num = 0
|
||||
|
||||
class IframeClient:
|
||||
|
||||
def __init__(self, handlers):
|
||||
def __init__(self, handlers, name):
|
||||
self.encrypted_communications = False
|
||||
self.name = name
|
||||
self.instance_num = v'++client_instance_num'
|
||||
self.handlers = {k: handlers[k] for k in handlers}
|
||||
self.initialize_handler = handlers.initialize
|
||||
self.handlers.initialize = self.initialize
|
||||
@ -233,6 +237,7 @@ class IframeClient:
|
||||
|
||||
def send_message(self, action, data):
|
||||
data.action = action
|
||||
data.iframe_id = f'{self.name}-{self.instance_num}'
|
||||
if self.encrypted_communications:
|
||||
data = self.gcm_to_parent.encrypt(JSON.stringify(data))
|
||||
window.parent.postMessage(data, '*')
|
||||
|
@ -191,7 +191,7 @@ class PopupIframeBoss:
|
||||
'clear': self.on_clear,
|
||||
'display': self.display,
|
||||
}
|
||||
self.comm = IframeClient(handlers)
|
||||
self.comm = IframeClient(handlers, 'popup-iframe')
|
||||
self.blob_url_map = {}
|
||||
self.name = None
|
||||
self.frag = None
|
||||
|
@ -169,7 +169,7 @@ class IframeBoss:
|
||||
'replace_highlights': self.replace_highlights,
|
||||
'clear_selection': def(): window.getSelection().removeAllRanges();,
|
||||
}
|
||||
self.comm = IframeClient(handlers)
|
||||
self.comm = IframeClient(handlers, 'main-iframe')
|
||||
self.last_window_ypos = 0
|
||||
self.length_before = None
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user