{"_id":"@codeninza/rte-core","_rev":"2-dae70b908d54cce2113642d6681a9214","name":"@codeninza/rte-core","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@codeninza/rte-core","version":"0.1.0","license":"MIT","_id":"@codeninza/rte-core@0.1.0","maintainers":[{"name":"codeninza","email":"mkraofx@gmail.com"}],"dist":{"shasum":"9cad056ded679f40626c825b5b3477e4b6052893","tarball":"https://registry.npmjs.org/@codeninza/rte-core/-/rte-core-0.1.0.tgz","fileCount":8,"integrity":"sha512-CV92IAnTD0RhNDqBQ9FQXBanhz4CkDm9ph7kmSfq/+HthkZO+6WFKqSP+9+5Px/UV+HtZwRY1Noq/XJ02c2cnw==","signatures":[{"sig":"MEUCIQDGQWQKaT489Q+HkehjJDFL2zIT1Wi4gd5kf2K9JAdDXQIga4LSAjcV5mufI9WTvH612EiegeLqHcmEmL8dc/MV+Is=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":360319},"main":"./dist/index.cjs","type":"module","_from":"file:codeninza-rte-core-0.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"test":"vitest run","build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"codeninza","email":"mkraofx@gmail.com"},"_resolved":"/private/var/folders/ky/l05z1fy51dbgzz81gdvn6vbr0000gn/T/a9d29fdce4d92df7a3c36785e1d4b259/codeninza-rte-core-0.1.0.tgz","_integrity":"sha512-CV92IAnTD0RhNDqBQ9FQXBanhz4CkDm9ph7kmSfq/+HthkZO+6WFKqSP+9+5Px/UV+HtZwRY1Noq/XJ02c2cnw==","_npmVersion":"11.12.0","description":"Editor core: model, schema, state, view. Zero runtime deps.","directories":{},"sideEffects":false,"_nodeVersion":"24.13.1","dependencies":{"tslib":"*"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"*","vitest":"*","typescript":"*"},"_npmOperationalInternal":{"tmp":"tmp/rte-core_0.1.0_1778268589452_0.37764602627829746","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@codeninza/rte-core","version":"0.1.1","description":"Editor core: model, schema, state, view. Zero runtime deps.","license":"MIT","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"sideEffects":false,"dependencies":{"tslib":"*"},"devDependencies":{"tsup":"*","typescript":"*","vitest":"*"},"scripts":{"build":"tsup","typecheck":"tsc --noEmit","test":"vitest run"},"_id":"@codeninza/rte-core@0.1.1","_integrity":"sha512-yVO8Xdlm0OcpRv43aYx3a+paFSX+6xl+wThWO41uK+PXEguA3WPsrxTf9RqgcHibj9PQX3kjv9/6EiY04vG+fQ==","_resolved":"/private/var/folders/ky/l05z1fy51dbgzz81gdvn6vbr0000gn/T/2c9597eb285247d39efa6b1a245ddde6/codeninza-rte-core-0.1.1.tgz","_from":"file:codeninza-rte-core-0.1.1.tgz","_nodeVersion":"24.13.1","_npmVersion":"11.12.0","dist":{"integrity":"sha512-yVO8Xdlm0OcpRv43aYx3a+paFSX+6xl+wThWO41uK+PXEguA3WPsrxTf9RqgcHibj9PQX3kjv9/6EiY04vG+fQ==","shasum":"a6669981be6c85450572a6925e9ce5d8aca6f833","tarball":"https://registry.npmjs.org/@codeninza/rte-core/-/rte-core-0.1.1.tgz","fileCount":8,"unpackedSize":364207,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIE6y9AtvkIVtAb2Ht97avWqEtQBcytP88KyRfnxI58ZSAiB9CfDfPksTnyc4yDw1oQO/O+H6y6oQxWOMtffQZV59Cg=="}]},"_npmUser":{"name":"codeninza","email":"mkraofx@gmail.com"},"directories":{},"maintainers":[{"name":"codeninza","email":"mkraofx@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rte-core_0.1.1_1778299366590_0.4939513482879092"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-08T19:29:49.384Z","modified":"2026-05-09T04:02:46.875Z","0.1.0":"2026-05-08T19:29:49.595Z","0.1.1":"2026-05-09T04:02:46.746Z"},"license":"MIT","description":"Editor core: model, schema, state, view. Zero runtime deps.","maintainers":[{"name":"codeninza","email":"mkraofx@gmail.com"}],"readme":"# @codeninza/rte-core\n\n> Tiny, model-driven editor engine. Zero runtime dependencies. TypeScript-first.\n\nThe core of [`rich-text-editor-koti`](https://www.npmjs.com/package/rich-text-editor-koti). Provides an immutable document model (ProseMirror-style), a schema, transactions, an editor state, and a DOM view that reconciles the model to a `contenteditable` element. **No marks, no toolbar, no media** — those live in [`@codeninza/rte-basic`](https://www.npmjs.com/package/@codeninza/rte-basic) and [`@codeninza/rte-math`](https://www.npmjs.com/package/@codeninza/rte-math).\n\n## Install\n\n```bash\nnpm install @codeninza/rte-core\n# or\npnpm add @codeninza/rte-core\n# or\nyarn add @codeninza/rte-core\n```\n\n## Quick start\n\n```ts\nimport { Editor, Paragraph } from '@codeninza/rte-core';\n\nconst host = document.getElementById('editor')!;\nconst editor = new Editor(host, {\n  extensions: [Paragraph()],\n});\n\neditor.commands.insertText('Hello, world.');\nconsole.log(editor.toJSON());\n// → { type: 'doc', content: [{ type: 'paragraph', content: [{ type: 'text', text: 'Hello, world.' }] }] }\n\neditor.onChange(() => console.log('doc changed:', editor.toJSON()));\n```\n\nThe host element gets `contenteditable=\"true\"`. Style it however you like; this package ships no CSS.\n\n## What's in the box\n\n### Document model\nImmutable, JSON-serializable nodes and marks.\n\n```ts\nimport { Node, Mark, Fragment, Slice } from '@codeninza/rte-core';\n```\n\n- `Node` — text and element nodes (atomic or with children)\n- `Mark` — inline annotations attached to text (bold, color, link, …)\n- `Fragment` — ordered list of sibling nodes\n- `Slice` — a fragment with optional open depth on each side (for replace ops)\n\n### Schema\n\n```ts\nimport { Schema } from '@codeninza/rte-core';\n\nconst schema = new Schema({\n  nodes: {\n    doc: { content: 'block+' },\n    paragraph: { content: 'inline*', group: 'block', toDOM: () => ['p', 0] },\n    text: { group: 'inline' },\n  },\n  marks: {\n    bold: { toDOM: () => ['strong', 0] },\n  },\n  topNode: 'doc',\n});\n```\n\nContent expressions (`'block+'`, `'inline*'`, `'paragraph heading*'`) are validated against `ContentMatch`. Marks support `inclusive`, `excludes`, and per-attribute defaults.\n\n### Transactions\n\n```ts\nimport { Mark } from '@codeninza/rte-core';\n\nconst tr = editor.currentState.tr;\ntr.insertText(1, 'Hello ');\ntr.addMark(1, 7, new Mark(editor.schema.marks.bold!, {}));\neditor.dispatch(tr);\n```\n\nEach transaction is a chained sequence of `Step`s (`ReplaceStep`, `AddMarkStep`, `RemoveMarkStep`). Steps invert cleanly, which makes history straightforward.\n\n### Editor state and view\n\n`EditorState` holds the doc, selection, and plugin state. `EditorView` renders the doc into a host element and reconciles changes via `Reconciler` (atomic-aware diffing) and `SelectionBridge` (DOM ↔ model selection sync, including text inside marked spans).\n\n### Plugin / extension system\n\n```ts\nimport type { Extension } from '@codeninza/rte-core';\n\nfunction MyMark(): Extension {\n  return {\n    name: 'myMark',\n    marks: [{ name: 'myMark', spec: { toDOM: () => ['em', 0] } }],\n  };\n}\n```\n\nPass to `new Editor(host, { extensions: [MyMark()] })`. Extensions can register nodes, marks, commands, keymaps, and toolbar items.\n\n### i18n\n\n```ts\neditor.locale.register('fi', { 'bold.title': 'Lihavoi' });\neditor.locale.set('fi');\neditor.locale.t('bold.title', 'Bold'); // → \"Lihavoi\"\n```\n\n## Architecture summary\n\n```\n┌──────────────────────────────────────────────┐\n│ EditorState (doc + selection + plugin state) │\n└────────────────────────┬─────────────────────┘\n                         │ dispatch(tr)\n                         ▼\n┌──────────────────────────────────────────────┐\n│ EditorView                                   │\n│  ├─ Reconciler  (atomic-aware DOM diff)      │\n│  ├─ DOMRenderer (model → HTMLElement)        │\n│  └─ SelectionBridge (model ⇄ DOM Range)      │\n└──────────────────────────────────────────────┘\n```\n\n## TypeScript\n\nShips with `.d.ts`. Strictly typed throughout.\n\n## Stability\n\nPre-1.0. The API may change between minor versions. Pin or use ranges accordingly.\n\n## Related packages\n\n| Package | What it adds |\n|---|---|\n| [`@codeninza/rte-basic`](https://www.npmjs.com/package/@codeninza/rte-basic) | Marks (bold, italic, color, highlight), headings, lists, image pipeline, history, toolbar items |\n| [`@codeninza/rte-math`](https://www.npmjs.com/package/@codeninza/rte-math) | KaTeX-rendered inline + block math nodes with edit popover |\n| [`rich-text-editor-koti`](https://www.npmjs.com/package/rich-text-editor-koti) | Drop-in IIFE bundle for `<script>`-tag use |\n\n## License\n\nMIT © Koteshwar Rao Myneni\n","readmeFilename":"README.md"}