I'm trying to change the absolute position of a OneNote div without success. I can create the full body with an absoluted positioned div:
This is my request:
[
{
'target':'body',
'action':'replace',
'content':'<body data-absolute-enabled="true">
<p>This content will appear in the _default div.</p>
<div style="position:absolute;top:175px;left:100px" data-id="div1">
<p>This content will appear in an absolute positioned div.</p>
</div>
<div>
<p>This content will also appear in the _default div.</p>
</div>
</body>'
}
]
This is the output html (it's ok):
<html>
<head>
<title>x2222x</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="created" content="2021-04-18T09:13:00.0000000" />
</head>
<body data-absolute-enabled="true" style="font-family:Calibri;font-size:11pt">
<div id="div:{f3e8317f-4b34-00f5-3826-a7b41de83075}{18}" style="position:absolute;left:48px;top:91px;width:624px">
<p id="p:{ef5cb98c-74e7-4c65-b51a-0adbc66d9c97}{225}" lang="en-US" style="margin-top:5.5pt;margin-bottom:5.5pt">
This content will appear in the _default div.</p>
<p id="p:{ef5cb98c-74e7-4c65-b51a-0adbc66d9c97}{228}" lang="en-US" style="margin-top:5.5pt;margin-bottom:5.5pt">
This content will also appear in the _default div.</p>
</div>
<div id="div:{ef5cb98c-74e7-4c65-b51a-0adbc66d9c97}{229}" data-id="div1"
style="position:absolute;left:99px;top:174px;width:624px">
<p id="p:{ef5cb98c-74e7-4c65-b51a-0adbc66d9c97}{233}" lang="en-US" style="margin-top:5.5pt;margin-bottom:5.5pt">
This content will appear in an absolute positioned div.</p>
</div>
</body>
</html>
But then, I can't change this position, I need to "move" the div1. How can I chage an absolute position to an especific div?
This is my request to "move" the div1 (by id) and it doesn't work:
PACH https://graph.microsoft.com/v1.0/me/onenote/pages/{my_page_id}/content
[
{
'target':'div:{ef5cb98c-74e7-4c65-b51a-0adbc66d9c97}{229}',
'action':'replace',
'content':'<div style="position:absolute;top:350px;left:200px" data-id="div1">
<p>This content will appear in an absolute positioned div (updated).</p>
</div>'
}
]
Thank you!!!
Looking at the relevant documents page absolutely positioned divs cannot be simply replaced and they must be direct children of the body element.
So the only way to achieve the outcome you are looking for would be to replace the entire body.