Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nikmel2803 committed Aug 29, 2024
1 parent 72c12d1 commit 4056e70
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions packages/model/src/entities/EditorDocument/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from '../../EventBus/events/index.js';
import type { Constructor } from '../../utils/types.js';
import { BaseDocumentEvent } from '../../EventBus/events/BaseEvent.js';
import { Index } from '../Index';
import type { Index } from '../Index';

/**
* EditorDocument class represents the top-level container for a tree-like structure of BlockNodes in an editor document.
Expand Down Expand Up @@ -324,43 +324,43 @@ export class EditorDocument extends EventBus {
return this.#children[blockIndex].getFragments(dataKey, start, end, tool);
}

/**
/**
* Inserts data to the specified index
*
* @param index - index to insert data
* @param data - data to insert
*/
public insertData(index: Index, data: unknown): void {
switch (true) {
case index.isTextIndex:
this.insertText(index.blockIndex!, index.dataKey!, data as string, index.textRange![0]);
break;

case index.isBlockIndex:
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
this.addBlock(data as Parameters<EditorDocument['addBlock']>[0], index.blockIndex);
default:
throw new Error('Unsupported index');
}
public insertData(index: Index, data: unknown): void {

Check warning on line 333 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
switch (true) {
case index.isTextIndex:
this.insertText(index.blockIndex!, index.dataKey!, data as string, index.textRange![0]);

Check warning on line 336 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
break;

Check warning on line 337 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 337 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

case index.isBlockIndex:
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
this.addBlock(data as Parameters<EditorDocument['addBlock']>[0], index.blockIndex);

Check warning on line 341 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 341 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
default:
throw new Error('Unsupported index');

Check warning on line 343 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 343 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
}

Check warning on line 344 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

/**
* Removes data from the specified index
*
* @param index - index to remove data from
*/
public removeData(index: Index): void {
switch (true) {
case (index.blockIndex !== undefined && index.dataKey !== undefined && index.textRange !== undefined):
this.removeText(index.blockIndex, index.dataKey, index.textRange[0], index.textRange[1]);
break;

case (index.blockIndex !== undefined):
this.removeBlock(index.blockIndex);
default:
throw new Error('Unsupported index');
}
/**
* Removes data from the specified index
*
* @param index - index to remove data from
*/
public removeData(index: Index): void {

Check warning on line 352 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
switch (true) {
case (index.blockIndex !== undefined && index.dataKey !== undefined && index.textRange !== undefined):

Check warning on line 354 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 354 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 354 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
this.removeText(index.blockIndex, index.dataKey, index.textRange[0], index.textRange[1]);

Check warning on line 355 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
break;

Check warning on line 356 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 356 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

case (index.blockIndex !== undefined):
this.removeBlock(index.blockIndex);

Check warning on line 359 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 359 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
default:
throw new Error('Unsupported index');

Check warning on line 361 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 361 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
}

Check warning on line 362 in packages/model/src/entities/EditorDocument/index.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

/**
* Listens to BlockNode events and bubbles them to the EditorDocument
Expand Down

0 comments on commit 4056e70

Please sign in to comment.