CodeSampleX

Beispiel

@tiptap/extension-image 3.11.0: Image

Verifiziertes Beispiel für npm @tiptap/extension-image 3.11.0: Image. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.

sha256:ebbda2515c96a84dcf2e1775e2b95364522e4ba3e2a1a38867f2f293144f54c9

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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-11

Fall

HOW
Ziel
verify pkg:npm/%40tiptap/extension-image@3.11.0
Pakete
Symbole
  • Image
Erstellt
2026-09-11T16:01:47Z

Contract

  1. assert importing @tiptap/extension-image provides Image node extension matching default export
  2. assert Image extension configures node type name as 'image' with block grouping and draggable enabled
  3. assert default Image options disable inline, base64, and resize
  4. assert Image.configure customizes inline mode, allowBase64 flag, and HTMLAttributes
  5. assert Image schema defines standard attributes src, alt, title, width, and height defaulting to null
  6. assert parseHTML selects img elements excluding data URIs by default and including them when allowBase64 is enabled
  7. assert renderHTML outputs img tag merging extension-level and node-level HTML attributes
  8. assert renderMarkdown generates standard markdown image syntax with or without title attribute
  9. assert parseMarkdown produces image node with src, alt, and title from token
  10. assert setImage command dispatches insertContent with image node type and attributes
  11. assert inputRegex matches standard markdown image syntax

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

NOTES.md
# Notes: TipTap Image Extension Verification

## Search Result
`search_known_solution` returned `NO_SAFE_MATCH` for `pkg:npm/%40tiptap/extension-image@3.11.0`. No verified public sample existed in the network for this extension. This sample demonstrates the exact module exports, schema definitions, options configuration, markdown parsing/rendering, and command insertion contracts.

## Naive Model Assumption
A developer or coding model assumes that `@tiptap/extension-image` can be used standalone without resolving peer dependencies `@tiptap/core` and `@tiptap/pm`, leading to TS2307 module resolution errors. Additionally, models often assume that `Image` is an inline node by default, that HTML parsing permits base64 data URIs without explicit configuration, or that `setImage` accepts arbitrary node structures instead of passing options directly to `insertContent`.

## Exact Behavior & Failure Mode
1. **Module Exports**: In the built distribution (`dist/index.js`), `Image` is exported as both a named export and default export, along with `inputRegex`.
2. **Peer Dependencies**: `@tiptap/extension-image` requires `@tiptap/core` and `@tiptap/pm`. Failing to declare them causes TS2307 missing module errors.
3. **Node Definition & Grouping**: By default, `Image` is a block-level node (`inline: false`, `group: 'block'`, `draggable: true`). When configured with `inline: true`, its `group` dynamically resolves to `'inline'`.
4. **HTML Parsing**: Default `parseHTML` specifies `'img[src]:not([src^="data:"])'` to exclude base64 data URIs. Setting `allowBase64: true` expands the selector to `'img[src]'`.
5. **Attributes**: Default schema attributes are `src`, `alt`, `title`, `width`, and `height`, each defaulting to `null`.
6. **Commands & Markdown**: The `setImage` command dispatches `insertContent` with `{ type: 'image', attrs }`. `renderMarkdown` formats markdown images as `![alt](src "title")` or `![alt](src)`.
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 pkg:npm/%40tiptap/extension-image@3.11.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40tiptap/extension-image@3.11.0
Demonstrate these symbols/APIs:
  - Image

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:2c2ff5f702fbfaa07dbbf0d3fa75a2b870562882a663d85f5e407b59e5cfda5a","contract":["assert importing @tiptap/extension-image provides Image node extension matching default export","assert Image extension configures node type name as 'image' with block grouping and draggable enabled","assert default Image options disable inline, base64, and resize","assert Image.configure customizes inline mode, allowBase64 flag, and HTMLAttributes","assert Image schema defines standard attributes src, alt, title, width, and height defaulting to null","assert parseHTML selects img elements excluding data URIs by default and including them when allowBase64 is enabled","assert renderHTML outputs img tag merging extension-level and node-level HTML attributes","assert renderMarkdown generates standard markdown image syntax with or without title attribute","assert parseMarkdown produces image node with src, alt, and title from token","assert setImage command dispatches insertContent with image node type and attributes","assert inputRegex matches standard markdown image syntax"],"goal":"verify pkg:npm/%40tiptap/extension-image@3.11.0","kind":"HOW","packages":["pkg:npm/%40tiptap/extension-image@3.11.0"],"schemaVersion":1,"symbols":["Image"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40tiptap/extension-image@3.11.0"],"schemaVersion":1,"subject":"pkg:npm/%40tiptap/extension-image@3.11.0","symbols":["Image"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "tiptap-extension-image-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "tiptap-extension-image-sample",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@tiptap/core": "3.11.0",
        "@tiptap/extension-image": "3.11.0",
        "@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/core": {
      "version": "3.11.0",
      "resolved": "https://registry.npmjs.org/@tiptap/core/-/core-3.11.0.tgz",
      "integrity": "sha512-kmS7ZVpHm1EMnW1Wmft9H5ZLM7E0G0NGBx+aGEHGDcNxZBXD2ZUa76CuWjIhOGpwsPbELp684ZdpF2JWoNi4Dg==",
      "license": "MIT",
      "funding": {
        "type": "github",
        "url": "https://github.com/sponsors/ueberdosis"
      },
      "peerDependencies": {
        "@tiptap/pm": "^3.11.0"
      }
    },
    "node_modules/@tiptap/extension-image": {
      "version": "3.11.0",
      "resolved": "https://registry.npmjs.org/@tiptap/extension-image/-/extension-image-3.11.0.tgz",
      "integrity": "sha512-AFH1kn5Cpe5D89fP4MKN98N8pwmB3s4Rn8jq6rk3QVaAwdrxwxbAqUI1sX7UPFzaq9eNcHgmGLaDL+UTspSW8g==",
      "license": "MIT",
      "funding": {
        "type": "github",
        "url": "https://github.com/sponsors/ueberdosis"
      },
      "peerDependencies": {
        "@tiptap/core": "^3.11.0"
      }
    },
    "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.1",
      "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.3.1.tgz",
      "integrity": "sha512-4Ej49aYTDFIQ+uBkfX8GBvJGccoARxxPep+7aWTs55ozbjQJpW9M26Fe53vnGgvLeVzva/amzjQQaQu9w0vMhA==",
      "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": "tiptap-extension-image-sample",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "@tiptap/core": "3.11.0",
    "@tiptap/extension-image": "3.11.0",
    "@tiptap/pm": "3.11.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40tiptap/extension-image@3.11.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40tiptap/extension-image@3.11.0"
  ],
  "symbols": [
    "Image"
  ]
}
test/contract.mjs
import { strict as assert } from 'node:assert';
import { Image, default as DefaultImage, inputRegex } from '@tiptap/extension-image';

const TEST_IMAGE_URL = 'https://example.com/images/sample.png';

