CodeSampleX

Ejemplo

@tiptap/extension-underline 3.11.0: configure

Muestra verificada para npm @tiptap/extension-underline 3.11.0: configure. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.

sha256:0c7f76f56dfd3ae179e714b43b33d6b62e9af6a470573054d940368d9b73cffc

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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-17

Caso

HOW
Objetivo
verify @tiptap/extension-underline.configure in pkg:npm/%40tiptap/extension-underline@3.11.0
Paquetes
Símbolos
  • @tiptap/extension-underline.configure
Entorno
node 22.23.2
Creado
2026-09-17T13:16:48Z

Contrato

  1. Underline exports a configure function on the mark extension
  2. Underline.configure() returns an extension instance with default options
  3. Underline.configure() overrides HTMLAttributes in the extension options
  4. Underline.configure() supports chained configuration calls merging options
  5. renderHTML of the configured extension merges configured HTMLAttributes with invocation attributes into a u tag
  6. parseHTML of the configured extension recognizes u tags and text-decoration underline styles

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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/extension-underline.configure in pkg:npm/%40tiptap/extension-underline@3.11.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40tiptap/extension-underline@3.11.0
Demonstrate these symbols/APIs:
  - @tiptap/extension-underline.configure
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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:0895c44ec5e7e322895d52c2e11c37e6ecacde165f3e453b74b70761bfad810d","constraints":{"executionContext":"node"},"contract":["Underline exports a configure function on the mark extension","Underline.configure() returns an extension instance with default options","Underline.configure() overrides HTMLAttributes in the extension options","Underline.configure() supports chained configuration calls merging options","renderHTML of the configured extension merges configured HTMLAttributes with invocation attributes into a u tag","parseHTML of the configured extension recognizes u tags and text-decoration underline styles"],"goal":"verify @tiptap/extension-underline.configure in pkg:npm/%40tiptap/extension-underline@3.11.0","kind":"HOW","packages":["pkg:npm/%40tiptap/extension-underline@3.11.0"],"schemaVersion":1,"symbols":["@tiptap/extension-underline.configure"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","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/extension-underline@3.11.0"],"schemaVersion":1,"subject":"pkg:npm/%40tiptap/extension-underline@3.11.0","symbols":["@tiptap/extension-underline.configure"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-tiptap-extension-underline",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-tiptap-extension-underline",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@tiptap/extension-underline": "3.11.0"
      }
    },
    "node_modules/@tiptap/core": {
      "version": "3.31.3",
      "resolved": "https://registry.npmjs.org/@tiptap/core/-/core-3.31.3.tgz",
      "integrity": "sha512-Cz50pvciQrxdSxgTkHOVz0uD0Yl/8Xt0QatGD6ILm47jW8EzyHR9RkUGs/D5IqzXKuVPntfw1ttaT926vXfiRg==",
      "license": "MIT",
      "peer": true,
      "funding": {
        "type": "github",
        "url": "https://github.com/sponsors/ueberdosis"
      },
      "peerDependencies": {
        "@tiptap/pm": "3.31.3"
      }
    },
    "node_modules/@tiptap/extension-underline": {
      "version": "3.11.0",
      "resolved": "https://registry.npmjs.org/@tiptap/extension-underline/-/extension-underline-3.11.0.tgz",
      "integrity": "sha512-D3PsS/84RlQKFjd5eerMIUioC0mNh4yy1RRV/WbXx6ugu+6T+0hT42gNk9Ap8pDsVQZCk0SHfDyBEUFC2KOwKw==",
      "license": "MIT",
      "funding": {
        "type": "github",
        "url": "https://github.com/sponsors/ueberdosis"
      },
      "peerDependencies": {
        "@tiptap/core": "^3.11.0"
      }
    },
    "node_modules/@tiptap/pm": {
      "version": "3.31.3",
      "resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-3.31.3.tgz",
      "integrity": "sha512-sZime0SWsz/k62W2WvHx5Ig7G2h7kVhrrmnqy+wEgIHfDwEfOlelRjaWCiBCFlF7dxGUntJusCh9FxlLhni0Ag==",
      "license": "MIT",
      "peer": true,
      "dependencies": {
        "prosemirror-changeset": "^2.4.1",
        "prosemirror-commands": "^1.7.1",
        "prosemirror-dropcursor": "^1.8.2",
        "prosemirror-gapcursor": "^1.4.1",
        "prosemirror-history": "^1.5.0",
        "prosemirror-inputrules": "^1.5.1",
        "prosemirror-keymap": "^1.2.3",
        "prosemirror-model": "^1.25.11",
        "prosemirror-schema-list": "^1.5.1",
        "prosemirror-state": "^1.4.4",
        "prosemirror-tables": "^1.8.5",
        "prosemirror-transform": "^1.12.0",
        "prosemirror-view": "^1.42.3"
      },
      "funding": {
        "type": "github",
        "url": "https://github.com/sponsors/ueberdosis"
      }
    },
    "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",
      "peer": true
    },
    "node_modules/prosemirror-changeset": {
      "version": "2.4.3",
      "resolved": "https://registry.npmjs.org/prosemirror-changeset/-/prosemirror-changeset-2.4.3.tgz",
      "integrity": "sha512-J8jqUZ1xybXKY44v3K0c8m8ZTIqJPVT34t2UVyxv4VEWoNd5C9t5Y52GNuMriRJ3IpNxOSE2R60vN4qBrTMcyQ==",
      "license": "MIT",
      "peer": true,
      "dependencies": {
        "prosemirror-transform": "^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",
      "peer": true,
      "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",
      "peer": true,
      "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",
      "peer": true,
      "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",
      "peer": true,
      "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",
      "peer": true,
      "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",
      "peer": true,
      "dependencies": {
        "prosemirror-state": "^1.0.0",
        "w3c-keyname": "^2.2.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",
      "peer": true,
      "dependencies": {
        "orderedmap": "^2.0.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",
      "peer": true,
      "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",
      "peer": true,
      "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",
      "peer": true,
      "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-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",
      "peer": true,
      "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",
      "peer": true,
      "dependencies": {
        "prosemirror-model": "^1.25.8",
        "prosemirror-state": "^1.0.0",
        "prosemirror-transform": "^1.1.0"
      }
    },
    "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",
      "peer": true
    },
    "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",
      "peer": true
    }
  }
}
package.json
{
  "name": "sample-tiptap-extension-underline",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room code sample for @tiptap/extension-underline@3.11.0",
  "main": "src/index.js",
  "license": "MIT-0",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "@tiptap/extension-underline": "3.11.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @tiptap/extension-underline.configure in pkg:npm/%40tiptap/extension-underline@3.11.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40tiptap/extension-underline@3.11.0"
  ],
  "symbols": [
    "@tiptap/extension-underline.configure"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
'use strict';

const { Underline } = require('@tiptap/extension-underline');

/**
 * Creates a configured Underline extension with customized HTML attributes.
 *
 * @param {Record<string, any>} [htmlAttributes={}] - HTML attributes for the underline tag.
 * @returns {object} Configured Underline mark extension instance.
 */
function createConfiguredUnderline(htmlAttributes = {}) {
  return Underline.configure({
    HTMLAttributes: htmlAttributes
  });
}

/**
 * Gets the default options from an Underline extension instance.
 *
 * @returns {object} Default extension options.
 */
function getDefaultUnderlineOptions() {
  const extension = Underline.configure();
  return extension.options;
}

module.exports = {
  Underline,
  createConfiguredUnderline,
  getDefaultUnderlineOptions
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const underlinePkg = require('@tiptap/extension-underline');
const {
  Underline,
  createConfiguredUnderline,
  getDefaultUnderlineOptions
} = require('../src/index.js');

// 1. Underline exports a configure function on the mark extension
assert.equal(typeof Underline, 'object', 'Underline must be an extension object');
assert.equal(typeof underlinePkg.Underline, 'object', 'Package must export Underline object');
assert.equal(typeof Underline.configure, 'function', 'Underline.configure must be a function');
assert.equal(Underline.name, 'underline', 'Extension name must be underline');
assert.equal(Underline.type, 'mark', 'Extension type must be mark');

// 2. Underline.configure() returns an extension instance with default options
const defaultExt = Underline.configure();
assert.equal(typeof defaultExt, 'object', 'Configured result must be an extension object');
assert.equal(defaultExt.name, 'underline', 'Configured extension name must be underline');
assert.equal(defaultExt.type, 'mark', 'Configured extension type must be mark');
assert.deepEqual(defaultExt.options, { HTMLAttributes: {} }, 'Default options must have empty HTMLAttributes');

const helperDefaultOptions = getDefaultUnderlineOptions();
assert.deepEqual(helperDefaultOptions, { HTMLAttributes: {} }, 'Helper must return default options');

// 3. Underline.configure() overrides HTMLAttributes in the extension options
const customExt = Underline.configure({
  HTMLAttributes: {
    class: 'custom-underline',
    'aria-label': 'underlined-text'
  }
});
assert.equal(customExt.name, 'underline', 'Custom extension name must be underline');
assert.equal(customExt.type, 'mark', 'Custom extension type must be mark');
assert.deepEqual(
  customExt.options.HTMLAttributes,
  {
    class: 'custom-underline',
    'aria-label': 'underlined-text'
  },
  'Options must reflect configured HTMLAttributes'
);

const helperCustomExt = createConfiguredUnderline({
  class: 'helper-underline',
  'data-testid': 'custom-mark'
});
assert.deepEqual(
  helperCustomExt.options.HTMLAttributes,
  {
    class: 'helper-underline',
    'data-testid': 'custom-mark'
  },
  'Helper must configure Underline with given attributes'
);

// 4. Underline.configure() supports chained configuration calls merging options
const baseExt = Underline.configure({
  HTMLAttributes: {
    class: 'base-class',
    title: 'tooltip'
  }
});
const chainedExt = baseExt.configure({
  HTMLAttributes: {
    class: 'overridden-class',
    'data-extra': 'added'
  }
});
assert.deepEqual(
  chainedExt.options.HTMLAttributes,
  {
    class: 'overridden-class',
    title: 'tooltip',
    'data-extra': 'added'
  },
  'Chained configure calls must merge HTMLAttributes'
);

// 5. renderHTML of the configured extension merges configured HTMLAttributes with invocation attributes into a u tag
const renderFn = customExt.config.renderHTML;
assert.equal(typeof renderFn, 'function', 'renderHTML must be a function on extension config');

const renderedOutput = renderFn.call(
  { options: customExt.options },
  { HTMLAttributes: { id: 'underline-node-1' } }
);
assert.deepEqual(
  renderedOutput,
  [
    'u',
    {
      class: 'custom-underline',
      'aria-label': 'underlined-text',
      id: 'underline-node-1'
    },
    0
  ],
  'renderHTML must return [tag, mergedAttributes, contentHole]'
);

// 6. parseHTML of the configured extension recognizes u tags and text-decoration underline styles
const parseRules = customExt.config.parseHTML();
assert.ok(Array.isArray(parseRules), 'parseHTML must return an array of parse rules');
assert.equal(parseRules.length, 2, 'parseHTML must return 2 rules');

const tagRule = parseRules.find((rule) => rule.tag === 'u');
assert.ok(tagRule, 'parseHTML must include a rule matching the <u> tag');

const styleRule = parseRules.find((rule) => rule.style === 'text-decoration');
assert.ok(styleRule, 'parseHTML must include a rule matching style text-decoration');
assert.equal(typeof styleRule.getAttrs, 'function', 'style rule must have getAttrs function');
assert.deepEqual(
  styleRule.getAttrs('text-decoration: underline'),
  {},
  'getAttrs must return empty object for underline style'
);
assert.equal(
  styleRule.getAttrs('text-decoration: line-through'),
  false,
  'getAttrs must return false for non-underline style'
);

console.log('All @tiptap/extension-underline.configure contract tests passed successfully.');

Seeder de origen

anónimo