deathau / cm-show-whitespace-obsidian Goto Github PK
View Code? Open in Web Editor NEWA plugin for [Obsidian](https://obsidian.md) which shows whitespace in the editor.
A plugin for [Obsidian](https://obsidian.md) which shows whitespace in the editor.
Hi!
In the new version of Obsidian 0.13.14 non-printable characters are not visible.
Pls update.
Not sure how this would best be implemented but it would be really cool if this could work with the live preview editor as well! Maybe showing only non-previewed whitespaces? Currently none are shown at all.
I think it would be useful to allow show whitespace to be toggled through ctrl/cmd+p rather than enabling and disabling the plugin.
I tried the plugin on Android, and it doesn't seem to do anything.
Additionally I found this while loading inspecting with the Chrome adb debugger:
Uncaught TypeError: cm.setOption is not a function
at eval (eval at <anonymous> (app.js:1), <anonymous>:139:64)
at app.js:1
at t.iterateLeaves (app.js:1)
at t.iterateLeaves (app.js:1)
at t.iterateAllLeaves (app.js:1)
at t.iterateCodeMirrors (app.js:1)
at CMShowWhitespacePlugin.t.registerCodeMirror (app.js:1)
at CMShowWhitespacePlugin._this.enable (eval at <anonymous> (app.js:1), <anonymous>:139:19)
at t.e.tryTrigger (app.js:1)
at t.e.trigger (app.js:1)
This plugin doesn't do anything on 1.1.16 (installer 1.1.16).
Subject
Hard to explain, therefore I mad a short screen recording of the issue.
Back when I added settings for specific whitespace characters there was not an official way to disable settings so I used this css hack and created a request on their API github obsidianmd/obsidian-api#8
.plugin-cm-show-whitespace-disabled {
opacity: 0.6;
.checkbox-container {
cursor: not-allowed;
// this is *not* an adequate way to disable an input but it's all we can do right now
pointer-events: none;
}
}
There is now an official way in the API to disable a setting using setDisabled
on both Setting and Component level. This section should be updated to use the new method.
I've just installed this plugin and switched to Legacy editor, having been bitten by some hidden NBSP
characters copied for a GitHub issue which caused me confusion in a Tasks plugin issue
This is what I hoped that this plugin would display - as screenshotted in PyCharm:
This is what it actually displayed...
That is, the NBSP
is indistinguishable from an ordinary space.
Hi folks, I have gathered the following snippet to make this plugin work with Obsidian v1.3.7 (more or less, I forgot how it used to work and wrote it for my own needs). Please feel free to use and make changes. Cheers.
Edit: The br
fixes do not work on iOS.
Edit 2: Added new line indicators for non-empty lines.
Please consult the doc if you are new to the snippets.
body.plugin-cm-show-whitespace [class*=cm-trailing-space]::after,
body.plugin-cm-show-whitespace [class*=cm-trailing-space]::before {
color: var(--text-muted);
}
.cm-line br {
content: " ";
display: inline-block;
}
.cm-line br::after,
.cm-line:not(:has(br)):not(:has(.cm-trailing-space-new-line))::after {
content: var(--newlineChar);
white-space: pre;
pointer-events: none;
color: var(--text-muted);
font-weight: normal;
opacity: 0.5;
padding-inline-start: 2px;
}
Hey!
So i normally use this for my check box CSS:
/* ...... 2.7.1 Nicer Round Checkboxes -- https://forum.obsidian.md/t/meta-post-common-css-hacks/1978/34 */
input[type="checkbox"],
.cm-formatting-task {
-webkit-appearance: none;
appearance: none;
border-radius: 50%;
border: 1px solid var(--text-faint);
padding: 0;
vertical-align: top;
}
.cm-s-obsidian span.cm-formatting-task {
color: transparent;
width: 1.25em !important;
height: 1.25em;
display: inline-block;
}
input[type="checkbox"]:focus {
outline: 0;
}
input[type="checkbox"]:checked,
.cm-formatting-task.cm-property {
background-color: var(--text-accent-hover);
border: 1px solid var(--text-accent-hover);
background-position: center;
background-size: 70%;
background-repeat: no-repeat;
background-image: url('data:image/svg+xml; utf8, <svg width="12px" height="10px" viewBox="0 0 12 8" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g transform="translate(-4.000000, -6.000000)" fill="%23ffffff"><path d="M8.1043257,14.0367999 L4.52468714,10.5420499 C4.32525014,10.3497722 4.32525014,10.0368095 4.52468714,9.8424863 L5.24777413,9.1439454 C5.44721114,8.95166768 5.77142411,8.95166768 5.97086112,9.1439454 L8.46638057,11.5903727 L14.0291389,6.1442083 C14.2285759,5.95193057 14.5527889,5.95193057 14.7522259,6.1442083 L15.4753129,6.84377194 C15.6747499,7.03604967 15.6747499,7.35003511 15.4753129,7.54129009 L8.82741268,14.0367999 C8.62797568,14.2290777 8.3037627,14.2290777 8.1043257,14.0367999"></path></g></g></svg>');
}
and normal appearance in edit/preview is thus:
When i have the whitespace plugin installed (not even active) this is what displays in edit mode only, preview mode is normal:
uninstalled the plugin and reinstalled, same issue. using latest versions of plugin and obsidian and no errors appear in the developer console
Would it be possible to add an option to only show whitespace at the end of a line? Similar to what you might use in a code editor.
Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.