@wordpress/editor 13.23.0 → 13.24.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.
Files changed (112) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/entities-saved-states/index.js +15 -1
  3. package/build/components/entities-saved-states/index.js.map +1 -1
  4. package/build/components/index.js +26 -2
  5. package/build/components/index.js.map +1 -1
  6. package/build/components/post-author/panel.js +24 -0
  7. package/build/components/post-author/panel.js.map +1 -0
  8. package/build/components/post-panel-row/index.js +36 -0
  9. package/build/components/post-panel-row/index.js.map +1 -0
  10. package/build/components/post-saved-state/index.js +21 -16
  11. package/build/components/post-saved-state/index.js.map +1 -1
  12. package/build/components/post-schedule/panel.js +67 -0
  13. package/build/components/post-schedule/panel.js.map +1 -0
  14. package/build/components/post-sync-status/index.js +8 -4
  15. package/build/components/post-sync-status/index.js.map +1 -1
  16. package/build/components/post-title/constants.js +11 -0
  17. package/build/components/post-title/constants.js.map +1 -0
  18. package/build/components/post-title/index.js +61 -89
  19. package/build/components/post-title/index.js.map +1 -1
  20. package/build/components/post-title/post-title-raw.js +92 -0
  21. package/build/components/post-title/post-title-raw.js.map +1 -0
  22. package/build/components/post-title/use-post-title-focus.js +64 -0
  23. package/build/components/post-title/use-post-title-focus.js.map +1 -0
  24. package/build/components/post-title/use-post-title.js +41 -0
  25. package/build/components/post-title/use-post-title.js.map +1 -0
  26. package/build/components/post-url/panel.js +4 -3
  27. package/build/components/post-url/panel.js.map +1 -1
  28. package/build/components/provider/constants.js +9 -0
  29. package/build/components/provider/constants.js.map +1 -0
  30. package/build/components/provider/disable-non-page-content-blocks.js +63 -0
  31. package/build/components/provider/disable-non-page-content-blocks.js.map +1 -0
  32. package/build/components/provider/index.js +27 -9
  33. package/build/components/provider/index.js.map +1 -1
  34. package/build/private-apis.js +2 -0
  35. package/build/private-apis.js.map +1 -1
  36. package/build/store/actions.js +23 -2
  37. package/build/store/actions.js.map +1 -1
  38. package/build/store/reducer.js +10 -1
  39. package/build/store/reducer.js.map +1 -1
  40. package/build/store/selectors.js +16 -2
  41. package/build/store/selectors.js.map +1 -1
  42. package/build-module/components/entities-saved-states/index.js +16 -2
  43. package/build-module/components/entities-saved-states/index.js.map +1 -1
  44. package/build-module/components/index.js +3 -0
  45. package/build-module/components/index.js.map +1 -1
  46. package/build-module/components/post-author/panel.js +14 -0
  47. package/build-module/components/post-author/panel.js.map +1 -0
  48. package/build-module/components/post-panel-row/index.js +27 -0
  49. package/build-module/components/post-panel-row/index.js.map +1 -0
  50. package/build-module/components/post-saved-state/index.js +22 -17
  51. package/build-module/components/post-saved-state/index.js.map +1 -1
  52. package/build-module/components/post-schedule/panel.js +59 -0
  53. package/build-module/components/post-schedule/panel.js.map +1 -0
  54. package/build-module/components/post-sync-status/index.js +8 -5
  55. package/build-module/components/post-sync-status/index.js.map +1 -1
  56. package/build-module/components/post-title/constants.js +3 -0
  57. package/build-module/components/post-title/constants.js.map +1 -0
  58. package/build-module/components/post-title/index.js +62 -91
  59. package/build-module/components/post-title/index.js.map +1 -1
  60. package/build-module/components/post-title/post-title-raw.js +83 -0
  61. package/build-module/components/post-title/post-title-raw.js.map +1 -0
  62. package/build-module/components/post-title/use-post-title-focus.js +57 -0
  63. package/build-module/components/post-title/use-post-title-focus.js.map +1 -0
  64. package/build-module/components/post-title/use-post-title.js +33 -0
  65. package/build-module/components/post-title/use-post-title.js.map +1 -0
  66. package/build-module/components/post-url/panel.js +5 -4
  67. package/build-module/components/post-url/panel.js.map +1 -1
  68. package/build-module/components/provider/constants.js +2 -0
  69. package/build-module/components/provider/constants.js.map +1 -0
  70. package/build-module/components/provider/disable-non-page-content-blocks.js +56 -0
  71. package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -0
  72. package/build-module/components/provider/index.js +25 -6
  73. package/build-module/components/provider/index.js.map +1 -1
  74. package/build-module/private-apis.js +2 -0
  75. package/build-module/private-apis.js.map +1 -1
  76. package/build-module/store/actions.js +21 -0
  77. package/build-module/store/actions.js.map +1 -1
  78. package/build-module/store/reducer.js +9 -1
  79. package/build-module/store/reducer.js.map +1 -1
  80. package/build-module/store/selectors.js +11 -0
  81. package/build-module/store/selectors.js.map +1 -1
  82. package/build-style/style-rtl.css +51 -18
  83. package/build-style/style.css +51 -18
  84. package/package.json +31 -31
  85. package/src/components/entities-saved-states/index.js +16 -1
  86. package/src/components/index.js +3 -0
  87. package/src/components/post-author/panel.js +18 -0
  88. package/src/components/post-author/style.scss +7 -0
  89. package/src/components/post-panel-row/index.js +26 -0
  90. package/src/components/post-panel-row/style.scss +21 -0
  91. package/src/components/post-saved-state/index.js +46 -37
  92. package/src/components/post-schedule/panel.js +65 -0
  93. package/src/components/post-schedule/style.scss +23 -0
  94. package/src/components/post-sync-status/index.js +5 -6
  95. package/src/components/post-sync-status/style.scss +3 -17
  96. package/src/components/post-title/constants.js +4 -0
  97. package/src/components/post-title/index.js +56 -87
  98. package/src/components/post-title/post-title-raw.js +82 -0
  99. package/src/components/post-title/style.scss +5 -0
  100. package/src/components/post-title/use-post-title-focus.js +50 -0
  101. package/src/components/post-title/use-post-title.js +25 -0
  102. package/src/components/post-url/panel.js +4 -8
  103. package/src/components/post-url/style.scss +1 -12
  104. package/src/components/provider/README.md +0 -13
  105. package/src/components/provider/constants.js +5 -0
  106. package/src/components/provider/disable-non-page-content-blocks.js +55 -0
  107. package/src/components/provider/index.js +41 -14
  108. package/src/private-apis.js +2 -0
  109. package/src/store/actions.js +21 -0
  110. package/src/store/reducer.js +10 -0
  111. package/src/store/selectors.js +11 -0
  112. package/src/style.scss +4 -0
@@ -8,12 +8,12 @@ import classnames from 'classnames';
8
8
  * WordPress dependencies
9
9
  */
10
10
  import { __ } from '@wordpress/i18n';
11
- import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from '@wordpress/element';
11
+ import { forwardRef, useState } from '@wordpress/element';
12
12
  import { decodeEntities } from '@wordpress/html-entities';
13
- import { ENTER } from '@wordpress/keycodes';
14
13
  import { useSelect, useDispatch } from '@wordpress/data';
15
- import { pasteHandler } from '@wordpress/blocks';
16
14
  import { store as blockEditorStore } from '@wordpress/block-editor';
15
+ import { ENTER } from '@wordpress/keycodes';
16
+ import { pasteHandler } from '@wordpress/blocks';
17
17
  import { __unstableUseRichText as useRichText, create, toHTMLString, insert } from '@wordpress/rich-text';
18
18
  import { useMergeRefs } from '@wordpress/compose';
19
19
  import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
@@ -21,33 +21,18 @@ import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
21
21
  /**
22
22
  * Internal dependencies
23
23
  */
24
- import PostTypeSupportCheck from '../post-type-support-check';
25
24
  import { store as editorStore } from '../../store';
