notion2hast 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 hankei6km
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,387 @@
1
+ # notion2hast
2
+
3
+ [Notion の blocks](https://developers.notion.com/reference/block) を [hast] へ変換。
4
+
5
+ 実装中。
6
+
7
+ ## Installtion
8
+
9
+ ```console
10
+ $ npm install --save notion2hast
11
+ ```
12
+
13
+ ## Security
14
+
15
+ `notion2hast` は信頼できるソースのみを扱う前提で動作します。
16
+
17
+ 第三者からのソースを扱う状況では [`hast-util-sanitize`] の併用を推奨します。
18
+
19
+ ## Usage
20
+
21
+ ### basic
22
+
23
+ ```typescript
24
+ import { Client as NotionClient } from '@notionhq/client'
25
+ import { ClientOptions } from '@notionhq/client/build/src/Client'
26
+ import { toHtml as hastToHtml } from 'hast-util-to-html'
27
+ import { blockToHast } from 'notion2hast'
28
+ import { Client } from 'notion2hast'
29
+
30
+ class FromNotion extends Client {
31
+ private client: NotionClient
32
+ constructor(options?: ClientOptions) {
33
+ super()
34
+ this.client = new NotionClient(options)
35
+ }
36
+ async listBlockChildren(
37
+ ...args: Parameters<NotionClient['blocks']['children']['list']>
38
+ ): Promise<ReturnType<NotionClient['blocks']['children']['list']>> {
39
+ return this.client.blocks.children.list(...args)
40
+ }
41
+ }
42
+
43
+ const apiKey = process.env.API_KEY
44
+ const blockId = process.env.BLOCK_ID
45
+
46
+ const client = new FromNotion({
47
+ auth: apiKey
48
+ })
49
+ const tree = await blockToHast(client, {
50
+ block_id: blockId,
51
+ blocktoHastOpts: { defaultClassName: true },
52
+ richTexttoHastOpts: { defaultClassName: true }
53
+ })
54
+ console.log(`${hastToHtml(tree)}`)
55
+ ```
56
+
57
+ ```html
58
+ <p>最初のパラグラフ。</p>
59
+ <h2>文字装飾</h2>
60
+ <p><strong>太字</strong></p>
61
+ <p><em>italic</em></p>
62
+ <p><s>打消し線</s></p>
63
+ <p><code>code</code></p>
64
+ <h2>リスト</h2>
65
+ <ul>
66
+ <li>項目1</li>
67
+ <li>
68
+ 項目2
69
+ <ul>
70
+ <li>
71
+ 項目2-1
72
+ <ul>
73
+ <li>項目<span style="color: #0b6e99">2-1-1</span></li>
74
+ </ul>
75
+ </li>
76
+ <li>項目2-2</li>
77
+ </ul>
78
+ </li>
79
+ </ul>
80
+ ```
81
+
82
+ ### Custom Client
83
+
84
+ Notions の Client(主に fetch 関連)が利用できない環境では Custom Client を利用可能。
85
+
86
+ 以下、Google Apps Script(clasp) で利用する場合の例。
87
+
88
+ `tohast.ts`
89
+
90
+ ```typescript
91
+ import { Client as NotionClient } from '@notionhq/client'
92
+ import { ClientOptions } from '@notionhq/client/build/src/Client'
93
+ import { toHtml as hastToHtml } from 'hast-util-to-html'
94
+ import { blockToHast } from '@hankei6km/notion2hast'
95
+ import { Client } from '@hankei6km/notion2hast'
96
+ import { listBlockChildren } from './notion'
97
+
98
+ export namespace NotionToHast {
99
+ class FromNotion extends Client {
100
+ //private client: NotionClient;
101
+ private auth: ClientOptions['auth']
102
+ constructor(options?: ClientOptions) {
103
+ super()
104
+ this.auth = options?.auth
105
+ }
106
+ async listBlockChildren(
107
+ ...args: Parameters<NotionClient['blocks']['children']['list']>
108
+ ): Promise<ReturnType<NotionClient['blocks']['children']['list']>> {
109
+ return listBlockChildren(this.auth || '', args[0].block_id) as any
110
+ }
111
+ }
112
+
113
+ export async function toHast(apiKey: string, block_id: string) {
114
+ const client = new FromNotion({ auth: apiKey })
115
+ const tree = await blockToHast(client, {
116
+ block_id,
117
+ blocktoHastOpts: { defaultClassName: true },
118
+ richTexttoHastOpts: { defaultClassName: true }
119
+ })
120
+ console.log(`${hastToHtml(tree)}`)
121
+ }
122
+ }
123
+ ```
124
+
125
+ `notion.ts`
126
+
127
+ ```typescript
128
+ import {
129
+ CreatePageParameters,
130
+ UpdatePageParameters,
131
+ QueryDatabaseParameters,
132
+ QueryDatabaseResponse
133
+ } from '@notionhq/client/build/src/api-endpoints'
134
+
135
+ const apiIUrlCreatePage = 'https://api.notion.com/v1/pages'
136
+ const apiUrlDabtabaseQuery = (database_id: string) =>
137
+ `https://api.notion.com/v1/databases/${database_id}/query`
138
+ const apiUrlUpdatePage = (page_id: string) =>
139
+ `https://api.notion.com/v1/pages/${page_id}`
140
+ const apiUrListBlockChildren = (block_id: string) =>
141
+ `https://api.notion.com/v1/blocks/${block_id}/children`
142
+ const apiVersion = '2022-02-22'
143
+
144
+ export function isErrRes(
145
+ res: GoogleAppsScript.URL_Fetch.HTTPResponse
146
+ ): boolean {
147
+ const code = Math.trunc(res.getResponseCode() / 100)
148
+ if (code === 4 || code === 5) {
149
+ return true
150
+ }
151
+ return false
152
+ }
153
+
154
+ export function listBlockChildren(apiKey: string, block_id: string) {
155
+ const url = apiUrListBlockChildren(block_id)
156
+ try {
157
+ const res = UrlFetchApp.fetch(url, {
158
+ headers: {
159
+ Authorization: `Bearer ${apiKey}`,
160
+ 'Content-Type': 'application/json',
161
+ 'Notion-Version': apiVersion
162
+ },
163
+ muteHttpExceptions: true
164
+ })
165
+ const code = res.getResponseCode()
166
+ if (isErrRes(res)) {
167
+ throw res.getContentText()
168
+ }
169
+ const resQuery = JSON.parse(res.getContentText()) as QueryDatabaseResponse
170
+ return resQuery
171
+ } catch (e) {
172
+ console.log(`${e}`)
173
+ throw e
174
+ }
175
+ }
176
+ ```
177
+
178
+ ### default class name
179
+
180
+ 各要素にデフォルトの class 名を追加。デフォルトのクラス名は properties map の key が使用される。
181
+
182
+ ```typescript
183
+ const client = new FromNotion({
184
+ auth: apiKey,
185
+ blocktoHastOpts: { defaultClassName: true },
186
+ richTexttoHastOpts: { defaultClassName: true }
187
+ })
188
+ ```
189
+
190
+ ```html
191
+ <p class="paragraph">最初のパラグラフ。</p>
192
+ <h2 class="heading-2">文字装飾</h2>
193
+ <p class="paragraph"><strong class="text-bold">太字</strong></p>
194
+ <p class="paragraph"><em class="text-italic">italic</em></p>
195
+ <p class="paragraph"><s class="text-strikethrough">打消し線</s></p>
196
+ <p class="paragraph"><code class="text-code">code</code></p>
197
+ ```
198
+
199
+ ### properties map
200
+
201
+ 指定要素のプロパティを変更。`className` を指定した場合、指定された要素にデフォルト class 名は追加されない。
202
+
203
+ ```typescript
204
+ const client = new FromNotion({
205
+ auth: apiKey,
206
+ blocktoHastOpts: {
207
+ defaultClassName: true,
208
+ blockToHastBuilderOpts: {
209
+ propertiesMap: {
210
+ 'heading-2': { style: 'border: solid;' },
211
+ callout: { className: 'flex' },
212
+ 'callout-paragraph': { className: 'grow' }
213
+ }
214
+ }
215
+ },
216
+ richTexttoHastOpts: { defaultClassName: true }
217
+ })
218
+ ```
219
+
220
+ ```html
221
+ <h2 style="border: solid" class="heading-2">コールアウト</h2>
222
+ <div class="flex" style="background-color: #ebeced">
223
+ <div class="callout-icon-emoji">💡</div>
224
+ <div class="grow">
225
+ <p>コールアウトの<strong class="text-bold">テキスト</strong>。</p>
226
+ </div>
227
+ </div>
228
+ ```
229
+
230
+ ## 対応状況
231
+
232
+ ### Block
233
+
234
+ - [x] paragraph
235
+ - [x] heading_1
236
+ - [x] heading_2
237
+ - [x] heading_3
238
+ - [x] bulleted_list_item
239
+ - [x] numbered_list_item
240
+ - [x] quote
241
+ - [ ] to_do - チェックは properties map で表現
242
+ - [x] toggle
243
+ - [ ] template
244
+ - [ ] synced_block
245
+ - [ ] child_page
246
+ - [ ] child_database
247
+ - [ ] equation
248
+ - [x] code
249
+ - [x] callout
250
+ - [x] divider
251
+ - [ ] breadcrumb
252
+ - [ ] table_of_contents
253
+ - [x] column_list
254
+ - [x] column
255
+ - [ ] link_to_page
256
+ - [x] table
257
+ - [x] table_row
258
+ - [ ] embed
259
+ - [ ] bookmark - `a` タグとして変換
260
+ - [x] image
261
+ - [ ] video
262
+ - [ ] pdf
263
+ - [ ] file
264
+ - [ ] audio
265
+ - [ ] link_preview
266
+ - [ ] unsupported
267
+
268
+ ### rich text
269
+
270
+ - [x] text
271
+ - [x] annotations
272
+ - [x] bold
273
+ - [x] italic
274
+ - [x] strikethrough
275
+ - [x] underline
276
+ - [x] code
277
+ - [x] color
278
+ - [x] href
279
+ - [ ] mention
280
+ - [ ] user
281
+ - [ ] date
282
+ - [ ] link_preview
283
+ - [ ] template_mention
284
+ - [ ] template_mention_date
285
+ - [ ] template_mention_user
286
+ - [ ] page
287
+ - [ ] database
288
+ - [ ] annotations
289
+ - [ ] bold
290
+ - [ ] italic
291
+ - [ ] strikethrough
292
+ - [ ] underline
293
+ - [ ] code
294
+ - [ ] color
295
+ - [ ] href
296
+ - [ ] equation
297
+ - [ ] annotations
298
+ - [ ] bold
299
+ - [ ] italic
300
+ - [ ] strikethrough
301
+ - [ ] underline
302
+ - [ ] code
303
+ - [ ] color
304
+ - [ ] href
305
+
306
+ ## properties mapping
307
+
308
+ ### block
309
+
310
+ - `paragraph`
311
+ - `heading-1`
312
+ - `heading-2`
313
+ - `heading-3`
314
+ - `code`
315
+ - `code-pre`
316
+ - `code-code`
317
+ - `code-caption`
318
+ - `callout`
319
+ - `callout-icon-emoji`
320
+ - `callout-icon-image`
321
+ - `callout-paragraph`
322
+ - `divider`
323
+ - `column-list`
324
+ - `column`
325
+ - `bulleted-list`
326
+ - `bulleted-list-item`
327
+ - `numbered-list`
328
+ - `numbered-list-item`
329
+ - `quote`
330
+ - `todo`
331
+ - `todo-checked`
332
+ - `todo-not-checked`
333
+ - `todo-text`
334
+ - `toggle`
335
+ - `toggle-summary`
336
+ - `table`
337
+ - `table-row`
338
+ - `table-row-cell`
339
+ - `table-row-header`
340
+ - `table-row-header-top-left`
341
+ - `table-row-header-top`
342
+ - `table-row-header-left`
343
+ - `bookmark`
344
+ - `bookmark-link`
345
+ - `bookmark-caption`
346
+ - `image`
347
+ - `image-img`
348
+ - `image-caption`
349
+
350
+ ### rich text
351
+
352
+ - `text-link`
353
+ - `text-bold`
354
+ - `text-code`
355
+ - `text-italic`
356
+ - `text-strikethrough`
357
+ - `text-underline`
358
+
359
+ ### color
360
+
361
+ - `gray`
362
+ - `brown`
363
+ - `orange`
364
+ - `yellow`
365
+ - `green`
366
+ - `blue`
367
+ - `purple`
368
+ - `pink`
369
+ - `red`
370
+ - `gray_background`
371
+ - `brown_background`
372
+ - `orange_background`
373
+ - `yellow_background`
374
+ - `green_background`
375
+ - `blue_background`
376
+ - `purple_background`
377
+ - `pink_background`
378
+ - `red_background`
379
+
380
+ ## ライセンス
381
+
382
+ MIT License
383
+
384
+ Copyright (c) 2022 hankei6km
385
+
386
+ [hast]: (https://github.com/syntax-tree/hast)
387
+ [`hast-util-sanitize`]: https://github.com/syntax-tree/hast-util-sanitize
package/dist/cli.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /// <reference types="node" />
2
+ import { Writable } from 'stream';
3
+ declare type Opts = {
4
+ apiKey: string;
5
+ blockId: string;
6
+ defaultClassName?: boolean;
7
+ toHtml?: boolean;
8
+ stdout: Writable;
9
+ stderr: Writable;
10
+ };
11
+ export declare const cli: ({ apiKey, blockId, defaultClassName, toHtml, stdout, stderr }: Opts) => Promise<number>;
12
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,37 @@
1
+ import { toHtml as hastToHtml } from 'hast-util-to-html';
2
+ import { Client as NotionClient } from '@notionhq/client';
3
+ import { Client } from './lib/client.js';
4
+ import { blockToHast } from './lib/notion2hast.js';
5
+ class CliClient extends Client {
6
+ constructor(options) {
7
+ super();
8
+ this.client = new NotionClient(options);
9
+ }
10
+ async listBlockChildren(...args) {
11
+ return this.client.blocks.children.list(...args);
12
+ }
13
+ }
14
+ export const cli = async ({ apiKey, blockId, defaultClassName, toHtml, stdout, stderr }) => {
15
+ try {
16
+ const client = new CliClient({
17
+ auth: apiKey
18
+ });
19
+ const tree = await blockToHast(client, {
20
+ block_id: blockId,
21
+ blocktoHastOpts: { defaultClassName },
22
+ richTexttoHastOpts: { defaultClassName }
23
+ });
24
+ if (toHtml) {
25
+ stdout.write(`${hastToHtml(tree)}\n`);
26
+ }
27
+ else {
28
+ stdout.write(`${JSON.stringify(tree, null, ' ')}\n`);
29
+ }
30
+ }
31
+ catch (err) {
32
+ stderr.write(err.toString());
33
+ stderr.write('\n');
34
+ return 1;
35
+ }
36
+ return 0;
37
+ };
@@ -0,0 +1,2 @@
1
+ export { blockToHast } from './lib/notion2hast.js';
2
+ export { Client } from './lib/client.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { blockToHast } from './lib/notion2hast.js';
2
+ export { Client } from './lib/client.js';
@@ -0,0 +1,216 @@
1
+ import { HChild, HProperties } from 'hastscript/lib/core';
2
+ import { Block, BlockToHastBuilderOpts, BlockToHastBuilderPropertiesKey, BlockToHastBuilderPropertiesMap, BlockToHastOpts, ToHastOpts } from './types.js';
3
+ import { RichTextToHast } from './richtext.js';
4
+ import { Client } from './client.js';
5
+ import { ColorProps } from './color.js';
6
+ export declare function isBlock(o: any): o is Block;
7
+ export declare class BlockItem {
8
+ private client;
9
+ private opts;
10
+ private blocks;
11
+ private next_cursor;
12
+ private blocksLen;
13
+ private idx;
14
+ constructor(client: Client, opts: ToHastOpts);
15
+ init(): Promise<void>;
16
+ block(): Promise<Block | null>;
17
+ }
18
+ declare type BlockToHastBuilderBuildOpts = {
19
+ block: Block;
20
+ nest: HChild[];
21
+ parent?: Block;
22
+ index: number;
23
+ richTextToHast: RichTextToHast;
24
+ colorProps: ColorProps;
25
+ };
26
+ export declare abstract class BlockToHastBuilder<T> {
27
+ protected blockType: T;
28
+ protected defaultClassname: boolean;
29
+ protected propertiesMap: BlockToHastBuilderPropertiesMap;
30
+ constructor(blockType: T, opts: BlockToHastBuilderOpts);
31
+ protected props(key: BlockToHastBuilderPropertiesKey): HProperties;
32
+ abstract outerTag(): {
33
+ name: string | null;
34
+ properties?: HProperties;
35
+ };
36
+ abstract build(opts: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
37
+ abstract isBreak(prevType: PrevType): boolean;
38
+ }
39
+ export declare class BlockParagraphToHast extends BlockToHastBuilder<'paragraph'> {
40
+ constructor(opts?: BlockToHastBuilderOpts);
41
+ outerTag(): {
42
+ name: string | null;
43
+ properties?: HProperties;
44
+ };
45
+ build({ block, nest, richTextToHast, colorProps }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
46
+ isBreak(_prevType: PrevType): boolean;
47
+ }
48
+ export declare class BlockHeading1ToHast extends BlockToHastBuilder<'heading_1'> {
49
+ constructor(opts?: BlockToHastBuilderOpts);
50
+ outerTag(): {
51
+ name: string | null;
52
+ properties?: HProperties;
53
+ };
54
+ build({ block, nest, richTextToHast, colorProps }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
55
+ isBreak(_prevType: PrevType): boolean;
56
+ }
57
+ export declare class BlockHeading2ToHast extends BlockToHastBuilder<'heading_2'> {
58
+ constructor(opts?: BlockToHastBuilderOpts);
59
+ outerTag(): {
60
+ name: string | null;
61
+ properties?: HProperties;
62
+ };
63
+ build({ block, nest, richTextToHast, colorProps }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
64
+ isBreak(_prevType: PrevType): boolean;
65
+ }
66
+ export declare class BlockHeading3ToHast extends BlockToHastBuilder<'heading_3'> {
67
+ constructor(opts?: BlockToHastBuilderOpts);
68
+ outerTag(): {
69
+ name: string | null;
70
+ properties?: HProperties;
71
+ };
72
+ build({ block, nest, richTextToHast, colorProps }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
73
+ isBreak(_prevType: PrevType): boolean;
74
+ }
75
+ export declare class BlockCodeToHast extends BlockToHastBuilder<'code'> {
76
+ constructor(opts?: BlockToHastBuilderOpts);
77
+ outerTag(): {
78
+ name: string | null;
79
+ properties?: HProperties;
80
+ };
81
+ build({ block, nest, richTextToHast }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
82
+ isBreak(_prevType: PrevType): boolean;
83
+ }
84
+ export declare class BlockCalloutToHast extends BlockToHastBuilder<'callout'> {
85
+ constructor(opts?: BlockToHastBuilderOpts);
86
+ outerTag(): {
87
+ name: string | null;
88
+ properties?: HProperties;
89
+ };
90
+ build({ block, nest, richTextToHast, colorProps }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
91
+ isBreak(_prevType: PrevType): boolean;
92
+ }
93
+ export declare class BlockDividerToHast extends BlockToHastBuilder<'divider'> {
94
+ constructor(opts?: BlockToHastBuilderOpts);
95
+ outerTag(): {
96
+ name: string | null;
97
+ properties?: HProperties;
98
+ };
99
+ build({ block, nest }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
100
+ isBreak(_prevType: PrevType): boolean;
101
+ }
102
+ export declare class BlockColumnListToHast extends BlockToHastBuilder<'column_list'> {
103
+ constructor(opts?: BlockToHastBuilderOpts);
104
+ outerTag(): {
105
+ name: string | null;
106
+ properties?: HProperties;
107
+ };
108
+ build({ block, nest, richTextToHast }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
109
+ isBreak(_prevType: PrevType): boolean;
110
+ }
111
+ export declare class BlockColumnToHast extends BlockToHastBuilder<'column'> {
112
+ constructor(opts?: BlockToHastBuilderOpts);
113
+ outerTag(): {
114
+ name: string | null;
115
+ properties?: HProperties;
116
+ };
117
+ build({ block, nest, richTextToHast }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
118
+ isBreak(_prevType: PrevType): boolean;
119
+ }
120
+ export declare class BlockBulletedListItemToHast extends BlockToHastBuilder<'bulleted_list_item'> {
121
+ constructor(opts?: BlockToHastBuilderOpts);
122
+ outerTag(): {
123
+ name: string | null;
124
+ properties?: HProperties;
125
+ };
126
+ build({ block, nest, richTextToHast, colorProps }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
127
+ isBreak(prevType: PrevType): boolean;
128
+ }
129
+ export declare class BlockNumberedListItemToHast extends BlockToHastBuilder<'numbered_list_item'> {
130
+ constructor(opts?: BlockToHastBuilderOpts);
131
+ outerTag(): {
132
+ name: string | null;
133
+ properties?: HProperties;
134
+ };
135
+ build({ block, nest, richTextToHast, colorProps }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
136
+ isBreak(prevType: PrevType): boolean;
137
+ }
138
+ export declare class BlockQuoteToHast extends BlockToHastBuilder<'quote'> {
139
+ constructor(opts?: BlockToHastBuilderOpts);
140
+ outerTag(): {
141
+ name: string | null;
142
+ properties?: HProperties;
143
+ };
144
+ build({ block, nest, richTextToHast, colorProps }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
145
+ isBreak(_prevType: PrevType): boolean;
146
+ }
147
+ export declare class BlockTodoToHast extends BlockToHastBuilder<'to_do'> {
148
+ constructor(opts?: BlockToHastBuilderOpts);
149
+ outerTag(): {
150
+ name: string | null;
151
+ properties?: HProperties;
152
+ };
153
+ build({ block, nest, richTextToHast, colorProps }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
154
+ isBreak(_prevType: PrevType): boolean;
155
+ }
156
+ export declare class BlockToggleToHast extends BlockToHastBuilder<'toggle'> {
157
+ constructor(opts?: BlockToHastBuilderOpts);
158
+ outerTag(): {
159
+ name: string | null;
160
+ properties?: HProperties;
161
+ };
162
+ build({ block, nest, richTextToHast, colorProps }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
163
+ isBreak(_prevType: PrevType): boolean;
164
+ }
165
+ export declare class BlockTableToHast extends BlockToHastBuilder<'table'> {
166
+ constructor(opts?: BlockToHastBuilderOpts);
167
+ outerTag(): {
168
+ name: string | null;
169
+ properties?: HProperties;
170
+ };
171
+ build({ block, nest, richTextToHast }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
172
+ isBreak(_prevType: PrevType): boolean;
173
+ }
174
+ export declare class BlockTableRowToHast extends BlockToHastBuilder<'table_row'> {
175
+ constructor(opts?: BlockToHastBuilderOpts);
176
+ outerTag(): {
177
+ name: string | null;
178
+ properties?: HProperties;
179
+ };
180
+ build({ block, nest, parent, index, richTextToHast }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
181
+ isBreak(_prevType: PrevType): boolean;
182
+ }
183
+ export declare class BlockBookmarkToHast extends BlockToHastBuilder<'bookmark'> {
184
+ constructor(opts?: BlockToHastBuilderOpts);
185
+ outerTag(): {
186
+ name: string | null;
187
+ properties?: HProperties;
188
+ };
189
+ build({ block, nest, richTextToHast }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
190
+ isBreak(_prevType: PrevType): boolean;
191
+ }
192
+ export declare class BlockImageToHast extends BlockToHastBuilder<'image'> {
193
+ constructor(opts?: BlockToHastBuilderOpts);
194
+ outerTag(): {
195
+ name: string | null;
196
+ properties?: HProperties;
197
+ };
198
+ build({ block, nest, richTextToHast }: BlockToHastBuilderBuildOpts): Promise<HChild[]>;
199
+ isBreak(_prevType: PrevType): boolean;
200
+ }
201
+ declare type PrevType = Block['type'] | undefined | '';
202
+ export declare class SurroundElement {
203
+ private prevType;
204
+ private children;
205
+ private defaultBlockToHastBuilders;
206
+ private blockToHastBuilders;
207
+ constructor(initType: PrevType, opts?: BlockToHastOpts);
208
+ protected builder(blockType: PrevType): BlockToHastBuilder<Block['type']> | undefined;
209
+ append({ block, nest, parent, index, richTextToHast, colorProps }: BlockToHastBuilderBuildOpts): Promise<void>;
210
+ nest(contet: HChild): void;
211
+ outerTag(): ReturnType<BlockToHastBuilder<Block['type']>['outerTag']> | null;
212
+ content(): HChild[];
213
+ isBreak(cur: PrevType): boolean;
214
+ reset(): void;
215
+ }
216
+ export {};