Skip to content

Commit c09f25a

Browse files
louisldlouisld
andauthored
Add support for custom format (#21)
* Add support for custom format * Settings description update * Remove toggling custom format * Only pass required settings to ZoterotItem * Add month and monthlocal option * Add custom date format * Date formatting with dayjs --------- Co-authored-by: louisld <[email protected]>
1 parent e18a520 commit c09f25a

File tree

9 files changed

+220
-81
lines changed

9 files changed

+220
-81
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# 2.1.0
2+
3+
- Added support for custom format link.
4+
- Removed `author` filter on item to include other type of creator.

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,36 @@ Conntect Zotero with Joplin to reference sources in notes and open them via `zot
1919
1. Open a note and enter `z@`
2020
2. Search for your reference
2121
3. Select it
22+
23+
### Custom text for links
24+
25+
Custom formattting of the text can be enabled from plugin settings.
26+
27+
#### Example
28+
29+
| Location | Display |
30+
|---|---|
31+
| Settings | `[<authorfirst>, <year>, *<title>*](<zoterolink>)<externallink>` |
32+
| Markdown | `[Jannes Magnusson, 2024, *jannessm/joplin-zotero-link*](zotero://select/library/items/Q5U7SN82)[&#x1F517;](https://github.com/jannessm/joplin-zotero-link)`|
33+
| Editor | [Jannes Magnusson, 2024, *jannessm/joplin-zotero-link*](zotero://select/library/items/Q5U7SN82)[&#x1F517;](https://github.com/jannessm/joplin-zotero-link) |
34+
35+
#### Available parameters
36+
| Key | Description |
37+
|----------------|----------------------|
38+
| `<key>` | Zotero key |
39+
| `<zoterolink>` | Local zotero link `zotero://select/library/items/<key>` |
40+
| `<authors>` | All authors |
41+
| `<authorfirst>` | First author |
42+
| `<title>` | Title |
43+
| `<date>` | Date in local format |
44+
| `<date:YYYY-MM-DDTHH:mm:ss>` | Date formating using [dayjs](https://day.js.org/) |
45+
| `<year>` | Year |
46+
| `<month>` | Month in `en-US` format |
47+
| `<monthlocal>` | Month in local format |
48+
| `<publication>` | Publication journal |
49+
| `<publicationshort>` | Short version of publication journal |
50+
| `<doi>` | DOI |
51+
| `<doiurl>` | DOI url `https://doi.org/<doi>` |
52+
| `<url>` | External url |
53+
| `<externallink>` | Give external link with icon 🔗 `[&#x1F517;](<url>)` |
54+
| `<externaldoi>` | Give external DOI link with icon 🔗 `[&#x1F517;](<doilink>)` |

package-lock.json

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

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "joplin-plugin-zotero-link",
3-
"version": "2.0.1",
3+
"version": "2.1.0",
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",
@@ -31,6 +31,7 @@
3131
"@codemirror/autocomplete": "^6.18.1",
3232
"@codemirror/language": "^6.10.3",
3333
"@codemirror/view": "^6.34.1",
34-
"@types/codemirror": "^5.60.15"
34+
"@types/codemirror": "^5.60.15",
35+
"dayjs": "^1.11.13"
3536
}
3637
}

src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ joplin.plugins.register({
2222
await joplin.contentScripts.onMessage(scriptId, async (msg) => {
2323

2424
if (msg === 'getSettings') {
25-
const settingValue = await joplin.settings.value(SETTING.Port);
25+
const port = await joplin.settings.value(SETTING.Port);
26+
const cf = await joplin.settings.value(SETTING.CustomFormat);
2627
return {
27-
port: settingValue,
28-
};
28+
port: port,
29+
customFormat: cf
30+
};
2931
} else {
3032
await dialogs.setHtml(error, `
3133
<h1>${msg.title}</h1>

0 commit comments

Comments
 (0)