react-cheminfo 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +210 -0
  3. package/lib/citation/core/clipboard.d.ts +14 -0
  4. package/lib/citation/core/clipboard.d.ts.map +1 -0
  5. package/lib/citation/core/clipboard.js +25 -0
  6. package/lib/citation/core/clipboard.js.map +1 -0
  7. package/lib/citation/core/download.d.ts +11 -0
  8. package/lib/citation/core/download.d.ts.map +1 -0
  9. package/lib/citation/core/download.js +20 -0
  10. package/lib/citation/core/download.js.map +1 -0
  11. package/lib/citation/core/formats.d.ts +91 -0
  12. package/lib/citation/core/formats.d.ts.map +1 -0
  13. package/lib/citation/core/formats.js +125 -0
  14. package/lib/citation/core/formats.js.map +1 -0
  15. package/lib/citation/core/index.d.ts +10 -0
  16. package/lib/citation/core/index.d.ts.map +1 -0
  17. package/lib/citation/core/index.js +7 -0
  18. package/lib/citation/core/index.js.map +1 -0
  19. package/lib/citation/core/reference.d.ts +30 -0
  20. package/lib/citation/core/reference.d.ts.map +1 -0
  21. package/lib/citation/core/reference.js +9 -0
  22. package/lib/citation/core/reference.js.map +1 -0
  23. package/lib/citation/core/render.d.ts +21 -0
  24. package/lib/citation/core/render.d.ts.map +1 -0
  25. package/lib/citation/core/render.js +74 -0
  26. package/lib/citation/core/render.js.map +1 -0
  27. package/lib/citation/core/segments.d.ts +47 -0
  28. package/lib/citation/core/segments.d.ts.map +1 -0
  29. package/lib/citation/core/segments.js +134 -0
  30. package/lib/citation/core/segments.js.map +1 -0
  31. package/lib/citation/ui/CitationMenu.d.ts +14 -0
  32. package/lib/citation/ui/CitationMenu.d.ts.map +1 -0
  33. package/lib/citation/ui/CitationMenu.js +63 -0
  34. package/lib/citation/ui/CitationMenu.js.map +1 -0
  35. package/lib/citation/ui/CitationPreview.d.ts +18 -0
  36. package/lib/citation/ui/CitationPreview.d.ts.map +1 -0
  37. package/lib/citation/ui/CitationPreview.js +55 -0
  38. package/lib/citation/ui/CitationPreview.js.map +1 -0
  39. package/lib/citation/ui/CiteButton.d.ts +22 -0
  40. package/lib/citation/ui/CiteButton.d.ts.map +1 -0
  41. package/lib/citation/ui/CiteButton.js +15 -0
  42. package/lib/citation/ui/CiteButton.js.map +1 -0
  43. package/lib/citation/ui/entries.d.ts +45 -0
  44. package/lib/citation/ui/entries.d.ts.map +1 -0
  45. package/lib/citation/ui/entries.js +52 -0
  46. package/lib/citation/ui/entries.js.map +1 -0
  47. package/lib/citation/ui/index.d.ts +7 -0
  48. package/lib/citation/ui/index.d.ts.map +1 -0
  49. package/lib/citation/ui/index.js +4 -0
  50. package/lib/citation/ui/index.js.map +1 -0
  51. package/lib/core.d.ts +3 -0
  52. package/lib/core.d.ts.map +1 -0
  53. package/lib/core.js +3 -0
  54. package/lib/core.js.map +1 -0
  55. package/lib/ecosystem/core/index.d.ts +3 -0
  56. package/lib/ecosystem/core/index.d.ts.map +1 -0
  57. package/lib/ecosystem/core/index.js +2 -0
  58. package/lib/ecosystem/core/index.js.map +1 -0
  59. package/lib/ecosystem/core/sites.d.ts +57 -0
  60. package/lib/ecosystem/core/sites.d.ts.map +1 -0
  61. package/lib/ecosystem/core/sites.js +105 -0
  62. package/lib/ecosystem/core/sites.js.map +1 -0
  63. package/lib/ecosystem/ui/EcosystemButton.d.ts +24 -0
  64. package/lib/ecosystem/ui/EcosystemButton.d.ts.map +1 -0
  65. package/lib/ecosystem/ui/EcosystemButton.js +14 -0
  66. package/lib/ecosystem/ui/EcosystemButton.js.map +1 -0
  67. package/lib/ecosystem/ui/EcosystemMenu.d.ts +17 -0
  68. package/lib/ecosystem/ui/EcosystemMenu.d.ts.map +1 -0
  69. package/lib/ecosystem/ui/EcosystemMenu.js +112 -0
  70. package/lib/ecosystem/ui/EcosystemMenu.js.map +1 -0
  71. package/lib/ecosystem/ui/index.d.ts +7 -0
  72. package/lib/ecosystem/ui/index.d.ts.map +1 -0
  73. package/lib/ecosystem/ui/index.js +4 -0
  74. package/lib/ecosystem/ui/index.js.map +1 -0
  75. package/lib/ecosystem/ui/marks.d.ts +18 -0
  76. package/lib/ecosystem/ui/marks.d.ts.map +1 -0
  77. package/lib/ecosystem/ui/marks.js +43 -0
  78. package/lib/ecosystem/ui/marks.js.map +1 -0
  79. package/lib/shared/ui/MenuButton.d.ts +34 -0
  80. package/lib/shared/ui/MenuButton.d.ts.map +1 -0
  81. package/lib/shared/ui/MenuButton.js +18 -0
  82. package/lib/shared/ui/MenuButton.js.map +1 -0
  83. package/lib/shared/ui/index.d.ts +2 -0
  84. package/lib/shared/ui/index.d.ts.map +1 -0
  85. package/lib/shared/ui/index.js +2 -0
  86. package/lib/shared/ui/index.js.map +1 -0
  87. package/lib/ui.d.ts +4 -0
  88. package/lib/ui.d.ts.map +1 -0
  89. package/lib/ui.js +4 -0
  90. package/lib/ui.js.map +1 -0
  91. package/package.json +79 -0
  92. package/src/citation/core/clipboard.ts +32 -0
  93. package/src/citation/core/download.ts +27 -0
  94. package/src/citation/core/formats.ts +169 -0
  95. package/src/citation/core/index.ts +23 -0
  96. package/src/citation/core/reference.ts +33 -0
  97. package/src/citation/core/render.ts +78 -0
  98. package/src/citation/core/segments.ts +170 -0
  99. package/src/citation/ui/CitationMenu.tsx +132 -0
  100. package/src/citation/ui/CitationPreview.tsx +84 -0
  101. package/src/citation/ui/CiteButton.tsx +39 -0
  102. package/src/citation/ui/entries.tsx +144 -0
  103. package/src/citation/ui/index.ts +6 -0
  104. package/src/core.ts +2 -0
  105. package/src/ecosystem/core/index.ts +7 -0
  106. package/src/ecosystem/core/sites.ts +164 -0
  107. package/src/ecosystem/ui/EcosystemButton.tsx +41 -0
  108. package/src/ecosystem/ui/EcosystemMenu.tsx +191 -0
  109. package/src/ecosystem/ui/index.ts +6 -0
  110. package/src/ecosystem/ui/marks.tsx +207 -0
  111. package/src/shared/ui/MenuButton.tsx +67 -0
  112. package/src/shared/ui/index.ts +1 -0
  113. package/src/ui.ts +3 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 cheminfo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,210 @@
