| import { BlockFlow, EditorContext, PublishedPostContext } from '.'; |
|
|
| interface ConfigurationData { |
| text: string; |
| } |
| interface ValidationData { |
| expectedText: string; |
| |
| expectedRole: 'heading' | 'paragraph'; |
| } |
|
|
| |
| |
| |
| export class MarkdownFlow implements BlockFlow { |
| private configurationData: ConfigurationData; |
| private validationData: ValidationData; |
|
|
| |
| |
| |
| |
| |
| |
| constructor( configurationData: ConfigurationData, validationData: ValidationData ) { |
| this.configurationData = configurationData; |
| this.validationData = validationData; |
| } |
|
|
| blockSidebarName = 'Markdown'; |
| blockEditorSelector = 'div[aria-label="Block: Markdown"]'; |
|
|
| |
| |
| |
| |
| |
| |
| async configure( context: EditorContext ): Promise< void > { |
| const textarea = context.addedBlockLocator.getByRole( 'textbox', { name: 'Markdown' } ); |
|
|
| await textarea.fill( this.configurationData.text ); |
|
|
| await context.editorPage.clickBlockToolbarButton( { name: 'Preview' } ); |
| await textarea.waitFor( { state: 'hidden' } ); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| async validateAfterPublish( context: PublishedPostContext ): Promise< void > { |
| await context.page |
| .getByRole( this.validationData.expectedRole, { |
| name: this.validationData.expectedText, |
| exact: true, |
| } ) |
| .waitFor(); |
| } |
| } |
|
|