@ndla/article-converter 1.0.1 → 1.0.3
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/README.md +32 -0
- package/es/plugins/{AsidePlugin.js → asidePlugin.js} +1 -1
- package/es/plugins/{CopyParagraphPlugin.js → copyParagraphPlugin.js} +1 -1
- package/es/plugins/{DivPlugin.js → divPlugin.js} +1 -1
- package/es/plugins/embed/{AudioEmbedPlugin.js → audioEmbedPlugin.js} +1 -1
- package/es/plugins/embed/{BrightcoveEmbedPlugin.js → brightcoveEmbedPlugin.js} +1 -1
- package/es/plugins/embed/{CodeEmbedPlugin.js → codeEmbedPlugin.js} +1 -1
- package/es/plugins/embed/{ConceptEmbedPlugin.js → conceptEmbedPlugin.js} +1 -1
- package/es/plugins/embed/{ConceptListEmbedPlugin.js → conceptListEmbedPlugin.js} +1 -1
- package/es/plugins/embed/{ContentLinkEmbedPlugin.js → contentLinkEmbedPlugin.js} +1 -1
- package/es/plugins/embed/{ExternalEmbedPlugin.js → externalEmbedPlugin.js} +1 -1
- package/es/plugins/embed/{FileEmbedPlugin.js → fileEmbedPlugin.js} +1 -1
- package/es/plugins/embed/{FootnoteEmbedPlugin.js → footnoteEmbedPlugin.js} +1 -1
- package/es/plugins/embed/{H5pEmbedPlugin.js → h5pEmbedPlugin.js} +1 -1
- package/es/plugins/embed/{IframeEmbedPlugin.js → iframeEmbedPlugin.js} +1 -1
- package/es/plugins/embed/{ImageEmbedPlugin.js → imageEmbedPlugin.js} +1 -1
- package/es/plugins/embed/index.js +26 -26
- package/es/plugins/embed/{RelatedContentEmbedPlugin.js → relatedContentEmbedPlugin.js} +1 -1
- package/es/plugins/{H3Plugin.js → h3Plugin.js} +1 -1
- package/es/plugins/index.js +22 -20
- package/es/plugins/{MathPlugin.js → mathPlugin.js} +1 -1
- package/es/plugins/oembed/{AnchorPlugin.js → anchorPlugin.js} +1 -1
- package/es/plugins/{OLPlugin.js → olPlugin.js} +1 -1
- package/es/plugins/{ParagraphPlugin.js → paragraphPlugin.js} +1 -1
- package/es/plugins/{SpanPlugin.js → spanPlugin.js} +1 -1
- package/es/plugins/{TablePlugin.js → tablePlugin.js} +1 -1
- package/es/plugins/{ULPlugin.js → ulPlugin.js} +1 -1
- package/lib/plugins/{AsidePlugin.d.ts → asidePlugin.d.ts} +1 -1
- package/lib/plugins/{AsidePlugin.js → asidePlugin.js} +3 -3
- package/lib/plugins/{CopyParagraphPlugin.d.ts → copyParagraphPlugin.d.ts} +1 -1
- package/lib/plugins/{CopyParagraphPlugin.js → copyParagraphPlugin.js} +3 -3
- package/lib/plugins/{DivPlugin.d.ts → divPlugin.d.ts} +1 -1
- package/lib/plugins/{DivPlugin.js → divPlugin.js} +3 -3
- package/lib/plugins/embed/{AudioEmbedPlugin.d.ts → audioEmbedPlugin.d.ts} +1 -1
- package/lib/plugins/embed/{AudioEmbedPlugin.js → audioEmbedPlugin.js} +3 -3
- package/lib/plugins/embed/{BrightcoveEmbedPlugin.d.ts → brightcoveEmbedPlugin.d.ts} +1 -1
- package/lib/plugins/embed/{BrightcoveEmbedPlugin.js → brightcoveEmbedPlugin.js} +3 -3
- package/lib/plugins/embed/{FileEmbedPlugin.d.ts → codeEmbedPlugin.d.ts} +1 -1
- package/lib/plugins/embed/{CodeEmbedPlugin.js → codeEmbedPlugin.js} +3 -3
- package/lib/plugins/embed/{ConceptEmbedPlugin.d.ts → conceptEmbedPlugin.d.ts} +1 -1
- package/lib/plugins/embed/{ConceptEmbedPlugin.js → conceptEmbedPlugin.js} +3 -3
- package/lib/plugins/embed/conceptListEmbedPlugin.d.ts +9 -0
- package/lib/plugins/embed/{ConceptListEmbedPlugin.js → conceptListEmbedPlugin.js} +3 -3
- package/lib/plugins/embed/contentLinkEmbedPlugin.d.ts +9 -0
- package/lib/plugins/embed/{ContentLinkEmbedPlugin.js → contentLinkEmbedPlugin.js} +3 -3
- package/lib/plugins/embed/{ExternalEmbedPlugin.d.ts → externalEmbedPlugin.d.ts} +1 -1
- package/lib/plugins/embed/{ExternalEmbedPlugin.js → externalEmbedPlugin.js} +3 -3
- package/lib/plugins/embed/{CodeEmbedPlugin.d.ts → fileEmbedPlugin.d.ts} +1 -1
- package/lib/plugins/embed/{FileEmbedPlugin.js → fileEmbedPlugin.js} +3 -3
- package/lib/plugins/embed/footnoteEmbedPlugin.d.ts +9 -0
- package/lib/plugins/embed/{FootnoteEmbedPlugin.js → footnoteEmbedPlugin.js} +3 -3
- package/lib/plugins/embed/{H5pEmbedPlugin.d.ts → h5pEmbedPlugin.d.ts} +1 -1
- package/lib/plugins/embed/{H5pEmbedPlugin.js → h5pEmbedPlugin.js} +3 -3
- package/lib/plugins/embed/iframeEmbedPlugin.d.ts +9 -0
- package/lib/plugins/embed/{IframeEmbedPlugin.js → iframeEmbedPlugin.js} +3 -3
- package/lib/plugins/embed/imageEmbedPlugin.d.ts +9 -0
- package/lib/plugins/embed/{ImageEmbedPlugin.js → imageEmbedPlugin.js} +3 -3
- package/lib/plugins/embed/index.js +26 -26
- package/lib/plugins/embed/relatedContentEmbedPlugin.d.ts +9 -0
- package/lib/plugins/embed/{RelatedContentEmbedPlugin.js → relatedContentEmbedPlugin.js} +3 -3
- package/lib/plugins/{OLPlugin.d.ts → h3Plugin.d.ts} +1 -1
- package/lib/plugins/{H3Plugin.js → h3Plugin.js} +3 -3
- package/lib/plugins/index.js +22 -20
- package/lib/plugins/{MathPlugin.d.ts → mathPlugin.d.ts} +1 -1
- package/lib/plugins/{MathPlugin.js → mathPlugin.js} +3 -3
- package/lib/plugins/oembed/{AnchorPlugin.d.ts → anchorPlugin.d.ts} +1 -1
- package/lib/plugins/oembed/{AnchorPlugin.js → anchorPlugin.js} +3 -3
- package/lib/plugins/{ULPlugin.d.ts → olPlugin.d.ts} +1 -1
- package/lib/plugins/{OLPlugin.js → olPlugin.js} +3 -3
- package/lib/plugins/paragraphPlugin.d.ts +9 -0
- package/lib/plugins/{ParagraphPlugin.js → paragraphPlugin.js} +3 -3
- package/lib/plugins/spanPlugin.d.ts +9 -0
- package/lib/plugins/{SpanPlugin.js → spanPlugin.js} +3 -3
- package/lib/plugins/tablePlugin.d.ts +9 -0
- package/lib/plugins/{TablePlugin.js → tablePlugin.js} +3 -3
- package/lib/plugins/{H3Plugin.d.ts → ulPlugin.d.ts} +1 -1
- package/lib/plugins/{ULPlugin.js → ulPlugin.js} +3 -3
- package/package.json +5 -5
- package/src/plugins/{AsidePlugin.tsx → asidePlugin.tsx} +1 -1
- package/src/plugins/{CopyParagraphPlugin.tsx → copyParagraphPlugin.tsx} +1 -1
- package/src/plugins/{DivPlugin.tsx → divPlugin.tsx} +1 -1
- package/src/plugins/embed/{AudioEmbedPlugin.tsx → audioEmbedPlugin.tsx} +1 -1
- package/src/plugins/embed/{BrightcoveEmbedPlugin.tsx → brightcoveEmbedPlugin.tsx} +1 -1
- package/src/plugins/embed/{CodeEmbedPlugin.tsx → codeEmbedPlugin.tsx} +1 -1
- package/src/plugins/embed/{ConceptEmbedPlugin.tsx → conceptEmbedPlugin.tsx} +1 -1
- package/src/plugins/embed/{ConceptListEmbedPlugin.tsx → conceptListEmbedPlugin.tsx} +1 -1
- package/src/plugins/embed/{ContentLinkEmbedPlugin.tsx → contentLinkEmbedPlugin.tsx} +1 -1
- package/src/plugins/embed/{ExternalEmbedPlugin.tsx → externalEmbedPlugin.tsx} +1 -1
- package/src/plugins/embed/{FileEmbedPlugin.tsx → fileEmbedPlugin.tsx} +1 -1
- package/src/plugins/embed/{FootnoteEmbedPlugin.tsx → footnoteEmbedPlugin.tsx} +1 -1
- package/src/plugins/embed/{H5pEmbedPlugin.tsx → h5pEmbedPlugin.tsx} +1 -1
- package/src/plugins/embed/{IframeEmbedPlugin.tsx → iframeEmbedPlugin.tsx} +1 -1
- package/src/plugins/embed/{ImageEmbedPlugin.tsx → imageEmbedPlugin.tsx} +1 -1
- package/src/plugins/embed/index.ts +26 -26
- package/src/plugins/embed/{RelatedContentEmbedPlugin.tsx → relatedContentEmbedPlugin.tsx} +1 -1
- package/src/plugins/{H3Plugin.tsx → h3Plugin.tsx} +1 -1
- package/src/plugins/index.ts +22 -20
- package/src/plugins/{MathPlugin.tsx → mathPlugin.tsx} +1 -1
- package/src/plugins/oembed/{AnchorPlugin.tsx → anchorPlugin.tsx} +1 -1
- package/src/plugins/{OLPlugin.tsx → olPlugin.tsx} +1 -1
- package/src/plugins/{ParagraphPlugin.tsx → paragraphPlugin.tsx} +1 -1
- package/src/plugins/{SpanPlugin.tsx → spanPlugin.tsx} +1 -1
- package/src/plugins/{TablePlugin.tsx → tablePlugin.tsx} +1 -1
- package/src/plugins/{ULPlugin.tsx → ulPlugin.tsx} +1 -1
- package/lib/plugins/ParagraphPlugin.d.ts +0 -9
- package/lib/plugins/SpanPlugin.d.ts +0 -9
- package/lib/plugins/TablePlugin.d.ts +0 -9
- package/lib/plugins/embed/ConceptListEmbedPlugin.d.ts +0 -9
- package/lib/plugins/embed/ContentLinkEmbedPlugin.d.ts +0 -9
- package/lib/plugins/embed/FootnoteEmbedPlugin.d.ts +0 -9
- package/lib/plugins/embed/IframeEmbedPlugin.d.ts +0 -9
- package/lib/plugins/embed/ImageEmbedPlugin.d.ts +0 -9
- package/lib/plugins/embed/RelatedContentEmbedPlugin.d.ts +0 -9
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.tablePlugin = void 0;
|
|
7
7
|
var _ui = require("@ndla/ui");
|
|
8
8
|
var _htmlReactParser = require("html-react-parser");
|
|
9
9
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
10
10
|
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; }
|
|
11
11
|
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; }
|
|
12
12
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
-
var
|
|
13
|
+
var tablePlugin = function tablePlugin(node, opts) {
|
|
14
14
|
var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
|
|
15
15
|
return (0, _jsxRuntime.jsx)(_ui.Table, _objectSpread(_objectSpread({}, props), {}, {
|
|
16
16
|
children: (0, _htmlReactParser.domToReact)(node.children, opts)
|
|
17
17
|
}));
|
|
18
18
|
};
|
|
19
|
-
exports.
|
|
19
|
+
exports.tablePlugin = tablePlugin;
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.ulPlugin = void 0;
|
|
7
7
|
var _htmlReactParser = require("html-react-parser");
|
|
8
8
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
9
9
|
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; }
|
|
10
10
|
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; }
|
|
11
11
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
-
var
|
|
12
|
+
var ulPlugin = function ulPlugin(node, opts) {
|
|
13
13
|
if (node.attribs['data-type'] === 'two-column') {
|
|
14
14
|
var _node$attribs$class;
|
|
15
15
|
var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
|
|
@@ -24,4 +24,4 @@ var OLPlugin = function OLPlugin(node, opts) {
|
|
|
24
24
|
}
|
|
25
25
|
return null;
|
|
26
26
|
};
|
|
27
|
-
exports.
|
|
27
|
+
exports.ulPlugin = ulPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/article-converter",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
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": "^1.0.
|
|
30
|
+
"@ndla/types-embed": "^1.0.1"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@ndla/code": "^2.1.
|
|
34
|
-
"@ndla/ui": "^34.6.
|
|
33
|
+
"@ndla/code": "^2.1.19",
|
|
34
|
+
"@ndla/ui": "^34.6.5",
|
|
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": "3d64cbc44a2f35c0e086a7b701765dfb34a40c04"
|
|
48
48
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { domToReact } from 'html-react-parser';
|
|
10
10
|
import { Aside, FactBoxV2 } from '@ndla/ui';
|
|
11
11
|
import { PluginType } from './types';
|
|
12
|
-
export const
|
|
12
|
+
export const asidePlugin: PluginType = (node, opts) => {
|
|
13
13
|
if (node.attribs['data-type'] === 'factAside') {
|
|
14
14
|
return <FactBoxV2>{domToReact(node.children, opts)}</FactBoxV2>;
|
|
15
15
|
} else if (node.attribs['data-type'] === 'rightAside') {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { CopyParagraphButtonV2 } from '@ndla/ui';
|
|
10
10
|
import { domToReact } from 'html-react-parser';
|
|
11
11
|
import { PluginType } from './types';
|
|
12
|
-
export const
|
|
12
|
+
export const copyParagraphPlugin: PluginType = (node, opts) => {
|
|
13
13
|
return (
|
|
14
14
|
<CopyParagraphButtonV2 copyText={node.attribs['data-text']}>
|
|
15
15
|
{domToReact(node.children, opts)}
|
|
@@ -10,7 +10,7 @@ import partition from 'lodash/partition';
|
|
|
10
10
|
import { domToReact, attributesToProps, Element } from 'html-react-parser';
|
|
11
11
|
import { FileListV2, RelatedArticleListV2 } from '@ndla/ui';
|
|
12
12
|
import { PluginType } from './types';
|
|
13
|
-
export const
|
|
13
|
+
export const divPlugin: PluginType = (node, opts) => {
|
|
14
14
|
if (node.attribs['data-type'] === 'related-content' && node.children.length) {
|
|
15
15
|
const props = attributesToProps(node.attribs);
|
|
16
16
|
|
|
@@ -11,7 +11,7 @@ import { AudioMetaData } from '@ndla/types-embed';
|
|
|
11
11
|
import { AudioEmbed } from '@ndla/ui';
|
|
12
12
|
import { PluginType } from '../types';
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const audioEmbedPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as AudioMetaData;
|
|
17
17
|
return <AudioEmbed embed={data} articlePath={opts.path} />;
|
|
@@ -11,7 +11,7 @@ import { BrightcoveMetaData } from '@ndla/types-embed';
|
|
|
11
11
|
import { BrightcoveEmbed } from '@ndla/ui';
|
|
12
12
|
import { PluginType } from '../types';
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const brightcoveEmbedPlugin: PluginType = (element) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as BrightcoveMetaData;
|
|
17
17
|
return <BrightcoveEmbed embed={data} />;
|
|
@@ -11,7 +11,7 @@ import { CodeMetaData } from '@ndla/types-embed';
|
|
|
11
11
|
import { CodeEmbed } from '@ndla/code';
|
|
12
12
|
import { PluginType } from '../types';
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const codeEmbedPlugin: PluginType = (element) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as CodeMetaData;
|
|
17
17
|
return <CodeEmbed embed={data} />;
|
|
@@ -11,7 +11,7 @@ import { ConceptMetaData } from '@ndla/types-embed';
|
|
|
11
11
|
import { ConceptEmbed } from '@ndla/ui';
|
|
12
12
|
import { PluginType } from '../types';
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const conceptEmbedPlugin: PluginType = (element) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as ConceptMetaData;
|
|
17
17
|
return <ConceptEmbed embed={data} fullWidth />;
|
|
@@ -11,7 +11,7 @@ import { ConceptListMetaData } from '@ndla/types-embed';
|
|
|
11
11
|
import { ConceptListEmbed } from '@ndla/ui';
|
|
12
12
|
import { PluginType } from '../types';
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const conceptListEmbedPlugin: PluginType = (element) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as ConceptListMetaData;
|
|
17
17
|
return <ConceptListEmbed embed={data} />;
|
|
@@ -11,7 +11,7 @@ import { ContentLinkMetaData } from '@ndla/types-embed';
|
|
|
11
11
|
import { ContentLinkEmbed } from '@ndla/ui';
|
|
12
12
|
import { PluginType } from '../types';
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const contentLinkEmbedPlugin: PluginType = (element, _, { isOembed }) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as ContentLinkMetaData;
|
|
17
17
|
return <ContentLinkEmbed embed={data} isOembed={isOembed} />;
|
|
@@ -11,7 +11,7 @@ import { OembedMetaData } from '@ndla/types-embed';
|
|
|
11
11
|
import { ExternalEmbed } from '@ndla/ui';
|
|
12
12
|
import { PluginType } from '../types';
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const externalEmbedPlugin: PluginType = (element) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as OembedMetaData;
|
|
17
17
|
return <ExternalEmbed embed={data} />;
|
|
@@ -11,7 +11,7 @@ import { FileMetaData } from '@ndla/types-embed';
|
|
|
11
11
|
import { PdfFile, FileV2 } from '@ndla/ui';
|
|
12
12
|
import { PluginType } from '../types';
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const fileEmbedPlugin: PluginType = (element) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as FileMetaData;
|
|
17
17
|
const { type, title, url } = data.embedData;
|
|
@@ -11,7 +11,7 @@ import { FootnoteMetaData } from '@ndla/types-embed';
|
|
|
11
11
|
import { FootnoteEmbed } from '@ndla/ui';
|
|
12
12
|
import { PluginType } from '../types';
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const footnoteEmbedPlugin: PluginType = (element) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as FootnoteMetaData;
|
|
17
17
|
return <FootnoteEmbed embed={data} />;
|
|
@@ -11,7 +11,7 @@ import { H5pMetaData } from '@ndla/types-embed';
|
|
|
11
11
|
import { H5pEmbed } from '@ndla/ui';
|
|
12
12
|
import { PluginType } from '../types';
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const h5pEmbedPlugin: PluginType = (element) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as H5pMetaData;
|
|
17
17
|
return <H5pEmbed embed={data} />;
|
|
@@ -11,7 +11,7 @@ import { IframeMetaData } from '@ndla/types-embed';
|
|
|
11
11
|
import { IframeEmbed } from '@ndla/ui';
|
|
12
12
|
import { PluginType } from '../types';
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const iframeEmbedPlugin: PluginType = (element) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as IframeMetaData;
|
|
17
17
|
return <IframeEmbed embed={data} />;
|
|
@@ -11,7 +11,7 @@ import { attributesToProps } from 'html-react-parser';
|
|
|
11
11
|
import { ImageMetaData } from '@ndla/types-embed';
|
|
12
12
|
import { PluginType } from '../types';
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const imageEmbedPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as ImageMetaData;
|
|
17
17
|
return <ImageEmbed embed={data} articlePath={opts.path} previewAlt={opts.previewAlt} />;
|
|
@@ -7,32 +7,32 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { PluginType } from '../types';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
10
|
+
import { audioEmbedPlugin } from './audioEmbedPlugin';
|
|
11
|
+
import { externalEmbedPlugin } from './externalEmbedPlugin';
|
|
12
|
+
import { h5pEmbedPlugin } from './h5pEmbedPlugin';
|
|
13
|
+
import { iframeEmbedPlugin } from './iframeEmbedPlugin';
|
|
14
|
+
import { imageEmbedPlugin } from './imageEmbedPlugin';
|
|
15
|
+
import { footnoteEmbedPlugin } from './footnoteEmbedPlugin';
|
|
16
|
+
import { brightcoveEmbedPlugin } from './brightcoveEmbedPlugin';
|
|
17
|
+
import { relatedContentEmbedPlugin } from './relatedContentEmbedPlugin';
|
|
18
|
+
import { contentLinkEmbedPlugin } from './contentLinkEmbedPlugin';
|
|
19
|
+
import { conceptEmbedPlugin } from './conceptEmbedPlugin';
|
|
20
|
+
import { conceptListEmbedPlugin } from './conceptListEmbedPlugin';
|
|
21
|
+
import { fileEmbedPlugin } from './fileEmbedPlugin';
|
|
22
|
+
import { codeEmbedPlugin } from './codeEmbedPlugin';
|
|
23
23
|
|
|
24
24
|
export const embedPlugins: Record<string, PluginType> = {
|
|
25
|
-
image:
|
|
26
|
-
audio:
|
|
27
|
-
h5p:
|
|
28
|
-
'code-block':
|
|
29
|
-
external:
|
|
30
|
-
iframe:
|
|
31
|
-
footnote:
|
|
32
|
-
brightcove:
|
|
33
|
-
'related-content':
|
|
34
|
-
'content-link':
|
|
35
|
-
concept:
|
|
36
|
-
'concept-list':
|
|
37
|
-
file:
|
|
25
|
+
image: imageEmbedPlugin,
|
|
26
|
+
audio: audioEmbedPlugin,
|
|
27
|
+
h5p: h5pEmbedPlugin,
|
|
28
|
+
'code-block': codeEmbedPlugin,
|
|
29
|
+
external: externalEmbedPlugin,
|
|
30
|
+
iframe: iframeEmbedPlugin,
|
|
31
|
+
footnote: footnoteEmbedPlugin,
|
|
32
|
+
brightcove: brightcoveEmbedPlugin,
|
|
33
|
+
'related-content': relatedContentEmbedPlugin,
|
|
34
|
+
'content-link': contentLinkEmbedPlugin,
|
|
35
|
+
concept: conceptEmbedPlugin,
|
|
36
|
+
'concept-list': conceptListEmbedPlugin,
|
|
37
|
+
file: fileEmbedPlugin,
|
|
38
38
|
};
|
|
@@ -11,7 +11,7 @@ import { RelatedContentMetaData } from '@ndla/types-embed';
|
|
|
11
11
|
import { RelatedContentEmbed } from '@ndla/ui';
|
|
12
12
|
import { PluginType } from '../types';
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const relatedContentEmbedPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as RelatedContentMetaData;
|
|
17
17
|
return <RelatedContentEmbed embed={data} subject={opts.subject} ndlaFrontendDomain={opts.frontendDomain} />;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { attributesToProps, domToReact } from 'html-react-parser';
|
|
10
10
|
import { PluginType } from './types';
|
|
11
|
-
export const
|
|
11
|
+
export const h3Plugin: PluginType = (node, opts) => {
|
|
12
12
|
const props = attributesToProps(node.attribs);
|
|
13
13
|
return (
|
|
14
14
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
package/src/plugins/index.ts
CHANGED
|
@@ -6,31 +6,33 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { copyParagraphPlugin } from './copyParagraphPlugin';
|
|
10
10
|
import { PluginType } from './types';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
11
|
+
import { olPlugin } from './olPlugin';
|
|
12
|
+
import { paragraphPlugin } from './paragraphPlugin';
|
|
13
|
+
import { spanPlugin } from './spanPlugin';
|
|
14
|
+
import { h3Plugin } from './h3Plugin';
|
|
15
|
+
import { mathPlugin } from './mathPlugin';
|
|
16
|
+
import { anchorPlugin } from './oembed/anchorPlugin';
|
|
17
|
+
import { divPlugin } from './divPlugin';
|
|
18
|
+
import { tablePlugin } from './tablePlugin';
|
|
19
|
+
import { asidePlugin } from './asidePlugin';
|
|
20
|
+
import { ulPlugin } from './ulPlugin';
|
|
20
21
|
|
|
21
22
|
export const basePlugins: Record<string, PluginType> = {
|
|
22
|
-
h2:
|
|
23
|
-
h3:
|
|
24
|
-
ol:
|
|
25
|
-
p:
|
|
26
|
-
span:
|
|
27
|
-
math:
|
|
28
|
-
div:
|
|
29
|
-
table:
|
|
30
|
-
aside:
|
|
23
|
+
h2: copyParagraphPlugin,
|
|
24
|
+
h3: h3Plugin,
|
|
25
|
+
ol: olPlugin,
|
|
26
|
+
p: paragraphPlugin,
|
|
27
|
+
span: spanPlugin,
|
|
28
|
+
math: mathPlugin,
|
|
29
|
+
div: divPlugin,
|
|
30
|
+
table: tablePlugin,
|
|
31
|
+
aside: asidePlugin,
|
|
32
|
+
ul: ulPlugin,
|
|
31
33
|
};
|
|
32
34
|
|
|
33
35
|
export const oembedPlugins: Record<string, PluginType> = {
|
|
34
36
|
...basePlugins,
|
|
35
|
-
a:
|
|
37
|
+
a: anchorPlugin,
|
|
36
38
|
};
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { attributesToProps } from 'html-react-parser';
|
|
10
10
|
import { PluginType } from './types';
|
|
11
|
-
export const
|
|
11
|
+
export const mathPlugin: PluginType = (node) => {
|
|
12
12
|
const props = attributesToProps(node.attribs);
|
|
13
13
|
return <span dangerouslySetInnerHTML={{ __html: `<math display="block">${props['data-math']}</math>` }} />;
|
|
14
14
|
};
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { attributesToProps, domToReact } from 'html-react-parser';
|
|
10
10
|
import { PluginType } from '../types';
|
|
11
|
-
export const
|
|
11
|
+
export const anchorPlugin: PluginType = (node, options) => {
|
|
12
12
|
const props = attributesToProps(node.attribs);
|
|
13
13
|
return (
|
|
14
14
|
<a {...props} target="_blank">
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { attributesToProps, domToReact } from 'html-react-parser';
|
|
10
10
|
import { PluginType } from './types';
|
|
11
|
-
export const
|
|
11
|
+
export const olPlugin: PluginType = (node, opts) => {
|
|
12
12
|
const props = attributesToProps(node.attribs);
|
|
13
13
|
const letterClass = node.attribs['data-type'] === 'letters' ? 'ol-list--roman' : false;
|
|
14
14
|
const num = node.attribs['start'];
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { attributesToProps, domToReact } from 'html-react-parser';
|
|
10
10
|
import { PluginType } from './types';
|
|
11
|
-
export const
|
|
11
|
+
export const paragraphPlugin: PluginType = (node, opts) => {
|
|
12
12
|
if (node.attribs['data-align'] === 'center') {
|
|
13
13
|
const props = attributesToProps(node.attribs);
|
|
14
14
|
const classes = [node.attribs.class ?? '', 'u-text-center'].filter((c) => !!c).join(' ');
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { attributesToProps, domToReact } from 'html-react-parser';
|
|
10
10
|
import { PluginType } from './types';
|
|
11
|
-
export const
|
|
11
|
+
export const spanPlugin: PluginType = (node, opts) => {
|
|
12
12
|
if (node.attribs['data-size'] === 'large') {
|
|
13
13
|
const props = attributesToProps(node.attribs);
|
|
14
14
|
return (
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { Table } from '@ndla/ui';
|
|
10
10
|
import { attributesToProps, domToReact } from 'html-react-parser';
|
|
11
11
|
import { PluginType } from './types';
|
|
12
|
-
export const
|
|
12
|
+
export const tablePlugin: PluginType = (node, opts) => {
|
|
13
13
|
const props = attributesToProps(node.attribs);
|
|
14
14
|
return <Table {...props}>{domToReact(node.children, opts)}</Table>;
|
|
15
15
|
};
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { attributesToProps, domToReact } from 'html-react-parser';
|
|
10
10
|
import { PluginType } from './types';
|
|
11
|
-
export const
|
|
11
|
+
export const ulPlugin: PluginType = (node, opts) => {
|
|
12
12
|
if (node.attribs['data-type'] === 'two-column') {
|
|
13
13
|
const props = attributesToProps(node.attribs);
|
|
14
14
|
const classes = [node.attribs.class ?? '', 'o-list--two-columns'].filter((c) => !!c).join(' ');
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-present, NDLA.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
import { PluginType } from './types';
|
|
9
|
-
export declare const ParagraphPlugin: PluginType;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-present, NDLA.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
import { PluginType } from './types';
|
|
9
|
-
export declare const SpanPlugin: PluginType;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-present, NDLA.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
import { PluginType } from './types';
|
|
9
|
-
export declare const TablePlugin: PluginType;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-present, NDLA.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
import { PluginType } from '../types';
|
|
9
|
-
export declare const ConceptListEmbedPlugin: PluginType;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-present, NDLA.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
import { PluginType } from '../types';
|
|
9
|
-
export declare const ContentLinkEmbedPlugin: PluginType;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-present, NDLA.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
import { PluginType } from '../types';
|
|
9
|
-
export declare const FootnoteEmbedPlugin: PluginType;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-present, NDLA.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
import { PluginType } from '../types';
|
|
9
|
-
export declare const IframeEmbedPlugin: PluginType;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-present, NDLA.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
import { PluginType } from '../types';
|
|
9
|
-
export declare const ImageEmbedPlugin: PluginType;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-present, NDLA.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
import { PluginType } from '../types';
|
|
9
|
-
export declare const RelatedContentEmbedPlugin: PluginType;
|