plugin.js 883 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. export default class CrowiPlugin {
  2. /**
  3. * process plugin entry
  4. *
  5. * @param {Crowi} crowi Crowi context class
  6. * @param {CrowiRenderer} crowiRenderer CrowiRenderer
  7. *
  8. * @memberof CrowiPlugin
  9. */
  10. installAll(crowi, crowiRenderer) {
  11. // import plugin definitions
  12. let definitions = [];
  13. try {
  14. definitions = require('../../tmp/plugins/plugin-definitions');
  15. }
  16. catch (e) {
  17. // TODO show warning
  18. // do nothing
  19. return;
  20. }
  21. definitions.forEach((definition) => {
  22. const meta = definition.meta;
  23. switch (meta.pluginSchemaVersion) {
  24. // v1 is deprecated
  25. case 1:
  26. break;
  27. // v2 or above
  28. default:
  29. definition.entries.forEach((entry) => {
  30. entry(crowi, crowiRenderer);
  31. });
  32. }
  33. });
  34. }
  35. }
  36. window.crowiPlugin = new CrowiPlugin(); // FIXME