diff --git a/javascript/src/api.ts b/javascript/src/api.ts index 3eaf995..d929a46 100644 --- a/javascript/src/api.ts +++ b/javascript/src/api.ts @@ -746,6 +746,10 @@ export type CellChange = SourceChange & { * Cell output changes */ outputsChange?: Delta>; + /** + * Cell stream output text changes + */ + streamOutputChange?: Delta; /** * Cell execution count change */ diff --git a/javascript/src/ycell.ts b/javascript/src/ycell.ts index a4df55c..b569937 100644 --- a/javascript/src/ycell.ts +++ b/javascript/src/ycell.ts @@ -827,24 +827,24 @@ export class YCodeCell /** * Remove text from a stream output. */ - removeStreamOutput(index: number, start: number): void { + removeStreamOutput(index: number, start: number, origin: any = null): void { this.transact(() => { const output = this._youtputs.get(index); const prevText = output.get('text') as Y.Text; const length = prevText.length - start; prevText.delete(start, length); - }, false); + }, false, origin); } /** * Append text to a stream output. */ - appendStreamOutput(index: number, text: string): void { + appendStreamOutput(index: number, text: string, origin: any = null): void { this.transact(() => { const output = this._youtputs.get(index); const prevText = output.get('text') as Y.Text; prevText.insert(prevText.length, text); - }, false); + }, false, origin); } /** @@ -895,6 +895,13 @@ export class YCodeCell protected getChanges(events: Y.YEvent[]): Partial { const changes = super.getChanges(events); + const streamOutputEvent = events.find( + event => event.path.length === 3 && event.path[0] === 'outputs' && event.path[2] === 'text' + ); + if (streamOutputEvent) { + changes.streamOutputChange = streamOutputEvent.changes.delta as any; + } + const outputEvent = events.find( event => event.target === this.ymodel.get('outputs') );