Standardize admin pages and blog editor
TaxBaik CI/CD / build-and-deploy (push) Failing after 2m39s

This commit is contained in:
2026-07-09 11:33:17 +09:00
parent 9cf6675dc9
commit 55933649f6
27 changed files with 825 additions and 68 deletions
@@ -0,0 +1,42 @@
(function () {
function syncEditor(editor, hiddenInput) {
const html = editor.innerHTML.trim();
hiddenInput.value = html;
}
function setupEditor(root) {
const editor = root.querySelector('[data-blog-editor]');
const hiddenInput = root.querySelector('[data-blog-editor-value]');
const preview = root.querySelector('[data-blog-preview]');
const buttons = root.querySelectorAll('[data-blog-command]');
if (!editor || !hiddenInput) return;
const renderPreview = () => {
if (preview) preview.innerHTML = editor.innerHTML;
};
editor.addEventListener('input', () => {
syncEditor(editor, hiddenInput);
renderPreview();
});
buttons.forEach(button => {
button.addEventListener('click', () => {
const command = button.getAttribute('data-blog-command');
const value = button.getAttribute('data-blog-value');
editor.focus();
document.execCommand(command, false, value);
syncEditor(editor, hiddenInput);
renderPreview();
});
});
syncEditor(editor, hiddenInput);
renderPreview();
}
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('[data-blog-editor-root]').forEach(setupEditor);
});
})();