| 1 |
// eslint-disable-next-line import/named |
| 2 |
import { BlockInstance } from '@wordpress/blocks'; |
| 3 |
import { dispatch } from '@wordpress/data'; |
| 4 |
|
| 5 |
/** |
| 6 |
* Defines typings for some non-exported Gutenberg functions to avoid |
| 7 |
* intellisense errors in function calls. |
| 8 |
* |
| 9 |
* This can be removed once Gutenberg provides typings for these functions. |
| 10 |
* |
| 11 |
* @since 3.12.0 |
| 12 |
*/ |
| 13 |
export interface GutenbergFunction { |
| 14 |
editPost( edits: Record<string, unknown> ): void; |
| 15 |
getBlock( clientId: string ): BlockInstance | null; |
| 16 |
getBlockParents( clientId: string ): string[]; |
| 17 |
getBlocks(): BlockInstance[]; |
| 18 |
getCurrentPostAttribute( attribute: string ): string; |
| 19 |
getCurrentPostId(): number | undefined; |
| 20 |
getEditedPostAttribute( attribute: string ): string; |
| 21 |
getEditedPostContent(): string; |
| 22 |
getPermalink(): string | null; |
| 23 |
getPermalink(): string | null; |
| 24 |
getSelectedBlock(): BlockInstance | null; |
| 25 |
hasMetaBoxes(): boolean; |
| 26 |
isAutosavingPost(): boolean; |
| 27 |
isSavingPost(): boolean; |
| 28 |
lockPostSaving( lockName: string ): void; |
| 29 |
lockPostAutosaving( lockName: string ): void; |
| 30 |
unlockPostAutosaving( lockName: string ): void; |
| 31 |
removeEditorPanel( panelName: string ): void; |
| 32 |
selectBlock( clientId: string, initialPosition?: number ): void; |
| 33 |
unlockPostSaving( lockName: string ): void; |
| 34 |
updateBlockAttributes( clientId: string, attributes: Record<string, unknown> ): void; |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Alias for dispatch( 'core/block-editor' ) calls that prevents intellisense |
| 39 |
* errors. |
| 40 |
* |
| 41 |
* @since 3.16.0 |
| 42 |
*/ |
| 43 |
export const dispatchCoreBlockEditor = dispatch( 'core/block-editor' ) as GutenbergFunction; |
| 44 |
|
| 45 |
/** |
| 46 |
* Alias for dispatch( 'core/editor' ) calls that prevents intellisense errors. |
| 47 |
* |
| 48 |
* @since 3.16.0 |
| 49 |
*/ |
| 50 |
export const dispatchCoreEditor = dispatch( 'core/editor' ) as GutenbergFunction; |
| 51 |
|
| 52 |
/** |
| 53 |
* Alias for dispatch( 'core/edit-post' ) calls that prevents intellisense |
| 54 |
* errors. |
| 55 |
* |
| 56 |
* @since 3.16.0 |
| 57 |
*/ |
| 58 |
export const dispatchCoreEditPost = dispatch( 'core/edit-post' ) as GutenbergFunction; |
| 59 |
|