-function setAlignmentForSection(alignment: CommonBlockAlignment): void {
- const selection = $getSelection();
+function setAlignmentForSection(editor: LexicalEditor, alignment: CommonBlockAlignment): void {
+ const selection = getLastSelection(editor);
+ const selectionNodes = selection?.getNodes() || [];
+ const decorators = $getDecoratorNodesInSelection(selection);
+
+ // Handle decorator node selection alignment
+ if (selectionNodes.length === 1 && decorators.length === 1 && nodeHasAlignment(decorators[0])) {
+ decorators[0].setAlignment(alignment);
+ console.log('setting for decorator!');
+ return;
+ }
+
+ // Handle normal block/range alignment