@secretstache/wordpress-gutenberg 0.6.16 → 0.7.0

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.
Files changed (38) hide show
  1. package/build/editor-canvas.css +1 -1
  2. package/build/index.js +3208 -3187
  3. package/build/index.js.map +1 -1
  4. package/package.json +8 -2
  5. package/src/components/EmptyBlockPlaceholder.jsx +67 -0
  6. package/src/components/IconPicker.jsx +4 -5
  7. package/src/components/MediaControl.jsx +3 -3
  8. package/src/components/PatternAppender.jsx +24 -0
  9. package/src/components/PatternsModal.jsx +33 -35
  10. package/src/components/SpacingControl.jsx +5 -6
  11. package/src/components/index.js +19 -16
  12. package/src/filters/block-categories.js +50 -0
  13. package/src/filters/hide-root-block-for-other.js +53 -0
  14. package/src/filters/index.js +24 -0
  15. package/src/filters/inner-blocks-cleanup.jsx +53 -0
  16. package/src/filters/root-block.js +41 -0
  17. package/src/hooks/useTabs.jsx +2 -2
  18. package/src/icons/index.jsx +74 -38
  19. package/src/index.js +2 -0
  20. package/src/plugins/index.js +22 -0
  21. package/src/plugins/root-block-appender.jsx +51 -0
  22. package/src/plugins/root-pattern-appender.jsx +53 -0
  23. package/src/styles/{_empty-block-appender.scss → _empty-block-placeholder.scss} +6 -1
  24. package/src/styles/_root-block-appender.scss +13 -0
  25. package/src/styles/_root-pattern-appender.scss +58 -0
  26. package/src/styles/editor-canvas.scss +9 -3
  27. package/src/utils/helpers.js +53 -0
  28. package/src/utils/index.js +0 -3
  29. package/src/components/EmptyBlockAppender.jsx +0 -38
  30. package/src/utils/attributes.js +0 -252
  31. package/src/utils/filters.jsx +0 -40
  32. package/src/utils/rootBlock/appender.js +0 -62
  33. package/src/utils/rootBlock/hideRootBlockForInlineInserter.js +0 -24
  34. package/src/utils/rootBlock/index.js +0 -6
  35. package/src/utils/rootBlock/rootBlockVisibilityFilter.js +0 -35
  36. package/src/utils/rootBlock/setRootBlockFilter.js +0 -30
  37. package/src/utils/rootBlock/setRootBlockForPostTypes.js +0 -73
  38. package/src/utils/rootBlock/unsetRootBlockFilter.js +0 -26
