          history[mindmapIndex].markdown = newMarkdown;
                localStorage.setItem('mindmap-history', JSON.stringify(history));
                showMindmap(currentMindmap.id);
                loadMindmaps();
            }
        }

        toggleEditMode(false);
    }

    async function shareMindmap() {
        const viewer = document.getElementById('mindmap-viewer');
        const currentMindmap = JSON.parse(viewer.dataset.currentMindmap || '{}');

        if (!currentMindmap.topic) 
          