定制 sgrigorjev/adf-tools 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sgrigorjev/adf-tools

最新稳定版本:1.2.2

Composer 安装命令:

composer require sgrigorjev/adf-tools

包简介

Atlassian Document Format PHP Tools

README 文档

README

Atlassian Document Format PHP Tools

This repository is a fork of Damien Harper's original repository adf-tools, with the following changes added:

Pull requests to the original repository

If the listed pull requests are accepted by the original library author, this repository will no longer be needed, the original library should be used in that case.

Documentation

Main innovations

Direct node append

In addition to the existing document composition style:

$document = (new Document())
    ->bulletlist()
        ->item()
            ->paragraph()
                ->text('item 1')
            ->end()
        ->end()
        ->item()
            ->paragraph()
                ->text('item 2')
            ->end()
        ->end()
    ->end()
;

An alternative method has been added to directly add nodes for more complex composition:

$document = (new Document())
    ->append(
        (new BulletList())
            ->append(
                (new ListItem())
                    ->append(
                        (new Paragraph())
                            ->append(new Text('item 1'))
                    ),
                (new ListItem())
                    ->append(
                        (new Paragraph())
                            ->append(new Text('item 2'))
                    )
                    
            )
    )
;

In this case, it will be possible to create and append nodes dynamically:

$paragraph = (new Paragraph())->append(new Text('Line 1'));

if (some condition) {
    $paragraph->append(new Text('(doc)', new Link('https://example.com/doc')));
}

$document = (new Document())->append($paragraph);

Extension node

Although element Extension is not described in Atlassian Document Format, in practice it is used in documents for the Confluence. One of the most famous extensions is, for example, the Table of Contents.

A new node type Extension has been added:

$document = (new Document())
    ->extension(
        'default',
        'com.atlassian.confluence.macro.core',
        'toc',
        [
            "macroParams" => [
                "maxLevel" => [
                    "value" => "3"
                ],
                "minLevel" => [
                    "value" => "1"
                ],
                "outline" => [
                    "value" => "false"
                ],
                "printable" => [
                    "value" => "false"
                ],
                "type" => [
                    "value" => "list"
                ]
            ]
        ],
        '123cad9c-95d8-49df-8b99-00886ba0af5d',
    )
;

or using direct node append:

$document = (new Document())
    ->append(
        new Extension(
            'default',
            'com.atlassian.confluence.macro.core',
            'toc',
            [
                "macroParams" => [
                    "maxLevel" => [
                        "value" => "3"
                    ],
                    "minLevel" => [
                        "value" => "1"
                    ],
                    "outline" => [
                        "value" => "false"
                    ],
                    "printable" => [
                        "value" => "false"
                    ],
                    "type" => [
                        "value" => "list"
                    ]
                ]
            ],
            '123cad9c-95d8-49df-8b99-00886ba0af5d',
        )
    )
;

Credits

License

adf-tools is free to use and is licensed under the MIT license

统计信息

  • 总下载量: 192
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 17
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-02