jmsfwk/adf-builder

此包已被废弃,不再维护。未建议替代包。

一个简化遵循 Atlassian 文档格式结构的文档构建的库。

1.0.1 2022-06-01 15:47 UTC

This package is auto-updated.

Last update: 2024-05-29 03:56:59 UTC


README

一个简化遵循 Atlassian 文档格式结构的文档构建的库。

此库基于 pyadf (Python)adf-builder (JavaScript)

安装

使用以下命令安装包

composer require jmsfwk/adf-builder

用法

use Jmsfwk\Adf\Document;

$doc = new Document();
$doc->paragraph()
    ->text('See the ')
    ->link('documention', 'https://example.com')
    ->text(' ')
    ->emoji('smile');

序列化

文档可以以不同的方式序列化

$doc = new Document();
$doc->toJson();      // Returns a compact JSON string
json_encode($doc); // Equivalent to '$doc->toString()'

示例

简单段落

为了得到如下输出

Hello @joe, 请 仔细 阅读以下合同

您将使用

use Jmsfwk\Adf\Document;

$doc = new Document();
$doc->paragraph()
    ->text('Hello ')
    ->mention($id, 'joe')
    ->text(', please ')
    ->em('carefully')
    ->text(' read ')
    ->link('this contract', 'https://www.example.com/contract');