Skip to content

Add "Paste from clipboard" button to page and markup sandboxes#1465

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-paste-button-sandboxes
Draft

Add "Paste from clipboard" button to page and markup sandboxes#1465
Copilot wants to merge 2 commits intomainfrom
copilot/add-paste-button-sandboxes

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

Both sandbox editors lacked a way to bulk-replace the editor content from the clipboard and immediately preview the result.

Changes

  • Both sandbox templates (sandbox-markup.html, sandbox-page.html): Inject a "Paste from clipboard" button next to the Preview button. On click, reads the clipboard via navigator.clipboard.readText(), replaces the full CodeMirror 6 editor content, then triggers Preview. Button is only added to the DOM when the Clipboard API is available (secure context / HTTPS).
navigator.clipboard.readText().then(function(text) {
  const view = rlCodemirror.EditorView.findFromDOM(
    document.querySelector('#div_id_content .cm-editor')
  );
  view.dispatch(view.state.update({
    changes: { from: 0, to: view.state.doc.length, insert: text },
  }));
  previewBtn.click();
});
  • sandbox-page.html (bugfix): The existing force-focus script was using the dead CodeMirror 5 API (div.CodeMirror / this.CodeMirror.focus()). Updated to use the CM6 API (EditorView.findFromDOM) consistent with the rest of the codebase.

Copilot AI linked an issue Apr 2, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add paste button to page and markup sandboxes Add "Paste from clipboard" button to page and markup sandboxes Apr 2, 2026
Copilot AI requested a review from inducer April 2, 2026 19:19
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.

Paste button in the page and markup sandboxes

2 participants