mirror of
https://github.com/octoleo/plantuml-server.git
synced 2024-11-17 01:35:13 +00:00
478ef3bce7
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
:
components
are for example a modal or dialog. Anything that include things directly seen and rendered on the page.js
contains 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
registerXxxCompletion
method
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.js
const 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.js
to get an idea how to register a new listener. - add your new method inside the language initialization inside
js/language/language.js
const 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
: setwithoutCSSJSCompress
totrue
to deactivate the minification- use
mvn fizzed-watcher:run
to watch changes and automatically update the bundledplantuml.min.{css,js}
andplantuml-language.min.js
files - if the browser get the error
ReferenceError: require is not defined
or something similar related to the webjars, trymvn clean install
to get things straight