Delete Document Settings

Summary

The delete method removes a stored value from Document Settings by its key. Deleting a key that does not exist does not raise an error. Values are scoped to the current document.

Purpose

  • Remove document-specific notes or metadata
  • Reset document-level extension state
  • Clean up old or unused document data

Syntax

SigmaSDK.WRITER.storage.document.delete(key)

Parameters

ParameterTypeRequiredDescription
keyStringYesThe key to delete from document storage
Note: Deleting a non-existent key does NOT raise an error. The Promise resolves successfully.

Basic Example

SigmaSDK.WRITER.storage.document.delete("notes")
    .then(function() {
        console.log("Document notes removed");
    });

Delete Multiple Keys

await Promise.all([
    SigmaSDK.WRITER.storage.document.delete("notes"),
    SigmaSDK.WRITER.storage.document.delete("reviewStatus"),
    SigmaSDK.WRITER.storage.document.delete("tags")
]);
console.log("All document settings cleared");

Complete Example

<!DOCTYPE html>
<html>
<head>
    <title>Document Settings Manager</title>
    <script src="https://static.zohocdn.com/sigma/client/sdk/v3/sigma-sdk.min.js"></script>
    <style>
        body { font-family: Arial, sans-serif; padding: 20px; }
        button { padding: 10px 20px; margin: 5px; cursor: pointer; }
        #output { margin-top: 15px; padding: 10px; background: #f9f9f9; }
    </style>
</head>
<body>
    <h1>Document Settings</h1>
    <button onclick="saveData()">Save Sample Data</button>
    <button onclick="clearData()">Clear All Data</button>
    <div id="output"></div>

    <script>
        SigmaSDK.WRITER.init();

        async function saveData() {
            await SigmaSDK.WRITER.storage.document.add({ key: "notes", value: "Sample note" });
            await SigmaSDK.WRITER.storage.document.add({ key: "status", value: "draft" });
            document.getElementById("output").textContent = "Data saved.";
        }

        async function clearData() {
            if (confirm("Clear all document settings?")) {
                await Promise.all([
                    SigmaSDK.WRITER.storage.document.delete("notes"),
                    SigmaSDK.WRITER.storage.document.delete("status")
                ]);
                document.getElementById("output").textContent = "Document settings cleared.";
                SigmaSDK.WRITER.showBannerMessage({ type: "success", message: "Settings cleared." });
            }
        }
    </script>
</body>
</html>

Related Pages