editors.js 811 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const Model = require('objection').Model
  2. /* global WIKI */
  3. /**
  4. * Editor model
  5. */
  6. module.exports = class Editor extends Model {
  7. static get tableName() { return 'editors' }
  8. static get idColumn() { return 'key' }
  9. static get jsonSchema () {
  10. return {
  11. type: 'object',
  12. required: ['key', 'isEnabled'],
  13. properties: {
  14. key: {type: 'string'},
  15. isEnabled: {type: 'boolean'}
  16. }
  17. }
  18. }
  19. static get jsonAttributes() {
  20. return ['config']
  21. }
  22. static async getEditors() {
  23. return WIKI.models.editors.query()
  24. }
  25. static async getDefaultEditor(contentType) {
  26. // TODO - hardcoded for now
  27. switch (contentType) {
  28. case 'markdown':
  29. return 'markdown'
  30. case 'html':
  31. return 'ckeditor'
  32. default:
  33. return 'code'
  34. }
  35. }
  36. }