Standardise types for ranges (#16927)
GitOrigin-RevId: 28dd0eb67e1684e6bd0e452d15315ce1f9e3481a
This commit is contained in:
@@ -1,36 +1,31 @@
|
||||
import { ThreadId } from './review-panel/review-panel'
|
||||
import { UserId } from './user'
|
||||
|
||||
export interface Operation {
|
||||
p: number
|
||||
p: number // position
|
||||
}
|
||||
|
||||
export interface InsertOperation extends Operation {
|
||||
i: string
|
||||
t: string
|
||||
}
|
||||
|
||||
export interface ChangeOperation extends Operation {
|
||||
c: string
|
||||
t: string
|
||||
i: string // inserted text
|
||||
}
|
||||
|
||||
export interface DeleteOperation extends Operation {
|
||||
d: string
|
||||
d: string // deleted text
|
||||
}
|
||||
|
||||
export interface CommentOperation extends Operation {
|
||||
c: string
|
||||
c: string // comment text
|
||||
t: ThreadId // thread/comment id
|
||||
}
|
||||
|
||||
export type NonCommentOperation =
|
||||
| InsertOperation
|
||||
| ChangeOperation
|
||||
| DeleteOperation
|
||||
export type EditOperation = InsertOperation | DeleteOperation
|
||||
|
||||
export type AnyOperation = NonCommentOperation | CommentOperation
|
||||
export type AnyOperation = EditOperation | CommentOperation
|
||||
|
||||
export type Change<T extends AnyOperation = AnyOperation> = {
|
||||
id: string
|
||||
metadata?: {
|
||||
user_id: string
|
||||
user_id: UserId | null
|
||||
ts: Date
|
||||
}
|
||||
op: T
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
import EventEmitter from '../frontend/js/utils/EventEmitter'
|
||||
import { ShareDoc } from './share-doc'
|
||||
import { EditorFacade } from '../frontend/js/features/source-editor/extensions/realtime'
|
||||
import {
|
||||
AnyOperation,
|
||||
Change,
|
||||
ChangeOperation,
|
||||
CommentOperation,
|
||||
DeleteOperation,
|
||||
InsertOperation,
|
||||
} from './change'
|
||||
|
||||
// type for the Document class in ide/editor/Document.js
|
||||
// note: this is a custom EventEmitter class
|
||||
|
||||
// TODO: MIGRATION: This doesn't match the type for
|
||||
// ide-react/editor/document.ts, which has a nullable `ranges` property and some
|
||||
// other quirks. They should match.
|
||||
export interface CurrentDoc extends EventEmitter {
|
||||
doc_id: string
|
||||
docName: string
|
||||
doc: ShareDoc | null
|
||||
track_changes_as: string | null
|
||||
ranges: {
|
||||
changes: Change<InsertOperation | ChangeOperation | DeleteOperation>[]
|
||||
comments: Change<CommentOperation>[]
|
||||
resolvedThreadIds: Record<string, any>
|
||||
removeCommentId: (id: string) => void
|
||||
removeChangeIds: (ids: string[]) => void
|
||||
getChanges: (
|
||||
ids: string[]
|
||||
) => Change<InsertOperation | ChangeOperation | DeleteOperation>[]
|
||||
validate: (text: string) => void
|
||||
}
|
||||
attachToCM6: (editor: EditorFacade) => void
|
||||
detachFromCM6: () => void
|
||||
submitOp: (op: AnyOperation) => void
|
||||
getSnapshot: () => string
|
||||
}
|
||||
Reference in New Issue
Block a user