comtent input as compoents
This commit is contained in:
parent
b5e52a75d7
commit
eff8d9a83e
2 changed files with 33 additions and 16 deletions
31
src/components/content-input.js
Normal file
31
src/components/content-input.js
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
import messages from '../content/messages';
|
||||||
|
|
||||||
|
export default class ContentInputComponent {
|
||||||
|
constructor(target) {
|
||||||
|
target.addEventListener('keypress', this.onKeyPress.bind(this));
|
||||||
|
target.addEventListener('keydown', this.onKeyDown.bind(this));
|
||||||
|
target.addEventListener('keyup', this.onKeyUp.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
onKeyPress(e) {
|
||||||
|
if (e.target instanceof HTMLInputElement ||
|
||||||
|
e.target instanceof HTMLTextAreaElement ||
|
||||||
|
e.target instanceof HTMLSelectElement) {
|
||||||
|
if (e.key === 'Escape' && e.target.blur) {
|
||||||
|
e.target.blur();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
browser.runtime.sendMessage({
|
||||||
|
type: messages.KEYDOWN,
|
||||||
|
code: e.which,
|
||||||
|
ctrl: e.ctrlKey
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onKeyDown() {
|
||||||
|
}
|
||||||
|
|
||||||
|
onKeyUp() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ import * as scrolls from '../content/scrolls';
|
||||||
import * as navigates from '../content/navigates';
|
import * as navigates from '../content/navigates';
|
||||||
import * as followActions from '../actions/follow';
|
import * as followActions from '../actions/follow';
|
||||||
import * as store from '../store';
|
import * as store from '../store';
|
||||||
|
import ContentInputComponent from '../components/content-input';
|
||||||
import FollowComponent from '../components/follow';
|
import FollowComponent from '../components/follow';
|
||||||
import followReducer from '../reducers/follow';
|
import followReducer from '../reducers/follow';
|
||||||
import operations from '../operations';
|
import operations from '../operations';
|
||||||
|
@ -18,25 +19,10 @@ followStore.subscribe(() => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const contentInputComponent = new ContentInputComponent(window);
|
||||||
|
|
||||||
consoleFrames.initialize(window.document);
|
consoleFrames.initialize(window.document);
|
||||||
|
|
||||||
window.addEventListener('keypress', (e) => {
|
|
||||||
if (e.target instanceof HTMLInputElement ||
|
|
||||||
e.target instanceof HTMLTextAreaElement ||
|
|
||||||
e.target instanceof HTMLSelectElement) {
|
|
||||||
if (e.key === 'Escape' && e.target.blur) {
|
|
||||||
e.target.blur();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
browser.runtime.sendMessage({
|
|
||||||
type: messages.KEYDOWN,
|
|
||||||
code: e.which,
|
|
||||||
ctrl: e.ctrlKey
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const execOperation = (operation) => {
|
const execOperation = (operation) => {
|
||||||
switch (operation.type) {
|
switch (operation.type) {
|
||||||
case operations.SCROLL_LINES:
|
case operations.SCROLL_LINES:
|
||||||
|
|
Reference in a new issue