updated to new obsidian API

This commit is contained in:
Ell 2022-06-19 23:42:29 +02:00
parent c37dff03fd
commit 5022385ee1
4 changed files with 17 additions and 74 deletions

65
package-lock.json generated
View file

@ -4,43 +4,6 @@
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"@codemirror/rangeset": {
"version": "0.19.9",
"resolved": "https://registry.npmjs.org/@codemirror/rangeset/-/rangeset-0.19.9.tgz",
"integrity": "sha512-V8YUuOvK+ew87Xem+71nKcqu1SXd5QROMRLMS/ljT5/3MCxtgrRie1Cvild0G/Z2f1fpWxzX78V0U4jjXBorBQ==",
"dev": true,
"requires": {
"@codemirror/state": "^0.19.0"
}
},
"@codemirror/state": {
"version": "0.19.9",
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-0.19.9.tgz",
"integrity": "sha512-psOzDolKTZkx4CgUqhBQ8T8gBc0xN5z4gzed109aF6x7D7umpDRoimacI/O6d9UGuyl4eYuDCZmDFr2Rq7aGOw==",
"dev": true,
"requires": {
"@codemirror/text": "^0.19.0"
}
},
"@codemirror/text": {
"version": "0.19.6",
"resolved": "https://registry.npmjs.org/@codemirror/text/-/text-0.19.6.tgz",
"integrity": "sha512-T9jnREMIygx+TPC1bOuepz18maGq/92q2a+n4qTqObKwvNMg+8cMTslb8yxeEDEq7S3kpgGWxgO1UWbQRij0dA==",
"dev": true
},
"@codemirror/view": {
"version": "0.19.47",
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-0.19.47.tgz",
"integrity": "sha512-SfbagKvJQl5dtt+9wYpo9sa3ZkMgUxTq+/hXDf0KVwIx+zu3cJIqfEm9xSx6yXkq7it7RsPGHaPasApNffF/8g==",
"dev": true,
"requires": {
"@codemirror/rangeset": "^0.19.5",
"@codemirror/state": "^0.19.3",
"@codemirror/text": "^0.19.0",
"style-mod": "^4.0.0",
"w3c-keyname": "^2.2.4"
}
},
"@electron/get": { "@electron/get": {
"version": "1.14.1", "version": "1.14.1",
"resolved": "https://registry.npmjs.org/@electron/get/-/get-1.14.1.tgz", "resolved": "https://registry.npmjs.org/@electron/get/-/get-1.14.1.tgz",
@ -688,9 +651,9 @@
} }
}, },
"moment": { "moment": {
"version": "2.29.1", "version": "2.29.3",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.3.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==", "integrity": "sha512-c6YRvhEo//6T2Jz/vVtYzqBzwvPT95JBQ+smCytzf7c50oMZRsR/a4w88aD34I+/QVSfnoAnSBFPJHItlOMJVw==",
"dev": true "dev": true
}, },
"ms": { "ms": {
@ -724,15 +687,13 @@
"optional": true "optional": true
}, },
"obsidian": { "obsidian": {
"version": "0.13.30", "version": "0.15.1",
"resolved": "https://registry.npmjs.org/obsidian/-/obsidian-0.13.30.tgz", "resolved": "https://registry.npmjs.org/obsidian/-/obsidian-0.15.1.tgz",
"integrity": "sha512-uAOrIyeHE9qYzg1Qjfpy/qlyLUFX9oyKWeHYO8NVDoI+pm5VUTMe7XWcsXPwb9iVsVmggVJcdV15Vqm9bljhxQ==", "integrity": "sha512-zE6jq3F/iMJTZ5x3lmn7OClS2U+T4VGbAsLrPmyJtc3X2UEEBmXbU4EVrx2+PmjVbgPie/etPWZvP9ZGwfgdAw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@codemirror/state": "^0.19.6",
"@codemirror/view": "^0.19.31",
"@types/codemirror": "0.0.108", "@types/codemirror": "0.0.108",
"moment": "2.29.1" "moment": "2.29.3"
} }
}, },
"once": { "once": {
@ -882,12 +843,6 @@
"safe-buffer": "~5.1.0" "safe-buffer": "~5.1.0"
} }
}, },
"style-mod": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.0.0.tgz",
"integrity": "sha512-OPhtyEjyyN9x3nhPsu76f52yUGXiZcgvsrFVtvTkyGRQJ0XK+GPc6ov1z+lRpbeabka+MYEQxOYRnt5nF30aMw==",
"dev": true
},
"sumchecker": { "sumchecker": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.1.tgz", "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.1.tgz",
@ -956,12 +911,6 @@
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
"dev": true "dev": true
}, },
"w3c-keyname": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.4.tgz",
"integrity": "sha512-tOhfEwEzFLJzf6d1ZPkYfGj+FWhIpBux9ppoP3rlclw3Z0BZv3N7b7030Z1kYth+6rDuAsXUFr+d0VE6Ed1ikw==",
"dev": true
},
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",

