The <vulniverse-editor> element¶
This is the actual integration surface — everything a host application
configures when embedding the editor, whether that host is
Vulnerability-Lookup or something else entirely.
config/vulniverse.toml (see Configuration) has no
effect here — it's a standalone-app-only concern; a host decides its own
panels/actions directly, in its own code.
Steps to embed it¶
frontend/src/editor/ has zero host-specific branches anywhere — every
step below lives entirely on the host's side of the
EditorRepository/EditorPanel/EditorAction boundary. See
Embedding: Vulnerability-Lookup for a fully worked example of
all of these steps together.
-
Build the element bundle:
Produces one self-contained file,dist/element/vulniverse-editor.js— CSS inlined, images base64'd, no external dependencies — plus its type declarations,vulniverse-editor.d.ts. Copy them into the host app's own static assets. Or skip the build: install the npm package, or download a released bundle (see Embed it). -
Load it with a static import:
Importing it runscustomElements.define("vulniverse-editor", ...)as a side effect. Use a top-level static import, not a dynamic one — static imports run to completion before the rest of the script body, sodocument.createElement("vulniverse-editor")afterward is guaranteed to produce an already-upgraded element. -
Implement an
EditorRepositoryagainst the host's own backend — this is the real integration work. See The repository. -
Construct the element and set it up:
const editor = document.createElement("vulniverse-editor"); editor.setAttribute("mode", vulnerabilityId ? "edit" : "create"); editor.setAttribute("profile", "gcve-bcp-05-1.7"); // or "cve-5.2.0", "osv-1.9.2" if (vulnerabilityId) editor.setAttribute("record-id", vulnerabilityId); editor.repository = new MyRepository({ /* ... */ });mode/profile/record-idare plain HTML attributes (strings only).repository(andpanels/actionsbelow) are always assigned as JS properties aftercreateElement— never as attribute strings, since they're objects/arrays, not strings.
They can also be set after the element is mounted (step 7), as
frameworks usually do. In edit mode the editor then shows "Waiting for
a repository…" and loads the record once repository is first set.
Only the first repository is used; to switch to another, mount a new
element.
-
(Optional) Add panels and actions — see
panelsandactionsbelow: -
Listen for events — see Events below:
-
Mount it:
-
(Optional) Theme it — the shadow-DOM CSS reads a handful of custom properties with fallbacks:
--vulniverse-primary,--vulniverse-primary-rgb,--vulniverse-accent-text,--vulniverse-text,--vulniverse-background,--vulniverse-muted,--vulniverse-border,--vulniverse-changed. CSS custom properties pierce shadow boundaries, so setting these on:root(or on the<vulniverse-editor>element itself) in the host page re-themes the editor's colors without touching its internal styles. Skip this if the defaults are fine. -
(Optional) Give it a real height — the element's
:hostrule isheight: 100%, a no-op unless the host page's own CSS gives<vulniverse-editor>a real, definite height (e.g. a flex/grid ancestor). Leave it alone to let it size to its own content instead.
Props reference¶
| Prop | Type | Notes |
|---|---|---|
mode |
"create" \| "edit" |
Defaults to "create". |
record-id |
string |
Required when mode="edit". |
profile |
string |
"gcve-bcp-05-1.7" (the default), "cve-5.2.0", or "osv-1.9.2". |
repository |
EditorRepository |
Set from JavaScript (editor.repository = ...), not an HTML attribute — see below. Before or after mounting; only the first one set is used. |
actions |
EditorAction[] |
Optional extra header buttons. |
panels |
EditorPanel[] |
Optional extra sidebar tabs — see note below. |
repository¶
repository is a plain object, not a string, so it's always assigned from
JavaScript rather than written as an HTML attribute:
What it has to implement (four required methods, and optional groups for deleting, templates, CWE/CPE suggestions, publishing, record quality and Patch2Vuln), with every signature and data shape: The repository.
panels and actions¶
editor.panels = [
myCustomPanel, // your own object shaped like EditorPanel
templatesPanel, // reused straight from Vulniverse's own bundle
];
editor.actions = [
myCustomAction, // your own object shaped like EditorAction
];
EditorPanel/EditorAction (frontend/src/editor/contracts.ts) are just
plain object shapes — nothing requires a panel or action to originate from
Vulniverse, so mixing host-authored and Vulniverse-authored entries in the
same array is expected. There's no config file and no
capabilities-filtering step for an embedded host (that machinery —
config/vulniverse.toml + GET /api/v1/capabilities — is
standalone-app-only, see Configuration); a host just
decides the array contents directly in its own code.
src/element.ts also exports:
downloadActionandtutorialAction— built-inEditorActions: the record as JSON, HTML or PDF (print dialog), and a short guided tour of the editor. Like the panels below, a host adds them toactionsitself.RecordValidationError— the error a repository throws fromcreateRecord/updateRecordwhen the record fails schema validation (as opposed to a network failure, a 404, or a conflict).EditorRepositoryError— an error with an HTTP-stylestatusanddetails, which the publishing panels read; see The repository.- The types
EditorRepository,EditorPanel,EditorAction,EditorContext,EditorDocument,LoadedRecord,ValidationResult,ValidationError,LifecycleTransitionandThemePreference, andVulniverseEditorElement, the element itself. They ship asvulniverse-editor.d.ts, next to the bundle and in the npm package. It's self-contained (Vue's types aren't needed) and registers the element inHTMLElementTagNameMap, sodocument.createElement("vulniverse-editor")is typed. defineComponent,h,onMounted,ref,watch— a minimal slice of Vue's runtime, so a host without a build step of its own can write a panel component against the same Vue the bundle uses.
Five built-in panels are exported from src/element.ts too — none are baked
into the element itself, so a host has to include each explicitly to get
its UI, but can then reuse it instead of authoring an equivalent from
scratch:
| Panel | Needs repository method(s) |
|---|---|
templatesPanel |
listTemplates + CRUD |
cveProgramPanel |
getCnaPublication + the publish actions |
vulnerabilityLookupPanel |
getCnaPublication + the publish actions |
recordQualityPanel |
scoreRecordQuality |
patch2vulnPanel |
submitPatch2VulnJob + getPatch2VulnJob |
A sixth built-in, recordStatsPanel, exists internally
(frontend/src/editor/panels/record-stats/) but is deliberately not
exported — it's a purely local computation over the already-loaded record
with no repository dependency, and isn't currently offered as a reusable
building block for embedding hosts.
Events¶
| Event | detail |
Fires when |
|---|---|---|
ready |
[] |
A new record is set up (mode="create") or a record loaded successfully; in edit mode without a repository yet, once it's set and the record loaded. Not fired when loading fails — error fires instead. |
loaded |
[identifier: string] (the record key) |
A record has been loaded, created, or saved. |
deleted |
[identifier: string] (the record key) |
A record was deleted. |
dirtyChange |
[dirty: boolean] |
The record's unsaved-changes state changed. Also dispatched as dirty-change. |
error |
[error: Error] |
An operation against repository failed. |
These are Vue custom-element events: event.detail is the array of
emitted arguments, so the value itself is event.detail[0].