@ckeditor/ckeditor5-widget 35.2.0 → 35.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,19 +2,15 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module widget/widgettypearound/utils
8
7
  */
9
-
10
8
  import { isWidget } from '../utils';
11
-
12
9
  /**
13
10
  * The name of the type around model selection attribute responsible for
14
11
  * displaying a fake caret next to a selected widget.
15
12
  */
16
13
  export const TYPE_AROUND_SELECTION_ATTRIBUTE = 'widget-type-around';
17
-
18
14
  /**
19
15
  * Checks if an element is a widget that qualifies to get the widget type around UI.
20
16
  *
@@ -23,20 +19,18 @@ export const TYPE_AROUND_SELECTION_ATTRIBUTE = 'widget-type-around';
23
19
  * @param {module:engine/model/schema~Schema} schema
24
20
  * @returns {Boolean}
25
21
  */
26
- export function isTypeAroundWidget( viewElement, modelElement, schema ) {
27
- return viewElement && isWidget( viewElement ) && !schema.isInline( modelElement );
22
+ export function isTypeAroundWidget(viewElement, modelElement, schema) {
23
+ return !!viewElement && isWidget(viewElement) && !schema.isInline(modelElement);
28
24
  }
29
-
30
25
  /**
31
26
  * For the passed HTML element, this helper finds the closest widget type around button ancestor.
32
27
  *
33
28
  * @param {HTMLElement} domElement
34
29
  * @returns {HTMLElement|null}
35
30
  */
36
- export function getClosestTypeAroundDomButton( domElement ) {
37
- return domElement.closest( '.ck-widget__type-around__button' );
31
+ export function getClosestTypeAroundDomButton(domElement) {
32
+ return domElement.closest('.ck-widget__type-around__button');
38
33
  }
39
-
40
34
  /**
41
35
  * For the passed widget type around button element, this helper determines at which position
42
36
  * the paragraph would be inserted into the content if, for instance, the button was
@@ -45,10 +39,9 @@ export function getClosestTypeAroundDomButton( domElement ) {
45
39
  * @param {HTMLElement} domElement
46
40
  * @returns {'before'|'after'} The position of the button.
47
41
  */
48
- export function getTypeAroundButtonPosition( domElement ) {
49
- return domElement.classList.contains( 'ck-widget__type-around__button_before' ) ? 'before' : 'after';
42
+ export function getTypeAroundButtonPosition(domElement) {
43
+ return domElement.classList.contains('ck-widget__type-around__button_before') ? 'before' : 'after';
50
44
  }
51
-
52
45
  /**
53
46
  * For the passed HTML element, this helper returns the closest view widget ancestor.
54
47
  *
@@ -56,12 +49,10 @@ export function getTypeAroundButtonPosition( domElement ) {
56
49
  * @param {module:engine/view/domconverter~DomConverter} domConverter
57
50
  * @returns {module:engine/view/element~Element}
58
51
  */
59
- export function getClosestWidgetViewElement( domElement, domConverter ) {
60
- const widgetDomElement = domElement.closest( '.ck-widget' );
61
-
62
- return domConverter.mapDomToView( widgetDomElement );
52
+ export function getClosestWidgetViewElement(domElement, domConverter) {
53
+ const widgetDomElement = domElement.closest('.ck-widget');
54
+ return domConverter.mapDomToView(widgetDomElement);
63
55
  }
64
-
65
56
  /**
66
57
  * For the passed selection instance, it returns the position of the fake caret displayed next to a widget.
67
58
  *
@@ -70,6 +61,6 @@ export function getClosestWidgetViewElement( domElement, domConverter ) {
70
61
  * @param {module:engine/model/selection~Selection|module:engine/model/documentselection~DocumentSelection} selection
71
62
  * @returns {'before'|'after'|null} The position of the fake caret or `null` when none is present.
72
63
  */
73
- export function getTypeAroundFakeCaretPosition( selection ) {
74
- return selection.getAttribute( TYPE_AROUND_SELECTION_ATTRIBUTE );
64
+ export function getTypeAroundFakeCaretPosition(selection) {
65
+ return selection.getAttribute(TYPE_AROUND_SELECTION_ATTRIBUTE);
75
66
  }