/
SimpleWriterPackage.js
48 lines (41 loc) · 1.54 KB
/
SimpleWriterPackage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import {
BasePackage, StrongPackage, EmphasisPackage, LinkPackage, Document,
ParagraphPackage, HeadingPackage, CodeblockPackage, SwitchTextTypePackage
} from 'substance'
import BodyPackage from '../body/BodyPackage'
import CommentPackage from '../comment/CommentPackage'
import SimpleHTMLImporter from './SimpleHTMLImporter'
/**
Standard configuration for SimpleWriter
We define a schema (simple-article) import some core packages
from Substance, as well as custom node types.
An HTML importer is registered to be able to turn HTML markup
into a SimpleArticle instance.
*/
export default {
name: 'simple-writer',
configure: function (config) {
config.defineSchema({
name: 'simple-article',
ArticleClass: Document,
defaultTextType: 'paragraph'
})
// BasePackage provides core functionaliy, such as undo/redo
// and the SwitchTextTypeTool. However, you could import those
// functionalities individually if you need more control
config.import(BasePackage)
config.import(SwitchTextTypePackage)
// core nodes
config.import(ParagraphPackage)
config.import(HeadingPackage)
config.import(CodeblockPackage)
config.import(StrongPackage, {toolGroup: 'annotations'})
config.import(EmphasisPackage, {toolGroup: 'annotations'})
config.import(LinkPackage, {toolGroup: 'annotations'})
// custom nodes
config.import(BodyPackage)
config.import(CommentPackage, {toolGroup: 'annotations'})
// Override Importer/Exporter
config.addImporter('html', SimpleHTMLImporter)
}
}