mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 01:29:04 +01:00
append html
This commit is contained in:
@@ -100,9 +100,9 @@ function scrollableArrayOfString(id: string, buffer: string[], trustHtml: boolea
|
||||
return element;
|
||||
}
|
||||
|
||||
export function createOutputContent(id: string, outputs: string[], linesLimit: number, scrollable: boolean, trustHtml: boolean): HTMLElement {
|
||||
export function createOutputContent(id: string, outputText: string, linesLimit: number, scrollable: boolean, trustHtml: boolean): HTMLElement {
|
||||
|
||||
const buffer = outputs.join('\n').split(/\r\n|\r|\n/g);
|
||||
const buffer = outputText.split(/\r\n|\r|\n/g);
|
||||
|
||||
if (scrollable) {
|
||||
return scrollableArrayOfString(id, buffer, trustHtml);
|
||||
@@ -110,3 +110,33 @@ export function createOutputContent(id: string, outputs: string[], linesLimit: n
|
||||
return truncatedArrayOfString(id, buffer, linesLimit, trustHtml);
|
||||
}
|
||||
}
|
||||
|
||||
export function appendOutput(element: HTMLElement, id: string, outputText: string, linesLimit: number, scrollable: boolean, trustHtml: boolean) {
|
||||
const buffer = outputText.split(/\r\n|\r|\n/g);
|
||||
let newContent: HTMLDivElement;
|
||||
if (scrollable) {
|
||||
newContent = scrollableArrayOfString(id, buffer, trustHtml);
|
||||
element.appendChild(newContent);
|
||||
// contains 1 span per line
|
||||
// const innerContainer = element.childNodes[0].childNodes[0];
|
||||
// const linesToAdd = newContent.childNodes[0].childNodes[0].childNodes;
|
||||
|
||||
// linesToAdd.forEach(span => {
|
||||
// innerContainer.appendChild(span);
|
||||
// while (innerContainer.childNodes.length > 5000) {
|
||||
// innerContainer.firstChild?.remove();
|
||||
// }
|
||||
// });
|
||||
} else {
|
||||
newContent = truncatedArrayOfString(id, buffer, linesLimit, trustHtml);
|
||||
|
||||
// contains 1 span per line
|
||||
const innerContainer = element.childNodes[0].childNodes[0];
|
||||
const linesToAdd = newContent.childNodes[0].childNodes[0].childNodes;
|
||||
|
||||
linesToAdd.forEach(span => {
|
||||
innerContainer.appendChild(span);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user