@wordpress/edit-post 6.3.10 → 6.6.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 +6 -0
- package/build/components/device-preview/index.js +26 -7
- package/build/components/device-preview/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.native.js +25 -7
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/template-title/delete-template.js +6 -5
- package/build/components/header/template-title/delete-template.js.map +1 -1
- package/build/components/header/template-title/edit-template-title.js +4 -2
- package/build/components/header/template-title/edit-template-title.js.map +1 -1
- package/build/components/header/template-title/template-description.js +3 -1
- package/build/components/header/template-title/template-description.js.map +1 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js +5 -3
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/preferences-modal/index.js +10 -6
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +1 -5
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/plugin-document-setting-panel/index.js +0 -1
- package/build/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
- package/build/components/sidebar/post-schedule/index.js +1 -1
- package/build/components/sidebar/post-schedule/index.js.map +1 -1
- package/build/components/sidebar/post-visibility/index.js +16 -1
- package/build/components/sidebar/post-visibility/index.js.map +1 -1
- package/build/components/text-editor/index.js +11 -24
- package/build/components/text-editor/index.js.map +1 -1
- package/build/components/visual-editor/index.js +19 -1
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/index.js +7 -1
- package/build/index.js.map +1 -1
- package/build-module/components/device-preview/index.js +24 -7
- package/build-module/components/device-preview/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js +26 -8
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/template-title/delete-template.js +6 -5
- package/build-module/components/header/template-title/delete-template.js.map +1 -1
- package/build-module/components/header/template-title/edit-template-title.js +4 -2
- package/build-module/components/header/template-title/edit-template-title.js.map +1 -1
- package/build-module/components/header/template-title/template-description.js +4 -2
- package/build-module/components/header/template-title/template-description.js.map +1 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js +5 -3
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +10 -6
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -5
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/plugin-document-setting-panel/index.js +0 -1
- package/build-module/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
- package/build-module/components/sidebar/post-schedule/index.js +1 -1
- package/build-module/components/sidebar/post-schedule/index.js.map +1 -1
- package/build-module/components/sidebar/post-visibility/index.js +17 -1
- package/build-module/components/sidebar/post-visibility/index.js.map +1 -1
- package/build-module/components/text-editor/index.js +11 -22
- package/build-module/components/text-editor/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +20 -2
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/index.js +7 -1
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +41 -81
- package/build-style/style.css +41 -81
- package/package.json +27 -27
- package/src/components/block-manager/style.scss +0 -4
- package/src/components/device-preview/index.js +36 -23
- package/src/components/header/header-toolbar/index.native.js +45 -8
- package/src/components/header/header-toolbar/style.native.scss +8 -4
- package/src/components/header/style.scss +14 -36
- package/src/components/header/template-title/delete-template.js +11 -4
- package/src/components/header/template-title/edit-template-title.js +27 -25
- package/src/components/header/template-title/style.scss +26 -5
- package/src/components/header/template-title/template-description.js +3 -2
- package/src/components/layout/index.js +1 -0
- package/src/components/layout/index.native.js +8 -5
- package/src/components/preferences-modal/index.js +18 -9
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +24 -14
- package/src/components/secondary-sidebar/list-view-sidebar.js +1 -5
- package/src/components/sidebar/plugin-document-setting-panel/index.js +0 -1
- package/src/components/sidebar/post-schedule/index.js +1 -1
- package/src/components/sidebar/post-schedule/style.scss +2 -2
- package/src/components/sidebar/post-visibility/index.js +12 -2
- package/src/components/sidebar/post-visibility/style.scss +2 -30
- package/src/components/sidebar/settings-header/style.scss +1 -1
- package/src/components/text-editor/index.js +9 -19
- package/src/components/visual-editor/index.js +14 -2
- package/src/components/visual-editor/test/index.native.js +93 -0
- package/src/index.js +7 -0
- package/src/test/editor.native.js +11 -2
- package/build/components/admin-notices/index.js +0 -129
- package/build/components/admin-notices/index.js.map +0 -1
- package/build/components/block-manager/show-all.js +0 -39
- package/build/components/block-manager/show-all.js.map +0 -1
- package/build/components/editor-initialization/utils.js +0 -38
- package/build/components/editor-initialization/utils.js.map +0 -1
- package/build-module/components/admin-notices/index.js +0 -114
- package/build-module/components/admin-notices/index.js.map +0 -1
- package/build-module/components/block-manager/show-all.js +0 -29
- package/build-module/components/block-manager/show-all.js.map +0 -1
- package/build-module/components/editor-initialization/utils.js +0 -29
- package/build-module/components/editor-initialization/utils.js.map +0 -1
- package/src/components/admin-notices/index.js +0 -110
- package/src/components/admin-notices/test/index.js +0 -63
- package/src/components/block-manager/show-all.js +0 -30
- package/src/components/editor-initialization/utils.js +0 -24
|
@@ -8,30 +8,34 @@ import {
|
|
|
8
8
|
store as editorStore,
|
|
9
9
|
} from '@wordpress/editor';
|
|
10
10
|
import { Button } from '@wordpress/components';
|
|
11
|
-
import {
|
|
11
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
12
|
import { __ } from '@wordpress/i18n';
|
|
13
13
|
import { displayShortcut } from '@wordpress/keycodes';
|
|
14
|
-
import { compose } from '@wordpress/compose';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Internal dependencies
|
|
18
17
|
*/
|
|
19
18
|
import { store as editPostStore } from '../../store';
|
|
20
19
|
|
|
21
|
-
function TextEditor(
|
|
20
|
+
export default function TextEditor() {
|
|
21
|
+
const isRichEditingEnabled = useSelect( ( select ) => {
|
|
22
|
+
return select( editorStore ).getEditorSettings().richEditingEnabled;
|
|
23
|
+
}, [] );
|
|
24
|
+
const { switchEditorMode } = useDispatch( editPostStore );
|
|
25
|
+
|
|
22
26
|
return (
|
|
23
27
|
<div className="edit-post-text-editor">
|
|
28
|
+
<TextEditorGlobalKeyboardShortcuts />
|
|
24
29
|
{ isRichEditingEnabled && (
|
|
25
30
|
<div className="edit-post-text-editor__toolbar">
|
|
26
31
|
<h2>{ __( 'Editing code' ) }</h2>
|
|
27
32
|
<Button
|
|
28
33
|
variant="tertiary"
|
|
29
|
-
onClick={
|
|
34
|
+
onClick={ () => switchEditorMode( 'visual' ) }
|
|
30
35
|
shortcut={ displayShortcut.secondary( 'm' ) }
|
|
31
36
|
>
|
|
32
37
|
{ __( 'Exit code editor' ) }
|
|
33
38
|
</Button>
|
|
34
|
-
<TextEditorGlobalKeyboardShortcuts />
|
|
35
39
|
</div>
|
|
36
40
|
) }
|
|
37
41
|
<div className="edit-post-text-editor__body">
|
|
@@ -41,17 +45,3 @@ function TextEditor( { onExit, isRichEditingEnabled } ) {
|
|
|
41
45
|
</div>
|
|
42
46
|
);
|
|
43
47
|
}
|
|
44
|
-
|
|
45
|
-
export default compose(
|
|
46
|
-
withSelect( ( select ) => ( {
|
|
47
|
-
isRichEditingEnabled: select( editorStore ).getEditorSettings()
|
|
48
|
-
.richEditingEnabled,
|
|
49
|
-
} ) ),
|
|
50
|
-
withDispatch( ( dispatch ) => {
|
|
51
|
-
return {
|
|
52
|
-
onExit() {
|
|
53
|
-
dispatch( editPostStore ).switchEditorMode( 'visual' );
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
} )
|
|
57
|
-
)( TextEditor );
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
__unstableIframe as Iframe,
|
|
30
30
|
__experimentalUseNoRecursiveRenders as useNoRecursiveRenders,
|
|
31
31
|
} from '@wordpress/block-editor';
|
|
32
|
-
import { useRef, useMemo } from '@wordpress/element';
|
|
32
|
+
import { useEffect, useRef, useMemo } from '@wordpress/element';
|
|
33
33
|
import { Button, __unstableMotion as motion } from '@wordpress/components';
|
|
34
34
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
35
35
|
import { useMergeRefs } from '@wordpress/compose';
|
|
@@ -85,11 +85,13 @@ function MaybeIframe( {
|
|
|
85
85
|
export default function VisualEditor( { styles } ) {
|
|
86
86
|
const {
|
|
87
87
|
deviceType,
|
|
88
|
+
isWelcomeGuideVisible,
|
|
88
89
|
isTemplateMode,
|
|
89
90
|
wrapperBlockName,
|
|
90
91
|
wrapperUniqueId,
|
|
91
92
|
} = useSelect( ( select ) => {
|
|
92
93
|
const {
|
|
94
|
+
isFeatureActive,
|
|
93
95
|
isEditingTemplate,
|
|
94
96
|
__experimentalGetPreviewDeviceType,
|
|
95
97
|
} = select( editPostStore );
|
|
@@ -105,11 +107,13 @@ export default function VisualEditor( { styles } ) {
|
|
|
105
107
|
|
|
106
108
|
return {
|
|
107
109
|
deviceType: __experimentalGetPreviewDeviceType(),
|
|
110
|
+
isWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),
|
|
108
111
|
isTemplateMode: _isTemplateMode,
|
|
109
112
|
wrapperBlockName: _wrapperBlockName,
|
|
110
113
|
wrapperUniqueId: getCurrentPostId(),
|
|
111
114
|
};
|
|
112
115
|
}, [] );
|
|
116
|
+
const { isCleanNewPost } = useSelect( editorStore );
|
|
113
117
|
const hasMetaBoxes = useSelect(
|
|
114
118
|
( select ) => select( editPostStore ).hasMetaBoxes(),
|
|
115
119
|
[]
|
|
@@ -186,6 +190,14 @@ export default function VisualEditor( { styles } ) {
|
|
|
186
190
|
return undefined;
|
|
187
191
|
}, [ isTemplateMode, themeSupportsLayout, defaultLayout ] );
|
|
188
192
|
|
|
193
|
+
const titleRef = useRef();
|
|
194
|
+
useEffect( () => {
|
|
195
|
+
if ( isWelcomeGuideVisible || ! isCleanNewPost() ) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
titleRef?.current?.focus();
|
|
199
|
+
}, [ isWelcomeGuideVisible, isCleanNewPost ] );
|
|
200
|
+
|
|
189
201
|
return (
|
|
190
202
|
<BlockTools
|
|
191
203
|
__unstableContentRef={ ref }
|
|
@@ -240,7 +252,7 @@ export default function VisualEditor( { styles } ) {
|
|
|
240
252
|
className="edit-post-visual-editor__post-title-wrapper"
|
|
241
253
|
contentEditable={ false }
|
|
242
254
|
>
|
|
243
|
-
<PostTitle />
|
|
255
|
+
<PostTitle ref={ titleRef } />
|
|
244
256
|
</div>
|
|
245
257
|
) }
|
|
246
258
|
<RecursionProvider>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { initializeEditor, fireEvent } from 'test/helpers';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
|
|
10
|
+
import { registerCoreBlocks } from '@wordpress/block-library';
|
|
11
|
+
|
|
12
|
+
beforeAll( () => {
|
|
13
|
+
// Register all core blocks
|
|
14
|
+
registerCoreBlocks();
|
|
15
|
+
} );
|
|
16
|
+
|
|
17
|
+
afterAll( () => {
|
|
18
|
+
// Clean up registered blocks
|
|
19
|
+
getBlockTypes().forEach( ( block ) => {
|
|
20
|
+
unregisterBlockType( block.name );
|
|
21
|
+
} );
|
|
22
|
+
} );
|
|
23
|
+
|
|
24
|
+
const initialHtml = `
|
|
25
|
+
<!-- wp:paragraph -->
|
|
26
|
+
<p>First example paragraph.</p>
|
|
27
|
+
<!-- /wp:paragraph -->
|
|
28
|
+
|
|
29
|
+
<!-- wp:paragraph -->
|
|
30
|
+
<p>Second example paragraph.</p>
|
|
31
|
+
<!-- /wp:paragraph -->
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
describe( 'when title is focused', () => {
|
|
35
|
+
it( 'new blocks are inserted after the title', async () => {
|
|
36
|
+
const screen = await initializeEditor( {
|
|
37
|
+
initialHtml,
|
|
38
|
+
} );
|
|
39
|
+
|
|
40
|
+
// Focus first block
|
|
41
|
+
fireEvent.press( screen.getByA11yLabel( /Paragraph Block. Row 1/ ) );
|
|
42
|
+
|
|
43
|
+
// Focus title
|
|
44
|
+
fireEvent(
|
|
45
|
+
screen.getAllByA11yLabel( 'Post title. test' )[ 0 ],
|
|
46
|
+
'select'
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// Add new Heading block
|
|
50
|
+
fireEvent.press( screen.getByA11yLabel( 'Add block' ) );
|
|
51
|
+
fireEvent.press( screen.getByText( 'Heading' ) );
|
|
52
|
+
|
|
53
|
+
expect( screen.getByA11yLabel( /Heading Block. Row 1/ ) ).toBeDefined();
|
|
54
|
+
expect(
|
|
55
|
+
screen.getByA11yLabel( /Paragraph Block. Row 2/ )
|
|
56
|
+
).toBeDefined();
|
|
57
|
+
expect(
|
|
58
|
+
screen.getByA11yLabel( /Paragraph Block. Row 3/ )
|
|
59
|
+
).toBeDefined();
|
|
60
|
+
} );
|
|
61
|
+
} );
|
|
62
|
+
|
|
63
|
+
describe( 'when title is no longer focused', () => {
|
|
64
|
+
it( 'new blocks are inserted after the currently focused block', async () => {
|
|
65
|
+
const screen = await initializeEditor( {
|
|
66
|
+
initialHtml,
|
|
67
|
+
} );
|
|
68
|
+
|
|
69
|
+
// Focus first block
|
|
70
|
+
fireEvent.press( screen.getByA11yLabel( /Paragraph Block. Row 1/ ) );
|
|
71
|
+
|
|
72
|
+
// Focus title
|
|
73
|
+
fireEvent(
|
|
74
|
+
screen.getAllByA11yLabel( 'Post title. test' )[ 0 ],
|
|
75
|
+
'select'
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// Focus last block
|
|
79
|
+
fireEvent.press( screen.getByA11yLabel( /Paragraph Block. Row 2/ ) );
|
|
80
|
+
|
|
81
|
+
// Add new Heading block
|
|
82
|
+
fireEvent.press( screen.getByA11yLabel( 'Add block' ) );
|
|
83
|
+
fireEvent.press( screen.getByText( 'Heading' ) );
|
|
84
|
+
|
|
85
|
+
expect(
|
|
86
|
+
screen.getByA11yLabel( /Paragraph Block. Row 1/ )
|
|
87
|
+
).toBeDefined();
|
|
88
|
+
expect(
|
|
89
|
+
screen.getByA11yLabel( /Paragraph Block. Row 2/ )
|
|
90
|
+
).toBeDefined();
|
|
91
|
+
expect( screen.getByA11yLabel( /Heading Block. Row 3/ ) ).toBeDefined();
|
|
92
|
+
} );
|
|
93
|
+
} );
|
package/src/index.js
CHANGED
|
@@ -117,12 +117,19 @@ export function initializeEditor(
|
|
|
117
117
|
preferredStyleVariations: {},
|
|
118
118
|
showBlockBreadcrumbs: true,
|
|
119
119
|
showIconLabels: false,
|
|
120
|
+
showListViewByDefault: false,
|
|
120
121
|
themeStyles: true,
|
|
121
122
|
welcomeGuide: true,
|
|
122
123
|
welcomeGuideTemplate: true,
|
|
123
124
|
} );
|
|
124
125
|
|
|
125
126
|
dispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();
|
|
127
|
+
|
|
128
|
+
// Check if the block list view should be open by default.
|
|
129
|
+
if ( select( editPostStore ).isFeatureActive( 'showListViewByDefault' ) ) {
|
|
130
|
+
dispatch( editPostStore ).setIsListViewOpened( true );
|
|
131
|
+
}
|
|
132
|
+
|
|
126
133
|
registerCoreBlocks();
|
|
127
134
|
if ( process.env.IS_GUTENBERG_PLUGIN ) {
|
|
128
135
|
__experimentalRegisterExperimentalCoreBlocks( {
|
|
@@ -25,10 +25,19 @@ const unsupportedBlock = `
|
|
|
25
25
|
<!-- /wp:notablock -->
|
|
26
26
|
`;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
beforeAll( () => {
|
|
29
|
+
jest.useFakeTimers( 'legacy' );
|
|
30
|
+
} );
|
|
31
|
+
|
|
32
|
+
afterAll( () => {
|
|
33
|
+
jest.runOnlyPendingTimers();
|
|
34
|
+
jest.useRealTimers();
|
|
35
|
+
} );
|
|
29
36
|
|
|
30
37
|
describe( 'Editor', () => {
|
|
31
|
-
beforeAll(
|
|
38
|
+
beforeAll( () => {
|
|
39
|
+
registerCoreBlocks();
|
|
40
|
+
} );
|
|
32
41
|
|
|
33
42
|
it( 'detects unsupported block and sends hasUnsupportedBlocks true to native', () => {
|
|
34
43
|
RNReactNativeGutenbergBridge.editorDidMount = jest.fn();
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.AdminNotices = void 0;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
var _data = require("@wordpress/data");
|
|
11
|
-
|
|
12
|
-
var _notices = require("@wordpress/notices");
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* WordPress dependencies
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Mapping of server-supported notice class names to an equivalent notices
|
|
20
|
-
* module status.
|
|
21
|
-
*
|
|
22
|
-
* @type {Map}
|
|
23
|
-
*/
|
|
24
|
-
const NOTICE_CLASS_STATUSES = {
|
|
25
|
-
'notice-success': 'success',
|
|
26
|
-
updated: 'success',
|
|
27
|
-
'notice-warning': 'warning',
|
|
28
|
-
'notice-error': 'error',
|
|
29
|
-
error: 'error',
|
|
30
|
-
'notice-info': 'info'
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Returns an array of admin notice Elements.
|
|
34
|
-
*
|
|
35
|
-
* @return {Element[]} Admin notice elements.
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
function getAdminNotices() {
|
|
39
|
-
// The order is reversed to match expectations of rendered order, since a
|
|
40
|
-
// NoticesList is itself rendered in reverse order (newest to oldest).
|
|
41
|
-
return Array.from(document.querySelectorAll('#wpbody-content > .notice')).reverse();
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Given an admin notice Element, returns the relevant notice content HTML.
|
|
45
|
-
*
|
|
46
|
-
* @param {Element} element Admin notice element.
|
|
47
|
-
*
|
|
48
|
-
* @return {Element} Upgraded notice HTML.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
function getNoticeHTML(element) {
|
|
53
|
-
const fragments = [];
|
|
54
|
-
|
|
55
|
-
for (const child of element.childNodes) {
|
|
56
|
-
if (child.nodeType !== child.ELEMENT_NODE) {
|
|
57
|
-
const value = child.nodeValue.trim();
|
|
58
|
-
|
|
59
|
-
if (value) {
|
|
60
|
-
fragments.push(child.nodeValue);
|
|
61
|
-
}
|
|
62
|
-
} else if (!child.classList.contains('notice-dismiss')) {
|
|
63
|
-
fragments.push(child.outerHTML);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return fragments.join('');
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Given an admin notice Element, returns the upgraded status type, or
|
|
71
|
-
* undefined if one cannot be determined (i.e. one is not assigned).
|
|
72
|
-
*
|
|
73
|
-
* @param {Element} element Admin notice element.
|
|
74
|
-
*
|
|
75
|
-
* @return {?string} Upgraded status type.
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
function getNoticeStatus(element) {
|
|
80
|
-
for (const className of element.classList) {
|
|
81
|
-
if (NOTICE_CLASS_STATUSES.hasOwnProperty(className)) {
|
|
82
|
-
return NOTICE_CLASS_STATUSES[className];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
class AdminNotices extends _element.Component {
|
|
88
|
-
componentDidMount() {
|
|
89
|
-
this.convertNotices();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
convertNotices() {
|
|
93
|
-
const {
|
|
94
|
-
createNotice
|
|
95
|
-
} = this.props;
|
|
96
|
-
getAdminNotices().forEach(element => {
|
|
97
|
-
// Convert and create.
|
|
98
|
-
const status = getNoticeStatus(element);
|
|
99
|
-
const content = getNoticeHTML(element);
|
|
100
|
-
const isDismissible = element.classList.contains('is-dismissible');
|
|
101
|
-
createNotice(status, content, {
|
|
102
|
-
speak: false,
|
|
103
|
-
__unstableHTML: true,
|
|
104
|
-
isDismissible
|
|
105
|
-
}); // Remove (now-redundant) admin notice element.
|
|
106
|
-
|
|
107
|
-
element.parentNode.removeChild(element);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
render() {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
exports.AdminNotices = AdminNotices;
|
|
118
|
-
|
|
119
|
-
var _default = (0, _data.withDispatch)(dispatch => {
|
|
120
|
-
const {
|
|
121
|
-
createNotice
|
|
122
|
-
} = dispatch(_notices.store);
|
|
123
|
-
return {
|
|
124
|
-
createNotice
|
|
125
|
-
};
|
|
126
|
-
})(AdminNotices);
|
|
127
|
-
|
|
128
|
-
exports.default = _default;
|
|
129
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/admin-notices/index.js"],"names":["NOTICE_CLASS_STATUSES","updated","error","getAdminNotices","Array","from","document","querySelectorAll","reverse","getNoticeHTML","element","fragments","child","childNodes","nodeType","ELEMENT_NODE","value","nodeValue","trim","push","classList","contains","outerHTML","join","getNoticeStatus","className","hasOwnProperty","AdminNotices","Component","componentDidMount","convertNotices","createNotice","props","forEach","status","content","isDismissible","speak","__unstableHTML","parentNode","removeChild","render","dispatch","noticesStore"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,qBAAqB,GAAG;AAC7B,oBAAkB,SADW;AAE7BC,EAAAA,OAAO,EAAE,SAFoB;AAG7B,oBAAkB,SAHW;AAI7B,kBAAgB,OAJa;AAK7BC,EAAAA,KAAK,EAAE,OALsB;AAM7B,iBAAe;AANc,CAA9B;AASA;AACA;AACA;AACA;AACA;;AACA,SAASC,eAAT,GAA2B;AAC1B;AACA;AACA,SAAOC,KAAK,CAACC,IAAN,CACNC,QAAQ,CAACC,gBAAT,CAA2B,2BAA3B,CADM,EAELC,OAFK,EAAP;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,aAAT,CAAwBC,OAAxB,EAAkC;AACjC,QAAMC,SAAS,GAAG,EAAlB;;AAEA,OAAM,MAAMC,KAAZ,IAAqBF,OAAO,CAACG,UAA7B,EAA0C;AACzC,QAAKD,KAAK,CAACE,QAAN,KAAmBF,KAAK,CAACG,YAA9B,EAA6C;AAC5C,YAAMC,KAAK,GAAGJ,KAAK,CAACK,SAAN,CAAgBC,IAAhB,EAAd;;AACA,UAAKF,KAAL,EAAa;AACZL,QAAAA,SAAS,CAACQ,IAAV,CAAgBP,KAAK,CAACK,SAAtB;AACA;AACD,KALD,MAKO,IAAK,CAAEL,KAAK,CAACQ,SAAN,CAAgBC,QAAhB,CAA0B,gBAA1B,CAAP,EAAsD;AAC5DV,MAAAA,SAAS,CAACQ,IAAV,CAAgBP,KAAK,CAACU,SAAtB;AACA;AACD;;AAED,SAAOX,SAAS,CAACY,IAAV,CAAgB,EAAhB,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,eAAT,CAA0Bd,OAA1B,EAAoC;AACnC,OAAM,MAAMe,SAAZ,IAAyBf,OAAO,CAACU,SAAjC,EAA6C;AAC5C,QAAKpB,qBAAqB,CAAC0B,cAAtB,CAAsCD,SAAtC,CAAL,EAAyD;AACxD,aAAOzB,qBAAqB,CAAEyB,SAAF,CAA5B;AACA;AACD;AACD;;AAEM,MAAME,YAAN,SAA2BC,kBAA3B,CAAqC;AAC3CC,EAAAA,iBAAiB,GAAG;AACnB,SAAKC,cAAL;AACA;;AAEDA,EAAAA,cAAc,GAAG;AAChB,UAAM;AAAEC,MAAAA;AAAF,QAAmB,KAAKC,KAA9B;AACA7B,IAAAA,eAAe,GAAG8B,OAAlB,CAA6BvB,OAAF,IAAe;AACzC;AACA,YAAMwB,MAAM,GAAGV,eAAe,CAAEd,OAAF,CAA9B;AACA,YAAMyB,OAAO,GAAG1B,aAAa,CAAEC,OAAF,CAA7B;AACA,YAAM0B,aAAa,GAAG1B,OAAO,CAACU,SAAR,CAAkBC,QAAlB,CACrB,gBADqB,CAAtB;AAGAU,MAAAA,YAAY,CAAEG,MAAF,EAAUC,OAAV,EAAmB;AAC9BE,QAAAA,KAAK,EAAE,KADuB;AAE9BC,QAAAA,cAAc,EAAE,IAFc;AAG9BF,QAAAA;AAH8B,OAAnB,CAAZ,CAPyC,CAazC;;AACA1B,MAAAA,OAAO,CAAC6B,UAAR,CAAmBC,WAAnB,CAAgC9B,OAAhC;AACA,KAfD;AAgBA;;AAED+B,EAAAA,MAAM,GAAG;AACR,WAAO,IAAP;AACA;;AA3B0C;;;;eA8B7B,wBAAgBC,QAAF,IAAgB;AAC5C,QAAM;AAAEX,IAAAA;AAAF,MAAmBW,QAAQ,CAAEC,cAAF,CAAjC;AAEA,SAAO;AAAEZ,IAAAA;AAAF,GAAP;AACA,CAJc,EAIVJ,YAJU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { withDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Mapping of server-supported notice class names to an equivalent notices\n * module status.\n *\n * @type {Map}\n */\nconst NOTICE_CLASS_STATUSES = {\n\t'notice-success': 'success',\n\tupdated: 'success',\n\t'notice-warning': 'warning',\n\t'notice-error': 'error',\n\terror: 'error',\n\t'notice-info': 'info',\n};\n\n/**\n * Returns an array of admin notice Elements.\n *\n * @return {Element[]} Admin notice elements.\n */\nfunction getAdminNotices() {\n\t// The order is reversed to match expectations of rendered order, since a\n\t// NoticesList is itself rendered in reverse order (newest to oldest).\n\treturn Array.from(\n\t\tdocument.querySelectorAll( '#wpbody-content > .notice' )\n\t).reverse();\n}\n\n/**\n * Given an admin notice Element, returns the relevant notice content HTML.\n *\n * @param {Element} element Admin notice element.\n *\n * @return {Element} Upgraded notice HTML.\n */\nfunction getNoticeHTML( element ) {\n\tconst fragments = [];\n\n\tfor ( const child of element.childNodes ) {\n\t\tif ( child.nodeType !== child.ELEMENT_NODE ) {\n\t\t\tconst value = child.nodeValue.trim();\n\t\t\tif ( value ) {\n\t\t\t\tfragments.push( child.nodeValue );\n\t\t\t}\n\t\t} else if ( ! child.classList.contains( 'notice-dismiss' ) ) {\n\t\t\tfragments.push( child.outerHTML );\n\t\t}\n\t}\n\n\treturn fragments.join( '' );\n}\n\n/**\n * Given an admin notice Element, returns the upgraded status type, or\n * undefined if one cannot be determined (i.e. one is not assigned).\n *\n * @param {Element} element Admin notice element.\n *\n * @return {?string} Upgraded status type.\n */\nfunction getNoticeStatus( element ) {\n\tfor ( const className of element.classList ) {\n\t\tif ( NOTICE_CLASS_STATUSES.hasOwnProperty( className ) ) {\n\t\t\treturn NOTICE_CLASS_STATUSES[ className ];\n\t\t}\n\t}\n}\n\nexport class AdminNotices extends Component {\n\tcomponentDidMount() {\n\t\tthis.convertNotices();\n\t}\n\n\tconvertNotices() {\n\t\tconst { createNotice } = this.props;\n\t\tgetAdminNotices().forEach( ( element ) => {\n\t\t\t// Convert and create.\n\t\t\tconst status = getNoticeStatus( element );\n\t\t\tconst content = getNoticeHTML( element );\n\t\t\tconst isDismissible = element.classList.contains(\n\t\t\t\t'is-dismissible'\n\t\t\t);\n\t\t\tcreateNotice( status, content, {\n\t\t\t\tspeak: false,\n\t\t\t\t__unstableHTML: true,\n\t\t\t\tisDismissible,\n\t\t\t} );\n\n\t\t\t// Remove (now-redundant) admin notice element.\n\t\t\telement.parentNode.removeChild( element );\n\t\t} );\n\t}\n\n\trender() {\n\t\treturn null;\n\t}\n}\n\nexport default withDispatch( ( dispatch ) => {\n\tconst { createNotice } = dispatch( noticesStore );\n\n\treturn { createNotice };\n} )( AdminNotices );\n"]}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = BlockManagerShowAll;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
var _compose = require("@wordpress/compose");
|
|
11
|
-
|
|
12
|
-
var _components = require("@wordpress/components");
|
|
13
|
-
|
|
14
|
-
var _i18n = require("@wordpress/i18n");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
function BlockManagerShowAll(_ref) {
|
|
20
|
-
let {
|
|
21
|
-
checked,
|
|
22
|
-
onChange
|
|
23
|
-
} = _ref;
|
|
24
|
-
const instanceId = (0, _compose.useInstanceId)(BlockManagerShowAll);
|
|
25
|
-
const id = 'edit-post-block-manager__show-all-' + instanceId;
|
|
26
|
-
return (0, _element.createElement)("div", {
|
|
27
|
-
className: "edit-post-block-manager__show-all"
|
|
28
|
-
}, (0, _element.createElement)("label", {
|
|
29
|
-
htmlFor: id,
|
|
30
|
-
className: "edit-post-block-manager__show-all-label"
|
|
31
|
-
},
|
|
32
|
-
/* translators: Checkbox toggle label */
|
|
33
|
-
(0, _i18n.__)('Show section')), (0, _element.createElement)(_components.FormToggle, {
|
|
34
|
-
id: id,
|
|
35
|
-
checked: checked,
|
|
36
|
-
onChange: event => onChange(event.target.checked)
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=show-all.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/block-manager/show-all.js"],"names":["BlockManagerShowAll","checked","onChange","instanceId","id","event","target"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKe,SAASA,mBAAT,OAAsD;AAAA,MAAxB;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,GAAwB;AACpE,QAAMC,UAAU,GAAG,4BAAeH,mBAAf,CAAnB;AACA,QAAMI,EAAE,GAAG,uCAAuCD,UAAlD;AAEA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AACC,IAAA,OAAO,EAAGC,EADX;AAEC,IAAA,SAAS,EAAC;AAFX;AAKE;AACA,gBAAI,cAAJ,CANF,CADD,EAUC,4BAAC,sBAAD;AACC,IAAA,EAAE,EAAGA,EADN;AAEC,IAAA,OAAO,EAAGH,OAFX;AAGC,IAAA,QAAQ,EAAKI,KAAF,IAAaH,QAAQ,CAAEG,KAAK,CAACC,MAAN,CAAaL,OAAf;AAHjC,IAVD,CADD;AAkBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { FormToggle } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nexport default function BlockManagerShowAll( { checked, onChange } ) {\n\tconst instanceId = useInstanceId( BlockManagerShowAll );\n\tconst id = 'edit-post-block-manager__show-all-' + instanceId;\n\n\treturn (\n\t\t<div className=\"edit-post-block-manager__show-all\">\n\t\t\t<label\n\t\t\t\thtmlFor={ id }\n\t\t\t\tclassName=\"edit-post-block-manager__show-all-label\"\n\t\t\t>\n\t\t\t\t{\n\t\t\t\t\t/* translators: Checkbox toggle label */\n\t\t\t\t\t__( 'Show section' )\n\t\t\t\t}\n\t\t\t</label>\n\t\t\t<FormToggle\n\t\t\t\tid={ id }\n\t\t\t\tchecked={ checked }\n\t\t\t\tonChange={ ( event ) => onChange( event.target.checked ) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.onChangeListener = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Given a selector returns a functions that returns the listener only
|
|
10
|
-
* if the returned value from the selector changes.
|
|
11
|
-
*
|
|
12
|
-
* @param {Function} selector Selector.
|
|
13
|
-
* @param {Function} listener Listener.
|
|
14
|
-
* @param {boolean} initial Flags whether listener should be invoked on
|
|
15
|
-
* initial call.
|
|
16
|
-
*
|
|
17
|
-
* @return {Function} Listener creator.
|
|
18
|
-
*/
|
|
19
|
-
const onChangeListener = function (selector, listener) {
|
|
20
|
-
let initial = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
21
|
-
let previousValue = selector();
|
|
22
|
-
|
|
23
|
-
if (initial) {
|
|
24
|
-
listener(selector());
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return () => {
|
|
28
|
-
const selectedValue = selector();
|
|
29
|
-
|
|
30
|
-
if (selectedValue !== previousValue) {
|
|
31
|
-
previousValue = selectedValue;
|
|
32
|
-
listener(selectedValue);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
exports.onChangeListener = onChangeListener;
|
|
38
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/editor-initialization/utils.js"],"names":["onChangeListener","selector","listener","initial","previousValue","selectedValue"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,gBAAgB,GAAG,UAAEC,QAAF,EAAYC,QAAZ,EAA2C;AAAA,MAArBC,OAAqB,uEAAX,KAAW;AAC1E,MAAIC,aAAa,GAAGH,QAAQ,EAA5B;;AACA,MAAKE,OAAL,EAAe;AACdD,IAAAA,QAAQ,CAAED,QAAQ,EAAV,CAAR;AACA;;AACD,SAAO,MAAM;AACZ,UAAMI,aAAa,GAAGJ,QAAQ,EAA9B;;AACA,QAAKI,aAAa,KAAKD,aAAvB,EAAuC;AACtCA,MAAAA,aAAa,GAAGC,aAAhB;AACAH,MAAAA,QAAQ,CAAEG,aAAF,CAAR;AACA;AACD,GAND;AAOA,CAZM","sourcesContent":["/**\n * Given a selector returns a functions that returns the listener only\n * if the returned value from the selector changes.\n *\n * @param {Function} selector Selector.\n * @param {Function} listener Listener.\n * @param {boolean} initial Flags whether listener should be invoked on\n * initial call.\n *\n * @return {Function} Listener creator.\n */\nexport const onChangeListener = ( selector, listener, initial = false ) => {\n\tlet previousValue = selector();\n\tif ( initial ) {\n\t\tlistener( selector() );\n\t}\n\treturn () => {\n\t\tconst selectedValue = selector();\n\t\tif ( selectedValue !== previousValue ) {\n\t\t\tpreviousValue = selectedValue;\n\t\t\tlistener( selectedValue );\n\t\t}\n\t};\n};\n"]}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { Component } from '@wordpress/element';
|
|
5
|
-
import { withDispatch } from '@wordpress/data';
|
|
6
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
7
|
-
/**
|
|
8
|
-
* Mapping of server-supported notice class names to an equivalent notices
|
|
9
|
-
* module status.
|
|
10
|
-
*
|
|
11
|
-
* @type {Map}
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const NOTICE_CLASS_STATUSES = {
|
|
15
|
-
'notice-success': 'success',
|
|
16
|
-
updated: 'success',
|
|
17
|
-
'notice-warning': 'warning',
|
|
18
|
-
'notice-error': 'error',
|
|
19
|
-
error: 'error',
|
|
20
|
-
'notice-info': 'info'
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Returns an array of admin notice Elements.
|
|
24
|
-
*
|
|
25
|
-
* @return {Element[]} Admin notice elements.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
function getAdminNotices() {
|
|
29
|
-
// The order is reversed to match expectations of rendered order, since a
|
|
30
|
-
// NoticesList is itself rendered in reverse order (newest to oldest).
|
|
31
|
-
return Array.from(document.querySelectorAll('#wpbody-content > .notice')).reverse();
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Given an admin notice Element, returns the relevant notice content HTML.
|
|
35
|
-
*
|
|
36
|
-
* @param {Element} element Admin notice element.
|
|
37
|
-
*
|
|
38
|
-
* @return {Element} Upgraded notice HTML.
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function getNoticeHTML(element) {
|
|
43
|
-
const fragments = [];
|
|
44
|
-
|
|
45
|
-
for (const child of element.childNodes) {
|
|
46
|
-
if (child.nodeType !== child.ELEMENT_NODE) {
|
|
47
|
-
const value = child.nodeValue.trim();
|
|
48
|
-
|
|
49
|
-
if (value) {
|
|
50
|
-
fragments.push(child.nodeValue);
|
|
51
|
-
}
|
|
52
|
-
} else if (!child.classList.contains('notice-dismiss')) {
|
|
53
|
-
fragments.push(child.outerHTML);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return fragments.join('');
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Given an admin notice Element, returns the upgraded status type, or
|
|
61
|
-
* undefined if one cannot be determined (i.e. one is not assigned).
|
|
62
|
-
*
|
|
63
|
-
* @param {Element} element Admin notice element.
|
|
64
|
-
*
|
|
65
|
-
* @return {?string} Upgraded status type.
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
function getNoticeStatus(element) {
|
|
70
|
-
for (const className of element.classList) {
|
|
71
|
-
if (NOTICE_CLASS_STATUSES.hasOwnProperty(className)) {
|
|
72
|
-
return NOTICE_CLASS_STATUSES[className];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export class AdminNotices extends Component {
|
|
78
|
-
componentDidMount() {
|
|
79
|
-
this.convertNotices();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
convertNotices() {
|
|
83
|
-
const {
|
|
84
|
-
createNotice
|
|
85
|
-
} = this.props;
|
|
86
|
-
getAdminNotices().forEach(element => {
|
|
87
|
-
// Convert and create.
|
|
88
|
-
const status = getNoticeStatus(element);
|
|
89
|
-
const content = getNoticeHTML(element);
|
|
90
|
-
const isDismissible = element.classList.contains('is-dismissible');
|
|
91
|
-
createNotice(status, content, {
|
|
92
|
-
speak: false,
|
|
93
|
-
__unstableHTML: true,
|
|
94
|
-
isDismissible
|
|
95
|
-
}); // Remove (now-redundant) admin notice element.
|
|
96
|
-
|
|
97
|
-
element.parentNode.removeChild(element);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
render() {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
export default withDispatch(dispatch => {
|
|
107
|
-
const {
|
|
108
|
-
createNotice
|
|
109
|
-
} = dispatch(noticesStore);
|
|
110
|
-
return {
|
|
111
|
-
createNotice
|
|
112
|
-
};
|
|
113
|
-
})(AdminNotices);
|
|
114
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/admin-notices/index.js"],"names":["Component","withDispatch","store","noticesStore","NOTICE_CLASS_STATUSES","updated","error","getAdminNotices","Array","from","document","querySelectorAll","reverse","getNoticeHTML","element","fragments","child","childNodes","nodeType","ELEMENT_NODE","value","nodeValue","trim","push","classList","contains","outerHTML","join","getNoticeStatus","className","hasOwnProperty","AdminNotices","componentDidMount","convertNotices","createNotice","props","forEach","status","content","isDismissible","speak","__unstableHTML","parentNode","removeChild","render","dispatch"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { withDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Mapping of server-supported notice class names to an equivalent notices\n * module status.\n *\n * @type {Map}\n */\nconst NOTICE_CLASS_STATUSES = {\n\t'notice-success': 'success',\n\tupdated: 'success',\n\t'notice-warning': 'warning',\n\t'notice-error': 'error',\n\terror: 'error',\n\t'notice-info': 'info',\n};\n\n/**\n * Returns an array of admin notice Elements.\n *\n * @return {Element[]} Admin notice elements.\n */\nfunction getAdminNotices() {\n\t// The order is reversed to match expectations of rendered order, since a\n\t// NoticesList is itself rendered in reverse order (newest to oldest).\n\treturn Array.from(\n\t\tdocument.querySelectorAll( '#wpbody-content > .notice' )\n\t).reverse();\n}\n\n/**\n * Given an admin notice Element, returns the relevant notice content HTML.\n *\n * @param {Element} element Admin notice element.\n *\n * @return {Element} Upgraded notice HTML.\n */\nfunction getNoticeHTML( element ) {\n\tconst fragments = [];\n\n\tfor ( const child of element.childNodes ) {\n\t\tif ( child.nodeType !== child.ELEMENT_NODE ) {\n\t\t\tconst value = child.nodeValue.trim();\n\t\t\tif ( value ) {\n\t\t\t\tfragments.push( child.nodeValue );\n\t\t\t}\n\t\t} else if ( ! child.classList.contains( 'notice-dismiss' ) ) {\n\t\t\tfragments.push( child.outerHTML );\n\t\t}\n\t}\n\n\treturn fragments.join( '' );\n}\n\n/**\n * Given an admin notice Element, returns the upgraded status type, or\n * undefined if one cannot be determined (i.e. one is not assigned).\n *\n * @param {Element} element Admin notice element.\n *\n * @return {?string} Upgraded status type.\n */\nfunction getNoticeStatus( element ) {\n\tfor ( const className of element.classList ) {\n\t\tif ( NOTICE_CLASS_STATUSES.hasOwnProperty( className ) ) {\n\t\t\treturn NOTICE_CLASS_STATUSES[ className ];\n\t\t}\n\t}\n}\n\nexport class AdminNotices extends Component {\n\tcomponentDidMount() {\n\t\tthis.convertNotices();\n\t}\n\n\tconvertNotices() {\n\t\tconst { createNotice } = this.props;\n\t\tgetAdminNotices().forEach( ( element ) => {\n\t\t\t// Convert and create.\n\t\t\tconst status = getNoticeStatus( element );\n\t\t\tconst content = getNoticeHTML( element );\n\t\t\tconst isDismissible = element.classList.contains(\n\t\t\t\t'is-dismissible'\n\t\t\t);\n\t\t\tcreateNotice( status, content, {\n\t\t\t\tspeak: false,\n\t\t\t\t__unstableHTML: true,\n\t\t\t\tisDismissible,\n\t\t\t} );\n\n\t\t\t// Remove (now-redundant) admin notice element.\n\t\t\telement.parentNode.removeChild( element );\n\t\t} );\n\t}\n\n\trender() {\n\t\treturn null;\n\t}\n}\n\nexport default withDispatch( ( dispatch ) => {\n\tconst { createNotice } = dispatch( noticesStore );\n\n\treturn { createNotice };\n} )( AdminNotices );\n"]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { useInstanceId } from '@wordpress/compose';
|
|
7
|
-
import { FormToggle } from '@wordpress/components';
|
|
8
|
-
import { __ } from '@wordpress/i18n';
|
|
9
|
-
export default function BlockManagerShowAll(_ref) {
|
|
10
|
-
let {
|
|
11
|
-
checked,
|
|
12
|
-
onChange
|
|
13
|
-
} = _ref;
|
|
14
|
-
const instanceId = useInstanceId(BlockManagerShowAll);
|
|
15
|
-
const id = 'edit-post-block-manager__show-all-' + instanceId;
|
|
16
|
-
return createElement("div", {
|
|
17
|
-
className: "edit-post-block-manager__show-all"
|
|
18
|
-
}, createElement("label", {
|
|
19
|
-
htmlFor: id,
|
|
20
|
-
className: "edit-post-block-manager__show-all-label"
|
|
21
|
-
},
|
|
22
|
-
/* translators: Checkbox toggle label */
|
|
23
|
-
__('Show section')), createElement(FormToggle, {
|
|
24
|
-
id: id,
|
|
25
|
-
checked: checked,
|
|
26
|
-
onChange: event => onChange(event.target.checked)
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=show-all.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/block-manager/show-all.js"],"names":["useInstanceId","FormToggle","__","BlockManagerShowAll","checked","onChange","instanceId","id","event","target"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,oBAA9B;AACA,SAASC,UAAT,QAA2B,uBAA3B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA,eAAe,SAASC,mBAAT,OAAsD;AAAA,MAAxB;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,GAAwB;AACpE,QAAMC,UAAU,GAAGN,aAAa,CAAEG,mBAAF,CAAhC;AACA,QAAMI,EAAE,GAAG,uCAAuCD,UAAlD;AAEA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AACC,IAAA,OAAO,EAAGC,EADX;AAEC,IAAA,SAAS,EAAC;AAFX;AAKE;AACAL,EAAAA,EAAE,CAAE,cAAF,CANJ,CADD,EAUC,cAAC,UAAD;AACC,IAAA,EAAE,EAAGK,EADN;AAEC,IAAA,OAAO,EAAGH,OAFX;AAGC,IAAA,QAAQ,EAAKI,KAAF,IAAaH,QAAQ,CAAEG,KAAK,CAACC,MAAN,CAAaL,OAAf;AAHjC,IAVD,CADD;AAkBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { FormToggle } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nexport default function BlockManagerShowAll( { checked, onChange } ) {\n\tconst instanceId = useInstanceId( BlockManagerShowAll );\n\tconst id = 'edit-post-block-manager__show-all-' + instanceId;\n\n\treturn (\n\t\t<div className=\"edit-post-block-manager__show-all\">\n\t\t\t<label\n\t\t\t\thtmlFor={ id }\n\t\t\t\tclassName=\"edit-post-block-manager__show-all-label\"\n\t\t\t>\n\t\t\t\t{\n\t\t\t\t\t/* translators: Checkbox toggle label */\n\t\t\t\t\t__( 'Show section' )\n\t\t\t\t}\n\t\t\t</label>\n\t\t\t<FormToggle\n\t\t\t\tid={ id }\n\t\t\t\tchecked={ checked }\n\t\t\t\tonChange={ ( event ) => onChange( event.target.checked ) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
|