diff --git a/README.md b/README.md index 3b06c0a..0519e6e 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,16 @@ Simple #private mode for [Obsidian](https://obsidian.md/). All files, links and **This plugin requires the obsidian plugin [Supercharged Links](https://github.com/mdelobelle/obsidian_supercharged_links) to work** -![docs/img.png](./docs/showcase_1.png) +![docs/showcase_1.png](docs/showcase_1.png) -![docs/img_1.png](./docs/showcase_2.png) +![docs/showcase_2.png](./docs/showcase_2.png) # Features * 3️⃣ Three Modes * Reveal all: to disable the blurring completely * Reveal on hover: only show #private content on hover (default) * Reveal never: only show #private content for the currently editing line +* 🔗 Blur also all links to #private files, or not, its your choice * 💻 By default not visible when using screenshare! Keep your secrets :) (desktop-only) * 📱 Supported on Obsidian Mobile * 🎀 Commands to set visibility (also usable on mobile) diff --git a/docs/showcase_1.png b/docs/showcase_1.png index 859c2df..6570449 100644 Binary files a/docs/showcase_1.png and b/docs/showcase_1.png differ diff --git a/main.ts b/main.ts index c15e64b..f15c814 100644 --- a/main.ts +++ b/main.ts @@ -4,13 +4,7 @@ * Licensed under the MIT License (http://opensource.org/licenses/MIT) */ -import { - addIcon, - Menu, - Platform, - Plugin, - setIcon, -} from "obsidian"; +import {addIcon, Menu, Platform, Plugin, setIcon,} from "obsidian"; enum Level { HidePrivate = "hide-private", @@ -21,7 +15,8 @@ enum Level { enum CssClass { RevealAll = "private-mode-reveal-all", RevealOnHover = "private-mode-reveal-on-hover", - UnprotectedScreenshare = "private-mode-unprotected-screenshare" + UnprotectedScreenshare = "private-mode-unprotected-screenshare", + BlurLinksToo = "private-mode-blur-links-too" } export default class PrivateModePlugin extends Plugin { @@ -29,6 +24,7 @@ export default class PrivateModePlugin extends Plugin { statusBarSpan: HTMLSpanElement; currentLevel: Level = Level.RevealOnHover; currentScreenshareProtection: boolean = true; + blurLinksToo: boolean = true; async onload() { this.statusBar = this.addStatusBarItem(); @@ -69,6 +65,17 @@ export default class PrivateModePlugin extends Plugin { }) ); menu.addSeparator() + menu.addItem((item) => + item + .setTitle('Blur Links too') + .setIcon('ph--link') + .setChecked(this.blurLinksToo) + .onClick(() => { + this.blurLinksToo = !this.blurLinksToo; + item.setChecked(!this.blurLinksToo) + this.updateGlobalRevealStyle(); + }) + ); menu.addItem((item) => item .setTitle('Visibility when screensharing') @@ -98,6 +105,7 @@ export default class PrivateModePlugin extends Plugin { addIcon("ph--eye-hand", eyeHand); addIcon("ph--eye-closed", eyeClosedIcon); addIcon("ph--screencast", screencastIcon); + addIcon("ph--link", linkIcon); this.addCommand({ id: "hide-private", @@ -176,7 +184,8 @@ export default class PrivateModePlugin extends Plugin { document.body.removeClass( CssClass.RevealAll, CssClass.RevealOnHover, - CssClass.UnprotectedScreenshare + CssClass.UnprotectedScreenshare, + CssClass.BlurLinksToo ); } @@ -184,6 +193,9 @@ export default class PrivateModePlugin extends Plugin { if (!this.currentScreenshareProtection) { document.body.classList.add(CssClass.UnprotectedScreenshare) } + if (this.blurLinksToo) { + document.body.classList.add(CssClass.BlurLinksToo) + } switch (this.currentLevel) { case Level.HidePrivate: setIcon(this.statusBarSpan, "ph--eye-closed") @@ -212,3 +224,6 @@ const eyeIcon = ``; + +// https://icon-sets.iconify.design/ph/link/ +const linkIcon = ``; diff --git a/styles.scss b/styles.scss index 1169a36..ba6afa3 100644 --- a/styles.scss +++ b/styles.scss @@ -9,11 +9,11 @@ } $element-selectors: ( - ".data-link-text[data-link-tags*='#private']:not(.tree-item-inner,.suggestion-title)": 1, // Link items - ".dataview tr:has(a[data-link-tags*='#private'])": 1, // dataview tables - ".suggestion-item:has([data-link-tags*='#private'])": 1, // Search results - ".nav-file-title:has([data-link-tags*='#private'])": 1, // "Files" tree - ".search-result:has([data-link-tags*='#private'])": 1, // Sidebar search + "body.private-mode-blur-links-too .data-link-text[data-link-tags*='#private']:not(.tree-item-inner,.suggestion-title)": 1, // Link items + "body.private-mode-blur-links-too .dataview tr:has(a[data-link-tags*='#private'])": 1, // dataview tables + "body.private-mode-blur-links-too .suggestion-item:has([data-link-tags*='#private'])": 1, // Search results + "body.private-mode-blur-links-too .nav-file-title:has([data-link-tags*='#private'])": 1, // "Files" tree + "body.private-mode-blur-links-too .search-result:has([data-link-tags*='#private'])": 1, // Sidebar search ".workspace-tabs:has(.is-active [data-link-tags*='#private']) .inline-title": 1, ".workspace-tabs:has(.is-active [data-link-tags*='#private']) .cm-line": 1, @@ -60,6 +60,7 @@ body.private-mode-reveal-on-hover .callout[data-callout="private"]:not(.is-colla filter: none; } +/* screenshare protection */ body.private-mode-unprotected-screenshare .status-bar-item.plugin-private-mode { color: var(--text-error); }