diff --git a/src/components/FavoriteComponentsModal.vue b/src/components/FavoriteComponentsModal.vue new file mode 100644 index 000000000..e311f8163 --- /dev/null +++ b/src/components/FavoriteComponentsModal.vue @@ -0,0 +1,179 @@ + + + + + diff --git a/src/hooks/useFavoriteComponents.ts b/src/hooks/useFavoriteComponents.ts new file mode 100644 index 000000000..be394b63a --- /dev/null +++ b/src/hooks/useFavoriteComponents.ts @@ -0,0 +1,54 @@ +import type { PPTElement } from '@/types/slides' + +const STORAGE_KEY = 'pptist-favorite-components' + +// TODO: Implement this function +const generateSvgPreview = async (elements: PPTElement[]): Promise => { + console.log('Generating SVG preview for:', elements) + // Placeholder implementation + await Promise.resolve() + return '' +} + +export interface FavoriteItem { + elements: PPTElement[]; + name: string; + previewSvg?: string; +} + +export default () => { + + const getFavorites = (): FavoriteItem[] => { + const favoritesJson = localStorage.getItem(STORAGE_KEY) + return favoritesJson ? JSON.parse(favoritesJson) : [] + } + + const addFavorite = (elements: PPTElement[], name: string) => { + if (!elements || elements.length === 0 || !name) return + + const favorites = getFavorites() + + const newFavorite: FavoriteItem = { + elements: elements, + name: name, + previewSvg: '', + } + + favorites.push(newFavorite) + localStorage.setItem(STORAGE_KEY, JSON.stringify(favorites)) + } + + const removeFavorite = (name: string) => { + const favorites = getFavorites() + const updatedFavorites = favorites.filter(favorite => favorite.name !== name) + localStorage.setItem(STORAGE_KEY, JSON.stringify(updatedFavorites)) + } + + // TODO: Implement other necessary functions later + + return { + addFavorite, + getFavorites, + removeFavorite, + } +} \ No newline at end of file diff --git a/src/views/Editor/Canvas/EditableElement.vue b/src/views/Editor/Canvas/EditableElement.vue index b191bf0ab..2a9dcdccc 100644 --- a/src/views/Editor/Canvas/EditableElement.vue +++ b/src/views/Editor/Canvas/EditableElement.vue @@ -17,7 +17,7 @@