current-doc.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import EventEmitter from '../frontend/js/utils/EventEmitter'
  2. import { ShareDoc } from './share-doc'
  3. import { EditorFacade } from '../frontend/js/features/source-editor/extensions/realtime'
  4. import {
  5. AnyOperation,
  6. Change,
  7. ChangeOperation,
  8. CommentOperation,
  9. DeleteOperation,
  10. InsertOperation,
  11. } from './change'
  12. // type for the Document class in ide/editor/Document.js
  13. // note: this is a custom EventEmitter class
  14. // TODO: MIGRATION: This doesn't match the type for
  15. // ide-react/editor/document.ts, which has a nullable `ranges` property and some
  16. // other quirks. They should match.
  17. export interface CurrentDoc extends EventEmitter {
  18. doc_id: string
  19. docName: string
  20. doc: ShareDoc | null
  21. track_changes_as: string | null
  22. ranges: {
  23. changes: Change<InsertOperation | ChangeOperation | DeleteOperation>[]
  24. comments: Change<CommentOperation>[]
  25. resolvedThreadIds: Record<string, any>
  26. removeCommentId: (id: string) => void
  27. removeChangeIds: (ids: string[]) => void
  28. getChanges: (
  29. ids: string[]
  30. ) => Change<InsertOperation | ChangeOperation | DeleteOperation>[]
  31. validate: (text: string) => void
  32. }
  33. attachToCM6: (editor: EditorFacade) => void
  34. detachFromCM6: () => void
  35. submitOp: (op: AnyOperation) => void
  36. getSnapshot: () => string
  37. }