Skip to content

Commit

Permalink
Created for spline-fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
rgravitvl committed Dec 6, 2024
1 parent 0d4f2eb commit e4175d0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions blocks/spline-viewer/spline-viewer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default async function decorate(block) {
try {

Check failure on line 2 in blocks/spline-viewer/spline-viewer.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 2 spaces but found 4
// get the content

Check failure on line 3 in blocks/spline-viewer/spline-viewer.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 6
const fragment = await getFragmentFromFile('/fragments/spline.html');

Check failure on line 4 in blocks/spline-viewer/spline-viewer.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 6

Check failure on line 4 in blocks/spline-viewer/spline-viewer.js

View workflow job for this annotation

GitHub Actions / build

'getFragmentFromFile' is not defined
block.innerHTML = '';

Check failure on line 5 in blocks/spline-viewer/spline-viewer.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 6
const fragmentHtml = parser.parseFromString(fragment, 'text/html');

Check failure on line 6 in blocks/spline-viewer/spline-viewer.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 6

Check failure on line 6 in blocks/spline-viewer/spline-viewer.js

View workflow job for this annotation

GitHub Actions / build

'parser' is not defined
[...fragmentHtml.body.children].forEach((item) => {

Check failure on line 7 in blocks/spline-viewer/spline-viewer.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 8
block.append(item);

Check failure on line 8 in blocks/spline-viewer/spline-viewer.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 6 spaces but found 12
});

Check failure on line 9 in blocks/spline-viewer/spline-viewer.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 8
} catch (e) {
block.textContent = '';
// eslint-disable-next-line no-console
console.warn(`cannot load snippet at ${e}`);
}
}
2 changes: 2 additions & 0 deletions fragments/spline.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<script type="module" src="https://unpkg.com/@splinetool/[email protected]/build/spline-viewer.js"></script>
<spline-viewer url="https://prod.spline.design/UBAIdqMtOkuDExkL/scene.splinecode"></spline-viewer>
2 changes: 2 additions & 0 deletions tools/importer/transformers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -93,6 +94,7 @@ export const transformers = [
embedScript,
callToActionText,
productNotFound,
splineViewer,
];

export const asyncTransformers = [
Expand Down
10 changes: 10 additions & 0 deletions tools/importer/transformers/spline-viewer.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit e4175d0

Please sign in to comment.