Repository navigation
Conversation
Reuse the fixture-only hunk from f867088 (mdx-editor#996). Keep all existing Markdown, image, and focus assertions.
|
Thanks for this. Pasting a spreadsheet region into a table is useful, but this version changes too much default behaviour for me to merge.
I would accept a much smaller version:
|
|
Updated normally to The paste-specific changes now:
The ordinary edit/blur reconciliation and shared export/history repair are reviewed separately in #1004. They were reproduced on current main before repair; this branch includes that dependency, so those files remain in this PR's main-relative diff until the core repair lands. Relative to the core head, this PR has only the nine table-paste source/example/test files. Verification on the exact published tree: 318 unit tests passed (existing 1 skip/1 todo retained), full lint, typecheck, library/declaration build, and the 24-package Lexical version check passed. Independent review reran 114 focused tests successfully. The old remote head and the standalone core head are both ancestors; no history rewrite was used. Exact-head CI is running. Local browser startup was environment-blocked before a page opened, so the native keyboard/focus, packaged-consumer, and cross-version CI gates are still pending for this head. This update supersedes the previous PR body's custom history-routing contract and readiness statement; I am not claiming the revised head is fully verified yet. |
|
Final verification for The first revised CI run exposed five failures in the shared core dependency, not the paste contract. They are fixed in #1004 ( The exact integrated tree also passes 321 local unit tests (the existing 1 skip/1 todo retained), full lint/typecheck/build, and independent re-review of the corrective changes. This was a normal update preserving the old branch and core ancestry. The narrowed paste delta remains nine source/example/test files relative to the standalone core repair; no custom table Undo/Redo routing or direct stack writes were reintroduced. Coverage uses real browser keyboard/focus plus synthetic clipboard events; native OS clipboard and external spreadsheet application integration were not separately tested. No upstream merge or deployment has been performed. |
petyosi
left a comment
There was a problem hiding this comment.
Thanks for narrowing this. Dropping the history routing and the CONTRIBUTING section is what I asked for. A few things are still needed:
1. Indented code is still pasted as a grid. The TSV check accepts lines that start with a tab, so "\tfoo()\n\tbar()" (2×2), "\tA\tint\n\tB\tstring" (2×3) or a Makefile recipe still empties the cell and overwrites the neighbouring cell. That was the original complaint. Please reject TSV whose first column is empty on every row. Any HTML table also counts, even 1×1, so a single copied spreadsheet cell replaces the whole cell content instead of inserting at the caret. Please apply the 2×2 rule to HTML tables too.
2. A paste inside a nested editor in a cell overwrites the table. The PASTE_COMMAND handler (TableEditor.tsx:568-570) ignores the editor that sent the command. Lexical sends commands up through parent editors by priority, so this critical-priority handler runs before an inline JSX editor's own paste handler. Pasting a\tb\nc\td inside a JSX component in a cell replaces that cell, including the component, and its neighbours. Please return false when the source editor is not the cell editor, and add a test with an editable inline JSX component in a cell.
3. Undo right after the paste does nothing. The destination cell remounts with an empty local history, so Ctrl/Cmd+Z and the toolbar Undo do nothing until focus leaves the table. The browser test asserts this. Without routing, one option is to focus outside the cell after the paste. In any case, Undo should reverse the paste the user just made.
4. Pending anchor text adds a second history step. If the anchor cell has unsaved text, save() commits it before the paste, so Undo first removes the paste and then the text. Please either record both as one entry or state it plainly in the docs.
5. It depends on #1004. This branch includes #1004 and uses ensureEditorHistoryBaseline and persistedContents. I've asked for #1004 to be cut down to the table-cell fix. Please rebase onto that once it lands.
Smaller: rejected or oversized regions, and any HTML over 1 MB that contains <table, are dropped silently via preventDefault. Please fall back to the normal paste instead of doing nothing.
|
Updated to
Local verification: the full unit suite passed 433 tests before the final empty-HTML cases; the final affected suites pass 60/60. Prettier, diff checks, and the 24-package Lexical version check pass. Local lint/typecheck were resource-killed and browser startup was environment-blocked before page creation, so I am not claiming those passed locally. Exact-head CI is running, including the native keyboard/focus cases in Chromium, Firefox, and WebKit. The PR description has been corrected to remove the obsolete routing and dropped-paste contract. |
|
Verification update for The initial CI failures are addressed: the parser's closure-mutated first-column flag was made explicit for typed lint, and the new nested-JSX browser fixture now activates the cell, focuses the nested editing host, and prepares its DOM caret before paste. The failed runs showed the caret was outside that editor, including Firefox failing the focus precondition before paste. The fixture now asserts both focus and caret location; component, pasted-content, and neighboring-cell assertions are retained. No tests were skipped or paste assertions removed to get this result. The fixes for the review remain confined to nine table-paste source/example/test files relative to current main. There is no global history-helper/core-export delta or direct history-stack manipulation. As documented above, region replacement is root-table-only; tables inside directive/JSX containers retain safe caret text paste. Browser coverage uses synthetic clipboard payloads with real keyboard/focus, not native OS clipboard or external spreadsheet interoperability. |
Refs #784.
Behavior
History and scope
The region is one parent history entry. Pending anchor text is merged into its baseline using a public Lexical history tag, so one Undo restores that text without an extra pending-text undo step. After region paste, focus moves to the parent so keyboard and toolbar Undo work immediately. Untouched cell histories remain local.
This version is based on the landed, table-scoped #1004 fix. There are no additional core/global history changes or direct history-stack writes in this PR. Region replacement is limited to tables in the root editor. Tables inside directive/JSX containers keep caret text paste instead of introducing cross-editor history routing.
Verification
Current head:
afa47d43a41ade74e3b5473c3bceef91e03dd658.CI for this head passes all four jobs. The PR merge-test tree matches the published head's tree.
git diff --checkpass.Local full lint/typecheck were resource-killed, and local browser startup was blocked before page creation; the full results above are from CI.
Coverage uses synthetic DOM clipboard payloads with real browser keyboard/focus. The nested JSX fixture explicitly focuses its editing host and prepares its DOM caret before paste. Native OS clipboard permissions and external spreadsheet application interoperability are not certified.