githubnext/chopinPublic

Let's compose rich plans together

Add the plan MDX dialect

The document model: a restricted MDX dialect, its Lexical schema, and the
canonical serialisation between them. One registry drives both the browser
editor and headless conversion on the server, because divergence there means
the two disagree about what a plan is.

Images are plain https URLs rather than uploaded assets. Validation mirrors the
link check but demands an absolute URL, since an image has nothing to resolve a
relative path against. The import visitor turns a URL the dialect will not
accept back into the text it came from: it would otherwise import cleanly,
serialise cleanly, and fail validation on the server, rebuilding the epoch over
something the author could have fixed if they could see it.

Component ids are minted wherever the component is created rather than only by
the server. A ULID has enough entropy that two editors inserting at the same
instant cannot collide, so this needs no round trip. The generator and the
validator are two halves of one contract, so a test asserts they agree.

Node types, state keys and data attributes are prefixed `plan-`.
KCKrzysztof Cieslak authored
e628de3Patch
Parentf6b9e56
28 files changed+4636-0
StackedSplit
bun.lock+555 โˆ’0
packages/dialect/package.json+69 โˆ’0
packages/dialect/src/convert.test.ts+191 โˆ’0
packages/dialect/src/convert.ts+156 โˆ’0
packages/dialect/src/dialect.test.ts+274 โˆ’0
packages/dialect/src/dialect.ts+224 โˆ’0
packages/dialect/src/index.ts+78 โˆ’0
packages/dialect/src/limits.ts+36 โˆ’0
packages/dialect/src/nodes/container-visitors.ts+99 โˆ’0
packages/dialect/src/nodes/containers.test.ts+234 โˆ’0
packages/dialect/src/nodes/containers.ts+297 โˆ’0
packages/dialect/src/nodes/content-visitors.ts+210 โˆ’0
packages/dialect/src/nodes/content.test.ts+138 โˆ’0
packages/dialect/src/nodes/content.ts+462 โˆ’0
packages/dialect/src/nodes/questionnaire.test.ts+115 โˆ’0
packages/dialect/src/nodes/questionnaire.ts+238 โˆ’0
packages/dialect/src/nodes/render.ts+26 โˆ’0
packages/dialect/src/nodes/shared.ts+49 โˆ’0
packages/dialect/src/nodes/table.ts+111 โˆ’0
packages/dialect/src/nodes/underline.ts+48 โˆ’0
packages/dialect/src/parse.ts+79 โˆ’0
packages/dialect/src/registry.test.ts+143 โˆ’0
packages/dialect/src/registry.ts+259 โˆ’0
packages/dialect/src/serialize.ts+59 โˆ’0
packages/dialect/src/ulid.test.ts+32 โˆ’0
packages/dialect/src/ulid.ts+36 โˆ’0
packages/dialect/src/validate.ts+399 โˆ’0
packages/dialect/tsconfig.json+19 โˆ’0