Skip to content

Commit

Permalink
release: 0.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
RyotaUshio committed Feb 11, 2024
1 parent b04fd10 commit 52087f3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
21 changes: 20 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -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';


Expand Down Expand Up @@ -40,6 +40,8 @@ export default class MyPlugin extends Plugin {
this.registerWorkspaceSyncEventSubscriber();

this.registerFileRenameHandler();

this.registerCommands();
}

get loadStrorageKey() {
Expand Down Expand Up @@ -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.`);
}
});
}
}
2 changes: 1 addition & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down

0 comments on commit 52087f3

Please sign in to comment.