mgmeyers / obsidian-embedded-note-titles

GNU General Public License v3.0
58 stars 5 forks source link

Updates for Live Preview and setting format for daily note titles #17

Closed dcoales closed 2 years ago

dcoales commented 2 years ago

Hi, I've changed the code to do two things:

1) If we are in live preview mode then add a container div containing a dummy gutter and h1 title to the cm-editor section with styles to match the main content so the header aligns with the content. Each item has a specific className to help with styling. I've also added the corresponding className to the corresponding header in non live preview mode so that styles on that className work no matter what mode you are in. I had to added the extra div to the cm-editor area rather than cm-scroller which means that the header stays in place by default. However you can get around this by adding the following snippet: .embedded-note-titles .cm-scroller {
overflow-x: unset;
}
.embedded-note-titles .cm-editor {
overflow-y: auto;
}

2) Provide settings to allow users to decide if they would like to change the display format of daily note titles.

mgmeyers commented 2 years ago

Hey @dcoales! With the release of the new live preview plugin API, I was able to find a much cleaner way to get headings into the editor using the codemirror 6 API:

https://github.com/mgmeyers/obsidian-embedded-note-titles/blob/main/src/main.ts#L64-L94

Apologies for not using all the work you put into this. I still need to port over your changes for modifying dates in headings. I'll keep this PR open until I get that in.

dcoales commented 2 years ago

No worries. It didn't take that long (which is why it was such a hack and I always assumed there would be a cleaner way to do it :-) I'll take a look at how you've done it for future reference. Thanks.