Skip to content

Commit

Permalink
fix(ImageEditor): fixes editor layout when editing in full screen mode
Browse files Browse the repository at this point in the history
Signed-off-by: Sanskar Soni <[email protected]>
  • Loading branch information
sanskar-soni-9 committed Jul 29, 2024
1 parent d315aac commit 9077f8b
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion css/viewer-main.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer-main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2084,7 +2084,7 @@ var E4=Object.defineProperty;var D4=(e,r,a)=>r in e?E4(e,r,{enumerable:!0,config
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/const um=e=>{let r={};if(e.nodeType===1){if(e.attributes.length>0){r["@attributes"]={};for(let a=0;a<e.attributes.length;a++){const n=e.attributes.item(a);r["@attributes"][n.nodeName]=n.nodeValue}}}else e.nodeType===3&&(r=e.nodeValue);if(e.hasChildNodes())for(let a=0;a<e.childNodes.length;a++){const n=e.childNodes.item(a),i=n.nodeName;if(typeof r[i]>"u")r[i]=um(n);else{if(typeof r[i].push>"u"){const s=r[i];r[i]=[],r[i].push(s)}r[i].push(um(n))}}return r},lae=e=>{let r=null;try{r=new DOMParser().parseFromString(e,"text/xml")}catch(a){console.error("Failed to parse xml document",a)}return r},W2=e=>{const r=um(lae(e))["d:multistatus"]["d:response"],a=[];for(const n in r){const i=r[n]["d:propstat"];i["d:status"]["#text"]==="HTTP/1.1 200 OK"&&a.push({id:parseInt(i["d:prop"]["oc:id"]["#text"]),displayName:i["d:prop"]["oc:display-name"]["#text"],canAssign:i["d:prop"]["oc:can-assign"]["#text"]==="true",userAssignable:i["d:prop"]["oc:user-assignable"]["#text"]==="true",userVisible:i["d:prop"]["oc:user-visible"]["#text"]==="true"})}return a},uae=async function(){if(window.NextcloudVueDocs)return Promise.resolve(W2(window.NextcloudVueDocs.tags));const e=await It({method:"PROPFIND",url:vc("dav")+"/systemtags/",data:'<?xml version="1.0"?>\n <d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">\n <d:prop>\n <oc:id />\n <oc:display-name />\n <oc:user-visible />\n <oc:user-assignable />\n <oc:can-assign />\n </d:prop>\n </d:propfind>'});return W2(e.data)};Qe(fU);({...Si.props,placeholder:ce("Select a tag")});Qe(_3);Qe(xU);Qe(WU);Bd(function(e){this.loadGroup(e)},200);const Au={name:pe("viewer","Name"),save:pe("viewer","Save"),saveAs:pe("viewer","Save as"),back:pe("viewer","Back"),loading:pe("viewer","Loading …"),resetOperations:pe("viewer","Reset"),changesLoseConfirmation:pe("viewer","All changes will be lost."),changesLoseConfirmationHint:pe("viewer","Are you sure you want to continue?"),cancel:pe("viewer","Cancel"),continue:pe("viewer","Continue"),undoTitle:pe("viewer","Undo"),redoTitle:pe("viewer","Redo"),showImageTitle:pe("viewer","Show original image"),zoomInTitle:pe("viewer","Zoom in"),zoomOutTitle:pe("viewer","Zoom out"),toggleZoomMenuTitle:pe("viewer","Toggle zoom menu"),adjustTab:pe("viewer","Adjust"),finetuneTab:pe("viewer","Fine-tune"),filtersTab:pe("viewer","Filters"),watermarkTab:pe("viewer","Watermark"),annotateTab:pe("viewer","Draw"),resize:pe("viewer","Resize"),resizeTab:pe("viewer","Resize"),invalidImageError:pe("viewer","Invalid image."),uploadImageError:pe("viewer","Error while uploading the image."),areNotImages:pe("viewer","are not images"),isNotImage:pe("viewer","is not an image"),toBeUploaded:pe("viewer","to be uploaded"),cropTool:pe("viewer","Crop"),original:pe("viewer","Original"),custom:pe("viewer","Custom"),square:pe("viewer","Square"),landscape:pe("viewer","Landscape"),portrait:pe("viewer","Portrait"),ellipse:pe("viewer","Ellipse"),classicTv:pe("viewer","Classic TV"),cinemascope:pe("viewer","CinemaScope"),arrowTool:pe("viewer","Arrow"),blurTool:pe("viewer","Blur"),brightnessTool:pe("viewer","Brightness"),contrastTool:pe("viewer","Contrast"),ellipseTool:pe("viewer","Ellipse"),unFlipX:pe("viewer","Un-flip X"),flipX:pe("viewer","Flip X"),unFlipY:pe("viewer","Un-flip Y"),flipY:pe("viewer","Flip Y"),hsvTool:pe("viewer","HSV"),hue:pe("viewer","Hue"),saturation:pe("viewer","Saturation"),value:pe("viewer","Value"),imageTool:pe("viewer","Image"),importing:pe("viewer","Importing …"),addImage:pe("viewer","+ Add image"),lineTool:pe("viewer","Line"),penTool:pe("viewer","Pen"),polygonTool:pe("viewer","Polygon"),sides:pe("viewer","Sides"),rectangleTool:pe("viewer","Rectangle"),cornerRadius:pe("viewer","Corner Radius"),resizeWidthTitle:pe("viewer","Width in pixels"),resizeHeightTitle:pe("viewer","Height in pixels"),toggleRatioLockTitle:pe("viewer","Toggle ratio lock"),reset:pe("viewer","Reset"),resetSize:pe("viewer","Reset to original image size"),rotateTool:pe("viewer","Rotate"),textTool:pe("viewer","Text"),textSpacings:pe("viewer","Text spacing"),textAlignment:pe("viewer","Text alignment"),fontFamily:pe("viewer","Font family"),size:pe("viewer","Size"),letterSpacing:pe("viewer","Letter spacing"),lineHeight:pe("viewer","Line height"),warmthTool:pe("viewer","Warmth"),addWatermark:pe("viewer","+ Add watermark"),addWatermarkTitle:pe("viewer","Choose watermark type"),uploadWatermark:pe("viewer","Upload watermark"),addWatermarkAsText:pe("viewer","Add as text"),padding:pe("viewer","Padding"),shadow:pe("viewer","Shadow"),horizontal:pe("viewer","Horizontal"),vertical:pe("viewer","Vertical"),blur:pe("viewer","Blur"),opacity:pe("viewer","Opacity"),position:pe("viewer","Position"),stroke:pe("viewer","Stroke"),saveAsModalLabel:pe("viewer","Save image as"),extension:pe("viewer","Extension"),nameIsRequired:pe("viewer","Name is required."),quality:pe("viewer","Quality"),imageDimensionsHoverTitle:pe("viewer","Saved image size (width x height)"),cropSizeLowerThanResizedWarning:pe("viewer","Note that the selected crop area is lower than the applied resize which might cause quality decrease"),actualSize:pe("viewer","Actual size (100%)"),fitSize:pe("viewer","Fit size")};let Su,Q2;const cae={name:"ImageEditor",props:{fileid:{type:[String,Number],required:!0},mime:{type:String,required:!0},src:{type:String,required:!0}},data(){return{imageEditor:null}},computed:{config(){return{source:this.src,defaultSavedImageName:this.defaultSavedImageName,defaultSavedImageType:this.defaultSavedImageType,useBackendTranslations:!1,observePluginContainerSize:!0,defaultTabId:Su.ADJUST,defaultToolId:Q2.CROP,tabsIds:Object.values(Su).filter(e=>e!==Su.WATERMARK).sort((e,r)=>e.localeCompare(r)),onClose:this.onClose,onSave:this.onSave,translations:Au,theme:{palette:{"bg-secondary":"var(--color-main-background)","bg-primary":"var(--color-background-dark)","bg-hover":"var(--color-background-hover)","bg-stateless":"var(--color-background-dark)","accent-primary":"var(--color-primary-element)","accent-stateless":"var(--color-primary-element)","border-active-bottom":"var(--color-primary-element)","bg-primary-active":"var(--color-background-dark)","bg-primary-hover":"var(--color-background-hover)","accent-primary-active":"var(--color-main-text)","accent-primary-hover":"var(--color-primary-element)",warning:"var(--color-error)"},typography:{fontFamily:"var(--font-face)"}}}},defaultSavedImageName(){return Lr.basename(this.src,Lr.extname(this.src))},defaultSavedImageType(){return Lr.extname(this.src).slice(1)||"jpeg"},hasHighContrastEnabled(){var r;return(((r=OCA==null?void 0:OCA.Theming)==null?void 0:r.enabledThemes)||[]).find(a=>a.indexOf("highcontrast")!==-1)},themeDataAttr(){return this.hasHighContrastEnabled?{"data-theme-dark-highcontrast":!0}:{"data-theme-dark":!0}}},async mounted(){const e=(await Ls(async()=>{const{default:r}=await import("./index-CT4OtIn4.mjs");return{default:r}},[],import.meta.url)).default;Su=e.TABS,Q2=e.TOOLS,this.imageEditor=new e(this.$refs.editor,this.config),this.imageEditor.render(),window.addEventListener("keydown",this.handleKeydown,!0),window.addEventListener("DOMNodeInserted",this.handleSfxModal)},beforeDestroy(){this.imageEditor&&this.imageEditor.terminate(),window.removeEventListener("keydown",this.handleKeydown,!0)},methods:{onClose(e,r){if(r){this.onExitWithoutSaving();return}window.removeEventListener("keydown",this.handleKeydown,!0),this.$emit("close")},async onSave({fullName:e,imageCanvas:r,mimeType:a,quality:n}){var l,u;const{origin:i,pathname:s}=new URL(this.src),o=i+Lr.join(Lr.dirname(s),e);_t.debug("Saving image...",{putUrl:o,src:this.src,fullName:e}),a=a.replace("jpg","jpeg"),n=Math.max(Math.min(n,1),0)||1;try{const d=await new Promise(f=>r.toBlob(f,a,n)),c=await It.put(o,new File([d],e));if(_t.info("Edited image saved!",{response:c}),KM(t("viewer","Image saved")),o!==this.src)Do("files:node:created",{fileid:parseInt((u=(l=c==null?void 0:c.headers)==null?void 0:l["oc-fileid"])==null?void 0:u.split("oc")[0])||null});else{this.$emit("updated");const f=await Zj(i,decodeURI(s)),h=new _j({id:Number.parseInt(this.fileid),source:this.src,mtime:new Date(f.lastmod),...f,attributes:{...f,...f.props}});Do("files:node:updated",h)}}catch(d){_t.error("Error saving image",{error:d}),Uu(t("viewer","Error saving image"))}},onExitWithoutSaving(){OC.dialogs.confirmDestructive(Au.changesLoseConfirmation+"\n\n"+Au.changesLoseConfirmationHint,t("viewer","Unsaved changes"),{type:OC.dialogs.YES_NO_BUTTONS,confirm:t("viewer","Drop changes"),confirmClasses:"error",cancel:Au.cancel},e=>{e&&this.onClose("warning-ignored",!1)})},handleKeydown(e){e.key!=="Enter"&&e.stopImmediatePropagation(),e.key==="Escape"&&(e.preventDefault(),document.querySelector(".FIE_topbar-close-button").click()),e.ctrlKey&&e.key==="s"&&(e.preventDefault(),document.querySelector(".FIE_topbar-save-button").click()),e.ctrlKey&&e.key==="z"&&(e.preventDefault(),document.querySelector(".FIE_topbar-undo-button").click())},handleSfxModal(e){var r;(r=e.target)!=null&&r.classList&&e.target.classList.contains("SfxModal-Wrapper")&&Do("viewer:trapElements:changed",e.target)}}};var dae=function(){var r=this,a=r._self._c;return a("div",r._b({ref:"editor",staticClass:"viewer__image-editor"},"div",r.themeDataAttr,!1))},fae=[],hae=qr(cae,dae,fae,!1,null,"a2c8f486",null,null);const gae=hae.exports;/*! third party licenses: js/vendor.LICENSE.txt *//**
*/const um=e=>{let r={};if(e.nodeType===1){if(e.attributes.length>0){r["@attributes"]={};for(let a=0;a<e.attributes.length;a++){const n=e.attributes.item(a);r["@attributes"][n.nodeName]=n.nodeValue}}}else e.nodeType===3&&(r=e.nodeValue);if(e.hasChildNodes())for(let a=0;a<e.childNodes.length;a++){const n=e.childNodes.item(a),i=n.nodeName;if(typeof r[i]>"u")r[i]=um(n);else{if(typeof r[i].push>"u"){const s=r[i];r[i]=[],r[i].push(s)}r[i].push(um(n))}}return r},lae=e=>{let r=null;try{r=new DOMParser().parseFromString(e,"text/xml")}catch(a){console.error("Failed to parse xml document",a)}return r},W2=e=>{const r=um(lae(e))["d:multistatus"]["d:response"],a=[];for(const n in r){const i=r[n]["d:propstat"];i["d:status"]["#text"]==="HTTP/1.1 200 OK"&&a.push({id:parseInt(i["d:prop"]["oc:id"]["#text"]),displayName:i["d:prop"]["oc:display-name"]["#text"],canAssign:i["d:prop"]["oc:can-assign"]["#text"]==="true",userAssignable:i["d:prop"]["oc:user-assignable"]["#text"]==="true",userVisible:i["d:prop"]["oc:user-visible"]["#text"]==="true"})}return a},uae=async function(){if(window.NextcloudVueDocs)return Promise.resolve(W2(window.NextcloudVueDocs.tags));const e=await It({method:"PROPFIND",url:vc("dav")+"/systemtags/",data:'<?xml version="1.0"?>\n <d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">\n <d:prop>\n <oc:id />\n <oc:display-name />\n <oc:user-visible />\n <oc:user-assignable />\n <oc:can-assign />\n </d:prop>\n </d:propfind>'});return W2(e.data)};Qe(fU);({...Si.props,placeholder:ce("Select a tag")});Qe(_3);Qe(xU);Qe(WU);Bd(function(e){this.loadGroup(e)},200);const Au={name:pe("viewer","Name"),save:pe("viewer","Save"),saveAs:pe("viewer","Save as"),back:pe("viewer","Back"),loading:pe("viewer","Loading …"),resetOperations:pe("viewer","Reset"),changesLoseConfirmation:pe("viewer","All changes will be lost."),changesLoseConfirmationHint:pe("viewer","Are you sure you want to continue?"),cancel:pe("viewer","Cancel"),continue:pe("viewer","Continue"),undoTitle:pe("viewer","Undo"),redoTitle:pe("viewer","Redo"),showImageTitle:pe("viewer","Show original image"),zoomInTitle:pe("viewer","Zoom in"),zoomOutTitle:pe("viewer","Zoom out"),toggleZoomMenuTitle:pe("viewer","Toggle zoom menu"),adjustTab:pe("viewer","Adjust"),finetuneTab:pe("viewer","Fine-tune"),filtersTab:pe("viewer","Filters"),watermarkTab:pe("viewer","Watermark"),annotateTab:pe("viewer","Draw"),resize:pe("viewer","Resize"),resizeTab:pe("viewer","Resize"),invalidImageError:pe("viewer","Invalid image."),uploadImageError:pe("viewer","Error while uploading the image."),areNotImages:pe("viewer","are not images"),isNotImage:pe("viewer","is not an image"),toBeUploaded:pe("viewer","to be uploaded"),cropTool:pe("viewer","Crop"),original:pe("viewer","Original"),custom:pe("viewer","Custom"),square:pe("viewer","Square"),landscape:pe("viewer","Landscape"),portrait:pe("viewer","Portrait"),ellipse:pe("viewer","Ellipse"),classicTv:pe("viewer","Classic TV"),cinemascope:pe("viewer","CinemaScope"),arrowTool:pe("viewer","Arrow"),blurTool:pe("viewer","Blur"),brightnessTool:pe("viewer","Brightness"),contrastTool:pe("viewer","Contrast"),ellipseTool:pe("viewer","Ellipse"),unFlipX:pe("viewer","Un-flip X"),flipX:pe("viewer","Flip X"),unFlipY:pe("viewer","Un-flip Y"),flipY:pe("viewer","Flip Y"),hsvTool:pe("viewer","HSV"),hue:pe("viewer","Hue"),saturation:pe("viewer","Saturation"),value:pe("viewer","Value"),imageTool:pe("viewer","Image"),importing:pe("viewer","Importing …"),addImage:pe("viewer","+ Add image"),lineTool:pe("viewer","Line"),penTool:pe("viewer","Pen"),polygonTool:pe("viewer","Polygon"),sides:pe("viewer","Sides"),rectangleTool:pe("viewer","Rectangle"),cornerRadius:pe("viewer","Corner Radius"),resizeWidthTitle:pe("viewer","Width in pixels"),resizeHeightTitle:pe("viewer","Height in pixels"),toggleRatioLockTitle:pe("viewer","Toggle ratio lock"),reset:pe("viewer","Reset"),resetSize:pe("viewer","Reset to original image size"),rotateTool:pe("viewer","Rotate"),textTool:pe("viewer","Text"),textSpacings:pe("viewer","Text spacing"),textAlignment:pe("viewer","Text alignment"),fontFamily:pe("viewer","Font family"),size:pe("viewer","Size"),letterSpacing:pe("viewer","Letter spacing"),lineHeight:pe("viewer","Line height"),warmthTool:pe("viewer","Warmth"),addWatermark:pe("viewer","+ Add watermark"),addWatermarkTitle:pe("viewer","Choose watermark type"),uploadWatermark:pe("viewer","Upload watermark"),addWatermarkAsText:pe("viewer","Add as text"),padding:pe("viewer","Padding"),shadow:pe("viewer","Shadow"),horizontal:pe("viewer","Horizontal"),vertical:pe("viewer","Vertical"),blur:pe("viewer","Blur"),opacity:pe("viewer","Opacity"),position:pe("viewer","Position"),stroke:pe("viewer","Stroke"),saveAsModalLabel:pe("viewer","Save image as"),extension:pe("viewer","Extension"),nameIsRequired:pe("viewer","Name is required."),quality:pe("viewer","Quality"),imageDimensionsHoverTitle:pe("viewer","Saved image size (width x height)"),cropSizeLowerThanResizedWarning:pe("viewer","Note that the selected crop area is lower than the applied resize which might cause quality decrease"),actualSize:pe("viewer","Actual size (100%)"),fitSize:pe("viewer","Fit size")};let Su,Q2;const cae={name:"ImageEditor",props:{fileid:{type:[String,Number],required:!0},mime:{type:String,required:!0},src:{type:String,required:!0}},data(){return{imageEditor:null}},computed:{config(){return{source:this.src,defaultSavedImageName:this.defaultSavedImageName,defaultSavedImageType:this.defaultSavedImageType,useBackendTranslations:!1,observePluginContainerSize:!0,defaultTabId:Su.ADJUST,defaultToolId:Q2.CROP,tabsIds:Object.values(Su).filter(e=>e!==Su.WATERMARK).sort((e,r)=>e.localeCompare(r)),onClose:this.onClose,onSave:this.onSave,translations:Au,theme:{palette:{"bg-secondary":"var(--color-main-background)","bg-primary":"var(--color-background-dark)","bg-hover":"var(--color-background-hover)","bg-stateless":"var(--color-background-dark)","accent-primary":"var(--color-primary-element)","accent-stateless":"var(--color-primary-element)","border-active-bottom":"var(--color-primary-element)","bg-primary-active":"var(--color-background-dark)","bg-primary-hover":"var(--color-background-hover)","accent-primary-active":"var(--color-main-text)","accent-primary-hover":"var(--color-primary-element)",warning:"var(--color-error)"},typography:{fontFamily:"var(--font-face)"}}}},defaultSavedImageName(){return Lr.basename(this.src,Lr.extname(this.src))},defaultSavedImageType(){return Lr.extname(this.src).slice(1)||"jpeg"},hasHighContrastEnabled(){var r;return(((r=OCA==null?void 0:OCA.Theming)==null?void 0:r.enabledThemes)||[]).find(a=>a.indexOf("highcontrast")!==-1)},themeDataAttr(){return this.hasHighContrastEnabled?{"data-theme-dark-highcontrast":!0}:{"data-theme-dark":!0}}},async mounted(){const e=(await Ls(async()=>{const{default:r}=await import("./index-CT4OtIn4.mjs");return{default:r}},[],import.meta.url)).default;Su=e.TABS,Q2=e.TOOLS,this.imageEditor=new e(this.$refs.editor,this.config),this.imageEditor.render(),window.addEventListener("keydown",this.handleKeydown,!0),window.addEventListener("DOMNodeInserted",this.handleSfxModal)},beforeDestroy(){this.imageEditor&&this.imageEditor.terminate(),window.removeEventListener("keydown",this.handleKeydown,!0)},methods:{onClose(e,r){if(r){this.onExitWithoutSaving();return}window.removeEventListener("keydown",this.handleKeydown,!0),this.$emit("close")},async onSave({fullName:e,imageCanvas:r,mimeType:a,quality:n}){var l,u;const{origin:i,pathname:s}=new URL(this.src),o=i+Lr.join(Lr.dirname(s),e);_t.debug("Saving image...",{putUrl:o,src:this.src,fullName:e}),a=a.replace("jpg","jpeg"),n=Math.max(Math.min(n,1),0)||1;try{const d=await new Promise(f=>r.toBlob(f,a,n)),c=await It.put(o,new File([d],e));if(_t.info("Edited image saved!",{response:c}),KM(t("viewer","Image saved")),o!==this.src)Do("files:node:created",{fileid:parseInt((u=(l=c==null?void 0:c.headers)==null?void 0:l["oc-fileid"])==null?void 0:u.split("oc")[0])||null});else{this.$emit("updated");const f=await Zj(i,decodeURI(s)),h=new _j({id:Number.parseInt(this.fileid),source:this.src,mtime:new Date(f.lastmod),...f,attributes:{...f,...f.props}});Do("files:node:updated",h)}}catch(d){_t.error("Error saving image",{error:d}),Uu(t("viewer","Error saving image"))}},onExitWithoutSaving(){OC.dialogs.confirmDestructive(Au.changesLoseConfirmation+"\n\n"+Au.changesLoseConfirmationHint,t("viewer","Unsaved changes"),{type:OC.dialogs.YES_NO_BUTTONS,confirm:t("viewer","Drop changes"),confirmClasses:"error",cancel:Au.cancel},e=>{e&&this.onClose("warning-ignored",!1)})},handleKeydown(e){e.key!=="Enter"&&e.stopImmediatePropagation(),e.key==="Escape"&&(e.preventDefault(),document.querySelector(".FIE_topbar-close-button").click()),e.ctrlKey&&e.key==="s"&&(e.preventDefault(),document.querySelector(".FIE_topbar-save-button").click()),e.ctrlKey&&e.key==="z"&&(e.preventDefault(),document.querySelector(".FIE_topbar-undo-button").click())},handleSfxModal(e){var r;(r=e.target)!=null&&r.classList&&e.target.classList.contains("SfxModal-Wrapper")&&Do("viewer:trapElements:changed",e.target)}}};var dae=function(){var r=this,a=r._self._c;return a("div",r._b({ref:"editor",staticClass:"viewer__image-editor"},"div",r.themeDataAttr,!1))},fae=[],hae=qr(cae,dae,fae,!1,null,"d82f2433",null,null);const gae=hae.exports;/*! third party licenses: js/vendor.LICENSE.txt *//**
* @copyright Copyright (c) 2023 Louis Chmn <[email protected]>
*
* @author Louis Chmn <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion js/viewer-main.mjs.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/components/ImageEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,6 @@ export default {
.viewer__image-editor {
position: absolute;
z-index: 10100;
top: calc(var(--header-height) * -1);
bottom: calc(var(--header-height) * -1);
left: 0;
width: 100%;
height: 100vh;
Expand Down

0 comments on commit 9077f8b

Please sign in to comment.