From 93886e34021aa5c79d3582d70a4284fa34cca49f Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Tue, 18 Aug 2026 17:56:00 +0530 Subject: [PATCH] Fix discharge editor alignment controls --- .../ipd_discharge/discharge_template_edit.php | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/app/Views/ipd_discharge/discharge_template_edit.php b/app/Views/ipd_discharge/discharge_template_edit.php index a3cb9a0..8465f28 100644 --- a/app/Views/ipd_discharge/discharge_template_edit.php +++ b/app/Views/ipd_discharge/discharge_template_edit.php @@ -126,14 +126,32 @@ $placeholders = [
+
+ + + + +
+
+ + + + +
+
+ + + + +
@@ -227,11 +245,10 @@ $placeholders = [ if (!CKEDITOR.instances[id]) { CKEDITOR.replace(id, { height: id === 'tpl_html' ? 280 : 140, - extraPlugins: 'justify', toolbar: [ {name: 'clipboard', items: ['Cut', 'Copy', 'Paste', 'PasteText', 'Undo', 'Redo']}, {name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike', 'RemoveFormat']}, - {name: 'paragraph', items: ['NumberedList', 'BulletedList', 'Outdent', 'Indent', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock']}, + {name: 'paragraph', items: ['NumberedList', 'BulletedList', 'Outdent', 'Indent']}, {name: 'links', items: ['Link', 'Unlink']}, {name: 'insert', items: ['Image', 'Table']}, {name: 'styles', items: ['Styles', 'Format']}, @@ -242,6 +259,31 @@ $placeholders = [ }); } + document.querySelectorAll('.ck-align-tools button').forEach(function (button) { + button.addEventListener('click', function () { + var editorId = button.closest('.ck-align-tools').getAttribute('data-editor'); + var alignment = button.getAttribute('data-align'); + if (typeof CKEDITOR === 'undefined' || !CKEDITOR.instances[editorId]) { + return; + } + var editor = CKEDITOR.instances[editorId]; + editor.focus(); + var element = editor.getSelection().getStartElement(); + var block = null; + while (element) { + var tag = element.getName ? element.getName() : ''; + if (['p', 'div', 'td', 'th', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].indexOf(tag) !== -1) { + block = element; + break; + } + element = element.getParent ? element.getParent() : null; + } + if (block) { + block.setStyle('text-align', alignment); + } + }); + }); + function getCsrf() { var el = document.querySelector('input[name^="csrf_"]'); return el ? {name: el.name, value: el.value} : {name: 'csrf_test_name', value: ''};