I want to trigger an event whenever editor removes a block (using "Remove" on the Content Area) and when a user click on "Move to Trash" on a block in the asset pane.
I find DataFactory.Instance.MovedContent event which is firing on every click on "Move to Trash"
But while clicking on Remove on the Content Area its not firing.
Update:-
I am doing these steps to achieve clicking on remove
Register event handlers for saving event and saved event for the page.
In saving event, get the page that is being saved, get the block ids from the content area by ContentArea.Items. Use the contentlink.ID property.
Store those ids in a List, store it in memory somewhere, preferably in httpcontext.items collection since you only need it for the request but a short lived cache also works. Now you know the ids of all blocks before the change by editor.
In saved event, get a new list of ids like above. Now you know the ids after editor change. Some block ids will be missing. Handle those by whatever you want to do...
void Instance_SavingContent(object sender, ContentEventArgs e) { if (e.Content is ListPdfDocumentBlock) { var properties = e.Content.GetType().GetProperties().Where(i => i.PropertyType == typeof(ContentArea)); if (properties != null) { List<int> ids = new List<int>(); foreach (var property in properties) { ContentArea contentArea = property.GetValue(e.Content) as ContentArea; if (contentArea != null) { foreach (ContentAreaItem contentAreaItem in contentArea.Items) { IContent itemContent = contentAreaItem.GetContent(); ids.Add(itemContent.ContentLink.ID); } } } HttpContext.Current.Items.Add("pdfId", ids); } } }
But the problem with this code is,its always returning updated ids. then how i will compare from old to new to identify which block is removed.