@layers-app/editor 0.0.14 → 0.0.16

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@layers-app/editor",
3
3
  "private": false,
4
- "version": "0.0.14",
4
+ "version": "0.0.16",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "start": "vite --mode full",
@@ -25,7 +25,7 @@
25
25
  "main": "dist/index.js",
26
26
  "types": "dist/index.d.ts",
27
27
  "dependencies": {
28
- "@layers-app/shared": "^0.0.23",
28
+ "@layers-app/shared": "^0.0.24",
29
29
  "@lexical/headless": "0.21.0",
30
30
  "@lexical/markdown": "0.21.0",
31
31
  "@lexical/react": "0.21.0",
@@ -40,11 +40,11 @@
40
40
  },
41
41
  "devDependencies": {
42
42
  "@eslint/js": "^9.9.0",
43
- "@mantine/core": "^7.16.2",
44
- "@mantine/dropzone": "^7.16.2",
45
- "@mantine/form": "^7.16.2",
46
- "@mantine/hooks": "^7.16.2",
47
- "@mantine/modals": "^7.16.2",
43
+ "@mantine/core": "^7.17.2",
44
+ "@mantine/dropzone": "^7.17.2",
45
+ "@mantine/form": "^7.17.2",
46
+ "@mantine/hooks": "^7.17.2",
47
+ "@mantine/modals": "^7.17.2",
48
48
  "@rollup/plugin-typescript": "^11.1.6",
49
49
  "@tabler/icons-react": "^3.7.0",
50
50
  "@trivago/prettier-plugin-sort-imports": "^5.2.1",
@@ -84,15 +84,16 @@
84
84
  "vite-plugin-commonjs": "^0.10.1",
85
85
  "vite-plugin-css-injected-by-js": "^3.5.0",
86
86
  "vite-plugin-dts": "^4.0.0-beta.1",
87
+ "vite-plugin-static-copy": "^2.3.0",
87
88
  "vite-plugin-svgr": "^4.2.0",
88
89
  "zustand": "^4.5.4"
89
90
  },
