@box/box-ai-content-answers 1.1.4 → 1.2.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.
@@ -1,11 +1,11 @@
1
1
  import i from "clsx";
2
- import _ from "../common/markdown-react.js";
3
- import f from "../common/markdown.js";
2
+ import { markdownToHtmlString as _ } from "../common/markdown.js";
3
+ import f from "../common/markdown-react.js";
4
4
  import { jsxs as h, Fragment as u, jsx as r } from "react/jsx-runtime";
5
- import '../../../../styles/answer-content.css';const C = "_answerContent_uoab3_1", x = "_answerMarkdown_uoab3_16", n = {
5
+ import '../../../../styles/answer-content.css';const C = "_answerContent_uoab3_1", k = "_answerMarkdown_uoab3_16", n = {
6
6
  answerContent: C,
7
- answerMarkdown: x
8
- }, v = ({
7
+ answerMarkdown: k
8
+ }, g = ({
9
9
  answer: e,
10
10
  isMarkdownEnabled: t,
11
11
  isReactMarkdownEnabled: w = !1,
@@ -13,15 +13,15 @@ import '../../../../styles/answer-content.css';const C = "_answerContent_uoab3_1
13
13
  variant: m = "modal",
14
14
  ...s
15
15
  }) => {
16
- const a = m === "sidebar", c = (d) => {
16
+ const a = m === "sidebar", l = (d) => {
17
17
  if (w)
18
- return /* @__PURE__ */ r(_, {
18
+ return /* @__PURE__ */ r(f, {
19
19
  children: d
20
20
  });
21
- const l = f.render(d);
21
+ const c = _(d);
22
22
  return /* @__PURE__ */ r("div", {
23
23
  dangerouslySetInnerHTML: {
24
- __html: l
24
+ __html: c
25
25
  }
26
26
  });
27
27
  };
@@ -33,11 +33,11 @@ import '../../../../styles/answer-content.css';const C = "_answerContent_uoab3_1
33
33
  }), t && e && /* @__PURE__ */ r("div", {
34
34
  className: i(n.answerContent, n.answerMarkdown, a && n.sidebar, "Answer-text", o),
35
35
  ...s,
36
- children: c(e)
36
+ children: l(e)
37
37
  })]
38
38
  });
39
39
  };
40
40
  export {
41
- v as AnswerContent,
42
- v as default
41
+ g as AnswerContent,
42
+ g as default
43
43
  };
@@ -1,43 +1,53 @@
1
- import { useNotification as n, Tooltip as l, IconButton as m } from "@box/blueprint-web";
1
+ import { useNotification as l, Tooltip as m, IconButton as d } from "@box/blueprint-web";
2
2
  import { Clipboard as u } from "@box/blueprint-web-assets/icons/Line";
3
- import { useIntl as d } from "react-intl";
3
+ import { useIntl as b } from "react-intl";
4
4
  import f from "../../messages.js";
