@@ -51,6 +51,12 @@ export default class LinkInlineTool implements InlineTool {
5151 */
5252 private readonly ENTER_KEY : number = 13 ;
5353
54+ /**
55+ * Popover item block CSS class
56+ */
57+ private readonly POPOVER_ITEM_CLASSNAME = "ce-popover-item-html" ;
58+
59+
5460 /**
5561 * Styles
5662 */
@@ -264,12 +270,12 @@ export default class LinkInlineTool implements InlineTool {
264270
265271 this . selection . restore ( ) ;
266272 this . selection . removeFakeBackground ( ) ;
267-
268- // check if other selection happend
269- if ( ! currentSelection . savedSelectionRange . collapsed ) {
270- // and recover new selection after removing fake background
273+
274+ // check if other selection happend outside popover element
275+ if ( this . checkSelectionTarget ( currentSelection . savedSelectionRange ) ) {
276+ // and recover new selection
271277 currentSelection . restore ( ) ;
272- }
278+ }
273279 }
274280
275281 this . nodes . input . classList . remove ( this . CSS . inputShowed ) ;
@@ -406,4 +412,22 @@ export default class LinkInlineTool implements InlineTool {
406412 private unlink ( ) : void {
407413 document . execCommand ( this . commandUnlink ) ;
408414 }
415+
416+ /**
417+ * Checks if the current selection range starts outside
418+ * of a popover item element
419+ *
420+ * @param range - The DOM Range to evaluate.
421+ * @returns `true` if popover item block is selection target otherwise - `false`.
422+ */
423+ private checkSelectionTarget ( range : Range ) : boolean {
424+ const container = range . startContainer ;
425+ if ( container instanceof HTMLElement ) {
426+ if ( container . classList . contains ( this . POPOVER_ITEM_CLASSNAME ) ) {
427+ return false ;
428+ }
429+ }
430+
431+ return true ;
432+ }
409433}
0 commit comments