如何在Google幻灯片API中取消高亮显示?

huangapple go评论69阅读模式
英文:

How to remove highlight in the google slides API?

问题

我正在使用Google API Python客户端来替换文本占位符为生成的数据。在这个示例中,我检测到所有实例的"bar"并将它们替换为"foo",在所有幻灯片中。slides_service是通过apiclient.discovery.build(...)进行实例化的。

如果"bar"具有高亮颜色,当我用"foo"替换它时,如何去除高亮颜色呢?我认为我需要向批量请求数组中添加一个单独的请求,但是我一直在这里上下滚动,没有找到任何线索。

为了更清晰,这是我所说的高亮选项,正如它在UI中呈现的那样。如何在Google幻灯片API中取消高亮显示?

英文:

I am using the Google API Python Client to replace text placeholders with generated data. In this example, I detect all instances of "bar" and replace them with "foo", in all slides. slides_service is instantiated with apiclient.discovery.build(...)

batch_requests_array = [
            {
                "replaceAllText": {
                    "replaceText": "foo",
                    "containsText": {
                        "text": "bar",
                        "matchCase": False
                    }
                }
            }
        ]

        batch_requests = {"requests": batch_requests_array}
        request = slides_service.presentations().batchUpdate(presentationId=slides_id, body=batch_requests)
        res = request.execute()

Now if bar has a highlight color, how can I remove that when I replace it with foo? I think I need to add a separate request to my batch requests array, but I have been scrolling up and down here without finding any clue.

For clarity, this is the highlight option I am talking about as it's presented in the UI 如何在Google幻灯片API中取消高亮显示?

答案1

得分: 1

要移除文本的突出显示颜色,您需要更新backgroundColor。为了给您一个想法,以下是请求的外观,这将使背景完全透明:

highlightedTextRequest = [
	{
		"updateTextStyle": {
			"objectId": "objectId",
			"style": {
				"backgroundColor": {
				}
			}
		}
	}
]

注意: 请求中的objectId是要样式化文本的形状或表格的ID。

参考文献:

英文:

To remove the highlight color of a text, you will have to update the backgroundColor. To give you an idea, this is how the request should look, this will set the background fully transparent:

highlightedTextRequest = [
	{
		"updateTextStyle": {
			"objectId": "objectId",
			"style": {
				"backgroundColor": {
				}
			},              
		"fields": "*"
		}
	}
]

Note: The objectId in the request, is the ID of the shape or table with the text to be styled.

References:

huangapple
  • 本文由 发表于 2023年2月8日 23:28:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75388048.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定