|
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[6139],{56139:(e,t,o)=>{o.r(t),o.d(t,{default:()=>g});var n,a=o(44604),i=o(53312),r=o(43269),c=o(12030);!function(e){e.resetImage="imageviewer:reset-image",e.zoomIn="imageviewer:zoom-in",e.zoomOut="imageviewer:zoom-out",e.flipHorizontal="imageviewer:flip-horizontal",e.flipVertical="imageviewer:flip-vertical",e.rotateClockwise="imageviewer:rotate-clockwise",e.rotateCounterclockwise="imageviewer:rotate-counterclockwise",e.invertColors="imageviewer:invert-colors"}(n||(n={}));const l=["png","gif","jpeg","bmp","ico","tiff"],d="Image",s="Image (Text)",m=["svg","xbm"],u=new RegExp(`[.](${m.join("|")})$`),g={activate:function(e,t,o,a){const c=t.load("jupyterlab");function g(t,o){var n,a;o.context.pathChanged.connect((()=>{v.save(o)})),v.add(o);const i=e.docRegistry.getFileTypesForPath(o.context.path);i.length>0&&(o.title.icon=i[0].icon,o.title.iconClass=null!==(n=i[0].iconClass)&&void 0!==n?n:"",o.title.iconLabel=null!==(a=i[0].iconLabel)&&void 0!==a?a:"")}[new r.ImageViewerFactory({name:d,label:c.__("Image"),modelName:"base64",fileTypes:[...l,...m],defaultFor:l,readOnly:!0}),new r.ImageViewerFactory({name:s,label:c.__("Image (Text)"),modelName:"text",fileTypes:m,defaultFor:m,readOnly:!0})].forEach((t=>{e.docRegistry.addWidgetFactory(t),t.widgetCreated.connect(g)}));const v=new i.WidgetTracker({namespace:"image-widget"});if(a&&a.restore(v,{command:"docmanager:open",args:e=>({path:e.context.path,factory:u.test(e.context.path)?s:d}),name:e=>e.context.path}),function(e,t,o){var a;const i=o.load("jupyterlab"),{commands:r,shell:c}=e;function l(){return null!==t.currentWidget&&t.currentWidget===c.currentWidget}r.addCommand(n.zoomIn,{execute:function(){var e;const o=null===(e=t.currentWidget)||void 0===e?void 0:e.content;o&&(o.scale=o.scale>1?o.scale+.5:2*o.scale)},label:i.__("Zoom In"),isEnabled:l}),r.addCommand(n.zoomOut,{execute:function(){var e;const o=null===(e=t.currentWidget)||void 0===e?void 0:e.content;o&&(o.scale=o.scale>1?o.scale-.5:o.scale/2)},label:i.__("Zoom Out"),isEnabled:l}),r.addCommand(n.resetImage,{execute:function(){var e;const o=null===(e=t.currentWidget)||void 0===e?void 0:e.content;o&&(o.scale=1,o.colorinversion=0,o.resetRotationFlip())},label:i.__("Reset Image"),isEnabled:l}),r.addCommand(n.rotateClockwise,{execute:function(){var e;const o=null===(e=t.currentWidget)||void 0===e?void 0:e.content;o&&o.rotateClockwise()},label:i.__("Rotate Clockwise"),isEnabled:l}),r.addCommand(n.rotateCounterclockwise,{execute:function(){var e;const o=null===(e=t.currentWidget)||void 0===e?void 0:e.content;o&&o.rotateCounterclockwise()},label:i.__("Rotate Counterclockwise"),isEnabled:l}),r.addCommand(n.flipHorizontal,{execute:function(){var e;const o=null===(e=t.currentWidget)||void 0===e?void 0:e.content;o&&o.flipHorizontal()},label:i.__("Flip image horizontally"),isEnabled:l}),r.addCommand(n.flipVertical,{execute:function(){var e;const o=null===(e=t.currentWidget)||void 0===e?void 0:e.content;o&&o.flipVertical()},label:i.__("Flip image vertically"),isEnabled:l}),r.addCommand(n.invertColors,{execute:function(){var e;const o=null===(e=t.currentWidget)||void 0===e?void 0:e.content;o&&(o.colorinversion+=1,o.colorinversion%=2)},label:i.__("Invert Colors"),isEnabled:l});const d=()=>{Object.values(n).forEach((e=>r.notifyCommandChanged(e)))};t.currentChanged.connect(d),null===(a=c.currentChanged)||void 0===a||a.connect(d)}(e,v,t),o){const e=c.__("Image Viewer");[n.zoomIn,n.zoomOut,n.resetImage,n.rotateClockwise,n.rotateCounterclockwise,n.flipHorizontal,n.flipVertical,n.invertColors].forEach((t=>{o.addItem({command:t,category:e})}))}return v},description:"Adds image viewer and provide its tracker.",id:"@jupyterlab/imageviewer-extension:plugin",provides:r.IImageTracker,requires:[c.ITranslator],optional:[i.ICommandPalette,a.ILayoutRestorer],autoStart:!0}}}]); |