diff --git a/README.md b/README.md index 8bcfde4..db5c8b5 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ This project is in its early stages. Please [open an issue](https://github.com/r -## Using +## Using -Gutenberg fields middleware requires only two files `dist/middleware.min.js` and `dist/middleware.min.css` as dependency. +Gutenberg fields middleware requires only two files `dist/middleware.min.js` and `dist/middleware.min.css` as dependency. There are two ways of using fields middleware. @@ -127,6 +127,7 @@ Gutenberg Fields Middleware supports the following field types and type configur - [input types: email / number/ hidden / search / tel etc.](docs/input.md) - [link](docs/link.md) - [media-icon](docs/media-icon.md) +- [notice](docs/notice.md) - [radio](docs/radio.md) - [range](docs/range.md) - [rich-text](docs/rich-text.md) @@ -144,7 +145,7 @@ Gutenberg Fields Middleware supports the following field types and type configur #### Returning field in `edit` method: - `middleware.fields.arrtibuteKeyName` for a **single** field when `placement` property is not defined. -- `middleware.blockControls` for **all** block-control fields. ( where `placement` is `block-control` ) +- `middleware.blockControls` for **all** block-control fields. ( where `placement` is `block-control` ) - `middleware.inspectorControls` for **all** inspector fields. ( where `placement` is `inspector` ) @@ -162,6 +163,5 @@ See [example usage](docs/alignment-toolbar.md#example-usage--es5-) of alignment- #### Example Usage: - See [examples](examples/) - * You can set GUTENBERG_FIELDS_MIDDLEWARE_IS_DEV to true during development in wp-config.php which will also enable example blocks. + * You can set GUTENBERG_FIELDS_MIDDLEWARE_IS_DEV to true during development in wp-config.php which will also enable example blocks. - Check [gutenberg-supplements](https://github.com/rtCamp/gutenberg-supplements) plugin where we have created some actual blocks using middleware. - diff --git a/dist/middleware.js b/dist/middleware.js index ab86236..5f0bd61 100644 --- a/dist/middleware.js +++ b/dist/middleware.js @@ -255,7 +255,7 @@ var Field = function (_Component) { /* 2 */ /***/ (function(module, exports) { -var core = module.exports = { version: '2.5.7' }; +var core = module.exports = { version: '2.6.0' }; if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef @@ -1591,6 +1591,9 @@ var GutenbergFieldsMiddleWare = function () { case 'media-icon': field = fields.mediaIcon(props, config, defaultConfig, attributeKey, this); break; + case 'notice': + field = fields.notice(props, config, defaultConfig, attributeKey, this); + break; case 'dropdown-menu': field = fields.dropDownMenu(props, config, defaultConfig, attributeKey, this); break; @@ -1658,7 +1661,7 @@ var GutenbergFieldsMiddleWare = function () { BlockControls, { key: 'block-controls', __source: { fileName: _jsxFileName, - lineNumber: 254 + lineNumber: 257 } }, _.isEmpty(fields) && __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_keys___default()(this.blockControlFields).map(function (key) { @@ -1688,7 +1691,7 @@ var GutenbergFieldsMiddleWare = function () { InspectorControls, { key: 'inspector-control', __source: { fileName: _jsxFileName, - lineNumber: 275 + lineNumber: 278 } }, _.isEmpty(fields) && __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_keys___default()(this.inspectorControlFields).map(function (key) { @@ -1846,7 +1849,7 @@ var GutenbergFieldsMiddleWare = function () { 'div', { key: props.className, __source: { fileName: _jsxFileName, - lineNumber: 427 + lineNumber: 430 } }, __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_keys___default()(this.fields).map(function (key) { @@ -2124,22 +2127,25 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "link", function() { return __WEBPACK_IMPORTED_MODULE_13__link__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__media_upload__ = __webpack_require__(130); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "mediaUpload", function() { return __WEBPACK_IMPORTED_MODULE_14__media_upload__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__radio__ = __webpack_require__(140); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "radio", function() { return __WEBPACK_IMPORTED_MODULE_15__radio__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__range__ = __webpack_require__(141); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "range", function() { return __WEBPACK_IMPORTED_MODULE_16__range__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__rich_text__ = __webpack_require__(142); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "richText", function() { return __WEBPACK_IMPORTED_MODULE_17__rich_text__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__select__ = __webpack_require__(144); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "select", function() { return __WEBPACK_IMPORTED_MODULE_18__select__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__text__ = __webpack_require__(145); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "text", function() { return __WEBPACK_IMPORTED_MODULE_19__text__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__textarea__ = __webpack_require__(146); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "textarea", function() { return __WEBPACK_IMPORTED_MODULE_20__textarea__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__tree_select__ = __webpack_require__(148); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "treeSelect", function() { return __WEBPACK_IMPORTED_MODULE_21__tree_select__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__url_input_button__ = __webpack_require__(149); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "urlInputButton", function() { return __WEBPACK_IMPORTED_MODULE_22__url_input_button__["a"]; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__notice__ = __webpack_require__(140); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "notice", function() { return __WEBPACK_IMPORTED_MODULE_15__notice__["a"]; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__radio__ = __webpack_require__(141); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "radio", function() { return __WEBPACK_IMPORTED_MODULE_16__radio__["a"]; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__range__ = __webpack_require__(142); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "range", function() { return __WEBPACK_IMPORTED_MODULE_17__range__["a"]; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__rich_text__ = __webpack_require__(143); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "richText", function() { return __WEBPACK_IMPORTED_MODULE_18__rich_text__["a"]; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__select__ = __webpack_require__(145); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "select", function() { return __WEBPACK_IMPORTED_MODULE_19__select__["a"]; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__text__ = __webpack_require__(146); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "text", function() { return __WEBPACK_IMPORTED_MODULE_20__text__["a"]; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__textarea__ = __webpack_require__(147); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "textarea", function() { return __WEBPACK_IMPORTED_MODULE_21__textarea__["a"]; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__tree_select__ = __webpack_require__(149); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "treeSelect", function() { return __WEBPACK_IMPORTED_MODULE_22__tree_select__["a"]; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__url_input_button__ = __webpack_require__(150); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "urlInputButton", function() { return __WEBPACK_IMPORTED_MODULE_23__url_input_button__["a"]; }); + @@ -4690,6 +4696,63 @@ module.exports = __webpack_require__(2).getIterator = function (it) { /* 140 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; +/* harmony export (immutable) */ __webpack_exports__["a"] = notice; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__components_field__ = __webpack_require__(1); + +var _jsxFileName = '/Users/yahilmadakiya/Local Sites/wp50/app/public/wp-content/plugins/gutenberg-fields-middleware/middleware/fields/notice/index.js'; +/** + * Notice field. + */ + + + +var Notice = wp.components.Notice; + + +function notice(props, config, defaultConfig, attributeKey, middleware) { + + var fieldAttributes = _.extend(defaultConfig, config); + + delete fieldAttributes.type; + delete fieldAttributes.message; + + return wp.element.createElement( + __WEBPACK_IMPORTED_MODULE_1__components_field__["a" /* default */], + __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, config, { + __source: { + fileName: _jsxFileName, + lineNumber: 17 + } + }), + wp.element.createElement( + Notice, + __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, fieldAttributes, { + __source: { + fileName: _jsxFileName, + lineNumber: 18 + } + }), + wp.element.createElement( + 'p', + { + __source: { + fileName: _jsxFileName, + lineNumber: 19 + } + }, + config.message + ) + ) + ); +} + +/***/ }), +/* 141 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = radio; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__ = __webpack_require__(0); @@ -4722,7 +4785,7 @@ function radio(props, config, defaultConfig, attributeKey) { } /***/ }), -/* 141 */ +/* 142 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -4748,14 +4811,14 @@ function range(props, config, defaultConfig) { } /***/ }), -/* 142 */ +/* 143 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = richText; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__editor_scss__ = __webpack_require__(143); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__editor_scss__ = __webpack_require__(144); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__editor_scss___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__editor_scss__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__components_field__ = __webpack_require__(1); @@ -4797,13 +4860,13 @@ function richText(props, config, defaultConfig, attributeKey) { } /***/ }), -/* 143 */ +/* 144 */ /***/ (function(module, exports) { // removed by extract-text-webpack-plugin /***/ }), -/* 144 */ +/* 145 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -4833,7 +4896,7 @@ function select(props, config, defaultConfig) { } /***/ }), -/* 145 */ +/* 146 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -4880,14 +4943,14 @@ function text(props, config, defaultConfig, attributeKey, middleware) { } /***/ }), -/* 146 */ +/* 147 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = textarea; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__editor_scss__ = __webpack_require__(147); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__editor_scss__ = __webpack_require__(148); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__editor_scss___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__editor_scss__); var _jsxFileName = '/Users/yahilmadakiya/Local Sites/wp50/app/public/wp-content/plugins/gutenberg-fields-middleware/middleware/fields/textarea/index.js'; @@ -4918,13 +4981,13 @@ function textarea(props, config, defaultConfig) { } /***/ }), -/* 147 */ +/* 148 */ /***/ (function(module, exports) { // removed by extract-text-webpack-plugin /***/ }), -/* 148 */ +/* 149 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -4954,7 +5017,7 @@ function treeSelect(props, config, defaultConfig) { } /***/ }), -/* 149 */ +/* 150 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; diff --git a/dist/middleware.min.js b/dist/middleware.min.js index caf79a9..b1edb3a 100644 --- a/dist/middleware.min.js +++ b/dist/middleware.min.js @@ -1 +1 @@ -!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=57)}([function(e,t,n){"use strict";t.__esModule=!0;var r=n(65),i=function(e){return e&&e.__esModule?e:{default:e}}(r);t.default=i.default||function(e){for(var t=1;t=t.length?{value:void 0,done:!0}:(e=r(t,n),this._i+=e.length,{value:e,done:!1})})},function(e,t){e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t){var n=Math.ceil,r=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?r:n)(e)}},function(e,t,n){var r=n(32)("keys"),i=n(24);e.exports=function(e){return r[e]||(r[e]=i(e))}},function(e,t,n){var r=n(2),i=n(4),o=i["__core-js_shared__"]||(i["__core-js_shared__"]={});(e.exports=function(e,t){return o[e]||(o[e]=void 0!==t?t:{})})("versions",[]).push({version:r.version,mode:n(23)?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},function(e,t){e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(e,t,n){var r=n(64);e.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t,n){var r=n(12);e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;if("function"==typeof(n=e.valueOf)&&!r(i=n.call(e)))return i;if(!t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},function(e,t){t.f=Object.getOwnPropertySymbols},function(e,t,n){var r=n(8),i=n(80),o=n(33),a=n(31)("IE_PROTO"),l=function(){},u=function(){var e,t=n(47)("iframe"),r=o.length;for(t.style.display="none",n(81).appendChild(t),t.src="javascript:",e=t.contentWindow.document,e.open(),e.write("