UNPKG

19.2 kBMarkdownView Raw
1<h1 align="center">
2 Markdown Editor
3</h1>
4
5<p align="center">
6
7 <a href="https://accordproject-markdown-editor.netlify.com/">
8 <img src="https://api.netlify.com/api/v1/badges/952fdc5d-a2bb-4895-a375-25ea1c6f30d8/deploy-status" alt="Netlify Status" />
9 </a>
10 <a href="https://travis-ci.org/accordproject/markdown-editor">
11 <img src="https://travis-ci.org/accordproject/markdown-editor.svg?branch=master" alt="Build Status">
12 </a>
13
14 <a href="https://www.npmjs.com/package/@accordproject/markdown-editor">
15 <img src="https://img.shields.io/npm/dm/@accordproject/markdown-editor" alt="npm version" />
16 </a>
17
18 <a href="https://badge.fury.io/js/%40accordproject%2Fmarkdown-editor">
19 <img src="https://badge.fury.io/js/%40accordproject%2Fmarkdown-editor.svg" alt="downloads" />
20 </a>
21
22 <a href="https://github.com/accordproject/markdown-editor/blob/master/LICENSE">
23 <img src="https://img.shields.io/github/license/accordproject/markdown-editor" alt="GitHub license">
24 </a>
25
26 <a href="https://accord-project-slack-signup.herokuapp.com/">
27 <img src="https://img.shields.io/badge/Accord%20Project-Join%20Slack-blue" alt="Join the Accord Project Slack" />
28 </a>
29
30</p>
31
32This repo contains two React-based editors:
331. A WYSIWYG [Slate][slate]-based editor that edits rich text and calls an `onChange`
34 callback with the modified Slate DOM.
352. A TextArea-based markdown editor that edits markdown text and calls an `onChange`
36 callback with the modified markdown text.
37
38The demo editor uses the `markdown-transform` package to transform Slate DOM
39to/from markdown text.
40
41Using these editors you could allow people to either edit rich formatted text using
42markdown (and provide a WYSIWYG preview), or allow them to edit using a WYSIWYG
43editor and use markdown for persistence.
44
45The editor includes a formatting toolbar.
46
47This component is Apache-2 licensed Open Source. Contributors welcome!
48
49### [Demo](https://accordproject-markdown-editor.netlify.com/)
50
51### Usage
52
53```
54npm install @accordproject/markdown-editor
55```
56
57You'll also need to be sure to install this package's peer dependencies:
58```
59npm install react react-dom slate slate-react styled-components
60```
61
62```
63import { SlateAsInputEditor } from '@accordproject/markdown-editor';
64import List from '@accordproject/markdown-editor/dist/plugins/list';
65import Video from '@accordproject/markdown-editor/dist/plugins/video';
66import { SlateTransformer } from '@accordproject/markdown-slate';
67
68const plugins = [List()];
69const slateTransformer = new SlateTransformer();
70
71function storeLocal(slateValue) {
72 const markdown = slateTransformer.toMarkdown(slateValue);
73 localStorage.setItem('markdown-editor', markdown);
74}
75
76ReactDOM.render(<SlateAsInputEditor plugins={plugins} lockText={false} onChange={storeLocal}/>
77, document.getElementById('root'));
78```
79
80### Example
81
82For an example React App see the `./examples/` folder.
83
84A `TextArea` containing [CommonMark][CommonMark] synchronized with a `MarkdownEditor` component, rendered using [Slate][slate].
85
86![overview image](overview.png)
87
88In order to run an isolated local development example, run `npm run dev` and then navigate to: http://localhost:3001/
89
90## Available Scripts
91
92In the project directory, you can run:
93
94#### `npm run dev`
95
96Runs the app in the development mode.<br>
97Open [http://localhost:3001/](http://localhost:3001/) to view it in the browser.
98
99The page will reload if you make edits.<br>
100
101#### `npm run build`
102
103Builds the app for production to the `build` folder.<br>
104It correctly bundles React in production mode and optimizes the build for the best performance.
105
106The build is minified and the filenames include the hashes.<br>
107Your app is ready to be deployed!
108
109## Styling
110
111You can style the toolbar of this component, as well as the width of the editor:
112
113#### `editorProps`
114
115This is an object with the following possible css inputs as strings:
116- `BUTTON_BACKGROUND_INACTIVE`
117- `BUTTON_BACKGROUND_ACTIVE`
118- `BUTTON_SYMBOL_INACTIVE`
119- `BUTTON_SYMBOL_ACTIVE`
120- `DROPDOWN_COLOR`
121- `TOOLBAR_BACKGROUND`
122- `EDITOR_BORDER_RADIUS`
123- `EDITOR_BORDER`
124- `EDITOR_HEIGHT`
125- `EDITOR_MARGIN`
126- `EDITOR_SHADOW`
127- `EDITOR_WIDTH`
128- `TOOLTIP_BACKGROUND`
129- `TOOLTIP`
130- `TOOLBAR_SHADOW`
131
132---
133
134<p align="center">
135 <a href="https://www.accordproject.org/">
136 <img src="assets/APLogo.png" alt="Accord Project Logo" width="400" />
137 </a>
138</p>
139
140Accord Project is an open source, non-profit, initiative working to transform contract management and contract automation by digitizing contracts. Accord Project operates under the umbrella of the [Linux Foundation][linuxfound]. The technical charter for the Accord Project can be found [here][charter].
141
142## Learn More About Accord Project
143
144### Overview
145* [Accord Project][apmain]
146* [Accord Project News][apnews]
147* [Accord Project Blog][apblog]
148* [Accord Project Slack][apslack]
149* [Accord Project Technical Documentation][apdoc]
150* [Accord Project GitHub][apgit]
151
152
153### Documentation
154* [Getting Started with Accord Project][docwelcome]
155* [Concepts and High-level Architecture][dochighlevel]
156* [How to use the Cicero Templating System][doccicero]
157* [How to Author Accord Project Templates][docstudio]
158* [Ergo Language Guide][docergo]
159
160### Ecosystem
161
162
163#### Core libraries:
164<table>
165 <tr>
166 <th headers="blank">Projects</th>
167 <th headers="blank">Package name</th>
168 <th headers="blank">Version</th>
169 <th headers="blank">Description</th>
170 </tr>
171 <tr>
172 <td headers><a href="https://github.com/accordproject/cicero">Cicero</a></td>
173 <td headers> <a href="https://github.com/accordproject/cicero/tree/master/packages/cicero-core">cicero-core</a></td>
174 <td headers> <a href="https://badge.fury.io/js/%40accordproject%2Fcicero-core"><img src="https://badge.fury.io/js/%40accordproject%2Fcicero-core.svg" alt="npm version"></a></td>
175 <td headers>Templates Core</td>
176 </tr>
177 <tr>
178 <td headers></td>
179 <td headers> <a href="https://github.com/accordproject/cicero/tree/master/packages/cicero-cli">cicero-cli</a></td>
180 <td headers> <a href="https://badge.fury.io/js/%40accordproject%2Fcicero-cli"><img src="https://badge.fury.io/js/%40accordproject%2Fcicero-cli.svg" alt="npm version"></a></td>
181 <td headers> Cicero CLI </td>
182 </tr>
183 <tr>
184 <td headers></td>
185 <td headers> <a href="https://github.com/accordproject/cicero/tree/master/packages/cicero-engine">cicero-engine</a></td>
186 <td headers> <a href="https://badge.fury.io/js/%40accordproject%2Fcicero-engine"><img src="https://badge.fury.io/js/%40accordproject%2Fcicero-engine.svg" alt="npm version"></a></td>
187 <td headers>Node.js VM based implementation of Accord Protcol Template Specification execution</td>
188 </tr>
189 <tr>
190 <td headers></td>
191 <td headers> <a href="https://github.com/accordproject/cicero/tree/master/packages/cicero-server">cicero-server</a></td>
192 <td headers> <a href="https://badge.fury.io/js/%40accordproject%2Fcicero-server"><img src="https://badge.fury.io/js/%40accordproject%2Fcicero-server.svg" alt="npm version"></a></td>
193 <td headers>Wraps the Cicero Engine and exposes it as a RESTful service<td>
194 </tr>
195 <tr>
196 <td headers></td>
197 <td headers> <a href="https://github.com/accordproject/cicero/tree/master/packages/cicero-test">cicero-test</a></td>
198 <td headers> <a href="https://badge.fury.io/js/%40accordproject%2Fcicero-test"><img src="https://badge.fury.io/js/%40accordproject%2Fcicero-test.svg" alt="npm version"></a></td>
199 <td headers> Testing support for Cicero based on cucumber</td>
200 </tr>
201 <tr>
202 <td headers></td>
203 <td headers> <a href="https://github.com/accordproject/cicero/tree/master/packages/cicero-tools">cicero-tools</a></td>
204 <td headers> <a href="https://badge.fury.io/js/%40accordproject%2Fcicero-tools"><img src="https://badge.fury.io/js/%40accordproject%2Fcicero-tools.svg" alt="npm version"></a></td>
205 <td headers>Cicero Tools</td>
206 </tr>
207 <tr>
208 <td headers="co1 c1"></td>
209 <td headers="co2 c1"> <a href="https://github.com/accordproject/cicero/tree/master/packages/generator-cicero-template">generator-cicero-template</a></td>
210 <td headers="co3 c1"> <a href="https://badge.fury.io/js/%40accordproject%2Fgenerator-cicero-template"><img src="https://badge.fury.io/js/%40accordproject%2Fgenerator-cicero-template.svg" alt="npm version"></a></td>
211 <td headers="co4 c1">Code generator for a Cicero Template</td>
212 </tr>
213 <tr>
214 <td headers><a href="https://github.com/accordproject/concerto">Concerto</a></td>
215 <td headers><a href="https://github.com/accordproject/concerto/tree/master/packages/concerto-core">concerto-core</a></td>
216 <td headers> <a href="https://badge.fury.io/js/%40accordproject%2Fconcerto-core"><img src="https://badge.fury.io/js/%40accordproject%2Fconcerto-core.svg" alt="npm version"></a></td>
217 <td headers> Core Implementation for the Concerto Modeling Language</td>
218 </tr>
219 <tr>
220 <td headers></td>
221 <td headers><a href="https://github.com/accordproject/concerto/tree/master/packages/concerto-tools">concerto-tools</a></td>
222 <td headers> <a href="https://badge.fury.io/js/%40accordproject%2Fconcerto-tools"><img src="https://badge.fury.io/js/%40accordproject%2Fconcerto-tools.svg" alt="npm version"></a></td>
223 <td headers> Tools for the Concerto Modeling Language</td>
224 </tr>
225 <tr>
226 <td headers></td>
227 <td headers><a href="https://github.com/accordproject/concerto/tree/master/packages/concerto-cli">concerto-cli</a></td>
228 <td headers> <a href="https://badge.fury.io/js/%40accordproject%2Fconcerto-cli"><img src="https://badge.fury.io/js/%40accordproject%2Fconcerto-cli.svg" alt="npm version"></a></td>
229 <td headers>command-line interface for Concerto</td>
230 </tr>
231 <tr>
232 <td headers><a href="https://github.com/accordproject/ergo">Ergo</a></td>
233 <td headers><a href="https://github.com/accordproject/ergo/tree/master/packages/ergo-cli">ergo-cli</a></td>
234 <td headers><a href="https://badge.fury.io/js/%40accordproject%2Fergo-cli"><img src="https://badge.fury.io/js/%40accordproject%2Fergo-cli.svg" alt="npm version"></a></td>
235 <td headers>Ergo CLI</td>
236 </tr>
237 <tr>
238 <th id="blank"></th>
239 <td headers><a href="https://github.com/accordproject/ergo/tree/master/packages/ergo-compiler">ergo-compiler</a></td>
240 <td headers><a href="https://badge.fury.io/js/%40accordproject%2Fergo-compiler"><img src="https://badge.fury.io/js/%40accordproject%2Fergo-compiler.svg" alt="npm version"></a></td>
241 <td headers>Ergo compiler</td>
242 </tr>
243 <tr>
244 <th id="blank"></th>
245 <td headers><a href="https://github.com/accordproject/ergo/tree/master/packages/ergo-test">ergo-test</a></td>
246 <td headers><a href="https://badge.fury.io/js/%40accordproject%2ergo-test"><img src="https://badge.fury.io/js/%40accordproject%2Fergo-test.svg" alt="npm version"></a></td>
247 <td headers>Ergo test</td>
248 </tr>
249 <tr>
250 <th id="blank"></th>
251 <td headers><a href="https://github.com/accordproject/ergo/tree/master/packages/ergo-engine">ergo-engine</a></td>
252 <td headers><a href="https://badge.fury.io/js/%40accordproject%2Fergo-engine"><img src="https://badge.fury.io/js/%40accordproject%2Fergo-engine.svg" alt="npm version"></a></td>
253 <td headers>Ergo engine</td>
254 </tr>
255 <tr>
256 <td headers><a href="https://docs.accordproject.org/docs/next/markup-cicero.html">Markdown</a></td>
257 <td headers><a href="https://github.com/accordproject/markdown-transform/tree/master/packages/markdown-common">markdown-common</a></td>
258 <td headers><a href="https://badge.fury.io/js/%40accordproject%2Fmarkdown-common"><img src="https://badge.fury.io/js/%40accordproject%2Fmarkdown-common.svg" alt="npm version"></a></td>
259 <td headers>A framework for transforming markdown</td>
260 </tr>
261 <tr>
262 <th id="blank"></th>
263 <td headers><a href="https://github.com/accordproject/markdown-transform/tree/master/packages/markdown-slate">markdown-slate</a></td>
264 <td headers><a href="https://badge.fury.io/js/%40accordproject%2Fmarkdown-slate"><img src="https://badge.fury.io/js/%40accordproject%2Fmarkdown-slate.svg" alt="npm version"></a></td>
265 <td headers>Transform markdown to/from CommonMark DOM</td>
266 </tr>
267 <tr>
268 <td headers></td>
269 <td headers><a href="https://github.com/accordproject/markdown-transform/tree/master/packages/markdown-cli"> markdown-cli </a></td>
270 <td headers> <a href="https://badge.fury.io/js/%40accordproject%2Fmarkdown-cli"><img src="https://badge.fury.io/js/%40accordproject%2Fmarkdown-cli.svg" alt="npm version"></a></td>
271 <td headers> CLI for markdown transformations.</td>
272 </tr>
273 <tr>
274 <th id="blank"></th>
275 <td headers><a href="https://github.com/accordproject/markdown-transform/tree/master/packages/markdown-cicero">markdown-cicero</a></td>
276 <td headers><a href="https://badge.fury.io/js/%40accordproject%2Fmarkdown-cicero"><img src="https://badge.fury.io/js/%40accordproject%2Fmarkdown-cicero.svg" alt="npm version"></a></td>
277 <td headers>CiceroDOM: Markdown extensions for contracts, clauses, variables etc.</td>
278 </tr>
279 <tr>
280 <th id="blank"></th>
281 <td headers><a href="https://github.com/accordproject/markdown-transform/tree/master/packages/markdown-html">markdown-html</a></td>
282 <td headers><a href="https://badge.fury.io/js/%40accordproject%2Fmarkdown-html"><img src="https://badge.fury.io/js/%40accordproject%2Fmarkdown-html.svg" alt="npm version"></a></td>
283 <td headers>Transform CiceroDOM to HTML</td>
284 </tr>
285
286</table>
287
288#### UI Components:
289
290<table>
291 <tr>
292 <th headers="blank">Projects</th>
293 <th headers="blank">Package name</th>
294 <th headers="blank">Version</th>
295 <th headers="blank">Description</th>
296 </tr>
297 <tr>
298 <td headers>Markdown Editor</td>
299 <td headers><a href="https://github.com/accordproject/markdown-editor">markdown-editor</a></td>
300 <td headers> <a href="https://badge.fury.io/js/%40accordproject%2Fmarkdown-editor">
301 <img src="https://badge.fury.io/js/%40accordproject%2Fmarkdown-editor.svg" alt="npm version"></a></td>
302 <td headers>WYSIWYG rich text web editor that persists text as markdown. Based on Slate.js</td>
303 </tr>
304 <tr>
305 <td headers="co1 c1">Cicero UI</td>
306 <td headers="co2 c1"><a href="https://github.com/accordproject/cicero-ui">cicero-ui</a></td>
307 <td headers="co3 c1"> <a href="https://badge.fury.io/js/%40accordproject%2Fcicero-ui"><img src="https://badge.fury.io/js/%40accordproject%2Fcicero-ui.svg" alt="npm version"></a></td>
308 <td headers="co4 c1">WYSIWYG contract editor, template libary browser, error panel component</td>
309 </tr>
310 <tr>
311 <td headers="co1 c1">Concerto UI</td>
312 <td headers="co2 c1"><a href="https://github.com/accordproject/concerto-ui">concerto-ui</a></td>
313 <td headers="co3 c1"> <a href="https://badge.fury.io/js/%40accordproject%2Fconcerto-ui-react"><img src="https://badge.fury.io/js/%40accordproject%2Fconcerto-ui-react.svg" alt="npm version"></a></td>
314 <td headers="co4 c1">Dynamic web forms generated from Concerto models</td>
315 </tr>
316</table>
317
318
319#### Template Editors:
320
321<table>
322 <tr>
323 <th headers="blank">Projects</th>
324 <th headers="blank">Cicero ver.</th>
325 <th headers="blank">Description</th>
326 </tr>
327 <tr>
328 <td headers><a href="https://github.com/accordproject/template-studio">Template Studio v1</a></td>
329 <td headers> <b>0.13.4</b></td>
330 <td headers>Web UI for creating, editing and testing Accord Project templates</td>
331 </tr>
332 <tr>
333 <td headers><a href="https://github.com/accordproject/template-studio-v2">Template Studio v2</a></td>
334 <td headers> <b>0.13.4</b></td>
335 <td headers>Web UI for creating, editing and testing Accord Project templates</td>
336 </tr>
337 <tr>
338 <td headers><a href="https://github.com/accordproject/cicero-vscode-extension">VSCode Extension</a></td>
339 <td headers><b>0.13.4</b></td>
340 <td headers>VS Code extension for editing Cicero templates and Ergo logic</td>
341 </tr>
342</table>
343
344
345#### Public templates and models:
346
347<table>
348 <tr>
349 <th headers="blank">Projects</th>
350 <th headers="blank">Description</th>
351 </tr>
352 <tr>
353 <td headers><a href="https://github.com/accordproject/models">Models</a></td>
354 <td headers>Accord Project Model Library </td>
355 </tr>
356 <tr>
357 <td headers><a href="https://github.com/accordproject/cicero-template-library">Template Library</a></td>
358 <td headers>Accord Project Template Library </td>
359 </tr>
360
361</table>
362
363
364#### Documentation:
365
366<table>
367 <tr>
368 <th headers="blank">Project</th>
369 <th headers="blank">Repo</th>
370 </tr>
371 <tr>
372 <td headers><a href="https://docs.accordproject.org/">Documentation</a></td>
373 <td headers><a href="https://github.com/accordproject/techdocs">techdocs</a></td>
374 </tr>
375 </table>
376
377## Contributing
378
379The Accord Project technology is being developed as open source. All the software packages are being actively maintained on GitHub and we encourage organizations and individuals to contribute requirements, documentation, issues, new templates, and code.
380
381Find out what’s coming on our [blog][apblog].
382
383Join the Accord Project Technology Working Group [Slack channel][apslack] to get involved!
384
385For code contributions, read our [CONTRIBUTING guide][contributing] and information for [DEVELOPERS][developers].
386
387## License <a name="license"></a>
388
389Accord Project source code files are made available under the [Apache License, Version 2.0][apache].
390Accord Project documentation files are made available under the [Creative Commons Attribution 4.0 International License][creativecommons] (CC-BY-4.0).
391
392[CommonMark]: https://commonmark.org
393[slate]: https://docs.slatejs.org/
394
395[linuxfound]: https://www.linuxfoundation.org
396[charter]: https://github.com/accordproject/markdown-editor/blob/master/CHARTER.md
397[apmain]: https://accordproject.org/
398[apworkgroup]: https://calendar.google.com/calendar/event?action=TEMPLATE&tmeid=MjZvYzIzZHVrYnI1aDVzbjZnMHJqYmtwaGlfMjAxNzExMTVUMjEwMDAwWiBkYW5AY2xhdXNlLmlv&tmsrc=dan%40clause.io
399[apblog]: https://medium.com/@accordhq
400[apnews]: https://www.accordproject.org/news/
401[apgit]: https://github.com/accordproject/
402[apdoc]: https://docs.accordproject.org/
403[apslack]: https://accord-project-slack-signup.herokuapp.com
404
405[docspec]: https://docs.accordproject.org/docs/spec-overview.html
406[docwelcome]: https://docs.accordproject.org/docs/accordproject.html
407[dochighlevel]: https://docs.accordproject.org/docs/spec-concepts.html
408[docergo]: https://docs.accordproject.org/docs/logic-ergo.html
409[docstart]: https://docs.accordproject.org/docs/accordproject.html
410[doccicero]: https://docs.accordproject.org/docs/basic-use.html
411[docstudio]: https://docs.accordproject.org/docs/advanced-latedelivery.html
412
413[contributing]: https://github.com/accordproject/markdown-editor/blob/master/CONTRIBUTING.md
414[developers]: https://github.com/accordproject/markdown-editor/blob/master/DEVELOPERS.md
415
416[apache]: https://github.com/accordproject/markdown-editor/blob/master/LICENSE
417[creativecommons]: http://creativecommons.org/licenses/by/4.0/