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

Function handleSetText

packages/sdk/src/engine/mutate.ts:353–370  ·  view source on GitHub ↗
(parsed: ParsedDocument, ids: HfId[], value: string)

Source from the content-addressed store, hash-verified

351}
352
353function handleSetText(parsed: ParsedDocument, ids: HfId[], value: string): MutationResult {
354 const result: MutationResult = { forward: [], inverse: [] };
355 for (const id of ids) {
356 const el = resolveScoped(parsed.document, id);
357 if (!el) continue;
358 const oldText = getOwnText(el);
359 setOwnText(el, value);
360 const path = textPath(id);
361 // getOwnText always returns string ("" for empty) — use it directly so
362 // the forward patch is always op:'replace', not op:'add'. An op:'add' on
363 // a text path is semantically wrong for external JSON-patch consumers
364 // (the path already exists; add would fail on strict appliers).
365 const p = scalarChange(path, oldText, value);
366 result.forward.push(p.forward);
367 result.inverse.push(p.inverse);
368 }
369 return result;
370}
371
372function handleSetAttribute(
373 parsed: ParsedDocument,

Callers 1

applyOpFunction · 0.85

Calls 5

resolveScopedFunction · 0.85
getOwnTextFunction · 0.85
setOwnTextFunction · 0.85
textPathFunction · 0.85
scalarChangeFunction · 0.85

Tested by

no test coverage detected