View file

@ -23,8 +23,7 @@ export class CustomFrame {
this.frame.setZoomFactor(this.data.zoomLevel); this.frame.setZoomFactor(this.data.zoomLevel);
this.frame.insertCSS(this.data.customCss); this.frame.insertCSS(this.data.customCss);
}); });
} } else {
else {
this.frame = document.createElement("iframe"); this.frame = document.createElement("iframe");
this.frame.setAttribute("sandbox", "allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation"); this.frame.setAttribute("sandbox", "allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation");
this.frame.setAttribute("allow", "encrypted-media; fullscreen; oversized-images; picture-in-picture; sync-xhr; geolocation;"); this.frame.setAttribute("allow", "encrypted-media; fullscreen; oversized-images; picture-in-picture; sync-xhr; geolocation;");
@ -63,8 +62,7 @@ export class CustomFrame {
public goBack(): void { public goBack(): void {
if (this.frame instanceof HTMLIFrameElement) { if (this.frame instanceof HTMLIFrameElement) {
this.frame.contentWindow.history.back(); this.frame.contentWindow.history.back();
} } else {
else {
this.frame.goBack(); this.frame.goBack();
} }
} }
@ -72,8 +70,7 @@ export class CustomFrame {
public goForward(): void { public goForward(): void {
if (this.frame instanceof HTMLIFrameElement) { if (this.frame instanceof HTMLIFrameElement) {
this.frame.contentWindow.history.forward(); this.frame.contentWindow.history.forward();
} } else {
else {
this.frame.goForward(); this.frame.goForward();
} }
} }
@ -82,8 +79,7 @@ export class CustomFrame {
if (!(this.frame instanceof HTMLIFrameElement)) { if (!(this.frame instanceof HTMLIFrameElement)) {
if (!this.frame.isDevToolsOpened()) { if (!this.frame.isDevToolsOpened()) {
this.frame.openDevTools(); this.frame.openDevTools();
} } else {
else {
this.frame.closeDevTools(); this.frame.closeDevTools();
} }
} }

View file

@ -83,13 +83,12 @@ export default class CustomFramesPlugin extends Plugin {
private async openLeaf(name: string, center: boolean, split: boolean): Promise<void> { private async openLeaf(name: string, center: boolean, split: boolean): Promise<void> {
if (center) { if (center) {
this.app.workspace.detachLeavesOfType(name); this.app.workspace.detachLeavesOfType(name);
let leaf = split ? this.app.workspace.splitActiveLeaf() : this.app.workspace.getUnpinnedLeaf(); let leaf = this.app.workspace.getLeaf(split);
await leaf.setViewState({ type: name }); await leaf.setViewState({ type: name, active: true });
} } else {
else {
if (!this.app.workspace.getLeavesOfType(name).length) if (!this.app.workspace.getLeavesOfType(name).length)
await this.app.workspace.getRightLeaf(false).setViewState({ type: name }); await this.app.workspace.getRightLeaf(false).setViewState({ type: name, active: true });
}
this.app.workspace.revealLeaf(this.app.workspace.getLeavesOfType(name)[0]); this.app.workspace.revealLeaf(this.app.workspace.getLeavesOfType(name)[0]);
} }
} }
}

View file

@ -182,8 +182,7 @@ export class CustomFramesSettingTab extends PluginSettingTab {
forceIframe: false, forceIframe: false,
customCss: "" customCss: ""
}); });
} } else {
else {
this.plugin.settings.frames.push(presets[option]); this.plugin.settings.frames.push(presets[option]);
} }
await this.plugin.saveSettings(); await this.plugin.saveSettings();