Dashboard Fach hinzufügen funktioniert in swe-b1-a-dev
This commit is contained in:
committed by
Matthias Grief
parent
b2cff02086
commit
6f73884baf
80
swe-b1-a-dev/webseite/dashboard/js/modules/QuillEditor.js
Normal file
80
swe-b1-a-dev/webseite/dashboard/js/modules/QuillEditor.js
Normal file
@@ -0,0 +1,80 @@
|
||||
export class QuillEditor {
|
||||
constructor(editorId = 'quillEditor', previewId = 'contentPreview') {
|
||||
this.quill = null;
|
||||
this.editorId = editorId;
|
||||
this.previewId = previewId;
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
console.log('Initializing Quill editor...'); // Debug log
|
||||
|
||||
const editorContainer = document.getElementById(this.editorId);
|
||||
if (!editorContainer) {
|
||||
console.error(`Editor container #${this.editorId} not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
this.quill = new Quill(`#${this.editorId}`, {
|
||||
theme: 'snow',
|
||||
modules: {
|
||||
toolbar: [
|
||||
[{ 'header': [1, 2, false] }],
|
||||
['bold', 'italic', 'underline'],
|
||||
['blockquote', 'code-block'],
|
||||
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
|
||||
[{ 'script': 'sub'}, { 'script': 'super' }],
|
||||
['link', 'image', 'formula'],
|
||||
['clean']
|
||||
]
|
||||
},
|
||||
placeholder: 'Fügen Sie hier Ihren Inhalt ein...'
|
||||
});
|
||||
|
||||
this.quill.on('text-change', () => this.updatePreview());
|
||||
console.log('Quill editor initialized');
|
||||
}
|
||||
|
||||
updatePreview() {
|
||||
const content = this.quill.root.innerHTML;
|
||||
const preview = document.getElementById(this.previewId);
|
||||
|
||||
if (preview) {
|
||||
preview.innerHTML = content;
|
||||
|
||||
// Re-render math if present
|
||||
if (window.MathJax) {
|
||||
MathJax.typeset([preview]);
|
||||
}
|
||||
|
||||
// Highlight code blocks if any
|
||||
if (window.Prism) {
|
||||
Prism.highlightAllUnder(preview);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getContent() {
|
||||
return this.quill.root.innerHTML;
|
||||
}
|
||||
|
||||
setContent(content) {
|
||||
if (this.quill) {
|
||||
this.quill.root.innerHTML = content;
|
||||
this.updatePreview();
|
||||
}
|
||||
}
|
||||
|
||||
undo() {
|
||||
this.quill?.history.undo();
|
||||
}
|
||||
|
||||
redo() {
|
||||
this.quill?.history.redo();
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.quill?.setContents([]);
|
||||
this.updatePreview();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user