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; this._popperVisible = true;
popMenu(popupTargetFromElement(this._fullScreenToolbarContainer), { popMenu(popupTargetFromElement(this._fullScreenToolbarContainer), {
options: { options: {

View File

@ -48,7 +48,7 @@ import { getEmbedLinkedDocIcons } from './utils.js';
export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinkedDocModel> { export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinkedDocModel> {
static override styles = styles; static override styles = styles;
private _load = async () => { private readonly _load = async () => {
const { const {
loading = true, loading = true,
isError = false, isError = false,
@ -103,7 +103,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
} }
}; };
private _selectBlock = () => { private readonly _selectBlock = () => {
const selectionManager = this.host.selection; const selectionManager = this.host.selection;
const blockSelection = selectionManager.create('block', { const blockSelection = selectionManager.create('block', {
blockId: this.blockId, blockId: this.blockId,
@ -111,7 +111,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
selectionManager.setGroup('note', [blockSelection]); selectionManager.setGroup('note', [blockSelection]);
}; };
private _setDocUpdatedAt = () => { private readonly _setDocUpdatedAt = () => {
const meta = this.doc.collection.meta.getDocMeta(this.model.pageId); const meta = this.doc.collection.meta.getDocMeta(this.model.pageId);
if (meta) { if (meta) {
const date = meta.updatedDate || meta.createDate; 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. // Caches total bounds, includes all blocks and elements.
private _cachedBounds: Bound | null = null; private _cachedBounds: Bound | null = null;
private _initEdgelessFitEffect = () => { private readonly _initEdgelessFitEffect = () => {
const fitToContent = () => { const fitToContent = () => {
if (this.isPageMode) return; if (this.isPageMode) return;
@ -99,7 +99,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
.catch(() => {}); .catch(() => {});
}; };
private _pageFilter: Query = { private readonly _pageFilter: Query = {
mode: 'loose', mode: 'loose',
match: [ match: [
{ {

View File

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

View File

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

View File

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

View File

@ -42,9 +42,9 @@ type RendererOptions = {
export class CanvasRenderer { export class CanvasRenderer {
private _container!: HTMLElement; 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; private _refreshRafId: number | null = null;

View File

@ -100,7 +100,7 @@ export class SurfaceBlockComponent extends BlockComponent<
private _cachedViewport = new Bound(); private _cachedViewport = new Bound();
private _initThemeObserver = () => { private readonly _initThemeObserver = () => {
const theme = this.std.get(ThemeProvider); const theme = this.std.get(ThemeProvider);
this.disposables.add(theme.theme$.subscribe(() => this.requestUpdate())); 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 type SurfaceMiddleware = (surface: SurfaceBlockModel) => () => void;
export class SurfaceBlockModel extends BaseSurfaceModel { export class SurfaceBlockModel extends BaseSurfaceModel {
private _disposables: DisposableGroup = new DisposableGroup(); private readonly _disposables: DisposableGroup = new DisposableGroup();
override _init() { override _init() {
this._extendElement(elementsCtorMap); this._extendElement(elementsCtorMap);

View File

@ -33,24 +33,27 @@ function pointAlmostEqual(a: IVec3, b: IVec3): boolean {
} }
export class AStarRunner { 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 _complete = false;
private _costSoFar = new Map<IVec3, number[]>(); private readonly _costSoFar = new Map<IVec3, number[]>();
private _current: IVec3 | null = null; private _current: IVec3 | null = null;
private _diagonalCount = new Map<IVec3, number[]>(); private readonly _diagonalCount = new Map<IVec3, number[]>();
private _frontier!: PriorityQueue< private _frontier!: PriorityQueue<
IVec3, IVec3,
[diagonalCount: number, pointPriority: number, distCost: number] [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() { get path() {
const result: IVec3[] = []; const result: IVec3[] = [];
@ -72,9 +75,9 @@ export class AStarRunner {
constructor( constructor(
points: IVec3[], points: IVec3[],
private _sp: IVec3, private readonly _sp: IVec3,
private _ep: IVec3, private readonly _ep: IVec3,
private _originalSp: IVec3, private readonly _originalSp: IVec3,
private _originalEp: IVec3, private _originalEp: IVec3,
blocks: Bound[] = [], blocks: Bound[] = [],
expandBlocks: 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> { 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( constructor(
private points: V[], private readonly points: V[],
private blocks: Bound[] = [], private readonly blocks: Bound[] = [],
private expandedBlocks: Bound[] = [], private readonly expandedBlocks: Bound[] = [],
private excludedPoints: V[] = [] private readonly excludedPoints: V[] = []
) { ) {
const xMap = this._xMap; const xMap = this._xMap;
const yMap = this._yMap; const yMap = this._yMap;

View File

@ -6,7 +6,7 @@ type PriorityQueueNode<T, K> = {
export class PriorityQueue<T, K> { export class PriorityQueue<T, K> {
heap: PriorityQueueNode<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 { bubbleDown(): void {
let index = 0; let index = 0;

View File

@ -9,11 +9,11 @@ import { RoughGenerator } from './generator.js';
import type { Point } from './geometry.js'; import type { Point } from './geometry.js';
export class RoughCanvas { 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 { get generator(): RoughGenerator {
return this.gen; return this.gen;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -45,17 +45,17 @@ export class MenuInput extends MenuFocusable {
} }
`; `;
private onCompositionEnd = () => { private readonly onCompositionEnd = () => {
this.data.onChange?.(this.inputRef.value); this.data.onChange?.(this.inputRef.value);
}; };
private onInput = (e: InputEvent) => { private readonly onInput = (e: InputEvent) => {
e.stopPropagation(); e.stopPropagation();
if (e.isComposing) return; if (e.isComposing) return;
this.data.onChange?.(this.inputRef.value); this.data.onChange?.(this.inputRef.value);
}; };
private onKeydown = (e: KeyboardEvent) => { private readonly onKeydown = (e: KeyboardEvent) => {
e.stopPropagation(); e.stopPropagation();
if (e.isComposing) return; if (e.isComposing) return;
if (e.key === 'Escape') { if (e.key === 'Escape') {
@ -71,7 +71,7 @@ export class MenuInput extends MenuFocusable {
} }
}; };
private stopPropagation = (e: Event) => { private readonly stopPropagation = (e: Event) => {
e.stopPropagation(); e.stopPropagation();
}; };
@ -140,17 +140,17 @@ export class MobileMenuInput extends MenuFocusable {
} }
`; `;
private onCompositionEnd = () => { private readonly onCompositionEnd = () => {
this.data.onChange?.(this.inputRef.value); this.data.onChange?.(this.inputRef.value);
}; };
private onInput = (e: InputEvent) => { private readonly onInput = (e: InputEvent) => {
e.stopPropagation(); e.stopPropagation();
if (e.isComposing) return; if (e.isComposing) return;
this.data.onChange?.(this.inputRef.value); this.data.onChange?.(this.inputRef.value);
}; };
private stopPropagation = (e: Event) => { private readonly stopPropagation = (e: Event) => {
e.stopPropagation(); e.stopPropagation();
}; };

View File

@ -83,13 +83,13 @@ export class MenuComponent
} }
`; `;
private _clickContainer = (e: MouseEvent) => { private readonly _clickContainer = (e: MouseEvent) => {
e.stopPropagation(); e.stopPropagation();
this.focusInput(); this.focusInput();
this.menu.closeSubMenu(); this.menu.closeSubMenu();
}; };
private searchRef = createRef<HTMLInputElement>(); private readonly searchRef = createRef<HTMLInputElement>();
override firstUpdated() { override firstUpdated() {
const input = this.searchRef.value; const input = this.searchRef.value;

View File

@ -57,9 +57,9 @@ export function onMenuOpen(listener: MenuOpenListener) {
export class Menu { export class Menu {
private _cleanupFns: Array<() => void> = []; private _cleanupFns: Array<() => void> = [];
private _currentFocused$ = signal<MenuFocusable>(); private readonly _currentFocused$ = signal<MenuFocusable>();
private _subMenu$ = signal<Menu>(); private readonly _subMenu$ = signal<Menu>();
closed = false; closed = false;

View File

@ -54,9 +54,9 @@ export class DatePicker extends WithDisposable(LitElement) {
/** current active month */ /** current active month */
private _cursor = new Date(); private _cursor = new Date();
private _maxYear = 2099; private readonly _maxYear = 2099;
private _minYear = 1970; private readonly _minYear = 1970;
get _cardStyle() { get _cardStyle() {
return { return {

View File

@ -68,6 +68,6 @@ export function getMonthMatrix(maybeDate: MaybeDate) {
} }
export function clamp(num1: number, num2: number, value: number) { 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); 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'; import type { PeekableClass, PeekViewService } from './type.js';
export class PeekableController<T extends PeekableClass> { export class PeekableController<T extends PeekableClass> {
private _getPeekViewService = (): PeekViewService | null => { private readonly _getPeekViewService = (): PeekViewService | null => {
return this.target.std.getOptional(PeekViewProvider); return this.target.std.getOptional(PeekViewProvider);
}; };
@ -25,7 +25,7 @@ export class PeekableController<T extends PeekableClass> {
} }
constructor( constructor(
private target: T, private readonly target: T,
private enable?: (e: T) => boolean private readonly enable?: (e: T) => boolean
) {} ) {}
} }

View File

@ -30,7 +30,7 @@ export class AffineLink extends ShadowlessElement {
private _identified: boolean = false; private _identified: boolean = false;
// see https://github.com/toeverything/AFFiNE/issues/1540 // see https://github.com/toeverything/AFFiNE/issues/1540
private _onMouseUp = () => { private readonly _onMouseUp = () => {
const anchorElement = this.querySelector('a'); const anchorElement = this.querySelector('a');
if (!anchorElement || !anchorElement.isContentEditable) return; if (!anchorElement || !anchorElement.isContentEditable) return;
anchorElement.contentEditable = 'false'; anchorElement.contentEditable = 'false';
@ -58,7 +58,7 @@ export class AffineLink extends ShadowlessElement {
refNodeSlotsProvider.docLinkClicked.emit(referenceInfo); refNodeSlotsProvider.docLinkClicked.emit(referenceInfo);
}; };
private _whenHover = new HoverController( private readonly _whenHover = new HoverController(
this, this,
({ abortController }) => { ({ abortController }) => {
if (this.block?.doc.readonly) { if (this.block?.doc.readonly) {

View File

@ -49,7 +49,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
private _bodyOverflowStyle = ''; private _bodyOverflowStyle = '';
private _createTemplate = () => { private readonly _createTemplate = () => {
this.updateComplete this.updateComplete
.then(() => { .then(() => {
this.linkInput?.focus(); this.linkInput?.focus();
@ -74,14 +74,14 @@ export class LinkPopup extends WithDisposable(LitElement) {
`; `;
}; };
private _delete = () => { private readonly _delete = () => {
if (this.inlineEditor.isValidInlineRange(this.targetInlineRange)) { if (this.inlineEditor.isValidInlineRange(this.targetInlineRange)) {
this.inlineEditor.deleteText(this.targetInlineRange); this.inlineEditor.deleteText(this.targetInlineRange);
} }
this.abortController.abort(); this.abortController.abort();
}; };
private _edit = () => { private readonly _edit = () => {
if (!this.host) return; if (!this.host) return;
this.type = 'edit'; this.type = 'edit';
@ -89,7 +89,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
track(this.host.std, 'OpenedAliasPopup', { control: 'edit' }); track(this.host.std, 'OpenedAliasPopup', { control: 'edit' });
}; };
private _editTemplate = () => { private readonly _editTemplate = () => {
this.updateComplete this.updateComplete
.then(() => { .then(() => {
if ( if (
@ -139,7 +139,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
private _embedOptions: EmbedOptions | null = null; private _embedOptions: EmbedOptions | null = null;
private _openLink = () => { private readonly _openLink = () => {
if (this.openLink) { if (this.openLink) {
this.openLink(); this.openLink();
return; return;
@ -154,7 +154,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
this.abortController.abort(); this.abortController.abort();
}; };
private _removeLink = () => { private readonly _removeLink = () => {
if (this.inlineEditor.isValidInlineRange(this.targetInlineRange)) { if (this.inlineEditor.isValidInlineRange(this.targetInlineRange)) {
this.inlineEditor.formatText(this.targetInlineRange, { this.inlineEditor.formatText(this.targetInlineRange, {
link: null, link: null,
@ -163,7 +163,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
this.abortController.abort(); this.abortController.abort();
}; };
private _toggleViewSelector = (e: Event) => { private readonly _toggleViewSelector = (e: Event) => {
if (!this.host) return; if (!this.host) return;
const opened = (e as CustomEvent<boolean>).detail; 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' }); track(this.host.std, 'OpenedViewSelector', { control: 'switch view' });
}; };
private _trackViewSelected = (type: string) => { private readonly _trackViewSelected = (type: string) => {
if (!this.host) return; if (!this.host) return;
track(this.host.std, 'SelectedView', { track(this.host.std, 'SelectedView', {
@ -181,7 +181,7 @@ export class LinkPopup extends WithDisposable(LitElement) {
}); });
}; };
private _viewTemplate = () => { private readonly _viewTemplate = () => {
if (!this.currentLink) return; if (!this.currentLink) return;
this._embedOptions = this._embedOptions =

View File

@ -89,7 +89,7 @@ export class ReferenceAliasPopup extends SignalWatcher(
} }
`; `;
private _onSave = () => { private readonly _onSave = () => {
const title = this.title$.value.trim(); const title = this.title$.value.trim();
if (!title) { if (!title) {
this.remove(); this.remove();
@ -103,7 +103,7 @@ export class ReferenceAliasPopup extends SignalWatcher(
this.remove(); this.remove();
}; };
private _updateTitle = (e: InputEvent) => { private readonly _updateTitle = (e: InputEvent) => {
const target = e.target as HTMLInputElement; const target = e.target as HTMLInputElement;
const value = target.value; const value = target.value;
this.title$.value = 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; const refAttribute = this.delta.attributes?.reference;
if (!refAttribute) { if (!refAttribute) {
return; return;
@ -88,7 +88,7 @@ export class AffineReference extends WithDisposable(ShadowlessElement) {
@state() @state()
accessor refMeta: DocMeta | undefined = undefined; accessor refMeta: DocMeta | undefined = undefined;
private _whenHover: HoverController = new HoverController( private readonly _whenHover: HoverController = new HoverController(
this, this,
({ abortController }) => { ({ abortController }) => {
if ( if (

View File

@ -50,7 +50,7 @@ import { styles } from './styles.js';
export class ReferencePopup extends WithDisposable(LitElement) { export class ReferencePopup extends WithDisposable(LitElement) {
static override styles = styles; static override styles = styles;
private _copyLink = () => { private readonly _copyLink = () => {
const url = this.std const url = this.std
.getOptional(GenerateDocUrlProvider) .getOptional(GenerateDocUrlProvider)
?.generateDocUrl(this.referenceInfo.pageId, this.referenceInfo.params); ?.generateDocUrl(this.referenceInfo.pageId, this.referenceInfo.params);
@ -65,13 +65,13 @@ export class ReferencePopup extends WithDisposable(LitElement) {
track(this.std, 'CopiedLink', { control: 'copy link' }); track(this.std, 'CopiedLink', { control: 'copy link' });
}; };
private _openDoc = () => { private readonly _openDoc = () => {
this.std this.std
.getOptional(RefNodeSlotsProvider) .getOptional(RefNodeSlotsProvider)
?.docLinkClicked.emit(this.referenceInfo); ?.docLinkClicked.emit(this.referenceInfo);
}; };
private _openEditPopup = (e: MouseEvent) => { private readonly _openEditPopup = (e: MouseEvent) => {
e.stopPropagation(); e.stopPropagation();
if (document.body.querySelector('reference-alias-popup')) { if (document.body.querySelector('reference-alias-popup')) {
@ -102,14 +102,14 @@ export class ReferencePopup extends WithDisposable(LitElement) {
track(std, 'OpenedAliasPopup', { control: 'edit' }); track(std, 'OpenedAliasPopup', { control: 'edit' });
}; };
private _toggleViewSelector = (e: Event) => { private readonly _toggleViewSelector = (e: Event) => {
const opened = (e as CustomEvent<boolean>).detail; const opened = (e as CustomEvent<boolean>).detail;
if (!opened) return; if (!opened) return;
track(this.std, 'OpenedViewSelector', { control: 'switch view' }); track(this.std, 'OpenedViewSelector', { control: 'switch view' });
}; };
private _trackViewSelected = (type: string) => { private readonly _trackViewSelected = (type: string) => {
track(this.std, 'SelectedView', { track(this.std, 'SelectedView', {
control: 'select view', control: 'select view',
type: `${type} view`, type: `${type} view`,

View File

@ -60,7 +60,7 @@ export class RichText extends WithDisposable(ShadowlessElement) {
private _inlineEditor: AffineInlineEditor | null = null; private _inlineEditor: AffineInlineEditor | null = null;
private _onCopy = (e: ClipboardEvent) => { private readonly _onCopy = (e: ClipboardEvent) => {
const inlineEditor = this.inlineEditor; const inlineEditor = this.inlineEditor;
if (!inlineEditor) return; if (!inlineEditor) return;
@ -77,7 +77,7 @@ export class RichText extends WithDisposable(ShadowlessElement) {
e.stopPropagation(); e.stopPropagation();
}; };
private _onCut = (e: ClipboardEvent) => { private readonly _onCut = (e: ClipboardEvent) => {
const inlineEditor = this.inlineEditor; const inlineEditor = this.inlineEditor;
if (!inlineEditor) return; if (!inlineEditor) return;
@ -99,7 +99,7 @@ export class RichText extends WithDisposable(ShadowlessElement) {
e.stopPropagation(); e.stopPropagation();
}; };
private _onPaste = (e: ClipboardEvent) => { private readonly _onPaste = (e: ClipboardEvent) => {
const inlineEditor = this.inlineEditor; const inlineEditor = this.inlineEditor;
if (!inlineEditor) return; if (!inlineEditor) return;
@ -121,14 +121,18 @@ export class RichText extends WithDisposable(ShadowlessElement) {
e.stopPropagation(); e.stopPropagation();
}; };
private _onStackItemAdded = (event: { stackItem: RichTextStackItem }) => { private readonly _onStackItemAdded = (event: {
stackItem: RichTextStackItem;
}) => {
const inlineRange = this.inlineEditor?.getInlineRange(); const inlineRange = this.inlineEditor?.getInlineRange();
if (inlineRange) { if (inlineRange) {
event.stackItem.meta.set('richtext-v-range', 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'); const inlineRange = event.stackItem.meta.get('richtext-v-range');
if (inlineRange && this.inlineEditor?.isValidInlineRange(inlineRange)) { if (inlineRange && this.inlineEditor?.isValidInlineRange(inlineRange)) {
this.inlineEditor?.setInlineRange(inlineRange); this.inlineEditor?.setInlineRange(inlineRange);

View File

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

View File

@ -13,13 +13,13 @@ export type VirtualKeyboardControllerConfig = {
}; };
export class VirtualKeyboardController implements ReactiveController { export class VirtualKeyboardController implements ReactiveController {
private _disposables = new DisposableGroup(); private readonly _disposables = new DisposableGroup();
private readonly _keyboardHeight$ = signal(0); private readonly _keyboardHeight$ = signal(0);
private readonly _keyboardOpened$ = signal(false); private readonly _keyboardOpened$ = signal(false);
private _storeInitialInputElementAttributes = () => { private readonly _storeInitialInputElementAttributes = () => {
const { inputElement } = this.config; const { inputElement } = this.config;
if (navigator.virtualKeyboard) { if (navigator.virtualKeyboard) {
const { overlaysContent } = navigator.virtualKeyboard; const { overlaysContent } = navigator.virtualKeyboard;

View File

@ -150,7 +150,7 @@ class TagManager {
return this.ops.value; return this.ops.value;
} }
constructor(private ops: TagManagerOptions) {} constructor(private readonly ops: TagManagerOptions) {}
deleteTag(id: string) { deleteTag(id: string) {
this.ops.onChange(this.value.value.filter(item => item !== id)); this.ops.onChange(this.value.value.filter(item => item !== id));
@ -180,7 +180,7 @@ export class MultiTagSelect extends SignalWatcher(
) { ) {
static override styles = styles; static override styles = styles;
private _clickItemOption = (e: MouseEvent, id: string) => { private readonly _clickItemOption = (e: MouseEvent, id: string) => {
e.stopPropagation(); e.stopPropagation();
const option = this.options.value.find(v => v.id === id); const option = this.options.value.find(v => v.id === id);
if (!option) { 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; this.tagManager.text.value = (event.target as HTMLInputElement).value;
}; };
private _onInputKeydown = (event: KeyboardEvent) => { private readonly _onInputKeydown = (event: KeyboardEvent) => {
event.stopPropagation(); event.stopPropagation();
const inputValue = this.text.value.trim(); const inputValue = this.text.value.trim();
if (event.key === 'Backspace' && inputValue === '') { 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]; 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; expose: DataViewInstance;
}>(); }>();
@property({ attribute: false }) @property({ attribute: false })
accessor config!: DataViewRendererConfig; accessor config!: DataViewRendererConfig;
private currentViewId$ = computed(() => { private readonly currentViewId$ = computed(() => {
return this.config.dataSource.viewManager.currentViewId$.value; return this.config.dataSource.viewManager.currentViewId$.value;
}); });
@ -218,7 +218,7 @@ declare global {
} }
export class DataView { export class DataView {
private _ref = createRef<DataViewRenderer>(); private readonly _ref = createRef<DataViewRenderer>();
get expose() { get expose() {
return this._ref.value?.view?.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) => { _click = (e: MouseEvent) => {
e.stopPropagation(); e.stopPropagation();

View File

@ -49,7 +49,7 @@ export class DetailSelection {
} }
} }
constructor(private viewEle: RecordDetail) {} constructor(private readonly viewEle: RecordDetail) {}
blur(selection: DetailViewSelection) { blur(selection: DetailViewSelection) {
const container = this.getFocusCellContainer(selection); 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) { if (this.readonly) {
return; return;
} }

View File

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

View File

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

View File

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

View File

@ -50,9 +50,9 @@ export class DataType<
> implements TypeDefinition > implements TypeDefinition
{ {
constructor( constructor(
private name: Name, private readonly name: Name,
_dataSchema: DataSchema, _dataSchema: DataSchema,
private valueSchema: ValueSchema private readonly valueSchema: ValueSchema
) {} ) {}
instance(literal?: Zod.TypeOf<DataSchema>) { 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> { export class Matcher<Data, Type extends TypeInstance = TypeInstance> {
constructor( constructor(
private list: MatcherData<Data, Type>[], private readonly list: MatcherData<Data, Type>[],
private _match: (type: Type, target: TypeInstance) => boolean = ( private readonly _match: (type: Type, target: TypeInstance) => boolean = (
type, type,
target target
) => typeSystem.unify(target, type) ) => typeSystem.unify(target, type)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -139,9 +139,9 @@ export abstract class SingleViewBase<
ViewData extends DataViewDataType = DataViewDataType, ViewData extends DataViewDataType = DataViewDataType,
> implements SingleView > implements SingleView
{ {
private searchString = signal(''); private readonly searchString = signal('');
private traitMap = new Map<symbol, unknown>(); private readonly traitMap = new Map<symbol, unknown>();
data$ = computed(() => { data$ = computed(() => {
return this.dataSource.viewDataGet(this.id) as ViewData | undefined; 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 _prevPortalAbortController: AbortController | null = null;
private openDatePicker = () => { private readonly openDatePicker = () => {
if ( if (
this._prevPortalAbortController && this._prevPortalAbortController &&
!this._prevPortalAbortController.signal.aborted !this._prevPortalAbortController.signal.aborted
@ -168,7 +168,7 @@ height: 46px;
} }
}; };
private updateValue = () => { private readonly updateValue = () => {
const tempValue = this.tempValue$.value; const tempValue = this.tempValue$.value;
const currentValue = this.value; const currentValue = this.value;

View File

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

View File

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

View File

@ -28,7 +28,7 @@ export class SelectCellEditing extends BaseCellRenderer<
string, string,
SelectPropertyData SelectPropertyData
> { > {
private popTagSelect = () => { private readonly popTagSelect = () => {
const value = signal(this._value); const value = signal(this._value);
this._disposables.add({ this._disposables.add({
dispose: popTagSelect( 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) { if (e.key === 'Enter' && !e.isComposing) {
this._setValue(); this._setValue();
setTimeout(() => { 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._inputEle.value = `${this.value ?? ''}`;
this.onChange(str); this.onChange(str);
}; };

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -100,7 +100,7 @@ export class DataViewKanban extends DataViewBase<
> { > {
static override styles = styles; static override styles = styles;
private dragController = new KanbanDragController(this); private readonly dragController = new KanbanDragController(this);
clipboardController = new KanbanClipboardController(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 }) @property({ attribute: false })
accessor column!: TableColumn; accessor column!: TableColumn;

View File

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

View File

@ -50,7 +50,7 @@ export class MobileTableGroup extends SignalWatcher(
) { ) {
static override styles = styles; static override styles = styles;
private clickAddRow = () => { private readonly clickAddRow = () => {
this.view.rowAdd('end', this.group?.key); this.view.rowAdd('end', this.group?.key);
requestAnimationFrame(() => { requestAnimationFrame(() => {
const selectionController = this.viewEle.selectionController; 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); this.view.rowAdd('start', this.group?.key);
requestAnimationFrame(() => { requestAnimationFrame(() => {
const selectionController = this.viewEle.selectionController; 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; const group = this.group;
if (!group) { if (!group) {
return; return;
@ -111,7 +111,7 @@ export class MobileTableGroup extends SignalWatcher(
]); ]);
}; };
private renderGroupHeader = () => { private readonly renderGroupHeader = () => {
if (!this.group) { if (!this.group) {
return null; return null;
} }

View File

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

View File

@ -45,7 +45,7 @@ export class MobileDataViewTable extends DataViewBase<
} }
`; `;
private _addRow = ( private readonly _addRow = (
tableViewManager: TableSingleView, tableViewManager: TableSingleView,
position: InsertToPosition | number 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 }) @property({ attribute: false })
accessor column!: TableColumn; accessor column!: TableColumn;

View File

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

View File

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

View File

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

View File

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

View File

@ -67,7 +67,7 @@ export class TableGroup extends SignalWatcher(
) { ) {
static override styles = styles; static override styles = styles;
private clickAddRow = () => { private readonly clickAddRow = () => {
this.view.rowAdd('end', this.group?.key); this.view.rowAdd('end', this.group?.key);
requestAnimationFrame(() => { requestAnimationFrame(() => {
const selectionController = this.viewEle.selectionController; 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); this.view.rowAdd('start', this.group?.key);
requestAnimationFrame(() => { requestAnimationFrame(() => {
const selectionController = this.viewEle.selectionController; 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; const group = this.group;
if (!group) { if (!group) {
return; return;
@ -128,7 +128,7 @@ export class TableGroup extends SignalWatcher(
]); ]);
}; };
private renderGroupHeader = () => { private readonly renderGroupHeader = () => {
if (!this.group) { if (!this.group) {
return null; return null;
} }

View File

@ -19,7 +19,7 @@ export class DatabaseColumnHeader extends SignalWatcher(
) { ) {
static override styles = styles; static override styles = styles;
private _onAddColumn = (e: MouseEvent) => { private readonly _onAddColumn = (e: MouseEvent) => {
if (this.readonly) return; if (this.readonly) return;
this.tableViewManager.propertyAdd('end'); this.tableViewManager.propertyAdd('end');
const ele = e.currentTarget as HTMLElement; 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) { if (this.tableViewManager.readonly$.value) {
return; return;
} }
this.popMenu(); this.popMenu();
}; };
private _clickTypeIcon = (event: MouseEvent) => { private readonly _clickTypeIcon = (event: MouseEvent) => {
if (this.tableViewManager.readonly$.value) { if (this.tableViewManager.readonly$.value) {
return; return;
} }
@ -96,7 +96,7 @@ export class DatabaseHeaderColumn extends SignalWatcher(
}); });
}; };
private _contextMenu = (e: MouseEvent) => { private readonly _contextMenu = (e: MouseEvent) => {
if (this.tableViewManager.readonly$.value) { if (this.tableViewManager.readonly$.value) {
return; return;
} }
@ -104,7 +104,7 @@ export class DatabaseHeaderColumn extends SignalWatcher(
this.popMenu(e.currentTarget as HTMLElement); this.popMenu(e.currentTarget as HTMLElement);
}; };
private _enterWidthDragBar = () => { private readonly _enterWidthDragBar = () => {
if (this.tableViewManager.readonly$.value) { if (this.tableViewManager.readonly$.value) {
return; return;
} }
@ -115,13 +115,13 @@ export class DatabaseHeaderColumn extends SignalWatcher(
this.drawWidthDragBar(); this.drawWidthDragBar();
}; };
private _leaveWidthDragBar = () => { private readonly _leaveWidthDragBar = () => {
cancelAnimationFrame(this.drawWidthDragBarTask); cancelAnimationFrame(this.drawWidthDragBarTask);
this.drawWidthDragBarTask = 0; this.drawWidthDragBarTask = 0;
getVerticalIndicator().remove(); getVerticalIndicator().remove();
}; };
private drawWidthDragBar = () => { private readonly drawWidthDragBar = () => {
const rect = getTableGroupRect(this); const rect = getTableGroupRect(this);
if (!rect) { if (!rect) {
return; return;
@ -136,7 +136,7 @@ export class DatabaseHeaderColumn extends SignalWatcher(
private drawWidthDragBarTask = 0; private drawWidthDragBarTask = 0;
private widthDragBar = createRef(); private readonly widthDragBar = createRef();
editTitle = () => { editTitle = () => {
this._clickColumn(); this._clickColumn();

View File

@ -87,14 +87,14 @@ export class DatabaseNumberFormatBar extends WithDisposable(LitElement) {
} }
`; `;
private _decrementDecimalPlaces = () => { private readonly _decrementDecimalPlaces = () => {
this.column.dataUpdate(data => ({ this.column.dataUpdate(data => ({
decimal: Math.max(((data.decimal as number) ?? 0) - 1, 0), decimal: Math.max(((data.decimal as number) ?? 0) - 1, 0),
})); }));
this.requestUpdate(); this.requestUpdate();
}; };
private _incrementDecimalPlaces = () => { private readonly _incrementDecimalPlaces = () => {
this.column.dataUpdate(data => ({ this.column.dataUpdate(data => ({
decimal: Math.min(((data.decimal as number) ?? 0) + 1, 8), 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) { if (this.view.readonly$.value) {
return; return;
} }

View File

@ -39,7 +39,7 @@ export class TableSingleView extends SingleViewBase<TableViewData> {
return result; return result;
}); });
private computedColumns$ = computed(() => { private readonly computedColumns$ = computed(() => {
return this.propertiesWithoutFilter$.value.map(id => { return this.propertiesWithoutFilter$.value.map(id => {
const column = this.propertyGet(id); const column = this.propertyGet(id);
return { return {
@ -51,19 +51,19 @@ export class TableSingleView extends SingleViewBase<TableViewData> {
}); });
}); });
private filter$ = computed(() => { private readonly filter$ = computed(() => {
return this.data$.value?.filter ?? emptyFilterGroup; return this.data$.value?.filter ?? emptyFilterGroup;
}); });
private groupBy$ = computed(() => { private readonly groupBy$ = computed(() => {
return this.data$.value?.groupBy; return this.data$.value?.groupBy;
}); });
private sortList$ = computed(() => { private readonly sortList$ = computed(() => {
return this.data$.value?.sort; return this.data$.value?.sort;
}); });
private sortManager = this.traitSet( private readonly sortManager = this.traitSet(
sortTraitKey, sortTraitKey,
new SortManager(this.sortList$, this, { new SortManager(this.sortList$, this, {
setSortList: sortList => { setSortList: sortList => {
@ -385,7 +385,7 @@ export class TableColumn extends PropertyBase {
} }
constructor( constructor(
private tableView: TableSingleView, private readonly tableView: TableSingleView,
columnId: string columnId: string
) { ) {
super(tableView as SingleView, columnId); 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( this.popConditionEdit(
popupTargetFromElement(evt.currentTarget as HTMLElement) popupTargetFromElement(evt.currentTarget as HTMLElement)
); );
}; };
private popConditionEdit = (target: PopupTarget) => { private readonly popConditionEdit = (target: PopupTarget) => {
const type = this.leftVar$.value?.type; const type = this.leftVar$.value?.type;
if (!type) { if (!type) {
return; 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) { if (this.isMaxDepth) {
this.onChange({ this.onChange({
...this.filterGroup.value, ...this.filterGroup.value,
@ -202,7 +202,7 @@ export class FilterGroupView extends SignalWatcher(ShadowlessElement) {
}); });
}; };
private _selectOp = (event: MouseEvent) => { private readonly _selectOp = (event: MouseEvent) => {
popFilterableSimpleMenu( popFilterableSimpleMenu(
popupTargetFromElement(event.currentTarget as HTMLElement), 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.onChange({
...this.filterGroup.value, ...this.filterGroup.value,
conditions: this.filterGroup.value.conditions.map((v, i) => 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', and: 'And',
or: 'Or', 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.onChange({
...this.filterGroup.value, ...this.filterGroup.value,
conditions: this.filterGroup.value.conditions.map((v, i) => 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); const element = popupTargetFromElement(e.target as HTMLElement);
popCreateFilter(element, { popCreateFilter(element, {
vars: this.vars, 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') { if (this.filterGroup.value.conditions[i]?.type !== 'group') {
return; 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.onChange({
...this.filterGroup.value, ...this.filterGroup.value,
conditions: this.filterGroup.value.conditions.map((v, i) => 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') { if (this.filterGroup.value.conditions[i]?.type !== 'group') {
return; return;
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -78,9 +78,9 @@ function customizer(_target: unknown, source: unknown) {
export class EditPropsStore extends LifeCycleWatcher { export class EditPropsStore extends LifeCycleWatcher {
static override key = 'EditPropsStore'; 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>; lastProps$: Signal<LastProps>;

View File

@ -23,7 +23,7 @@ export class EmbedOptionService
extends Extension extends Extension
implements EmbedOptionProvider implements EmbedOptionProvider
{ {
private _embedBlockRegistry = new Set<EmbedOptions>(); private readonly _embedBlockRegistry = new Set<EmbedOptions>();
getEmbedBlockOptions = (url: string): EmbedOptions | null => { getEmbedBlockOptions = (url: string): EmbedOptions | null => {
const entries = this._embedBlockRegistry.entries(); 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$; return isInsideEdgelessEditor(this.std.host) ? this.edgeless$ : this.app$;
} }
constructor(private std: BlockStdScope) { constructor(private readonly std: BlockStdScope) {
super(); super();
const extension = this.std.getOptional(ThemeExtensionIdentifier); const extension = this.std.getOptional(ThemeExtensionIdentifier);
this.app$ = extension?.getAppTheme?.() || getThemeObserver().theme$; this.app$ = extension?.getAppTheme?.() || getThemeObserver().theme$;
@ -172,7 +172,7 @@ export class ThemeService extends Extension {
} }
export class ThemeObserver { export class ThemeObserver {
private observer: MutationObserver; private readonly observer: MutationObserver;
theme$ = signal(ColorScheme.Light); theme$ = signal(ColorScheme.Light);

View File

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

View File

@ -54,9 +54,11 @@ export class AffineScrollAnchoringWidget extends WidgetComponent {
#listened = false; #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); anchor$ = signal<Anchor | null>(null);

View File

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

View File

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

View File

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

View File

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

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