chore: replace all cn comments of fe to en version by volc api (#320)

This commit is contained in:
tecvan
2025-07-31 10:32:15 +08:00
committed by GitHub
parent 716ec0cba8
commit 71f6245a01
2960 changed files with 15545 additions and 15545 deletions

View File

@@ -22,12 +22,12 @@ describe('compareNodePosition', () => {
let siblingNode: HTMLElement;
beforeEach(() => {
// 在每个测试之前创建新的 DOM 结构
// Create a new DOM structure before each test
parentNode = document.createElement('div');
childNode = document.createElement('span');
siblingNode = document.createElement('p');
parentNode.appendChild(childNode); // childNode parentNode 的子节点
parentNode.appendChild(siblingNode); // siblingNode childNode 的同级节点
parentNode.appendChild(childNode); // childNode is a sub-node of parentNode
parentNode.appendChild(siblingNode); // siblingNode is a sibling of childNode
});
it('should return "before" if nodeA is before nodeB', () => {

View File

@@ -17,7 +17,7 @@
import { findAncestorNodeByTagName } from '../src/utils/helper/find-ancestor-node-by-tag-name';
describe('findAncestorNodeByTagName', () => {
// 设置 DOM 环境
// Setting up the DOM environment
document.body.innerHTML = `
<div id="ancestor">
<div id="parent">
@@ -41,7 +41,7 @@ describe('findAncestorNodeByTagName', () => {
it('should return the node itself if it matches the tag name', () => {
const result = findAncestorNodeByTagName(child, 'div');
expect(result).toBe(parent); // 因为 child 的直接父级 parent 也是 div
expect(result).toBe(parent); // Because the child's immediate parent is also a div
});
it('should return null if the input node is null', () => {

View File

@@ -18,7 +18,7 @@ import { findLastChildNode } from '../src/utils/helper/find-last-child-node';
describe('findLastChildNode', () => {
it('should return the last child node of a nested node structure', () => {
// 创建一个嵌套的节点结构
// Create a nested node structure
const parentNode = document.createElement('div');
const childNode1 = document.createElement('span');
const childNode2 = document.createElement('p');
@@ -28,21 +28,21 @@ describe('findLastChildNode', () => {
childNode1.appendChild(childNode2);
childNode2.appendChild(lastChildNode);
// 调用 findLastChildNode 函数
// Call the findLastChildNode function
const result = findLastChildNode(parentNode);
// 验证结果是否为最深层的子节点
// Verify that the result is the deepest sub-node
expect(result).toBe(lastChildNode);
});
it('should return the node itself if it has no children', () => {
// 创建一个没有子节点的节点
// Create a node without a sub-node
const singleNode = document.createElement('div');
// 调用 findLastChildNode 函数
// Call the findLastChildNode function
const result = findLastChildNode(singleNode);
// 验证结果是否为节点本身
// Verify whether the result is the node itself
expect(result).toBe(singleNode);
});
});

View File

@@ -17,7 +17,7 @@
import { findLastSiblingNode } from '../src/utils/helper/find-last-sibling-node';
describe('findLastSiblingNode', () => {
// 设置 DOM 环境
// Setting up the DOM environment
document.body.innerHTML = `
<div id="ancestor">
<div id="sibling1" data-scope="valid"></div>

View File

@@ -17,7 +17,7 @@
import { findNearestAnchor } from '../src/utils/helper/find-nearest-link-node';
describe('findNearestAnchor', () => {
// 设置 DOM 环境
// Setting up the DOM environment
document.body.innerHTML = `
<div>
<a id="anchor1" href="#">

View File

@@ -20,7 +20,7 @@ describe('getAllChildNodesInNode', () => {
let root: HTMLElement;
beforeEach(() => {
// 在每个测试用例之前设置 DOM 结构
// Setting up the DOM structure before each test case
document.body.innerHTML = `
<div id="root">
<span>Text 1</span>
@@ -46,8 +46,8 @@ describe('getAllChildNodesInNode', () => {
it('should correctly handle text and element nodes', () => {
const nodes = getAllChildNodesInNode(root);
// 检查返回的节点类型是否正确
expect(nodes.some(node => node.nodeType === Node.TEXT_NODE)).toBe(true); // 至少有一个文本节点
expect(nodes.some(node => node.nodeType === Node.ELEMENT_NODE)).toBe(true); // 至少有一个元素节点
// Check if the returned node type is correct
expect(nodes.some(node => node.nodeType === Node.TEXT_NODE)).toBe(true); // At least one text node
expect(nodes.some(node => node.nodeType === Node.ELEMENT_NODE)).toBe(true); // There is at least one element node
});
});

View File

@@ -20,7 +20,7 @@ describe('getAllNodesInRange', () => {
let root: HTMLElement;
beforeEach(() => {
// 在每个测试用例之前设置 DOM 结构
// Setting up the DOM structure before each test case
document.body.innerHTML = `
<div id="root">
<span>Text 1</span>
@@ -35,11 +35,11 @@ describe('getAllNodesInRange', () => {
it('should return all nodes within a range, including text and element nodes', () => {
const range = new Range();
range.setStart(root, 0); // 设置范围开始于 root 的第一个子节点
range.setEnd(root, 3); // 设置范围结束于 root 的最后一个子节点
range.setStart(root, 0); // Setup scope starts at the first sub-node of root
range.setEnd(root, 3); // The setting range ends at the last sub-node of root.
const nodes = getAllNodesInRange(range);
// 预期包含:span, div, Text 3
// Expected to include: span, div, Text 3
expect(nodes.length).toBe(5);
expect((nodes[0] as Node).nodeType).toBe(Node.ELEMENT_NODE); // span
expect((nodes[1] as Node).nodeType).toBe(Node.TEXT_NODE); // text
@@ -50,8 +50,8 @@ describe('getAllNodesInRange', () => {
it('should return an empty array if the range is collapsed', () => {
const range = document.createRange();
range.setStart(root, 1); // 设置范围的开始和结束都在同一位置
range.setEnd(root, 1); // 这将创建一个折叠的范围,即没有包含任何节点
range.setStart(root, 1); // Set the start and end of the range at the same location
range.setEnd(root, 1); // This will create a collapsed scope that contains no nodes
const nodes = getAllNodesInRange(range);
expect(nodes).toEqual([root]);

View File

@@ -20,7 +20,7 @@ describe('getRangeDirection', () => {
it('should return "none" when the range start and end are the same', () => {
const range = document.createRange();
const div = document.createElement('div');
document.body.appendChild(div); // 确保节点在 DOM
document.body.appendChild(div); // Make sure the node is in the DOM
range.setStart(div, 0);
range.setEnd(div, 0);
@@ -30,11 +30,11 @@ describe('getRangeDirection', () => {
it('should return "forward" when the range is selected forwards', () => {
const div = document.createElement('div');
document.body.appendChild(div); // 确保节点在 DOM
document.body.appendChild(div); // Make sure the node is in the DOM
div.textContent = 'Test content';
const range = document.createRange();
range.setStart(div.firstChild as Node, 0);
range.setEnd(div.firstChild as Node, 4); // 选择了 "Test"
range.setEnd(div.firstChild as Node, 4); // Select "Test"
const direction = getRangeDirection(range);
expect(direction).toBe('forward');