MarkBind / markbind

MarkBind is a tool for generating content-heavy websites from source files in Markdown format
https://markbind.org/
MIT License
134 stars 123 forks source link

Pop-Ups like tooltip/trigger do not work within the tree component #1831

Open tlylt opened 2 years ago

tlylt commented 2 years ago

What did you do? Please include the actual source code causing the issue. The support for inline markdown/HTML elements works for most syntax within the tree component, but not for tooltip/popover

<tooltip id="tt:trigger_id" content="This tooltip triggered by a trigger"></tooltip>

<tree>
C:/course/
  textbook/
    <tooltip content="hello">index.md</tooltip>
    <trigger for="tt:trigger_id">via trigger</trigger>
</tree>

Testing the above code will give:

<div class="tree">C:/course/
├── <span data-mb-component-type="tooltip" tabindex="0" content="hello" class="trigger"><!----> <!----> index.md</span>
└── <span tabindex="0" class="trigger"><!----> via trigger</span></div>

image

Notice the white space added in front of the words "index.md" and "via trigger". While the direct tooltip approach does not work on hover, the trigger approach works. Not too sure if this is a bug with the tooltip/trigger element or is it due to the newly added tree component.

More context in the description and comments of #1807

What did you expect to happen? Expect the tree component to support inline components such as tooltip.

What actually happened? Please include the actual, raw output. Either not working as expected, or with unwanted spaces added in front of the trigger words

jovyntls commented 2 years ago

I think it's because the tree component uses markdown-it to render its contents using the renderInline method (here and here). However, pop-up components need to go through processNode in order to parse their contents, so rendering it as inline markdown is insufficient for fully parsing the node.

This means that any component that requires processNode , e.g. include, won't work either:

<div id="fragment">this is a fragment</div>

<tree>
C:/course/
  <include src="./index.md#fragment" />
</tree>

image

Maybe we can add in the docs that the tree component only supports inline markdown?

kaixin-hc commented 5 months ago

In the docs we already have this line

You can use Tree in combination with inline Markdown or inline HTML elements.

and also

Currently, Pop-Ups(tooltip/trigger) are not supported within a tree component.

as an alert. I think this is sufficient (though I wouldn't be opposed to further refining the wording)

I think at present, it is not necessary to explore also supporting this as it looks troublesome without much benefit? Would welcome more opinions.

tlylt commented 5 months ago

Keeping it as a low priority item seems reasonable to me.