@jpmorganchase/mosaic-content-editor-plugin 0.1.0-beta.47 → 0.1.0-beta.49
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/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +22 -0
- package/dist/{chunk-IVMPDIDZ.js → chunk-G5KHGFL7.js} +1 -1
- package/dist/{chunk-FDQTXNTN.js → chunk-L2OH7BJU.js} +1 -1
- package/dist/chunk-NRVOINKM.js +1 -0
- package/dist/chunk-U4LYPE2K.js +1 -0
- package/dist/chunk-YFKHACPP.js +1 -0
- package/dist/components/Editor.js +1 -1
- package/dist/components/Toolbar/InsertImage.js +1 -1
- package/dist/components/Toolbar/InsertLink.js +1 -1
- package/dist/components/Toolbar/Toolbar.js +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/FloatingToolbarPlugin.js +1 -1
- package/dist/plugins/MarkdownLinkPlugin.js +1 -1
- package/dist/plugins/PreviewPlugin.js +1 -1
- package/package.json +3 -3
- package/src/components/Editor.tsx +0 -2
- package/src/components/Toolbar/InsertImage.tsx +19 -24
- package/src/components/Toolbar/InsertLink.tsx +32 -44
- package/dist/chunk-23CWTC65.js +0 -1
- package/dist/chunk-E2MDU6JD.js +0 -1
- package/dist/chunk-V6H2L7PK.js +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@jpmorganchase/mosaic-content-editor-plugin:build: cache hit, replaying output
|
|
1
|
+
@jpmorganchase/mosaic-content-editor-plugin:build: cache hit, replaying output 3000f9b9dd1dfb1e
|
|
2
2
|
@jpmorganchase/mosaic-content-editor-plugin:build: $ npm-run-all --parallel build:*
|
|
3
|
-
@jpmorganchase/mosaic-content-editor-plugin:build: $ tsc
|
|
4
3
|
@jpmorganchase/mosaic-content-editor-plugin:build: $ node ../../scripts/bundle.js
|
|
4
|
+
@jpmorganchase/mosaic-content-editor-plugin:build: $ tsc
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @jpmorganchase/mosaic-content-editor-plugin
|
|
2
2
|
|
|
3
|
+
## 0.1.0-beta.49
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @jpmorganchase/mosaic-components@0.1.0-beta.49
|
|
8
|
+
- @jpmorganchase/mosaic-theme@0.1.0-beta.49
|
|
9
|
+
|
|
10
|
+
## 0.1.0-beta.48
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- eb085d3d: ### Fix
|
|
15
|
+
|
|
16
|
+
The insert/edit link dialog no longer closes when its contents are clicked.
|
|
17
|
+
|
|
18
|
+
### Refactor
|
|
19
|
+
|
|
20
|
+
The forms used to insert/edit links and insert images in the content editor plugin have been updated to use the latest version of `FormField` and `Input` from Salt-ds.
|
|
21
|
+
|
|
22
|
+
- @jpmorganchase/mosaic-components@0.1.0-beta.48
|
|
23
|
+
- @jpmorganchase/mosaic-theme@0.1.0-beta.48
|
|
24
|
+
|
|
3
25
|
## 0.1.0-beta.47
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as l}from"./chunk-4B2NDAA2.js";import{a as s}from"./chunk-DLRFTDUZ.js";import{a as d}from"./chunk-
|
|
1
|
+
import{a as l}from"./chunk-4B2NDAA2.js";import{a as s}from"./chunk-DLRFTDUZ.js";import{a as d}from"./chunk-NRVOINKM.js";import{a as b}from"./chunk-DXTVYP7D.js";import{a as n}from"./chunk-PC66Q33O.js";import{a as m}from"./chunk-FW7CHFWO.js";import{a as e}from"./chunk-5KRV6UWE.js";import{c as p}from"./chunk-YFKHACPP.js";import{a as T}from"./chunk-7JRJTNUG.js";import{a as r}from"./chunk-GYUEXLD6.js";import{a as t}from"./chunk-3QIETKQW.js";import{c as i}from"./chunk-G57W376H.js";import o from"react";import{Icon as a}from"@jpmorganchase/mosaic-components";var I=()=>{let{canRedo:f,canUndo:y,redoEdit:u,undoEdit:g}=m(),{setPageState:B}=i();return o.createElement(T,{"aria-label":"page editing toolbar"},o.createElement(r,{"aria-label":"history tooltray"},o.createElement(t,{label:"Undo",disabled:!y,onClick:g},o.createElement(a,{name:"undo"})),o.createElement(t,{label:"Redo",disabled:!f,onClick:u},o.createElement(a,{name:"redo"})),o.createElement(l,null)),o.createElement(e,null),o.createElement(r,{"aria-label":"text format tooltray"},o.createElement(p,null),o.createElement(b,null),o.createElement(d,null),o.createElement(s,null),o.createElement(l,null)),o.createElement(r,{"aria-label":"stop editing tooltray",align:"right"},o.createElement(t,{label:"Cancel Editing",onClick:()=>B("VIEW")},o.createElement(a,{name:"delete"})),o.createElement(l,null)),o.createElement(r,{"aria-label":"copy tooltray"},o.createElement(n,null)))},W=I;export{W as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as f}from"./chunk-5KRV6UWE.js";import{c as b}from"./chunk-
|
|
1
|
+
import{a as f}from"./chunk-5KRV6UWE.js";import{c as b}from"./chunk-YFKHACPP.js";import{a as u}from"./chunk-YIFLQ5MW.js";import{a as y}from"./chunk-7JRJTNUG.js";import{a as c}from"./chunk-GYUEXLD6.js";import{a as d}from"./chunk-TSWYSURQ.js";import o,{useCallback as U,useEffect as h,useState as T}from"react";import{useLexicalComposerContext as L}from"@lexical/react/LexicalComposerContext";import{mergeRegister as A}from"@lexical/utils";import{$getSelection as B,$isRangeSelection as M,COMMAND_PRIORITY_LOW as R,SELECTION_CHANGE_COMMAND as _}from"lexical";import{flip as k,inline as w,useInteractions as D,useDismiss as $}from"@floating-ui/react";import{useFloatingUI as v}from"@salt-ds/core";function tt(){let[e]=L(),[t,i]=T(null),[m,r]=T(!1),C=t?{middleware:[w(t),k({fallbackPlacements:["bottom-start","top-start"]})]}:{placement:"bottom-start",strategy:"absolute"},{context:P,floating:x,reference:p,strategy:F}=v({placement:"bottom-start",open:m,onOpenChange:r,strategy:"absolute",...C}),{getFloatingProps:I}=D([$(P,{ancestorScroll:!0})]),n=U(()=>{let l=B(),s=window.getSelection(),g=s?.anchorNode?.parentElement;if(M(l)&&g&&!s?.isCollapsed){p(g);let S=s.getRangeAt(0),{x:E,y:O,height:N}=S.getBoundingClientRect();i({x:E,y:O+N}),r(!0)}else i(null),r(!1)},[p]);h(()=>A(e.registerUpdateListener(({editorState:l})=>{l.read(()=>{n()})}),e.registerCommand(_,()=>(n(),!1),R)),[e,n]);let a={position:F};return t&&(a={...a,top:t.y,left:t.x}),o.createElement(u,{ref:x,open:m,style:a,...I({})},o.createElement(y,{"aria-label":"page editing toolbar",className:d.toolbar},o.createElement(f,{floating:!0}),o.createElement(c,{"aria-label":"text format tooltray"},o.createElement(b,null))))}export{tt as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as b}from"./chunk-KZXCNQER.js";import{a as I}from"./chunk-YBFKG74H.js";import{a as v}from"./chunk-3QIETKQW.js";import{a as h}from"./chunk-XSZUCLBY.js";import e,{useState as i}from"react";import{useLexicalComposerContext as M}from"@lexical/react/LexicalComposerContext";import{Button as c,Icon as P}from"@jpmorganchase/mosaic-components";import{string as C,object as V}from"yup";import{Input as S,FormField as D,FormFieldLabel as y,FormFieldHelperText as A}from"@salt-ds/core";import{ButtonBar as q,DialogTitle as w,DialogContent as L,DialogActions as N}from"@salt-ds/lab";var B=V({alt:C().required("Alternative Information is a required field").max(100,"Alternative Information must be fewer than 100 characters"),url:C().required("Url is required").url("Must be a valid Url")}),E={url:"https://"},Y=()=>{let[T]=M(),[s,m]=i(!1),[r,u]=i(E),[n,d]=i(),f=t=>{m(t),t||u(E)},x=()=>m(!0),p=()=>{f(!1)},g=t=>{let o=t.inner.reduce((l,{path:a,message:O})=>({...l,[a]:O}),{});d(o)},F=t=>{let{name:o,value:l}=t.target,a={...r,[o]:l};B.validateAt(o,a,{abortEarly:!1}).then(()=>{d({...n,[o]:void 0})},g),u(a)};return e.createElement(e.Fragment,null,e.createElement(v,{active:s,onClick:x,label:"Insert Image"},e.createElement(P,{name:"addDocument"})),e.createElement(h,{onOpenChange:f,open:s},e.createElement("form",{onSubmit:async t=>{t.preventDefault(),B.validate(r,{abortEarly:!1}).then(()=>{let o={alt:r&&r.alt!==void 0?r.alt:null,url:r&&r.url!==void 0?r.url:null};T.dispatchCommand(I,o),p()},g)},noValidate:!0},e.createElement(w,null,"Insert Image"),e.createElement(L,null,e.createElement("div",{className:b.fullWidth},e.createElement(D,{validationStatus:n?.url?"error":void 0},e.createElement(y,null,"Url for image"),e.createElement(S,{value:r?.url,inputProps:{name:"url"},onChange:F}),e.createElement(A,null,n?.url)),e.createElement(D,{validationStatus:n?.alt?"error":void 0},e.createElement(y,null,"Alternative Information (alt)"),e.createElement(S,{value:r?.alt,inputProps:{name:"alt"},onChange:F}),e.createElement(A,null,n?.alt||"Provides alternative information for the image if for some reason it cannot be viewed")))),e.createElement(N,null,e.createElement(q,null,e.createElement(c,{onClick:p},"Cancel"),e.createElement(c,{variant:"cta",type:"submit"},"Insert"))))))};export{Y as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as E}from"./chunk-G5KHGFL7.js";import{a as y}from"./chunk-TVGVMAJS.js";import{a as f}from"./chunk-UWF3FV3R.js";import{a as x}from"./chunk-QHE4U3WR.js";import{a}from"./chunk-M4ISRNFD.js";import{b as w}from"./chunk-YBFKG74H.js";import{a as M}from"./chunk-ROQUYURQ.js";import{a as h}from"./chunk-3FJGHVH5.js";import{a as k}from"./chunk-QKOQTH4L.js";import{a as P}from"./chunk-RO6ARCLZ.js";import{a as b}from"./chunk-L2OH7BJU.js";import{b as S}from"./chunk-YFKHACPP.js";import{a as C,d as v,f as l}from"./chunk-G57W376H.js";import{a as T}from"./chunk-FKL4ZGDB.js";import{a as g}from"./chunk-PXUVNH4P.js";import{a as n}from"./chunk-NXV7KCC5.js";import R from"react";import{$convertToMarkdownString as oo}from"@lexical/markdown";import{OnChangePlugin as ro}from"@lexical/react/LexicalOnChangePlugin";import to from"lodash/debounce";import o,{useRef as B,useState as D}from"react";import H from"clsx";import j from"gray-matter";import{LexicalComposer as A}from"@lexical/react/LexicalComposer";import{ListPlugin as I}from"@lexical/react/LexicalListPlugin";import{TablePlugin as J}from"@lexical/react/LexicalTablePlugin";import{LinkPlugin as W}from"@lexical/react/LexicalLinkPlugin";import{HistoryPlugin as X}from"@lexical/react/LexicalHistoryPlugin";import{MarkdownShortcutPlugin as q}from"@lexical/react/LexicalMarkdownShortcutPlugin";import G from"react-split";import{$convertFromMarkdownString as K}from"@lexical/markdown";function Q(r){console.error(r)}var V={namespace:"mosaic-content-editor",onError:Q,nodes:P,theme:h},Y=()=>{let r=document.createElement("div");return r.className=n.gutter,r},Z=({components:r,content:e,persistUrl:m,PreviewComponent:i,previewUrl:s,source:p,user:t})=>{let L=C()||p,{setUser:N}=v(),[c,u]=D(!1),U=B(null),{data:d,content:z}=j(e),$=()=>{u(!0),N(t)},O=()=>{u(!1)};return o.createElement(A,{initialConfig:{...V,editorState:()=>K(z,a)}},o.createElement("div",{className:n.root,onFocus:$,onBlur:O},o.createElement("div",{className:n.toolbarContainer},o.createElement(E,null),o.createElement(y,{meta:d,persistUrl:m}),o.createElement(k,null)),o.createElement("div",{className:n.editorRoot},o.createElement(G,{className:n.splitter,cursor:"col-resize",direction:"horizontal",dragInterval:1,expandToMin:!1,gutter:Y,gutterAlign:"center",minSize:100,sizes:[50,50],snapOffset:30},o.createElement(f,{className:H({[n.focused]:c,[n.unfocused]:!c}),ref:U},o.createElement(g,null)),o.createElement(f,null,i&&o.createElement(i,{source:L,meta:d,components:r}))),o.createElement(X,null),o.createElement(I,null),o.createElement(J,null),o.createElement(W,null),o.createElement(q,{transformers:a}),s?o.createElement(F,{previewUrl:s}):null,o.createElement(w,null),o.createElement(S,null),o.createElement(x,null),o.createElement(T,null),o.createElement(b,null),o.createElement(M,null))))},_=Z;async function eo(r,e){return await(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"markdown",text:e})})).json()}function no(r){let e=to(r,250,{maxWait:500});return{onChange:i=>{i.read(()=>{let s=oo(a);s&&e(s)})}}}var F=({previewUrl:r})=>{let{setErrorMessage:e,setPreviewContent:m}=l(),i=async p=>{try{if(p){let t=await eo(r,p);!t.error&&t?.source?m(t.source):e(`${t.error?.toUpperCase()}: ${t?.exception}`)}}catch(t){t instanceof Error&&e(`MDX Error: ${t.message}`)}},{onChange:s}=no(i);return R.createElement(ro,{onChange:s,ignoreSelectionChange:!0})};export{F as a,_ as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as C}from"./chunk-WZYDYWT3.js";import{a as I}from"./chunk-3QIETKQW.js";import{e as p}from"./chunk-G57W376H.js";import{a as k}from"./chunk-XSZUCLBY.js";import{$createLinkNode as W,TOGGLE_LINK_COMMAND as G}from"@lexical/link";import{useLexicalComposerContext as U}from"@lexical/react/LexicalComposerContext";import{$wrapNodes as j}from"@lexical/selection";import{$createParagraphNode as Y,$createTextNode as z,$getSelection as J,$isRangeSelection as Q,$isTextNode as X,COMMAND_PRIORITY_EDITOR as Z,createCommand as R}from"lexical";import ee,{useCallback as te,useEffect as ne}from"react";import e,{useEffect as O,useState as F}from"react";import{useLexicalComposerContext as B}from"@lexical/react/LexicalComposerContext";import{Button as N,Icon as _}from"@jpmorganchase/mosaic-components";import{string as h,object as A}from"yup";import{Input as T,FormField as D,FormFieldLabel as S,FormFieldHelperText as E}from"@salt-ds/core";import{ButtonBar as $,DialogTitle as w,DialogContent as K,DialogActions as q}from"@salt-ds/lab";import{$getSelection as V,$isRangeSelection as H}from"lexical";var b=A({url:h().required("Url is required"),text:h().required("Text is required").max(100,"Text must be fewer than 100 characters")}),Le=()=>{let{isInsertingLink:t,setIsInsertingLink:r}=p();return e.createElement(I,{active:t,onClick:()=>r(!0),label:"Insert Link"},e.createElement(_,{name:"linked"}))},v={url:"https://",text:""},y=()=>{let[t]=B(),{isInsertingLink:r,setIsInsertingLink:s}=p(),[o,i]=F(v),[a,d]=F(),m=n=>{s(n),n||(d(void 0),i(v))},g=()=>{m(!1)};O(()=>{t.getEditorState().read(()=>{if(r){let n=V();if(H(n)){let l=n.getTextContent();i(u=>({...u,text:l}))}}})},[t,r]);let x=n=>{let l=n.inner.reduce((u,{path:c,message:P})=>({...u,[c]:P}),{});d(l)},L=n=>{let{name:l,value:u}=n.target,c={...o,[l]:u};b.validateAt(l,c,{abortEarly:!1}).then(()=>{d({...a,[l]:void 0})},x),i(c)},M=async()=>{b.validate(o,{abortEarly:!1}).then(()=>{let n={url:o?.url,text:o?.text};t.dispatchCommand(f,n),g()},x)};return e.createElement(k,{onOpenChange:m,open:r},e.createElement(w,null,"Insert Link"),e.createElement(K,null,e.createElement("div",{className:C.fullWidth},e.createElement(D,{validationStatus:a?.url?"error":void 0},e.createElement(S,null,"Image URL text"),e.createElement(T,{value:o?.url,inputProps:{name:"url"},onChange:L}),e.createElement(E,null,a?.url)),e.createElement(D,{validationStatus:a?.text?"error":void 0},e.createElement(S,null,"Link Text"),e.createElement(T,{value:o?.text,inputProps:{name:"text"},onChange:L}),e.createElement(E,null,a?.text)))),e.createElement(q,null,e.createElement($,null,e.createElement(N,{onClick:g},"Cancel"),e.createElement(N,{variant:"cta",onClick:M},"Insert"))))};var f=R();function oe(){let[t]=U(),r=te(({url:s,text:o})=>{t.update(()=>{let i=J();if(Q(i)&&s!==void 0&&o!==void 0){let a=i.focus.getNode();if(X(a))t.dispatchCommand(G,s);else{let d=W(s),m=z(o);m.setFormat(i.focus.getNode().getFormat()),d.append(m),j(i,()=>d,Y())}}})},[t]);ne(()=>t.registerCommand(f,s=>(r(s),!0),Z),[t,r])}function Se(){return oe(),ee.createElement(y,null)}export{f as a,Se as b,Le as c,y as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a}from"../chunk-
|
|
1
|
+
import{b as a}from"../chunk-U4LYPE2K.js";import"../chunk-G5KHGFL7.js";import"../chunk-4B2NDAA2.js";import"../chunk-4LQ77YZW.js";import"../chunk-DLRFTDUZ.js";import"../chunk-NRVOINKM.js";import"../chunk-KZXCNQER.js";import"../chunk-DXTVYP7D.js";import"../chunk-NFA3MZOC.js";import"../chunk-TVGVMAJS.js";import"../chunk-6EO5B7QP.js";import"../chunk-R2MEEU32.js";import"../chunk-UWF3FV3R.js";import"../chunk-KQ2ZCDYD.js";import"../chunk-QHE4U3WR.js";import"../chunk-BFF3MNBV.js";import"../chunk-5YCBSSDA.js";import"../chunk-NFSXCTUU.js";import"../chunk-6TM3EYFS.js";import"../chunk-M4ISRNFD.js";import"../chunk-ESJNOEFD.js";import"../chunk-WNTJMWYJ.js";import"../chunk-RT5CJ7T5.js";import"../chunk-G4LBXKDE.js";import"../chunk-YBFKG74H.js";import"../chunk-ROQUYURQ.js";import"../chunk-ESKW4XF6.js";import"../chunk-6YPAVQF4.js";import"../chunk-3FJGHVH5.js";import"../chunk-JQUDHJIQ.js";import"../chunk-ZHZ4E2MI.js";import"../chunk-PC66Q33O.js";import"../chunk-QKOQTH4L.js";import"../chunk-FW7CHFWO.js";import"../chunk-RO6ARCLZ.js";import"../chunk-L2OH7BJU.js";import"../chunk-5KRV6UWE.js";import"../chunk-SOMQOHNT.js";import"../chunk-U7COOUR6.js";import"../chunk-YFKHACPP.js";import"../chunk-WZYDYWT3.js";import"../chunk-YIFLQ5MW.js";import"../chunk-XP37MJCS.js";import"../chunk-P5OBPOC4.js";import"../chunk-7JRJTNUG.js";import"../chunk-GYUEXLD6.js";import"../chunk-FH2LMMJT.js";import"../chunk-7LK4O57W.js";import"../chunk-3QIETKQW.js";import"../chunk-Y2A2ULLZ.js";import"../chunk-G57W376H.js";import"../chunk-TSWYSURQ.js";import"../chunk-FKL4ZGDB.js";import"../chunk-Z6W7GDHE.js";import"../chunk-PXUVNH4P.js";import"../chunk-XSZUCLBY.js";import"../chunk-OW5SK4AJ.js";import"../chunk-NXV7KCC5.js";import"../chunk-6X665P47.js";export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-NRVOINKM.js";import"../../chunk-KZXCNQER.js";import"../../chunk-YBFKG74H.js";import"../../chunk-3QIETKQW.js";import"../../chunk-Y2A2ULLZ.js";import"../../chunk-XSZUCLBY.js";import"../../chunk-OW5SK4AJ.js";export{a as InsertImage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as a,d as b}from"../../chunk-
|
|
1
|
+
import{c as a,d as b}from"../../chunk-YFKHACPP.js";import"../../chunk-WZYDYWT3.js";import"../../chunk-3QIETKQW.js";import"../../chunk-Y2A2ULLZ.js";import"../../chunk-G57W376H.js";import"../../chunk-XSZUCLBY.js";import"../../chunk-OW5SK4AJ.js";export{a as InsertLinkButton,b as InsertLinkDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-G5KHGFL7.js";import"../../chunk-4B2NDAA2.js";import"../../chunk-4LQ77YZW.js";import"../../chunk-DLRFTDUZ.js";import"../../chunk-NRVOINKM.js";import"../../chunk-KZXCNQER.js";import"../../chunk-DXTVYP7D.js";import"../../chunk-NFA3MZOC.js";import"../../chunk-YBFKG74H.js";import"../../chunk-PC66Q33O.js";import"../../chunk-FW7CHFWO.js";import"../../chunk-5KRV6UWE.js";import"../../chunk-SOMQOHNT.js";import"../../chunk-U7COOUR6.js";import"../../chunk-YFKHACPP.js";import"../../chunk-WZYDYWT3.js";import"../../chunk-YIFLQ5MW.js";import"../../chunk-XP37MJCS.js";import"../../chunk-P5OBPOC4.js";import"../../chunk-7JRJTNUG.js";import"../../chunk-GYUEXLD6.js";import"../../chunk-FH2LMMJT.js";import"../../chunk-7LK4O57W.js";import"../../chunk-3QIETKQW.js";import"../../chunk-Y2A2ULLZ.js";import"../../chunk-G57W376H.js";import"../../chunk-XSZUCLBY.js";import"../../chunk-OW5SK4AJ.js";export{a as default};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as c}from"./chunk-
|
|
1
|
+
import{b as c}from"./chunk-U4LYPE2K.js";import"./chunk-G5KHGFL7.js";import"./chunk-4B2NDAA2.js";import"./chunk-4LQ77YZW.js";import"./chunk-DLRFTDUZ.js";import"./chunk-NRVOINKM.js";import"./chunk-KZXCNQER.js";import"./chunk-DXTVYP7D.js";import"./chunk-NFA3MZOC.js";import"./chunk-TVGVMAJS.js";import"./chunk-6EO5B7QP.js";import"./chunk-R2MEEU32.js";import"./chunk-UWF3FV3R.js";import"./chunk-KQ2ZCDYD.js";import"./chunk-QHE4U3WR.js";import"./chunk-BFF3MNBV.js";import"./chunk-5YCBSSDA.js";import"./chunk-NFSXCTUU.js";import"./chunk-6TM3EYFS.js";import"./chunk-M4ISRNFD.js";import"./chunk-ESJNOEFD.js";import"./chunk-WNTJMWYJ.js";import"./chunk-RT5CJ7T5.js";import"./chunk-G4LBXKDE.js";import"./chunk-YBFKG74H.js";import"./chunk-ROQUYURQ.js";import"./chunk-ESKW4XF6.js";import"./chunk-6YPAVQF4.js";import"./chunk-3FJGHVH5.js";import"./chunk-JQUDHJIQ.js";import{a as d}from"./chunk-ZHZ4E2MI.js";import"./chunk-PC66Q33O.js";import"./chunk-QKOQTH4L.js";import"./chunk-FW7CHFWO.js";import"./chunk-RO6ARCLZ.js";import"./chunk-L2OH7BJU.js";import"./chunk-5KRV6UWE.js";import"./chunk-SOMQOHNT.js";import"./chunk-U7COOUR6.js";import"./chunk-YFKHACPP.js";import"./chunk-WZYDYWT3.js";import"./chunk-YIFLQ5MW.js";import"./chunk-XP37MJCS.js";import"./chunk-P5OBPOC4.js";import"./chunk-7JRJTNUG.js";import"./chunk-GYUEXLD6.js";import"./chunk-FH2LMMJT.js";import"./chunk-7LK4O57W.js";import"./chunk-3QIETKQW.js";import"./chunk-Y2A2ULLZ.js";import{c as a,f as b}from"./chunk-G57W376H.js";import"./chunk-TSWYSURQ.js";import"./chunk-FKL4ZGDB.js";import"./chunk-Z6W7GDHE.js";import"./chunk-PXUVNH4P.js";import"./chunk-XSZUCLBY.js";import"./chunk-OW5SK4AJ.js";import"./chunk-NXV7KCC5.js";import"./chunk-6X665P47.js";export{c as Editor,d as EditorControls,b as useContentEditor,a as usePageState};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-L2OH7BJU.js";import"../chunk-5KRV6UWE.js";import"../chunk-SOMQOHNT.js";import"../chunk-U7COOUR6.js";import"../chunk-YFKHACPP.js";import"../chunk-WZYDYWT3.js";import"../chunk-YIFLQ5MW.js";import"../chunk-XP37MJCS.js";import"../chunk-P5OBPOC4.js";import"../chunk-7JRJTNUG.js";import"../chunk-GYUEXLD6.js";import"../chunk-FH2LMMJT.js";import"../chunk-7LK4O57W.js";import"../chunk-3QIETKQW.js";import"../chunk-Y2A2ULLZ.js";import"../chunk-G57W376H.js";import"../chunk-TSWYSURQ.js";import"../chunk-XSZUCLBY.js";import"../chunk-OW5SK4AJ.js";export{a as FloatingToolbarPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"../chunk-
|
|
1
|
+
import{a,b}from"../chunk-YFKHACPP.js";import"../chunk-WZYDYWT3.js";import"../chunk-3QIETKQW.js";import"../chunk-Y2A2ULLZ.js";import"../chunk-G57W376H.js";import"../chunk-XSZUCLBY.js";import"../chunk-OW5SK4AJ.js";export{a as INSERT_MARKDOWN_LINK_COMMAND,b as MarkdownLinkPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-U4LYPE2K.js";import"../chunk-G5KHGFL7.js";import"../chunk-4B2NDAA2.js";import"../chunk-4LQ77YZW.js";import"../chunk-DLRFTDUZ.js";import"../chunk-NRVOINKM.js";import"../chunk-KZXCNQER.js";import"../chunk-DXTVYP7D.js";import"../chunk-NFA3MZOC.js";import"../chunk-TVGVMAJS.js";import"../chunk-6EO5B7QP.js";import"../chunk-R2MEEU32.js";import"../chunk-UWF3FV3R.js";import"../chunk-KQ2ZCDYD.js";import"../chunk-QHE4U3WR.js";import"../chunk-BFF3MNBV.js";import"../chunk-5YCBSSDA.js";import"../chunk-NFSXCTUU.js";import"../chunk-6TM3EYFS.js";import"../chunk-M4ISRNFD.js";import"../chunk-ESJNOEFD.js";import"../chunk-WNTJMWYJ.js";import"../chunk-RT5CJ7T5.js";import"../chunk-G4LBXKDE.js";import"../chunk-YBFKG74H.js";import"../chunk-ROQUYURQ.js";import"../chunk-ESKW4XF6.js";import"../chunk-6YPAVQF4.js";import"../chunk-3FJGHVH5.js";import"../chunk-JQUDHJIQ.js";import"../chunk-ZHZ4E2MI.js";import"../chunk-PC66Q33O.js";import"../chunk-QKOQTH4L.js";import"../chunk-FW7CHFWO.js";import"../chunk-RO6ARCLZ.js";import"../chunk-L2OH7BJU.js";import"../chunk-5KRV6UWE.js";import"../chunk-SOMQOHNT.js";import"../chunk-U7COOUR6.js";import"../chunk-YFKHACPP.js";import"../chunk-WZYDYWT3.js";import"../chunk-YIFLQ5MW.js";import"../chunk-XP37MJCS.js";import"../chunk-P5OBPOC4.js";import"../chunk-7JRJTNUG.js";import"../chunk-GYUEXLD6.js";import"../chunk-FH2LMMJT.js";import"../chunk-7LK4O57W.js";import"../chunk-3QIETKQW.js";import"../chunk-Y2A2ULLZ.js";import"../chunk-G57W376H.js";import"../chunk-TSWYSURQ.js";import"../chunk-FKL4ZGDB.js";import"../chunk-Z6W7GDHE.js";import"../chunk-PXUVNH4P.js";import"../chunk-XSZUCLBY.js";import"../chunk-OW5SK4AJ.js";import"../chunk-NXV7KCC5.js";import"../chunk-6X665P47.js";export{a as PreviewPlugin};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jpmorganchase/mosaic-content-editor-plugin",
|
|
3
3
|
"description": "Mosaic - In Browser content editing plugin",
|
|
4
|
-
"version": "0.1.0-beta.
|
|
4
|
+
"version": "0.1.0-beta.49",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "",
|
|
7
7
|
"repository": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"typescript": "^4.8.3"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@jpmorganchase/mosaic-components": "^0.1.0-beta.
|
|
42
|
-
"@jpmorganchase/mosaic-theme": "^0.1.0-beta.
|
|
41
|
+
"@jpmorganchase/mosaic-components": "^0.1.0-beta.49",
|
|
42
|
+
"@jpmorganchase/mosaic-theme": "^0.1.0-beta.49",
|
|
43
43
|
"@salt-ds/core": "^1.8.1",
|
|
44
44
|
"@salt-ds/icons": "^1.6.0",
|
|
45
45
|
"@salt-ds/lab": "1.0.0-alpha.16",
|
|
@@ -27,7 +27,6 @@ import { ScrollableSection } from './ScrollableSection/ScrollableSection';
|
|
|
27
27
|
import HorizontalRulePlugin from '../plugins/HorizontalRulePlugin';
|
|
28
28
|
import { FloatingToolbarPlugin } from '../plugins/FloatingToolbarPlugin';
|
|
29
29
|
import { TableActionMenuPlugin } from '../plugins/TableActionMenuPlugin';
|
|
30
|
-
import { InsertLinkDialog } from './Toolbar/InsertLink';
|
|
31
30
|
|
|
32
31
|
function onError(error: Error) {
|
|
33
32
|
console.error(error);
|
|
@@ -137,7 +136,6 @@ const Editor: FC<EditorProps> = ({
|
|
|
137
136
|
<HorizontalRulePlugin />
|
|
138
137
|
<FloatingToolbarPlugin />
|
|
139
138
|
<TableActionMenuPlugin />
|
|
140
|
-
<InsertLinkDialog />
|
|
141
139
|
</div>
|
|
142
140
|
</div>
|
|
143
141
|
</LexicalComposer>
|
|
@@ -2,14 +2,8 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
3
|
import { Button, Icon } from '@jpmorganchase/mosaic-components';
|
|
4
4
|
import { string, object } from 'yup';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
DialogTitle,
|
|
8
|
-
DialogContent,
|
|
9
|
-
DialogActions,
|
|
10
|
-
FormField,
|
|
11
|
-
Input
|
|
12
|
-
} from '@salt-ds/lab';
|
|
5
|
+
import { Input, FormField, FormFieldLabel, FormFieldHelperText } from '@salt-ds/core';
|
|
6
|
+
import { ButtonBar, DialogTitle, DialogContent, DialogActions } from '@salt-ds/lab';
|
|
13
7
|
|
|
14
8
|
import { ToolbarButton } from './ToolbarButton';
|
|
15
9
|
import { Dialog } from '../Dialog';
|
|
@@ -52,11 +46,16 @@ export const InsertImage = () => {
|
|
|
52
46
|
|
|
53
47
|
const handleOpenChange = (open: boolean) => {
|
|
54
48
|
setIsOpen(open);
|
|
49
|
+
if (!open) {
|
|
50
|
+
setValues(initialState);
|
|
51
|
+
}
|
|
55
52
|
};
|
|
56
53
|
|
|
57
54
|
const handleOpen = () => setIsOpen(true);
|
|
58
55
|
|
|
59
|
-
const handleClose = () =>
|
|
56
|
+
const handleClose = () => {
|
|
57
|
+
handleOpenChange(false);
|
|
58
|
+
};
|
|
60
59
|
|
|
61
60
|
const processErrors = validationErrors => {
|
|
62
61
|
const newErrors = validationErrors.inner.reduce(
|
|
@@ -69,8 +68,8 @@ export const InsertImage = () => {
|
|
|
69
68
|
setErrors(newErrors);
|
|
70
69
|
};
|
|
71
70
|
|
|
72
|
-
const handleChange =
|
|
73
|
-
const { name } = event.target;
|
|
71
|
+
const handleChange = event => {
|
|
72
|
+
const { name, value } = event.target;
|
|
74
73
|
const newValues = { ...values, [name]: value };
|
|
75
74
|
validationSchema.validateAt(name, newValues, { abortEarly: false }).then(() => {
|
|
76
75
|
setErrors({ ...errors, [name]: undefined });
|
|
@@ -101,22 +100,18 @@ export const InsertImage = () => {
|
|
|
101
100
|
<DialogTitle>Insert Image</DialogTitle>
|
|
102
101
|
<DialogContent>
|
|
103
102
|
<div className={styles.fullWidth}>
|
|
104
|
-
<FormField
|
|
105
|
-
|
|
106
|
-
validationStatus={errors?.url ? 'error' : undefined}
|
|
107
|
-
helperText={errors?.url}
|
|
108
|
-
>
|
|
103
|
+
<FormField validationStatus={errors?.url ? 'error' : undefined}>
|
|
104
|
+
<FormFieldLabel>Url for image</FormFieldLabel>
|
|
109
105
|
<Input value={values?.url} inputProps={{ name: 'url' }} onChange={handleChange} />
|
|
106
|
+
<FormFieldHelperText>{errors?.url}</FormFieldHelperText>
|
|
110
107
|
</FormField>
|
|
111
|
-
<FormField
|
|
112
|
-
|
|
113
|
-
validationStatus={errors?.alt ? 'error' : undefined}
|
|
114
|
-
helperText={
|
|
115
|
-
errors?.alt ||
|
|
116
|
-
'Provides alternative information for the image if for some reason it cannot be viewed'
|
|
117
|
-
}
|
|
118
|
-
>
|
|
108
|
+
<FormField validationStatus={errors?.alt ? 'error' : undefined}>
|
|
109
|
+
<FormFieldLabel>Alternative Information (alt)</FormFieldLabel>
|
|
119
110
|
<Input value={values?.alt} inputProps={{ name: 'alt' }} onChange={handleChange} />
|
|
111
|
+
<FormFieldHelperText>
|
|
112
|
+
{errors?.alt ||
|
|
113
|
+
'Provides alternative information for the image if for some reason it cannot be viewed'}
|
|
114
|
+
</FormFieldHelperText>
|
|
120
115
|
</FormField>
|
|
121
116
|
</div>
|
|
122
117
|
</DialogContent>
|
|
@@ -2,14 +2,8 @@ import React, { useEffect, useState } from 'react';
|
|
|
2
2
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
3
|
import { Button, Icon } from '@jpmorganchase/mosaic-components';
|
|
4
4
|
import { string, object } from 'yup';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
Input,
|
|
8
|
-
ButtonBar,
|
|
9
|
-
DialogTitle,
|
|
10
|
-
DialogContent,
|
|
11
|
-
DialogActions
|
|
12
|
-
} from '@salt-ds/lab';
|
|
5
|
+
import { Input, FormField, FormFieldLabel, FormFieldHelperText } from '@salt-ds/core';
|
|
6
|
+
import { ButtonBar, DialogTitle, DialogContent, DialogActions } from '@salt-ds/lab';
|
|
13
7
|
import { $getSelection, $isRangeSelection } from 'lexical';
|
|
14
8
|
|
|
15
9
|
import { ToolbarButton } from './ToolbarButton';
|
|
@@ -20,7 +14,7 @@ import styles from './InsertLink.css';
|
|
|
20
14
|
|
|
21
15
|
const validationSchema = object({
|
|
22
16
|
url: string().required('Url is required'),
|
|
23
|
-
text: string().required('Text is required').max(
|
|
17
|
+
text: string().required('Text is required').max(100, 'Text must be fewer than 100 characters')
|
|
24
18
|
});
|
|
25
19
|
|
|
26
20
|
export const InsertLinkButton = () => {
|
|
@@ -37,7 +31,8 @@ export const InsertLinkButton = () => {
|
|
|
37
31
|
};
|
|
38
32
|
|
|
39
33
|
const initialState = {
|
|
40
|
-
url: 'https://'
|
|
34
|
+
url: 'https://',
|
|
35
|
+
text: ''
|
|
41
36
|
};
|
|
42
37
|
|
|
43
38
|
type FormValueState =
|
|
@@ -78,7 +73,7 @@ export const InsertLinkDialog = () => {
|
|
|
78
73
|
const selection = $getSelection();
|
|
79
74
|
if ($isRangeSelection(selection)) {
|
|
80
75
|
const textContent = selection.getTextContent();
|
|
81
|
-
setValues(
|
|
76
|
+
setValues(prevState => ({ ...prevState, text: textContent }));
|
|
82
77
|
}
|
|
83
78
|
}
|
|
84
79
|
});
|
|
@@ -95,8 +90,8 @@ export const InsertLinkDialog = () => {
|
|
|
95
90
|
setErrors(newErrors);
|
|
96
91
|
};
|
|
97
92
|
|
|
98
|
-
const handleChange =
|
|
99
|
-
const { name } = event.target;
|
|
93
|
+
const handleChange = event => {
|
|
94
|
+
const { name, value } = event.target;
|
|
100
95
|
const newValues = { ...values, [name]: value };
|
|
101
96
|
validationSchema.validateAt(name, newValues, { abortEarly: false }).then(() => {
|
|
102
97
|
setErrors({ ...errors, [name]: undefined });
|
|
@@ -104,8 +99,7 @@ export const InsertLinkDialog = () => {
|
|
|
104
99
|
setValues(newValues);
|
|
105
100
|
};
|
|
106
101
|
|
|
107
|
-
const handleSubmit = async
|
|
108
|
-
event.preventDefault();
|
|
102
|
+
const handleSubmit = async () => {
|
|
109
103
|
validationSchema.validate(values, { abortEarly: false }).then(() => {
|
|
110
104
|
const payload: InsertLinkPayload = {
|
|
111
105
|
url: values?.url,
|
|
@@ -118,35 +112,29 @@ export const InsertLinkDialog = () => {
|
|
|
118
112
|
|
|
119
113
|
return (
|
|
120
114
|
<Dialog onOpenChange={handleOpenChange} open={isInsertingLink}>
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
<
|
|
124
|
-
<
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
<Button variant="cta" type="submit">
|
|
145
|
-
Insert
|
|
146
|
-
</Button>
|
|
147
|
-
</ButtonBar>
|
|
148
|
-
</DialogActions>
|
|
149
|
-
</form>
|
|
115
|
+
<DialogTitle>Insert Link</DialogTitle>
|
|
116
|
+
<DialogContent>
|
|
117
|
+
<div className={styles.fullWidth}>
|
|
118
|
+
<FormField validationStatus={errors?.url ? 'error' : undefined}>
|
|
119
|
+
<FormFieldLabel>Image URL text</FormFieldLabel>
|
|
120
|
+
<Input value={values?.url} inputProps={{ name: 'url' }} onChange={handleChange} />
|
|
121
|
+
<FormFieldHelperText>{errors?.url}</FormFieldHelperText>
|
|
122
|
+
</FormField>
|
|
123
|
+
<FormField validationStatus={errors?.text ? 'error' : undefined}>
|
|
124
|
+
<FormFieldLabel>Link Text</FormFieldLabel>
|
|
125
|
+
<Input value={values?.text} inputProps={{ name: 'text' }} onChange={handleChange} />
|
|
126
|
+
<FormFieldHelperText>{errors?.text}</FormFieldHelperText>
|
|
127
|
+
</FormField>
|
|
128
|
+
</div>
|
|
129
|
+
</DialogContent>
|
|
130
|
+
<DialogActions>
|
|
131
|
+
<ButtonBar>
|
|
132
|
+
<Button onClick={handleClose}>Cancel</Button>
|
|
133
|
+
<Button variant="cta" onClick={handleSubmit}>
|
|
134
|
+
Insert
|
|
135
|
+
</Button>
|
|
136
|
+
</ButtonBar>
|
|
137
|
+
</DialogActions>
|
|
150
138
|
</Dialog>
|
|
151
139
|
);
|
|
152
140
|
};
|
package/dist/chunk-23CWTC65.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as h}from"./chunk-IVMPDIDZ.js";import{a as k}from"./chunk-TVGVMAJS.js";import{a as f}from"./chunk-UWF3FV3R.js";import{a as T}from"./chunk-QHE4U3WR.js";import{a}from"./chunk-M4ISRNFD.js";import{b as w}from"./chunk-YBFKG74H.js";import{a as L}from"./chunk-ROQUYURQ.js";import{a as y}from"./chunk-3FJGHVH5.js";import{a as x}from"./chunk-QKOQTH4L.js";import{a as P}from"./chunk-RO6ARCLZ.js";import{a as M}from"./chunk-FDQTXNTN.js";import{b as S,d as E}from"./chunk-V6H2L7PK.js";import{a as C,d as v,f as l}from"./chunk-G57W376H.js";import{a as b}from"./chunk-FKL4ZGDB.js";import{a as g}from"./chunk-PXUVNH4P.js";import{a as n}from"./chunk-NXV7KCC5.js";import oo from"react";import{$convertToMarkdownString as ro}from"@lexical/markdown";import{OnChangePlugin as to}from"@lexical/react/LexicalOnChangePlugin";import eo from"lodash/debounce";import o,{useRef as B,useState as H}from"react";import I from"clsx";import j from"gray-matter";import{LexicalComposer as A}from"@lexical/react/LexicalComposer";import{ListPlugin as J}from"@lexical/react/LexicalListPlugin";import{TablePlugin as W}from"@lexical/react/LexicalTablePlugin";import{LinkPlugin as X}from"@lexical/react/LexicalLinkPlugin";import{HistoryPlugin as q}from"@lexical/react/LexicalHistoryPlugin";import{MarkdownShortcutPlugin as G}from"@lexical/react/LexicalMarkdownShortcutPlugin";import K from"react-split";import{$convertFromMarkdownString as Q}from"@lexical/markdown";function V(r){console.error(r)}var Y={namespace:"mosaic-content-editor",onError:V,nodes:P,theme:y},Z=()=>{let r=document.createElement("div");return r.className=n.gutter,r},_=({components:r,content:e,persistUrl:m,PreviewComponent:i,previewUrl:s,source:p,user:t})=>{let N=C()||p,{setUser:U}=v(),[u,c]=H(!1),z=B(null),{data:d,content:$}=j(e),D=()=>{c(!0),U(t)},O=()=>{c(!1)};return o.createElement(A,{initialConfig:{...Y,editorState:()=>Q($,a)}},o.createElement("div",{className:n.root,onFocus:D,onBlur:O},o.createElement("div",{className:n.toolbarContainer},o.createElement(h,null),o.createElement(k,{meta:d,persistUrl:m}),o.createElement(x,null)),o.createElement("div",{className:n.editorRoot},o.createElement(K,{className:n.splitter,cursor:"col-resize",direction:"horizontal",dragInterval:1,expandToMin:!1,gutter:Z,gutterAlign:"center",minSize:100,sizes:[50,50],snapOffset:30},o.createElement(f,{className:I({[n.focused]:u,[n.unfocused]:!u}),ref:z},o.createElement(g,null)),o.createElement(f,null,i&&o.createElement(i,{source:N,meta:d,components:r}))),o.createElement(q,null),o.createElement(J,null),o.createElement(W,null),o.createElement(X,null),o.createElement(G,{transformers:a}),s?o.createElement(F,{previewUrl:s}):null,o.createElement(w,null),o.createElement(S,null),o.createElement(T,null),o.createElement(b,null),o.createElement(M,null),o.createElement(L,null),o.createElement(E,null))))},R=_;async function no(r,e){return await(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"markdown",text:e})})).json()}function io(r){let e=eo(r,250,{maxWait:500});return{onChange:i=>{i.read(()=>{let s=ro(a);s&&e(s)})}}}var F=({previewUrl:r})=>{let{setErrorMessage:e,setPreviewContent:m}=l(),i=async p=>{try{if(p){let t=await no(r,p);!t.error&&t?.source?m(t.source):e(`${t.error?.toUpperCase()}: ${t?.exception}`)}}catch(t){t instanceof Error&&e(`MDX Error: ${t.message}`)}},{onChange:s}=io(i);return oo.createElement(to,{onChange:s,ignoreSelectionChange:!0})};export{F as a,R as b};
|
package/dist/chunk-E2MDU6JD.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as v}from"./chunk-KZXCNQER.js";import{a as c}from"./chunk-YBFKG74H.js";import{a as g}from"./chunk-3QIETKQW.js";import{a as h}from"./chunk-XSZUCLBY.js";import e,{useState as s}from"react";import{useLexicalComposerContext as O}from"@lexical/react/LexicalComposerContext";import{Button as I,Icon as T}from"@jpmorganchase/mosaic-components";import{string as b,object as x}from"yup";import{ButtonBar as M,DialogTitle as P,DialogContent as V,DialogActions as q,FormField as C,Input as S}from"@salt-ds/lab";var D=x({alt:b().required("Alternative Information is a required field").max(100,"Alternative Information must be fewer than 100 characters"),url:b().required("Url is required").url("Must be a valid Url")}),w={url:"https://"},J=()=>{let[y]=O(),[u,i]=s(!1),[t,F]=s(w),[n,m]=s(),A=r=>{i(r)},B=()=>i(!0),d=()=>i(!1),f=r=>{let o=r.inner.reduce((a,{path:l,message:E})=>({...a,[l]:E}),{});m(o)},p=(r,o)=>{let{name:a}=r.target,l={...t,[a]:o};D.validateAt(a,l,{abortEarly:!1}).then(()=>{m({...n,[a]:void 0})},f),F(l)};return e.createElement(e.Fragment,null,e.createElement(g,{active:u,onClick:B,label:"Insert Image"},e.createElement(T,{name:"addDocument"})),e.createElement(h,{onOpenChange:A,open:u},e.createElement("form",{onSubmit:async r=>{r.preventDefault(),D.validate(t,{abortEarly:!1}).then(()=>{let o={alt:t&&t.alt!==void 0?t.alt:null,url:t&&t.url!==void 0?t.url:null};y.dispatchCommand(c,o),d()},f)},noValidate:!0},e.createElement(P,null,"Insert Image"),e.createElement(V,null,e.createElement("div",{className:v.fullWidth},e.createElement(C,{label:"Url for image",validationStatus:n?.url?"error":void 0,helperText:n?.url},e.createElement(S,{value:t?.url,inputProps:{name:"url"},onChange:p})),e.createElement(C,{label:"Alternative Information (alt)",validationStatus:n?.alt?"error":void 0,helperText:n?.alt||"Provides alternative information for the image if for some reason it cannot be viewed"},e.createElement(S,{value:t?.alt,inputProps:{name:"alt"},onChange:p})))),e.createElement(q,null,e.createElement(M,null,e.createElement(I,{onClick:d},"Cancel"),e.createElement(I,{variant:"cta",type:"submit"},"Insert"))))))};export{J as a};
|
package/dist/chunk-V6H2L7PK.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as C}from"./chunk-WZYDYWT3.js";import{a as L}from"./chunk-3QIETKQW.js";import{e as f}from"./chunk-G57W376H.js";import{a as k}from"./chunk-XSZUCLBY.js";import{$createLinkNode as V,TOGGLE_LINK_COMMAND as q}from"@lexical/link";import{useLexicalComposerContext as W}from"@lexical/react/LexicalComposerContext";import{$wrapNodes as G}from"@lexical/selection";import{$createParagraphNode as U,$createTextNode as j,$getSelection as Y,$isRangeSelection as z,$isTextNode as H,COMMAND_PRIORITY_EDITOR as J,createCommand as Q}from"lexical";import X,{useCallback as Z,useEffect as R}from"react";import t,{useEffect as F,useState as h}from"react";import{useLexicalComposerContext as M}from"@lexical/react/LexicalComposerContext";import{Button as N,Icon as P}from"@jpmorganchase/mosaic-components";import{string as S,object as O}from"yup";import{FormField as D,Input as T,ButtonBar as B,DialogTitle as _,DialogContent as A,DialogActions as $}from"@salt-ds/lab";import{$getSelection as w,$isRangeSelection as K}from"lexical";var b=O({url:S().required("Url is required"),text:S().required("Text is required").max(10,"Text must be fewer than 100 characters")}),pt=()=>{let{isInsertingLink:e,setIsInsertingLink:r}=f();return t.createElement(L,{active:e,onClick:()=>r(!0),label:"Insert Link"},t.createElement(P,{name:"linked"}))},y={url:"https://"},E=()=>{let[e]=M(),{isInsertingLink:r,setIsInsertingLink:a}=f(),[o,i]=h(y),[s,m]=h(),u=n=>{a(n),n||(m(void 0),i(y))},g=()=>{u(!1)};F(()=>{e.getEditorState().read(()=>{if(r){let n=w();if(K(n)){let l=n.getTextContent();i(d=>({...d,text:l}))}}})},[e,r]);let x=n=>{let l=n.inner.reduce((d,{path:c,message:v})=>({...d,[c]:v}),{});m(l)},I=(n,l)=>{let{name:d}=n.target,c={...o,[d]:l};b.validateAt(d,c,{abortEarly:!1}).then(()=>{m({...s,[d]:void 0})},x),i(c)};return t.createElement(k,{onOpenChange:u,open:r},t.createElement("form",{onSubmit:async n=>{n.preventDefault(),b.validate(o,{abortEarly:!1}).then(()=>{let l={url:o?.url,text:o?.text};e.dispatchCommand(p,l),g()},x)},noValidate:!0},t.createElement(_,null,"Insert Link"),t.createElement(A,null,t.createElement("div",{className:C.fullWidth},t.createElement(D,{label:"Image URL text",validationStatus:s?.url?"error":void 0,helperText:s?.url},t.createElement(T,{value:o?.url,inputProps:{name:"url"},onChange:I})),t.createElement(D,{label:"Link text",validationStatus:s?.text?"error":void 0,helperText:s?.text},t.createElement(T,{value:o?.text,inputProps:{name:"text"},onChange:I})))),t.createElement($,null,t.createElement(B,null,t.createElement(N,{onClick:g},"Cancel"),t.createElement(N,{variant:"cta",type:"submit"},"Insert")))))};var p=Q();function tt(){let[e]=W(),r=Z(({url:a,text:o})=>{e.update(()=>{let i=Y();if(z(i)&&a!==void 0&&o!==void 0){let s=i.focus.getNode();if(H(s))e.dispatchCommand(q,a);else{let m=V(a),u=j(o);u.setFormat(i.focus.getNode().getFormat()),m.append(u),G(i,()=>m,U())}}})},[e]);R(()=>e.registerCommand(p,a=>(r(a),!0),J),[e,r])}function St(){return tt(),X.createElement(E,null)}export{p as a,St as b,pt as c,E as d};
|