├── readme.txt
├── changelog.txt
├── .gitignore
├── postcss.config.js
├── .babelrc
├── assets
├── src
│ ├── scss
│ │ ├── blocks-editor.scss
│ │ ├── blocks-style.scss
│ │ └── blocks
│ │ │ ├── highlight
│ │ │ ├── editor.scss
│ │ │ └── style.scss
│ │ │ ├── plugin-card
│ │ │ ├── editor.scss
│ │ │ └── style.scss
│ │ │ └── click-to-tweet
│ │ │ ├── style.scss
│ │ │ └── editor.scss
│ └── js
│ │ ├── blocks
│ │ ├── highlight
│ │ │ ├── components
│ │ │ │ ├── colors.js
│ │ │ │ ├── controls.js
│ │ │ │ ├── inspector.js
│ │ │ │ └── edit.js
│ │ │ └── index.js
│ │ ├── click-to-tweet
│ │ │ ├── components
│ │ │ │ ├── colors.js
│ │ │ │ ├── controls.js
│ │ │ │ ├── inspector.js
│ │ │ │ └── edit.js
│ │ │ └── index.js
│ │ └── plugin-card
│ │ │ ├── components
│ │ │ ├── controls.js
│ │ │ └── edit.js
│ │ │ └── index.js
│ │ ├── gutenberg.js
│ │ └── utils
│ │ └── icons.js
├── img
│ └── icons
│ │ ├── star-full.svg
│ │ ├── star-half.svg
│ │ ├── star-empty.svg
│ │ └── twitter.svg
├── css
│ ├── blocks_editor.css
│ └── blocks_style.css
└── js
│ └── gutenberg.js
├── .vscode
└── tasks.json
├── package.json
├── includes
├── class-mb-gutenberg.php
├── class-mb-rest.php
└── blocks
│ └── class-mb-plugin-card.php
├── webpack.config.js
└── machoblocks.php
/readme.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/changelog.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 | = 1.0 - February 2, 2016 =
4 |
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.log
2 | /node_modules/
3 | .idea/
4 | /.standard.json
5 | package-lock.json
--------------------------------------------------------------------------------
/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: [
3 | require('autoprefixer')
4 | ]
5 | };
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["babel-preset-es2015", "babel-preset-react"],
3 | "plugins": ["transform-object-rest-spread"]
4 | }
--------------------------------------------------------------------------------
/assets/src/scss/blocks-editor.scss:
--------------------------------------------------------------------------------
1 |
2 | @import 'blocks/highlight/editor';
3 | @import 'blocks/click-to-tweet/editor';
4 | @import 'blocks/plugin-card/editor';
--------------------------------------------------------------------------------
/assets/src/scss/blocks-style.scss:
--------------------------------------------------------------------------------
1 | @import 'blocks/highlight/style';
2 | @import 'blocks/click-to-tweet/style';
3 | @import 'blocks/plugin-card/style';
4 |
--------------------------------------------------------------------------------
/assets/src/scss/blocks/highlight/editor.scss:
--------------------------------------------------------------------------------
1 | .editor-block-list__block[data-type="machoblocks/highlight"] {
2 | background: transparent !important;
3 | }
4 |
--------------------------------------------------------------------------------
/assets/src/js/blocks/highlight/components/colors.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WordPress dependencies
3 | */
4 | const { withColors } = wp.editor;
5 |
6 | /**
7 | * Generate block colors.
8 | */
9 | const applyWithColors = withColors(
10 | 'backgroundColor',
11 | { textColor: 'color' },
12 | );
13 |
14 | export default applyWithColors;
--------------------------------------------------------------------------------
/assets/src/js/blocks/click-to-tweet/components/colors.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WordPress dependencies
3 | */
4 | const { withColors } = wp.editor;
5 |
6 | /**
7 | * Generate block colors.
8 | */
9 | const applyWithColors = withColors(
10 | 'backgroundColor',
11 | { textColor: 'color' },
12 | { buttonColor: 'background-color' },
13 | );
14 |
15 | export default applyWithColors;
--------------------------------------------------------------------------------
/assets/img/icons/star-full.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/src/scss/blocks/highlight/style.scss:
--------------------------------------------------------------------------------
1 | .wp-block-machoblocks-highlight {
2 | background: transparent !important;
3 |
4 | &:empty {
5 | display: none;
6 | }
7 |
8 | & + & {
9 | padding-top: 7px;
10 | }
11 |
12 | &__content {
13 | padding: 2px 5px 2px 3px;
14 | position: relative;
15 | border-radius: 6px;
16 | }
17 |
18 | &__content:not(.has-background) {
19 | background-color: #f3ead1;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | // See https://go.microsoft.com/fwlink/?LinkId=733558
3 | // for the documentation about the tasks.json format
4 | "version": "2.0.0",
5 | "tasks": [
6 | {
7 | "type": "grunt",
8 | "task": "checktextdomain",
9 | "problemMatcher": []
10 | },
11 | {
12 | "type": "grunt",
13 | "task": "buildpot",
14 | "problemMatcher": []
15 | },
16 | {
17 | "type": "grunt",
18 | "task": "build-archive",
19 | "problemMatcher": []
20 | },
21 | {
22 | "label": "npm run watch",
23 | "type": "npm",
24 | "script": "watch",
25 | "problemMatcher": [],
26 | "auto": true
27 | }
28 | ]
29 | }
--------------------------------------------------------------------------------
/assets/img/icons/star-half.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/src/js/blocks/plugin-card/components/controls.js:
--------------------------------------------------------------------------------
1 | /**
2 | * WordPress dependencies
3 | */
4 | const { __ } = wp.i18n;
5 | const { BlockControls } = wp.editor;
6 | const { Component} = wp.element;
7 | const { IconButton, Toolbar } = wp.components;
8 |
9 | export default class Controls extends Component {
10 |
11 | constructor( props ) {
12 | super( ...arguments );
13 | }
14 |
15 | onChangePluginClick() {
16 | this.props.setAttributes( {
17 | pluginSlug: '',
18 | } );
19 | }
20 |
21 | render() {
22 |
23 | return (
24 |
88 |
135 |
158 | { ! RichText.isEmpty( content ) && (
159 |
112 |
${ content }
`, 136 | } ), 137 | }, 138 | { 139 | type: 'block', 140 | blocks: [ 'core/quote' ], 141 | transform: ( { content } ) => createBlock( 'core/quote', { 142 | value: `${ content }
`, 143 | } ), 144 | }, 145 | ], 146 | }, 147 | 148 | edit: Edit, 149 | 150 | save( { attributes } ) { 151 | 152 | const { 153 | buttonColor, 154 | buttonText, 155 | customButtonColor, 156 | customTextColor, 157 | content, 158 | customFontSize, 159 | fontSize, 160 | textColor, 161 | textAlign, 162 | url, 163 | via, 164 | } = attributes; 165 | 166 | const viaUrl = via ? `&via=${via}` : ''; 167 | 168 | const tweetUrl = `http://twitter.com/share?&text=${ encodeURIComponent( content ) }&url=${url}${viaUrl}`; 169 | 170 | const textColorClass = getColorClassName( 'color', textColor ); 171 | 172 | const fontSizeClass = getFontSizeClass( fontSize ); 173 | 174 | const textClasses = classnames( 'wp-block-machoblocks-click-to-tweet__text', { 175 | 'has-text-color': textColor || customTextColor, 176 | [ fontSizeClass ]: fontSizeClass, 177 | [ textColorClass ]: textColorClass, 178 | } ); 179 | 180 | const textStyles = { 181 | fontSize: fontSizeClass ? undefined : customFontSize, 182 | color: textColorClass ? undefined : customTextColor, 183 | }; 184 | 185 | const buttonColorClass = getColorClassName( 'background-color', buttonColor ); 186 | 187 | const buttonClasses = classnames( 'wp-block-machoblocks-click-to-tweet__twitter-btn', { 188 | 'has-button-color': buttonColor || customButtonColor, 189 | [ buttonColorClass ]: buttonColorClass, 190 | } ); 191 | 192 | const buttonStyles = { 193 | backgroundColor: buttonColorClass ? undefined : customButtonColor, 194 | }; 195 | 196 | return ( 197 | ! RichText.isEmpty( content ) && ( 198 |199 |215 | ) 216 | ); 217 | }, 218 | }; 219 | 220 | export { name, title, icon, settings }; 221 | -------------------------------------------------------------------------------- /assets/src/js/utils/icons.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Custom icons 3 | */ 4 | const icons = {}; 5 | 6 | icons.at = 7 | ; 16 | 17 | icons.twitter = 18 | ; 31 | 32 | icons.pluginCard = 33 | ; 74 | 75 | 76 | icons.highlight = 77 | 80 | 81 | export default icons; 82 | -------------------------------------------------------------------------------- /assets/src/js/blocks/plugin-card/components/edit.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Internal dependencies 3 | */ 4 | import BlockControls from './controls'; 5 | import icons from '../../../utils/icons'; 6 | 7 | /** 8 | * WordPress dependencies 9 | */ 10 | const { __ } = wp.i18n; 11 | const { Placeholder, Dashicon, TextControl, Spinner } = wp.components; 12 | const { Component, Fragment } = wp.element; 13 | 14 | /** 15 | * Block edit function 16 | */ 17 | export default class Edit extends Component { 18 | 19 | constructor( props ) { 20 | super( ...arguments ); 21 | 22 | this.state = { 23 | status: 'loading-plugin', 24 | searchInput: '', 25 | pluginList: [], 26 | } 27 | } 28 | 29 | searchPlugins( value ) { 30 | this.setState( { status: 'loading-results' } ); 31 | 32 | wp.apiFetch({ path: `machoblocks/v1/get_plugins?search='${ encodeURIComponent( value ) }` }).then( response => { 33 | this.setState({ 34 | pluginList: response.data.plugins, 35 | status: 'ready', 36 | }); 37 | }); 38 | } 39 | 40 | getPlugin( slug ) { 41 | this.setState( { status: 'loading-plugin' } ); 42 | 43 | wp.apiFetch({ path: `machoblocks/v1/get_plugins?slug='${ encodeURIComponent( slug ) }` }).then( response => { 44 | this.setPlugin( response.data ); 45 | this.setState({ status: 'ready' }); 46 | }); 47 | } 48 | 49 | setPlugin( plugin ) { 50 | this.props.setAttributes({ 51 | pluginSlug: plugin.slug, 52 | pluginName: plugin.name, 53 | pluginIcon: this.getPluginIcon( plugin ), 54 | pluginVersion: plugin.version, 55 | pluginAuthor: plugin.author, 56 | pluginRating: plugin.rating, 57 | pluginDescription: plugin.short_description, 58 | pluginActiveInstalls: plugin.active_installs, 59 | pluginDownloadLink: plugin.download_link 60 | }); 61 | } 62 | 63 | componentWillMount() { 64 | if( this.props.attributes.pluginSlug !== '' ) { 65 | this.getPlugin( this.props.attributes.pluginSlug ); 66 | } 67 | else { 68 | this.setState( { status: 'ready' } ); 69 | } 70 | } 71 | 72 | onPluginSelectClick( plugin ) { 73 | this.setPlugin( plugin ); 74 | this.setState( { pluginList: [] } ); 75 | } 76 | 77 | onSearchChange( value ){ 78 | 79 | this.setState( { searchInput: value } ); 80 | 81 | clearTimeout(this.timeout); 82 | 83 | if( value.length < 3 ) { 84 | this.setState( { pluginList: [] } ); 85 | } 86 | 87 | if( value.length >= 3 && this.state.status === 'ready' ) { 88 | this.timeout = setTimeout( () => this.searchPlugins( value ), 500 ); 89 | } 90 | } 91 | 92 | getPluginIcon( plugin ) { 93 | let icon = ''; 94 | if ( plugin.icons['2x'] ) { 95 | icon = plugin.icons['2x']; 96 | } else if ( plugin.icons['1x'] ) { 97 | icon = plugin.icons['x']; 98 | } else if ( plugin.icons.default ) { 99 | icon = plugin.icons.default; 100 | } 101 | 102 | return icon; 103 | } 104 | 105 | getNiceNumber( n ) { 106 | if ( n > 1000000000 ) { 107 | return Math.round( n / 1000000000 ) + '+' + ' billion'; 108 | } else if ( n > 1000000 ) { 109 | return Math.round( n / 1000000 ) + '+' + ' million'; 110 | } 111 | 112 | return n + '+'; 113 | } 114 | 115 | getStars( r ) { 116 | let rating = Math.round( r / 10 ) / 2; 117 | let fullStars = Math.floor( rating ); 118 | let halfStars = Math.ceil( rating - fullStars ); 119 | let emptyStars = 5 - fullStars - halfStars; 120 | 121 | let output = []; 122 | 123 | _.times( fullStars, () => { 124 | output.push(); 125 | }); 126 | 127 | _.times( halfStars, () => { 128 | output.push(); 129 | }); 130 | 131 | _.times( emptyStars, () => { 132 | output.push(); 133 | }); 134 | 135 | return output; 136 | } 137 | 138 | render() { 139 | 140 | const { status, pluginList, searchInput } = this.state; 141 | const { attributes, setAttributes, className } = this.props; 142 | const { pluginSlug, pluginName, pluginIcon, pluginVersion, pluginAuthor, pluginRating, pluginDescription, pluginActiveInstalls, pluginDownloadLink } = attributes; 143 | 144 | if ( status === 'loading-plugin' ) { 145 | return [ 146 |205 | 214 |
{ pluginDescription }
' + content + '
' 428 | }); 429 | } 430 | }, { 431 | type: 'block', 432 | blocks: ['core/quote'], 433 | transform: function transform(_ref6) { 434 | var content = _ref6.content; 435 | return createBlock('core/quote', { 436 | value: '' + content + '
' 437 | }); 438 | } 439 | }] 440 | }, 441 | 442 | edit: _edit2.default, 443 | 444 | save: function save(_ref7) { 445 | var _classnames; 446 | 447 | var attributes = _ref7.attributes; 448 | var buttonColor = attributes.buttonColor, 449 | buttonText = attributes.buttonText, 450 | customButtonColor = attributes.customButtonColor, 451 | customTextColor = attributes.customTextColor, 452 | content = attributes.content, 453 | customFontSize = attributes.customFontSize, 454 | fontSize = attributes.fontSize, 455 | textColor = attributes.textColor, 456 | textAlign = attributes.textAlign, 457 | url = attributes.url, 458 | via = attributes.via; 459 | 460 | 461 | var viaUrl = via ? '&via=' + via : ''; 462 | 463 | var tweetUrl = 'http://twitter.com/share?&text=' + encodeURIComponent(content) + '&url=' + url + viaUrl; 464 | 465 | var textColorClass = getColorClassName('color', textColor); 466 | 467 | var fontSizeClass = getFontSizeClass(fontSize); 468 | 469 | var textClasses = (0, _classnames4.default)('wp-block-machoblocks-click-to-tweet__text', (_classnames = { 470 | 'has-text-color': textColor || customTextColor 471 | }, _defineProperty(_classnames, fontSizeClass, fontSizeClass), _defineProperty(_classnames, textColorClass, textColorClass), _classnames)); 472 | 473 | var textStyles = { 474 | fontSize: fontSizeClass ? undefined : customFontSize, 475 | color: textColorClass ? undefined : customTextColor 476 | }; 477 | 478 | var buttonColorClass = getColorClassName('background-color', buttonColor); 479 | 480 | var buttonClasses = (0, _classnames4.default)('wp-block-machoblocks-click-to-tweet__twitter-btn', _defineProperty({ 481 | 'has-button-color': buttonColor || customButtonColor 482 | }, buttonColorClass, buttonColorClass)); 483 | 484 | var buttonStyles = { 485 | backgroundColor: buttonColorClass ? undefined : customButtonColor 486 | }; 487 | 488 | return !RichText.isEmpty(content) && React.createElement( 489 | 'blockquote', 490 | { style: { textAlign: textAlign } }, 491 | React.createElement(RichText.Content, { 492 | tagName: 'p', 493 | className: textClasses, 494 | style: textStyles, 495 | value: content 496 | }), 497 | React.createElement(RichText.Content, { 498 | tagName: 'a', 499 | className: buttonClasses, 500 | style: buttonStyles, 501 | value: buttonText, 502 | href: tweetUrl, 503 | target: '_blank', 504 | rel: 'noopener noreferrer' 505 | }) 506 | ); 507 | } 508 | }; 509 | 510 | exports.name = name; 511 | exports.title = title; 512 | exports.icon = icon; 513 | exports.settings = settings; 514 | 515 | /***/ }), 516 | /* 5 */ 517 | /***/ (function(module, exports, __webpack_require__) { 518 | 519 | "use strict"; 520 | 521 | 522 | Object.defineProperty(exports, "__esModule", { 523 | value: true 524 | }); 525 | exports.settings = exports.icon = exports.title = exports.name = undefined; 526 | 527 | var _classnames2 = __webpack_require__(0); 528 | 529 | var _classnames3 = _interopRequireDefault(_classnames2); 530 | 531 | var _edit = __webpack_require__(11); 532 | 533 | var _edit2 = _interopRequireDefault(_edit); 534 | 535 | var _icons = __webpack_require__(3); 536 | 537 | var _icons2 = _interopRequireDefault(_icons); 538 | 539 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 540 | 541 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /** 542 | * External dependencies 543 | */ 544 | 545 | 546 | /** 547 | * Internal dependencies 548 | */ 549 | 550 | 551 | /** 552 | * WordPress dependencies 553 | */ 554 | var __ = wp.i18n.__; 555 | var createBlock = wp.blocks.createBlock; 556 | var _wp$editor = wp.editor, 557 | RichText = _wp$editor.RichText, 558 | getColorClassName = _wp$editor.getColorClassName, 559 | getFontSizeClass = _wp$editor.getFontSizeClass; 560 | 561 | /** 562 | * Block constants 563 | */ 564 | 565 | var name = 'highlight'; 566 | 567 | var title = __('Highlight'); 568 | 569 | var icon = _icons2.default.highlight; 570 | 571 | var keywords = [__('text'), __('paragraph'), __('highlight')]; 572 | 573 | var blockAttributes = { 574 | content: { 575 | type: 'string', 576 | source: 'html', 577 | selector: 'mark' 578 | }, 579 | align: { 580 | type: 'string' 581 | }, 582 | backgroundColor: { 583 | type: 'string' 584 | }, 585 | textColor: { 586 | type: 'string' 587 | }, 588 | customBackgroundColor: { 589 | type: 'string' 590 | }, 591 | customTextColor: { 592 | type: 'string' 593 | }, 594 | fontSize: { 595 | type: 'string' 596 | }, 597 | customFontSize: { 598 | type: 'number' 599 | } 600 | }; 601 | 602 | var settings = { 603 | 604 | title: title, 605 | 606 | description: __('Highlight text.'), 607 | 608 | keywords: keywords, 609 | 610 | attributes: blockAttributes, 611 | 612 | transforms: { 613 | from: [{ 614 | type: 'block', 615 | blocks: ['core/paragraph'], 616 | transform: function transform(_ref) { 617 | var content = _ref.content; 618 | 619 | return createBlock('machoblocks/' + name, { 620 | content: content 621 | }); 622 | } 623 | }, { 624 | type: 'raw', 625 | selector: 'div.wp-block-machoblocks-highlight', 626 | schema: { 627 | div: { 628 | classes: ['wp-block-machoblocks-highlight'] 629 | } 630 | } 631 | }, { 632 | type: 'prefix', 633 | prefix: ':highlight', 634 | transform: function transform(content) { 635 | return createBlock('machoblocks/' + name, { 636 | content: content 637 | }); 638 | } 639 | }], 640 | to: [{ 641 | type: 'block', 642 | blocks: ['core/paragraph'], 643 | transform: function transform(_ref2) { 644 | var content = _ref2.content; 645 | 646 | // transforming an empty block 647 | if (!content || !content.length) { 648 | return createBlock('core/paragraph'); 649 | } 650 | // transforming a block with content 651 | return createBlock('core/paragraph', { 652 | content: content 653 | }); 654 | } 655 | }] 656 | }, 657 | 658 | edit: _edit2.default, 659 | 660 | save: function save(_ref3) { 661 | var _classnames; 662 | 663 | var attributes = _ref3.attributes; 664 | var backgroundColor = attributes.backgroundColor, 665 | content = attributes.content, 666 | customBackgroundColor = attributes.customBackgroundColor, 667 | customFontSize = attributes.customFontSize, 668 | customTextColor = attributes.customTextColor, 669 | fontSize = attributes.fontSize, 670 | textAlign = attributes.textAlign, 671 | textColor = attributes.textColor; 672 | 673 | 674 | var textClass = getColorClassName('color', textColor); 675 | 676 | var backgroundClass = getColorClassName('background-color', backgroundColor); 677 | 678 | var fontSizeClass = getFontSizeClass(fontSize); 679 | 680 | var classes = (0, _classnames3.default)('wp-block-machoblocks-highlight__content', (_classnames = { 681 | 'has-text-color': textColor || customTextColor 682 | }, _defineProperty(_classnames, textClass, textClass), _defineProperty(_classnames, 'has-background', backgroundColor || customBackgroundColor), _defineProperty(_classnames, backgroundClass, backgroundClass), _defineProperty(_classnames, fontSizeClass, fontSizeClass), _classnames)); 683 | 684 | var styles = { 685 | backgroundColor: backgroundClass ? undefined : customBackgroundColor, 686 | color: textClass ? undefined : customTextColor, 687 | fontSize: fontSizeClass ? undefined : customFontSize 688 | }; 689 | 690 | return React.createElement( 691 | 'p', 692 | { style: { textAlign: textAlign } }, 693 | !RichText.isEmpty(content) && React.createElement(RichText.Content, { 694 | tagName: 'mark', 695 | className: classes, 696 | style: styles, 697 | value: content 698 | }) 699 | ); 700 | } 701 | }; 702 | 703 | exports.name = name; 704 | exports.title = title; 705 | exports.icon = icon; 706 | exports.settings = settings; 707 | 708 | /***/ }), 709 | /* 6 */ 710 | /***/ (function(module, exports, __webpack_require__) { 711 | 712 | "use strict"; 713 | 714 | 715 | Object.defineProperty(exports, "__esModule", { 716 | value: true 717 | }); 718 | exports.settings = exports.icon = exports.title = exports.name = undefined; 719 | 720 | var _classnames = __webpack_require__(0); 721 | 722 | var _classnames2 = _interopRequireDefault(_classnames); 723 | 724 | var _edit = __webpack_require__(14); 725 | 726 | var _edit2 = _interopRequireDefault(_edit); 727 | 728 | var _icons = __webpack_require__(3); 729 | 730 | var _icons2 = _interopRequireDefault(_icons); 731 | 732 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 733 | 734 | /** 735 | * WordPress dependencies 736 | */ 737 | 738 | 739 | /** 740 | * Internal dependencies 741 | */ 742 | var __ = wp.i18n.__; 743 | 744 | /** 745 | * Block constants 746 | */ 747 | /** 748 | * External dependencies 749 | */ 750 | 751 | var name = 'plugin-card'; 752 | 753 | var title = __('Plugin Card'); 754 | 755 | var icon = _icons2.default.pluginCard; 756 | 757 | var keywords = [__('plugin'), __('w.org'), __('card')]; 758 | 759 | var blockAttributes = { 760 | pluginSlug: { 761 | type: 'string', 762 | default: '' 763 | } 764 | }; 765 | 766 | var settings = { 767 | 768 | title: title, 769 | 770 | description: __('Display a WordPress plugin card from w.org.'), 771 | 772 | keywords: keywords, 773 | 774 | attributes: blockAttributes, 775 | 776 | edit: _edit2.default, 777 | 778 | save: function save() { 779 | return null; 780 | } 781 | }; 782 | 783 | exports.name = name; 784 | exports.title = title; 785 | exports.icon = icon; 786 | exports.settings = settings; 787 | 788 | /***/ }), 789 | /* 7 */ 790 | /***/ (function(module, exports, __webpack_require__) { 791 | 792 | "use strict"; 793 | 794 | 795 | Object.defineProperty(exports, "__esModule", { 796 | value: true 797 | }); 798 | 799 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 800 | 801 | var _icons = __webpack_require__(3); 802 | 803 | var _icons2 = _interopRequireDefault(_icons); 804 | 805 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 806 | 807 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 808 | 809 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 810 | 811 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** 812 | * Internal dependencies 813 | */ 814 | 815 | 816 | /** 817 | * WordPress dependencies 818 | */ 819 | var __ = wp.i18n.__; 820 | var _wp$element = wp.element, 821 | Component = _wp$element.Component, 822 | Fragment = _wp$element.Fragment; 823 | var Toolbar = wp.components.Toolbar; 824 | var _wp$editor = wp.editor, 825 | AlignmentToolbar = _wp$editor.AlignmentToolbar, 826 | BlockControls = _wp$editor.BlockControls; 827 | 828 | var Controls = function (_Component) { 829 | _inherits(Controls, _Component); 830 | 831 | function Controls(props) { 832 | _classCallCheck(this, Controls); 833 | 834 | return _possibleConstructorReturn(this, (Controls.__proto__ || Object.getPrototypeOf(Controls)).apply(this, arguments)); 835 | } 836 | 837 | _createClass(Controls, [{ 838 | key: 'render', 839 | value: function render() { 840 | var _props = this.props, 841 | className = _props.className, 842 | attributes = _props.attributes, 843 | isSelected = _props.isSelected, 844 | setAttributes = _props.setAttributes; 845 | var textAlign = attributes.textAlign, 846 | via = attributes.via; 847 | 848 | 849 | return React.createElement( 850 | Fragment, 851 | null, 852 | React.createElement( 853 | BlockControls, 854 | null, 855 | React.createElement(AlignmentToolbar, { 856 | value: textAlign, 857 | onChange: function onChange(nextTextAlign) { 858 | return setAttributes({ textAlign: nextTextAlign }); 859 | } 860 | }), 861 | React.createElement( 862 | Toolbar, 863 | null, 864 | React.createElement( 865 | 'div', 866 | { className: className + '__via-wrapper' }, 867 | React.createElement( 868 | 'label', 869 | { 870 | 'aria-label': __('Twitter Username'), 871 | className: className + '__via-label', 872 | htmlFor: className + '__via' 873 | }, 874 | _icons2.default.at 875 | ), 876 | React.createElement('input', { 877 | 'aria-label': __('Twitter Username'), 878 | className: className + '__via', 879 | id: className + '__via', 880 | onChange: function onChange(event) { 881 | return setAttributes({ via: event.target.value }); 882 | }, 883 | placeholder: __('Username'), 884 | type: 'text', 885 | value: via 886 | }) 887 | ) 888 | ) 889 | ) 890 | ); 891 | } 892 | }]); 893 | 894 | return Controls; 895 | }(Component); 896 | 897 | ; 898 | 899 | exports.default = Controls; 900 | 901 | /***/ }), 902 | /* 8 */ 903 | /***/ (function(module, exports, __webpack_require__) { 904 | 905 | "use strict"; 906 | 907 | 908 | Object.defineProperty(exports, "__esModule", { 909 | value: true 910 | }); 911 | 912 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 913 | 914 | var _classnames3 = __webpack_require__(0); 915 | 916 | var _classnames4 = _interopRequireDefault(_classnames3); 917 | 918 | var _colors = __webpack_require__(1); 919 | 920 | var _colors2 = _interopRequireDefault(_colors); 921 | 922 | var _inspector = __webpack_require__(9); 923 | 924 | var _inspector2 = _interopRequireDefault(_inspector); 925 | 926 | var _controls = __webpack_require__(7); 927 | 928 | var _controls2 = _interopRequireDefault(_controls); 929 | 930 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 931 | 932 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 933 | 934 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 935 | 936 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 937 | 938 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** 939 | * External dependencies 940 | */ 941 | 942 | 943 | /** 944 | * Internal dependencies 945 | */ 946 | 947 | 948 | /** 949 | * WordPress dependencies 950 | */ 951 | var __ = wp.i18n.__; 952 | var _wp$element = wp.element, 953 | Component = _wp$element.Component, 954 | Fragment = _wp$element.Fragment; 955 | var compose = wp.compose.compose; 956 | var _wp$editor = wp.editor, 957 | RichText = _wp$editor.RichText, 958 | withFontSizes = _wp$editor.withFontSizes; 959 | var withSelect = wp.data.withSelect; 960 | 961 | /** 962 | * Block constants 963 | */ 964 | 965 | var applyWithSelect = withSelect(function (select) { 966 | var _select = select('core/editor'), 967 | getPermalink = _select.getPermalink; 968 | 969 | return { 970 | postLink: getPermalink() 971 | }; 972 | }); 973 | 974 | /** 975 | * Block edit function 976 | */ 977 | 978 | var Edit = function (_Component) { 979 | _inherits(Edit, _Component); 980 | 981 | function Edit() { 982 | _classCallCheck(this, Edit); 983 | 984 | return _possibleConstructorReturn(this, (Edit.__proto__ || Object.getPrototypeOf(Edit)).apply(this, arguments)); 985 | } 986 | 987 | _createClass(Edit, [{ 988 | key: 'componentWillReceiveProps', 989 | value: function componentWillReceiveProps(_ref) { 990 | var postLink = _ref.postLink; 991 | 992 | if (postLink) { 993 | this.props.setAttributes({ 994 | url: postLink 995 | }); 996 | } 997 | } 998 | }, { 999 | key: 'render', 1000 | value: function render() { 1001 | var _classnames; 1002 | 1003 | var _props = this.props, 1004 | attributes = _props.attributes, 1005 | buttonColor = _props.buttonColor, 1006 | className = _props.className, 1007 | isSelected = _props.isSelected, 1008 | setAttributes = _props.setAttributes, 1009 | setButtonColor = _props.setButtonColor, 1010 | setTextColor = _props.setTextColor, 1011 | textColor = _props.textColor, 1012 | fallbackButtonColor = _props.fallbackButtonColor, 1013 | fallbackTextColor = _props.fallbackTextColor, 1014 | fallbackFontSize = _props.fallbackFontSize, 1015 | fontSize = _props.fontSize, 1016 | onReplace = _props.onReplace; 1017 | var buttonText = attributes.buttonText, 1018 | content = attributes.content, 1019 | url = attributes.url, 1020 | via = attributes.via, 1021 | textAlign = attributes.textAlign; 1022 | 1023 | 1024 | return [React.createElement( 1025 | Fragment, 1026 | null, 1027 | isSelected && React.createElement(_controls2.default, this.props), 1028 | isSelected && React.createElement(_inspector2.default, this.props), 1029 | React.createElement( 1030 | 'blockquote', 1031 | { className: className, style: { textAlign: textAlign } }, 1032 | React.createElement(RichText, { 1033 | tagName: 'p', 1034 | multiline: 'false' 1035 | /* translators: the text of the click to tweet element */ 1036 | , placeholder: __('Add a quote to tweet...'), 1037 | value: content, 1038 | formattingControls: [] // disable controls 1039 | , className: (0, _classnames4.default)(className + '__text', (_classnames = { 1040 | 'has-text-color': textColor.color 1041 | }, _defineProperty(_classnames, textColor.class, textColor.class), _defineProperty(_classnames, fontSize.class, fontSize.class), _classnames)), 1042 | style: { 1043 | color: textColor.color, 1044 | fontSize: fontSize.size ? fontSize.size + 'px' : undefined 1045 | }, 1046 | onChange: function onChange(nextContent) { 1047 | return setAttributes({ content: nextContent }); 1048 | }, 1049 | keepPlaceholderOnFocus: true, 1050 | onRemove: function onRemove(forward) { 1051 | var hasEmptyTweet = content.length === 0 || content.length === 1; 1052 | 1053 | if (!forward && hasEmptyTweet) { 1054 | onReplace([]); 1055 | } 1056 | } 1057 | }), 1058 | React.createElement(RichText, { 1059 | tagName: 'span', 1060 | multiline: 'false', 1061 | placeholder: __('Add button...'), 1062 | value: buttonText, 1063 | formattingControls: [] // disable controls 1064 | , className: (0, _classnames4.default)(className + '__twitter-btn', _defineProperty({ 1065 | 'has-button-color': buttonColor.color 1066 | }, buttonColor.class, buttonColor.class)), 1067 | style: { 1068 | backgroundColor: buttonColor.color 1069 | }, 1070 | onChange: function onChange(nextButtonText) { 1071 | return setAttributes({ buttonText: nextButtonText }); 1072 | }, 1073 | keepPlaceholderOnFocus: true 1074 | }) 1075 | ) 1076 | )]; 1077 | } 1078 | }]); 1079 | 1080 | return Edit; 1081 | }(Component); 1082 | 1083 | ; 1084 | 1085 | exports.default = compose([applyWithSelect, _colors2.default, withFontSizes('fontSize')])(Edit); 1086 | 1087 | /***/ }), 1088 | /* 9 */ 1089 | /***/ (function(module, exports, __webpack_require__) { 1090 | 1091 | "use strict"; 1092 | 1093 | 1094 | Object.defineProperty(exports, "__esModule", { 1095 | value: true 1096 | }); 1097 | 1098 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 1099 | 1100 | var _colors = __webpack_require__(1); 1101 | 1102 | var _colors2 = _interopRequireDefault(_colors); 1103 | 1104 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1105 | 1106 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1107 | 1108 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 1109 | 1110 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** 1111 | * Internal dependencies 1112 | */ 1113 | 1114 | 1115 | /** 1116 | * WordPress dependencies 1117 | */ 1118 | var __ = wp.i18n.__; 1119 | var _wp$element = wp.element, 1120 | Component = _wp$element.Component, 1121 | Fragment = _wp$element.Fragment; 1122 | var compose = wp.compose.compose; 1123 | var _wp$editor = wp.editor, 1124 | InspectorControls = _wp$editor.InspectorControls, 1125 | ContrastChecker = _wp$editor.ContrastChecker, 1126 | PanelColorSettings = _wp$editor.PanelColorSettings, 1127 | FontSizePicker = _wp$editor.FontSizePicker, 1128 | withFontSizes = _wp$editor.withFontSizes; 1129 | var _wp$components = wp.components, 1130 | PanelBody = _wp$components.PanelBody, 1131 | withFallbackStyles = _wp$components.withFallbackStyles; 1132 | 1133 | /** 1134 | * Contrast checker 1135 | */ 1136 | 1137 | var _window = window, 1138 | getComputedStyle = _window.getComputedStyle; 1139 | 1140 | 1141 | var applyFallbackStyles = withFallbackStyles(function (node, ownProps) { 1142 | var _ownProps$attributes = ownProps.attributes, 1143 | textColor = _ownProps$attributes.textColor, 1144 | buttonColor = _ownProps$attributes.buttonColor, 1145 | fontSize = _ownProps$attributes.fontSize, 1146 | customFontSize = _ownProps$attributes.customFontSize; 1147 | 1148 | var editableNode = node.querySelector('[contenteditable="true"]'); 1149 | //verify if editableNode is available, before using getComputedStyle. 1150 | var computedStyles = editableNode ? getComputedStyle(editableNode) : null; 1151 | return { 1152 | fallbackButtonColor: buttonColor || !computedStyles ? undefined : computedStyles.buttonColor, 1153 | fallbackTextColor: textColor || !computedStyles ? undefined : computedStyles.color, 1154 | fallbackFontSize: fontSize || customFontSize || !computedStyles ? undefined : parseInt(computedStyles.fontSize) || undefined 1155 | }; 1156 | }); 1157 | 1158 | /** 1159 | * Inspector controls 1160 | */ 1161 | 1162 | var Inspector = function (_Component) { 1163 | _inherits(Inspector, _Component); 1164 | 1165 | function Inspector(props) { 1166 | _classCallCheck(this, Inspector); 1167 | 1168 | return _possibleConstructorReturn(this, (Inspector.__proto__ || Object.getPrototypeOf(Inspector)).apply(this, arguments)); 1169 | } 1170 | 1171 | _createClass(Inspector, [{ 1172 | key: 'render', 1173 | value: function render() { 1174 | var _props = this.props, 1175 | attributes = _props.attributes, 1176 | buttonColor = _props.buttonColor, 1177 | fallbackButtonColor = _props.fallbackButtonColor, 1178 | fallbackFontSize = _props.fallbackFontSize, 1179 | fallbackTextColor = _props.fallbackTextColor, 1180 | fontSize = _props.fontSize, 1181 | isSelected = _props.isSelected, 1182 | setAttributes = _props.setAttributes, 1183 | setButtonColor = _props.setButtonColor, 1184 | setFontSize = _props.setFontSize, 1185 | setTextColor = _props.setTextColor, 1186 | textColor = _props.textColor; 1187 | 1188 | 1189 | return React.createElement( 1190 | Fragment, 1191 | null, 1192 | React.createElement( 1193 | InspectorControls, 1194 | null, 1195 | React.createElement( 1196 | PanelBody, 1197 | { title: __('Text Settings'), className: 'blocks-font-size' }, 1198 | React.createElement(FontSizePicker, { 1199 | fallbackFontSize: fallbackFontSize, 1200 | value: fontSize.size, 1201 | onChange: setFontSize 1202 | }) 1203 | ), 1204 | React.createElement( 1205 | PanelColorSettings, 1206 | { 1207 | title: __('Color Settings'), 1208 | initialOpen: false, 1209 | colorSettings: [{ 1210 | value: textColor.color, 1211 | onChange: setTextColor, 1212 | label: __('Text Color') 1213 | }, { 1214 | value: buttonColor.color, 1215 | onChange: setButtonColor, 1216 | label: __('Button Color') 1217 | }] 1218 | }, 1219 | React.createElement(ContrastChecker, { 1220 | textColor: '#ffffff', 1221 | backgroundColor: buttonColor.color, 1222 | fallbackButtonColor: fallbackButtonColor, 1223 | fallbackTextColor: fallbackTextColor 1224 | }) 1225 | ) 1226 | ) 1227 | ); 1228 | } 1229 | }]); 1230 | 1231 | return Inspector; 1232 | }(Component); 1233 | 1234 | exports.default = compose([_colors2.default, applyFallbackStyles, withFontSizes('fontSize')])(Inspector); 1235 | 1236 | /***/ }), 1237 | /* 10 */ 1238 | /***/ (function(module, exports, __webpack_require__) { 1239 | 1240 | "use strict"; 1241 | 1242 | 1243 | Object.defineProperty(exports, "__esModule", { 1244 | value: true 1245 | }); 1246 | 1247 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 1248 | 1249 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1250 | 1251 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 1252 | 1253 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 1254 | 1255 | /** 1256 | * WordPress dependencies 1257 | */ 1258 | var __ = wp.i18n.__; 1259 | var _wp$element = wp.element, 1260 | Component = _wp$element.Component, 1261 | Fragment = _wp$element.Fragment; 1262 | var _wp$editor = wp.editor, 1263 | BlockControls = _wp$editor.BlockControls, 1264 | AlignmentToolbar = _wp$editor.AlignmentToolbar; 1265 | 1266 | var Controls = function (_Component) { 1267 | _inherits(Controls, _Component); 1268 | 1269 | function Controls(props) { 1270 | _classCallCheck(this, Controls); 1271 | 1272 | return _possibleConstructorReturn(this, (Controls.__proto__ || Object.getPrototypeOf(Controls)).apply(this, arguments)); 1273 | } 1274 | 1275 | _createClass(Controls, [{ 1276 | key: "render", 1277 | value: function render() { 1278 | var _props = this.props, 1279 | attributes = _props.attributes, 1280 | setAttributes = _props.setAttributes; 1281 | var align = attributes.align; 1282 | 1283 | 1284 | return React.createElement( 1285 | Fragment, 1286 | null, 1287 | React.createElement( 1288 | BlockControls, 1289 | null, 1290 | React.createElement(AlignmentToolbar, { 1291 | value: align, 1292 | onChange: function onChange(nextAlign) { 1293 | return setAttributes({ align: nextAlign }); 1294 | } 1295 | }) 1296 | ) 1297 | ); 1298 | } 1299 | }]); 1300 | 1301 | return Controls; 1302 | }(Component); 1303 | 1304 | ; 1305 | 1306 | exports.default = Controls; 1307 | 1308 | /***/ }), 1309 | /* 11 */ 1310 | /***/ (function(module, exports, __webpack_require__) { 1311 | 1312 | "use strict"; 1313 | 1314 | 1315 | Object.defineProperty(exports, "__esModule", { 1316 | value: true 1317 | }); 1318 | 1319 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 1320 | 1321 | var _classnames2 = __webpack_require__(0); 1322 | 1323 | var _classnames3 = _interopRequireDefault(_classnames2); 1324 | 1325 | var _colors = __webpack_require__(2); 1326 | 1327 | var _colors2 = _interopRequireDefault(_colors); 1328 | 1329 | var _controls = __webpack_require__(10); 1330 | 1331 | var _controls2 = _interopRequireDefault(_controls); 1332 | 1333 | var _inspector = __webpack_require__(12); 1334 | 1335 | var _inspector2 = _interopRequireDefault(_inspector); 1336 | 1337 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1338 | 1339 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 1340 | 1341 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1342 | 1343 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 1344 | 1345 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** 1346 | * External dependencies 1347 | */ 1348 | 1349 | 1350 | /** 1351 | * Internal dependencies 1352 | */ 1353 | 1354 | 1355 | /** 1356 | * WordPress dependencies 1357 | */ 1358 | var __ = wp.i18n.__; 1359 | var _wp$element = wp.element, 1360 | Component = _wp$element.Component, 1361 | Fragment = _wp$element.Fragment; 1362 | var compose = wp.compose.compose; 1363 | var _wp$editor = wp.editor, 1364 | RichText = _wp$editor.RichText, 1365 | withFontSizes = _wp$editor.withFontSizes; 1366 | var createBlock = wp.blocks.createBlock; 1367 | 1368 | /** 1369 | * Block edit function 1370 | */ 1371 | 1372 | var Edit = function (_Component) { 1373 | _inherits(Edit, _Component); 1374 | 1375 | function Edit(props) { 1376 | _classCallCheck(this, Edit); 1377 | 1378 | var _this = _possibleConstructorReturn(this, (Edit.__proto__ || Object.getPrototypeOf(Edit)).apply(this, arguments)); 1379 | 1380 | _this.splitBlock = _this.splitBlock.bind(_this); 1381 | return _this; 1382 | } 1383 | 1384 | /** 1385 | * Split handler for RichText value, namely when content is pasted or the 1386 | * user presses the Enter key. 1387 | * 1388 | * @param {?Array} before Optional before value, to be used as content 1389 | * in place of what exists currently for the 1390 | * block. If undefined, the block is deleted. 1391 | * @param {?Array} after Optional after value, to be appended in a new 1392 | * paragraph block to the set of blocks passed 1393 | * as spread. 1394 | * @param {...WPBlock} blocks Optional blocks inserted between the before 1395 | * and after value blocks. 1396 | */ 1397 | 1398 | 1399 | _createClass(Edit, [{ 1400 | key: 'splitBlock', 1401 | value: function splitBlock(before, after) { 1402 | var _props = this.props, 1403 | attributes = _props.attributes, 1404 | insertBlocksAfter = _props.insertBlocksAfter, 1405 | setAttributes = _props.setAttributes, 1406 | onReplace = _props.onReplace; 1407 | 1408 | for (var _len = arguments.length, blocks = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { 1409 | blocks[_key - 2] = arguments[_key]; 1410 | } 1411 | 1412 | if (after) { 1413 | // Append "After" content as a new paragraph block to the end of 1414 | // any other blocks being inserted after the current paragraph. 1415 | blocks.push(createBlock('core/paragraph', { content: after })); 1416 | } 1417 | 1418 | if (blocks.length && insertBlocksAfter) { 1419 | insertBlocksAfter(blocks); 1420 | } 1421 | 1422 | var content = attributes.content; 1423 | 1424 | 1425 | if (!before) { 1426 | // If before content is omitted, treat as intent to delete block. 1427 | onReplace([]); 1428 | } else if (content !== before) { 1429 | // Only update content if it has in-fact changed. In case that user 1430 | // has created a new paragraph at end of an existing one, the value 1431 | // of before will be strictly equal to the current content. 1432 | setAttributes({ content: before }); 1433 | } 1434 | } 1435 | }, { 1436 | key: 'render', 1437 | value: function render() { 1438 | var _classnames; 1439 | 1440 | var _props2 = this.props, 1441 | attributes = _props2.attributes, 1442 | backgroundColor = _props2.backgroundColor, 1443 | className = _props2.className, 1444 | insertBlocksAfter = _props2.insertBlocksAfter, 1445 | isSelected = _props2.isSelected, 1446 | mergeBlocks = _props2.mergeBlocks, 1447 | onReplace = _props2.onReplace, 1448 | setAttributes = _props2.setAttributes, 1449 | setBackgroundColor = _props2.setBackgroundColor, 1450 | setTextColor = _props2.setTextColor, 1451 | textColor = _props2.textColor, 1452 | fallbackFontSize = _props2.fallbackFontSize, 1453 | fontSize = _props2.fontSize; 1454 | var content = attributes.content, 1455 | textAlign = attributes.textAlign; 1456 | 1457 | 1458 | return [React.createElement( 1459 | Fragment, 1460 | null, 1461 | isSelected && React.createElement(_controls2.default, this.props), 1462 | isSelected && React.createElement(_inspector2.default, this.props), 1463 | React.createElement( 1464 | 'p', 1465 | { className: className, style: { textAlign: textAlign } }, 1466 | React.createElement(RichText, { 1467 | tagName: 'mark', 1468 | placeholder: __('Add highlighted text...'), 1469 | value: content, 1470 | onChange: function onChange(value) { 1471 | return setAttributes({ content: value }); 1472 | }, 1473 | onMerge: mergeBlocks, 1474 | onSplit: this.splitBlock, 1475 | onRemove: function onRemove() { 1476 | return onReplace([]); 1477 | }, 1478 | className: (0, _classnames3.default)(className + '__content', (_classnames = { 1479 | 'has-background': backgroundColor.color 1480 | }, _defineProperty(_classnames, backgroundColor.class, backgroundColor.class), _defineProperty(_classnames, 'has-text-color', textColor.color), _defineProperty(_classnames, textColor.class, textColor.class), _defineProperty(_classnames, fontSize.class, fontSize.class), _classnames)), 1481 | style: { 1482 | backgroundColor: backgroundColor.color, 1483 | color: textColor.color, 1484 | fontSize: fontSize.size ? fontSize.size + 'px' : undefined 1485 | }, 1486 | keepPlaceholderOnFocus: true 1487 | }) 1488 | ) 1489 | )]; 1490 | } 1491 | }]); 1492 | 1493 | return Edit; 1494 | }(Component); 1495 | 1496 | ; 1497 | 1498 | exports.default = compose([_colors2.default, withFontSizes('fontSize')])(Edit); 1499 | 1500 | /***/ }), 1501 | /* 12 */ 1502 | /***/ (function(module, exports, __webpack_require__) { 1503 | 1504 | "use strict"; 1505 | 1506 | 1507 | Object.defineProperty(exports, "__esModule", { 1508 | value: true 1509 | }); 1510 | 1511 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 1512 | 1513 | var _colors = __webpack_require__(2); 1514 | 1515 | var _colors2 = _interopRequireDefault(_colors); 1516 | 1517 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1518 | 1519 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1520 | 1521 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 1522 | 1523 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** 1524 | * Internal dependencies 1525 | */ 1526 | 1527 | 1528 | /** 1529 | * WordPress dependencies 1530 | */ 1531 | var __ = wp.i18n.__; 1532 | var _wp$element = wp.element, 1533 | Component = _wp$element.Component, 1534 | Fragment = _wp$element.Fragment; 1535 | var compose = wp.compose.compose; 1536 | var _wp$editor = wp.editor, 1537 | InspectorControls = _wp$editor.InspectorControls, 1538 | ContrastChecker = _wp$editor.ContrastChecker, 1539 | PanelColorSettings = _wp$editor.PanelColorSettings, 1540 | FontSizePicker = _wp$editor.FontSizePicker, 1541 | withFontSizes = _wp$editor.withFontSizes; 1542 | var _wp$components = wp.components, 1543 | PanelBody = _wp$components.PanelBody, 1544 | withFallbackStyles = _wp$components.withFallbackStyles; 1545 | 1546 | /** 1547 | * Contrast checker 1548 | */ 1549 | 1550 | var _window = window, 1551 | getComputedStyle = _window.getComputedStyle; 1552 | 1553 | 1554 | var ContrastCheckerWithFallbackStyles = withFallbackStyles(function (node, ownProps) { 1555 | var textColor = ownProps.textColor, 1556 | backgroundColor = ownProps.backgroundColor, 1557 | fontSize = ownProps.fontSize, 1558 | customFontSize = ownProps.customFontSize; 1559 | //avoid the use of querySelector if textColor color is known and verify if node is available. 1560 | 1561 | var textNode = !textColor && node ? node.querySelector('[contenteditable="true"]') : null; 1562 | return { 1563 | fallbackBackgroundColor: backgroundColor || !node ? undefined : getComputedStyle(node).backgroundColor, 1564 | fallbackTextColor: textColor || !textNode ? undefined : getComputedStyle(textNode).color, 1565 | fallbackFontSize: fontSize || customFontSize || !computedStyles ? undefined : parseInt(computedStyles.fontSize) || undefined 1566 | }; 1567 | })(ContrastChecker); 1568 | 1569 | /** 1570 | * Inspector controls 1571 | */ 1572 | 1573 | var Inspector = function (_Component) { 1574 | _inherits(Inspector, _Component); 1575 | 1576 | function Inspector(props) { 1577 | _classCallCheck(this, Inspector); 1578 | 1579 | return _possibleConstructorReturn(this, (Inspector.__proto__ || Object.getPrototypeOf(Inspector)).apply(this, arguments)); 1580 | } 1581 | 1582 | _createClass(Inspector, [{ 1583 | key: 'render', 1584 | value: function render() { 1585 | var _props = this.props, 1586 | attributes = _props.attributes, 1587 | backgroundColor = _props.backgroundColor, 1588 | textColor = _props.textColor, 1589 | setBackgroundColor = _props.setBackgroundColor, 1590 | setTextColor = _props.setTextColor, 1591 | setAttributes = _props.setAttributes, 1592 | fallbackBackgroundColor = _props.fallbackBackgroundColor, 1593 | fallbackTextColor = _props.fallbackTextColor, 1594 | setFontSize = _props.setFontSize, 1595 | fallbackFontSize = _props.fallbackFontSize, 1596 | fontSize = _props.fontSize; 1597 | 1598 | 1599 | return React.createElement( 1600 | Fragment, 1601 | null, 1602 | React.createElement( 1603 | InspectorControls, 1604 | null, 1605 | React.createElement( 1606 | PanelBody, 1607 | { title: __('Text Settings'), className: 'blocks-font-size' }, 1608 | React.createElement(FontSizePicker, { 1609 | fallbackFontSize: fallbackFontSize, 1610 | value: fontSize.size, 1611 | onChange: setFontSize 1612 | }) 1613 | ), 1614 | React.createElement( 1615 | PanelColorSettings, 1616 | { 1617 | title: __('Color Settings'), 1618 | initialOpen: false, 1619 | colorSettings: [{ 1620 | value: backgroundColor.color, 1621 | onChange: setBackgroundColor, 1622 | label: __('Background Color') 1623 | }, { 1624 | value: textColor.color, 1625 | onChange: setTextColor, 1626 | label: __('Text Color') 1627 | }] 1628 | }, 1629 | React.createElement(ContrastChecker, { 1630 | textColor: textColor.color, 1631 | backgroundColor: backgroundColor.color, 1632 | fallbackBackgroundColor: fallbackBackgroundColor, 1633 | fallbackTextColor: fallbackTextColor 1634 | }) 1635 | ) 1636 | ) 1637 | ); 1638 | } 1639 | }]); 1640 | 1641 | return Inspector; 1642 | }(Component); 1643 | 1644 | ; 1645 | 1646 | exports.default = compose([_colors2.default])(Inspector); 1647 | 1648 | /***/ }), 1649 | /* 13 */ 1650 | /***/ (function(module, exports, __webpack_require__) { 1651 | 1652 | "use strict"; 1653 | 1654 | 1655 | Object.defineProperty(exports, "__esModule", { 1656 | value: true 1657 | }); 1658 | 1659 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 1660 | 1661 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1662 | 1663 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 1664 | 1665 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 1666 | 1667 | /** 1668 | * WordPress dependencies 1669 | */ 1670 | var __ = wp.i18n.__; 1671 | var BlockControls = wp.editor.BlockControls; 1672 | var Component = wp.element.Component; 1673 | var _wp$components = wp.components, 1674 | IconButton = _wp$components.IconButton, 1675 | Toolbar = _wp$components.Toolbar; 1676 | 1677 | var Controls = function (_Component) { 1678 | _inherits(Controls, _Component); 1679 | 1680 | function Controls(props) { 1681 | _classCallCheck(this, Controls); 1682 | 1683 | return _possibleConstructorReturn(this, (Controls.__proto__ || Object.getPrototypeOf(Controls)).apply(this, arguments)); 1684 | } 1685 | 1686 | _createClass(Controls, [{ 1687 | key: 'onChangePluginClick', 1688 | value: function onChangePluginClick() { 1689 | this.props.setAttributes({ 1690 | pluginSlug: '' 1691 | }); 1692 | } 1693 | }, { 1694 | key: 'render', 1695 | value: function render() { 1696 | var _this2 = this; 1697 | 1698 | return React.createElement( 1699 | BlockControls, 1700 | null, 1701 | React.createElement( 1702 | Toolbar, 1703 | null, 1704 | React.createElement(IconButton, { 1705 | label: __('Change Plugin'), 1706 | icon: 'edit', 1707 | onClick: function onClick() { 1708 | return _this2.onChangePluginClick(); 1709 | } 1710 | }) 1711 | ) 1712 | ); 1713 | } 1714 | }]); 1715 | 1716 | return Controls; 1717 | }(Component); 1718 | 1719 | exports.default = Controls; 1720 | 1721 | /***/ }), 1722 | /* 14 */ 1723 | /***/ (function(module, exports, __webpack_require__) { 1724 | 1725 | "use strict"; 1726 | 1727 | 1728 | Object.defineProperty(exports, "__esModule", { 1729 | value: true 1730 | }); 1731 | 1732 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 1733 | 1734 | var _controls = __webpack_require__(13); 1735 | 1736 | var _controls2 = _interopRequireDefault(_controls); 1737 | 1738 | var _icons = __webpack_require__(3); 1739 | 1740 | var _icons2 = _interopRequireDefault(_icons); 1741 | 1742 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1743 | 1744 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1745 | 1746 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 1747 | 1748 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** 1749 | * Internal dependencies 1750 | */ 1751 | 1752 | 1753 | /** 1754 | * WordPress dependencies 1755 | */ 1756 | var __ = wp.i18n.__; 1757 | var _wp$components = wp.components, 1758 | Placeholder = _wp$components.Placeholder, 1759 | Dashicon = _wp$components.Dashicon, 1760 | TextControl = _wp$components.TextControl, 1761 | Spinner = _wp$components.Spinner; 1762 | var _wp$element = wp.element, 1763 | Component = _wp$element.Component, 1764 | Fragment = _wp$element.Fragment; 1765 | 1766 | /** 1767 | * Block edit function 1768 | */ 1769 | 1770 | var Edit = function (_Component) { 1771 | _inherits(Edit, _Component); 1772 | 1773 | function Edit(props) { 1774 | _classCallCheck(this, Edit); 1775 | 1776 | var _this = _possibleConstructorReturn(this, (Edit.__proto__ || Object.getPrototypeOf(Edit)).apply(this, arguments)); 1777 | 1778 | _this.state = { 1779 | status: 'loading-plugin', 1780 | searchInput: '', 1781 | pluginList: [] 1782 | }; 1783 | return _this; 1784 | } 1785 | 1786 | _createClass(Edit, [{ 1787 | key: 'searchPlugins', 1788 | value: function searchPlugins(value) { 1789 | var _this2 = this; 1790 | 1791 | this.setState({ status: 'loading-results' }); 1792 | 1793 | wp.apiFetch({ path: 'machoblocks/v1/get_plugins?search=\'' + encodeURIComponent(value) }).then(function (response) { 1794 | _this2.setState({ 1795 | pluginList: response.data.plugins, 1796 | status: 'ready' 1797 | }); 1798 | }); 1799 | } 1800 | }, { 1801 | key: 'getPlugin', 1802 | value: function getPlugin(slug) { 1803 | var _this3 = this; 1804 | 1805 | this.setState({ status: 'loading-plugin' }); 1806 | 1807 | wp.apiFetch({ path: 'machoblocks/v1/get_plugins?slug=\'' + encodeURIComponent(slug) }).then(function (response) { 1808 | _this3.setPlugin(response.data); 1809 | _this3.setState({ status: 'ready' }); 1810 | }); 1811 | } 1812 | }, { 1813 | key: 'setPlugin', 1814 | value: function setPlugin(plugin) { 1815 | this.props.setAttributes({ 1816 | pluginSlug: plugin.slug, 1817 | pluginName: plugin.name, 1818 | pluginIcon: this.getPluginIcon(plugin), 1819 | pluginVersion: plugin.version, 1820 | pluginAuthor: plugin.author, 1821 | pluginRating: plugin.rating, 1822 | pluginDescription: plugin.short_description, 1823 | pluginActiveInstalls: plugin.active_installs, 1824 | pluginDownloadLink: plugin.download_link 1825 | }); 1826 | } 1827 | }, { 1828 | key: 'componentWillMount', 1829 | value: function componentWillMount() { 1830 | if (this.props.attributes.pluginSlug !== '') { 1831 | this.getPlugin(this.props.attributes.pluginSlug); 1832 | } else { 1833 | this.setState({ status: 'ready' }); 1834 | } 1835 | } 1836 | }, { 1837 | key: 'onPluginSelectClick', 1838 | value: function onPluginSelectClick(plugin) { 1839 | this.setPlugin(plugin); 1840 | this.setState({ pluginList: [] }); 1841 | } 1842 | }, { 1843 | key: 'onSearchChange', 1844 | value: function onSearchChange(value) { 1845 | var _this4 = this; 1846 | 1847 | this.setState({ searchInput: value }); 1848 | 1849 | clearTimeout(this.timeout); 1850 | 1851 | if (value.length < 3) { 1852 | this.setState({ pluginList: [] }); 1853 | } 1854 | 1855 | if (value.length >= 3 && this.state.status === 'ready') { 1856 | this.timeout = setTimeout(function () { 1857 | return _this4.searchPlugins(value); 1858 | }, 500); 1859 | } 1860 | } 1861 | }, { 1862 | key: 'getPluginIcon', 1863 | value: function getPluginIcon(plugin) { 1864 | var icon = ''; 1865 | if (plugin.icons['2x']) { 1866 | icon = plugin.icons['2x']; 1867 | } else if (plugin.icons['1x']) { 1868 | icon = plugin.icons['x']; 1869 | } else if (plugin.icons.default) { 1870 | icon = plugin.icons.default; 1871 | } 1872 | 1873 | return icon; 1874 | } 1875 | }, { 1876 | key: 'getNiceNumber', 1877 | value: function getNiceNumber(n) { 1878 | if (n > 1000000000) { 1879 | return Math.round(n / 1000000000) + '+' + ' billion'; 1880 | } else if (n > 1000000) { 1881 | return Math.round(n / 1000000) + '+' + ' million'; 1882 | } 1883 | 1884 | return n + '+'; 1885 | } 1886 | }, { 1887 | key: 'getStars', 1888 | value: function getStars(r) { 1889 | var rating = Math.round(r / 10) / 2; 1890 | var fullStars = Math.floor(rating); 1891 | var halfStars = Math.ceil(rating - fullStars); 1892 | var emptyStars = 5 - fullStars - halfStars; 1893 | 1894 | var output = []; 1895 | 1896 | _.times(fullStars, function () { 1897 | output.push(React.createElement('div', { 'class': 'wp-block-machoblocks-plugin__star-full', 'aria-hidden': 'true' })); 1898 | }); 1899 | 1900 | _.times(halfStars, function () { 1901 | output.push(React.createElement('div', { 'class': 'wp-block-machoblocks-plugin__star-half', 'aria-hidden': 'true' })); 1902 | }); 1903 | 1904 | _.times(emptyStars, function () { 1905 | output.push(React.createElement('div', { 'class': 'wp-block-machoblocks-plugin__star-empty', 'aria-hidden': 'true' })); 1906 | }); 1907 | 1908 | return output; 1909 | } 1910 | }, { 1911 | key: 'render', 1912 | value: function render() { 1913 | var _this5 = this; 1914 | 1915 | var _state = this.state, 1916 | status = _state.status, 1917 | pluginList = _state.pluginList, 1918 | searchInput = _state.searchInput; 1919 | var _props = this.props, 1920 | attributes = _props.attributes, 1921 | setAttributes = _props.setAttributes, 1922 | className = _props.className; 1923 | var pluginSlug = attributes.pluginSlug, 1924 | pluginName = attributes.pluginName, 1925 | pluginIcon = attributes.pluginIcon, 1926 | pluginVersion = attributes.pluginVersion, 1927 | pluginAuthor = attributes.pluginAuthor, 1928 | pluginRating = attributes.pluginRating, 1929 | pluginDescription = attributes.pluginDescription, 1930 | pluginActiveInstalls = attributes.pluginActiveInstalls, 1931 | pluginDownloadLink = attributes.pluginDownloadLink; 1932 | 1933 | 1934 | if (status === 'loading-plugin') { 1935 | return [React.createElement( 1936 | Placeholder, 1937 | { 1938 | icon: 'admin-plugins', 1939 | label: __('Plugin Card') 1940 | }, 1941 | React.createElement(Spinner, null) 1942 | )]; 1943 | } 1944 | 1945 | if (pluginSlug === '') { 1946 | return [React.createElement( 1947 | Placeholder, 1948 | { 1949 | label: __('Plugin Card') 1950 | }, 1951 | React.createElement( 1952 | 'div', 1953 | { 'class': className + '__placeholder' }, 1954 | React.createElement(Dashicon, { icon: 'search' }), 1955 | 'loading-results' === status && React.createElement(Spinner, null), 1956 | React.createElement(TextControl, { 1957 | type: 'text', 1958 | placeholder: __('Search for a plugin'), 1959 | value: searchInput, 1960 | onChange: function onChange(value) { 1961 | return _this5.onSearchChange(value); 1962 | } 1963 | }), 1964 | pluginList.length > 0 && React.createElement( 1965 | 'div', 1966 | { 'class': className + '__search-results' }, 1967 | pluginList.map(function (plugin, index) { 1968 | return [React.createElement( 1969 | 'div', 1970 | { 1971 | key: index, 1972 | onClick: function onClick() { 1973 | return _this5.onPluginSelectClick(plugin); 1974 | } 1975 | }, 1976 | React.createElement('img', { src: _this5.getPluginIcon(plugin) }), 1977 | React.createElement( 1978 | 'span', 1979 | null, 1980 | plugin.name 1981 | ) 1982 | )]; 1983 | }) 1984 | ) 1985 | ) 1986 | )]; 1987 | } 1988 | 1989 | return [React.createElement( 1990 | Fragment, 1991 | null, 1992 | React.createElement(_controls2.default, this.props), 1993 | React.createElement( 1994 | 'div', 1995 | { 'class': className }, 1996 | React.createElement( 1997 | 'div', 1998 | { 'class': className + '__details' }, 1999 | React.createElement( 2000 | 'div', 2001 | null, 2002 | React.createElement('img', { 'class': className + '__icon', src: pluginIcon, alt: pluginName }), 2003 | React.createElement( 2004 | 'a', 2005 | { 'class': className + '__download', href: pluginDownloadLink }, 2006 | 'Download' 2007 | ) 2008 | ), 2009 | React.createElement( 2010 | 'div', 2011 | null, 2012 | React.createElement( 2013 | 'h5', 2014 | { 'class': className + '__name' }, 2015 | pluginName 2016 | ), 2017 | React.createElement( 2018 | 'div', 2019 | { 'class': className + '__description' }, 2020 | React.createElement( 2021 | 'p', 2022 | null, 2023 | pluginDescription 2024 | ) 2025 | ), 2026 | React.createElement( 2027 | 'div', 2028 | { 'class': className + '__sub' }, 2029 | React.createElement( 2030 | 'div', 2031 | { 'class': className + '__author' }, 2032 | 'by ', 2033 | React.createElement('span', { dangerouslySetInnerHTML: { __html: pluginAuthor } }) 2034 | ) 2035 | ) 2036 | ) 2037 | ), 2038 | React.createElement( 2039 | 'div', 2040 | { 'class': className + '__stats' }, 2041 | React.createElement( 2042 | 'div', 2043 | { 'class': className + '__installs' }, 2044 | React.createElement( 2045 | 'strong', 2046 | null, 2047 | __('Active Installations') 2048 | ), 2049 | React.createElement( 2050 | 'div', 2051 | null, 2052 | this.getNiceNumber(pluginActiveInstalls) 2053 | ) 2054 | ), 2055 | React.createElement( 2056 | 'div', 2057 | null, 2058 | React.createElement( 2059 | 'strong', 2060 | null, 2061 | __('Rating') 2062 | ), 2063 | React.createElement( 2064 | 'div', 2065 | { 'class': className + '__rating' }, 2066 | this.getStars(pluginRating) 2067 | ) 2068 | ), 2069 | React.createElement( 2070 | 'div', 2071 | { 'class': className + '__version' }, 2072 | React.createElement( 2073 | 'strong', 2074 | null, 2075 | __('Plugin Version') 2076 | ), 2077 | React.createElement( 2078 | 'div', 2079 | null, 2080 | pluginVersion 2081 | ) 2082 | ) 2083 | ) 2084 | ) 2085 | )]; 2086 | } 2087 | }]); 2088 | 2089 | return Edit; 2090 | }(Component); 2091 | 2092 | exports.default = Edit; 2093 | ; 2094 | 2095 | /***/ }), 2096 | /* 15 */ 2097 | /***/ (function(module, exports, __webpack_require__) { 2098 | 2099 | "use strict"; 2100 | 2101 | 2102 | Object.defineProperty(exports, "__esModule", { 2103 | value: true 2104 | }); 2105 | 2106 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 2107 | 2108 | exports.registerBlocks = registerBlocks; 2109 | 2110 | var _highlight = __webpack_require__(5); 2111 | 2112 | var highlight = _interopRequireWildcard(_highlight); 2113 | 2114 | var _clickToTweet = __webpack_require__(4); 2115 | 2116 | var clickToTweet = _interopRequireWildcard(_clickToTweet); 2117 | 2118 | var _pluginCard = __webpack_require__(6); 2119 | 2120 | var pluginCard = _interopRequireWildcard(_pluginCard); 2121 | 2122 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } 2123 | 2124 | /** 2125 | * WordPress dependencies 2126 | */ 2127 | var registerBlockType = wp.blocks.registerBlockType; 2128 | 2129 | // Category slug and title 2130 | 2131 | var category = { 2132 | slug: 'machoblocks' 2133 | }; 2134 | 2135 | function registerBlocks() { 2136 | [highlight, clickToTweet, pluginCard].forEach(function (block) { 2137 | 2138 | if (!block) { 2139 | return; 2140 | } 2141 | 2142 | var name = block.name, 2143 | icon = block.icon, 2144 | settings = block.settings; 2145 | 2146 | 2147 | registerBlockType('machoblocks/' + name, _extends({ category: category.slug, icon: { src: icon, foreground: '#6939f4' } }, settings)); 2148 | }); 2149 | }; 2150 | registerBlocks(); 2151 | 2152 | /***/ }) 2153 | /******/ ]); --------------------------------------------------------------------------------