HeroBlackInk / ultimate-todoist-sync-for-obsidian

GNU General Public License v3.0
145 stars 20 forks source link

Single Line Comments in Language Block Codes are hidden #69

Open ebouchut opened 10 months ago

ebouchut commented 10 months ago

πŸ‘ First off thank you @HeroBlackInk for this useful plugin.

I noticed the following issue.

Summary

When editing a note with a single-line comment in a language code block, with Ultimate Todoist Sync for Obsidian plugin enabled, then the comment is not shown (whatever the value of Editing Mode (Live Preview or Source mode)).

Description of the Issue

When I type this in an Obsidian note:

```java
// Single-line comment

Then I **expect**, the `// Single-line comment` to be shown in the editor, like so

```java
// Single-line comment

❌ Whereas it is not when Ultimate Todoist Sync for Obsidian is enabled whatever the value of Editing Mode (Live Preview or Source mode), and I get this instead.

FYI, the issue is the same for a single-line comment in a Ruby code block.

```ruby
# Single-line comment

βœ… When I disable the `Ultimate Todoist Sync for Obsidian` plugin, the comment is shown as expected.

## How to Reproduce this Issue?

- Create a new Obsidian Vault
- Install and enable the `Ultimate Todoist Sync for Obsidian` plugin
- Create a new note and paste this
  // Single-line comment
MAWSpitau commented 9 months ago

I do have the same problem, but with HTML-comments like:

<!-- Kommentar -->

This is what the hidden line looks like...

I would love to have this Bug fixed and see my comments again ;)

MAWSpitau commented 9 months ago

You can fix this with this workaround:

Change this: .cm-line:not(:hover):not(.cm-active) span.cm-comment { display: none; } to this: /* .cm-line:not(:hover):not(.cm-active) span.cm-comment { display: none; } */

What it does:

ebouchut commented 9 months ago

πŸ‘ Thank you @MAWSpitau for this workaround.

ebouchut commented 9 months ago

🧐 I will try to build a CSS selector to only target/hide the Todoist comments.

ebouchut commented 9 months ago

I have a CSS rule handy to hide the start and end Obsidian comment surrounding the todoist_id.

.cm-line:not(:hover):not(.cm-active) > .cm-comment.cm-comment-start:has(~ .dataview.inline-field > .dataview.inline-field-key[data-dv-key="todoist_id"]),
.cm-line:not(:hover):not(.cm-active) > .cm-comment.cm-comment-start:has(~ .dataview.inline-field > .dataview.inline-field-key[data-dv-key="todoist_id"]) ~ .cm-comment.cm-comment-end
{
    display: none;
}

βœ… This fixed the issue for me, it:

It is brittle because it depends on the CSS classes of the Tasks Obsidian plugin.

@MAWSpitau and anyone else interested, let me know if this works for you.

Tejeev commented 5 months ago

I also see this, so I like having a fix. Thank you! I've tried the fix, and it does not hide the todoist_id, so I've elected to just comment out the comment hiding CSS from styles.css for the time being. Either way, I'm grateful to have my comments back, so thank you guys :)

Regarding the final fix, I know my preferences are just that, mine, but I thought I'd share them just in case they are useful.

On a related note, I'm not sure if it's my mistake or some bug but I'm always able to see the todoist_id in edit mode, though the %% are hidden when not moused over or editing the line. I haven't had time to investigate this yet.