diff --git a/client/modules/Preview/EmbedFrame.jsx b/client/modules/Preview/EmbedFrame.jsx index 4b2ad60d9b..a307e309d7 100644 --- a/client/modules/Preview/EmbedFrame.jsx +++ b/client/modules/Preview/EmbedFrame.jsx @@ -7,8 +7,8 @@ import { JSHINT } from 'jshint'; import decomment from 'decomment'; import { resolvePathToFile } from '../../../server/utils/filePath'; import getConfig from '../../utils/getConfig'; +import resolvePathsForElementsWithAttribute from '../../../server/utils/filePath'; import { - MEDIA_FILE_REGEX, MEDIA_FILE_QUOTED_REGEX, STRING_REGEX, PLAINTEXT_FILE_REGEX, @@ -34,19 +34,6 @@ const Frame = styled.iframe` `} `; -function resolvePathsForElementsWithAttribute(attr, sketchDoc, files) { - const elements = sketchDoc.querySelectorAll(`[${attr}]`); - const elementsArray = Array.prototype.slice.call(elements); - elementsArray.forEach((element) => { - if (element.getAttribute(attr).match(MEDIA_FILE_REGEX)) { - const resolvedFile = resolvePathToFile(element.getAttribute(attr), files); - if (resolvedFile && resolvedFile.url) { - element.setAttribute(attr, resolvedFile.url); - } - } - }); -} - function resolveCSSLinksInString(content, files) { let newContent = content; let cssFileStrings = content.match(STRING_REGEX);