@carbon/ai-chat-components 1.4.0 → 1.5.0-rc.1

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 (100) hide show
  1. package/custom-elements.json +837 -284
  2. package/es/components/chat-history/src/chat-history.scss.js +1 -1
  3. package/es/components/chat-history/src/history-panel-item.d.ts +14 -0
  4. package/es/components/chat-history/src/history-panel-item.js +30 -0
  5. package/es/components/chat-history/src/history-panel-item.js.map +1 -1
  6. package/es/components/code-snippet/src/code-snippet.d.ts +5 -0
  7. package/es/components/code-snippet/src/code-snippet.js +17 -5
  8. package/es/components/code-snippet/src/code-snippet.js.map +1 -1
  9. package/es/components/feedback/src/feedback.d.ts +4 -0
  10. package/es/components/feedback/src/feedback.js +6 -4
  11. package/es/components/feedback/src/feedback.js.map +1 -1
  12. package/es/components/markdown/index.d.ts +3 -1
  13. package/es/components/markdown/index.js +1 -1
  14. package/es/components/markdown/src/markdown-renderer-types.d.ts +100 -0
  15. package/es/components/markdown/src/markdown-renderer-types.js +8 -0
  16. package/es/components/markdown/src/markdown-renderer-types.js.map +1 -0
  17. package/es/components/markdown/src/markdown-renderer.d.ts +14 -64
  18. package/es/components/markdown/src/markdown-renderer.js +120 -134
  19. package/es/components/markdown/src/markdown-renderer.js.map +1 -1
  20. package/es/components/markdown/src/markdown-token-tree.d.ts +50 -5
  21. package/es/components/markdown/src/markdown-token-tree.js +182 -47
  22. package/es/components/markdown/src/markdown-token-tree.js.map +1 -1
  23. package/es/components/markdown/src/markdown.d.ts +49 -1
  24. package/es/components/markdown/src/markdown.js +307 -106
  25. package/es/components/markdown/src/markdown.js.map +1 -1
  26. package/es/components/markdown/src/markdown.scss.js +1 -1
  27. package/es/components/markdown/src/plugins/markdown-it-task-lists.js +2 -5
  28. package/es/components/markdown/src/plugins/markdown-it-task-lists.js.map +1 -1
  29. package/es/components/markdown/src/utils/lit-directives.d.ts +17 -0
  30. package/es/components/markdown/src/utils/lit-directives.js +84 -0
  31. package/es/components/markdown/src/utils/lit-directives.js.map +1 -0
  32. package/es/components/markdown/src/utils/plugin-fallback.d.ts +33 -0
  33. package/es/components/markdown/src/utils/plugin-fallback.js +219 -0
  34. package/es/components/markdown/src/utils/plugin-fallback.js.map +1 -0
  35. package/es/components/markdown/src/utils/streaming-table.d.ts +28 -0
  36. package/es/components/markdown/src/utils/streaming-table.js +86 -0
  37. package/es/components/markdown/src/utils/streaming-table.js.map +1 -0
  38. package/es/components/markdown/src/utils/table-helpers.d.ts +17 -0
  39. package/es/components/markdown/src/utils/table-helpers.js +104 -2
  40. package/es/components/markdown/src/utils/table-helpers.js.map +1 -1
  41. package/es/components/table/src/table.js +4 -1
  42. package/es/components/table/src/table.js.map +1 -1
  43. package/es/components/truncated-text/src/truncated-text.scss.js +1 -1
  44. package/es/components/workspace-shell/src/workspace-shell.scss.js +1 -1
  45. package/es/react/markdown.d.ts +46 -2
  46. package/es/react/markdown.js +177 -20
  47. package/es/react/markdown.js.map +1 -1
  48. package/es-custom/components/chat-history/src/chat-history.scss.js +1 -1
  49. package/es-custom/components/chat-history/src/history-panel-item.d.ts +14 -0
  50. package/es-custom/components/chat-history/src/history-panel-item.js +30 -0
  51. package/es-custom/components/chat-history/src/history-panel-item.js.map +1 -1
  52. package/es-custom/components/code-snippet/src/code-snippet.d.ts +5 -0
  53. package/es-custom/components/code-snippet/src/code-snippet.js +17 -5
  54. package/es-custom/components/code-snippet/src/code-snippet.js.map +1 -1
  55. package/es-custom/components/feedback/src/feedback.d.ts +4 -0
  56. package/es-custom/components/feedback/src/feedback.js +6 -4
  57. package/es-custom/components/feedback/src/feedback.js.map +1 -1
  58. package/es-custom/components/markdown/index.d.ts +3 -1
  59. package/es-custom/components/markdown/index.js +1 -1
  60. package/es-custom/components/markdown/src/markdown-renderer-types.d.ts +100 -0
  61. package/es-custom/components/markdown/src/markdown-renderer-types.js +8 -0
  62. package/es-custom/components/markdown/src/markdown-renderer-types.js.map +1 -0
  63. package/es-custom/components/markdown/src/markdown-renderer.d.ts +14 -64
  64. package/es-custom/components/markdown/src/markdown-renderer.js +120 -134
  65. package/es-custom/components/markdown/src/markdown-renderer.js.map +1 -1
  66. package/es-custom/components/markdown/src/markdown-token-tree.d.ts +50 -5
  67. package/es-custom/components/markdown/src/markdown-token-tree.js +182 -47
  68. package/es-custom/components/markdown/src/markdown-token-tree.js.map +1 -1
  69. package/es-custom/components/markdown/src/markdown.d.ts +49 -1
  70. package/es-custom/components/markdown/src/markdown.js +307 -106
  71. package/es-custom/components/markdown/src/markdown.js.map +1 -1
  72. package/es-custom/components/markdown/src/markdown.scss.js +1 -1
  73. package/es-custom/components/markdown/src/plugins/markdown-it-task-lists.js +2 -5
  74. package/es-custom/components/markdown/src/plugins/markdown-it-task-lists.js.map +1 -1
  75. package/es-custom/components/markdown/src/utils/lit-directives.d.ts +17 -0
  76. package/es-custom/components/markdown/src/utils/lit-directives.js +84 -0
  77. package/es-custom/components/markdown/src/utils/lit-directives.js.map +1 -0
  78. package/es-custom/components/markdown/src/utils/plugin-fallback.d.ts +33 -0
  79. package/es-custom/components/markdown/src/utils/plugin-fallback.js +219 -0
  80. package/es-custom/components/markdown/src/utils/plugin-fallback.js.map +1 -0
  81. package/es-custom/components/markdown/src/utils/streaming-table.d.ts +28 -0
  82. package/es-custom/components/markdown/src/utils/streaming-table.js +86 -0
  83. package/es-custom/components/markdown/src/utils/streaming-table.js.map +1 -0
  84. package/es-custom/components/markdown/src/utils/table-helpers.d.ts +17 -0
  85. package/es-custom/components/markdown/src/utils/table-helpers.js +104 -2
  86. package/es-custom/components/markdown/src/utils/table-helpers.js.map +1 -1
  87. package/es-custom/components/table/src/table.js +4 -1
  88. package/es-custom/components/table/src/table.js.map +1 -1
  89. package/es-custom/components/truncated-text/src/truncated-text.scss.js +1 -1
  90. package/es-custom/components/workspace-shell/src/workspace-shell.scss.js +1 -1
  91. package/es-custom/react/markdown.d.ts +46 -2
  92. package/es-custom/react/markdown.js +177 -20
  93. package/es-custom/react/markdown.js.map +1 -1
  94. package/package.json +5 -4
  95. package/es/components/markdown/src/utils.d.ts +0 -4
  96. package/es/components/markdown/src/utils.js +0 -25
  97. package/es/components/markdown/src/utils.js.map +0 -1
  98. package/es-custom/components/markdown/src/utils.d.ts +0 -4
  99. package/es-custom/components/markdown/src/utils.js +0 -25
  100. package/es-custom/components/markdown/src/utils.js.map +0 -1
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { css } from 'lit';
9
9
 
10
- var styles = css(["@charset \"UTF-8\";:host{--cds-aichat-border-radius-start-start:0.5rem;--cds-aichat-border-radius-start-end:0.5rem;--cds-aichat-border-radius-end-start:0.5rem;--cds-aichat-border-radius-end-end:0.5rem;display:block;font-size:var(--cds-body-01-font-size,.875rem);font-weight:var(--cds-body-01-font-weight,400);inline-size:100%;letter-spacing:var(--cds-body-01-letter-spacing,.16px);line-height:var(--cds-body-01-line-height,1.42857);max-inline-size:100%}:host mark{background-color:var(--cds-highlight,#d0e2ff);border-radius:.25rem;color:var(--cds-text-primary,#161616)}:host b,:host strong{font-weight:700}:host em,:host i{font-style:italic}:host blockquote{border-inline-start:2px solid var(--cds-border-subtle-00,#e0e0e0);padding-inline-start:.5rem}:host blockquote>:not(:first-child){margin-block-start:1rem}:host blockquote>h1+:not(:first-child),:host blockquote>h2+:not(:first-child),:host blockquote>h3+:not(:first-child),:host blockquote>h4+:not(:first-child),:host blockquote>h5+:not(:first-child),:host blockquote>h6+:not(:first-child){margin-block-start:.5rem}:host .cds-aichat-markdown-stack{display:block;max-inline-size:100%}:host .cds-aichat-markdown-stack>:not(:first-child){margin-block-start:1rem}:host .cds-aichat-markdown-stack>h1+:not(:first-child),:host .cds-aichat-markdown-stack>h2+:not(:first-child),:host .cds-aichat-markdown-stack>h3+:not(:first-child),:host .cds-aichat-markdown-stack>h4+:not(:first-child),:host .cds-aichat-markdown-stack>h5+:not(:first-child),:host .cds-aichat-markdown-stack>h6+:not(:first-child){margin-block-start:.25rem}:host p{font-size:var(--cds-body-01-font-size,.875rem);font-weight:var(--cds-body-01-font-weight,400);letter-spacing:var(--cds-body-01-letter-spacing,.16px);line-height:var(--cds-body-01-line-height,1.42857)}:host a{color:var(--cds-link-primary,#0f62fe);outline:none;text-decoration:none}@media (prefers-reduced-motion:no-preference){:host a{transition:color motion(standard,productive) 70ms}}:host a:hover{color:var(--cds-link-primary-hover,#0043ce);text-decoration:underline}:host a:focus{outline:1px solid var(--cds-focus,#0f62fe)}@media screen and (prefers-contrast){:host a:focus{outline-style:dotted}}:host a:focus{outline-color:var(--cds-focus,#0f62fe);text-decoration:underline}:host a:visited{color:var(--cds-link-primary,#0f62fe)}:host a:active{outline:1px solid var(--cds-focus,#0f62fe)}@media screen and (prefers-contrast){:host a:active{outline-style:dotted}}:host a:active{color:var(--cds-link-primary,#0f62fe);outline-color:var(--cds-focus,#0f62fe);text-decoration:underline}:host a:visited:hover{color:var(--cds-link-primary-hover,#0043ce)}:host a:active:visited,:host a:active:visited:hover{outline:1px solid var(--cds-focus,#0f62fe)}@media screen and (prefers-contrast){:host a:active:visited,:host a:active:visited:hover{outline-style:dotted}}:host a:active:visited,:host a:active:visited:hover{color:var(--cds-link-primary,#0f62fe);outline-color:var(--cds-focus,#0f62fe);text-decoration:underline}:host pre{background-color:var(--cds-layer-02,#fff);border:1px solid var(--cds-chat-bubble-border,#e0e0e0);font-family:var(--cds-code-02-font-family,\"IBM Plex Mono\",system-ui,-apple-system,BlinkMacSystemFont,\".SFNSText-Regular\",monospace);font-size:var(--cds-code-02-font-size,.875rem);font-weight:var(--cds-code-02-font-weight,400);letter-spacing:var(--cds-code-02-letter-spacing,.32px);line-height:var(--cds-code-02-line-height,1.42857);overflow:auto hidden;padding:1rem;white-space:pre-wrap}:host img{max-inline-size:100%}:host h1{font-size:var(--cds-heading-04-font-size,1.75rem);font-weight:var(--cds-heading-04-font-weight,400);letter-spacing:var(--cds-heading-04-letter-spacing,0);line-height:var(--cds-heading-04-line-height,1.28572)}:host h2{font-size:var(--cds-heading-03-font-size,1.25rem);font-weight:var(--cds-heading-03-font-weight,400);letter-spacing:var(--cds-heading-03-letter-spacing,0);line-height:var(--cds-heading-03-line-height,1.4)}:host h3{font-size:var(--cds-heading-02-font-size,1rem);font-weight:var(--cds-heading-02-font-weight,600);letter-spacing:var(--cds-heading-02-letter-spacing,0);line-height:var(--cds-heading-02-line-height,1.5)}:host h4{font-size:var(--cds-heading-01-font-size,.875rem);font-weight:var(--cds-heading-01-font-weight,600);letter-spacing:var(--cds-heading-01-letter-spacing,.16px);line-height:var(--cds-heading-01-line-height,1.42857)}:host h5{font-size:var(--cds-heading-01-font-size,.875rem);font-weight:var(--cds-heading-01-font-weight,600);letter-spacing:var(--cds-heading-01-letter-spacing,.16px);line-height:var(--cds-heading-01-line-height,1.42857)}:host h6{font-size:var(--cds-heading-01-font-size,.875rem);font-weight:var(--cds-heading-01-font-weight,600);letter-spacing:var(--cds-heading-01-letter-spacing,.16px);line-height:var(--cds-heading-01-line-height,1.42857)}:host ol,:host ul{font-size:var(--cds-body-01-font-size,.875rem);font-weight:var(--cds-body-01-font-weight,400);letter-spacing:var(--cds-body-01-letter-spacing,.16px);line-height:var(--cds-body-01-line-height,1.42857);list-style:none;margin:0;padding:0}:host li{padding-inline-start:.25rem}:host li+li{margin-block-start:.5rem}:host ul{margin-inline-start:1rem}:host ul>li{color:var(--cds-text-primary,#161616);position:relative}:host ul>li:before{content:\"–\";inset-inline-start:-1rem;position:absolute}:host ol{counter-reset:item;margin-inline-start:1rem}:host ol>li{color:var(--cds-text-primary,#161616);position:relative}:host ol>li:before{content:counter(item) \".\";counter-increment:item;inset-inline-start:-1rem;position:absolute}:host ol ol,:host ol ul,:host ul ol,:host ul ul{margin-block-start:.5rem;margin-inline-start:2rem}:host ul ul>li:before{content:\"▪\";inset-inline-start:-.75rem}:host ol ol{list-style-type:lower-latin}:host ol ol>li:before{content:counter(item,lower-latin) \".\"}:host .cds-aichat-table--square{--cds-aichat-border-radius-start-start:0;--cds-aichat-border-radius-start-end:0;--cds-aichat-border-radius-end-start:0;--cds-aichat-border-radius-end-end:0}:host cds-ordered-list cds-list-item:not([nested]){margin-inline-start:1rem}:host cds-aichat-code-snippet{display:block}:host cds-aichat-code-snippet:not(:defined){display:none}"]);
10
+ var styles = css(["@charset \"UTF-8\";:host{--cds-aichat-border-radius-start-start:0.5rem;--cds-aichat-border-radius-start-end:0.5rem;--cds-aichat-border-radius-end-start:0.5rem;--cds-aichat-border-radius-end-end:0.5rem;display:block;font-size:var(--cds-body-01-font-size,.875rem);font-weight:var(--cds-body-01-font-weight,400);inline-size:100%;letter-spacing:var(--cds-body-01-letter-spacing,.16px);line-height:var(--cds-body-01-line-height,1.42857);max-inline-size:100%}:host mark{background-color:var(--cds-highlight,#d0e2ff);border-radius:.25rem;color:var(--cds-text-primary,#161616)}:host b,:host strong{font-weight:700}:host em,:host i{font-style:italic}:host blockquote{border-inline-start:2px solid var(--cds-border-subtle-00,#e0e0e0);padding-inline-start:.5rem}:host blockquote>:not(:first-child){margin-block-start:1rem}:host blockquote>h1+:not(:first-child),:host blockquote>h2+:not(:first-child),:host blockquote>h3+:not(:first-child),:host blockquote>h4+:not(:first-child),:host blockquote>h5+:not(:first-child),:host blockquote>h6+:not(:first-child){margin-block-start:.5rem}:host .cds-aichat-markdown-stack{display:block;max-inline-size:100%}:host .cds-aichat-markdown-stack>slot{display:block}:host .cds-aichat-markdown-stack>:not(:first-child){margin-block-start:1rem}:host .cds-aichat-markdown-stack>h1+:not(:first-child),:host .cds-aichat-markdown-stack>h2+:not(:first-child),:host .cds-aichat-markdown-stack>h3+:not(:first-child),:host .cds-aichat-markdown-stack>h4+:not(:first-child),:host .cds-aichat-markdown-stack>h5+:not(:first-child),:host .cds-aichat-markdown-stack>h6+:not(:first-child){margin-block-start:.25rem}:host p{font-size:var(--cds-body-01-font-size,.875rem);font-weight:var(--cds-body-01-font-weight,400);letter-spacing:var(--cds-body-01-letter-spacing,.16px);line-height:var(--cds-body-01-line-height,1.42857)}:host a{color:var(--cds-link-primary,#0f62fe);outline:none;text-decoration:none}@media (prefers-reduced-motion:no-preference){:host a{transition:color motion(standard,productive) 70ms}}:host a:hover{color:var(--cds-link-primary-hover,#0043ce);text-decoration:underline}:host a:focus{outline:1px solid var(--cds-focus,#0f62fe)}@media screen and (prefers-contrast){:host a:focus{outline-style:dotted}}:host a:focus{outline-color:var(--cds-focus,#0f62fe);text-decoration:underline}:host a:visited{color:var(--cds-link-primary,#0f62fe)}:host a:active{outline:1px solid var(--cds-focus,#0f62fe)}@media screen and (prefers-contrast){:host a:active{outline-style:dotted}}:host a:active{color:var(--cds-link-primary,#0f62fe);outline-color:var(--cds-focus,#0f62fe);text-decoration:underline}:host a:visited:hover{color:var(--cds-link-primary-hover,#0043ce)}:host a:active:visited,:host a:active:visited:hover{outline:1px solid var(--cds-focus,#0f62fe)}@media screen and (prefers-contrast){:host a:active:visited,:host a:active:visited:hover{outline-style:dotted}}:host a:active:visited,:host a:active:visited:hover{color:var(--cds-link-primary,#0f62fe);outline-color:var(--cds-focus,#0f62fe);text-decoration:underline}:host pre{background-color:var(--cds-layer-02,#fff);border:1px solid var(--cds-chat-bubble-border,#e0e0e0);font-family:var(--cds-code-02-font-family,\"IBM Plex Mono\",system-ui,-apple-system,BlinkMacSystemFont,\".SFNSText-Regular\",monospace);font-size:var(--cds-code-02-font-size,.875rem);font-weight:var(--cds-code-02-font-weight,400);letter-spacing:var(--cds-code-02-letter-spacing,.32px);line-height:var(--cds-code-02-line-height,1.42857);overflow:auto hidden;padding:1rem;white-space:pre-wrap}:host hr{background-color:var(--cds-border-subtle-01,#c6c6c6);block-size:1px;border:0;margin:0}:host img{max-inline-size:100%}:host h1{font-size:var(--cds-heading-04-font-size,1.75rem);font-weight:var(--cds-heading-04-font-weight,400);letter-spacing:var(--cds-heading-04-letter-spacing,0);line-height:var(--cds-heading-04-line-height,1.28572)}:host h2{font-size:var(--cds-heading-03-font-size,1.25rem);font-weight:var(--cds-heading-03-font-weight,400);letter-spacing:var(--cds-heading-03-letter-spacing,0);line-height:var(--cds-heading-03-line-height,1.4)}:host h3{font-size:var(--cds-heading-02-font-size,1rem);font-weight:var(--cds-heading-02-font-weight,600);letter-spacing:var(--cds-heading-02-letter-spacing,0);line-height:var(--cds-heading-02-line-height,1.5)}:host h4{font-size:var(--cds-heading-01-font-size,.875rem);font-weight:var(--cds-heading-01-font-weight,600);letter-spacing:var(--cds-heading-01-letter-spacing,.16px);line-height:var(--cds-heading-01-line-height,1.42857)}:host h5{font-size:var(--cds-heading-01-font-size,.875rem);font-weight:var(--cds-heading-01-font-weight,600);letter-spacing:var(--cds-heading-01-letter-spacing,.16px);line-height:var(--cds-heading-01-line-height,1.42857)}:host h6{font-size:var(--cds-heading-01-font-size,.875rem);font-weight:var(--cds-heading-01-font-weight,600);letter-spacing:var(--cds-heading-01-letter-spacing,.16px);line-height:var(--cds-heading-01-line-height,1.42857)}:host ol,:host ul{font-size:var(--cds-body-01-font-size,.875rem);font-weight:var(--cds-body-01-font-weight,400);letter-spacing:var(--cds-body-01-letter-spacing,.16px);line-height:var(--cds-body-01-line-height,1.42857);list-style:none;margin:0;padding:0}:host li{padding-inline-start:.25rem}:host li+li{margin-block-start:.5rem}:host ul{margin-inline-start:1rem}:host ul>li{color:var(--cds-text-primary,#161616);position:relative}:host ul>li:before{content:\"–\";inset-inline-start:-1rem;position:absolute}:host ol{counter-reset:item;margin-inline-start:1rem}:host ol>li{color:var(--cds-text-primary,#161616);position:relative}:host ol>li:before{content:counter(item) \".\";counter-increment:item;inset-inline-start:-1rem;position:absolute}:host ol ol,:host ol ul,:host ul ol,:host ul ul{margin-block-start:.5rem;margin-inline-start:2rem}:host ul ul>li:before{content:\"▪\";inset-inline-start:-.75rem}:host ol ol{list-style-type:lower-latin}:host ol ol>li:before{content:counter(item,lower-latin) \".\"}:host .cds-aichat-table--square{--cds-aichat-border-radius-start-start:0;--cds-aichat-border-radius-start-end:0;--cds-aichat-border-radius-end-start:0;--cds-aichat-border-radius-end-end:0}:host cds-ordered-list cds-list-item:not([nested]){margin-inline-start:1rem}:host cds-aichat-code-snippet{display:block}:host cds-aichat-code-snippet:not(:defined){display:none}"]);
11
11
 
