@ckeditor/ckeditor5-ui 29.2.0 → 32.0.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.
Files changed (146) hide show
  1. package/LICENSE.md +2 -2
  2. package/lang/translations/ar.po +2 -2
  3. package/lang/translations/ast.po +1 -1
  4. package/lang/translations/az.po +1 -1
  5. package/lang/translations/cs.po +1 -1
  6. package/lang/translations/da.po +1 -1
  7. package/lang/translations/de-ch.po +1 -1
  8. package/lang/translations/de.po +1 -1
  9. package/lang/translations/el.po +2 -2
  10. package/lang/translations/en-au.po +1 -1
  11. package/lang/translations/en-gb.po +1 -1
  12. package/lang/translations/en.po +1 -1
  13. package/lang/translations/eo.po +1 -1
  14. package/lang/translations/es.po +1 -1
  15. package/lang/translations/et.po +1 -1
  16. package/lang/translations/eu.po +1 -1
  17. package/lang/translations/fa.po +1 -1
  18. package/lang/translations/fi.po +1 -1
  19. package/lang/translations/fr.po +1 -1
  20. package/lang/translations/gl.po +1 -1
  21. package/lang/translations/he.po +1 -1
  22. package/lang/translations/hi.po +1 -1
  23. package/lang/translations/hr.po +1 -1
  24. package/lang/translations/hu.po +1 -1
  25. package/lang/translations/id.po +1 -1
  26. package/lang/translations/it.po +1 -1
  27. package/lang/translations/ja.po +1 -1
  28. package/lang/translations/km.po +1 -1
  29. package/lang/translations/kn.po +1 -1
  30. package/lang/translations/ko.po +1 -1
  31. package/lang/translations/ku.po +1 -1
  32. package/lang/translations/lt.po +1 -1
  33. package/lang/translations/lv.po +1 -1
  34. package/lang/translations/nb.po +1 -1
  35. package/lang/translations/ne.po +1 -1
  36. package/lang/translations/nl.po +2 -2
  37. package/lang/translations/no.po +1 -1
  38. package/lang/translations/pl.po +1 -1
  39. package/lang/translations/pt-br.po +1 -1
  40. package/lang/translations/pt.po +1 -1
  41. package/lang/translations/ro.po +1 -1
  42. package/lang/translations/ru.po +1 -1
  43. package/lang/translations/sk.po +1 -1
  44. package/lang/translations/sl.po +1 -1
  45. package/lang/translations/sq.po +1 -1
  46. package/lang/translations/sr-latn.po +1 -1
  47. package/lang/translations/sr.po +1 -1
  48. package/lang/translations/sv.po +1 -1
  49. package/lang/translations/th.po +1 -1
  50. package/lang/translations/tk.po +1 -1
  51. package/lang/translations/tr.po +1 -1
  52. package/lang/translations/ug.po +2 -2
  53. package/lang/translations/uk.po +1 -1
  54. package/lang/translations/uz.po +105 -0
  55. package/lang/translations/vi.po +1 -1
  56. package/lang/translations/zh-cn.po +1 -1
  57. package/lang/translations/zh.po +1 -1
  58. package/package.json +20 -21
  59. package/src/bindings/clickoutsidehandler.js +1 -1
  60. package/src/bindings/injectcsstransitiondisabler.js +1 -1
  61. package/src/bindings/preventdefault.js +1 -1
  62. package/src/bindings/submithandler.js +1 -1
  63. package/src/button/button.jsdoc +1 -1
  64. package/src/button/buttonview.js +2 -2
  65. package/src/button/switchbuttonview.js +1 -1
  66. package/src/colorgrid/colorgridview.js +11 -1
  67. package/src/colorgrid/colortileview.js +1 -1
  68. package/src/colorgrid/utils.js +1 -1
  69. package/src/componentfactory.js +1 -1
  70. package/src/dropdown/button/dropdownbutton.jsdoc +1 -1
  71. package/src/dropdown/button/dropdownbuttonview.js +1 -1
  72. package/src/dropdown/button/splitbuttonview.js +11 -1
  73. package/src/dropdown/dropdownpanelfocusable.jsdoc +1 -1
  74. package/src/dropdown/dropdownpanelview.js +1 -1
  75. package/src/dropdown/dropdownview.js +1 -1
  76. package/src/dropdown/utils.js +1 -1
  77. package/src/editableui/editableuiview.js +1 -1
  78. package/src/editableui/inline/inlineeditableuiview.js +1 -1
  79. package/src/editorui/bodycollection.js +1 -1
  80. package/src/editorui/boxed/boxededitoruiview.js +1 -1
  81. package/src/editorui/editoruiview.js +1 -1
  82. package/src/focuscycler.js +19 -4
  83. package/src/formheader/formheaderview.js +1 -1
  84. package/src/icon/iconview.js +1 -1
  85. package/src/iframe/iframeview.js +1 -1
  86. package/src/index.js +3 -1
  87. package/src/input/inputview.js +216 -0
  88. package/src/inputnumber/inputnumberview.js +71 -0
  89. package/src/inputtext/inputtextview.js +7 -169
  90. package/src/label/labelview.js +1 -1
  91. package/src/labeledfield/labeledfieldview.js +1 -1
  92. package/src/labeledfield/utils.js +54 -5
  93. package/src/labeledinput/labeledinputview.js +1 -1
  94. package/src/list/listitemview.js +1 -1
  95. package/src/list/listseparatorview.js +1 -1
  96. package/src/list/listview.js +11 -1
  97. package/src/model.js +1 -1
  98. package/src/notification/notification.js +2 -2
  99. package/src/panel/balloon/balloonpanelview.js +343 -217
  100. package/src/panel/balloon/contextualballoon.js +32 -5
  101. package/src/panel/sticky/stickypanelview.js +6 -2
  102. package/src/template.js +1 -1
  103. package/src/toolbar/balloon/balloontoolbar.js +49 -36
  104. package/src/toolbar/block/blockbuttonview.js +1 -1
  105. package/src/toolbar/block/blocktoolbar.js +4 -3
  106. package/src/toolbar/enabletoolbarkeyboardfocus.js +1 -1
  107. package/src/toolbar/normalizetoolbarconfig.js +1 -1
  108. package/src/toolbar/toolbarlinebreakview.js +1 -1
  109. package/src/toolbar/toolbarseparatorview.js +1 -1
  110. package/src/toolbar/toolbarview.js +7 -4
  111. package/src/tooltip/tooltipview.js +1 -1
  112. package/src/view.js +1 -1
  113. package/src/viewcollection.js +1 -1
  114. package/theme/components/button/button.css +1 -1
  115. package/theme/components/button/switchbutton.css +1 -1
  116. package/theme/components/colorgrid/colorgrid.css +1 -1
  117. package/theme/components/dropdown/dropdown.css +1 -1
  118. package/theme/components/dropdown/listdropdown.css +1 -1
  119. package/theme/components/dropdown/splitbutton.css +1 -1
  120. package/theme/components/dropdown/toolbardropdown.css +1 -1
  121. package/theme/components/editorui/editorui.css +1 -1
  122. package/theme/components/formheader/formheader.css +1 -1
  123. package/theme/components/icon/icon.css +1 -1
  124. package/theme/components/{inputtext/inputtext.css → input/input.css} +1 -1
  125. package/theme/components/label/label.css +1 -1
  126. package/theme/components/labeledfield/labeledfieldview.css +1 -1
  127. package/theme/components/labeledinput/labeledinput.css +1 -1
  128. package/theme/components/list/list.css +1 -1
  129. package/theme/components/panel/balloonpanel.css +1 -1
  130. package/theme/components/panel/balloonrotator.css +1 -1
  131. package/theme/components/panel/fakepanel.css +1 -1
  132. package/theme/components/panel/stickypanel.css +1 -1
  133. package/theme/components/responsive-form/responsiveform.css +1 -1
  134. package/theme/components/toolbar/blocktoolbar.css +1 -1
  135. package/theme/components/toolbar/toolbar.css +1 -1
  136. package/theme/components/tooltip/mixins/_tooltip.css +1 -1
  137. package/theme/components/tooltip/tooltip.css +1 -1
  138. package/theme/globals/_hidden.css +1 -1
  139. package/theme/globals/_reset.css +1 -1
  140. package/theme/globals/_transition.css +1 -1
  141. package/theme/globals/_zindex.css +1 -1
  142. package/theme/globals/globals.css +1 -1
  143. package/theme/mixins/_dir.css +1 -1
  144. package/theme/mixins/_rwd.css +1 -1
  145. package/theme/mixins/_unselectable.css +1 -1
  146. package/CHANGELOG.md +0 -542
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
@@ -232,7 +232,8 @@ export default class BalloonPanelView extends View {
232
232
  defaultPositions.northArrowSouthMiddleWest,
233
233
  defaultPositions.northArrowSouthMiddleEast,
234
234
  defaultPositions.northArrowSouthWest,
235
- defaultPositions.northArrowSouthEast
235
+ defaultPositions.northArrowSouthEast,
236
+ defaultPositions.viewportStickyNorth
236
237
  ],
