File tree Expand file tree Collapse file tree 6 files changed +67
-9
lines changed
src/bundle/Resources/public Expand file tree Collapse file tree 6 files changed +67
-9
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
22import clickOutsideHandler from '@ckeditor/ckeditor5-ui/src/bindings/clickoutsidehandler' ;
33import ClickObserver from '@ckeditor/ckeditor5-engine/src/view/observer/clickobserver' ;
44
5+ import { setPanelContentMaxHeight } from '../helpers/panel-helper' ;
56import IbexaCustomTagFormView from '../ui/custom-tag-form-view' ;
67import IbexaCustomTagAttributesView from '../ui/custom-tag-attributes-view' ;
78import IbexaButtonView from '../../common/button-view/button-view' ;
@@ -18,6 +19,14 @@ class IbexaCustomTagUI extends Plugin {
1819 this . addCustomTag = this . addCustomTag . bind ( this ) ;
1920
2021 this . isNew = false ;
22+
23+ let timeoutId = null ;
24+ this . listenTo ( this . balloon . view , 'change:top' , ( ) => {
25+ clearTimeout ( timeoutId ) ;
26+ timeoutId = setTimeout ( ( ) => {
27+ setPanelContentMaxHeight ( this . balloon . view ) ;
28+ } , 0 ) ;
29+ } ) ;
2130 }
2231
2332 isCustomTagSelected ( eventData ) {
Original file line number Diff line number Diff line change 1+ const setPanelContentMaxHeight = ( balloonView ) => {
2+ const MIN_HEIGHT_VALUE = 100 ;
3+ const MARGIN = 50 ;
4+ const { innerHeight : windowHeight } = window ;
5+ const { element : panelNode } = balloonView ;
6+ const panelHeader = panelNode . querySelector ( '.ibexa-custom-tag-panel-header' ) ;
7+ const panelContent = panelNode . querySelector ( '.ibexa-custom-tag-panel-content' ) ;
8+ const panelFooter = panelNode . querySelector ( '.ibexa-custom-tag-panel-footer' ) ;
9+
10+ if ( ! panelContent ) {
11+ return ;
12+ }
13+
14+ const isBalloonAbovePivot = panelNode . classList . contains ( 'ck-balloon-panel_arrow_s' ) ;
15+ const panelInitialHeight = panelNode . offsetHeight ;
16+ const panelTopPosition = parseInt ( panelNode . style . top , 10 ) ;
17+ const panelHeaderHeight = panelHeader ?. offsetHeight ?? 0 ;
18+ const panelFooterHeight = panelFooter ?. offsetHeight ?? 0 ;
19+ const maxHeightValue = isBalloonAbovePivot
20+ ? panelInitialHeight + panelTopPosition - panelHeaderHeight - panelFooterHeight - MARGIN
21+ : windowHeight - panelTopPosition - panelHeaderHeight - panelFooterHeight - MARGIN ;
22+ const panelMaxHeight = maxHeightValue < MIN_HEIGHT_VALUE ? MIN_HEIGHT_VALUE : maxHeightValue ;
23+
24+ panelContent . style . maxHeight = `${ panelMaxHeight } px` ;
25+
26+ if ( isBalloonAbovePivot ) {
27+ const panelNewHeight = panelNode . offsetHeight ;
28+ const panelHeightChange = panelInitialHeight - panelNewHeight ;
29+ const panelNewTopPosition = panelTopPosition + panelHeightChange ;
30+
31+ panelNode . style . top = `${ panelNewTopPosition } px` ;
32+ }
33+ } ;
34+
35+ export { setPanelContentMaxHeight } ;
Original file line number Diff line number Diff line change @@ -33,11 +33,12 @@ class IbexaCustomTagAttributesView extends View {
3333
3434 buttonView . delegate ( 'execute' ) . to ( this , 'edit-attributes' ) ;
3535
36+ const items = [ ] ;
3637 const children = [
3738 {
3839 tag : 'div' ,
3940 attributes : {
40- class : 'ibexa-custom-tag-attributes__header' ,
41+ class : 'ibexa-custom-tag-attributes__header ibexa-custom-tag-panel-header ' ,
4142 } ,
4243 children : [
4344 {
@@ -63,7 +64,7 @@ class IbexaCustomTagAttributesView extends View {
6364 const getValueLabelMethods = window . ibexa . richText . CKEditor . customTags ?. getValueLabelMethods || { } ;
6465 const valueLabel = getValueLabelMethods [ name ] && value !== '-' ? getValueLabelMethods [ name ] ( value , config ) : value ;
6566
66- children . push ( {
67+ items . push ( {
6768 tag : 'div' ,
6869 attributes : {
6970 class : 'ibexa-custom-tag-attributes__item' ,
@@ -87,6 +88,14 @@ class IbexaCustomTagAttributesView extends View {
8788 } ) ;
8889 } ) ;
8990
91+ children . push ( {
92+ tag : 'div' ,
93+ attributes : {
94+ class : 'ibexa-custom-tag-attributes__items ibexa-custom-tag-panel-content' ,
95+ } ,
96+ children : items ,
97+ } ) ;
98+
9099 return children ;
91100 }
92101}
Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ class IbexaCustomTagFormView extends View {
121121 {
122122 tag : 'div' ,
123123 attributes : {
124- class : 'ibexa-ckeditor-balloon-form__header' ,
124+ class : 'ibexa-ckeditor-balloon-form__header ibexa-custom-tag-panel-header ' ,
125125 } ,
126126 children : [ label ] ,
127127 } ,
@@ -134,14 +134,14 @@ class IbexaCustomTagFormView extends View {
134134 {
135135 tag : 'div' ,
136136 attributes : {
137- class : 'ibexa-ckeditor-balloon-form__fields' ,
137+ class : 'ibexa-ckeditor-balloon-form__fields ibexa-custom-tag-panel-content ' ,
138138 } ,
139139 children : this . children ,
140140 } ,
141141 {
142142 tag : 'div' ,
143143 attributes : {
144- class : 'ibexa-ckeditor-balloon-form__actions' ,
144+ class : 'ibexa-ckeditor-balloon-form__actions ibexa-custom-tag-panel-footer ' ,
145145 } ,
146146 children : [ this . saveButtonView , this . cancelButtonView ] ,
147147 } ,
Original file line number Diff line number Diff line change 11.ck.ck-reset_all {
22 .ibexa-ckeditor-balloon-form {
3- padding : 0 calculateRem ( 16 px ) ;
3+ position : relative ;
44
55 & __header {
66 border-top-left-radius : $ibexa-border-radius ;
77 border-top-right-radius : $ibexa-border-radius ;
8- padding : calculateRem (2px ) 0 ;
8+ padding : calculateRem (2px ) calculateRem ( 16 px ) ;
99 font-weight : bold ;
1010 }
1111
1212 & __fields {
13- padding : calculateRem (8px ) 0 ;
13+ overflow : auto ;
14+ padding : calculateRem (8px ) calculateRem (16px );
1415
1516 & --attributes {
1617 border-bottom : calculateRem (1px ) solid $ibexa-color-light ;
135136 }
136137
137138 & __actions {
138- padding : 0 0 calculateRem (16px );
139+ padding : calculateRem ( 8 px ) calculateRem (16px );
139140 }
140141 }
141142
Original file line number Diff line number Diff line change 1717 font-weight : bold ;
1818 }
1919
20+ & __items {
21+ overflow : auto ;
22+ }
23+
2024 & __item {
2125 padding : calculateRem (8px ) calculateRem (16px );
2226 }
You can’t perform that action at this time.
0 commit comments