diff --git a/components/Blocks/EmbedBlock.tsx b/components/Blocks/EmbedBlock.tsx
index 0dd9e967..4d892938 100644
--- a/components/Blocks/EmbedBlock.tsx
+++ b/components/Blocks/EmbedBlock.tsx
@@ -1,6 +1,6 @@
import { useEntitySetContext } from "components/EntitySetProvider";
import { generateKeyBetween } from "fractional-indexing";
-import { useEffect, useState } from "react";
+import { useCallback, useEffect, useState } from "react";
import { useEntity, useReplicache } from "src/replicache";
import { useUIState } from "src/useUIState";
import { BlockProps } from "./Block";
@@ -13,9 +13,11 @@ import { isUrl } from "src/utils/isURL";
import { elementId } from "src/utils/elementId";
import { deleteBlock } from "./DeleteBlock";
import { focusBlock } from "src/utils/focusBlock";
+import { useDrag } from "src/hooks/useDrag";
export const EmbedBlock = (props: BlockProps & { preview?: boolean }) => {
let { permissions } = useEntitySetContext();
+ let { rep } = useReplicache();
let url = useEntity(props.entityID, "embed/url");
let isCanvasBlock = props.pageType === "canvas";
@@ -23,6 +25,24 @@ export const EmbedBlock = (props: BlockProps & { preview?: boolean }) => {
s.selectedBlocks.find((b) => b.value === props.entityID),
);
+ let height = useEntity(props.entityID, "embed/height")?.data.value || 360;
+
+ let heightOnDragEnd = useCallback(
+ (dragPosition: { x: number; y: number }) => {
+ rep?.mutate.assertFact({
+ entity: props.entityID,
+ attribute: "embed/height",
+ data: {
+ type: "number",
+ value: height + dragPosition.y,
+ },
+ });
+ },
+ [props, rep, height],
+ );
+
+ let heightHandle = useDrag({ onDragEnd: heightOnDragEnd });
+
useEffect(() => {
if (props.preview) return;
let input = document.getElementById(elementId.block(props.entityID).input);
@@ -55,10 +75,11 @@ export const EmbedBlock = (props: BlockProps & { preview?: boolean }) => {
}
return (
-
+
{/*
the iframe!
- very simple, just a fixed height (could add as an option)
can also add 'allow' and 'referrerpolicy' attributes later if needed
*/}
-
*/}
+
+ {!props.preview && permissions.write && (
+ <>
+
+ >
+ )}
);
};
diff --git a/components/Blocks/useBlockMouseHandlers.ts b/components/Blocks/useBlockMouseHandlers.ts
index 6ba156e6..78f86bee 100644
--- a/components/Blocks/useBlockMouseHandlers.ts
+++ b/components/Blocks/useBlockMouseHandlers.ts
@@ -16,6 +16,7 @@ export function useBlockMouseHandlers(props: Block) {
let { rep } = useReplicache();
let onMouseDown = useCallback(
(e: MouseEvent) => {
+ if ((e.target as Element).getAttribute("data-draggable")) return;
if (isMobile) return;
if (!entity_set.permissions.write) return;
useSelectingMouse.setState({ start: props.value });
diff --git a/components/SelectionManager.tsx b/components/SelectionManager.tsx
index 89ba9672..c5cb1554 100644
--- a/components/SelectionManager.tsx
+++ b/components/SelectionManager.tsx
@@ -491,6 +491,7 @@ export function SelectionManager() {
if (isMobile) return;
if (!entity_set.permissions.write) return;
let mouseDownListener = (e: MouseEvent) => {
+ if ((e.target as Element).getAttribute("data-draggable")) return;
setMouseDown(true);
let contentEditableParent = getContentEditableParent(e.target as Node);
if (contentEditableParent) {
diff --git a/src/hooks/useDrag.ts b/src/hooks/useDrag.ts
index 9323acc8..d734b0cf 100644
--- a/src/hooks/useDrag.ts
+++ b/src/hooks/useDrag.ts
@@ -76,6 +76,7 @@ export const useDrag = (args: {
window.addEventListener(
"touchmove",
(e) => {
+ e.preventDefault();
if (args.delay && touchStart.current) {
const deltaX = e.touches[0].clientX - touchStart.current.x;
const deltaY = e.touches[0].clientY - touchStart.current.y;
@@ -102,6 +103,7 @@ export const useDrag = (args: {
window.addEventListener(
"pointermove",
(e: PointerEvent) => {
+ e.preventDefault();
currentDragDelta.current.x = e.clientX - dragStart.x;
currentDragDelta.current.y = e.clientY - dragStart.y;
setDragDelta({ ...currentDragDelta.current });
diff --git a/src/replicache/attributes.ts b/src/replicache/attributes.ts
index c1fab8c1..fe777164 100644
--- a/src/replicache/attributes.ts
+++ b/src/replicache/attributes.ts
@@ -117,6 +117,10 @@ const EmbedBlockAttributes = {
type: "string",
cardinality: "one",
},
+ "embed/height": {
+ type: "number",
+ cardinality: "one",
+ },
} as const;
export const ThemeAttributes = {