Skip to content

Commit

Permalink
fix(core): rename delete fragment event #WIK-4877
Browse files Browse the repository at this point in the history
  • Loading branch information
huanhuanwa committed Oct 13, 2021
1 parent f830c92 commit 1b3eebc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
6 changes: 1 addition & 5 deletions packages/src/components/editable/editable.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,11 +725,7 @@ export class SlateEditableComponent implements OnInit, OnChanges, OnDestroy, Aft
const { selection } = this.editor;

if (selection) {
if (Range.isExpanded(selection)) {
Editor.deleteFragment(this.editor);
} else {
AngularEditor.deleteFragmentdata(this.editor);
}
AngularEditor.deleteCutData(this.editor);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/src/plugins/angular-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, getCardTarge
export interface AngularEditor extends BaseEditor {
insertData: (data: DataTransfer) => void;
setFragmentData: (data: DataTransfer) => void;
deleteFragmentData: ()=> void;
deleteCutData: ()=> void;
onKeydown: (event: KeyboardEvent) => void;
onClick: (event: MouseEvent) => void;
injector: Injector;
Expand Down Expand Up @@ -283,8 +283,8 @@ export const AngularEditor = {
* Delete currently selected fragment when collapsed is true
*/

deleteFragmentdata(editor: AngularEditor): void{
editor.deleteFragmentData();
deleteCutData(editor: AngularEditor): void{
editor.deleteCutData();
},

/**
Expand Down
13 changes: 8 additions & 5 deletions packages/src/plugins/with-angular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,18 @@ export const withAngular = <T extends Editor>(editor: T, clipboardFormatKey = 'x
document.body.removeChild(div);
};

e.deleteFragmentData = () => {
e.deleteCutData = () => {
const { selection } = editor;
if (selection) {
const node = Node.parent(editor, selection.anchor.path);
if (Editor.isVoid(editor, node)) {
Transforms.delete(editor);
if (Range.isExpanded(selection)) {
Editor.deleteFragment(editor);
} else {
const node = Node.parent(editor, selection.anchor.path);
if (Editor.isVoid(editor, node)) {
Transforms.delete(editor);
}
}
}

};

e.insertData = (data: DataTransfer) => {
Expand Down

0 comments on commit 1b3eebc

Please sign in to comment.