Switch to vercel's biome setup (#543)
This commit is contained in:
parent
b8643353c0
commit
43aa1c6e58
52 changed files with 414 additions and 201 deletions
|
|
@ -49,7 +49,7 @@ export const patchDocumentNode = (schema, oldNode, newNode) => {
|
|||
const matchedNodes = matchNodes(
|
||||
schema,
|
||||
diffOldChildren,
|
||||
diffNewChildren
|
||||
diffNewChildren,
|
||||
).sort((a, b) => b.count - a.count);
|
||||
const bestMatch = matchedNodes[0];
|
||||
if (bestMatch) {
|
||||
|
|
@ -62,11 +62,11 @@ export const patchDocumentNode = (schema, oldNode, newNode) => {
|
|||
...patchRemainNodes(
|
||||
schema,
|
||||
oldBeforeMatchChildren,
|
||||
newBeforeMatchChildren
|
||||
)
|
||||
newBeforeMatchChildren,
|
||||
),
|
||||
);
|
||||
finalLeftChildren.push(
|
||||
...diffOldChildren.slice(oldStartIndex, oldEndIndex)
|
||||
...diffOldChildren.slice(oldStartIndex, oldEndIndex),
|
||||
);
|
||||
|
||||
const oldAfterMatchChildren = diffOldChildren.slice(oldEndIndex);
|
||||
|
|
@ -76,17 +76,17 @@ export const patchDocumentNode = (schema, oldNode, newNode) => {
|
|||
...patchRemainNodes(
|
||||
schema,
|
||||
oldAfterMatchChildren,
|
||||
newAfterMatchChildren
|
||||
)
|
||||
newAfterMatchChildren,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
finalLeftChildren.push(
|
||||
...patchRemainNodes(schema, diffOldChildren, diffNewChildren)
|
||||
...patchRemainNodes(schema, diffOldChildren, diffNewChildren),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
finalLeftChildren.push(
|
||||
...patchRemainNodes(schema, diffOldChildren, diffNewChildren)
|
||||
...patchRemainNodes(schema, diffOldChildren, diffNewChildren),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ const patchRemainNodes = (schema, oldChildren, newChildren) => {
|
|||
!isTextNode(rightOldNode) && matchNodeType(rightOldNode, rightNewNode);
|
||||
if (Array.isArray(leftOldNode) && Array.isArray(leftNewNode)) {
|
||||
finalLeftChildren.push(
|
||||
...patchTextNodes(schema, leftOldNode, leftNewNode)
|
||||
...patchTextNodes(schema, leftOldNode, leftNewNode),
|
||||
);
|
||||
left += 1;
|
||||
continue;
|
||||
|
|
@ -165,7 +165,7 @@ const patchRemainNodes = (schema, oldChildren, newChildren) => {
|
|||
const equalityLeft = computeChildEqualityFactor(leftOldNode, leftNewNode);
|
||||
const equalityRight = computeChildEqualityFactor(
|
||||
rightOldNode,
|
||||
rightNewNode
|
||||
rightNewNode,
|
||||
);
|
||||
if (equalityLeft < equalityRight) {
|
||||
updateLeft = false;
|
||||
|
|
@ -175,21 +175,21 @@ const patchRemainNodes = (schema, oldChildren, newChildren) => {
|
|||
}
|
||||
if (updateLeft) {
|
||||
finalLeftChildren.push(
|
||||
patchDocumentNode(schema, leftOldNode, leftNewNode)
|
||||
patchDocumentNode(schema, leftOldNode, leftNewNode),
|
||||
);
|
||||
left += 1;
|
||||
} else if (updateRight) {
|
||||
finalRightChildren.unshift(
|
||||
patchDocumentNode(schema, rightOldNode, rightNewNode)
|
||||
patchDocumentNode(schema, rightOldNode, rightNewNode),
|
||||
);
|
||||
right += 1;
|
||||
} else {
|
||||
// Delete and insert
|
||||
finalLeftChildren.push(
|
||||
createDiffNode(schema, leftOldNode, DiffType.Deleted)
|
||||
createDiffNode(schema, leftOldNode, DiffType.Deleted),
|
||||
);
|
||||
finalLeftChildren.push(
|
||||
createDiffNode(schema, leftNewNode, DiffType.Inserted)
|
||||
createDiffNode(schema, leftNewNode, DiffType.Inserted),
|
||||
);
|
||||
left += 1;
|
||||
}
|
||||
|
|
@ -202,7 +202,7 @@ const patchRemainNodes = (schema, oldChildren, newChildren) => {
|
|||
...oldChildren
|
||||
.slice(left, left + deleteNodeLen)
|
||||
.flat()
|
||||
.map((node) => createDiffNode(schema, node, DiffType.Deleted))
|
||||
.map((node) => createDiffNode(schema, node, DiffType.Deleted)),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ const patchRemainNodes = (schema, oldChildren, newChildren) => {
|
|||
...newChildren
|
||||
.slice(left, left + insertNodeLen)
|
||||
.flat()
|
||||
.map((node) => createDiffNode(schema, node, DiffType.Inserted))
|
||||
.map((node) => createDiffNode(schema, node, DiffType.Inserted)),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ export const patchTextNodes = (schema, oldNode, newNode) => {
|
|||
// Map sentences to unique characters
|
||||
const { chars1, chars2, lineArray } = sentencesToChars(
|
||||
oldSentences,
|
||||
newSentences
|
||||
newSentences,
|
||||
);
|
||||
|
||||
// Perform the diff
|
||||
|
|
@ -253,7 +253,7 @@ export const patchTextNodes = (schema, oldNode, newNode) => {
|
|||
const node = createTextNode(
|
||||
schema,
|
||||
sentence,
|
||||
type !== DiffType.Unchanged ? [createDiffMark(schema, type)] : []
|
||||
type !== DiffType.Unchanged ? [createDiffMark(schema, type)] : [],
|
||||
);
|
||||
return node;
|
||||
});
|
||||
|
|
@ -427,7 +427,7 @@ export const createNewNode = (oldNode, children) => {
|
|||
oldNode.type,
|
||||
oldNode.attrs,
|
||||
Fragment.fromArray(children),
|
||||
oldNode.marks
|
||||
oldNode.marks,
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -448,8 +448,8 @@ function mapDocumentNode(node, mapper) {
|
|||
Fragment.from(
|
||||
node.content.content
|
||||
.map((node) => mapDocumentNode(node, mapper))
|
||||
.filter((n) => n)
|
||||
)
|
||||
.filter((n) => n),
|
||||
),
|
||||
);
|
||||
return mapper(copy) || copy;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue