[@wordpress/editor] add new definitions (#37141)

* add misc helper types to @wordpress/api-fetch

* [@wordpress/block-editor] add missing property to EditorInserterItem

* [@wordpress/editor] add new definitions

* format files
This commit is contained in:
Derek Sifford 2019-07-26 13:49:17 -04:00 committed by Wesley Wigham
parent a031f03c2c
commit c76ed19786
65 changed files with 1917 additions and 0 deletions

View File

@ -64,6 +64,10 @@ export namespace Schema {
type Contextual<T extends Context, TAdditional = {}, TEditAdditional = {}> = T extends 'edit'
? { raw: string; rendered: string } & TAdditional & TEditAdditional
: { rendered: string } & TAdditional;
type Decontextualize<T> = {
[k in keyof T]: T[k] extends Contextual<any> ? string : T[k];
};
type OpenOrClosed = 'open' | 'closed';
type PostFormat =
| 'aside'
@ -117,6 +121,7 @@ export namespace Schema {
template: string;
title: Contextual<T>;
type: string;
[k: string]: unknown;
}
interface BasePostRevision<T extends Context> extends BaseResponse {
@ -447,6 +452,12 @@ export namespace Schema {
T extends 'view' ? Pick<BasePost<T>, ViewKeys.Post> :
BasePost<T>;
// prettier-ignore
type PostOrPage<T extends Context = 'view'> =
T extends 'embed' ? Pick<BasePost<T>, EmbedKeys.Post> & Partial<Pick<BasePage<T>, EmbedKeys.Page>> :
T extends 'view' ? Pick<BasePost<T>, ViewKeys.Post> & Partial<Pick<BasePage<T>, ViewKeys.Page>> :
BasePost<T> & Partial<BasePage<T>>;
// prettier-ignore
type PostRevision<T extends Context = 'view'> =
T extends 'embed' ? Pick<BasePostRevision<T>, EmbedKeys.PostRevision> :

View File

@ -81,6 +81,7 @@ export interface EditorInserterItem {
* Hueristic that combines frequency and recency.
*/
frecency: number;
hasChildBlocksWithInserterSupport: boolean;
}
export interface EditorSelection {

View File

@ -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<EditorInserterItem>;
export const userAutocompleter: Autocomplete.Completer<Schema.User>;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace AutosaveMonitor {
interface Props {
children?: never;
}
}
declare const AutosaveMonitor: ComponentType<AutosaveMonitor.Props>;
export default AutosaveMonitor;

View File

@ -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;

View File

@ -0,0 +1,10 @@
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace DocumentOutlineCheck {
interface Props {
children: ReactNode;
}
}
declare const DocumentOutlineCheck: ComponentType<DocumentOutlineCheck.Props>;
export default DocumentOutlineCheck;

View File

@ -0,0 +1,12 @@
import { ComponentType } from '@wordpress/element';
declare namespace DocumentOutline {
interface Props {
children?: never;
hasOutlineItemsDisabled?: boolean;
onSelect(): void;
}
}
declare const DocumentOutline: ComponentType<DocumentOutline.Props>;
export default DocumentOutline;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace EditorHistoryRedo {
interface Props {
children?: never;
}
}
declare const EditorHistoryRedo: ComponentType<EditorHistoryRedo.Props>;
export default EditorHistoryRedo;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace EditorHistoryUndo {
interface Props {
children?: never;
}
}
declare const EditorHistoryUndo: ComponentType<EditorHistoryUndo.Props>;
export default EditorHistoryUndo;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace EditorNotices {
interface Props {
children?: never;
}
}
declare const EditorNotices: ComponentType<EditorNotices.Props>;
export default EditorNotices;

View File

@ -0,0 +1,11 @@
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace ErrorBoundary {
interface Props {
children: ReactNode;
onError(): void;
}
}
declare const ErrorBoundary: ComponentType<ErrorBoundary.Props>;
export default ErrorBoundary;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace TextEditorGlobalKeyboardShortcuts {
interface Props {
children?: never;
}
}
declare const TextEditorGlobalKeyboardShortcuts: ComponentType<TextEditorGlobalKeyboardShortcuts.Props>;
export default TextEditorGlobalKeyboardShortcuts;

View File

@ -0,0 +1,15 @@
import { ComponentType } from '@wordpress/element';
declare namespace VisualEditorGlobalKeyboardShortcuts {
interface Props {
children?: never;
}
}
declare const VisualEditorGlobalKeyboardShortcuts: ComponentType<VisualEditorGlobalKeyboardShortcuts.Props>;
/**
* @deprecated
*/
export const EditorGlobalKeyboardShortcuts: typeof VisualEditorGlobalKeyboardShortcuts;
export default VisualEditorGlobalKeyboardShortcuts;

View File

@ -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';

View File

@ -0,0 +1,10 @@
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace PageAttributesCheck {
interface Props {
children: ReactNode;
}
}
declare const PageAttributesCheck: ComponentType<PageAttributesCheck.Props>;
export default PageAttributesCheck;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PageAttributesOrder {
interface Props {
children?: never;
}
}
declare const PageAttributesOrder: ComponentType<PageAttributesOrder.Props>;
export default PageAttributesOrder;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PageAttributesParent {
interface Props {
children?: never;
}
}
declare const PageAttributesParent: ComponentType<PageAttributesParent.Props>;
export default PageAttributesParent;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PageTemplate {
interface Props {
children?: never;
}
}
declare const PageTemplate: ComponentType<PageTemplate.Props>;
export default PageTemplate;

View File

@ -0,0 +1,10 @@
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace PostAuthorCheck {
interface Props {
children: ReactNode;
}
}
declare const PostAuthorCheck: ComponentType<PostAuthorCheck.Props>;
export default PostAuthorCheck;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostAuthor {
interface Props {
children?: never;
}
}
declare const PostAuthor: ComponentType<PostAuthor.Props>;
export default PostAuthor;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostComments {
interface Props {
children?: never;
}
}
declare const PostComments: ComponentType<PostComments.Props>;
export default PostComments;

View File

@ -0,0 +1,11 @@
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace PostExcerptCheck {
interface Props {
children: ReactNode;
supportKeys?: string | string[];
}
}
declare const PostExcerptCheck: ComponentType<PostExcerptCheck.Props>;
export default PostExcerptCheck;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostExcerpt {
interface Props {
children?: never;
}
}
declare const PostExcerpt: ComponentType<PostExcerpt.Props>;
export default PostExcerpt;

View File

@ -0,0 +1,11 @@
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace PostFeaturedImageCheck {
interface Props {
children: ReactNode;
supportKeys?: string | string[];
}
}
declare const PostFeaturedImageCheck: ComponentType<PostFeaturedImageCheck.Props>;
export default PostFeaturedImageCheck;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostFeaturedImage {
interface Props {
children?: never;
}
}
declare const PostFeaturedImage: ComponentType<PostFeaturedImage.Props>;
export default PostFeaturedImage;

View File

@ -0,0 +1,11 @@
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace PostFormatCheck {
interface Props {
children: ReactNode;
supportKeys?: string | string[];
}
}
declare const PostFormatCheck: ComponentType<PostFormatCheck.Props>;
export default PostFormatCheck;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostFormat {
interface Props {
children?: never;
}
}
declare const PostFormat: ComponentType<PostFormat.Props>;
export default PostFormat;

View File

@ -0,0 +1,10 @@
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace PostLastRevisionCheck {
interface Props {
children: ReactNode;
}
}
declare const PostLastRevisionCheck: ComponentType<PostLastRevisionCheck.Props>;
export default PostLastRevisionCheck;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostLastRevision {
interface Props {
children?: never;
}
}
declare const PostLastRevision: ComponentType<PostLastRevision.Props>;
export default PostLastRevision;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostLockedModal {
interface Props {
children?: never;
}
}
declare const PostLockedModal: ComponentType<PostLockedModal.Props>;
export default PostLockedModal;

View File

@ -0,0 +1,10 @@
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace PostPendingStatusCheck {
interface Props {
children: ReactNode;
}
}
declare const PostPendingStatusCheck: ComponentType<PostPendingStatusCheck.Props>;
export default PostPendingStatusCheck;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostPendingStatus {
interface Props {
children?: never;
}
}
declare const PostPendingStatus: ComponentType<PostPendingStatus.Props>;
export default PostPendingStatus;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostPingbacks {
interface Props {
children?: never;
}
}
declare const PostPingbacks: ComponentType<PostPingbacks.Props>;
export default PostPingbacks;

View File

@ -0,0 +1,12 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostPreviewButton {
interface Props {
children?: never;
forcePreviewLink?: string;
forceIsAutosaveable?: boolean;
}
}
declare const PostPreviewButton: ComponentType<PostPreviewButton.Props>;
export default PostPreviewButton;

View File

@ -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<PostPublishButton.Props>;
export default PostPublishButton;

View File

@ -0,0 +1,11 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostPublishButtonLabel {
interface Props {
children?: never;
forceIsSaving?: boolean;
}
}
declare const PostPublishButtonLabel: ComponentType<PostPublishButtonLabel.Props>;
export default PostPublishButtonLabel;

View File

@ -0,0 +1,15 @@
import { ComponentType, HTMLProps } from '@wordpress/element';
declare namespace PostPublishPanel {
interface Props extends HTMLProps<HTMLDivElement> {
children?: never;
onClose(): void;
forceIsDirty?: boolean;
forceIsSaving?: boolean;
PostPublishExtension?: ComponentType;
PrePublishExtension?: ComponentType;
}
}
declare const PostPublishPanel: ComponentType<PostPublishPanel.Props>;
export default PostPublishPanel;

View File

@ -0,0 +1,12 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostSavedState {
interface Props {
children?: never;
forceIsDirty?: boolean;
forceIsSaving?: boolean;
}
}
declare const PostSavedState: ComponentType<PostSavedState.Props>;
export default PostSavedState;

View File

@ -0,0 +1,10 @@
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace PostScheduleCheck {
interface Props {
children: ReactNode;
}
}
declare const PostScheduleCheck: ComponentType<PostScheduleCheck.Props>;
export default PostScheduleCheck;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostSchedule {
interface Props {
children?: never;
}
}
declare const PostSchedule: ComponentType<PostSchedule.Props>;
export default PostSchedule;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostScheduleLabel {
interface Props {
children?: never;
}
}
declare const PostScheduleLabel: ComponentType<PostScheduleLabel.Props>;
export default PostScheduleLabel;

View File

@ -0,0 +1,10 @@
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace PostStickyCheck {
interface Props {
children: ReactNode;
}
}
declare const PostStickyCheck: ComponentType<PostStickyCheck.Props>;
export default PostStickyCheck;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostSticky {
interface Props {
children?: never;
}
}
declare const PostSticky: ComponentType<PostSticky.Props>;
export default PostSticky;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostSwitchToDraftButton {
interface Props {
children?: never;
}
}
declare const PostSwitchToDraftButton: ComponentType<PostSwitchToDraftButton.Props>;
export default PostSwitchToDraftButton;

View File

@ -0,0 +1,10 @@
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace PostTaxonomiesCheck {
interface Props {
children: ReactNode;
}
}
declare const PostTaxonomiesCheck: ComponentType<PostTaxonomiesCheck.Props>;
export default PostTaxonomiesCheck;

View File

@ -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<PostTaxonomies.Props>;
export default PostTaxonomies;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostTextEditor {
interface Props {
children?: never;
}
}
declare const PostTextEditor: ComponentType<PostTextEditor.Props>;
export default PostTextEditor;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostTitle {
interface Props {
children?: never;
}
}
declare const PostTitle: ComponentType<PostTitle.Props>;
export default PostTitle;

View File

@ -0,0 +1,10 @@
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace PostTrashCheck {
interface Props {
children: ReactNode;
}
}
declare const PostTrashCheck: ComponentType<PostTrashCheck.Props>;
export default PostTrashCheck;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostTrash {
interface Props {
children?: never;
}
}
declare const PostTrash: ComponentType<PostTrash.Props>;
export default PostTrash;

View File

@ -0,0 +1,11 @@
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace PostTypeSupportCheck {
interface Props {
children: ReactNode;
supportKeys: string | string[];
}
}
declare const PostTypeSupportCheck: ComponentType<PostTypeSupportCheck.Props>;
export default PostTypeSupportCheck;

View File

@ -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<PostVisibilityCheck.Props>;
export default PostVisibilityCheck;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostVisibility {
interface Props {
children?: never;
}
}
declare const PostVisibility: ComponentType<PostVisibility.Props>;
export default PostVisibility;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace PostVisibilityLabel {
interface Props {
children?: never;
}
}
declare const PostVisibilityLabel: ComponentType<PostVisibilityLabel.Props>;
export default PostVisibilityLabel;

View File

@ -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<EditorSettings>;
post: Record<string, any>; // FIXME: fix this later on if needed
}
}
declare const EditorProvider: ComponentType<EditorProvider.Props>;
export default EditorProvider;

View File

@ -0,0 +1,11 @@
import { ComponentType } from '@wordpress/element';
declare namespace TableOfContents {
interface Props {
children?: never;
hasOutlineItemsDisabled?: boolean;
}
}
declare const TableOfContents: ComponentType<TableOfContents.Props>;
export default TableOfContents;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace UnsavedChangesWarning {
interface Props {
children?: never;
}
}
declare const UnsavedChangesWarning: ComponentType<UnsavedChangesWarning.Props>;
export default UnsavedChangesWarning;

View File

@ -0,0 +1,10 @@
import { ComponentType } from '@wordpress/element';
declare namespace WordCount {
interface Props {
children?: never;
}
}
declare const WordCount: ComponentType<WordCount.Props>;
export default WordCount;

17
types/wordpress__editor/index.d.ts vendored Normal file
View File

@ -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 <https://github.com/dsifford>
// 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';

View File

@ -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<string, boolean>): IterableIterator<void>;
/**
* 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<string, any>): 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<void>;
/**
* 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<void>;
/**
* Signals that the blocks have been updated.
*
* @param blocks - Block Array.
* @param options - Optional options.
*/
export function resetEditorBlocks(blocks: BlockInstance[], options?: Record<string, any>): IterableIterator<void>;
/**
* 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<string, any>): void;
/**
* Action generator for saving the current post in the editor.
*/
export function savePost(options?: Record<string, any>): IterableIterator<void>;
/**
* 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<string, any>,
edits?: Record<string, any>,
template?: TemplateArray
): IterableIterator<void>;
/**
* Used to setup the editor state when first opening an editor.
*
* @param post - Post object.
*/
export function setupEditorState(post: Record<string, any>): void;
/**
* Action generator for trashing the current post in the editor.
*/
export function trashPost(): IterableIterator<void>;
/**
* 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<EditorSettings>): 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<string, any>): void;
/**
* Used to lock the editor.
*
* @param lock - Details about the post lock status, user, and nonce.
*/
export function updatePostLock(lock: EditorSettings['postLock']): void;

View File

@ -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<T extends keyof Autosave>(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<Schema.PostOrPage<'edit'>>;
/**
* Returns an attribute value of the saved post.
*
* @param attributeName - Post attribute name.
*/
export function getCurrentPostAttribute<T extends keyof Schema.PostOrPage<'edit'>>(
attributeName: T
): Schema.Decontextualize<Schema.PostOrPage<'edit'>>[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<T extends keyof Schema.PostOrPage<'edit'>>(
attributeName: T
): Schema.Decontextualize<Schema.PostOrPage<'edit'>>[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<Schema.Decontextualize<Schema.PostOrPage<'edit'>>>;
/**
* 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<string, any>) => 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;

View File

@ -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"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -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;

View File

@ -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
//
<e.AutosaveMonitor />;
//
// DocumentOutline
//
<e.DocumentOutline onSelect={() => console.log('selected')} />;
<e.DocumentOutline onSelect={() => console.log('selected')} hasOutlineItemsDisabled />;
//
// DocumentOutlineCheck
//
<e.DocumentOutlineCheck>Hello World</e.DocumentOutlineCheck>;
//
// EditorGlobalKeyboardShortcuts
//
<e.EditorGlobalKeyboardShortcuts />;
//
// EditorHistoryRedo
//
<e.EditorHistoryRedo />;
//
// EditorHistoryUndo
//
<e.EditorHistoryUndo />;
//
// EditorNotices
//
<e.EditorNotices />;
//
// ErrorBoundary
//
<e.ErrorBoundary onError={() => console.log('error!')}>Hello world</e.ErrorBoundary>;
//
// PageAttributesCheck
//
<e.PageAttributesCheck>Hello world</e.PageAttributesCheck>;
//
// PageAttributesOrder
//
<e.PageAttributesOrder />;
//
// PageAttributesParent
//
<e.PageAttributesParent />;
//
// PageTemplate
//
<e.PageTemplate />;
//
// PostAuthor
//
<e.PostAuthor />;
//
// PostAuthorCheck
//
<e.PostAuthorCheck>Hello world</e.PostAuthorCheck>;
//
// PostComments
//
<e.PostComments />;
//
// PostExcerpt
//
<e.PostExcerpt />;
//
// PostExcerptCheck
//
<e.PostExcerptCheck>Hello world</e.PostExcerptCheck>;
<e.PostExcerptCheck supportKeys="author">Hello world</e.PostExcerptCheck>;
<e.PostExcerptCheck supportKeys={['author', 'thumbnail']}>Hello world</e.PostExcerptCheck>;
//
// PostFeaturedImage
//
<e.PostFeaturedImage />;
//
// PostFeaturedImageCheck
//
<e.PostFeaturedImageCheck>Hello world</e.PostFeaturedImageCheck>;
<e.PostFeaturedImageCheck supportKeys="author">Hello world</e.PostFeaturedImageCheck>;
<e.PostFeaturedImageCheck supportKeys={['author', 'thumbnail']}>Hello world</e.PostFeaturedImageCheck>;
//
// PostFormat
//
<e.PostFormat />;
//
// PostFormatCheck
//
<e.PostFormatCheck>Hello world</e.PostFormatCheck>;
<e.PostFormatCheck supportKeys="author">Hello world</e.PostFormatCheck>;
<e.PostFormatCheck supportKeys={['author', 'thumbnail']}>Hello world</e.PostFormatCheck>;
//
// PostLastRevision
//
<e.PostLastRevision />;
//
// PostLastRevisionCheck
//
<e.PostLastRevisionCheck>Hello world</e.PostLastRevisionCheck>;
//
// PostLockedModal
//
<e.PostLockedModal />;
//
// PostPendingStatus
//
<e.PostPendingStatus />;
//
// PostPendingStatusCheck
//
<e.PostPendingStatusCheck>Hello world</e.PostPendingStatusCheck>;
//
// PostPingbacks
//
<e.PostPingbacks />;
//
// PostPreviewButton
//
<e.PostPreviewButton />;
<e.PostPreviewButton forceIsAutosaveable />;
<e.PostPreviewButton forcePreviewLink="https://foo.bar" />;
<e.PostPreviewButton forcePreviewLink="https://foo.bar" forceIsAutosaveable />;
//
// PostPublishButton
//
<e.PostPublishButton focusOnMount={true} onSubmit={() => console.log('submitted')} forceIsDirty forceIsSaving />;
<e.PostPublishButton forceIsDirty forceIsSaving={false} isOpen isToggle onToggle={() => console.log('toggled')} />;
//
// PostPublishButtonLabel
//
<e.PostPublishButtonLabel />;
<e.PostPublishButtonLabel forceIsSaving />;
//
// PostPublishPanel
//
<e.PostPublishPanel
forceIsDirty
forceIsSaving
className="foo"
aria-hidden={false}
onClose={() => console.log('closed')}
PrePublishExtension={() => <h1>hello world</h1>}
PostPublishExtension={() => <h1>hello world</h1>}
/>;
<e.PostPublishPanel onClose={() => console.log('closed')} />;
//
// PostSavedState
//
<e.PostSavedState />;
<e.PostSavedState forceIsDirty forceIsSaving />;
//
// PostSchedule
//
<e.PostSchedule />;
//
// PostScheduleCheck
//
<e.PostScheduleCheck>Hello world</e.PostScheduleCheck>;
//
// PostScheduleLabel
//
<e.PostScheduleLabel />;
//
// PostSticky
//
<e.PostSticky />;
//
// PostStickyCheck
//
<e.PostStickyCheck>Hello world</e.PostStickyCheck>;
//
// PostSwitchToDraftButton
//
<e.PostSwitchToDraftButton />;
//
// PostTaxonomies
//
<e.PostTaxonomies />;
<e.PostTaxonomies
taxonomyWrapper={(content, taxonomy) => (
<div>
<h1>{taxonomy.name}</h1>
<code>{taxonomy.slug}</code>
{content}
</div>
)}
/>;
//
// PostTaxonomiesCheck
//
<e.PostTaxonomiesCheck>Hello world</e.PostTaxonomiesCheck>;
//
// PostTextEditor
//
<e.PostTextEditor />;
//
// PostTitle
//
<e.PostTitle />;
//
// PostTrash
//
<e.PostTrash />;
//
// PostTrashCheck
//
<e.PostTrashCheck>Hello world</e.PostTrashCheck>;
//
// PostTypeSupportCheck
//
<e.PostTypeSupportCheck supportKeys="author">Hello world</e.PostTypeSupportCheck>;
<e.PostTypeSupportCheck supportKeys={['author', 'thumbnail']}>Hello world</e.PostTypeSupportCheck>;
//
// PostVisibility
//
<e.PostVisibility />;
//
// PostVisibilityCheck
//
<e.PostVisibilityCheck
render={({ canEdit }) => (
<div>
<h1>{`You ${canEdit ? 'can' : "can't"} edit`}</h1>
</div>
)}
/>;
//
// PostVisibilityLabel
//
<e.PostVisibilityLabel />;
//
// TableOfContents
//
<e.TableOfContents />;
<e.TableOfContents hasOutlineItemsDisabled />;
//
// TextEditorGlobalKeyboardShortcuts
//
<e.TextEditorGlobalKeyboardShortcuts />;
//
// UnsavedChangesWarning
//
<e.UnsavedChangesWarning />;
//
// VisualEditorGlobalKeyboardShortcuts
//
<e.VisualEditorGlobalKeyboardShortcuts />;
//
// WordCount
//
<e.WordCount />;
//
// EditorProvider
//
<e.EditorProvider useSubRegistry={false} post={{}}>
Hello World
</e.EditorProvider>;
<e.AlignmentToolbar value="adf" onChange={t => t && console.log(t)} />;
//
// Store
// ============================================================================
// $ExpectType IterableIterator<void>
dispatch('core/editor').autosave();
// $ExpectType IterableIterator<void>
dispatch('core/editor').autosave({ foo: true, bar: false });
// $ExpectType void
dispatch('core/editor').editPost({ content: 'foo' });
// $ExpectType IterableIterator<void>
dispatch('core/editor').resetEditorBlocks([BLOCK_INSTANCE]);
// $ExpectType IterableIterator<void>
dispatch('core/editor').resetEditorBlocks([BLOCK_INSTANCE], { foo: 'bar' });
// $ExpectType void
dispatch('core/editor').resetPost({ content: 'foo' });
// $ExpectType IterableIterator<void>
dispatch('core/editor').savePost();
// $ExpectType IterableIterator<void>
dispatch('core/editor').savePost({ content: 'foo' });
// $ExpectType IterableIterator<void>
dispatch('core/editor').setupEditor({ content: 'foo' });
// $ExpectType IterableIterator<void>
dispatch('core/editor').setupEditor({ content: 'foo' }, { content: 'bar' });
// $ExpectType IterableIterator<void>
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<BasePost<"edit"> & Partial<BasePage<"edit">>>
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);