Add hyperlink support to modify_doc_text

This commit is contained in:
Gigi Sayfan
2026-02-07 13:44:09 -08:00
parent 79a578eda9
commit 34957de2e4
6 changed files with 54 additions and 6 deletions

View File

@@ -367,6 +367,7 @@ async def modify_doc_text(
font_family: str = None,
text_color: str = None,
background_color: str = None,
link_url: str = None,
) -> str:
"""
Modifies text in a Google Doc - can insert/replace text and/or apply formatting in a single operation.
@@ -384,13 +385,14 @@ async def modify_doc_text(
font_family: Font family name (e.g., "Arial", "Times New Roman")
text_color: Foreground text color (#RRGGBB)
background_color: Background/highlight color (#RRGGBB)
link_url: Hyperlink URL (http/https)
Returns:
str: Confirmation message with operation details
"""
logger.info(
f"[modify_doc_text] Doc={document_id}, start={start_index}, end={end_index}, text={text is not None}, "
f"formatting={any([bold, italic, underline, font_size, font_family, text_color, background_color])}"
f"formatting={any([bold, italic, underline, font_size, font_family, text_color, background_color, link_url])}"
)
# Input validation
@@ -410,9 +412,10 @@ async def modify_doc_text(
font_family,
text_color,
background_color,
link_url,
]
):
return "Error: Must provide either 'text' to insert/replace, or formatting parameters (bold, italic, underline, font_size, font_family, text_color, background_color)."
return "Error: Must provide either 'text' to insert/replace, or formatting parameters (bold, italic, underline, font_size, font_family, text_color, background_color, link_url)."
# Validate text formatting params if provided
if any(
@@ -434,6 +437,7 @@ async def modify_doc_text(
font_family,
text_color,
background_color,
link_url,
)
if not is_valid:
return f"Error: {error_msg}"
@@ -491,6 +495,7 @@ async def modify_doc_text(
font_family,
text_color,
background_color,
link_url,
]
):
# Adjust range for formatting based on text operations
@@ -524,6 +529,7 @@ async def modify_doc_text(
font_family,
text_color,
background_color,
link_url,
)
)
@@ -542,6 +548,8 @@ async def modify_doc_text(
format_details.append(f"text_color={text_color}")
if background_color:
format_details.append(f"background_color={background_color}")
if link_url:
format_details.append(f"link_url={link_url}")
operations.append(
f"Applied formatting ({', '.join(format_details)}) to range {format_start}-{format_end}"