mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
chore: fix eslint in blocksuite (#9232)
This commit is contained in:
@@ -45,17 +45,17 @@ export class MenuInput extends MenuFocusable {
|
||||
}
|
||||
`;
|
||||
|
||||
private onCompositionEnd = () => {
|
||||
private readonly onCompositionEnd = () => {
|
||||
this.data.onChange?.(this.inputRef.value);
|
||||
};
|
||||
|
||||
private onInput = (e: InputEvent) => {
|
||||
private readonly onInput = (e: InputEvent) => {
|
||||
e.stopPropagation();
|
||||
if (e.isComposing) return;
|
||||
this.data.onChange?.(this.inputRef.value);
|
||||
};
|
||||
|
||||
private onKeydown = (e: KeyboardEvent) => {
|
||||
private readonly onKeydown = (e: KeyboardEvent) => {
|
||||
e.stopPropagation();
|
||||
if (e.isComposing) return;
|
||||
if (e.key === 'Escape') {
|
||||
@@ -71,7 +71,7 @@ export class MenuInput extends MenuFocusable {
|
||||
}
|
||||
};
|
||||
|
||||
private stopPropagation = (e: Event) => {
|
||||
private readonly stopPropagation = (e: Event) => {
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
@@ -140,17 +140,17 @@ export class MobileMenuInput extends MenuFocusable {
|
||||
}
|
||||
`;
|
||||
|
||||
private onCompositionEnd = () => {
|
||||
private readonly onCompositionEnd = () => {
|
||||
this.data.onChange?.(this.inputRef.value);
|
||||
};
|
||||
|
||||
private onInput = (e: InputEvent) => {
|
||||
private readonly onInput = (e: InputEvent) => {
|
||||
e.stopPropagation();
|
||||
if (e.isComposing) return;
|
||||
this.data.onChange?.(this.inputRef.value);
|
||||
};
|
||||
|
||||
private stopPropagation = (e: Event) => {
|
||||
private readonly stopPropagation = (e: Event) => {
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
|
||||
@@ -83,13 +83,13 @@ export class MenuComponent
|
||||
}
|
||||
`;
|
||||
|
||||
private _clickContainer = (e: MouseEvent) => {
|
||||
private readonly _clickContainer = (e: MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
this.focusInput();
|
||||
this.menu.closeSubMenu();
|
||||
};
|
||||
|
||||
private searchRef = createRef<HTMLInputElement>();
|
||||
private readonly searchRef = createRef<HTMLInputElement>();
|
||||
|
||||
override firstUpdated() {
|
||||
const input = this.searchRef.value;
|
||||
|
||||
@@ -57,9 +57,9 @@ export function onMenuOpen(listener: MenuOpenListener) {
|
||||
export class Menu {
|
||||
private _cleanupFns: Array<() => void> = [];
|
||||
|
||||
private _currentFocused$ = signal<MenuFocusable>();
|
||||
private readonly _currentFocused$ = signal<MenuFocusable>();
|
||||
|
||||
private _subMenu$ = signal<Menu>();
|
||||
private readonly _subMenu$ = signal<Menu>();
|
||||
|
||||
closed = false;
|
||||
|
||||
|
||||
@@ -54,9 +54,9 @@ export class DatePicker extends WithDisposable(LitElement) {
|
||||
/** current active month */
|
||||
private _cursor = new Date();
|
||||
|
||||
private _maxYear = 2099;
|
||||
private readonly _maxYear = 2099;
|
||||
|
||||
private _minYear = 1970;
|
||||
private readonly _minYear = 1970;
|
||||
|
||||
get _cardStyle() {
|
||||
return {
|
||||
|
||||
@@ -68,6 +68,6 @@ export function getMonthMatrix(maybeDate: MaybeDate) {
|
||||
}
|
||||
|
||||
export function clamp(num1: number, num2: number, value: number) {
|
||||
const [min, max] = [num1, num2].sort();
|
||||
const [min, max] = [num1, num2].sort((a, b) => a - b);
|
||||
return Math.min(Math.max(value, min), max);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { PeekViewProvider } from './service.js';
|
||||
import type { PeekableClass, PeekViewService } from './type.js';
|
||||
|
||||
export class PeekableController<T extends PeekableClass> {
|
||||
private _getPeekViewService = (): PeekViewService | null => {
|
||||
private readonly _getPeekViewService = (): PeekViewService | null => {
|
||||
return this.target.std.getOptional(PeekViewProvider);
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ export class PeekableController<T extends PeekableClass> {
|
||||
}
|
||||
|
||||
constructor(
|
||||
private target: T,
|
||||
private enable?: (e: T) => boolean
|
||||
private readonly target: T,
|
||||
private readonly enable?: (e: T) => boolean
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export class AffineLink extends ShadowlessElement {
|
||||
private _identified: boolean = false;
|
||||
|
||||
// see https://github.com/toeverything/AFFiNE/issues/1540
|
||||
private _onMouseUp = () => {
|
||||
private readonly _onMouseUp = () => {
|
||||
const anchorElement = this.querySelector('a');
|
||||
if (!anchorElement || !anchorElement.isContentEditable) return;
|
||||
anchorElement.contentEditable = 'false';
|
||||
@@ -58,7 +58,7 @@ export class AffineLink extends ShadowlessElement {
|
||||
refNodeSlotsProvider.docLinkClicked.emit(referenceInfo);
|
||||
};
|
||||
|
||||
private _whenHover = new HoverController(
|
||||
private readonly _whenHover = new HoverController(
|
||||
this,
|
||||
({ abortController }) => {
|
||||
if (this.block?.doc.readonly) {
|
||||
|
||||
@@ -49,7 +49,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
|
||||
|
||||
private _bodyOverflowStyle = '';
|
||||
|
||||
private _createTemplate = () => {
|
||||
private readonly _createTemplate = () => {
|
||||
this.updateComplete
|
||||
.then(() => {
|
||||
this.linkInput?.focus();
|
||||
@@ -74,14 +74,14 @@ export class LinkPopup extends WithDisposable(LitElement) {
|
||||
`;
|
||||
};
|
||||
|
||||
private _delete = () => {
|
||||
private readonly _delete = () => {
|
||||
if (this.inlineEditor.isValidInlineRange(this.targetInlineRange)) {
|
||||
this.inlineEditor.deleteText(this.targetInlineRange);
|
||||
}
|
||||
this.abortController.abort();
|
||||
};
|
||||
|
||||
private _edit = () => {
|
||||
private readonly _edit = () => {
|
||||
if (!this.host) return;
|
||||
|
||||
this.type = 'edit';
|
||||
@@ -89,7 +89,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
|
||||
track(this.host.std, 'OpenedAliasPopup', { control: 'edit' });
|
||||
};
|
||||
|
||||
private _editTemplate = () => {
|
||||
private readonly _editTemplate = () => {
|
||||
this.updateComplete
|
||||
.then(() => {
|
||||
if (
|
||||
@@ -139,7 +139,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
|
||||
|
||||
private _embedOptions: EmbedOptions | null = null;
|
||||
|
||||
private _openLink = () => {
|
||||
private readonly _openLink = () => {
|
||||
if (this.openLink) {
|
||||
this.openLink();
|
||||
return;
|
||||
@@ -154,7 +154,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
|
||||
this.abortController.abort();
|
||||
};
|
||||
|
||||
private _removeLink = () => {
|
||||
private readonly _removeLink = () => {
|
||||
if (this.inlineEditor.isValidInlineRange(this.targetInlineRange)) {
|
||||
this.inlineEditor.formatText(this.targetInlineRange, {
|
||||
link: null,
|
||||
@@ -163,7 +163,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
|
||||
this.abortController.abort();
|
||||
};
|
||||
|
||||
private _toggleViewSelector = (e: Event) => {
|
||||
private readonly _toggleViewSelector = (e: Event) => {
|
||||
if (!this.host) return;
|
||||
|
||||
const opened = (e as CustomEvent<boolean>).detail;
|
||||
@@ -172,7 +172,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
|
||||
track(this.host.std, 'OpenedViewSelector', { control: 'switch view' });
|
||||
};
|
||||
|
||||
private _trackViewSelected = (type: string) => {
|
||||
private readonly _trackViewSelected = (type: string) => {
|
||||
if (!this.host) return;
|
||||
|
||||
track(this.host.std, 'SelectedView', {
|
||||
@@ -181,7 +181,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
|
||||
});
|
||||
};
|
||||
|
||||
private _viewTemplate = () => {
|
||||
private readonly _viewTemplate = () => {
|
||||
if (!this.currentLink) return;
|
||||
|
||||
this._embedOptions =
|
||||
|
||||
@@ -89,7 +89,7 @@ export class ReferenceAliasPopup extends SignalWatcher(
|
||||
}
|
||||
`;
|
||||
|
||||
private _onSave = () => {
|
||||
private readonly _onSave = () => {
|
||||
const title = this.title$.value.trim();
|
||||
if (!title) {
|
||||
this.remove();
|
||||
@@ -103,7 +103,7 @@ export class ReferenceAliasPopup extends SignalWatcher(
|
||||
this.remove();
|
||||
};
|
||||
|
||||
private _updateTitle = (e: InputEvent) => {
|
||||
private readonly _updateTitle = (e: InputEvent) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
const value = target.value;
|
||||
this.title$.value = value;
|
||||
|
||||
@@ -68,7 +68,7 @@ export class AffineReference extends WithDisposable(ShadowlessElement) {
|
||||
}
|
||||
`;
|
||||
|
||||
private _updateRefMeta = (doc: Doc) => {
|
||||
private readonly _updateRefMeta = (doc: Doc) => {
|
||||
const refAttribute = this.delta.attributes?.reference;
|
||||
if (!refAttribute) {
|
||||
return;
|
||||
@@ -88,7 +88,7 @@ export class AffineReference extends WithDisposable(ShadowlessElement) {
|
||||
@state()
|
||||
accessor refMeta: DocMeta | undefined = undefined;
|
||||
|
||||
private _whenHover: HoverController = new HoverController(
|
||||
private readonly _whenHover: HoverController = new HoverController(
|
||||
this,
|
||||
({ abortController }) => {
|
||||
if (
|
||||
|
||||
@@ -50,7 +50,7 @@ import { styles } from './styles.js';
|
||||
export class ReferencePopup extends WithDisposable(LitElement) {
|
||||
static override styles = styles;
|
||||
|
||||
private _copyLink = () => {
|
||||
private readonly _copyLink = () => {
|
||||
const url = this.std
|
||||
.getOptional(GenerateDocUrlProvider)
|
||||
?.generateDocUrl(this.referenceInfo.pageId, this.referenceInfo.params);
|
||||
@@ -65,13 +65,13 @@ export class ReferencePopup extends WithDisposable(LitElement) {
|
||||
track(this.std, 'CopiedLink', { control: 'copy link' });
|
||||
};
|
||||
|
||||
private _openDoc = () => {
|
||||
private readonly _openDoc = () => {
|
||||
this.std
|
||||
.getOptional(RefNodeSlotsProvider)
|
||||
?.docLinkClicked.emit(this.referenceInfo);
|
||||
};
|
||||
|
||||
private _openEditPopup = (e: MouseEvent) => {
|
||||
private readonly _openEditPopup = (e: MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
|
||||
if (document.body.querySelector('reference-alias-popup')) {
|
||||
@@ -102,14 +102,14 @@ export class ReferencePopup extends WithDisposable(LitElement) {
|
||||
track(std, 'OpenedAliasPopup', { control: 'edit' });
|
||||
};
|
||||
|
||||
private _toggleViewSelector = (e: Event) => {
|
||||
private readonly _toggleViewSelector = (e: Event) => {
|
||||
const opened = (e as CustomEvent<boolean>).detail;
|
||||
if (!opened) return;
|
||||
|
||||
track(this.std, 'OpenedViewSelector', { control: 'switch view' });
|
||||
};
|
||||
|
||||
private _trackViewSelected = (type: string) => {
|
||||
private readonly _trackViewSelected = (type: string) => {
|
||||
track(this.std, 'SelectedView', {
|
||||
control: 'select view',
|
||||
type: `${type} view`,
|
||||
|
||||
@@ -60,7 +60,7 @@ export class RichText extends WithDisposable(ShadowlessElement) {
|
||||
|
||||
private _inlineEditor: AffineInlineEditor | null = null;
|
||||
|
||||
private _onCopy = (e: ClipboardEvent) => {
|
||||
private readonly _onCopy = (e: ClipboardEvent) => {
|
||||
const inlineEditor = this.inlineEditor;
|
||||
if (!inlineEditor) return;
|
||||
|
||||
@@ -77,7 +77,7 @@ export class RichText extends WithDisposable(ShadowlessElement) {
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
private _onCut = (e: ClipboardEvent) => {
|
||||
private readonly _onCut = (e: ClipboardEvent) => {
|
||||
const inlineEditor = this.inlineEditor;
|
||||
if (!inlineEditor) return;
|
||||
|
||||
@@ -99,7 +99,7 @@ export class RichText extends WithDisposable(ShadowlessElement) {
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
private _onPaste = (e: ClipboardEvent) => {
|
||||
private readonly _onPaste = (e: ClipboardEvent) => {
|
||||
const inlineEditor = this.inlineEditor;
|
||||
if (!inlineEditor) return;
|
||||
|
||||
@@ -121,14 +121,18 @@ export class RichText extends WithDisposable(ShadowlessElement) {
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
private _onStackItemAdded = (event: { stackItem: RichTextStackItem }) => {
|
||||
private readonly _onStackItemAdded = (event: {
|
||||
stackItem: RichTextStackItem;
|
||||
}) => {
|
||||
const inlineRange = this.inlineEditor?.getInlineRange();
|
||||
if (inlineRange) {
|
||||
event.stackItem.meta.set('richtext-v-range', inlineRange);
|
||||
}
|
||||
};
|
||||
|
||||
private _onStackItemPopped = (event: { stackItem: RichTextStackItem }) => {
|
||||
private readonly _onStackItemPopped = (event: {
|
||||
stackItem: RichTextStackItem;
|
||||
}) => {
|
||||
const inlineRange = event.stackItem.meta.get('richtext-v-range');
|
||||
if (inlineRange && this.inlineEditor?.isValidInlineRange(inlineRange)) {
|
||||
this.inlineEditor?.setInlineRange(inlineRange);
|
||||
|
||||
@@ -125,7 +125,7 @@ export class Tooltip extends LitElement {
|
||||
|
||||
private _hoverController!: HoverController;
|
||||
|
||||
private _setUpHoverController = () => {
|
||||
private readonly _setUpHoverController = () => {
|
||||
this._hoverController = new HoverController(
|
||||
this,
|
||||
() => {
|
||||
|
||||
@@ -13,13 +13,13 @@ export type VirtualKeyboardControllerConfig = {
|
||||
};
|
||||
|
||||
export class VirtualKeyboardController implements ReactiveController {
|
||||
private _disposables = new DisposableGroup();
|
||||
private readonly _disposables = new DisposableGroup();
|
||||
|
||||
private readonly _keyboardHeight$ = signal(0);
|
||||
|
||||
private readonly _keyboardOpened$ = signal(false);
|
||||
|
||||
private _storeInitialInputElementAttributes = () => {
|
||||
private readonly _storeInitialInputElementAttributes = () => {
|
||||
const { inputElement } = this.config;
|
||||
if (navigator.virtualKeyboard) {
|
||||
const { overlaysContent } = navigator.virtualKeyboard;
|
||||
|
||||
Reference in New Issue
Block a user