async function runContract() {
  // ---------------------------------------------------------------------------
  // Contract Assertion 1:
  // Importing @tiptap/extension-image provides Image node extension matching
  // default export.
  // ---------------------------------------------------------------------------
  assert.strictEqual(
    Image,
    DefaultImage,
    'named export Image must be identical to default export'
  );
  assert.strictEqual(
    Image.name,
    'image',
    'Image extension name must be "image"'
  );
  assert.strictEqual(
    Image.type,
    'node',
    'Image extension type must be "node"'
  );

  // ---------------------------------------------------------------------------
  // Contract Assertion 2:
  // Image extension configures node type name as 'image' with block grouping and
  // draggable enabled.
  // ---------------------------------------------------------------------------
  assert.strictEqual(
    Image.config.draggable,
    true,
    'Image extension draggable must be true'
  );
  assert.strictEqual(
    Image.config.inline.call(Image),
    false,
    'Image extension must not be inline by default'
  );
  assert.strictEqual(
    Image.config.group.call(Image),
    'block',
    'Image extension group must be "block" by default'
  );

  // ---------------------------------------------------------------------------
  // Contract Assertion 3:
  // Default Image options disable inline, base64, and resize.
  // ---------------------------------------------------------------------------
  const defaultOpts = Image.options;
  assert.strictEqual(defaultOpts.inline, false, 'inline option must be false by default');
  assert.strictEqual(defaultOpts.allowBase64, false, 'allowBase64 option must be false by default');
  assert.strictEqual(defaultOpts.resize, false, 'resize option must be false by default');
  assert.deepStrictEqual(defaultOpts.HTMLAttributes, {}, 'HTMLAttributes must be empty object by default');

  // ---------------------------------------------------------------------------
  // Contract Assertion 4:
  // Image.configure customizes inline mode, allowBase64 flag, and HTMLAttributes.
  // ---------------------------------------------------------------------------
  const configured = Image.configure({
    inline: true,
    allowBase64: true,
    HTMLAttributes: { class: 'custom-image', loading: 'lazy' },
  });
  assert.strictEqual(configured.options.inline, true, 'configured inline must be true');
  assert.strictEqual(configured.config.inline.call(configured), true, 'configured inline getter must return true');
  assert.strictEqual(configured.config.group.call(configured), 'inline', 'configured group must be "inline"');
  assert.strictEqual(configured.options.allowBase64, true, 'configured allowBase64 must be true');
  assert.strictEqual(configured.options.HTMLAttributes.class, 'custom-image', 'configured class must be set');
  assert.strictEqual(configured.options.HTMLAttributes.loading, 'lazy', 'configured loading must be set');

  // ---------------------------------------------------------------------------
  // Contract Assertion 5:
  // Image schema defines standard attributes src, alt, title, width, and height
  // defaulting to null.
  // ---------------------------------------------------------------------------
  const attributes = Image.config.addAttributes.call(Image);
  const expectedAttrs = ['src', 'alt', 'title', 'width', 'height'];
  assert.deepStrictEqual(
    Object.keys(attributes).sort(),
    expectedAttrs.sort(),
    'Image attributes must define src, alt, title, width, and height'
  );
  for (const attr of expectedAttrs) {
    assert.strictEqual(
      attributes[attr].default,
      null,
      `Attribute ${attr} default must be null`
    );
  }

  // ---------------------------------------------------------------------------
  // Contract Assertion 6:
  // parseHTML selects img elements excluding data URIs by default and including
  // them when allowBase64 is enabled.
  // ---------------------------------------------------------------------------
  const parseDefault = Image.config.parseHTML.call(Image);
  assert.deepStrictEqual(
    parseDefault,
    [{ tag: 'img[src]:not([src^="data:"])' }],
    'default parseHTML must exclude data: URIs'
  );

  const parseBase64 = configured.config.parseHTML.call(configured);
  assert.deepStrictEqual(
    parseBase64,
    [{ tag: 'img[src]' }],
    'parseHTML with allowBase64 enabled must match any img[src]'
  );

  // ---------------------------------------------------------------------------
  // Contract Assertion 7:
  // renderHTML outputs img tag merging extension-level and node-level HTML
  // attributes.
  // ---------------------------------------------------------------------------
  const defaultRender = Image.config.renderHTML.call(Image, {
    HTMLAttributes: { src: TEST_IMAGE_URL, alt: 'Sample' },
  });
  assert.strictEqual(defaultRender[0], 'img', 'rendered tag name must be img');
  assert.deepStrictEqual(
    defaultRender[1],
    { src: TEST_IMAGE_URL, alt: 'Sample' },
    'rendered attributes must include node HTMLAttributes'
  );

  const configuredRender = configured.config.renderHTML.call(configured, {
    HTMLAttributes: { src: TEST_IMAGE_URL, alt: 'Sample' },
  });
  assert.strictEqual(configuredRender[0], 'img', 'rendered tag name must be img');
  assert.deepStrictEqual(
    configuredRender[1],
    { class: 'custom-image', loading: 'lazy', src: TEST_IMAGE_URL, alt: 'Sample' },
    'rendered attributes must merge configured extension attributes with node attributes'
  );

  // ---------------------------------------------------------------------------
  // Contract Assertion 8:
  // renderMarkdown generates standard markdown image syntax with or without title
  // attribute.
  // ---------------------------------------------------------------------------
  const mdWithTitle = Image.config.renderMarkdown({
    attrs: { src: TEST_IMAGE_URL, alt: 'Banner', title: 'Header image' },
  });
  assert.strictEqual(
    mdWithTitle,
    `![Banner](${TEST_IMAGE_URL} "Header image")`,
    'renderMarkdown must format image with title'
  );

  const mdWithoutTitle = Image.config.renderMarkdown({
    attrs: { src: TEST_IMAGE_URL, alt: 'Banner', title: null },
  });
  assert.strictEqual(
    mdWithoutTitle,
    `![Banner](${TEST_IMAGE_URL})`,
    'renderMarkdown must format image without title when title is absent'
  );

  // ---------------------------------------------------------------------------
  // Contract Assertion 9:
  // parseMarkdown produces image node with src, alt, and title from token.
  // ---------------------------------------------------------------------------
  const mockToken = {
    href: TEST_IMAGE_URL,
    title: 'Photo Title',
    text: 'Photo Alt',
  };
  const mockHelpers = {
    createNode: (type, attrs) => ({ type, attrs }),
  };
  const parsedNode = Image.config.parseMarkdown(mockToken, mockHelpers);
  assert.deepStrictEqual(
    parsedNode,
    {
      type: 'image',
      attrs: {
        src: TEST_IMAGE_URL,
        title: 'Photo Title',
        alt: 'Photo Alt',
      },
    },
    'parseMarkdown must construct image node with token href, title, and alt'
  );

  // ---------------------------------------------------------------------------
  // Contract Assertion 10:
  // setImage command dispatches insertContent with image node type and
  // attributes.
  // ---------------------------------------------------------------------------
  const commands = Image.config.addCommands.call(Image);
  assert.strictEqual(typeof commands.setImage, 'function', 'setImage command must be a function');

  let insertedContent = null;
  const mockEditorContext = {
    commands: {
      insertContent: (content) => {
        insertedContent = content;
        return true;
      },
    },
  };

  const commandResult = commands.setImage({
    src: TEST_IMAGE_URL,
    alt: 'Hero image',
    title: 'Hero',
  })(mockEditorContext);

  assert.strictEqual(commandResult, true, 'setImage command must return true');
  assert.deepStrictEqual(
    insertedContent,
    {
      type: 'image',
      attrs: {
        src: TEST_IMAGE_URL,
        alt: 'Hero image',
        title: 'Hero',
      },
    },
    'setImage must pass image node type and attributes to insertContent'
  );

  // ---------------------------------------------------------------------------
  // Contract Assertion 11:
  // inputRegex matches standard markdown image syntax.
  // ---------------------------------------------------------------------------
  assert.ok(inputRegex instanceof RegExp, 'inputRegex must be a RegExp instance');
  const markdownImgString = `![Alt text](${TEST_IMAGE_URL} "Title")`;
  const matchResult = markdownImgString.match(inputRegex);
  assert.ok(matchResult !== null, 'inputRegex must match markdown image syntax');
  assert.strictEqual(matchResult[2], 'Alt text', 'match group 2 must capture alt text');
  assert.strictEqual(matchResult[3], TEST_IMAGE_URL, 'match group 3 must capture src');
  assert.strictEqual(matchResult[4], 'Title', 'match group 4 must capture title');

  console.log('All contract assertions passed successfully.');
}

runContract().catch((err) => {
  console.error('Contract failed:', err);
  process.exit(1);
});

Ursprungs-Seeder

anonym