@wordpress/list-reusable-blocks 3.16.1-next.4d3b314fd5.0 → 3.18.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 +4 -0
- package/build/components/import-dropdown/index.js +2 -6
- package/build/components/import-dropdown/index.js.map +1 -1
- package/build/utils/export.js +2 -2
- package/build/utils/export.js.map +1 -1
- package/build-module/components/import-dropdown/index.js +2 -6
- package/build-module/components/import-dropdown/index.js.map +1 -1
- package/build-module/utils/export.js +1 -1
- package/build-module/utils/export.js.map +1 -1
- package/package.json +8 -8
- package/src/components/import-dropdown/index.js +2 -6
- package/src/utils/export.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,7 +9,7 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _compose = require("@wordpress/compose");
|
|
13
13
|
|
|
14
14
|
var _i18n = require("@wordpress/i18n");
|
|
15
15
|
|
|
@@ -17,10 +17,6 @@ var _components = require("@wordpress/components");
|
|
|
17
17
|
|
|
18
18
|
var _importForm = _interopRequireDefault(require("../import-form"));
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* External dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
20
|
/**
|
|
25
21
|
* WordPress dependencies
|
|
26
22
|
*/
|
|
@@ -51,7 +47,7 @@ function ImportDropdown(_ref) {
|
|
|
51
47
|
onClose
|
|
52
48
|
} = _ref3;
|
|
53
49
|
return (0, _element.createElement)(_importForm.default, {
|
|
54
|
-
onUpload: (0,
|
|
50
|
+
onUpload: (0, _compose.pipe)(onClose, onUpload)
|
|
55
51
|
});
|
|
56
52
|
}
|
|
57
53
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/list-reusable-blocks/src/components/import-dropdown/index.js"],"names":["ImportDropdown","onUpload","isOpen","onToggle","onClose"],"mappings":";;;;;;;;;;;AAGA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/list-reusable-blocks/src/components/import-dropdown/index.js"],"names":["ImportDropdown","onUpload","isOpen","onToggle","onClose"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGA,SAASA,cAAT,OAAwC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACvC,SACC,4BAAC,oBAAD;AACC,IAAA,QAAQ,EAAC,cADV;AAEC,IAAA,gBAAgB,EAAC,+CAFlB;AAGC,IAAA,YAAY,EAAG;AAAA,UAAE;AAAEC,QAAAA,MAAF;AAAUC,QAAAA;AAAV,OAAF;AAAA,aACd,4BAAC,kBAAD;AACC,yBAAgBD,MADjB;AAEC,QAAA,OAAO,EAAGC,QAFX;AAGC,QAAA,OAAO,EAAC;AAHT,SAKG,cAAI,kBAAJ,CALH,CADc;AAAA,KAHhB;AAYC,IAAA,aAAa,EAAG;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aACf,4BAAC,mBAAD;AAAY,QAAA,QAAQ,EAAG,mBAAMA,OAAN,EAAeH,QAAf;AAAvB,QADe;AAAA;AAZjB,IADD;AAkBA;;eAEcD,c","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { pipe } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport ImportForm from '../import-form';\n\nfunction ImportDropdown( { onUpload } ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tposition=\"bottom right\"\n\t\t\tcontentClassName=\"list-reusable-blocks-import-dropdown__content\"\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Import from JSON' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<ImportForm onUpload={ pipe( onClose, onUpload ) } />\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default ImportDropdown;\n"]}
|
package/build/utils/export.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _changeCase = require("change-case");
|
|
11
11
|
|
|
12
12
|
var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
|
|
13
13
|
|
|
@@ -44,7 +44,7 @@ async function exportReusableBlock(id) {
|
|
|
44
44
|
title,
|
|
45
45
|
content
|
|
46
46
|
}, null, 2);
|
|
47
|
-
const fileName = (0,
|
|
47
|
+
const fileName = (0, _changeCase.paramCase)(title) + '.json';
|
|
48
48
|
(0, _file.download)(fileName, fileContent, 'application/json');
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/list-reusable-blocks/src/utils/export.js"],"names":["exportReusableBlock","id","postType","path","post","rest_base","title","raw","content","fileContent","JSON","stringify","__file","fileName"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,eAAeA,mBAAf,CAAoCC,EAApC,EAAyC;AACxC,QAAMC,QAAQ,GAAG,MAAM,uBAAU;AAAEC,IAAAA,IAAI,EAAG;AAAT,GAAV,CAAvB;AACA,QAAMC,IAAI,GAAG,MAAM,uBAAU;AAC5BD,IAAAA,IAAI,EAAG,UAAUD,QAAQ,CAACG,SAAW,IAAIJ,EAAI;AADjB,GAAV,CAAnB;AAGA,QAAMK,KAAK,GAAGF,IAAI,CAACE,KAAL,CAAWC,GAAzB;AACA,QAAMC,OAAO,GAAGJ,IAAI,CAACI,OAAL,CAAaD,GAA7B;AACA,QAAME,WAAW,GAAGC,IAAI,CAACC,SAAL,CACnB;AACCC,IAAAA,MAAM,EAAE,UADT;AAECN,IAAAA,KAFD;AAGCE,IAAAA;AAHD,GADmB,EAMnB,IANmB,EAOnB,CAPmB,CAApB;AASA,QAAMK,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"sources":["@wordpress/list-reusable-blocks/src/utils/export.js"],"names":["exportReusableBlock","id","postType","path","post","rest_base","title","raw","content","fileContent","JSON","stringify","__file","fileName"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,eAAeA,mBAAf,CAAoCC,EAApC,EAAyC;AACxC,QAAMC,QAAQ,GAAG,MAAM,uBAAU;AAAEC,IAAAA,IAAI,EAAG;AAAT,GAAV,CAAvB;AACA,QAAMC,IAAI,GAAG,MAAM,uBAAU;AAC5BD,IAAAA,IAAI,EAAG,UAAUD,QAAQ,CAACG,SAAW,IAAIJ,EAAI;AADjB,GAAV,CAAnB;AAGA,QAAMK,KAAK,GAAGF,IAAI,CAACE,KAAL,CAAWC,GAAzB;AACA,QAAMC,OAAO,GAAGJ,IAAI,CAACI,OAAL,CAAaD,GAA7B;AACA,QAAME,WAAW,GAAGC,IAAI,CAACC,SAAL,CACnB;AACCC,IAAAA,MAAM,EAAE,UADT;AAECN,IAAAA,KAFD;AAGCE,IAAAA;AAHD,GADmB,EAMnB,IANmB,EAOnB,CAPmB,CAApB;AASA,QAAMK,QAAQ,GAAG,2BAAWP,KAAX,IAAqB,OAAtC;AAEA,sBAAUO,QAAV,EAAoBJ,WAApB,EAAiC,kBAAjC;AACA;;eAEcT,mB","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 fileContent = JSON.stringify(\n\t\t{\n\t\t\t__file: 'wp_block',\n\t\t\ttitle,\n\t\t\tcontent,\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"]}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { flow } from 'lodash';
|
|
7
3
|
/**
|
|
8
4
|
* WordPress dependencies
|
|
9
5
|
*/
|
|
10
|
-
|
|
6
|
+
import { pipe } from '@wordpress/compose';
|
|
11
7
|
import { __ } from '@wordpress/i18n';
|
|
12
8
|
import { Dropdown, Button } from '@wordpress/components';
|
|
13
9
|
/**
|
|
@@ -39,7 +35,7 @@ function ImportDropdown(_ref) {
|
|
|
39
35
|
onClose
|
|
40
36
|
} = _ref3;
|
|
41
37
|
return createElement(ImportForm, {
|
|
42
|
-
onUpload:
|
|
38
|
+
onUpload: pipe(onClose, onUpload)
|
|
43
39
|
});
|
|
44
40
|
}
|
|
45
41
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/list-reusable-blocks/src/components/import-dropdown/index.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/list-reusable-blocks/src/components/import-dropdown/index.js"],"names":["pipe","__","Dropdown","Button","ImportForm","ImportDropdown","onUpload","isOpen","onToggle","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,oBAArB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,uBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,gBAAvB;;AAEA,SAASC,cAAT,OAAwC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACvC,SACC,cAAC,QAAD;AACC,IAAA,QAAQ,EAAC,cADV;AAEC,IAAA,gBAAgB,EAAC,+CAFlB;AAGC,IAAA,YAAY,EAAG;AAAA,UAAE;AAAEC,QAAAA,MAAF;AAAUC,QAAAA;AAAV,OAAF;AAAA,aACd,cAAC,MAAD;AACC,yBAAgBD,MADjB;AAEC,QAAA,OAAO,EAAGC,QAFX;AAGC,QAAA,OAAO,EAAC;AAHT,SAKGP,EAAE,CAAE,kBAAF,CALL,CADc;AAAA,KAHhB;AAYC,IAAA,aAAa,EAAG;AAAA,UAAE;AAAEQ,QAAAA;AAAF,OAAF;AAAA,aACf,cAAC,UAAD;AAAY,QAAA,QAAQ,EAAGT,IAAI,CAAES,OAAF,EAAWH,QAAX;AAA3B,QADe;AAAA;AAZjB,IADD;AAkBA;;AAED,eAAeD,cAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { pipe } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport ImportForm from '../import-form';\n\nfunction ImportDropdown( { onUpload } ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tposition=\"bottom right\"\n\t\t\tcontentClassName=\"list-reusable-blocks-import-dropdown__content\"\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Import from JSON' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<ImportForm onUpload={ pipe( onClose, onUpload ) } />\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default ImportDropdown;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/list-reusable-blocks/src/utils/export.js"],"names":["kebabCase","apiFetch","download","exportReusableBlock","id","postType","path","post","rest_base","title","raw","content","fileContent","JSON","stringify","__file","fileName"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/list-reusable-blocks/src/utils/export.js"],"names":["paramCase","kebabCase","apiFetch","download","exportReusableBlock","id","postType","path","post","rest_base","title","raw","content","fileContent","JSON","stringify","__file","fileName"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,IAAIC,SAAtB,QAAuC,aAAvC;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,QAAzB;AAEA;AACA;AACA;AACA;AACA;;AACA,eAAeC,mBAAf,CAAoCC,EAApC,EAAyC;AACxC,QAAMC,QAAQ,GAAG,MAAMJ,QAAQ,CAAE;AAAEK,IAAAA,IAAI,EAAG;AAAT,GAAF,CAA/B;AACA,QAAMC,IAAI,GAAG,MAAMN,QAAQ,CAAE;AAC5BK,IAAAA,IAAI,EAAG,UAAUD,QAAQ,CAACG,SAAW,IAAIJ,EAAI;AADjB,GAAF,CAA3B;AAGA,QAAMK,KAAK,GAAGF,IAAI,CAACE,KAAL,CAAWC,GAAzB;AACA,QAAMC,OAAO,GAAGJ,IAAI,CAACI,OAAL,CAAaD,GAA7B;AACA,QAAME,WAAW,GAAGC,IAAI,CAACC,SAAL,CACnB;AACCC,IAAAA,MAAM,EAAE,UADT;AAECN,IAAAA,KAFD;AAGCE,IAAAA;AAHD,GADmB,EAMnB,IANmB,EAOnB,CAPmB,CAApB;AASA,QAAMK,QAAQ,GAAGhB,SAAS,CAAES,KAAF,CAAT,GAAqB,OAAtC;AAEAP,EAAAA,QAAQ,CAAEc,QAAF,EAAYJ,WAAZ,EAAyB,kBAAzB,CAAR;AACA;;AAED,eAAeT,mBAAf","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 fileContent = JSON.stringify(\n\t\t{\n\t\t\t__file: 'wp_block',\n\t\t\ttitle,\n\t\t\tcontent,\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/list-reusable-blocks",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.18.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,12 +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/components": "^21.
|
|
31
|
-
"@wordpress/compose": "^5.
|
|
32
|
-
"@wordpress/element": "^4.
|
|
33
|
-
"@wordpress/i18n": "^4.
|
|
34
|
-
"
|
|
29
|
+
"@wordpress/api-fetch": "^6.17.0",
|
|
30
|
+
"@wordpress/components": "^21.3.0",
|
|
31
|
+
"@wordpress/compose": "^5.18.0",
|
|
32
|
+
"@wordpress/element": "^4.18.0",
|
|
33
|
+
"@wordpress/i18n": "^4.20.0",
|
|
34
|
+
"change-case": "^4.1.2"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": "^17.0.0",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "a2ff0e6471c88436dad0287beb88d1729aa6f5dd"
|
|
44
44
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { flow } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
4
|
+
import { pipe } from '@wordpress/compose';
|
|
9
5
|
import { __ } from '@wordpress/i18n';
|
|
10
6
|
import { Dropdown, Button } from '@wordpress/components';
|
|
11
7
|
|
|
@@ -29,7 +25,7 @@ function ImportDropdown( { onUpload } ) {
|
|
|
29
25
|
</Button>
|
|
30
26
|
) }
|
|
31
27
|
renderContent={ ( { onClose } ) => (
|
|
32
|
-
<ImportForm onUpload={
|
|
28
|
+
<ImportForm onUpload={ pipe( onClose, onUpload ) } />
|
|
33
29
|
) }
|
|
34
30
|
/>
|
|
35
31
|
);
|