MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / patchInlineStyle

Function patchInlineStyle

packages/studio/src/utils/sourcePatcher.ts:157–170  ·  view source on GitHub ↗

* Apply a style property change to an element's inline style in the HTML source.

(
  html: string,
  elementId: string,
  prop: string,
  value: string | null,
)

Source from the content-addressed store, hash-verified

155 * Apply a style property change to an element's inline style in the HTML source.
156 */
157function patchInlineStyle(
158 html: string,
159 elementId: string,
160 prop: string,
161 value: string | null,
162): string {
163 // Find the element tag with this id
164 const idPattern = new RegExp(`(<[^>]*\\bid=(["'])${escapeRegex(elementId)}\\2[^>]*)>`, "i");
165 const match = idPattern.exec(html);
166 if (!match) return html;
167
168 const tag = match[1];
169 return patchInlineStyleInTag(html, tag, prop, value);
170}
171
172function patchInlineStyleInTag(
173 html: string,

Callers 1

applyPatchFunction · 0.85

Calls 2

patchInlineStyleInTagFunction · 0.85
escapeRegexFunction · 0.70

Tested by

no test coverage detected