PluginProbe
Tableberg – Simple Gutenberg Table Block / 1.1.5
Tableberg – Simple Gutenberg Table Block v1.1.5
1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 trunk 0.0.2 0.2.1 0.3.2 0.3.3 0.4.1 0.5.0 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 All 42 releases
tableberg / src / blocks / element-edit-common.tsx

element-edit-common.tsx in Tableberg – Simple Gutenberg Table Block 1.1.5, at src/blocks/element-edit-common.tsx

54 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { CSSProperties } from "react";
2
3 import { CellKey } from "../attributes";
4 import {
5 ElementAlignment,
6 elementAlignmentToJustifyContent,
7 } from "../alignment";
8
9 /** Shared bits for the element blocks' edit components. */
10
11 export function alignmentWrapperStyle(align: ElementAlignment): CSSProperties {
12 return {
13 display: "flex",
14 justifyContent: elementAlignmentToJustifyContent(align),
15 textAlign: align,
16 };
17 }
18
19 // Placeholder coords for reused controls whose store path is inactive in
20 // the native editor (the passed updateAttrs/updateStyles override always
21 // wins).
22 export const NO_COORDS = "0,0" as CellKey;
23
24 import { BlockControls } from "@wordpress/block-editor";
25 import { ToolbarWithDropdown } from "@tableberg/components";
26 import { __ } from "@wordpress/i18n";
27
28 export function ElementAlignmentToolbar({
29 align,
30 onChange,
31 }: {
32 align: ElementAlignment;
33 onChange: (align: ElementAlignment) => void;
34 }) {
35 return (
36 <BlockControls>
37 <ToolbarWithDropdown
38 title={__("Align element", "tableberg")}
39 value={align}
40 onChange={(newAlign?: string) => {
41 if (
42 newAlign === "left" ||
43 newAlign === "center" ||
44 newAlign === "right"
45 ) {
46 onChange(newAlign);
47 }
48 }}
49 controlset="alignment"
50 />
51 </BlockControls>
52 );
53 }
54