### Install via shadcn CLI Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Install the Minimal Tiptap Editor component directly from the registry using the shadcn CLI. ```bash npx shadcn@latest add https://raw.githubusercontent.com/Aslam97/shadcn-minimal-tiptap/main/registry/block-registry.json ``` -------------------------------- ### Install required dependencies Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Install all required npm packages for the editor, including Tiptap extensions and lowlight. ```bash npm install lowlight react-medium-image-zoom @radix-ui/react-icons @tiptap/extension-bubble-menu @tiptap/extension-code-block-lowlight @tiptap/extension-color @tiptap/extension-horizontal-rule @tiptap/extension-image @tiptap/extension-list @tiptap/extension-table @tiptap/extension-text-style @tiptap/markdown @tiptap/extension-typography @tiptap/extensions @tiptap/pm @tiptap/react @tiptap/starter-kit ``` -------------------------------- ### React component usage Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Implement the MinimalTiptapEditor component in your React application. Requires the minimal-tiptap directory copied into your project and the listed Shadcn UI components installed. ```tsx import { useState } from "react" import { Content } from "@tiptap/react" import { MinimalTiptapEditor } from "./minimal-tiptap" export const App = () => { const [value, setValue] = useState("") return ( ) } ``` -------------------------------- ### Initialize New Project with Local Registry using npx shadcn@latest init Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Initialize a new project with the local registry. ```bash npx shadcn@latest init http://127.0.0.1:8080/block-registry.json ``` -------------------------------- ### Host Registry Locally with npm run host-registry Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Host the registry locally. ```bash npm run host-registry ``` -------------------------------- ### Build Component Registry with npm run build-registry Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Build the component registry after updating the component. ```bash npm run build-registry ``` -------------------------------- ### Add Local Registry to Project with npx shadcn@latest add Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Use the local registry in a project by adding it with the specified URL. ```bash npx shadcn@latest add http://127.0.0.1:8080/block-registry.json -o ``` -------------------------------- ### Configure Image extension with custom options Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Use this configuration to set allowed MIME types, a maximum file size, and custom handlers for image removal, upload, and various action/validation events. The uploadFn must return the uploaded image URL; if not specified, enable the allowBase64 option. ```typescript Image.configure({ allowedMimeTypes: ["image/jpeg", "image/png", "image/gif"], onImageRemove: handleImageRemove, maxFileSize: 5 * 1024 * 1024, // 5MB uploadFn: customImageUploader, onActionSuccess: handleActionSuccess, onActionError: handleActionError, onValidationError: handleValidationError, }) ``` -------------------------------- ### Configure TooltipProvider Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Wrap your application root component with TooltipProvider to enable tooltips for the editor. ```tsx import { TooltipProvider } from "@/components/ui/tooltip" export const App = () => { return ( {/* Application components */} ) } ``` -------------------------------- ### Image Extension Configuration Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Configuration options for the Image extension, including allowed MIME types, file size limits, and custom upload and error handling functions. ```APIDOC ## Image Extension Configuration ### Description Configure the Image extension with custom options. The `uploadFn` must return the uploaded image URL. If no `uploadFn` is specified, enable the `allowBase64` option. ### Configuration Options - `allowedMimeTypes` (string[]) - Allowed MIME types for image uploads. - `onImageRemove` (function) - Callback when an image is removed. - `maxFileSize` (number) - Maximum file size in bytes. - `uploadFn` (function) - Custom upload handler that returns the uploaded image URL. - `onActionSuccess` (function) - Callback on successful upload action. - `onActionError` (function) - Callback on upload error. - `onValidationError` (function) - Callback on validation error. ### Example ```typescript Image.configure({ allowedMimeTypes: ["image/jpeg", "image/png", "image/gif"], onImageRemove: handleImageRemove, maxFileSize: 5 * 1024 * 1024, // 5MB uploadFn: customImageUploader, onActionSuccess: handleActionSuccess, onActionError: handleActionError, onValidationError: handleValidationError, }) ``` ``` -------------------------------- ### Tailwind CSS entry point reference Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Add this line to /minimal-tiptap/styles/index.css to reference your Tailwind CSS entry point. ```css @reference "path-to-your-entry-point-tailwind.css"; ``` -------------------------------- ### Implement custom image upload handler Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Define an async upload function that receives the file and editor instance, then returns the uploaded image URL. This handler is passed to the Image extension via the uploadFn option. ```typescript const customImageUploader = async (file: File, editor: Editor) => { // Implement upload logic // Return the uploaded image URL return "https://example.com/uploaded-image.jpg" } Image.configure({ uploadFn: customImageUploader, }) ``` -------------------------------- ### Configure Toolbar Sections with SectionOne, SectionTwo, SectionFour, SectionFive Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Customize toolbar sections using configuration options. Use activeLevels for heading levels, activeActions for actions, and mainActionCount to control main action count. Variant can be set to 'outline'. ```typescript ``` -------------------------------- ### Custom Image Upload Handler Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Implement a custom upload handler for the Image extension. The handler receives a File and the Editor instance, and must return the uploaded image URL. ```APIDOC ## Custom Image Upload Handler ### Description Implement a custom upload handler for the Image extension. The handler receives a File and the Editor instance, and must return the uploaded image URL. ### Function Signature `async (file: File, editor: Editor) => Promise` ### Parameters - `file` (File) - The image file to upload. - `editor` (Editor) - The Tiptap editor instance. ### Returns - `string` - The URL of the uploaded image. ### Example ```typescript const customImageUploader = async (file: File, editor: Editor) => { // Implement upload logic // Return the uploaded image URL return "https://example.com/uploaded-image.jpg" } Image.configure({ uploadFn: customImageUploader, }) ``` ``` -------------------------------- ### Handle image action and validation errors Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Configure the Image extension with error handlers for upload failures and validation errors. Use these callbacks to log errors and implement user notifications or validation feedback. ```typescript Image.configure({ onActionError: (error, props) => { console.error("Image upload failed:", error, props) // Implement user notification }, onValidationError: (errors) => { console.error("Image validation failed:", errors) // Display validation feedback }, }) ``` -------------------------------- ### Editor Props Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Configuration options for the minimal Tiptap editor component. These props control initial content, output format, styling, and update behavior. ```APIDOC ## Editor Props ### Description Configuration options for the minimal Tiptap editor component. These props control initial content, output format, styling, and update behavior. ### Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value` | string | - | Initial editor content | | `onChange` | function | - | Content change event handler | | `editorContentClassName` | string | - | CSS class for the editor content container | | `output` | 'html' \| 'json' \| 'text' \| 'markdown' | 'html' | Desired output format | | `placeholder` | string | - | Editor placeholder text | | `editorClassName` | string | - | CSS class for the editor container | | `throttleDelay` | number | 0 | Update throttling delay in milliseconds | ``` -------------------------------- ### Image Error Management Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Implement comprehensive error handling for the Image extension using the onActionError and onValidationError callbacks. ```APIDOC ## Image Error Management ### Description Implement comprehensive error handling for the Image extension using the `onActionError` and `onValidationError` callbacks. ### Callbacks - `onActionError` (function) - Called when an image upload action fails. Receives an error object and props. - `onValidationError` (function) - Called when image validation fails. Receives an array of validation errors. ### Example ```typescript Image.configure({ onActionError: (error, props) => { console.error("Image upload failed:", error, props) // Implement user notification }, onValidationError: (errors) => { console.error("Image validation failed:", errors) // Display validation feedback }, }) ``` ``` -------------------------------- ### Prevent Dropdown Menu Trigger Focus with onCloseAutoFocus Source: https://github.com/aslam97/minimal-tiptap/blob/main/README.md Use onCloseAutoFocus to prevent the dropdown menu trigger from receiving focus after selection. ```typescript onCloseAutoFocus={event => event.preventDefault()} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.