Skip to content

clipboard: Add Clipboard API use cases module#230

Merged
Artur- merged 12 commits into
mainfrom
clipboard
May 11, 2026
Merged

clipboard: Add Clipboard API use cases module#230
Artur- merged 12 commits into
mainfrom
clipboard

Conversation

@Artur-
Copy link
Copy Markdown
Member

@Artur- Artur- commented May 7, 2026

Adds a new use-cases module mirroring the geolocation/signals layout, covering the Clipboard API requirements from vaadin/platform#8759 and the Flow PR vaadin/flow#23615:

UC1 — copy static text on click (with success/error callbacks)
UC2 — copy current value of a component
UC3 — copy image
UC4 — paste text and HTML
UC5 — paste files
UC6 — copy via a context-menu item
UC7 — detect availability and degrade gracefully

UC7 references a Clipboard.isAvailable() that is not yet in the snapshot API; the call is stubbed locally to return true so the module compiles, with the view's enabled/disabled branches kept in place for when the real method lands.

The clipboard module overrides flow.version to 25.2.clipboard-SNAPSHOT (the build from the feature branch); vaadin.version stays on the parent's regular release line so signals/geolocation are unaffected.

Artur- added 12 commits May 7, 2026 11:23
Adds a new use-cases module mirroring the geolocation/signals layout,
covering the Clipboard API requirements from vaadin/platform#8759 and
the Flow PR vaadin/flow#23615:

  UC1 — copy static text on click (with success/error callbacks)
  UC2 — copy current value of a component
  UC3 — copy image
  UC4 — paste text and HTML
  UC5 — paste files
  UC6 — copy via a context-menu item
  UC7 — detect availability and degrade gracefully

UC7 references a Clipboard.isAvailable() that is not yet in the
snapshot API; the call is stubbed locally to return true so the module
compiles, with the view's enabled/disabled branches kept in place for
when the real method lands.

The clipboard module overrides flow.version to 25.2.clipboard-SNAPSHOT
(the build from the feature branch); vaadin.version stays on the
parent's regular release line so signals/geolocation are unaffected.
Pasted HTML was inserted live into the page via Html, so its CSS and
markup could break the surrounding layout. Render the preview inside
a sandboxed IFrame (srcdoc) and show the raw markup as escaped text
in a monospace block alongside it.
The framework's paste handler uploads files before invoking the
server-side listener, so a server-driven spinner only appears after
the upload is already done. Toggle an indeterminate ProgressBar
from a capture-phase JS paste listener so it shows the moment the
upload starts, then hide it from the existing server-side listener
once the upload+roundtrip completes.
The Flow PR moved the Clipboard API from com.vaadin.flow.component.page
to com.vaadin.flow.component.clipboard and added the hooks the views
were previously working around or stubbing:

- UC2/UC3 use the new (target, source, onSuccess, onError) overloads
  of copyOnClick / copyImageOnClick to surface success/failure
  notifications.
- UC5 drops the capture-phase JS spinner workaround in favour of
  addPasteStartListener (show) + addPasteListener (hide on success)
  + addPasteFailedListener (hide and notify on per-file failure),
  which closes the previously-unhandled "upload failed" path.
- UC7 replaces the always-true isClipboardAvailable() stub with
  Clipboard.availabilityHintSignal(), observed via Signal.effect so
  the UI reacts as the value resolves from UNKNOWN to AVAILABLE or
  UNSUPPORTED.
Mirrors the pattern from geolocation/page-visibility (PR #231): a
fixed top-right "View source" link whose href is rebuilt per route in
beforeEnter, hidden for non-*View targets.
Runs the same flyctl deploy command as .github/workflows/fly-deploy.yml
for one module at a time. Falls back to ~/.vaadin/proKey when
VAADIN_PRO_KEY is not in the environment.
@Artur- Artur- enabled auto-merge (squash) May 11, 2026 11:07
@Artur- Artur- merged commit 6850f33 into main May 11, 2026
5 checks passed
@Artur- Artur- deleted the clipboard branch May 11, 2026 11:10
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