@ndla/article-converter 3.0.5 → 4.0.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/es/plugins/embed/campaignBlockPlugin.js +4 -7
- package/es/plugins/mathPlugin.js +16 -4
- package/lib/plugins/embed/campaignBlockPlugin.js +4 -7
- package/lib/plugins/mathPlugin.js +16 -5
- package/package.json +5 -5
- package/src/plugins/embed/campaignBlockPlugin.tsx +4 -8
- package/src/plugins/mathPlugin.tsx +3 -2
|
@@ -27,13 +27,10 @@ export var campaignBlockPlugin = function campaignBlockPlugin(element, _, opts)
|
|
|
27
27
|
text: embed.urlText
|
|
28
28
|
},
|
|
29
29
|
path: opts.path,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
imageBefore: data.status === 'success' && data.data.imageBefore ? {
|
|
35
|
-
src: data.data.imageBefore.image.imageUrl,
|
|
36
|
-
alt: data.data.imageBefore.alttext.alttext
|
|
30
|
+
imageSide: embed.imageSide,
|
|
31
|
+
image: data.status === 'success' && data.data.image ? {
|
|
32
|
+
src: data.data.image.image.imageUrl,
|
|
33
|
+
alt: data.data.image.alttext.alttext
|
|
37
34
|
} : undefined
|
|
38
35
|
});
|
|
39
36
|
};
|
package/es/plugins/mathPlugin.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
var _excluded = ["data-math"];
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
1
10
|
/**
|
|
2
11
|
* Copyright (c) 2023-present, NDLA.
|
|
3
12
|
*
|
|
@@ -9,10 +18,13 @@
|
|
|
9
18
|
import { attributesToProps } from 'html-react-parser';
|
|
10
19
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
11
20
|
export var mathPlugin = function mathPlugin(node) {
|
|
12
|
-
var
|
|
13
|
-
|
|
21
|
+
var _attributesToProps = attributesToProps(node.attribs),
|
|
22
|
+
mathContent = _attributesToProps['data-math'],
|
|
23
|
+
props = _objectWithoutProperties(_attributesToProps, _excluded);
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
return _jsx("math", _objectSpread(_objectSpread({}, props), {}, {
|
|
14
26
|
dangerouslySetInnerHTML: {
|
|
15
|
-
__html:
|
|
27
|
+
__html: mathContent
|
|
16
28
|
}
|
|
17
|
-
});
|
|
29
|
+
}));
|
|
18
30
|
};
|
|
@@ -33,13 +33,10 @@ var campaignBlockPlugin = function campaignBlockPlugin(element, _, opts) {
|
|
|
33
33
|
text: embed.urlText
|
|
34
34
|
},
|
|
35
35
|
path: opts.path,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
imageBefore: data.status === 'success' && data.data.imageBefore ? {
|
|
41
|
-
src: data.data.imageBefore.image.imageUrl,
|
|
42
|
-
alt: data.data.imageBefore.alttext.alttext
|
|
36
|
+
imageSide: embed.imageSide,
|
|
37
|
+
image: data.status === 'success' && data.data.image ? {
|
|
38
|
+
src: data.data.image.image.imageUrl,
|
|
39
|
+
alt: data.data.image.alttext.alttext
|
|
43
40
|
} : undefined
|
|
44
41
|
});
|
|
45
42
|
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.mathPlugin = void 0;
|
|
7
8
|
var _htmlReactParser = require("html-react-parser");
|
|
8
9
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
10
|
+
var _excluded = ["data-math"];
|
|
9
11
|
/**
|
|
10
12
|
* Copyright (c) 2023-present, NDLA.
|
|
11
13
|
*
|
|
@@ -13,13 +15,22 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
13
15
|
* LICENSE file in the root directory of this source tree.
|
|
14
16
|
*
|
|
15
17
|
*/
|
|
16
|
-
|
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
22
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
23
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
24
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
25
|
var mathPlugin = function mathPlugin(node) {
|
|
18
|
-
var
|
|
19
|
-
|
|
26
|
+
var _attributesToProps = (0, _htmlReactParser.attributesToProps)(node.attribs),
|
|
27
|
+
mathContent = _attributesToProps['data-math'],
|
|
28
|
+
props = _objectWithoutProperties(_attributesToProps, _excluded);
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
return (0, _jsxRuntime.jsx)("math", _objectSpread(_objectSpread({}, props), {}, {
|
|
20
31
|
dangerouslySetInnerHTML: {
|
|
21
|
-
__html:
|
|
32
|
+
__html: mathContent
|
|
22
33
|
}
|
|
23
|
-
});
|
|
34
|
+
}));
|
|
24
35
|
};
|
|
25
36
|
exports.mathPlugin = mathPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/article-converter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Transforms NDLA articles into extended html versions",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"src"
|
|
28
28
|
],
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@ndla/types-embed": "^
|
|
30
|
+
"@ndla/types-embed": "^4.0.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@ndla/code": "^
|
|
34
|
-
"@ndla/ui": "^
|
|
33
|
+
"@ndla/code": "^3.0.0",
|
|
34
|
+
"@ndla/ui": "^45.0.0",
|
|
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": "
|
|
47
|
+
"gitHead": "5acc97933b03a599d9ad83a4e3a6d305b573f83c"
|
|
48
48
|
}
|
|
@@ -21,14 +21,10 @@ export const campaignBlockPlugin: PluginType = (element, _, opts) => {
|
|
|
21
21
|
description={{ text: embed.description, language: embed.descriptionLanguage }}
|
|
22
22
|
url={{ url: embed.url, text: embed.urlText }}
|
|
23
23
|
path={opts.path}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
:
|
|
28
|
-
}
|
|
29
|
-
imageBefore={
|
|
30
|
-
data.status === 'success' && data.data.imageBefore
|
|
31
|
-
? { src: data.data.imageBefore.image.imageUrl, alt: data.data.imageBefore.alttext.alttext }
|
|
24
|
+
imageSide={embed.imageSide}
|
|
25
|
+
image={
|
|
26
|
+
data.status === 'success' && data.data.image
|
|
27
|
+
? { src: data.data.image.image.imageUrl, alt: data.data.image.alttext.alttext }
|
|
32
28
|
: undefined
|
|
33
29
|
}
|
|
34
30
|
/>
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { attributesToProps } from 'html-react-parser';
|
|
10
10
|
import { PluginType } from './types';
|
|
11
11
|
export const mathPlugin: PluginType = (node) => {
|
|
12
|
-
const props = attributesToProps(node.attribs);
|
|
13
|
-
|
|
12
|
+
const { 'data-math': mathContent, ...props } = attributesToProps(node.attribs);
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
return <math {...props} dangerouslySetInnerHTML={{ __html: mathContent }} />;
|
|
14
15
|
};
|