@atlaskit/help-article 6.0.24 → 6.0.26

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,20 @@
1
1
  # @atlaskit/help-article
2
2
 
3
+ ## 6.0.26
4
+
5
+ ### Patch Changes
6
+
7
+ - [`6a82d7964a37b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6a82d7964a37b) -
8
+ Icon entrypoint migration
9
+ - Updated dependencies
10
+
11
+ ## 6.0.25
12
+
13
+ ### Patch Changes
14
+
15
+ - [`a7e68749821fe`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a7e68749821fe) -
16
+ [ux] fix issue where link inside article was opening within an iframe
17
+
3
18
  ## 6.0.24
4
19
 
5
20
  ### Patch Changes
@@ -5,7 +5,8 @@
5
5
  "target": "es5",
6
6
  "outDir": "../../../../../confluence/tsDist/@atlaskit__help-article",
7
7
  "rootDir": "../",
8
- "composite": true
8
+ "composite": true,
9
+ "noCheck": true
9
10
  },
10
11
  "include": [
11
12
  "../src/**/*.ts",
@@ -3,9 +3,10 @@
3
3
  "compilerOptions": {
4
4
  "declaration": true,
5
5
  "target": "es5",
6
- "outDir": "../../../../../tsDist/@atlaskit__help-article/app",
6
+ "outDir": "../../../../../jira/tsDist/@atlaskit__help-article/app",
7
7
  "rootDir": "../",
8
- "composite": true
8
+ "composite": true,
9
+ "noCheck": true
9
10
  },
10
11
  "include": [
11
12
  "../src/**/*.ts",
@@ -5,7 +5,8 @@
5
5
  "target": "es5",
6
6
  "outDir": "../../../../../tsDist/@atlaskit__help-article/app",
7
7
  "rootDir": "../",
8
- "composite": true
8
+ "composite": true,
9
+ "noCheck": true
9
10
  },
10
11
  "include": [
11
12
  "../src/**/*.ts",
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = exports.ArticleBody = void 0;
8
+ exports.processLinksForNewTab = exports.default = exports.ArticleBody = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _debounce = _interopRequireDefault(require("lodash/debounce"));
11
11
  var _reactDom = _interopRequireDefault(require("react-dom"));
@@ -18,6 +18,40 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
18
18
 
19
19
  var IFRAME_CONTAINER_ID = 'help-iframe-container';
20
20
  var IFRAME_ID = 'help-iframe';
21
+
22
+ /**
23
+ * Processes HTML content to ensure all links open in a new tab
24
+ * @param htmlContent - The HTML string to process
25
+ * @returns The processed HTML with target="_blank" added to all links
26
+ */
27
+ var processLinksForNewTab = exports.processLinksForNewTab = function processLinksForNewTab(htmlContent) {
28
+ // Create a temporary DOM element to parse the HTML
29
+ var tempDiv = document.createElement('div');
30
+ tempDiv.innerHTML = htmlContent;
31
+
32
+ // Find all anchor tags
33
+ var links = tempDiv.querySelectorAll('a[href]');
34
+
35
+ // Process each link
36
+ links.forEach(function (link) {
37
+ // Add target="_blank" if no target is specified or if target is not already "_blank"
38
+ if (!link.hasAttribute('target') || link.getAttribute('target') !== '_blank') {
39
+ link.setAttribute('target', '_blank');
40
+ }
41
+
42
+ // Always add security attributes for all external links
43
+ var existingRel = link.getAttribute('rel');
44
+ var relValues = existingRel ? existingRel.split(' ') : [];
45
+ if (!relValues.includes('noopener')) {
46
+ relValues.push('noopener');
47
+ }
48
+ if (!relValues.includes('noreferrer')) {
49
+ relValues.push('noreferrer');
50
+ }
51
+ link.setAttribute('rel', relValues.join(' '));
52
+ });
53
+ return tempDiv.innerHTML;
54
+ };
21
55
  var ArticleBody = exports.ArticleBody = function ArticleBody(props) {
22
56
  /**
23
57
  * Set article height
@@ -96,7 +130,9 @@ var ArticleBody = exports.ArticleBody = function ArticleBody(props) {
96
130
  if (newIframe !== null) {
97
131
  var iframeDocument = newIframe.document;
98
132
  iframeDocument.open();
99
- iframeDocument.write("<div>".concat(body, "</div>"));
133
+ // Process the HTML to ensure all links open in new tabs
134
+ var processedBody = processLinksForNewTab(body);
135
+ iframeDocument.write("<div>".concat(processedBody, "</div>"));
100
136
  iframeDocument.close();
101
137
  var head = iframeDocument.head || iframeDocument.getElementsByTagName('head')[0];
102
138
  var style = iframeDocument.createElement('style');
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
- var _linkExternalShortcut = _interopRequireDefault(require("@atlaskit/icon/core/migration/link-external--shortcut"));
9
+ var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
10
10
  var _heading = _interopRequireDefault(require("@atlaskit/heading"));
11
11
  var _HelpArticle = require("../model/HelpArticle");
12
12
  var _compiled = require("@atlaskit/primitives/compiled");
@@ -26,7 +26,7 @@ var HelpArticle = function HelpArticle(props) {
26
26
  target: "_blank"
27
27
  }, /*#__PURE__*/_react.default.createElement(_heading.default, {
28
28
  size: "large"
29
- }, title, /*#__PURE__*/_react.default.createElement(_compiled.Text, null, " "), /*#__PURE__*/_react.default.createElement(_linkExternalShortcut.default, {
29
+ }, title, /*#__PURE__*/_react.default.createElement(_compiled.Text, null, " "), /*#__PURE__*/_react.default.createElement(_linkExternal.default, {
30
30
  color: "currentColor",
31
31
  label: "link icon",
32
32
  LEGACY_size: "small"
package/dist/cjs/index.js CHANGED
@@ -16,5 +16,12 @@ Object.defineProperty(exports, "default", {
16
16
  return _HelpArticle.default;
17
17
  }
18
18
  });
19
+ Object.defineProperty(exports, "processLinksForNewTab", {
20
+ enumerable: true,
21
+ get: function get() {
22
+ return _ArticleBody.processLinksForNewTab;
23
+ }
24
+ });
19
25
  var _HelpArticle = _interopRequireDefault(require("./components/HelpArticle"));
20
- var _HelpArticle2 = require("./model/HelpArticle");
26
+ var _HelpArticle2 = require("./model/HelpArticle");
27
+ var _ArticleBody = require("./components/ArticleBody");
@@ -9,6 +9,40 @@ import resetCSS from './resetCss';
9
9
  import { ArticleFrame } from './styled';
10
10
  const IFRAME_CONTAINER_ID = 'help-iframe-container';
11
11
  const IFRAME_ID = 'help-iframe';
12
+
13
+ /**
14
+ * Processes HTML content to ensure all links open in a new tab
15
+ * @param htmlContent - The HTML string to process
16
+ * @returns The processed HTML with target="_blank" added to all links
17
+ */
18
+ export const processLinksForNewTab = htmlContent => {
19
+ // Create a temporary DOM element to parse the HTML
20
+ const tempDiv = document.createElement('div');
21
+ tempDiv.innerHTML = htmlContent;
22
+
23
+ // Find all anchor tags
24
+ const links = tempDiv.querySelectorAll('a[href]');
25
+
26
+ // Process each link
27
+ links.forEach(link => {
28
+ // Add target="_blank" if no target is specified or if target is not already "_blank"
29
+ if (!link.hasAttribute('target') || link.getAttribute('target') !== '_blank') {
30
+ link.setAttribute('target', '_blank');
31
+ }
32
+
33
+ // Always add security attributes for all external links
34
+ const existingRel = link.getAttribute('rel');
35
+ const relValues = existingRel ? existingRel.split(' ') : [];
36
+ if (!relValues.includes('noopener')) {
37
+ relValues.push('noopener');
38
+ }
39
+ if (!relValues.includes('noreferrer')) {
40
+ relValues.push('noreferrer');
41
+ }
42
+ link.setAttribute('rel', relValues.join(' '));
43
+ });
44
+ return tempDiv.innerHTML;
45
+ };
12
46
  export const ArticleBody = props => {
13
47
  /**
14
48
  * Set article height
@@ -85,7 +119,9 @@ export const ArticleBody = props => {
85
119
  if (newIframe !== null) {
86
120
  const iframeDocument = newIframe.document;
87
121
  iframeDocument.open();
88
- iframeDocument.write(`<div>${body}</div>`);
122
+ // Process the HTML to ensure all links open in new tabs
123
+ const processedBody = processLinksForNewTab(body);
124
+ iframeDocument.write(`<div>${processedBody}</div>`);
89
125
  iframeDocument.close();
90
126
  const head = iframeDocument.head || iframeDocument.getElementsByTagName('head')[0];
91
127
  const style = iframeDocument.createElement('style');
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import ShortcutIcon from '@atlaskit/icon/core/migration/link-external--shortcut';
2
+ import ShortcutIcon from '@atlaskit/icon/core/link-external';
3
3
  import Heading from '@atlaskit/heading';
4
4
  import { BODY_FORMAT_TYPES } from '../model/HelpArticle';
5
5
  import { Text } from '@atlaskit/primitives/compiled';
@@ -1,2 +1,3 @@
1
1
  export { default } from './components/HelpArticle';
2
- export { BODY_FORMAT_TYPES } from './model/HelpArticle';
2
+ export { BODY_FORMAT_TYPES } from './model/HelpArticle';
3
+ export { processLinksForNewTab } from './components/ArticleBody';
@@ -9,6 +9,40 @@ import resetCSS from './resetCss';
9
9
  import { ArticleFrame } from './styled';
10
10
  var IFRAME_CONTAINER_ID = 'help-iframe-container';
11
11
  var IFRAME_ID = 'help-iframe';
12
+
13
+ /**
14
+ * Processes HTML content to ensure all links open in a new tab
15
+ * @param htmlContent - The HTML string to process
16
+ * @returns The processed HTML with target="_blank" added to all links
17
+ */
18
+ export var processLinksForNewTab = function processLinksForNewTab(htmlContent) {
19
+ // Create a temporary DOM element to parse the HTML
20
+ var tempDiv = document.createElement('div');
21
+ tempDiv.innerHTML = htmlContent;
22
+
23
+ // Find all anchor tags
24
+ var links = tempDiv.querySelectorAll('a[href]');
25
+
26
+ // Process each link
27
+ links.forEach(function (link) {
28
+ // Add target="_blank" if no target is specified or if target is not already "_blank"
29
+ if (!link.hasAttribute('target') || link.getAttribute('target') !== '_blank') {
30
+ link.setAttribute('target', '_blank');
31
+ }
32
+
33
+ // Always add security attributes for all external links
34
+ var existingRel = link.getAttribute('rel');
35
+ var relValues = existingRel ? existingRel.split(' ') : [];
36
+ if (!relValues.includes('noopener')) {
37
+ relValues.push('noopener');
38
+ }
39
+ if (!relValues.includes('noreferrer')) {
40
+ relValues.push('noreferrer');
41
+ }
42
+ link.setAttribute('rel', relValues.join(' '));
43
+ });
44
+ return tempDiv.innerHTML;
45
+ };
12
46
  export var ArticleBody = function ArticleBody(props) {
13
47
  /**
14
48
  * Set article height
@@ -87,7 +121,9 @@ export var ArticleBody = function ArticleBody(props) {
87
121
  if (newIframe !== null) {
88
122
  var iframeDocument = newIframe.document;
89
123
  iframeDocument.open();
90
- iframeDocument.write("<div>".concat(body, "</div>"));
124
+ // Process the HTML to ensure all links open in new tabs
125
+ var processedBody = processLinksForNewTab(body);
126
+ iframeDocument.write("<div>".concat(processedBody, "</div>"));
91
127
  iframeDocument.close();
92
128
  var head = iframeDocument.head || iframeDocument.getElementsByTagName('head')[0];
93
129
  var style = iframeDocument.createElement('style');
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import ShortcutIcon from '@atlaskit/icon/core/migration/link-external--shortcut';
2
+ import ShortcutIcon from '@atlaskit/icon/core/link-external';
3
3
  import Heading from '@atlaskit/heading';
4
4
  import { BODY_FORMAT_TYPES } from '../model/HelpArticle';
5
5
  import { Text } from '@atlaskit/primitives/compiled';
package/dist/esm/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { default } from './components/HelpArticle';
2
- export { BODY_FORMAT_TYPES } from './model/HelpArticle';
2
+ export { BODY_FORMAT_TYPES } from './model/HelpArticle';
3
+ export { processLinksForNewTab } from './components/ArticleBody';
@@ -7,5 +7,11 @@ export interface Props {
7
7
  onArticleRenderBegin?(): void;
8
8
  onArticleRenderDone?(): void;
9
9
  }
10
+ /**
11
+ * Processes HTML content to ensure all links open in a new tab
12
+ * @param htmlContent - The HTML string to process
13
+ * @returns The processed HTML with target="_blank" added to all links
14
+ */
15
+ export declare const processLinksForNewTab: (htmlContent: string) => string;
10
16
  export declare const ArticleBody: (props: Props) => React.JSX.Element | null;
11
17
  export default ArticleBody;
@@ -1,3 +1,4 @@
1
1
  export { default } from './components/HelpArticle';
2
2
  export { BODY_FORMAT_TYPES } from './model/HelpArticle';
3
3
  export type { HelpArticle, AdfDoc } from './model/HelpArticle';
4
+ export { processLinksForNewTab } from './components/ArticleBody';
@@ -7,5 +7,11 @@ export interface Props {
7
7
  onArticleRenderBegin?(): void;
8
8
  onArticleRenderDone?(): void;
9
9
  }
10
+ /**
11
+ * Processes HTML content to ensure all links open in a new tab
12
+ * @param htmlContent - The HTML string to process
13
+ * @returns The processed HTML with target="_blank" added to all links
14
+ */
15
+ export declare const processLinksForNewTab: (htmlContent: string) => string;
10
16
  export declare const ArticleBody: (props: Props) => React.JSX.Element | null;
11
17
  export default ArticleBody;
@@ -1,3 +1,4 @@
1
1
  export { default } from './components/HelpArticle';
2
2
  export { BODY_FORMAT_TYPES } from './model/HelpArticle';
3
3
  export type { HelpArticle, AdfDoc } from './model/HelpArticle';
4
+ export { processLinksForNewTab } from './components/ArticleBody';
package/docs/0-intro.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { md, code, Example, Props, AtlassianInternalWarning } from '@atlaskit/docs';
3
3
 
4
- const _default_1: any = md`
4
+ const intro: React.ReactElement = md`
5
5
  ${(<AtlassianInternalWarning />)}
6
6
 
7
7
  ## Usage
@@ -34,4 +34,4 @@ const _default_1: any = md`
34
34
 
35
35
  ${(<Props props={require('!!extract-react-types-loader!../src/components/HelpArticle')} />)}
36
36
  `;
37
- export default _default_1;
37
+ export default intro;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/help-article",
3
- "version": "6.0.24",
3
+ "version": "6.0.26",
4
4
  "description": "A cross-product help-article component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -33,10 +33,10 @@
33
33
  "dependencies": {
34
34
  "@atlaskit/css-reset": "^7.3.0",
35
35
  "@atlaskit/heading": "^5.2.0",
36
- "@atlaskit/icon": "^29.0.0",
37
- "@atlaskit/primitives": "^16.1.0",
38
- "@atlaskit/renderer": "^124.12.0",
39
- "@atlaskit/tokens": "^8.0.0",
36
+ "@atlaskit/icon": "^29.3.0",
37
+ "@atlaskit/primitives": "^17.0.0",
38
+ "@atlaskit/renderer": "^124.22.0",
39
+ "@atlaskit/tokens": "^9.0.0",
40
40
  "@babel/runtime": "^7.0.0",
41
41
  "@compiled/react": "^0.18.6",
42
42
  "lodash": "^4.17.21"