@carbon/ai-chat-components 1.9.0-rc.0 → 1.9.0-rc.2
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/custom-elements.json +6784 -6387
- package/es/components/file-uploads/src/file-upload-item.js +1 -1
- package/es/components/file-uploads/src/file-upload-item.js.map +1 -1
- package/es/components/markdown/src/markdown-renderer-types.d.ts +10 -6
- package/es/components/markdown/src/markdown-renderer.js +12 -5
- package/es/components/markdown/src/markdown-renderer.js.map +1 -1
- package/es/components/markdown/src/markdown.js +14 -0
- package/es/components/markdown/src/markdown.js.map +1 -1
- package/es/components/markdown/src/utils/plugin-fallback.js +7 -5
- package/es/components/markdown/src/utils/plugin-fallback.js.map +1 -1
- package/es/components/markdown/src/utils/slot-names.d.ts +1 -0
- package/es/components/markdown/src/utils/slot-names.js +83 -0
- package/es/components/markdown/src/utils/slot-names.js.map +1 -0
- package/es/components/prompt-line/autocomplete/src/autocomplete.d.ts +23 -6
- package/es/components/prompt-line/autocomplete/src/autocomplete.js +82 -49
- package/es/components/prompt-line/autocomplete/src/autocomplete.js.map +1 -1
- package/es/components/prompt-line/autocomplete/src/autocomplete.scss.js +1 -1
- package/es/components/prompt-line/src/autocomplete-controller.d.ts +18 -2
- package/es/components/prompt-line/src/autocomplete-controller.js +65 -25
- package/es/components/prompt-line/src/autocomplete-controller.js.map +1 -1
- package/es/components/prompt-line/src/error-message.scss.js +1 -1
- package/es/components/prompt-line/src/prompt-line-constants.d.ts +10 -0
- package/es/components/prompt-line/src/prompt-line-constants.js +8 -1
- package/es/components/prompt-line/src/prompt-line-constants.js.map +1 -1
- package/es/components/prompt-line/src/prompt-line-controller.d.ts +15 -2
- package/es/components/prompt-line/src/prompt-line-controller.js +5 -2
- package/es/components/prompt-line/src/prompt-line-controller.js.map +1 -1
- package/es/components/prompt-line/src/prompt-line-rich-loader.js +5 -0
- package/es/components/prompt-line/src/prompt-line-rich-loader.js.map +1 -1
- package/es/components/prompt-line/src/prompt-line-rich-runtime.d.ts +2 -0
- package/es/components/prompt-line/src/prompt-line-rich-runtime.js +111 -15
- package/es/components/prompt-line/src/prompt-line-rich-runtime.js.map +1 -1
- package/es/components/prompt-line/src/prompt-line-shell.scss.js +1 -1
- package/es/components/prompt-line/src/prompt-line.d.ts +44 -7
- package/es/components/prompt-line/src/prompt-line.js +124 -31
- package/es/components/prompt-line/src/prompt-line.js.map +1 -1
- package/es/components/prompt-line/src/send-control.scss.js +1 -1
- package/es/components/prompt-line/src/tiptap/build-extensions.js +35 -5
- package/es/components/prompt-line/src/tiptap/build-extensions.js.map +1 -1
- package/es/components/prompt-line/src/tiptap/carbon-autocomplete.d.ts +5 -1
- package/es/components/prompt-line/src/tiptap/carbon-autocomplete.js +16 -7
- package/es/components/prompt-line/src/tiptap/carbon-autocomplete.js.map +1 -1
- package/es/components/prompt-line/src/tiptap/carbon-mention.js +3 -3
- package/es/components/prompt-line/src/tiptap/carbon-mention.js.map +1 -1
- package/es/components/prompt-line/src/tiptap/carbon-starter-trigger.d.ts +12 -1
- package/es/components/prompt-line/src/tiptap/carbon-starter-trigger.js +35 -4
- package/es/components/prompt-line/src/tiptap/carbon-starter-trigger.js.map +1 -1
- package/es/components/prompt-line/src/tiptap/editor-styles.js +1 -1
- package/es/components/prompt-line/src/tiptap/editor-styles.js.map +1 -1
- package/es/components/prompt-line/src/tiptap/extension-equivalence.d.ts +63 -0
- package/es/components/prompt-line/src/tiptap/extension-equivalence.js +80 -0
- package/es/components/prompt-line/src/tiptap/extension-equivalence.js.map +1 -0
- package/es/components/prompt-line/src/tiptap/index.d.ts +1 -4
- package/es/components/prompt-line/src/tiptap/index.js +1 -18
- package/es/components/prompt-line/src/tiptap/index.js.map +1 -1
- package/es/components/prompt-line/src/tiptap/json-utils.d.ts +8 -0
- package/es/components/prompt-line/src/tiptap/json-utils.js +11 -1
- package/es/components/prompt-line/src/tiptap/json-utils.js.map +1 -1
- package/es/components/prompt-line/src/tiptap/render-token-chip.js +3 -5
- package/es/components/prompt-line/src/tiptap/render-token-chip.js.map +1 -1
- package/es/components/prompt-line/src/tiptap/types.d.ts +27 -18
- package/es/components/toolbar/src/toolbar.js +7 -3
- package/es/components/toolbar/src/toolbar.js.map +1 -1
- package/es/react/hooks/useChatAutocomplete.d.ts +6 -1
- package/es/react/hooks/useChatAutocomplete.js +26 -8
- package/es/react/hooks/useChatAutocomplete.js.map +1 -1
- package/es/react/prompt-line.d.ts +3 -2
- package/es/react/prompt-line.js +3 -2
- package/es/react/prompt-line.js.map +1 -1
- package/es-custom/components/file-uploads/src/file-upload-item.js +1 -1
- package/es-custom/components/file-uploads/src/file-upload-item.js.map +1 -1
- package/es-custom/components/markdown/src/markdown-renderer-types.d.ts +10 -6
- package/es-custom/components/markdown/src/markdown-renderer.js +12 -5
- package/es-custom/components/markdown/src/markdown-renderer.js.map +1 -1
- package/es-custom/components/markdown/src/markdown.js +14 -0
- package/es-custom/components/markdown/src/markdown.js.map +1 -1
- package/es-custom/components/markdown/src/utils/plugin-fallback.js +7 -5
- package/es-custom/components/markdown/src/utils/plugin-fallback.js.map +1 -1
- package/es-custom/components/markdown/src/utils/slot-names.d.ts +1 -0
- package/es-custom/components/markdown/src/utils/slot-names.js +83 -0
- package/es-custom/components/markdown/src/utils/slot-names.js.map +1 -0
- package/es-custom/components/prompt-line/autocomplete/src/autocomplete.d.ts +23 -6
- package/es-custom/components/prompt-line/autocomplete/src/autocomplete.js +82 -49
- package/es-custom/components/prompt-line/autocomplete/src/autocomplete.js.map +1 -1
- package/es-custom/components/prompt-line/autocomplete/src/autocomplete.scss.js +1 -1
- package/es-custom/components/prompt-line/src/autocomplete-controller.d.ts +18 -2
- package/es-custom/components/prompt-line/src/autocomplete-controller.js +65 -25
- package/es-custom/components/prompt-line/src/autocomplete-controller.js.map +1 -1
- package/es-custom/components/prompt-line/src/error-message.scss.js +1 -1
- package/es-custom/components/prompt-line/src/prompt-line-constants.d.ts +10 -0
- package/es-custom/components/prompt-line/src/prompt-line-constants.js +8 -1
- package/es-custom/components/prompt-line/src/prompt-line-constants.js.map +1 -1
- package/es-custom/components/prompt-line/src/prompt-line-controller.d.ts +15 -2
- package/es-custom/components/prompt-line/src/prompt-line-controller.js +5 -2
- package/es-custom/components/prompt-line/src/prompt-line-controller.js.map +1 -1
- package/es-custom/components/prompt-line/src/prompt-line-rich-loader.js +5 -0
- package/es-custom/components/prompt-line/src/prompt-line-rich-loader.js.map +1 -1
- package/es-custom/components/prompt-line/src/prompt-line-rich-runtime.d.ts +2 -0
- package/es-custom/components/prompt-line/src/prompt-line-rich-runtime.js +111 -15
- package/es-custom/components/prompt-line/src/prompt-line-rich-runtime.js.map +1 -1
- package/es-custom/components/prompt-line/src/prompt-line-shell.scss.js +1 -1
- package/es-custom/components/prompt-line/src/prompt-line.d.ts +44 -7
- package/es-custom/components/prompt-line/src/prompt-line.js +124 -31
- package/es-custom/components/prompt-line/src/prompt-line.js.map +1 -1
- package/es-custom/components/prompt-line/src/send-control.scss.js +1 -1
- package/es-custom/components/prompt-line/src/tiptap/build-extensions.js +35 -5
- package/es-custom/components/prompt-line/src/tiptap/build-extensions.js.map +1 -1
- package/es-custom/components/prompt-line/src/tiptap/carbon-autocomplete.d.ts +5 -1
- package/es-custom/components/prompt-line/src/tiptap/carbon-autocomplete.js +16 -7
- package/es-custom/components/prompt-line/src/tiptap/carbon-autocomplete.js.map +1 -1
- package/es-custom/components/prompt-line/src/tiptap/carbon-mention.js +3 -3
- package/es-custom/components/prompt-line/src/tiptap/carbon-mention.js.map +1 -1
- package/es-custom/components/prompt-line/src/tiptap/carbon-starter-trigger.d.ts +12 -1
- package/es-custom/components/prompt-line/src/tiptap/carbon-starter-trigger.js +35 -4
- package/es-custom/components/prompt-line/src/tiptap/carbon-starter-trigger.js.map +1 -1
- package/es-custom/components/prompt-line/src/tiptap/editor-styles.js +1 -1
- package/es-custom/components/prompt-line/src/tiptap/editor-styles.js.map +1 -1
- package/es-custom/components/prompt-line/src/tiptap/extension-equivalence.d.ts +63 -0
- package/es-custom/components/prompt-line/src/tiptap/extension-equivalence.js +80 -0
- package/es-custom/components/prompt-line/src/tiptap/extension-equivalence.js.map +1 -0
- package/es-custom/components/prompt-line/src/tiptap/index.d.ts +1 -4
- package/es-custom/components/prompt-line/src/tiptap/index.js +1 -18
- package/es-custom/components/prompt-line/src/tiptap/index.js.map +1 -1
- package/es-custom/components/prompt-line/src/tiptap/json-utils.d.ts +8 -0
- package/es-custom/components/prompt-line/src/tiptap/json-utils.js +11 -1
- package/es-custom/components/prompt-line/src/tiptap/json-utils.js.map +1 -1
- package/es-custom/components/prompt-line/src/tiptap/render-token-chip.js +3 -5
- package/es-custom/components/prompt-line/src/tiptap/render-token-chip.js.map +1 -1
- package/es-custom/components/prompt-line/src/tiptap/types.d.ts +27 -18
- package/es-custom/components/toolbar/src/toolbar.js +7 -3
- package/es-custom/components/toolbar/src/toolbar.js.map +1 -1
- package/es-custom/react/hooks/useChatAutocomplete.d.ts +6 -1
- package/es-custom/react/hooks/useChatAutocomplete.js +26 -8
- package/es-custom/react/hooks/useChatAutocomplete.js.map +1 -1
- package/es-custom/react/prompt-line.d.ts +3 -2
- package/es-custom/react/prompt-line.js +3 -2
- package/es-custom/react/prompt-line.js.map +1 -1
- package/package.json +14 -24
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*
|
|
4
|
+
* Copyright IBM Corp. 2026
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Value-level equivalence for the extension list handed to
|
|
11
|
+
* `<cds-aichat-prompt-line>`, so a host config update that says the same thing
|
|
12
|
+
* does not recreate the live editor (which resets undo history).
|
|
13
|
+
*
|
|
14
|
+
* The built Tiptap instances cannot be compared directly: `carbonAutocomplete`
|
|
15
|
+
* and `carbonStarterTrigger` capture their config in closures, leaving
|
|
16
|
+
* `.options` empty (two different item lists would compare equal), while
|
|
17
|
+
* `carbonMention` / `carbonCommand` install fresh function identities on every
|
|
18
|
+
* `.configure()` (identical configs would compare unequal). So each factory
|
|
19
|
+
* output is tagged here with the source config it was built from, and
|
|
20
|
+
* equivalence compares those configs instead.
|
|
21
|
+
*
|
|
22
|
+
* Only the appended list is compared. The base bundle (schema, undo/redo,
|
|
23
|
+
* placeholder, keymap, value-sync, ...) is constructed inside the rich runtime
|
|
24
|
+
* and never reaches this module.
|
|
25
|
+
*/
|
|
26
|
+
import type { Extension } from '@tiptap/core';
|
|
27
|
+
import type { AutocompleteConfig, StartersConfig, TriggerSuggestionConfig } from './types.js';
|
|
28
|
+
/** Which carbon factory produced an extension. */
|
|
29
|
+
export type ExtensionSourceKind = 'mention' | 'command' | 'autocomplete' | 'starters';
|
|
30
|
+
/** The config an extension was built from, recorded at build time. */
|
|
31
|
+
export interface ExtensionSourceDescriptor {
|
|
32
|
+
kind: ExtensionSourceKind;
|
|
33
|
+
config: TriggerSuggestionConfig | AutocompleteConfig | StartersConfig | undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Record the source config on a built extension. Returns the same instance so
|
|
37
|
+
* factories can tag inline.
|
|
38
|
+
*/
|
|
39
|
+
export declare function tagExtensionSource<T>(extension: T, descriptor: ExtensionSourceDescriptor): T;
|
|
40
|
+
/** Read back a descriptor, or `undefined` for host-supplied extensions. */
|
|
41
|
+
export declare function getExtensionSource(extension: unknown): ExtensionSourceDescriptor | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Whether two extension lists install the same editor behavior.
|
|
44
|
+
*
|
|
45
|
+
* Compared positionally — extension order is ProseMirror plugin order, so a
|
|
46
|
+
* reordered list is a genuinely different editor and never reorder-matched.
|
|
47
|
+
*
|
|
48
|
+
* Per pair:
|
|
49
|
+
* - Same instance wins outright. This is the only rule available for
|
|
50
|
+
* host-supplied extensions, whose documented contract already asks hosts to
|
|
51
|
+
* memoize them.
|
|
52
|
+
* - Two carbon extensions of the same kind compare their source configs by
|
|
53
|
+
* value, with functions compared by reference (lodash `isEqual` semantics) —
|
|
54
|
+
* a host that rebuilds its callbacks each render genuinely gets a new editor,
|
|
55
|
+
* same as before.
|
|
56
|
+
* - Starter triggers are always equivalent: every difference they can carry
|
|
57
|
+
* (`items`, `isOn`) is applied to the live editor's storage instead. See
|
|
58
|
+
* `RichController.setExtensions`. `buildCarbonExtensions` installs the
|
|
59
|
+
* extension for an empty list too, so emptying `items` stays a storage write
|
|
60
|
+
* instead of a length change that rejects the pair before this rule is
|
|
61
|
+
* reached.
|
|
62
|
+
*/
|
|
63
|
+
export declare function areExtensionSetsEquivalent(previous: readonly Extension[], next: readonly Extension[]): boolean;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2025
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import isEqual from 'lodash-es/isEqual.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @license
|
|
12
|
+
*
|
|
13
|
+
* Copyright IBM Corp. 2026
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/
|
|
18
|
+
const EXTENSION_SOURCE = Symbol.for('cds-aichat.prompt-line.extension-source');
|
|
19
|
+
/**
|
|
20
|
+
* Record the source config on a built extension. Returns the same instance so
|
|
21
|
+
* factories can tag inline.
|
|
22
|
+
*/
|
|
23
|
+
function tagExtensionSource(extension, descriptor) {
|
|
24
|
+
extension[EXTENSION_SOURCE] = descriptor;
|
|
25
|
+
return extension;
|
|
26
|
+
}
|
|
27
|
+
/** Read back a descriptor, or `undefined` for host-supplied extensions. */
|
|
28
|
+
function getExtensionSource(extension) {
|
|
29
|
+
if (!extension || typeof extension !== 'object') {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return extension[EXTENSION_SOURCE];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether two extension lists install the same editor behavior.
|
|
36
|
+
*
|
|
37
|
+
* Compared positionally — extension order is ProseMirror plugin order, so a
|
|
38
|
+
* reordered list is a genuinely different editor and never reorder-matched.
|
|
39
|
+
*
|
|
40
|
+
* Per pair:
|
|
41
|
+
* - Same instance wins outright. This is the only rule available for
|
|
42
|
+
* host-supplied extensions, whose documented contract already asks hosts to
|
|
43
|
+
* memoize them.
|
|
44
|
+
* - Two carbon extensions of the same kind compare their source configs by
|
|
45
|
+
* value, with functions compared by reference (lodash `isEqual` semantics) —
|
|
46
|
+
* a host that rebuilds its callbacks each render genuinely gets a new editor,
|
|
47
|
+
* same as before.
|
|
48
|
+
* - Starter triggers are always equivalent: every difference they can carry
|
|
49
|
+
* (`items`, `isOn`) is applied to the live editor's storage instead. See
|
|
50
|
+
* `RichController.setExtensions`. `buildCarbonExtensions` installs the
|
|
51
|
+
* extension for an empty list too, so emptying `items` stays a storage write
|
|
52
|
+
* instead of a length change that rejects the pair before this rule is
|
|
53
|
+
* reached.
|
|
54
|
+
*/
|
|
55
|
+
function areExtensionSetsEquivalent(previous, next) {
|
|
56
|
+
if (previous === next) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
if (previous.length !== next.length) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return previous.every((prevExtension, index) => isExtensionEquivalent(prevExtension, next[index]));
|
|
63
|
+
}
|
|
64
|
+
function isExtensionEquivalent(previous, next) {
|
|
65
|
+
if (previous === next) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
const prevSource = getExtensionSource(previous);
|
|
69
|
+
const nextSource = getExtensionSource(next);
|
|
70
|
+
if (!prevSource || !nextSource || prevSource.kind !== nextSource.kind) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (prevSource.kind === 'starters') {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return isEqual(prevSource.config, nextSource.config);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { areExtensionSetsEquivalent, getExtensionSource, tagExtensionSource };
|
|
80
|
+
//# sourceMappingURL=extension-equivalence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-equivalence.js","sources":["../../../../../src/components/prompt-line/src/tiptap/extension-equivalence.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;AAOG;AAwCH,MAAM,gBAAgB,GAAkB,MAAM,CAAC,GAAG,CAChD,yCAAyC,CAC1C;AAED;;;AAGG;AACG,SAAU,kBAAkB,CAChC,SAAY,EACZ,UAAqC,EAAA;AAEpC,IAAA,SAAqC,CAAC,gBAAgB,CAAC,GAAG,UAAU;AACrE,IAAA,OAAO,SAAS;AAClB;AAEA;AACM,SAAU,kBAAkB,CAChC,SAAkB,EAAA;IAElB,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;AAC/C,QAAA,OAAO,SAAS;IAClB;AACA,IAAA,OAAQ,SAAqC,CAAC,gBAAgB,CACvB;AACzC;AAEA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,0BAA0B,CACxC,QAA8B,EAC9B,IAA0B,EAAA;AAE1B,IAAA,IAAI,QAAQ,KAAK,IAAI,EAAE;AACrB,QAAA,OAAO,IAAI;IACb;IACA,IAAI,QAAQ,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE;AACnC,QAAA,OAAO,KAAK;IACd;IACA,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,KAAK,KACzC,qBAAqB,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAClD;AACH;AAEA,SAAS,qBAAqB,CAAC,QAAmB,EAAE,IAAe,EAAA;AACjE,IAAA,IAAI,QAAQ,KAAK,IAAI,EAAE;AACrB,QAAA,OAAO,IAAI;IACb;AACA,IAAA,MAAM,UAAU,GAAG,kBAAkB,CAAC,QAAQ,CAAC;AAC/C,IAAA,MAAM,UAAU,GAAG,kBAAkB,CAAC,IAAI,CAAC;AAC3C,IAAA,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,EAAE;AACrE,QAAA,OAAO,KAAK;IACd;AACA,IAAA,IAAI,UAAU,CAAC,IAAI,KAAK,UAAU,EAAE;AAClC,QAAA,OAAO,IAAI;IACb;IACA,OAAO,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC;AACtD;;;;"}
|
|
@@ -35,8 +35,5 @@ export { PlainTextPaste } from './plain-text-paste.js';
|
|
|
35
35
|
export { Keymap } from './keymap.js';
|
|
36
36
|
export { default as Placeholder } from '@tiptap/extension-placeholder';
|
|
37
37
|
export { UndoRedo } from '@tiptap/extensions';
|
|
38
|
-
export
|
|
39
|
-
readonly depth: 100;
|
|
40
|
-
readonly newGroupDelay: 500;
|
|
41
|
-
};
|
|
38
|
+
export { HISTORY_DEFAULTS } from '../prompt-line-constants.js';
|
|
42
39
|
export type { StarterTriggerStorage } from './carbon-starter-trigger.js';
|
|
@@ -22,22 +22,5 @@ export { PlainTextPaste } from './plain-text-paste.js';
|
|
|
22
22
|
export { Keymap } from './keymap.js';
|
|
23
23
|
export { default as Placeholder } from '@tiptap/extension-placeholder';
|
|
24
24
|
export { UndoRedo } from '@tiptap/extensions';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @license
|
|
28
|
-
*
|
|
29
|
-
* Copyright IBM Corp. 2026
|
|
30
|
-
*
|
|
31
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
32
|
-
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/
|
|
34
|
-
/**
|
|
35
|
-
* Public barrel for the carbon Tiptap factories and helpers. Imported by the
|
|
36
|
-
* `<cds-aichat-prompt-line>` element and re-exported from
|
|
37
|
-
* [../../index.ts] so consumers can do
|
|
38
|
-
* `import { carbonMention, ... } from "@carbon/ai-chat-components"`.
|
|
39
|
-
*/
|
|
40
|
-
const HISTORY_DEFAULTS = { depth: 100, newGroupDelay: 500 };
|
|
41
|
-
|
|
42
|
-
export { HISTORY_DEFAULTS };
|
|
25
|
+
export { HISTORY_DEFAULTS } from '../prompt-line-constants.js';
|
|
43
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -59,3 +59,11 @@ export declare function projectRawValue(editor: Editor): string;
|
|
|
59
59
|
* prompt-line upgrades from textarea to Tiptap mode.
|
|
60
60
|
*/
|
|
61
61
|
export declare function textToDoc(text: string): JSONContent;
|
|
62
|
+
/**
|
|
63
|
+
* Map a plain-text offset into a ProseMirror position inside the doc
|
|
64
|
+
* {@link textToDoc} builds from the same text. Lives here because it encodes
|
|
65
|
+
* that function's shape: one paragraph per line, so a position costs +1 for the
|
|
66
|
+
* doc/first-paragraph start plus +1 for every newline before it, each of which
|
|
67
|
+
* opens another paragraph. Change `textToDoc` and this has to change with it.
|
|
68
|
+
*/
|
|
69
|
+
export declare function textOffsetToDocPos(text: string, offset: number): number;
|
|
@@ -153,6 +153,16 @@ function textToDoc(text) {
|
|
|
153
153
|
: { type: 'paragraph' }),
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Map a plain-text offset into a ProseMirror position inside the doc
|
|
158
|
+
* {@link textToDoc} builds from the same text. Lives here because it encodes
|
|
159
|
+
* that function's shape: one paragraph per line, so a position costs +1 for the
|
|
160
|
+
* doc/first-paragraph start plus +1 for every newline before it, each of which
|
|
161
|
+
* opens another paragraph. Change `textToDoc` and this has to change with it.
|
|
162
|
+
*/
|
|
163
|
+
function textOffsetToDocPos(text, offset) {
|
|
164
|
+
return offset + 1 + (text.slice(0, offset).split('\n').length - 1);
|
|
165
|
+
}
|
|
156
166
|
|
|
157
|
-
export { findNodesByType, getRawText, mapNodes, projectRawValue, removeNodesByType, textToDoc };
|
|
167
|
+
export { findNodesByType, getRawText, mapNodes, projectRawValue, removeNodesByType, textOffsetToDocPos, textToDoc };
|
|
158
168
|
//# sourceMappingURL=json-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-utils.js","sources":["../../../../../src/components/prompt-line/src/tiptap/json-utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAOG;AAYH;;;AAGG;SACa,iBAAiB,CAC/B,IAAiB,EACjB,GAAG,KAAe,EAAA;AAElB,IAAA,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC;AAC7B,IAAA,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;AAC9E;AAEA;;;;;;;AAOG;AACG,SAAU,QAAQ,CACtB,IAAiB,EACjB,EAA6C,EAAA;IAE7C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AAC7B,IAAA,OAAO,MAAM,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE;AACpE;AAEA,SAAS,IAAI,CACX,IAAiB,EACjB,EAA6C,EAAA;IAE7C,IAAI,IAAI,GAAgB,IAAI;AAC5B,IAAA,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QAC3C,MAAM,cAA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AI,IAAI,CAAC,OAAO,EAAE;AAChB,gBAAA,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE;oBAChC,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,cAAc,CAAC;gBAC5C;YACF;QACF;;AAEJ;AAEA;;;AAGG;AACG,SAAU,eAAe,CAAC,MAAc,EAAA;AAC5C,IAAA,OAAO,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;AACrC;AAEA;;;;;AAKG;AACG,SAAU,SAAS,CAAC,IAAY,EAAA;IACpC,OAAO;AACL,QAAA,IAAI,EAAE,KAAK;AACX,QAAA,OAAO,EAAE;aACN,KAAK,CAAC,IAAI;AACV,aAAA,GAAG,CAAC,CAAC,IAAI,KACR;AACE,cAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC9D,cAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAC1B;KACJ;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"json-utils.js","sources":["../../../../../src/components/prompt-line/src/tiptap/json-utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAOG;AAYH;;;AAGG;SACa,iBAAiB,CAC/B,IAAiB,EACjB,GAAG,KAAe,EAAA;AAElB,IAAA,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC;AAC7B,IAAA,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;AAC9E;AAEA;;;;;;;AAOG;AACG,SAAU,QAAQ,CACtB,IAAiB,EACjB,EAA6C,EAAA;IAE7C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AAC7B,IAAA,OA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
|
23
23
|
}
|
|
24
24
|
setVarsForSelector('.cds-aichat--token', { 'white-space': 'normal' });
|
|
25
25
|
setVarsForSelector('.cds-aichat--token[data-token-context="composer"]', {
|
|
26
|
-
color: 'var(--cds-tag-color-blue)',
|
|
26
|
+
color: 'var(--cds-tag-color-blue, #0043ce)',
|
|
27
27
|
});
|
|
28
|
-
setVarsForSelector('.cds-aichat--token[data-token-context="composer"]::selection', { 'background-color': 'var(--cds-tag-background-blue)' });
|
|
28
|
+
setVarsForSelector('.cds-aichat--token[data-token-context="composer"]::selection', { 'background-color': 'var(--cds-tag-background-blue, #d0e2ff)' });
|
|
29
29
|
setVarsForSelector('.cds-aichat--token[data-token-context="historical"]', {
|
|
30
|
-
color: 'var(--cds-link-secondary)',
|
|
30
|
+
color: 'var(--cds-link-secondary, #0043ce)',
|
|
31
31
|
});
|
|
32
32
|
tokenStyleRulesInstalled = true;
|
|
33
33
|
}
|
|
@@ -77,8 +77,6 @@ function createTokenContainer(attrs, type, context) {
|
|
|
77
77
|
dom.setAttribute('data-token-type', type);
|
|
78
78
|
dom.setAttribute('data-token-context', context);
|
|
79
79
|
dom.setAttribute('data-raw-value', value ?? label ?? '');
|
|
80
|
-
dom.setAttribute('role', 'img');
|
|
81
|
-
dom.setAttribute('aria-label', label || value || '');
|
|
82
80
|
dom.className = 'cds-aichat--token';
|
|
83
81
|
return dom;
|
|
84
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-token-chip.js","sources":["../../../../../src/components/prompt-line/src/tiptap/render-token-chip.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;AAAA;;;;;;;AAOG;AAiBH,IAAI,wBAAwB,GAAG,KAAK;AAEpC,SAAS,qBAAqB,GAAA;IAC5B,IAAI,wBAAwB,EAAE;QAC5B;IACF;IACA,kBAAkB,CAAC,oBAAoB,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC;IACrE,kBAAkB,CAAC,mDAAmD,EAAE;AACtE,QAAA,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"render-token-chip.js","sources":["../../../../../src/components/prompt-line/src/tiptap/render-token-chip.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;AAAA;;;;;;;AAOG;AAiBH,IAAI,wBAAwB,GAAG,KAAK;AAEpC,SAAS,qBAAqB,GAAA;IAC5B,IAAI,wBAAwB,EAAE;QAC5B;IACF;IACA,kBAAkB,CAAC,oBAAoB,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC;IACrE,kBAAkB,CAAC,mDAAmD,EAAE;AACtE,QAAA,KAAK,EAAE,oCAAoC;AAC5C,KAAA,CAAC;IACF,kBAAkB,CAChB,8DAA8D,EAC9D,EAAE,kBAAkB,EAAE,yCAAyC,EAAE,CAClE;IACD,kBAAkB,CAAC,qDAAqD,EAAE;AACxE,QAAA,KAAK,EAAE,oCAAoC;AAC5C,KAAA,CAAC;IACF,wBAAwB,GAAG,IAAI;AACjC;AAmDM,SAAU,eAAe,CAAC,IAAyB,EAAA;AACvD,IAAA,MAAM,GAAG,GAAG,oBAAoB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC;AACrE,IAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,iBAAiB;IAE/C,IAAI,CAAC,QAAQ,EAAE;QACb,GAAG,CAAC,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC9C,QAAA,OAAO,GAAG;IACZ;AAEA,IAAA,MAAM,IAAI,GAAmB;QAC3B,EAAE,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE;QAC1D,KAAK,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE;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;AAC5C,IAAA,GAAG,CAAC,YAAY,CAAC,iBAAiB,EAAE,IAAI,CAAC;AACzC,IAAA,GAAG,CAAC,YAAY,CAAC,oBAAoB,EAAE,OAAO,CAAC;IAC/C,GAAG,CAAC,YAAY,CAAC,gBAAgB,EAAE,KAAK,IAAI,KAAK,IAAI,EAAE,CAAC;AACxD,IAAA,GAAG,CAAC,SAAS,GAAG,mBAAmB;AACnC,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,iBAAiB,CAAC,KAAqB,EAAA;IAC9C,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC;AAC3C,IAAA,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI;AAClE,IAAA,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI;AAClE,IAAA,MAAM,OAAO,GAAG,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,GAAG,KAAK,CAAC,OAAO,GAAG,EAAE;AACtE,IAAA,IAAI,CAAC,WAAW,GAAG,CAAA,EAAG,OAAO,CAAA,EAAG,KAAK,IAAI,KAAK,IAAI,EAAE,CAAA,CAAE;AACtD,IAAA,OAAO,IAAI;AACb;;;;"}
|
|
@@ -71,10 +71,18 @@ export interface CustomListProps {
|
|
|
71
71
|
items: SuggestionItem[];
|
|
72
72
|
/** Current query string (text after trigger). */
|
|
73
73
|
query: string;
|
|
74
|
-
/** Callback to invoke when user selects an item. */
|
|
75
|
-
onSelect: (item: SuggestionItem) => void;
|
|
76
74
|
/** Callback to invoke when list should be dismissed. */
|
|
77
75
|
onDismiss: () => void;
|
|
76
|
+
/**
|
|
77
|
+
* Callback to invoke when user sends an item directly to chat, bypassing
|
|
78
|
+
* the editor.
|
|
79
|
+
*/
|
|
80
|
+
onSend: (text: string) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Callback to invoke when user selects an item to insert into the editor
|
|
83
|
+
* without sending to chat.
|
|
84
|
+
*/
|
|
85
|
+
onSelect: (item: SuggestionItem) => void;
|
|
78
86
|
}
|
|
79
87
|
/**
|
|
80
88
|
* Fields shared by every suggestion config.
|
|
@@ -86,32 +94,33 @@ export interface BaseSuggestionConfig {
|
|
|
86
94
|
items: SuggestionItem[] | ((query: string) => Promise<SuggestionItem[]> | SuggestionItem[]);
|
|
87
95
|
/** Minimum query length before items() is called. Defaults to 0. */
|
|
88
96
|
minQueryLength?: number;
|
|
89
|
-
/** Debounce delay in ms for the async items function. Defaults to 200. */
|
|
90
|
-
debounceMs?: number;
|
|
91
97
|
/** Called after the user selects an item and insertion is complete. */
|
|
92
98
|
onSelect?: (item: SuggestionItem) => void;
|
|
93
99
|
/** Replace the built-in suggestion list UI. */
|
|
94
100
|
renderCustomList?: (props: CustomListProps) => HTMLElement | unknown;
|
|
101
|
+
/**
|
|
102
|
+
* When `true`, clicking a suggestion item fires `cds-aichat-autocomplete-select`
|
|
103
|
+
* and inserts the item into the editor rather than sending immediately.
|
|
104
|
+
* Defaults to `false`. This property is omitted in TriggerSuggestionConfig
|
|
105
|
+
* since mentions and commands should always insert into the editor.
|
|
106
|
+
*/
|
|
107
|
+
disableDirectSend?: boolean;
|
|
95
108
|
}
|
|
96
109
|
/**
|
|
97
110
|
* Trigger-character-driven suggestion config. Used by `carbonMention` and
|
|
98
111
|
* `carbonCommand` (the carbon factories distinguish them only by their
|
|
99
112
|
* default Tiptap node `name`).
|
|
113
|
+
*
|
|
114
|
+
* Mention and command items always insert a token chip into the editor.
|
|
115
|
+
* `disableDirectSend` is always `true` for these triggers and is therefore
|
|
116
|
+
* omitted so it cannot be set or overridden.
|
|
100
117
|
*/
|
|
101
|
-
export interface TriggerSuggestionConfig extends BaseSuggestionConfig {
|
|
118
|
+
export interface TriggerSuggestionConfig extends Omit<BaseSuggestionConfig, 'disableDirectSend'> {
|
|
102
119
|
/** Character that activates the suggestion (e.g. "@", "/"). */
|
|
103
120
|
trigger: string;
|
|
104
121
|
/** Whether the trigger must appear at the start of the input/line, or
|
|
105
122
|
* anywhere. Defaults to "anywhere". */
|
|
106
123
|
triggerPosition?: 'start' | 'anywhere';
|
|
107
|
-
/**
|
|
108
|
-
* Override the schema-node name. Threaded through `Mention.extend({ name })`
|
|
109
|
-
* inside the carbon factory to sidestep Tiptap's last-named-wins stacking
|
|
110
|
-
* caveat when multiple triggers coexist.
|
|
111
|
-
*
|
|
112
|
-
* Defaults: `"mention"` (carbonMention) / `"command"` (carbonCommand).
|
|
113
|
-
*/
|
|
114
|
-
name?: string;
|
|
115
124
|
/** Replace the visual element rendered inside the token chip. */
|
|
116
125
|
renderCustomToken?: (item: SuggestionItem) => HTMLElement | ReactNode;
|
|
117
126
|
/**
|
|
@@ -140,11 +149,11 @@ export interface TriggerSuggestionConfig extends BaseSuggestionConfig {
|
|
|
140
149
|
}
|
|
141
150
|
/**
|
|
142
151
|
* Live autocomplete config. Selection inserts plain text (no token chip).
|
|
152
|
+
*
|
|
153
|
+
* Note: only one autocomplete config per editor is supported, because Tiptap
|
|
154
|
+
* resolves extensions by name.
|
|
143
155
|
*/
|
|
144
|
-
export
|
|
145
|
-
/** Override the suggestion plugin key name. Defaults to `"autocomplete"`. */
|
|
146
|
-
name?: string;
|
|
147
|
-
}
|
|
156
|
+
export type AutocompleteConfig = BaseSuggestionConfig;
|
|
148
157
|
/**
|
|
149
158
|
* Configuration for starter prompts — shown when the editor is empty and
|
|
150
159
|
* focused. Extends {@link BaseSuggestionConfig} so consumers can supply a
|
|
@@ -153,7 +162,7 @@ export interface AutocompleteConfig extends BaseSuggestionConfig {
|
|
|
153
162
|
* `items` is required and must be a static array (starters are resolved once
|
|
154
163
|
* from storage, not re-queried per keystroke).
|
|
155
164
|
*/
|
|
156
|
-
export interface StartersConfig extends Pick<BaseSuggestionConfig, 'renderCustomList'> {
|
|
165
|
+
export interface StartersConfig extends Pick<BaseSuggestionConfig, 'renderCustomList' | 'disableDirectSend'> {
|
|
157
166
|
/** The starter prompts to display. */
|
|
158
167
|
items: SuggestionItem[];
|
|
159
168
|
/**
|
|
@@ -200,9 +200,13 @@ let CDSAIChatToolbar = CDSAIChatToolbar_1 = class CDSAIChatToolbar extends LitEl
|
|
|
200
200
|
OVERFLOW_MENU_SIZE.MEDIUM);
|
|
201
201
|
}
|
|
202
202
|
render() {
|
|
203
|
-
const { hiddenActions, visibleActions } = this.getActions();
|
|
204
|
-
const showOverflowMenu =
|
|
205
|
-
const
|
|
203
|
+
const { hiddenActions: rawHiddenActions, visibleActions: rawVisibleActions, } = this.getActions();
|
|
204
|
+
const showOverflowMenu = rawHiddenActions.length > 1;
|
|
205
|
+
const visibleActions = showOverflowMenu
|
|
206
|
+
? rawVisibleActions
|
|
207
|
+
: [...rawVisibleActions, ...rawHiddenActions];
|
|
208
|
+
const hiddenActions = showOverflowMenu ? rawHiddenActions : [];
|
|
209
|
+
const showInitialActions = rawVisibleActions.length === 0 && rawHiddenActions.length === 0;
|
|
206
210
|
return html `
|
|
207
211
|
<div data-rounded="top" class=${blockClass}>
|
|
208
212
|
<div data-fixed class="${blockClass}__start">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbar.js","sources":["../../../../src/components/toolbar/src/toolbar.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;;AAmBH,MAAM,UAAU,GAAG,CAAA,EAAG,MAAM,UAAU;AA6BtC;;;;;;;;;AASG;AAEH,IAAM,gBAAgB,GAAA,kBAAA,GAAtB,MAAM,gBAAiB,SAAQ,UAAU,CAAA;AAAzC,IAAA,WAAA,GAAA;;AACE;;AAEG;QACc,IAAA,CAAA,KAAK,GAAG,KAAK;;QAI9B,IAAA,CAAA,OAAO,GAAa,EAAE;;QAItB,IAAA,CAAA,QAAQ,GAAG,KAAK;QAsBR,IAAA,CAAA,cAAc,GAAG,CAAC;AAkHlB,QAA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|
|
10
10
|
import type PromptLineElement from '../../components/prompt-line/src/prompt-line.js';
|
|
11
|
-
import type { AutocompleteConfig, StartersConfig, TriggerChangeEventDetail, TriggerSuggestionConfig } from '../../components/prompt-line/src/tiptap/types.js';
|
|
11
|
+
import type { AutocompleteConfig, StartersConfig, SuggestionItem, TriggerChangeEventDetail, TriggerSuggestionConfig } from '../../components/prompt-line/src/tiptap/types.js';
|
|
12
12
|
export interface UseChatAutocompleteOptions {
|
|
13
13
|
mention?: TriggerSuggestionConfig;
|
|
14
14
|
command?: TriggerSuggestionConfig;
|
|
@@ -20,6 +20,11 @@ export interface UseChatAutocompleteOptions {
|
|
|
20
20
|
isSendDisabled?: boolean;
|
|
21
21
|
/** Fired after a starter is selected and inserted (used to trigger send). */
|
|
22
22
|
onStarterSelected?: (text: string) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Fired when an autocomplete suggestion item is selected.
|
|
25
|
+
* Called after the controller has already inserted the item.
|
|
26
|
+
*/
|
|
27
|
+
onSelectItem?: (item: SuggestionItem) => void;
|
|
23
28
|
/**
|
|
24
29
|
* Fired when the send button inside an autocomplete suggestion item is clicked.
|
|
25
30
|
*/
|
|
@@ -12,7 +12,7 @@ import CDSAIChatAutocomplete from '../autocomplete.js';
|
|
|
12
12
|
import { AutocompleteController } from '../../components/prompt-line/src/autocomplete-controller.js';
|
|
13
13
|
|
|
14
14
|
function useChatAutocomplete(options) {
|
|
15
|
-
const { mention, command, autocomplete, starters, promptLineRef, isSendDisabled, onStarterSelected, onSendItem, attached = true, maxHeight, } = options;
|
|
15
|
+
const { mention, command, autocomplete, starters, promptLineRef, isSendDisabled, onStarterSelected, onSelectItem, onSendItem, attached = true, maxHeight, } = options;
|
|
16
16
|
const [state, setState] = React.useState({
|
|
17
17
|
trigger: null,
|
|
18
18
|
items: [],
|
|
@@ -24,6 +24,8 @@ function useChatAutocomplete(options) {
|
|
|
24
24
|
// but reading them out of refs avoids re-instantiation churn.
|
|
25
25
|
const onStarterRef = React.useRef(onStarterSelected);
|
|
26
26
|
onStarterRef.current = onStarterSelected;
|
|
27
|
+
const onSelectItemRef = React.useRef(onSelectItem);
|
|
28
|
+
onSelectItemRef.current = onSelectItem;
|
|
27
29
|
const onSendItemRef = React.useRef(onSendItem);
|
|
28
30
|
onSendItemRef.current = onSendItem;
|
|
29
31
|
if (!controllerRef.current) {
|
|
@@ -65,13 +67,15 @@ function useChatAutocomplete(options) {
|
|
|
65
67
|
}, [promptLineRef]);
|
|
66
68
|
const handleSelect = React.useCallback((item) => {
|
|
67
69
|
controllerRef.current?.select(item);
|
|
70
|
+
onSelectItemRef.current?.(item);
|
|
68
71
|
}, []);
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
const isSendDisabledRef = React.useRef(isSendDisabled);
|
|
73
|
+
isSendDisabledRef.current = isSendDisabled;
|
|
74
|
+
const handleSend = React.useCallback((text) => {
|
|
75
|
+
if (!text || isSendDisabledRef.current) {
|
|
72
76
|
return;
|
|
73
77
|
}
|
|
74
|
-
controllerRef.current?.dismiss();
|
|
78
|
+
controllerRef.current?.dismiss(true);
|
|
75
79
|
onSendItemRef.current?.(text);
|
|
76
80
|
}, []);
|
|
77
81
|
const dismiss = React.useCallback(() => {
|
|
@@ -106,8 +110,9 @@ function useChatAutocomplete(options) {
|
|
|
106
110
|
const result = state.renderCustomList({
|
|
107
111
|
items: state.items,
|
|
108
112
|
query: state.trigger.query,
|
|
109
|
-
onSelect: handleSelect,
|
|
110
113
|
onDismiss: dismiss,
|
|
114
|
+
onSelect: handleSelect,
|
|
115
|
+
onSend: handleSend,
|
|
111
116
|
});
|
|
112
117
|
if (result == null) {
|
|
113
118
|
return null;
|
|
@@ -117,7 +122,7 @@ function useChatAutocomplete(options) {
|
|
|
117
122
|
}
|
|
118
123
|
return (jsx(CustomReactNodePortal, { slot: "autocomplete-content", node: result, onMount: setListElement, onMousedown: (e) => e.preventDefault() }));
|
|
119
124
|
}
|
|
120
|
-
return (jsx(CDSAIChatAutocomplete, { ref: setListElement, slot: "autocomplete-content", items: state.items, attached: attached, onSelect: (e) => handleSelect(e.detail.item), onSend:
|
|
125
|
+
return (jsx(CDSAIChatAutocomplete, { ref: setListElement, slot: "autocomplete-content", items: state.items, attached: attached, disableDirectSend: state.disableDirectSend, onDismiss: dismiss, onSelect: (e) => handleSelect(e.detail.item), onSend: (e) => handleSend(e.detail?.text) }));
|
|
121
126
|
}, [
|
|
122
127
|
state,
|
|
123
128
|
handleSelect,
|
|
@@ -182,7 +187,6 @@ function CustomReactNodePortal({ slot, node, onMount, onMousedown, }) {
|
|
|
182
187
|
}
|
|
183
188
|
chatWrapper.appendChild(hostEl);
|
|
184
189
|
setHostElement(hostEl);
|
|
185
|
-
onMount?.(hostEl);
|
|
186
190
|
return () => {
|
|
187
191
|
onMount?.(null);
|
|
188
192
|
if (onMousedown) {
|
|
@@ -197,6 +201,20 @@ function CustomReactNodePortal({ slot, node, onMount, onMousedown, }) {
|
|
|
197
201
|
// those updates in place.
|
|
198
202
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
199
203
|
}, []);
|
|
204
|
+
// After the portal content is committed into hostElement, hand the first
|
|
205
|
+
// child element to the controller. This is typically a custom element (e.g.
|
|
206
|
+
// <cds-aichat-autocomplete>) whose properties (anchorElement, keydown
|
|
207
|
+
// forwarding) only work on the element itself — not on the plain <div>
|
|
208
|
+
// wrapper that createPortal renders into. Custom elements are defined
|
|
209
|
+
// synchronously at module load, so by the time useEffect fires (post-paint)
|
|
210
|
+
// the element is fully upgraded and its properties are available.
|
|
211
|
+
React.useEffect(() => {
|
|
212
|
+
if (!hostElement) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const child = hostElement.firstElementChild;
|
|
216
|
+
onMount?.(child ?? hostElement);
|
|
217
|
+
}, [hostElement, onMount]);
|
|
200
218
|
return (jsx("div", { slot: slot, ref: containerRef, children: hostElement ? ReactDOM.createPortal(node, hostElement) : null }));
|
|
201
219
|
}
|
|
202
220
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChatAutocomplete.js","sources":["../../../src/react/hooks/useChatAutocomplete.tsx"],"sourcesContent":[null],"names":["_jsx","Autocomplete"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useChatAutocomplete.js","sources":["../../../src/react/hooks/useChatAutocomplete.tsx"],"sourcesContent":[null],"names":["_jsx","Autocomplete"],"mappings":";;;;;;;;;;;;;AA2EM,SAAU,mBAAmB,CACjC,OAAmC,EAAA;IAEnC,MAAM,EACJ,OAAO,EACP,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,QAAQ,GAAG,IAAI,EACf,SAAS,GACV,GAAG,OAAO;IAEX,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAA8B;AACpE,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,KAAK,EAAE,EAAE;AACV,KAAA,CAAC;;;IAIF,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAgC,IAAI,CAAC;;;IAGvE,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC;AACpD,IAAA,YAAY,CAAC,OAAO,GAAG,iBAAiB;IACxC,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC;AAClD,IAAA,eAAe,CAAC,OAAO,GAAG,YAAY;IACtC,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC;AAC9C,IAAA,aAAa,CAAC,OAAO,GAAG,UAAU;AAElC,IAAA,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;AAC1B,QAAA,aAAa,CAAC,OAAO,GAAG,IAAI,sBAAsB,CAAC;YACjD,OAAO;YACP,OAAO;YACP,YAAY;YACZ,QAAQ;YACR,cAAc;AACd,YAAA,iBAAiB,EAAE,CAAC,IAAI,KA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K;QACnB,IAAI,CAAC,WAAW,EAAE;YAChB;QACF;AACA,QAAA,MAAM,KAAK,GAAG,WAAW,CAAC,iBAAuC;AACjE,QAAA,OAAO,GAAG,KAAK,IAAI,WAAW,CAAC;AACjC,IAAA,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAE1B,IAAA,QACEA,GAAA,CAAA,KAAA,EAAA,EAAK,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAA,QAAA,EAC/B,WAAW,GAAG,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,IAAI,EAAA,CAC1D;AAEV;;;;"}
|
|
@@ -11,8 +11,9 @@ import React from 'react';
|
|
|
11
11
|
* React wrapper for `<cds-aichat-prompt-line>`. Mirrors the WC's prompt-line
|
|
12
12
|
* surface verbatim — no host-side prop transformation required. The element
|
|
13
13
|
* renders a Tiptap-free textarea by default and upgrades to the rich Tiptap
|
|
14
|
-
* editor in place when the `rich` prop is set
|
|
15
|
-
*
|
|
14
|
+
* editor in place when the `rich` prop is set, or `ensureEditor()` is called —
|
|
15
|
+
* `extensions` alone are staged, not a trigger. Chat-domain config layering
|
|
16
|
+
* happens one level up at the shell. Imperative
|
|
16
17
|
* methods are reachable via ref.
|
|
17
18
|
*
|
|
18
19
|
* Wrapped in `withWebComponentBridge` so testId / rich / extensions / content
|
package/es/react/prompt-line.js
CHANGED
|
@@ -22,8 +22,9 @@ import { withWebComponentBridge } from './utils/withWebComponentBridge.js';
|
|
|
22
22
|
* React wrapper for `<cds-aichat-prompt-line>`. Mirrors the WC's prompt-line
|
|
23
23
|
* surface verbatim — no host-side prop transformation required. The element
|
|
24
24
|
* renders a Tiptap-free textarea by default and upgrades to the rich Tiptap
|
|
25
|
-
* editor in place when the `rich` prop is set
|
|
26
|
-
*
|
|
25
|
+
* editor in place when the `rich` prop is set, or `ensureEditor()` is called —
|
|
26
|
+
* `extensions` alone are staged, not a trigger. Chat-domain config layering
|
|
27
|
+
* happens one level up at the shell. Imperative
|
|
27
28
|
* methods are reachable via ref.
|
|
28
29
|
*
|
|
29
30
|
* Wrapped in `withWebComponentBridge` so testId / rich / extensions / content
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-line.js","sources":["../../src/react/prompt-line.tsx"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;AAOG;AAQH
|
|
1
|
+
{"version":3,"file":"prompt-line.js","sources":["../../src/react/prompt-line.tsx"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;AAOG;AAQH;;;;;;;;;;;;;;AAcG;AACH,MAAM,UAAU,GAAG,sBAAsB,CACvC,eAAe,CAAC;AACd,IAAA,OAAO,EAAE,wBAAwB;AACjC,IAAA,YAAY,EAAE,iBAAiB;AAC/B,IAAA,KAAK,EAAE,KAAK;AACZ,IAAA,MAAM,EAAE;AACN,QAAA,QAAQ,EAAE,0BAA0B;AACpC,QAAA,OAAO,EAAE,yBAAyB;AAClC,QAAA,MAAM,EAAE,wBAAwB;AAChC,QAAA,QAAQ,EAAE,0BAA0B;AACpC,QAAA,SAAS,EAAE,2BAA2B;AACtC,QAAA,YAAY,EAAE,+BAA+B;AAC7C,QAAA,eAAe,EAAE,2BAA2B;AAC5C,QAAA,gBAAgB,EAAE,6BAA6B;AAChD,KAAA;AACF,CAAA,CAAC;;;;"}
|
|
@@ -260,7 +260,7 @@ let FileUploadItemElement = class FileUploadItemElement extends LitElement {
|
|
|
260
260
|
@click="${openVideo}">
|
|
261
261
|
<video
|
|
262
262
|
class="${prefix}-file-upload-item__preview"
|
|
263
|
-
src="${
|
|
263
|
+
src="${objectURL}"
|
|
264
264
|
width="36"
|
|
265
265
|
height="36"
|
|
266
266
|
preload="metadata"
|