chore: format all frontend files (#430)

This commit is contained in:
tecvan
2025-07-31 23:15:48 +08:00
committed by GitHub
parent 8b078ff013
commit 6995cec404
8787 changed files with 11975 additions and 10924 deletions

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { compareNodePosition } from '../src/utils/helper/compare-node-position';
describe('compareNodePosition', () => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { findAncestorNodeByTagName } from '../src/utils/helper/find-ancestor-node-by-tag-name';
describe('findAncestorNodeByTagName', () => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { findLastChildNode } from '../src/utils/helper/find-last-child-node';
describe('findLastChildNode', () => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { findLastSiblingNode } from '../src/utils/helper/find-last-sibling-node';
describe('findLastSiblingNode', () => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { findNearestAnchor } from '../src/utils/helper/find-nearest-link-node';
describe('findNearestAnchor', () => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { getAllChildNodesInNode } from '../src/utils/helper/get-all-child-nodes-in-node';
describe('getAllChildNodesInNode', () => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { getAllNodesInRange } from '../src/utils/helper/get-all-nodes-in-range';
describe('getAllNodesInRange', () => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { getRangeDirection } from '../src/utils/helper/get-range-direction';
describe('getRangeDirection', () => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const CONTENT_ATTRIBUTE_NAME = 'data-grab-mark';
export const MESSAGE_SOURCE_ATTRIBUTE_NAME = 'data-grab-source';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { useEffect, useRef, useState, type MutableRefObject } from 'react';
import { defer } from 'lodash-es';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { useGrab } from './hooks/use-grab';
export { SelectionData } from './types/selection';
export { type GrabPosition } from './types/selection';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const enum GrabElementType {
IMAGE = 'image',
LINK = 'link',

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type getOriginContentText } from '../utils/normalizer/get-origin-content-text';
import { type getNormalizeNodeList } from '../utils/normalizer/get-normalize-node-list';
import { type getHumanizedContentText } from '../utils/normalizer/get-humanize-content-text';

View File

@@ -13,5 +13,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/// <reference types='@coze-arch/bot-typings' />

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { getPictureNodeUrl } from './get-picture-node-url';
/**

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const getAncestorAttributeNode = (
node: Node | null,
attributeName: string,

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const getAncestorAttributeValue = (
node: Node | null,
attributeName: string,

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Get URLs in image Node
* @param node Node

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const getRectData = ({ selection }: { selection: Selection }) => {
if (!selection.rangeCount) {
return;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type SelectionData } from '../types/selection';
import {
CONTENT_ATTRIBUTE_NAME,

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Determine the node inclusion relationship
* Reference document "https://developer.mozilla.org/zh-CN/docs/Web/API/Node/compareDocumentPosition"

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Find ancestor nodes (including itself) by TagName
* @param node Node | null

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Find the last sub-node of a node
* @param node Node

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { getAncestorAttributeValue } from '../get-ancestor-attribute-value';
/**

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const findNearestAnchor = (
node: Node | null,
): HTMLAnchorElement | null => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { compareNodePosition } from './compare-node-position';
export const findNotContainsPreviousSibling = (

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Helper function to obtain all nodes in the selection
export const getAllChildNodesInNode = (node: Node): Node[] => {
const nodes: Node[] = [];

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Helper function to obtain all nodes in the selection
export const getAllNodesInRange = (range: Range): Node[] => {
const nodes: Node[] = [];

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const getRangeDirection = (range: Range) => {
const position = range.compareBoundaryPoints(Range.START_TO_END, range);

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Direction } from '../../types/selection';
import { compareNodePosition } from './compare-node-position';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const hasAncestorWithAttribute = (
node: Node | null,
attributeName: string,

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const hasVisibleSelection = (range: Range): boolean => {
// Clone all nodes within the Range
const documentFragment = range.cloneContents();

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export function isTouchDevice(): boolean {
return 'ontouchend' in document;
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type GrabNode } from '../../types/node';
import { isGrabTextNode } from './is-grab-text-node';
import { isGrabLink } from './is-grab-link';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { processSpecialNode } from '../process-node/process-special-node';
import {
GrabElementType,

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Get formatted SelectionNodeList data
* Get the text content fed to the large model

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type GrabElement, type GrabNode } from '../../types/node';
export const isGrabElement = (node: GrabNode): node is GrabElement =>

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
GrabElementType,
type GrabImageElement,

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
GrabElementType,
type GrabLinkElement,

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type GrabNode, type GrabText } from '../../types/node';
export const isGrabTextNode = (node: GrabNode): node is GrabText =>

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { processSpecialNode } from './process-special-node';
export const processChildNode = (childNodes: NodeListOf<Node>) => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { findPictureValidChildNode } from '../find-picture-valid-child-node';
/**

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { getAllChildNodesInNode } from '../helper/get-all-child-nodes-in-node';
import { findNotContainsPreviousSibling } from '../helper/find-not-contains-previous-sibling';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { findLastChildNode } from '../helper/find-last-child-node';
import { getAncestorAttributeValue } from '../get-ancestor-attribute-value';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { findNearestAnchor } from '../helper/find-nearest-link-node';
export const fixLink = (range: Range, startNode: Node, endNode: Node) => {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { getAncestorAttributeValue } from '../get-ancestor-attribute-value';
export const fixStartNode = ({

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Fix the actual function of the selection
* @param range Range

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CONTENT_ATTRIBUTE_NAME } from '../constants/range';
import { getAllNodesInRange } from './helper/get-all-nodes-in-range';
import { findAncestorNodeByTagName } from './helper/find-ancestor-node-by-tag-name';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineConfig } from '@coze-arch/vitest-config';
export default defineConfig({