@atlaskit/smart-card 43.26.2 → 43.26.4

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 (30) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/messages.js +15 -10
  3. package/dist/cjs/utils/analytics/analytics.js +1 -1
  4. package/dist/cjs/view/FlexibleCard/components/actions/copy-link-action/index.js +2 -1
  5. package/dist/cjs/view/FlexibleCard/components/actions/preview-action/index.js +3 -2
  6. package/dist/cjs/view/FlexibleCard/components/actions/rovo-chat-action/html-to-adf.js +180 -0
  7. package/dist/cjs/view/FlexibleCard/components/actions/rovo-chat-action/index.js +25 -11
  8. package/dist/cjs/view/FlexibleCard/components/actions/view-related-links-action/related-links-action-icon/index.js +2 -1
  9. package/dist/cjs/view/LinkUrl/index.js +1 -1
  10. package/dist/es2019/messages.js +15 -10
  11. package/dist/es2019/utils/analytics/analytics.js +1 -1
  12. package/dist/es2019/view/FlexibleCard/components/actions/copy-link-action/index.js +2 -1
  13. package/dist/es2019/view/FlexibleCard/components/actions/preview-action/index.js +3 -2
  14. package/dist/es2019/view/FlexibleCard/components/actions/rovo-chat-action/html-to-adf.js +161 -0
  15. package/dist/es2019/view/FlexibleCard/components/actions/rovo-chat-action/index.js +23 -29
  16. package/dist/es2019/view/FlexibleCard/components/actions/view-related-links-action/related-links-action-icon/index.js +2 -1
  17. package/dist/es2019/view/LinkUrl/index.js +1 -1
  18. package/dist/esm/messages.js +15 -10
  19. package/dist/esm/utils/analytics/analytics.js +1 -1
  20. package/dist/esm/view/FlexibleCard/components/actions/copy-link-action/index.js +2 -1
  21. package/dist/esm/view/FlexibleCard/components/actions/preview-action/index.js +3 -2
  22. package/dist/esm/view/FlexibleCard/components/actions/rovo-chat-action/html-to-adf.js +172 -0
  23. package/dist/esm/view/FlexibleCard/components/actions/rovo-chat-action/index.js +25 -11
  24. package/dist/esm/view/FlexibleCard/components/actions/view-related-links-action/related-links-action-icon/index.js +2 -1
  25. package/dist/esm/view/LinkUrl/index.js +1 -1
  26. package/dist/types/messages.d.ts +1 -1
  27. package/dist/types/view/FlexibleCard/components/actions/rovo-chat-action/html-to-adf.d.ts +8 -0
  28. package/dist/types-ts4.5/messages.d.ts +1 -1
  29. package/dist/types-ts4.5/view/FlexibleCard/components/actions/rovo-chat-action/html-to-adf.d.ts +8 -0
  30. package/package.json +8 -4
