Skip to content

Commit

Permalink
After CR
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasOsti committed Sep 12, 2024
1 parent 214f84d commit ac3260e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import clickOutsideHandler from '@ckeditor/ckeditor5-ui/src/bindings/clickoutsidehandler';
import ClickObserver from '@ckeditor/ckeditor5-engine/src/view/observer/clickobserver';

import { setPanelContentMaxHeight } from '../helpers/panel-helper';
import IbexaCustomTagFormView from '../ui/custom-tag-form-view';
import IbexaCustomTagAttributesView from '../ui/custom-tag-attributes-view';
import IbexaButtonView from '../../common/button-view/button-view';
Expand Down Expand Up @@ -150,7 +151,7 @@ class IbexaCustomTagUI extends Plugin {
position: { target },
});

this.setPanelContentMaxHeight();
setPanelContentMaxHeight(this.balloon.view);
this.balloon.updatePosition({ target });
}

Expand Down Expand Up @@ -184,7 +185,7 @@ class IbexaCustomTagUI extends Plugin {
position: this.getBalloonPositionData(),
});

this.setPanelContentMaxHeight();
setPanelContentMaxHeight(this.balloon.view);
this.balloon.updatePosition(this.getBalloonPositionData());
}

Expand Down Expand Up @@ -219,22 +220,6 @@ class IbexaCustomTagUI extends Plugin {
return { target: view.domConverter.viewRangeToDom(range) };
}

setPanelContentMaxHeight() {
const { innerHeight: windowHeight } = window;
const { top: panelTopPosition, element: panelNode } = this.balloon.view;
const panelHeader = panelNode.querySelector('.ibexa-custom-tag-panel-header');
const panelContent = panelNode.querySelector('.ibexa-custom-tag-panel-content');
const panelFooter = panelNode.querySelector('.ibexa-custom-tag-panel-footer');
const panelHeaderHeight = panelHeader?.offsetHeight ?? 0;
const panelFooterHeight = panelFooter?.offsetHeight ?? 0;
const isPanelOverTopWindowEdge = panelTopPosition < 0;
const maxHeightValue = isPanelOverTopWindowEdge
? panelContent.offsetHeight - Math.abs(panelTopPosition)
: windowHeight - panelTopPosition - panelHeaderHeight - panelFooterHeight;

panelContent.style.maxHeight = `${maxHeightValue}px`;
}

addCustomTag() {
const values = Object.entries(this.config.attributes).reduce((outputValues, [attributeName, config]) => {
outputValues[attributeName] = config.defaultValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const setPanelContentMaxHeight = (balloonView) => {
const { innerHeight: windowHeight } = window;
const { top: panelTopPosition, element: panelNode } = balloonView;
const panelHeader = panelNode.querySelector('.ibexa-custom-tag-panel-header');
const panelContent = panelNode.querySelector('.ibexa-custom-tag-panel-content');
const panelFooter = panelNode.querySelector('.ibexa-custom-tag-panel-footer');
const panelHeaderHeight = panelHeader?.offsetHeight ?? 0;
const panelFooterHeight = panelFooter?.offsetHeight ?? 0;
const isPanelOverTopWindowEdge = panelTopPosition < 0;
const maxHeightValue = isPanelOverTopWindowEdge
? panelContent.offsetHeight - Math.abs(panelTopPosition)
: windowHeight - panelTopPosition - panelHeaderHeight - panelFooterHeight;

panelContent.style.maxHeight = `${maxHeightValue}px`;
};

export { setPanelContentMaxHeight };
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import clickOutsideHandler from '@ckeditor/ckeditor5-ui/src/bindings/clickoutsidehandler';
import ClickObserver from '@ckeditor/ckeditor5-engine/src/view/observer/clickobserver';

import { setPanelContentMaxHeight } from '../helpers/panel-helper';
import IbexaCustomTagFormView from '../ui/custom-tag-form-view';
import IbexaButtonView from '../../common/button-view/button-view';

Expand Down Expand Up @@ -90,7 +91,7 @@ class IbexaInlineCustomTagUI extends Plugin {
position: this.getBalloonPositionData(),
});

this.setPanelContentMaxHeight();
setPanelContentMaxHeight(this.balloon.view);
this.balloon.updatePosition(this.getBalloonPositionData());
}

Expand All @@ -116,22 +117,6 @@ class IbexaInlineCustomTagUI extends Plugin {
return { target: view.domConverter.viewRangeToDom(range) };
}

setPanelContentMaxHeight() {
const { innerHeight: windowHeight } = window;
const { top: panelTopPosition, element: panelNode } = this.balloon.view;
const panelHeader = panelNode.querySelector('.ibexa-custom-tag-panel-header');
const panelContent = panelNode.querySelector('.ibexa-custom-tag-panel-content');
const panelFooter = panelNode.querySelector('.ibexa-custom-tag-panel-footer');
const panelHeaderHeight = panelHeader?.offsetHeight ?? 0;
const panelFooterHeight = panelFooter?.offsetHeight ?? 0;
const isPanelOverTopWindowEdge = panelTopPosition < 0;
const maxHeightValue = isPanelOverTopWindowEdge
? panelContent.offsetHeight - Math.abs(panelTopPosition)
: windowHeight - panelTopPosition - panelHeaderHeight - panelFooterHeight;

panelContent.style.maxHeight = `${maxHeightValue}px`;
}

addInlineCustomTag() {
const values = Object.entries(this.config.attributes).reduce((outputValues, [attributeName, config]) => {
outputValues[attributeName] = config.defaultValue;
Expand Down

0 comments on commit ac3260e

Please sign in to comment.