chore: format all frontend files (#430)
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -13,5 +13,5 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
/// <reference types='@coze-arch/bot-typings' />
|
||||
|
||||
@@ -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';
|
||||
|
||||
/**
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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';
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
@@ -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 = (
|
||||
|
||||
@@ -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[] = [];
|
||||
|
||||
@@ -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[] = [];
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 =>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
import {
|
||||
GrabElementType,
|
||||
type GrabImageElement,
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
import {
|
||||
GrabElementType,
|
||||
type GrabLinkElement,
|
||||
|
||||
@@ -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 =>
|
||||
|
||||
@@ -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>) => {
|
||||
|
||||
@@ -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';
|
||||
|
||||
/**
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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 = ({
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user