@@ -0,0 +1,161 @@
1
+ /**
2
+ * This is a simplified version of html to adf conversion,
3
+ * used specifically for SL RovoChatAction prompt message,
4
+ * and does not support all ADF offered via @atlaskit/adf-utils
5
+ *
6
+ * Support: p, ul, li, text, b, strong, code, inlineCard (replace a hyperlink)
7
+ */
8
+ import { code, doc, inlineCard, p, b, ul, li, text } from '@atlaskit/adf-utils/builders';
9
+ const INLINE_TAG_NAMES = ['b', 'strong', 'code', 'a', 'inlineCard'];
10
+ const BLOCK_TAG_NAMES = ['p', 'ul', 'ol', 'li'];
11
+
12
+ /**
13
+ * Group Captures Example
14
+ * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
15
+ * match[1] Self-closing tag name br from <br/> or <img src="x"/>
16
+ * match[2] Opening tag name div from <div> or <div class="x">
17
+ * match[3] Closing tag name div from </div>
18
+ * match[4] Text content Hello world
19
+ */
20
+ const htmlRegex = /<\s*(\w+)[^>]*?\s*\/\s*>|<\s*(\w+)[^>]*>|<\s*\/\s*(\w+)\s*>|([^<]+)/g;
21
+ const decodeHtmlEntities = (text = '') => {
22
+ return text.replace(/&nbsp;/g, ' ').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&').replace(/&quot;/g, '"').replace(/&#39;/g, "'");
23
+ };
24
+ const tokenizeHtml = html => {
25
+ const tokens = [];
26
+ let match;
27
+ while ((match = htmlRegex.exec(html)) !== null) {
28
+ const selfClosingTag = match[1];
29
+ const openingTag = match[2];
30
+ const closingTag = match[3];
31
+ const textContent = match[4];
32
+ if (selfClosingTag) {
33
+ tokens.push({
34
+ type: 'selfClosing',
35
+ tagName: selfClosingTag.toLowerCase()
36
+ });
37
+ } else if (openingTag) {
38
+ tokens.push({
39
+ type: 'open',
40
+ tagName: openingTag.toLowerCase()
41
+ });
42
+ } else if (closingTag) {
43
+ tokens.push({
44
+ type: 'close',
45
+ tagName: closingTag.toLowerCase()
46
+ });
47
+ } else if (textContent) {
48
+ if (textContent !== null && textContent !== void 0 && textContent.trim()) {
49
+ tokens.push({
50
+ type: 'text',
51
+ content: decodeHtmlEntities(textContent)
52
+ });
53
+ }
54
+ }
55
+ }
56
+ return tokens;
57
+ };
58
+ const buildListItem = (content = []) => {
59
+ // Check if content has only text/inline elements
60
+ const hasOnlyInlineContent = content.every(node => node.type === 'text' || node.type === 'hardBreak' || !node.type);
61
+ if (hasOnlyInlineContent) {
62
+ // Wrap text content in a paragraph
63
+ return li([p(...content)]);
64
+ }
65
+
66
+ // Content has block elements (like nested lists), use as-is
67
+ return li(content);
68
+ };
69
+ const blockToAdf = (tagName, content = []) => {
70
+ switch (tagName) {
71
+ case 'p':
72
+ return p(...content);
73
+ case 'ul':
74
+ return ul(...content);
75
+ case 'li':
76
+ return buildListItem(content);
77
+ }
78
+ };
79
+ const inlineToAdf = (tagName, content) => {
80
+ switch (tagName) {
81
+ case 'b':
82
+ case 'strong':
83
+ return b(content);
84
+ case 'code':
85
+ return code(content);
86
+ case 'a':
87
+ case 'inlineCard':
88
+ return inlineCard({
89
+ url: content
90
+ });
91
+ default:
92
+ return text(content);
93
+ }
94
+ };
95
+ const parseTokensToAdf = tokens => {
96
+ const stack = [{
97
+ type: 'root',
98
+ content: []
99
+ }];
100
+ let currentMarks = [];
101
+ for (let i = 0; i < tokens.length; i++) {
102
+ const token = tokens[i];
103
+ const current = stack[stack.length - 1];
104
+ switch (token.type) {
105
+ case 'text':
106
+ if (token.content) {
107
+ var _currentMarks, _currentMarks$;
108
+ const inlineAdfNode = inlineToAdf((_currentMarks = currentMarks) === null || _currentMarks === void 0 ? void 0 : (_currentMarks$ = _currentMarks[0]) === null || _currentMarks$ === void 0 ? void 0 : _currentMarks$.type, token.content);
109
+ current.content.push(inlineAdfNode);
110
+ }
111
+ break;
112
+ case 'open':
113
+ if (INLINE_TAG_NAMES.includes(token.tagName)) {
114
+ currentMarks.push({
115
+ type: token.tagName
116
+ });
117
+ } else if (BLOCK_TAG_NAMES.includes(token.tagName)) {
118
+ stack.push({
119
+ type: token.tagName,
120
+ content: []
121
+ });
122
+ }
123
+ break;
124
+ case 'close':
125
+ // Inline formatting
126
+ if (token.tagName && INLINE_TAG_NAMES.includes(token.tagName)) {
127
+ currentMarks = currentMarks.filter(m => m.type !== token.tagName);
128
+ }
129
+ // Block elements
130
+ else if (stack.length > 1) {
131
+ const closed = stack.pop();
132
+ const parent = stack[stack.length - 1];
133
+ const adfNode = blockToAdf(closed === null || closed === void 0 ? void 0 : closed.type, closed === null || closed === void 0 ? void 0 : closed.content);
134
+ if (adfNode) {
135
+ parent.content.push(adfNode);
136
+ }
137
+ }
138
+ break;
139
+ }
140
+ }
141
+
142
+ // Return root content
143
+ return stack[0].content;
144
+ };
145
+
146
+ /**
147
+ * Convert HTML string to ADF format
148
+ *
149
+ * This is a simplified version specific for RovoChatAction prompt message
150
+ * and does not support all ADF offered via @atlaskit/adf-utils
151
+ */
152
+ const htmlToAdf = html => {
153
+ try {
154
+ const tokens = tokenizeHtml(html);
155
+ const adfContent = parseTokensToAdf(tokens);
156
+ return doc(...adfContent);
157
+ } catch {
158
+ return html;
159
+ }
160
+ };
161
+ export default htmlToAdf;
@@ -9,6 +9,7 @@ import AiChapterIcon from '../../../assets/ai-chapter-icon';
9
9
  import AIEditIcon from '../../../assets/ai-edit-icon';
