editor-settings.ts 814 B

1234567891011121314151617181920212223242526
  1. import type { EditorSettings } from '@growi/editor';
  2. import type { Document, Model } from 'mongoose';
  3. import { Schema } from 'mongoose';
  4. import { getOrCreateModel } from '../util/mongoose-utils';
  5. export interface EditorSettingsDocument extends EditorSettings, Document {
  6. userId: Schema.Types.ObjectId;
  7. }
  8. export type EditorSettingsModel = Model<EditorSettingsDocument>;
  9. const editorSettingsSchema = new Schema<
  10. EditorSettingsDocument,
  11. EditorSettingsModel
  12. >({
  13. userId: { type: Schema.Types.ObjectId },
  14. theme: { type: String },
  15. keymapMode: { type: String },
  16. styleActiveLine: { type: Boolean, default: false },
  17. autoFormatMarkdownTable: { type: Boolean, default: true },
  18. });
  19. export default getOrCreateModel<EditorSettingsDocument, EditorSettingsModel>(
  20. 'EditorSettings',
  21. editorSettingsSchema,
  22. );