Skip to content

Commit

Permalink
Merge pull request #22 from spiegeltechlab/support-php7.4-syntax
Browse files Browse the repository at this point in the history
Add PHP 7.4 support
  • Loading branch information
timoisik committed Apr 27, 2023
2 parents 1afc115 + 7dd1e40 commit 3d1ddac
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.0, 8.1]
php: [7.4, 8.0, 8.1]
stability: [prefer-lowest, prefer-stable]
node-version: [16]

Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ You can install the package via composer:
composer require ueberdosis/tiptap-php
```

PHP 7.4 support: The package should work with PHP 7.4, but it requires `spatie/shiki-php` which requires PHP 8.0. You can still install the package though, if you pass `--ignore-platform-reqs`. You just won’t be able to use the `CodeBlockShiki` node then.

## Usage
The PHP package mimics large parts of the JavaScript package. If you know your way around Tiptap, the PHP syntax will feel familiar to you.

Expand Down Expand Up @@ -311,6 +309,8 @@ use Tiptap\Core\Node;
class CustomNode extends Node
{
public static $name = 'customNode';

public static $priority = 100;

public function addOptions()
{
Expand Down Expand Up @@ -349,6 +349,12 @@ class CustomNode extends Node
}
```

#### Extension priority

Extensions are evaluated in the order of descending priority. By default, all Nodes, Marks, and Extensions, have a priority value of `100`.

Priority should be defined when creating a Node extension to match markup that could be matched be other Nodes - an example of this is the [TaskItem Node](src/Nodes/TaskItem.php) which has evaluation priority over the [ListItem Node](src/Nodes/ListItem.php).

## Testing
```bash
composer test
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": "^7.4|^8.0",
"scrivo/highlight.php": "v9.18.1.9",
"spatie/shiki-php": "^1.1"
"spatie/shiki-php": "^1.3"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.5",
Expand Down
6 changes: 1 addition & 5 deletions src/Nodes/CodeBlockShiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ public function renderHTML($node, $HTMLAttributes = [])
}

try {
$content = Shiki::highlight(
code: $code,
language: $language,
theme: 'nord',
);
$content = Shiki::highlight($code, $language, 'nord');
} catch (DomainException $exception) {
$mergedAttributes = HTML::mergeAttributes(
$this->options['HTMLAttributes'],
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/TaskItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class TaskItem extends Node
{
public static $name = 'taskItem';

public static $priority = 1000;

public function addOptions()
{
return [
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/TaskList.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class TaskList extends Node
{
public static $name = 'taskList';

public static $priority = 1000;

public function addOptions()
{
return [
Expand Down

0 comments on commit 3d1ddac

Please sign in to comment.