Inserting HTML at current Caret position
Hannah's onboarding tool is built around boilerplate. Her company's HR team writes offer letters in a WPF authoring app, and each letter is 80% common language and 20% candidate-specific. The common language lives in a library of named snippets: Standard Benefits Clause, California Addendum, Remote Work Provision, Signing Bonus Section A. The recruiters told Hannah they want one-click insertion -- click Standard Benefits Clause, see it appear in the letter at the cursor, keep typing.
Replacing the whole document is not the right move. The recruiter has already filled in the candidate's name, address, and start date. What Hannah needs is to drop a fragment of HTML in at the caret position without disturbing anything around it. The Content service on the editor exposes exactly that:
// SpiceLogic.HtmlEditor.Abstractions.Services.IContentService
void InsertHtml(string htmlText, bool keepSelected);The first version
Hannah wires a button per snippet into the toolbar area. Each button's click handler grabs the snippet from her snippet repository and pushes it into the editor:
<DockPanel xmlns:editor="clr-namespace:SpiceLogic.HtmlEditor.WPF;assembly=SpiceLogic.HtmlEditor.WPF">
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<Button Content="Standard Benefits" Click="InsertBenefits_Click" />
<Button Content="California Addendum" Click="InsertCalifornia_Click" />
<Button Content="Remote Work Provision" Click="InsertRemoteWork_Click" />
</StackPanel>
<editor:WpfHtmlEditor x:Name="LetterEditor" />
</DockPanel>private void InsertBenefits_Click(object sender, RoutedEventArgs e)
{
var html = _snippetRepo.Get("Standard-Benefits-2026");
LetterEditor.Focus();
LetterEditor.Content.InsertHtml(html, keepSelected: false);
}The explicit Focus() call matters. A click on the toolbar button moves WPF keyboard focus to the button itself; without putting it back on the editor first, the caret position is undefined and the inserted markup can land in unexpected places. With focus restored, the snippet drops in exactly where the recruiter's cursor was, and the cursor sits at the end of the inserted block ready for the next keystroke.

The keepSelected switch
The boolean parameter controls what is selected after the insert. The recruiter use case wants false -- drop the clause in, position the caret at the end, let the recruiter keep typing. But there is a second use case Hannah hits a sprint later. A new button reads Insert Signing Bonus Placeholder and the recruiter is expected to immediately type the amount over the placeholder text. For that, she passes true so the placeholder is selected as soon as it appears, and the first keystroke overwrites it:
private void InsertBonusPlaceholder_Click(object sender, RoutedEventArgs e)
{
LetterEditor.Focus();
LetterEditor.Content.InsertHtml(
"<span class=\"placeholder\">[BONUS AMOUNT]</span>",
keepSelected: true);
}One method, two distinct user experiences, decided by a single boolean.

What it will not do
One of Hannah's snippets contained an inline <script> block -- a leftover from a prototype that injected a tracking pixel. The script never executed. InsertHtml filters script blocks out by design; allowing the caret-insertion path to inject executable JavaScript would be an obvious vector for hostile content if a snippet ever came from an untrusted source. When a script block genuinely belongs in the document, the Content service exposes a parallel InsertScript(string scriptMarkUp) method for that purpose. Styles and link tags that belong in the document head go through InsertHtmlBetweenHead(string) -- inserting them at the caret puts them in the body where they will not have their intended effect.
Shipping it
The final onboarding tool ships with 23 named snippets in the snippet repository, each wired to its own toolbar button. The recruiters compose a typical offer letter in about a minute -- candidate-specific details typed by hand, every common clause inserted with one click at the caret position. The same pattern works for an email-signature button in a CRM, a merge-field picker in a contract authoring tool, or any place a developer wants the user to drop pre-built HTML into the document without leaving the editor.