Substance: a JavaScript library for web-based content editing
substance.io
substance.io
https://medium.com/@_mql/build-your-own-editor-with-substanc...
And some usage examples:
Scientific Writing - http://substance.io/lens - https://github.com/Coko-Foundation/pubsweet-core Spreadsheet Software - https://stenci.la/demo/sheets/iris Digital Archives: - https://medium.com/@_daniel/publish-interactive-historical-d...
however, the 'lens' example seems broken. in both FF and chrome (all up-to-date) I can't insert figures. FF just does nothing, chrome gives me a file chooser, but images do not appear in the document. is this a known bug ?
Especially since the generated HTML of the editor is very verbose and doesn't respect semantic (header1 isn't translate as h1 but a div with a super long id. Why?)
And what is so terrible about contentEditable? I spent a few minutes with it a few month ago and it felt great (and works on old version of IE), just lacking some library on top of it to give the end user a way to fully control everything.
Many of those editors tends to produce bad looking HTML code that might be fine for today but will become an headache to migrate to any other platform or will become an headache when somebody decide they want to change the color of all their link as their crappy editors produce inline styling ....
Anyway we might not have a one size fit all solution but WYSIWYG isn't a perfect solution either.
In the very near future there will also be NLM JATS XML support (a standard format in science).
To address the verbosity: if you're looking at the output HTML, you're looking at the wrong place. That's just a rendering of the internal model, which is very succinct and semantic indeed, e.g. in XML: https://github.com/substance/lens/blob/d18d2c6353db8d97649b9...
Each content type consists of the following pieces:
- Node (model) [1] - Component (visual representation) [2] - Converter (optional, used to map from and to XML/HTML) [3]
The verbose output for heading1 you see is just the DOM projection of the data, which is custom and can be specified in the Component implementation [2]. Often you need to add extra markup and interactive elements, so that's why for Substance content (data) is not rendered 1:1 but through a custom renderer component.
Please have a look at the examples [4], which includes minimal but functional implementations using most of the available concepts.
[1] https://github.com/substance/substance/blob/master/packages/... [2] https://github.com/substance/substance/blob/master/packages/... [3] https://github.com/substance/substance/blob/master/packages/... [4] https://github.com/substance/examples#substance-examples
Unfortunately it looks like it's JQuery and AMD modules, and I'm a Polymer and browserify shop, so it may just not be feasible. [sad face]
They are not AMD based (have a look here indeed https://github.com/substance/substance/blob/master/browser.j...) and about jQuery I’m pretty sure you can wrap it up as a Web Component pretty easily.
Also, did I say browserify? I meant vulcanize.
I've deleted the amd.boot.js file as it's no longer supported.
If the authors are around, I'd love to hear what was their thinking regarding implementing focus and selection, with regards to the inconvenients outlined by the author of ProseMirror here: http://marijnhaverbeke.nl/blog/prosemirror.html#general-appr...
In a nutshell, ProseMirror chose to keep contentEditable in order to have browser-level support for spell-checking, screen-readers, RTL, etc.
What are the tradeoffs exactly?
Thanks.
I had a brief talk with the author of ProseMirror the other day. From my point of view the difference lies in scope. ProseMirror's focus is providing an editor widget that can be extended but works out of the box with HTML + markdown. With Substance you basically start from zero, and you probably have to invest more time to get going. But then you could build apps that are not limited to one isolated editor area for instance. You could build a custom title editor, body editor and metadata editor and have a shared toolbar for them and shared undo/redo history. Substance also provides a bunch of top-level UI components that you can but don't have to use. A ScrollPane with a visual scrollbar for instance. A Table Of Contents component, TwoPanel editor layout etc.