@wordpress/list-reusable-blocks 4.22.0 → 4.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.24.0 (2023-11-29)
6
+
7
+ ## 4.23.0 (2023-11-16)
8
+
5
9
  ## 4.22.0 (2023-11-02)
6
10
 
7
11
  ## 4.21.0 (2023-10-18)
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _changeCase = require("change-case");
9
9
  var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
10
- var _file = require("./file");
10
+ var _blob = require("@wordpress/blob");
11
11
  /**
12
12
  * External dependencies
13
13
  */
@@ -42,7 +42,7 @@ async function exportReusableBlock(id) {
42
42
  syncStatus
43
43
  }, null, 2);
44
44
  const fileName = (0, _changeCase.paramCase)(title) + '.json';
45
- (0, _file.download)(fileName, fileContent, 'application/json');
45
+ (0, _blob.downloadBlob)(fileName, fileContent, 'application/json');
46
46
  }
47
47
  var _default = exportReusableBlock;
48
48
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["_changeCase","require","_apiFetch","_interopRequireDefault","_file","exportReusableBlock","id","postType","apiFetch","path","post","rest_base","title","raw","content","syncStatus","wp_pattern_sync_status","fileContent","JSON","stringify","__file","fileName","kebabCase","download","_default","exports","default"],"sources":["@wordpress/list-reusable-blocks/src/utils/export.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { download } from './file';\n\n/**\n * Export a reusable block as a JSON file.\n *\n * @param {number} id\n */\nasync function exportReusableBlock( id ) {\n\tconst postType = await apiFetch( { path: `/wp/v2/types/wp_block` } );\n\tconst post = await apiFetch( {\n\t\tpath: `/wp/v2/${ postType.rest_base }/${ id }?context=edit`,\n\t} );\n\tconst title = post.title.raw;\n\tconst content = post.content.raw;\n\tconst syncStatus = post.wp_pattern_sync_status;\n\tconst fileContent = JSON.stringify(\n\t\t{\n\t\t\t__file: 'wp_block',\n\t\t\ttitle,\n\t\t\tcontent,\n\t\t\tsyncStatus,\n\t\t},\n\t\tnull,\n\t\t2\n\t);\n\tconst fileName = kebabCase( title ) + '.json';\n\n\tdownload( fileName, fileContent, 'application/json' );\n}\n\nexport default exportReusableBlock;\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,eAAeI,mBAAmBA,CAAEC,EAAE,EAAG;EACxC,MAAMC,QAAQ,GAAG,MAAM,IAAAC,iBAAQ,EAAE;IAAEC,IAAI,EAAG;EAAuB,CAAE,CAAC;EACpE,MAAMC,IAAI,GAAG,MAAM,IAAAF,iBAAQ,EAAE;IAC5BC,IAAI,EAAG,UAAUF,QAAQ,CAACI,SAAW,IAAIL,EAAI;EAC9C,CAAE,CAAC;EACH,MAAMM,KAAK,GAAGF,IAAI,CAACE,KAAK,CAACC,GAAG;EAC5B,MAAMC,OAAO,GAAGJ,IAAI,CAACI,OAAO,CAACD,GAAG;EAChC,MAAME,UAAU,GAAGL,IAAI,CAACM,sBAAsB;EAC9C,MAAMC,WAAW,GAAGC,IAAI,CAACC,SAAS,CACjC;IACCC,MAAM,EAAE,UAAU;IAClBR,KAAK;IACLE,OAAO;IACPC;EACD,CAAC,EACD,IAAI,EACJ,CACD,CAAC;EACD,MAAMM,QAAQ,GAAG,IAAAC,qBAAS,EAAEV,KAAM,CAAC,GAAG,OAAO;EAE7C,IAAAW,cAAQ,EAAEF,QAAQ,EAAEJ,WAAW,EAAE,kBAAmB,CAAC;AACtD;AAAC,IAAAO,QAAA,GAEcnB,mBAAmB;AAAAoB,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_changeCase","require","_apiFetch","_interopRequireDefault","_blob","exportReusableBlock","id","postType","apiFetch","path","post","rest_base","title","raw","content","syncStatus","wp_pattern_sync_status","fileContent","JSON","stringify","__file","fileName","kebabCase","downloadBlob","_default","exports","default"],"sources":["@wordpress/list-reusable-blocks/src/utils/export.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { downloadBlob } from '@wordpress/blob';\n\n/**\n * Export a reusable block as a JSON file.\n *\n * @param {number} id\n */\nasync function exportReusableBlock( id ) {\n\tconst postType = await apiFetch( { path: `/wp/v2/types/wp_block` } );\n\tconst post = await apiFetch( {\n\t\tpath: `/wp/v2/${ postType.rest_base }/${ id }?context=edit`,\n\t} );\n\tconst title = post.title.raw;\n\tconst content = post.content.raw;\n\tconst syncStatus = post.wp_pattern_sync_status;\n\tconst fileContent = JSON.stringify(\n\t\t{\n\t\t\t__file: 'wp_block',\n\t\t\ttitle,\n\t\t\tcontent,\n\t\t\tsyncStatus,\n\t\t},\n\t\tnull,\n\t\t2\n\t);\n\tconst fileName = kebabCase( title ) + '.json';\n\n\tdownloadBlob( fileName, fileContent, 'application/json' );\n}\n\nexport default exportReusableBlock;\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,eAAeI,mBAAmBA,CAAEC,EAAE,EAAG;EACxC,MAAMC,QAAQ,GAAG,MAAM,IAAAC,iBAAQ,EAAE;IAAEC,IAAI,EAAG;EAAuB,CAAE,CAAC;EACpE,MAAMC,IAAI,GAAG,MAAM,IAAAF,iBAAQ,EAAE;IAC5BC,IAAI,EAAG,UAAUF,QAAQ,CAACI,SAAW,IAAIL,EAAI;EAC9C,CAAE,CAAC;EACH,MAAMM,KAAK,GAAGF,IAAI,CAACE,KAAK,CAACC,GAAG;EAC5B,MAAMC,OAAO,GAAGJ,IAAI,CAACI,OAAO,CAACD,GAAG;EAChC,MAAME,UAAU,GAAGL,IAAI,CAACM,sBAAsB;EAC9C,MAAMC,WAAW,GAAGC,IAAI,CAACC,SAAS,CACjC;IACCC,MAAM,EAAE,UAAU;IAClBR,KAAK;IACLE,OAAO;IACPC;EACD,CAAC,EACD,IAAI,EACJ,CACD,CAAC;EACD,MAAMM,QAAQ,GAAG,IAAAC,qBAAS,EAAEV,KAAM,CAAC,GAAG,OAAO;EAE7C,IAAAW,kBAAY,EAAEF,QAAQ,EAAEJ,WAAW,EAAE,kBAAmB,CAAC;AAC1D;AAAC,IAAAO,QAAA,GAEcnB,mBAAmB;AAAAoB,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -3,35 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.download = download;
7
6
  exports.readTextFile = readTextFile;
8
- /**
9
- * Downloads a file.
10
- *
11
- * @param {string} fileName File Name.
12
- * @param {string} content File Content.
13
- * @param {string} contentType File mime type.
14
- */
15
- function download(fileName, content, contentType) {
16
- const file = new window.Blob([content], {
17
- type: contentType
18
- });
19
-
20
- // IE11 can't use the click to download technique
21
- // we use a specific IE11 technique instead.
22
- if (window.navigator.msSaveOrOpenBlob) {
23
- window.navigator.msSaveOrOpenBlob(file, fileName);
24
- } else {
25
- const a = document.createElement('a');
26
- a.href = URL.createObjectURL(file);
27
- a.download = fileName;
28
- a.style.display = 'none';
29
- document.body.appendChild(a);
30
- a.click();
31
- document.body.removeChild(a);
32
- }
33
- }
34
-
35
7
  /**
36
8
  * Reads the textual content of the given file.
37
9
  *
@@ -1 +1 @@
1
- {"version":3,"names":["download","fileName","content","contentType","file","window","Blob","type","navigator","msSaveOrOpenBlob","a","document","createElement","href","URL","createObjectURL","style","display","body","appendChild","click","removeChild","readTextFile","reader","FileReader","Promise","resolve","onload","result","readAsText"],"sources":["@wordpress/list-reusable-blocks/src/utils/file.js"],"sourcesContent":["/**\n * Downloads a file.\n *\n * @param {string} fileName File Name.\n * @param {string} content File Content.\n * @param {string} contentType File mime type.\n */\nexport function download( fileName, content, contentType ) {\n\tconst file = new window.Blob( [ content ], { type: contentType } );\n\n\t// IE11 can't use the click to download technique\n\t// we use a specific IE11 technique instead.\n\tif ( window.navigator.msSaveOrOpenBlob ) {\n\t\twindow.navigator.msSaveOrOpenBlob( file, fileName );\n\t} else {\n\t\tconst a = document.createElement( 'a' );\n\t\ta.href = URL.createObjectURL( file );\n\t\ta.download = fileName;\n\n\t\ta.style.display = 'none';\n\t\tdocument.body.appendChild( a );\n\t\ta.click();\n\t\tdocument.body.removeChild( a );\n\t}\n}\n\n/**\n * Reads the textual content of the given file.\n *\n * @param {File} file File.\n * @return {Promise<string>} Content of the file.\n */\nexport function readTextFile( file ) {\n\tconst reader = new window.FileReader();\n\treturn new Promise( ( resolve ) => {\n\t\treader.onload = () => {\n\t\t\tresolve( reader.result );\n\t\t};\n\t\treader.readAsText( file );\n\t} );\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,QAAQA,CAAEC,QAAQ,EAAEC,OAAO,EAAEC,WAAW,EAAG;EAC1D,MAAMC,IAAI,GAAG,IAAIC,MAAM,CAACC,IAAI,CAAE,CAAEJ,OAAO,CAAE,EAAE;IAAEK,IAAI,EAAEJ;EAAY,CAAE,CAAC;;EAElE;EACA;EACA,IAAKE,MAAM,CAACG,SAAS,CAACC,gBAAgB,EAAG;IACxCJ,MAAM,CAACG,SAAS,CAACC,gBAAgB,CAAEL,IAAI,EAAEH,QAAS,CAAC;EACpD,CAAC,MAAM;IACN,MAAMS,CAAC,GAAGC,QAAQ,CAACC,aAAa,CAAE,GAAI,CAAC;IACvCF,CAAC,CAACG,IAAI,GAAGC,GAAG,CAACC,eAAe,CAAEX,IAAK,CAAC;IACpCM,CAAC,CAACV,QAAQ,GAAGC,QAAQ;IAErBS,CAAC,CAACM,KAAK,CAACC,OAAO,GAAG,MAAM;IACxBN,QAAQ,CAACO,IAAI,CAACC,WAAW,CAAET,CAAE,CAAC;IAC9BA,CAAC,CAACU,KAAK,CAAC,CAAC;IACTT,QAAQ,CAACO,IAAI,CAACG,WAAW,CAAEX,CAAE,CAAC;EAC/B;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASY,YAAYA,CAAElB,IAAI,EAAG;EACpC,MAAMmB,MAAM,GAAG,IAAIlB,MAAM,CAACmB,UAAU,CAAC,CAAC;EACtC,OAAO,IAAIC,OAAO,CAAIC,OAAO,IAAM;IAClCH,MAAM,CAACI,MAAM,GAAG,MAAM;MACrBD,OAAO,CAAEH,MAAM,CAACK,MAAO,CAAC;IACzB,CAAC;IACDL,MAAM,CAACM,UAAU,CAAEzB,IAAK,CAAC;EAC1B,CAAE,CAAC;AACJ"}
1
+ {"version":3,"names":["readTextFile","file","reader","window","FileReader","Promise","resolve","onload","result","readAsText"],"sources":["@wordpress/list-reusable-blocks/src/utils/file.js"],"sourcesContent":["/**\n * Reads the textual content of the given file.\n *\n * @param {File} file File.\n * @return {Promise<string>} Content of the file.\n */\nexport function readTextFile( file ) {\n\tconst reader = new window.FileReader();\n\treturn new Promise( ( resolve ) => {\n\t\treader.onload = () => {\n\t\t\tresolve( reader.result );\n\t\t};\n\t\treader.readAsText( file );\n\t} );\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAYA,CAAEC,IAAI,EAAG;EACpC,MAAMC,MAAM,GAAG,IAAIC,MAAM,CAACC,UAAU,CAAC,CAAC;EACtC,OAAO,IAAIC,OAAO,CAAIC,OAAO,IAAM;IAClCJ,MAAM,CAACK,MAAM,GAAG,MAAM;MACrBD,OAAO,CAAEJ,MAAM,CAACM,MAAO,CAAC;IACzB,CAAC;IACDN,MAAM,CAACO,UAAU,CAAER,IAAK,CAAC;EAC1B,CAAE,CAAC;AACJ"}
@@ -11,7 +11,7 @@ import apiFetch from '@wordpress/api-fetch';
11
11
  /**
12
12
  * Internal dependencies
13
13
  */
14
- import { download } from './file';
14
+ import { downloadBlob } from '@wordpress/blob';
15
15
 
16
16
  /**
17
17
  * Export a reusable block as a JSON file.
@@ -35,7 +35,7 @@ async function exportReusableBlock(id) {
35
35
  syncStatus
36
36
  }, null, 2);
37
37
  const fileName = kebabCase(title) + '.json';
38
- download(fileName, fileContent, 'application/json');
38
+ downloadBlob(fileName, fileContent, 'application/json');
39
39
  }
40
40
  export default exportReusableBlock;
41
41
  //# sourceMappingURL=export.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["paramCase","kebabCase","apiFetch","download","exportReusableBlock","id","postType","path","post","rest_base","title","raw","content","syncStatus","wp_pattern_sync_status","fileContent","JSON","stringify","__file","fileName"],"sources":["@wordpress/list-reusable-blocks/src/utils/export.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { download } from './file';\n\n/**\n * Export a reusable block as a JSON file.\n *\n * @param {number} id\n */\nasync function exportReusableBlock( id ) {\n\tconst postType = await apiFetch( { path: `/wp/v2/types/wp_block` } );\n\tconst post = await apiFetch( {\n\t\tpath: `/wp/v2/${ postType.rest_base }/${ id }?context=edit`,\n\t} );\n\tconst title = post.title.raw;\n\tconst content = post.content.raw;\n\tconst syncStatus = post.wp_pattern_sync_status;\n\tconst fileContent = JSON.stringify(\n\t\t{\n\t\t\t__file: 'wp_block',\n\t\t\ttitle,\n\t\t\tcontent,\n\t\t\tsyncStatus,\n\t\t},\n\t\tnull,\n\t\t2\n\t);\n\tconst fileName = kebabCase( title ) + '.json';\n\n\tdownload( fileName, fileContent, 'application/json' );\n}\n\nexport default exportReusableBlock;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,IAAIC,SAAS,QAAQ,aAAa;;AAEpD;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,sBAAsB;;AAE3C;AACA;AACA;AACA,SAASC,QAAQ,QAAQ,QAAQ;;AAEjC;AACA;AACA;AACA;AACA;AACA,eAAeC,mBAAmBA,CAAEC,EAAE,EAAG;EACxC,MAAMC,QAAQ,GAAG,MAAMJ,QAAQ,CAAE;IAAEK,IAAI,EAAG;EAAuB,CAAE,CAAC;EACpE,MAAMC,IAAI,GAAG,MAAMN,QAAQ,CAAE;IAC5BK,IAAI,EAAG,UAAUD,QAAQ,CAACG,SAAW,IAAIJ,EAAI;EAC9C,CAAE,CAAC;EACH,MAAMK,KAAK,GAAGF,IAAI,CAACE,KAAK,CAACC,GAAG;EAC5B,MAAMC,OAAO,GAAGJ,IAAI,CAACI,OAAO,CAACD,GAAG;EAChC,MAAME,UAAU,GAAGL,IAAI,CAACM,sBAAsB;EAC9C,MAAMC,WAAW,GAAGC,IAAI,CAACC,SAAS,CACjC;IACCC,MAAM,EAAE,UAAU;IAClBR,KAAK;IACLE,OAAO;IACPC;EACD,CAAC,EACD,IAAI,EACJ,CACD,CAAC;EACD,MAAMM,QAAQ,GAAGlB,SAAS,CAAES,KAAM,CAAC,GAAG,OAAO;EAE7CP,QAAQ,CAAEgB,QAAQ,EAAEJ,WAAW,EAAE,kBAAmB,CAAC;AACtD;AAEA,eAAeX,mBAAmB"}
1
+ {"version":3,"names":["paramCase","kebabCase","apiFetch","downloadBlob","exportReusableBlock","id","postType","path","post","rest_base","title","raw","content","syncStatus","wp_pattern_sync_status","fileContent","JSON","stringify","__file","fileName"],"sources":["@wordpress/list-reusable-blocks/src/utils/export.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { downloadBlob } from '@wordpress/blob';\n\n/**\n * Export a reusable block as a JSON file.\n *\n * @param {number} id\n */\nasync function exportReusableBlock( id ) {\n\tconst postType = await apiFetch( { path: `/wp/v2/types/wp_block` } );\n\tconst post = await apiFetch( {\n\t\tpath: `/wp/v2/${ postType.rest_base }/${ id }?context=edit`,\n\t} );\n\tconst title = post.title.raw;\n\tconst content = post.content.raw;\n\tconst syncStatus = post.wp_pattern_sync_status;\n\tconst fileContent = JSON.stringify(\n\t\t{\n\t\t\t__file: 'wp_block',\n\t\t\ttitle,\n\t\t\tcontent,\n\t\t\tsyncStatus,\n\t\t},\n\t\tnull,\n\t\t2\n\t);\n\tconst fileName = kebabCase( title ) + '.json';\n\n\tdownloadBlob( fileName, fileContent, 'application/json' );\n}\n\nexport default exportReusableBlock;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,IAAIC,SAAS,QAAQ,aAAa;;AAEpD;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,sBAAsB;;AAE3C;AACA;AACA;AACA,SAASC,YAAY,QAAQ,iBAAiB;;AAE9C;AACA;AACA;AACA;AACA;AACA,eAAeC,mBAAmBA,CAAEC,EAAE,EAAG;EACxC,MAAMC,QAAQ,GAAG,MAAMJ,QAAQ,CAAE;IAAEK,IAAI,EAAG;EAAuB,CAAE,CAAC;EACpE,MAAMC,IAAI,GAAG,MAAMN,QAAQ,CAAE;IAC5BK,IAAI,EAAG,UAAUD,QAAQ,CAACG,SAAW,IAAIJ,EAAI;EAC9C,CAAE,CAAC;EACH,MAAMK,KAAK,GAAGF,IAAI,CAACE,KAAK,CAACC,GAAG;EAC5B,MAAMC,OAAO,GAAGJ,IAAI,CAACI,OAAO,CAACD,GAAG;EAChC,MAAME,UAAU,GAAGL,IAAI,CAACM,sBAAsB;EAC9C,MAAMC,WAAW,GAAGC,IAAI,CAACC,SAAS,CACjC;IACCC,MAAM,EAAE,UAAU;IAClBR,KAAK;IACLE,OAAO;IACPC;EACD,CAAC,EACD,IAAI,EACJ,CACD,CAAC;EACD,MAAMM,QAAQ,GAAGlB,SAAS,CAAES,KAAM,CAAC,GAAG,OAAO;EAE7CP,YAAY,CAAEgB,QAAQ,EAAEJ,WAAW,EAAE,kBAAmB,CAAC;AAC1D;AAEA,eAAeX,mBAAmB"}
@@ -1,30 +1,3 @@
1
- /**
2
- * Downloads a file.
3
- *
4
- * @param {string} fileName File Name.
5
- * @param {string} content File Content.
6
- * @param {string} contentType File mime type.
7
- */
8
- export function download(fileName, content, contentType) {
9
- const file = new window.Blob([content], {
10
- type: contentType
11
- });
12
-
13
- // IE11 can't use the click to download technique
14
- // we use a specific IE11 technique instead.
15
- if (window.navigator.msSaveOrOpenBlob) {
16
- window.navigator.msSaveOrOpenBlob(file, fileName);
17
- } else {
18
- const a = document.createElement('a');
19
- a.href = URL.createObjectURL(file);
20
- a.download = fileName;
21
- a.style.display = 'none';
22
- document.body.appendChild(a);
23
- a.click();
24
- document.body.removeChild(a);
25
- }
26
- }
27
-
28
1
  /**
29
2
  * Reads the textual content of the given file.
30
3
  *
@@ -1 +1 @@
1
- {"version":3,"names":["download","fileName","content","contentType","file","window","Blob","type","navigator","msSaveOrOpenBlob","a","document","createElement","href","URL","createObjectURL","style","display","body","appendChild","click","removeChild","readTextFile","reader","FileReader","Promise","resolve","onload","result","readAsText"],"sources":["@wordpress/list-reusable-blocks/src/utils/file.js"],"sourcesContent":["/**\n * Downloads a file.\n *\n * @param {string} fileName File Name.\n * @param {string} content File Content.\n * @param {string} contentType File mime type.\n */\nexport function download( fileName, content, contentType ) {\n\tconst file = new window.Blob( [ content ], { type: contentType } );\n\n\t// IE11 can't use the click to download technique\n\t// we use a specific IE11 technique instead.\n\tif ( window.navigator.msSaveOrOpenBlob ) {\n\t\twindow.navigator.msSaveOrOpenBlob( file, fileName );\n\t} else {\n\t\tconst a = document.createElement( 'a' );\n\t\ta.href = URL.createObjectURL( file );\n\t\ta.download = fileName;\n\n\t\ta.style.display = 'none';\n\t\tdocument.body.appendChild( a );\n\t\ta.click();\n\t\tdocument.body.removeChild( a );\n\t}\n}\n\n/**\n * Reads the textual content of the given file.\n *\n * @param {File} file File.\n * @return {Promise<string>} Content of the file.\n */\nexport function readTextFile( file ) {\n\tconst reader = new window.FileReader();\n\treturn new Promise( ( resolve ) => {\n\t\treader.onload = () => {\n\t\t\tresolve( reader.result );\n\t\t};\n\t\treader.readAsText( file );\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,QAAQA,CAAEC,QAAQ,EAAEC,OAAO,EAAEC,WAAW,EAAG;EAC1D,MAAMC,IAAI,GAAG,IAAIC,MAAM,CAACC,IAAI,CAAE,CAAEJ,OAAO,CAAE,EAAE;IAAEK,IAAI,EAAEJ;EAAY,CAAE,CAAC;;EAElE;EACA;EACA,IAAKE,MAAM,CAACG,SAAS,CAACC,gBAAgB,EAAG;IACxCJ,MAAM,CAACG,SAAS,CAACC,gBAAgB,CAAEL,IAAI,EAAEH,QAAS,CAAC;EACpD,CAAC,MAAM;IACN,MAAMS,CAAC,GAAGC,QAAQ,CAACC,aAAa,CAAE,GAAI,CAAC;IACvCF,CAAC,CAACG,IAAI,GAAGC,GAAG,CAACC,eAAe,CAAEX,IAAK,CAAC;IACpCM,CAAC,CAACV,QAAQ,GAAGC,QAAQ;IAErBS,CAAC,CAACM,KAAK,CAACC,OAAO,GAAG,MAAM;IACxBN,QAAQ,CAACO,IAAI,CAACC,WAAW,CAAET,CAAE,CAAC;IAC9BA,CAAC,CAACU,KAAK,CAAC,CAAC;IACTT,QAAQ,CAACO,IAAI,CAACG,WAAW,CAAEX,CAAE,CAAC;EAC/B;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASY,YAAYA,CAAElB,IAAI,EAAG;EACpC,MAAMmB,MAAM,GAAG,IAAIlB,MAAM,CAACmB,UAAU,CAAC,CAAC;EACtC,OAAO,IAAIC,OAAO,CAAIC,OAAO,IAAM;IAClCH,MAAM,CAACI,MAAM,GAAG,MAAM;MACrBD,OAAO,CAAEH,MAAM,CAACK,MAAO,CAAC;IACzB,CAAC;IACDL,MAAM,CAACM,UAAU,CAAEzB,IAAK,CAAC;EAC1B,CAAE,CAAC;AACJ"}
1
+ {"version":3,"names":["readTextFile","file","reader","window","FileReader","Promise","resolve","onload","result","readAsText"],"sources":["@wordpress/list-reusable-blocks/src/utils/file.js"],"sourcesContent":["/**\n * Reads the textual content of the given file.\n *\n * @param {File} file File.\n * @return {Promise<string>} Content of the file.\n */\nexport function readTextFile( file ) {\n\tconst reader = new window.FileReader();\n\treturn new Promise( ( resolve ) => {\n\t\treader.onload = () => {\n\t\t\tresolve( reader.result );\n\t\t};\n\t\treader.readAsText( file );\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAYA,CAAEC,IAAI,EAAG;EACpC,MAAMC,MAAM,GAAG,IAAIC,MAAM,CAACC,UAAU,CAAC,CAAC;EACtC,OAAO,IAAIC,OAAO,CAAIC,OAAO,IAAM;IAClCJ,MAAM,CAACK,MAAM,GAAG,MAAM;MACrBD,OAAO,CAAEJ,MAAM,CAACM,MAAO,CAAC;IACzB,CAAC;IACDN,MAAM,CAACO,UAAU,CAAER,IAAK,CAAC;EAC1B,CAAE,CAAC;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/list-reusable-blocks",
3
- "version": "4.22.0",
3
+ "version": "4.24.0",
4
4
  "description": "Adding Export/Import support to the reusable blocks listing.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -26,11 +26,12 @@
26
26
  "module": "build-module/index.js",
27
27
  "dependencies": {
28
28
  "@babel/runtime": "^7.16.0",
29
- "@wordpress/api-fetch": "^6.42.0",
30
- "@wordpress/components": "^25.11.0",
31
- "@wordpress/compose": "^6.22.0",
32
- "@wordpress/element": "^5.22.0",
33
- "@wordpress/i18n": "^4.45.0",
29
+ "@wordpress/api-fetch": "^6.44.0",
30
+ "@wordpress/blob": "^3.47.0",
31
+ "@wordpress/components": "^25.13.0",
32
+ "@wordpress/compose": "^6.24.0",
33
+ "@wordpress/element": "^5.24.0",
34
+ "@wordpress/i18n": "^4.47.0",
34
35
  "change-case": "^4.1.2"
35
36
  },
36
37
  "peerDependencies": {
@@ -40,5 +41,5 @@
40
41
  "publishConfig": {
41
42
  "access": "public"
42
43
  },
43
- "gitHead": "2a00e87b57b9c27ed2b9b0fd8d423ef3cada72c1"
44
+ "gitHead": "d98dff8ea96f29cfea045bf964269f46f040d539"
44
45
  }
@@ -11,7 +11,7 @@ import apiFetch from '@wordpress/api-fetch';
11
11
  /**
12
12
  * Internal dependencies
13
13
  */
14
- import { download } from './file';
14
+ import { downloadBlob } from '@wordpress/blob';
15
15
 
16
16
  /**
17
17
  * Export a reusable block as a JSON file.
@@ -38,7 +38,7 @@ async function exportReusableBlock( id ) {
38
38
  );
39
39
  const fileName = kebabCase( title ) + '.json';
40
40
 
41
- download( fileName, fileContent, 'application/json' );
41
+ downloadBlob( fileName, fileContent, 'application/json' );
42
42
  }
43
43
 
44
44
  export default exportReusableBlock;
package/src/utils/file.js CHANGED
@@ -1,29 +1,3 @@
1
- /**
2
- * Downloads a file.
3
- *
4
- * @param {string} fileName File Name.
5
- * @param {string} content File Content.
6
- * @param {string} contentType File mime type.
7
- */
8
- export function download( fileName, content, contentType ) {
9
- const file = new window.Blob( [ content ], { type: contentType } );
10
-
11
- // IE11 can't use the click to download technique
12
- // we use a specific IE11 technique instead.
13
- if ( window.navigator.msSaveOrOpenBlob ) {
14
- window.navigator.msSaveOrOpenBlob( file, fileName );
15
- } else {
16
- const a = document.createElement( 'a' );
17
- a.href = URL.createObjectURL( file );
18
- a.download = fileName;
19
-
20
- a.style.display = 'none';
21
- document.body.appendChild( a );
22
- a.click();
23
- document.body.removeChild( a );
24
- }
25
- }
26
-
27
1
  /**
28
2
  * Reads the textual content of the given file.
29
3
  *