CodeSampleX

サンプル

@tiptap/pm 3.11.0: history

検証済みサンプル — npm @tiptap/pm 3.11.0: history. node 22 · linux debian/x64 · docker で contract を実行し、成功しました: history returns an EditorState plugin configured with…

sha256:1cae9887cb1391518811aafa3a707d7b7a59c8c5857f5f244468d2f12d9b2c55

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

検証実行環境

環境 コントラクト ステージ 実行日
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-15

ケース

HOW
ゴール
verify @tiptap/pm.history in pkg:npm/%40tiptap/pm@3.11.0
パッケージ
シンボル
  • @tiptap/pm.history
環境
node 22.23.2
作成日
2026-09-15T00:59:48Z

コントラクト

  1. history returns an EditorState plugin configured with depth and newGroupDelay options
  2. undoDepth and redoDepth reflect zero on initial editor state
  3. document edit transactions record history events increasing undoDepth and resetting redoDepth
  4. undo reverses the last edit restoring previous document text and decrementing undoDepth
  5. redo reapplies the undone edit restoring document text and decrementing redoDepth
  6. undo and redo commands return false when their respective history stacks are empty
  7. transactions with addToHistory set to false modify document content without creating history events
  8. closeHistory closes the active history event group preventing subsequent edits from merging
  9. isHistoryTransaction returns true for transactions dispatched by undo or redo operations
  10. undoNoScroll and redoNoScroll execute history operations without setting scrolledIntoView flag

ファイル

  • PROMPT.md
  • csx.json
  • index.mjs
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

ソースアーティファクトをダウンロード (tar.gz)

ソース

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify @tiptap/pm.history in pkg:npm/%40tiptap/pm@3.11.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40tiptap/pm@3.11.0
Demonstrate these symbols/APIs:
  - @tiptap/pm.history

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:c4baf086996d5b1fc7749c04b5fce247fecf220ee707ad0b1b3cb0261d0f5792","contract":["history returns an EditorState plugin configured with depth and newGroupDelay options","undoDepth and redoDepth reflect zero on initial editor state","document edit transactions record history events increasing undoDepth and resetting redoDepth","undo reverses the last edit restoring previous document text and decrementing undoDepth","redo reapplies the undone edit restoring document text and decrementing redoDepth","undo and redo commands return false when their respective history stacks are empty","transactions with addToHistory set to false modify document content without creating history events","closeHistory closes the active history event group preventing subsequent edits from merging","isHistoryTransaction returns true for transactions dispatched by undo or redo operations","undoNoScroll and redoNoScroll execute history operations without setting scrolledIntoView flag"],"goal":"verify @tiptap/pm.history in pkg:npm/%40tiptap/pm@3.11.0","kind":"HOW","packages":["pkg:npm/%40tiptap/pm@3.11.0"],"schemaVersion":1,"symbols":["@tiptap/pm.history"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40tiptap/pm@3.11.0"],"schemaVersion":1,"subject":"pkg:npm/%40tiptap/pm@3.11.0","symbols":["@tiptap/pm.history"],"verifierAdapter":"node-typescript@1"}
index.mjs
import {
  history,
  undo,
  redo,
  undoDepth,
  redoDepth,
  undoNoScroll,
  redoNoScroll,
  closeHistory,
  isHistoryTransaction
} from '@tiptap/pm/history';
import { EditorState, Plugin } from '@tiptap/pm/state';
import { schema } from '@tiptap/pm/schema-basic';

export {
  history,
  undo,
  redo,
  undoDepth,
  redoDepth,
  undoNoScroll,
  redoNoScroll,
  closeHistory,
  isHistoryTransaction,
  EditorState,
  Plugin,
  schema
};

