Files
wizarr/app/static/js/init-tinymde.js
Matthieu B fc49da65f6 refactor: fix ruff linting and ty type errors
- Fix invalid parameter defaults: library_id: str | None = None
- Replace try-except-pass with contextlib.suppress()
- Remove unnecessary dict.keys() calls
- Remove unnecessary variable assignments before return
- Combine nested if statements
- Add type ignore comments for intentional shadowing
- Add type ignore comments for SQLAlchemy dynamic attributes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 22:06:15 +02:00

33 lines
1.1 KiB
JavaScript

function attachTinyMDE() {
const modal = document.getElementById('step-modal') || document;
const textarea = modal.querySelector('textarea[name="markdown"]');
if (!textarea || textarea.dataset.tinymdeAttached) return;
textarea.dataset.tinymdeAttached = '1';
if (typeof TinyMDE === 'undefined') {
console.warn('TinyMDE not loaded');
return;
}
// Create TinyMDE editor and store reference for widget insertion
const editor = new TinyMDE.Editor({ textarea: textarea });
textarea.tinyMDEEditor = editor; // Store reference on textarea
// Style the generated editor to match input fields
const edRoot = textarea.nextElementSibling; // TinyMDE inserts after textarea
if (edRoot) {
edRoot.classList.add(
'bg-gray-50',
'border',
'border-gray-300',
'rounded-lg',
'p-2.5',
'dark:bg-gray-700',
'dark:border-gray-600',
'dark:text-white'
);
edRoot._tinyMDEInstance = editor; // Also store on DOM element
}
}
document.addEventListener('htmx:afterOnLoad', attachTinyMDE);
document.addEventListener('DOMContentLoaded', attachTinyMDE);