12
12
  export { styles as default };
13
13
  //# sourceMappingURL=markdown.scss.js.map
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  /*
9
- * Copyright IBM Corp. 2025
9
+ * Copyright IBM Corp. 2025, 2026
10
10
  *
11
11
  * This source code is licensed under the Apache-2.0 license found in the
12
12
  * LICENSE file in the root directory of this source tree.
@@ -53,10 +53,7 @@ function markdownItTaskLists(md) {
53
53
  listItemToken.attrs = attrs;
54
54
  const checkboxOpenToken = new state.Token("task_checkbox_open", "cds-checkbox", 1);
55
55
  checkboxOpenToken.content = "";
56
- checkboxOpenToken.attrs = [
57
- ["checked", checked ? "true" : "false"],
58
- ["disabled", "true"],
59
- ];
56
+ checkboxOpenToken.attrs = [["checked", checked ? "true" : "false"]];
60
57
  const checkboxCloseToken = new state.Token("task_checkbox_close", "cds-checkbox", -1);
61
58
  checkboxCloseToken.content = "";
62
59
  // Remove the checkbox syntax from the text
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-it-task-lists.js","sources":["../../../../../src/components/markdown/src/plugins/markdown-it-task-lists.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAOG;AAgBH,SAAS,mBAAmB,CAAC,EAAc,EAAA;AACzC,IAAA,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,YAAY,EAAE,CAAC,KAAgB,KAAI;AAC/D,QAAA,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM;AAE3B,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACtC,YAAA,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC;;AAGvB,YAAA,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,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AC,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;gBACvC,CAAC,UAAU,EAAE,MAAM,CAAC;aACrB;AAED,YAAA,MAAM,kBAAkB,GAAU,IAAI,KAAK,CAAC,KAAK,CAC/C,qBAAqB,EACrB,cAAc,EACd,EAAE,CACH;AACD,YAAA,kBAAkB,CAAC,OAAO,GAAG,EAAE;;AAG/B,YAAA,UAAU,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;;AAG9D,YAAA,QAAQ,CAAC,OAAO,CAAC,iBAAiB,CAAC;AACnC,YAAA,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC;QACnC;AAEA,QAAA,OAAO,KAAK;AACd,IAAA,CAAC,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"markdown-it-task-lists.js","sources":["../../../../../src/components/markdown/src/plugins/markdown-it-task-lists.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAOG;AAgBH,SAAS,mBAAmB,CAAC,EAAc,EAAA;AACzC,IAAA,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,YAAY,EAAE,CAAC,KAAgB,KAAI;AAC/D,QAAA,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM;AAE3B,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACtC,YAAA,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC;;AAGvB,YAAA,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;gBAC3B;YACF;;AAGA,YAAA,IAAI,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,gBAAgB,EAAE;gBACpD;YACF;AAEA,YAAA,MAAM,QAAQ,GAA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A,kBAAkB,CAAC,OAAO,GAAG,EAAE;;AAG/B,YAAA,UAAU,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;;AAG9D,YAAA,QAAQ,CAAC,OAAO,CAAC,iBAAiB,CAAC;AACnC,YAAA,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC;QACnC;AAEA,QAAA,OAAO,KAAK;AACd,IAAA,CAAC,CAAC;AACJ;;;;"}
@@ -0,0 +1,17 @@
1
+ import { TemplateResult } from "lit";
2
+ import { Directive, Part, PartInfo } from "lit/directive.js";
3
+ declare class SpreadAttrs extends Directive {
4
+ render(_attrs: Record<string, unknown>): symbol;
5
+ update(part: any, [attrs]: [Record<string, unknown>]): symbol;
6
+ }
7
+ export declare const spread: (_attrs: Record<string, unknown>) => import("lit-html/directive.js").DirectiveResult<typeof SpreadAttrs>;
8
+ export declare const sanitizeHtmlContent: (content: string) => string;
9
+ declare class HtmlContainer extends Directive {
10
+ private slotElement;
11
+ private lastOpeningHtml;
12
+ constructor(partInfo: PartInfo);
13
+ render(_openingHtml: string, _childTemplate: TemplateResult, _sanitize: boolean): symbol;
14
+ update(part: Part, [openingHtml, childTemplate, sanitize]: [string, TemplateResult, boolean]): symbol;
15
+ }
16
+ export declare const htmlContainer: (_openingHtml: string, _childTemplate: TemplateResult, _sanitize: boolean) => import("lit-html/directive.js").DirectiveResult<typeof HtmlContainer>;
17
+ export {};
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import DOMPurify from 'dompurify';
9
+ import { nothing, render } from 'lit';
10
+ import { directive, Directive, PartType } from 'lit/directive.js';
11
+ import { HTML_CONTAINER_SLOT } from './html-helpers.js';
12
+
13
+ /*
14
+ * Copyright IBM Corp. 2025, 2026
15
+ *
16
+ * This source code is licensed under the Apache-2.0 license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ *
19
+ * @license
20
+ */
21
+ // Generic attribute spread for Lit templates
22
+ class SpreadAttrs extends Directive {
23
+ render(_attrs) {
24
+ return nothing;
25
+ }
26
+ update(part, [attrs]) {
27
+ const el = part.element;
28
+ for (const [k, v] of Object.entries(attrs ?? {})) {
29
+ if (v === false || v === null || v === undefined) {
30
+ el.removeAttribute(k);
31
+ }
32
+ else if (v === true) {
33
+ el.setAttribute(k, "");
34
+ }
35
+ else {
36
+ el.setAttribute(k, String(v));
37
+ }
38
+ }
39
+ return nothing;
40
+ }
41
+ }
42
+ const spread = directive(SpreadAttrs);
43
+ const sanitizeHtmlContent = (content) => DOMPurify.sanitize(content, {
44
+ ADD_ATTR: ["data-aichat-markdown"],
45
+ CUSTOM_ELEMENT_HANDLING: {
46
+ tagNameCheck: () => true, // Allow custom elements
47
+ attributeNameCheck: () => true,
48
+ allowCustomizedBuiltInElements: true,
49
+ },
50
+ });
51
+ class HtmlContainer extends Directive {
52
+ constructor(partInfo) {
53
+ super(partInfo);
54
+ this.slotElement = null;
55
+ this.lastOpeningHtml = "";
56
+ if (partInfo.type !== PartType.ELEMENT) {
57
+ throw new Error("HtmlContainer must be used on an element");
58
+ }
59
+ }
60
+ render(_openingHtml, _childTemplate, _sanitize) {
61
+ return nothing;
62
+ }
63
+ update(part, [openingHtml, childTemplate, sanitize]) {
64
+ const host = part.element;
65
+ if (!this.slotElement || this.lastOpeningHtml !== openingHtml) {
66
+ this.lastOpeningHtml = openingHtml;
67
+ let content = `${openingHtml}${HTML_CONTAINER_SLOT}`;
68
+ if (sanitize && content) {
69
+ content = sanitizeHtmlContent(content);
70
+ }
71
+ const fragment = document.createRange().createContextualFragment(content);
72
+ host.replaceChildren(...Array.from(fragment.childNodes));
73
+ this.slotElement = host.querySelector("[data-aichat-markdown]");
74
+ }
75
+ if (this.slotElement) {
76
+ render(childTemplate, this.slotElement);
77
+ }
78
+ return nothing;
79
+ }
80
+ }
81
+ const htmlContainer = directive(HtmlContainer);
82
+
83
+ export { htmlContainer, sanitizeHtmlContent, spread };
84
+ //# sourceMappingURL=lit-directives.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lit-directives.js","sources":["../../../../../src/components/markdown/src/utils/lit-directives.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;AAOG;AAeH;AACA,MAAM,WAAY,SAAQ,SAAS,CAAA;AACjC,IAAA,MAAM,CAAC,MAA+B,EAAA;AACpC,QAAA,OAAO,OAAO;IAChB;AACA,IAAA,MAAM,CAAC,IAAS,EAAE,CAAC,KAAK,CAA4B,EAAA;AAClD,QAAA,MAAM,EAAE,GAAG,IAAI,CAAC,OAAkB;AAClC,QAAA,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE;AAChD,YAAA,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,EAAE;AAChD,gBAAA,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;YACvB;AAAO,iBAAA,IAAI,CAAC,KAAK,IAAI,EAAE;AACrB,gBAAA,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,EAAE,CAAC;YACxB;iBAAO;gBACL,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;YAC/B;QACF;AACA,QAAA,OAAO,OAAO;IAChB;AACD;MAEY,MAAM,GAAG,SAAS,CAAC,WAAW;AAEpC,MAAM,mBAAmB,GAAG,CAAC,OAAe,KACjD,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE;IAC1B,QAAQ,EAAE,CAAC,sBAAsB,CAAC;AAClC,IAAA,uBAAuB,EAAE;AACvB,QAAA,YAAY,EAAE,MAAM,IAAI;AACxB,QAAA,kBAAkB,EAAE,MAAM,IA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AAC,WAAW,CAAC;QACzC;AAEA,QAAA,OAAO,OAAO;IAChB;AACD;MAEY,aAAa,GAAG,SAAS,CAAC,aAAa;;;;"}
@@ -0,0 +1,33 @@
1
+ import { TemplateResult } from "lit";
2
+ import MarkdownIt, { Token } from "markdown-it";
3
+ import { type TokenTree } from "../markdown-token-tree.js";
4
+ import type { RenderTokenTreeOptions } from "../markdown-renderer-types.js";
5
+ /**
6
+ * True when the renderer can dispatch `token` itself (hand-written Lit
7
+ * template). False when an unknown plugin-introduced token type or tag should
8
+ * route through `md.renderer.render()`.
9
+ */
10
+ export declare function isNativelyHandled(token: Partial<Token>): boolean;
11
+ /**
12
+ * True when the token's type is in the curated delegation allow-list and a
13
+ * user-supplied markdown-it plugin has overridden (or added) the matching
14
+ * `md.renderer.rules[type]`. Native dispatch sites consult this to decide
15
+ * whether to route through `md.renderer.render()` instead of the hand-written
16
+ * Lit template.
17
+ */
18
+ export declare function shouldDelegateToPluginRule(token: Partial<Token>, md: MarkdownIt | undefined): boolean;
19
+ /**
20
+ * Renders an unknown token via markdown-it's HTML renderer and emits a named
21
+ * `<slot>` placeholder. The markdown element adopts a light-DOM
22
+ * `<div slot="…">` host containing the sanitized HTML so consumer-supplied
23
+ * CSS (e.g. KaTeX's stylesheet) reaches the rendered output.
24
+ *
25
+ * For leaf token types in {@link PLUGIN_DELEGABLE_TOKEN_TYPES} the rendered
26
+ * HTML is cached on the {@link TokenTree} node and inherited across
27
+ * `diffTokenTree` calls when the underlying token is unchanged — so a stable
28
+ * earlier-in-document fence/image/etc. doesn't re-invoke the plugin's rule on
29
+ * every streaming chunk. The cache is tagged with the `MarkdownIt` instance
30
+ * that produced it; a plugin swap (which builds a fresh instance) invalidates
31
+ * the cache automatically.
32
+ */
33
+ export declare function renderFallback(token: Token, node: TokenTree, md: MarkdownIt, sanitize: boolean, options: RenderTokenTreeOptions): TemplateResult;
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { html } from 'lit';
9
+ import { PLUGIN_DELEGABLE_TOKEN_TYPES, getPluginOverriddenRules } from '../markdown-token-tree.js';
10
+ import { sanitizeHtmlContent } from './lit-directives.js';
11
+
12
+ /*
13
+ * Copyright IBM Corp. 2025, 2026
14
+ *
15
+ * This source code is licensed under the Apache-2.0 license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ *
18
+ * @license
19
+ */
20
+ /**
21
+ * Slot-name prefix shared by every plugin-fallback descriptor. The element
22
+ * suffixes a render-scoped sequence number; the markdown component uses this
23
+ * prefix when adopting the light-DOM host so external observers can target
24
+ * plugin output with CSS or query selectors.
25
+ *
26
+ * @internal
27
+ */
28
+ const PLUGIN_FALLBACK_SLOT_PREFIX = "cds-aichat-markdown-renderer-pluginFallback";
29
+ // Token types our hand-written renderer handles natively (no markdown-it
30
+ // fallback needed).
31
+ const NATIVELY_HANDLED_TOKEN_TYPES = new Set([
32
+ "root",
33
+ "text",
34
+ "code_inline",
35
+ "fence",
36
+ "html_block",
37
+ "html_inline",
38
+ "html_container",
39
+ "inline",
40
+ "hr",
41
+ "thematic_break",
42
+ ]);
43
+ // HTML tags whose paired open/close (or self-contained leaf) is rendered by
44
+ // `renderWithStaticTag`. Anything else falls through to the markdown-it
45
+ // renderer fallback.
46
+ const NATIVELY_HANDLED_TAGS = new Set([
47
+ "p",
48
+ "blockquote",
49
+ "pre",
50
+ "hr",
51
+ "h1",
52
+ "h2",
53
+ "h3",
54
+ "h4",
55
+ "h5",
56
+ "h6",
57
+ "ul",
58
+ "ol",
59
+ "li",
60
+ "cds-checkbox",
61
+ "strong",
62
+ "em",
63
+ "code",
64
+ "del",
65
+ "sub",
66
+ "sup",
67
+ "span",
68
+ "i",
69
+ "b",
70
+ "small",
71
+ "mark",
72
+ "ins",
73
+ "s",
74
+ "kbd",
75
+ "var",
76
+ "samp",
77
+ "cite",
78
+ "abbr",
79
+ "dfn",
80
+ "time",
81
+ "q",
82
+ "a",
83
+ "table",
84
+ "img",
85
+ // Table internals — their open/close pairs are walked into via children.
86
+ "thead",
87
+ "tbody",
88
+ "tr",
89
+ "th",
90
+ "td",
91
+ // Task-list checkbox input element produced by markdown-it-task-lists.
92
+ "input",
93
+ ]);
94
+ /**
95
+ * True when the renderer can dispatch `token` itself (hand-written Lit
96
+ * template). False when an unknown plugin-introduced token type or tag should
97
+ * route through `md.renderer.render()`.
98
+ */
99
+ function isNativelyHandled(token) {
100
+ if (token.type && NATIVELY_HANDLED_TOKEN_TYPES.has(token.type)) {
101
+ return true;
102
+ }
103
+ if (token.tag && NATIVELY_HANDLED_TAGS.has(token.tag)) {
104
+ return true;
105
+ }
106
+ return false;
107
+ }
108
+ /**
109
+ * True when the token's type is in the curated delegation allow-list and a
110
+ * user-supplied markdown-it plugin has overridden (or added) the matching
111
+ * `md.renderer.rules[type]`. Native dispatch sites consult this to decide
112
+ * whether to route through `md.renderer.render()` instead of the hand-written
113
+ * Lit template.
114
+ */
115
+ function shouldDelegateToPluginRule(token, md) {
116
+ if (!token.type || !md) {
117
+ return false;
118
+ }
119
+ if (!PLUGIN_DELEGABLE_TOKEN_TYPES.has(token.type)) {
120
+ return false;
121
+ }
122
+ return getPluginOverriddenRules(md).has(token.type);
123
+ }
124
+ function synthesizeCloseToken(openToken) {
125
+ const closeType = openToken.type.replace(/_open$/, "_close");
126
+ return {
127
+ type: closeType,
128
+ tag: openToken.tag,
129
+ nesting: -1,
130
+ level: Math.max(0, openToken.level - 1),
131
+ content: "",
132
+ attrs: null,
133
+ children: null,
134
+ markup: openToken.markup,
135
+ block: openToken.block,
136
+ hidden: false,
137
+ map: null,
138
+ info: "",
139
+ meta: null,
140
+ };
141
+ }
142
+ /**
143
+ * Re-emits the original flat markdown-it token sequence beneath `node` so the
144
+ * sequence can be passed to `md.renderer.render()`. `inline` tokens are emitted
145
+ * as-is (markdown-it's renderer reads their `.children` directly).
146
+ */
147
+ function flattenSubtree(node) {
148
+ const tokens = [];
149
+ for (const child of node.children) {
150
+ const t = child.token;
151
+ if (t.type === "inline") {
152
+ tokens.push(t);
153
+ }
154
+ else if (t.nesting === 1) {
155
+ tokens.push(t);
156
+ tokens.push(...flattenSubtree(child));
157
+ tokens.push(synthesizeCloseToken(t));
158
+ }
159
+ else {
160
+ tokens.push(t);
161
+ }
162
+ }
163
+ return tokens;
164
+ }
165
+ /**
166
+ * Builds the flat token slice to hand to `md.renderer.render()` for a token the
167
+ * native renderer doesn't handle. Leaf tokens render alone; paired-container
168
+ * opens reassemble `[open, ...children, close]` from the tree.
169
+ */
170
+ function sliceForFallback(token, node) {
171
+ if (token.nesting === 1) {
172
+ return [token, ...flattenSubtree(node), synthesizeCloseToken(token)];
173
+ }
174
+ return [token];
175
+ }
176
+ /**
177
+ * Renders an unknown token via markdown-it's HTML renderer and emits a named
178
+ * `<slot>` placeholder. The markdown element adopts a light-DOM
179
+ * `<div slot="…">` host containing the sanitized HTML so consumer-supplied
180
+ * CSS (e.g. KaTeX's stylesheet) reaches the rendered output.
181
+ *
182
+ * For leaf token types in {@link PLUGIN_DELEGABLE_TOKEN_TYPES} the rendered
183
+ * HTML is cached on the {@link TokenTree} node and inherited across
184
+ * `diffTokenTree` calls when the underlying token is unchanged — so a stable
185
+ * earlier-in-document fence/image/etc. doesn't re-invoke the plugin's rule on
186
+ * every streaming chunk. The cache is tagged with the `MarkdownIt` instance
187
+ * that produced it; a plugin swap (which builds a fresh instance) invalidates
188
+ * the cache automatically.
189
+ */
190
+ function renderFallback(token, node, md, sanitize, options) {
191
+ let safe;
192
+ if (node?.cachedHtml && node.cachedHtml.md === md) {
193
+ safe = node.cachedHtml.html;
194
+ }
195
+ else {
196
+ const slice = sliceForFallback(token, node);
197
+ const htmlStr = md.renderer.render(slice, md.options, {});
198
+ safe = sanitize ? sanitizeHtmlContent(htmlStr) : htmlStr;
199
+ if (node &&
200
+ typeof token.type === "string" &&
201
+ PLUGIN_DELEGABLE_TOKEN_TYPES.has(token.type)) {
202
+ node.cachedHtml = { md, html: safe };
203
+ }
204
+ }
205
+ const index = options.pluginSlotCounter?.next() ?? 0;
206
+ const slotName = `${PLUGIN_FALLBACK_SLOT_PREFIX}-${index}`;
207
+ options.recordCustomRender?.({
208
+ slotName,
209
+ kind: "pluginFallback",
210
+ token,
211
+ node,
212
+ html: safe,
213
+ isInline: token.block === false,
214
+ });
215
+ return html `<slot name=${slotName}></slot>`;
216
+ }
217
+
218
+ export { PLUGIN_FALLBACK_SLOT_PREFIX, isNativelyHandled, renderFallback, shouldDelegateToPluginRule };
219
+ //# sourceMappingURL=plugin-fallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-fallback.js","sources":["../../../../../src/components/markdown/src/utils/plugin-fallback.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;;;AAOG;AAaH;;;;;;;AAOG;AACI,MAAM,2BAA2B,GACtC;AAEF;AACA;AACA,MAAM,4BAA4B,GAAG,IAAI,GAAG,CAAS;IACnD,MAAM;IACN,MAAM;IACN,aAAa;IACb,OAAO;IACP,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,QAAQ;IACR,IAAI;IACJ,gBAAgB;AACjB,CAAA,CAAC;AAEF;AACA;AACA;AACA,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAS;IAC5C,GAAG;IACH,YAAY;IACZ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,cAAc;IACd,QAAQ;IACR,IAAI;IACJ,MAAM;IACN,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,GAAG;IACH,GAAG;IACH,OAAO;IACP,MAAM;IACN,KAAK;IACL,GAAG;IACH,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;IACL,MAAM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AY;AAChB,IAAA,IAAI,IAAI,EAAE,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE;AACjD,QAAA,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI;IAC7B;SAAO;QACL,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC;AAC3C,QAAA,MAAM,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC;AACzD,QAAA,IAAI,GAAG,QAAQ,GAAG,mBAAmB,CAAC,OAAO,CAAC,GAAG,OAAO;AACxD,QAAA,IACE,IAAI;AACJ,YAAA,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;YAC9B,4BAA4B,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAC5C;YACA,IAAI,CAAC,UAAU,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;QACtC;IACF;IAEA,MAAM,KAAK,GAAG,OAAO,CAAC,iBAAiB,EAAE,IAAI,EAAE,IAAI,CAAC;AACpD,IAAA,MAAM,QAAQ,GAAG,CAAA,EAAG,2BAA2B,CAAA,CAAA,EAAI,KAAK,EAAE;IAC1D,OAAO,CAAC,kBAAkB,GAAG;QAC3B,QAAQ;AACR,QAAA,IAAI,EAAE,gBAAgB;QACtB,KAAK;QACL,IAAI;AACJ,QAAA,IAAI,EAAE,IAAI;AACV,QAAA,QAAQ,EAAE,KAAK,CAAC,KAAK,KAAK,KAAK;AAChC,KAAA,CAAC;AACF,IAAA,OAAO,IAAI,CAAA,CAAA,WAAA,EAAc,QAAQ,UAAU;AAC7C;;;;"}
@@ -0,0 +1,28 @@
1
+ import type { TokenTree } from "../markdown-token-tree.js";
2
+ /**
3
+ * True if the right-most leaf of the tree is a `table` token. A trailing table
4
+ * is one that sits at the end of the current markdown output, not just at the
5
+ * end of an arbitrary subtree — so we follow only the rightmost branch.
6
+ */
7
+ export declare function hasTrailingTableToken(node: TokenTree): boolean;
8
+ /**
9
+ * True if any table token in the tree has a sibling that follows it. Used to
10
+ * detect that the streaming author has moved past a table, so we can exit the
11
+ * "table loading" hold and render the live table.
12
+ */
13
+ export declare function hasNodeAfterTable(node: TokenTree): boolean;
14
+ /**
15
+ * True when a table at `currentIndex` inside `parentChildren` has no
16
+ * siblings after it — i.e. it is currently the last child of its parent.
17
+ * The streaming-table renderer uses this to decide whether the live table
18
+ * should show its skeleton/loading state.
19
+ */
20
+ export declare function isTableAtStreamingTail(parentChildren: readonly unknown[], currentIndex: number): boolean;
21
+ /**
22
+ * Heuristic that returns true when the last non-empty line of the markdown
23
+ * source looks like an in-progress table row or separator. markdown-it can
24
+ * momentarily stop recognizing the table token while a row is half-written, so
25
+ * the streaming-table hold uses this to avoid flickering between table and
26
+ * non-table renderings.
27
+ */
28
+ export declare function hasLikelyPartialTableTail(markdown: string): boolean;
@@ -0,0 +1,86 @@
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
+ * Copyright IBM Corp. 2025, 2026
10
+ *
11
+ * This source code is licensed under the Apache-2.0 license found in the
12
+ * LICENSE file in the root directory of this source tree.
13
+ *
14
+ * @license
15
+ */
16
+ /**
17
+ * True if the right-most leaf of the tree is a `table` token. A trailing table
18
+ * is one that sits at the end of the current markdown output, not just at the
19
+ * end of an arbitrary subtree — so we follow only the rightmost branch.
20
+ */
21
+ function hasTrailingTableToken(node) {
22
+ if (node.token.tag === "table") {
23
+ return true;
24
+ }
25
+ const children = node.children || [];
26
+ if (children.length === 0) {
27
+ return false;
28
+ }
29
+ return hasTrailingTableToken(children[children.length - 1]);
30
+ }
31
+ /**
32
+ * True if any table token in the tree has a sibling that follows it. Used to
33
+ * detect that the streaming author has moved past a table, so we can exit the
34
+ * "table loading" hold and render the live table.
35
+ */
36
+ function hasNodeAfterTable(node) {
37
+ const children = node.children || [];
38
+ for (let index = 0; index < children.length; index++) {
39
+ const child = children[index];
40
+ if (child.token.tag === "table" && index < children.length - 1) {
41
+ return true;
42
+ }
43
+ if (hasNodeAfterTable(child)) {
44
+ return true;
45
+ }
46
+ }
47
+ return false;
48
+ }
49
+ /**
50
+ * True when a table at `currentIndex` inside `parentChildren` has no
51
+ * siblings after it — i.e. it is currently the last child of its parent.
52
+ * The streaming-table renderer uses this to decide whether the live table
53
+ * should show its skeleton/loading state.
54
+ */
55
+ function isTableAtStreamingTail(parentChildren, currentIndex) {
56
+ return currentIndex >= parentChildren.length - 1;
57
+ }
58
+ /**
59
+ * Heuristic that returns true when the last non-empty line of the markdown
60
+ * source looks like an in-progress table row or separator. markdown-it can
61
+ * momentarily stop recognizing the table token while a row is half-written, so
62
+ * the streaming-table hold uses this to avoid flickering between table and
63
+ * non-table renderings.
64
+ */
65
+ function hasLikelyPartialTableTail(markdown) {
66
+ const normalized = markdown.replace(/\r/g, "");
67
+ const lines = normalized.split("\n");
68
+ let index = lines.length - 1;
69
+ while (index >= 0 && lines[index].trim() === "") {
70
+ index--;
71
+ }
72
+ if (index < 0) {
73
+ return false;
74
+ }
75
+ const lastLine = lines[index].trim();
76
+ // During streaming, partially emitted table rows frequently end with a pipe
77
+ // and markdown-it can temporarily stop recognizing the table token.
78
+ if (lastLine.startsWith("|") || lastLine.endsWith("|")) {
79
+ return true;
80
+ }
81
+ // Keep loading mode if the tail still looks like a table separator row.
82
+ return /^\|?[\s:-]+(\|[\s:-]+)+\|?$/.test(lastLine);
83
+ }
84
+
85
+ export { hasLikelyPartialTableTail, hasNodeAfterTable, hasTrailingTableToken, isTableAtStreamingTail };
86
+ //# sourceMappingURL=streaming-table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streaming-table.js","sources":["../../../../../src/components/markdown/src/utils/streaming-table.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAOG;AA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,CAAC;AACpC,IAAA,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC;AAE5B,IAAA,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;AAC/C,QAAA,KAAK,EAAE;IACT;AAEA,IAAA,IAAI,KAAK,GAAG,CAAC,EAAE;AACb,QAAA,OAAO,KAAK;IACd;IAEA,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE;;;AAIpC,IAAA,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AACtD,QAAA,OAAO,IAAI;IACb;;AAGA,IAAA,OAAO,6BAA6B,CAAC,IAAI,CAAC,QAAQ,CAAC;AACrD;;;;"}
@@ -1,3 +1,6 @@
1
+ import { TemplateResult } from "lit";
2
+ import type { Token } from "markdown-it";
3
+ import type { RenderTokenTreeOptions } from "../markdown-renderer-types.js";
1
4
  import type { TokenTree } from "../markdown-token-tree";