26
-
27
- /**
28
- * Constants
29
- */
30
- const REGEXP_NEWLINES = /[\r\n]+/g;
25
+ import { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';
26
+ import usePostTitleFocus from './use-post-title-focus';
27
+ import usePostTitle from './use-post-title';
28
+ import PostTypeSupportCheck from '../post-type-support-check';
31
29
  function PostTitle(_, forwardedRef) {
32
- const ref = useRef();
33
- const [isSelected, setIsSelected] = useState(false);
34
- const {
35
- editPost
36
- } = useDispatch(editorStore);
37
- const {
38
- insertDefaultBlock,
39
- clearSelectedBlock,
40
- insertBlocks
41
- } = useDispatch(blockEditorStore);
42
30
  const {
43
- isCleanNewPost,
44
- title,
45
31
  placeholder,
46
32
  hasFixedToolbar
47
33
  } = useSelect(select => {
48
34
  const {
49
- getEditedPostAttribute,
50
- isCleanNewPost: _isCleanNewPost
35
+ getEditedPostAttribute
51
36
  } = select(editorStore);
52
37
  const {
53
38
  getSettings
@@ -57,54 +42,31 @@ function PostTitle(_, forwardedRef) {
57
42
  hasFixedToolbar: _hasFixedToolbar
58
43
  } = getSettings();
59
44
  return {
60
- isCleanNewPost: _isCleanNewPost(),
61
45
  title: getEditedPostAttribute('title'),
62
46
  placeholder: titlePlaceholder,
63
47
  hasFixedToolbar: _hasFixedToolbar
64
48
  };
65
49
  }, []);
66
- useImperativeHandle(forwardedRef, () => ({
67
- focus: () => {
68
- ref?.current?.focus();
69
- }
70
- }));
71
- useEffect(() => {
72
- if (!ref.current) {
73
- return;
74
- }
75
- const {
76
- defaultView
77
- } = ref.current.ownerDocument;
78
- const {
79
- name,
80
- parent
81
- } = defaultView;
82
- const ownerDocument = name === 'editor-canvas' ? parent.document : defaultView.document;
83
- const {
84
- activeElement,
85
- body
86
- } = ownerDocument;
87
-
88
- // Only autofocus the title when the post is entirely empty. This should
89
- // only happen for a new post, which means we focus the title on new
90
- // post so the author can start typing right away, without needing to
91
- // click anything.
92
- if (isCleanNewPost && (!activeElement || body === activeElement)) {
93
- ref.current.focus();
94
- }
95
- }, [isCleanNewPost]);
96
- function onEnterPress() {
97
- insertDefaultBlock(undefined, undefined, 0);
50
+ const [isSelected, setIsSelected] = useState(false);
51
+ const {
52
+ ref: focusRef
53
+ } = usePostTitleFocus(forwardedRef);
54
+ const {
55
+ title,
56
+ setTitle: onUpdate
57
+ } = usePostTitle();
58
+ const [selection, setSelection] = useState({});
59
+ const {
60
+ clearSelectedBlock,
61
+ insertBlocks,
62
+ insertDefaultBlock
63
+ } = useDispatch(blockEditorStore);
64
+ function onChange(value) {
65
+ onUpdate(value.replace(REGEXP_NEWLINES, ' '));
98
66
  }
99
67
  function onInsertBlockAfter(blocks) {
100
68
  insertBlocks(blocks, 0);
101
69
  }
102
- function onUpdate(newTitle) {
103
- editPost({
104
- title: newTitle
105
- });
106
- }
107
- const [selection, setSelection] = useState({});
108
70
  function onSelect() {
109
71
  setIsSelected(true);
110
72
  clearSelectedBlock();
@@ -113,8 +75,8 @@ function PostTitle(_, forwardedRef) {
113
75
  setIsSelected(false);
114
76
  setSelection({});
115
77
  }
116
- function onChange(value) {
117
- onUpdate(value.replace(REGEXP_NEWLINES, ' '));
78
+ function onEnterPress() {
79
+ insertDefaultBlock(undefined, undefined, 0);
118
80
  }
119
81
  function onKeyDown(event) {
120
82
  if (event.keyCode === ENTER) {
@@ -158,7 +120,11 @@ function PostTitle(_, forwardedRef) {
158
120
  if (typeof content !== 'string') {
159
121
  const [firstBlock] = content;
160
122
  if (!title && (firstBlock.name === 'core/heading' || firstBlock.name === 'core/paragraph')) {
161
- onUpdate(stripHTML(firstBlock.attributes.content));
123
+ // Strip HTML to avoid unwanted HTML being added to the title.
124
+ // In the majority of cases it is assumed that HTML in the title
125
+ // is undesirable.
126
+ const contentNoHTML = stripHTML(firstBlock.attributes.content);
127
+ onUpdate(contentNoHTML);
162
128
  onInsertBlockAfter(content.slice(1));
163
129
  } else {
164
130
  onInsertBlockAfter(content);
@@ -170,8 +136,13 @@ function PostTitle(_, forwardedRef) {
170
136
  }),
171
137
  ...selection
172
138
  };
139
+
140
+ // Strip HTML to avoid unwanted HTML being added to the title.
141
+ // In the majority of cases it is assumed that HTML in the title
142
+ // is undesirable.
143
+ const contentNoHTML = stripHTML(content);
173
144
  const newValue = insert(value, create({
174
- html: stripHTML(content)
145
+ html: contentNoHTML
175
146
  }));
176
147
  onUpdate(toHTMLString({
177
148
  value: newValue
@@ -182,13 +153,6 @@ function PostTitle(_, forwardedRef) {
182
153
  });
183
154
  }
184
155
  }
185
-
186
- // The wp-block className is important for editor styles.
187
- // This same block is used in both the visual and the code editor.
188
- const className = classnames('wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text', {
189
- 'is-selected': isSelected,
190
- 'has-fixed-toolbar': hasFixedToolbar
191
- });
192
156
  const decodedPlaceholder = decodeEntities(placeholder) || __('Add title');
193
157
  const {
194
158
  ref: richTextRef
@@ -213,26 +177,33 @@ function PostTitle(_, forwardedRef) {
213
177
  };
214
178
  });
215
179
  },
216
- __unstableDisableFormats: true
180
+ __unstableDisableFormats: false
217
181
  });
218
182
 
219
- /* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
220
- return createElement(PostTypeSupportCheck, {
221
- supportKeys: "title"
222
- }, createElement("h1", {
223
- ref: useMergeRefs([richTextRef, ref]),
224
- contentEditable: true,
225
- className: className,
226
- "aria-label": decodedPlaceholder,
227
- role: "textbox",
228
- "aria-multiline": "true",
229
- onFocus: onSelect,
230
- onBlur: onUnselect,
231
- onKeyDown: onKeyDown,
232
- onKeyPress: onUnselect,
233
- onPaste: onPaste
234
- }));
235
- /* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
183
+ // The wp-block className is important for editor styles.
184
+ // This same block is used in both the visual and the code editor.
185
+ const className = classnames(DEFAULT_CLASSNAMES, {
186
+ 'is-selected': isSelected,
187
+ 'has-fixed-toolbar': hasFixedToolbar
188
+ });
189
+ return (/* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
190
+ createElement(PostTypeSupportCheck, {
191
+ supportKeys: "title"
192
+ }, createElement("h1", {
193
+ ref: useMergeRefs([richTextRef, focusRef]),
194
+ contentEditable: true,
195
+ className: className,
196
+ "aria-label": decodedPlaceholder,
197
+ role: "textbox",
198
+ "aria-multiline": "true",
199
+ onFocus: onSelect,
200
+ onBlur: onUnselect,
201
+ onKeyDown: onKeyDown,
202
+ onKeyPress: onUnselect,
203
+ onPaste: onPaste
204
+ }))
205
+ /* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
206
+ );
236
207
  }
237
208
 
238
209
  export default forwardRef(PostTitle);
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","__","forwardRef","useEffect","useImperativeHandle","useRef","useState","decodeEntities","ENTER","useSelect","useDispatch","pasteHandler","store","blockEditorStore","__unstableUseRichText","useRichText","create","toHTMLString","insert","useMergeRefs","__unstableStripHTML","stripHTML","PostTypeSupportCheck","editorStore","REGEXP_NEWLINES","PostTitle","_","forwardedRef","ref","isSelected","setIsSelected","editPost","insertDefaultBlock","clearSelectedBlock","insertBlocks","isCleanNewPost","title","placeholder","hasFixedToolbar","select","getEditedPostAttribute","_isCleanNewPost","getSettings","titlePlaceholder","_hasFixedToolbar","focus","current","defaultView","ownerDocument","name","parent","document","activeElement","body","onEnterPress","undefined","onInsertBlockAfter","blocks","onUpdate","newTitle","selection","setSelection","onSelect","onUnselect","onChange","value","replace","onKeyDown","event","keyCode","preventDefault","onPaste","clipboardData","plainText","html","getData","error1","error2","window","console","log","content","HTML","length","firstBlock","attributes","slice","newValue","start","end","className","decodedPlaceholder","richTextRef","selectionStart","selectionEnd","onSelectionChange","newStart","newEnd","sel","__unstableDisableFormats","createElement","supportKeys","contentEditable","role","onFocus","onBlur","onKeyPress"],"sources":["@wordpress/editor/src/components/post-title/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tforwardRef,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { ENTER } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { pasteHandler } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\t__unstableUseRichText as useRichText,\n\tcreate,\n\ttoHTMLString,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport { store as editorStore } from '../../store';\n\n/**\n * Constants\n */\nconst REGEXP_NEWLINES = /[\\r\\n]+/g;\n\nfunction PostTitle( _, forwardedRef ) {\n\tconst ref = useRef();\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { insertDefaultBlock, clearSelectedBlock, insertBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { isCleanNewPost, title, placeholder, hasFixedToolbar } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostAttribute, isCleanNewPost: _isCleanNewPost } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\tconst { titlePlaceholder, hasFixedToolbar: _hasFixedToolbar } =\n\t\t\t\tgetSettings();\n\n\t\t\treturn {\n\t\t\t\tisCleanNewPost: _isCleanNewPost(),\n\t\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\t\tplaceholder: titlePlaceholder,\n\t\t\t\thasFixedToolbar: _hasFixedToolbar,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tuseImperativeHandle( forwardedRef, () => ( {\n\t\tfocus: () => {\n\t\t\tref?.current?.focus();\n\t\t},\n\t} ) );\n\n\tuseEffect( () => {\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { defaultView } = ref.current.ownerDocument;\n\t\tconst { name, parent } = defaultView;\n\t\tconst ownerDocument =\n\t\t\tname === 'editor-canvas' ? parent.document : defaultView.document;\n\t\tconst { activeElement, body } = ownerDocument;\n\n\t\t// Only autofocus the title when the post is entirely empty. This should\n\t\t// only happen for a new post, which means we focus the title on new\n\t\t// post so the author can start typing right away, without needing to\n\t\t// click anything.\n\t\tif ( isCleanNewPost && ( ! activeElement || body === activeElement ) ) {\n\t\t\tref.current.focus();\n\t\t}\n\t}, [ isCleanNewPost ] );\n\n\tfunction onEnterPress() {\n\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t}\n\n\tfunction onInsertBlockAfter( blocks ) {\n\t\tinsertBlocks( blocks, 0 );\n\t}\n\n\tfunction onUpdate( newTitle ) {\n\t\teditPost( { title: newTitle } );\n\t}\n\n\tconst [ selection, setSelection ] = useState( {} );\n\n\tfunction onSelect() {\n\t\tsetIsSelected( true );\n\t\tclearSelectedBlock();\n\t}\n\n\tfunction onUnselect() {\n\t\tsetIsSelected( false );\n\t\tsetSelection( {} );\n\t}\n\n\tfunction onChange( value ) {\n\t\tonUpdate( value.replace( REGEXP_NEWLINES, ' ' ) );\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.keyCode === ENTER ) {\n\t\t\tevent.preventDefault();\n\t\t\tonEnterPress();\n\t\t}\n\t}\n\n\tfunction onPaste( event ) {\n\t\tconst clipboardData = event.clipboardData;\n\n\t\tlet plainText = '';\n\t\tlet html = '';\n\n\t\t// IE11 only supports `Text` as an argument for `getData` and will\n\t\t// otherwise throw an invalid argument error, so we try the standard\n\t\t// arguments first, then fallback to `Text` if they fail.\n\t\ttry {\n\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t} catch ( error1 ) {\n\t\t\ttry {\n\t\t\t\thtml = clipboardData.getData( 'Text' );\n\t\t\t} catch ( error2 ) {\n\t\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t\t// behaviour.\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t} );\n\n\t\tevent.preventDefault();\n\n\t\tif ( ! content.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( typeof content !== 'string' ) {\n\t\t\tconst [ firstBlock ] = content;\n\n\t\t\tif (\n\t\t\t\t! title &&\n\t\t\t\t( firstBlock.name === 'core/heading' ||\n\t\t\t\t\tfirstBlock.name === 'core/paragraph' )\n\t\t\t) {\n\t\t\t\tonUpdate( stripHTML( firstBlock.attributes.content ) );\n\t\t\t\tonInsertBlockAfter( content.slice( 1 ) );\n\t\t\t} else {\n\t\t\t\tonInsertBlockAfter( content );\n\t\t\t}\n\t\t} else {\n\t\t\tconst value = {\n\t\t\t\t...create( { html: title } ),\n\t\t\t\t...selection,\n\t\t\t};\n\t\t\tconst newValue = insert(\n\t\t\t\tvalue,\n\t\t\t\tcreate( { html: stripHTML( content ) } )\n\t\t\t);\n\t\t\tonUpdate( toHTMLString( { value: newValue } ) );\n\t\t\tsetSelection( {\n\t\t\t\tstart: newValue.start,\n\t\t\t\tend: newValue.end,\n\t\t\t} );\n\t\t}\n\t}\n\n\t// The wp-block className is important for editor styles.\n\t// This same block is used in both the visual and the code editor.\n\tconst className = classnames(\n\t\t'wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text',\n\t\t{\n\t\t\t'is-selected': isSelected,\n\t\t\t'has-fixed-toolbar': hasFixedToolbar,\n\t\t}\n\t);\n\tconst decodedPlaceholder =\n\t\tdecodeEntities( placeholder ) || __( 'Add title' );\n\tconst { ref: richTextRef } = useRichText( {\n\t\tvalue: title,\n\t\tonChange,\n\t\tplaceholder: decodedPlaceholder,\n\t\tselectionStart: selection.start,\n\t\tselectionEnd: selection.end,\n\t\tonSelectionChange( newStart, newEnd ) {\n\t\t\tsetSelection( ( sel ) => {\n\t\t\t\tconst { start, end } = sel;\n\t\t\t\tif ( start === newStart && end === newEnd ) {\n\t\t\t\t\treturn sel;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstart: newStart,\n\t\t\t\t\tend: newEnd,\n\t\t\t\t};\n\t\t\t} );\n\t\t},\n\t\t__unstableDisableFormats: true,\n\t} );\n\n\t/* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"title\">\n\t\t\t<h1\n\t\t\t\tref={ useMergeRefs( [ richTextRef, ref ] ) }\n\t\t\t\tcontentEditable\n\t\t\t\tclassName={ className }\n\t\t\t\taria-label={ decodedPlaceholder }\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline=\"true\"\n\t\t\t\tonFocus={ onSelect }\n\t\t\t\tonBlur={ onUnselect }\n\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\tonKeyPress={ onUnselect }\n\t\t\t\tonPaste={ onPaste }\n\t\t\t/>\n\t\t</PostTypeSupportCheck>\n\t);\n\t/* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n}\n\nexport default forwardRef( PostTitle );\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,UAAU,EACVC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACF,oBAAoB;AAC3B,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,KAAK,QAAQ,qBAAqB;AAC3C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SACCC,qBAAqB,IAAIC,WAAW,EACpCC,MAAM,EACNC,YAAY,EACZC,MAAM,QACA,sBAAsB;AAC7B,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;;AAEjE;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,4BAA4B;AAC7D,SAASV,KAAK,IAAIW,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA,MAAMC,eAAe,GAAG,UAAU;AAElC,SAASC,SAASA,CAAEC,CAAC,EAAEC,YAAY,EAAG;EACrC,MAAMC,GAAG,GAAGvB,MAAM,CAAC,CAAC;EACpB,MAAM,CAAEwB,UAAU,EAAEC,aAAa,CAAE,GAAGxB,QAAQ,CAAE,KAAM,CAAC;EACvD,MAAM;IAAEyB;EAAS,CAAC,GAAGrB,WAAW,CAAEa,WAAY,CAAC;EAC/C,MAAM;IAAES,kBAAkB;IAAEC,kBAAkB;IAAEC;EAAa,CAAC,GAC7DxB,WAAW,CAAEG,gBAAiB,CAAC;EAChC,MAAM;IAAEs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AAO,EAAG1C,QAAU;IACpB2C,MAAM,EAAG1C,UAAY;IACrBI,SAAS,EAAGA,SAAW;IACvBuC,UAAU,EAAG3C,UAAY;IACzBQ,OAAO,EAAGA;EAAS,CACnB,CACoB,CAAC;EAExB;AACD;;AAEA,eAAerE,UAAU,CAAEuB,SAAU,CAAC"}
1
+ {"version":3,"names":["classnames","__","forwardRef","useState","decodeEntities","useSelect","useDispatch","store","blockEditorStore","ENTER","pasteHandler","__unstableUseRichText","useRichText","create","toHTMLString","insert","useMergeRefs","__unstableStripHTML","stripHTML","editorStore","DEFAULT_CLASSNAMES","REGEXP_NEWLINES","usePostTitleFocus","usePostTitle","PostTypeSupportCheck","PostTitle","_","forwardedRef","placeholder","hasFixedToolbar","select","getEditedPostAttribute","getSettings","titlePlaceholder","_hasFixedToolbar","title","isSelected","setIsSelected","ref","focusRef","setTitle","onUpdate","selection","setSelection","clearSelectedBlock","insertBlocks","insertDefaultBlock","onChange","value","replace","onInsertBlockAfter","blocks","onSelect","onUnselect","onEnterPress","undefined","onKeyDown","event","keyCode","preventDefault","onPaste","clipboardData","plainText","html","getData","error1","error2","window","console","log","content","HTML","length","firstBlock","name","contentNoHTML","attributes","slice","newValue","start","end","decodedPlaceholder","richTextRef","selectionStart","selectionEnd","onSelectionChange","newStart","newEnd","sel","__unstableDisableFormats","className","createElement","supportKeys","contentEditable","role","onFocus","onBlur","onKeyPress"],"sources":["@wordpress/editor/src/components/post-title/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { forwardRef, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { ENTER } from '@wordpress/keycodes';\nimport { pasteHandler } from '@wordpress/blocks';\nimport {\n\t__unstableUseRichText as useRichText,\n\tcreate,\n\ttoHTMLString,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';\nimport usePostTitleFocus from './use-post-title-focus';\nimport usePostTitle from './use-post-title';\nimport PostTypeSupportCheck from '../post-type-support-check';\n\nfunction PostTitle( _, forwardedRef ) {\n\tconst { placeholder, hasFixedToolbar } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { titlePlaceholder, hasFixedToolbar: _hasFixedToolbar } =\n\t\t\tgetSettings();\n\n\t\treturn {\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\tplaceholder: titlePlaceholder,\n\t\t\thasFixedToolbar: _hasFixedToolbar,\n\t\t};\n\t}, [] );\n\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\n\tconst { ref: focusRef } = usePostTitleFocus( forwardedRef );\n\n\tconst { title, setTitle: onUpdate } = usePostTitle();\n\n\tconst [ selection, setSelection ] = useState( {} );\n\n\tconst { clearSelectedBlock, insertBlocks, insertDefaultBlock } =\n\t\tuseDispatch( blockEditorStore );\n\n\tfunction onChange( value ) {\n\t\tonUpdate( value.replace( REGEXP_NEWLINES, ' ' ) );\n\t}\n\n\tfunction onInsertBlockAfter( blocks ) {\n\t\tinsertBlocks( blocks, 0 );\n\t}\n\n\tfunction onSelect() {\n\t\tsetIsSelected( true );\n\t\tclearSelectedBlock();\n\t}\n\n\tfunction onUnselect() {\n\t\tsetIsSelected( false );\n\t\tsetSelection( {} );\n\t}\n\n\tfunction onEnterPress() {\n\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.keyCode === ENTER ) {\n\t\t\tevent.preventDefault();\n\t\t\tonEnterPress();\n\t\t}\n\t}\n\n\tfunction onPaste( event ) {\n\t\tconst clipboardData = event.clipboardData;\n\n\t\tlet plainText = '';\n\t\tlet html = '';\n\n\t\t// IE11 only supports `Text` as an argument for `getData` and will\n\t\t// otherwise throw an invalid argument error, so we try the standard\n\t\t// arguments first, then fallback to `Text` if they fail.\n\t\ttry {\n\t\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\t\thtml = clipboardData.getData( 'text/html' );\n\t\t} catch ( error1 ) {\n\t\t\ttry {\n\t\t\t\thtml = clipboardData.getData( 'Text' );\n\t\t\t} catch ( error2 ) {\n\t\t\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t\t\t// don't support clipboardData at all, so allow default\n\t\t\t\t// behaviour.\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\twindow.console.log( 'Received HTML:\\n\\n', html );\n\t\twindow.console.log( 'Received plain text:\\n\\n', plainText );\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t} );\n\n\t\tevent.preventDefault();\n\n\t\tif ( ! content.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( typeof content !== 'string' ) {\n\t\t\tconst [ firstBlock ] = content;\n\n\t\t\tif (\n\t\t\t\t! title &&\n\t\t\t\t( firstBlock.name === 'core/heading' ||\n\t\t\t\t\tfirstBlock.name === 'core/paragraph' )\n\t\t\t) {\n\t\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t\t// is undesirable.\n\t\t\t\tconst contentNoHTML = stripHTML(\n\t\t\t\t\tfirstBlock.attributes.content\n\t\t\t\t);\n\t\t\t\tonUpdate( contentNoHTML );\n\t\t\t\tonInsertBlockAfter( content.slice( 1 ) );\n\t\t\t} else {\n\t\t\t\tonInsertBlockAfter( content );\n\t\t\t}\n\t\t} else {\n\t\t\tconst value = {\n\t\t\t\t...create( { html: title } ),\n\t\t\t\t...selection,\n\t\t\t};\n\n\t\t\t// Strip HTML to avoid unwanted HTML being added to the title.\n\t\t\t// In the majority of cases it is assumed that HTML in the title\n\t\t\t// is undesirable.\n\t\t\tconst contentNoHTML = stripHTML( content );\n\n\t\t\tconst newValue = insert( value, create( { html: contentNoHTML } ) );\n\t\t\tonUpdate( toHTMLString( { value: newValue } ) );\n\t\t\tsetSelection( {\n\t\t\t\tstart: newValue.start,\n\t\t\t\tend: newValue.end,\n\t\t\t} );\n\t\t}\n\t}\n\n\tconst decodedPlaceholder =\n\t\tdecodeEntities( placeholder ) || __( 'Add title' );\n\n\tconst { ref: richTextRef } = useRichText( {\n\t\tvalue: title,\n\t\tonChange,\n\t\tplaceholder: decodedPlaceholder,\n\t\tselectionStart: selection.start,\n\t\tselectionEnd: selection.end,\n\t\tonSelectionChange( newStart, newEnd ) {\n\t\t\tsetSelection( ( sel ) => {\n\t\t\t\tconst { start, end } = sel;\n\t\t\t\tif ( start === newStart && end === newEnd ) {\n\t\t\t\t\treturn sel;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstart: newStart,\n\t\t\t\t\tend: newEnd,\n\t\t\t\t};\n\t\t\t} );\n\t\t},\n\t\t__unstableDisableFormats: false,\n\t} );\n\n\t// The wp-block className is important for editor styles.\n\t// This same block is used in both the visual and the code editor.\n\tconst className = classnames( DEFAULT_CLASSNAMES, {\n\t\t'is-selected': isSelected,\n\t\t'has-fixed-toolbar': hasFixedToolbar,\n\t} );\n\n\treturn (\n\t\t/* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t\t<PostTypeSupportCheck supportKeys=\"title\">\n\t\t\t<h1\n\t\t\t\tref={ useMergeRefs( [ richTextRef, focusRef ] ) }\n\t\t\t\tcontentEditable\n\t\t\t\tclassName={ className }\n\t\t\t\taria-label={ decodedPlaceholder }\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline=\"true\"\n\t\t\t\tonFocus={ onSelect }\n\t\t\t\tonBlur={ onUnselect }\n\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\tonKeyPress={ onUnselect }\n\t\t\t\tonPaste={ onPaste }\n\t\t\t/>\n\t\t</PostTypeSupportCheck>\n\t\t/* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */\n\t);\n}\n\nexport default forwardRef( PostTitle );\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,UAAU,EAAEC,QAAQ,QAAQ,oBAAoB;AACzD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,KAAK,QAAQ,qBAAqB;AAC3C,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SACCC,qBAAqB,IAAIC,WAAW,EACpCC,MAAM,EACNC,YAAY,EACZC,MAAM,QACA,sBAAsB;AAC7B,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;;AAEjE;AACA;AACA;AACA,SAASX,KAAK,IAAIY,WAAW,QAAQ,aAAa;AAClD,SAASC,kBAAkB,EAAEC,eAAe,QAAQ,aAAa;AACjE,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,oBAAoB,MAAM,4BAA4B;AAE7D,SAASC,SAASA,CAAEC,CAAC,EAAEC,YAAY,EAAG;EACrC,MAAM;IAAEC,WAAW;IAAEC;EAAgB,CAAC,GAAGxB,SAAS,CAAIyB,MAAM,IAAM;IACjE,MAAM;MAAEC;IAAuB,CAAC,GAAGD,MAAM,CAAEX,WAAY,CAAC;IACxD,MAAM;MAAEa;IAAY,CAAC,GAAGF,MAAM,CAAEtB,gBA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,GAAG;QACX;QACA,OAAO;UACNT,KAAK,EAAEO,QAAQ;UACfN,GAAG,EAAEO;QACN,CAAC;MACF,CAAE,CAAC;IACJ,CAAC;IACDE,wBAAwB,EAAE;EAC3B,CAAE,CAAC;;EAEH;EACA;EACA,MAAMC,SAAS,GAAG1F,UAAU,CAAEoB,kBAAkB,EAAE;IACjD,aAAa,EAAEgB,UAAU;IACzB,mBAAmB,EAAEP;EACtB,CAAE,CAAC;EAEH,OACC;IACA8D,aAAA,CAACnE,oBAAoB;MAACoE,WAAW,EAAC;IAAO,GACxCD,aAAA;MACCrD,GAAG,EAAGtB,YAAY,CAAE,CAAEkE,WAAW,EAAE3C,QAAQ,CAAG,CAAG;MACjDsD,eAAe;MACfH,SAAS,EAAGA,SAAW;MACvB,cAAaT,kBAAoB;MACjCa,IAAI,EAAC,SAAS;MACd,kBAAe,MAAM;MACrBC,OAAO,EAAG3C,QAAU;MACpB4C,MAAM,EAAG3C,UAAY;MACrBG,SAAS,EAAGA,SAAW;MACvByC,UAAU,EAAG5C,UAAY;MACzBO,OAAO,EAAGA;IAAS,CACnB,CACoB;IACtB;EAAA;AAEF;;AAEA,eAAe1D,UAAU,CAAEuB,SAAU,CAAC"}
@@ -0,0 +1,83 @@
1
+ import { createElement } from "react";
2
+ /**
3
+ * External dependencies
4
+ */
5
+ import classnames from 'classnames';
6
+
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+ import { TextareaControl } from '@wordpress/components';
11
+ import { __ } from '@wordpress/i18n';
12
+ import { decodeEntities } from '@wordpress/html-entities';
13
+ import { useSelect } from '@wordpress/data';
14
+ import { store as blockEditorStore } from '@wordpress/block-editor';
15
+ import { useState, forwardRef } from '@wordpress/element';
16
+
17
+ /**
18
+ * Internal dependencies
19
+ */
20
+ import { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';
21
+ import usePostTitleFocus from './use-post-title-focus';
22
+ import usePostTitle from './use-post-title';
23
+ function PostTitleRaw(_, forwardedRef) {
24
+ const {
25
+ placeholder,
26
+ hasFixedToolbar
27
+ } = useSelect(select => {
28
+ const {
29
+ getSettings
30
+ } = select(blockEditorStore);
31
+ const {
32
+ titlePlaceholder,
33
+ hasFixedToolbar: _hasFixedToolbar
34
+ } = getSettings();
35
+ return {
36
+ placeholder: titlePlaceholder,
37
+ hasFixedToolbar: _hasFixedToolbar
38
+ };
39
+ }, []);
40
+ const [isSelected, setIsSelected] = useState(false);
41
+ const {
42
+ title,
43
+ setTitle: onUpdate
44
+ } = usePostTitle();
45
+ const {
46
+ ref: focusRef
47
+ } = usePostTitleFocus(forwardedRef);
48
+ function onChange(value) {
49
+ onUpdate(value.replace(REGEXP_NEWLINES, ' '));
50
+ }
51
+ function onSelect() {
52
+ setIsSelected(true);
53
+ }
54
+ function onUnselect() {
55
+ setIsSelected(false);
56
+ }
57
+
58
+ // The wp-block className is important for editor styles.
59
+ // This same block is used in both the visual and the code editor.
60
+ const className = classnames(DEFAULT_CLASSNAMES, {
61
+ 'is-selected': isSelected,
62
+ 'has-fixed-toolbar': hasFixedToolbar,
63
+ 'is-raw-text': true
64
+ });
65
+ const decodedPlaceholder = decodeEntities(placeholder) || __('Add title');
66
+ return createElement(TextareaControl, {
67
+ ref: focusRef,
68
+ value: title,
69
+ onChange: onChange,
70
+ onFocus: onSelect,
71
+ onBlur: onUnselect,
72
+ label: placeholder,
73
+ className: className,
74
+ placeholder: decodedPlaceholder,
75
+ hideLabelFromVision: true,
76
+ autoComplete: "off",
77
+ dir: "auto",
78
+ rows: 1,
79
+ __nextHasNoMarginBottom: true
80
+ });
81
+ }
82
+ export default forwardRef(PostTitleRaw);
83
+ //# sourceMappingURL=post-title-raw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["classnames","TextareaControl","__","decodeEntities","useSelect","store","blockEditorStore","useState","forwardRef","DEFAULT_CLASSNAMES","REGEXP_NEWLINES","usePostTitleFocus","usePostTitle","PostTitleRaw","_","forwardedRef","placeholder","hasFixedToolbar","select","getSettings","titlePlaceholder","_hasFixedToolbar","isSelected","setIsSelected","title","setTitle","onUpdate","ref","focusRef","onChange","value","replace","onSelect","onUnselect","className","decodedPlaceholder","createElement","onFocus","onBlur","label","hideLabelFromVision","autoComplete","dir","rows","__nextHasNoMarginBottom"],"sources":["@wordpress/editor/src/components/post-title/post-title-raw.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { TextareaControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useState, forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';\nimport usePostTitleFocus from './use-post-title-focus';\nimport usePostTitle from './use-post-title';\n\nfunction PostTitleRaw( _, forwardedRef ) {\n\tconst { placeholder, hasFixedToolbar } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { titlePlaceholder, hasFixedToolbar: _hasFixedToolbar } =\n\t\t\tgetSettings();\n\n\t\treturn {\n\t\t\tplaceholder: titlePlaceholder,\n\t\t\thasFixedToolbar: _hasFixedToolbar,\n\t\t};\n\t}, [] );\n\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\n\tconst { title, setTitle: onUpdate } = usePostTitle();\n\tconst { ref: focusRef } = usePostTitleFocus( forwardedRef );\n\n\tfunction onChange( value ) {\n\t\tonUpdate( value.replace( REGEXP_NEWLINES, ' ' ) );\n\t}\n\n\tfunction onSelect() {\n\t\tsetIsSelected( true );\n\t}\n\n\tfunction onUnselect() {\n\t\tsetIsSelected( false );\n\t}\n\n\t// The wp-block className is important for editor styles.\n\t// This same block is used in both the visual and the code editor.\n\tconst className = classnames( DEFAULT_CLASSNAMES, {\n\t\t'is-selected': isSelected,\n\t\t'has-fixed-toolbar': hasFixedToolbar,\n\t\t'is-raw-text': true,\n\t} );\n\n\tconst decodedPlaceholder =\n\t\tdecodeEntities( placeholder ) || __( 'Add title' );\n\n\treturn (\n\t\t<TextareaControl\n\t\t\tref={ focusRef }\n\t\t\tvalue={ title }\n\t\t\tonChange={ onChange }\n\t\t\tonFocus={ onSelect }\n\t\t\tonBlur={ onUnselect }\n\t\t\tlabel={ placeholder }\n\t\t\tclassName={ className }\n\t\t\tplaceholder={ decodedPlaceholder }\n\t\t\thideLabelFromVision={ true }\n\t\t\tautoComplete=\"off\"\n\t\t\tdir=\"auto\"\n\t\t\trows={ 1 }\n\t\t\t__nextHasNoMarginBottom\n\t\t/>\n\t);\n}\n\nexport default forwardRef( PostTitleRaw );\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,QAAQ,EAAEC,UAAU,QAAQ,oBAAoB;;AAEzD;AACA;AACA;AACA,SAASC,kBAAkB,EAAEC,eAAe,QAAQ,aAAa;AACjE,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,YAAY,MAAM,kBAAkB;AAE3C,SAASC,YAAYA,CAAEC,CAAC,EAAEC,YAAY,EAAG;EACxC,MAAM;IAAEC,WAAW;IAAEC;EAAgB,CAAC,GAAGb,SAAS,CAAIc,MAAM,IAAM;IACjE,MAAM;MAAEC;IAAY,CAAC,GAAGD,MAAM,CAAEZ,gBAAiB,CAAC;IAClD,MAAM;MAAEc,gBAAgB;MAAEH,eAAe,EAAEI;IAAiB,CAAC,GAC5DF,WAAW,CAAC,CAAC;IAEd,OAAO;MACNH,WAAW,EAAEI,gBAAgB;MAC7BH,eAAe,EAAEI;IAClB,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+1,57 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useEffect, useImperativeHandle, useRef } from '@wordpress/element';
5
+ import { useSelect } from '@wordpress/data';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { store as editorStore } from '../../store';
11
+ export default function usePostTitleFocus(forwardedRef) {
12
+ const ref = useRef();
13
+ const {
14
+ isCleanNewPost
15
+ } = useSelect(select => {
16
+ const {
17
+ isCleanNewPost: _isCleanNewPost
18
+ } = select(editorStore);
19
+ return {
20
+ isCleanNewPost: _isCleanNewPost()
21
+ };
22
+ }, []);
23
+ useImperativeHandle(forwardedRef, () => ({
24
+ focus: () => {
25
+ ref?.current?.focus();
26
+ }
27
+ }));
28
+ useEffect(() => {
29
+ if (!ref.current) {
30
+ return;
31
+ }
32
+ const {
33
+ defaultView
34
+ } = ref.current.ownerDocument;
35
+ const {
36
+ name,
37
+ parent
38
+ } = defaultView;
39
+ const ownerDocument = name === 'editor-canvas' ? parent.document : defaultView.document;
40
+ const {
41
+ activeElement,
42
+ body
43
+ } = ownerDocument;
44
+
45
+ // Only autofocus the title when the post is entirely empty. This should
46
+ // only happen for a new post, which means we focus the title on new
47
+ // post so the author can start typing right away, without needing to
48
+ // click anything.
49
+ if (isCleanNewPost && (!activeElement || body === activeElement)) {
50
+ ref.current.focus();
51
+ }
52
+ }, [isCleanNewPost]);
53
+ return {
54
+ ref
55
+ };
56
+ }
57
+ //# sourceMappingURL=use-post-title-focus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useImperativeHandle","useRef","useSelect","store","editorStore","usePostTitleFocus","forwardedRef","ref","isCleanNewPost","select","_isCleanNewPost","focus","current","defaultView","ownerDocument","name","parent","document","activeElement","body"],"sources":["@wordpress/editor/src/components/post-title/use-post-title-focus.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useImperativeHandle, useRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function usePostTitleFocus( forwardedRef ) {\n\tconst ref = useRef();\n\n\tconst { isCleanNewPost } = useSelect( ( select ) => {\n\t\tconst { isCleanNewPost: _isCleanNewPost } = select( editorStore );\n\n\t\treturn {\n\t\t\tisCleanNewPost: _isCleanNewPost(),\n\t\t};\n\t}, [] );\n\n\tuseImperativeHandle( forwardedRef, () => ( {\n\t\tfocus: () => {\n\t\t\tref?.current?.focus();\n\t\t},\n\t} ) );\n\n\tuseEffect( () => {\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { defaultView } = ref.current.ownerDocument;\n\t\tconst { name, parent } = defaultView;\n\t\tconst ownerDocument =\n\t\t\tname === 'editor-canvas' ? parent.document : defaultView.document;\n\t\tconst { activeElement, body } = ownerDocument;\n\n\t\t// Only autofocus the title when the post is entirely empty. This should\n\t\t// only happen for a new post, which means we focus the title on new\n\t\t// post so the author can start typing right away, without needing to\n\t\t// click anything.\n\t\tif ( isCleanNewPost && ( ! activeElement || body === activeElement ) ) {\n\t\t\tref.current.focus();\n\t\t}\n\t}, [ isCleanNewPost ] );\n\n\treturn { ref };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,mBAAmB,EAAEC,MAAM,QAAQ,oBAAoB;AAC3E,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAElD,eAAe,SAASC,iBAAiBA,CAAEC,YAAY,EAAG;EACzD,MAAMC,GAAG,GAAGN,MAAM,CAAC,CAAC;EAEpB,MAAM;IAAEO;EAAe,CAAC,GAAGN,SAAS,CAAIO,MAAM,IAAM;IACnD,MAAM;MAAED,cAAc,EAAEE;IAAgB,CAAC,GAAGD,MAAM,CAAEL,WAAY,CAAC;IAEjE,OAAO;MACNI,cAAc,EAAEE,eAAe,CAAC;IACjC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEPV,mBAAmB,CAAEM,YAAY,EAAE,OAAQ;IAC1CK,KAAK,EAAEA,CAAA,KAAM;MACZJ,GAAG,EAAEK,OAAO,EAAED,KAAK,CAAC,CAAC;IACtB;EACD,CAAC,CAAG,CAAC;EAELZ,SAAS,CAAE,MAAM;IAChB,IAAK,CAAEQ,GAAG,CAACK,OAAO,EAAG;MACpB;IACD;IAEA,MAAM;MAAEC;IAAY,CAAC,GAAGN,GAAG,CAACK,OAAO,CAACE,aAAa;IACjD,MAAM;MAAEC,IAAI;MAAEC;IAAO,CAAC,GAAGH,WAAW;IACpC,MAAMC,aAAa,GAClBC,IAAI,KAAK,eAAe,GAAGC,MAAM,CAACC,QAAQ,GAAGJ,WAAW,CAACI,QAAQ;IAClE,MAAM;MAAEC,aAAa;MAAEC;IAAK,CAAC,GAAGL,aAAa;;IAE7C;IACA;IACA;IACA;IACA,IAAKN,cAAc,KAAM,CAAEU,aAAa,IAAIC,IAAI,KAAKD,aAAa,CAAE,EAAG;MACtEX,GAAG,CAACK,OAAO,CAACD,KAAK,CAAC,CAAC;IACpB;EACD,CAAC,EAAE,CAAEH,cAAc,CAAG,CAAC;EAEvB,OAAO;IAAED;EAAI,CAAC;AACf"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect, useDispatch } from '@wordpress/data';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+ import { store as editorStore } from '../../store';
9
+ export default function usePostTitle() {
10
+ const {
11
+ editPost
12
+ } = useDispatch(editorStore);
13
+ const {
14
+ title
15
+ } = useSelect(select => {
16
+ const {
17
+ getEditedPostAttribute
18
+ } = select(editorStore);
19
+ return {
20
+ title: getEditedPostAttribute('title')
21
+ };
22
+ }, []);
23
+ function updateTitle(newTitle) {
24
+ editPost({
25
+ title: newTitle
26
+ });
27
+ }
28
+ return {
29
+ title,
30
+ setTitle: updateTitle
31
+ };
32
+ }
33
+ //# sourceMappingURL=use-post-title.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useSelect","useDispatch","store","editorStore","usePostTitle","editPost","title","select","getEditedPostAttribute","updateTitle","newTitle","setTitle"],"sources":["@wordpress/editor/src/components/post-title/use-post-title.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function usePostTitle() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { title } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\n\t\treturn {\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t};\n\t}, [] );\n\n\tfunction updateTitle( newTitle ) {\n\t\teditPost( { title: newTitle } );\n\t}\n\n\treturn { title, setTitle: updateTitle };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAElD,eAAe,SAASC,YAAYA,CAAA,EAAG;EACtC,MAAM;IAAEC;EAAS,CAAC,GAAGJ,WAAW,CAAEE,WAAY,CAAC;EAC/C,MAAM;IAAEG;EAAM,CAAC,GAAGN,SAAS,CAAIO,MAAM,IAAM;IAC1C,MAAM;MAAEC;IAAuB,CAAC,GAAGD,MAAM,CAAEJ,WAAY,CAAC;IAExD,OAAO;MACNG,KAAK,EAAEE,sBAAsB,CAAE,OAAQ;IACxC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,SAASC,WAAWA,CAAEC,QAAQ,EAAG;IAChCL,QAAQ,CAAE;MAAEC,KAAK,EAAEI;IAAS,CAAE,CAAC;EAChC;EAEA,OAAO;IAAEJ,KAAK;IAAEK,QAAQ,EAAEF;EAAY,CAAC;AACxC"}
@@ -3,7 +3,7 @@ import { createElement } from "react";
3
3
  * WordPress dependencies
4
4
  */
5
5
  import { useMemo, useState } from '@wordpress/element';
6
- import { __experimentalHStack as HStack, Dropdown, Button } from '@wordpress/components';
6
+ import { Dropdown, Button } from '@wordpress/components';
7
7
  import { __, sprintf } from '@wordpress/i18n';
8
8
 
9
9
  /**
@@ -12,6 +12,7 @@ import { __, sprintf } from '@wordpress/i18n';
12
12
  import PostURLCheck from './check';
13
13
  import PostURL from './index';
14
14
  import { usePostURLLabel } from './label';
15
+ import PostPanelRow from '../post-panel-row';
15
16
  export default function PostURLPanel() {
16
17
  // Use internal state instead of a ref to make sure that the component
17
18
  // re-renders when the popover's anchor updates.
@@ -21,10 +22,10 @@ export default function PostURLPanel() {
21
22
  anchor: popoverAnchor,
22
23
  placement: 'bottom-end'
23
24
  }), [popoverAnchor]);
24
- return createElement(PostURLCheck, null, createElement(HStack, {
25
- className: "editor-post-url__panel",
25
+ return createElement(PostURLCheck, null, createElement(PostPanelRow, {
26
+ label: __('URL'),
26
27
  ref: setPopoverAnchor
27
- }, createElement("span", null, __('URL')), createElement(Dropdown, {
28
+ }, createElement(Dropdown, {
28
29
  popoverProps: popoverProps,
29
30
  className: "editor-post-url__panel-dropdown",
30
31
  contentClassName: "editor-post-url__panel-dialog",
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","useState","__experimentalHStack","HStack","Dropdown","Button","__","sprintf","PostURLCheck","PostURL","usePostURLLabel","PostURLPanel","popoverAnchor","setPopoverAnchor","popoverProps","anchor","placement","createElement","className","ref","contentClassName","focusOnMount","renderToggle","isOpen","onToggle","PostURLToggle","onClick","renderContent","onClose","label","variant"],"sources":["@wordpress/editor/src/components/post-url/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\nimport {\n\t__experimentalHStack as HStack,\n\tDropdown,\n\tButton,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PostURLCheck from './check';\nimport PostURL from './index';\nimport { usePostURLLabel } from './label';\n\nexport default function PostURLPanel() {\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( { anchor: popoverAnchor, placement: 'bottom-end' } ),\n\t\t[ popoverAnchor ]\n\t);\n\n\treturn (\n\t\t<PostURLCheck>\n\t\t\t<HStack className=\"editor-post-url__panel\" ref={ setPopoverAnchor }>\n\t\t\t\t<span>{ __( 'URL' ) }</span>\n\t\t\t\t<Dropdown\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tclassName=\"editor-post-url__panel-dropdown\"\n\t\t\t\t\tcontentClassName=\"editor-post-url__panel-dialog\"\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<PostURLToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<PostURL onClose={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</HStack>\n\t\t</PostURLCheck>\n\t);\n}\n\nfunction PostURLToggle( { isOpen, onClick } ) {\n\tconst label = usePostURLLabel();\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"editor-post-url__panel-toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\t// translators: %s: Current post URL.\n\t\t\taria-label={ sprintf( __( 'Change URL: %s' ), label ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SACCC,oBAAoB,IAAIC,MAAM,EAC9BC,QAAQ,EACRC,MAAM,QACA,uBAAuB;AAC9B,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC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H,OAAO,EAAGA;EAAS,GAEjBG,KACK,CAAC;AAEX"}
1
+ {"version":3,"names":["useMemo","useState","Dropdown","Button","__","sprintf","PostURLCheck","PostURL","usePostURLLabel","PostPanelRow","PostURLPanel","popoverAnchor","setPopoverAnchor","popoverProps","anchor","placement","createElement","label","ref","className","contentClassName","focusOnMount","renderToggle","isOpen","onToggle","PostURLToggle","onClick","renderContent","onClose","variant"],"sources":["@wordpress/editor/src/components/post-url/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PostURLCheck from './check';\nimport PostURL from './index';\nimport { usePostURLLabel } from './label';\nimport PostPanelRow from '../post-panel-row';\n\nexport default function PostURLPanel() {\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( { anchor: popoverAnchor, placement: 'bottom-end' } ),\n\t\t[ popoverAnchor ]\n\t);\n\n\treturn (\n\t\t<PostURLCheck>\n\t\t\t<PostPanelRow label={ __( 'URL' ) } ref={ setPopoverAnchor }>\n\t\t\t\t<Dropdown\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tclassName=\"editor-post-url__panel-dropdown\"\n\t\t\t\t\tcontentClassName=\"editor-post-url__panel-dialog\"\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<PostURLToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<PostURL onClose={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</PostPanelRow>\n\t\t</PostURLCheck>\n\t);\n}\n\nfunction PostURLToggle( { isOpen, onClick } ) {\n\tconst label = usePostURLLabel();\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"editor-post-url__panel-toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\t// translators: %s: Current post URL.\n\t\t\taria-label={ sprintf( __( 'Change URL: %s' ), label ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,QAAQ,EAAEC,MAAM,QAAQ,uBAAuB;AACxD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC,YAAY,MAAM,SAAS;AAClC,OAAOC,OAAO,MAAM,SAAS;AAC7B,SAASC,eAAe,QAAQ,SAAS;AACzC,OAAOC,YAAY,MAAM,mBAAmB;AAE5C,eAAe,SAASC,YAAYA,CAAA,EAAG;EACtC;EACA;EACA,MAAM,CAAEC,aAAa,EAAEC,gBAAgB,CAAE,GAAGX,QAAQ,CAAE,IAAK,CAAC;EAC5D;EACA,MAAMY,YAAY,GAAGb,OAAO,CAC3B,OAAQ;IAAEc,MAAM,EAAEH,aAAa;IAAEI,SAAS,EAAE;EAAa,CAAC,CAAE,EAC5D,CAAEJ,aAAa,CAChB,CAAC;EAED,OACCK,aAAA,CAACV,YAAY,QACZU,aAAA,CAACP,YAAY;IAACQ,KAAK,EAAGb,EAAE,CAAE,KAAM,CAAG;IAACc,GAAG,EAAGN;EAAkB,GAC3DI,aAAA,CAACd,QAAQ;IACRW,YAAY,EAAGA,YAAc;IAC7BM,SAAS,EAAC,iCAAiC;IAC3CC,gBAAgB,EAAC,+BAA+B;IAChDC,YAAY;IACZC,YAAY,EAAGA,CAAE;MAAEC,MAAM;MAAEC;IAAS,CAAC,KACpCR,aAAA,CAACS,aAAa;MAACF,MAAM,EAAGA,MAAQ;MAACG,OAAO,EAAGF;IAAU,CAAE,CACrD;IACHG,aAAa,EAAGA,CAAE;MAAEC;IAAQ,CAAC,KAC5BZ,aAAA,CAACT,OAAO;MAACqB,OAAO,EAAGA;IAAS,CAAE;EAC5B,CACH,CACY,CACD,CAAC;AAEjB;AAEA,SAASH,aAAaA,CAAE;EAAEF,MAAM;EAAEG;AAAQ,CAAC,EAAG;EAC7C,MAAMT,KAAK,GAAGT,eAAe,CAAC,CAAC;EAC/B,OACCQ,aAAA,CAACb,MAAM;IACNgB,SAAS,EAAC,+BAA+B;IACzCU,OAAO,EAAC,UAAU;IAClB,iBAAgBN;IAChB;IAAA;IACA,cAAalB,OAAO,CAAED,EAAE,CAAE,gBAAiB,CAAC,EAAEa,KAAM,CAAG;IACvDS,OAAO,EAAGA;EAAS,GAEjBT,KACK,CAAC;AAEX"}
@@ -0,0 +1,2 @@
1
+ export const PAGE_CONTENT_BLOCK_TYPES = ['core/post-title', 'core/post-featured-image', 'core/post-content'];
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PAGE_CONTENT_BLOCK_TYPES"],"sources":["@wordpress/editor/src/components/provider/constants.js"],"sourcesContent":["export const PAGE_CONTENT_BLOCK_TYPES = [\n\t'core/post-title',\n\t'core/post-featured-image',\n\t'core/post-content',\n];\n"],"mappings":"AAAA,OAAO,MAAMA,wBAAwB,GAAG,CACvC,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,CACnB"}
@@ -0,0 +1,56 @@
1
+ import { createElement } from "react";
2
+ /**
3
+ * WordPress dependencies
4
+ */
5
+ import { useSelect, useDispatch } from '@wordpress/data';
6
+ import { useBlockEditingMode, store as blockEditorStore } from '@wordpress/block-editor';
7
+ import { useEffect } from '@wordpress/element';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import { PAGE_CONTENT_BLOCK_TYPES } from './constants';
13
+ function DisableBlock({
14
+ clientId
15
+ }) {
16
+ const isDescendentOfQueryLoop = useSelect(select => {
17
+ const {
18
+ getBlockParentsByBlockName
19
+ } = select(blockEditorStore);
20
+ return getBlockParentsByBlockName(clientId, 'core/query').length !== 0;
21
+ }, [clientId]);
22
+ const mode = isDescendentOfQueryLoop ? undefined : 'contentOnly';
23
+ const {
24
+ setBlockEditingMode,
25
+ unsetBlockEditingMode
26
+ } = useDispatch(blockEditorStore);
27
+ useEffect(() => {
28
+ if (mode) {
29
+ setBlockEditingMode(clientId, mode);
30
+ return () => {
31
+ unsetBlockEditingMode(clientId);
32
+ };
33
+ }
34
+ }, [clientId, mode, setBlockEditingMode, unsetBlockEditingMode]);
35
+ }
36
+
37
+ /**
38
+ * Component that when rendered, makes it so that the site editor allows only
39
+ * page content to be edited.
40
+ */
41
+ export default function DisableNonPageContentBlocks() {
42
+ useBlockEditingMode('disabled');
43
+ const clientIds = useSelect(select => {
44
+ const {
45
+ __experimentalGetGlobalBlocksByName
46
+ } = select(blockEditorStore);
47
+ return __experimentalGetGlobalBlocksByName(PAGE_CONTENT_BLOCK_TYPES);
48
+ }, []);
49
+ return clientIds.map(clientId => {
50
+ return createElement(DisableBlock, {
51
+ key: clientId,
52
+ clientId: clientId
53
+ });
54
+ });
55
+ }
56
+ //# sourceMappingURL=disable-non-page-content-blocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useSelect","useDispatch","useBlockEditingMode","store","blockEditorStore","useEffect","PAGE_CONTENT_BLOCK_TYPES","DisableBlock","clientId","isDescendentOfQueryLoop","select","getBlockParentsByBlockName","length","mode","undefined","setBlockEditingMode","unsetBlockEditingMode","DisableNonPageContentBlocks","clientIds","__experimentalGetGlobalBlocksByName","map","createElement","key"],"sources":["@wordpress/editor/src/components/provider/disable-non-page-content-blocks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseBlockEditingMode,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { PAGE_CONTENT_BLOCK_TYPES } from './constants';\n\nfunction DisableBlock( { clientId } ) {\n\tconst isDescendentOfQueryLoop = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParentsByBlockName } = select( blockEditorStore );\n\t\t\treturn (\n\t\t\t\tgetBlockParentsByBlockName( clientId, 'core/query' ).length !==\n\t\t\t\t0\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst mode = isDescendentOfQueryLoop ? undefined : 'contentOnly';\n\tconst { setBlockEditingMode, unsetBlockEditingMode } =\n\t\tuseDispatch( blockEditorStore );\n\tuseEffect( () => {\n\t\tif ( mode ) {\n\t\t\tsetBlockEditingMode( clientId, mode );\n\t\t\treturn () => {\n\t\t\t\tunsetBlockEditingMode( clientId );\n\t\t\t};\n\t\t}\n\t}, [ clientId, mode, setBlockEditingMode, unsetBlockEditingMode ] );\n}\n\n/**\n * Component that when rendered, makes it so that the site editor allows only\n * page content to be edited.\n */\nexport default function DisableNonPageContentBlocks() {\n\tuseBlockEditingMode( 'disabled' );\n\tconst clientIds = useSelect( ( select ) => {\n\t\tconst { __experimentalGetGlobalBlocksByName } =\n\t\t\tselect( blockEditorStore );\n\t\treturn __experimentalGetGlobalBlocksByName( PAGE_CONTENT_BLOCK_TYPES );\n\t}, [] );\n\n\treturn clientIds.map( ( clientId ) => {\n\t\treturn <DisableBlock key={ clientId } clientId={ clientId } />;\n\t} );\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,mBAAmB,EACnBC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,SAAS,QAAQ,oBAAoB;;AAE9C;AACA;AACA;AACA,SAASC,wBAAwB,QAAQ,aAAa;AAEtD,SAASC,YAAYA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACrC,MAAMC,uBAAuB,GAAGT,SAAS,CACt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