Skip to content

Commit

Permalink
Add replaces configuration for editor context menus (#4714)
Browse files Browse the repository at this point in the history
  • Loading branch information
myovchev authored Sep 5, 2024
1 parent 84ea4e2 commit db4f125
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Context menus can be supplied a `menuId` so that interested components can listen to their opening/closing.
* Add batch operations to pages.
* Add shortcuts to pages manager.
* Add `replaces` (boolean, `false` by default) option to the context operation definition (registered via `apos.doc.addContextOperation()`) to allow the operation to require a replace confirmation before being executed. The user confirmation results in the Editor modal being closed and the operation being executed. The operation is not executed if the user cancels the confirmation.

### Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,18 @@ export default {

},
async customAction(doc, operation) {
if (operation.replaces) {
const confirm = await apos.confirm({
heading: 'apostrophe:replaceHeadingPrompt',
description: this.$t('apostrophe:replaceDescPrompt'),
affirmativeLabel: 'apostrophe:replace',
icon: false
});
if (!confirm) {
return;
}
this.$emit('close', doc);
}
const props = {
moduleName: operation.moduleName || this.moduleName,
// For backwards compatibility
Expand Down
2 changes: 2 additions & 0 deletions modules/@apostrophecms/i18n/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@
"removeLink": "Remove Link",
"removeRichTextAnchor": "Remove Rich Text Anchor",
"replace": "Replace",
"replaceHeadingPrompt": "Replace Document?",
"replaceDescPrompt": "This operation will replace the contents of this document. Are you sure?",
"resolveErrorsBeforeSaving": "Resolve errors before saving.",
"resolveErrorsFirst": "Resolve errors first.",
"restore": "Restore",
Expand Down

0 comments on commit db4f125

Please sign in to comment.