diff --git a/types/wordpress__api-fetch/index.d.ts b/types/wordpress__api-fetch/index.d.ts index 3bd59b6a43..b9de048215 100644 --- a/types/wordpress__api-fetch/index.d.ts +++ b/types/wordpress__api-fetch/index.d.ts @@ -64,6 +64,10 @@ export namespace Schema { type Contextual = T extends 'edit' ? { raw: string; rendered: string } & TAdditional & TEditAdditional : { rendered: string } & TAdditional; + type Decontextualize = { + [k in keyof T]: T[k] extends Contextual ? string : T[k]; + }; + type OpenOrClosed = 'open' | 'closed'; type PostFormat = | 'aside' @@ -117,6 +121,7 @@ export namespace Schema { template: string; title: Contextual; type: string; + [k: string]: unknown; } interface BasePostRevision extends BaseResponse { @@ -447,6 +452,12 @@ export namespace Schema { T extends 'view' ? Pick, ViewKeys.Post> : BasePost; + // prettier-ignore + type PostOrPage = + T extends 'embed' ? Pick, EmbedKeys.Post> & Partial, EmbedKeys.Page>> : + T extends 'view' ? Pick, ViewKeys.Post> & Partial, ViewKeys.Page>> : + BasePost & Partial>; + // prettier-ignore type PostRevision = T extends 'embed' ? Pick, EmbedKeys.PostRevision> : diff --git a/types/wordpress__block-editor/index.d.ts b/types/wordpress__block-editor/index.d.ts index b32ae031c7..cb342b1fef 100644 --- a/types/wordpress__block-editor/index.d.ts +++ b/types/wordpress__block-editor/index.d.ts @@ -81,6 +81,7 @@ export interface EditorInserterItem { * Hueristic that combines frequency and recency. */ frecency: number; + hasChildBlocksWithInserterSupport: boolean; } export interface EditorSelection { diff --git a/types/wordpress__editor/components/autocompleters.d.ts b/types/wordpress__editor/components/autocompleters.d.ts new file mode 100644 index 0000000000..41a1155737 --- /dev/null +++ b/types/wordpress__editor/components/autocompleters.d.ts @@ -0,0 +1,6 @@ +import { Schema } from '@wordpress/api-fetch'; +import { EditorInserterItem } from '@wordpress/block-editor'; +import { Autocomplete } from '@wordpress/components'; + +export const blockAutocompleter: Autocomplete.Completer; +export const userAutocompleter: Autocomplete.Completer; diff --git a/types/wordpress__editor/components/autosave-monitor.d.ts b/types/wordpress__editor/components/autosave-monitor.d.ts new file mode 100644 index 0000000000..ab15b64cba --- /dev/null +++ b/types/wordpress__editor/components/autosave-monitor.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace AutosaveMonitor { + interface Props { + children?: never; + } +} +declare const AutosaveMonitor: ComponentType; + +export default AutosaveMonitor; diff --git a/types/wordpress__editor/components/deprecated.d.ts b/types/wordpress__editor/components/deprecated.d.ts new file mode 100644 index 0000000000..0ed05237c8 --- /dev/null +++ b/types/wordpress__editor/components/deprecated.d.ts @@ -0,0 +1,158 @@ +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const AlignmentToolbar: typeof import('@wordpress/block-editor').AlignmentToolbar; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const Autocomplete: typeof import('@wordpress/block-editor').Autocomplete; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const BlockAlignmentToolbar: typeof import('@wordpress/block-editor').BlockAlignmentToolbar; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const BlockControls: typeof import('@wordpress/block-editor').BlockControls; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const BlockEdit: typeof import('@wordpress/block-editor').BlockEdit; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const BlockEditorKeyboardShortcuts: typeof import('@wordpress/block-editor').BlockEditorKeyboardShortcuts; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const BlockFormatControls: typeof import('@wordpress/block-editor').BlockFormatControls; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const BlockIcon: typeof import('@wordpress/block-editor').BlockIcon; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const BlockInspector: typeof import('@wordpress/block-editor').BlockInspector; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const BlockList: typeof import('@wordpress/block-editor').BlockList; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const BlockMover: typeof import('@wordpress/block-editor').BlockMover; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const BlockNavigationDropdown: typeof import('@wordpress/block-editor').BlockNavigationDropdown; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const BlockSelectionClearer: typeof import('@wordpress/block-editor').BlockSelectionClearer; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const BlockSettingsMenu: typeof import('@wordpress/block-editor').BlockSettingsMenu; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const BlockTitle: typeof import('@wordpress/block-editor').BlockTitle; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const BlockToolbar: typeof import('@wordpress/block-editor').BlockToolbar; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const ColorPalette: typeof import('@wordpress/block-editor').ColorPalette; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const ContrastChecker: typeof import('@wordpress/block-editor').ContrastChecker; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const CopyHandler: typeof import('@wordpress/block-editor').CopyHandler; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const DefaultBlockAppender: typeof import('@wordpress/block-editor').DefaultBlockAppender; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const FontSizePicker: typeof import('@wordpress/block-editor').FontSizePicker; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const InnerBlocks: typeof import('@wordpress/block-editor').InnerBlocks; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const Inserter: typeof import('@wordpress/block-editor').Inserter; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const InspectorAdvancedControls: typeof import('@wordpress/block-editor').InspectorAdvancedControls; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const InspectorControls: typeof import('@wordpress/block-editor').InspectorControls; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const MediaPlaceholder: typeof import('@wordpress/block-editor').MediaPlaceholder; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const MediaUpload: typeof import('@wordpress/block-editor').MediaUpload; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const MediaUploadCheck: typeof import('@wordpress/block-editor').MediaUploadCheck; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const MultiBlocksSwitcher: typeof import('@wordpress/block-editor').MultiBlocksSwitcher; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const MultiSelectScrollIntoView: typeof import('@wordpress/block-editor').MultiSelectScrollIntoView; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const NavigableToolbar: typeof import('@wordpress/block-editor').NavigableToolbar; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const ObserveTyping: typeof import('@wordpress/block-editor').ObserveTyping; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const PanelColorSettings: typeof import('@wordpress/block-editor').PanelColorSettings; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const PlainText: typeof import('@wordpress/block-editor').PlainText; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const PreserveScrollInReorder: typeof import('@wordpress/block-editor').PreserveScrollInReorder; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const RichText: typeof import('@wordpress/block-editor').RichText; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const RichTextShortcut: typeof import('@wordpress/block-editor').RichTextShortcut; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const RichTextToolbarButton: typeof import('@wordpress/block-editor').RichTextToolbarButton; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const SkipToSelectedBlock: typeof import('@wordpress/block-editor').SkipToSelectedBlock; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const URLInput: typeof import('@wordpress/block-editor').URLInput; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const URLInputButton: typeof import('@wordpress/block-editor').URLInputButton; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const URLPopover: typeof import('@wordpress/block-editor').URLPopover; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const Warning: typeof import('@wordpress/block-editor').Warning; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const WritingFlow: typeof import('@wordpress/block-editor').WritingFlow; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const createCustomColorsHOC: typeof import('@wordpress/block-editor').createCustomColorsHOC; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const getColorClassName: typeof import('@wordpress/block-editor').getColorClassName; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const getColorObjectByAttributeValues: typeof import('@wordpress/block-editor').getColorObjectByAttributeValues; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const getColorObjectByColorValue: typeof import('@wordpress/block-editor').getColorObjectByColorValue; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const getFontSize: typeof import('@wordpress/block-editor').getFontSize; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const getFontSizeClass: typeof import('@wordpress/block-editor').getFontSizeClass; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const withColorContext: typeof import('@wordpress/block-editor').withColorContext; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const withColors: typeof import('@wordpress/block-editor').withColors; + +/** @deprecated use import from '@wordpress/block-editor' instead. */ +export const withFontSizes: typeof import('@wordpress/block-editor').withFontSizes; diff --git a/types/wordpress__editor/components/document-outline/check.d.ts b/types/wordpress__editor/components/document-outline/check.d.ts new file mode 100644 index 0000000000..1cc22b494f --- /dev/null +++ b/types/wordpress__editor/components/document-outline/check.d.ts @@ -0,0 +1,10 @@ +import { ComponentType, ReactNode } from '@wordpress/element'; + +declare namespace DocumentOutlineCheck { + interface Props { + children: ReactNode; + } +} +declare const DocumentOutlineCheck: ComponentType; + +export default DocumentOutlineCheck; diff --git a/types/wordpress__editor/components/document-outline/index.d.ts b/types/wordpress__editor/components/document-outline/index.d.ts new file mode 100644 index 0000000000..e0d5c97446 --- /dev/null +++ b/types/wordpress__editor/components/document-outline/index.d.ts @@ -0,0 +1,12 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace DocumentOutline { + interface Props { + children?: never; + hasOutlineItemsDisabled?: boolean; + onSelect(): void; + } +} +declare const DocumentOutline: ComponentType; + +export default DocumentOutline; diff --git a/types/wordpress__editor/components/editor-history/redo.d.ts b/types/wordpress__editor/components/editor-history/redo.d.ts new file mode 100644 index 0000000000..7dd5871e99 --- /dev/null +++ b/types/wordpress__editor/components/editor-history/redo.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace EditorHistoryRedo { + interface Props { + children?: never; + } +} +declare const EditorHistoryRedo: ComponentType; + +export default EditorHistoryRedo; diff --git a/types/wordpress__editor/components/editor-history/undo.d.ts b/types/wordpress__editor/components/editor-history/undo.d.ts new file mode 100644 index 0000000000..bcf3462e4c --- /dev/null +++ b/types/wordpress__editor/components/editor-history/undo.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace EditorHistoryUndo { + interface Props { + children?: never; + } +} +declare const EditorHistoryUndo: ComponentType; + +export default EditorHistoryUndo; diff --git a/types/wordpress__editor/components/editor-notices.d.ts b/types/wordpress__editor/components/editor-notices.d.ts new file mode 100644 index 0000000000..3fb1e6653b --- /dev/null +++ b/types/wordpress__editor/components/editor-notices.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace EditorNotices { + interface Props { + children?: never; + } +} +declare const EditorNotices: ComponentType; + +export default EditorNotices; diff --git a/types/wordpress__editor/components/error-boundary.d.ts b/types/wordpress__editor/components/error-boundary.d.ts new file mode 100644 index 0000000000..6ba895c4b1 --- /dev/null +++ b/types/wordpress__editor/components/error-boundary.d.ts @@ -0,0 +1,11 @@ +import { ComponentType, ReactNode } from '@wordpress/element'; + +declare namespace ErrorBoundary { + interface Props { + children: ReactNode; + onError(): void; + } +} +declare const ErrorBoundary: ComponentType; + +export default ErrorBoundary; diff --git a/types/wordpress__editor/components/global-keyboard-shortcuts/text-editor-shortcuts.d.ts b/types/wordpress__editor/components/global-keyboard-shortcuts/text-editor-shortcuts.d.ts new file mode 100644 index 0000000000..61272eeb49 --- /dev/null +++ b/types/wordpress__editor/components/global-keyboard-shortcuts/text-editor-shortcuts.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace TextEditorGlobalKeyboardShortcuts { + interface Props { + children?: never; + } +} +declare const TextEditorGlobalKeyboardShortcuts: ComponentType; + +export default TextEditorGlobalKeyboardShortcuts; diff --git a/types/wordpress__editor/components/global-keyboard-shortcuts/visual-editor-shortcuts.d.ts b/types/wordpress__editor/components/global-keyboard-shortcuts/visual-editor-shortcuts.d.ts new file mode 100644 index 0000000000..90148900a2 --- /dev/null +++ b/types/wordpress__editor/components/global-keyboard-shortcuts/visual-editor-shortcuts.d.ts @@ -0,0 +1,15 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace VisualEditorGlobalKeyboardShortcuts { + interface Props { + children?: never; + } +} +declare const VisualEditorGlobalKeyboardShortcuts: ComponentType; + +/** + * @deprecated + */ +export const EditorGlobalKeyboardShortcuts: typeof VisualEditorGlobalKeyboardShortcuts; + +export default VisualEditorGlobalKeyboardShortcuts; diff --git a/types/wordpress__editor/components/index.d.ts b/types/wordpress__editor/components/index.d.ts new file mode 100644 index 0000000000..f271f31685 --- /dev/null +++ b/types/wordpress__editor/components/index.d.ts @@ -0,0 +1,64 @@ +// Block Creation Components +export * from './autocompleters'; + +// Post Related Components +export { default as AutosaveMonitor } from './autosave-monitor'; +export { default as DocumentOutline } from './document-outline'; +export { default as DocumentOutlineCheck } from './document-outline/check'; +export { + default as VisualEditorGlobalKeyboardShortcuts, + EditorGlobalKeyboardShortcuts, +} from './global-keyboard-shortcuts/visual-editor-shortcuts'; +export { default as TextEditorGlobalKeyboardShortcuts } from './global-keyboard-shortcuts/text-editor-shortcuts'; +export { default as EditorHistoryRedo } from './editor-history/redo'; +export { default as EditorHistoryUndo } from './editor-history/undo'; +export { default as EditorNotices } from './editor-notices'; +export { default as ErrorBoundary } from './error-boundary'; +export { default as PageAttributesCheck } from './page-attributes/check'; +export { default as PageAttributesOrder } from './page-attributes/order'; +export { default as PageAttributesParent } from './page-attributes/parent'; +export { default as PageTemplate } from './page-attributes/template'; +export { default as PostAuthor } from './post-author'; +export { default as PostAuthorCheck } from './post-author/check'; +export { default as PostComments } from './post-comments'; +export { default as PostExcerpt } from './post-excerpt'; +export { default as PostExcerptCheck } from './post-excerpt/check'; +export { default as PostFeaturedImage } from './post-featured-image'; +export { default as PostFeaturedImageCheck } from './post-featured-image/check'; +export { default as PostFormat } from './post-format'; +export { default as PostFormatCheck } from './post-format/check'; +export { default as PostLastRevision } from './post-last-revision'; +export { default as PostLastRevisionCheck } from './post-last-revision/check'; +export { default as PostLockedModal } from './post-locked-modal'; +export { default as PostPendingStatus } from './post-pending-status'; +export { default as PostPendingStatusCheck } from './post-pending-status/check'; +export { default as PostPingbacks } from './post-pingbacks'; +export { default as PostPreviewButton } from './post-preview-button'; +export { default as PostPublishButton } from './post-publish-button'; +export { default as PostPublishButtonLabel } from './post-publish-button/label'; +export { default as PostPublishPanel } from './post-publish-panel'; +export { default as PostSavedState } from './post-saved-state'; +export { default as PostSchedule } from './post-schedule'; +export { default as PostScheduleCheck } from './post-schedule/check'; +export { default as PostScheduleLabel } from './post-schedule/label'; +export { default as PostSticky } from './post-sticky'; +export { default as PostStickyCheck } from './post-sticky/check'; +export { default as PostSwitchToDraftButton } from './post-switch-to-draft-button'; +export { default as PostTaxonomies } from './post-taxonomies'; +export { default as PostTaxonomiesCheck } from './post-taxonomies/check'; +export { default as PostTextEditor } from './post-text-editor'; +export { default as PostTitle } from './post-title'; +export { default as PostTrash } from './post-trash'; +export { default as PostTrashCheck } from './post-trash/check'; +export { default as PostTypeSupportCheck } from './post-type-support-check'; +export { default as PostVisibility } from './post-visibility'; +export { default as PostVisibilityLabel } from './post-visibility/label'; +export { default as PostVisibilityCheck } from './post-visibility/check'; +export { default as TableOfContents } from './table-of-contents'; +export { default as UnsavedChangesWarning } from './unsaved-changes-warning'; +export { default as WordCount } from './word-count'; + +// State Related Components +export { default as EditorProvider } from './provider'; + +export * from './deprecated'; diff --git a/types/wordpress__editor/components/page-attributes/check.d.ts b/types/wordpress__editor/components/page-attributes/check.d.ts new file mode 100644 index 0000000000..9230c33788 --- /dev/null +++ b/types/wordpress__editor/components/page-attributes/check.d.ts @@ -0,0 +1,10 @@ +import { ComponentType, ReactNode } from '@wordpress/element'; + +declare namespace PageAttributesCheck { + interface Props { + children: ReactNode; + } +} +declare const PageAttributesCheck: ComponentType; + +export default PageAttributesCheck; diff --git a/types/wordpress__editor/components/page-attributes/order.d.ts b/types/wordpress__editor/components/page-attributes/order.d.ts new file mode 100644 index 0000000000..45daefe003 --- /dev/null +++ b/types/wordpress__editor/components/page-attributes/order.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PageAttributesOrder { + interface Props { + children?: never; + } +} +declare const PageAttributesOrder: ComponentType; + +export default PageAttributesOrder; diff --git a/types/wordpress__editor/components/page-attributes/parent.d.ts b/types/wordpress__editor/components/page-attributes/parent.d.ts new file mode 100644 index 0000000000..f672a11ad6 --- /dev/null +++ b/types/wordpress__editor/components/page-attributes/parent.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PageAttributesParent { + interface Props { + children?: never; + } +} +declare const PageAttributesParent: ComponentType; + +export default PageAttributesParent; diff --git a/types/wordpress__editor/components/page-attributes/template.d.ts b/types/wordpress__editor/components/page-attributes/template.d.ts new file mode 100644 index 0000000000..eee72543c6 --- /dev/null +++ b/types/wordpress__editor/components/page-attributes/template.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PageTemplate { + interface Props { + children?: never; + } +} +declare const PageTemplate: ComponentType; + +export default PageTemplate; diff --git a/types/wordpress__editor/components/post-author/check.d.ts b/types/wordpress__editor/components/post-author/check.d.ts new file mode 100644 index 0000000000..07f4ca60c7 --- /dev/null +++ b/types/wordpress__editor/components/post-author/check.d.ts @@ -0,0 +1,10 @@ +import { ComponentType, ReactNode } from '@wordpress/element'; + +declare namespace PostAuthorCheck { + interface Props { + children: ReactNode; + } +} +declare const PostAuthorCheck: ComponentType; + +export default PostAuthorCheck; diff --git a/types/wordpress__editor/components/post-author/index.d.ts b/types/wordpress__editor/components/post-author/index.d.ts new file mode 100644 index 0000000000..1b56e94b78 --- /dev/null +++ b/types/wordpress__editor/components/post-author/index.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostAuthor { + interface Props { + children?: never; + } +} +declare const PostAuthor: ComponentType; + +export default PostAuthor; diff --git a/types/wordpress__editor/components/post-comments.d.ts b/types/wordpress__editor/components/post-comments.d.ts new file mode 100644 index 0000000000..fcd70bd9c6 --- /dev/null +++ b/types/wordpress__editor/components/post-comments.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostComments { + interface Props { + children?: never; + } +} +declare const PostComments: ComponentType; + +export default PostComments; diff --git a/types/wordpress__editor/components/post-excerpt/check.d.ts b/types/wordpress__editor/components/post-excerpt/check.d.ts new file mode 100644 index 0000000000..33d880ee6c --- /dev/null +++ b/types/wordpress__editor/components/post-excerpt/check.d.ts @@ -0,0 +1,11 @@ +import { ComponentType, ReactNode } from '@wordpress/element'; + +declare namespace PostExcerptCheck { + interface Props { + children: ReactNode; + supportKeys?: string | string[]; + } +} +declare const PostExcerptCheck: ComponentType; + +export default PostExcerptCheck; diff --git a/types/wordpress__editor/components/post-excerpt/index.d.ts b/types/wordpress__editor/components/post-excerpt/index.d.ts new file mode 100644 index 0000000000..f5bd8eb49c --- /dev/null +++ b/types/wordpress__editor/components/post-excerpt/index.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostExcerpt { + interface Props { + children?: never; + } +} +declare const PostExcerpt: ComponentType; + +export default PostExcerpt; diff --git a/types/wordpress__editor/components/post-featured-image/check.d.ts b/types/wordpress__editor/components/post-featured-image/check.d.ts new file mode 100644 index 0000000000..9d121fa1bc --- /dev/null +++ b/types/wordpress__editor/components/post-featured-image/check.d.ts @@ -0,0 +1,11 @@ +import { ComponentType, ReactNode } from '@wordpress/element'; + +declare namespace PostFeaturedImageCheck { + interface Props { + children: ReactNode; + supportKeys?: string | string[]; + } +} +declare const PostFeaturedImageCheck: ComponentType; + +export default PostFeaturedImageCheck; diff --git a/types/wordpress__editor/components/post-featured-image/index.d.ts b/types/wordpress__editor/components/post-featured-image/index.d.ts new file mode 100644 index 0000000000..e7ede00106 --- /dev/null +++ b/types/wordpress__editor/components/post-featured-image/index.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostFeaturedImage { + interface Props { + children?: never; + } +} +declare const PostFeaturedImage: ComponentType; + +export default PostFeaturedImage; diff --git a/types/wordpress__editor/components/post-format/check.d.ts b/types/wordpress__editor/components/post-format/check.d.ts new file mode 100644 index 0000000000..9cd17fc893 --- /dev/null +++ b/types/wordpress__editor/components/post-format/check.d.ts @@ -0,0 +1,11 @@ +import { ComponentType, ReactNode } from '@wordpress/element'; + +declare namespace PostFormatCheck { + interface Props { + children: ReactNode; + supportKeys?: string | string[]; + } +} +declare const PostFormatCheck: ComponentType; + +export default PostFormatCheck; diff --git a/types/wordpress__editor/components/post-format/index.d.ts b/types/wordpress__editor/components/post-format/index.d.ts new file mode 100644 index 0000000000..2201755e95 --- /dev/null +++ b/types/wordpress__editor/components/post-format/index.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostFormat { + interface Props { + children?: never; + } +} +declare const PostFormat: ComponentType; + +export default PostFormat; diff --git a/types/wordpress__editor/components/post-last-revision/check.d.ts b/types/wordpress__editor/components/post-last-revision/check.d.ts new file mode 100644 index 0000000000..6d961d1f71 --- /dev/null +++ b/types/wordpress__editor/components/post-last-revision/check.d.ts @@ -0,0 +1,10 @@ +import { ComponentType, ReactNode } from '@wordpress/element'; + +declare namespace PostLastRevisionCheck { + interface Props { + children: ReactNode; + } +} +declare const PostLastRevisionCheck: ComponentType; + +export default PostLastRevisionCheck; diff --git a/types/wordpress__editor/components/post-last-revision/index.d.ts b/types/wordpress__editor/components/post-last-revision/index.d.ts new file mode 100644 index 0000000000..e55736ed0c --- /dev/null +++ b/types/wordpress__editor/components/post-last-revision/index.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostLastRevision { + interface Props { + children?: never; + } +} +declare const PostLastRevision: ComponentType; + +export default PostLastRevision; diff --git a/types/wordpress__editor/components/post-locked-modal.d.ts b/types/wordpress__editor/components/post-locked-modal.d.ts new file mode 100644 index 0000000000..15042bb2a7 --- /dev/null +++ b/types/wordpress__editor/components/post-locked-modal.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostLockedModal { + interface Props { + children?: never; + } +} +declare const PostLockedModal: ComponentType; + +export default PostLockedModal; diff --git a/types/wordpress__editor/components/post-pending-status/check.d.ts b/types/wordpress__editor/components/post-pending-status/check.d.ts new file mode 100644 index 0000000000..93096dbcef --- /dev/null +++ b/types/wordpress__editor/components/post-pending-status/check.d.ts @@ -0,0 +1,10 @@ +import { ComponentType, ReactNode } from '@wordpress/element'; + +declare namespace PostPendingStatusCheck { + interface Props { + children: ReactNode; + } +} +declare const PostPendingStatusCheck: ComponentType; + +export default PostPendingStatusCheck; diff --git a/types/wordpress__editor/components/post-pending-status/index.d.ts b/types/wordpress__editor/components/post-pending-status/index.d.ts new file mode 100644 index 0000000000..ae5cd58b34 --- /dev/null +++ b/types/wordpress__editor/components/post-pending-status/index.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostPendingStatus { + interface Props { + children?: never; + } +} +declare const PostPendingStatus: ComponentType; + +export default PostPendingStatus; diff --git a/types/wordpress__editor/components/post-pingbacks.d.ts b/types/wordpress__editor/components/post-pingbacks.d.ts new file mode 100644 index 0000000000..758b4bda92 --- /dev/null +++ b/types/wordpress__editor/components/post-pingbacks.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostPingbacks { + interface Props { + children?: never; + } +} +declare const PostPingbacks: ComponentType; + +export default PostPingbacks; diff --git a/types/wordpress__editor/components/post-preview-button.d.ts b/types/wordpress__editor/components/post-preview-button.d.ts new file mode 100644 index 0000000000..bdea1c1af5 --- /dev/null +++ b/types/wordpress__editor/components/post-preview-button.d.ts @@ -0,0 +1,12 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostPreviewButton { + interface Props { + children?: never; + forcePreviewLink?: string; + forceIsAutosaveable?: boolean; + } +} +declare const PostPreviewButton: ComponentType; + +export default PostPreviewButton; diff --git a/types/wordpress__editor/components/post-publish-button/index.d.ts b/types/wordpress__editor/components/post-publish-button/index.d.ts new file mode 100644 index 0000000000..82b4d87ddc --- /dev/null +++ b/types/wordpress__editor/components/post-publish-button/index.d.ts @@ -0,0 +1,23 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostPublishButton { + interface BaseProps { + children?: never; + focusOnMount?: boolean; + forceIsDirty?: boolean; + forceIsSaving?: boolean; + isOpen?: boolean; + } + interface SubmitProps extends BaseProps { + isToggle?: false; + onSubmit?(): void; + } + interface ToggleProps extends BaseProps { + isToggle: true; + onToggle(): void; + } + type Props = SubmitProps | ToggleProps; +} +declare const PostPublishButton: ComponentType; + +export default PostPublishButton; diff --git a/types/wordpress__editor/components/post-publish-button/label.d.ts b/types/wordpress__editor/components/post-publish-button/label.d.ts new file mode 100644 index 0000000000..8dbddc53fe --- /dev/null +++ b/types/wordpress__editor/components/post-publish-button/label.d.ts @@ -0,0 +1,11 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostPublishButtonLabel { + interface Props { + children?: never; + forceIsSaving?: boolean; + } +} +declare const PostPublishButtonLabel: ComponentType; + +export default PostPublishButtonLabel; diff --git a/types/wordpress__editor/components/post-publish-panel.d.ts b/types/wordpress__editor/components/post-publish-panel.d.ts new file mode 100644 index 0000000000..d3e45d4ba2 --- /dev/null +++ b/types/wordpress__editor/components/post-publish-panel.d.ts @@ -0,0 +1,15 @@ +import { ComponentType, HTMLProps } from '@wordpress/element'; + +declare namespace PostPublishPanel { + interface Props extends HTMLProps { + children?: never; + onClose(): void; + forceIsDirty?: boolean; + forceIsSaving?: boolean; + PostPublishExtension?: ComponentType; + PrePublishExtension?: ComponentType; + } +} +declare const PostPublishPanel: ComponentType; + +export default PostPublishPanel; diff --git a/types/wordpress__editor/components/post-saved-state.d.ts b/types/wordpress__editor/components/post-saved-state.d.ts new file mode 100644 index 0000000000..cbef85e80e --- /dev/null +++ b/types/wordpress__editor/components/post-saved-state.d.ts @@ -0,0 +1,12 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostSavedState { + interface Props { + children?: never; + forceIsDirty?: boolean; + forceIsSaving?: boolean; + } +} +declare const PostSavedState: ComponentType; + +export default PostSavedState; diff --git a/types/wordpress__editor/components/post-schedule/check.d.ts b/types/wordpress__editor/components/post-schedule/check.d.ts new file mode 100644 index 0000000000..a6550a1bf9 --- /dev/null +++ b/types/wordpress__editor/components/post-schedule/check.d.ts @@ -0,0 +1,10 @@ +import { ComponentType, ReactNode } from '@wordpress/element'; + +declare namespace PostScheduleCheck { + interface Props { + children: ReactNode; + } +} +declare const PostScheduleCheck: ComponentType; + +export default PostScheduleCheck; diff --git a/types/wordpress__editor/components/post-schedule/index.d.ts b/types/wordpress__editor/components/post-schedule/index.d.ts new file mode 100644 index 0000000000..9549099b46 --- /dev/null +++ b/types/wordpress__editor/components/post-schedule/index.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostSchedule { + interface Props { + children?: never; + } +} +declare const PostSchedule: ComponentType; + +export default PostSchedule; diff --git a/types/wordpress__editor/components/post-schedule/label.d.ts b/types/wordpress__editor/components/post-schedule/label.d.ts new file mode 100644 index 0000000000..11021c802e --- /dev/null +++ b/types/wordpress__editor/components/post-schedule/label.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostScheduleLabel { + interface Props { + children?: never; + } +} +declare const PostScheduleLabel: ComponentType; + +export default PostScheduleLabel; diff --git a/types/wordpress__editor/components/post-sticky/check.d.ts b/types/wordpress__editor/components/post-sticky/check.d.ts new file mode 100644 index 0000000000..e05d47998d --- /dev/null +++ b/types/wordpress__editor/components/post-sticky/check.d.ts @@ -0,0 +1,10 @@ +import { ComponentType, ReactNode } from '@wordpress/element'; + +declare namespace PostStickyCheck { + interface Props { + children: ReactNode; + } +} +declare const PostStickyCheck: ComponentType; + +export default PostStickyCheck; diff --git a/types/wordpress__editor/components/post-sticky/index.d.ts b/types/wordpress__editor/components/post-sticky/index.d.ts new file mode 100644 index 0000000000..4fd74e94a6 --- /dev/null +++ b/types/wordpress__editor/components/post-sticky/index.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostSticky { + interface Props { + children?: never; + } +} +declare const PostSticky: ComponentType; + +export default PostSticky; diff --git a/types/wordpress__editor/components/post-switch-to-draft-button.d.ts b/types/wordpress__editor/components/post-switch-to-draft-button.d.ts new file mode 100644 index 0000000000..d7e4a42c56 --- /dev/null +++ b/types/wordpress__editor/components/post-switch-to-draft-button.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostSwitchToDraftButton { + interface Props { + children?: never; + } +} +declare const PostSwitchToDraftButton: ComponentType; + +export default PostSwitchToDraftButton; diff --git a/types/wordpress__editor/components/post-taxonomies/check.d.ts b/types/wordpress__editor/components/post-taxonomies/check.d.ts new file mode 100644 index 0000000000..562031f7fb --- /dev/null +++ b/types/wordpress__editor/components/post-taxonomies/check.d.ts @@ -0,0 +1,10 @@ +import { ComponentType, ReactNode } from '@wordpress/element'; + +declare namespace PostTaxonomiesCheck { + interface Props { + children: ReactNode; + } +} +declare const PostTaxonomiesCheck: ComponentType; + +export default PostTaxonomiesCheck; diff --git a/types/wordpress__editor/components/post-taxonomies/index.d.ts b/types/wordpress__editor/components/post-taxonomies/index.d.ts new file mode 100644 index 0000000000..8e77cb9f15 --- /dev/null +++ b/types/wordpress__editor/components/post-taxonomies/index.d.ts @@ -0,0 +1,12 @@ +import { Schema } from '@wordpress/api-fetch'; +import { ComponentType, ReactNode } from '@wordpress/element'; + +declare namespace PostTaxonomies { + interface Props { + children?: never; + taxonomyWrapper?(content: ReactNode, taxonomy: Schema.Taxonomy<'edit'>): JSX.Element; + } +} +declare const PostTaxonomies: ComponentType; + +export default PostTaxonomies; diff --git a/types/wordpress__editor/components/post-text-editor.d.ts b/types/wordpress__editor/components/post-text-editor.d.ts new file mode 100644 index 0000000000..fc01efb9d0 --- /dev/null +++ b/types/wordpress__editor/components/post-text-editor.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostTextEditor { + interface Props { + children?: never; + } +} +declare const PostTextEditor: ComponentType; + +export default PostTextEditor; diff --git a/types/wordpress__editor/components/post-title.d.ts b/types/wordpress__editor/components/post-title.d.ts new file mode 100644 index 0000000000..933d55be4b --- /dev/null +++ b/types/wordpress__editor/components/post-title.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostTitle { + interface Props { + children?: never; + } +} +declare const PostTitle: ComponentType; + +export default PostTitle; diff --git a/types/wordpress__editor/components/post-trash/check.d.ts b/types/wordpress__editor/components/post-trash/check.d.ts new file mode 100644 index 0000000000..ba9f9f38d5 --- /dev/null +++ b/types/wordpress__editor/components/post-trash/check.d.ts @@ -0,0 +1,10 @@ +import { ComponentType, ReactNode } from '@wordpress/element'; + +declare namespace PostTrashCheck { + interface Props { + children: ReactNode; + } +} +declare const PostTrashCheck: ComponentType; + +export default PostTrashCheck; diff --git a/types/wordpress__editor/components/post-trash/index.d.ts b/types/wordpress__editor/components/post-trash/index.d.ts new file mode 100644 index 0000000000..416fb6029e --- /dev/null +++ b/types/wordpress__editor/components/post-trash/index.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostTrash { + interface Props { + children?: never; + } +} +declare const PostTrash: ComponentType; + +export default PostTrash; diff --git a/types/wordpress__editor/components/post-type-support-check.d.ts b/types/wordpress__editor/components/post-type-support-check.d.ts new file mode 100644 index 0000000000..6258319edb --- /dev/null +++ b/types/wordpress__editor/components/post-type-support-check.d.ts @@ -0,0 +1,11 @@ +import { ComponentType, ReactNode } from '@wordpress/element'; + +declare namespace PostTypeSupportCheck { + interface Props { + children: ReactNode; + supportKeys: string | string[]; + } +} +declare const PostTypeSupportCheck: ComponentType; + +export default PostTypeSupportCheck; diff --git a/types/wordpress__editor/components/post-visibility/check.d.ts b/types/wordpress__editor/components/post-visibility/check.d.ts new file mode 100644 index 0000000000..9036851227 --- /dev/null +++ b/types/wordpress__editor/components/post-visibility/check.d.ts @@ -0,0 +1,14 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostVisibilityCheck { + interface RenderProps { + canEdit: boolean; + } + interface Props { + children?: never; + render(props: RenderProps): JSX.Element; + } +} +declare const PostVisibilityCheck: ComponentType; + +export default PostVisibilityCheck; diff --git a/types/wordpress__editor/components/post-visibility/index.d.ts b/types/wordpress__editor/components/post-visibility/index.d.ts new file mode 100644 index 0000000000..d14ec708c6 --- /dev/null +++ b/types/wordpress__editor/components/post-visibility/index.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostVisibility { + interface Props { + children?: never; + } +} +declare const PostVisibility: ComponentType; + +export default PostVisibility; diff --git a/types/wordpress__editor/components/post-visibility/label.d.ts b/types/wordpress__editor/components/post-visibility/label.d.ts new file mode 100644 index 0000000000..e21387cda9 --- /dev/null +++ b/types/wordpress__editor/components/post-visibility/label.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace PostVisibilityLabel { + interface Props { + children?: never; + } +} +declare const PostVisibilityLabel: ComponentType; + +export default PostVisibilityLabel; diff --git a/types/wordpress__editor/components/provider.d.ts b/types/wordpress__editor/components/provider.d.ts new file mode 100644 index 0000000000..d3a1b2ffb9 --- /dev/null +++ b/types/wordpress__editor/components/provider.d.ts @@ -0,0 +1,17 @@ +import { EditorSettings } from '@wordpress/block-editor'; +import { BlockInstance } from '@wordpress/blocks'; +import { ComponentType, ReactNode } from '@wordpress/element'; + +declare namespace EditorProvider { + interface Props { + children: ReactNode; + blocks?: BlockInstance[]; + initialEdits?: object; + useSubRegistry?: boolean; + settings?: Partial; + post: Record; // FIXME: fix this later on if needed + } +} +declare const EditorProvider: ComponentType; + +export default EditorProvider; diff --git a/types/wordpress__editor/components/table-of-contents.d.ts b/types/wordpress__editor/components/table-of-contents.d.ts new file mode 100644 index 0000000000..5115cf00f5 --- /dev/null +++ b/types/wordpress__editor/components/table-of-contents.d.ts @@ -0,0 +1,11 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace TableOfContents { + interface Props { + children?: never; + hasOutlineItemsDisabled?: boolean; + } +} +declare const TableOfContents: ComponentType; + +export default TableOfContents; diff --git a/types/wordpress__editor/components/unsaved-changes-warning.d.ts b/types/wordpress__editor/components/unsaved-changes-warning.d.ts new file mode 100644 index 0000000000..c6e703ce48 --- /dev/null +++ b/types/wordpress__editor/components/unsaved-changes-warning.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace UnsavedChangesWarning { + interface Props { + children?: never; + } +} +declare const UnsavedChangesWarning: ComponentType; + +export default UnsavedChangesWarning; diff --git a/types/wordpress__editor/components/word-count.d.ts b/types/wordpress__editor/components/word-count.d.ts new file mode 100644 index 0000000000..aae2a59997 --- /dev/null +++ b/types/wordpress__editor/components/word-count.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from '@wordpress/element'; + +declare namespace WordCount { + interface Props { + children?: never; + } +} +declare const WordCount: ComponentType; + +export default WordCount; diff --git a/types/wordpress__editor/index.d.ts b/types/wordpress__editor/index.d.ts new file mode 100644 index 0000000000..05da5a28bd --- /dev/null +++ b/types/wordpress__editor/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for @wordpress/editor 9.4 +// Project: https://github.com/WordPress/gutenberg/tree/master/packages/editor/README.md +// Definitions by: Derek Sifford +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.5 + +import { dispatch, select } from '@wordpress/data'; + +export { storeConfig, transformStyles } from '@wordpress/block-editor'; + +declare module '@wordpress/data' { + function dispatch(key: 'core/editor'): typeof import('./store/actions'); + function select(key: 'core/editor'): typeof import('./store/selectors'); +} + +export * from './components'; +export * from './utils'; diff --git a/types/wordpress__editor/store/actions.d.ts b/types/wordpress__editor/store/actions.d.ts new file mode 100644 index 0000000000..3af87e8abc --- /dev/null +++ b/types/wordpress__editor/store/actions.d.ts @@ -0,0 +1,172 @@ +import { EditorSettings } from '@wordpress/block-editor'; +import { BlockInstance, TemplateArray } from '@wordpress/blocks'; +import { Autosave } from '@wordpress/core-data'; +import { dispatch } from '@wordpress/data'; + +export { + clearSelectedBlock, + enterFormattedText, + exitFormattedText, + hideInsertionPoint, + insertBlock, + insertBlocks, + insertDefaultBlock, + mergeBlocks, + moveBlockToPosition, + moveBlocksDown, + moveBlocksUp, + multiSelect, + receiveBlocks, + removeBlock, + removeBlocks, + replaceBlock, + replaceBlocks, + resetBlocks, + selectBlock, + setTemplateValidity, + showInsertionPoint, + startMultiSelect, + startTyping, + stopMultiSelect, + stopTyping, + synchronizeTemplate, + toggleBlockMode, + toggleSelection, + updateBlock, + updateBlockAttributes, + updateBlockListSettings, +} from '@wordpress/block-editor/store/actions'; + +/** + * Action generator used in signalling that the post should autosave. + * + * @param options - Extra flags to identify the autosave. + */ +export function autosave(options?: Record): IterableIterator; + +/** + * Signals that an undo history record should be created. + */ +export function createUndoLevel(): void; + +/** + * Signals that the user has disabled the publish sidebar. + */ +export function disablePublishSidebar(): void; + +/** + * Signals that attributes of the post have been edited. + * + * @param edits - Post attributes to edit. + */ +export function editPost(edits: Record): void; + +/** + * Signals that the user has enabled the publish sidebar. + */ +export function enablePublishSidebar(): void; + +/** + * Signals that post saving is locked. + * + * @param lockName - The lock name. + */ +export function lockPostSaving(lockName: string): void; + +/** + * Signals that undo history should restore last popped state. + */ +export function redo(): void; + +/** + * Action generator for handling refreshing the current post. + */ +export function refreshPost(): IterableIterator; + +/** + * Signals that the latest autosave of the post has been received, by initialization or autosave. + * + * @deprecated since 5.6. Callers should use the `receiveAutosaves( postId, autosave )` + * selector from the '@wordpress/core-data' package. + * + * @param newAutosave - Autosave post object. + */ +export function resetAutosave(newAutosave: Autosave): IterableIterator; + +/** + * Signals that the blocks have been updated. + * + * @param blocks - Block Array. + * @param options - Optional options. + */ +export function resetEditorBlocks(blocks: BlockInstance[], options?: Record): IterableIterator; + +/** + * Signals that the latest version of the post has been received, either by initialization or save. + * + * @param post - Post object. + */ +export function resetPost(post: Record): void; + +/** + * Action generator for saving the current post in the editor. + */ +export function savePost(options?: Record): IterableIterator; + +/** + * Signals that editor has initialized with the specified post object and editor settings. + * + * @param post - Post object. + * @param edits - Initial edited attributes object. + * @param template - Block Template. + */ +export function setupEditor( + post: Record, + edits?: Record, + template?: TemplateArray +): IterableIterator; + +/** + * Used to setup the editor state when first opening an editor. + * + * @param post - Post object. + */ +export function setupEditorState(post: Record): void; + +/** + * Action generator for trashing the current post in the editor. + */ +export function trashPost(): IterableIterator; + +/** + * Signals that undo history should pop. + */ +export function undo(): void; + +/** + * Signals that post saving is unlocked. + * + * @param lockName - The lock name. + */ +export function unlockPostSaving(lockName: string): void; + +/** + * Signals that the post editor settings have been updated. + * + * @param settings - Updated settings + */ +export function updateEditorSettings(settings: Partial): void; + +/** + * Signals that a patch of updates for the latest version of the post have been received. + * + * @param edits - Updated post fields. + */ +export function updatePost(edits: Record): void; + +/** + * Used to lock the editor. + * + * @param lock - Details about the post lock status, user, and nonce. + */ +export function updatePostLock(lock: EditorSettings['postLock']): void; diff --git a/types/wordpress__editor/store/selectors.d.ts b/types/wordpress__editor/store/selectors.d.ts new file mode 100644 index 0000000000..47bdc60e5a --- /dev/null +++ b/types/wordpress__editor/store/selectors.d.ts @@ -0,0 +1,396 @@ +import { Schema } from '@wordpress/api-fetch'; +import { EditorSettings } from '@wordpress/block-editor'; +import { BlockInstance } from '@wordpress/blocks'; +import { Autosave } from '@wordpress/core-data'; + +export { + canInsertBlockType, + getAdjacentBlockClientId, + getBlock, + getBlockAttributes, + getBlockCount, + getBlockHierarchyRootClientId, + getBlockIndex, + getBlockInsertionPoint, + getBlockListSettings, + getBlockMode, + getBlockName, + getBlockOrder, + getBlockRootClientId, + getBlockSelectionEnd, + getBlockSelectionStart, + getBlocks, + getBlocksByClientId, + getClientIdsOfDescendants, + getClientIdsWithDescendants, + getFirstMultiSelectedBlockClientId, + getGlobalBlockCount, + getInserterItems, + getLastMultiSelectedBlockClientId, + getMultiSelectedBlockClientIds, + getMultiSelectedBlocks, + getMultiSelectedBlocksEndClientId, + getMultiSelectedBlocksStartClientId, + getNextBlockClientId, + getPreviousBlockClientId, + getSelectedBlock, + getSelectedBlockClientId, + getSelectedBlockCount, + getSelectedBlocksInitialCaretPosition, + getTemplate, + getTemplateLock, + hasInserterItems, + hasMultiSelection, + hasSelectedBlock, + hasSelectedInnerBlock, + isAncestorMultiSelected, + isBlockInsertionPointVisible, + isBlockMultiSelected, + isBlockSelected, + isBlockValid, + isBlockWithinSelection, + isCaretWithinFormattedText, + isFirstMultiSelectedBlock, + isMultiSelecting, + isSelectionEnabled, + isTyping, + isValidTemplate, +} from '@wordpress/block-editor/store/selectors'; + +/** + * Returns whether or not the user has the unfiltered_html capability. + * + * @returns Whether the user can or can't post unfiltered HTML. + */ +export function canUserUseUnfilteredHTML(): boolean; + +/** + * Returns `true` if a previous post save was attempted but failed, or `false` otherwise. + * + * @returns Whether the post save failed. + */ +export function didPostSaveRequestFail(): boolean; + +/** + * Returns `true` if a previous post save was attempted successfully, or `false` otherwise. + * + * @returns Whether the post was saved successfully. + */ +export function didPostSaveRequestSucceed(): boolean; + +/** + * Returns the active post lock. + */ +export function getActivePostLock(): string | undefined; + +/** + * Returns the current autosave, or an empty object if one is not set (i.e. if the post has yet to + * be autosaved, or has been saved or published since the last autosave). + * + * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` + * selector from the '@wordpress/core-data' package. + */ +export function getAutosave(): Autosave | {}; + +/** + * Returns an attribute value of the current autosave revision for a post, or an empty object if + * there is no autosave for the post. + * + * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` selector + * from the '@wordpress/core-data' package and access properties on the returned + * autosave object using getPostRawValue. + * + * @param attributeName - Autosave attribute name. + */ +export function getAutosaveAttribute(attributeName: T): Autosave[T] | {}; + +/** + * Returns a set of blocks which are to be used in consideration of the post's generated save + * content. + * + * @returns Filtered set of blocks for save. + */ +export function getBlocksForSerialization(): BlockInstance[]; + +/** + * Returns the post currently being edited in its last known saved state, not including unsaved + * edits. Returns an object containing relevant default post values if the post has not yet been + * saved. + */ +export function getCurrentPost(): Schema.Decontextualize>; + +/** + * Returns an attribute value of the saved post. + * + * @param attributeName - Post attribute name. + */ +export function getCurrentPostAttribute>( + attributeName: T +): Schema.Decontextualize>[T] | undefined; + +/** + * Returns the ID of the post currently being edited. + */ +export function getCurrentPostId(): number; + +/** + * Returns the last revision ID of the post currently being edited, or `null` if the post has no + * revisions. + */ +export function getCurrentPostLastRevisionId(): number | null; + +/** + * Returns the number of revisions of the post currently being edited. + */ +export function getCurrentPostRevisionsCount(): number; + +/** + * Returns the post type of the post currently being edited. + */ +export function getCurrentPostType(): string; + +/** + * Returns a single attribute of the post being edited, preferring the unsaved edit if one exists, + * but falling back to the attribute for the last known saved state of the post. + * + * @param attributeName - Post attribute name. + */ +export function getEditedPostAttribute>( + attributeName: T +): Schema.Decontextualize>[T] | undefined; + +/** + * Returns the content of the post being edited, preferring raw string edit before falling back to + * serialization of block state. + */ +export function getEditedPostContent(): string; + +/** + * Returns the post preview link. + */ +export function getEditedPostPreviewLink(): string | null; + +/** + * Returns the current visibility of the post being edited, preferring the unsaved value if + * different than the saved post. The return value is one of `"private"`, `"password"`, or `"public"`. + */ +export function getEditedPostVisibility(): 'password' | 'private' | 'public'; + +/** + * Return the current block list. + */ +export function getEditorBlocks(): BlockInstance[]; + +/** + * Returns the post editor settings. + */ +export function getEditorSettings(): EditorSettings; + +/** + * Returns the permalink for the post. + * + * @returns The permalink, or `null` if the post is not viewable. + */ +export function getPermalink(): string | null; + +/** + * Returns the permalink for a post, split into it's three parts: the prefix, the postName, and the + * suffix. + * + * @returns An object containing the prefix, postName, and suffix for the permalink, or `null` if + * the post is not viewable. + */ +export function getPermalinkParts(): { postName: string; prefix: string; suffix?: string } | null; + +/** + * Returns any post values which have been changed in the editor but not yet been saved. + * + * @returns Object of key value pairs comprising unsaved edits. + */ +export function getPostEdits(): Partial>>; + +/** + * Returns details about the post lock user. + */ +export function getPostLockUser(): Schema.User | undefined | null; + +/** + * Returns a new reference when edited values have changed. This is useful in inferring where an + * edit has been made between states by comparison of the return values using strict equality. + * + * @example + * ```js + * const hasEditOccurred = ( + * getReferenceByDistinctEdits( beforeState ) !== + * getReferenceByDistinctEdits( afterState ) + * ); + * ``` + * + * @returns A value whose reference will change only when an edit occurs. + */ +export function getReferenceByDistinctEdits(): []; + +/** + * Returns state object prior to a specified optimist transaction ID, or `null` if the transaction + * corresponding to the given ID cannot be found. + * + * @param transactionId - Optimist transaction ID. + * + * @returns Global application state prior to transaction. + */ +export function getStateBeforeOptimisticTransaction(transactionId: object): any; + +/** + * Returns a suggested post format for the current post, inferred only if there is a single block + * within the post and it is of a type known to match a default post format. Returns `null` if the + * format cannot be determined. + */ +export function getSuggestedPostFormat(): string | null; + +/** + * Returns the true if there is an existing autosave, otherwise false. + * + * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` selector + * from the '@wordpress/core-data' package and check for a truthy value. + */ +export function hasAutosave(): boolean; + +/** + * Returns `true` if content includes unsaved changes, or `false` otherwise. + */ +export function hasChangedContent(): boolean; + +/** + * Returns `true` if any future editor history snapshots exist, or `false` otherwise. + */ +export function hasEditorRedo(): boolean; + +/** + * Returns `true` if any past editor history snapshots exist, or `false` otherwise. + */ +export function hasEditorUndo(): boolean; + +/** + * Returns `true` if an optimistic transaction is pending commit, for which the before state + * satisfies the given predicate function. + * + * @param predicate - Function given state, returning `true` if match. + */ +export function inSomeHistory(predicate: (state: Record) => boolean): boolean; + +/** + * Returns `true` if the post is autosaving, or `false` otherwise. + */ +export function isAutosavingPost(): boolean; + +/** + * Returns `true` if there are no unsaved values for the current edit session and if the currently + * edited post is new (has never been saved before). + */ +export function isCleanNewPost(): boolean; + +/** + * Returns `true` if post is pending review. + */ +export function isCurrentPostPending(): boolean; + +/** + * Return `true` if the current post has already been published. + */ +export function isCurrentPostPublished(): boolean; + +/** + * Returns `true` if post is already scheduled. + */ +export function isCurrentPostScheduled(): boolean; + +/** + * Returns `true` if the post can be autosaved, or `false` otherwise. + */ +export function isEditedPostAutosaveable(): boolean; + +/** + * Return `true` if the post being edited is being scheduled. Preferring the unsaved status values. + */ +export function isEditedPostBeingScheduled(): boolean; + +/** + * Returns whether the current post should be considered to have a "floating" date (i.e. that it + * would publish "Immediately" rather than at a set time). + * + * @remarks + * Unlike in the PHP backend, the REST API returns a full date string for posts where the + * 0000-00-00T00:00:00 placeholder is present in the database. To infer that a post is set to + * publish "Immediately" we check whether the date and modified date are the same. + */ +export function isEditedPostDateFloating(): boolean; + +/** + * Returns `true` if there are unsaved values for the current edit session, or `false` if the + * editing state matches the saved or new post. + */ +export function isEditedPostDirty(): boolean; + +/** + * Returns `true` if the edited post has content. A post has content if it has at least one saveable + * block or otherwise has a non-empty content property assigned. + */ +export function isEditedPostEmpty(): boolean; + +/** + * Returns `true` if the currently edited post is yet to be saved, or `false` if the post has been + * saved. + */ +export function isEditedPostNew(): boolean; + +/** + * Return `true` if the post being edited can be published. + */ +export function isEditedPostPublishable(): boolean; + +/** + * Returns `true` if the post can be saved, or `false` otherwise. A post must contain a title, an + * excerpt, or non-empty content to be valid for save. + */ +export function isEditedPostSaveable(): boolean; + +/** + * Returns whether the permalink is editable or not. + */ +export function isPermalinkEditable(): boolean; + +/** + * Returns whether the edition of the post has been taken over. + */ +export function isPostLockTakeover(): boolean; + +/** + * Returns whether the post is locked. + */ +export function isPostLocked(): boolean; + +/** + * Returns whether post saving is locked. + */ +export function isPostSavingLocked(): boolean; + +/** + * Returns `true` if the post is being previewed, or `false` otherwise. + */ +export function isPreviewingPost(): boolean; + +/** + * Returns whether the pre-publish panel should be shown or skipped when the user clicks the + * "publish" button. + */ +export function isPublishSidebarEnabled(): boolean; + +/** + * Returns `true` if the post is being published, or `false` otherwise. + */ +export function isPublishingPost(): boolean; + +/** + * Returns `true` if the post is currently being saved, or `false` otherwise. + */ +export function isSavingPost(): boolean; diff --git a/types/wordpress__editor/tsconfig.json b/types/wordpress__editor/tsconfig.json new file mode 100644 index 0000000000..08eb969749 --- /dev/null +++ b/types/wordpress__editor/tsconfig.json @@ -0,0 +1,95 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["dom", "es6"], + "jsx": "preserve", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@wordpress/api-fetch": ["wordpress__api-fetch"], + "@wordpress/block-editor": ["wordpress__block-editor"], + "@wordpress/block-editor/store/actions": ["wordpress__block-editor/store/actions"], + "@wordpress/block-editor/store/selectors": ["wordpress__block-editor/store/selectors"], + "@wordpress/blocks": ["wordpress__blocks"], + "@wordpress/components": ["wordpress__components"], + "@wordpress/core-data": ["wordpress__core-data"], + "@wordpress/data": ["wordpress__data"], + "@wordpress/editor": ["wordpress__editor"], + "@wordpress/element": ["wordpress__element"], + "@wordpress/keycodes": ["wordpress__keycodes"], + "@wordpress/media-utils": ["wordpress__media-utils"], + "@wordpress/notices": ["wordpress__notices"], + "@wordpress/rich-text": ["wordpress__rich-text"] + } + }, + "files": [ + "components/autocompleters.d.ts", + "components/autosave-monitor.d.ts", + "components/deprecated.d.ts", + "components/document-outline/check.d.ts", + "components/document-outline/index.d.ts", + "components/editor-history/redo.d.ts", + "components/editor-history/undo.d.ts", + "components/editor-notices.d.ts", + "components/error-boundary.d.ts", + "components/global-keyboard-shortcuts/text-editor-shortcuts.d.ts", + "components/global-keyboard-shortcuts/visual-editor-shortcuts.d.ts", + "components/index.d.ts", + "components/page-attributes/check.d.ts", + "components/page-attributes/order.d.ts", + "components/page-attributes/parent.d.ts", + "components/page-attributes/template.d.ts", + "components/post-author/check.d.ts", + "components/post-author/index.d.ts", + "components/post-comments.d.ts", + "components/post-excerpt/check.d.ts", + "components/post-excerpt/index.d.ts", + "components/post-featured-image/check.d.ts", + "components/post-featured-image/index.d.ts", + "components/post-format/check.d.ts", + "components/post-format/index.d.ts", + "components/post-last-revision/check.d.ts", + "components/post-last-revision/index.d.ts", + "components/post-locked-modal.d.ts", + "components/post-pending-status/check.d.ts", + "components/post-pending-status/index.d.ts", + "components/post-pingbacks.d.ts", + "components/post-preview-button.d.ts", + "components/post-publish-button/index.d.ts", + "components/post-publish-button/label.d.ts", + "components/post-publish-panel.d.ts", + "components/post-saved-state.d.ts", + "components/post-schedule/check.d.ts", + "components/post-schedule/index.d.ts", + "components/post-schedule/label.d.ts", + "components/post-sticky/check.d.ts", + "components/post-sticky/index.d.ts", + "components/post-switch-to-draft-button.d.ts", + "components/post-taxonomies/check.d.ts", + "components/post-taxonomies/index.d.ts", + "components/post-text-editor.d.ts", + "components/post-title.d.ts", + "components/post-trash/check.d.ts", + "components/post-trash/index.d.ts", + "components/post-type-support-check.d.ts", + "components/post-visibility/check.d.ts", + "components/post-visibility/index.d.ts", + "components/post-visibility/label.d.ts", + "components/provider.d.ts", + "components/table-of-contents.d.ts", + "components/unsaved-changes-warning.d.ts", + "components/word-count.d.ts", + "index.d.ts", + "store/actions.d.ts", + "store/selectors.d.ts", + "utils/index.d.ts", + "wordpress__editor-tests.tsx" + ] +} diff --git a/types/wordpress__editor/tslint.json b/types/wordpress__editor/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/wordpress__editor/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/wordpress__editor/utils/index.d.ts b/types/wordpress__editor/utils/index.d.ts new file mode 100644 index 0000000000..0db75624af --- /dev/null +++ b/types/wordpress__editor/utils/index.d.ts @@ -0,0 +1,18 @@ +export { uploadMedia as mediaUpload } from '@wordpress/media-utils'; + +/** + * Performs some basic cleanup of a string for use as a post slug + * + * This replicates some of what sanitize_title() does in WordPress core, but is only designed to + * approximate what the slug will be. + * + * Converts whitespace, periods, forward slashes and underscores to hyphens. Converts Latin-1 + * Supplement and Latin Extended-A letters to basic Latin letters. Removes combining diacritical + * marks. Converts remaining string to lowercase. It does not touch octets, HTML entities, or other + * encoded characters. + * + * @param slug - Title or slug to be processed. + * + * @returns Processed string + */ +export function cleanForSlug(slug: string): string; diff --git a/types/wordpress__editor/wordpress__editor-tests.tsx b/types/wordpress__editor/wordpress__editor-tests.tsx new file mode 100644 index 0000000000..52897d3234 --- /dev/null +++ b/types/wordpress__editor/wordpress__editor-tests.tsx @@ -0,0 +1,399 @@ +import { dispatch, select } from '@wordpress/data'; +import * as e from '@wordpress/editor'; + +declare const BLOCK_INSTANCE: import('@wordpress/blocks').BlockInstance; + +// +// Components +// ============================================================================ + +// +// AutosaveMonitor +// +; + +// +// DocumentOutline +// + console.log('selected')} />; + console.log('selected')} hasOutlineItemsDisabled />; + +// +// DocumentOutlineCheck +// +Hello World; + +// +// EditorGlobalKeyboardShortcuts +// +; + +// +// EditorHistoryRedo +// +; + +// +// EditorHistoryUndo +// +; + +// +// EditorNotices +// +; + +// +// ErrorBoundary +// + console.log('error!')}>Hello world; + +// +// PageAttributesCheck +// +Hello world; + +// +// PageAttributesOrder +// +; + +// +// PageAttributesParent +// +; + +// +// PageTemplate +// +; + +// +// PostAuthor +// +; + +// +// PostAuthorCheck +// +Hello world; + +// +// PostComments +// +; + +// +// PostExcerpt +// +; + +// +// PostExcerptCheck +// +Hello world; +Hello world; +Hello world; + +// +// PostFeaturedImage +// +; + +// +// PostFeaturedImageCheck +// +Hello world; +Hello world; +Hello world; + +// +// PostFormat +// +; + +// +// PostFormatCheck +// +Hello world; +Hello world; +Hello world; + +// +// PostLastRevision +// +; + +// +// PostLastRevisionCheck +// +Hello world; + +// +// PostLockedModal +// +; + +// +// PostPendingStatus +// +; + +// +// PostPendingStatusCheck +// +Hello world; + +// +// PostPingbacks +// +; + +// +// PostPreviewButton +// +; +; +; +; + +// +// PostPublishButton +// + console.log('submitted')} forceIsDirty forceIsSaving />; + console.log('toggled')} />; + +// +// PostPublishButtonLabel +// +; +; + +// +// PostPublishPanel +// + console.log('closed')} + PrePublishExtension={() =>

hello world

} + PostPublishExtension={() =>

hello world

} +/>; + console.log('closed')} />; + +// +// PostSavedState +// +; +; + +// +// PostSchedule +// +; + +// +// PostScheduleCheck +// +Hello world; + +// +// PostScheduleLabel +// +; + +// +// PostSticky +// +; + +// +// PostStickyCheck +// +Hello world; + +// +// PostSwitchToDraftButton +// +; + +// +// PostTaxonomies +// +; + ( +
+

{taxonomy.name}

+ {taxonomy.slug} + {content} +
+ )} +/>; + +// +// PostTaxonomiesCheck +// +Hello world; + +// +// PostTextEditor +// +; + +// +// PostTitle +// +; + +// +// PostTrash +// +; + +// +// PostTrashCheck +// +Hello world; + +// +// PostTypeSupportCheck +// +Hello world; +Hello world; + +// +// PostVisibility +// +; + +// +// PostVisibilityCheck +// + ( +
+

