修复了一些问题

This commit is contained in:
2026-08-25 19:59:43 +08:00
parent f5746da0ae
commit c484ee6ef3
5 changed files with 16 additions and 87 deletions
-54
View File
@@ -100,7 +100,6 @@
if (!this.form) {
return;
}
this.hydrateEditor();
this.bindDirty();
this.bindAutoHeight();
this.bindSubmitButtons();
@@ -114,59 +113,6 @@
this.loadFeaturedFromDom();
},
hydrateEditor: function () {
var snapshot = document.getElementById('aksrt-initial-post-content');
var textarea = qs('#post_content') || qs('[name="post_content"]');
var initialContent = snapshot ? snapshot.value : textarea ? textarea.value : '';
if (!initialContent) {
return;
}
var fallbackToTextEditor = function () {
if (window.switchEditors && typeof window.switchEditors.go === 'function') {
window.switchEditors.go('post_content', 'html');
}
if (textarea) {
textarea.value = initialContent;
textarea.style.opacity = '1';
textarea.style.display = 'block';
}
};
var attempts = 0;
var restore = function () {
var editor = window.tinymce && window.tinymce.get('post_content');
if (!editor) {
attempts += 1;
if (attempts < 20) {
setTimeout(restore, 250);
} else {
fallbackToTextEditor();
}
return;
}
var hydrate = function () {
var current = editor.getContent({ format: 'raw' });
if (!current || !current.trim()) {
editor.setContent(initialContent);
editor.save();
}
if (!editor.getContent({ format: 'raw' }).trim()) {
fallbackToTextEditor();
}
};
if (editor.initialized) {
hydrate();
} else {
editor.on('init', hydrate);
}
};
restore();
},
bindDirty: function () {
var self = this;
this.form.addEventListener('input', function () {