chore: fix eslint in blocksuite (#9232)

This commit is contained in:
Saul-Mirone
2024-12-20 16:48:10 +00:00
parent bfcc53dc1f
commit 3a82da0e5b
269 changed files with 935 additions and 842 deletions

View File

@@ -140,7 +140,7 @@ export class InlineEditor<
return this._rootElement;
}
private _inlineRangeProviderOverride = false;
private readonly _inlineRangeProviderOverride: boolean;
get inlineRangeProviderOverride() {
return this._inlineRangeProviderOverride;
}
@@ -220,6 +220,7 @@ export class InlineEditor<
inlineRangeProvider,
vLineRenderer = null,
} = ops;
this._inlineRangeProviderOverride = false;
this.yText = yText;
this.isEmbed = isEmbed;
this.vLineRenderer = vLineRenderer;

View File

@@ -15,7 +15,7 @@ export class EventService<TextAttributes extends BaseTextAttributes> {
private _isComposing = false;
private _isRangeCompletelyInRoot = (range: Range) => {
private readonly _isRangeCompletelyInRoot = (range: Range) => {
if (range.commonAncestorContainer.ownerDocument !== document) return false;
const rootElement = this.editor.rootElement;
@@ -38,7 +38,7 @@ export class EventService<TextAttributes extends BaseTextAttributes> {
}
};
private _onBeforeInput = (event: InputEvent) => {
private readonly _onBeforeInput = (event: InputEvent) => {
const range = this.editor.rangeService.getNativeRange();
if (
this.editor.isReadonly ||
@@ -119,7 +119,7 @@ export class EventService<TextAttributes extends BaseTextAttributes> {
this.editor.slots.inputting.emit();
};
private _onClick = (event: MouseEvent) => {
private readonly _onClick = (event: MouseEvent) => {
// select embed element when click on it
if (event.target instanceof Node && isInEmbedElement(event.target)) {
const selection = document.getSelection();
@@ -138,7 +138,7 @@ export class EventService<TextAttributes extends BaseTextAttributes> {
}
};
private _onCompositionEnd = async (event: CompositionEvent) => {
private readonly _onCompositionEnd = async (event: CompositionEvent) => {
this._isComposing = false;
if (!this.editor.rootElement.isConnected) return;
@@ -179,7 +179,7 @@ export class EventService<TextAttributes extends BaseTextAttributes> {
this.editor.slots.inputting.emit();
};
private _onCompositionStart = () => {
private readonly _onCompositionStart = () => {
this._isComposing = true;
// embeds is not editable and it will break IME
const embeds = this.editor.rootElement.querySelectorAll(
@@ -197,7 +197,7 @@ export class EventService<TextAttributes extends BaseTextAttributes> {
}
};
private _onCompositionUpdate = () => {
private readonly _onCompositionUpdate = () => {
if (!this.editor.rootElement.isConnected) return;
const range = this.editor.rangeService.getNativeRange();
@@ -211,7 +211,7 @@ export class EventService<TextAttributes extends BaseTextAttributes> {
this.editor.slots.inputting.emit();
};
private _onKeyDown = (event: KeyboardEvent) => {
private readonly _onKeyDown = (event: KeyboardEvent) => {
const inlineRange = this.editor.getInlineRange();
if (!inlineRange) return;
@@ -270,7 +270,7 @@ export class EventService<TextAttributes extends BaseTextAttributes> {
}
};
private _onSelectionChange = () => {
private readonly _onSelectionChange = () => {
const rootElement = this.editor.rootElement;
const previousInlineRange = this.editor.getInlineRange();
if (this._isComposing) {

View File

@@ -11,7 +11,10 @@ import type { BaseTextAttributes } from '../utils/base-attributes.js';
import { deltaInsertsToChunks } from '../utils/delta-convert.js';
export class RenderService<TextAttributes extends BaseTextAttributes> {
private _onYTextChange = (_: Y.YTextEvent, transaction: Y.Transaction) => {
private readonly _onYTextChange = (
_: Y.YTextEvent,
transaction: Y.Transaction
) => {
this.editor.slots.textChange.emit();
const yText = this.editor.yText;