Skip to content

get the right ownerId when we're pasting into a "block" element #411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Added the “Parse embeds” field setting. ([#409](https://github.com/craftcms/ckeditor/pull/409))
- 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))

## 4.8.0 - 2025-04-30

Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/ckeditor/dist/ckeditor5-craftcms.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/ckeditor/dist/ckeditor5-craftcms.js.map

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion src/web/assets/ckeditor/src/ckeditor5-craftcms.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,21 @@ const handleClipboard = function (editor, plugins) {
await elementEditor.ensureIsDraftOrRevision();

// get the target owner id, in case we're pasting to a different element all together
ownerId = elementEditor.settings.elementId;

// first try to get that ID by wrapper div
// this way if the CKE field we're pasting into is nested in a matrixblock (or similar), we'll get the correct owner ID
let inputContainer = $editorElement.parents('.input');
if (inputContainer.length > 0) {
let divWrapper = $(inputContainer[0]).find('div[data-config]');
if (divWrapper.length > 0) {
ownerId = $(divWrapper[0]).data('element-id');
}
}

// if we still didn't get the ownerId this way, get it form the element editor
if (ownerId == null) {
ownerId = elementEditor.settings.elementId;
}

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