I’d like to implement what’s described at this other post Hide or Truncate URLs in Editor using CSS? - Resolved help - Obsidian Forum to solve the problem explained there:
“Some URLs [in the editor view] are very long…Without having to use a URL shortener of some kind, is there some way to use CSS that could hide this from view in the editor?”
I tried the CSS solution found there, but while it shortens URLs beautifully, if you try to edit a URL, weird things happen instead:
- if you try to edit by mouse selection, the URL reverts to the symbol replacement
- if you try to use Backspace or Delete keys on the keyboard, it deletes text after the URL instead
- using the arrow keys, you can navigate the first line of the URL, but if the URL wraps to multiple lines, the cursor cannot go to the 2nd or later line (the URL will revert to the symbol)
I’m wondering if maybe the CSS worked in previous versions of Obsidian but is now broken.
Here’s the CSS in question:
font-size: 0;
}
div:not(.CodeMirror-activeline) > .CodeMirror-line .cm-string.cm-url:not(.cm-formatting)::after {
content: '🔗';
font-size: 1rem;
Edit: I think this is prob. how it always behaved. For now I’m using a link-shortening service as a workaround instead of the CSS.
Edit #2: At least the mouse-selecting portion of this bug was previously known. At the moment all of the buggy behavior is resolved by the CodeMirror Options plugin, mentioned here: CSS 'Active Line' Fails When Highlighting Text - #5 by jokysatria