10
10
  import AISearchIcon from '../../../assets/ai-search-icon';
11
11
  import Action from '../action';
12
+ import htmlToAdf from './html-to-adf';
12
13
  export let RovoChatPromptKey = /*#__PURE__*/function (RovoChatPromptKey) {
13
14
  RovoChatPromptKey["RECOMMEND_OTHER_SOURCES"] = "recommend-other-sources";
14
15
  RovoChatPromptKey["SHOW_OTHER_MENTIONS"] = "show-other-mentions";
@@ -21,7 +22,6 @@ const getContext = (intl, product) => {
21
22
  case 'CONFLUENCE':
22
23
  return {
23
24
  contextLong: intl.formatMessage(messages.rovo_prompt_context_confluence_page),
24
- contextLongPlural: intl.formatMessage(messages.rovo_prompt_context_confluence_page_plural),
25
25
  contextShort: intl.formatMessage(messages.rovo_prompt_context_confluence_page_short)
26
26
  };
27
27
  case 'JSW':
@@ -30,25 +30,28 @@ const getContext = (intl, product) => {
30
30
  case 'JPD':
31
31
  return {
32
32
  contextLong: intl.formatMessage(messages.rovo_prompt_context_jira_work_item),
33
- contextLongPlural: intl.formatMessage(messages.rovo_prompt_context_jira_work_item_plural),
34
33
  contextShort: intl.formatMessage(messages.rovo_prompt_context_jira_work_item_short)
35
34
  };
36
35
  }
37
36
  };
38
- const getPromptAction = (promptKey, intl, url, product) => {
37
+ const getPromptAction = (promptKey, intl, url = '', product) => {
39
38
  var _getContext;
40
39
  const {
41
40
  contextLong,
42
- contextLongPlural,
43
41
  contextShort
44
42
  } = (_getContext = getContext(intl, product)) !== null && _getContext !== void 0 ? _getContext : {
45
43
  contextLong: intl.formatMessage(messages.rovo_prompt_context_generic),
46
- contextLongPlural: intl.formatMessage(messages.rovo_prompt_context_generic_plural),
47
44
  contextShort: intl.formatMessage(messages.rovo_prompt_context_generic)
48
45
  };
49
46
  switch (promptKey) {
50
47
  case RovoChatPromptKey.RECOMMEND_OTHER_SOURCES:
51
48
  const label_recommend = intl.formatMessage(messages.rovo_prompt_button_recommend_other_sources);
49
+ const html_recommend = intl.formatMessage(messages.rovo_prompt_message_recommend_other_sources, {
50
+ context: contextLong,
51
+ url
52
+ }, {
53
+ ignoreTag: true
54
+ });
52
55
  return {
53
56
  icon: /*#__PURE__*/React.createElement(AIEditIcon, null),
54
57
  content: label_recommend,
@@ -56,18 +59,17 @@ const getPromptAction = (promptKey, intl, url, product) => {
56
59
  data: {
57
60
  name: label_recommend,
58
61
  dialogues: [],
59
- // NAVX-3581: To be translated and converted to ADF
60
- prompt: `From this ${url} and the ${contextLong} I’m viewing now as context:
61
- - Search across all sources I can access for items that discuss similar concepts, themes, or problems, or that reference similar or closely related sources (including links to the same or related pages, issues, or docs).
62
- - Return the results as a list or table with columns: Item, Type, Short summary, and Why it’s similar.
63
- - For each result, give a one‑sentence Short summary of what the item is about.
64
- - In Why it’s similar, briefly explain (in a phrase or short sentence) what makes it related to this Smart Link and/or the item I’m viewing (for example: same project, similar decision, shared requirements, overlapping stakeholders, similar metrics, or referencing related docs).
65
- - Order the list from most to least relevant based on Rovo’s assessment of semantic similarity to both the Smart Link target and the current item. Prioritize items that I do not own or have not contributed to.
66
- - If there are more than 5 results, show the 5 most relevant and state how many additional items you found.`
62
+ prompt: htmlToAdf(html_recommend)
67
63
  }
68
64
  };
69
65
  case RovoChatPromptKey.SHOW_OTHER_MENTIONS:
70
66
  const label_other_mentions = intl.formatMessage(messages.rovo_prompt_button_show_other_mentions);
67
+ const html_other_mentions = intl.formatMessage(messages.rovo_prompt_message_show_other_mentions, {
68
+ context: contextLong,
69
+ url
70
+ }, {
71
+ ignoreTag: true
72
+ });
71
73
  return {
72
74
  icon: /*#__PURE__*/React.createElement(AiChapterIcon, null),
73
75
  content: label_other_mentions,
@@ -75,20 +77,19 @@ const getPromptAction = (promptKey, intl, url, product) => {
75
77
  data: {
76
78
  name: label_other_mentions,
77
79
  dialogues: [],
78
- // NAVX-3581: To be translated and converted to ADF
79
- prompt: `From this ${url} and the ${contextLong} I’m viewing now:
80
- - Search across all ${contextLongPlural} I can access for other items that contain this exact Smart Link (same underlying URL/resource).
81
- - List all matching items in a table with columns: Item, Type, Short summary, How this item uses the link, and Relevance to current item.
82
- - For Short summary, give a one‑sentence description of what the page/issue is about.
83
- - For How this item uses the link, briefly explain the role this link plays there (e.g., decision doc, background context, implementation details, status update).
84
- - For Relevance to current item, compare each item to the page/issue I’m viewing now and label it High, Medium, or Low relevance, with a short reason (a phrase or single clause).
85
- - If there are more than 15 matches, show the 15 most relevant and tell me how many additional matches exist.`
80
+ prompt: htmlToAdf(html_other_mentions)
86
81
  }
87
82
  };
88
83
  case RovoChatPromptKey.SUGGEST_IMPROVEMENT:
89
84
  const label_improvement = intl.formatMessage(messages.rovo_prompt_button_suggest_improvement, {
90
85
  context: contextShort
91
86
  });
87
+ const html_improvement = intl.formatMessage(messages.rovo_prompt_message_suggest_improvement, {
88
+ context: contextLong,
89
+ url
90
+ }, {
91
+ ignoreTag: true
92
+ });
92
93
  return {
93
94
  icon: /*#__PURE__*/React.createElement(AISearchIcon, null),
94
95
  content: label_improvement,
@@ -96,14 +97,7 @@ const getPromptAction = (promptKey, intl, url, product) => {
96
97
  data: {
97
98
  name: label_improvement,
98
99
  dialogues: [],
99
- // NAVX-3581: To be translated and converted to ADF
100
- prompt: `Using the ${contextLong} I’m viewing now, plus all files and links referenced in it (including this ${url}):
101
- - Identify unclear reasoning, missing context, or contradictions between the item and its linked files.
102
- - Call out any places where assumptions are not backed up by data or prior docs.
103
- - Stay concise: summarize your findings in no more than three short paragraphs of content listed as bullets of no more than a couple of sentences long focused only on the two points above.
104
- - After presenting that summary, ask me explicitly if I want you to go deeper. Only if I say yes, then:
105
- - Suggest concrete rewrites (bullets or short paragraphs) to make the argument clearer, more concise, and better aligned with the supporting files.
106
- - Propose 3–5 follow‑up edits or additions that would make this item and its linked docs “share‑ready” for stakeholders.`
100
+ prompt: htmlToAdf(html_improvement)
107
101
  }
108
102
  };
109
103
  }
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
  import ClockIcon from '@atlaskit/icon/core/clock';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  const RelatedLinksActionIcon = () => /*#__PURE__*/React.createElement(ClockIcon, {
4
5
  color: "currentColor",
5
6
  spacing: "spacious",
6
- label: "View related links..."
7
+ label: fg('navx-3698-flexible-card-a11y-fix') ? '' : 'View related links...'
7
8
  });
8
9
  export default RelatedLinksActionIcon;
@@ -12,7 +12,7 @@ import LinkWarningModal from './LinkWarningModal';
12
12
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
13
13
  const PACKAGE_DATA = {
14
14
  packageName: "@atlaskit/smart-card",
15
- packageVersion: "43.26.1",
15
+ packageVersion: "43.26.3",
16
16
  componentName: 'linkUrl'
17
17
  };
18
18
  const Anchor = withLinkClickedEvent('a');
@@ -860,11 +860,6 @@ export var messages = defineMessages({
860
860
  defaultMessage: 'Confluence page',
861
861
  description: 'The Confluence page the user see Smart Link in, to be used as the {context} for Rovo prompt message'
862
862
  },
863
- rovo_prompt_context_confluence_page_plural: {
864
- id: 'fabric.linking.rovo_prompt_context_confluence_page_plural.non-final',
865
- defaultMessage: 'Confluence pages',
866
- description: 'The Confluence page the user see Smart Link in, to be used as the {context} for Rovo prompt message'
867
- },
868
863
  rovo_prompt_context_confluence_page_short: {
869
864
  id: 'fabric.linking.rovo_prompt_context_confluence_page_short.non-final',
870
865
  defaultMessage: 'page',
@@ -875,11 +870,6 @@ export var messages = defineMessages({
875
870
  defaultMessage: 'Jira work item',
876
871
  description: 'The Jira work item the user see Smart Link in, to be used as the {context} for Rovo prompt message'
877
872
  },
878
- rovo_prompt_context_jira_work_item_plural: {
879
- id: 'fabric.linking.rovo_prompt_context_jira_work_item_plural.non-final',
880
- defaultMessage: 'Jira work items',
881
- description: 'The Jira work item the user see Smart Link in, to be used as the {context} for Rovo prompt message'
882
- },
883
873
  rovo_prompt_context_jira_work_item_short: {
884
874
  id: 'fabric.linking.rovo_prompt_context_jira_work_item_short.non-final',
885
875
  defaultMessage: 'work item',
@@ -890,14 +880,29 @@ export var messages = defineMessages({
890
880
  defaultMessage: 'Recommend other sources',
891
881
  description: 'The name of the action to send prompt message to Rovo Chat in relation to current Smart Link'
892
882
  },
883
+ rovo_prompt_message_recommend_other_sources: {
884
+ id: 'fabric.linking.rovo_prompt_message_recommend_other_sources.non-final',
885
+ defaultMessage: '<p>From this <a>{url}</a> and the {context} I’m viewing now as context:</p><ul><li><p>Search across all sources I can access for items that discuss <b>similar concepts, themes, or problems</b>, or that <b>reference similar or closely related sources</b> (including links to the same or related pages, issues, or docs).</p></li><li><p>Return the results as a list or table with columns: <code>Item</code>, <code>Type</code>, <code>Short summary</code>, and <code>Why it’s similar</code>.</p></li><li><p>For each result, give a one‑sentence <b>Short summary</b> of what the item is about.</p></li><li><p>In <b>Why it’s similar</b>, briefly explain (in a phrase or short sentence) what makes it related to this Smart Link and/or the item I’m viewing (for example: same project, similar decision, shared requirements, overlapping stakeholders, similar metrics, or referencing related docs).</p></li><li><p>Order the list from <b>most to least relevant</b> based on Rovo’s assessment of semantic similarity to both the Smart Link target and the current item. Prioritize items that I do not own or have not contributed to.</p></li><li><p>If there are more than 5 results, show the <b>5 most relevant</b> and state how many additional items you found.</p></li></ul>',
886
+ description: 'The prompt message to send to Rovo Chat. {context} refers to the content the user triggered from, e.g. Confluence page or Jira work item. {url} refers to Smart Link that the user triggers this action from. (Please make sure all html tags remain the same.)'
887
+ },
893
888
  rovo_prompt_button_show_other_mentions: {
894
889
  id: 'fabric.linking.rovo_prompt_button_show_other_mentions.non-final',
895
890
  defaultMessage: 'Show other mentions',
896
891
  description: 'The name of the action to send prompt message to Rovo Chat in relation to current Smart Link'
897
892
  },
893
+ rovo_prompt_message_show_other_mentions: {
894
+ id: 'fabric.linking.rovo_prompt_message_show_other_mentions.non-final',
895
+ defaultMessage: '<p>From <a>{url}</a> and the {context} I’m viewing now:</p><ul><li><p>Search across all Confluence pages and Jira work items I can access for other items that contain this exact Smart Link (same underlying URL/resource).</p></li><li><p>List all matching items in a table with columns: <code>Item</code>, <code>Type</code>, <code>Short summary</code>, <code>How this item uses the link</code>, and <code>Relevance to current item</code>.</p></li><li><p>For <code>Short summary</code>, give a one‑sentence description of what the {context} is about.</p></li><li><p>For <code>How this item uses the link</code>, briefly explain the role this link plays there (e.g., decision doc, background context, implementation details, status update).</p></li><li><p>For <code>Relevance to current item</code>, compare each item to the {context} I’m viewing now and label it <code>High</code>, <code>Medium</code>, or <code>Low</code> relevance, with a short reason (a phrase or single clause).</p></li><li><p>If there are more than 15 matches, show the 15 most relevant and tell me how many additional matches exist.</p></li></ul>',
896
+ description: 'The prompt message to send to Rovo Chat. {context} refers to the content the user triggered from, e.g. Confluence page or Jira work item. {url} refers to Smart Link that the user triggers this action from. (Please make sure all html tags remain the same.)'
897
+ },
898
898
  rovo_prompt_button_suggest_improvement: {
899
899
  id: 'fabric.linking.rovo_prompt_button_suggest_improvement.non-final',
900
900
  defaultMessage: 'Suggest {context} improvement',
901
901
  description: 'The name of the action to send prompt message to Rovo Chat in relation to current Smart Link'
902
+ },
903
+ rovo_prompt_message_suggest_improvement: {
904
+ id: 'fabric.linking.rovo_prompt_message_suggest_improvement.non-final',
905
+ defaultMessage: '<p>Using the {context} I’m viewing now, plus all files and links referenced in it (including <a>{url}</a>):</p><ul><li><p>Identify unclear reasoning, missing context, or contradictions between the item and its linked files.</p></li><li><p>Call out any places where assumptions are not backed up by data or prior docs.</p></li><li><p>Stay concise: summarize your findings in <b>no more than three short paragraphs of content listed as bullets</b> of no more than a couple of sentences long focused only on the two points above.</p></li><li><p>After presenting that summary, <b>ask me explicitly</b> if I want you to go deeper. Only if I say yes, then:</p><ul><li><p>Suggest concrete rewrites (bullets or short paragraphs) to make the argument clearer, more concise, and better aligned with the supporting files.</p></li><li><p>Propose 3–5 follow‑up edits or additions that would make this item and its linked docs “share‑ready” for stakeholders.</p></li></ul></li></ul>',
906
+ description: 'The prompt message to send to Rovo Chat. {context} refers to the content the user triggered from, e.g. Confluence page or Jira work item. {url} refers to Smart Link that the user triggers this action from. (Please make sure all html tags remain the same.)'
902
907
  }
903
908
  });
@@ -4,7 +4,7 @@ export var ANALYTICS_CHANNEL = 'media';
4
4
  export var context = {
5
5
  componentName: 'smart-cards',
6
6
  packageName: "@atlaskit/smart-card",
7
- packageVersion: "43.26.1"
7
+ packageVersion: "43.26.3"
8
8
  };
9
9
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -10,6 +10,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
10
10
  import React, { useCallback, useState } from 'react';
11
11
  import { FormattedMessage } from 'react-intl-next';
12
12
  import LinkIcon from '@atlaskit/icon/core/link';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
13
14
  import { ActionName } from '../../../../../constants';
14
15
  import { messages } from '../../../../../messages';
15
16
  import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
@@ -58,7 +59,7 @@ var CopyLinkAction = function CopyLinkAction(_ref) {
58
59
  content: /*#__PURE__*/React.createElement(FormattedMessage, messages.copy_url_to_clipboard),
59
60
  icon: /*#__PURE__*/React.createElement(LinkIcon, {
60
61
  color: "currentColor",
61
- label: "copy url",
62
+ label: fg('navx-3698-flexible-card-a11y-fix') ? '' : 'copy url',
62
63
  spacing: "spacious"
63
64
  }),
64
65
  onClick: onClick,
@@ -5,6 +5,7 @@ import React, { useCallback } from 'react';
5
5
  import { FormattedMessage } from 'react-intl-next';
6
6
  import MediaServicesActualSizeIcon from '@atlaskit/icon/core/grow-diagonal';
7
7
  import PanelRightIcon from '@atlaskit/icon/core/panel-right';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
8
9
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
9
10
  import { ActionName } from '../../../../../constants';
10
11
  import { messages } from '../../../../../messages';
@@ -33,13 +34,13 @@ var PreviewAction = function PreviewAction(_ref) {
33
34
  return /*#__PURE__*/React.createElement(PanelRightIcon, {
34
35
  color: "currentColor",
35
36
  spacing: "spacious",
36
- label: "Open preview panel"
37
+ label: fg('navx-3698-flexible-card-a11y-fix') ? '' : 'Open preview panel'
37
38
  });
38
39
  }
39
40
  return /*#__PURE__*/React.createElement(MediaServicesActualSizeIcon, {
40
41
  color: "currentColor",
41
42
  spacing: "spacious",
42
- label: "Open preview"
43
+ label: fg('navx-3698-flexible-card-a11y-fix') ? '' : 'Open preview'
43
44
  });
44
45
  }, [hasPreviewPanel]);
45
46
  var actionLabel = useCallback(function () {
@@ -0,0 +1,172 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ /**
3
+ * This is a simplified version of html to adf conversion,
4
+ * used specifically for SL RovoChatAction prompt message,
5
+ * and does not support all ADF offered via @atlaskit/adf-utils
6
+ *
7
+ * Support: p, ul, li, text, b, strong, code, inlineCard (replace a hyperlink)
8
+ */
9
+ import { code, doc, inlineCard, p, b, ul, li, text } from '@atlaskit/adf-utils/builders';
10
+ var INLINE_TAG_NAMES = ['b', 'strong', 'code', 'a', 'inlineCard'];
11
+ var BLOCK_TAG_NAMES = ['p', 'ul', 'ol', 'li'];
12
+
13
+ /**
14
+ * Group Captures Example
15
+ * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
16
+ * match[1] Self-closing tag name br from <br/> or <img src="x"/>
17
+ * match[2] Opening tag name div from <div> or <div class="x">
18
+ * match[3] Closing tag name div from </div>
19
+ * match[4] Text content Hello world
20
+ */
21
+ var htmlRegex = /<\s*(\w+)[^>]*?\s*\/\s*>|<\s*(\w+)[^>]*>|<\s*\/\s*(\w+)\s*>|([^<]+)/g;
22
+ var decodeHtmlEntities = function decodeHtmlEntities() {
23
+ var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
24
+ return text.replace(/&nbsp;/g, ' ').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&').replace(/&quot;/g, '"').replace(/&#39;/g, "'");
25
+ };
26
+ var tokenizeHtml = function tokenizeHtml(html) {
27
+ var tokens = [];
28
+ var match;
29
+ while ((match = htmlRegex.exec(html)) !== null) {
30
+ var selfClosingTag = match[1];
31
+ var openingTag = match[2];
32
+ var closingTag = match[3];
33
+ var textContent = match[4];
34
+ if (selfClosingTag) {
35
+ tokens.push({
36
+ type: 'selfClosing',
37
+ tagName: selfClosingTag.toLowerCase()
38
+ });
39
+ } else if (openingTag) {
40
+ tokens.push({
41
+ type: 'open',
42
+ tagName: openingTag.toLowerCase()
43
+ });
44
+ } else if (closingTag) {
45
+ tokens.push({
46
+ type: 'close',
47
+ tagName: closingTag.toLowerCase()
48
+ });
49
+ } else if (textContent) {
50
+ if (textContent !== null && textContent !== void 0 && textContent.trim()) {
51
+ tokens.push({
52
+ type: 'text',
53
+ content: decodeHtmlEntities(textContent)
54
+ });
55
+ }
56
+ }
57
+ }
58
+ return tokens;
59
+ };
60
+ var buildListItem = function buildListItem() {
61
+ var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
62
+ // Check if content has only text/inline elements
63
+ var hasOnlyInlineContent = content.every(function (node) {
64
+ return node.type === 'text' || node.type === 'hardBreak' || !node.type;
65
+ });
66
+ if (hasOnlyInlineContent) {
67
+ // Wrap text content in a paragraph
68
+ return li([p.apply(void 0, _toConsumableArray(content))]);
69
+ }
70
+
71
+ // Content has block elements (like nested lists), use as-is
72
+ return li(content);
73
+ };
74
+ var blockToAdf = function blockToAdf(tagName) {
75
+ var content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
76
+ switch (tagName) {
77
+ case 'p':
78
+ return p.apply(void 0, _toConsumableArray(content));
79
+ case 'ul':
80
+ return ul.apply(void 0, _toConsumableArray(content));
81
+ case 'li':
82
+ return buildListItem(content);
83
+ }
84
+ };
85
+ var inlineToAdf = function inlineToAdf(tagName, content) {
86
+ switch (tagName) {
87
+ case 'b':
88
+ case 'strong':
89
+ return b(content);
90
+ case 'code':
91
+ return code(content);
92
+ case 'a':
93
+ case 'inlineCard':
94
+ return inlineCard({
95
+ url: content
96
+ });
97
+ default:
98
+ return text(content);
99
+ }
100
+ };
101
+ var parseTokensToAdf = function parseTokensToAdf(tokens) {
102
+ var stack = [{
103
+ type: 'root',
104
+ content: []
105
+ }];
106
+ var currentMarks = [];
107
+ var _loop = function _loop() {
108
+ var token = tokens[i];
109
+ var current = stack[stack.length - 1];
110
+ switch (token.type) {
111
+ case 'text':
112
+ if (token.content) {
113
+ var _currentMarks;
114
+ var inlineAdfNode = inlineToAdf((_currentMarks = currentMarks) === null || _currentMarks === void 0 || (_currentMarks = _currentMarks[0]) === null || _currentMarks === void 0 ? void 0 : _currentMarks.type, token.content);
115
+ current.content.push(inlineAdfNode);
116
+ }
117
+ break;
118
+ case 'open':
119
+ if (INLINE_TAG_NAMES.includes(token.tagName)) {
120
+ currentMarks.push({
121
+ type: token.tagName
122
+ });
123
+ } else if (BLOCK_TAG_NAMES.includes(token.tagName)) {
124
+ stack.push({
125
+ type: token.tagName,
126
+ content: []
127
+ });
128
+ }
129
+ break;
130
+ case 'close':
131
+ // Inline formatting
132
+ if (token.tagName && INLINE_TAG_NAMES.includes(token.tagName)) {
133
+ currentMarks = currentMarks.filter(function (m) {
134
+ return m.type !== token.tagName;
135
+ });
136
+ }
137
+ // Block elements
138
+ else if (stack.length > 1) {
139
+ var closed = stack.pop();
140
+ var parent = stack[stack.length - 1];
141
+ var adfNode = blockToAdf(closed === null || closed === void 0 ? void 0 : closed.type, closed === null || closed === void 0 ? void 0 : closed.content);
142
+ if (adfNode) {
143
+ parent.content.push(adfNode);
144
+ }
145
+ }
146
+ break;
147
+ }
148
+ };
149
+ for (var i = 0; i < tokens.length; i++) {
150
+ _loop();
151
+ }
152
+
153
+ // Return root content
154
+ return stack[0].content;
155
+ };
156
+
157
+ /**
158
+ * Convert HTML string to ADF format
159
+ *
160
+ * This is a simplified version specific for RovoChatAction prompt message
161
+ * and does not support all ADF offered via @atlaskit/adf-utils
162
+ */
163
+ var htmlToAdf = function htmlToAdf(html) {
164
+ try {
165
+ var tokens = tokenizeHtml(html);
166
+ var adfContent = parseTokensToAdf(tokens);
167
+ return doc.apply(void 0, _toConsumableArray(adfContent));
168
+ } catch (_unused) {
169
+ return html;
170
+ }
171
+ };
172
+ export default htmlToAdf;