1
+ # react-cheminfo
2
+
3
+ [![NPM version][npm-image]][npm-url]
4
+ [![build status][ci-image]][ci-url]
5
+ [![Test coverage][codecov-image]][codecov-url]
6
+ [![npm download][download-image]][download-url]
7
+
8
+ Assembled React components shared by the `*.cheminfo.org` sites.
9
+
10
+ ## What it is
11
+
12
+ [`react-science`](https://www.npmjs.com/package/react-science) gives us
13
+ **primitives** — `Toolbar`, `Accordion`, `SplitPane`, `Button`. This package is
14
+ the layer above: **assemblies**, a component you hand data to and it delivers a
15
+ whole feature, its copy, its interactions and its logic included. A site
16
+ normally depends on both.
17
+
18
+ ## Installation
19
+
20
+ ```console
21
+ npm i react-cheminfo
22
+ ```
23
+
24
+ `react`, `react-dom`, `@blueprintjs/core` and `react-science` are peer
25
+ dependencies: a site already has them, and a second copy of `react-science`
26
+ would mean two Blueprint style trees in one page.
27
+
28
+ ## Two entry points
29
+
30
+ | Import | Holds |
31
+ | --------------------- | ----------------------------------------------------------------------------- |
32
+ | `react-cheminfo/ui` | the React components |
33
+ | `react-cheminfo/core` | the framework-free logic — citation formats, the site list — with no React in |
34
+
35
+ A backend serving an RIS endpoint, and every unit test of that logic, therefore
36
+ load no React at all.
37
+
38
+ The sources are organised the other way round — one folder per component
39
+ (`src/citation`, `src/ecosystem`), each holding a `core/` and a `ui/` half — and
40
+ `src/core.ts` and `src/ui.ts` are the barrels the two entry points point at.
41
+ `src/shared` holds what more than one of them is built on: `MenuButton`, the
42
+ shape every button of a site header takes, which is why `CiteButton` and
43
+ `EcosystemButton` differ only in their glyph and their menu, and why both accept
44
+ the `compact` and `placement` props of the exported `HeaderButtonProps`.
45
+
46
+ ## Components
47
+
48
+ ### `CiteButton`
49
+
50
+ The Cite entry of a site header: one button opening the work at its DOI, copying
51
+ its reference in the style a journal asks for, and saving the files a reference
52
+ manager imports.
53
+
54
+ ```tsx
55
+ import { CiteButton } from 'react-cheminfo/ui';
56
+
57
+ <CiteButton reference={PAPER} />;
58
+ ```
59
+
60
+ - **HTML** and **Markdown**, each in the four styles chemists are asked for —
61
+ ACS, Nature, RSC and Wiley. An HTML copy is written to the clipboard in both
62
+ flavours, so Word and Google Docs keep the emphasis while a plain editor
63
+ receives a clean line; that is why plain text is not a separate entry.
64
+ - **BibTeX**, **RIS** and the **DOI link**, which carry no style.
65
+ - **RIS and BibTeX files**, served with the MIME types Zotero, Mendeley and
66
+ EndNote recognise, so opening the saved file imports it.
67
+ - A hover **preview** of exactly what each entry copies or saves.
68
+ - `compact` drops the text and the caret, leaving the icon alone to open the
69
+ menu, for a header that has run out of room. The label stays what the pointer
70
+ and a screen reader are told.
71
+
72
+ Adding a style means one function in `citation/core/segments.ts` and one entry
73
+ in `CITATION_STYLES` — the three output formats and the preview follow.
74
+
75
+ ### `EcosystemButton`
76
+
77
+ The Tools entry of a site header: one button opening every other site of the
78
+ family, each behind its own little logo and the two colours it owns.
79
+
80
+ ```tsx
81
+ import { EcosystemButton } from 'react-cheminfo/ui';
82
+
83
+ <EcosystemButton currentSiteId="vcl" />;
84
+ ```
85
+
86
+ - `currentSiteId` is the one thing that differs per site: that tile is shown
87
+ with a _you are here_ label and is not a link. Passing nothing links all ten.
88
+ - `compact` drops the text and the caret, leaving the icon alone to open the
89
+ menu, for a header that has run out of room. The label stays what the pointer
90
+ and a screen reader are told.
91
+ - A tile **lights up in the colour of the site it opens**, so running the
92
+ pointer down the grid is what makes the ten pairs of colours read.
93
+
94
+ Each mark keeps the geometry of that site's own logo where it has one, redrawn
95
+ on a plate of the site's own colour so ten marks from ten sites still read as
96
+ one row, and carrying the site's answering colour on exactly one element —
97
+ which is what stops it collapsing into a flat shape at 16 px.
98
+
99
+ **NMRium** keeps its artwork whole: the symbol is the one from `Logo.tsx` of the
100
+ NMRium sources, in its orange, on the plum its logo sets the rest of the
101
+ wordmark in. **ChemCalc** is the one mark that is ours — its logo is an atom
102
+ that is unreadable small, so the tile draws what the tool returns, an isotopic
103
+ pattern, in ChemCalc's own indigo and teal.
104
+
105
+ The colours a name is set in are the site's own and are not retuned to reach the
106
+ 4.5:1 of body text: ChemCalc's teal and NMRium's orange both land just under it,
107
+ which is why a name is set bold, where 3:1 is the threshold.
108
+
109
+ ## Styling
110
+
111
+ **No stylesheet, nothing for a consumer to import.** Every rule is a
112
+ module-level `CSSProperties` constant applied with `style`, the way `react-mf`
113
+ does it — so there is no import step, no load-order surprise, and no specificity
114
+ fight with Blueprint, since an inline rule outranks every selector.
115
+
116
+ A component never hard-codes a site's identity: what differs per site is passed
117
+ in as props, or read from a CSS variable (`--brand`, `--brand-alt`, `--accent`)
118
+ so each site keeps the two colours it owns.
119
+
120
+ ## Development
121
+
122
+ ```console
123
+ npm run dev
124
+ ```
125
+
126
+ opens Storybook on <http://localhost:10815> — every component of the package,
127
+ under every prop it takes, with the controls to set them and the snippet that
128
+ reproduces what is on show. The **Brand** toolbar retunes `--brand` /
129
+ `--brand-alt` / `--accent` on the canvas, so you can watch a component carry a
130
+ site's two colours. Components land there as they move into the package.
131
+
132
+ A story is a `*.stories.tsx` file in `stories/`, written in CSF: a default
133
+ export naming the component, and one export per state the sites use it in. The
134
+ prose and the types of the controls come from the props' own JSDoc, read off the
135
+ source by `@storybook/addon-docs`, so a component is documented by documenting
136
+ its props — never by writing a page for it. `stories/headerButton.ts` already
137
+ describes the controls every header button shares.
138
+
139
+ ```console
140
+ npm run build-storybook # storybook-static/
141
+ ```
142
+
143
+ is what GitHub Pages serves at <https://cheminfo.github.io/react-cheminfo/>,
144
+ built and deployed by `.github/workflows/pages.yml` on every push to `main`.
145
+
146
+ ## Testing
147
+
148
+ Unit tests cover the framework-free half, which is where the citation formats
149
+ and the site list live:
150
+
151
+ ```console
152
+ npm run test # vitest + type-check + eslint + prettier
153
+ ```
154
+
155
+ The components themselves are almost entirely interaction — Blueprint popovers
156
+ with hover delays, submenus, clipboard writes in two flavours, file downloads —
157
+ so they are tested in a real browser rather than a simulated DOM:
158
+
159
+ ```console
160
+ npx playwright install --with-deps chromium # once
161
+ npm run test-e2e # or test-e2e-ui to watch
162
+ ```
163
+
164
+ `npm run test-e2e` starts Storybook itself and drives each story on its own
165
+ address (`/iframe.html?id=…`), so there is nothing to launch first. It is a
166
+ separate command from `npm run test`, because it needs a browser that a plain CI
167
+ job does not have; its own workflow installs one.
168
+
169
+ ## Testing a local build
170
+
171
+ Before publishing, test the **packed artifact** rather than the sources: it is
172
+ what a site will actually install, and it is where a missing file or a wrong
173
+ `exports` entry shows up.
174
+
175
+ ```console
176
+ npm run tsc # build lib/
177
+ npm pack # react-cheminfo-0.0.0.tgz
178
+ ```
179
+
180
+ Then, from a throwaway app — or from the site you are about to adopt it in:
181
+
182
+ ```console
183
+ npm i ../react-cheminfo/react-cheminfo-0.0.0.tgz
184
+ ```
185
+
186
+ Import from both entry points, so the check covers the framework-free half too:
187
+
188
+ ```tsx
189
+ import { CITATION_STYLES, formatCitation } from 'react-cheminfo/core';
190
+ import { CiteButton, EcosystemButton } from 'react-cheminfo/ui';
191
+ ```
192
+
193
+ Reinstall the tarball after every `npm pack` — npm caches it by name and
194
+ version, and this package stays at `0.0.0` until release-please cuts the first
195
+ one.
196
+
197
+ ## [API Documentation](https://cheminfo.github.io/react-cheminfo/)
198
+
199
+ ## License
200
+
201
+ [MIT](./LICENSE)
202
+
203
+ [npm-image]: https://img.shields.io/npm/v/react-cheminfo.svg
204
+ [npm-url]: https://www.npmjs.com/package/react-cheminfo
205
+ [ci-image]: https://github.com/cheminfo/react-cheminfo/workflows/Node.js%20CI/badge.svg?branch=main
206
+ [ci-url]: https://github.com/cheminfo/react-cheminfo/actions?query=workflow%3A%22Node.js+CI%22
207
+ [codecov-image]: https://img.shields.io/codecov/c/github/cheminfo/react-cheminfo.svg
208
+ [codecov-url]: https://codecov.io/gh/cheminfo/react-cheminfo
209
+ [download-image]: https://img.shields.io/npm/dm/react-cheminfo.svg
210
+ [download-url]: https://www.npmjs.com/package/react-cheminfo
@@ -0,0 +1,14 @@
1
+ import type { CitationFormatId } from './formats.ts';
2
+ import type { Reference } from './reference.ts';
3
+ import type { CitationStyleId } from './segments.ts';
4
+ /**
5
+ * Put a reference on the clipboard. HTML goes on in both flavours, so a paste
6
+ * into Word or Google Docs keeps the emphasis of the style while a plain text
7
+ * editor still receives a readable line rather than the markup.
8
+ * @param reference - Reference to copy.
9
+ * @param format - Format to copy it in.
10
+ * @param style - Journal style, for the formats that have one.
11
+ * @returns Resolves once the clipboard holds the citation.
12
+ */
13
+ export declare function copyCitation(reference: Reference, format: CitationFormatId, style?: CitationStyleId): Promise<void>;
14
+ //# sourceMappingURL=clipboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../../src/citation/core/clipboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,gBAAgB,EACxB,KAAK,CAAC,EAAE,eAAe,GACtB,OAAO,CAAC,IAAI,CAAC,CAaf"}
@@ -0,0 +1,25 @@
1
+ import { formatCitation } from "./formats.js";
2
+ /**
3
+ * Put a reference on the clipboard. HTML goes on in both flavours, so a paste
4
+ * into Word or Google Docs keeps the emphasis of the style while a plain text
5
+ * editor still receives a readable line rather than the markup.
6
+ * @param reference - Reference to copy.
7
+ * @param format - Format to copy it in.
8
+ * @param style - Journal style, for the formats that have one.
9
+ * @returns Resolves once the clipboard holds the citation.
10
+ */
11
+ export function copyCitation(reference, format, style) {
12
+ const value = formatCitation(reference, format, style);
13
+ if (format !== 'html' || typeof ClipboardItem === 'undefined') {
14
+ return navigator.clipboard.writeText(value);
15
+ }
16
+ return navigator.clipboard.write([
17
+ new ClipboardItem({
18
+ 'text/html': new Blob([value], { type: 'text/html' }),
19
+ 'text/plain': new Blob([formatCitation(reference, 'text', style)], {
20
+ type: 'text/plain',
21
+ }),
22
+ }),
23
+ ]);
24
+ }
25
+ //# sourceMappingURL=clipboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipboard.js","sourceRoot":"","sources":["../../../src/citation/core/clipboard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAI9C;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAC1B,SAAoB,EACpB,MAAwB,EACxB,KAAuB;IAEvB,MAAM,KAAK,GAAG,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACvD,IAAI,MAAM,KAAK,MAAM,IAAI,OAAO,aAAa,KAAK,WAAW,EAAE,CAAC;QAC9D,OAAO,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC;QAC/B,IAAI,aAAa,CAAC;YAChB,WAAW,EAAE,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;YACrD,YAAY,EAAE,IAAI,IAAI,CAAC,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE;gBACjE,IAAI,EAAE,YAAY;aACnB,CAAC;SACH,CAAC;KACH,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { CitationDownload } from './formats.ts';
2
+ import type { Reference } from './reference.ts';
3
+ /**
4
+ * Save the reference as the file a reference manager imports. The MIME type
5
+ * is the one Zotero, Mendeley and EndNote recognise, so opening the saved
6
+ * file hands it to whichever of them is installed.
7
+ * @param reference - Reference to save.
8
+ * @param download - File to write, from `CITATION_DOWNLOADS`.
9
+ */
10
+ export declare function downloadCitation(reference: Reference, download: CitationDownload): void;
11
+ //# sourceMappingURL=download.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../src/citation/core/download.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,gBAAgB,GACzB,IAAI,CAYN"}
@@ -0,0 +1,20 @@
1
+ import { citationFilename, formatCitation } from "./formats.js";
2
+ /**
3
+ * Save the reference as the file a reference manager imports. The MIME type
4
+ * is the one Zotero, Mendeley and EndNote recognise, so opening the saved
5
+ * file hands it to whichever of them is installed.
6
+ * @param reference - Reference to save.
7
+ * @param download - File to write, from `CITATION_DOWNLOADS`.
8
+ */
9
+ export function downloadCitation(reference, download) {
10
+ const content = formatCitation(reference, download.format);
11
+ const url = URL.createObjectURL(new Blob([content], { type: download.mimeType }));
12
+ const anchor = document.createElement('a');
13
+ anchor.href = url;
14
+ anchor.download = citationFilename(reference, download.extension);
15
+ document.body.append(anchor);
16
+ anchor.click();
17
+ anchor.remove();
18
+ URL.revokeObjectURL(url);
19
+ }
20
+ //# sourceMappingURL=download.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.js","sourceRoot":"","sources":["../../../src/citation/core/download.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGhE;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,SAAoB,EACpB,QAA0B;IAE1B,MAAM,OAAO,GAAG,cAAc,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3D,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAC7B,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CACjD,CAAC;IACF,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,MAAM,CAAC,QAAQ,GAAG,gBAAgB,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IAClE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7B,MAAM,CAAC,KAAK,EAAE,CAAC;IACf,MAAM,CAAC,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,91 @@
1
+ import type { Reference } from './reference.ts';
2
+ import type { CitationStyleId } from './segments.ts';
3
+ /** The formats the reference can be copied in. */
4
+ export type CitationFormatId = 'text' | 'html' | 'markdown' | 'bibtex' | 'ris' | 'doi';
5
+ /** One entry of the copy menu. */
6
+ export interface CitationFormat {
7
+ id: CitationFormatId;
8
+ /** Name of the format. */
9
+ label: string;
10
+ /** Where that format is pasted, shown on the right of the entry. */
11
+ hint: string;
12
+ /**
13
+ * Whether the format is written differently by each journal style, and so
14
+ * opens the submenu of styles rather than copying straight away.
15
+ */
16
+ styled: boolean;
17
+ }
18
+ /**
19
+ * Every format offered, in the order the menu lists them. Plain text is not
20
+ * one of them: an HTML copy carries it as its second flavour, so a paste into
21
+ * a plain editor already gives the unmarked line.
22
+ */
23
+ export declare const CITATION_FORMATS: readonly [{
24
+ readonly id: "html";
25
+ readonly label: "HTML";
26
+ readonly hint: "Word, Docs, email";
27
+ readonly styled: true;
28
+ }, {
29
+ readonly id: "markdown";
30
+ readonly label: "Markdown";
31
+ readonly hint: "README, issue";
32
+ readonly styled: true;
33
+ }, {
34
+ readonly id: "bibtex";
35
+ readonly label: "BibTeX";
36
+ readonly hint: "LaTeX";
37
+ readonly styled: false;
38
+ }, {
39
+ readonly id: "ris";
40
+ readonly label: "RIS";
41
+ readonly hint: "EndNote, Zotero";
42
+ readonly styled: false;
43
+ }, {
44
+ readonly id: "doi";
45
+ readonly label: "DOI link";
46
+ readonly hint: "URL";
47
+ readonly styled: false;
48
+ }];
49
+ /** The style a format that has one is written in unless another is picked. */
50
+ export declare const DEFAULT_CITATION_STYLE: CitationStyleId;
51
+ /** One entry of the download menu: a file a reference manager imports. */
52
+ export interface CitationDownload {
53
+ format: CitationFormatId;
54
+ label: string;
55
+ hint: string;
56
+ extension: string;
57
+ mimeType: string;
58
+ }
59
+ /**
60
+ * The files offered for download. Zotero, Mendeley and EndNote all import
61
+ * both, and their connectors recognise the MIME types below on their own.
62
+ */
63
+ export declare const CITATION_DOWNLOADS: readonly [{
64
+ readonly format: "ris";
65
+ readonly label: "RIS file";
66
+ readonly hint: "Zotero, Mendeley, EndNote";
67
+ readonly extension: "ris";
68
+ readonly mimeType: "application/x-research-info-systems";
69
+ }, {
70
+ readonly format: "bibtex";
71
+ readonly label: "BibTeX file";
72
+ readonly hint: "JabRef, Overleaf";
73
+ readonly extension: "bib";
74
+ readonly mimeType: "application/x-bibtex";
75
+ }];
76
+ /**
77
+ * Name the saved file carries, e.g. `Vanderveen2015.ris`.
78
+ * @param reference - Reference the file holds.
79
+ * @param extension - Extension of the file, without its dot.
80
+ * @returns The file name.
81
+ */
82
+ export declare function citationFilename(reference: Reference, extension: string): string;
83
+ /**
84
+ * Render a reference in one of the citation formats.
85
+ * @param reference - Reference to render.
86
+ * @param format - Format to render it in.
87
+ * @param style - Journal style, for the formats that have one.
88
+ * @returns The citation, ready to be copied to the clipboard.
89
+ */
90
+ export declare function formatCitation(reference: Reference, format: CitationFormatId, style?: CitationStyleId): string;
91
+ //# sourceMappingURL=formats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formats.d.ts","sourceRoot":"","sources":["../../../src/citation/core/formats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD,kDAAkD;AAClD,MAAM,MAAM,gBAAgB,GAC1B,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC;AAE1D,kCAAkC;AAClC,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,gBAAgB,CAAC;IACrB,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;EAMiB,CAAC;AAE/C,8EAA8E;AAC9E,eAAO,MAAM,sBAAsB,EAAE,eAAuB,CAAC;AAE7D,0EAA0E;AAC1E,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAeiB,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,MAAM,GAChB,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,gBAAgB,EACxB,KAAK,GAAE,eAAwC,GAC9C,MAAM,CAiBR"}
@@ -0,0 +1,125 @@
1
+ import { doiUrl } from "./reference.js";
2
+ import { renderHtml, renderMarkdown, renderText } from "./render.js";
3
+ import { citationSegments } from "./segments.js";
4
+ /**
5
+ * Every format offered, in the order the menu lists them. Plain text is not
6
+ * one of them: an HTML copy carries it as its second flavour, so a paste into
7
+ * a plain editor already gives the unmarked line.
8
+ */
9
+ export const CITATION_FORMATS = [
10
+ { id: 'html', label: 'HTML', hint: 'Word, Docs, email', styled: true },
11
+ { id: 'markdown', label: 'Markdown', hint: 'README, issue', styled: true },
12
+ { id: 'bibtex', label: 'BibTeX', hint: 'LaTeX', styled: false },
13
+ { id: 'ris', label: 'RIS', hint: 'EndNote, Zotero', styled: false },
14
+ { id: 'doi', label: 'DOI link', hint: 'URL', styled: false },
15
+ ];
16
+ /** The style a format that has one is written in unless another is picked. */
17
+ export const DEFAULT_CITATION_STYLE = 'acs';
18
+ /**
19
+ * The files offered for download. Zotero, Mendeley and EndNote all import
20
+ * both, and their connectors recognise the MIME types below on their own.
21
+ */
22
+ export const CITATION_DOWNLOADS = [
23
+ {
24
+ format: 'ris',
25
+ label: 'RIS file',
26
+ hint: 'Zotero, Mendeley, EndNote',
27
+ extension: 'ris',
28
+ mimeType: 'application/x-research-info-systems',
29
+ },
30
+ {
31
+ format: 'bibtex',
32
+ label: 'BibTeX file',
33
+ hint: 'JabRef, Overleaf',
34
+ extension: 'bib',
35
+ mimeType: 'application/x-bibtex',
36
+ },
37
+ ];
38
+ /**
39
+ * Name the saved file carries, e.g. `Vanderveen2015.ris`.
40
+ * @param reference - Reference the file holds.
41
+ * @param extension - Extension of the file, without its dot.
42
+ * @returns The file name.
43
+ */
44
+ export function citationFilename(reference, extension) {
45
+ return `${bibTeXKey(reference)}.${extension}`;
46
+ }
47
+ /**
48
+ * Render a reference in one of the citation formats.
49
+ * @param reference - Reference to render.
50
+ * @param format - Format to render it in.
51
+ * @param style - Journal style, for the formats that have one.
52
+ * @returns The citation, ready to be copied to the clipboard.
53
+ */
54
+ export function formatCitation(reference, format, style = DEFAULT_CITATION_STYLE) {
55
+ switch (format) {
56
+ case 'text':
57
+ return renderText(citationSegments(reference, style));
58
+ case 'html':
59
+ return renderHtml(citationSegments(reference, style));
60
+ case 'markdown':
61
+ return renderMarkdown(citationSegments(reference, style));
62
+ case 'bibtex':
63
+ return formatBibTeX(reference);
64
+ case 'ris':
65
+ return formatRis(reference);
66
+ case 'doi':
67
+ return doiUrl(reference);
68
+ default:
69
+ throw new Error(`unknown citation format: ${String(format)}`);
70
+ }
71
+ }
72
+ function formatBibTeX(reference) {
73
+ const { title, journal, year, volume, issue, publisher, doi } = reference;
74
+ const { firstPage, lastPage } = reference;
75
+ const fields = [
76
+ ['author', authorList(reference, ' and ')],
77
+ ['title', title],
78
+ ['journal', journal],
79
+ ['year', String(year)],
80
+ ['volume', volume],
81
+ ['number', issue],
82
+ ['pages', `${firstPage}--${lastPage}`],
83
+ ['publisher', publisher],
84
+ ['doi', doi],
85
+ ['url', doiUrl(reference)],
86
+ ];
87
+ const body = fields
88
+ .map(([name, value]) => ` ${name} = {${value}},`)
89
+ .join('\n');
90
+ return `@article{${bibTeXKey(reference)},\n${body}\n}`;
91
+ }
92
+ function formatRis(reference) {
93
+ const { title, journal, year, volume, issue, publisher, doi } = reference;
94
+ const { authors, firstPage, lastPage } = reference;
95
+ const lines = [
96
+ ['TY', 'JOUR'],
97
+ ...authors.map((author) => [
98
+ 'AU',
99
+ `${author.family}, ${author.given}`,
100
+ ]),
101
+ ['TI', title],
102
+ ['JO', journal],
103
+ ['PY', String(year)],
104
+ ['VL', volume],
105
+ ['IS', issue],
106
+ ['SP', firstPage],
107
+ ['EP', lastPage],
108
+ ['PB', publisher],
109
+ ['DO', doi],
110
+ ['UR', doiUrl(reference)],
111
+ ['ER', ''],
112
+ ];
113
+ return lines.map(([tag, value]) => `${tag} - ${value}`).join('\n');
114
+ }
115
+ function authorList(reference, separator) {
116
+ return reference.authors
117
+ .map((author) => `${author.family}, ${author.given}`)
118
+ .join(separator);
119
+ }
120
+ function bibTeXKey(reference) {
121
+ const first = reference.authors[0];
122
+ const family = first === undefined ? 'reference' : first.family;
123
+ return `${family.replaceAll(/[^a-zA-Z]/g, '')}${reference.year}`;
124
+ }
125
+ //# sourceMappingURL=formats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formats.js","sourceRoot":"","sources":["../../../src/citation/core/formats.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAoBjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,EAAE,IAAI,EAAE;IACtE,EAAE,EAAE,EAAE,UAAU,EAAE,K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,EAAE,SAAiB;IACzD,OAAO,SAAS,CAAC,OAAO;SACrB,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC;SACpD,IAAI,CAAC,SAAS,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,SAAS,CAAC,SAAoB;IACrC,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;IAChE,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;AACnE,CAAC"}
@@ -0,0 +1,10 @@
1
+ export { copyCitation } from './clipboard.ts';
2
+ export { downloadCitation } from './download.ts';
3
+ export type { CitationDownload, CitationFormat, CitationFormatId, } from './formats.ts';
4
+ export { CITATION_DOWNLOADS, CITATION_FORMATS, DEFAULT_CITATION_STYLE, citationFilename, formatCitation, } from './formats.ts';
5
+ export type { Reference, ReferenceAuthor } from './reference.ts';
6
+ export { doiUrl } from './reference.ts';
7
+ export { renderHtml, renderMarkdown, renderText } from './render.ts';
8
+ export type { CitationSegment, CitationStyle, CitationStyleId, } from './segments.ts';
9
+ export { CITATION_STYLES, citationSegments } from './segments.ts';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/citation/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrE,YAAY,EACV,eAAe,EACf,aAAa,EACb,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { copyCitation } from "./clipboard.js";
2
+ export { downloadCitation } from "./download.js";
3
+ export { CITATION_DOWNLOADS, CITATION_FORMATS, DEFAULT_CITATION_STYLE, citationFilename, formatCitation, } from "./formats.js";
4
+ export { doiUrl } from "./reference.js";
5
+ export { renderHtml, renderMarkdown, renderText } from "./render.js";
6
+ export { CITATION_STYLES, citationSegments } from "./segments.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/citation/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAMjD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMrE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,30 @@
1
+ /** One author of a reference, as the citation styles need them. */
2
+ export interface ReferenceAuthor {
3
+ /** Initials or first name, e.g. `J. R.`. */
4
+ given: string;
5
+ /** Family name, e.g. `Vanderveen`. */
6
+ family: string;
7
+ }
8
+ /** A journal article, with everything the citation formats need. */
9
+ export interface Reference {
10
+ authors: readonly ReferenceAuthor[];
11
+ title: string;
12
+ /** Full journal name, e.g. `Green Chemistry`. */
13
+ journal: string;
14
+ /** Abbreviated journal name, e.g. `Green Chem.`. */
15
+ journalAbbreviation: string;
16
+ year: number;
17
+ volume: string;
18
+ issue: string;
19
+ firstPage: string;
20
+ lastPage: string;
21
+ doi: string;
22
+ publisher: string;
23
+ }
24
+ /**
25
+ * Resolvable address of a reference.
26
+ * @param reference - Reference to link to.
27
+ * @returns The `https://doi.org/…` URL.
28
+ */
29
+ export declare function doiUrl(reference: Reference): string;
30
+ //# sourceMappingURL=reference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/citation/core/reference.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,oEAAoE;AACpE,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAEnD"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Resolvable address of a reference.
3
+ * @param reference - Reference to link to.
4
+ * @returns The `https://doi.org/…` URL.
5
+ */
6
+ export function doiUrl(reference) {
7
+ return `https://doi.org/${reference.doi}`;
8
+ }
9
+ //# sourceMappingURL=reference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference.js","sourceRoot":"","sources":["../../../src/citation/core/reference.ts"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,SAAoB;IACzC,OAAO,mBAAmB,SAAS,CAAC,GAAG,EAAE,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { CitationSegment } from './segments.ts';
2
+ /**
3
+ * Write the segments as they read in an email or a manuscript.
4
+ * @param segments - Segments of the citation.
5
+ * @returns The citation, with no markup at all.
6
+ */
7
+ export declare function renderText(segments: readonly CitationSegment[]): string;
8
+ /**
9
+ * Write the segments as HTML, so a paste into Word or a web page keeps the
10
+ * italics and the bold the style asks for.
11
+ * @param segments - Segments of the citation.
12
+ * @returns The citation as one line of HTML.
13
+ */
14
+ export declare function renderHtml(segments: readonly CitationSegment[]): string;
15
+ /**
16
+ * Write the segments as Markdown, for a README or an issue.
17
+ * @param segments - Segments of the citation.
18
+ * @returns The citation as one line of Markdown.
19
+ */
20
+ export declare function renderMarkdown(segments: readonly CitationSegment[]): string;
21
+ //# sourceMappingURL=render.d.ts.map