237
238
  limiter: defaultLimiterElement,
238
239
  fitInViewport: true
@@ -244,9 +245,11 @@ export default class BalloonPanelView extends View {
244
245
  // so it is better to use int values.
245
246
  const left = parseInt( optimalPosition.left );
246
247
  const top = parseInt( optimalPosition.top );
247
- const position = optimalPosition.name;
248
248
 
249
- Object.assign( this, { top, left, position } );
249
+ const { name: position, config = {} } = optimalPosition;
250
+ const { withArrow = true } = config;
251
+
252
+ Object.assign( this, { top, left, position, withArrow } );
250
253
  }
251
254
 
252
255
  /**
@@ -401,7 +404,7 @@ function getDomElement( object ) {
401
404
  * \|/
402
405
  * >|-----|<---------------- horizontal offset
403
406
  *
404
- * @default 30
407
+ * @default 25
405
408
  * @member {Number} module:ui/panel/balloon/balloonpanelview~BalloonPanelView.arrowHorizontalOffset
406
409
  */
407
410
  BalloonPanelView.arrowHorizontalOffset = 25;
@@ -420,11 +423,35 @@ BalloonPanelView.arrowHorizontalOffset = 25;
420
423
  * -------------------------------
421
424
  * ^
422
425
  *
423
- * @default 15
426
+ * @default 10
424
427
  * @member {Number} module:ui/panel/balloon/balloonpanelview~BalloonPanelView.arrowVerticalOffset
