Skip to content

Commit 670930b

Browse files
authored
Merge pull request #411 from craftcms/bugfix/408-pasting-nested-entries-into-matrix-block
get the right ownerId when we're pasting into a "block" element
2 parents 7424b1f + 489fae8 commit 670930b

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- Added the “Parse embeds” field setting. ([#409](https://github.com/craftcms/ckeditor/pull/409))
6+
- Fixed an error that occurred when copy/pasting a nested entry from a top-level element’s CKEditor field into a nested element’s CKEditor field. ([#408](https://github.com/craftcms/ckeditor/issues/408))
67

78
## 4.8.0 - 2025-04-30
89

src/web/assets/ckeditor/dist/ckeditor5-craftcms.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/web/assets/ckeditor/dist/ckeditor5-craftcms.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/web/assets/ckeditor/src/ckeditor5-craftcms.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,21 @@ const handleClipboard = function (editor, plugins) {
440440
await elementEditor.ensureIsDraftOrRevision();
441441

442442
// get the target owner id, in case we're pasting to a different element all together
443-
ownerId = elementEditor.settings.elementId;
443+
444+
// first try to get that ID by wrapper div
445+
// this way if the CKE field we're pasting into is nested in a matrixblock (or similar), we'll get the correct owner ID
446+
let inputContainer = $editorElement.parents('.input');
447+
if (inputContainer.length > 0) {
448+
let divWrapper = $(inputContainer[0]).find('div[data-config]');
449+
if (divWrapper.length > 0) {
450+
ownerId = $(divWrapper[0]).data('element-id');
451+
}
452+
}
453+
454+
// if we still didn't get the ownerId this way, get it form the element editor
455+
if (ownerId == null) {
456+
ownerId = elementEditor.settings.elementId;
457+
}
444458

445459
// get the target field id, in case we're pasting to a different field all together (not different instance, different field)
446460
layoutElementUid = $editorElement

0 commit comments

Comments
 (0)