feat: expose useDropPosition, useListIndex, and DropIndicator from @portabletext/editor#2765
Closed
christianhg wants to merge 1 commit into
Closed
Conversation
🦋 Changeset detectedLatest commit: 34ab20f The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📦 Bundle Stats —
|
| Metric | Value | vs feat/editor-on-behavior-event (a8a1787) |
|---|---|---|
| Internal (raw) | 776.8 KB | -959 B, -0.1% |
| Internal (gzip) | 147.6 KB | -213 B, -0.1% |
| Bundled (raw) | 1.38 MB | -988 B, -0.1% |
| Bundled (gzip) | 309.5 KB | -182 B, -0.1% |
| Import time | 97ms | -1ms, -0.9% |
@portabletext/editor/behaviors
| Metric | Value | vs feat/editor-on-behavior-event (a8a1787) |
|---|---|---|
| Internal (raw) | 467 B | - |
| Internal (gzip) | 207 B | - |
| Bundled (raw) | 424 B | - |
| Bundled (gzip) | 171 B | - |
| Import time | 2ms | +0ms, +0.3% |
@portabletext/editor/plugins
| Metric | Value | vs feat/editor-on-behavior-event (a8a1787) |
|---|---|---|
| Internal (raw) | 2.7 KB | - |
| Internal (gzip) | 894 B | - |
| Bundled (raw) | 2.5 KB | - |
| Bundled (gzip) | 827 B | - |
| Import time | 7ms | -0ms, -0.2% |
@portabletext/editor/selectors
| Metric | Value | vs feat/editor-on-behavior-event (a8a1787) |
|---|---|---|
| Internal (raw) | 79.3 KB | -6 B, -0.0% |
| Internal (gzip) | 14.5 KB | -6 B, -0.0% |
| Bundled (raw) | 74.8 KB | -6 B, -0.0% |
| Bundled (gzip) | 13.4 KB | -12 B, -0.1% |
| Import time | 8ms | -0ms, -0.5% |
@portabletext/editor/traversal
| Metric | Value | vs feat/editor-on-behavior-event (a8a1787) |
|---|---|---|
| Internal (raw) | 25.4 KB | - |
| Internal (gzip) | 5.0 KB | - |
| Bundled (raw) | 25.4 KB | - |
| Bundled (gzip) | 5.0 KB | - |
| Import time | 6ms | +0ms, +0.3% |
@portabletext/editor/utils
| Metric | Value | vs feat/editor-on-behavior-event (a8a1787) |
|---|---|---|
| Internal (raw) | 28.7 KB | - |
| Internal (gzip) | 6.0 KB | - |
| Bundled (raw) | 26.7 KB | - |
| Bundled (gzip) | 5.7 KB | - |
| Import time | 6ms | +0ms, +0.6% |
🗺️ . · ./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.
📦 Bundle Stats — @portabletext/markdown
Compared against feat/editor-on-behavior-event (a8a17873)
| Metric | Value | vs feat/editor-on-behavior-event (a8a1787) |
|---|---|---|
| Internal (raw) | 53.0 KB | - |
| Internal (gzip) | 9.6 KB | - |
| Bundled (raw) | 347.6 KB | - |
| Bundled (gzip) | 96.0 KB | - |
| Import time | 40ms | +0ms, +0.1% |
🗺️ View treemap · 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.
8b8d3dd to
ae373ec
Compare
ae373ec to
c1990db
Compare
c1990db to
427747a
Compare
427747a to
c7bce94
Compare
c7bce94 to
bf38f2a
Compare
bf38f2a to
a936758
Compare
…tor/plugins
Promotes the engine's drop-position machinery to a small public surface
under @portabletext/editor/plugins:
- useDropPosition(path) — path-scoped, returns 'start' | 'end' | undefined.
Used inside renderBlock or container render callbacks to know where to
paint a drop indicator.
- DropIndicator — the default visual; export for consumers who want to
paint it themselves while keeping the engine's visual identity.
- DropPosition — type.
The engine continues to paint the default indicator via the existing
renderBlock and renderListItem paths, so there's no breaking change for
consumers relying on the implicit affordance. The structural change is
small: state moves from a hook called inside Editable.tsx into a
DropPositionProvider mounted by EditorProvider; Editable.tsx reads the
context via useDropPosition() (no-arg overload).
The plugin is built on top of editor.on('drag.dragover', …) from #2764 —
same publication surface any future drag-aware plugin would use.
a936758 to
34ab20f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Companion to #2764. Promotes the engine's drop-position machinery and list-index map to a small public surface on
@portabletext/editor.What's public
useDropPosition(path)— path-scoped, returns'start' | 'end' | undefined. Drop intorenderBlockor a container render callback to paint a drop indicator at the right edge.useListIndex(path)— path-scoped, returns the 1-based numbered-list index orundefined. The same value the engine paints ondata-list-index.DropIndicator— the default drop-indicator visual. Export so consumers can paint it themselves while keeping the engine's visual identity.DropPosition— the'start' | 'end'type.All four are
@betaand ship from the main entry.Built on
editor.onuseDropPositionsubscribes toeditor.on('drag.dragover', …)from #2764 — the same publication surface any future drag-aware plugin would use. Noadd behaviorsend, no store primitive, no new context contract on the public editor type. The engine publishes the behavior-event stream; the plugin builds the React-context provider on top.useListIndexreads from the engine'slistIndexMapvia the existing engine selector context. Same pattern: the engine maintains the map, the hook exposes a stable path-keyed read.The engine's built-in
renderBlock/renderListItempaths consume bothuseDropPosition(props.path)anduseListIndex(props.path)directly. Drop position threading throughRenderElementprops is gone;resolve-element-drop-positionis gone; the engine and external consumers read from the same context.No breaking change
The engine continues to paint the default drop indicator and
data-list-indexvia the built-inrenderBlockandrenderListItempaths. Consumers relying on the implicit affordances see no behavior change.EditorProvidermounts an@internalDropPositionProviderso the context is always available to render callbacks.Followups (not in this PR)
dropPositionandlistIndexrender-props become redundant; that PR shrinks to justdraggable.