From af427cd01c38f206452967bb3434e86ee5642b8a Mon Sep 17 00:00:00 2001 From: Graeme Fulton Date: Sun, 23 Jun 2024 12:53:13 -0400 Subject: [PATCH] fix for video, and remove alt text button for video for now --- components/Editor/Menus/Common/WidthRange.js | 48 ++-------- components/Editor/Menus/ImageMenu.jsx | 14 +-- .../VideoPopoverButton/VideoPopoverButton.js | 89 +++++++++---------- components/Editor/Menus/VideoMenu.js | 6 +- 4 files changed, 58 insertions(+), 99 deletions(-) diff --git a/components/Editor/Menus/Common/WidthRange.js b/components/Editor/Menus/Common/WidthRange.js index 26da138f..981f64ae 100644 --- a/components/Editor/Menus/Common/WidthRange.js +++ b/components/Editor/Menus/Common/WidthRange.js @@ -19,33 +19,8 @@ const WidthSlider = ({ editor, showing, figureType }) => { } const updateWidth = value => { - if (figureType === "video") { - //the video rerenders on change quite badly,causing the tooltip to disappear - //so only update video width on mouseup - - editor.commands.updateAttributes("figure", { width: value + "%" }); - } else { - //if not video, update width as the slider moves - - // let height = null - // //get child of figure - // const image_node = editor.state.selection?.$anchor?.nodeAfter?.content?.content?.length?editor.state.selection?.$anchor?.nodeAfter?.content?.content[0]:null - // console.log(image_node) - // if(image_node?.type?.name=='image'){ - // //get current selection position - // const parentPos = editor.state.selection.$anchor.pos +1 - // var domNode = editor.view.nodeDOM(parentPos) - // console.log(domNode) - // //get intrinsic height of image - // let styles = window.getComputedStyle(domNode) - // let minHeight = styles.height - // //depending on the old percentage (value), the new percentage, and the current compouted height, calculate the new height in % - // height = minHeight - // } - - setValue(value); - editor.commands.updateAttributes("figure", { width: value + "%" }); - } + setValue(value); + editor.commands.updateAttributes("figure", { width: value + "%" }); }; return ( @@ -61,21 +36,14 @@ const WidthSlider = ({ editor, showing, figureType }) => { value={value} // onInput={(e) => setWidth(e.target.value)} onChange={e => { - if (figureType === "video") { - //the video rerenders on change quite badly,causing the tooltip to disappear - //so only update video width on mouseup - setValue(e.target.value); - } else { - //if not video, update width as the slider moves - updateWidth(e.target.value); - } + updateWidth(e.target.value); }} // onChange={(e) => setValue(e.target.value)} - onMouseUp={e => { - if (figureType === "video") { - updateWidth(e.target.value); - } - }} + // onMouseUp={e => { + // if (figureType === "video") { + // updateWidth(e.target.value); + // } + // }} /> {value}% diff --git a/components/Editor/Menus/ImageMenu.jsx b/components/Editor/Menus/ImageMenu.jsx index dcaaf2cc..4e2ad60f 100644 --- a/components/Editor/Menus/ImageMenu.jsx +++ b/components/Editor/Menus/ImageMenu.jsx @@ -73,14 +73,14 @@ const ImageMenu = ({ editor, isSelecting }) => { const selection = editor.state.selection; const isTextSelection = selection instanceof TextSelection; - // if (!editor.isActive("figure", { figureType: "image" })) { - // return false; - // } + if (!editor.isActive("figure", { figureType: "image" })) { + return false; + } - // if (isTextSelection) { - // setShowing(false); - // return false; - // } + if (isTextSelection) { + setShowing(false); + return false; + } //update image src const figure_node = selection?.$anchor?.nodeAfter diff --git a/components/Editor/Menus/MenuButtons/VideoPopoverButton/VideoPopoverButton.js b/components/Editor/Menus/MenuButtons/VideoPopoverButton/VideoPopoverButton.js index 6814543a..0fd8c4fe 100644 --- a/components/Editor/Menus/MenuButtons/VideoPopoverButton/VideoPopoverButton.js +++ b/components/Editor/Menus/MenuButtons/VideoPopoverButton/VideoPopoverButton.js @@ -204,55 +204,46 @@ const VideoModalButton = ({ editor, showing }) => { }; return ( - -
- - setModal("alt")} - className={"text-sm hover:bg-gray-800 hover:text-white"} - aria-label="Update link" - > - ALT - - - {/* */} - -
- - {modalOption == "alt" && "Alternative Text"} - - {modalOption == "alt" && - "Write a brief description of this image for readers with visual impairments"} - -
- -
-
- hi - {/* */} -
- {/*
- - - - - - - -
*/} - - - - - -
-
+
+ +
+ + // + //
+ // + // setModal("alt")} + // className={"text-sm hover:bg-gray-800 hover:text-white"} + // aria-label="Update link" + // > + // ALT + // + // + // + //
+ // + // {modalOption == "alt" && "Alternative Text"} + // + // {modalOption == "alt" && + // "Write a brief description of this image for readers with visual impairments"} + // + //
+ // + //
+ //
+ // hi + //
+ // + // + // + // + // + //
+ //
); }; diff --git a/components/Editor/Menus/VideoMenu.js b/components/Editor/Menus/VideoMenu.js index fa183272..4a672dd3 100644 --- a/components/Editor/Menus/VideoMenu.js +++ b/components/Editor/Menus/VideoMenu.js @@ -51,7 +51,7 @@ const VideoMenu = ({ editor, isSelecting }) => { tippyOptions={{ // arrow: roundArrow, arrow: false, - placement: "top-start", + placement: "left-start", zIndex: "38", popperOptions: { modifiers: [{ name: "eventListeners", options: { scroll: false } }, @@ -127,8 +127,8 @@ const VideoMenu = ({ editor, isSelecting }) => { > {/* bold */}
+ className={`${isSelecting ? "" : "pointer-events-all"} p-2 w-fit -mt-[52px] ml-[102%] duration-300 rounded-xl shadow-md bg-gray-900 flex text-gray-100`} + >