chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -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