1<?php 2 3namespace dokuwiki\plugin\prosemirror\parser; 4 5class ParagraphNode extends Node 6{ 7 /** @var TextNode[] */ 8 protected $subnodes = []; 9 10 protected $parent; 11 12 public function __construct($data, Node $parent) 13 { 14 $this->parent = &$parent; 15 16 $previousNode = null; 17 if (empty($data['content'])) { 18 return; 19 } 20 foreach ($data['content'] as $nodeData) { 21 $newNode = self::getSubNode($nodeData, $this, $previousNode); 22 $this->subnodes[] = $newNode; 23 $previousNode = $newNode; 24 } 25 } 26 27 public function toSyntax() 28 { 29 $doc = ''; 30 foreach ($this->subnodes as $subnode) { 31 if ($subnode instanceof \dokuwiki\plugin\prosemirror\parser\ParagraphNode) $doc .= "\n"; 32 $doc .= $subnode->toSyntax(); 33 if ($subnode instanceof \dokuwiki\plugin\prosemirror\parser\ParagraphNode) $doc .= "\n"; 34 } 35 return $doc; 36 } 37} 38