Agent Editor

Selection-based document formatting and Agent assistance connected to your own service.

Agent Editor

Default

Edit the document directly or select text to show its floating toolbar. Ctrl/Cmd + B, I and U toggle supported formats; Ctrl/Cmd + Enter opens Ask Agent; Escape closes the toolbar. Select the opening sentence of the weekly portal report, ask for a concise summary of the results, and replace the original with the revised answer. Responses are local demo data.

Formatting

Bind both v-model and v-model:marks to persist plain text and formatting independently. Formats may overlap. Highlight key results and use Agent to polish the selected opening text. Toolbar actions preserve the selection, and Ctrl/Cmd + Z / Shift + Z undo and redo edits. Ranges refer to the current text using UTF-16 indices.

Async request

Provide request to connect your own Agent service. Its context includes the prompt, selected text, complete document, a cancellation signal and report() for progress labels and sources. Errors remain visible for retry. Closing, stopping or changing the document cancels the session and ignores late results. This example uses a local Promise to demonstrate loading, sources and failure.

Streaming

Return an AsyncIterable<string> for incremental chunks; the component appends each chunk without duplicating it. Complete string results can also reveal progressively with stream-interval. Stop aborts the request, and applications should pass signal to their fetch or stream reader. Finished answers can replace the selection, insert after the current paragraph, or be copied.

Slots

Use toolbar for focused format actions and answer for custom answer presentation. The slot scope contains the selection and component-owned commands so examples do not need to reimplement range manipulation or request state.

Agent icon

Use agent-icon for PNG or SVG image URLs, or the agent-icon slot for inline SVG and icon components. The slot takes precedence and receives status and busy. Icons fit a 22px box and are decorative; controls retain their accessible names.

API

PROPS

Property
Type
Values
Description
default
Example
More
agent-icon
String
—
Custom PNG / SVG URL overriding global agentIcon, shared with Message; an empty string restores the default SVG.
—
v-model
String
—
Plain document text. HTML is treated as literal text.
''
v-model:marks
[]
—
Controlled inline ranges. start is inclusive and end exclusive; offsets use UTF-16 code units.
[]
title
String
—
Optional document heading.
—
label
String
—
Accessible document name; falls back to title or the localized document label.
—
placeholder
String
—
Hint shown when the document is empty; localized by default.
—
prompt-placeholder
String
—
Agent prompt hint; localized by default.
—
request
—
Receives prompt, selection, document, AbortSignal and report(). Return text, an AgentEditorResult, or an async iterable of incremental text chunks; Promise results are supported. Takes priority over answer.
—
answer
String
—
Fixed answer for local previews or predetermined content. Without answer or request, formatting remains available and Ask Agent is disabled.
—
formats
[]
bold | italic | underline | strike | code
Available toolbar formats and keyboard format commands.
['bold', 'italic', 'underline', 'strike', 'code']
readonly
Boolean
true | false
Allow selection and Agent questions, but block editing, formatting and applying answers.
false
disabled
Boolean
true | false
Disable document interaction and close/cancel the floating assistance session.
false
animate
Boolean
true | false
Animate whole-answer reveal and toolbar effects. Reduced-motion preferences are respected.
true
stream-interval
Number
milliseconds
Reveal step interval for complete string results. Long answers use bounded grapheme batches; async iterable chunks follow their producer's timing. 0 reveals strings immediately.
18

EVENTS

Event
Type
Description
default
Example
More
update:modelValue
(text: string) => void
Plain text changes.
—
—
update:marks
(marks: []) => void
Inline formatting changes.
—
—
selection-change
(selection: | null) => void
Selection changes; null means no selected text.
—
—
format-change
(format: , marks: []) => void
A format command has been applied.
—
—
request
(request: ) => void
A request is submitted. Use the request prop to provide its result.
—
—
response
(result: ) => void
The complete answer and its sources.
—
—
error
(error: unknown) => void
A request or clipboard operation fails.
—
—
cancel
() => void
A pending operation is cancelled.
—
—
apply
(text: string, mode: 'replace' | 'insert') => void
Answer text is applied to the document.
—
—

SLOTS

Slot
Scope
Description
default
Example
More
agent-icon
{ status: ; busy: boolean }
Assistant icon in the toolbar and prompt. Takes precedence over agent-icon.
—
—
title
{}
Document heading.
—
—
toolbar
{ selection: ; format: (format: ) => void; activeFormats: [] }
Custom format actions. Ask Agent and close controls remain available.
—
—
answer
{ text: string; status: ; selection: ; apply: (mode: 'replace' | 'insert') => void }
Custom answer content; built-in answer actions remain available.
—
—

EXPOSES

Method
Type
Description
default
Example
More
focus
() => void
Focus the document.
—
—
select
(start: number, end: number) => boolean
Select a text range and open its toolbar.
—
—
format
(format: ) => void
Toggle one format on the saved selection.
—
—
ask
(prompt?: string) => Promise<boolean>
Submit a question about the current selection; resolves whether it completed.
—
—
cancel
() => void
Cancel the pending answer and return to prompt entry.
—
—
close
(restoreFocus?: boolean) => void
Close the toolbar and cancel pending work; restoreFocus defaults to false.
—
—
apply
(mode: 'replace' | 'insert') => boolean
Replace selected text or insert after its paragraph with a complete answer.
—
—
Last Updated: 2026-10-28, 06:17:56 UTC
Copied