diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-03-16 22:40:26 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-16 22:40:26 +0900 |
commit | d8bbad8e1b774d6e46c7fa05324c90ce2b716a66 (patch) | |
tree | 4d4dd139b2e73bbaa5643e5b3bd6e123a6ce3e99 /src/console | |
parent | 1f2afb8c157aa601e7cbd46041c9bf063c63d982 (diff) | |
parent | 04ebd1e5331d29b2413c174ae0fe9d73566b3b8d (diff) |
Merge pull request #1034 from ueokande/iframe-dynamic-resize
Iframe dynamic resize
Diffstat (limited to 'src/console')
-rw-r--r-- | src/console/clients/ConsoleFrameClient.ts | 11 | ||||
-rw-r--r-- | src/console/components/Console.tsx | 8 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/console/clients/ConsoleFrameClient.ts b/src/console/clients/ConsoleFrameClient.ts new file mode 100644 index 0000000..954e518 --- /dev/null +++ b/src/console/clients/ConsoleFrameClient.ts @@ -0,0 +1,11 @@ +import * as messages from "../../shared/messages"; + +export default class ConsoleFrameClient { + async resize(width: number, height: number): Promise<void> { + await browser.runtime.sendMessage({ + type: messages.CONSOLE_RESIZE, + width, + height, + }); + } +} diff --git a/src/console/components/Console.tsx b/src/console/components/Console.tsx index 1c673fa..18a6632 100644 --- a/src/console/components/Console.tsx +++ b/src/console/components/Console.tsx @@ -13,6 +13,7 @@ import ColorScheme from "../../shared/ColorScheme"; import { LightTheme, DarkTheme } from "./Theme"; import styled from "./Theme"; import { ThemeProvider } from "styled-components"; +import ConsoleFrameClient from "../clients/ConsoleFrameClient"; const ConsoleWrapper = styled.div` border-top: 1px solid gray; @@ -30,6 +31,7 @@ class Console extends React.Component<Props> { private input: React.RefObject<Input>; private commandLineParser: CommandLineParser = new CommandLineParser(); + private consoleFrameClient = new ConsoleFrameClient(); constructor(props: Props) { super(props); @@ -130,6 +132,12 @@ class Console extends React.Component<Props> { } else if (prevProps.mode !== "find" && this.props.mode === "find") { this.focus(); } + + const { + scrollWidth: width, + scrollHeight: height, + } = document.getElementById("vimvixen-console")!; + this.consoleFrameClient.resize(width, height); } render() { |