On this page

Editors and resize controls

Source-backed editor adapters, embedded rich content, diff pairs, numeric font boundaries and accessible resize handles.

Editor canvas and syntax

Editors use editor.background and editor.text, a theme-aware reading canvas. This is deliberately different from static fenced code blocks (color.code.background / color.code.text), whose dark canvas has its own paired text. Never combine the editor syntax foregrounds with that static code-block canvas.

Use editor.syntax.comment, .string, .number, .keyword, .type and .delimiter for language tokens. These aliases reuse readable semantic foregrounds on the editor surface in both themes. Syntax coloring names language constructs, not operational status: a green string is not a successful operation. Keep language punctuation and text available without color. Editor gutter, line numbers, selection, line highlight and cursor have their own editor.* roles. Selection must retain a caret, native selection range or another non-color cue.

Diff inspection

Inserted lines use editor.diff.inserted.background with the inserted text annotation; removed lines use the removed pair. Keep native + / − gutter markers and accessible diff navigation. Do not add transparency to these pairs or interpret a changed value as an application failure. Ordinary code within either line keeps the theme-aware syntax foregrounds.

Numeric framework APIs

Monaco and similar frameworks require resolved values, not CSS var() strings. Use tokenPixels(name, locale, observedRootFontSize) at numeric framework boundaries and reuse useAntDesignVueRootFontSize() from the existing Source provider. The nominal16px default is not a reader-root override. Do not copy a downstream token table. editor.font.family, .size, .lineHeight and .weight carry the complete font.code.default recipe (nominal14/20, Vietnamese14/24); configure all four. Preserve read-only, wrapping, language workers, cancellation and diff layout.

Public editor companion

The existing @beehexa/ant-design-vue-tokens package includes the ./editor companion subpath for embedded content and editors; it is not a sixth package. Import the package’s styles.css once alongside token CSS.

import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { useAntDesignVueRootFontSize } from '@beehexa/ant-design-vue-tokens'
import {
  beehexaEditorOptions,
  registerBeehexaMonacoThemes,
  useBeehexaMonacoDiffOptions,
} from '@beehexa/ant-design-vue-tokens/editor'

// Use the runtime returned by the application's existing lazy editor loader.
registerBeehexaMonacoThemes(monaco)
const { locale } = useI18n()
const rootFontSize = useAntDesignVueRootFontSize()
const options = computed(() => ({
  ...beehexaEditorOptions(locale.value, rootFontSize.value),
  readOnly: true,
}))
const onDiffEditorMount = useBeehexaMonacoDiffOptions(options)
// Bind options, the registered theme and @editor-did-mount to the real DiffEditor.

beehexaEditorOptions(locale = 'en', rootFontSize = 16) returns the complete code font and scrollbar options. Vietnamese locale tags such as vi and vi-VN select taller leading. Reapply options when locale or the observed root changes. useBeehexaMonacoDiffOptions(options) bridges the missing options watcher in monaco-editor-vue3 DiffEditor. Create it in setup and bind the returned callback to each real editor-did-mount; it applies current options at mount and to all retained instances on change. Native disposal removes instances and the Vue scope clears the binding. Models, selection, scroll and native ownership remain unchanged. The exported BeehexaEditorOptions is a structural subset of Monaco’s official construction options, not a replacement for its full option type.

registerBeehexaMonacoThemes(runtime) defines exactly beehexa-light and beehexa-dark, including syntax, gutter, selection, diff, input, completion, hover, menu and other native widget color pairs. A WeakSet registers each runtime only once. Select the appropriate registered theme when application mode changes; registration does not select a theme, create an editor or load Monaco. BeehexaMonacoRuntime, BeehexaMonacoThemeData and BeehexaMonacoTokenRule describe the official structural API boundary without importing a Monaco runtime, adding a dependency or requiring a consumer ambient shim. The host retains Monaco workers, language registration, cancellation, disposal and lazy loading.

Use data-bh-editor-severity="error" or "warning" on a viewer ancestor for operational canvas severity. Keep a visible error/warning label or icon; these backgrounds are not a language syntax palette or a replacement for diagnostics. The companion CSS owns the native Monaco canvas/margin bridge. It also raises detached hover, completion and parameter-hint widgets to z-index.tooltip. Its sole layering !important is necessary to override Monaco’s inline widget z-index above an isolated fullscreen editor; it does not override widget paint.

Embedded rich content

Use .bh-markdown on sanitized semantic HTML inside a product page. Running prose uses body.large; the embedded outline uses heading.large for h1, heading.medium for h2, heading.small for h3, and heading.xsmall for deeper headings. This is subordinate product content, not the standalone documentation-page scale. Keep heading levels meaningful and in order. Paragraph/list spacing, baseline-aligned table cells, table header label.small, semibold emphasis, quote border, separators and code presentation belong to this source recipe rather than a local renderer skin. Links use the semantic link/hover pair and the standard visible keyboard focus ring.

data-bh-density="compact" on .bh-markdown is the editing-preview variant: paragraph spacing is space.100 rather than space.200; framed code uses space.150 padding on surface.subtle. It intentionally retains the host’s native heading/list/table metrics, so existing compact editor layouts are not expanded by the reading-view recipe. Inline static code uses the complete color.code.background / color.code.text pair. Ordinary reading-view inline code uses the neutral surface.subtle / text pair at surrounding text size.

Unhighlighted fenced blocks use the static code pair. Highlight.js .hljs uses the editor canvas/text and editor.syntax.* palette, including nested highlighted blocks in rich content. Do not apply a bundled highlight theme or combine those syntax foregrounds with the separate static-code canvas. Highlighted block containers use the same editor canvas so their padded frame remains paired too. Syntax names language constructs; operational severity, priority, status and data visualization meanings remain separate and retain textual cues.

Inline images use .bh-content-image for radius.100; set data-bh-zoomable="true" only when a real action opens inspection. Use the framework’s native Image preview for the inspection overlay, controls, keyboard dismissal and focus return rather than adding a second fullscreen scrim.

Image, copy and fullscreen actions use native Button APIs and icon slots. Preserve accessible names and copied announcements; a Source semantic success icon may supplement the announcement but color alone is insufficient. Explicit render failures use native Alert, and loading states use native Skeleton/Spin APIs. Allocate the represented content’s geometry and retain its loading announcement; a placeholder is not an interactive control or a status outcome.

Allocated interactive renderer viewports

Interactive Monaco editors/diffs and workflow/Mermaid viewers fill the width and remaining block allocation supplied by their parent. Their toolbar/header stays intrinsic outside the viewport. Page, Card body, Tab pane, Drawer/modal and splitter ancestors must each have a real allocation and allow shrinkage with min-width: 0 and min-height: 0; a percentage inside an auto-height chain is not an allocation. Use native fill APIs and bh-ant-fill-card/Spin wrapperClassName before adding structural hosts. Do not subtract guessed header pixels from a viewport unit.

@beehexa/vue-components/css exposes opt-ins for existing renderer hosts: bh-renderer-viewport is the shrinkable fill/overflow shell; bh-renderer-viewport__surface is its actual interactive surface. The latter retains layout.renderer.minimum-inline-size and minimum-block-size only when the available allocation is smaller (350px each at the nominal16px root, scaling with the reader). Larger allocations are filled, never capped at the minimum. The outer pane remains parent-sized, including narrow mobile panes. Keep one explicit outer overflow owner for access below the minimum; native editor text scrollbars are still owned by Monaco. If an enclosing content scroller already provides the relevant access, do not add a competing scrolling wrapper.

When a renderer owns intrinsic header/notice chrome, its existing root can use bh-renderer-frame. Keep the header a sibling outside the actual bh-renderer-viewport; keep the SDK host as that viewport’s bh-renderer-viewport__surface. The frame owns the sole access scrollbar: its nested viewport grows from the readable surface rather than shrinking to zero when the header exceeds the allocation. A title followed directly by an SDK surface is also supported. Size-only containment on those surfaces prevents retained SDK canvas dimensions from determining a later allocation; it does not clip paint, popups or focus, replace models, or observe/re-layout the editor. The source minimum excludes chrome. At adequate size the viewport fills the remainder; below minimum the parent-sized frame scrolls across chrome and SDK. Do not add a second overflow owner to that nested viewport.

This intrinsic-header rule is for text editors, notices and genuine document chrome. Graph navigation controls are different: Workflow/Mermaid/authoring graphs use the Data Flow floating dock inside the drawing viewport, default lower-left, never an external toolbar band. Follow the shared canvas and dock contract.

bh-renderer-frame--document on that same existing frame delegates access to an already scrolling native Card/document. Its automatic block size and nonshrinking renderer remove a competing frame scrollbar, including when a shared editor normally declares height: 100%. Use the existing bh-ant-fill-tabs--document role for intervening native Tabs; pass an editor’s public height="auto" where it explicitly controls its own block size. Keep document wrappers and intrinsic descriptions nonshrinking and overflow-visible. Do not mark a second wrapper as an SDK surface or leave a nested zero-height text scroller beside it. Native fullscreen and explicit data-bh-overlay-owner frames retain their bounded fullscreen allocation. Use the default frame for a bounded standalone widget. bh-renderer-access reserves only native toolbar/interaction rows in an outer allocation when intrinsic page chrome would otherwise reduce it to zero; its size follows existing control/coarse-pointer roles, not the readable SDK minimum. Static placeholders receive neither SDK minimum nor forced scrollbars.

Apply the minimum to interactive renderers, not ordinary read-only fields, labels, static Markdown code or an empty selection/loading/error placeholder. Unbounded inline authoring previews use this same readable minimum as their intrinsic budget, not a second fixed preview height. Metadata above an editor remains intrinsic and accessible; let its editor section grow into any remainder.

Reuse renderer lifecycle APIs: Monaco automaticLayout/retained layout(), native workflow viewport measurement and the retained Mermaid host’s resize path. Re-measure after hidden tabs, Drawer activation, collapse, splitter, root-scale or fullscreen changes without replacing models, caret/undo state or graph instances. Container resizing is not a request to run fitView again or reset manual zoom/pan; initial and explicitly requested fit are separate actions.

Retained controls that move between native overlay owners must bind native hover-only Tooltip triggers to the primary device’s (hover: hover) capability. Keep the Button’s accessible name and native mouse hover; touch compatibility mouse events must not leave an old owner’s hint intercepting the next control. Do not hide tooltip paint or change pointer events to mask that lifecycle defect.

The renderer still owns sanitization, HTML structure, container layout and scroll containment, image fitting and action positioning, zoom/pan, delegated events, copying, fullscreen focus containment, Escape, focus return and scroll locking. Use the interaction companion’s action-size/icon-only/touch opt-ins for control geometry rather than a local button sizing/padding recipe. Do not transfer those behaviors into a stylesheet or remove them when adopting the source classes. See Typography usage, Interaction states and Data visualization for the underlying reading, control-state and semantic-data rules.

Semantic slots without local presentation CSS

Use existing source-configured native Typography, Tag, Avatar and other components first. If replacing custom semantic HTML would change its structure, refs, keyboard handling or layout, the same companion stylesheet exposes these minimal source-role attributes. They do not impose display, positioning, margins, truncation, wrapping, flex/grid or responsive layout.

Attribute Existing source roles
data-bh-font body-small, body-default, body-large, label-small, label-default, heading-xsmall, heading-small, heading-medium, heading-large, heading-xlarge, code-default
data-bh-text neutral, subtle, subtlest, success, warning, danger, info, inverse, disabled, on-bold, on-brand
data-bh-numeric="tabular" Tabular figures for table numbers, changing counters and KPI values
data-bh-icon-size small = size.icon.default (16 px); default = size.icon.medium (20 px); large = size.icon.large (24 px); xlarge = size.icon.empty (32 px, empty-state icons only)
data-bh-diff removed and inserted use the corresponding editor.diff.*.text annotation roles, not operational failure/success

data-bh-font applies the complete font shorthand, including locale-aware line height; never follow it with a consumer weight, size or line-height override. Native technical textareas/inputs may select code-default through this boundary without introducing a dashboard input-font rule. Use semantic em/i for genuine terms or titles requiring italics, sparingly, not a new local font-style recipe. The font roles do not change the semantic heading level of their HTML element.

