@udecode/plate-alignment
Advanced tools
Comparing version 33.0.0 to 33.0.6
@@ -7,3 +7,3 @@ import * as _udecode_plate_common_server from '@udecode/plate-common/server'; | ||
declare const useAlignDropdownMenuState: () => { | ||
value: Alignment; | ||
value: "center" | "end" | "justify" | "left" | "right"; | ||
}; | ||
@@ -13,3 +13,3 @@ declare const useAlignDropdownMenu: ({ value, }: ReturnType<typeof useAlignDropdownMenuState>) => { | ||
onValueChange: (newValue: string) => void; | ||
value: Alignment; | ||
value: "center" | "end" | "justify" | "left" | "right"; | ||
}; | ||
@@ -16,0 +16,0 @@ }; |
@@ -50,21 +50,29 @@ "use strict"; | ||
const value = (0, import_plate_common.useEditorSelector)((editor) => { | ||
if ((0, import_server.isCollapsed)(editor.selection)) { | ||
const entry = (0, import_server.findNode)(editor, { | ||
match: (n) => (0, import_server.isDefined)(n[KEY_ALIGN]) | ||
}); | ||
if (entry) { | ||
const nodeValue = entry[0][KEY_ALIGN]; | ||
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"; | ||
let commonAlignment; | ||
const codeBlockEntries = (0, import_plate_common.getNodeEntries)(editor, { | ||
match: (n) => (0, import_plate_common.isBlock)(editor, n) | ||
}); | ||
const nodes = Array.from(codeBlockEntries); | ||
nodes.forEach(([node, path]) => { | ||
const align = node[KEY_ALIGN] || "left"; | ||
if (!(0, import_server.isDefined)(commonAlignment)) { | ||
commonAlignment = align; | ||
} else if (commonAlignment !== align) { | ||
commonAlignment = void 0; | ||
} | ||
}); | ||
if ((0, import_server.isDefined)(commonAlignment)) { | ||
const nodeValue = commonAlignment; | ||
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 "start"; | ||
return "left"; | ||
}, []); | ||
@@ -71,0 +79,0 @@ return { |
{ | ||
"name": "@udecode/plate-alignment", | ||
"version": "33.0.0", | ||
"version": "33.0.6", | ||
"description": "Text alignment plugin for Plate", | ||
@@ -45,3 +45,3 @@ "license": "MIT", | ||
"peerDependencies": { | ||
"@udecode/plate-common": ">=33.0.0", | ||
"@udecode/plate-common": ">=33.0.4", | ||
"react": ">=16.8.0", | ||
@@ -48,0 +48,0 @@ "react-dom": ">=16.8.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
25864
328