5
- import { LOGGER_BASE_CONFIG as b, LOGGER_ACTION_CLICK as C } from "../common/constants.js";
6
- import t from "./messages.js";
7
- import { focusInput as T } from "../common/focusInputUtils.js";
8
- import { jsx as s } from "react/jsx-runtime";
5
+ import { LOGGER_BASE_CONFIG as C, LOGGER_ACTION_CLICK as g } from "../common/constants.js";
6
+ import { focusInput as y } from "../common/focusInputUtils.js";
7
+ import { markdownToHtmlString as T } from "../common/markdown.js";
8
+ import a from "./messages.js";
9
+ import { jsx as n } from "react/jsx-runtime";
9
10
  const N = ({
10
- answer: i,
11
- onAnswerCopy: a,
12
- recordAction: r
11
+ answer: t,
12
+ onAnswerCopy: r,
13
+ recordAction: e
13
14
  }) => {
14
15
  const {
15
16
  formatMessage: o
16
- } = d(), {
17
- addNotification: c
18
- } = n(), p = () => {
19
- r && r({
20
- ...b,
21
- action: C,
17
+ } = b(), {
18
+ addNotification: s
19
+ } = l(), p = async () => {
20
+ if (e && e({
21
+ ...C,
22
+ action: g,
22
23
  target: "copyToClipboard"
23
- }), i && navigator && navigator.clipboard && navigator.clipboard.writeText && navigator.clipboard.writeText(i).then(() => {
24
- c({
24
+ }), t && navigator && navigator.clipboard && navigator.clipboard.write) {
25
+ const i = T(t), c = new ClipboardItem({
26
+ "text/html": new Blob([i], {
27
+ type: "text/html"
28
+ }),
29
+ "text/plain": new Blob([t], {
30
+ type: "text/plain"
31
+ })
32
+ });
33
+ await navigator.clipboard.write([c]), s({
25
34
  sensitivity: "foreground",
26
- styledText: o(t.copyToClipboardSucceeded),
35
+ styledText: o(a.copyToClipboardSucceeded),
27
36
  variant: "success",
28
- typeIconAriaLabel: o(t.copyButtonSuccessText),
37
+ typeIconAriaLabel: o(a.copyButtonSuccessText),
29
38
  closeButtonAriaLabel: o(f.closeButtonText)
30
- }), a && a(i);
31
- }), T();
39
+ }), r && r(t);
40
+ }
41
+ y();
32
42
  };
33
- return /* @__PURE__ */ s(l, {
34
- content: o(t.copyToClipboard),
35
- children: /* @__PURE__ */ s(m, {
36
- "aria-label": o(t.copyToClipboard),
43
+ return /* @__PURE__ */ n(m, {
44
+ content: o(a.copyToClipboard),
45
+ children: /* @__PURE__ */ n(d, {
46
+ "aria-label": o(a.copyToClipboard),
37
47
  icon: u,
38
48
  onClick: p,
39
- onFocusCapture: (e) => {
40
- e.target.matches(":focus-visible") || e.stopPropagation();
49
+ onFocusCapture: (i) => {
50
+ i.target.matches(":focus-visible") || i.stopPropagation();
41
51
  },
42
52
  size: "x-small",
43
53
  "data-target-id": "IconButton-copyToClipboard"
@@ -1057,11 +1057,11 @@ https://github.com/highlightjs/highlight.js/issues/2277`), U = u, k = f), w ===
1057
1057
  for (const u in Ae)
1058
1058
  typeof Ae[u] == "object" && ut(Ae[u]);
1059
1059
  return Object.assign(n, Ae), n;
1060
- }, he = Tt({});
1061
- he.newInstance = () => Tt({});
1062
- var yr = he;
1063
- he.HighlightJS = he;
1064
- he.default = he;
1060
+ }, Ne = Tt({});
1061
+ Ne.newInstance = () => Tt({});
1062
+ var yr = Ne;
1063
+ Ne.HighlightJS = Ne;
1064
+ Ne.default = Ne;
1065
1065
  var De, Mn;
1066
1066
  function Tr() {
1067
1067
  if (Mn) return De;
@@ -10658,15 +10658,15 @@ function jr() {
10658
10658
  end: /\//,
10659
10659
  contains: ge
10660
10660
  }, re = ($) => {
10661
- const Re = t($, /\//), Ne = t(/\//, $);
10661
+ const Re = t($, /\//), ye = t(/\//, $);
10662
10662
  return {
10663
10663
  begin: Re,
10664
- end: Ne,
10664
+ end: ye,
10665
10665
  contains: [
10666
10666
  ...ge,
10667
10667
  {
10668
10668
  scope: "comment",
10669
- begin: `#(?!.*${Ne})`,
10669
+ begin: `#(?!.*${ye})`,
10670
10670
  end: /$/
10671
10671
  }
10672
10672
  ]
@@ -10884,7 +10884,7 @@ function jr() {
10884
10884
  for (const $ of oe.variants) {
10885
10885
  const Re = $.contains.find((Ot) => Ot.label === "interpol");
10886
10886
  Re.keywords = u;
10887
- const Ne = [
10887
+ const ye = [
10888
10888
  ...f,
10889
10889
  ...U,
10890
10890
  ...te,
@@ -10893,13 +10893,13 @@ function jr() {
10893
10893
  ...G
10894
10894
  ];
10895
10895
  Re.contains = [
10896
- ...Ne,
10896
+ ...ye,
10897
10897
  {
10898
10898
  begin: /\(/,
10899
10899
  end: /\)/,
10900
10900
  contains: [
10901
10901
  "self",
10902
- ...Ne
10902
+ ...ye
10903
10903
  ]
10904
10904
  }
10905
10905
  ];
@@ -12130,7 +12130,7 @@ R.registerLanguage("wasm", ra());
12130
12130
  R.HighlightJS = R;
12131
12131
  R.default = R;
12132
12132
  var aa = R;
12133
- const Me = /* @__PURE__ */ At(aa), ye = new wt({
12133
+ const Me = /* @__PURE__ */ At(aa), he = new wt({
12134
12134
  breaks: !1,
12135
12135
  html: !1,
12136
12136
  linkTarget: "_blank",
@@ -12147,9 +12147,9 @@ const Me = /* @__PURE__ */ At(aa), ye = new wt({
12147
12147
  return "";
12148
12148
  }
12149
12149
  });
12150
- ye.renderer.rules.table_open = () => `<div class="${fe.tableWrapper}" tabindex="0"><table>`;
12151
- ye.renderer.rules.table_close = () => "</table></div>";
12152
- ye.renderer.rules.link_open = (n, e) => {
12150
+ he.renderer.rules.table_open = () => `<div class="${fe.tableWrapper}" tabindex="0"><table>`;
12151
+ he.renderer.rules.table_close = () => "</table></div>";
12152
+ he.renderer.rules.link_open = (n, e) => {
12153
12153
  const {
12154
12154
  href: t
12155
12155
  } = n[e];
@@ -12159,10 +12159,11 @@ ye.renderer.rules.link_open = (n, e) => {
12159
12159
  } catch {
12160
12160
  a = "", c = !1;
12161
12161
  } finally {
12162
- c ? ye.renderer.rules.link_close = () => "</a>" : ye.renderer.rules.link_close = () => ` (${t})`;
12162
+ c ? he.renderer.rules.link_close = () => "</a>" : he.renderer.rules.link_close = () => ` (${t})`;
12163
12163
  }
12164
12164
  return a;
12165
12165
  };
12166
+ const ca = (n) => he.render(n);
12166
12167
  export {
12167
- ye as default
12168
+ ca as markdownToHtmlString
12168
12169
  };
@@ -30,6 +30,7 @@ export declare const citationsFromHubsMetadata: {
30
30
  export declare const answerWithLargeTable = "\n| English | Spanish | French | German | Italian | Portuguese | Dutch | Russian | Japanese | Color | Origin | Taste | Uses | Season | Nutritional Benefits |\n|---------------|---------------|---------------|--------------|--------------|--------------|--------------|--------------|--------------|--------------|--------------|--------------|---------------------|------------------|-------------------------------------------|\n| Apple | Manzana | Pomme | Apfel | Mela | Ma\u00E7\u00E3 | Appel | \u042F\u0431\u043B\u043E\u043A\u043E | \u308A\u3093\u3054 | Red | Europe | Sweet | Eating, Cooking | Autumn | High in fiber, vitamin C |\n| Banana | Pl\u00E1tano | Banane | Banane | Banana | Banana | Banaan | \u0411\u0430\u043D\u0430\u043D | \u30D0\u30CA\u30CA | Yellow | Tropical | Sweet | Eating, Smoothies | Year-round | High in potassium, vitamin B6 |\n| Orange | Naranja | Orange | Orange | Arancia | Laranja | Sinaasappel | \u0410\u043F\u0435\u043B\u044C\u0441\u0438\u043D | \u30AA\u30EC\u30F3\u30B8 | Orange | Asia | Tangy | Juice, Eating | Winter | High in vitamin C, antioxidants |\n| Grape | Uva | Raisin | Traube | Uva | Uva | Druif | \u0412\u0438\u043D\u043E\u0433\u0440\u0430\u0434 | \u3076\u3069\u3046 | Purple | Europe | Sweet | Eating, Wine | Autumn | High in antioxidants |\n| Strawberry | Fresa | Fraisier | Erdbeere | Fragola | Morango | Aardbei | \u041A\u043B\u0443\u0431\u043D\u0438\u043A\u0430 | \u3044\u3061\u3054 | Red | Europe | Sweet | Eating, Desserts | Spring | High in vitamin C, fiber |\n| Blueberry | Ar\u00E1ndano | Myrtille | Heidelbeere | Mirtillo | Mirtilo | Bosbes | \u0413\u043E\u043B\u0443\u0431\u0438\u043A\u0430 | \u30D6\u30EB\u30FC\u30D9\u30EA\u30FC | Blue | North America| Sweet | Eating, Baking | Summer | High in antioxidants |\n| Lemon | Lim\u00F3n | Citron | Zitrone | Limone | Lim\u00E3o | Citroen | \u041B\u0438\u043C\u043E\u043D | \u30EC\u30E2\u30F3 | Yellow | Asia | Sour | Juice, Cooking | Year-round | High in vitamin C, aids digestion |\n| Pineapple | Pi\u00F1a | Ananas | Ananas | Ananas | Abacaxi | Ananas | \u0410\u043D\u0430\u043D\u0430\u0441 | \u30D1\u30A4\u30CA\u30C3\u30D7\u30EB | Brown/Yellow | South America| Sweet | Eating, Juicing | Summer | Rich in vitamin C, aids digestion |\n| Watermelon | Sand\u00EDa | Past\u00E8que | Wassermelone | Anguria | Melancia | Watermeloen | \u0410\u0440\u0431\u0443\u0437 | \u30B9\u30A4\u30AB | Green/Red | Africa | Sweet | Eating, Juicing | Summer | Hydrating, low in calories |\n| Cherry | Cereza | Cerise | Kirsche | Ciliegia | Cereja | Kers | \u0412\u0438\u0448\u043D\u044F | \u3055\u304F\u3089\u3093\u307C | Red | Europe | Sweet | Eating, Desserts | Spring | High in antioxidants, anti-inflammatory |\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Sed hendrerit nisi eget ligula suscipit, id tempus lorem volutpat. Nam eget placerat justo. Fusce vitae tortor id mi accumsan vestibulum. Integer auctor fermentum nisi, et consequat orci facilisis ac. Ut vitae nisl sit amet orci ullamcorper fringilla non a turpis. Proin nec turpis sed elit mattis efficitur. Sed consequat dui et nisi malesuada, sed sodales nulla hendrerit. Nullam tristique, lorem nec aliquet varius, mauris purus eleifend justo, vitae varius purus mauris sit amet purus. Duis ac odio ut nulla fermentum congue. Integer consequat dui sed libero vulputate commodo. \n Donec rhoncus purus nec turpis pulvinar, ac aliquam neque aliquet. Sed semper libero quis massa vehicula, sit amet rhoncus tortor fringilla. Nulla facilisi. In ut nibh eget mauris dictum suscipit vel eget lacus. Nullam sollicitudin leo nec ligula convallis, eget pharetra nisi tristique. Nulla facilisi. Phasellus vestibulum tristique sollicitudin. Cras lacinia velit quis sapien tristique, sed luctus elit ultricies. Suspendisse ut dictum tortor. Phasellus sed purus nec odio congue ullamcorper. Sed auctor lorem id venenatis cursus. Sed ac quam tortor. Sed vel ante nec nulla vulputate placerat. Maecenas sed ante eget leo ultrices posuere. Vivamus sit amet feugiat risus.\n";
31
31
  export declare const answerWithTable = "\n| English | Spanish | Color |\n|---------------|---------------|-------------|\n| Apple | Manzana | Red |\n| Banana | Pl\u00E1tano | Yellow |\n| Orange | Naranja | Orange |\n| Grape | Uva | Purple |\n| Strawberry | Fresa | Red |\n| Blueberry | Ar\u00E1ndano | Blue |\n| Lemon | Lim\u00F3n | Yellow |\n| Pineapple | Pi\u00F1a | Brown/Yellow|\n| Watermelon | Sand\u00EDa | Green/Red |\n| Cherry | Cereza | Red |\n";
32
32
  export declare const answerWithCodeBlocks = "\nCode Blocks\n```html\n<div>\n <p>This is a paragraph inside a &lt;div&gt; block.</p>\n</div>\n```\n\n```\nfunction greet(name) {\n console.log('Hello, ' + name + '!');\n}\n\ngreet('World');\n```\n\n```c++\n#include <iostream>\n\nint main() {\n std::cout << \"Hello, world! This is a long line that will cause overflow in the code block when displayed on a narrow screen or container.\" << std::endl;\n return 0;\n}\n```\n";
33
+ export declare const comprehensiveMarkdownAnswer = "\n# Comprehensive AI Answer with All Markdown Features\n\nThis is a comprehensive mock AI answer designed to test all markdown rendering capabilities in the Box AI content answers system.\n\n## Text Formatting\n\nHere we demonstrate various text formatting options:\n\n- **Bold text** using double asterisks\n- *Italic text* using single asterisks \n- ***Bold and italic*** using triple asterisks\n- ~~Strikethrough text~~ using double tildes\n- `Inline code` using backticks\n- [External link](https://www.example.com) to external websites\n- [Box file link](https://app.box.com/file/123) to Box documents\n\n## Headers\n\nWe support all header levels:\n\n# Header 1\n## Header 2 \n### Header 3\n#### Header 4\n##### Header 5\n###### Header 6\n\n## Lists\n\n### Unordered Lists\n- First item\n- Second item\n - Nested item A\n - Nested item B\n - Deeply nested item\n- Third item\n\n### Ordered Lists\n1. First numbered item\n2. Second numbered item\n 1. Nested numbered item A\n 2. Nested numbered item B\n 1. Deeply nested numbered item\n3. Third numbered item\n\n### Mixed Lists\n1. Ordered item with unordered sub-items\n - Unordered sub-item 1\n - Unordered sub-item 2\n2. Another ordered item\n - More unordered content\n - Even more content\n\n## Code Blocks\n\n### JavaScript\n```javascript\nfunction calculateSum(a, b) {\n return a + b;\n}\n\nconst result = calculateSum(5, 3);\nconsole.log('Result:', result);\n```\n\n### Python\n```python\ndef fibonacci(n):\n if n <= 1:\n return n\n return fibonacci(n-1) + fibonacci(n-2)\n\n# Calculate first 10 Fibonacci numbers\nfor i in range(10):\n print(f\"F({i}) = {fibonacci(i)}\")\n```\n\n### HTML\n```html\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <title>Sample Page</title>\n</head>\n<body>\n <h1>Welcome to our site</h1>\n <p>This is a sample paragraph with <strong>bold</strong> and <em>italic</em> text.</p>\n</body>\n</html>\n```\n\n### CSS\n```css\n.container {\n max-width: 1200px;\n margin: 0 auto;\n padding: 20px;\n}\n\n.button {\n background-color: #007bff;\n color: white;\n padding: 10px 20px;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n}\n\n.button:hover {\n background-color: #0056b3;\n}\n```\n\n## Tables\n\n### Simple Table\n| Feature | Status | Notes |\n|---------|--------|-------|\n| Headers | \u2705 | All 6 levels supported |\n| Lists | \u2705 | Ordered, unordered, mixed |\n| Code | \u2705 | Inline and blocks |\n| Links | \u2705 | External and Box files |\n\n### Complex Table\n| Language | Type | Paradigm | Popularity | Use Cases |\n|----------|------|----------|------------|-----------|\n| JavaScript | Dynamic | Multi-paradigm | Very High | Web development, Node.js |\n| Python | Dynamic | Multi-paradigm | Very High | Data science, AI, web |\n| Java | Static | Object-oriented | High | Enterprise, Android |\n| C++ | Static | Multi-paradigm | High | Systems, games, performance |\n| Rust | Static | Multi-paradigm | Growing | Systems, safety-critical |\n\n## Blockquotes\n\n> This is a simple blockquote. It can contain multiple lines and will be properly formatted.\n\n> **Important Note:** Blockquotes can also contain other markdown elements like **bold text** and [links](https://example.com).\n\n> ### Blockquote with Header\n> \n> This blockquote contains a header and demonstrates how nested elements work within blockquotes.\n\n## Horizontal Rules\n\nWe can use horizontal rules to separate sections:\n\n---\n\n## Footnotes\n\nHere's some text with a footnote[^1] and another footnote[^2].\n\n[^1]: This is the first footnote with additional information.\n[^2]: This is the second footnote that might contain links to [external resources](https://example.com).\n\n## Task Lists\n\n- [x] Implement basic markdown support\n- [x] Add code block syntax highlighting \n- [x] Support tables and lists\n- [ ] Add custom components for Box files\n- [ ] Implement advanced table features\n- [ ] Add support for mathematical expressions\n\n## Mixed Content Example\n\nHere's a paragraph that combines multiple markdown features:\n\nThe **Box AI system** supports various content types including:\n1. *Text documents* with formatting\n2. `Code files` with syntax highlighting\n3. [Spreadsheets](https://app.box.com/file/456) with data analysis\n4. [Presentations](https://app.box.com/file/789) with visual content\n\n> **Pro Tip:** You can reference multiple file types in a single answer, and the system will automatically create clickable links to Box files while showing external links with their URLs.\n\n---\n\n## Conclusion\n\nThis comprehensive example demonstrates the full range of markdown features supported by the Box AI content answers system. All elements should render correctly in both legacy and React markdown modes.\n\n**Key Features Tested:**\n- \u2705 Headers (H1-H6)\n- \u2705 Text formatting (bold, italic, strikethrough, code)\n- \u2705 Lists (ordered, unordered, mixed, nested)\n- \u2705 Code blocks with syntax highlighting\n- \u2705 Tables (simple and complex)\n- \u2705 Blockquotes\n- \u2705 Links (external and Box files)\n- \u2705 Horizontal rules\n- \u2705 Footnotes\n- \u2705 Task lists\n- \u2705 Mixed content scenarios\n";
33
34
  export declare const testItems: {
34
35
  id: string;
35
36
  name: string;
@@ -104,3 +105,5 @@ export declare const AnswerWithNonBoxUrlsMarkdown: (props: AnswerProps) => impor
104
105
  export declare const AnswerWithMixedUrlsMarkdown: (props: AnswerProps) => import("react/jsx-runtime").JSX.Element;
105
106
  export declare const AnswerWithReactModeCitations: (props: AnswerProps) => import("react/jsx-runtime").JSX.Element;
106
107
  export declare const AnswerWithReactModeMixedUrls: (props: AnswerProps) => import("react/jsx-runtime").JSX.Element;
108
+ export declare const AnswerWithComprehensiveMarkdown: (props: AnswerProps) => import("react/jsx-runtime").JSX.Element;
109
+ export declare const AnswerWithComprehensiveMarkdownReact: (props: AnswerProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,7 @@
1
- declare const md: any;
2
- export default md;
1
+ /**
2
+ * Renders markdown content to HTML string.
3
+ * This abstraction makes it easier to replace the underlying markdown library in the future.
4
+ * @param content - The markdown content to render
5
+ * @returns The rendered HTML string
6
+ */
7
+ export declare const markdownToHtmlString: (content: string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/box-ai-content-answers",
3
- "version": "1.1.4",
3
+ "version": "1.2.0",
4
4
  "peerDependencies": {
5
5
  "@box/blueprint-web": "^7.8.0",
6
6
  "@box/blueprint-web-assets": "^4.56.1",
@@ -17,11 +17,11 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "@box/babel-plugin-target-attributes": "1.3.0",
20
- "@box/blueprint-web": "^12.84.0",
21
- "@box/blueprint-web-assets": "^4.72.0",
22
- "@box/box-ai-agent-selector": "^1.1.3",
23
- "@box/item-icon": "^1.1.3",
24
- "@box/storybook-utils": "^0.14.8",
20
+ "@box/blueprint-web": "^12.85.1",
21
+ "@box/blueprint-web-assets": "^4.73.0",
22
+ "@box/box-ai-agent-selector": "^1.1.5",
23
+ "@box/item-icon": "^1.1.5",
24
+ "@box/storybook-utils": "^0.14.9",
25
25
  "@testing-library/react": "^15.0.6",
26
26
  "react": "^18.3.0",
27
27
  "react-dom": "^18.3.0",