diff --git a/blocks/spline-viewer/spline-viewer.js b/blocks/spline-viewer/spline-viewer.js new file mode 100644 index 000000000..11f9f5fe8 --- /dev/null +++ b/blocks/spline-viewer/spline-viewer.js @@ -0,0 +1,18 @@ +import { getFragmentFromFile } from '../../scripts/scripts.js'; + +export default async function decorate(block) { + try { + // get the content + const fragment = await getFragmentFromFile('/fragments/spline.html'); + block.innerHTML = ''; + const parser = new DOMParser(); + const fragmentHtml = parser.parseFromString(fragment, 'text/html'); + [...fragmentHtml.body.children].forEach((item) => { + block.append(item); + }); + } catch (e) { + block.textContent = ''; + // eslint-disable-next-line no-console + console.warn(`cannot load snippet at ${e}`); + } +} diff --git a/fragments/spline.html b/fragments/spline.html new file mode 100644 index 000000000..4d28cb890 --- /dev/null +++ b/fragments/spline.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/tools/importer/transformers/index.js b/tools/importer/transformers/index.js index e1e330263..1858acca1 100644 --- a/tools/importer/transformers/index.js +++ b/tools/importer/transformers/index.js @@ -47,6 +47,7 @@ import workflowCarousel from './workflowCarousel.js'; import embedScript from './embedScript.js'; import callToActionText from './callToActionText.js'; import productNotFound from './product-not-found.js'; +import splineViewer from './spline-viewer.js'; // eslint-disable-next-line import/prefer-default-export export const transformers = [ @@ -93,6 +94,7 @@ export const transformers = [ embedScript, callToActionText, productNotFound, + splineViewer, ]; export const asyncTransformers = [ diff --git a/tools/importer/transformers/spline-viewer.js b/tools/importer/transformers/spline-viewer.js new file mode 100644 index 000000000..b879ea777 --- /dev/null +++ b/tools/importer/transformers/spline-viewer.js @@ -0,0 +1,10 @@ +/* global WebImporter */ +const splineViewer = (main, document) => { + const splineViewerEl = main.querySelector('div#spline-viewer'); + if (splineViewerEl) { + const block = [['Spline Viewer'], ['']]; + const table = WebImporter.DOMUtils.createTable(block, document); + splineViewerEl.replaceWith(table); + } +}; +export default splineViewer;