
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
@webwriter/code
Advanced tools
Write and run code as a code cell. Supports several languages (HTML, JavaScript/TypeScript, Python, Java, WebAssembly).
@webwriter/code@3.0.2)License: MIT | Version: 3.0.2
The Code Widget enables interactive code exercises directly in the browser. Users can effortlessly write, execute, and explore code in multiple programming languages, including:
To set up the development environment, clone the repository and execute the following commands:
npm install
npm run dev # runs @webwriter/build dev
Finally, import the code directory into WebWriter to begin.
Snippets are examples and templates using the package's widgets.
| Name | Import Path |
|---|---|
| HTML | @webwriter/code/snippets/HTML.html |
CodeHTML (<webwriter-code-html>)Code widget for HTML with live preview functionality.
Use with a CDN (e.g. jsdelivr):
<link href="https://cdn.jsdelivr.net/npm/@webwriter/code/widgets/webwriter-code-html.css" rel="stylesheet">
<script type="module" src="https://cdn.jsdelivr.net/npm/@webwriter/code/widgets/webwriter-code-html.js"></script>
<webwriter-code-html></webwriter-code-html>
Or use with a bundler (e.g. Vite):
npm install @webwriter/code
<link href="@webwriter/code/widgets/webwriter-code-html.css" rel="stylesheet">
<script type="module" src="@webwriter/code/widgets/webwriter-code-html.js"></script>
<webwriter-code-html></webwriter-code-html>
| Name (Attribute Name) | Type | Description | Default | Reflects |
|---|---|---|---|---|
code (code) | String | The source code content displayed in the editor. | - | β |
visible (visible) | boolean | Whether the code editor is visible to the user. | true | β |
autoRun (autoRun) | boolean | Whether to automatically run the code when the component is first loaded. | false | β |
runnable (runnable) | boolean | Whether the code execution is allowed and the run button is enabled. | true | β |
autocomplete (autocomplete) | boolean | Whether autocompletion is enabled in the code editor. | false | β |
lockedLines (lockedLines) | number[] | Array of line numbers that should be locked from editing. | [] | β |
showExecutionTime (showExecutionTime) | boolean | Whether to display the execution time in the controls. | false | β |
executionTime (executionTime) | number | The execution time in milliseconds of the last code run. | 0 | β |
showExecutionCount (showExecutionCount) | boolean | Whether to display the execution count in the run button. | false | β |
executionCount (executionCount) | number | The number of times the code has been executed. | 0 | β |
results (results) | any | The results from the last code execution. | [] | β |
diagnostics (diagnostics) | Diagnostic[] | Compilation or runtime errors from the last code execution. | [] | β |
Fields including properties and attributes define the current state of the widget and offer customization options.
| Name | Value |
|---|
The editing config defines how explorable authoring tools such as WebWriter treat the widget.
No public methods, slots, events, custom CSS properties, or CSS parts.
CodeJavaScript (<webwriter-code-javascript>)Code widget for JavaScript with execution capabilities.
Use with a CDN (e.g. jsdelivr):
<link href="https://cdn.jsdelivr.net/npm/@webwriter/code/widgets/webwriter-code-javascript.css" rel="stylesheet">
<script type="module" src="https://cdn.jsdelivr.net/npm/@webwriter/code/widgets/webwriter-code-javascript.js"></script>
<webwriter-code-javascript></webwriter-code-javascript>
Or use with a bundler (e.g. Vite):
npm install @webwriter/code
<link href="@webwriter/code/widgets/webwriter-code-javascript.css" rel="stylesheet">
<script type="module" src="@webwriter/code/widgets/webwriter-code-javascript.js"></script>
<webwriter-code-javascript></webwriter-code-javascript>
| Name (Attribute Name) | Type | Description | Default | Reflects |
|---|---|---|---|---|
code (code) | String | The source code content displayed in the editor. | - | β |
visible (visible) | boolean | Whether the code editor is visible to the user. | true | β |
autoRun (autoRun) | boolean | Whether to automatically run the code when the component is first loaded. | false | β |
runnable (runnable) | boolean | Whether the code execution is allowed and the run button is enabled. | true | β |
autocomplete (autocomplete) | boolean | Whether autocompletion is enabled in the code editor. | false | β |
lockedLines (lockedLines) | number[] | Array of line numbers that should be locked from editing. | [] | β |
showExecutionTime (showExecutionTime) | boolean | Whether to display the execution time in the controls. | false | β |
executionTime (executionTime) | number | The execution time in milliseconds of the last code run. | 0 | β |
showExecutionCount (showExecutionCount) | boolean | Whether to display the execution count in the run button. | false | β |
executionCount (executionCount) | number | The number of times the code has been executed. | 0 | β |
results (results) | any | The results from the last code execution. | [] | β |
diagnostics (diagnostics) | Diagnostic[] | Compilation or runtime errors from the last code execution. | [] | β |
Fields including properties and attributes define the current state of the widget and offer customization options.
| Name | Value |
|---|
The editing config defines how explorable authoring tools such as WebWriter treat the widget.
No public methods, slots, events, custom CSS properties, or CSS parts.
CodeJava (<webwriter-code-java>)Code widget for Java with compilation and execution capabilities using TeaVM (Java 21).
Use with a CDN (e.g. jsdelivr):
<link href="https://cdn.jsdelivr.net/npm/@webwriter/code/widgets/webwriter-code-java.css" rel="stylesheet">
<script type="module" src="https://cdn.jsdelivr.net/npm/@webwriter/code/widgets/webwriter-code-java.js"></script>
<webwriter-code-java></webwriter-code-java>
Or use with a bundler (e.g. Vite):
npm install @webwriter/code
<link href="@webwriter/code/widgets/webwriter-code-java.css" rel="stylesheet">
<script type="module" src="@webwriter/code/widgets/webwriter-code-java.js"></script>
<webwriter-code-java></webwriter-code-java>
| Name (Attribute Name) | Type | Description | Default | Reflects |
|---|---|---|---|---|
code (code) | String | The source code content displayed in the editor. | - | β |
visible (visible) | boolean | Whether the code editor is visible to the user. | true | β |
autoRun (autoRun) | boolean | Whether to automatically run the code when the component is first loaded. | false | β |
runnable (runnable) | boolean | Whether the code execution is allowed and the run button is enabled. | true | β |
autocomplete (autocomplete) | boolean | Whether autocompletion is enabled in the code editor. | false | β |
lockedLines (lockedLines) | number[] | Array of line numbers that should be locked from editing. | [] | β |
showExecutionTime (showExecutionTime) | boolean | Whether to display the execution time in the controls. | false | β |
executionTime (executionTime) | number | The execution time in milliseconds of the last code run. | 0 | β |
showExecutionCount (showExecutionCount) | boolean | Whether to display the execution count in the run button. | false | β |
executionCount (executionCount) | number | The number of times the code has been executed. | 0 | β |
results (results) | any | The results from the last code execution. | [] | β |
diagnostics (diagnostics) | Diagnostic[] | Compilation or runtime errors from the last code execution. | [] | β |
Fields including properties and attributes define the current state of the widget and offer customization options.
| Name | Value |
|---|
The editing config defines how explorable authoring tools such as WebWriter treat the widget.
No public methods, slots, events, custom CSS properties, or CSS parts.
CodeTypeScript (<webwriter-code-typescript>)Code widget for TypeScript with compilation and execution capabilities.
Use with a CDN (e.g. jsdelivr):
<link href="https://cdn.jsdelivr.net/npm/@webwriter/code/widgets/webwriter-code-typescript.css" rel="stylesheet">
<script type="module" src="https://cdn.jsdelivr.net/npm/@webwriter/code/widgets/webwriter-code-typescript.js"></script>
<webwriter-code-typescript></webwriter-code-typescript>
Or use with a bundler (e.g. Vite):
npm install @webwriter/code
<link href="@webwriter/code/widgets/webwriter-code-typescript.css" rel="stylesheet">
<script type="module" src="@webwriter/code/widgets/webwriter-code-typescript.js"></script>
<webwriter-code-typescript></webwriter-code-typescript>
| Name (Attribute Name) | Type | Description | Default | Reflects |
|---|---|---|---|---|
code (code) | String | The source code content displayed in the editor. | - | β |
visible (visible) | boolean | Whether the code editor is visible to the user. | true | β |
autoRun (autoRun) | boolean | Whether to automatically run the code when the component is first loaded. | false | β |
runnable (runnable) | boolean | Whether the code execution is allowed and the run button is enabled. | true | β |
autocomplete (autocomplete) | boolean | Whether autocompletion is enabled in the code editor. | false | β |
lockedLines (lockedLines) | number[] | Array of line numbers that should be locked from editing. | [] | β |
showExecutionTime (showExecutionTime) | boolean | Whether to display the execution time in the controls. | false | β |
executionTime (executionTime) | number | The execution time in milliseconds of the last code run. | 0 | β |
showExecutionCount (showExecutionCount) | boolean | Whether to display the execution count in the run button. | false | β |
executionCount (executionCount) | number | The number of times the code has been executed. | 0 | β |
results (results) | any | The results from the last code execution. | [] | β |
diagnostics (diagnostics) | Diagnostic[] | Compilation or runtime errors from the last code execution. | [] | β |
Fields including properties and attributes define the current state of the widget and offer customization options.
| Name | Value |
|---|
The editing config defines how explorable authoring tools such as WebWriter treat the widget.
No public methods, slots, events, custom CSS properties, or CSS parts.
CodePython (<webwriter-code-python>)Code widget for Python with execution capabilities using Pyodide.
Use with a CDN (e.g. jsdelivr):
<link href="https://cdn.jsdelivr.net/npm/@webwriter/code/widgets/webwriter-code-python.css" rel="stylesheet">
<script type="module" src="https://cdn.jsdelivr.net/npm/@webwriter/code/widgets/webwriter-code-python.js"></script>
<webwriter-code-python></webwriter-code-python>
Or use with a bundler (e.g. Vite):
npm install @webwriter/code
<link href="@webwriter/code/widgets/webwriter-code-python.css" rel="stylesheet">
<script type="module" src="@webwriter/code/widgets/webwriter-code-python.js"></script>
<webwriter-code-python></webwriter-code-python>
| Name (Attribute Name) | Type | Description | Default | Reflects |
|---|---|---|---|---|
code (code) | String | The source code content displayed in the editor. | - | β |
visible (visible) | boolean | Whether the code editor is visible to the user. | true | β |
autoRun (autoRun) | boolean | Whether to automatically run the code when the component is first loaded. | false | β |
runnable (runnable) | boolean | Whether the code execution is allowed and the run button is enabled. | true | β |
autocomplete (autocomplete) | boolean | Whether autocompletion is enabled in the code editor. | false | β |
lockedLines (lockedLines) | number[] | Array of line numbers that should be locked from editing. | [] | β |
showExecutionTime (showExecutionTime) | boolean | Whether to display the execution time in the controls. | false | β |
executionTime (executionTime) | number | The execution time in milliseconds of the last code run. | 0 | β |
showExecutionCount (showExecutionCount) | boolean | Whether to display the execution count in the run button. | false | β |
executionCount (executionCount) | number | The number of times the code has been executed. | 0 | β |
results (results) | any | The results from the last code execution. | [] | β |
diagnostics (diagnostics) | Diagnostic[] | Compilation or runtime errors from the last code execution. | [] | β |
Fields including properties and attributes define the current state of the widget and offer customization options.
| Name | Value |
|---|
The editing config defines how explorable authoring tools such as WebWriter treat the widget.
No public methods, slots, events, custom CSS properties, or CSS parts.
CodeWebAssembly (<webwriter-code-webassembly>)Code widget for WebAssembly with compilation and execution capabilities.
Use with a CDN (e.g. jsdelivr):
<link href="https://cdn.jsdelivr.net/npm/@webwriter/code/widgets/webwriter-code-webassembly.css" rel="stylesheet">
<script type="module" src="https://cdn.jsdelivr.net/npm/@webwriter/code/widgets/webwriter-code-webassembly.js"></script>
<webwriter-code-webassembly></webwriter-code-webassembly>
Or use with a bundler (e.g. Vite):
npm install @webwriter/code
<link href="@webwriter/code/widgets/webwriter-code-webassembly.css" rel="stylesheet">
<script type="module" src="@webwriter/code/widgets/webwriter-code-webassembly.js"></script>
<webwriter-code-webassembly></webwriter-code-webassembly>
| Name (Attribute Name) | Type | Description | Default | Reflects |
|---|---|---|---|---|
code (code) | String | The source code content displayed in the editor. | - | β |
visible (visible) | boolean | Whether the code editor is visible to the user. | true | β |
autoRun (autoRun) | boolean | Whether to automatically run the code when the component is first loaded. | false | β |
runnable (runnable) | boolean | Whether the code execution is allowed and the run button is enabled. | true | β |
autocomplete (autocomplete) | boolean | Whether autocompletion is enabled in the code editor. | false | β |
lockedLines (lockedLines) | number[] | Array of line numbers that should be locked from editing. | [] | β |
showExecutionTime (showExecutionTime) | boolean | Whether to display the execution time in the controls. | false | β |
executionTime (executionTime) | number | The execution time in milliseconds of the last code run. | 0 | β |
showExecutionCount (showExecutionCount) | boolean | Whether to display the execution count in the run button. | false | β |
executionCount (executionCount) | number | The number of times the code has been executed. | 0 | β |
results (results) | any | The results from the last code execution. | [] | β |
diagnostics (diagnostics) | Diagnostic[] | Compilation or runtime errors from the last code execution. | [] | β |
Fields including properties and attributes define the current state of the widget and offer customization options.
| Name | Value |
|---|
The editing config defines how explorable authoring tools such as WebWriter treat the widget.
No public methods, slots, events, custom CSS properties, or CSS parts.
Generated with @webwriter/build@1.8.1
FAQs
Write and run code as a code cell. Supports several languages (HTML, JavaScript/TypeScript, Python, Java, WebAssembly).
We found that @webwriter/code demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.