components
2 years ago
customize-sidebar.js
2 years ago
post-sidebar.js
2 years ago
sidebar.js
2 years ago
toolbar.js
2 years ago
toolbar.js
98 lines
| 1 | /* |
| 2 | * Block Editor Toolbar |
| 3 | * |
| 4 | * Copyright (c) 2023 Boholweb WP |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | /* Add widget options attribute to all existing blocks, in Toolbar */ |
| 9 | |
| 10 | const { createHigherOrderComponent } = wp.compose; |
| 11 | const { Fragment } = wp.element; |
| 12 | const { BlockControls, InspectorControls } = wp.blockEditor; |
| 13 | // const { ToolbarGroup, ToolbarButton, ToolbarDropdownMenu, Toolbar } = |
| 14 | // wp.components; |
| 15 | |
| 16 | import { |
| 17 | Card, |
| 18 | CardHeader, |
| 19 | CardBody, |
| 20 | CardFooter, |
| 21 | __experimentalText as Text, |
| 22 | __experimentalHeading as Heading, |
| 23 | ToolbarDropdownMenu, |
| 24 | } from "@wordpress/components"; |
| 25 | |
| 26 | import classnames from "classnames"; |
| 27 | import { more, alignCenter, grid } from "@wordpress/icons"; |
| 28 | |
| 29 | /** |
| 30 | * Add Widget Options Button to Toolbar |
| 31 | */ |
| 32 | const toolbarButton = createHigherOrderComponent((BlockEdit) => { |
| 33 | return (props) => { |
| 34 | const { attributes, setAttributes } = props; |
| 35 | const { paragraphAttribute } = attributes; |
| 36 | |
| 37 | return ( |
| 38 | <Fragment> |
| 39 | <BlockControls group="block"> |
| 40 | <ToolbarDropdownMenu |
| 41 | icon="welcome-widgets-menus" |
| 42 | label="Widget Options" |
| 43 | controls={[ |
| 44 | { |
| 45 | title: "Columns", |
| 46 | icon: grid, |
| 47 | onClick: () => console.log("Columns"), |
| 48 | }, |
| 49 | { |
| 50 | title: "Alignment", |
| 51 | icon: alignCenter, |
| 52 | onClick: () => console.log("Alignment"), |
| 53 | }, |
| 54 | { |
| 55 | title: "Role", |
| 56 | icon: "admin-users", |
| 57 | onClick: () => console.log("Role"), |
| 58 | }, |
| 59 | { |
| 60 | title: "Visibility", |
| 61 | icon: "visibility", |
| 62 | onClick: () => console.log("Visibility"), |
| 63 | }, |
| 64 | { |
| 65 | title: "Devices", |
| 66 | icon: "smartphone", |
| 67 | onClick: () => console.log("Devices"), |
| 68 | }, |
| 69 | { |
| 70 | title: "Days & Dates", |
| 71 | icon: "calendar-alt", |
| 72 | onClick: () => console.log("Days & Dates"), |
| 73 | }, |
| 74 | { |
| 75 | title: "Styling", |
| 76 | icon: "art", |
| 77 | onClick: () => console.log("Styling"), |
| 78 | }, |
| 79 | { |
| 80 | title: "Class,ID & Logic", |
| 81 | icon: "admin-generic", |
| 82 | onClick: () => console.log("Class,ID & Logic"), |
| 83 | }, |
| 84 | ]} |
| 85 | /> |
| 86 | </BlockControls> |
| 87 | <BlockEdit {...props} /> |
| 88 | </Fragment> |
| 89 | ); |
| 90 | }; |
| 91 | }, "toolbarButton"); |
| 92 | |
| 93 | wp.hooks.addFilter( |
| 94 | "editor.BlockEdit", |
| 95 | "widgetopts-attributes/toolbar-button", |
| 96 | toolbarButton |
| 97 | ); |
| 98 |