@webikon/webentor-core 0.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/pre-commit +40 -0
- package/.prettierrc.js +5 -0
- package/CHANGELOG.md +88 -0
- package/LICENCE.md +7 -0
- package/README.md +26 -0
- package/core-js/_alpine.ts +20 -0
- package/core-js/_slider.ts +232 -0
- package/core-js/_utils.ts +126 -0
- package/core-js/blocks-components/block-appender.tsx +36 -0
- package/core-js/blocks-components/button.tsx +424 -0
- package/core-js/blocks-components/custom-image-sizes-panel.tsx +197 -0
- package/core-js/blocks-components/index.ts +4 -0
- package/core-js/blocks-components/typography-picker-select.tsx +31 -0
- package/core-js/blocks-filters/_filter-core-typography.tsx +108 -0
- package/core-js/blocks-filters/_slider-settings.tsx +283 -0
- package/core-js/blocks-filters/index.ts +3 -0
- package/core-js/blocks-filters/responsive-settings/components/DisabledSliderInfo.tsx +10 -0
- package/core-js/blocks-filters/responsive-settings/constants.ts +11 -0
- package/core-js/blocks-filters/responsive-settings/index.tsx +196 -0
- package/core-js/blocks-filters/responsive-settings/settings/block-link/index.ts +1 -0
- package/core-js/blocks-filters/responsive-settings/settings/block-link/panel.tsx +47 -0
- package/core-js/blocks-filters/responsive-settings/settings/border/border/index.tsx +1 -0
- package/core-js/blocks-filters/responsive-settings/settings/border/border/properties.ts +27 -0
- package/core-js/blocks-filters/responsive-settings/settings/border/border/settings.tsx +310 -0
- package/core-js/blocks-filters/responsive-settings/settings/border/border-radius/index.tsx +1 -0
- package/core-js/blocks-filters/responsive-settings/settings/border/border-radius/properties.ts +31 -0
- package/core-js/blocks-filters/responsive-settings/settings/border/border-radius/settings.tsx +211 -0
- package/core-js/blocks-filters/responsive-settings/settings/border/index.ts +1 -0
- package/core-js/blocks-filters/responsive-settings/settings/border/panel.tsx +54 -0
- package/core-js/blocks-filters/responsive-settings/settings/container/display/index.ts +2 -0
- package/core-js/blocks-filters/responsive-settings/settings/container/display/properties.ts +167 -0
- package/core-js/blocks-filters/responsive-settings/settings/container/display/settings.tsx +73 -0
- package/core-js/blocks-filters/responsive-settings/settings/container/flexbox/index.ts +2 -0
- package/core-js/blocks-filters/responsive-settings/settings/container/flexbox/properties.ts +187 -0
- package/core-js/blocks-filters/responsive-settings/settings/container/flexbox/settings.tsx +131 -0
- package/core-js/blocks-filters/responsive-settings/settings/container/grid/index.ts +2 -0
- package/core-js/blocks-filters/responsive-settings/settings/container/grid/properties.ts +187 -0
- package/core-js/blocks-filters/responsive-settings/settings/container/grid/settings.tsx +132 -0
- package/core-js/blocks-filters/responsive-settings/settings/container/index.ts +4 -0
- package/core-js/blocks-filters/responsive-settings/settings/container/panel.tsx +92 -0
- package/core-js/blocks-filters/responsive-settings/settings/spacing/index.ts +3 -0
- package/core-js/blocks-filters/responsive-settings/settings/spacing/panel.tsx +45 -0
- package/core-js/blocks-filters/responsive-settings/settings/spacing/properties.ts +74 -0
- package/core-js/blocks-filters/responsive-settings/settings/spacing/settings.tsx +85 -0
- package/core-js/blocks-filters/responsive-settings/types/index.ts +68 -0
- package/core-js/blocks-filters/responsive-settings/utils.ts +321 -0
- package/core-js/blocks-utils/_use-block-parent.ts +27 -0
- package/core-js/blocks-utils/_use-post-types.ts +43 -0
- package/core-js/blocks-utils/_use-taxonomies.ts +29 -0
- package/core-js/blocks-utils/index.ts +3 -0
- package/core-js/config/webentor-config.ts +718 -0
- package/core-js/index.ts +14 -0
- package/core-js/types/_block-components.ts +7 -0
- package/core-js/types/_webentor-config.ts +182 -0
- package/package.json +98 -0
- package/resources/blocks/e-accordion/block.json +34 -0
- package/resources/blocks/e-accordion/e-accordion.block.tsx +125 -0
- package/resources/blocks/e-accordion/script.ts +1 -0
- package/resources/blocks/e-accordion/style.css +8 -0
- package/resources/blocks/e-accordion-group/block.json +56 -0
- package/resources/blocks/e-accordion-group/e-accordion-group.block.tsx +99 -0
- package/resources/blocks/e-breadcrumbs/block.json +41 -0
- package/resources/blocks/e-breadcrumbs/e-breadcrumbs.block.tsx +53 -0
- package/resources/blocks/e-button/block.json +32 -0
- package/resources/blocks/e-button/e-button.block.tsx +55 -0
- package/resources/blocks/e-gallery/block.json +90 -0
- package/resources/blocks/e-gallery/e-gallery.block.tsx +316 -0
- package/resources/blocks/e-icon-picker/block.json +37 -0
- package/resources/blocks/e-icon-picker/e-icon-picker.block.tsx +230 -0
- package/resources/blocks/e-icon-picker/style.css +17 -0
- package/resources/blocks/e-image/block.json +78 -0
- package/resources/blocks/e-image/e-image.block.tsx +331 -0
- package/resources/blocks/e-picker-query-loop/block.json +25 -0
- package/resources/blocks/e-picker-query-loop/e-picker-query-loop.block.tsx +189 -0
- package/resources/blocks/e-post-template/block.json +25 -0
- package/resources/blocks/e-post-template/e-post-template.block.tsx +100 -0
- package/resources/blocks/e-query-loop/block.json +36 -0
- package/resources/blocks/e-query-loop/constants.tsx +8 -0
- package/resources/blocks/e-query-loop/e-query-loop.block.tsx +270 -0
- package/resources/blocks/e-query-loop/taxonomy-controls.tsx +184 -0
- package/resources/blocks/e-slider/block.json +42 -0
- package/resources/blocks/e-slider/e-slider.block.tsx +100 -0
- package/resources/blocks/e-svg/block.json +37 -0
- package/resources/blocks/e-svg/e-svg.block.tsx +156 -0
- package/resources/blocks/e-tab-container/block.json +49 -0
- package/resources/blocks/e-tab-container/e-tab-container.block.tsx +123 -0
- package/resources/blocks/e-table/block.json +30 -0
- package/resources/blocks/e-table/e-table.block.tsx +120 -0
- package/resources/blocks/e-table/script.ts +48 -0
- package/resources/blocks/e-table-cell/block.json +40 -0
- package/resources/blocks/e-table-cell/e-table-cell.block.tsx +180 -0
- package/resources/blocks/e-table-row/block.json +28 -0
- package/resources/blocks/e-table-row/e-table-row.block.tsx +118 -0
- package/resources/blocks/e-tabs/block.json +27 -0
- package/resources/blocks/e-tabs/e-tabs.block.tsx +90 -0
- package/resources/blocks/l-404/block.json +51 -0
- package/resources/blocks/l-404/l-404.block.tsx +75 -0
- package/resources/blocks/l-flexible-container/block.json +34 -0
- package/resources/blocks/l-flexible-container/l-flexible-container.block.tsx +97 -0
- package/resources/blocks/l-footer/block.json +23 -0
- package/resources/blocks/l-footer/l-footer.block.tsx +51 -0
- package/resources/blocks/l-formatted-content/block.json +28 -0
- package/resources/blocks/l-formatted-content/l-formatted-content.block.tsx +97 -0
- package/resources/blocks/l-header/block.json +26 -0
- package/resources/blocks/l-header/l-header.block.tsx +100 -0
- package/resources/blocks/l-mobile-nav/block.json +15 -0
- package/resources/blocks/l-mobile-nav/l-mobile-nav.block.tsx +56 -0
- package/resources/blocks/l-mobile-nav/style.css +54 -0
- package/resources/blocks/l-nav-menu/block.json +27 -0
- package/resources/blocks/l-nav-menu/l-nav-menu.block.tsx +109 -0
- package/resources/blocks/l-nav-menu/style.css +134 -0
- package/resources/blocks/l-post-card/block.json +13 -0
- package/resources/blocks/l-post-card/l-post-card.block.tsx +52 -0
- package/resources/blocks/l-section/block.json +89 -0
- package/resources/blocks/l-section/l-section.block.tsx +316 -0
- package/resources/blocks/l-site-logo/block.json +15 -0
- package/resources/blocks/l-site-logo/l-site-logo.block.tsx +54 -0
- package/resources/core-components/slider/slider.script.ts +11 -0
- package/resources/core-components/slider/slider.style.css +134 -0
- package/resources/scripts/editor.ts +29 -0
- package/resources/styles/app.css +21 -0
- package/resources/styles/common/_editor.css +86 -0
- package/resources/styles/common/_form.css +83 -0
- package/resources/styles/common/_global.css +73 -0
- package/resources/styles/common/_theme.css +75 -0
- package/resources/styles/common/_utilities.css +33 -0
- package/resources/styles/common/_wordpress.css +110 -0
- package/resources/styles/components/_table.css +102 -0
- package/resources/styles/editor.css +16 -0
- package/resources/styles/partials/.gitkeep +0 -0
- package/resources/styles/partials/_header.css +21 -0
- package/resources/styles/partials/_pagination.css +35 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../schemas/webentor-block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"title": "Table",
|
|
5
|
+
"description": "Improved table with possibility to add inner rows and cells.",
|
|
6
|
+
"name": "webentor/e-table",
|
|
7
|
+
"icon": "editor-table",
|
|
8
|
+
"category": "webentor-elements",
|
|
9
|
+
"example": {
|
|
10
|
+
"attributes": {
|
|
11
|
+
"mode": "preview",
|
|
12
|
+
"data": {
|
|
13
|
+
"preview_image_help": true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"attributes": {
|
|
18
|
+
"template": {
|
|
19
|
+
"type": "array",
|
|
20
|
+
"default": null
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"supports": {
|
|
24
|
+
"html": false,
|
|
25
|
+
"webentor": {
|
|
26
|
+
"spacing": true,
|
|
27
|
+
"border": true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InnerBlocks,
|
|
3
|
+
useBlockProps,
|
|
4
|
+
useInnerBlocksProps,
|
|
5
|
+
} from '@wordpress/block-editor';
|
|
6
|
+
import {
|
|
7
|
+
BlockEditProps,
|
|
8
|
+
registerBlockType,
|
|
9
|
+
TemplateArray,
|
|
10
|
+
} from '@wordpress/blocks';
|
|
11
|
+
import { applyFilters } from '@wordpress/hooks';
|
|
12
|
+
import { __ } from '@wordpress/i18n';
|
|
13
|
+
|
|
14
|
+
import { WebentorBlockAppender } from '@webentorCore/blocks-components';
|
|
15
|
+
import { useBlockParent } from '@webentorCore/blocks-utils/_use-block-parent';
|
|
16
|
+
|
|
17
|
+
import block from './block.json';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Edit component.
|
|
21
|
+
* See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#edit
|
|
22
|
+
*
|
|
23
|
+
* @param {object} props The block props.
|
|
24
|
+
* @param {object} props.attributes Block attributes.
|
|
25
|
+
* @param {string} props.className Class name for the block.
|
|
26
|
+
* @param {Function} props.setAttributes Sets the value for block attributes.
|
|
27
|
+
* @returns {Function} Render the edit screen
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
type AttributesType = {
|
|
31
|
+
coverImage: string;
|
|
32
|
+
template?: TemplateArray;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const BlockEdit: React.FC<BlockEditProps<AttributesType>> = (props) => {
|
|
36
|
+
const { attributes } = props;
|
|
37
|
+
|
|
38
|
+
const blockProps = useBlockProps();
|
|
39
|
+
const parentBlockProps = useBlockParent();
|
|
40
|
+
/**
|
|
41
|
+
* Filter allowed blocks used in webentor/e-table inner block
|
|
42
|
+
*/
|
|
43
|
+
const allowedBlocks: string[] = applyFilters(
|
|
44
|
+
'webentor.core.e-table.allowedBlocks',
|
|
45
|
+
['webentor/e-table-row'],
|
|
46
|
+
blockProps,
|
|
47
|
+
parentBlockProps,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Filter template used in webentor/e-table inner block
|
|
52
|
+
*/
|
|
53
|
+
const defaultTemplate: TemplateArray = attributes?.template ?? [
|
|
54
|
+
[
|
|
55
|
+
'webentor/e-table-row',
|
|
56
|
+
[['webentor/e-table-cell', 'webentor/e-table-cell']],
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
'webentor/e-table-row',
|
|
60
|
+
['webentor/e-table-cell', 'webentor/e-table-cell'],
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
'webentor/e-table-row',
|
|
64
|
+
['webentor/e-table-cell', 'webentor/e-table-cell'],
|
|
65
|
+
],
|
|
66
|
+
];
|
|
67
|
+
const template: TemplateArray = applyFilters(
|
|
68
|
+
'webentor.core.e-table.template',
|
|
69
|
+
defaultTemplate,
|
|
70
|
+
blockProps,
|
|
71
|
+
parentBlockProps,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const { children, ...innerBlocksProps } = useInnerBlocksProps(blockProps, {
|
|
75
|
+
allowedBlocks,
|
|
76
|
+
template,
|
|
77
|
+
renderAppender: false, // Disable the default appender
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Preview image for block inserter
|
|
81
|
+
if (attributes.coverImage) {
|
|
82
|
+
return <img src={attributes.coverImage} width="468" />;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div {...blockProps}>
|
|
87
|
+
<div className="wp-block-table">
|
|
88
|
+
<table className="wbtr:w-full">
|
|
89
|
+
<tbody {...innerBlocksProps}>
|
|
90
|
+
{children}
|
|
91
|
+
|
|
92
|
+
<tr></tr>
|
|
93
|
+
</tbody>
|
|
94
|
+
</table>
|
|
95
|
+
|
|
96
|
+
<div className="wbtr:my-2">
|
|
97
|
+
<WebentorBlockAppender
|
|
98
|
+
rootClientId={props.clientId}
|
|
99
|
+
text={__('Add rows', 'webentor')}
|
|
100
|
+
/>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#save
|
|
109
|
+
*
|
|
110
|
+
* @return {null} Dynamic blocks do not save the HTML.
|
|
111
|
+
*/
|
|
112
|
+
const BlockSave = () => <InnerBlocks.Content />;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Register block.
|
|
116
|
+
*/
|
|
117
|
+
registerBlockType(block, {
|
|
118
|
+
edit: BlockEdit,
|
|
119
|
+
save: BlockSave,
|
|
120
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { throttle } from '@webentorCore/_utils';
|
|
2
|
+
|
|
3
|
+
// Determine if the table is scrollable
|
|
4
|
+
const isTableScrollable = (table: HTMLElement) => {
|
|
5
|
+
const tableWidth = table.offsetWidth;
|
|
6
|
+
const tableScrollWidth = table.scrollWidth;
|
|
7
|
+
return tableScrollWidth > tableWidth;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// Add scroll shadow to the table
|
|
11
|
+
const addScrollShadow = (table: HTMLElement) => {
|
|
12
|
+
table.closest('.table-scroll-shadow')?.classList.add('has-scroll');
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const removeScrollShadow = (table: HTMLElement) => {
|
|
16
|
+
table.closest('.table-scroll-shadow')?.classList.remove('has-scroll');
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
20
|
+
const tables = document.querySelectorAll(
|
|
21
|
+
'.wp-block-table',
|
|
22
|
+
) as NodeListOf<HTMLElement>;
|
|
23
|
+
|
|
24
|
+
tables.forEach((table) => {
|
|
25
|
+
if (isTableScrollable(table)) {
|
|
26
|
+
addScrollShadow(table);
|
|
27
|
+
} else {
|
|
28
|
+
removeScrollShadow(table);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
window.addEventListener(
|
|
34
|
+
'resize',
|
|
35
|
+
throttle(() => {
|
|
36
|
+
const tables = document.querySelectorAll(
|
|
37
|
+
'.wp-block-table',
|
|
38
|
+
) as NodeListOf<HTMLElement>;
|
|
39
|
+
|
|
40
|
+
tables.forEach((table) => {
|
|
41
|
+
if (isTableScrollable(table)) {
|
|
42
|
+
addScrollShadow(table);
|
|
43
|
+
} else {
|
|
44
|
+
removeScrollShadow(table);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}, 100),
|
|
48
|
+
);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../schemas/webentor-block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"title": "Table Cell",
|
|
5
|
+
"description": "Cell with inner content.",
|
|
6
|
+
"name": "webentor/e-table-cell",
|
|
7
|
+
"parent": ["webentor/e-table-row"],
|
|
8
|
+
"category": "webentor-elements",
|
|
9
|
+
"example": {
|
|
10
|
+
"attributes": {
|
|
11
|
+
"mode": "preview",
|
|
12
|
+
"data": {
|
|
13
|
+
"preview_image_help": true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"attributes": {
|
|
18
|
+
"rowSpan": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"default": ""
|
|
21
|
+
},
|
|
22
|
+
"colSpan": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"default": ""
|
|
25
|
+
},
|
|
26
|
+
"showAsTh": {
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"default": false
|
|
29
|
+
},
|
|
30
|
+
"template": {
|
|
31
|
+
"type": "array",
|
|
32
|
+
"default": null
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"supports": {
|
|
36
|
+
"html": false,
|
|
37
|
+
"multiple": true,
|
|
38
|
+
"customClassName": false
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InnerBlocks,
|
|
3
|
+
InspectorControls,
|
|
4
|
+
useBlockProps,
|
|
5
|
+
useInnerBlocksProps,
|
|
6
|
+
} from '@wordpress/block-editor';
|
|
7
|
+
import {
|
|
8
|
+
BlockEditProps,
|
|
9
|
+
registerBlockType,
|
|
10
|
+
TemplateArray,
|
|
11
|
+
} from '@wordpress/blocks';
|
|
12
|
+
import {
|
|
13
|
+
__experimentalNumberControl as NumberControl,
|
|
14
|
+
PanelBody,
|
|
15
|
+
PanelRow,
|
|
16
|
+
ToggleControl,
|
|
17
|
+
} from '@wordpress/components';
|
|
18
|
+
import { applyFilters } from '@wordpress/hooks';
|
|
19
|
+
import { __ } from '@wordpress/i18n';
|
|
20
|
+
|
|
21
|
+
import { useBlockParent } from '@webentorCore/blocks-utils/_use-block-parent';
|
|
22
|
+
|
|
23
|
+
import block from './block.json';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Edit component.
|
|
27
|
+
* See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#edit
|
|
28
|
+
*
|
|
29
|
+
* @param {object} props The block props.
|
|
30
|
+
* @param {object} props.attributes Block attributes.
|
|
31
|
+
* @param {string} props.className Class name for the block.
|
|
32
|
+
* @param {Function} props.setAttributes Sets the value for block attributes.
|
|
33
|
+
* @returns {Function} Render the edit screen
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
type AttributesType = {
|
|
37
|
+
rowSpan: number;
|
|
38
|
+
colSpan: number;
|
|
39
|
+
showAsTh: boolean;
|
|
40
|
+
coverImage: string;
|
|
41
|
+
template?: TemplateArray;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const BlockEdit: React.FC<BlockEditProps<AttributesType>> = (props) => {
|
|
45
|
+
const { attributes, setAttributes } = props;
|
|
46
|
+
const { rowSpan, colSpan, showAsTh } = attributes;
|
|
47
|
+
|
|
48
|
+
const blockProps = useBlockProps();
|
|
49
|
+
const parentBlockProps = useBlockParent();
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Filter allowed blocks used in webentor/e-table-cell inner block
|
|
53
|
+
*/
|
|
54
|
+
const allowedBlocks: string[] = applyFilters(
|
|
55
|
+
'webentor.core.e-table-cell.allowedBlocks',
|
|
56
|
+
['core/paragraph', 'core/heading', 'core/list'],
|
|
57
|
+
blockProps,
|
|
58
|
+
parentBlockProps,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Filter template used in webentor/e-table-cell inner block
|
|
63
|
+
*/
|
|
64
|
+
const defaultTemplate: TemplateArray = attributes?.template ?? [
|
|
65
|
+
['core/paragraph', { placeholder: __('Add cell content', 'webentor') }],
|
|
66
|
+
];
|
|
67
|
+
const template: TemplateArray = applyFilters(
|
|
68
|
+
'webentor.core.e-table-cell.template',
|
|
69
|
+
defaultTemplate,
|
|
70
|
+
blockProps,
|
|
71
|
+
parentBlockProps,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const { children, ...innerBlocksProps } = useInnerBlocksProps(blockProps, {
|
|
75
|
+
allowedBlocks,
|
|
76
|
+
template,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Preview image for block inserter
|
|
80
|
+
if (attributes.coverImage) {
|
|
81
|
+
return <img src={attributes.coverImage} width="468" />;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const CellContent = (
|
|
85
|
+
<div {...innerBlocksProps}>
|
|
86
|
+
<div className="wbtr:mb-1 wbtr:text-10 wbtr:opacity-50">
|
|
87
|
+
{__('Cell Content', 'webentor')}
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
{children}
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<>
|
|
96
|
+
<InspectorControls>
|
|
97
|
+
<PanelBody title={__('Block Settings', 'webentor')} initialOpen={true}>
|
|
98
|
+
<PanelRow>
|
|
99
|
+
<NumberControl
|
|
100
|
+
label={__('Row Span', 'webentor')}
|
|
101
|
+
help={__(
|
|
102
|
+
'Set the number of rows this cell should span.',
|
|
103
|
+
'webentor',
|
|
104
|
+
)}
|
|
105
|
+
value={rowSpan}
|
|
106
|
+
onChange={(rowSpan) => setAttributes({ rowSpan })}
|
|
107
|
+
min={0}
|
|
108
|
+
/>
|
|
109
|
+
</PanelRow>
|
|
110
|
+
|
|
111
|
+
<PanelRow>
|
|
112
|
+
<NumberControl
|
|
113
|
+
label={__('Col Span', 'webentor')}
|
|
114
|
+
help={__(
|
|
115
|
+
'Set the number of columns this cell should span.',
|
|
116
|
+
'webentor',
|
|
117
|
+
)}
|
|
118
|
+
value={colSpan}
|
|
119
|
+
onChange={(colSpan) => setAttributes({ colSpan })}
|
|
120
|
+
min={0}
|
|
121
|
+
/>
|
|
122
|
+
</PanelRow>
|
|
123
|
+
|
|
124
|
+
<PanelRow>
|
|
125
|
+
<ToggleControl
|
|
126
|
+
label={__('Render as <th>> (head) cell', 'webentor')}
|
|
127
|
+
checked={showAsTh}
|
|
128
|
+
onChange={(showAsTh) => setAttributes({ showAsTh })}
|
|
129
|
+
/>
|
|
130
|
+
</PanelRow>
|
|
131
|
+
</PanelBody>
|
|
132
|
+
</InspectorControls>
|
|
133
|
+
|
|
134
|
+
{showAsTh ? (
|
|
135
|
+
<th
|
|
136
|
+
className={`wbtr:border wbtr:border-dashed wbtr:border-black wbtr:p-2`}
|
|
137
|
+
rowSpan={rowSpan}
|
|
138
|
+
colSpan={colSpan}
|
|
139
|
+
>
|
|
140
|
+
{CellContent}
|
|
141
|
+
</th>
|
|
142
|
+
) : (
|
|
143
|
+
<td
|
|
144
|
+
className={`wbtr:border wbtr:border-dashed wbtr:border-black wbtr:p-2`}
|
|
145
|
+
rowSpan={rowSpan}
|
|
146
|
+
colSpan={colSpan}
|
|
147
|
+
>
|
|
148
|
+
{CellContent}
|
|
149
|
+
</td>
|
|
150
|
+
)}
|
|
151
|
+
</>
|
|
152
|
+
);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#save
|
|
157
|
+
*
|
|
158
|
+
* @return {null} Dynamic blocks do not save the HTML.
|
|
159
|
+
*/
|
|
160
|
+
const BlockSave = () => <InnerBlocks.Content />;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Register block.
|
|
164
|
+
*/
|
|
165
|
+
registerBlockType(block, {
|
|
166
|
+
edit: BlockEdit,
|
|
167
|
+
save: BlockSave,
|
|
168
|
+
// TODO: extract icon to icon set
|
|
169
|
+
icon: {
|
|
170
|
+
src: (
|
|
171
|
+
<svg
|
|
172
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
173
|
+
viewBox="0 0 14 14"
|
|
174
|
+
style={{ minWidth: 16, minHeight: 16, width: 16, height: 16 }}
|
|
175
|
+
>
|
|
176
|
+
<path d="M2 6h4V2H2v4Zm0 2v4h4V8H2Zm10-2V2H8v4h4Zm0 2H8v4h4V8ZM2 0h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2Z" />
|
|
177
|
+
</svg>
|
|
178
|
+
),
|
|
179
|
+
},
|
|
180
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../schemas/webentor-block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"title": "Table Row",
|
|
5
|
+
"description": "Row with inner content.",
|
|
6
|
+
"name": "webentor/e-table-row",
|
|
7
|
+
"parent": ["webentor/e-table"],
|
|
8
|
+
"category": "webentor-elements",
|
|
9
|
+
"example": {
|
|
10
|
+
"attributes": {
|
|
11
|
+
"mode": "preview",
|
|
12
|
+
"data": {
|
|
13
|
+
"preview_image_help": true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"attributes": {
|
|
18
|
+
"template": {
|
|
19
|
+
"type": "array",
|
|
20
|
+
"default": null
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"supports": {
|
|
24
|
+
"html": false,
|
|
25
|
+
"multiple": true,
|
|
26
|
+
"customClassName": false
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InnerBlocks,
|
|
3
|
+
useBlockProps,
|
|
4
|
+
useInnerBlocksProps,
|
|
5
|
+
} from '@wordpress/block-editor';
|
|
6
|
+
import {
|
|
7
|
+
BlockEditProps,
|
|
8
|
+
registerBlockType,
|
|
9
|
+
TemplateArray,
|
|
10
|
+
} from '@wordpress/blocks';
|
|
11
|
+
import { applyFilters } from '@wordpress/hooks';
|
|
12
|
+
import { __ } from '@wordpress/i18n';
|
|
13
|
+
|
|
14
|
+
import { WebentorBlockAppender } from '@webentorCore/blocks-components';
|
|
15
|
+
import { useBlockParent } from '@webentorCore/blocks-utils/_use-block-parent';
|
|
16
|
+
|
|
17
|
+
import block from './block.json';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Edit component.
|
|
21
|
+
* See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#edit
|
|
22
|
+
*
|
|
23
|
+
* @param {object} props The block props.
|
|
24
|
+
* @param {object} props.attributes Block attributes.
|
|
25
|
+
* @param {string} props.className Class name for the block.
|
|
26
|
+
* @param {Function} props.setAttributes Sets the value for block attributes.
|
|
27
|
+
* @returns {Function} Render the edit screen
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
type AttributesType = {
|
|
31
|
+
coverImage: string;
|
|
32
|
+
template?: TemplateArray;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const BlockEdit: React.FC<BlockEditProps<AttributesType>> = (props) => {
|
|
36
|
+
const { attributes } = props;
|
|
37
|
+
|
|
38
|
+
const blockProps = useBlockProps();
|
|
39
|
+
const parentBlockProps = useBlockParent();
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Filter allowed blocks used in webentor/e-table-row inner block
|
|
43
|
+
*/
|
|
44
|
+
const allowedBlocks: string[] = applyFilters(
|
|
45
|
+
'webentor.core.e-table-row.allowedBlocks',
|
|
46
|
+
['webentor/e-table-cell'],
|
|
47
|
+
blockProps,
|
|
48
|
+
parentBlockProps,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Filter template used in webentor/e-table-row inner block
|
|
53
|
+
*/
|
|
54
|
+
const defaultTemplate: TemplateArray = attributes?.template ?? [
|
|
55
|
+
['webentor/e-table-cell'],
|
|
56
|
+
['webentor/e-table-cell'],
|
|
57
|
+
];
|
|
58
|
+
const template: TemplateArray = applyFilters(
|
|
59
|
+
'webentor.core.e-table-row.template',
|
|
60
|
+
defaultTemplate,
|
|
61
|
+
blockProps,
|
|
62
|
+
parentBlockProps,
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const { children, ...innerBlocksProps } = useInnerBlocksProps(blockProps, {
|
|
66
|
+
allowedBlocks,
|
|
67
|
+
template,
|
|
68
|
+
renderAppender: false, // Disable the default appender
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Preview image for block inserter
|
|
72
|
+
if (attributes.coverImage) {
|
|
73
|
+
return <img src={attributes.coverImage} width="468" />;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<tr {...innerBlocksProps} className={`${innerBlocksProps.className}`}>
|
|
78
|
+
{children}
|
|
79
|
+
|
|
80
|
+
<td>
|
|
81
|
+
<WebentorBlockAppender
|
|
82
|
+
rootClientId={props.clientId}
|
|
83
|
+
text={__('Add cell', 'webentor')}
|
|
84
|
+
/>
|
|
85
|
+
</td>
|
|
86
|
+
</tr>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#save
|
|
92
|
+
*
|
|
93
|
+
* @return {null} Dynamic blocks do not save the HTML.
|
|
94
|
+
*/
|
|
95
|
+
const BlockSave = () => <InnerBlocks.Content />;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Register block.
|
|
99
|
+
*/
|
|
100
|
+
registerBlockType(block, {
|
|
101
|
+
edit: BlockEdit,
|
|
102
|
+
save: BlockSave,
|
|
103
|
+
// TODO: extract icon to icon set
|
|
104
|
+
icon: {
|
|
105
|
+
src: (
|
|
106
|
+
<svg
|
|
107
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
108
|
+
viewBox="0 0 1920 1920"
|
|
109
|
+
style={{ minWidth: 16, minHeight: 16, width: 16, height: 16 }}
|
|
110
|
+
>
|
|
111
|
+
<path
|
|
112
|
+
fillRule="evenodd"
|
|
113
|
+
d="M1694.118 0C1818.692 0 1920 101.308 1920 225.882v1468.236c0 124.574-101.308 225.882-225.882 225.882H225.882C101.308 1920 0 1818.692 0 1694.118V225.882C0 101.308 101.308 0 225.882 0Zm.226 1355.294h-339.05v338.824h339.05v-338.824Zm-564.932 0H790.588v338.824h338.824v-338.824Zm-564.706 0H225.882v338.824h338.824v-338.824Zm564.706-1129.412H790.588v338.824h338.824V225.882Zm-564.706 0H225.882v338.824h338.824V225.882Zm1129.412 0h-338.824v338.824h338.824V225.882Z"
|
|
114
|
+
/>
|
|
115
|
+
</svg>
|
|
116
|
+
),
|
|
117
|
+
},
|
|
118
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../schemas/webentor-block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "webentor/e-tabs",
|
|
5
|
+
"title": "Tabs",
|
|
6
|
+
"description": "Tabs block.",
|
|
7
|
+
"category": "webentor-elements",
|
|
8
|
+
"icon": "feedback",
|
|
9
|
+
"allowedBlocks": ["webentor/e-tab-container"],
|
|
10
|
+
"keywords": ["tabs", "elements"],
|
|
11
|
+
"attributes": {},
|
|
12
|
+
"example": {
|
|
13
|
+
"attributes": {
|
|
14
|
+
"mode": "preview",
|
|
15
|
+
"data": {
|
|
16
|
+
"preview_image_help": true
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"supports": {
|
|
21
|
+
"anchor": true,
|
|
22
|
+
"webentor": {
|
|
23
|
+
"display": true,
|
|
24
|
+
"spacing": true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InnerBlocks,
|
|
3
|
+
useBlockProps,
|
|
4
|
+
useInnerBlocksProps,
|
|
5
|
+
} from '@wordpress/block-editor';
|
|
6
|
+
import {
|
|
7
|
+
BlockEditProps,
|
|
8
|
+
registerBlockType,
|
|
9
|
+
TemplateArray,
|
|
10
|
+
} from '@wordpress/blocks';
|
|
11
|
+
import { applyFilters } from '@wordpress/hooks';
|
|
12
|
+
|
|
13
|
+
import { useBlockParent } from '@webentorCore/blocks-utils/_use-block-parent';
|
|
14
|
+
|
|
15
|
+
import block from './block.json';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Edit component.
|
|
19
|
+
* See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#edit
|
|
20
|
+
*
|
|
21
|
+
* @param {object} props The block props.
|
|
22
|
+
* @returns {Function} Render the edit screen
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
type AttributesType = {
|
|
26
|
+
coverImage: string;
|
|
27
|
+
template?: TemplateArray;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const BlockEdit: React.FC<BlockEditProps<AttributesType>> = (props) => {
|
|
31
|
+
const { attributes } = props;
|
|
32
|
+
|
|
33
|
+
const blockProps = useBlockProps();
|
|
34
|
+
const parentBlockProps = useBlockParent();
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Filter allowed blocks used in webentor/e-tabs inner block
|
|
38
|
+
*/
|
|
39
|
+
const allowedBlocks: string[] = applyFilters(
|
|
40
|
+
'webentor.core.e-tabs.allowedBlocks',
|
|
41
|
+
['webentor/e-tab-container'],
|
|
42
|
+
blockProps,
|
|
43
|
+
parentBlockProps,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Filter template used in webentor/e-tabs inner block
|
|
48
|
+
*/
|
|
49
|
+
const defaultTemplate: TemplateArray = attributes?.template ?? [
|
|
50
|
+
['webentor/e-tab-container'],
|
|
51
|
+
];
|
|
52
|
+
const template: TemplateArray = applyFilters(
|
|
53
|
+
'webentor.core.e-tabs.template',
|
|
54
|
+
defaultTemplate,
|
|
55
|
+
blockProps,
|
|
56
|
+
parentBlockProps,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const innerBlocksProps = useInnerBlocksProps(blockProps, {
|
|
60
|
+
allowedBlocks,
|
|
61
|
+
template,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Preview image for block inserter
|
|
65
|
+
if (attributes.coverImage) {
|
|
66
|
+
return <img src={attributes.coverImage} width="468" />;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div
|
|
71
|
+
{...innerBlocksProps}
|
|
72
|
+
className={`${blockProps.className} ${innerBlocksProps.className} e-tabs wbtr:border wbtr:border-dashed wbtr:border-editor-border wbtr:p-2`}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#save
|
|
79
|
+
*
|
|
80
|
+
* @return {null} Dynamic blocks do not save the HTML.
|
|
81
|
+
*/
|
|
82
|
+
const BlockSave = () => <InnerBlocks.Content />;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Register block.
|
|
86
|
+
*/
|
|
87
|
+
registerBlockType(block, {
|
|
88
|
+
edit: BlockEdit,
|
|
89
|
+
save: BlockSave,
|
|
90
|
+
});
|