-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into #1990-functional-group-does-not-connect-wi…
…th-another-functional-group-on-clickdrag
- Loading branch information
Showing
15 changed files
with
190 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export function b64toBlob( | ||
b64Data: string, | ||
contentType = '', | ||
sliceSize = 512 | ||
): Blob { | ||
const byteCharacters: string = window.atob(b64Data) | ||
const byteArrays: Array<Uint8Array> = [] | ||
|
||
for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) { | ||
const slice: string = byteCharacters.slice(offset, offset + sliceSize) | ||
const byteNumbers: Array<number> = new Array(slice.length) | ||
|
||
for (let i = 0; i < slice.length; i++) { | ||
byteNumbers[i] = slice.charCodeAt(i) | ||
} | ||
|
||
const byteArray: Uint8Array = new Uint8Array(byteNumbers) | ||
byteArrays.push(byteArray) | ||
} | ||
|
||
const blob: Blob = new Blob(byteArrays, { type: contentType }) | ||
return blob | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ | |
export * from './ifDef' | ||
export * from './tfx' | ||
export * from './runAsyncAction' | ||
export * from './b64toBlob' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
packages/ketcher-react/src/script/editor/utils/functionalGroupsTooltip.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { FunctionalGroup } from 'ketcher-core' | ||
|
||
let showTooltipTimer: ReturnType<typeof setTimeout> | null = null | ||
|
||
export const TOOLTIP_DELAY = 300 | ||
|
||
export function showTooltip(editor, infoPanelData) { | ||
editor.event.showInfo.dispatch(null) | ||
|
||
if (showTooltipTimer) { | ||
clearTimeout(showTooltipTimer) | ||
} | ||
if (infoPanelData) { | ||
showTooltipTimer = setTimeout(() => { | ||
editor.event.showInfo.dispatch(infoPanelData) | ||
}, TOOLTIP_DELAY) | ||
} | ||
} | ||
|
||
export function showFunctionalGroupsTooltip(editor) { | ||
let infoPanelData: any = null | ||
const checkFunctionGroupTypes = ['sgroups', 'functionalGroups'] | ||
const closestCollapsibleStructures = editor.findItem( | ||
event, | ||
checkFunctionGroupTypes | ||
) | ||
if (closestCollapsibleStructures) { | ||
const sGroup = editor.struct()?.sgroups.get(closestCollapsibleStructures.id) | ||
if (sGroup && !sGroup.data.expanded) { | ||
const groupName = sGroup.data.name | ||
const groupStruct = FunctionalGroup.getFunctionalGroupByName(groupName) | ||
infoPanelData = { | ||
groupStruct, | ||
event, | ||
sGroup | ||
} | ||
} | ||
} | ||
showTooltip(editor, infoPanelData) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.