Virtual Code Box

VirtualCodeBox is a special type of code box, that is controlled only through code. It doesn't have any additional GUI.

Usage Example

The following example demonstrates how to create a VirtualCodeBox. Simply instantiate the VirtualCodeBox class by passing a reference to the root element of code box. You can read more about elements of code box here. You can also provide additional options as a second parameter.

<div id="MyVirtualCodeBox">
    <pre data-cb-name="addition" data-cb-active><code>let x = 1;
let y = 2;

console.log("result: " + (x + y));</code></pre>
    <pre data-cb-name="connecting strings"><code>let string1 = "This is";
let string2 = " string.";

console.log(string1 + string2);</code></pre>
</div>
import { VirtualCodeBox } from "@jirkasa/code-box";

new VirtualCodeBox(document.getElementById("MyVirtualCodeBox"));
let x = 1;
let y = 2;

console.log("result: " + (x + y));
let string1 = "This is";
let string2 = " string.";

console.log(string1 + string2);

If you want to create multiple virtual code boxes, you can use the VirtualCodeBoxCreator. For more information, refer to the chapter on creators.

Options

VirtualCodeBox accepts all options from the base CodeBox class and does not have any additional options.

Methods

VirtualCodeBox has methods that are already described in the chapter about the base CodeBox class. It does not define any additional methods.