Skip to content

Commit

Permalink
Fixed looking for a editable ancestor.
Browse files Browse the repository at this point in the history
  • Loading branch information
niegowski committed Aug 13, 2024
1 parent 83966bb commit 5424dea
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/ckeditor5-widget/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export default class Widget extends Plugin {
const widgetElement = element.findAncestor( isWidget );

if ( !widgetElement || isInsideNestedEditable( element ) ) {
const editableElement = findClosestNestedEditable( element );
const editableElement = findClosestEditableAncestor( element );

if ( !editableElement || !element.childCount ) {
return;
Expand Down Expand Up @@ -643,14 +643,14 @@ function isInsideNestedEditable( element: ViewElement ) {
}

/**
* Returns the closest nested editable element, it includes the element itself.
* Returns the closest editable ancestor element, it includes the element itself.
*/
function findClosestNestedEditable( element: ViewElement ) {
function findClosestEditableAncestor( element: ViewElement ) {
if ( element.is( 'editableElement' ) ) {
return element;
}

return element.findAncestor( 'editableElement' );
return element.findAncestor( element => element.is( 'editableElement' ) );
}

/**
Expand Down

0 comments on commit 5424dea

Please sign in to comment.