react-cheminfo 0.136.0 → 0.138.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 (107) hide show
  1. package/README.md +1 -1
  2. package/lib/crystal3d/core/crystalView.d.ts +10 -0
  3. package/lib/crystal3d/core/crystalView.d.ts.map +1 -1
  4. package/lib/crystal3d/core/crystalView.js +7 -0
  5. package/lib/crystal3d/core/crystalView.js.map +1 -1
  6. package/lib/crystal3d/core/index.d.ts +2 -2
  7. package/lib/crystal3d/core/index.d.ts.map +1 -1
  8. package/lib/crystal3d/core/index.js +1 -1
  9. package/lib/crystal3d/core/index.js.map +1 -1
  10. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts.map +1 -1
  11. package/lib/crystal3d/ui/CrystalCanvas3D.js +9 -1
  12. package/lib/crystal3d/ui/CrystalCanvas3D.js.map +1 -1
  13. package/lib/crystal3d/ui/CrystalStructureView.js +5 -2
  14. package/lib/crystal3d/ui/CrystalStructureView.js.map +1 -1
  15. package/lib/crystal3d/ui/CrystalViewControls.d.ts +7 -3
  16. package/lib/crystal3d/ui/CrystalViewControls.d.ts.map +1 -1
  17. package/lib/crystal3d/ui/CrystalViewControls.js +6 -4
  18. package/lib/crystal3d/ui/CrystalViewControls.js.map +1 -1
  19. package/lib/crystal3d/ui/crystalScene.d.ts +6 -0
  20. package/lib/crystal3d/ui/crystalScene.d.ts.map +1 -1
  21. package/lib/crystal3d/viewer/renderStructure.d.ts +25 -0
  22. package/lib/crystal3d/viewer/renderStructure.d.ts.map +1 -1
  23. package/lib/crystal3d/viewer/renderStructure.js +41 -1
  24. package/lib/crystal3d/viewer/renderStructure.js.map +1 -1
  25. package/lib/crystal3d/viewer/viewer.d.ts +11 -2
  26. package/lib/crystal3d/viewer/viewer.d.ts.map +1 -1
  27. package/lib/crystal3d/viewer/viewer.js +17 -2
  28. package/lib/crystal3d/viewer/viewer.js.map +1 -1
  29. package/lib/download/core/croppedMarkup.d.ts.map +1 -1
  30. package/lib/download/core/croppedMarkup.js +16 -40
  31. package/lib/download/core/croppedMarkup.js.map +1 -1
  32. package/lib/download/core/dataUrl.d.ts +27 -0
  33. package/lib/download/core/dataUrl.d.ts.map +1 -0
  34. package/lib/download/core/dataUrl.js +54 -0
  35. package/lib/download/core/dataUrl.js.map +1 -0
  36. package/lib/download/core/index.d.ts +3 -0
  37. package/lib/download/core/index.d.ts.map +1 -1
  38. package/lib/download/core/index.js +2 -0
  39. package/lib/download/core/index.js.map +1 -1
  40. package/lib/download/core/svgMarkup.d.ts +39 -0
  41. package/lib/download/core/svgMarkup.d.ts.map +1 -0
  42. package/lib/download/core/svgMarkup.js +100 -0
  43. package/lib/download/core/svgMarkup.js.map +1 -0
  44. package/lib/drawing/render/motion.d.ts +2 -2
  45. package/lib/drawing/render/motion.d.ts.map +1 -1
  46. package/lib/drawing/render/motion.js +23 -4
  47. package/lib/drawing/render/motion.js.map +1 -1
  48. package/lib/drawing/render/primitives.d.ts +14 -0
  49. package/lib/drawing/render/primitives.d.ts.map +1 -1
  50. package/lib/drawing/render/svg.d.ts.map +1 -1
  51. package/lib/drawing/render/svg.js +27 -7
  52. package/lib/drawing/render/svg.js.map +1 -1
  53. package/lib/drawing/ui/movingFigure.d.ts.map +1 -1
  54. package/lib/drawing/ui/movingFigure.js +4 -30
  55. package/lib/drawing/ui/movingFigure.js.map +1 -1
  56. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  57. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  58. package/lib/locales/de.json +7 -0
  59. package/lib/locales/en.json +7 -0
  60. package/lib/locales/es.json +7 -0
  61. package/lib/locales/fr.json +7 -0
  62. package/lib/locales/it.json +7 -0
  63. package/lib/referents/core/figureReferents.d.ts +3 -2
  64. package/lib/referents/core/figureReferents.d.ts.map +1 -1
  65. package/lib/referents/core/figureReferents.js +6 -3
  66. package/lib/referents/core/figureReferents.js.map +1 -1
  67. package/lib/referents/core/index.d.ts +1 -0
  68. package/lib/referents/core/index.d.ts.map +1 -1
  69. package/lib/referents/core/index.js +1 -0
  70. package/lib/referents/core/index.js.map +1 -1
  71. package/lib/referents/core/quoteParts.d.ts +21 -0
  72. package/lib/referents/core/quoteParts.d.ts.map +1 -0
  73. package/lib/referents/core/quoteParts.js +71 -0
  74. package/lib/referents/core/quoteParts.js.map +1 -0
  75. package/lib/referents/core/readReferents.d.ts +2 -1
  76. package/lib/referents/core/readReferents.d.ts.map +1 -1
  77. package/lib/referents/core/readReferents.js +28 -2
  78. package/lib/referents/core/readReferents.js.map +1 -1
  79. package/lib/referents/core/types.d.ts +44 -0
  80. package/lib/referents/core/types.d.ts.map +1 -1
  81. package/package.json +1 -1
  82. package/src/crystal3d/core/crystalView.ts +17 -0
  83. package/src/crystal3d/core/index.ts +2 -0
  84. package/src/crystal3d/ui/CrystalCanvas3D.tsx +9 -0
  85. package/src/crystal3d/ui/CrystalStructureView.tsx +7 -2
  86. package/src/crystal3d/ui/CrystalViewControls.tsx +33 -4
  87. package/src/crystal3d/ui/crystalScene.ts +6 -0
  88. package/src/crystal3d/viewer/renderStructure.ts +66 -1
  89. package/src/crystal3d/viewer/viewer.ts +19 -3
  90. package/src/download/core/croppedMarkup.ts +16 -42
  91. package/src/download/core/dataUrl.ts +59 -0
  92. package/src/download/core/index.ts +3 -0
  93. package/src/download/core/svgMarkup.ts +113 -0
  94. package/src/drawing/render/motion.ts +23 -4
  95. package/src/drawing/render/primitives.ts +14 -0
  96. package/src/drawing/render/svg.ts +34 -7
  97. package/src/drawing/ui/movingFigure.ts +4 -28
  98. package/src/locales/de.json +7 -0
  99. package/src/locales/en.json +7 -0
  100. package/src/locales/es.json +7 -0
  101. package/src/locales/fr.json +7 -0
  102. package/src/locales/it.json +7 -0
  103. package/src/referents/core/figureReferents.ts +8 -3
  104. package/src/referents/core/index.ts +1 -0
  105. package/src/referents/core/quoteParts.ts +82 -0
  106. package/src/referents/core/readReferents.ts +27 -2
  107. package/src/referents/core/types.ts +45 -0
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The text of a quote a figure carries, read out of its inline HTML as runs of
3
+ * text and the marks over them: what a document inserts, and what a menu
4
+ * shows. Only the marks a quote may carry are read; every other tag is
5
+ * dropped, its text kept, so nothing a figure carries is ever run as markup.
6
+ */
7
+ import { unescapeXml } from "../../drawing/render/markup.js";
8
+ const MARKS = {
9
+ sup: 'superscript',
10
+ sub: 'subscript',
11
+ i: 'italic',
12
+ em: 'italic',
13
+ b: 'bold',
14
+ strong: 'bold',
15
+ };
16
+ const TAG = /^<(?<close>\/)?(?<name>[a-z][a-z\d]*)\b[^>]*>$/i;
17
+ /**
18
+ * The runs of a quote's text.
19
+ * @param html - The quote, as inline HTML.
20
+ * @returns Its text, run by run; adjacent runs under the same marks are one.
21
+ */
22
+ export function quoteParts(html) {
23
+ const parts = [];
24
+ const open = [];
25
+ for (const token of html.split(/(?<tag><[^>]*>)/)) {
26
+ if (token === '')
27
+ continue;
28
+ if (token.startsWith('<')) {
29
+ const groups = TAG.exec(token)?.groups;
30
+ const mark = MARKS[groups?.name?.toLowerCase() ?? ''];
31
+ if (mark === undefined)
32
+ continue;
33
+ if (groups?.close === undefined) {
34
+ open.push(mark);
35
+ }
36
+ else {
37
+ const index = open.lastIndexOf(mark);
38
+ if (index !== -1)
39
+ open.splice(index, 1);
40
+ }
41
+ continue;
42
+ }
43
+ append(parts, decoded(token), [...new Set(open)]);
44
+ }
45
+ return parts;
46
+ }
47
+ function append(parts, text, marks) {
48
+ if (text === '')
49
+ return;
50
+ const last = parts.at(-1);
51
+ if (last !== undefined && sameMarks(last.marks, marks)) {
52
+ last.text += text;
53
+ }
54
+ else {
55
+ parts.push({ text, marks });
56
+ }
57
+ }
58
+ function sameMarks(first, second) {
59
+ return (first.length === second.length &&
60
+ first.every((mark) => second.includes(mark)));
61
+ }
62
+ function decoded(text) {
63
+ try {
64
+ return unescapeXml(text);
65
+ }
66
+ catch {
67
+ // A character reference past the last code point: kept as written.
68
+ return text;
69
+ }
70
+ }
71
+ //# sourceMappingURL=quoteParts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quoteParts.js","sourceRoot":"","sources":["../../../src/referents/core/quoteParts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAY7D,MAAM,KAAK,GAAwC;IACjD,GAAG,EAAE,aAAa;IAClB,GAAG,EAAE,WAAW;IAChB,CAAC,EAAE,QAAQ;IACX,EAAE,EAAE,QAAQ;IACZ,CAAC,EAAE,MAAM;IACT,MAAM,EAAE,MAAM;CACf,CAAC;AAEF,MAAM,GAAG,GAAG,iDAAiD,CAAC;AAE9D;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,MAAM,IAAI,GAAgB,EAAE,CAAC;IAC7B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAClD,IAAI,KAAK,KAAK,EAAE;YAAE,SAAS;QAC3B,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;YACvC,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;YACtD,IAAI,IAAI,KAAK,SAAS;gBAAE,SAAS;YACjC,IAAI,MAAM,EAAE,KAAK,KAAK,SAAS,EAAE,CAAC;gBAChC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClB,CAAC;iBAAM,CAAC;gBACN,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACrC,IAAI,KAAK,KAAK,CAAC,CAAC;oBAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC1C,CAAC;YACD,SAAS;QACX,CAAC;QACD,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,MAAM,CAAC,KAAkB,EAAE,IAAY,EAAE,KAAkB;IAClE,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO;IACxB,MAAM,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,IAAI,KAAK,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC;QACvD,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;IACpB,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAAkB,EAAE,MAAmB;IACxD,OAAO,CACL,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAC7C,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,IAAY;IAC3B,IAAI,CAAC;QACH,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,mEAAmE;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -6,7 +6,8 @@ import type { FigureReferents } from './types.ts';
6
6
  /**
7
7
  * Referents from parsed JSON.
8
8
  * @param value - What was parsed.
9
- * @returns The referents and series that read; empty lists for anything else.
9
+ * @returns The referents, series and quotes that read; empty lists for
10
+ * anything else, and no quotes when none read.
10
11
  */
