@ndla/ui 56.0.121-alpha.0 → 56.0.122-alpha.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/lib/i18n/index.d.ts +1 -1
- package/lib/i18n/useComponentTranslations.d.ts +2 -1
- package/lib/index.d.ts +1 -1
- package/lib/locale/messages-en.d.ts +34 -0
- package/lib/locale/messages-nb.d.ts +34 -0
- package/lib/locale/messages-nn.d.ts +34 -0
- package/lib/locale/messages-se.d.ts +34 -0
- package/package.json +6 -5
- package/src/Article/ArticleByline.tsx +1 -1
- package/src/i18n/index.ts +1 -0
- package/src/i18n/useComponentTranslations.ts +36 -1
- package/src/index.ts +1 -0
- package/src/locale/messages-en.ts +34 -0
- package/src/locale/messages-nb.ts +34 -0
- package/src/locale/messages-nn.ts +34 -0
- package/src/locale/messages-se.ts +34 -0
- package/es/Article/Article.js +0 -199
- package/es/Article/ArticleByline.js +0 -182
- package/es/Article/ArticleFootNotes.js +0 -60
- package/es/Article/index.js +0 -11
- package/es/AudioPlayer/AudioPlayer.js +0 -218
- package/es/AudioPlayer/Controls.js +0 -332
- package/es/AudioPlayer/SpeechControl.js +0 -56
- package/es/AudioPlayer/index.js +0 -10
- package/es/Breadcrumb/Breadcrumb.js +0 -60
- package/es/Breadcrumb/BreadcrumbItem.js +0 -62
- package/es/Breadcrumb/HomeBreadcrumb.js +0 -77
- package/es/Breadcrumb/index.js +0 -11
- package/es/CampaignBlock/CampaignBlock.js +0 -180
- package/es/CampaignBlock/index.js +0 -9
- package/es/CodeBlock/CodeBlock.js +0 -35
- package/es/CodeBlock/codeLanguageOptions.js +0 -84
- package/es/CodeBlock/index.js +0 -10
- package/es/Concept/Concept.js +0 -72
- package/es/ContactBlock/ContactBlock.js +0 -199
- package/es/ContactBlock/index.js +0 -9
- package/es/ContentTypeBadge/ContentTypeBadge.js +0 -50
- package/es/ContentTypeBlockQuote/ContentTypeBlockQuote.js +0 -32
- package/es/ContentTypeFramedContent/ContentTypeFramedContent.js +0 -32
- package/es/ContentTypeHero/ContentTypeHero.js +0 -50
- package/es/ContentTypeHero/index.js +0 -9
- package/es/CopyParagraphButton/CopyParagraphButton.js +0 -83
- package/es/CopyParagraphButton/index.js +0 -11
- package/es/Embed/AudioEmbed.js +0 -76
- package/es/Embed/BrightcoveEmbed.js +0 -133
- package/es/Embed/CodeEmbed.js +0 -79
- package/es/Embed/ConceptEmbed.js +0 -123
- package/es/Embed/ConceptInlineTriggerButton.js +0 -45
- package/es/Embed/ContentLinkEmbed.js +0 -51
- package/es/Embed/CopyrightEmbed.js +0 -33
- package/es/Embed/EmbedErrorPlaceholder.js +0 -58
- package/es/Embed/EmbedWrapper.js +0 -51
- package/es/Embed/ExternalEmbed.js +0 -74
- package/es/Embed/FootnoteEmbed.js +0 -44
- package/es/Embed/GlossEmbed.js +0 -80
- package/es/Embed/H5pEmbed.js +0 -61
- package/es/Embed/IframeEmbed.js +0 -93
- package/es/Embed/ImageEmbed.js +0 -238
- package/es/Embed/InlineTriggerButton.js +0 -37
- package/es/Embed/RelatedContentEmbed.js +0 -55
- package/es/Embed/UnknownEmbed.js +0 -31
- package/es/Embed/UuDisclaimerEmbed.js +0 -88
- package/es/Embed/index.js +0 -25
- package/es/Embed/types.js +0 -1
- package/es/ErrorMessage/ErrorMessage.js +0 -95
- package/es/ErrorMessage/index.js +0 -10
- package/es/FactBox/FactBox.js +0 -177
- package/es/FactBox/index.js +0 -10
- package/es/FileList/File.js +0 -101
- package/es/FileList/FileList.js +0 -47
- package/es/FileList/PdfFile.js +0 -50
- package/es/FileList/index.js +0 -11
- package/es/Gloss/Gloss.js +0 -175
- package/es/Gloss/GlossExample.js +0 -64
- package/es/Gloss/index.js +0 -10
- package/es/Grid/Grid.js +0 -94
- package/es/Grid/GridParallaxItem.js +0 -32
- package/es/Grid/index.js +0 -10
- package/es/KeyFigure/KeyFigure.js +0 -63
- package/es/KeyFigure/index.js +0 -9
- package/es/LicenseByline/EmbedByline.js +0 -212
- package/es/LicenseByline/LicenseLink.js +0 -56
- package/es/LicenseByline/index.js +0 -10
- package/es/LinkBlock/LinkBlock.js +0 -103
- package/es/LinkBlock/LinkBlockSection.js +0 -35
- package/es/LinkBlock/index.js +0 -10
- package/es/Pitch/Pitch.js +0 -83
- package/es/Pitch/index.js +0 -9
- package/es/RelatedArticleList/RelatedArticleList.js +0 -135
- package/es/RelatedArticleList/index.js +0 -11
- package/es/ResourceBox/ResourceBox.js +0 -99
- package/es/ResourceBox/index.js +0 -10
- package/es/TagSelector/TagSelector.js +0 -143
- package/es/ZendeskButton/ZendeskButton.js +0 -55
- package/es/i18n/formatNestedMessages.js +0 -25
- package/es/i18n/i18n.js +0 -35
- package/es/i18n/index.js +0 -11
- package/es/i18n/useComponentTranslations.js +0 -164
- package/es/index.js +0 -45
- package/es/locale/messages-en.js +0 -428
- package/es/locale/messages-nb.js +0 -428
- package/es/locale/messages-nn.js +0 -428
- package/es/locale/messages-se.js +0 -428
- package/es/model/ContentType.js +0 -68
- package/es/model/SubjectCategories.js +0 -12
- package/es/model/SubjectTypes.js +0 -11
- package/es/model/WordClass.js +0 -45
- package/es/model/index.js +0 -21
- package/es/types.js +0 -1
- package/es/utils/licenseAttributes.js +0 -18
- package/es/utils/relativeUrl.js +0 -37
- package/lib/Article/Article.js +0 -207
- package/lib/Article/ArticleByline.js +0 -189
- package/lib/Article/ArticleFootNotes.js +0 -67
- package/lib/Article/index.js +0 -68
- package/lib/AudioPlayer/AudioPlayer.js +0 -224
- package/lib/AudioPlayer/Controls.js +0 -338
- package/lib/AudioPlayer/SpeechControl.js +0 -62
- package/lib/AudioPlayer/index.js +0 -16
- package/lib/Breadcrumb/Breadcrumb.js +0 -67
- package/lib/Breadcrumb/BreadcrumbItem.js +0 -68
- package/lib/Breadcrumb/HomeBreadcrumb.js +0 -84
- package/lib/Breadcrumb/index.js +0 -23
- package/lib/CampaignBlock/CampaignBlock.js +0 -187
- package/lib/CampaignBlock/index.js +0 -13
- package/lib/CodeBlock/CodeBlock.js +0 -41
- package/lib/CodeBlock/codeLanguageOptions.js +0 -90
- package/lib/CodeBlock/index.js +0 -20
- package/lib/Concept/Concept.js +0 -78
- package/lib/ContactBlock/ContactBlock.js +0 -206
- package/lib/ContactBlock/index.js +0 -18
- package/lib/ContentTypeBadge/ContentTypeBadge.js +0 -57
- package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.js +0 -38
- package/lib/ContentTypeFramedContent/ContentTypeFramedContent.js +0 -38
- package/lib/ContentTypeHero/ContentTypeHero.js +0 -57
- package/lib/ContentTypeHero/index.js +0 -12
- package/lib/CopyParagraphButton/CopyParagraphButton.js +0 -89
- package/lib/CopyParagraphButton/index.js +0 -22
- package/lib/Embed/AudioEmbed.js +0 -84
- package/lib/Embed/BrightcoveEmbed.js +0 -142
- package/lib/Embed/CodeEmbed.js +0 -86
- package/lib/Embed/ConceptEmbed.js +0 -131
- package/lib/Embed/ConceptInlineTriggerButton.js +0 -51
- package/lib/Embed/ContentLinkEmbed.js +0 -57
- package/lib/Embed/CopyrightEmbed.js +0 -39
- package/lib/Embed/EmbedErrorPlaceholder.js +0 -64
- package/lib/Embed/EmbedWrapper.js +0 -57
- package/lib/Embed/ExternalEmbed.js +0 -81
- package/lib/Embed/FootnoteEmbed.js +0 -50
- package/lib/Embed/GlossEmbed.js +0 -88
- package/lib/Embed/H5pEmbed.js +0 -68
- package/lib/Embed/IframeEmbed.js +0 -100
- package/lib/Embed/ImageEmbed.js +0 -248
- package/lib/Embed/InlineTriggerButton.js +0 -43
- package/lib/Embed/RelatedContentEmbed.js +0 -61
- package/lib/Embed/UnknownEmbed.js +0 -37
- package/lib/Embed/UuDisclaimerEmbed.js +0 -94
- package/lib/Embed/index.js +0 -150
- package/lib/Embed/types.js +0 -5
- package/lib/ErrorMessage/ErrorMessage.js +0 -101
- package/lib/ErrorMessage/index.js +0 -16
- package/lib/FactBox/FactBox.js +0 -184
- package/lib/FactBox/index.js +0 -16
- package/lib/FileList/File.js +0 -108
- package/lib/FileList/FileList.js +0 -54
- package/lib/FileList/PdfFile.js +0 -57
- package/lib/FileList/index.js +0 -44
- package/lib/Gloss/Gloss.js +0 -181
- package/lib/Gloss/GlossExample.js +0 -70
- package/lib/Gloss/index.js +0 -20
- package/lib/Grid/Grid.js +0 -101
- package/lib/Grid/GridParallaxItem.js +0 -39
- package/lib/Grid/index.js +0 -19
- package/lib/KeyFigure/KeyFigure.js +0 -70
- package/lib/KeyFigure/index.js +0 -13
- package/lib/LicenseByline/EmbedByline.js +0 -220
- package/lib/LicenseByline/LicenseLink.js +0 -62
- package/lib/LicenseByline/index.js +0 -19
- package/lib/LinkBlock/LinkBlock.js +0 -110
- package/lib/LinkBlock/LinkBlockSection.js +0 -41
- package/lib/LinkBlock/index.js +0 -20
- package/lib/Pitch/Pitch.js +0 -91
- package/lib/Pitch/index.js +0 -12
- package/lib/RelatedArticleList/RelatedArticleList.js +0 -143
- package/lib/RelatedArticleList/index.js +0 -21
- package/lib/ResourceBox/ResourceBox.js +0 -106
- package/lib/ResourceBox/index.js +0 -13
- package/lib/TagSelector/TagSelector.js +0 -150
- package/lib/ZendeskButton/ZendeskButton.js +0 -61
- package/lib/i18n/formatNestedMessages.js +0 -32
- package/lib/i18n/i18n.js +0 -41
- package/lib/i18n/index.js +0 -62
- package/lib/i18n/useComponentTranslations.js +0 -176
- package/lib/index.js +0 -593
- package/lib/locale/messages-en.js +0 -435
- package/lib/locale/messages-nb.js +0 -435
- package/lib/locale/messages-nn.js +0 -435
- package/lib/locale/messages-se.js +0 -435
- package/lib/model/ContentType.js +0 -74
- package/lib/model/SubjectCategories.js +0 -18
- package/lib/model/SubjectTypes.js +0 -17
- package/lib/model/WordClass.js +0 -51
- package/lib/model/index.js +0 -28
- package/lib/types.js +0 -5
- package/lib/utils/licenseAttributes.js +0 -25
- package/lib/utils/relativeUrl.js +0 -44
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024-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
|
-
|
|
9
|
-
import { forwardRef } from "react";
|
|
10
|
-
import { FramedContent } from "@ndla/primitives";
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
const contentTypeToVariantMapping = {
|
|
13
|
-
"subject-material": "brand1",
|
|
14
|
-
"source-material": "brand1",
|
|
15
|
-
concept: "brand1",
|
|
16
|
-
"tasks-and-activities": "brand2",
|
|
17
|
-
"assessment-resources": "brand2"
|
|
18
|
-
};
|
|
19
|
-
export const ContentTypeFramedContent = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
20
|
-
let {
|
|
21
|
-
variant = "neutral",
|
|
22
|
-
contentType,
|
|
23
|
-
...props
|
|
24
|
-
} = _ref;
|
|
25
|
-
const color = contentType ? contentTypeToVariantMapping[contentType] ?? "brand1" : "brand1";
|
|
26
|
-
const variantColor = variant === "colored" ? color : undefined;
|
|
27
|
-
return /*#__PURE__*/_jsx(FramedContent, {
|
|
28
|
-
...props,
|
|
29
|
-
colorTheme: variantColor,
|
|
30
|
-
ref: ref
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024-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
|
-
|
|
9
|
-
import { forwardRef } from "react";
|
|
10
|
-
import { Hero } from "@ndla/primitives";
|
|
11
|
-
import * as contentTypes from "../model/ContentType";
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
export const contentTypeToHeroMap = {
|
|
14
|
-
[contentTypes.SUBJECT_MATERIAL]: "primary",
|
|
15
|
-
[contentTypes.TASKS_AND_ACTIVITIES]: "brand2Bold",
|
|
16
|
-
[contentTypes.ASSESSMENT_RESOURCES]: "brand2",
|
|
17
|
-
// This will never happen
|
|
18
|
-
[contentTypes.SUBJECT]: "primary",
|
|
19
|
-
[contentTypes.SOURCE_MATERIAL]: "brand1",
|
|
20
|
-
// This will never happen
|
|
21
|
-
[contentTypes.LEARNING_PATH]: "primary",
|
|
22
|
-
[contentTypes.TOPIC]: "neutral",
|
|
23
|
-
[contentTypes.MULTIDISCIPLINARY]: "primary",
|
|
24
|
-
[contentTypes.CONCEPT]: "brand1Moderate",
|
|
25
|
-
[contentTypes.EXTERNAL]: "primary",
|
|
26
|
-
[contentTypes.IMAGE]: "primary",
|
|
27
|
-
[contentTypes.AUDIO]: "primary",
|
|
28
|
-
[contentTypes.PODCAST]: "primary",
|
|
29
|
-
[contentTypes.VIDEO]: "primary",
|
|
30
|
-
[contentTypes.MISSING]: "neutral",
|
|
31
|
-
[contentTypes.GLOSS]: "brand1Moderate",
|
|
32
|
-
// this will never happen
|
|
33
|
-
[contentTypes.PROGRAMME]: "primary",
|
|
34
|
-
// this will never happen
|
|
35
|
-
[contentTypes.PODCAST_SERIES]: "primary",
|
|
36
|
-
[contentTypes.FRONTPAGE_ARTICLE]: "primary"
|
|
37
|
-
};
|
|
38
|
-
export const ContentTypeHero = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
39
|
-
let {
|
|
40
|
-
contentType,
|
|
41
|
-
children,
|
|
42
|
-
...props
|
|
43
|
-
} = _ref;
|
|
44
|
-
return /*#__PURE__*/_jsx(Hero, {
|
|
45
|
-
variant: contentTypeToHeroMap[contentType ?? "missing"] ?? contentTypeToHeroMap["missing"],
|
|
46
|
-
...props,
|
|
47
|
-
ref: ref,
|
|
48
|
-
children: children
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2021-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
|
-
|
|
9
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
10
|
-
import { useTranslation } from "react-i18next";
|
|
11
|
-
import { LinkMedium } from "@ndla/icons";
|
|
12
|
-
import { IconButton } from "@ndla/primitives";
|
|
13
|
-
import { styled } from "@ndla/styled-system/jsx";
|
|
14
|
-
import { copyTextToClipboard } from "@ndla/util";
|
|
15
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
const ContainerDiv = styled("div", {
|
|
17
|
-
base: {
|
|
18
|
-
position: "relative",
|
|
19
|
-
_hover: {
|
|
20
|
-
"& [data-copy-button]": {
|
|
21
|
-
opacity: "1",
|
|
22
|
-
cursor: "pointer"
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
const StyledIconButton = styled(IconButton, {
|
|
28
|
-
base: {
|
|
29
|
-
position: "absolute",
|
|
30
|
-
left: "-xxlarge",
|
|
31
|
-
top: "-4xsmall",
|
|
32
|
-
opacity: "0",
|
|
33
|
-
cursor: "pointer",
|
|
34
|
-
"&:focus, &:focus-visible, &:active": {
|
|
35
|
-
opacity: "1"
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
const CopyParagraphButton = _ref => {
|
|
40
|
-
let {
|
|
41
|
-
children,
|
|
42
|
-
copyText,
|
|
43
|
-
lang
|
|
44
|
-
} = _ref;
|
|
45
|
-
const [hasCopied, setHasCopied] = useState(false);
|
|
46
|
-
const {
|
|
47
|
-
t
|
|
48
|
-
} = useTranslation();
|
|
49
|
-
const sanitizedTitle = useMemo(() => encodeURIComponent(copyText.replace(/ /g, "-")), [copyText]);
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if (hasCopied) {
|
|
52
|
-
setTimeout(() => setHasCopied(false), 3000);
|
|
53
|
-
}
|
|
54
|
-
}, [hasCopied]);
|
|
55
|
-
const onCopyClick = useCallback(() => {
|
|
56
|
-
setHasCopied(true);
|
|
57
|
-
const {
|
|
58
|
-
location
|
|
59
|
-
} = window;
|
|
60
|
-
const newHash = `#${sanitizedTitle}`;
|
|
61
|
-
const port = location.port ? `:${location.port}` : "";
|
|
62
|
-
const urlToCopy = `${location.protocol}//${location.hostname}${port}${location.pathname}${location.search}${newHash}`;
|
|
63
|
-
copyTextToClipboard(urlToCopy);
|
|
64
|
-
}, [sanitizedTitle]);
|
|
65
|
-
const tooltip = hasCopied ? t("article.copyPageLinkCopied") : t("article.copyHeaderLink");
|
|
66
|
-
return /*#__PURE__*/_jsxs(ContainerDiv, {
|
|
67
|
-
"data-embed-type": "copy-heading",
|
|
68
|
-
children: [/*#__PURE__*/_jsx(StyledIconButton, {
|
|
69
|
-
variant: "clear",
|
|
70
|
-
"data-copy-button": "",
|
|
71
|
-
onClick: onCopyClick,
|
|
72
|
-
title: tooltip,
|
|
73
|
-
"aria-label": `${tooltip}: ${copyText}`,
|
|
74
|
-
children: /*#__PURE__*/_jsx(LinkMedium, {})
|
|
75
|
-
}), /*#__PURE__*/_jsx("h2", {
|
|
76
|
-
id: sanitizedTitle,
|
|
77
|
-
tabIndex: -1,
|
|
78
|
-
lang: lang,
|
|
79
|
-
children: children
|
|
80
|
-
})]
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
export default CopyParagraphButton;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2021-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
|
-
|
|
9
|
-
import CopyParagraphButton from "./CopyParagraphButton";
|
|
10
|
-
export { CopyParagraphButton };
|
|
11
|
-
export default CopyParagraphButton;
|
package/es/Embed/AudioEmbed.js
DELETED
|
@@ -1,76 +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
|
-
|
|
9
|
-
import { Figure } from "@ndla/primitives";
|
|
10
|
-
import { styled } from "@ndla/styled-system/jsx";
|
|
11
|
-
import EmbedErrorPlaceholder from "./EmbedErrorPlaceholder";
|
|
12
|
-
import AudioPlayer from "../AudioPlayer";
|
|
13
|
-
import { EmbedByline } from "../LicenseByline";
|
|
14
|
-
import { licenseAttributes } from "../utils/licenseAttributes";
|
|
15
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
const StyledFigure = styled(Figure, {
|
|
17
|
-
base: {
|
|
18
|
-
clear: "both"
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
export const getFirstNonEmptyLicenseCredits = authors => Object.values(authors).find(i => i.length > 0) ?? [];
|
|
22
|
-
const AudioEmbed = _ref => {
|
|
23
|
-
let {
|
|
24
|
-
embed,
|
|
25
|
-
lang
|
|
26
|
-
} = _ref;
|
|
27
|
-
const type = embed.embedData.type === "standard" ? "audio" : "podcast";
|
|
28
|
-
if (embed.status === "error") {
|
|
29
|
-
return /*#__PURE__*/_jsx(EmbedErrorPlaceholder, {
|
|
30
|
-
type: type
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
const {
|
|
34
|
-
data,
|
|
35
|
-
embedData
|
|
36
|
-
} = embed;
|
|
37
|
-
if (embedData.type === "minimal") {
|
|
38
|
-
return /*#__PURE__*/_jsx(AudioPlayer, {
|
|
39
|
-
speech: true,
|
|
40
|
-
src: data.audioFile.url,
|
|
41
|
-
title: data.title.title
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
const subtitle = data.series ? {
|
|
45
|
-
title: data.series.title.title,
|
|
46
|
-
url: `/podkast/${data.series.id}`
|
|
47
|
-
} : undefined;
|
|
48
|
-
const coverPhoto = data.podcastMeta?.coverPhoto;
|
|
49
|
-
const img = coverPhoto && {
|
|
50
|
-
url: coverPhoto.url,
|
|
51
|
-
alt: coverPhoto.altText
|
|
52
|
-
};
|
|
53
|
-
const licenseProps = licenseAttributes(data.copyright.license.license, lang, embedData.url);
|
|
54
|
-
return /*#__PURE__*/_jsxs(StyledFigure, {
|
|
55
|
-
lang: lang,
|
|
56
|
-
"data-embed-type": type,
|
|
57
|
-
...licenseProps,
|
|
58
|
-
children: [/*#__PURE__*/_jsx(AudioPlayer, {
|
|
59
|
-
description: data.podcastMeta?.introduction ?? "",
|
|
60
|
-
img: img,
|
|
61
|
-
src: data.audioFile.url,
|
|
62
|
-
textVersion: data.manuscript?.manuscript.length ? /*#__PURE__*/_jsx("div", {
|
|
63
|
-
dangerouslySetInnerHTML: {
|
|
64
|
-
__html: data.manuscript.manuscript
|
|
65
|
-
}
|
|
66
|
-
}) : undefined,
|
|
67
|
-
title: data.title.title,
|
|
68
|
-
subtitle: subtitle
|
|
69
|
-
}), /*#__PURE__*/_jsx(EmbedByline, {
|
|
70
|
-
error: false,
|
|
71
|
-
type: data.audioType === "standard" ? "audio" : "podcast",
|
|
72
|
-
copyright: embed.data.copyright
|
|
73
|
-
})]
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
export default AudioEmbed;
|
|
@@ -1,133 +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
|
-
|
|
9
|
-
import parse from "html-react-parser";
|
|
10
|
-
import { useEffect, useMemo, useRef, useState } from "react";
|
|
11
|
-
import { useTranslation } from "react-i18next";
|
|
12
|
-
import { Button, Figure } from "@ndla/primitives";
|
|
13
|
-
import { styled } from "@ndla/styled-system/jsx";
|
|
14
|
-
import EmbedErrorPlaceholder from "./EmbedErrorPlaceholder";
|
|
15
|
-
import { EmbedByline } from "../LicenseByline";
|
|
16
|
-
import { licenseAttributes } from "../utils/licenseAttributes";
|
|
17
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
-
const LinkedVideoButton = styled(Button, {
|
|
19
|
-
base: {
|
|
20
|
-
marginBlockStart: "3xsmall"
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const BrightcoveIframe = styled("iframe", {
|
|
24
|
-
base: {
|
|
25
|
-
border: 0,
|
|
26
|
-
height: "auto",
|
|
27
|
-
width: "100%"
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
export const makeIframeString = function (url, width, height) {
|
|
31
|
-
let title = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
|
|
32
|
-
const strippedWidth = typeof width === "number" ? width : width.replace(/\s*px/, "");
|
|
33
|
-
const strippedHeight = typeof height === "number" ? height : height.replace(/\s*px/, "");
|
|
34
|
-
const urlOrTitle = title || url;
|
|
35
|
-
return `<iframe title="${urlOrTitle}" aria-label="${urlOrTitle}" src="${url}" width="${strippedWidth}" height="${strippedHeight}" allowfullscreen scrolling="no" frameborder="0" loading="lazy"></iframe>`;
|
|
36
|
-
};
|
|
37
|
-
export const isNumeric = value => !Number.isNaN(value - Number.parseFloat(value));
|
|
38
|
-
const getIframeProps = (data, sources) => {
|
|
39
|
-
const {
|
|
40
|
-
account,
|
|
41
|
-
videoid,
|
|
42
|
-
player = "default"
|
|
43
|
-
} = data;
|
|
44
|
-
const source = sources.filter(s => s.width && s.height).toSorted((a, b) => a.height - b.height)[0];
|
|
45
|
-
return {
|
|
46
|
-
src: `https://players.brightcove.net/${account}/${player}_default/index.html?videoId=${videoid}`,
|
|
47
|
-
height: source?.height ?? "480",
|
|
48
|
-
width: source?.width ?? "640"
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
const BrightcoveEmbed = _ref => {
|
|
52
|
-
let {
|
|
53
|
-
embed,
|
|
54
|
-
renderContext = "article",
|
|
55
|
-
lang
|
|
56
|
-
} = _ref;
|
|
57
|
-
const [showOriginalVideo, setShowOriginalVideo] = useState(true);
|
|
58
|
-
const {
|
|
59
|
-
t
|
|
60
|
-
} = useTranslation();
|
|
61
|
-
const iframeRef = useRef(null);
|
|
62
|
-
const {
|
|
63
|
-
embedData
|
|
64
|
-
} = embed;
|
|
65
|
-
const fallbackTitle = `${t("embed.type.video")}: ${embedData.videoid}`;
|
|
66
|
-
const parsedDescription = useMemo(() => {
|
|
67
|
-
if (embed.embedData.caption || renderContext === "article") {
|
|
68
|
-
return embed.embedData.caption ? parse(embed.embedData.caption) : undefined;
|
|
69
|
-
} else if (embed.status === "success" && embed.data.description) {
|
|
70
|
-
return parse(embed.data.description);
|
|
71
|
-
}
|
|
72
|
-
}, [embed, renderContext]);
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
const iframe = iframeRef.current;
|
|
75
|
-
if (iframe) {
|
|
76
|
-
const [width, height] = [parseInt(iframe.width), parseInt(iframe.height)];
|
|
77
|
-
iframe.style.aspectRatio = `${width}/${height}`;
|
|
78
|
-
iframe.width = "";
|
|
79
|
-
iframe.height = "";
|
|
80
|
-
}
|
|
81
|
-
}, []);
|
|
82
|
-
if (embed.status === "error") {
|
|
83
|
-
return /*#__PURE__*/_jsx(EmbedErrorPlaceholder, {
|
|
84
|
-
type: "video",
|
|
85
|
-
children: /*#__PURE__*/_jsx(BrightcoveIframe, {
|
|
86
|
-
ref: iframeRef,
|
|
87
|
-
title: embedData.alt || fallbackTitle,
|
|
88
|
-
"aria-label": embedData.alt || fallbackTitle,
|
|
89
|
-
...getIframeProps(embedData, []),
|
|
90
|
-
allow: "fullscreen; encrypted-media"
|
|
91
|
-
})
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
const {
|
|
95
|
-
data
|
|
96
|
-
} = embed;
|
|
97
|
-
const linkedVideoId = isNumeric(data.link?.text) ? data.link?.text : undefined;
|
|
98
|
-
const originalVideoProps = getIframeProps(embedData, data.sources);
|
|
99
|
-
const alternativeVideoProps = linkedVideoId ? getIframeProps({
|
|
100
|
-
...embedData,
|
|
101
|
-
videoid: linkedVideoId
|
|
102
|
-
}, data.sources) : undefined;
|
|
103
|
-
const licenseProps = licenseAttributes(data?.copyright?.license.license, lang, embedData.pageUrl);
|
|
104
|
-
const title = data.name?.trim() ? `${t("embed.type.video")}: ${data.name}` : fallbackTitle;
|
|
105
|
-
return /*#__PURE__*/_jsxs(Figure, {
|
|
106
|
-
"data-embed-type": "brightcove",
|
|
107
|
-
...licenseProps,
|
|
108
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
109
|
-
className: "brightcove-video",
|
|
110
|
-
children: /*#__PURE__*/_jsx(BrightcoveIframe, {
|
|
111
|
-
ref: iframeRef,
|
|
112
|
-
className: "original",
|
|
113
|
-
title: title,
|
|
114
|
-
"aria-label": title,
|
|
115
|
-
...(alternativeVideoProps && !showOriginalVideo ? alternativeVideoProps : originalVideoProps),
|
|
116
|
-
allow: "fullscreen; encrypted-media"
|
|
117
|
-
})
|
|
118
|
-
}), /*#__PURE__*/_jsx(EmbedByline, {
|
|
119
|
-
type: "video",
|
|
120
|
-
copyright: data.copyright,
|
|
121
|
-
description: parsedDescription,
|
|
122
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
123
|
-
children: !!linkedVideoId && /*#__PURE__*/_jsx(LinkedVideoButton, {
|
|
124
|
-
size: "small",
|
|
125
|
-
variant: "secondary",
|
|
126
|
-
onClick: () => setShowOriginalVideo(p => !p),
|
|
127
|
-
children: t(`figure.button.${!showOriginalVideo ? "original" : "alternative"}`)
|
|
128
|
-
})
|
|
129
|
-
})
|
|
130
|
-
})]
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
export default BrightcoveEmbed;
|
package/es/Embed/CodeEmbed.js
DELETED
|
@@ -1,79 +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
|
-
|
|
9
|
-
import { useEffect, useState } from "react";
|
|
10
|
-
import { useTranslation } from "react-i18next";
|
|
11
|
-
import { FileCopyLine, CheckLine } from "@ndla/icons";
|
|
12
|
-
import { Button, Figure } from "@ndla/primitives";
|
|
13
|
-
import { styled } from "@ndla/styled-system/jsx";
|
|
14
|
-
import { copyTextToClipboard } from "@ndla/util";
|
|
15
|
-
import EmbedErrorPlaceholder from "./EmbedErrorPlaceholder";
|
|
16
|
-
import { CodeBlock, codeLanguageOptions } from "../CodeBlock";
|
|
17
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
-
const StyledFigCaption = styled("figcaption", {
|
|
19
|
-
base: {
|
|
20
|
-
textStyle: "label.large",
|
|
21
|
-
fontWeight: "bold"
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
const StyledFigure = styled(Figure, {
|
|
25
|
-
base: {
|
|
26
|
-
clear: "both",
|
|
27
|
-
// We apply margin here to allow for the float and size props on figure to work as intended.
|
|
28
|
-
"& > *:not(:where(:first-child))": {
|
|
29
|
-
marginBlockStart: "xsmall"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
const getTitleFromFormat = format => {
|
|
34
|
-
const selectedLanguage = codeLanguageOptions.find(item => item.format === format);
|
|
35
|
-
if (selectedLanguage) {
|
|
36
|
-
return selectedLanguage.title;
|
|
37
|
-
}
|
|
38
|
-
return;
|
|
39
|
-
};
|
|
40
|
-
const CodeEmbed = _ref => {
|
|
41
|
-
let {
|
|
42
|
-
embed
|
|
43
|
-
} = _ref;
|
|
44
|
-
const [isCopied, setIsCopied] = useState(false);
|
|
45
|
-
const {
|
|
46
|
-
t
|
|
47
|
-
} = useTranslation();
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
if (isCopied) {
|
|
50
|
-
const timer = setInterval(() => setIsCopied(false), 3000);
|
|
51
|
-
// ensure interval is cleared - also if unmounted
|
|
52
|
-
return () => {
|
|
53
|
-
clearTimeout(timer);
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}, [isCopied]);
|
|
57
|
-
if (embed.status === "error") {
|
|
58
|
-
return /*#__PURE__*/_jsx(EmbedErrorPlaceholder, {
|
|
59
|
-
type: "code"
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
return /*#__PURE__*/_jsxs(StyledFigure, {
|
|
63
|
-
"data-embed-type": "code-block",
|
|
64
|
-
children: [/*#__PURE__*/_jsx(StyledFigCaption, {
|
|
65
|
-
children: embed.embedData.title || getTitleFromFormat(embed.embedData.codeFormat)
|
|
66
|
-
}), /*#__PURE__*/_jsx(CodeBlock, {
|
|
67
|
-
highlightedCode: embed.status === "success" ? embed.data.highlightedCode : "",
|
|
68
|
-
format: embed.embedData.codeFormat
|
|
69
|
-
}), /*#__PURE__*/_jsxs(Button, {
|
|
70
|
-
variant: "secondary",
|
|
71
|
-
onClick: () => {
|
|
72
|
-
copyTextToClipboard(embed.status === "success" ? embed.data.decodedContent : "");
|
|
73
|
-
setIsCopied(true);
|
|
74
|
-
},
|
|
75
|
-
children: [isCopied ? /*#__PURE__*/_jsx(CheckLine, {}) : /*#__PURE__*/_jsx(FileCopyLine, {}), isCopied ? t("codeBlock.copiedCode") : t("codeBlock.copyCode")]
|
|
76
|
-
})]
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
export default CodeEmbed;
|
package/es/Embed/ConceptEmbed.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024-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
|
-
|
|
9
|
-
import parse from "html-react-parser";
|
|
10
|
-
import { forwardRef, useMemo, useRef } from "react";
|
|
11
|
-
import { Portal } from "@ark-ui/react";
|
|
12
|
-
import { PopoverContent, PopoverRoot, PopoverTrigger } from "@ndla/primitives";
|
|
13
|
-
import { styled } from "@ndla/styled-system/jsx";
|
|
14
|
-
import { ConceptInlineTriggerButton } from "./ConceptInlineTriggerButton";
|
|
15
|
-
import EmbedErrorPlaceholder from "./EmbedErrorPlaceholder";
|
|
16
|
-
import { GlossEmbed } from "./GlossEmbed";
|
|
17
|
-
import { Concept } from "../Concept/Concept";
|
|
18
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
-
const StyledPopoverContent = styled(PopoverContent, {
|
|
20
|
-
base: {
|
|
21
|
-
width: "surface.xlarge",
|
|
22
|
-
maxHeight: "50vh",
|
|
23
|
-
overflowY: "auto"
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
export const ConceptEmbed = _ref => {
|
|
27
|
-
let {
|
|
28
|
-
embed,
|
|
29
|
-
renderContext,
|
|
30
|
-
lang,
|
|
31
|
-
previewAlt
|
|
32
|
-
} = _ref;
|
|
33
|
-
const parsedContent = useMemo(() => {
|
|
34
|
-
if (embed.status === "error" || !embed.data.concept.content) return undefined;
|
|
35
|
-
return parse(embed.data.concept.content.htmlContent);
|
|
36
|
-
}, [embed]);
|
|
37
|
-
if (embed.status === "error" && embed.embedData.type === "inline") {
|
|
38
|
-
return /*#__PURE__*/_jsx("span", {
|
|
39
|
-
children: embed.embedData.linkText
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
if (embed.status === "error") {
|
|
43
|
-
// TODO: This could be either concept or gloss. We don't know if it errors out. :)
|
|
44
|
-
return /*#__PURE__*/_jsx(EmbedErrorPlaceholder, {
|
|
45
|
-
type: "gloss"
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
const {
|
|
49
|
-
concept,
|
|
50
|
-
visualElement
|
|
51
|
-
} = embed.data;
|
|
52
|
-
|
|
53
|
-
// TODO: Consider whether we should do this in article-converter instead.
|
|
54
|
-
if (embed.data.concept.glossData) {
|
|
55
|
-
return /*#__PURE__*/_jsx(GlossEmbed, {
|
|
56
|
-
embed: embed
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
if (embed.embedData.type === "inline") {
|
|
60
|
-
return /*#__PURE__*/_jsx(InlineConcept, {
|
|
61
|
-
previewAlt: previewAlt,
|
|
62
|
-
linkText: embed.embedData.linkText,
|
|
63
|
-
copyright: concept.copyright,
|
|
64
|
-
visualElement: visualElement,
|
|
65
|
-
lang: lang,
|
|
66
|
-
title: concept.title.title,
|
|
67
|
-
source: concept.source,
|
|
68
|
-
children: parsedContent
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return /*#__PURE__*/_jsx(BlockConcept, {
|
|
72
|
-
previewAlt: previewAlt,
|
|
73
|
-
copyright: concept.copyright,
|
|
74
|
-
visualElement: visualElement,
|
|
75
|
-
lang: lang,
|
|
76
|
-
title: renderContext === "embed" ? undefined : concept.title.title,
|
|
77
|
-
source: concept.source,
|
|
78
|
-
children: parsedContent
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
export const InlineConcept = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
82
|
-
let {
|
|
83
|
-
linkText,
|
|
84
|
-
copyright,
|
|
85
|
-
visualElement,
|
|
86
|
-
previewAlt,
|
|
87
|
-
lang,
|
|
88
|
-
children,
|
|
89
|
-
title,
|
|
90
|
-
source,
|
|
91
|
-
...rest
|
|
92
|
-
} = _ref2;
|
|
93
|
-
const contentRef = useRef(null);
|
|
94
|
-
return /*#__PURE__*/_jsxs(PopoverRoot, {
|
|
95
|
-
initialFocusEl: () => contentRef.current,
|
|
96
|
-
children: [/*#__PURE__*/_jsx(PopoverTrigger, {
|
|
97
|
-
asChild: true,
|
|
98
|
-
ref: ref,
|
|
99
|
-
...rest,
|
|
100
|
-
children: /*#__PURE__*/_jsx(ConceptInlineTriggerButton, {
|
|
101
|
-
children: linkText
|
|
102
|
-
})
|
|
103
|
-
}), /*#__PURE__*/_jsx(Portal, {
|
|
104
|
-
children: /*#__PURE__*/_jsx(StyledPopoverContent, {
|
|
105
|
-
ref: contentRef,
|
|
106
|
-
children: /*#__PURE__*/_jsx(Concept, {
|
|
107
|
-
copyright: copyright,
|
|
108
|
-
visualElement: visualElement,
|
|
109
|
-
title: title,
|
|
110
|
-
lang: lang,
|
|
111
|
-
source: source,
|
|
112
|
-
previewAlt: previewAlt,
|
|
113
|
-
children: children
|
|
114
|
-
})
|
|
115
|
-
})
|
|
116
|
-
})]
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
export const BlockConcept = /*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/_jsx(Concept, {
|
|
120
|
-
...props,
|
|
121
|
-
"data-embed-type": "concept",
|
|
122
|
-
ref: ref
|
|
123
|
-
}));
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024-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
|
-
|
|
9
|
-
import { styled } from "@ndla/styled-system/jsx";
|
|
10
|
-
import { InlineTriggerButton } from "./InlineTriggerButton";
|
|
11
|
-
export const ConceptInlineTriggerButton = styled(InlineTriggerButton, {
|
|
12
|
-
base: {
|
|
13
|
-
position: "relative",
|
|
14
|
-
overflow: "visible",
|
|
15
|
-
borderBottom: "1px solid",
|
|
16
|
-
borderStyle: "dashed",
|
|
17
|
-
borderColor: "stroke.hover",
|
|
18
|
-
paddingBlockStart: "5xsmall",
|
|
19
|
-
width: "fit-content",
|
|
20
|
-
cursor: "pointer",
|
|
21
|
-
_hover: {
|
|
22
|
-
borderColor: "text.link",
|
|
23
|
-
background: "surface.actionSubtle.hover"
|
|
24
|
-
},
|
|
25
|
-
_active: {
|
|
26
|
-
borderColor: "text.link",
|
|
27
|
-
background: "surface.actionSubtle.active"
|
|
28
|
-
},
|
|
29
|
-
// The global focus ring forces the border-radius to be xsmall, causing the dashed border to be cut off. This is a workaround.
|
|
30
|
-
_focusVisible: {
|
|
31
|
-
outline: "none",
|
|
32
|
-
borderRadius: "0",
|
|
33
|
-
_after: {
|
|
34
|
-
content: '""',
|
|
35
|
-
position: "absolute",
|
|
36
|
-
inset: "0",
|
|
37
|
-
outline: "3px",
|
|
38
|
-
borderRadius: "xsmall",
|
|
39
|
-
outlineColor: "stroke.default",
|
|
40
|
-
outlineOffset: "3px",
|
|
41
|
-
outlineStyle: "solid"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
});
|