Skip to content

Commit

Permalink
fix: image width and height modification in url is not saved
Browse files Browse the repository at this point in the history
  • Loading branch information
finnar-bin committed Jan 4, 2024
1 parent 1c8d71d commit 9f207b4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/shell/components/FieldTypeTinyMCE/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,17 @@ export const FieldTypeTinyMCE = React.memo(function FieldTypeTinyMCE({
}
}}
onObjectResized={(evt) => {
evt.target.src = `${evt.target.currentSrc}?width=${evt.width}&height=${evt.height}`
const currentValue = tinymce?.activeEditor?.getContent() ?? "";
const newImageUrl = `${
evt.target.currentSrc?.split("?")?.[0]
}?width=${evt.width}&height=${evt.height}`;

tinymce?.activeEditor?.setContent(
currentValue.replace(
evt.target.currentSrc?.replaceAll("&", "&"),
newImageUrl
)
);
}}
init={{
plugins: [
Expand Down

0 comments on commit 9f207b4

Please sign in to comment.