-
Notifications
You must be signed in to change notification settings - Fork 19
Add streamOutputChange
attribute to cell change object
#264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -827,24 +827,32 @@ export class YCodeCell | |
/** | ||
* Remove text from a stream output. | ||
*/ | ||
removeStreamOutput(index: number, start: number): 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); | ||
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, | ||
origin | ||
); | ||
} | ||
|
||
/** | ||
* Append text to a stream output. | ||
*/ | ||
appendStreamOutput(index: number, text: string): void { | ||
this.transact(() => { | ||
const output = this._youtputs.get(index); | ||
const prevText = output.get('text') as Y.Text; | ||
prevText.insert(prevText.length, text); | ||
}, false); | ||
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, | ||
origin | ||
); | ||
} | ||
|
||
/** | ||
|
@@ -895,6 +903,16 @@ export class YCodeCell | |
protected getChanges(events: Y.YEvent<any>[]): Partial<CellChange> { | ||
const changes = super.getChanges(events); | ||
|
||
const streamOutputEvent = events.find( | ||
event => | ||
event.path.length === 3 && | ||
event.path[0] === 'outputs' && | ||
event.path[2] === 'text' | ||
Comment on lines
+910
to
+913
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's hard to understand this without some concrete example. I guess a comment or a test could help here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The event path is an array leading to the changed property, so to access the |
||
); | ||
if (streamOutputEvent) { | ||
changes.streamOutputChange = streamOutputEvent.changes.delta as any; | ||
} | ||
|
||
const outputEvent = events.find( | ||
event => event.target === this.ymodel.get('outputs') | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are valid types/values for
origin
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Yjs an origin can be of any type.