@squiz/formatted-text-editor 2.2.0 → 2.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - b4b34a6: Added basic checks in case no content tools are provided (no context)
8
+
3
9
  ## 2.2.0
4
10
 
5
11
  ### Minor Changes
@@ -10,7 +10,7 @@ const dxp_ai_client_react_1 = require("@squiz/dxp-ai-client-react");
10
10
  const react_2 = require("@remirror/react");
11
11
  const ContentToolsDropdown = () => {
12
12
  const { contentTools } = (0, dxp_ai_client_react_1.useAiService)();
13
- const dropdownItems = contentTools.map((item) => ({
13
+ const dropdownItems = contentTools?.map((item) => ({
14
14
  items: [
15
15
  {
16
16
  action: () => alert(JSON.stringify(item, null, 2)),
@@ -21,7 +21,7 @@ const ContentToolsDropdown = () => {
21
21
  key: item.id,
22
22
  }));
23
23
  // No content tools to show, don't show dropdown at all
24
- if (contentTools.length === 0) {
24
+ if (!contentTools || contentTools?.length === 0) {
25
25
  return null;
26
26
  }
27
27
  return (react_1.default.createElement(react_1.default.Fragment, null,
@@ -30,6 +30,6 @@ const ContentToolsDropdown = () => {
30
30
  format: sds_1.BUTTON_FORMAT_TRANSPARENT,
31
31
  icon: AiIcon_1.ICON_AI,
32
32
  theme: sds_1.BUTTON_THEME_DEFAULT,
33
- }, className: "content-tools-dropdown", dropdownPosition: sds_1.DROPDOWN_POSITION_RIGHT, heading: 'Rewrite to...', sections: dropdownItems })));
33
+ }, className: "content-tools-dropdown", dropdownPosition: sds_1.DROPDOWN_POSITION_RIGHT, heading: 'Rewrite to...', sections: dropdownItems ?? [] })));
34
34
  };
35
35
  exports.default = ContentToolsDropdown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/formatted-text-editor",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "private": false,
@@ -7,7 +7,7 @@ import { VerticalDivider } from '@remirror/react';
7
7
  const ContentToolsDropdown = () => {
8
8
  const { contentTools } = useAiService();
9
9
 
10
- const dropdownItems = contentTools.map((item) => ({
10
+ const dropdownItems = contentTools?.map((item) => ({
11
11
  items: [
12
12
  {
13
13
  action: () => alert(JSON.stringify(item, null, 2)),
@@ -19,7 +19,7 @@ const ContentToolsDropdown = () => {
19
19
  }));
20
20
 
21
21
  // No content tools to show, don't show dropdown at all
22
- if (contentTools.length === 0) {
22
+ if (!contentTools || contentTools?.length === 0) {
23
23
  return null;
24
24
  }
25
25
 
@@ -37,7 +37,7 @@ const ContentToolsDropdown = () => {
37
37
  className="content-tools-dropdown"
38
38
  dropdownPosition={DROPDOWN_POSITION_RIGHT}
39
39
  heading={'Rewrite to...'}
40
- sections={dropdownItems}
40
+ sections={dropdownItems ?? []}
41
41
  />
42
42
  </>
43
43
  );