Merge branch 'feat/wiki' into 'main'

Feat/wiki

See merge request jjimenez/safekat!581
This commit is contained in:
Alvaro
2025-03-02 09:25:35 +00:00
54 changed files with 14061 additions and 7 deletions

View File

@ -0,0 +1,41 @@
import Ajax from "../components/ajax.js";
class TranslationHelper {
constructor() {
this.locale = "es"
this.lang = {}
}
async get_translations(translationFile) {
return new Promise(async (resolve,reject) => {
this.locale = $("meta[name='locale']").attr("content");
this.translationFile = translationFile
const ajax = new Ajax('/translate/getTranslation',
{
locale: this.locale,
translationFile: this.translationFile
},
null,
(response) => {
this.lang = JSON.parse(response)
resolve(this.lang)
},
(error) => {
reject(error)
}
);
ajax.post()
})
}
get_lang(key) {
if (key in this.lang) {
return this.lang[key]
}else{
return key
}
}
}
export default TranslationHelper;

View File

@ -19,10 +19,10 @@ export const initAutonumeric = () => {
new AutoNumeric(this, {
digitGroupSeparator: ".",
decimalCharacter: ",",
allowDecimalPadding : 'floats',
allowDecimalPadding: 'floats',
decimalPlaces: 2,
unformatOnSubmit: true,
});
}
})
@ -32,10 +32,10 @@ export const initAutonumeric = () => {
new AutoNumeric(this, {
digitGroupSeparator: ".",
decimalCharacter: ",",
allowDecimalPadding : 'floats',
allowDecimalPadding: 'floats',
decimalPlaces: $(this).data('decimal-places'),
unformatOnSubmit: true,
});
}
})
@ -49,7 +49,7 @@ export const initAutonumeric = () => {
// allowDecimalPadding : 'floats',
// decimalPlaces: 2,
// unformatOnSubmit: true,
// });
// }
// })
@ -85,4 +85,26 @@ export const initAutonumeric = () => {
// });
// }
// })
}
export const getTablerIconClassName = () => {
const classNames = [];
for (const sheet of document.styleSheets) {
try {
if (sheet.cssRules) {
for (const rule of sheet.cssRules) {
if (rule.selectorText && rule.selectorText.startsWith(".ti-")) {
let className = rule.selectorText.split(" ")[0].replace(".", "");
className = className.split("::")[0]
className = className.split(":")[0]
classNames.push(className);
}
}
}
} catch (e) {
console.warn("Cannot access stylesheet:", sheet.href);
}
}
return classNames.reverse();
}

View File

@ -1,6 +1,5 @@
export const alertConfirmationDelete = (title, type = "primary") => {
return Swal.fire({
title: '¿Está seguro?',
@ -18,7 +17,23 @@ export const alertConfirmationDelete = (title, type = "primary") => {
buttonsStyling: false
})
}
export const alertConfirmAction = (title, type = "primary") => {
return Swal.fire({
title: '¿Está seguro?',
text: title,
icon: 'info',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Sí',
cancelButtonText: 'Cancelar',
customClass: {
confirmButton: 'btn btn-success me-1',
cancelButton: 'btn btn-label-secondary'
},
buttonsStyling: false
})
}
export const alertSuccessMessage = (title, type = "primary") => {
return Swal.fire({
showCancelButton: false,
@ -63,4 +78,52 @@ export const toastPresupuestoSummary = (value, target = 'body') => {
timerProgressBar: false,
stopKeydownPropagation: false,
})
}
export const alertSuccess = (value, target = 'body') => {
return Swal.mixin({
toast: true,
position: 'bottom-end',
html: `<span class="text-sm-left text-wrap">${value}</span>`,
customClass: {
popup: 'bg-success text-white',
},
icon : 'success',
iconColor: 'white',
target: target,
showConfirmButton: false,
timer: 2000,
timerProgressBar: true,
})
}
export const alertError = (value, target = 'body') => {
return Swal.mixin({
toast: true,
position: 'bottom-end',
html: `<span class="text-sm-left text-wrap">${value}</span>`,
customClass: {
popup: 'bg-danger text-white',
},
icon : 'error',
iconColor: 'white',
target: target,
showConfirmButton: false,
timer: 2000,
timerProgressBar: true,
})
}
export const alertWarning = (value, target = 'body') => {
return Swal.mixin({
toast: true,
position: 'bottom-end',
html: `<span class="text-sm-left text-wrap">${value}</span>`,
customClass: {
popup: 'bg-warning text-white',
},
icon : 'warning',
iconColor: 'white',
target: target,
showConfirmButton: false,
timer: 2000,
timerProgressBar: true,
})
}

View File

@ -0,0 +1,255 @@
import Ajax from '../ajax.js'
import { es } from './lang/es.js';
import '../../../../../themes/vuexy/js/editorjs/toc.js';
import '../../../../../themes/vuexy/js/editorjs/list.js';
import '../../../../../themes/vuexy/js/editorjs/tune.js';
import '../../../../../themes/vuexy/js/editorjs/table.js';
import '../../../../../../themes/vuexy/js/editorjs/image.js';
import '../../../../../../themes/vuexy/js/editorjs/alert.js';
import '../../../../../../themes/vuexy/js/editorjs/header.js';
import '../../../../../../themes/vuexy/js/editorjs/drag-drop.js';
import EditorJS from '../../../../../themes/vuexy/js/editorjs.mjs';
import TranslationHelper from '../../common/TranslationHelper.js';
import { alertConfirmAction, alertError, alertSuccess, alertWarning } from '../alerts/sweetAlert.js';
import WikiSectionForm from '../forms/WikiSectionForm.js'
class WikiEditor extends TranslationHelper{
constructor() {
super();
this.sectionId = $("#wiki-section-id").val();
this.wikiFormSection = new WikiSectionForm()
this.wikiFormSection.setId(this.sectionId)
}
async initEditor()
{
this.wikiFormSection.init()
await this.get_translations("Wiki")
this.editor = new EditorJS({
holder: 'editorjs',
i18n: this.locale == "es" ? es : null,
autofocus: true,
readOnly: true,
tunes: {
alignment: {
class: AlignmentBlockTune,
},
},
tools: {
toc: TOC,
header: {
class: Header,
tunes: ['alignment'],
config: {
placeholder: "",
levels: [1, 2, 3, 4],
defaultLevel: 1
},
},
nestedchecklist: {
class: editorjsNestedChecklist,
config: {
maxLevel: 1,
}
},
alert: {
class: Alert,
inlineToolbar: true,
tunes: ['alignment'],
config: {
alertTypes: ['primary', 'secondary', 'info', 'success', 'warning', 'danger', 'light', 'dark'],
defaultType: 'primary',
messagePlaceholder: 'Introduzca texto',
},
},
image: {
class: ImageTool,
config: {
features: {
border: true,
caption: 'optional',
stretch: false
},
endpoints: {
byFile: `/wiki/file/upload/${this.sectionId}`, // Your backend file uploader endpoint
byUrl: 'fetchUrl', // Your endpoint that provides uploading by Url
}
}
},
table: {
class: Table,
tunes: ['alignment'],
inlineToolbar: true,
config: {
rows: 2,
cols: 3,
maxRows: 5,
maxCols: 5,
},
},
alignment: {
class: AlignmentBlockTune,
config: {
default: "left",
blocks: {
header: 'left',
list: 'left'
}
}
},
},
})
}
async initViewOnly()
{
try {
await this.initEditor()
await this.editor.isReady;
this.handleGetDataPublished();
} catch (reason) {
console.log(`Editor.js initialization failed because of ${reason}`)
}
}
async init() {
try {
await this.initEditor()
await this.editor.isReady;
new DragDrop(this.editor);
/** Do anything you need after editor initialization */
$('#save-editor').on('click', () => {
this.editor.save().then(outputData => {
alertConfirmAction(this.get_lang('save_content')).then(result => {
if (result.isConfirmed) {
this.handleSaveContent(outputData)
}
});
})
})
$('#release-editor').on('click', () => {
this.editor.save().then(outputData => {
alertConfirmAction('Publicar contenido').then(result => {
if (result.isConfirmed) {
this.handlePublishContent(outputData)
}
console.log(result)
});
}).catch((error) => {
alertError(this.get_lang('need_editor_to_save')).fire()
})
})
$('#preview-editor').on('click', () => {
this.editor.readOnly.toggle()
$('#edit-editor').removeClass('d-none')
$('#preview-editor').addClass('d-none')
$('#release-editor').attr('disabled', 'disabled')
$('#save-editor').attr('disabled', 'disabled')
})
$('#edit-editor').on('click', () => {
$('#edit-editor').addClass('d-none')
$('#preview-editor').removeClass('d-none')
$('#release-editor').attr('disabled', null)
$('#save-editor').attr('disabled', null)
this.editor.readOnly.toggle()
})
this.handleGetData();
} catch (reason) {
console.log(`Editor.js initialization failed because of ${reason}`)
}
}
handleGetData() {
const ajax = new Ajax(`/wiki/section/${this.sectionId}`,
null,
null,
this.handleGetDataSuccess.bind(this),
this.handleGetDataError.bind(this))
ajax.get()
}
handleGetDataSuccess(response) {
if (response.data.contents?.editor_data) {
alertSuccess(response.message).fire()
this.renderContent(response.data.contents.editor_data)
} else {
alertWarning('No hay contenido').fire()
}
}
handleGetDataError(error) {
console.log(error)
}
handleGetDataPublished() {
const ajax = new Ajax(`/wiki/section/${this.sectionId}`,
null,
null,
this.handleGetDataPublishedSuccess.bind(this),
this.handleGetDataPublishedError.bind(this))
ajax.get()
}
handleGetDataPublishedSuccess(response) {
if (response.data.contents?.published_data) {
alertSuccess(response.message).fire()
this.renderContent(response.data.contents.published_data)
} else {
alertWarning(this.get_lang('no_content')).fire()
}
}
handleGetDataPublishedError(error) {
alertError(error.error).fire()
}
renderContent(content) {
try {
let parsedContent = JSON.parse(content)
this.editor.render(parsedContent)
this.centerImages()
} catch (error) {
console.log(error)
}
}
handleSaveContent(data) {
const ajax = new Ajax(`/wiki/save/${this.sectionId}`,
data,
null,
this.handleSaveContentSuccess.bind(this),
this.handleSaveContentError.bind(this))
ajax.post()
}
handleSaveContentSuccess(response) {
this.handleGetData()
}
handleSaveContentError(response) { }
handlePublishContent(data) {
const ajax = new Ajax(`/wiki/publish/${this.sectionId}`,
data,
null,
this.handleSaveContentSuccess.bind(this),
this.handleSaveContentError.bind(this))
ajax.post()
}
handleSaveContentSuccess(response) {
this.handleGetData()
}
handleSaveContentError(response) { }
centerImages(){
setInterval(() => {
$(".image-tool img").css('margin','0 auto')
$(".image-tool__caption").css('margin','0 auto').css('border','none').css('text-align','center').css('box-shadow','none')
},500)
}
}
export default WikiEditor

View File

@ -0,0 +1,65 @@
export const dataExample = {
"time": 1739862579806,
"blocks": [
{
"id": "uynEMELQjD",
"type": "header",
"data": {
"text": "Presupuesto",
"level": 1
}
},
{
"id": "5lBp4qELvp",
"type": "header",
"data": {
"text": "Introducción",
"level": 4
}
},
{
"id": "cf8xhN8Zo_",
"type": "paragraph",
"data": {
"text": "\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam lacinia\n diam ut tincidunt ornare. Suspendisse bibendum, velit ut mollis \nplacerat, tellus ante iaculis mi, ut luctus erat ligula sed est. Integer\n aliquam mauris eu diam tristique viverra. Proin id sem nisi. Praesent \ngravida tortor ac aliquam faucibus. Curabitur faucibus, magna vel \nconsectetur luctus, arcu diam iaculis lectus, posuere vehicula nisl \nnulla eget nibh.<b> Praesent tincidunt</b> enim condimentum interdum sodales. \nCurabitur eu diam sed mauris dignissim vestibulum eu quis justo. Nam \nornare odio id tincidunt aliquam. Quisque quis elit quis sem blandit \nimperdiet euismod non quam. Mauris maximus elit eu elementum consequat. \nSed nec cursus nibh. Nullam accumsan enim in tortor semper, in dapibus \nquam sagittis. In volutpat nisl libero, et pharetra dui luctus vitae. \nProin sit amet ornare mi. Sed vulputate ligula at elit posuere, non \nultrices risus ornare.\n"
}
},
{
"id": "2SnovwX73t",
"type": "header",
"data": {
"text": "Configuracion",
"level": 4
}
},
{
"id": "Sz_mcM8_BZ",
"type": "paragraph",
"data": {
"text": "\nFusce varius, erat vitae egestas elementum, ante turpis tincidunt erat, \nsit amet scelerisque massa nisl vel mauris. Cras eu condimentum magna, \nac finibus orci. Donec convallis sapien nulla, ac porta massa elementum \nsed. Nulla elit urna, ornare id quam ac, luctus commodo sem. Nam a \nsemper lectus. Sed eget ex varius, pretium ante ac, ultricies est. Sed \nut est leo. In velit lorem, vestibulum id sodales eu, vulputate et \nlectus. Mauris elementum lectus consequat cursus sollicitudin. Proin in \nsagittis turpis. Pellentesque ut pulvinar mi. Nullam nec purus vel enim \nconvallis rutrum. Pellentesque sem elit, fringilla quis accumsan quis, \nconvallis eu est. Nam malesuada nulla volutpat dui lobortis, vitae \nauctor turpis faucibus.\n"
}
},
{
"id": "Alu9XBLH6v",
"type": "paragraph",
"data": {
"text": "\nMaecenas sit amet iaculis diam. Aliquam sed feugiat neque. Proin et \npellentesque mi, et elementum risus. Sed volutpat, nibh quis finibus \nvenenatis, augue magna mollis est, vel efficitur nulla ligula et urna. \nVestibulum dictum molestie orci, vel pretium sapien fringilla eget. \nPellentesque fringilla facilisis congue. Proin bibendum dui non nisl \nornare rhoncus. Nam sit amet eros est. Integer luctus molestie lacus. \nPraesent elementum condimentum bibendum. Donec lacus nibh, sagittis in \ntempor nec, lacinia lacinia erat. Mauris pulvinar erat non nulla \npharetra dignissim. Quisque commodo dolor a neque lacinia porttitor. \nCras rhoncus ligula nibh.\n"
}
},
{
"id": "DLkw7hyvB1",
"type": "paragraph",
"data": {
"text": "\nPellentesque condimentum ullamcorper faucibus. Quisque vel enim et urna \nvenenatis faucibus at suscipit ipsum. Suspendisse nec nisi sit amet \ntortor suscipit volutpat ac eget mauris. Curabitur arcu arcu, vehicula \nin malesuada vitae, dapibus sit amet massa. Vivamus nec ex porttitor, \nvehicula nunc et, euismod velit. Maecenas dolor tortor, cursus quis \npurus ut, vulputate malesuada nunc. Morbi hendrerit auctor nisi. In \nfaucibus nibh sed quam suscipit lacinia. Cras placerat ornare lorem \nhendrerit blandit. Lorem ipsum dolor sit amet, consectetur adipiscing \nelit. Aliquam porttitor nisl ut arcu pretium, a sodales est iaculis. \nCras commodo sit amet tortor a rutrum. Mauris tristique magna nibh, quis\n bibendum tortor feugiat eget.\n"
}
},
{
"id": "3Ph1J1DR_5",
"type": "paragraph",
"data": {
"text": "\nPraesent iaculis tellus in quam rutrum ultrices. Phasellus ultricies \nlacus in neque volutpat iaculis. Aliquam at egestas tellus, vitae \nsollicitudin sapien. Sed commodo tellus ut ligula elementum iaculis. \nCurabitur sodales consequat dui, et tincidunt nunc vehicula vitae. \nSuspendisse aliquam justo a ante pellentesque ultrices ut in turpis. \nClass aptent taciti sociosqu ad litora torquent per conubia nostra, per \ninceptos himenaeos. Mauris scelerisque mattis tortor, in molestie neque \nbibendum a. Curabitur ut tempor erat. Donec aliquam scelerisque ipsum, \nbibendum placerat ante efficitur at. Sed malesuada, eros ut posuere \nvenenatis, leo est sagittis mi, at pretium augue tortor id ligula. Ut \negestas eget sapien a rhoncus. Ut lectus arcu, consequat posuere ipsum \nin, mollis iaculis augue.\n"
}
}
],
"version": "2.31.0-rc.8"
}

View File

@ -0,0 +1,155 @@
export const es = {
messages: {
/**
* Other below: translation of different UI components of the editor.js core
*/
ui: {
"blockTunes": {
"toggler": {
"Click to tune": "Click para editar",
"or drag to move": "o arrastra para editar",
"Filter" : "Filtrar"
},
"filter" : {
"Filter" : "Filtrar"
}
},
"inlineToolbar": {
"converter": {
"Convert to": "Convertir a",
"Filter" : "Filtrar"
},
},
"toolbar": {
"toolbox": {
"Add": "Añadir",
"Filter" : "Filtrar"
},
}
},
/**
* Section for translation Tool Names: both block and inline tools
*/
toolNames: {
"Text": "Texto",
"Heading": "Encabezado",
"List": "Lista",
"Unordered List": "Lista",
"Ordered List" : "Enumeración",
"Warning": "Advertencia",
"Checklist": "Checklist",
"Quote": "Cita",
"Code": "Codigo",
"Nested Checklist": "Lista anidada",
"Delimiter": "Delimitador",
"Raw HTML": "Raw HTML",
"Table": "Tabla",
"Link": "Enlace",
"Marker": "Subrayar",
"Bold": "Negrita",
"Italic": "Cursiva",
"InlineCode": "Código",
"Image" : "Imagen",
"Alert" : "Alerta",
"Convert to" : "Convertir a",
"TOC" : "Tabla de contenidos"
},
/**
* Section for passing translations to the external tools classes
*/
tools: {
/**
* Each subsection is the i18n dictionary that will be passed to the corresponded plugin
* The name of a plugin should be equal the name you specify in the 'tool' section for that plugin
*/
"warning": { // <-- 'Warning' tool will accept this dictionary section
"Title": "Titulo",
"Message": "Mensaje",
},
"list" : {
"Start with" : "Empezar con",
"Unordered": "Sin orden",
"Ordered" : "Ordenada",
"Counter type" : "Contador",
"Convert to" : "Convertir a",
},
"toc" : {
'Refresh' : "Actualizar",
},
"table" : {
"Add column to left" : "Añadir columna a la izquierda",
"Add column to right" : "Añadir columna a la derecha",
"Delete column" : "Eliminar columna",
"Delete row" : "Eliminar fila",
"Without headings" : "Sin encabezados",
"With headings" : "Con encabezados",
"Stretch" : "Ampliar",
"Add row above" : "Añadir fila arriba",
"Add row below" : "Añadir fila abajo",
},
/**
* Link is the internal Inline Tool
*/
"link": {
"Add a link": "Añadir un enlace"
},
/**
* The "stub" is an internal block tool, used to fit blocks that does not have the corresponded plugin
*/
"stub": {
'The block can not be displayed correctly.': 'El bloque no puede ser mostrado correctamente'
},
"alert" : {
"Primary" : "Color primario",
"Secondary" : "Color secundario",
"Info" : "Info",
"Success" : "Éxito",
"Warning" : "Advertencia",
"Danger" : "Peligro",
"Light" : "Ligero",
"Left" : "Izquierda",
"Right" :"Derecha",
"Dark" : "Oscuro",
"Center" : "Centrar"
},
"image": {
"With border" : "Con borde",
"Stretch image" : "Estirar imagen",
"With background" : "Añadir fondo",
"Select an Image" : "Seleccione una imagen",
"With caption" : "Con título"
}
},
/**
* Section allows to translate Block Tunes
*/
blockTunes: {
/**
* Each subsection is the i18n dictionary that will be passed to the corresponded Block Tune plugin
* The name of a plugin should be equal the name you specify in the 'tunes' section for that plugin
*
* Also, there are few internal block tunes: "delete", "moveUp" and "moveDown"
*/
"delete": {
"Delete": "Eliminar",
"Click to delete" : "Click para eliminar"
},
"moveUp": {
"Move up": "Mover hacia arriba"
},
"moveDown": {
"Move down": "Mover hacia abajo"
}
},
}
}

View File

@ -0,0 +1,168 @@
import Ajax from "../ajax.js";
import { alertConfirmAction, alertConfirmationDelete, alertError, alertSuccess } from "../alerts/sweetAlert.js";
import Modal from "../modal.js"
import { getTablerIconClassName } from "../../common/common.js";
class WikiSectionForm {
constructor() {
this.item = $("#formSection")
this.btnNew = $("#submit-new-section")
this.btnUpdate = $("#submit-update-section")
this.btnDelete = $("#delete-section")
this.name = this.item.find('#section-name')
this.icon = this.item.find('#section-icon')
this.roles = this.item.find('#section-roles').select2({
dropdownParent: this.item.parent()
})
this.newSectionBtn = $("#new-section")
this.editSectionBtn = $("#edit-section")
this.modalSection = $("#modalSection")
this.modal = new Modal(this.modalSection)
this.icons = getTablerIconClassName().map((e, index) => {
return { 'text': e, 'id': `ti ${e}` }
})
}
renderIcon(option) {
var icon = `<i class="ti ${option.text}"></i> ${option.text}`;
return icon;
}
init() {
this.icon.wrap('<div class="position-relative"></div>').select2({
data: this.icons,
dropdownParent: this.icon.parent(),
templateResult: this.renderIcon,
templateSelection: this.renderIcon,
escapeMarkup: function (m) { return m; }
})
this.icon.on('change', () => {
console.log(this.icon.val())
})
this.btnNew.on('click', this.post.bind(this))
this.btnUpdate.on('click', this.update.bind(this))
this.btnDelete.on('click',this.deleteConfirm.bind(this))
this.newSectionBtn.on('click', () => {
this.initPost()
})
this.editSectionBtn.on('click', () => {
this.initUpdate()
})
}
setId(id) {
this.sectionId = id
}
initPost() {
this.showPost()
}
initUpdate() {
this.showUpdate()
}
getFormData() {
return {
name: this.name.val(),
icon: this.icon.val(),
roles: this.roles.val()
}
}
post() {
const ajax = new Ajax('/wiki/section',
this.getFormData(),
null,
this.success.bind(this),
this.error.bind(this)
)
ajax.post()
}
update() {
const ajax = new Ajax('/wiki/update/section',
{
wiki_section_id: this.sectionId,
...this.getFormData()
},
null,
this.success.bind(this),
this.error.bind(this)
)
ajax.post()
}
deleteConfirm() {
alertConfirmAction('Eliminar sección').then(result => {
if (result.isConfirmed) {
this.delete()
}
console.log(result)
});
}
delete() {
const ajax = new Ajax('/wiki/section/' + this.sectionId,
null,
null,
this.success.bind(this),
this.error.bind(this)
)
ajax.delete()
}
success(response) {
alertSuccess(response.message).fire()
this.modal.toggle()
}
error(error) {
alertError(error?.message).fire()
}
showPost() {
this.empty()
this.btnNew.removeClass('d-none')
this.btnUpdate.addClass('d-none')
$("#modalTitleNew").removeClass('d-none')
$("#modalTitleEdit").addClass('d-none')
this.modal.toggle()
}
async showUpdate() {
this.empty()
const sectionData = await this.handleShowSection()
if (sectionData) {
console.log(sectionData)
this.name.val(sectionData.data.name)
this.icon.val(sectionData.data.icon).trigger('change')
this.roles.val(sectionData.data.roles_array).trigger('change')
}
this.btnUpdate.removeClass('d-none')
this.btnNew.addClass('d-none')
$("#modalTitleNew").addClass('d-none')
$("#modalTitleEdit").removeClass('d-none')
this.modal.toggle()
}
handleShowSection() {
return new Promise((resolve, reject) => {
const ajax = new Ajax('/wiki/section/' + this.sectionId,
null,
null,
(response) => {
resolve(response)
},
(error) => {
alertError(error.message).fire()
resolve(false)
}
)
ajax.get()
})
}
empty() {
this.name.val(null)
this.icon.val("").trigger('change')
this.roles.val("").trigger('change')
}
}
export default WikiSectionForm

View File

@ -0,0 +1,37 @@
import "../../../../../themes/vuexy/vendor/libs/sortablejs/sortable.js"
class ListSortable{
constructor(listItem,config = {}) {
this.list = Sortable.create($(listItem)[0], {
animation: 150,
group: 'menuSorting',
handle: '.drag-handle',
direction : 'vertical',
...config,
});
}
getArray(){
const list = this.list.toArray()
return list
}
onChange(callback)
{
this.list.option('onChange',callback)
}
onMove(callback)
{
this.list.option('onMove',callback)
}
onEnd(callback)
{
this.list.option('onEnd',callback)
}
}
export default ListSortable

View File

@ -9,6 +9,7 @@ class Modal{
show(){
this.item.modal('show');
}
}
export default Modal;

View File

@ -0,0 +1,13 @@
import WikiEditor from "../../components/editorjs/WikiEditor.js"
import Ajax from "../../components/ajax.js"
$(async () => {
try {
const editor = new WikiEditor()
await editor.init()
} catch (error) {
}
})

View File

@ -0,0 +1,25 @@
import Ajax from "../../components/ajax.js"
import { alertError, alertSuccess } from "../../components/alerts/sweetAlert.js"
import ListSortable from "../../components/listSortable.js"
$(() => {
const menuSectionList = new ListSortable('#menu-inner-list')
menuSectionList.onEnd(updateWikiSectionOrder)
})
const updateWikiSectionOrder = (evt) =>
{
let list = new ListSortable('#menu-inner-list')
const ajax = new Ajax('/wiki/section/update/order',
{
orders : list.getArray()
},
null,
(response) => alertSuccess(response.message).fire(),
(error) => alertError(error.message).fire(),
)
ajax.post();
}

View File

@ -0,0 +1,13 @@
import WikiEditor from "../../components/editorjs/WikiEditor.js"
$(async() => {
try {
const editor = new WikiEditor()
await editor.initViewOnly()
} catch (error) {
}
})

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,15 @@
/**
* Skipped minification because the original files appears to be already minified.
* Original file: /npm/@editorjs/header@2.8.8/dist/header.umd.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".ce-header{padding:.6em 0 3px;margin:0;line-height:1.25em;outline:none}.ce-header p,.ce-header div{padding:0!important;margin:0!important}")),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
(function(n,s){typeof exports=="object"&&typeof module<"u"?module.exports=s():typeof define=="function"&&define.amd?define(s):(n=typeof globalThis<"u"?globalThis:n||self,n.Header=s())})(this,function(){"use strict";const n="",s='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M19 17V10.2135C19 10.1287 18.9011 10.0824 18.836 10.1367L16 12.5"/></svg>',a='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16 11C16 10 19 9.5 19 12C19 13.9771 16.0684 13.9997 16.0012 16.8981C15.9999 16.9533 16.0448 17 16.1 17L19.3 17"/></svg>',h='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16 11C16 10.5 16.8323 10 17.6 10C18.3677 10 19.5 10.311 19.5 11.5C19.5 12.5315 18.7474 12.9022 18.548 12.9823C18.5378 12.9864 18.5395 13.0047 18.5503 13.0063C18.8115 13.0456 20 13.3065 20 14.8C20 16 19.5 17 17.8 17C17.8 17 16 17 16 16.3"/></svg>',d='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M18 10L15.2834 14.8511C15.246 14.9178 15.294 15 15.3704 15C16.8489 15 18.7561 15 20.2 15M19 17C19 15.7187 19 14.8813 19 13.6"/></svg>',u='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M16 15.9C16 15.9 16.3768 17 17.8 17C19.5 17 20 15.6199 20 14.7C20 12.7323 17.6745 12.0486 16.1635 12.9894C16.094 13.0327 16 12.9846 16 12.9027V10.1C16 10.0448 16.0448 10 16.1 10H19.8"/></svg>',g='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M6 7L6 12M6 17L6 12M6 12L12 12M12 7V12M12 17L12 12"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M19.5 10C16.5 10.5 16 13.3285 16 15M16 15V15C16 16.1046 16.8954 17 18 17H18.3246C19.3251 17 20.3191 16.3492 20.2522 15.3509C20.0612 12.4958 16 12.6611 16 15Z"/></svg>',c='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M9 7L9 12M9 17V12M9 12L15 12M15 7V12M15 17L15 12"/></svg>';/**
* Header block for the Editor.js.
*
* @author CodeX (team@ifmo.su)
* @copyright CodeX 2018
* @license MIT
* @version 2.0.0
*/class v{constructor({data:e,config:t,api:i,readOnly:r}){this.api=i,this.readOnly=r,this._settings=t,this._data=this.normalizeData(e),this._element=this.getTag()}get _CSS(){return{block:this.api.styles.block,wrapper:"ce-header"}}isHeaderData(e){return e.text!==void 0}normalizeData(e){const t={text:"",level:this.defaultLevel.number};return this.isHeaderData(e)&&(t.text=e.text||"",e.level!==void 0&&!isNaN(parseInt(e.level.toString()))&&(t.level=parseInt(e.level.toString()))),t}render(){return this._element}renderSettings(){return this.levels.map(e=>({icon:e.svg,label:this.api.i18n.t(`Heading ${e.number}`),onActivate:()=>this.setLevel(e.number),closeOnActivate:!0,isActive:this.currentLevel.number===e.number,render:()=>document.createElement("div")}))}setLevel(e){this.data={level:e,text:this.data.text}}merge(e){this._element.insertAdjacentHTML("beforeend",e.text)}validate(e){return e.text.trim()!==""}save(e){return{text:e.innerHTML,level:this.currentLevel.number}}static get conversionConfig(){return{export:"text",import:"text"}}static get sanitize(){return{level:!1,text:{}}}static get isReadOnlySupported(){return!0}get data(){return this._data.text=this._element.innerHTML,this._data.level=this.currentLevel.number,this._data}set data(e){if(this._data=this.normalizeData(e),e.level!==void 0&&this._element.parentNode){const t=this.getTag();t.innerHTML=this._element.innerHTML,this._element.parentNode.replaceChild(t,this._element),this._element=t}e.text!==void 0&&(this._element.innerHTML=this._data.text||"")}getTag(){const e=document.createElement(this.currentLevel.tag);return e.innerHTML=this._data.text||"",e.classList.add(this._CSS.wrapper),e.contentEditable=this.readOnly?"false":"true",e.dataset.placeholder=this.api.i18n.t(this._settings.placeholder||""),e}get currentLevel(){let e=this.levels.find(t=>t.number===this._data.level);return e||(e=this.defaultLevel),e}get defaultLevel(){if(this._settings.defaultLevel){const e=this.levels.find(t=>t.number===this._settings.defaultLevel);if(e)return e;console.warn("(ง'̀-'́)ง Heading Tool: the default level specified was not found in available levels")}return this.levels[1]}get levels(){const e=[{number:1,tag:"H1",svg:s},{number:2,tag:"H2",svg:a},{number:3,tag:"H3",svg:h},{number:4,tag:"H4",svg:d},{number:5,tag:"H5",svg:u},{number:6,tag:"H6",svg:g}];return this._settings.levels?e.filter(t=>this._settings.levels.includes(t.number)):e}onPaste(e){const t=e.detail;if("data"in t){const i=t.data;let r=this.defaultLevel.number;switch(i.tagName){case"H1":r=1;break;case"H2":r=2;break;case"H3":r=3;break;case"H4":r=4;break;case"H5":r=5;break;case"H6":r=6;break}this._settings.levels&&(r=this._settings.levels.reduce((o,l)=>Math.abs(l-r)<Math.abs(o-r)?l:o)),this.data={level:r,text:i.innerHTML}}}static get pasteConfig(){return{tags:["H1","H2","H3","H4","H5","H6"]}}static get toolbox(){return{icon:c,title:"Heading"}}}return v});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
/**
* Skipped minification because the original files appears to be already minified.
* Original file: /npm/@editorjs/warning@1.4.1/dist/warning.umd.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(`.cdx-warning{position:relative}@media all and (min-width: 736px){.cdx-warning{padding-left:36px}}.cdx-warning [contentEditable=true][data-placeholder]:before{position:absolute;content:attr(data-placeholder);color:#707684;font-weight:400;opacity:0}.cdx-warning [contentEditable=true][data-placeholder]:empty:before{opacity:1}.cdx-warning [contentEditable=true][data-placeholder]:empty:focus:before{opacity:0}.cdx-warning:before{content:"";background-image:url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='5' y='5' width='14' height='14' rx='4' stroke='black' stroke-width='2'/%3E%3Cline x1='12' y1='9' x2='12' y2='12' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M12 15.02V15.01' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");width:24px;height:24px;background-size:24px 24px;position:absolute;margin-top:8px;left:0}@media all and (max-width: 735px){.cdx-warning:before{display:none}}.cdx-warning__message{min-height:85px}.cdx-warning__title{margin-bottom:6px}`)),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
(function(r,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(r=typeof globalThis<"u"?globalThis:r||self,r.Warning=n())})(this,function(){"use strict";const r='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><rect width="14" height="14" x="5" y="5" stroke="currentColor" stroke-width="2" rx="4"/><line x1="12" x2="12" y1="9" y2="12" stroke="currentColor" stroke-linecap="round" stroke-width="2"/><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M12 15.02V15.01"/></svg>',n="";class a{static get isReadOnlySupported(){return!0}static get toolbox(){return{icon:r,title:"Warning"}}static get enableLineBreaks(){return!0}static get DEFAULT_TITLE_PLACEHOLDER(){return"Title"}static get DEFAULT_MESSAGE_PLACEHOLDER(){return"Message"}get CSS(){return{baseClass:this.api.styles.block,wrapper:"cdx-warning",title:"cdx-warning__title",input:this.api.styles.input,message:"cdx-warning__message"}}constructor({data:t,config:e,api:s,readOnly:i}){this.api=s,this.readOnly=i,this.titlePlaceholder=(e==null?void 0:e.titlePlaceholder)||a.DEFAULT_TITLE_PLACEHOLDER,this.messagePlaceholder=(e==null?void 0:e.messagePlaceholder)||a.DEFAULT_MESSAGE_PLACEHOLDER,this.data={title:t.title||"",message:t.message||""}}render(){const t=this._make("div",[this.CSS.baseClass,this.CSS.wrapper]),e=this._make("div",[this.CSS.input,this.CSS.title],{contentEditable:!this.readOnly,innerHTML:this.data.title}),s=this._make("div",[this.CSS.input,this.CSS.message],{contentEditable:!this.readOnly,innerHTML:this.data.message});return e.dataset.placeholder=this.titlePlaceholder,s.dataset.placeholder=this.messagePlaceholder,t.appendChild(e),t.appendChild(s),t}save(t){const e=t.querySelector(`.${this.CSS.title}`),s=t.querySelector(`.${this.CSS.message}`);return Object.assign(this.data,{title:(e==null?void 0:e.innerHTML)??"",message:(s==null?void 0:s.innerHTML)??""})}_make(t,e=null,s={}){const i=document.createElement(t);Array.isArray(e)?i.classList.add(...e):e&&i.classList.add(e);for(const l in s)i[l]=s[l];return i}static get sanitize(){return{title:{},message:{}}}}return a});

File diff suppressed because one or more lines are too long