用户在OneNote中将他的待办事项组织为嵌套列表,如下所示:user's page
我需要将“任务A”标记为已完成。根据{{3}},我应该执行todo的替换操作。
首先,我打电话给GET /me/onenote/pages/{pageId}/content?includeIDs=true
来查找待办事项“任务A”的正确ID(请参阅“修补程序之前的页面内容”⇩)。
然后我将PATCH /me/onenote/pages/{pageId}/content
与正文一起发送:
[
{
"action": "replace",
"target": "p:{33109592-eab9-44fa-8cec-867ab11cecfd}{55}",
"content": "<p data-tag=\"to-do:completed\" style=\"margin-top:0pt;margin-bottom:0pt\">Task A</p>"
}
]
API响应204,并且“任务A”现在已完成。但它已移至“第2点”下:documentation
如果我替换“任务B”的标记,则会出现相同的问题-它已完成,但在“子任务B1”下。
如何在不中断列表的情况下替换待办事项?
PATCH(图形API响应)之前的页面内容
<html lang="en-US">
<head>
<title>Nested list</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="created" content="2018-10-04T09:46:00.0000000" />
</head>
<body data-absolute-enabled="true" style="font-family:Calibri;font-size:11pt">
<div id="div:{33109592-eab9-44fa-8cec-867ab11cecfd}{49}" style="position:absolute;left:76px;top:144px;width:548px">
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{55}" data-tag="to-do" style="margin-top:0pt;margin-bottom:0pt">Task A</p>
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{52}" style="margin-top:0pt;margin-bottom:0pt">Point 1</p>
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{54}" style="margin-top:0pt;margin-bottom:0pt">Point 2</p>
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{59}" data-tag="to-do" style="margin-top:0pt;margin-bottom:0pt">Task B</p>
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{58}" data-tag="to-do" style="margin-top:0pt;margin-bottom:0pt">Subtask B1</p>
</div>
</body>
</html>
PATCH(图形API响应)后的页面内容
<html lang="en-US">
<head>
<title>Nested list</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="created" content="2018-10-04T09:46:00.0000000" />
</head>
<body data-absolute-enabled="true" style="font-family:Calibri;font-size:11pt">
<div id="div:{33109592-eab9-44fa-8cec-867ab11cecfd}{49}" style="position:absolute;left:76px;top:144px;width:548px">
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{52}" style="margin-top:0pt;margin-bottom:0pt">Point 1</p>
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{54}" style="margin-top:0pt;margin-bottom:0pt">Point 2</p>
<p id="p:{b815e00e-3326-49db-bcdd-7aecba36b1a4}{92}" data-tag="to-do:completed" style="margin-top:0pt;margin-bottom:0pt">Task A</p>
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{59}" data-tag="to-do" style="margin-top:0pt;margin-bottom:0pt">Task B</p>
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{58}" data-tag="to-do" style="margin-top:0pt;margin-bottom:0pt">Subtask B1</p>
</div>
</body>
</html>
答案 0 :(得分:0)
对于这个问题,我不知道API服务器端如何处理它。您可以在UserVoice中提交功能请求,也可以在Github中提交错误。
针对您的客户端的解决方法:在任务A 和 Point1 之间添加空行。我已经对其进行了测试,它对我而言效果很好。
<div id="div:{46b62548-ca53-41b9-90e1-75d14bbc7504}{38}" style="position:absolute;left:48px;top:115px;width:624px">
<p id="p:{6a8603ba-4743-4f74-a61a-795245aa36b0}{139}" style="margin-top:0pt;margin-bottom:0pt"> </p>
<p id="p:{6a8603ba-4743-4f74-a61a-795245aa36b0}{137}" style="margin-top:0pt;margin-bottom:0pt"> </p>
<p id="p:{9c90b33e-de52-4fe5-9ebe-a6f0787cc91b}{131}" data-tag="to-do:completed" style="margin-top:0pt;margin-bottom:0pt">Task A</p>
<br />
<p id="p:{6a8603ba-4743-4f74-a61a-795245aa36b0}{211}" style="margin-top:0pt;margin-bottom:0pt">Point </p>
<p id="p:{6a8603ba-4743-4f74-a61a-795245aa36b0}{141}" style="margin-top:0pt;margin-bottom:0pt"> Point2</p>
<p id="p:{6a8603ba-4743-4f74-a61a-795245aa36b0}{169}" style="margin-top:0pt;margin-bottom:0pt"> </p>
<p id="p:{6a8603ba-4743-4f74-a61a-795245aa36b0}{145}" data-tag="to-do" style="margin-top:0pt;margin-bottom:0pt">Task B</p>
<p id="p:{6a8603ba-4743-4f74-a61a-795245aa36b0}{173}" style="margin-top:0pt;margin-bottom:0pt"> </p>
<p id="p:{6a8603ba-4743-4f74-a61a-795245aa36b0}{144}" data-tag="to-do" style="margin-top:0pt;margin-bottom:0pt"> SubTask B1</p>
</div>