@datagrok/helm 2.8.2 → 2.10.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.
- package/CHANGELOG.md +8 -0
- package/README.md +2 -2
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +4 -4
- package/src/helm-helper.ts +36 -5
- package/src/utils/helm-service.ts +14 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/helm",
|
|
3
3
|
"friendlyName": "Helm",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.10.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Maria Dolotova",
|
|
7
7
|
"email": "mdolotova@datagrok.ai"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"css/helm.css"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@datagrok-libraries/bio": "^5.50.
|
|
19
|
+
"@datagrok-libraries/bio": "^5.50.1",
|
|
20
20
|
"@datagrok-libraries/chem-meta": "^1.2.7",
|
|
21
21
|
"cash-dom": "^8.1.1",
|
|
22
22
|
"@datagrok-libraries/utils": "^4.4.0",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"dayjs": "^1.10.6",
|
|
25
25
|
"lru-cache": "^10.4.3",
|
|
26
26
|
"rxjs": "^6.5.5",
|
|
27
|
-
"wu": "^2.1.0"
|
|
27
|
+
"wu": "^2.1.0",
|
|
28
|
+
"@datagrok-libraries/helm-web-editor": "^1.1.14"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@datagrok-libraries/helm-web-editor": "^1.1.13",
|
|
31
31
|
"@datagrok-libraries/js-draw-lite": "^0.0.10",
|
|
32
32
|
"@datagrok/bio": "^2.18.4",
|
|
33
33
|
"@datagrok/chem": "^1.13.0",
|
package/src/helm-helper.ts
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
App, Point, HelmType, IHelmBio, HelmAtom, HelmBond, HelmMol, GetMonomerFunc, GetMonomerResType,
|
|
10
10
|
MonomerExplorer, TabDescType, MonomersFuncs, MonomerSetType, ISeqMonomer, PolymerType, MonomerType,
|
|
11
11
|
DojoType, JSDraw2ModuleType, IHelmEditorOptions, IHelmDrawOptions,
|
|
12
|
+
Editor,
|
|
13
|
+
IBio,
|
|
12
14
|
} from '@datagrok-libraries/bio/src/helm/types';
|
|
13
15
|
import {HelmTabKeys, HelmTypes, MonomerTypes, PolymerTypes} from '@datagrok-libraries/bio/src/helm/consts';
|
|
14
16
|
import {errInfo} from '@datagrok-libraries/bio/src/utils/err-info';
|
|
@@ -28,6 +30,7 @@ import {getHoveredMonomerFromEditorMol} from './utils/get-hovered';
|
|
|
28
30
|
/* eslint-enable max-len */
|
|
29
31
|
|
|
30
32
|
import {_package} from './package';
|
|
33
|
+
import { IEditorOptions } from '@datagrok-libraries/js-draw-lite/src/types/jsdraw2';
|
|
31
34
|
|
|
32
35
|
declare const dojo: DojoType;
|
|
33
36
|
declare const JSDraw2: JSDraw2ModuleType;
|
|
@@ -326,20 +329,48 @@ export class HelmHelper implements IHelmHelper {
|
|
|
326
329
|
return getHoveredMonomerFromEditorMol(x, y, mol, height);
|
|
327
330
|
}
|
|
328
331
|
|
|
332
|
+
//if molfiles are accessed too often, it is better to cache it
|
|
333
|
+
private _molfilesEditor: Editor<unknown, IBio<unknown>, IEditorOptions> | null = null;
|
|
334
|
+
private _molfilesEditorHost: HTMLDivElement | null = null;
|
|
335
|
+
private get molfilesEditor(): Editor<unknown, IBio<unknown>, IEditorOptions> {
|
|
336
|
+
if (this._molfilesEditorRemovingTimer)
|
|
337
|
+
clearTimeout(this._molfilesEditorRemovingTimer);
|
|
338
|
+
if (this._molfilesEditor == null) {
|
|
339
|
+
this._molfilesEditorHost = ui.div([], {style: {width: '0px', height: '0px', position: 'fixed'}});
|
|
340
|
+
document.documentElement.appendChild(this._molfilesEditorHost);
|
|
341
|
+
this._molfilesEditor = new JSDraw2.Editor(this._molfilesEditorHost, {viewonly: true});
|
|
342
|
+
}
|
|
343
|
+
this._molfilesEditorRemovingTimer = setTimeout(() => {
|
|
344
|
+
this.removeMolfilesEditor();
|
|
345
|
+
}, 1000);
|
|
346
|
+
return this._molfilesEditor;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// after batch conversion, remove the editor to avoid sliding pages
|
|
350
|
+
private _molfilesEditorRemovingTimer: any = null;
|
|
351
|
+
private removeMolfilesEditor(): void {
|
|
352
|
+
if (this._molfilesEditorHost) {
|
|
353
|
+
$(this._molfilesEditorHost).empty();
|
|
354
|
+
this._molfilesEditorHost.remove();
|
|
355
|
+
this._molfilesEditorHost = null;
|
|
356
|
+
this._molfilesEditor = null;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
329
360
|
public getMolfiles(helmStrList: string[]): string[] {
|
|
330
|
-
const host = ui.div([], {style: {width: '0', height: '0'}});
|
|
331
|
-
document.documentElement.appendChild(host);
|
|
332
361
|
try {
|
|
333
|
-
const editor =
|
|
362
|
+
const editor = this.molfilesEditor;
|
|
334
363
|
const resList = helmStrList.map((helmStr, i) => {
|
|
364
|
+
//no-draw instruction to avoid time spent on rendering
|
|
365
|
+
editor.helm && (editor.helm.noDraw = true);
|
|
335
366
|
editor.setHelm(helmStr);
|
|
336
367
|
const mol = editor.getMolfile();
|
|
337
368
|
return mol;
|
|
338
369
|
});
|
|
339
370
|
return resList;
|
|
340
371
|
} finally {
|
|
341
|
-
$(host).empty();
|
|
342
|
-
host.remove();
|
|
372
|
+
// $(host).empty();
|
|
373
|
+
// host.remove();
|
|
343
374
|
}
|
|
344
375
|
}
|
|
345
376
|
|
|
@@ -40,6 +40,18 @@ export class HelmService extends HelmServiceBase {
|
|
|
40
40
|
this.editorLruCache = new LRUCache<string, HelmEditor>({max: 20});
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
private getNewEditorHost() {
|
|
44
|
+
const hostDiv = ui.box();
|
|
45
|
+
hostDiv.style.position = 'absolute';
|
|
46
|
+
hostDiv.style.left = '0px';
|
|
47
|
+
hostDiv.style.right = '0px';
|
|
48
|
+
hostDiv.style.width = '0px';
|
|
49
|
+
hostDiv.style.height = '0px';
|
|
50
|
+
hostDiv.style.visibility = 'hidden';
|
|
51
|
+
this.hostDiv.appendChild(hostDiv);
|
|
52
|
+
return hostDiv;
|
|
53
|
+
}
|
|
54
|
+
|
|
43
55
|
protected override toLog(): string {
|
|
44
56
|
return `Helm: ${super.toLog()}`;
|
|
45
57
|
}
|
|
@@ -50,7 +62,8 @@ export class HelmService extends HelmServiceBase {
|
|
|
50
62
|
let resEditor: HelmEditor | undefined = this.editorLruCache.get(editorKey);
|
|
51
63
|
if (!resEditor) {
|
|
52
64
|
const getMonomerFuncs = _package.helmHelper.buildMonomersFuncsFromLib(props.monomerLib, );
|
|
53
|
-
|
|
65
|
+
const hostDiv = this.getNewEditorHost();
|
|
66
|
+
resEditor = new JSDraw2.Editor<HelmType, IHelmBio, IHelmEditorOptions>(hostDiv, {
|
|
54
67
|
width: props.width, height: props.height, skin: 'w8', viewonly: true,
|
|
55
68
|
drawOptions: {getMonomer: getMonomerFuncs.getMonomer},
|
|
56
69
|
});
|