@ndla/ui 56.0.123-alpha.0 → 56.0.124-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/es/Article/Article.js +122 -194
- package/es/Article/Article.js.map +1 -0
- package/es/Article/ArticleByline.js +121 -170
- package/es/Article/ArticleByline.js.map +1 -0
- package/es/Article/ArticleFootNotes.js +38 -58
- package/es/Article/ArticleFootNotes.js.map +1 -0
- package/es/AudioPlayer/AudioPlayer.js +151 -212
- package/es/AudioPlayer/AudioPlayer.js.map +1 -0
- package/es/AudioPlayer/Controls.js +246 -324
- package/es/AudioPlayer/Controls.js.map +1 -0
- package/es/AudioPlayer/SpeechControl.js +36 -52
- package/es/AudioPlayer/SpeechControl.js.map +1 -0
- package/es/AudioPlayer/index.js +7 -9
- package/es/AudioPlayer/index.js.map +1 -0
- package/es/Breadcrumb/Breadcrumb.js +42 -58
- package/es/Breadcrumb/Breadcrumb.js.map +1 -0
- package/es/Breadcrumb/BreadcrumbItem.js +33 -59
- package/es/Breadcrumb/BreadcrumbItem.js.map +1 -0
- package/es/Breadcrumb/HomeBreadcrumb.js +41 -74
- package/es/Breadcrumb/HomeBreadcrumb.js.map +1 -0
- package/es/Breadcrumb/index.js +8 -10
- package/es/Breadcrumb/index.js.map +1 -0
- package/es/CampaignBlock/CampaignBlock.js +124 -173
- package/es/CampaignBlock/CampaignBlock.js.map +1 -0
- package/es/CodeBlock/CodeBlock.js +21 -31
- package/es/CodeBlock/CodeBlock.js.map +1 -0
- package/es/CodeBlock/codeLanguageOptions.js +112 -82
- package/es/CodeBlock/codeLanguageOptions.js.map +1 -0
- package/es/Concept/Concept.js +46 -68
- package/es/Concept/Concept.js.map +1 -0
- package/es/ContactBlock/ContactBlock.js +137 -191
- package/es/ContactBlock/ContactBlock.js.map +1 -0
- package/es/ContentTypeBadge/ContentTypeBadge.js +38 -47
- package/es/ContentTypeBadge/ContentTypeBadge.js.map +1 -0
- package/es/ContentTypeBlockQuote/ContentTypeBlockQuote.js +21 -28
- package/es/ContentTypeBlockQuote/ContentTypeBlockQuote.js.map +1 -0
- package/es/ContentTypeFramedContent/ContentTypeFramedContent.js +21 -28
- package/es/ContentTypeFramedContent/ContentTypeFramedContent.js.map +1 -0
- package/es/ContentTypeHero/ContentTypeHero.js +36 -47
- package/es/ContentTypeHero/ContentTypeHero.js.map +1 -0
- package/es/CopyParagraphButton/CopyParagraphButton.js +57 -78
- package/es/CopyParagraphButton/CopyParagraphButton.js.map +1 -0
- package/es/CopyParagraphButton/index.js +7 -10
- package/es/CopyParagraphButton/index.js.map +1 -0
- package/es/Embed/AudioEmbed.js +49 -73
- package/es/Embed/AudioEmbed.js.map +1 -0
- package/es/Embed/BrightcoveEmbed.js +90 -127
- package/es/Embed/BrightcoveEmbed.js.map +1 -0
- package/es/Embed/CodeEmbed.js +55 -73
- package/es/Embed/CodeEmbed.js.map +1 -0
- package/es/Embed/ConceptEmbed.js +72 -117
- package/es/Embed/ConceptEmbed.js.map +1 -0
- package/es/Embed/ConceptInlineTriggerButton.js +39 -44
- package/es/Embed/ConceptInlineTriggerButton.js.map +1 -0
- package/es/Embed/ContentLinkEmbed.js +29 -49
- package/es/Embed/ContentLinkEmbed.js.map +1 -0
- package/es/Embed/CopyrightEmbed.js +21 -31
- package/es/Embed/CopyrightEmbed.js.map +1 -0
- package/es/Embed/EmbedErrorPlaceholder.js +40 -55
- package/es/Embed/EmbedErrorPlaceholder.js.map +1 -0
- package/es/Embed/EmbedWrapper.js +21 -46
- package/es/Embed/EmbedWrapper.js.map +1 -0
- package/es/Embed/ExternalEmbed.js +50 -70
- package/es/Embed/ExternalEmbed.js.map +1 -0
- package/es/Embed/FootnoteEmbed.js +25 -42
- package/es/Embed/FootnoteEmbed.js.map +1 -0
- package/es/Embed/GlossEmbed.js +49 -77
- package/es/Embed/GlossEmbed.js.map +1 -0
- package/es/Embed/H5pEmbed.js +35 -58
- package/es/Embed/H5pEmbed.js.map +1 -0
- package/es/Embed/IframeEmbed.js +65 -89
- package/es/Embed/IframeEmbed.js.map +1 -0
- package/es/Embed/ImageEmbed.js +167 -225
- package/es/Embed/ImageEmbed.js.map +1 -0
- package/es/Embed/InlineTriggerButton.js +20 -32
- package/es/Embed/InlineTriggerButton.js.map +1 -0
- package/es/Embed/RelatedContentEmbed.js +36 -53
- package/es/Embed/RelatedContentEmbed.js.map +1 -0
- package/es/Embed/UnknownEmbed.js +18 -29
- package/es/Embed/UnknownEmbed.js.map +1 -0
- package/es/Embed/UuDisclaimerEmbed.js +51 -85
- package/es/Embed/UuDisclaimerEmbed.js.map +1 -0
- package/es/ErrorMessage/ErrorMessage.js +51 -92
- package/es/ErrorMessage/ErrorMessage.js.map +1 -0
- package/es/ErrorMessage/index.js +7 -9
- package/es/ErrorMessage/index.js.map +1 -0
- package/es/FactBox/FactBox.js +114 -170
- package/es/FactBox/FactBox.js.map +1 -0
- package/es/FactBox/index.js +7 -9
- package/es/FactBox/index.js.map +1 -0
- package/es/FileList/File.js +70 -95
- package/es/FileList/File.js.map +1 -0
- package/es/FileList/FileList.js +31 -46
- package/es/FileList/FileList.js.map +1 -0
- package/es/FileList/PdfFile.js +27 -49
- package/es/FileList/PdfFile.js.map +1 -0
- package/es/Gloss/Gloss.js +133 -166
- package/es/Gloss/Gloss.js.map +1 -0
- package/es/Gloss/GlossExample.js +42 -60
- package/es/Gloss/GlossExample.js.map +1 -0
- package/es/Grid/Grid.js +63 -91
- package/es/Grid/Grid.js.map +1 -0
- package/es/Grid/GridParallaxItem.js +19 -30
- package/es/Grid/GridParallaxItem.js.map +1 -0
- package/es/KeyFigure/KeyFigure.js +44 -61
- package/es/KeyFigure/KeyFigure.js.map +1 -0
- package/es/LicenseByline/EmbedByline.js +126 -206
- package/es/LicenseByline/EmbedByline.js.map +1 -0
- package/es/LicenseByline/LicenseLink.js +28 -53
- package/es/LicenseByline/LicenseLink.js.map +1 -0
- package/es/LinkBlock/LinkBlock.js +70 -99
- package/es/LinkBlock/LinkBlock.js.map +1 -0
- package/es/LinkBlock/LinkBlockSection.js +20 -32
- package/es/LinkBlock/LinkBlockSection.js.map +1 -0
- package/es/Pitch/Pitch.js +59 -80
- package/es/Pitch/Pitch.js.map +1 -0
- package/es/RelatedArticleList/RelatedArticleList.js +91 -129
- package/es/RelatedArticleList/RelatedArticleList.js.map +1 -0
- package/es/RelatedArticleList/index.js +7 -10
- package/es/RelatedArticleList/index.js.map +1 -0
- package/es/ResourceBox/ResourceBox.js +71 -96
- package/es/ResourceBox/ResourceBox.js.map +1 -0
- package/es/TagSelector/TagSelector.js +93 -136
- package/es/TagSelector/TagSelector.js.map +1 -0
- package/es/ZendeskButton/ZendeskButton.js +38 -52
- package/es/ZendeskButton/ZendeskButton.js.map +1 -0
- package/es/_virtual/rolldown_runtime.js +11 -0
- package/es/i18n/formatNestedMessages.js +16 -24
- package/es/i18n/formatNestedMessages.js.map +1 -0
- package/es/i18n/i18n.js +25 -31
- package/es/i18n/i18n.js.map +1 -0
- package/es/i18n/useComponentTranslations.js +147 -203
- package/es/i18n/useComponentTranslations.js.map +1 -0
- package/es/index.js +64 -44
- package/es/locale/messages-en.js +435 -459
- package/es/locale/messages-en.js.map +1 -0
- package/es/locale/messages-nb.js +435 -459
- package/es/locale/messages-nb.js.map +1 -0
- package/es/locale/messages-nn.js +435 -459
- package/es/locale/messages-nn.js.map +1 -0
- package/es/locale/messages-se.js +435 -459
- package/es/locale/messages-se.js.map +1 -0
- package/es/model/ContentType.js +69 -65
- package/es/model/ContentType.js.map +1 -0
- package/es/model/SubjectCategories.js +23 -10
- package/es/model/SubjectCategories.js.map +1 -0
- package/es/model/SubjectTypes.js +21 -9
- package/es/model/SubjectTypes.js.map +1 -0
- package/es/model/WordClass.js +51 -43
- package/es/model/WordClass.js.map +1 -0
- package/es/model/index.js +16 -18
- package/es/model/index.js.map +1 -0
- package/es/utils/licenseAttributes.js +15 -17
- package/es/utils/licenseAttributes.js.map +1 -0
- package/es/utils/relativeUrl.js +21 -32
- package/es/utils/relativeUrl.js.map +1 -0
- package/lib/Article/Article.js +130 -203
- package/lib/Article/Article.js.map +1 -0
- package/lib/Article/ArticleByline.js +125 -179
- package/lib/Article/ArticleByline.js.map +1 -0
- package/lib/Article/ArticleFootNotes.js +39 -65
- package/lib/Article/ArticleFootNotes.js.map +1 -0
- package/lib/AudioPlayer/AudioPlayer.js +155 -221
- package/lib/AudioPlayer/AudioPlayer.js.map +1 -0
- package/lib/AudioPlayer/Controls.js +249 -332
- package/lib/AudioPlayer/Controls.js.map +1 -0
- package/lib/AudioPlayer/SpeechControl.js +39 -60
- package/lib/AudioPlayer/SpeechControl.js.map +1 -0
- package/lib/AudioPlayer/index.js +7 -15
- package/lib/AudioPlayer/index.js.map +1 -0
- package/lib/Breadcrumb/Breadcrumb.js +43 -65
- package/lib/Breadcrumb/Breadcrumb.js.map +1 -0
- package/lib/Breadcrumb/BreadcrumbItem.js +34 -65
- package/lib/Breadcrumb/BreadcrumbItem.js.map +1 -0
- package/lib/Breadcrumb/HomeBreadcrumb.js +43 -82
- package/lib/Breadcrumb/HomeBreadcrumb.js.map +1 -0
- package/lib/Breadcrumb/index.js +8 -22
- package/lib/Breadcrumb/index.js.map +1 -0
- package/lib/CampaignBlock/CampaignBlock.js +128 -183
- package/lib/CampaignBlock/CampaignBlock.js.map +1 -0
- package/lib/CodeBlock/CodeBlock.js +23 -38
- package/lib/CodeBlock/CodeBlock.js.map +1 -0
- package/lib/CodeBlock/codeLanguageOptions.js +112 -87
- package/lib/CodeBlock/codeLanguageOptions.js.map +1 -0
- package/lib/Concept/Concept.js +48 -75
- package/lib/Concept/Concept.js.map +1 -0
- package/lib/ContactBlock/ContactBlock.js +141 -200
- package/lib/ContactBlock/ContactBlock.js.map +1 -0
- package/lib/ContentTypeBadge/ContentTypeBadge.js +40 -54
- package/lib/ContentTypeBadge/ContentTypeBadge.js.map +1 -0
- package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.js +23 -35
- package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.js.map +1 -0
- package/lib/ContentTypeFramedContent/ContentTypeFramedContent.js +23 -35
- package/lib/ContentTypeFramedContent/ContentTypeFramedContent.js.map +1 -0
- package/lib/ContentTypeHero/ContentTypeHero.js +37 -54
- package/lib/ContentTypeHero/ContentTypeHero.js.map +1 -0
- package/lib/CopyParagraphButton/CopyParagraphButton.js +61 -87
- package/lib/CopyParagraphButton/CopyParagraphButton.js.map +1 -0
- package/lib/CopyParagraphButton/index.js +7 -21
- package/lib/CopyParagraphButton/index.js.map +1 -0
- package/lib/Embed/AudioEmbed.js +51 -82
- package/lib/Embed/AudioEmbed.js.map +1 -0
- package/lib/Embed/BrightcoveEmbed.js +93 -138
- package/lib/Embed/BrightcoveEmbed.js.map +1 -0
- package/lib/Embed/CodeEmbed.js +59 -83
- package/lib/Embed/CodeEmbed.js.map +1 -0
- package/lib/Embed/ConceptEmbed.js +77 -127
- package/lib/Embed/ConceptEmbed.js.map +1 -0
- package/lib/Embed/ConceptInlineTriggerButton.js +39 -49
- package/lib/Embed/ConceptInlineTriggerButton.js.map +1 -0
- package/lib/Embed/ContentLinkEmbed.js +30 -55
- package/lib/Embed/ContentLinkEmbed.js.map +1 -0
- package/lib/Embed/CopyrightEmbed.js +22 -37
- package/lib/Embed/CopyrightEmbed.js.map +1 -0
- package/lib/Embed/EmbedErrorPlaceholder.js +42 -62
- package/lib/Embed/EmbedErrorPlaceholder.js.map +1 -0
- package/lib/Embed/EmbedWrapper.js +24 -54
- package/lib/Embed/EmbedWrapper.js.map +1 -0
- package/lib/Embed/ExternalEmbed.js +53 -79
- package/lib/Embed/ExternalEmbed.js.map +1 -0
- package/lib/Embed/FootnoteEmbed.js +26 -48
- package/lib/Embed/FootnoteEmbed.js.map +1 -0
- package/lib/Embed/GlossEmbed.js +51 -86
- package/lib/Embed/GlossEmbed.js.map +1 -0
- package/lib/Embed/H5pEmbed.js +37 -66
- package/lib/Embed/H5pEmbed.js.map +1 -0
- package/lib/Embed/IframeEmbed.js +68 -98
- package/lib/Embed/IframeEmbed.js.map +1 -0
- package/lib/Embed/ImageEmbed.js +173 -238
- package/lib/Embed/ImageEmbed.js.map +1 -0
- package/lib/Embed/InlineTriggerButton.js +23 -40
- package/lib/Embed/InlineTriggerButton.js.map +1 -0
- package/lib/Embed/RelatedContentEmbed.js +37 -59
- package/lib/Embed/RelatedContentEmbed.js.map +1 -0
- package/lib/Embed/UnknownEmbed.js +19 -35
- package/lib/Embed/UnknownEmbed.js.map +1 -0
- package/lib/Embed/UuDisclaimerEmbed.js +53 -92
- package/lib/Embed/UuDisclaimerEmbed.js.map +1 -0
- package/lib/ErrorMessage/ErrorMessage.js +53 -99
- package/lib/ErrorMessage/ErrorMessage.js.map +1 -0
- package/lib/ErrorMessage/index.js +7 -15
- package/lib/ErrorMessage/index.js.map +1 -0
- package/lib/FactBox/FactBox.js +118 -180
- package/lib/FactBox/FactBox.js.map +1 -0
- package/lib/FactBox/index.js +7 -15
- package/lib/FactBox/index.js.map +1 -0
- package/lib/FileList/File.js +75 -105
- package/lib/FileList/File.js.map +1 -0
- package/lib/FileList/FileList.js +33 -52
- package/lib/FileList/FileList.js.map +1 -0
- package/lib/FileList/PdfFile.js +27 -55
- package/lib/FileList/PdfFile.js.map +1 -0
- package/lib/Gloss/Gloss.js +138 -176
- package/lib/Gloss/Gloss.js.map +1 -0
- package/lib/Gloss/GlossExample.js +45 -68
- package/lib/Gloss/GlossExample.js.map +1 -0
- package/lib/Grid/Grid.js +64 -98
- package/lib/Grid/Grid.js.map +1 -0
- package/lib/Grid/GridParallaxItem.js +19 -36
- package/lib/Grid/GridParallaxItem.js.map +1 -0
- package/lib/KeyFigure/KeyFigure.js +45 -68
- package/lib/KeyFigure/KeyFigure.js.map +1 -0
- package/lib/LicenseByline/EmbedByline.js +130 -216
- package/lib/LicenseByline/EmbedByline.js.map +1 -0
- package/lib/LicenseByline/LicenseLink.js +29 -59
- package/lib/LicenseByline/LicenseLink.js.map +1 -0
- package/lib/LinkBlock/LinkBlock.js +73 -108
- package/lib/LinkBlock/LinkBlock.js.map +1 -0
- package/lib/LinkBlock/LinkBlockSection.js +22 -39
- package/lib/LinkBlock/LinkBlockSection.js.map +1 -0
- package/lib/Pitch/Pitch.js +61 -89
- package/lib/Pitch/Pitch.js.map +1 -0
- package/lib/RelatedArticleList/RelatedArticleList.js +96 -140
- package/lib/RelatedArticleList/RelatedArticleList.js.map +1 -0
- package/lib/RelatedArticleList/index.js +7 -20
- package/lib/RelatedArticleList/index.js.map +1 -0
- package/lib/ResourceBox/ResourceBox.js +73 -104
- package/lib/ResourceBox/ResourceBox.js.map +1 -0
- package/lib/TagSelector/TagSelector.js +103 -145
- package/lib/TagSelector/TagSelector.js.map +1 -0
- package/lib/ZendeskButton/ZendeskButton.js +39 -58
- package/lib/ZendeskButton/ZendeskButton.js.map +1 -0
- package/lib/_virtual/rolldown_runtime.js +42 -0
- package/lib/i18n/formatNestedMessages.js +16 -30
- package/lib/i18n/formatNestedMessages.js.map +1 -0
- package/lib/i18n/i18n.js +28 -38
- package/lib/i18n/i18n.js.map +1 -0
- package/lib/i18n/useComponentTranslations.js +154 -215
- package/lib/i18n/useComponentTranslations.js.map +1 -0
- package/lib/index.js +156 -598
- package/lib/locale/messages-en.js +436 -466
- package/lib/locale/messages-en.js.map +1 -0
- package/lib/locale/messages-nb.js +436 -466
- package/lib/locale/messages-nb.js.map +1 -0
- package/lib/locale/messages-nn.js +436 -466
- package/lib/locale/messages-nn.js.map +1 -0
- package/lib/locale/messages-se.js +436 -466
- package/lib/locale/messages-se.js.map +1 -0
- package/lib/model/ContentType.js +90 -70
- package/lib/model/ContentType.js.map +1 -0
- package/lib/model/SubjectCategories.js +26 -14
- package/lib/model/SubjectCategories.js.map +1 -0
- package/lib/model/SubjectTypes.js +24 -13
- package/lib/model/SubjectTypes.js.map +1 -0
- package/lib/model/WordClass.js +55 -48
- package/lib/model/WordClass.js.map +1 -0
- package/lib/model/index.js +16 -25
- package/lib/model/index.js.map +1 -0
- package/lib/utils/licenseAttributes.js +14 -22
- package/lib/utils/licenseAttributes.js.map +1 -0
- package/lib/utils/relativeUrl.js +20 -38
- package/lib/utils/relativeUrl.js.map +1 -0
- package/package.json +12 -11
- package/es/Article/index.js +0 -11
- package/es/CampaignBlock/index.js +0 -9
- package/es/CodeBlock/index.js +0 -10
- package/es/ContactBlock/index.js +0 -9
- package/es/ContentTypeHero/index.js +0 -9
- package/es/Embed/index.js +0 -25
- package/es/Embed/types.js +0 -1
- package/es/FileList/index.js +0 -11
- package/es/Gloss/index.js +0 -10
- package/es/Grid/index.js +0 -10
- package/es/KeyFigure/index.js +0 -9
- package/es/LicenseByline/index.js +0 -10
- package/es/LinkBlock/index.js +0 -10
- package/es/Pitch/index.js +0 -9
- package/es/ResourceBox/index.js +0 -10
- package/es/i18n/index.js +0 -11
- package/es/types.js +0 -1
- package/lib/Article/index.js +0 -68
- package/lib/CampaignBlock/index.js +0 -13
- package/lib/CodeBlock/index.js +0 -20
- package/lib/ContactBlock/index.js +0 -18
- package/lib/ContentTypeHero/index.js +0 -12
- package/lib/Embed/index.js +0 -150
- package/lib/Embed/types.js +0 -5
- package/lib/FileList/index.js +0 -44
- package/lib/Gloss/index.js +0 -20
- package/lib/Grid/index.js +0 -19
- package/lib/KeyFigure/index.js +0 -13
- package/lib/LicenseByline/index.js +0 -19
- package/lib/LinkBlock/index.js +0 -20
- package/lib/Pitch/index.js +0 -12
- package/lib/ResourceBox/index.js +0 -13
- package/lib/i18n/index.js +0 -68
- package/lib/types.js +0 -5
|
@@ -1,142 +1,97 @@
|
|
|
1
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_EmbedByline = require('../LicenseByline/EmbedByline.js');
|
|
3
|
+
const require_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
|
|
4
|
+
const require_licenseAttributes = require('../utils/licenseAttributes.js');
|
|
5
|
+
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
6
|
+
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
7
|
+
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
8
|
+
const html_react_parser = require_rolldown_runtime.__toESM(require("html-react-parser"));
|
|
9
|
+
const react_i18next = require_rolldown_runtime.__toESM(require("react-i18next"));
|
|
10
|
+
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
2
11
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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;
|
|
12
|
+
//#region src/Embed/BrightcoveEmbed.tsx
|
|
13
|
+
const LinkedVideoButton = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Button, { base: { marginBlockStart: "3xsmall" } });
|
|
14
|
+
const BrightcoveIframe = (0, __ndla_styled_system_jsx.styled)("iframe", { base: {
|
|
15
|
+
border: 0,
|
|
16
|
+
height: "auto",
|
|
17
|
+
width: "100%"
|
|
18
|
+
} });
|
|
19
|
+
const isNumeric = (value) => !Number.isNaN(value - Number.parseFloat(value));
|
|
47
20
|
const getIframeProps = (data, sources) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
src: `https://players.brightcove.net/${account}/${player}_default/index.html?videoId=${videoid}`,
|
|
56
|
-
height: source?.height ?? "480",
|
|
57
|
-
width: source?.width ?? "640"
|
|
58
|
-
};
|
|
21
|
+
const { account, videoid, player = "default" } = data;
|
|
22
|
+
const source = sources.filter((s) => s.width && s.height).toSorted((a, b) => a.height - b.height)[0];
|
|
23
|
+
return {
|
|
24
|
+
src: `https://players.brightcove.net/${account}/${player}_default/index.html?videoId=${videoid}`,
|
|
25
|
+
height: source?.height ?? "480",
|
|
26
|
+
width: source?.width ?? "640"
|
|
27
|
+
};
|
|
59
28
|
};
|
|
60
|
-
const BrightcoveEmbed =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
});
|
|
29
|
+
const BrightcoveEmbed = ({ embed, renderContext = "article", lang }) => {
|
|
30
|
+
const [showOriginalVideo, setShowOriginalVideo] = (0, react.useState)(true);
|
|
31
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
32
|
+
const iframeRef = (0, react.useRef)(null);
|
|
33
|
+
const { embedData } = embed;
|
|
34
|
+
const fallbackTitle = `${t("embed.type.video")}: ${embedData.videoid}`;
|
|
35
|
+
const parsedDescription = (0, react.useMemo)(() => {
|
|
36
|
+
if (embed.embedData.caption || renderContext === "article") return embed.embedData.caption ? (0, html_react_parser.default)(embed.embedData.caption) : void 0;
|
|
37
|
+
else if (embed.status === "success" && embed.data.description) return (0, html_react_parser.default)(embed.data.description);
|
|
38
|
+
}, [embed, renderContext]);
|
|
39
|
+
(0, react.useEffect)(() => {
|
|
40
|
+
const iframe = iframeRef.current;
|
|
41
|
+
if (iframe) {
|
|
42
|
+
const [width, height] = [parseInt(iframe.width), parseInt(iframe.height)];
|
|
43
|
+
iframe.style.aspectRatio = `${width}/${height}`;
|
|
44
|
+
iframe.width = "";
|
|
45
|
+
iframe.height = "";
|
|
46
|
+
}
|
|
47
|
+
}, []);
|
|
48
|
+
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmbedErrorPlaceholder.EmbedErrorPlaceholder_default, {
|
|
49
|
+
type: "video",
|
|
50
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BrightcoveIframe, {
|
|
51
|
+
ref: iframeRef,
|
|
52
|
+
title: embedData.alt || fallbackTitle,
|
|
53
|
+
"aria-label": embedData.alt || fallbackTitle,
|
|
54
|
+
...getIframeProps(embedData, []),
|
|
55
|
+
allow: "fullscreen; encrypted-media"
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
const { data } = embed;
|
|
59
|
+
const linkedVideoId = isNumeric(data.link?.text) ? data.link?.text : void 0;
|
|
60
|
+
const originalVideoProps = getIframeProps(embedData, data.sources);
|
|
61
|
+
const alternativeVideoProps = linkedVideoId ? getIframeProps({
|
|
62
|
+
...embedData,
|
|
63
|
+
videoid: linkedVideoId
|
|
64
|
+
}, data.sources) : void 0;
|
|
65
|
+
const licenseProps = require_licenseAttributes.licenseAttributes(data?.copyright?.license.license, lang, embedData.pageUrl);
|
|
66
|
+
const title = data.name?.trim() ? `${t("embed.type.video")}: ${data.name}` : fallbackTitle;
|
|
67
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.Figure, {
|
|
68
|
+
"data-embed-type": "brightcove",
|
|
69
|
+
...licenseProps,
|
|
70
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
71
|
+
className: "brightcove-video",
|
|
72
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BrightcoveIframe, {
|
|
73
|
+
ref: iframeRef,
|
|
74
|
+
className: "original",
|
|
75
|
+
title,
|
|
76
|
+
"aria-label": title,
|
|
77
|
+
...alternativeVideoProps && !showOriginalVideo ? alternativeVideoProps : originalVideoProps,
|
|
78
|
+
allow: "fullscreen; encrypted-media"
|
|
79
|
+
})
|
|
80
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmbedByline.EmbedByline, {
|
|
81
|
+
type: "video",
|
|
82
|
+
copyright: data.copyright,
|
|
83
|
+
description: parsedDescription,
|
|
84
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: !!linkedVideoId && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LinkedVideoButton, {
|
|
85
|
+
size: "small",
|
|
86
|
+
variant: "secondary",
|
|
87
|
+
onClick: () => setShowOriginalVideo((p) => !p),
|
|
88
|
+
children: t(`figure.button.${!showOriginalVideo ? "original" : "alternative"}`)
|
|
89
|
+
}) })
|
|
90
|
+
})]
|
|
91
|
+
});
|
|
141
92
|
};
|
|
142
|
-
var
|
|
93
|
+
var BrightcoveEmbed_default = BrightcoveEmbed;
|
|
94
|
+
|
|
95
|
+
//#endregion
|
|
96
|
+
exports.BrightcoveEmbed_default = BrightcoveEmbed_default;
|
|
97
|
+
//# sourceMappingURL=BrightcoveEmbed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrightcoveEmbed.js","names":["Button","value: any","data: BrightcoveEmbedData","sources: BrightcoveVideoSource[]","EmbedErrorPlaceholder","Figure","EmbedByline"],"sources":["../../src/Embed/BrightcoveEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport parse from \"html-react-parser\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { Button, Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { BrightcoveEmbedData, BrightcoveMetaData, BrightcoveVideoSource } from \"@ndla/types-embed\";\nimport EmbedErrorPlaceholder from \"./EmbedErrorPlaceholder\";\nimport type { RenderContext } from \"./types\";\nimport { EmbedByline } from \"../LicenseByline\";\nimport { licenseAttributes } from \"../utils/licenseAttributes\";\n\ninterface Props {\n embed: BrightcoveMetaData;\n renderContext?: RenderContext;\n lang?: string;\n}\n\nconst LinkedVideoButton = styled(Button, {\n base: {\n marginBlockStart: \"3xsmall\",\n },\n});\n\nconst BrightcoveIframe = styled(\"iframe\", {\n base: {\n border: 0,\n height: \"auto\",\n width: \"100%\",\n },\n});\n\nexport const makeIframeString = (url: string, width: string | number, height: string | number, title = \"\") => {\n const strippedWidth = typeof width === \"number\" ? width : width.replace(/\\s*px/, \"\");\n const strippedHeight = typeof height === \"number\" ? height : height.replace(/\\s*px/, \"\");\n const urlOrTitle = title || url;\n return `<iframe title=\"${urlOrTitle}\" aria-label=\"${urlOrTitle}\" src=\"${url}\" width=\"${strippedWidth}\" height=\"${strippedHeight}\" allowfullscreen scrolling=\"no\" frameborder=\"0\" loading=\"lazy\"></iframe>`;\n};\n\nexport const isNumeric = (value: any) => !Number.isNaN(value - Number.parseFloat(value));\n\nconst getIframeProps = (data: BrightcoveEmbedData, sources: BrightcoveVideoSource[]) => {\n const { account, videoid, player = \"default\" } = data;\n\n const source = sources.filter((s) => s.width && s.height).toSorted((a, b) => a!.height! - b.height!)[0];\n\n return {\n src: `https://players.brightcove.net/${account}/${player}_default/index.html?videoId=${videoid}`,\n height: source?.height ?? \"480\",\n width: source?.width ?? \"640\",\n };\n};\nconst BrightcoveEmbed = ({ embed, renderContext = \"article\", lang }: Props) => {\n const [showOriginalVideo, setShowOriginalVideo] = useState(true);\n const { t } = useTranslation();\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const { embedData } = embed;\n const fallbackTitle = `${t(\"embed.type.video\")}: ${embedData.videoid}`;\n const parsedDescription = useMemo(() => {\n if (embed.embedData.caption || renderContext === \"article\") {\n return embed.embedData.caption ? parse(embed.embedData.caption) : undefined;\n } else if (embed.status === \"success\" && embed.data.description) {\n return parse(embed.data.description);\n }\n }, [embed, renderContext]);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (iframe) {\n const [width, height] = [parseInt(iframe.width), parseInt(iframe.height)];\n iframe.style.aspectRatio = `${width}/${height}`;\n iframe.width = \"\";\n iframe.height = \"\";\n }\n }, []);\n if (embed.status === \"error\") {\n return (\n <EmbedErrorPlaceholder type=\"video\">\n <BrightcoveIframe\n ref={iframeRef}\n title={embedData.alt || fallbackTitle}\n aria-label={embedData.alt || fallbackTitle}\n {...getIframeProps(embedData, [])}\n allow=\"fullscreen; encrypted-media\"\n />\n </EmbedErrorPlaceholder>\n );\n }\n const { data } = embed;\n\n const linkedVideoId = isNumeric(data.link?.text) ? data.link?.text : undefined;\n\n const originalVideoProps = getIframeProps(embedData, data.sources);\n const alternativeVideoProps = linkedVideoId\n ? getIframeProps({ ...embedData, videoid: linkedVideoId }, data.sources)\n : undefined;\n\n const licenseProps = licenseAttributes(data?.copyright?.license.license, lang, embedData.pageUrl);\n\n const title = data.name?.trim() ? `${t(\"embed.type.video\")}: ${data.name}` : fallbackTitle;\n\n return (\n <Figure data-embed-type=\"brightcove\" {...licenseProps}>\n <div className=\"brightcove-video\">\n <BrightcoveIframe\n ref={iframeRef}\n className=\"original\"\n title={title}\n aria-label={title}\n {...(alternativeVideoProps && !showOriginalVideo ? alternativeVideoProps : originalVideoProps)}\n allow=\"fullscreen; encrypted-media\"\n />\n </div>\n <EmbedByline type=\"video\" copyright={data.copyright!} description={parsedDescription}>\n <div>\n {!!linkedVideoId && (\n <LinkedVideoButton size=\"small\" variant=\"secondary\" onClick={() => setShowOriginalVideo((p) => !p)}>\n {t(`figure.button.${!showOriginalVideo ? \"original\" : \"alternative\"}`)}\n </LinkedVideoButton>\n )}\n </div>\n </EmbedByline>\n </Figure>\n );\n};\n\nexport default BrightcoveEmbed;\n"],"mappings":"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"}
|
package/lib/Embed/CodeEmbed.js
CHANGED
|
@@ -1,86 +1,62 @@
|
|
|
1
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
|
|
3
|
+
const require_CodeBlock = require('../CodeBlock/CodeBlock.js');
|
|
4
|
+
const require_codeLanguageOptions = require('../CodeBlock/codeLanguageOptions.js');
|
|
5
|
+
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
6
|
+
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
7
|
+
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
8
|
+
const react_i18next = require_rolldown_runtime.__toESM(require("react-i18next"));
|
|
9
|
+
const __ndla_icons = require_rolldown_runtime.__toESM(require("@ndla/icons"));
|
|
10
|
+
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
11
|
+
const __ndla_util = require_rolldown_runtime.__toESM(require("@ndla/util"));
|
|
2
12
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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;
|
|
13
|
+
//#region src/Embed/CodeEmbed.tsx
|
|
14
|
+
const StyledFigCaption = (0, __ndla_styled_system_jsx.styled)("figcaption", { base: {
|
|
15
|
+
textStyle: "label.large",
|
|
16
|
+
fontWeight: "bold"
|
|
17
|
+
} });
|
|
18
|
+
const StyledFigure = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Figure, { base: {
|
|
19
|
+
clear: "both",
|
|
20
|
+
"& > *:not(:where(:first-child))": { marginBlockStart: "xsmall" }
|
|
21
|
+
} });
|
|
22
|
+
const getTitleFromFormat = (format) => {
|
|
23
|
+
const selectedLanguage = require_codeLanguageOptions.codeLanguageOptions.find((item) => item.format === format);
|
|
24
|
+
if (selectedLanguage) return selectedLanguage.title;
|
|
25
|
+
return;
|
|
46
26
|
};
|
|
47
|
-
const CodeEmbed =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
});
|
|
27
|
+
const CodeEmbed = ({ embed }) => {
|
|
28
|
+
const [isCopied, setIsCopied] = (0, react.useState)(false);
|
|
29
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
30
|
+
(0, react.useEffect)(() => {
|
|
31
|
+
if (isCopied) {
|
|
32
|
+
const timer = setInterval(() => setIsCopied(false), 3e3);
|
|
33
|
+
return () => {
|
|
34
|
+
clearTimeout(timer);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}, [isCopied]);
|
|
38
|
+
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmbedErrorPlaceholder.EmbedErrorPlaceholder_default, { type: "code" });
|
|
39
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledFigure, {
|
|
40
|
+
"data-embed-type": "code-block",
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledFigCaption, { children: embed.embedData.title || getTitleFromFormat(embed.embedData.codeFormat) }),
|
|
43
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CodeBlock.CodeBlock_default, {
|
|
44
|
+
highlightedCode: embed.status === "success" ? embed.data.highlightedCode : "",
|
|
45
|
+
format: embed.embedData.codeFormat
|
|
46
|
+
}),
|
|
47
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.Button, {
|
|
48
|
+
variant: "secondary",
|
|
49
|
+
onClick: () => {
|
|
50
|
+
(0, __ndla_util.copyTextToClipboard)(embed.status === "success" ? embed.data.decodedContent : "");
|
|
51
|
+
setIsCopied(true);
|
|
52
|
+
},
|
|
53
|
+
children: [isCopied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.CheckLine, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.FileCopyLine, {}), isCopied ? t("codeBlock.copiedCode") : t("codeBlock.copyCode")]
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
});
|
|
85
57
|
};
|
|
86
|
-
var
|
|
58
|
+
var CodeEmbed_default = CodeEmbed;
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
exports.CodeEmbed_default = CodeEmbed_default;
|
|
62
|
+
//# sourceMappingURL=CodeEmbed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeEmbed.js","names":["Figure","format: string","item: ICodeLangugeOption","EmbedErrorPlaceholder","CodeBlock","Button","CheckLine","FileCopyLine"],"sources":["../../src/Embed/CodeEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { useEffect, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { FileCopyLine, CheckLine } from \"@ndla/icons\";\nimport { Button, Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { CodeMetaData } from \"@ndla/types-embed\";\nimport { copyTextToClipboard } from \"@ndla/util\";\nimport EmbedErrorPlaceholder from \"./EmbedErrorPlaceholder\";\nimport { CodeBlock, codeLanguageOptions } from \"../CodeBlock\";\nimport type { ICodeLangugeOption } from \"../CodeBlock/codeLanguageOptions\";\n\ninterface Props {\n embed: CodeMetaData;\n}\n\nconst StyledFigCaption = styled(\"figcaption\", {\n base: {\n textStyle: \"label.large\",\n fontWeight: \"bold\",\n },\n});\n\nconst StyledFigure = styled(Figure, {\n base: {\n clear: \"both\",\n // We apply margin here to allow for the float and size props on figure to work as intended.\n \"& > *:not(:where(:first-child))\": {\n marginBlockStart: \"xsmall\",\n },\n },\n});\n\nconst getTitleFromFormat = (format: string) => {\n const selectedLanguage = codeLanguageOptions.find((item: ICodeLangugeOption) => item.format === format);\n if (selectedLanguage) {\n return selectedLanguage.title;\n }\n return;\n};\n\nconst CodeEmbed = ({ embed }: Props) => {\n const [isCopied, setIsCopied] = useState(false);\n const { t } = useTranslation();\n\n useEffect(() => {\n if (isCopied) {\n const timer = setInterval(() => setIsCopied(false), 3000);\n // ensure interval is cleared - also if unmounted\n return () => {\n clearTimeout(timer);\n };\n }\n }, [isCopied]);\n\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type=\"code\" />;\n }\n\n return (\n <StyledFigure data-embed-type=\"code-block\">\n <StyledFigCaption>{embed.embedData.title || getTitleFromFormat(embed.embedData.codeFormat)}</StyledFigCaption>\n <CodeBlock\n highlightedCode={embed.status === \"success\" ? embed.data.highlightedCode : \"\"}\n format={embed.embedData.codeFormat}\n />\n <Button\n variant=\"secondary\"\n onClick={() => {\n copyTextToClipboard(embed.status === \"success\" ? embed.data.decodedContent : \"\");\n setIsCopied(true);\n }}\n >\n {isCopied ? <CheckLine /> : <FileCopyLine />}\n {isCopied ? t(\"codeBlock.copiedCode\") : t(\"codeBlock.copyCode\")}\n </Button>\n </StyledFigure>\n );\n};\n\nexport default CodeEmbed;\n"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,mBAAmB,qCAAO,cAAc,EAC5C,MAAM;CACJ,WAAW;CACX,YAAY;AACb,EACF,EAAC;AAEF,MAAM,eAAe,qCAAOA,0BAAQ,EAClC,MAAM;CACJ,OAAO;CAEP,mCAAmC,EACjC,kBAAkB,SACnB;AACF,EACF,EAAC;AAEF,MAAM,qBAAqB,CAACC,WAAmB;CAC7C,MAAM,mBAAmB,gDAAoB,KAAK,CAACC,SAA6B,KAAK,WAAW,OAAO;AACvG,KAAI,iBACF,QAAO,iBAAiB;AAE1B;AACD;AAED,MAAM,YAAY,CAAC,EAAE,OAAc,KAAK;CACtC,MAAM,CAAC,UAAU,YAAY,GAAG,oBAAS,MAAM;CAC/C,MAAM,EAAE,GAAG,GAAG,mCAAgB;AAE9B,sBAAU,MAAM;AACd,MAAI,UAAU;GACZ,MAAM,QAAQ,YAAY,MAAM,YAAY,MAAM,EAAE,IAAK;AAEzD,UAAO,MAAM;AACX,iBAAa,MAAM;GACpB;EACF;CACF,GAAE,CAAC,QAAS,EAAC;AAEd,KAAI,MAAM,WAAW,QACnB,wBAAO,2BAACC,+DAAsB,MAAK,SAAS;AAG9C,wBACE,4BAAC;EAAa,mBAAgB;;mBAC5B,2BAAC,8BAAkB,MAAM,UAAU,SAAS,mBAAmB,MAAM,UAAU,WAAW,GAAoB;mBAC9G,2BAACC;IACC,iBAAiB,MAAM,WAAW,YAAY,MAAM,KAAK,kBAAkB;IAC3E,QAAQ,MAAM,UAAU;KACxB;mBACF,4BAACC;IACC,SAAQ;IACR,SAAS,MAAM;AACb,0CAAoB,MAAM,WAAW,YAAY,MAAM,KAAK,iBAAiB,GAAG;AAChF,iBAAY,KAAK;IAClB;eAEA,2BAAW,2BAACC,2BAAY,mBAAG,2BAACC,8BAAe,EAC3C,WAAW,EAAE,uBAAuB,GAAG,EAAE,qBAAqB;KACxD;;GACI;AAElB;AAED,wBAAe"}
|
|
@@ -1,131 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
|
|
3
|
+
const require_ConceptInlineTriggerButton = require('./ConceptInlineTriggerButton.js');
|
|
4
|
+
const require_GlossEmbed = require('./GlossEmbed.js');
|
|
5
|
+
const require_Concept = require('../Concept/Concept.js');
|
|
6
|
+
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
7
|
+
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
8
|
+
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
9
|
+
const html_react_parser = require_rolldown_runtime.__toESM(require("html-react-parser"));
|
|
10
|
+
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
11
|
+
const __ark_ui_react = require_rolldown_runtime.__toESM(require("@ark-ui/react"));
|
|
2
12
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
//#region src/Embed/ConceptEmbed.tsx
|
|
14
|
+
const StyledPopoverContent = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.PopoverContent, { base: {
|
|
15
|
+
width: "surface.xlarge",
|
|
16
|
+
maxHeight: "50vh",
|
|
17
|
+
overflowY: "auto"
|
|
18
|
+
} });
|
|
19
|
+
const ConceptEmbed = ({ embed, renderContext, lang, previewAlt }) => {
|
|
20
|
+
const parsedContent = (0, react.useMemo)(() => {
|
|
21
|
+
if (embed.status === "error" || !embed.data.concept.content) return void 0;
|
|
22
|
+
return (0, html_react_parser.default)(embed.data.concept.content.htmlContent);
|
|
23
|
+
}, [embed]);
|
|
24
|
+
if (embed.status === "error" && embed.embedData.type === "inline") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: embed.embedData.linkText });
|
|
25
|
+
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmbedErrorPlaceholder.EmbedErrorPlaceholder_default, { type: "gloss" });
|
|
26
|
+
const { concept, visualElement } = embed.data;
|
|
27
|
+
if (embed.data.concept.glossData) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_GlossEmbed.GlossEmbed, { embed });
|
|
28
|
+
if (embed.embedData.type === "inline") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineConcept, {
|
|
29
|
+
previewAlt,
|
|
30
|
+
linkText: embed.embedData.linkText,
|
|
31
|
+
copyright: concept.copyright,
|
|
32
|
+
visualElement,
|
|
33
|
+
lang,
|
|
34
|
+
title: concept.title.title,
|
|
35
|
+
source: concept.source,
|
|
36
|
+
children: parsedContent
|
|
37
|
+
});
|
|
38
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BlockConcept, {
|
|
39
|
+
previewAlt,
|
|
40
|
+
copyright: concept.copyright,
|
|
41
|
+
visualElement,
|
|
42
|
+
lang,
|
|
43
|
+
title: renderContext === "embed" ? void 0 : concept.title.title,
|
|
44
|
+
source: concept.source,
|
|
45
|
+
children: parsedContent
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
const InlineConcept = (0, react.forwardRef)(({ linkText, copyright, visualElement, previewAlt, lang, children, title, source,...rest }, ref) => {
|
|
49
|
+
const contentRef = (0, react.useRef)(null);
|
|
50
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.PopoverRoot, {
|
|
51
|
+
initialFocusEl: () => contentRef.current,
|
|
52
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.PopoverTrigger, {
|
|
53
|
+
asChild: true,
|
|
54
|
+
ref,
|
|
55
|
+
...rest,
|
|
56
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ConceptInlineTriggerButton.ConceptInlineTriggerButton, { children: linkText })
|
|
57
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ark_ui_react.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledPopoverContent, {
|
|
58
|
+
ref: contentRef,
|
|
59
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Concept.Concept, {
|
|
60
|
+
copyright,
|
|
61
|
+
visualElement,
|
|
62
|
+
title,
|
|
63
|
+
lang,
|
|
64
|
+
source,
|
|
65
|
+
previewAlt,
|
|
66
|
+
children
|
|
67
|
+
})
|
|
68
|
+
}) })]
|
|
69
|
+
});
|
|
32
70
|
});
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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;
|
|
71
|
+
const BlockConcept = (0, react.forwardRef)((props, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Concept.Concept, {
|
|
72
|
+
...props,
|
|
73
|
+
"data-embed-type": "concept",
|
|
74
|
+
ref
|
|
75
|
+
}));
|
|
59
76
|
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
};
|
|
77
|
+
//#endregion
|
|
78
|
+
exports.BlockConcept = BlockConcept;
|
|
88
79
|
exports.ConceptEmbed = ConceptEmbed;
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
}));
|
|
80
|
+
exports.InlineConcept = InlineConcept;
|
|
81
|
+
//# sourceMappingURL=ConceptEmbed.js.map
|