Reputation: 71
When I try to add link to very left text in quill editor the popUp opened is hiding in the left side.And I am using Snow theme.
The below image shows my issue.
Upvotes: 2
Views: 2535
Reputation: 1
**The link tooltip cut off by edge of the React quill editor Conditionally handle: If the link is -negative on the left than replace it with 10px else default position. **
useEffect(() => {
const adjustTooltipPosition = () => {
const tooltip = document.querySelector('.ql-tooltip');
if (tooltip) {
const left = parseFloat(tooltip.style.left) || 0;
if (left < 0) {
tooltip.style.left = '10px';
}
}
};
const observer = new MutationObserver(adjustTooltipPosition);
const editorContainer = document.querySelector('.ql-container');
if (editorContainer) {
observer.observe(editorContainer, {
childList: true,
subtree: true,
attributes: true,
});
}
return () => {
observer.disconnect();
};
}, []);
Upvotes: 0
Reputation: 11
From the official documentation Quill is bound to document.body, you need to modify it:
<div id="quillContainer">
<ReactQuill
theme="snow"
bounds={'#quillContainer'}
/>
</div>
Upvotes: 1
Reputation: 835
i had the same problem.
this github issue comment recommending the bounds config property worked for me: https://github.com/slab/quill/issues/360#issuecomment-584789063
const SELECTOR_CONTAINER = '#quill-container-2';
const DEFAULT_CONFIG = {
theme: 'bubble',
bounds: SELECTOR_CONTAINER
};
new Quill(SELECTOR_CONTAINER, DEFAULT_CONFIG);
Upvotes: 0
Reputation: 63
If someone encounter this, by default Quill is bound to document.body
.
On the instance you can use the bounds
property to define your own container where Quill (tooltip, etc...) will be contained: Quill documentation
Upvotes: 2
Reputation: 41
Not the most elegant solution, but you may need to override the css:
.ql-tooltip {
left: 0!important;
}
Sometimes quilljs doesn't play nice with theming libraries like certain versions of bootstrap (which was the issue in my case).
Upvotes: 2