plantuml.js 714 B

1234567891011121314151617181920212223242526
  1. import urljoin from 'url-join';
  2. export default class PlantUMLConfigurer {
  3. constructor(crowi) {
  4. this.crowi = crowi;
  5. const config = crowi.getConfig();
  6. this.deflate = require('markdown-it-plantuml/lib/deflate.js');
  7. this.serverUrl = config.env.PLANTUML_URI || 'http://plantuml.com';
  8. this.generateSource = this.generateSource.bind(this);
  9. }
  10. configure(md) {
  11. md.use(require('markdown-it-plantuml'), 'name', {
  12. generateSource: this.generateSource,
  13. });
  14. }
  15. generateSource(umlCode) {
  16. const zippedCode =
  17. this.deflate.encode64(this.deflate.zip_deflate('@startuml\n' + umlCode + '\n@enduml', 9));
  18. return urljoin(this.serverUrl, 'plantuml', 'svg' , zippedCode);
  19. }
  20. }