chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -33,22 +33,22 @@ export interface PromptConfiguratorModalProps extends ModalProps {
|
||||
workflowId?: string;
|
||||
defaultPrompt?: string;
|
||||
canEdit?: boolean;
|
||||
/** 用于埋点: 页面来源 */
|
||||
/** For event tracking: page source */
|
||||
source: string;
|
||||
enableDiff?: boolean;
|
||||
promptSectionConfig?: {
|
||||
/** 提示词输入框的 placeholder */
|
||||
/** Cue word text box placeholder */
|
||||
editorPlaceholder?: React.ReactNode;
|
||||
/** 提示词划词actions */
|
||||
/** Cue action */
|
||||
editorActions?: React.ReactNode;
|
||||
/** 头部 actions */
|
||||
/** Head actions */
|
||||
headerActions?: React.ReactNode;
|
||||
/** 提示词输入框的 active line placeholder */
|
||||
/** Cue text box active line placeholder */
|
||||
editorActiveLinePlaceholder?: React.ReactNode;
|
||||
/** 提示词输入框的 extensions */
|
||||
/** Tip text box extensions */
|
||||
editorExtensions?: React.ReactNode;
|
||||
};
|
||||
/** 最外层容器插槽 */
|
||||
/** outermost container slot */
|
||||
containerAppendSlot?: React.ReactNode;
|
||||
importPromptWhenEmpty?: string;
|
||||
getConversationId?: () => string | undefined;
|
||||
|
||||
@@ -18,7 +18,7 @@ import { useCallback, useRef, useEffect, type ReactNode, useMemo } from 'react';
|
||||
|
||||
import { merge } from 'lodash-es';
|
||||
import { Renderer, Placeholder, useEditor } from '@coze-editor/editor/react';
|
||||
// promptPreset是针对Prompt提供了一系列内置扩展的集合
|
||||
// promptPreset is a collection of built-in extensions for Prompt
|
||||
import promptPreset, {
|
||||
type EditorAPI,
|
||||
} from '@coze-editor/editor/preset-prompt';
|
||||
@@ -29,7 +29,7 @@ import { LanguageSupport } from '@coze-common/editor-plugins/language-support';
|
||||
import { defaultTheme } from '@/theme/default';
|
||||
|
||||
export interface PromptEditorRenderProps {
|
||||
readonly?: boolean; // 所有插入编辑器相关操作禁用:action-bar
|
||||
readonly?: boolean; // All insert editor related operations are disabled: action-bar
|
||||
placeholder?: ReactNode;
|
||||
className?: string;
|
||||
dataTestID?: string;
|
||||
@@ -39,11 +39,11 @@ export interface PromptEditorRenderProps {
|
||||
onChange?: (value: string) => void;
|
||||
onFocus?: () => void;
|
||||
/**
|
||||
* 光标焦点丢失
|
||||
* Cursor focus lost
|
||||
*/
|
||||
onBlur?: () => void;
|
||||
options?: Record<string, string | number>;
|
||||
isControled?: boolean; // 是否受控
|
||||
isControled?: boolean; // Is it controlled
|
||||
getEditor?: (editor: EditorAPI) => void;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ export const PromptEditorRender: React.FC<PromptEditorRenderProps> = props => {
|
||||
};
|
||||
}, [editor, onFocus]);
|
||||
|
||||
// 值受控
|
||||
// value controlled
|
||||
useEffect(() => {
|
||||
const curEditor = apiRef.current;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import { type ModalHierarchyServiceConstructor } from './type';
|
||||
import { type FreeGrabModalHierarchyAction } from './store';
|
||||
|
||||
export class FreeGrabModalHierarchyService {
|
||||
/** Tip: semi modal zIndex 为 1000 */
|
||||
/** Tip: semi modal zIndex is 1000 */
|
||||
private baseZIndex = 1000;
|
||||
public registerModal: FreeGrabModalHierarchyAction['registerModal'];
|
||||
public removeModal: FreeGrabModalHierarchyAction['removeModal'];
|
||||
|
||||
@@ -19,7 +19,7 @@ import { create } from 'zustand';
|
||||
import { produce } from 'immer';
|
||||
|
||||
export interface FreeGrabModalHierarchyState {
|
||||
// modal 的 key list
|
||||
// Modal key list
|
||||
modalHierarchyList: string[];
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export interface FreeGrabModalHierarchyAction {
|
||||
}
|
||||
|
||||
/**
|
||||
* 可自由拖拽的弹窗之间的层级关系
|
||||
* Hierarchical relationship between pop-ups that can be dragged and dropped freely
|
||||
*/
|
||||
export const createFreeGrabModalHierarchyStore = () =>
|
||||
create<FreeGrabModalHierarchyState & FreeGrabModalHierarchyAction>()(
|
||||
|
||||
@@ -45,14 +45,14 @@ export const insertToNewline = async ({
|
||||
selection,
|
||||
scrollIntoView: true,
|
||||
});
|
||||
// 等待下一个微任务周期,确保状态已更新
|
||||
// Wait for the next microtask cycle to ensure that the status has been updated
|
||||
await Promise.resolve();
|
||||
|
||||
// 使用更新后的state获取最新文档内容
|
||||
// Use the updated state to get the latest document content
|
||||
const newDoc = editor.$view.state.doc.toString();
|
||||
|
||||
// 插入到新一行
|
||||
// 注意:该操作提前会触发 chrome bug 导致崩溃问题
|
||||
// Insert to new line
|
||||
// Note: This operation will trigger a chrome bug in advance, resulting in a crash
|
||||
editor.focus();
|
||||
return newDoc;
|
||||
};
|
||||
|
||||
@@ -23,13 +23,13 @@ export const getSelectionBoundary = (editor: EditorAPI) => {
|
||||
return { left: 0, top: 0, width: 0, height: 0 };
|
||||
}
|
||||
|
||||
// 初始化最大矩形
|
||||
// Initialize the largest rectangle
|
||||
let maxLeft = Infinity;
|
||||
let maxTop = Infinity;
|
||||
let maxRight = -Infinity;
|
||||
let maxBottom = -Infinity;
|
||||
|
||||
// 遍历所有矩形,计算包围盒的边界
|
||||
// Iterate through all rectangles and calculate the bounding box boundary
|
||||
rects.forEach(rect => {
|
||||
maxLeft = Math.min(maxLeft, rect.left);
|
||||
maxTop = Math.min(maxTop, rect.top);
|
||||
@@ -37,18 +37,18 @@ export const getSelectionBoundary = (editor: EditorAPI) => {
|
||||
maxBottom = Math.max(maxBottom, rect.top + (rect.height ?? 0));
|
||||
});
|
||||
|
||||
// 计算最终的宽度和高度
|
||||
// Calculate the final width and height
|
||||
const width = maxRight - maxLeft;
|
||||
const height = maxBottom - maxTop;
|
||||
|
||||
// 获取编辑器的滚动位置
|
||||
// Get the scroll position of the editor
|
||||
const { scrollLeft } = editor.$view.scrollDOM;
|
||||
const { scrollTop } = editor.$view.scrollDOM;
|
||||
|
||||
// 获取编辑器容器的位置
|
||||
// Get the location of the editor container
|
||||
const editorRect = editor.$view.dom.getBoundingClientRect();
|
||||
|
||||
// 计算相对于视口的绝对位置
|
||||
// Calculate the absolute position relative to the viewport
|
||||
const absoluteLeft = editorRect.left + maxLeft - scrollLeft;
|
||||
const absoluteTop = editorRect.top + maxTop - scrollTop;
|
||||
const absoluteBottom = editorRect.top + maxBottom - scrollTop;
|
||||
|
||||
Reference in New Issue
Block a user