From ed0a470449b4267b8718ff08dd4f21175cd9efb2 Mon Sep 17 00:00:00 2001 From: Glen Date: Mon, 9 Jan 2023 09:45:04 +0200 Subject: [PATCH 1/4] Fix "Cannot read property 'attributes' of null" --- plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.js b/plugin.js index 8a10ab0..1c562a0 100644 --- a/plugin.js +++ b/plugin.js @@ -3060,7 +3060,7 @@ } ); // If widget did not have data-cke-widget attribute before upcasting remove it. - if ( widgetElement.attributes[ 'data-cke-widget-keep-attr' ] != '1' ) + if ( widgetElement && widgetElement.attributes[ 'data-cke-widget-keep-attr' ] != '1' ) delete widgetElement.attributes[ 'data-widget' ]; } } From 4f89cad32bb86dd248a10994115ee1882efda9a8 Mon Sep 17 00:00:00 2001 From: Tomasz Jakut Date: Mon, 23 Jan 2023 15:36:56 +0100 Subject: [PATCH 2/4] Remove widget if there is no replacement for it. --- plugin.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugin.js b/plugin.js index 1c562a0..f8f909f 100644 --- a/plugin.js +++ b/plugin.js @@ -3117,7 +3117,16 @@ if ( !retElement ) retElement = widgetElement; - toBe.wrapper.replaceWith( retElement ); + // In some edge cases (especially applying formating + // at the boundary of the inline editable) the widget + // is going to be duplicated (split in half). + // In that case there won't be a retElement + // and we can safely remove such doppelganger widget (#698). + if ( retElement ) { + toBe.wrapper.replaceWith( retElement ); + } else { + toBe.wrapper.remove(); + } } }, null, null, 13 ); From b7759d1c229628778d79eaf12f0ab07d94a4221e Mon Sep 17 00:00:00 2001 From: Tomasz Jakut Date: Fri, 3 Feb 2023 16:33:23 +0100 Subject: [PATCH 3/4] Apply code style suggestions from code review. Co-authored-by: Kratek --- plugin.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin.js b/plugin.js index f8f909f..5b0e40a 100644 --- a/plugin.js +++ b/plugin.js @@ -3060,8 +3060,9 @@ } ); // If widget did not have data-cke-widget attribute before upcasting remove it. - if ( widgetElement && widgetElement.attributes[ 'data-cke-widget-keep-attr' ] != '1' ) + if ( widgetElement && widgetElement.attributes[ 'data-cke-widget-keep-attr' ] != '1' ) { delete widgetElement.attributes[ 'data-widget' ]; + } } } // Nested editable. From 144a79f802d783da0e29d9c2bef87a43f1c45ff4 Mon Sep 17 00:00:00 2001 From: Tomasz Jakut Date: Fri, 3 Feb 2023 16:34:29 +0100 Subject: [PATCH 4/4] Fix incorrect curly brace position. --- plugin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin.js b/plugin.js index 5b0e40a..669d95e 100644 --- a/plugin.js +++ b/plugin.js @@ -3060,9 +3060,9 @@ } ); // If widget did not have data-cke-widget attribute before upcasting remove it. - if ( widgetElement && widgetElement.attributes[ 'data-cke-widget-keep-attr' ] != '1' ) { + if ( widgetElement && widgetElement.attributes[ 'data-cke-widget-keep-attr' ] != '1' ) { delete widgetElement.attributes[ 'data-widget' ]; - } + } } } // Nested editable.