I’m taking a stab at my first plugin, toggling the display of completed tasks, and I’d like to programmatically toggle a css property (.markdown-preview-view li.task-list-item.is-checked adding display: none).
I see that this.app has a customCss property, so my hope is there’s a way to add or remove rules there, but I didn’t see this in the developer docs.
Yep, I cloned the repo and added the custom css – works perfectly. The feature I’d like to add is a UI element that allows the user to toggle display on and off.
If you want a global toggle, have the command do something like document.body.toggleClass("hide-completed-tasks") and have your CSS rule key off of body.hide-completed-tasks .markdown-preview-view li.task-list-item.is-checked.
If you want a per-pane toggle, have the command call toggleClass() on the .containerEl of the .activeLeaf of this.app.workspace, and use div.hide-completed-tasks in place of body.hide-completed-tasks in the CSS.