Go to insertmode in google docs

This commit is contained in:
Florian Bruhin 2014-06-23 08:02:10 +02:00
parent 35ffc2c2c0
commit 0028bd94cc
2 changed files with 12 additions and 9 deletions

View File

@ -10,8 +10,6 @@ Bugs
- Handle it correctly when a new statusbar question is asked while another is
still active. (see notes)
- iggy: qutebrowser gets out of insert mode a lot on Google Drive/Docs
- Ugly font rendering on Windows on http://support.sigasi.com/Knowledgebase/List
- On doodle, when modifying something on http://doodle.com/create and clicking

View File

@ -185,7 +185,9 @@ class WebView(QWebView):
Args:
hitresult: A QWebHitTestResult
"""
# FIXME is this algorithm accurate?
# Beginnings of div-classes which are actually some kind of editor.
DIV_CLASSES = ['CodeMirror', # Javascript editor over a textarea
'kix-'] # Google Docs editor
elem = hitresult.element()
tag = elem.tagName().lower()
if hitresult.isContentEditable() and webelem.is_writable(elem):
@ -208,12 +210,15 @@ class WebView(QWebView):
log.mouse.debug("<object type='{}'> clicked.".format(objtype))
return config.get('input', 'insert-mode-on-plugins')
elif tag == 'div':
# CodeMirror is some java-script editor which hides the underlying
# textarea, but is editable.
if any([c.startswith('CodeMirror') for c in elem.classes()]):
return True
else:
return False
log.webview.debug("div with classes {} clicked!".format(
elem.classes()))
for klass in elem.classes():
if any([klass.startswith(e) for e in DIV_CLASSES]):
return True
elif tag == 'span':
log.webview.debug("span with classes {} clicked!".format(
elem.classes()))
return False
def _mousepress_backforward(self, e):
"""Handle back/forward mouse button presses.