Since the front-end received much more code (features) than first expected, the files became much too large. For this reason, the JS and CSS code has now been split by component and thus into several small files. However, since there are now many small files, a JS and CSS bundle tool had to come :D.
3.8 KiB
3.8 KiB
Front-end Contribution
Web UI
The Web UI uses vanilla javascript.
As online editor Microsoft's Monaco Editor. The documentation can be found here. You may recognize the editor since it's the code editor from VS Code.
The main entry file are index.jsp, previewer.jsp and error.jsp.
The code structure is mainly divided into components and js:
componentsare for example a modal or dialog. Anything that include things directly seen and rendered on the page.jscontains more the things that do not have a direct influence on the UI. For example the PlantUML language features or the methods for cross-browser/cross-tab communication.
PlantUML Language Features
At the moment there is no defined PlantUML language.
Feel free to create one!
But until then the syntax highlighting form apex is used.
IMHO it works quite well.
All PlantUML language features are bundled into a seperate file plantuml-language.min.js.
Therefore anything under js/language should be independent!
Code Completion
What do you need to do to create a new code completion feature:
- create a new JS file under
js/language/completion- let's sayxxx.js - create a new
registerXxxCompletionmethod
It may help you if you look into the documentation or at the provided sample code to understand more aboutmonaco.languages.registerCompletionItemProvider.PlantUmlLanguageFeatures.prototype.registerEmojiCompletion = function() { monaco.languages.registerCompletionItemProvider(PlantUmlLanguageFeatures.languageSelector, { provideCompletionItems: async (model, position) => { // ... return { suggestions }; } }); }; - add your new method inside the language initialization inside
js/language/language.jsconst PlantUmlLanguageFeatures = function(initialize = true) { if (initialize) { // initialize all validation and code completion methods this.addStartEndValidationListeners(); this.registerThemeCompletion(); this.registerIconCompletion(); this.registerEmojiCompletion(); + this.registerXxxCompletion(); } };
Code Validation
What do you need to do to create a new code validation feature:
- create a new JS file under
js/language/validation/listeners- let's sayzzz-validation.js - register your validation methods to the designated event listener
The validation event order is:before→code→line→after
You may look atjs/language/validation/listeners/start-end-validation.jsto get an idea how to register a new listener. - add your new method inside the language initialization inside
js/language/language.jsconst PlantUmlLanguageFeatures = function(initialize = true) { if (initialize) { // initialize all validation and code completion methods this.addStartEndValidationListeners(); + this.addZzzValidationListeners(); this.registerThemeCompletion(); this.registerIconCompletion(); this.registerEmojiCompletion(); } };
Tipps
pom.xml: setwithoutCSSJSCompresstotrueto deactivate the minification- use
mvn fizzed-watcher:runto watch changes and automatically update the bundledplantuml.min.{css,js}andplantuml-language.min.jsfiles - if the browser get the error
ReferenceError: require is not definedor something similar related to the webjars, trymvn clean installto get things straight