Changeset 2113913
- Timestamp:
- 06/28/2019 01:52:58 AM (7 years ago)
- Location:
- magic-block/trunk
- Files:
-
- 3 edited
-
js/magicblock-jsx.js (modified) (5 diffs)
-
js/magicblock.build.js (modified) (6 diffs)
-
magicblock.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
magic-block/trunk/js/magicblock-jsx.js
r2048444 r2113913 29 29 attribute: 'style', 30 30 }, 31 href: { 32 type: 'string', 33 source: 'attribute', 34 selector: '.wp-block-magicblock-magicblock', 35 attribute: 'href', 36 }, 31 37 elemId: { 32 38 type: 'string', … … 47 53 elemTag = props.attributes.elemTag, 48 54 elemId = props.attributes.elemId, 49 elemClass = props.attributes.elemClass; 55 elemClass = props.attributes.elemClass, 56 href = props.attributes.href; 50 57 51 58 function convertClassString(input) { … … 69 76 } 70 77 78 function onChangeHref ( newHref ) { 79 props.setAttributes( { href: newHref } ); 80 } 81 82 83 84 const linkPanels = ( 85 <PanelBody title="Link Href"> 86 <PlainText onChange={onChangeHref} value={href} className="magicblock-plaintext"/> 87 </PanelBody> 88 ); 89 71 90 return ( 72 91 <Fragment> … … 84 103 { label: "dl", value: 'dl'}, 85 104 { label: "dd", value: 'dd'}, 86 { label: "dt", value: 'dt'} 105 { label: "dt", value: 'dt'}, 106 { label: "a", value: "a"} 87 107 ]} 88 108 /> 89 109 </PanelBody> 110 { elemTag === "a" ? linkPanels : null } 90 111 <PanelBody title="ID"> 91 112 <PlainText onChange={onChangeID} value={elemId} className="magicblock-plaintext"/> … … 113 134 elemId = props.attributes.elemId, 114 135 elemClass = props.attributes.elemClass, 115 ElemTag = props.attributes.elemTag || "div"; 136 ElemTag = props.attributes.elemTag || "div", 137 href = props.attributes.href || ""; 138 139 const aProps = {}; 140 if(ElemTag === "a" && href){ 141 aProps.href = href; 142 } 116 143 117 144 return (<ElemTag 118 145 className={elemClass} 119 146 style={inlineSytle} 120 id={elemId}> 147 id={elemId} 148 {...aProps} 149 > 121 150 <InnerBlocks.Content/> 122 151 </ElemTag>); -
magic-block/trunk/js/magicblock.build.js
r2048444 r2113913 68 68 /***/ (function(module, exports) { 69 69 70 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; }; 71 70 72 console.log('magicblock is up and running'); 71 73 … … 106 108 attribute: 'style' 107 109 }, 110 href: { 111 type: 'string', 112 source: 'attribute', 113 selector: '.wp-block-magicblock-magicblock', 114 attribute: 'href' 115 }, 108 116 elemId: { 109 117 type: 'string', … … 124 132 elemTag = props.attributes.elemTag, 125 133 elemId = props.attributes.elemId, 126 elemClass = props.attributes.elemClass; 134 elemClass = props.attributes.elemClass, 135 href = props.attributes.href; 127 136 128 137 function convertClassString(input) { … … 145 154 props.setAttributes({ elemClass: newClass }); 146 155 } 156 157 function onChangeHref(newHref) { 158 props.setAttributes({ href: newHref }); 159 } 160 161 var linkPanels = wp.element.createElement( 162 PanelBody, 163 { title: "Link Href" }, 164 wp.element.createElement(PlainText, { onChange: onChangeHref, value: href, className: "magicblock-plaintext" }) 165 ); 147 166 148 167 return wp.element.createElement( … … 155 174 PanelBody, 156 175 { title: "Element Type" }, 157 wp.element.createElement(SelectControl, { label: "Tag", value: elemTag, onChange: onChangeElem, options: [{ label: "div", value: "div" }, { label: "section", value: 'section' }, { label: "main", value: 'main' }, { label: "aside", value: 'aside' }, { label: "article", value: 'article' }, { label: "header", value: 'header' }, { label: "footer", value: 'footer' }, { label: "nav", value: 'nav' }, { label: "dl", value: 'dl' }, { label: "dd", value: 'dd' }, { label: "dt", value: 'dt' } ]176 wp.element.createElement(SelectControl, { label: "Tag", value: elemTag, onChange: onChangeElem, options: [{ label: "div", value: "div" }, { label: "section", value: 'section' }, { label: "main", value: 'main' }, { label: "aside", value: 'aside' }, { label: "article", value: 'article' }, { label: "header", value: 'header' }, { label: "footer", value: 'footer' }, { label: "nav", value: 'nav' }, { label: "dl", value: 'dl' }, { label: "dd", value: 'dd' }, { label: "dt", value: 'dt' }, { label: "a", value: "a" }] 158 177 }) 159 178 ), 179 elemTag === "a" ? linkPanels : null, 160 180 wp.element.createElement( 161 181 PanelBody, … … 206 226 elemId = props.attributes.elemId, 207 227 elemClass = props.attributes.elemClass, 208 ElemTag = props.attributes.elemTag || "div"; 228 ElemTag = props.attributes.elemTag || "div", 229 href = props.attributes.href || ""; 230 231 var aProps = {}; 232 if (ElemTag === "a" && href) { 233 aProps.href = href; 234 } 209 235 210 236 return wp.element.createElement( 211 237 ElemTag, 212 {238 _extends({ 213 239 className: elemClass, 214 240 style: inlineSytle, 215 id: elemId }, 241 id: elemId 242 }, aProps), 216 243 wp.element.createElement(InnerBlocks.Content, null) 217 244 ); -
magic-block/trunk/magicblock.php
r2112491 r2113913 3 3 Plugin Name: Magic Block 4 4 Description: Registers a container block with the WP5+ (Gutenberg) editor. This block has settings for element type (div, section, etc), id, classname, and style (inline css). 5 Version: 1. 0.25 Version: 1.1 6 6 Author: Will Delphia 7 7 License: GPL2
Note: See TracChangeset
for help on using the changeset viewer.