Treat the Jupyter input line as editable

This commit is contained in:
Florian Bruhin 2017-02-23 17:43:22 +01:00
parent fa3bb9a5c8
commit e832105dd5
2 changed files with 14 additions and 10 deletions

View File

@ -73,6 +73,7 @@ Fixed
- `:navigate prev/next` now detects `rel` attributes on `<a>` elements, and
handles multiple `rel` attributes correctly.
- Fixed a crash when hinting with target `userscript` and spawning a non-existing script
- Lines in Jupyter notebook now trigger insert mode
v0.9.1
------

View File

@ -223,18 +223,22 @@ class AbstractWebElement(collections.abc.MutableMapping):
else:
return False
def _is_editable_div(self):
"""Check if a div-element is editable.
def _is_editable_classes(self):
"""Check if an element is editable based on its classes.
Return:
True if the element is editable, False otherwise.
"""
# Beginnings of div-classes which are actually some kind of editor.
div_classes = ('CodeMirror', # Javascript editor over a textarea
'kix-', # Google Docs editor
'ace_') # http://ace.c9.io/
classes = {
'div': ['CodeMirror', # Javascript editor over a textarea
'kix-', # Google Docs editor
'ace_'], # http://ace.c9.io/
'pre': ['CodeMirror'],
}
relevant_classes = classes[self.tag_name()]
for klass in self.classes():
if any([klass.startswith(e) for e in div_classes]):
if any([klass.strip().startswith(e) for e in relevant_classes]):
return True
return False
@ -265,10 +269,9 @@ class AbstractWebElement(collections.abc.MutableMapping):
return config.get('input', 'insert-mode-on-plugins') and not strict
elif tag == 'object':
return self._is_editable_object() and not strict
elif tag == 'div':
return self._is_editable_div() and not strict
else:
return False
elif tag in ['div', 'pre']:
return self._is_editable_classes() and not strict
return False
def is_text_input(self):
"""Check if this element is some kind of text box."""