跳到主要内容

Wiki.macro.finishEdit

Finish macro editing, keep confirmed content and release the collaboration lock. This method does not automatically save the app form.

Requirements​

ONES@ones-open/web-sdk
7.45.0+0.0.20+

Declare and enable a Wiki custom macro. Each method targets the calling entry's macro instance and does not accept another macro's ID. Public sharing, mobile and search do not load the macro runtime and cannot call these methods.

Signature​

interface MacroAPI {
finishEdit(): Promise<void>
}

Parameters​

No parameters. Do not pass form content, callbacks or macro IDs.

Returns and behavior​

Promise<void> resolves after pending saves finish, the session ends and undo records are combined. Wiki then closes the edit entry; the app does not need to close the host dialog.

Call only from the macro's active edit entry. Unsaved form fields are not read. Call saveData first when changes must be saved.

Errors​

Error codeMeaning and triggerRecommended handling
READ_ONLYCalled from the render entry, or the macro is no longer writable, edit permission was lost or login credentials are unavailable.Keep form content and do not report completion early; verify edit state after restoring access.
SESSION_EXPIREDThe edit session is missing, finished or expired, or the editor was destroyed while waiting for collaboration updates.Stop using the old session; reopen the page or macro editor and check what was saved.
REVISION_CONFLICTThe current macro revision differs from the session record, or another operation changed session state.Read current content and review differences instead of repeatedly submitting the old session.
COMMIT_UNKNOWNA previous save or this finish operation is unconfirmed, or the server acknowledged it but the corresponding collaboration revision did not arrive within the wait period. This does not prove finishing failed.Keep current state and retry finishEdit to confirm the original operation; do not switch to cancellation or open another session.
MACRO_UNAVAILABLEThe runtime, macro block, app or a dependency is unavailable, or macro availability authorization failed.Verify page and session state after recovery before continuing.

finishEdit first confirms any pending save. It can therefore also return that save's INVALID_JSON, DATA_TOO_LARGE, INVALID_EXPORT_SPEC, RESOURCE_NOT_ACCESSIBLE or CARD_UPDATE_FAILED; see the saveData error table for their meaning and handling. Call this method only after saveData succeeds.

Catch failures with try / catch; see Catching errors for the error object contract.

Examples​

Install via package manager​

import { Wiki } from '@ones-open/web-sdk'
import type { WikiMacroContent } from '@ones-open/web-sdk'

async function submit(content: WikiMacroContent) {
try {
await Wiki.macro.saveData(content)
await Wiki.macro.finishEdit()
} catch (error) {
console.error(error)
}
}

Use via external script​

<script src="https://unpkg.com/@ones-open/web-sdk@0.0.20/dist/index.iife.js"></script>
<script>
;(async function () {
await window.SDK.Wiki.macro.finishEdit()
})().catch(console.error)
</script>