mirror of
https://github.com/codex-team/editor.js
synced 2026-03-15 07:05:48 +01:00
Make confirmation props optional
This commit is contained in:
parent
da1dd6f30e
commit
54f07f7a4f
3 changed files with 17 additions and 7 deletions
|
|
@ -51,9 +51,7 @@ export default class DeleteTune implements BlockTune {
|
|||
label: this.api.i18n.t('Delete'),
|
||||
name: 'delete',
|
||||
confirmation: {
|
||||
icon: $.svg('cross', 14, 14).outerHTML,
|
||||
label: 'Click to delete',
|
||||
name: 'delete',
|
||||
label: this.api.i18n.t('Click to delete'),
|
||||
onActivate: (item, e): void => this.handleClick(e),
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@
|
|||
},
|
||||
"blockTunes": {
|
||||
"delete": {
|
||||
"Delete": ""
|
||||
"Delete": "",
|
||||
"Click to delete": ""
|
||||
},
|
||||
"moveUp": {
|
||||
"Move up": ""
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ interface PopoverItemWithConfirmation extends PopoverItemBase {
|
|||
* Item parameters that should be applied on item activation.
|
||||
* May be used to ask user for confirmation before executing popover item activation handler.
|
||||
*/
|
||||
confirmation: PopoverItem;
|
||||
confirmation: Partial<PopoverItem>;
|
||||
|
||||
onActivate?: never;
|
||||
}
|
||||
|
|
@ -505,8 +505,19 @@ export default class Popover extends EventsDispatcher<PopoverEvent> {
|
|||
if (this.itemRequiringConfirmation === null) {
|
||||
this.itemRequiringConfirmation = clickedItem;
|
||||
}
|
||||
this.items[itemIndex] = clickedItem.confirmation;
|
||||
const confirmationStateItemEl = this.createItem(clickedItem.confirmation as PopoverItem);
|
||||
const newItemData = {
|
||||
...clickedItem,
|
||||
...clickedItem.confirmation,
|
||||
} as PopoverItem;
|
||||
|
||||
/** Prevent confirmation loop */
|
||||
if (newItemData.confirmation === clickedItem.confirmation) {
|
||||
delete newItemData.confirmation;
|
||||
}
|
||||
|
||||
this.items[itemIndex] = newItemData;
|
||||
|
||||
const confirmationStateItemEl = this.createItem(newItemData as PopoverItem);
|
||||
|
||||
confirmationStateItemEl.classList.add(Popover.CSS.itemConfirmation);
|
||||
itemEl.parentElement.replaceChild(confirmationStateItemEl, itemEl);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue