@automattic/jetpack-shared-extension-utils 1.0.2 → 1.1.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
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.1.1] - 2025-06-18
9
+ ### Changed
10
+ - Internal updates.
11
+
12
+ ## [1.1.0] - 2025-06-16
13
+ ### Added
14
+ - Components: Add reusable link to open support articles in Help Center. [#43883]
15
+
8
16
  ## [1.0.2] - 2025-06-10
9
17
  ### Changed
10
18
  - Update dependencies. [#43796]
@@ -657,6 +665,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
657
665
  ### Changed
658
666
  - Core: prepare utility for release
659
667
 
668
+ [1.1.1]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/1.1.0...1.1.1
669
+ [1.1.0]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/1.0.2...1.1.0
660
670
  [1.0.2]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/1.0.1...1.0.2
661
671
  [1.0.1]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/1.0.0...1.0.1
662
672
  [1.0.0]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/0.20.3...1.0.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/jetpack-shared-extension-utils",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "description": "Utility functions used by the block editor extensions",
5
5
  "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/shared-extension-utils/#readme",
6
6
  "bugs": {
@@ -19,10 +19,10 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@automattic/color-studio": "4.1.0",
22
- "@automattic/jetpack-analytics": "^1.0.0",
22
+ "@automattic/jetpack-analytics": "^1.0.1",
23
23
  "@automattic/jetpack-base-styles": "^1.0.0",
24
- "@automattic/jetpack-components": "^1.1.1",
25
- "@automattic/jetpack-connection": "^1.2.1",
24
+ "@automattic/jetpack-components": "^1.1.3",
25
+ "@automattic/jetpack-connection": "^1.2.3",
26
26
  "@automattic/jetpack-script-data": "^0.4.3",
27
27
  "@wordpress/api-fetch": "7.24.0",
28
28
  "@wordpress/block-editor": "14.19.0",
@@ -49,9 +49,9 @@
49
49
  "@testing-library/react": "16.2.0",
50
50
  "@testing-library/user-event": "14.6.1",
51
51
  "@wordpress/babel-plugin-import-jsx-pragma": "5.24.0",
52
- "babel-jest": "29.7.0",
53
- "jest": "29.7.0",
54
- "jest-environment-jsdom": "29.7.0",
52
+ "babel-jest": "30.0.0",
53
+ "jest": "30.0.0",
54
+ "jest-environment-jsdom": "30.0.0",
55
55
  "jetpack-js-tools": "workspace:*",
56
56
  "react": "18.3.1",
57
57
  "react-dom": "18.3.1"
@@ -1,2 +1,3 @@
1
1
  export { default as JetpackEditorPanelLogo } from './jetpack-editor-panel-logo';
2
2
  export { Nudge } from './upgrade-nudge';
3
+ export { WpcomSupportLink } from './wpcom-support-link';
@@ -0,0 +1,44 @@
1
+ import { ExternalLink } from '@wordpress/components';
2
+ import { useDispatch } from '@wordpress/data';
3
+ import React, { forwardRef } from 'react';
4
+
5
+ /**
6
+ * Renders a link that opens a WP.com support article in the Help Center.
7
+ *
8
+ * @param {object} props - The component props.
9
+ * @param {string} props.supportLink - Support link URL.
10
+ * @param {number} props.supportPostId - Support post ID.
11
+ * @param {React.Component} props.children - Support link content.
12
+ * @param {Function} [props.onClick] - Callback function to be called when the link is clicked.
13
+ * @param {object} [props.style] - CSS properties to be applied to the link.
14
+ * @return {React.JSX.Element} The component to render.
15
+ */
16
+ export const WpcomSupportLink = forwardRef(
17
+ ( { supportLink, supportPostId, children, onClick, style }, ref ) => {
18
+ const helpCenterDispatch = useDispatch( 'automattic/help-center' );
19
+ const setShowSupportDoc = helpCenterDispatch?.setShowSupportDoc;
20
+
21
+ if ( setShowSupportDoc ) {
22
+ return (
23
+ <a
24
+ href={ supportLink }
25
+ // eslint-disable-next-line react/jsx-no-bind
26
+ onClick={ event => {
27
+ event.preventDefault();
28
+ onClick?.();
29
+ setShowSupportDoc( supportLink, supportPostId );
30
+ } }
31
+ style={ style }
32
+ ref={ ref }
33
+ >
34
+ { children }
35
+ </a>
36
+ );
37
+ }
38
+ return (
39
+ <ExternalLink href={ supportLink } onClick={ onClick } style={ style } ref={ ref }>
40
+ { children }
41
+ </ExternalLink>
42
+ );
43
+ }
44
+ );