@uipath/apollo-react 3.26.1-pr170.dbcf8c9 → 3.26.2-pr202.089892a

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.
Files changed (50) hide show
  1. package/README.md +2 -0
  2. package/dist/canvas/icons/CaseManagementProject.cjs +1 -1
  3. package/dist/canvas/icons/CaseManagementProject.js +1 -1
  4. package/dist/material/components/ap-chat/components/input/chat-input-editor.cjs +6 -13
  5. package/dist/material/components/ap-chat/components/input/chat-input-editor.d.ts +1 -0
  6. package/dist/material/components/ap-chat/components/input/chat-input-editor.d.ts.map +1 -1
  7. package/dist/material/components/ap-chat/components/input/chat-input-editor.js +7 -14
  8. package/dist/material/components/ap-chat/components/input/chat-input-resource-picker.cjs +193 -236
  9. package/dist/material/components/ap-chat/components/input/chat-input-resource-picker.d.ts.map +1 -1
  10. package/dist/material/components/ap-chat/components/input/chat-input-resource-picker.js +195 -238
  11. package/dist/material/components/ap-chat/components/input/chat-input.cjs +2 -1
  12. package/dist/material/components/ap-chat/components/input/chat-input.d.ts.map +1 -1
  13. package/dist/material/components/ap-chat/components/input/chat-input.js +2 -1
  14. package/dist/material/components/ap-chat/components/input/tiptap/resource-chip-node-view.cjs +3 -12
  15. package/dist/material/components/ap-chat/components/input/tiptap/resource-chip-node-view.d.ts.map +1 -1
  16. package/dist/material/components/ap-chat/components/input/tiptap/resource-chip-node-view.js +4 -13
  17. package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.cjs +3 -25
  18. package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.d.ts +0 -1
  19. package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.d.ts.map +1 -1
  20. package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.js +4 -26
  21. package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.styles.cjs +1 -2
  22. package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.styles.d.ts.map +1 -1
  23. package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.styles.js +1 -2
  24. package/dist/material/components/ap-chat/components/input/tiptap/tiptap-resource-suggestion.cjs +14 -19
  25. package/dist/material/components/ap-chat/components/input/tiptap/tiptap-resource-suggestion.d.ts +2 -5
  26. package/dist/material/components/ap-chat/components/input/tiptap/tiptap-resource-suggestion.d.ts.map +1 -1
  27. package/dist/material/components/ap-chat/components/input/tiptap/tiptap-resource-suggestion.js +14 -16
  28. package/dist/material/components/ap-chat/components/input/tiptap/tiptap.utils.cjs +0 -21
  29. package/dist/material/components/ap-chat/components/input/tiptap/tiptap.utils.d.ts +0 -5
  30. package/dist/material/components/ap-chat/components/input/tiptap/tiptap.utils.d.ts.map +1 -1
  31. package/dist/material/components/ap-chat/components/input/tiptap/tiptap.utils.js +1 -19
  32. package/dist/material/components/ap-chat/components/message/chat-message.cjs +0 -2
  33. package/dist/material/components/ap-chat/components/message/chat-message.d.ts.map +1 -1
  34. package/dist/material/components/ap-chat/components/message/chat-message.js +0 -2
  35. package/dist/material/components/ap-chat/components/message/markdown/parsers/resource-token-parser.cjs +2 -11
  36. package/dist/material/components/ap-chat/components/message/markdown/parsers/resource-token-parser.d.ts +0 -1
  37. package/dist/material/components/ap-chat/components/message/markdown/parsers/resource-token-parser.d.ts.map +1 -1
  38. package/dist/material/components/ap-chat/components/message/markdown/parsers/resource-token-parser.js +1 -7
  39. package/dist/material/components/ap-chat/hooks/use-resource-picker-state.cjs +4 -13
  40. package/dist/material/components/ap-chat/hooks/use-resource-picker-state.d.ts.map +1 -1
  41. package/dist/material/components/ap-chat/hooks/use-resource-picker-state.js +4 -13
  42. package/dist/material/components/ap-chat/providers/resource-picker-provider.cjs +19 -54
  43. package/dist/material/components/ap-chat/providers/resource-picker-provider.d.ts +1 -4
  44. package/dist/material/components/ap-chat/providers/resource-picker-provider.d.ts.map +1 -1
  45. package/dist/material/components/ap-chat/providers/resource-picker-provider.js +20 -55
  46. package/dist/material/components/ap-chat/service/ChatConstants.cjs +4 -16
  47. package/dist/material/components/ap-chat/service/ChatConstants.d.ts +1 -4
  48. package/dist/material/components/ap-chat/service/ChatConstants.d.ts.map +1 -1
  49. package/dist/material/components/ap-chat/service/ChatConstants.js +2 -5
  50. package/package.json +1 -2
@@ -2,16 +2,16 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useLingui } from "@lingui/react";
3
3
  import { styled } from "@mui/material/styles";
4
4
  import { NodeViewWrapper } from "@tiptap/react";
5
- import apollo_core, { Typography } from "@uipath/apollo-core";
5
+ import apollo_core from "@uipath/apollo-core";
6
6
  import react from "react";
7
7
  import { useChatState } from "../../../providers/chat-state-provider.js";
8
8
  import { CHAT_RESOURCE_CHIP_MAX_WIDTH } from "../../../service/index.js";
9
- import { fontByVariant } from "../../../utils/font-by-variant.js";
10
9
  import { AutopilotChatActionButton } from "../../common/action-button.js";
11
10
  import { AutopilotChatTooltip } from "../../common/tooltip.js";
12
11
  const ChipContent = styled('span')(({ theme, readonly })=>({
13
12
  display: 'inline-flex',
14
13
  alignItems: 'center',
14
+ gap: apollo_core.Spacing.SpacingMicro,
15
15
  padding: `0 ${apollo_core.Padding.PadS}`,
16
16
  backgroundColor: theme.palette.semantic.colorPrimaryLighter,
17
17
  color: theme.palette.semantic.colorForeground,
@@ -33,8 +33,7 @@ const ChipLabel = styled('span')(()=>({
33
33
  fontWeight: apollo_core.FontFamily.FontWeightSemibold,
34
34
  overflow: 'hidden',
35
35
  textOverflow: 'ellipsis',
36
- whiteSpace: 'nowrap',
37
- padding: `0 ${apollo_core.Padding.PadS}`
36
+ whiteSpace: 'nowrap'
38
37
  }));
39
38
  const ChipDeleteContainer = styled('span')(({ visible, compactMode, theme })=>({
40
39
  opacity: visible ? 1 : 0,
@@ -47,7 +46,7 @@ const ChipDeleteContainer = styled('span')(({ visible, compactMode, theme })=>({
47
46
  backgroundColor: theme.palette.semantic.colorPrimaryLighter,
48
47
  borderRadius: `calc(${apollo_core.Border.BorderRadiusL} * 2)`,
49
48
  transition: 'opacity 0.15s ease-in-out',
50
- '& .MuiButtonBase-root.MuiButtonBase-root': {
49
+ '& .MuiButtonBase-root': {
51
50
  height: compactMode ? apollo_core.Spacing.SpacingS : apollo_core.Spacing.SpacingM,
52
51
  width: compactMode ? apollo_core.Spacing.SpacingS : apollo_core.Spacing.SpacingM,
53
52
  padding: 0,
@@ -118,16 +117,8 @@ const ResourceChipBase = /*#__PURE__*/ react.memo(ResourceChipBaseInner);
118
117
  ResourceChipBase.displayName = 'ResourceChipBase';
119
118
  const ResourceChipNodeView = /*#__PURE__*/ react.memo(({ node, deleteNode })=>{
120
119
  const { label, icon } = node.attrs;
121
- const { spacing } = useChatState();
122
- const lineHeight = fontByVariant(spacing.primaryFontToken)?.lineHeight ?? Typography.fontSizeM.lineHeight;
123
120
  return /*#__PURE__*/ jsx(NodeViewWrapper, {
124
121
  as: "span",
125
- style: {
126
- display: 'inline-flex',
127
- alignItems: 'center',
128
- height: lineHeight,
129
- verticalAlign: 'top'
130
- },
131
122
  children: /*#__PURE__*/ jsx(ResourceChipBase, {
132
123
  label: label,
133
124
  icon: icon,
@@ -49,7 +49,6 @@ var extension_text_default = /*#__PURE__*/ __webpack_require__.n(extension_text_
49
49
  const extensions_namespaceObject = require("@tiptap/extensions");
50
50
  const model_namespaceObject = require("@tiptap/pm/model");
51
51
  const react_namespaceObject = require("@tiptap/react");
52
- const suggestion_namespaceObject = require("@tiptap/suggestion");
53
52
  const external_react_namespaceObject = require("react");
54
53
  var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
55
54
  const external_resource_chip_node_view_cjs_namespaceObject = require("./resource-chip-node-view.cjs");
@@ -88,7 +87,6 @@ function TipTapEditorInner(props, ref) {
88
87
  onMentionQueryChange
89
88
  });
90
89
  const mentionRangeRef = external_react_default().useRef(null);
91
- const suppressSuggestionRef = external_react_default().useRef(false);
92
90
  external_react_default().useLayoutEffect(()=>{
93
91
  callbacksRef.current = {
94
92
  onChange,
@@ -117,7 +115,7 @@ function TipTapEditorInner(props, ref) {
117
115
  mentionRangeRef.current = range;
118
116
  callbacksRef.current.onMentionQueryChange?.(query, range);
119
117
  }
120
- }, suppressSuggestionRef), []);
118
+ }), []);
121
119
  const extensions = external_react_default().useMemo(()=>[
122
120
  extension_document_default(),
123
121
  extension_paragraph_default(),
@@ -155,16 +153,6 @@ function TipTapEditorInner(props, ref) {
155
153
  },
156
154
  editorProps: {
157
155
  handleKeyDown: (_view, event)=>callbacksRef.current.onKeyDown?.(event) ?? false,
158
- handleDOMEvents: {
159
- mousedown: ()=>{
160
- suppressSuggestionRef.current = false;
161
- return false;
162
- },
163
- keydown: ()=>{
164
- suppressSuggestionRef.current = false;
165
- return false;
166
- }
167
- },
168
156
  attributes: {
169
157
  'data-testid': 'tiptap-editor'
170
158
  },
@@ -261,34 +249,24 @@ function TipTapEditorInner(props, ref) {
261
249
  ]);
262
250
  const triggerMention = (0, external_react_namespaceObject.useCallback)(()=>{
263
251
  if (!editor) return;
264
- suppressSuggestionRef.current = false;
265
252
  editor.chain().focus().insertContent('@').run();
266
253
  }, [
267
254
  editor
268
255
  ]);
269
- const exitMention = (0, external_react_namespaceObject.useCallback)(()=>{
270
- if (!editor) return;
271
- suppressSuggestionRef.current = true;
272
- (0, suggestion_namespaceObject.exitSuggestion)(editor.view, external_tiptap_resource_suggestion_cjs_namespaceObject.ResourceMentionPluginKey);
273
- }, [
274
- editor
275
- ]);
276
256
  external_react_default().useImperativeHandle(ref, ()=>({
277
257
  focus,
278
258
  insertResource,
279
259
  getSerializedContent,
280
260
  clear,
281
261
  clearMentionQuery,
282
- triggerMention,
283
- exitMention
262
+ triggerMention
284
263
  }), [
285
264
  focus,
286
265
  insertResource,
287
266
  getSerializedContent,
288
267
  clear,
289
268
  clearMentionQuery,
290
- triggerMention,
291
- exitMention
269
+ triggerMention
292
270
  ]);
293
271
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_tiptap_editor_styles_cjs_namespaceObject.EditorContainer, {
294
272
  minRows: minRows,
@@ -9,7 +9,6 @@ export interface TipTapEditorHandle {
9
9
  clear: () => void;
10
10
  clearMentionQuery: () => void;
11
11
  triggerMention: () => void;
12
- exitMention: () => void;
13
12
  }
14
13
  interface TipTapEditorCallbacks {
15
14
  onChange?: (value: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"tiptap-editor.d.ts","sourceRoot":"","sources":["../../../../../../../src/material/components/ap-chat/components/input/tiptap/tiptap-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAU1C,OAAO,KAAkC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAIpE,OAAO,EACL,KAAK,iBAAiB,EAGvB,MAAM,8BAA8B,CAAC;AA2BtC,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,cAAc,EAAE,CAAC,QAAQ,EAAE,yBAAyB,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IAC7E,oBAAoB,EAAE,MAAM,MAAM,CAAC;IACnC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,UAAU,qBAAqB;IAC7B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC;IAC9C,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACnE,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC9D;AAED,UAAU,iBAAkB,SAAQ,qBAAqB;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAiQD,eAAO,MAAM,YAAY,yFAA4C,CAAC"}
1
+ {"version":3,"file":"tiptap-editor.d.ts","sourceRoot":"","sources":["../../../../../../../src/material/components/ap-chat/components/input/tiptap/tiptap-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAS1C,OAAO,KAAkC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAIpE,OAAO,EAAE,KAAK,iBAAiB,EAA4B,MAAM,8BAA8B,CAAC;AA2BhG,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,cAAc,EAAE,CAAC,QAAQ,EAAE,yBAAyB,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IAC7E,oBAAoB,EAAE,MAAM,MAAM,CAAC;IACnC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,UAAU,qBAAqB;IAC7B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC;IAC9C,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACnE,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC9D;AAED,UAAU,iBAAkB,SAAQ,qBAAqB;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAmOD,eAAO,MAAM,YAAY,yFAA4C,CAAC"}
@@ -7,12 +7,11 @@ import extension_text from "@tiptap/extension-text";
7
7
  import { Placeholder, UndoRedo } from "@tiptap/extensions";
8
8
  import { Fragment, Node, Slice } from "@tiptap/pm/model";
9
9
  import { EditorContent, ReactNodeViewRenderer, useEditor } from "@tiptap/react";
10
- import { exitSuggestion } from "@tiptap/suggestion";
11
10
  import react, { forwardRef, useCallback } from "react";
12
11
  import { ResourceChipNodeView } from "./resource-chip-node-view.js";
13
12
  import { textToDocument } from "./tiptap.utils.js";
14
13
  import { EditorContainer } from "./tiptap-editor.styles.js";
15
- import { ResourceMentionPluginKey, createResourceSuggestion } from "./tiptap-resource-suggestion.js";
14
+ import { createResourceSuggestion } from "./tiptap-resource-suggestion.js";
16
15
  const ResourceMention = extension_mention.extend({
17
16
  addAttributes () {
18
17
  return {
@@ -45,7 +44,6 @@ function TipTapEditorInner(props, ref) {
45
44
  onMentionQueryChange
46
45
  });
47
46
  const mentionRangeRef = react.useRef(null);
48
- const suppressSuggestionRef = react.useRef(false);
49
47
  react.useLayoutEffect(()=>{
50
48
  callbacksRef.current = {
51
49
  onChange,
@@ -74,7 +72,7 @@ function TipTapEditorInner(props, ref) {
74
72
  mentionRangeRef.current = range;
75
73
  callbacksRef.current.onMentionQueryChange?.(query, range);
76
74
  }
77
- }, suppressSuggestionRef), []);
75
+ }), []);
78
76
  const extensions = react.useMemo(()=>[
79
77
  extension_document,
80
78
  extension_paragraph,
@@ -112,16 +110,6 @@ function TipTapEditorInner(props, ref) {
112
110
  },
113
111
  editorProps: {
114
112
  handleKeyDown: (_view, event)=>callbacksRef.current.onKeyDown?.(event) ?? false,
115
- handleDOMEvents: {
116
- mousedown: ()=>{
117
- suppressSuggestionRef.current = false;
118
- return false;
119
- },
120
- keydown: ()=>{
121
- suppressSuggestionRef.current = false;
122
- return false;
123
- }
124
- },
125
113
  attributes: {
126
114
  'data-testid': 'tiptap-editor'
127
115
  },
@@ -218,34 +206,24 @@ function TipTapEditorInner(props, ref) {
218
206
  ]);
219
207
  const triggerMention = useCallback(()=>{
220
208
  if (!editor) return;
221
- suppressSuggestionRef.current = false;
222
209
  editor.chain().focus().insertContent('@').run();
223
210
  }, [
224
211
  editor
225
212
  ]);
226
- const exitMention = useCallback(()=>{
227
- if (!editor) return;
228
- suppressSuggestionRef.current = true;
229
- exitSuggestion(editor.view, ResourceMentionPluginKey);
230
- }, [
231
- editor
232
- ]);
233
213
  react.useImperativeHandle(ref, ()=>({
234
214
  focus,
235
215
  insertResource,
236
216
  getSerializedContent,
237
217
  clear,
238
218
  clearMentionQuery,
239
- triggerMention,
240
- exitMention
219
+ triggerMention
241
220
  }), [
242
221
  focus,
243
222
  insertResource,
244
223
  getSerializedContent,
245
224
  clear,
246
225
  clearMentionQuery,
247
- triggerMention,
248
- exitMention
226
+ triggerMention
249
227
  ]);
250
228
  return /*#__PURE__*/ jsx(EditorContainer, {
251
229
  minRows: minRows,
@@ -51,8 +51,7 @@ const EditorContainer = (0, styles_namespaceObject.styled)('div')(({ theme, minR
51
51
  paddingBottom: EDITOR_PADDING,
52
52
  '& p': {
53
53
  margin: 0,
54
- minHeight: lineHeight,
55
- lineHeight: lineHeight
54
+ minHeight: lineHeight
56
55
  },
57
56
  '& p.is-editor-empty:first-of-type::before': {
58
57
  content: 'attr(data-placeholder)',
@@ -1 +1 @@
1
- {"version":3,"file":"tiptap-editor.styles.d.ts","sourceRoot":"","sources":["../../../../../../../src/material/components/ap-chat/components/input/tiptap/tiptap-editor.styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,eAAe;aACjB,MAAM;aACN,MAAM;gBACH,MAAM;yGA2BjB,CAAC"}
1
+ {"version":3,"file":"tiptap-editor.styles.d.ts","sourceRoot":"","sources":["../../../../../../../src/material/components/ap-chat/components/input/tiptap/tiptap-editor.styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,eAAe;aACjB,MAAM;aACN,MAAM;gBACH,MAAM;yGA0BjB,CAAC"}
@@ -13,8 +13,7 @@ const EditorContainer = styled('div')(({ theme, minRows, maxRows, lineHeight })=
13
13
  paddingBottom: EDITOR_PADDING,
14
14
  '& p': {
15
15
  margin: 0,
16
- minHeight: lineHeight,
17
- lineHeight: lineHeight
16
+ minHeight: lineHeight
18
17
  },
19
18
  '& p.is-editor-empty:first-of-type::before': {
20
19
  content: 'attr(data-placeholder)',
@@ -24,14 +24,8 @@ var __webpack_require__ = {};
24
24
  var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
- createResourceSuggestion: ()=>createResourceSuggestion,
28
- ResourceMentionPluginKey: ()=>ResourceMentionPluginKey
27
+ createResourceSuggestion: ()=>createResourceSuggestion
29
28
  });
30
- const state_namespaceObject = require("@tiptap/pm/state");
31
- const index_cjs_namespaceObject = require("../../../service/index.cjs");
32
- const external_tiptap_utils_cjs_namespaceObject = require("./tiptap.utils.cjs");
33
- const ResourceMentionPluginKey = new state_namespaceObject.PluginKey('resourceMention');
34
- const RESOURCE_QUERY_START_PATTERN = /^[a-zA-Z0-9_./\\]/;
35
29
  function getCursorCoordinates(editor, pos) {
36
30
  const coords = editor.view.coordsAtPos(pos);
37
31
  return {
@@ -39,40 +33,41 @@ function getCursorCoordinates(editor, pos) {
39
33
  left: coords.left
40
34
  };
41
35
  }
42
- function createResourceSuggestion(callbacks, suppressRef) {
36
+ function createResourceSuggestion(callbacks) {
37
+ let isActive = false;
43
38
  return {
44
- pluginKey: ResourceMentionPluginKey,
45
39
  allowSpaces: true,
46
40
  allow: ({ state, range })=>{
47
- if (suppressRef.current) return false;
48
41
  const textFrom = range.from + 1;
49
42
  const textTo = range.to;
50
43
  const query = textFrom < textTo ? state.doc.textBetween(textFrom, textTo) : '';
51
- if (query.length > 0 && !RESOURCE_QUERY_START_PATTERN.test(query.charAt(0))) return false;
52
- if (query.includes(index_cjs_namespaceObject.CHAT_RESOURCE_MENTION_TERMINATOR)) return false;
44
+ if (query.startsWith(' ') || query.includes(' ')) return false;
53
45
  return true;
54
46
  },
47
+ items: ()=>[],
55
48
  render: ()=>({
56
49
  onStart: (props)=>{
50
+ isActive = true;
57
51
  const coords = getCursorCoordinates(props.editor, props.range.from);
58
- const { query, fullRange } = (0, external_tiptap_utils_cjs_namespaceObject.getFullMentionQuery)(props.editor, props.range);
59
- callbacks.onStart?.(fullRange, coords);
60
- callbacks.onQueryChange?.(query, fullRange);
52
+ callbacks.onStart?.(props.range, coords);
53
+ callbacks.onQueryChange?.(props.query, props.range);
61
54
  },
62
55
  onUpdate: (props)=>{
63
- const { query, fullRange } = (0, external_tiptap_utils_cjs_namespaceObject.getFullMentionQuery)(props.editor, props.range);
64
- callbacks.onQueryChange?.(query, fullRange);
56
+ callbacks.onQueryChange?.(props.query, props.range);
57
+ },
58
+ onKeyDown: (props)=>{
59
+ if (!isActive) return false;
60
+ return callbacks.onKeyDown?.(props.event) ?? false;
65
61
  },
66
62
  onExit: ()=>{
63
+ isActive = false;
67
64
  callbacks.onExit?.();
68
65
  }
69
66
  })
70
67
  };
71
68
  }
72
- exports.ResourceMentionPluginKey = __webpack_exports__.ResourceMentionPluginKey;
73
69
  exports.createResourceSuggestion = __webpack_exports__.createResourceSuggestion;
74
70
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
75
- "ResourceMentionPluginKey",
76
71
  "createResourceSuggestion"
77
72
  ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
78
73
  Object.defineProperty(exports, '__esModule', {
@@ -1,7 +1,5 @@
1
1
  import type { Range } from '@tiptap/core';
2
2
  import type { MentionOptions } from '@tiptap/extension-mention';
3
- import { PluginKey } from '@tiptap/pm/state';
4
- export declare const ResourceMentionPluginKey: PluginKey<any>;
5
3
  export interface CursorCoordinates {
6
4
  top: number;
7
5
  left: number;
@@ -10,9 +8,8 @@ interface ResourceSuggestionCallbacks {
10
8
  onStart?: (range: Range, coords: CursorCoordinates) => void;
11
9
  onExit?: () => void;
12
10
  onQueryChange?: (query: string, range: Range) => void;
11
+ onKeyDown?: (event: KeyboardEvent) => boolean;
13
12
  }
14
- export declare function createResourceSuggestion(callbacks: ResourceSuggestionCallbacks, suppressRef: {
15
- current: boolean;
16
- }): MentionOptions['suggestion'];
13
+ export declare function createResourceSuggestion(callbacks: ResourceSuggestionCallbacks): MentionOptions['suggestion'];
17
14
  export {};
18
15
  //# sourceMappingURL=tiptap-resource-suggestion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tiptap-resource-suggestion.d.ts","sourceRoot":"","sources":["../../../../../../../src/material/components/ap-chat/components/input/tiptap/tiptap-resource-suggestion.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,KAAK,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAI7C,eAAO,MAAM,wBAAwB,gBAAmC,CAAC;AAKzE,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,2BAA2B;IACnC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC5D,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACvD;AAUD,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,2BAA2B,EACtC,WAAW,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GAChC,cAAc,CAAC,YAAY,CAAC,CAwC9B"}
1
+ {"version":3,"file":"tiptap-resource-suggestion.d.ts","sourceRoot":"","sources":["../../../../../../../src/material/components/ap-chat/components/input/tiptap/tiptap-resource-suggestion.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,KAAK,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,2BAA2B;IACnC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC5D,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACtD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC;CAC/C;AAUD,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,2BAA2B,GACrC,cAAc,CAAC,YAAY,CAAC,CAyC9B"}
@@ -1,8 +1,3 @@
1
- import { PluginKey } from "@tiptap/pm/state";
2
- import { CHAT_RESOURCE_MENTION_TERMINATOR } from "../../../service/index.js";
3
- import { getFullMentionQuery } from "./tiptap.utils.js";
4
- const ResourceMentionPluginKey = new PluginKey('resourceMention');
5
- const RESOURCE_QUERY_START_PATTERN = /^[a-zA-Z0-9_./\\]/;
6
1
  function getCursorCoordinates(editor, pos) {
7
2
  const coords = editor.view.coordsAtPos(pos);
8
3
  return {
@@ -10,34 +5,37 @@ function getCursorCoordinates(editor, pos) {
10
5
  left: coords.left
11
6
  };
12
7
  }
13
- function createResourceSuggestion(callbacks, suppressRef) {
8
+ function createResourceSuggestion(callbacks) {
9
+ let isActive = false;
14
10
  return {
15
- pluginKey: ResourceMentionPluginKey,
16
11
  allowSpaces: true,
17
12
  allow: ({ state, range })=>{
18
- if (suppressRef.current) return false;
19
13
  const textFrom = range.from + 1;
20
14
  const textTo = range.to;
21
15
  const query = textFrom < textTo ? state.doc.textBetween(textFrom, textTo) : '';
22
- if (query.length > 0 && !RESOURCE_QUERY_START_PATTERN.test(query.charAt(0))) return false;
23
- if (query.includes(CHAT_RESOURCE_MENTION_TERMINATOR)) return false;
16
+ if (query.startsWith(' ') || query.includes(' ')) return false;
24
17
  return true;
25
18
  },
19
+ items: ()=>[],
26
20
  render: ()=>({
27
21
  onStart: (props)=>{
22
+ isActive = true;
28
23
  const coords = getCursorCoordinates(props.editor, props.range.from);
29
- const { query, fullRange } = getFullMentionQuery(props.editor, props.range);
30
- callbacks.onStart?.(fullRange, coords);
31
- callbacks.onQueryChange?.(query, fullRange);
24
+ callbacks.onStart?.(props.range, coords);
25
+ callbacks.onQueryChange?.(props.query, props.range);
32
26
  },
33
27
  onUpdate: (props)=>{
34
- const { query, fullRange } = getFullMentionQuery(props.editor, props.range);
35
- callbacks.onQueryChange?.(query, fullRange);
28
+ callbacks.onQueryChange?.(props.query, props.range);
29
+ },
30
+ onKeyDown: (props)=>{
31
+ if (!isActive) return false;
32
+ return callbacks.onKeyDown?.(props.event) ?? false;
36
33
  },
37
34
  onExit: ()=>{
35
+ isActive = false;
38
36
  callbacks.onExit?.();
39
37
  }
40
38
  })
41
39
  };
42
40
  }
43
- export { ResourceMentionPluginKey, createResourceSuggestion };
41
+ export { createResourceSuggestion };
@@ -24,27 +24,8 @@ var __webpack_require__ = {};
24
24
  var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
- getFullMentionQuery: ()=>getFullMentionQuery,
28
27
  textToDocument: ()=>textToDocument
29
28
  });
30
- const index_cjs_namespaceObject = require("../../../service/index.cjs");
31
- function getFullMentionQuery(editor, range) {
32
- const textFrom = range.from + 1;
33
- const parentEnd = editor.state.doc.resolve(textFrom).end();
34
- if (textFrom >= parentEnd) return {
35
- query: '',
36
- fullRange: range
37
- };
38
- const fullText = editor.state.doc.textBetween(textFrom, parentEnd, '', '');
39
- const query = fullText.split(index_cjs_namespaceObject.CHAT_RESOURCE_MENTION_TERMINATOR)[0] ?? '';
40
- return {
41
- query,
42
- fullRange: {
43
- from: range.from,
44
- to: textFrom + query.length
45
- }
46
- };
47
- }
48
29
  function textToDocument(text) {
49
30
  if (!text) return {
50
31
  type: 'doc',
@@ -67,10 +48,8 @@ function textToDocument(text) {
67
48
  content: paragraphs
68
49
  };
69
50
  }
70
- exports.getFullMentionQuery = __webpack_exports__.getFullMentionQuery;
71
51
  exports.textToDocument = __webpack_exports__.textToDocument;
72
52
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
73
- "getFullMentionQuery",
74
53
  "textToDocument"
75
54
  ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
76
55
  Object.defineProperty(exports, '__esModule', {
@@ -1,8 +1,3 @@
1
- import type { Editor, Range } from '@tiptap/core';
2
- export declare function getFullMentionQuery(editor: Editor, range: Range): {
3
- query: string;
4
- fullRange: Range;
5
- };
6
1
  export declare function textToDocument(text: string): {
7
2
  type: 'doc';
8
3
  content: Array<{
@@ -1 +1 @@
1
- {"version":3,"file":"tiptap.utils.d.ts","sourceRoot":"","sources":["../../../../../../../src/material/components/ap-chat/components/input/tiptap/tiptap.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AASlD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,GACX;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,KAAK,CAAA;CAAE,CAYrC;AAOD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG;IAC5C,IAAI,EAAE,KAAK,CAAC;IACZ,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAC;CACxF,CAaA"}
1
+ {"version":3,"file":"tiptap.utils.d.ts","sourceRoot":"","sources":["../../../../../../../src/material/components/ap-chat/components/input/tiptap/tiptap.utils.ts"],"names":[],"mappings":"AAKA,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG;IAC5C,IAAI,EAAE,KAAK,CAAC;IACZ,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAC;CACxF,CAaA"}
@@ -1,21 +1,3 @@
1
- import { CHAT_RESOURCE_MENTION_TERMINATOR } from "../../../service/index.js";
2
- function getFullMentionQuery(editor, range) {
3
- const textFrom = range.from + 1;
4
- const parentEnd = editor.state.doc.resolve(textFrom).end();
5
- if (textFrom >= parentEnd) return {
6
- query: '',
7
- fullRange: range
8
- };
9
- const fullText = editor.state.doc.textBetween(textFrom, parentEnd, '', '');
10
- const query = fullText.split(CHAT_RESOURCE_MENTION_TERMINATOR)[0] ?? '';
11
- return {
12
- query,
13
- fullRange: {
14
- from: range.from,
15
- to: textFrom + query.length
16
- }
17
- };
18
- }
19
1
  function textToDocument(text) {
20
2
  if (!text) return {
21
3
  type: 'doc',
@@ -38,4 +20,4 @@ function textToDocument(text) {
38
20
  content: paragraphs
39
21
  };
40
22
  }
41
- export { getFullMentionQuery, textToDocument };
23
+ export { textToDocument };
@@ -50,7 +50,6 @@ const external_chat_message_content_cjs_namespaceObject = require("./chat-messag
50
50
  const chat_fre_cjs_namespaceObject = require("./first-run-experience/chat-fre.cjs");
51
51
  const chat_loading_cjs_namespaceObject = require("./loader/chat-loading.cjs");
52
52
  const chat_loading_messages_cjs_namespaceObject = require("./loader/chat-loading-messages.cjs");
53
- const resource_token_parser_cjs_namespaceObject = require("./markdown/parsers/resource-token-parser.cjs");
54
53
  const chat_suggestions_cjs_namespaceObject = require("./suggestions/chat-suggestions.cjs");
55
54
  const MessageContainer = (0, material_namespaceObject.styled)('div')(({ isOverflow, isContainerWide, gap })=>({
56
55
  display: 'flex',
@@ -129,7 +128,6 @@ function AutopilotChatMessagesComponent({ isOverflow, isContainerWide }) {
129
128
  const onCopy = external_react_default().useCallback(({ group, message })=>{
130
129
  let finalString = '';
131
130
  finalString = 0 === group.length ? message.toCopy ?? message.content : group.map((msg)=>msg.toCopy ?? msg.content).join('\n');
132
- finalString = (0, resource_token_parser_cjs_namespaceObject.stripResourceTokens)(finalString);
133
131
  if (navigator.clipboard && finalString) navigator.clipboard.writeText(finalString).catch(()=>{});
134
132
  }, []);
135
133
  external_react_default().useEffect(()=>{
@@ -1 +1 @@
1
- {"version":3,"file":"chat-message.d.ts","sourceRoot":"","sources":["../../../../../../src/material/components/ap-chat/components/message/chat-message.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAgGvC,iBAAS,8BAA8B,CAAC,EACtC,UAAU,EACV,eAAe,GAChB,EAAE;IACD,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;CAC1B,2CA2JA;AAED,eAAO,MAAM,qBAAqB,kEAA6C,CAAC"}
1
+ {"version":3,"file":"chat-message.d.ts","sourceRoot":"","sources":["../../../../../../src/material/components/ap-chat/components/message/chat-message.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAC;AA+FvC,iBAAS,8BAA8B,CAAC,EACtC,UAAU,EACV,eAAe,GAChB,EAAE;IACD,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;CAC1B,2CAyJA;AAED,eAAO,MAAM,qBAAqB,kEAA6C,CAAC"}
@@ -11,7 +11,6 @@ import { AutopilotChatMessageContent } from "./chat-message-content.js";
11
11
  import { AutopilotChatFRE } from "./first-run-experience/chat-fre.js";
12
12
  import { AutopilotChatLoading } from "./loader/chat-loading.js";
13
13
  import { AutopilotChatLoadingMessages } from "./loader/chat-loading-messages.js";
14
- import { stripResourceTokens } from "./markdown/parsers/resource-token-parser.js";
15
14
  import { AutopilotChatSuggestions } from "./suggestions/chat-suggestions.js";
16
15
  const MessageContainer = styled('div')(({ isOverflow, isContainerWide, gap })=>({
17
16
  display: 'flex',
@@ -90,7 +89,6 @@ function AutopilotChatMessagesComponent({ isOverflow, isContainerWide }) {
90
89
  const onCopy = react.useCallback(({ group, message })=>{
91
90
  let finalString = '';
92
91
  finalString = 0 === group.length ? message.toCopy ?? message.content : group.map((msg)=>msg.toCopy ?? msg.content).join('\n');
93
- finalString = stripResourceTokens(finalString);
94
92
  if (navigator.clipboard && finalString) navigator.clipboard.writeText(finalString).catch(()=>{});
95
93
  }, []);
96
94
  react.useEffect(()=>{
@@ -24,8 +24,7 @@ var __webpack_require__ = {};
24
24
  var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
- resourceTokenPlugin: ()=>resourceTokenPlugin,
28
- stripResourceTokens: ()=>stripResourceTokens
27
+ resourceTokenPlugin: ()=>resourceTokenPlugin
29
28
  });
30
29
  const external_unist_util_visit_namespaceObject = require("unist-util-visit");
31
30
  const RESOURCE_TOKEN_PATTERN = /\[\[resource-token:(.*?)\]\]/g;
@@ -55,12 +54,6 @@ const parseResourceData = (json)=>{
55
54
  return null;
56
55
  }
57
56
  };
58
- function stripResourceTokens(text) {
59
- return text.replace(RESOURCE_TOKEN_PATTERN, (match, json)=>{
60
- const resource = parseResourceData(json);
61
- return resource?.displayName ?? match;
62
- });
63
- }
64
57
  function resourceTokenPlugin() {
65
58
  return (tree)=>{
66
59
  (0, external_unist_util_visit_namespaceObject.visit)(tree, 'text', (node, _index, parent)=>{
@@ -88,10 +81,8 @@ function resourceTokenPlugin() {
88
81
  };
89
82
  }
90
83
  exports.resourceTokenPlugin = __webpack_exports__.resourceTokenPlugin;
91
- exports.stripResourceTokens = __webpack_exports__.stripResourceTokens;
92
84
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
93
- "resourceTokenPlugin",
94
- "stripResourceTokens"
85
+ "resourceTokenPlugin"
95
86
  ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
96
87
  Object.defineProperty(exports, '__esModule', {
97
88
  value: true
@@ -1,4 +1,3 @@
1
1
  import type { Root } from 'mdast';
2
- export declare function stripResourceTokens(text: string): string;
3
2
  export declare function resourceTokenPlugin(): (tree: Root) => void;
4
3
  //# sourceMappingURL=resource-token-parser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resource-token-parser.d.ts","sourceRoot":"","sources":["../../../../../../../../src/material/components/ap-chat/components/message/markdown/parsers/resource-token-parser.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAQ,MAAM,OAAO,CAAC;AA+DxC,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKxD;AAKD,wBAAgB,mBAAmB,KACzB,MAAM,IAAI,UA2CnB"}
1
+ {"version":3,"file":"resource-token-parser.d.ts","sourceRoot":"","sources":["../../../../../../../../src/material/components/ap-chat/components/message/markdown/parsers/resource-token-parser.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAQ,MAAM,OAAO,CAAC;AA+DxC,wBAAgB,mBAAmB,KACzB,MAAM,IAAI,UA2CnB"}
@@ -26,12 +26,6 @@ const parseResourceData = (json)=>{
26
26
  return null;
27
27
  }
28
28
  };
29
- function stripResourceTokens(text) {
30
- return text.replace(RESOURCE_TOKEN_PATTERN, (match, json)=>{
31
- const resource = parseResourceData(json);
32
- return resource?.displayName ?? match;
33
- });
34
- }
35
29
  function resourceTokenPlugin() {
36
30
  return (tree)=>{
37
31
  visit(tree, 'text', (node, _index, parent)=>{
@@ -58,4 +52,4 @@ function resourceTokenPlugin() {
58
52
  });
59
53
  };
60
54
  }
61
- export { resourceTokenPlugin, stripResourceTokens };
55
+ export { resourceTokenPlugin };
@@ -50,20 +50,12 @@ function pickerReducer(state, action) {
50
50
  anchorPosition: action.coords
51
51
  };
52
52
  case 'CLOSE':
53
+ return initialPickerState;
54
+ case 'SET_QUERY':
53
55
  return {
54
56
  ...state,
55
- anchorPosition: null
57
+ query: action.query
56
58
  };
57
- case 'SET_QUERY':
58
- {
59
- const newTrimmed = action.query.trim();
60
- if (action.query === state.query || newTrimmed === state.query.trim()) return state;
61
- return {
62
- ...state,
63
- query: action.query,
64
- searchInProgress: !!newTrimmed
65
- };
66
- }
67
59
  case 'LOAD_START':
68
60
  return {
69
61
  ...state,
@@ -143,8 +135,7 @@ function pickerReducer(state, action) {
143
135
  return {
144
136
  ...state,
145
137
  searchResults: [],
146
- searchDone: true,
147
- searchInProgress: false
138
+ searchDone: true
148
139
  };
149
140
  default:
150
141
  return state;