Skip to content

[examples/node-state-style] Refactor: Migrate to Extension-based architecture - #2

Closed
etrepum wants to merge 1 commit into
mainfrom
claude/merge-node-state-style-8ILRo
Closed

etrepum wants to merge 1 commit into
mainfrom
claude/merge-node-state-style-8ILRo

Conversation

@etrepum

@etrepum etrepum commented Apr 28, 2026

Copy link
Copy Markdown
Owner

Description

This PR consolidates the dev-node-state-style example into the main examples/node-state-style example and refactors it to use the new Extension-based architecture instead of the legacy Plugin-based approach.

Changes:

  • Removed: The entire dev-examples/dev-node-state-style directory, which was a development-only example
  • Updated: examples/node-state-style to use LexicalExtensionComposer instead of LexicalComposer
  • Migrated: From Plugin-based setup (LexicalComposer, RichTextPlugin, HistoryPlugin, AutoFocusPlugin) to Extension-based setup (RichTextExtension, HistoryExtension, AutoFocusExtension, defineExtension)
  • Updated: Dependencies in package.json to use @lexical/extension and @lexical/history instead of @lexical/clipboard
  • Refactored: styleState.ts to remove legacy DOM mutation listener code and use the new DOMRenderExtension API for style application

The core functionality remains the same—demonstrating how NodeState can be used with a DOMRenderExtension to override create and export behavior of nodes—but now uses the modern Extension architecture.

Closes #

Test plan

The example application should continue to function identically:

  • Style properties can be added, edited, and removed from nodes
  • The tree view displays the node hierarchy correctly
  • HTML and JSON export views render properly
  • Toolbar formatting commands work as expected

Existing tests for the style state functionality pass with the refactored code.

https://claude.ai/code/session_01RuqYZ3WU4vdtmWAHurST9w

Now that 0.44.0 is released and ships DOMRenderExtension, replace the
mutation-listener based node-state-style example with the extension-based
implementation from dev-examples/dev-node-state-style. Drop the dev-only
copy. The dev-examples directory and integration test infrastructure
remain so future examples built on unreleased APIs can use them.

https://claude.ai/code/session_01RuqYZ3WU4vdtmWAHurST9w
@etrepum etrepum closed this Apr 28, 2026
etrepum added a commit that referenced this pull request Oct 5, 2026
… selection tests

## Description

The macOS Chromium first-node table selection test failed all three attempts because its leading paragraph survived setup Backspace. The later shift-selection assertion then saw the trailing paragraph at child index 2 instead of 1.

Check native and Lexical caret positions before deleting adjacent paragraphs and before shift-selection in the related first-node, last-node, and surrounding-content variants. Verify the remaining paragraph count after setup deletion. Preserve all existing table-selection expectations and platform exclusions.

## Test plan

### Before

macOS Chromium on e8c17b8:
https://github.com/facebook/lexical/actions/runs/37251396589

```
Selection > shift+arrowup into a table, when the table is the first node, selects the whole table
- Expected
+ Received
  Array [
-   1,
+   2,
  ]
Retry #1
Retry #2
1 failed
```

### After

Linux WebKit, all eight adjacent-table selection cases repeated three times, four workers, retries disabled:
```
rich-text: expected=18, skipped=6, unexpected=0, flaky=0
rich-text-with-collab: expected=18, skipped=6, unexpected=0, flaky=0
```

```sh
E2E_EDITOR_MODE=rich-text node node_modules/playwright/cli.js test --project=webkit --workers=4 --retries=0 e2e/Selection.spec.mjs --grep 'into a table' --repeat-each=3 --reporter=json
E2E_EDITOR_MODE=rich-text-with-collab node node_modules/playwright/cli.js test --project=webkit --workers=4 --retries=0 e2e/Selection.spec.mjs --grep 'into a table' --repeat-each=3 --reporter=json
```

ESLint, Prettier, and git diff --check passed. macOS Chromium is unavailable locally and is validated in CI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants