editors.js 788 B

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