@wordpress/editor 13.14.0 → 13.15.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 +2 -0
- package/build/components/entities-saved-states/entity-record-item.js +3 -37
- package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build/components/entities-saved-states/entity-type-list.js +2 -4
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/entities-saved-states/index.js +0 -1
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/{save-shortcut.js → index.js} +13 -25
- package/build/components/global-keyboard-shortcuts/index.js.map +1 -0
- package/build/components/index.js +32 -19
- package/build/components/index.js.map +1 -1
- package/build/components/post-preview-button/index.js +62 -157
- package/build/components/post-preview-button/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +4 -9
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-button/label.js +2 -4
- package/build/components/post-publish-button/label.js.map +1 -1
- package/build/components/post-publish-panel/index.js +1 -3
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-saved-state/index.js +2 -5
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-schedule/label.js +4 -4
- package/build/components/post-schedule/label.js.map +1 -1
- package/build/components/post-sync-status/index.js +84 -5
- package/build/components/post-sync-status/index.js.map +1 -1
- package/build/components/post-text-editor/index.js +51 -58
- package/build/components/post-text-editor/index.js.map +1 -1
- package/build/store/actions.js +37 -3
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +53 -61
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js +6 -40
- package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-type-list.js +2 -4
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +0 -1
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/{save-shortcut.js → index.js} +12 -23
- package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -0
- package/build-module/components/index.js +9 -4
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/post-preview-button/index.js +63 -149
- package/build-module/components/post-preview-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +4 -9
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/label.js +2 -4
- package/build-module/components/post-publish-button/label.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js +1 -3
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +2 -5
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-schedule/label.js +4 -4
- package/build-module/components/post-schedule/label.js.map +1 -1
- package/build-module/components/post-sync-status/index.js +84 -8
- package/build-module/components/post-sync-status/index.js.map +1 -1
- package/build-module/components/post-text-editor/index.js +48 -56
- package/build-module/components/post-text-editor/index.js.map +1 -1
- package/build-module/store/actions.js +31 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +46 -55
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +0 -18
- package/build-style/style.css +0 -18
- package/package.json +30 -30
- package/src/components/entities-saved-states/entity-record-item.js +3 -61
- package/src/components/entities-saved-states/entity-type-list.js +0 -2
- package/src/components/entities-saved-states/index.js +0 -1
- package/src/components/entities-saved-states/style.scss +0 -15
- package/src/components/global-keyboard-shortcuts/index.js +49 -0
- package/src/components/index.js +12 -3
- package/src/components/post-preview-button/index.js +73 -156
- package/src/components/post-preview-button/test/index.js +94 -158
- package/src/components/post-publish-button/index.js +2 -7
- package/src/components/post-publish-button/label.js +2 -2
- package/src/components/post-publish-button/test/index.js +0 -10
- package/src/components/post-publish-panel/index.js +1 -3
- package/src/components/post-saved-state/index.js +2 -5
- package/src/components/post-schedule/label.js +4 -4
- package/src/components/post-sync-status/index.js +100 -7
- package/src/components/post-text-editor/index.js +34 -57
- package/src/components/post-title/style.native.scss +5 -5
- package/src/store/actions.js +34 -2
- package/src/store/selectors.js +45 -41
- package/src/store/test/selectors.js +36 -25
- package/build/components/global-keyboard-shortcuts/save-shortcut.js.map +0 -1
- package/build/components/global-keyboard-shortcuts/text-editor-shortcuts.js +0 -22
- package/build/components/global-keyboard-shortcuts/text-editor-shortcuts.js.map +0 -1
- package/build/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -45
- package/build/components/global-keyboard-shortcuts/visual-editor-shortcuts.js.map +0 -1
- package/build-module/components/global-keyboard-shortcuts/save-shortcut.js.map +0 -1
- package/build-module/components/global-keyboard-shortcuts/text-editor-shortcuts.js +0 -12
- package/build-module/components/global-keyboard-shortcuts/text-editor-shortcuts.js.map +0 -1
- package/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -32
- package/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js.map +0 -1
- package/src/components/global-keyboard-shortcuts/save-shortcut.js +0 -55
- package/src/components/global-keyboard-shortcuts/text-editor-shortcuts.js +0 -8
- package/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -29
- package/src/components/post-text-editor/test/index.js +0 -156
|
@@ -1,34 +1,24 @@
|
|
|
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
|
});
|
|
8
|
-
exports.default =
|
|
6
|
+
exports.default = PostPreviewButton;
|
|
9
7
|
|
|
10
8
|
var _element = require("@wordpress/element");
|
|
11
9
|
|
|
12
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
10
|
var _components = require("@wordpress/components");
|
|
15
11
|
|
|
16
12
|
var _i18n = require("@wordpress/i18n");
|
|
17
13
|
|
|
18
14
|
var _data = require("@wordpress/data");
|
|
19
15
|
|
|
20
|
-
var _compose = require("@wordpress/compose");
|
|
21
|
-
|
|
22
16
|
var _hooks = require("@wordpress/hooks");
|
|
23
17
|
|
|
24
18
|
var _coreData = require("@wordpress/core-data");
|
|
25
19
|
|
|
26
20
|
var _store = require("../../store");
|
|
27
21
|
|
|
28
|
-
/**
|
|
29
|
-
* External dependencies
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
22
|
/**
|
|
33
23
|
* WordPress dependencies
|
|
34
24
|
*/
|
|
@@ -117,54 +107,44 @@ function writeInterstitialMessage(targetDocument) {
|
|
|
117
107
|
targetDocument.close();
|
|
118
108
|
}
|
|
119
109
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (previewWindow && !previewWindow.closed) {
|
|
152
|
-
previewWindow.location = url;
|
|
110
|
+
function PostPreviewButton({
|
|
111
|
+
className,
|
|
112
|
+
textContent,
|
|
113
|
+
forceIsAutosaveable,
|
|
114
|
+
role,
|
|
115
|
+
onPreview
|
|
116
|
+
}) {
|
|
117
|
+
const {
|
|
118
|
+
postId,
|
|
119
|
+
currentPostLink,
|
|
120
|
+
previewLink,
|
|
121
|
+
isSaveable,
|
|
122
|
+
isViewable
|
|
123
|
+
} = (0, _data.useSelect)(select => {
|
|
124
|
+
var _postType$viewable;
|
|
125
|
+
|
|
126
|
+
const editor = select(_store.store);
|
|
127
|
+
const core = select(_coreData.store);
|
|
128
|
+
const postType = core.getPostType(editor.getCurrentPostType('type'));
|
|
129
|
+
return {
|
|
130
|
+
postId: editor.getCurrentPostId(),
|
|
131
|
+
currentPostLink: editor.getCurrentPostAttribute('link'),
|
|
132
|
+
previewLink: editor.getEditedPostPreviewLink(),
|
|
133
|
+
isSaveable: editor.isEditedPostSaveable(),
|
|
134
|
+
isViewable: (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false
|
|
135
|
+
};
|
|
136
|
+
}, []);
|
|
137
|
+
const {
|
|
138
|
+
__unstableSaveForPreview
|
|
139
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
153
140
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
}
|
|
141
|
+
if (!isViewable) {
|
|
142
|
+
return null;
|
|
158
143
|
}
|
|
159
144
|
|
|
160
|
-
|
|
161
|
-
const {
|
|
162
|
-
postId
|
|
163
|
-
} = this.props;
|
|
164
|
-
return `wp-preview-${postId}`;
|
|
165
|
-
}
|
|
145
|
+
const targetId = `wp-preview-${postId}`;
|
|
166
146
|
|
|
167
|
-
openPreviewWindow
|
|
147
|
+
const openPreviewWindow = async event => {
|
|
168
148
|
// Our Preview button has its 'href' and 'target' set correctly for a11y
|
|
169
149
|
// purposes. Unfortunately, though, we can't rely on the default 'click'
|
|
170
150
|
// handler since sometimes it incorrectly opens a new tab instead of reusing
|
|
@@ -172,110 +152,35 @@ class PostPreviewButton extends _element.Component {
|
|
|
172
152
|
// https://github.com/WordPress/gutenberg/pull/8330
|
|
173
153
|
event.preventDefault(); // Open up a Preview tab if needed. This is where we'll show the preview.
|
|
174
154
|
|
|
175
|
-
|
|
176
|
-
this.previewWindow = window.open('', this.getWindowTarget());
|
|
177
|
-
} // Focus the Preview tab. This might not do anything, depending on the browser's
|
|
155
|
+
const previewWindow = window.open('', targetId); // Focus the Preview tab. This might not do anything, depending on the browser's
|
|
178
156
|
// and user's preferences.
|
|
179
157
|
// https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus
|
|
180
158
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
render() {
|
|
210
|
-
const {
|
|
211
|
-
previewLink,
|
|
212
|
-
currentPostLink,
|
|
213
|
-
isSaveable,
|
|
214
|
-
role
|
|
215
|
-
} = this.props; // Link to the `?preview=true` URL if we have it, since this lets us see
|
|
216
|
-
// changes that were autosaved since the post was last published. Otherwise,
|
|
217
|
-
// just link to the post's URL.
|
|
218
|
-
|
|
219
|
-
const href = previewLink || currentPostLink;
|
|
220
|
-
const classNames = (0, _classnames.default)({
|
|
221
|
-
'editor-post-preview': !this.props.className
|
|
222
|
-
}, this.props.className);
|
|
223
|
-
return (0, _element.createElement)(_components.Button, {
|
|
224
|
-
variant: !this.props.className ? 'tertiary' : undefined,
|
|
225
|
-
className: classNames,
|
|
226
|
-
href: href,
|
|
227
|
-
target: this.getWindowTarget(),
|
|
228
|
-
disabled: !isSaveable,
|
|
229
|
-
onClick: this.openPreviewWindow,
|
|
230
|
-
ref: this.buttonRef,
|
|
231
|
-
role: role
|
|
232
|
-
}, this.props.textContent ? this.props.textContent : (0, _element.createElement)(_element.Fragment, null, (0, _i18n._x)('Preview', 'imperative verb'), (0, _element.createElement)(_components.VisuallyHidden, {
|
|
233
|
-
as: "span"
|
|
234
|
-
},
|
|
235
|
-
/* translators: accessibility text */
|
|
236
|
-
(0, _i18n.__)('(opens in a new tab)'))));
|
|
237
|
-
}
|
|
238
|
-
|
|
159
|
+
previewWindow.focus();
|
|
160
|
+
writeInterstitialMessage(previewWindow.document);
|
|
161
|
+
const link = await __unstableSaveForPreview({
|
|
162
|
+
forceIsAutosaveable
|
|
163
|
+
});
|
|
164
|
+
previewWindow.location = link;
|
|
165
|
+
onPreview?.();
|
|
166
|
+
}; // Link to the `?preview=true` URL if we have it, since this lets us see
|
|
167
|
+
// changes that were autosaved since the post was last published. Otherwise,
|
|
168
|
+
// just link to the post's URL.
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
const href = previewLink || currentPostLink;
|
|
172
|
+
return (0, _element.createElement)(_components.Button, {
|
|
173
|
+
variant: !className ? 'tertiary' : undefined,
|
|
174
|
+
className: className || 'editor-post-preview',
|
|
175
|
+
href: href,
|
|
176
|
+
target: targetId,
|
|
177
|
+
disabled: !isSaveable,
|
|
178
|
+
onClick: openPreviewWindow,
|
|
179
|
+
role: role
|
|
180
|
+
}, textContent || (0, _element.createElement)(_element.Fragment, null, (0, _i18n._x)('Preview', 'imperative verb'), (0, _element.createElement)(_components.VisuallyHidden, {
|
|
181
|
+
as: "span"
|
|
182
|
+
},
|
|
183
|
+
/* translators: accessibility text */
|
|
184
|
+
(0, _i18n.__)('(opens in a new tab)'))));
|
|
239
185
|
}
|
|
240
|
-
|
|
241
|
-
exports.PostPreviewButton = PostPreviewButton;
|
|
242
|
-
|
|
243
|
-
var _default = (0, _compose.compose)([(0, _data.withSelect)((select, {
|
|
244
|
-
forcePreviewLink,
|
|
245
|
-
forceIsAutosaveable
|
|
246
|
-
}) => {
|
|
247
|
-
var _postType$viewable;
|
|
248
|
-
|
|
249
|
-
const {
|
|
250
|
-
getCurrentPostId,
|
|
251
|
-
getCurrentPostAttribute,
|
|
252
|
-
getEditedPostAttribute,
|
|
253
|
-
isEditedPostSaveable,
|
|
254
|
-
isEditedPostAutosaveable,
|
|
255
|
-
getEditedPostPreviewLink,
|
|
256
|
-
isPostLocked
|
|
257
|
-
} = select(_store.store);
|
|
258
|
-
const {
|
|
259
|
-
getPostType
|
|
260
|
-
} = select(_coreData.store);
|
|
261
|
-
const previewLink = getEditedPostPreviewLink();
|
|
262
|
-
const postType = getPostType(getEditedPostAttribute('type'));
|
|
263
|
-
return {
|
|
264
|
-
postId: getCurrentPostId(),
|
|
265
|
-
currentPostLink: getCurrentPostAttribute('link'),
|
|
266
|
-
previewLink: forcePreviewLink !== undefined ? forcePreviewLink : previewLink,
|
|
267
|
-
isSaveable: isEditedPostSaveable(),
|
|
268
|
-
isAutosaveable: forceIsAutosaveable || isEditedPostAutosaveable(),
|
|
269
|
-
isViewable: (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false,
|
|
270
|
-
isDraft: ['draft', 'auto-draft'].indexOf(getEditedPostAttribute('status')) !== -1,
|
|
271
|
-
isPostLocked: isPostLocked()
|
|
272
|
-
};
|
|
273
|
-
}), (0, _data.withDispatch)(dispatch => ({
|
|
274
|
-
autosave: dispatch(_store.store).autosave,
|
|
275
|
-
savePost: dispatch(_store.store).savePost
|
|
276
|
-
})), (0, _compose.ifCondition)(({
|
|
277
|
-
isViewable
|
|
278
|
-
}) => isViewable)])(PostPreviewButton);
|
|
279
|
-
|
|
280
|
-
exports.default = _default;
|
|
281
186
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-preview-button/index.js"],"names":["writeInterstitialMessage","targetDocument","markup","write","title","close","PostPreviewButton","Component","constructor","arguments","buttonRef","openPreviewWindow","bind","componentDidUpdate","prevProps","previewLink","props","setPreviewWindowLink","url","previewWindow","closed","location","current","focus","getWindowTarget","postId","event","preventDefault","window","open","isAutosaveable","isPostLocked","target","href","isDraft","savePost","isPreview","autosave","document","render","currentPostLink","isSaveable","role","classNames","className","undefined","textContent","select","forcePreviewLink","forceIsAutosaveable","getCurrentPostId","getCurrentPostAttribute","getEditedPostAttribute","isEditedPostSaveable","isEditedPostAutosaveable","getEditedPostPreviewLink","editorStore","getPostType","coreStore","postType","isViewable","viewable","indexOf","dispatch"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;AAGA,SAASA,wBAAT,CAAmCC,cAAnC,EAAoD;AACnD,MAAIC,MAAM,GAAG,6BACZ;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,eAAD;AAAK,IAAA,KAAK,EAAC,4BAAX;AAAwC,IAAA,OAAO,EAAC;AAAhD,KACC,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAC,OADX;AAEC,IAAA,CAAC,EAAC,uEAFH;AAGC,IAAA,IAAI,EAAC;AAHN,IADD,EAMC,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAC,OADX;AAEC,IAAA,CAAC,EAAC,0nBAFH;AAGC,IAAA,IAAI,EAAC;AAHN,IAND,CADD,EAaC,uCAAK,cAAI,qBAAJ,CAAL,CAbD,CADY,CAAb;AAkBAA,EAAAA,MAAM,IAAK;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EArDC;AAuDA;AACD;AACA;AACA;AACA;;AACCA,EAAAA,MAAM,GAAG,yBAAc,uCAAd,EAAuDA,MAAvD,CAAT;AAEAD,EAAAA,cAAc,CAACE,KAAf,CAAsBD,MAAtB;AACAD,EAAAA,cAAc,CAACG,KAAf,GAAuB,cAAI,qBAAJ,CAAvB;AACAH,EAAAA,cAAc,CAACI,KAAf;AACA;;AAEM,MAAMC,iBAAN,SAAgCC,kBAAhC,CAA0C;AAChDC,EAAAA,WAAW,GAAG;AACb,UAAO,GAAGC,SAA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AAA,QAAQ,EAAE0B,QAAQ,CAAEP,YAAF,CAAR,CAAwBnB,QADH;AAE/BF,EAAAA,QAAQ,EAAE4B,QAAQ,CAAEP,YAAF,CAAR,CAAwBrB;AAFH,CAAlB,CAAd,CA/BuB,EAmCvB,0BAAa,CAAE;AAAEyB,EAAAA;AAAF,CAAF,KAAsBA,UAAnC,CAnCuB,CAAT,EAoCVtD,iBApCU,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Component, createRef, renderToString } from '@wordpress/element';\nimport { Button, Path, SVG, VisuallyHidden } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { ifCondition, compose } from '@wordpress/compose';\nimport { applyFilters } from '@wordpress/hooks';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction writeInterstitialMessage( targetDocument ) {\n\tlet markup = renderToString(\n\t\t<div className=\"editor-post-preview-button__interstitial-message\">\n\t\t\t<SVG xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 96 96\">\n\t\t\t\t<Path\n\t\t\t\t\tclassName=\"outer\"\n\t\t\t\t\td=\"M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t/>\n\t\t\t\t<Path\n\t\t\t\t\tclassName=\"inner\"\n\t\t\t\t\td=\"M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t/>\n\t\t\t</SVG>\n\t\t\t<p>{ __( 'Generating preview…' ) }</p>\n\t\t</div>\n\t);\n\n\tmarkup += `\n\t\t<style>\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\twidth: 100vw;\n\t\t\t}\n\t\t\t@-webkit-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-moz-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-o-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg {\n\t\t\t\twidth: 192px;\n\t\t\t\theight: 192px;\n\t\t\t\tstroke: #555d66;\n\t\t\t\tstroke-width: 0.75;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg .outer,\n\t\t\t.editor-post-preview-button__interstitial-message svg .inner {\n\t\t\t\tstroke-dasharray: 280;\n\t\t\t\tstroke-dashoffset: 280;\n\t\t\t\t-webkit-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-moz-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-o-animation: paint 1.5s ease infinite alternate;\n\t\t\t\tanimation: paint 1.5s ease infinite alternate;\n\t\t\t}\n\t\t\tp {\n\t\t\t\ttext-align: center;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n\t\t\t}\n\t\t</style>\n\t`;\n\n\t/**\n\t * Filters the interstitial message shown when generating previews.\n\t *\n\t * @param {string} markup The preview interstitial markup.\n\t */\n\tmarkup = applyFilters( 'editor.PostPreview.interstitialMarkup', markup );\n\n\ttargetDocument.write( markup );\n\ttargetDocument.title = __( 'Generating preview…' );\n\ttargetDocument.close();\n}\n\nexport class PostPreviewButton extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.buttonRef = createRef();\n\n\t\tthis.openPreviewWindow = this.openPreviewWindow.bind( this );\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { previewLink } = this.props;\n\t\t// This relies on the window being responsible to unset itself when\n\t\t// navigation occurs or a new preview window is opened, to avoid\n\t\t// unintentional forceful redirects.\n\t\tif ( previewLink && ! prevProps.previewLink ) {\n\t\t\tthis.setPreviewWindowLink( previewLink );\n\t\t}\n\t}\n\n\t/**\n\t * Sets the preview window's location to the given URL, if a preview window\n\t * exists and is not closed.\n\t *\n\t * @param {string} url URL to assign as preview window location.\n\t */\n\tsetPreviewWindowLink( url ) {\n\t\tconst { previewWindow } = this;\n\n\t\tif ( previewWindow && ! previewWindow.closed ) {\n\t\t\tpreviewWindow.location = url;\n\t\t\tif ( this.buttonRef.current ) {\n\t\t\t\tthis.buttonRef.current.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tgetWindowTarget() {\n\t\tconst { postId } = this.props;\n\t\treturn `wp-preview-${ postId }`;\n\t}\n\n\topenPreviewWindow( event ) {\n\t\t// Our Preview button has its 'href' and 'target' set correctly for a11y\n\t\t// purposes. Unfortunately, though, we can't rely on the default 'click'\n\t\t// handler since sometimes it incorrectly opens a new tab instead of reusing\n\t\t// the existing one.\n\t\t// https://github.com/WordPress/gutenberg/pull/8330\n\t\tevent.preventDefault();\n\n\t\t// Open up a Preview tab if needed. This is where we'll show the preview.\n\t\tif ( ! this.previewWindow || this.previewWindow.closed ) {\n\t\t\tthis.previewWindow = window.open( '', this.getWindowTarget() );\n\t\t}\n\n\t\t// Focus the Preview tab. This might not do anything, depending on the browser's\n\t\t// and user's preferences.\n\t\t// https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus\n\t\tthis.previewWindow.focus();\n\n\t\tif (\n\t\t\t// If we don't need to autosave the post before previewing, then we simply\n\t\t\t// load the Preview URL in the Preview tab.\n\t\t\t! this.props.isAutosaveable ||\n\t\t\t// Do not save or overwrite the post, if the post is already locked.\n\t\t\tthis.props.isPostLocked\n\t\t) {\n\t\t\tthis.setPreviewWindowLink( event.target.href );\n\t\t\treturn;\n\t\t}\n\n\t\t// Request an autosave. This happens asynchronously and causes the component\n\t\t// to update when finished.\n\t\tif ( this.props.isDraft ) {\n\t\t\tthis.props.savePost( { isPreview: true } );\n\t\t} else {\n\t\t\tthis.props.autosave( { isPreview: true } );\n\t\t}\n\n\t\t// Display a 'Generating preview' message in the Preview tab while we wait for the\n\t\t// autosave to finish.\n\t\twriteInterstitialMessage( this.previewWindow.document );\n\t}\n\n\trender() {\n\t\tconst { previewLink, currentPostLink, isSaveable, role } = this.props;\n\n\t\t// Link to the `?preview=true` URL if we have it, since this lets us see\n\t\t// changes that were autosaved since the post was last published. Otherwise,\n\t\t// just link to the post's URL.\n\t\tconst href = previewLink || currentPostLink;\n\n\t\tconst classNames = classnames(\n\t\t\t{\n\t\t\t\t'editor-post-preview': ! this.props.className,\n\t\t\t},\n\t\t\tthis.props.className\n\t\t);\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\tvariant={ ! this.props.className ? 'tertiary' : undefined }\n\t\t\t\tclassName={ classNames }\n\t\t\t\thref={ href }\n\t\t\t\ttarget={ this.getWindowTarget() }\n\t\t\t\tdisabled={ ! isSaveable }\n\t\t\t\tonClick={ this.openPreviewWindow }\n\t\t\t\tref={ this.buttonRef }\n\t\t\t\trole={ role }\n\t\t\t>\n\t\t\t\t{ this.props.textContent ? (\n\t\t\t\t\tthis.props.textContent\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ _x( 'Preview', 'imperative verb' ) }\n\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</Button>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select, { forcePreviewLink, forceIsAutosaveable } ) => {\n\t\tconst {\n\t\t\tgetCurrentPostId,\n\t\t\tgetCurrentPostAttribute,\n\t\t\tgetEditedPostAttribute,\n\t\t\tisEditedPostSaveable,\n\t\t\tisEditedPostAutosaveable,\n\t\t\tgetEditedPostPreviewLink,\n\t\t\tisPostLocked,\n\t\t} = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\n\t\tconst previewLink = getEditedPostPreviewLink();\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tcurrentPostLink: getCurrentPostAttribute( 'link' ),\n\t\t\tpreviewLink:\n\t\t\t\tforcePreviewLink !== undefined ? forcePreviewLink : previewLink,\n\t\t\tisSaveable: isEditedPostSaveable(),\n\t\t\tisAutosaveable: forceIsAutosaveable || isEditedPostAutosaveable(),\n\t\t\tisViewable: postType?.viewable ?? false,\n\t\t\tisDraft:\n\t\t\t\t[ 'draft', 'auto-draft' ].indexOf(\n\t\t\t\t\tgetEditedPostAttribute( 'status' )\n\t\t\t\t) !== -1,\n\t\t\tisPostLocked: isPostLocked(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => ( {\n\t\tautosave: dispatch( editorStore ).autosave,\n\t\tsavePost: dispatch( editorStore ).savePost,\n\t} ) ),\n\tifCondition( ( { isViewable } ) => isViewable ),\n] )( PostPreviewButton );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-preview-button/index.js"],"names":["writeInterstitialMessage","targetDocument","markup","write","title","close","PostPreviewButton","className","textContent","forceIsAutosaveable","role","onPreview","postId","currentPostLink","previewLink","isSaveable","isViewable","select","editor","editorStore","core","coreStore","postType","getPostType","getCurrentPostType","getCurrentPostId","getCurrentPostAttribute","getEditedPostPreviewLink","isEditedPostSaveable","viewable","__unstableSaveForPreview","targetId","openPreviewWindow","event","preventDefault","previewWindow","window","open","focus","document","link","location","href","undefined"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAbA;AACA;AACA;;AAQA;AACA;AACA;AAGA,SAASA,wBAAT,CAAmCC,cAAnC,EAAoD;AACnD,MAAIC,MAAM,GAAG,6BACZ;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,eAAD;AAAK,IAAA,KAAK,EAAC,4BAAX;AAAwC,IAAA,OAAO,EAAC;AAAhD,KACC,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAC,OADX;AAEC,IAAA,CAAC,EAAC,uEAFH;AAGC,IAAA,IAAI,EAAC;AAHN,IADD,EAMC,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAC,OADX;AAEC,IAAA,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AO,EAAGiB,iBANX;AAOC,IAAA,IAAI,EAAGtB;AAPR,KASGF,WAAW,IACZ,qDACG,cAAI,SAAJ,EAAe,iBAAf,CADH,EAEC,4BAAC,0BAAD;AAAgB,IAAA,EAAE,EAAC;AAAnB;AAEE;AACA,gBAAI,sBAAJ,CAHF,CAFD,CAVF,CADD;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { renderToString } from '@wordpress/element';\nimport { Button, Path, SVG, VisuallyHidden } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { applyFilters } from '@wordpress/hooks';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction writeInterstitialMessage( targetDocument ) {\n\tlet markup = renderToString(\n\t\t<div className=\"editor-post-preview-button__interstitial-message\">\n\t\t\t<SVG xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 96 96\">\n\t\t\t\t<Path\n\t\t\t\t\tclassName=\"outer\"\n\t\t\t\t\td=\"M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t/>\n\t\t\t\t<Path\n\t\t\t\t\tclassName=\"inner\"\n\t\t\t\t\td=\"M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t/>\n\t\t\t</SVG>\n\t\t\t<p>{ __( 'Generating preview…' ) }</p>\n\t\t</div>\n\t);\n\n\tmarkup += `\n\t\t<style>\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\twidth: 100vw;\n\t\t\t}\n\t\t\t@-webkit-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-moz-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-o-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg {\n\t\t\t\twidth: 192px;\n\t\t\t\theight: 192px;\n\t\t\t\tstroke: #555d66;\n\t\t\t\tstroke-width: 0.75;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg .outer,\n\t\t\t.editor-post-preview-button__interstitial-message svg .inner {\n\t\t\t\tstroke-dasharray: 280;\n\t\t\t\tstroke-dashoffset: 280;\n\t\t\t\t-webkit-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-moz-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-o-animation: paint 1.5s ease infinite alternate;\n\t\t\t\tanimation: paint 1.5s ease infinite alternate;\n\t\t\t}\n\t\t\tp {\n\t\t\t\ttext-align: center;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n\t\t\t}\n\t\t</style>\n\t`;\n\n\t/**\n\t * Filters the interstitial message shown when generating previews.\n\t *\n\t * @param {string} markup The preview interstitial markup.\n\t */\n\tmarkup = applyFilters( 'editor.PostPreview.interstitialMarkup', markup );\n\n\ttargetDocument.write( markup );\n\ttargetDocument.title = __( 'Generating preview…' );\n\ttargetDocument.close();\n}\n\nexport default function PostPreviewButton( {\n\tclassName,\n\ttextContent,\n\tforceIsAutosaveable,\n\trole,\n\tonPreview,\n} ) {\n\tconst { postId, currentPostLink, previewLink, isSaveable, isViewable } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst editor = select( editorStore );\n\t\t\tconst core = select( coreStore );\n\n\t\t\tconst postType = core.getPostType(\n\t\t\t\teditor.getCurrentPostType( 'type' )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tpostId: editor.getCurrentPostId(),\n\t\t\t\tcurrentPostLink: editor.getCurrentPostAttribute( 'link' ),\n\t\t\t\tpreviewLink: editor.getEditedPostPreviewLink(),\n\t\t\t\tisSaveable: editor.isEditedPostSaveable(),\n\t\t\t\tisViewable: postType?.viewable ?? false,\n\t\t\t};\n\t\t}, [] );\n\n\tconst { __unstableSaveForPreview } = useDispatch( editorStore );\n\n\tif ( ! isViewable ) {\n\t\treturn null;\n\t}\n\n\tconst targetId = `wp-preview-${ postId }`;\n\n\tconst openPreviewWindow = async ( event ) => {\n\t\t// Our Preview button has its 'href' and 'target' set correctly for a11y\n\t\t// purposes. Unfortunately, though, we can't rely on the default 'click'\n\t\t// handler since sometimes it incorrectly opens a new tab instead of reusing\n\t\t// the existing one.\n\t\t// https://github.com/WordPress/gutenberg/pull/8330\n\t\tevent.preventDefault();\n\n\t\t// Open up a Preview tab if needed. This is where we'll show the preview.\n\t\tconst previewWindow = window.open( '', targetId );\n\n\t\t// Focus the Preview tab. This might not do anything, depending on the browser's\n\t\t// and user's preferences.\n\t\t// https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus\n\t\tpreviewWindow.focus();\n\n\t\twriteInterstitialMessage( previewWindow.document );\n\n\t\tconst link = await __unstableSaveForPreview( { forceIsAutosaveable } );\n\n\t\tpreviewWindow.location = link;\n\n\t\tonPreview?.();\n\t};\n\n\t// Link to the `?preview=true` URL if we have it, since this lets us see\n\t// changes that were autosaved since the post was last published. Otherwise,\n\t// just link to the post's URL.\n\tconst href = previewLink || currentPostLink;\n\n\treturn (\n\t\t<Button\n\t\t\tvariant={ ! className ? 'tertiary' : undefined }\n\t\t\tclassName={ className || 'editor-post-preview' }\n\t\t\thref={ href }\n\t\t\ttarget={ targetId }\n\t\t\tdisabled={ ! isSaveable }\n\t\t\tonClick={ openPreviewWindow }\n\t\t\trole={ role }\n\t\t>\n\t\t\t{ textContent || (\n\t\t\t\t<>\n\t\t\t\t\t{ _x( 'Preview', 'imperative verb' ) }\n\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t}\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</Button>\n\t);\n}\n"]}
|
|
@@ -113,7 +113,6 @@ class PostPublishButton extends _element.Component {
|
|
|
113
113
|
render() {
|
|
114
114
|
const {
|
|
115
115
|
forceIsDirty,
|
|
116
|
-
forceIsSaving,
|
|
117
116
|
hasPublishAction,
|
|
118
117
|
isBeingScheduled,
|
|
119
118
|
isOpen,
|
|
@@ -132,8 +131,8 @@ class PostPublishButton extends _element.Component {
|
|
|
132
131
|
hasNonPostEntityChanges,
|
|
133
132
|
isSavingNonPostEntityChanges
|
|
134
133
|
} = this.props;
|
|
135
|
-
const isButtonDisabled = (isSaving ||
|
|
136
|
-
const isToggleDisabled = (isPublished || isSaving ||
|
|
134
|
+
const isButtonDisabled = (isSaving || !isSaveable || isPostSavingLocked || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
|
|
135
|
+
const isToggleDisabled = (isPublished || isSaving || !isSaveable || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
|
|
137
136
|
let publishStatus;
|
|
138
137
|
|
|
139
138
|
if (!hasPublishAction) {
|
|
@@ -181,7 +180,6 @@ class PostPublishButton extends _element.Component {
|
|
|
181
180
|
};
|
|
182
181
|
const toggleChildren = isBeingScheduled ? (0, _i18n.__)('Schedule…') : (0, _i18n.__)('Publish');
|
|
183
182
|
const buttonChildren = (0, _element.createElement)(_label.default, {
|
|
184
|
-
forceIsSaving: forceIsSaving,
|
|
185
183
|
hasNonPostEntityChanges: hasNonPostEntityChanges
|
|
186
184
|
});
|
|
187
185
|
const componentProps = isToggle ? toggleProps : buttonProps;
|
|
@@ -217,12 +215,9 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
|
217
215
|
hasNonPostEntityChanges,
|
|
218
216
|
isSavingNonPostEntityChanges
|
|
219
217
|
} = select(_store.store);
|
|
220
|
-
|
|
221
|
-
const _isAutoSaving = isAutosavingPost();
|
|
222
|
-
|
|
223
218
|
return {
|
|
224
|
-
isSaving: isSavingPost()
|
|
225
|
-
isAutoSaving:
|
|
219
|
+
isSaving: isSavingPost(),
|
|
220
|
+
isAutoSaving: isAutosavingPost(),
|
|
226
221
|
isBeingScheduled: isEditedPostBeingScheduled(),
|
|
227
222
|
visibility: getEditedPostVisibility(),
|
|
228
223
|
isSaveable: isEditedPostSaveable(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-button/index.js"],"names":["noop","PostPublishButton","Component","constructor","props","buttonNode","createOnClick","bind","closeEntitiesSavedStates","state","entitiesSavedStatesCallback","componentDidMount","focusOnMount","timeoutID","setTimeout","current","focus","componentWillUnmount","clearTimeout","callback","args","hasNonPostEntityChanges","setEntitiesSavedStatesCallback","setState","savedEntities","postType","postId","some","elt","kind","name","key","render","forceIsDirty","forceIsSaving","hasPublishAction","isBeingScheduled","isOpen","isPostSavingLocked","isPublishable","isPublished","isSaveable","isSaving","isAutoSaving","isToggle","onSave","onStatusChange","onSubmit","onToggle","visibility","isSavingNonPostEntityChanges","isButtonDisabled","isToggleDisabled","publishStatus","onClickButton","onClickToggle","buttonProps","className","isBusy","variant","onClick","toggleProps","toggleChildren","buttonChildren","componentProps","componentChildren","select","isSavingPost","isAutosavingPost","isEditedPostBeingScheduled","getEditedPostVisibility","isCurrentPostPublished","isEditedPostSaveable","isEditedPostPublishable","getCurrentPost","getCurrentPostType","getCurrentPostId","editorStore","_isAutoSaving","_links","dispatch","editPost","savePost","status","undoIgnore"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEO,MAAMC,iBAAN,SAAgCC,kBAAhC,CAA0C;AAChDC,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAOA,KAAP;AACA,SAAKC,UAAL,GAAkB,yBAAlB;AAEA,SAAKC,aAAL,GAAqB,KAAKA,aAAL,CAAmBC,IAAnB,CAAyB,IAAzB,CAArB;AACA,SAAKC,wBAAL,GACC,KAAKA,wBAAL,CAA8BD,IAA9B,CAAoC,IAApC,CADD;AAGA,SAAKE,K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8B,QAAF,IAAgB;AAC7B,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAyBF,QAAQ,CAAEH,YAAF,CAAvC;AACA,SAAO;AACN/B,IAAAA,cAAc,EAAIqC,MAAF,IACfF,QAAQ,CAAE;AAAEE,MAAAA;AAAF,KAAF,EAAc;AAAEC,MAAAA,UAAU,EAAE;AAAd,KAAd,CAFH;AAGNvC,IAAAA,MAAM,EAAEqC;AAHF,GAAP;AAKA,CAPD,CAnCuB,CAAT,EA2CVjF,iBA3CU,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { Component, createRef } from '@wordpress/element';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PublishButtonLabel from './label';\nimport { store as editorStore } from '../../store';\n\nconst noop = () => {};\n\nexport class PostPublishButton extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\t\tthis.buttonNode = createRef();\n\n\t\tthis.createOnClick = this.createOnClick.bind( this );\n\t\tthis.closeEntitiesSavedStates =\n\t\t\tthis.closeEntitiesSavedStates.bind( this );\n\n\t\tthis.state = {\n\t\t\tentitiesSavedStatesCallback: false,\n\t\t};\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.props.focusOnMount ) {\n\t\t\t// This timeout is necessary to make sure the `useEffect` hook of\n\t\t\t// `useFocusReturn` gets the correct element (the button that opens the\n\t\t\t// PostPublishPanel) otherwise it will get this button.\n\t\t\tthis.timeoutID = setTimeout( () => {\n\t\t\t\tthis.buttonNode.current.focus();\n\t\t\t}, 0 );\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tclearTimeout( this.timeoutID );\n\t}\n\n\tcreateOnClick( callback ) {\n\t\treturn ( ...args ) => {\n\t\t\tconst { hasNonPostEntityChanges, setEntitiesSavedStatesCallback } =\n\t\t\t\tthis.props;\n\t\t\t// If a post with non-post entities is published, but the user\n\t\t\t// elects to not save changes to the non-post entities, those\n\t\t\t// entities will still be dirty when the Publish button is clicked.\n\t\t\t// We also need to check that the `setEntitiesSavedStatesCallback`\n\t\t\t// prop was passed. See https://github.com/WordPress/gutenberg/pull/37383\n\t\t\tif ( hasNonPostEntityChanges && setEntitiesSavedStatesCallback ) {\n\t\t\t\t// The modal for multiple entity saving will open,\n\t\t\t\t// hold the callback for saving/publishing the post\n\t\t\t\t// so that we can call it if the post entity is checked.\n\t\t\t\tthis.setState( {\n\t\t\t\t\tentitiesSavedStatesCallback: () => callback( ...args ),\n\t\t\t\t} );\n\n\t\t\t\t// Open the save panel by setting its callback.\n\t\t\t\t// To set a function on the useState hook, we must set it\n\t\t\t\t// with another function (() => myFunction). Passing the\n\t\t\t\t// function on its own will cause an error when called.\n\t\t\t\tsetEntitiesSavedStatesCallback(\n\t\t\t\t\t() => this.closeEntitiesSavedStates\n\t\t\t\t);\n\t\t\t\treturn noop;\n\t\t\t}\n\n\t\t\treturn callback( ...args );\n\t\t};\n\t}\n\n\tcloseEntitiesSavedStates( savedEntities ) {\n\t\tconst { postType, postId } = this.props;\n\t\tconst { entitiesSavedStatesCallback } = this.state;\n\t\tthis.setState( { entitiesSavedStatesCallback: false }, () => {\n\t\t\tif (\n\t\t\t\tsavedEntities &&\n\t\t\t\tsavedEntities.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === 'postType' &&\n\t\t\t\t\t\telt.name === postType &&\n\t\t\t\t\t\telt.key === postId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// The post entity was checked, call the held callback from `createOnClick`.\n\t\t\t\tentitiesSavedStatesCallback();\n\t\t\t}\n\t\t} );\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tforceIsDirty,\n\t\t\tforceIsSaving,\n\t\t\thasPublishAction,\n\t\t\tisBeingScheduled,\n\t\t\tisOpen,\n\t\t\tisPostSavingLocked,\n\t\t\tisPublishable,\n\t\t\tisPublished,\n\t\t\tisSaveable,\n\t\t\tisSaving,\n\t\t\tisAutoSaving,\n\t\t\tisToggle,\n\t\t\tonSave,\n\t\t\tonStatusChange,\n\t\t\tonSubmit = noop,\n\t\t\tonToggle,\n\t\t\tvisibility,\n\t\t\thasNonPostEntityChanges,\n\t\t\tisSavingNonPostEntityChanges,\n\t\t} = this.props;\n\n\t\tconst isButtonDisabled =\n\t\t\t( isSaving ||\n\t\t\t\tforceIsSaving ||\n\t\t\t\t! isSaveable ||\n\t\t\t\tisPostSavingLocked ||\n\t\t\t\t( ! isPublishable && ! forceIsDirty ) ) &&\n\t\t\t( ! hasNonPostEntityChanges || isSavingNonPostEntityChanges );\n\n\t\tconst isToggleDisabled =\n\t\t\t( isPublished ||\n\t\t\t\tisSaving ||\n\t\t\t\tforceIsSaving ||\n\t\t\t\t! isSaveable ||\n\t\t\t\t( ! isPublishable && ! forceIsDirty ) ) &&\n\t\t\t( ! hasNonPostEntityChanges || isSavingNonPostEntityChanges );\n\n\t\tlet publishStatus;\n\t\tif ( ! hasPublishAction ) {\n\t\t\tpublishStatus = 'pending';\n\t\t} else if ( visibility === 'private' ) {\n\t\t\tpublishStatus = 'private';\n\t\t} else if ( isBeingScheduled ) {\n\t\t\tpublishStatus = 'future';\n\t\t} else {\n\t\t\tpublishStatus = 'publish';\n\t\t}\n\n\t\tconst onClickButton = () => {\n\t\t\tif ( isButtonDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonSubmit();\n\t\t\tonStatusChange( publishStatus );\n\t\t\tonSave();\n\t\t};\n\n\t\tconst onClickToggle = () => {\n\t\t\tif ( isToggleDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonToggle();\n\t\t};\n\n\t\tconst buttonProps = {\n\t\t\t'aria-disabled': isButtonDisabled,\n\t\t\tclassName: 'editor-post-publish-button',\n\t\t\tisBusy: ! isAutoSaving && isSaving,\n\t\t\tvariant: 'primary',\n\t\t\tonClick: this.createOnClick( onClickButton ),\n\t\t};\n\n\t\tconst toggleProps = {\n\t\t\t'aria-disabled': isToggleDisabled,\n\t\t\t'aria-expanded': isOpen,\n\t\t\tclassName: 'editor-post-publish-panel__toggle',\n\t\t\tisBusy: isSaving && isPublished,\n\t\t\tvariant: 'primary',\n\t\t\tonClick: this.createOnClick( onClickToggle ),\n\t\t};\n\n\t\tconst toggleChildren = isBeingScheduled\n\t\t\t? __( 'Schedule…' )\n\t\t\t: __( 'Publish' );\n\t\tconst buttonChildren = (\n\t\t\t<PublishButtonLabel\n\t\t\t\tforceIsSaving={ forceIsSaving }\n\t\t\t\thasNonPostEntityChanges={ hasNonPostEntityChanges }\n\t\t\t/>\n\t\t);\n\n\t\tconst componentProps = isToggle ? toggleProps : buttonProps;\n\t\tconst componentChildren = isToggle ? toggleChildren : buttonChildren;\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<Button\n\t\t\t\t\tref={ this.buttonNode }\n\t\t\t\t\t{ ...componentProps }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\tcomponentProps.className,\n\t\t\t\t\t\t'editor-post-publish-button__button',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'has-changes-dot': hasNonPostEntityChanges,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ componentChildren }\n\t\t\t\t</Button>\n\t\t\t</>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tisSavingPost,\n\t\t\tisAutosavingPost,\n\t\t\tisEditedPostBeingScheduled,\n\t\t\tgetEditedPostVisibility,\n\t\t\tisCurrentPostPublished,\n\t\t\tisEditedPostSaveable,\n\t\t\tisEditedPostPublishable,\n\t\t\tisPostSavingLocked,\n\t\t\tgetCurrentPost,\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentPostId,\n\t\t\thasNonPostEntityChanges,\n\t\t\tisSavingNonPostEntityChanges,\n\t\t} = select( editorStore );\n\t\tconst _isAutoSaving = isAutosavingPost();\n\t\treturn {\n\t\t\tisSaving: isSavingPost() || _isAutoSaving,\n\t\t\tisAutoSaving: _isAutoSaving,\n\t\t\tisBeingScheduled: isEditedPostBeingScheduled(),\n\t\t\tvisibility: getEditedPostVisibility(),\n\t\t\tisSaveable: isEditedPostSaveable(),\n\t\t\tisPostSavingLocked: isPostSavingLocked(),\n\t\t\tisPublishable: isEditedPostPublishable(),\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\thasPublishAction:\n\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t\thasNonPostEntityChanges: hasNonPostEntityChanges(),\n\t\t\tisSavingNonPostEntityChanges: isSavingNonPostEntityChanges(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { editPost, savePost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonStatusChange: ( status ) =>\n\t\t\t\teditPost( { status }, { undoIgnore: true } ),\n\t\t\tonSave: savePost,\n\t\t};\n\t} ),\n] )( PostPublishButton );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-button/index.js"],"names":["noop","PostPublishButton","Component","constructor","props","buttonNode","createOnClick","bind","closeEntitiesSavedStates","state","entitiesSavedStatesCallback","componentDidMount","focusOnMount","timeoutID","setTimeout","current","focus","componentWillUnmount","clearTimeout","callback","args","hasNonPostEntityChanges","setEntitiesSavedStatesCallback","setState","savedEntities","postType","postId","some","elt","kind","name","key","render","forceIsDirty","hasPublishAction","isBeingScheduled","isOpen","isPostSavingLocked","isPublishable","isPublished","isSaveable","isSaving","isAutoSaving","isToggle","onSave","onStatusChange","onSubmit","onToggle","visibility","isSavingNonPostEntityChanges","isButtonDisabled","isToggleDisabled","publishStatus","onClickButton","onClickToggle","buttonProps","className","isBusy","variant","onClick","toggleProps","toggleChildren","buttonChildren","componentProps","componentChildren","select","isSavingPost","isAutosavingPost","isEditedPostBeingScheduled","getEditedPostVisibility","isCurrentPostPublished","isEditedPostSaveable","isEditedPostPublishable","getCurrentPost","getCurrentPostType","getCurrentPostId","editorStore","_links","dispatch","editPost","savePost","status","undoIgnore"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEO,MAAMC,iBAAN,SAAgCC,kBAAhC,CAA0C;AAChDC,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAOA,KAAP;AACA,SAAKC,UAAL,GAAkB,yBAAlB;AAEA,SAAKC,aAAL,GAAqB,KAAKA,aAAL,CAAmBC,IAAnB,CAAyB,IAAzB,CAArB;AACA,SAAKC,wBAAL,GACC,KAAKA,wBAAL,CAA8BD,IAA9B,CAAoC,IAApC,CADD;AAGA,SAAKE,KAAL,GAAa;AACZC,MAAAA,2BAA2B,EAAE;AADjB,KAAb;AAGA;;AAEDC,EAAAA,iBAAiB,GAAG;AACnB,QAAK,KAAKP,KAAL,CAAWQ,YAAhB,EAA+B;AAC9B;AACA;AACA;AACA,WAAKC,SAAL,GAAiBC,UAAU,CAAE,MAAM;AAClC,aAAKT,UAAL,CAAgBU,OAAhB,CAAwBC,KAAxB;AACA,OAF0B,EAExB,CAFwB,CAA3B;AAGA;AACD;;AAEDC,EAAAA,oBAAoB,GAAG;AACtBC,IAAAA,YAAY,CAAE,KAAKL,SAAP,CAAZ;AACA;;AAEDP,EAAAA,aAAa,CAAEa,QAAF,EAAa;AACzB,WAAO,CAAE,GAAGC,IAAL,KAAe;AACrB,YAAM;AAAEC,QAAAA,uBAAF;AAA2BC,QAAAA;AAA3B,UACL,KAAKlB,KADN,CADqB,CAGrB;AACA;AACA;AACA;AACA;;AACA,UAAKiB,uBAAuB,IAAIC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AAU,EAAEqB,uBAAuB,EAJ7B;AAKN7B,IAAAA,UAAU,EAAE+B,oBAAoB,EAL1B;AAMNlC,IAAAA,kBAAkB,EAAEA,kBAAkB,EANhC;AAONC,IAAAA,aAAa,EAAEkC,uBAAuB,EAPhC;AAQNjC,IAAAA,WAAW,EAAE+B,sBAAsB,EAR7B;AASNpC,IAAAA,gBAAgB,2BACfuC,cAAc,GAAGI,MAAjB,GAA2B,mBAA3B,CADe,yEACqC,KAV/C;AAWNpD,IAAAA,QAAQ,EAAEiD,kBAAkB,EAXtB;AAYNhD,IAAAA,MAAM,EAAEiD,gBAAgB,EAZlB;AAaNtD,IAAAA,uBAAuB,EAAEA,uBAAuB,EAb1C;AAcN4B,IAAAA,4BAA4B,EAAEA,4BAA4B;AAdpD,GAAP;AAgBA,CAhCD,CADuB,EAkCvB,wBAAgB6B,QAAF,IAAgB;AAC7B,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAyBF,QAAQ,CAAEF,YAAF,CAAvC;AACA,SAAO;AACN/B,IAAAA,cAAc,EAAIoC,MAAF,IACfF,QAAQ,CAAE;AAAEE,MAAAA;AAAF,KAAF,EAAc;AAAEC,MAAAA,UAAU,EAAE;AAAd,KAAd,CAFH;AAGNtC,IAAAA,MAAM,EAAEoC;AAHF,GAAP;AAKA,CAPD,CAlCuB,CAAT,EA0CV/E,iBA1CU,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { Component, createRef } from '@wordpress/element';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PublishButtonLabel from './label';\nimport { store as editorStore } from '../../store';\n\nconst noop = () => {};\n\nexport class PostPublishButton extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\t\tthis.buttonNode = createRef();\n\n\t\tthis.createOnClick = this.createOnClick.bind( this );\n\t\tthis.closeEntitiesSavedStates =\n\t\t\tthis.closeEntitiesSavedStates.bind( this );\n\n\t\tthis.state = {\n\t\t\tentitiesSavedStatesCallback: false,\n\t\t};\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.props.focusOnMount ) {\n\t\t\t// This timeout is necessary to make sure the `useEffect` hook of\n\t\t\t// `useFocusReturn` gets the correct element (the button that opens the\n\t\t\t// PostPublishPanel) otherwise it will get this button.\n\t\t\tthis.timeoutID = setTimeout( () => {\n\t\t\t\tthis.buttonNode.current.focus();\n\t\t\t}, 0 );\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tclearTimeout( this.timeoutID );\n\t}\n\n\tcreateOnClick( callback ) {\n\t\treturn ( ...args ) => {\n\t\t\tconst { hasNonPostEntityChanges, setEntitiesSavedStatesCallback } =\n\t\t\t\tthis.props;\n\t\t\t// If a post with non-post entities is published, but the user\n\t\t\t// elects to not save changes to the non-post entities, those\n\t\t\t// entities will still be dirty when the Publish button is clicked.\n\t\t\t// We also need to check that the `setEntitiesSavedStatesCallback`\n\t\t\t// prop was passed. See https://github.com/WordPress/gutenberg/pull/37383\n\t\t\tif ( hasNonPostEntityChanges && setEntitiesSavedStatesCallback ) {\n\t\t\t\t// The modal for multiple entity saving will open,\n\t\t\t\t// hold the callback for saving/publishing the post\n\t\t\t\t// so that we can call it if the post entity is checked.\n\t\t\t\tthis.setState( {\n\t\t\t\t\tentitiesSavedStatesCallback: () => callback( ...args ),\n\t\t\t\t} );\n\n\t\t\t\t// Open the save panel by setting its callback.\n\t\t\t\t// To set a function on the useState hook, we must set it\n\t\t\t\t// with another function (() => myFunction). Passing the\n\t\t\t\t// function on its own will cause an error when called.\n\t\t\t\tsetEntitiesSavedStatesCallback(\n\t\t\t\t\t() => this.closeEntitiesSavedStates\n\t\t\t\t);\n\t\t\t\treturn noop;\n\t\t\t}\n\n\t\t\treturn callback( ...args );\n\t\t};\n\t}\n\n\tcloseEntitiesSavedStates( savedEntities ) {\n\t\tconst { postType, postId } = this.props;\n\t\tconst { entitiesSavedStatesCallback } = this.state;\n\t\tthis.setState( { entitiesSavedStatesCallback: false }, () => {\n\t\t\tif (\n\t\t\t\tsavedEntities &&\n\t\t\t\tsavedEntities.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === 'postType' &&\n\t\t\t\t\t\telt.name === postType &&\n\t\t\t\t\t\telt.key === postId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// The post entity was checked, call the held callback from `createOnClick`.\n\t\t\t\tentitiesSavedStatesCallback();\n\t\t\t}\n\t\t} );\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tforceIsDirty,\n\t\t\thasPublishAction,\n\t\t\tisBeingScheduled,\n\t\t\tisOpen,\n\t\t\tisPostSavingLocked,\n\t\t\tisPublishable,\n\t\t\tisPublished,\n\t\t\tisSaveable,\n\t\t\tisSaving,\n\t\t\tisAutoSaving,\n\t\t\tisToggle,\n\t\t\tonSave,\n\t\t\tonStatusChange,\n\t\t\tonSubmit = noop,\n\t\t\tonToggle,\n\t\t\tvisibility,\n\t\t\thasNonPostEntityChanges,\n\t\t\tisSavingNonPostEntityChanges,\n\t\t} = this.props;\n\n\t\tconst isButtonDisabled =\n\t\t\t( isSaving ||\n\t\t\t\t! isSaveable ||\n\t\t\t\tisPostSavingLocked ||\n\t\t\t\t( ! isPublishable && ! forceIsDirty ) ) &&\n\t\t\t( ! hasNonPostEntityChanges || isSavingNonPostEntityChanges );\n\n\t\tconst isToggleDisabled =\n\t\t\t( isPublished ||\n\t\t\t\tisSaving ||\n\t\t\t\t! isSaveable ||\n\t\t\t\t( ! isPublishable && ! forceIsDirty ) ) &&\n\t\t\t( ! hasNonPostEntityChanges || isSavingNonPostEntityChanges );\n\n\t\tlet publishStatus;\n\t\tif ( ! hasPublishAction ) {\n\t\t\tpublishStatus = 'pending';\n\t\t} else if ( visibility === 'private' ) {\n\t\t\tpublishStatus = 'private';\n\t\t} else if ( isBeingScheduled ) {\n\t\t\tpublishStatus = 'future';\n\t\t} else {\n\t\t\tpublishStatus = 'publish';\n\t\t}\n\n\t\tconst onClickButton = () => {\n\t\t\tif ( isButtonDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonSubmit();\n\t\t\tonStatusChange( publishStatus );\n\t\t\tonSave();\n\t\t};\n\n\t\tconst onClickToggle = () => {\n\t\t\tif ( isToggleDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonToggle();\n\t\t};\n\n\t\tconst buttonProps = {\n\t\t\t'aria-disabled': isButtonDisabled,\n\t\t\tclassName: 'editor-post-publish-button',\n\t\t\tisBusy: ! isAutoSaving && isSaving,\n\t\t\tvariant: 'primary',\n\t\t\tonClick: this.createOnClick( onClickButton ),\n\t\t};\n\n\t\tconst toggleProps = {\n\t\t\t'aria-disabled': isToggleDisabled,\n\t\t\t'aria-expanded': isOpen,\n\t\t\tclassName: 'editor-post-publish-panel__toggle',\n\t\t\tisBusy: isSaving && isPublished,\n\t\t\tvariant: 'primary',\n\t\t\tonClick: this.createOnClick( onClickToggle ),\n\t\t};\n\n\t\tconst toggleChildren = isBeingScheduled\n\t\t\t? __( 'Schedule…' )\n\t\t\t: __( 'Publish' );\n\t\tconst buttonChildren = (\n\t\t\t<PublishButtonLabel\n\t\t\t\thasNonPostEntityChanges={ hasNonPostEntityChanges }\n\t\t\t/>\n\t\t);\n\n\t\tconst componentProps = isToggle ? toggleProps : buttonProps;\n\t\tconst componentChildren = isToggle ? toggleChildren : buttonChildren;\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<Button\n\t\t\t\t\tref={ this.buttonNode }\n\t\t\t\t\t{ ...componentProps }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\tcomponentProps.className,\n\t\t\t\t\t\t'editor-post-publish-button__button',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'has-changes-dot': hasNonPostEntityChanges,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ componentChildren }\n\t\t\t\t</Button>\n\t\t\t</>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tisSavingPost,\n\t\t\tisAutosavingPost,\n\t\t\tisEditedPostBeingScheduled,\n\t\t\tgetEditedPostVisibility,\n\t\t\tisCurrentPostPublished,\n\t\t\tisEditedPostSaveable,\n\t\t\tisEditedPostPublishable,\n\t\t\tisPostSavingLocked,\n\t\t\tgetCurrentPost,\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentPostId,\n\t\t\thasNonPostEntityChanges,\n\t\t\tisSavingNonPostEntityChanges,\n\t\t} = select( editorStore );\n\t\treturn {\n\t\t\tisSaving: isSavingPost(),\n\t\t\tisAutoSaving: isAutosavingPost(),\n\t\t\tisBeingScheduled: isEditedPostBeingScheduled(),\n\t\t\tvisibility: getEditedPostVisibility(),\n\t\t\tisSaveable: isEditedPostSaveable(),\n\t\t\tisPostSavingLocked: isPostSavingLocked(),\n\t\t\tisPublishable: isEditedPostPublishable(),\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\thasPublishAction:\n\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t\thasNonPostEntityChanges: hasNonPostEntityChanges(),\n\t\t\tisSavingNonPostEntityChanges: isSavingNonPostEntityChanges(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { editPost, savePost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonStatusChange: ( status ) =>\n\t\t\t\teditPost( { status }, { undoIgnore: true } ),\n\t\t\tonSave: savePost,\n\t\t};\n\t} ),\n] )( PostPublishButton );\n"]}
|
|
@@ -52,9 +52,7 @@ function PublishButtonLabel({
|
|
|
52
52
|
return (0, _i18n.__)('Publish');
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
var _default = (0, _compose.compose)([(0, _data.withSelect)(
|
|
56
|
-
forceIsSaving
|
|
57
|
-
}) => {
|
|
55
|
+
var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
58
56
|
var _getCurrentPost$_link;
|
|
59
57
|
|
|
60
58
|
const {
|
|
@@ -69,7 +67,7 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)((select, {
|
|
|
69
67
|
return {
|
|
70
68
|
isPublished: isCurrentPostPublished(),
|
|
71
69
|
isBeingScheduled: isEditedPostBeingScheduled(),
|
|
72
|
-
isSaving:
|
|
70
|
+
isSaving: isSavingPost(),
|
|
73
71
|
isPublishing: isPublishingPost(),
|
|
74
72
|
hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
|
|
75
73
|
postType: getCurrentPostType(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-button/label.js"],"names":["PublishButtonLabel","isPublished","isBeingScheduled","isSaving","isPublishing","hasPublishAction","isAutosaving","hasNonPostEntityChanges","select","
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-button/label.js"],"names":["PublishButtonLabel","isPublished","isBeingScheduled","isSaving","isPublishing","hasPublishAction","isAutosaving","hasNonPostEntityChanges","select","isCurrentPostPublished","isEditedPostBeingScheduled","isSavingPost","isPublishingPost","getCurrentPost","getCurrentPostType","isAutosavingPost","editorStore","_links","postType"],"mappings":";;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGO,SAASA,kBAAT,CAA6B;AACnCC,EAAAA,WADmC;AAEnCC,EAAAA,gBAFmC;AAGnCC,EAAAA,QAHmC;AAInCC,EAAAA,YAJmC;AAKnCC,EAAAA,gBALmC;AAMnCC,EAAAA,YANmC;AAOnCC,EAAAA;AAPmC,CAA7B,EAQH;AACH,MAA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ES,gBAAgB;AARxB,GAAP;AAUA,CApBD,CADuB,CAAT,EAsBVf,kBAtBU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { compose } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function PublishButtonLabel( {\n\tisPublished,\n\tisBeingScheduled,\n\tisSaving,\n\tisPublishing,\n\thasPublishAction,\n\tisAutosaving,\n\thasNonPostEntityChanges,\n} ) {\n\tif ( isPublishing ) {\n\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\treturn __( 'Publishing…' );\n\t} else if ( isPublished && isSaving && ! isAutosaving ) {\n\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\treturn __( 'Updating…' );\n\t} else if ( isBeingScheduled && isSaving && ! isAutosaving ) {\n\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\treturn __( 'Scheduling…' );\n\t}\n\n\tif ( ! hasPublishAction ) {\n\t\treturn hasNonPostEntityChanges\n\t\t\t? __( 'Submit for Review…' )\n\t\t\t: __( 'Submit for Review' );\n\t} else if ( isPublished ) {\n\t\treturn hasNonPostEntityChanges ? __( 'Update…' ) : __( 'Update' );\n\t} else if ( isBeingScheduled ) {\n\t\treturn hasNonPostEntityChanges ? __( 'Schedule…' ) : __( 'Schedule' );\n\t}\n\n\treturn __( 'Publish' );\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tisCurrentPostPublished,\n\t\t\tisEditedPostBeingScheduled,\n\t\t\tisSavingPost,\n\t\t\tisPublishingPost,\n\t\t\tgetCurrentPost,\n\t\t\tgetCurrentPostType,\n\t\t\tisAutosavingPost,\n\t\t} = select( editorStore );\n\t\treturn {\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\tisBeingScheduled: isEditedPostBeingScheduled(),\n\t\t\tisSaving: isSavingPost(),\n\t\t\tisPublishing: isPublishingPost(),\n\t\t\thasPublishAction:\n\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tisAutosaving: isAutosavingPost(),\n\t\t};\n\t} ),\n] )( PublishButtonLabel );\n"]}
|
|
@@ -65,7 +65,6 @@ class PostPublishPanel extends _element.Component {
|
|
|
65
65
|
render() {
|
|
66
66
|
const {
|
|
67
67
|
forceIsDirty,
|
|
68
|
-
forceIsSaving,
|
|
69
68
|
isBeingScheduled,
|
|
70
69
|
isPublished,
|
|
71
70
|
isPublishSidebarEnabled,
|
|
@@ -101,8 +100,7 @@ class PostPublishPanel extends _element.Component {
|
|
|
101
100
|
}, (0, _element.createElement)(_postPublishButton.default, {
|
|
102
101
|
focusOnMount: true,
|
|
103
102
|
onSubmit: this.onSubmit,
|
|
104
|
-
forceIsDirty: forceIsDirty
|
|
105
|
-
forceIsSaving: forceIsSaving
|
|
103
|
+
forceIsDirty: forceIsDirty
|
|
106
104
|
})), (0, _element.createElement)("div", {
|
|
107
105
|
className: "editor-post-publish-panel__header-cancel-button"
|
|
108
106
|
}, (0, _element.createElement)(_components.Button, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/index.js"],"names":["PostPublishPanel","Component","constructor","arguments","onSubmit","bind","componentDidUpdate","prevProps","isPublished","props","isSaving","isDirty","onClose","hasPublishAction","isPostTypeViewable","render","forceIsDirty","
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/index.js"],"names":["PostPublishPanel","Component","constructor","arguments","onSubmit","bind","componentDidUpdate","prevProps","isPublished","props","isSaving","isDirty","onClose","hasPublishAction","isPostTypeViewable","render","forceIsDirty","isBeingScheduled","isPublishSidebarEnabled","isScheduled","isSavingNonPostEntityChanges","onTogglePublishSidebar","PostPublishExtension","PrePublishExtension","additionalProps","propsForPanel","isPublishedOrScheduled","isPrePublish","isPostPublish","closeSmall","select","getPostType","coreStore","getCurrentPost","getEditedPostAttribute","isCurrentPostPublished","isCurrentPostScheduled","isEditedPostBeingScheduled","isEditedPostDirty","isAutosavingPost","isSavingPost","editorStore","postType","_links","viewable","dispatch","disablePublishSidebar","enablePublishSidebar","withFocusReturn","withConstrainedTabbing"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AAOA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAeA;AACA;AACA;AAMO,MAAMA,gBAAN,SAA+BC,kBAA/B,CAAyC;AAC/CC,EAAAA,WAAW,GAAG;AACb,UAAO,GAAGC,SAAV;AACA,SAAKC,QAAL,GAAgB,KAAKA,QAAL,CAAcC,IAAd,CAAoB,IAApB,CAAhB;AACA;;AAEDC,EAAAA,kBAAkB,CAAEC,SAAF,EAAc;AAC/B;AACA;AACA,QACCA,SAAS,CAACC,WAAV,IACA,CAAE,KAAKC,KAAL,CAAWC,QADb,IAEA,KAAKD,KAAL,CAAWE,OAHZ,EAIE;AACD,WAAKF,KAAL,CAAWG,OAAX;AACA;AACD;;AAEDR,EAAAA,QAAQ,GAAG;AACV,UAAM;AAAEQ,MAAAA,OAAF;AAAWC,MAAAA,gBAAX;AAA6BC,MAAAA;AAA7B,QAAoD,KAAKL,KAA/D;;AACA,QAAK,CAAEI,gBAAF,IAAsB,CAAEC,kBAA7B,EAAkD;AACjDF,MAAAA,OAAO;AACP;AACD;;AAEDG,EAAAA,MAAM,GAAG;AACR,UAAM;AACLC,MAAAA,YADK;AAELC,MAAAA,gBAFK;AAGLT,MAAAA,WAHK;AAILU,MAAAA,uBAJK;AAKLC,MAAAA,WALK;AAMLT,MAAAA,QANK;AAOLU,MAAAA,4BAPK;AAQLR,MAAAA,OARK;AASLS,MAAAA,sBATK;AAULC,MAAAA,oBAVK;AAWLC,MAAAA,mBAXK;AAYL,SAAGC;AAZE,QAaF,KAAKf,KAbT;AAcA,UAAM;AACLI,MAAAA,gBADK;AAELF,MAAAA,OAFK;A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AAAzB,MACLF,QAAQ,CAAEJ,YAAF,CADT;AAEA,SAAO;AACNpB,IAAAA,sBAAsB,EAAE,MAAM;AAC7B,UAAKH,uBAAL,EAA+B;AAC9B4B,QAAAA,qBAAqB;AACrB,OAFD,MAEO;AACNC,QAAAA,oBAAoB;AACpB;AACD;AAPK,GAAP;AASA,CAZD,CA9BuB,EA2CvBC,2BA3CuB,EA4CvBC,kCA5CuB,CAAT,EA6CVjD,gBA7CU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Component } from '@wordpress/element';\nimport {\n\tButton,\n\tSpinner,\n\tCheckboxControl,\n\twithFocusReturn,\n\twithConstrainedTabbing,\n} from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { closeSmall } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostPublishButton from '../post-publish-button';\nimport PostPublishPanelPrepublish from './prepublish';\nimport PostPublishPanelPostpublish from './postpublish';\nimport { store as editorStore } from '../../store';\n\nexport class PostPublishPanel extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.onSubmit = this.onSubmit.bind( this );\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\t// Automatically collapse the publish sidebar when a post\n\t\t// is published and the user makes an edit.\n\t\tif (\n\t\t\tprevProps.isPublished &&\n\t\t\t! this.props.isSaving &&\n\t\t\tthis.props.isDirty\n\t\t) {\n\t\t\tthis.props.onClose();\n\t\t}\n\t}\n\n\tonSubmit() {\n\t\tconst { onClose, hasPublishAction, isPostTypeViewable } = this.props;\n\t\tif ( ! hasPublishAction || ! isPostTypeViewable ) {\n\t\t\tonClose();\n\t\t}\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tforceIsDirty,\n\t\t\tisBeingScheduled,\n\t\t\tisPublished,\n\t\t\tisPublishSidebarEnabled,\n\t\t\tisScheduled,\n\t\t\tisSaving,\n\t\t\tisSavingNonPostEntityChanges,\n\t\t\tonClose,\n\t\t\tonTogglePublishSidebar,\n\t\t\tPostPublishExtension,\n\t\t\tPrePublishExtension,\n\t\t\t...additionalProps\n\t\t} = this.props;\n\t\tconst {\n\t\t\thasPublishAction,\n\t\t\tisDirty,\n\t\t\tisPostTypeViewable,\n\t\t\t...propsForPanel\n\t\t} = additionalProps;\n\t\tconst isPublishedOrScheduled =\n\t\t\tisPublished || ( isScheduled && isBeingScheduled );\n\t\tconst isPrePublish = ! isPublishedOrScheduled && ! isSaving;\n\t\tconst isPostPublish = isPublishedOrScheduled && ! isSaving;\n\t\treturn (\n\t\t\t<div className=\"editor-post-publish-panel\" { ...propsForPanel }>\n\t\t\t\t<div className=\"editor-post-publish-panel__header\">\n\t\t\t\t\t{ isPostPublish ? (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\tlabel={ __( 'Close panel' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<div className=\"editor-post-publish-panel__header-publish-button\">\n\t\t\t\t\t\t\t\t<PostPublishButton\n\t\t\t\t\t\t\t\t\tfocusOnMount\n\t\t\t\t\t\t\t\t\tonSubmit={ this.onSubmit }\n\t\t\t\t\t\t\t\t\tforceIsDirty={ forceIsDirty }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"editor-post-publish-panel__header-cancel-button\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tdisabled={ isSavingNonPostEntityChanges }\n\t\t\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<div className=\"editor-post-publish-panel__content\">\n\t\t\t\t\t{ isPrePublish && (\n\t\t\t\t\t\t<PostPublishPanelPrepublish>\n\t\t\t\t\t\t\t{ PrePublishExtension && <PrePublishExtension /> }\n\t\t\t\t\t\t</PostPublishPanelPrepublish>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isPostPublish && (\n\t\t\t\t\t\t<PostPublishPanelPostpublish focusOnMount={ true }>\n\t\t\t\t\t\t\t{ PostPublishExtension && <PostPublishExtension /> }\n\t\t\t\t\t\t</PostPublishPanelPostpublish>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isSaving && <Spinner /> }\n\t\t\t\t</div>\n\t\t\t\t<div className=\"editor-post-publish-panel__footer\">\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Always show pre-publish checks.' ) }\n\t\t\t\t\t\tchecked={ isPublishSidebarEnabled }\n\t\t\t\t\t\tonChange={ onTogglePublishSidebar }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst {\n\t\t\tgetCurrentPost,\n\t\t\tgetEditedPostAttribute,\n\t\t\tisCurrentPostPublished,\n\t\t\tisCurrentPostScheduled,\n\t\t\tisEditedPostBeingScheduled,\n\t\t\tisEditedPostDirty,\n\t\t\tisAutosavingPost,\n\t\t\tisSavingPost,\n\t\t\tisSavingNonPostEntityChanges,\n\t\t} = select( editorStore );\n\t\tconst { isPublishSidebarEnabled } = select( editorStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn {\n\t\t\thasPublishAction:\n\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\tisPostTypeViewable: postType?.viewable,\n\t\t\tisBeingScheduled: isEditedPostBeingScheduled(),\n\t\t\tisDirty: isEditedPostDirty(),\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\tisPublishSidebarEnabled: isPublishSidebarEnabled(),\n\t\t\tisSaving: isSavingPost() && ! isAutosavingPost(),\n\t\t\tisSavingNonPostEntityChanges: isSavingNonPostEntityChanges(),\n\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, { isPublishSidebarEnabled } ) => {\n\t\tconst { disablePublishSidebar, enablePublishSidebar } =\n\t\t\tdispatch( editorStore );\n\t\treturn {\n\t\t\tonTogglePublishSidebar: () => {\n\t\t\t\tif ( isPublishSidebarEnabled ) {\n\t\t\t\t\tdisablePublishSidebar();\n\t\t\t\t} else {\n\t\t\t\t\tenablePublishSidebar();\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t} ),\n\twithFocusReturn,\n\twithConstrainedTabbing,\n] )( PostPublishPanel );\n"]}
|
|
@@ -44,14 +44,11 @@ var _store = require("../../store");
|
|
|
44
44
|
* @param {Object} props Component props.
|
|
45
45
|
* @param {?boolean} props.forceIsDirty Whether to force the post to be marked
|
|
46
46
|
* as dirty.
|
|
47
|
-
* @param {?boolean} props.forceIsSaving Whether to force the post to be marked
|
|
48
|
-
* as being saved.
|
|
49
47
|
* @param {?boolean} props.showIconLabels Whether interface buttons show labels instead of icons
|
|
50
48
|
* @return {import('@wordpress/element').WPComponent} The component.
|
|
51
49
|
*/
|
|
52
50
|
function PostSavedState({
|
|
53
51
|
forceIsDirty,
|
|
54
|
-
forceIsSaving,
|
|
55
52
|
showIconLabels = false
|
|
56
53
|
}) {
|
|
57
54
|
const [forceSavedMessage, setForceSavedMessage] = (0, _element.useState)(false);
|
|
@@ -86,12 +83,12 @@ function PostSavedState({
|
|
|
86
83
|
isNew: isEditedPostNew(),
|
|
87
84
|
isPending: 'pending' === getEditedPostAttribute('status'),
|
|
88
85
|
isPublished: isCurrentPostPublished(),
|
|
89
|
-
isSaving:
|
|
86
|
+
isSaving: isSavingPost(),
|
|
90
87
|
isSaveable: isEditedPostSaveable(),
|
|
91
88
|
isScheduled: isCurrentPostScheduled(),
|
|
92
89
|
hasPublishAction: (_getCurrentPost$_link = getCurrentPost()?._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false
|
|
93
90
|
};
|
|
94
|
-
}, [forceIsDirty
|
|
91
|
+
}, [forceIsDirty]);
|
|
95
92
|
const {
|
|
96
93
|
savePost
|
|
97
94
|
} = (0, _data.useDispatch)(_store.store);
|