@wordpress/editor 12.0.18 → 12.2.0
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 +16 -0
- package/LICENSE.md +1 -1
- package/README.md +7 -1
- package/build/components/deprecated.js +5 -5
- package/build/components/deprecated.js.map +1 -1
- package/build/components/editor-help/add-blocks.native.js +1 -1
- package/build/components/editor-help/add-blocks.native.js.map +1 -1
- package/build/components/editor-help/index.native.js +1 -1
- package/build/components/editor-help/index.native.js.map +1 -1
- package/build/components/entities-saved-states/index.js +19 -10
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/index.js +18 -0
- package/build/components/index.js.map +1 -1
- package/build/components/post-format/index.js +6 -4
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-locked-modal/index.js +34 -25
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-category-panel.js +81 -0
- package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -0
- package/build/components/post-publish-panel/prepublish.js +3 -1
- package/build/components/post-publish-panel/prepublish.js.map +1 -1
- package/build/components/post-taxonomies/most-used-terms.js +3 -3
- package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build/components/post-title/index.native.js +1 -0
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-trash/index.js +1 -1
- package/build/components/post-trash/index.js.map +1 -1
- package/build/components/post-visibility/index.js +30 -14
- package/build/components/post-visibility/index.js.map +1 -1
- package/build/components/provider/index.native.js +12 -6
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +11 -6
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/store/actions.js +21 -15
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +12 -39
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils/notice-builder.js +1 -1
- package/build/store/utils/notice-builder.js.map +1 -1
- package/build-module/components/deprecated.js +5 -4
- package/build-module/components/deprecated.js.map +1 -1
- package/build-module/components/editor-help/add-blocks.native.js +1 -1
- package/build-module/components/editor-help/add-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/index.native.js +1 -1
- package/build-module/components/editor-help/index.native.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +19 -10
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/index.js +2 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/post-format/index.js +7 -5
- package/build-module/components/post-format/index.js.map +1 -1
- package/build-module/components/post-locked-modal/index.js +37 -25
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-category-panel.js +66 -0
- package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -0
- package/build-module/components/post-publish-panel/prepublish.js +2 -1
- package/build-module/components/post-publish-panel/prepublish.js.map +1 -1
- package/build-module/components/post-taxonomies/most-used-terms.js +3 -3
- package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build-module/components/post-title/index.native.js +1 -0
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/post-trash/index.js +1 -1
- package/build-module/components/post-trash/index.js.map +1 -1
- package/build-module/components/post-visibility/index.js +31 -15
- package/build-module/components/post-visibility/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +10 -7
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +11 -6
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/store/actions.js +21 -15
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +10 -35
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils/notice-builder.js +1 -1
- package/build-module/store/utils/notice-builder.js.map +1 -1
- package/build-style/style-rtl.css +9 -27
- package/build-style/style.css +9 -27
- package/package.json +31 -30
- package/src/components/autosave-monitor/test/index.js +1 -1
- package/src/components/deprecated.js +2 -5
- package/src/components/editor-help/add-blocks.native.js +1 -1
- package/src/components/editor-help/index.native.js +1 -1
- package/src/components/entities-saved-states/index.js +21 -10
- package/src/components/entities-saved-states/style.scss +0 -12
- package/src/components/index.js +2 -0
- package/src/components/post-format/index.js +9 -10
- package/src/components/post-locked-modal/index.js +92 -53
- package/src/components/post-locked-modal/style.scss +7 -17
- package/src/components/post-publish-panel/maybe-category-panel.js +88 -0
- package/src/components/post-publish-panel/prepublish.js +2 -0
- package/src/components/post-taxonomies/README.md +25 -1
- package/src/components/post-taxonomies/most-used-terms.js +3 -3
- package/src/components/post-title/index.native.js +1 -0
- package/src/components/post-trash/index.js +1 -1
- package/src/components/post-visibility/index.js +25 -11
- package/src/components/provider/index.native.js +10 -7
- package/src/components/provider/use-block-editor-settings.js +14 -3
- package/src/store/actions.js +18 -23
- package/src/store/selectors.js +9 -40
- package/src/store/test/actions.js +1 -41
- package/src/store/utils/notice-builder.js +1 -1
- package/src/store/utils/test/notice-builder.js +1 -1
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -27,8 +25,6 @@ var _coreData = require("@wordpress/core-data");
|
|
|
27
25
|
|
|
28
26
|
var _url2 = require("../../utils/url");
|
|
29
27
|
|
|
30
|
-
var _postPreviewButton = _interopRequireDefault(require("../post-preview-button"));
|
|
31
|
-
|
|
32
28
|
var _store = require("../../store");
|
|
33
29
|
|
|
34
30
|
/**
|
|
@@ -56,7 +52,8 @@ function PostLockedModal() {
|
|
|
56
52
|
postId,
|
|
57
53
|
postLockUtils,
|
|
58
54
|
activePostLock,
|
|
59
|
-
postType
|
|
55
|
+
postType,
|
|
56
|
+
previewLink
|
|
60
57
|
} = (0, _data.useSelect)(select => {
|
|
61
58
|
const {
|
|
62
59
|
isPostLocked,
|
|
@@ -65,6 +62,7 @@ function PostLockedModal() {
|
|
|
65
62
|
getCurrentPostId,
|
|
66
63
|
getActivePostLock,
|
|
67
64
|
getEditedPostAttribute,
|
|
65
|
+
getEditedPostPreviewLink,
|
|
68
66
|
getEditorSettings
|
|
69
67
|
} = select(_store.store);
|
|
70
68
|
const {
|
|
@@ -77,7 +75,8 @@ function PostLockedModal() {
|
|
|
77
75
|
postId: getCurrentPostId(),
|
|
78
76
|
postLockUtils: getEditorSettings().postLockUtils,
|
|
79
77
|
activePostLock: getActivePostLock(),
|
|
80
|
-
postType: getPostType(getEditedPostAttribute('type'))
|
|
78
|
+
postType: getPostType(getEditedPostAttribute('type')),
|
|
79
|
+
previewLink: getEditedPostPreviewLink()
|
|
81
80
|
};
|
|
82
81
|
}, []);
|
|
83
82
|
(0, _element.useEffect)(() => {
|
|
@@ -120,7 +119,8 @@ function PostLockedModal() {
|
|
|
120
119
|
isLocked: true,
|
|
121
120
|
isTakeover: true,
|
|
122
121
|
user: {
|
|
123
|
-
|
|
122
|
+
name: received.lock_error.name,
|
|
123
|
+
avatar: received.lock_error.avatar_src_2x
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
126
|
} else if (received.new_lock) {
|
|
@@ -183,9 +183,9 @@ function PostLockedModal() {
|
|
|
183
183
|
const allPostsUrl = (0, _url2.getWPAdminURL)('edit.php', {
|
|
184
184
|
post_type: (0, _lodash.get)(postType, ['slug'])
|
|
185
185
|
});
|
|
186
|
-
const allPostsLabel = (0, _i18n.__)('Exit
|
|
186
|
+
const allPostsLabel = (0, _i18n.__)('Exit editor');
|
|
187
187
|
return (0, _element.createElement)(_components.Modal, {
|
|
188
|
-
title: isTakeover ? (0, _i18n.__)('Someone else has taken over this post
|
|
188
|
+
title: isTakeover ? (0, _i18n.__)('Someone else has taken over this post') : (0, _i18n.__)('This post is already being edited'),
|
|
189
189
|
focusOnMount: true,
|
|
190
190
|
shouldCloseOnClickOutside: false,
|
|
191
191
|
shouldCloseOnEsc: false,
|
|
@@ -194,24 +194,33 @@ function PostLockedModal() {
|
|
|
194
194
|
}, !!userAvatar && (0, _element.createElement)("img", {
|
|
195
195
|
src: userAvatar,
|
|
196
196
|
alt: (0, _i18n.__)('Avatar'),
|
|
197
|
-
className: "editor-post-locked-modal__avatar"
|
|
198
|
-
|
|
197
|
+
className: "editor-post-locked-modal__avatar",
|
|
198
|
+
width: 64,
|
|
199
|
+
height: 64
|
|
200
|
+
}), (0, _element.createElement)("div", null, !!isTakeover && (0, _element.createElement)("p", null, (0, _element.createInterpolateElement)(userDisplayName ? (0, _i18n.sprintf)(
|
|
199
201
|
/* translators: %s: user's display name */
|
|
200
|
-
(0, _i18n.__)('
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
202
|
+
(0, _i18n.__)('<strong>%s</strong> now has editing control of this posts (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'), userDisplayName) : (0, _i18n.__)('Another user now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'), {
|
|
203
|
+
strong: (0, _element.createElement)("strong", null),
|
|
204
|
+
PreviewLink: (0, _element.createElement)(_components.ExternalLink, {
|
|
205
|
+
href: previewLink
|
|
206
|
+
}, (0, _i18n.__)('preview'))
|
|
207
|
+
})), !isTakeover && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("p", null, (0, _element.createInterpolateElement)(userDisplayName ? (0, _i18n.sprintf)(
|
|
206
208
|
/* translators: %s: user's display name */
|
|
207
|
-
(0, _i18n.__)('
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
209
|
+
(0, _i18n.__)('<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'), userDisplayName) : (0, _i18n.__)('Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'), {
|
|
210
|
+
strong: (0, _element.createElement)("strong", null),
|
|
211
|
+
PreviewLink: (0, _element.createElement)(_components.ExternalLink, {
|
|
212
|
+
href: previewLink
|
|
213
|
+
}, (0, _i18n.__)('preview'))
|
|
214
|
+
})), (0, _element.createElement)("p", null, (0, _i18n.__)('If you take over, the other user will lose editing control to the post, but their changes will be saved.'))), (0, _element.createElement)(_components.Flex, {
|
|
215
|
+
className: "editor-post-locked-modal__buttons",
|
|
216
|
+
justify: "flex-end",
|
|
217
|
+
expanded: false
|
|
218
|
+
}, !isTakeover && (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.Button, {
|
|
219
|
+
variant: "tertiary",
|
|
214
220
|
href: unlockUrl
|
|
215
|
-
}, (0, _i18n.__)('Take
|
|
221
|
+
}, (0, _i18n.__)('Take over'))), (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.Button, {
|
|
222
|
+
variant: "primary",
|
|
223
|
+
href: allPostsUrl
|
|
224
|
+
}, allPostsLabel)))));
|
|
216
225
|
}
|
|
217
226
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-locked-modal/index.js"],"names":["PostLockedModal","instanceId","hookName","autosave","updatePostLock","editorStore","isLocked","isTakeover","user","postId","postLockUtils","activePostLock","postType","select","isPostLocked","isPostLockTakeover","getPostLockUser","getCurrentPostId","getActivePostLock","getEditedPostAttribute","getEditorSettings","getPostType","coreStore","sendPostLock","data","lock","post_id","receivePostLock","received","lock_error","avatar","avatar_src","new_lock","releasePostLock","window","FormData","append","unlockNonce","navigator","sendBeacon","ajaxUrl","xhr","XMLHttpRequest","open","send","addEventListener","removeEventListener","userDisplayName","name","userAvatar","unlockUrl","lockKey","post","action","_wpnonce","nonce","allPostsUrl","post_type","allPostsLabel"],"mappings":";;;;;;;;;AAYA;;AATA;;AAKA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAtBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;AAKe,SAASA,eAA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U,GACP,cAAI,wCAAJ,CADO,GAEP,cAAI,oCAAJ,CAJL;AAMC,IAAA,YAAY,EAAG,IANhB;AAOC,IAAA,yBAAyB,EAAG,KAP7B;AAQC,IAAA,gBAAgB,EAAG,KARpB;AASC,IAAA,aAAa,EAAG,KATjB;AAUC,IAAA,SAAS,EAAC;AAVX,KAYG,CAAC,CAAE0C,UAAH,IACD;AACC,IAAA,GAAG,EAAGA,UADP;AAEC,IAAA,GAAG,EAAG,cAAI,QAAJ,CAFP;AAGC,IAAA,SAAS,EAAC;AAHX,IAbF,EAmBG,CAAC,CAAE1C,UAAH,IACD,yCACC,yCACGwC,eAAe,GACd;AACA;AACA,gBACC,uGADD,CAFA,EAKAA,eALA,CADc,GAQd,cACA,iHADA,CATJ,CADD,EAeC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAGS;AAAjC,KACGE,aADH,CADD,CAfD,CApBF,EA0CG,CAAEnD,UAAF,IACD,yCACC,yCACGwC,eAAe,GACd;AACA;AACA,gBACC,kGADD,CAFA,EAKAA,eALA,CADc,GAQd,cACA,4GADA,CATJ,CADD,EAeC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,WAAhB;AAA4B,IAAA,IAAI,EAAGS;AAAnC,KACGE,aADH,CADD,EAIC,4BAAC,0BAAD,OAJD,EAKC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAGR;AAAjC,KACG,cAAI,WAAJ,CADH,CALD,CAfD,CA3CF,CADD;AAwEA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Modal, Button } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useEffect } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { getWPAdminURL } from '../../utils/url';\nimport PostPreviewButton from '../post-preview-button';\nimport { store as editorStore } from '../../store';\n\nexport default function PostLockedModal() {\n\tconst instanceId = useInstanceId( PostLockedModal );\n\tconst hookName = 'core/editor/post-locked-modal-' + instanceId;\n\tconst { autosave, updatePostLock } = useDispatch( editorStore );\n\tconst {\n\t\tisLocked,\n\t\tisTakeover,\n\t\tuser,\n\t\tpostId,\n\t\tpostLockUtils,\n\t\tactivePostLock,\n\t\tpostType,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisPostLocked,\n\t\t\tisPostLockTakeover,\n\t\t\tgetPostLockUser,\n\t\t\tgetCurrentPostId,\n\t\t\tgetActivePostLock,\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditorSettings,\n\t\t} = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\treturn {\n\t\t\tisLocked: isPostLocked(),\n\t\t\tisTakeover: isPostLockTakeover(),\n\t\t\tuser: getPostLockUser(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostLockUtils: getEditorSettings().postLockUtils,\n\t\t\tactivePostLock: getActivePostLock(),\n\t\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * Keep the lock refreshed.\n\t\t *\n\t\t * When the user does not send a heartbeat in a heartbeat-tick\n\t\t * the user is no longer editing and another user can start editing.\n\t\t *\n\t\t * @param {Object} data Data to send in the heartbeat request.\n\t\t */\n\t\tfunction sendPostLock( data ) {\n\t\t\tif ( isLocked ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdata[ 'wp-refresh-post-lock' ] = {\n\t\t\t\tlock: activePostLock,\n\t\t\t\tpost_id: postId,\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing.\n\t\t *\n\t\t * @param {Object} data Data received in the heartbeat request\n\t\t */\n\t\tfunction receivePostLock( data ) {\n\t\t\tif ( ! data[ 'wp-refresh-post-lock' ] ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst received = data[ 'wp-refresh-post-lock' ];\n\t\t\tif ( received.lock_error ) {\n\t\t\t\t// Auto save and display the takeover modal.\n\t\t\t\tautosave();\n\t\t\t\tupdatePostLock( {\n\t\t\t\t\tisLocked: true,\n\t\t\t\t\tisTakeover: true,\n\t\t\t\t\tuser: {\n\t\t\t\t\t\tavatar: received.lock_error.avatar_src,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t} else if ( received.new_lock ) {\n\t\t\t\tupdatePostLock( {\n\t\t\t\t\tisLocked: false,\n\t\t\t\t\tactivePostLock: received.new_lock,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Unlock the post before the window is exited.\n\t\t */\n\t\tfunction releasePostLock() {\n\t\t\tif ( isLocked || ! activePostLock ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst data = new window.FormData();\n\t\t\tdata.append( 'action', 'wp-remove-post-lock' );\n\t\t\tdata.append( '_wpnonce', postLockUtils.unlockNonce );\n\t\t\tdata.append( 'post_ID', postId );\n\t\t\tdata.append( 'active_post_lock', activePostLock );\n\n\t\t\tif ( window.navigator.sendBeacon ) {\n\t\t\t\twindow.navigator.sendBeacon( postLockUtils.ajaxUrl, data );\n\t\t\t} else {\n\t\t\t\tconst xhr = new window.XMLHttpRequest();\n\t\t\t\txhr.open( 'POST', postLockUtils.ajaxUrl, false );\n\t\t\t\txhr.send( data );\n\t\t\t}\n\t\t}\n\n\t\t// Details on these events on the Heartbeat API docs\n\t\t// https://developer.wordpress.org/plugins/javascript/heartbeat-api/\n\t\taddAction( 'heartbeat.send', hookName, sendPostLock );\n\t\taddAction( 'heartbeat.tick', hookName, receivePostLock );\n\t\twindow.addEventListener( 'beforeunload', releasePostLock );\n\n\t\treturn () => {\n\t\t\tremoveAction( 'heartbeat.send', hookName );\n\t\t\tremoveAction( 'heartbeat.tick', hookName );\n\t\t\twindow.removeEventListener( 'beforeunload', releasePostLock );\n\t\t};\n\t}, [] );\n\n\tif ( ! isLocked ) {\n\t\treturn null;\n\t}\n\n\tconst userDisplayName = user.name;\n\tconst userAvatar = user.avatar;\n\n\tconst unlockUrl = addQueryArgs( 'post.php', {\n\t\t'get-post-lock': '1',\n\t\tlockKey: true,\n\t\tpost: postId,\n\t\taction: 'edit',\n\t\t_wpnonce: postLockUtils.nonce,\n\t} );\n\tconst allPostsUrl = getWPAdminURL( 'edit.php', {\n\t\tpost_type: get( postType, [ 'slug' ] ),\n\t} );\n\tconst allPostsLabel = __( 'Exit the Editor' );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={\n\t\t\t\tisTakeover\n\t\t\t\t\t? __( 'Someone else has taken over this post.' )\n\t\t\t\t\t: __( 'This post is already being edited.' )\n\t\t\t}\n\t\t\tfocusOnMount={ true }\n\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\tshouldCloseOnEsc={ false }\n\t\t\tisDismissible={ false }\n\t\t\tclassName=\"editor-post-locked-modal\"\n\t\t>\n\t\t\t{ !! userAvatar && (\n\t\t\t\t<img\n\t\t\t\t\tsrc={ userAvatar }\n\t\t\t\t\talt={ __( 'Avatar' ) }\n\t\t\t\t\tclassName=\"editor-post-locked-modal__avatar\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ !! isTakeover && (\n\t\t\t\t<div>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t{ userDisplayName\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: user's display name */\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'%s now has editing control of this post. Don’t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'Another user now has editing control of this post. Don’t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t ) }\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div className=\"editor-post-locked-modal__buttons\">\n\t\t\t\t\t\t<Button variant=\"primary\" href={ allPostsUrl }>\n\t\t\t\t\t\t\t{ allPostsLabel }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! isTakeover && (\n\t\t\t\t<div>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t{ userDisplayName\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: user's display name */\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'%s is currently working on this post, which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'Another user is currently working on this post, which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t ) }\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div className=\"editor-post-locked-modal__buttons\">\n\t\t\t\t\t\t<Button variant=\"secondary\" href={ allPostsUrl }>\n\t\t\t\t\t\t\t{ allPostsLabel }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<PostPreviewButton />\n\t\t\t\t\t\t<Button variant=\"primary\" href={ unlockUrl }>\n\t\t\t\t\t\t\t{ __( 'Take Over' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</Modal>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-locked-modal/index.js"],"names":["PostLockedModal","instanceId","hookName","autosave","updatePostLock","editorStore","isLocked","isTakeover","user","postId","postLockUtils","activePostLock","postType","previewLink","select","isPostLocked","isPostLockTakeover","getPostLockUser","getCurrentPostId","getActivePostLock","getEditedPostAttribute","getEditedPostPreviewLink","getEditorSettings","getPostType","coreStore","sendPostLock","data","lock","post_id","receivePostLock","received","lock_error","name","avatar","avatar_src_2x","new_lock","releasePostLock","window","FormData","append","unlockNonce","navigator","sendBeacon","ajaxUrl","xhr","XMLHttpRequest","open","send","addEventListener","removeEventListener","userDisplayName","userAvatar","unlockUrl","lockKey","post","action","_wpnonce","nonce","allPostsUrl","post_type","allPostsLabel","strong","PreviewLink"],"mappings":";;;;;;;AAkBA;;AAfA;;AAKA;;AACA;;AAOA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AA3BA;AACA;AACA;;AAGA;AACA;AACA;;AAgBA;AACA;AACA;AAIe,SAASA,eAAT,GAA2B;AACzC,QAAMC,UAAU,GAAG,4BAAeD,eAAf,CAAnB;AACA,QAAME,QAAQ,GAAG,mCAAmCD,UAApD;AACA,QAAM;AAAEE,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAA+B,uBAAaC,YAAb,CAArC;AACA,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,UAFK;AAGLC,IAAAA,IAHK;AAILC,IAAAA,MAJK;AAKLC,IAAAA,aALK;AAMLC,IAAAA,cANK;AAOLC,IAAAA,QAPK;AAQLC,IAAAA;AARK,MASF,qBAAaC,MAAF,IAAc;AAC5B,UAAM;AACLC,MAAAA,YADK;AAELC,MAAAA,kBAFK;AAGLC,MAAAA,eAHK;AAILC,MAAAA,gBAJK;AAKLC,MAAAA,iBALK;AAMLC,MAAAA,sBANK;AAOLC,MAAAA,wBAPK;AAQLC,MAAAA;AARK,QASFR,MAAM,CAAET,YAAF,CATV;AAUA,UAAM;AAAEkB,MAAAA;AAAF,QAAkBT,MAAM,CAAEU,eAAF,CAA9B;AAC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,EAKAA,eALA,CADY,GAQZ,cACA,mIADA,CATF,EAYD;AACCW,IAAAA,MAAM,EAAE,2CADT;AAECC,IAAAA,WAAW,EACV,4BAAC,wBAAD;AAAc,MAAA,IAAI,EAAGjD;AAArB,OACG,cAAI,SAAJ,CADH;AAHF,GAZC,CADH,CAFF,EA0BG,CAAEN,UAAF,IACD,qDACC,uCACG,uCACD2C,eAAe,GACZ;AACA;AACA,gBACC,qIADD,CAFA,EAKAA,eALA,CADY,GAQZ,cACA,8HADA,CATF,EAYD;AACCW,IAAAA,MAAM,EAAE,2CADT;AAECC,IAAAA,WAAW,EACV,4BAAC,wBAAD;AAAc,MAAA,IAAI,EAAGjD;AAArB,OACG,cAAI,SAAJ,CADH;AAHF,GAZC,CADH,CADD,EAwBC,uCACG,cACD,0GADC,CADH,CAxBD,CA3BF,EA2DC,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAC,mCADX;AAEC,IAAA,OAAO,EAAC,UAFT;AAGC,IAAA,QAAQ,EAAG;AAHZ,KAKG,CAAEN,UAAF,IACD,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,IAAI,EAAG6C;AAAlC,KACG,cAAI,WAAJ,CADH,CADD,CANF,EAYC,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAGM;AAAjC,KACGE,aADH,CADD,CAZD,CA3DD,CArBD,CADD;AAsGA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tModal,\n\tButton,\n\tExternalLink,\n\tFlex,\n\tFlexItem,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useEffect, createInterpolateElement } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { getWPAdminURL } from '../../utils/url';\nimport { store as editorStore } from '../../store';\n\nexport default function PostLockedModal() {\n\tconst instanceId = useInstanceId( PostLockedModal );\n\tconst hookName = 'core/editor/post-locked-modal-' + instanceId;\n\tconst { autosave, updatePostLock } = useDispatch( editorStore );\n\tconst {\n\t\tisLocked,\n\t\tisTakeover,\n\t\tuser,\n\t\tpostId,\n\t\tpostLockUtils,\n\t\tactivePostLock,\n\t\tpostType,\n\t\tpreviewLink,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisPostLocked,\n\t\t\tisPostLockTakeover,\n\t\t\tgetPostLockUser,\n\t\t\tgetCurrentPostId,\n\t\t\tgetActivePostLock,\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditedPostPreviewLink,\n\t\t\tgetEditorSettings,\n\t\t} = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\treturn {\n\t\t\tisLocked: isPostLocked(),\n\t\t\tisTakeover: isPostLockTakeover(),\n\t\t\tuser: getPostLockUser(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostLockUtils: getEditorSettings().postLockUtils,\n\t\t\tactivePostLock: getActivePostLock(),\n\t\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\t\tpreviewLink: getEditedPostPreviewLink(),\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * Keep the lock refreshed.\n\t\t *\n\t\t * When the user does not send a heartbeat in a heartbeat-tick\n\t\t * the user is no longer editing and another user can start editing.\n\t\t *\n\t\t * @param {Object} data Data to send in the heartbeat request.\n\t\t */\n\t\tfunction sendPostLock( data ) {\n\t\t\tif ( isLocked ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdata[ 'wp-refresh-post-lock' ] = {\n\t\t\t\tlock: activePostLock,\n\t\t\t\tpost_id: postId,\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing.\n\t\t *\n\t\t * @param {Object} data Data received in the heartbeat request\n\t\t */\n\t\tfunction receivePostLock( data ) {\n\t\t\tif ( ! data[ 'wp-refresh-post-lock' ] ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst received = data[ 'wp-refresh-post-lock' ];\n\t\t\tif ( received.lock_error ) {\n\t\t\t\t// Auto save and display the takeover modal.\n\t\t\t\tautosave();\n\t\t\t\tupdatePostLock( {\n\t\t\t\t\tisLocked: true,\n\t\t\t\t\tisTakeover: true,\n\t\t\t\t\tuser: {\n\t\t\t\t\t\tname: received.lock_error.name,\n\t\t\t\t\t\tavatar: received.lock_error.avatar_src_2x,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t} else if ( received.new_lock ) {\n\t\t\t\tupdatePostLock( {\n\t\t\t\t\tisLocked: false,\n\t\t\t\t\tactivePostLock: received.new_lock,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Unlock the post before the window is exited.\n\t\t */\n\t\tfunction releasePostLock() {\n\t\t\tif ( isLocked || ! activePostLock ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst data = new window.FormData();\n\t\t\tdata.append( 'action', 'wp-remove-post-lock' );\n\t\t\tdata.append( '_wpnonce', postLockUtils.unlockNonce );\n\t\t\tdata.append( 'post_ID', postId );\n\t\t\tdata.append( 'active_post_lock', activePostLock );\n\n\t\t\tif ( window.navigator.sendBeacon ) {\n\t\t\t\twindow.navigator.sendBeacon( postLockUtils.ajaxUrl, data );\n\t\t\t} else {\n\t\t\t\tconst xhr = new window.XMLHttpRequest();\n\t\t\t\txhr.open( 'POST', postLockUtils.ajaxUrl, false );\n\t\t\t\txhr.send( data );\n\t\t\t}\n\t\t}\n\n\t\t// Details on these events on the Heartbeat API docs\n\t\t// https://developer.wordpress.org/plugins/javascript/heartbeat-api/\n\t\taddAction( 'heartbeat.send', hookName, sendPostLock );\n\t\taddAction( 'heartbeat.tick', hookName, receivePostLock );\n\t\twindow.addEventListener( 'beforeunload', releasePostLock );\n\n\t\treturn () => {\n\t\t\tremoveAction( 'heartbeat.send', hookName );\n\t\t\tremoveAction( 'heartbeat.tick', hookName );\n\t\t\twindow.removeEventListener( 'beforeunload', releasePostLock );\n\t\t};\n\t}, [] );\n\n\tif ( ! isLocked ) {\n\t\treturn null;\n\t}\n\n\tconst userDisplayName = user.name;\n\tconst userAvatar = user.avatar;\n\n\tconst unlockUrl = addQueryArgs( 'post.php', {\n\t\t'get-post-lock': '1',\n\t\tlockKey: true,\n\t\tpost: postId,\n\t\taction: 'edit',\n\t\t_wpnonce: postLockUtils.nonce,\n\t} );\n\tconst allPostsUrl = getWPAdminURL( 'edit.php', {\n\t\tpost_type: get( postType, [ 'slug' ] ),\n\t} );\n\tconst allPostsLabel = __( 'Exit editor' );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={\n\t\t\t\tisTakeover\n\t\t\t\t\t? __( 'Someone else has taken over this post' )\n\t\t\t\t\t: __( 'This post is already being edited' )\n\t\t\t}\n\t\t\tfocusOnMount={ true }\n\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\tshouldCloseOnEsc={ false }\n\t\t\tisDismissible={ false }\n\t\t\tclassName=\"editor-post-locked-modal\"\n\t\t>\n\t\t\t{ !! userAvatar && (\n\t\t\t\t<img\n\t\t\t\t\tsrc={ userAvatar }\n\t\t\t\t\talt={ __( 'Avatar' ) }\n\t\t\t\t\tclassName=\"editor-post-locked-modal__avatar\"\n\t\t\t\t\twidth={ 64 }\n\t\t\t\t\theight={ 64 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<div>\n\t\t\t\t{ !! isTakeover && (\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: user's display name */\n\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t'<strong>%s</strong> now has editing control of this posts (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t'Another user now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tstrong: <strong />,\n\t\t\t\t\t\t\t\tPreviewLink: (\n\t\t\t\t\t\t\t\t\t<ExternalLink href={ previewLink }>\n\t\t\t\t\t\t\t\t\t\t{ __( 'preview' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t{ ! isTakeover && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: user's display name */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t'Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tstrong: <strong />,\n\t\t\t\t\t\t\t\t\tPreviewLink: (\n\t\t\t\t\t\t\t\t\t\t<ExternalLink href={ previewLink }>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'preview' ) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'If you take over, the other user will lose editing control to the post, but their changes will be saved.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"editor-post-locked-modal__buttons\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t{ ! isTakeover && (\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<Button variant=\"tertiary\" href={ unlockUrl }>\n\t\t\t\t\t\t\t\t{ __( 'Take over' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"primary\" href={ allPostsUrl }>\n\t\t\t\t\t\t\t{ allPostsLabel }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _lodash = require("lodash");
|
|
13
|
+
|
|
14
|
+
var _i18n = require("@wordpress/i18n");
|
|
15
|
+
|
|
16
|
+
var _data = require("@wordpress/data");
|
|
17
|
+
|
|
18
|
+
var _components = require("@wordpress/components");
|
|
19
|
+
|
|
20
|
+
var _coreData = require("@wordpress/core-data");
|
|
21
|
+
|
|
22
|
+
var _hierarchicalTermSelector = _interopRequireDefault(require("../post-taxonomies/hierarchical-term-selector"));
|
|
23
|
+
|
|
24
|
+
var _store = require("../../store");
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* External dependencies
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* WordPress dependencies
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Internal dependencies
|
|
36
|
+
*/
|
|
37
|
+
function MaybeCategoryPanel() {
|
|
38
|
+
const hasNoCategory = (0, _data.useSelect)(select => {
|
|
39
|
+
var _select$getEntityReco;
|
|
40
|
+
|
|
41
|
+
const postType = select(_store.store).getCurrentPostType();
|
|
42
|
+
const categoriesTaxonomy = select(_coreData.store).getTaxonomy('category');
|
|
43
|
+
const defaultCategorySlug = 'uncategorized';
|
|
44
|
+
const defaultCategory = (_select$getEntityReco = select(_coreData.store).getEntityRecords('taxonomy', 'category', {
|
|
45
|
+
slug: defaultCategorySlug
|
|
46
|
+
})) === null || _select$getEntityReco === void 0 ? void 0 : _select$getEntityReco[0];
|
|
47
|
+
const postTypeSupportsCategories = categoriesTaxonomy && (0, _lodash.some)(categoriesTaxonomy.types, type => type === postType);
|
|
48
|
+
const categories = categoriesTaxonomy && select(_store.store).getEditedPostAttribute(categoriesTaxonomy.rest_base); // This boolean should return true if everything is loaded
|
|
49
|
+
// ( categoriesTaxonomy, defaultCategory )
|
|
50
|
+
// and the post has not been assigned a category different than "uncategorized".
|
|
51
|
+
|
|
52
|
+
return !!categoriesTaxonomy && !!defaultCategory && postTypeSupportsCategories && ((categories === null || categories === void 0 ? void 0 : categories.length) === 0 || (categories === null || categories === void 0 ? void 0 : categories.length) === 1 && defaultCategory.id === categories[0]);
|
|
53
|
+
}, []);
|
|
54
|
+
const [shouldShowPanel, setShouldShowPanel] = (0, _element.useState)(false);
|
|
55
|
+
(0, _element.useEffect)(() => {
|
|
56
|
+
// We use state to avoid hiding the panel if the user edits the categories
|
|
57
|
+
// and adds one within the panel itself (while visible).
|
|
58
|
+
if (hasNoCategory) {
|
|
59
|
+
setShouldShowPanel(true);
|
|
60
|
+
}
|
|
61
|
+
}, [hasNoCategory]);
|
|
62
|
+
|
|
63
|
+
if (!shouldShowPanel) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const panelBodyTitle = [(0, _i18n.__)('Suggestion:'), (0, _element.createElement)("span", {
|
|
68
|
+
className: "editor-post-publish-panel__link",
|
|
69
|
+
key: "label"
|
|
70
|
+
}, (0, _i18n.__)('Assign a category'))];
|
|
71
|
+
return (0, _element.createElement)(_components.PanelBody, {
|
|
72
|
+
initialOpen: false,
|
|
73
|
+
title: panelBodyTitle
|
|
74
|
+
}, (0, _element.createElement)("p", null, (0, _i18n.__)('Categories provide a helpful way to group related posts together and to quickly tell readers what a post is about.')), (0, _element.createElement)(_hierarchicalTermSelector.default, {
|
|
75
|
+
slug: "category"
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var _default = MaybeCategoryPanel;
|
|
80
|
+
exports.default = _default;
|
|
81
|
+
//# sourceMappingURL=maybe-category-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-category-panel.js"],"names":["MaybeCategoryPanel","hasNoCategory","select","postType","editorStore","getCurrentPostType","categoriesTaxonomy","coreStore","getTaxonomy","defaultCategorySlug","defaultCategory","getEntityRecords","slug","postTypeSupportsCategories","types","type","categories","getEditedPostAttribute","rest_base","length","id","shouldShowPanel","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,eAAF,EAAmBC,kBAAnB,IAA0C,uBAAU,KAAV,CAAhD;AACA,0BAAW,MAAM;AAChB;AACA;AACA,QAAKrB,aAAL,EAAqB;AACpBqB,MAAAA,kBAAkB,CAAE,IAAF,CAAlB;AACA;AACD,GAND,EAMG,CAAErB,aAAF,CANH;;AAQA,MAAK,CAAEoB,eAAP,EAAyB;AACxB,WAAO,IAAP;AACA;;AAED,QAAME,cAAc,GAAG,CACtB,cAAI,aAAJ,CADsB,EAEtB;AAAM,IAAA,SAAS,EAAC,iCAAhB;AAAkD,IAAA,GAAG,EAAC;AAAtD,KACG,cAAI,mBAAJ,CADH,CAFsB,CAAvB;AAOA,SACC,4BAAC,qBAAD;AAAW,IAAA,WAAW,EAAG,KAAzB;AAAiC,IAAA,KAAK,EAAGA;AAAzC,KACC,uCACG,cACD,oHADC,CADH,CADD,EAMC,4BAAC,iCAAD;AAA0B,IAAA,IAAI,EAAC;AAA/B,IAND,CADD;AAUA;;eAEcvB,kB","sourcesContent":["/**\n * External dependencies\n */\nimport { some } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport HierarchicalTermSelector from '../post-taxonomies/hierarchical-term-selector';\nimport { store as editorStore } from '../../store';\n\nfunction MaybeCategoryPanel() {\n\tconst hasNoCategory = useSelect( ( select ) => {\n\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\tconst categoriesTaxonomy = select( coreStore ).getTaxonomy(\n\t\t\t'category'\n\t\t);\n\t\tconst defaultCategorySlug = 'uncategorized';\n\t\tconst defaultCategory = select( coreStore ).getEntityRecords(\n\t\t\t'taxonomy',\n\t\t\t'category',\n\t\t\t{\n\t\t\t\tslug: defaultCategorySlug,\n\t\t\t}\n\t\t)?.[ 0 ];\n\t\tconst postTypeSupportsCategories =\n\t\t\tcategoriesTaxonomy &&\n\t\t\tsome( categoriesTaxonomy.types, ( type ) => type === postType );\n\t\tconst categories =\n\t\t\tcategoriesTaxonomy &&\n\t\t\tselect( editorStore ).getEditedPostAttribute(\n\t\t\t\tcategoriesTaxonomy.rest_base\n\t\t\t);\n\n\t\t// This boolean should return true if everything is loaded\n\t\t// ( categoriesTaxonomy, defaultCategory )\n\t\t// and the post has not been assigned a category different than \"uncategorized\".\n\t\treturn (\n\t\t\t!! categoriesTaxonomy &&\n\t\t\t!! defaultCategory &&\n\t\t\tpostTypeSupportsCategories &&\n\t\t\t( categories?.length === 0 ||\n\t\t\t\t( categories?.length === 1 &&\n\t\t\t\t\tdefaultCategory.id === categories[ 0 ] ) )\n\t\t);\n\t}, [] );\n\tconst [ shouldShowPanel, setShouldShowPanel ] = useState( false );\n\tuseEffect( () => {\n\t\t// We use state to avoid hiding the panel if the user edits the categories\n\t\t// and adds one within the panel itself (while visible).\n\t\tif ( hasNoCategory ) {\n\t\t\tsetShouldShowPanel( true );\n\t\t}\n\t}, [ hasNoCategory ] );\n\n\tif ( ! shouldShowPanel ) {\n\t\treturn null;\n\t}\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'Assign a category' ) }\n\t\t</span>,\n\t];\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Categories provide a helpful way to group related posts together and to quickly tell readers what a post is about.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<HierarchicalTermSelector slug=\"category\" />\n\t\t</PanelBody>\n\t);\n}\n\nexport default MaybeCategoryPanel;\n"]}
|
|
@@ -39,6 +39,8 @@ var _maybePostFormatPanel = _interopRequireDefault(require("./maybe-post-format-
|
|
|
39
39
|
|
|
40
40
|
var _store = require("../../store");
|
|
41
41
|
|
|
42
|
+
var _maybeCategoryPanel = _interopRequireDefault(require("./maybe-category-panel"));
|
|
43
|
+
|
|
42
44
|
/**
|
|
43
45
|
* External dependencies
|
|
44
46
|
*/
|
|
@@ -133,7 +135,7 @@ function PostPublishPanelPrepublish(_ref) {
|
|
|
133
135
|
className: "editor-post-publish-panel__link",
|
|
134
136
|
key: "label"
|
|
135
137
|
}, (0, _element.createElement)(_label2.default, null))]
|
|
136
|
-
}, (0, _element.createElement)(_postSchedule.default, null))), (0, _element.createElement)(_maybePostFormatPanel.default, null), (0, _element.createElement)(_maybeTagsPanel.default, null), children);
|
|
138
|
+
}, (0, _element.createElement)(_postSchedule.default, null))), (0, _element.createElement)(_maybePostFormatPanel.default, null), (0, _element.createElement)(_maybeTagsPanel.default, null), (0, _element.createElement)(_maybeCategoryPanel.default, null), children);
|
|
137
139
|
}
|
|
138
140
|
|
|
139
141
|
var _default = PostPublishPanelPrepublish;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/prepublish.js"],"names":["PostPublishPanelPrepublish","children","isBeingScheduled","isRequestingSiteIcon","hasPublishAction","siteIconUrl","siteTitle","siteHome","select","getCurrentPost","isEditedPostBeingScheduled","editorStore","getEntityRecord","isResolving","coreStore","siteData","undefined","site_icon_url","name","home","siteIcon","wordpress","prePublishTitle","prePublishBodyText"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/prepublish.js"],"names":["PostPublishPanelPrepublish","children","isBeingScheduled","isRequestingSiteIcon","hasPublishAction","siteIconUrl","siteTitle","siteHome","select","getCurrentPost","isEditedPostBeingScheduled","editorStore","getEntityRecord","isResolving","coreStore","siteData","undefined","site_icon_url","name","home","siteIcon","wordpress","prePublishTitle","prePublishBodyText"],"mappings":";;;;;;;;;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C,MAAA,GAAG,EAAC;AAFL,OAIC,4BAAC,cAAD,OAJD,CAFO;AAFT,KAYC,4BAAC,uBAAD,OAZD,CADD,EAeC,4BAAC,qBAAD;AACC,IAAA,WAAW,EAAG,KADf;AAEC,IAAA,KAAK,EAAG,CACP,cAAI,UAAJ,CADO,EAEP;AACC,MAAA,SAAS,EAAC,iCADX;AAEC,MAAA,GAAG,EAAC;AAFL,OAIC,4BAAC,eAAD,OAJD,CAFO;AAFT,KAYC,4BAAC,qBAAD,OAZD,CAfD,CAfF,EA8CC,4BAAC,6BAAD,OA9CD,EA+CC,4BAAC,uBAAD,OA/CD,EAgDC,4BAAC,2BAAD,OAhDD,EAiDGH,QAjDH,CADD;AAqDA;;eAEcD,0B","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Icon, PanelBody } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { wordpress } from '@wordpress/icons';\nimport { filterURLForDisplay } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport PostVisibility from '../post-visibility';\nimport PostVisibilityLabel from '../post-visibility/label';\nimport PostSchedule from '../post-schedule';\nimport PostScheduleLabel from '../post-schedule/label';\nimport MaybeTagsPanel from './maybe-tags-panel';\nimport MaybePostFormatPanel from './maybe-post-format-panel';\nimport { store as editorStore } from '../../store';\nimport MaybeCategoryPanel from './maybe-category-panel';\n\nfunction PostPublishPanelPrepublish( { children } ) {\n\tconst {\n\t\tisBeingScheduled,\n\t\tisRequestingSiteIcon,\n\t\thasPublishAction,\n\t\tsiteIconUrl,\n\t\tsiteTitle,\n\t\tsiteHome,\n\t} = useSelect( ( select ) => {\n\t\tconst { getCurrentPost, isEditedPostBeingScheduled } = select(\n\t\t\teditorStore\n\t\t);\n\t\tconst { getEntityRecord, isResolving } = select( coreStore );\n\t\tconst siteData =\n\t\t\tgetEntityRecord( 'root', '__unstableBase', undefined ) || {};\n\n\t\treturn {\n\t\t\thasPublishAction: get(\n\t\t\t\tgetCurrentPost(),\n\t\t\t\t[ '_links', 'wp:action-publish' ],\n\t\t\t\tfalse\n\t\t\t),\n\t\t\tisBeingScheduled: isEditedPostBeingScheduled(),\n\t\t\tisRequestingSiteIcon: isResolving( 'getEntityRecord', [\n\t\t\t\t'root',\n\t\t\t\t'__unstableBase',\n\t\t\t\tundefined,\n\t\t\t] ),\n\t\t\tsiteIconUrl: siteData.site_icon_url,\n\t\t\tsiteTitle: siteData.name,\n\t\t\tsiteHome: siteData.home && filterURLForDisplay( siteData.home ),\n\t\t};\n\t}, [] );\n\n\tlet siteIcon = (\n\t\t<Icon className=\"components-site-icon\" size=\"36px\" icon={ wordpress } />\n\t);\n\n\tif ( siteIconUrl ) {\n\t\tsiteIcon = (\n\t\t\t<img\n\t\t\t\talt={ __( 'Site Icon' ) }\n\t\t\t\tclassName=\"components-site-icon\"\n\t\t\t\tsrc={ siteIconUrl }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( isRequestingSiteIcon ) {\n\t\tsiteIcon = null;\n\t}\n\n\tlet prePublishTitle, prePublishBodyText;\n\n\tif ( ! hasPublishAction ) {\n\t\tprePublishTitle = __( 'Are you ready to submit for review?' );\n\t\tprePublishBodyText = __(\n\t\t\t'When you’re ready, submit your work for review, and an Editor will be able to approve it for you.'\n\t\t);\n\t} else if ( isBeingScheduled ) {\n\t\tprePublishTitle = __( 'Are you ready to schedule?' );\n\t\tprePublishBodyText = __(\n\t\t\t'Your work will be published at the specified date and time.'\n\t\t);\n\t} else {\n\t\tprePublishTitle = __( 'Are you ready to publish?' );\n\t\tprePublishBodyText = __(\n\t\t\t'Double-check your settings before publishing.'\n\t\t);\n\t}\n\n\treturn (\n\t\t<div className=\"editor-post-publish-panel__prepublish\">\n\t\t\t<div>\n\t\t\t\t<strong>{ prePublishTitle }</strong>\n\t\t\t</div>\n\t\t\t<p>{ prePublishBodyText }</p>\n\t\t\t<div className=\"components-site-card\">\n\t\t\t\t{ siteIcon }\n\t\t\t\t<div className=\"components-site-info\">\n\t\t\t\t\t<span className=\"components-site-name\">\n\t\t\t\t\t\t{ decodeEntities( siteTitle ) || __( '(Untitled)' ) }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"components-site-home\">{ siteHome }</span>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t{ hasPublishAction && (\n\t\t\t\t<>\n\t\t\t\t\t<PanelBody\n\t\t\t\t\t\tinitialOpen={ false }\n\t\t\t\t\t\ttitle={ [\n\t\t\t\t\t\t\t__( 'Visibility:' ),\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName=\"editor-post-publish-panel__link\"\n\t\t\t\t\t\t\t\tkey=\"label\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<PostVisibilityLabel />\n\t\t\t\t\t\t\t</span>,\n\t\t\t\t\t\t] }\n\t\t\t\t\t>\n\t\t\t\t\t\t<PostVisibility />\n\t\t\t\t\t</PanelBody>\n\t\t\t\t\t<PanelBody\n\t\t\t\t\t\tinitialOpen={ false }\n\t\t\t\t\t\ttitle={ [\n\t\t\t\t\t\t\t__( 'Publish:' ),\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName=\"editor-post-publish-panel__link\"\n\t\t\t\t\t\t\t\tkey=\"label\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<PostScheduleLabel />\n\t\t\t\t\t\t\t</span>,\n\t\t\t\t\t\t] }\n\t\t\t\t\t>\n\t\t\t\t\t\t<PostSchedule />\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<MaybePostFormatPanel />\n\t\t\t<MaybeTagsPanel />\n\t\t\t<MaybeCategoryPanel />\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\nexport default PostPublishPanelPrepublish;\n"]}
|
|
@@ -28,9 +28,9 @@ var _terms2 = require("../../utils/terms");
|
|
|
28
28
|
/**
|
|
29
29
|
* Internal dependencies
|
|
30
30
|
*/
|
|
31
|
-
const
|
|
31
|
+
const MIN_MOST_USED_TERMS = 3;
|
|
32
32
|
const DEFAULT_QUERY = {
|
|
33
|
-
per_page:
|
|
33
|
+
per_page: 10,
|
|
34
34
|
orderby: 'count',
|
|
35
35
|
order: 'desc',
|
|
36
36
|
hide_empty: true,
|
|
@@ -50,7 +50,7 @@ function MostUsedTerms(_ref) {
|
|
|
50
50
|
const mostUsedTerms = select(_coreData.store).getEntityRecords('taxonomy', taxonomy.slug, DEFAULT_QUERY);
|
|
51
51
|
return {
|
|
52
52
|
_terms: mostUsedTerms,
|
|
53
|
-
showTerms: (mostUsedTerms === null || mostUsedTerms === void 0 ? void 0 : mostUsedTerms.length)
|
|
53
|
+
showTerms: (mostUsedTerms === null || mostUsedTerms === void 0 ? void 0 : mostUsedTerms.length) >= MIN_MOST_USED_TERMS
|
|
54
54
|
};
|
|
55
55
|
}, []);
|
|
56
56
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/most-used-terms.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/most-used-terms.js"],"names":["MIN_MOST_USED_TERMS","DEFAULT_QUERY","per_page","orderby","order","hide_empty","_fields","context","MostUsedTerms","onSelect","taxonomy","_terms","showTerms","select","mostUsedTerms","coreStore","getEntityRecords","slug","length","terms","label","map","term","id","name"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAGA,MAAMA,mBAAmB,GAAG,CAA5B;AACA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAE,EADW;AAErBC,EAAAA,OAAO,EAAE,OAFY;AAGrBC,EAAAA,KAAK,EAAE,MAHc;AAIrBC,EAAA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ependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unescapeTerms } from '../../utils/terms';\n\nconst MIN_MOST_USED_TERMS = 3;\nconst DEFAULT_QUERY = {\n\tper_page: 10,\n\torderby: 'count',\n\torder: 'desc',\n\thide_empty: true,\n\t_fields: 'id,name,count',\n\tcontext: 'view',\n};\n\nexport default function MostUsedTerms( { onSelect, taxonomy } ) {\n\tconst { _terms, showTerms } = useSelect( ( select ) => {\n\t\tconst mostUsedTerms = select( coreStore ).getEntityRecords(\n\t\t\t'taxonomy',\n\t\t\ttaxonomy.slug,\n\t\t\tDEFAULT_QUERY\n\t\t);\n\t\treturn {\n\t\t\t_terms: mostUsedTerms,\n\t\t\tshowTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS,\n\t\t};\n\t}, [] );\n\n\tif ( ! showTerms ) {\n\t\treturn null;\n\t}\n\n\tconst terms = unescapeTerms( _terms );\n\tconst label = get( taxonomy, [ 'labels', 'most_used' ] );\n\n\treturn (\n\t\t<div className=\"editor-post-taxonomies__flat-term-most-used\">\n\t\t\t<h3 className=\"editor-post-taxonomies__flat-term-most-used-label\">\n\t\t\t\t{ label }\n\t\t\t</h3>\n\t\t\t{ /*\n\t\t\t * Disable reason: The `list` ARIA role is redundant but\n\t\t\t * Safari+VoiceOver won't announce the list otherwise.\n\t\t\t */\n\t\t\t/* eslint-disable jsx-a11y/no-redundant-roles */ }\n\t\t\t<ul\n\t\t\t\trole=\"list\"\n\t\t\t\tclassName=\"editor-post-taxonomies__flat-term-most-used-list\"\n\t\t\t>\n\t\t\t\t{ terms.map( ( term ) => (\n\t\t\t\t\t<li key={ term.id }>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tonClick={ () => onSelect( term ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ term.name }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</li>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t\t{ /* eslint-enable jsx-a11y/no-redundant-roles */ }\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-title/index.native.js"],"names":["PostTitle","Component","constructor","props","setRef","bind","componentDidUpdate","prevProps","isSelected","isAnyBlockSelected","richTextRef","blur","onUnselect","componentDidMount","innerRef","handleFocusOutside","focus","onSelect","onPaste","value","onChange","plainText","content","mode","tagName","valueToInsert","html","richText","getTitle","title","postType","render","placeholder","style","focusedBorderColor","borderStyle","isDimmed","globalStyles","decodedPlaceholder","borderColor","titleStyles","text","color","placeholderColor","styles","titleContainer","dimmed","onBlur","onUpdate","onEnterPress","select","isPostTitleSelected","getEditedPostAttribute","editorStore","getSelectedBlockClientId","getBlockRootClientId","getSettings","blockEditorStore","selectedId","selectionIsNested","__experimentalGlobalStylesBaseStyles","dispatch","undo","redo","togglePostTitleSelection","clearSelectedBlock","insertDefaultBlock","undefined","onUndo","onRedo","withInstanceId","withFocusOutside"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAMA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AA3BA;AACA;AACA;;AAIA;AACA;AACA;;AAgBA;AACA;AACA;AAGA,MAAMA,SAAN,SAAwBC,kBAAxB,CAAkC;AACjCC,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAOA,KAAP;AAEA,SAAKC,MAAL,GAAc,KAAKA,MAAL,CAAYC,IAAZ,CAAkB,IAAlB,CAAd;AACA;;AACDC,EAAAA,kBAAkB,CAAEC,SAAF,EAAc;AAC/B;AACA,QACC,KAAKJ,KAAL,CAAWK,UAAX,IACA,CAAED,SAAS,CAACE,kBADZ,IAEA,KAAKN,KAAL,CAAWM,kBAHZ,EAIE;AACD,UAAK,KAAKC,WAAV,EAAwB;AACvB,aAAK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AAGNlD,IAAAA,UAAU,EAAE2C,mBAAmB,EAHzB;AAINf,IAAAA,QAAQ,EAAEuB,iBAJJ;AAKNtB,IAAAA;AALM,GAAP;AAOA,CAtBD,CADc,EAwBd,wBAAgBwB,QAAF,IAAgB;AAC7B,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,IAAR;AAAcC,IAAAA;AAAd,MAA2CH,QAAQ,CACxDR,aADwD,CAAzD;AAIA,QAAM;AAAEY,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,MAA6CL,QAAQ,CAC1DJ,kBAD0D,CAA3D;AAIA,SAAO;AACNR,IAAAA,YAAY,GAAG;AACdiB,MAAAA,kBAAkB,CAAEC,SAAF,EAAaA,SAAb,EAAwB,CAAxB,CAAlB;AACA,KAHK;;AAINC,IAAAA,MAAM,EAAEN,IAJF;AAKNO,IAAAA,MAAM,EAAEN,IALF;;AAMN9C,IAAAA,QAAQ,GAAG;AACV+C,MAAAA,wBAAwB,CAAE,IAAF,CAAxB;AACAC,MAAAA,kBAAkB;AAClB,KATK;;AAUNrD,IAAAA,UAAU,GAAG;AACZoD,MAAAA,wBAAwB,CAAE,KAAF,CAAxB;AACA;;AAZK,GAAP;AAcA,CAvBD,CAxBc,EAgDdM,uBAhDc,EAiDdC,4BAjDc,EAkDZvE,SAlDY,C","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport {\n\t__experimentalRichText as RichText,\n\tcreate,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { withFocusOutside } from '@wordpress/components';\nimport { withInstanceId, compose } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { pasteHandler } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nclass PostTitle extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.setRef = this.setRef.bind( this );\n\t}\n\tcomponentDidUpdate( prevProps ) {\n\t\t// Unselect if any other block is selected and blur the RichText\n\t\tif (\n\t\t\tthis.props.isSelected &&\n\t\t\t! prevProps.isAnyBlockSelected &&\n\t\t\tthis.props.isAnyBlockSelected\n\t\t) {\n\t\t\tif ( this.richTextRef ) {\n\t\t\t\tthis.richTextRef.blur();\n\t\t\t}\n\t\t\tthis.props.onUnselect();\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.props.innerRef ) {\n\t\t\tthis.props.innerRef( this );\n\t\t}\n\t}\n\n\thandleFocusOutside() {\n\t\tthis.props.onUnselect();\n\t}\n\n\tfocus() {\n\t\tthis.props.onSelect();\n\t}\n\n\tonPaste( { value, onChange, plainText } ) {\n\t\tconst content = pasteHandler( {\n\t\t\tplainText,\n\t\t\tmode: 'INLINE',\n\t\t\ttagName: 'p',\n\t\t} );\n\n\t\tif ( typeof content === 'string' ) {\n\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t}\n\t}\n\n\tsetRef( richText ) {\n\t\tthis.richTextRef = richText;\n\t}\n\n\tgetTitle( title, postType ) {\n\t\tif ( 'page' === postType ) {\n\t\t\treturn isEmpty( title )\n\t\t\t\t? /* translators: accessibility text. empty page title. */\n\t\t\t\t __( 'Page title. Empty' )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. %s: text content of the page title. */\n\t\t\t\t\t\t__( 'Page title. %s' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t );\n\t\t}\n\n\t\treturn isEmpty( title )\n\t\t\t? /* translators: accessibility text. empty post title. */\n\t\t\t __( 'Post title. Empty' )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: accessibility text. %s: text content of the post title. */\n\t\t\t\t\t__( 'Post title. %s' ),\n\t\t\t\t\ttitle\n\t\t\t );\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tplaceholder,\n\t\t\tstyle,\n\t\t\ttitle,\n\t\t\tfocusedBorderColor,\n\t\t\tborderStyle,\n\t\t\tisDimmed,\n\t\t\tpostType,\n\t\t\tglobalStyles,\n\t\t} = this.props;\n\n\t\tconst decodedPlaceholder = decodeEntities( placeholder );\n\t\tconst borderColor = this.props.isSelected\n\t\t\t? focusedBorderColor\n\t\t\t: 'transparent';\n\t\tconst titleStyles = {\n\t\t\t...style,\n\t\t\t...( globalStyles?.text && {\n\t\t\t\tcolor: globalStyles.text,\n\t\t\t\tplaceholderColor: globalStyles.text,\n\t\t\t} ),\n\t\t};\n\n\t\treturn (\n\t\t\t<View\n\t\t\t\tstyle={ [\n\t\t\t\t\tstyles.titleContainer,\n\t\t\t\t\tborderStyle,\n\t\t\t\t\t{ borderColor },\n\t\t\t\t\tisDimmed && styles.dimmed,\n\t\t\t\t] }\n\t\t\t\taccessible={ ! this.props.isSelected }\n\t\t\t\taccessibilityLabel={ this.getTitle( title, postType ) }\n\t\t\t\taccessibilityHint={ __( 'Updates the title.' ) }\n\t\t\t>\n\t\t\t\t<RichText\n\t\t\t\t\tsetRef={ this.setRef }\n\t\t\t\t\taccessibilityLabel={ this.getTitle( title, postType ) }\n\t\t\t\t\ttagName={ 'p' }\n\t\t\t\t\ttagsToEliminate={ [ 'strong' ] }\n\t\t\t\t\tunstableOnFocus={ this.props.onSelect }\n\t\t\t\t\tonBlur={ this.props.onBlur } // always assign onBlur as a props\n\t\t\t\t\tmultiline={ false }\n\t\t\t\t\tstyle={ titleStyles }\n\t\t\t\t\tstyles={ styles }\n\t\t\t\t\tfontSize={ 24 }\n\t\t\t\t\tfontWeight={ 'bold' }\n\t\t\t\t\tdeleteEnter={ true }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tthis.props.onUpdate( value );\n\t\t\t\t\t} }\n\t\t\t\t\tonPaste={ this.onPaste }\n\t\t\t\t\tplaceholder={ decodedPlaceholder }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonSelectionChange={ () => {} }\n\t\t\t\t\tonEnter={ this.props.onEnterPress }\n\t\t\t\t\tdisableEditingMenu={ true }\n\t\t\t\t\t__unstableIsSelected={ this.props.isSelected }\n\t\t\t\t\t__unstableOnCreateUndoLevel={ () => {} }\n\t\t\t\t></RichText>\n\t\t\t</View>\n\t\t);\n\t}\n}\n\nexport default compose(\n\twithSelect( ( select ) => {\n\t\tconst { isPostTitleSelected, getEditedPostAttribute } = select(\n\t\t\teditorStore\n\t\t);\n\t\tconst {\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetSettings,\n\t\t} = select( blockEditorStore );\n\n\t\tconst selectedId = getSelectedBlockClientId();\n\t\tconst selectionIsNested = !! getBlockRootClientId( selectedId );\n\t\tconst globalStyles = getSettings()?.__experimentalGlobalStylesBaseStyles\n\t\t\t?.color;\n\n\t\treturn {\n\t\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\t\tisAnyBlockSelected: !! selectedId,\n\t\t\tisSelected: isPostTitleSelected(),\n\t\t\tisDimmed: selectionIsNested,\n\t\t\tglobalStyles,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { undo, redo, togglePostTitleSelection } = dispatch(\n\t\t\teditorStore\n\t\t);\n\n\t\tconst { clearSelectedBlock, insertDefaultBlock } = dispatch(\n\t\t\tblockEditorStore\n\t\t);\n\n\t\treturn {\n\t\t\tonEnterPress() {\n\t\t\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t\t\t},\n\t\t\tonUndo: undo,\n\t\t\tonRedo: redo,\n\t\t\tonSelect() {\n\t\t\t\ttogglePostTitleSelection( true );\n\t\t\t\tclearSelectedBlock();\n\t\t\t},\n\t\t\tonUnselect() {\n\t\t\t\ttogglePostTitleSelection( false );\n\t\t\t},\n\t\t};\n\t} ),\n\twithInstanceId,\n\twithFocusOutside\n)( PostTitle );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-title/index.native.js"],"names":["PostTitle","Component","constructor","props","setRef","bind","componentDidUpdate","prevProps","isSelected","isAnyBlockSelected","richTextRef","blur","onUnselect","componentDidMount","innerRef","handleFocusOutside","focus","onSelect","onPaste","value","onChange","plainText","content","mode","tagName","valueToInsert","html","richText","getTitle","title","postType","render","placeholder","style","focusedBorderColor","borderStyle","isDimmed","globalStyles","decodedPlaceholder","borderColor","titleStyles","text","color","placeholderColor","styles","titleContainer","dimmed","onBlur","onUpdate","onEnterPress","select","isPostTitleSelected","getEditedPostAttribute","editorStore","getSelectedBlockClientId","getBlockRootClientId","getSettings","blockEditorStore","selectedId","selectionIsNested","__experimentalGlobalStylesBaseStyles","dispatch","undo","redo","togglePostTitleSelection","clearSelectedBlock","insertDefaultBlock","undefined","onUndo","onRedo","withInstanceId","withFocusOutside"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAMA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AA3BA;AACA;AACA;;AAIA;AACA;AACA;;AAgBA;AACA;AACA;AAGA,MAAMA,SAAN,SAAwBC,kBAAxB,CAAkC;AACjCC,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAOA,KAAP;AAEA,SAAKC,MAAL,GAAc,KAAKA,MAAL,CAAYC,IAAZ,CAAkB,IAAlB,CAAd;AACA;;AACDC,EAAAA,kBAAkB,CAAEC,SAAF,EAAc;AAC/B;AACA,QACC,KAAKJ,KAAL,CAAWK,UAAX,IACA,CAAED,SAAS,CAACE,kBADZ,IAEA,KAAKN,KAAL,CAAWM,kBAHZ,EAIE;AACD,UAAK,KAAKC,WAAV,EAAwB;AACvB,aAAKA,WAAL,CAAiBC,IAAjB;AACA;;AACD,WAAKR,KAAL,CAAWS,UAAX;AACA;AACD;;AAEDC,EAAAA,iBAAiB,GAAG;AACnB,QAA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J;AAKNtB,IAAAA;AALM,GAAP;AAOA,CAtBD,CADc,EAwBd,wBAAgBwB,QAAF,IAAgB;AAC7B,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,IAAR;AAAcC,IAAAA;AAAd,MAA2CH,QAAQ,CACxDR,aADwD,CAAzD;AAIA,QAAM;AAAEY,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,MAA6CL,QAAQ,CAC1DJ,kBAD0D,CAA3D;AAIA,SAAO;AACNR,IAAAA,YAAY,GAAG;AACdiB,MAAAA,kBAAkB,CAAEC,SAAF,EAAaA,SAAb,EAAwB,CAAxB,CAAlB;AACA,KAHK;;AAINC,IAAAA,MAAM,EAAEN,IAJF;AAKNO,IAAAA,MAAM,EAAEN,IALF;;AAMN9C,IAAAA,QAAQ,GAAG;AACV+C,MAAAA,wBAAwB,CAAE,IAAF,CAAxB;AACAC,MAAAA,kBAAkB;AAClB,KATK;;AAUNrD,IAAAA,UAAU,GAAG;AACZoD,MAAAA,wBAAwB,CAAE,KAAF,CAAxB;AACA;;AAZK,GAAP;AAcA,CAvBD,CAxBc,EAgDdM,uBAhDc,EAiDdC,4BAjDc,EAkDZvE,SAlDY,C","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport {\n\t__experimentalRichText as RichText,\n\tcreate,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { withFocusOutside } from '@wordpress/components';\nimport { withInstanceId, compose } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { pasteHandler } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nclass PostTitle extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.setRef = this.setRef.bind( this );\n\t}\n\tcomponentDidUpdate( prevProps ) {\n\t\t// Unselect if any other block is selected and blur the RichText\n\t\tif (\n\t\t\tthis.props.isSelected &&\n\t\t\t! prevProps.isAnyBlockSelected &&\n\t\t\tthis.props.isAnyBlockSelected\n\t\t) {\n\t\t\tif ( this.richTextRef ) {\n\t\t\t\tthis.richTextRef.blur();\n\t\t\t}\n\t\t\tthis.props.onUnselect();\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.props.innerRef ) {\n\t\t\tthis.props.innerRef( this );\n\t\t}\n\t}\n\n\thandleFocusOutside() {\n\t\tthis.props.onUnselect();\n\t}\n\n\tfocus() {\n\t\tthis.props.onSelect();\n\t}\n\n\tonPaste( { value, onChange, plainText } ) {\n\t\tconst content = pasteHandler( {\n\t\t\tplainText,\n\t\t\tmode: 'INLINE',\n\t\t\ttagName: 'p',\n\t\t} );\n\n\t\tif ( typeof content === 'string' ) {\n\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t}\n\t}\n\n\tsetRef( richText ) {\n\t\tthis.richTextRef = richText;\n\t}\n\n\tgetTitle( title, postType ) {\n\t\tif ( 'page' === postType ) {\n\t\t\treturn isEmpty( title )\n\t\t\t\t? /* translators: accessibility text. empty page title. */\n\t\t\t\t __( 'Page title. Empty' )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. %s: text content of the page title. */\n\t\t\t\t\t\t__( 'Page title. %s' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t );\n\t\t}\n\n\t\treturn isEmpty( title )\n\t\t\t? /* translators: accessibility text. empty post title. */\n\t\t\t __( 'Post title. Empty' )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: accessibility text. %s: text content of the post title. */\n\t\t\t\t\t__( 'Post title. %s' ),\n\t\t\t\t\ttitle\n\t\t\t );\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tplaceholder,\n\t\t\tstyle,\n\t\t\ttitle,\n\t\t\tfocusedBorderColor,\n\t\t\tborderStyle,\n\t\t\tisDimmed,\n\t\t\tpostType,\n\t\t\tglobalStyles,\n\t\t} = this.props;\n\n\t\tconst decodedPlaceholder = decodeEntities( placeholder );\n\t\tconst borderColor = this.props.isSelected\n\t\t\t? focusedBorderColor\n\t\t\t: 'transparent';\n\t\tconst titleStyles = {\n\t\t\t...style,\n\t\t\t...( globalStyles?.text && {\n\t\t\t\tcolor: globalStyles.text,\n\t\t\t\tplaceholderColor: globalStyles.text,\n\t\t\t} ),\n\t\t};\n\n\t\treturn (\n\t\t\t<View\n\t\t\t\tstyle={ [\n\t\t\t\t\tstyles.titleContainer,\n\t\t\t\t\tborderStyle,\n\t\t\t\t\t{ borderColor },\n\t\t\t\t\tisDimmed && styles.dimmed,\n\t\t\t\t] }\n\t\t\t\taccessible={ ! this.props.isSelected }\n\t\t\t\taccessibilityLabel={ this.getTitle( title, postType ) }\n\t\t\t\taccessibilityHint={ __( 'Updates the title.' ) }\n\t\t\t>\n\t\t\t\t<RichText\n\t\t\t\t\tsetRef={ this.setRef }\n\t\t\t\t\taccessibilityLabel={ this.getTitle( title, postType ) }\n\t\t\t\t\ttagName={ 'p' }\n\t\t\t\t\ttagsToEliminate={ [ 'strong' ] }\n\t\t\t\t\tunstableOnFocus={ this.props.onSelect }\n\t\t\t\t\tonBlur={ this.props.onBlur } // always assign onBlur as a props\n\t\t\t\t\tmultiline={ false }\n\t\t\t\t\tstyle={ titleStyles }\n\t\t\t\t\tstyles={ styles }\n\t\t\t\t\tfontSize={ 24 }\n\t\t\t\t\tlineHeight={ 1 }\n\t\t\t\t\tfontWeight={ 'bold' }\n\t\t\t\t\tdeleteEnter={ true }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tthis.props.onUpdate( value );\n\t\t\t\t\t} }\n\t\t\t\t\tonPaste={ this.onPaste }\n\t\t\t\t\tplaceholder={ decodedPlaceholder }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonSelectionChange={ () => {} }\n\t\t\t\t\tonEnter={ this.props.onEnterPress }\n\t\t\t\t\tdisableEditingMenu={ true }\n\t\t\t\t\t__unstableIsSelected={ this.props.isSelected }\n\t\t\t\t\t__unstableOnCreateUndoLevel={ () => {} }\n\t\t\t\t></RichText>\n\t\t\t</View>\n\t\t);\n\t}\n}\n\nexport default compose(\n\twithSelect( ( select ) => {\n\t\tconst { isPostTitleSelected, getEditedPostAttribute } = select(\n\t\t\teditorStore\n\t\t);\n\t\tconst {\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetSettings,\n\t\t} = select( blockEditorStore );\n\n\t\tconst selectedId = getSelectedBlockClientId();\n\t\tconst selectionIsNested = !! getBlockRootClientId( selectedId );\n\t\tconst globalStyles = getSettings()?.__experimentalGlobalStylesBaseStyles\n\t\t\t?.color;\n\n\t\treturn {\n\t\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\t\tisAnyBlockSelected: !! selectedId,\n\t\t\tisSelected: isPostTitleSelected(),\n\t\t\tisDimmed: selectionIsNested,\n\t\t\tglobalStyles,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { undo, redo, togglePostTitleSelection } = dispatch(\n\t\t\teditorStore\n\t\t);\n\n\t\tconst { clearSelectedBlock, insertDefaultBlock } = dispatch(\n\t\t\tblockEditorStore\n\t\t);\n\n\t\treturn {\n\t\t\tonEnterPress() {\n\t\t\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t\t\t},\n\t\t\tonUndo: undo,\n\t\t\tonRedo: redo,\n\t\t\tonSelect() {\n\t\t\t\ttogglePostTitleSelection( true );\n\t\t\t\tclearSelectedBlock();\n\t\t\t},\n\t\t\tonUnselect() {\n\t\t\t\ttogglePostTitleSelection( false );\n\t\t\t},\n\t\t};\n\t} ),\n\twithInstanceId,\n\twithFocusOutside\n)( PostTitle );\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-trash/index.js"],"names":["PostTrash","isNew","postId","postType","props","onClick","trashPost","select","isEditedPostNew","getCurrentPostId","getCurrentPostType","editorStore","dispatch"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGA,SAASA,SAAT,OAA4D;AAAA,MAAxC;AAAEC,IAAAA,KAAF;AAASC,IAAAA,MAAT;AAAiBC,IAAAA,QAAjB;AAA2B,OAAGC;AAA9B,GAAwC;;AAC3D,MAAKH,KAAK,IAAI,CAAEC,MAAhB,EAAyB;AACxB,WAAO,IAAP;AACA;;AAED,QAAMG,OAAO,GAAG,MAAMD,KAAK,CAACE,SAAN,CAAiBJ,MAAjB,EAAyBC,QAAzB,CAAtB;;AAEA,SACC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,mBADX;AAEC,IAAA,aAAa,MAFd;AAGC,IAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-trash/index.js"],"names":["PostTrash","isNew","postId","postType","props","onClick","trashPost","select","isEditedPostNew","getCurrentPostId","getCurrentPostType","editorStore","dispatch"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGA,SAASA,SAAT,OAA4D;AAAA,MAAxC;AAAEC,IAAAA,KAAF;AAASC,IAAAA,MAAT;AAAiBC,IAAAA,QAAjB;AAA2B,OAAGC;AAA9B,GAAwC;;AAC3D,MAAKH,KAAK,IAAI,CAAEC,MAAhB,EAAyB;AACxB,WAAO,IAAP;AACA;;AAED,QAAMG,OAAO,GAAG,MAAMD,KAAK,CAACE,SAAN,CAAiBJ,MAAjB,EAAyBC,QAAzB,CAAtB;;AAEA,SACC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,mBADX;AAEC,IAAA,aAAa,MAFd;AAGC,IAAA,OAAO,EAAC,WAHT;AAIC,IAAA,OAAO,EAAGE;AAJX,KAMG,cAAI,eAAJ,CANH,CADD;AAUA;;eAEc,sBAAS,CACvB,sBAAcE,MAAF,IAAc;AACzB,QAAM;AACLC,IAAAA,eADK;AAELC,IAAAA,gBAFK;AAGLC,IAAAA;AAHK,MAIFH,MAAM,CAAEI,YAAF,CAJV;AAKA,SAAO;AACNV,IAAAA,KAAK,EAAEO,eAAe,EADhB;AAENN,IAAAA,MAAM,EAAEO,gBAAgB,EAFlB;AAGNN,IAAAA,QAAQ,EAAEO,kBAAkB;AAHtB,GAAP;AAKA,CAXD,CADuB,EAavB,wBAAgBE,QAAF,KAAkB;AAC/BN,EAAAA,SAAS,EAAEM,QAAQ,CAAED,YAAF,CAAR,CAAwBL;AADJ,CAAlB,CAAd,CAbuB,CAAT,EAgBVN,SAhBU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction PostTrash( { isNew, postId, postType, ...props } ) {\n\tif ( isNew || ! postId ) {\n\t\treturn null;\n\t}\n\n\tconst onClick = () => props.trashPost( postId, postType );\n\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"editor-post-trash\"\n\t\t\tisDestructive\n\t\t\tvariant=\"secondary\"\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ __( 'Move to trash' ) }\n\t\t</Button>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tisEditedPostNew,\n\t\t\tgetCurrentPostId,\n\t\t\tgetCurrentPostType,\n\t\t} = select( editorStore );\n\t\treturn {\n\t\t\tisNew: isEditedPostNew(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => ( {\n\t\ttrashPost: dispatch( editorStore ).trashPost,\n\t} ) ),\n] )( PostTrash );\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -7,6 +9,8 @@ exports.default = exports.PostVisibility = void 0;
|
|
|
7
9
|
|
|
8
10
|
var _element = require("@wordpress/element");
|
|
9
11
|
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
10
14
|
var _i18n = require("@wordpress/i18n");
|
|
11
15
|
|
|
12
16
|
var _components = require("@wordpress/components");
|
|
@@ -29,12 +33,30 @@ var _store = require("../../store");
|
|
|
29
33
|
class PostVisibility extends _element.Component {
|
|
30
34
|
constructor(props) {
|
|
31
35
|
super(...arguments);
|
|
36
|
+
(0, _defineProperty2.default)(this, "confirmPrivate", () => {
|
|
37
|
+
const {
|
|
38
|
+
onUpdateVisibility,
|
|
39
|
+
onSave
|
|
40
|
+
} = this.props;
|
|
41
|
+
onUpdateVisibility('private');
|
|
42
|
+
this.setState({
|
|
43
|
+
hasPassword: false,
|
|
44
|
+
showPrivateConfirmDialog: false
|
|
45
|
+
});
|
|
46
|
+
onSave();
|
|
47
|
+
});
|
|
48
|
+
(0, _defineProperty2.default)(this, "handleDialogCancel", () => {
|
|
49
|
+
this.setState({
|
|
50
|
+
showPrivateConfirmDialog: false
|
|
51
|
+
});
|
|
52
|
+
});
|
|
32
53
|
this.setPublic = this.setPublic.bind(this);
|
|
33
54
|
this.setPrivate = this.setPrivate.bind(this);
|
|
34
55
|
this.setPasswordProtected = this.setPasswordProtected.bind(this);
|
|
35
56
|
this.updatePassword = this.updatePassword.bind(this);
|
|
36
57
|
this.state = {
|
|
37
|
-
hasPassword: !!props.password
|
|
58
|
+
hasPassword: !!props.password,
|
|
59
|
+
showPrivateConfirmDialog: false
|
|
38
60
|
};
|
|
39
61
|
}
|
|
40
62
|
|
|
@@ -51,20 +73,9 @@ class PostVisibility extends _element.Component {
|
|
|
51
73
|
}
|
|
52
74
|
|
|
53
75
|
setPrivate() {
|
|
54
|
-
if ( // eslint-disable-next-line no-alert
|
|
55
|
-
!window.confirm((0, _i18n.__)('Would you like to privately publish this post now?'))) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const {
|
|
60
|
-
onUpdateVisibility,
|
|
61
|
-
onSave
|
|
62
|
-
} = this.props;
|
|
63
|
-
onUpdateVisibility('private');
|
|
64
76
|
this.setState({
|
|
65
|
-
|
|
77
|
+
showPrivateConfirmDialog: true
|
|
66
78
|
});
|
|
67
|
-
onSave();
|
|
68
79
|
}
|
|
69
80
|
|
|
70
81
|
setPasswordProtected() {
|
|
@@ -151,7 +162,12 @@ class PostVisibility extends _element.Component {
|
|
|
151
162
|
onChange: this.updatePassword,
|
|
152
163
|
value: password,
|
|
153
164
|
placeholder: (0, _i18n.__)('Use a secure password')
|
|
154
|
-
}))
|
|
165
|
+
})), (0, _element.createElement)(_components.__experimentalConfirmDialog, {
|
|
166
|
+
key: "private-publish-confirmation",
|
|
167
|
+
isOpen: this.state.showPrivateConfirmDialog,
|
|
168
|
+
onConfirm: this.confirmPrivate,
|
|
169
|
+
onCancel: this.handleDialogCancel
|
|
170
|
+
}, (0, _i18n.__)('Would you like to privately publish this post now?'))];
|
|
155
171
|
}
|
|
156
172
|
|
|
157
173
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-visibility/index.js"],"names":["PostVisibility","Component","constructor","props","arguments","setPublic","bind","setPrivate","setPasswordProtected","updatePassword","state","hasPassword","password","visibility","onUpdateVisibility","status","setState","window","confirm","onSave","event","target","value","render","instanceId","visibilityHandlers","public","onSelect","checked","private","visibilityOptions","map","label","info","select","getEditedPostAttribute","getEditedPostVisibility","editorStore","dispatch","savePost","editPost","withInstanceId"],"mappings":";;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AAbA;AACA;AACA;;AAOA;AACA;AACA;AAIO,MAAMA,cAAN,SAA6BC,kBAA7B,CAAuC;AAC7CC,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAO,GAAGC,SAAV;AAEA,SAAKC,SAAL,GAAiB,KAAKA,SAAL,CAAeC,IAAf,CAAqB,IAArB,CAAjB;AACA,SAAKC,UAAL,GAAkB,KAAKA,UAAL,CAAgBD,IAAhB,CAAsB,IAAtB,CAAlB;AACA,SAAKE,oBAAL,GAA4B,KAAKA,oBAAL,CAA0BF,IAA1B,CAAgC,IAAhC,CAA5B;AACA,SAAKG,cAAL,GAAsB,KAAKA,cAAL,CAAoBH,IAApB,CAA0B,IAA1B,CAAtB;AAEA,SAAKI,KAAL,GAAa;AACZC,MAAAA,WAAW,EAAE,CAAC,CAAER,KAAK,CAACS;AADV,KAAb;AAGA;;AAEDP,EAAAA,SAAS,GAAG;AACX,UAAM;AAAEQ,MAAAA,UAAF;AAAcC,MAAAA,kBAAd;AAAkCC,MAAAA;AAAlC,QAA6C,KAAKZ,KAAxD;AAEAW,IAAAA,kBAAkB,CAAED,UAAU,KAAK,SAAf,GAA2B,OAA3B,GAAqCE,MAAvC,CAAlB;AACA,SAAKC,QAAL,CAAe;AAAEL,MAAAA,WAAW,EAAE;AAAf,KAAf;AACA;;AAEDJ,EAAAA,UAAU,GAAG;AACZ,SACC;AACA,KAAEU,MAAM,CAACC,OAAP,CACD,cAAI,oDAAJ,CADC,CAFH,EAKE;AACD;AACA;;AAED,UAAM;AAAEJ,MAAAA,kBAAF;AAAsBK,MAAAA;AAAtB,QAAiC,KAAKhB,KAA5C;AAEAW,IAAAA,kBAAkB,CAAE,SAAF,CAAlB;AACA,SAAKE,QAAL,CAAe;AAAEL,MAAAA,WAAW,EAAE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C,MAAA,QAAQ,EAAG,KAAKf,cAJjB;AAKC,MAAA,KAAK,EAAGG,QALT;AAMC,MAAA,WAAW,EAAG,cAAI,uBAAJ;AANf,MAVD,CAzCK,CAAP;AA8DA;;AArI4C;;;;eAwI/B,sBAAS,CACvB,sBAAcsB,MAAF,IAAc;AACzB,QAAM;AAAEC,IAAAA,sBAAF;AAA0BC,IAAAA;AAA1B,MAAsDF,MAAM,CACjEG,YADiE,CAAlE;AAGA,SAAO;AACNtB,IAAAA,MAAM,EAAEoB,sBAAsB,CAAE,QAAF,CADxB;AAENtB,IAAAA,UAAU,EAAEuB,uBAAuB,EAF7B;AAGNxB,IAAAA,QAAQ,EAAEuB,sBAAsB,CAAE,UAAF;AAH1B,GAAP;AAKA,CATD,CADuB,EAWvB,wBAAgBG,QAAF,IAAgB;AAC7B,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAyBF,QAAQ,CAAED,YAAF,CAAvC;AACA,SAAO;AACNlB,IAAAA,MAAM,EAAEoB,QADF;;AAENzB,IAAAA,kBAAkB,CAAEC,MAAF,EAA0B;AAAA,UAAhBH,QAAgB,uEAAL,EAAK;AAC3C4B,MAAAA,QAAQ,CAAE;AAAEzB,QAAAA,MAAF;AAAUH,QAAAA;AAAV,OAAF,CAAR;AACA;;AAJK,GAAP;AAMA,CARD,CAXuB,EAoBvB6B,uBApBuB,CAAT,EAqBVzC,cArBU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Component } from '@wordpress/element';\nimport { VisuallyHidden } from '@wordpress/components';\nimport { withInstanceId, compose } from '@wordpress/compose';\nimport { withSelect, withDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { visibilityOptions } from './utils';\nimport { store as editorStore } from '../../store';\n\nexport class PostVisibility extends Component {\n\tconstructor( props ) {\n\t\tsuper( ...arguments );\n\n\t\tthis.setPublic = this.setPublic.bind( this );\n\t\tthis.setPrivate = this.setPrivate.bind( this );\n\t\tthis.setPasswordProtected = this.setPasswordProtected.bind( this );\n\t\tthis.updatePassword = this.updatePassword.bind( this );\n\n\t\tthis.state = {\n\t\t\thasPassword: !! props.password,\n\t\t};\n\t}\n\n\tsetPublic() {\n\t\tconst { visibility, onUpdateVisibility, status } = this.props;\n\n\t\tonUpdateVisibility( visibility === 'private' ? 'draft' : status );\n\t\tthis.setState( { hasPassword: false } );\n\t}\n\n\tsetPrivate() {\n\t\tif (\n\t\t\t// eslint-disable-next-line no-alert\n\t\t\t! window.confirm(\n\t\t\t\t__( 'Would you like to privately publish this post now?' )\n\t\t\t)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { onUpdateVisibility, onSave } = this.props;\n\n\t\tonUpdateVisibility( 'private' );\n\t\tthis.setState( { hasPassword: false } );\n\t\tonSave();\n\t}\n\n\tsetPasswordProtected() {\n\t\tconst { visibility, onUpdateVisibility, status, password } = this.props;\n\n\t\tonUpdateVisibility(\n\t\t\tvisibility === 'private' ? 'draft' : status,\n\t\t\tpassword || ''\n\t\t);\n\t\tthis.setState( { hasPassword: true } );\n\t}\n\n\tupdatePassword( event ) {\n\t\tconst { status, onUpdateVisibility } = this.props;\n\t\tonUpdateVisibility( status, event.target.value );\n\t}\n\n\trender() {\n\t\tconst { visibility, password, instanceId } = this.props;\n\n\t\tconst visibilityHandlers = {\n\t\t\tpublic: {\n\t\t\t\tonSelect: this.setPublic,\n\t\t\t\tchecked: visibility === 'public' && ! this.state.hasPassword,\n\t\t\t},\n\t\t\tprivate: {\n\t\t\t\tonSelect: this.setPrivate,\n\t\t\t\tchecked: visibility === 'private',\n\t\t\t},\n\t\t\tpassword: {\n\t\t\t\tonSelect: this.setPasswordProtected,\n\t\t\t\tchecked: this.state.hasPassword,\n\t\t\t},\n\t\t};\n\n\t\treturn [\n\t\t\t<fieldset\n\t\t\t\tkey=\"visibility-selector\"\n\t\t\t\tclassName=\"editor-post-visibility__dialog-fieldset\"\n\t\t\t>\n\t\t\t\t<legend className=\"editor-post-visibility__dialog-legend\">\n\t\t\t\t\t{ __( 'Post Visibility' ) }\n\t\t\t\t</legend>\n\t\t\t\t{ visibilityOptions.map( ( { value, label, info } ) => (\n\t\t\t\t\t<div\n\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\tclassName=\"editor-post-visibility__choice\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\tname={ `editor-post-visibility__setting-${ instanceId }` }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tonChange={ visibilityHandlers[ value ].onSelect }\n\t\t\t\t\t\t\tchecked={ visibilityHandlers[ value ].checked }\n\t\t\t\t\t\t\tid={ `editor-post-${ value }-${ instanceId }` }\n\t\t\t\t\t\t\taria-describedby={ `editor-post-${ value }-${ instanceId }-description` }\n\t\t\t\t\t\t\tclassName=\"editor-post-visibility__dialog-radio\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<label\n\t\t\t\t\t\t\thtmlFor={ `editor-post-${ value }-${ instanceId }` }\n\t\t\t\t\t\t\tclassName=\"editor-post-visibility__dialog-label\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</label>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tid={ `editor-post-${ value }-${ instanceId }-description` }\n\t\t\t\t\t\t\t\tclassName=\"editor-post-visibility__dialog-info\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ info }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t}\n\t\t\t\t\t</div>\n\t\t\t\t) ) }\n\t\t\t</fieldset>,\n\t\t\tthis.state.hasPassword && (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"editor-post-visibility__dialog-password\"\n\t\t\t\t\tkey=\"password-selector\"\n\t\t\t\t>\n\t\t\t\t\t<VisuallyHidden\n\t\t\t\t\t\tas=\"label\"\n\t\t\t\t\t\thtmlFor={ `editor-post-visibility__dialog-password-input-${ instanceId }` }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Create password' ) }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t<input\n\t\t\t\t\t\tclassName=\"editor-post-visibility__dialog-password-input\"\n\t\t\t\t\t\tid={ `editor-post-visibility__dialog-password-input-${ instanceId }` }\n\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\tonChange={ this.updatePassword }\n\t\t\t\t\t\tvalue={ password }\n\t\t\t\t\t\tplaceholder={ __( 'Use a secure password' ) }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t),\n\t\t];\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute, getEditedPostVisibility } = select(\n\t\t\teditorStore\n\t\t);\n\t\treturn {\n\t\t\tstatus: getEditedPostAttribute( 'status' ),\n\t\t\tvisibility: getEditedPostVisibility(),\n\t\t\tpassword: getEditedPostAttribute( 'password' ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { savePost, editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonSave: savePost,\n\t\t\tonUpdateVisibility( status, password = '' ) {\n\t\t\t\teditPost( { status, password } );\n\t\t\t},\n\t\t};\n\t} ),\n\twithInstanceId,\n] )( PostVisibility );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-visibility/index.js"],"names":["PostVisibility","Component","constructor","props","arguments","onUpdateVisibility","onSave","setState","hasPassword","showPrivateConfirmDialog","setPublic","bind","setPrivate","setPasswordProtected","updatePassword","state","password","visibility","status","event","target","value","render","instanceId","visibilityHandlers","public","onSelect","checked","private","visibilityOptions","map","label","info","confirmPrivate","handleDialogCancel","select","getEditedPostAttribute","getEditedPostVisibility","editorStore","dispatch","savePost","editPost","withInstanceId"],"mappings":";;;;;;;;;AAIA;;;;AADA;;AAEA;;AAIA;;A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Component } from '@wordpress/element';\nimport {\n\tVisuallyHidden,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { withInstanceId, compose } from '@wordpress/compose';\nimport { withSelect, withDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { visibilityOptions } from './utils';\nimport { store as editorStore } from '../../store';\n\nexport class PostVisibility extends Component {\n\tconstructor( props ) {\n\t\tsuper( ...arguments );\n\n\t\tthis.setPublic = this.setPublic.bind( this );\n\t\tthis.setPrivate = this.setPrivate.bind( this );\n\t\tthis.setPasswordProtected = this.setPasswordProtected.bind( this );\n\t\tthis.updatePassword = this.updatePassword.bind( this );\n\n\t\tthis.state = {\n\t\t\thasPassword: !! props.password,\n\t\t\tshowPrivateConfirmDialog: false,\n\t\t};\n\t}\n\n\tsetPublic() {\n\t\tconst { visibility, onUpdateVisibility, status } = this.props;\n\n\t\tonUpdateVisibility( visibility === 'private' ? 'draft' : status );\n\t\tthis.setState( { hasPassword: false } );\n\t}\n\n\tsetPrivate() {\n\t\tthis.setState( { showPrivateConfirmDialog: true } );\n\t}\n\n\tconfirmPrivate = () => {\n\t\tconst { onUpdateVisibility, onSave } = this.props;\n\n\t\tonUpdateVisibility( 'private' );\n\t\tthis.setState( {\n\t\t\thasPassword: false,\n\t\t\tshowPrivateConfirmDialog: false,\n\t\t} );\n\t\tonSave();\n\t};\n\n\thandleDialogCancel = () => {\n\t\tthis.setState( { showPrivateConfirmDialog: false } );\n\t};\n\n\tsetPasswordProtected() {\n\t\tconst { visibility, onUpdateVisibility, status, password } = this.props;\n\n\t\tonUpdateVisibility(\n\t\t\tvisibility === 'private' ? 'draft' : status,\n\t\t\tpassword || ''\n\t\t);\n\t\tthis.setState( { hasPassword: true } );\n\t}\n\n\tupdatePassword( event ) {\n\t\tconst { status, onUpdateVisibility } = this.props;\n\t\tonUpdateVisibility( status, event.target.value );\n\t}\n\n\trender() {\n\t\tconst { visibility, password, instanceId } = this.props;\n\n\t\tconst visibilityHandlers = {\n\t\t\tpublic: {\n\t\t\t\tonSelect: this.setPublic,\n\t\t\t\tchecked: visibility === 'public' && ! this.state.hasPassword,\n\t\t\t},\n\t\t\tprivate: {\n\t\t\t\tonSelect: this.setPrivate,\n\t\t\t\tchecked: visibility === 'private',\n\t\t\t},\n\t\t\tpassword: {\n\t\t\t\tonSelect: this.setPasswordProtected,\n\t\t\t\tchecked: this.state.hasPassword,\n\t\t\t},\n\t\t};\n\n\t\treturn [\n\t\t\t<fieldset\n\t\t\t\tkey=\"visibility-selector\"\n\t\t\t\tclassName=\"editor-post-visibility__dialog-fieldset\"\n\t\t\t>\n\t\t\t\t<legend className=\"editor-post-visibility__dialog-legend\">\n\t\t\t\t\t{ __( 'Post Visibility' ) }\n\t\t\t\t</legend>\n\t\t\t\t{ visibilityOptions.map( ( { value, label, info } ) => (\n\t\t\t\t\t<div\n\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\tclassName=\"editor-post-visibility__choice\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\tname={ `editor-post-visibility__setting-${ instanceId }` }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tonChange={ visibilityHandlers[ value ].onSelect }\n\t\t\t\t\t\t\tchecked={ visibilityHandlers[ value ].checked }\n\t\t\t\t\t\t\tid={ `editor-post-${ value }-${ instanceId }` }\n\t\t\t\t\t\t\taria-describedby={ `editor-post-${ value }-${ instanceId }-description` }\n\t\t\t\t\t\t\tclassName=\"editor-post-visibility__dialog-radio\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<label\n\t\t\t\t\t\t\thtmlFor={ `editor-post-${ value }-${ instanceId }` }\n\t\t\t\t\t\t\tclassName=\"editor-post-visibility__dialog-label\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</label>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tid={ `editor-post-${ value }-${ instanceId }-description` }\n\t\t\t\t\t\t\t\tclassName=\"editor-post-visibility__dialog-info\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ info }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t}\n\t\t\t\t\t</div>\n\t\t\t\t) ) }\n\t\t\t</fieldset>,\n\t\t\tthis.state.hasPassword && (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"editor-post-visibility__dialog-password\"\n\t\t\t\t\tkey=\"password-selector\"\n\t\t\t\t>\n\t\t\t\t\t<VisuallyHidden\n\t\t\t\t\t\tas=\"label\"\n\t\t\t\t\t\thtmlFor={ `editor-post-visibility__dialog-password-input-${ instanceId }` }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Create password' ) }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t<input\n\t\t\t\t\t\tclassName=\"editor-post-visibility__dialog-password-input\"\n\t\t\t\t\t\tid={ `editor-post-visibility__dialog-password-input-${ instanceId }` }\n\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\tonChange={ this.updatePassword }\n\t\t\t\t\t\tvalue={ password }\n\t\t\t\t\t\tplaceholder={ __( 'Use a secure password' ) }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t),\n\t\t\t<ConfirmDialog\n\t\t\t\tkey=\"private-publish-confirmation\"\n\t\t\t\tisOpen={ this.state.showPrivateConfirmDialog }\n\t\t\t\tonConfirm={ this.confirmPrivate }\n\t\t\t\tonCancel={ this.handleDialogCancel }\n\t\t\t>\n\t\t\t\t{ __( 'Would you like to privately publish this post now?' ) }\n\t\t\t</ConfirmDialog>,\n\t\t];\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute, getEditedPostVisibility } = select(\n\t\t\teditorStore\n\t\t);\n\t\treturn {\n\t\t\tstatus: getEditedPostAttribute( 'status' ),\n\t\t\tvisibility: getEditedPostVisibility(),\n\t\t\tpassword: getEditedPostAttribute( 'password' ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { savePost, editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonSave: savePost,\n\t\t\tonUpdateVisibility( status, password = '' ) {\n\t\t\t\teditPost( { status, password } );\n\t\t\t},\n\t\t};\n\t} ),\n\twithInstanceId,\n] )( PostVisibility );\n"]}
|