33namespace Medienbaecker \Tiptap ;
44
55use Kirby \Text \KirbyTags ;
6- use Kirby \Uuid \Uuid ;
7- use InvalidArgumentException ;
86
97/**
10- * Processes KirbyTags and UUIDs in Tiptap content
11- * Handles the transformation of KirbyTag text and UUID resolution
8+ * Processes KirbyTags in Tiptap content
9+ * Handles the transformation of KirbyTag text
1210 */
1311class KirbyTagProcessor
1412{
1513 /**
16- * Process content node for KirbyTags and UUIDs
14+ * Process content node for KirbyTags
1715 * @param array $node Node to process (passed by reference)
1816 * @param object $parent Parent page/model for KirbyTag context
1917 * @param bool $allowHtml Whether to allow HTML in text nodes
@@ -33,11 +31,6 @@ public static function processContent(&$node, $parent, $allowHtml = false, $inCo
3331 // Mark text nodes that are inside code blocks
3432 $ node ['_inCodeBlock ' ] = $ inCodeBlock ;
3533
36- // Process UUIDs
37- if (str_contains ($ text , ':// ' )) {
38- $ text = static ::processUuids ($ text );
39- }
40-
4134 // Process KirbyTags
4235 $ parsed = KirbyTags::parse ($ text , ['parent ' => $ parent ]);
4336
@@ -58,23 +51,4 @@ public static function processContent(&$node, $parent, $allowHtml = false, $inCo
5851 }
5952 }
6053 }
61-
62- /**
63- * Process UUIDs in text content
64- * @param string $text Text content to process
65- * @return string Processed text with resolved UUIDs
66- */
67- private static function processUuids ($ text )
68- {
69- return preg_replace_callback ('/(page|file):\/\/[a-zA-Z0-9-]+/ ' , function ($ matches ) {
70- try {
71- if ($ url = Uuid::for ($ matches [0 ])?->model()?->url()) {
72- return $ url ;
73- }
74- } catch (InvalidArgumentException ) {
75- // Ignore invalid UUIDs
76- }
77- return $ matches [0 ];
78- }, $ text );
79- }
8054}
0 commit comments