{`You ${canEdit ? 'can' : "can't"} edit`}

+
+ )} +/>; + +// +// PostVisibilityLabel +// +; + +// +// TableOfContents +// +; +; + +// +// TextEditorGlobalKeyboardShortcuts +// +; + +// +// UnsavedChangesWarning +// +; + +// +// VisualEditorGlobalKeyboardShortcuts +// +; + +// +// WordCount +// +; + +// +// EditorProvider +// + + Hello World +; + + t && console.log(t)} />; + +// +// Store +// ============================================================================ + +// $ExpectType IterableIterator +dispatch('core/editor').autosave(); +// $ExpectType IterableIterator +dispatch('core/editor').autosave({ foo: true, bar: false }); + +// $ExpectType void +dispatch('core/editor').editPost({ content: 'foo' }); + +// $ExpectType IterableIterator +dispatch('core/editor').resetEditorBlocks([BLOCK_INSTANCE]); +// $ExpectType IterableIterator +dispatch('core/editor').resetEditorBlocks([BLOCK_INSTANCE], { foo: 'bar' }); + +// $ExpectType void +dispatch('core/editor').resetPost({ content: 'foo' }); + +// $ExpectType IterableIterator +dispatch('core/editor').savePost(); +// $ExpectType IterableIterator +dispatch('core/editor').savePost({ content: 'foo' }); + +// $ExpectType IterableIterator +dispatch('core/editor').setupEditor({ content: 'foo' }); +// $ExpectType IterableIterator +dispatch('core/editor').setupEditor({ content: 'foo' }, { content: 'bar' }); +// $ExpectType IterableIterator +dispatch('core/editor').setupEditor({ content: 'foo' }, { content: 'bar' }, [ + ['core/paragraph', {}, [['core/paragraph']]], +]); + +// $ExpectType void +dispatch('core/editor').updateEditorSettings({ codeEditingEnabled: false }); + +// $ExpectType void +dispatch('core/editor').updatePostLock({ isLocked: false, user: null }); + +// $ExpectType string | undefined +select('core/editor').getActivePostLock(); + +// $ExpectType number | {} +select('core/editor').getAutosaveAttribute('author'); + +// $ExpectType Decontextualize & Partial>> +select('core/editor').getCurrentPost(); + +// $ExpectType string | undefined +select('core/editor').getCurrentPostAttribute('content'); +// $ExpectType number | undefined +select('core/editor').getCurrentPostAttribute('author'); +// $ExpectType any[] | undefined +select('core/editor').getCurrentPostAttribute('meta'); +// $ExpectType "open" | "closed" | undefined +select('core/editor').getCurrentPostAttribute('comment_status'); +// $ExpectType number | undefined +select('core/editor').getCurrentPostAttribute('menu_order'); +// $ExpectType unknown +select('core/editor').getCurrentPostAttribute('foo'); + +// $ExpectType EditorSettings +select('core/editor').getEditorSettings(); + +// $ExpectType string | undefined +select('core/editor').getPostEdits().content; +// $ExpectType number | undefined +select('core/editor').getPostEdits().author; +// $ExpectType unknown +select('core/editor').getPostEdits().foo; + +// $ExpectType [] +select('core/editor').getReferenceByDistinctEdits(); + +// $ExpectType boolean +select('core/editor').inSomeHistory(state => state.foo === true);