Skip to content

SerializeAsHTML() does not work with xterm-headless - TerminalCore lacks _colorManager #4148

@gpickell

Description

@gpickell

I tried to use the Terminal from xterm-headless with the xterm-addon-serialize addon. I managed to get it to work after I hacked in a property. See the following code fragment:

import xterm from "xterm-headless";
import { SerializeAddon } from "xterm-addon-serialize";

const term = new xterm.Terminal({
    allowProposedApi: true,
});

const ser = new SerializeAddon();

// HACK: Make it work (omit to demonstrate error)
term._core._colorManager = {
    colors: {
        ansi: {
            1: {
                css: "blue",
            }
        }
    }
};

term.loadAddon(ser);
term.write("Hello from \x1B[1;3;31mxterm.js\x1B[0m $ ");
term.write("", () => {
    // this will throw without the hack
    console.log(ser.serializeAsHTML({
        includeGlobalBackground: true
    }));
});

The ColorManager should get moved to common or this addon package should bundle a copy of it and use it only if there is no _colorManager.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions