Skip to content

Commit

Permalink
fix: caption width match file container TypeCellOS#1169
Browse files Browse the repository at this point in the history
  • Loading branch information
mwonng committed Oct 24, 2024
1 parent 8867e64 commit e8e44c7
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions packages/core/src/blocks/FileBlockContent/fileBlockHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ export const createFileAndCaptionWrapper = (
caption.className = "bn-file-caption";
caption.textContent = block.props.caption;

if (typeof block.props.previewWidth === "number" &&
block.props.previewWidth > 0 &&
block.props.caption !== undefined
) {
caption.style.width = `${block.props.previewWidth}px`
}

fileAndCaptionWrapper.appendChild(file);
fileAndCaptionWrapper.appendChild(caption);

Expand Down Expand Up @@ -266,10 +273,10 @@ export const createResizeHandlesWrapper = (
// calculate the new width of the element.
let resizeParams:
| {
handleUsed: "left" | "right";
initialWidth: number;
initialClientX: number;
}
handleUsed: "left" | "right";
initialWidth: number;
initialClientX: number;
}
| undefined;

// Updates the element width with an updated width depending on the cursor X
Expand Down Expand Up @@ -331,6 +338,10 @@ export const createResizeHandlesWrapper = (
// `width` prop to the new value.
const windowMouseUpHandler = (event: MouseEvent) => {
// Hides the drag handles if the cursor is no longer over the element.

// console.log("mouse up-- now ---", wrapper, editor, block)
// console.log("next to wrapper-- now ---", wrapper.nextSibling, element)
const caption = wrapper.nextSibling as HTMLElement;
if (
(!event.target ||
!wrapper.contains(event.target as Node) ||
Expand Down

0 comments on commit e8e44c7

Please sign in to comment.