@wordpress/editor 14.48.0 → 14.48.1
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 +25 -1
- package/build/components/block-removal-warnings/index.cjs +0 -3
- package/build/components/block-removal-warnings/index.cjs.map +2 -2
- package/build/components/collab-sidebar/note-indicator-toolbar.cjs +49 -43
- package/build/components/collab-sidebar/note-indicator-toolbar.cjs.map +3 -3
- package/build/components/collaborators-overlay/use-block-highlighting.cjs +1 -8
- package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +3 -3
- package/build/components/collaborators-overlay/use-render-cursors.cjs +1 -7
- package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
- package/build/components/more-menu/view-more-menu-group.cjs +1 -2
- package/build/components/more-menu/view-more-menu-group.cjs.map +2 -2
- package/build/components/page-attributes/parent.cjs +1 -0
- package/build/components/page-attributes/parent.cjs.map +2 -2
- package/build/components/post-publish-button/index.cjs +114 -157
- package/build/components/post-publish-button/index.cjs.map +3 -3
- package/build/components/post-revisions-preview/block-diff.cjs +21 -9
- package/build/components/post-revisions-preview/block-diff.cjs.map +2 -2
- package/build/components/post-revisions-preview/preserve-client-ids.cjs +2 -2
- package/build/components/post-revisions-preview/preserve-client-ids.cjs.map +2 -2
- package/build/components/provider/index.cjs +2 -0
- package/build/components/provider/index.cjs.map +3 -3
- package/build/components/provider/use-network-reconnect.cjs +51 -0
- package/build/components/provider/use-network-reconnect.cjs.map +7 -0
- package/build/components/revision-fields-diff/index.cjs +2 -2
- package/build/components/revision-fields-diff/index.cjs.map +2 -2
- package/build/components/sidebar/index.cjs +1 -4
- package/build/components/sidebar/index.cjs.map +2 -2
- package/build/components/template-actions-panel/block-theme-content.cjs +7 -1
- package/build/components/template-actions-panel/block-theme-content.cjs.map +2 -2
- package/build/components/upload-progress-snackbar/index.cjs +161 -0
- package/build/components/upload-progress-snackbar/index.cjs.map +7 -0
- package/build/components/upload-progress-snackbar/tracker.cjs +90 -0
- package/build/components/upload-progress-snackbar/tracker.cjs.map +7 -0
- package/build/private-apis.cjs +2 -0
- package/build/private-apis.cjs.map +3 -3
- package/build/store/selectors.cjs +1 -2
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/media-upload/index.cjs +16 -0
- package/build/utils/media-upload/index.cjs.map +3 -3
- package/build-module/components/block-removal-warnings/index.mjs +0 -3
- package/build-module/components/block-removal-warnings/index.mjs.map +2 -2
- package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs +53 -44
- package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +1 -8
- package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs +1 -7
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
- package/build-module/components/more-menu/view-more-menu-group.mjs +1 -2
- package/build-module/components/more-menu/view-more-menu-group.mjs.map +2 -2
- package/build-module/components/page-attributes/parent.mjs +1 -0
- package/build-module/components/page-attributes/parent.mjs.map +2 -2
- package/build-module/components/post-publish-button/index.mjs +116 -159
- package/build-module/components/post-publish-button/index.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/block-diff.mjs +20 -8
- package/build-module/components/post-revisions-preview/block-diff.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/preserve-client-ids.mjs +1 -1
- package/build-module/components/post-revisions-preview/preserve-client-ids.mjs.map +1 -1
- package/build-module/components/provider/index.mjs +2 -0
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-network-reconnect.mjs +30 -0
- package/build-module/components/provider/use-network-reconnect.mjs.map +7 -0
- package/build-module/components/revision-fields-diff/index.mjs +2 -2
- package/build-module/components/revision-fields-diff/index.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs +2 -11
- package/build-module/components/sidebar/index.mjs.map +2 -2
- package/build-module/components/template-actions-panel/block-theme-content.mjs +7 -1
- package/build-module/components/template-actions-panel/block-theme-content.mjs.map +2 -2
- package/build-module/components/upload-progress-snackbar/index.mjs +135 -0
- package/build-module/components/upload-progress-snackbar/index.mjs.map +7 -0
- package/build-module/components/upload-progress-snackbar/tracker.mjs +61 -0
- package/build-module/components/upload-progress-snackbar/tracker.mjs.map +7 -0
- package/build-module/private-apis.mjs +2 -0
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/selectors.mjs +1 -2
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/media-upload/index.mjs +19 -0
- package/build-module/utils/media-upload/index.mjs.map +2 -2
- package/build-style/style-rtl.css +454 -81
- package/build-style/style.css +454 -81
- package/build-types/components/block-removal-warnings/index.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/add-comment.d.ts +6 -0
- package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/comment-author-info.d.ts +8 -0
- package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/comment-form.d.ts +9 -0
- package/build-types/components/collab-sidebar/comment-form.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts +6 -0
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/comment-menu-item.d.ts +6 -0
- package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/comments.d.ts +10 -0
- package/build-types/components/collab-sidebar/comments.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts +0 -3
- package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
- package/build-types/components/document-bar/index.d.ts +2 -2
- package/build-types/components/document-bar/index.d.ts.map +1 -1
- package/build-types/components/global-styles-provider/index.d.ts +16 -0
- package/build-types/components/global-styles-provider/index.d.ts.map +1 -0
- package/build-types/components/media/index.d.ts +3 -0
- package/build-types/components/media/index.d.ts.map +1 -0
- package/build-types/components/media/metadata-panel.d.ts +12 -0
- package/build-types/components/media/metadata-panel.d.ts.map +1 -0
- package/build-types/components/media/preview.d.ts +9 -0
- package/build-types/components/media/preview.d.ts.map +1 -0
- package/build-types/components/more-menu/view-more-menu-group.d.ts.map +1 -1
- package/build-types/components/page-attributes/parent.d.ts.map +1 -1
- package/build-types/components/post-publish-button/index.d.ts +9 -9
- package/build-types/components/post-publish-button/index.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/block-diff.d.ts +3 -0
- package/build-types/components/post-revisions-preview/block-diff.d.ts.map +1 -1
- package/build-types/components/post-text-editor/index.d.ts +1 -1
- package/build-types/components/post-text-editor/index.d.ts.map +1 -1
- package/build-types/components/post-text-editor/utils.d.ts +29 -0
- package/build-types/components/post-text-editor/utils.d.ts.map +1 -0
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/provider/use-network-reconnect.d.ts +8 -0
- package/build-types/components/provider/use-network-reconnect.d.ts.map +1 -0
- package/build-types/components/revision-fields-diff/index.d.ts +3 -0
- package/build-types/components/revision-fields-diff/index.d.ts.map +1 -1
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -1
- package/build-types/components/upload-progress-snackbar/index.d.ts +19 -0
- package/build-types/components/upload-progress-snackbar/index.d.ts.map +1 -0
- package/build-types/components/upload-progress-snackbar/stories/index.story.d.ts +28 -0
- package/build-types/components/upload-progress-snackbar/stories/index.story.d.ts.map +1 -0
- package/build-types/components/upload-progress-snackbar/tracker.d.ts +41 -0
- package/build-types/components/upload-progress-snackbar/tracker.d.ts.map +1 -0
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
- package/build-types/utils/media-upload/index.d.ts.map +1 -1
- package/package.json +53 -50
- package/src/components/README.md +1 -1
- package/src/components/block-removal-warnings/index.js +0 -7
- package/src/components/collab-sidebar/note-indicator-toolbar.js +73 -60
- package/src/components/collaborators-overlay/use-block-highlighting.ts +0 -9
- package/src/components/collaborators-overlay/use-render-cursors.ts +0 -8
- package/src/components/collaborators-presence/avatar/test/index.tsx +8 -3
- package/src/components/more-menu/view-more-menu-group.js +1 -2
- package/src/components/page-attributes/parent.js +1 -0
- package/src/components/post-publish-button/index.js +143 -192
- package/src/components/post-publish-button/test/index.js +137 -114
- package/src/components/post-revisions-preview/block-diff.js +63 -19
- package/src/components/post-revisions-preview/preserve-client-ids.js +1 -1
- package/src/components/post-revisions-preview/test/block-diff.js +109 -6
- package/src/components/provider/index.js +4 -0
- package/src/components/provider/test/use-network-reconnect.js +137 -0
- package/src/components/provider/use-network-reconnect.js +44 -0
- package/src/components/revision-fields-diff/index.js +7 -2
- package/src/components/sidebar/index.js +2 -11
- package/src/components/template-actions-panel/block-theme-content.js +10 -1
- package/src/components/upload-progress-snackbar/README.md +26 -0
- package/src/components/upload-progress-snackbar/index.js +216 -0
- package/src/components/upload-progress-snackbar/stories/index.story.tsx +85 -0
- package/src/components/upload-progress-snackbar/style.scss +30 -0
- package/src/components/upload-progress-snackbar/test/index.js +199 -0
- package/src/components/upload-progress-snackbar/tracker.js +105 -0
- package/src/private-apis.js +2 -0
- package/src/store/selectors.js +1 -3
- package/src/style.scss +1 -0
- package/src/utils/media-upload/index.js +27 -0
- package/src/components/commands/index.native.js +0 -2
- package/src/components/deprecated.native.js +0 -47
- package/src/components/editor-help/add-blocks.native.js +0 -40
- package/src/components/editor-help/customize-blocks.native.js +0 -40
- package/src/components/editor-help/help-detail-navigation-screen.native.js +0 -67
- package/src/components/editor-help/help-get-support-button.native.js +0 -38
- package/src/components/editor-help/help-section-title.native.js +0 -29
- package/src/components/editor-help/help-topic-row.native.js +0 -33
- package/src/components/editor-help/icon-move-blocks.native.js +0 -10
- package/src/components/editor-help/index.native.js +0 -208
- package/src/components/editor-help/intro-to-blocks.native.js +0 -91
- package/src/components/editor-help/move-blocks.native.js +0 -55
- package/src/components/editor-help/remove-blocks.native.js +0 -35
- package/src/components/editor-help/style.android.scss +0 -6
- package/src/components/editor-help/style.ios.scss +0 -6
- package/src/components/editor-help/test/index.native.js +0 -81
- package/src/components/editor-help/view-sections.native.js +0 -79
- package/src/components/error-boundary/index.native.js +0 -192
- package/src/components/error-boundary/style.native.scss +0 -116
- package/src/components/index.native.js +0 -15
- package/src/components/offline-status/index.native.js +0 -99
- package/src/components/offline-status/style.native.scss +0 -28
- package/src/components/offline-status/test/index.native.js +0 -108
- package/src/components/post-title/index.native.js +0 -282
- package/src/components/post-title/style.native.scss +0 -13
- package/src/components/post-title/test/__snapshots__/index.native.js.snap +0 -25
- package/src/components/post-title/test/index.native.js +0 -78
- package/src/components/provider/index.native.js +0 -497
- package/src/components/provider/use-block-editor-settings.native.js +0 -48
- package/src/components/template-part-menu-items/index.native.js +0 -3
- package/src/hooks/index.native.js +0 -0
- package/src/index.native.js +0 -16
- package/src/private-apis.native.js +0 -33
- package/src/store/actions.native.js +0 -27
- package/src/store/reducer.native.js +0 -94
- package/src/store/selectors.native.js +0 -57
- package/src/store/test/actions.native.js +0 -16
- package/src/store/test/reducer.native.js +0 -36
- package/src/store/test/selectors.native.js +0 -28
- package/src/utils/index.native.js +0 -6
- package/src/utils/media-sideload/index.native.js +0 -1
- package/src/utils/media-upload/index.native.js +0 -1
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { View } from 'react-native';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { Component } from '@wordpress/element';
|
|
10
|
-
import { create, toHTMLString, insert } from '@wordpress/rich-text';
|
|
11
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
12
|
-
import { withDispatch, withSelect } from '@wordpress/data';
|
|
13
|
-
import { withFocusOutside } from '@wordpress/components';
|
|
14
|
-
import { withInstanceId, compose } from '@wordpress/compose';
|
|
15
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
16
|
-
import { pasteHandler } from '@wordpress/blocks';
|
|
17
|
-
import { store as blockEditorStore, RichText } from '@wordpress/block-editor';
|
|
18
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
19
|
-
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
20
|
-
|
|
21
|
-
/** @typedef {import('./types').RichTextValue} RichTextValue */
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Internal dependencies
|
|
25
|
-
*/
|
|
26
|
-
import styles from './style.scss';
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Inserts content with title
|
|
30
|
-
*
|
|
31
|
-
* This function processes the given content and title, updating the title
|
|
32
|
-
* and content based on certain conditions. If the content is an array of
|
|
33
|
-
* blocks, it will check the first block for a heading or paragraph to use
|
|
34
|
-
* as the title. If the content is a string, it will strip HTML and update
|
|
35
|
-
* the title and content accordingly.
|
|
36
|
-
*
|
|
37
|
-
* @param {string} title The post title.
|
|
38
|
-
* @param {Array | string} content The content to be processed. It can be an array of blocks or a string.
|
|
39
|
-
* @param {Function} onUpdateTitle Callback function to update the title.
|
|
40
|
-
* @param {Function} onUpdateContent Callback function to update the content.
|
|
41
|
-
* @param {RichTextValue} value The initial value object, default is an object with empty text.
|
|
42
|
-
*/
|
|
43
|
-
export function insertContentWithTitle(
|
|
44
|
-
title,
|
|
45
|
-
content,
|
|
46
|
-
onUpdateTitle,
|
|
47
|
-
onUpdateContent,
|
|
48
|
-
value = create( { text: '' } )
|
|
49
|
-
) {
|
|
50
|
-
if ( ! content.length ) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if ( typeof content !== 'string' ) {
|
|
55
|
-
const [ firstBlock ] = content;
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
! title &&
|
|
59
|
-
( firstBlock.name === 'core/heading' ||
|
|
60
|
-
firstBlock.name === 'core/paragraph' )
|
|
61
|
-
) {
|
|
62
|
-
// Strip HTML to avoid unwanted HTML being added to the title.
|
|
63
|
-
// In the majority of cases it is assumed that HTML in the title
|
|
64
|
-
// is undesirable.
|
|
65
|
-
const contentNoHTML = stripHTML( firstBlock.attributes.content );
|
|
66
|
-
onUpdateTitle( contentNoHTML );
|
|
67
|
-
onUpdateContent( content.slice( 1 ) );
|
|
68
|
-
} else {
|
|
69
|
-
onUpdateContent( content );
|
|
70
|
-
}
|
|
71
|
-
} else {
|
|
72
|
-
// Strip HTML to avoid unwanted HTML being added to the title.
|
|
73
|
-
// In the majority of cases it is assumed that HTML in the title
|
|
74
|
-
// is undesirable.
|
|
75
|
-
const contentNoHTML = stripHTML( content );
|
|
76
|
-
|
|
77
|
-
const newValue = insert( value, create( { html: contentNoHTML } ) );
|
|
78
|
-
onUpdateTitle( toHTMLString( { value: newValue } ) );
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
class PostTitle extends Component {
|
|
83
|
-
constructor( props ) {
|
|
84
|
-
super( props );
|
|
85
|
-
|
|
86
|
-
this.setRef = this.setRef.bind( this );
|
|
87
|
-
this.onPaste = this.onPaste.bind( this );
|
|
88
|
-
}
|
|
89
|
-
componentDidUpdate( prevProps ) {
|
|
90
|
-
// Unselect if any other block is selected and blur the RichText.
|
|
91
|
-
if (
|
|
92
|
-
this.props.isSelected &&
|
|
93
|
-
! prevProps.isAnyBlockSelected &&
|
|
94
|
-
this.props.isAnyBlockSelected
|
|
95
|
-
) {
|
|
96
|
-
if ( this.richTextRef ) {
|
|
97
|
-
this.richTextRef.blur();
|
|
98
|
-
}
|
|
99
|
-
this.props.onUnselect();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
componentDidMount() {
|
|
104
|
-
if ( this.props.innerRef ) {
|
|
105
|
-
this.props.innerRef( this );
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
handleFocusOutside() {
|
|
110
|
-
this.props.onUnselect();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
focus() {
|
|
114
|
-
this.props.onSelect();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
onPaste( { value, plainText, html } ) {
|
|
118
|
-
const {
|
|
119
|
-
title,
|
|
120
|
-
onInsertBlockAfter: onInsertBlocks,
|
|
121
|
-
onUpdate,
|
|
122
|
-
} = this.props;
|
|
123
|
-
|
|
124
|
-
const content = pasteHandler( {
|
|
125
|
-
HTML: html,
|
|
126
|
-
plainText,
|
|
127
|
-
} );
|
|
128
|
-
|
|
129
|
-
insertContentWithTitle(
|
|
130
|
-
title,
|
|
131
|
-
content,
|
|
132
|
-
onUpdate,
|
|
133
|
-
onInsertBlocks,
|
|
134
|
-
value
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
setRef( richText ) {
|
|
139
|
-
this.richTextRef = richText;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
getTitle( title, postType ) {
|
|
143
|
-
if ( 'page' === postType ) {
|
|
144
|
-
return ! title
|
|
145
|
-
? /* translators: accessibility text. empty page title. */
|
|
146
|
-
__( 'Page title. Empty' )
|
|
147
|
-
: sprintf(
|
|
148
|
-
/* translators: accessibility text. %s: text content of the page title. */
|
|
149
|
-
__( 'Page title. %s' ),
|
|
150
|
-
title
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return ! title
|
|
155
|
-
? /* translators: accessibility text. empty post title. */
|
|
156
|
-
__( 'Post title. Empty' )
|
|
157
|
-
: sprintf(
|
|
158
|
-
/* translators: accessibility text. %s: text content of the post title. */
|
|
159
|
-
__( 'Post title. %s' ),
|
|
160
|
-
title
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
render() {
|
|
165
|
-
const {
|
|
166
|
-
placeholder,
|
|
167
|
-
style,
|
|
168
|
-
title,
|
|
169
|
-
focusedBorderColor,
|
|
170
|
-
borderStyle,
|
|
171
|
-
isDimmed,
|
|
172
|
-
postType,
|
|
173
|
-
globalStyles,
|
|
174
|
-
} = this.props;
|
|
175
|
-
|
|
176
|
-
const decodedPlaceholder = decodeEntities( placeholder );
|
|
177
|
-
const borderColor = this.props.isSelected
|
|
178
|
-
? focusedBorderColor
|
|
179
|
-
: 'transparent';
|
|
180
|
-
const titleStyles = {
|
|
181
|
-
...style,
|
|
182
|
-
...( globalStyles?.text && {
|
|
183
|
-
color: globalStyles.text,
|
|
184
|
-
placeholderColor: globalStyles.text,
|
|
185
|
-
} ),
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
return (
|
|
189
|
-
<View
|
|
190
|
-
testID="post-title"
|
|
191
|
-
style={ [
|
|
192
|
-
styles.titleContainer,
|
|
193
|
-
borderStyle,
|
|
194
|
-
{ borderColor },
|
|
195
|
-
isDimmed && styles.dimmed,
|
|
196
|
-
] }
|
|
197
|
-
accessible={ ! this.props.isSelected }
|
|
198
|
-
accessibilityLabel={ this.getTitle( title, postType ) }
|
|
199
|
-
accessibilityHint={ __( 'Updates the title.' ) }
|
|
200
|
-
>
|
|
201
|
-
<RichText.Raw
|
|
202
|
-
ref={ this.setRef }
|
|
203
|
-
accessibilityLabel={ this.getTitle( title, postType ) }
|
|
204
|
-
tagName="p"
|
|
205
|
-
tagsToEliminate={ [ 'strong' ] }
|
|
206
|
-
unstableOnFocus={ this.props.onSelect }
|
|
207
|
-
onBlur={ this.props.onBlur } // Always assign onBlur as a props.
|
|
208
|
-
style={ titleStyles }
|
|
209
|
-
styles={ styles }
|
|
210
|
-
fontSize={ 24 }
|
|
211
|
-
lineHeight={ 1 }
|
|
212
|
-
fontWeight="bold"
|
|
213
|
-
deleteEnter
|
|
214
|
-
onChange={ ( value ) => {
|
|
215
|
-
this.props.onUpdate( value );
|
|
216
|
-
} }
|
|
217
|
-
onPaste={ this.onPaste }
|
|
218
|
-
placeholder={ decodedPlaceholder }
|
|
219
|
-
value={ title }
|
|
220
|
-
onSelectionChange={ () => {} }
|
|
221
|
-
onEnter={ this.props.onEnterPress }
|
|
222
|
-
disableEditingMenu
|
|
223
|
-
__unstableIsSelected={ this.props.isSelected }
|
|
224
|
-
__unstableOnCreateUndoLevel={ () => {} }
|
|
225
|
-
/>
|
|
226
|
-
</View>
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
export default compose(
|
|
232
|
-
withSelect( ( select ) => {
|
|
233
|
-
const { isPostTitleSelected, getEditedPostAttribute } =
|
|
234
|
-
select( editorStore );
|
|
235
|
-
const { getSelectedBlockClientId, getBlockRootClientId, getSettings } =
|
|
236
|
-
select( blockEditorStore );
|
|
237
|
-
|
|
238
|
-
const selectedId = getSelectedBlockClientId();
|
|
239
|
-
const selectionIsNested = !! getBlockRootClientId( selectedId );
|
|
240
|
-
const globalStyles =
|
|
241
|
-
getSettings()?.__experimentalGlobalStylesBaseStyles?.color;
|
|
242
|
-
|
|
243
|
-
return {
|
|
244
|
-
postType: getEditedPostAttribute( 'type' ),
|
|
245
|
-
title: getEditedPostAttribute( 'title' ),
|
|
246
|
-
isAnyBlockSelected: !! selectedId,
|
|
247
|
-
isSelected: isPostTitleSelected(),
|
|
248
|
-
isDimmed: selectionIsNested,
|
|
249
|
-
globalStyles,
|
|
250
|
-
};
|
|
251
|
-
} ),
|
|
252
|
-
withDispatch( ( dispatch ) => {
|
|
253
|
-
const { undo, redo, togglePostTitleSelection, editPost } =
|
|
254
|
-
dispatch( editorStore );
|
|
255
|
-
|
|
256
|
-
const { clearSelectedBlock, insertDefaultBlock, insertBlocks } =
|
|
257
|
-
dispatch( blockEditorStore );
|
|
258
|
-
|
|
259
|
-
return {
|
|
260
|
-
onEnterPress() {
|
|
261
|
-
insertDefaultBlock( undefined, undefined, 0 );
|
|
262
|
-
},
|
|
263
|
-
onUndo: undo,
|
|
264
|
-
onRedo: redo,
|
|
265
|
-
onSelect() {
|
|
266
|
-
togglePostTitleSelection( true );
|
|
267
|
-
clearSelectedBlock();
|
|
268
|
-
},
|
|
269
|
-
onUnselect() {
|
|
270
|
-
togglePostTitleSelection( false );
|
|
271
|
-
},
|
|
272
|
-
onUpdate( title ) {
|
|
273
|
-
editPost( { title } );
|
|
274
|
-
},
|
|
275
|
-
onInsertBlockAfter( blocks ) {
|
|
276
|
-
insertBlocks( blocks, 0 );
|
|
277
|
-
},
|
|
278
|
-
};
|
|
279
|
-
} ),
|
|
280
|
-
withInstanceId,
|
|
281
|
-
withFocusOutside
|
|
282
|
-
)( PostTitle );
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`PostTitle does not update title with existing content when pasting HTML 1`] = `
|
|
4
|
-
"<!-- wp:heading -->
|
|
5
|
-
<h2 class="wp-block-heading">Howdy</h2>
|
|
6
|
-
<!-- /wp:heading -->
|
|
7
|
-
|
|
8
|
-
<!-- wp:heading -->
|
|
9
|
-
<h2 class="wp-block-heading">This is a heading.</h2>
|
|
10
|
-
<!-- /wp:heading -->
|
|
11
|
-
|
|
12
|
-
<!-- wp:paragraph -->
|
|
13
|
-
<p>This is a paragraph.</p>
|
|
14
|
-
<!-- /wp:paragraph -->"
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
exports[`PostTitle populates empty title with first block content when pasting HTML 1`] = `
|
|
18
|
-
"<!-- wp:heading -->
|
|
19
|
-
<h2 class="wp-block-heading">This is a heading.</h2>
|
|
20
|
-
<!-- /wp:heading -->
|
|
21
|
-
|
|
22
|
-
<!-- wp:paragraph -->
|
|
23
|
-
<p>This is a paragraph.</p>
|
|
24
|
-
<!-- /wp:paragraph -->"
|
|
25
|
-
`;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
getEditorHtml,
|
|
6
|
-
getEditorTitle,
|
|
7
|
-
initializeEditor,
|
|
8
|
-
pasteIntoRichText,
|
|
9
|
-
selectRangeInRichText,
|
|
10
|
-
screen,
|
|
11
|
-
setupCoreBlocks,
|
|
12
|
-
within,
|
|
13
|
-
} from 'test/helpers';
|
|
14
|
-
|
|
15
|
-
setupCoreBlocks();
|
|
16
|
-
|
|
17
|
-
const HTML_MULTIPLE_TAGS = `<h2>Howdy</h2>
|
|
18
|
-
<h2>This is a heading.</h2>
|
|
19
|
-
<p>This is a paragraph.</p>`;
|
|
20
|
-
|
|
21
|
-
describe( 'PostTitle', () => {
|
|
22
|
-
it( 'populates empty title with first block content when pasting HTML', async () => {
|
|
23
|
-
await initializeEditor( { initialTitle: '' } );
|
|
24
|
-
|
|
25
|
-
const postTitle = within(
|
|
26
|
-
screen.getByTestId( 'post-title' )
|
|
27
|
-
).getByPlaceholderText( 'Add title' );
|
|
28
|
-
pasteIntoRichText( postTitle, { html: HTML_MULTIPLE_TAGS } );
|
|
29
|
-
|
|
30
|
-
expect( console ).toHaveLogged();
|
|
31
|
-
expect( getEditorTitle() ).toBe( 'Howdy' );
|
|
32
|
-
expect( getEditorHtml() ).toMatchSnapshot();
|
|
33
|
-
} );
|
|
34
|
-
|
|
35
|
-
it( 'does not update title with existing content when pasting HTML', async () => {
|
|
36
|
-
const initialTitle = 'Hello';
|
|
37
|
-
await initializeEditor( { initialTitle } );
|
|
38
|
-
|
|
39
|
-
const postTitle = within(
|
|
40
|
-
screen.getByTestId( 'post-title' )
|
|
41
|
-
).getByPlaceholderText( 'Add title' );
|
|
42
|
-
selectRangeInRichText( postTitle, 0 );
|
|
43
|
-
pasteIntoRichText( postTitle, { html: HTML_MULTIPLE_TAGS } );
|
|
44
|
-
|
|
45
|
-
expect( console ).toHaveLogged();
|
|
46
|
-
expect( getEditorTitle() ).toBe( initialTitle );
|
|
47
|
-
expect( getEditorHtml() ).toMatchSnapshot();
|
|
48
|
-
} );
|
|
49
|
-
|
|
50
|
-
it( 'updates title with existing content when pasting text', async () => {
|
|
51
|
-
await initializeEditor( { initialTitle: 'World' } );
|
|
52
|
-
|
|
53
|
-
const postTitle = within(
|
|
54
|
-
screen.getByTestId( 'post-title' )
|
|
55
|
-
).getByPlaceholderText( 'Add title' );
|
|
56
|
-
selectRangeInRichText( postTitle, 0 );
|
|
57
|
-
pasteIntoRichText( postTitle, { text: 'Hello' } );
|
|
58
|
-
|
|
59
|
-
expect( console ).toHaveLogged();
|
|
60
|
-
expect( getEditorTitle() ).toBe( 'HelloWorld' );
|
|
61
|
-
expect( getEditorHtml() ).toBe( '' );
|
|
62
|
-
} );
|
|
63
|
-
|
|
64
|
-
it( 'does not add HTML to title when pasting span tag', async () => {
|
|
65
|
-
const pasteHTML = `<span style="border: 1px solid black">l</span>`;
|
|
66
|
-
await initializeEditor( { initialTitle: 'Helo' } );
|
|
67
|
-
|
|
68
|
-
const postTitle = within(
|
|
69
|
-
screen.getByTestId( 'post-title' )
|
|
70
|
-
).getByPlaceholderText( 'Add title' );
|
|
71
|
-
selectRangeInRichText( postTitle, 2 );
|
|
72
|
-
pasteIntoRichText( postTitle, { html: pasteHTML } );
|
|
73
|
-
|
|
74
|
-
expect( console ).toHaveLogged();
|
|
75
|
-
expect( getEditorTitle() ).toBe( 'Hello' );
|
|
76
|
-
expect( getEditorHtml() ).toBe( '' );
|
|
77
|
-
} );
|
|
78
|
-
} );
|