Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolbar works barely after dynamicly creating quill editors #3176

Closed
HiImBenny opened this issue Sep 18, 2020 · 1 comment
Closed

Toolbar works barely after dynamicly creating quill editors #3176

HiImBenny opened this issue Sep 18, 2020 · 1 comment

Comments

@HiImBenny
Copy link

HiImBenny commented Sep 18, 2020

I wrote a javascript code for dynamicly creating quill editors. First the toolbar buttons were not working at all. So i copied the "ql-toolbar"-div from a single created editor and build the html code before creating an editor. Now most buttons are working except for color, font, background color and link. Can anybody help me to get the buttons to work? And sorry for my bad english.

Here is my js code:
var toolbarhtml = //Here is the html code of the ql-toolbar div
function CreateBoxes(Amount, Editable, BoolToolbar) {
var box = document.getElementById("controlAddIn");
box.innerHTML += "<div id="wrapper">";
var wrapper = document.getElementById("wrapper");
for (var i = 0; i < Amount; i++) {
var editor = "editor" + (i + 1);
var header = "heading" + (i + 1);
wrapper.innerHTML += "<div class="wrapped" id="div" + (i + 1) + ""><h2 class="navHeader2" id="" + header + "">";
var div = document.getElementById("div" + (i + 1));
var preScript = "<div class="editors" id="" + editor + "">";
var postScript = ""
var fullScript = preScript + "" + postScript;
if(BoolToolbar){
div.innerHTML += toolbarhtml;
}
div.innerHTML += fullScript;
wrapper.innerHTML += "";
}
box.innerHTML += "";
var divs = document.getElementsByClassName("editors");
if(BoolToolbar){
var toolbars = document.getElementsByClassName("ql-toolbar");
var custombuttons = document.getElementsByClassName("customspan");
}

for(var j = 0; j < divs.length; j++){
    var quill;
    if(BoolToolbar){
        //custombuttons[j].innerHTML += "<button class=\"custombutton\" onclick=\"text(" + (j + 1) + ")\">T</button>";
        //ignore the line above, thats just for my custom button, which is working fine
        quill = new Quill(divs[j], {
            modules: {
                toolbar: toolbars[j]
            },
            theme: 'snow'
        });

	} else {
        quill = new Quill(divs[j], {
            modules: {
            },
            theme: 'bubble'
        });
	}
    

    if(!Editable){
        quill.disable();
	}
}

}

P.S.: If you need the html code from the var toolbar, tell me. But be warned, its very very long and confusing.

@HiImBenny HiImBenny reopened this Sep 18, 2020
@benbro
Copy link
Contributor

benbro commented Feb 1, 2024

@benbro benbro closed this as completed Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants