@jpmorganchase/mosaic-content-editor-plugin 0.1.0-beta.31 → 0.1.0-beta.33
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 +1 -1
- package/CHANGELOG.md +16 -0
- package/dist/{chunk-QVDPLRWG.js → chunk-5G53ILEQ.js} +1 -1
- package/dist/{chunk-XL3KLIV3.js → chunk-B3MUPQQA.js} +1 -1
- package/dist/chunk-DK6F4XAE.js +1 -0
- package/dist/chunk-HYOY3SMH.js +1 -0
- package/dist/chunk-KD66I56W.js +1 -0
- package/dist/chunk-R6U5TOP4.js +1 -0
- package/dist/chunk-SI5CM3F4.js +1 -0
- package/dist/components/Editor.js +1 -1
- package/dist/components/LinkEditor/LinkEditor.js +1 -1
- package/dist/components/Toolbar/InsertTable.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/PreviewPlugin.js +1 -1
- package/dist/plugins/TableActionMenuPlugin.js +1 -1
- package/package.json +7 -7
- package/src/components/LinkEditor/LinkEditor.tsx +3 -2
- package/src/components/Toolbar/InsertTable.tsx +2 -2
- package/src/plugins/FloatingToolbarPlugin.tsx +3 -3
- package/src/plugins/TableActionMenuPlugin.tsx +2 -2
- package/dist/chunk-ENTOKO6G.js +0 -1
- package/dist/chunk-HN5XYH53.js +0 -1
- package/dist/chunk-HSZQ3ZK6.js +0 -1
- package/dist/chunk-WNREGBHC.js +0 -1
- package/dist/chunk-ZUOQD3SL.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 14171e7d8b36186d
|
|
2
2
|
@jpmorganchase/mosaic-content-editor-plugin:build: $ npm-run-all --parallel build:*
|
|
3
3
|
@jpmorganchase/mosaic-content-editor-plugin:build: $ node ../../scripts/bundle.js
|
|
4
4
|
@jpmorganchase/mosaic-content-editor-plugin:build: $ tsc
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @jpmorganchase/mosaic-content-editor-plugin
|
|
2
2
|
|
|
3
|
+
## 0.1.0-beta.33
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @jpmorganchase/mosaic-components@0.1.0-beta.33
|
|
8
|
+
- @jpmorganchase/mosaic-theme@0.1.0-beta.33
|
|
9
|
+
|
|
10
|
+
## 0.1.0-beta.32
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 6265b19: Upgrade to latest Salt libraries
|
|
15
|
+
- Updated dependencies [6265b19]
|
|
16
|
+
- @jpmorganchase/mosaic-components@0.1.0-beta.32
|
|
17
|
+
- @jpmorganchase/mosaic-theme@0.1.0-beta.32
|
|
18
|
+
|
|
3
19
|
## 0.1.0-beta.31
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as h}from"./chunk-
|
|
1
|
+
import{a as h}from"./chunk-B3MUPQQA.js";import{a as k}from"./chunk-6TWGPQT5.js";import{a as f}from"./chunk-UWF3FV3R.js";import{a as b}from"./chunk-DK6F4XAE.js";import{a as T}from"./chunk-KD66I56W.js";import{a as y}from"./chunk-3FJGHVH5.js";import{a as s}from"./chunk-XGBC7YGO.js";import{a as M}from"./chunk-YQHKK2ZS.js";import{a as P}from"./chunk-RO6ARCLZ.js";import{a as F}from"./chunk-SI5CM3F4.js";import{a as x}from"./chunk-FKL4ZGDB.js";import{b as w}from"./chunk-YBFKG74H.js";import{b as E,d as S}from"./chunk-JJ5K5LVL.js";import{a as g}from"./chunk-WCG3U3X2.js";import{a as t}from"./chunk-NXV7KCC5.js";import{a as C,d as v,f as p}from"./chunk-G57W376H.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 I,useState as $}from"react";import A from"clsx";import O from"gray-matter";import{LexicalComposer as U}from"@lexical/react/LexicalComposer";import{ListPlugin as X}from"@lexical/react/LexicalListPlugin";import{TablePlugin as W}from"@lexical/react/LexicalTablePlugin";import{LinkPlugin as j}from"@lexical/react/LexicalLinkPlugin";import{HistoryPlugin as q}from"@lexical/react/LexicalHistoryPlugin";import{MarkdownShortcutPlugin as G}from"@lexical/react/LexicalMarkdownShortcutPlugin";import J 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:y},Y=()=>{let r=document.createElement("div");return r.className=t.gutter,r},Z=({compileMDX:r,content:m,source:a,PreviewComponent:e,user:n,components:l})=>{let i=C()||a,{setUser:N}=v(),[u,d]=$(!1),z=I(null),{data:c,content:D}=O(m),B=()=>{d(!0),N(n)},H=()=>{d(!1)};return o.createElement(U,{initialConfig:{...V,editorState:()=>K(D,s)}},o.createElement("div",{className:t.root,onFocus:B,onBlur:H},o.createElement("div",{className:t.toolbarContainer},o.createElement(h,null),o.createElement(k,{meta:c}),o.createElement(M,null)),o.createElement("div",{className:t.editorRoot},o.createElement(J,{className:t.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:A({[t.focused]:u,[t.unfocused]:!u}),ref:z},o.createElement(g,null)),o.createElement(f,null,e&&o.createElement(e,{source:i,meta:c,components:l}))),o.createElement(q,null),o.createElement(X,null),o.createElement(W,null),o.createElement(j,null),o.createElement(G,{transformers:s}),r&&o.createElement(L,{compileMDX:r}),o.createElement(w,null),o.createElement(E,null),o.createElement(b,null),o.createElement(x,null),o.createElement(F,null),o.createElement(T,null),o.createElement(S,null))))},_=Z;function eo(r){let m=to(r,250,{maxWait:500});return{onChange:e=>{e.read(()=>{let n=oo(s);n&&m(n)})}}}var L=({compileMDX:r})=>{let{setErrorMessage:m,setPreviewContent:a}=p(),e=async l=>{try{let i=await r(l,!1);a(i)}catch(i){i instanceof Error&&m(`MDX Error: ${i.message}`)}},{onChange:n}=eo(e);return R.createElement(ro,{onChange:n,ignoreSelectionChange:!0})};export{L as a,_ as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"./chunk-ZUGL4RMA.js";import{a as d}from"./chunk-L5I3DIHV.js";import{a as m}from"./chunk-
|
|
1
|
+
import{a as s}from"./chunk-ZUGL4RMA.js";import{a as d}from"./chunk-L5I3DIHV.js";import{a as m}from"./chunk-HYOY3SMH.js";import{a as i}from"./chunk-FW7CHFWO.js";import{a as e}from"./chunk-4CRC7NS5.js";import{c as b}from"./chunk-JJ5K5LVL.js";import{a as n}from"./chunk-PC66Q33O.js";import{c as a}from"./chunk-G57W376H.js";import o from"react";import{Toolbar as g,ToolbarButton as t,Tooltray as r}from"@salt-ds/lab";import{Icon as l}from"@jpmorganchase/mosaic-components";var I=()=>{let{canRedo:p,canUndo:T,redoEdit:y,undoEdit:f}=i(),{setPageState:u}=a();return o.createElement(g,{"aria-label":"page editing toolbar",style:{minWidth:"100px"}},o.createElement(r,{"aria-label":"history tooltray"},o.createElement(t,{label:"Undo",disabled:!T,onClick:f},o.createElement(l,{name:"undo"})),o.createElement(t,{label:"Redo",disabled:!p,onClick:y},o.createElement(l,{name:"redo"}))),o.createElement(e,null),o.createElement(r,{"aria-label":"text format tooltray"},o.createElement(b,null),o.createElement(m,null),o.createElement(d,null),o.createElement(s,null)),o.createElement(r,{"aria-label":"stop editing tooltray",alignEnd:!0},o.createElement(t,{label:"Cancel Editing",onClick:()=>u("VIEW")},o.createElement(l,{name:"delete"}))),o.createElement(r,{"aria-label":"copy tooltray","data-pad-start":!0},o.createElement(n,null)))},v=I;export{v as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as C}from"./chunk-G4LBXKDE.js";import{a as S}from"./chunk-HB6ONQSD.js";import{a as L}from"./chunk-5YCBSSDA.js";import{a as y}from"./chunk-MJUOPD42.js";import{c as g,d}from"./chunk-R6U5TOP4.js";import{a as E}from"./chunk-VO6JTL4J.js";import{mergeRegister as x}from"@lexical/utils";import{$getSelection as P,$isRangeSelection as v,COMMAND_PRIORITY_LOW as T,SELECTION_CHANGE_COMMAND as B}from"lexical";import l,{useCallback as G,useEffect as k,useRef as $,useState as f}from"react";import{$isLinkNode as I,TOGGLE_LINK_COMMAND as b}from"@lexical/link";import{useLexicalComposerContext as F}from"@lexical/react/LexicalComposerContext";import{useFloatingUI as H}from"@salt-ds/core";import{Input as w}from"@salt-ds/lab";function re(){let[t]=F(),N=$(null),[o,r]=f(""),[h,i]=f(!1),[O,a]=f(null),c=()=>{r(""),i(!1),a(null)},{context:D,floating:M,reference:m,strategy:R,x:A,y:K}=H({placement:"right",strategy:"absolute",open:o.length>0,onOpenChange:c}),{getFloatingProps:U}=d([g(D,{ancestorScroll:!0})]),n=G(()=>{let e=P();if(v(e)){let s=C(e),p=s.getParent();I(p)?(m(t.getElementByKey(p.getKey())),r(p.getURL()),a(e)):I(s)?(m(t.getElementByKey(s.getKey())),r(s.getURL()),a(e)):c()}return i(!1),!0},[t,m]);k(()=>x(t.registerUpdateListener(({editorState:e})=>{e.read(()=>{n()})}),t.registerCommand(B,()=>(n(),!0),T)),[t,n]),k(()=>{t.getEditorState().read(()=>{n()})},[t,n]);let u=()=>{O!==null&&o!==""&&(t.dispatchCommand(b,o),i(!1))},_=()=>i(!0);return l.createElement(E,{className:L.popper,ref:M,open:o.length>0,style:{top:K??"",left:A??"",position:R},...U({})},h?l.createElement(w,{endAdornment:l.createElement(y,{onSave:u}),ref:N,value:o,onChange:e=>{r(e.target.value)},onKeyDown:e=>{e.key==="Enter"?(e.preventDefault(),u()):e.key==="Escape"&&e.preventDefault()}}):l.createElement(S,{onClick:_}))}export{re as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o}from"./chunk-GWUYDDYS.js";import{c as N,d as M}from"./chunk-R6U5TOP4.js";import{a as F}from"./chunk-VO6JTL4J.js";import{a as E}from"./chunk-PMMRU33I.js";import e,{useRef as P,useState as y}from"react";import{Icon as H}from"@jpmorganchase/mosaic-components";import{useLexicalComposerContext as W}from"@lexical/react/LexicalComposerContext";import{INSERT_TABLE_COMMAND as j}from"@lexical/table";import{useFloatingUI as q}from"@salt-ds/core";var G=({index:n,...r})=>e.createElement("td",{className:o.cell,"data-column":n,...r}),J=({children:n,index:r})=>e.createElement("tr",{className:r===1?o.headerRow:o.row,"data-row":r},n),K=({rowCount:n,columnCount:r})=>{let a=[],s=[];for(let t=1;t<=r;t++)a.push(e.createElement(G,{key:t,index:t}));for(let t=1;t<=n;t++)s.push(e.createElement(J,{key:t,index:t},a));return e.createElement("tbody",null,s)};function Q(n){let r=parseInt(n?.dataset?.column||"0",10),a=n.parentNode,s=parseInt(a?.dataset?.row||"0",10);return{columnIndex:r,rowIndex:s}}var ie=({minRows:n=2,minColumns:r=2,maxColumns:a=10,initialRowCount:s=4,initialColumnCount:t=4})=>{let[O]=W(),g=P(null),c=P(!1),[m,d]=y(t),[i,p]=y(s),[f,h]=y(!1),v=()=>{x(),h(l=>!l)},{context:L,floating:S,reference:B,strategy:k,x:A,y:D}=q({placement:"bottom",strategy:"absolute",open:f,onOpenChange:v}),{getFloatingProps:_}=M([N(L,{ancestorScroll:!0})]),$=l=>{let I=l.nativeEvent.target;if(!g.current?.contains(I)||!c.current)return;let{columnIndex:w,rowIndex:T}=Q(I);w<m&&w>=r&&d(w),T<i&&T>=n&&p(T)};function x(){d(t),p(s),c.current=!1}let z=()=>{c.current=!0,m+1<=a&&d(l=>l+1)},R=()=>{c.current=!0,p(l=>l+1)},U=()=>{O.dispatchCommand(j,{columns:m.toString(),rows:i.toString()}),x(),h(!1)},u=25,b=i*u,C=m*u;return e.createElement(e.Fragment,null,e.createElement(E,{ref:B,onClick:v,active:f},e.createElement(H,{name:"grid"}),e.createElement("div",{className:o.spacer}),e.createElement(H,{name:"chevronDown"})),e.createElement(F,{className:o.popper,ref:S,open:f,style:{top:D??"",left:A??"",position:k},..._({})},e.createElement("div",{className:o.tableContainer,onMouseOver:$,onClick:U},e.createElement("table",{className:o.table,style:{width:C,height:b},ref:g},e.createElement(K,{rowCount:i,columnCount:m})),e.createElement("div",{className:o.dimensions},`${m} x ${i}`),e.createElement("div",{className:o.addColumnArea,style:{left:C,height:b+u},onMouseOver:z}),e.createElement("div",{className:o.addRowArea,style:{top:b,width:C+u},onMouseOver:R}))))};export{ie as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as M}from"./chunk-ESKW4XF6.js";import{a as T}from"./chunk-6YPAVQF4.js";import{c as S,d as L}from"./chunk-R6U5TOP4.js";import{a as D}from"./chunk-VO6JTL4J.js";import A,{useCallback as i,useEffect as h,useState as E}from"react";import{useLexicalComposerContext as N}from"@lexical/react/LexicalComposerContext";import{$getSelection as B,$isRangeSelection as O}from"lexical";import{$deleteTableColumn as U,$getElementGridForTableNode as $,$getTableCellNodeFromLexicalNode as k,$getTableColumnIndexFromTableCellNode as y,$getTableNodeFromLexicalNodeOrThrow as u,$getTableRowIndexFromTableCellNode as F,$insertTableColumn as K,$insertTableRow as G,$isTableCellNode as a,$removeTableRowAtIndex as H}from"@lexical/table";import{useFloatingUI as j}from"@salt-ds/core";import{ArrowDownIcon as q,ArrowLeftIcon as z,ArrowRightIcon as J,ArrowUpIcon as Q,DeleteIcon as v,DeleteSolidIcon as V}from"@salt-ds/icons";var W={menuItems:[{title:"Insert Row Above",icon:Q},{title:"Insert Row Below",icon:q},{title:"Insert Column Left",icon:z},{title:"Insert Column Right",icon:J},{title:"Delete Row",icon:v},{title:"Delete Column",icon:v},{title:"Delete Table",icon:V}]};function X({editor:t,tableCellNode:e,onComplete:o}){let s=n=>{if(!!n){if(n.title==="Delete Row"){f();return}if(n.title==="Insert Row Below"){m(!0);return}if(n.title==="Insert Row Above"){m(!1);return}if(n.title==="Insert Column Left"){d(!1);return}if(n.title==="Insert Column Right"){d(!0);return}if(n.title==="Delete Column"){p();return}n.title==="Delete Table"&&I()}},f=i(()=>{t.update(()=>{if(a(e)){let n=u(e),l=F(e);H(n,l),o()}})},[t,o,e]),m=i(n=>{t.update(()=>{if(a(e)){let l=u(e),c=F(e),r=$(t,l);G(l,c,n,1,r)}o()})},[t,e,o]),d=i(n=>{t.update(()=>{if(a(e)){let l=u(e),c=y(e),r=$(t,l);K(l,c,n,1,r)}o()})},[t,e,o]),p=i(()=>{t.update(()=>{if(a(e)){let n=u(e),l=y(e);U(n,l),o()}})},[t,e,o]),I=i(()=>{t.update(()=>{a(e)&&(u(e).remove(),o())})},[t,e,o]);return A.createElement(M,{initialSource:W,onItemClick:s})}function ae(){let[t]=N(),[e,o]=E(null),[s,f]=E(null),{context:m,floating:d,reference:p,strategy:I,x:n,y:l}=j({placement:"right",strategy:"absolute",open:e!==null,onOpenChange:()=>o(null)}),{getFloatingProps:c}=L([S(m,{ancestorScroll:!0})]),r=i(()=>{let g=B(),w=window.getSelection(),{activeElement:C}=document;if(g==null){o(null);return}let x=t.getRootElement();if(O(g)&&x!==null&&w!==null&&x.contains(w.anchorNode)){let R=k(g.anchor.getNode());if(R==null){o(null);return}let b=t.getElementByKey(R.getKey());if(b==null){o(null);return}b.classList.add(...T.focused),o(R),p(b),f(b)}else C||o(null)},[t,p]);h(()=>t.registerUpdateListener(()=>{t.getEditorState().read(()=>{r()})}),[t,r]),h(function(){return s?.classList.add(...T.focused),function(){s?.classList.remove(...T.focused)}},[s?.classList,e]);let P=()=>{f(null),o(null)};return A.createElement(D,{ref:d,open:e!==null,style:{top:l??"",left:n??"",position:I},...c({})},A.createElement(X,{editor:t,tableCellNode:e,onComplete:P}))}export{ae as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function ie(e){return e.split("-")[1]}function xe(e){return e==="y"?"height":"width"}function H(e){return e.split("-")[0]}function se(e){return["top","bottom"].includes(H(e))?"x":"y"}function ce(e){return typeof e!="number"?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(e):{top:e,right:e,bottom:e,left:e}}function V(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}async function _(e,t){var r;t===void 0&&(t={});let{x:n,y:i,platform:o,rects:u,elements:f,strategy:h}=e,{boundary:O="clippingAncestors",rootBoundary:C="viewport",elementContext:a="floating",altBoundary:I=!1,padding:m=0}=t,R=ce(m),E=f[I?a==="floating"?"reference":"floating":a],T=V(await o.getClippingRect({element:(r=await(o.isElement==null?void 0:o.isElement(E)))==null||r?E:E.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(f.floating)),boundary:O,rootBoundary:C,strategy:h})),P=a==="floating"?{...u.floating,x:n,y:i}:u.reference,d=await(o.getOffsetParent==null?void 0:o.getOffsetParent(f.floating)),p=await(o.isElement==null?void 0:o.isElement(d))&&await(o.getScale==null?void 0:o.getScale(d))||{x:1,y:1},w=V(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({rect:P,offsetParent:d,strategy:h}):P);return{top:(T.top-w.top+R.top)/p.y,bottom:(w.bottom-T.bottom+R.bottom)/p.y,left:(T.left-w.left+R.left)/p.x,right:(w.right-T.right+R.right)/p.x}}var z=Math.min,Y=Math.max;var Ee=["top","right","bottom","left"],Ge=Ee.reduce((e,t)=>e.concat(t,t+"-start",t+"-end"),[]),Te={left:"right",right:"left",bottom:"top",top:"bottom"};function W(e){return e.replace(/left|right|bottom|top/g,t=>Te[t])}function Pe(e,t,r){r===void 0&&(r=!1);let n=ie(e),i=se(e),o=xe(i),u=i==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(u=W(u)),{main:u,cross:W(u)}}var Ce={start:"end",end:"start"};function j(e){return e.replace(/start|end/g,t=>Ce[t])}var U=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r;let{placement:n,middlewareData:i,rects:o,initialPlacement:u,platform:f,elements:h}=t,{mainAxis:O=!0,crossAxis:C=!0,fallbackPlacements:a,fallbackStrategy:I="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:R=!0,...E}=e,T=H(n),P=H(u)===u,d=await(f.isRTL==null?void 0:f.isRTL(h.floating)),p=a||(P||!R?[W(u)]:function(c){let v=W(c);return[j(c),v,j(v)]}(u));a||m==="none"||p.push(...function(c,v,s,y){let x=ie(c),b=function(M,F,te){let ne=["left","right"],re=["right","left"],be=["top","bottom"],we=["bottom","top"];switch(M){case"top":case"bottom":return te?F?re:ne:F?ne:re;case"left":case"right":return F?be:we;default:return[]}}(H(c),s==="start",y);return x&&(b=b.map(M=>M+"-"+x),v&&(b=b.concat(b.map(j)))),b}(u,R,m,d));let w=[u,...p],g=await _(t,E),L=[],A=((r=i.flip)==null?void 0:r.overflows)||[];if(O&&L.push(g[T]),C){let{main:c,cross:v}=Pe(n,o,d);L.push(g[c],g[v])}if(A=[...A,{placement:n,overflows:L}],!L.every(c=>c<=0)){var k,D;let c=(((k=i.flip)==null?void 0:k.index)||0)+1,v=w[c];if(v)return{data:{index:c,overflows:A},reset:{placement:v}};let s=(D=A.filter(y=>y.overflows[0]<=0).sort((y,x)=>y.overflows[1]-x.overflows[1])[0])==null?void 0:D.placement;if(!s)switch(I){case"bestFit":{var S;let y=(S=A.map(x=>[x.placement,x.overflows.filter(b=>b>0).reduce((b,M)=>b+M,0)]).sort((x,b)=>x[1]-b[1])[0])==null?void 0:S[0];y&&(s=y);break}case"initialPlacement":s=u}if(n!==s)return{reset:{placement:s}}}return{}}}};function oe(e){let t=z(...e.map(n=>n.left)),r=z(...e.map(n=>n.top));return{x:t,y:r,width:Y(...e.map(n=>n.right))-t,height:Y(...e.map(n=>n.bottom))-r}}var X=function(e){return e===void 0&&(e={}),{name:"inline",options:e,async fn(t){let{placement:r,elements:n,rects:i,platform:o,strategy:u}=t,{padding:f=2,x:h,y:O}=e,C=Array.from(await(o.getClientRects==null?void 0:o.getClientRects(n.reference))||[]),a=function(E){let T=E.slice().sort((p,w)=>p.y-w.y),P=[],d=null;for(let p=0;p<T.length;p++){let w=T[p];!d||w.y-d.y>d.height/2?P.push([w]):P[P.length-1].push(w),d=w}return P.map(p=>V(oe(p)))}(C),I=V(oe(C)),m=ce(f),R=await o.getElementRects({reference:{getBoundingClientRect:function(){if(a.length===2&&a[0].left>a[1].right&&h!=null&&O!=null)return a.find(E=>h>E.left-m.left&&h<E.right+m.right&&O>E.top-m.top&&O<E.bottom+m.bottom)||I;if(a.length>=2){if(se(r)==="x"){let g=a[0],L=a[a.length-1],A=H(r)==="top",k=g.top,D=L.bottom,S=A?g.left:L.left,c=A?g.right:L.right;return{top:k,bottom:D,left:S,right:c,width:c-S,height:D-k,x:S,y:k}}let E=H(r)==="left",T=Y(...a.map(g=>g.right)),P=z(...a.map(g=>g.left)),d=a.filter(g=>E?g.left===P:g.right===T),p=d[0].top,w=d[d.length-1].bottom;return{top:p,bottom:w,left:P,right:T,width:T-P,height:w-p,x:P,y:p}}return I}},floating:n.floating,strategy:u});return i.reference.x!==R.reference.x||i.reference.y!==R.reference.y||i.reference.width!==R.reference.width||i.reference.height!==R.reference.height?{reset:{rects:R}}:{}}}};function B(e){var t;return((t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Oe(e){return B(e).getComputedStyle(e)}function pe(e){return e instanceof B(e).Node}function ge(e){return pe(e)?(e.nodeName||"").toLowerCase():""}function Ie(e){return e instanceof B(e).HTMLElement}function le(e){return typeof ShadowRoot>"u"?!1:e instanceof B(e).ShadowRoot||e instanceof ShadowRoot}function he(e){let{overflow:t,overflowX:r,overflowY:n,display:i}=Oe(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&!["inline","contents"].includes(i)}function Me(e){return["html","body","#document"].includes(ge(e))}function Le(e){return((pe(e)?e.ownerDocument:e.document)||window.document).documentElement}function Ae(e){if(ge(e)==="html")return e;let t=e.assignedSlot||e.parentNode||le(e)&&e.host||Le(e);return le(t)?t.host:t}function Re(e){let t=Ae(e);return Me(t)?t.ownerDocument.body:Ie(t)&&he(t)?t:Re(t)}function N(e,t){var r;t===void 0&&(t=[]);let n=Re(e),i=n===((r=e.ownerDocument)==null?void 0:r.body),o=B(n);return i?t.concat(o,o.visualViewport||[],he(n)?n:[]):t.concat(n,N(n))}import*as K from"react";import{useLayoutEffect as nt,useEffect as rt}from"react";import*as ke from"react-dom";import*as l from"react";import{useLayoutEffect as at,useEffect as ft,useRef as dt}from"react";import{createPortal as pt,flushSync as gt}from"react-dom";var ht=l["useId".toString()];var Fe=l.createContext(null),Ne=l.createContext(null),He=()=>{var e;return((e=l.useContext(Fe))==null?void 0:e.id)||null},_e=()=>l.useContext(Ne);function ye(e){return e?.ownerDocument||document}function Be(){let e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform}function Ve(){let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:r,version:n}=t;return r+"/"+n}).join(" "):navigator.userAgent}function ee(e){return ye(e).defaultView||window}function q(e){return e?e instanceof ee(e).Element:!1}function We(e){return e?e instanceof ee(e).HTMLElement:!1}function Ke(e){if(e.mozInputSource===0&&e.isTrusted)return!0;let t=/Android/i;return(t.test(Be())||t.test(Ve()))&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function je(e){return e.width===0&&e.height===0||e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType!=="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0}function G(e,t){let r=e.filter(i=>{var o;return i.parentId===t&&((o=i.context)==null?void 0:o.open)}),n=r;for(;n.length;)n=e.filter(i=>{var o;return(o=n)==null?void 0:o.some(u=>{var f;return i.parentId===u.id&&((f=i.context)==null?void 0:f.open)})}),r=r.concat(n);return r}function ze(e){return"composedPath"in e?e.composedPath()[0]:e.target}var Ye=l["useInsertionEffect".toString()],Ue=Ye||(e=>e());function Z(e){let t=l.useRef(()=>{});return Ue(()=>{t.current=e}),l.useCallback(function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return t.current==null?void 0:t.current(...n)},[])}function Q(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);let r=e;return r.target!=null&&t.contains(r.target)}var Xe={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},$e={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},qe=e=>{var t,r;return{escapeKeyBubbles:typeof e=="boolean"?e:(t=e?.escapeKey)!=null?t:!1,outsidePressBubbles:typeof e=="boolean"?e:(r=e?.outsidePress)!=null?r:!0}},Rt=function(e,t){t===void 0&&(t={});let{open:r,onOpenChange:n,events:i,nodeId:o,elements:{reference:u,domReference:f,floating:h},dataRef:O}=e,{enabled:C=!0,escapeKey:a=!0,outsidePress:I=!0,outsidePressEvent:m="pointerdown",referencePress:R=!1,referencePressEvent:E="pointerdown",ancestorScroll:T=!1,bubbles:P}=t,d=_e(),p=He()!=null,w=Z(typeof I=="function"?I:()=>!1),g=typeof I=="function"?w:I,L=l.useRef(!1),{escapeKeyBubbles:A,outsidePressBubbles:k}=qe(P),D=Z(c=>{if(!r||!C||!a||c.key!=="Escape")return;let v=d?G(d.nodesRef.current,o):[];if(!A&&(c.stopPropagation(),v.length>0)){let s=!0;if(v.forEach(y=>{var x;if((x=y.context)!=null&&x.open&&!y.context.dataRef.current.__escapeKeyBubbles){s=!1;return}}),!s)return}i.emit("dismiss",{type:"escapeKey",data:{returnFocus:{preventScroll:!1}}}),n(!1)}),S=Z(c=>{let v=L.current;if(L.current=!1,v||typeof g=="function"&&!g(c))return;let s=ze(c);if(We(s)&&h){let b=s.clientWidth>0&&s.scrollWidth>s.clientWidth,M=s.clientHeight>0&&s.scrollHeight>s.clientHeight,F=M&&c.offsetX>s.clientWidth;if(M&&ee(h).getComputedStyle(s).direction==="rtl"&&(F=c.offsetX<=s.offsetWidth-s.clientWidth),F||b&&c.offsetY>s.clientHeight)return}let y=d&&G(d.nodesRef.current,o).some(b=>{var M;return Q(c,(M=b.context)==null?void 0:M.elements.floating)});if(Q(c,h)||Q(c,f)||y)return;let x=d?G(d.nodesRef.current,o):[];if(x.length>0){let b=!0;if(x.forEach(M=>{var F;if((F=M.context)!=null&&F.open&&!M.context.dataRef.current.__outsidePressBubbles){b=!1;return}}),!b)return}i.emit("dismiss",{type:"outsidePress",data:{returnFocus:p?{preventScroll:!0}:Ke(c)||je(c)}}),n(!1)});return l.useEffect(()=>{if(!r||!C)return;O.current.__escapeKeyBubbles=A,O.current.__outsidePressBubbles=k;function c(){n(!1)}let v=ye(h);a&&v.addEventListener("keydown",D),g&&v.addEventListener(m,S);let s=[];return T&&(q(f)&&(s=N(f)),q(h)&&(s=s.concat(N(h))),!q(u)&&u&&u.contextElement&&(s=s.concat(N(u.contextElement)))),s=s.filter(y=>{var x;return y!==((x=v.defaultView)==null?void 0:x.visualViewport)}),s.forEach(y=>{y.addEventListener("scroll",c,{passive:!0})}),()=>{a&&v.removeEventListener("keydown",D),g&&v.removeEventListener(m,S),s.forEach(y=>{y.removeEventListener("scroll",c)})}},[O,h,f,u,a,g,m,r,n,T,C,A,k,D,S]),l.useEffect(()=>{L.current=!1},[g,m]),l.useMemo(()=>C?{reference:{onKeyDown:D,[Xe[E]]:()=>{R&&(i.emit("dismiss",{type:"referencePress",data:{returnFocus:!1}}),n(!1))}},floating:{onKeyDown:D,[$e[m]]:()=>{L.current=!0}}}:{},[C,i,R,m,E,n,D])};function J(e,t,r){let n=new Map;return{...r==="floating"&&{tabIndex:-1},...e,...t.map(i=>i?i[r]:null).concat(e).reduce((i,o)=>(o&&Object.entries(o).forEach(u=>{let[f,h]=u;if(f.indexOf("on")===0){if(n.has(f)||n.set(f,[]),typeof h=="function"){var O;(O=n.get(f))==null||O.push(h),i[f]=function(){for(var C,a=arguments.length,I=new Array(a),m=0;m<a;m++)I[m]=arguments[m];return(C=n.get(f))==null?void 0:C.map(R=>R(...I)).find(R=>R!==void 0)}}}else i[f]=h}),i),{})}}var vt=function(e){e===void 0&&(e=[]);let t=e,r=l.useCallback(o=>J(o,e,"reference"),t),n=l.useCallback(o=>J(o,e,"floating"),t),i=l.useCallback(o=>J(o,e,"item"),e.map(o=>o?.item));return l.useMemo(()=>({getReferenceProps:r,getFloatingProps:n,getItemProps:i}),[r,n,i])};export{U as a,X as b,Rt as c,vt as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c}from"./chunk-4CRC7NS5.js";import{a as f,b as u,c as b,d as y}from"./chunk-R6U5TOP4.js";import{a as d}from"./chunk-VO6JTL4J.js";import{c as S}from"./chunk-JJ5K5LVL.js";import o,{useCallback as L,useEffect as N,useState as T}from"react";import{useLexicalComposerContext as A}from"@lexical/react/LexicalComposerContext";import{mergeRegister as M}from"@lexical/utils";import{$getSelection as R,$isRangeSelection as _,COMMAND_PRIORITY_LOW as k,SELECTION_CHANGE_COMMAND as w}from"lexical";import{Toolbar as D,Tooltray as B}from"@salt-ds/lab";import{useFloatingUI as W}from"@salt-ds/core";function V(){let[e]=A(),[t,i]=T(null),[s,r]=T(!1),P=t?{middleware:[u(t),f({fallbackPlacements:["bottom-start","top-start"]})]}:{placement:"bottom-start",strategy:"absolute"},{context:x,floating:C,reference:m,strategy:F}=W({placement:"bottom-start",open:s,onOpenChange:r,strategy:"absolute",...P}),{getFloatingProps:I}=y([b(x,{ancestorScroll:!0})]),n=L(()=>{let a=R(),p=window.getSelection(),g=p?.anchorNode?.parentElement;if(_(a)&&g){m(g);let E=p.getRangeAt(0),{x:O,y:h,height:U}=E.getBoundingClientRect();i({x:O,y:h+U}),r(!0)}else i(null),r(!1)},[m]);N(()=>M(e.registerUpdateListener(({editorState:a})=>{a.read(()=>{n()})}),e.registerCommand(w,()=>(n(),!1),k)),[e,n]);let l={position:F};return t&&(l={...l,top:t.y,left:t.x}),o.createElement(d,{ref:C,open:s,style:l,...I({})},o.createElement(D,{"aria-label":"page editing toolbar",style:{minWidth:"100px"}},o.createElement(c,{floating:!0}),o.createElement(B,{"aria-label":"text format tooltray"},o.createElement(S,null))))}export{V as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a}from"../chunk-
|
|
1
|
+
import{b as a}from"../chunk-5G53ILEQ.js";import"../chunk-B3MUPQQA.js";import"../chunk-ZUGL4RMA.js";import"../chunk-L5I3DIHV.js";import"../chunk-KZXCNQER.js";import"../chunk-HYOY3SMH.js";import"../chunk-GWUYDDYS.js";import"../chunk-6TWGPQT5.js";import"../chunk-MOZEUF74.js";import"../chunk-6TM3EYFS.js";import"../chunk-UWF3FV3R.js";import"../chunk-KQ2ZCDYD.js";import"../chunk-DK6F4XAE.js";import"../chunk-G4LBXKDE.js";import"../chunk-HB6ONQSD.js";import"../chunk-5YCBSSDA.js";import"../chunk-MJUOPD42.js";import"../chunk-KD66I56W.js";import"../chunk-ESKW4XF6.js";import"../chunk-6YPAVQF4.js";import"../chunk-3FJGHVH5.js";import"../chunk-JQUDHJIQ.js";import"../chunk-XGBC7YGO.js";import"../chunk-WNTJMWYJ.js";import"../chunk-ESJNOEFD.js";import"../chunk-RT5CJ7T5.js";import"../chunk-YQHKK2ZS.js";import"../chunk-FW7CHFWO.js";import"../chunk-RO6ARCLZ.js";import"../chunk-SI5CM3F4.js";import"../chunk-4CRC7NS5.js";import"../chunk-JYGEHLYM.js";import"../chunk-U7COOUR6.js";import"../chunk-R6U5TOP4.js";import"../chunk-VO6JTL4J.js";import"../chunk-XP37MJCS.js";import"../chunk-P5OBPOC4.js";import"../chunk-FKL4ZGDB.js";import"../chunk-YBFKG74H.js";import"../chunk-JJ5K5LVL.js";import"../chunk-WZYDYWT3.js";import"../chunk-PMMRU33I.js";import"../chunk-FFJYM47T.js";import"../chunk-FI57IKHZ.js";import"../chunk-WCG3U3X2.js";import"../chunk-NXV7KCC5.js";import"../chunk-PZZKTKIE.js";import"../chunk-WTMALWJU.js";import"../chunk-PC66Q33O.js";import"../chunk-G57W376H.js";export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-DK6F4XAE.js";import"../../chunk-G4LBXKDE.js";import"../../chunk-HB6ONQSD.js";import"../../chunk-5YCBSSDA.js";import"../../chunk-MJUOPD42.js";import"../../chunk-R6U5TOP4.js";import"../../chunk-VO6JTL4J.js";import"../../chunk-XP37MJCS.js";import"../../chunk-P5OBPOC4.js";export{a as LinkEditor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-HYOY3SMH.js";import"../../chunk-GWUYDDYS.js";import"../../chunk-R6U5TOP4.js";import"../../chunk-VO6JTL4J.js";import"../../chunk-XP37MJCS.js";import"../../chunk-P5OBPOC4.js";import"../../chunk-PMMRU33I.js";import"../../chunk-FFJYM47T.js";export{a as InsertTable};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-B3MUPQQA.js";import"../../chunk-ZUGL4RMA.js";import"../../chunk-L5I3DIHV.js";import"../../chunk-KZXCNQER.js";import"../../chunk-HYOY3SMH.js";import"../../chunk-GWUYDDYS.js";import"../../chunk-FW7CHFWO.js";import"../../chunk-4CRC7NS5.js";import"../../chunk-JYGEHLYM.js";import"../../chunk-U7COOUR6.js";import"../../chunk-R6U5TOP4.js";import"../../chunk-VO6JTL4J.js";import"../../chunk-XP37MJCS.js";import"../../chunk-P5OBPOC4.js";import"../../chunk-YBFKG74H.js";import"../../chunk-JJ5K5LVL.js";import"../../chunk-WZYDYWT3.js";import"../../chunk-PMMRU33I.js";import"../../chunk-FFJYM47T.js";import"../../chunk-PC66Q33O.js";import"../../chunk-G57W376H.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-5G53ILEQ.js";import"./chunk-B3MUPQQA.js";import"./chunk-ZUGL4RMA.js";import"./chunk-L5I3DIHV.js";import"./chunk-KZXCNQER.js";import"./chunk-HYOY3SMH.js";import"./chunk-GWUYDDYS.js";import"./chunk-6TWGPQT5.js";import"./chunk-MOZEUF74.js";import"./chunk-6TM3EYFS.js";import"./chunk-UWF3FV3R.js";import"./chunk-KQ2ZCDYD.js";import"./chunk-DK6F4XAE.js";import"./chunk-G4LBXKDE.js";import"./chunk-HB6ONQSD.js";import"./chunk-5YCBSSDA.js";import"./chunk-MJUOPD42.js";import"./chunk-KD66I56W.js";import"./chunk-ESKW4XF6.js";import"./chunk-6YPAVQF4.js";import"./chunk-3FJGHVH5.js";import"./chunk-JQUDHJIQ.js";import"./chunk-XGBC7YGO.js";import"./chunk-WNTJMWYJ.js";import"./chunk-ESJNOEFD.js";import"./chunk-RT5CJ7T5.js";import"./chunk-YQHKK2ZS.js";import"./chunk-FW7CHFWO.js";import"./chunk-RO6ARCLZ.js";import"./chunk-SI5CM3F4.js";import"./chunk-4CRC7NS5.js";import"./chunk-JYGEHLYM.js";import"./chunk-U7COOUR6.js";import"./chunk-R6U5TOP4.js";import"./chunk-VO6JTL4J.js";import"./chunk-XP37MJCS.js";import"./chunk-P5OBPOC4.js";import"./chunk-FKL4ZGDB.js";import"./chunk-YBFKG74H.js";import"./chunk-JJ5K5LVL.js";import"./chunk-WZYDYWT3.js";import"./chunk-PMMRU33I.js";import"./chunk-FFJYM47T.js";import"./chunk-FI57IKHZ.js";import"./chunk-WCG3U3X2.js";import"./chunk-NXV7KCC5.js";import{a as d}from"./chunk-PZZKTKIE.js";import"./chunk-WTMALWJU.js";import"./chunk-PC66Q33O.js";import{c as a,f as b}from"./chunk-G57W376H.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-SI5CM3F4.js";import"../chunk-4CRC7NS5.js";import"../chunk-JYGEHLYM.js";import"../chunk-U7COOUR6.js";import"../chunk-R6U5TOP4.js";import"../chunk-VO6JTL4J.js";import"../chunk-XP37MJCS.js";import"../chunk-P5OBPOC4.js";import"../chunk-JJ5K5LVL.js";import"../chunk-WZYDYWT3.js";import"../chunk-PMMRU33I.js";import"../chunk-FFJYM47T.js";import"../chunk-G57W376H.js";export{a as FloatingToolbarPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-5G53ILEQ.js";import"../chunk-B3MUPQQA.js";import"../chunk-ZUGL4RMA.js";import"../chunk-L5I3DIHV.js";import"../chunk-KZXCNQER.js";import"../chunk-HYOY3SMH.js";import"../chunk-GWUYDDYS.js";import"../chunk-6TWGPQT5.js";import"../chunk-MOZEUF74.js";import"../chunk-6TM3EYFS.js";import"../chunk-UWF3FV3R.js";import"../chunk-KQ2ZCDYD.js";import"../chunk-DK6F4XAE.js";import"../chunk-G4LBXKDE.js";import"../chunk-HB6ONQSD.js";import"../chunk-5YCBSSDA.js";import"../chunk-MJUOPD42.js";import"../chunk-KD66I56W.js";import"../chunk-ESKW4XF6.js";import"../chunk-6YPAVQF4.js";import"../chunk-3FJGHVH5.js";import"../chunk-JQUDHJIQ.js";import"../chunk-XGBC7YGO.js";import"../chunk-WNTJMWYJ.js";import"../chunk-ESJNOEFD.js";import"../chunk-RT5CJ7T5.js";import"../chunk-YQHKK2ZS.js";import"../chunk-FW7CHFWO.js";import"../chunk-RO6ARCLZ.js";import"../chunk-SI5CM3F4.js";import"../chunk-4CRC7NS5.js";import"../chunk-JYGEHLYM.js";import"../chunk-U7COOUR6.js";import"../chunk-R6U5TOP4.js";import"../chunk-VO6JTL4J.js";import"../chunk-XP37MJCS.js";import"../chunk-P5OBPOC4.js";import"../chunk-FKL4ZGDB.js";import"../chunk-YBFKG74H.js";import"../chunk-JJ5K5LVL.js";import"../chunk-WZYDYWT3.js";import"../chunk-PMMRU33I.js";import"../chunk-FFJYM47T.js";import"../chunk-FI57IKHZ.js";import"../chunk-WCG3U3X2.js";import"../chunk-NXV7KCC5.js";import"../chunk-PZZKTKIE.js";import"../chunk-WTMALWJU.js";import"../chunk-PC66Q33O.js";import"../chunk-G57W376H.js";export{a as PreviewPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-KD66I56W.js";import"../chunk-ESKW4XF6.js";import"../chunk-6YPAVQF4.js";import"../chunk-R6U5TOP4.js";import"../chunk-VO6JTL4J.js";import"../chunk-XP37MJCS.js";import"../chunk-P5OBPOC4.js";export{a as TableActionMenuPlugin};
|
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.33",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "",
|
|
7
7
|
"repository": {
|
|
@@ -38,12 +38,12 @@
|
|
|
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.
|
|
43
|
-
"@salt-ds/core": "^1.
|
|
44
|
-
"@salt-ds/icons": "^1.
|
|
45
|
-
"@salt-ds/lab": "1.0.0-alpha.
|
|
46
|
-
"@salt-ds/theme": "^1.
|
|
41
|
+
"@jpmorganchase/mosaic-components": "^0.1.0-beta.33",
|
|
42
|
+
"@jpmorganchase/mosaic-theme": "^0.1.0-beta.33",
|
|
43
|
+
"@salt-ds/core": "^1.7.0",
|
|
44
|
+
"@salt-ds/icons": "^1.3.0",
|
|
45
|
+
"@salt-ds/lab": "1.0.0-alpha.7",
|
|
46
|
+
"@salt-ds/theme": "^1.4.0",
|
|
47
47
|
"@lexical/code": "0.5.0",
|
|
48
48
|
"@lexical/link": "0.5.0",
|
|
49
49
|
"@lexical/list": "0.5.0",
|
|
@@ -9,8 +9,9 @@ import {
|
|
|
9
9
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
10
10
|
import { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link';
|
|
11
11
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { useFloatingUI } from '@salt-ds/core';
|
|
13
|
+
import { Input } from '@salt-ds/lab';
|
|
14
|
+
import { useDismiss, useInteractions } from '@floating-ui/react';
|
|
14
15
|
|
|
15
16
|
import styles from './LinkEditor.css';
|
|
16
17
|
import { SaveAdornment } from './SaveAdornment';
|
|
@@ -3,8 +3,8 @@ import { Icon } from '@jpmorganchase/mosaic-components';
|
|
|
3
3
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
4
4
|
import { INSERT_TABLE_COMMAND } from '@lexical/table';
|
|
5
5
|
|
|
6
|
-
import { useFloatingUI } from '@salt-ds/
|
|
7
|
-
import { useDismiss, useInteractions } from '@floating-ui/react
|
|
6
|
+
import { useFloatingUI } from '@salt-ds/core';
|
|
7
|
+
import { useDismiss, useInteractions } from '@floating-ui/react';
|
|
8
8
|
import { Popper } from '../Popper/Popper';
|
|
9
9
|
import { TextFormatToolbarButton } from './TextFormatToolbarButton';
|
|
10
10
|
import styles from './InsertTable.css';
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
SELECTION_CHANGE_COMMAND
|
|
9
9
|
} from 'lexical';
|
|
10
10
|
import { Toolbar as SaltToolbar, Tooltray as SaltTooltray } from '@salt-ds/lab';
|
|
11
|
-
import { flip, inline } from '@floating-ui/react
|
|
12
|
-
import { useFloatingUI, UseFloatingUIProps } from '@salt-ds/
|
|
13
|
-
import { useInteractions, useDismiss } from '@floating-ui/react
|
|
11
|
+
import { flip, inline } from '@floating-ui/react';
|
|
12
|
+
import { useFloatingUI, UseFloatingUIProps } from '@salt-ds/core';
|
|
13
|
+
import { useInteractions, useDismiss } from '@floating-ui/react';
|
|
14
14
|
import { Popper } from '../components/Popper/Popper';
|
|
15
15
|
import { TextFormatTooltray } from '../components/Toolbar/TextFormatTooltray';
|
|
16
16
|
import { InsertLinkButton } from '../components/Toolbar/InsertLink';
|
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
$removeTableRowAtIndex,
|
|
15
15
|
TableCellNode
|
|
16
16
|
} from '@lexical/table';
|
|
17
|
-
import { useFloatingUI } from '@salt-ds/
|
|
18
|
-
import { useDismiss, useInteractions } from '@floating-ui/react
|
|
17
|
+
import { useFloatingUI } from '@salt-ds/core';
|
|
18
|
+
import { useDismiss, useInteractions } from '@floating-ui/react';
|
|
19
19
|
import {
|
|
20
20
|
ArrowDownIcon,
|
|
21
21
|
ArrowLeftIcon,
|
package/dist/chunk-ENTOKO6G.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function F(e){return e.split("-")[0]}function _(e){return e.split("-")[1]}function K(e){return["top","bottom"].includes(F(e))?"x":"y"}function J(e){return e==="y"?"height":"width"}function B(e){return typeof e!="number"?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(e):{top:e,right:e,bottom:e,left:e}}function S(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}async function $(e,t){var c;t===void 0&&(t={});let{x:r,y:n,platform:i,rects:o,elements:l,strategy:p}=e,{boundary:a="clippingAncestors",rootBoundary:x="viewport",elementContext:f="floating",altBoundary:s=!1,padding:b=0}=t,d=B(b),R=l[s?f==="floating"?"reference":"floating":f],g=S(await i.getClippingRect({element:(c=await(i.isElement==null?void 0:i.isElement(R)))==null||c?R:R.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:a,rootBoundary:x,strategy:p})),h=S(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({rect:f==="floating"?{...o.floating,x:r,y:n}:o.reference,offsetParent:await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),strategy:p}):o[f]);return{top:g.top-h.top+d.top,bottom:h.bottom-g.bottom+d.bottom,left:g.left-h.left+d.left,right:h.right-g.right+d.right}}var Q=Math.min,Z=Math.max;var ee={left:"right",right:"left",bottom:"top",top:"bottom"};function k(e){return e.replace(/left|right|bottom|top/g,t=>ee[t])}function te(e,t,c){c===void 0&&(c=!1);let r=_(e),n=K(e),i=J(n),o=n==="x"?r===(c?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(o=k(o)),{main:o,cross:k(o)}}var ne={start:"end",end:"start"};function V(e){return e.replace(/start|end/g,t=>ne[t])}var re=["top","right","bottom","left"],xe=re.reduce((e,t)=>e.concat(t,t+"-start",t+"-end"),[]);var oe=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var c;let{placement:r,middlewareData:n,rects:i,initialPlacement:o,platform:l,elements:p}=t,{mainAxis:a=!0,crossAxis:x=!0,fallbackPlacements:f,fallbackStrategy:s="bestFit",flipAlignment:b=!0,...d}=e,R=F(r),g=f||(R===o||!b?[k(o)]:function(y){let w=k(y);return[V(y),w,V(w)]}(o)),h=[o,...g],E=await $(t,d),T=[],v=((c=n.flip)==null?void 0:c.overflows)||[];if(a&&T.push(E[R]),x){let{main:y,cross:w}=te(r,i,await(l.isRTL==null?void 0:l.isRTL(p.floating)));T.push(E[y],E[w])}if(v=[...v,{placement:r,overflows:T}],!T.every(y=>y<=0)){var L,u;let y=((L=(u=n.flip)==null?void 0:u.index)!=null?L:0)+1,w=h[y];if(w)return{data:{index:y,overflows:v},reset:{placement:w}};let C="bottom";switch(s){case"bestFit":{var P;let I=(P=v.map(O=>[O,O.overflows.filter(D=>D>0).reduce((D,q)=>D+q,0)]).sort((O,D)=>O[1]-D[1])[0])==null?void 0:P[0].placement;I&&(C=I);break}case"initialPlacement":C=o}if(r!==C)return{reset:{placement:C}}}return{}}}};var ie=function(e){return e===void 0&&(e={}),{name:"inline",options:e,async fn(t){var c;let{placement:r,elements:n,rects:i,platform:o,strategy:l}=t,{padding:p=2,x:a,y:x}=e,f=S(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({rect:i.reference,offsetParent:await(o.getOffsetParent==null?void 0:o.getOffsetParent(n.floating)),strategy:l}):i.reference),s=(c=await(o.getClientRects==null?void 0:o.getClientRects(n.reference)))!=null?c:[],b=B(p),d=await o.getElementRects({reference:{getBoundingClientRect:function(){var R;if(s.length===2&&s[0].left>s[1].right&&a!=null&&x!=null)return(R=s.find(g=>a>g.left-b.left&&a<g.right+b.right&&x>g.top-b.top&&x<g.bottom+b.bottom))!=null?R:f;if(s.length>=2){if(K(r)==="x"){let u=s[0],P=s[s.length-1],y=F(r)==="top",w=u.top,C=P.bottom,I=y?u.left:P.left,O=y?u.right:P.right;return{top:w,bottom:C,left:I,right:O,width:O-I,height:C-w,x:I,y:w}}let g=F(r)==="left",h=Z(...s.map(u=>u.right)),E=Q(...s.map(u=>u.left)),T=s.filter(u=>g?u.left===E:u.right===h),v=T[0].top,L=T[T.length-1].bottom;return{top:v,bottom:L,left:E,right:h,width:h-E,height:L-v,x:E,y:v}}return f}},floating:n.floating,strategy:l});return i.reference.x!==d.reference.x||i.reference.y!==d.reference.y||i.reference.width!==d.reference.width||i.reference.height!==d.reference.height?{reset:{rects:d}}:{}}}};function j(e){return e&&e.document&&e.location&&e.alert&&e.setInterval}function A(e){if(e==null)return window;if(!j(e)){let t=e.ownerDocument;return t&&t.defaultView||window}return e}function ce(e){return A(e).getComputedStyle(e)}function G(e){return j(e)?"":e?(e.nodeName||"").toLowerCase():""}function le(e){return e instanceof A(e).HTMLElement}function ue(e){return typeof ShadowRoot>"u"?!1:e instanceof A(e).ShadowRoot||e instanceof ShadowRoot}function U(e){let{overflow:t,overflowX:c,overflowY:r}=ce(e);return/auto|scroll|overlay|hidden/.test(t+r+c)}function se(e){return(t=e,(t instanceof A(t).Node?e.ownerDocument:e.document)||window.document).documentElement;var t}function ae(e){return G(e)==="html"?e:e.assignedSlot||e.parentNode||(ue(e)?e.host:null)||se(e)}function X(e){let t=ae(e);return["html","body","#document"].includes(G(t))?e.ownerDocument.body:le(t)&&U(t)?t:X(t)}function M(e,t){var c;t===void 0&&(t=[]);let r=X(e),n=r===((c=e.ownerDocument)==null?void 0:c.body),i=A(r),o=n?[i].concat(i.visualViewport||[],U(r)?r:[]):r,l=t.concat(o);return n?l:l.concat(M(o))}import*as m from"react";import{useLayoutEffect as fe,useEffect as de,useRef as ge}from"react";import{createPortal as Ne}from"react-dom";var me=typeof document<"u"?fe:de;var He=m["useId".toString()];var pe=m.createContext(null);var he=()=>m.useContext(pe);function N(e,t,c){let r={};return{...c==="floating"&&{tabIndex:-1},...e,...t.map(n=>n?n[c]:null).concat(e).reduce((n,i)=>(i&&Object.entries(i).forEach(o=>{let[l,p]=o;l.indexOf("on")===0?(r[l]||(r[l]=[]),typeof p=="function"&&r[l].push(p),n[l]=function(){for(var a=arguments.length,x=new Array(a),f=0;f<a;f++)x[f]=arguments[f];r[l].forEach(s=>s(...x))}):n[l]=p}),n),{})}}var We=function(e){return e===void 0&&(e=[]),{getReferenceProps:t=>N(t,e,"reference"),getFloatingProps:t=>N(t,e,"floating"),getItemProps:t=>N(t,e,"item")}};function z(e){var t;return(t=e?.ownerDocument)!=null?t:document}function Y(e){var t;return(t=z(e).defaultView)!=null?t:window}function H(e){return e?e instanceof Y(e).Element:!1}function ve(e){return e?e instanceof Y(e).HTMLElement:!1}function ye(e,t){var c;let r=(c=e?.nodesRef.current.filter(o=>{var l;return o.parentId===t&&((l=o.context)==null?void 0:l.open)}))!=null?c:[],n=r;for(;n.length;){var i;n=(i=e?.nodesRef.current.filter(o=>{var l;return(l=n)==null?void 0:l.some(p=>{var a;return o.parentId===p.id&&((a=o.context)==null?void 0:a.open)})}))!=null?i:[],r=r.concat(n)}return r}function we(e){let t=e.activeElement;for(;((c=t)==null||(r=c.shadowRoot)==null?void 0:r.activeElement)!=null;){var c,r;t=t.shadowRoot.activeElement}return t}function Re(e){let t=ge(e);return me(()=>{t.current=e}),t}function W(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);let c=e;return c.target!=null&&t.contains(c.target)}var ze=function(e,t){let{open:c,onOpenChange:r,refs:n,events:i,nodeId:o}=e,{enabled:l=!0,escapeKey:p=!0,outsidePointerDown:a=!0,referencePointerDown:x=!1,ancestorScroll:f=!1,bubbles:s=!0}=t===void 0?{}:t,b=he(),d=Re(r),R=m.useCallback(()=>{var h;return(h=n.floating.current)==null?void 0:h.contains(we(z(n.floating.current)))},[n.floating]),g=m.useCallback(()=>{ve(n.reference.current)&&n.reference.current.focus()},[n.reference]);return m.useEffect(()=>{if(!c||!l)return;function h(u){if(u.key==="Escape"){if(!s&&!R())return;i.emit("dismiss"),d.current(!1),g()}}function E(u){let P=b&&ye(b,o).some(y=>{var w;return W(u,(w=y.context)==null?void 0:w.refs.floating.current)});W(u,n.floating.current)||H(n.reference.current)&&W(u,n.reference.current)||P||!s&&!R()||(i.emit("dismiss"),d.current(!1),g())}function T(){d.current(!1)}let v=z(n.floating.current);p&&v.addEventListener("keydown",h),a&&v.addEventListener("mousedown",E);let L=(f?[...H(n.reference.current)?M(n.reference.current):[],...H(n.floating.current)?M(n.floating.current):[]]:[]).filter(u=>{var P;return u!==((P=v.defaultView)==null?void 0:P.visualViewport)});return L.forEach(u=>u.addEventListener("scroll",T,{passive:!0})),()=>{p&&v.removeEventListener("keydown",h),a&&v.removeEventListener("mousedown",E),L.forEach(u=>u.removeEventListener("scroll",T))}},[p,a,i,b,o,c,d,g,f,l,s,R,n.floating,n.reference]),l?{reference:{onPointerDown(){x&&(i.emit("dismiss"),r(!1))}}}:{}};export{oe as a,ie as b,We as c,ze as d};
|
package/dist/chunk-HN5XYH53.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as c}from"./chunk-4CRC7NS5.js";import{a as f,b as u,c as b,d as y}from"./chunk-ENTOKO6G.js";import{a as d}from"./chunk-VO6JTL4J.js";import{c as S}from"./chunk-JJ5K5LVL.js";import o,{useCallback as L,useEffect as N,useState as T}from"react";import{useLexicalComposerContext as A}from"@lexical/react/LexicalComposerContext";import{mergeRegister as M}from"@lexical/utils";import{$getSelection as R,$isRangeSelection as _,COMMAND_PRIORITY_LOW as k,SELECTION_CHANGE_COMMAND as w}from"lexical";import{Toolbar as D,Tooltray as B}from"@salt-ds/lab";import{useFloatingUI as W}from"@salt-ds/lab";function V(){let[e]=A(),[t,i]=T(null),[s,r]=T(!1),P=t?{middleware:[u(t),f({fallbackPlacements:["bottom-start","top-start"]})]}:{placement:"bottom-start",strategy:"absolute"},{context:x,floating:C,reference:m,strategy:F}=W({placement:"bottom-start",open:s,onOpenChange:r,strategy:"absolute",...P}),{getFloatingProps:I}=b([y(x,{ancestorScroll:!0})]),n=L(()=>{let a=R(),p=window.getSelection(),g=p?.anchorNode?.parentElement;if(_(a)&&g){m(g);let E=p.getRangeAt(0),{x:O,y:h,height:U}=E.getBoundingClientRect();i({x:O,y:h+U}),r(!0)}else i(null),r(!1)},[m]);N(()=>M(e.registerUpdateListener(({editorState:a})=>{a.read(()=>{n()})}),e.registerCommand(w,()=>(n(),!1),k)),[e,n]);let l={position:F};return t&&(l={...l,top:t.y,left:t.x}),o.createElement(d,{ref:C,open:s,style:l,...I({})},o.createElement(D,{"aria-label":"page editing toolbar",style:{minWidth:"100px"}},o.createElement(c,{floating:!0}),o.createElement(B,{"aria-label":"text format tooltray"},o.createElement(S,null))))}export{V as a};
|
package/dist/chunk-HSZQ3ZK6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as C}from"./chunk-G4LBXKDE.js";import{a as S}from"./chunk-HB6ONQSD.js";import{a as L}from"./chunk-5YCBSSDA.js";import{a as y}from"./chunk-MJUOPD42.js";import{c as g,d}from"./chunk-ENTOKO6G.js";import{a as E}from"./chunk-VO6JTL4J.js";import{mergeRegister as x}from"@lexical/utils";import{$getSelection as P,$isRangeSelection as v,COMMAND_PRIORITY_LOW as T,SELECTION_CHANGE_COMMAND as B}from"lexical";import l,{useCallback as G,useEffect as k,useRef as $,useState as f}from"react";import{$isLinkNode as I,TOGGLE_LINK_COMMAND as b}from"@lexical/link";import{useLexicalComposerContext as F}from"@lexical/react/LexicalComposerContext";import{Input as H,useFloatingUI as w}from"@salt-ds/lab";function ne(){let[t]=F(),N=$(null),[o,r]=f(""),[h,s]=f(!1),[O,a]=f(null),c=()=>{r(""),s(!1),a(null)},{context:D,floating:M,reference:m,strategy:R,x:A,y:K}=w({placement:"right",strategy:"absolute",open:o.length>0,onOpenChange:c}),{getFloatingProps:U}=g([d(D,{ancestorScroll:!0})]),n=G(()=>{let e=P();if(v(e)){let i=C(e),p=i.getParent();I(p)?(m(t.getElementByKey(p.getKey())),r(p.getURL()),a(e)):I(i)?(m(t.getElementByKey(i.getKey())),r(i.getURL()),a(e)):c()}return s(!1),!0},[t,m]);k(()=>x(t.registerUpdateListener(({editorState:e})=>{e.read(()=>{n()})}),t.registerCommand(B,()=>(n(),!0),T)),[t,n]),k(()=>{t.getEditorState().read(()=>{n()})},[t,n]);let u=()=>{O!==null&&o!==""&&(t.dispatchCommand(b,o),s(!1))},_=()=>s(!0);return l.createElement(E,{className:L.popper,ref:M,open:o.length>0,style:{top:K??"",left:A??"",position:R},...U({})},h?l.createElement(H,{endAdornment:l.createElement(y,{onSave:u}),ref:N,value:o,onChange:e=>{r(e.target.value)},onKeyDown:e=>{e.key==="Enter"?(e.preventDefault(),u()):e.key==="Escape"&&e.preventDefault()}}):l.createElement(S,{onClick:_}))}export{ne as a};
|
package/dist/chunk-WNREGBHC.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as M}from"./chunk-ESKW4XF6.js";import{a as T}from"./chunk-6YPAVQF4.js";import{c as S,d as L}from"./chunk-ENTOKO6G.js";import{a as D}from"./chunk-VO6JTL4J.js";import A,{useCallback as i,useEffect as h,useState as E}from"react";import{useLexicalComposerContext as N}from"@lexical/react/LexicalComposerContext";import{$getSelection as B,$isRangeSelection as O}from"lexical";import{$deleteTableColumn as U,$getElementGridForTableNode as $,$getTableCellNodeFromLexicalNode as k,$getTableColumnIndexFromTableCellNode as y,$getTableNodeFromLexicalNodeOrThrow as u,$getTableRowIndexFromTableCellNode as F,$insertTableColumn as K,$insertTableRow as G,$isTableCellNode as a,$removeTableRowAtIndex as H}from"@lexical/table";import{useFloatingUI as j}from"@salt-ds/lab";import{ArrowDownIcon as q,ArrowLeftIcon as z,ArrowRightIcon as J,ArrowUpIcon as Q,DeleteIcon as v,DeleteSolidIcon as V}from"@salt-ds/icons";var W={menuItems:[{title:"Insert Row Above",icon:Q},{title:"Insert Row Below",icon:q},{title:"Insert Column Left",icon:z},{title:"Insert Column Right",icon:J},{title:"Delete Row",icon:v},{title:"Delete Column",icon:v},{title:"Delete Table",icon:V}]};function X({editor:t,tableCellNode:e,onComplete:o}){let s=n=>{if(!!n){if(n.title==="Delete Row"){f();return}if(n.title==="Insert Row Below"){m(!0);return}if(n.title==="Insert Row Above"){m(!1);return}if(n.title==="Insert Column Left"){d(!1);return}if(n.title==="Insert Column Right"){d(!0);return}if(n.title==="Delete Column"){p();return}n.title==="Delete Table"&&I()}},f=i(()=>{t.update(()=>{if(a(e)){let n=u(e),l=F(e);H(n,l),o()}})},[t,o,e]),m=i(n=>{t.update(()=>{if(a(e)){let l=u(e),c=F(e),r=$(t,l);G(l,c,n,1,r)}o()})},[t,e,o]),d=i(n=>{t.update(()=>{if(a(e)){let l=u(e),c=y(e),r=$(t,l);K(l,c,n,1,r)}o()})},[t,e,o]),p=i(()=>{t.update(()=>{if(a(e)){let n=u(e),l=y(e);U(n,l),o()}})},[t,e,o]),I=i(()=>{t.update(()=>{a(e)&&(u(e).remove(),o())})},[t,e,o]);return A.createElement(M,{initialSource:W,onItemClick:s})}function ae(){let[t]=N(),[e,o]=E(null),[s,f]=E(null),{context:m,floating:d,reference:p,strategy:I,x:n,y:l}=j({placement:"right",strategy:"absolute",open:e!==null,onOpenChange:()=>o(null)}),{getFloatingProps:c}=S([L(m,{ancestorScroll:!0})]),r=i(()=>{let g=B(),w=window.getSelection(),{activeElement:C}=document;if(g==null){o(null);return}let x=t.getRootElement();if(O(g)&&x!==null&&w!==null&&x.contains(w.anchorNode)){let R=k(g.anchor.getNode());if(R==null){o(null);return}let b=t.getElementByKey(R.getKey());if(b==null){o(null);return}b.classList.add(...T.focused),o(R),p(b),f(b)}else C||o(null)},[t,p]);h(()=>t.registerUpdateListener(()=>{t.getEditorState().read(()=>{r()})}),[t,r]),h(function(){return s?.classList.add(...T.focused),function(){s?.classList.remove(...T.focused)}},[s?.classList,e]);let P=()=>{f(null),o(null)};return A.createElement(D,{ref:d,open:e!==null,style:{top:l??"",left:n??"",position:I},...c({})},A.createElement(X,{editor:t,tableCellNode:e,onComplete:P}))}export{ae as a};
|
package/dist/chunk-ZUOQD3SL.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as o}from"./chunk-GWUYDDYS.js";import{c as N,d as M}from"./chunk-ENTOKO6G.js";import{a as F}from"./chunk-VO6JTL4J.js";import{a as E}from"./chunk-PMMRU33I.js";import e,{useRef as P,useState as y}from"react";import{Icon as H}from"@jpmorganchase/mosaic-components";import{useLexicalComposerContext as W}from"@lexical/react/LexicalComposerContext";import{INSERT_TABLE_COMMAND as j}from"@lexical/table";import{useFloatingUI as q}from"@salt-ds/lab";var G=({index:n,...r})=>e.createElement("td",{className:o.cell,"data-column":n,...r}),J=({children:n,index:r})=>e.createElement("tr",{className:r===1?o.headerRow:o.row,"data-row":r},n),K=({rowCount:n,columnCount:r})=>{let a=[],s=[];for(let t=1;t<=r;t++)a.push(e.createElement(G,{key:t,index:t}));for(let t=1;t<=n;t++)s.push(e.createElement(J,{key:t,index:t},a));return e.createElement("tbody",null,s)};function Q(n){let r=parseInt(n?.dataset?.column||"0",10),a=n.parentNode,s=parseInt(a?.dataset?.row||"0",10);return{columnIndex:r,rowIndex:s}}var ie=({minRows:n=2,minColumns:r=2,maxColumns:a=10,initialRowCount:s=4,initialColumnCount:t=4})=>{let[O]=W(),g=P(null),c=P(!1),[m,d]=y(t),[i,p]=y(s),[f,h]=y(!1),v=()=>{x(),h(l=>!l)},{context:L,floating:S,reference:B,strategy:k,x:A,y:D}=q({placement:"bottom",strategy:"absolute",open:f,onOpenChange:v}),{getFloatingProps:_}=N([M(L,{ancestorScroll:!0})]),$=l=>{let I=l.nativeEvent.target;if(!g.current?.contains(I)||!c.current)return;let{columnIndex:w,rowIndex:T}=Q(I);w<m&&w>=r&&d(w),T<i&&T>=n&&p(T)};function x(){d(t),p(s),c.current=!1}let z=()=>{c.current=!0,m+1<=a&&d(l=>l+1)},R=()=>{c.current=!0,p(l=>l+1)},U=()=>{O.dispatchCommand(j,{columns:m.toString(),rows:i.toString()}),x(),h(!1)},u=25,b=i*u,C=m*u;return e.createElement(e.Fragment,null,e.createElement(E,{ref:B,onClick:v,active:f},e.createElement(H,{name:"grid"}),e.createElement("div",{className:o.spacer}),e.createElement(H,{name:"chevronDown"})),e.createElement(F,{className:o.popper,ref:S,open:f,style:{top:D??"",left:A??"",position:k},..._({})},e.createElement("div",{className:o.tableContainer,onMouseOver:$,onClick:U},e.createElement("table",{className:o.table,style:{width:C,height:b},ref:g},e.createElement(K,{rowCount:i,columnCount:m})),e.createElement("div",{className:o.dimensions},`${m} x ${i}`),e.createElement("div",{className:o.addColumnArea,style:{left:C,height:b+u},onMouseOver:z}),e.createElement("div",{className:o.addRowArea,style:{top:b,width:C+u},onMouseOver:R}))))};export{ie as a};
|