Skip to content

Comments

feat: add optional at prop to insert.text event#2230

Draft
christianhg wants to merge 1 commit intomainfrom
feat/insert-text-at
Draft

feat: add optional at prop to insert.text event#2230
christianhg wants to merge 1 commit intomainfrom
feat/insert-text-at

Conversation

@christianhg
Copy link
Member

@christianhg christianhg commented Feb 22, 2026

Adds an optional at prop to the insert.text event for programmatic text insertion at a specific location. This lets callers insert text without moving the current selection.

Changes

  • behavior.types.event.ts: Added at?: NonNullable<EditorSelection> to insert.text, matching insert.block, delete, annotation.add, etc.
  • operation.insert.text.ts: Converts at to a Slate range and passes it to Transforms.insertText. Falls back to current selection when omitted.
  • behavior.abstract.insert.ts: Expanded selection and no-selection behaviors use event.at ?? snapshot.context.selection as their operating location (same pattern as insert.blocks).
  • behavior.core.insert.ts: Pending marks behavior skips when at is provided, since pending marks are selection-relative state. Inserted text inherits marks from the surrounding context at the target location instead.
  • Three new gherkin scenarios: insert after, insert before, and insert over an expanded range.

@changeset-bot
Copy link

changeset-bot bot commented Feb 22, 2026

🦋 Changeset detected

Latest commit: 3c880bd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@portabletext/editor Minor
@portabletext/plugin-character-pair-decorator Major
@portabletext/plugin-emoji-picker Patch
@portabletext/plugin-input-rule Patch
@portabletext/plugin-markdown-shortcuts Major
@portabletext/plugin-one-line Major
@portabletext/plugin-paste-link Major
@portabletext/plugin-sdk-value Major
@portabletext/plugin-typeahead-picker Patch
@portabletext/plugin-typography Patch
@portabletext/toolbar Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Feb 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
portable-text-editor-documentation Ready Ready Preview, Comment Feb 22, 2026 0:11am
portable-text-example-basic Ready Ready Preview, Comment Feb 22, 2026 0:11am
portable-text-playground Ready Ready Preview, Comment Feb 22, 2026 0:11am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant