Move update-scroll into notebookDocument
This commit is contained in:
parent
2ac11a6eb2
commit
556c5d4699
3 changed files with 33 additions and 18 deletions
|
@ -807,6 +807,7 @@ var requirejs = (function() {
|
|||
this.hiddenInsetMapping.delete(request.output);
|
||||
|
||||
return {
|
||||
cellId: request.cell.id,
|
||||
outputId: id,
|
||||
cellTop: request.cellTop,
|
||||
outputOffset: request.outputOffset,
|
||||
|
|
|
@ -174,6 +174,7 @@ export interface ICreationRequestMessage {
|
|||
}
|
||||
|
||||
export interface IContentWidgetTopRequest {
|
||||
readonly cellId: string;
|
||||
readonly outputId: string;
|
||||
readonly cellTop: number;
|
||||
readonly outputOffset: number;
|
||||
|
|
|
@ -633,24 +633,8 @@ async function webviewPreloads(style: PreloadStyles, options: PreloadOptions, re
|
|||
// const date = new Date();
|
||||
// console.log('----- will scroll ---- ', date.getMinutes() + ':' + date.getSeconds() + ':' + date.getMilliseconds());
|
||||
|
||||
for (const request of event.data.widgets) {
|
||||
const widget = document.getElementById(request.outputId);
|
||||
if (widget) {
|
||||
widget.parentElement!.parentElement!.style.top = `${request.cellTop}px`;
|
||||
widget.parentElement!.style.top = `${request.outputOffset}px`;
|
||||
if (request.forceDisplay) {
|
||||
widget.parentElement!.parentElement!.style.visibility = 'visible';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const cell of event.data.markupCells) {
|
||||
const container = document.getElementById(cell.id);
|
||||
if (container) {
|
||||
container.style.top = `${cell.top}px`;
|
||||
}
|
||||
}
|
||||
|
||||
notebookDocument.updateOutputsScroll(event.data.widgets);
|
||||
notebookDocument.updateMarkupScrolls(event.data.markupCells);
|
||||
break;
|
||||
}
|
||||
case 'clear':
|
||||
|
@ -1019,6 +1003,15 @@ async function webviewPreloads(style: PreloadStyles, options: PreloadOptions, re
|
|||
}
|
||||
}
|
||||
|
||||
public updateMarkupScrolls(markupCells: { id: string; top: number; }[]) {
|
||||
for (const { id, top } of markupCells) {
|
||||
const cell = this._markupCells.get(id);
|
||||
if (cell) {
|
||||
cell.element.style.top = `${top}px`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public clearAll() {
|
||||
this._markupCells.clear();
|
||||
this._outputCells.clear();
|
||||
|
@ -1054,6 +1047,13 @@ async function webviewPreloads(style: PreloadStyles, options: PreloadOptions, re
|
|||
const cell = this._outputCells.get(cellId);
|
||||
cell?.updateOutputHeight(outputId, height);
|
||||
}
|
||||
|
||||
public updateOutputsScroll(updates: webviewMessages.IContentWidgetTopRequest[]) {
|
||||
for (const request of updates) {
|
||||
const cell = this._outputCells.get(request.cellId);
|
||||
cell?.updateScroll(request);
|
||||
}
|
||||
}
|
||||
}();
|
||||
|
||||
class MarkupCell implements IOutputItem {
|
||||
|
@ -1309,6 +1309,19 @@ async function webviewPreloads(style: PreloadStyles, options: PreloadOptions, re
|
|||
outputContainer.style.maxHeight = `${height}px`;
|
||||
outputContainer.style.height = `${height}px`;
|
||||
}
|
||||
|
||||
public updateScroll(request: webviewMessages.IContentWidgetTopRequest) {
|
||||
this.element.style.top = `${request.cellTop}px`;
|
||||
|
||||
const outputContainer = this.outputElements.get(request.outputId);
|
||||
if (outputContainer) {
|
||||
outputContainer.style.top = `${request.outputOffset}px`;
|
||||
}
|
||||
|
||||
if (request.forceDisplay) {
|
||||
this.element.style.visibility = 'visible';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vscode.postMessage({
|
||||
|
|
Loading…
Reference in a new issue