The form-builder language is implemented as three main parts:
- Ace editor - for highlight and autocomplete editor
nearley.js
parser - turns form-definition into structured json- A builder that turns the json into html
In addition, there's a help file
- Add to
ace/lib/ace/mode/formbuilder_highlight_rules.js
the language rules. See documentation here. - Add to
ace/lib/ace/mode/formbuilder.js
indent and outdent rules. Make sure you add both. - From the root of the project, run
npm run build_ace
. Files will be compiled intosrc/ace
- For the autocomplete to work, add
keywords
andconsts
tosrc/editor-init.js
- In the same file, update the snippets or add new ones to show the new features of the language
- In
src/index.html
update the default form to show your the new features of the language
Ace editor is only used for the editor itself. However, the language parser and builder is using nearley.js
- a flexible language parser.
The grammar file is located at src/parser/grammar
. It is similar concept of Ace highlight rules, but in a slightly different syntax. Unfortunately I couldn't find an easy way to reuse the same language rules for both Ace and nearley.
- Install nearley globally
npm install -g nearley
- Edit the grammar file and add the new language rules. Each rule should have a function that returns a json that represents the new language feature.
- You can use
nearley-test
in your console to quickly test your new grammar against some form definition, or use the playground to do it online. - Compile the grammar using
npm run build_grammar
. The result is written togrammar.js
just next to the grammar source file.
- Edit
src/builder.js
. It uses js template strings as its template engine. - Install sass globally using
npm install -g sass
- Edit
src/themes/default.scss
and add any relevant css rules. - Compile the scss file using
npm run build_themes
and commit the result css and map files. It will be in the same folder.
- Edit
src/help.js
and describe your additions.