Changeset View
Changeset View
Standalone View
Standalone View
web/utils/typeahead-utils.js
// @flow | // @flow | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { oldValidUsernameRegexString } from 'lib/shared/account-utils'; | import { oldValidUsernameRegexString } from 'lib/shared/account-utils'; | ||||
import { stringForUserExplicit } from 'lib/shared/user-utils'; | import { stringForUserExplicit } from 'lib/shared/user-utils'; | ||||
import type { RelativeMemberInfo } from 'lib/types/thread-types'; | import type { RelativeMemberInfo } from 'lib/types/thread-types'; | ||||
import { typeaheadStyle } from '../chat/chat-constants'; | import { typeaheadStyle } from '../chat/chat-constants'; | ||||
import { type InputState } from '../input/input-state'; | import { type InputState } from '../input/input-state'; | ||||
const typeaheadRegex: RegExp = new RegExp( | const webTypeaheadRegex: RegExp = new RegExp( | ||||
`(?<textPrefix>(?:^(?:.|\n)*\\s+)|^)@(?<username>${oldValidUsernameRegexString})?$`, | `(?<textPrefix>(?:^(?:.|\n)*\\s+)|^)@(?<username>${oldValidUsernameRegexString})?$`, | ||||
); | ); | ||||
export type TypeaheadTooltipAction = { | export type TypeaheadTooltipAction = { | ||||
+key: string, | +key: string, | ||||
+onClick: (SyntheticEvent<HTMLButtonElement>) => mixed, | +onClick: (SyntheticEvent<HTMLButtonElement>) => mixed, | ||||
+actionButtonContent: React.Node, | +actionButtonContent: React.Node, | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | const left: number = | ||||
textareaBoundingClientRect.left - | textareaBoundingClientRect.left - | ||||
typeaheadStyle.tooltipLeftOffset + | typeaheadStyle.tooltipLeftOffset + | ||||
caretLeftOffset; | caretLeftOffset; | ||||
return { top, left }; | return { top, left }; | ||||
} | } | ||||
export { | export { | ||||
typeaheadRegex, | webTypeaheadRegex, | ||||
getCaretOffsets, | getCaretOffsets, | ||||
getTypeaheadTooltipActions, | getTypeaheadTooltipActions, | ||||
getTypeaheadTooltipPosition, | getTypeaheadTooltipPosition, | ||||
}; | }; |