Archived
62 lines
2.0 KiB
JavaScript
62 lines
2.0 KiB
JavaScript
frappe.provide("frappe.ui.form");
|
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
console.log("[editor_override] ✅ 3 Patch Summernote aktif (field message & custom_note_kwitansi di Payment Request)");
|
|
|
|
// Helper: ganti Quill → Summernote
|
|
function replaceWithSummernote(field) {
|
|
if (!field || !field.$wrapper) return;
|
|
|
|
// Cek kalau Summernote sudah ada
|
|
if (field.$wrapper.find(".note-editor").length) {
|
|
console.log("[editor_override] Summernote sudah ada di:", field.df.fieldname);
|
|
return;
|
|
}
|
|
|
|
console.log("[editor_override] 🚀 Ganti Quill → Summernote di field:", field.df.fieldname);
|
|
|
|
// Hapus editor lama
|
|
field.$wrapper.empty();
|
|
|
|
// Tambah textarea
|
|
let $textarea = $('<textarea></textarea>').appendTo(field.$wrapper);
|
|
|
|
// Init Summernote
|
|
$textarea.summernote({
|
|
height: 200,
|
|
toolbar: [
|
|
["style", ["bold", "italic", "underline", "clear"]],
|
|
["font", ["fontsize", "color"]],
|
|
["para", ["ul", "ol", "paragraph"]],
|
|
["table", ["table"]],
|
|
["insert", ["link", "picture", "video"]],
|
|
["view", ["codeview"]]
|
|
],
|
|
callbacks: {
|
|
onChange: function (contents) {
|
|
field.set_value(contents || "");
|
|
}
|
|
}
|
|
});
|
|
|
|
// Isi value awal (kalau ada)
|
|
if (field.value) {
|
|
$textarea.summernote("code", field.value);
|
|
}
|
|
}
|
|
|
|
// Override hanya untuk Payment Request (field message & custom_note_kwitansi)
|
|
frappe.ui.form.on("Payment Request", {
|
|
onload_post_render: function (frm) {
|
|
["message", "custom_note_kwitansi"].forEach((fname) => {
|
|
let field = frm.fields_dict[fname];
|
|
if (field) {
|
|
setTimeout(() => {
|
|
replaceWithSummernote(field);
|
|
}, 500);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|