current-doc.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import EventEmitter from '../frontend/js/utils/EventEmitter'
  2. import { ShareDoc } from './share-doc'
  3. import { EditorFacade } from '../modules/source-editor/frontend/js/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. export interface CurrentDoc extends EventEmitter {
  15. doc_id: string
  16. docName: string
  17. doc: ShareDoc | null
  18. track_changes_as: string | null
  19. ranges: {
  20. changes: Change<InsertOperation | ChangeOperation | DeleteOperation>[]
  21. comments: Change<CommentOperation>[]
  22. resolvedThreadIds: Record<string, any>
  23. removeCommentId: (id: string) => void
  24. removeChangeIds: (ids: string[]) => void
  25. getChanges: (
  26. ids: string[]
  27. ) => Change<InsertOperation | ChangeOperation | DeleteOperation>[]
  28. validate: (text: string) => void
  29. }
  30. attachToCM6: (editor: EditorFacade) => void
  31. detachFromCM6: () => void
  32. submitOp: (op: AnyOperation) => void
  33. getSnapshot: () => string
  34. }