datopian / datahub

🌀 Rapidly build rich data portals using a modern frontend framework
https://datahub.io/opensource
MIT License
2.17k stars 322 forks source link

Obsidian-style foldable callout syntax (e.g. "![Info]- Title") ( Duplicate of #1060) #1070

Open marcchehab opened 3 months ago

marcchehab commented 3 months ago

This adds Obsidian-style foldable callout syntax, as described here: https://help.obsidian.md/Editing+and+formatting/Callouts#Foldable+callouts

Please note that I tested this in my customized Flowershow, so maybe the CSS I added for the padding isn't what you need!

Kind regards from Zurich!

Marc

As promised: A new PR from a branch, so I can mess with my main branch.

changeset-bot[bot] commented 3 months ago

⚠️ No Changeset found

Latest commit: 943866a6d2260681c2b97d425d5b57e2509faef4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

vercel[bot] commented 3 months ago

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

Name Status Preview Comments Updated (UTC)
portaljs-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 4, 2024 9:04pm
site-portaljs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 4, 2024 9:04pm
4 Ignored Deployments | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **portaljs-alan-turing** | ⬜️ Ignored ([Inspect](https://vercel.com/datopian1/portaljs-alan-turing/EJLmsseo9nhyz4zb5nTXPFcVEvoE)) | [Visit Preview](https://portaljs-alan-turing-git-fork-marcchehab-folda-2f189a-datopian1.vercel.app) | | Apr 4, 2024 9:04pm | | **portaljs-ckan** | ⬜️ Ignored ([Inspect](https://vercel.com/datopian1/portaljs-ckan/4nFPK3gYcCBoZgzQ33PcnPCmhUig)) | [Visit Preview](https://portaljs-ckan-git-fork-marcchehab-foldable-callouts-datopian1.vercel.app) | | Apr 4, 2024 9:04pm | | **portaljs-git-example** | ⬜️ Ignored ([Inspect](https://vercel.com/datopian1/portaljs-git-example/9CxjHENgediYY38rFAmvCvZ98yqF)) | [Visit Preview](https://portaljs-git-example-git-fork-marcchehab-folda-ca01f5-datopian1.vercel.app) | | Apr 4, 2024 9:04pm | | **portaljs-learn** | ⬜️ Ignored ([Inspect](https://vercel.com/datopian1/portaljs-learn/CKU2VreBWGCWJUdt2hWN9t2wcYq9)) | [Visit Preview](https://portaljs-learn-git-fork-marcchehab-foldable-callouts-datopian1.vercel.app) | | Apr 4, 2024 9:04pm |
vercel[bot] commented 3 months ago

@marcchehab is attempting to deploy a commit to the Datopian Team on Vercel.

A member of the Team first needs to authorize it.

olayway commented 3 months ago

Hello @marcchehab! Thank you so much for waiting so patiently for our review! 🙏 🌸 I'll make sure we merge your code ASAP!

As for the missing arrows: they are just not positioned correctly. Since the pseudo-elements are "absolutely" positioned, they need some "relative" ancestor. And so they show up after adding position: relative to .callout-title class.

image

However, as you can see, they are not perfectly centered vertically. This can be fixed with CSS though to achieve this:

image

See my suggestions to your CSS styles.

:trophy: Would be nice to have a simple test for this feature in test/remark-callouts.spec.ts, but it's not required.

Overall, great work, and I can't wait to have it shipped! :rocket:

marcchehab commented 3 months ago

@olayway thanks for your kind corrections 🥳 I'll immediately port those to my main branch 😬 I'll have a look if I can write a testfile, I'll have to figure out how to use mocha with ts.

Btw: Once we merge this, I can ship another PR to correct a bug in callouts (if something in the title inserts a new element, e.g. a bold text, it breaks the title)

marcchehab commented 3 months ago

I can't get mocha to run, so I can't write tests... (Among other things I tried to run mocha in packages/remark-callouts, but no success so far, even though its clearly using your .mocharc.yaml)

olayway commented 3 months ago

I can't get mocha to run, so I can't write tests... (Among other things I tried to run mocha in packages/remark-callouts, but no success so far, even though its clearly using your .mocharc.yaml)

@marcchehab Thank you for giving it a go! Try running this in the root of the repo:

pnpm i
pnpm nx test remark-callouts