diff --git a/entry_types/scrolled/app/helpers/pageflow_scrolled/packs_helper.rb b/entry_types/scrolled/app/helpers/pageflow_scrolled/packs_helper.rb index f1f638254..796f2265f 100644 --- a/entry_types/scrolled/app/helpers/pageflow_scrolled/packs_helper.rb +++ b/entry_types/scrolled/app/helpers/pageflow_scrolled/packs_helper.rb @@ -38,14 +38,13 @@ def scrolled_frontend_packs(entry, widget_scope:) def scrolled_editor_packs(entry) ['pageflow-scrolled-editor'] + Pageflow.config_for(entry).additional_editor_packs.paths(entry) + + Pageflow.config_for(entry).additional_frontend_packs.paths(entry) + scrolled_frontend_widget_type_packs(entry, :editor) end def scrolled_editor_stylesheet_packs(entry) - Pageflow - .config_for(entry) - .additional_editor_packs - .stylesheet_paths(entry) + Pageflow.config_for(entry).additional_editor_packs.stylesheet_paths(entry) + + Pageflow.config_for(entry).additional_frontend_packs.paths(entry) end private diff --git a/entry_types/scrolled/config/locales/new/tiktok.de.yml b/entry_types/scrolled/config/locales/new/tiktok.de.yml new file mode 100644 index 000000000..6acb18cbb --- /dev/null +++ b/entry_types/scrolled/config/locales/new/tiktok.de.yml @@ -0,0 +1,12 @@ +de: + pageflow_scrolled: + editor: + content_elements: + tikTokEmbed: + attributes: + url: + label: TikTok-URL + description: Bettet Inhalte von TikTok ein + name: TikTok + tabs: + general: TikTok-Embed diff --git a/entry_types/scrolled/config/locales/new/tiktok.en.yml b/entry_types/scrolled/config/locales/new/tiktok.en.yml new file mode 100644 index 000000000..758aca028 --- /dev/null +++ b/entry_types/scrolled/config/locales/new/tiktok.en.yml @@ -0,0 +1,12 @@ +en: + pageflow_scrolled: + editor: + content_elements: + tikTokEmbed: + attributes: + url: + label: TikTok URL + description: Embed content from TikTok + name: TikTok + tabs: + general: TikTok Embed diff --git a/entry_types/scrolled/lib/generators/pageflow_scrolled/install/install_generator.rb b/entry_types/scrolled/lib/generators/pageflow_scrolled/install/install_generator.rb index 009d3378b..fdba102e5 100644 --- a/entry_types/scrolled/lib/generators/pageflow_scrolled/install/install_generator.rb +++ b/entry_types/scrolled/lib/generators/pageflow_scrolled/install/install_generator.rb @@ -128,7 +128,7 @@ def frontend_pack def server_pack create_file 'app/javascript/packs/pageflow-scrolled-server.js', <<-JS import 'pageflow-scrolled/frontend-server'; - import 'pageflow-scrolled/contentElements-frontend'; + import 'pageflow-scrolled/contentElements-server'; import 'pageflow-scrolled/widgets-server'; JS end diff --git a/entry_types/scrolled/lib/pageflow_scrolled/plugin.rb b/entry_types/scrolled/lib/pageflow_scrolled/plugin.rb index 3cff4ce9b..41c2f3956 100644 --- a/entry_types/scrolled/lib/pageflow_scrolled/plugin.rb +++ b/entry_types/scrolled/lib/pageflow_scrolled/plugin.rb @@ -14,6 +14,11 @@ def configure(config) c.revision_components.register(Storyline) + c.additional_frontend_packs.register( + 'pageflow-scrolled/contentElements/tikTokEmbed-frontend', + content_element_type_names: ['tikTokEmbed'] + ) + c.widget_types.register(ReactWidgetType.new(name: 'defaultNavigation', role: 'header'), default: true) diff --git a/entry_types/scrolled/package/.gitignore b/entry_types/scrolled/package/.gitignore index 9040a62d0..ff82081d8 100644 --- a/entry_types/scrolled/package/.gitignore +++ b/entry_types/scrolled/package/.gitignore @@ -1,4 +1,5 @@ /node_modules +/contentElements /editor.js /frontend /frontend-server.js diff --git a/entry_types/scrolled/package/config/webpack.js b/entry_types/scrolled/package/config/webpack.js index 5accd724e..79579994a 100644 --- a/entry_types/scrolled/package/config/webpack.js +++ b/entry_types/scrolled/package/config/webpack.js @@ -7,8 +7,18 @@ module.exports = { // supported by the browser. 'video.js$': 'video.js/core.es.js' }, + fallback: { + // Silently ignore minimatch trying to load Node built-in module. + 'path': false + } }, entry: { + 'pageflow-scrolled/contentElements/tikTokEmbed-frontend': { + import: [ + 'pageflow-scrolled/contentElements/tikTokEmbed-frontend', + 'pageflow-scrolled/contentElements/tikTokEmbed-frontend.css' + ] + }, 'pageflow-scrolled/widgets/defaultNavigation': { import: [ 'pageflow-scrolled/widgets/defaultNavigation', diff --git a/entry_types/scrolled/package/contentElements-server.js b/entry_types/scrolled/package/contentElements-server.js new file mode 100644 index 000000000..1c9f2aaa3 --- /dev/null +++ b/entry_types/scrolled/package/contentElements-server.js @@ -0,0 +1,2 @@ +import 'pageflow-scrolled/contentElements-frontend'; +import 'pageflow-scrolled/contentElements/tikTokEmbed-frontend'; diff --git a/entry_types/scrolled/package/package.json b/entry_types/scrolled/package/package.json index 28101f691..a5e3c3713 100644 --- a/entry_types/scrolled/package/package.json +++ b/entry_types/scrolled/package/package.json @@ -22,6 +22,7 @@ "react-measure": "^2.3.0", "react-player": "^1.15.2", "react-quick-pinch-zoom": "^4.8.0", + "react-tiny-oembed": "^1.1.0", "react-tooltip": "^3.11.1", "react_ujs": "^2.6.1", "reselect": "^4.0.0", diff --git a/entry_types/scrolled/package/src/contentElements/editor.js b/entry_types/scrolled/package/src/contentElements/editor.js index 305ff0059..16b90e3cf 100644 --- a/entry_types/scrolled/package/src/contentElements/editor.js +++ b/entry_types/scrolled/package/src/contentElements/editor.js @@ -10,8 +10,9 @@ import './inlineBeforeAfter/editor'; import './externalLinkList/editor'; import './vrImage/editor'; import './iframeEmbed/editor'; +import './imageGallery/editor' import './twitterEmbed/editor' +import './tikTokEmbed/editor' import './question/editor' import './counter/editor' import './quote/editor' -import './imageGallery/editor' diff --git a/entry_types/scrolled/package/src/contentElements/tikTokEmbed/TikTokEmbed.js b/entry_types/scrolled/package/src/contentElements/tikTokEmbed/TikTokEmbed.js new file mode 100644 index 000000000..063f3a20a --- /dev/null +++ b/entry_types/scrolled/package/src/contentElements/tikTokEmbed/TikTokEmbed.js @@ -0,0 +1,53 @@ +import React from 'react'; +import Embed from 'react-tiny-oembed'; + +import { + ContentElementBox, + ThirdPartyOptIn, + useContentElementEditorState, + ThirdPartyOptOutInfo, + useContentElementLifecycle, + useIsStaticPreview +} from 'pageflow-scrolled/frontend'; + +import styles from './TikTokEmbed.module.css'; + +const tikTokProvider = { + provider_name: "TikTok", + provider_url: "http://www.tiktok.com/", + endpoints: [ + { + schemes: [ + "https://www.tiktok.com/*", + "https://www.tiktok.com/*/video/*" + ], + url: "https://www.tiktok.com/oembed" + } + ] +}; + +export function TikTokEmbed({configuration}) { + const {url} = configuration; + const {isEditable, isSelected} = useContentElementEditorState(); + const {shouldLoad} = useContentElementLifecycle(); + const isStaticPreview = useIsStaticPreview(); + + return ( + +
+
+ {shouldLoad && url && !isStaticPreview && + +
+ +
+
} +
+ +
+
+ ); +} diff --git a/entry_types/scrolled/package/src/contentElements/tikTokEmbed/TikTokEmbed.module.css b/entry_types/scrolled/package/src/contentElements/tikTokEmbed/TikTokEmbed.module.css new file mode 100644 index 000000000..c0260a790 --- /dev/null +++ b/entry_types/scrolled/package/src/contentElements/tikTokEmbed/TikTokEmbed.module.css @@ -0,0 +1,17 @@ +.wrapper { + margin: 0 auto; + max-width: 325px; + min-height: 450px; + display: flex; + flex-direction: column; + justify-content: center; +} + +.inner { + background-color: #fff; + visibility: hidden; +} + +.inner:has(iframe) { + visibility: visible; +} diff --git a/entry_types/scrolled/package/src/contentElements/tikTokEmbed/editor.js b/entry_types/scrolled/package/src/contentElements/tikTokEmbed/editor.js new file mode 100644 index 000000000..d1425f1e6 --- /dev/null +++ b/entry_types/scrolled/package/src/contentElements/tikTokEmbed/editor.js @@ -0,0 +1,25 @@ +import {editor} from 'pageflow-scrolled/editor'; +import {UrlInputView} from 'pageflow/ui'; +import pictogram from './pictogram.svg' + +editor.contentElementTypes.register('tikTokEmbed', { + pictogram, + category: 'media', + supportedPositions: ['inline', 'sticky', 'standAlone', 'left', 'right'], + supportedWidthRange: ['md', 'full'], + + configurationEditor() { + this.tab('general', function() { + this.input('url', UrlInputView, { + supportedHosts: [ + 'https://www.tiktok.com' + ], + displayPropertyName: 'displayUrl', + required: true, + permitHttps: true + }); + this.group('ContentElementPosition'); + }); + }, + defaultConfig: {}, +}); diff --git a/entry_types/scrolled/package/src/contentElements/tikTokEmbed/frontend.js b/entry_types/scrolled/package/src/contentElements/tikTokEmbed/frontend.js new file mode 100644 index 000000000..6e3302c06 --- /dev/null +++ b/entry_types/scrolled/package/src/contentElements/tikTokEmbed/frontend.js @@ -0,0 +1,19 @@ +import {frontend} from 'pageflow-scrolled/frontend'; +import {TikTokEmbed} from './TikTokEmbed'; + +frontend.contentElementTypes.register('tikTokEmbed', { + component: TikTokEmbed, + lifecycle: true, + customMargin: true, + + consentVendors({t}) { + const prefix = 'pageflow_scrolled.public.tiktok'; + + return [{ + name: 'tiktok', + displayName: t(`${prefix}.consent_vendor_name`), + description: t(`${prefix}.consent_vendor_description`), + paradigm: 'lazy opt-in' + }]; + } +}); diff --git a/entry_types/scrolled/package/src/contentElements/tikTokEmbed/pictogram.svg b/entry_types/scrolled/package/src/contentElements/tikTokEmbed/pictogram.svg new file mode 100644 index 000000000..02ec7576d --- /dev/null +++ b/entry_types/scrolled/package/src/contentElements/tikTokEmbed/pictogram.svg @@ -0,0 +1 @@ + diff --git a/entry_types/scrolled/package/src/contentElements/tikTokEmbed/stories.js b/entry_types/scrolled/package/src/contentElements/tikTokEmbed/stories.js new file mode 100644 index 000000000..f9529467d --- /dev/null +++ b/entry_types/scrolled/package/src/contentElements/tikTokEmbed/stories.js @@ -0,0 +1,10 @@ +import './frontend'; +import {storiesOfContentElement} from 'pageflow-scrolled/spec/support/stories'; + +storiesOfContentElement(module, { + typeName: 'tikTokEmbed', + baseConfiguration: { + url: 'https://www.tiktok.com/@scout2015/video/6718335390845095173' + }, + consent: true +}); diff --git a/entry_types/scrolled/package/src/frontend/thirdPartyConsent/OptOutInfo.js b/entry_types/scrolled/package/src/frontend/thirdPartyConsent/OptOutInfo.js index 8c40420e6..09b349eab 100644 --- a/entry_types/scrolled/package/src/frontend/thirdPartyConsent/OptOutInfo.js +++ b/entry_types/scrolled/package/src/frontend/thirdPartyConsent/OptOutInfo.js @@ -24,7 +24,8 @@ import InfoIcon from '../icons/information.svg' */ export function OptOutInfo({ providerName, - hide + hide, + inset }) { const {t} = useI18n(); const theme = useTheme(); @@ -46,7 +47,7 @@ export function OptOutInfo({ return (