Plugin Directory

Changeset 2180951


Ignore:
Timestamp:
10/27/2019 12:32:10 PM (6 years ago)
Author:
iseulde
Message:

v0.0.23

Location:
slide/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • slide/trunk/index.js

    r2180454 r2180951  
     1window.slide = {};
     2window.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);
    1147(({
    2148  i18n,
     
    11157  url,
    12158  codeEditor
    13 }, FontPicker) => {
     159}, { FontPicker }) => {
    14160  const { __ } = i18n;
    15161  const { registerBlockType, createBlock } = blocks;
     
    8621008})(
    8631009  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
    9851011);
    9861012(({
     
    9881014  element: { createElement: e, Fragment: f },
    9891015  blockEditor: { InspectorControls },
    990   components: { PanelBody, TextControl },
     1016  components: { PanelBody, TextControl, SelectControl },
    9911017  i18n: { __ }
    992 }) => {
     1018}, { FontPicker }) => {
    9931019  const allowedBlocks = new Set(['core/paragraph']);
    9941020
     
    10061032          ...settings.attributes,
    10071033          fontFamily: {
     1034            type: 'string'
     1035          },
     1036          fontWeight: {
    10081037            type: 'string'
    10091038          }
     
    10291058              PanelBody,
    10301059              {
    1031                 title: __('Font Family', 'slide'),
    1032                 icon: 'format-video',
     1060                title: __('Font', 'slide'),
     1061                icon: 'format-text',
    10331062                initialOpen: false
    10341063              },
    1035               e(TextControl, {
    1036                 label: __('Font Family'),
     1064              e(FontPicker, {
     1065                label: __('Font Family', 'slide'),
    10371066                value: attributes.fontFamily,
    10381067                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 })
    10391085              })
    10401086            )
     
    10531099          const { wrapperProps = {}, attributes } = props;
    10541100          const { style = {} } = wrapperProps;
    1055           const { fontFamily } = attributes;
     1101          const { fontFamily, fontWeight } = attributes;
    10561102
    10571103          if (fontFamily) {
     
    10621108                style: {
    10631109                  ...style,
    1064                   fontFamily
     1110                  fontFamily,
     1111                  fontWeight
    10651112                }
    10661113              }
     
    10821129      }
    10831130
    1084       const { fontFamily } = attributes;
     1131      const { fontFamily, fontWeight } = attributes;
    10851132      const { style = {} } = extraProps;
    10861133
     
    10891136        style: {
    10901137          ...style,
    1091           fontFamily
     1138          fontFamily,
     1139          fontWeight
    10921140        }
    10931141      };
    10941142    }
    10951143  );
    1096 })(window.wp);
     1144})(window.wp, window.slide);
  • slide/trunk/index.php

    r2180454 r2180951  
    55 * Plugin URI:  https://wordpress.org/plugins/slide/
    66 * Description: Allows you to create presentations with the block editor.
    7  * Version:     0.0.22
     7 * Version:     0.0.23
    88 * Author:      Ella van Durpe
    99 * Author URI:  https://ellavandurpe.com
  • slide/trunk/readme.md

    r2180454 r2180951  
    66    Requires PHP:      5.6
    77    Tested up to:      5.3
    8     Stable tag:        0.0.22
     8    Stable tag:        0.0.23
    99    License:           GPL-2.0-or-later
    1010    License URI:       http://www.gnu.org/licenses/gpl-2.0.html
  • slide/trunk/speaker.css

    r2178439 r2180951  
    153153    top: auto;
    154154    left: auto;
    155     background: #fff;
    156155}
    157156
     
    162161    position: absolute;
    163162    top: 0;
     163    background: #fff;
    164164}
    165165
  • slide/trunk/speaker.js

    r2178439 r2180951  
    137137
    138138    upcomingSlide = document.createElement('iframe');
    139     upcomingSlide.setAttribute('width', 640);
    140     upcomingSlide.setAttribute('height', 512);
     139    upcomingSlide.setAttribute('width', 1280);
     140    upcomingSlide.setAttribute('height', 1024);
    141141    upcomingSlide.setAttribute('src', upcomingURL);
    142142    document.querySelector('#upcoming-slide').appendChild(upcomingSlide);
  • slide/trunk/template.php

    r2180409 r2180951  
    9494            display: flex;
    9595            flex-direction: column;
     96        }
     97
     98        .receiver .reveal .slides *,
     99        .receiver .reveal .backgrounds * {
     100            pointer-events: none;
    96101        }
    97102
Note: See TracChangeset for help on using the changeset viewer.