| 1 |
import { waitUntilExists, waitUntilGone } from '@help-center/lib/tour-helpers'; |
| 2 |
import { hasPageCreatorEnabled } from '@help-center/lib/utils'; |
| 3 |
import { __, isRTL } from '@wordpress/i18n'; |
| 4 |
|
| 5 |
export default { |
| 6 |
id: 'library-tour', |
| 7 |
title: __('Design Library', 'extendify-local'), |
| 8 |
settings: { |
| 9 |
allowOverflow: true, |
| 10 |
hideDotsNav: true, |
| 11 |
startFrom: [ |
| 12 |
hasPageCreatorEnabled |
| 13 |
? `${window.extSharedData.adminUrl}post-new.php?post_type=page&ext-page-creator-close=1` |
| 14 |
: `${window.extSharedData.adminUrl}post-new.php?post_type=page&ext-close=1`, |
| 15 |
`${window.extSharedData.adminUrl}post-new.php?post_type=page`, |
| 16 |
], |
| 17 |
}, |
| 18 |
onStart: async () => { |
| 19 |
// Wait for gutenberg to be ready |
| 20 |
await waitUntilExists('#extendify-library-btn'); |
| 21 |
|
| 22 |
// Close sidebar if open |
| 23 |
document |
| 24 |
.querySelector(`[aria-label="${__('Settings')}"].is-pressed`) |
| 25 |
?.click(); |
| 26 |
}, |
| 27 |
steps: [ |
| 28 |
{ |
| 29 |
title: __('Open the Pattern Library', 'extendify-local'), |
| 30 |
text: __( |
| 31 |
'The Extendify pattern library can be opened by clicking the button to the left.', |
| 32 |
'extendify-local', |
| 33 |
), |
| 34 |
attachTo: { |
| 35 |
element: '#extendify-library-btn [role="button"]', |
| 36 |
offset: { |
| 37 |
marginTop: 0, |
| 38 |
marginLeft: isRTL() ? -15 : 15, |
| 39 |
}, |
| 40 |
position: { |
| 41 |
x: isRTL() ? 'left' : 'right', |
| 42 |
y: 'top', |
| 43 |
}, |
| 44 |
hook: isRTL() ? 'top right' : 'top left', |
| 45 |
}, |
| 46 |
events: { |
| 47 |
beforeAttach: () => {}, |
| 48 |
}, |
| 49 |
}, |
| 50 |
{ |
| 51 |
title: __('Filter Patterns', 'extendify-local'), |
| 52 |
text: __( |
| 53 |
'Click on any pattern category to refine the selection.', |
| 54 |
'extendify-local', |
| 55 |
), |
| 56 |
attachTo: { |
| 57 |
element: '#extendify-library-category-control', |
| 58 |
position: { |
| 59 |
x: isRTL() ? 'left' : 'right', |
| 60 |
y: 'top', |
| 61 |
}, |
| 62 |
hook: isRTL() ? 'top right' : 'top left', |
| 63 |
}, |
| 64 |
options: { |
| 65 |
allowPointerEvents: true, |
| 66 |
}, |
| 67 |
events: { |
| 68 |
beforeAttach: async () => { |
| 69 |
// Open the Extendify library panel |
| 70 |
dispatchEvent(new CustomEvent('extendify::open-library')); |
| 71 |
|
| 72 |
return await waitUntilExists('#extendify-library-category-control'); |
| 73 |
}, |
| 74 |
}, |
| 75 |
}, |
| 76 |
{ |
| 77 |
title: __('Select a Pattern', 'extendify-local'), |
| 78 |
text: __( |
| 79 |
'Simply select any pattern you wish to insert into a page by clicking on it.', |
| 80 |
'extendify-local', |
| 81 |
), |
| 82 |
attachTo: { |
| 83 |
element: '#extendify-library-patterns-list', |
| 84 |
position: { |
| 85 |
x: isRTL() ? 'right' : 'left', |
| 86 |
y: 'top', |
| 87 |
}, |
| 88 |
hook: isRTL() ? 'top right' : 'top left', |
| 89 |
}, |
| 90 |
events: { |
| 91 |
beforeAttach: async () => { |
| 92 |
await waitUntilExists('#extendify-library-patterns-list'); |
| 93 |
}, |
| 94 |
}, |
| 95 |
}, |
| 96 |
{ |
| 97 |
title: __('View the Inserted Pattern', 'extendify-local'), |
| 98 |
text: __( |
| 99 |
'The selected pattern has been inserted into the page.', |
| 100 |
'extendify-local', |
| 101 |
), |
| 102 |
attachTo: { |
| 103 |
element: '.wp-block-group:last-child', |
| 104 |
frame: 'iframe[name="editor-canvas"]', |
| 105 |
offset: { |
| 106 |
marginTop: 15, |
| 107 |
marginLeft: 0, |
| 108 |
}, |
| 109 |
position: { |
| 110 |
x: isRTL() ? 'left' : 'right', |
| 111 |
y: 'top', |
| 112 |
}, |
| 113 |
hook: isRTL() ? 'top left' : 'top right', |
| 114 |
}, |
| 115 |
events: { |
| 116 |
beforeAttach: async () => { |
| 117 |
document |
| 118 |
.querySelector('#extendify-library-patterns-list .library-pattern') |
| 119 |
?.click(); |
| 120 |
|
| 121 |
return await waitUntilGone('#extendify-library-patterns-list'); |
| 122 |
}, |
| 123 |
}, |
| 124 |
options: { |
| 125 |
hideBackButton: true, |
| 126 |
}, |
| 127 |
}, |
| 128 |
], |
| 129 |
}; |
| 130 |
|