2018-04-26 04:58:42 -05:00
|
|
|
// Clears the rest of the line after the caret
|
|
|
|
export default function ClearPlugin() {
|
|
|
|
return {
|
2019-07-30 08:49:32 -05:00
|
|
|
onKeyDown(event: any, change: { value?: any; deleteForward?: any }) {
|
2018-04-26 04:58:42 -05:00
|
|
|
const { value } = change;
|
|
|
|
if (!value.isCollapsed) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event.key === 'k' && event.ctrlKey) {
|
|
|
|
event.preventDefault();
|
|
|
|
const text = value.anchorText.text;
|
|
|
|
const offset = value.anchorOffset;
|
|
|
|
const length = text.length;
|
|
|
|
const forward = length - offset;
|
|
|
|
change.deleteForward(forward);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|