@ndla/article-converter 2.4.0 → 2.4.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.
@@ -10,8 +10,9 @@ import { CopyParagraphButtonV2 } from '@ndla/ui';
10
10
  import { domToReact } from 'html-react-parser';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
12
  export var copyParagraphPlugin = function copyParagraphPlugin(node, opts) {
13
- var _node$parent;
14
- if (((_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.name) === 'section') {
13
+ var _parent$attribs;
14
+ var parent = node.parent;
15
+ if ((parent === null || parent === void 0 ? void 0 : parent.name) === 'section' || (parent === null || parent === void 0 ? void 0 : parent.name) === 'div' && Object.keys((_parent$attribs = parent.attribs) !== null && _parent$attribs !== void 0 ? _parent$attribs : {}).length === 0) {
15
16
  return _jsx(CopyParagraphButtonV2, {
16
17
  copyText: node.attribs['data-text'],
17
18
  children: domToReact(node.children, opts)
@@ -16,8 +16,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
16
16
  */
17
17
 
18
18
  var copyParagraphPlugin = function copyParagraphPlugin(node, opts) {
19
- var _node$parent;
20
- if (((_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.name) === 'section') {
19
+ var _parent$attribs;
20
+ var parent = node.parent;
21
+ if ((parent === null || parent === void 0 ? void 0 : parent.name) === 'section' || (parent === null || parent === void 0 ? void 0 : parent.name) === 'div' && Object.keys((_parent$attribs = parent.attribs) !== null && _parent$attribs !== void 0 ? _parent$attribs : {}).length === 0) {
21
22
  return (0, _jsxRuntime.jsx)(_ui.CopyParagraphButtonV2, {
22
23
  copyText: node.attribs['data-text'],
23
24
  children: (0, _htmlReactParser.domToReact)(node.children, opts)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/article-converter",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Transforms NDLA articles into extended html versions",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@ndla/code": "^2.2.15",
34
- "@ndla/ui": "^42.0.0",
34
+ "@ndla/ui": "^42.0.1",
35
35
  "html-react-parser": "^3.0.8",
36
36
  "lodash": "^4.17.20"
37
37
  },
@@ -44,5 +44,5 @@
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  },
47
- "gitHead": "7a418d51a890d239ba9a2fb1eb8058141cb41c4b"
47
+ "gitHead": "a96d41fdd79d1372f1b8e8a3f50ad52983d26e30"
48
48
  }
@@ -10,7 +10,8 @@ import { CopyParagraphButtonV2 } from '@ndla/ui';
10
10
  import { Element, domToReact } from 'html-react-parser';
11
11
  import { PluginType } from './types';
12
12
  export const copyParagraphPlugin: PluginType = (node, opts) => {
13
- if ((node.parent as Element | undefined)?.name === 'section') {
13
+ const parent = node.parent as Element | undefined;
14
+ if (parent?.name === 'section' || (parent?.name === 'div' && Object.keys(parent.attribs ?? {}).length === 0)) {
14
15
  return (
15
16
  <CopyParagraphButtonV2 copyText={node.attribs['data-text']}>
16
17
  {domToReact(node.children, opts)}