|
@@ -13,6 +13,7 @@ import { useLoading } from "src/hooks/useLoading";
|
|
import { useConfig } from "src/hocs/config";
|
|
import { useConfig } from "src/hocs/config";
|
|
import { Tools } from "../Editor/Tools";
|
|
import { Tools } from "../Editor/Tools";
|
|
import { ConfigActionType } from "src/reducer/reducer";
|
|
import { ConfigActionType } from "src/reducer/reducer";
|
|
|
|
+import { useFocusNode } from "src/hooks/useFocusNode";
|
|
|
|
|
|
const StyledLiveEditor = styled.div`
|
|
const StyledLiveEditor = styled.div`
|
|
position: relative;
|
|
position: relative;
|
|
@@ -51,49 +52,16 @@ export const LiveEditor: React.FC = React.memo(function LiveEditor() {
|
|
setData({ nodes, edges });
|
|
setData({ nodes, edges });
|
|
}, [json, settings.expand]);
|
|
}, [json, settings.expand]);
|
|
|
|
|
|
- React.useEffect(() => {
|
|
|
|
- if (!settings.zoomPanPinch) return;
|
|
|
|
- const zoomPanPinch = settings.zoomPanPinch.instance.wrapperComponent;
|
|
|
|
-
|
|
|
|
- const node = document.querySelector(
|
|
|
|
- `span[data-key*='${settings.searchNode}' i]`
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- document
|
|
|
|
- .querySelector("foreignObject.searched")
|
|
|
|
- ?.classList.remove("searched");
|
|
|
|
-
|
|
|
|
- if (zoomPanPinch && node && node.parentElement) {
|
|
|
|
- const newScale = 1;
|
|
|
|
- const x = Number(node.getAttribute("data-x"));
|
|
|
|
- const y = Number(node.getAttribute("data-y"));
|
|
|
|
-
|
|
|
|
- const newPositionX =
|
|
|
|
- (zoomPanPinch.offsetLeft - x) * newScale +
|
|
|
|
- node.getBoundingClientRect().width;
|
|
|
|
- const newPositionY =
|
|
|
|
- (zoomPanPinch.offsetTop - y) * newScale +
|
|
|
|
- node.getBoundingClientRect().height;
|
|
|
|
-
|
|
|
|
- node.parentElement.parentElement
|
|
|
|
- ?.closest("foreignObject")
|
|
|
|
- ?.classList.toggle("searched");
|
|
|
|
-
|
|
|
|
- settings.zoomPanPinch?.setTransform(newPositionX, newPositionY, newScale);
|
|
|
|
- }
|
|
|
|
- }, [settings.searchNode, settings.zoomPanPinch]);
|
|
|
|
-
|
|
|
|
const onCanvasClick = () => {
|
|
const onCanvasClick = () => {
|
|
const input = document.querySelector("input:focus") as HTMLInputElement;
|
|
const input = document.querySelector("input:focus") as HTMLInputElement;
|
|
if (input) input.blur();
|
|
if (input) input.blur();
|
|
};
|
|
};
|
|
|
|
|
|
- const onInit = (ref: ReactZoomPanPinchRef) => {
|
|
|
|
|
|
+ const onInit = (ref: ReactZoomPanPinchRef) =>
|
|
dispatch({
|
|
dispatch({
|
|
type: ConfigActionType.SET_ZOOM_PAN_PICNH_REF,
|
|
type: ConfigActionType.SET_ZOOM_PAN_PICNH_REF,
|
|
payload: ref,
|
|
payload: ref,
|
|
});
|
|
});
|
|
- };
|
|
|
|
|
|
|
|
if (pageLoaded)
|
|
if (pageLoaded)
|
|
return (
|
|
return (
|