mirror of
https://github.com/markusmo3/obsidian-private-mode.git
synced 2026-07-22 05:42:42 +00:00
parent
54e1b642d5
commit
d6acc5909f
4 changed files with 33 additions and 16 deletions
|
|
@ -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**
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
# 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)
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 72 KiB |
33
main.ts
33
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 = `<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xM
|
|||
|
||||
// https://icon-sets.iconify.design/ph/screencast/
|
||||
const screencastIcon = `<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path fill="currentColor" d="M232 56v144a16 16 0 0 1-16 16h-72a8 8 0 0 1 0-16h72V56H40v40a8 8 0 0 1-16 0V56a16 16 0 0 1 16-16h176a16 16 0 0 1 16 16M32 184a8 8 0 0 0 0 16a8 8 0 0 1 8 8a8 8 0 0 0 16 0a24 24 0 0 0-24-24m0-32a8 8 0 0 0 0 16a40 40 0 0 1 40 40a8 8 0 0 0 16 0a56.06 56.06 0 0 0-56-56m0-32a8 8 0 0 0 0 16a72.08 72.08 0 0 1 72 72a8 8 0 0 0 16 0a88.1 88.1 0 0 0-88-88"/></svg>`;
|
||||
|
||||
// https://icon-sets.iconify.design/ph/link/
|
||||
const linkIcon = `<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path fill="currentColor" d="M240 88.23a54.43 54.43 0 0 1-16 37L189.25 160a54.27 54.27 0 0 1-38.63 16h-.05A54.63 54.63 0 0 1 96 119.84a8 8 0 0 1 16 .45A38.62 38.62 0 0 0 150.58 160a38.4 38.4 0 0 0 27.31-11.31l34.75-34.75a38.63 38.63 0 0 0-54.63-54.63l-11 11A8 8 0 0 1 135.7 59l11-11a54.65 54.65 0 0 1 77.3 0a54.86 54.86 0 0 1 16 40.23m-131 97.43l-11 11A38.4 38.4 0 0 1 70.6 208a38.63 38.63 0 0 1-27.29-65.94L78 107.31a38.63 38.63 0 0 1 66 28.4a8 8 0 0 0 16 .45A54.86 54.86 0 0 0 144 96a54.65 54.65 0 0 0-77.27 0L32 130.75A54.62 54.62 0 0 0 70.56 224a54.28 54.28 0 0 0 38.64-16l11-11a8 8 0 0 0-11.2-11.34"/></svg>`;
|
||||
|
|
|
|||
11
styles.scss
11
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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue