Skip to content

feat: pass dropPosition to defineContainer's render callback#2643

Open
christianhg wants to merge 1 commit into
mainfrom
feat/drop-position-on-container-render
Open

feat: pass dropPosition to defineContainer's render callback#2643
christianhg wants to merge 1 commit into
mainfrom
feat/drop-position-on-container-render

Conversation

@christianhg
Copy link
Copy Markdown
Member

Today defineContainer's render callback receives the engine's path-resolved focused/selected/readOnly state for the container, but not the resolved drop position. Legacy block-objects already auto-paint a drop indicator via the engine. Containers couldn't, because the data wasn't plumbed through.

This passes dropPosition: 'start' | 'end' | undefined to the render callback when a drag targets the container's block boundary. Consumers paint their own indicator using whatever DOM and styling they prefer:

defineContainer({
  scope: '$..callout',
  field: 'content',
  render: ({attributes, children, dropPosition}) => (
    <aside {...attributes} data-drop-position={dropPosition}>
      {children}
    </aside>
  ),
})

The resolution reuses the same path-based match the legacy pipeline uses (resolveElementDropPosition). No new engine logic, no new subscriptions, no new public hooks. Containers that don't reference dropPosition in their render callback pay zero extra cost during a drag.

The playground callout demonstrates the pattern with a thin top/bottom border painted via Tailwind data-attribute selectors.

Containers receive the resolved drop position ('start' | 'end' | undefined) when a drag targets the container's block boundary. Consumers paint their own drop indicator.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 11, 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 May 11, 2026 0:27am
portable-text-example-basic Ready Ready Preview, Comment May 11, 2026 0:27am
portable-text-playground Ready Ready Preview, Comment May 11, 2026 0:27am

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 11, 2026

🦋 Changeset detected

Latest commit: 8663222

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

📦 Bundle Stats — @portabletext/editor

Compared against main (1b64415c)

@portabletext/editor

Metric Value vs main (1b64415)
Internal (raw) 744.5 KB +325 B, +0.0%
Internal (gzip) 142.9 KB +28 B, +0.0%
Bundled (raw) 1.35 MB +325 B, +0.0%
Bundled (gzip) 303.9 KB +27 B, +0.0%
Import time 96ms +0ms, +0.0%

@portabletext/editor/behaviors

Metric Value vs main (1b64415)
Internal (raw) 467 B -
Internal (gzip) 207 B -
Bundled (raw) 424 B -
Bundled (gzip) 171 B -
Import time 2ms +0ms, +0.6%

@portabletext/editor/plugins

Metric Value vs main (1b64415)
Internal (raw) 3.6 KB -
Internal (gzip) 1021 B -
Bundled (raw) 3.4 KB -
Bundled (gzip) 952 B -
Import time 8ms +0ms, +0.1%

@portabletext/editor/selectors

Metric Value vs main (1b64415)
Internal (raw) 76.3 KB -
Internal (gzip) 14.3 KB -
Bundled (raw) 72.4 KB -
Bundled (gzip) 13.3 KB -
Import time 8ms +0ms, +0.2%

@portabletext/editor/traversal

Metric Value vs main (1b64415)
Internal (raw) 9.2 KB -
Internal (gzip) 2.4 KB -
Bundled (raw) 9.3 KB -
Bundled (gzip) 2.4 KB -
Import time 5ms +0ms, +0.9%

@portabletext/editor/utils

Metric Value vs main (1b64415)
Internal (raw) 30.6 KB -
Internal (gzip) 6.5 KB -
Bundled (raw) 28.4 KB -
Bundled (gzip) 6.1 KB -
Import time 7ms +0ms, +2.0%

🗺️ . · ./behaviors · ./plugins · ./selectors · ./traversal · ./utils · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

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