Skip to content

Commit

Permalink
Merge pull request #2953 from shaungrady/add-start-end-to-alignment-p…
Browse files Browse the repository at this point in the history
…lugin

[alignment] Support 'start' and 'end' values, default to 'start'
  • Loading branch information
zbeyens committed Feb 16, 2024
2 parents 56a1877 + 67fae94 commit 45ff410
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/light-comics-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@udecode/plate-alignment": patch
---

[alignment] Support 'start' and 'end' values, default to 'start'
2 changes: 1 addition & 1 deletion packages/alignment/src/__tests__/setAlign/left.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ it('should remove align prop', () => {
plugins: [createAlignPlugin()],
});

setAlign(editor, { value: 'left' });
setAlign(editor, { value: 'start' });

expect(editor.children).toEqual(output.children);
});
4 changes: 2 additions & 2 deletions packages/alignment/src/createAlignPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export const createAlignPlugin = createPluginFactory({
inject: {
props: {
nodeKey: KEY_ALIGN,
defaultNodeValue: 'left',
defaultNodeValue: 'start',
styleKey: 'textAlign',
validNodeValues: ['left', 'center', 'right', 'justify'],
validNodeValues: ['start', 'left', 'center', 'right', 'end', 'justify'],
validTypes: [getPluginType(editor, ELEMENT_DEFAULT)],
},
},
Expand Down
6 changes: 4 additions & 2 deletions packages/alignment/src/hooks/useAlignDropdownMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ export const useAlignDropdownMenuState = () => {

if (entry) {
const nodeValue = entry[0][KEY_ALIGN] as string;
if (nodeValue === 'right') return 'right';
if (nodeValue === 'left') return 'left';
if (nodeValue === 'center') return 'center';
if (nodeValue === 'right') return 'right';
if (nodeValue === 'end') return 'end';
if (nodeValue === 'justify') return 'justify';
}
}

return 'left';
return 'start';
}, []);

return {
Expand Down
2 changes: 1 addition & 1 deletion packages/alignment/src/types.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type Alignment = 'left' | 'center' | 'right' | 'justify';
export type Alignment = 'start' | 'left' | 'center' | 'right' | 'end' | 'justify';

0 comments on commit 45ff410

Please sign in to comment.