425
428
  */
426
429
  BalloonPanelView.arrowVerticalOffset = 10;
427
430
 
431
+ /**
432
+ * A vertical offset of the balloon panel from the edge of the viewport if sticky.
433
+ * It helps in accessing toolbar buttons underneath the balloon panel.
434
+ *
435
+ * +---------------------------------------------------+
436
+ * | Target |
437
+ * | |
438
+ * | /-- vertical offset |
439
+ * +-----------------------------V-------------------------+
440
+ * | Toolbar +-------------+ |
441
+ * +--------------------| Balloon |--------------------+
442
+ * | | +-------------+ | |
443
+ * | | | |
444
+ * | | | |
445
+ * | | | |
446
+ * | +---------------------------------------------------+ |
447
+ * | Viewport |
448
+ * +-------------------------------------------------------+
449
+ *
450
+ * @default 20
451
+ * @member {Number} module:ui/panel/balloon/balloonpanelview~BalloonPanelView.stickyVerticalOffset
452
+ */
453
+ BalloonPanelView.stickyVerticalOffset = 20;
454
+
428
455
  /**
429
456
  * Function used to calculate the optimal position for the balloon.
430
457
  *
@@ -702,225 +729,324 @@ BalloonPanelView._getOptimalPosition = getOptimalPosition;
702
729
  * | Balloon |
703
730
  * +-----------------+
704
731
  *
732
+ * * `viewportStickyNorth`
733
+ *
734
+ * +---------------------------+
735
+ * | [ Target ] |
736
+ * | |
737
+ * +-----------------------------------+
738
+ * | | +-----------------+ | |
739
+ * | | | Balloon | | |
740
+ * | | +-----------------+ | |
741
+ * | | | |
742
+ * | | | |
743
+ * | | | |
744
+ * | | | |
745
+ * | +---------------------------+ |
746
+ * | Viewport |
747
+ * +-----------------------------------+
705
748
  *
706
749
  * See {@link module:ui/panel/balloon/balloonpanelview~BalloonPanelView#attachTo}.
707
750
  *
708
751
  * Positioning functions must be compatible with {@link module:utils/dom/position~Position}.
709
752
  *
753
+ * Default positioning functions with customized offsets can be generated using
754
+ * {@link module:ui/panel/balloon/balloonpanelview~generatePositions}.
755
+ *
710
756
  * The name that the position function returns will be reflected in the balloon panel's class that
711
757
  * controls the placement of the "arrow". See {@link #position} to learn more.
712
758
  *
713
- * @member {Object} module:ui/panel/balloon/balloonpanelview~BalloonPanelView.defaultPositions
759
+ * @member {Object.<String,module:utils/dom/position~positioningFunction>}
760
+ * module:ui/panel/balloon/balloonpanelview~BalloonPanelView.defaultPositions
714
761
  */
715
- BalloonPanelView.defaultPositions = {
716
-
717
- // ------- North west
718
-
719
- northWestArrowSouthWest: ( targetRect, balloonRect ) => ( {
720
- top: getNorthTop( targetRect, balloonRect ),
721
- left: targetRect.left - BalloonPanelView.arrowHorizontalOffset,
722
- name: 'arrow_sw'
723
- } ),
724
-
725
- northWestArrowSouthMiddleWest: ( targetRect, balloonRect ) => ( {
726
- top: getNorthTop( targetRect, balloonRect ),
727
- left: targetRect.left - ( balloonRect.width * .25 ) - BalloonPanelView.arrowHorizontalOffset,
728
- name: 'arrow_smw'
729
- } ),
730
-
731
- northWestArrowSouth: ( targetRect, balloonRect ) => ( {
732
- top: getNorthTop( targetRect, balloonRect ),
733
- left: targetRect.left - balloonRect.width / 2,
734
- name: 'arrow_s'
735
- } ),
736
-
737
- northWestArrowSouthMiddleEast: ( targetRect, balloonRect ) => ( {
738
- top: getNorthTop( targetRect, balloonRect ),
739
- left: targetRect.left - ( balloonRect.width * .75 ) + BalloonPanelView.arrowHorizontalOffset,
740
- name: 'arrow_sme'
741
- } ),
742
-
743
- northWestArrowSouthEast: ( targetRect, balloonRect ) => ( {
744
- top: getNorthTop( targetRect, balloonRect ),
745
- left: targetRect.left - balloonRect.width + BalloonPanelView.arrowHorizontalOffset,
746
- name: 'arrow_se'
747
- } ),
748
-
749
- // ------- North
750
-
751
- northArrowSouthWest: ( targetRect, balloonRect ) => ( {
752
- top: getNorthTop( targetRect, balloonRect ),
753
- left: targetRect.left + targetRect.width / 2 - BalloonPanelView.arrowHorizontalOffset,
754
- name: 'arrow_sw'
755
- } ),
756
-
757
- northArrowSouthMiddleWest: ( targetRect, balloonRect ) => ( {
758
- top: getNorthTop( targetRect, balloonRect ),
759
- left: targetRect.left + targetRect.width / 2 - ( balloonRect.width * .25 ) - BalloonPanelView.arrowHorizontalOffset,
760
- name: 'arrow_smw'
761
- } ),
762
-
763
- northArrowSouth: ( targetRect, balloonRect ) => ( {
764
- top: getNorthTop( targetRect, balloonRect ),
765
- left: targetRect.left + targetRect.width / 2 - balloonRect.width / 2,
766
- name: 'arrow_s'
767
- } ),
768
-
769
- northArrowSouthMiddleEast: ( targetRect, balloonRect ) => ( {
770
- top: getNorthTop( targetRect, balloonRect ),
771
- left: targetRect.left + targetRect.width / 2 - ( balloonRect.width * .75 ) + BalloonPanelView.arrowHorizontalOffset,
772
- name: 'arrow_sme'
773
- } ),
774
-
775
- northArrowSouthEast: ( targetRect, balloonRect ) => ( {
776
- top: getNorthTop( targetRect, balloonRect ),
777
- left: targetRect.left + targetRect.width / 2 - balloonRect.width + BalloonPanelView.arrowHorizontalOffset,
778
- name: 'arrow_se'
779
- } ),
780
-
781
- // ------- North east
782
-
783
- northEastArrowSouthWest: ( targetRect, balloonRect ) => ( {
784
- top: getNorthTop( targetRect, balloonRect ),
785
- left: targetRect.right - BalloonPanelView.arrowHorizontalOffset,
786
- name: 'arrow_sw'
787
- } ),
788
-
789
- northEastArrowSouthMiddleWest: ( targetRect, balloonRect ) => ( {
790
- top: getNorthTop( targetRect, balloonRect ),
791
- left: targetRect.right - ( balloonRect.width * .25 ) - BalloonPanelView.arrowHorizontalOffset,
792
- name: 'arrow_smw'
793
- } ),
794
- northEastArrowSouth: ( targetRect, balloonRect ) => ( {
795
- top: getNorthTop( targetRect, balloonRect ),
796
- left: targetRect.right - balloonRect.width / 2,
797
- name: 'arrow_s'
798
- } ),
799
-
800
- northEastArrowSouthMiddleEast: ( targetRect, balloonRect ) => ( {
801
- top: getNorthTop( targetRect, balloonRect ),
802
- left: targetRect.right - ( balloonRect.width * .75 ) + BalloonPanelView.arrowHorizontalOffset,
803
- name: 'arrow_sme'
804
- } ),
805
-
806
- northEastArrowSouthEast: ( targetRect, balloonRect ) => ( {
807
- top: getNorthTop( targetRect, balloonRect ),
808
- left: targetRect.right - balloonRect.width + BalloonPanelView.arrowHorizontalOffset,
809
- name: 'arrow_se'
810
- } ),
811
- // ------- South west
812
-
813
- southWestArrowNorthWest: ( targetRect, balloonRect ) => ( {
814
- top: getSouthTop( targetRect, balloonRect ),
815
- left: targetRect.left - BalloonPanelView.arrowHorizontalOffset,
816
- name: 'arrow_nw'
817
- } ),
818
-
819
- southWestArrowNorthMiddleWest: ( targetRect, balloonRect ) => ( {
820
- top: getSouthTop( targetRect, balloonRect ),
821
- left: targetRect.left - ( balloonRect.width * .25 ) - BalloonPanelView.arrowHorizontalOffset,
822
- name: 'arrow_nmw'
823
- } ),
824
-
825
- southWestArrowNorth: ( targetRect, balloonRect ) => ( {
826
- top: getSouthTop( targetRect, balloonRect ),
827
- left: targetRect.left - balloonRect.width / 2,
828
- name: 'arrow_n'
829
- } ),
830
-
831
- southWestArrowNorthMiddleEast: ( targetRect, balloonRect ) => ( {
832
- top: getSouthTop( targetRect, balloonRect ),
833
- left: targetRect.left - ( balloonRect.width * .75 ) + BalloonPanelView.arrowHorizontalOffset,
834
- name: 'arrow_nme'
835
- } ),
836
-
837
- southWestArrowNorthEast: ( targetRect, balloonRect ) => ( {
838
- top: getSouthTop( targetRect, balloonRect ),
839
- left: targetRect.left - balloonRect.width + BalloonPanelView.arrowHorizontalOffset,
840
- name: 'arrow_ne'
841
- } ),
842
-
843
- // ------- South
844
-
845
- southArrowNorthWest: ( targetRect, balloonRect ) => ( {
846
- top: getSouthTop( targetRect, balloonRect ),
847
- left: targetRect.left + targetRect.width / 2 - BalloonPanelView.arrowHorizontalOffset,
848
- name: 'arrow_nw'
849
- } ),
850
- southArrowNorthMiddleWest: ( targetRect, balloonRect ) => ( {
851
- top: getSouthTop( targetRect, balloonRect ),
852
- left: targetRect.left + targetRect.width / 2 - ( balloonRect.width * 0.25 ) - BalloonPanelView.arrowHorizontalOffset,
853
- name: 'arrow_nmw'
854
- } ),
855
-
856
- southArrowNorth: ( targetRect, balloonRect ) => ( {
857
- top: getSouthTop( targetRect, balloonRect ),
858
- left: targetRect.left + targetRect.width / 2 - balloonRect.width / 2,
859
- name: 'arrow_n'
860
- } ),
861
-
862
- southArrowNorthMiddleEast: ( targetRect, balloonRect ) => ( {
863
- top: getSouthTop( targetRect, balloonRect ),
864
- left: targetRect.left + targetRect.width / 2 - ( balloonRect.width * 0.75 ) + BalloonPanelView.arrowHorizontalOffset,
865
- name: 'arrow_nme'
866
- } ),
867
-
868
- southArrowNorthEast: ( targetRect, balloonRect ) => ( {
869
- top: getSouthTop( targetRect, balloonRect ),
870
- left: targetRect.left + targetRect.width / 2 - balloonRect.width + BalloonPanelView.arrowHorizontalOffset,
871
- name: 'arrow_ne'
872
- } ),
873
-
874
- // ------- South east
875
-
876
- southEastArrowNorthWest: ( targetRect, balloonRect ) => ( {
877
- top: getSouthTop( targetRect, balloonRect ),
878
- left: targetRect.right - BalloonPanelView.arrowHorizontalOffset,
879
- name: 'arrow_nw'
880
- } ),
881
-
882
- southEastArrowNorthMiddleWest: ( targetRect, balloonRect ) => ( {
883
- top: getSouthTop( targetRect, balloonRect ),
884
- left: targetRect.right - ( balloonRect.width * .25 ) - BalloonPanelView.arrowHorizontalOffset,
885
- name: 'arrow_nmw'
886
- } ),
887
-
888
- southEastArrowNorth: ( targetRect, balloonRect ) => ( {
889
- top: getSouthTop( targetRect, balloonRect ),
890
- left: targetRect.right - balloonRect.width / 2,
891
- name: 'arrow_n'
892
- } ),
893
-
894
- southEastArrowNorthMiddleEast: ( targetRect, balloonRect ) => ( {
895
- top: getSouthTop( targetRect, balloonRect ),
896
- left: targetRect.right - ( balloonRect.width * .75 ) + BalloonPanelView.arrowHorizontalOffset,
897
- name: 'arrow_nme'
898
- } ),
899
-
900
- southEastArrowNorthEast: ( targetRect, balloonRect ) => ( {
901
- top: getSouthTop( targetRect, balloonRect ),
902
- left: targetRect.right - balloonRect.width + BalloonPanelView.arrowHorizontalOffset,
903
- name: 'arrow_ne'
904
- } )
905
-
906
- };
907
-
908
- // Returns the top coordinate for positions starting with `north*`.
909
- //
910
- // @private
911
- // @param {utils/dom/rect~Rect} targetRect A rect of the target.
912
- // @param {utils/dom/rect~Rect} elementRect A rect of the balloon.
913
- // @returns {Number}
914
- function getNorthTop( targetRect, balloonRect ) {
915
- return targetRect.top - balloonRect.height - BalloonPanelView.arrowVerticalOffset;
916
- }
762
+ BalloonPanelView.defaultPositions = generatePositions();
917
763
 
