This commit is contained in:
Taylor Wilsdon
2026-03-03 17:36:21 -05:00
parent 548394efbb
commit a5a896977f
2 changed files with 17 additions and 5 deletions

View File

@@ -369,7 +369,10 @@ def create_update_paragraph_style_request(
def create_find_replace_request(
find_text: str, replace_text: str, match_case: bool = False, tab_id: Optional[str] = None
find_text: str,
replace_text: str,
match_case: bool = False,
tab_id: Optional[str] = None,
) -> Dict[str, Any]:
"""
Create a replaceAllText request for Google Docs API.
@@ -434,7 +437,9 @@ def create_insert_page_break_request(
return {"insertPageBreak": {"location": location}}
def create_insert_doc_tab_request(title: str, index: int, parent_tab_id: Optional[str] = None) -> Dict[str, Any]:
def create_insert_doc_tab_request(
title: str, index: int, parent_tab_id: Optional[str] = None
) -> Dict[str, Any]:
"""
Create an addDocumentTab request for Google Docs API.
@@ -556,7 +561,7 @@ def create_bullet_list_request(
nesting_level: Nesting level (0-8, where 0 is top level). If None or 0, no tabs added.
paragraph_start_indices: Optional paragraph start positions for ranges with
multiple paragraphs. If omitted, only start_index is tab-prefixed.
tab_id: Optional ID of the tab to target
doc_tab_id: Optional ID of the tab to target
Returns:
List of request dictionaries (insertText for nesting tabs if needed,
@@ -593,7 +598,9 @@ def create_bullet_list_request(
for paragraph_start in paragraph_starts:
adjusted_start = paragraph_start + inserted_char_count
requests.append(create_insert_text_request(adjusted_start, tabs, doc_tab_id))
requests.append(
create_insert_text_request(adjusted_start, tabs, doc_tab_id)
)
inserted_char_count += nesting_level
# Keep createParagraphBullets range aligned to the same logical content.

View File

@@ -295,7 +295,9 @@ class BatchOperationManager:
description = f"find/replace '{op['find_text']}''{op['replace_text']}'"
elif op_type == "insert_doc_tab":
request = create_insert_doc_tab_request(op["title"], op["index"], op.get("parent_tab_id"))
request = create_insert_doc_tab_request(
op["title"], op["index"], op.get("parent_tab_id")
)
description = f"insert tab '{op['title']}' at {op['index']}"
if op.get("parent_tab_id"):
description += f" under parent tab {op['parent_tab_id']}"
@@ -318,6 +320,9 @@ class BatchOperationManager:
"insert_table",
"insert_page_break",
"find_replace",
"insert_doc_tab",
"delete_doc_tab",
"update_doc_tab",
]
raise ValueError(
f"Unsupported operation type '{op_type}'. Supported: {', '.join(supported_types)}"