Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add all Headings to every List-Item #2330

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

SpocWeb
Copy link

@SpocWeb SpocWeb commented May 14, 2024

In Response to #2290 and #2325 I have prepared this minimal Prototype.
@blacksmithgu Please consider this as a basis for discussion, I am not pushing for this exact Design,
but including the Heading Hierarchy would increase the Expressivity very much.

This adds a new List to every ListItem containing the path of containing Headings in strictly monotonously decreasing Levels.
This forms a kind of xPath or jsonPath to each List Item
and thus helps to organize multiple Lists within the same Markdown Document in markdown.ts:

export class ListItem {
    symbol: string;
    link: Link;
    section: Link;
    /** List of all Headings 'above' this one in ascending Order, to be able to properly group List Items */
    headings: HeadingCache[];
    ...

I am unsure on how to handle the serialize(cache: ListSerializationCache): SListItem-Operation in PageMetadada.tx (line 260)
It does not seem to support the Obsidian HeadingCache Class, so I am converting it to a List of Heading-Strings
with proper number of #s to indicate the correct Heading Level
headings: this.headings.map(h => "#".repeat(h.level) + " " + h.heading),

Best Regards and thank you for this powerful component. I am aware that there are many factors to consider for the evolution of the DataView.

@nirmalhk7
Copy link

Nicely done. I'd really like to have this merged.

@charle36
Copy link

Noob question, would this allow us to build queries with a placeholder for the query's heading(s)?

If so, one use case I can see is the ability to write a query with such a placeholder and then move/duplicate it in a board (from the Kanban plugin) and have the query automatically adjust in function of the column it's in. In addition, renaming a link in the heading would adjust the links in the properties without breaking the query. That would be a nice addition! (But again, noob question!)

@SpocWeb
Copy link
Author

SpocWeb commented Feb 19, 2025

renaming a link in the heading would adjust the links in the properties without breaking the query.

This could already be possible now using these task properties in dataview:

property Type Description
path Text The full path of the file this task is in. Equals to file.path for pages.
section Link Link to the section this task is contained in.
link Link Link to the closest linkable block near this task; useful for making links which go to the task.

@charle36
Copy link

This could already be possible now using these task properties in dataview:

Not as far as I know, there seems to be no way for a query to refer to its own heading or task at the moment, only its own file (with "this.").

@holroy
Copy link
Contributor

holroy commented Feb 23, 2025

This could already be possible now using these task properties in dataview:

Not as far as I know, there seems to be no way for a query to refer to its own heading or task at the moment, only its own file (with "this.").

It surely is possibly for both task and list item to refer to their section link, and access the closest heading of the given item.

This PR seems to be more on actually having the full list of headings it's under. Let's say you got an outline like H2 A | H3 AA | H2 B | H3 BB | a task instead of only seeing the H3 BB then get the full hierarchy of H2 B and H3 BB if that make sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants