openchemlib 8.14.0 → 8.16.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/dist/openchemlib-core.js +147 -145
- package/dist/openchemlib-full.js +169 -157
- package/dist/openchemlib-full.pretty.js +34128 -25017
- package/dist/openchemlib-minimal.js +111 -110
- package/full.d.ts +8 -1
- package/full.js +5 -0
- package/full.pretty.d.ts +1 -0
- package/full.pretty.js +5 -0
- package/lib/canvas_editor/clipboard_handler.js +15 -0
- package/lib/canvas_editor/create_editor.js +152 -0
- package/lib/canvas_editor/cursor_manager_16.js +41 -0
- package/lib/canvas_editor/cursor_manager_24.js +43 -0
- package/lib/canvas_editor/cursors_24px.js +21 -0
- package/lib/canvas_editor/draw_context.js +156 -0
- package/lib/canvas_editor/editor_area.js +31 -0
- package/lib/canvas_editor/editor_dialog.js +250 -0
- package/lib/canvas_editor/editor_image.js +46 -0
- package/lib/canvas_editor/editor_stylesheet.js +21 -0
- package/lib/canvas_editor/events.js +142 -0
- package/lib/canvas_editor/init/canvas_editor.js +137 -0
- package/lib/canvas_editor/init/canvas_editor_element.js +352 -0
- package/lib/canvas_editor/init/index.js +70 -0
- package/lib/canvas_editor/toolbar.js +28 -0
- package/lib/canvas_editor/ui_helper.js +57 -0
- package/lib/canvas_editor/utils.js +55 -0
- package/package.json +40 -20
- package/types.d.ts +347 -14
package/types.d.ts
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
export interface IMoleculeFromSmilesOptions {
|
|
4
4
|
/**
|
|
5
5
|
* Disable coordinate invention.
|
|
6
|
-
* @default
|
|
6
|
+
* @default false
|
|
7
7
|
*/
|
|
8
8
|
noCoordinates?: boolean;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Disable stereo features parsing.
|
|
12
|
-
* @default
|
|
12
|
+
* @default false
|
|
13
13
|
*/
|
|
14
14
|
noStereo?: boolean;
|
|
15
15
|
}
|
|
@@ -115,17 +115,17 @@ export interface IHoseCodesOptions {
|
|
|
115
115
|
export interface ISmilesGeneratorOptions {
|
|
116
116
|
/**
|
|
117
117
|
* Whether to create SMILES with SMARTS capabilities.
|
|
118
|
-
* @default
|
|
118
|
+
* @default false
|
|
119
119
|
*/
|
|
120
120
|
createSmarts?: boolean;
|
|
121
121
|
/**
|
|
122
122
|
* Whether to include mapping information (atomMapNo) in the SMILES.
|
|
123
|
-
* @default
|
|
123
|
+
* @default false
|
|
124
124
|
*/
|
|
125
125
|
includeMapping?: boolean;
|
|
126
126
|
/**
|
|
127
127
|
* Should localisation of double bonds be attempted?
|
|
128
|
-
* @default
|
|
128
|
+
* @default false
|
|
129
129
|
*/
|
|
130
130
|
kekulizedOutput?: boolean;
|
|
131
131
|
}
|
|
@@ -504,6 +504,7 @@ export declare class Molecule {
|
|
|
504
504
|
/**
|
|
505
505
|
* Returns the OCL object.
|
|
506
506
|
*/
|
|
507
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
507
508
|
getOCL(): any;
|
|
508
509
|
|
|
509
510
|
toSmiles(): string;
|
|
@@ -1452,7 +1453,7 @@ export declare class Molecule {
|
|
|
1452
1453
|
* @param feature - one of cAtomQF... Because of long it could be an internal object
|
|
1453
1454
|
* @param value - if true, the feature is set, otherwise it is removed
|
|
1454
1455
|
*/
|
|
1455
|
-
setAtomQueryFeature(atom: number, feature:
|
|
1456
|
+
setAtomQueryFeature(atom: number, feature: number, value: boolean): void;
|
|
1456
1457
|
|
|
1457
1458
|
/**
|
|
1458
1459
|
* Sets an atom's radical state as singulet,dublet,triplet or none
|
|
@@ -2673,7 +2674,7 @@ export declare class Molecule {
|
|
|
2673
2674
|
export interface ISmilesParserOptions {
|
|
2674
2675
|
/**
|
|
2675
2676
|
* Enable SMARTS parsing with `'smarts'` or `'guess'`.
|
|
2676
|
-
* @default
|
|
2677
|
+
* @default 'smiles'
|
|
2677
2678
|
*/
|
|
2678
2679
|
smartsMode?: 'smiles' | 'smarts' | 'guess';
|
|
2679
2680
|
|
|
@@ -2702,13 +2703,13 @@ export interface ISmilesParserParseMoleculeOptions {
|
|
|
2702
2703
|
|
|
2703
2704
|
/**
|
|
2704
2705
|
* Disable coordinate invention.
|
|
2705
|
-
* @default
|
|
2706
|
+
* @default false
|
|
2706
2707
|
*/
|
|
2707
2708
|
noCoordinates?: boolean;
|
|
2708
2709
|
|
|
2709
2710
|
/**
|
|
2710
2711
|
* Disable stereo features parsing.
|
|
2711
|
-
* @default
|
|
2712
|
+
* @default false
|
|
2712
2713
|
*/
|
|
2713
2714
|
noStereo?: boolean;
|
|
2714
2715
|
}
|
|
@@ -2767,6 +2768,7 @@ export declare class RingCollection {
|
|
|
2767
2768
|
/**
|
|
2768
2769
|
* Returns the OCL object.
|
|
2769
2770
|
*/
|
|
2771
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2770
2772
|
getOCL(): any;
|
|
2771
2773
|
|
|
2772
2774
|
getAtomRingSize(atom: number): number;
|
|
@@ -2824,6 +2826,7 @@ export declare class RingCollection {
|
|
|
2824
2826
|
* console.log(OCL.CanonizerUtil.getIDCode(molecule, OCL.CanonizerUtil.NOSTEREO_TAUTOMER));
|
|
2825
2827
|
* ```
|
|
2826
2828
|
*/
|
|
2829
|
+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
2827
2830
|
export declare class CanonizerUtil {
|
|
2828
2831
|
static NORMAL: 0;
|
|
2829
2832
|
static NOSTEREO: 1;
|
|
@@ -2902,6 +2905,7 @@ export declare class Reaction {
|
|
|
2902
2905
|
/**
|
|
2903
2906
|
* Returns the OCL object.
|
|
2904
2907
|
*/
|
|
2908
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2905
2909
|
getOCL(): any;
|
|
2906
2910
|
|
|
2907
2911
|
/**
|
|
@@ -3085,9 +3089,99 @@ export declare class Reaction {
|
|
|
3085
3089
|
getMergedCopy(): Reaction;
|
|
3086
3090
|
}
|
|
3087
3091
|
|
|
3092
|
+
interface ReactionEncoderEncodeOptionsBase {
|
|
3093
|
+
/**
|
|
3094
|
+
* @default false
|
|
3095
|
+
*/
|
|
3096
|
+
keepAbsoluteCoordinates?: boolean;
|
|
3097
|
+
}
|
|
3098
|
+
|
|
3099
|
+
/**
|
|
3100
|
+
* Bound to Java ReactionEncoder `String[] encode(Reaction reaction, boolean keepAbsoluteCoordinates, boolean sortByIDCode)`
|
|
3101
|
+
* result will be joined with Java `ReactionEncoder.OBJECT_DELIMITER`
|
|
3102
|
+
*/
|
|
3103
|
+
export interface ReactionEncoderEncodeOptionsSort
|
|
3104
|
+
extends ReactionEncoderEncodeOptionsBase {
|
|
3105
|
+
/**
|
|
3106
|
+
* @default false
|
|
3107
|
+
*/
|
|
3108
|
+
sortByIDCode?: boolean;
|
|
3109
|
+
}
|
|
3110
|
+
|
|
3111
|
+
/**
|
|
3112
|
+
* Bound to Java ReactionEncoder `String encode(Reaction reaction, boolean keepAbsoluteCoordinates, int mode)`
|
|
3113
|
+
*/
|
|
3114
|
+
export interface ReactionEncoderEncodeOptionsMode
|
|
3115
|
+
extends ReactionEncoderEncodeOptionsBase {
|
|
3116
|
+
/**
|
|
3117
|
+
* @default ReactionEncoder.INCLUDE_DEFAULT
|
|
3118
|
+
* @see ReactionEncoder.INCLUDE_DEFAULT
|
|
3119
|
+
*/
|
|
3120
|
+
mode?: number;
|
|
3121
|
+
}
|
|
3122
|
+
|
|
3123
|
+
export type ReactionEncoderEncodeOptions =
|
|
3124
|
+
| ReactionEncoderEncodeOptionsSort
|
|
3125
|
+
| ReactionEncoderEncodeOptionsMode;
|
|
3126
|
+
|
|
3127
|
+
export interface ReactionEncoderDecodeOptionsCoordinates {
|
|
3128
|
+
/**
|
|
3129
|
+
* @default false
|
|
3130
|
+
*/
|
|
3131
|
+
ensureCoordinates?: boolean;
|
|
3132
|
+
}
|
|
3133
|
+
|
|
3134
|
+
export interface ReactionEncoderDecodeOptionsMode {
|
|
3135
|
+
/**
|
|
3136
|
+
* @default ReactionEncoder.INCLUDE_DEFAULT
|
|
3137
|
+
* @see ReactionEncoder.INCLUDE_DEFAULT
|
|
3138
|
+
*/
|
|
3139
|
+
mode?: number;
|
|
3140
|
+
}
|
|
3141
|
+
|
|
3142
|
+
export type ReactionEncoderDecodeOptions =
|
|
3143
|
+
| ReactionEncoderDecodeOptionsCoordinates
|
|
3144
|
+
| ReactionEncoderDecodeOptionsMode;
|
|
3145
|
+
|
|
3146
|
+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
3088
3147
|
export declare class ReactionEncoder {
|
|
3089
|
-
static
|
|
3090
|
-
static
|
|
3148
|
+
static readonly INCLUDE_MAPPING = 0b00001;
|
|
3149
|
+
static readonly INCLUDE_COORDS = 0b00010;
|
|
3150
|
+
static readonly INCLUDE_DRAWING_OBJECTS = 0b00100;
|
|
3151
|
+
static readonly INCLUDE_CATALYSTS = 0b01000;
|
|
3152
|
+
static readonly RETAIN_REACTANT_AND_PRODUCT_ORDER = 0b10000;
|
|
3153
|
+
|
|
3154
|
+
static readonly INCLUDE_ALL =
|
|
3155
|
+
ReactionEncoder.INCLUDE_MAPPING |
|
|
3156
|
+
ReactionEncoder.INCLUDE_COORDS |
|
|
3157
|
+
ReactionEncoder.INCLUDE_DRAWING_OBJECTS |
|
|
3158
|
+
ReactionEncoder.INCLUDE_CATALYSTS;
|
|
3159
|
+
static readonly INCLUDE_RXN_CODE_ONLY = 0b00000;
|
|
3160
|
+
static readonly INCLUDE_DEFAULT =
|
|
3161
|
+
ReactionEncoder.INCLUDE_MAPPING | ReactionEncoder.INCLUDE_COORDS;
|
|
3162
|
+
|
|
3163
|
+
static readonly MOLECULE_DELIMITER: string;
|
|
3164
|
+
static readonly OBJECT_DELIMITER: string;
|
|
3165
|
+
static readonly PRODUCT_IDENTIFIER: string;
|
|
3166
|
+
static readonly CATALYST_DELIMITER: string;
|
|
3167
|
+
|
|
3168
|
+
/**
|
|
3169
|
+
* @param reaction
|
|
3170
|
+
* @param options - @default {keepAbsoluteCoordinates: false, mode: ReactionEncoder.INCLUDE_DEFAULT}
|
|
3171
|
+
*/
|
|
3172
|
+
static encode(
|
|
3173
|
+
reaction: Reaction,
|
|
3174
|
+
options?: ReactionEncoderEncodeOptions,
|
|
3175
|
+
): string | null;
|
|
3176
|
+
|
|
3177
|
+
/**
|
|
3178
|
+
* @param reaction
|
|
3179
|
+
* @param options - @default {mode: ReactionEncoder.INCLUDE_DEFAULT}
|
|
3180
|
+
*/
|
|
3181
|
+
static decode(
|
|
3182
|
+
reaction: string,
|
|
3183
|
+
options?: ReactionEncoderDecodeOptions,
|
|
3184
|
+
): Reaction | null;
|
|
3091
3185
|
}
|
|
3092
3186
|
|
|
3093
3187
|
export declare class Reactor {
|
|
@@ -3108,6 +3202,7 @@ export declare class SDFileParser {
|
|
|
3108
3202
|
/**
|
|
3109
3203
|
* Returns the OCL object.
|
|
3110
3204
|
*/
|
|
3205
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3111
3206
|
getOCL(): any;
|
|
3112
3207
|
|
|
3113
3208
|
/**
|
|
@@ -3164,6 +3259,7 @@ export declare class SSSearcher {
|
|
|
3164
3259
|
/**
|
|
3165
3260
|
* Returns the OCL object.
|
|
3166
3261
|
*/
|
|
3262
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3167
3263
|
getOCL(): any;
|
|
3168
3264
|
|
|
3169
3265
|
/**
|
|
@@ -3204,6 +3300,7 @@ export declare class SSSearcherWithIndex {
|
|
|
3204
3300
|
/**
|
|
3205
3301
|
* Returns the OCL object.
|
|
3206
3302
|
*/
|
|
3303
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3207
3304
|
getOCL(): any;
|
|
3208
3305
|
|
|
3209
3306
|
/**
|
|
@@ -3315,6 +3412,7 @@ export declare class DruglikenessPredictor {
|
|
|
3315
3412
|
/**
|
|
3316
3413
|
* Returns the OCL object.
|
|
3317
3414
|
*/
|
|
3415
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3318
3416
|
getOCL(): any;
|
|
3319
3417
|
|
|
3320
3418
|
/**
|
|
@@ -3359,6 +3457,7 @@ export declare class ToxicityPredictor {
|
|
|
3359
3457
|
/**
|
|
3360
3458
|
* Returns the OCL object.
|
|
3361
3459
|
*/
|
|
3460
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3362
3461
|
getOCL(): any;
|
|
3363
3462
|
|
|
3364
3463
|
/**
|
|
@@ -3406,6 +3505,7 @@ export declare class ConformerGenerator {
|
|
|
3406
3505
|
/**
|
|
3407
3506
|
* Returns the OCL object.
|
|
3408
3507
|
*/
|
|
3508
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3409
3509
|
getOCL(): any;
|
|
3410
3510
|
|
|
3411
3511
|
/**
|
|
@@ -3468,6 +3568,7 @@ export declare class ConformerGenerator {
|
|
|
3468
3568
|
molecules(): IterableIterator<Molecule>;
|
|
3469
3569
|
}
|
|
3470
3570
|
|
|
3571
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
3471
3572
|
export interface IForceFieldMMFF94Options {
|
|
3472
3573
|
// TODO
|
|
3473
3574
|
}
|
|
@@ -3512,6 +3613,7 @@ export declare class ForceFieldMMFF94 {
|
|
|
3512
3613
|
/**
|
|
3513
3614
|
* Returns the OCL object.
|
|
3514
3615
|
*/
|
|
3616
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3515
3617
|
getOCL(): any;
|
|
3516
3618
|
|
|
3517
3619
|
/**
|
|
@@ -3583,6 +3685,7 @@ export declare class StructureEditor {
|
|
|
3583
3685
|
/**
|
|
3584
3686
|
* Returns the OCL object.
|
|
3585
3687
|
*/
|
|
3688
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3586
3689
|
getOCL(): any;
|
|
3587
3690
|
|
|
3588
3691
|
getMolecule(): Molecule;
|
|
@@ -3663,14 +3766,14 @@ export declare class StructureEditor {
|
|
|
3663
3766
|
hasFocus(): boolean;
|
|
3664
3767
|
}
|
|
3665
3768
|
|
|
3666
|
-
export type AtomHighlightCallback = (atom: number, selected: boolean) =>
|
|
3769
|
+
export type AtomHighlightCallback = (atom: number, selected: boolean) => void;
|
|
3667
3770
|
|
|
3668
|
-
export type BondHighlightCallback = (bond: number, selected: boolean) =>
|
|
3771
|
+
export type BondHighlightCallback = (bond: number, selected: boolean) => void;
|
|
3669
3772
|
|
|
3670
3773
|
export type ChangeListenerCallback = (
|
|
3671
3774
|
idcode: string,
|
|
3672
3775
|
molecule: Molecule,
|
|
3673
|
-
) =>
|
|
3776
|
+
) => void;
|
|
3674
3777
|
|
|
3675
3778
|
export declare namespace SVGRenderer {
|
|
3676
3779
|
export function renderMolecule(
|
|
@@ -3679,3 +3782,233 @@ export declare namespace SVGRenderer {
|
|
|
3679
3782
|
height: number,
|
|
3680
3783
|
): string;
|
|
3681
3784
|
}
|
|
3785
|
+
|
|
3786
|
+
export type OnChangeEventType =
|
|
3787
|
+
| 'molecule'
|
|
3788
|
+
| 'selection'
|
|
3789
|
+
| 'highlight-atom'
|
|
3790
|
+
| 'highlight-bond';
|
|
3791
|
+
|
|
3792
|
+
export interface OnChangeEvent {
|
|
3793
|
+
type: OnChangeEventType;
|
|
3794
|
+
isUserEvent: boolean;
|
|
3795
|
+
}
|
|
3796
|
+
|
|
3797
|
+
export type OnChangeListenerCallback = (event: OnChangeEvent) => void;
|
|
3798
|
+
|
|
3799
|
+
export type CanvasEditorMode = 'molecule' | 'reaction';
|
|
3800
|
+
|
|
3801
|
+
export interface CanvasEditorOptions {
|
|
3802
|
+
/**
|
|
3803
|
+
* No toolbar and user interactions are ignored.
|
|
3804
|
+
* @default false
|
|
3805
|
+
*/
|
|
3806
|
+
readOnly?: boolean;
|
|
3807
|
+
/**
|
|
3808
|
+
* Mode in which the editor will be initialized.
|
|
3809
|
+
* @default 'molecule'
|
|
3810
|
+
*/
|
|
3811
|
+
initialMode?: CanvasEditorMode;
|
|
3812
|
+
/**
|
|
3813
|
+
* Whether the editor should be initialized with a fragment.
|
|
3814
|
+
*/
|
|
3815
|
+
initialFragment?: boolean;
|
|
3816
|
+
}
|
|
3817
|
+
|
|
3818
|
+
export declare class CanvasEditor {
|
|
3819
|
+
/**
|
|
3820
|
+
* Create a new canvas-based editor.
|
|
3821
|
+
* @param element - The DOM element in which to create the editor.
|
|
3822
|
+
* @param options
|
|
3823
|
+
*/
|
|
3824
|
+
constructor(element: HTMLElement, options?: CanvasEditorOptions);
|
|
3825
|
+
|
|
3826
|
+
/**
|
|
3827
|
+
* Get the current editor mode.
|
|
3828
|
+
*/
|
|
3829
|
+
getMode(): CanvasEditorMode;
|
|
3830
|
+
|
|
3831
|
+
/**
|
|
3832
|
+
* Set the molecule to be edited.
|
|
3833
|
+
* Actions in the editor will mutate the molecule object directly.
|
|
3834
|
+
* @param molecule
|
|
3835
|
+
*/
|
|
3836
|
+
setMolecule(molecule: Molecule): void;
|
|
3837
|
+
|
|
3838
|
+
/**
|
|
3839
|
+
* Get the molecule being edited.
|
|
3840
|
+
*/
|
|
3841
|
+
getMolecule(): Molecule;
|
|
3842
|
+
|
|
3843
|
+
/**
|
|
3844
|
+
* Set the reaction to be edited.
|
|
3845
|
+
* Actions in the editor will mutate the reaction object directly.
|
|
3846
|
+
* @param reaction
|
|
3847
|
+
*/
|
|
3848
|
+
setReaction(reaction: Reaction): void;
|
|
3849
|
+
|
|
3850
|
+
/**
|
|
3851
|
+
* Get the reaction being edited.
|
|
3852
|
+
*/
|
|
3853
|
+
getReaction(): Reaction;
|
|
3854
|
+
|
|
3855
|
+
/**
|
|
3856
|
+
* Set a callback to be notified when the editor state changes.
|
|
3857
|
+
* @param callback
|
|
3858
|
+
*/
|
|
3859
|
+
setOnChangeListener(callback: OnChangeListenerCallback): void;
|
|
3860
|
+
|
|
3861
|
+
/**
|
|
3862
|
+
* Remove the change listener callback.
|
|
3863
|
+
*/
|
|
3864
|
+
removeOnChangeListener(): void;
|
|
3865
|
+
|
|
3866
|
+
/**
|
|
3867
|
+
* Clear the editor state.
|
|
3868
|
+
* Same as clicking on the clear button in the toolbar.
|
|
3869
|
+
*/
|
|
3870
|
+
clearAll(): void;
|
|
3871
|
+
|
|
3872
|
+
/**
|
|
3873
|
+
* Destroy the editor.
|
|
3874
|
+
* This should be called when the editor is no longer needed to free resources.
|
|
3875
|
+
* All methods will throw an error after calling this.
|
|
3876
|
+
*/
|
|
3877
|
+
destroy(): void;
|
|
3878
|
+
}
|
|
3879
|
+
|
|
3880
|
+
interface CanvasEditorElementModeEnum {
|
|
3881
|
+
MOLECULE: 'molecule';
|
|
3882
|
+
REACTION: 'reaction';
|
|
3883
|
+
}
|
|
3884
|
+
|
|
3885
|
+
type CanvasEditorElementMode = 'molecule' | 'reaction';
|
|
3886
|
+
|
|
3887
|
+
interface CanvasEditorElementConstructor extends CustomElementConstructor {
|
|
3888
|
+
readonly MODE: CanvasEditorElementModeEnum;
|
|
3889
|
+
readonly observedAttributes: ['idcode', 'fragment', 'mode', 'readonly'];
|
|
3890
|
+
|
|
3891
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3892
|
+
new (...params: any[]): CanvasEditorElement;
|
|
3893
|
+
}
|
|
3894
|
+
|
|
3895
|
+
/**
|
|
3896
|
+
* a Webcomponent to wrap CanvasEditor
|
|
3897
|
+
*
|
|
3898
|
+
* The class CanvasEditorElement is not exposed in OCL scope.
|
|
3899
|
+
* You can obtain it from `registerCustomElement`
|
|
3900
|
+
*
|
|
3901
|
+
* Usage:
|
|
3902
|
+
*
|
|
3903
|
+
* In Javascript:
|
|
3904
|
+
* ```js
|
|
3905
|
+
* import {registerCustomElement, Molecule, ReactionEncoder} from 'openchemlib/minimal';
|
|
3906
|
+
*
|
|
3907
|
+
* // register CanvasEditorElement with `openchemlib-editor` tag name
|
|
3908
|
+
* const CanvasEditorElement = registerCustomElement();
|
|
3909
|
+
*
|
|
3910
|
+
* // CanvasEditorElementConstructor.MODE return enums of possible modes
|
|
3911
|
+
* const firstEditor = document.querySelector('openchemlib-editor');
|
|
3912
|
+
* console.assert(firstEditor instanceof CanvasEditorElement);
|
|
3913
|
+
*
|
|
3914
|
+
* firstEditor.setMolecule(Molecule.fromIDCode('ffc`P@H`QxNQQJJIJIZJHiSkQSejB`jFjhhaEqFUh@'));
|
|
3915
|
+
* const molecule = firstEditor.getMolecule();
|
|
3916
|
+
*
|
|
3917
|
+
* firstEditor.setReaction(ReactionEncoder.decode('gJX@@eKU@@ gGQHDHaImfh@!defH@DAIfUVjj`@'));
|
|
3918
|
+
* const reaction = firstEditor.getReaction();
|
|
3919
|
+
*
|
|
3920
|
+
* firstEditor.clearAll();
|
|
3921
|
+
* ```
|
|
3922
|
+
*
|
|
3923
|
+
* In HTML
|
|
3924
|
+
* ```html
|
|
3925
|
+
* <p>Empty editor</p>
|
|
3926
|
+
* <openchemlib-editor></openchemlib-editor>
|
|
3927
|
+
*
|
|
3928
|
+
* <p>Molecule <code>ffc`P@H`QxNQQJJIJIZJHiSkQSejB`jFjhhaEqFUh@</code></p>
|
|
3929
|
+
* <openchemlib-editor
|
|
3930
|
+
* idcode="ffc`P@H`QxNQQJJIJIZJHiSkQSejB`jFjhhaEqFUh@"
|
|
3931
|
+
* ></openchemlib-editor>
|
|
3932
|
+
*
|
|
3933
|
+
* <p>
|
|
3934
|
+
* Molecule Fragment
|
|
3935
|
+
* <code>
|
|
3936
|
+
* ffc`P@H`QxNQQJJIJIZJHiSkQSejB`jFjhhaEqFUhCyqHiCHy@leBhMEh]B\sa^kp
|
|
3937
|
+
* </code>
|
|
3938
|
+
* </p>
|
|
3939
|
+
* <openchemlib-editor
|
|
3940
|
+
* idcode="ffc`P@H`QxNQQJJIJIZJHiSkQSejB`jFjhhaEqFUhCyqHiCHy@leBhMEh]B\sa^kp"
|
|
3941
|
+
* fragment
|
|
3942
|
+
* ></openchemlib-editor>
|
|
3943
|
+
*
|
|
3944
|
+
* <p>Reaction <code>gJX@@eKU@@ gGQHDHaImfh@!defH@DAIfUVjj`@</code></p>
|
|
3945
|
+
* <openchemlib-editor
|
|
3946
|
+
* idcode="gJX@@eKU@@ gGQHDHaImfh@!defH@DAIfUVjj`@"
|
|
3947
|
+
* mode="reaction"
|
|
3948
|
+
* ></openchemlib-editor>
|
|
3949
|
+
*
|
|
3950
|
+
* <p>
|
|
3951
|
+
* Reaction Fragment
|
|
3952
|
+
* <code>gJX@@eKU@P gGQHDHaImfhB!defH@DAIfUVjj`B</code>
|
|
3953
|
+
* </p>
|
|
3954
|
+
* <openchemlib-editor
|
|
3955
|
+
* idcode="gJX@@eKU@P gGQHDHaImfhB!defH@DAIfUVjj`B"
|
|
3956
|
+
* mode="reaction"
|
|
3957
|
+
* fragment
|
|
3958
|
+
* ></openchemlib-editor>
|
|
3959
|
+
*
|
|
3960
|
+
* <p>
|
|
3961
|
+
* Molecule readonly
|
|
3962
|
+
* <code>ffc`P@H`QxNQQJJIJIZJHiSkQSejB`jFjhhaEqFUh@</code>
|
|
3963
|
+
* </p>
|
|
3964
|
+
* <openchemlib-editor
|
|
3965
|
+
* readonly
|
|
3966
|
+
* idcode="ffc`P@H`QxNQQJJIJIZJHiSkQSejB`jFjhhaEqFUh@"
|
|
3967
|
+
* ></openchemlib-editor>
|
|
3968
|
+
* ```
|
|
3969
|
+
*
|
|
3970
|
+
* Styling:
|
|
3971
|
+
* `registerCustomElement()` insertRule to define height to 400px and width to 600px on `openchemlib-editor` element.
|
|
3972
|
+
* This element need to be contained by fixed width and height, or it will grow indefinitely.
|
|
3973
|
+
* So for responsive layout, ensure your container has max-width and max-height
|
|
3974
|
+
* before override the inserted rules to 100% instead fixed units.
|
|
3975
|
+
*
|
|
3976
|
+
* ```css
|
|
3977
|
+
* // need to be into a fixed size container
|
|
3978
|
+
* openchemlib-editor:defined {
|
|
3979
|
+
* width: 100%;
|
|
3980
|
+
* height: 100%
|
|
3981
|
+
* }
|
|
3982
|
+
* ```
|
|
3983
|
+
*/
|
|
3984
|
+
declare interface CanvasEditorElement extends HTMLElement {
|
|
3985
|
+
/**
|
|
3986
|
+
* @defaultValue ''
|
|
3987
|
+
*/
|
|
3988
|
+
idcode: string;
|
|
3989
|
+
/**
|
|
3990
|
+
* @defaultValue false
|
|
3991
|
+
*/
|
|
3992
|
+
fragment: boolean;
|
|
3993
|
+
/**
|
|
3994
|
+
* @defaultValue 'molecule'
|
|
3995
|
+
*/
|
|
3996
|
+
mode: CanvasEditorElementMode;
|
|
3997
|
+
/**
|
|
3998
|
+
* @defaultValue false
|
|
3999
|
+
*/
|
|
4000
|
+
readonly: boolean;
|
|
4001
|
+
|
|
4002
|
+
getMolecule(): Molecule;
|
|
4003
|
+
setMolecule(molecule: Molecule): void;
|
|
4004
|
+
|
|
4005
|
+
getReaction(): Reaction;
|
|
4006
|
+
setReaction(reaction: Reaction): void;
|
|
4007
|
+
|
|
4008
|
+
clearAll(): void;
|
|
4009
|
+
}
|
|
4010
|
+
|
|
4011
|
+
/**
|
|
4012
|
+
* register `<openchemlib-editor>` element with `CanvasEditorElementConstructor` if not already defined.
|
|
4013
|
+
*/
|
|
4014
|
+
declare function registerCustomElement(): CanvasEditorElementConstructor;
|