Changeset 2180951
- Timestamp:
- 10/27/2019 12:32:10 PM (6 years ago)
- Location:
- slide/trunk
- Files:
-
- 6 edited
-
index.js (modified) (10 diffs)
-
index.php (modified) (1 diff)
-
readme.md (modified) (1 diff)
-
speaker.css (modified) (2 diffs)
-
speaker.js (modified) (1 diff)
-
template.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
slide/trunk/index.js
r2180454 r2180951 1 window.slide = {}; 2 window.slide.FontPicker = (({ 3 i18n: { __ }, 4 element: { createElement: e }, 5 components: { BaseControl }, 6 compose: { withInstanceId } 7 }) => { 8 const googleFonts = { 9 'Abril Fatface': { weight: ['400'] }, 10 Anton: { weight: ['400'] }, 11 Arvo: { weight: ['400', '700'] }, 12 Asap: { weight: ['400', '500', '600', '700'] }, 13 'Barlow Condensed': { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] }, 14 Barlow: { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] }, 15 'Cormorant Garamond': { weight: ['300', '400', '500', '600', '700'] }, 16 Faustina: { weight: ['400', '500', '600', '700'] }, 17 'Fira Sans': { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] }, 18 'IBM Plex Sans': { weight: ['100', '200', '300', '400', '500', '600', '700'] }, 19 Inconsolata: { weight: ['400', '700'] }, 20 Heebo: { weight: ['100', '300', '400', '500', '700', '800', '900'] }, 21 Karla: { weight: ['400', '700'] }, 22 Lato: { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] }, 23 Lora: { weight: ['400', '700'] }, 24 Merriweather: { weight: ['300', '400', '500', '600', '700', '800', '900'] }, 25 Montserrat: { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] }, 26 'Noto Sans': { weight: ['400', '700'] }, 27 'Noto Serif': { weight: ['400', '700'] }, 28 'Open Sans': { weight: ['300', '400', '500', '600', '700', '800'] }, 29 Oswald: { weight: ['200', '300', '400', '500', '600', '700'] }, 30 'Playfair Display': { weight: ['400', '700', '900'] }, 31 'PT Serif': { weight: ['400', '700'] }, 32 Roboto: { weight: ['100', '300', '400', '500', '700', '900'] }, 33 Rubik: { weight: ['300', '400', '500', '700', '900'] }, 34 Tajawal: { weight: ['200', '300', '400', '500', '700', '800', '900'] }, 35 Ubuntu: { weight: ['300', '400', '500', '700'] }, 36 Yrsa: { weight: ['300', '400', '500', '600', '700'] }, 37 'Source Serif Pro': { weight: ['200', '300', '400', '600', '700', '900'] }, 38 'Source Sans Pro': { weight: ['200', '300', '400', '600', '700', '900'] }, 39 Martel: { weight: ['200', '300', '400', '600', '700', '800', '900'] } 40 }; 41 42 return withInstanceId(({ label, value, help, instanceId, onChange, className, ...props }) => { 43 const id = `inspector-coblocks-font-family-${instanceId}`; 44 const systemFonts = [ 45 { value: 'Arial', label: 'Arial' }, 46 { value: '', label: 'Helvetica' }, 47 { value: 'Times New Roman', label: 'Times New Roman' }, 48 { value: 'Georgia', label: 'Georgia' } 49 ]; 50 const fonts = []; 51 52 function sortThings (a, b) { 53 return a > b ? 1 : b > a ? -1 : 0; 54 } 55 56 // Add Google Fonts 57 Object.keys(googleFonts).sort(sortThings).map((k) => { 58 fonts.push( 59 { value: k, label: k } 60 ); 61 }); 62 63 const customFonts = []; 64 65 if (document.fonts && document.fonts.forEach) { 66 document.fonts.forEach((font) => { 67 if (googleFonts[font.family]) { 68 return; 69 } 70 71 if (font.family === 'dashicons') { 72 return; 73 } 74 75 if (customFonts.find(({ value }) => value === font.family)) { 76 return; 77 } 78 79 customFonts.push({ value: font.family, label: font.family }); 80 }); 81 } 82 83 const onChangeValue = ({ target: { value } }) => { 84 const googleFontsAttr = ':100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic'; 85 const isSystemFont = systemFonts.filter(function (font) { 86 return font.label === value; 87 }).length > 0; 88 89 let url = ''; 90 91 if (!isSystemFont) { 92 url = 'https://fonts.googleapis.com/css?family=' + value.replace(/ /g, '+') + googleFontsAttr; 93 } 94 95 onChange(value, url); 96 }; 97 98 return ( 99 e( 100 BaseControl, 101 { 102 label, 103 id, 104 help, 105 className 106 }, 107 e( 108 'select', 109 { 110 className: 'components-select-control__input components-select-control__input--coblocks-fontfamily', 111 onChange: onChangeValue, 112 'aria-describedby': help ? `${id}__help` : undefined, 113 ...props 114 }, 115 customFonts.length > 0 && e('optgroup', { label: 'Custom Loaded Fonts' }, 116 customFonts.map((option, index) => 117 e('option', { 118 key: option.value, 119 value: option.value, 120 selected: value === option.value 121 }, option.label) 122 ) 123 ), 124 e('optgroup', { label: 'System Fonts' }, 125 systemFonts.map((option, index) => 126 e('option', { 127 key: option.value, 128 value: option.value, 129 selected: value === option.value 130 }, option.label) 131 ) 132 ), 133 e('optgroup', { label: 'Google Fonts' }, 134 fonts.map((option, index) => 135 e('option', { 136 key: option.value, 137 value: option.value, 138 selected: value === option.value 139 }, option.label) 140 ) 141 ) 142 ) 143 ) 144 ); 145 }); 146 })(window.wp); 1 147 (({ 2 148 i18n, … … 11 157 url, 12 158 codeEditor 13 }, FontPicker) => {159 }, { FontPicker }) => { 14 160 const { __ } = i18n; 15 161 const { registerBlockType, createBlock } = blocks; … … 862 1008 })( 863 1009 window.wp, 864 (({ 865 i18n: { __ }, 866 element: { createElement: e }, 867 components: { BaseControl }, 868 compose: { withInstanceId } 869 }) => { 870 const googleFonts = { 871 'Abril Fatface': { weight: ['400'] }, 872 Anton: { weight: ['400'] }, 873 Arvo: { weight: ['400', '700'] }, 874 Asap: { weight: ['400', '500', '600', '700'] }, 875 'Barlow Condensed': { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] }, 876 Barlow: { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] }, 877 'Cormorant Garamond': { weight: ['300', '400', '500', '600', '700'] }, 878 Faustina: { weight: ['400', '500', '600', '700'] }, 879 'Fira Sans': { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] }, 880 'IBM Plex Sans': { weight: ['100', '200', '300', '400', '500', '600', '700'] }, 881 Inconsolata: { weight: ['400', '700'] }, 882 Heebo: { weight: ['100', '300', '400', '500', '700', '800', '900'] }, 883 Karla: { weight: ['400', '700'] }, 884 Lato: { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] }, 885 Lora: { weight: ['400', '700'] }, 886 Merriweather: { weight: ['300', '400', '500', '600', '700', '800', '900'] }, 887 Montserrat: { weight: ['100', '200', '300', '400', '500', '600', '700', '800', '900'] }, 888 'Noto Sans': { weight: ['400', '700'] }, 889 'Noto Serif': { weight: ['400', '700'] }, 890 'Open Sans': { weight: ['300', '400', '500', '600', '700', '800'] }, 891 Oswald: { weight: ['200', '300', '400', '500', '600', '700'] }, 892 'Playfair Display': { weight: ['400', '700', '900'] }, 893 'PT Serif': { weight: ['400', '700'] }, 894 Roboto: { weight: ['100', '300', '400', '500', '700', '900'] }, 895 Rubik: { weight: ['300', '400', '500', '700', '900'] }, 896 Tajawal: { weight: ['200', '300', '400', '500', '700', '800', '900'] }, 897 Ubuntu: { weight: ['300', '400', '500', '700'] }, 898 Yrsa: { weight: ['300', '400', '500', '600', '700'] }, 899 'Source Serif Pro': { weight: ['200', '300', '400', '600', '700', '900'] }, 900 'Source Sans Pro': { weight: ['200', '300', '400', '600', '700', '900'] }, 901 Martel: { weight: ['200', '300', '400', '600', '700', '800', '900'] } 902 }; 903 904 return withInstanceId(({ label, value, help, instanceId, onChange, className, ...props }) => { 905 const id = `inspector-coblocks-font-family-${instanceId}`; 906 const systemFonts = [ 907 { value: '', label: __('Default') }, 908 { value: 'Arial', label: 'Arial' }, 909 { value: 'Helvetica', label: 'Helvetica' }, 910 { value: 'Times New Roman', label: 'Times New Roman' }, 911 { value: 'Georgia', label: 'Georgia' } 912 ]; 913 const fonts = []; 914 915 systemFonts.map((font) => { 916 fonts.push(font); 917 }); 918 919 function sortThings (a, b) { 920 return a > b ? 1 : b > a ? -1 : 0; 921 } 922 923 // Add Google Fonts 924 Object.keys(googleFonts).sort(sortThings).map((k) => { 925 fonts.push( 926 { value: k, label: k } 927 ); 928 }); 929 930 const onChangeValue = ({ target: { value } }) => { 931 const googleFontsAttr = ':100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic'; 932 const isSystemFont = systemFonts.filter(function (font) { 933 return font.label === value; 934 }).length > 0; 935 936 let url = ''; 937 938 if (!isSystemFont) { 939 url = 'https://fonts.googleapis.com/css?family=' + value.replace(/ /g, '+') + googleFontsAttr; 940 } 941 942 onChange(value, url); 943 }; 944 945 return ( 946 e( 947 BaseControl, 948 { 949 label, 950 id, 951 help, 952 className 953 }, 954 e( 955 'select', 956 { 957 className: 'components-select-control__input components-select-control__input--coblocks-fontfamily', 958 onChange: onChangeValue, 959 'aria-describedby': help ? `${id}__help` : undefined, 960 ...props 961 }, 962 e('optgroup', { label: 'System Fonts' }, 963 systemFonts.map((option, index) => 964 e('option', { 965 key: option.value, 966 value: option.value, 967 selected: value === option.value 968 }, option.label) 969 ) 970 ), 971 e('optgroup', { label: 'Google Fonts' }, 972 fonts.map((option, index) => 973 e('option', { 974 key: option.value, 975 value: option.value, 976 selected: value === option.value 977 }, option.label) 978 ) 979 ) 980 ) 981 ) 982 ); 983 }); 984 })(window.wp) 1010 window.slide 985 1011 ); 986 1012 (({ … … 988 1014 element: { createElement: e, Fragment: f }, 989 1015 blockEditor: { InspectorControls }, 990 components: { PanelBody, TextControl },1016 components: { PanelBody, TextControl, SelectControl }, 991 1017 i18n: { __ } 992 } ) => {1018 }, { FontPicker }) => { 993 1019 const allowedBlocks = new Set(['core/paragraph']); 994 1020 … … 1006 1032 ...settings.attributes, 1007 1033 fontFamily: { 1034 type: 'string' 1035 }, 1036 fontWeight: { 1008 1037 type: 'string' 1009 1038 } … … 1029 1058 PanelBody, 1030 1059 { 1031 title: __('Font Family', 'slide'),1032 icon: 'format- video',1060 title: __('Font', 'slide'), 1061 icon: 'format-text', 1033 1062 initialOpen: false 1034 1063 }, 1035 e( TextControl, {1036 label: __('Font Family' ),1064 e(FontPicker, { 1065 label: __('Font Family', 'slide'), 1037 1066 value: attributes.fontFamily, 1038 1067 onChange: (fontFamily) => setAttributes({ fontFamily }) 1068 }), 1069 e(SelectControl, { 1070 label: __('Font Weight', 'slide'), 1071 help: __('Depending on the Font, some options may not be available.'), 1072 options: [ 1073 { value: '100', label: __('Thin', 'slide') }, 1074 { value: '200', label: __('Extra Light', 'slide') }, 1075 { value: '300', label: __('Light', 'slide') }, 1076 { value: '400', label: __('Normal', 'slide') }, 1077 { value: '500', label: __('Medium', 'slide') }, 1078 { value: '600', label: __('Semi Bold', 'slide') }, 1079 { value: '700', label: __('Bold', 'slide') }, 1080 { value: '800', label: __('Extra Bold', 'slide') }, 1081 { value: '900', label: __('Black', 'slide') } 1082 ], 1083 value: attributes.fontWeight || '400', 1084 onChange: (fontWeight) => setAttributes({ fontWeight }) 1039 1085 }) 1040 1086 ) … … 1053 1099 const { wrapperProps = {}, attributes } = props; 1054 1100 const { style = {} } = wrapperProps; 1055 const { fontFamily } = attributes;1101 const { fontFamily, fontWeight } = attributes; 1056 1102 1057 1103 if (fontFamily) { … … 1062 1108 style: { 1063 1109 ...style, 1064 fontFamily 1110 fontFamily, 1111 fontWeight 1065 1112 } 1066 1113 } … … 1082 1129 } 1083 1130 1084 const { fontFamily } = attributes;1131 const { fontFamily, fontWeight } = attributes; 1085 1132 const { style = {} } = extraProps; 1086 1133 … … 1089 1136 style: { 1090 1137 ...style, 1091 fontFamily 1138 fontFamily, 1139 fontWeight 1092 1140 } 1093 1141 }; 1094 1142 } 1095 1143 ); 1096 })(window.wp );1144 })(window.wp, window.slide); -
slide/trunk/index.php
r2180454 r2180951 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.2 27 * Version: 0.0.23 8 8 * Author: Ella van Durpe 9 9 * Author URI: https://ellavandurpe.com -
slide/trunk/readme.md
r2180454 r2180951 6 6 Requires PHP: 5.6 7 7 Tested up to: 5.3 8 Stable tag: 0.0.2 28 Stable tag: 0.0.23 9 9 License: GPL-2.0-or-later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
slide/trunk/speaker.css
r2178439 r2180951 153 153 top: auto; 154 154 left: auto; 155 background: #fff;156 155 } 157 156 … … 162 161 position: absolute; 163 162 top: 0; 163 background: #fff; 164 164 } 165 165 -
slide/trunk/speaker.js
r2178439 r2180951 137 137 138 138 upcomingSlide = document.createElement('iframe'); 139 upcomingSlide.setAttribute('width', 640);140 upcomingSlide.setAttribute('height', 512);139 upcomingSlide.setAttribute('width', 1280); 140 upcomingSlide.setAttribute('height', 1024); 141 141 upcomingSlide.setAttribute('src', upcomingURL); 142 142 document.querySelector('#upcoming-slide').appendChild(upcomingSlide); -
slide/trunk/template.php
r2180409 r2180951 94 94 display: flex; 95 95 flex-direction: column; 96 } 97 98 .receiver .reveal .slides *, 99 .receiver .reveal .backgrounds * { 100 pointer-events: none; 96 101 } 97 102
Note: See TracChangeset
for help on using the changeset viewer.