export default history;
package-lock.json
{
  "name": "sample-tiptap-pm-history",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-tiptap-pm-history",
      "version": "1.0.0",
      "dependencies": {
        "@tiptap/pm": "3.11.0"
      }
    },
    "node_modules/@remirror/core-constants": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/@remirror/core-constants/-/core-constants-3.0.0.tgz",
      "integrity": "sha512-42aWfPrimMfDKDi4YegyS7x+/0tlzaqwPQCULLanv3DMIlu96KTJR0fM5isWX2UViOqlGnX6YFgqWepcX+XMNg==",
      "license": "MIT"
    },
    "node_modules/@tiptap/pm": {
      "version": "3.11.0",
      "resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-3.11.0.tgz",
      "integrity": "sha512-plCQDLCZIOc92cizB8NNhBRN0szvYR3cx9i5IXo6v9Xsgcun8KHNcJkesc2AyeqdIs0BtOJZaqQ9adHThz8UDw==",
      "license": "MIT",
      "dependencies": {
        "prosemirror-changeset": "^2.3.0",
        "prosemirror-collab": "^1.3.1",
        "prosemirror-commands": "^1.6.2",
        "prosemirror-dropcursor": "^1.8.1",
        "prosemirror-gapcursor": "^1.3.2",
        "prosemirror-history": "^1.4.1",
        "prosemirror-inputrules": "^1.4.0",
        "prosemirror-keymap": "^1.2.2",
        "prosemirror-markdown": "^1.13.1",
        "prosemirror-menu": "^1.2.4",
        "prosemirror-model": "^1.24.1",
        "prosemirror-schema-basic": "^1.2.3",
        "prosemirror-schema-list": "^1.5.0",
        "prosemirror-state": "^1.4.3",
        "prosemirror-tables": "^1.6.4",
        "prosemirror-trailing-node": "^3.0.0",
        "prosemirror-transform": "^1.10.2",
        "prosemirror-view": "^1.38.1"
      },
      "funding": {
        "type": "github",
        "url": "https://github.com/sponsors/ueberdosis"
      }
    },
    "node_modules/@types/linkify-it": {
      "version": "5.0.0",
      "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz",
      "integrity": "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==",
      "license": "MIT"
    },
    "node_modules/@types/markdown-it": {
      "version": "14.2.0",
      "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-14.2.0.tgz",
      "integrity": "sha512-NoQ2yGlLWj4wpxMs+TYmRKk3thDrQ97agr7sFqfLsAlvoS8SNQuTrlObhFqG9iugdTtgOE9jpJ6FNM4ZGsa5xQ==",
      "license": "MIT",
      "dependencies": {
        "@types/linkify-it": "^5",
        "@types/mdurl": "^2"
      }
    },
    "node_modules/@types/mdurl": {
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-2.0.0.tgz",
      "integrity": "sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==",
      "license": "MIT"
    },
    "node_modules/argparse": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
      "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
      "license": "Python-2.0"
    },
    "node_modules/crelt": {
      "version": "1.0.7",
      "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.7.tgz",
      "integrity": "sha512-aK6BbWfhf4U/wCcLHKPJl/xa6VkVstRaPywWtMKGwuOLc/wZTyQYuoxgvZnNsBvv7Kg3YTBQYYBCggcviQczuA==",
      "license": "MIT"
    },
    "node_modules/entities": {
      "version": "4.5.0",
      "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
      "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
      "license": "BSD-2-Clause",
      "engines": {
        "node": ">=0.12"
      },
      "funding": {
        "url": "https://github.com/fb55/entities?sponsor=1"
      }
    },
    "node_modules/escape-string-regexp": {
      "version": "4.0.0",
      "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
      "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
      "license": "MIT",
      "engines": {
        "node": ">=10"
      },
      "funding": {
        "url": "https://github.com/sponsors/sindresorhus"
      }
    },
    "node_modules/linkify-it": {
      "version": "5.0.2",
      "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.2.tgz",
      "integrity": "sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/puzrin"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/markdown-it"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "uc.micro": "^2.0.0"
      }
    },
    "node_modules/markdown-it": {
      "version": "14.3.2",
      "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.3.2.tgz",
      "integrity": "sha512-sHHjZ5fJKlgrG4qns2YwVcdNep35h5fERrfkD2YNsb9UFk0UIHarbiTaHKVMlPuWAoiilyK8Fv/jAm11slsY7Q==",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/puzrin"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/markdown-it"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "argparse": "^2.0.1",
        "entities": "^4.5.0",
        "linkify-it": "^5.0.2",
        "mdurl": "^2.0.0",
        "punycode.js": "^2.3.1",
        "uc.micro": "^2.1.0"
      },
      "bin": {
        "markdown-it": "bin/markdown-it.mjs"
      }
    },
    "node_modules/mdurl": {
      "version": "2.1.0",
      "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.1.0.tgz",
      "integrity": "sha512-1+HBaOx0zi/dQWht8rNv9MYf9qqpqL/kxI0hXImU6Y547zM6Sni8BQibt7ifgMcYtQg41ao3Ivd6cnSM86inpg==",
      "license": "MIT"
    },
    "node_modules/orderedmap": {
      "version": "2.1.1",
      "resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.1.tgz",
      "integrity": "sha512-TvAWxi0nDe1j/rtMcWcIj94+Ffe6n7zhow33h40SKxmsmozs6dz/e+EajymfoFcHd7sxNn8yHM8839uixMOV6g==",
      "license": "MIT"
    },
    "node_modules/prosemirror-changeset": {
      "version": "2.4.2",
      "resolved": "https://registry.npmjs.org/prosemirror-changeset/-/prosemirror-changeset-2.4.2.tgz",
      "integrity": "sha512-ViYrjMSg3YFiXwIhKaluu+/mi3Yrxt6AR8ri14ulTaGcZtXO1CThl7A2gv79qx5fQnOw8woKwyBU2u+9PVCm3w==",
      "license": "MIT",
      "dependencies": {
        "prosemirror-transform": "^1.0.0"
      }
    },
    "node_modules/prosemirror-collab": {
      "version": "1.3.1",
      "resolved": "https://registry.npmjs.org/prosemirror-collab/-/prosemirror-collab-1.3.1.tgz",
      "integrity": "sha512-4SnynYR9TTYaQVXd/ieUvsVV4PDMBzrq2xPUWutHivDuOshZXqQ5rGbZM84HEaXKbLdItse7weMGOUdDVcLKEQ==",
      "license": "MIT",
      "dependencies": {
        "prosemirror-state": "^1.0.0"
      }
    },
    "node_modules/prosemirror-commands": {
      "version": "1.7.2",
      "resolved": "https://registry.npmjs.org/prosemirror-commands/-/prosemirror-commands-1.7.2.tgz",
      "integrity": "sha512-q6Q6szxqdu9Xd6EcdKsqXghu5nQdZTpB4Q9yd04WRc7/jt763e/rT60Owh0L1GYY+T46o5rD+9lEN36dZS43tw==",
      "license": "MIT",
      "dependencies": {
        "prosemirror-model": "^1.0.0",
        "prosemirror-state": "^1.0.0",
        "prosemirror-transform": "^1.10.2"
      }
    },
    "node_modules/prosemirror-dropcursor": {
      "version": "1.8.3",
      "resolved": "https://registry.npmjs.org/prosemirror-dropcursor/-/prosemirror-dropcursor-1.8.3.tgz",
      "integrity": "sha512-FoYbsJR8gK+DGlqhNoE29Loa38eIZPzQRIb1VMaDNBoo4OLP6vVof/jR8qFY/6XvUd6Dhug8MDCHl2a/h8RTfQ==",
      "license": "MIT",
      "dependencies": {
        "prosemirror-state": "^1.0.0",
        "prosemirror-transform": "^1.1.0",
        "prosemirror-view": "^1.1.0"
      }
    },
    "node_modules/prosemirror-gapcursor": {
      "version": "1.4.1",
      "resolved": "https://registry.npmjs.org/prosemirror-gapcursor/-/prosemirror-gapcursor-1.4.1.tgz",
      "integrity": "sha512-pMdYaEnjNMSwl11yjEGtgTmLkR08m/Vl+Jj443167p9eB3HVQKhYCc4gmHVDsLPODfZfjr/MmirsdyZziXbQKw==",
      "license": "MIT",
      "dependencies": {
        "prosemirror-keymap": "^1.0.0",
        "prosemirror-model": "^1.0.0",
        "prosemirror-state": "^1.0.0",
        "prosemirror-view": "^1.0.0"
      }
    },
    "node_modules/prosemirror-history": {
      "version": "1.5.0",
      "resolved": "https://registry.npmjs.org/prosemirror-history/-/prosemirror-history-1.5.0.tgz",
      "integrity": "sha512-zlzTiH01eKA55UAf1MEjtssJeHnGxO0j4K4Dpx+gnmX9n+SHNlDqI2oO1Kv1iPN5B1dm5fsljCfqKF9nFL6HRg==",
      "license": "MIT",
      "dependencies": {
        "prosemirror-state": "^1.2.2",
        "prosemirror-transform": "^1.0.0",
        "prosemirror-view": "^1.31.0",
        "rope-sequence": "^1.3.0"
      }
    },
    "node_modules/prosemirror-inputrules": {
      "version": "1.5.1",
      "resolved": "https://registry.npmjs.org/prosemirror-inputrules/-/prosemirror-inputrules-1.5.1.tgz",
      "integrity": "sha512-7wj4uMjKaXWAQ1CDgxNzNtR9AlsuwzHfdFH1ygEHA2KHF2DOEaXl1CJfNPAKCg9qNEh4rum975QLaCiQPyY6Fw==",
      "license": "MIT",
      "dependencies": {
        "prosemirror-state": "^1.0.0",
        "prosemirror-transform": "^1.0.0"
      }
    },
    "node_modules/prosemirror-keymap": {
      "version": "1.2.3",
      "resolved": "https://registry.npmjs.org/prosemirror-keymap/-/prosemirror-keymap-1.2.3.tgz",
      "integrity": "sha512-4HucRlpiLd1IPQQXNqeo81BGtkY8Ai5smHhKW9jjPKRc2wQIxksg7Hl1tTI2IfT2B/LgX6bfYvXxEpJl7aKYKw==",
      "license": "MIT",
      "dependencies": {
        "prosemirror-state": "^1.0.0",
        "w3c-keyname": "^2.2.0"
      }
    },
    "node_modules/prosemirror-markdown": {
      "version": "1.13.7",
      "resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.13.7.tgz",
      "integrity": "sha512-NV57Oxe3fXR+bNGXS5XW4sKt/XGIyY3n0eHVUoJORcismeF4FFMpLBnl0YESy2BvJQHloexX+9P+zT3VqFj/CQ==",
      "license": "MIT",
      "dependencies": {
        "@types/markdown-it": "^14.0.0",
        "markdown-it": "^14.0.0",
        "prosemirror-model": "^1.25.0"
      }
    },
    "node_modules/prosemirror-menu": {
      "version": "1.3.2",
      "resolved": "https://registry.npmjs.org/prosemirror-menu/-/prosemirror-menu-1.3.2.tgz",
      "integrity": "sha512-6VgUJTYod0nMBlCaYJGhXGLu7Gt4AvcwcOq0YfJCY/6Uh+3S7UsWhpy6rJFCBFOmonq1hD8KyWOtZhkppd4YPg==",
      "license": "MIT",
      "dependencies": {
        "crelt": "^1.0.0",
        "prosemirror-commands": "^1.0.0",
        "prosemirror-history": "^1.0.0",
        "prosemirror-state": "^1.0.0"
      }
    },
    "node_modules/prosemirror-model": {
      "version": "1.25.11",
      "resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.25.11.tgz",
      "integrity": "sha512-QWg9RhnpLlogAmp3p96uEFrE5txQpFynd4vhBAELkwgOCWQs/X0yCzB3/hrHqiPwf91RG5KyWq6553zs9JqIOQ==",
      "license": "MIT",
      "dependencies": {
        "orderedmap": "^2.0.0"
      }
    },
    "node_modules/prosemirror-schema-basic": {
      "version": "1.2.4",
      "resolved": "https://registry.npmjs.org/prosemirror-schema-basic/-/prosemirror-schema-basic-1.2.4.tgz",
      "integrity": "sha512-ELxP4TlX3yr2v5rM7Sb70SqStq5NvI15c0j9j/gjsrO5vaw+fnnpovCLEGIcpeGfifkuqJwl4fon6b+KdrODYQ==",
      "license": "MIT",
      "dependencies": {
        "prosemirror-model": "^1.25.0"
      }
    },
    "node_modules/prosemirror-schema-list": {
      "version": "1.5.1",
      "resolved": "https://registry.npmjs.org/prosemirror-schema-list/-/prosemirror-schema-list-1.5.1.tgz",
      "integrity": "sha512-927lFx/uwyQaGwJxLWCZRkjXG0p48KpMj6ueoYiu4JX05GGuGcgzAy62dfiV8eFZftgyBUvLx76RsMe20fJl+Q==",
      "license": "MIT",
      "dependencies": {
        "prosemirror-model": "^1.0.0",
        "prosemirror-state": "^1.0.0",
        "prosemirror-transform": "^1.7.3"
      }
    },
    "node_modules/prosemirror-state": {
      "version": "1.4.4",
      "resolved": "https://registry.npmjs.org/prosemirror-state/-/prosemirror-state-1.4.4.tgz",
      "integrity": "sha512-6jiYHH2CIGbCfnxdHbXZ12gySFY/fz/ulZE333G6bPqIZ4F+TXo9ifiR86nAHpWnfoNjOb3o5ESi7J8Uz1jXHw==",
      "license": "MIT",
      "dependencies": {
        "prosemirror-model": "^1.0.0",
        "prosemirror-transform": "^1.0.0",
        "prosemirror-view": "^1.27.0"
      }
    },
    "node_modules/prosemirror-tables": {
      "version": "1.8.5",
      "resolved": "https://registry.npmjs.org/prosemirror-tables/-/prosemirror-tables-1.8.5.tgz",
      "integrity": "sha512-V/0cDCsHKHe/tfWkeCmthNUcEp1IVO3p6vwN8XtwE9PZQLAZJigbw3QoraAdfJPir4NKJtNvOB8oYGKRl+t0Dw==",
      "license": "MIT",
      "dependencies": {
        "prosemirror-keymap": "^1.2.3",
        "prosemirror-model": "^1.25.4",
        "prosemirror-state": "^1.4.4",
        "prosemirror-transform": "^1.10.5",
        "prosemirror-view": "^1.41.4"
      }
    },
    "node_modules/prosemirror-trailing-node": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/prosemirror-trailing-node/-/prosemirror-trailing-node-3.0.0.tgz",
      "integrity": "sha512-xiun5/3q0w5eRnGYfNlW1uU9W6x5MoFKWwq/0TIRgt09lv7Hcser2QYV8t4muXbEr+Fwo0geYn79Xs4GKywrRQ==",
      "license": "MIT",
      "dependencies": {
        "@remirror/core-constants": "3.0.0",
        "escape-string-regexp": "^4.0.0"
      },
      "peerDependencies": {
        "prosemirror-model": "^1.22.1",
        "prosemirror-state": "^1.4.2",
        "prosemirror-view": "^1.33.8"
      }
    },
    "node_modules/prosemirror-transform": {
      "version": "1.12.1",
      "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.12.1.tgz",
      "integrity": "sha512-t4F5615FycnCqsX7ShTUs8+jfnwcf46kuFRvSl/3qFx2QTZ4DjgowesLHQXcFP7G//TjesqZG3WtgL7vdyVJyA==",
      "license": "MIT",
      "dependencies": {
        "prosemirror-model": "^1.21.0"
      }
    },
    "node_modules/prosemirror-view": {
      "version": "1.42.3",
      "resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.42.3.tgz",
      "integrity": "sha512-oTN7EtH+CpwxU9NrwEYWd0UZ4JUx7l048l5A2Xppm4p/60isZYLnth9QVQmC3VRIvdrIWCxwZSd+Uz791G31/w==",
      "license": "MIT",
      "dependencies": {
        "prosemirror-model": "^1.25.8",
        "prosemirror-state": "^1.0.0",
        "prosemirror-transform": "^1.1.0"
      }
    },
    "node_modules/punycode.js": {
      "version": "2.3.1",
      "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz",
      "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==",
      "license": "MIT",
      "engines": {
        "node": ">=6"
      }
    },
    "node_modules/rope-sequence": {
      "version": "1.3.4",
      "resolved": "https://registry.npmjs.org/rope-sequence/-/rope-sequence-1.3.4.tgz",
      "integrity": "sha512-UT5EDe2cu2E/6O4igUr5PSFs23nvvukicWHx6GnOPlHAiiYbzNuCRQCuiUdHJQcqKalLKlrYJnjY0ySGsXNQXQ==",
      "license": "MIT"
    },
    "node_modules/uc.micro": {
      "version": "2.1.0",
      "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz",
      "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==",
      "license": "MIT"
    },
    "node_modules/w3c-keyname": {
      "version": "2.2.8",
      "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
      "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-tiptap-pm-history",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "@tiptap/pm": "3.11.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @tiptap/pm.history in pkg:npm/%40tiptap/pm@3.11.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40tiptap/pm@3.11.0"
  ],
  "symbols": [
    "@tiptap/pm.history"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import {
  history,
  undo,
  redo,
  undoDepth,
  redoDepth,
  undoNoScroll,
  redoNoScroll,
  closeHistory,
  isHistoryTransaction,
  EditorState,
  Plugin,
  schema
} from '../index.mjs';

// 1. history returns an EditorState plugin configured with depth and newGroupDelay options
{
  const plugin = history({ depth: 50, newGroupDelay: 300 });
  assert.ok(plugin instanceof Plugin, 'history must return a Plugin instance');
  const state = EditorState.create({ schema, plugins: [plugin] });
  assert.ok(state instanceof EditorState, 'EditorState must initialize with history plugin');
}

// 2. undoDepth and redoDepth reflect zero on initial editor state
{
  const state = EditorState.create({ schema, plugins: [history()] });
  assert.equal(undoDepth(state), 0, 'initial undoDepth must be 0');
  assert.equal(redoDepth(state), 0, 'initial redoDepth must be 0');
}

// 3. document edit transactions record history events increasing undoDepth and resetting redoDepth
{
  let state = EditorState.create({ schema, plugins: [history()] });
  const tr = state.tr.insertText('Alpha ');
  state = state.apply(tr);
  assert.equal(state.doc.textContent, 'Alpha ');
  assert.equal(undoDepth(state), 1, 'undoDepth must increment on document edit');
  assert.equal(redoDepth(state), 0, 'redoDepth must be 0 after new edit');
}

// 4. undo reverses the last edit restoring previous document text and decrementing undoDepth
{
  let state = EditorState.create({ schema, plugins: [history()] });
  state = state.apply(state.tr.insertText('Alpha '));

  let dispatchedTr = null;
  const undoSuccess = undo(state, (tr) => {
    dispatchedTr = tr;
    state = state.apply(tr);
  });
  assert.equal(undoSuccess, true, 'undo must return true when events exist');
  assert.ok(dispatchedTr != null, 'undo must provide a dispatch transaction');
  assert.equal(state.doc.textContent, '', 'document content must be empty after undo');
  assert.equal(undoDepth(state), 0, 'undoDepth must be 0 after undoing sole event');
  assert.equal(redoDepth(state), 1, 'redoDepth must be 1 after undo');
}

// 5. redo reapplies the undone edit restoring document text and decrementing redoDepth
{
  let state = EditorState.create({ schema, plugins: [history()] });
  state = state.apply(state.tr.insertText('Alpha '));
  undo(state, (tr) => { state = state.apply(tr); });

  let dispatchedTr = null;
  const redoSuccess = redo(state, (tr) => {
    dispatchedTr = tr;
    state = state.apply(tr);
  });
  assert.equal(redoSuccess, true, 'redo must return true when redoable events exist');
  assert.ok(dispatchedTr != null, 'redo must provide a dispatch transaction');
  assert.equal(state.doc.textContent, 'Alpha ', 'document text must be restored after redo');
  assert.equal(undoDepth(state), 1, 'undoDepth must increment back to 1');
  assert.equal(redoDepth(state), 0, 'redoDepth must decrement back to 0');
}

// 6. undo and redo commands return false when their respective history stacks are empty
{
  const state = EditorState.create({ schema, plugins: [history()] });
  assert.equal(undo(state), false, 'undo must return false when undoDepth is 0');
  assert.equal(redo(state), false, 'redo must return false when redoDepth is 0');
}

// 7. transactions with addToHistory set to false modify document content without creating history events
{
  let state = EditorState.create({ schema, plugins: [history()] });
  state = state.apply(state.tr.insertText('Recorded'));
  assert.equal(undoDepth(state), 1);

  const unrecordedTr = state.tr.insertText(' Unrecorded');
  unrecordedTr.setMeta('addToHistory', false);
  state = state.apply(unrecordedTr);

  assert.equal(state.doc.textContent, 'Recorded Unrecorded');
  assert.equal(undoDepth(state), 1, 'undoDepth must not increase when addToHistory is false');
}

// 8. closeHistory closes the active history event group preventing subsequent edits from merging
{
  let state = EditorState.create({ schema, plugins: [history()] });
  state = state.apply(state.tr.insertText('First '));
  state = state.apply(closeHistory(state.tr));

  state = state.apply(state.tr.insertText('Second'));
  assert.equal(state.doc.textContent, 'First Second');
  assert.equal(undoDepth(state), 2, 'closeHistory must cause second edit to start new event');

  undo(state, (tr) => { state = state.apply(tr); });
  assert.equal(state.doc.textContent, 'First ', 'first undo must only revert Second');

  undo(state, (tr) => { state = state.apply(tr); });
  assert.equal(state.doc.textContent, '', 'second undo must revert First');
}

// 9. isHistoryTransaction returns true for transactions dispatched by undo or redo operations
{
  let state = EditorState.create({ schema, plugins: [history()] });
  state = state.apply(state.tr.insertText('History test'));

  let undoTr = null;
  undo(state, (tr) => {
    undoTr = tr;
    state = state.apply(tr);
  });
  assert.equal(isHistoryTransaction(undoTr), true, 'undo transaction must be recognized');

  let redoTr = null;
  redo(state, (tr) => {
    redoTr = tr;
    state = state.apply(tr);
  });
  assert.equal(isHistoryTransaction(redoTr), true, 'redo transaction must be recognized');

  const regularTr = state.tr.insertText('!');
  assert.equal(isHistoryTransaction(regularTr), false, 'regular transaction must not be history transaction');
}

// 10. undoNoScroll and redoNoScroll execute history operations without setting scrolledIntoView flag
{
  let state = EditorState.create({ schema, plugins: [history()] });
  state = state.apply(state.tr.insertText('NoScroll'));

  let undoTr = null;
  const undoResult = undoNoScroll(state, (tr) => {
    undoTr = tr;
    state = state.apply(tr);
  });
  assert.equal(undoResult, true);
  assert.equal(state.doc.textContent, '');
  assert.equal(undoTr.scrolledIntoView, false, 'undoNoScroll must not set scrolledIntoView');

  let redoTr = null;
  const redoResult = redoNoScroll(state, (tr) => {
    redoTr = tr;
    state = state.apply(tr);
  });
  assert.equal(redoResult, true);
  assert.equal(state.doc.textContent, 'NoScroll');
  assert.equal(redoTr.scrolledIntoView, false, 'redoNoScroll must not set scrolledIntoView');
}

console.log('All @tiptap/pm.history contract tests passed successfully.');

オリジンシーダー

匿名