The JS Block is a highly flexible "custom rendering block" that allows you to write JavaScript directly to generate interfaces, bind events, call data APIs, or integrate third-party libraries. It is suitable for personalized visualizations, temporary experiments, and lightweight extension scenarios that are difficult to cover with built-in blocks.
The JS Block's runtime context has common capabilities injected and can be used directly:
ctx.element: The DOM container of the block (safely wrapped as ElementProxy), supporting innerHTML, querySelector, addEventListener, etc.ctx.requireAsync(url): Asynchronously loads an AMD/UMD library by URL.ctx.importAsync(url): Dynamically imports an ESM module by URL.ctx.openView: Opens a configured view (popup/drawer/page).ctx.useResource(...) + ctx.resource: Accesses data as a resource.ctx.i18n.t() / ctx.t(): Built-in internationalization capability.ctx.onRefReady(ctx.ref, cb): Renders after the container is ready to avoid timing issues.ctx.React / ctx.ReactDOM / ctx.antd: Supports JSX. You can write JSX directly in the editor, and it will be rendered by ctx.ReactDOM.ctx.render(vnode): Renders a React element, HTML string, or DOM node to the default container ctx.element. Multiple calls will reuse the same React Root and overwrite the container's existing content.You can add a JS Block to a page or a popup.

The JS Block's script editor supports syntax highlighting, error hints, and built-in code snippets (Snippets), allowing you to quickly insert common examples such as rendering charts, binding button events, loading external libraries, rendering React/Vue components, timelines, information cards, etc.
Snippets: Opens the list of built-in code snippets. You can search and insert a selected snippet into the code editor at the current cursor position with one click.Run: Directly runs the code in the current editor and outputs the execution logs to the Logs panel at the bottom. It supports displaying console.log/info/warn/error, and errors will be highlighted with links to the specific row and column.
Additionally, you can directly summon the AI employee "Frontend Engineer · Nathan" from the top-right corner of the editor. Nathan can help you write or modify scripts based on the current context. You can then "Apply to editor" with one click and run the code to see the effect. For details, see:
ctx.element (ElementProxy) for the script, which only affects the current block and does not interfere with other areas of the page.window/document/navigator use secure proxy objects, allowing common APIs while restricting risky behaviors.class or [name=...] attribute selectors. Avoid using fixed ids to prevent conflicts from duplicate ids when using multiple blocks or popups.