Hướng dẫn nâng cấp module từ NukeViet 4.5.05 lên NukeViet 4.5.06 - nukeviet/update GitHub Wiki
Xem hướng dẫn nâng cấp module lên 4.5.05 tại đây
Làm bước này cho các module trước ngày 01/08/2025
Nếu module của bạn sử dụng trình soạn thảo ngoài site cho một số tính năng đặc biệt cần cập nhật nó sang ckeditor 5 theo nguyên tắc sau:
Dùng CKEditor trực tiếp qua js
<script type="text/javascript" src="{NV_BASE_SITEURL}{NV_EDITORSDIR}/ckeditor/ckeditor.js?t={TIMESTAMP}"></script>
CKEDITOR.replace('content', {width: '100%',height: '200px',removePlugins: 'uploadfile,uploadimage,autosave'});
Cần thay thành dạng như
<script type="text/javascript" src="{NV_BASE_SITEURL}{NV_EDITORSDIR}/ckeditor5-classic/ckeditor.js?t={TIMESTAMP}"></script>
<script type="text/javascript" src="{NV_BASE_SITEURL}{NV_EDITORSDIR}/ckeditor5-classic/language/{NV_LANG_INTERFACE}.js?t={TIMESTAMP}"></script>
<script type="text/javascript">
(async () => {
await ClassicEditor
.create(document.getElementById("commentcontent"), {
language: '{NV_LANG_INTERFACE}',
removePlugins: ["NVBox"],
image: {insert: {integrations: ["url"]}},
nvmedia: {insert: {integrations: ["url"]}},
toolbar: {
items: [
'undo',
'redo',
'selectAll',
'|',
'link',
'imageInsert',
'nvmediaInsert',
'insertTable',
'code',
'codeBlock',
'horizontalLine',
'specialCharacters',
'pageBreak',
'|',
'findAndReplace',
'showBlocks',
'|',
'bulletedList',
'numberedList',
'outdent',
'indent',
'blockQuote',
'heading',
'fontSize',
'fontFamily',
'fontColor',
'fontBackgroundColor',
'highlight',
'alignment',
'|',
'bold',
'italic',
'underline',
'strikethrough',
'subscript',
'superscript',
'|',
'sourceEditing',
'restrictedEditingException',
'removeFormat'
],
shouldNotGroupWhenFull: false
}
})
.then(editor => {
window.nveditor = window.nveditor || [];
window.nveditor["commentcontent"] = editor;
if (editor.sourceElement && editor.sourceElement instanceof HTMLTextAreaElement && editor.sourceElement.form) {
editor.sourceElement.dataset.editorname = "commentcontent";
editor.sourceElement.form.addEventListener("submit", event => {
// Xử lý khi submit form thông thường
editor.sourceElement.value = editor.getData();
});
}
})
.catch(error => {
console.error(error);
});
})();
</script>
Dùng CKEditor thông qua PHP
if (defined('NV_EDITOR')) {
require_once NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php';
} elseif (!nv_function_exists('nv_aleditor') and file_exists(NV_ROOTDIR . '/' . NV_EDITORSDIR . '/ckeditor/ckeditor.js')) {
define('NV_EDITOR', true);
define('NV_IS_CKEDITOR', true);
$my_head .= '<script type="text/javascript" src="' . NV_BASE_SITEURL . NV_EDITORSDIR . '/ckeditor/ckeditor.js"></script>';
/**
* nv_aleditor()
*
* @param mixed $textareaname
* @param string $width
* @param string $height
* @param string $val
* @param string $customtoolbar
* @return
*/
function nv_aleditor($textareaname, $width = '100%', $height = '450px', $val = '', $customtoolbar = '')
{
global $module_data;
$return = '<textarea style="width: ' . $width . '; height:' . $height . ';" id="' . $module_data . '_' . $textareaname . '" name="' . $textareaname . '">' . $val . '</textarea>';
$return .= "<script type=\"text/javascript\">
CKEDITOR.replace( '" . $module_data . '_' . $textareaname . "', {" . (!empty($customtoolbar) ? 'toolbar : "' . $customtoolbar . '",' : '') . " width: '" . $width . "',height: '" . $height . "',removePlugins: 'uploadfile,uploadimage'});
</script>";
return $return;
}
}
Thay lại thành
if (!defined('NV_EDITOR')) {
define('NV_EDITOR', 'ckeditor5-classic');
}
require_once NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php';