@wordpress/editor 13.12.0 → 13.12.2
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/build/components/deprecated.js +4 -5
- package/build/components/deprecated.js.map +1 -1
- package/build/components/editor-help/help-detail-navigation-screen.native.js +2 -4
- package/build/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
- package/build/components/editor-help/index.native.js +2 -4
- package/build/components/editor-help/index.native.js.map +1 -1
- package/build/components/editor-history/redo.js +2 -6
- package/build/components/editor-history/redo.js.map +1 -1
- package/build/components/editor-history/undo.js +2 -6
- package/build/components/editor-history/undo.js.map +1 -1
- package/build/components/entities-saved-states/hooks/use-is-dirty.js +3 -1
- package/build/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
- package/build/components/entities-saved-states/index.js +8 -9
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/page-attributes/order.js +2 -1
- package/build/components/page-attributes/order.js.map +1 -1
- package/build/components/post-excerpt/check.js +2 -4
- package/build/components/post-excerpt/check.js.map +1 -1
- package/build/components/post-featured-image/check.js +2 -4
- package/build/components/post-featured-image/check.js.map +1 -1
- package/build/components/post-format/check.js +2 -4
- package/build/components/post-format/check.js.map +1 -1
- package/build/components/post-publish-button/index.js +4 -6
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-panel/index.js +4 -5
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.js +150 -0
- package/build/components/post-publish-panel/maybe-upload-media.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-sync-status/index.js +67 -0
- package/build/components/post-sync-status/index.js.map +1 -0
- package/build/components/post-taxonomies/flat-term-selector.js +25 -34
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-title/index.js +8 -1
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/post-visibility/index.js +4 -7
- package/build/components/post-visibility/index.js.map +1 -1
- package/build/components/provider/index.js +3 -5
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/index.native.js +5 -10
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +1 -1
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/provider/with-registry-provider.js +4 -2
- package/build/components/provider/with-registry-provider.js.map +1 -1
- package/build/components/table-of-contents/index.js +2 -4
- package/build/components/table-of-contents/index.js.map +1 -1
- package/build/hooks/custom-sources-backwards-compatibility.js +4 -7
- package/build/hooks/custom-sources-backwards-compatibility.js.map +1 -1
- package/build/{lockUnlock.js → lock-unlock.js} +1 -1
- package/build/lock-unlock.js.map +1 -0
- package/build/private-apis.js +1 -1
- package/build/private-apis.js.map +1 -1
- package/build-module/components/deprecated.js +4 -4
- package/build-module/components/deprecated.js.map +1 -1
- package/build-module/components/editor-help/help-detail-navigation-screen.native.js +2 -3
- package/build-module/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
- package/build-module/components/editor-help/index.native.js +2 -3
- package/build-module/components/editor-help/index.native.js.map +1 -1
- package/build-module/components/editor-history/redo.js +2 -3
- package/build-module/components/editor-history/redo.js.map +1 -1
- package/build-module/components/editor-history/undo.js +2 -3
- package/build-module/components/editor-history/undo.js.map +1 -1
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.js +3 -1
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +8 -8
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/page-attributes/order.js +2 -1
- package/build-module/components/page-attributes/order.js.map +1 -1
- package/build-module/components/post-excerpt/check.js +2 -3
- package/build-module/components/post-excerpt/check.js.map +1 -1
- package/build-module/components/post-featured-image/check.js +2 -3
- package/build-module/components/post-featured-image/check.js.map +1 -1
- package/build-module/components/post-format/check.js +2 -3
- package/build-module/components/post-format/check.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +4 -5
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js +4 -4
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.js +138 -0
- package/build-module/components/post-publish-panel/maybe-upload-media.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-sync-status/index.js +56 -0
- package/build-module/components/post-sync-status/index.js.map +1 -0
- package/build-module/components/post-taxonomies/flat-term-selector.js +25 -32
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-title/index.js +8 -1
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/post-visibility/index.js +4 -4
- package/build-module/components/post-visibility/index.js.map +1 -1
- package/build-module/components/provider/index.js +3 -4
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +5 -9
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +1 -1
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/provider/with-registry-provider.js +4 -2
- package/build-module/components/provider/with-registry-provider.js.map +1 -1
- package/build-module/components/table-of-contents/index.js +2 -3
- package/build-module/components/table-of-contents/index.js.map +1 -1
- package/build-module/hooks/custom-sources-backwards-compatibility.js +4 -4
- package/build-module/hooks/custom-sources-backwards-compatibility.js.map +1 -1
- package/build-module/{lockUnlock.js → lock-unlock.js} +1 -1
- package/build-module/lock-unlock.js.map +1 -0
- package/build-module/private-apis.js +1 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-style/style-rtl.css +15 -1
- package/build-style/style.css +15 -1
- package/package.json +30 -31
- package/src/components/editor-help/test/index.native.js +3 -2
- package/src/components/entities-saved-states/hooks/use-is-dirty.js +2 -0
- package/src/components/index.js +1 -0
- package/src/components/post-publish-panel/maybe-upload-media.js +167 -0
- package/src/components/post-publish-panel/prepublish.js +2 -0
- package/src/components/post-publish-panel/style.scss +1 -1
- package/src/components/post-sync-status/index.js +55 -0
- package/src/components/post-sync-status/style.scss +16 -0
- package/src/components/post-taxonomies/flat-term-selector.js +20 -30
- package/src/components/post-title/index.js +3 -1
- package/src/components/provider/index.js +1 -1
- package/src/components/provider/index.native.js +2 -9
- package/src/components/provider/use-block-editor-settings.js +1 -0
- package/src/private-apis.js +1 -1
- package/src/style.scss +1 -0
- package/build/lockUnlock.js.map +0 -1
- package/build-module/lockUnlock.js.map +0 -1
- /package/src/{lockUnlock.js → lock-unlock.js} +0 -0
|
@@ -418,7 +418,7 @@
|
|
|
418
418
|
.editor-post-publish-panel__content {
|
|
419
419
|
min-height: calc(100% - 144px);
|
|
420
420
|
}
|
|
421
|
-
.editor-post-publish-panel__content .components-spinner {
|
|
421
|
+
.editor-post-publish-panel__content > .components-spinner {
|
|
422
422
|
display: block;
|
|
423
423
|
margin: 100px auto 0;
|
|
424
424
|
}
|
|
@@ -627,6 +627,20 @@
|
|
|
627
627
|
margin-left: 0;
|
|
628
628
|
}
|
|
629
629
|
|
|
630
|
+
.edit-post-sync-status {
|
|
631
|
+
width: 100%;
|
|
632
|
+
position: relative;
|
|
633
|
+
justify-content: flex-start;
|
|
634
|
+
}
|
|
635
|
+
.edit-post-sync-status > span {
|
|
636
|
+
display: block;
|
|
637
|
+
width: 45%;
|
|
638
|
+
flex-shrink: 0;
|
|
639
|
+
}
|
|
640
|
+
.edit-post-sync-status .components-base-control {
|
|
641
|
+
padding-right: 6px;
|
|
642
|
+
}
|
|
643
|
+
|
|
630
644
|
.editor-post-taxonomies__hierarchical-terms-list {
|
|
631
645
|
max-height: 14em;
|
|
632
646
|
overflow: auto;
|
package/build-style/style.css
CHANGED
|
@@ -418,7 +418,7 @@
|
|
|
418
418
|
.editor-post-publish-panel__content {
|
|
419
419
|
min-height: calc(100% - 144px);
|
|
420
420
|
}
|
|
421
|
-
.editor-post-publish-panel__content .components-spinner {
|
|
421
|
+
.editor-post-publish-panel__content > .components-spinner {
|
|
422
422
|
display: block;
|
|
423
423
|
margin: 100px auto 0;
|
|
424
424
|
}
|
|
@@ -627,6 +627,20 @@
|
|
|
627
627
|
margin-right: 0;
|
|
628
628
|
}
|
|
629
629
|
|
|
630
|
+
.edit-post-sync-status {
|
|
631
|
+
width: 100%;
|
|
632
|
+
position: relative;
|
|
633
|
+
justify-content: flex-start;
|
|
634
|
+
}
|
|
635
|
+
.edit-post-sync-status > span {
|
|
636
|
+
display: block;
|
|
637
|
+
width: 45%;
|
|
638
|
+
flex-shrink: 0;
|
|
639
|
+
}
|
|
640
|
+
.edit-post-sync-status .components-base-control {
|
|
641
|
+
padding-left: 6px;
|
|
642
|
+
}
|
|
643
|
+
|
|
630
644
|
.editor-post-taxonomies__hierarchical-terms-list {
|
|
631
645
|
max-height: 14em;
|
|
632
646
|
overflow: auto;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "13.12.
|
|
3
|
+
"version": "13.12.2",
|
|
4
4
|
"description": "Enhanced block editor for WordPress posts.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -31,37 +31,36 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.16.0",
|
|
34
|
-
"@wordpress/a11y": "^3.35.
|
|
35
|
-
"@wordpress/api-fetch": "^6.32.
|
|
36
|
-
"@wordpress/blob": "^3.35.
|
|
37
|
-
"@wordpress/block-editor": "^12.3.
|
|
38
|
-
"@wordpress/blocks": "^12.12.
|
|
39
|
-
"@wordpress/components": "^25.1.
|
|
40
|
-
"@wordpress/compose": "^6.12.
|
|
41
|
-
"@wordpress/core-data": "^6.12.
|
|
42
|
-
"@wordpress/data": "^9.5.
|
|
43
|
-
"@wordpress/date": "^4.35.
|
|
44
|
-
"@wordpress/deprecated": "^3.35.
|
|
45
|
-
"@wordpress/dom": "^3.35.
|
|
46
|
-
"@wordpress/element": "^5.12.
|
|
47
|
-
"@wordpress/hooks": "^3.35.
|
|
48
|
-
"@wordpress/html-entities": "^3.35.
|
|
49
|
-
"@wordpress/i18n": "^4.35.
|
|
50
|
-
"@wordpress/icons": "^9.26.
|
|
51
|
-
"@wordpress/keyboard-shortcuts": "^4.12.
|
|
52
|
-
"@wordpress/keycodes": "^3.35.
|
|
53
|
-
"@wordpress/media-utils": "^4.26.
|
|
54
|
-
"@wordpress/notices": "^4.3.
|
|
55
|
-
"@wordpress/preferences": "^3.12.
|
|
56
|
-
"@wordpress/private-apis": "^0.17.
|
|
57
|
-
"@wordpress/reusable-blocks": "^4.12.
|
|
58
|
-
"@wordpress/rich-text": "^6.12.
|
|
59
|
-
"@wordpress/server-side-render": "^4.12.
|
|
60
|
-
"@wordpress/url": "^3.36.
|
|
61
|
-
"@wordpress/wordcount": "^3.35.
|
|
34
|
+
"@wordpress/a11y": "^3.35.1",
|
|
35
|
+
"@wordpress/api-fetch": "^6.32.1",
|
|
36
|
+
"@wordpress/blob": "^3.35.1",
|
|
37
|
+
"@wordpress/block-editor": "^12.3.2",
|
|
38
|
+
"@wordpress/blocks": "^12.12.1",
|
|
39
|
+
"@wordpress/components": "^25.1.2",
|
|
40
|
+
"@wordpress/compose": "^6.12.1",
|
|
41
|
+
"@wordpress/core-data": "^6.12.2",
|
|
42
|
+
"@wordpress/data": "^9.5.1",
|
|
43
|
+
"@wordpress/date": "^4.35.1",
|
|
44
|
+
"@wordpress/deprecated": "^3.35.1",
|
|
45
|
+
"@wordpress/dom": "^3.35.1",
|
|
46
|
+
"@wordpress/element": "^5.12.1",
|
|
47
|
+
"@wordpress/hooks": "^3.35.1",
|
|
48
|
+
"@wordpress/html-entities": "^3.35.1",
|
|
49
|
+
"@wordpress/i18n": "^4.35.1",
|
|
50
|
+
"@wordpress/icons": "^9.26.2",
|
|
51
|
+
"@wordpress/keyboard-shortcuts": "^4.12.1",
|
|
52
|
+
"@wordpress/keycodes": "^3.35.1",
|
|
53
|
+
"@wordpress/media-utils": "^4.26.1",
|
|
54
|
+
"@wordpress/notices": "^4.3.1",
|
|
55
|
+
"@wordpress/preferences": "^3.12.2",
|
|
56
|
+
"@wordpress/private-apis": "^0.17.1",
|
|
57
|
+
"@wordpress/reusable-blocks": "^4.12.2",
|
|
58
|
+
"@wordpress/rich-text": "^6.12.1",
|
|
59
|
+
"@wordpress/server-side-render": "^4.12.2",
|
|
60
|
+
"@wordpress/url": "^3.36.1",
|
|
61
|
+
"@wordpress/wordcount": "^3.35.1",
|
|
62
62
|
"classnames": "^2.3.1",
|
|
63
63
|
"date-fns": "^2.28.0",
|
|
64
|
-
"escape-html": "^1.0.3",
|
|
65
64
|
"memize": "^2.1.0",
|
|
66
65
|
"react-autosize-textarea": "^7.1.0",
|
|
67
66
|
"rememo": "^4.0.2",
|
|
@@ -74,5 +73,5 @@
|
|
|
74
73
|
"publishConfig": {
|
|
75
74
|
"access": "public"
|
|
76
75
|
},
|
|
77
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "a00463f06c90ae6705951861eb889e67a52bf448"
|
|
78
77
|
}
|
|
@@ -35,10 +35,11 @@ it( 'navigates back from help topic detail screen', async () => {
|
|
|
35
35
|
const backButton = screen.getAllByLabelText( 'Go back' );
|
|
36
36
|
fireEvent.press( backButton[ backButton.length - 1 ] );
|
|
37
37
|
|
|
38
|
-
// Currently logs `act` warning due to https://github.com/callstack/react-native-testing-library/issues/379
|
|
39
38
|
const text =
|
|
40
39
|
'Each block has its own settings. To find them, tap on a block. Its settings will appear on the toolbar at the bottom of the screen.';
|
|
41
|
-
await waitForElementToBeRemoved( () =>
|
|
40
|
+
await waitForElementToBeRemoved( () =>
|
|
41
|
+
screen.getByText( text, { hidden: true } )
|
|
42
|
+
);
|
|
42
43
|
|
|
43
44
|
expect( screen.queryByText( text ) ).toBeNull();
|
|
44
45
|
} );
|
|
@@ -13,6 +13,8 @@ const TRANSLATED_SITE_PROPERTIES = {
|
|
|
13
13
|
site_icon: __( 'Icon' ),
|
|
14
14
|
show_on_front: __( 'Show on front' ),
|
|
15
15
|
page_on_front: __( 'Page on front' ),
|
|
16
|
+
posts_per_page: __( 'Maximum posts per page' ),
|
|
17
|
+
default_comment_status: __( 'Allow comments on new posts' ),
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
export const useIsDirty = () => {
|
package/src/components/index.js
CHANGED
|
@@ -51,6 +51,7 @@ export { default as PostSlugCheck } from './post-slug/check';
|
|
|
51
51
|
export { default as PostSticky } from './post-sticky';
|
|
52
52
|
export { default as PostStickyCheck } from './post-sticky/check';
|
|
53
53
|
export { default as PostSwitchToDraftButton } from './post-switch-to-draft-button';
|
|
54
|
+
export { default as PostSyncStatus } from './post-sync-status';
|
|
54
55
|
export { default as PostTaxonomies } from './post-taxonomies';
|
|
55
56
|
export { FlatTermSelector as PostTaxonomiesFlatTermSelector } from './post-taxonomies/flat-term-selector';
|
|
56
57
|
export { HierarchicalTermSelector as PostTaxonomiesHierarchicalTermSelector } from './post-taxonomies/hierarchical-term-selector';
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
PanelBody,
|
|
6
|
+
Button,
|
|
7
|
+
Spinner,
|
|
8
|
+
__unstableMotion as motion,
|
|
9
|
+
__unstableAnimatePresence as AnimatePresence,
|
|
10
|
+
} from '@wordpress/components';
|
|
11
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
12
|
+
import { __ } from '@wordpress/i18n';
|
|
13
|
+
import { upload } from '@wordpress/icons';
|
|
14
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
15
|
+
import { useState } from '@wordpress/element';
|
|
16
|
+
import { isBlobURL } from '@wordpress/blob';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
import { store as editorStore } from '../../store';
|
|
22
|
+
|
|
23
|
+
function flattenBlocks( blocks ) {
|
|
24
|
+
const result = [];
|
|
25
|
+
|
|
26
|
+
blocks.forEach( ( block ) => {
|
|
27
|
+
result.push( block );
|
|
28
|
+
result.push( ...flattenBlocks( block.innerBlocks ) );
|
|
29
|
+
} );
|
|
30
|
+
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function Image( block ) {
|
|
35
|
+
const { selectBlock } = useDispatch( blockEditorStore );
|
|
36
|
+
return (
|
|
37
|
+
<motion.img
|
|
38
|
+
tabIndex={ 0 }
|
|
39
|
+
role="button"
|
|
40
|
+
aria-label={ __( 'Select image block.' ) }
|
|
41
|
+
onClick={ () => {
|
|
42
|
+
selectBlock( block.clientId );
|
|
43
|
+
} }
|
|
44
|
+
onKeyDown={ ( event ) => {
|
|
45
|
+
if ( event.key === 'Enter' || event.key === ' ' ) {
|
|
46
|
+
selectBlock( block.clientId );
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
}
|
|
49
|
+
} }
|
|
50
|
+
key={ block.clientId }
|
|
51
|
+
alt={ block.attributes.alt }
|
|
52
|
+
src={ block.attributes.url }
|
|
53
|
+
animate={ { opacity: 1 } }
|
|
54
|
+
exit={ { opacity: 0, scale: 0 } }
|
|
55
|
+
style={ {
|
|
56
|
+
width: '36px',
|
|
57
|
+
height: '36px',
|
|
58
|
+
objectFit: 'cover',
|
|
59
|
+
borderRadius: '2px',
|
|
60
|
+
cursor: 'pointer',
|
|
61
|
+
} }
|
|
62
|
+
whileHover={ { scale: 1.08 } }
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default function PostFormatPanel() {
|
|
68
|
+
const [ isUploading, setIsUploading ] = useState( false );
|
|
69
|
+
const { editorBlocks, mediaUpload } = useSelect(
|
|
70
|
+
( select ) => ( {
|
|
71
|
+
editorBlocks: select( editorStore ).getEditorBlocks(),
|
|
72
|
+
mediaUpload: select( blockEditorStore ).getSettings().mediaUpload,
|
|
73
|
+
} ),
|
|
74
|
+
[]
|
|
75
|
+
);
|
|
76
|
+
const externalImages = flattenBlocks( editorBlocks ).filter(
|
|
77
|
+
( block ) =>
|
|
78
|
+
block.name === 'core/image' &&
|
|
79
|
+
block.attributes.url &&
|
|
80
|
+
! block.attributes.id
|
|
81
|
+
);
|
|
82
|
+
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
83
|
+
|
|
84
|
+
if ( ! mediaUpload || ! externalImages.length ) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const panelBodyTitle = [
|
|
89
|
+
__( 'Suggestion:' ),
|
|
90
|
+
<span className="editor-post-publish-panel__link" key="label">
|
|
91
|
+
{ __( 'External media' ) }
|
|
92
|
+
</span>,
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
function uploadImages() {
|
|
96
|
+
setIsUploading( true );
|
|
97
|
+
Promise.all(
|
|
98
|
+
externalImages.map( ( image ) =>
|
|
99
|
+
window
|
|
100
|
+
.fetch(
|
|
101
|
+
image.attributes.url.includes( '?' )
|
|
102
|
+
? image.attributes.url
|
|
103
|
+
: image.attributes.url + '?'
|
|
104
|
+
)
|
|
105
|
+
.then( ( response ) => response.blob() )
|
|
106
|
+
.then(
|
|
107
|
+
( blob ) =>
|
|
108
|
+
new Promise( ( resolve, reject ) => {
|
|
109
|
+
mediaUpload( {
|
|
110
|
+
filesList: [ blob ],
|
|
111
|
+
onFileChange: ( [ media ] ) => {
|
|
112
|
+
if ( isBlobURL( media.url ) ) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
updateBlockAttributes( image.clientId, {
|
|
117
|
+
id: media.id,
|
|
118
|
+
url: media.url,
|
|
119
|
+
} );
|
|
120
|
+
resolve();
|
|
121
|
+
},
|
|
122
|
+
onError() {
|
|
123
|
+
reject();
|
|
124
|
+
},
|
|
125
|
+
} );
|
|
126
|
+
} )
|
|
127
|
+
)
|
|
128
|
+
)
|
|
129
|
+
).finally( () => {
|
|
130
|
+
setIsUploading( false );
|
|
131
|
+
} );
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<PanelBody initialOpen={ true } title={ panelBodyTitle }>
|
|
136
|
+
<p>
|
|
137
|
+
{ __(
|
|
138
|
+
'There are some external images in the post which can be uploaded to the media library. Images coming from different domains may not always display correctly, load slowly for visitors, or be removed unexpectedly.'
|
|
139
|
+
) }
|
|
140
|
+
</p>
|
|
141
|
+
<div
|
|
142
|
+
style={ {
|
|
143
|
+
display: 'inline-flex',
|
|
144
|
+
flexWrap: 'wrap',
|
|
145
|
+
gap: '8px',
|
|
146
|
+
} }
|
|
147
|
+
>
|
|
148
|
+
<AnimatePresence>
|
|
149
|
+
{ externalImages.map( ( image ) => {
|
|
150
|
+
return <Image key={ image.clientId } { ...image } />;
|
|
151
|
+
} ) }
|
|
152
|
+
</AnimatePresence>
|
|
153
|
+
{ isUploading ? (
|
|
154
|
+
<Spinner />
|
|
155
|
+
) : (
|
|
156
|
+
<Button
|
|
157
|
+
icon={ upload }
|
|
158
|
+
variant="primary"
|
|
159
|
+
onClick={ uploadImages }
|
|
160
|
+
>
|
|
161
|
+
{ __( 'Upload all' ) }
|
|
162
|
+
</Button>
|
|
163
|
+
) }
|
|
164
|
+
</div>
|
|
165
|
+
</PanelBody>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
@@ -20,6 +20,7 @@ import MaybeTagsPanel from './maybe-tags-panel';
|
|
|
20
20
|
import MaybePostFormatPanel from './maybe-post-format-panel';
|
|
21
21
|
import { store as editorStore } from '../../store';
|
|
22
22
|
import MaybeCategoryPanel from './maybe-category-panel';
|
|
23
|
+
import MaybeUploadMedia from './maybe-upload-media';
|
|
23
24
|
|
|
24
25
|
function PostPublishPanelPrepublish( { children } ) {
|
|
25
26
|
const {
|
|
@@ -103,6 +104,7 @@ function PostPublishPanelPrepublish( { children } ) {
|
|
|
103
104
|
<span className="components-site-home">{ siteHome }</span>
|
|
104
105
|
</div>
|
|
105
106
|
</div>
|
|
107
|
+
<MaybeUploadMedia />
|
|
106
108
|
{ hasPublishAction && (
|
|
107
109
|
<>
|
|
108
110
|
<PanelBody
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { ToggleControl, PanelRow } from '@wordpress/components';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { store as editorStore } from '../../store';
|
|
12
|
+
|
|
13
|
+
export default function PostSyncStatus() {
|
|
14
|
+
const { editPost } = useDispatch( editorStore );
|
|
15
|
+
const { meta, postType } = useSelect( ( select ) => {
|
|
16
|
+
const { getEditedPostAttribute } = select( editorStore );
|
|
17
|
+
return {
|
|
18
|
+
meta: getEditedPostAttribute( 'meta' ),
|
|
19
|
+
postType: getEditedPostAttribute( 'type' ),
|
|
20
|
+
};
|
|
21
|
+
}, [] );
|
|
22
|
+
if ( postType !== 'wp_block' ) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const onUpdateSync = ( syncStatus ) =>
|
|
26
|
+
editPost( {
|
|
27
|
+
meta: {
|
|
28
|
+
...meta,
|
|
29
|
+
wp_block:
|
|
30
|
+
syncStatus === 'unsynced'
|
|
31
|
+
? { sync_status: syncStatus }
|
|
32
|
+
: null,
|
|
33
|
+
},
|
|
34
|
+
} );
|
|
35
|
+
const syncStatus = meta?.wp_block?.sync_status;
|
|
36
|
+
const isFullySynced = ! syncStatus;
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<PanelRow className="edit-post-sync-status">
|
|
40
|
+
<span>{ __( 'Syncing' ) }</span>
|
|
41
|
+
<ToggleControl
|
|
42
|
+
__nextHasNoMarginBottom
|
|
43
|
+
label={
|
|
44
|
+
isFullySynced ? __( 'Fully synced' ) : __( 'Not synced' )
|
|
45
|
+
}
|
|
46
|
+
checked={ isFullySynced }
|
|
47
|
+
onChange={ () => {
|
|
48
|
+
onUpdateSync(
|
|
49
|
+
syncStatus === 'unsynced' ? 'fully' : 'unsynced'
|
|
50
|
+
);
|
|
51
|
+
} }
|
|
52
|
+
/>
|
|
53
|
+
</PanelRow>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.edit-post-sync-status {
|
|
2
|
+
width: 100%;
|
|
3
|
+
position: relative;
|
|
4
|
+
justify-content: flex-start;
|
|
5
|
+
|
|
6
|
+
> span {
|
|
7
|
+
display: block;
|
|
8
|
+
width: 45%;
|
|
9
|
+
flex-shrink: 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.components-base-control {
|
|
13
|
+
// Match padding on tertiary buttons for alignment.
|
|
14
|
+
padding-left: $grid-unit-15 * 0.5;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import escapeHtml from 'escape-html';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -12,7 +7,6 @@ import { FormTokenField, withFilters } from '@wordpress/components';
|
|
|
12
7
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
13
8
|
import { store as coreStore } from '@wordpress/core-data';
|
|
14
9
|
import { useDebounce } from '@wordpress/compose';
|
|
15
|
-
import apiFetch from '@wordpress/api-fetch';
|
|
16
10
|
import { speak } from '@wordpress/a11y';
|
|
17
11
|
|
|
18
12
|
/**
|
|
@@ -51,28 +45,6 @@ const termNamesToIds = ( names, terms ) => {
|
|
|
51
45
|
);
|
|
52
46
|
};
|
|
53
47
|
|
|
54
|
-
// Tries to create a term or fetch it if it already exists.
|
|
55
|
-
function findOrCreateTerm( termName, restBase, namespace ) {
|
|
56
|
-
const escapedTermName = escapeHtml( termName );
|
|
57
|
-
|
|
58
|
-
return apiFetch( {
|
|
59
|
-
path: `/${ namespace }/${ restBase }`,
|
|
60
|
-
method: 'POST',
|
|
61
|
-
data: { name: escapedTermName },
|
|
62
|
-
} )
|
|
63
|
-
.catch( ( error ) => {
|
|
64
|
-
if ( error.code !== 'term_exists' ) {
|
|
65
|
-
return Promise.reject( error );
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return Promise.resolve( {
|
|
69
|
-
id: error.data.term_id,
|
|
70
|
-
name: termName,
|
|
71
|
-
} );
|
|
72
|
-
} )
|
|
73
|
-
.then( unescapeTerm );
|
|
74
|
-
}
|
|
75
|
-
|
|
76
48
|
export function FlatTermSelector( { slug } ) {
|
|
77
49
|
const [ values, setValues ] = useState( [] );
|
|
78
50
|
const [ search, setSearch ] = useState( '' );
|
|
@@ -165,11 +137,30 @@ export function FlatTermSelector( { slug } ) {
|
|
|
165
137
|
}, [ searchResults ] );
|
|
166
138
|
|
|
167
139
|
const { editPost } = useDispatch( editorStore );
|
|
140
|
+
const { saveEntityRecord } = useDispatch( coreStore );
|
|
168
141
|
|
|
169
142
|
if ( ! hasAssignAction ) {
|
|
170
143
|
return null;
|
|
171
144
|
}
|
|
172
145
|
|
|
146
|
+
async function findOrCreateTerm( term ) {
|
|
147
|
+
try {
|
|
148
|
+
const newTerm = await saveEntityRecord( 'taxonomy', slug, term, {
|
|
149
|
+
throwOnError: true,
|
|
150
|
+
} );
|
|
151
|
+
return unescapeTerm( newTerm );
|
|
152
|
+
} catch ( error ) {
|
|
153
|
+
if ( error.code !== 'term_exists' ) {
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
id: error.data.term_id,
|
|
159
|
+
name: term.name,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
173
164
|
function onUpdateTerms( newTermIds ) {
|
|
174
165
|
editPost( { [ taxonomy.rest_base ]: newTermIds } );
|
|
175
166
|
}
|
|
@@ -209,10 +200,9 @@ export function FlatTermSelector( { slug } ) {
|
|
|
209
200
|
return;
|
|
210
201
|
}
|
|
211
202
|
|
|
212
|
-
const namespace = taxonomy?.rest_namespace ?? 'wp/v2';
|
|
213
203
|
Promise.all(
|
|
214
204
|
newTermNames.map( ( termName ) =>
|
|
215
|
-
findOrCreateTerm( termName
|
|
205
|
+
findOrCreateTerm( { name: termName } )
|
|
216
206
|
)
|
|
217
207
|
).then( ( newTerms ) => {
|
|
218
208
|
const newAvailableTerms = availableTerms.concat( newTerms );
|
|
@@ -74,8 +74,10 @@ function PostTitle( _, forwardedRef ) {
|
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
const { defaultView } = ref.current.ownerDocument;
|
|
78
|
+
const { name, parent } = defaultView;
|
|
77
79
|
const ownerDocument =
|
|
78
|
-
|
|
80
|
+
name === 'editor-canvas' ? parent.document : defaultView.document;
|
|
79
81
|
const { activeElement, body } = ownerDocument;
|
|
80
82
|
|
|
81
83
|
// Only autofocus the title when the post is entirely empty. This should
|
|
@@ -19,7 +19,7 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
19
19
|
import withRegistryProvider from './with-registry-provider';
|
|
20
20
|
import { store as editorStore } from '../../store';
|
|
21
21
|
import useBlockEditorSettings from './use-block-editor-settings';
|
|
22
|
-
import { unlock } from '../../
|
|
22
|
+
import { unlock } from '../../lock-unlock';
|
|
23
23
|
|
|
24
24
|
const { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );
|
|
25
25
|
|
|
@@ -319,8 +319,6 @@ class NativeEditorProvider extends Component {
|
|
|
319
319
|
const { mode, switchMode } = this.props;
|
|
320
320
|
// Refresh html content first.
|
|
321
321
|
this.serializeToNativeAction();
|
|
322
|
-
// Make sure to blur the selected block and dismiss the keyboard.
|
|
323
|
-
this.props.clearSelectedBlock();
|
|
324
322
|
switchMode( mode === 'visual' ? 'text' : 'visual' );
|
|
325
323
|
}
|
|
326
324
|
|
|
@@ -387,12 +385,8 @@ const ComposedNativeProvider = compose( [
|
|
|
387
385
|
withDispatch( ( dispatch ) => {
|
|
388
386
|
const { editPost, resetEditorBlocks, updateEditorSettings } =
|
|
389
387
|
dispatch( editorStore );
|
|
390
|
-
const {
|
|
391
|
-
|
|
392
|
-
clearSelectedBlock,
|
|
393
|
-
insertBlock,
|
|
394
|
-
replaceBlock,
|
|
395
|
-
} = dispatch( blockEditorStore );
|
|
388
|
+
const { updateSettings, insertBlock, replaceBlock } =
|
|
389
|
+
dispatch( blockEditorStore );
|
|
396
390
|
const { switchEditorMode } = dispatch( editPostStore );
|
|
397
391
|
const { addEntities, receiveEntityRecords } = dispatch( coreStore );
|
|
398
392
|
const { createSuccessNotice } = dispatch( noticesStore );
|
|
@@ -401,7 +395,6 @@ const ComposedNativeProvider = compose( [
|
|
|
401
395
|
updateBlockEditorSettings: updateSettings,
|
|
402
396
|
updateEditorSettings,
|
|
403
397
|
addEntities,
|
|
404
|
-
clearSelectedBlock,
|
|
405
398
|
insertBlock,
|
|
406
399
|
createSuccessNotice,
|
|
407
400
|
editTitle( title ) {
|
package/src/private-apis.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { ExperimentalEditorProvider } from './components/provider';
|
|
5
|
-
import { lock } from './
|
|
5
|
+
import { lock } from './lock-unlock';
|
|
6
6
|
import { EntitiesSavedStatesExtensible } from './components/entities-saved-states';
|
|
7
7
|
|
|
8
8
|
export const privateApis = {};
|
package/src/style.scss
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
@import "./components/post-publish-button/style.scss";
|
|
12
12
|
@import "./components/post-publish-panel/style.scss";
|
|
13
13
|
@import "./components/post-saved-state/style.scss";
|
|
14
|
+
@import "./components/post-sync-status/style.scss";
|
|
14
15
|
@import "./components/post-taxonomies/style.scss";
|
|
15
16
|
@import "./components/post-text-editor/style.scss";
|
|
16
17
|
@import "./components/post-url/style.scss";
|
package/build/lockUnlock.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/lockUnlock.js"],"names":["lock","unlock"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAEO,MAAM;AAAEA,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZ,mEACC,8GADD,EAEC,mBAFD,CADM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/editor'\n\t);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/lockUnlock.js"],"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAT,QAAiE,yBAAjE;AACA,OAAO,MAAM;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZF,gDAAgD,CAC/C,8GAD+C,EAE/C,mBAF+C,CAD1C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/editor'\n\t);\n"]}
|
|
File without changes
|