Welcome to the JavaScript feedback portal. We’re happy you’re here! If you have feedback on how to improve the JavaScript, we’d love to hear it!>
Thanks for joining our community and helping improve Syncfusion products!
this.container.documentEditor.keyDown = function (args: DocumentEditorKeyDownEventArgs) {
const documentEditor: DocumentEditor = args.source;
const selection: Selection = documentEditor.selection;
const nextWidget: ElementBox = (!!selection.start.paragraph.nextWidget && !!selection.start.paragraph.nextWidget.childWidgets[0] && !!selection.start.paragraph.nextWidget.childWidgets[0]['children'] && !!selection.start.paragraph.nextWidget.childWidgets[0]['children'][0]) ? selection.start.paragraph.nextWidget.childWidgets[0]['children'][0] : null;
const nextWidgetName: string = (!!nextWidget) ? nextWidget.constructor.name : null;
console.debug({
children: JSON.stringify(selection.start.currentWidget.children.reduce((acc: string[], child: ElementBox) => {
acc.push(child.constructor.name);
return acc;
}, [])),
actual: _this.ej2Document.getInline(selection.start),
isAtParagraphEnd: selection.start.isAtParagraphEnd
});
let keyCode: number = args.event.which || args.event.keyCode;
if (keyCode == 46) { //delete
const nextElementToDeleteIsRestrictedEndTag: boolean = nextWidgetName === 'EditRangeEndElementBox' && selection.start.isAtParagraphEnd;
const selectionInRestrictedEndTag: boolean = selection.start.currentWidget.children.length == 1 && selection.start.currentWidget.children[0].constructor.name === 'EditRangeEndElementBox';
if (nextElementToDeleteIsRestrictedEndTag || selectionInRestrictedEndTag) {
console.log('You cannot delete here');
args.isHandled = true;
}
}
}