[lexical-extension][lexical-rich-text][lexical-react] Feature: Support configuration of indentable nodes#8122
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
3559dca to
448742e
Compare
448742e to
fcf67e9
Compare
etrepum
left a comment
There was a problem hiding this comment.
I would suggest an even simpler approach where something like $canIndent: (node: ElementNode) => boolean is the configuration with a default implementation of (node) => node.canIndent() and then the user can make any possible override of behavior from there.
e9bb293 to
55415cd
Compare
Good idea. I did it and also extended the current e2e test for indentation, since now the maximum indentation level can be set by selected nodes independently of each other. I think it looks expected and natural, watch the demo video in the updated description |
|
I think the integration tests are failing because this introduced a circular dependency from extension -> rich-text -> dragon -> extension |
thanks, fixed |
etrepum
left a comment
There was a problem hiding this comment.
Can you update the e2e test to preserve the existing tests? It's difficult to see if this is backwards compatible or not because it looks like the tests have also changed in-place.
The test had to be changed anyway because it checked the old behavior of the plugin and failed after the changes. Previously, it was expected that none of the elements would set indentation if at least one of them reached the maximum value Maybe this workaround will help you 😅
console codeasync function copyHtmlToClipboard(html) {
const blob = new Blob([html], { type: "text/html" });
const data = new ClipboardItem({ "text/html": blob });
await navigator.clipboard.write([data]);
console.log("HTML сopied as text/html");
}
// paste html here
const html = `
`;
// focus on the document during the timer
setTimeout(() => copyHtmlToClipboard(html), 1500); |
|
My point here is that we should verify that if you don’t add any new settings then the behavior shouldn’t change. |
That's the point. Without changing the settings, the test fails with an error because it checked different behavior. https://github.com/facebook/lexical/actions/runs/21797687397/job/62887841955#step:11:293 I can revert to the previous behavior and add a check for the existence of the maximum indent value among the selected elements so that the test does not fail, but I think from a UX perspective it is better to give the user the ability to indent all remaining nodes than not to give it at all. |
etrepum
left a comment
There was a problem hiding this comment.
I think that behavior probably makes sense, but I think the PR description should cover this change in behavior before this is merged.
There might be some interaction with autocomplete, this test seems to be consistently failing and it's not marked as flaky https://github.com/facebook/lexical/actions/runs/21873757189/job/63136469223?pr=8122
|
I think this test might need to be looked at: |
Breaking Change
TabIndentationExtensionandTabIndentationPluginnow enforce max indentation level on a per-block basis. Previously, any block at max indentation in the selection would prevent all indentation of the selection.Description
I added a new option to the
TabIndentationplugin and extension. The essence of the feature is to provide an interface for a limited selection of classes that can be indented by pressing Tab.Although it is possible to override the
canIndentmethod for classes that do not need indents, this generates a lot of boilerplate code. For example, in a real-world case, you may need to be able to set nested lists using Tab, but not set indents for all other elements. To do this, you would need to extend each class used from lexical to override only one method,canIndentWith the new option in the plugin, this task is simplifiedIt is now also possible to set indents for each node within a selection independently of each other. If one of the nodes has the maximum indent value, the indent will be added to the others. Previously, Tab did not work for any nodes if there was at least one maximum value among the nodes.
Test plan
Before
All elements can be indented. If one of the selected nodes has the maximum indentation, no indentation will be set for the other elements.
Screen.Recording.2026-02-08.at.17.50.57.mov
After
All elements can be indented. Nodes with maximum indentation are ignored, while the rest elements are indented
Screen.Recording.2026-02-08.at.17.53.12.mov
If indents are only needed for specific nodes. For example, for lists
Screen.Recording.2026-02-08.at.03.14.30.mov