var ec = $(`#${element.name}`);
ec.css({"height": "300px"});
if (typeof Quill === "undefined") {
$.getScript("https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.js", function() {
// Add the CSS dynamically
let link = document.createElement('link');
link.rel = 'stylesheet';
link.href = 'https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.snow.css';
document.head.appendChild(link);
// Wait for the stylesheet to load
link.onload = function() {
// Initialize Quill editor
var el = $(`#${element.name}`).get(0);
if (!el) {
console.error("Element not found:", `#${element.name}`);
return;
}
// Ensure the element is contenteditable
el.setAttribute('contenteditable', 'true');
// Create the Quill editor instance with the toolbar
let quill = new Quill(el, {
theme: 'snow',
modules: {
toolbar: [
[{ 'header': '1' }, { 'header': '2' }, { 'font': [] }],
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
['bold', 'italic', 'underline', 'strike'],
['link', 'image'],
[{ 'align': [] }],
['blockquote', 'code-block'],
['clean'] // This is the button to clear formatting
]
}
});
quill.on('text-change', function() {
console.log('Content changed');
});
};
});
}
< /code>
Результат заключается в том, что я вижу редактор Quill, и я могу ввести в Quill.
кнопки видны. < /p>
Проблема в том, что если я нажимаю на жирную или курсивную кнопку, нет никакого эффекта. То есть я выбираю текст и нажимаю на «жирный жирник». На этом этапе линейная console.log ('Content изменен');
активен, и я вижу выход на консоли. Но текст не меняется. < /P>
Я искал, это так и нашел это. Это говорит, что мне нужно инициализировать Quill. Поэтому я продолжал искать и нашел это. Но все еще ничего не происходит. < /P>
Пожалуйста, помогите. Спасибо.
if (typeof Quill === "undefined") { $.getScript("https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.js", function() { // Add the CSS dynamically let link = document.createElement('link'); link.rel = 'stylesheet'; link.href = 'https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.snow.css'; document.head.appendChild(link);
// Wait for the stylesheet to load link.onload = function() { // Initialize Quill editor var el = $(`#${element.name}`).get(0); if (!el) { console.error("Element not found:", `#${element.name}`); return; }
// Ensure the element is contenteditable el.setAttribute('contenteditable', 'true');
// Create the Quill editor instance with the toolbar let quill = new Quill(el, { theme: 'snow', modules: { toolbar: [ [{ 'header': '1' }, { 'header': '2' }, { 'font': [] }], [{ 'list': 'ordered'}, { 'list': 'bullet' }], ['bold', 'italic', 'underline', 'strike'], ['link', 'image'], [{ 'align': [] }], ['blockquote', 'code-block'], ['clean'] // This is the button to clear formatting ] } }); quill.on('text-change', function() { console.log('Content changed'); }); }; }); } < /code> Результат заключается в том, что я вижу редактор Quill, и я могу ввести в Quill. кнопки видны. < /p> Проблема в том, что если я нажимаю на жирную или курсивную кнопку, нет никакого эффекта. То есть я выбираю текст и нажимаю на «жирный жирник». На этом этапе линейная console.log ('Content изменен'); [/code] активен, и я вижу выход на консоли. Но текст не меняется. < /P> Я искал, это так и нашел это. Это говорит, что мне нужно инициализировать Quill. Поэтому я продолжал искать и нашел это. Но все еще ничего не происходит. < /P> Пожалуйста, помогите. Спасибо.