Skip to content

Commit

Permalink
close #7
Browse files Browse the repository at this point in the history
- fix field name on gutenberg blocks
  • Loading branch information
iamntz committed Mar 4, 2019
1 parent 3a90b1a commit 57902c7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

_(this is an extension of [Carbon Fields](http://carbonfields.net/) plugin)_

Adds a `urlpicker` field type to Carbon Fields. Install using composer:
```cli
composer require iamntz/carbon-fields-urlpicker
```

For Carbon Fields v3, you need to specify the `v3` branch:

```cli
Expand Down
2 changes: 1 addition & 1 deletion assets/build/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) *
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* WEBPACK VAR INJECTION */(function(__webpack_provided_wp_dot_element) {/* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/objectSpread */ \"./node_modules/@babel/runtime/helpers/objectSpread.js\");\n/* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ \"./node_modules/@babel/runtime/helpers/classCallCheck.js\");\n/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @babel/runtime/helpers/createClass */ \"./node_modules/@babel/runtime/helpers/createClass.js\");\n/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ \"./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js\");\n/* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ \"./node_modules/@babel/runtime/helpers/getPrototypeOf.js\");\n/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @babel/runtime/helpers/inherits */ \"./node_modules/@babel/runtime/helpers/inherits.js\");\n/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @babel/runtime/helpers/assertThisInitialized */ \"./node_modules/@babel/runtime/helpers/assertThisInitialized.js\");\n/* harmony import */ var _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6__);\n/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ \"./node_modules/@babel/runtime/helpers/defineProperty.js\");\n/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7__);\n/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @wordpress/element */ \"@wordpress/element\");\n/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_8__);\n/* harmony import */ var _LinkPicker_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./LinkPicker.js */ \"./assets/src/LinkPicker.js\");\n\n\n\n\n\n\n\n\n\n/**\n * External dependencies.\n */\n\n\n\nvar UrlPickerField =\n/*#__PURE__*/\nfunction (_Component) {\n _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_5___default()(UrlPickerField, _Component);\n\n function UrlPickerField() {\n var _getPrototypeOf2;\n\n var _this;\n\n _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, UrlPickerField);\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n _this = _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3___default()(this, (_getPrototypeOf2 = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_4___default()(UrlPickerField)).call.apply(_getPrototypeOf2, [this].concat(args)));\n\n _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_this)), \"resetFieldValues\", function (e) {\n e.preventDefault();\n var field = _this.props.field;\n\n _this.props.onChange(field.id, {\n url: '',\n anchor: '',\n blank: ''\n });\n });\n\n _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_this)), \"openUrlPicker\", function (e) {\n var target = e.currentTarget;\n var field = _this.props.field;\n Object(_LinkPicker_js__WEBPACK_IMPORTED_MODULE_9__[\"maybeLoadTinyMcerPicker\"])().then(function () {\n return Object(_LinkPicker_js__WEBPACK_IMPORTED_MODULE_9__[\"openTinyMceLinkEditor\"])(target, field);\n }).then(function (data) {\n return _this.props.onChange(field.id, _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default()({}, data));\n });\n return false;\n });\n\n _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_this)), \"getButton\", function () {\n var value = _this.props.field.value;\n\n if (value.url.length > 0) {\n return __webpack_provided_wp_dot_element.createElement(\"span\", {\n className: \"carbon-fields--urlpicker\",\n \"data-is-blank\": value.blank ? 1 : 0\n }, __webpack_provided_wp_dot_element.createElement(\"span\", {\n onClick: _this.openUrlPicker.bind(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_this)))\n }, __webpack_provided_wp_dot_element.createElement(\"strong\", null, value.url.replace(\"\".concat(carbonFieldsUrlpickerL10n.home_url), '')), __webpack_provided_wp_dot_element.createElement(\"br\", null), __webpack_provided_wp_dot_element.createElement(\"small\", null, __webpack_provided_wp_dot_element.createElement(\"em\", null, value.anchor))), __webpack_provided_wp_dot_element.createElement(\"span\", {\n className: \"carbon-fields--urlpicker__remove\",\n onClick: _this.resetFieldValues.bind(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_this))),\n title: carbonFieldsUrlpickerL10n.remove_link\n }, \"\\xD7\"));\n }\n\n return __webpack_provided_wp_dot_element.createElement(\"span\", {\n className: \"button button-secondary\",\n onClick: _this.openUrlPicker.bind(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_this)))\n }, carbonFieldsUrlpickerL10n.select_link);\n });\n\n return _this;\n }\n\n _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default()(UrlPickerField, [{\n key: \"render\",\n\n /**\n * Render a number input field.\n *\n * @return {Object}\n */\n value: function render() {\n var _this$props = this.props,\n id = _this$props.id,\n name = _this$props.name,\n value = _this$props.value,\n field = _this$props.field;\n return __webpack_provided_wp_dot_element.createElement(\"div\", null, this.getButton(), __webpack_provided_wp_dot_element.createElement(\"input\", {\n name: \"\".concat(name, \"[url]\"),\n value: value.url,\n type: \"hidden\",\n readOnly: true\n }), __webpack_provided_wp_dot_element.createElement(\"input\", {\n name: \"\".concat(name, \"[anchor]\"),\n value: value.anchor,\n type: \"hidden\",\n readOnly: true\n }), __webpack_provided_wp_dot_element.createElement(\"input\", {\n name: \"\".concat(name, \"[blank]\"),\n value: value.blank,\n type: \"hidden\",\n readOnly: true\n }));\n }\n }]);\n\n return UrlPickerField;\n}(_wordpress_element__WEBPACK_IMPORTED_MODULE_8__[\"Component\"]);\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (UrlPickerField);\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! @wordpress/element */ \"@wordpress/element\")))\n\n//# sourceURL=webpack:///./assets/src/UrlPickerField.js?");
eval("__webpack_require__.r(__webpack_exports__);\n/* WEBPACK VAR INJECTION */(function(__webpack_provided_wp_dot_element) {/* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/objectSpread */ \"./node_modules/@babel/runtime/helpers/objectSpread.js\");\n/* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ \"./node_modules/@babel/runtime/helpers/classCallCheck.js\");\n/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @babel/runtime/helpers/createClass */ \"./node_modules/@babel/runtime/helpers/createClass.js\");\n/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ \"./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js\");\n/* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ \"./node_modules/@babel/runtime/helpers/getPrototypeOf.js\");\n/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @babel/runtime/helpers/inherits */ \"./node_modules/@babel/runtime/helpers/inherits.js\");\n/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @babel/runtime/helpers/assertThisInitialized */ \"./node_modules/@babel/runtime/helpers/assertThisInitialized.js\");\n/* harmony import */ var _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6__);\n/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ \"./node_modules/@babel/runtime/helpers/defineProperty.js\");\n/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7__);\n/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @wordpress/element */ \"@wordpress/element\");\n/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_8__);\n/* harmony import */ var _LinkPicker_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./LinkPicker.js */ \"./assets/src/LinkPicker.js\");\n\n\n\n\n\n\n\n\n\n/**\n * External dependencies.\n */\n\n\n\nvar UrlPickerField =\n/*#__PURE__*/\nfunction (_Component) {\n _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_5___default()(UrlPickerField, _Component);\n\n function UrlPickerField() {\n var _getPrototypeOf2;\n\n var _this;\n\n _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, UrlPickerField);\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n _this = _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3___default()(this, (_getPrototypeOf2 = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_4___default()(UrlPickerField)).call.apply(_getPrototypeOf2, [this].concat(args)));\n\n _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_this)), \"resetFieldValues\", function (e) {\n e.preventDefault();\n var _this$props = _this.props,\n field = _this$props.field,\n id = _this$props.id;\n\n _this.props.onChange(id, {\n url: '',\n anchor: '',\n blank: ''\n });\n });\n\n _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_this)), \"openUrlPicker\", function (e) {\n var target = e.currentTarget;\n var _this$props2 = _this.props,\n field = _this$props2.field,\n id = _this$props2.id;\n Object(_LinkPicker_js__WEBPACK_IMPORTED_MODULE_9__[\"maybeLoadTinyMcerPicker\"])().then(function () {\n return Object(_LinkPicker_js__WEBPACK_IMPORTED_MODULE_9__[\"openTinyMceLinkEditor\"])(target, field);\n }).then(function (data) {\n return _this.props.onChange(id, _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default()({}, data));\n });\n return false;\n });\n\n _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_this)), \"getButton\", function () {\n var value = _this.props.field.value;\n\n if (value.url.length > 0) {\n return __webpack_provided_wp_dot_element.createElement(\"span\", {\n className: \"carbon-fields--urlpicker\",\n \"data-is-blank\": value.blank ? 1 : 0\n }, __webpack_provided_wp_dot_element.createElement(\"span\", {\n onClick: _this.openUrlPicker.bind(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_this)))\n }, __webpack_provided_wp_dot_element.createElement(\"strong\", null, value.url.replace(\"\".concat(carbonFieldsUrlpickerL10n.home_url), '')), __webpack_provided_wp_dot_element.createElement(\"br\", null), __webpack_provided_wp_dot_element.createElement(\"small\", null, __webpack_provided_wp_dot_element.createElement(\"em\", null, value.anchor))), __webpack_provided_wp_dot_element.createElement(\"span\", {\n className: \"carbon-fields--urlpicker__remove\",\n onClick: _this.resetFieldValues.bind(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_this))),\n title: carbonFieldsUrlpickerL10n.remove_link\n }, \"\\xD7\"));\n }\n\n return __webpack_provided_wp_dot_element.createElement(\"span\", {\n className: \"button button-secondary\",\n onClick: _this.openUrlPicker.bind(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_6___default()(_this)))\n }, carbonFieldsUrlpickerL10n.select_link);\n });\n\n return _this;\n }\n\n _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default()(UrlPickerField, [{\n key: \"render\",\n\n /**\n * Render a number input field.\n *\n * @return {Object}\n */\n value: function render() {\n var _this$props3 = this.props,\n id = _this$props3.id,\n name = _this$props3.name,\n value = _this$props3.value,\n field = _this$props3.field;\n return __webpack_provided_wp_dot_element.createElement(\"div\", null, this.getButton(), __webpack_provided_wp_dot_element.createElement(\"input\", {\n name: \"\".concat(name, \"[url]\"),\n value: value.url,\n type: \"hidden\",\n readOnly: true\n }), __webpack_provided_wp_dot_element.createElement(\"input\", {\n name: \"\".concat(name, \"[anchor]\"),\n value: value.anchor,\n type: \"hidden\",\n readOnly: true\n }), __webpack_provided_wp_dot_element.createElement(\"input\", {\n name: \"\".concat(name, \"[blank]\"),\n value: value.blank,\n type: \"hidden\",\n readOnly: true\n }));\n }\n }]);\n\n return UrlPickerField;\n}(_wordpress_element__WEBPACK_IMPORTED_MODULE_8__[\"Component\"]);\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (UrlPickerField);\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! @wordpress/element */ \"@wordpress/element\")))\n\n//# sourceURL=webpack:///./assets/src/UrlPickerField.js?");

/***/ }),

Expand Down
Loading

0 comments on commit 57902c7

Please sign in to comment.