@@ -1,38 +1,74 @@
1
- export const editIcon = () => (
2
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false">
3
- <path d="m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"></path>
4
- </svg>
5
- );
6
-
7
- export const trashIcon = () => (
8
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false">
9
- <path fillRule="evenodd" clipRule="evenodd" d="M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"></path>
10
- </svg>
11
- );
12
-
13
- export const pageIcon = () => (
14
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false">
15
- <path d="M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"></path>
16
- <path d="M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"></path>
17
- </svg>
18
- );
19
-
20
- export const plusIcon = () => (
21
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false">
22
- <path d="M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"></path>
23
- </svg>
24
- );
25
-
26
- export const sidesBottomIcon = () => (
27
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false">
28
- <path d="m7.5 6h9v-1.5h-9zm0 13.5h9v-1.5h-9zm-3-3h1.5v-9h-1.5zm13.5-9v9h1.5v-9z" style={{ opacity: 0.25 }}></path>
29
- <path d="m16.5 19.5h-9v-1.5h9z"></path>
30
- </svg>
31
- );
32
-
33
- export const sidesTopIcon = () => (
34
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false">
35
- <path d="m7.5 6h9v-1.5h-9zm0 13.5h9v-1.5h-9zm-3-3h1.5v-9h-1.5zm13.5-9v9h1.5v-9z" style={{ opacity: 0.25 }}></path>
36
- <path d="m16.5 6h-9v-1.5h9z"></path>
37
- </svg>
38
- );
1
+ import { deprecationWarning } from '../utils/internal/helpers.js';
2
+
3
+ export const editIcon = () => {
4
+ deprecationWarning('Warning: editIcon is deprecated since version 0.6.16 and will be removed in future versions. Please consider to use icons from @wordpress/icons package instead.');
5
+
6
+ return (
7
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false">
8
+ <path d="m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" />
9
+ </svg>
10
+ );
11
+ }
12
+
13
+ export const trashIcon = () => {
14
+ deprecationWarning('Warning: trashIcon is deprecated since version 0.6.16 and will be removed in future versions. Please consider to use icons from @wordpress/icons package instead.');
15
+
16
+ return (
17
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false">
18
+ <path fillRule="evenodd" clipRule="evenodd" d="M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z" />
19
+ </svg>
20
+ );
21
+ }
22
+
23
+ export const pageIcon = () => {
24
+ deprecationWarning('Warning: pageIcon is deprecated since version 0.6.16 and will be removed in future versions. Please consider to use icons from @wordpress/icons package instead.');
25
+
26
+ return (
27
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false">
28
+ <path d="M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z" />
29
+ <path d="M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"></path>
30
+ </svg>
31
+ );
32
+ }
33
+
34
+ export const plusIcon = () => {
35
+ deprecationWarning('Warning: plusIcon is deprecated since version 0.6.16 and will be removed in future versions. Please consider to use icons from @wordpress/icons package instead.');
36
+
37
+ return (
38
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false">
39
+ <path d="M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" />
40
+ </svg>
41
+ );
42
+ }
43
+
44
+ export const sidesBottomIcon = () => {
45
+ deprecationWarning('Warning: sidesBottomIcon is deprecated since version 0.6.16 and will be removed in future versions. Please consider to use icons from @wordpress/icons package instead.');
46
+
47
+ return (
48
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false">
49
+ <path d="m7.5 6h9v-1.5h-9zm0 13.5h9v-1.5h-9zm-3-3h1.5v-9h-1.5zm13.5-9v9h1.5v-9z" style={{ opacity: 0.25 }} />
50
+ <path d="m16.5 19.5h-9v-1.5h9z" />
51
+ </svg>
52
+ );
53
+ }
54
+
55
+ export const sidesTopIcon = () => {
56
+ deprecationWarning('Warning: sidesTopIcon is deprecated since version 0.6.16 and will be removed in future versions. Please consider to use icons from @wordpress/icons package instead.');
57
+
58
+ return (
59
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false">
60
+ <path d="m7.5 6h9v-1.5h-9zm0 13.5h9v-1.5h-9zm-3-3h1.5v-9h-1.5zm13.5-9v9h1.5v-9z" style={{ opacity: 0.25 }} />
61
+ <path d="m16.5 6h-9v-1.5h9z" />
62
+ </svg>
63
+ );
64
+ }
65
+
66
+ export const addTemplateIcon = () => {
67
+ deprecationWarning('Warning: addTemplateIcon is deprecated since version 0.6.16 and will be removed in future versions. Please consider to use icons from @wordpress/icons package instead.');
68
+
69
+ return (
70
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" aria-hidden="true" focusable="false">
71
+ <path fillRule="evenodd" clipRule="evenodd" d="M18.5 5.5V8H20V5.5H22.5V4H20V1.5H18.5V4H16V5.5H18.5ZM13.9624 4H6C4.89543 4 4 4.89543 4 6V18C4 19.1046 4.89543 20 6 20H18C19.1046 20 20 19.1046 20 18V10.0391H18.5V18C18.5 18.2761 18.2761 18.5 18 18.5H10L10 10.4917L16.4589 10.5139L16.4641 9.01389L5.5 8.97618V6C5.5 5.72386 5.72386 5.5 6 5.5H13.9624V4ZM5.5 10.4762V18C5.5 18.2761 5.72386 18.5 6 18.5H8.5L8.5 10.4865L5.5 10.4762Z" />
72
+ </svg>
73
+ );
74
+ }
package/src/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from './components/index.js';
2
2
  export * from './hooks/index.js';
3
+ export * from './plugins/index.js';
4
+ export * from './filters/index.js';
3
5
 
4
6
  export * from './utils/index.js';
