MCPcopy Create free account
hub / github.com/OpenDCAI/Paper2Any / wrapText

Function wrapText

frontend-workflow/src/utils/mindmapTree.ts:349–363  ·  view source on GitHub ↗
(value: string, maxChars: number, maxLines: number)

Source from the content-addressed store, hash-verified

347 .replace(/'/g, ''');
348
349const wrapText = (value: string, maxChars: number, maxLines: number) => {
350 const text = value.trim();
351 if (!text) return [];
352 const segments: string[] = [];
353 let cursor = 0;
354 while (cursor < text.length && segments.length < maxLines) {
355 const next = text.slice(cursor, cursor + maxChars);
356 segments.push(next);
357 cursor += maxChars;
358 }
359 if (cursor < text.length && segments.length > 0) {
360 segments[segments.length - 1] = `${segments[segments.length - 1]}…`;
361 }
362 return segments;
363};
364
365const nodeBoxWidth = (isRoot: boolean) => (isRoot ? 280 : SVG_NODE_WIDTH);
366const nodeBoxHeight = (isRoot: boolean) => (isRoot ? 104 : SVG_NODE_HEIGHT);

Callers 1

buildMindMapSvgFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected