add language support and fix export issue with page editor where the exported PDF was just the same as the originally uploaded file

This commit is contained in:
EthanHealy01
2025-08-22 16:51:24 +01:00
parent 45d99777cc
commit e0a865173e
10 changed files with 173 additions and 77 deletions

View File

@@ -18,8 +18,19 @@ export function RightRailProvider({ children }: { children: React.ReactNode }) {
const registerButtons = useCallback((newButtons: RightRailButtonConfig[]) => {
setButtons(prev => {
const merged = [...prev.filter(b => !newButtons.some(nb => nb.id === b.id)), ...newButtons];
return merged.sort((a, b) => (a.order || 0) - (b.order || 0));
const byId = new Map(prev.map(b => [b.id, b] as const));
newButtons.forEach(nb => {
const existing = byId.get(nb.id) || ({} as RightRailButtonConfig);
byId.set(nb.id, { ...existing, ...nb });
});
const merged = Array.from(byId.values());
merged.sort((a, b) => (a.order ?? 0) - (b.order ?? 0) || a.id.localeCompare(b.id));
if (process.env.NODE_ENV === 'development') {
const ids = newButtons.map(b => b.id);
const dupes = ids.filter((id, idx) => ids.indexOf(id) !== idx);
if (dupes.length) console.warn('[RightRail] Duplicate ids in registerButtons:', dupes);
}
return merged;
});
}, []);