@automattic/jetpack-shared-extension-utils 1.0.2 → 1.1.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ 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.0] - 2025-06-16
9
+ ### Added
10
+ - Components: Add reusable link to open support articles in Help Center. [#43883]
11
+
8
12
  ## [1.0.2] - 2025-06-10
9
13
  ### Changed
10
14
  - Update dependencies. [#43796]
@@ -657,6 +661,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
657
661
  ### Changed
658
662
  - Core: prepare utility for release
659
663
 
664
+ [1.1.0]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/1.0.2...1.1.0
660
665
  [1.0.2]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/1.0.1...1.0.2
661
666
  [1.0.1]: https://github.com/Automattic/jetpack-shared-extension-utils/compare/1.0.0...1.0.1
662
667
  [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.0",
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": {
@@ -21,8 +21,8 @@
21
21
  "@automattic/color-studio": "4.1.0",
22
22
  "@automattic/jetpack-analytics": "^1.0.0",
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.2",
25
+ "@automattic/jetpack-connection": "^1.2.2",
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",
@@ -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
+ );