@univerjs/docs-hyper-link-ui 0.6.0 → 0.6.1-nightly.202502211606

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/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Se=Object.defineProperty;var ke=(e,n,t)=>n in e?Se(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var P=(e,n,t)=>ke(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),Le=require("@univerjs/docs-hyper-link"),xe=require("@univerjs/engine-render"),C=require("@univerjs/docs"),K=require("@univerjs/docs-ui"),D=require("rxjs"),l=require("react/jsx-runtime"),S=require("@univerjs/design"),u=require("@univerjs/ui"),_=require("react"),Oe="docs-hyper-link-ui.config",ce={},le={type:o.CommandType.COMMAND,id:"docs.command.add-hyper-link",async handler(e,n){if(!n)return!1;const{payload:t,unitId:i,selections:r}=n,s=e.get(o.ICommandService),c=o.generateRandomId(),d=C.addCustomRangeBySelectionFactory(e,{rangeId:c,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:t},unitId:i,selections:r});return d?s.syncExecuteCommand(d.id,d.params):!1}},ue={id:"docs.command.update-hyper-link",type:o.CommandType.COMMAND,handler(e,n){var v;if(!n)return!1;const{unitId:t,payload:i,segmentId:r,linkId:s}=n,c=e.get(o.ICommandService),d=e.get(o.IUniverInstanceService),h=e.get(C.DocSelectionManagerService).getActiveTextRange(),I=d.getUnit(t,o.UniverInstanceType.UNIVER_DOC);if(!h||!I)return!1;const f=(v=o.getBodySlice(I.getSelfOrHeaderFooterModel(r).getBody(),h.startOffset,h.endOffset).textRuns)==null?void 0:v[0];f&&(f.ed=n.label.length+1);const a=C.replaceSelectionFactory(e,{unitId:t,body:{dataStream:`${n.label}`,customRanges:[{rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:n.label.length+1,properties:{url:i}}],textRuns:f?[f]:void 0},selection:{startOffset:h.startOffset,endOffset:h.endOffset,collapsed:!1,segmentId:r}});return a?c.syncExecuteCommand(a.id,a.params):!1}},Pe="univer-docs-link-edit",De="univer-docs-link-edit-buttons",Re="univer-docs-link-edit-button",T={docsLinkEdit:Pe,docsLinkEditButtons:De,docsLinkEditButton:Re};function Ee(e){return/^[a-zA-Z]+:\/\//.test(e)}function Me(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function Ue(e){return Ee(e)?e:Me(e)?`mailto://${e}`:`https://${e}`}const j=()=>{const e=u.useDependency(L),n=u.useDependency(o.LocaleService),t=u.useObservable(e.editingLink$),i=u.useDependency(o.ICommandService),r=u.useDependency(o.IUniverInstanceService),s=u.useDependency(C.DocSelectionManagerService),[c,d]=_.useState(""),[g,h]=_.useState(""),[I,m]=_.useState(!1),f=o.Tools.isLegalUrl(c),a=t?r.getUnit(t.unitId,o.UniverInstanceType.UNIVER_DOC):r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);_.useEffect(()=>{var Q,X,ee,ne,te,ie,re,oe,se;const p=s.getActiveTextRange();if(!p)return;if(t){const b=(Q=a==null?void 0:a.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:Q.getBody(),w=(X=b==null?void 0:b.customRanges)==null?void 0:X.find(A=>(t==null?void 0:t.linkId)===A.rangeId&&A.startIndex===t.startIndex&&A.endIndex===t.endIndex);a&&w&&(d((ne=(ee=w.properties)==null?void 0:ee.url)!=null?ne:""),h(o.BuildTextUtils.transform.getPlainText(o.getBodySlice(b,w.startIndex,w.endIndex+1).dataStream)));return}const x=(te=a==null?void 0:a.getSelfOrHeaderFooterModel(p.segmentId))==null?void 0:te.getBody(),J=x?p:null,U=J&&((re=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(J,(ie=x==null?void 0:x.customRanges)!=null?ie:[]))==null?void 0:re[0]);a&&U&&d((se=(oe=U==null?void 0:U.properties)==null?void 0:oe.url)!=null?se:"")},[a,t,s,r]);const v=()=>{e.hideEditPopup()},k=()=>{if(m(!0),!f||!a)return;const p=Ue(c);if(!t)i.executeCommand(le.id,{unitId:a.getUnitId(),payload:p});else{if(!g)return;i.executeCommand(ue.id,{unitId:a.getUnitId(),payload:p,linkId:t.linkId,label:g,segmentId:t.segmentId})}e.hideEditPopup()};if(a)return l.jsxs("div",{className:T.docsLinkEdit,children:[l.jsxs("div",{children:[t?l.jsx(S.FormLayout,{label:n.t("docLink.edit.label"),error:I&&!g?n.t("docLink.edit.labelError"):"",children:l.jsx(S.Input,{value:g,onChange:h,autoFocus:!0,onKeyDown:p=>{p.keyCode===u.KeyCode.ENTER&&k()}})}):null,l.jsx(S.FormLayout,{label:n.t("docLink.edit.address"),error:I&&!f?n.t("docLink.edit.addressError"):"",children:l.jsx(S.Input,{value:c,onChange:d,autoFocus:!0,onKeyDown:p=>{p.keyCode===u.KeyCode.ENTER&&k()}})})]}),l.jsxs("div",{className:T.docsLinkEditButtons,children:[l.jsx(S.Button,{className:T.docsLinkEditButton,onClick:v,children:n.t("docLink.edit.cancel")}),l.jsx(S.Button,{disabled:!c,className:T.docsLinkEditButton,type:"primary",onClick:k,children:n.t("docLink.edit.confirm")})]})]})};j.componentKey="docs-hyper-link-edit";var y=function(){return y=Object.assign||function(e){for(var n,t=1,i=arguments.length;t<i;t++){n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},y.apply(this,arguments)},be=function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)n.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(t[i[r]]=e[i[r]]);return t},M=_.forwardRef(function(e,n){var t=e.icon,i=e.id,r=e.className,s=e.extend,c=be(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),g=_.useRef("_".concat(Ne()));return pe(t,"".concat(i),{defIds:t.defIds,idSuffix:g.current},y({ref:n,className:d},c),s)});function pe(e,n,t,i,r){return _.createElement(e.tag,y(y({key:n},we(e,t,r)),i),(Te(e,t).children||[]).map(function(s,c){return pe(s,"".concat(n,"-").concat(e.tag,"-").concat(c),t,void 0,r)}))}function we(e,n,t){var i=y({},e.attrs);t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1);var r=n.defIds;return!r||r.length===0||(e.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+n.idSuffix),Object.entries(i).forEach(function(s){var c=s[0],d=s[1];typeof d=="string"&&(i[c]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),i}function Te(e,n){var t,i=n.defIds;return!i||i.length===0?e:e.tag==="defs"&&(!((t=e.children)===null||t===void 0)&&t.length)?y(y({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.indexOf(r.attrs.id)>-1?y(y({},r),{attrs:y(y({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):e}function Ne(){return Math.random().toString(36).substring(2,8)}M.displayName="UniverIcon";var je={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ge=_.forwardRef(function(e,n){return _.createElement(M,Object.assign({},e,{id:"copy-single",ref:n,icon:je}))});ge.displayName="CopySingle";var He={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},z=_.forwardRef(function(e,n){return _.createElement(M,Object.assign({},e,{id:"link-single",ref:n,icon:He}))});z.displayName="LinkSingle";var $e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},he=_.forwardRef(function(e,n){return _.createElement(M,Object.assign({},e,{id:"unlink-single",ref:n,icon:$e}))});he.displayName="UnlinkSingle";var Be={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},ve=_.forwardRef(function(e,n){return _.createElement(M,Object.assign({},e,{id:"write-single",ref:n,icon:Be}))});ve.displayName="WriteSingle";function fe(e){var n,t,i="";if(typeof e=="string"||typeof e=="number")i+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(n=0;n<r;n++)e[n]&&(t=fe(e[n]))&&(i&&(i+=" "),i+=t)}else for(t in e)e[t]&&(i&&(i+=" "),i+=t);return i}function de(){for(var e,n,t=0,i="",r=arguments.length;t<r;t++)(e=arguments[t])&&(n=fe(e))&&(i&&(i+=" "),i+=n);return i}const Ie={type:o.CommandType.COMMAND,id:"docs.command.delete-hyper-link",async handler(e,n){if(!n)return!1;const{unitId:t,linkId:i,segmentId:r}=n,s=e.get(o.ICommandService),c=C.deleteCustomRangeFactory(e,{unitId:t,rangeId:i,segmentId:r});return c?await s.syncExecuteCommand(c.id,c.params):!1}},me=e=>{const n=e.get(C.DocSelectionManagerService),t=e.get(o.IUniverInstanceService),i=n.getTextRanges();if(!(i!=null&&i.length))return!0;const r=i[0];return!!(!t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC)||!r||r.collapsed)},R={type:o.CommandType.OPERATION,id:"doc.operation.show-hyper-link-edit-popup",handler(e,n){var c;const t=n==null?void 0:n.link,i=e.get(o.IUniverInstanceService);if(me(e)&&!t)return!1;const r=e.get(L),s=(t==null?void 0:t.unitId)||((c=i.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC))==null?void 0:c.getUnitId());return s?(r.showEditPopup(s,t),!0):!1}},Z={type:o.CommandType.OPERATION,id:"doc.operation.toggle-hyper-link-info-popup",handler(e,n){const t=e.get(L);return n?(t.showInfoPopup(n),!0):(t.hideInfoPopup(),!0)}},_e={type:o.CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(e,n){var h,I,m;if(!n)return!1;const{unitId:t,linkId:i,segmentId:r}=n,c=e.get(o.IUniverInstanceService).getUnit(t,o.UniverInstanceType.UNIVER_DOC),d=c==null?void 0:c.getSelfOrHeaderFooterModel(r).getBody(),g=(m=(I=(h=d==null?void 0:d.customRanges)==null?void 0:h.find(f=>f.rangeId===i&&f.rangeType===o.CustomRangeType.HYPERLINK))==null?void 0:I.properties)==null?void 0:m.url;return g&&window.open(g,"_blank","noopener noreferrer"),!0}},Ke="univer-doc-link",Ae="univer-doc-link-type",Fe="univer-doc-link-content",Ve="univer-doc-link-url",Ye="univer-doc-link-operations",qe="univer-doc-link-operation",O={docLink:Ke,docLinkType:Ae,docLinkContent:Fe,docLinkUrl:Ve,docLinkOperations:Ye,docLinkOperation:qe},H=()=>{var k,p;const e=u.useDependency(L),n=u.useDependency(o.ICommandService),t=u.useDependency(u.IMessageService),i=u.useDependency(o.LocaleService),r=u.useObservable(e.showingLink$),s=u.useDependency(o.IUniverInstanceService);if(!r)return null;const{unitId:c,linkId:d,segmentId:g,startIndex:h,endIndex:I}=r,m=s.getUnit(c,o.UniverInstanceType.UNIVER_DOC),f=m==null?void 0:m.getSelfOrHeaderFooterModel(g).getBody(),a=(k=f==null?void 0:f.customRanges)==null?void 0:k.find(x=>x.rangeId===d&&x.rangeType===o.CustomRangeType.HYPERLINK&&x.startIndex===h&&x.endIndex===I);if(!a)return null;const v=(p=a.properties)==null?void 0:p.url;return l.jsxs("div",{className:O.docLink,onClick:()=>{e.hideInfoPopup()},children:[l.jsxs("div",{className:de(O.docLinkContent),onClick:()=>window.open(v),children:[l.jsx("div",{className:O.docLinkType,children:l.jsx(z,{})}),l.jsx(S.Tooltip,{showIfEllipsis:!0,title:v,children:l.jsx("span",{className:O.docLinkUrl,children:v})})]}),l.jsxs("div",{className:O.docLinkOperations,children:[l.jsx("div",{className:de(O.docLinkOperation),onClick:()=>{navigator.clipboard.writeText(v),t.show({content:i.t("docLink.info.coped"),type:S.MessageType.Info})},children:l.jsx(S.Tooltip,{placement:"bottom",title:i.t("docLink.info.copy"),children:l.jsx(ge,{})})}),l.jsx("div",{className:O.docLinkOperation,onClick:()=>{n.executeCommand(R.id,{link:r})},children:l.jsx(S.Tooltip,{placement:"bottom",title:i.t("docLink.info.edit"),children:l.jsx(ve,{})})}),l.jsx("div",{className:O.docLinkOperation,onClick:()=>{n.executeCommand(Ie.id,{unitId:c,linkId:a.rangeId,segmentId:g})},children:l.jsx(S.Tooltip,{placement:"bottom",title:i.t("docLink.info.cancel"),children:l.jsx(he,{})})})]})]})};H.componentKey="univer.doc.link-info-popup";var Ze=Object.getOwnPropertyDescriptor,We=(e,n,t,i)=>{for(var r=i>1?void 0:i?Ze(n,t):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},F=(e,n)=>(t,i)=>n(t,i,e);let L=class extends o.Disposable{constructor(n,t,i){super();P(this,"_editingLink$",new D.BehaviorSubject(null));P(this,"_showingLink$",new D.BehaviorSubject(null));P(this,"editingLink$",this._editingLink$.asObservable());P(this,"showingLink$",this._showingLink$.asObservable());P(this,"_editPopup",null);P(this,"_infoPopup",null);this._docCanvasPopupManagerService=n,this._textSelectionManagerService=t,this._univerInstanceService=i,this.disposeWithMe(()=>{this._editingLink$.complete(),this._showingLink$.complete()})}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(n,t){this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(t);const i=this._textSelectionManagerService.getTextRanges({unitId:n,subUnitId:n});let r=i==null?void 0:i[i.length-1];if(t){const{segmentId:s,segmentPage:c,startIndex:d,endIndex:g}=t;r={collapsed:!1,startOffset:d,endOffset:g+1,segmentId:s,segmentPage:c},this._textSelectionManagerService.replaceDocRanges([{startOffset:d,endOffset:g+1}])}return r?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(r,{componentKey:j.componentKey,direction:"bottom"},n),this._editPopup):null}hideEditPopup(){var n;this._editingLink$.next(null),(n=this._editPopup)==null||n.dispose()}showInfoPopup(n){var h,I,m,f,a,v;const{linkId:t,unitId:i,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}=n;if(!(((h=this.showing)==null?void 0:h.linkId)===t&&((I=this.showing)==null?void 0:I.unitId)===i&&((m=this.showing)==null?void 0:m.segmentId)===r&&((f=this.showing)==null?void 0:f.segmentPage)===s&&((a=this.showing)==null?void 0:a.startIndex)===c&&((v=this.showing)==null?void 0:v.endIndex)===d||(this._infoPopup&&this._infoPopup.dispose(),!this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_DOC))))return this._showingLink$.next({unitId:i,linkId:t,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}),this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:c,endOffset:d+1,segmentId:r,segmentPage:s},{componentKey:H.componentKey,direction:"top-center",multipleDirection:"top",onClickOutside:()=>{this.hideInfoPopup()}},i),this._infoPopup}hideInfoPopup(){var n;this._showingLink$.next(null),(n=this._infoPopup)==null||n.dispose()}};L=We([F(0,o.Inject(K.DocCanvasPopManagerService)),F(1,o.Inject(C.DocSelectionManagerService)),F(2,o.IUniverInstanceService)],L);var Ge=Object.getOwnPropertyDescriptor,ze=(e,n,t,i)=>{for(var r=i>1?void 0:i?Ge(n,t):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},V=(e,n)=>(t,i)=>n(t,i,e);let $=class extends o.Disposable{constructor(e,n,t){super(),this._commandService=e,this._univerInstanceService=n,this._docHyperLinkService=t,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var n,t,i;if(e.id===C.SetTextSelectionsOperation.id){const r=e.params,{unitId:s,ranges:c,segmentId:d}=r,g=this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_DOC),h=c[0];if(h&&g){const{startOffset:I,endOffset:m,collapsed:f,segmentPage:a}=h,v=(t=(n=g.getSelfOrHeaderFooterModel(d))==null?void 0:n.getBody())==null?void 0:t.customRanges;if(f){const k=(i=v==null?void 0:v.findIndex(p=>p.startIndex<I&&p.endIndex>m-1))!=null?i:-1;if(k>-1){const p=v[k];this._docHyperLinkService.showInfoPopup({unitId:s,linkId:p.rangeId,segmentId:d,segmentPage:a,startIndex:p.startIndex,endIndex:p.endIndex});return}}else if(v==null?void 0:v.find(p=>p.startIndex<=I&&p.endIndex>=m-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};$=ze([V(0,o.ICommandService),V(1,o.IUniverInstanceService),V(2,o.Inject(L))],$);var Je=Object.getOwnPropertyDescriptor,Qe=(e,n,t,i)=>{for(var r=i>1?void 0:i?Je(n,t):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},E=(e,n)=>(t,i)=>n(t,i,e);let W=class extends o.Disposable{constructor(e,n,t,i,r,s){super(),this._context=e,this._docEventManagerService=n,this._commandService=t,this._hyperLinkPopupService=i,this._docSkeletonManagerService=r,this._docSelectionManagerService=s,!(this._context.unitId===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY||this._context.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)&&(this._initHover(),this._initClick())}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(Z.id)}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(e=>{var r;const n=e.find(s=>s.range.rangeType===o.CustomRangeType.HYPERLINK),t=this._docSelectionManagerService.getTextRanges(),i=t==null?void 0:t[0].segmentId;if(((r=n==null?void 0:n.segmentId)!=null?r:"")!==i){this._hideInfoPopup();return}n?this._commandService.executeCommand(Z.id,{unitId:this._context.unitId,linkId:n.range.rangeId,segmentId:n.segmentId,segmentPage:n.segmentPageIndex,rangeId:n.range.rangeId,startIndex:n.range.startIndex,endIndex:n.range.endIndex}):this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(e=>{const n=e.range;n&&this._commandService.executeCommand(_e.id,{unitId:this._context.unitId,linkId:n.rangeId,segmentId:e.segmentId})}))}};W=Qe([E(1,o.Inject(K.DocEventManagerService)),E(2,o.ICommandService),E(3,o.Inject(L)),E(4,o.Inject(C.DocSkeletonManagerService)),E(5,o.Inject(C.DocSelectionManagerService))],W);var Xe=Object.getOwnPropertyDescriptor,en=(e,n,t,i)=>{for(var r=i>1?void 0:i?Xe(n,t):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},Y=(e,n)=>(t,i)=>n(t,i,e);let G=class extends o.Disposable{constructor(e,n,t,i){super(),this._context=e,this._docInterceptorService=n,this._hyperLinkService=t,this._docRenderController=i,this._init(),this._initReRender()}_init(){this._docInterceptorService.intercept(C.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:(e,n,t)=>{if(!e)return t(e);const{unitId:i,index:r}=n,s=this._hyperLinkService.showing;if(!s)return t({...e,active:!1});const{linkId:c,unitId:d,startIndex:g,endIndex:h}=s,I=d===i&&e.rangeId===c&&r>=g&&r<=h;return t({...e,active:I})}})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(D.distinctUntilChanged((e,n)=>(e==null?void 0:e.linkId)===(n==null?void 0:n.linkId)&&(e==null?void 0:e.unitId)===(n==null?void 0:n.unitId)&&(e==null?void 0:e.startIndex)===(n==null?void 0:n.startIndex)),D.pairwise()).subscribe(([e,n])=>{n?n.unitId===this._context.unitId&&this._docRenderController.reRender(n.unitId):e&&e.unitId===this._context.unitId&&this._docRenderController.reRender(e.unitId)}))}};G=en([Y(1,o.Inject(C.DocInterceptorService)),Y(2,o.Inject(L)),Y(3,o.Inject(K.DocRenderController))],G);const Ce="doc-hyper-link-icon";function ae(e){return{id:R.id,type:u.MenuItemType.BUTTON,icon:Ce,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:u.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC),disabled$:new D.Observable(function(n){const i=e.get(C.DocSelectionManagerService).textSelection$.pipe(D.debounceTime(16)).subscribe(()=>{n.next(me(e))});return()=>{i.unsubscribe()}})}}const nn={id:R.id,binding:u.MetaKeys.CTRL_COMMAND|u.KeyCode.K,description:"docLink.menu.tooltip",preconditions:K.whenDocAndEditorFocused},tn={[u.RibbonStartGroup.OTHERS]:{[R.id]:{order:0,menuItemFactory:ae}},[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.DATA]:{[R.id]:{order:0,menuItemFactory:ae}}}};var rn=Object.getOwnPropertyDescriptor,on=(e,n,t,i)=>{for(var r=i>1?void 0:i?rn(n,t):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},N=(e,n)=>(t,i)=>n(t,i,e);let B=class extends o.Disposable{constructor(e,n,t,i){super(),this._componentManager=e,this._commandService=n,this._menuManagerService=t,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[j,j.componentKey],[H,H.componentKey],[z,Ce]].forEach(([e,n])=>{this._componentManager.register(n,e)})}_initCommands(){[le,ue,Ie,R,Z,_e].forEach(e=>{this._commandService.registerCommand(e)})}_initShortcut(){[nn].forEach(e=>{this._shortcutService.registerShortcut(e)})}_initMenus(){this._menuManagerService.mergeMenu(tn)}};B=on([N(0,o.Inject(u.ComponentManager)),N(1,o.ICommandService),N(2,u.IMenuManagerService),N(3,u.IShortcutService)],B);const sn="DOC_HYPER_LINK_UI_PLUGIN";var cn=Object.defineProperty,dn=Object.getOwnPropertyDescriptor,an=(e,n,t)=>n in e?cn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,ln=(e,n,t,i)=>{for(var r=i>1?void 0:i?dn(n,t):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},q=(e,n)=>(t,i)=>n(t,i,e),ye=(e,n,t)=>an(e,typeof n!="symbol"?n+"":n,t);exports.UniverDocsHyperLinkUIPlugin=class extends o.Plugin{constructor(n=ce,t,i,r){super(),this._config=n,this._injector=t,this._renderManagerSrv=i,this._configService=r;const{menu:s,...c}=o.merge({},ce,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Oe,c)}onStarting(){[[L],[B],[$]].forEach(t=>{this._injector.add(t)}),this._injector.get(B)}onReady(){this._injector.get($)}onRendered(){this._initRenderModule()}_initRenderModule(){[[G],[W]].forEach(n=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,n)})}};ye(exports.UniverDocsHyperLinkUIPlugin,"pluginName",sn);ye(exports.UniverDocsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC);exports.UniverDocsHyperLinkUIPlugin=ln([o.DependentOn(Le.UniverDocsHyperLinkPlugin),q(1,o.Inject(o.Injector)),q(2,xe.IRenderManagerService),q(3,o.IConfigService)],exports.UniverDocsHyperLinkUIPlugin);
1
+ "use strict";var Se=Object.defineProperty;var ke=(n,e,t)=>e in n?Se(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var P=(n,e,t)=>ke(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),Le=require("@univerjs/docs-hyper-link"),xe=require("@univerjs/engine-render"),C=require("@univerjs/docs"),K=require("@univerjs/docs-ui"),D=require("rxjs"),l=require("react/jsx-runtime"),S=require("@univerjs/design"),u=require("@univerjs/ui"),_=require("react"),Oe="docs-hyper-link-ui.config",ce={},le={type:o.CommandType.COMMAND,id:"docs.command.add-hyper-link",async handler(n,e){if(!e)return!1;const{payload:t,unitId:i,selections:r}=e,s=n.get(o.ICommandService),c=o.generateRandomId(),d=C.addCustomRangeBySelectionFactory(n,{rangeId:c,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:t},unitId:i,selections:r});return d?s.syncExecuteCommand(d.id,d.params):!1}},ue={id:"docs.command.update-hyper-link",type:o.CommandType.COMMAND,handler(n,e){var f;if(!e)return!1;const{unitId:t,payload:i,segmentId:r,linkId:s}=e,c=n.get(o.ICommandService),d=n.get(o.IUniverInstanceService),h=n.get(C.DocSelectionManagerService).getActiveTextRange(),I=d.getUnit(t,o.UniverInstanceType.UNIVER_DOC);if(!h||!I)return!1;const v=(f=o.getBodySlice(I.getSelfOrHeaderFooterModel(r).getBody(),h.startOffset,h.endOffset).textRuns)==null?void 0:f[0];v&&(v.ed=e.label.length+1);const a=C.replaceSelectionFactory(n,{unitId:t,body:{dataStream:`${e.label}`,customRanges:[{rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:e.label.length+1,properties:{url:i}}],textRuns:v?[v]:void 0},selection:{startOffset:h.startOffset,endOffset:h.endOffset,collapsed:!1,segmentId:r}});return a?c.syncExecuteCommand(a.id,a.params):!1}},Pe="univer-docs-link-edit",De="univer-docs-link-edit-buttons",Re="univer-docs-link-edit-button",T={docsLinkEdit:Pe,docsLinkEditButtons:De,docsLinkEditButton:Re};function Ee(n){return/^[a-zA-Z]+:\/\//.test(n)}function Me(n){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(n)}function Ue(n){return Ee(n)?n:Me(n)?`mailto://${n}`:`https://${n}`}const N=()=>{const n=u.useDependency(L),e=u.useDependency(o.LocaleService),t=u.useObservable(n.editingLink$),i=u.useDependency(o.ICommandService),r=u.useDependency(o.IUniverInstanceService),s=u.useDependency(C.DocSelectionManagerService),[c,d]=_.useState(""),[g,h]=_.useState(""),[I,m]=_.useState(!1),v=o.Tools.isLegalUrl(c),a=t?r.getUnit(t.unitId,o.UniverInstanceType.UNIVER_DOC):r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);_.useEffect(()=>{var Q,X,ee,ne,te,ie,re,oe,se;const p=s.getActiveTextRange();if(!p)return;if(t){const b=(Q=a==null?void 0:a.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:Q.getBody(),w=(X=b==null?void 0:b.customRanges)==null?void 0:X.find(A=>(t==null?void 0:t.linkId)===A.rangeId&&A.startIndex===t.startIndex&&A.endIndex===t.endIndex);a&&w&&(d((ne=(ee=w.properties)==null?void 0:ee.url)!=null?ne:""),h(o.BuildTextUtils.transform.getPlainText(o.getBodySlice(b,w.startIndex,w.endIndex+1).dataStream)));return}const x=(te=a==null?void 0:a.getSelfOrHeaderFooterModel(p.segmentId))==null?void 0:te.getBody(),J=x?p:null,U=J&&((re=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(J,(ie=x==null?void 0:x.customRanges)!=null?ie:[]))==null?void 0:re[0]);a&&U&&d((se=(oe=U==null?void 0:U.properties)==null?void 0:oe.url)!=null?se:"")},[a,t,s,r]);const f=()=>{n.hideEditPopup()},k=()=>{if(m(!0),!v||!a)return;const p=Ue(c);if(!t)i.executeCommand(le.id,{unitId:a.getUnitId(),payload:p});else{if(!g)return;i.executeCommand(ue.id,{unitId:a.getUnitId(),payload:p,linkId:t.linkId,label:g,segmentId:t.segmentId})}n.hideEditPopup()};if(a)return l.jsxs("div",{className:T.docsLinkEdit,children:[l.jsxs("div",{children:[t?l.jsx(S.FormLayout,{label:e.t("docLink.edit.label"),error:I&&!g?e.t("docLink.edit.labelError"):"",children:l.jsx(S.Input,{value:g,onChange:h,autoFocus:!0,onKeyDown:p=>{p.keyCode===u.KeyCode.ENTER&&k()}})}):null,l.jsx(S.FormLayout,{label:e.t("docLink.edit.address"),error:I&&!v?e.t("docLink.edit.addressError"):"",children:l.jsx(S.Input,{value:c,onChange:d,autoFocus:!0,onKeyDown:p=>{p.keyCode===u.KeyCode.ENTER&&k()}})})]}),l.jsxs("div",{className:T.docsLinkEditButtons,children:[l.jsx(S.Button,{className:T.docsLinkEditButton,onClick:f,children:e.t("docLink.edit.cancel")}),l.jsx(S.Button,{disabled:!c,className:T.docsLinkEditButton,type:"primary",onClick:k,children:e.t("docLink.edit.confirm")})]})]})};N.componentKey="docs-hyper-link-edit";var y=function(){return y=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},y.apply(this,arguments)},be=function(n,e){var t={};for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(n);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(n,i[r])&&(t[i[r]]=n[i[r]]);return t},M=_.forwardRef(function(n,e){var t=n.icon,i=n.id,r=n.className,s=n.extend,c=be(n,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),g=_.useRef("_".concat(je()));return pe(t,"".concat(i),{defIds:t.defIds,idSuffix:g.current},y({ref:e,className:d},c),s)});function pe(n,e,t,i,r){return _.createElement(n.tag,y(y({key:e},we(n,t,r)),i),(Te(n,t).children||[]).map(function(s,c){return pe(s,"".concat(e,"-").concat(n.tag,"-").concat(c),t,void 0,r)}))}function we(n,e,t){var i=y({},n.attrs);t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1),n.tag==="mask"&&i.id&&(i.id=i.id+e.idSuffix),Object.entries(i).forEach(function(s){var c=s[0],d=s[1];c==="mask"&&typeof d=="string"&&(i[c]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var r=e.defIds;return!r||r.length===0||(n.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(s){var c=s[0],d=s[1];typeof d=="string"&&(i[c]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function Te(n,e){var t,i=e.defIds;return!i||i.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?y(y({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.indexOf(r.attrs.id)>-1?y(y({},r),{attrs:y(y({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):n}function je(){return Math.random().toString(36).substring(2,8)}M.displayName="UniverIcon";var Ne={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ge=_.forwardRef(function(n,e){return _.createElement(M,Object.assign({},n,{id:"copy-single",ref:e,icon:Ne}))});ge.displayName="CopySingle";var He={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},z=_.forwardRef(function(n,e){return _.createElement(M,Object.assign({},n,{id:"link-single",ref:e,icon:He}))});z.displayName="LinkSingle";var $e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},he=_.forwardRef(function(n,e){return _.createElement(M,Object.assign({},n,{id:"unlink-single",ref:e,icon:$e}))});he.displayName="UnlinkSingle";var Be={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},fe=_.forwardRef(function(n,e){return _.createElement(M,Object.assign({},n,{id:"write-single",ref:e,icon:Be}))});fe.displayName="WriteSingle";function ve(n){var e,t,i="";if(typeof n=="string"||typeof n=="number")i+=n;else if(typeof n=="object")if(Array.isArray(n)){var r=n.length;for(e=0;e<r;e++)n[e]&&(t=ve(n[e]))&&(i&&(i+=" "),i+=t)}else for(t in n)n[t]&&(i&&(i+=" "),i+=t);return i}function de(){for(var n,e,t=0,i="",r=arguments.length;t<r;t++)(n=arguments[t])&&(e=ve(n))&&(i&&(i+=" "),i+=e);return i}const Ie={type:o.CommandType.COMMAND,id:"docs.command.delete-hyper-link",async handler(n,e){if(!e)return!1;const{unitId:t,linkId:i,segmentId:r}=e,s=n.get(o.ICommandService),c=C.deleteCustomRangeFactory(n,{unitId:t,rangeId:i,segmentId:r});return c?await s.syncExecuteCommand(c.id,c.params):!1}},me=n=>{const e=n.get(C.DocSelectionManagerService),t=n.get(o.IUniverInstanceService),i=e.getTextRanges();if(!(i!=null&&i.length))return!0;const r=i[0];return!!(!t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC)||!r||r.collapsed)},R={type:o.CommandType.OPERATION,id:"doc.operation.show-hyper-link-edit-popup",handler(n,e){var c;const t=e==null?void 0:e.link,i=n.get(o.IUniverInstanceService);if(me(n)&&!t)return!1;const r=n.get(L),s=(t==null?void 0:t.unitId)||((c=i.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC))==null?void 0:c.getUnitId());return s?(r.showEditPopup(s,t),!0):!1}},Z={type:o.CommandType.OPERATION,id:"doc.operation.toggle-hyper-link-info-popup",handler(n,e){const t=n.get(L);return e?(t.showInfoPopup(e),!0):(t.hideInfoPopup(),!0)}},_e={type:o.CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(n,e){var h,I,m;if(!e)return!1;const{unitId:t,linkId:i,segmentId:r}=e,c=n.get(o.IUniverInstanceService).getUnit(t,o.UniverInstanceType.UNIVER_DOC),d=c==null?void 0:c.getSelfOrHeaderFooterModel(r).getBody(),g=(m=(I=(h=d==null?void 0:d.customRanges)==null?void 0:h.find(v=>v.rangeId===i&&v.rangeType===o.CustomRangeType.HYPERLINK))==null?void 0:I.properties)==null?void 0:m.url;return g&&window.open(g,"_blank","noopener noreferrer"),!0}},Ke="univer-doc-link",Ae="univer-doc-link-type",Fe="univer-doc-link-content",Ve="univer-doc-link-url",Ye="univer-doc-link-operations",qe="univer-doc-link-operation",O={docLink:Ke,docLinkType:Ae,docLinkContent:Fe,docLinkUrl:Ve,docLinkOperations:Ye,docLinkOperation:qe},H=()=>{var k,p;const n=u.useDependency(L),e=u.useDependency(o.ICommandService),t=u.useDependency(u.IMessageService),i=u.useDependency(o.LocaleService),r=u.useObservable(n.showingLink$),s=u.useDependency(o.IUniverInstanceService);if(!r)return null;const{unitId:c,linkId:d,segmentId:g,startIndex:h,endIndex:I}=r,m=s.getUnit(c,o.UniverInstanceType.UNIVER_DOC),v=m==null?void 0:m.getSelfOrHeaderFooterModel(g).getBody(),a=(k=v==null?void 0:v.customRanges)==null?void 0:k.find(x=>x.rangeId===d&&x.rangeType===o.CustomRangeType.HYPERLINK&&x.startIndex===h&&x.endIndex===I);if(!a)return null;const f=(p=a.properties)==null?void 0:p.url;return l.jsxs("div",{className:O.docLink,onClick:()=>{n.hideInfoPopup()},children:[l.jsxs("div",{className:de(O.docLinkContent),onClick:()=>window.open(f),children:[l.jsx("div",{className:O.docLinkType,children:l.jsx(z,{})}),l.jsx(S.Tooltip,{showIfEllipsis:!0,title:f,children:l.jsx("span",{className:O.docLinkUrl,children:f})})]}),l.jsxs("div",{className:O.docLinkOperations,children:[l.jsx("div",{className:de(O.docLinkOperation),onClick:()=>{navigator.clipboard.writeText(f),t.show({content:i.t("docLink.info.coped"),type:S.MessageType.Info})},children:l.jsx(S.Tooltip,{placement:"bottom",title:i.t("docLink.info.copy"),children:l.jsx(ge,{})})}),l.jsx("div",{className:O.docLinkOperation,onClick:()=>{e.executeCommand(R.id,{link:r})},children:l.jsx(S.Tooltip,{placement:"bottom",title:i.t("docLink.info.edit"),children:l.jsx(fe,{})})}),l.jsx("div",{className:O.docLinkOperation,onClick:()=>{e.executeCommand(Ie.id,{unitId:c,linkId:a.rangeId,segmentId:g})},children:l.jsx(S.Tooltip,{placement:"bottom",title:i.t("docLink.info.cancel"),children:l.jsx(he,{})})})]})]})};H.componentKey="univer.doc.link-info-popup";var Ze=Object.getOwnPropertyDescriptor,We=(n,e,t,i)=>{for(var r=i>1?void 0:i?Ze(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=c(r)||r);return r},F=(n,e)=>(t,i)=>e(t,i,n);let L=class extends o.Disposable{constructor(e,t,i){super();P(this,"_editingLink$",new D.BehaviorSubject(null));P(this,"_showingLink$",new D.BehaviorSubject(null));P(this,"editingLink$",this._editingLink$.asObservable());P(this,"showingLink$",this._showingLink$.asObservable());P(this,"_editPopup",null);P(this,"_infoPopup",null);this._docCanvasPopupManagerService=e,this._textSelectionManagerService=t,this._univerInstanceService=i,this.disposeWithMe(()=>{this._editingLink$.complete(),this._showingLink$.complete()})}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(e,t){this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(t);const i=this._textSelectionManagerService.getTextRanges({unitId:e,subUnitId:e});let r=i==null?void 0:i[i.length-1];if(t){const{segmentId:s,segmentPage:c,startIndex:d,endIndex:g}=t;r={collapsed:!1,startOffset:d,endOffset:g+1,segmentId:s,segmentPage:c},this._textSelectionManagerService.replaceDocRanges([{startOffset:d,endOffset:g+1}])}return r?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(r,{componentKey:N.componentKey,direction:"bottom"},e),this._editPopup):null}hideEditPopup(){var e;this._editingLink$.next(null),(e=this._editPopup)==null||e.dispose()}showInfoPopup(e){var h,I,m,v,a,f;const{linkId:t,unitId:i,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}=e;if(!(((h=this.showing)==null?void 0:h.linkId)===t&&((I=this.showing)==null?void 0:I.unitId)===i&&((m=this.showing)==null?void 0:m.segmentId)===r&&((v=this.showing)==null?void 0:v.segmentPage)===s&&((a=this.showing)==null?void 0:a.startIndex)===c&&((f=this.showing)==null?void 0:f.endIndex)===d||(this._infoPopup&&this._infoPopup.dispose(),!this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_DOC))))return this._showingLink$.next({unitId:i,linkId:t,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}),this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:c,endOffset:d+1,segmentId:r,segmentPage:s},{componentKey:H.componentKey,direction:"top-center",multipleDirection:"top",onClickOutside:()=>{this.hideInfoPopup()}},i),this._infoPopup}hideInfoPopup(){var e;this._showingLink$.next(null),(e=this._infoPopup)==null||e.dispose()}};L=We([F(0,o.Inject(K.DocCanvasPopManagerService)),F(1,o.Inject(C.DocSelectionManagerService)),F(2,o.IUniverInstanceService)],L);var Ge=Object.getOwnPropertyDescriptor,ze=(n,e,t,i)=>{for(var r=i>1?void 0:i?Ge(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=c(r)||r);return r},V=(n,e)=>(t,i)=>e(t,i,n);let $=class extends o.Disposable{constructor(n,e,t){super(),this._commandService=n,this._univerInstanceService=e,this._docHyperLinkService=t,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var e,t,i;if(n.id===C.SetTextSelectionsOperation.id){const r=n.params,{unitId:s,ranges:c,segmentId:d}=r,g=this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_DOC),h=c[0];if(h&&g){const{startOffset:I,endOffset:m,collapsed:v,segmentPage:a}=h,f=(t=(e=g.getSelfOrHeaderFooterModel(d))==null?void 0:e.getBody())==null?void 0:t.customRanges;if(v){const k=(i=f==null?void 0:f.findIndex(p=>p.startIndex<I&&p.endIndex>m-1))!=null?i:-1;if(k>-1){const p=f[k];this._docHyperLinkService.showInfoPopup({unitId:s,linkId:p.rangeId,segmentId:d,segmentPage:a,startIndex:p.startIndex,endIndex:p.endIndex});return}}else if(f==null?void 0:f.find(p=>p.startIndex<=I&&p.endIndex>=m-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};$=ze([V(0,o.ICommandService),V(1,o.IUniverInstanceService),V(2,o.Inject(L))],$);var Je=Object.getOwnPropertyDescriptor,Qe=(n,e,t,i)=>{for(var r=i>1?void 0:i?Je(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=c(r)||r);return r},E=(n,e)=>(t,i)=>e(t,i,n);let W=class extends o.Disposable{constructor(n,e,t,i,r,s){super(),this._context=n,this._docEventManagerService=e,this._commandService=t,this._hyperLinkPopupService=i,this._docSkeletonManagerService=r,this._docSelectionManagerService=s,!(this._context.unitId===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY||this._context.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)&&(this._initHover(),this._initClick())}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(Z.id)}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(n=>{var r;const e=n.find(s=>s.range.rangeType===o.CustomRangeType.HYPERLINK),t=this._docSelectionManagerService.getTextRanges(),i=t==null?void 0:t[0].segmentId;if(((r=e==null?void 0:e.segmentId)!=null?r:"")!==i){this._hideInfoPopup();return}e?this._commandService.executeCommand(Z.id,{unitId:this._context.unitId,linkId:e.range.rangeId,segmentId:e.segmentId,segmentPage:e.segmentPageIndex,rangeId:e.range.rangeId,startIndex:e.range.startIndex,endIndex:e.range.endIndex}):this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(n=>{const e=n.range;e&&this._commandService.executeCommand(_e.id,{unitId:this._context.unitId,linkId:e.rangeId,segmentId:n.segmentId})}))}};W=Qe([E(1,o.Inject(K.DocEventManagerService)),E(2,o.ICommandService),E(3,o.Inject(L)),E(4,o.Inject(C.DocSkeletonManagerService)),E(5,o.Inject(C.DocSelectionManagerService))],W);var Xe=Object.getOwnPropertyDescriptor,en=(n,e,t,i)=>{for(var r=i>1?void 0:i?Xe(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=c(r)||r);return r},Y=(n,e)=>(t,i)=>e(t,i,n);let G=class extends o.Disposable{constructor(n,e,t,i){super(),this._context=n,this._docInterceptorService=e,this._hyperLinkService=t,this._docRenderController=i,this._init(),this._initReRender()}_init(){this._docInterceptorService.intercept(C.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:(n,e,t)=>{if(!n)return t(n);const{unitId:i,index:r}=e,s=this._hyperLinkService.showing;if(!s)return t({...n,active:!1});const{linkId:c,unitId:d,startIndex:g,endIndex:h}=s,I=d===i&&n.rangeId===c&&r>=g&&r<=h;return t({...n,active:I})}})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(D.distinctUntilChanged((n,e)=>(n==null?void 0:n.linkId)===(e==null?void 0:e.linkId)&&(n==null?void 0:n.unitId)===(e==null?void 0:e.unitId)&&(n==null?void 0:n.startIndex)===(e==null?void 0:e.startIndex)),D.pairwise()).subscribe(([n,e])=>{e?e.unitId===this._context.unitId&&this._docRenderController.reRender(e.unitId):n&&n.unitId===this._context.unitId&&this._docRenderController.reRender(n.unitId)}))}};G=en([Y(1,o.Inject(C.DocInterceptorService)),Y(2,o.Inject(L)),Y(3,o.Inject(K.DocRenderController))],G);const Ce="doc-hyper-link-icon";function ae(n){return{id:R.id,type:u.MenuItemType.BUTTON,icon:Ce,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:u.getMenuHiddenObservable(n,o.UniverInstanceType.UNIVER_DOC),disabled$:new D.Observable(function(e){const i=n.get(C.DocSelectionManagerService).textSelection$.pipe(D.debounceTime(16)).subscribe(()=>{e.next(me(n))});return()=>{i.unsubscribe()}})}}const nn={id:R.id,binding:u.MetaKeys.CTRL_COMMAND|u.KeyCode.K,description:"docLink.menu.tooltip",preconditions:K.whenDocAndEditorFocused},tn={[u.RibbonStartGroup.OTHERS]:{[R.id]:{order:0,menuItemFactory:ae}},[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.DATA]:{[R.id]:{order:0,menuItemFactory:ae}}}};var rn=Object.getOwnPropertyDescriptor,on=(n,e,t,i)=>{for(var r=i>1?void 0:i?rn(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=c(r)||r);return r},j=(n,e)=>(t,i)=>e(t,i,n);let B=class extends o.Disposable{constructor(n,e,t,i){super(),this._componentManager=n,this._commandService=e,this._menuManagerService=t,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[N,N.componentKey],[H,H.componentKey],[z,Ce]].forEach(([n,e])=>{this._componentManager.register(e,n)})}_initCommands(){[le,ue,Ie,R,Z,_e].forEach(n=>{this._commandService.registerCommand(n)})}_initShortcut(){[nn].forEach(n=>{this._shortcutService.registerShortcut(n)})}_initMenus(){this._menuManagerService.mergeMenu(tn)}};B=on([j(0,o.Inject(u.ComponentManager)),j(1,o.ICommandService),j(2,u.IMenuManagerService),j(3,u.IShortcutService)],B);const sn="DOC_HYPER_LINK_UI_PLUGIN";var cn=Object.defineProperty,dn=Object.getOwnPropertyDescriptor,an=(n,e,t)=>e in n?cn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ln=(n,e,t,i)=>{for(var r=i>1?void 0:i?dn(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=c(r)||r);return r},q=(n,e)=>(t,i)=>e(t,i,n),ye=(n,e,t)=>an(n,typeof e!="symbol"?e+"":e,t);exports.UniverDocsHyperLinkUIPlugin=class extends o.Plugin{constructor(e=ce,t,i,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=i,this._configService=r;const{menu:s,...c}=o.merge({},ce,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Oe,c)}onStarting(){[[L],[B],[$]].forEach(t=>{this._injector.add(t)}),this._injector.get(B)}onReady(){this._injector.get($)}onRendered(){this._initRenderModule()}_initRenderModule(){[[G],[W]].forEach(e=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,e)})}};ye(exports.UniverDocsHyperLinkUIPlugin,"pluginName",sn);ye(exports.UniverDocsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC);exports.UniverDocsHyperLinkUIPlugin=ln([o.DependentOn(Le.UniverDocsHyperLinkPlugin),q(1,o.Inject(o.Injector)),q(2,xe.IRenderManagerService),q(3,o.IConfigService)],exports.UniverDocsHyperLinkUIPlugin);
package/lib/es/index.js CHANGED
@@ -9,9 +9,9 @@ import { DocCanvasPopManagerService as sn, DocEventManagerService as cn, DocRend
9
9
  import { BehaviorSubject as ve, distinctUntilChanged as ln, pairwise as un, Observable as pn, debounceTime as gn } from "rxjs";
10
10
  import { jsxs as R, jsx as h } from "react/jsx-runtime";
11
11
  import { FormLayout as Ie, Input as _e, Button as Ce, Tooltip as B, MessageType as hn } from "@univerjs/design";
12
- import { useDependency as S, useObservable as xe, KeyCode as ne, IMessageService as fn, MetaKeys as mn, getMenuHiddenObservable as vn, MenuItemType as In, ContextMenuPosition as _n, ContextMenuGroup as Cn, RibbonStartGroup as Sn, ComponentManager as kn, IMenuManagerService as yn, IShortcutService as Ln } from "@univerjs/ui";
12
+ import { useDependency as k, useObservable as xe, KeyCode as ne, IMessageService as fn, MetaKeys as mn, getMenuHiddenObservable as vn, MenuItemType as In, ContextMenuPosition as _n, ContextMenuGroup as Cn, RibbonStartGroup as kn, ComponentManager as Sn, IMenuManagerService as yn, IShortcutService as Ln } from "@univerjs/ui";
13
13
  import { useState as q, useEffect as On, forwardRef as U, useRef as xn, createElement as T } from "react";
14
- const Pn = "docs-hyper-link-ui.config", Se = {}, Pe = {
14
+ const Pn = "docs-hyper-link-ui.config", ke = {}, Pe = {
15
15
  type: M.COMMAND,
16
16
  id: "docs.command.add-hyper-link",
17
17
  async handler(e, n) {
@@ -82,7 +82,7 @@ function Dn(e) {
82
82
  return bn(e) ? e : wn(e) ? `mailto://${e}` : `https://${e}`;
83
83
  }
84
84
  const V = () => {
85
- const e = S(k), n = S(Oe), t = xe(e.editingLink$), i = S(O), r = S(x), o = S(b), [s, c] = q(""), [l, u] = q(""), [f, m] = q(!1), g = Ke.isLegalUrl(s), d = t ? r.getUnit(t.unitId, _.UNIVER_DOC) : r.getCurrentUnitForType(_.UNIVER_DOC);
85
+ const e = k(S), n = k(Oe), t = xe(e.editingLink$), i = k(O), r = k(x), o = k(b), [s, c] = q(""), [l, u] = q(""), [f, m] = q(!1), g = Ke.isLegalUrl(s), d = t ? r.getUnit(t.unitId, _.UNIVER_DOC) : r.getCurrentUnitForType(_.UNIVER_DOC);
86
86
  On(() => {
87
87
  var ce, de, ae, le, ue, pe, ge, he, fe;
88
88
  const a = o.getActiveTextRange();
@@ -209,7 +209,10 @@ function Ee(e, n, t, i, r) {
209
209
  }
210
210
  function Un(e, n, t) {
211
211
  var i = v({}, e.attrs);
212
- t != null && t.colorChannel1 && i.fill === "colorChannel1" && (i.fill = t.colorChannel1);
212
+ t != null && t.colorChannel1 && i.fill === "colorChannel1" && (i.fill = t.colorChannel1), e.tag === "mask" && i.id && (i.id = i.id + n.idSuffix), Object.entries(i).forEach(function(o) {
213
+ var s = o[0], c = o[1];
214
+ s === "mask" && typeof c == "string" && (i[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(n.idSuffix, ")")));
215
+ });
213
216
  var r = n.defIds;
214
217
  return !r || r.length === 0 || (e.tag === "use" && i["xlink:href"] && (i["xlink:href"] = i["xlink:href"] + n.idSuffix), Object.entries(i).forEach(function(o) {
215
218
  var s = o[0], c = o[1];
@@ -267,7 +270,7 @@ function De(e) {
267
270
  } else for (t in e) e[t] && (i && (i += " "), i += t);
268
271
  return i;
269
272
  }
270
- function ke() {
273
+ function Se() {
271
274
  for (var e, n, t = 0, i = "", r = arguments.length; t < r; t++) (e = arguments[t]) && (n = De(e)) && (i && (i += " "), i += n);
272
275
  return i;
273
276
  }
@@ -294,14 +297,14 @@ const Ne = {
294
297
  const t = n == null ? void 0 : n.link, i = e.get(x);
295
298
  if (Ue(e) && !t)
296
299
  return !1;
297
- const r = e.get(k), o = (t == null ? void 0 : t.unitId) || ((s = i.getCurrentUnitForType(_.UNIVER_DOC)) == null ? void 0 : s.getUnitId());
300
+ const r = e.get(S), o = (t == null ? void 0 : t.unitId) || ((s = i.getCurrentUnitForType(_.UNIVER_DOC)) == null ? void 0 : s.getUnitId());
298
301
  return o ? (r.showEditPopup(o, t), !0) : !1;
299
302
  }
300
303
  }, te = {
301
304
  type: M.OPERATION,
302
305
  id: "doc.operation.toggle-hyper-link-info-popup",
303
306
  handler(e, n) {
304
- const t = e.get(k);
307
+ const t = e.get(S);
305
308
  return n ? (t.showInfoPopup(n), !0) : (t.hideInfoPopup(), !0);
306
309
  }
307
310
  }, Te = {
@@ -323,7 +326,7 @@ const Ne = {
323
326
  docLinkOperation: Wn
324
327
  }, Y = () => {
325
328
  var C, a;
326
- const e = S(k), n = S(O), t = S(fn), i = S(Oe), r = xe(e.showingLink$), o = S(x);
329
+ const e = k(S), n = k(O), t = k(fn), i = k(Oe), r = xe(e.showingLink$), o = k(x);
327
330
  if (!r)
328
331
  return null;
329
332
  const { unitId: s, linkId: c, segmentId: l, startIndex: u, endIndex: f } = r, m = o.getUnit(s, _.UNIVER_DOC), g = m == null ? void 0 : m.getSelfOrHeaderFooterModel(l).getBody(), d = (C = g == null ? void 0 : g.customRanges) == null ? void 0 : C.find((y) => y.rangeId === c && y.rangeType === D.HYPERLINK && y.startIndex === u && y.endIndex === f);
@@ -338,7 +341,7 @@ const Ne = {
338
341
  e.hideInfoPopup();
339
342
  },
340
343
  children: [
341
- /* @__PURE__ */ R("div", { className: ke(L.docLinkContent), onClick: () => window.open(p), children: [
344
+ /* @__PURE__ */ R("div", { className: Se(L.docLinkContent), onClick: () => window.open(p), children: [
342
345
  /* @__PURE__ */ h("div", { className: L.docLinkType, children: /* @__PURE__ */ h(oe, {}) }),
343
346
  /* @__PURE__ */ h(B, { showIfEllipsis: !0, title: p, children: /* @__PURE__ */ h("span", { className: L.docLinkUrl, children: p }) })
344
347
  ] }),
@@ -346,7 +349,7 @@ const Ne = {
346
349
  /* @__PURE__ */ h(
347
350
  "div",
348
351
  {
349
- className: ke(L.docLinkOperation),
352
+ className: Se(L.docLinkOperation),
350
353
  onClick: () => {
351
354
  navigator.clipboard.writeText(p), t.show({
352
355
  content: i.t("docLink.info.coped"),
@@ -393,7 +396,7 @@ var Gn = Object.getOwnPropertyDescriptor, zn = (e, n, t, i) => {
393
396
  (s = e[o]) && (r = s(r) || r);
394
397
  return r;
395
398
  }, J = (e, n) => (t, i) => n(t, i, e);
396
- let k = class extends N {
399
+ let S = class extends N {
397
400
  constructor(n, t, i) {
398
401
  super();
399
402
  P(this, "_editingLink$", new ve(null));
@@ -470,11 +473,11 @@ let k = class extends N {
470
473
  this._showingLink$.next(null), (n = this._infoPopup) == null || n.dispose();
471
474
  }
472
475
  };
473
- k = zn([
476
+ S = zn([
474
477
  J(0, I(sn)),
475
478
  J(1, I(b)),
476
479
  J(2, x)
477
- ], k);
480
+ ], S);
478
481
  var qn = Object.getOwnPropertyDescriptor, Jn = (e, n, t, i) => {
479
482
  for (var r = i > 1 ? void 0 : i ? qn(n, t) : n, o = e.length - 1, s; o >= 0; o--)
480
483
  (s = e[o]) && (r = s(r) || r);
@@ -511,7 +514,7 @@ let Z = class extends N {
511
514
  Z = Jn([
512
515
  Q(0, O),
513
516
  Q(1, x),
514
- Q(2, I(k))
517
+ Q(2, I(S))
515
518
  ], Z);
516
519
  var Qn = Object.getOwnPropertyDescriptor, Xn = (e, n, t, i) => {
517
520
  for (var r = i > 1 ? void 0 : i ? Qn(n, t) : n, o = e.length - 1, s; o >= 0; o--)
@@ -573,7 +576,7 @@ let ie = class extends N {
573
576
  ie = Xn([
574
577
  w(1, I(cn)),
575
578
  w(2, O),
576
- w(3, I(k)),
579
+ w(3, I(S)),
577
580
  w(4, I(tn)),
578
581
  w(5, I(b))
579
582
  ], ie);
@@ -616,7 +619,7 @@ let re = class extends N {
616
619
  };
617
620
  re = nt([
618
621
  X(1, I(rn)),
619
- X(2, I(k)),
622
+ X(2, I(S)),
620
623
  X(3, I(dn))
621
624
  ], re);
622
625
  const $e = "doc-hyper-link-icon";
@@ -644,7 +647,7 @@ const tt = {
644
647
  description: "docLink.menu.tooltip",
645
648
  preconditions: an
646
649
  }, it = {
647
- [Sn.OTHERS]: {
650
+ [kn.OTHERS]: {
648
651
  [E.id]: {
649
652
  order: 0,
650
653
  menuItemFactory: ye
@@ -699,7 +702,7 @@ let W = class extends N {
699
702
  }
700
703
  };
701
704
  W = ot([
702
- F(0, I(kn)),
705
+ F(0, I(Sn)),
703
706
  F(1, O),
704
707
  F(2, yn),
705
708
  F(3, Ln)
@@ -711,18 +714,18 @@ var ct = Object.defineProperty, dt = Object.getOwnPropertyDescriptor, at = (e, n
711
714
  return r;
712
715
  }, ee = (e, n) => (t, i) => n(t, i, e), He = (e, n, t) => at(e, typeof n != "symbol" ? n + "" : n, t);
713
716
  let G = class extends Ge {
714
- constructor(e = Se, n, t, i) {
717
+ constructor(e = ke, n, t, i) {
715
718
  super(), this._config = e, this._injector = n, this._renderManagerSrv = t, this._configService = i;
716
719
  const { menu: r, ...o } = ze(
717
720
  {},
718
- Se,
721
+ ke,
719
722
  this._config
720
723
  );
721
724
  r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(Pn, o);
722
725
  }
723
726
  onStarting() {
724
727
  [
725
- [k],
728
+ [S],
726
729
  [W],
727
730
  [Z]
728
731
  ].forEach((n) => {
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(a,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/docs-hyper-link"),require("@univerjs/engine-render"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("@univerjs/ui"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-hyper-link","@univerjs/engine-render","@univerjs/docs","@univerjs/docs-ui","rxjs","react/jsx-runtime","@univerjs/design","@univerjs/ui","react"],o):(a=typeof globalThis<"u"?globalThis:a||self,o(a.UniverDocsHyperLinkUi={},a.UniverCore,a.UniverDocsHyperLink,a.UniverEngineRender,a.UniverDocs,a.UniverDocsUi,a.rxjs,a.React,a.UniverDesign,a.UniverUi,a.React))})(this,function(a,o,U,Le,y,b,E,u,k,p,_){"use strict";var en=Object.defineProperty;var nn=(a,o,U)=>o in a?en(a,o,{enumerable:!0,configurable:!0,writable:!0,value:U}):a[o]=U;var P=(a,o,U)=>nn(a,typeof o!="symbol"?o+"":o,U);const Oe="docs-hyper-link-ui.config",X={},ee={type:o.CommandType.COMMAND,id:"docs.command.add-hyper-link",async handler(e,n){if(!n)return!1;const{payload:t,unitId:i,selections:r}=n,s=e.get(o.ICommandService),c=o.generateRandomId(),d=y.addCustomRangeBySelectionFactory(e,{rangeId:c,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:t},unitId:i,selections:r});return d?s.syncExecuteCommand(d.id,d.params):!1}},ne={id:"docs.command.update-hyper-link",type:o.CommandType.COMMAND,handler(e,n){var f;if(!n)return!1;const{unitId:t,payload:i,segmentId:r,linkId:s}=n,c=e.get(o.ICommandService),d=e.get(o.IUniverInstanceService),h=e.get(y.DocSelectionManagerService).getActiveTextRange(),m=d.getUnit(t,o.UniverInstanceType.UNIVER_DOC);if(!h||!m)return!1;const I=(f=o.getBodySlice(m.getSelfOrHeaderFooterModel(r).getBody(),h.startOffset,h.endOffset).textRuns)==null?void 0:f[0];I&&(I.ed=n.label.length+1);const l=y.replaceSelectionFactory(e,{unitId:t,body:{dataStream:`${n.label}`,customRanges:[{rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:n.label.length+1,properties:{url:i}}],textRuns:I?[I]:void 0},selection:{startOffset:h.startOffset,endOffset:h.endOffset,collapsed:!1,segmentId:r}});return l?c.syncExecuteCommand(l.id,l.params):!1}},R={docsLinkEdit:"univer-docs-link-edit",docsLinkEditButtons:"univer-docs-link-edit-buttons",docsLinkEditButton:"univer-docs-link-edit-button"};function xe(e){return/^[a-zA-Z]+:\/\//.test(e)}function De(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function Pe(e){return xe(e)?e:De(e)?`mailto://${e}`:`https://${e}`}const N=()=>{const e=p.useDependency(L),n=p.useDependency(o.LocaleService),t=p.useObservable(e.editingLink$),i=p.useDependency(o.ICommandService),r=p.useDependency(o.IUniverInstanceService),s=p.useDependency(y.DocSelectionManagerService),[c,d]=_.useState(""),[v,h]=_.useState(""),[m,C]=_.useState(!1),I=o.Tools.isLegalUrl(c),l=t?r.getUnit(t.unitId,o.UniverInstanceType.UNIVER_DOC):r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);_.useEffect(()=>{var he,fe,Ie,me,_e,Ce,ye,Se,ke;const g=s.getActiveTextRange();if(!g)return;if(t){const A=(he=l==null?void 0:l.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:he.getBody(),F=(fe=A==null?void 0:A.customRanges)==null?void 0:fe.find(Q=>(t==null?void 0:t.linkId)===Q.rangeId&&Q.startIndex===t.startIndex&&Q.endIndex===t.endIndex);l&&F&&(d((me=(Ie=F.properties)==null?void 0:Ie.url)!=null?me:""),h(o.BuildTextUtils.transform.getPlainText(o.getBodySlice(A,F.startIndex,F.endIndex+1).dataStream)));return}const x=(_e=l==null?void 0:l.getSelfOrHeaderFooterModel(g.segmentId))==null?void 0:_e.getBody(),ve=x?g:null,K=ve&&((ye=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(ve,(Ce=x==null?void 0:x.customRanges)!=null?Ce:[]))==null?void 0:ye[0]);l&&K&&d((ke=(Se=K==null?void 0:K.properties)==null?void 0:Se.url)!=null?ke:"")},[l,t,s,r]);const f=()=>{e.hideEditPopup()},O=()=>{if(C(!0),!I||!l)return;const g=Pe(c);if(!t)i.executeCommand(ee.id,{unitId:l.getUnitId(),payload:g});else{if(!v)return;i.executeCommand(ne.id,{unitId:l.getUnitId(),payload:g,linkId:t.linkId,label:v,segmentId:t.segmentId})}e.hideEditPopup()};if(l)return u.jsxs("div",{className:R.docsLinkEdit,children:[u.jsxs("div",{children:[t?u.jsx(k.FormLayout,{label:n.t("docLink.edit.label"),error:m&&!v?n.t("docLink.edit.labelError"):"",children:u.jsx(k.Input,{value:v,onChange:h,autoFocus:!0,onKeyDown:g=>{g.keyCode===p.KeyCode.ENTER&&O()}})}):null,u.jsx(k.FormLayout,{label:n.t("docLink.edit.address"),error:m&&!I?n.t("docLink.edit.addressError"):"",children:u.jsx(k.Input,{value:c,onChange:d,autoFocus:!0,onKeyDown:g=>{g.keyCode===p.KeyCode.ENTER&&O()}})})]}),u.jsxs("div",{className:R.docsLinkEditButtons,children:[u.jsx(k.Button,{className:R.docsLinkEditButton,onClick:f,children:n.t("docLink.edit.cancel")}),u.jsx(k.Button,{disabled:!c,className:R.docsLinkEditButton,type:"primary",onClick:O,children:n.t("docLink.edit.confirm")})]})]})};N.componentKey="docs-hyper-link-edit";var S=function(){return S=Object.assign||function(e){for(var n,t=1,i=arguments.length;t<i;t++){n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},S.apply(this,arguments)},Ue=function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)n.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(t[i[r]]=e[i[r]]);return t},T=_.forwardRef(function(e,n){var t=e.icon,i=e.id,r=e.className,s=e.extend,c=Ue(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),v=_.useRef("_".concat(Te()));return te(t,"".concat(i),{defIds:t.defIds,idSuffix:v.current},S({ref:n,className:d},c),s)});function te(e,n,t,i,r){return _.createElement(e.tag,S(S({key:n},Ee(e,t,r)),i),(Me(e,t).children||[]).map(function(s,c){return te(s,"".concat(n,"-").concat(e.tag,"-").concat(c),t,void 0,r)}))}function Ee(e,n,t){var i=S({},e.attrs);t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1);var r=n.defIds;return!r||r.length===0||(e.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+n.idSuffix),Object.entries(i).forEach(function(s){var c=s[0],d=s[1];typeof d=="string"&&(i[c]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),i}function Me(e,n){var t,i=n.defIds;return!i||i.length===0?e:e.tag==="defs"&&(!((t=e.children)===null||t===void 0)&&t.length)?S(S({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.indexOf(r.attrs.id)>-1?S(S({},r),{attrs:S(S({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):e}function Te(){return Math.random().toString(36).substring(2,8)}T.displayName="UniverIcon";var we={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=_.forwardRef(function(e,n){return _.createElement(T,Object.assign({},e,{id:"copy-single",ref:n,icon:we}))});ie.displayName="CopySingle";var be={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},V=_.forwardRef(function(e,n){return _.createElement(T,Object.assign({},e,{id:"link-single",ref:n,icon:be}))});V.displayName="LinkSingle";var Re={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},re=_.forwardRef(function(e,n){return _.createElement(T,Object.assign({},e,{id:"unlink-single",ref:n,icon:Re}))});re.displayName="UnlinkSingle";var Ne={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},oe=_.forwardRef(function(e,n){return _.createElement(T,Object.assign({},e,{id:"write-single",ref:n,icon:Ne}))});oe.displayName="WriteSingle";function se(e){var n,t,i="";if(typeof e=="string"||typeof e=="number")i+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(n=0;n<r;n++)e[n]&&(t=se(e[n]))&&(i&&(i+=" "),i+=t)}else for(t in e)e[t]&&(i&&(i+=" "),i+=t);return i}function ce(){for(var e,n,t=0,i="",r=arguments.length;t<r;t++)(e=arguments[t])&&(n=se(e))&&(i&&(i+=" "),i+=n);return i}const de={type:o.CommandType.COMMAND,id:"docs.command.delete-hyper-link",async handler(e,n){if(!n)return!1;const{unitId:t,linkId:i,segmentId:r}=n,s=e.get(o.ICommandService),c=y.deleteCustomRangeFactory(e,{unitId:t,rangeId:i,segmentId:r});return c?await s.syncExecuteCommand(c.id,c.params):!1}},ae=e=>{const n=e.get(y.DocSelectionManagerService),t=e.get(o.IUniverInstanceService),i=n.getTextRanges();if(!(i!=null&&i.length))return!0;const r=i[0];return!!(!t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC)||!r||r.collapsed)},M={type:o.CommandType.OPERATION,id:"doc.operation.show-hyper-link-edit-popup",handler(e,n){var c;const t=n==null?void 0:n.link,i=e.get(o.IUniverInstanceService);if(ae(e)&&!t)return!1;const r=e.get(L),s=(t==null?void 0:t.unitId)||((c=i.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC))==null?void 0:c.getUnitId());return s?(r.showEditPopup(s,t),!0):!1}},Y={type:o.CommandType.OPERATION,id:"doc.operation.toggle-hyper-link-info-popup",handler(e,n){const t=e.get(L);return n?(t.showInfoPopup(n),!0):(t.hideInfoPopup(),!0)}},le={type:o.CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(e,n){var h,m,C;if(!n)return!1;const{unitId:t,linkId:i,segmentId:r}=n,c=e.get(o.IUniverInstanceService).getUnit(t,o.UniverInstanceType.UNIVER_DOC),d=c==null?void 0:c.getSelfOrHeaderFooterModel(r).getBody(),v=(C=(m=(h=d==null?void 0:d.customRanges)==null?void 0:h.find(I=>I.rangeId===i&&I.rangeType===o.CustomRangeType.HYPERLINK))==null?void 0:m.properties)==null?void 0:C.url;return v&&window.open(v,"_blank","noopener noreferrer"),!0}},D={docLink:"univer-doc-link",docLinkType:"univer-doc-link-type",docLinkContent:"univer-doc-link-content",docLinkUrl:"univer-doc-link-url",docLinkOperations:"univer-doc-link-operations",docLinkOperation:"univer-doc-link-operation"},j=()=>{var O,g;const e=p.useDependency(L),n=p.useDependency(o.ICommandService),t=p.useDependency(p.IMessageService),i=p.useDependency(o.LocaleService),r=p.useObservable(e.showingLink$),s=p.useDependency(o.IUniverInstanceService);if(!r)return null;const{unitId:c,linkId:d,segmentId:v,startIndex:h,endIndex:m}=r,C=s.getUnit(c,o.UniverInstanceType.UNIVER_DOC),I=C==null?void 0:C.getSelfOrHeaderFooterModel(v).getBody(),l=(O=I==null?void 0:I.customRanges)==null?void 0:O.find(x=>x.rangeId===d&&x.rangeType===o.CustomRangeType.HYPERLINK&&x.startIndex===h&&x.endIndex===m);if(!l)return null;const f=(g=l.properties)==null?void 0:g.url;return u.jsxs("div",{className:D.docLink,onClick:()=>{e.hideInfoPopup()},children:[u.jsxs("div",{className:ce(D.docLinkContent),onClick:()=>window.open(f),children:[u.jsx("div",{className:D.docLinkType,children:u.jsx(V,{})}),u.jsx(k.Tooltip,{showIfEllipsis:!0,title:f,children:u.jsx("span",{className:D.docLinkUrl,children:f})})]}),u.jsxs("div",{className:D.docLinkOperations,children:[u.jsx("div",{className:ce(D.docLinkOperation),onClick:()=>{navigator.clipboard.writeText(f),t.show({content:i.t("docLink.info.coped"),type:k.MessageType.Info})},children:u.jsx(k.Tooltip,{placement:"bottom",title:i.t("docLink.info.copy"),children:u.jsx(ie,{})})}),u.jsx("div",{className:D.docLinkOperation,onClick:()=>{n.executeCommand(M.id,{link:r})},children:u.jsx(k.Tooltip,{placement:"bottom",title:i.t("docLink.info.edit"),children:u.jsx(oe,{})})}),u.jsx("div",{className:D.docLinkOperation,onClick:()=>{n.executeCommand(de.id,{unitId:c,linkId:l.rangeId,segmentId:v})},children:u.jsx(k.Tooltip,{placement:"bottom",title:i.t("docLink.info.cancel"),children:u.jsx(re,{})})})]})]})};j.componentKey="univer.doc.link-info-popup";var je=Object.getOwnPropertyDescriptor,He=(e,n,t,i)=>{for(var r=i>1?void 0:i?je(n,t):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},q=(e,n)=>(t,i)=>n(t,i,e);let L=class extends o.Disposable{constructor(n,t,i){super();P(this,"_editingLink$",new E.BehaviorSubject(null));P(this,"_showingLink$",new E.BehaviorSubject(null));P(this,"editingLink$",this._editingLink$.asObservable());P(this,"showingLink$",this._showingLink$.asObservable());P(this,"_editPopup",null);P(this,"_infoPopup",null);this._docCanvasPopupManagerService=n,this._textSelectionManagerService=t,this._univerInstanceService=i,this.disposeWithMe(()=>{this._editingLink$.complete(),this._showingLink$.complete()})}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(n,t){this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(t);const i=this._textSelectionManagerService.getTextRanges({unitId:n,subUnitId:n});let r=i==null?void 0:i[i.length-1];if(t){const{segmentId:s,segmentPage:c,startIndex:d,endIndex:v}=t;r={collapsed:!1,startOffset:d,endOffset:v+1,segmentId:s,segmentPage:c},this._textSelectionManagerService.replaceDocRanges([{startOffset:d,endOffset:v+1}])}return r?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(r,{componentKey:N.componentKey,direction:"bottom"},n),this._editPopup):null}hideEditPopup(){var n;this._editingLink$.next(null),(n=this._editPopup)==null||n.dispose()}showInfoPopup(n){var h,m,C,I,l,f;const{linkId:t,unitId:i,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}=n;if(!(((h=this.showing)==null?void 0:h.linkId)===t&&((m=this.showing)==null?void 0:m.unitId)===i&&((C=this.showing)==null?void 0:C.segmentId)===r&&((I=this.showing)==null?void 0:I.segmentPage)===s&&((l=this.showing)==null?void 0:l.startIndex)===c&&((f=this.showing)==null?void 0:f.endIndex)===d||(this._infoPopup&&this._infoPopup.dispose(),!this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_DOC))))return this._showingLink$.next({unitId:i,linkId:t,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}),this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:c,endOffset:d+1,segmentId:r,segmentPage:s},{componentKey:j.componentKey,direction:"top-center",multipleDirection:"top",onClickOutside:()=>{this.hideInfoPopup()}},i),this._infoPopup}hideInfoPopup(){var n;this._showingLink$.next(null),(n=this._infoPopup)==null||n.dispose()}};L=He([q(0,o.Inject(b.DocCanvasPopManagerService)),q(1,o.Inject(y.DocSelectionManagerService)),q(2,o.IUniverInstanceService)],L);var $e=Object.getOwnPropertyDescriptor,Be=(e,n,t,i)=>{for(var r=i>1?void 0:i?$e(n,t):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},Z=(e,n)=>(t,i)=>n(t,i,e);let H=class extends o.Disposable{constructor(e,n,t){super(),this._commandService=e,this._univerInstanceService=n,this._docHyperLinkService=t,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var n,t,i;if(e.id===y.SetTextSelectionsOperation.id){const r=e.params,{unitId:s,ranges:c,segmentId:d}=r,v=this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_DOC),h=c[0];if(h&&v){const{startOffset:m,endOffset:C,collapsed:I,segmentPage:l}=h,f=(t=(n=v.getSelfOrHeaderFooterModel(d))==null?void 0:n.getBody())==null?void 0:t.customRanges;if(I){const O=(i=f==null?void 0:f.findIndex(g=>g.startIndex<m&&g.endIndex>C-1))!=null?i:-1;if(O>-1){const g=f[O];this._docHyperLinkService.showInfoPopup({unitId:s,linkId:g.rangeId,segmentId:d,segmentPage:l,startIndex:g.startIndex,endIndex:g.endIndex});return}}else if(f==null?void 0:f.find(g=>g.startIndex<=m&&g.endIndex>=C-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};H=Be([Z(0,o.ICommandService),Z(1,o.IUniverInstanceService),Z(2,o.Inject(L))],H);var Ke=Object.getOwnPropertyDescriptor,Ae=(e,n,t,i)=>{for(var r=i>1?void 0:i?Ke(n,t):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},w=(e,n)=>(t,i)=>n(t,i,e);let W=class extends o.Disposable{constructor(e,n,t,i,r,s){super(),this._context=e,this._docEventManagerService=n,this._commandService=t,this._hyperLinkPopupService=i,this._docSkeletonManagerService=r,this._docSelectionManagerService=s,!(this._context.unitId===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY||this._context.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)&&(this._initHover(),this._initClick())}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(Y.id)}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(e=>{var r;const n=e.find(s=>s.range.rangeType===o.CustomRangeType.HYPERLINK),t=this._docSelectionManagerService.getTextRanges(),i=t==null?void 0:t[0].segmentId;if(((r=n==null?void 0:n.segmentId)!=null?r:"")!==i){this._hideInfoPopup();return}n?this._commandService.executeCommand(Y.id,{unitId:this._context.unitId,linkId:n.range.rangeId,segmentId:n.segmentId,segmentPage:n.segmentPageIndex,rangeId:n.range.rangeId,startIndex:n.range.startIndex,endIndex:n.range.endIndex}):this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(e=>{const n=e.range;n&&this._commandService.executeCommand(le.id,{unitId:this._context.unitId,linkId:n.rangeId,segmentId:e.segmentId})}))}};W=Ae([w(1,o.Inject(b.DocEventManagerService)),w(2,o.ICommandService),w(3,o.Inject(L)),w(4,o.Inject(y.DocSkeletonManagerService)),w(5,o.Inject(y.DocSelectionManagerService))],W);var Fe=Object.getOwnPropertyDescriptor,Ve=(e,n,t,i)=>{for(var r=i>1?void 0:i?Fe(n,t):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},G=(e,n)=>(t,i)=>n(t,i,e);let z=class extends o.Disposable{constructor(e,n,t,i){super(),this._context=e,this._docInterceptorService=n,this._hyperLinkService=t,this._docRenderController=i,this._init(),this._initReRender()}_init(){this._docInterceptorService.intercept(y.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:(e,n,t)=>{if(!e)return t(e);const{unitId:i,index:r}=n,s=this._hyperLinkService.showing;if(!s)return t({...e,active:!1});const{linkId:c,unitId:d,startIndex:v,endIndex:h}=s,m=d===i&&e.rangeId===c&&r>=v&&r<=h;return t({...e,active:m})}})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(E.distinctUntilChanged((e,n)=>(e==null?void 0:e.linkId)===(n==null?void 0:n.linkId)&&(e==null?void 0:e.unitId)===(n==null?void 0:n.unitId)&&(e==null?void 0:e.startIndex)===(n==null?void 0:n.startIndex)),E.pairwise()).subscribe(([e,n])=>{n?n.unitId===this._context.unitId&&this._docRenderController.reRender(n.unitId):e&&e.unitId===this._context.unitId&&this._docRenderController.reRender(e.unitId)}))}};z=Ve([G(1,o.Inject(y.DocInterceptorService)),G(2,o.Inject(L)),G(3,o.Inject(b.DocRenderController))],z);const ue="doc-hyper-link-icon";function pe(e){return{id:M.id,type:p.MenuItemType.BUTTON,icon:ue,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:p.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC),disabled$:new E.Observable(function(n){const i=e.get(y.DocSelectionManagerService).textSelection$.pipe(E.debounceTime(16)).subscribe(()=>{n.next(ae(e))});return()=>{i.unsubscribe()}})}}const Ye={id:M.id,binding:p.MetaKeys.CTRL_COMMAND|p.KeyCode.K,description:"docLink.menu.tooltip",preconditions:b.whenDocAndEditorFocused},qe={[p.RibbonStartGroup.OTHERS]:{[M.id]:{order:0,menuItemFactory:pe}},[p.ContextMenuPosition.MAIN_AREA]:{[p.ContextMenuGroup.DATA]:{[M.id]:{order:0,menuItemFactory:pe}}}};var Ze=Object.getOwnPropertyDescriptor,We=(e,n,t,i)=>{for(var r=i>1?void 0:i?Ze(n,t):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},$=(e,n)=>(t,i)=>n(t,i,e);let B=class extends o.Disposable{constructor(e,n,t,i){super(),this._componentManager=e,this._commandService=n,this._menuManagerService=t,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[N,N.componentKey],[j,j.componentKey],[V,ue]].forEach(([e,n])=>{this._componentManager.register(n,e)})}_initCommands(){[ee,ne,de,M,Y,le].forEach(e=>{this._commandService.registerCommand(e)})}_initShortcut(){[Ye].forEach(e=>{this._shortcutService.registerShortcut(e)})}_initMenus(){this._menuManagerService.mergeMenu(qe)}};B=We([$(0,o.Inject(p.ComponentManager)),$(1,o.ICommandService),$(2,p.IMenuManagerService),$(3,p.IShortcutService)],B);const Ge="DOC_HYPER_LINK_UI_PLUGIN";var ze=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(e,n,t)=>n in e?ze(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Xe=(e,n,t,i)=>{for(var r=i>1?void 0:i?Je(n,t):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},J=(e,n)=>(t,i)=>n(t,i,e),ge=(e,n,t)=>Qe(e,typeof n!="symbol"?n+"":n,t);a.UniverDocsHyperLinkUIPlugin=class extends o.Plugin{constructor(n=X,t,i,r){super(),this._config=n,this._injector=t,this._renderManagerSrv=i,this._configService=r;const{menu:s,...c}=o.merge({},X,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Oe,c)}onStarting(){[[L],[B],[H]].forEach(t=>{this._injector.add(t)}),this._injector.get(B)}onReady(){this._injector.get(H)}onRendered(){this._initRenderModule()}_initRenderModule(){[[z],[W]].forEach(n=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,n)})}},ge(a.UniverDocsHyperLinkUIPlugin,"pluginName",Ge),ge(a.UniverDocsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC),a.UniverDocsHyperLinkUIPlugin=Xe([o.DependentOn(U.UniverDocsHyperLinkPlugin),J(1,o.Inject(o.Injector)),J(2,Le.IRenderManagerService),J(3,o.IConfigService)],a.UniverDocsHyperLinkUIPlugin),Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
1
+ (function(a,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/docs-hyper-link"),require("@univerjs/engine-render"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("@univerjs/ui"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-hyper-link","@univerjs/engine-render","@univerjs/docs","@univerjs/docs-ui","rxjs","react/jsx-runtime","@univerjs/design","@univerjs/ui","react"],o):(a=typeof globalThis<"u"?globalThis:a||self,o(a.UniverDocsHyperLinkUi={},a.UniverCore,a.UniverDocsHyperLink,a.UniverEngineRender,a.UniverDocs,a.UniverDocsUi,a.rxjs,a.React,a.UniverDesign,a.UniverUi,a.React))})(this,function(a,o,U,Le,y,b,E,u,k,p,_){"use strict";var en=Object.defineProperty;var nn=(a,o,U)=>o in a?en(a,o,{enumerable:!0,configurable:!0,writable:!0,value:U}):a[o]=U;var P=(a,o,U)=>nn(a,typeof o!="symbol"?o+"":o,U);const Oe="docs-hyper-link-ui.config",X={},ee={type:o.CommandType.COMMAND,id:"docs.command.add-hyper-link",async handler(e,n){if(!n)return!1;const{payload:i,unitId:t,selections:r}=n,s=e.get(o.ICommandService),c=o.generateRandomId(),d=y.addCustomRangeBySelectionFactory(e,{rangeId:c,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:i},unitId:t,selections:r});return d?s.syncExecuteCommand(d.id,d.params):!1}},ne={id:"docs.command.update-hyper-link",type:o.CommandType.COMMAND,handler(e,n){var f;if(!n)return!1;const{unitId:i,payload:t,segmentId:r,linkId:s}=n,c=e.get(o.ICommandService),d=e.get(o.IUniverInstanceService),h=e.get(y.DocSelectionManagerService).getActiveTextRange(),m=d.getUnit(i,o.UniverInstanceType.UNIVER_DOC);if(!h||!m)return!1;const I=(f=o.getBodySlice(m.getSelfOrHeaderFooterModel(r).getBody(),h.startOffset,h.endOffset).textRuns)==null?void 0:f[0];I&&(I.ed=n.label.length+1);const l=y.replaceSelectionFactory(e,{unitId:i,body:{dataStream:`${n.label}`,customRanges:[{rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:n.label.length+1,properties:{url:t}}],textRuns:I?[I]:void 0},selection:{startOffset:h.startOffset,endOffset:h.endOffset,collapsed:!1,segmentId:r}});return l?c.syncExecuteCommand(l.id,l.params):!1}},R={docsLinkEdit:"univer-docs-link-edit",docsLinkEditButtons:"univer-docs-link-edit-buttons",docsLinkEditButton:"univer-docs-link-edit-button"};function xe(e){return/^[a-zA-Z]+:\/\//.test(e)}function De(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function Pe(e){return xe(e)?e:De(e)?`mailto://${e}`:`https://${e}`}const N=()=>{const e=p.useDependency(L),n=p.useDependency(o.LocaleService),i=p.useObservable(e.editingLink$),t=p.useDependency(o.ICommandService),r=p.useDependency(o.IUniverInstanceService),s=p.useDependency(y.DocSelectionManagerService),[c,d]=_.useState(""),[v,h]=_.useState(""),[m,C]=_.useState(!1),I=o.Tools.isLegalUrl(c),l=i?r.getUnit(i.unitId,o.UniverInstanceType.UNIVER_DOC):r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);_.useEffect(()=>{var he,fe,Ie,me,_e,Ce,ye,Se,ke;const g=s.getActiveTextRange();if(!g)return;if(i){const A=(he=l==null?void 0:l.getSelfOrHeaderFooterModel(i.segmentId))==null?void 0:he.getBody(),F=(fe=A==null?void 0:A.customRanges)==null?void 0:fe.find(Q=>(i==null?void 0:i.linkId)===Q.rangeId&&Q.startIndex===i.startIndex&&Q.endIndex===i.endIndex);l&&F&&(d((me=(Ie=F.properties)==null?void 0:Ie.url)!=null?me:""),h(o.BuildTextUtils.transform.getPlainText(o.getBodySlice(A,F.startIndex,F.endIndex+1).dataStream)));return}const x=(_e=l==null?void 0:l.getSelfOrHeaderFooterModel(g.segmentId))==null?void 0:_e.getBody(),ve=x?g:null,K=ve&&((ye=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(ve,(Ce=x==null?void 0:x.customRanges)!=null?Ce:[]))==null?void 0:ye[0]);l&&K&&d((ke=(Se=K==null?void 0:K.properties)==null?void 0:Se.url)!=null?ke:"")},[l,i,s,r]);const f=()=>{e.hideEditPopup()},O=()=>{if(C(!0),!I||!l)return;const g=Pe(c);if(!i)t.executeCommand(ee.id,{unitId:l.getUnitId(),payload:g});else{if(!v)return;t.executeCommand(ne.id,{unitId:l.getUnitId(),payload:g,linkId:i.linkId,label:v,segmentId:i.segmentId})}e.hideEditPopup()};if(l)return u.jsxs("div",{className:R.docsLinkEdit,children:[u.jsxs("div",{children:[i?u.jsx(k.FormLayout,{label:n.t("docLink.edit.label"),error:m&&!v?n.t("docLink.edit.labelError"):"",children:u.jsx(k.Input,{value:v,onChange:h,autoFocus:!0,onKeyDown:g=>{g.keyCode===p.KeyCode.ENTER&&O()}})}):null,u.jsx(k.FormLayout,{label:n.t("docLink.edit.address"),error:m&&!I?n.t("docLink.edit.addressError"):"",children:u.jsx(k.Input,{value:c,onChange:d,autoFocus:!0,onKeyDown:g=>{g.keyCode===p.KeyCode.ENTER&&O()}})})]}),u.jsxs("div",{className:R.docsLinkEditButtons,children:[u.jsx(k.Button,{className:R.docsLinkEditButton,onClick:f,children:n.t("docLink.edit.cancel")}),u.jsx(k.Button,{disabled:!c,className:R.docsLinkEditButton,type:"primary",onClick:O,children:n.t("docLink.edit.confirm")})]})]})};N.componentKey="docs-hyper-link-edit";var S=function(){return S=Object.assign||function(e){for(var n,i=1,t=arguments.length;i<t;i++){n=arguments[i];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},S.apply(this,arguments)},Ue=function(e,n){var i={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(i[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(e);r<t.length;r++)n.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(e,t[r])&&(i[t[r]]=e[t[r]]);return i},T=_.forwardRef(function(e,n){var i=e.icon,t=e.id,r=e.className,s=e.extend,c=Ue(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),v=_.useRef("_".concat(Te()));return te(i,"".concat(t),{defIds:i.defIds,idSuffix:v.current},S({ref:n,className:d},c),s)});function te(e,n,i,t,r){return _.createElement(e.tag,S(S({key:n},Ee(e,i,r)),t),(Me(e,i).children||[]).map(function(s,c){return te(s,"".concat(n,"-").concat(e.tag,"-").concat(c),i,void 0,r)}))}function Ee(e,n,i){var t=S({},e.attrs);i!=null&&i.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=i.colorChannel1),e.tag==="mask"&&t.id&&(t.id=t.id+n.idSuffix),Object.entries(t).forEach(function(s){var c=s[0],d=s[1];c==="mask"&&typeof d=="string"&&(t[c]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var r=n.defIds;return!r||r.length===0||(e.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(s){var c=s[0],d=s[1];typeof d=="string"&&(t[c]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function Me(e,n){var i,t=n.defIds;return!t||t.length===0?e:e.tag==="defs"&&(!((i=e.children)===null||i===void 0)&&i.length)?S(S({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?S(S({},r),{attrs:S(S({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):e}function Te(){return Math.random().toString(36).substring(2,8)}T.displayName="UniverIcon";var we={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=_.forwardRef(function(e,n){return _.createElement(T,Object.assign({},e,{id:"copy-single",ref:n,icon:we}))});ie.displayName="CopySingle";var be={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},V=_.forwardRef(function(e,n){return _.createElement(T,Object.assign({},e,{id:"link-single",ref:n,icon:be}))});V.displayName="LinkSingle";var Re={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},re=_.forwardRef(function(e,n){return _.createElement(T,Object.assign({},e,{id:"unlink-single",ref:n,icon:Re}))});re.displayName="UnlinkSingle";var Ne={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},oe=_.forwardRef(function(e,n){return _.createElement(T,Object.assign({},e,{id:"write-single",ref:n,icon:Ne}))});oe.displayName="WriteSingle";function se(e){var n,i,t="";if(typeof e=="string"||typeof e=="number")t+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(n=0;n<r;n++)e[n]&&(i=se(e[n]))&&(t&&(t+=" "),t+=i)}else for(i in e)e[i]&&(t&&(t+=" "),t+=i);return t}function ce(){for(var e,n,i=0,t="",r=arguments.length;i<r;i++)(e=arguments[i])&&(n=se(e))&&(t&&(t+=" "),t+=n);return t}const de={type:o.CommandType.COMMAND,id:"docs.command.delete-hyper-link",async handler(e,n){if(!n)return!1;const{unitId:i,linkId:t,segmentId:r}=n,s=e.get(o.ICommandService),c=y.deleteCustomRangeFactory(e,{unitId:i,rangeId:t,segmentId:r});return c?await s.syncExecuteCommand(c.id,c.params):!1}},ae=e=>{const n=e.get(y.DocSelectionManagerService),i=e.get(o.IUniverInstanceService),t=n.getTextRanges();if(!(t!=null&&t.length))return!0;const r=t[0];return!!(!i.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC)||!r||r.collapsed)},M={type:o.CommandType.OPERATION,id:"doc.operation.show-hyper-link-edit-popup",handler(e,n){var c;const i=n==null?void 0:n.link,t=e.get(o.IUniverInstanceService);if(ae(e)&&!i)return!1;const r=e.get(L),s=(i==null?void 0:i.unitId)||((c=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC))==null?void 0:c.getUnitId());return s?(r.showEditPopup(s,i),!0):!1}},Y={type:o.CommandType.OPERATION,id:"doc.operation.toggle-hyper-link-info-popup",handler(e,n){const i=e.get(L);return n?(i.showInfoPopup(n),!0):(i.hideInfoPopup(),!0)}},le={type:o.CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(e,n){var h,m,C;if(!n)return!1;const{unitId:i,linkId:t,segmentId:r}=n,c=e.get(o.IUniverInstanceService).getUnit(i,o.UniverInstanceType.UNIVER_DOC),d=c==null?void 0:c.getSelfOrHeaderFooterModel(r).getBody(),v=(C=(m=(h=d==null?void 0:d.customRanges)==null?void 0:h.find(I=>I.rangeId===t&&I.rangeType===o.CustomRangeType.HYPERLINK))==null?void 0:m.properties)==null?void 0:C.url;return v&&window.open(v,"_blank","noopener noreferrer"),!0}},D={docLink:"univer-doc-link",docLinkType:"univer-doc-link-type",docLinkContent:"univer-doc-link-content",docLinkUrl:"univer-doc-link-url",docLinkOperations:"univer-doc-link-operations",docLinkOperation:"univer-doc-link-operation"},j=()=>{var O,g;const e=p.useDependency(L),n=p.useDependency(o.ICommandService),i=p.useDependency(p.IMessageService),t=p.useDependency(o.LocaleService),r=p.useObservable(e.showingLink$),s=p.useDependency(o.IUniverInstanceService);if(!r)return null;const{unitId:c,linkId:d,segmentId:v,startIndex:h,endIndex:m}=r,C=s.getUnit(c,o.UniverInstanceType.UNIVER_DOC),I=C==null?void 0:C.getSelfOrHeaderFooterModel(v).getBody(),l=(O=I==null?void 0:I.customRanges)==null?void 0:O.find(x=>x.rangeId===d&&x.rangeType===o.CustomRangeType.HYPERLINK&&x.startIndex===h&&x.endIndex===m);if(!l)return null;const f=(g=l.properties)==null?void 0:g.url;return u.jsxs("div",{className:D.docLink,onClick:()=>{e.hideInfoPopup()},children:[u.jsxs("div",{className:ce(D.docLinkContent),onClick:()=>window.open(f),children:[u.jsx("div",{className:D.docLinkType,children:u.jsx(V,{})}),u.jsx(k.Tooltip,{showIfEllipsis:!0,title:f,children:u.jsx("span",{className:D.docLinkUrl,children:f})})]}),u.jsxs("div",{className:D.docLinkOperations,children:[u.jsx("div",{className:ce(D.docLinkOperation),onClick:()=>{navigator.clipboard.writeText(f),i.show({content:t.t("docLink.info.coped"),type:k.MessageType.Info})},children:u.jsx(k.Tooltip,{placement:"bottom",title:t.t("docLink.info.copy"),children:u.jsx(ie,{})})}),u.jsx("div",{className:D.docLinkOperation,onClick:()=>{n.executeCommand(M.id,{link:r})},children:u.jsx(k.Tooltip,{placement:"bottom",title:t.t("docLink.info.edit"),children:u.jsx(oe,{})})}),u.jsx("div",{className:D.docLinkOperation,onClick:()=>{n.executeCommand(de.id,{unitId:c,linkId:l.rangeId,segmentId:v})},children:u.jsx(k.Tooltip,{placement:"bottom",title:t.t("docLink.info.cancel"),children:u.jsx(re,{})})})]})]})};j.componentKey="univer.doc.link-info-popup";var je=Object.getOwnPropertyDescriptor,He=(e,n,i,t)=>{for(var r=t>1?void 0:t?je(n,i):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},q=(e,n)=>(i,t)=>n(i,t,e);let L=class extends o.Disposable{constructor(n,i,t){super();P(this,"_editingLink$",new E.BehaviorSubject(null));P(this,"_showingLink$",new E.BehaviorSubject(null));P(this,"editingLink$",this._editingLink$.asObservable());P(this,"showingLink$",this._showingLink$.asObservable());P(this,"_editPopup",null);P(this,"_infoPopup",null);this._docCanvasPopupManagerService=n,this._textSelectionManagerService=i,this._univerInstanceService=t,this.disposeWithMe(()=>{this._editingLink$.complete(),this._showingLink$.complete()})}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(n,i){this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(i);const t=this._textSelectionManagerService.getTextRanges({unitId:n,subUnitId:n});let r=t==null?void 0:t[t.length-1];if(i){const{segmentId:s,segmentPage:c,startIndex:d,endIndex:v}=i;r={collapsed:!1,startOffset:d,endOffset:v+1,segmentId:s,segmentPage:c},this._textSelectionManagerService.replaceDocRanges([{startOffset:d,endOffset:v+1}])}return r?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(r,{componentKey:N.componentKey,direction:"bottom"},n),this._editPopup):null}hideEditPopup(){var n;this._editingLink$.next(null),(n=this._editPopup)==null||n.dispose()}showInfoPopup(n){var h,m,C,I,l,f;const{linkId:i,unitId:t,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}=n;if(!(((h=this.showing)==null?void 0:h.linkId)===i&&((m=this.showing)==null?void 0:m.unitId)===t&&((C=this.showing)==null?void 0:C.segmentId)===r&&((I=this.showing)==null?void 0:I.segmentPage)===s&&((l=this.showing)==null?void 0:l.startIndex)===c&&((f=this.showing)==null?void 0:f.endIndex)===d||(this._infoPopup&&this._infoPopup.dispose(),!this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_DOC))))return this._showingLink$.next({unitId:t,linkId:i,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}),this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:c,endOffset:d+1,segmentId:r,segmentPage:s},{componentKey:j.componentKey,direction:"top-center",multipleDirection:"top",onClickOutside:()=>{this.hideInfoPopup()}},t),this._infoPopup}hideInfoPopup(){var n;this._showingLink$.next(null),(n=this._infoPopup)==null||n.dispose()}};L=He([q(0,o.Inject(b.DocCanvasPopManagerService)),q(1,o.Inject(y.DocSelectionManagerService)),q(2,o.IUniverInstanceService)],L);var $e=Object.getOwnPropertyDescriptor,Be=(e,n,i,t)=>{for(var r=t>1?void 0:t?$e(n,i):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},Z=(e,n)=>(i,t)=>n(i,t,e);let H=class extends o.Disposable{constructor(e,n,i){super(),this._commandService=e,this._univerInstanceService=n,this._docHyperLinkService=i,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var n,i,t;if(e.id===y.SetTextSelectionsOperation.id){const r=e.params,{unitId:s,ranges:c,segmentId:d}=r,v=this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_DOC),h=c[0];if(h&&v){const{startOffset:m,endOffset:C,collapsed:I,segmentPage:l}=h,f=(i=(n=v.getSelfOrHeaderFooterModel(d))==null?void 0:n.getBody())==null?void 0:i.customRanges;if(I){const O=(t=f==null?void 0:f.findIndex(g=>g.startIndex<m&&g.endIndex>C-1))!=null?t:-1;if(O>-1){const g=f[O];this._docHyperLinkService.showInfoPopup({unitId:s,linkId:g.rangeId,segmentId:d,segmentPage:l,startIndex:g.startIndex,endIndex:g.endIndex});return}}else if(f==null?void 0:f.find(g=>g.startIndex<=m&&g.endIndex>=C-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};H=Be([Z(0,o.ICommandService),Z(1,o.IUniverInstanceService),Z(2,o.Inject(L))],H);var Ke=Object.getOwnPropertyDescriptor,Ae=(e,n,i,t)=>{for(var r=t>1?void 0:t?Ke(n,i):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},w=(e,n)=>(i,t)=>n(i,t,e);let W=class extends o.Disposable{constructor(e,n,i,t,r,s){super(),this._context=e,this._docEventManagerService=n,this._commandService=i,this._hyperLinkPopupService=t,this._docSkeletonManagerService=r,this._docSelectionManagerService=s,!(this._context.unitId===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY||this._context.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)&&(this._initHover(),this._initClick())}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(Y.id)}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(e=>{var r;const n=e.find(s=>s.range.rangeType===o.CustomRangeType.HYPERLINK),i=this._docSelectionManagerService.getTextRanges(),t=i==null?void 0:i[0].segmentId;if(((r=n==null?void 0:n.segmentId)!=null?r:"")!==t){this._hideInfoPopup();return}n?this._commandService.executeCommand(Y.id,{unitId:this._context.unitId,linkId:n.range.rangeId,segmentId:n.segmentId,segmentPage:n.segmentPageIndex,rangeId:n.range.rangeId,startIndex:n.range.startIndex,endIndex:n.range.endIndex}):this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(e=>{const n=e.range;n&&this._commandService.executeCommand(le.id,{unitId:this._context.unitId,linkId:n.rangeId,segmentId:e.segmentId})}))}};W=Ae([w(1,o.Inject(b.DocEventManagerService)),w(2,o.ICommandService),w(3,o.Inject(L)),w(4,o.Inject(y.DocSkeletonManagerService)),w(5,o.Inject(y.DocSelectionManagerService))],W);var Fe=Object.getOwnPropertyDescriptor,Ve=(e,n,i,t)=>{for(var r=t>1?void 0:t?Fe(n,i):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},G=(e,n)=>(i,t)=>n(i,t,e);let z=class extends o.Disposable{constructor(e,n,i,t){super(),this._context=e,this._docInterceptorService=n,this._hyperLinkService=i,this._docRenderController=t,this._init(),this._initReRender()}_init(){this._docInterceptorService.intercept(y.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:(e,n,i)=>{if(!e)return i(e);const{unitId:t,index:r}=n,s=this._hyperLinkService.showing;if(!s)return i({...e,active:!1});const{linkId:c,unitId:d,startIndex:v,endIndex:h}=s,m=d===t&&e.rangeId===c&&r>=v&&r<=h;return i({...e,active:m})}})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(E.distinctUntilChanged((e,n)=>(e==null?void 0:e.linkId)===(n==null?void 0:n.linkId)&&(e==null?void 0:e.unitId)===(n==null?void 0:n.unitId)&&(e==null?void 0:e.startIndex)===(n==null?void 0:n.startIndex)),E.pairwise()).subscribe(([e,n])=>{n?n.unitId===this._context.unitId&&this._docRenderController.reRender(n.unitId):e&&e.unitId===this._context.unitId&&this._docRenderController.reRender(e.unitId)}))}};z=Ve([G(1,o.Inject(y.DocInterceptorService)),G(2,o.Inject(L)),G(3,o.Inject(b.DocRenderController))],z);const ue="doc-hyper-link-icon";function pe(e){return{id:M.id,type:p.MenuItemType.BUTTON,icon:ue,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:p.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC),disabled$:new E.Observable(function(n){const t=e.get(y.DocSelectionManagerService).textSelection$.pipe(E.debounceTime(16)).subscribe(()=>{n.next(ae(e))});return()=>{t.unsubscribe()}})}}const Ye={id:M.id,binding:p.MetaKeys.CTRL_COMMAND|p.KeyCode.K,description:"docLink.menu.tooltip",preconditions:b.whenDocAndEditorFocused},qe={[p.RibbonStartGroup.OTHERS]:{[M.id]:{order:0,menuItemFactory:pe}},[p.ContextMenuPosition.MAIN_AREA]:{[p.ContextMenuGroup.DATA]:{[M.id]:{order:0,menuItemFactory:pe}}}};var Ze=Object.getOwnPropertyDescriptor,We=(e,n,i,t)=>{for(var r=t>1?void 0:t?Ze(n,i):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},$=(e,n)=>(i,t)=>n(i,t,e);let B=class extends o.Disposable{constructor(e,n,i,t){super(),this._componentManager=e,this._commandService=n,this._menuManagerService=i,this._shortcutService=t,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[N,N.componentKey],[j,j.componentKey],[V,ue]].forEach(([e,n])=>{this._componentManager.register(n,e)})}_initCommands(){[ee,ne,de,M,Y,le].forEach(e=>{this._commandService.registerCommand(e)})}_initShortcut(){[Ye].forEach(e=>{this._shortcutService.registerShortcut(e)})}_initMenus(){this._menuManagerService.mergeMenu(qe)}};B=We([$(0,o.Inject(p.ComponentManager)),$(1,o.ICommandService),$(2,p.IMenuManagerService),$(3,p.IShortcutService)],B);const Ge="DOC_HYPER_LINK_UI_PLUGIN";var ze=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(e,n,i)=>n in e?ze(e,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[n]=i,Xe=(e,n,i,t)=>{for(var r=t>1?void 0:t?Je(n,i):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(r=c(r)||r);return r},J=(e,n)=>(i,t)=>n(i,t,e),ge=(e,n,i)=>Qe(e,typeof n!="symbol"?n+"":n,i);a.UniverDocsHyperLinkUIPlugin=class extends o.Plugin{constructor(n=X,i,t,r){super(),this._config=n,this._injector=i,this._renderManagerSrv=t,this._configService=r;const{menu:s,...c}=o.merge({},X,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Oe,c)}onStarting(){[[L],[B],[H]].forEach(i=>{this._injector.add(i)}),this._injector.get(B)}onReady(){this._injector.get(H)}onRendered(){this._initRenderModule()}_initRenderModule(){[[z],[W]].forEach(n=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,n)})}},ge(a.UniverDocsHyperLinkUIPlugin,"pluginName",Ge),ge(a.UniverDocsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC),a.UniverDocsHyperLinkUIPlugin=Xe([o.DependentOn(U.UniverDocsHyperLinkPlugin),J(1,o.Inject(o.Injector)),J(2,Le.IRenderManagerService),J(3,o.IConfigService)],a.UniverDocsHyperLinkUIPlugin),Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-hyper-link-ui",
3
- "version": "0.6.0",
3
+ "version": "0.6.1-nightly.202502211606",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -52,25 +52,25 @@
52
52
  "rxjs": ">=7.0.0"
53
53
  },
54
54
  "dependencies": {
55
- "@univerjs/icons": "^0.2.15",
55
+ "@univerjs/icons": "^0.2.20",
56
56
  "clsx": "^2.1.1",
57
- "@univerjs/core": "0.6.0",
58
- "@univerjs/design": "0.6.0",
59
- "@univerjs/docs": "0.6.0",
60
- "@univerjs/docs-ui": "0.6.0",
61
- "@univerjs/docs-hyper-link": "0.6.0",
62
- "@univerjs/engine-render": "0.6.0",
63
- "@univerjs/ui": "0.6.0"
57
+ "@univerjs/core": "0.6.1-nightly.202502211606",
58
+ "@univerjs/design": "0.6.1-nightly.202502211606",
59
+ "@univerjs/docs": "0.6.1-nightly.202502211606",
60
+ "@univerjs/docs-hyper-link": "0.6.1-nightly.202502211606",
61
+ "@univerjs/engine-render": "0.6.1-nightly.202502211606",
62
+ "@univerjs/docs-ui": "0.6.1-nightly.202502211606",
63
+ "@univerjs/ui": "0.6.1-nightly.202502211606"
64
64
  },
65
65
  "devDependencies": {
66
- "postcss": "^8.5.2",
66
+ "postcss": "^8.5.3",
67
67
  "react": "18.3.1",
68
68
  "rxjs": "^7.8.1",
69
69
  "tailwindcss": "^3.4.17",
70
70
  "typescript": "^5.7.3",
71
- "vite": "^6.1.0",
72
- "vitest": "^3.0.5",
73
- "@univerjs-infra/shared": "0.6.0"
71
+ "vite": "^6.1.1",
72
+ "vitest": "^3.0.6",
73
+ "@univerjs-infra/shared": "0.6.1"
74
74
  },
75
75
  "scripts": {
76
76
  "test": "vitest run",
package/LICENSE DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS