@epam/ai-dial-skills 1.2.0-dev.141 → 1.2.0-dev.142
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/components/ChatSkill/ChatSkill.d.ts +3 -2
- package/components/ChatSkill/ChatSkill.d.ts.map +1 -1
- package/hooks/useSkillMentions/useSkillMentions.d.ts +50 -0
- package/hooks/useSkillMentions/useSkillMentions.d.ts.map +1 -0
- package/hooks/useSkillSelectorOverlay/useSkillSelectorOverlay.d.ts +4 -3
- package/hooks/useSkillSelectorOverlay/useSkillSelectorOverlay.d.ts.map +1 -1
- package/index.css +1 -1
- package/index.d.ts +8 -0
- package/index.d.ts.map +1 -1
- package/index.js +406 -281
- package/models/skill-mention-anchor.d.ts +12 -0
- package/models/skill-mention-anchor.d.ts.map +1 -0
- package/models/skill-selector-overlay.d.ts +100 -54
- package/models/skill-selector-overlay.d.ts.map +1 -1
- package/package.json +4 -4
- package/utils/skill-mention-matching.d.ts +25 -0
- package/utils/skill-mention-matching.d.ts.map +1 -0
- package/utils/skill-mention-tracking.d.ts +39 -0
- package/utils/skill-mention-tracking.d.ts.map +1 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** A skill mention's location within the current plain-text draft. */
|
|
2
|
+
export interface SkillMentionAnchor {
|
|
3
|
+
/** The mentioned skill's resource URL — the value sent as this entry's `{ url }`. */
|
|
4
|
+
url: string;
|
|
5
|
+
/** Display name at the time of insertion (`/${name}` is what actually sits in the text). */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Character offset of the leading `/` in the current draft string. */
|
|
8
|
+
start: number;
|
|
9
|
+
/** Length of the `/{name}` run, `1 + name.length`. */
|
|
10
|
+
length: number;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=skill-mention-anchor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-mention-anchor.d.ts","sourceRoot":"","sources":["../../src/models/skill-mention-anchor.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,WAAW,kBAAkB;IACjC,qFAAqF;IACrF,GAAG,EAAE,MAAM,CAAC;IACZ,4FAA4F;IAC5F,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RequestSkill } from '@epam/ai-dial-chat-shared';
|
|
2
|
-
import { CommandMenuConfig, MenuOverlayConfig } from '@epam/ai-dial-conversation-input';
|
|
2
|
+
import { CommandMenuConfig, HighlightedTextRange, MenuOverlayConfig } from '@epam/ai-dial-conversation-input';
|
|
3
3
|
import { ComponentType, ReactNode } from 'react';
|
|
4
4
|
import { SkillListingEntry } from './favorite-skill-item';
|
|
5
5
|
import { FavoriteSkillsPanelLabels } from './favorite-skills-panel-props';
|
|
@@ -28,11 +28,6 @@ export interface SkillSelectorOverlayLabels {
|
|
|
28
28
|
* is open with an empty query. Defaults to `'Type to filter'`.
|
|
29
29
|
*/
|
|
30
30
|
emptyQueryHintLabel?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Message shown alone in the selected skill chip's error-state tooltip
|
|
33
|
-
* while the current deployment does not support skills.
|
|
34
|
-
*/
|
|
35
|
-
unsupportedTooltipLabel?: string;
|
|
36
31
|
/** Labels forwarded to the favorites panel rendered as the overlay. */
|
|
37
32
|
panelLabels?: FavoriteSkillsPanelLabels;
|
|
38
33
|
}
|
|
@@ -46,9 +41,13 @@ export interface UseSkillSelectorOverlayOptions {
|
|
|
46
41
|
/**
|
|
47
42
|
* Whether the input's current deployment supports skills. While `false`
|
|
48
43
|
* (with the flow enabled) the entry points are omitted — no Add-menu item
|
|
49
|
-
* and no slash menu — but
|
|
50
|
-
*
|
|
51
|
-
*
|
|
44
|
+
* and no slash menu — but a tracked mention stays in the draft text and
|
|
45
|
+
* folds into `isSkillUnsupported` for the host's own send-disabled
|
|
46
|
+
* condition. The host resolves this from its own deployment data. Note: a
|
|
47
|
+
* live-composing mention has no per-mention error styling of its own (it
|
|
48
|
+
* renders as a plain highlighted run, not a `ChatSkill`); only the sent
|
|
49
|
+
* `custom_content.skills`/history rendering, and this boolean fold, reflect
|
|
50
|
+
* the unsupported state.
|
|
52
51
|
*/
|
|
53
52
|
isSkillsSupported: boolean;
|
|
54
53
|
/** The user's own skills. */
|
|
@@ -84,18 +83,18 @@ export interface UseSkillSelectorOverlayOptions {
|
|
|
84
83
|
export interface UseSkillSelectorOverlayResult {
|
|
85
84
|
/**
|
|
86
85
|
* The Skills entry for the `menuOverlays` prop of
|
|
87
|
-
* `ConversationInput`/`Input`. `undefined` while the flow
|
|
88
|
-
* current deployment does not support skills: the host
|
|
89
|
-
* entirely when this is `undefined`, so a stub renderer
|
|
90
|
-
* menu item in place with nothing behind it.
|
|
86
|
+
* `ConversationInput`/`EditMessageInput`/`Input`. `undefined` while the flow
|
|
87
|
+
* is disabled or the current deployment does not support skills: the host
|
|
88
|
+
* omits the entry entirely when this is `undefined`, so a stub renderer
|
|
89
|
+
* would leave the menu item in place with nothing behind it.
|
|
91
90
|
*/
|
|
92
91
|
skillMenuOverlay?: MenuOverlayConfig;
|
|
93
92
|
/**
|
|
94
93
|
* The Skills entry for the `commandMenu` prop of
|
|
95
|
-
* `ConversationInput`/`Input`: typing `/` into an empty
|
|
96
|
-
* favorites panel in search mode above the input.
|
|
97
|
-
* flow is disabled or the current deployment does not
|
|
98
|
-
* disabling the slash menu entirely.
|
|
94
|
+
* `ConversationInput`/`EditMessageInput`/`Input`: typing `/` into an empty
|
|
95
|
+
* textarea opens the favorites panel in search mode above the input.
|
|
96
|
+
* `undefined` while the flow is disabled or the current deployment does not
|
|
97
|
+
* support skills, disabling the slash menu entirely.
|
|
99
98
|
*/
|
|
100
99
|
commandMenu?: CommandMenuConfig;
|
|
101
100
|
/**
|
|
@@ -109,55 +108,102 @@ export interface UseSkillSelectorOverlayResult {
|
|
|
109
108
|
*/
|
|
110
109
|
skillDetailsPanel: ReactNode;
|
|
111
110
|
/**
|
|
112
|
-
* The
|
|
113
|
-
* `
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
111
|
+
* The composer's message text after the most recent skill selection, with
|
|
112
|
+
* every `/{name}` mention spliced in. Pass straight through to
|
|
113
|
+
* `ConversationInput`/`EditMessageInput`'s own `message` prop alongside
|
|
114
|
+
* `messageRevision` — like that prop's existing "populated by a starter
|
|
115
|
+
* selection" use, this is a one-shot push applied on a `messageRevision`
|
|
116
|
+
* bump, not a value the host feeds back on every keystroke (ordinary typing
|
|
117
|
+
* is tracked separately through `onDraftChange`).
|
|
119
118
|
*/
|
|
120
|
-
|
|
119
|
+
message: string;
|
|
121
120
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* `
|
|
121
|
+
* Token that forces `message` to re-apply even when its string value is
|
|
122
|
+
* unchanged from the last push (e.g. the same skill selected again).
|
|
123
|
+
* Bumped on every call to the selection handlers backing `skillMenuOverlay`
|
|
124
|
+
* and `commandMenu`. Pass straight through to the composer's own
|
|
125
|
+
* `messageRevision` prop.
|
|
126
126
|
*/
|
|
127
|
-
|
|
127
|
+
messageRevision: number;
|
|
128
128
|
/**
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* `
|
|
132
|
-
* disabled.
|
|
129
|
+
* Every currently-tracked skill mention's character range within the
|
|
130
|
+
* composer's live draft text, for `ConversationInput`/`EditMessageInput`/
|
|
131
|
+
* `Input`'s `activeMentions` prop (the live-composing highlighted-run
|
|
132
|
+
* render). Empty while nothing is mentioned or the flow is disabled.
|
|
133
133
|
*/
|
|
134
|
-
|
|
134
|
+
activeMentions: HighlightedTextRange[];
|
|
135
135
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
136
|
+
* Reconciles tracked mentions against an external edit to the composer's
|
|
137
|
+
* draft text (ordinary typing, deleting, pasting, undo/redo). Wire to the
|
|
138
|
+
* composer's own `onChange` callback, in addition to whatever the host
|
|
139
|
+
* already does with that value — this keeps `activeMentions`/
|
|
140
|
+
* `selectedSkills` in sync with live edits between selections.
|
|
139
141
|
*/
|
|
140
|
-
|
|
142
|
+
onDraftChange: (nextValue: string) => void;
|
|
143
|
+
/**
|
|
144
|
+
* Looks up the mention whose run ends exactly at `caretPosition`, without
|
|
145
|
+
* mutating any state. Pass straight through to the composer's
|
|
146
|
+
* `onBackspaceAtCaret` prop, which performs the actual whole-mention
|
|
147
|
+
* deletion through the textarea's native editing pipeline and reports the
|
|
148
|
+
* result back through `onDraftChange`. Returns `undefined` when the caret
|
|
149
|
+
* isn't at a mention boundary.
|
|
150
|
+
*/
|
|
151
|
+
onBackspaceAtCaret: (caretPosition: number) => HighlightedTextRange | undefined;
|
|
141
152
|
/**
|
|
142
|
-
*
|
|
143
|
-
*
|
|
153
|
+
* Caret offset to place the cursor at immediately after the most recent
|
|
154
|
+
* skill selection applies `message`/`messageRevision` — the position right
|
|
155
|
+
* after the inserted mention's text. Pass straight through to the
|
|
156
|
+
* composer's `caretPositionOverride` prop. `undefined` before any selection
|
|
157
|
+
* has been made this session.
|
|
144
158
|
*/
|
|
145
|
-
|
|
159
|
+
caretPositionOverride: number | undefined;
|
|
146
160
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
161
|
+
* Whether at least one skill is mentioned while the current deployment does
|
|
162
|
+
* not support skills — hosts must fold this into their send-disabled
|
|
163
|
+
* conditions. Always `false` while `isEnabled` is `false`.
|
|
150
164
|
*/
|
|
151
|
-
|
|
165
|
+
isSkillUnsupported: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Every currently-tracked mention as the send-time `custom_content.skills`
|
|
168
|
+
* payload, in left-to-right text order — `undefined` while nothing is
|
|
169
|
+
* mentioned or the flow is disabled, so `custom_content.skills` is omitted
|
|
170
|
+
* entirely. Cleared to `undefined` by `resetSkillMentions` after a
|
|
171
|
+
* successful send.
|
|
172
|
+
*/
|
|
173
|
+
selectedSkills: RequestSkill[] | undefined;
|
|
152
174
|
/**
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
*
|
|
160
|
-
* `
|
|
175
|
+
* Clears every tracked mention and the draft text alongside it. Call after
|
|
176
|
+
* a successful send, matching the per-message selection-clears semantics of
|
|
177
|
+
* `custom_content.skills`.
|
|
178
|
+
*/
|
|
179
|
+
resetSkillMentions: () => void;
|
|
180
|
+
/**
|
|
181
|
+
* Seeds the draft and its tracked mentions from a persisted message — runs
|
|
182
|
+
* `matchSkillMentions` once against `content`/`skills` and initializes
|
|
183
|
+
* `message`/`activeMentions` from the result (bumping `messageRevision`).
|
|
184
|
+
* Call once when entering edit mode on a message that carries
|
|
185
|
+
* `custom_content.skills`.
|
|
186
|
+
*/
|
|
187
|
+
seedSkillMentions: (content: string, skills: RequestSkill[] | undefined) => void;
|
|
188
|
+
/**
|
|
189
|
+
* Renders a user message's `content` and `custom_content.skills` as an
|
|
190
|
+
* ordered array interleaving plain-text runs and `ChatSkill` elements at
|
|
191
|
+
* each mention's actual text position — for `UserMessageBubble`'s
|
|
192
|
+
* `textSegments` prop. Resolves each entry's name from the listing pools
|
|
193
|
+
* matched on its url, falling back to the url's last non-empty segment,
|
|
194
|
+
* sharing the "View details" panel with the favorite rows. Returns `null`
|
|
195
|
+
* while `isEnabled` is `false` or `skills` is empty/absent; a mention
|
|
196
|
+
* `matchSkillMentions` cannot locate in `content` is simply omitted from
|
|
197
|
+
* the render (see `matchSkillMentions`'s own doc for that heuristic).
|
|
198
|
+
*/
|
|
199
|
+
renderHistorySkillSegments: (content: string, skills: RequestSkill[] | undefined) => ReactNode[] | null;
|
|
200
|
+
/**
|
|
201
|
+
* Renders every entry of `skills` as a flat list of `ChatSkill` elements,
|
|
202
|
+
* ignoring text position — for `AssistantMessageBubble`'s `beforeContent`
|
|
203
|
+
* slot, since assistant text is model-generated markdown and never
|
|
204
|
+
* authors positioned mentions. Each entry's name/description resolve the
|
|
205
|
+
* same way as `renderHistorySkillSegments`. Returns `null` while
|
|
206
|
+
* `isEnabled` is `false` or the array is empty/absent.
|
|
161
207
|
*/
|
|
162
208
|
renderHistorySkills: (skills: RequestSkill[] | undefined) => ReactNode;
|
|
163
209
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill-selector-overlay.d.ts","sourceRoot":"","sources":["../../src/models/skill-selector-overlay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,WAAW,+BAA+B;IAC9C,iFAAiF;IACjF,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,2EAA2E;IAC3E,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,qEAAqE;AACrE,MAAM,WAAW,0BAA0B;IACzC,2EAA2E;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAChF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B
|
|
1
|
+
{"version":3,"file":"skill-selector-overlay.d.ts","sourceRoot":"","sources":["../../src/models/skill-selector-overlay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAA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AAC;IACV;;;;;;;;;;OAUG;IACH,0BAA0B,EAAE,CAC1B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,KAC/B,SAAS,EAAE,GAAG,IAAI,CAAC;IACxB;;;;;;;OAOG;IACH,mBAAmB,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,KAAK,SAAS,CAAC;CACxE"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-skills",
|
|
3
3
|
"description": "Host-agnostic UI for picking a favorite skill to attach to a chat input",
|
|
4
|
-
"version": "1.2.0-dev.
|
|
4
|
+
"version": "1.2.0-dev.142",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@tabler/icons-react": "^3.44.0",
|
|
21
|
-
"@epam/ai-dial-catalog": "1.2.0-dev.
|
|
22
|
-
"@epam/ai-dial-conversation-input": "1.2.0-dev.
|
|
21
|
+
"@epam/ai-dial-catalog": "1.2.0-dev.142",
|
|
22
|
+
"@epam/ai-dial-conversation-input": "1.2.0-dev.142"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@epam/ai-dial-chat-shared": "1.2.0-dev.
|
|
25
|
+
"@epam/ai-dial-chat-shared": "1.2.0-dev.142",
|
|
26
26
|
"@epam/ai-dial-ui-kit": "^0.15.0-dev.18",
|
|
27
27
|
"react": "^19.2.8"
|
|
28
28
|
},
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RequestSkill } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
/** One resolved mention location, or omitted for a skill whose text mention could not be found. */
|
|
3
|
+
export interface ResolvedSkillMention {
|
|
4
|
+
/** Index into the input `skills` array this location resolves. */
|
|
5
|
+
skillIndex: number;
|
|
6
|
+
/** Character offset of the leading `/` in `text`. */
|
|
7
|
+
start: number;
|
|
8
|
+
/** Length of the matched `/{name}` run. */
|
|
9
|
+
length: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Matches each entry of `skills` (in array order) to the next available
|
|
13
|
+
* `/{name}` occurrence in `text`, where `name` is that entry's display name
|
|
14
|
+
* resolved via `resolveName(url)` — the current listing name, falling back to
|
|
15
|
+
* the url's last path segment (`getSkillFallbackName`). Scans left to right,
|
|
16
|
+
* consuming text as it goes, so two skills with the same resolved name are
|
|
17
|
+
* still matched to distinct, successive occurrences in the text. A skill
|
|
18
|
+
* whose exact `/{name}` cannot be found at or after the current scan position
|
|
19
|
+
* (e.g. the user's later edit broke the mention) is omitted from the result —
|
|
20
|
+
* it still counts as a real `custom_content.skills` entry for sending, it
|
|
21
|
+
* simply renders nowhere in particular, and later entries still get their own
|
|
22
|
+
* independent forward search from the same unmoved cursor.
|
|
23
|
+
*/
|
|
24
|
+
export declare const matchSkillMentions: (text: string, skills: RequestSkill[], resolveName: (url: string) => string) => ResolvedSkillMention[];
|
|
25
|
+
//# sourceMappingURL=skill-mention-matching.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-mention-matching.d.ts","sourceRoot":"","sources":["../../src/utils/skill-mention-matching.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,mGAAmG;AACnG,MAAM,WAAW,oBAAoB;IACnC,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;CAChB;AAKD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,MAAM,EACZ,QAAQ,YAAY,EAAE,EACtB,aAAa,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,KACnC,oBAAoB,EA0BtB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { SkillMentionAnchor } from '../models/skill-mention-anchor';
|
|
2
|
+
/** A single-region text edit, expressed as the replaced range in the previous string. */
|
|
3
|
+
export interface TextChange {
|
|
4
|
+
/** Character offset where the previous and next strings first diverge. */
|
|
5
|
+
start: number;
|
|
6
|
+
/** Number of characters removed from the previous string at `start`. */
|
|
7
|
+
deletedLength: number;
|
|
8
|
+
/** Number of characters inserted at `start` in the next string. */
|
|
9
|
+
insertedLength: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Diffs two strings produced by a single-cursor edit (typing, deleting,
|
|
13
|
+
* pasting, cutting, undo/redo) via their common prefix and common suffix —
|
|
14
|
+
* cheap (O(n)) and exact for that class of edit, which is everything a
|
|
15
|
+
* textarea actually produces.
|
|
16
|
+
*/
|
|
17
|
+
export declare const diffTextChange: (previous: string, next: string) => TextChange;
|
|
18
|
+
/**
|
|
19
|
+
* Applies a text change to a set of tracked mention anchors: an anchor
|
|
20
|
+
* entirely before the edited region is untouched, one entirely after is
|
|
21
|
+
* shifted by the edit's length delta, and one that overlaps the edited region
|
|
22
|
+
* is dropped — the user edited into the middle of a mention, so it reverts to
|
|
23
|
+
* plain text and no longer contributes a `custom_content.skills` entry.
|
|
24
|
+
*/
|
|
25
|
+
export declare const reconcileAnchors: (anchors: SkillMentionAnchor[], change: TextChange) => SkillMentionAnchor[];
|
|
26
|
+
/**
|
|
27
|
+
* Inserts a new mention anchor at `atIndex` and shifts every anchor at or
|
|
28
|
+
* after that index by the inserted `/{name}` run's length — plus one more
|
|
29
|
+
* when `hasTrailingSpace` — keeping the result ordered by `start`
|
|
30
|
+
* (left-to-right reading order).
|
|
31
|
+
*/
|
|
32
|
+
export declare const insertAnchor: (anchors: SkillMentionAnchor[], atIndex: number, url: string, name: string, hasTrailingSpace: boolean) => SkillMentionAnchor[];
|
|
33
|
+
/**
|
|
34
|
+
* Finds the anchor whose mention run ends exactly at `caretPosition` — the
|
|
35
|
+
* caret sitting immediately after that mention — or `undefined` if none does.
|
|
36
|
+
* Used to detect the whole-mention Backspace gesture.
|
|
37
|
+
*/
|
|
38
|
+
export declare const findMentionAtCaret: (anchors: SkillMentionAnchor[], caretPosition: number) => SkillMentionAnchor | undefined;
|
|
39
|
+
//# sourceMappingURL=skill-mention-tracking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-mention-tracking.d.ts","sourceRoot":"","sources":["../../src/utils/skill-mention-tracking.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,yFAAyF;AACzF,MAAM,WAAW,UAAU;IACzB,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,aAAa,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,EAAE,MAAM,MAAM,KAAG,UAyB/D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC3B,SAAS,kBAAkB,EAAE,EAC7B,QAAQ,UAAU,KACjB,kBAAkB,EAmBpB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GACvB,SAAS,kBAAkB,EAAE,EAC7B,SAAS,MAAM,EACf,KAAK,MAAM,EACX,MAAM,MAAM,EACZ,kBAAkB,OAAO,KACxB,kBAAkB,EAkBpB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,kBAAkB,EAAE,EAC7B,eAAe,MAAM,KACpB,kBAAkB,GAAG,SACkD,CAAC"}
|