mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
chore: fix eslint in blocksuite (#9232)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -38,7 +38,7 @@ type MixTextToSliceSnapshotPayload = {
|
||||
};
|
||||
|
||||
export class MixTextAdapter extends BaseAdapter<MixText> {
|
||||
private _markdownAdapter: MarkdownAdapter;
|
||||
private readonly _markdownAdapter: MarkdownAdapter;
|
||||
|
||||
constructor(job: Job) {
|
||||
super(job);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -48,7 +48,7 @@ export class AIItemList extends WithDisposable(LitElement) {
|
||||
|
||||
private _activeSubMenuItem: AIItemConfig | null = null;
|
||||
|
||||
private _closeSubMenu = () => {
|
||||
private readonly _closeSubMenu = () => {
|
||||
if (this._abortController) {
|
||||
this._abortController.abort();
|
||||
this._abortController = null;
|
||||
@@ -56,11 +56,11 @@ export class AIItemList extends WithDisposable(LitElement) {
|
||||
this._activeSubMenuItem = null;
|
||||
};
|
||||
|
||||
private _itemClassName = (item: AIItemConfig) => {
|
||||
private readonly _itemClassName = (item: AIItemConfig) => {
|
||||
return 'ai-item-' + item.name.split(' ').join('-').toLocaleLowerCase();
|
||||
};
|
||||
|
||||
private _openSubMenu = (item: AIItemConfig) => {
|
||||
private readonly _openSubMenu = (item: AIItemConfig) => {
|
||||
if (!item.subItem || item.subItem.length === 0) {
|
||||
this._closeSubMenu();
|
||||
return;
|
||||
|
||||
@@ -45,7 +45,7 @@ export class AISubItemList extends WithDisposable(LitElement) {
|
||||
${menuItemStyles}
|
||||
`;
|
||||
|
||||
private _handleClick = (subItem: AISubItemConfig) => {
|
||||
private readonly _handleClick = (subItem: AISubItemConfig) => {
|
||||
this.onClick?.();
|
||||
if (subItem.handler) {
|
||||
// TODO: add parameters to ai handler
|
||||
|
||||
@@ -22,11 +22,11 @@ import { embedCardModalStyles } from './styles.js';
|
||||
export class EmbedCardCreateModal extends WithDisposable(ShadowlessElement) {
|
||||
static override styles = embedCardModalStyles;
|
||||
|
||||
private _onCancel = () => {
|
||||
private readonly _onCancel = () => {
|
||||
this.remove();
|
||||
};
|
||||
|
||||
private _onConfirm = () => {
|
||||
private readonly _onConfirm = () => {
|
||||
const url = this.input.value;
|
||||
|
||||
if (!isValidUrl(url)) {
|
||||
@@ -91,7 +91,7 @@ export class EmbedCardCreateModal extends WithDisposable(ShadowlessElement) {
|
||||
this.remove();
|
||||
};
|
||||
|
||||
private _onDocumentKeydown = (e: KeyboardEvent) => {
|
||||
private readonly _onDocumentKeydown = (e: KeyboardEvent) => {
|
||||
e.stopPropagation();
|
||||
if (e.key === 'Enter' && !e.isComposing) {
|
||||
this._onConfirm();
|
||||
|
||||
@@ -144,11 +144,11 @@ export class EmbedCardEditModal extends SignalWatcher(
|
||||
|
||||
private _blockComponent: BlockComponent | null = null;
|
||||
|
||||
private _hide = () => {
|
||||
private readonly _hide = () => {
|
||||
this.remove();
|
||||
};
|
||||
|
||||
private _onKeydown = (e: KeyboardEvent) => {
|
||||
private readonly _onKeydown = (e: KeyboardEvent) => {
|
||||
e.stopPropagation();
|
||||
if (e.key === 'Enter' && !(e.isComposing || e.shiftKey)) {
|
||||
this._onSave();
|
||||
@@ -159,7 +159,7 @@ export class EmbedCardEditModal extends SignalWatcher(
|
||||
}
|
||||
};
|
||||
|
||||
private _onReset = () => {
|
||||
private readonly _onReset = () => {
|
||||
const blockComponent = this._blockComponent;
|
||||
|
||||
if (!blockComponent) {
|
||||
@@ -186,7 +186,7 @@ export class EmbedCardEditModal extends SignalWatcher(
|
||||
this.remove();
|
||||
};
|
||||
|
||||
private _onSave = () => {
|
||||
private readonly _onSave = () => {
|
||||
const blockComponent = this._blockComponent;
|
||||
|
||||
if (!blockComponent) {
|
||||
@@ -224,12 +224,12 @@ export class EmbedCardEditModal extends SignalWatcher(
|
||||
this.remove();
|
||||
};
|
||||
|
||||
private _updateDescription = (e: InputEvent) => {
|
||||
private readonly _updateDescription = (e: InputEvent) => {
|
||||
const target = e.target as HTMLTextAreaElement;
|
||||
this.description$.value = target.value;
|
||||
};
|
||||
|
||||
private _updateTitle = (e: InputEvent) => {
|
||||
private readonly _updateTitle = (e: InputEvent) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
this.title$.value = target.value;
|
||||
};
|
||||
|
||||
@@ -31,13 +31,13 @@ export type FileDropOptions = {
|
||||
export class FileDropManager {
|
||||
private static _dropResult: DropResult | null = null;
|
||||
|
||||
private _blockService: BlockService;
|
||||
private readonly _blockService: BlockService;
|
||||
|
||||
private _fileDropOptions: FileDropOptions;
|
||||
private readonly _fileDropOptions: FileDropOptions;
|
||||
|
||||
private _indicator!: DragIndicator;
|
||||
private readonly _indicator!: DragIndicator;
|
||||
|
||||
private _onDrop = (event: DragEvent) => {
|
||||
private readonly _onDrop = (event: DragEvent) => {
|
||||
this._indicator.rect = null;
|
||||
|
||||
const { onDrop } = this._fileDropOptions;
|
||||
|
||||
@@ -64,7 +64,7 @@ export class SmoothCorner extends LitElement {
|
||||
}
|
||||
`;
|
||||
|
||||
private _resizeObserver: ResizeObserver | null = null;
|
||||
private readonly _resizeObserver: ResizeObserver | null = null;
|
||||
|
||||
get _path() {
|
||||
return getFigmaSquircleSvgPath({
|
||||
|
||||
@@ -137,16 +137,18 @@ export const quickActionConfig: QuickActionConfig[] = [
|
||||
|
||||
const doc = host.doc;
|
||||
const autofill = getTitleFromSelectedModels(selectedModels);
|
||||
void promptDocTitle(host, autofill).then(title => {
|
||||
if (title === null) return;
|
||||
convertSelectedBlocksToLinkedDoc(
|
||||
host.std,
|
||||
doc,
|
||||
draftedModels,
|
||||
title
|
||||
).catch(console.error);
|
||||
notifyDocCreated(host, doc);
|
||||
});
|
||||
promptDocTitle(host, autofill)
|
||||
.then(title => {
|
||||
if (title === null) return;
|
||||
convertSelectedBlocksToLinkedDoc(
|
||||
host.std,
|
||||
doc,
|
||||
draftedModels,
|
||||
title
|
||||
).catch(console.error);
|
||||
notifyDocCreated(host, doc);
|
||||
})
|
||||
.catch(console.error);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -44,11 +44,11 @@ export type ExportOptions = {
|
||||
imageProxyEndpoint: string;
|
||||
};
|
||||
export class ExportManager {
|
||||
private _exportOptions: ExportOptions = {
|
||||
private readonly _exportOptions: ExportOptions = {
|
||||
imageProxyEndpoint: DEFAULT_IMAGE_PROXY_ENDPOINT,
|
||||
};
|
||||
|
||||
private _replaceRichTextWithSvgElement = (element: HTMLElement) => {
|
||||
private readonly _replaceRichTextWithSvgElement = (element: HTMLElement) => {
|
||||
const richList = Array.from(element.querySelectorAll('.inline-editor'));
|
||||
richList.forEach(rich => {
|
||||
const svgEle = this._elementToSvgElement(
|
||||
|
||||
@@ -8,7 +8,7 @@ export class Zip {
|
||||
|
||||
private finalized = false;
|
||||
|
||||
private zip = new fflate.Zip((err, chunk, final) => {
|
||||
private readonly zip = new fflate.Zip((err, chunk, final) => {
|
||||
if (!err) {
|
||||
const temp = new Uint8Array(this.compressed.length + chunk.length);
|
||||
temp.set(this.compressed);
|
||||
|
||||
Reference in New Issue
Block a user