;
        const newMarkdown = textarea.value;
        const viewer = document.getElementById('mindmap-viewer');
        const currentMindmap = JSON.parse(viewer.dataset.currentMindmap || '{}');

        if (newMarkdown !== currentMarkdown) {
            currentMarkdown = newMarkdown;

            const history = JSON.parse(localStorage.getItem('mindmap-history') || '[]');
            const mindmapIndex = history.findIndex(item => item.id === currentMindmap.id);

            if (mindmapIndex !== -1) {
      