Skip to content

Invalid content type "bulletList" for block node "blockquote" #13

@mzeis

Description

@mzeis

Hi,

First: thank you a lot for this open-sourcing this package! I learned about it by working with https://github.com/lesstif/php-JiraCloud-RESTAPI.

When I fetch issues from Jira Cloud using said library, and I further process them, for some of them, I get an exception like this:

In BlockNode.php line 65:
                                                                  
  [InvalidArgumentException]                                      
  Invalid content type "bulletList" for block node "blockquote".  
                                                                  

Exception trace:
  at /var/www/vendor/damienharper/adf-tools/src/Node/BlockNode.php:65
 DH\Adf\Node\BlockNode->append() at /var/www/vendor/damienharper/adf-tools/src/Node/BlockNode.php:43
 DH\Adf\Node\BlockNode::load() at /var/www/vendor/damienharper/adf-tools/src/Node/BlockNode.php:41
 DH\Adf\Node\BlockNode::load() at /var/www/src/path/to/my/code/Class.php:54
...

Looking at the documentation page referenced in \DH\Adf\Node\Block\Blockquote, in my understanding "bulletList" should be allowed here:

content must contain array of one or more of the following nodes:

Would it be an option to add bulletList (and orderedList, for which I also got an exception) as an allowed content type to Blockquote?

I did a quick test by adding them:

<?php

declare(strict_types=1);

namespace DH\Adf\Node\Block;

use DH\Adf\Builder\BulletListBuilder;
use DH\Adf\Builder\OrderedListBuilder;
use DH\Adf\Builder\ParagraphBuilder;
use DH\Adf\Node\BlockNode;
use JsonSerializable;

/**
 * @see https://developer.atlassian.com/cloud/jira/platform/apis/document/nodes/blockquote
 */
class Blockquote extends BlockNode implements JsonSerializable
{
    use BulletListBuilder;
    use OrderedListBuilder;
    use ParagraphBuilder;

    protected string $type = 'blockquote';
    protected array $allowedContentTypes = [
        BulletList::class,
        OrderedList::class,
        Paragraph::class,
    ];
}

I got no errors, and the result seems to be correct for my use case, too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions