|
| 1 | +# Sharedb-ace |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +This is a fork of the [original sharedb-ace repository](https://github.com/jethrokuan/sharedb-ace). |
| 6 | + |
| 7 | +Sharedb-ace provides two-way bindings between [ShareDB](https://github.com/share/sharedb) and [Ace Editor](http://ace.c9.io/). |
| 8 | + |
| 9 | +## Installation |
| 10 | + |
| 11 | +Using npm: |
| 12 | + |
| 13 | +```bash |
| 14 | +npm install @sourceacademy/sharedb-ace |
| 15 | +``` |
| 16 | + |
| 17 | +Using pre-compiled js from unpkg CDN: |
| 18 | + |
| 19 | +```html |
| 20 | +<script src="https://unpkg.com/sharedb-ace@latest/dist/sharedb-ace.min.js"></script> |
| 21 | +``` |
| 22 | + |
| 23 | +## Documentation |
| 24 | + |
| 25 | +### Single Ace-editor Instance |
| 26 | + |
| 27 | +Setup the ShareDB document as a string: |
| 28 | + |
| 29 | +```javascript |
| 30 | +ShareAce.on('ready', function() { |
| 31 | + ShareAce.add(editor, [], [ Plugins, Here ]); |
| 32 | +}); |
| 33 | +``` |
| 34 | + |
| 35 | +### Multiple Ace-editor Instances |
| 36 | + |
| 37 | +Your setup may be more complex, and requires the use of multiple ace-instances synchronized over one connection. Setup the ShareDB document to be a JSON object. |
| 38 | + |
| 39 | +For example: |
| 40 | + |
| 41 | +```javascript |
| 42 | +{ |
| 43 | + "foo": "", |
| 44 | + "bar": "" |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +Next, connect the two paths to two separate ace editor instances: |
| 49 | + |
| 50 | +```javascript |
| 51 | +ShareAce.on('ready', function() { |
| 52 | + ShareAce.add(editor1, ["foo"], []); |
| 53 | + ShareAce.add(editor2, ["bar"], []); |
| 54 | +}); |
| 55 | +``` |
| 56 | + |
| 57 | +## Developing sharedb-ace |
| 58 | + |
| 59 | +1. Fork or clone this repo: |
| 60 | + |
| 61 | +```bash |
| 62 | +git clone https://github.com/jethrokuan/sharedb-ace.git |
| 63 | +``` |
| 64 | + |
| 65 | +```bash |
| 66 | +cd sharedb-ace && yarn install |
| 67 | +``` |
| 68 | + |
| 69 | +To test the package locally, run the following on this sharedb-ace repository: |
| 70 | + |
| 71 | +```bash |
| 72 | +yarn build |
| 73 | +yarn link |
| 74 | +``` |
| 75 | + |
| 76 | +Then, run the following on the frontend repository: |
| 77 | + |
| 78 | +```bash |
| 79 | +yarn link @sourceacademy/sharedb-ace |
| 80 | +``` |
| 81 | + |
| 82 | +Now, whenever you want to update the ShareDB Ace binding, simply run `yarn build`. |
| 83 | + |
| 84 | +### Generating JS Docs |
| 85 | + |
| 86 | +We generate javascript documentation using inline documentation. |
| 87 | + |
| 88 | +```bash |
| 89 | +jsdoc source/*.js --destination ./docs/ |
| 90 | +``` |
| 91 | + |
| 92 | +### License |
| 93 | + |
| 94 | +> Copyright 2019 Jethro Kuan |
| 95 | +> |
| 96 | +> Permission is hereby granted, free of charge, to any person obtaining |
| 97 | +> a copy of this software and associated documentation files (the |
| 98 | +> "Software"), to deal in the Software without restriction, including |
| 99 | +> without limitation the rights to use, copy, modify, merge, publish, |
| 100 | +> distribute, sublicense, and/or sell copies of the Software, and to |
| 101 | +> permit persons to whom the Software is furnished to do so, subject to |
| 102 | +> the following conditions: |
| 103 | +> |
| 104 | +> The above copyright notice and this permission notice shall be |
| 105 | +> included in all copies or substantial portions of the Software. |
| 106 | +> |
| 107 | +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 108 | +> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 109 | +> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 110 | +> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 111 | +> CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 112 | +> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 113 | +> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
0 commit comments