2
5
  export declare const DEFAULT_PAGINATION_SUPPLEMENTAL_TEXT: ({ count, }: {
3
6
  count: number;
@@ -29,3 +32,17 @@ export declare function extractTableData(tableNode: TokenTree): {
29
32
  * text content without HTML formatting.
30
33
  */
31
34
  export declare function extractTextContent(node: TokenTree): string;
35
+ /**
36
+ * Renders the body of the `case "table"` branch of `renderWithStaticTag`.
37
+ *
38
+ * Lives outside the renderer's switch because it covers three flows: streaming
39
+ * loading state, default Carbon-table rendering, and the `customRenderers.table`
40
+ * slot override.
41
+ *
42
+ * `renderToken` is the recursive renderer the caller dispatched from, passed in
43
+ * to avoid a cycle with `markdown-renderer.ts`. `slotName` is non-undefined when
44
+ * the consumer registered a `table` custom renderer, in which case the result is
45
+ * wrapped in a named `<slot>` and an override descriptor is reported via
46
+ * `recordCustomRender`.
47
+ */
48
+ export declare function renderTable(token: Token, node: TokenTree, attrs: Record<string, string>, options: RenderTokenTreeOptions, renderToken: (node: TokenTree, options: RenderTokenTreeOptions) => TemplateResult, slotName: string | undefined): TemplateResult;