Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rhysd/react-vimjs

Vim in Your Web App
https://github.com/rhysd/react-vimjs

emscripten react react-component vim

Last synced: 9 days ago
JSON representation

Vim in Your Web App

Awesome Lists containing this project

README

        

![React TRUE Vim Component](https://raw.githubusercontent.com/rhysd/react-vimjs/master/misc/react-vimjs-bannar.jpg)
========================
[![Build Status](https://travis-ci.org/rhysd/react-vimjs.svg)](https://travis-ci.org/rhysd/react-vimjs)

This is a [Vim.js](https://github.com/coolwanglu/vim.js) component for [React.js](https://facebook.github.io/react/). You can easily introduce Vim into your React.js web application.

Please try [Markdown Demo](http://rhysd.github.io/react-vimjs/). The source code of this demo is [here](example).

## Install

Install via [npm](https://www.npmjs.com).

```
$ npm install react-vimjs
```

## Usage

### Basic Usage

You can use `` component.

- `index.js`

```javascript
import React from 'react'
import Vim from 'react-vimjs'

React.render(
Loading... ,
document.body
);
```

- `index.html`

```html



Hello, react-vimjs





```

You need to link `vim.css` in `dist` directory and load `vim.js` with `` tag after loading your `index.js`. And set path to `vim.js.mem` as property of `<Vim>` component.
`<Vim>` has many other optional properties. (Document is TODO)

Basically all files are put on memory so it is volatile after closing the page. Only `.vimrc` is saved to local storage.

### Edit Local File

You can load local file with file chooser easily with `<FileUpload>` component.

```javascript
import Vim,{FileUpload} from 'react-vimjs'

React.render(
<div>
<Vim memPath="path/to/vim.js.mem"> Loading... </Vim>
<FileUpload onUpload={(dir, name) => alert("Loaded " + dir + "/" + name)}>
<button type="button">
Edit Local File
</button>
</FileUpload>
</div>,
document.body
);
```

Children of `<FileUpload>` component gets clickable. When clicked, `<input>` file chooser is launched and you can select a file. If `onUpload` property is set, it is called with the path to loaded file after loading the file is success. When `blah.txt` is selected, `/root/blah.txt` is created in Emscripten filesystem and you can open it with `:edit blah.txt`.