xref: /plugin/catmenu/parser/CatmenuNode.php (revision 6983cdfd4483215ff5a1e573925c9c612964e790)
1*6983cdfdSLORTET<?php
2*6983cdfdSLORTET
3*6983cdfdSLORTETnamespace dokuwiki\plugin\catmenu\parser;
4*6983cdfdSLORTET
5*6983cdfdSLORTETuse dokuwiki\plugin\prosemirror\parser\Node;
6*6983cdfdSLORTET
7*6983cdfdSLORTETclass CatmenuNode extends Node
8*6983cdfdSLORTET{
9*6983cdfdSLORTET    protected $data;
10*6983cdfdSLORTET    protected $parent;
11*6983cdfdSLORTET
12*6983cdfdSLORTET    public function __construct($data, Node $parent)
13*6983cdfdSLORTET    {
14*6983cdfdSLORTET        $this->data = $data;
15*6983cdfdSLORTET        $this->parent = $parent;
16*6983cdfdSLORTET    }
17*6983cdfdSLORTET
18*6983cdfdSLORTET    public function toSyntax()
19*6983cdfdSLORTET    {
20*6983cdfdSLORTET        $attrs = $this->data['attrs'] ?? [];
21*6983cdfdSLORTET        $syntax = trim((string)($attrs['syntax'] ?? ''));
22*6983cdfdSLORTET        if ($syntax !== '') return $syntax;
23*6983cdfdSLORTET        return '{{catmenu>.}}';
24*6983cdfdSLORTET    }
25*6983cdfdSLORTET}
26