Install the Bundle
composer require besmartand-pro/tiptap-editor
php bin/console besmartand-pro:tiptap-editor:install
@tiptap/*, bootstrap-icons) and configures Encore/Vite.Verify Frontend Build
pnpm install (or npm install/yarn install) to ensure Tiptap dependencies are installed.npm run dev # or yarn dev / pnpm dev
First Form Integration
Add the TiptapType to a Symfony form:
use BeSmartAndPro\TiptapEditorBundle\Form\Type\TiptapType;
$builder->add('content', TiptapType::class, [
'tiptap_placeholder' => 'Start typing here...',
]);
{{ stimulus_controller('besmartand-pro--tiptap-editor') }}
Test the Editor
json column type if storing as JSON).config/packages/besmartand_pro_tiptap_editor.yaml for upload settings (e.g., Flysystem, security roles).assets/controllers/besmartand_pro/tiptap_editor_controller.ts for Stimulus logic and assets/styles/besmartand_pro_tiptap_editor.scss for CSS overrides.TiptapField in your CRUD controller:
yield TiptapField::new('content', 'Content')->setPlaceholder('Edit here...');
Replace a standard textarea in a Symfony form with a WYSIWYG editor:
// src/Form/ArticleType.php
use BeSmartAndPro\TiptapEditorBundle\Form\Type\TiptapType;
class ArticleType extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder->add('body', TiptapType::class, [
'tiptap_placeholder' => 'Write your article...',
'tiptap_toolbar' => ['bold', 'italic', 'bulletList', 'link'], // Customize toolbar
]);
}
}
Template:
{{ form_row(form.body) }}
Result: A lightweight Tiptap editor with the specified toolbar buttons.
$builder->add('description', TiptapType::class, [
'tiptap_placeholder' => 'Describe your product...',
'tiptap_toolbar' => ['heading', '|', 'bold', 'italic'], // Custom toolbar groups
]);
$builder->add('content', TiptapType::class, [
'constraints' => [new Length(['max' => 5000])],
]);
yield TiptapField::new('content', 'Content')
->setPlaceholder('Edit in the editor...')
->setFormTypeOption('tiptap_toolbar', ['bold', 'italic', 'link']);
{# templates/easyadmin/crud/field/tiptap.html.twig #}
{{ field|raw }}
config/packages/besmartand_pro_tiptap_editor.yaml):
besmartand_pro_tiptap_editor:
upload:
enabled: true
filesystem_service: 'oneup_flysystem.images_filesystem'
public_url_prefix: '/uploads'
security_attribute: 'ROLE_ADMIN'
max_file_size: 5242880 # 5MB
oneup_flysystem) is configured to handle uploads. The bundle expects a service with writeStream() method.// assets/controllers/besmartand_pro/tiptap_editor_controller.ts
import { MyCustomExtension } from '../extensions/my_custom_extension';
connect() {
this.editor = new Editor({
extensions: [
StarterKit,
Image,
Link,
Placeholder,
MyCustomExtension, // Add your extension
],
});
}
extensions array.assets/styles/besmartand_pro_tiptap_editor.scss:
$tiptap-editor-bg: #f8f9fa;
$tiptap-toolbar-bg: #e9ecef;
.ProseMirror) in your global stylesheet.class CustomTiptapType extends TiptapType {
public function configureOptions(OptionsResolver $resolver) {
$resolver->setDefaults([
'tiptap_storage_format' => 'json', // Store as JSON instead of HTML
]);
}
}
setFormTypeOption to pass options to the underlying TiptapType:
yield TiptapField::new('content')
->setFormTypeOption('tiptap_toolbar', ['bold', 'italic'])
->setFormTypeOption('tiptap_placeholder', 'Custom placeholder...');
assets/app.ts:
import './styles/besmartand_pro_tiptap_editor.scss';
webpack.config.js:
Encore
.addEntry('tiptap-editor', './assets/styles/besmartand_pro_tiptap_editor.scss')
.enableSassLoader();
security_attribute config to restrict uploads to specific roles:
besmartand_pro_tiptap_editor:
upload:
security_attribute: 'ROLE_CONTENT_MANAGER'
Frontend Build Failures:
@tiptap/* dependencies after installation.npm install (or pnpm install) and rebuild assets.package.json for missing dependencies and rerun the installer:
php bin/console besmartand-pro:tiptap-editor:install --force
Stimulus Controller Not Loading:
{{ stimulus_controller('besmartand-pro--tiptap-editor') }}
StimulusController errors and verify the controller file exists at assets/controllers/besmartand_pro/tiptap_editor_controller.ts.Image Uploads Not Working:
upload.enabled: true in config.public_url_prefix is correct and the files are accessible at the given URL.Toolbar Buttons Missing:
link) are not appearing.link for ExtensionLink). Refer to Tiptap’s documentation for valid button names.**EasyAdmin Field Not Rendering
How can I help you explore Laravel packages today?