| 1 |
/* global $e, elementor */ |
| 2 |
|
| 3 |
import * as hooks from './hooks/'; |
| 4 |
import * as commands from './commands'; |
| 5 |
|
| 6 |
export class BeyondwordsComponent extends $e.modules.ComponentBase { |
| 7 |
constructor() { |
| 8 |
super(); |
| 9 |
|
| 10 |
this.bindEvents(); |
| 11 |
} |
| 12 |
|
| 13 |
/** |
| 14 |
* Listen to click events. |
| 15 |
* |
| 16 |
* Inspired by https://github.com/elementor/elementor/blob/9aadba35a9ad52cd5e9cbef55a5761f47403491c/modules/container-converter/assets/js/editor/component.js#L10 |
| 17 |
* |
| 18 |
* @return {void} |
| 19 |
*/ |
| 20 |
bindEvents() { |
| 21 |
// Copy "Inspect" data |
| 22 |
elementor.channels.editor.on( 'beyondwords:copy-inspect-data', () => { |
| 23 |
// @todo Copy data |
| 24 |
elementor.notifications.showToast( { |
| 25 |
// message: __( 'TODO: The data has been copied.', 'elementor' ), |
| 26 |
message: 'TODO: The data has been copied.', |
| 27 |
} ); |
| 28 |
} ); |
| 29 |
|
| 30 |
// Email support |
| 31 |
elementor.channels.editor.on( 'beyondwords:email-support', () => { |
| 32 |
window.location.href = 'mailto:[email protected]'; |
| 33 |
} ); |
| 34 |
|
| 35 |
// Open guide |
| 36 |
elementor.channels.editor.on( 'beyondwords:open-guide', () => { |
| 37 |
window.open( |
| 38 |
'https://docs.beyondwords.io/docs-and-guides/content/connect-cms/wordpress/install?utm_source=wordpress&utm_medium=referral&utm_campaign=&utm_content=plugin' |
| 39 |
); |
| 40 |
} ); |
| 41 |
} |
| 42 |
|
| 43 |
getNamespace() { |
| 44 |
return 'beyondwords'; |
| 45 |
} |
| 46 |
|
| 47 |
defaultCommands() { |
| 48 |
return this.importCommands( commands ); |
| 49 |
} |
| 50 |
|
| 51 |
// https://github.com/elementor/elementor/blob/9aadba35a9ad52cd5e9cbef55a5761f47403491c/docs/modules/web-cli/assets/js/core/hooks.md |
| 52 |
defaultHooks() { |
| 53 |
return this.importHooks( hooks ); |
| 54 |
} |
| 55 |
|
| 56 |
// Redux state for this JS component |
| 57 |
defaultStates() { |
| 58 |
return { |
| 59 |
// A correspnding `Slice` instance will be available under `$e.store.get( 'beyondwords' )`. |
| 60 |
'': { |
| 61 |
initialState: { |
| 62 |
projectId: null, |
| 63 |
contentId: null, |
| 64 |
}, |
| 65 |
reducers: { |
| 66 |
setProjectId: ( prev, { payload } ) => { |
| 67 |
return { |
| 68 |
...prev, |
| 69 |
projectId: payload, |
| 70 |
}; |
| 71 |
}, |
| 72 |
setContentId: ( prev, { payload } ) => { |
| 73 |
return { |
| 74 |
...prev, |
| 75 |
contentId: payload, |
| 76 |
}; |
| 77 |
}, |
| 78 |
}, |
| 79 |
}, |
| 80 |
}; |
| 81 |
} |
| 82 |
} |
| 83 |
|