@carbon/ai-chat-components 1.14.0 → 1.15.0-rc.0

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 (177) hide show
  1. package/custom-elements.json +8737 -8823
  2. package/es/components/audio-player/src/transcript.js +1 -1
  3. package/es/components/carousel/src/carousel.d.ts +1 -1
  4. package/es/components/carousel/src/carousel.js +1 -1
  5. package/es/components/carousel/src/carousel.js.map +1 -1
  6. package/es/components/chat-history/src/history-panel-item.d.ts +8 -0
  7. package/es/components/chat-history/src/history-panel-item.js +44 -1
  8. package/es/components/chat-history/src/history-panel-item.js.map +1 -1
  9. package/es/components/code-snippet/src/code-snippet.d.ts +4 -0
  10. package/es/components/code-snippet/src/code-snippet.js +12 -0
  11. package/es/components/code-snippet/src/code-snippet.js.map +1 -1
  12. package/es/components/feedback/src/feedback.js +1 -1
  13. package/es/components/file-uploads/src/file-upload-item.d.ts +16 -17
  14. package/es/components/file-uploads/src/file-upload-item.js +98 -58
  15. package/es/components/file-uploads/src/file-upload-item.js.map +1 -1
  16. package/es/components/file-uploads/src/file-upload-item.scss.js +1 -1
  17. package/es/components/file-uploads/src/file-uploads.d.ts +20 -0
  18. package/es/components/file-uploads/src/file-uploads.js +55 -1
  19. package/es/components/file-uploads/src/file-uploads.js.map +1 -1
  20. package/es/components/file-uploads/src/file-uploads.scss.js +1 -1
  21. package/es/components/markdown/index.js +1 -2
  22. package/es/components/markdown/index.js.map +1 -1
  23. package/es/components/markdown/src/inline-markdown.d.ts +2 -2
  24. package/es/components/markdown/src/inline-markdown.js +8 -2
  25. package/es/components/markdown/src/inline-markdown.js.map +1 -1
  26. package/es/components/markdown/src/inline-markdown.scss.js +2 -2
  27. package/es/components/markdown/src/markdown-renderer-types.d.ts +2 -0
  28. package/es/components/markdown/src/markdown-renderer.js +3 -1
  29. package/es/components/markdown/src/markdown-renderer.js.map +1 -1
  30. package/es/components/markdown/src/markdown.d.ts +4 -0
  31. package/es/components/markdown/src/markdown.js +14 -0
  32. package/es/components/markdown/src/markdown.js.map +1 -1
  33. package/es/components/markdown/src/utils/inline-run-projection.js +3 -17
  34. package/es/components/markdown/src/utils/inline-run-projection.js.map +1 -1
  35. package/es/components/message-item-shell/index.d.ts +11 -0
  36. package/es/components/message-item-shell/index.js +9 -0
  37. package/es/components/message-item-shell/index.js.map +1 -0
  38. package/es/components/message-item-shell/src/message-item-shell.d.ts +48 -0
  39. package/es/components/message-item-shell/src/message-item-shell.js +91 -0
  40. package/es/components/message-item-shell/src/message-item-shell.js.map +1 -0
  41. package/es/components/message-item-shell/src/message-item-shell.scss.js +13 -0
  42. package/es/components/message-item-shell/src/message-item-shell.scss.js.map +1 -0
  43. package/es/components/prompt-line/src/prompt-line-controller.d.ts +1 -1
  44. package/es/components/prompt-line/src/prompt-line-rich-runtime.js +19 -2
  45. package/es/components/prompt-line/src/prompt-line-rich-runtime.js.map +1 -1
  46. package/es/components/prompt-line/src/prompt-line-shell.scss.js +1 -1
  47. package/es/components/prompt-line/src/prompt-line-textarea-runtime.js +9 -4
  48. package/es/components/prompt-line/src/prompt-line-textarea-runtime.js.map +1 -1
  49. package/es/components/prompt-line/src/prompt-line.d.ts +17 -7
  50. package/es/components/prompt-line/src/prompt-line.js +39 -0
  51. package/es/components/prompt-line/src/prompt-line.js.map +1 -1
  52. package/es/components/prompt-line/src/prompt-line.scss.js +1 -1
  53. package/es/components/prompt-line/src/tiptap/chat-enter.d.ts +2 -2
  54. package/es/components/prompt-line/src/tiptap/chat-enter.js +2 -2
  55. package/es/components/prompt-line/src/tiptap/chat-enter.js.map +1 -1
  56. package/es/components/prompt-line/src/tiptap/editor-styles.js +1 -1
  57. package/es/components/prompt-line/src/tiptap/editor-styles.js.map +1 -1
  58. package/es/components/prompt-line/src/tiptap/types.d.ts +3 -4
  59. package/es/components/shared/root-styles.d.ts +30 -0
  60. package/es/components/shared/root-styles.js +72 -0
  61. package/es/components/shared/root-styles.js.map +1 -0
  62. package/es/components/toolbar/src/toolbar.d.ts +14 -4
  63. package/es/components/toolbar/src/toolbar.js +29 -6
  64. package/es/components/toolbar/src/toolbar.js.map +1 -1
  65. package/es/components/user-avatar/index.d.ts +10 -0
  66. package/es/components/user-avatar/index.js +9 -0
  67. package/es/components/user-avatar/index.js.map +1 -0
  68. package/es/components/user-avatar/src/user-avatar.d.ts +46 -0
  69. package/es/components/user-avatar/src/user-avatar.js +153 -0
  70. package/es/components/user-avatar/src/user-avatar.js.map +1 -0
  71. package/es/components/user-avatar/src/user-avatar.scss.js +13 -0
  72. package/es/components/user-avatar/src/user-avatar.scss.js.map +1 -0
  73. package/es/globals/utils/iconTransform.js +1 -0
  74. package/es/globals/utils/iconTransform.js.map +1 -1
  75. package/es/react/chat-header.js +4 -2
  76. package/es/react/chat-header.js.map +1 -1
  77. package/es/react/code-snippet.d.ts +4 -1
  78. package/es/react/code-snippet.js +3 -1
  79. package/es/react/code-snippet.js.map +1 -1
  80. package/es/react/message-item-shell.d.ts +3 -0
  81. package/es/react/message-item-shell.js +30 -0
  82. package/es/react/message-item-shell.js.map +1 -0
  83. package/es/react/toolbar.d.ts +1 -1
  84. package/es/react/toolbar.js +3 -1
  85. package/es/react/toolbar.js.map +1 -1
  86. package/es/react/user-avatar.d.ts +3 -0
  87. package/es/react/user-avatar.js +29 -0
  88. package/es/react/user-avatar.js.map +1 -0
  89. package/es-custom/components/audio-player/src/transcript.js +1 -1
  90. package/es-custom/components/carousel/src/carousel.d.ts +1 -1
  91. package/es-custom/components/carousel/src/carousel.js +1 -1
  92. package/es-custom/components/carousel/src/carousel.js.map +1 -1
  93. package/es-custom/components/chat-history/src/history-panel-item.d.ts +8 -0
  94. package/es-custom/components/chat-history/src/history-panel-item.js +44 -1
  95. package/es-custom/components/chat-history/src/history-panel-item.js.map +1 -1
  96. package/es-custom/components/code-snippet/src/code-snippet.d.ts +4 -0
  97. package/es-custom/components/code-snippet/src/code-snippet.js +12 -0
  98. package/es-custom/components/code-snippet/src/code-snippet.js.map +1 -1
  99. package/es-custom/components/feedback/src/feedback.js +1 -1
  100. package/es-custom/components/file-uploads/src/file-upload-item.d.ts +16 -17
  101. package/es-custom/components/file-uploads/src/file-upload-item.js +98 -58
  102. package/es-custom/components/file-uploads/src/file-upload-item.js.map +1 -1
  103. package/es-custom/components/file-uploads/src/file-upload-item.scss.js +1 -1
  104. package/es-custom/components/file-uploads/src/file-uploads.d.ts +20 -0
  105. package/es-custom/components/file-uploads/src/file-uploads.js +55 -1
  106. package/es-custom/components/file-uploads/src/file-uploads.js.map +1 -1
  107. package/es-custom/components/file-uploads/src/file-uploads.scss.js +1 -1
  108. package/es-custom/components/markdown/index.js +1 -2
  109. package/es-custom/components/markdown/index.js.map +1 -1
  110. package/es-custom/components/markdown/src/inline-markdown.d.ts +2 -2
  111. package/es-custom/components/markdown/src/inline-markdown.js +8 -2
  112. package/es-custom/components/markdown/src/inline-markdown.js.map +1 -1
  113. package/es-custom/components/markdown/src/inline-markdown.scss.js +2 -2
  114. package/es-custom/components/markdown/src/markdown-renderer-types.d.ts +2 -0
  115. package/es-custom/components/markdown/src/markdown-renderer.js +3 -1
  116. package/es-custom/components/markdown/src/markdown-renderer.js.map +1 -1
  117. package/es-custom/components/markdown/src/markdown.d.ts +4 -0
  118. package/es-custom/components/markdown/src/markdown.js +14 -0
  119. package/es-custom/components/markdown/src/markdown.js.map +1 -1
  120. package/es-custom/components/markdown/src/utils/inline-run-projection.js +3 -17
  121. package/es-custom/components/markdown/src/utils/inline-run-projection.js.map +1 -1
  122. package/es-custom/components/message-item-shell/index.d.ts +11 -0
  123. package/es-custom/components/message-item-shell/index.js +9 -0
  124. package/es-custom/components/message-item-shell/index.js.map +1 -0
  125. package/es-custom/components/message-item-shell/src/message-item-shell.d.ts +48 -0
  126. package/es-custom/components/message-item-shell/src/message-item-shell.js +91 -0
  127. package/es-custom/components/message-item-shell/src/message-item-shell.js.map +1 -0
  128. package/es-custom/components/message-item-shell/src/message-item-shell.scss.js +13 -0
  129. package/es-custom/components/message-item-shell/src/message-item-shell.scss.js.map +1 -0
  130. package/es-custom/components/prompt-line/src/prompt-line-controller.d.ts +1 -1
  131. package/es-custom/components/prompt-line/src/prompt-line-rich-runtime.js +19 -2
  132. package/es-custom/components/prompt-line/src/prompt-line-rich-runtime.js.map +1 -1
  133. package/es-custom/components/prompt-line/src/prompt-line-shell.scss.js +1 -1
  134. package/es-custom/components/prompt-line/src/prompt-line-textarea-runtime.js +9 -4
  135. package/es-custom/components/prompt-line/src/prompt-line-textarea-runtime.js.map +1 -1
  136. package/es-custom/components/prompt-line/src/prompt-line.d.ts +17 -7
  137. package/es-custom/components/prompt-line/src/prompt-line.js +39 -0
  138. package/es-custom/components/prompt-line/src/prompt-line.js.map +1 -1
  139. package/es-custom/components/prompt-line/src/prompt-line.scss.js +1 -1
  140. package/es-custom/components/prompt-line/src/tiptap/chat-enter.d.ts +2 -2
  141. package/es-custom/components/prompt-line/src/tiptap/chat-enter.js +2 -2
  142. package/es-custom/components/prompt-line/src/tiptap/chat-enter.js.map +1 -1
  143. package/es-custom/components/prompt-line/src/tiptap/editor-styles.js +1 -1
  144. package/es-custom/components/prompt-line/src/tiptap/editor-styles.js.map +1 -1
  145. package/es-custom/components/prompt-line/src/tiptap/types.d.ts +3 -4
  146. package/es-custom/components/shared/root-styles.d.ts +30 -0
  147. package/es-custom/components/shared/root-styles.js +72 -0
  148. package/es-custom/components/shared/root-styles.js.map +1 -0
  149. package/es-custom/components/toolbar/src/toolbar.d.ts +14 -4
  150. package/es-custom/components/toolbar/src/toolbar.js +29 -6
  151. package/es-custom/components/toolbar/src/toolbar.js.map +1 -1
  152. package/es-custom/components/user-avatar/index.d.ts +10 -0
  153. package/es-custom/components/user-avatar/index.js +9 -0
  154. package/es-custom/components/user-avatar/index.js.map +1 -0
  155. package/es-custom/components/user-avatar/src/user-avatar.d.ts +46 -0
  156. package/es-custom/components/user-avatar/src/user-avatar.js +153 -0
  157. package/es-custom/components/user-avatar/src/user-avatar.js.map +1 -0
  158. package/es-custom/components/user-avatar/src/user-avatar.scss.js +13 -0
  159. package/es-custom/components/user-avatar/src/user-avatar.scss.js.map +1 -0
  160. package/es-custom/globals/utils/iconTransform.js +1 -0
  161. package/es-custom/globals/utils/iconTransform.js.map +1 -1
  162. package/es-custom/react/chat-header.js +4 -2
  163. package/es-custom/react/chat-header.js.map +1 -1
  164. package/es-custom/react/code-snippet.d.ts +4 -1
  165. package/es-custom/react/code-snippet.js +3 -1
  166. package/es-custom/react/code-snippet.js.map +1 -1
  167. package/es-custom/react/message-item-shell.d.ts +3 -0
  168. package/es-custom/react/message-item-shell.js +30 -0
  169. package/es-custom/react/message-item-shell.js.map +1 -0
  170. package/es-custom/react/toolbar.d.ts +1 -1
  171. package/es-custom/react/toolbar.js +3 -1
  172. package/es-custom/react/toolbar.js.map +1 -1
  173. package/es-custom/react/user-avatar.d.ts +3 -0
  174. package/es-custom/react/user-avatar.js +29 -0
  175. package/es-custom/react/user-avatar.js.map +1 -0
  176. package/package.json +8 -6
  177. package/telemetry.yml +16 -0
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-line-textarea-runtime.js","sources":["../../../../src/components/prompt-line/src/prompt-line-textarea-runtime.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * Textarea runtime for `<cds-aichat-prompt-line>`'s default (non-rich) mode.\n * This module is **statically imported** by the prompt-line shell\n * ([./prompt-line.ts]), so it is always part of the initial bundle — but it\n * carries **no `@tiptap/*` runtime**. The only Tiptap symbols used here are\n * type imports erased at compile time.\n *\n * `TextareaController` implements {@link PromptLineController} backed by a\n * native `<textarea>`. It mirrors the typography and sizing of the Tiptap\n * editor exactly (auto-grow via a CSS grid mirror, Carbon `body-01` tokens,\n * the same `max-block-size` cap) so the textarea→editor swap triggered by\n * the rich-mode loader ([./prompt-line-rich-loader.ts]) is visually\n * imperceptible. State — plain text, caret position, and keyboard-focus\n * tracking — transfers losslessly to the rich controller because the textarea\n * is always the plain-text source of truth. The same `cds-aichat-prompt-*`\n * events are emitted, keeping the React wrapper and `Input` handlers\n * mode-agnostic.\n *\n * `Editor` / `JSONContent` are **type-only** imports here — erased at compile,\n * so this module carries no Tiptap runtime.\n */\n\nimport type { Editor, Extension, JSONContent } from '@tiptap/core';\n\nimport { IS_PHONE } from '../../../globals/utils/browser-utils.js';\nimport {\n adoptOnRoot,\n setVarsForSelector,\n} from '../../shared/dynamic-css-var-sheet.js';\nimport {\n PROMPT_LINE_MAX_BLOCK_SIZE,\n TYPING_TIMEOUT_MS,\n} from './prompt-line-constants.js';\nimport { MouseFocusController } from './prompt-line-mouse-focus.js';\nimport type {\n PromptLineController,\n PromptLineControllerInit,\n SetContentUpdater,\n} from './prompt-line-controller.js';\nimport { getRawText, textToDoc } from './tiptap/json-utils.js';\n\n// ---------------------------------------------------------------------------\n// Textarea styling (CSP-safe — installed on the shared dynamic stylesheet,\n// governed by `style-src` not `style-src-attr`, matching ./tiptap/editor-styles).\n// ---------------------------------------------------------------------------\n\nconst TA_GROW_CLASS = 'cds-aichat--input-textarea-grow';\nconst TA_FIELD_CLASS = 'cds-aichat--input-textarea';\nconst TA_MIRROR_CLASS = 'cds-aichat--input-textarea-mirror';\nconst TA_PHONE_CLASS = 'cds-aichat--input-textarea--phone';\n\nlet textareaRulesInstalled = false;\n\n// Typography intentionally mirrors `.cds-aichat--input-pm-content` in\n// ./tiptap/editor-styles.ts so the textarea and the Tiptap editor are pixel-\n// identical and the textarea→editor swap is imperceptible.\nfunction ensureTextareaStyleRules(): void {\n if (textareaRulesInstalled) {\n return;\n }\n // Auto-grow wrapper: textarea and mirror occupy the same grid cell; the\n // (content-bearing) mirror dictates the height, the textarea stretches to\n // fill it. No per-keystroke inline `style.height` (CSP-safe auto-grow).\n // Cap the box at the shared max and clip the (unbounded) mirror past it; the\n // field below scrolls within that cap.\n setVarsForSelector(`.${TA_GROW_CLASS}`, {\n display: 'grid',\n 'inline-size': '100%',\n 'max-block-size': PROMPT_LINE_MAX_BLOCK_SIZE,\n overflow: 'hidden',\n });\n setVarsForSelector(`.${TA_GROW_CLASS} > *`, {\n 'grid-area': '1 / 1 / 2 / 2',\n });\n // Shared typography + reset for both the field and the mirror.\n const shared: Record<string, string> = {\n margin: '0',\n padding: '0',\n border: 'none',\n 'white-space': 'pre-wrap',\n 'overflow-wrap': 'anywhere',\n 'font-family': 'inherit',\n 'font-size': 'var(--cds-body-01-font-size, 0.875rem)',\n 'font-weight': 'var(--cds-body-01-font-weight, 400)',\n 'letter-spacing': 'var(--cds-body-01-letter-spacing, 0.16px)',\n 'line-height': 'var(--cds-body-01-line-height, 1.42857)',\n };\n setVarsForSelector(`.${TA_FIELD_CLASS}`, {\n ...shared,\n appearance: 'none',\n background: 'transparent',\n color: 'var(--cds-text-primary, #161616)',\n outline: 'none',\n resize: 'none',\n // The field is its own scroll container past the cap so the browser keeps\n // the caret in view natively (an ancestor scroller would not track it).\n 'overflow-x': 'hidden',\n 'overflow-y': 'auto',\n 'inline-size': '100%',\n 'min-block-size': '0',\n 'max-block-size': PROMPT_LINE_MAX_BLOCK_SIZE,\n });\n setVarsForSelector(`.${TA_FIELD_CLASS}::placeholder`, {\n color: 'var(--cds-text-secondary, #525252)',\n opacity: '1',\n });\n setVarsForSelector(`.${TA_MIRROR_CLASS}`, {\n ...shared,\n visibility: 'hidden',\n 'pointer-events': 'none',\n });\n setVarsForSelector(`.${TA_PHONE_CLASS}`, {\n 'font-size': 'var(--cds-body-02-font-size, 1rem)',\n 'font-weight': 'var(--cds-body-02-font-weight, 400)',\n 'letter-spacing': 'var(--cds-body-02-letter-spacing, 0)',\n 'line-height': 'var(--cds-body-02-line-height, 1.5)',\n });\n textareaRulesInstalled = true;\n}\n\n/**\n * `<textarea>`-backed controller. Tiptap-free; emits the same prompt events as\n * the rich editor. Auto-grows via a hidden mirror, capped at\n * `PROMPT_LINE_MAX_BLOCK_SIZE` with the field scrolling past it — the same cap\n * the rich contenteditable applies (see ./tiptap/editor-styles.ts), so the\n * textarea→rich swap is imperceptible.\n */\nexport class TextareaController\n extends MouseFocusController\n implements PromptLineController\n{\n private _wrap: HTMLDivElement | null = null;\n private _textarea: HTMLTextAreaElement | null = null;\n private _mirror: HTMLDivElement | null = null;\n private _host: HTMLElement | null = null;\n\n private _isTyping = false;\n private _typingTimer: ReturnType<typeof setTimeout> | null = null;\n\n mount(host: HTMLElement, init: PromptLineControllerInit): void {\n ensureTextareaStyleRules();\n const root = host.getRootNode();\n if (root instanceof ShadowRoot || root instanceof Document) {\n adoptOnRoot(root);\n }\n\n const wrap = document.createElement('div');\n wrap.className = TA_GROW_CLASS;\n\n const textarea = document.createElement('textarea');\n textarea.className = TA_FIELD_CLASS;\n textarea.classList.toggle(TA_PHONE_CLASS, IS_PHONE);\n textarea.setAttribute('rows', '1');\n textarea.setAttribute('name', 'message');\n textarea.setAttribute('spellcheck', 'true');\n textarea.setAttribute('tabindex', '0');\n textarea.placeholder = init.placeholder;\n textarea.value = init.value;\n textarea.readOnly = init.disabled;\n if (init.ariaLabel) {\n textarea.setAttribute('aria-label', init.ariaLabel);\n }\n if (init.testId) {\n textarea.setAttribute('data-testid', init.testId);\n }\n\n const mirror = document.createElement('div');\n mirror.className = TA_MIRROR_CLASS;\n mirror.classList.toggle(TA_PHONE_CLASS, IS_PHONE);\n mirror.setAttribute('aria-hidden', 'true');\n\n wrap.appendChild(textarea);\n wrap.appendChild(mirror);\n host.appendChild(wrap);\n\n this._wrap = wrap;\n this._textarea = textarea;\n this._mirror = mirror;\n this._host = host;\n\n textarea.addEventListener('input', this._onInput);\n textarea.addEventListener('keydown', this._onKeydown);\n textarea.addEventListener('focus', this._onFocus);\n textarea.addEventListener('blur', this._onBlur);\n\n // Pointer/touch before focus marks the next focus as mouse-driven so we\n // suppress the keyboard-focus outline.\n this._attachMouseFocusListeners(host);\n\n this._syncMirror();\n }\n\n destroy(): void {\n this._clearTypingTimer();\n const ta = this._textarea;\n if (ta) {\n ta.removeEventListener('input', this._onInput);\n ta.removeEventListener('keydown', this._onKeydown);\n ta.removeEventListener('focus', this._onFocus);\n ta.removeEventListener('blur', this._onBlur);\n }\n const host = this._host;\n if (host) {\n this._detachMouseFocusListeners(host);\n }\n this._wrap?.remove();\n this._wrap = null;\n this._textarea = null;\n this._mirror = null;\n }\n\n getValue(): string {\n return this._textarea?.value ?? '';\n }\n\n setContent(next: JSONContent | string | SetContentUpdater): void {\n if (typeof next === 'function') {\n const prev = textToDoc(this.getValue());\n this._setValue(getRawText((next as SetContentUpdater)(prev)), true);\n return;\n }\n this._setValue(typeof next === 'string' ? next : getRawText(next), true);\n }\n\n insertContent(\n content: JSONContent | string,\n opts: { at?: number } = {}\n ): void {\n const ta = this._textarea;\n if (!ta) {\n return;\n }\n const text = typeof content === 'string' ? content : getRawText(content);\n const value = ta.value;\n const at =\n typeof opts.at === 'number'\n ? Math.max(0, Math.min(opts.at, value.length))\n : (ta.selectionStart ?? value.length);\n const end = typeof opts.at === 'number' ? at : (ta.selectionEnd ?? at);\n const nextValue = value.slice(0, at) + text + value.slice(end);\n const caret = at + text.length;\n this._setValue(nextValue, true);\n ta.setSelectionRange(caret, caret);\n }\n\n clearContent(): void {\n this._setValue('', true);\n }\n\n getEditor(): Editor | null {\n return null;\n }\n\n focus(keyboardFocus: boolean): void {\n this._setNextFocusOrigin(keyboardFocus);\n this._textarea?.focus();\n }\n\n blur(): void {\n this._textarea?.blur();\n }\n\n hasFocus(): boolean {\n const ta = this._textarea;\n if (!ta) {\n return false;\n }\n const root = ta.getRootNode() as Document | ShadowRoot;\n return root.activeElement === ta;\n }\n\n getSelection(): { from: number; to: number } {\n const ta = this._textarea;\n if (!ta) {\n return { from: 0, to: 0 };\n }\n return { from: ta.selectionStart ?? 0, to: ta.selectionEnd ?? 0 };\n }\n\n setTextSelection(pos: number | { from: number; to: number }): void {\n const ta = this._textarea;\n if (!ta) {\n return;\n }\n const len = ta.value.length;\n if (typeof pos === 'number') {\n const p = Math.max(0, Math.min(pos, len));\n ta.setSelectionRange(p, p);\n return;\n }\n ta.setSelectionRange(\n Math.max(0, Math.min(pos.from, len)),\n Math.max(0, Math.min(pos.to, len))\n );\n }\n\n selectAll(): void {\n this._textarea?.select();\n }\n\n setEditable(editable: boolean): void {\n if (this._textarea) {\n this._textarea.readOnly = !editable;\n }\n }\n\n setPlaceholder(placeholder: string): void {\n if (this._textarea) {\n this._textarea.placeholder = placeholder;\n }\n }\n\n setAriaLabel(ariaLabel: string): void {\n const ta = this._textarea;\n if (!ta) {\n return;\n }\n if (ariaLabel) {\n ta.setAttribute('aria-label', ariaLabel);\n } else {\n ta.removeAttribute('aria-label');\n }\n }\n\n setTestId(testId: string): void {\n const ta = this._textarea;\n if (!ta) {\n return;\n }\n if (testId) {\n ta.setAttribute('data-testid', testId);\n } else {\n ta.removeAttribute('data-testid');\n }\n }\n\n setExtensions(_extensions: Extension[]): void {\n // Textarea mode has no Tiptap extensions; the shell upgrades to the rich\n // controller when host extensions appear.\n }\n\n setComposing(_composing: boolean): void {\n // Nothing to withhold: a `<textarea>` survives its own recreate, and the\n // element gates the upgrade on composition itself.\n }\n\n undo(): boolean {\n return false;\n }\n\n redo(): boolean {\n return false;\n }\n\n resetHistory(): void {\n // Plain textarea uses the browser's native undo stack.\n }\n\n // -------------------------------------------------------------------------\n // Internals\n // -------------------------------------------------------------------------\n\n private _onInput = (): void => {\n this._syncMirror();\n this._markTyping();\n this._emitChange();\n };\n\n // Enter-to-send mirrors the rich editor's base bundle (`Keymap` +\n // `carbonChatEnter`): plain Enter sends when non-empty, Mod-Enter sends,\n // Shift-Enter inserts a newline, and Enter on an empty field falls through to\n // the native newline (matching `carbonChatEnter`'s empty guard).\n private _onKeydown = (event: KeyboardEvent): void => {\n this._dispatch('cds-aichat-prompt-keydown', { originalEvent: event });\n // While an IME composition is active, Enter commits the candidate — let the\n // IME own it. ProseMirror suppresses its keymap the same way, so the rich\n // editor and the textarea agree. Without this, confirming a CJK candidate\n // would send the half-composed text.\n if (event.isComposing) {\n return;\n }\n if (event.key === 'Enter' && !event.shiftKey) {\n const isModEnter = event.metaKey || event.ctrlKey;\n if (isModEnter || this.getValue() !== '') {\n event.preventDefault();\n this._dispatch('cds-aichat-prompt-send-intent');\n }\n }\n };\n\n private _onFocus = (): void => {\n const wasMouseFocus = this._consumeMouseFocus();\n this._dispatch('cds-aichat-prompt-focus', { keyboard: !wasMouseFocus });\n };\n\n private _onBlur = (): void => {\n this._dispatch('cds-aichat-prompt-blur');\n };\n\n /** Programmatic value write: updates the field, mirror, and emits change. */\n private _setValue(text: string, emit: boolean): void {\n const ta = this._textarea;\n if (!ta) {\n return;\n }\n ta.value = text;\n this._syncMirror();\n if (emit) {\n this._emitChange();\n }\n }\n\n private _emitChange(): void {\n // Carry a plain-text doc as `content` so Redux / `getState().input.content`\n // stays consistent with the rich editor (which emits `editor.getJSON()`).\n const rawValue = this.getValue();\n this._dispatch('cds-aichat-prompt-change', {\n rawValue,\n content: textToDoc(rawValue),\n });\n }\n\n private _syncMirror(): void {\n if (this._mirror && this._textarea) {\n // Trailing newline so the box grows the instant a new line starts.\n this._mirror.textContent = `${this._textarea.value}\\n`;\n }\n }\n\n private _markTyping(): void {\n if (!this._isTyping) {\n this._isTyping = true;\n this._dispatch('cds-aichat-prompt-typing', { isTyping: true });\n }\n this._clearTypingTimer();\n this._typingTimer = setTimeout(() => {\n this._isTyping = false;\n this._dispatch('cds-aichat-prompt-typing', { isTyping: false });\n }, TYPING_TIMEOUT_MS);\n }\n\n private _clearTypingTimer(): void {\n if (this._typingTimer != null) {\n clearTimeout(this._typingTimer);\n this._typingTimer = null;\n }\n }\n\n private _dispatch(name: string, detail?: unknown): void {\n this._textarea?.dispatchEvent(\n new CustomEvent(name, {\n detail,\n bubbles: true,\n composed: true,\n })\n );\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;;;;;;;AAOG;AA2CH;AACA;AACA;AACA;AAEA,MAAM,aAAa,GA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CAAC,YAAY,GAAG,UAAU,CAAC,MAAK;AAClC,YAAA,IAAI,CAAC,SAAS,GAAG,KAAK;YACtB,IAAI,CAAC,SAAS,CAAC,0BAA0B,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QACjE,CAAC,EAAE,iBAAiB,CAAC;IACvB;IAEQ,iBAAiB,GAAA;AACvB,QAAA,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,EAAE;AAC7B,YAAA,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC;AAC/B,YAAA,IAAI,CAAC,YAAY,GAAG,IAAI;QAC1B;IACF;IAEQ,SAAS,CAAC,IAAY,EAAE,MAAgB,EAAA;QAC9C,IAAI,CAAC,SAAS,EAAE,aAAa,CAC3B,IAAI,WAAW,CAAC,IAAI,EAAE;YACpB,MAAM;AACN,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA,CAAC,CACH;IACH;AACD;;"}
1
+ {"version":3,"file":"prompt-line-textarea-runtime.js","sources":["../../../../src/components/prompt-line/src/prompt-line-textarea-runtime.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * Textarea runtime for `<cds-aichat-prompt-line>`'s default (non-rich) mode.\n * This module is **statically imported** by the prompt-line shell\n * ([./prompt-line.ts]), so it is always part of the initial bundle — but it\n * carries **no `@tiptap/*` runtime**. The only Tiptap symbols used here are\n * type imports erased at compile time.\n *\n * `TextareaController` implements {@link PromptLineController} backed by a\n * native `<textarea>`. It mirrors the typography and sizing of the Tiptap\n * editor exactly (auto-grow via a CSS grid mirror, Carbon `body-01` tokens,\n * the same `max-block-size` cap) so the textarea→editor swap triggered by\n * the rich-mode loader ([./prompt-line-rich-loader.ts]) is visually\n * imperceptible. State — plain text, caret position, and keyboard-focus\n * tracking — transfers losslessly to the rich controller because the textarea\n * is always the plain-text source of truth. The same `cds-aichat-prompt-*`\n * events are emitted, keeping the React wrapper and `Input` handlers\n * mode-agnostic.\n *\n * `Editor` / `JSONContent` are **type-only** imports here — erased at compile,\n * so this module carries no Tiptap runtime.\n */\n\nimport type { Editor, Extension, JSONContent } from '@tiptap/core';\n\nimport { IS_PHONE } from '../../../globals/utils/browser-utils.js';\nimport {\n adoptOnRoot,\n setVarsForSelector,\n} from '../../shared/dynamic-css-var-sheet.js';\nimport {\n PROMPT_LINE_MAX_BLOCK_SIZE,\n TYPING_TIMEOUT_MS,\n} from './prompt-line-constants.js';\nimport { MouseFocusController } from './prompt-line-mouse-focus.js';\nimport type {\n PromptLineController,\n PromptLineControllerInit,\n SetContentUpdater,\n} from './prompt-line-controller.js';\nimport { getRawText, textToDoc } from './tiptap/json-utils.js';\n\n// ---------------------------------------------------------------------------\n// Textarea styling (CSP-safe — installed on the shared dynamic stylesheet,\n// governed by `style-src` not `style-src-attr`, matching ./tiptap/editor-styles).\n// ---------------------------------------------------------------------------\n\nconst TA_GROW_CLASS = 'cds-aichat--input-textarea-grow';\nconst TA_FIELD_CLASS = 'cds-aichat--input-textarea';\nconst TA_MIRROR_CLASS = 'cds-aichat--input-textarea-mirror';\nconst TA_PHONE_CLASS = 'cds-aichat--input-textarea--phone';\n\nlet textareaRulesInstalled = false;\n\n// Typography intentionally mirrors `.cds-aichat--input-pm-content` in\n// ./tiptap/editor-styles.ts so the textarea and the Tiptap editor are pixel-\n// identical and the textarea→editor swap is imperceptible.\nfunction ensureTextareaStyleRules(): void {\n if (textareaRulesInstalled) {\n return;\n }\n // Auto-grow wrapper: textarea and mirror occupy the same grid cell; the\n // (content-bearing) mirror dictates the height, the textarea stretches to\n // fill it. No per-keystroke inline `style.height` (CSP-safe auto-grow).\n // Cap the box at the shared max and clip the (unbounded) mirror past it; the\n // field below scrolls within that cap.\n setVarsForSelector(`.${TA_GROW_CLASS}`, {\n display: 'grid',\n 'inline-size': '100%',\n 'max-block-size': PROMPT_LINE_MAX_BLOCK_SIZE,\n overflow: 'hidden',\n });\n setVarsForSelector(`.${TA_GROW_CLASS} > *`, {\n 'grid-area': '1 / 1 / 2 / 2',\n });\n // Shared typography + reset for both the field and the mirror.\n const shared: Record<string, string> = {\n margin: '0',\n padding: '0',\n border: 'none',\n 'white-space': 'pre-wrap',\n 'overflow-wrap': 'anywhere',\n 'font-family': 'inherit',\n 'font-size': 'var(--cds-body-01-font-size, 0.875rem)',\n 'font-weight': 'var(--cds-body-01-font-weight, 400)',\n 'letter-spacing': 'var(--cds-body-01-letter-spacing, 0.16px)',\n 'line-height': 'var(--cds-body-01-line-height, 1.42857)',\n };\n setVarsForSelector(`.${TA_FIELD_CLASS}`, {\n ...shared,\n appearance: 'none',\n background: 'transparent',\n color: 'var(--cds-text-primary, #161616)',\n outline: 'none',\n resize: 'none',\n // The field is its own scroll container past the cap so the browser keeps\n // the caret in view natively (an ancestor scroller would not track it).\n 'overflow-x': 'hidden',\n 'overflow-y': 'auto',\n 'inline-size': '100%',\n 'min-block-size': '0',\n 'max-block-size': PROMPT_LINE_MAX_BLOCK_SIZE,\n });\n setVarsForSelector(`.${TA_FIELD_CLASS}::placeholder`, {\n color: 'var(--cds-text-placeholder, var(--cds-text-secondary, #525252))',\n opacity: '1',\n });\n setVarsForSelector(`.${TA_MIRROR_CLASS}`, {\n ...shared,\n visibility: 'hidden',\n 'pointer-events': 'none',\n });\n setVarsForSelector(`.${TA_PHONE_CLASS}`, {\n 'font-size': 'var(--cds-body-02-font-size, 1rem)',\n 'font-weight': 'var(--cds-body-02-font-weight, 400)',\n 'letter-spacing': 'var(--cds-body-02-letter-spacing, 0)',\n 'line-height': 'var(--cds-body-02-line-height, 1.5)',\n });\n textareaRulesInstalled = true;\n}\n\n/**\n * `<textarea>`-backed controller. Tiptap-free; emits the same prompt events as\n * the rich editor. Auto-grows via a hidden mirror, capped at\n * `PROMPT_LINE_MAX_BLOCK_SIZE` with the field scrolling past it — the same cap\n * the rich contenteditable applies (see ./tiptap/editor-styles.ts), so the\n * textarea→rich swap is imperceptible.\n */\nexport class TextareaController\n extends MouseFocusController\n implements PromptLineController\n{\n private _wrap: HTMLDivElement | null = null;\n private _textarea: HTMLTextAreaElement | null = null;\n private _mirror: HTMLDivElement | null = null;\n private _host: HTMLElement | null = null;\n\n private _isTyping = false;\n private _typingTimer: ReturnType<typeof setTimeout> | null = null;\n\n mount(host: HTMLElement, init: PromptLineControllerInit): void {\n ensureTextareaStyleRules();\n const root = host.getRootNode();\n if (root instanceof ShadowRoot || root instanceof Document) {\n adoptOnRoot(root);\n }\n\n const wrap = document.createElement('div');\n wrap.className = TA_GROW_CLASS;\n\n const textarea = document.createElement('textarea');\n textarea.className = TA_FIELD_CLASS;\n textarea.classList.toggle(TA_PHONE_CLASS, IS_PHONE);\n textarea.setAttribute('rows', '1');\n textarea.setAttribute('name', 'message');\n textarea.setAttribute('spellcheck', 'true');\n textarea.setAttribute('tabindex', '0');\n textarea.placeholder = init.placeholder;\n textarea.value = init.value;\n textarea.disabled = init.disabled;\n if (init.ariaLabel) {\n textarea.setAttribute('aria-label', init.ariaLabel);\n }\n if (init.testId) {\n textarea.setAttribute('data-testid', init.testId);\n }\n\n const mirror = document.createElement('div');\n mirror.className = TA_MIRROR_CLASS;\n mirror.classList.toggle(TA_PHONE_CLASS, IS_PHONE);\n mirror.setAttribute('aria-hidden', 'true');\n\n wrap.appendChild(textarea);\n wrap.appendChild(mirror);\n host.appendChild(wrap);\n\n this._wrap = wrap;\n this._textarea = textarea;\n this._mirror = mirror;\n this._host = host;\n\n textarea.addEventListener('input', this._onInput);\n textarea.addEventListener('keydown', this._onKeydown);\n textarea.addEventListener('focus', this._onFocus);\n textarea.addEventListener('blur', this._onBlur);\n\n // Pointer/touch before focus marks the next focus as mouse-driven so we\n // suppress the keyboard-focus outline.\n this._attachMouseFocusListeners(host);\n\n this._syncMirror();\n }\n\n destroy(): void {\n this._clearTypingTimer();\n const ta = this._textarea;\n if (ta) {\n ta.removeEventListener('input', this._onInput);\n ta.removeEventListener('keydown', this._onKeydown);\n ta.removeEventListener('focus', this._onFocus);\n ta.removeEventListener('blur', this._onBlur);\n }\n const host = this._host;\n if (host) {\n this._detachMouseFocusListeners(host);\n }\n this._wrap?.remove();\n this._wrap = null;\n this._textarea = null;\n this._mirror = null;\n }\n\n getValue(): string {\n return this._textarea?.value ?? '';\n }\n\n setContent(next: JSONContent | string | SetContentUpdater): void {\n if (typeof next === 'function') {\n const prev = textToDoc(this.getValue());\n this._setValue(getRawText((next as SetContentUpdater)(prev)), true);\n return;\n }\n this._setValue(typeof next === 'string' ? next : getRawText(next), true);\n }\n\n insertContent(\n content: JSONContent | string,\n opts: { at?: number } = {}\n ): void {\n const ta = this._textarea;\n if (!ta) {\n return;\n }\n const text = typeof content === 'string' ? content : getRawText(content);\n const value = ta.value;\n const at =\n typeof opts.at === 'number'\n ? Math.max(0, Math.min(opts.at, value.length))\n : (ta.selectionStart ?? value.length);\n const end = typeof opts.at === 'number' ? at : (ta.selectionEnd ?? at);\n const nextValue = value.slice(0, at) + text + value.slice(end);\n const caret = at + text.length;\n this._setValue(nextValue, true);\n ta.setSelectionRange(caret, caret);\n }\n\n clearContent(): void {\n this._setValue('', true);\n }\n\n getEditor(): Editor | null {\n return null;\n }\n\n focus(keyboardFocus: boolean): void {\n this._setNextFocusOrigin(keyboardFocus);\n this._textarea?.focus();\n }\n\n blur(): void {\n this._textarea?.blur();\n }\n\n hasFocus(): boolean {\n const ta = this._textarea;\n if (!ta) {\n return false;\n }\n const root = ta.getRootNode() as Document | ShadowRoot;\n return root.activeElement === ta;\n }\n\n getSelection(): { from: number; to: number } {\n const ta = this._textarea;\n if (!ta) {\n return { from: 0, to: 0 };\n }\n return { from: ta.selectionStart ?? 0, to: ta.selectionEnd ?? 0 };\n }\n\n setTextSelection(pos: number | { from: number; to: number }): void {\n const ta = this._textarea;\n if (!ta) {\n return;\n }\n const len = ta.value.length;\n if (typeof pos === 'number') {\n const p = Math.max(0, Math.min(pos, len));\n ta.setSelectionRange(p, p);\n return;\n }\n ta.setSelectionRange(\n Math.max(0, Math.min(pos.from, len)),\n Math.max(0, Math.min(pos.to, len))\n );\n }\n\n selectAll(): void {\n this._textarea?.select();\n }\n\n setEditable(editable: boolean): void {\n const ta = this._textarea;\n if (!ta) {\n return;\n }\n if (!editable && this.hasFocus()) {\n ta.blur();\n }\n ta.disabled = !editable;\n }\n\n setPlaceholder(placeholder: string): void {\n if (this._textarea) {\n this._textarea.placeholder = placeholder;\n }\n }\n\n setAriaLabel(ariaLabel: string): void {\n const ta = this._textarea;\n if (!ta) {\n return;\n }\n if (ariaLabel) {\n ta.setAttribute('aria-label', ariaLabel);\n } else {\n ta.removeAttribute('aria-label');\n }\n }\n\n setTestId(testId: string): void {\n const ta = this._textarea;\n if (!ta) {\n return;\n }\n if (testId) {\n ta.setAttribute('data-testid', testId);\n } else {\n ta.removeAttribute('data-testid');\n }\n }\n\n setExtensions(_extensions: Extension[]): void {\n // Textarea mode has no Tiptap extensions; the shell upgrades to the rich\n // controller when host extensions appear.\n }\n\n setComposing(_composing: boolean): void {\n // Nothing to withhold: a `<textarea>` survives its own recreate, and the\n // element gates the upgrade on composition itself.\n }\n\n undo(): boolean {\n return false;\n }\n\n redo(): boolean {\n return false;\n }\n\n resetHistory(): void {\n // Plain textarea uses the browser's native undo stack.\n }\n\n // -------------------------------------------------------------------------\n // Internals\n // -------------------------------------------------------------------------\n\n private _onInput = (): void => {\n this._syncMirror();\n this._markTyping();\n this._emitChange();\n };\n\n // Enter-to-send mirrors the rich editor's base bundle (`Keymap` +\n // `carbonChatEnter`): plain Enter sends when non-empty, Mod-Enter sends,\n // Shift-Enter inserts a newline, and Enter on an empty field falls through to\n // the native newline (matching `carbonChatEnter`'s empty guard).\n private _onKeydown = (event: KeyboardEvent): void => {\n this._dispatch('cds-aichat-prompt-keydown', { originalEvent: event });\n // While an IME composition is active, Enter commits the candidate — let the\n // IME own it. ProseMirror suppresses its keymap the same way, so the rich\n // editor and the textarea agree. Without this, confirming a CJK candidate\n // would send the half-composed text.\n if (event.isComposing) {\n return;\n }\n if (event.key === 'Enter' && !event.shiftKey) {\n const isModEnter = event.metaKey || event.ctrlKey;\n if (isModEnter || this.getValue() !== '') {\n event.preventDefault();\n this._dispatch('cds-aichat-prompt-send-intent');\n }\n }\n };\n\n private _onFocus = (): void => {\n const wasMouseFocus = this._consumeMouseFocus();\n this._dispatch('cds-aichat-prompt-focus', { keyboard: !wasMouseFocus });\n };\n\n private _onBlur = (): void => {\n this._dispatch('cds-aichat-prompt-blur');\n };\n\n /** Programmatic value write: updates the field, mirror, and emits change. */\n private _setValue(text: string, emit: boolean): void {\n const ta = this._textarea;\n if (!ta) {\n return;\n }\n ta.value = text;\n this._syncMirror();\n if (emit) {\n this._emitChange();\n }\n }\n\n private _emitChange(): void {\n // Carry a plain-text doc as `content` so Redux / `getState().input.content`\n // stays consistent with the rich editor (which emits `editor.getJSON()`).\n const rawValue = this.getValue();\n this._dispatch('cds-aichat-prompt-change', {\n rawValue,\n content: textToDoc(rawValue),\n });\n }\n\n private _syncMirror(): void {\n if (this._mirror && this._textarea) {\n // Trailing newline so the box grows the instant a new line starts.\n this._mirror.textContent = `${this._textarea.value}\\n`;\n }\n }\n\n private _markTyping(): void {\n if (!this._isTyping) {\n this._isTyping = true;\n this._dispatch('cds-aichat-prompt-typing', { isTyping: true });\n }\n this._clearTypingTimer();\n this._typingTimer = setTimeout(() => {\n this._isTyping = false;\n this._dispatch('cds-aichat-prompt-typing', { isTyping: false });\n }, TYPING_TIMEOUT_MS);\n }\n\n private _clearTypingTimer(): void {\n if (this._typingTimer != null) {\n clearTimeout(this._typingTimer);\n this._typingTimer = null;\n }\n }\n\n private _dispatch(name: string, detail?: unknown): void {\n this._textarea?.dispatchEvent(\n new CustomEvent(name, {\n detail,\n bubbles: true,\n composed: true,\n })\n );\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;;;;;;;AAOG;AA2CH;AACA;AACA;AACA;AAEA,MAAM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,IAAI,CAAC,SAAS,CAAC,0BAA0B,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAChE;QACA,IAAI,CAAC,iBAAiB,EAAE;AACxB,QAAA,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,MAAK;AAClC,YAAA,IAAI,CAAC,SAAS,GAAG,KAAK;YACtB,IAAI,CAAC,SAAS,CAAC,0BAA0B,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QACjE,CAAC,EAAE,iBAAiB,CAAC;IACvB;IAEQ,iBAAiB,GAAA;AACvB,QAAA,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,EAAE;AAC7B,YAAA,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC;AAC/B,YAAA,IAAI,CAAC,YAAY,GAAG,IAAI;QAC1B;IACF;IAEQ,SAAS,CAAC,IAAY,EAAE,MAAgB,EAAA;QAC9C,IAAI,CAAC,SAAS,EAAE,aAAa,CAC3B,IAAI,WAAW,CAAC,IAAI,EAAE;YACpB,MAAM;AACN,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA,CAAC,CACH;IACH;AACD;;"}
@@ -6,6 +6,9 @@
6
6
  * This source code is licensed under the Apache-2.0 license found in the
7
7
  * LICENSE file in the root directory of this source tree.
8
8
  */
9
+ import type { Editor, Extension, JSONContent } from '@tiptap/core';
10
+ import { LitElement } from 'lit';
11
+ import type { SetContentUpdater } from './prompt-line-controller.js';
9
12
  /**
10
13
  * `<cds-aichat-prompt-line>` — the editing-surface layer of the chat input
11
14
  * stack.
@@ -20,10 +23,12 @@
20
23
  * for the rest of its life.
21
24
  *
22
25
  * Both modes expose the same imperative API (`getEditor`, `setContent`,
23
- * `insertContent`, …) and emit the same events, so the React wrapper and
24
- * `@carbon/ai-chat`'s `Input` are mode-agnostic. `getEditor()` returns `null`
25
- * in textarea mode (it's a probe — it never triggers a load); call
26
- * `ensureEditor()` to force the upgrade and resolve with the live editor.
26
+ * `insertContent`, …) and emit the same `cds-aichat-prompt-*` events, so the
27
+ * React wrapper and `@carbon/ai-chat`'s `Input` are mode-agnostic. Only rich
28
+ * mode fires `cds-aichat-trigger-change` and `cds-aichat-light-dom-portal`.
29
+ * `getEditor()` returns `null` in textarea mode (it's a probe — it never
30
+ * triggers a load); call `ensureEditor()` to force the upgrade and resolve
31
+ * with the live editor.
27
32
  *
28
33
  * The Carbon Tiptap bundle the rich editor installs — schema, value-sync,
29
34
  * typing-indicator, plain-text paste, keymap (`Mod-Enter`/`Enter` →
@@ -32,12 +37,17 @@
32
37
  * should compose their own element against `@tiptap/core` directly.
33
38
  *
34
39
  * @element cds-aichat-prompt-line
40
+ * @fires {CustomEvent<InputChangeEventDetail>} cds-aichat-prompt-change - Fired when the content changes.
41
+ * @fires {CustomEvent<{ keyboard: boolean }>} cds-aichat-prompt-focus - Fired when the editing surface gains focus. `keyboard` is false for mouse focus.
42
+ * @fires {CustomEvent} cds-aichat-prompt-blur - Fired when the editing surface loses focus.
43
+ * @fires {CustomEvent<TypingEventDetail>} cds-aichat-prompt-typing - Fired when the user starts or stops typing.
44
+ * @fires {CustomEvent<{ originalEvent: KeyboardEvent }>} cds-aichat-prompt-keydown - Fired for each key press in the editing surface.
45
+ * @fires {CustomEvent} cds-aichat-prompt-send-intent - Fired when the user presses Enter in a non-empty field, or Cmd+Enter (Ctrl+Enter on Windows and Linux) even when the field is empty.
46
+ * @fires {CustomEvent<TriggerChangeEventDetail>} cds-aichat-trigger-change - Fired when an autocomplete trigger such as `@` or `/` starts, changes, or ends. Rich mode only.
47
+ * @fires {CustomEvent<LightDomPortalEventDetail>} cds-aichat-light-dom-portal - Fired when a rich-editor node asks the host to render content in the light DOM. Rich mode only.
35
48
  *
36
49
  * @experimental
37
50
  */
38
- import type { Editor, Extension, JSONContent } from '@tiptap/core';
39
- import { LitElement } from 'lit';
40
- import type { SetContentUpdater } from './prompt-line-controller.js';
41
51
  declare class PromptLineElement extends LitElement {
42
52
  static styles: import("lit").CSSResult;
43
53
  /**
@@ -24,6 +24,45 @@ import styles from './prompt-line.scss.js';
24
24
  * This source code is licensed under the Apache-2.0 license found in the
25
25
  * LICENSE file in the root directory of this source tree.
26
26
  */
27
+ /**
28
+ * `<cds-aichat-prompt-line>` — the editing-surface layer of the chat input
29
+ * stack.
30
+ *
31
+ * It renders a lightweight `<textarea>` by default and **never statically
32
+ * imports `@tiptap/*`**, so chats that don't use advanced input features ship
33
+ * no Tiptap. When the `rich` property is set, or `ensureEditor()` is called,
34
+ * the element dynamically imports a Tiptap runtime and upgrades the surface in
35
+ * place — text, caret, and focus carry over because the textarea holds plain
36
+ * text. Host `extensions` alone do not trigger it; they are staged for whichever
37
+ * surface mounts. The upgrade is **sticky**: once rich, the element stays rich
38
+ * for the rest of its life.
39
+ *
40
+ * Both modes expose the same imperative API (`getEditor`, `setContent`,
41
+ * `insertContent`, …) and emit the same `cds-aichat-prompt-*` events, so the
42
+ * React wrapper and `@carbon/ai-chat`'s `Input` are mode-agnostic. Only rich
43
+ * mode fires `cds-aichat-trigger-change` and `cds-aichat-light-dom-portal`.
44
+ * `getEditor()` returns `null` in textarea mode (it's a probe — it never
45
+ * triggers a load); call `ensureEditor()` to force the upgrade and resolve
46
+ * with the live editor.
47
+ *
48
+ * The Carbon Tiptap bundle the rich editor installs — schema, value-sync,
49
+ * typing-indicator, plain-text paste, keymap (`Mod-Enter`/`Enter` →
50
+ * `cds-aichat-prompt-send-intent`), placeholder, undo/redo — lives in
51
+ * [./prompt-line-rich-runtime.ts]. Non-chat hosts wanting Tiptap inside Lit
52
+ * should compose their own element against `@tiptap/core` directly.
53
+ *
54
+ * @element cds-aichat-prompt-line
55
+ * @fires {CustomEvent<InputChangeEventDetail>} cds-aichat-prompt-change - Fired when the content changes.
56
+ * @fires {CustomEvent<{ keyboard: boolean }>} cds-aichat-prompt-focus - Fired when the editing surface gains focus. `keyboard` is false for mouse focus.
57
+ * @fires {CustomEvent} cds-aichat-prompt-blur - Fired when the editing surface loses focus.
58
+ * @fires {CustomEvent<TypingEventDetail>} cds-aichat-prompt-typing - Fired when the user starts or stops typing.
59
+ * @fires {CustomEvent<{ originalEvent: KeyboardEvent }>} cds-aichat-prompt-keydown - Fired for each key press in the editing surface.
60
+ * @fires {CustomEvent} cds-aichat-prompt-send-intent - Fired when the user presses Enter in a non-empty field, or Cmd+Enter (Ctrl+Enter on Windows and Linux) even when the field is empty.
61
+ * @fires {CustomEvent<TriggerChangeEventDetail>} cds-aichat-trigger-change - Fired when an autocomplete trigger such as `@` or `/` starts, changes, or ends. Rich mode only.
62
+ * @fires {CustomEvent<LightDomPortalEventDetail>} cds-aichat-light-dom-portal - Fired when a rich-editor node asks the host to render content in the light DOM. Rich mode only.
63
+ *
64
+ * @experimental
65
+ */
27
66
  let PromptLineElement = class PromptLineElement extends LitElement {
28
67
  constructor() {
29
68
  super(...arguments);
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-line.js","sources":["../../../../src/components/prompt-line/src/prompt-line.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * `<cds-aichat-prompt-line>` — the editing-surface layer of the chat input\n * stack.\n *\n * It renders a lightweight `<textarea>` by default and **never statically\n * imports `@tiptap/*`**, so chats that don't use advanced input features ship\n * no Tiptap. When the `rich` property is set, or `ensureEditor()` is called,\n * the element dynamically imports a Tiptap runtime and upgrades the surface in\n * place — text, caret, and focus carry over because the textarea holds plain\n * text. Host `extensions` alone do not trigger it; they are staged for whichever\n * surface mounts. The upgrade is **sticky**: once rich, the element stays rich\n * for the rest of its life.\n *\n * Both modes expose the same imperative API (`getEditor`, `setContent`,\n * `insertContent`, …) and emit the same events, so the React wrapper and\n * `@carbon/ai-chat`'s `Input` are mode-agnostic. `getEditor()` returns `null`\n * in textarea mode (it's a probe — it never triggers a load); call\n * `ensureEditor()` to force the upgrade and resolve with the live editor.\n *\n * The Carbon Tiptap bundle the rich editor installs — schema, value-sync,\n * typing-indicator, plain-text paste, keymap (`Mod-Enter`/`Enter` →\n * `cds-aichat-prompt-send-intent`), placeholder, undo/redo — lives in\n * [./prompt-line-rich-runtime.ts]. Non-chat hosts wanting Tiptap inside Lit\n * should compose their own element against `@tiptap/core` directly.\n *\n * @element cds-aichat-prompt-line\n *\n * @experimental\n */\n\nimport type { Editor, Extension, JSONContent } from '@tiptap/core';\nimport { css, html, LitElement, unsafeCSS } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { carbonElement } from '../../../globals/decorators/carbon-element.js';\nimport prefix from '../../../globals/settings.js';\nimport { adoptOnRoot } from '../../shared/dynamic-css-var-sheet.js';\nimport type {\n PromptLineController,\n PromptLineControllerInit,\n SetContentUpdater,\n} from './prompt-line-controller.js';\nimport { TextareaController } from './prompt-line-textarea-runtime.js';\nimport {\n getRichRuntimeIfLoaded,\n loadRichRuntime,\n} from './prompt-line-rich-loader.js';\nimport { getRawText, textOffsetToDocPos } from './tiptap/json-utils.js';\n\nimport styles from './prompt-line.scss?lit';\n\n@carbonElement(`${prefix}-prompt-line`)\nclass PromptLineElement extends LitElement {\n static styles = css`\n ${unsafeCSS(styles)}\n `;\n\n /**\n * Host-supplied Tiptap extensions, appended to the carbon bundle when the\n * rich editor mounts. These are *staged*, not a rich-mode trigger: setting\n * them while in textarea mode does not load Tiptap. Select rich explicitly\n * with `rich` or call `ensureEditor()`; the upgrade mounts with these\n * already installed.\n *\n * A new array is compared by value against the set last supplied, so a config\n * update that rebuilds an equivalent one leaves the live editor and its undo\n * history in place, writing any starter `items`/`isOn` through to storage.\n * Only a genuinely different set recreates the editor, preserving content,\n * selection, and focus but resetting history.\n * Extensions built by `buildCarbonExtensions` compare by their source\n * config; anything you supply directly compares by reference, so memoize\n * those (a fresh instance each render reads as a real change).\n */\n @property({ type: Array, attribute: false })\n extensions: Extension[] = [];\n\n /**\n * Initial / current content. Accepts Tiptap-native JSONContent or a plain\n * string. In textarea mode JSONContent is flattened to plain text.\n */\n @property({ type: Object, attribute: false })\n content?: JSONContent | string;\n\n /**\n * Selects the rich Tiptap editor. The element lazy-loads Tiptap and upgrades\n * the textarea in place; the upgrade is sticky (clearing `rich` later keeps\n * the editor). Defaults to the textarea.\n */\n @property({ type: Boolean, reflect: true })\n rich = false;\n\n /** Disables editing. The surface stays mounted but non-editable. */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /** Placeholder text shown when the surface is empty. */\n @property({ type: String })\n placeholder = '';\n\n /** Accessible label for the editing surface. */\n @property({ type: String, attribute: 'aria-label', reflect: true })\n override ariaLabel = 'Message';\n\n /** Test id, applied to the inner editable element. */\n @property({ type: String, attribute: 'test-id' })\n testId = '';\n\n /** Focus the surface on mount. */\n @property({ type: Boolean })\n override autofocus = false;\n\n private _controller: PromptLineController | null = null;\n private _mode: 'textarea' | 'rich' = 'textarea';\n private _editorHost: HTMLElement | null = null;\n private _lastExtensionsRef: Extension[] | null = null;\n /**\n * The `content` value the current surface was seeded with, and whether that\n * seed is still unconsumed. Both are needed: the value catches the echo, and\n * the latch releases after one `updated()` so a later change back to the same\n * value still lands. Comparing on the value alone suppressed it for the life\n * of the surface, dropping `a` in an `a` -> `b` -> `a` sequence.\n */\n private _seededContent?: JSONContent | string;\n private _seedPending = false;\n /** Pending deferred teardown, cancelled if the element is reattached. */\n private _pendingTeardownTimer: ReturnType<typeof setTimeout> | null = null;\n private _focusedWithKeyboard: boolean | null = null;\n /** Sticky latch — once rich is wanted it never reverts. */\n private _richLatched = false;\n private _upgrading = false;\n /**\n * The element owns the host's composition listeners for both layers — it\n * gates its own textarea→rich upgrade on this, and pushes the state to the\n * active controller via `setComposing` so rich mode can withhold a recreate.\n * One observer, so the two layers cannot disagree.\n */\n private _isComposing = false;\n private _pendingUpgrade = false;\n /**\n * Shared promise for in-flight `ensureEditor()` callers. Created lazily on the\n * first `ensureEditor()` call that needs an upgrade, settled once the rich\n * editor is mounted (`_swapToRich`) or the upgrade can't complete.\n */\n private _richReady: Promise<Editor> | null = null;\n private _resolveRichReady: ((editor: Editor) => void) | null = null;\n private _rejectRichReady: ((reason: Error) => void) | null = null;\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n override firstUpdated(): void {\n this._initializeSurface();\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this._pendingTeardownTimer !== null) {\n // Reattached before the deferred teardown ran — a move, not an unmount.\n // The controller and its editor host traveled with the element, so the\n // Tiptap instance (and its undo history) survives untouched.\n //\n // Unlike `_teardownSurface`, this deliberately leaves `_isComposing` /\n // `_pendingUpgrade` alone: the host div and its composition listeners are\n // still attached, so a later `compositionend` reaches them and releases\n // whatever was parked. Teardown has to reset eagerly only because it\n // discards the listeners that would otherwise do it.\n clearTimeout(this._pendingTeardownTimer);\n this._pendingTeardownTimer = null;\n const root = this._editorHost?.getRootNode();\n if (root instanceof ShadowRoot || root instanceof Document) {\n adoptOnRoot(root);\n }\n this._controller?.getEditor()?.view.updateRoot();\n const activeElement = this.ownerDocument.activeElement;\n if (\n this._focusedWithKeyboard !== null &&\n (!activeElement || activeElement === this.ownerDocument.body)\n ) {\n this._controller?.focus(this._focusedWithKeyboard, true);\n } else {\n this._focusedWithKeyboard = null;\n }\n if (this._richLatched && this._mode === 'textarea') {\n void this._requestRichUpgrade();\n }\n return;\n }\n // Reattached after a real teardown. `firstUpdated` is a one-shot, so\n // without this the element would come back permanently inert.\n if (this._isTornDown()) {\n this._initializeSurface();\n }\n }\n\n override updated(changed: Map<string | number | symbol, unknown>): void {\n if (!this._controller) {\n return;\n }\n if (\n (changed.has('rich') || changed.has('extensions')) &&\n this._wantsRich()\n ) {\n this._richLatched = true;\n if (this._mode === 'textarea') {\n void this._requestRichUpgrade();\n }\n }\n if (\n changed.has('extensions') &&\n this.extensions !== this._lastExtensionsRef\n ) {\n this._lastExtensionsRef = this.extensions;\n if (this._mode === 'rich') {\n this._controller.setExtensions(this.extensions);\n }\n }\n if (changed.has('disabled')) {\n this._controller.setEditable(!this.disabled);\n }\n // The seed echo is skipped once — re-applying it would emit a spurious\n // host-origin change event. Every later update lands, including one that\n // returns to the seed value, and including one alongside an extensions\n // change (which may no-op or recreate; either way the seed is the previous\n // doc).\n if (changed.has('content')) {\n const echoesSeed =\n this._seedPending && this.content === this._seededContent;\n this._seedPending = false;\n if (!echoesSeed) {\n this._controller.setContent(this.content ?? '');\n }\n }\n if (changed.has('placeholder')) {\n this._controller.setPlaceholder(this.placeholder);\n }\n if (changed.has('testId')) {\n this._controller.setTestId(this.testId);\n }\n if (changed.has('ariaLabel')) {\n this._controller.setAriaLabel(this.ariaLabel);\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n if (!this._controller || this._pendingTeardownTimer !== null) {\n return;\n }\n // Deferred by a task so a reparent — remove and re-append in the same\n // frame — keeps the live editor instead of destroying and rebuilding it.\n // A macrotask rather than a microtask because the reconnect can be\n // scheduled separately from the removal, and rather than a frame callback\n // because those never fire in a background tab, which would leak the\n // editor of a chat that really was unmounted.\n this._pendingTeardownTimer = setTimeout(() => {\n this._pendingTeardownTimer = null;\n this._teardownSurface();\n }, 0);\n }\n\n /** Destroy the editing surface. Deferred from `disconnectedCallback`. */\n private _teardownSurface(): void {\n this._focusedWithKeyboard = null;\n this._failRichReady(new Error('Input is not currently rendered'));\n this._controller?.destroy();\n this._controller = null;\n this._editorHost?.remove();\n this._editorHost = null;\n this._lastExtensionsRef = null;\n // Back to the default surface. `_richLatched` is the sticky flag, so a late\n // reconnect still comes back rich; leaving `_mode` on 'rich' with no\n // controller would just be a field outliving what it describes.\n this._mode = 'textarea';\n // The host div (and its composition listeners) is gone, so a composition\n // that was in flight can never fire its `compositionend`. Left set, these\n // would park the first upgrade after a reattach forever.\n this._isComposing = false;\n this._pendingUpgrade = false;\n }\n\n /** Mount the editing surface. Runs on first render and on a late reconnect. */\n private _initializeSurface(): void {\n // Guard against Lit running the pending first update on an element that was\n // appended and removed in a single task before the update flushed. Without\n // this check the editor mounts on a detached host with no disconnectedCallback\n // left to clean it up, because the callback already ran before the update.\n if (!this.isConnected) {\n return;\n }\n const host = this._mountEditorHost();\n this._lastExtensionsRef = this.extensions;\n this._seededContent = this.content;\n this._seedPending = true;\n this._richLatched = this._wantsRich();\n\n const warmRuntime = this._richLatched ? getRichRuntimeIfLoaded() : null;\n if (warmRuntime) {\n // Runtime already loaded (e.g. preloaded at boot) — mount rich directly,\n // no textarea flash.\n this._mode = 'rich';\n this._controller = warmRuntime.createRichController();\n this._controller.mount(host, this._makeInit());\n } else {\n this._mode = 'textarea';\n this._controller = new TextareaController();\n this._controller.mount(host, this._makeInit());\n if (this._richLatched) {\n void this._requestRichUpgrade();\n }\n }\n\n if (this.autofocus) {\n // Defer so consumer listeners are attached first.\n Promise.resolve().then(() => this._controller?.focus(false));\n }\n }\n\n override render() {\n return html`\n <div class=\"frame\">\n <slot name=\"editor\"></slot>\n </div>\n `;\n }\n\n // ---------------------------------------------------------------------------\n // Public methods (delegate to the active controller)\n // ---------------------------------------------------------------------------\n\n /** Returns the live Tiptap editor, or `null` in textarea mode. */\n getEditor(): Editor | null {\n return this._controller?.getEditor() ?? null;\n }\n\n /**\n * Lazily load Tiptap (if not already loaded), upgrade the textarea to the\n * rich editor in place, and resolve with the live editor. Resolves\n * immediately when already rich. Rejects when the surface isn't mounted or\n * the runtime can't load (SSR). Concurrent callers share one in-flight\n * upgrade.\n */\n ensureEditor(): Promise<Editor> {\n if (!this.isConnected || this._pendingTeardownTimer !== null) {\n return Promise.reject(new Error('Input is not currently rendered'));\n }\n if (this._mode === 'rich') {\n const editor = this._controller?.getEditor();\n if (editor) {\n return Promise.resolve(editor);\n }\n }\n // Connected but not yet rendered, or already torn down — nothing to upgrade.\n if (!this._editorHost || !this._controller) {\n return Promise.reject(new Error('Input is not currently rendered'));\n }\n this._richLatched = true;\n if (!this._richReady) {\n this._richReady = new Promise<Editor>((resolve, reject) => {\n this._resolveRichReady = resolve;\n this._rejectRichReady = reject;\n });\n }\n // Capture the promise before starting the upgrade: _requestRichUpgrade may\n // run synchronously (warm runtime path) and call _failRichReady, which\n // nulls this._richReady. Returning the captured reference keeps the\n // rejection visible to the caller.\n const promise = this._richReady;\n void this._requestRichUpgrade();\n return promise;\n }\n\n /**\n * Current plain-text value. Works in both modes (in rich mode this mirrors\n * `getEditor()?.getText()`), so callers don't need to branch on `getEditor()`\n * being `null`.\n */\n getValue(): string {\n return this._controller?.getValue() ?? '';\n }\n\n override focus(): void {\n this._controller?.focus(false);\n }\n\n override blur(): void {\n this._focusedWithKeyboard = null;\n this._controller?.blur();\n }\n\n /** Returns `true` if the editing surface currently holds focus. */\n hasFocus(): boolean {\n return this._controller?.hasFocus() ?? false;\n }\n\n clearContent(): void {\n this._controller?.clearContent();\n }\n\n setContent(next: JSONContent | string | SetContentUpdater): void {\n this._controller?.setContent(next);\n }\n\n insertContent(\n content: JSONContent | string,\n opts: { at?: number } = {}\n ): void {\n this._controller?.insertContent(content, opts);\n }\n\n setTextSelection(pos: number | { from: number; to: number }): void {\n this._controller?.setTextSelection(pos);\n }\n\n selectAll(): void {\n this._controller?.selectAll();\n }\n\n undo(): boolean {\n return this._controller?.undo() ?? false;\n }\n\n redo(): boolean {\n return this._controller?.redo() ?? false;\n }\n\n /**\n * Drops the editor's undo and redo history, keeping the live editor,\n * its focus, and its plugin state. Emits Tiptap's `transaction` event but\n * no `update`, value-change, typing, or token events. No-op in plain\n * textarea mode.\n */\n resetHistory(): void {\n this._controller?.resetHistory();\n }\n\n // ---------------------------------------------------------------------------\n // Internals\n // ---------------------------------------------------------------------------\n\n private _wantsRich(): boolean {\n return this._richLatched || this.rich;\n }\n\n /**\n * Rendered once and then torn down — the element is inert until something\n * re-runs the mount path. Distinct from \"not yet rendered\", where Lit's own\n * `firstUpdated` still has it.\n */\n private _isTornDown(): boolean {\n return this.hasUpdated && !this._controller;\n }\n\n private _mountEditorHost(): HTMLElement {\n const host = document.createElement('div');\n host.setAttribute('slot', 'editor');\n host.dataset.aichatEditorHost = '';\n this.appendChild(host);\n this._editorHost = host;\n\n // Defer an upgrade requested mid-IME-composition so we don't tear the\n // field out from under the user.\n host.addEventListener('compositionstart', this._onCompositionStart);\n host.addEventListener('compositionend', this._onCompositionEnd);\n host.addEventListener('cds-aichat-prompt-focus', (event) => {\n this._focusedWithKeyboard = (event as CustomEvent).detail.keyboard;\n });\n host.addEventListener('cds-aichat-prompt-blur', () => {\n // Chromium blurs a removed ancestor's descendants before disconnecting\n // them. Wait until the DOM move finishes before treating this as a blur.\n queueMicrotask(() => {\n if (this.isConnected && !this._controller?.hasFocus()) {\n this._focusedWithKeyboard = null;\n }\n });\n });\n\n const root = host.getRootNode();\n if (root instanceof ShadowRoot || root instanceof Document) {\n adoptOnRoot(root);\n }\n return host;\n }\n\n private _onCompositionStart = (): void => {\n this._isComposing = true;\n this._controller?.setComposing(true);\n };\n\n private _onCompositionEnd = (): void => {\n this._isComposing = false;\n this._controller?.setComposing(false);\n if (this._pendingUpgrade) {\n this._pendingUpgrade = false;\n void this._requestRichUpgrade();\n }\n };\n\n /** Build the controller init from current props (rich seed by default). */\n private _makeInit(valueOverride?: string): PromptLineControllerInit {\n const value =\n valueOverride ??\n (typeof this.content === 'string'\n ? this.content\n : this.content\n ? getRawText(this.content)\n : '');\n return {\n value,\n // On an upgrade we seed losslessly from the textarea's plain text, so\n // the structured `content` prop is only used for the initial mount.\n content: valueOverride === undefined ? this.content : undefined,\n placeholder: this.placeholder,\n disabled: this.disabled,\n ariaLabel: this.ariaLabel,\n testId: this.testId,\n extensions: this.extensions,\n };\n }\n\n /** Resolve any pending `ensureEditor()` callers with the live editor. */\n private _settleRichReady(): void {\n const editor = this._controller?.getEditor();\n if (editor && this._resolveRichReady) {\n this._resolveRichReady(editor);\n this._resolveRichReady = null;\n this._rejectRichReady = null;\n }\n }\n\n /**\n * Reject any pending `ensureEditor()` callers and clear the shared promise so\n * a later call can retry.\n */\n private _failRichReady(reason: Error): void {\n if (this._rejectRichReady) {\n this._rejectRichReady(reason);\n }\n this._resolveRichReady = null;\n this._rejectRichReady = null;\n this._richReady = null;\n }\n\n /**\n * Request a textarea→rich upgrade. The upgrade may be declined or deferred:\n * returns without upgrading when already rich, when a concurrent upgrade is\n * in flight, when a teardown is pending (element scheduled for removal), when\n * a composition is in flight, or when the runtime is unavailable (SSR).\n */\n private async _requestRichUpgrade(): Promise<void> {\n if (this._mode === 'rich' || this._upgrading) {\n return;\n }\n this._upgrading = true;\n try {\n const module = getRichRuntimeIfLoaded() ?? (await loadRichRuntime());\n // After the async import, re-check all bail conditions — any of them can\n // have changed while the runtime was loading:\n // - `_pendingTeardownTimer`: element disconnected during the import; the\n // teardown is scheduled but hasn't run yet, so _editorHost and\n // _controller are still set. Mounting here would build an editor that\n // is destroyed a macrotask later, and resolve any pending ensureEditor()\n // with a dead editor. Reject instead.\n // - `_editorHost` / `_controller` null: real teardown already ran.\n // - `module` null: SSR or runtime load failed.\n if (!module || !this._editorHost || !this._controller) {\n this._failRichReady(\n new Error(\n module\n ? 'Input is not currently rendered'\n : 'Input editor runtime is unavailable'\n )\n );\n return;\n }\n if (this._pendingTeardownTimer !== null) {\n // Teardown is deferred but imminent. Reject so callers get a clear\n // error rather than a live editor that disappears one task later.\n this._failRichReady(new Error('Input is not currently rendered'));\n return;\n }\n if (this._isComposing) {\n // Defer until composition ends; `_richReady` stays pending and settles\n // when `_onCompositionEnd` re-runs the upgrade.\n this._pendingUpgrade = true;\n return;\n }\n this._swapToRich(module.createRichController());\n } catch (error) {\n // A failed runtime load or mount must reject pending `ensureEditor()`\n // callers rather than leave them hanging.\n this._failRichReady(\n error instanceof Error ? error : new Error(String(error))\n );\n } finally {\n this._upgrading = false;\n }\n }\n\n private _swapToRich(rich: PromptLineController): void {\n const previous = this._controller;\n const host = this._editorHost;\n if (!previous || !host) {\n return;\n }\n const value = previous.getValue();\n const selection = previous.getSelection();\n const hadFocus = previous.hasFocus();\n const hadKeyboardFocus = previous.getKeyboardFocus();\n\n previous.destroy();\n this._controller = rich;\n this._mode = 'rich';\n // Seeded losslessly from the textarea's text, which already reflects\n // `content`, so an in-flight identical `content` update stays a no-op.\n this._seededContent = this.content;\n this._seedPending = true;\n rich.mount(host, this._makeInit(value));\n\n rich.setTextSelection({\n from: textOffsetToDocPos(value, selection.from),\n to: textOffsetToDocPos(value, selection.to),\n });\n if (hadFocus) {\n rich.focus(hadKeyboardFocus, true);\n }\n this._settleRichReady();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cds-aichat-prompt-line': PromptLineElement;\n }\n}\n\nexport default PromptLineElement;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AAsDH,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU,CAAA;AAA1C,IAAA,WAAA,GAAA;;AAKE;;;;;;;;;;;;;;;AAeG;QAEH,IAAA,CAAA,UAAU,GAAgB,EAAE;AAS5B;;;;AAIG;QAEH,IAAA,CAAA,IAAI,GAAG,KAAK;;QAIZ,IAAA,CAAA,QAAQ,GAAG,KAAK;;QAIhB,IAAA,CAAA,WAAW,GAAG,EAAE;;QAIP,IAAA,CAAA,SAAS,GAAG,SAAS;;QAI9B,IAAA,CAAA,MAAM,GAAG,EAAE;;QAIF,IAAA,CAAA,SAAS,GAAG,KAAK;QAElB,IAAA,CAAA,WAAW,GAAgC,IAAI;QAC/C,IAAA,CAAA,KAAK,GAAwB,UAAU;QACvC,IAAA,CAAA,WAAW,GAAuB,IAAI;QACtC,IAAA,CAAA,kBAAkB,GAAuB,IAAI;QAS7C,IAAA,CAAA,YAAY,GAAG,KAAK;;QAEpB,IAAA,CAAA,qBAAqB,GAAyC,IAAI;QAClE,IAAA,CAAA,oBAAoB,GAAmB,IAAI;;QAE3C,IAAA,CAAA,YAAY,GAAG,KAAK;QACpB,IAAA,CAAA,UAAU,GAAG,KAAK;AAC1B;;;;;AAKG;QACK,IAAA,CAAA,YAAY,GAAG,KAAK;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IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAC7B,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,MAAA,CAAA;AAIb,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AACzB,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAIjB,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;AACT,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAIR,UAAA,CAAA;AADR,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE;AACnC,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAI/B,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE;AACpC,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAIH,UAAA,CAAA;AADR,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;AACA,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAzDvB,iBAAiB,GAAA,UAAA,CAAA;AADtB,IAAA,aAAa,CAAC,CAAA,EAAG,MAAM,CAAA,YAAA,CAAc;AAChC,CAAA,EAAA,iBAAiB,CAgkBtB;AAQD,0BAAe,iBAAiB;;"}
1
+ {"version":3,"file":"prompt-line.js","sources":["../../../../src/components/prompt-line/src/prompt-line.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Editor, Extension, JSONContent } from '@tiptap/core';\nimport { css, html, LitElement, unsafeCSS } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { carbonElement } from '../../../globals/decorators/carbon-element.js';\nimport prefix from '../../../globals/settings.js';\nimport { adoptOnRoot } from '../../shared/dynamic-css-var-sheet.js';\nimport type {\n PromptLineController,\n PromptLineControllerInit,\n SetContentUpdater,\n} from './prompt-line-controller.js';\nimport { TextareaController } from './prompt-line-textarea-runtime.js';\nimport {\n getRichRuntimeIfLoaded,\n loadRichRuntime,\n} from './prompt-line-rich-loader.js';\nimport { getRawText, textOffsetToDocPos } from './tiptap/json-utils.js';\n\nimport styles from './prompt-line.scss?lit';\n\n/**\n * `<cds-aichat-prompt-line>` — the editing-surface layer of the chat input\n * stack.\n *\n * It renders a lightweight `<textarea>` by default and **never statically\n * imports `@tiptap/*`**, so chats that don't use advanced input features ship\n * no Tiptap. When the `rich` property is set, or `ensureEditor()` is called,\n * the element dynamically imports a Tiptap runtime and upgrades the surface in\n * place — text, caret, and focus carry over because the textarea holds plain\n * text. Host `extensions` alone do not trigger it; they are staged for whichever\n * surface mounts. The upgrade is **sticky**: once rich, the element stays rich\n * for the rest of its life.\n *\n * Both modes expose the same imperative API (`getEditor`, `setContent`,\n * `insertContent`, …) and emit the same `cds-aichat-prompt-*` events, so the\n * React wrapper and `@carbon/ai-chat`'s `Input` are mode-agnostic. Only rich\n * mode fires `cds-aichat-trigger-change` and `cds-aichat-light-dom-portal`.\n * `getEditor()` returns `null` in textarea mode (it's a probe — it never\n * triggers a load); call `ensureEditor()` to force the upgrade and resolve\n * with the live editor.\n *\n * The Carbon Tiptap bundle the rich editor installs — schema, value-sync,\n * typing-indicator, plain-text paste, keymap (`Mod-Enter`/`Enter` →\n * `cds-aichat-prompt-send-intent`), placeholder, undo/redo — lives in\n * [./prompt-line-rich-runtime.ts]. Non-chat hosts wanting Tiptap inside Lit\n * should compose their own element against `@tiptap/core` directly.\n *\n * @element cds-aichat-prompt-line\n * @fires {CustomEvent<InputChangeEventDetail>} cds-aichat-prompt-change - Fired when the content changes.\n * @fires {CustomEvent<{ keyboard: boolean }>} cds-aichat-prompt-focus - Fired when the editing surface gains focus. `keyboard` is false for mouse focus.\n * @fires {CustomEvent} cds-aichat-prompt-blur - Fired when the editing surface loses focus.\n * @fires {CustomEvent<TypingEventDetail>} cds-aichat-prompt-typing - Fired when the user starts or stops typing.\n * @fires {CustomEvent<{ originalEvent: KeyboardEvent }>} cds-aichat-prompt-keydown - Fired for each key press in the editing surface.\n * @fires {CustomEvent} cds-aichat-prompt-send-intent - Fired when the user presses Enter in a non-empty field, or Cmd+Enter (Ctrl+Enter on Windows and Linux) even when the field is empty.\n * @fires {CustomEvent<TriggerChangeEventDetail>} cds-aichat-trigger-change - Fired when an autocomplete trigger such as `@` or `/` starts, changes, or ends. Rich mode only.\n * @fires {CustomEvent<LightDomPortalEventDetail>} cds-aichat-light-dom-portal - Fired when a rich-editor node asks the host to render content in the light DOM. Rich mode only.\n *\n * @experimental\n */\n@carbonElement(`${prefix}-prompt-line`)\nclass PromptLineElement extends LitElement {\n static styles = css`\n ${unsafeCSS(styles)}\n `;\n\n /**\n * Host-supplied Tiptap extensions, appended to the carbon bundle when the\n * rich editor mounts. These are *staged*, not a rich-mode trigger: setting\n * them while in textarea mode does not load Tiptap. Select rich explicitly\n * with `rich` or call `ensureEditor()`; the upgrade mounts with these\n * already installed.\n *\n * A new array is compared by value against the set last supplied, so a config\n * update that rebuilds an equivalent one leaves the live editor and its undo\n * history in place, writing any starter `items`/`isOn` through to storage.\n * Only a genuinely different set recreates the editor, preserving content,\n * selection, and focus but resetting history.\n * Extensions built by `buildCarbonExtensions` compare by their source\n * config; anything you supply directly compares by reference, so memoize\n * those (a fresh instance each render reads as a real change).\n */\n @property({ type: Array, attribute: false })\n extensions: Extension[] = [];\n\n /**\n * Initial / current content. Accepts Tiptap-native JSONContent or a plain\n * string. In textarea mode JSONContent is flattened to plain text.\n */\n @property({ type: Object, attribute: false })\n content?: JSONContent | string;\n\n /**\n * Selects the rich Tiptap editor. The element lazy-loads Tiptap and upgrades\n * the textarea in place; the upgrade is sticky (clearing `rich` later keeps\n * the editor). Defaults to the textarea.\n */\n @property({ type: Boolean, reflect: true })\n rich = false;\n\n /** Disables editing. The surface stays mounted but non-editable. */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /** Placeholder text shown when the surface is empty. */\n @property({ type: String })\n placeholder = '';\n\n /** Accessible label for the editing surface. */\n @property({ type: String, attribute: 'aria-label', reflect: true })\n override ariaLabel = 'Message';\n\n /** Test id, applied to the inner editable element. */\n @property({ type: String, attribute: 'test-id' })\n testId = '';\n\n /** Focus the surface on mount. */\n @property({ type: Boolean })\n override autofocus = false;\n\n private _controller: PromptLineController | null = null;\n private _mode: 'textarea' | 'rich' = 'textarea';\n private _editorHost: HTMLElement | null = null;\n private _lastExtensionsRef: Extension[] | null = null;\n /**\n * The `content` value the current surface was seeded with, and whether that\n * seed is still unconsumed. Both are needed: the value catches the echo, and\n * the latch releases after one `updated()` so a later change back to the same\n * value still lands. Comparing on the value alone suppressed it for the life\n * of the surface, dropping `a` in an `a` -> `b` -> `a` sequence.\n */\n private _seededContent?: JSONContent | string;\n private _seedPending = false;\n /** Pending deferred teardown, cancelled if the element is reattached. */\n private _pendingTeardownTimer: ReturnType<typeof setTimeout> | null = null;\n private _focusedWithKeyboard: boolean | null = null;\n /** Sticky latch — once rich is wanted it never reverts. */\n private _richLatched = false;\n private _upgrading = false;\n /**\n * The element owns the host's composition listeners for both layers — it\n * gates its own textarea→rich upgrade on this, and pushes the state to the\n * active controller via `setComposing` so rich mode can withhold a recreate.\n * One observer, so the two layers cannot disagree.\n */\n private _isComposing = false;\n private _pendingUpgrade = false;\n /**\n * Shared promise for in-flight `ensureEditor()` callers. Created lazily on the\n * first `ensureEditor()` call that needs an upgrade, settled once the rich\n * editor is mounted (`_swapToRich`) or the upgrade can't complete.\n */\n private _richReady: Promise<Editor> | null = null;\n private _resolveRichReady: ((editor: Editor) => void) | null = null;\n private _rejectRichReady: ((reason: Error) => void) | null = null;\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n override firstUpdated(): void {\n this._initializeSurface();\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this._pendingTeardownTimer !== null) {\n // Reattached before the deferred teardown ran — a move, not an unmount.\n // The controller and its editor host traveled with the element, so the\n // Tiptap instance (and its undo history) survives untouched.\n //\n // Unlike `_teardownSurface`, this deliberately leaves `_isComposing` /\n // `_pendingUpgrade` alone: the host div and its composition listeners are\n // still attached, so a later `compositionend` reaches them and releases\n // whatever was parked. Teardown has to reset eagerly only because it\n // discards the listeners that would otherwise do it.\n clearTimeout(this._pendingTeardownTimer);\n this._pendingTeardownTimer = null;\n const root = this._editorHost?.getRootNode();\n if (root instanceof ShadowRoot || root instanceof Document) {\n adoptOnRoot(root);\n }\n this._controller?.getEditor()?.view.updateRoot();\n const activeElement = this.ownerDocument.activeElement;\n if (\n this._focusedWithKeyboard !== null &&\n (!activeElement || activeElement === this.ownerDocument.body)\n ) {\n this._controller?.focus(this._focusedWithKeyboard, true);\n } else {\n this._focusedWithKeyboard = null;\n }\n if (this._richLatched && this._mode === 'textarea') {\n void this._requestRichUpgrade();\n }\n return;\n }\n // Reattached after a real teardown. `firstUpdated` is a one-shot, so\n // without this the element would come back permanently inert.\n if (this._isTornDown()) {\n this._initializeSurface();\n }\n }\n\n override updated(changed: Map<string | number | symbol, unknown>): void {\n if (!this._controller) {\n return;\n }\n if (\n (changed.has('rich') || changed.has('extensions')) &&\n this._wantsRich()\n ) {\n this._richLatched = true;\n if (this._mode === 'textarea') {\n void this._requestRichUpgrade();\n }\n }\n if (\n changed.has('extensions') &&\n this.extensions !== this._lastExtensionsRef\n ) {\n this._lastExtensionsRef = this.extensions;\n if (this._mode === 'rich') {\n this._controller.setExtensions(this.extensions);\n }\n }\n if (changed.has('disabled')) {\n this._controller.setEditable(!this.disabled);\n }\n // The seed echo is skipped once — re-applying it would emit a spurious\n // host-origin change event. Every later update lands, including one that\n // returns to the seed value, and including one alongside an extensions\n // change (which may no-op or recreate; either way the seed is the previous\n // doc).\n if (changed.has('content')) {\n const echoesSeed =\n this._seedPending && this.content === this._seededContent;\n this._seedPending = false;\n if (!echoesSeed) {\n this._controller.setContent(this.content ?? '');\n }\n }\n if (changed.has('placeholder')) {\n this._controller.setPlaceholder(this.placeholder);\n }\n if (changed.has('testId')) {\n this._controller.setTestId(this.testId);\n }\n if (changed.has('ariaLabel')) {\n this._controller.setAriaLabel(this.ariaLabel);\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n if (!this._controller || this._pendingTeardownTimer !== null) {\n return;\n }\n // Deferred by a task so a reparent — remove and re-append in the same\n // frame — keeps the live editor instead of destroying and rebuilding it.\n // A macrotask rather than a microtask because the reconnect can be\n // scheduled separately from the removal, and rather than a frame callback\n // because those never fire in a background tab, which would leak the\n // editor of a chat that really was unmounted.\n this._pendingTeardownTimer = setTimeout(() => {\n this._pendingTeardownTimer = null;\n this._teardownSurface();\n }, 0);\n }\n\n /** Destroy the editing surface. Deferred from `disconnectedCallback`. */\n private _teardownSurface(): void {\n this._focusedWithKeyboard = null;\n this._failRichReady(new Error('Input is not currently rendered'));\n this._controller?.destroy();\n this._controller = null;\n this._editorHost?.remove();\n this._editorHost = null;\n this._lastExtensionsRef = null;\n // Back to the default surface. `_richLatched` is the sticky flag, so a late\n // reconnect still comes back rich; leaving `_mode` on 'rich' with no\n // controller would just be a field outliving what it describes.\n this._mode = 'textarea';\n // The host div (and its composition listeners) is gone, so a composition\n // that was in flight can never fire its `compositionend`. Left set, these\n // would park the first upgrade after a reattach forever.\n this._isComposing = false;\n this._pendingUpgrade = false;\n }\n\n /** Mount the editing surface. Runs on first render and on a late reconnect. */\n private _initializeSurface(): void {\n // Guard against Lit running the pending first update on an element that was\n // appended and removed in a single task before the update flushed. Without\n // this check the editor mounts on a detached host with no disconnectedCallback\n // left to clean it up, because the callback already ran before the update.\n if (!this.isConnected) {\n return;\n }\n const host = this._mountEditorHost();\n this._lastExtensionsRef = this.extensions;\n this._seededContent = this.content;\n this._seedPending = true;\n this._richLatched = this._wantsRich();\n\n const warmRuntime = this._richLatched ? getRichRuntimeIfLoaded() : null;\n if (warmRuntime) {\n // Runtime already loaded (e.g. preloaded at boot) — mount rich directly,\n // no textarea flash.\n this._mode = 'rich';\n this._controller = warmRuntime.createRichController();\n this._controller.mount(host, this._makeInit());\n } else {\n this._mode = 'textarea';\n this._controller = new TextareaController();\n this._controller.mount(host, this._makeInit());\n if (this._richLatched) {\n void this._requestRichUpgrade();\n }\n }\n\n if (this.autofocus) {\n // Defer so consumer listeners are attached first.\n Promise.resolve().then(() => this._controller?.focus(false));\n }\n }\n\n override render() {\n return html`\n <div class=\"frame\">\n <slot name=\"editor\"></slot>\n </div>\n `;\n }\n\n // ---------------------------------------------------------------------------\n // Public methods (delegate to the active controller)\n // ---------------------------------------------------------------------------\n\n /** Returns the live Tiptap editor, or `null` in textarea mode. */\n getEditor(): Editor | null {\n return this._controller?.getEditor() ?? null;\n }\n\n /**\n * Lazily load Tiptap (if not already loaded), upgrade the textarea to the\n * rich editor in place, and resolve with the live editor. Resolves\n * immediately when already rich. Rejects when the surface isn't mounted or\n * the runtime can't load (SSR). Concurrent callers share one in-flight\n * upgrade.\n */\n ensureEditor(): Promise<Editor> {\n if (!this.isConnected || this._pendingTeardownTimer !== null) {\n return Promise.reject(new Error('Input is not currently rendered'));\n }\n if (this._mode === 'rich') {\n const editor = this._controller?.getEditor();\n if (editor) {\n return Promise.resolve(editor);\n }\n }\n // Connected but not yet rendered, or already torn down — nothing to upgrade.\n if (!this._editorHost || !this._controller) {\n return Promise.reject(new Error('Input is not currently rendered'));\n }\n this._richLatched = true;\n if (!this._richReady) {\n this._richReady = new Promise<Editor>((resolve, reject) => {\n this._resolveRichReady = resolve;\n this._rejectRichReady = reject;\n });\n }\n // Capture the promise before starting the upgrade: _requestRichUpgrade may\n // run synchronously (warm runtime path) and call _failRichReady, which\n // nulls this._richReady. Returning the captured reference keeps the\n // rejection visible to the caller.\n const promise = this._richReady;\n void this._requestRichUpgrade();\n return promise;\n }\n\n /**\n * Current plain-text value. Works in both modes (in rich mode this mirrors\n * `getEditor()?.getText()`), so callers don't need to branch on `getEditor()`\n * being `null`.\n */\n getValue(): string {\n return this._controller?.getValue() ?? '';\n }\n\n override focus(): void {\n this._controller?.focus(false);\n }\n\n override blur(): void {\n this._focusedWithKeyboard = null;\n this._controller?.blur();\n }\n\n /** Returns `true` if the editing surface currently holds focus. */\n hasFocus(): boolean {\n return this._controller?.hasFocus() ?? false;\n }\n\n clearContent(): void {\n this._controller?.clearContent();\n }\n\n setContent(next: JSONContent | string | SetContentUpdater): void {\n this._controller?.setContent(next);\n }\n\n insertContent(\n content: JSONContent | string,\n opts: { at?: number } = {}\n ): void {\n this._controller?.insertContent(content, opts);\n }\n\n setTextSelection(pos: number | { from: number; to: number }): void {\n this._controller?.setTextSelection(pos);\n }\n\n selectAll(): void {\n this._controller?.selectAll();\n }\n\n undo(): boolean {\n return this._controller?.undo() ?? false;\n }\n\n redo(): boolean {\n return this._controller?.redo() ?? false;\n }\n\n /**\n * Drops the editor's undo and redo history, keeping the live editor,\n * its focus, and its plugin state. Emits Tiptap's `transaction` event but\n * no `update`, value-change, typing, or token events. No-op in plain\n * textarea mode.\n */\n resetHistory(): void {\n this._controller?.resetHistory();\n }\n\n // ---------------------------------------------------------------------------\n // Internals\n // ---------------------------------------------------------------------------\n\n private _wantsRich(): boolean {\n return this._richLatched || this.rich;\n }\n\n /**\n * Rendered once and then torn down — the element is inert until something\n * re-runs the mount path. Distinct from \"not yet rendered\", where Lit's own\n * `firstUpdated` still has it.\n */\n private _isTornDown(): boolean {\n return this.hasUpdated && !this._controller;\n }\n\n private _mountEditorHost(): HTMLElement {\n const host = document.createElement('div');\n host.setAttribute('slot', 'editor');\n host.dataset.aichatEditorHost = '';\n this.appendChild(host);\n this._editorHost = host;\n\n // Defer an upgrade requested mid-IME-composition so we don't tear the\n // field out from under the user.\n host.addEventListener('compositionstart', this._onCompositionStart);\n host.addEventListener('compositionend', this._onCompositionEnd);\n host.addEventListener('cds-aichat-prompt-focus', (event) => {\n this._focusedWithKeyboard = (event as CustomEvent).detail.keyboard;\n });\n host.addEventListener('cds-aichat-prompt-blur', () => {\n // Chromium blurs a removed ancestor's descendants before disconnecting\n // them. Wait until the DOM move finishes before treating this as a blur.\n queueMicrotask(() => {\n if (this.isConnected && !this._controller?.hasFocus()) {\n this._focusedWithKeyboard = null;\n }\n });\n });\n\n const root = host.getRootNode();\n if (root instanceof ShadowRoot || root instanceof Document) {\n adoptOnRoot(root);\n }\n return host;\n }\n\n private _onCompositionStart = (): void => {\n this._isComposing = true;\n this._controller?.setComposing(true);\n };\n\n private _onCompositionEnd = (): void => {\n this._isComposing = false;\n this._controller?.setComposing(false);\n if (this._pendingUpgrade) {\n this._pendingUpgrade = false;\n void this._requestRichUpgrade();\n }\n };\n\n /** Build the controller init from current props (rich seed by default). */\n private _makeInit(valueOverride?: string): PromptLineControllerInit {\n const value =\n valueOverride ??\n (typeof this.content === 'string'\n ? this.content\n : this.content\n ? getRawText(this.content)\n : '');\n return {\n value,\n // On an upgrade we seed losslessly from the textarea's plain text, so\n // the structured `content` prop is only used for the initial mount.\n content: valueOverride === undefined ? this.content : undefined,\n placeholder: this.placeholder,\n disabled: this.disabled,\n ariaLabel: this.ariaLabel,\n testId: this.testId,\n extensions: this.extensions,\n };\n }\n\n /** Resolve any pending `ensureEditor()` callers with the live editor. */\n private _settleRichReady(): void {\n const editor = this._controller?.getEditor();\n if (editor && this._resolveRichReady) {\n this._resolveRichReady(editor);\n this._resolveRichReady = null;\n this._rejectRichReady = null;\n }\n }\n\n /**\n * Reject any pending `ensureEditor()` callers and clear the shared promise so\n * a later call can retry.\n */\n private _failRichReady(reason: Error): void {\n if (this._rejectRichReady) {\n this._rejectRichReady(reason);\n }\n this._resolveRichReady = null;\n this._rejectRichReady = null;\n this._richReady = null;\n }\n\n /**\n * Request a textarea→rich upgrade. The upgrade may be declined or deferred:\n * returns without upgrading when already rich, when a concurrent upgrade is\n * in flight, when a teardown is pending (element scheduled for removal), when\n * a composition is in flight, or when the runtime is unavailable (SSR).\n */\n private async _requestRichUpgrade(): Promise<void> {\n if (this._mode === 'rich' || this._upgrading) {\n return;\n }\n this._upgrading = true;\n try {\n const module = getRichRuntimeIfLoaded() ?? (await loadRichRuntime());\n // After the async import, re-check all bail conditions — any of them can\n // have changed while the runtime was loading:\n // - `_pendingTeardownTimer`: element disconnected during the import; the\n // teardown is scheduled but hasn't run yet, so _editorHost and\n // _controller are still set. Mounting here would build an editor that\n // is destroyed a macrotask later, and resolve any pending ensureEditor()\n // with a dead editor. Reject instead.\n // - `_editorHost` / `_controller` null: real teardown already ran.\n // - `module` null: SSR or runtime load failed.\n if (!module || !this._editorHost || !this._controller) {\n this._failRichReady(\n new Error(\n module\n ? 'Input is not currently rendered'\n : 'Input editor runtime is unavailable'\n )\n );\n return;\n }\n if (this._pendingTeardownTimer !== null) {\n // Teardown is deferred but imminent. Reject so callers get a clear\n // error rather than a live editor that disappears one task later.\n this._failRichReady(new Error('Input is not currently rendered'));\n return;\n }\n if (this._isComposing) {\n // Defer until composition ends; `_richReady` stays pending and settles\n // when `_onCompositionEnd` re-runs the upgrade.\n this._pendingUpgrade = true;\n return;\n }\n this._swapToRich(module.createRichController());\n } catch (error) {\n // A failed runtime load or mount must reject pending `ensureEditor()`\n // callers rather than leave them hanging.\n this._failRichReady(\n error instanceof Error ? error : new Error(String(error))\n );\n } finally {\n this._upgrading = false;\n }\n }\n\n private _swapToRich(rich: PromptLineController): void {\n const previous = this._controller;\n const host = this._editorHost;\n if (!previous || !host) {\n return;\n }\n const value = previous.getValue();\n const selection = previous.getSelection();\n const hadFocus = previous.hasFocus();\n const hadKeyboardFocus = previous.getKeyboardFocus();\n\n previous.destroy();\n this._controller = rich;\n this._mode = 'rich';\n // Seeded losslessly from the textarea's text, which already reflects\n // `content`, so an in-flight identical `content` update stays a no-op.\n this._seededContent = this.content;\n this._seedPending = true;\n rich.mount(host, this._makeInit(value));\n\n rich.setTextSelection({\n from: textOffsetToDocPos(value, selection.from),\n to: textOffsetToDocPos(value, selection.to),\n });\n if (hadFocus) {\n rich.focus(hadKeyboardFocus, true);\n }\n this._settleRichReady();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cds-aichat-prompt-line': PromptLineElement;\n }\n}\n\nexport default PromptLineElement;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AAuBH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCG;AAEH,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU,CAAA;AAA1C,IAAA,WAAA,GAAA;;AAKE;;;;;;;;;;;;;;;AAeG;QAEH,IAAA,CAAA,UAAU,GAAgB,EAAE;AAS5B;;;;AAIG;QAEH,IAAA,CAAA,IAAI,GAAG,KAAK;;QAIZ,IAAA,CAAA,QAAQ,GAAG,KAAK;;QAIhB,IAAA,CAAA,WAAW,GAAG,EAAE;;QAIP,IAAA,CAAA,SAAS,GAAG,SAAS;;QAI9B,IAAA,CAAA,MAAM,GAAG,EAAE;;QAIF,IAAA,CAAA,SAAS,GAAG,KAAK;QAElB,IAAA,CAAA,WAAW,GAAgC,IAAI;QAC/C,IAAA,CAAA,KAAK,GAAwB,UAAU;QACvC,IAAA,CAAA,WAAW,GAAuB,IAAI;QACtC,IAAA,CAAA,kBAAkB,GAAuB,IAAI;QAS7C,IAAA,CAAA,YAAY,GAAG,KAAK;;QAEpB,IAAA,CAAA,qBAAqB,GAAyC,IAAI;QAClE,IAAA,CAAA,oBAAoB,GAAmB,IAAI;;QAE3C,IAAA,CAAA,YAAY,GAAG,KAAK;QACpB,IAAA,CAAA,UAAU,GAAG,KAAK;AAC1B;;;;;AAKG;QAC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block;inline-size:100%}"]);
10
+ var styles = css([":host{display:block;inline-size:100%}:host([disabled]){--cds-text-placeholder:var(--cds-text-disabled,rgba(22,22,22,.25))}.frame{display:flex;inline-size:100%}::slotted([slot=editor]){display:block;inline-size:100%}"]);
11
11
 
12
12
  export { styles as default };
13
13
  //# sourceMappingURL=prompt-line.scss.js.map
@@ -8,8 +8,8 @@
8
8
  */
9
9
  /**
10
10
  * `carbonChatEnter` — Tiptap extension that binds plain `Enter` to fire
11
- * `cds-aichat-prompt-send-intent`, matching the legacy chat UX where Enter
12
- * sends and Mod-Enter inserts a newline. `<cds-aichat-prompt-line>` installs
11
+ * `cds-aichat-prompt-send-intent`, matching the chat UX where Enter sends and
12
+ * Shift-Enter inserts a newline. `<cds-aichat-prompt-line>` installs
13
13
  * it in its base bundle (both surfaces send on Enter); it stays a standalone
14
14
  * extension so hosts composing their own editor can opt in the same way.
15
15
  */
@@ -17,8 +17,8 @@ import { Extension } from '@tiptap/core';
17
17
  */
18
18
  /**
19
19
  * `carbonChatEnter` — Tiptap extension that binds plain `Enter` to fire
20
- * `cds-aichat-prompt-send-intent`, matching the legacy chat UX where Enter
21
- * sends and Mod-Enter inserts a newline. `<cds-aichat-prompt-line>` installs
20
+ * `cds-aichat-prompt-send-intent`, matching the chat UX where Enter sends and
21
+ * Shift-Enter inserts a newline. `<cds-aichat-prompt-line>` installs
22
22
  * it in its base bundle (both surfaces send on Enter); it stays a standalone
23
23
  * extension so hosts composing their own editor can opt in the same way.
24
24
  */
@@ -1 +1 @@
1
- {"version":3,"file":"chat-enter.js","sources":["../../../../../src/components/prompt-line/src/tiptap/chat-enter.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * `carbonChatEnter` — Tiptap extension that binds plain `Enter` to fire\n * `cds-aichat-prompt-send-intent`, matching the legacy chat UX where Enter\n * sends and Mod-Enter inserts a newline. `<cds-aichat-prompt-line>` installs\n * it in its base bundle (both surfaces send on Enter); it stays a standalone\n * extension so hosts composing their own editor can opt in the same way.\n */\n\nimport { Extension } from '@tiptap/core';\n\nexport function carbonChatEnter(): Extension {\n return Extension.create({\n name: 'carbonChatEnter',\n addKeyboardShortcuts() {\n return {\n Enter: ({ editor }) => {\n if (editor.isEmpty) {\n return false;\n }\n editor.view.dom.dispatchEvent(\n new CustomEvent('cds-aichat-prompt-send-intent', {\n bubbles: true,\n composed: true,\n })\n );\n return true;\n },\n };\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;AAOG;AAEH;;;;;;AAMG;SAIa,eAAe,GAAA;IAC7B,OAAO,SAAS,CAAC,MAAM,CAAC;AACtB,QAAA,IAAI,EAAE,iBAAiB;QACvB,oBAAoB,GAAA;YAClB,OAAO;AACL,gBAAA,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,KAAI;AACpB,oBAAA,IAAI,MAAM,CAAC,OAAO,EAAE;AAClB,wBAAA,OAAO,KAAK;oBACd;oBACA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAC3B,IAAI,WAAW,CAAC,+BAA+B,EAAE;AAC/C,wBAAA,OAAO,EAAE,IAAI;AACb,wBAAA,QAAQ,EAAE,IAAI;AACf,qBAAA,CAAC,CACH;AACD,oBAAA,OAAO,IAAI;gBACb,CAAC;aACF;QACH,CAAC;AACF,KAAA,CAAC;AACJ;;"}
1
+ {"version":3,"file":"chat-enter.js","sources":["../../../../../src/components/prompt-line/src/tiptap/chat-enter.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * `carbonChatEnter` — Tiptap extension that binds plain `Enter` to fire\n * `cds-aichat-prompt-send-intent`, matching the chat UX where Enter sends and\n * Shift-Enter inserts a newline. `<cds-aichat-prompt-line>` installs\n * it in its base bundle (both surfaces send on Enter); it stays a standalone\n * extension so hosts composing their own editor can opt in the same way.\n */\n\nimport { Extension } from '@tiptap/core';\n\nexport function carbonChatEnter(): Extension {\n return Extension.create({\n name: 'carbonChatEnter',\n addKeyboardShortcuts() {\n return {\n Enter: ({ editor }) => {\n if (editor.isEmpty) {\n return false;\n }\n editor.view.dom.dispatchEvent(\n new CustomEvent('cds-aichat-prompt-send-intent', {\n bubbles: true,\n composed: true,\n })\n );\n return true;\n },\n };\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;AAOG;AAEH;;;;;;AAMG;SAIa,eAAe,GAAA;IAC7B,OAAO,SAAS,CAAC,MAAM,CAAC;AACtB,QAAA,IAAI,EAAE,iBAAiB;QACvB,oBAAoB,GAAA;YAClB,OAAO;AACL,gBAAA,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,KAAI;AACpB,oBAAA,IAAI,MAAM,CAAC,OAAO,EAAE;AAClB,wBAAA,OAAO,KAAK;oBACd;oBACA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAC3B,IAAI,WAAW,CAAC,+BAA+B,EAAE;AAC/C,wBAAA,OAAO,EAAE,IAAI;AACb,wBAAA,QAAQ,EAAE,IAAI;AACf,qBAAA,CAAC,CACH;AACD,oBAAA,OAAO,IAAI;gBACb,CAAC;aACF;QACH,CAAC;AACF,KAAA,CAAC;AACJ;;"}
@@ -57,7 +57,7 @@ function ensurePmContentStyleRules() {
57
57
  // displacing the caret onto a second line. Standard Tiptap pattern.
58
58
  setVarsForSelector(`.${PM_CONTENT_CLASS} p.is-editor-empty:first-child::before`, {
59
59
  content: 'attr(data-placeholder)',
60
- color: 'var(--cds-text-secondary, #525252)',
60
+ color: 'var(--cds-text-placeholder, var(--cds-text-secondary, #525252))',
61
61
  float: 'left',
62
62
  height: '0',
63
63
  'pointer-events': 'none',
@@ -1 +1 @@
1
- {"version":3,"file":"editor-styles.js","sources":["../../../../../src/components/prompt-line/src/tiptap/editor-styles.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { setVarsForSelector } from '../../../shared/dynamic-css-var-sheet.js';\nimport { PROMPT_LINE_MAX_BLOCK_SIZE } from '../prompt-line-constants.js';\n\nconst PM_CONTENT_CLASS = 'cds-aichat--input-pm-content';\nconst PM_PHONE_CLASS = 'cds-aichat--input-pm-content--phone';\nlet pmStyleRulesInstalled = false;\n\nfunction ensurePmContentStyleRules(): void {\n if (pmStyleRulesInstalled) {\n return;\n }\n setVarsForSelector(`.${PM_CONTENT_CLASS}`, {\n border: 'none',\n margin: '0',\n background: 'transparent',\n color: 'var(--cds-text-primary, #161616)',\n outline: 'none',\n 'white-space': 'pre-wrap',\n 'overflow-wrap': 'anywhere',\n 'font-size': 'var(--cds-body-01-font-size, 0.875rem)',\n 'font-weight': 'var(--cds-body-01-font-weight, 400)',\n 'letter-spacing': 'var(--cds-body-01-letter-spacing, 0.16px)',\n 'line-height': 'var(--cds-body-01-line-height, 1.42857)',\n 'max-block-size': PROMPT_LINE_MAX_BLOCK_SIZE,\n 'overflow-y': 'auto',\n });\n // Tiptap renders block content into real <p> tags inside the light-DOM\n // contenteditable. Neutralize the user-agent / host paragraph margin so\n // the prompt line doesn't inflate to whatever the host page styles `p` as.\n setVarsForSelector(`.${PM_CONTENT_CLASS} p`, {\n margin: '0',\n padding: '0',\n });\n setVarsForSelector(`.${PM_PHONE_CLASS}`, {\n 'font-size': 'var(--cds-body-02-font-size, 1rem)',\n 'font-weight': 'var(--cds-body-02-font-weight, 400)',\n 'letter-spacing': 'var(--cds-body-02-letter-spacing, 0)',\n 'line-height': 'var(--cds-body-02-line-height, 1.5)',\n });\n // Tiptap's Placeholder extension only tags empty textblocks with\n // `is-editor-empty` + `data-placeholder` — the host renders the text. The\n // ::before float/height-0 pair keeps the placeholder in flow without\n // displacing the caret onto a second line. Standard Tiptap pattern.\n setVarsForSelector(\n `.${PM_CONTENT_CLASS} p.is-editor-empty:first-child::before`,\n {\n content: 'attr(data-placeholder)',\n color: 'var(--cds-text-secondary, #525252)',\n float: 'left',\n height: '0',\n 'pointer-events': 'none',\n }\n );\n pmStyleRulesInstalled = true;\n}\n\n/**\n * Apply the editor's intrinsic typography and reset styles to the PM content\n * node. The PM contenteditable lives in light DOM (so `::slotted()` can't\n * reach it from the shell's shadow DOM), so we install a class-based rule\n * on the shared dynamic stylesheet (constructable, document-scoped) and add\n * the corresponding classes to the element. This is CSP-safe: stylesheet\n * mutations are governed by `style-src` (not `style-src-attr`) and don't\n * require `'unsafe-inline'`.\n */\nexport function applyEditorStyles(pmDom: HTMLElement, isPhone: boolean): void {\n ensurePmContentStyleRules();\n pmDom.classList.add(PM_CONTENT_CLASS);\n pmDom.classList.toggle(PM_PHONE_CLASS, isPhone);\n}\n"],"names":[],"mappings":";;;;;;;;;;AAAA;;;;;;;AAOG;AAKH,MAAM,gBAAgB,GAAG,8BAA8B;AACvD,MAAM,cAAc,GAAG,qCAAqC;AAC5D,IAAI,qBAAqB,GAAG,KAAK;AAEjC,SAAS,yBAAyB,GAAA;IAChC,IAAI,qBAAqB,EAAE;QACzB;IACF;AACA,IAAA,kBAAkB,CAAC,CAAA,CAAA,EAAI,gBAAgB,CAAA,CAAE,EAAE;AACzC,QAAA,MAAM,EAAE,MAAM;AACd,QAAA,MAAM,EAAE,GAAG;AACX,QAAA,UAAU,EAAE,aAAa;AACzB,QAAA,KAAK,EAAE,kCAAkC;AACzC,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,aAAa,EAAE,UAAU;AACzB,QAAA,eAAe,EAAE,UAAU;AAC3B,QAAA,WAAW,EAAE,wCAAwC;AACrD,QAAA,aAAa,EAAE,qCAAqC;AACpD,QAAA,gBAAgB,EAAE,2CAA2C;AAC7D,QAAA,aAAa,EAAE,yCAAyC;AACxD,QAAA,gBAAgB,EAAE,0BAA0B;AAC5C,QAAA,YAAY,EAAE,MAAM;AACrB,KAAA,CAAC;;;;AAIF,IAAA,kBAAkB,CAAC,CAAA,CAAA,EAAI,gBAAgB,CAAA,EAAA,CAAI,EAAE;AAC3C,QAAA,MAAM,EAAE,GAAG;AACX,QAAA,OAAO,EAAE,GAAG;AACb,KAAA,CAAC;AACF,IAAA,kBAAkB,CAAC,CAAA,CAAA,EAAI,cAAc,CAAA,CAAE,EAAE;AACvC,QAAA,WAAW,EAAE,oCAAoC;AACjD,QAAA,aAAa,EAAE,qCAAqC;AACpD,QAAA,gBAAgB,EAAE,sCAAsC;AACxD,QAAA,aAAa,EAAE,qCAAqC;AACrD,KAAA,CAAC;;;;;AAKF,IAAA,kBAAkB,CAChB,CAAA,CAAA,EAAI,gBAAgB,CAAA,sCAAA,CAAwC,EAC5D;AACE,QAAA,OAAO,EAAE,wBAAwB;AACjC,QAAA,KAAK,EAAE,oCAAoC;AAC3C,QAAA,KAAK,EAAE,MAAM;AACb,QAAA,MAAM,EAAE,GAAG;AACX,QAAA,gBAAgB,EAAE,MAAM;AACzB,KAAA,CACF;IACD,qBAAqB,GAAG,IAAI;AAC9B;AAEA;;;;;;;;AAQG;AACG,SAAU,iBAAiB,CAAC,KAAkB,EAAE,OAAgB,EAAA;AACpE,IAAA,yBAAyB,EAAE;AAC3B,IAAA,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC;IACrC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC;AACjD;;"}
1
+ {"version":3,"file":"editor-styles.js","sources":["../../../../../src/components/prompt-line/src/tiptap/editor-styles.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { setVarsForSelector } from '../../../shared/dynamic-css-var-sheet.js';\nimport { PROMPT_LINE_MAX_BLOCK_SIZE } from '../prompt-line-constants.js';\n\nconst PM_CONTENT_CLASS = 'cds-aichat--input-pm-content';\nconst PM_PHONE_CLASS = 'cds-aichat--input-pm-content--phone';\nlet pmStyleRulesInstalled = false;\n\nfunction ensurePmContentStyleRules(): void {\n if (pmStyleRulesInstalled) {\n return;\n }\n setVarsForSelector(`.${PM_CONTENT_CLASS}`, {\n border: 'none',\n margin: '0',\n background: 'transparent',\n color: 'var(--cds-text-primary, #161616)',\n outline: 'none',\n 'white-space': 'pre-wrap',\n 'overflow-wrap': 'anywhere',\n 'font-size': 'var(--cds-body-01-font-size, 0.875rem)',\n 'font-weight': 'var(--cds-body-01-font-weight, 400)',\n 'letter-spacing': 'var(--cds-body-01-letter-spacing, 0.16px)',\n 'line-height': 'var(--cds-body-01-line-height, 1.42857)',\n 'max-block-size': PROMPT_LINE_MAX_BLOCK_SIZE,\n 'overflow-y': 'auto',\n });\n // Tiptap renders block content into real <p> tags inside the light-DOM\n // contenteditable. Neutralize the user-agent / host paragraph margin so\n // the prompt line doesn't inflate to whatever the host page styles `p` as.\n setVarsForSelector(`.${PM_CONTENT_CLASS} p`, {\n margin: '0',\n padding: '0',\n });\n setVarsForSelector(`.${PM_PHONE_CLASS}`, {\n 'font-size': 'var(--cds-body-02-font-size, 1rem)',\n 'font-weight': 'var(--cds-body-02-font-weight, 400)',\n 'letter-spacing': 'var(--cds-body-02-letter-spacing, 0)',\n 'line-height': 'var(--cds-body-02-line-height, 1.5)',\n });\n // Tiptap's Placeholder extension only tags empty textblocks with\n // `is-editor-empty` + `data-placeholder` — the host renders the text. The\n // ::before float/height-0 pair keeps the placeholder in flow without\n // displacing the caret onto a second line. Standard Tiptap pattern.\n setVarsForSelector(\n `.${PM_CONTENT_CLASS} p.is-editor-empty:first-child::before`,\n {\n content: 'attr(data-placeholder)',\n color: 'var(--cds-text-placeholder, var(--cds-text-secondary, #525252))',\n float: 'left',\n height: '0',\n 'pointer-events': 'none',\n }\n );\n pmStyleRulesInstalled = true;\n}\n\n/**\n * Apply the editor's intrinsic typography and reset styles to the PM content\n * node. The PM contenteditable lives in light DOM (so `::slotted()` can't\n * reach it from the shell's shadow DOM), so we install a class-based rule\n * on the shared dynamic stylesheet (constructable, document-scoped) and add\n * the corresponding classes to the element. This is CSP-safe: stylesheet\n * mutations are governed by `style-src` (not `style-src-attr`) and don't\n * require `'unsafe-inline'`.\n */\nexport function applyEditorStyles(pmDom: HTMLElement, isPhone: boolean): void {\n ensurePmContentStyleRules();\n pmDom.classList.add(PM_CONTENT_CLASS);\n pmDom.classList.toggle(PM_PHONE_CLASS, isPhone);\n}\n"],"names":[],"mappings":";;;;;;;;;;AAAA;;;;;;;AAOG;AAKH,MAAM,gBAAgB,GAAG,8BAA8B;AACvD,MAAM,cAAc,GAAG,qCAAqC;AAC5D,IAAI,qBAAqB,GAAG,KAAK;AAEjC,SAAS,yBAAyB,GAAA;IAChC,IAAI,qBAAqB,EAAE;QACzB;IACF;AACA,IAAA,kBAAkB,CAAC,CAAA,CAAA,EAAI,gBAAgB,CAAA,CAAE,EAAE;AACzC,QAAA,MAAM,EAAE,MAAM;AACd,QAAA,MAAM,EAAE,GAAG;AACX,QAAA,UAAU,EAAE,aAAa;AACzB,QAAA,KAAK,EAAE,kCAAkC;AACzC,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,aAAa,EAAE,UAAU;AACzB,QAAA,eAAe,EAAE,UAAU;AAC3B,QAAA,WAAW,EAAE,wCAAwC;AACrD,QAAA,aAAa,EAAE,qCAAqC;AACpD,QAAA,gBAAgB,EAAE,2CAA2C;AAC7D,QAAA,aAAa,EAAE,yCAAyC;AACxD,QAAA,gBAAgB,EAAE,0BAA0B;AAC5C,QAAA,YAAY,EAAE,MAAM;AACrB,KAAA,CAAC;;;;AAIF,IAAA,kBAAkB,CAAC,CAAA,CAAA,EAAI,gBAAgB,CAAA,EAAA,CAAI,EAAE;AAC3C,QAAA,MAAM,EAAE,GAAG;AACX,QAAA,OAAO,EAAE,GAAG;AACb,KAAA,CAAC;AACF,IAAA,kBAAkB,CAAC,CAAA,CAAA,EAAI,cAAc,CAAA,CAAE,EAAE;AACvC,QAAA,WAAW,EAAE,oCAAoC;AACjD,QAAA,aAAa,EAAE,qCAAqC;AACpD,QAAA,gBAAgB,EAAE,sCAAsC;AACxD,QAAA,aAAa,EAAE,qCAAqC;AACrD,KAAA,CAAC;;;;;AAKF,IAAA,kBAAkB,CAChB,CAAA,CAAA,EAAI,gBAAgB,CAAA,sCAAA,CAAwC,EAC5D;AACE,QAAA,OAAO,EAAE,wBAAwB;AACjC,QAAA,KAAK,EAAE,iEAAiE;AACxE,QAAA,KAAK,EAAE,MAAM;AACb,QAAA,MAAM,EAAE,GAAG;AACX,QAAA,gBAAgB,EAAE,MAAM;AACzB,KAAA,CACF;IACD,qBAAqB,GAAG,IAAI;AAC9B;AAEA;;;;;;;;AAQG;AACG,SAAU,iBAAiB,CAAC,KAAkB,EAAE,OAAgB,EAAA;AACpE,IAAA,yBAAyB,EAAE;AAC3B,IAAA,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC;IACrC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC;AACjD;;"}
@@ -214,10 +214,9 @@ export interface StartersConfig extends Pick<BaseSuggestionConfig, 'renderCustom
214
214
  isOn?: boolean;
215
215
  }
216
216
  /**
217
- * Detail payload for the trigger-change event emitted directly by each carbon
218
- * factory's suggestion-render lifecycle. The shape is shared with the legacy
219
- * `TriggerChangeEventDetail` (see `../types.ts`) so existing listeners keep
220
- * working unchanged across the wave.
217
+ * Detail payload for the trigger-change event emitted by the Carbon trigger
218
+ * factories (mention, command, autocomplete, and starter). This is the only
219
+ * definition; `../types.ts` re-exports it.
221
220
  */
222
221
  export interface TriggerChangeEventDetail {
223
222
  /** The trigger type that fired (`"mention"`/`"command"`/`"autocomplete"`/`"starter"`). */
@@ -0,0 +1,30 @@
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
+ * Rules attached to one root by {@link attachRootStyles}.
11
+ */
12
+ interface RootStyles {
13
+ /** Replace the attached rules. A no-op when the text is unchanged. */
14
+ update(cssText: string): void;
15
+ /** Remove the attached rules from the root. */
16
+ detach(): void;
17
+ }
18
+ /**
19
+ * Attaches CSS rules to one document or shadow root.
20
+ *
21
+ * Uses a constructed stylesheet so the rules pass a strict CSP. The sheet is
22
+ * built from the root's own document, since a sheet from another document
23
+ * can't be adopted. Browsers without constructed-sheet support get a `<style>`
24
+ * element instead.
25
+ *
26
+ * Each call owns its own sheet. Use `dynamic-css-var-sheet.ts` for one sheet
27
+ * shared across roots.
28
+ */
29
+ declare function attachRootStyles(root: Document | ShadowRoot, cssText: string): RootStyles;
30
+ export { attachRootStyles, type RootStyles };
@@ -0,0 +1,72 @@
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
+ /**
9
+ * @license
10
+ *
11
+ * Copyright IBM Corp. 2026
12
+ *
13
+ * This source code is licensed under the Apache-2.0 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ */
16
+ /**
17
+ * Attaches CSS rules to one document or shadow root.
18
+ *
19
+ * Uses a constructed stylesheet so the rules pass a strict CSP. The sheet is
20
+ * built from the root's own document, since a sheet from another document
21
+ * can't be adopted. Browsers without constructed-sheet support get a `<style>`
22
+ * element instead.
23
+ *
24
+ * Each call owns its own sheet. Use `dynamic-css-var-sheet.ts` for one sheet
25
+ * shared across roots.
26
+ */
27
+ function attachRootStyles(root, cssText) {
28
+ const isDocument = root.nodeType === Node.DOCUMENT_NODE;
29
+ const ownerDocument = isDocument
30
+ ? root
31
+ : root.ownerDocument;
32
+ let sheet;
33
+ let element;
34
+ try {
35
+ const candidate = new ownerDocument.defaultView.CSSStyleSheet();
36
+ candidate.replaceSync(cssText);
37
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, candidate];
38
+ sheet = candidate;
39
+ }
40
+ catch {
41
+ element = ownerDocument.createElement('style');
42
+ element.textContent = cssText;
43
+ const container = isDocument
44
+ ? (root.head ?? root.documentElement)
45
+ : root;
46
+ container.appendChild(element);
47
+ }
48
+ let current = cssText;
49
+ return {
50
+ update(nextText) {
51
+ if (nextText === current) {
52
+ return;
53
+ }
54
+ current = nextText;
55
+ if (sheet) {
56
+ sheet.replaceSync(nextText);
57
+ }
58
+ else if (element) {
59
+ element.textContent = nextText;
60
+ }
61
+ },
62
+ detach() {
63
+ if (sheet) {
64
+ root.adoptedStyleSheets = root.adoptedStyleSheets.filter((existing) => existing !== sheet);
65
+ }
66
+ element?.remove();
67
+ },
68
+ };
69
+ }
70
+
71
+ export { attachRootStyles };
72
+ //# sourceMappingURL=root-styles.js.map