Skip to content
This repository has been archived by the owner on Dec 27, 2020. It is now read-only.

Add delete text action #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/common/array.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
export function insert<T>(arr: T[], index: number, slice: T[]): T[] {
return [...arr.slice(0, index), ...slice, ...arr.slice(index)];
}

export function remove<T>(arr: T[], idx: number, count: number = 1): T[] {
return [
...arr.slice(0, idx),
...arr.slice(idx + count)
];
}
Comment on lines 1 to +10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are going to use those helpers over & over again. Let's include unit tests for them so that we are confident they are working correctly when dealing with complexities for the actions.

2 changes: 1 addition & 1 deletion src/components/Fluent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { SelectionService } from '../services/selection.service';
export class Fluent extends Component<any, any> {
private editorStateService = new IEditorStateService();
private selectionService = new SelectionService();

public render() {
return (
<div className={styles.Fluent}>
Expand Down
Loading