@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,142 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.makeIframeString = exports.isNumeric = exports.default = void 0;
|
|
7
|
-
var _htmlReactParser = _interopRequireDefault(require("html-react-parser"));
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _reactI18next = require("react-i18next");
|
|
10
|
-
var _primitives = require("@ndla/primitives");
|
|
11
|
-
var _jsx2 = require("@ndla/styled-system/jsx");
|
|
12
|
-
var _EmbedErrorPlaceholder = _interopRequireDefault(require("./EmbedErrorPlaceholder"));
|
|
13
|
-
var _LicenseByline = require("../LicenseByline");
|
|
14
|
-
var _licenseAttributes = require("../utils/licenseAttributes");
|
|
15
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
-
/**
|
|
18
|
-
* Copyright (c) 2023-present, NDLA.
|
|
19
|
-
*
|
|
20
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
21
|
-
* LICENSE file in the root directory of this source tree.
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
const LinkedVideoButton = (0, _jsx2.styled)(_primitives.Button, {
|
|
26
|
-
base: {
|
|
27
|
-
marginBlockStart: "3xsmall"
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
const BrightcoveIframe = (0, _jsx2.styled)("iframe", {
|
|
31
|
-
base: {
|
|
32
|
-
border: 0,
|
|
33
|
-
height: "auto",
|
|
34
|
-
width: "100%"
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
const makeIframeString = function (url, width, height) {
|
|
38
|
-
let title = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
|
|
39
|
-
const strippedWidth = typeof width === "number" ? width : width.replace(/\s*px/, "");
|
|
40
|
-
const strippedHeight = typeof height === "number" ? height : height.replace(/\s*px/, "");
|
|
41
|
-
const urlOrTitle = title || url;
|
|
42
|
-
return `<iframe title="${urlOrTitle}" aria-label="${urlOrTitle}" src="${url}" width="${strippedWidth}" height="${strippedHeight}" allowfullscreen scrolling="no" frameborder="0" loading="lazy"></iframe>`;
|
|
43
|
-
};
|
|
44
|
-
exports.makeIframeString = makeIframeString;
|
|
45
|
-
const isNumeric = value => !Number.isNaN(value - Number.parseFloat(value));
|
|
46
|
-
exports.isNumeric = isNumeric;
|
|
47
|
-
const getIframeProps = (data, sources) => {
|
|
48
|
-
const {
|
|
49
|
-
account,
|
|
50
|
-
videoid,
|
|
51
|
-
player = "default"
|
|
52
|
-
} = data;
|
|
53
|
-
const source = sources.filter(s => s.width && s.height).toSorted((a, b) => a.height - b.height)[0];
|
|
54
|
-
return {
|
|
55
|
-
src: `https://players.brightcove.net/${account}/${player}_default/index.html?videoId=${videoid}`,
|
|
56
|
-
height: source?.height ?? "480",
|
|
57
|
-
width: source?.width ?? "640"
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
const BrightcoveEmbed = _ref => {
|
|
61
|
-
let {
|
|
62
|
-
embed,
|
|
63
|
-
renderContext = "article",
|
|
64
|
-
lang
|
|
65
|
-
} = _ref;
|
|
66
|
-
const [showOriginalVideo, setShowOriginalVideo] = (0, _react.useState)(true);
|
|
67
|
-
const {
|
|
68
|
-
t
|
|
69
|
-
} = (0, _reactI18next.useTranslation)();
|
|
70
|
-
const iframeRef = (0, _react.useRef)(null);
|
|
71
|
-
const {
|
|
72
|
-
embedData
|
|
73
|
-
} = embed;
|
|
74
|
-
const fallbackTitle = `${t("embed.type.video")}: ${embedData.videoid}`;
|
|
75
|
-
const parsedDescription = (0, _react.useMemo)(() => {
|
|
76
|
-
if (embed.embedData.caption || renderContext === "article") {
|
|
77
|
-
return embed.embedData.caption ? (0, _htmlReactParser.default)(embed.embedData.caption) : undefined;
|
|
78
|
-
} else if (embed.status === "success" && embed.data.description) {
|
|
79
|
-
return (0, _htmlReactParser.default)(embed.data.description);
|
|
80
|
-
}
|
|
81
|
-
}, [embed, renderContext]);
|
|
82
|
-
(0, _react.useEffect)(() => {
|
|
83
|
-
const iframe = iframeRef.current;
|
|
84
|
-
if (iframe) {
|
|
85
|
-
const [width, height] = [parseInt(iframe.width), parseInt(iframe.height)];
|
|
86
|
-
iframe.style.aspectRatio = `${width}/${height}`;
|
|
87
|
-
iframe.width = "";
|
|
88
|
-
iframe.height = "";
|
|
89
|
-
}
|
|
90
|
-
}, []);
|
|
91
|
-
if (embed.status === "error") {
|
|
92
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_EmbedErrorPlaceholder.default, {
|
|
93
|
-
type: "video",
|
|
94
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BrightcoveIframe, {
|
|
95
|
-
ref: iframeRef,
|
|
96
|
-
title: embedData.alt || fallbackTitle,
|
|
97
|
-
"aria-label": embedData.alt || fallbackTitle,
|
|
98
|
-
...getIframeProps(embedData, []),
|
|
99
|
-
allow: "fullscreen; encrypted-media"
|
|
100
|
-
})
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
const {
|
|
104
|
-
data
|
|
105
|
-
} = embed;
|
|
106
|
-
const linkedVideoId = isNumeric(data.link?.text) ? data.link?.text : undefined;
|
|
107
|
-
const originalVideoProps = getIframeProps(embedData, data.sources);
|
|
108
|
-
const alternativeVideoProps = linkedVideoId ? getIframeProps({
|
|
109
|
-
...embedData,
|
|
110
|
-
videoid: linkedVideoId
|
|
111
|
-
}, data.sources) : undefined;
|
|
112
|
-
const licenseProps = (0, _licenseAttributes.licenseAttributes)(data?.copyright?.license.license, lang, embedData.pageUrl);
|
|
113
|
-
const title = data.name?.trim() ? `${t("embed.type.video")}: ${data.name}` : fallbackTitle;
|
|
114
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_primitives.Figure, {
|
|
115
|
-
"data-embed-type": "brightcove",
|
|
116
|
-
...licenseProps,
|
|
117
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
118
|
-
className: "brightcove-video",
|
|
119
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BrightcoveIframe, {
|
|
120
|
-
ref: iframeRef,
|
|
121
|
-
className: "original",
|
|
122
|
-
title: title,
|
|
123
|
-
"aria-label": title,
|
|
124
|
-
...(alternativeVideoProps && !showOriginalVideo ? alternativeVideoProps : originalVideoProps),
|
|
125
|
-
allow: "fullscreen; encrypted-media"
|
|
126
|
-
})
|
|
127
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LicenseByline.EmbedByline, {
|
|
128
|
-
type: "video",
|
|
129
|
-
copyright: data.copyright,
|
|
130
|
-
description: parsedDescription,
|
|
131
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
132
|
-
children: !!linkedVideoId && /*#__PURE__*/(0, _jsxRuntime.jsx)(LinkedVideoButton, {
|
|
133
|
-
size: "small",
|
|
134
|
-
variant: "secondary",
|
|
135
|
-
onClick: () => setShowOriginalVideo(p => !p),
|
|
136
|
-
children: t(`figure.button.${!showOriginalVideo ? "original" : "alternative"}`)
|
|
137
|
-
})
|
|
138
|
-
})
|
|
139
|
-
})]
|
|
140
|
-
});
|
|
141
|
-
};
|
|
142
|
-
var _default = exports.default = BrightcoveEmbed;
|
package/lib/Embed/CodeEmbed.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _reactI18next = require("react-i18next");
|
|
9
|
-
var _icons = require("@ndla/icons");
|
|
10
|
-
var _primitives = require("@ndla/primitives");
|
|
11
|
-
var _jsx2 = require("@ndla/styled-system/jsx");
|
|
12
|
-
var _util = require("@ndla/util");
|
|
13
|
-
var _EmbedErrorPlaceholder = _interopRequireDefault(require("./EmbedErrorPlaceholder"));
|
|
14
|
-
var _CodeBlock = require("../CodeBlock");
|
|
15
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
-
/**
|
|
18
|
-
* Copyright (c) 2023-present, NDLA.
|
|
19
|
-
*
|
|
20
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
21
|
-
* LICENSE file in the root directory of this source tree.
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
const StyledFigCaption = (0, _jsx2.styled)("figcaption", {
|
|
26
|
-
base: {
|
|
27
|
-
textStyle: "label.large",
|
|
28
|
-
fontWeight: "bold"
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
const StyledFigure = (0, _jsx2.styled)(_primitives.Figure, {
|
|
32
|
-
base: {
|
|
33
|
-
clear: "both",
|
|
34
|
-
// We apply margin here to allow for the float and size props on figure to work as intended.
|
|
35
|
-
"& > *:not(:where(:first-child))": {
|
|
36
|
-
marginBlockStart: "xsmall"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
const getTitleFromFormat = format => {
|
|
41
|
-
const selectedLanguage = _CodeBlock.codeLanguageOptions.find(item => item.format === format);
|
|
42
|
-
if (selectedLanguage) {
|
|
43
|
-
return selectedLanguage.title;
|
|
44
|
-
}
|
|
45
|
-
return;
|
|
46
|
-
};
|
|
47
|
-
const CodeEmbed = _ref => {
|
|
48
|
-
let {
|
|
49
|
-
embed
|
|
50
|
-
} = _ref;
|
|
51
|
-
const [isCopied, setIsCopied] = (0, _react.useState)(false);
|
|
52
|
-
const {
|
|
53
|
-
t
|
|
54
|
-
} = (0, _reactI18next.useTranslation)();
|
|
55
|
-
(0, _react.useEffect)(() => {
|
|
56
|
-
if (isCopied) {
|
|
57
|
-
const timer = setInterval(() => setIsCopied(false), 3000);
|
|
58
|
-
// ensure interval is cleared - also if unmounted
|
|
59
|
-
return () => {
|
|
60
|
-
clearTimeout(timer);
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}, [isCopied]);
|
|
64
|
-
if (embed.status === "error") {
|
|
65
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_EmbedErrorPlaceholder.default, {
|
|
66
|
-
type: "code"
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(StyledFigure, {
|
|
70
|
-
"data-embed-type": "code-block",
|
|
71
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(StyledFigCaption, {
|
|
72
|
-
children: embed.embedData.title || getTitleFromFormat(embed.embedData.codeFormat)
|
|
73
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_CodeBlock.CodeBlock, {
|
|
74
|
-
highlightedCode: embed.status === "success" ? embed.data.highlightedCode : "",
|
|
75
|
-
format: embed.embedData.codeFormat
|
|
76
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_primitives.Button, {
|
|
77
|
-
variant: "secondary",
|
|
78
|
-
onClick: () => {
|
|
79
|
-
(0, _util.copyTextToClipboard)(embed.status === "success" ? embed.data.decodedContent : "");
|
|
80
|
-
setIsCopied(true);
|
|
81
|
-
},
|
|
82
|
-
children: [isCopied ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.CheckLine, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.FileCopyLine, {}), isCopied ? t("codeBlock.copiedCode") : t("codeBlock.copyCode")]
|
|
83
|
-
})]
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
var _default = exports.default = CodeEmbed;
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.InlineConcept = exports.ConceptEmbed = exports.BlockConcept = void 0;
|
|
7
|
-
var _htmlReactParser = _interopRequireDefault(require("html-react-parser"));
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _react2 = require("@ark-ui/react");
|
|
10
|
-
var _primitives = require("@ndla/primitives");
|
|
11
|
-
var _jsx2 = require("@ndla/styled-system/jsx");
|
|
12
|
-
var _ConceptInlineTriggerButton = require("./ConceptInlineTriggerButton");
|
|
13
|
-
var _EmbedErrorPlaceholder = _interopRequireDefault(require("./EmbedErrorPlaceholder"));
|
|
14
|
-
var _GlossEmbed = require("./GlossEmbed");
|
|
15
|
-
var _Concept = require("../Concept/Concept");
|
|
16
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
-
/**
|
|
19
|
-
* Copyright (c) 2024-present, NDLA.
|
|
20
|
-
*
|
|
21
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
22
|
-
* LICENSE file in the root directory of this source tree.
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
const StyledPopoverContent = (0, _jsx2.styled)(_primitives.PopoverContent, {
|
|
27
|
-
base: {
|
|
28
|
-
width: "surface.xlarge",
|
|
29
|
-
maxHeight: "50vh",
|
|
30
|
-
overflowY: "auto"
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
const ConceptEmbed = _ref => {
|
|
34
|
-
let {
|
|
35
|
-
embed,
|
|
36
|
-
renderContext,
|
|
37
|
-
lang,
|
|
38
|
-
previewAlt
|
|
39
|
-
} = _ref;
|
|
40
|
-
const parsedContent = (0, _react.useMemo)(() => {
|
|
41
|
-
if (embed.status === "error" || !embed.data.concept.content) return undefined;
|
|
42
|
-
return (0, _htmlReactParser.default)(embed.data.concept.content.htmlContent);
|
|
43
|
-
}, [embed]);
|
|
44
|
-
if (embed.status === "error" && embed.embedData.type === "inline") {
|
|
45
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
46
|
-
children: embed.embedData.linkText
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
if (embed.status === "error") {
|
|
50
|
-
// TODO: This could be either concept or gloss. We don't know if it errors out. :)
|
|
51
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_EmbedErrorPlaceholder.default, {
|
|
52
|
-
type: "gloss"
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
const {
|
|
56
|
-
concept,
|
|
57
|
-
visualElement
|
|
58
|
-
} = embed.data;
|
|
59
|
-
|
|
60
|
-
// TODO: Consider whether we should do this in article-converter instead.
|
|
61
|
-
if (embed.data.concept.glossData) {
|
|
62
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GlossEmbed.GlossEmbed, {
|
|
63
|
-
embed: embed
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
if (embed.embedData.type === "inline") {
|
|
67
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(InlineConcept, {
|
|
68
|
-
previewAlt: previewAlt,
|
|
69
|
-
linkText: embed.embedData.linkText,
|
|
70
|
-
copyright: concept.copyright,
|
|
71
|
-
visualElement: visualElement,
|
|
72
|
-
lang: lang,
|
|
73
|
-
title: concept.title.title,
|
|
74
|
-
source: concept.source,
|
|
75
|
-
children: parsedContent
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(BlockConcept, {
|
|
79
|
-
previewAlt: previewAlt,
|
|
80
|
-
copyright: concept.copyright,
|
|
81
|
-
visualElement: visualElement,
|
|
82
|
-
lang: lang,
|
|
83
|
-
title: renderContext === "embed" ? undefined : concept.title.title,
|
|
84
|
-
source: concept.source,
|
|
85
|
-
children: parsedContent
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
exports.ConceptEmbed = ConceptEmbed;
|
|
89
|
-
const InlineConcept = exports.InlineConcept = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
90
|
-
let {
|
|
91
|
-
linkText,
|
|
92
|
-
copyright,
|
|
93
|
-
visualElement,
|
|
94
|
-
previewAlt,
|
|
95
|
-
lang,
|
|
96
|
-
children,
|
|
97
|
-
title,
|
|
98
|
-
source,
|
|
99
|
-
...rest
|
|
100
|
-
} = _ref2;
|
|
101
|
-
const contentRef = (0, _react.useRef)(null);
|
|
102
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_primitives.PopoverRoot, {
|
|
103
|
-
initialFocusEl: () => contentRef.current,
|
|
104
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_primitives.PopoverTrigger, {
|
|
105
|
-
asChild: true,
|
|
106
|
-
ref: ref,
|
|
107
|
-
...rest,
|
|
108
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ConceptInlineTriggerButton.ConceptInlineTriggerButton, {
|
|
109
|
-
children: linkText
|
|
110
|
-
})
|
|
111
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Portal, {
|
|
112
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledPopoverContent, {
|
|
113
|
-
ref: contentRef,
|
|
114
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Concept.Concept, {
|
|
115
|
-
copyright: copyright,
|
|
116
|
-
visualElement: visualElement,
|
|
117
|
-
title: title,
|
|
118
|
-
lang: lang,
|
|
119
|
-
source: source,
|
|
120
|
-
previewAlt: previewAlt,
|
|
121
|
-
children: children
|
|
122
|
-
})
|
|
123
|
-
})
|
|
124
|
-
})]
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
const BlockConcept = exports.BlockConcept = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Concept.Concept, {
|
|
128
|
-
...props,
|
|
129
|
-
"data-embed-type": "concept",
|
|
130
|
-
ref: ref
|
|
131
|
-
}));
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ConceptInlineTriggerButton = void 0;
|
|
7
|
-
var _jsx = require("@ndla/styled-system/jsx");
|
|
8
|
-
var _InlineTriggerButton = require("./InlineTriggerButton");
|
|
9
|
-
/**
|
|
10
|
-
* Copyright (c) 2024-present, NDLA.
|
|
11
|
-
*
|
|
12
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
13
|
-
* LICENSE file in the root directory of this source tree.
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
const ConceptInlineTriggerButton = exports.ConceptInlineTriggerButton = (0, _jsx.styled)(_InlineTriggerButton.InlineTriggerButton, {
|
|
18
|
-
base: {
|
|
19
|
-
position: "relative",
|
|
20
|
-
overflow: "visible",
|
|
21
|
-
borderBottom: "1px solid",
|
|
22
|
-
borderStyle: "dashed",
|
|
23
|
-
borderColor: "stroke.hover",
|
|
24
|
-
paddingBlockStart: "5xsmall",
|
|
25
|
-
width: "fit-content",
|
|
26
|
-
cursor: "pointer",
|
|
27
|
-
_hover: {
|
|
28
|
-
borderColor: "text.link",
|
|
29
|
-
background: "surface.actionSubtle.hover"
|
|
30
|
-
},
|
|
31
|
-
_active: {
|
|
32
|
-
borderColor: "text.link",
|
|
33
|
-
background: "surface.actionSubtle.active"
|
|
34
|
-
},
|
|
35
|
-
// The global focus ring forces the border-radius to be xsmall, causing the dashed border to be cut off. This is a workaround.
|
|
36
|
-
_focusVisible: {
|
|
37
|
-
outline: "none",
|
|
38
|
-
borderRadius: "0",
|
|
39
|
-
_after: {
|
|
40
|
-
content: '""',
|
|
41
|
-
position: "absolute",
|
|
42
|
-
inset: "0",
|
|
43
|
-
outline: "3px",
|
|
44
|
-
borderRadius: "xsmall",
|
|
45
|
-
outlineColor: "stroke.default",
|
|
46
|
-
outlineOffset: "3px",
|
|
47
|
-
outlineStyle: "solid"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _reactI18next = require("react-i18next");
|
|
8
|
-
var _primitives = require("@ndla/primitives");
|
|
9
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
-
/**
|
|
11
|
-
* Copyright (c) 2023-present, NDLA.
|
|
12
|
-
*
|
|
13
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
14
|
-
* LICENSE file in the root directory of this source tree.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const ContentLinkEmbed = _ref => {
|
|
19
|
-
let {
|
|
20
|
-
embed,
|
|
21
|
-
isOembed,
|
|
22
|
-
children
|
|
23
|
-
} = _ref;
|
|
24
|
-
const {
|
|
25
|
-
t
|
|
26
|
-
} = (0, _reactI18next.useTranslation)();
|
|
27
|
-
if (embed.status === "error") {
|
|
28
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitives.Text, {
|
|
29
|
-
color: "text.error",
|
|
30
|
-
asChild: true,
|
|
31
|
-
consumeCss: true,
|
|
32
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
33
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
34
|
-
children: `${t("embed.linkError")}: `
|
|
35
|
-
}), children]
|
|
36
|
-
})
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
const {
|
|
40
|
-
embedData,
|
|
41
|
-
data
|
|
42
|
-
} = embed;
|
|
43
|
-
if (embedData.openIn === "new-context" || isOembed) {
|
|
44
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
|
|
45
|
-
href: data.path,
|
|
46
|
-
"data-embed-type": "content-link",
|
|
47
|
-
target: "_blank",
|
|
48
|
-
rel: "noopener noreferrer",
|
|
49
|
-
children: children
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
|
|
53
|
-
href: data.path,
|
|
54
|
-
children: children
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
var _default = exports.default = ContentLinkEmbed;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _jsx2 = require("@ndla/styled-system/jsx");
|
|
8
|
-
var _LicenseByline = require("../LicenseByline");
|
|
9
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
-
/**
|
|
11
|
-
* Copyright (c) 2024-present, NDLA.
|
|
12
|
-
*
|
|
13
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
14
|
-
* LICENSE file in the root directory of this source tree.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const StyledCopyrightContent = (0, _jsx2.styled)("div", {
|
|
19
|
-
base: {
|
|
20
|
-
marginBlockEnd: "xsmall"
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const CopyrightEmbed = _ref => {
|
|
24
|
-
let {
|
|
25
|
-
embed,
|
|
26
|
-
children
|
|
27
|
-
} = _ref;
|
|
28
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("figure", {
|
|
29
|
-
"data-embed-type": "copyright",
|
|
30
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(StyledCopyrightContent, {
|
|
31
|
-
"data-copyright-content": "",
|
|
32
|
-
children: children
|
|
33
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LicenseByline.EmbedByline, {
|
|
34
|
-
type: "copyright",
|
|
35
|
-
copyright: embed.embedData.copyright
|
|
36
|
-
})]
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
var _default = exports.default = CopyrightEmbed;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _icons = require("@ndla/icons");
|
|
8
|
-
var _primitives = require("@ndla/primitives");
|
|
9
|
-
var _jsx2 = require("@ndla/styled-system/jsx");
|
|
10
|
-
var _LicenseByline = require("../LicenseByline");
|
|
11
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
/**
|
|
13
|
-
* Copyright (c) 2023-present, NDLA.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const ErrorPlaceholder = (0, _jsx2.styled)("div", {
|
|
21
|
-
base: {
|
|
22
|
-
display: "flex",
|
|
23
|
-
alignItems: "center",
|
|
24
|
-
justifyContent: "center",
|
|
25
|
-
background: "background.subtle",
|
|
26
|
-
height: "surface.xsmall",
|
|
27
|
-
border: "1px solid",
|
|
28
|
-
borderColor: "stroke.default",
|
|
29
|
-
borderRadius: "xsmall",
|
|
30
|
-
"& svg": {
|
|
31
|
-
height: "5xlarge",
|
|
32
|
-
width: "5xlarge",
|
|
33
|
-
fill: "stroke.default"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
const StyledFigure = (0, _jsx2.styled)(_primitives.Figure, {
|
|
38
|
-
base: {
|
|
39
|
-
"& > *:not(:first-child)": {
|
|
40
|
-
marginBlockStart: "3xsmall"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
const EmbedErrorPlaceholder = _ref => {
|
|
45
|
-
let {
|
|
46
|
-
type,
|
|
47
|
-
children,
|
|
48
|
-
figureType,
|
|
49
|
-
float
|
|
50
|
-
} = _ref;
|
|
51
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(StyledFigure, {
|
|
52
|
-
size: figureType,
|
|
53
|
-
float: float,
|
|
54
|
-
"data-embed-type": type,
|
|
55
|
-
children: [children ?? /*#__PURE__*/(0, _jsxRuntime.jsx)(ErrorPlaceholder, {
|
|
56
|
-
"data-embed-type": type,
|
|
57
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.ErrorWarningLine, {})
|
|
58
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LicenseByline.EmbedByline, {
|
|
59
|
-
error: true,
|
|
60
|
-
type: type
|
|
61
|
-
})]
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
var _default = exports.default = EmbedErrorPlaceholder;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.EmbedWrapper = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _react2 = require("@ark-ui/react");
|
|
9
|
-
var _css = require("@ndla/styled-system/css");
|
|
10
|
-
var _jsx2 = require("@ndla/styled-system/jsx");
|
|
11
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
/**
|
|
13
|
-
* Copyright (c) 2024-present, NDLA.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const embedWrapperRecipe = (0, _css.cva)({
|
|
21
|
-
base: {
|
|
22
|
-
position: "relative"
|
|
23
|
-
},
|
|
24
|
-
defaultVariants: {
|
|
25
|
-
noClear: false
|
|
26
|
-
},
|
|
27
|
-
variants: {
|
|
28
|
-
noClear: {
|
|
29
|
-
true: {
|
|
30
|
-
"& + [data-embed-wrapper]": {
|
|
31
|
-
clear: "both"
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
false: {
|
|
35
|
-
clear: "both"
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
const StyledEmbedWrapper = (0, _jsx2.styled)(_react2.ark.div, {}, {
|
|
41
|
-
baseComponent: true
|
|
42
|
-
});
|
|
43
|
-
const EmbedWrapper = exports.EmbedWrapper = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
44
|
-
let {
|
|
45
|
-
noClear,
|
|
46
|
-
css: cssProp,
|
|
47
|
-
...props
|
|
48
|
-
} = _ref;
|
|
49
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledEmbedWrapper, {
|
|
50
|
-
css: _css.css.raw(embedWrapperRecipe.raw({
|
|
51
|
-
noClear
|
|
52
|
-
}), cssProp),
|
|
53
|
-
"data-embed-wrapper": "",
|
|
54
|
-
...props,
|
|
55
|
-
ref: ref
|
|
56
|
-
});
|
|
57
|
-
});
|