From 52087f34d4ee15658efa3544656fff351e168bd4 Mon Sep 17 00:00:00 2001 From: RyotaUshio Date: Mon, 12 Feb 2024 00:49:07 +0900 Subject: [PATCH] release: 0.1.5 --- manifest.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/main.ts | 21 ++++++++++++++++++++- src/settings.ts | 2 +- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/manifest.json b/manifest.json index 7b7df3a..1ef2a8a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "view-sync", "name": "View Sync", - "version": "0.1.4", + "version": "0.1.5", "minAppVersion": "1.3.5", "description": "Sync the state of the active view, not files, among devices.", "author": "Ryota Ushio", diff --git a/package-lock.json b/package-lock.json index d41d237..13482e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-view-sync", - "version": "0.1.4", + "version": "0.1.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "obsidian-view-sync", - "version": "0.1.4", + "version": "0.1.5", "license": "MIT", "devDependencies": { "@types/node": "^16.11.6", diff --git a/package.json b/package.json index 88936c1..df2810a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-view-sync", - "version": "0.1.4", + "version": "0.1.5", "description": "An Obsidian.md plugin to sync the state of the active view, not files, among devices.", "scripts": { "dev": "node esbuild.config.mjs", diff --git a/src/main.ts b/src/main.ts index 13fe3c7..cd2750b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -import { FileView, Platform, Plugin, TFile, View, WorkspaceLeaf, normalizePath } from 'obsidian'; +import { FileView, Notice, Platform, Plugin, TFile, View, WorkspaceLeaf, normalizePath } from 'obsidian'; import { ViewSyncSettings, DEFAULT_SETTINGS, ViewSyncSettingTab } from 'settings'; @@ -40,6 +40,8 @@ export default class MyPlugin extends Plugin { this.registerWorkspaceSyncEventSubscriber(); this.registerFileRenameHandler(); + + this.registerCommands(); } get loadStrorageKey() { @@ -183,4 +185,21 @@ export default class MyPlugin extends Plugin { } })); } + + registerCommands() { + this.addCommand({ + id: 'copy-view-type', + name: 'Copy active view type', + callback: () => { + const leaf = this.app.workspace.activeLeaf; + if (leaf) { + const type = leaf.view.getViewType(); + navigator.clipboard.writeText(type); + new Notice(`${this.manifest.name}: View type "${type}" copied to clipboard.`); + return; + } + new Notice(`${this.manifest.name}: There is no active view.`); + } + }); + } } diff --git a/src/settings.ts b/src/settings.ts index 4b6a305..a3b1732 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -205,7 +205,7 @@ export class ViewSyncSettingTab extends PluginSettingTab { .setDesc('Active view states will be tracked by this file. Required for other devices to follow this device\'s active view states. Each device should have a unique path to avoid conflicts. The extension can be anything.') this.addCSVSetting('viewTypes', 'ex) markdown, pdf, canvas') .setName('View types to record') - .setDesc('Comma-separated list of view types to record. Other types of views will be ignored. Required if this device is the main device (= followed by other devices).'); + .setDesc('Comma-separated list of view types to record. Other types of views will be ignored. Required if this device is the main device (= followed by other devices). Note that view types are case-sensitive. To get the type of the active view, you can run the "Copy active view type" command.'); this.addToggleSetting('watchAnother', () => this.redisplay()) .setName('Follow another device') .setDesc('Note: It might be problematic if you let two devices follow each other. I recommend a one-way sync: one main device and one or more follower devices.');