@wordpress/editor 9.25.11 → 9.25.14

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.
@@ -11,6 +11,8 @@ var _element = require("@wordpress/element");
11
11
 
12
12
  var _data = require("@wordpress/data");
13
13
 
14
+ var _coreData = require("@wordpress/core-data");
15
+
14
16
  var _combobox = _interopRequireDefault(require("./combobox"));
15
17
 
16
18
  var _select = _interopRequireDefault(require("./select"));
@@ -26,10 +28,8 @@ var minimumUsersForCombobox = 25;
26
28
 
27
29
  function PostAuthor() {
28
30
  var showCombobox = (0, _data.useSelect)(function (select) {
29
- var authors = select('core').getUsers({
30
- who: 'authors',
31
- per_page: minimumUsersForCombobox + 1
32
- });
31
+ // Not using `getUsers()` because it requires `list_users` capability.
32
+ var authors = select(_coreData.store).getAuthors();
33
33
  return (authors === null || authors === void 0 ? void 0 : authors.length) >= minimumUsersForCombobox;
34
34
  }, []);
35
35
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-author/index.js"],"names":["minimumUsersForCombobox","PostAuthor","showCombobox","select","authors","getUsers","who","per_page","length"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;AAIA,IAAMA,uBAAuB,GAAG,EAAhC;;AAEA,SAASC,UAAT,GAAsB;AACrB,MAAMC,YAAY,GAAG,qBAAW,UAAEC,MAAF,EAAc;AAC7C,QAAMC,OAAO,GAAGD,MAAM,CAAE,MAAF,CAAN,CAAiBE,QAAjB,CAA2B;AAC1CC,MAAAA,GAAG,EAAE,SADqC;AAE1CC,MAAAA,QAAQ,EAAEP,uBAAuB,GAAG;AAFM,KAA3B,CAAhB;AAIA,WAAO,CAAAI,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEI,MAAT,KAAmBR,uBAA1B;AACA,GANoB,EAMlB,EANkB,CAArB;;AAQA,MAAKE,YAAL,EAAoB;AACnB,WAAO,4BAAC,iBAAD,OAAP;AACA;;AACD,SAAO,4BAAC,eAAD,OAAP;AACA;;eAEcD,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport PostAuthorCombobox from './combobox';\nimport PostAuthorSelect from './select';\n\nconst minimumUsersForCombobox = 25;\n\nfunction PostAuthor() {\n\tconst showCombobox = useSelect( ( select ) => {\n\t\tconst authors = select( 'core' ).getUsers( {\n\t\t\twho: 'authors',\n\t\t\tper_page: minimumUsersForCombobox + 1,\n\t\t} );\n\t\treturn authors?.length >= minimumUsersForCombobox;\n\t}, [] );\n\n\tif ( showCombobox ) {\n\t\treturn <PostAuthorCombobox />;\n\t}\n\treturn <PostAuthorSelect />;\n}\n\nexport default PostAuthor;\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-author/index.js"],"names":["minimumUsersForCombobox","PostAuthor","showCombobox","select","authors","coreStore","getAuthors","length"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIA,IAAMA,uBAAuB,GAAG,EAAhC;;AAEA,SAASC,UAAT,GAAsB;AACrB,MAAMC,YAAY,GAAG,qBAAW,UAAEC,MAAF,EAAc;AAC7C;AACA,QAAMC,OAAO,GAAGD,MAAM,CAAEE,eAAF,CAAN,CAAoBC,UAApB,EAAhB;AACA,WAAO,CAAAF,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEG,MAAT,KAAmBP,uBAA1B;AACA,GAJoB,EAIlB,EAJkB,CAArB;;AAMA,MAAKE,YAAL,EAAoB;AACnB,WAAO,4BAAC,iBAAD,OAAP;AACA;;AACD,SAAO,4BAAC,eAAD,OAAP;AACA;;eAEcD,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostAuthorCombobox from './combobox';\nimport PostAuthorSelect from './select';\n\nconst minimumUsersForCombobox = 25;\n\nfunction PostAuthor() {\n\tconst showCombobox = useSelect( ( select ) => {\n\t\t// Not using `getUsers()` because it requires `list_users` capability.\n\t\tconst authors = select( coreStore ).getAuthors();\n\t\treturn authors?.length >= minimumUsersForCombobox;\n\t}, [] );\n\n\tif ( showCombobox ) {\n\t\treturn <PostAuthorCombobox />;\n\t}\n\treturn <PostAuthorSelect />;\n}\n\nexport default PostAuthor;\n"]}
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = PostTextEditor;
9
- exports.DEBOUNCE_TIME = void 0;
10
9
 
11
10
  var _element = require("@wordpress/element");
12
11
 
@@ -31,9 +30,6 @@ var _components = require("@wordpress/components");
31
30
  /**
32
31
  * WordPress dependencies
33
32
  */
34
- var DEBOUNCE_TIME = 300;
35
- exports.DEBOUNCE_TIME = DEBOUNCE_TIME;
36
-
37
33
  function PostTextEditor() {
38
34
  var postContent = (0, _data.useSelect)(function (select) {
39
35
  return select('core/editor').getEditedPostContent();
@@ -58,18 +54,6 @@ function PostTextEditor() {
58
54
  if (!isDirty && value !== postContent) {
59
55
  setValue(postContent);
60
56
  }
61
-
62
- var saveText = function saveText() {
63
- var blocks = (0, _blocks.parse)(value);
64
- resetEditorBlocks(blocks);
65
- };
66
-
67
- (0, _element.useEffect)(function () {
68
- var timeoutId = setTimeout(saveText, DEBOUNCE_TIME);
69
- return function () {
70
- clearTimeout(timeoutId);
71
- };
72
- }, [value]);
73
57
  /**
74
58
  * Handles a textarea change event to notify the onChange prop callback and
75
59
  * reflect the new value in the component's own state. This marks the start
@@ -82,6 +66,7 @@ function PostTextEditor() {
82
66
  * @param {Event} event Change event.
83
67
  */
84
68
 
69
+
85
70
  var onChange = function onChange(event) {
86
71
  var newValue = event.target.value;
87
72
  editPost({
@@ -99,7 +84,8 @@ function PostTextEditor() {
99
84
 
100
85
  var stopEditing = function stopEditing() {
101
86
  if (isDirty) {
102
- saveText();
87
+ var blocks = (0, _blocks.parse)(value);
88
+ resetEditorBlocks(blocks);
103
89
  setIsDirty(false);
104
90
  }
105
91
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-text-editor/index.js"],"names":["DEBOUNCE_TIME","PostTextEditor","postContent","select","getEditedPostContent","editPost","resetEditorBlocks","value","setValue","isDirty","setIsDirty","instanceId","saveText","blocks","timeoutId","setTimeout","clearTimeout","onChange","event","newValue","target","content","stopEditing"],"mappings":";;;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;AAQO,IAAMA,aAAa,GAAG,GAAtB;;;AACQ,SAASC,cAAT,GAA0B;AACxC,MAAMC,WAAW,GAAG,qBACnB,UAAEC,MAAF;AAAA,WAAcA,MAAM,CAAE,aAAF,CAAN,CAAwBC,oBAAxB,EAAd;AAAA,GADmB,EAEnB,EAFmB,CAApB;;AADwC,qBAMA,uBAAa,aAAb,CANA;AAAA,MAMhCC,QANgC,gBAMhCA,QANgC;AAAA,MAMtBC,iBANsB,gBAMtBA,iBANsB;;AAAA,kBAQZ,uBAAUJ,WAAV,CARY;AAAA;AAAA,MAQhCK,KARgC;AAAA,MAQzBC,QARyB;;AAAA,mBASR,uBAAU,KAAV,CATQ;AAAA;AAAA,MAShCC,OATgC;AAAA,MASvBC,UATuB;;AAUxC,MAAMC,UAAU,GAAG,4BAAeV,cAAf,CAAnB;;AAEA,MAAK,CAAEQ,OAAF,IAAaF,KAAK,KAAKL,WAA5B,EAA0C;AACzCM,IAAAA,QAAQ,CAAEN,WAAF,CAAR;AACA;;AAED,MAAMU,QAAQ,GAAG,SAAXA,QAAW,GAAM;AACtB,QAAMC,MAAM,GAAG,mBAAON,KAAP,CAAf;AACAD,IAAAA,iBAAiB,CAAEO,MAAF,CAAjB;AACA,GAHD;;AAKA,0BAAW,YAAM;AAChB,QAAMC,SAAS,GAAGC,UAAU,CAAEH,QAAF,EAAYZ,aAAZ,CAA5B;AACA,WAAO,YAAM;AACZgB,MAAAA,YAAY,CAAEF,SAAF,CAAZ;AACA,KAFD;AAGA,GALD,EAKG,CAAEP,KAAF,CALH;AAOA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACC,MAAMU,QAAQ,GAAG,SAAXA,QAAW,CAAEC,KAAF,EAAa;AAC7B,QAAMC,QAAQ,GAAGD,KAAK,CAACE,MAAN,CAAab,KAA9B;AACAF,IAAAA,QAAQ,CAAE;AAAEgB,MAAAA,OAAO,EAAEF;AAAX,KAAF,CAAR;AACAX,IAAAA,QAAQ,CAAEW,QAAF,CAAR;AACAT,IAAAA,UAAU,CAAE,IAAF,CAAV;AACA,GALD;AAOA;AACD;AACA;AACA;AACA;;;AACC,MAAMY,WAAW,GAAG,SAAdA,WAAc,GAAM;AACzB,QAAKb,OAAL,EAAe;AACdG,MAAAA,QAAQ;AACRF,MAAAA,UAAU,CAAE,KAAF,CAAV;AACA;AACD,GALD;;AAOA,SACC,qDACC,4BAAC,0BAAD;AACC,IAAA,EAAE,EAAC,OADJ;AAEC,IAAA,OAAO,yBAAoBC,UAApB;AAFR,KAIG,cAAI,mBAAJ,CAJH,CADD,EAOC,4BAAC,8BAAD;AACC,IAAA,YAAY,EAAC,KADd;AAEC,IAAA,GAAG,EAAC,MAFL;AAGC,IAAA,KAAK,EAAGJ,KAHT;AAIC,IAAA,QAAQ,EAAGU,QAJZ;AAKC,IAAA,MAAM,EAAGK,WALV;AAMC,IAAA,SAAS,EAAC,yBANX;AAOC,IAAA,EAAE,yBAAoBX,UAApB,CAPH;AAQC,IAAA,WAAW,EAAG,cAAI,iCAAJ;AARf,IAPD,CADD;AAoBA","sourcesContent":["/**\n * External dependencies\n */\nimport Textarea from 'react-autosize-textarea';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { parse } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/components';\n\nexport const DEBOUNCE_TIME = 300;\nexport default function PostTextEditor() {\n\tconst postContent = useSelect(\n\t\t( select ) => select( 'core/editor' ).getEditedPostContent(),\n\t\t[]\n\t);\n\n\tconst { editPost, resetEditorBlocks } = useDispatch( 'core/editor' );\n\n\tconst [ value, setValue ] = useState( postContent );\n\tconst [ isDirty, setIsDirty ] = useState( false );\n\tconst instanceId = useInstanceId( PostTextEditor );\n\n\tif ( ! isDirty && value !== postContent ) {\n\t\tsetValue( postContent );\n\t}\n\n\tconst saveText = () => {\n\t\tconst blocks = parse( value );\n\t\tresetEditorBlocks( blocks );\n\t};\n\n\tuseEffect( () => {\n\t\tconst timeoutId = setTimeout( saveText, DEBOUNCE_TIME );\n\t\treturn () => {\n\t\t\tclearTimeout( timeoutId );\n\t\t};\n\t}, [ value ] );\n\n\t/**\n\t * Handles a textarea change event to notify the onChange prop callback and\n\t * reflect the new value in the component's own state. This marks the start\n\t * of the user's edits, if not already changed, preventing future props\n\t * changes to value from replacing the rendered value. This is expected to\n\t * be followed by a reset to dirty state via `stopEditing`.\n\t *\n\t * @see stopEditing\n\t *\n\t * @param {Event} event Change event.\n\t */\n\tconst onChange = ( event ) => {\n\t\tconst newValue = event.target.value;\n\t\teditPost( { content: newValue } );\n\t\tsetValue( newValue );\n\t\tsetIsDirty( true );\n\t};\n\n\t/**\n\t * Function called when the user has completed their edits, responsible for\n\t * ensuring that changes, if made, are surfaced to the onPersist prop\n\t * callback and resetting dirty state.\n\t */\n\tconst stopEditing = () => {\n\t\tif ( isDirty ) {\n\t\t\tsaveText();\n\t\t\tsetIsDirty( false );\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<VisuallyHidden\n\t\t\t\tas=\"label\"\n\t\t\t\thtmlFor={ `post-content-${ instanceId }` }\n\t\t\t>\n\t\t\t\t{ __( 'Type text or HTML' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<Textarea\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\tdir=\"auto\"\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonBlur={ stopEditing }\n\t\t\t\tclassName=\"editor-post-text-editor\"\n\t\t\t\tid={ `post-content-${ instanceId }` }\n\t\t\t\tplaceholder={ __( 'Start writing with text or HTML' ) }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-text-editor/index.js"],"names":["PostTextEditor","postContent","select","getEditedPostContent","editPost","resetEditorBlocks","value","setValue","isDirty","setIsDirty","instanceId","onChange","event","newValue","target","content","stopEditing","blocks"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;AAQe,SAASA,cAAT,GAA0B;AACxC,MAAMC,WAAW,GAAG,qBACnB,UAAEC,MAAF;AAAA,WAAcA,MAAM,CAAE,aAAF,CAAN,CAAwBC,oBAAxB,EAAd;AAAA,GADmB,EAEnB,EAFmB,CAApB;;AADwC,qBAMA,uBAAa,aAAb,CANA;AAAA,MAMhCC,QANgC,gBAMhCA,QANgC;AAAA,MAMtBC,iBANsB,gBAMtBA,iBANsB;;AAAA,kBAQZ,uBAAUJ,WAAV,CARY;AAAA;AAAA,MAQhCK,KARgC;AAAA,MAQzBC,QARyB;;AAAA,mBASR,uBAAU,KAAV,CATQ;AAAA;AAAA,MAShCC,OATgC;AAAA,MASvBC,UATuB;;AAUxC,MAAMC,UAAU,GAAG,4BAAeV,cAAf,CAAnB;;AAEA,MAAK,CAAEQ,OAAF,IAAaF,KAAK,KAAKL,WAA5B,EAA0C;AACzCM,IAAAA,QAAQ,CAAEN,WAAF,CAAR;AACA;AAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,MAAMU,QAAQ,GAAG,SAAXA,QAAW,CAAEC,KAAF,EAAa;AAC7B,QAAMC,QAAQ,GAAGD,KAAK,CAACE,MAAN,CAAaR,KAA9B;AACAF,IAAAA,QAAQ,CAAE;AAAEW,MAAAA,OAAO,EAAEF;AAAX,KAAF,CAAR;AACAN,IAAAA,QAAQ,CAAEM,QAAF,CAAR;AACAJ,IAAAA,UAAU,CAAE,IAAF,CAAV;AACA,GALD;AAOA;AACD;AACA;AACA;AACA;;;AACC,MAAMO,WAAW,GAAG,SAAdA,WAAc,GAAM;AACzB,QAAKR,OAAL,EAAe;AACd,UAAMS,MAAM,GAAG,mBAAOX,KAAP,CAAf;AACAD,MAAAA,iBAAiB,CAAEY,MAAF,CAAjB;AACAR,MAAAA,UAAU,CAAE,KAAF,CAAV;AACA;AACD,GAND;;AAQA,SACC,qDACC,4BAAC,0BAAD;AACC,IAAA,EAAE,EAAC,OADJ;AAEC,IAAA,OAAO,yBAAoBC,UAApB;AAFR,KAIG,cAAI,mBAAJ,CAJH,CADD,EAOC,4BAAC,8BAAD;AACC,IAAA,YAAY,EAAC,KADd;AAEC,IAAA,GAAG,EAAC,MAFL;AAGC,IAAA,KAAK,EAAGJ,KAHT;AAIC,IAAA,QAAQ,EAAGK,QAJZ;AAKC,IAAA,MAAM,EAAGK,WALV;AAMC,IAAA,SAAS,EAAC,yBANX;AAOC,IAAA,EAAE,yBAAoBN,UAApB,CAPH;AAQC,IAAA,WAAW,EAAG,cAAI,iCAAJ;AARf,IAPD,CADD;AAoBA","sourcesContent":["/**\n * External dependencies\n */\nimport Textarea from 'react-autosize-textarea';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { parse } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/components';\n\nexport default function PostTextEditor() {\n\tconst postContent = useSelect(\n\t\t( select ) => select( 'core/editor' ).getEditedPostContent(),\n\t\t[]\n\t);\n\n\tconst { editPost, resetEditorBlocks } = useDispatch( 'core/editor' );\n\n\tconst [ value, setValue ] = useState( postContent );\n\tconst [ isDirty, setIsDirty ] = useState( false );\n\tconst instanceId = useInstanceId( PostTextEditor );\n\n\tif ( ! isDirty && value !== postContent ) {\n\t\tsetValue( postContent );\n\t}\n\n\t/**\n\t * Handles a textarea change event to notify the onChange prop callback and\n\t * reflect the new value in the component's own state. This marks the start\n\t * of the user's edits, if not already changed, preventing future props\n\t * changes to value from replacing the rendered value. This is expected to\n\t * be followed by a reset to dirty state via `stopEditing`.\n\t *\n\t * @see stopEditing\n\t *\n\t * @param {Event} event Change event.\n\t */\n\tconst onChange = ( event ) => {\n\t\tconst newValue = event.target.value;\n\t\teditPost( { content: newValue } );\n\t\tsetValue( newValue );\n\t\tsetIsDirty( true );\n\t};\n\n\t/**\n\t * Function called when the user has completed their edits, responsible for\n\t * ensuring that changes, if made, are surfaced to the onPersist prop\n\t * callback and resetting dirty state.\n\t */\n\tconst stopEditing = () => {\n\t\tif ( isDirty ) {\n\t\t\tconst blocks = parse( value );\n\t\t\tresetEditorBlocks( blocks );\n\t\t\tsetIsDirty( false );\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<VisuallyHidden\n\t\t\t\tas=\"label\"\n\t\t\t\thtmlFor={ `post-content-${ instanceId }` }\n\t\t\t>\n\t\t\t\t{ __( 'Type text or HTML' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<Textarea\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\tdir=\"auto\"\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonBlur={ stopEditing }\n\t\t\t\tclassName=\"editor-post-text-editor\"\n\t\t\t\tid={ `post-content-${ instanceId }` }\n\t\t\t\tplaceholder={ __( 'Start writing with text or HTML' ) }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
@@ -4,6 +4,7 @@ import { createElement } from "@wordpress/element";
4
4
  * WordPress dependencies
5
5
  */
6
6
  import { useSelect } from '@wordpress/data';
7
+ import { store as coreStore } from '@wordpress/core-data';
7
8
  /**
8
9
  * Internal dependencies
9
10
  */
@@ -14,10 +15,8 @@ var minimumUsersForCombobox = 25;
14
15
 
15
16
  function PostAuthor() {
16
17
  var showCombobox = useSelect(function (select) {
17
- var authors = select('core').getUsers({
18
- who: 'authors',
19
- per_page: minimumUsersForCombobox + 1
20
- });
18
+ // Not using `getUsers()` because it requires `list_users` capability.
19
+ var authors = select(coreStore).getAuthors();
21
20
  return (authors === null || authors === void 0 ? void 0 : authors.length) >= minimumUsersForCombobox;
22
21
  }, []);
23
22
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-author/index.js"],"names":["useSelect","PostAuthorCombobox","PostAuthorSelect","minimumUsersForCombobox","PostAuthor","showCombobox","select","authors","getUsers","who","per_page","length"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,YAA/B;AACA,OAAOC,gBAAP,MAA6B,UAA7B;AAEA,IAAMC,uBAAuB,GAAG,EAAhC;;AAEA,SAASC,UAAT,GAAsB;AACrB,MAAMC,YAAY,GAAGL,SAAS,CAAE,UAAEM,MAAF,EAAc;AAC7C,QAAMC,OAAO,GAAGD,MAAM,CAAE,MAAF,CAAN,CAAiBE,QAAjB,CAA2B;AAC1CC,MAAAA,GAAG,EAAE,SADqC;AAE1CC,MAAAA,QAAQ,EAAEP,uBAAuB,GAAG;AAFM,KAA3B,CAAhB;AAIA,WAAO,CAAAI,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEI,MAAT,KAAmBR,uBAA1B;AACA,GAN6B,EAM3B,EAN2B,CAA9B;;AAQA,MAAKE,YAAL,EAAoB;AACnB,WAAO,cAAC,kBAAD,OAAP;AACA;;AACD,SAAO,cAAC,gBAAD,OAAP;AACA;;AAED,eAAeD,UAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport PostAuthorCombobox from './combobox';\nimport PostAuthorSelect from './select';\n\nconst minimumUsersForCombobox = 25;\n\nfunction PostAuthor() {\n\tconst showCombobox = useSelect( ( select ) => {\n\t\tconst authors = select( 'core' ).getUsers( {\n\t\t\twho: 'authors',\n\t\t\tper_page: minimumUsersForCombobox + 1,\n\t\t} );\n\t\treturn authors?.length >= minimumUsersForCombobox;\n\t}, [] );\n\n\tif ( showCombobox ) {\n\t\treturn <PostAuthorCombobox />;\n\t}\n\treturn <PostAuthorSelect />;\n}\n\nexport default PostAuthor;\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-author/index.js"],"names":["useSelect","store","coreStore","PostAuthorCombobox","PostAuthorSelect","minimumUsersForCombobox","PostAuthor","showCombobox","select","authors","getAuthors","length"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,YAA/B;AACA,OAAOC,gBAAP,MAA6B,UAA7B;AAEA,IAAMC,uBAAuB,GAAG,EAAhC;;AAEA,SAASC,UAAT,GAAsB;AACrB,MAAMC,YAAY,GAAGP,SAAS,CAAE,UAAEQ,MAAF,EAAc;AAC7C;AACA,QAAMC,OAAO,GAAGD,MAAM,CAAEN,SAAF,CAAN,CAAoBQ,UAApB,EAAhB;AACA,WAAO,CAAAD,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEE,MAAT,KAAmBN,uBAA1B;AACA,GAJ6B,EAI3B,EAJ2B,CAA9B;;AAMA,MAAKE,YAAL,EAAoB;AACnB,WAAO,cAAC,kBAAD,OAAP;AACA;;AACD,SAAO,cAAC,gBAAD,OAAP;AACA;;AAED,eAAeD,UAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostAuthorCombobox from './combobox';\nimport PostAuthorSelect from './select';\n\nconst minimumUsersForCombobox = 25;\n\nfunction PostAuthor() {\n\tconst showCombobox = useSelect( ( select ) => {\n\t\t// Not using `getUsers()` because it requires `list_users` capability.\n\t\tconst authors = select( coreStore ).getAuthors();\n\t\treturn authors?.length >= minimumUsersForCombobox;\n\t}, [] );\n\n\tif ( showCombobox ) {\n\t\treturn <PostAuthorCombobox />;\n\t}\n\treturn <PostAuthorSelect />;\n}\n\nexport default PostAuthor;\n"]}
@@ -10,12 +10,11 @@ import Textarea from 'react-autosize-textarea';
10
10
  */
11
11
 
12
12
  import { __ } from '@wordpress/i18n';
13
- import { useState, useEffect } from '@wordpress/element';
13
+ import { useState } from '@wordpress/element';
14
14
  import { parse } from '@wordpress/blocks';
15
15
  import { useDispatch, useSelect } from '@wordpress/data';
16
16
  import { useInstanceId } from '@wordpress/compose';
17
17
  import { VisuallyHidden } from '@wordpress/components';
18
- export var DEBOUNCE_TIME = 300;
19
18
  export default function PostTextEditor() {
20
19
  var postContent = useSelect(function (select) {
21
20
  return select('core/editor').getEditedPostContent();
@@ -40,18 +39,6 @@ export default function PostTextEditor() {
40
39
  if (!isDirty && value !== postContent) {
41
40
  setValue(postContent);
42
41
  }
43
-
44
- var saveText = function saveText() {
45
- var blocks = parse(value);
46
- resetEditorBlocks(blocks);
47
- };
48
-
49
- useEffect(function () {
50
- var timeoutId = setTimeout(saveText, DEBOUNCE_TIME);
51
- return function () {
52
- clearTimeout(timeoutId);
53
- };
54
- }, [value]);
55
42
  /**
56
43
  * Handles a textarea change event to notify the onChange prop callback and
57
44
  * reflect the new value in the component's own state. This marks the start
@@ -64,6 +51,7 @@ export default function PostTextEditor() {
64
51
  * @param {Event} event Change event.
65
52
  */
66
53
 
54
+
67
55
  var onChange = function onChange(event) {
68
56
  var newValue = event.target.value;
69
57
  editPost({
@@ -81,7 +69,8 @@ export default function PostTextEditor() {
81
69
 
82
70
  var stopEditing = function stopEditing() {
83
71
  if (isDirty) {
84
- saveText();
72
+ var blocks = parse(value);
73
+ resetEditorBlocks(blocks);
85
74
  setIsDirty(false);
86
75
  }
87
76
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-text-editor/index.js"],"names":["Textarea","__","useState","useEffect","parse","useDispatch","useSelect","useInstanceId","VisuallyHidden","DEBOUNCE_TIME","PostTextEditor","postContent","select","getEditedPostContent","editPost","resetEditorBlocks","value","setValue","isDirty","setIsDirty","instanceId","saveText","blocks","timeoutId","setTimeout","clearTimeout","onChange","event","newValue","target","content","stopEditing"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,QAAP,MAAqB,yBAArB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,KAAT,QAAsB,mBAAtB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,cAAT,QAA+B,uBAA/B;AAEA,OAAO,IAAMC,aAAa,GAAG,GAAtB;AACP,eAAe,SAASC,cAAT,GAA0B;AACxC,MAAMC,WAAW,GAAGL,SAAS,CAC5B,UAAEM,MAAF;AAAA,WAAcA,MAAM,CAAE,aAAF,CAAN,CAAwBC,oBAAxB,EAAd;AAAA,GAD4B,EAE5B,EAF4B,CAA7B;;AADwC,qBAMAR,WAAW,CAAE,aAAF,CANX;AAAA,MAMhCS,QANgC,gBAMhCA,QANgC;AAAA,MAMtBC,iBANsB,gBAMtBA,iBANsB;;AAAA,kBAQZb,QAAQ,CAAES,WAAF,CARI;AAAA;AAAA,MAQhCK,KARgC;AAAA,MAQzBC,QARyB;;AAAA,mBASRf,QAAQ,CAAE,KAAF,CATA;AAAA;AAAA,MAShCgB,OATgC;AAAA,MASvBC,UATuB;;AAUxC,MAAMC,UAAU,GAAGb,aAAa,CAAEG,cAAF,CAAhC;;AAEA,MAAK,CAAEQ,OAAF,IAAaF,KAAK,KAAKL,WAA5B,EAA0C;AACzCM,IAAAA,QAAQ,CAAEN,WAAF,CAAR;AACA;;AAED,MAAMU,QAAQ,GAAG,SAAXA,QAAW,GAAM;AACtB,QAAMC,MAAM,GAAGlB,KAAK,CAAEY,KAAF,CAApB;AACAD,IAAAA,iBAAiB,CAAEO,MAAF,CAAjB;AACA,GAHD;;AAKAnB,EAAAA,SAAS,CAAE,YAAM;AAChB,QAAMoB,SAAS,GAAGC,UAAU,CAAEH,QAAF,EAAYZ,aAAZ,CAA5B;AACA,WAAO,YAAM;AACZgB,MAAAA,YAAY,CAAEF,SAAF,CAAZ;AACA,KAFD;AAGA,GALQ,EAKN,CAAEP,KAAF,CALM,CAAT;AAOA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACC,MAAMU,QAAQ,GAAG,SAAXA,QAAW,CAAEC,KAAF,EAAa;AAC7B,QAAMC,QAAQ,GAAGD,KAAK,CAACE,MAAN,CAAab,KAA9B;AACAF,IAAAA,QAAQ,CAAE;AAAEgB,MAAAA,OAAO,EAAEF;AAAX,KAAF,CAAR;AACAX,IAAAA,QAAQ,CAAEW,QAAF,CAAR;AACAT,IAAAA,UAAU,CAAE,IAAF,CAAV;AACA,GALD;AAOA;AACD;AACA;AACA;AACA;;;AACC,MAAMY,WAAW,GAAG,SAAdA,WAAc,GAAM;AACzB,QAAKb,OAAL,EAAe;AACdG,MAAAA,QAAQ;AACRF,MAAAA,UAAU,CAAE,KAAF,CAAV;AACA;AACD,GALD;;AAOA,SACC,8BACC,cAAC,cAAD;AACC,IAAA,EAAE,EAAC,OADJ;AAEC,IAAA,OAAO,yBAAoBC,UAApB;AAFR,KAIGnB,EAAE,CAAE,mBAAF,CAJL,CADD,EAOC,cAAC,QAAD;AACC,IAAA,YAAY,EAAC,KADd;AAEC,IAAA,GAAG,EAAC,MAFL;AAGC,IAAA,KAAK,EAAGe,KAHT;AAIC,IAAA,QAAQ,EAAGU,QAJZ;AAKC,IAAA,MAAM,EAAGK,WALV;AAMC,IAAA,SAAS,EAAC,yBANX;AAOC,IAAA,EAAE,yBAAoBX,UAApB,CAPH;AAQC,IAAA,WAAW,EAAGnB,EAAE,CAAE,iCAAF;AARjB,IAPD,CADD;AAoBA","sourcesContent":["/**\n * External dependencies\n */\nimport Textarea from 'react-autosize-textarea';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { parse } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/components';\n\nexport const DEBOUNCE_TIME = 300;\nexport default function PostTextEditor() {\n\tconst postContent = useSelect(\n\t\t( select ) => select( 'core/editor' ).getEditedPostContent(),\n\t\t[]\n\t);\n\n\tconst { editPost, resetEditorBlocks } = useDispatch( 'core/editor' );\n\n\tconst [ value, setValue ] = useState( postContent );\n\tconst [ isDirty, setIsDirty ] = useState( false );\n\tconst instanceId = useInstanceId( PostTextEditor );\n\n\tif ( ! isDirty && value !== postContent ) {\n\t\tsetValue( postContent );\n\t}\n\n\tconst saveText = () => {\n\t\tconst blocks = parse( value );\n\t\tresetEditorBlocks( blocks );\n\t};\n\n\tuseEffect( () => {\n\t\tconst timeoutId = setTimeout( saveText, DEBOUNCE_TIME );\n\t\treturn () => {\n\t\t\tclearTimeout( timeoutId );\n\t\t};\n\t}, [ value ] );\n\n\t/**\n\t * Handles a textarea change event to notify the onChange prop callback and\n\t * reflect the new value in the component's own state. This marks the start\n\t * of the user's edits, if not already changed, preventing future props\n\t * changes to value from replacing the rendered value. This is expected to\n\t * be followed by a reset to dirty state via `stopEditing`.\n\t *\n\t * @see stopEditing\n\t *\n\t * @param {Event} event Change event.\n\t */\n\tconst onChange = ( event ) => {\n\t\tconst newValue = event.target.value;\n\t\teditPost( { content: newValue } );\n\t\tsetValue( newValue );\n\t\tsetIsDirty( true );\n\t};\n\n\t/**\n\t * Function called when the user has completed their edits, responsible for\n\t * ensuring that changes, if made, are surfaced to the onPersist prop\n\t * callback and resetting dirty state.\n\t */\n\tconst stopEditing = () => {\n\t\tif ( isDirty ) {\n\t\t\tsaveText();\n\t\t\tsetIsDirty( false );\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<VisuallyHidden\n\t\t\t\tas=\"label\"\n\t\t\t\thtmlFor={ `post-content-${ instanceId }` }\n\t\t\t>\n\t\t\t\t{ __( 'Type text or HTML' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<Textarea\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\tdir=\"auto\"\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonBlur={ stopEditing }\n\t\t\t\tclassName=\"editor-post-text-editor\"\n\t\t\t\tid={ `post-content-${ instanceId }` }\n\t\t\t\tplaceholder={ __( 'Start writing with text or HTML' ) }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-text-editor/index.js"],"names":["Textarea","__","useState","parse","useDispatch","useSelect","useInstanceId","VisuallyHidden","PostTextEditor","postContent","select","getEditedPostContent","editPost","resetEditorBlocks","value","setValue","isDirty","setIsDirty","instanceId","onChange","event","newValue","target","content","stopEditing","blocks"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,QAAP,MAAqB,yBAArB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,KAAT,QAAsB,mBAAtB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,cAAT,QAA+B,uBAA/B;AAEA,eAAe,SAASC,cAAT,GAA0B;AACxC,MAAMC,WAAW,GAAGJ,SAAS,CAC5B,UAAEK,MAAF;AAAA,WAAcA,MAAM,CAAE,aAAF,CAAN,CAAwBC,oBAAxB,EAAd;AAAA,GAD4B,EAE5B,EAF4B,CAA7B;;AADwC,qBAMAP,WAAW,CAAE,aAAF,CANX;AAAA,MAMhCQ,QANgC,gBAMhCA,QANgC;AAAA,MAMtBC,iBANsB,gBAMtBA,iBANsB;;AAAA,kBAQZX,QAAQ,CAAEO,WAAF,CARI;AAAA;AAAA,MAQhCK,KARgC;AAAA,MAQzBC,QARyB;;AAAA,mBASRb,QAAQ,CAAE,KAAF,CATA;AAAA;AAAA,MAShCc,OATgC;AAAA,MASvBC,UATuB;;AAUxC,MAAMC,UAAU,GAAGZ,aAAa,CAAEE,cAAF,CAAhC;;AAEA,MAAK,CAAEQ,OAAF,IAAaF,KAAK,KAAKL,WAA5B,EAA0C;AACzCM,IAAAA,QAAQ,CAAEN,WAAF,CAAR;AACA;AAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,MAAMU,QAAQ,GAAG,SAAXA,QAAW,CAAEC,KAAF,EAAa;AAC7B,QAAMC,QAAQ,GAAGD,KAAK,CAACE,MAAN,CAAaR,KAA9B;AACAF,IAAAA,QAAQ,CAAE;AAAEW,MAAAA,OAAO,EAAEF;AAAX,KAAF,CAAR;AACAN,IAAAA,QAAQ,CAAEM,QAAF,CAAR;AACAJ,IAAAA,UAAU,CAAE,IAAF,CAAV;AACA,GALD;AAOA;AACD;AACA;AACA;AACA;;;AACC,MAAMO,WAAW,GAAG,SAAdA,WAAc,GAAM;AACzB,QAAKR,OAAL,EAAe;AACd,UAAMS,MAAM,GAAGtB,KAAK,CAAEW,KAAF,CAApB;AACAD,MAAAA,iBAAiB,CAAEY,MAAF,CAAjB;AACAR,MAAAA,UAAU,CAAE,KAAF,CAAV;AACA;AACD,GAND;;AAQA,SACC,8BACC,cAAC,cAAD;AACC,IAAA,EAAE,EAAC,OADJ;AAEC,IAAA,OAAO,yBAAoBC,UAApB;AAFR,KAIGjB,EAAE,CAAE,mBAAF,CAJL,CADD,EAOC,cAAC,QAAD;AACC,IAAA,YAAY,EAAC,KADd;AAEC,IAAA,GAAG,EAAC,MAFL;AAGC,IAAA,KAAK,EAAGa,KAHT;AAIC,IAAA,QAAQ,EAAGK,QAJZ;AAKC,IAAA,MAAM,EAAGK,WALV;AAMC,IAAA,SAAS,EAAC,yBANX;AAOC,IAAA,EAAE,yBAAoBN,UAApB,CAPH;AAQC,IAAA,WAAW,EAAGjB,EAAE,CAAE,iCAAF;AARjB,IAPD,CADD;AAoBA","sourcesContent":["/**\n * External dependencies\n */\nimport Textarea from 'react-autosize-textarea';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { parse } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/components';\n\nexport default function PostTextEditor() {\n\tconst postContent = useSelect(\n\t\t( select ) => select( 'core/editor' ).getEditedPostContent(),\n\t\t[]\n\t);\n\n\tconst { editPost, resetEditorBlocks } = useDispatch( 'core/editor' );\n\n\tconst [ value, setValue ] = useState( postContent );\n\tconst [ isDirty, setIsDirty ] = useState( false );\n\tconst instanceId = useInstanceId( PostTextEditor );\n\n\tif ( ! isDirty && value !== postContent ) {\n\t\tsetValue( postContent );\n\t}\n\n\t/**\n\t * Handles a textarea change event to notify the onChange prop callback and\n\t * reflect the new value in the component's own state. This marks the start\n\t * of the user's edits, if not already changed, preventing future props\n\t * changes to value from replacing the rendered value. This is expected to\n\t * be followed by a reset to dirty state via `stopEditing`.\n\t *\n\t * @see stopEditing\n\t *\n\t * @param {Event} event Change event.\n\t */\n\tconst onChange = ( event ) => {\n\t\tconst newValue = event.target.value;\n\t\teditPost( { content: newValue } );\n\t\tsetValue( newValue );\n\t\tsetIsDirty( true );\n\t};\n\n\t/**\n\t * Function called when the user has completed their edits, responsible for\n\t * ensuring that changes, if made, are surfaced to the onPersist prop\n\t * callback and resetting dirty state.\n\t */\n\tconst stopEditing = () => {\n\t\tif ( isDirty ) {\n\t\t\tconst blocks = parse( value );\n\t\t\tresetEditorBlocks( blocks );\n\t\t\tsetIsDirty( false );\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<VisuallyHidden\n\t\t\t\tas=\"label\"\n\t\t\t\thtmlFor={ `post-content-${ instanceId }` }\n\t\t\t>\n\t\t\t\t{ __( 'Type text or HTML' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<Textarea\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\tdir=\"auto\"\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonBlur={ stopEditing }\n\t\t\t\tclassName=\"editor-post-text-editor\"\n\t\t\t\tid={ `post-content-${ instanceId }` }\n\t\t\t\tplaceholder={ __( 'Start writing with text or HTML' ) }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "9.25.11",
3
+ "version": "9.25.14",
4
4
  "description": "Building blocks for WordPress editors.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -28,16 +28,16 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "@babel/runtime": "^7.12.5",
31
- "@wordpress/api-fetch": "^3.21.5",
31
+ "@wordpress/api-fetch": "^3.21.6",
32
32
  "@wordpress/autop": "^2.11.1",
33
33
  "@wordpress/blob": "^2.12.1",
34
- "@wordpress/block-editor": "^5.2.11",
35
- "@wordpress/blocks": "^7.0.6",
36
- "@wordpress/components": "^12.0.8",
37
- "@wordpress/compose": "^3.24.5",
38
- "@wordpress/core-data": "^2.25.9",
39
- "@wordpress/data": "^4.26.8",
40
- "@wordpress/data-controls": "^1.20.8",
34
+ "@wordpress/block-editor": "^5.2.13",
35
+ "@wordpress/blocks": "^7.0.7",
36
+ "@wordpress/components": "^12.0.9",
37
+ "@wordpress/compose": "^3.24.6",
38
+ "@wordpress/core-data": "^2.25.11",
39
+ "@wordpress/data": "^4.26.9",
40
+ "@wordpress/data-controls": "^1.20.10",
41
41
  "@wordpress/date": "^3.13.1",
42
42
  "@wordpress/deprecated": "^2.11.1",
43
43
  "@wordpress/element": "^2.19.1",
@@ -46,14 +46,14 @@
46
46
  "@wordpress/i18n": "^3.18.0",
47
47
  "@wordpress/icons": "^2.9.1",
48
48
  "@wordpress/is-shallow-equal": "^3.0.1",
49
- "@wordpress/keyboard-shortcuts": "^1.13.8",
49
+ "@wordpress/keyboard-shortcuts": "^1.13.9",
50
50
  "@wordpress/keycodes": "^2.18.3",
51
- "@wordpress/media-utils": "^1.19.5",
52
- "@wordpress/notices": "^2.12.8",
53
- "@wordpress/reusable-blocks": "^1.1.11",
54
- "@wordpress/rich-text": "^3.24.8",
55
- "@wordpress/server-side-render": "^1.20.8",
56
- "@wordpress/url": "^2.21.2",
51
+ "@wordpress/media-utils": "^1.19.6",
52
+ "@wordpress/notices": "^2.12.9",
53
+ "@wordpress/reusable-blocks": "^1.1.13",
54
+ "@wordpress/rich-text": "^3.24.9",
55
+ "@wordpress/server-side-render": "^1.20.10",
56
+ "@wordpress/url": "^2.21.3",
57
57
  "@wordpress/wordcount": "^2.14.1",
58
58
  "classnames": "^2.2.5",
59
59
  "lodash": "^4.17.19",
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "b46033c6a1f28897b809cd1b1c43241544f7a940"
67
+ "gitHead": "14a64efc7cf32f4d37400902a7c1cbb822bc5c2f"
68
68
  }
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useSelect } from '@wordpress/data';
5
+ import { store as coreStore } from '@wordpress/core-data';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -13,10 +14,8 @@ const minimumUsersForCombobox = 25;
13
14
 
14
15
  function PostAuthor() {
15
16
  const showCombobox = useSelect( ( select ) => {
16
- const authors = select( 'core' ).getUsers( {
17
- who: 'authors',
18
- per_page: minimumUsersForCombobox + 1,
19
- } );
17
+ // Not using `getUsers()` because it requires `list_users` capability.
18
+ const authors = select( coreStore ).getAuthors();
20
19
  return authors?.length >= minimumUsersForCombobox;
21
20
  }, [] );
22
21
 
@@ -7,13 +7,12 @@ import Textarea from 'react-autosize-textarea';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { __ } from '@wordpress/i18n';
10
- import { useState, useEffect } from '@wordpress/element';
10
+ import { useState } from '@wordpress/element';
11
11
  import { parse } from '@wordpress/blocks';
12
12
  import { useDispatch, useSelect } from '@wordpress/data';
13
13
  import { useInstanceId } from '@wordpress/compose';
14
14
  import { VisuallyHidden } from '@wordpress/components';
15
15
 
16
- export const DEBOUNCE_TIME = 300;
17
16
  export default function PostTextEditor() {
18
17
  const postContent = useSelect(
19
18
  ( select ) => select( 'core/editor' ).getEditedPostContent(),
@@ -30,18 +29,6 @@ export default function PostTextEditor() {
30
29
  setValue( postContent );
31
30
  }
32
31
 
33
- const saveText = () => {
34
- const blocks = parse( value );
35
- resetEditorBlocks( blocks );
36
- };
37
-
38
- useEffect( () => {
39
- const timeoutId = setTimeout( saveText, DEBOUNCE_TIME );
40
- return () => {
41
- clearTimeout( timeoutId );
42
- };
43
- }, [ value ] );
44
-
45
32
  /**
46
33
  * Handles a textarea change event to notify the onChange prop callback and
47
34
  * reflect the new value in the component's own state. This marks the start
@@ -67,7 +54,8 @@ export default function PostTextEditor() {
67
54
  */
68
55
  const stopEditing = () => {
69
56
  if ( isDirty ) {
70
- saveText();
57
+ const blocks = parse( value );
58
+ resetEditorBlocks( blocks );
71
59
  setIsDirty( false );
72
60
  }
73
61
  };
@@ -7,14 +7,13 @@ import Textarea from 'react-autosize-textarea';
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
- import * as wp from '@wordpress/data';
10
+ import { useSelect } from '@wordpress/data';
11
11
 
12
12
  /**
13
13
  * Internal dependencies
14
14
  */
15
- import PostTextEditor, { DEBOUNCE_TIME } from '../';
15
+ import PostTextEditor from '../';
16
16
 
17
- const useSelect = wp.useSelect;
18
17
  // "Downgrade" ReactAutosizeTextarea to a regular textarea. Assumes aligned
19
18
  // props interface.
20
19
  jest.mock( 'react-autosize-textarea', () => ( props ) => (
@@ -176,23 +175,4 @@ describe( 'PostTextEditor', () => {
176
175
 
177
176
  expect( textarea.props.value ).toBe( 'Goodbye World' );
178
177
  } );
179
- it( 'debounce value update after given time', () => {
180
- let wrapper;
181
- act( () => {
182
- wrapper = create( <PostTextEditor /> );
183
- } );
184
- const mockDispatchFn = jest.fn();
185
- jest.mock( '@wordpress/data/src/components/use-dispatch', () => ( {
186
- useDispatch: () => ( {
187
- editPost: jest.fn(),
188
- resetEditorBlocks: mockDispatchFn,
189
- } ),
190
- } ) );
191
-
192
- const textarea = wrapper.root.findByType( Textarea );
193
- act( () => textarea.props.onChange( { target: { value: 'text' } } ) );
194
- setTimeout( () => {
195
- expect( mockDispatchFn ).toHaveBeenCalled();
196
- }, DEBOUNCE_TIME );
197
- } );
198
178
  } );