rhysd / neovim-component

<neovim-editor> WebComponent to embed Neovim to your app with great ease
https://github.com/rhysd/NyaoVim
MIT License
193 stars 18 forks source link

Remove default size (height/width) and make screen fit to <canvas> size #8

Closed rhysd closed 8 years ago

rhysd commented 8 years ago

Currently inner canvas element has fixed size and user must manage width and height of <neovim-editor> component. This is because we must know lines and cols before starting nvim (otherwise it is needed to send vim_try_resize after nvim starting).

  1. <neovim-editor> (includes inner <canvas>) is created
  2. nvim process starts
  3. <neovim-editor> is attached to DOM

Now the size must be specified because we can't know the element size before attaching it to DOM. The sequence might be:

  1. <neovim-editor> (includes inner <canvas>) is created
  2. <neovim-editor> is attached to DOM
  3. Get the size of inner <canvas> and calculate lines and cols
  4. nvim process starts with the lines and cols

Starting process will be delayed until DOM is attached. I must check the start up time change to ensure this change has small impact to it.

rhysd commented 8 years ago

Default size is not removal because <canvas> doesn't have 'resize' event... We might make a compromize with resize on <body> resized.