Skip to content

Commit f582e46

Browse files
committed
Fixes split-view issue
1 parent 5c96a63 commit f582e46

File tree

3 files changed

+21
-30
lines changed

3 files changed

+21
-30
lines changed

main.js

Lines changed: 6 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"main": "ExtractHighlightsPlugin.js",
66
"type": "module",
77
"scripts": {
8-
"dev": "rollup --config rollup.config.js -w",
9-
"build": "rollup --config rollup.config.js",
10-
"test": "cross-env TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\" }' mocha -r ts-node/register -r ignore-styles -r jsdom-global/register test/**/*.ts",
11-
"test:watch": "cross-env TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\" }' mocha -r ts-node/register -r ignore-styles -r jsdom-global/register --watch --watch-files src, test/**/*.ts"
8+
"dev": "rollup --config rollup.config.js -w",
9+
"build": "rollup --config rollup.config.js",
10+
"test": "cross-env TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\" }' mocha -r ts-node/register -r ignore-styles -r jsdom-global/register test/**/*.ts",
11+
"test:watch": "cross-env TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\" }' mocha -r ts-node/register -r ignore-styles -r jsdom-global/register --watch --watch-files src, test/**/*.ts"
1212
},
1313
"keywords": [],
1414
"author": "",
@@ -18,21 +18,21 @@
1818
"@rollup/plugin-node-resolve": "^9.0.0",
1919
"@rollup/plugin-typescript": "^6.0.0",
2020
"@types/chai": "^4.2.14",
21-
"@types/mocha": "^8.0.4",
22-
"@types/node": "^14.14.9",
21+
"@types/mocha": "^8.2.0",
22+
"@types/node": "^14.14.14",
2323
"chai": "^4.2.0",
2424
"cross-env": "^7.0.2",
2525
"ignore-styles": "^5.0.1",
2626
"jsdom": "^16.4.0",
2727
"jsdom-global": "^3.0.2",
2828
"mocha": "^8.2.1",
2929
"obsidian": "https://github.com/obsidianmd/obsidian-api/tarball/master",
30-
"rollup": "^2.32.1",
31-
"ts-node": "^9.1.0",
30+
"rollup": "^2.35.1",
31+
"ts-node": "^9.1.1",
3232
"tslib": "^1.14.1",
33-
"typescript": "^4.0.3"
33+
"typescript": "^4.1.3"
3434
},
3535
"dependencies": {
36-
"electron": "^10.1.5"
36+
"electron": "^10.2.0"
3737
}
3838
}

src/main.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Plugin, Notice, addIcon, View, MarkdownView} from "obsidian"
1+
import {Plugin, Notice, addIcon, View, MarkdownView, Workspace} from "obsidian"
22
import ExtractHighlightsPluginSettings from "./ExtractHighlightsPluginSettings"
33
import ExtractHighlightsPluginSettingsTab from "./ExtractHighlightsPluginSettingsTab"
44
import {Position} from "codemirror";
@@ -24,16 +24,6 @@ export default class ExtractHighlightsPlugin extends Plugin {
2424
this.extractHighlights();
2525
});
2626

27-
this.registerEvent(
28-
this.app.on('codemirror', (cm: CodeMirror.Editor | MarkdownView) => {
29-
if ('sourceMode' in cm) {
30-
this.editor = cm.sourceMode.cmEditor;
31-
} else {
32-
this.editor = cm;
33-
}
34-
}),
35-
);
36-
3727
this.addCommand({
3828
id: "shortcut-extract-highlights",
3929
name: "Shortcut for extracting highlights",
@@ -173,6 +163,10 @@ export default class ExtractHighlightsPlugin extends Plugin {
173163
}
174164

175165
createHighlight() {
166+
const mdView = this.app.workspace.activeLeaf.view as MarkdownView;
167+
const doc = mdView.sourceMode.cmEditor;
168+
this.editor = doc;
169+
176170
const cursorPosition = this.editor.getCursor();
177171
let lineText = this.editor.getLine(cursorPosition.line);
178172

0 commit comments

Comments
 (0)