918
- // Returns the top coordinate for positions starting with `south*`.
919
- //
920
- // @private
921
- // @param {utils/dom/rect~Rect} targetRect A rect of the target.
922
- // @param {utils/dom/rect~Rect} elementRect A rect of the balloon.
923
- // @returns {Number}
924
- function getSouthTop( targetRect ) {
925
- return targetRect.bottom + BalloonPanelView.arrowVerticalOffset;
764
+ /**
765
+ * Returns available {@link module:ui/panel/balloon/balloonpanelview~BalloonPanelView}
766
+ * {@link module:utils/dom/position~positioningFunction positioning functions} adjusted by the specific offsets.
767
+ *
768
+ * @protected
769
+ * @param {Object} [options] Options to generate positions. If not specified, this helper will simply return
770
+ * {@link module:ui/panel/balloon/balloonpanelview~BalloonPanelView.defaultPositions}.
771
+ * @param {Number} [options.horizontalOffset] A custom horizontal offset (in pixels) of each position. If
772
+ * not specified, {@link module:ui/panel/balloon/balloonpanelview~BalloonPanelView.arrowHorizontalOffset the default value}
773
+ * will be used.
774
+ * @param {Number} [options.verticalOffset] A custom vertical offset (in pixels) of each position. If
775
+ * not specified, {@link module:ui/panel/balloon/balloonpanelview~BalloonPanelView.arrowVerticalOffset the default value}
776
+ * will be used.
777
+ * @param {Number} [options.stickyVerticalOffset] A custom offset (in pixels) of the `viewportStickyNorth` positioning function.
778
+ * If not specified, {@link module:ui/panel/balloon/balloonpanelview~BalloonPanelView.stickyVerticalOffset the default value}
779
+ * will be used.
780
+ * @param {Object} [options.config] Additional configuration of the balloon balloon panel view.
781
+ * Currently only {@link module:ui/panel/balloon/balloonpanelview~BalloonPanelView#withArrow} is supported. Learn more
782
+ * about {@link module:utils/dom/position~positioningFunction positioning functions}.
783
+ * @returns {Object.<String,module:utils/dom/position~positioningFunction>}
784
+ */
785
+ export function generatePositions( {
786
+ horizontalOffset = BalloonPanelView.arrowHorizontalOffset,
787
+ verticalOffset = BalloonPanelView.arrowVerticalOffset,
788
+ stickyVerticalOffset = BalloonPanelView.stickyVerticalOffset,
789
+ config
790
+ } = {} ) {
791
+ return {
792
+ // ------- North west
793
+
794
+ northWestArrowSouthWest: ( targetRect, balloonRect ) => ( {
795
+ top: getNorthTop( targetRect, balloonRect ),
796
+ left: targetRect.left - horizontalOffset,
797
+ name: 'arrow_sw',
798
+ ...( config && { config } )
799
+ } ),
800
+
801
+ northWestArrowSouthMiddleWest: ( targetRect, balloonRect ) => ( {
802
+ top: getNorthTop( targetRect, balloonRect ),
803
+ left: targetRect.left - ( balloonRect.width * .25 ) - horizontalOffset,
804
+ name: 'arrow_smw',
805
+ ...( config && { config } )
806
+ } ),
807
+
808
+ northWestArrowSouth: ( targetRect, balloonRect ) => ( {
809
+ top: getNorthTop( targetRect, balloonRect ),
810
+ left: targetRect.left - balloonRect.width / 2,
811
+ name: 'arrow_s',
812
+ ...( config && { config } )
813
+ } ),
814
+
815
+ northWestArrowSouthMiddleEast: ( targetRect, balloonRect ) => ( {
816
+ top: getNorthTop( targetRect, balloonRect ),
817
+ left: targetRect.left - ( balloonRect.width * .75 ) + horizontalOffset,
818
+ name: 'arrow_sme',
819
+ ...( config && { config } )
820
+ } ),
821
+
822
+ northWestArrowSouthEast: ( targetRect, balloonRect ) => ( {
823
+ top: getNorthTop( targetRect, balloonRect ),
824
+ left: targetRect.left - balloonRect.width + horizontalOffset,
825
+ name: 'arrow_se',
826
+ ...( config && { config } )
827
+ } ),
828
+
829
+ // ------- North
830
+
831
+ northArrowSouthWest: ( targetRect, balloonRect ) => ( {
832
+ top: getNorthTop( targetRect, balloonRect ),
833
+ left: targetRect.left + targetRect.width / 2 - horizontalOffset,
834
+ name: 'arrow_sw',
835
+ ...( config && { config } )
836
+ } ),
837
+
838
+ northArrowSouthMiddleWest: ( targetRect, balloonRect ) => ( {
839
+ top: getNorthTop( targetRect, balloonRect ),
840
+ left: targetRect.left + targetRect.width / 2 - ( balloonRect.width * .25 ) - horizontalOffset,
841
+ name: 'arrow_smw',
842
+ ...( config && { config } )
843
+ } ),
844
+
845
+ northArrowSouth: ( targetRect, balloonRect ) => ( {
846
+ top: getNorthTop( targetRect, balloonRect ),
847
+ left: targetRect.left + targetRect.width / 2 - balloonRect.width / 2,
848
+ name: 'arrow_s',
849
+ ...( config && { config } )
850
+ } ),
851
+
852
+ northArrowSouthMiddleEast: ( targetRect, balloonRect ) => ( {
853
+ top: getNorthTop( targetRect, balloonRect ),
854
+ left: targetRect.left + targetRect.width / 2 - ( balloonRect.width * .75 ) + horizontalOffset,
855
+ name: 'arrow_sme',
856
+ ...( config && { config } )
857
+ } ),
858
+
859
+ northArrowSouthEast: ( targetRect, balloonRect ) => ( {
860
+ top: getNorthTop( targetRect, balloonRect ),
861
+ left: targetRect.left + targetRect.width / 2 - balloonRect.width + horizontalOffset,
862
+ name: 'arrow_se',
863
+ ...( config && { config } )
864
+ } ),
865
+
866
+ // ------- North east
867
+
868
+ northEastArrowSouthWest: ( targetRect, balloonRect ) => ( {
869
+ top: getNorthTop( targetRect, balloonRect ),
870
+ left: targetRect.right - horizontalOffset,
871
+ name: 'arrow_sw',
872
+ ...( config && { config } )
873
+ } ),
874
+
875
+ northEastArrowSouthMiddleWest: ( targetRect, balloonRect ) => ( {
876
+ top: getNorthTop( targetRect, balloonRect ),
877
+ left: targetRect.right - ( balloonRect.width * .25 ) - horizontalOffset,
878
+ name: 'arrow_smw',
879
+ ...( config && { config } )
880
+ } ),
881
+
882
+ northEastArrowSouth: ( targetRect, balloonRect ) => ( {
883
+ top: getNorthTop( targetRect, balloonRect ),
884
+ left: targetRect.right - balloonRect.width / 2,
885
+ name: 'arrow_s',
886
+ ...( config && { config } )
887
+ } ),
888
+
889
+ northEastArrowSouthMiddleEast: ( targetRect, balloonRect ) => ( {
890
+ top: getNorthTop( targetRect, balloonRect ),
891
+ left: targetRect.right - ( balloonRect.width * .75 ) + horizontalOffset,
892
+ name: 'arrow_sme',
893
+ ...( config && { config } )
894
+ } ),
895
+
896
+ northEastArrowSouthEast: ( targetRect, balloonRect ) => ( {
897
+ top: getNorthTop( targetRect, balloonRect ),
898
+ left: targetRect.right - balloonRect.width + horizontalOffset,
899
+ name: 'arrow_se',
900
+ ...( config && { config } )
901
+ } ),
902
+
903
+ // ------- South west
904
+
905
+ southWestArrowNorthWest: ( targetRect, balloonRect ) => ( {
906
+ top: getSouthTop( targetRect, balloonRect ),
907
+ left: targetRect.left - horizontalOffset,
908
+ name: 'arrow_nw',
909
+ ...( config && { config } )
910
+ } ),
911
+
912
+ southWestArrowNorthMiddleWest: ( targetRect, balloonRect ) => ( {
913
+ top: getSouthTop( targetRect, balloonRect ),
914
+ left: targetRect.left - ( balloonRect.width * .25 ) - horizontalOffset,
915
+ name: 'arrow_nmw',
916
+ ...( config && { config } )
917
+ } ),
918
+
919
+ southWestArrowNorth: ( targetRect, balloonRect ) => ( {
920
+ top: getSouthTop( targetRect, balloonRect ),
921
+ left: targetRect.left - balloonRect.width / 2,
922
+ name: 'arrow_n',
923
+ ...( config && { config } )
924
+ } ),
925
+
926
+ southWestArrowNorthMiddleEast: ( targetRect, balloonRect ) => ( {
927
+ top: getSouthTop( targetRect, balloonRect ),
928
+ left: targetRect.left - ( balloonRect.width * .75 ) + horizontalOffset,
929
+ name: 'arrow_nme',
930
+ ...( config && { config } )
931
+ } ),
932
+
933
+ southWestArrowNorthEast: ( targetRect, balloonRect ) => ( {
934
+ top: getSouthTop( targetRect, balloonRect ),
935
+ left: targetRect.left - balloonRect.width + horizontalOffset,
936
+ name: 'arrow_ne',
937
+ ...( config && { config } )
938
+ } ),
939
+
940
+ // ------- South
941
+
942
+ southArrowNorthWest: ( targetRect, balloonRect ) => ( {
943
+ top: getSouthTop( targetRect, balloonRect ),
944
+ left: targetRect.left + targetRect.width / 2 - horizontalOffset,
945
+ name: 'arrow_nw',
946
+ ...( config && { config } )
947
+ } ),
948
+
949
+ southArrowNorthMiddleWest: ( targetRect, balloonRect ) => ( {
950
+ top: getSouthTop( targetRect, balloonRect ),
951
+ left: targetRect.left + targetRect.width / 2 - ( balloonRect.width * 0.25 ) - horizontalOffset,
952
+ name: 'arrow_nmw',
953
+ ...( config && { config } )
954
+ } ),
955
+
956
+ southArrowNorth: ( targetRect, balloonRect ) => ( {
957
+ top: getSouthTop( targetRect, balloonRect ),
958
+ left: targetRect.left + targetRect.width / 2 - balloonRect.width / 2,
959
+ name: 'arrow_n',
960
+ ...( config && { config } )
961
+ } ),
962
+
963
+ southArrowNorthMiddleEast: ( targetRect, balloonRect ) => ( {
964
+ top: getSouthTop( targetRect, balloonRect ),
965
+ left: targetRect.left + targetRect.width / 2 - ( balloonRect.width * 0.75 ) + horizontalOffset,
966
+ name: 'arrow_nme',
967
+ ...( config && { config } )
968
+ } ),
969
+
970
+ southArrowNorthEast: ( targetRect, balloonRect ) => ( {
971
+ top: getSouthTop( targetRect, balloonRect ),
972
+ left: targetRect.left + targetRect.width / 2 - balloonRect.width + horizontalOffset,
973
+ name: 'arrow_ne',
974
+ ...( config && { config } )
975
+ } ),
976
+
977
+ // ------- South east
978
+
979
+ southEastArrowNorthWest: ( targetRect, balloonRect ) => ( {
980
+ top: getSouthTop( targetRect, balloonRect ),
981
+ left: targetRect.right - horizontalOffset,
982
+ name: 'arrow_nw',
983
+ ...( config && { config } )
984
+ } ),
985
+
986
+ southEastArrowNorthMiddleWest: ( targetRect, balloonRect ) => ( {
987
+ top: getSouthTop( targetRect, balloonRect ),
988
+ left: targetRect.right - ( balloonRect.width * .25 ) - horizontalOffset,
989
+ name: 'arrow_nmw',
990
+ ...( config && { config } )
991
+ } ),
992
+
993
+ southEastArrowNorth: ( targetRect, balloonRect ) => ( {
994
+ top: getSouthTop( targetRect, balloonRect ),
995
+ left: targetRect.right - balloonRect.width / 2,
996
+ name: 'arrow_n',
997
+ ...( config && { config } )
998
+ } ),
999
+
1000
+ southEastArrowNorthMiddleEast: ( targetRect, balloonRect ) => ( {
1001
+ top: getSouthTop( targetRect, balloonRect ),
1002
+ left: targetRect.right - ( balloonRect.width * .75 ) + horizontalOffset,
1003
+ name: 'arrow_nme',
1004
+ ...( config && { config } )
1005
+ } ),
1006
+
1007
+ southEastArrowNorthEast: ( targetRect, balloonRect ) => ( {
1008
+ top: getSouthTop( targetRect, balloonRect ),
1009
+ left: targetRect.right - balloonRect.width + horizontalOffset,
1010
+ name: 'arrow_ne',
1011
+ ...( config && { config } )
1012
+ } ),
1013
+
1014
+ // ------- Sticky
1015
+
1016
+ viewportStickyNorth: ( targetRect, balloonRect, viewportRect ) => {
1017
+ if ( !targetRect.getIntersection( viewportRect ) ) {
1018
+ return null;
1019
+ }
1020
+
1021
+ return {
1022
+ top: viewportRect.top + stickyVerticalOffset,
1023
+ left: targetRect.left + targetRect.width / 2 - balloonRect.width / 2,
1024
+ name: 'arrowless',
1025
+ config: {
1026
+ withArrow: false,
1027
+ ...config
1028
+ }
1029
+ };
1030
+ }
1031
+ };
1032
+
1033
+ // Returns the top coordinate for positions starting with `north*`.
1034
+ //
1035
+ // @private
1036
+ // @param {utils/dom/rect~Rect} targetRect A rect of the target.
1037
+ // @param {utils/dom/rect~Rect} elementRect A rect of the balloon.
1038
+ // @returns {Number}
1039
+ function getNorthTop( targetRect, balloonRect ) {
1040
+ return targetRect.top - balloonRect.height - verticalOffset;
1041
+ }
1042
+
1043
+ // Returns the top coordinate for positions starting with `south*`.
1044
+ //
1045
+ // @private
1046
+ // @param {utils/dom/rect~Rect} targetRect A rect of the target.
1047
+ // @param {utils/dom/rect~Rect} elementRect A rect of the balloon.
1048
+ // @returns {Number}
1049
+ function getSouthTop( targetRect ) {
1050
+ return targetRect.bottom + verticalOffset;
1051
+ }
926
1052
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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
5
 
@@ -7,7 +7,7 @@
7
7
  * @module ui/panel/balloon/contextualballoon
8
8
  */
9
9
 
10
- import { Plugin } from 'ckeditor5/src/core';
10
+ import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
11
11
  import BalloonPanelView from './balloonpanelview';
12
12
  import View from '../../view';
13
13
  import ButtonView from '../../button/buttonview';
@@ -170,6 +170,17 @@ export default class ContextualBalloon extends Plugin {
170
170
  this._fakePanelsView = this._createFakePanelsView();
171
171
  }
172
172
 
173
+ /**
174
+ * @inheritDoc
175
+ */
176
+ destroy() {
177
+ super.destroy();
178
+
179
+ this.view.destroy();
180
+ this._rotatorView.destroy();
181
+ this._fakePanelsView.destroy();
182
+ }
183
+
173
184
  /**
174
185
  * Returns `true` when the given view is in one of the stacks. Otherwise returns `false`.
175
186
  *
@@ -498,11 +509,18 @@ export default class ContextualBalloon extends Plugin {
498
509
  _getBalloonPosition() {
499
510
  let position = Array.from( this._visibleStack.values() ).pop().position;
500
511
 
501
- // Use the default limiter if none has been specified.
502
- if ( position && !position.limiter ) {
512
+ if ( position ) {
513
+ // Use the default limiter if none has been specified.
514
+ if ( !position.limiter ) {
515
+ // Don't modify the original options object.
516
+ position = Object.assign( {}, position, {
517
+ limiter: this.positionLimiter
518
+ } );
519
+ }
520
+
503
521
  // Don't modify the original options object.
504
522
  position = Object.assign( {}, position, {
505
- limiter: this.positionLimiter
523
+ viewportOffsetConfig: this.editor.ui.viewportOffset
506
524
  } );
507
525
  }
508
526
 
@@ -621,6 +639,15 @@ class RotatorView extends View {
621
639
  this.focusTracker.add( this.element );
622
640
  }
623
641
 
642
+ /**
643
+ * @inheritDoc
644
+ */
645
+ destroy() {
646
+ super.destroy();
647
+
648
+ this.focusTracker.destroy();
649
+ }
650
+
624
651
  /**
625
652
  * Shows a given view.
626
653
  *