@@ -0,0 +1,22 @@
1
+ import { select, subscribe } from '@wordpress/data';
2
+ import { waitForRootContainer } from '../utils/index.js';
3
+
4
+ export * from './root-block-appender.jsx';
5
+ export * from './root-pattern-appender.jsx';
6
+
7
+ export const setPostTypePlugins = (plugins, currentPostType) => {
8
+ if (!plugins || !currentPostType) return;
9
+
10
+ waitForRootContainer()
11
+ .then(() => {
12
+ plugins?.forEach((plugin) => {
13
+ if (plugin.isRegistered) {
14
+ plugin.unregister();
15
+ }
16
+
17
+ if (plugin.postTypes.includes(currentPostType)) {
18
+ plugin.register();
19
+ }
20
+ });
21
+ });
22
+ };
@@ -0,0 +1,51 @@
1
+ import { registerPlugin, unregisterPlugin } from '@wordpress/plugins';
2
+ import { createPortal } from '@wordpress/element';
3
+ import { dispatch } from '@wordpress/data';
4
+ import { createBlock } from '@wordpress/blocks';
5
+
6
+ import { getRootContainer } from '../utils/index.js';
7
+
8
+ export class RootBlockAppenderPlugin {
9
+ name = 'root-block-appender';
10
+ isRegistered = false;
11
+
12
+ constructor(
13
+ rootBlockName = 'ssm/section-wrapper',
14
+ postTypes = ['page', 'post', 'ssm_design_system'],
15
+ tooltipText = 'Add Row',
16
+ ) {
17
+ this.rootBlockName = rootBlockName;
18
+ this.postTypes = postTypes;
19
+ this.tooltipText = tooltipText;
20
+ }
21
+
22
+ register() {
23
+ const container = getRootContainer();
24
+
25
+ if (!container) {
26
+ console.error(`[${this.name}] - root container is not found.`);
27
+ return;
28
+ }
29
+
30
+ registerPlugin(this.name, {
31
+ render: () => createPortal(
32
+ <button
33
+ className="components-button block-editor-button-block-appender root-block-appender"
34
+ onClick={() => dispatch('core/block-editor').insertBlock(createBlock(this.rootBlockName))}
35
+ aria-label={this.tooltipText}
36
+ data-tooltip={this.tooltipText}
37
+ >
38
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"></path></svg>
39
+ </button>,
40
+ container
41
+ ),
42
+ });
43
+
44
+ this.isRegistered = true;
45
+ }
46
+
47
+ unregister() {
48
+ unregisterPlugin(this.name);
49
+ this.isRegistered = false;
50
+ }
51
+ }
@@ -0,0 +1,53 @@
1
+ import { registerPlugin, unregisterPlugin } from '@wordpress/plugins';
2
+ import { createPortal } from '@wordpress/element';
3
+
4
+ import { __experimentalPatternAppender as PatternAppender } from '../components/PatternAppender.jsx';
5
+ import { getRootContainer } from '../utils/index.js';
6
+
7
+ export class RootPatternAppenderPlugin {
8
+ name = 'root-pattern-appender';
9
+ isRegistered = false;
10
+
11
+ constructor(
12
+ postTypes = ['page', 'post', 'ssm_design_system'],
13
+ tooltipText = 'Add Pattern',
14
+ ) {
15
+ this.postTypes = postTypes;
16
+ this.tooltipText = tooltipText;
17
+ }
18
+
19
+ register() {
20
+ const container = getRootContainer();
21
+
22
+ if (!container) {
23
+ console.error(`[${this.name}] - root container is not found.`);
24
+ return;
25
+ }
26
+
27
+ registerPlugin(this.name, {
28
+ render: () => createPortal(
29
+ <PatternAppender
30
+ render={({ setModalOpen }) => (
31
+ <button
32
+ className="components-button block-editor-button-block-appender root-pattern-appender"
33
+ onClick={() => setModalOpen(true)}
34
+ aria-label={this.tooltipText}
35
+ data-tooltip={this.tooltipText}
36
+ >
37
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" aria-hidden="true" focusable="false"><path fillRule="evenodd" clipRule="evenodd" d="M18.5 5.5V8H20V5.5H22.5V4H20V1.5H18.5V4H16V5.5H18.5ZM13.9624 4H6C4.89543 4 4 4.89543 4 6V18C4 19.1046 4.89543 20 6 20H18C19.1046 20 20 19.1046 20 18V10.0391H18.5V18C18.5 18.2761 18.2761 18.5 18 18.5H10L10 10.4917L16.4589 10.5139L16.4641 9.01389L5.5 8.97618V6C5.5 5.72386 5.72386 5.5 6 5.5H13.9624V4ZM5.5 10.4762V18C5.5 18.2761 5.72386 18.5 6 18.5H8.5L8.5 10.4865L5.5 10.4762Z"></path></svg>
38
+ </button>
39
+ )}
40
+ rootClientId={null}
41
+ />,
42
+ container
43
+ )
44
+ });
45
+
46
+ this.isRegistered = true;
47
+ }
48
+
49
+ unregister() {
50
+ unregisterPlugin(this.name);
51
+ this.isRegistered = false;
52
+ }
53
+ }
@@ -1,4 +1,4 @@
1
- .empty-block-appender {
1
+ .empty-block-placeholder {
2
2
  --button-color: #192f5f;
3
3
  --button-color-hover: var(--wp-admin-theme-color);
4
4
  --button-border: #192f5f;
@@ -24,6 +24,11 @@
24
24
  --text-color: #fff;
25
25
  }
26
26
 
27
+ &__buttons-wrapper {
28
+ display: flex;
29
+ gap: 16px;
30
+ }
31
+
27
32
  &__content {
28
33
  display: flex;
29
34
  flex-direction: column;
@@ -3,6 +3,7 @@
3
3
  bottom: 30px;
4
4
  left: 50%;
5
5
  transform: translateX(-50%);
6
+ max-width: none !important;
6
7
  width: calc(100% - 60px);
7
8
 
8
9
  &::after {
@@ -38,3 +39,15 @@
38
39
  display: none;
39
40
  }
40
41
  }
42
+
43
+ &:has(> .root-block-appender):has(> .root-pattern-appender) > .root-block-appender {
44
+ left: 15%;
45
+ width: 50%;
46
+ transform: none;
47
+ max-width: none !important;
48
+ margin: unset !important;
49
+ box-shadow: none;
50
+ border: 1px solid #000;
51
+ border-top-right-radius: 0;
52
+ border-bottom-right-radius: 0;
53
+ }
@@ -0,0 +1,58 @@
1
+ .root-pattern-appender {
2
+ position: absolute;
3
+ bottom: 30px;
4
+ left: 50%;
5
+ transform: translateX(-50%);
6
+ max-width: none !important;
7
+ width: calc(100% - 60px);
8
+
9
+ &::after {
10
+ position: absolute;
11
+ bottom: -30px;
12
+ left: 50%;
13
+ transform: translateX(-50%);
14
+ visibility: hidden;
15
+ opacity: 0;
16
+ z-index: 1;
17
+ transition: opacity 0.3s;
18
+ border-radius: 2px;
19
+ background: #000;
20
+ padding: 4px 8px;
21
+ width: max-content;
22
+ max-width: 200px;
23
+ content: attr(data-tooltip);
24
+ color: #f0f0f0;
25
+ font-size: 12px;
26
+ line-height: 1.4;
27
+ font-family:
28
+ -apple-system,
29
+ BlinkMacSystemFont,
30
+ Segoe UI,
31
+ Roboto,
32
+ Oxygen-Sans,
33
+ Ubuntu,
34
+ Cantarell,
35
+ Helvetica Neue,
36
+ sans-serif;
37
+ text-align: center;
38
+ white-space: nowrap;
39
+ }
40
+
41
+ &:hover::after {
42
+ visibility: visible;
43
+ opacity: 1;
44
+ }
45
+ }
46
+
47
+ &:has(> .root-pattern-appender):has(> .root-block-appender) > .root-pattern-appender {
48
+ left: 65%;
49
+ width: 20%;
50
+ transform: none;
51
+ max-width: none !important;
52
+ margin: unset !important;
53
+ box-shadow: none;
54
+ border: 1px solid #000;
55
+ border-left: none;
56
+ border-top-left-radius: 0;
57
+ border-bottom-left-radius: 0;
58
+ }
@@ -19,19 +19,25 @@
19
19
  }
