ketcher-react 2.23.0-rc.4 → 2.24.0-rc.2

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.
@@ -14,8 +14,9 @@
14
14
  * limitations under the License.
15
15
  ***************************************************************************/
16
16
  /// <reference types="react" />
17
- import { Ketcher, ServiceMode, StructServiceProvider } from 'ketcher-core';
17
+ import { Ketcher, ServiceMode, StructService, StructServiceProvider } from 'ketcher-core';
18
18
  import { ButtonsConfig } from './ButtonsConfig';
19
+ import { initApp } from '../../ui';
19
20
  import { Root } from 'react-dom/client';
20
21
  declare class KetcherBuilder {
21
22
  private structService;
@@ -24,10 +25,13 @@ declare class KetcherBuilder {
24
25
  private formatterFactory;
25
26
  constructor();
26
27
  appendApiAsync(structServiceProvider: StructServiceProvider): Promise<void>;
28
+ reinitializeApi(structServiceProvider: StructServiceProvider, setStructServiceToStore: (structService: StructService) => void): StructService;
27
29
  appendServiceMode(mode: ServiceMode): void;
28
30
  appendUiAsync(element: HTMLDivElement | null, appRoot: Root, staticResourcesUrl: string, errorHandler: (message: string) => void, buttons?: ButtonsConfig, togglerComponent?: JSX.Element): Promise<{
29
31
  setKetcher: (ketcher: Ketcher) => void;
30
32
  ketcherId: string;
33
+ cleanup: ReturnType<typeof initApp> | null;
34
+ setServer: (structService: StructService) => void;
31
35
  }>;
32
36
  build(): Ketcher | undefined;
33
37
  }
@@ -99,11 +99,10 @@ declare class Editor implements KetcherEditor {
99
99
  handler: any;
100
100
  };
101
101
  unsubscribe(eventName: any, subscriber: any): void;
102
- findItem(event: any, maps: Array<string> | null, skip?: any): any;
102
+ findItem(event: any, maps: Array<string> | null, skip?: any): import(".").ClosestItemWithMap<unknown> | null;
103
103
  findMerge(srcItems: any, maps: any): {
104
- atoms: Map<number, number>;
105
- bonds: Map<number, number>;
106
- atomToFunctionalGroup: Map<number, number> | null;
104
+ atoms: Map<any, any>;
105
+ atomToFunctionalGroup: Map<any, any>;
107
106
  };
108
107
  explicitSelected(): any;
109
108
  structSelected(): Struct;
@@ -15,4 +15,5 @@
15
15
  ***************************************************************************/
16
16
  import { Editor } from './Editor';
17
17
  export { Editor };
18
+ export * from './shared/closest.types';
18
19
  export default Editor;
@@ -1,14 +1,25 @@
1
- declare namespace _default {
2
- export { findClosestAtom as atom };
3
- export { findClosestItem as item };
4
- export { findCloseMerge as merge };
5
- }
6
- export default _default;
7
- declare function findClosestAtom(restruct: any, pos: any, skip: any, minDist: any): {
1
+ /****************************************************************************
2
+ * Copyright 2021 EPAM Systems
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ ***************************************************************************/
16
+ import { Vec2, ReStruct } from 'ketcher-core';
17
+ import { ClosestItemWithMap } from './closest.types';
18
+ declare function findClosestAtom(restruct: ReStruct, pos: Vec2, skip: any, minDist: any): {
8
19
  id: never;
9
20
  dist: any;
10
21
  } | null;
11
- declare function findClosestItem(restruct: any, pos: any, maps: any, skip: any, options: any): any;
22
+ declare function findClosestItem(restruct: ReStruct, pos: Vec2, maps: any, skip: any, options: any): ClosestItemWithMap | null;
12
23
  /**
13
24
  * @param restruct { ReStruct }
14
25
  * @param selected { object }
@@ -20,9 +31,13 @@ declare function findClosestItem(restruct: any, pos: any, maps: any, skip: any,
20
31
  * atomToFunctionalGroup: Map<number, number>?
21
32
  * }}
22
33
  */
23
- declare function findCloseMerge(restruct: ReStruct, selected: object, maps: string[] | undefined, options: RenderOption): {
24
- atoms: Map<number, number>;
25
- bonds: Map<number, number>;
26
- atomToFunctionalGroup: Map<number, number> | null;
34
+ declare function findCloseMerge(restruct: ReStruct, selected: any, maps: string[] | undefined, options: any): {
35
+ atoms: Map<any, any>;
36
+ atomToFunctionalGroup: Map<any, any>;
37
+ };
38
+ declare const _default: {
39
+ atom: typeof findClosestAtom;
40
+ item: typeof findClosestItem;
41
+ merge: typeof findCloseMerge;
27
42
  };
28
- import { ReStruct } from "ketcher-core/dist/application/render/restruct";
43
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import { Vec2 } from 'ketcher-core';
2
+ export interface ClosestItem<T = Vec2> {
3
+ id: number;
4
+ dist: number;
5
+ ref?: T | null;
6
+ }
7
+ export interface ClosestItemWithMap<T = unknown> extends ClosestItem<T> {
8
+ map: string;
9
+ }
@@ -1,5 +1,5 @@
1
1
  import { Editor } from '../../Editor';
2
2
  declare const isMacroMolecule: (editor: Editor, id: number) => boolean;
3
3
  declare const isMergingToMacroMolecule: (editor: Editor, dragCtx: any) => boolean;
4
- declare const isBondingWithMacroMolecule: (editor: Editor, event: MouseEvent) => boolean | undefined;
4
+ declare const isBondingWithMacroMolecule: (editor: Editor, event: MouseEvent) => boolean | null | undefined;
5
5
  export { isBondingWithMacroMolecule, isMacroMolecule, isMergingToMacroMolecule, };
@@ -31,6 +31,7 @@ declare class LassoHelper {
31
31
  simpleObjects: number[];
32
32
  texts: number[];
33
33
  rgroupAttachmentPoints: number[];
34
+ images: number[];
34
35
  };
35
36
  begin(event: any): void;
36
37
  running(): boolean;
@@ -44,6 +45,7 @@ declare class LassoHelper {
44
45
  simpleObjects: number[];
45
46
  texts: number[];
46
47
  rgroupAttachmentPoints: number[];
48
+ images: number[];
47
49
  } | null;
48
50
  update(): void;
49
51
  end(): {
@@ -56,6 +58,7 @@ declare class LassoHelper {
56
58
  simpleObjects: number[];
57
59
  texts: number[];
58
60
  rgroupAttachmentPoints: number[];
61
+ images: number[];
59
62
  };
60
63
  cancel(): void;
61
64
  }
@@ -13,7 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  ***************************************************************************/
16
- declare function getElementsInRectangle(restruct: any, p0: any, p1: any): {
16
+ import { ReStruct } from 'ketcher-core';
17
+ declare function getElementsInRectangle(restruct: ReStruct, p0: any, p1: any): {
17
18
  atoms: number[];
18
19
  bonds: number[];
19
20
  rxnArrows: number[];
@@ -23,8 +24,9 @@ declare function getElementsInRectangle(restruct: any, p0: any, p1: any): {
23
24
  simpleObjects: number[];
24
25
  texts: number[];
25
26
  rgroupAttachmentPoints: number[];
27
+ images: number[];
26
28
  };
27
- declare function getElementsInPolygon(restruct: any, rr: any): {
29
+ declare function getElementsInPolygon(restruct: ReStruct, rr: any): {
28
30
  atoms: number[];
29
31
  bonds: number[];
30
32
  rxnArrows: number[];
@@ -34,6 +36,7 @@ declare function getElementsInPolygon(restruct: any, rr: any): {
34
36
  simpleObjects: number[];
35
37
  texts: number[];
36
38
  rgroupAttachmentPoints: number[];
39
+ images: number[];
37
40
  };
38
41
  declare const _default: {
39
42
  inRectangle: typeof getElementsInRectangle;
@@ -0,0 +1,18 @@
1
+ import { Vec2 } from 'ketcher-core';
2
+ import { Tool } from './Tool';
3
+ import type Editor from '../Editor';
4
+ export declare class ImageTool implements Tool {
5
+ private readonly editor;
6
+ static readonly INPUT_ID = "image-upload";
7
+ private element;
8
+ private dragCtx;
9
+ constructor(editor: Editor);
10
+ mousedown(event: MouseEvent): void;
11
+ click(event: MouseEvent): void;
12
+ mousemove(event: PointerEvent): void;
13
+ mouseup(): boolean;
14
+ onFileUpload(clickPosition: Vec2): void;
15
+ private createElement;
16
+ private getElement;
17
+ private resetElementValue;
18
+ }
@@ -1,17 +1,2 @@
1
- /****************************************************************************
2
- * Copyright 2021 EPAM Systems
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- ***************************************************************************/
16
1
  import { ToolConstructorInterface } from './Tool';
17
2
  export declare const toolsMap: Record<string, ToolConstructorInterface>;
@@ -1,3 +1,3 @@
1
1
  import { ReStruct, Vec2 } from 'ketcher-core';
2
2
  export declare function getSelectionMap(structure: ReStruct): {};
3
- export declare function getStructCenter(ReStruct: any, selection?: any): Vec2;
3
+ export declare function getStructCenter(reStruct: ReStruct, selection?: any): Vec2;
@@ -15,7 +15,7 @@
15
15
  ***************************************************************************/
16
16
  /// <reference types="react" />
17
17
  import { Root } from 'react-dom/client';
18
- import { ButtonsConfig } from './builders';
18
+ import { ButtonsConfig, KetcherBuilder } from './builders';
19
19
  import { StructServiceProvider } from 'ketcher-core';
20
20
  interface Config {
21
21
  element: HTMLDivElement | null;
@@ -29,6 +29,9 @@ interface Config {
29
29
  declare function buildKetcherAsync({ element, appRoot, staticResourcesUrl, structServiceProvider, buttons, errorHandler, togglerComponent, }: Config): Promise<{
30
30
  ketcher: import("ketcher-core").Ketcher | undefined;
31
31
  ketcherId: string;
32
+ cleanup: (() => void) | null;
33
+ builder: KetcherBuilder;
34
+ setServer: (structService: import("ketcher-core").StructService) => void;
32
35
  }>;
33
36
  export type { Config, ButtonsConfig };
34
37
  export * from './providers';
@@ -20,5 +20,6 @@ declare function initApp(element: HTMLDivElement | null, appRoot: Root, staticRe
20
20
  editor: any;
21
21
  setKetcher: (ketcher: Ketcher) => void;
22
22
  ketcherId: string;
23
- }) => void, togglerComponent?: JSX.Element): void;
23
+ setServer: (server: StructService) => void;
24
+ }) => void, togglerComponent?: JSX.Element): () => void;
24
25
  export { initApp };
@@ -400,6 +400,13 @@ declare const config: {
400
400
  bonds: {
401
401
  hidden: (options: any) => boolean;
402
402
  };
403
+ images: {
404
+ title: string;
405
+ action: {
406
+ tool: string;
407
+ };
408
+ hidden: (options: any) => boolean;
409
+ };
403
410
  'force-update': {
404
411
  shortcut: string;
405
412
  action: (editor: any) => void;
@@ -339,6 +339,13 @@ declare const _default: {
339
339
  bonds: {
340
340
  hidden: (options: any) => boolean;
341
341
  };
342
+ images: {
343
+ title: string;
344
+ action: {
345
+ tool: string;
346
+ };
347
+ hidden: (options: any) => boolean;
348
+ };
342
349
  };
343
350
  export default _default;
344
351
  import { isFlipDisabled } from "./flips";
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  ***************************************************************************/
16
16
  export declare function initKeydownListener(element: any): (dispatch: any, getState: any) => void;
17
+ export declare function removeKeydownListener(element: any): () => void;
17
18
  export declare function initClipboard(dispatch: any): {
18
19
  formats: any[];
19
20
  focused(): boolean;
@@ -1,6 +1,11 @@
1
1
  export default function _default(options: any, server: any, setEditor: any): import("redux").Store<any, any> & {
2
2
  dispatch: any;
3
3
  };
4
+ export function setServer(server: any): {
5
+ type: string;
6
+ server: any;
7
+ };
8
+ export const SET_SERVER: "SET_SERVER";
4
9
  import { onAction } from "./shared";
5
10
  import { load } from "./shared";
6
11
  export { onAction, load };
@@ -14,3 +14,4 @@
14
14
  * limitations under the License.
15
15
  ***************************************************************************/
16
16
  export declare function initMouseListener(element: any): (dispatch: any, getState: any) => void;
17
+ export declare function removeMouseListeners(element: any): () => void;
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  ***************************************************************************/
16
- /// <reference types="react" />
16
+ import React from 'react';
17
17
  import 'react-contexify/ReactContexify.css';
18
18
  declare const ContextMenu: React.FC;
19
19
  export default ContextMenu;
@@ -1,6 +1,6 @@
1
1
  import { AtomType } from 'ketcher-core';
2
2
  export declare function atomValid(label: string, isMultipleAtoms: boolean, atomType: AtomType, isCustomQuery: boolean): boolean | "";
3
3
  export declare function AtomListValid(value: string, atomType: AtomType, isCustomQuery: boolean): boolean;
4
- export declare function pseudoAtomValid(value: string, atomType: AtomType, isCustomQuery: boolean): boolean | "";
4
+ export declare function pseudoAtomValid(value: string, atomType: AtomType, isCustomQuery: boolean, disableQueryElements?: string[] | null): boolean | "";
5
5
  export declare function chargeValid(charge: any, isMultipleAtoms: boolean, isCustomQuery: boolean): boolean | null;
6
6
  export declare function customQueryValid(value: string, isCustomQuery: boolean): boolean;
@@ -13,13 +13,14 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  ***************************************************************************/
16
+ import { IMAGE_KEY } from 'domain/constants';
16
17
  declare type TopGroup = 'document' | 'edit' | 'zoom' | 'process' | 'meta';
17
18
  declare type LeftGroup = 'hand' | 'select' | 'bond' | 'charge' | 'transform' | 'sgroup' | 'rgroup' | 'shape' | 'text';
18
19
  declare type BottomGroup = 'template-common' | 'template-lib';
19
20
  declare type RightGroup = 'atom' | 'period-table';
20
21
  declare type ToolbarGroupVariant = TopGroup | LeftGroup | BottomGroup | RightGroup;
21
22
  declare type TopToolbarItemVariant = 'clear' | 'open' | 'save' | 'undo' | 'redo' | 'cut' | 'copies' | 'copy' | 'copy-image' | 'copy-mol' | 'copy-ket' | 'paste' | 'zoom-in' | 'zoom-out' | 'zoom-list' | 'layout' | 'clean' | 'arom' | 'dearom' | 'cip' | 'check' | 'analyse' | 'recognize' | 'miew' | 'settings' | 'help' | 'about';
22
- declare type LeftToolbarItemVariant = 'hand' | 'select' | 'select-lasso' | 'select-rectangle' | 'select-fragment' | 'erase' | 'bonds' | 'bond-common' | 'bond-single' | 'bond-double' | 'bond-triple' | 'bond-dative' | 'bond-stereo' | 'bond-up' | 'bond-down' | 'bond-updown' | 'bond-crossed' | 'bond-query' | 'bond-special' | 'bond-any' | 'bond-hydrogen' | 'bond-aromatic' | 'bond-singledouble' | 'bond-singlearomatic' | 'bond-doublearomatic' | 'chain' | 'charge-plus' | 'charge-minus' | 'sgroup' | 'reaction-plus' | 'arrows' | 'reaction-arrow-open-angle' | 'reaction-arrow-filled-triangle' | 'reaction-arrow-filled-bow' | 'reaction-arrow-dashed-open-angle' | 'reaction-arrow-failed' | 'reaction-arrow-both-ends-filled-triangle' | 'reaction-arrow-equilibrium-filled-half-bow' | 'reaction-arrow-equilibrium-filled-triangle' | 'reaction-arrow-equilibrium-open-angle' | 'reaction-arrow-unbalanced-equilibrium-filled-half-bow' | 'reaction-arrow-unbalanced-equilibrium-open-half-angle' | 'reaction-arrow-unbalanced-equilibrium-large-filled-half-bow' | 'reaction-arrow-unbalanced-equilibrium-filled-half-triangle' | 'reaction-arrow-elliptical-arc-arrow-filled-bow' | 'reaction-arrow-elliptical-arc-arrow-filled-triangle' | 'reaction-arrow-elliptical-arc-arrow-open-angle' | 'reaction-arrow-elliptical-arc-arrow-open-half-angle' | 'reaction-mapping-tools' | 'reaction-automap' | 'reaction-map' | 'reaction-unmap' | 'rgroup' | 'rgroup-label' | 'rgroup-fragment' | 'rgroup-attpoints' | 'shapes' | 'shape-ellipse' | 'shape-rectangle' | 'shape-line' | 'text';
23
+ declare type LeftToolbarItemVariant = 'hand' | 'select' | 'select-lasso' | 'select-rectangle' | 'select-fragment' | 'erase' | 'bonds' | 'bond-common' | 'bond-single' | 'bond-double' | 'bond-triple' | 'bond-dative' | 'bond-stereo' | 'bond-up' | 'bond-down' | 'bond-updown' | 'bond-crossed' | 'bond-query' | 'bond-special' | 'bond-any' | 'bond-hydrogen' | 'bond-aromatic' | 'bond-singledouble' | 'bond-singlearomatic' | 'bond-doublearomatic' | 'chain' | 'charge-plus' | 'charge-minus' | 'sgroup' | 'reaction-plus' | 'arrows' | 'reaction-arrow-open-angle' | 'reaction-arrow-filled-triangle' | 'reaction-arrow-filled-bow' | 'reaction-arrow-dashed-open-angle' | 'reaction-arrow-failed' | 'reaction-arrow-both-ends-filled-triangle' | 'reaction-arrow-equilibrium-filled-half-bow' | 'reaction-arrow-equilibrium-filled-triangle' | 'reaction-arrow-equilibrium-open-angle' | 'reaction-arrow-unbalanced-equilibrium-filled-half-bow' | 'reaction-arrow-unbalanced-equilibrium-open-half-angle' | 'reaction-arrow-unbalanced-equilibrium-large-filled-half-bow' | 'reaction-arrow-unbalanced-equilibrium-filled-half-triangle' | 'reaction-arrow-elliptical-arc-arrow-filled-bow' | 'reaction-arrow-elliptical-arc-arrow-filled-triangle' | 'reaction-arrow-elliptical-arc-arrow-open-angle' | 'reaction-arrow-elliptical-arc-arrow-open-half-angle' | 'reaction-mapping-tools' | 'reaction-automap' | 'reaction-map' | 'reaction-unmap' | 'rgroup' | 'rgroup-label' | 'rgroup-fragment' | 'rgroup-attpoints' | 'shapes' | 'shape-ellipse' | 'shape-rectangle' | 'shape-line' | 'text' | typeof IMAGE_KEY;
23
24
  declare type BottomToolbarItemVariant = 'template-common' | 'template-lib' | 'enhanced-stereo' | 'fullscreen';
24
25
  declare type RightToolbarItemVariant = 'atom' | 'freq-atoms' | 'period-table' | 'extended-table' | 'any-atom';
25
26
  declare type FloatingToolItemVariant = 'transform-flip-h' | 'transform-flip-v' | 'erase';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ketcher-react",
3
- "version": "2.23.0-rc.4",
3
+ "version": "2.24.0-rc.2",
4
4
  "description": "Web-based molecule sketcher",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "http://lifescience.opensource.epam.com/ketcher",