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
No known key found for this signature in database
GPG Key ID: 0D941B4A9125B742
269 changed files with 935 additions and 842 deletions

View File

@ -68,7 +68,7 @@ export class EmbedHtmlFullscreenToolbar extends LitElement {
}
`;
private _popSettings = () => {
private readonly _popSettings = () => {
this._popperVisible = true;
popMenu(popupTargetFromElement(this._fullScreenToolbarContainer), {
options: {

View File

@ -48,7 +48,7 @@ import { getEmbedLinkedDocIcons } from './utils.js';
export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinkedDocModel> {
static override styles = styles;
private _load = async () => {
private readonly _load = async () => {
const {
loading = true,
isError = false,
@ -103,7 +103,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
}
};
private _selectBlock = () => {
private readonly _selectBlock = () => {
const selectionManager = this.host.selection;
const blockSelection = selectionManager.create('block', {
blockId: this.blockId,
@ -111,7 +111,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
selectionManager.setGroup('note', [blockSelection]);
};
private _setDocUpdatedAt = () => {
private readonly _setDocUpdatedAt = () => {
const meta = this.doc.collection.meta.getDocMeta(this.model.pageId);
if (meta) {
const date = meta.updatedDate || meta.createDate;

View File

@ -55,7 +55,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
// Caches total bounds, includes all blocks and elements.
private _cachedBounds: Bound | null = null;
private _initEdgelessFitEffect = () => {
private readonly _initEdgelessFitEffect = () => {
const fitToContent = () => {
if (this.isPageMode) return;
@ -99,7 +99,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
.catch(() => {});
};
private _pageFilter: Query = {
private readonly _pageFilter: Query = {
mode: 'loose',
match: [
{

View File

@ -36,7 +36,7 @@ export class ListBlockComponent extends CaptionedBlockComponent<
private _inlineRangeProvider: InlineRangeProvider | null = null;
private _onClickIcon = (e: MouseEvent) => {
private readonly _onClickIcon = (e: MouseEvent) => {
e.stopPropagation();
if (this.model.type === 'toggle') {

View File

@ -34,13 +34,13 @@ export class ParagraphBlockComponent extends CaptionedBlockComponent<
> {
static override styles = paragraphBlockStyles;
private _composing = signal(false);
private readonly _composing = signal(false);
private _displayPlaceholder = signal(false);
private readonly _displayPlaceholder = signal(false);
private _inlineRangeProvider: InlineRangeProvider | null = null;
private _isInDatabase = () => {
private readonly _isInDatabase = () => {
let parent = this.parentElement;
while (parent && parent !== document.body) {
if (parent.tagName.toLowerCase() === 'affine-database') {

View File

@ -1149,7 +1149,7 @@ export class PathGenerator {
export class ConnectorPathGenerator extends PathGenerator {
constructor(
private options: {
private readonly options: {
getElementById: (id: string) => GfxModel | null;
}
) {

View File

@ -42,9 +42,9 @@ type RendererOptions = {
export class CanvasRenderer {
private _container!: HTMLElement;
private _disposables = new DisposableGroup();
private readonly _disposables = new DisposableGroup();
private _overlays = new Set<Overlay>();
private readonly _overlays = new Set<Overlay>();
private _refreshRafId: number | null = null;

View File

@ -100,7 +100,7 @@ export class SurfaceBlockComponent extends BlockComponent<
private _cachedViewport = new Bound();
private _initThemeObserver = () => {
private readonly _initThemeObserver = () => {
const theme = this.std.get(ThemeProvider);
this.disposables.add(theme.theme$.subscribe(() => this.requestUpdate()));
};

View File

@ -34,7 +34,7 @@ export const SurfaceBlockSchema = defineBlockSchema({
export type SurfaceMiddleware = (surface: SurfaceBlockModel) => () => void;
export class SurfaceBlockModel extends BaseSurfaceModel {
private _disposables: DisposableGroup = new DisposableGroup();
private readonly _disposables: DisposableGroup = new DisposableGroup();
override _init() {
this._extendElement(elementsCtorMap);

View File

@ -33,24 +33,27 @@ function pointAlmostEqual(a: IVec3, b: IVec3): boolean {
}
export class AStarRunner {
private _cameFrom = new Map<IVec3, { from: IVec3[]; indexs: number[] }>();
private readonly _cameFrom = new Map<
IVec3,
{ from: IVec3[]; indexs: number[] }
>();
private _complete = false;
private _costSoFar = new Map<IVec3, number[]>();
private readonly _costSoFar = new Map<IVec3, number[]>();
private _current: IVec3 | null = null;
private _diagonalCount = new Map<IVec3, number[]>();
private readonly _diagonalCount = new Map<IVec3, number[]>();
private _frontier!: PriorityQueue<
IVec3,
[diagonalCount: number, pointPriority: number, distCost: number]
>;
private _graph: Graph<IVec3>;
private readonly _graph: Graph<IVec3>;
private _pointPriority = new Map<IVec3, number[]>();
private readonly _pointPriority = new Map<IVec3, number[]>();
get path() {
const result: IVec3[] = [];
@ -72,9 +75,9 @@ export class AStarRunner {
constructor(
points: IVec3[],
private _sp: IVec3,
private _ep: IVec3,
private _originalSp: IVec3,
private readonly _sp: IVec3,
private readonly _ep: IVec3,
private readonly _originalSp: IVec3,
private _originalEp: IVec3,
blocks: Bound[] = [],
expandBlocks: Bound[] = []

View File

@ -27,15 +27,15 @@ function arrayAlmostEqual(point: IVec | IVec3, point2: IVec | IVec3) {
}
export class Graph<V extends IVec | IVec3 = IVec> {
private _xMap = new Map<number, V[]>();
private readonly _xMap = new Map<number, V[]>();
private _yMap = new Map<number, V[]>();
private readonly _yMap = new Map<number, V[]>();
constructor(
private points: V[],
private blocks: Bound[] = [],
private expandedBlocks: Bound[] = [],
private excludedPoints: V[] = []
private readonly points: V[],
private readonly blocks: Bound[] = [],
private readonly expandedBlocks: Bound[] = [],
private readonly excludedPoints: V[] = []
) {
const xMap = this._xMap;
const yMap = this._yMap;

View File

@ -6,7 +6,7 @@ type PriorityQueueNode<T, K> = {
export class PriorityQueue<T, K> {
heap: PriorityQueueNode<T, K>[] = [];
constructor(private _compare: (a: K, b: K) => number) {}
constructor(private readonly _compare: (a: K, b: K) => number) {}
bubbleDown(): void {
let index = 0;

View File

@ -9,11 +9,11 @@ import { RoughGenerator } from './generator.js';
import type { Point } from './geometry.js';
export class RoughCanvas {
private canvas: HTMLCanvasElement;
private readonly canvas: HTMLCanvasElement;
private ctx: CanvasRenderingContext2D;
private readonly ctx: CanvasRenderingContext2D;
private gen: RoughGenerator;
private readonly gen: RoughGenerator;
get generator(): RoughGenerator {
return this.gen;

View File

@ -5,7 +5,7 @@ import type { PatternFiller, RenderHelper } from './filler-interface.js';
import { polygonHachureLines } from './scan-line-hachure.js';
export class DashedFiller implements PatternFiller {
private helper: RenderHelper;
private readonly helper: RenderHelper;
constructor(helper: RenderHelper) {
this.helper = helper;

View File

@ -5,7 +5,7 @@ import type { PatternFiller, RenderHelper } from './filler-interface.js';
import { polygonHachureLines } from './scan-line-hachure.js';
export class DotFiller implements PatternFiller {
private helper: RenderHelper;
private readonly helper: RenderHelper;
constructor(helper: RenderHelper) {
this.helper = helper;

View File

@ -4,7 +4,7 @@ import type { PatternFiller, RenderHelper } from './filler-interface.js';
import { polygonHachureLines } from './scan-line-hachure.js';
export class HachureFiller implements PatternFiller {
private helper: RenderHelper;
private readonly helper: RenderHelper;
constructor(helper: RenderHelper) {
this.helper = helper;

View File

@ -5,7 +5,7 @@ import type { PatternFiller, RenderHelper } from './filler-interface.js';
import { polygonHachureLines } from './scan-line-hachure.js';
export class ZigZagLineFiller implements PatternFiller {
private helper: RenderHelper;
private readonly helper: RenderHelper;
constructor(helper: RenderHelper) {
this.helper = helper;

View File

@ -28,7 +28,7 @@ import {
const NOS = 'none';
export class RoughGenerator {
private config: Config;
private readonly config: Config;
defaultOptions: ResolvedOptions = {
maxRandomnessOffset: 2,

View File

@ -10,9 +10,9 @@ import { RoughGenerator } from './generator.js';
import type { Point } from './geometry.js';
export class RoughSVG {
private gen: RoughGenerator;
private readonly gen: RoughGenerator;
private svg: SVGSVGElement;
private readonly svg: SVGSVGElement;
get generator(): RoughGenerator {
return this.gen;

View File

@ -15,7 +15,7 @@ import { handleLayout } from '../utils/mindmap/utils.js';
export class MindMapView extends GfxElementModelView<MindmapElementModel> {
static override type = 'mindmap';
private _collapseButtons = new Map<string, LocalShapeElementModel>();
private readonly _collapseButtons = new Map<string, LocalShapeElementModel>();
private _hoveredState = new Map<
string,

View File

@ -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();
};

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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);
}

View File

@ -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
) {}
}

View File

@ -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) {

View File

@ -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 =

View File

@ -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;

View File

@ -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 (

View File

@ -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`,

