Changeset 2175652
- Timestamp:
- 10/18/2019 02:21:13 PM (6 years ago)
- Location:
- slide/trunk
- Files:
-
- 1 added
- 7 edited
-
common.css (modified) (2 diffs)
-
default-content.html (added)
-
index.css (modified) (3 diffs)
-
index.js (modified) (12 diffs)
-
index.php (modified) (3 diffs)
-
readme.md (modified) (1 diff)
-
register.php (modified) (1 diff)
-
template.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
slide/trunk/common.css
r2171722 r2175652 1 section.wp-block-slide-slide {2 padding: 0.2em !important;1 .wp-block-slide-slide { 2 box-sizing: border-box; 3 3 line-height: 1.3; 4 4 } 5 5 6 section.wp-block-slide-slide h1, 7 section.wp-block-slide-slide h2, 8 section.wp-block-slide-slide h3, 9 section.wp-block-slide-slide h4, 10 section.wp-block-slide-slide h5, 11 section.wp-block-slide-slide h6 { 6 .wp-block-slide-slide * { 7 box-sizing: inherit; 8 } 9 10 .wp-block-slide-slide h1, 11 .wp-block-slide-slide h2, 12 .wp-block-slide-slide h3, 13 .wp-block-slide-slide h4, 14 .wp-block-slide-slide h5, 15 .wp-block-slide-slide h6 { 12 16 line-height: 1.2; 13 17 word-wrap: break-word; … … 15 19 } 16 20 17 section.wp-block-slide-slide h1 {21 .wp-block-slide-slide h1 { 18 22 font-size: 2.5em; 19 23 } 20 24 21 section.wp-block-slide-slide h2 {25 .wp-block-slide-slide h2 { 22 26 font-size: 1.6em; 23 27 } 24 28 25 section.wp-block-slide-slide h3 {29 .wp-block-slide-slide h3 { 26 30 font-size: 1.3em; 27 31 } 28 32 29 section.wp-block-slide-slide h4 {33 .wp-block-slide-slide h4 { 30 34 font-size: 1em; 31 35 } 32 36 33 section.wp-block-slide-slide p {37 .wp-block-slide-slide p { 34 38 margin: 20px 0; 35 39 } -
slide/trunk/index.css
r2174452 r2175652 50 50 } 51 51 52 body { 53 counter-reset: slidecounter; 54 } 55 56 div[data-type="slide/slide"]:before { 57 content: counter( slidecounter ); 58 counter-increment: slidecounter; 59 font-size: 24px; 60 } 61 62 div.is-selected[data-type="slide/slide"]:before { 63 content: ''; 64 } 65 52 66 .block-editor-default-block-appender textarea.block-editor-default-block-appender__content { 53 67 font-size: inherit; … … 59 73 } 60 74 61 section.wp-block-slide-slide { 75 .wp-block-slide-slide__body { 76 position: relative; 77 padding: 50px; 78 overflow: hidden; 62 79 outline: 1px dashed currentColor; 63 width: 1060px !important; 64 height: 700px !important; 65 padding: calc( 50px + 0.2em ) !important; 80 } 81 82 .wp-block-slide-slide { 83 position: relative; 84 width: 960px !important; 85 height: 720px !important; 86 padding: 0.2em; 66 87 display: flex; 67 88 flex-direction: column; 68 89 justify-content: center; 90 outline: 1px dashed currentColor; 69 91 } 70 92 … … 77 99 } 78 100 101 .wp-block-slide-slide__background iframe { 102 width: 100%; 103 height: 100%; 104 max-height: 100%; 105 max-width: 100%; 106 pointer-events: none; 107 } 108 109 .is-selected .wp-block-slide-slide__background iframe { 110 pointer-events: all; 111 } 112 79 113 .wp-block-slide-slide .fragment { 80 114 opacity: 0.5; 81 115 } 116 117 div[data-type="slide/slide"] div[data-block] > .components-notice { 118 margin: 0; 119 } 120 121 /* Hide appender displayed if a block or previous block is selected. */ 122 .block-editor-inner-blocks .block-editor-block-list__block.is-selected + .block-list-appender, 123 .is-selected .block-editor-inner-blocks .block-editor-block-list__block + .block-list-appender { 124 display: none; 125 } 126 127 /* Show appender if it's at the end of a list */ 128 .block-editor-inner-blocks .block-editor-block-list__block.is-selected + .block-list-appender:last-child { 129 display: block; 130 height: 0; 131 margin-top: 0; 132 margin-bottom: 0; 133 } -
slide/trunk/index.js
r2175315 r2175652 19 19 const { PluginDocumentSettingPanel } = editPost; 20 20 const { useSelect, useDispatch, subscribe, select, dispatch } = data; 21 const { TextareaControl, ColorPicker, PanelBody, RangeControl, SelectControl, ToggleControl, Button, FocalPointPicker, ExternalLink } = components;21 const { TextareaControl, ColorPicker, PanelBody, RangeControl, SelectControl, ToggleControl, Button, FocalPointPicker, ExternalLink, Notice, TextControl, RadioControl } = components; 22 22 const { MediaUpload, __experimentalGradientPickerControl, InnerBlocks, InspectorControls, RichTextToolbarButton } = blockEditor; 23 23 const { addQueryArgs } = url; … … 39 39 const controlsKey = 'presentation-controls'; 40 40 const progressKey = 'presentation-progress'; 41 const cssPrefix = '.block-editor-block-list__layout .block-editor-block-list__block[data-type="slide/slide"]'; 41 const widthKey = 'presentation-width'; 42 const horizontalPaddingKey = 'presentation-horizontal-padding'; 43 const verticalPaddingKey = 'presentation-vertical-padding'; 42 44 43 45 const CodeEditor = memo(({ onChange, ...props }) => { … … 80 82 81 83 const slide = createBlock('slide/slide', {}, [ 82 createBlock(block.name, block.attributes) 84 block.name === 'core/paragraph' 85 ? createBlock('core/heading') 86 : createBlock(block.name, block.attributes) 83 87 ]); 84 88 … … 98 102 meta: { ...meta, [key]: value } 99 103 }); 100 const rules = { 101 color: meta[colorKey] || '#000',104 105 const bodyRules = { 102 106 'background-color': meta[bgColorKey] || '#fff', 103 107 'background-image': meta[backgroundGradientKey] || 'none', 108 color: meta[colorKey] || '#000', 104 109 'font-size': (meta[fontSizeKey] || '42') + 'px', 105 110 'font-family': meta[fontFamilyKey] || 'Helvetica, sans-serif' 111 }; 112 113 const rules = { 114 width: meta[widthKey] ? meta[widthKey] + 'px !important' : undefined, 115 'padding-top': meta[verticalPaddingKey] ? meta[verticalPaddingKey] : '0.2em', 116 'padding-bottom': meta[verticalPaddingKey] ? meta[verticalPaddingKey] : '0.2em', 117 'padding-left': meta[horizontalPaddingKey] ? meta[horizontalPaddingKey] : '0.2em', 118 'padding-right': meta[horizontalPaddingKey] ? meta[horizontalPaddingKey] : '0.2em' 106 119 }; 107 120 … … 113 126 }; 114 127 115 console.log(meta[fontFamilyUrlKey]);116 117 128 return [ 129 ...Object.keys(bodyRules).map((key) => { 130 return e( 131 'style', 132 null, 133 `.wp-block-slide-slide__body {${key}:${bodyRules[key]}}` 134 ); 135 }), 118 136 ...Object.keys(rules).map((key) => { 119 137 return e( 120 138 'style', 121 139 null, 122 ` ${cssPrefix} section{${key}:${rules[key]}}`140 `.wp-block-slide-slide {${key}:${rules[key]}}` 123 141 ); 124 142 }), … … 127 145 'style', 128 146 null, 129 ` ${cssPrefix} section.wp-block-slide-slide__background {${key}:${backgroundRules[key]}}`147 `.wp-block-slide-slide__background {${key}:${backgroundRules[key]}}` 130 148 ); 131 149 }), … … 140 158 null, 141 159 (meta[fontFamilyHeadingUrlKey] ? `@import url("${meta[fontFamilyHeadingUrlKey]}");` : '') + 142 `${cssPrefix} section h1, ${cssPrefix} section h2, ${cssPrefix} section h3, ${cssPrefix} section h4, ${cssPrefix} section h5, ${cssPrefix} section h6 { font-family: ${meta[fontFamilyHeadingKey]} }` 160 `.wp-block-slide-slide h1, .wp-block-slide-slide h2, .wp-block-slide-slide h3, .wp-block-slide-slide h4, .wp-block-slide-slide h5, .wp-block-slide-slide h6 { font-family: ${meta[fontFamilyHeadingKey]} }` 161 ), 162 !!meta[widthKey] && e( 163 'style', 164 null, 165 `.editor-styles-wrapper .editor-writing-flow { width: ${parseInt(meta[widthKey], 10) + 130}px !important; }` 166 ), 167 e( 168 PluginDocumentSettingPanel, 169 { 170 name: 'slide-dimensions', 171 title: __('Setup', 'slide'), 172 icon: 'editor-expand' 173 }, 174 e(RadioControl, { 175 selected: meta[widthKey] === '1280' ? '16:9' : '', 176 options: [ 177 { label: __('Standard 4:3'), value: '' }, 178 { label: __('Widescreen 16:9'), value: '16:9' } 179 ], 180 onChange: (value) => { 181 editPost({ 182 meta: { 183 [widthKey]: value === '16:9' ? '1280' : '' 184 } 185 }); 186 } 187 }), 188 e(TextControl, { 189 label: __('Horizontal Padding'), 190 placeholder: '0.2em', 191 value: meta[horizontalPaddingKey], 192 onChange: (value) => updateMeta(value, horizontalPaddingKey) 193 }), 194 e(TextControl, { 195 label: __('Vertical Padding'), 196 placeholder: '0.2em', 197 value: meta[verticalPaddingKey], 198 onChange: (value) => updateMeta(value, verticalPaddingKey) 199 }) 143 200 ), 144 201 e( … … 449 506 backgroundOpacity: { 450 507 type: 'string' 508 }, 509 hidden: { 510 type: 'boolean' 511 }, 512 backgroundIframeUrl: { 513 type: 'string' 451 514 } 452 515 }, … … 465 528 PanelBody, 466 529 { 467 title: __('S lideNotes', 'slide'),530 title: __('Speaker Notes', 'slide'), 468 531 icon: 'edit', 469 532 initialOpen: false … … 472 535 label: __('Anything you want to remember.', 'slide'), 473 536 value: attributes.notes, 474 onChange: (notes) => setAttributes({ notes }) 537 onChange: (notes) => setAttributes({ notes }), 538 rows: 10 475 539 }) 476 540 ), … … 598 662 }) 599 663 }) 664 ), 665 e( 666 PanelBody, 667 { 668 title: __('Background Iframe', 'slide'), 669 icon: 'format-image', 670 initialOpen: false 671 }, 672 e(TextControl, { 673 label: __('Iframe URL'), 674 value: attributes.backgroundIframeUrl, 675 onChange: (backgroundIframeUrl) => setAttributes({ backgroundIframeUrl }) 676 }), 677 e('br'), e('br'), 678 !!attributes.backgroundIframeUrl && e(RangeControl, { 679 label: __('Opacity', 'slide'), 680 value: attributes.backgroundOpacity ? parseInt(attributes.backgroundOpacity, 10) : undefined, 681 min: 0, 682 max: 100, 683 initialPosition: 100, 684 onChange: (value) => setAttributes({ 685 backgroundOpacity: value + '' 686 }) 687 }) 688 ), 689 e( 690 PanelBody, 691 { 692 title: __('Visibility', 'slide'), 693 icon: 'visibility', 694 initialOpen: false 695 }, 696 e(ToggleControl, { 697 label: __('Hide Slide', 'slide'), 698 checked: attributes.hidden, 699 onChange: (hidden) => setAttributes({ hidden }) 700 }) 600 701 ) 601 702 ), 602 e( 603 'section', 604 { 605 className, 703 attributes.hidden && e( 704 Notice, 705 { status: 'warning', isDismissible: false }, 706 'This slide is hidden' 707 ), 708 e( 709 'div', 710 { 711 className: 'wp-block-slide-slide__body', 606 712 style: { 607 713 color: attributes.color || undefined, … … 620 726 opacity: attributes.backgroundOpacity ? attributes.backgroundOpacity / 100 : undefined 621 727 } 622 } 728 }, 729 !!attributes.backgroundIframeUrl && e('iframe', { 730 src: attributes.backgroundIframeUrl 731 }) 623 732 ), 624 e(InnerBlocks) 733 e( 734 'section', 735 { className }, 736 e(InnerBlocks) 737 ) 625 738 ) 626 739 ); 627 740 }, 628 741 save: ({ attributes }) => e( 629 'section',742 attributes.hidden ? 'div' : 'section', 630 743 { 631 744 style: { 632 color: attributes.color || undefined 745 color: attributes.color || undefined, 746 display: attributes.hidden ? 'none' : undefined 633 747 }, 634 748 'data-background-color': attributes.backgroundColor || undefined, 635 749 'data-background-image': attributes.backgroundUrl ? attributes.backgroundUrl : undefined, 636 750 'data-background-position': attributes.focalPoint ? `${attributes.focalPoint.x * 100}% ${attributes.focalPoint.y * 100}%` : undefined, 637 'data-background-opacity': attributes.backgroundOpacity ? attributes.backgroundOpacity / 100 : undefined 751 'data-background-opacity': attributes.backgroundOpacity ? attributes.backgroundOpacity / 100 : undefined, 752 'data-background-iframe': attributes.backgroundIframeUrl ? attributes.backgroundIframeUrl : undefined 638 753 }, 639 754 e(InnerBlocks.Content) -
slide/trunk/index.php
r2175315 r2175652 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. 97 * Version: 0.0.10 8 8 * Author: Ella van Durpe 9 9 * Author URI: https://ellavandurpe.com … … 173 173 }, 99999 ); 174 174 175 add_action( 'load-post.php', function() { 176 if ( get_current_screen()->post_type !== 'presentation' ) { 177 return; 178 } 179 180 remove_editor_styles(); 181 }, 99999 ); 182 183 add_action( 'load-post-new.php', function() { 184 if ( get_current_screen()->post_type !== 'presentation' ) { 185 return; 186 } 187 188 remove_editor_styles(); 189 }, 99999 ); 175 foreach ( array( 176 'load-post.php', 177 'load-post-new.php', 178 ) as $tag ) { 179 add_action( $tag, function() { 180 if ( get_current_screen()->post_type !== 'presentation' ) { 181 return; 182 } 183 184 remove_editor_styles(); 185 remove_theme_support( 'editor-color-palette' ); 186 remove_theme_support( 'editor-font-sizes' ); 187 }, 99999 ); 188 } 190 189 191 190 add_action( 'admin_bar_menu', function ( $wp_admin_bar ) { … … 206 205 } 207 206 208 return "<!-- wp:slide/slide -->\n<section class=\"wp-block-slide-slide\"></section>\n<!-- /wp:slide/slide -->";207 return file_get_contents( __DIR__ . '/default-content.html' ); 209 208 }, 10, 2 ); -
slide/trunk/readme.md
r2175315 r2175652 6 6 Requires PHP: 5.6 7 7 Tested up to: 5.3 8 Stable tag: 0.0. 98 Stable tag: 0.0.10 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
r2175315 r2175652 68 68 'controls', 69 69 'progress', 70 'width', 71 'horizontal-padding', 72 'vertical-padding', 70 73 ) as $key ) { 71 74 register_post_meta( 'presentation', "presentation-$key", array( -
slide/trunk/template.php
r2175315 r2175652 72 72 } 73 73 74 section.wp-block-slide-slide { 75 padding-top: <?php echo get_post_meta( get_the_ID(), 'presentation-vertical-padding', true ) ?: '0.2em'; ?> !important; 76 padding-bottom: <?php echo get_post_meta( get_the_ID(), 'presentation-vertical-padding', true ) ?: '0.2em'; ?> !important; 77 padding-left: <?php echo get_post_meta( get_the_ID(), 'presentation-horizontal-padding', true ) ?: '0.2em'; ?> !important; 78 padding-right: <?php echo get_post_meta( get_the_ID(), 'presentation-horizontal-padding', true ) ?: '0.2em'; ?> !important; 79 } 80 74 81 .reveal .slides { 75 82 text-align: inherit; … … 114 121 preloadIframes: true, 115 122 hideAddressBar: true, 123 height: 720, 124 width: <?php echo get_post_meta( get_the_ID(), 'presentation-width', true ) ?: '960'; ?>, 125 margin: 0.08, 116 126 } ); 117 127 window.addEventListener( 'DOMContentLoaded', function() {
Note: See TracChangeset
for help on using the changeset viewer.