Fix all biome linter errors (#541)
This commit is contained in:
parent
f23c73f6a5
commit
e5d654bf41
46 changed files with 317 additions and 275 deletions
|
|
@ -2,9 +2,9 @@ import { textblockTypeInputRule } from 'prosemirror-inputrules';
|
|||
import { Schema } from 'prosemirror-model';
|
||||
import { schema } from 'prosemirror-schema-basic';
|
||||
import { addListNodes } from 'prosemirror-schema-list';
|
||||
import { Transaction } from 'prosemirror-state';
|
||||
import { EditorView } from 'prosemirror-view';
|
||||
import { MutableRefObject } from 'react';
|
||||
import type { Transaction } from 'prosemirror-state';
|
||||
import type { EditorView } from 'prosemirror-view';
|
||||
import type { MutableRefObject } from 'react';
|
||||
|
||||
import { buildContentFromDocument } from './functions';
|
||||
|
||||
|
|
|
|||
|
|
@ -248,18 +248,16 @@ export const patchTextNodes = (schema, oldNode, newNode) => {
|
|||
});
|
||||
|
||||
// Map diffs to nodes
|
||||
const res = diffs
|
||||
.map(([type, sentences]) => {
|
||||
return sentences.map((sentence) => {
|
||||
const node = createTextNode(
|
||||
schema,
|
||||
sentence,
|
||||
type !== DiffType.Unchanged ? [createDiffMark(schema, type)] : []
|
||||
);
|
||||
return node;
|
||||
});
|
||||
})
|
||||
.flat();
|
||||
const res = diffs.flatMap(([type, sentences]) => {
|
||||
return sentences.map((sentence) => {
|
||||
const node = createTextNode(
|
||||
schema,
|
||||
sentence,
|
||||
type !== DiffType.Unchanged ? [createDiffMark(schema, type)] : []
|
||||
);
|
||||
return node;
|
||||
});
|
||||
});
|
||||
|
||||
return res;
|
||||
};
|
||||
|
|
@ -278,28 +276,26 @@ const sentencesToChars = (oldSentences, newSentences) => {
|
|||
const chars1 = oldSentences
|
||||
.map((sentence) => {
|
||||
const line = sentence;
|
||||
if (lineHash.hasOwnProperty(line)) {
|
||||
return String.fromCharCode(lineHash[line]);
|
||||
} else {
|
||||
lineHash[line] = lineStart;
|
||||
lineArray[lineStart] = line;
|
||||
lineStart++;
|
||||
if (line in lineHash) {
|
||||
return String.fromCharCode(lineHash[line]);
|
||||
}
|
||||
lineHash[line] = lineStart;
|
||||
lineArray[lineStart] = line;
|
||||
lineStart++;
|
||||
return String.fromCharCode(lineHash[line]);
|
||||
})
|
||||
.join('');
|
||||
|
||||
const chars2 = newSentences
|
||||
.map((sentence) => {
|
||||
const line = sentence;
|
||||
if (lineHash.hasOwnProperty(line)) {
|
||||
return String.fromCharCode(lineHash[line]);
|
||||
} else {
|
||||
lineHash[line] = lineStart;
|
||||
lineArray[lineStart] = line;
|
||||
lineStart++;
|
||||
if (line in lineHash) {
|
||||
return String.fromCharCode(lineHash[line]);
|
||||
}
|
||||
lineHash[line] = lineStart;
|
||||
lineArray[lineStart] = line;
|
||||
lineStart++;
|
||||
return String.fromCharCode(lineHash[line]);
|
||||
})
|
||||
.join('');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
'use client';
|
||||
|
||||
import { defaultMarkdownSerializer } from 'prosemirror-markdown';
|
||||
import { DOMParser, Node } from 'prosemirror-model';
|
||||
import { Decoration, DecorationSet, EditorView } from 'prosemirror-view';
|
||||
import { DOMParser, type Node } from 'prosemirror-model';
|
||||
import { Decoration, DecorationSet, type EditorView } from 'prosemirror-view';
|
||||
import { renderToString } from 'react-dom/server';
|
||||
|
||||
import { Markdown } from '@/components/markdown';
|
||||
|
||||
import { documentSchema } from './config';
|
||||
import { createSuggestionWidget, UISuggestion } from './suggestions';
|
||||
import { createSuggestionWidget, type UISuggestion } from './suggestions';
|
||||
|
||||
export const buildDocumentFromContent = (content: string) => {
|
||||
const parser = DOMParser.fromSchema(documentSchema);
|
||||
|
|
@ -28,7 +28,7 @@ export const createDecorations = (
|
|||
) => {
|
||||
const decorations: Array<Decoration> = [];
|
||||
|
||||
suggestions.forEach((suggestion) => {
|
||||
for (const suggestion of suggestions) {
|
||||
decorations.push(
|
||||
Decoration.inline(
|
||||
suggestion.selectionStart,
|
||||
|
|
@ -56,7 +56,7 @@ export const createDecorations = (
|
|||
}
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return DecorationSet.create(view.state.doc, decorations);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
import { Node } from 'prosemirror-model';
|
||||
import { PluginKey, Plugin } from 'prosemirror-state';
|
||||
import { Decoration, DecorationSet, EditorView } from 'prosemirror-view';
|
||||
import type { Node } from 'prosemirror-model';
|
||||
import { Plugin, PluginKey } from 'prosemirror-state';
|
||||
import {
|
||||
type Decoration,
|
||||
DecorationSet,
|
||||
type EditorView,
|
||||
} from 'prosemirror-view';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
|
||||
import { Suggestion as PreviewSuggestion } from '@/components/suggestion';
|
||||
import { Suggestion } from '@/lib/db/schema';
|
||||
import type { Suggestion } from '@/lib/db/schema';
|
||||
|
||||
export interface UISuggestion extends Suggestion {
|
||||
selectionStart: number;
|
||||
|
|
@ -77,7 +81,7 @@ export function createSuggestionWidget(
|
|||
const onApply = () => {
|
||||
const { state, dispatch } = view;
|
||||
|
||||
let decorationTransaction = state.tr;
|
||||
const decorationTransaction = state.tr;
|
||||
const currentState = suggestionsPluginKey.getState(state);
|
||||
const currentDecorations = currentState?.decorations;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue