suport iFrame
This commit is contained in:
parent
9da3e47877
commit
44390cb146
@ -1039,7 +1039,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
this.state.activeEmbeddable?.state === "hover";
|
this.state.activeEmbeddable?.state === "hover";
|
||||||
|
|
||||||
// Modify the scale based on el.scale property
|
// Modify the scale based on el.scale property
|
||||||
const [xScale, yScale] = el.scale;
|
const [xScale, yScale] = el.scale ?? [1, 1];
|
||||||
const scaledTransform = `scale(${scale * xScale}, ${scale * yScale})`;
|
const scaledTransform = `scale(${scale * xScale}, ${scale * yScale})`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -1056,10 +1056,9 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
: "none",
|
: "none",
|
||||||
display: isVisible ? "block" : "none",
|
display: isVisible ? "block" : "none",
|
||||||
opacity: el.opacity / 100,
|
opacity: el.opacity / 100,
|
||||||
["--embeddable-radius" as string]: `${getCornerRadius(
|
["--embeddable-radius" as string]: `${
|
||||||
Math.min(el.width, el.height),
|
getCornerRadius(Math.min(el.width, el.height), el) / xScale
|
||||||
el,
|
}px`,
|
||||||
)}px`,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
@ -294,8 +294,11 @@ const restoreElement = (
|
|||||||
case "ellipse":
|
case "ellipse":
|
||||||
case "rectangle":
|
case "rectangle":
|
||||||
case "diamond":
|
case "diamond":
|
||||||
case "iframe":
|
|
||||||
return restoreElementWithProperties(element, {});
|
return restoreElementWithProperties(element, {});
|
||||||
|
case "iframe":
|
||||||
|
return restoreElementWithProperties(element, {
|
||||||
|
scale: element.scale ?? [1, 1],
|
||||||
|
});
|
||||||
case "embeddable":
|
case "embeddable":
|
||||||
return restoreElementWithProperties(element, {
|
return restoreElementWithProperties(element, {
|
||||||
validated: null,
|
validated: null,
|
||||||
|
@ -153,6 +153,7 @@ export const newIframeElement = (
|
|||||||
): NonDeleted<ExcalidrawIframeElement> => {
|
): NonDeleted<ExcalidrawIframeElement> => {
|
||||||
return {
|
return {
|
||||||
..._newElementBase<ExcalidrawIframeElement>("iframe", opts),
|
..._newElementBase<ExcalidrawIframeElement>("iframe", opts),
|
||||||
|
scale: [1, 1],
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
isArrowElement,
|
isArrowElement,
|
||||||
isBoundToContainer,
|
isBoundToContainer,
|
||||||
|
isIframeLikeElement,
|
||||||
isFrameLikeElement,
|
isFrameLikeElement,
|
||||||
isFreeDrawElement,
|
isFreeDrawElement,
|
||||||
isImageElement,
|
isImageElement,
|
||||||
@ -586,7 +587,7 @@ export const resizeSingleElement = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
if ("scale" in element && "scale" in stateAtResizeStart) {
|
if ("scale" in element && "scale" in stateAtResizeStart) {
|
||||||
if (isFrameLikeElement(element)) {
|
if (isIframeLikeElement(element)) {
|
||||||
if (shouldMaintainAspectRatio) {
|
if (shouldMaintainAspectRatio) {
|
||||||
const scale: [number, number] = [
|
const scale: [number, number] = [
|
||||||
Math.abs(
|
Math.abs(
|
||||||
|
@ -104,6 +104,7 @@ export type ExcalidrawIframeElement = _ExcalidrawElementBase &
|
|||||||
type: "iframe";
|
type: "iframe";
|
||||||
// TODO move later to AI-specific frame
|
// TODO move later to AI-specific frame
|
||||||
customData?: { generationData?: MagicCacheData };
|
customData?: { generationData?: MagicCacheData };
|
||||||
|
scale: [number, number];
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
export type ExcalidrawIframeLikeElement =
|
export type ExcalidrawIframeLikeElement =
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
isInitializedImageElement,
|
isInitializedImageElement,
|
||||||
isArrowElement,
|
isArrowElement,
|
||||||
hasBoundTextElement,
|
hasBoundTextElement,
|
||||||
isFrameLikeElement,
|
isIframeLikeElement,
|
||||||
isMagicFrameElement,
|
isMagicFrameElement,
|
||||||
} from "../element/typeChecks";
|
} from "../element/typeChecks";
|
||||||
import { getElementAbsoluteCoords } from "../element/bounds";
|
import { getElementAbsoluteCoords } from "../element/bounds";
|
||||||
@ -522,7 +522,7 @@ const drawElementFromCanvas = (
|
|||||||
if (
|
if (
|
||||||
"scale" in elementWithCanvas.element &&
|
"scale" in elementWithCanvas.element &&
|
||||||
!isPendingImageElement(element, renderConfig) &&
|
!isPendingImageElement(element, renderConfig) &&
|
||||||
!isFrameLikeElement(element)
|
!isIframeLikeElement(element)
|
||||||
) {
|
) {
|
||||||
context.scale(
|
context.scale(
|
||||||
elementWithCanvas.element.scale[0],
|
elementWithCanvas.element.scale[0],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user