refactor(editor): cleanup ts-expect-error (#9369)
This commit is contained in:
@@ -34,7 +34,7 @@ export const insertLinkByQuickSearchCommand: Command<
|
|||||||
|
|
||||||
// add normal link;
|
// add normal link;
|
||||||
if ('externalUrl' in result) {
|
if ('externalUrl' in result) {
|
||||||
// @ts-expect-error TODO: fix after bookmark refactor
|
// @ts-expect-error FIXME: fix after bookmark refactor
|
||||||
std.command.exec('insertBookmark', { url: result.externalUrl });
|
std.command.exec('insertBookmark', { url: result.externalUrl });
|
||||||
return {
|
return {
|
||||||
flavour: 'affine:bookmark',
|
flavour: 'affine:bookmark',
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ export async function copyImageBlob(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error FIXME: BS-2239
|
||||||
if (window.apis?.clipboard?.copyAsImageFromString) {
|
if (window.apis?.clipboard?.copyAsImageFromString) {
|
||||||
const dataURL = await convertToString(blob);
|
const dataURL = await convertToString(blob);
|
||||||
if (!dataURL)
|
if (!dataURL)
|
||||||
@@ -250,7 +250,7 @@ export async function copyImageBlob(
|
|||||||
ErrorCode.DefaultRuntimeError,
|
ErrorCode.DefaultRuntimeError,
|
||||||
'Cant convert a blob to data URL.'
|
'Cant convert a blob to data URL.'
|
||||||
);
|
);
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error FIXME: BS-2239
|
||||||
await window.apis.clipboard?.copyAsImageFromString(dataURL);
|
await window.apis.clipboard?.copyAsImageFromString(dataURL);
|
||||||
} else {
|
} else {
|
||||||
// DOMException: Type image/jpeg not supported on write.
|
// DOMException: Type image/jpeg not supported on write.
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export class LatexBlockComponent extends CaptionedBlockComponent<LatexBlockModel
|
|||||||
const latex = this.model.latex$.value;
|
const latex = this.model.latex$.value;
|
||||||
|
|
||||||
katexContainer.replaceChildren();
|
katexContainer.replaceChildren();
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error lit hack won't fix
|
||||||
delete katexContainer['_$litPart$'];
|
delete katexContainer['_$litPart$'];
|
||||||
|
|
||||||
if (latex.length === 0) {
|
if (latex.length === 0) {
|
||||||
@@ -60,7 +60,7 @@ export class LatexBlockComponent extends CaptionedBlockComponent<LatexBlockModel
|
|||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
katexContainer.replaceChildren();
|
katexContainer.replaceChildren();
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error lit hack won't fix
|
||||||
delete katexContainer['_$litPart$'];
|
delete katexContainer['_$litPart$'];
|
||||||
render(
|
render(
|
||||||
html`<span class="latex-block-error-placeholder"
|
html`<span class="latex-block-error-placeholder"
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export function forwardDelete(std: BlockStdScope) {
|
|||||||
const ignoreForwardDeleteFlavourList: BlockSuite.Flavour[] = [
|
const ignoreForwardDeleteFlavourList: BlockSuite.Flavour[] = [
|
||||||
'affine:attachment',
|
'affine:attachment',
|
||||||
'affine:bookmark',
|
'affine:bookmark',
|
||||||
// @ts-expect-error TODO: should be fixed after database model is migrated to affine-models
|
// @ts-expect-error FIXME: should be fixed after database model is migrated to affine-models
|
||||||
'affine:database',
|
'affine:database',
|
||||||
'affine:code',
|
'affine:code',
|
||||||
'affine:image',
|
'affine:image',
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export function mergeWithPrev(editorHost: EditorHost, model: BlockModel) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-expect-error TODO: should be fixed after database model is migrated to affine-models
|
// @ts-expect-error FIXME: should be fixed after database model is migrated to affine-models
|
||||||
if (matchFlavours(parent, ['affine:database'])) {
|
if (matchFlavours(parent, ['affine:database'])) {
|
||||||
doc.deleteBlock(model);
|
doc.deleteBlock(model);
|
||||||
focusTextModel(editorHost.std, prevBlock.id, prevBlock.text?.yText.length);
|
focusTextModel(editorHost.std, prevBlock.id, prevBlock.text?.yText.length);
|
||||||
|
|||||||
@@ -482,7 +482,7 @@ export const LatexExtension = InlineMarkdownExtension({
|
|||||||
if (!latexBlock || latexBlock.flavour !== 'affine:latex') return;
|
if (!latexBlock || latexBlock.flavour !== 'affine:latex') return;
|
||||||
|
|
||||||
//FIXME(@Flrande): wait for refactor
|
//FIXME(@Flrande): wait for refactor
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error BS-2241
|
||||||
latexBlock.toggleEditor();
|
latexBlock.toggleEditor();
|
||||||
})
|
})
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
|
|||||||
@@ -58,10 +58,7 @@ export class AffineLatexNode extends SignalWatcher(
|
|||||||
gap: 10px;
|
gap: 10px;
|
||||||
|
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
background: ${
|
background: ${unsafeCSSVarV2('chip/label/red')};
|
||||||
// @ts-expect-error FIXME: ts error
|
|
||||||
unsafeCSSVarV2('label/red')
|
|
||||||
};
|
|
||||||
|
|
||||||
color: ${unsafeCSSVarV2('text/highlight/fg/red')};
|
color: ${unsafeCSSVarV2('text/highlight/fg/red')};
|
||||||
font-family: Inter;
|
font-family: Inter;
|
||||||
@@ -126,7 +123,7 @@ export class AffineLatexNode extends SignalWatcher(
|
|||||||
if (!latexContainer) return;
|
if (!latexContainer) return;
|
||||||
|
|
||||||
latexContainer.replaceChildren();
|
latexContainer.replaceChildren();
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error lit hack won't fix
|
||||||
delete latexContainer['_$litPart$'];
|
delete latexContainer['_$litPart$'];
|
||||||
|
|
||||||
if (latex.length === 0) {
|
if (latex.length === 0) {
|
||||||
@@ -142,7 +139,7 @@ export class AffineLatexNode extends SignalWatcher(
|
|||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
latexContainer.replaceChildren();
|
latexContainer.replaceChildren();
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error lit hack won't fix
|
||||||
delete latexContainer['_$litPart$'];
|
delete latexContainer['_$litPart$'];
|
||||||
render(
|
render(
|
||||||
html`<span class="error-placeholder">Error equation</span>`,
|
html`<span class="error-placeholder">Error equation</span>`,
|
||||||
|
|||||||
@@ -110,8 +110,7 @@ const compareAny = (a: unknown, b: unknown) => {
|
|||||||
if (!b) {
|
if (!b) {
|
||||||
return Compare.LT;
|
return Compare.LT;
|
||||||
}
|
}
|
||||||
// @ts-expect-error FIXME: ts error
|
return Number(a) - Number(b);
|
||||||
return a - b;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const compareTag = (type: DataTypeOf<typeof t.tag>, a: unknown, b: unknown) => {
|
const compareTag = (type: DataTypeOf<typeof t.tag>, a: unknown, b: unknown) => {
|
||||||
|
|||||||
@@ -499,10 +499,9 @@ export const mindmapStyleGetters: Record<MindmapStyle, MindmapStyleGetter> = {
|
|||||||
|
|
||||||
export const applyNodeStyle = (node: MindmapNode, nodeStyle: NodeStyle) => {
|
export const applyNodeStyle = (node: MindmapNode, nodeStyle: NodeStyle) => {
|
||||||
Object.entries(nodeStyle).forEach(([key, value]) => {
|
Object.entries(nodeStyle).forEach(([key, value]) => {
|
||||||
// @ts-expect-error FIXME: ts error
|
const element = node.element as unknown as Record<string, unknown>;
|
||||||
if (!isEqual(node.element[key], value)) {
|
if (!isEqual(element[key], value)) {
|
||||||
// @ts-expect-error FIXME: ts error
|
element[key] = value;
|
||||||
node.element[key] = value;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -175,8 +175,8 @@ export const replaceIdMiddleware: JobMiddleware = ({ slots, collection }) => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'group': {
|
case 'group': {
|
||||||
// @ts-expect-error FIXME: ts error
|
const json = (value.children as Record<string, unknown>)
|
||||||
const json = value.children.json as Record<string, unknown>;
|
.json as Record<string, unknown>;
|
||||||
Object.entries(json).forEach(([key, value]) => {
|
Object.entries(json).forEach(([key, value]) => {
|
||||||
if (idMap.has(key)) {
|
if (idMap.has(key)) {
|
||||||
delete json[key];
|
delete json[key];
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
type BlockHtmlAdapterMatcher,
|
type BlockHtmlAdapterMatcher,
|
||||||
HastUtils,
|
HastUtils,
|
||||||
} from '@blocksuite/affine-shared/adapters';
|
} from '@blocksuite/affine-shared/adapters';
|
||||||
|
import type { DeltaInsert } from '@blocksuite/inline';
|
||||||
import { nanoid } from '@blocksuite/store';
|
import { nanoid } from '@blocksuite/store';
|
||||||
import { bundledLanguagesInfo, codeToHast } from 'shiki';
|
import { bundledLanguagesInfo, codeToHast } from 'shiki';
|
||||||
|
|
||||||
@@ -74,16 +75,15 @@ export const codeBlockHtmlAdapterMatcher: BlockHtmlAdapterMatcher = {
|
|||||||
)?.id ?? 'text')
|
)?.id ?? 'text')
|
||||||
: 'text';
|
: 'text';
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
const text = (o.node.props.text as Record<string, unknown>)
|
||||||
const text = o.node.props.text.delta as DeltaInsert[];
|
.delta as DeltaInsert[];
|
||||||
const code = text.map(delta => delta.insert).join('');
|
const code = text.map(delta => delta.insert).join('');
|
||||||
const hast = await codeToHast(code, {
|
const hast = await codeToHast(code, {
|
||||||
lang: matchedLang,
|
lang: matchedLang,
|
||||||
theme: 'light-plus',
|
theme: 'light-plus',
|
||||||
});
|
});
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
walkerContext.openNode(hast as never, 'children').closeNode();
|
||||||
walkerContext.openNode(hast, 'children').closeNode();
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export function cloneDeep<T>(obj: T): T {
|
|||||||
seen.set(val, copy);
|
seen.set(val, copy);
|
||||||
|
|
||||||
Object.keys(val).forEach(key => {
|
Object.keys(val).forEach(key => {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error deep clone
|
||||||
copy[key] = clone(val[key]);
|
copy[key] = clone(val[key]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -319,8 +319,7 @@ export class EdgelessChangeTextMenu extends WithDisposable(LitElement) {
|
|||||||
|
|
||||||
const key = this.elementType === 'connector' ? 'labelStyle' : 'color';
|
const key = this.elementType === 'connector' ? 'labelStyle' : 'color';
|
||||||
this.elements.forEach(ele => {
|
this.elements.forEach(ele => {
|
||||||
// @ts-expect-error: FIXME
|
ele[event.type === 'start' ? 'stash' : 'pop'](key as 'color');
|
||||||
ele[event.type === 'start' ? 'stash' : 'pop'](key);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ export const edgelessToBlob = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const writeImageBlobToClipboard = async (blob: Blob) => {
|
export const writeImageBlobToClipboard = async (blob: Blob) => {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error FIXME: BS-2239
|
||||||
if (window.apis?.clipboard?.copyAsImageFromString) {
|
if (window.apis?.clipboard?.copyAsImageFromString) {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error FIXME: BS-2239
|
||||||
await window.apis.clipboard?.copyAsImageFromString(blob);
|
await window.apis.clipboard?.copyAsImageFromString(blob);
|
||||||
} else {
|
} else {
|
||||||
await navigator.clipboard.write([new ClipboardItem({ [blob.type]: blob })]);
|
await navigator.clipboard.write([new ClipboardItem({ [blob.type]: blob })]);
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ export function setObjectPropMeta(
|
|||||||
prop: string | symbol,
|
prop: string | symbol,
|
||||||
val: unknown
|
val: unknown
|
||||||
) {
|
) {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
target[symbol] = target[symbol] ?? {};
|
target[symbol] = target[symbol] ?? {};
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
target[symbol][prop] = val;
|
target[symbol][prop] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,11 +32,11 @@ export function getObjectPropMeta(
|
|||||||
prop?: string | symbol
|
prop?: string | symbol
|
||||||
) {
|
) {
|
||||||
if (prop) {
|
if (prop) {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
return target[symbol]?.[prop] ?? null;
|
return target[symbol]?.[prop] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
return target[symbol] ?? {};
|
return target[symbol] ?? {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export function updateDerivedProps(
|
|||||||
const decoratorState = getDecoratorState(receiver.surface);
|
const decoratorState = getDecoratorState(receiver.surface);
|
||||||
decoratorState.deriving = true;
|
decoratorState.deriving = true;
|
||||||
keys(derivedProps).forEach(key => {
|
keys(derivedProps).forEach(key => {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
receiver[key] = derivedProps[key];
|
receiver[key] = derivedProps[key];
|
||||||
});
|
});
|
||||||
decoratorState.deriving = false;
|
decoratorState.deriving = false;
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ export function startObserve(
|
|||||||
) {
|
) {
|
||||||
const proto = Object.getPrototypeOf(receiver);
|
const proto = Object.getPrototypeOf(receiver);
|
||||||
const observeFn = getObserveMeta(proto, prop as string)!;
|
const observeFn = getObserveMeta(proto, prop as string)!;
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
const observerDisposable = receiver[observerDisposableSymbol] ?? {};
|
const observerDisposable = receiver[observerDisposableSymbol] ?? {};
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
receiver[observerDisposableSymbol] = observerDisposable;
|
receiver[observerDisposableSymbol] = observerDisposable;
|
||||||
|
|
||||||
if (observerDisposable[prop]) {
|
if (observerDisposable[prop]) {
|
||||||
@@ -114,7 +114,7 @@ export function initializeObservers(
|
|||||||
});
|
});
|
||||||
|
|
||||||
receiver['_disposable'].add(() => {
|
receiver['_disposable'].add(() => {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
Object.values(receiver[observerDisposableSymbol] ?? {}).forEach(dispose =>
|
Object.values(receiver[observerDisposableSymbol] ?? {}).forEach(dispose =>
|
||||||
(dispose as () => void)()
|
(dispose as () => void)()
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ export abstract class GfxPrimitiveElementModel<
|
|||||||
|
|
||||||
const value = this._stashed.get(prop);
|
const value = this._stashed.get(prop);
|
||||||
this._stashed.delete(prop);
|
this._stashed.delete(prop);
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
delete this[prop];
|
delete this[prop];
|
||||||
|
|
||||||
if (getFieldPropsSet(this).has(prop as string)) {
|
if (getFieldPropsSet(this).has(prop as string)) {
|
||||||
|
|||||||
@@ -126,14 +126,14 @@ export abstract class GfxLocalElementModel implements GfxCompatibleInterface {
|
|||||||
this._local.delete('deserializedXYWH');
|
this._local.delete('deserializedXYWH');
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
const oldValue = target[prop as string];
|
const oldValue = target[prop as string];
|
||||||
|
|
||||||
if (oldValue === value) {
|
if (oldValue === value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
target[prop as string] = value;
|
target[prop as string] = value;
|
||||||
|
|
||||||
if (!this._props.has(prop)) {
|
if (!this._props.has(prop)) {
|
||||||
@@ -158,7 +158,7 @@ export abstract class GfxLocalElementModel implements GfxCompatibleInterface {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// eslint-disable-next-line no-constructor-return
|
// oxlint-disable-next-line no-constructor-return
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
|||||||
|
|
||||||
Object.keys(rest).forEach(key => {
|
Object.keys(rest).forEach(key => {
|
||||||
if (props[key] !== undefined) {
|
if (props[key] !== undefined) {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
elementModel.model[key] = props[key];
|
elementModel.model[key] = props[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -177,7 +177,7 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
|||||||
state.skipField = options.skipFieldInit ?? false;
|
state.skipField = options.skipFieldInit ?? false;
|
||||||
|
|
||||||
let mounted = false;
|
let mounted = false;
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
Ctor['_decoratorState'] = state;
|
Ctor['_decoratorState'] = state;
|
||||||
|
|
||||||
const elementModel = new Ctor({
|
const elementModel = new Ctor({
|
||||||
@@ -188,7 +188,7 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
|||||||
onChange: payload => mounted && options.onChange({ id, ...payload }),
|
onChange: payload => mounted && options.onChange({ id, ...payload }),
|
||||||
}) as GfxPrimitiveElementModel;
|
}) as GfxPrimitiveElementModel;
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
delete Ctor['_decoratorState'];
|
delete Ctor['_decoratorState'];
|
||||||
state.creating = false;
|
state.creating = false;
|
||||||
state.skipField = false;
|
state.skipField = false;
|
||||||
@@ -364,7 +364,7 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
|||||||
{
|
{
|
||||||
const group = this.getGroup(payload.id);
|
const group = this.getGroup(payload.id);
|
||||||
if (group) {
|
if (group) {
|
||||||
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
// oxlint-disable-next-line unicorn/prefer-dom-node-remove
|
||||||
group.removeChild(payload.model as GfxModel);
|
group.removeChild(payload.model as GfxModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -385,7 +385,7 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
|||||||
throw new Error(`Invalid element type: ${type}`);
|
throw new Error(`Invalid element type: ${type}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
return (ctor.propsToY ?? GfxPrimitiveElementModel.propsToY)(props);
|
return (ctor.propsToY ?? GfxPrimitiveElementModel.propsToY)(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,7 +449,7 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
|||||||
|
|
||||||
const id = nanoid();
|
const id = nanoid();
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
props.id = id;
|
props.id = id;
|
||||||
|
|
||||||
const elementModel = this._createElementFromProps(props, {
|
const elementModel = this._createElementFromProps(props, {
|
||||||
@@ -502,7 +502,7 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
// oxlint-disable-next-line unicorn/prefer-dom-node-remove
|
||||||
group?.removeChild(element as GfxModel);
|
group?.removeChild(element as GfxModel);
|
||||||
|
|
||||||
this.elements.getValue()!.delete(id);
|
this.elements.getValue()!.delete(id);
|
||||||
@@ -612,7 +612,7 @@ export class SurfaceBlockModel extends BlockModel<SurfaceBlockProps> {
|
|||||||
props as Record<string, unknown>
|
props as Record<string, unknown>
|
||||||
) as T;
|
) as T;
|
||||||
Object.entries(props).forEach(([key, value]) => {
|
Object.entries(props).forEach(([key, value]) => {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
elementModel[key] = value;
|
elementModel[key] = value;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ export class ToolController extends GfxExtension {
|
|||||||
});
|
});
|
||||||
|
|
||||||
get currentTool$() {
|
get currentTool$() {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
// oxlint-disable-next-line typescript/no-this-alias
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -143,7 +143,7 @@ export class ToolController extends GfxExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get currentToolOption$() {
|
get currentToolOption$() {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
// oxlint-disable-next-line typescript/no-this-alias
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -475,7 +475,7 @@ export class ToolController extends GfxExtension {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.std.provider.getAll(ToolIdentifier).forEach(tool => {
|
this.std.provider.getAll(ToolIdentifier).forEach(tool => {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
tool['eventTarget'] = eventTarget;
|
tool['eventTarget'] = eventTarget;
|
||||||
this._register(tool);
|
this._register(tool);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ export function toGfxBlockComponent<
|
|||||||
WidgetName extends string,
|
WidgetName extends string,
|
||||||
B extends typeof BlockComponent<Model, Service, WidgetName>,
|
B extends typeof BlockComponent<Model, Service, WidgetName>,
|
||||||
>(CustomBlock: B) {
|
>(CustomBlock: B) {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
return class extends CustomBlock {
|
return class extends CustomBlock {
|
||||||
[GfxElementSymbol] = true;
|
[GfxElementSymbol] = true;
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ describe('isEqual', () => {
|
|||||||
)
|
)
|
||||||
).toBe(true);
|
).toBe(true);
|
||||||
expect(isEqual({}, { foo: 1 })).toBe(false);
|
expect(isEqual({}, { foo: 1 })).toBe(false);
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
expect(isEqual({ foo: 1 }, {})).toBe(false);
|
expect(isEqual({ foo: 1 }, {})).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ describe('isEqual', () => {
|
|||||||
bigint: 110101195306153019n,
|
bigint: 110101195306153019n,
|
||||||
};
|
};
|
||||||
expect(isEqual(nested, nested)).toBe(true);
|
expect(isEqual(nested, nested)).toBe(true);
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
expect(isEqual({ foo: [] }, { foo: '' })).toBe(false);
|
expect(isEqual({ foo: [] }, { foo: '' })).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -114,9 +114,9 @@ export const debounce = <T extends (...args: any[]) => void>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
export async function nextTick() {
|
export async function nextTick() {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error check window.scheduler
|
||||||
if ('scheduler' in window && 'yield' in window.scheduler) {
|
if ('scheduler' in window && 'yield' in window.scheduler) {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error check window.scheduler.yield
|
||||||
return window.scheduler.yield();
|
return window.scheduler.yield();
|
||||||
} else if (typeof requestIdleCallback !== 'undefined') {
|
} else if (typeof requestIdleCallback !== 'undefined') {
|
||||||
return new Promise(resolve => requestIdleCallback(resolve));
|
return new Promise(resolve => requestIdleCallback(resolve));
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ export async function assertSelection(
|
|||||||
([richTextIndex]) => {
|
([richTextIndex]) => {
|
||||||
const richText =
|
const richText =
|
||||||
document?.querySelectorAll('test-rich-text')[richTextIndex];
|
document?.querySelectorAll('test-rich-text')[richTextIndex];
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error getInlineRange
|
||||||
const inlineEditor = richText.inlineEditor;
|
const inlineEditor = richText.inlineEditor;
|
||||||
return inlineEditor?.getInlineRange();
|
return inlineEditor?.getInlineRange();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const spaceMetaId = 'meta';
|
|||||||
function serializCollection(doc: BlockSuiteDoc): Record<string, any> {
|
function serializCollection(doc: BlockSuiteDoc): Record<string, any> {
|
||||||
const spaces = {};
|
const spaces = {};
|
||||||
doc.spaces.forEach((subDoc, key) => {
|
doc.spaces.forEach((subDoc, key) => {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
spaces[key] = subDoc.toJSON();
|
spaces[key] = subDoc.toJSON();
|
||||||
});
|
});
|
||||||
const json = doc.toJSON();
|
const json = doc.toJSON();
|
||||||
@@ -103,7 +103,7 @@ describe('basic', () => {
|
|||||||
|
|
||||||
assert.equal(collection.isEmpty, false);
|
assert.equal(collection.isEmpty, false);
|
||||||
assert.equal(typeof actualDoc.createDate, 'number');
|
assert.equal(typeof actualDoc.createDate, 'number');
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
delete actualDoc.createDate;
|
delete actualDoc.createDate;
|
||||||
|
|
||||||
assert.deepEqual(actual, {
|
assert.deepEqual(actual, {
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ test('always get latest value in onChange', () => {
|
|||||||
|
|
||||||
let value: unknown;
|
let value: unknown;
|
||||||
rootModel.propsUpdated.on(({ key }) => {
|
rootModel.propsUpdated.on(({ key }) => {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
value = rootModel[key];
|
value = rootModel[key];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -96,23 +96,23 @@ test('snapshot to model', async () => {
|
|||||||
});
|
});
|
||||||
expect(model.flavour).toBe(rootModel.flavour);
|
expect(model.flavour).toBe(rootModel.flavour);
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
expect(model.props.title).toBeInstanceOf(Text);
|
expect(model.props.title).toBeInstanceOf(Text);
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
map.set('title', model.props.title.yText);
|
map.set('title', model.props.title.yText);
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
expect(model.props.title.toString()).toBe('doc title');
|
expect(model.props.title.toString()).toBe('doc title');
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
expect(model.props.style).toEqual({
|
expect(model.props.style).toEqual({
|
||||||
color: 'red',
|
color: 'red',
|
||||||
});
|
});
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
expect(model.props.count).toBe(3);
|
expect(model.props.count).toBe(3);
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
expect(model.props.items).toMatchObject([
|
expect(model.props.items).toMatchObject([
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
@@ -125,7 +125,7 @@ test('snapshot to model', async () => {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
model.props.items.forEach((item, index) => {
|
model.props.items.forEach((item, index) => {
|
||||||
expect(item.content).toBeInstanceOf(Text);
|
expect(item.content).toBeInstanceOf(Text);
|
||||||
const key = `item:${index}:content`;
|
const key = `item:${index}:content`;
|
||||||
|
|||||||
@@ -49,11 +49,11 @@ describe('blocksuite yjs', () => {
|
|||||||
|
|
||||||
proxy.obj2 = { foo: 2, bar: { num: 3 } };
|
proxy.obj2 = { foo: 2, bar: { num: 3 } };
|
||||||
expect(map.get('obj2')).toBeInstanceOf(Y.Map);
|
expect(map.get('obj2')).toBeInstanceOf(Y.Map);
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
expect(map.get('obj2').get('bar').get('num')).toBe(3);
|
expect(map.get('obj2').get('bar').get('num')).toBe(3);
|
||||||
|
|
||||||
proxy.obj2.bar.str = 'hello';
|
proxy.obj2.bar.str = 'hello';
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
expect(map.get('obj2').get('bar').get('str')).toBe('hello');
|
expect(map.get('obj2').get('bar').get('str')).toBe('hello');
|
||||||
|
|
||||||
proxy.obj3 = {};
|
proxy.obj3 = {};
|
||||||
@@ -105,7 +105,7 @@ describe('blocksuite yjs', () => {
|
|||||||
|
|
||||||
proxy.inner.native.setValue(['hello', 'world', 'foo']);
|
proxy.inner.native.setValue(['hello', 'world', 'foo']);
|
||||||
expect(native.getValue()).toEqual(['hello', 'world', 'foo']);
|
expect(native.getValue()).toEqual(['hello', 'world', 'foo']);
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
expect(map.get('inner').get('native').get('value')).toEqual([
|
expect(map.get('inner').get('native').get('value')).toEqual([
|
||||||
'hello',
|
'hello',
|
||||||
'world',
|
'world',
|
||||||
@@ -114,10 +114,10 @@ describe('blocksuite yjs', () => {
|
|||||||
|
|
||||||
const native2 = new Boxed(0);
|
const native2 = new Boxed(0);
|
||||||
proxy.inner.native2 = native2;
|
proxy.inner.native2 = native2;
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
expect(map.get('inner').get('native2').get('value')).toBe(0);
|
expect(map.get('inner').get('native2').get('value')).toBe(0);
|
||||||
native2.setValue(1);
|
native2.setValue(1);
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
expect(map.get('inner').get('native2').get('value')).toBe(1);
|
expect(map.get('inner').get('native2').get('value')).toBe(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ function MagicProps(): {
|
|||||||
|
|
||||||
const modelLabel = Symbol('model_label');
|
const modelLabel = Symbol('model_label');
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error allow magic props
|
||||||
export class BlockModel<
|
export class BlockModel<
|
||||||
Props extends object = object,
|
Props extends object = object,
|
||||||
PropsSignal extends object = SignaledProps<Props>,
|
PropsSignal extends object = SignaledProps<Props>,
|
||||||
|
|||||||
@@ -46,12 +46,12 @@ export class SyncController {
|
|||||||
const keyName = key.replace('prop:', '');
|
const keyName = key.replace('prop:', '');
|
||||||
const proxy = this._getPropsProxy(keyName, value);
|
const proxy = this._getPropsProxy(keyName, value);
|
||||||
this._byPassUpdate(() => {
|
this._byPassUpdate(() => {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error allow magic props
|
||||||
this.model[keyName] = proxy;
|
this.model[keyName] = proxy;
|
||||||
const signalKey = `${keyName}$`;
|
const signalKey = `${keyName}$`;
|
||||||
this._mutex(() => {
|
this._mutex(() => {
|
||||||
if (signalKey in this.model) {
|
if (signalKey in this.model) {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error allow magic props
|
||||||
this.model[signalKey].value = y2Native(value);
|
this.model[signalKey].value = y2Native(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -62,10 +62,10 @@ export class SyncController {
|
|||||||
if (type.action === 'delete') {
|
if (type.action === 'delete') {
|
||||||
const keyName = key.replace('prop:', '');
|
const keyName = key.replace('prop:', '');
|
||||||
this._byPassUpdate(() => {
|
this._byPassUpdate(() => {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error allow magic props
|
||||||
delete this.model[keyName];
|
delete this.model[keyName];
|
||||||
if (`${keyName}$` in this.model) {
|
if (`${keyName}$` in this.model) {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error allow magic props
|
||||||
this.model[`${keyName}$`].value = undefined;
|
this.model[`${keyName}$`].value = undefined;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -136,7 +136,7 @@ export class SyncController {
|
|||||||
const value = data.value;
|
const value = data.value;
|
||||||
if (!this.model) return;
|
if (!this.model) return;
|
||||||
_mutex(() => {
|
_mutex(() => {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error allow magic props
|
||||||
this.model[key] = value;
|
this.model[key] = value;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -208,7 +208,7 @@ export class SyncController {
|
|||||||
|
|
||||||
function setValue(target: BlockModel, p: string, value: unknown) {
|
function setValue(target: BlockModel, p: string, value: unknown) {
|
||||||
_mutex(() => {
|
_mutex(() => {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error allow magic props
|
||||||
target[`${p}$`].value = value;
|
target[`${p}$`].value = value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -222,7 +222,7 @@ export class SyncController {
|
|||||||
const signalKey = `${name}$`;
|
const signalKey = `${name}$`;
|
||||||
if (signalKey in this.model) {
|
if (signalKey in this.model) {
|
||||||
this._mutex(() => {
|
this._mutex(() => {
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error allow magic props
|
||||||
this.model[signalKey].value = this.model[name];
|
this.model[signalKey].value = this.model[name];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export function syncBlockProps(
|
|||||||
if (SYS_KEYS.has(key)) return;
|
if (SYS_KEYS.has(key)) return;
|
||||||
if (value === undefined) return;
|
if (value === undefined) return;
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error allow props
|
||||||
model[key] = value;
|
model[key] = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ export function syncBlockProps(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error allow props
|
||||||
model[key] = native2Y(value);
|
model[key] = native2Y(value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ function renderToImageData(index: number, scale: number) {
|
|||||||
bitmap.fill(0, 0, width, height);
|
bitmap.fill(0, 0, width, height);
|
||||||
page.render(bitmap, 0, 0, width, height, 0, flags);
|
page.render(bitmap, 0, 0, width, height, 0, flags);
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
const data = new Uint8ClampedArray(bitmap.toUint8Array());
|
const data = new Uint8ClampedArray(bitmap.toUint8Array());
|
||||||
|
|
||||||
bitmap.close();
|
bitmap.close();
|
||||||
|
|||||||
@@ -38,12 +38,12 @@ export const devtoolsFormatter: typeof window.devtoolsFormatters = [
|
|||||||
if ('flavour' in (obj as BlockModel) && 'yBlock' in (obj as BlockModel)) {
|
if ('flavour' in (obj as BlockModel) && 'yBlock' in (obj as BlockModel)) {
|
||||||
globalUtils.assertType<BlockModel>(obj);
|
globalUtils.assertType<BlockModel>(obj);
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
const { props } = obj.page._blockTree.getBlock(obj.id)._parseYBlock();
|
const { props } = obj.page._blockTree.getBlock(obj.id)._parseYBlock();
|
||||||
|
|
||||||
const propsArr = Object.entries(props).flatMap(([key]) => {
|
const propsArr = Object.entries(props).flatMap(([key]) => {
|
||||||
return [
|
return [
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error ignore
|
||||||
...toStyledEntry(key, obj[key]),
|
...toStyledEntry(key, obj[key]),
|
||||||
['div', {}, ''],
|
['div', {}, ''],
|
||||||
] as HTMLTemplate[];
|
] as HTMLTemplate[];
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const env =
|
|||||||
: {};
|
: {};
|
||||||
const importIdentifier = '__ $BLOCKSUITE_EDITOR$ __';
|
const importIdentifier = '__ $BLOCKSUITE_EDITOR$ __';
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error check global identifier
|
||||||
if (env[importIdentifier] === true) {
|
if (env[importIdentifier] === true) {
|
||||||
// https://github.com/yjs/yjs/issues/438
|
// https://github.com/yjs/yjs/issues/438
|
||||||
console.error(
|
console.error(
|
||||||
@@ -22,5 +22,5 @@ if (env[importIdentifier] === true) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-expect-error FIXME: ts error
|
// @ts-expect-error set global identifier
|
||||||
env[importIdentifier] = true;
|
env[importIdentifier] = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user