Classes
Components
Modules
Configurator
Class defined in util/Configurator.js#55
Default Configurator for Substance editors. It provides an API for adding nodes to the schema, components, commands and tools etc.
Example
let configurator = new Configurator()
configurator.addNode(Heading)
configurator.addComponent('heading', HeadingComponent)
To modularize configuration, package definitions can be imported.
configurator.import(ParagraphPackage)
You can create your own extensions that way.
const AlienPackage = {
name: 'alien'
configure: function(config) {
config.addNode(AlienNode)
config.addComponent('alien', AlienComponent)
config.addCommand('add-alien', AddAlienCommand)
config.addTool('add-alien', AddAlienTool)
}
}
From within a package, another package can be imported. This provides a simple mechanism to model dependencies between packages. Just make sure you don't run into cyclic dependencies as there is no checking for that at the moment.
new Configurator()
Constructor defined in util/Configurator.js#56
this.addNode()
Method defined in util/Configurator.js#85
- @param {String} NodeClass node class name.
this.addLabel(labelName, label)
Method defined in util/Configurator.js#190
Parameters
labelName | String | name of label. |
label | String | label. Define a new label Label is either a string or a hash with translations. If string is provided 'en' is used as the language. |
this.addSeed(seed)
Method defined in util/Configurator.js#230
Parameters
seed | Seed function. Define a seed function Seed function is a transaction function. |
Example
var seedFn = function(tx) {
var body = tx.get('body');
tx.create({
id: 'p1',
type: 'paragraph',
content: 'This is your new paragraph!'
});
body.show('p1');
};
config.addSeed(seedFn);