Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRO-6418: Add replaces configuration for editor context menus #4714

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading