PHP code example of awcodes / filament-tiptap-editor
1. Go to this page and download the library: Download awcodes/filament-tiptap-editor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
awcodes / filament-tiptap-editor example snippets
use FilamentTiptapEditor\TiptapEditor;
use FilamentTiptapEditor\Enums\TiptapOutput;
TiptapEditor::make('content')
->profile('default|simple|minimal|none|custom')
->tools([]) // individual tools to use in the editor, overwrites profile
->disk('string') // optional, defaults to config setting
->directory('string or Closure returning a string') // optional, defaults to config setting
->acceptedFileTypes(['array of file types']) // optional, defaults to config setting
->maxSize('integer in KB') // optional, defaults to config setting
->output(TiptapOutput::Html) // optional, change the format for saved data, default is html
->maxContentWidth('5xl')
->
use FilamentTiptapEditor\Enums\TiptapOutput;
TiptapEditor::make('content')
->output(FilamentTiptapEditor\TiptapOutput::Json);
use FilamentTiptapEditor\TiptapBlock;
class BatmanBlock extends TiptapBlock
{
public string $preview = 'blocks.previews.batman';
public string $rendered = 'blocks.rendered.batman';
public function getFormSchema(): array
{
return [
TextInput::make('name'),
TextInput::make('color'),
Select::make('side')
->options([
'Hero' => 'Hero',
'Villain' => 'Villain',
])
->default('Hero')
];
}
}
use FilamentTiptapEditor\TiptapBlock;
class StaticBlock extends TiptapBlock
{
public string $preview = 'blocks.previews.static';
public string $rendered = 'blocks.rendered.static';
}
class BatmanBlock extends TiptapBlock
{
public string $width = 'xl';
public bool $slideOver = true;
public ?string $icon = 'heroicon-o-film';
}
use App\TiptapBlocks\BatmanBlock;
use App\TiptapBlocks\StaticBlock;
use FilamentTiptapEditor\TiptapEditor;
TiptapEditor::configureUsing(function (TiptapEditor $component) {
$component
->blocks([
BatmanBlock::class,
StaticBlock::class,
]);
});
use App\TiptapBlocks\BatmanBlock;
use App\TiptapBlocks\StaticBlock;
use FilamentTiptapEditor\TiptapEditor;
TiptapEditor::configureUsing(function (TiptapEditor $component) {
$component
->collapseBlocksPanel()
->blocks([...]);
});