@wordpress/edit-post 7.12.0 → 7.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/block-manager/index.js +20 -4
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/device-preview/index.js +2 -4
- package/build/components/device-preview/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.js +2 -2
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/index.js +29 -35
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/plugin-sidebar-more-menu-item/index.js +4 -7
- package/build/components/header/plugin-sidebar-more-menu-item/index.js.map +1 -1
- package/build/components/header/writing-menu/index.js +0 -8
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +2 -1
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -3
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/preferences-modal/meta-boxes-section.js +2 -1
- package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build/components/preferences-modal/options/enable-custom-fields.js +1 -1
- package/build/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +4 -8
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js +4 -7
- package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build/components/sidebar/post-status/index.js +1 -1
- package/build/components/sidebar/post-status/index.js.map +1 -1
- package/build/components/visual-editor/index.js +19 -11
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/editor.js +30 -9
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +4 -5
- package/build/editor.native.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +122 -0
- package/build/hooks/commands/use-common-commands.js.map +1 -0
- package/build/hooks/validate-multiple-use/index.js +6 -8
- package/build/hooks/validate-multiple-use/index.js.map +1 -1
- package/build/index.js +18 -2
- package/build/index.js.map +1 -1
- package/build/{private-apis.js → lock-unlock.js} +1 -1
- package/build/lock-unlock.js.map +1 -0
- package/build/plugins/index.js +1 -1
- package/build/plugins/index.js.map +1 -1
- package/build-module/components/block-manager/index.js +23 -7
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/device-preview/index.js +2 -4
- package/build-module/components/device-preview/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.js +1 -1
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/index.js +28 -35
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/plugin-sidebar-more-menu-item/index.js +4 -4
- package/build-module/components/header/plugin-sidebar-more-menu-item/index.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js +0 -8
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +2 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -3
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/preferences-modal/meta-boxes-section.js +2 -1
- package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-custom-fields.js +1 -1
- package/build-module/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +4 -5
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js +4 -4
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/post-status/index.js +2 -2
- package/build-module/components/sidebar/post-status/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +14 -7
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/editor.js +26 -6
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +4 -4
- package/build-module/editor.native.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +108 -0
- package/build-module/hooks/commands/use-common-commands.js.map +1 -0
- package/build-module/hooks/validate-multiple-use/index.js +6 -5
- package/build-module/hooks/validate-multiple-use/index.js.map +1 -1
- package/build-module/index.js +18 -2
- package/build-module/index.js.map +1 -1
- package/build-module/{private-apis.js → lock-unlock.js} +1 -1
- package/build-module/lock-unlock.js.map +1 -0
- package/build-module/plugins/index.js +1 -1
- package/build-module/plugins/index.js.map +1 -1
- package/build-style/style-rtl.css +3 -1
- package/build-style/style.css +3 -1
- package/package.json +32 -32
- package/src/components/block-manager/index.js +51 -31
- package/src/components/block-manager/style.scss +3 -1
- package/src/components/device-preview/index.js +1 -2
- package/src/components/header/header-toolbar/index.js +1 -1
- package/src/components/header/index.js +11 -16
- package/src/components/header/writing-menu/index.js +0 -10
- package/src/components/keyboard-shortcuts/index.js +1 -3
- package/src/components/preferences-modal/options/enable-custom-fields.js +2 -2
- package/src/components/preferences-modal/options/test/__snapshots__/enable-custom-fields.js.snap +2 -2
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +11 -5
- package/src/components/sidebar/post-status/index.js +2 -1
- package/src/components/visual-editor/index.js +12 -11
- package/src/editor.js +24 -1
- package/src/hooks/commands/use-common-commands.js +103 -0
- package/src/index.js +30 -3
- package/src/plugins/index.js +1 -1
- package/src/test/editor.native.js +34 -9
- package/build/private-apis.js.map +0 -1
- package/build-module/private-apis.js.map +0 -1
- /package/src/{private-apis.js → lock-unlock.js} +0 -0
package/src/components/preferences-modal/options/test/__snapshots__/enable-custom-fields.js.snap
CHANGED
|
@@ -100,7 +100,7 @@ exports[`EnableCustomFieldsOption renders a checked checkbox and a confirmation
|
|
|
100
100
|
class="components-button edit-post-preferences-modal__custom-fields-confirmation-button is-secondary"
|
|
101
101
|
type="button"
|
|
102
102
|
>
|
|
103
|
-
|
|
103
|
+
Show & Reload Page
|
|
104
104
|
</button>
|
|
105
105
|
</div>
|
|
106
106
|
</div>
|
|
@@ -303,7 +303,7 @@ exports[`EnableCustomFieldsOption renders an unchecked checkbox and a confirmati
|
|
|
303
303
|
class="components-button edit-post-preferences-modal__custom-fields-confirmation-button is-secondary"
|
|
304
304
|
type="button"
|
|
305
305
|
>
|
|
306
|
-
|
|
306
|
+
Hide & Reload Page
|
|
307
307
|
</button>
|
|
308
308
|
</div>
|
|
309
309
|
</div>
|
|
@@ -607,15 +607,21 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
|
|
|
607
607
|
border-radius: 2px;
|
|
608
608
|
}
|
|
609
609
|
|
|
610
|
+
.emotion-13 svg,
|
|
611
|
+
.emotion-13 path {
|
|
612
|
+
fill: currentColor;
|
|
613
|
+
}
|
|
614
|
+
|
|
610
615
|
.emotion-13:hover {
|
|
611
616
|
color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
|
|
612
617
|
}
|
|
613
618
|
|
|
614
|
-
.emotion-13:focus {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
+
.emotion-13:focus-visible {
|
|
620
|
+
box-shadow: 0 0 0 var( --wp-admin-border-width-focus ) var(
|
|
621
|
+
--wp-components-color-accent,
|
|
622
|
+
var( --wp-admin-theme-color, var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9)) )
|
|
623
|
+
);
|
|
624
|
+
outline: 2px solid transparent;
|
|
619
625
|
}
|
|
620
626
|
|
|
621
627
|
.emotion-15 {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '@wordpress/components';
|
|
9
9
|
import { withSelect, withDispatch } from '@wordpress/data';
|
|
10
10
|
import { compose, ifCondition } from '@wordpress/compose';
|
|
11
|
-
import { PostSwitchToDraftButton } from '@wordpress/editor';
|
|
11
|
+
import { PostSwitchToDraftButton, PostSyncStatus } from '@wordpress/editor';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
@@ -51,6 +51,7 @@ function PostStatus( { isOpened, onTogglePanel } ) {
|
|
|
51
51
|
<PostFormat />
|
|
52
52
|
<PostSlug />
|
|
53
53
|
<PostAuthor />
|
|
54
|
+
<PostSyncStatus />
|
|
54
55
|
{ fills }
|
|
55
56
|
<HStack
|
|
56
57
|
style={ {
|
|
@@ -23,12 +23,10 @@ import {
|
|
|
23
23
|
__experimentalUseResizeCanvas as useResizeCanvas,
|
|
24
24
|
__unstableEditorStyles as EditorStyles,
|
|
25
25
|
useSetting,
|
|
26
|
-
__experimentalLayoutStyle as LayoutStyle,
|
|
27
26
|
__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,
|
|
28
27
|
__unstableIframe as Iframe,
|
|
29
28
|
__experimentalRecursionProvider as RecursionProvider,
|
|
30
|
-
|
|
31
|
-
__experimentaluseLayoutStyles as useLayoutStyles,
|
|
29
|
+
privateApis as blockEditorPrivateApis,
|
|
32
30
|
} from '@wordpress/block-editor';
|
|
33
31
|
import { useEffect, useRef, useMemo } from '@wordpress/element';
|
|
34
32
|
import { __unstableMotion as motion } from '@wordpress/components';
|
|
@@ -41,6 +39,11 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
41
39
|
* Internal dependencies
|
|
42
40
|
*/
|
|
43
41
|
import { store as editPostStore } from '../../store';
|
|
42
|
+
import { unlock } from '../../lock-unlock';
|
|
43
|
+
|
|
44
|
+
const { LayoutStyle, useLayoutClasses, useLayoutStyles } = unlock(
|
|
45
|
+
blockEditorPrivateApis
|
|
46
|
+
);
|
|
44
47
|
|
|
45
48
|
const isGutenbergPlugin = process.env.IS_GUTENBERG_PLUGIN ? true : false;
|
|
46
49
|
|
|
@@ -372,11 +375,12 @@ export default function VisualEditor( { styles } ) {
|
|
|
372
375
|
! isTemplateMode && (
|
|
373
376
|
<>
|
|
374
377
|
<LayoutStyle
|
|
375
|
-
selector=".edit-post-visual-editor__post-title-wrapper
|
|
378
|
+
selector=".edit-post-visual-editor__post-title-wrapper"
|
|
376
379
|
layout={ fallbackLayout }
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
+
/>
|
|
381
|
+
<LayoutStyle
|
|
382
|
+
selector=".block-editor-block-list__layout.is-root-container"
|
|
383
|
+
layout={ blockListLayout }
|
|
380
384
|
/>
|
|
381
385
|
{ align && (
|
|
382
386
|
<LayoutStyle css={ alignCSS } />
|
|
@@ -385,9 +389,6 @@ export default function VisualEditor( { styles } ) {
|
|
|
385
389
|
<LayoutStyle
|
|
386
390
|
layout={ postContentLayout }
|
|
387
391
|
css={ postContentLayoutStyles }
|
|
388
|
-
layoutDefinitions={
|
|
389
|
-
globalLayoutSettings?.definitions
|
|
390
|
-
}
|
|
391
392
|
/>
|
|
392
393
|
) }
|
|
393
394
|
</>
|
|
@@ -417,7 +418,7 @@ export default function VisualEditor( { styles } ) {
|
|
|
417
418
|
? 'wp-site-blocks'
|
|
418
419
|
: `${ blockListLayoutClass } wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.
|
|
419
420
|
}
|
|
420
|
-
|
|
421
|
+
layout={ blockListLayout }
|
|
421
422
|
/>
|
|
422
423
|
</RecursionProvider>
|
|
423
424
|
</MaybeIframe>
|
package/src/editor.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
store as editorStore,
|
|
10
10
|
privateApis as editorPrivateApis,
|
|
11
11
|
} from '@wordpress/editor';
|
|
12
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
12
13
|
import { useMemo } from '@wordpress/element';
|
|
13
14
|
import { SlotFillProvider } from '@wordpress/components';
|
|
14
15
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -23,13 +24,16 @@ import { privateApis as coreCommandsPrivateApis } from '@wordpress/core-commands
|
|
|
23
24
|
import Layout from './components/layout';
|
|
24
25
|
import EditorInitialization from './components/editor-initialization';
|
|
25
26
|
import { store as editPostStore } from './store';
|
|
26
|
-
import { unlock } from './
|
|
27
|
+
import { unlock } from './lock-unlock';
|
|
28
|
+
import useCommonCommands from './hooks/commands/use-common-commands';
|
|
27
29
|
|
|
28
30
|
const { ExperimentalEditorProvider } = unlock( editorPrivateApis );
|
|
31
|
+
const { getLayoutStyles } = unlock( blockEditorPrivateApis );
|
|
29
32
|
const { useCommands } = unlock( coreCommandsPrivateApis );
|
|
30
33
|
|
|
31
34
|
function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
32
35
|
useCommands();
|
|
36
|
+
useCommonCommands();
|
|
33
37
|
const {
|
|
34
38
|
hasFixedToolbar,
|
|
35
39
|
focusMode,
|
|
@@ -164,10 +168,29 @@ function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
|
164
168
|
presetStyles.push( style );
|
|
165
169
|
}
|
|
166
170
|
} );
|
|
171
|
+
|
|
167
172
|
const defaultEditorStyles = [
|
|
168
173
|
...settings.defaultEditorStyles,
|
|
169
174
|
...presetStyles,
|
|
170
175
|
];
|
|
176
|
+
|
|
177
|
+
// If theme styles are not present or displayed, ensure that
|
|
178
|
+
// base layout styles are still present in the editor.
|
|
179
|
+
if (
|
|
180
|
+
! settings.disableLayoutStyles &&
|
|
181
|
+
! ( hasThemeStyles && themeStyles.length )
|
|
182
|
+
) {
|
|
183
|
+
defaultEditorStyles.push( {
|
|
184
|
+
css: getLayoutStyles( {
|
|
185
|
+
style: {},
|
|
186
|
+
selector: 'body',
|
|
187
|
+
hasBlockGapSupport: false,
|
|
188
|
+
hasFallbackGapSupport: true,
|
|
189
|
+
fallbackGapValue: '0.5em',
|
|
190
|
+
} ),
|
|
191
|
+
} );
|
|
192
|
+
}
|
|
193
|
+
|
|
171
194
|
return hasThemeStyles && themeStyles.length
|
|
172
195
|
? settings.styles
|
|
173
196
|
: defaultEditorStyles;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import { __, isRTL } from '@wordpress/i18n';
|
|
6
|
+
import {
|
|
7
|
+
code,
|
|
8
|
+
cog,
|
|
9
|
+
drawerLeft,
|
|
10
|
+
drawerRight,
|
|
11
|
+
blockDefault,
|
|
12
|
+
} from '@wordpress/icons';
|
|
13
|
+
import { useCommand } from '@wordpress/commands';
|
|
14
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
15
|
+
import { store as interfaceStore } from '@wordpress/interface';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Internal dependencies
|
|
19
|
+
*/
|
|
20
|
+
import { store as editPostStore } from '../../store';
|
|
21
|
+
|
|
22
|
+
export default function useCommonCommands() {
|
|
23
|
+
const { openGeneralSidebar, closeGeneralSidebar, switchEditorMode } =
|
|
24
|
+
useDispatch( editPostStore );
|
|
25
|
+
const { editorMode, activeSidebar } = useSelect(
|
|
26
|
+
( select ) => ( {
|
|
27
|
+
activeSidebar: select( interfaceStore ).getActiveComplementaryArea(
|
|
28
|
+
editPostStore.name
|
|
29
|
+
),
|
|
30
|
+
editorMode: select( editPostStore ).getEditorMode(),
|
|
31
|
+
} ),
|
|
32
|
+
[]
|
|
33
|
+
);
|
|
34
|
+
const { toggle } = useDispatch( preferencesStore );
|
|
35
|
+
|
|
36
|
+
useCommand( {
|
|
37
|
+
name: 'core/open-settings-sidebar',
|
|
38
|
+
label: __( 'Toggle settings sidebar' ),
|
|
39
|
+
icon: isRTL() ? drawerLeft : drawerRight,
|
|
40
|
+
callback: ( { close } ) => {
|
|
41
|
+
close();
|
|
42
|
+
if ( activeSidebar === 'edit-post/document' ) {
|
|
43
|
+
closeGeneralSidebar();
|
|
44
|
+
} else {
|
|
45
|
+
openGeneralSidebar( 'edit-post/document' );
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
} );
|
|
49
|
+
|
|
50
|
+
useCommand( {
|
|
51
|
+
name: 'core/open-block-inspector',
|
|
52
|
+
label: __( 'Toggle block inspector' ),
|
|
53
|
+
icon: blockDefault,
|
|
54
|
+
callback: ( { close } ) => {
|
|
55
|
+
close();
|
|
56
|
+
if ( activeSidebar === 'edit-post/block' ) {
|
|
57
|
+
closeGeneralSidebar();
|
|
58
|
+
} else {
|
|
59
|
+
openGeneralSidebar( 'edit-post/block' );
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
} );
|
|
63
|
+
|
|
64
|
+
useCommand( {
|
|
65
|
+
name: 'core/toggle-distraction-free',
|
|
66
|
+
label: __( 'Toggle distraction free' ),
|
|
67
|
+
icon: cog,
|
|
68
|
+
callback: ( { close } ) => {
|
|
69
|
+
toggle( 'core/edit-post', 'distractionFree' );
|
|
70
|
+
close();
|
|
71
|
+
},
|
|
72
|
+
} );
|
|
73
|
+
|
|
74
|
+
useCommand( {
|
|
75
|
+
name: 'core/toggle-spotlight-mode',
|
|
76
|
+
label: __( 'Toggle spotlight mode' ),
|
|
77
|
+
icon: cog,
|
|
78
|
+
callback: ( { close } ) => {
|
|
79
|
+
toggle( 'core/edit-post', 'focusMode' );
|
|
80
|
+
close();
|
|
81
|
+
},
|
|
82
|
+
} );
|
|
83
|
+
|
|
84
|
+
useCommand( {
|
|
85
|
+
name: 'core/toggle-top-toolbar',
|
|
86
|
+
label: __( 'Toggle top toolbar' ),
|
|
87
|
+
icon: cog,
|
|
88
|
+
callback: ( { close } ) => {
|
|
89
|
+
toggle( 'core/edit-post', 'fixedToolbar' );
|
|
90
|
+
close();
|
|
91
|
+
},
|
|
92
|
+
} );
|
|
93
|
+
|
|
94
|
+
useCommand( {
|
|
95
|
+
name: 'core/toggle-code-editor',
|
|
96
|
+
label: __( 'Toggle code editor' ),
|
|
97
|
+
icon: code,
|
|
98
|
+
callback: ( { close } ) => {
|
|
99
|
+
switchEditorMode( editorMode === 'visual' ? 'text' : 'visual' );
|
|
100
|
+
close();
|
|
101
|
+
},
|
|
102
|
+
} );
|
|
103
|
+
}
|
package/src/index.js
CHANGED
|
@@ -79,7 +79,7 @@ export function initializeEditor(
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/*
|
|
82
|
-
* Prevent adding template part
|
|
82
|
+
* Prevent adding template part in the post editor.
|
|
83
83
|
* Only add the filter when the post editor is initialized, not imported.
|
|
84
84
|
* Also only add the filter(s) after registerCoreBlocks()
|
|
85
85
|
* so that common filters in the block library are not overwritten.
|
|
@@ -90,8 +90,7 @@ export function initializeEditor(
|
|
|
90
90
|
( canInsert, blockType ) => {
|
|
91
91
|
if (
|
|
92
92
|
! select( editPostStore ).isEditingTemplate() &&
|
|
93
|
-
|
|
94
|
-
blockType.name === 'core/post-content' )
|
|
93
|
+
blockType.name === 'core/template-part'
|
|
95
94
|
) {
|
|
96
95
|
return false;
|
|
97
96
|
}
|
|
@@ -99,6 +98,34 @@ export function initializeEditor(
|
|
|
99
98
|
}
|
|
100
99
|
);
|
|
101
100
|
|
|
101
|
+
/*
|
|
102
|
+
* Prevent adding post content block (except in query block) in the post editor.
|
|
103
|
+
* Only add the filter when the post editor is initialized, not imported.
|
|
104
|
+
* Also only add the filter(s) after registerCoreBlocks()
|
|
105
|
+
* so that common filters in the block library are not overwritten.
|
|
106
|
+
*/
|
|
107
|
+
addFilter(
|
|
108
|
+
'blockEditor.__unstableCanInsertBlockType',
|
|
109
|
+
'removePostContentFromInserter',
|
|
110
|
+
(
|
|
111
|
+
canInsert,
|
|
112
|
+
blockType,
|
|
113
|
+
rootClientId,
|
|
114
|
+
{ getBlockParentsByBlockName }
|
|
115
|
+
) => {
|
|
116
|
+
if (
|
|
117
|
+
! select( editPostStore ).isEditingTemplate() &&
|
|
118
|
+
blockType.name === 'core/post-content'
|
|
119
|
+
) {
|
|
120
|
+
return (
|
|
121
|
+
getBlockParentsByBlockName( rootClientId, 'core/query' )
|
|
122
|
+
.length > 0
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
return canInsert;
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
|
|
102
129
|
// Show a console log warning if the browser is not in Standards rendering mode.
|
|
103
130
|
const documentMode =
|
|
104
131
|
document.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';
|
package/src/plugins/index.js
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
act,
|
|
6
|
+
addBlock,
|
|
7
|
+
fireEvent,
|
|
8
|
+
getBlock,
|
|
9
|
+
initializeEditor,
|
|
10
|
+
render,
|
|
11
|
+
setupCoreBlocks,
|
|
12
|
+
} from 'test/helpers';
|
|
5
13
|
|
|
6
14
|
/**
|
|
7
15
|
* WordPress dependencies
|
|
8
16
|
*/
|
|
9
|
-
import {
|
|
10
|
-
|
|
17
|
+
import RNReactNativeGutenbergBridge, {
|
|
18
|
+
subscribeParentToggleHTMLMode,
|
|
19
|
+
} from '@wordpress/react-native-bridge';
|
|
11
20
|
// Force register 'core/editor' store.
|
|
12
21
|
import { store } from '@wordpress/editor'; // eslint-disable-line no-unused-vars
|
|
13
22
|
|
|
14
|
-
jest.mock( '../components/layout', () => () => 'Layout' );
|
|
15
|
-
|
|
16
23
|
/**
|
|
17
24
|
* Internal dependencies
|
|
18
25
|
*/
|
|
@@ -34,11 +41,9 @@ afterAll( () => {
|
|
|
34
41
|
jest.useRealTimers();
|
|
35
42
|
} );
|
|
36
43
|
|
|
37
|
-
|
|
38
|
-
beforeAll( () => {
|
|
39
|
-
registerCoreBlocks();
|
|
40
|
-
} );
|
|
44
|
+
setupCoreBlocks();
|
|
41
45
|
|
|
46
|
+
describe( 'Editor', () => {
|
|
42
47
|
it( 'detects unsupported block and sends hasUnsupportedBlocks true to native', () => {
|
|
43
48
|
RNReactNativeGutenbergBridge.editorDidMount = jest.fn();
|
|
44
49
|
|
|
@@ -56,6 +61,26 @@ describe( 'Editor', () => {
|
|
|
56
61
|
RNReactNativeGutenbergBridge.editorDidMount
|
|
57
62
|
).toHaveBeenCalledWith( [ 'core/notablock' ] );
|
|
58
63
|
} );
|
|
64
|
+
|
|
65
|
+
it( 'toggles the editor from Visual to HTML mode', async () => {
|
|
66
|
+
// Arrange
|
|
67
|
+
let toggleMode;
|
|
68
|
+
subscribeParentToggleHTMLMode.mockImplementation( ( callback ) => {
|
|
69
|
+
toggleMode = callback;
|
|
70
|
+
} );
|
|
71
|
+
const screen = await initializeEditor();
|
|
72
|
+
await addBlock( screen, 'Paragraph' );
|
|
73
|
+
|
|
74
|
+
// Act
|
|
75
|
+
const paragraphBlock = getBlock( screen, 'Paragraph' );
|
|
76
|
+
fireEvent.press( paragraphBlock );
|
|
77
|
+
|
|
78
|
+
toggleMode();
|
|
79
|
+
|
|
80
|
+
// Assert
|
|
81
|
+
const htmlEditor = await screen.findByLabelText( 'html-view-content' );
|
|
82
|
+
expect( htmlEditor ).toBeVisible();
|
|
83
|
+
} );
|
|
59
84
|
} );
|
|
60
85
|
|
|
61
86
|
// Utilities.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/private-apis.js"],"names":["lock","unlock"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAM;AAAEA,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZ,mEACC,8GADD,EAEC,sBAFD,CADM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\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/edit-post'\n\t);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/private-apis.js"],"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAT,QAAiE,yBAAjE;AAEA,OAAO,MAAM;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZF,gDAAgD,CAC/C,8GAD+C,EAE/C,sBAF+C,CAD1C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\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/edit-post'\n\t);\n"]}
|
|
File without changes
|