react-client
react-client copied to clipboard
Externals Syntax for CodiMD (Internal) or HackMD Notes
Editing and previewing in Night Theme is currently all great, but the published note keeps its bright white background, and there seems to be no settings that can toggle it for now.
My current workaround is copy and pasting the entire <style> ... </style>
code from https://hackmd.io/hackmd-dark-theme to my CodiMD note, which is quite lengthy, and it feels awkward to do this on every note I intend to publish later on.
With HackMD, we're able to use {%hackmd noteid %}
to include content from other HackMD notes, and I'm a big fan of this particular dark theme hack. Will this become a supported feature for CodiMD as well? Also, would it be practical for syntax {%codimd noteid %}
to look up notes within the local server?
I like the idea. I'm currently not sure what would be the best way to embed them, but the basic idea is definitely nice.
You're describing two separate issues.
- You want to enable dark mode for the view-only/publish mode.
- You want an include tag to insert code from another document.
Am I right?
As far as I can see @ErikMichelson introduced the dark / light toogle for the view mode in https://github.com/codimd/react-client/pull/563 so this should fix 1. at least somewhat. I don't think the theme should be dictated by the user sending the link, but by the prefernces of the user opening the link (light per default and possibly dark if the user configured it on the particular instance)
I'm currently thinking about 2.:
I guess we would need to decide on three questions:
- What syntax should we use?
@alfieyfc suggested
{%codimd noteid %}
maybe we could use{%hedgedoc noteid %}
. This could be done, but we mostly removed{% %}
this syntax. We could also just find and replace single line links like we do with youtube, vimeo and asciinema. - How should we implement this? I guess including the other pads in an interactive way would be problematic, because we would have to maintain multiple WS connections. So I'd suggest to just grab the text via http and include it in somekind of frame. So in the editor there would be just the one line and the renderer would show the content in a small frame (maybe with a link to the actual note at the top)
- How do we handle recursion? Loop detection? We could just don't render includes in includes. That way one note can only include multiple other notes, but these can't include any other nodes or at least they won't be rendered (just leave the single line link).
You're describing two separate issues.
- You want to enable dark mode for the view-only/publish mode.
- You want an include tag to insert code from another document.
Am I right?
I would say I'm describing 2.
and only using my dark view-only/publish
workaround as a practical example.
To be more specific, I was looking for:
- include tag to insert code from another codimd document (eg.
{%codimd noteid %}
)
and perhaps also hoping for:
- include tag to insert code from a hackmd document (eg.
{%hackmd noteid %}
)
What I had in mind when opening the feature request was exactly as @DerMolly said: We could also just find and replace single line links like we do with youtube, vimeo and asciinema.
But as for now, my coding skills aren't good enough to decide how should we go with this 😓
How do we handle recursion? Loop detection?
I just tried this scenario on hackmd
-
When including itself, it definitely crashes my notebook in several ways:
- Can't edit note while it's struggling with embedding itself
- Account status keeps logging online and offline, despite stable internet connection
-
When including other notes that includes further notes, it works like a charm (from what I've tried)
Thank for the update @alfieyfc.
and perhaps also hoping for:
include tag to insert code from a hackmd document (eg. {%hackmd noteid %})
I'm not sure we want or even can include this as a lot of the syntax changed with 2.0 and we would basically need to include everything hackmd implements in the future to keep up.
When including other notes that includes further notes, it works like a charm (from what I've tried)
Note A: includes hackmd Dark Them Note B: includes Note A Note C: includes Note B
Interesting. I think if we want to introduce this feature we should work with a maximum inclusion depth (maybe something like 3) and we would need to include loop detection (depending on the inclusion depth implementation this could already be solved by that). Handling this feature wrong (either by accident or on purpose) should not break the note.
Just a side note: I think a hard limit of the inclusion depth will limit functionality. I can imagine use cases where you would need more.
I'd prefer a server setting for a maximum display depth which then asks the user if they want to open other levels. It might be also an idea to add an option whether a note should be unfolded or minimized by default.
Given these two features (deep note linking) and folding / unfolding settings, users could even achieve some workflow similar to https://workflowy.com/ without having a dedicated solution for that. And with Markdown support. It'd be awesome :wink: