Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# json-document

json-document는 Zod schema가 있는 JSON 문서를 편집하기 위한 headless document
engine입니다.
json-document는 문서, 표, 슬라이드, 캔버스, 노트 편집기가 함께 쓸 수 있는
provider-neutral JSON 편집 protocol과 headless document projection입니다.

폼, CMS block, kanban board, outliner, settings editor처럼 UI가 다른 편집 툴도
결국 schema가 있는 JSON document를 읽고, 바꾸고, 선택하고, 복사하고,
붙여넣고, 되돌립니다. json-document는 이 공통 document engine을 UI 밖에 둡니다.
v2 root는 JSON, JSON Pointer, JSONPath, JSON Patch만 전제로 하며 Zod, React,
selection, clipboard, history를 필수 계약에 넣지 않습니다.

```txt
schema -> document -> pointer/query -> can* -> change -> result
Pure Protocol
|-> Document Projection -> host adapter
`-> Candidate Editing Session -> React / rich host adapter
```

공식 사이트: https://developer-1px.github.io/json-document/
Expand All @@ -24,17 +25,15 @@ schema -> document -> pointer/query -> can* -> change -> result
| 제품별 feature 지도 | [docs/public/recipes.md](docs/public/recipes.md) |
| 문서 구조 | [docs/README.md](docs/README.md) |
| 변경 기록 | [docs/changelog.md](docs/changelog.md) |
| core 의미론 명세 | [docs/standard/json-document-spec.md](docs/standard/json-document-spec.md) |
| 1.0 conformance profile | [docs/standard/conformance-profile.md](docs/standard/conformance-profile.md) |
| result/error 계약 | [docs/standard/result-contract.md](docs/standard/result-contract.md) |
| selection 계약 | [docs/standard/selection-contract.md](docs/standard/selection-contract.md) |
| schema introspection 계약 | [docs/standard/schema-introspection-contract.md](docs/standard/schema-introspection-contract.md) |
| v2 Projection 표준 | [docs/standard/v2-projection-profile.md](docs/standard/v2-projection-profile.md) |
| v2 공개 표면 manifest | [docs/standard/v2-public-surface.json](docs/standard/v2-public-surface.json) |
| Candidate Session의 1.x 기준선 | [docs/standard/conformance-profile.md](docs/standard/conformance-profile.md) |

## 코드 지도

| 위치 | 역할 |
| --- | --- |
| [packages/json-document](packages/json-document) | core package. `createJSONDocument`, JSON Patch/Pointer/Path, selection, clipboard, history |
| [packages/json-document](packages/json-document) | v2 Kernel과 optional Candidate Session |
| [packages/collection](packages/collection) | ordered JSON array item 이동/복제/삭제 |
| [packages/clipboard-web](packages/clipboard-web) | browser clipboard bridge |
| [packages/contenteditable-web](packages/contenteditable-web) | `@interactive-os/json-document-contenteditable-web` DOM contenteditable text-surface adapter |
Expand All @@ -61,13 +60,16 @@ schema -> document -> pointer/query -> can* -> change -> result

## 경계

json-document가 제공하는 document engine:
v2 Kernel이 제공하는 최소 계약:

- Zod schema로 검증되는 JSON document state
- JSON Pointer 주소, JSON Patch mutation, JSONPath search
- `can*` capability result
- headless selection, clipboard payload, undo/redo history
- 반복 편집 개념을 조립하는 작은 extension 함수
- immutable JSON snapshot
- JSON Pointer read와 JSONPath query
- state를 바꾸지 않는 `canPatch`
- ordered atomic JSON Patch commit
- canonical applied change publication

`@interactive-os/json-document/session`은 Zod 기반 schema 검증, selection,
clipboard, history와 고수준 편집 동사를 제공하는 optional Candidate 표면입니다.

편집 툴이 계속 소유하는 것:

Expand Down
2 changes: 1 addition & 1 deletion apps/grouping-lab/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo, useState } from "react";
import { createGrouping, type GroupingAdapter, type GroupingChangeResult } from "@interactive-os/json-document-grouping";
import type { Pointer } from "@interactive-os/json-document";
import type { Pointer } from "@interactive-os/json-document/session";
import { useJSONDocument } from "@interactive-os/json-document/react";
import { z } from "zod";
import "./grouping-lab.css";
Expand Down
2 changes: 1 addition & 1 deletion apps/outliner-blind-b/src/outlinerModel.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { createJSONDocument } from "@interactive-os/json-document";
import { createJSONDocument } from "@interactive-os/json-document/session";
import {
addChild,
addSibling,
Expand Down
2 changes: 1 addition & 1 deletion apps/outliner-blind-b/src/outlinerModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as z from "zod";
import type { JSONDocument, JSONPatchOperation, Pointer } from "@interactive-os/json-document";
import type { JSONDocument, JSONPatchOperation, Pointer } from "@interactive-os/json-document/session";

export type OutlineNode = {
id: string;
Expand Down
2 changes: 1 addition & 1 deletion apps/outliner/src/OutlineRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// keydown 은 props 로 받는다 — chord dispatcher 는 부모 책임.

import { useEffect, useRef } from "react";
import type { JSONDocument, Pointer } from "@interactive-os/json-document";
import type { JSONDocument, Pointer } from "@interactive-os/json-document/session";
import type { OutlineNode } from "./schema.js";
import type { Mode } from "./keymap.js";

Expand Down
2 changes: 1 addition & 1 deletion apps/outliner/src/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
type WebClipboardCutResult,
type WebClipboardPasteResult,
} from "@interactive-os/json-document-clipboard-web";
import type { JSONDocument, Pointer } from "@interactive-os/json-document";
import type { JSONDocument, Pointer } from "@interactive-os/json-document/session";
import type { OutlineNode } from "./schema.js";

export type ClipboardMode = "empty" | "copy" | "cut";
Expand Down
2 changes: 1 addition & 1 deletion apps/outliner/src/commands/context.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Command 들이 공유하는 ctx 형식 + 공용 헬퍼.

import type { JSONDocument, Pointer, SelectionPoint, SelectionState } from "@interactive-os/json-document";
import type { JSONDocument, Pointer, SelectionPoint, SelectionState } from "@interactive-os/json-document/session";
import type { OutlineNode } from "../schema.js";
import type { ClipboardApi } from "../clipboard.js";
import { comparePointer } from "../pointer-utils.js";
Expand Down
2 changes: 1 addition & 1 deletion apps/outliner/src/commands/focus.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Focus navigation — DFS visible order 위에서 좌표 이동만 (state 미변경).

import type { Pointer } from "@interactive-os/json-document";
import type { Pointer } from "@interactive-os/json-document/session";
import type { OutlineNode } from "../schema.js";
import {
parentOf, nextVisible, prevVisible, firstVisible, lastVisible, firstChildOf,
Expand Down
2 changes: 1 addition & 1 deletion apps/outliner/src/commands/structure.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createCollection } from "@interactive-os/json-document-collection";
import { createOutline } from "@interactive-os/json-document-outline";
import { type JSONResult, type Pointer } from "@interactive-os/json-document";
import { type JSONResult, type Pointer } from "@interactive-os/json-document/session";
import { lastIndex, parentOf } from "../pointer-utils.js";
import { focusOf, type CommandContext, targetsOf, sortDfs } from "./context.js";

Expand Down
2 changes: 1 addition & 1 deletion apps/outliner/src/hooks/useClickPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// click = collapse

import { useCallback } from "react";
import type { Pointer, SelectionState } from "@interactive-os/json-document";
import type { Pointer, SelectionState } from "@interactive-os/json-document/session";
import type { Mode } from "../keymap.js";

export function useClickPolicy(
Expand Down
2 changes: 1 addition & 1 deletion apps/outliner/src/hooks/useDraftState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type DocumentPersistenceRestoreResult,
type DocumentPersistenceSaveResult,
} from "@interactive-os/json-document-persist-web";
import type { JSONDocument } from "@interactive-os/json-document";
import type { JSONDocument } from "@interactive-os/json-document/session";
import type { OutlineNode } from "../schema.js";

const DRAFT_KEY = "json-document.outliner.draft";
Expand Down
2 changes: 1 addition & 1 deletion apps/outliner/src/hooks/useToasts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Toast 상태. error 는 클릭 시까지 유지 (zod 메시지가 길어서), info 는 2.5s.

import { useCallback, useEffect, useRef, useState } from "react";
import type { JSONDocumentError } from "@interactive-os/json-document";
import type { JSONDocumentError } from "@interactive-os/json-document/session";

export interface ToastMessage {
id: number;
Expand Down
2 changes: 1 addition & 1 deletion apps/outliner/src/pointer-utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Outliner-local Pointer helpers. RFC 6901 위에서 outline 트리를 다루는 식별 함수들.

import { parentPointer, lastSegmentIndex, withLastSegment, type Pointer } from "@interactive-os/json-document";
import { parentPointer, lastSegmentIndex, withLastSegment, type Pointer } from "@interactive-os/json-document/session";
import type { OutlineNode } from "./schema.js";

// Outliner-local 별칭 — json-document 의 path arithmetic 헬퍼를 짧은 이름으로.
Expand Down
2 changes: 1 addition & 1 deletion apps/outliner/tests/stress.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { renderHook } from "@testing-library/react";
import { afterEach, describe, expect, test } from "vitest";
import { z } from "zod";
import { Outliner, OutlineSchema, SAMPLE } from "../src/index.js";
import type { JSONDocumentError } from "@interactive-os/json-document";
import type { JSONDocumentError } from "@interactive-os/json-document/session";
import { useJSONDocument } from "@interactive-os/json-document/react";

afterEach(cleanup);
Expand Down
2 changes: 1 addition & 1 deletion apps/review-comments-lab/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type Comments,
} from "@interactive-os/json-document-comments";
import { useJSONDocument } from "@interactive-os/json-document/react";
import { type Pointer } from "@interactive-os/json-document";
import { type Pointer } from "@interactive-os/json-document/session";
import { z } from "zod";
import "./review-comments-lab.css";

Expand Down
6 changes: 3 additions & 3 deletions apps/site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="description"
content="json-document is a Zod-guarded headless JSON editing engine for JSON Patch, JSON Pointer, JSONPath, selection, clipboard, and history."
content="Provider-neutral JSON editing protocol and six-member headless document projection for JSON Patch, JSON Pointer, and JSONPath."
/>
<meta name="theme-color" content="#fafaf9" />
<meta property="og:type" content="website" />
<meta property="og:site_name" content="@interactive-os/json-document" />
<meta property="og:title" content="json-document - Headless JSON editing" />
<meta
property="og:description"
content="json-document is a Zod-guarded headless JSON editing engine for JSON Patch, JSON Pointer, JSONPath, selection, clipboard, and history."
content="Provider-neutral JSON editing protocol and six-member headless document projection for JSON Patch, JSON Pointer, and JSONPath."
/>
<meta property="og:url" content="https://developer-1px.github.io/json-document/" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="json-document - Headless JSON editing" />
<meta
name="twitter:description"
content="json-document is a Zod-guarded headless JSON editing engine for JSON Patch, JSON Pointer, JSONPath, selection, clipboard, and history."
content="Provider-neutral JSON editing protocol and six-member headless document projection for JSON Patch, JSON Pointer, and JSONPath."
/>
<link rel="canonical" href="https://developer-1px.github.io/json-document/" />
<link rel="icon" href="%BASE_URL%favicon.svg" type="image/svg+xml" />
Expand Down
2 changes: 1 addition & 1 deletion apps/site/public/site.webmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@interactive-os/json-document",
"short_name": "@interactive-os/json-document",
"description": "Zod-guarded headless JSON editing.",
"description": "Provider-neutral JSON editing protocol and headless document projection.",
"start_url": ".",
"display": "standalone",
"background_color": "#fafaf9",
Expand Down
Loading