Add hyperlink support to modify_doc_text
This commit is contained in:
@@ -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}"
|
||||
|
||||
Reference in New Issue
Block a user