View File

@ -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);

View File

@ -125,7 +125,7 @@ export class Tooltip extends LitElement {
private _hoverController!: HoverController;
private _setUpHoverController = () => {
private readonly _setUpHoverController = () => {
this._hoverController = new HoverController(
this,
() => {

View File

@ -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;

View File

@ -150,7 +150,7 @@ class TagManager {
return this.ops.value;
}
constructor(private ops: TagManagerOptions) {}
constructor(private readonly ops: TagManagerOptions) {}
deleteTag(id: string) {
this.ops.onChange(this.value.value.filter(item => item !== id));
@ -180,7 +180,7 @@ export class MultiTagSelect extends SignalWatcher(
) {
static override styles = styles;
private _clickItemOption = (e: MouseEvent, id: string) => {
private readonly _clickItemOption = (e: MouseEvent, id: string) => {
e.stopPropagation();
const option = this.options.value.find(v => v.id === id);
if (!option) {
@ -235,11 +235,11 @@ export class MultiTagSelect extends SignalWatcher(
});
};
private _onInput = (event: KeyboardEvent) => {
private readonly _onInput = (event: KeyboardEvent) => {
this.tagManager.text.value = (event.target as HTMLInputElement).value;
};
private _onInputKeydown = (event: KeyboardEvent) => {
private readonly _onInputKeydown = (event: KeyboardEvent) => {
event.stopPropagation();
const inputValue = this.text.value.trim();
if (event.key === 'Backspace' && inputValue === '') {
@ -257,9 +257,9 @@ export class MultiTagSelect extends SignalWatcher(
}
};
private tagManager = new TagManager(this);
private readonly tagManager = new TagManager(this);
private selectedTag$ = computed(() => {
private readonly selectedTag$ = computed(() => {
return this.tagManager.filteredOptions$.value[this.selectedIndex];
});

View File

@ -63,14 +63,14 @@ export class DataViewRenderer extends SignalWatcher(
}
`;
private _view = createRef<{
private readonly _view = createRef<{
expose: DataViewInstance;
}>();
@property({ attribute: false })
accessor config!: DataViewRendererConfig;
private currentViewId$ = computed(() => {
private readonly currentViewId$ = computed(() => {
return this.config.dataSource.viewManager.currentViewId$.value;
});
@ -218,7 +218,7 @@ declare global {
}
export class DataView {
private _ref = createRef<DataViewRenderer>();
private readonly _ref = createRef<DataViewRenderer>();
get expose() {
return this._ref.value?.view?.expose;

View File

@ -109,7 +109,7 @@ export class RecordField extends SignalWatcher(
}
`;
private _cell = createRef<DataViewCellLifeCycle>();
private readonly _cell = createRef<DataViewCellLifeCycle>();
_click = (e: MouseEvent) => {
e.stopPropagation();

View File

@ -49,7 +49,7 @@ export class DetailSelection {
}
}
constructor(private viewEle: RecordDetail) {}
constructor(private readonly viewEle: RecordDetail) {}
blur(selection: DetailViewSelection) {
const container = this.getFocusCellContainer(selection);

View File

@ -21,7 +21,7 @@ export class NumberGroupView extends BaseGroup<NonNullable<unknown>, number> {
}
`;
private _click = () => {
private readonly _click = () => {
if (this.readonly) {
return;
}

View File

@ -42,7 +42,7 @@ export class SelectGroupView extends BaseGroup<
}
`;
private _click = (e: MouseEvent) => {
private readonly _click = (e: MouseEvent) => {
if (this.readonly) {
return;
}

View File

@ -21,7 +21,7 @@ export class StringGroupView extends BaseGroup<NonNullable<unknown>, string> {
}
`;
private _click = () => {
private readonly _click = () => {
if (this.readonly) {
return;
}

View File

@ -103,7 +103,7 @@ export class GroupTrait {
return groupMap;
});
private _groupsDataList$ = computed(() => {
private readonly _groupsDataList$ = computed(() => {
const groupMap = this.groupDataMap$.value;
if (!groupMap) {
return;
@ -143,9 +143,9 @@ export class GroupTrait {
}
constructor(
private groupBy$: ReadonlySignal<GroupBy | undefined>,
private readonly groupBy$: ReadonlySignal<GroupBy | undefined>,
public view: SingleView,
private ops: {
private readonly ops: {
groupBySet: (groupBy: GroupBy | undefined) => void;
sortGroup: (keys: string[]) => string[];
sortRow: (groupKey: string, rowIds: string[]) => string[];

View File

@ -50,9 +50,9 @@ export class DataType<
> implements TypeDefinition
{
constructor(
private name: Name,
private readonly name: Name,
_dataSchema: DataSchema,
private valueSchema: ValueSchema
private readonly valueSchema: ValueSchema
) {}
instance(literal?: Zod.TypeOf<DataSchema>) {

View File

@ -14,8 +14,8 @@ export class MatcherCreator<Data, Type extends TypeInstance = TypeInstance> {
export class Matcher<Data, Type extends TypeInstance = TypeInstance> {
constructor(
private list: MatcherData<Data, Type>[],
private _match: (type: Type, target: TypeInstance) => boolean = (
private readonly list: MatcherData<Data, Type>[],
private readonly _match: (type: Type, target: TypeInstance) => boolean = (
type,
target
) => typeSystem.unify(target, type)

View File

@ -32,7 +32,7 @@ const getMap2 = <T>(
};
export class TypeSystem {
private _unify: Unify = (
private readonly _unify: Unify = (
ctx: TypeVarContext,
left: TypeInstance | undefined,
right: TypeInstance | undefined

View File

@ -34,7 +34,7 @@ export class SortManager {
constructor(
readonly sort$: ReadonlySignal<Sort | undefined>,
readonly view: SingleView,
private ops: {
private readonly ops: {
setSortList: (sortList: Sort) => void;
}
) {}

View File

@ -56,20 +56,20 @@ const defaultCoordinates: Coordinates = {
};
export class DndContext {
private dragMove = (coordinates: Coordinates) => {
private readonly dragMove = (coordinates: Coordinates) => {
this.activationCoordinates$.value = coordinates;
this.autoScroll();
};
private droppableNodes$ = signal<DroppableNodes>(new Map());
private readonly droppableNodes$ = signal<DroppableNodes>(new Map());
private initialCoordinates$ = signal<Coordinates>();
private readonly initialCoordinates$ = signal<Coordinates>();
private initScrollOffset$ = signal(defaultCoordinates);
private readonly initScrollOffset$ = signal(defaultCoordinates);
private session$ = signal<DndSession>();
private readonly session$ = signal<DndSession>();
private startSession = (
private readonly startSession = (
id: UniqueIdentifier,
activeNode: HTMLElement,
sessionCreator: DndSessionCreator
@ -96,7 +96,7 @@ export class DndContext {
activationCoordinates$ = signal<Coordinates>();
private translate$ = computed(() => {
private readonly translate$ = computed(() => {
const init = this.initialCoordinates$.value;
const current = this.activationCoordinates$.value;
if (!init || !current) {

View File

@ -192,8 +192,8 @@ export class MouseSession implements DndSession {
constructor(
event: Event,
private sessionProps: DndSessionProps,
private props: MouseSensorProps
private readonly sessionProps: DndSessionProps,
private readonly props: MouseSensorProps
) {
this.initialCoordinates = getEventCoordinates(event) ?? defaultCoordinates;
this.attach();

View File

@ -1,5 +1,5 @@
export class Listeners<T extends EventTarget> {
private listeners: [
private readonly listeners: [
string,
EventListenerOrEventListenerObject | null,
AddEventListenerOptions | boolean | undefined,

View File

@ -139,9 +139,9 @@ export abstract class SingleViewBase<
ViewData extends DataViewDataType = DataViewDataType,
> implements SingleView
{
private searchString = signal('');
private readonly searchString = signal('');
private traitMap = new Map<symbol, unknown>();
private readonly traitMap = new Map<symbol, unknown>();
data$ = computed(() => {
return this.dataSource.viewDataGet(this.id) as ViewData | undefined;

View File

@ -66,7 +66,7 @@ export class DateCellEditing extends BaseCellRenderer<number> {
private _prevPortalAbortController: AbortController | null = null;
private openDatePicker = () => {
private readonly openDatePicker = () => {
if (
this._prevPortalAbortController &&
!this._prevPortalAbortController.signal.aborted
@ -168,7 +168,7 @@ height: 46px;
}
};
private updateValue = () => {
private readonly updateValue = () => {
const tempValue = this.tempValue$.value;
const currentValue = this.value;

View File

@ -28,7 +28,7 @@ export class MultiSelectCellEditing extends BaseCellRenderer<
string[],
SelectPropertyData
> {
private popTagSelect = () => {
private readonly popTagSelect = () => {
const value = signal(this._value);
this._disposables.add({
dispose: popTagSelect(

View File

@ -95,7 +95,7 @@ export class NumberCellEditing extends BaseCellRenderer<
}
`;
private _getFormattedString = (value: number) => {
private readonly _getFormattedString = (value: number) => {
const enableNewFormatting =
this.view.featureFlags$.value.enable_number_formatting;
const decimals = this.property.data$.value.decimal ?? 0;
@ -106,7 +106,7 @@ export class NumberCellEditing extends BaseCellRenderer<
: value.toString();
};
private _keydown = (e: KeyboardEvent) => {
private readonly _keydown = (e: KeyboardEvent) => {
const ctrlKey = IS_MAC ? e.metaKey : e.ctrlKey;
if (e.key.toLowerCase() === 'z' && ctrlKey) {
@ -121,7 +121,7 @@ export class NumberCellEditing extends BaseCellRenderer<
}
};
private _setValue = (str: string = this._inputEle.value) => {
private readonly _setValue = (str: string = this._inputEle.value) => {
if (!str) {
this.onChange(undefined);
return;

View File

@ -28,7 +28,7 @@ export class SelectCellEditing extends BaseCellRenderer<
string,
SelectPropertyData
> {
private popTagSelect = () => {
private readonly popTagSelect = () => {
const value = signal(this._value);
this._disposables.add({
dispose: popTagSelect(

View File

@ -70,7 +70,7 @@ export class TextCellEditing extends BaseCellRenderer<string> {
}
`;
private _keydown = (e: KeyboardEvent) => {
private readonly _keydown = (e: KeyboardEvent) => {
if (e.key === 'Enter' && !e.isComposing) {
this._setValue();
setTimeout(() => {
@ -79,7 +79,7 @@ export class TextCellEditing extends BaseCellRenderer<string> {
}
};
private _setValue = (str: string = this._inputEle.value) => {
private readonly _setValue = (str: string = this._inputEle.value) => {
this._inputEle.value = `${this.value ?? ''}`;
this.onChange(str);
};

View File

@ -91,7 +91,7 @@ export class MobileKanbanCard extends SignalWatcher(
) {
static override styles = styles;
private clickCenterPeek = (e: MouseEvent) => {
private readonly clickCenterPeek = (e: MouseEvent) => {
e.stopPropagation();
this.dataViewEle.openDetailPanel({
view: this.view,
@ -99,7 +99,7 @@ export class MobileKanbanCard extends SignalWatcher(
});
};
private clickMore = (e: MouseEvent) => {
private readonly clickMore = (e: MouseEvent) => {
e.stopPropagation();
popCardMenu(
popupTargetFromElement(e.currentTarget as HTMLElement),

View File

@ -51,7 +51,7 @@ export class MobileKanbanCell extends SignalWatcher(
) {
static override styles = styles;
private _cell = createRef<DataViewCellLifeCycle>();
private readonly _cell = createRef<DataViewCellLifeCycle>();
isEditing$ = computed(() => {
const selection = this.kanban?.props.selection$.value;

View File

@ -60,15 +60,15 @@ export class MobileKanbanGroup extends SignalWatcher(
) {
static override styles = styles;
private clickAddCard = () => {
private readonly clickAddCard = () => {
this.view.addCard('end', this.group.key);
};
private clickAddCardInStart = () => {
private readonly clickAddCardInStart = () => {
this.view.addCard('start', this.group.key);
};
private clickGroupOptions = (e: MouseEvent) => {
private readonly clickGroupOptions = (e: MouseEvent) => {
const ele = e.currentTarget as HTMLElement;
popFilterableSimpleMenu(popupTargetFromElement(ele), [
menu.group({

View File

@ -125,7 +125,7 @@ export class KanbanCard extends SignalWatcher(
) {
static override styles = styles;
private clickEdit = (e: MouseEvent) => {
private readonly clickEdit = (e: MouseEvent) => {
e.stopPropagation();
const selection = this.getSelection();
if (selection) {
@ -133,7 +133,7 @@ export class KanbanCard extends SignalWatcher(
}
};
private clickMore = (e: MouseEvent) => {
private readonly clickMore = (e: MouseEvent) => {
e.stopPropagation();
const selection = this.getSelection();
const ele = e.currentTarget as HTMLElement;
@ -156,7 +156,7 @@ export class KanbanCard extends SignalWatcher(
}
};
private contextMenu = (e: MouseEvent) => {
private readonly contextMenu = (e: MouseEvent) => {
e.stopPropagation();
e.preventDefault();
const selection = this.getSelection();

View File

@ -59,7 +59,7 @@ export class KanbanCell extends SignalWatcher(
) {
static override styles = styles;
private _cell = createRef<DataViewCellLifeCycle>();
private readonly _cell = createRef<DataViewCellLifeCycle>();
selectCurrentCell = (editing: boolean) => {
const selectionView = this.closest(

View File

@ -5,7 +5,7 @@ import type { KanbanViewSelectionWithType } from '../../types.js';
import type { DataViewKanban } from '../kanban-view.js';
export class KanbanClipboardController implements ReactiveController {
private _onCopy = (
private readonly _onCopy = (
_context: UIEventStateContext,
_kanbanSelection: KanbanViewSelectionWithType
) => {
@ -13,7 +13,7 @@ export class KanbanClipboardController implements ReactiveController {
return true;
};
private _onPaste = (_context: UIEventStateContext) => {
private readonly _onPaste = (_context: UIEventStateContext) => {
// todo
return true;
};

View File

@ -140,7 +140,7 @@ export class KanbanDragController implements ReactiveController {
return scrollContainer;
}
constructor(private host: DataViewKanban) {
constructor(private readonly host: DataViewKanban) {
this.host.addController(this);
}

View File

@ -7,7 +7,7 @@ export class KanbanHotkeysController implements ReactiveController {
return !!this.host.selectionController.selection;
}
constructor(private host: DataViewKanban) {
constructor(private readonly host: DataViewKanban) {
this.host.addController(this);
}

View File

@ -79,7 +79,7 @@ export class KanbanSelectionController implements ReactiveController {
return this.host.props.view;
}
constructor(private host: DataViewKanban) {
constructor(private readonly host: DataViewKanban) {
this.host.addController(this);
}

View File

@ -96,7 +96,7 @@ export class KanbanGroup extends SignalWatcher(
) {
static override styles = styles;
private clickAddCard = () => {
private readonly clickAddCard = () => {
const id = this.view.addCard('end', this.group.key);
requestAnimationFrame(() => {
const kanban = this.closest('affine-data-view-kanban');
@ -114,7 +114,7 @@ export class KanbanGroup extends SignalWatcher(
});
};
private clickAddCardInStart = () => {
private readonly clickAddCardInStart = () => {
const id = this.view.addCard('start', this.group.key);
requestAnimationFrame(() => {
const kanban = this.closest('affine-data-view-kanban');
@ -132,7 +132,7 @@ export class KanbanGroup extends SignalWatcher(
});
};
private clickGroupOptions = (e: MouseEvent) => {
private readonly clickGroupOptions = (e: MouseEvent) => {
const ele = e.currentTarget as HTMLElement;
popFilterableSimpleMenu(popupTargetFromElement(ele), [
menu.action({

View File

@ -35,7 +35,7 @@ export class KanbanHeader extends SignalWatcher(
) {
static override styles = styles;
private clickGroup = (e: MouseEvent) => {
private readonly clickGroup = (e: MouseEvent) => {
const groupTrait = this.view.traitGet(groupTraitKey);
if (!groupTrait) {
return;

View File

@ -100,7 +100,7 @@ export class DataViewKanban extends DataViewBase<
> {
static override styles = styles;
private dragController = new KanbanDragController(this);
private readonly dragController = new KanbanDragController(this);
clipboardController = new KanbanClipboardController(this);

View File

@ -36,7 +36,7 @@ export class MobileTableCell extends SignalWatcher(
}
`;
private _cell = createRef<DataViewCellLifeCycle>();
private readonly _cell = createRef<DataViewCellLifeCycle>();
@property({ attribute: false })
accessor column!: TableColumn;

View File

@ -53,7 +53,7 @@ export class MobileTableColumnHeader extends SignalWatcher(
}
`;
private _clickColumn = () => {
private readonly _clickColumn = () => {
if (this.tableViewManager.readonly$.value) {
return;
}

View File

@ -50,7 +50,7 @@ export class MobileTableGroup extends SignalWatcher(
) {
static override styles = styles;
private clickAddRow = () => {
private readonly clickAddRow = () => {
this.view.rowAdd('end', this.group?.key);
requestAnimationFrame(() => {
const selectionController = this.viewEle.selectionController;
@ -68,7 +68,7 @@ export class MobileTableGroup extends SignalWatcher(
});
};
private clickAddRowInStart = () => {
private readonly clickAddRowInStart = () => {
this.view.rowAdd('start', this.group?.key);
requestAnimationFrame(() => {
const selectionController = this.viewEle.selectionController;
@ -86,7 +86,7 @@ export class MobileTableGroup extends SignalWatcher(
});
};
private clickGroupOptions = (e: MouseEvent) => {
private readonly clickGroupOptions = (e: MouseEvent) => {
const group = this.group;
if (!group) {
return;
@ -111,7 +111,7 @@ export class MobileTableGroup extends SignalWatcher(
]);
};
private renderGroupHeader = () => {
private readonly renderGroupHeader = () => {
if (!this.group) {
return null;
}

View File

@ -23,7 +23,7 @@ export class MobileTableHeader extends SignalWatcher(
}
`;
private _onAddColumn = () => {
private readonly _onAddColumn = () => {
if (this.readonly) return;
this.tableViewManager.propertyAdd('end');
this.editLastColumnTitle();

View File

@ -45,7 +45,7 @@ export class MobileDataViewTable extends DataViewBase<
}
`;
private _addRow = (
private readonly _addRow = (
tableViewManager: TableSingleView,
position: InsertToPosition | number
) => {

View File

@ -43,7 +43,7 @@ export class DatabaseCellContainer extends SignalWatcher(
}
`;
private _cell = createRef<DataViewCellLifeCycle>();
private readonly _cell = createRef<DataViewCellLifeCycle>();
@property({ attribute: false })
accessor column!: TableColumn;

View File

@ -16,7 +16,7 @@ type JsonAreaData = string[][];
const TEXT = 'text/plain';
export class TableClipboardController implements ReactiveController {
private _onCopy = (
private readonly _onCopy = (
tableSelection: TableViewSelectionWithType,
isCut = false
) => {
@ -72,11 +72,11 @@ export class TableClipboardController implements ReactiveController {
return true;
};
private _onCut = (tableSelection: TableViewSelectionWithType) => {
private readonly _onCut = (tableSelection: TableViewSelectionWithType) => {
this._onCopy(tableSelection, true);
};
private _onPaste = async (_context: UIEventStateContext) => {
private readonly _onPaste = async (_context: UIEventStateContext) => {
const event = _context.get('clipboardState').raw;
event.stopPropagation();
const view = this.host;

View File

@ -128,7 +128,7 @@ export class TableDragController implements ReactiveController {
return position;
};
constructor(private host: DataViewTable) {
constructor(private readonly host: DataViewTable) {
this.host.addController(this);
}

View File

@ -10,7 +10,7 @@ export class TableHotkeysController implements ReactiveController {
return this.host.selectionController;
}
constructor(private host: DataViewTable) {
constructor(private readonly host: DataViewTable) {
this.host.addController(this);
}

View File

@ -29,7 +29,7 @@ import {
export class TableSelectionController implements ReactiveController {
private _tableViewSelection?: TableViewSelectionWithType;
private getFocusCellContainer = () => {
private readonly getFocusCellContainer = () => {
if (
!this._tableViewSelection ||
this._tableViewSelection.selectionType !== 'area'

View File

@ -67,7 +67,7 @@ export class TableGroup extends SignalWatcher(
) {
static override styles = styles;
private clickAddRow = () => {
private readonly clickAddRow = () => {
this.view.rowAdd('end', this.group?.key);
requestAnimationFrame(() => {
const selectionController = this.viewEle.selectionController;
@ -85,7 +85,7 @@ export class TableGroup extends SignalWatcher(
});
};
private clickAddRowInStart = () => {
private readonly clickAddRowInStart = () => {
this.view.rowAdd('start', this.group?.key);
requestAnimationFrame(() => {
const selectionController = this.viewEle.selectionController;
@ -103,7 +103,7 @@ export class TableGroup extends SignalWatcher(
});
};
private clickGroupOptions = (e: MouseEvent) => {
private readonly clickGroupOptions = (e: MouseEvent) => {
const group = this.group;
if (!group) {
return;
@ -128,7 +128,7 @@ export class TableGroup extends SignalWatcher(
]);
};
private renderGroupHeader = () => {
private readonly renderGroupHeader = () => {
if (!this.group) {
return null;
}

View File

@ -19,7 +19,7 @@ export class DatabaseColumnHeader extends SignalWatcher(
) {
static override styles = styles;
private _onAddColumn = (e: MouseEvent) => {
private readonly _onAddColumn = (e: MouseEvent) => {
if (this.readonly) return;
this.tableViewManager.propertyAdd('end');
const ele = e.currentTarget as HTMLElement;

View File

@ -63,14 +63,14 @@ export class DatabaseHeaderColumn extends SignalWatcher(
}
`;
private _clickColumn = () => {
private readonly _clickColumn = () => {
if (this.tableViewManager.readonly$.value) {
return;
}
this.popMenu();
};
private _clickTypeIcon = (event: MouseEvent) => {
private readonly _clickTypeIcon = (event: MouseEvent) => {
if (this.tableViewManager.readonly$.value) {
return;
}
@ -96,7 +96,7 @@ export class DatabaseHeaderColumn extends SignalWatcher(
});
};
private _contextMenu = (e: MouseEvent) => {
private readonly _contextMenu = (e: MouseEvent) => {
if (this.tableViewManager.readonly$.value) {
return;
}
@ -104,7 +104,7 @@ export class DatabaseHeaderColumn extends SignalWatcher(
this.popMenu(e.currentTarget as HTMLElement);
};
private _enterWidthDragBar = () => {
private readonly _enterWidthDragBar = () => {
if (this.tableViewManager.readonly$.value) {
return;
}
@ -115,13 +115,13 @@ export class DatabaseHeaderColumn extends SignalWatcher(
this.drawWidthDragBar();
};
private _leaveWidthDragBar = () => {
private readonly _leaveWidthDragBar = () => {
cancelAnimationFrame(this.drawWidthDragBarTask);
this.drawWidthDragBarTask = 0;
getVerticalIndicator().remove();
};
private drawWidthDragBar = () => {
private readonly drawWidthDragBar = () => {
const rect = getTableGroupRect(this);
if (!rect) {
return;
@ -136,7 +136,7 @@ export class DatabaseHeaderColumn extends SignalWatcher(
private drawWidthDragBarTask = 0;
private widthDragBar = createRef();
private readonly widthDragBar = createRef();
editTitle = () => {
this._clickColumn();

View File

@ -87,14 +87,14 @@ export class DatabaseNumberFormatBar extends WithDisposable(LitElement) {
}
`;
private _decrementDecimalPlaces = () => {
private readonly _decrementDecimalPlaces = () => {
this.column.dataUpdate(data => ({
decimal: Math.max(((data.decimal as number) ?? 0) - 1, 0),
}));
this.requestUpdate();
};
private _incrementDecimalPlaces = () => {
private readonly _incrementDecimalPlaces = () => {
this.column.dataUpdate(data => ({
decimal: Math.min(((data.decimal as number) ?? 0) + 1, 8),
}));

View File

@ -114,7 +114,7 @@ export class TableRow extends SignalWatcher(WithDisposable(ShadowlessElement)) {
}
`;
private _clickDragHandler = () => {
private readonly _clickDragHandler = () => {
if (this.view.readonly$.value) {
return;
}

View File

@ -39,7 +39,7 @@ export class TableSingleView extends SingleViewBase<TableViewData> {
return result;
});
private computedColumns$ = computed(() => {
private readonly computedColumns$ = computed(() => {
return this.propertiesWithoutFilter$.value.map(id => {
const column = this.propertyGet(id);
return {
@ -51,19 +51,19 @@ export class TableSingleView extends SingleViewBase<TableViewData> {
});
});
private filter$ = computed(() => {
private readonly filter$ = computed(() => {
return this.data$.value?.filter ?? emptyFilterGroup;
});
private groupBy$ = computed(() => {
private readonly groupBy$ = computed(() => {
return this.data$.value?.groupBy;
});
private sortList$ = computed(() => {
private readonly sortList$ = computed(() => {
return this.data$.value?.sort;
});
private sortManager = this.traitSet(
private readonly sortManager = this.traitSet(
sortTraitKey,
new SortManager(this.sortList$, this, {
setSortList: sortList => {
@ -385,7 +385,7 @@ export class TableColumn extends PropertyBase {
}
constructor(
private tableView: TableSingleView,
private readonly tableView: TableSingleView,
columnId: string
) {
super(tableView as SingleView, columnId);

View File

@ -82,13 +82,13 @@ export class FilterConditionView extends SignalWatcher(ShadowlessElement) {
}
`;
private onClickButton = (evt: Event) => {
private readonly onClickButton = (evt: Event) => {
this.popConditionEdit(
popupTargetFromElement(evt.currentTarget as HTMLElement)
);
};
private popConditionEdit = (target: PopupTarget) => {
private readonly popConditionEdit = (target: PopupTarget) => {
const type = this.leftVar$.value?.type;
if (!type) {
return;

View File

@ -184,7 +184,7 @@ export class FilterGroupView extends SignalWatcher(ShadowlessElement) {
}
`;
private _addNew = (e: MouseEvent) => {
private readonly _addNew = (e: MouseEvent) => {
if (this.isMaxDepth) {
this.onChange({
...this.filterGroup.value,
@ -202,7 +202,7 @@ export class FilterGroupView extends SignalWatcher(ShadowlessElement) {
});
};
private _selectOp = (event: MouseEvent) => {
private readonly _selectOp = (event: MouseEvent) => {
popFilterableSimpleMenu(
popupTargetFromElement(event.currentTarget as HTMLElement),
[
@ -228,7 +228,7 @@ export class FilterGroupView extends SignalWatcher(ShadowlessElement) {
);
};
private _setFilter = (index: number, filter: Filter) => {
private readonly _setFilter = (index: number, filter: Filter) => {
this.onChange({
...this.filterGroup.value,
conditions: this.filterGroup.value.conditions.map((v, i) =>
@ -237,7 +237,7 @@ export class FilterGroupView extends SignalWatcher(ShadowlessElement) {
});
};
private opMap = {
private readonly opMap = {
and: 'And',
or: 'Or',
};

View File

@ -77,7 +77,7 @@ export class FilterBar extends SignalWatcher(ShadowlessElement) {
}
`;
private _setFilter = (index: number, filter: Filter) => {
private readonly _setFilter = (index: number, filter: Filter) => {
this.onChange({
...this.filterGroup.value,
conditions: this.filterGroup.value.conditions.map((v, i) =>
@ -86,7 +86,7 @@ export class FilterBar extends SignalWatcher(ShadowlessElement) {
});
};
private addFilter = (e: MouseEvent) => {
private readonly addFilter = (e: MouseEvent) => {
const element = popupTargetFromElement(e.target as HTMLElement);
popCreateFilter(element, {
vars: this.vars,
@ -103,7 +103,7 @@ export class FilterBar extends SignalWatcher(ShadowlessElement) {
});
};
private expandGroup = (position: PopupTarget, i: number) => {
private readonly expandGroup = (position: PopupTarget, i: number) => {
if (this.filterGroup.value.conditions[i]?.type !== 'group') {
return;
}

View File

@ -158,7 +158,7 @@ export class FilterRootView extends SignalWatcher(ShadowlessElement) {
}
`;
private _setFilter = (index: number, filter: Filter) => {
private readonly _setFilter = (index: number, filter: Filter) => {
this.onChange({
...this.filterGroup.value,
conditions: this.filterGroup.value.conditions.map((v, i) =>
@ -167,7 +167,7 @@ export class FilterRootView extends SignalWatcher(ShadowlessElement) {
});
};
private expandGroup = (position: PopupTarget, i: number) => {
private readonly expandGroup = (position: PopupTarget, i: number) => {
if (this.filterGroup.value.conditions[i]?.type !== 'group') {
return;
}

View File

@ -93,7 +93,7 @@ export class DataViewHeaderToolsSearch extends WidgetBase<
> {
static override styles = styles;
private _clearSearch = () => {
private readonly _clearSearch = () => {
this._searchInput.value = '';
this.view.setSearch('');
this.preventBlur = true;
@ -102,25 +102,25 @@ export class DataViewHeaderToolsSearch extends WidgetBase<
});
};
private _clickSearch = (e: MouseEvent) => {
private readonly _clickSearch = (e: MouseEvent) => {
e.stopPropagation();
this.showSearch = true;
};
private _onSearch = (event: InputEvent) => {
private readonly _onSearch = (event: InputEvent) => {
const el = event.target as HTMLInputElement;
const inputValue = el.value.trim();
this.view.setSearch(inputValue);
};
private _onSearchBlur = () => {
private readonly _onSearchBlur = () => {
if (this._searchInput.value || this.preventBlur) {
return;
}
this.showSearch = false;
};
private _onSearchKeydown = (event: KeyboardEvent) => {
private readonly _onSearchKeydown = (event: KeyboardEvent) => {
if (event.key === 'Escape') {
if (this._searchInput.value) {
this._searchInput.value = '';

View File

@ -19,7 +19,7 @@ const styles = css`
export class DataViewHeaderToolsAddRow extends WidgetBase {
static override styles = styles;
private _onAddNewRecord = () => {
private readonly _onAddNewRecord = () => {
if (this.readonly) return;
this.viewMethods.addRow?.('start');
};

View File

@ -151,7 +151,7 @@ export class MindmapElementModel extends GfxGroupLikeElementModel<MindmapElement
private _queuedLayout = false;
private _stashedNode = new Set<string>();
private readonly _stashedNode = new Set<string>();
private _tree!: MindmapRoot;

View File

@ -77,7 +77,7 @@ export abstract class MindmapStyleGetter {
}
export class StyleOne extends MindmapStyleGetter {
private _colorOrders = [
private readonly _colorOrders = [
LineColor.Purple,
LineColor.Magenta,
LineColor.Orange,
@ -188,7 +188,7 @@ export class StyleOne extends MindmapStyleGetter {
export const styleOne = new StyleOne();
export class StyleTwo extends MindmapStyleGetter {
private _colorOrders = [
private readonly _colorOrders = [
ShapeFillColor.Blue,
'#7ae2d5',
ShapeFillColor.Yellow,
@ -298,7 +298,11 @@ export class StyleTwo extends MindmapStyleGetter {
export const styleTwo = new StyleTwo();
export class StyleThree extends MindmapStyleGetter {
private _strokeColor = [LineColor.Yellow, LineColor.Green, LineColor.Teal];
private readonly _strokeColor = [
LineColor.Yellow,
LineColor.Green,
LineColor.Teal,
];
readonly root = {
radius: 10,
@ -402,7 +406,7 @@ export class StyleThree extends MindmapStyleGetter {
export const styleThree = new StyleThree();
export class StyleFour extends MindmapStyleGetter {
private _colors = [
private readonly _colors = [
ShapeFillColor.Purple,
ShapeFillColor.Magenta,
ShapeFillColor.Orange,

View File

@ -78,9 +78,9 @@ function customizer(_target: unknown, source: unknown) {
export class EditPropsStore extends LifeCycleWatcher {
static override key = 'EditPropsStore';
private _disposables = new DisposableGroup();
private readonly _disposables = new DisposableGroup();
private innerProps$: Signal<DeepPartial<LastProps>> = signal({});
private readonly innerProps$: Signal<DeepPartial<LastProps>> = signal({});
lastProps$: Signal<LastProps>;

View File

@ -23,7 +23,7 @@ export class EmbedOptionService
extends Extension
implements EmbedOptionProvider
{
private _embedBlockRegistry = new Set<EmbedOptions>();
private readonly _embedBlockRegistry = new Set<EmbedOptions>();
getEmbedBlockOptions = (url: string): EmbedOptions | null => {
const entries = this._embedBlockRegistry.entries();

View File

@ -61,7 +61,7 @@ export class ThemeService extends Extension {
return isInsideEdgelessEditor(this.std.host) ? this.edgeless$ : this.app$;
}
constructor(private std: BlockStdScope) {
constructor(private readonly std: BlockStdScope) {
super();
const extension = this.std.getOptional(ThemeExtensionIdentifier);
this.app$ = extension?.getAppTheme?.() || getThemeObserver().theme$;
@ -172,7 +172,7 @@ export class ThemeService extends Extension {
}
export class ThemeObserver {
private observer: MutationObserver;
private readonly observer: MutationObserver;
theme$ = signal(ColorScheme.Light);

View File

@ -6,7 +6,7 @@ import { SpecBuilder } from './spec-builder.js';
export class SpecProvider {
static instance: SpecProvider;
private specMap = new Map<string, ExtensionType[]>();
private readonly specMap = new Map<string, ExtensionType[]>();
private constructor() {}

View File

@ -54,9 +54,11 @@ export class AffineScrollAnchoringWidget extends WidgetComponent {
#listened = false;
#requestUpdateFn = () => this.requestUpdate();
readonly #requestUpdateFn = () => this.requestUpdate();
#resizeObserver: ResizeObserver = new ResizeObserver(this.#requestUpdateFn);
readonly #resizeObserver: ResizeObserver = new ResizeObserver(
this.#requestUpdateFn
);
anchor$ = signal<Anchor | null>(null);

View File

@ -51,11 +51,11 @@ type HtmlToSliceSnapshotPayload = {
};
export class HtmlAdapter extends BaseAdapter<Html> {
private _astToHtml = (ast: Root) => {
private readonly _astToHtml = (ast: Root) => {
return unified().use(rehypeStringify).stringify(ast);
};
private _traverseHtml = async (
private readonly _traverseHtml = async (
html: HtmlAST,
snapshot: BlockSnapshot,
assets?: AssetsManager
@ -108,7 +108,7 @@ export class HtmlAdapter extends BaseAdapter<Html> {
return walker.walk(html, snapshot);
};
private _traverseSnapshot = async (
private readonly _traverseSnapshot = async (
snapshot: BlockSnapshot,
html: HtmlAST,
assets?: AssetsManager

View File

@ -50,7 +50,7 @@ type MarkdownToSliceSnapshotPayload = {
};
export class MarkdownAdapter extends BaseAdapter<Markdown> {
private _traverseMarkdown = (
private readonly _traverseMarkdown = (
markdown: MarkdownAST,
snapshot: BlockSnapshot,
assets?: AssetsManager
@ -105,7 +105,7 @@ export class MarkdownAdapter extends BaseAdapter<Markdown> {
return walker.walk(markdown, snapshot);
};
private _traverseSnapshot = async (
private readonly _traverseSnapshot = async (
snapshot: BlockSnapshot,
markdown: MarkdownAST,
assets?: AssetsManager

View File

@ -38,7 +38,7 @@ type MixTextToSliceSnapshotPayload = {
};
export class MixTextAdapter extends BaseAdapter<MixText> {
private _markdownAdapter: MarkdownAdapter;
private readonly _markdownAdapter: MarkdownAdapter;
constructor(job: Job) {
super(job);

View File

@ -54,7 +54,7 @@ type NotionHtmlToDocSnapshotPayload = {
type NotionHtmlToBlockSnapshotPayload = NotionHtmlToDocSnapshotPayload;
export class NotionHtmlAdapter extends BaseAdapter<NotionHtml> {
private _traverseNotionHtml = async (
private readonly _traverseNotionHtml = async (
html: HtmlAST,
snapshot: BlockSnapshot,
assets?: AssetsManager,

Some files were not shown because too many files have changed in this diff Show More