Changeset 2114800
- Timestamp:
- 06/29/2019 07:24:04 PM (7 years ago)
- Location:
- magic-block/trunk
- Files:
-
- 4 edited
-
css/magicblock.css (modified) (1 diff)
-
js/magicblock-jsx.js (modified) (5 diffs)
-
js/magicblock.build.js (modified) (5 diffs)
-
magicblock.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
magic-block/trunk/css/magicblock.css
r2112486 r2114800 48 48 background: rgba(230, 186, 173, 0.214); 49 49 } 50 51 .magicblock-newtab { 52 margin-top: 1em; 53 } 54 55 .edit-post-settings-sidebar__panel-block .components-panel__body .magicblock-newtab .components-base-control { 56 margin-bottom: .3em; 57 } 58 -
magic-block/trunk/js/magicblock-jsx.js
r2114557 r2114800 4 4 const { InspectorControls, InnerBlocks, PlainText} = wp.editor; 5 5 const { Fragment } = wp.element; 6 const { PanelBody, SelectControl } = wp.components; 6 const { PanelBody, SelectControl, CheckboxControl } = wp.components; 7 7 8 8 9 const icon = () => { … … 35 36 attribute: 'href', 36 37 }, 38 newTab: { 39 type: 'boolean' 40 }, 37 41 elemId: { 38 42 type: 'string', … … 54 58 elemId = props.attributes.elemId, 55 59 elemClass = props.attributes.elemClass, 56 href = props.attributes.href; 60 href = props.attributes.href, 61 newTab = props.attributes.newTab; 62 57 63 58 64 function convertClassString(input) { … … 80 86 } 81 87 88 function onChangeNewTab ( newNewTab ) { 89 props.setAttributes( { newTab: newNewTab } ); 90 } 82 91 83 92 84 93 const linkPanels = ( 85 <PanelBody title=" LinkHref">94 <PanelBody title="Href"> 86 95 <PlainText onChange={onChangeHref} value={href} className="magicblock-plaintext"/> 96 <div className="magicblock-flex magicblock-newtab"> 97 <CheckboxControl 98 label="Open in new tab" 99 checked={newTab} 100 onChange={onChangeNewTab} 101 /> 102 </div> 87 103 </PanelBody> 88 104 ); … … 139 155 elemClass = props.attributes.elemClass, 140 156 ElemTag = props.attributes.elemTag || "div", 141 href = props.attributes.href || ""; 157 href = props.attributes.href || "", 158 newTab = props.attributes.newTab; 142 159 143 160 const aProps = {}; 144 161 if(ElemTag === "a" && href){ 145 162 aProps.href = href; 163 if(newTab) { 164 aProps.target = "_blank"; 165 aProps.rel = "noopener noreferrer"; 166 } 146 167 } 147 168 -
magic-block/trunk/js/magicblock.build.js
r2114557 r2114800 80 80 var _wp$components = wp.components, 81 81 PanelBody = _wp$components.PanelBody, 82 SelectControl = _wp$components.SelectControl; 82 SelectControl = _wp$components.SelectControl, 83 CheckboxControl = _wp$components.CheckboxControl; 83 84 84 85 … … 114 115 attribute: 'href' 115 116 }, 117 newTab: { 118 type: 'boolean' 119 }, 116 120 elemId: { 117 121 type: 'string', … … 133 137 elemId = props.attributes.elemId, 134 138 elemClass = props.attributes.elemClass, 135 href = props.attributes.href; 139 href = props.attributes.href, 140 newTab = props.attributes.newTab; 136 141 137 142 function convertClassString(input) { … … 159 164 } 160 165 166 function onChangeNewTab(newNewTab) { 167 props.setAttributes({ newTab: newNewTab }); 168 } 169 161 170 var linkPanels = wp.element.createElement( 162 171 PanelBody, 163 { title: "Link Href" }, 164 wp.element.createElement(PlainText, { onChange: onChangeHref, value: href, className: "magicblock-plaintext" }) 172 { title: "Href" }, 173 wp.element.createElement(PlainText, { onChange: onChangeHref, value: href, className: "magicblock-plaintext" }), 174 wp.element.createElement( 175 "div", 176 { className: "magicblock-flex magicblock-newtab" }, 177 wp.element.createElement(CheckboxControl, { 178 label: "Open in new tab", 179 checked: newTab, 180 onChange: onChangeNewTab 181 }) 182 ) 165 183 ); 166 184 … … 243 261 elemClass = props.attributes.elemClass, 244 262 ElemTag = props.attributes.elemTag || "div", 245 href = props.attributes.href || ""; 263 href = props.attributes.href || "", 264 newTab = props.attributes.newTab; 246 265 247 266 var aProps = {}; 248 267 if (ElemTag === "a" && href) { 249 268 aProps.href = href; 269 if (newTab) { 270 aProps.target = "_blank"; 271 aProps.rel = "noopener noreferrer"; 272 } 250 273 } 251 274 -
magic-block/trunk/magicblock.php
r2114557 r2114800 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.1. 15 Version: 1.1.2 6 6 Author: Will Delphia 7 7 License: GPL2
Note: See TracChangeset
for help on using the changeset viewer.