Copy and paste
What it does
Components can be copied and pasted with the keyboard, inside a page, between two pages, and between two sites. What goes to the clipboard is text: the same JSON as the export of a page, with only the copied components in it.
Limitations
- Copy and paste are in the editor of a page. The editors of a template and of a saved block do not have them yet.
- A translation that shares the structure of the original page cannot add or remove components: paste on the original.
- Several components are copied together, but only the first is selected after a paste.
Keys
| Key | What it does |
|---|---|
| Ctrl + C (Cmd + C on a Mac) | Copies the selected components, with what is in their slots. |
| Ctrl + X | Copies them and removes them from the page. |
| Ctrl + V | A component is selected: replaces it. Nothing is selected: adds at the end of the page, or of the slot you Alt-clicked. |
| Ctrl + Shift + V | Pastes after the selected component. |
"The selected components" are those chosen in the Structure panel (Ctrl or Shift + click), else the one selected on the canvas. To paste into a slot, Alt + click it (on an empty part, or on a component in it): it gets a dashed outline, nothing is selected, and the next paste goes at the end of that slot. A plain click would select the component the slot is in, which a paste replaces. Any other click ends the choice.
The keys work when the focus is on the canvas or in the Structure panel. In a field, a text editor, a dialog or a form of Drupal inside the editor they are the browser's own. Selected text is copied as text. Text on the clipboard that is not a copy of components (a sentence, a link) is ignored.
The action bar of the selected component has the same actions: Copy, Cut, Paste (replaces it) and Paste after. The buttons read the clipboard, and the browser may ask you to allow that once.
What a paste does
- The pasted components get new ids. A paste is one step of Undo, and is not saved until you save the page.
- A Paragraph block gets a new paragraph with the copied values, made when the page is saved. Two blocks never share a paragraph, also not on the page they were copied from. A paragraph of the Paragraphs Library stays linked.
- A saved block of the library stays linked. If this site does not have it, the rules of the import apply: it is made when you may manage the library, otherwise its content is pasted as a copy.
- Media is found by its UUID on this site. When the text carries the file (the copy includes the media files, up to the size limit of the export), it is made once in the media library. Otherwise the editor says that the media item is missing, and the rest is still pasted.
- A text that cannot be used (a component this site does not have) pastes nothing and says why.
Endpoint
POST /frame-editor/node/{node}/paste with {"file": <the text, or the decoded file>} and the CSRF token in the X-CSRF-Token header. It needs the permission to use the editor and edit access to the page; the permission to import layouts is not needed. It answers with items (the components, with new ids), warnings and what was created, and changes nothing on the page. It uses LayoutImporter::paste(), which is the "insert" mode of the import with copies of paragraphs.