ChunDe Claude Sonnet 4.5 commited on
Commit
b4f24b2
·
1 Parent(s): daeedc1

fix: Smart text object detection for layout customization

Browse files

Instead of hardcoded object IDs, now dynamically finds and updates:
- Title text: Large text (fontSize > 100) or ID contains "title"
- Subtitle text: Smaller text or ID contains "subtitle"/"description"

Removes isFromLayout flag when updating to unlock editing.

Fixes text customization across all layout types.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>

Files changed (1) hide show
  1. mcp_server_comprehensive.py +38 -8
mcp_server_comprehensive.py CHANGED
@@ -418,17 +418,47 @@ async def create_thumbnail(inputs: Dict[str, Any]) -> Dict[str, Any]:
418
 
419
  # Update title if specified
420
  if title:
421
- result = await execute_api_call(page, "updateText", "title-text", title)
422
- results.append({"step": "update_title", "result": result})
423
- # Unlock the layout object by removing isFromLayout flag
424
- await execute_api_call(page, "updateObject", "title-text", {"isFromLayout": False})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
425
 
426
  # Update subtitle if specified
427
  if subtitle:
428
- result = await execute_api_call(page, "updateText", "subtitle", subtitle)
429
- results.append({"step": "update_subtitle", "result": result})
430
- # Unlock the layout object by removing isFromLayout flag
431
- await execute_api_call(page, "updateObject", "subtitle", {"isFromLayout": False})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
432
 
433
  # Add Huggy if specified
434
  if huggy_id:
 
418
 
419
  # Update title if specified
420
  if title:
421
+ # Get all objects to find text objects
422
+ objects_result = await execute_api_call(page, "listObjects", {})
423
+ if objects_result.get("success"):
424
+ objects = objects_result.get("objects", [])
425
+ text_objects = [obj for obj in objects if obj.get("type") == "text"]
426
+
427
+ # Update all text objects that contain title-like text or are large
428
+ for obj in text_objects:
429
+ obj_id = obj.get("id")
430
+ obj_text = obj.get("text", "")
431
+ font_size = obj.get("fontSize", 0)
432
+
433
+ # If it's a large text object (likely a title)
434
+ if font_size > 100 or "title" in obj_id.lower():
435
+ await execute_api_call(page, "updateObject", obj_id, {
436
+ "text": title,
437
+ "isFromLayout": False
438
+ })
439
+ results.append({"step": "update_title_text", "objectId": obj_id})
440
 
441
  # Update subtitle if specified
442
  if subtitle:
443
+ # Get all objects to find subtitle text
444
+ objects_result = await execute_api_call(page, "listObjects", {})
445
+ if objects_result.get("success"):
446
+ objects = objects_result.get("objects", [])
447
+ text_objects = [obj for obj in objects if obj.get("type") == "text"]
448
+
449
+ # Find subtitle (smaller text, contains "subtitle" or "description")
450
+ for obj in text_objects:
451
+ obj_id = obj.get("id")
452
+ obj_text = obj.get("text", "").lower()
453
+ font_size = obj.get("fontSize", 0)
454
+
455
+ # Smaller text or contains subtitle/description keywords
456
+ if (font_size < 100 and "subtitle" in obj_text) or "subtitle" in obj_id.lower() or "description" in obj_id.lower():
457
+ await execute_api_call(page, "updateObject", obj_id, {
458
+ "text": subtitle,
459
+ "isFromLayout": False
460
+ })
461
+ results.append({"step": "update_subtitle_text", "objectId": obj_id})
462
 
463
  # Add Huggy if specified
464
  if huggy_id: