提交后再到结果接口查询
const requestId = crypto.randomUUID();
const ack = await mn.api('/writing/pencil-commit', {
method: 'POST',
body: {
surfaceId, requestId,
target: { topicid, noteid, layerId: '' },
confirm: true
}
});
if (ack.error) { mn.log(ack.error.code); return; }
// 202 只是受理,结果要另查;同一个 requestId,不要换新的
const r = await mn.api('/writing/pencil-result', {
method: 'POST',
body: { requestId }
});
mn.log(r.settled, r.outcome, r.persistedSnapshotVerified, r.snapshotCurrent);
{
"schemaVersion": 1,
"state": "pending",
"currentness": "at-native-callback-only",
"ready": false,
"surfaceId": "C1186BB5-28FF-464A-BF15-D1786839B339",
"bridgeApiVersion": "0.91",
"inputGate": {
"scope": "application-ui-only",
"state": "active",
"programmaticNavigationBlocked": false,
"grantsCallerLease": false
},
"topicid": "449C1665-E0DD-4A20-9E67-2B0D451F746D",
"scope": "focus-pencil-snapshot-only",
"requestId": "4CD53713-A786-481F-A58E-E6543F9FEB55",
"windowId": "287538A6-9249-4FD6-B026-493466471716",
"receipt": null,
"canSwitch": false,
"target": {
"topicid": "449C1665-E0DD-4A20-9E67-2B0D451F746D",
"noteid": "D3085422-2CB9-4B68-A78D-DEE351CF9C38",
"layerId": ""
},
"inputFrozen": true,
"includesNonPencilEditors": false,
"durability": "process-local-operation-record"
}手写会话
保存焦点画布的笔迹
将当前焦点根画布上的笔迹保存为快照。该接口只作用于当前焦点根画布,不写入整份编辑器,也不切换题目。
该接口立即返回受理,state 为 pending。受理不是完成,结果要用 POST /writing/pencil-result
用同一个 requestId 去查。
同一个标识配同一个请求只返回原结果,不会重做;不同的目标共用同一个标识会返回冲突。 每个窗口同时只准有一笔未完成的操作。MarginNote 重启之后这些记录会消失,因此查不到不等于没保存过, 要独立读回确认。
POST
/
writing
/
pencil-commit
提交后再到结果接口查询
const requestId = crypto.randomUUID();
const ack = await mn.api('/writing/pencil-commit', {
method: 'POST',
body: {
surfaceId, requestId,
target: { topicid, noteid, layerId: '' },
confirm: true
}
});
if (ack.error) { mn.log(ack.error.code); return; }
// 202 只是受理,结果要另查;同一个 requestId,不要换新的
const r = await mn.api('/writing/pencil-result', {
method: 'POST',
body: { requestId }
});
mn.log(r.settled, r.outcome, r.persistedSnapshotVerified, r.snapshotCurrent);
{
"schemaVersion": 1,
"state": "pending",
"currentness": "at-native-callback-only",
"ready": false,
"surfaceId": "C1186BB5-28FF-464A-BF15-D1786839B339",
"bridgeApiVersion": "0.91",
"inputGate": {
"scope": "application-ui-only",
"state": "active",
"programmaticNavigationBlocked": false,
"grantsCallerLease": false
},
"topicid": "449C1665-E0DD-4A20-9E67-2B0D451F746D",
"scope": "focus-pencil-snapshot-only",
"requestId": "4CD53713-A786-481F-A58E-E6543F9FEB55",
"windowId": "287538A6-9249-4FD6-B026-493466471716",
"receipt": null,
"canSwitch": false,
"target": {
"topicid": "449C1665-E0DD-4A20-9E67-2B0D451F746D",
"noteid": "D3085422-2CB9-4B68-A78D-DEE351CF9C38",
"layerId": ""
},
"inputFrozen": true,
"includesNonPencilEditors": false,
"durability": "process-local-operation-record"
}请求体
application/json
响应
实测响应。
Show child attributes
Show child attributes
实测为 null。什么情况下返回非空,尚无依据。
Show child attributes
Show child attributes