1. Go to this page and download the library: Download ueberdosis/tiptap-php 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/ */
(new \Tiptap\Editor([
'extensions' => [
new \Tiptap\Extensions\StarterKit([
'codeBlock' => false,
]),
new \Tiptap\Nodes\CodeBlockHighlight(),
],
]))
->setContent('<pre><code><?php phpinfo()</code></pre>')
->getHTML();
// Returns:
// <pre><code class="hljs php"><span class="hljs-meta"><?php</span> phpinfo()</code></pre>
(new \Tiptap\Editor([
'extensions' => [
new \Tiptap\Extensions\StarterKit([
'codeBlock' => false,
]),
new \Tiptap\Nodes\CodeBlockShiki,
],
]))
->setContent('<pre><code><?php phpinfo()</code></pre>')
->getHTML();
(new \Tiptap\Editor([
'extensions' => [
new \Tiptap\Extensions\StarterKit([
'codeBlock' => false,
]),
new \Tiptap\Nodes\CodeBlockShiki([
'theme' => 'github-dark', // default: nord, see https://github.com/shikijs/shiki/blob/main/docs/themes.md
'defaultLanguage' => 'php' // default: html, see https://github.com/shikijs/shiki/blob/main/docs/languages.md
'guessLanguage' => true // default: true, if the language isn’t passed, it tries to guess the language with highlight.php
]),
],
]))
->setContent('<pre><code><?php phpinfo()</code></pre>')
->getHTML();
class CustomBold extends \Tiptap\Marks\Bold
{
public function renderHTML($mark)
{
// Renders <b> instead of <strong>
return ['b', 0]
}
}
new \Tiptap\Editor([
'extensions' => [
new Paragraph,
new Text,
new CustomBold,
],
])
use Tiptap\Core\Node;
class CustomNode extends Node
{
public static $name = 'customNode';
public static $priority = 100;
public function addOptions()
{
return [
'HTMLAttributes' => [],
];
}
public function parseHTML()
{
return [
[
'tag' => 'my-custom-tag[data-id]',
],
[
'tag' => 'my-custom-tag',
'getAttrs' => function ($DOMNode) {
return ! \Tiptap\Utils\InlineStyle::hasAttribute($DOMNode, [
'background-color' => '#000000',
]) ? null : false;
},
],
[
'style' => 'background-color',
'getAttrs' => function ($value) {
return (bool) preg_match('/^(black)$/', $value) ? null : false;
},
],
];
}
public function renderHTML($node)
{
return ['my-custom-tag', ['class' => 'foobar'], 0]
}
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.