├── .editorconfig
├── .eslintignore
├── .eslintrc
├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── .yamllint.yaml
│ ├── bug_report.yml
│ └── feature_request.yml
├── pull_request_template.md
└── workflows
│ └── release.yml
├── .gitignore
├── .release.sh
├── Changelog.md
├── LICENSE
├── README.md
├── esbuild.config.mjs
├── main.ts
├── manifest.json
├── package.json
├── styles.css
├── tsconfig.json
└── versions.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | # top-most EditorConfig file
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | insert_final_newline = true
7 | indent_style = tab
8 | indent_size = 4
9 | tab_width = 4
10 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | npm node_modules
2 | build
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "parser": "@typescript-eslint/parser",
4 | "plugins": ["@typescript-eslint"],
5 | "extends": [
6 | "eslint:recommended",
7 | "plugin:@typescript-eslint/eslint-recommended",
8 | "plugin:@typescript-eslint/recommended"
9 | ],
10 | "parserOptions": {"sourceType": "module"},
11 |
12 | "rules": {
13 | // specifically for Obsidian Plugins
14 | "@typescript-eslint/no-unused-vars": "off",
15 | "@typescript-eslint/ban-ts-comment": "off",
16 | "@typescript-eslint/no-extra-semi": "warn",
17 | "@typescript-eslint/no-empty-function": "warn",
18 | "no-shadow": ["error", { "builtinGlobals": true, "hoist": "all", "allow": ["Editor"] }],
19 |
20 | //-----------------------------------
21 | //-----------------------------------
22 | //-----------------------------------
23 |
24 | // Variables
25 | "camelcase": ["error", {"properties": "always", "ignoreImports": true}],
26 | "no-var": "error",
27 | "prefer-const": "warn",
28 | "sort-vars": "warn",
29 | // "no-use-before-define": "error",
30 | "no-multi-assign": "error",
31 | "no-sequences": "error",
32 | "no-undefined": "error",
33 | "one-var-declaration-per-line": ["error", "initializations"],
34 |
35 | // Regex
36 | "prefer-regex-literals": ["error", {"disallowRedundantWrapping": true}],
37 |
38 | // Spacing
39 | "no-mixed-spaces-and-tabs": "warn",
40 | "no-empty-function": "warn",
41 | "indent": ["warn", "tab", { "SwitchCase": 1 } ],
42 | "no-multi-spaces": "warn",
43 | "array-bracket-spacing": "warn",
44 | "space-before-blocks": "warn",
45 | "semi-spacing": "warn",
46 | "object-curly-spacing": ["warn", "always"],
47 | "no-whitespace-before-property": "error",
48 | "no-empty": "warn",
49 | "arrow-spacing": "warn",
50 | "keyword-spacing": "warn",
51 | "spaced-comment": ["warn", "always", { "exceptions": ["-", "_"] }],
52 |
53 | // Line Breaks
54 | "object-curly-newline": ["warn", { "multiline": true }],
55 | "newline-per-chained-call": ["error", { "ignoreChainWithDepth": 2 }],
56 | "no-multiple-empty-lines": ["warn", { "max": 2 } ],
57 |
58 | // Brackets
59 | "no-extra-parens": ["warn", "all", { "returnAssign": false }],
60 | "curly": ["warn", "multi-or-nest"],
61 |
62 | // Arrays
63 | "array-callback-return": ["error", { "checkForEach": false, "allowImplicit": true }],
64 |
65 | // Loops
66 | "no-unmodified-loop-condition": "error",
67 | "no-unreachable-loop": "error",
68 | "no-await-in-loop": "error",
69 |
70 | // async/await
71 | "require-atomic-updates": "error",
72 |
73 | // return
74 | "no-useless-return": "error",
75 |
76 | // Semicolon & Comma
77 | "no-extra-semi": "warn",
78 | "semi-style": ["error", "last"],
79 | "semi": ["warn", "always", {"omitLastInOneLineBlock": true }],
80 | "comma-spacing": "warn",
81 | "comma-style": "warn",
82 | "comma-dangle": ["error", {"arrays": "never", "objects": "only-multiline" }],
83 |
84 | // Strings & Numbers
85 | "quotes": ["warn", "double", {"avoidEscape": true}],
86 | "no-useless-concat": "warn",
87 | "no-multi-str": "error",
88 | "no-magic-numbers": ["error", { "ignore": [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 1000, 10000], "ignoreArrayIndexes": true }],
89 | "no-floating-decimal": "warn",
90 | "no-implicit-coercion": "error",
91 |
92 | // Conditions
93 | "eqeqeq" : "error",
94 | "no-eq-null" : "error",
95 | "no-negated-condition": "error",
96 | "no-unneeded-ternary": "error",
97 | "no-nested-ternary": "error",
98 | "yoda": "warn",
99 | "no-mixed-operators": "error",
100 | "no-else-return": ["error", { "allowElseIf": false} ],
101 | "no-lonely-if": "error",
102 |
103 | // Imports
104 | "no-duplicate-imports": "warn",
105 | "sort-imports": "warn",
106 |
107 | // Misc
108 | "dot-notation": "error"
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/displaying-a-sponsor-button-in-your-repository
2 |
3 | custom: https://www.paypal.me/ChrisGrieser
4 | ko_fi: pseudometa
5 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/.yamllint.yaml:
--------------------------------------------------------------------------------
1 | # https://yamllint.readthedocs.io/en/stable/configuration.html#extending-the-default-configuration
2 | extends: default
3 |
4 | yaml-files:
5 | - '*.yaml'
6 | - '*.yml'
7 |
8 | rules:
9 | line-length: disable
10 | document-start: disable
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.yml:
--------------------------------------------------------------------------------
1 | name: Bug Report
2 | description: File a bug report
3 | title: "[Bug]: "
4 | labels: ["bug"]
5 | body:
6 | - type: textarea
7 | id: bug-description
8 | attributes:
9 | label: Bug Description
10 | description: A clear and concise description of the bug.
11 | validations:
12 | required: true
13 | - type: textarea
14 | id: screenshot
15 | attributes:
16 | label: Relevant Screenshot
17 | description: If applicable, add screenshots or a screen recording to help explain your problem.
18 | - type: textarea
19 | id: reproduction-steps
20 | attributes:
21 | label: To Reproduce
22 | description: Steps to reproduce the problem
23 | placeholder: |
24 | For example:
25 | 1. Go to '...'
26 | 2. Click on '...'
27 | 3. Scroll down to '...'
28 | - type: input
29 | id: obsi-version
30 | attributes:
31 | label: Obsidian Version
32 | description: You can find the version in the *About* Tab of the settings.
33 | placeholder: 0.13.19
34 | validations:
35 | required: true
36 | - type: checkboxes
37 | id: editor
38 | attributes:
39 | label: Which editor are you using?
40 | options:
41 | - label: New Editor
42 | - label: Legacy Editor
43 | - type: checkboxes
44 | id: checklist
45 | attributes:
46 | label: Checklist
47 | options:
48 | - label: I updated to the latest version of the plugin.
49 | required: true
50 |
51 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.yml:
--------------------------------------------------------------------------------
1 | name: Feature request
2 | description: Suggest an idea
3 | title: "Feature Request: "
4 | labels: ["feature request"]
5 | body:
6 | - type: textarea
7 | id: feature-requested
8 | attributes:
9 | label: Feature Requested
10 | description: A clear and concise description of the feature.
11 | validations:
12 | required: true
13 | - type: textarea
14 | id: screenshot
15 | attributes:
16 | label: Relevant Screenshot
17 | description: If applicable, add screenshots or a screen recording to help explain the request.
18 | - type: checkboxes
19 | id: checklist
20 | attributes:
21 | label: Checklist
22 | options:
23 | - label: The feature would be useful to more users than just me.
24 | required: true
25 |
26 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | ## Description of the Change
2 |
3 |
4 | ## Checklist
5 | - [ ] Used the provided eslint configuration, [as explained in the Readme](README.md#Contribute).
6 | - [ ] Did *not* use prettier.
7 | - [ ] Used expressive variable names.
8 | - [ ] Code is commented well.
9 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release Obsidian plugin
2 |
3 | on:
4 | push:
5 | tags:
6 | - "*"
7 |
8 | env:
9 | PLUGIN_NAME: obsidian-sidebar-toggler # Change this to match the id of your plugin.
10 |
11 | jobs:
12 | build:
13 | runs-on: ubuntu-latest
14 |
15 | steps:
16 | - uses: actions/checkout@v2
17 | - name: Use Node.js
18 | uses: actions/setup-node@v1
19 | with:
20 | node-version: "17.x" # node version, get via `node --version`
21 |
22 | - name: Build
23 | id: build # remove styles.css in cp line, if it isn't used
24 | run: |
25 | npm install
26 | npm run build
27 | mkdir ${{ env.PLUGIN_NAME }}
28 | cp main.js manifest.json ${{ env.PLUGIN_NAME }}
29 | zip -r ${{ env.PLUGIN_NAME }}.zip ${{ env.PLUGIN_NAME }}
30 | ls
31 | echo "::set-output name=tag_name::$(git tag --sort version:refname | tail -n 1)"
32 |
33 | - name: Create Release
34 | id: create_release
35 | uses: actions/create-release@v1
36 | env:
37 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 | VERSION: ${{ github.ref }}
39 | with:
40 | tag_name: ${{ github.ref }}
41 | release_name: ${{ github.ref }}
42 | draft: false
43 | prerelease: false
44 |
45 | - name: Upload zip file
46 | id: upload-zip
47 | uses: actions/upload-release-asset@v1
48 | env:
49 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50 | with:
51 | upload_url: ${{ steps.create_release.outputs.upload_url }}
52 | asset_path: ./${{ env.PLUGIN_NAME }}.zip
53 | asset_name: ${{ env.PLUGIN_NAME }}-${{ steps.build.outputs.tag_name }}.zip
54 | asset_content_type: application/zip
55 |
56 | - name: Upload main.js
57 | id: upload-main
58 | uses: actions/upload-release-asset@v1
59 | env:
60 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61 | with:
62 | upload_url: ${{ steps.create_release.outputs.upload_url }}
63 | asset_path: ./main.js
64 | asset_name: main.js
65 | asset_content_type: text/javascript
66 |
67 | - name: Upload manifest.json
68 | id: upload-manifest
69 | uses: actions/upload-release-asset@v1
70 | env:
71 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72 | with:
73 | upload_url: ${{ steps.create_release.outputs.upload_url }}
74 | asset_path: ./manifest.json
75 | asset_name: manifest.json
76 | asset_content_type: application/json
77 |
78 | # - name: Upload styles.css
79 | # id: upload-css
80 | # uses: actions/upload-release-asset@v1
81 | # env:
82 | # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83 | # with:
84 | # upload_url: ${{ steps.create_release.outputs.upload_url }}
85 | # asset_path: ./styles.css
86 | # asset_name: styles.css
87 | # asset_content_type: text/css
88 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # npm
2 | node_modules
3 | package-lock.json
4 |
5 | # obsidian
6 | data.json
7 | main.js
8 |
9 | # Mac
10 | .DS_Store
11 |
12 | # Info for me
13 | Info for me.md
14 |
--------------------------------------------------------------------------------
/.release.sh:
--------------------------------------------------------------------------------
1 | #!/bin/zsh
2 |
3 | # Release Obsidian Plugin
4 | # https://forum.obsidian.md/t/using-github-actions-to-release-plugins/7877
5 | # https://marcus.se.net/obsidian-plugin-docs/publishing/release-your-plugin-with-github-actions
6 |
7 | # Requirements
8 | # - markdownlint
9 | # - eslint
10 |
11 | # ensure relevant files exist
12 | if [[ ! -f "./manifest.json" ]] ; then
13 | echo "manifest.json does not exist yet"
14 | exit 1
15 | fi
16 | if [[ ! -f "./versions.json" ]] ; then
17 | echo "versions.json does not exist yet"
18 | exit 1
19 | fi
20 | if [[ ! -f "./package.json" ]] ; then
21 | echo "package.json does not exist yet"
22 | exit 1
23 | fi
24 | if [[ ! -f "./.github/workflows/release.yml" ]] ; then
25 | echo "/.github/workflows/release.yml does not exist yet"
26 | exit 1
27 | fi
28 |
29 | # Prompt for version number, if not entered
30 | nextVersion="$*"
31 | currentVersion=$(grep "version" "./manifest.json" | cut -d\" -f4)
32 | echo "current version: $currentVersion"
33 | echo -n " next version: "
34 | if [[ -z "$nextVersion" ]]; then
35 | read -r nextVersion
36 | else
37 | echo "$nextVersion"
38 | fi
39 | echo ""
40 |
41 | # Lint
42 | cd "$(dirname "$0")" || exit 1
43 | eslint . --fix --ext=ts # to not lint the main.js files
44 | markdownlint --fix ./README.md
45 |
46 | # set version number in `manifest.json`
47 | sed -E -i '' "s/\"version\".*/\"version\": \"$nextVersion\",/" "manifest.json"
48 | sed -E -i '' "s/\"version\".*/\"version\": \"$nextVersion\",/" "package.json"
49 |
50 | # add version number in `versions.json`, assuming same compatibility
51 | grep -Ev "^$" "versions.json" | grep -v "}" | sed -e '$ d' > temp
52 | minObsidianVersion=$(grep -Ev "^$" "versions.json" | grep -v "}" | tail -n1 | cut -d\" -f4)
53 | # shellcheck disable=SC2129
54 | echo " \"$currentVersion\": \"$minObsidianVersion\"," >> temp
55 | echo " \"$nextVersion\": \"$minObsidianVersion\"" >> temp
56 | echo "}" >> temp
57 | mv temp versions.json
58 |
59 | # update changelog
60 | echo "- $(date +"%Y-%m-%d") release $nextVersion" > ./Changelog.md
61 | git log --pretty=format:"- %ad%x09%s" --date=short | grep -Ev "minor$" | grep -Ev "patch$" | grep -Ev "typos?$" | grep -v "refactoring" | grep -v "Add files via upload" | grep -Ev "\tDelete" | grep -Ev "\tUpdate.*\.md" | sed -E "s/\t\+ /\t/g" >> ./Changelog.md
62 |
63 | # push the manifest and versions JSONs
64 | git add -A
65 | git commit -m "release $nextVersion"
66 |
67 | git pull
68 | git push
69 |
70 | # trigger the release action
71 | git tag "$nextVersion"
72 | git push origin --tags
73 |
--------------------------------------------------------------------------------
/Changelog.md:
--------------------------------------------------------------------------------
1 | - 2023-02-20 release 0.4.1
2 | - 2023-02-20 chore
3 | - 2023-02-20 fix: right sidebar not toggling when left hidden
4 | - 2023-02-20 docs: update
5 | - 2022-07-21 update readme for new URI
6 | - 2022-07-20 release 0.4.0
7 | - 2022-07-20 URI schema now combines showing & side
8 | - 2022-07-07 added explanations to readme
9 | - 2022-07-07 release 0.3.1
10 | - 2022-07-07 release 0.3.0
11 | - 2022-07-07 URI schemes working
12 | - 2022-07-07 release 0.2.0
13 | - 2022-07-07 first working prototype
14 | - 2022-07-07 Initial commit
15 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Christopher Grieser
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Sidebar Toggler
2 |
3 |   [](Changelog.md)
4 |
5 | Finer control of the Obsidian sidebars. To be used with an external window manager.
6 |
7 |
8 | ---
9 |
10 | > __Note__
11 | > This plugin has been archived, since the same functionality can now be achieved by the [Advanced URI plugin](https://obsidian.md/plugins?id=obsidian-advanced-uri) in a much more efficient and customizable manner using it's new `eval` URI scheme:
12 |
13 | ```text
14 | # show left sidebar
15 | obsidian://advanced-uri?eval=this.app.workspace.leftSplit.expand%28%29
16 |
17 | # hide right sidebar
18 | obsidian://advanced-uri?eval=this.app.workspace.rightSplit.collapse%28%29
19 | ```
20 |
21 | ---
22 |
23 |
24 |
25 | - [What the plugin does](#what-the-plugin-does)
26 | - [Purpose of this plugin](#purpose-of-this-plugin)
27 | - [Similar plugins](#similar-plugins)
28 | - [Installation](#installation)
29 | - [Contribute](#contribute)
30 | - [About the developer](#about-the-developer)
31 |
32 |
33 | ## What the plugin does
34 |
35 | It adds four commands for toggling the sidebar. As opposed to Obsidian's native commands, which only allow *toggling* of the sidebars, you can explicitly determine whether to show or hide them.
36 |
37 | - Hide left sidebar
38 | - Hide right sidebar
39 | - Show left sidebar
40 | - Show right sidebar
41 |
42 | In addition, the plugin registers a URI schemes for those commands. The URI must include `showLeft` or `showRight`, and both accept only `true` and `false` as valid input. You can also include both to affect both sidebars with one URI.
43 |
44 | ```text
45 | # Show left sidebar (and do nothing to the ride sidebar)
46 | obsidian://sidebar?showLeft=true
47 |
48 | # Show left and hide right sidebar
49 | obsidian://sidebar?showLeft=true&showRight=false
50 | ```
51 |
52 | ## Purpose of this plugin
53 |
54 | The main use for this plugin is to provide a simple and clear method for __window management apps__ to control Obsidian's sidebars. Just add something like `open "obsidian://sidebar?side=left&show=false"` to your window management configuration to have your window manager control Obsidian's sidebars.
55 |
56 | I, for example, have configured to hide Obsidian's sidebars when I trigger a vertical split of my windows. When I maximize my Obsidian window, the sidebars are shown again.
57 |
58 | For the macOS Automation app [Hammerspoon](http://www.hammerspoon.org/), for example, such a function could look like this:
59 |
60 | ```lua
61 | function toggleObsidianSidebar (obsiWin)
62 | local obsi_width = obsiWin:frame().w
63 | local screen_width = obsiWin:screen():frame().w
64 | if (obsi_width / screen_width > 0.6) then
65 | hs.urlevent.openURL("obsidian://sidebar?showLeft=true&showRight=false")
66 | else
67 | hs.urlevent.openURL("obsidian://sidebar?showLeft=false&showRight=false")
68 | end
69 | end
70 | ```
71 |
72 | ## Similar plugins
73 |
74 | [Hide Sidebars when Narrow](https://obsidian.md/plugins?id=obsidian-hide-sidebars-when-narrow) shows/hides the sidebars automatically based on configurable pixel widths.
75 |
76 | ## Installation
77 |
78 | Available in Obsidian's Community Plugin Browser via: `Settings` → `Community Plugins` → `Browse` → Search for *"Sidebar Toggler"*
79 |
80 | ## Contribute
81 |
82 | Please use the [`.eslintrc` configuration located in the repository](.eslintrc) and run eslint before doing a pull request.
83 |
84 | ```shell
85 | # Run eslint fixing most common mistakes
86 | eslint --fix *.ts
87 | ```
88 |
89 |
90 | ## About the developer
91 |
92 | In my day job, I am a sociologist studying the social mechanisms underlying the digital economy. For my PhD project, I investigate the governance of the app economy and how software ecosystems manage the tension between innovation and compatibility. If you are interested in this subject, feel free to get in touch!
93 |
94 | __Profiles__
95 |
96 | - [Academic Website](https://chris-grieser.de/)
97 | - [ResearchGate](https://www.researchgate.net/profile/Christopher-Grieser)
98 | - [Discord](https://discordapp.com/users/462774483044794368/)
99 | - [GitHub](https://github.com/chrisgrieser/)
100 | - [Twitter](https://twitter.com/pseudo_meta)
101 | - [LinkedIn](https://www.linkedin.com/in/christopher-grieser-ba693b17a/)
102 |
103 | __Buy Me a Coffee__
104 |
105 |
106 |
--------------------------------------------------------------------------------
/esbuild.config.mjs:
--------------------------------------------------------------------------------
1 | import esbuild from "esbuild";
2 | import process from "process";
3 | import builtins from 'builtin-modules'
4 |
5 | const banner =
6 | `/*
7 | THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
8 | if you want to view the source, please visit the github repository of this plugin
9 | */
10 | `;
11 |
12 | const prod = (process.argv[2] === 'production');
13 |
14 | esbuild.build({
15 | banner: {
16 | js: banner,
17 | },
18 | entryPoints: ['main.ts'],
19 | bundle: true,
20 | external: ['obsidian', 'electron', ...builtins],
21 | format: 'cjs',
22 | watch: !prod,
23 | target: 'es2018',
24 | logLevel: "info",
25 | sourcemap: prod ? false : 'inline',
26 | treeShaking: true,
27 | minify: prod,
28 | outfile: 'main.js',
29 | }).catch(() => process.exit(1));
30 |
--------------------------------------------------------------------------------
/main.ts:
--------------------------------------------------------------------------------
1 | import { Notice, Plugin } from "obsidian";
2 |
3 | interface UriParameters {
4 | showLeft?: string;
5 | showRight?: string;
6 | }
7 |
8 | export default class SidebarToggler extends Plugin {
9 | async onload() {
10 | console.log("Sidebar Toggler Plugin loaded.");
11 |
12 | this.addCommand({
13 | id: "show-left-sidebar",
14 | name: "Show Left Sidebar",
15 | callback: () => this.toggleSidebar("left", true),
16 | });
17 | this.addCommand({
18 | id: "show-right-sidebar",
19 | name: "Show Right Sidebar",
20 | callback: () => this.toggleSidebar("right", true),
21 | });
22 | this.addCommand({
23 | id: "hide-left-sidebar",
24 | name: "Hide Left Sidebar",
25 | callback: () => this.toggleSidebar("left", false),
26 | });
27 | this.addCommand({
28 | id: "hide-right-sidebar",
29 | name: "Hide Right Sidebar",
30 | callback: () => this.toggleSidebar("right", false),
31 | });
32 |
33 | this.registerObsidianProtocolHandler("sidebar", async p => {
34 | const parameters = p as unknown as UriParameters;
35 | // eslint-disable-next-line curly
36 | for (const parameter in parameters) {
37 | // eslint-disable-next-line @typescript-eslint/no-explicit-any, no-extra-parens
38 | (parameters as any)[parameter] = (parameters as any)[parameter];
39 | }
40 |
41 | const leftParamValid = ["true", "false"].includes(parameters.showLeft);
42 | const rightParamValid = ["true", "false"].includes(parameters.showRight);
43 | if (!leftParamValid && !rightParamValid) {
44 | new Notice("URI invalid.\n\nPlease refer to the README of the Sidebar Toggler Plugin.");
45 | return;
46 | }
47 |
48 | if (parameters.showLeft === "true") this.toggleSidebar("left", true);
49 | else if (parameters.showLeft === "false") this.toggleSidebar("left", false);
50 | if (parameters.showRight === "true") this.toggleSidebar("right", true);
51 | else if (parameters.showRight === "false") this.toggleSidebar("right", false);
52 | });
53 | }
54 |
55 | async onunload() {
56 | console.log("Sidebar Toggler Plugin unloaded.");
57 | }
58 |
59 | toggleSidebar(side: string, show: boolean) {
60 | if (side === "left" && show) this.app.workspace.leftSplit.expand();
61 | else if (side === "right" && show) this.app.workspace.rightSplit.expand();
62 | else if (side === "left" && !show) this.app.workspace.leftSplit.collapse();
63 | else if (side === "right" && !show) this.app.workspace.rightSplit.collapse();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "obsidian-sidebar-toggler",
3 | "name": "Sidebar Toggler",
4 | "version": "0.4.1",
5 | "minAppVersion": "0.14.0",
6 | "description": "Finer control of the Obsidian sidebars. To be used with an external window manager.",
7 | "author": "pseudometa",
8 | "authorUrl": "https://chris-grieser.de/",
9 | "isDesktopOnly": true
10 | }
11 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "obsidian-sidebar-toggler",
3 | "version": "0.4.1",
4 | "description": "Finer control of the Obsidian sidebars. To be used with an external window manager.",
5 | "main": "main.js",
6 | "scripts": {
7 | "dev": "node esbuild.config.mjs",
8 | "build": "node esbuild.config.mjs production"
9 | },
10 | "keywords": [],
11 | "author": "",
12 | "license": "MIT",
13 | "devDependencies": {
14 | "@types/node": "^16.11.6",
15 | "@typescript-eslint/eslint-plugin": "^5.2.0",
16 | "@typescript-eslint/parser": "^5.2.0",
17 | "builtin-modules": "^3.2.0",
18 | "esbuild": "0.13.12",
19 | "obsidian": "latest",
20 | "tslib": "2.3.1",
21 | "typescript": "4.4.4"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/styles.css:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": ".",
4 | "inlineSourceMap": true,
5 | "inlineSources": true,
6 | "module": "ESNext",
7 | "target": "ES6",
8 | "allowJs": true,
9 | "noImplicitAny": true,
10 | "moduleResolution": "node",
11 | "importHelpers": true,
12 | "lib": [
13 | "DOM",
14 | "ES5",
15 | "ES6",
16 | "ES7"
17 | ]
18 | },
19 | "include": [
20 | "**/*.ts"
21 | ]
22 | }
23 |
--------------------------------------------------------------------------------
/versions.json:
--------------------------------------------------------------------------------
1 | {
2 | "0.1.0": "0.13.19",
3 | "0.2.0": "0.13.19",
4 | "0.3.0": "0.13.19",
5 | "0.3.1": "0.13.19",
6 | "0.4.0": "0.13.19",
7 | "0.4.1": "0.13.19"
8 | }
9 |
--------------------------------------------------------------------------------