0.3.9修复onlyoffice 的打开问题
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import { BlockNoteEditor, Block } from "@blocknote/core";
|
||||
import { createReactBlockSpec } from "@blocknote/react";
|
||||
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import React, { useCallback, useMemo, useState } from "react";
|
||||
import type { CustomBlockSchema } from "../schema";
|
||||
import CompactTablePreview from "@/components/online-table/CompactTablePreview";
|
||||
import { useEditorBridgeStore } from "@/store/editor-bridge";
|
||||
@@ -53,12 +53,15 @@ const OnlineTableBlockComponent = ({
|
||||
height: storedHeight ?? DEFAULT_HEIGHT,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
setDraftSize({
|
||||
width: storedWidth ?? DEFAULT_WIDTH,
|
||||
height: storedHeight ?? DEFAULT_HEIGHT,
|
||||
});
|
||||
}, [storedWidth, storedHeight]);
|
||||
const clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));
|
||||
|
||||
const committedSize = useMemo(
|
||||
() => ({
|
||||
width: clamp(storedWidth ?? DEFAULT_WIDTH, MIN_WIDTH, MAX_WIDTH),
|
||||
height: clamp(storedHeight ?? DEFAULT_HEIGHT, MIN_HEIGHT, MAX_HEIGHT),
|
||||
}),
|
||||
[storedHeight, storedWidth],
|
||||
);
|
||||
|
||||
const commitSize = useCallback(
|
||||
(next: { width: number; height: number }) => {
|
||||
@@ -71,7 +74,7 @@ const OnlineTableBlockComponent = ({
|
||||
},
|
||||
});
|
||||
},
|
||||
[block, block.props, editor],
|
||||
[block, editor],
|
||||
);
|
||||
|
||||
// 阶段三:实现双击/按钮进入全屏编辑
|
||||
@@ -87,20 +90,19 @@ const OnlineTableBlockComponent = ({
|
||||
editor.removeBlocks([block.id]);
|
||||
}, [block.id, editor]);
|
||||
|
||||
const clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));
|
||||
|
||||
const startResize = useCallback(
|
||||
(handle: ResizeHandle) => (event: React.MouseEvent) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
const startX = event.clientX;
|
||||
const startY = event.clientY;
|
||||
const startWidth = draftSize.width;
|
||||
const startHeight = draftSize.height;
|
||||
const startWidth = committedSize.width;
|
||||
const startHeight = committedSize.height;
|
||||
let nextWidth = startWidth;
|
||||
let nextHeight = startHeight;
|
||||
const axes = handleMapping[handle];
|
||||
setActiveHandle(handle);
|
||||
setDraftSize({ width: startWidth, height: startHeight });
|
||||
document.body.style.userSelect = "none";
|
||||
const cursor =
|
||||
axes.horizontal && axes.vertical
|
||||
@@ -155,16 +157,16 @@ const OnlineTableBlockComponent = ({
|
||||
window.addEventListener("mousemove", handleMove);
|
||||
window.addEventListener("mouseup", handleUp);
|
||||
},
|
||||
[commitSize, draftSize.height, draftSize.width],
|
||||
[commitSize, committedSize.height, committedSize.width],
|
||||
);
|
||||
|
||||
const size = useMemo(
|
||||
() => ({
|
||||
width: clamp(draftSize.width, MIN_WIDTH, MAX_WIDTH),
|
||||
height: clamp(draftSize.height, MIN_HEIGHT, MAX_HEIGHT),
|
||||
}),
|
||||
[draftSize.height, draftSize.width],
|
||||
);
|
||||
const size = useMemo(() => {
|
||||
const src = activeHandle ? draftSize : committedSize;
|
||||
return {
|
||||
width: clamp(src.width, MIN_WIDTH, MAX_WIDTH),
|
||||
height: clamp(src.height, MIN_HEIGHT, MAX_HEIGHT),
|
||||
};
|
||||
}, [activeHandle, committedSize, draftSize]);
|
||||
|
||||
const handleClass = (handle: ResizeHandle) =>
|
||||
`wolai-table-resize-handle wolai-table-resize-handle--${handle} ${
|
||||
|
||||
Reference in New Issue
Block a user