Skip to content

Commit ce52b14

Browse files
committed
Fix mark support in node data helpers
1 parent e0d4c62 commit ce52b14

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 3.0.4 (2025-08-04)
4+
5+
- [fix] Mark support in node data helpers
6+
37
## 3.0.3 (2024-10-16)
48

59
- [fix] Fix undefined property error

docs/helpers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ order: 6
1313

1414
Data helpers are available in the `JackSleight\StatamicBardMutator\Support\Data` namespace.
1515

16-
#### `Data::node($type, $attrs = [], $content = [])`
16+
#### `Data::node($type, $attrs = [], $content = [], $marks = [])`
1717

1818
Creates a new node object.
1919

2020
#### `Data::mark($type, $attrs = [])`
2121

2222
Creates a new mark object.
2323

24-
#### `Data::text($text)`
24+
#### `Data::text($text, $marks = [])`
2525

2626
Creates a new text node object.
2727

28-
#### `Data::html($html|$tag, $attrs = [], $content = [])`
28+
#### `Data::html($html|$tag, $attrs = [], $content = [], $marks = [])`
2929

3030
Creates a new HTML node object.
3131

src/Support/Data.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,21 @@ public static function walk(object $item, Closure $callback): void
4242
]);
4343
}
4444

45-
public static function node(string $type, array $attrs = null, array $content = null): object
45+
public static function node(string $type, ?array $attrs = null, ?array $content = null, ?array $marks = null): object
4646
{
4747
$item = (object) [
4848
'type' => $type,
4949
'attrs' => (object) ($attrs ?? []),
5050
'content' => ($content ?? []),
51+
'marks' => ($marks ?? []),
5152
];
5253

5354
Mutator::setProcessed($item);
5455

5556
return $item;
5657
}
5758

58-
public static function mark(string $type, array $attrs = null): object
59+
public static function mark(string $type, ?array $attrs = null): object
5960
{
6061
$item = (object) [
6162
'type' => $type,
@@ -67,28 +68,31 @@ public static function mark(string $type, array $attrs = null): object
6768
return $item;
6869
}
6970

70-
public static function text(string $text): object
71+
public static function text(string $text, ?array $marks = null): object
7172
{
7273
$item = (object) [
7374
'type' => 'text',
7475
'text' => $text,
76+
'marks' => ($marks ?? []),
7577
];
7678

7779
Mutator::setProcessed($item);
7880

7981
return $item;
8082
}
8183

82-
public static function html(string $html, array $attrs = null, array $content = null): object
84+
public static function html(string $html, ?array $attrs = null, ?array $content = null, ?array $marks = null): object
8385
{
8486
$item = preg_match('/^[a-z][a-z0-9-]*$/i', $html)
8587
? (object) [
8688
'type' => 'bmuHtml',
8789
'render' => [$html, ($attrs ?? []), 0],
8890
'content' => ($content ?? []),
91+
'marks' => ($marks ?? []),
8992
] : (object) [
9093
'type' => 'bmuHtml',
9194
'render' => ['content' => $html],
95+
'marks' => ($attrs ?? []),
9296
];
9397

9498
Mutator::setProcessed($item);

0 commit comments

Comments
 (0)