从上下文获取目标再提交
const ctx = await mn.api('/writing/context', { method: 'POST', body: {} });
const surface = (ctx.surfaces || [])[0];
const target = surface && surface.state
&& surface.state.visiblePages
&& surface.state.visiblePages[0].pagedCommitTarget;
if (!target) { mn.log('这条路径当前不可用'); return; }
await mn.api('/writing/pencil-document-commit', {
method: 'POST',
body: {
surfaceId: surface.surfaceId,
requestId: crypto.randomUUID(),
writer: 'paged',
target,
confirm: true
}
});{
"schemaVersion": 1,
"state": "pending",
"currentness": "at-native-callback-only",
"ready": false,
"surfaceId": "8D01BA73-1CF6-4E6B-BCF1-9378B108C16B",
"bridgeApiVersion": "0.91",
"inputGate": {
"scope": "application-ui-only",
"state": "active",
"programmaticNavigationBlocked": false,
"grantsCallerLease": false
},
"topicid": "449C1665-E0DD-4A20-9E67-2B0D451F746D",
"scope": "document-pencil-snapshot-only",
"requestId": "78E0BE17-6C0A-4C4B-8D48-48AC4E4CE160",
"windowId": "287538A6-9249-4FD6-B026-493466471716",
"receipt": null,
"canSwitch": false,
"target": {
"pageNo": 1,
"storageBookmd5": "ec280b8dbd77594d16b090165fdd4c07ec280b8dbd77594d16b090165fdd4c07",
"storagePage": 1,
"bookmd5": "ec280b8dbd77594d16b090165fdd4c07ec280b8dbd77594d16b090165fdd4c07",
"storageTopicId": "B1F2A354-125A-4384-A271-C0B829AB9E09",
"layerId": "",
"topicid": "449C1665-E0DD-4A20-9E67-2B0D451F746D"
},
"inputFrozen": true,
"includesNonPencilEditors": false,
"durability": "process-local-operation-record"
}手写会话
保存文档页上的笔迹
把文档阅读器里可见页画布上的笔迹存成快照,连续阅读与翻页模式都支持。
目标要从 POST /writing/context 返回的 state.visiblePages[].continuousCommitTarget
或 pagedCommitTarget 原样返回。取到 null 表示这条路径当前不可用。
连续阅读的目标里页面清单最多 64 页。
与保存焦点画布一样,返回的是受理,结果用 POST /writing/pencil-result 查。
POST
/
writing
/
pencil-document-commit
从上下文获取目标再提交
const ctx = await mn.api('/writing/context', { method: 'POST', body: {} });
const surface = (ctx.surfaces || [])[0];
const target = surface && surface.state
&& surface.state.visiblePages
&& surface.state.visiblePages[0].pagedCommitTarget;
if (!target) { mn.log('这条路径当前不可用'); return; }
await mn.api('/writing/pencil-document-commit', {
method: 'POST',
body: {
surfaceId: surface.surfaceId,
requestId: crypto.randomUUID(),
writer: 'paged',
target,
confirm: true
}
});{
"schemaVersion": 1,
"state": "pending",
"currentness": "at-native-callback-only",
"ready": false,
"surfaceId": "8D01BA73-1CF6-4E6B-BCF1-9378B108C16B",
"bridgeApiVersion": "0.91",
"inputGate": {
"scope": "application-ui-only",
"state": "active",
"programmaticNavigationBlocked": false,
"grantsCallerLease": false
},
"topicid": "449C1665-E0DD-4A20-9E67-2B0D451F746D",
"scope": "document-pencil-snapshot-only",
"requestId": "78E0BE17-6C0A-4C4B-8D48-48AC4E4CE160",
"windowId": "287538A6-9249-4FD6-B026-493466471716",
"receipt": null,
"canSwitch": false,
"target": {
"pageNo": 1,
"storageBookmd5": "ec280b8dbd77594d16b090165fdd4c07ec280b8dbd77594d16b090165fdd4c07",
"storagePage": 1,
"bookmd5": "ec280b8dbd77594d16b090165fdd4c07ec280b8dbd77594d16b090165fdd4c07",
"storageTopicId": "B1F2A354-125A-4384-A271-C0B829AB9E09",
"layerId": "",
"topicid": "449C1665-E0DD-4A20-9E67-2B0D451F746D"
},
"inputFrozen": true,
"includesNonPencilEditors": false,
"durability": "process-local-operation-record"
}请求体
application/json
同 pencil-commit,用 UUID。
连续阅读或翻页。该项不替调用方切换阅读与手写模式。
可用选项:
continuous, paged 从 POST /writing/context 返回的 state.visiblePages[].continuousCommitTarget 或 pagedCommitTarget 原样返回。取到 null 表示这条路径当前不可用。
必填。由 MarginNote 自动补上。
必须是本窗口的文档面。
响应
实测响应。
Show child attributes
Show child attributes
实测为 null。什么情况下返回非空,尚无依据。
Show child attributes
Show child attributes