Skip to content

Add server-side copy/cut/paste/duplicate for blocks - #71

Open
helmutkaufmann wants to merge 2 commits into
wintercms:mainfrom
helmutkaufmann:feat/copy-paste-blocks
Open

Add server-side copy/cut/paste/duplicate for blocks#71
helmutkaufmann wants to merge 2 commits into
wintercms:mainfrom
helmutkaufmann:feat/copy-paste-blocks

Conversation

@helmutkaufmann

Copy link
Copy Markdown
Contributor

Split out of #68 (closed in favor of smaller, focused PRs).

Summary

  • Copy/Cut/Paste/Duplicate is fully server-side and captures all field types (switches, mediafinders, nested repeaters), which a client-side DOM scrape cannot do reliably.
  • Copying calls a server-side handler (onCopyItem) that builds the block's form widget and calls getSaveData(); pasting renders the new item server-side, pre-populated from the captured payload (stored client-side in sessionStorage for the duration of the browser session).
  • Toolbar: collapse, copy, cut, paste, duplicate, config (if applicable), delete — plus a "Paste block" entry in the "Add Block" palette for pasting into an empty widget or at the end of a list.
  • Paste/duplicate respect the widget's allow/ignore/tags constraints.
  • Rich-text and code editor widgets are refreshed via their own APIs after a pasted item is inserted into the DOM.

See the README section "Cut, paste and duplicate blocks" for usage.

Test plan

  • New tests in tests/formwidgets/BlocksTest.php verifying copy preserves nested/switch/text field values, and that pasting seeds a new item without clobbering existing ones
  • Full plugin test suite passes (php artisan winter:test -p Winter.Blocks)

helmutkaufmann and others added 2 commits July 30, 2026 15:27
Each block item gets a single toolbar (collapse, copy, cut, paste,
duplicate, config, delete). Copy/cut/duplicate serialize the item's
full saved data server-side via a new onCopyItem handler (Form
widget + getSaveData()), which correctly captures switches,
mediafinders and nested repeaters that a client-side DOM scrape
would miss. The clipboard (sessionStorage) round-trips through
onAddItem's new _paste_data/_paste_config params, which seed the
new item via an overridden getValueFromIndex() before it's rendered,
so pasted blocks arrive fully populated - including populating any
nested repeaters - without rebuilding the rest of the existing items.
Richeditor/codeeditor widgets are refreshed after a paste fill since
they bypass their own client-side init.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@helmutkaufmann, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3e22d629-1780-4400-b09b-8dc55ec7d458

📥 Commits

Reviewing files that changed from the base of the PR and between 394377b and e06452f.

📒 Files selected for processing (9)
  • CHANGELOG.md
  • README.md
  • formwidgets/Blocks.php
  • formwidgets/blocks/assets/less/blocks.less
  • formwidgets/blocks/partials/_block.php
  • formwidgets/blocks/partials/_block_item.php
  • tests/fixtures/blocks/complex.block
  • tests/formwidgets/BlocksTest.php
  • updates/version.yaml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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