jh-changes
Shin'ya Ueoka 7 years ago
parent ccc81312a1
commit a57cdbd5b5
  1. 4
      src/content/components/common/follow.js
  2. 10
      src/content/components/common/input.js
  3. 8
      src/shared/utils/dom.js

@ -1,5 +1,6 @@
import messages from 'shared/messages'; import messages from 'shared/messages';
import Hint from './hint'; import Hint from './hint';
import * as dom from 'shared/utils/dom';
const TARGET_SELECTOR = [ const TARGET_SELECTOR = [
'a', 'button', 'input', 'textarea', 'a', 'button', 'input', 'textarea',
@ -136,10 +137,11 @@ export default class Follow {
case 'button': case 'button':
return element.click(); return element.click();
default: default:
// it may contenteditable if (dom.isContentEditable(element)) {
return element.focus(); return element.focus();
} }
} }
}
onMessage(message, sender) { onMessage(message, sender) {
switch (message.type) { switch (message.type) {

@ -1,3 +1,5 @@
import * as dom from 'shared/utils/dom';
const modifierdKeyName = (name) => { const modifierdKeyName = (name) => {
if (name.length === 1) { if (name.length === 1) {
return name.toUpperCase(); return name.toUpperCase();
@ -78,12 +80,12 @@ export default class InputComponent {
} }
fromInput(e) { fromInput(e) {
if (!e.target) {
return false;
}
return e.target instanceof HTMLInputElement || return e.target instanceof HTMLInputElement ||
e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLTextAreaElement ||
e.target instanceof HTMLSelectElement || e.target instanceof HTMLSelectElement ||
e.target instanceof HTMLElement && dom.isContentEditable(e.target);
e.target.hasAttribute('contenteditable') && (
e.target.getAttribute('contenteditable').toLowerCase() === 'true' ||
e.target.getAttribute('contenteditable').toLowerCase() === '');
} }
} }

@ -0,0 +1,8 @@
const isContentEditable = (element) => {
return element.hasAttribute('contenteditable') && (
element.getAttribute('contenteditable').toLowerCase() === 'true' ||
element.getAttribute('contenteditable').toLowerCase() === ''
);
};
export { isContentEditable };