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

Feat: allow link to section mark #7744

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

Conversation

linonetwo
Copy link
Contributor

@linonetwo linonetwo commented Sep 15, 2023

This is block-level link. Prepare for block-level backlink. (wait for #6081 so I can continue modify back-indexer)

Add a new ^id syntax, see #7537 for details.

Also modify pretty wiki link's parsing rule to allow link to such an id. And modify link widget to allow id widget to react to link jumping.

(Currently, if New Tiddler is not currently opened, hookFocusElementEvent can't highlight the element, I have to use setTimeout to wait for the dom element actually show. Is there a better solution?)

And sadly, we can't use #xxx as ID, otherwise will encounter Invalid selector: ##BlockLevelLinksID1

Demo: https://tiddlywiki5-bsqd5sfir-jermolenes-projects.vercel.app/#Block%20Level%20Links%20in%20WikiText:%5B%5BBlock%20Level%20Links%20in%20WikiText%5D%5D%20%5B%5BLinking%20in%20WikiText%5D%5D

title: New Tiddler 1

[[New Tiddler^sdfd]]

[[New Tiddler^bbbb]]

[[ddd|New Tiddler^ddd]]

sdfa
title: New Tiddler

\```css
.main {
  display: none;
}
\```

^sdfd

asfd ^bbbb

* adfgd ^ccc
** dsaffda ^ddd
** adsfad

@vercel
Copy link

vercel bot commented Sep 15, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
tiddlywiki5 ✅ Ready (Inspect) Visit Preview Jun 9, 2024 3:44pm

@kookma
Copy link
Contributor

kookma commented Sep 16, 2023

This is a minor comment: The highlighted color would be nice to follow the palette in use.
This is another minor comment: a toolbar button/shortcut to create unique/sequence number or identifier when creating section mark.

@kookma
Copy link
Contributor

kookma commented Sep 16, 2023

Some use cases:

  1. with footnotes, click to show the footnote at the tiddler bottom
  2. with references like refnotes, click to highlight the reference in the bibliograpgy/references tiddler
  3. partial transclusion when start and end of section is defined

@linonetwo
Copy link
Contributor Author

linonetwo commented Sep 16, 2023

The highlighted color would be nice to follow the palette in use.

Sure, I'm using the existing <<colour highlight-background>>, I'm not sure if there are some better configurable alternatives.

https://github.com/Jermolene/TiddlyWiki5/blob/07130c2ad094dcb04c65fb8ce8496a40afb8a2ac/themes/tiddlywiki/vanilla/base.tid#L2416-L2420

a toolbar button/shortcut to create unique/sequence number or identifier

I'm not sure if this is necessary, I will auto create id on target tiddler, when you write a link in another, when using the WYSIWYG editor (or maybe codemirror-enhannced), this is the UX of Obsidian. While it is reasonable to fall back to a menu button, if user is using empty edition, but that will have a huge UX gap between Obsidian.

footnotes

Yes, it can be used to write footnotes and in refnotes. But its main purpose is for block-level backlinks, and block-level transclusion, like in Obsidian. We need to have all that they have!

partial transclusion when start and end of section is defined

I think Obsidian can only transclude a single block. I'm not sure if transclude syntax can be extended to reference 2 id to create a reference...

@kookma
Copy link
Contributor

kookma commented Sep 16, 2023

Sure, I'm using the existing <<colour highlight-background>>, I'm not sure if there are some better configurable alternatives.

I think this is good to go!

I think Obsidian can only transclude a single block.

That is fine.

Thank you

@linonetwo
Copy link
Contributor Author

linonetwo commented Sep 22, 2023

Done a refactor, to make use of deeper tw core history mechanism, instead of simply using hooks.

I don't think it is good to update codeblock/html/commentblock/quoteblock/styleblock/table/typedblock/horizrule , to allow ends with (?:\n|$|([ ]\^(\S+)$|^\^(\S+)$)) is a good idea now, so I have to keep the previousSibling logic. But you can see the syntax is easy to remember, won't be much confusion.

截屏2023-09-22 23 23 58

@Jermolene

@linonetwo
Copy link
Contributor Author

@Jermolene Please review this again! A qq group member ask for paragraph level transclusion, but I can't implement it without this syntax.
And I want this to be official, so more plugins can interoperate on this.

@linonetwo
Copy link
Contributor Author

with this PR, I can implement obsidian plugin like this
Image_1708164307648.jpg

@pmario
Copy link
Member

pmario commented Feb 17, 2024

@Jermolene ... I think this PR would be a nice feature.

@CrossEye
Copy link
Contributor

@pmario: Somehow I missed this comment months ago:

@CrossEye -- Can you have a closer look at this one. IMO it's related to your implementation of the permalink creation.

While I will dig into the actual code when I'm not on mobile, I don't really see how this would be related. At a feature level, they don't have much in common. Are there similar implementation ideas?

@dongrentianyu
Copy link

@Jermolene Could you check this request again? I really wish tiddlywiki would make this possible.

@linonetwo
Copy link
Contributor Author

@Jermolene Could you check this before 5.2.4?

@dongrentianyu
Copy link

@Jermolene we need you to check this pr.

@Jermolene
Copy link
Member

Hi @linonetwo thank you for your continued work on this. I recognise that there is a strong user demand for anchors and I am keen to get them into the core.

Two areas that I think need more work is documentation and tests. There should definitely be tests for the new parse rules, and it may be possible to create a rig so that the navigation can be tested too.

I am also concerned how this implementation will work with static renderings. For example, anchor links should work within a static rendering such as https://tiddlywiki.com/alltiddlers.html. There are obviously some interactive features that we cannot support in static renderings, but basic link navigation needs to work as expected.

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.

6 participants