githubnext/chopinPublic

Let's compose rich plans together

Give a table rails to reshape it by

A grip per column above the table and per row beside it: drag one to
reorder, press the cross to remove, press the plus between two to insert
there. Every gesture has a keyboard equivalent, because a reorder that
is only a drag is a reorder some people cannot perform at all.

They are a measured overlay rather than chrome inside the node, because
a `<table>` cannot contain a `<div>` — the `data-plan-chrome` slot the
callouts and tabs portal into is not available at any price here, so the
choice was between subclassing `TableNode` and reading rectangles.

The header row does not take part. Nothing in the document marks a row
as the header: being first is the whole of what makes it one, and the
column alignment hangs off its cells. A drag that moved it would not
reorder the table so much as change what it claims.

This also installs the plugins `@lexical/table` assumes are registered
and were not — cell navigation, the integrity transforms, and the
unmerge transform that keeps a pasted table to a shape GFM can write.
The theme gains the two class names its selection paints through, which
MDXEditor's names for no table and so drew nothing at all.

Limits are checked before a row exists rather than after: past
`MAX_TABLE_ROWS` the server refuses the update, and it cannot undo a Yjs
transaction, so the room is rebuilt under a fresh epoch and everybody in
it loses their undo and their cursors.
KCKrzysztof Cieslak authored
31a39cePatch
Parent5a8a277
13 files changed+1868-4
StackedSplit
agents.md+65 −4
bun.lock+1 −0
packages/editor/package.json+1 −0
packages/editor/src/plan-editor.tsx+8 −0
packages/editor/src/styles.css+224 −0
packages/editor/src/table/geometry.test.ts+113 −0
packages/editor/src/table/geometry.ts+152 −0
packages/editor/src/table/ops.test.ts+261 −0
packages/editor/src/table/ops.ts+185 −0
packages/editor/src/table/rails.tsx+685 −0
packages/editor/src/table/shape.test.ts+75 −0
packages/editor/src/table/shape.ts+94 −0
packages/editor/src/widgets-plugin.tsx+4 −0