@typix-editor/extension-floating-link 1.0.0 → 2.0.0
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/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var O=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var pt=Object.prototype.hasOwnProperty;var dt=(t,e)=>{for(var g in e)O(t,g,{get:e[g],enumerable:!0})},ft=(t,e,g,E)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of ct(e))!pt.call(t,a)&&a!==g&&O(t,a,{get:()=>e[a],enumerable:!(E=st(e,a))||E.enumerable});return t};var ut=t=>ft(O({},"__esModule",{value:!0}),t);var mt={};dt(mt,{FloatingLinkExtension:()=>w});module.exports=ut(mt);var j=require("@lexical/react/LexicalComposerContext"),tt=require("react-dom"),et=require("@typix-editor/react");var v=require("@lexical/link"),C=require("@lexical/utils"),m=require("lexical"),D=require("react"),T=require("@typix-editor/react");function H(t){let[e,g]=(0,D.useState)(t),[E,a]=(0,D.useState)(!1);return(0,D.useEffect)(()=>{function d(){let o=(0,m.$getSelection)();if((0,m.$isRangeSelection)(o)){let s=(0,T.getSelectedNode)(o),k=(0,C.$findMatchingParent)(s,v.$isLinkNode),f=(0,C.$findMatchingParent)(s,v.$isAutoLinkNode);if(!(k||f)){a(!1);return}let R=o.getNodes().filter(n=>!(0,m.$isLineBreakNode)(n)).find(n=>{let h=(0,C.$findMatchingParent)(n,v.$isLinkNode),M=(0,C.$findMatchingParent)(n,v.$isAutoLinkNode);return k&&!k.is(h)||h&&!h.is(k)||f&&!f.is(M)||M&&(!M.is(f)||M.getIsUnlinked())});a(!R)}else if((0,m.$isNodeSelection)(o)){let s=o.getNodes();if(s.length===0){a(!1);return}let k=s[0],f=k.getParent();a((0,v.$isLinkNode)(f)||(0,v.$isLinkNode)(k))}}return(0,C.mergeRegister)(t.registerUpdateListener(({editorState:o})=>{o.read(()=>{d()})}),t.registerCommand(m.SELECTION_CHANGE_COMMAND,(o,s)=>(d(),g(s),!1),m.COMMAND_PRIORITY_CRITICAL),t.registerCommand(m.CLICK_COMMAND,o=>{let s=(0,m.$getSelection)();if((0,m.$isRangeSelection)(s)){let k=(0,T.getSelectedNode)(s),f=(0,C.$findMatchingParent)(k,v.$isLinkNode);if((0,v.$isLinkNode)(f)&&(o.metaKey||o.ctrlKey))return window.open(f.getURL(),"_blank"),!0}return!1},m.COMMAND_PRIORITY_LOW))},[t]),{activeEditor:e,isLink:E,setIsLink:a}}var _=require("@lexical/link"),P=require("@lexical/utils"),u=require("lexical"),l=require("react"),L=require("@typix-editor/react");function K({editor:t,isLink:e,setIsLink:g,verticalOffset:E}){let a=(0,l.useRef)(null),{floatingAnchorElem:d}=(0,L.useRootContext)(),o=(0,l.useRef)(null),[s,k]=(0,l.useState)(""),[f,R]=(0,l.useState)("https://"),[n,h]=(0,l.useState)(!1),[M,$]=(0,l.useState)(null),X=(0,l.useRef)(e);(0,l.useEffect)(()=>{X.current=e},[e]);let S=(0,l.useCallback)(()=>{let c=a.current;if(!X.current&&c&&d){(0,L.setFloatingElemPositionForLinkEditor)(null,c,d);return}let i=(0,u.$getSelection)(),x="";if((0,u.$isRangeSelection)(i)){let y=(0,L.getSelectedNode)(i),N=(0,P.$findMatchingParent)(y,_.$isLinkNode);N?x=N.getURL():(0,_.$isLinkNode)(y)&&(x=y.getURL())}else if((0,u.$isNodeSelection)(i)){let y=i.getNodes();if(y.length>0){let N=y[0],I=N.getParent();(0,_.$isLinkNode)(I)?x=I.getURL():(0,_.$isLinkNode)(N)&&(x=N.getURL())}}k(x);let A=(0,u.getDOMSelection)(t._window),J=document.activeElement;if(c===null)return;let F=t.getRootElement();if(i!==null&&F!==null&&t.isEditable()&&d){let y;if((0,u.$isNodeSelection)(i)){let N=i.getNodes();if(N.length>0){let I=t.getElementByKey(N[0].getKey());I&&(y=I.getBoundingClientRect())}}else A!==null&&F.contains(A.anchorNode)&&(y=A.focusNode?.parentElement?.getBoundingClientRect());y&&(y.y+=E,(0,L.setFloatingElemPositionForLinkEditor)(y,c,d)),$(i)}else(!J||!c.contains(J))&&(F!==null&&d&&(0,L.setFloatingElemPositionForLinkEditor)(null,c,d),$(null),h(!1),k(""));return!0},[d,t,E]);(0,l.useEffect)(()=>{let c=d?.parentElement,i=()=>{t.getEditorState().read(()=>{S()})};return window.addEventListener("resize",i),c&&c.addEventListener("scroll",i),()=>{window.removeEventListener("resize",i),c&&c.removeEventListener("scroll",i)}},[d?.parentElement,t,S]),(0,l.useEffect)(()=>(0,P.mergeRegister)(t.registerUpdateListener(({editorState:c})=>{c.read(()=>{S()})}),t.registerCommand(u.SELECTION_CHANGE_COMMAND,()=>(S(),!1),u.COMMAND_PRIORITY_LOW),t.registerCommand(u.KEY_ESCAPE_COMMAND,()=>e?(g(!1),!0):!1,u.COMMAND_PRIORITY_HIGH)),[t,S,g,e]),(0,l.useEffect)(()=>{t.getEditorState().read(()=>{S()})},[t,S]),(0,l.useEffect)(()=>{n&&o.current&&o.current.focus()},[n,e]),(0,l.useEffect)(()=>{let c=a.current;if(c===null)return;let i=x=>{!c.contains(x.relatedTarget)&&e&&(g(!1),h(!1))};return c.addEventListener("focusout",i),()=>{c.removeEventListener("focusout",i)}},[g,e]);let ot=(0,l.useCallback)(()=>{M!==null&&(f.trim()===""||f==="https://"||(t.update(()=>{t.dispatchCommand(_.TOGGLE_LINK_COMMAND,(0,L.sanitizeUrl)(f));let c=(0,u.$getSelection)();if((0,u.$isRangeSelection)(c)){let i=(0,L.getSelectedNode)(c).getParent();if((0,_.$isAutoLinkNode)(i)){let x=(0,_.$createLinkNode)(i.getURL(),{rel:i.__rel,target:i.__target,title:i.__title});i.replace(x,!0)}}}),R("https://"),h(!1)))},[t,f,M]),it=(0,l.useCallback)(()=>{h(!1),R(s||"https://")},[s]),rt=(0,l.useCallback)(()=>{R(s),h(!0)},[s]),lt=(0,l.useCallback)(()=>{t.dispatchCommand(_.TOGGLE_LINK_COMMAND,null)},[t]),at=f==="https://"||(0,L.validateUrl)(f);return{editorRef:a,renderProps:{isEditing:n,linkUrl:s,editedUrl:f,isValidUrl:at,setEditedUrl:R,submitLink:ot,cancelEdit:it,startEdit:rt,deleteLink:lt,inputRef:o}}}var Z=require("@typix-editor/react");var r=require("react/jsx-runtime"),b={width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};function B(){return(0,r.jsxs)("svg",{...b,"aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),(0,r.jsx)("path",{d:"m15 5 4 4"})]})}function G(){return(0,r.jsxs)("svg",{...b,"aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M3 6h18"}),(0,r.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,r.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),(0,r.jsx)("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),(0,r.jsx)("line",{x1:"14",x2:"14",y1:"11",y2:"17"})]})}function Y(){return(0,r.jsx)("svg",{...b,"aria-hidden":"true",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function z(){return(0,r.jsxs)("svg",{...b,"aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M18 6 6 18"}),(0,r.jsx)("path",{d:"m6 6 12 12"})]})}function V(){return(0,r.jsxs)("svg",{...b,width:12,height:12,"aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M15 3h6v6"}),(0,r.jsx)("path",{d:"M10 14 21 3"}),(0,r.jsx)("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"})]})}function W(){return(0,r.jsxs)("svg",{...b,"aria-hidden":"true",children:[(0,r.jsx)("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),(0,r.jsx)("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}var p=require("react/jsx-runtime");function q({isEditing:t,linkUrl:e,editedUrl:g,isValidUrl:E,setEditedUrl:a,submitLink:d,cancelEdit:o,startEdit:s,deleteLink:k,inputRef:f}){let R=n=>{n.key==="Enter"?(n.preventDefault(),d()):n.key==="Escape"&&(n.preventDefault(),o())};return t?(0,p.jsxs)("div",{className:"typix-floating-link__edit",children:[(0,p.jsxs)("div",{className:"typix-floating-link__input-wrapper",children:[(0,p.jsx)("span",{className:"typix-floating-link__input-icon",children:(0,p.jsx)(W,{})}),(0,p.jsx)("input",{ref:f,className:"typix-floating-link__input",value:g,onChange:n=>a(n.target.value),onKeyDown:R,placeholder:"Paste or type a link...","aria-label":"Link URL",spellCheck:!1,autoComplete:"off"})]}),(0,p.jsxs)("div",{className:"typix-floating-link__actions",children:[(0,p.jsx)("button",{type:"button",className:"typix-floating-link__btn typix-floating-link__btn--cancel","aria-label":"Cancel",title:"Cancel",onClick:o,onMouseDown:n=>n.preventDefault(),children:(0,p.jsx)(z,{})}),(0,p.jsx)("button",{type:"button",className:"typix-floating-link__btn typix-floating-link__btn--confirm","aria-label":"Apply link",title:"Apply",disabled:!E,onClick:n=>{n.preventDefault(),d()},onMouseDown:n=>n.preventDefault(),children:(0,p.jsx)(Y,{})})]})]}):(0,p.jsxs)("div",{className:"typix-floating-link__view",children:[(0,p.jsxs)("a",{className:"typix-floating-link__url",href:(0,Z.sanitizeUrl)(e),target:"_blank",rel:"noopener noreferrer",title:e,children:[(0,p.jsx)("span",{className:"typix-floating-link__url-text",children:e}),(0,p.jsx)(V,{})]}),(0,p.jsx)("div",{className:"typix-floating-link__divider"}),(0,p.jsx)("button",{type:"button",className:"typix-floating-link__btn typix-floating-link__btn--edit","aria-label":"Edit link",title:"Edit",onClick:n=>{n.preventDefault(),s()},onMouseDown:n=>n.preventDefault(),children:(0,p.jsx)(B,{})}),(0,p.jsx)("button",{type:"button",className:"typix-floating-link__btn typix-floating-link__btn--delete","aria-label":"Remove link",title:"Remove",onClick:k,onMouseDown:n=>n.preventDefault(),children:(0,p.jsx)(G,{})})]})}var U=require("react/jsx-runtime");function Q({editor:t,isLink:e,setIsLink:g,children:E,verticalOffset:a}){let{editorRef:d,renderProps:o}=K({editor:t,isLink:e,setIsLink:g,verticalOffset:a});return(0,U.jsx)("div",{ref:d,className:"typix-floating-link",onMouseDown:s=>{s.target!==d.current&&s.preventDefault()},children:e?E?E(o):(0,U.jsx)(q,{...o}):null})}var nt=require("react/jsx-runtime");function w({children:t,verticalOffset:e=40}={}){let[g]=(0,j.useLexicalComposerContext)(),{floatingAnchorElem:E}=(0,et.useRootContext)(),{activeEditor:a,isLink:d,setIsLink:o}=H(g);return E?(0,tt.createPortal)((0,nt.jsx)(Q,{editor:a,isLink:d,setIsLink:o,verticalOffset:e,children:t}),E):null}w.displayName="Typix.FloatingLinkExtension";0&&(module.exports={FloatingLinkExtension});
|
package/dist/index.d.cts
CHANGED
|
@@ -31,5 +31,8 @@ type FloatingLinkExtensionProps = {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
declare function FloatingLinkExtension({ children, verticalOffset, }?: FloatingLinkExtensionProps): JSX.Element | null;
|
|
34
|
+
declare namespace FloatingLinkExtension {
|
|
35
|
+
var displayName: string;
|
|
36
|
+
}
|
|
34
37
|
|
|
35
38
|
export { FloatingLinkExtension, type FloatingLinkExtensionProps, type FloatingLinkRenderProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -31,5 +31,8 @@ type FloatingLinkExtensionProps = {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
declare function FloatingLinkExtension({ children, verticalOffset, }?: FloatingLinkExtensionProps): JSX.Element | null;
|
|
34
|
+
declare namespace FloatingLinkExtension {
|
|
35
|
+
var displayName: string;
|
|
36
|
+
}
|
|
34
37
|
|
|
35
38
|
export { FloatingLinkExtension, type FloatingLinkExtensionProps, type FloatingLinkRenderProps };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import{useLexicalComposerContext as
|
|
2
|
+
import{useLexicalComposerContext as At}from"@lexical/react/LexicalComposerContext";import{createPortal as Ft}from"react-dom";import{useRootContext as Ot}from"@typix-editor/react";import{$isAutoLinkNode as $,$isLinkNode as h}from"@lexical/link";import{$findMatchingParent as C,mergeRegister as ft}from"@lexical/utils";import{$getSelection as X,$isLineBreakNode as ut,$isNodeSelection as mt,$isRangeSelection as J,CLICK_COMMAND as gt,COMMAND_PRIORITY_CRITICAL as Et,COMMAND_PRIORITY_LOW as kt,SELECTION_CHANGE_COMMAND as Lt}from"lexical";import{useEffect as yt,useState as H}from"react";import{getSelectedNode as K}from"@typix-editor/react";function B(t){let[a,u]=H(t),[m,p]=H(!1);return yt(()=>{function l(){let n=X();if(J(n)){let i=K(n),d=C(i,h),s=C(i,$);if(!(d||s)){p(!1);return}let y=n.getNodes().filter(e=>!ut(e)).find(e=>{let E=C(e,h),_=C(e,$);return d&&!d.is(E)||E&&!E.is(d)||s&&!s.is(_)||_&&(!_.is(s)||_.getIsUnlinked())});p(!y)}else if(mt(n)){let i=n.getNodes();if(i.length===0){p(!1);return}let d=i[0],s=d.getParent();p(h(s)||h(d))}}return ft(t.registerUpdateListener(({editorState:n})=>{n.read(()=>{l()})}),t.registerCommand(Lt,(n,i)=>(l(),u(i),!1),Et),t.registerCommand(gt,n=>{let i=X();if(J(i)){let d=K(i),s=C(d,h);if(h(s)&&(n.metaKey||n.ctrlKey))return window.open(s.getURL(),"_blank"),!0}return!1},kt))},[t]),{activeEditor:a,isLink:m,setIsLink:p}}import{$createLinkNode as _t,$isAutoLinkNode as vt,$isLinkNode as I,TOGGLE_LINK_COMMAND as G}from"@lexical/link";import{$findMatchingParent as ht,mergeRegister as xt}from"@lexical/utils";import{$getSelection as Y,$isNodeSelection as z,$isRangeSelection as V,COMMAND_PRIORITY_HIGH as Nt,COMMAND_PRIORITY_LOW as Rt,getDOMSelection as Ct,KEY_ESCAPE_COMMAND as Mt,SELECTION_CHANGE_COMMAND as St}from"lexical";import{useCallback as M,useEffect as x,useRef as F,useState as D}from"react";import{getSelectedNode as W,sanitizeUrl as bt,setFloatingElemPositionForLinkEditor as O,useRootContext as It,validateUrl as Dt}from"@typix-editor/react";function Z({editor:t,isLink:a,setIsLink:u,verticalOffset:m}){let p=F(null),{floatingAnchorElem:l}=It(),n=F(null),[i,d]=D(""),[s,y]=D("https://"),[e,E]=D(!1),[_,T]=D(null),U=F(a);x(()=>{U.current=a},[a]);let v=M(()=>{let r=p.current;if(!U.current&&r&&l){O(null,r,l);return}let o=Y(),k="";if(V(o)){let g=W(o),L=ht(g,I);L?k=L.getURL():I(g)&&(k=g.getURL())}else if(z(o)){let g=o.getNodes();if(g.length>0){let L=g[0],R=L.getParent();I(R)?k=R.getURL():I(L)&&(k=L.getURL())}}d(k);let P=Ct(t._window),w=document.activeElement;if(r===null)return;let A=t.getRootElement();if(o!==null&&A!==null&&t.isEditable()&&l){let g;if(z(o)){let L=o.getNodes();if(L.length>0){let R=t.getElementByKey(L[0].getKey());R&&(g=R.getBoundingClientRect())}}else P!==null&&A.contains(P.anchorNode)&&(g=P.focusNode?.parentElement?.getBoundingClientRect());g&&(g.y+=m,O(g,r,l)),T(o)}else(!w||!r.contains(w))&&(A!==null&&l&&O(null,r,l),T(null),E(!1),d(""));return!0},[l,t,m]);x(()=>{let r=l?.parentElement,o=()=>{t.getEditorState().read(()=>{v()})};return window.addEventListener("resize",o),r&&r.addEventListener("scroll",o),()=>{window.removeEventListener("resize",o),r&&r.removeEventListener("scroll",o)}},[l?.parentElement,t,v]),x(()=>xt(t.registerUpdateListener(({editorState:r})=>{r.read(()=>{v()})}),t.registerCommand(St,()=>(v(),!1),Rt),t.registerCommand(Mt,()=>a?(u(!1),!0):!1,Nt)),[t,v,u,a]),x(()=>{t.getEditorState().read(()=>{v()})},[t,v]),x(()=>{e&&n.current&&n.current.focus()},[e,a]),x(()=>{let r=p.current;if(r===null)return;let o=k=>{!r.contains(k.relatedTarget)&&a&&(u(!1),E(!1))};return r.addEventListener("focusout",o),()=>{r.removeEventListener("focusout",o)}},[u,a]);let at=M(()=>{_!==null&&(s.trim()===""||s==="https://"||(t.update(()=>{t.dispatchCommand(G,bt(s));let r=Y();if(V(r)){let o=W(r).getParent();if(vt(o)){let k=_t(o.getURL(),{rel:o.__rel,target:o.__target,title:o.__title});o.replace(k,!0)}}}),y("https://"),E(!1)))},[t,s,_]),st=M(()=>{E(!1),y(i||"https://")},[i]),ct=M(()=>{y(i),E(!0)},[i]),pt=M(()=>{t.dispatchCommand(G,null)},[t]),dt=s==="https://"||Dt(s);return{editorRef:p,renderProps:{isEditing:e,linkUrl:i,editedUrl:s,isValidUrl:dt,setEditedUrl:y,submitLink:at,cancelEdit:st,startEdit:ct,deleteLink:pt,inputRef:n}}}import{sanitizeUrl as Pt}from"@typix-editor/react";import{jsx as c,jsxs as S}from"react/jsx-runtime";var N={width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};function q(){return S("svg",{...N,"aria-hidden":"true",children:[c("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),c("path",{d:"m15 5 4 4"})]})}function Q(){return S("svg",{...N,"aria-hidden":"true",children:[c("path",{d:"M3 6h18"}),c("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),c("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),c("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),c("line",{x1:"14",x2:"14",y1:"11",y2:"17"})]})}function j(){return c("svg",{...N,"aria-hidden":"true",children:c("polyline",{points:"20 6 9 17 4 12"})})}function tt(){return S("svg",{...N,"aria-hidden":"true",children:[c("path",{d:"M18 6 6 18"}),c("path",{d:"m6 6 12 12"})]})}function et(){return S("svg",{...N,width:12,height:12,"aria-hidden":"true",children:[c("path",{d:"M15 3h6v6"}),c("path",{d:"M10 14 21 3"}),c("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"})]})}function nt(){return S("svg",{...N,"aria-hidden":"true",children:[c("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),c("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}import{jsx as f,jsxs as b}from"react/jsx-runtime";function ot({isEditing:t,linkUrl:a,editedUrl:u,isValidUrl:m,setEditedUrl:p,submitLink:l,cancelEdit:n,startEdit:i,deleteLink:d,inputRef:s}){let y=e=>{e.key==="Enter"?(e.preventDefault(),l()):e.key==="Escape"&&(e.preventDefault(),n())};return t?b("div",{className:"typix-floating-link__edit",children:[b("div",{className:"typix-floating-link__input-wrapper",children:[f("span",{className:"typix-floating-link__input-icon",children:f(nt,{})}),f("input",{ref:s,className:"typix-floating-link__input",value:u,onChange:e=>p(e.target.value),onKeyDown:y,placeholder:"Paste or type a link...","aria-label":"Link URL",spellCheck:!1,autoComplete:"off"})]}),b("div",{className:"typix-floating-link__actions",children:[f("button",{type:"button",className:"typix-floating-link__btn typix-floating-link__btn--cancel","aria-label":"Cancel",title:"Cancel",onClick:n,onMouseDown:e=>e.preventDefault(),children:f(tt,{})}),f("button",{type:"button",className:"typix-floating-link__btn typix-floating-link__btn--confirm","aria-label":"Apply link",title:"Apply",disabled:!m,onClick:e=>{e.preventDefault(),l()},onMouseDown:e=>e.preventDefault(),children:f(j,{})})]})]}):b("div",{className:"typix-floating-link__view",children:[b("a",{className:"typix-floating-link__url",href:Pt(a),target:"_blank",rel:"noopener noreferrer",title:a,children:[f("span",{className:"typix-floating-link__url-text",children:a}),f(et,{})]}),f("div",{className:"typix-floating-link__divider"}),f("button",{type:"button",className:"typix-floating-link__btn typix-floating-link__btn--edit","aria-label":"Edit link",title:"Edit",onClick:e=>{e.preventDefault(),i()},onMouseDown:e=>e.preventDefault(),children:f(q,{})}),f("button",{type:"button",className:"typix-floating-link__btn typix-floating-link__btn--delete","aria-label":"Remove link",title:"Remove",onClick:d,onMouseDown:e=>e.preventDefault(),children:f(Q,{})})]})}import{jsx as it}from"react/jsx-runtime";function rt({editor:t,isLink:a,setIsLink:u,children:m,verticalOffset:p}){let{editorRef:l,renderProps:n}=Z({editor:t,isLink:a,setIsLink:u,verticalOffset:p});return it("div",{ref:l,className:"typix-floating-link",onMouseDown:i=>{i.target!==l.current&&i.preventDefault()},children:a?m?m(n):it(ot,{...n}):null})}import{jsx as Tt}from"react/jsx-runtime";function lt({children:t,verticalOffset:a=40}={}){let[u]=At(),{floatingAnchorElem:m}=Ot(),{activeEditor:p,isLink:l,setIsLink:n}=B(u);return m?Ft(Tt(rt,{editor:p,isLink:l,setIsLink:n,verticalOffset:a,children:t}),m):null}lt.displayName="Typix.FloatingLinkExtension";export{lt as FloatingLinkExtension};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typix-editor/extension-floating-link",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Floating link editor extension for Typix",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Diyorbek Juraev <mrdiyorbekjuraev@gmail.com>",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": "^18.2.0 || ^19.0.0-0",
|
|
29
|
-
"react-dom": "^18.2.0 || ^19.0.0-0"
|
|
29
|
+
"react-dom": "^18.2.0 || ^19.0.0-0",
|
|
30
|
+
"@typix-editor/react": "2.0.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@lexical/react": "^0.39.0",
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
"lexical": "^0.39.0",
|
|
38
39
|
"react": "^18.2.0 || ^19.0.0-0",
|
|
39
40
|
"react-dom": "^18.2.0 || ^19.0.0-0",
|
|
40
|
-
"@typix-editor/react": "
|
|
41
|
+
"@typix-editor/react": "2.0.0"
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
44
|
"build": "tsup",
|