Explorar o código

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

GitOrigin-RevId: 58e9eed34137a7cf66f301972e066cb5b5bb79e4
Alf Eaton %!s(int64=4) %!d(string=hai) anos
pai
achega
74be20292e

+ 1 - 2
services/web/frontend/js/utils/EventEmitter.js

@@ -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) {

+ 6 - 3
services/web/types/current-doc.ts

@@ -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
 }

+ 9 - 0
services/web/types/share-doc.ts

@@ -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
+}