MCPcopy
hub / github.com/makeplane/plane / extractAssetsFromHTMLContent

Function extractAssetsFromHTMLContent

packages/editor/src/core/helpers/parser.ts:22–37  ·  view source on GitHub ↗
(htmlContent: string)

Source from the content-addressed store, hash-verified

20 * @returns {string[]} array of asset sources
21 */
22const extractAssetsFromHTMLContent = (htmlContent: string): string[] => {
23 // create a DOM parser
24 const parser = new DOMParser();
25 // parse the HTML string into a DOM document
26 const doc = parser.parseFromString(htmlContent, "text/html");
27 // collect all unique asset sources
28 const assetSources = new Set<string>();
29 // extract sources from image components
30 const imageComponents = doc.querySelectorAll("image-component");
31 imageComponents.forEach((component) => {
32 const src = component.getAttribute("src");
33 if (src) assetSources.add(src);
34 });
35 const additionalAssetIds = extractAdditionalAssetsFromHTMLContent(htmlContent);
36 return [...Array.from(assetSources), ...additionalAssetIds];
37};
38
39/**
40 * @description function to replace assets in HTML content with new IDs

Callers 1

Calls 2

addMethod · 0.80

Tested by

no test coverage detected