MarkMindCkm / obsidian-markmind

A mind map, outline for obsidian,It support mobile and desktop
801 stars 35 forks source link

Copy as markdown issue #642

Open uncatchableee opened 1 year ago

uncatchableee commented 1 year ago

Hi,

When the node is collapsed, copy as markdown adds extra characters to the text something like this ^dc197f12-4e5a-3467.

I also added copy and paste buttons to your javascript code. I can give you the code so you can add it to your official plugin. I don't want to patch the plugin again on a new release. Please let me know. here is my discord. uncatchable#8793 copy-paste

I also think your plugin is missing these features:

1) search: you may want to use obsidian default search and make it somehow obsidian sees your md file as canvas or you need to write your own code. For example Ctrl+F brings up a box and we can search for a text. 2) change the node box size. 3) break text of a node into child or sibiling. 4) Expand all children of the node one level at a time.

MarkMindCkm commented 1 year ago

search : you can use open or close search box in more options expand node : you can use ctrl + p , then execute expand all node command

uncatchableee commented 1 year ago

Copy and paste code

To copy the nodes I used your getMarkdown() function. I just tweaked a little bit so instead of markdown format, it converts it to indented format and to build from indented format I used this code and passed the indented format from clipboard to this function. The only thing is that a node should be selected. The rest is just adding the copy and paste buttons.

    build_with_indent(my_selected_node, clipboardText) {

         // Split the clipboard text into lines
         const lines = clipboardText.toString().split("\n");

         // Create a stack to keep track of the current level of indentation
         const stack = [];
         stack.push(0); 

         // Create a variable to keep track of the current parent element
         let currentParent = my_selected_node.parent;
         // Loop through each line of text
         for (let i = 0; i < lines.length; i++) {
           const line = lines[i]

           // Count the number of spaces at the beginning of the line
           const indent = line.search(/\S/);

           // If the line is not indented, ignore it
           if (indent === -1) {
             continue;
           }

           // If the indent level is less than the current level, pop the stack
           while (stack.length > 1 && indent <= stack[stack.length - 1]) {
             stack.pop();
             my_selected_node = my_selected_node.parent;
           }

           // If the indent level is greater than the current level, create a new child element
           if (indent >= stack[stack.length - 1]) {
               this.execute("addChildNode", {
                                        parent: my_selected_node,
                                        data: {
                                            text: line.trim()                                             
                                        }
                                    })
        // move to new child                    
        my_selected_node.children.forEach( function(my_child) {
                if (my_child.data['text']===line.trim()) {
                    my_selected_node=my_child;
                } 
             });

             stack.push(indent);
           }

         }
    }

Search

There is no open or close search box in more options!

image

The only search is available is here and it only shows json data and if you click on it, it doesn't take you to the node.

image

I am looking for something like below. You press ctrl+F and you type your text and it takes you to the node.

search


Reference to another node

Right now there is a capability to reference to a section in a md file by [[md-file#section|alias]] but it would be a good idea that if we could reference another node in the map by [[mindmapfile#node-id|alias]] and by clicking on it would take you to that node.

image


Expand

When I am talking about expanding a node, I mean not expanding all the nodes at once. Only expand the selected node one level at a time like below

expand


Change the box size

Can you please add so we can change the node box size? Some time I want to see the whole text in one line.

box-size



One vertical line but different colors at the end

Can you please make it the root node instead of having multiple lines has one line but different color for its children?

image


Copy as markdown issue

When the node is closed, copy as markdown adds extra characters to the text something like this ^dc197f12-4e5a-3467.

markdown issue

Table don't get rendered.

table issue