Changeset 2175288
- Timestamp:
- 10/17/2019 08:53:03 PM (6 years ago)
- Location:
- slide/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
slide/trunk/index.js
r2175185 r2175288 11 11 url, 12 12 codeEditor 13 } ) => {13 }, FontPicker) => { 14 14 const { __ } = i18n; 15 15 const { registerBlockType, createBlock } = blocks; … … 19 19 const { PluginDocumentSettingPanel } = editPost; 20 20 const { useSelect, useDispatch, subscribe, select, dispatch } = data; 21 const { TextareaControl, ColorPicker, PanelBody, RangeControl, TextControl,SelectControl, ToggleControl, Button, FocalPointPicker, ExternalLink } = components;21 const { TextareaControl, ColorPicker, PanelBody, RangeControl, SelectControl, ToggleControl, Button, FocalPointPicker, ExternalLink } = components; 22 22 const { MediaUpload, __experimentalGradientPickerControl, InnerBlocks, InspectorControls, RichTextToolbarButton } = blockEditor; 23 23 const { addQueryArgs } = url; … … 32 32 const fontSizeKey = 'presentation-font-size'; 33 33 const fontFamilyKey = 'presentation-font-family'; 34 const fontFamilyUrlKey = 'presentation-font-url-family'; 34 35 const transitionKey = 'presentation-transition'; 35 36 const transitionSpeedKey = 'presentation-transition-speed'; … … 110 111 }; 111 112 113 console.log(meta[fontFamilyUrlKey]); 114 112 115 return [ 113 116 ...Object.keys(rules).map((key) => { … … 126 129 }), 127 130 e('style', null, meta[cssKey]), 131 !!meta[fontFamilyUrlKey] && e( 132 'style', 133 null, 134 `@import url("${meta[fontFamilyUrlKey]}")` 135 ), 128 136 e( 129 137 PluginDocumentSettingPanel, … … 141 149 onChange: (value) => updateMeta(value + '', fontSizeKey) 142 150 }), 143 e( TextControl, {151 e(FontPicker, { 144 152 label: __('Font Family', 'slide'), 145 help: __('E.g. "Helvetica, sans-serif" or "Georgia, serif"', 'slide'),146 153 value: meta[fontFamilyKey], 147 154 onChange: (value) => updateMeta(value, fontFamilyKey) … … 638 645 window.requestAnimationFrame(resize); 639 646 } 640 })(window.wp); 647 })( 648 window.wp, 649 (({ 650 i18n: { __ }, 651 element: { createElement: e }, 652 components: { BaseControl }, 653 compose: { withInstanceId }, 654 data: { select, dispatch } 655 }) => { 656 const fontFamilyUrlKey = 'presentation-font-url-family'; 657 const googleFonts = { 658 'Abril Fatface': { weight: ['400'] }, 659 Anton: { weight: ['400'] }, 660 Arvo: { weight: ['400', '700'] }, 661 Asap: { weight: ['400', '500', '600', '700'] }, 662 'Barlow Condensed': { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] }, 663 Barlow: { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] }, 664 'Cormorant Garamond': { weight: ['300', '400', '500', '600', '700'] }, 665 Faustina: { weight: ['400', '500', '600', '700'] }, 666 'Fira Sans': { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] }, 667 'IBM Plex Sans': { weight: ['100', '200', '300', '400', '500', '600', '700'] }, 668 Inconsolata: { weight: ['400', '700'] }, 669 Heebo: { weight: ['100', '300', '400', '500', '700', '800', '900'] }, 670 Karla: { weight: ['400', '700'] }, 671 Lato: { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] }, 672 Lora: { weight: ['400', '700'] }, 673 Merriweather: { weight: ['300', '400', '500', '600', '700', '800', '900'] }, 674 Montserrat: { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] }, 675 'Noto Sans': { weight: ['400', '700'] }, 676 'Noto Serif': { weight: ['400', '700'] }, 677 'Open Sans': { weight: ['300', '400', '500', '600', '700', '800'] }, 678 Oswald: { weight: ['200', '300', '400', '500', '600', '700'] }, 679 'Playfair Display': { weight: ['400', '700', '900'] }, 680 'PT Serif': { weight: ['400', '700'] }, 681 Roboto: { weight: ['100', '300', '400', '500', '700', '900'] }, 682 Rubik: { weight: ['300', '400', '500', '700', '900'] }, 683 Tajawal: { weight: ['200', '300', '400', '500', '700', '800', '900'] }, 684 Ubuntu: { weight: ['300', '400', '500', '700'] }, 685 Yrsa: { weight: ['300', '400', '500', '600', '700'] } 686 }; 687 688 return withInstanceId(({ label, value, help, instanceId, onChange, className, ...props }) => { 689 const id = `inspector-coblocks-font-family-${instanceId}`; 690 const systemFonts = [ 691 { value: '', label: __('Default') }, 692 { value: 'Arial', label: 'Arial' }, 693 { value: 'Helvetica', label: 'Helvetica' }, 694 { value: 'Times New Roman', label: 'Times New Roman' }, 695 { value: 'Georgia', label: 'Georgia' } 696 ]; 697 const fonts = []; 698 699 // Add Google Fonts 700 Object.keys(googleFonts).map((k) => { 701 fonts.push( 702 { value: k, label: k } 703 ); 704 }); 705 706 systemFonts.reverse().map((font) => { 707 fonts.unshift(font); 708 }); 709 710 const onChangeValue = ({ target: { value } }) => { 711 const googleFontsAttr = ':100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic'; 712 const isSystemFont = systemFonts.filter(function (font) { 713 return font.label === value; 714 }).length > 0; 715 716 let url = ''; 717 718 if (!isSystemFont) { 719 url = 'https://fonts.googleapis.com/css?family=' + value.replace(/ /g, '+') + googleFontsAttr; 720 } 721 722 onChange(value); 723 dispatch('core/editor').editPost({ 724 meta: { 725 [fontFamilyUrlKey]: url 726 } 727 }); 728 }; 729 730 return ( 731 e( 732 BaseControl, 733 { 734 label, 735 id, 736 help, 737 className 738 }, 739 e( 740 'select', 741 { 742 id, 743 className: 'components-select-control__input components-select-control__input--coblocks-fontfamily', 744 onChange: onChangeValue, 745 'aria-describedby': help ? `${id}__help` : undefined, 746 ...props 747 }, 748 fonts.map((option, index) => 749 e('option', { 750 key: `${option.label}-${option.value}-${index}`, 751 value: option.value, 752 selected: value === option.value ? 'selected' : '' 753 }, option.label) 754 ) 755 ) 756 ) 757 ); 758 }); 759 })(window.wp) 760 ); -
slide/trunk/index.php
r2175185 r2175288 5 5 * Plugin URI: https://wordpress.org/plugins/slide/ 6 6 * Description: Allows you to create presentations with the block editor. 7 * Version: 0.0. 77 * Version: 0.0.8 8 8 * Author: Ella van Durpe 9 9 * Author URI: https://ellavandurpe.com … … 59 59 'wp-block-editor', 60 60 'wp-url', 61 'wp-compose', 61 62 ), 62 63 filemtime( dirname( __FILE__ ) . '/index.js' ), … … 134 135 } 135 136 137 $font_url = get_post_meta( get_the_ID(), 'presentation-font-family-url', true ); 138 139 if ( $font_url ) { 140 wp_enqueue_style( 141 'slide-default-font', 142 $font_url, 143 array() 144 ); 145 } 146 136 147 wp_enqueue_style( 137 148 'slide-common', -
slide/trunk/readme.md
r2175185 r2175288 6 6 Requires PHP: 5.6 7 7 Tested up to: 5.3 8 Stable tag: 0.0. 78 Stable tag: 0.0.8 9 9 License: GPL-2.0-or-later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
slide/trunk/register.php
r2175129 r2175288 61 61 'font-size', 62 62 'font-family', 63 'font-family-url', 63 64 'transition', 64 65 'transition-speed',
Note: See TracChangeset
for help on using the changeset viewer.