Correction for edit tools

This commit is contained in:
2026-07-23 04:33:21 +02:00
committed by kitoy
parent fb9388a0de
commit 2da8aad1a9
2 changed files with 39 additions and 7 deletions

View File

@@ -10,7 +10,7 @@
onclick="enableModBtn()" onclick="enableModBtn()"
hx-get="{% if page %}/{{ page }}{% endif %}/view/{{ bloc.name }}" hx-get="{% if page %}/{{ page }}{% endif %}/view/{{ bloc.name }}"
hx-swap="outerHTML" hx-swap="outerHTML"
hx-target="#{{ bloc.name }}" > Annuler </button> hx-target="#{{ bloc.name }}" > Fermer </button>
</div> </div>
<script> <script>
function enableModBtn(){ function enableModBtn(){
@@ -20,9 +20,13 @@
function saveText(){ function saveText(){
editor_content = document.getElementById("editor"); editor_content = document.getElementById("editor");
result = document.getElementById("text");
if (editor_content != null) if (editor_content != null)
{ {
document.getElementById("text").innerHTML = quill.getSemanticHTML(0); console.log(quill.root.innerHTML);
result.innerHTML = quill.root.innerHTML;
delete quill; delete quill;
} }
enableModBtn(); enableModBtn();

View File

@@ -7,7 +7,6 @@
<!-- Initialize Quill editor --> <!-- Initialize Quill editor -->
<script> <script>
var toolbarOptions = [ var toolbarOptions = [
@@ -30,12 +29,41 @@
['clean'] // remove formatting button ['clean'] // remove formatting button
]; ];
var quill = new Quill('#editor', { var quill = new Quill('#editor', {
modules: { theme: 'snow',
modules: {
syntax: true, // Include syntax module syntax: true, // Include syntax module
toolbar: toolbarOptions // Include button in toolbar toolbar: toolbarOptions, // Include button in toolbar
resize: {
// embed tags to capture resize
embedTags: ["VIDEO", "IFRAME"],
// custom toolbar
tools: [
"left",
"center",
"right",
"full",
"edit",
{
text: "Alt",
attrs: {
title: "Set image alt",
class: "btn-alt",
},
verify(activeEle) {
return activeEle && activeEle.tagName === "IMG";
},
handler(evt, button, activeEle) {
let alt = activeEle.alt || "";
alt = window.prompt("Description de l'image", alt);
if (alt == null) return;
activeEle.setAttribute("alt", alt);
},
},
],
}
}, },
theme: 'snow'
}); });
</script> </script>