90
91
  "peerDependencies": {
91
- "@mantine/core": ">=7.16.2",
92
- "@mantine/dropzone": ">=7.16.2",
93
- "@mantine/form": ">=7.16.2",
94
- "@mantine/hooks": ">=7.16.2",
95
- "@mantine/modals": ">=7.16.2",
92
+ "@mantine/core": ">=7.17.2",
93
+ "@mantine/dropzone": ">=7.17.2",
94
+ "@mantine/form": ">=7.17.2",
95
+ "@mantine/hooks": ">=7.17.2",
96
+ "@mantine/modals": ">=7.17.2",
96
97
  "@tabler/icons-react": ">=3.7.0",
97
98
  "i18next": "^23.11.5",
98
99
  "lodash-es": ">=4.17.21",
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),m=require("react"),e=require("./layers.Dyb1dHPy.js"),b=require("./layers.C0b1Opuc.js"),S=require("react-dom"),h=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,B=h&&"documentMode"in document?document.documentMode:null,_=!(!h||!("InputEvent"in window)||B)&&"getTargetRanges"in new window.InputEvent("input"),A=h&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),N=h&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,W=h&&/^(?=.*Chrome).*/i.test(navigator.userAgent),M=h&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!W;function j(r,n){n.update(()=>{if(r!==null){const t=e.ue(r,KeyboardEvent)?null:r.clipboardData,s=e.Ri();if(s!==null&&t!=null){r.preventDefault();const c=e.v(n);c!==null&&t.setData("text/html",c),t.setData("text/plain",s.getTextContent())}}})}function O(r){return e.N(r.registerCommand(e.i,n=>{const t=e.Ri();return!!e.ki(t)&&(t.deleteCharacter(n),!0)},e.Rs),r.registerCommand(e.u$2,n=>{const t=e.Ri();return!!e.ki(t)&&(t.deleteWord(n),!0)},e.Rs),r.registerCommand(e.f,n=>{const t=e.Ri();return!!e.ki(t)&&(t.deleteLine(n),!0)},e.Rs),r.registerCommand(e.l$1,n=>{const t=e.Ri();if(!e.ki(t))return!1;if(typeof n=="string")t.insertText(n);else{const s=n.dataTransfer;if(s!=null)e.D$1(s,t);else{const c=n.data;c&&t.insertText(c)}}return!0},e.Rs),r.registerCommand(e.a$1,()=>{const n=e.Ri();return!!e.ki(n)&&(n.removeText(),!0)},e.Rs),r.registerCommand(e.s,n=>{const t=e.Ri();return!!e.ki(t)&&(t.insertLineBreak(n),!0)},e.Rs),r.registerCommand(e.o,()=>{const n=e.Ri();return!!e.ki(n)&&(n.insertLineBreak(),!0)},e.Rs),r.registerCommand(e.m,n=>{const t=e.Ri();if(!e.ki(t))return!1;const s=n,c=s.shiftKey;return!!e.L$1(t,!0)&&(s.preventDefault(),e.$(t,c,!0),!0)},e.Rs),r.registerCommand(e.p,n=>{const t=e.Ri();if(!e.ki(t))return!1;const s=n,c=s.shiftKey;return!!e.L$1(t,!1)&&(s.preventDefault(),e.$(t,c,!1),!0)},e.Rs),r.registerCommand(e.k,n=>{const t=e.Ri();return!!e.ki(t)&&(!N||navigator.language!=="ko-KR")&&(n.preventDefault(),r.dispatchCommand(e.i,!0))},e.Rs),r.registerCommand(e.w,n=>{const t=e.Ri();return!!e.ki(t)&&(n.preventDefault(),r.dispatchCommand(e.i,!1))},e.Rs),r.registerCommand(e.C,n=>{const t=e.Ri();if(!e.ki(t))return!1;if(n!==null){if((N||A||M)&&_)return!1;n.preventDefault()}return r.dispatchCommand(e.s,!1)},e.Rs),r.registerCommand(e.z,()=>(e.Ht(),!0),e.Rs),r.registerCommand(e.A,n=>{const t=e.Ri();return!!e.ki(t)&&(j(n,r),!0)},e.Rs),r.registerCommand(e.B,n=>{const t=e.Ri();return!!e.ki(t)&&(function(s,c){j(s,c),c.update(()=>{const i=e.Ri();e.ki(i)&&i.removeText()})}(n,r),!0)},e.Rs),r.registerCommand(e.c,n=>{const t=e.Ri();return!!e.ki(t)&&(function(s,c){s.preventDefault(),c.update(()=>{const i=e.Ri(),{clipboardData:u}=s;u!=null&&e.ki(i)&&e.D$1(u,i)},{tag:"paste"})}(n,r),!0)},e.Rs),r.registerCommand(e.L,n=>{const t=e.Ri();return!!e.ki(t)&&(n.preventDefault(),!0)},e.Rs),r.registerCommand(e.D,n=>{const t=e.Ri();return!!e.ki(t)&&(n.preventDefault(),!0)},e.Rs))}const D=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?m.useLayoutEffect:m.useEffect;function P(r){return r.getEditorState().read(e.g(r.isComposing()))}function z({contentEditable:r,placeholder:n=null,ErrorBoundary:t}){const[s]=e.u(),c=function(i,u){const[f,k]=m.useState(()=>i.getDecorators());return D(()=>i.registerDecoratorListener(C=>{S.flushSync(()=>{k(C)})}),[i]),m.useEffect(()=>{k(i.getDecorators())},[i]),m.useMemo(()=>{const C=[],y=Object.keys(f);for(let E=0;E<y.length;E++){const v=y[E],x=d.jsx(u,{onError:a=>i._onError(a),children:d.jsx(m.Suspense,{fallback:null,children:f[v]})}),o=i.getElementByKey(v);o!==null&&C.push(S.createPortal(x,o,v))}return C},[u,f,i])}(s,t);return function(i){D(()=>e.N(O(i),e.o$1(i)),[i])}(s),d.jsxs(d.Fragment,{children:[r,d.jsx(K,{content:n}),c]})}function K({content:r}){const[n]=e.u(),t=function(c){const[i,u]=m.useState(()=>P(c));return D(()=>{function f(){const k=P(c);u(k)}return f(),e.N(c.registerUpdateListener(()=>{f()}),c.registerEditableListener(()=>{f()}))},[c]),i}(n),s=e.a$2();return t?typeof r=="function"?r(s):r:null}const X=new URL(window.location.href);new URLSearchParams(X.search);const q="https://wss.dudoc.io";function I(r,n){let t=n.get(r);return t===void 0?(t=new e.Doc,n.set(r,t)):t.load(),new e.WebsocketProvider(q,"/"+r,t,{connect:!1})}const U=e.CAN_USE_DOM?m.useLayoutEffect:m.useEffect,Y={...e.theme,paragraph:"StickyEditorTheme__paragraph"};function w(r,n){const t=r.style,s=n.rootElementRect,c=s!==null?s.left:0,i=s!==null?s.top:0;t.top=i+n.y+"px",t.left=c+n.x+"px"}function H({x:r,y:n,nodeKey:t,color:s,caption:c}){const[i]=e.u(),u=m.useRef(null),f=m.useRef({isDragging:!1,offsetX:0,offsetY:0,rootElementRect:null,x:0,y:0}),{isCollabActive:k}=e.l();m.useEffect(()=>{const o=f.current;o.x=r,o.y=n;const a=u.current;a!==null&&w(a,o)},[r,n]),U(()=>{const o=f.current,a=new ResizeObserver(R=>{for(let g=0;g<R.length;g++){const $=R[g],{target:T}=$;o.rootElementRect=T.getBoundingClientRect();const L=u.current;L!==null&&w(L,o)}}),l=i.registerRootListener((R,g)=>{g!==null&&a.unobserve(g),R!==null&&a.observe(R)}),p=()=>{const R=i.getRootElement(),g=u.current;R!==null&&g!==null&&(o.rootElementRect=R.getBoundingClientRect(),w(g,o))};return window.addEventListener("resize",p),()=>{window.removeEventListener("resize",p),l()}},[i]),m.useEffect(()=>{const o=u.current;o!==null&&setTimeout(()=>{o.style.setProperty("transition","top 0.3s ease 0s, left 0.3s ease 0s")},500)},[]);const C=o=>{const a=u.current,l=f.current,p=l.rootElementRect;a!==null&&l.isDragging&&p!==null&&(l.x=o.pageX-l.offsetX-p.left,l.y=o.pageY-l.offsetY-p.top,w(a,l))},y=()=>{const o=u.current,a=f.current;o!==null&&(a.isDragging=!1,o.classList.remove("dragging"),i.update(()=>{const l=e.Ct(t);e.$isStickyNode(l)&&l.setPosition(a.x,a.y)})),document.removeEventListener("pointermove",C),document.removeEventListener("pointerup",y)},E=()=>{i.update(()=>{const o=e.Ct(t);e.$isStickyNode(o)&&o.remove()})},v=()=>{i.update(()=>{const o=e.Ct(t);e.$isStickyNode(o)&&o.toggleColor()})},{historyState:x}=e.useSharedHistoryContext();return d.jsx("div",{ref:u,className:"sticky-note-container",children:d.jsxs("div",{className:`sticky-note ${s}`,onPointerDown:o=>{const a=u.current;if(a==null||o.button===2||o.target!==a.firstChild)return;const l=a,p=f.current;if(l!==null){const{top:R,left:g}=l.getBoundingClientRect();p.offsetX=o.clientX-g,p.offsetY=o.clientY-R,p.isDragging=!0,l.classList.add("dragging"),document.addEventListener("pointermove",C),document.addEventListener("pointerup",y),o.preventDefault()}},children:[d.jsx("button",{onClick:E,className:"delete","aria-label":"Delete sticky note",title:"Delete",children:"X"}),d.jsx("button",{onClick:v,className:"color","aria-label":"Change sticky note color",title:"Color",children:d.jsx("i",{className:"bucket"})}),d.jsxs(b.d,{initialEditor:c,initialTheme:Y,children:[k?d.jsx(e._,{id:c.getKey(),providerFactory:I,shouldBootstrap:!0}):d.jsx(e.a$3,{externalHistoryState:x}),d.jsx(z,{contentEditable:d.jsx(e.LexicalContentEditable,{className:"StickyNode__contentEditable"}),placeholder:d.jsx(b.Placeholder,{className:"StickyNode__placeholder",children:"What's up?"}),ErrorBoundary:e.a})]})]})})}exports.default=H;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),s=require("react"),D=require("react-i18next"),t=require("./layers.Dyb1dHPy.js"),E=require("@mantine/core"),U=require("@tabler/icons-react"),F=i=>{const{width:g,height:r,isLoading:l,isError:u,src:f,id:m,altText:p,imageRef:j,maxWidth:v}=i;return n.jsxs("div",{className:"media-wrapper",style:{width:g,height:r,display:"inline-flex",position:"relative"},children:[n.jsx(E.LoadingOverlay,{visible:l,zIndex:1e3,overlayProps:{backgroundOpacity:.5},loaderProps:{size:24,color:"black"}}),n.jsx(E.LoadingOverlay,{visible:u,zIndex:1e3,overlayProps:{backgroundOpacity:.5},loaderProps:{children:n.jsx(E.Flex,{bg:"white",maw:300,justify:"center",children:n.jsx(E.Alert,{variant:"light",color:"red",title:"Ошибка загрузки",icon:n.jsx(U.IconInfoCircle,{}),children:"Попробуйте загрузить заново."})})}}),n.jsx(B,{className:null,src:f,altText:p,imageRef:j,width:"inherit",height:"inherit",maxWidth:v||"auto",id:m})]})};function B({altText:i,className:g,imageRef:r,src:l,width:u,height:f,maxWidth:m,id:p}){return n.jsx("img",{className:g||void 0,src:l,alt:i,ref:r,style:{height:f,maxWidth:m,width:u},draggable:"false","data-id":p})}function G({src:i,altText:g,nodeKey:r,width:l,height:u,maxWidth:f,showCaption:m,caption:p,id:j,create:v,alignment:H}){const W=s.useRef(null),[P,S]=s.useState(!0),[R,M]=s.useState(!1),{isCollabActive:O}=t.l(),[h]=t.u(),[x,b]=s.useState(!0),[d,w]=s.useState({width:0,height:0}),{fetchUploadImage:z,fetchDeleteImage:L}=s.useContext(t.Context),{t:y}=D.useTranslation();s.useEffect(()=>{if(!i||i.startsWith("data:image/")){S(!1);return}const e=new Image;e.src=i,e.onload=()=>S(!1),e.onerror=()=>{S(!1),M(!0)}},[i]);const T=(e,a)=>{h.update(()=>{t.Ft(null);const c=t.Ct(r);t.$isImageNode(c)&&c.setWidthAndHeight(e,a)})},{historyState:k}=t.useSharedHistoryContext(),{settings:{showNestedEditorTreeView:q}}=t.useSettings(),[C,I]=s.useState(!1);function $(e){return e.endsWith(".svg")||e.includes("image/svg+xml")}function _(e){return new Promise((a,c)=>{if($(e)){a(0);return}const o=new Image;o.src=e,o.onload=()=>{a(o.width)},o.onerror=()=>{c(new Error("Failed to load image"))}})}return s.useEffect(()=>{v&&I(!0)},[v]),s.useEffect(()=>{let e=l,a=u,c=100;i&&_(i).then(o=>{typeof e=="number"&&e<c&&o<c?(b(!0),w({width:e,height:a})):o<c?(b(!0),w({width:"auto",height:"auto"})):(w({width:o,height:o}),b(!1))})},[i]),s.useEffect(()=>{d.width&&d.height&&x&&h.update(()=>{const e=t.Ct(r);t.$isImageNode(e)&&e.setWidthAndHeight(d.width,d.height)})},[d.width,d.height,x]),s.useEffect(()=>{const e=document.documentElement;t.toggleLockScroll(C,e)},[C]),i?x?n.jsx(F,{width:d.width,height:d.height,isLoading:P,isError:R,isIcon:x,src:i,id:j,editor:h,nodeKey:r,fetchDeleteImage:L,altText:g,imageRef:W,maxWidth:f,showCaption:m,caption:p,isCollabActive:O,historyState:k,showNestedEditorTreeView:q,t:y}):n.jsx(t.ResizableContainer,{editor:h,isIcon:x,width:typeof l=="string"&&l.includes("%")?parseFloat(l):l,height:typeof u=="string"&&u.includes("%")?parseFloat(u):l,initialWidth:d.width||"",initialHeight:d.height||"",onResizeEnd:T,alignment:H,children:n.jsx(F,{width:"inherit",height:"inherit",isLoading:P,isError:R,isIcon:x,src:i,id:j,editor:h,nodeKey:r,fetchDeleteImage:L,altText:g,imageRef:W,maxWidth:f,showCaption:m,caption:p,isCollabActive:O,historyState:k,showNestedEditorTreeView:q,t:y})}):n.jsx(t.ImagePicker,{uploading:!1,onUpload:e=>{!z||!e.length||(e.forEach((a,c)=>{z(a,(o,A)=>{c===0?h.update(()=>{const N=t.Ct(r);t.$isImageNode(N)&&(N.setSrc(o),N.setId(A))}):h.dispatchCommand(t.INSERT_IMAGE_COMMAND,{altText:"",src:o,id:A})})}),I(!1))},popoverProps:{opened:C,position:"bottom",onChange:I},onChange:e=>{I(!1),h.update(()=>{const a=t.Ct(r);t.$isImageNode(a)&&a.setSrc(e)})},children:n.jsx(t.EmptyNodeButton,{title:y("editor.image.add_photo"),icon:"photo",onClick:()=>I(!C)})})}exports.default=G;
@@ -1 +0,0 @@
1
- "use strict";const c=require("./layers.Dyb1dHPy.js"),i=require("react"),_=require("react/jsx-runtime");function E(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var k=E(function(e){const t=new URLSearchParams;t.append("code",e);for(let o=1;o<arguments.length;o++)t.append("v",arguments[o]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function m(e){const t=e.transform();return t!==null?new Set([t]):new Set}function O({initialEditor:e,children:t,initialNodes:o,initialTheme:g,skipCollabChecks:x}){const p=i.useRef(!1),u=i.useContext(c.l$2);u==null&&k(9);const[l,{getTheme:v}]=u,w=i.useMemo(()=>{const s=g||v()||void 0,y=c.o$2(u,s);if(s!==void 0&&(e._config.theme=s),e._parentEditor=l,o)for(let n of o){let a=null,r=null;if(typeof n!="function"){const f=n;n=f.replace,a=f.with,r=f.withKlass||null}const h=e._nodes.get(n.getType());e._nodes.set(n.getType(),{exportDOM:h?h.exportDOM:void 0,klass:n,replace:a,replaceWithKlass:r,transforms:m(n)})}else{const n=e._nodes=new Map(l._nodes);for(const[a,r]of n)e._nodes.set(a,{exportDOM:r.exportDOM,klass:r.klass,replace:r.replace,replaceWithKlass:r.replaceWithKlass,transforms:m(r.klass)})}return e._config.namespace=l._config.namespace,e._editable=l._editable,[e,y]},[]),{isCollabActive:M,yjsDocMap:b}=c.l(),d=x||p.current||b.has(e.getKey());return i.useEffect(()=>{d&&(p.current=!0)},[d]),i.useEffect(()=>l.registerEditableListener(s=>{e.setEditable(s)}),[e,l]),_.jsx(c.l$2.Provider,{value:w,children:!M||d?t:null})}function P({children:e,className:t}){return _.jsx("div",{className:t||"Placeholder__root",children:e})}exports.Placeholder=P;exports.d=O;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),i=require("react"),e=require("./layers.Dyb1dHPy.js"),R=require("./layers.C0b1Opuc.js"),y=require("@mantine/core");function D({children:a,label:r,className:n,...m}){return t.jsxs("div",{className:"Input__wrapper",children:[t.jsx("label",{style:{marginTop:"-1em"},className:"Input__label",children:r}),t.jsx("select",{...m,className:n||"select",children:a})]})}function q({label:a,value:r,onChange:n,placeholder:m="","data-test-id":o,type:d="text"}){return t.jsx(y.TextInput,{type:d,placeholder:m,value:r,onChange:c=>{n(c.target.value)},label:a,"data-test-id":o,mb:10})}const k=new Set;function L(a){if(!k.has(a))throw new Promise(r=>{const n=new Image;n.src=a,n.onload=()=>{k.add(a),r(null)}})}function B({altText:a,className:r,imageRef:n,src:m,width:o,height:d,position:c}){return L(m),t.jsx("img",{className:r||void 0,src:m,alt:a,ref:n,"data-position":c,style:{display:"block",height:d,width:o},draggable:"false"})}function _({activeEditor:a,nodeKey:r,onClose:n}){const o=a.getEditorState().read(()=>e.Ct(r)),[d,c]=i.useState(o.getAltText()),[C,S]=i.useState(o.getShowCaption()),[b,x]=i.useState(o.getPosition()),j=f=>{S(f.target.checked)},g=f=>{x(f.target.value)},p=()=>{const f={altText:d,position:b,showCaption:C};o&&a.update(()=>{o.update(f)}),n()};return t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{marginBottom:"1em"},children:t.jsx(q,{label:"Alt-текст",placeholder:"Альтернативный текст",onChange:c,value:d,"data-test-id":"image-modal-alt-text-input"})}),t.jsxs(D,{style:{marginBottom:"1em",width:"208px"},value:b,label:"Position",name:"position",id:"position-select",onChange:g,children:[t.jsx("option",{value:"left",children:"Left"}),t.jsx("option",{value:"right",children:"Right"}),t.jsx("option",{value:"full",children:"Full Width"})]}),t.jsxs("div",{className:"Input__wrapper",children:[t.jsx("input",{id:"caption",type:"checkbox",checked:C,onChange:j}),t.jsx("label",{htmlFor:"caption",children:"Show Caption"})]}),t.jsx(e.Button,{"data-test-id":"image-modal-file-upload-btn",onClick:()=>p(),children:"Применить"})]})}function K({src:a,altText:r,nodeKey:n,width:m,height:o,showCaption:d,caption:c,position:C}){const[S,b]=e.useModal(),x=i.useRef(null),j=i.useRef(null),[g,p,f]=e.u$1(n),[l]=e.u(),[P,F]=i.useState(null),E=i.useRef(null),v=i.useCallback(u=>{if(g&&e.wi(e.Ri())){u.preventDefault();const s=e.Ct(n);e.$isInlineImageNode(s)&&s.remove()}return!1},[g,n]),w=i.useCallback(u=>{const h=e.Ri(),s=j.current;if(g&&e.wi(h)&&h.getNodes().length===1){if(d)return e.Ft(null),u.preventDefault(),c.focus(),!0;if(s!==null&&s!==document.activeElement)return u.preventDefault(),s.focus(),!0}return!1},[c,g,d]),N=i.useCallback(u=>E.current===c||j.current===u.target?(e.Ft(null),l.update(()=>{p(!0);const h=l.getRootElement();h!==null&&h.focus()}),!0):!1,[c,l,p]);i.useEffect(()=>{let u=!0;const h=e.N(l.registerUpdateListener(({editorState:s})=>{u&&F(s.read(()=>e.Ri()))}),l.registerCommand(e.t,(s,I)=>(E.current=I,!1),e.Ks),l.registerCommand(e.r,s=>{const I=s;return I.target===x.current?(I.shiftKey?p(!g):(f(),p(!0)),!0):!1},e.Ks),l.registerCommand(e.D,s=>s.target===x.current?(s.preventDefault(),!0):!1,e.Ks),l.registerCommand(e.w,v,e.Ks),l.registerCommand(e.k,v,e.Ks),l.registerCommand(e.C,w,e.Ks),l.registerCommand(e.b,N,e.Ks));return()=>{u=!1,h()}},[f,l,g,n,v,w,N,p]);const T=g;return t.jsxs(i.Suspense,{fallback:null,children:[t.jsxs(t.Fragment,{children:[t.jsxs("div",{draggable:!1,children:[t.jsx("button",{className:"image-edit-button",ref:j,onClick:()=>{b("Update Inline Image",u=>t.jsx(_,{activeEditor:l,nodeKey:n,onClose:u}))},children:"Edit"}),t.jsx(B,{className:T?`focused ${e.wi(P)?"draggable":""}`:null,src:a,altText:r,imageRef:x,width:m,height:o,position:C})]}),d&&t.jsx("div",{className:"image-caption-container",children:t.jsxs(R.d,{initialEditor:c,children:[t.jsx(e.LinkPlugin,{}),t.jsx(e.FloatingTextFormatToolbarPlugin,{}),t.jsx(e.h,{contentEditable:t.jsx(e.LexicalContentEditable,{className:"InlineImageNode__contentEditable"}),placeholder:t.jsx(R.Placeholder,{className:"InlineImageNode__placeholder",children:"Enter a caption..."}),ErrorBoundary:e.a})]})})]}),S]})}exports.UpdateInlineImageDialog=_;exports.default=K;
@@ -1,288 +0,0 @@
1
- import { jsxs as f, jsx as e, Fragment as L } from "react/jsx-runtime";
2
- import { useRef as w, useState as E, useCallback as _, useEffect as A, Suspense as M } from "react";
3
- import { e as U, f as q, u as z, w as k, g as F, c as B, h as O, F as D, N as W, i as G, K as h, j as H, k as J, m as Q, D as V, r as X, n as Y, L as Z, o as K, p as ee, q as te, s as ne, B as ae } from "./layers.B3PKFuLO.js";
4
- import { d as le, P as oe } from "./layers.CovbS90x.js";
5
- import { TextInput as re } from "@mantine/core";
6
- function ie({
7
- children: n,
8
- label: o,
9
- className: t,
10
- ...u
11
- }) {
12
- return /* @__PURE__ */ f("div", { className: "Input__wrapper", children: [
13
- /* @__PURE__ */ e("label", { style: { marginTop: "-1em" }, className: "Input__label", children: o }),
14
- /* @__PURE__ */ e("select", { ...u, className: t || "select", children: n })
15
- ] });
16
- }
17
- function se({
18
- label: n,
19
- value: o,
20
- onChange: t,
21
- placeholder: u = "",
22
- "data-test-id": r,
23
- type: c = "text"
24
- }) {
25
- return /* @__PURE__ */ e(
26
- re,
27
- {
28
- type: c,
29
- placeholder: u,
30
- value: o,
31
- onChange: (i) => {
32
- t(i.target.value);
33
- },
34
- label: n,
35
- "data-test-id": r,
36
- mb: 10
37
- }
38
- );
39
- }
40
- const y = /* @__PURE__ */ new Set();
41
- function ce(n) {
42
- if (!y.has(n))
43
- throw new Promise((o) => {
44
- const t = new Image();
45
- t.src = n, t.onload = () => {
46
- y.add(n), o(null);
47
- };
48
- });
49
- }
50
- function ue({
51
- altText: n,
52
- className: o,
53
- imageRef: t,
54
- src: u,
55
- width: r,
56
- height: c,
57
- position: i
58
- }) {
59
- return ce(u), /* @__PURE__ */ e(
60
- "img",
61
- {
62
- className: o || void 0,
63
- src: u,
64
- alt: n,
65
- ref: t,
66
- "data-position": i,
67
- style: {
68
- display: "block",
69
- height: c,
70
- width: r
71
- },
72
- draggable: "false"
73
- }
74
- );
75
- }
76
- function de({
77
- activeEditor: n,
78
- nodeKey: o,
79
- onClose: t
80
- }) {
81
- const r = n.getEditorState().read(
82
- () => B(o)
83
- ), [c, i] = E(r.getAltText()), [I, x] = E(r.getShowCaption()), [v, C] = E(r.getPosition()), b = (m) => {
84
- x(m.target.checked);
85
- }, d = (m) => {
86
- C(m.target.value);
87
- }, p = () => {
88
- const m = { altText: c, position: v, showCaption: I };
89
- r && n.update(() => {
90
- r.update(m);
91
- }), t();
92
- };
93
- return /* @__PURE__ */ f(L, { children: [
94
- /* @__PURE__ */ e("div", { style: { marginBottom: "1em" }, children: /* @__PURE__ */ e(
95
- se,
96
- {
97
- label: "Alt-текст",
98
- placeholder: "Альтернативный текст",
99
- onChange: i,
100
- value: c,
101
- "data-test-id": "image-modal-alt-text-input"
102
- }
103
- ) }),
104
- /* @__PURE__ */ f(
105
- ie,
106
- {
107
- style: { marginBottom: "1em", width: "208px" },
108
- value: v,
109
- label: "Position",
110
- name: "position",
111
- id: "position-select",
112
- onChange: d,
113
- children: [
114
- /* @__PURE__ */ e("option", { value: "left", children: "Left" }),
115
- /* @__PURE__ */ e("option", { value: "right", children: "Right" }),
116
- /* @__PURE__ */ e("option", { value: "full", children: "Full Width" })
117
- ]
118
- }
119
- ),
120
- /* @__PURE__ */ f("div", { className: "Input__wrapper", children: [
121
- /* @__PURE__ */ e(
122
- "input",
123
- {
124
- id: "caption",
125
- type: "checkbox",
126
- checked: I,
127
- onChange: b
128
- }
129
- ),
130
- /* @__PURE__ */ e("label", { htmlFor: "caption", children: "Show Caption" })
131
- ] }),
132
- /* @__PURE__ */ e(
133
- ae,
134
- {
135
- "data-test-id": "image-modal-file-upload-btn",
136
- onClick: () => p(),
137
- children: "Применить"
138
- }
139
- )
140
- ] });
141
- }
142
- function be({
143
- src: n,
144
- altText: o,
145
- nodeKey: t,
146
- width: u,
147
- height: r,
148
- showCaption: c,
149
- caption: i,
150
- position: I
151
- }) {
152
- const [x, v] = U(), C = w(null), b = w(null), [d, p, m] = q(t), [l] = z(), [$, j] = E(null), P = w(null), N = _(
153
- (s) => {
154
- if (d && k(F())) {
155
- s.preventDefault();
156
- const a = B(t);
157
- O(a) && a.remove();
158
- }
159
- return !1;
160
- },
161
- [d, t]
162
- ), T = _(
163
- (s) => {
164
- const g = F(), a = b.current;
165
- if (d && k(g) && g.getNodes().length === 1) {
166
- if (c)
167
- return D(null), s.preventDefault(), i.focus(), !0;
168
- if (a !== null && a !== document.activeElement)
169
- return s.preventDefault(), a.focus(), !0;
170
- }
171
- return !1;
172
- },
173
- [i, d, c]
174
- ), R = _(
175
- (s) => P.current === i || b.current === s.target ? (D(null), l.update(() => {
176
- p(!0);
177
- const g = l.getRootElement();
178
- g !== null && g.focus();
179
- }), !0) : !1,
180
- [i, l, p]
181
- );
182
- return A(() => {
183
- let s = !0;
184
- const g = W(
185
- l.registerUpdateListener(({ editorState: a }) => {
186
- s && j(a.read(() => F()));
187
- }),
188
- l.registerCommand(
189
- Y,
190
- (a, S) => (P.current = S, !1),
191
- h
192
- ),
193
- l.registerCommand(
194
- X,
195
- (a) => {
196
- const S = a;
197
- return S.target === C.current ? (S.shiftKey ? p(!d) : (m(), p(!0)), !0) : !1;
198
- },
199
- h
200
- ),
201
- l.registerCommand(
202
- V,
203
- (a) => a.target === C.current ? (a.preventDefault(), !0) : !1,
204
- h
205
- ),
206
- l.registerCommand(
207
- Q,
208
- N,
209
- h
210
- ),
211
- l.registerCommand(
212
- J,
213
- N,
214
- h
215
- ),
216
- l.registerCommand(H, T, h),
217
- l.registerCommand(
218
- G,
219
- R,
220
- h
221
- )
222
- );
223
- return () => {
224
- s = !1, g();
225
- };
226
- }, [
227
- m,
228
- l,
229
- d,
230
- t,
231
- N,
232
- T,
233
- R,
234
- p
235
- ]), /* @__PURE__ */ f(M, { fallback: null, children: [
236
- /* @__PURE__ */ f(L, { children: [
237
- /* @__PURE__ */ f("div", { draggable: !1, children: [
238
- /* @__PURE__ */ e(
239
- "button",
240
- {
241
- className: "image-edit-button",
242
- ref: b,
243
- onClick: () => {
244
- v("Update Inline Image", (s) => /* @__PURE__ */ e(
245
- de,
246
- {
247
- activeEditor: l,
248
- nodeKey: t,
249
- onClose: s
250
- }
251
- ));
252
- },
253
- children: "Edit"
254
- }
255
- ),
256
- /* @__PURE__ */ e(
257
- ue,
258
- {
259
- className: d ? `focused ${k($) ? "draggable" : ""}` : null,
260
- src: n,
261
- altText: o,
262
- imageRef: C,
263
- width: u,
264
- height: r,
265
- position: I
266
- }
267
- )
268
- ] }),
269
- c && /* @__PURE__ */ e("div", { className: "image-caption-container", children: /* @__PURE__ */ f(le, { initialEditor: i, children: [
270
- /* @__PURE__ */ e(Z, {}),
271
- /* @__PURE__ */ e(K, {}),
272
- /* @__PURE__ */ e(
273
- ee,
274
- {
275
- contentEditable: /* @__PURE__ */ e(ne, { className: "InlineImageNode__contentEditable" }),
276
- placeholder: /* @__PURE__ */ e(oe, { className: "InlineImageNode__placeholder", children: "Enter a caption..." }),
277
- ErrorBoundary: te
278
- }
279
- )
280
- ] }) })
281
- ] }),
282
- x
283
- ] });
284
- }
285
- export {
286
- de as UpdateInlineImageDialog,
287
- be as default
288
- };
@@ -1,52 +0,0 @@
1
- import { ad as p, ae as k, l as E } from "./layers.B3PKFuLO.js";
2
- import { useRef as O, useContext as P, useMemo as D, useEffect as h } from "react";
3
- import { jsx as _ } from "react/jsx-runtime";
4
- function K(e) {
5
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
6
- }
7
- var C = K(function(e) {
8
- const t = new URLSearchParams();
9
- t.append("code", e);
10
- for (let o = 1; o < arguments.length; o++) t.append("v", arguments[o]);
11
- throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
12
- });
13
- function m(e) {
14
- const t = e.transform();
15
- return t !== null ? /* @__PURE__ */ new Set([t]) : /* @__PURE__ */ new Set();
16
- }
17
- function S({ initialEditor: e, children: t, initialNodes: o, initialTheme: g, skipCollabChecks: v }) {
18
- const f = O(!1), i = P(p);
19
- i == null && C(9);
20
- const [l, { getTheme: w }] = i, x = D(() => {
21
- const a = g || w() || void 0, y = k(i, a);
22
- if (a !== void 0 && (e._config.theme = a), e._parentEditor = l, o) for (let r of o) {
23
- let s = null, n = null;
24
- if (typeof r != "function") {
25
- const d = r;
26
- r = d.replace, s = d.with, n = d.withKlass || null;
27
- }
28
- const u = e._nodes.get(r.getType());
29
- e._nodes.set(r.getType(), { exportDOM: u ? u.exportDOM : void 0, klass: r, replace: s, replaceWithKlass: n, transforms: m(r) });
30
- }
31
- else {
32
- const r = e._nodes = new Map(l._nodes);
33
- for (const [s, n] of r) e._nodes.set(s, { exportDOM: n.exportDOM, klass: n.klass, replace: n.replace, replaceWithKlass: n.replaceWithKlass, transforms: m(n.klass) });
34
- }
35
- return e._config.namespace = l._config.namespace, e._editable = l._editable, [e, y];
36
- }, []), { isCollabActive: M, yjsDocMap: b } = E(), c = v || f.current || b.has(e.getKey());
37
- return h(() => {
38
- c && (f.current = !0);
39
- }, [c]), h(() => l.registerEditableListener((a) => {
40
- e.setEditable(a);
41
- }), [e, l]), _(p.Provider, { value: x, children: !M || c ? t : null });
42
- }
43
- function W({
44
- children: e,
45
- className: t
46
- }) {
47
- return /* @__PURE__ */ _("div", { className: t || "Placeholder__root", children: e });
48
- }
49
- export {
50
- W as P,
51
- S as d
52
- };
@@ -1,170 +0,0 @@
1
- import { jsx as o, jsxs as g } from "react/jsx-runtime";
2
- import { useMemo as I, useState as D, useRef as S, useCallback as $, useEffect as V } from "react";
3
- import { u as j, f as E, w as P, g as x, c as k, v as b, N as R, k as w, K as v, m as B, r as y, B as A, x as T, l as W } from "./layers.B3PKFuLO.js";
4
- function O(...t) {
5
- return t.filter(Boolean).join(" ");
6
- }
7
- function F(t) {
8
- return t.reduce((c, n) => c + n.votes.length, 0);
9
- }
10
- function L({
11
- option: t,
12
- index: c,
13
- options: n,
14
- totalVotes: a,
15
- withPollNode: p
16
- }) {
17
- const { clientID: r } = W(), h = S(null), m = t.votes, _ = m.indexOf(r) !== -1, i = m.length, f = t.text;
18
- return /* @__PURE__ */ g("div", { className: "PollNode__optionContainer", children: [
19
- /* @__PURE__ */ o(
20
- "div",
21
- {
22
- className: O(
23
- "PollNode__optionCheckboxWrapper",
24
- _ && "PollNode__optionCheckboxChecked"
25
- ),
26
- children: /* @__PURE__ */ o(
27
- "input",
28
- {
29
- ref: h,
30
- className: "PollNode__optionCheckbox",
31
- type: "checkbox",
32
- onChange: () => {
33
- p((d) => {
34
- d.toggleVote(t, r);
35
- });
36
- },
37
- checked: _
38
- }
39
- )
40
- }
41
- ),
42
- /* @__PURE__ */ g("div", { className: "PollNode__optionInputWrapper", children: [
43
- /* @__PURE__ */ o(
44
- "div",
45
- {
46
- className: "PollNode__optionInputVotes",
47
- style: { width: `${i === 0 ? 0 : i / a * 100}%` }
48
- }
49
- ),
50
- /* @__PURE__ */ o("span", { className: "PollNode__optionInputVotesCount", children: i > 0 && (i === 1 ? "1 vote" : `${i} votes`) }),
51
- /* @__PURE__ */ o(
52
- "input",
53
- {
54
- className: "PollNode__optionInput",
55
- type: "text",
56
- value: f,
57
- onChange: (d) => {
58
- const u = d.target, N = u.value, e = u.selectionStart, l = u.selectionEnd;
59
- p(
60
- (s) => {
61
- s.setOptionText(t, N);
62
- },
63
- () => {
64
- u.selectionStart = e, u.selectionEnd = l;
65
- }
66
- );
67
- },
68
- placeholder: `Option ${c + 1}`
69
- }
70
- )
71
- ] }),
72
- /* @__PURE__ */ o(
73
- "button",
74
- {
75
- disabled: n.length < 3,
76
- className: O(
77
- "PollNode__optionDelete",
78
- n.length < 3 && "PollNode__optionDeleteDisabled"
79
- ),
80
- "aria-label": "Remove",
81
- onClick: () => {
82
- p((d) => {
83
- d.deleteOption(t);
84
- });
85
- }
86
- }
87
- )
88
- ] });
89
- }
90
- function z({
91
- question: t,
92
- options: c,
93
- nodeKey: n
94
- }) {
95
- const [a] = j(), p = I(() => F(c), [c]), [r, h, m] = E(n), [C, _] = D(null), i = S(null), f = $(
96
- (e) => {
97
- if (r && P(x())) {
98
- e.preventDefault();
99
- const s = k(n);
100
- b(s) && s.remove();
101
- }
102
- return !1;
103
- },
104
- [r, n]
105
- );
106
- V(() => R(
107
- a.registerUpdateListener(({ editorState: e }) => {
108
- _(e.read(() => x()));
109
- }),
110
- a.registerCommand(
111
- y,
112
- (e) => {
113
- const l = e;
114
- return l.target === i.current ? (l.shiftKey || m(), h(!r), !0) : !1;
115
- },
116
- v
117
- ),
118
- a.registerCommand(
119
- B,
120
- f,
121
- v
122
- ),
123
- a.registerCommand(
124
- w,
125
- f,
126
- v
127
- )
128
- ), [m, a, r, n, f, h]);
129
- const d = (e, l) => {
130
- a.update(
131
- () => {
132
- const s = k(n);
133
- b(s) && e(s);
134
- },
135
- { onUpdate: l }
136
- );
137
- }, u = () => {
138
- d((e) => {
139
- e.addOption(T());
140
- });
141
- }, N = P(C) && r;
142
- return /* @__PURE__ */ o(
143
- "div",
144
- {
145
- className: `PollNode__container ${N ? "focused" : ""}`,
146
- ref: i,
147
- children: /* @__PURE__ */ g("div", { className: "PollNode__inner", children: [
148
- /* @__PURE__ */ o("h2", { className: "PollNode__heading", children: t }),
149
- c.map((e, l) => {
150
- const s = e.uid;
151
- return /* @__PURE__ */ o(
152
- L,
153
- {
154
- withPollNode: d,
155
- option: e,
156
- index: l,
157
- options: c,
158
- totalVotes: p
159
- },
160
- s
161
- );
162
- }),
163
- /* @__PURE__ */ o("div", { className: "PollNode__footer", children: /* @__PURE__ */ o(A, { onClick: u, small: !0, children: "Add Option" }) })
164
- ] })
165
- }
166
- );
167
- }
168
- export {
169
- z as default
170
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),x=require("react"),e=require("./layers.Dyb1dHPy.js");function C(...n){return n.filter(Boolean).join(" ")}function P(n){return n.reduce((i,s)=>i+s.votes.length,0)}function j({option:n,index:i,options:s,totalVotes:r,withPollNode:h}){const{clientID:a}=e.l(),m=x.useRef(null),N=n.votes,f=N.indexOf(a)!==-1,d=N.length,_=n.text;return o.jsxs("div",{className:"PollNode__optionContainer",children:[o.jsx("div",{className:C("PollNode__optionCheckboxWrapper",f&&"PollNode__optionCheckboxChecked"),children:o.jsx("input",{ref:m,className:"PollNode__optionCheckbox",type:"checkbox",onChange:()=>{h(u=>{u.toggleVote(n,a)})},checked:f})}),o.jsxs("div",{className:"PollNode__optionInputWrapper",children:[o.jsx("div",{className:"PollNode__optionInputVotes",style:{width:`${d===0?0:d/r*100}%`}}),o.jsx("span",{className:"PollNode__optionInputVotesCount",children:d>0&&(d===1?"1 vote":`${d} votes`)}),o.jsx("input",{className:"PollNode__optionInput",type:"text",value:_,onChange:u=>{const p=u.target,v=p.value,t=p.selectionStart,l=p.selectionEnd;h(c=>{c.setOptionText(n,v)},()=>{p.selectionStart=t,p.selectionEnd=l})},placeholder:`Option ${i+1}`})]}),o.jsx("button",{disabled:s.length<3,className:C("PollNode__optionDelete",s.length<3&&"PollNode__optionDeleteDisabled"),"aria-label":"Remove",onClick:()=>{h(u=>{u.deleteOption(n)})}})]})}function k({question:n,options:i,nodeKey:s}){const[r]=e.u(),h=x.useMemo(()=>P(i),[i]),[a,m,N]=e.u$1(s),[g,f]=x.useState(null),d=x.useRef(null),_=x.useCallback(t=>{if(a&&e.wi(e.Ri())){t.preventDefault();const c=e.Ct(s);e.$isPollNode(c)&&c.remove()}return!1},[a,s]);x.useEffect(()=>e.N(r.registerUpdateListener(({editorState:t})=>{f(t.read(()=>e.Ri()))}),r.registerCommand(e.r,t=>{const l=t;return l.target===d.current?(l.shiftKey||N(),m(!a),!0):!1},e.Ks),r.registerCommand(e.w,_,e.Ks),r.registerCommand(e.k,_,e.Ks)),[N,r,a,s,_,m]);const u=(t,l)=>{r.update(()=>{const c=e.Ct(s);e.$isPollNode(c)&&t(c)},{onUpdate:l})},p=()=>{u(t=>{t.addOption(e.createPollOption())})},v=e.wi(g)&&a;return o.jsx("div",{className:`PollNode__container ${v?"focused":""}`,ref:d,children:o.jsxs("div",{className:"PollNode__inner",children:[o.jsx("h2",{className:"PollNode__heading",children:n}),i.map((t,l)=>{const c=t.uid;return o.jsx(j,{withPollNode:u,option:t,index:l,options:i,totalVotes:h},c)}),o.jsx("div",{className:"PollNode__footer",children:o.jsx(e.Button,{onClick:p,small:!0,children:"Add Option"})})]})})}exports.default=k;