Skip to content

Commit f6b1f85

Browse files
authored
IBX-9154: The dropdown for custom class is illegible (#193)
1 parent 27e36a9 commit f6b1f85

File tree

9 files changed

+68
-16
lines changed

9 files changed

+68
-16
lines changed

src/bundle/Resources/public/js/CKEditor/custom-attributes/custom-attributes-ui.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import clickOutsideHandler from '@ckeditor/ckeditor5-ui/src/bindings/clickoutsid
33

44
import IbexaCustomAttributesFormView from './ui/custom-attributes-form-view';
55
import IbexaButtonView from '../common/button-view/button-view';
6+
import { setPanelContentMaxHeight } from '../helpers/custom-panel-helper';
67

78
import { getCustomAttributesElementConfig, getCustomClassesElementConfig } from './helpers/config-helper';
89

@@ -16,6 +17,15 @@ class IbexaAttributesUI extends Plugin {
1617
this.formView = this.createFormView();
1718

1819
this.showForm = this.showForm.bind(this);
20+
21+
let timeoutId = null;
22+
23+
this.listenTo(this.balloon.view, 'change:top', () => {
24+
clearTimeout(timeoutId);
25+
timeoutId = setTimeout(() => {
26+
setPanelContentMaxHeight(this.balloon.view);
27+
}, 0);
28+
});
1929
}
2030

2131
getModelElement() {

src/bundle/Resources/public/js/CKEditor/custom-attributes/ui/custom-attributes-form-view.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ class IbexaCustomAttributesFormView extends View {
4444
this.setTemplate({
4545
tag: 'div',
4646
attributes: {
47-
class: 'ibexa-ckeditor-balloon-form',
47+
class: 'ibexa-ckeditor-balloon-form ibexa-custom-panel',
4848
},
4949
children: [
5050
{
5151
tag: 'div',
5252
attributes: {
53-
class: 'ibexa-ckeditor-balloon-form__header',
53+
class: 'ibexa-ckeditor-balloon-form__header ibexa-custom-panel__header',
5454
},
5555
children: ['Custom Attributes'],
5656
},
@@ -63,14 +63,14 @@ class IbexaCustomAttributesFormView extends View {
6363
{
6464
tag: 'div',
6565
attributes: {
66-
class: 'ibexa-ckeditor-balloon-form__fields',
66+
class: 'ibexa-ckeditor-balloon-form__fields ibexa-custom-panel__content ibexa-custom-panel__content--overflow-with-scroll',
6767
},
6868
children: this.children,
6969
},
7070
{
7171
tag: 'div',
7272
attributes: {
73-
class: 'ibexa-ckeditor-balloon-form__actions',
73+
class: 'ibexa-ckeditor-balloon-form__actions ibexa-custom-panel__footer',
7474
},
7575
children: [this.saveButtonView, this.revertButtonView, this.cancelButtonView],
7676
},

src/bundle/Resources/public/js/CKEditor/custom-tags/block-custom-tag/custom-tag-ui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
22
import clickOutsideHandler from '@ckeditor/ckeditor5-ui/src/bindings/clickoutsidehandler';
33
import ClickObserver from '@ckeditor/ckeditor5-engine/src/view/observer/clickobserver';
44

5-
import { setPanelContentMaxHeight } from '../helpers/panel-helper';
5+
import { setPanelContentMaxHeight } from '../../helpers/custom-panel-helper';
66
import IbexaCustomTagFormView from '../ui/custom-tag-form-view';
77
import IbexaCustomTagAttributesView from '../ui/custom-tag-attributes-view';
88
import IbexaButtonView from '../../common/button-view/button-view';

src/bundle/Resources/public/js/CKEditor/custom-tags/ui/custom-tag-attributes-view.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class IbexaCustomTagAttributesView extends View {
3838
{
3939
tag: 'div',
4040
attributes: {
41-
class: 'ibexa-custom-tag-attributes__header ibexa-custom-tag-panel-header',
41+
class: 'ibexa-custom-tag-attributes__header ibexa-custom-panel__header',
4242
},
4343
children: [
4444
{
@@ -91,7 +91,7 @@ class IbexaCustomTagAttributesView extends View {
9191
children.push({
9292
tag: 'div',
9393
attributes: {
94-
class: 'ibexa-custom-tag-attributes__items ibexa-custom-tag-panel-content',
94+
class: 'ibexa-custom-tag-attributes__items ibexa-custom-panel__content',
9595
},
9696
children: items,
9797
});

src/bundle/Resources/public/js/CKEditor/custom-tags/ui/custom-tag-form-view.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ class IbexaCustomTagFormView extends View {
115115
this.setTemplate({
116116
tag: 'div',
117117
attributes: {
118-
class: 'ibexa-ckeditor-balloon-form',
118+
class: 'ibexa-ckeditor-balloon-form ibexa-custom-panel',
119119
},
120120
children: [
121121
{
122122
tag: 'div',
123123
attributes: {
124-
class: 'ibexa-ckeditor-balloon-form__header ibexa-custom-tag-panel-header',
124+
class: 'ibexa-ckeditor-balloon-form__header ibexa-custom-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 ibexa-custom-tag-panel-content',
137+
class: 'ibexa-ckeditor-balloon-form__fields ibexa-custom-panel__content ibexa-custom-panel__content--overflow-with-scroll',
138138
},
139139
children: this.children,
140140
},
141141
{
142142
tag: 'div',
143143
attributes: {
144-
class: 'ibexa-ckeditor-balloon-form__actions ibexa-custom-tag-panel-footer',
144+
class: 'ibexa-ckeditor-balloon-form__actions ibexa-custom-panel__footer',
145145
},
146146
children: [this.saveButtonView, this.cancelButtonView],
147147
},

src/bundle/Resources/public/js/CKEditor/custom-tags/helpers/panel-helper.js renamed to src/bundle/Resources/public/js/CKEditor/helpers/custom-panel-helper.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
const setPanelContentMaxHeight = (balloonView) => {
22
const MIN_HEIGHT_VALUE = 100;
33
const MARGIN = 50;
4+
const BOTTOM_ARROW_CLASSES = ['ck-balloon-panel_arrow_s', 'ck-balloon-panel_arrow_se', 'ck-balloon-panel_arrow_sw'];
45
const { innerHeight: windowHeight } = window;
56
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');
7+
const panelHeader = panelNode.querySelector('.ibexa-custom-panel__header');
8+
const panelContent = panelNode.querySelector('.ibexa-custom-panel__content');
9+
const panelFooter = panelNode.querySelector('.ibexa-custom-panel__footer');
910

1011
if (!panelContent) {
1112
return;
1213
}
1314

14-
const isBalloonAbovePivot = panelNode.classList.contains('ck-balloon-panel_arrow_s');
15+
const isBalloonAbovePivot = [...panelNode.classList].some((className) => BOTTOM_ARROW_CLASSES.includes(className));
1516
const panelInitialHeight = panelNode.offsetHeight;
1617
const panelTopPosition = parseInt(panelNode.style.top, 10);
1718
const panelHeaderHeight = panelHeader?.offsetHeight ?? 0;

src/bundle/Resources/public/scss/_balloon-form.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
}
1111

1212
&__fields {
13-
overflow: auto;
1413
padding: calculateRem(8px) calculateRem(16px);
1514

1615
&--attributes {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.ibexa-custom-panel {
2+
min-width: calculateRem(320px);
3+
4+
&__content {
5+
&--overflow-with-scroll {
6+
overflow: auto;
7+
8+
&.ibexa-ckeditor-balloon-form__fields {
9+
.ck.ck-labeled-field-view {
10+
.ck.ck-input {
11+
width: 100%;
12+
}
13+
14+
.ck.ck-dropdown {
15+
width: 100%;
16+
17+
.ck.ck-button {
18+
display: block;
19+
20+
.ck.ck-button__label {
21+
width: calc(100% - calculateRem(20px));
22+
height: fit-content;
23+
white-space: normal;
24+
overflow: hidden;
25+
}
26+
}
27+
}
28+
29+
.ck-dropdown__panel-visible {
30+
position: static;
31+
bottom: 0;
32+
height: fit-content;
33+
max-height: 100%;
34+
border: none;
35+
box-shadow: none;
36+
}
37+
}
38+
}
39+
}
40+
}
41+
}

src/bundle/Resources/public/scss/ckeditor.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
@import 'general';
66
@import 'custom-tag';
77
@import 'custom-tag-attributes';
8+
@import 'custom-panel';
89
@import 'elements-path';
910
@import 'tools';
1011
@import 'character-counter';

0 commit comments

Comments
 (0)