@oyat/editor 1.8.2 → 1.8.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-combobox.d.ts","sourceRoot":"","sources":["../../../src/components/ui/inline-combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"inline-combobox.d.ts","sourceRoot":"","sources":["../../../src/components/ui/inline-combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAY,QAAQ,EAAE,MAAM,SAAS,CAAC;AAElD,OAAO,EACL,KAAK,iBAAiB,EAEtB,aAAa,EACb,kBAAkB,EAElB,eAAe,EAMhB,MAAM,gBAAgB,CAAC;AAYxB,KAAK,QAAQ,GAAG,CACd,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EAC5E,MAAM,EAAE,MAAM,KACX,OAAO,CAAC;AA6Bb,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,QAAQ,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC,CAAC;AAEF,QAAA,MAAM,cAAc,GAAI,iHASrB,mBAAmB,4CAuIrB,CAAC;AAEF,QAAA,MAAM,mBAAmB;4CAItB,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC,GAAG;QAC1C,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;KAChD;;CA8CA,CAAC;AAIF,QAAA,MAAM,qBAAqB,EAAE,OAAO,eAsCnC,CAAC;AAiBF,QAAA,MAAM,kBAAkB,GAAI,uEAQzB;IACD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,iBAAiB,GACnB,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,mDA4B3C,CAAC;AAEF,QAAA,MAAM,mBAAmB,GAAI,0BAG1B,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,mDAsBtC,CAAC;AAEF,QAAA,MAAM,iBAAiB,8IAAc,CAAC;AAEtC,iBAAS,mBAAmB,CAAC,EAC3B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,2CAU5C;AAED,iBAAS,wBAAwB,CAAC,EAChC,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,kBAAkB,CAAC,2CAUjD;AAED,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,GAClB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -260,7 +260,7 @@ return ha.jsxs("div",{className:ya("relative",l&&"opacity-50",p(n,s.type)?.node.
|
|
|
260
260
|
return ha.jsx("div",{...r,className:ya("slate-gutterLeft","-translate-x-full absolute top-0 z-50 flex h-full cursor-text hover:opacity-100 sm:opacity-0",p(n,s.type)?.node.isContainer?"group-hover/container:opacity-100":"group-hover:opacity-100",o&&"hidden",!i&&"opacity-0",t),contentEditable:!1,children:e})}const Uc=e.memo(function({isDragging:e,previewRef:t,resetPreview:r,setPreviewTop:n}){const s=D(),o=R();/* @__PURE__ */
|
|
261
261
|
return ha.jsxs(Fa,{children:[
|
|
262
262
|
/* @__PURE__ */ha.jsx(La,{asChild:!0,children:/* @__PURE__ */ha.jsx("div",{className:"flex size-full items-center justify-center",onClick:e=>{e.preventDefault(),s.getApi(nt).blockSelection.focus()},onMouseDown:e=>{if(r(),0!==e.button&&2!==e.button||e.shiftKey)return;const n=s.getApi(nt).blockSelection.getNodes({sort:!0});let i=n.length>0?n:s.api.blocks({mode:"highest"});i.some(([e])=>e.id===o.id)||(i=[[o,s.api.findPath(o)]]);const a=Be(s,i).map(([e])=>e);0===n.length&&(s.tf.blur(),s.tf.collapse());const l=qc(s,a);t.current?.append(...l),t.current?.classList.remove("hidden"),t.current?.classList.add("opacity-0"),s.setOption(on,"multiplePreviewRef",t),s.getApi(nt).blockSelection.set(a.map(e=>e.id))},onMouseEnter:()=>{if(e)return;const t=s.getApi(nt).blockSelection.getNodes({sort:!0});let r=t.length>0?t:s.api.blocks({mode:"highest"});r.some(([e])=>e.id===o.id)||(r=[[o,s.api.findPath(o)]]);const i=Be(s,r),a=i.map(e=>e[0].id);if(a.length>1&&a.includes(o.id)){const e=Wc(s,{blocks:i.map(e=>e[0]),element:o});n(e)}else n(0)},onMouseUp:()=>{r()},"data-plate-prevent-deselect":!0,role:"button",children:/* @__PURE__ */ha.jsx(Gt,{className:"text-muted-foreground"})})}),
|
|
263
|
-
/* @__PURE__ */ha.jsx(Ha,{children:"Drag to move"})]})}),$c=e.memo(function({className:e,...t}){const{dropLine:r}=ln();return r?/* @__PURE__ */ha.jsx("div",{...t,className:ya("slate-dropLine","absolute inset-x-0 h-0.5 opacity-100 transition-opacity","bg-brand/50","top"===r&&"-top-px","bottom"===r&&"-bottom-px",e)}):null}),qc=(e,t)=>{const r=[],n=[],s=e=>{Array.from(e.attributes).forEach(t=>{(t.name.startsWith("data-slate")||t.name.startsWith("data-block-id"))&&e.removeAttribute(t.name)}),Array.from(e.children).forEach(e=>{s(e)})};return t.forEach((o,i)=>{((o,i)=>{const a=e.api.toDOMNode(o),l=a.cloneNode(!0);((e,t)=>{const r=e.scrollLeft;if(r>0){const n=document.createElement("div");n.style.overflow="hidden",n.style.width=`${e.clientWidth}px`;const s=document.createElement("div");for(s.style.transform=`translateX(-${r}px)`,s.style.width=`${e.scrollWidth}px`;t.firstChild;)s.append(t.firstChild);const o=window.getComputedStyle(e);t.style.padding="0",s.style.padding=o.padding,n.append(s),t.append(n)}})(a,l),n.push(o.id);const c=document.createElement("div");c.append(l),c.style.display="flow-root";const d=t[i-1];if(d){const t=e.api.toDOMNode(d).parentElement.getBoundingClientRect(),r=a.parentElement.getBoundingClientRect().top-t.bottom;r>15&&(c.style.marginTop=`${r}px`)}s(l),r.push(c)})(o,i)}),e.setOption(on,"draggingId",n),r},Wc=(e,{blocks:t,element:r})=>{const n=e.api.toDOMNode(r),s=e.api.toDOMNode(e),o=t[0],i=e.api.toDOMNode(o),a=Number(window.getComputedStyle(s).paddingTop.replace("px","")),l=i.getBoundingClientRect().top-s.getBoundingClientRect().top-a,c=window.getComputedStyle(i).marginTop,d=Number(c.replace("px","")),u=n.getBoundingClientRect().top-s.getBoundingClientRect().top-a,m=window.getComputedStyle(n).marginTop;return u-l+d-Number(m.replace("px",""))},Kc=(e,t)=>{const r=e.api.toDOMNode(t),n=window.getComputedStyle(r).marginTop;return Number(n.replace("px",""))},Zc=[on.configure({options:{enableScroller:!0,onDropFiles:({dragItem:e,editor:t,target:r})=>{t.getTransforms(ps).insert.media(e.files,{at:r,nextBlock:!1})}},render:{aboveNodes:t=>{const{editor:n,element:s,path:o}=t;if(e.useMemo(()=>{if(n.dom.readOnly)return!1;if(1===o.length&&!h(n,s,Lc))return!0;if(3===o.length&&!h(n,s,Lc)){if(n.api.some({at:o,match:{type:n.getType(r.column)}}))return!0}if(4===o.length&&!h(n,s,Lc)){if(n.api.some({at:o,match:{type:n.getType(r.table)}}))return!0}return!1},[n,s,o]))return e=>/* @__PURE__ */ha.jsx(Hc,{...e})},aboveSlate:({children:e})=>/* @__PURE__ */ha.jsx(Is,{backend:Bs,children:e})}})],Gc=[Ts,Ds],Yc=e.createContext(null),Qc=({group:e,keywords:t=[],label:r,value:n},s)=>{const o=new Set([n,...t,e,r].filter(Boolean));return Array.from(o).some(e=>$s(e,s))},Xc=({children:t,element:r,filter:n=Qc,hideWhenNoValue:s=!1,setValue:o,showTrigger:i=!0,trigger:a,value:l})=>{const c=D(),d=e.useRef(null),u=qs(d),[m,h]=e.useState(""),p=void 0!==l,x=p?l:m,f=e.useMemo(()=>{const e=r.userId,t=c.meta.userId;return!e||e===t},[c.meta.userId,r]),g=e.useCallback(e=>{o?.(e),p||h(e)},[o,p]),b=e.useRef(null);e.useEffect(()=>{const e=c.api.findPath(r);if(!e)return;const t=c.api.before(e);if(!t)return;const n=c.api.pointRef(t);return b.current=n
|
|
263
|
+
/* @__PURE__ */ha.jsx(Ha,{children:"Drag to move"})]})}),$c=e.memo(function({className:e,...t}){const{dropLine:r}=ln();return r?/* @__PURE__ */ha.jsx("div",{...t,className:ya("slate-dropLine","absolute inset-x-0 h-0.5 opacity-100 transition-opacity","bg-brand/50","top"===r&&"-top-px","bottom"===r&&"-bottom-px",e)}):null}),qc=(e,t)=>{const r=[],n=[],s=e=>{Array.from(e.attributes).forEach(t=>{(t.name.startsWith("data-slate")||t.name.startsWith("data-block-id"))&&e.removeAttribute(t.name)}),Array.from(e.children).forEach(e=>{s(e)})};return t.forEach((o,i)=>{((o,i)=>{const a=e.api.toDOMNode(o),l=a.cloneNode(!0);((e,t)=>{const r=e.scrollLeft;if(r>0){const n=document.createElement("div");n.style.overflow="hidden",n.style.width=`${e.clientWidth}px`;const s=document.createElement("div");for(s.style.transform=`translateX(-${r}px)`,s.style.width=`${e.scrollWidth}px`;t.firstChild;)s.append(t.firstChild);const o=window.getComputedStyle(e);t.style.padding="0",s.style.padding=o.padding,n.append(s),t.append(n)}})(a,l),n.push(o.id);const c=document.createElement("div");c.append(l),c.style.display="flow-root";const d=t[i-1];if(d){const t=e.api.toDOMNode(d).parentElement.getBoundingClientRect(),r=a.parentElement.getBoundingClientRect().top-t.bottom;r>15&&(c.style.marginTop=`${r}px`)}s(l),r.push(c)})(o,i)}),e.setOption(on,"draggingId",n),r},Wc=(e,{blocks:t,element:r})=>{const n=e.api.toDOMNode(r),s=e.api.toDOMNode(e),o=t[0],i=e.api.toDOMNode(o),a=Number(window.getComputedStyle(s).paddingTop.replace("px","")),l=i.getBoundingClientRect().top-s.getBoundingClientRect().top-a,c=window.getComputedStyle(i).marginTop,d=Number(c.replace("px","")),u=n.getBoundingClientRect().top-s.getBoundingClientRect().top-a,m=window.getComputedStyle(n).marginTop;return u-l+d-Number(m.replace("px",""))},Kc=(e,t)=>{const r=e.api.toDOMNode(t),n=window.getComputedStyle(r).marginTop;return Number(n.replace("px",""))},Zc=[on.configure({options:{enableScroller:!0,onDropFiles:({dragItem:e,editor:t,target:r})=>{t.getTransforms(ps).insert.media(e.files,{at:r,nextBlock:!1})}},render:{aboveNodes:t=>{const{editor:n,element:s,path:o}=t;if(e.useMemo(()=>{if(n.dom.readOnly)return!1;if(1===o.length&&!h(n,s,Lc))return!0;if(3===o.length&&!h(n,s,Lc)){if(n.api.some({at:o,match:{type:n.getType(r.column)}}))return!0}if(4===o.length&&!h(n,s,Lc)){if(n.api.some({at:o,match:{type:n.getType(r.table)}}))return!0}return!1},[n,s,o]))return e=>/* @__PURE__ */ha.jsx(Hc,{...e})},aboveSlate:({children:e})=>/* @__PURE__ */ha.jsx(Is,{backend:Bs,children:e})}})],Gc=[Ts,Ds],Yc=e.createContext(null),Qc=({group:e,keywords:t=[],label:r,value:n},s)=>{const o=new Set([n,...t,e,r].filter(Boolean));return Array.from(o).some(e=>$s(e,s))},Xc=({children:t,element:r,filter:n=Qc,hideWhenNoValue:s=!1,setValue:o,showTrigger:i=!0,trigger:a,value:l})=>{const c=D(),d=e.useRef(null),u=qs(d),[m,h]=e.useState(""),p=void 0!==l,x=p?l:m,f=e.useMemo(()=>{const e=r.userId,t=c.meta.userId;return!e||e===t},[c.meta.userId,r]),g=e.useCallback(e=>{o?.(e),p||h(e)},[o,p]),b=e.useRef(null);e.useEffect(()=>{b.current?.unref(),b.current=null;const e=c.api.findPath(r);if(!e)return;const t=c.api.before(e);if(!t)return;const n=c.api.pointRef(t);return b.current=n,()=>{b.current===n&&(b.current=null),n.unref()}},[c,r]);const{props:j,removeInput:v}=Ws({cancelInputOnBlur:!0,cursorState:u,autoFocus:f,ref:d,onCancelInput:e=>{"backspace"!==e&&c.tf.insertText(a+x,{at:b.current?.current??void 0}),"arrowLeft"!==e&&"arrowRight"!==e||c.tf.move({distance:1,reverse:"arrowLeft"===e})}}),[y,w]=e.useState(!1),C=e.useMemo(()=>({filter:n,inputProps:j,inputRef:d,removeInput:v,setHasEmpty:w,showTrigger:i,trigger:a}),[a,i,n,d,j,v,w]),k=As({setValue:t=>e.startTransition(()=>g(t))}),N=k.useState("items");return e.useEffect(()=>{k.getState().activeId||k.setActiveId(k.first())},[N,k]),/* @__PURE__ */ha.jsx("span",{contentEditable:!1,children:/* @__PURE__ */ha.jsx(Os,{open:(N.length>0||y)&&(!s||x.length>0),store:k,children:/* @__PURE__ */ha.jsx(Yc.Provider,{value:C,children:t})})})},Jc=({className:t,ref:r,...n})=>{const{inputProps:s,inputRef:o,showTrigger:i,trigger:a}=e.useContext(Yc),l=Ms().useState("value"),c=K(r,o);/* @__PURE__ */
|
|
264
264
|
return ha.jsxs(ha.Fragment,{children:[i&&a,
|
|
265
265
|
/* @__PURE__ */ha.jsxs("span",{className:"relative min-h-[1lh]",children:[
|
|
266
266
|
/* @__PURE__ */ha.jsx("span",{className:"invisible overflow-hidden text-nowrap","aria-hidden":"true",children:l||""}),
|