20
20
  }
21
21
 
22
-
23
22
  .block-editor-block-list__layout.is-root-container {
24
23
  @import "root-block-appender";
25
- @import "empty-block-appender";
24
+ @import "root-pattern-appender";
25
+ @import "empty-block-placeholder";
26
+
26
27
  @import "new-child-btn";
27
28
  @import "image-wrapper";
28
29
 
29
30
  margin-bottom: 0;
30
31
  padding-bottom: 0;
31
32
 
32
- &:has(.root-block-appender) {
33
+ &:has(.root-block-appender),
34
+ &:has(.root-pattern-appender) {
33
35
  margin-bottom: 3rem;
34
36
  padding-bottom: 200px;
37
+
38
+ & > .block-list-appender.wp-block {
39
+ display: none;
40
+ }
35
41
  }
36
42
 
37
43
  &.has-background {
@@ -324,6 +324,22 @@ export function updateBlockApiVersion(blockName, apiVersion = 3) {
324
324
  }
325
325
  }
326
326
 
327
+ /**
328
+ * Updates the API version of all registered blocks with an API version less than 3.
329
+ *
330
+ * Retrieves the list of registered blocks from the `core/blocks` store, filters out blocks
331
+ * with an API version less than 3, and updates their API version to the specified value.
332
+ *
333
+ * @param {number} apiVersion - The target API version to update blocks to.
334
+ */
335
+ export const updateAllBlocksApiVersion = (apiVersion) => {
336
+ select('core/blocks')
337
+ ?.getBlockTypes()
338
+ ?.filter((block) => block.apiVersion < 3)
339
+ ?.map((block) => block.name)
340
+ ?.forEach((blockName) => updateBlockApiVersion(blockName, apiVersion));
341
+ };
342
+
327
343
  /**
328
344
  * Creates object-position style based on focal point coordinates
329
345
  *
@@ -379,3 +395,40 @@ export const useDefaultSelectOptions = (postType, mapper = null, extraParams = {
379
395
  };
380
396
  }, [ postType, JSON.stringify(query) ]);
381
397
  };
398
+
399
+ export const hideBlockForInlineInserter = (blockName) => {
400
+ const styleElementId = `ssm-hide-${blockName}-for-inline-inserter`;
401
+
402
+ // Construct the CSS rule
403
+ const cssRule = `[id*="-block-${blockName}"] { display: none !important; }`;
404
+
405
+ // Create a style element
406
+ const styleElement = document.createElement('style');
407
+ styleElement.id = styleElementId;
408
+
409
+ // Set the CSS rule as the content of the style element
410
+ styleElement.appendChild(document.createTextNode(cssRule));
411
+
412
+ // Append the style element to the document's head
413
+ document.head.appendChild(styleElement);
414
+
415
+ // cleanup function
416
+ return () => {
417
+ document.head.removeChild(styleElement);
418
+ }
419
+ };
420
+
421
+ export const subscribeForPostTypeChange = (callback) => {
422
+ let prevPostType = null;
423
+
424
+ return subscribe(() => {
425
+ const currentPostType = select('core/editor').getCurrentPostType();
426
+ const isPostTypeChanged = currentPostType && (currentPostType !== prevPostType);
427
+
428
+ if (isPostTypeChanged) {
429
+ callback(currentPostType, prevPostType);
430
+
431
+ prevPostType = currentPostType;
432
+ }
433
+ }, 'core/block-editor');
434
+ };
@@ -1,7 +1,4 @@
1
- export * from './rootBlock/index.js';
2
1
  export * from './rootContainer/index.js';
3
2
 
4
- export * from './attributes.js';
5
3
  export * from './constants.js';
6
4
  export * from './helpers.js';
7
- export * from './filters.jsx';
@@ -1,38 +0,0 @@
1
- import { InnerBlocks } from '@wordpress/block-editor';
2
- import classNames from 'classnames';
3
-
4
- export const EmptyBlockAppender = (props) => {
5
- const {
6
- showIcon = true,
7
- showAppender = true,
8
- title = 'This block is empty',
9
- text = 'Use the "+" button below to add content blocks',
10
- isLight = false,
11
- className,
12
- } = props;
13
-
14
- return (
15
- <div className={classNames('empty-block-appender', className, { 'empty-block-appender--light': isLight })}>
16
- <div className="empty-block-appender__content">
17
- {
18
- showIcon && (
19
- <svg className="empty-block-appender__icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
20
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 13h6m-3-3v6m5 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
21
- </svg>
22
- )
23
- }
24
-
25
- <h3 className="empty-block-appender__title">{title}</h3>
26
- <p className="empty-block-appender__text">{text}</p>
27
- </div>
28
-
29
- {
30
- showAppender && (
31
- <div className="empty-block-appender__button">
32
- <InnerBlocks.ButtonBlockAppender />
33
- </div>
34
- )
35
- }
36
- </div>
37
- );
38
- };