wikilabs / plugins

TW5 plugins: https://wikilabs.github.io
30 stars 8 forks source link

allow attaching of arbitrary other tocP-Trees into another one #48

Open rimi opened 3 years ago

rimi commented 3 years ago

Hi Mario

as i had the need to support connecting of multiple of your tocP-trees within arbitrary locations of other trees i enhanced your implementation to support that too. At the moment i only implemented it for 'tocp' and 'tocP-selective-expandable' but at least one of the other implementations i quickly looked above uses methods i already adapted.

To "hook" another tree into an existing, a node just needs to define a list of a list of other field-names (starting with the keyword 'root' as usual for your trees) inside a field called 'tocp.treelinker.fields' (centrally defined and adaptable via macro). the according trees are than hooked into the outer. Own children are also rendered and your "add-children" function natively uses the right field-name inside of the according tree.

Hope you find it useful!

Regards, Mirko

rimi commented 3 years ago

Ah i forgot to mention the usecases i was after:

  1. obviously: divide knowledge/content into separate trees
  2. to have the ability to attach subtrees in multiple locations, what now works as i want it (btw: if one would make the entry 'root' configurable for my proposed hook, parts of the same tree could also be easily rendered to different locations within that tree)

Mirko

rimi commented 3 years ago

Far faster understanding, i quickly created a simple example within your tocP-Shocase: tiddlywiki.zip

Mirko

pmario commented 3 years ago

Hi @rimi .. Thanks for the feedback!!

I think it would be easier to let tocP just call a tiddler that contains an other tocP or toc definition. ... This would let us create very complex structures. ...

I think it would only need some CSS adjustments. ...


I didn't have looked at your code yet. ... I'll do so soon! Thx. again!

rimi commented 3 years ago

I think it would be easier to let tocP just call a tiddler that contains an other tocP or toc definition. ... This would let us create very complex structures. ...

I think it would only need some CSS adjustments. ...

Interesting approach, but i don't get in depth ;). You mean to add a node that itself contains a <<tocP...>>-macro in some of its field? What would happen if there was some other text around that macro? Most probably you refer to a special tocP-field and not the text, right?

pmario commented 3 years ago

Interesting approach, but i don't get in depth ;). You mean to add a node that itself contains a <>-macro in some of its field? What would happen if there was some other text around that macro? Most probably you refer to a special tocP-field and not the text, right?

I was thinking about a tocP macro in the text field. ... I did a different experiment with a modified toc macro 2017 .. But it was a bit hacky. see the zip toc-merge-experiment-v0.0.2-all.json.zip You should import it into a default empty.html for testing.

I called the config field: "merge" ... But tocP would prbably need a slightly different approach.

tocP will also need some refactoring, since it still uses the "old" """$param$""" approach. .. New toc uses <<__param__>>, which is a variable. ...

pmario commented 3 years ago

@rimi ... I'm not 100% sure, what you want to achieve. ... Can you be mores specific here?

There some more open issues https://github.com/wikilabs/plugins/issues?q=is%3Aissue+is%3Aopen+label%3Atocp ... that I probably should have a closer look at. ...