@wordpress/editor 14.7.1-next.5368f64a9.0 → 14.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +1 -1
- package/build/bindings/post-meta.js +42 -7
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/block-manager/index.js +45 -66
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/document-bar/index.js +20 -28
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/editor-history/redo.js +2 -4
- package/build/components/editor-history/redo.js.map +1 -1
- package/build/components/editor-history/undo.js +2 -4
- package/build/components/editor-history/undo.js.map +1 -1
- package/build/components/editor-interface/index.js +1 -2
- package/build/components/editor-interface/index.js.map +1 -1
- package/build/components/error-boundary/index.js +2 -4
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/global-styles-provider/index.js +21 -12
- package/build/components/global-styles-provider/index.js.map +1 -1
- package/build/components/header/index.js +4 -4
- package/build/components/header/index.js.map +1 -1
- package/build/components/media-categories/index.js +1 -0
- package/build/components/media-categories/index.js.map +1 -1
- package/build/components/post-excerpt/panel.js +2 -5
- package/build/components/post-excerpt/panel.js.map +1 -1
- package/build/components/post-featured-image/index.js +6 -12
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-format/index.js +2 -4
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-last-revision/index.js +2 -4
- package/build/components/post-last-revision/index.js.map +1 -1
- package/build/components/post-locked-modal/index.js +4 -8
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-publish-panel/index.js +2 -4
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-post-format-panel.js +2 -4
- package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.js +2 -4
- package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build/components/post-status/index.js +1 -0
- package/build/components/post-status/index.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +2 -4
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/most-used-terms.js +2 -4
- package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build/components/post-url/index.js +8 -7
- package/build/components/post-url/index.js.map +1 -1
- package/build/components/preview-dropdown/index.js +5 -57
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build/components/save-publish-panels/index.js +4 -10
- package/build/components/save-publish-panels/index.js.map +1 -1
- package/build/components/zoom-out-toggle/index.js +38 -0
- package/build/components/zoom-out-toggle/index.js.map +1 -0
- package/build/dataviews/store/private-actions.js +4 -10
- package/build/dataviews/store/private-actions.js.map +1 -1
- package/build-module/bindings/post-meta.js +40 -7
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/block-manager/index.js +46 -67
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +22 -28
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/editor-history/redo.js +2 -4
- package/build-module/components/editor-history/redo.js.map +1 -1
- package/build-module/components/editor-history/undo.js +2 -4
- package/build-module/components/editor-history/undo.js.map +1 -1
- package/build-module/components/editor-interface/index.js +1 -2
- package/build-module/components/editor-interface/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +2 -4
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/global-styles-provider/index.js +21 -12
- package/build-module/components/global-styles-provider/index.js.map +1 -1
- package/build-module/components/header/index.js +4 -4
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/media-categories/index.js +1 -0
- package/build-module/components/media-categories/index.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +2 -5
- package/build-module/components/post-excerpt/panel.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +6 -12
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-format/index.js +2 -4
- package/build-module/components/post-format/index.js.map +1 -1
- package/build-module/components/post-last-revision/index.js +2 -4
- package/build-module/components/post-last-revision/index.js.map +1 -1
- package/build-module/components/post-locked-modal/index.js +4 -8
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js +2 -4
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js +2 -4
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.js +2 -4
- package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build-module/components/post-status/index.js +1 -0
- package/build-module/components/post-status/index.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +2 -4
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/most-used-terms.js +2 -4
- package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build-module/components/post-url/index.js +9 -8
- package/build-module/components/post-url/index.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +5 -57
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/save-publish-panels/index.js +4 -10
- package/build-module/components/save-publish-panels/index.js.map +1 -1
- package/build-module/components/zoom-out-toggle/index.js +31 -0
- package/build-module/components/zoom-out-toggle/index.js.map +1 -0
- package/build-module/dataviews/store/private-actions.js +2 -8
- package/build-module/dataviews/store/private-actions.js.map +1 -1
- package/build-style/style-rtl.css +38 -23
- package/build-style/style.css +38 -23
- package/build-types/bindings/post-meta.d.ts +4 -1
- package/build-types/bindings/post-meta.d.ts.map +1 -1
- package/build-types/components/block-manager/index.d.ts +1 -2
- package/build-types/components/block-manager/index.d.ts.map +1 -1
- package/build-types/components/document-bar/index.d.ts +7 -6
- package/build-types/components/document-bar/index.d.ts.map +1 -1
- package/build-types/components/editor-history/redo.d.ts.map +1 -1
- package/build-types/components/editor-history/undo.d.ts.map +1 -1
- package/build-types/components/editor-interface/index.d.ts +1 -2
- package/build-types/components/editor-interface/index.d.ts.map +1 -1
- package/build-types/components/error-boundary/index.d.ts.map +1 -1
- package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts +2 -2
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/post-format/index.d.ts.map +1 -1
- package/build-types/components/post-last-revision/index.d.ts.map +1 -1
- package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/index.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-post-format-panel.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-upload-media.d.ts.map +1 -1
- package/build-types/components/post-status/index.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/most-used-terms.d.ts.map +1 -1
- package/build-types/components/post-url/index.d.ts.map +1 -1
- package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
- package/build-types/components/save-publish-panels/index.d.ts.map +1 -1
- package/build-types/components/zoom-out-toggle/index.d.ts +3 -0
- package/build-types/components/zoom-out-toggle/index.d.ts.map +1 -0
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/package.json +37 -36
- package/src/bindings/post-meta.js +56 -20
- package/src/components/block-manager/index.js +50 -67
- package/src/components/document-bar/index.js +29 -41
- package/src/components/document-bar/style.scss +33 -15
- package/src/components/editor-history/redo.js +1 -2
- package/src/components/editor-history/undo.js +1 -2
- package/src/components/editor-interface/index.js +1 -2
- package/src/components/error-boundary/index.js +1 -6
- package/src/components/global-styles-provider/index.js +50 -36
- package/src/components/header/index.js +8 -2
- package/src/components/post-excerpt/panel.js +1 -3
- package/src/components/post-featured-image/index.js +3 -6
- package/src/components/post-featured-image/style.scss +1 -5
- package/src/components/post-format/index.js +1 -2
- package/src/components/post-last-revision/index.js +1 -2
- package/src/components/post-locked-modal/index.js +2 -4
- package/src/components/post-panel-row/style.scss +1 -0
- package/src/components/post-publish-panel/index.js +1 -2
- package/src/components/post-publish-panel/maybe-post-format-panel.js +1 -2
- package/src/components/post-publish-panel/maybe-upload-media.js +1 -2
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
- package/src/components/post-status/index.js +1 -0
- package/src/components/post-status/style.scss +5 -0
- package/src/components/post-taxonomies/hierarchical-term-selector.js +1 -2
- package/src/components/post-taxonomies/most-used-terms.js +1 -2
- package/src/components/post-taxonomies/style.scss +0 -4
- package/src/components/post-url/index.js +9 -7
- package/src/components/preview-dropdown/index.js +26 -84
- package/src/components/save-publish-panels/index.js +2 -6
- package/src/components/zoom-out-toggle/index.js +34 -0
- package/src/dataviews/store/private-actions.ts +10 -8
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/dataviews/actions/duplicate-pattern.js +0 -48
- package/build/dataviews/actions/duplicate-pattern.js.map +0 -1
- package/build/dataviews/actions/duplicate-post.js +0 -146
- package/build/dataviews/actions/duplicate-post.js.map +0 -1
- package/build/dataviews/actions/duplicate-post.native.js +0 -9
- package/build/dataviews/actions/duplicate-post.native.js.map +0 -1
- package/build/dataviews/actions/export-pattern.js +0 -57
- package/build/dataviews/actions/export-pattern.js.map +0 -1
- package/build/dataviews/actions/export-pattern.native.js +0 -9
- package/build/dataviews/actions/export-pattern.native.js.map +0 -1
- package/build/dataviews/actions/permanently-delete-post.js +0 -109
- package/build/dataviews/actions/permanently-delete-post.js.map +0 -1
- package/build/dataviews/actions/reorder-page.js +0 -116
- package/build/dataviews/actions/reorder-page.js.map +0 -1
- package/build/dataviews/actions/reorder-page.native.js +0 -9
- package/build/dataviews/actions/reorder-page.native.js.map +0 -1
- package/build/dataviews/actions/view-post-revisions.js +0 -49
- package/build/dataviews/actions/view-post-revisions.js.map +0 -1
- package/build/dataviews/actions/view-post.js +0 -36
- package/build/dataviews/actions/view-post.js.map +0 -1
- package/build-module/dataviews/actions/duplicate-pattern.js +0 -39
- package/build-module/dataviews/actions/duplicate-pattern.js.map +0 -1
- package/build-module/dataviews/actions/duplicate-post.js +0 -139
- package/build-module/dataviews/actions/duplicate-post.js.map +0 -1
- package/build-module/dataviews/actions/duplicate-post.native.js +0 -3
- package/build-module/dataviews/actions/duplicate-post.native.js.map +0 -1
- package/build-module/dataviews/actions/export-pattern.js +0 -51
- package/build-module/dataviews/actions/export-pattern.js.map +0 -1
- package/build-module/dataviews/actions/export-pattern.native.js +0 -3
- package/build-module/dataviews/actions/export-pattern.native.js.map +0 -1
- package/build-module/dataviews/actions/permanently-delete-post.js +0 -102
- package/build-module/dataviews/actions/permanently-delete-post.js.map +0 -1
- package/build-module/dataviews/actions/reorder-page.js +0 -111
- package/build-module/dataviews/actions/reorder-page.js.map +0 -1
- package/build-module/dataviews/actions/reorder-page.native.js +0 -3
- package/build-module/dataviews/actions/reorder-page.native.js.map +0 -1
- package/build-module/dataviews/actions/view-post-revisions.js +0 -43
- package/build-module/dataviews/actions/view-post-revisions.js.map +0 -1
- package/build-module/dataviews/actions/view-post.js +0 -30
- package/build-module/dataviews/actions/view-post.js.map +0 -1
- package/build-types/dataviews/actions/duplicate-pattern.d.ts +0 -5
- package/build-types/dataviews/actions/duplicate-pattern.d.ts.map +0 -1
- package/build-types/dataviews/actions/duplicate-post.d.ts +0 -5
- package/build-types/dataviews/actions/duplicate-post.d.ts.map +0 -1
- package/build-types/dataviews/actions/duplicate-post.native.d.ts +0 -3
- package/build-types/dataviews/actions/duplicate-post.native.d.ts.map +0 -1
- package/build-types/dataviews/actions/export-pattern.d.ts +0 -8
- package/build-types/dataviews/actions/export-pattern.d.ts.map +0 -1
- package/build-types/dataviews/actions/export-pattern.native.d.ts +0 -3
- package/build-types/dataviews/actions/export-pattern.native.d.ts.map +0 -1
- package/build-types/dataviews/actions/permanently-delete-post.d.ts +0 -5
- package/build-types/dataviews/actions/permanently-delete-post.d.ts.map +0 -1
- package/build-types/dataviews/actions/reorder-page.d.ts +0 -8
- package/build-types/dataviews/actions/reorder-page.d.ts.map +0 -1
- package/build-types/dataviews/actions/reorder-page.native.d.ts +0 -3
- package/build-types/dataviews/actions/reorder-page.native.d.ts.map +0 -1
- package/build-types/dataviews/actions/view-post-revisions.d.ts +0 -8
- package/build-types/dataviews/actions/view-post-revisions.d.ts.map +0 -1
- package/build-types/dataviews/actions/view-post.d.ts +0 -8
- package/build-types/dataviews/actions/view-post.d.ts.map +0 -1
- package/src/dataviews/actions/duplicate-pattern.tsx +0 -40
- package/src/dataviews/actions/duplicate-post.native.tsx +0 -3
- package/src/dataviews/actions/duplicate-post.tsx +0 -174
- package/src/dataviews/actions/export-pattern.native.tsx +0 -3
- package/src/dataviews/actions/export-pattern.tsx +0 -76
- package/src/dataviews/actions/permanently-delete-post.tsx +0 -118
- package/src/dataviews/actions/reorder-page.native.tsx +0 -3
- package/src/dataviews/actions/reorder-page.tsx +0 -125
- package/src/dataviews/actions/view-post-revisions.tsx +0 -47
- package/src/dataviews/actions/view-post.tsx +0 -30
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useDispatch } from '@wordpress/data';
|
|
5
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
-
import { __ } from '@wordpress/i18n';
|
|
7
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
8
|
-
import { useState } from '@wordpress/element';
|
|
9
|
-
import { DataForm, isItemValid } from '@wordpress/dataviews';
|
|
10
|
-
import {
|
|
11
|
-
Button,
|
|
12
|
-
__experimentalHStack as HStack,
|
|
13
|
-
__experimentalVStack as VStack,
|
|
14
|
-
} from '@wordpress/components';
|
|
15
|
-
import type { Action, RenderModalProps } from '@wordpress/dataviews';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Internal dependencies
|
|
19
|
-
*/
|
|
20
|
-
import type { CoreDataError, BasePost } from '../types';
|
|
21
|
-
import { orderField } from '../fields';
|
|
22
|
-
|
|
23
|
-
const fields = [ orderField ];
|
|
24
|
-
const formOrderAction = {
|
|
25
|
-
fields: [ 'menu_order' ],
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
function ReorderModal( {
|
|
29
|
-
items,
|
|
30
|
-
closeModal,
|
|
31
|
-
onActionPerformed,
|
|
32
|
-
}: RenderModalProps< BasePost > ) {
|
|
33
|
-
const [ item, setItem ] = useState( items[ 0 ] );
|
|
34
|
-
const orderInput = item.menu_order;
|
|
35
|
-
const { editEntityRecord, saveEditedEntityRecord } =
|
|
36
|
-
useDispatch( coreStore );
|
|
37
|
-
const { createSuccessNotice, createErrorNotice } =
|
|
38
|
-
useDispatch( noticesStore );
|
|
39
|
-
|
|
40
|
-
async function onOrder( event: React.FormEvent ) {
|
|
41
|
-
event.preventDefault();
|
|
42
|
-
|
|
43
|
-
if ( ! isItemValid( item, fields, formOrderAction ) ) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
await editEntityRecord( 'postType', item.type, item.id, {
|
|
49
|
-
menu_order: orderInput,
|
|
50
|
-
} );
|
|
51
|
-
closeModal?.();
|
|
52
|
-
// Persist edited entity.
|
|
53
|
-
await saveEditedEntityRecord( 'postType', item.type, item.id, {
|
|
54
|
-
throwOnError: true,
|
|
55
|
-
} );
|
|
56
|
-
createSuccessNotice( __( 'Order updated.' ), {
|
|
57
|
-
type: 'snackbar',
|
|
58
|
-
} );
|
|
59
|
-
onActionPerformed?.( items );
|
|
60
|
-
} catch ( error ) {
|
|
61
|
-
const typedError = error as CoreDataError;
|
|
62
|
-
const errorMessage =
|
|
63
|
-
typedError.message && typedError.code !== 'unknown_error'
|
|
64
|
-
? typedError.message
|
|
65
|
-
: __( 'An error occurred while updating the order' );
|
|
66
|
-
createErrorNotice( errorMessage, {
|
|
67
|
-
type: 'snackbar',
|
|
68
|
-
} );
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
const isSaveDisabled = ! isItemValid( item, fields, formOrderAction );
|
|
72
|
-
return (
|
|
73
|
-
<form onSubmit={ onOrder }>
|
|
74
|
-
<VStack spacing="5">
|
|
75
|
-
<div>
|
|
76
|
-
{ __(
|
|
77
|
-
'Determines the order of pages. Pages with the same order value are sorted alphabetically. Negative order values are supported.'
|
|
78
|
-
) }
|
|
79
|
-
</div>
|
|
80
|
-
<DataForm
|
|
81
|
-
data={ item }
|
|
82
|
-
fields={ fields }
|
|
83
|
-
form={ formOrderAction }
|
|
84
|
-
onChange={ ( changes ) =>
|
|
85
|
-
setItem( {
|
|
86
|
-
...item,
|
|
87
|
-
...changes,
|
|
88
|
-
} )
|
|
89
|
-
}
|
|
90
|
-
/>
|
|
91
|
-
<HStack justify="right">
|
|
92
|
-
<Button
|
|
93
|
-
__next40pxDefaultSize
|
|
94
|
-
variant="tertiary"
|
|
95
|
-
onClick={ () => {
|
|
96
|
-
closeModal?.();
|
|
97
|
-
} }
|
|
98
|
-
>
|
|
99
|
-
{ __( 'Cancel' ) }
|
|
100
|
-
</Button>
|
|
101
|
-
<Button
|
|
102
|
-
__next40pxDefaultSize
|
|
103
|
-
variant="primary"
|
|
104
|
-
type="submit"
|
|
105
|
-
accessibleWhenDisabled
|
|
106
|
-
disabled={ isSaveDisabled }
|
|
107
|
-
>
|
|
108
|
-
{ __( 'Save' ) }
|
|
109
|
-
</Button>
|
|
110
|
-
</HStack>
|
|
111
|
-
</VStack>
|
|
112
|
-
</form>
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const reorderPage: Action< BasePost > = {
|
|
117
|
-
id: 'order-pages',
|
|
118
|
-
label: __( 'Order' ),
|
|
119
|
-
isEligible( { status } ) {
|
|
120
|
-
return status !== 'trash';
|
|
121
|
-
},
|
|
122
|
-
RenderModal: ReorderModal,
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export default reorderPage;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
5
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
6
|
-
import type { Action } from '@wordpress/dataviews';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import type { Post } from '../types';
|
|
12
|
-
|
|
13
|
-
const viewPostRevisions: Action< Post > = {
|
|
14
|
-
id: 'view-post-revisions',
|
|
15
|
-
context: 'list',
|
|
16
|
-
label( items ) {
|
|
17
|
-
const revisionsCount =
|
|
18
|
-
items[ 0 ]._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;
|
|
19
|
-
return sprintf(
|
|
20
|
-
/* translators: %s: number of revisions */
|
|
21
|
-
__( 'View revisions (%s)' ),
|
|
22
|
-
revisionsCount
|
|
23
|
-
);
|
|
24
|
-
},
|
|
25
|
-
isEligible( post ) {
|
|
26
|
-
if ( post.status === 'trash' ) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
const lastRevisionId =
|
|
30
|
-
post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;
|
|
31
|
-
const revisionsCount =
|
|
32
|
-
post?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;
|
|
33
|
-
return !! lastRevisionId && revisionsCount > 1;
|
|
34
|
-
},
|
|
35
|
-
callback( posts, { onActionPerformed } ) {
|
|
36
|
-
const post = posts[ 0 ];
|
|
37
|
-
const href = addQueryArgs( 'revision.php', {
|
|
38
|
-
revision: post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id,
|
|
39
|
-
} );
|
|
40
|
-
document.location.href = href;
|
|
41
|
-
if ( onActionPerformed ) {
|
|
42
|
-
onActionPerformed( posts );
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default viewPostRevisions;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { external } from '@wordpress/icons';
|
|
5
|
-
import { _x } from '@wordpress/i18n';
|
|
6
|
-
import type { Action } from '@wordpress/dataviews';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import type { BasePost } from '../types';
|
|
12
|
-
|
|
13
|
-
const viewPost: Action< BasePost > = {
|
|
14
|
-
id: 'view-post',
|
|
15
|
-
label: _x( 'View', 'verb' ),
|
|
16
|
-
isPrimary: true,
|
|
17
|
-
icon: external,
|
|
18
|
-
isEligible( post ) {
|
|
19
|
-
return post.status !== 'trash';
|
|
20
|
-
},
|
|
21
|
-
callback( posts, { onActionPerformed } ) {
|
|
22
|
-
const post = posts[ 0 ];
|
|
23
|
-
window.open( post?.link, '_blank' );
|
|
24
|
-
if ( onActionPerformed ) {
|
|
25
|
-
onActionPerformed( posts );
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export default viewPost;
|