Open u12206050 opened 8 years ago
I found a another solution. But don't know whether it will be a efficient one.
So basically I am wrapping all the quill editors. Then I applied CSS property position:absolute
to all the toolbar. Then through JavaScript I am getting the focused editor and making the corresponding toolbar visible and hiding all the remaining toolbar.
.editor-container{
position: relative;
padding-top: 50px;
}
.editor-container .ql-toolbar{
position: absolute;
top: 0;
left: 0;
width: 100%;
background: #fff;
}
.ql-container{
border: 1px solid #000!important;
margin-bottom: 1rem;
}
.d-none{
display: none;
}
<div class="editor-container">
<div id="editor" class="editor"></div>
<div id="editor1" class="editor"></div>
</div>
let quill = new Quill("#editor", {
theme: "snow",
});
let quill1 = new Quill("#editor1", {
theme: "snow",
});
document.querySelectorAll(".editor .ql-editor").forEach((item)=>{
item.addEventListener("click",(e)=>{
// Getting the focused editor
let selectedEditor = e.currentTarget.parentElement;
let selectedEditorToolbar = selectedEditor.previousElementSibling;
// Making the toolbar visible if already hidden.
selectedEditorToolbar.classList.remove("d-none");
// Hiding Toolbar of all non focused editor.
document.querySelectorAll(".ql-toolbar").forEach((toolbar)=>{
if(!toolbar.isEqualNode(selectedEditorToolbar)){
toolbar.classList.add("d-none");
}
})
})
})
Woah, this is open for a long time now.
Can somebody pin the official solution to this?
Don't think such a solution exists.
I found a another solution. But don't know whether it will be a efficient one. ...
It's a nice solution, but you're using two toolbars instead of one for both editable areas. But if they're in the same container, it would still appear as one. Though it would be a hassle doing it this way with an unknown amount of editable areas that are all placed at diffent places.
I have achieve the functionality with angular.
i have created a quill module about this issue, maybe it helps; https://github.com/TonyYu2015/quill-free-container
`<!DOCTYPE html>
Hello World!
Some initial bold text
Some lorem ipsum text
Hello World! 2
Some initial bold text
Some lorem ipsum text
Hello World! 3
Some initial bold text
Some lorem ipsum text
Hello World! 4
Some initial bold text
Some lorem ipsum text
` dynamically created toolbar and hide the other toolbar and visible active tollbar
it's working fine for my code example is here
https://codesandbox.io/embed/blazing-river-8s9vsl?fontsize=14&hidenavigation=1&theme=dark
When having more than one editor on a page, each one currently seems to require their own toolbar. If I try to assign a previously assigned toolbar then the events don't work for the second editor.
Steps for Reproduction
Expected behavior: Would be easy enough to simply keep track of which editor was last active and apply and changes to that editor eg. Changing font size etc.
Actual behavior: The tool bar seems broken as soon as the second editor is attached to it. Only the second editor is actually usable, because when trying to type in the first one, the cursor jumps to the second one.