Wrap the SourceEditor component in an error boundary (#8605)

GitOrigin-RevId: 58e9eed34137a7cf66f301972e066cb5b5bb79e4
This commit is contained in:
Alf Eaton 2022-08-24 12:49:15 +01:00 committed by Copybot
parent c2b4a2d3ea
commit 74be20292e
3 changed files with 16 additions and 5 deletions

View file

@ -20,9 +20,8 @@
// Trigger all events for the foo event (including namespaces): .trigger 'foo'
// Remove all listeners for the foo event (including namespaces): .off 'foo'
// Remove a listener for the foo event with the bar namespace: .off 'foo.bar'
let EventEmitter
export default EventEmitter = class EventEmitter {
export default class EventEmitter {
on(event, callback) {
let namespace
if (!this.events) {

View file

@ -1,3 +1,5 @@
import EventEmitter from '../frontend/js/utils/EventEmitter'
import { ShareDoc } from './share-doc'
import { EditorFacade } from '../modules/source-editor/frontend/js/extensions/realtime'
import {
AnyOperation,
@ -8,9 +10,12 @@ import {
InsertOperation,
} from './change'
export type CurrentDoc = {
// type for the Document class in ide/editor/Document.js
// note: this is a custom EventEmitter class
export interface CurrentDoc extends EventEmitter {
doc_id: string
docName: string
doc: ShareDoc | null
track_changes_as: string | null
ranges: {
changes: Change<InsertOperation | ChangeOperation | DeleteOperation>[]
@ -25,8 +30,6 @@ export type CurrentDoc = {
}
attachToCM6: (editor: EditorFacade) => void
detachFromCM6: () => void
on: (eventName: string, listener: EventListener) => void
off: (eventName: string) => void
submitOp: (op: AnyOperation) => void
getSnapshot: () => string
}

View file

@ -0,0 +1,9 @@
import EventEmitter from 'events'
// type for the Doc class in vendor/libs/sharejs.js
export interface ShareDoc extends EventEmitter {
detach_cm6?: () => void
getText: () => string
insert: (pos: number, insert: string, fromUndo: boolean) => void
del: (pos: number, length: number, fromUndo: boolean) => void
}