11
12
  export declare function readReferents(value: unknown): FigureReferents;
12
13
  //# sourceMappingURL=readReferents.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"readReferents.d.ts","sourceRoot":"","sources":["../../../src/referents/core/readReferents.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAEV,eAAe,EAKhB,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAa7D"}
1
+ {"version":3,"file":"readReferents.d.ts","sourceRoot":"","sources":["../../../src/referents/core/readReferents.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAGV,eAAe,EAKhB,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAoB7D"}
@@ -5,7 +5,8 @@
5
5
  /**
6
6
  * Referents from parsed JSON.
7
7
  * @param value - What was parsed.
8
- * @returns The referents and series that read; empty lists for anything else.
8
+ * @returns The referents, series and quotes that read; empty lists for
9
+ * anything else, and no quotes when none read.
9
10
  */
10
11
  export function readReferents(value) {
11
12
  const record = isRecord(value) ? value : {};
@@ -21,7 +22,32 @@ export function readReferents(value) {
21
22
  if (one)
22
23
  series.push(one);
23
24
  }
24
- return { referents, series };
25
+ const quotes = [];
26
+ for (const item of listOf(record.quotes)) {
27
+ const quote = readQuote(item);
28
+ if (quote)
29
+ quotes.push(quote);
30
+ }
31
+ return quotes.length === 0
32
+ ? { referents, series }
33
+ : { referents, series, quotes };
34
+ }
35
+ function readQuote(value) {
36
+ if (!isRecord(value) || !isKey(value.key) || !isKey(value.kind)) {
37
+ return undefined;
38
+ }
39
+ if (!isText(value.title) || !isText(value.html))
40
+ return undefined;
41
+ const quote = {
42
+ key: value.key,
43
+ kind: value.kind,
44
+ title: value.title,
45
+ html: value.html,
46
+ };
47
+ if (isText(value.picture))
48
+ quote.picture = value.picture;
49
+ copyStructure(value, quote);
50
+ return quote;
25
51
  }
26
52
  function readReferent(value) {
27
53
  if (!isRecord(value) || !isKey(value.key))
@@ -1 +1 @@
1
- {"version":3,"file":"readReferents.js","sourceRoot":"","sources":["../../../src/referents/core/readReferents.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5C,MAAM,SAAS,GAAqB,EAAE,CAAC;IACvC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5C,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,QAAQ;YAAE,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;IACD,MAAM,MAAM,GAAqB,EAAE,CAAC;IACpC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACzC,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,GAAG;YAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;AAC/B,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5D,MAAM,QAAQ,GAAmB,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;IACpD,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;QAAE,QAAQ,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI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EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC;AAChF,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC"}
@@ -124,12 +124,56 @@ export interface ReferentSeries {
124
124
  */
125
125
  numbering?: SeriesNumbering;
126
126
  }
127
+ /**
128
+ * A text a figure lets a document quote as it stands, rather than number: the
129
+ * description of an NMR spectrum as a journal prints it, offered by the `@`
130
+ * menu of the document the figure is placed in.
131
+ */
132
+ export interface FigureQuote {
133
+ /** What names it, stable for as long as the figure carries it. */
134
+ key: string;
135
+ /** What it is, `nmr`: quotes of one kind are offered together. */
136
+ kind: string;
137
+ /** What it is offered as, `¹H NMR · ethylbenzene`. */
138
+ title: string;
139
+ /**
140
+ * The text, as inline HTML: only `<sup>`, `<sub>`, `<i>`, `<em>`, `<b>` and
141
+ * `<strong>` are read, by `quoteParts`.
142
+ */
143
+ html: string;
144
+ /**
145
+ * What it describes, as an SVG document: the structure the spectrum was
146
+ * recorded on.
147
+ * @default undefined — named by its title alone
148
+ */
149
+ picture?: string;
150
+ /**
151
+ * The structure as an OpenChemLib ID code.
152
+ * @default undefined
153
+ */
154
+ idCode?: string;
155
+ /**
156
+ * The structure as SMILES.
157
+ * @default undefined
158
+ */
159
+ smiles?: string;
160
+ /**
161
+ * The structure's molecular formula.
162
+ * @default undefined
163
+ */
164
+ mf?: string;
165
+ }
127
166
  /** What a figure numbers. */
128
167
  export interface FigureReferents {
129
168
  /** The referents, in the order their labels are read. */
130
169
  referents: FigureReferent[];
131
170
  /** The series the figure defines. */
132
171
  series: ReferentSeries[];
172
+ /**
173
+ * The texts it lets a document quote.
174
+ * @default undefined — none
175
+ */
176
+ quotes?: FigureQuote[];
133
177
  }
134
178
  /** A label, or a reference in the text: a referent, or one of its members. */
135
179
  export interface ReferentMention {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/referents/core/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,qEAAqE;AACrE,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC7B,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED,kEAAkE;AAClE,MAAM,WAAW,SAAS;IACxB,4EAA4E;IAC5E,EAAE,EAAE,MAAM,CAAC;IACX,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,MAAM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AAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,6BAA6B;AAC7B,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,qCAAqC;IACrC,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;CACxB;AAED,8EAA8E;AAC9E,MAAM,WAAW,eAAe;IAC9B,oBAAoB;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-cheminfo",
3
- "version": "0.136.0",
3
+ "version": "0.138.0",
4
4
  "license": "MIT",
5
5
  "description": "React components, hooks and framework-free helpers shared by the cheminfo sites: site chrome, citations, sharing, routing, pedagogy, charts, and the structure, orbital and 3D molecule viewers",
6
6
  "author": "Luc Patiny",
@@ -27,6 +27,20 @@ export const CRYSTAL_PACKINGS: readonly CrystalPacking[] = [
27
27
  'cell',
28
28
  ];
29
29
 
30
+ /**
31
+ * Which bonds are drawn: every one, all but those to a metal atom (molstar
32
+ * draws those dashed, and a coordination network of them hides the rest), or
33
+ * none.
34
+ */
35
+ export type CrystalBonds = 'all' | 'noMetal' | 'none';
36
+
37
+ /** Every choice of bonds, in the order a control offers them. */
38
+ export const CRYSTAL_BONDS: readonly CrystalBonds[] = [
39
+ 'all',
40
+ 'noMetal',
41
+ 'none',
42
+ ];
43
+
30
44
  /** The cells along each axis a control offers, and a link may ask for. */
31
45
  export const CELL_COUNT_RANGE = { minimum: 1, maximum: 4 } as const;
32
46
 
@@ -104,6 +118,8 @@ export interface CrystalViewSettings {
104
118
  readonly cells: number;
105
119
  /** Whether the box of the unit cell is drawn. */
106
120
  readonly unitCell: boolean;
121
+ /** Which bonds are drawn. */
122
+ readonly bonds: CrystalBonds;
107
123
  }
108
124
 
109
125
  /** One cell, its molecules whole, inside its box. */
@@ -111,4 +127,5 @@ export const DEFAULT_CRYSTAL_VIEW_SETTINGS: CrystalViewSettings = {
111
127
  packing: 'molecules',
112
128
  cells: 1,
113
129
  unitCell: true,
130
+ bonds: 'all',
114
131
  };
@@ -119,6 +119,7 @@ export {
119
119
  repeatedAtomCount,
120
120
  } from './cellStack.ts';
121
121
  export type {
122
+ CrystalBonds,
122
123
  CrystalPacking,
123
124
  CrystalView,
124
125
  CrystalViewOptions,
@@ -126,6 +127,7 @@ export type {
126
127
  } from './crystalView.ts';
127
128
  export {
128
129
  CELL_COUNT_RANGE,
130
+ CRYSTAL_BONDS,
129
131
  CRYSTAL_PACKINGS,
130
132
  DEFAULT_CRYSTAL_VIEW_SETTINGS,
131
133
  crystalView,
@@ -83,6 +83,7 @@ export function CrystalCanvas3D(props: CrystalCanvas3DProps): ReactElement {
83
83
  cell = null,
84
84
  repeat,
85
85
  representation,
86
+ bonds = 'all',
86
87
  elements,
87
88
  labels,
88
89
  elementStyle,
@@ -202,6 +203,14 @@ export function CrystalCanvas3D(props: CrystalCanvas3DProps): ReactElement {
202
203
  void report(failure, work);
203
204
  }, [container, background, atoms, cell, repeat, representation]);
204
205
 
206
+ // Declared after the structure, so a new viewer draws its first structure
207
+ // with these bonds; a later change redraws the bonds alone.
208
+ useEffect(() => {
209
+ const viewer = held.current;
210
+ if (viewer === null) return;
211
+ void report(failure, viewer.setBonds(bonds));
212
+ }, [container, background, bonds]);
213
+
205
214
  // Once the structure above is on screen, so they are drawn on the atoms they
206
215
  // name.
207
216
  useEffect(() => {
@@ -93,7 +93,7 @@ type CrystalDrawingProps = Required<
93
93
 
94
94
  function CrystalDrawing(props: CrystalDrawingProps): ReactElement {
95
95
  const { cell, name, settings, onSettingsChange, ...viewer } = props;
96
- const { packing, cells, unitCell } = settings;
96
+ const { packing, cells, unitCell, bonds } = settings;
97
97
  const view = useMemo(
98
98
  () => crystalView(cell.atoms, cell.lattice, { packing, cells, bondLimit }),
99
99
  [cell, packing, cells],
@@ -103,8 +103,9 @@ function CrystalDrawing(props: CrystalDrawingProps): ReactElement {
103
103
  atoms: view.atoms,
104
104
  cell: unitCell ? cell.lattice.cell : null,
105
105
  repeat: [view.cells, view.cells, view.cells],
106
+ bonds,
106
107
  }),
107
- [view, unitCell, cell],
108
+ [view, unitCell, cell, bonds],
108
109
  );
109
110
  const caption = useCrystalCaption(name, view, cells);
110
111
  return (
@@ -119,6 +120,10 @@ function CrystalDrawing(props: CrystalDrawingProps): ReactElement {
119
120
  onUnitCellChange={(next) => {
120
121
  onSettingsChange({ ...settings, unitCell: next });
121
122
  }}
123
+ bonds={bonds}
124
+ onBondsChange={(next) => {
125
+ onSettingsChange({ ...settings, bonds: next });
126
+ }}
122
127
  cells={cells}
123
128
  onCellsChange={(next) => {
124
129
  onSettingsChange({ ...settings, cells: next });
@@ -1,13 +1,18 @@
1
1
  /**
2
2
  * How a crystal is drawn: whole molecules or the atoms the cell cuts, whether
3
- * the box of the cell is drawn, and how many cells along each axis.
3
+ * the box of the cell is drawn, which bonds, and how many cells along each
4
+ * axis.
4
5
  */
5
6
 
6
7
  import type { ReactElement } from 'react';
7
8
 
8
9
  import { useChromeT } from '../../i18n/ui/useT.ts';
9
- import type { CrystalPacking } from '../core/crystalView.ts';
10
- import { CELL_COUNT_RANGE, CRYSTAL_PACKINGS } from '../core/crystalView.ts';
10
+ import type { CrystalBonds, CrystalPacking } from '../core/crystalView.ts';
11
+ import {
12
+ CELL_COUNT_RANGE,
13
+ CRYSTAL_BONDS,
14
+ CRYSTAL_PACKINGS,
15
+ } from '../core/crystalView.ts';
11
16
 
12
17
  /** Props of {@link CrystalViewControls}. */
13
18
  export interface CrystalViewControlsProps {
@@ -17,13 +22,16 @@ export interface CrystalViewControlsProps {
17
22
  /** Whether the box of the unit cell is drawn. */
18
23
  unitCell: boolean;
19
24
  onUnitCellChange: (unitCell: boolean) => void;
25
+ /** Which bonds are drawn. */
26
+ bonds: CrystalBonds;
27
+ onBondsChange: (bonds: CrystalBonds) => void;
20
28
  /** Cells along each axis. */
21
29
  cells: number;
22
30
  onCellsChange: (cells: number) => void;
23
31
  }
24
32
 
25
33
  /**
26
- * The two rows of chips under a crystal.
34
+ * The rows of chips under a crystal.
27
35
  * @param props - See {@link CrystalViewControlsProps}.
28
36
  * @returns The chip bar.
29
37
  */
@@ -35,6 +43,8 @@ export function CrystalViewControls(
35
43
  onPackingChange,
36
44
  unitCell,
37
45
  onUnitCellChange,
46
+ bonds,
47
+ onBondsChange,
38
48
  cells,
39
49
  onCellsChange,
40
50
  } = props;
@@ -71,6 +81,25 @@ export function CrystalViewControls(
71
81
  </button>
72
82
  </div>
73
83
  </div>
84
+ <div className="chip-row">
85
+ <div className="chip-row__label">{t('crystal3d.bonds')}</div>
86
+ <div className="chip-row__chips">
87
+ {CRYSTAL_BONDS.map((value) => (
88
+ <button
89
+ key={value}
90
+ type="button"
91
+ className="chip"
92
+ aria-pressed={bonds === value}
93
+ title={t(`crystal3d.bonds.${value}Help`)}
94
+ onClick={() => {
95
+ onBondsChange(value);
96
+ }}
97
+ >
98
+ {t(`crystal3d.bonds.${value}`)}
99
+ </button>
100
+ ))}
101
+ </div>
102
+ </div>
74
103
  <div className="chip-row">
75
104
  <div className="chip-row__label">{t('crystal3d.cells')}</div>
76
105
  <div className="chip-row__chips">
@@ -9,6 +9,7 @@
9
9
 
10
10
  import type { Molecule3DCamera } from '../../molecule3d/core/camera.ts';
11
11
  import type { Molecule3DCapture } from '../../molecule3d/ui/moleculeViewer3DProps.ts';
12
+ import type { CrystalBonds } from '../core/crystalView.ts';
12
13
  import type { ElementStyle } from '../core/primitives.ts';
13
14
  import type {
14
15
  CellRepeat,
@@ -75,6 +76,11 @@ export interface CrystalScene {
75
76
  * @default 'ball-and-stick'
76
77
  */
77
78
  readonly representation?: 'ball-and-stick' | 'spacefill';
79
+ /**
80
+ * Which bonds are drawn; changing it leaves the camera where it is.
81
+ * @default 'all'
82
+ */
83
+ readonly bonds?: CrystalBonds;
78
84
  /**
79
85
  * An operation waiting to be applied.
80
86
  * @default null
@@ -9,8 +9,12 @@
9
9
  import type { Structure } from 'molstar/lib/mol-model/structure.js';
10
10
  import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
11
11
  import { PluginStateObject } from 'molstar/lib/mol-plugin-state/objects.js';
12
+ import { StateTransforms } from 'molstar/lib/mol-plugin-state/transforms.js';
12
13
  import type { Representation } from 'molstar/lib/mol-repr/representation.js';
14
+ import type { BallAndStickParams } from 'molstar/lib/mol-repr/structure/representation/ball-and-stick.js';
15
+ import type { ParamDefinition } from 'molstar/lib/mol-util/param-definition.js';
13
16
 
17
+ import type { CrystalBonds } from '../core/crystalView.ts';
14
18
  import { toXyzText } from '../core/structureText.ts';
15
19
  import type { ViewerAtom } from '../core/types.ts';
16
20
 
@@ -27,6 +31,11 @@ export interface StructureStyle {
27
31
  * @default 0.25
28
32
  */
29
33
  sizeFactor?: number;
34
+ /**
35
+ * Which bonds the balls and sticks draw.
36
+ * @default 'all'
37
+ */
38
+ bonds?: CrystalBonds;
30
39
  }
31
40
 
32
41
  /**
@@ -43,7 +52,11 @@ export async function renderStructure(
43
52
  ): Promise<void> {
44
53
  await clearStructure(plugin);
45
54
  if (atoms.length === 0) return;
46
- const { representation = 'ball-and-stick', sizeFactor = 0.25 } = style;
55
+ const {
56
+ representation = 'ball-and-stick',
57
+ sizeFactor = 0.25,
58
+ bonds = 'all',
59
+ } = style;
47
60
 
48
61
  const data = await plugin.builders.data.rawData(
49
62
  { data: toXyzText(atoms) },
@@ -79,6 +92,7 @@ export async function renderStructure(
79
92
  sizeFactor,
80
93
  sizeAspectRatio: 2 / 3,
81
94
  aromaticBonds: false,
95
+ ...bondParams(bonds),
82
96
  },
83
97
  color: 'element-symbol',
84
98
  colorParams: {
@@ -89,6 +103,51 @@ export async function renderStructure(
89
103
  representationRefs.set(plugin, drawn.ref);
90
104
  }
91
105
 
106
+ /**
107
+ * Draw other bonds between the atoms on screen, in place: the camera, the
108
+ * measurements and an operation half applied all stay where they are.
109
+ * @param plugin - The molstar context.
110
+ * @param bonds - Which bonds are drawn.
111
+ */
112
+ export async function setStructureBonds(
113
+ plugin: PluginContext,
114
+ bonds: CrystalBonds,
115
+ ): Promise<void> {
116
+ const ref = representationRefs.get(plugin);
117
+ if (ref === undefined) return;
118
+ await plugin
119
+ .build()
120
+ .to(ref)
121
+ .update(StateTransforms.Representation.StructureRepresentation3D, (old) =>
122
+ old.type.name === 'ball-and-stick'
123
+ ? {
124
+ ...old,
125
+ type: {
126
+ ...old.type,
127
+ params: { ...old.type.params, ...bondParams(bonds) },
128
+ },
129
+ }
130
+ : old,
131
+ )
132
+ .commit();
133
+ }
134
+
135
+ /**
136
+ * The ball-and-stick parameters that draw these bonds. A metal's bonds are
137
+ * molstar's metal coordination, which it draws dashed.
138
+ * @param bonds - Which bonds are drawn.
139
+ * @returns The parameters to merge into the representation's own.
140
+ */
141
+ export function bondParams(bonds: CrystalBonds): BondParams {
142
+ return {
143
+ visuals:
144
+ bonds === 'none'
145
+ ? ['element-sphere']
146
+ : ['element-sphere', 'intra-bond', 'inter-bond'],
147
+ excludeTypes: bonds === 'noMetal' ? ['metal-coordination'] : [],
148
+ };
149
+ }
150
+
92
151
  /**
93
152
  * Remove the atoms, leaving every drawn layer in place.
94
153
  * @param plugin - The molstar context.
@@ -134,6 +193,12 @@ export function crystalStructure(plugin: PluginContext): Structure | undefined {
134
193
  return object.data;
135
194
  }
136
195
 
196
+ /** The ball-and-stick parameters that say which bonds are drawn. */
197
+ type BondParams = Pick<
198
+ ParamDefinition.Values<BallAndStickParams>,
199
+ 'visuals' | 'excludeTypes'
200
+ >;
201
+
137
202
  /** Deleting this ref deletes the model and the representation under it. */
138
203
  const STRUCTURE_DATA_REF = 'crystal3d-structure-data';
139
204
 
@@ -9,6 +9,7 @@
9
9
  */
10
10
 
11
11
  import { clearMeasurements } from '../../molstar/core/index.ts';
12
+ import type { CrystalBonds } from '../core/crystalView.ts';
12
13
  import { mergeDrawings, withoutDrawings } from '../core/drawingSet.ts';
13
14
  import type {
14
15
  CellRepeat,
@@ -29,6 +30,7 @@ import { CrystalViewerPlugin } from './plugin.ts';
29
30
  import type { CellStyle } from './renderCell.ts';
30
31
  import type { ElementLayerStyle } from './renderElements.ts';
31
32
  import type { StructureStyle } from './renderStructure.ts';
33
+ import { setStructureBonds } from './renderStructure.ts';
32
34
  import { drawCell, drawElements, drawStructure } from './sceneParts.ts';
33
35
 
34
36
  /**
@@ -53,6 +55,7 @@ export function createCrystalViewer(
53
55
  export class CrystalViewer extends CrystalViewerPlugin {
54
56
  #drawings: readonly SymmetryDrawing[] = [];
55
57
  #elementStyle: ElementLayerStyle = {};
58
+ #bonds: CrystalBonds = 'all';
56
59
 
57
60
  /**
58
61
  * The symmetry elements drawn right now, in drawing order.
@@ -66,20 +69,33 @@ export class CrystalViewer extends CrystalViewerPlugin {
66
69
  * Replace the atoms on screen.
67
70
  * @param atoms - The whole scene, expanded and repeated already, in Cartesian
68
71
  * ångström. An empty list clears them.
69
- * @param style - See {@link StructureStyle}.
72
+ * @param style - See {@link StructureStyle}; its bonds are the ones last
73
+ * set by {@link CrystalViewer.setBonds}.
70
74
  * @returns Resolves once the atoms are drawn.
71
75
  */
72
76
  showStructure(
73
77
  atoms: readonly ViewerAtom[],
74
- style?: StructureStyle,
78
+ style?: Omit<StructureStyle, 'bonds'>,
75
79
  ): Promise<void> {
76
80
  // A measurement names atoms of the structure it was taken on.
77
81
  return this.run(async (plugin) => {
78
82
  await clearMeasurements(plugin);
79
- await drawStructure(plugin, atoms, style);
83
+ await drawStructure(plugin, atoms, { ...style, bonds: this.#bonds });
80
84
  });
81
85
  }
82
86
 
87
+ /**
88
+ * Draw other bonds, on the atoms on screen and on every later structure. The
89
+ * atoms are not drawn again, so the camera stays where it is.
90
+ * @param bonds - Which bonds are drawn.
91
+ * @returns Resolves once they are drawn.
92
+ */
93
+ setBonds(bonds: CrystalBonds): Promise<void> {
94
+ if (bonds === this.#bonds) return Promise.resolve();
95
+ this.#bonds = bonds;
96
+ return this.run((plugin) => setStructureBonds(plugin, bonds));
97
+ }
98
+
83
99
  /**
84
100
  * Remove the atoms, leaving the cell and the elements in place.
85
101
  * @returns Resolves once the atoms are gone.