@wordpress/list-reusable-blocks 4.22.0 → 4.23.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 +2 -0
- package/build/utils/export.js +2 -2
- package/build/utils/export.js.map +1 -1
- package/build/utils/file.js +0 -28
- package/build/utils/file.js.map +1 -1
- package/build-module/utils/export.js +2 -2
- package/build-module/utils/export.js.map +1 -1
- package/build-module/utils/file.js +0 -27
- package/build-module/utils/file.js.map +1 -1
- package/package.json +8 -7
- package/src/utils/export.js +2 -2
- package/src/utils/file.js +0 -26
package/CHANGELOG.md
CHANGED
package/build/utils/export.js
CHANGED
|
@@ -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
|
|
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,
|
|
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","
|
|
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"}
|
package/build/utils/file.js
CHANGED
|
@@ -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
|
*
|
package/build/utils/file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
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 {
|
|
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
|
-
|
|
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","
|
|
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":["
|
|
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.
|
|
3
|
+
"version": "4.23.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.
|
|
30
|
-
"@wordpress/
|
|
31
|
-
"@wordpress/
|
|
32
|
-
"@wordpress/
|
|
33
|
-
"@wordpress/
|
|
29
|
+
"@wordpress/api-fetch": "^6.43.0",
|
|
30
|
+
"@wordpress/blob": "^3.46.0",
|
|
31
|
+
"@wordpress/components": "^25.12.0",
|
|
32
|
+
"@wordpress/compose": "^6.23.0",
|
|
33
|
+
"@wordpress/element": "^5.23.0",
|
|
34
|
+
"@wordpress/i18n": "^4.46.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": "
|
|
44
|
+
"gitHead": "839018ff6029ba749780e288e08ff9cd898e50e8"
|
|
44
45
|
}
|
package/src/utils/export.js
CHANGED
|
@@ -11,7 +11,7 @@ import apiFetch from '@wordpress/api-fetch';
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
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
|
-
|
|
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
|
*
|