Text colors map to color.text.*; neutral means color.text itself. On a data-bh-icon-size glyph the same semantic choices select the existing color.icon.* counterparts. Both subtle text levels use color.icon.subtle because the source does not define a separate tertiary icon role. on-brand retains its explicit readable brand foreground. Do not resize a control’s native glyph with these content opt-ins. Icon dimensions are not interactive target sizes. Status meanings still require explicit text, labels or recognizable glyphs.

.bh-content-code is a static-code content recipe: code.default, the complete static code foreground/background pair, radius.050 and space.050 padding. Add --inline for mono at the surrounding font size with horizontal-only padding, --field for a readable technical value with space.050 / space.100 padding, or --block for a code output region with space.100 padding. Add data-bh-code-tone="neutral" for the alternative surface.subtle / text pair. These are reading/technical-value roles, not a configurable arbitrary box API. The host keeps display, overflow and wrapping. Do not put editor syntax colors on this static canvas; highlighted content uses the editor recipe above.

.bh-content-table is for static instructional/comparison tables whose actual HTML table, scoped row headers and footer semantics must remain intact. It uses body.default and text, a border cell frame and space.150 cell padding. Header cells and footer totals use label.small on surface.subtle. Keep width, collapse, margins, alignment, no-wrap choices and responsive overflow structural; do not reintroduce local table paint. Reuse native source-configured Table for sorting, filtering, pagination or row-selection interactions.

.bh-content-highlight pairs background.brand.bold with text.on-brand, zero padding and radius.0 for an in-place search match. The matched text stays real text and search navigation retains its accessible current-match indication. .bh-app on body opts into body.default, text and surface.page without setting root font size, margins or page geometry.

data-bh-editor-severity also owns the viewer’s source-accent leading border, using the matching danger/warning border role. Consumers keep its data meaning and explicit label, not a local semantic presentation rule. All semantic content presentation remains source-owned: token binding is not an exception permitting dashboard colors, font declarations, borders, control geometry or state recipes.

Resize controls

Use ResizablePanel from @beehexa/vue-components for actual split panes; it is independent of Ant Design Vue. Import its typed CSS entry, bind v-model:ratio, supply first/second slots and a localized separatorLabel, and let the consumer’s existing breakpoint select horizontal left/right or vertical top/bottom. Keep the same editor/model/canvas instances when direction, visibility, theme, locale or fullscreen changes. Listen to its after-layout resize dimensions to update retained renderer hosts, not to reset model/zoom or remount them.

resize.divider is the visible line, not its interaction area. The source component centers that line at 90% cross-axis length by default, with a clear midpoint handle inside the physical gutter and above independently clipped pane content. Resting panes/root do not create stacking contexts that trap nested overlays. Reactive resizerSize changes only the visible line’s CSS length, not its full-cross-axis hit region. The handle uses resize.handle.width, .height, .radius, .background, resize.color and resize.grip. Hover, focus and drag use resize.active on the divider; the handle uses resize.handle.activeBackground with resize.activeGrip. Targets use resize.target / resize.touchTarget; focus uses source border roles. No arbitrary AntD/global-body selector is needed.

The component owns pointer capture/cancellation, local editor/iframe drag shielding, selection prevention, keyboard arrows/Shift/Home/End and Enter/double-click reset to the initial ratio within live bounds. It preserves named separator orientation/value/min/max/controls semantics, hidden-pane state, and cleanup. Read the complete active Resizable panel API, usage and accessibility rules before composing a consumer.

Fullscreen and popup ordering

Fullscreen editors, code viewers and image inspection use z-index.modal (400) with isolation, like dialogs and drawers. Monaco completion, hover and parameter-hint widgets use z-index.tooltip (600); ordinary in-page popups keep framework layers inside their owner via the adapter’s contextual container. Mark custom fullscreen hosts with data-bh-overlay-owner. Native confirmations resolve invocation-time ordering through getAntDesignVueModalZIndex, and nested drawers use getAntDesignVueOverlayZIndex with their live owner layer. Blocking global loading covers the page like a dialog, so it uses z-index.modal (400); toast feedback (700) stays on top. See Z-index for the complete ordering. Avoid a new local z-index scale or a glass effect; custom fullscreen surfaces use semantic surfaces and image inspection uses one color.surface.scrim layer. Layering does not replace focus containment, Escape handling, focus return, scroll locking or reachable controls.