0.40.1
5 years ago
block.js
5 years ago
component.js
5 years ago
component_0_39_5.js
5 years ago
component_0_40_0.js
5 years ago
heading-toolbar.js
5 years ago
schema.js
6 years ago
component.js
344 lines
| 1 | import { vkbBlockEditor } from "./../../_helper/depModules"; |
| 2 | const { RichText } = vkbBlockEditor; |
| 3 | const { __ } = wp.i18n; |
| 4 | const { Component } = wp.element; |
| 5 | |
| 6 | export class VKBHeading extends Component { |
| 7 | render() { |
| 8 | const { |
| 9 | level, |
| 10 | align, |
| 11 | title, |
| 12 | titleColor, |
| 13 | titleSize, |
| 14 | subText, |
| 15 | subTextFlag, |
| 16 | subTextColor, |
| 17 | subTextSize, |
| 18 | titleStyle, |
| 19 | titleMarginBottom, |
| 20 | outerMarginBottom |
| 21 | } = this.props.attributes; |
| 22 | const setAttributes = this.props.setAttributes; |
| 23 | const for_ = this.props.for_; |
| 24 | |
| 25 | const containerClass = `vk_heading vk_heading-style-${titleStyle}`; |
| 26 | const tagName = "h" + level; |
| 27 | let cStyle; |
| 28 | let tStyle; |
| 29 | |
| 30 | //containerのマージンを切り替え |
| 31 | if (outerMarginBottom != null) { |
| 32 | cStyle = { marginBottom: outerMarginBottom + `rem` }; |
| 33 | } |
| 34 | |
| 35 | //titleのマージンを切り替え |
| 36 | if (titleMarginBottom != null) { |
| 37 | tStyle = { |
| 38 | color: titleColor, |
| 39 | fontSize: titleSize + "rem", |
| 40 | marginBottom: titleMarginBottom + "rem", |
| 41 | textAlign: align |
| 42 | }; |
| 43 | } else { |
| 44 | tStyle = { |
| 45 | color: titleColor, |
| 46 | fontSize: titleSize + "rem", |
| 47 | textAlign: align |
| 48 | }; |
| 49 | } |
| 50 | |
| 51 | if (for_ === "edit") { |
| 52 | return ( |
| 53 | <div className={ containerClass } style={ cStyle }> |
| 54 | <RichText |
| 55 | tagName={ tagName } |
| 56 | value={ title } |
| 57 | onChange={ value => setAttributes({ title: value }) } |
| 58 | style={ tStyle } |
| 59 | className={ `vk_heading_title vk_heading_title-style-${titleStyle}` } |
| 60 | placeholder={ __("Input title…", "vk-blocks") } |
| 61 | /> |
| 62 | { // サブテキスト |
| 63 | (() => { |
| 64 | if (subTextFlag === "on") { |
| 65 | return ( |
| 66 | <RichText |
| 67 | tagName={ "p" } |
| 68 | value={ subText } |
| 69 | onChange={ value => setAttributes({ subText: value }) } |
| 70 | style={ { |
| 71 | color: subTextColor, |
| 72 | fontSize: subTextSize + "rem", |
| 73 | textAlign: align |
| 74 | } } |
| 75 | className={ `vk_heading_subtext vk_heading_subtext-style-${titleStyle}` } |
| 76 | placeholder={ __("Input sub text…", "vk-blocks") } |
| 77 | /> |
| 78 | ); |
| 79 | } |
| 80 | })() } |
| 81 | </div> |
| 82 | ); |
| 83 | } else if (for_ === "save") { |
| 84 | return ( |
| 85 | <div className={ containerClass } style={ cStyle }> |
| 86 | <RichText.Content |
| 87 | tagName={ tagName } |
| 88 | value={ title } |
| 89 | onChange={ value => setAttributes({ title: value }) } |
| 90 | style={ tStyle } |
| 91 | className={ `vk_heading_title vk_heading_title-style-${titleStyle}` } |
| 92 | placeholder={ __("Input title…", "vk-blocks") } |
| 93 | /> |
| 94 | { // サブテキスト |
| 95 | (() => { |
| 96 | if (subTextFlag === "on") { |
| 97 | return ( |
| 98 | <RichText.Content |
| 99 | tagName={ "p" } |
| 100 | value={ subText } |
| 101 | onChange={ value => setAttributes({ subText: value }) } |
| 102 | style={ { |
| 103 | color: subTextColor, |
| 104 | fontSize: subTextSize + "rem", |
| 105 | textAlign: align |
| 106 | } } |
| 107 | className={ `vk_heading_subtext vk_heading_subtext-style-${titleStyle}` } |
| 108 | placeholder={ __("Input sub text…", "vk-blocks") } |
| 109 | /> |
| 110 | ); |
| 111 | } |
| 112 | })() } |
| 113 | </div> |
| 114 | ); |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | export class VKBHeading2 extends Component { |
| 120 | render() { |
| 121 | const { |
| 122 | level, |
| 123 | align, |
| 124 | title, |
| 125 | titleColor, |
| 126 | titleSize, |
| 127 | subText, |
| 128 | subTextFlag, |
| 129 | subTextColor, |
| 130 | subTextSize, |
| 131 | titleStyle, |
| 132 | titleMarginBottom, |
| 133 | outerMarginBottom |
| 134 | } = this.props.attributes; |
| 135 | const setAttributes = this.props.setAttributes; |
| 136 | const for_ = this.props.for_; |
| 137 | |
| 138 | const containerClass = `vk_heading vk_heading-style-${titleStyle}`; |
| 139 | const tagName = "h" + level; |
| 140 | let cStyle; |
| 141 | let tStyle; |
| 142 | |
| 143 | //containerのマージンを切り替え |
| 144 | if (outerMarginBottom != null) { |
| 145 | cStyle = { marginBottom: outerMarginBottom + `rem` }; |
| 146 | } |
| 147 | |
| 148 | //titleのマージンを切り替え |
| 149 | if (titleMarginBottom != null) { |
| 150 | tStyle = { |
| 151 | color: titleColor, |
| 152 | fontSize: titleSize + "rem", |
| 153 | marginBottom: titleMarginBottom + "rem", |
| 154 | textAlign: align |
| 155 | }; |
| 156 | } else { |
| 157 | tStyle = { |
| 158 | color: titleColor, |
| 159 | fontSize: titleSize + "rem", |
| 160 | textAlign: align |
| 161 | }; |
| 162 | } |
| 163 | |
| 164 | if (for_ === "edit") { |
| 165 | return ( |
| 166 | <div className={ containerClass } style={ cStyle }> |
| 167 | <RichText |
| 168 | tagName={ tagName } |
| 169 | value={ title } |
| 170 | onChange={ value => setAttributes({ title: value }) } |
| 171 | style={ tStyle } |
| 172 | className={ `vk_heading_title vk_heading_title-style-${titleStyle}` } |
| 173 | placeholder={ __("Input title…", "vk-blocks") } |
| 174 | /> |
| 175 | { // サブテキスト |
| 176 | (() => { |
| 177 | if (subTextFlag === "on") { |
| 178 | return ( |
| 179 | <RichText |
| 180 | tagName={ "p" } |
| 181 | value={ subText } |
| 182 | onChange={ value => setAttributes({ subText: value }) } |
| 183 | style={ { |
| 184 | color: subTextColor, |
| 185 | fontSize: subTextSize + "rem", |
| 186 | textAlign: align |
| 187 | } } |
| 188 | className={ `vk_heading_subtext vk_heading_subtext-style-${titleStyle}` } |
| 189 | placeholder={ __("Input sub text…", "vk-blocks") } |
| 190 | /> |
| 191 | ); |
| 192 | } |
| 193 | })() } |
| 194 | </div> |
| 195 | ); |
| 196 | } else if (for_ === "save") { |
| 197 | return ( |
| 198 | <div className={ containerClass } style={ cStyle }> |
| 199 | <RichText.Content |
| 200 | tagName={ tagName } |
| 201 | value={ title } |
| 202 | onChange={ value => setAttributes({ title: value }) } |
| 203 | style={ tStyle } |
| 204 | className={ `vk_heading_title vk_heading_title-style-${titleStyle}` } |
| 205 | placeholder={ __("Input title…", "vk-blocks") } |
| 206 | /> |
| 207 | { // サブテキスト |
| 208 | (() => { |
| 209 | if (subTextFlag === "on") { |
| 210 | return ( |
| 211 | <RichText.Content |
| 212 | tagName={ "p" } |
| 213 | value={ subText } |
| 214 | onChange={ value => setAttributes({ subText: value }) } |
| 215 | style={ { |
| 216 | color: subTextColor, |
| 217 | fontSize: subTextSize + "rem", |
| 218 | textAlign: align |
| 219 | } } |
| 220 | className={ `vk_heading_subtext vk_heading_subtext-style-${titleStyle}` } |
| 221 | placeholder={ __("Input sub text…", "vk-blocks") } |
| 222 | /> |
| 223 | ); |
| 224 | } |
| 225 | })() } |
| 226 | </div> |
| 227 | ); |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | export class VKBHeadingV0_24_1 extends React.Component { |
| 233 | render() { |
| 234 | const { |
| 235 | level, |
| 236 | align, |
| 237 | title, |
| 238 | titleColor, |
| 239 | titleSize, |
| 240 | subText, |
| 241 | subTextFlag, |
| 242 | subTextColor, |
| 243 | subTextSize, |
| 244 | titleStyle, |
| 245 | titleMarginBottom, |
| 246 | outerMarginBottom |
| 247 | } = this.props.attributes; |
| 248 | const setAttributes = this.props.setAttributes; |
| 249 | const for_ = this.props.for_; |
| 250 | |
| 251 | const containerClass = `vk_heading vk_heading-style-${titleStyle}`; |
| 252 | const tagName = "h" + level; |
| 253 | let cStyle; |
| 254 | let tStyle; |
| 255 | |
| 256 | //containerのマージンを切り替え |
| 257 | if (outerMarginBottom !== null) { |
| 258 | cStyle = { marginBottom: outerMarginBottom + `rem` }; |
| 259 | } |
| 260 | |
| 261 | //titleのマージンを切り替え |
| 262 | if (titleMarginBottom != null) { |
| 263 | tStyle = { |
| 264 | color: titleColor, |
| 265 | fontSize: titleSize + "rem", |
| 266 | marginBottom: titleMarginBottom + "rem", |
| 267 | textAlign: align |
| 268 | }; |
| 269 | } else { |
| 270 | tStyle = { |
| 271 | color: titleColor, |
| 272 | fontSize: titleSize + "rem", |
| 273 | textAlign: align |
| 274 | }; |
| 275 | } |
| 276 | |
| 277 | if (for_ === "edit") { |
| 278 | return ( |
| 279 | <div className={ containerClass } style={ cStyle }> |
| 280 | <RichText |
| 281 | tagName={ tagName } |
| 282 | value={ title } |
| 283 | onChange={ value => setAttributes({ title: value }) } |
| 284 | style={ tStyle } |
| 285 | className={ `vk_heading_title vk_heading_title-style-${titleStyle}` } |
| 286 | placeholder={ __("Input title…", "vk-blocks") } |
| 287 | /> |
| 288 | { // サブテキスト |
| 289 | (() => { |
| 290 | if (subTextFlag === "on") { |
| 291 | return ( |
| 292 | <RichText |
| 293 | tagName={ "p" } |
| 294 | value={ subText } |
| 295 | onChange={ value => setAttributes({ subText: value }) } |
| 296 | style={ { |
| 297 | color: subTextColor, |
| 298 | fontSize: subTextSize + "rem", |
| 299 | textAlign: align |
| 300 | } } |
| 301 | className={ `vk_heading_subtext vk_heading_subtext-style-${titleStyle}` } |
| 302 | placeholder={ __("Input sub text…", "vk-blocks") } |
| 303 | /> |
| 304 | ); |
| 305 | } |
| 306 | })() } |
| 307 | </div> |
| 308 | ); |
| 309 | } else if (for_ === "save") { |
| 310 | return ( |
| 311 | <div className={ containerClass } style={ cStyle }> |
| 312 | <RichText.Content |
| 313 | tagName={ tagName } |
| 314 | value={ title } |
| 315 | onChange={ value => setAttributes({ title: value }) } |
| 316 | style={ tStyle } |
| 317 | className={ `vk_heading_title vk_heading_title-style-${titleStyle}` } |
| 318 | placeholder={ __("Input title…", "vk-blocks") } |
| 319 | /> |
| 320 | { // サブテキスト |
| 321 | (() => { |
| 322 | if (subTextFlag === "on") { |
| 323 | return ( |
| 324 | <RichText.Content |
| 325 | tagName={ "p" } |
| 326 | value={ subText } |
| 327 | onChange={ value => setAttributes({ subText: value }) } |
| 328 | style={ { |
| 329 | color: subTextColor, |
| 330 | fontSize: subTextSize + "rem", |
| 331 | textAlign: align |
| 332 | } } |
| 333 | className={ `vk_heading_subtext vk_heading_subtext-style-${titleStyle}` } |
| 334 | placeholder={ __("Input sub text…", "vk-blocks") } |
| 335 | /> |
| 336 | ); |
| 337 | } |
| 338 | })() } |
| 339 | </div> |
| 340 | ); |
| 341 | } |
| 342 | } |
| 343 | } |
| 344 |