Skip to content

Commit 527be8c

Browse files
committed
Add pushStreamOutput method
1 parent 8d7daaf commit 527be8c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

javascript/src/ycell.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,8 @@ export class YCodeCell
764764
return JSONExt.deepCopy(this._youtputs.toJSON());
765765
}
766766

767-
createOutputs(outputs: Array<nbformat.IOutput>): Array<any> {
768-
const newOutputs: Array<any> = [];
767+
createOutputs(outputs: Array<nbformat.IOutput>): Array<Y.Map<any>> {
768+
const newOutputs: Array<Y.Map<any>> = [];
769769
for (const output of outputs) {
770770
let _newOutput: { [id: string]: any };
771771
const newOutput = new Y.Map();
@@ -798,6 +798,17 @@ export class YCodeCell
798798
}, false);
799799
}
800800

801+
/**
802+
* Push text to a stream output.
803+
*/
804+
pushStreamOutput(index: number, text: string): void {
805+
this.transact(() => {
806+
const output = this._youtputs.get(index);
807+
const prevText = output.get('text') as Y.Array<string>;
808+
prevText.push([text]);
809+
}, false);
810+
}
811+
801812
/**
802813
* Replace content from `start' to `end` with `outputs`.
803814
*
@@ -863,7 +874,7 @@ export class YCodeCell
863874
return changes;
864875
}
865876

866-
private _youtputs: Y.Array<nbformat.IOutput>;
877+
private _youtputs: Y.Array<Y.Map<any>>;
867878
}
868879

869880
class YAttachmentCell

0 commit comments

Comments
 (0)