Skip to content

developer-1px/editable

Repository files navigation

Interactive OS Editable

This repository explores a durable editing boundary:

  • @interactive-os/json-document is the canonical, headless JSON state protocol.
  • @interactive-os/editable owns DOM and Input Events normalization.
  • document semantics live in adapters, with Markdown supplied as a reference candidate rather than root policy.

The stable package root deliberately exposes only mountEditor. Its adapter contract is open to Docs-, Sheet-, Slides-, canvas-, block-, or source-oriented models without putting Markdown text semantics into the host.

The engine owns only the host's contenteditable state and data-editable-owner marker. Each product supplies its own ARIA role, spellcheck, and focus behavior; editor-owned subtrees cannot overlap or nest.

import { mountEditor } from "@interactive-os/editable";
import {
  createMarkdownAdapter,
  createMarkdownDocument,
} from "@interactive-os/editable/markdown";

const document = createMarkdownDocument({
  id: "note",
  source: "# 제목 없는 노트",
});
const adapter = createMarkdownAdapter();
const editor = mountEditor({ root, document, adapter });

The editor snapshot atomically exposes the published JSON value, logical selection, and isComposing. Document edits carry a namespaced transaction ID and logical selectionAfter; external changes are mapped by the adapter. Selection-only changes do not write the document. History is a separate extension concern.

Markdown keeps one /source string canonical. Rich and Live Preview modes are DOM projections of that source. Composition uses a browser-owned island, rebases disjoint external changes, and rejects overlap.

packages/editable/
  index.ts                    stable DOM facade
  browser/contract.ts         stable protocol types
  browser/genericEditor.ts    generic DOM state machine
  markdown/index.ts           reference Markdown adapter

src/note-editor/           app-owned demo
vendor/json-document-v2/  pinned pre-release dependency artifact

The vendored JSON document tarball is pinned because v2 is not yet published; its source commit and SHA-256 are recorded beside the artifact.

Run

pnpm install
pnpm dev

Verify

pnpm exec tsc --noEmit
pnpm run test:package
pnpm run build:package
pnpm run check:editable-layers
pnpm run build
pnpm run verify:browser

Package verification also installs the packed artifact in a clean temporary project. The root-only fixture proves that the Markdown parser is not installed; the Markdown fixture adds its declared optional peer and imports the subpath.

About

editable

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages