Skip to content

Commit 494638b

Browse files
author
Jannes
committed
add codemirror error message
1 parent 15d0f4d commit 494638b

File tree

5 files changed

+41
-27
lines changed

5 files changed

+41
-27
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Conntect Zotero with Joplin to reference sources in notes and open them via `zotero://` links.
44

5+
When having trouble using this plugin, please have a look down below to the FAQ.
6+
57
## Installation
68

79
### Zotero >= 7
@@ -55,6 +57,10 @@ Custom formattting of the text can be enabled from plugin settings.
5557

5658
## FAQ
5759

58-
### Zotero crashes after installation
60+
### Joplin crashes after installation
61+
62+
- using CodeMirror v5 (only supported up to v1.2.1) (#17, #18, #20, #22)
63+
64+
### No Zotero Data could be loaded
5965

60-
Please have a look at this [issues](https://github.com/jannessm/joplin-zotero-link/issues/20), if it helps. Otherwise create a new one.
66+
- check if the port is correct under the plugin settings (#3, #4, #6)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "joplin-plugin-zotero-link",
3-
"version": "2.1.1",
3+
"version": "2.1.2",
44
"scripts": {
55
"dist": "webpack --env joplin-plugin-config=buildMain && webpack --env joplin-plugin-config=buildExtraScripts && webpack --env joplin-plugin-config=createArchive",
66
"prepare": "npm run dist",

src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 1,
33
"id": "nz.magnusso.zotero-link",
44
"app_min_version": "2.12",
5-
"version": "2.1.1",
5+
"version": "2.1.2",
66
"name": "Zotero Link",
77
"description": "Link Zotero entries in notes",
88
"author": "Jannes Magnusson",

src/zotero-link.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,22 @@ module.exports = {
99
if (!value) return;
1010
const zq = new ZoteroQuery(context, cm);
1111

12-
console.log(CodeMirror);
13-
CodeMirror.addExtension([
14-
CodeMirror.joplinExtensions.completionSource(
15-
zq.getCompletions()
16-
),
17-
18-
// Joplin also exposes a Facet that allows enabling or disabling CodeMirror's
19-
// built-in autocompletions. These apply, for example, to HTML tags.
20-
CodeMirror.joplinExtensions.enableLanguageDataAutocomplete.of(true)
21-
]);
12+
try {
13+
CodeMirror.addExtension([
14+
CodeMirror.joplinExtensions.completionSource(
15+
zq.getCompletions()
16+
),
17+
18+
// Joplin also exposes a Facet that allows enabling or disabling CodeMirror's
19+
// built-in autocompletions. These apply, for example, to HTML tags.
20+
CodeMirror.joplinExtensions.enableLanguageDataAutocomplete.of(true)
21+
]);
22+
} catch {
23+
this.context.postMessage({
24+
title: 'Zotero Link could not be initialized.',
25+
description: 'You are probably using a CodeMirror v5 which is only supported by ZoteroLink<=1.2.1.'
26+
});
27+
}
2228
});
2329
};
2430

src/zotero-query.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,27 @@ export class ZoteroQuery {
6060

6161
let data;
6262

63-
try {
64-
data = await this.tryZotero7(settings.port);
63+
data = await this.tryZotero7(settings.port);
64+
65+
// zotero api is not working. Try to use zotserver
66+
if (!data) {
67+
data = await this.tryZotServer(settings.port);
68+
}
69+
70+
if (!!data) {
71+
data = data.filter(item => item.itemType !== 'attachment' && item.itemType !== 'note')
72+
.map(item => new ZoteroItem(item, settings.customFormat));
6573

66-
// zotero api is not working. Try to use zotserver
67-
if (!data) {
68-
data = await this.tryZotServer(settings.port);
69-
}
70-
} catch {
74+
data.sort((a: ZoteroItem, b: ZoteroItem) => a.title.localeCompare(b.title));
75+
return data;
76+
} else {
7177
this.context.postMessage({
7278
title: 'Loading Zotero data failed.',
7379
description: 'Data could not be loaded from Zotero. Please check if Zotero is running with the correct port set in your settings. Otherwise a broken reference in your library could be an issue. Please have a look at existing github issues to find more help.'
7480
});
75-
}
76-
77-
data = data.filter(item => item.itemType !== 'attachment' && item.itemType !== 'note')
78-
.map(item => new ZoteroItem(item, settings.customFormat));
7981

80-
data.sort((a: ZoteroItem, b: ZoteroItem) => a.title.localeCompare(b.title));
81-
return data;
82+
return [];
83+
}
8284
}
8385

8486
async tryZotero7(port: string){

0 commit comments

Comments
 (0)