mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 06:18:45 +08:00
chore: fix eslint in blocksuite (#9232)
This commit is contained in:
@@ -14,7 +14,7 @@ export class EdgelessAddFrameButton extends WithDisposable(LitElement) {
|
||||
}
|
||||
`;
|
||||
|
||||
private _createFrame = () => {
|
||||
private readonly _createFrame = () => {
|
||||
const frame = this.edgeless.service.frame.createFrameOnSelected();
|
||||
if (!frame) return;
|
||||
this.edgeless.std
|
||||
|
||||
@@ -16,7 +16,7 @@ export class EdgelessAddGroupButton extends WithDisposable(LitElement) {
|
||||
}
|
||||
`;
|
||||
|
||||
private _createGroup = () => {
|
||||
private readonly _createGroup = () => {
|
||||
this.edgeless.service.createGroupFromSelected();
|
||||
};
|
||||
|
||||
|
||||
+3
-3
@@ -23,11 +23,11 @@ import { attachmentViewToggleMenu } from '../../../attachment-block/index.js';
|
||||
import type { EdgelessRootBlockComponent } from '../../edgeless/edgeless-root-block.js';
|
||||
|
||||
export class EdgelessChangeAttachmentButton extends WithDisposable(LitElement) {
|
||||
private _download = () => {
|
||||
private readonly _download = () => {
|
||||
this._block?.download();
|
||||
};
|
||||
|
||||
private _setCardStyle = (style: EmbedCardStyle) => {
|
||||
private readonly _setCardStyle = (style: EmbedCardStyle) => {
|
||||
const bounds = Bound.deserialize(this.model.xywh);
|
||||
bounds.w = EMBED_CARD_WIDTH[style];
|
||||
bounds.h = EMBED_CARD_HEIGHT[style];
|
||||
@@ -35,7 +35,7 @@ export class EdgelessChangeAttachmentButton extends WithDisposable(LitElement) {
|
||||
this.model.doc.updateBlock(this.model, { style, xywh });
|
||||
};
|
||||
|
||||
private _showCaption = () => {
|
||||
private readonly _showCaption = () => {
|
||||
this._block?.captionEditor?.show();
|
||||
};
|
||||
|
||||
|
||||
@@ -44,12 +44,12 @@ function notEqual<K extends keyof BrushProps>(key: K, value: BrushProps[K]) {
|
||||
}
|
||||
|
||||
export class EdgelessChangeBrushButton extends WithDisposable(LitElement) {
|
||||
private _setBrushColor = ({ detail: color }: ColorEvent) => {
|
||||
private readonly _setBrushColor = ({ detail: color }: ColorEvent) => {
|
||||
this._setBrushProp('color', color);
|
||||
this._selectedColor = color;
|
||||
};
|
||||
|
||||
private _setLineWidth = ({ detail: lineWidth }: LineWidthEvent) => {
|
||||
private readonly _setLineWidth = ({ detail: lineWidth }: LineWidthEvent) => {
|
||||
this._setBrushProp('lineWidth', lineWidth);
|
||||
this._selectedSize = lineWidth;
|
||||
};
|
||||
|
||||
+13
-13
@@ -112,7 +112,7 @@ export class EdgelessChangeEmbedCardButton extends WithDisposable(LitElement) {
|
||||
}
|
||||
`;
|
||||
|
||||
private _convertToCardView = () => {
|
||||
private readonly _convertToCardView = () => {
|
||||
if (this._isCardView) {
|
||||
return;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ export class EdgelessChangeEmbedCardButton extends WithDisposable(LitElement) {
|
||||
this._doc.deleteBlock(this.model);
|
||||
};
|
||||
|
||||
private _convertToEmbedView = () => {
|
||||
private readonly _convertToEmbedView = () => {
|
||||
if (this._isEmbedView) {
|
||||
return;
|
||||
}
|
||||
@@ -217,7 +217,7 @@ export class EdgelessChangeEmbedCardButton extends WithDisposable(LitElement) {
|
||||
this._doc.deleteBlock(this.model);
|
||||
};
|
||||
|
||||
private _copyUrl = () => {
|
||||
private readonly _copyUrl = () => {
|
||||
let url!: ReturnType<GenerateDocUrlService['generateDocUrl']>;
|
||||
|
||||
if ('url' in this.model) {
|
||||
@@ -241,7 +241,7 @@ export class EdgelessChangeEmbedCardButton extends WithDisposable(LitElement) {
|
||||
|
||||
private _embedOptions: EmbedOptions | null = null;
|
||||
|
||||
private _getScale = () => {
|
||||
private readonly _getScale = () => {
|
||||
if ('scale' in this.model) {
|
||||
return this.model.scale ?? 1;
|
||||
} else if (isEmbedHtmlBlock(this.model)) {
|
||||
@@ -252,11 +252,11 @@ export class EdgelessChangeEmbedCardButton extends WithDisposable(LitElement) {
|
||||
return bound.h / EMBED_CARD_HEIGHT[this.model.style];
|
||||
};
|
||||
|
||||
private _open = () => {
|
||||
private readonly _open = () => {
|
||||
this._blockComponent?.open();
|
||||
};
|
||||
|
||||
private _openEditPopup = (e: MouseEvent) => {
|
||||
private readonly _openEditPopup = (e: MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
|
||||
if (isEmbedHtmlBlock(this.model)) return;
|
||||
@@ -277,12 +277,12 @@ export class EdgelessChangeEmbedCardButton extends WithDisposable(LitElement) {
|
||||
});
|
||||
};
|
||||
|
||||
private _peek = () => {
|
||||
private readonly _peek = () => {
|
||||
if (!this._blockComponent) return;
|
||||
peek(this._blockComponent);
|
||||
};
|
||||
|
||||
private _setCardStyle = (style: EmbedCardStyle) => {
|
||||
private readonly _setCardStyle = (style: EmbedCardStyle) => {
|
||||
const bounds = Bound.deserialize(this.model.xywh);
|
||||
bounds.w = EMBED_CARD_WIDTH[style];
|
||||
bounds.h = EMBED_CARD_HEIGHT[style];
|
||||
@@ -295,7 +295,7 @@ export class EdgelessChangeEmbedCardButton extends WithDisposable(LitElement) {
|
||||
});
|
||||
};
|
||||
|
||||
private _setEmbedScale = (scale: number) => {
|
||||
private readonly _setEmbedScale = (scale: number) => {
|
||||
if (isEmbedHtmlBlock(this.model)) return;
|
||||
|
||||
const bound = Bound.deserialize(this.model.xywh);
|
||||
@@ -320,7 +320,7 @@ export class EdgelessChangeEmbedCardButton extends WithDisposable(LitElement) {
|
||||
});
|
||||
};
|
||||
|
||||
private _toggleCardScaleSelector = (e: Event) => {
|
||||
private readonly _toggleCardScaleSelector = (e: Event) => {
|
||||
const opened = (e as CustomEvent<boolean>).detail;
|
||||
if (!opened) return;
|
||||
|
||||
@@ -329,7 +329,7 @@ export class EdgelessChangeEmbedCardButton extends WithDisposable(LitElement) {
|
||||
});
|
||||
};
|
||||
|
||||
private _toggleCardStyleSelector = (e: Event) => {
|
||||
private readonly _toggleCardStyleSelector = (e: Event) => {
|
||||
const opened = (e as CustomEvent<boolean>).detail;
|
||||
if (!opened) return;
|
||||
|
||||
@@ -338,7 +338,7 @@ export class EdgelessChangeEmbedCardButton extends WithDisposable(LitElement) {
|
||||
});
|
||||
};
|
||||
|
||||
private _toggleViewSelector = (e: Event) => {
|
||||
private readonly _toggleViewSelector = (e: Event) => {
|
||||
const opened = (e as CustomEvent<boolean>).detail;
|
||||
if (!opened) return;
|
||||
|
||||
@@ -347,7 +347,7 @@ export class EdgelessChangeEmbedCardButton extends WithDisposable(LitElement) {
|
||||
});
|
||||
};
|
||||
|
||||
private _trackViewSelected = (type: string) => {
|
||||
private readonly _trackViewSelected = (type: string) => {
|
||||
track(this.std, this.model, this._viewType, 'SelectedView', {
|
||||
control: 'select view',
|
||||
type: `${type} view`,
|
||||
|
||||
@@ -9,12 +9,12 @@ import { downloadImageBlob } from '../../../image-block/utils.js';
|
||||
import type { EdgelessRootBlockComponent } from '../../edgeless/edgeless-root-block.js';
|
||||
|
||||
export class EdgelessChangeImageButton extends WithDisposable(LitElement) {
|
||||
private _download = () => {
|
||||
private readonly _download = () => {
|
||||
if (!this._blockComponent) return;
|
||||
downloadImageBlob(this._blockComponent).catch(console.error);
|
||||
};
|
||||
|
||||
private _showCaption = () => {
|
||||
private readonly _showCaption = () => {
|
||||
this._blockComponent?.captionEditor?.show();
|
||||
};
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ export class EdgelessChangeMindmapLayoutPanel extends LitElement {
|
||||
}
|
||||
|
||||
export class EdgelessChangeMindmapButton extends WithDisposable(LitElement) {
|
||||
private _updateLayoutType = (layoutType: LayoutType) => {
|
||||
private readonly _updateLayoutType = (layoutType: LayoutType) => {
|
||||
this.edgeless.std.get(EditPropsStore).recordLastProps('mindmap', {
|
||||
layoutType,
|
||||
});
|
||||
@@ -166,7 +166,7 @@ export class EdgelessChangeMindmapButton extends WithDisposable(LitElement) {
|
||||
this.layoutType = layoutType;
|
||||
};
|
||||
|
||||
private _updateStyle = (style: MindmapStyle) => {
|
||||
private readonly _updateStyle = (style: MindmapStyle) => {
|
||||
this.edgeless.std.get(EditPropsStore).recordLastProps('mindmap', { style });
|
||||
this._mindmaps.forEach(element => (element.style = style));
|
||||
};
|
||||
|
||||
@@ -78,7 +78,7 @@ function getMostCommonBackground(
|
||||
}
|
||||
|
||||
export class EdgelessChangeNoteButton extends WithDisposable(LitElement) {
|
||||
private _setBorderRadius = (borderRadius: number) => {
|
||||
private readonly _setBorderRadius = (borderRadius: number) => {
|
||||
this.notes.forEach(note => {
|
||||
const props = {
|
||||
edgeless: {
|
||||
@@ -92,7 +92,7 @@ export class EdgelessChangeNoteButton extends WithDisposable(LitElement) {
|
||||
});
|
||||
};
|
||||
|
||||
private _setNoteScale = (scale: number) => {
|
||||
private readonly _setNoteScale = (scale: number) => {
|
||||
this.notes.forEach(note => {
|
||||
this.doc.updateBlock(note, () => {
|
||||
const bound = Bound.deserialize(note.xywh);
|
||||
|
||||
@@ -176,7 +176,7 @@ export class EdgelessChangeTextMenu extends WithDisposable(LitElement) {
|
||||
}
|
||||
`;
|
||||
|
||||
private _setFontFamily = (fontFamily: FontFamily) => {
|
||||
private readonly _setFontFamily = (fontFamily: FontFamily) => {
|
||||
const currentFontWeight = getMostCommonFontWeight(this.elements);
|
||||
const fontWeight = TextUtils.isFontWeightSupported(
|
||||
fontFamily,
|
||||
@@ -199,7 +199,7 @@ export class EdgelessChangeTextMenu extends WithDisposable(LitElement) {
|
||||
});
|
||||
};
|
||||
|
||||
private _setFontSize = (fontSize: number) => {
|
||||
private readonly _setFontSize = (fontSize: number) => {
|
||||
const props = { fontSize };
|
||||
this.elements.forEach(element => {
|
||||
this.service.updateElement(element.id, buildProps(element, props));
|
||||
@@ -207,7 +207,7 @@ export class EdgelessChangeTextMenu extends WithDisposable(LitElement) {
|
||||
});
|
||||
};
|
||||
|
||||
private _setFontWeightAndStyle = (
|
||||
private readonly _setFontWeightAndStyle = (
|
||||
fontWeight: FontWeight,
|
||||
fontStyle: FontStyle
|
||||
) => {
|
||||
@@ -218,21 +218,23 @@ export class EdgelessChangeTextMenu extends WithDisposable(LitElement) {
|
||||
});
|
||||
};
|
||||
|
||||
private _setTextAlign = (textAlign: TextAlign) => {
|
||||
private readonly _setTextAlign = (textAlign: TextAlign) => {
|
||||
const props = { textAlign };
|
||||
this.elements.forEach(element => {
|
||||
this.service.updateElement(element.id, buildProps(element, props));
|
||||
});
|
||||
};
|
||||
|
||||
private _setTextColor = ({ detail: color }: ColorEvent) => {
|
||||
private readonly _setTextColor = ({ detail: color }: ColorEvent) => {
|
||||
const props = { color };
|
||||
this.elements.forEach(element => {
|
||||
this.service.updateElement(element.id, buildProps(element, props));
|
||||
});
|
||||
};
|
||||
|
||||
private _updateElementBound = (element: BlockSuite.EdgelessTextModelType) => {
|
||||
private readonly _updateElementBound = (
|
||||
element: BlockSuite.EdgelessTextModelType
|
||||
) => {
|
||||
const elementType = this.elementType;
|
||||
if (elementType === 'text' && element instanceof TextElementModel) {
|
||||
// the change of font family will change the bound of the text
|
||||
|
||||
@@ -112,7 +112,7 @@ export class EdgelessElementToolbarWidget extends WidgetComponent<
|
||||
}
|
||||
`;
|
||||
|
||||
private _quickConnect = ({ x, y }: MouseEvent) => {
|
||||
private readonly _quickConnect = ({ x, y }: MouseEvent) => {
|
||||
const element = this.selection.selectedElements[0];
|
||||
const point = this.edgeless.service.viewport.toViewCoordFromClientCoord([
|
||||
x,
|
||||
@@ -127,7 +127,9 @@ export class EdgelessElementToolbarWidget extends WidgetComponent<
|
||||
ctc.quickConnect(point, element);
|
||||
};
|
||||
|
||||
private _updateOnSelectedChange = (element: string | { id: string }) => {
|
||||
private readonly _updateOnSelectedChange = (
|
||||
element: string | { id: string }
|
||||
) => {
|
||||
const id = typeof element === 'string' ? element : element.id;
|
||||
|
||||
if (this.isConnected && !this._dragging && this.selection.has(id)) {
|
||||
|
||||
@@ -20,13 +20,13 @@ import {
|
||||
} from '../../../edgeless/utils/query.js';
|
||||
|
||||
export class ElementToolbarMoreMenuContext extends MenuContext {
|
||||
#empty = true;
|
||||
readonly #empty: boolean;
|
||||
|
||||
#includedFrame = false;
|
||||
readonly #includedFrame: boolean;
|
||||
|
||||
#multiple = false;
|
||||
readonly #multiple: boolean;
|
||||
|
||||
#single = false;
|
||||
readonly #single: boolean;
|
||||
|
||||
edgeless!: EdgelessRootBlockComponent;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user