12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- const Model = require('objection').Model
- /* global WIKI */
- /**
- * Editor model
- */
- module.exports = class Editor extends Model {
- static get tableName() { return 'editors' }
- static get idColumn() { return 'key' }
- static get jsonSchema () {
- return {
- type: 'object',
- required: ['key', 'isEnabled'],
- properties: {
- key: {type: 'string'},
- isEnabled: {type: 'boolean'}
- }
- }
- }
- static get jsonAttributes() {
- return ['config']
- }
- static async getEditors() {
- return WIKI.models.editors.query()
- }
- static async getDefaultEditor(contentType) {
- // TODO - hardcoded for now
- switch (contentType) {
- case 'markdown':
- return 'markdown'
- case 'html':
- return 'ckeditor'
- default:
- return 'code'
- }
- }
- }
|