diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-04-04 23:06:00 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-04-05 22:21:33 +0900 |
commit | 9041bae89f54efce14239768e642f99d1f0b35d1 (patch) | |
tree | 47f6910761b0db63c3afac4dc819f1510b9191a2 /src/console/components/CommandPrompt.tsx | |
parent | 3a7e55fd292196f600c11fad36425014677a1351 (diff) |
Make resize to a custom hook
Diffstat (limited to 'src/console/components/CommandPrompt.tsx')
-rw-r--r-- | src/console/components/CommandPrompt.tsx | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/console/components/CommandPrompt.tsx b/src/console/components/CommandPrompt.tsx index 4e02668..f6f4d8f 100644 --- a/src/console/components/CommandPrompt.tsx +++ b/src/console/components/CommandPrompt.tsx @@ -6,12 +6,12 @@ import CommandLineParser, { InputPhase, } from "../commandline/CommandLineParser"; import Completion from "./console/Completion"; -import ConsoleFrameClient from "../clients/ConsoleFrameClient"; import Input from "./console//Input"; import { Command } from "../../shared/Command"; import styled from "styled-components"; import reducer, { defaultState, completedText } from "../reducers/completion"; import CompletionType from "../../shared/CompletionType"; +import useAutoResize from "../hooks/useAutoResize"; const COMPLETION_MAX_ITEMS = 33; @@ -26,7 +26,8 @@ const CommandPrompt: React.FC = () => { defaultState ); const commandLineParser = new CommandLineParser(); - const consoleFrameClient = new ConsoleFrameClient(); + + useAutoResize(); const onBlur = () => { dispatch(consoleActions.hideCommand()); @@ -106,12 +107,6 @@ const CommandPrompt: React.FC = () => { Promise.resolve(action).then((a) => { if (a) { completionDispatch(a); - - const { - scrollWidth: width, - scrollHeight: height, - } = document.getElementById("vimvixen-console")!; - consoleFrameClient.resize(width, height); } }); }; @@ -127,12 +122,6 @@ const CommandPrompt: React.FC = () => { Promise.resolve(completionAction).then((a) => { if (a) { completionDispatch(a); - - const { - scrollWidth: width, - scrollHeight: height, - } = document.getElementById("vimvixen-console")!; - consoleFrameClient.resize(width, height); } }); }); |