How pipipi-pikachu/pptist works
Project Type & Purpose
• PPTist is a front-end, single-page application (SPA) that emulates Microsoft PowerPoint’s features. Its primary purpose is slide editing, real-time presentation editing, and previewing across devices (desktop, mobile, and presenter modes).
• Built with Vue 3, the project avoids heavy third-party UI libraries to facilitate custom styling and easier extension.
Analyzing the File Structure
• Top-Level Layout: Notice files like index.html, package.json, vite.config.ts, and configuration files that solidify it as a frontend SPA.
• src Directory: This is the heart of the application. It contains:
• Component layers (e.g., src/components and src/views) which clearly divide UI elements for different parts of the app.
• Views are grouped based on use-cases—Editor (full slide editing), Mobile (mobile editing and preview), and Screen (presentation mode).
• Directories like src/hooks and src/services indicate reusable logic layers (custom hooks for operations like dragging, scaling, history, etc., and services for config and communication).
• The store (src/store) provides state management across UI components.
• Documentation (doc/): Provides extra context such as element behaviors, canvas layout, and custom element information.
Core Components and Relationships
a. Main Components to Highlight:
– Presentation Editor: Comprises the “Editor” view (src/views/Editor) that holds the canvas, toolbar, thumbnail panel, export dialogs, etc.
– Canvas & Slide Management: The canvas area (src/views/Editor/Canvas) where slides are rendered for editing. Also includes gridlines, guides, and selection components.
– Toolbar & Context Menus: Tools for adjusting styles and options (many are under src/views/Editor/Toolbar) and a context menu available globally (src/components/Contextmenu).
– Mobile & Screen Views: Submodules like src/views/Mobile and src/views/Screen capture adaptation for mobile editing and presentation modes.
– Global Utilities & Store: The global state management in src/store and utility functions in src/utils (such as clipboard, DOM manipulation, prosemirror integrations) tie the UI together.
b. Relationships & Interactions:
– The Editor view interacts with Canvas, which in turn renders individual slide elements.
– Toolbar and context menus provide controls that trigger actions through hooks (src/hooks) and update state via the store.
– Custom directives (in src/plugins/directive) manage DOM event behaviors, like click-outside or tooltips.
– Services (in src/services) abstract configuration or integration logic, forming the bridge between UI state and “back-end-like” operations (e.g., export functions).
– Communication flows from UI events (e.g., dragging, selecting, editing) through custom hooks (e.g., useMoveElement, useDeleteElement) to update the Vue store.
– Reusable utility libraries (in src/utils and src/views/components/element/hooks) handle transformations, parsing (like the HTML and SVG parsers), and other operations.
Architectural Patterns & Design Principles
• Component-Based Architecture: Uses Vue’s single-file component design to modularize complex slide editing and presentation functions.
• Separation of Concerns: Dividing views (editor, mobile, screen) from business logic (services, hooks, store) makes the design maintainable.
• Reusability: Custom hooks and utilities encourage reuse across various editing capabilities.
• State Management: The central store (with modules like slides, snapshot, keyboard, and screen) is pivotal for synchronizing UI state and interaction events.
• Responsive Design: Multiple views (Editor, Mobile, Screen) cater to different device requirements using similar underlying logic.