28 lines
650 B
TypeScript
28 lines
650 B
TypeScript
/**
|
|
* External dependencies
|
|
*/
|
|
import { HTMLToMarkdown } from '@automattic/jetpack-ai-client';
|
|
import { getBlockContent } from '@wordpress/blocks';
|
|
/**
|
|
* Types
|
|
*/
|
|
import { BlockHandler } from '../block-handler';
|
|
|
|
const HTMLConverter = new HTMLToMarkdown( { fixes: [ 'paragraph' ] } );
|
|
|
|
export function getParagraphMarkdown( html: string ) {
|
|
return HTMLConverter.render( { content: html } );
|
|
}
|
|
|
|
export class ParagraphHandler extends BlockHandler {
|
|
constructor( clientId: string ) {
|
|
super( clientId, [ 'paragraph' ] );
|
|
}
|
|
|
|
public getContent() {
|
|
const block = this.getBlock();
|
|
|
|
return getParagraphMarkdown( getBlockContent( block ) );
|
|
}
|
|
}
|