@equinor/ioc-common-frontend 20.0.5 → 20.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/{ImageComponent-swu51ub3.js → ImageComponent-B4gqFWF1.js} +1 -1
- package/build/{ImageComponent-CE3CS8Uc.cjs → ImageComponent-BSKGFWln.cjs} +1 -1
- package/build/{index-CdpAjXus.cjs → index-CkD1tPM8.cjs} +84 -84
- package/build/{index-Bhq1f3lQ.js → index-OL-cI6tv.js} +3 -3
- package/build/index.esm.js +1 -1
- package/build/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as te, o as z, _ as x, $ as re } from "./index-
|
|
1
|
+
import { s as te, o as z, _ as x, $ as re } from "./index-OL-cI6tv.js";
|
|
2
2
|
import { jsx as m, Fragment as ne } from "react/jsx-runtime";
|
|
3
3
|
import { $getSelection as E, $isNodeSelection as d, $createNodeSelection as ae, $setSelection as K, $getNodeByKey as k, createCommand as oe, $isRangeSelection as ie, mergeRegister as se, SELECTION_CHANGE_COMMAND as ue, COMMAND_PRIORITY_LOW as u, CLICK_COMMAND as le, DRAGSTART_COMMAND as ce, KEY_DELETE_COMMAND as de, KEY_BACKSPACE_COMMAND as he, KEY_ENTER_COMMAND as me, KEY_ESCAPE_COMMAND as ge } from "lexical";
|
|
4
4
|
import { useState as G, useEffect as P, useCallback as h, useRef as L, Suspense as fe } from "react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require('./ImageComponent.css');var s=require("./index-
|
|
1
|
+
"use strict";require('./ImageComponent.css');var s=require("./index-CkD1tPM8.cjs"),d=require("react/jsx-runtime"),e=require("lexical"),a=require("react");function Y(r,M){return r.getEditorState().read(()=>{const f=e.$getNodeByKey(M);return f!==null&&f.isSelected()})}s.styleInject("");var p=new Set,$=e.createCommand("RIGHT_CLICK_IMAGE_COMMAND");function B(r){var M=r.altText,f=r.className,v=r.imageRef,N=r.src,R=r.width,A=r.height,O=r.maxWidth,m=r.onError;return(function(c){if(!p.has(c))throw new Promise(function(S){var _=new Image;_.src=c,_.onload=function(){p.add(c),S(null)},_.onerror=function(){p.add(c)}})})(N),d.jsx("img",{className:f||void 0,src:N,alt:M,ref:v,style:{height:A,maxWidth:O,width:R},onError:m,draggable:"false"})}function U(){return d.jsx("img",{src:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M22%203H2v18h20v-2h-2v-2h2v-2h-2v-2h2v-2h-2V9h2V7h-2V5h2V3zm-2%204v2h-2v2h2v2h-2v2h2v2h-2v2H4V5h14v2h2zm-6%202h-2v2h-2v2H8v2H6v2h2v-2h2v-2h2v-2h2v2h2v-2h-2V9zM6%207h2v2H6V7z'%20fill='%23000000'/%3e%3c/svg%3e",style:{height:200,opacity:.2,width:200},draggable:"false"})}exports.RIGHT_CLICK_IMAGE_COMMAND=$,exports.default=function(r){var M=r.src,f=r.altText,v=r.nodeKey,N=r.width,R=r.height,A=r.maxWidth,O=r.showCaption,m=r.caption,c=a.useRef(null),S=a.useRef(null),_=(function(n){const[t]=s.o(),[g,h]=a.useState(()=>Y(t,n));return a.useEffect(()=>{let o=!0;const u=t.registerUpdateListener(()=>{o&&h(Y(t,n))});return()=>{o=!1,u()}},[t,n]),[g,a.useCallback(o=>{t.update(()=>{let u=e.$getSelection();e.$isNodeSelection(u)||(u=e.$createNodeSelection(),e.$setSelection(u)),e.$isNodeSelection(u)&&(o?u.add(n):u.delete(n))})},[t,n]),a.useCallback(()=>{t.update(()=>{const o=e.$getSelection();e.$isNodeSelection(o)&&o.clear()})},[t])]})(v),E=s._slicedToArray(_,3),l=E[0],C=E[1],I=E[2],P=s.o(),i=s._slicedToArray(P,1)[0],G=a.useState(null),w=s._slicedToArray(G,2),L=w[0],j=w[1],y=a.useRef(null),V=a.useState(!1),b=s._slicedToArray(V,2),k=b[0],H=b[1],x=a.useCallback(function(n){if(l&&e.$isNodeSelection(e.$getSelection())){n.preventDefault();var t=e.$getNodeByKey(v);if(s.$isImageNode(t))return t?.remove(),!0}return!1},[l,v]),K=a.useCallback(function(n){var t=e.$getSelection(),g=S.current;if(l&&e.$isNodeSelection(t)&&t.getNodes().length===1){if(O)return e.$setSelection(null),n.preventDefault(),m.focus(),!0;if(g!==null&&g!==document.activeElement)return n.preventDefault(),g.focus(),!0}return!1},[m,l,O]),W=a.useCallback(function(n){return(y.current===m||S.current===n.target)&&(e.$setSelection(null),i.update(function(){C(!0);var t=i.getRootElement();t!==null&&t.focus()}),!0)},[m,i,C]),D=a.useCallback(function(n){var t=n;return t.target===c.current&&(t.shiftKey?C(!l):(I(),C(!0)),!0)},[l,C,I]),T=a.useCallback(function(n){i.getEditorState().read(function(){var t=e.$getSelection();n.target.tagName==="IMG"&&e.$isRangeSelection(t)&&t.getNodes().length===1&&i.dispatchCommand($,n)})},[i]);a.useEffect(function(){var n=!0,t=i.getRootElement(),g=e.mergeRegister(i.registerUpdateListener(function(h){var o=h.editorState;n&&j(o.read(function(){return e.$getSelection()}))}),i.registerCommand(e.SELECTION_CHANGE_COMMAND,function(h,o){return y.current=o,!1},e.COMMAND_PRIORITY_LOW),i.registerCommand(e.CLICK_COMMAND,D,e.COMMAND_PRIORITY_LOW),i.registerCommand($,D,e.COMMAND_PRIORITY_LOW),i.registerCommand(e.DRAGSTART_COMMAND,function(h){return h.target===c.current&&(h.preventDefault(),!0)},e.COMMAND_PRIORITY_LOW),i.registerCommand(e.KEY_DELETE_COMMAND,x,e.COMMAND_PRIORITY_LOW),i.registerCommand(e.KEY_BACKSPACE_COMMAND,x,e.COMMAND_PRIORITY_LOW),i.registerCommand(e.KEY_ENTER_COMMAND,K,e.COMMAND_PRIORITY_LOW),i.registerCommand(e.KEY_ESCAPE_COMMAND,W,e.COMMAND_PRIORITY_LOW));return t?.addEventListener("contextmenu",T),function(){n=!1,g(),t?.removeEventListener("contextmenu",T)}},[I,i,l,v,x,K,W,D,T,C]);var q=l&&e.$isNodeSelection(L),z=l;return d.jsx(a.Suspense,{fallback:null,children:d.jsx(d.Fragment,{children:d.jsx("div",{draggable:q,children:k?d.jsx(U,{}):d.jsx(B,{className:z?"focused ".concat(e.$isNodeSelection(L)?"draggable":""):null,src:M,altText:f,imageRef:c,width:N,height:R,maxWidth:A,onError:function(){return H(!0)}})})})})};
|