[API] MindManager API - How to Add Text While Preserving Formatting
Hello MindManager Community,
I'm developing a macro that adds references to selected topics (what I call a "reference popularizer"). The macro works by appending formatted references like "[RefName]" to the end of selected topics. It handles spacing intelligently based on the current text:
- For empty topics, it just adds the reference
- If a topic ends with "]", it adds a space before the new reference
- If a topic already ends with a space, it adds the reference without additional spacing
- Otherwise, it adds a space followed by the reference
The Problem: When I use Topic.Text to modify topic text, it completely removes all existing formatting (colors, underlining, etc.). This creates a frustrating experience for users who carefully formatted their topics.
What I've Tried:
1. Using Topic.Title.InsertText with calculated position - This didn't insert at the expected position
2. Using Topic.Title.TextRTF to get RTF text and then appending to it - This didn't add anything
3. Using Topic.Title.InsertTextRTF - This resulted in an "Unable to execute a command" error
4. Using Topic.Title.GetDisplayText(mmDisplayTextAll) to get text, then adding reference - This still lost formatting
Here's a simplified version of my current code:
' Get current text currentText = Topic.Text ' Add reference with proper spacing If currentText = "" Then Topic.Text = newRef ElseIf Right(currentText, 1) = "]" Then Topic.Text = currentText & " " & newRef ElseIf Right(currentText, 1) = " " Then Topic.Text = currentText & newRef Else Topic.Text = currentText & " " & newRef End If
My Question: Is there a way to add text to the end of a topic while preserving the existing text formatting? Is there any approach using the MindManager API that allows for appending text without destroying formatting attributes?
I've explored several methods from the API documentation (Title object, GetDisplayText, TextRTF) but haven't found a reliable solution. Any guidance would be greatly appreciated!
Thank you in advance,
ps i have tried 10x times /w claude 3.5 sonnet, and 5+ /w claude 3.7 sonnet + thinking.
those are state of the art LLMs.
i have even already share the api documents to it as much as i can.
thank you.
ps i have tried 10x times /w claude 3.5 sonnet, and 5+ /w claude 3.7 sonnet + thinking.
those are state of the art LLMs.
i have even already share the api documents to it as much as i can.
thank you.
This will be difficult without parsing the RTF. RTF itself is complex and RTF libraries are not easy to find. The method Topic.Text extracts the plain text without formatting. Some alternatives are:
This will be difficult without parsing the RTF. RTF itself is complex and RTF libraries are not easy to find. The method Topic.Text extracts the plain text without formatting. Some alternatives are:
---