@univerjs/docs-hyper-link-ui 0.5.1-nightly.202412241606 → 0.5.1-nightly.202412261606

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,4 +1,4 @@
1
- "use strict";var Oe=Object.defineProperty;var Pe=(n,e,t)=>e in n?Oe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var P=(n,e,t)=>Pe(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),Re=require("@univerjs/docs-hyper-link"),Ee=require("@univerjs/engine-render"),C=require("@univerjs/docs"),K=require("@univerjs/docs-ui"),R=require("rxjs"),m=require("react"),S=require("@univerjs/design"),_=require("@univerjs/ui"),De="docs-hyper-link-ui.config",be={};var V={exports:{}},D={};/**
1
+ "use strict";var Pe=Object.defineProperty;var Re=(n,e,t)=>e in n?Pe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var P=(n,e,t)=>Re(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),Ee=require("@univerjs/docs-hyper-link"),De=require("@univerjs/engine-render"),C=require("@univerjs/docs"),K=require("@univerjs/docs-ui"),R=require("rxjs"),m=require("react"),S=require("@univerjs/design"),_=require("@univerjs/ui"),be="docs-hyper-link-ui.config",ae={};var V={exports:{}},D={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ae;function Me(){if(ae)return D;ae=1;var n=m,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function c(d,a,g){var u,h={},f=null,l=null;g!==void 0&&(f=""+g),a.key!==void 0&&(f=""+a.key),a.ref!==void 0&&(l=a.ref);for(u in a)i.call(a,u)&&!s.hasOwnProperty(u)&&(h[u]=a[u]);if(d&&d.defaultProps)for(u in a=d.defaultProps,a)h[u]===void 0&&(h[u]=a[u]);return{$$typeof:e,type:d,key:f,ref:l,props:h,_owner:r.current}}return D.Fragment=t,D.jsx=c,D.jsxs=c,D}var le;function Ue(){return le||(le=1,V.exports=Me()),V.exports}var p=Ue();const ge={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}},fe={id:"docs.command.update-hyper-link",type:o.CommandType.COMMAND,handler(n,e){var I;if(!e)return!1;const{unitId:t,payload:i,segmentId:r,linkId:s}=e,c=n.get(o.ICommandService),d=n.get(o.IUniverInstanceService),g=n.get(C.DocSelectionManagerService).getActiveTextRange(),u=d.getUnit(t,o.UniverInstanceType.UNIVER_DOC);if(!g||!u)return!1;const f=(I=o.getBodySlice(u.getSelfOrHeaderFooterModel(r).getBody(),g.startOffset,g.endOffset).textRuns)==null?void 0:I[0];f&&(f.ed=e.label.length+1);const l=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:f?[f]:void 0},selection:{startOffset:g.startOffset,endOffset:g.endOffset,collapsed:!1,segmentId:r}});return l?c.syncExecuteCommand(l.id,l.params):!1}},we="univer-docs-link-edit",Te="univer-docs-link-edit-title",je="univer-docs-link-edit-close",Ne="univer-docs-link-edit-buttons",$e="univer-docs-link-edit-button",j={docsLinkEdit:we,docsLinkEditTitle:Te,docsLinkEditClose:je,docsLinkEditButtons:Ne,docsLinkEditButton:$e};function He(n){return/^[a-zA-Z]+:\/\//.test(n)}function Be(n){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(n)}function Ae(n){return He(n)?n:Be(n)?`mailto://${n}`:`https://${n}`}const $=()=>{const n=o.useDependency(k),e=o.useDependency(o.LocaleService),t=o.useObservable(n.editingLink$),i=o.useDependency(o.ICommandService),r=o.useDependency(o.IUniverInstanceService),s=o.useDependency(C.DocSelectionManagerService),[c,d]=m.useState(""),[a,g]=m.useState(""),[u,h]=m.useState(!1),f=o.Tools.isLegalUrl(c),l=t?r.getUnit(t.unitId,o.UniverInstanceType.UNIVER_DOC):r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);m.useEffect(()=>{var ee,ne,te,ie,re,oe,se,ce,de;const v=s.getActiveTextRange();if(!v)return;if(t){const w=(ee=l==null?void 0:l.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:ee.getBody(),T=(ne=w==null?void 0:w.customRanges)==null?void 0:ne.find(F=>(t==null?void 0:t.linkId)===F.rangeId&&F.startIndex===t.startIndex&&F.endIndex===t.endIndex);l&&T&&(d((ie=(te=T.properties)==null?void 0:te.url)!=null?ie:""),g(o.BuildTextUtils.transform.getPlainText(o.getBodySlice(w,T.startIndex,T.endIndex+1).dataStream)));return}const x=(re=l==null?void 0:l.getSelfOrHeaderFooterModel(v.segmentId))==null?void 0:re.getBody(),X=x?v:null,U=X&&((se=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(X,(oe=x==null?void 0:x.customRanges)!=null?oe:[]))==null?void 0:se[0]);l&&U&&d((de=(ce=U==null?void 0:U.properties)==null?void 0:ce.url)!=null?de:"")},[l,t,s,r]);const I=()=>{n.hideEditPopup()},L=()=>{if(h(!0),!f||!l)return;const v=Ae(c);if(!t)i.executeCommand(ge.id,{unitId:l.getUnitId(),payload:v});else{if(!a)return;i.executeCommand(fe.id,{unitId:l.getUnitId(),payload:v,linkId:t.linkId,label:a,segmentId:t.segmentId})}n.hideEditPopup()};if(l)return p.jsxs("div",{className:j.docsLinkEdit,children:[p.jsxs("div",{children:[t?p.jsx(S.FormLayout,{label:e.t("docLink.edit.label"),error:u&&!a?e.t("docLink.edit.labelError"):"",children:p.jsx(S.Input,{value:a,onChange:g,autoFocus:!0,onKeyDown:v=>{v.keyCode===_.KeyCode.ENTER&&L()}})}):null,p.jsx(S.FormLayout,{label:e.t("docLink.edit.address"),error:u&&!f?e.t("docLink.edit.addressError"):"",children:p.jsx(S.Input,{value:c,onChange:d,autoFocus:!0,onKeyDown:v=>{v.keyCode===_.KeyCode.ENTER&&L()}})})]}),p.jsxs("div",{className:j.docsLinkEditButtons,children:[p.jsx(S.Button,{className:j.docsLinkEditButton,onClick:I,children:e.t("docLink.edit.cancel")}),p.jsx(S.Button,{disabled:!c,className:j.docsLinkEditButton,type:"primary",onClick:L,children:e.t("docLink.edit.confirm")})]})]})};$.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)},Ke=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=m.forwardRef(function(n,e){var t=n.icon,i=n.id,r=n.className,s=n.extend,c=Ke(n,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),a=m.useRef("_".concat(qe()));return ve(t,"".concat(i),{defIds:t.defIds,idSuffix:a.current},y({ref:e,className:d},c),s)});function ve(n,e,t,i,r){return m.createElement(n.tag,y(y({key:e},Fe(n,t,r)),i),(Ve(n,t).children||[]).map(function(s,c){return ve(s,"".concat(e,"-").concat(n.tag,"-").concat(c),t,void 0,r)}))}function Fe(n,e,t){var i=y({},n.attrs);t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1);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 Ve(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 qe(){return Math.random().toString(36).substring(2,8)}M.displayName="UniverIcon";var Ye={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"}}]},he=m.forwardRef(function(n,e){return m.createElement(M,Object.assign({},n,{id:"copy-single",ref:e,icon:Ye}))});he.displayName="CopySingle";var Ze={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"}}]},Q=m.forwardRef(function(n,e){return m.createElement(M,Object.assign({},n,{id:"link-single",ref:e,icon:Ze}))});Q.displayName="LinkSingle";var We={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"}}]},Ie=m.forwardRef(function(n,e){return m.createElement(M,Object.assign({},n,{id:"unlink-single",ref:e,icon:We}))});Ie.displayName="UnlinkSingle";var Ge={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"}}]},me=m.forwardRef(function(n,e){return m.createElement(M,Object.assign({},n,{id:"write-single",ref:e,icon:Ge}))});me.displayName="WriteSingle";function _e(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=_e(n[e]))&&(i&&(i+=" "),i+=t)}else for(t in n)n[t]&&(i&&(i+=" "),i+=t);return i}function ue(){for(var n,e,t=0,i="",r=arguments.length;t<r;t++)(n=arguments[t])&&(e=_e(n))&&(i&&(i+=" "),i+=e);return i}const Ce={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}},ye=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)},E={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(ye(n)&&!t)return!1;const r=n.get(k),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}},G={type:o.CommandType.OPERATION,id:"doc.operation.toggle-hyper-link-info-popup",handler(n,e){const t=n.get(k);return e?(t.showInfoPopup(e),!0):(t.hideInfoPopup(),!0)}},Se={type:o.CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(n,e){var g,u,h;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(),a=(h=(u=(g=d==null?void 0:d.customRanges)==null?void 0:g.find(f=>f.rangeId===i&&f.rangeType===o.CustomRangeType.HYPERLINK))==null?void 0:u.properties)==null?void 0:h.url;return a&&window.open(a,"_blank","noopener noreferrer"),!0}},Je="univer-doc-link",ze="univer-doc-link-type",Qe="univer-doc-link-content",Xe="univer-doc-link-content-error",en="univer-doc-link-url",nn="univer-doc-link-operations",tn="univer-doc-link-operation",rn="univer-doc-link-operation-error",O={docLink:Je,docLinkType:ze,docLinkContent:Qe,docLinkContentError:Xe,docLinkUrl:en,docLinkOperations:nn,docLinkOperation:tn,docLinkOperationError:rn},H=()=>{var L,v;const n=o.useDependency(k),e=o.useDependency(o.ICommandService),t=o.useDependency(_.IMessageService),i=o.useDependency(o.LocaleService),r=_.useObservable(n.showingLink$),s=o.useDependency(o.IUniverInstanceService);if(!r)return null;const{unitId:c,linkId:d,segmentId:a,startIndex:g,endIndex:u}=r,h=s.getUnit(c,o.UniverInstanceType.UNIVER_DOC),f=h==null?void 0:h.getSelfOrHeaderFooterModel(a).getBody(),l=(L=f==null?void 0:f.customRanges)==null?void 0:L.find(x=>x.rangeId===d&&x.rangeType===o.CustomRangeType.HYPERLINK&&x.startIndex===g&&x.endIndex===u);if(!l)return null;const I=(v=l.properties)==null?void 0:v.url;return p.jsxs("div",{className:O.docLink,onClick:()=>{n.hideInfoPopup()},children:[p.jsxs("div",{className:ue(O.docLinkContent),onClick:()=>window.open(I),children:[p.jsx("div",{className:O.docLinkType,children:p.jsx(Q,{})}),p.jsx(S.Tooltip,{showIfEllipsis:!0,title:I,children:p.jsx("span",{className:O.docLinkUrl,children:I})})]}),p.jsxs("div",{className:O.docLinkOperations,children:[p.jsx("div",{className:ue(O.docLinkOperation),onClick:()=>{navigator.clipboard.writeText(I),t.show({content:i.t("docLink.info.coped"),type:S.MessageType.Info})},children:p.jsx(S.Tooltip,{placement:"bottom",title:i.t("docLink.info.copy"),children:p.jsx(he,{})})}),p.jsx("div",{className:O.docLinkOperation,onClick:()=>{e.executeCommand(E.id,{link:r})},children:p.jsx(S.Tooltip,{placement:"bottom",title:i.t("docLink.info.edit"),children:p.jsx(me,{})})}),p.jsx("div",{className:O.docLinkOperation,onClick:()=>{e.executeCommand(Ce.id,{unitId:c,linkId:l.rangeId,segmentId:a})},children:p.jsx(S.Tooltip,{placement:"bottom",title:i.t("docLink.info.cancel"),children:p.jsx(Ie,{})})})]})]})};H.componentKey="univer.doc.link-info-popup";var on=Object.defineProperty,sn=Object.getOwnPropertyDescriptor,cn=(n,e,t,i)=>{for(var r=i>1?void 0:i?sn(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&on(e,t,r),r},q=(n,e)=>(t,i)=>e(t,i,n);let k=class extends o.Disposable{constructor(e,t,i){super();P(this,"_editingLink$",new R.BehaviorSubject(null));P(this,"_showingLink$",new R.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:a}=t;r={collapsed:!1,startOffset:d,endOffset:a+1,segmentId:s,segmentPage:c},this._textSelectionManagerService.replaceDocRanges([{startOffset:d,endOffset:a+1}])}return r?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(r,{componentKey:$.componentKey,direction:"bottom"},e),this._editPopup):null}hideEditPopup(){var e;this._editingLink$.next(null),(e=this._editPopup)==null||e.dispose()}showInfoPopup(e){var g,u,h,f,l,I;const{linkId:t,unitId:i,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}=e;if(!(((g=this.showing)==null?void 0:g.linkId)===t&&((u=this.showing)==null?void 0:u.unitId)===i&&((h=this.showing)==null?void 0:h.segmentId)===r&&((f=this.showing)==null?void 0:f.segmentPage)===s&&((l=this.showing)==null?void 0:l.startIndex)===c&&((I=this.showing)==null?void 0:I.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()}};k=cn([q(0,o.Inject(K.DocCanvasPopManagerService)),q(1,o.Inject(C.DocSelectionManagerService)),q(2,o.IUniverInstanceService)],k);var dn=Object.defineProperty,an=Object.getOwnPropertyDescriptor,ln=(n,e,t,i)=>{for(var r=i>1?void 0:i?an(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&dn(e,t,r),r},Y=(n,e)=>(t,i)=>e(t,i,n);let B=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,a=this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_DOC),g=c[0];if(g&&a){const{startOffset:u,endOffset:h,collapsed:f,segmentPage:l}=g,I=(t=(e=a.getSelfOrHeaderFooterModel(d))==null?void 0:e.getBody())==null?void 0:t.customRanges;if(f){const L=(i=I==null?void 0:I.findIndex(v=>v.startIndex<u&&v.endIndex>h-1))!=null?i:-1;if(L>-1){const v=I[L];this._docHyperLinkService.showInfoPopup({unitId:s,linkId:v.rangeId,segmentId:d,segmentPage:l,startIndex:v.startIndex,endIndex:v.endIndex});return}}else if(I==null?void 0:I.find(v=>v.startIndex<=u&&v.endIndex>=h-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};B=ln([Y(0,o.ICommandService),Y(1,o.IUniverInstanceService),Y(2,o.Inject(k))],B);var un=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,gn=(n,e,t,i)=>{for(var r=i>1?void 0:i?pn(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&un(e,t,r),r},b=(n,e)=>(t,i)=>e(t,i,n);let J=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(G.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(G.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(Se.id,{unitId:this._context.unitId,linkId:e.rangeId,segmentId:n.segmentId})}))}};J=gn([b(1,o.Inject(K.DocEventManagerService)),b(2,o.ICommandService),b(3,o.Inject(k)),b(4,o.Inject(C.DocSkeletonManagerService)),b(5,o.Inject(C.DocSelectionManagerService))],J);var fn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,hn=(n,e,t,i)=>{for(var r=i>1?void 0:i?vn(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&fn(e,t,r),r},Z=(n,e)=>(t,i)=>e(t,i,n);let z=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:a,endIndex:g}=s,u=d===i&&n.rangeId===c&&r>=a&&r<=g;return t({...n,active:u})}})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(R.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)),R.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)}))}};z=hn([Z(1,o.Inject(C.DocInterceptorService)),Z(2,o.Inject(k)),Z(3,o.Inject(K.DocRenderController))],z);const Le="doc-hyper-link-icon";function pe(n){return{id:E.id,type:_.MenuItemType.BUTTON,icon:Le,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:_.getMenuHiddenObservable(n,o.UniverInstanceType.UNIVER_DOC),disabled$:new R.Observable(function(e){const i=n.get(C.DocSelectionManagerService).textSelection$.pipe(R.debounceTime(16)).subscribe(()=>{e.next(ye(n))});return()=>{i.unsubscribe()}})}}const In={id:E.id,binding:_.MetaKeys.CTRL_COMMAND|_.KeyCode.K,description:"docLink.menu.tooltip",preconditions:K.whenDocAndEditorFocused},mn={[_.RibbonStartGroup.OTHERS]:{[E.id]:{order:0,menuItemFactory:pe}},[_.ContextMenuPosition.MAIN_AREA]:{[_.ContextMenuGroup.DATA]:{[E.id]:{order:0,menuItemFactory:pe}}}};var _n=Object.defineProperty,Cn=Object.getOwnPropertyDescriptor,yn=(n,e,t,i)=>{for(var r=i>1?void 0:i?Cn(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&_n(e,t,r),r},N=(n,e)=>(t,i)=>e(t,i,n);let A=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(){[[$,$.componentKey],[H,H.componentKey],[Q,Le]].forEach(([n,e])=>{this._componentManager.register(e,n)})}_initCommands(){[ge,fe,Ce,E,G,Se].forEach(n=>{this._commandService.registerCommand(n)})}_initShortcut(){[In].forEach(n=>{this._shortcutService.registerShortcut(n)})}_initMenus(){this._menuManagerService.mergeMenu(mn)}};A=yn([N(0,o.Inject(_.ComponentManager)),N(1,o.ICommandService),N(2,_.IMenuManagerService),N(3,_.IShortcutService)],A);const Sn="DOC_HYPER_LINK_UI_PLUGIN";var ke=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,kn=(n,e,t)=>e in n?ke(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,xn=(n,e,t,i)=>{for(var r=i>1?void 0:i?Ln(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&ke(e,t,r),r},W=(n,e)=>(t,i)=>e(t,i,n),xe=(n,e,t)=>kn(n,typeof e!="symbol"?e+"":e,t);exports.UniverDocsHyperLinkUIPlugin=class extends o.Plugin{constructor(e=be,t,i,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=i,this._configService=r;const{menu:s,...c}=this._config;s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(De,c)}onStarting(){[[k],[A],[B]].forEach(t=>{this._injector.add(t)}),this._injector.get(A)}onReady(){this._injector.get(B)}onRendered(){this._initRenderModule()}_initRenderModule(){[[z],[J]].forEach(e=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,e)})}};xe(exports.UniverDocsHyperLinkUIPlugin,"pluginName",Sn);xe(exports.UniverDocsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC);exports.UniverDocsHyperLinkUIPlugin=xn([o.DependentOn(Re.UniverDocsHyperLinkPlugin),W(1,o.Inject(o.Injector)),W(2,Ee.IRenderManagerService),W(3,o.IConfigService)],exports.UniverDocsHyperLinkUIPlugin);
9
+ */var le;function Me(){if(le)return D;le=1;var n=m,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function c(d,a,g){var u,h={},f=null,l=null;g!==void 0&&(f=""+g),a.key!==void 0&&(f=""+a.key),a.ref!==void 0&&(l=a.ref);for(u in a)i.call(a,u)&&!s.hasOwnProperty(u)&&(h[u]=a[u]);if(d&&d.defaultProps)for(u in a=d.defaultProps,a)h[u]===void 0&&(h[u]=a[u]);return{$$typeof:e,type:d,key:f,ref:l,props:h,_owner:r.current}}return D.Fragment=t,D.jsx=c,D.jsxs=c,D}var ue;function Ue(){return ue||(ue=1,V.exports=Me()),V.exports}var p=Ue();const fe={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}},ve={id:"docs.command.update-hyper-link",type:o.CommandType.COMMAND,handler(n,e){var I;if(!e)return!1;const{unitId:t,payload:i,segmentId:r,linkId:s}=e,c=n.get(o.ICommandService),d=n.get(o.IUniverInstanceService),g=n.get(C.DocSelectionManagerService).getActiveTextRange(),u=d.getUnit(t,o.UniverInstanceType.UNIVER_DOC);if(!g||!u)return!1;const f=(I=o.getBodySlice(u.getSelfOrHeaderFooterModel(r).getBody(),g.startOffset,g.endOffset).textRuns)==null?void 0:I[0];f&&(f.ed=e.label.length+1);const l=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:f?[f]:void 0},selection:{startOffset:g.startOffset,endOffset:g.endOffset,collapsed:!1,segmentId:r}});return l?c.syncExecuteCommand(l.id,l.params):!1}},we="univer-docs-link-edit",Te="univer-docs-link-edit-title",je="univer-docs-link-edit-close",Ne="univer-docs-link-edit-buttons",$e="univer-docs-link-edit-button",j={docsLinkEdit:we,docsLinkEditTitle:Te,docsLinkEditClose:je,docsLinkEditButtons:Ne,docsLinkEditButton:$e};function He(n){return/^[a-zA-Z]+:\/\//.test(n)}function Be(n){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(n)}function Ae(n){return He(n)?n:Be(n)?`mailto://${n}`:`https://${n}`}const $=()=>{const n=o.useDependency(k),e=o.useDependency(o.LocaleService),t=o.useObservable(n.editingLink$),i=o.useDependency(o.ICommandService),r=o.useDependency(o.IUniverInstanceService),s=o.useDependency(C.DocSelectionManagerService),[c,d]=m.useState(""),[a,g]=m.useState(""),[u,h]=m.useState(!1),f=o.Tools.isLegalUrl(c),l=t?r.getUnit(t.unitId,o.UniverInstanceType.UNIVER_DOC):r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);m.useEffect(()=>{var ee,ne,te,ie,re,oe,se,ce,de;const v=s.getActiveTextRange();if(!v)return;if(t){const w=(ee=l==null?void 0:l.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:ee.getBody(),T=(ne=w==null?void 0:w.customRanges)==null?void 0:ne.find(F=>(t==null?void 0:t.linkId)===F.rangeId&&F.startIndex===t.startIndex&&F.endIndex===t.endIndex);l&&T&&(d((ie=(te=T.properties)==null?void 0:te.url)!=null?ie:""),g(o.BuildTextUtils.transform.getPlainText(o.getBodySlice(w,T.startIndex,T.endIndex+1).dataStream)));return}const x=(re=l==null?void 0:l.getSelfOrHeaderFooterModel(v.segmentId))==null?void 0:re.getBody(),X=x?v:null,U=X&&((se=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(X,(oe=x==null?void 0:x.customRanges)!=null?oe:[]))==null?void 0:se[0]);l&&U&&d((de=(ce=U==null?void 0:U.properties)==null?void 0:ce.url)!=null?de:"")},[l,t,s,r]);const I=()=>{n.hideEditPopup()},L=()=>{if(h(!0),!f||!l)return;const v=Ae(c);if(!t)i.executeCommand(fe.id,{unitId:l.getUnitId(),payload:v});else{if(!a)return;i.executeCommand(ve.id,{unitId:l.getUnitId(),payload:v,linkId:t.linkId,label:a,segmentId:t.segmentId})}n.hideEditPopup()};if(l)return p.jsxs("div",{className:j.docsLinkEdit,children:[p.jsxs("div",{children:[t?p.jsx(S.FormLayout,{label:e.t("docLink.edit.label"),error:u&&!a?e.t("docLink.edit.labelError"):"",children:p.jsx(S.Input,{value:a,onChange:g,autoFocus:!0,onKeyDown:v=>{v.keyCode===_.KeyCode.ENTER&&L()}})}):null,p.jsx(S.FormLayout,{label:e.t("docLink.edit.address"),error:u&&!f?e.t("docLink.edit.addressError"):"",children:p.jsx(S.Input,{value:c,onChange:d,autoFocus:!0,onKeyDown:v=>{v.keyCode===_.KeyCode.ENTER&&L()}})})]}),p.jsxs("div",{className:j.docsLinkEditButtons,children:[p.jsx(S.Button,{className:j.docsLinkEditButton,onClick:I,children:e.t("docLink.edit.cancel")}),p.jsx(S.Button,{disabled:!c,className:j.docsLinkEditButton,type:"primary",onClick:L,children:e.t("docLink.edit.confirm")})]})]})};$.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)},Ke=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=m.forwardRef(function(n,e){var t=n.icon,i=n.id,r=n.className,s=n.extend,c=Ke(n,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),a=m.useRef("_".concat(qe()));return he(t,"".concat(i),{defIds:t.defIds,idSuffix:a.current},y({ref:e,className:d},c),s)});function he(n,e,t,i,r){return m.createElement(n.tag,y(y({key:e},Fe(n,t,r)),i),(Ve(n,t).children||[]).map(function(s,c){return he(s,"".concat(e,"-").concat(n.tag,"-").concat(c),t,void 0,r)}))}function Fe(n,e,t){var i=y({},n.attrs);t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1);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 Ve(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 qe(){return Math.random().toString(36).substring(2,8)}M.displayName="UniverIcon";var Ye={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=m.forwardRef(function(n,e){return m.createElement(M,Object.assign({},n,{id:"copy-single",ref:e,icon:Ye}))});Ie.displayName="CopySingle";var Ze={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"}}]},Q=m.forwardRef(function(n,e){return m.createElement(M,Object.assign({},n,{id:"link-single",ref:e,icon:Ze}))});Q.displayName="LinkSingle";var We={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"}}]},me=m.forwardRef(function(n,e){return m.createElement(M,Object.assign({},n,{id:"unlink-single",ref:e,icon:We}))});me.displayName="UnlinkSingle";var Ge={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"}}]},_e=m.forwardRef(function(n,e){return m.createElement(M,Object.assign({},n,{id:"write-single",ref:e,icon:Ge}))});_e.displayName="WriteSingle";function Ce(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=Ce(n[e]))&&(i&&(i+=" "),i+=t)}else for(t in n)n[t]&&(i&&(i+=" "),i+=t);return i}function pe(){for(var n,e,t=0,i="",r=arguments.length;t<r;t++)(n=arguments[t])&&(e=Ce(n))&&(i&&(i+=" "),i+=e);return i}const ye={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}},Se=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)},E={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(Se(n)&&!t)return!1;const r=n.get(k),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}},G={type:o.CommandType.OPERATION,id:"doc.operation.toggle-hyper-link-info-popup",handler(n,e){const t=n.get(k);return e?(t.showInfoPopup(e),!0):(t.hideInfoPopup(),!0)}},Le={type:o.CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(n,e){var g,u,h;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(),a=(h=(u=(g=d==null?void 0:d.customRanges)==null?void 0:g.find(f=>f.rangeId===i&&f.rangeType===o.CustomRangeType.HYPERLINK))==null?void 0:u.properties)==null?void 0:h.url;return a&&window.open(a,"_blank","noopener noreferrer"),!0}},Je="univer-doc-link",ze="univer-doc-link-type",Qe="univer-doc-link-content",Xe="univer-doc-link-content-error",en="univer-doc-link-url",nn="univer-doc-link-operations",tn="univer-doc-link-operation",rn="univer-doc-link-operation-error",O={docLink:Je,docLinkType:ze,docLinkContent:Qe,docLinkContentError:Xe,docLinkUrl:en,docLinkOperations:nn,docLinkOperation:tn,docLinkOperationError:rn},H=()=>{var L,v;const n=o.useDependency(k),e=o.useDependency(o.ICommandService),t=o.useDependency(_.IMessageService),i=o.useDependency(o.LocaleService),r=_.useObservable(n.showingLink$),s=o.useDependency(o.IUniverInstanceService);if(!r)return null;const{unitId:c,linkId:d,segmentId:a,startIndex:g,endIndex:u}=r,h=s.getUnit(c,o.UniverInstanceType.UNIVER_DOC),f=h==null?void 0:h.getSelfOrHeaderFooterModel(a).getBody(),l=(L=f==null?void 0:f.customRanges)==null?void 0:L.find(x=>x.rangeId===d&&x.rangeType===o.CustomRangeType.HYPERLINK&&x.startIndex===g&&x.endIndex===u);if(!l)return null;const I=(v=l.properties)==null?void 0:v.url;return p.jsxs("div",{className:O.docLink,onClick:()=>{n.hideInfoPopup()},children:[p.jsxs("div",{className:pe(O.docLinkContent),onClick:()=>window.open(I),children:[p.jsx("div",{className:O.docLinkType,children:p.jsx(Q,{})}),p.jsx(S.Tooltip,{showIfEllipsis:!0,title:I,children:p.jsx("span",{className:O.docLinkUrl,children:I})})]}),p.jsxs("div",{className:O.docLinkOperations,children:[p.jsx("div",{className:pe(O.docLinkOperation),onClick:()=>{navigator.clipboard.writeText(I),t.show({content:i.t("docLink.info.coped"),type:S.MessageType.Info})},children:p.jsx(S.Tooltip,{placement:"bottom",title:i.t("docLink.info.copy"),children:p.jsx(Ie,{})})}),p.jsx("div",{className:O.docLinkOperation,onClick:()=>{e.executeCommand(E.id,{link:r})},children:p.jsx(S.Tooltip,{placement:"bottom",title:i.t("docLink.info.edit"),children:p.jsx(_e,{})})}),p.jsx("div",{className:O.docLinkOperation,onClick:()=>{e.executeCommand(ye.id,{unitId:c,linkId:l.rangeId,segmentId:a})},children:p.jsx(S.Tooltip,{placement:"bottom",title:i.t("docLink.info.cancel"),children:p.jsx(me,{})})})]})]})};H.componentKey="univer.doc.link-info-popup";var on=Object.defineProperty,sn=Object.getOwnPropertyDescriptor,cn=(n,e,t,i)=>{for(var r=i>1?void 0:i?sn(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&on(e,t,r),r},q=(n,e)=>(t,i)=>e(t,i,n);let k=class extends o.Disposable{constructor(e,t,i){super();P(this,"_editingLink$",new R.BehaviorSubject(null));P(this,"_showingLink$",new R.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:a}=t;r={collapsed:!1,startOffset:d,endOffset:a+1,segmentId:s,segmentPage:c},this._textSelectionManagerService.replaceDocRanges([{startOffset:d,endOffset:a+1}])}return r?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(r,{componentKey:$.componentKey,direction:"bottom"},e),this._editPopup):null}hideEditPopup(){var e;this._editingLink$.next(null),(e=this._editPopup)==null||e.dispose()}showInfoPopup(e){var g,u,h,f,l,I;const{linkId:t,unitId:i,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}=e;if(!(((g=this.showing)==null?void 0:g.linkId)===t&&((u=this.showing)==null?void 0:u.unitId)===i&&((h=this.showing)==null?void 0:h.segmentId)===r&&((f=this.showing)==null?void 0:f.segmentPage)===s&&((l=this.showing)==null?void 0:l.startIndex)===c&&((I=this.showing)==null?void 0:I.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()}};k=cn([q(0,o.Inject(K.DocCanvasPopManagerService)),q(1,o.Inject(C.DocSelectionManagerService)),q(2,o.IUniverInstanceService)],k);var dn=Object.defineProperty,an=Object.getOwnPropertyDescriptor,ln=(n,e,t,i)=>{for(var r=i>1?void 0:i?an(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&dn(e,t,r),r},Y=(n,e)=>(t,i)=>e(t,i,n);let B=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,a=this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_DOC),g=c[0];if(g&&a){const{startOffset:u,endOffset:h,collapsed:f,segmentPage:l}=g,I=(t=(e=a.getSelfOrHeaderFooterModel(d))==null?void 0:e.getBody())==null?void 0:t.customRanges;if(f){const L=(i=I==null?void 0:I.findIndex(v=>v.startIndex<u&&v.endIndex>h-1))!=null?i:-1;if(L>-1){const v=I[L];this._docHyperLinkService.showInfoPopup({unitId:s,linkId:v.rangeId,segmentId:d,segmentPage:l,startIndex:v.startIndex,endIndex:v.endIndex});return}}else if(I==null?void 0:I.find(v=>v.startIndex<=u&&v.endIndex>=h-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};B=ln([Y(0,o.ICommandService),Y(1,o.IUniverInstanceService),Y(2,o.Inject(k))],B);var un=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,gn=(n,e,t,i)=>{for(var r=i>1?void 0:i?pn(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&un(e,t,r),r},b=(n,e)=>(t,i)=>e(t,i,n);let J=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(G.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(G.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(Le.id,{unitId:this._context.unitId,linkId:e.rangeId,segmentId:n.segmentId})}))}};J=gn([b(1,o.Inject(K.DocEventManagerService)),b(2,o.ICommandService),b(3,o.Inject(k)),b(4,o.Inject(C.DocSkeletonManagerService)),b(5,o.Inject(C.DocSelectionManagerService))],J);var fn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,hn=(n,e,t,i)=>{for(var r=i>1?void 0:i?vn(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&fn(e,t,r),r},Z=(n,e)=>(t,i)=>e(t,i,n);let z=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:a,endIndex:g}=s,u=d===i&&n.rangeId===c&&r>=a&&r<=g;return t({...n,active:u})}})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(R.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)),R.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)}))}};z=hn([Z(1,o.Inject(C.DocInterceptorService)),Z(2,o.Inject(k)),Z(3,o.Inject(K.DocRenderController))],z);const ke="doc-hyper-link-icon";function ge(n){return{id:E.id,type:_.MenuItemType.BUTTON,icon:ke,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:_.getMenuHiddenObservable(n,o.UniverInstanceType.UNIVER_DOC),disabled$:new R.Observable(function(e){const i=n.get(C.DocSelectionManagerService).textSelection$.pipe(R.debounceTime(16)).subscribe(()=>{e.next(Se(n))});return()=>{i.unsubscribe()}})}}const In={id:E.id,binding:_.MetaKeys.CTRL_COMMAND|_.KeyCode.K,description:"docLink.menu.tooltip",preconditions:K.whenDocAndEditorFocused},mn={[_.RibbonStartGroup.OTHERS]:{[E.id]:{order:0,menuItemFactory:ge}},[_.ContextMenuPosition.MAIN_AREA]:{[_.ContextMenuGroup.DATA]:{[E.id]:{order:0,menuItemFactory:ge}}}};var _n=Object.defineProperty,Cn=Object.getOwnPropertyDescriptor,yn=(n,e,t,i)=>{for(var r=i>1?void 0:i?Cn(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&_n(e,t,r),r},N=(n,e)=>(t,i)=>e(t,i,n);let A=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(){[[$,$.componentKey],[H,H.componentKey],[Q,ke]].forEach(([n,e])=>{this._componentManager.register(e,n)})}_initCommands(){[fe,ve,ye,E,G,Le].forEach(n=>{this._commandService.registerCommand(n)})}_initShortcut(){[In].forEach(n=>{this._shortcutService.registerShortcut(n)})}_initMenus(){this._menuManagerService.mergeMenu(mn)}};A=yn([N(0,o.Inject(_.ComponentManager)),N(1,o.ICommandService),N(2,_.IMenuManagerService),N(3,_.IShortcutService)],A);const Sn="DOC_HYPER_LINK_UI_PLUGIN";var xe=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,kn=(n,e,t)=>e in n?xe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,xn=(n,e,t,i)=>{for(var r=i>1?void 0:i?Ln(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&xe(e,t,r),r},W=(n,e)=>(t,i)=>e(t,i,n),Oe=(n,e,t)=>kn(n,typeof e!="symbol"?e+"":e,t);exports.UniverDocsHyperLinkUIPlugin=class extends o.Plugin{constructor(e=ae,t,i,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=i,this._configService=r;const{menu:s,...c}=o.Tools.deepMerge(ae,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(be,c)}onStarting(){[[k],[A],[B]].forEach(t=>{this._injector.add(t)}),this._injector.get(A)}onReady(){this._injector.get(B)}onRendered(){this._initRenderModule()}_initRenderModule(){[[z],[J]].forEach(e=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,e)})}};Oe(exports.UniverDocsHyperLinkUIPlugin,"pluginName",Sn);Oe(exports.UniverDocsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC);exports.UniverDocsHyperLinkUIPlugin=xn([o.DependentOn(Ee.UniverDocsHyperLinkPlugin),W(1,o.Inject(o.Injector)),W(2,De.IRenderManagerService),W(3,o.IConfigService)],exports.UniverDocsHyperLinkUIPlugin);
package/lib/es/index.js CHANGED
@@ -1,16 +1,16 @@
1
- var Be = Object.defineProperty;
2
- var Ke = (n, e, t) => e in n ? Be(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var P = (n, e, t) => Ke(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { CommandType as E, ICommandService as x, generateRandomId as Fe, CustomRangeType as D, IUniverInstanceService as O, UniverInstanceType as I, getBodySlice as Oe, useDependency as S, LocaleService as Pe, useObservable as Ve, Tools as Ye, BuildTextUtils as me, Disposable as N, Inject as _, DOCS_ZEN_EDITOR_UNIT_ID_KEY as Ze, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as We, DependentOn as Ge, Injector as qe, Plugin as Je, IConfigService as ze } from "@univerjs/core";
5
- import { UniverDocsHyperLinkPlugin as Qe } from "@univerjs/docs-hyper-link";
6
- import { IRenderManagerService as Xe } from "@univerjs/engine-render";
7
- import { addCustomRangeBySelectionFactory as en, DocSelectionManagerService as b, replaceSelectionFactory as nn, deleteCustomRangeFactory as tn, SetTextSelectionsOperation as rn, DocSkeletonManagerService as on, DocInterceptorService as sn, DOC_INTERCEPTOR_POINT as cn } from "@univerjs/docs";
8
- import { DocCanvasPopManagerService as dn, DocEventManagerService as an, DocRenderController as ln, whenDocAndEditorFocused as un } from "@univerjs/docs-ui";
9
- import { BehaviorSubject as _e, distinctUntilChanged as pn, pairwise as fn, Observable as gn, debounceTime as hn } from "rxjs";
10
- import vn, { useState as J, useEffect as mn, forwardRef as j, useRef as _n, createElement as U } from "react";
11
- import { FormLayout as Ie, Input as Ce, Button as Se, Tooltip as B, MessageType as In } from "@univerjs/design";
12
- import { KeyCode as te, IMessageService as Cn, useObservable as Sn, MetaKeys as Ln, MenuItemType as yn, getMenuHiddenObservable as kn, RibbonStartGroup as xn, ContextMenuPosition as On, ContextMenuGroup as Pn, ComponentManager as Rn, IMenuManagerService as En, IShortcutService as bn } from "@univerjs/ui";
13
- const Mn = "docs-hyper-link-ui.config", wn = {};
1
+ var Fe = Object.defineProperty;
2
+ var Ve = (n, e, t) => e in n ? Fe(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var P = (n, e, t) => Ve(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { CommandType as E, ICommandService as x, generateRandomId as Ye, CustomRangeType as D, IUniverInstanceService as O, UniverInstanceType as I, getBodySlice as Pe, useDependency as S, LocaleService as Re, useObservable as Ze, Tools as Ee, BuildTextUtils as me, Disposable as N, Inject as _, DOCS_ZEN_EDITOR_UNIT_ID_KEY as We, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as Ge, DependentOn as qe, Injector as Je, Plugin as ze, IConfigService as Qe } from "@univerjs/core";
5
+ import { UniverDocsHyperLinkPlugin as Xe } from "@univerjs/docs-hyper-link";
6
+ import { IRenderManagerService as en } from "@univerjs/engine-render";
7
+ import { addCustomRangeBySelectionFactory as nn, DocSelectionManagerService as b, replaceSelectionFactory as tn, deleteCustomRangeFactory as rn, SetTextSelectionsOperation as on, DocSkeletonManagerService as sn, DocInterceptorService as cn, DOC_INTERCEPTOR_POINT as dn } from "@univerjs/docs";
8
+ import { DocCanvasPopManagerService as an, DocEventManagerService as ln, DocRenderController as un, whenDocAndEditorFocused as pn } from "@univerjs/docs-ui";
9
+ import { BehaviorSubject as _e, distinctUntilChanged as fn, pairwise as gn, Observable as hn, debounceTime as vn } from "rxjs";
10
+ import mn, { useState as J, useEffect as _n, forwardRef as j, useRef as In, createElement as U } from "react";
11
+ import { FormLayout as Ie, Input as Ce, Button as Se, Tooltip as B, MessageType as Cn } from "@univerjs/design";
12
+ import { KeyCode as te, IMessageService as Sn, useObservable as Ln, MetaKeys as yn, MenuItemType as kn, getMenuHiddenObservable as xn, RibbonStartGroup as On, ContextMenuPosition as Pn, ContextMenuGroup as Rn, ComponentManager as En, IMenuManagerService as bn, IShortcutService as Mn } from "@univerjs/ui";
13
+ const wn = "docs-hyper-link-ui.config", Le = {};
14
14
  var z = { exports: {} }, M = {};
15
15
  /**
16
16
  * @license React
@@ -21,11 +21,11 @@ var z = { exports: {} }, M = {};
21
21
  * This source code is licensed under the MIT license found in the
22
22
  * LICENSE file in the root directory of this source tree.
23
23
  */
24
- var Le;
24
+ var ye;
25
25
  function Dn() {
26
- if (Le) return M;
27
- Le = 1;
28
- var n = vn, e = Symbol.for("react.element"), t = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, r = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, o = { key: !0, ref: !0, __self: !0, __source: !0 };
26
+ if (ye) return M;
27
+ ye = 1;
28
+ var n = mn, e = Symbol.for("react.element"), t = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, r = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, o = { key: !0, ref: !0, __self: !0, __source: !0 };
29
29
  function s(c, d, p) {
30
30
  var l, h = {}, f = null, a = null;
31
31
  p !== void 0 && (f = "" + p), d.key !== void 0 && (f = "" + d.key), d.ref !== void 0 && (a = d.ref);
@@ -35,18 +35,18 @@ function Dn() {
35
35
  }
36
36
  return M.Fragment = t, M.jsx = s, M.jsxs = s, M;
37
37
  }
38
- var ye;
38
+ var ke;
39
39
  function Nn() {
40
- return ye || (ye = 1, z.exports = Dn()), z.exports;
40
+ return ke || (ke = 1, z.exports = Dn()), z.exports;
41
41
  }
42
42
  var u = Nn();
43
- const Re = {
43
+ const be = {
44
44
  type: E.COMMAND,
45
45
  id: "docs.command.add-hyper-link",
46
46
  async handler(n, e) {
47
47
  if (!e)
48
48
  return !1;
49
- const { payload: t, unitId: i, selections: r } = e, o = n.get(x), s = Fe(), c = en(
49
+ const { payload: t, unitId: i, selections: r } = e, o = n.get(x), s = Ye(), c = nn(
50
50
  n,
51
51
  {
52
52
  rangeId: s,
@@ -60,7 +60,7 @@ const Re = {
60
60
  );
61
61
  return c ? o.syncExecuteCommand(c.id, c.params) : !1;
62
62
  }
63
- }, Ee = {
63
+ }, Me = {
64
64
  id: "docs.command.update-hyper-link",
65
65
  type: E.COMMAND,
66
66
  handler(n, e) {
@@ -70,9 +70,9 @@ const Re = {
70
70
  const { unitId: t, payload: i, segmentId: r, linkId: o } = e, s = n.get(x), c = n.get(O), p = n.get(b).getActiveTextRange(), l = c.getUnit(t, I.UNIVER_DOC);
71
71
  if (!p || !l)
72
72
  return !1;
73
- const f = (v = Oe(l.getSelfOrHeaderFooterModel(r).getBody(), p.startOffset, p.endOffset).textRuns) == null ? void 0 : v[0];
73
+ const f = (v = Pe(l.getSelfOrHeaderFooterModel(r).getBody(), p.startOffset, p.endOffset).textRuns) == null ? void 0 : v[0];
74
74
  f && (f.ed = e.label.length + 1);
75
- const a = nn(n, {
75
+ const a = tn(n, {
76
76
  unitId: t,
77
77
  body: {
78
78
  dataStream: `${e.label}`,
@@ -113,15 +113,15 @@ function Kn(n) {
113
113
  return An(n) ? n : Bn(n) ? `mailto://${n}` : `https://${n}`;
114
114
  }
115
115
  const V = () => {
116
- const n = S(L), e = S(Pe), t = Ve(n.editingLink$), i = S(x), r = S(O), o = S(b), [s, c] = J(""), [d, p] = J(""), [l, h] = J(!1), f = Ye.isLegalUrl(s), a = t ? r.getUnit(t.unitId, I.UNIVER_DOC) : r.getCurrentUnitForType(I.UNIVER_DOC);
117
- mn(() => {
116
+ const n = S(L), e = S(Re), t = Ze(n.editingLink$), i = S(x), r = S(O), o = S(b), [s, c] = J(""), [d, p] = J(""), [l, h] = J(!1), f = Ee.isLegalUrl(s), a = t ? r.getUnit(t.unitId, I.UNIVER_DOC) : r.getCurrentUnitForType(I.UNIVER_DOC);
117
+ _n(() => {
118
118
  var de, ae, le, ue, pe, fe, ge, he, ve;
119
119
  const g = o.getActiveTextRange();
120
120
  if (!g)
121
121
  return;
122
122
  if (t) {
123
123
  const H = (de = a == null ? void 0 : a.getSelfOrHeaderFooterModel(t.segmentId)) == null ? void 0 : de.getBody(), A = (ae = H == null ? void 0 : H.customRanges) == null ? void 0 : ae.find((q) => (t == null ? void 0 : t.linkId) === q.rangeId && q.startIndex === t.startIndex && q.endIndex === t.endIndex);
124
- a && A && (c((ue = (le = A.properties) == null ? void 0 : le.url) != null ? ue : ""), p(me.transform.getPlainText(Oe(H, A.startIndex, A.endIndex + 1).dataStream)));
124
+ a && A && (c((ue = (le = A.properties) == null ? void 0 : le.url) != null ? ue : ""), p(me.transform.getPlainText(Pe(H, A.startIndex, A.endIndex + 1).dataStream)));
125
125
  return;
126
126
  }
127
127
  const y = (pe = a == null ? void 0 : a.getSelfOrHeaderFooterModel(g.segmentId)) == null ? void 0 : pe.getBody(), ce = y ? g : null, T = ce && ((ge = me.customRange.getCustomRangesInterestsWithSelection(ce, (fe = y == null ? void 0 : y.customRanges) != null ? fe : [])) == null ? void 0 : ge[0]);
@@ -134,14 +134,14 @@ const V = () => {
134
134
  return;
135
135
  const g = Kn(s);
136
136
  if (!t)
137
- i.executeCommand(Re.id, {
137
+ i.executeCommand(be.id, {
138
138
  unitId: a.getUnitId(),
139
139
  payload: g
140
140
  });
141
141
  else {
142
142
  if (!d)
143
143
  return;
144
- i.executeCommand(Ee.id, {
144
+ i.executeCommand(Me.id, {
145
145
  unitId: a.getUnitId(),
146
146
  payload: g,
147
147
  linkId: t.linkId,
@@ -230,12 +230,12 @@ var m = function() {
230
230
  e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(n, i[r]) && (t[i[r]] = n[i[r]]);
231
231
  return t;
232
232
  }, $ = j(function(n, e) {
233
- var t = n.icon, i = n.id, r = n.className, o = n.extend, s = Fn(n, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), d = _n("_".concat(Zn()));
234
- return be(t, "".concat(i), { defIds: t.defIds, idSuffix: d.current }, m({ ref: e, className: c }, s), o);
233
+ var t = n.icon, i = n.id, r = n.className, o = n.extend, s = Fn(n, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), d = In("_".concat(Zn()));
234
+ return we(t, "".concat(i), { defIds: t.defIds, idSuffix: d.current }, m({ ref: e, className: c }, s), o);
235
235
  });
236
- function be(n, e, t, i, r) {
236
+ function we(n, e, t, i, r) {
237
237
  return U(n.tag, m(m({ key: e }, Vn(n, t, r)), i), (Yn(n, t).children || []).map(function(o, s) {
238
- return be(o, "".concat(e, "-").concat(n.tag, "-").concat(s), t, void 0, r);
238
+ return we(o, "".concat(e, "-").concat(n.tag, "-").concat(s), t, void 0, r);
239
239
  }));
240
240
  }
241
241
  function Vn(n, e, t) {
@@ -257,14 +257,14 @@ function Zn() {
257
257
  return Math.random().toString(36).substring(2, 8);
258
258
  }
259
259
  $.displayName = "UniverIcon";
260
- var Wn = { 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" } }] }, Me = j(function(n, e) {
260
+ var Wn = { 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" } }] }, De = j(function(n, e) {
261
261
  return U($, Object.assign({}, n, {
262
262
  id: "copy-single",
263
263
  ref: e,
264
264
  icon: Wn
265
265
  }));
266
266
  });
267
- Me.displayName = "CopySingle";
267
+ De.displayName = "CopySingle";
268
268
  var Gn = { 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" } }] }, se = j(function(n, e) {
269
269
  return U($, Object.assign({}, n, {
270
270
  id: "link-single",
@@ -273,45 +273,45 @@ var Gn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em"
273
273
  }));
274
274
  });
275
275
  se.displayName = "LinkSingle";
276
- var qn = { 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" } }] }, we = j(function(n, e) {
276
+ var qn = { 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" } }] }, Ne = j(function(n, e) {
277
277
  return U($, Object.assign({}, n, {
278
278
  id: "unlink-single",
279
279
  ref: e,
280
280
  icon: qn
281
281
  }));
282
282
  });
283
- we.displayName = "UnlinkSingle";
284
- var Jn = { 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" } }] }, De = j(function(n, e) {
283
+ Ne.displayName = "UnlinkSingle";
284
+ var Jn = { 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" } }] }, je = j(function(n, e) {
285
285
  return U($, Object.assign({}, n, {
286
286
  id: "write-single",
287
287
  ref: e,
288
288
  icon: Jn
289
289
  }));
290
290
  });
291
- De.displayName = "WriteSingle";
292
- function Ne(n) {
291
+ je.displayName = "WriteSingle";
292
+ function Ue(n) {
293
293
  var e, t, i = "";
294
294
  if (typeof n == "string" || typeof n == "number") i += n;
295
295
  else if (typeof n == "object") if (Array.isArray(n)) {
296
296
  var r = n.length;
297
- for (e = 0; e < r; e++) n[e] && (t = Ne(n[e])) && (i && (i += " "), i += t);
297
+ for (e = 0; e < r; e++) n[e] && (t = Ue(n[e])) && (i && (i += " "), i += t);
298
298
  } else for (t in n) n[t] && (i && (i += " "), i += t);
299
299
  return i;
300
300
  }
301
- function ke() {
302
- for (var n, e, t = 0, i = "", r = arguments.length; t < r; t++) (n = arguments[t]) && (e = Ne(n)) && (i && (i += " "), i += e);
301
+ function xe() {
302
+ for (var n, e, t = 0, i = "", r = arguments.length; t < r; t++) (n = arguments[t]) && (e = Ue(n)) && (i && (i += " "), i += e);
303
303
  return i;
304
304
  }
305
- const je = {
305
+ const $e = {
306
306
  type: E.COMMAND,
307
307
  id: "docs.command.delete-hyper-link",
308
308
  async handler(n, e) {
309
309
  if (!e)
310
310
  return !1;
311
- const { unitId: t, linkId: i, segmentId: r } = e, o = n.get(x), s = tn(n, { unitId: t, rangeId: i, segmentId: r });
311
+ const { unitId: t, linkId: i, segmentId: r } = e, o = n.get(x), s = rn(n, { unitId: t, rangeId: i, segmentId: r });
312
312
  return s ? await o.syncExecuteCommand(s.id, s.params) : !1;
313
313
  }
314
- }, Ue = (n) => {
314
+ }, Te = (n) => {
315
315
  const e = n.get(b), t = n.get(O), i = e.getTextRanges();
316
316
  if (!(i != null && i.length))
317
317
  return !0;
@@ -323,7 +323,7 @@ const je = {
323
323
  handler(n, e) {
324
324
  var s;
325
325
  const t = e == null ? void 0 : e.link, i = n.get(O);
326
- if (Ue(n) && !t)
326
+ if (Te(n) && !t)
327
327
  return !1;
328
328
  const r = n.get(L), o = (t == null ? void 0 : t.unitId) || ((s = i.getCurrentUnitForType(I.UNIVER_DOC)) == null ? void 0 : s.getUnitId());
329
329
  return o ? (r.showEditPopup(o, t), !0) : !1;
@@ -335,7 +335,7 @@ const je = {
335
335
  const t = n.get(L);
336
336
  return e ? (t.showInfoPopup(e), !0) : (t.hideInfoPopup(), !0);
337
337
  }
338
- }, $e = {
338
+ }, He = {
339
339
  type: E.OPERATION,
340
340
  id: "doc.operation.click-hyper-link",
341
341
  handler(n, e) {
@@ -356,7 +356,7 @@ const je = {
356
356
  docLinkOperationError: rt
357
357
  }, Y = () => {
358
358
  var C, g;
359
- const n = S(L), e = S(x), t = S(Cn), i = S(Pe), r = Sn(n.showingLink$), o = S(O);
359
+ const n = S(L), e = S(x), t = S(Sn), i = S(Re), r = Ln(n.showingLink$), o = S(O);
360
360
  if (!r)
361
361
  return null;
362
362
  const { unitId: s, linkId: c, segmentId: d, startIndex: p, endIndex: l } = r, h = o.getUnit(s, I.UNIVER_DOC), f = h == null ? void 0 : h.getSelfOrHeaderFooterModel(d).getBody(), a = (C = f == null ? void 0 : f.customRanges) == null ? void 0 : C.find((y) => y.rangeId === c && y.rangeType === D.HYPERLINK && y.startIndex === p && y.endIndex === l);
@@ -371,7 +371,7 @@ const je = {
371
371
  n.hideInfoPopup();
372
372
  },
373
373
  children: [
374
- /* @__PURE__ */ u.jsxs("div", { className: ke(k.docLinkContent), onClick: () => window.open(v), children: [
374
+ /* @__PURE__ */ u.jsxs("div", { className: xe(k.docLinkContent), onClick: () => window.open(v), children: [
375
375
  /* @__PURE__ */ u.jsx("div", { className: k.docLinkType, children: /* @__PURE__ */ u.jsx(se, {}) }),
376
376
  /* @__PURE__ */ u.jsx(B, { showIfEllipsis: !0, title: v, children: /* @__PURE__ */ u.jsx("span", { className: k.docLinkUrl, children: v }) })
377
377
  ] }),
@@ -379,14 +379,14 @@ const je = {
379
379
  /* @__PURE__ */ u.jsx(
380
380
  "div",
381
381
  {
382
- className: ke(k.docLinkOperation),
382
+ className: xe(k.docLinkOperation),
383
383
  onClick: () => {
384
384
  navigator.clipboard.writeText(v), t.show({
385
385
  content: i.t("docLink.info.coped"),
386
- type: In.Info
386
+ type: Cn.Info
387
387
  });
388
388
  },
389
- children: /* @__PURE__ */ u.jsx(B, { placement: "bottom", title: i.t("docLink.info.copy"), children: /* @__PURE__ */ u.jsx(Me, {}) })
389
+ children: /* @__PURE__ */ u.jsx(B, { placement: "bottom", title: i.t("docLink.info.copy"), children: /* @__PURE__ */ u.jsx(De, {}) })
390
390
  }
391
391
  ),
392
392
  /* @__PURE__ */ u.jsx(
@@ -398,7 +398,7 @@ const je = {
398
398
  link: r
399
399
  });
400
400
  },
401
- children: /* @__PURE__ */ u.jsx(B, { placement: "bottom", title: i.t("docLink.info.edit"), children: /* @__PURE__ */ u.jsx(De, {}) })
401
+ children: /* @__PURE__ */ u.jsx(B, { placement: "bottom", title: i.t("docLink.info.edit"), children: /* @__PURE__ */ u.jsx(je, {}) })
402
402
  }
403
403
  ),
404
404
  /* @__PURE__ */ u.jsx(
@@ -406,13 +406,13 @@ const je = {
406
406
  {
407
407
  className: k.docLinkOperation,
408
408
  onClick: () => {
409
- e.executeCommand(je.id, {
409
+ e.executeCommand($e.id, {
410
410
  unitId: s,
411
411
  linkId: a.rangeId,
412
412
  segmentId: d
413
413
  });
414
414
  },
415
- children: /* @__PURE__ */ u.jsx(B, { placement: "bottom", title: i.t("docLink.info.cancel"), children: /* @__PURE__ */ u.jsx(we, {}) })
415
+ children: /* @__PURE__ */ u.jsx(B, { placement: "bottom", title: i.t("docLink.info.cancel"), children: /* @__PURE__ */ u.jsx(Ne, {}) })
416
416
  }
417
417
  )
418
418
  ] })
@@ -504,7 +504,7 @@ let L = class extends N {
504
504
  }
505
505
  };
506
506
  L = ct([
507
- Q(0, _(dn)),
507
+ Q(0, _(an)),
508
508
  Q(1, _(b)),
509
509
  Q(2, O)
510
510
  ], L);
@@ -521,7 +521,7 @@ let Z = class extends N {
521
521
  this.disposeWithMe(
522
522
  this._commandService.onCommandExecuted((n) => {
523
523
  var e, t, i;
524
- if (n.id === rn.id) {
524
+ if (n.id === on.id) {
525
525
  const r = n.params, { unitId: o, ranges: s, segmentId: c } = r, d = this._univerInstanceService.getUnit(o, I.UNIVER_DOC), p = s[0];
526
526
  if (p && d) {
527
527
  const { startOffset: l, endOffset: h, collapsed: f, segmentPage: a } = p, v = (t = (e = d.getSelfOrHeaderFooterModel(c)) == null ? void 0 : e.getBody()) == null ? void 0 : t.customRanges;
@@ -553,7 +553,7 @@ var ut = Object.defineProperty, pt = Object.getOwnPropertyDescriptor, ft = (n, e
553
553
  }, w = (n, e) => (t, i) => e(t, i, n);
554
554
  let re = class extends N {
555
555
  constructor(n, e, t, i, r, o) {
556
- super(), this._context = n, this._docEventManagerService = e, this._commandService = t, this._hyperLinkPopupService = i, this._docSkeletonManagerService = r, this._docSelectionManagerService = o, !(this._context.unitId === Ze || this._context.unitId === We) && (this._initHover(), this._initClick());
556
+ super(), this._context = n, this._docEventManagerService = e, this._commandService = t, this._hyperLinkPopupService = i, this._docSkeletonManagerService = r, this._docSelectionManagerService = o, !(this._context.unitId === We || this._context.unitId === Ge) && (this._initHover(), this._initClick());
557
557
  }
558
558
  get _skeleton() {
559
559
  return this._docSkeletonManagerService.getSkeleton();
@@ -592,7 +592,7 @@ let re = class extends N {
592
592
  this._docEventManagerService.clickCustomRanges$.subscribe((n) => {
593
593
  const e = n.range;
594
594
  e && this._commandService.executeCommand(
595
- $e.id,
595
+ He.id,
596
596
  {
597
597
  unitId: this._context.unitId,
598
598
  linkId: e.rangeId,
@@ -604,10 +604,10 @@ let re = class extends N {
604
604
  }
605
605
  };
606
606
  re = ft([
607
- w(1, _(an)),
607
+ w(1, _(ln)),
608
608
  w(2, x),
609
609
  w(3, _(L)),
610
- w(4, _(on)),
610
+ w(4, _(sn)),
611
611
  w(5, _(b))
612
612
  ], re);
613
613
  var gt = Object.defineProperty, ht = Object.getOwnPropertyDescriptor, vt = (n, e, t, i) => {
@@ -620,7 +620,7 @@ let oe = class extends N {
620
620
  super(), this._context = n, this._docInterceptorService = e, this._hyperLinkService = t, this._docRenderController = i, this._init(), this._initReRender();
621
621
  }
622
622
  _init() {
623
- this._docInterceptorService.intercept(cn.CUSTOM_RANGE, {
623
+ this._docInterceptorService.intercept(dn.CUSTOM_RANGE, {
624
624
  handler: (n, e, t) => {
625
625
  if (!n)
626
626
  return t(n);
@@ -640,30 +640,30 @@ let oe = class extends N {
640
640
  }
641
641
  _initReRender() {
642
642
  this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(
643
- pn((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)),
644
- fn()
643
+ fn((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)),
644
+ gn()
645
645
  ).subscribe(([n, e]) => {
646
646
  e ? e.unitId === this._context.unitId && this._docRenderController.reRender(e.unitId) : n && n.unitId === this._context.unitId && this._docRenderController.reRender(n.unitId);
647
647
  }));
648
648
  }
649
649
  };
650
650
  oe = vt([
651
- ee(1, _(sn)),
651
+ ee(1, _(cn)),
652
652
  ee(2, _(L)),
653
- ee(3, _(ln))
653
+ ee(3, _(un))
654
654
  ], oe);
655
- const Te = "doc-hyper-link-icon";
656
- function xe(n) {
655
+ const Ae = "doc-hyper-link-icon";
656
+ function Oe(n) {
657
657
  return {
658
658
  id: R.id,
659
- type: yn.BUTTON,
660
- icon: Te,
659
+ type: kn.BUTTON,
660
+ icon: Ae,
661
661
  title: "docLink.menu.tooltip",
662
662
  tooltip: "docLink.menu.tooltip",
663
- hidden$: kn(n, I.UNIVER_DOC),
664
- disabled$: new gn(function(e) {
665
- const i = n.get(b).textSelection$.pipe(hn(16)).subscribe(() => {
666
- e.next(Ue(n));
663
+ hidden$: xn(n, I.UNIVER_DOC),
664
+ disabled$: new hn(function(e) {
665
+ const i = n.get(b).textSelection$.pipe(vn(16)).subscribe(() => {
666
+ e.next(Te(n));
667
667
  });
668
668
  return () => {
669
669
  i.unsubscribe();
@@ -673,21 +673,21 @@ function xe(n) {
673
673
  }
674
674
  const mt = {
675
675
  id: R.id,
676
- binding: Ln.CTRL_COMMAND | te.K,
676
+ binding: yn.CTRL_COMMAND | te.K,
677
677
  description: "docLink.menu.tooltip",
678
- preconditions: un
678
+ preconditions: pn
679
679
  }, _t = {
680
- [xn.OTHERS]: {
680
+ [On.OTHERS]: {
681
681
  [R.id]: {
682
682
  order: 0,
683
- menuItemFactory: xe
683
+ menuItemFactory: Oe
684
684
  }
685
685
  },
686
- [On.MAIN_AREA]: {
687
- [Pn.DATA]: {
686
+ [Pn.MAIN_AREA]: {
687
+ [Rn.DATA]: {
688
688
  [R.id]: {
689
689
  order: 0,
690
- menuItemFactory: xe
690
+ menuItemFactory: Oe
691
691
  }
692
692
  }
693
693
  }
@@ -705,19 +705,19 @@ let W = class extends N {
705
705
  [
706
706
  [V, V.componentKey],
707
707
  [Y, Y.componentKey],
708
- [se, Te]
708
+ [se, Ae]
709
709
  ].forEach(([n, e]) => {
710
710
  this._componentManager.register(e, n);
711
711
  });
712
712
  }
713
713
  _initCommands() {
714
714
  [
715
- Re,
716
- Ee,
717
- je,
715
+ be,
716
+ Me,
717
+ $e,
718
718
  R,
719
719
  ie,
720
- $e
720
+ He
721
721
  ].forEach((n) => {
722
722
  this._commandService.registerCommand(n);
723
723
  });
@@ -732,22 +732,25 @@ let W = class extends N {
732
732
  }
733
733
  };
734
734
  W = St([
735
- F(0, _(Rn)),
735
+ F(0, _(En)),
736
736
  F(1, x),
737
- F(2, En),
738
- F(3, bn)
737
+ F(2, bn),
738
+ F(3, Mn)
739
739
  ], W);
740
740
  const Lt = "DOC_HYPER_LINK_UI_PLUGIN";
741
- var He = Object.defineProperty, yt = Object.getOwnPropertyDescriptor, kt = (n, e, t) => e in n ? He(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, xt = (n, e, t, i) => {
741
+ var Be = Object.defineProperty, yt = Object.getOwnPropertyDescriptor, kt = (n, e, t) => e in n ? Be(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, xt = (n, e, t, i) => {
742
742
  for (var r = i > 1 ? void 0 : i ? yt(e, t) : e, o = n.length - 1, s; o >= 0; o--)
743
743
  (s = n[o]) && (r = (i ? s(e, t, r) : s(r)) || r);
744
- return i && r && He(e, t, r), r;
745
- }, ne = (n, e) => (t, i) => e(t, i, n), Ae = (n, e, t) => kt(n, typeof e != "symbol" ? e + "" : e, t);
746
- let G = class extends Je {
747
- constructor(n = wn, e, t, i) {
744
+ return i && r && Be(e, t, r), r;
745
+ }, ne = (n, e) => (t, i) => e(t, i, n), Ke = (n, e, t) => kt(n, typeof e != "symbol" ? e + "" : e, t);
746
+ let G = class extends ze {
747
+ constructor(n = Le, e, t, i) {
748
748
  super(), this._config = n, this._injector = e, this._renderManagerSrv = t, this._configService = i;
749
- const { menu: r, ...o } = this._config;
750
- r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(Mn, o);
749
+ const { menu: r, ...o } = Ee.deepMerge(
750
+ Le,
751
+ this._config
752
+ );
753
+ r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(wn, o);
751
754
  }
752
755
  onStarting() {
753
756
  [
@@ -773,13 +776,13 @@ let G = class extends Je {
773
776
  });
774
777
  }
775
778
  };
776
- Ae(G, "pluginName", Lt);
777
- Ae(G, "type", I.UNIVER_DOC);
779
+ Ke(G, "pluginName", Lt);
780
+ Ke(G, "type", I.UNIVER_DOC);
778
781
  G = xt([
779
- Ge(Qe),
780
- ne(1, _(qe)),
781
- ne(2, Xe),
782
- ne(3, ze)
782
+ qe(Xe),
783
+ ne(1, _(Je)),
784
+ ne(2, en),
785
+ ne(3, Qe)
783
786
  ], G);
784
787
  export {
785
788
  G as UniverDocsHyperLinkUIPlugin
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(p,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"),require("@univerjs/design"),require("@univerjs/ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-hyper-link","@univerjs/engine-render","@univerjs/docs","@univerjs/docs-ui","rxjs","react","@univerjs/design","@univerjs/ui"],o):(p=typeof globalThis<"u"?globalThis:p||self,o(p.UniverDocsHyperLinkUi={},p.UniverCore,p.UniverDocsHyperLink,p.UniverEngineRender,p.UniverDocs,p.UniverDocsUi,p.rxjs,p.React,p.UniverDesign,p.UniverUi))})(this,function(p,o,E,Re,y,b,D,_,L,C){"use strict";var pn=Object.defineProperty;var fn=(p,o,E)=>o in p?pn(p,o,{enumerable:!0,configurable:!0,writable:!0,value:E}):p[o]=E;var R=(p,o,E)=>fn(p,typeof o!="symbol"?o+"":o,E);const Ee="docs-hyper-link-ui.config",De={};var Y={exports:{}},j={};/**
1
+ (function(p,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"),require("@univerjs/design"),require("@univerjs/ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-hyper-link","@univerjs/engine-render","@univerjs/docs","@univerjs/docs-ui","rxjs","react","@univerjs/design","@univerjs/ui"],o):(p=typeof globalThis<"u"?globalThis:p||self,o(p.UniverDocsHyperLinkUi={},p.UniverCore,p.UniverDocsHyperLink,p.UniverEngineRender,p.UniverDocs,p.UniverDocsUi,p.rxjs,p.React,p.UniverDesign,p.UniverUi))})(this,function(p,o,E,Ee,y,b,D,_,L,C){"use strict";var pn=Object.defineProperty;var fn=(p,o,E)=>o in p?pn(p,o,{enumerable:!0,configurable:!0,writable:!0,value:E}):p[o]=E;var R=(p,o,E)=>fn(p,typeof o!="symbol"?o+"":o,E);const De="docs-hyper-link-ui.config",ne={};var Y={exports:{}},j={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ne;function Ue(){if(ne)return j;ne=1;var n=_,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function c(d,a,v){var u,I={},h=null,l=null;v!==void 0&&(h=""+v),a.key!==void 0&&(h=""+a.key),a.ref!==void 0&&(l=a.ref);for(u in a)i.call(a,u)&&!s.hasOwnProperty(u)&&(I[u]=a[u]);if(d&&d.defaultProps)for(u in a=d.defaultProps,a)I[u]===void 0&&(I[u]=a[u]);return{$$typeof:e,type:d,key:h,ref:l,props:I,_owner:r.current}}return j.Fragment=t,j.jsx=c,j.jsxs=c,j}var te;function je(){return te||(te=1,Y.exports=Ue()),Y.exports}var f=je();const ie={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=y.addCustomRangeBySelectionFactory(n,{rangeId:c,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:t},unitId:i,selections:r});return d?s.syncExecuteCommand(d.id,d.params):!1}},re={id:"docs.command.update-hyper-link",type:o.CommandType.COMMAND,handler(n,e){var m;if(!e)return!1;const{unitId:t,payload:i,segmentId:r,linkId:s}=e,c=n.get(o.ICommandService),d=n.get(o.IUniverInstanceService),v=n.get(y.DocSelectionManagerService).getActiveTextRange(),u=d.getUnit(t,o.UniverInstanceType.UNIVER_DOC);if(!v||!u)return!1;const h=(m=o.getBodySlice(u.getSelfOrHeaderFooterModel(r).getBody(),v.startOffset,v.endOffset).textRuns)==null?void 0:m[0];h&&(h.ed=e.label.length+1);const l=y.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:h?[h]:void 0},selection:{startOffset:v.startOffset,endOffset:v.endOffset,collapsed:!1,segmentId:r}});return l?c.syncExecuteCommand(l.id,l.params):!1}},w={docsLinkEdit:"univer-docs-link-edit",docsLinkEditTitle:"univer-docs-link-edit-title",docsLinkEditClose:"univer-docs-link-edit-close",docsLinkEditButtons:"univer-docs-link-edit-buttons",docsLinkEditButton:"univer-docs-link-edit-button"};function Me(n){return/^[a-zA-Z]+:\/\//.test(n)}function Te(n){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(n)}function be(n){return Me(n)?n:Te(n)?`mailto://${n}`:`https://${n}`}const N=()=>{const n=o.useDependency(k),e=o.useDependency(o.LocaleService),t=o.useObservable(n.editingLink$),i=o.useDependency(o.ICommandService),r=o.useDependency(o.IUniverInstanceService),s=o.useDependency(y.DocSelectionManagerService),[c,d]=_.useState(""),[a,v]=_.useState(""),[u,I]=_.useState(!1),h=o.Tools.isLegalUrl(c),l=t?r.getUnit(t.unitId,o.UniverInstanceType.UNIVER_DOC):r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);_.useEffect(()=>{var _e,Ce,ye,Se,Le,ke,xe,Oe,Pe;const g=s.getActiveTextRange();if(!g)return;if(t){const $=(_e=l==null?void 0:l.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:_e.getBody(),V=(Ce=$==null?void 0:$.customRanges)==null?void 0:Ce.find(ee=>(t==null?void 0:t.linkId)===ee.rangeId&&ee.startIndex===t.startIndex&&ee.endIndex===t.endIndex);l&&V&&(d((Se=(ye=V.properties)==null?void 0:ye.url)!=null?Se:""),v(o.BuildTextUtils.transform.getPlainText(o.getBodySlice($,V.startIndex,V.endIndex+1).dataStream)));return}const O=(Le=l==null?void 0:l.getSelfOrHeaderFooterModel(g.segmentId))==null?void 0:Le.getBody(),me=O?g:null,F=me&&((xe=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(me,(ke=O==null?void 0:O.customRanges)!=null?ke:[]))==null?void 0:xe[0]);l&&F&&d((Pe=(Oe=F==null?void 0:F.properties)==null?void 0:Oe.url)!=null?Pe:"")},[l,t,s,r]);const m=()=>{n.hideEditPopup()},x=()=>{if(I(!0),!h||!l)return;const g=be(c);if(!t)i.executeCommand(ie.id,{unitId:l.getUnitId(),payload:g});else{if(!a)return;i.executeCommand(re.id,{unitId:l.getUnitId(),payload:g,linkId:t.linkId,label:a,segmentId:t.segmentId})}n.hideEditPopup()};if(l)return f.jsxs("div",{className:w.docsLinkEdit,children:[f.jsxs("div",{children:[t?f.jsx(L.FormLayout,{label:e.t("docLink.edit.label"),error:u&&!a?e.t("docLink.edit.labelError"):"",children:f.jsx(L.Input,{value:a,onChange:v,autoFocus:!0,onKeyDown:g=>{g.keyCode===C.KeyCode.ENTER&&x()}})}):null,f.jsx(L.FormLayout,{label:e.t("docLink.edit.address"),error:u&&!h?e.t("docLink.edit.addressError"):"",children:f.jsx(L.Input,{value:c,onChange:d,autoFocus:!0,onKeyDown:g=>{g.keyCode===C.KeyCode.ENTER&&x()}})})]}),f.jsxs("div",{className:w.docsLinkEditButtons,children:[f.jsx(L.Button,{className:w.docsLinkEditButton,onClick:m,children:e.t("docLink.edit.cancel")}),f.jsx(L.Button,{disabled:!c,className:w.docsLinkEditButton,type:"primary",onClick:x,children:e.t("docLink.edit.confirm")})]})]})};N.componentKey="docs-hyper-link-edit";var S=function(){return S=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},S.apply(this,arguments)},we=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=we(n,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),a=_.useRef("_".concat(Be()));return oe(t,"".concat(i),{defIds:t.defIds,idSuffix:a.current},S({ref:e,className:d},c),s)});function oe(n,e,t,i,r){return _.createElement(n.tag,S(S({key:e},Ne(n,t,r)),i),(He(n,t).children||[]).map(function(s,c){return oe(s,"".concat(e,"-").concat(n.tag,"-").concat(c),t,void 0,r)}))}function Ne(n,e,t){var i=S({},n.attrs);t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1);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 He(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)?S(S({},n),{children:n.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+e.idSuffix})}):r})}):n}function Be(){return Math.random().toString(36).substring(2,8)}M.displayName="UniverIcon";var Ae={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"}}]},se=_.forwardRef(function(n,e){return _.createElement(M,Object.assign({},n,{id:"copy-single",ref:e,icon:Ae}))});se.displayName="CopySingle";var Ke={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:Ke}))});Z.displayName="LinkSingle";var Fe={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"}}]},ce=_.forwardRef(function(n,e){return _.createElement(M,Object.assign({},n,{id:"unlink-single",ref:e,icon:Fe}))});ce.displayName="UnlinkSingle";var $e={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"}}]},de=_.forwardRef(function(n,e){return _.createElement(M,Object.assign({},n,{id:"write-single",ref:e,icon:$e}))});de.displayName="WriteSingle";function ae(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=ae(n[e]))&&(i&&(i+=" "),i+=t)}else for(t in n)n[t]&&(i&&(i+=" "),i+=t);return i}function le(){for(var n,e,t=0,i="",r=arguments.length;t<r;t++)(n=arguments[t])&&(e=ae(n))&&(i&&(i+=" "),i+=e);return i}const ue={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=y.deleteCustomRangeFactory(n,{unitId:t,rangeId:i,segmentId:r});return c?await s.syncExecuteCommand(c.id,c.params):!1}},pe=n=>{const e=n.get(y.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)},U={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(pe(n)&&!t)return!1;const r=n.get(k),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}},W={type:o.CommandType.OPERATION,id:"doc.operation.toggle-hyper-link-info-popup",handler(n,e){const t=n.get(k);return e?(t.showInfoPopup(e),!0):(t.hideInfoPopup(),!0)}},fe={type:o.CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(n,e){var v,u,I;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(),a=(I=(u=(v=d==null?void 0:d.customRanges)==null?void 0:v.find(h=>h.rangeId===i&&h.rangeType===o.CustomRangeType.HYPERLINK))==null?void 0:u.properties)==null?void 0:I.url;return a&&window.open(a,"_blank","noopener noreferrer"),!0}},P={docLink:"univer-doc-link",docLinkType:"univer-doc-link-type",docLinkContent:"univer-doc-link-content",docLinkContentError:"univer-doc-link-content-error",docLinkUrl:"univer-doc-link-url",docLinkOperations:"univer-doc-link-operations",docLinkOperation:"univer-doc-link-operation",docLinkOperationError:"univer-doc-link-operation-error"},H=()=>{var x,g;const n=o.useDependency(k),e=o.useDependency(o.ICommandService),t=o.useDependency(C.IMessageService),i=o.useDependency(o.LocaleService),r=C.useObservable(n.showingLink$),s=o.useDependency(o.IUniverInstanceService);if(!r)return null;const{unitId:c,linkId:d,segmentId:a,startIndex:v,endIndex:u}=r,I=s.getUnit(c,o.UniverInstanceType.UNIVER_DOC),h=I==null?void 0:I.getSelfOrHeaderFooterModel(a).getBody(),l=(x=h==null?void 0:h.customRanges)==null?void 0:x.find(O=>O.rangeId===d&&O.rangeType===o.CustomRangeType.HYPERLINK&&O.startIndex===v&&O.endIndex===u);if(!l)return null;const m=(g=l.properties)==null?void 0:g.url;return f.jsxs("div",{className:P.docLink,onClick:()=>{n.hideInfoPopup()},children:[f.jsxs("div",{className:le(P.docLinkContent),onClick:()=>window.open(m),children:[f.jsx("div",{className:P.docLinkType,children:f.jsx(Z,{})}),f.jsx(L.Tooltip,{showIfEllipsis:!0,title:m,children:f.jsx("span",{className:P.docLinkUrl,children:m})})]}),f.jsxs("div",{className:P.docLinkOperations,children:[f.jsx("div",{className:le(P.docLinkOperation),onClick:()=>{navigator.clipboard.writeText(m),t.show({content:i.t("docLink.info.coped"),type:L.MessageType.Info})},children:f.jsx(L.Tooltip,{placement:"bottom",title:i.t("docLink.info.copy"),children:f.jsx(se,{})})}),f.jsx("div",{className:P.docLinkOperation,onClick:()=>{e.executeCommand(U.id,{link:r})},children:f.jsx(L.Tooltip,{placement:"bottom",title:i.t("docLink.info.edit"),children:f.jsx(de,{})})}),f.jsx("div",{className:P.docLinkOperation,onClick:()=>{e.executeCommand(ue.id,{unitId:c,linkId:l.rangeId,segmentId:a})},children:f.jsx(L.Tooltip,{placement:"bottom",title:i.t("docLink.info.cancel"),children:f.jsx(ce,{})})})]})]})};H.componentKey="univer.doc.link-info-popup";var Ve=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,Ze=(n,e,t,i)=>{for(var r=i>1?void 0:i?Ye(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&Ve(e,t,r),r},G=(n,e)=>(t,i)=>e(t,i,n);let k=class extends o.Disposable{constructor(e,t,i){super();R(this,"_editingLink$",new D.BehaviorSubject(null));R(this,"_showingLink$",new D.BehaviorSubject(null));R(this,"editingLink$",this._editingLink$.asObservable());R(this,"showingLink$",this._showingLink$.asObservable());R(this,"_editPopup",null);R(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:a}=t;r={collapsed:!1,startOffset:d,endOffset:a+1,segmentId:s,segmentPage:c},this._textSelectionManagerService.replaceDocRanges([{startOffset:d,endOffset:a+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 v,u,I,h,l,m;const{linkId:t,unitId:i,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}=e;if(!(((v=this.showing)==null?void 0:v.linkId)===t&&((u=this.showing)==null?void 0:u.unitId)===i&&((I=this.showing)==null?void 0:I.segmentId)===r&&((h=this.showing)==null?void 0:h.segmentPage)===s&&((l=this.showing)==null?void 0:l.startIndex)===c&&((m=this.showing)==null?void 0:m.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()}};k=Ze([G(0,o.Inject(b.DocCanvasPopManagerService)),G(1,o.Inject(y.DocSelectionManagerService)),G(2,o.IUniverInstanceService)],k);var We=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,Je=(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=(i?c(e,t,r):c(r))||r);return i&&r&&We(e,t,r),r},J=(n,e)=>(t,i)=>e(t,i,n);let B=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===y.SetTextSelectionsOperation.id){const r=n.params,{unitId:s,ranges:c,segmentId:d}=r,a=this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_DOC),v=c[0];if(v&&a){const{startOffset:u,endOffset:I,collapsed:h,segmentPage:l}=v,m=(t=(e=a.getSelfOrHeaderFooterModel(d))==null?void 0:e.getBody())==null?void 0:t.customRanges;if(h){const x=(i=m==null?void 0:m.findIndex(g=>g.startIndex<u&&g.endIndex>I-1))!=null?i:-1;if(x>-1){const g=m[x];this._docHyperLinkService.showInfoPopup({unitId:s,linkId:g.rangeId,segmentId:d,segmentPage:l,startIndex:g.startIndex,endIndex:g.endIndex});return}}else if(m==null?void 0:m.find(g=>g.startIndex<=u&&g.endIndex>=I-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};B=Je([J(0,o.ICommandService),J(1,o.IUniverInstanceService),J(2,o.Inject(k))],B);var ze=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,Xe=(n,e,t,i)=>{for(var r=i>1?void 0:i?Qe(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&ze(e,t,r),r},T=(n,e)=>(t,i)=>e(t,i,n);let z=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(W.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(W.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(fe.id,{unitId:this._context.unitId,linkId:e.rangeId,segmentId:n.segmentId})}))}};z=Xe([T(1,o.Inject(b.DocEventManagerService)),T(2,o.ICommandService),T(3,o.Inject(k)),T(4,o.Inject(y.DocSkeletonManagerService)),T(5,o.Inject(y.DocSelectionManagerService))],z);var qe=Object.defineProperty,en=Object.getOwnPropertyDescriptor,nn=(n,e,t,i)=>{for(var r=i>1?void 0:i?en(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&qe(e,t,r),r},Q=(n,e)=>(t,i)=>e(t,i,n);let X=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(y.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:a,endIndex:v}=s,u=d===i&&n.rangeId===c&&r>=a&&r<=v;return t({...n,active:u})}})}_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)}))}};X=nn([Q(1,o.Inject(y.DocInterceptorService)),Q(2,o.Inject(k)),Q(3,o.Inject(b.DocRenderController))],X);const ve="doc-hyper-link-icon";function he(n){return{id:U.id,type:C.MenuItemType.BUTTON,icon:ve,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:C.getMenuHiddenObservable(n,o.UniverInstanceType.UNIVER_DOC),disabled$:new D.Observable(function(e){const i=n.get(y.DocSelectionManagerService).textSelection$.pipe(D.debounceTime(16)).subscribe(()=>{e.next(pe(n))});return()=>{i.unsubscribe()}})}}const tn={id:U.id,binding:C.MetaKeys.CTRL_COMMAND|C.KeyCode.K,description:"docLink.menu.tooltip",preconditions:b.whenDocAndEditorFocused},rn={[C.RibbonStartGroup.OTHERS]:{[U.id]:{order:0,menuItemFactory:he}},[C.ContextMenuPosition.MAIN_AREA]:{[C.ContextMenuGroup.DATA]:{[U.id]:{order:0,menuItemFactory:he}}}};var on=Object.defineProperty,sn=Object.getOwnPropertyDescriptor,cn=(n,e,t,i)=>{for(var r=i>1?void 0:i?sn(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&on(e,t,r),r},A=(n,e)=>(t,i)=>e(t,i,n);let K=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,ve]].forEach(([n,e])=>{this._componentManager.register(e,n)})}_initCommands(){[ie,re,ue,U,W,fe].forEach(n=>{this._commandService.registerCommand(n)})}_initShortcut(){[tn].forEach(n=>{this._shortcutService.registerShortcut(n)})}_initMenus(){this._menuManagerService.mergeMenu(rn)}};K=cn([A(0,o.Inject(C.ComponentManager)),A(1,o.ICommandService),A(2,C.IMenuManagerService),A(3,C.IShortcutService)],K);const dn="DOC_HYPER_LINK_UI_PLUGIN";var ge=Object.defineProperty,an=Object.getOwnPropertyDescriptor,ln=(n,e,t)=>e in n?ge(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,un=(n,e,t,i)=>{for(var r=i>1?void 0:i?an(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&ge(e,t,r),r},q=(n,e)=>(t,i)=>e(t,i,n),Ie=(n,e,t)=>ln(n,typeof e!="symbol"?e+"":e,t);p.UniverDocsHyperLinkUIPlugin=class extends o.Plugin{constructor(e=De,t,i,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=i,this._configService=r;const{menu:s,...c}=this._config;s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Ee,c)}onStarting(){[[k],[K],[B]].forEach(t=>{this._injector.add(t)}),this._injector.get(K)}onReady(){this._injector.get(B)}onRendered(){this._initRenderModule()}_initRenderModule(){[[X],[z]].forEach(e=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,e)})}},Ie(p.UniverDocsHyperLinkUIPlugin,"pluginName",dn),Ie(p.UniverDocsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC),p.UniverDocsHyperLinkUIPlugin=un([o.DependentOn(E.UniverDocsHyperLinkPlugin),q(1,o.Inject(o.Injector)),q(2,Re.IRenderManagerService),q(3,o.IConfigService)],p.UniverDocsHyperLinkUIPlugin),Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
9
+ */var te;function Ue(){if(te)return j;te=1;var n=_,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function c(d,a,v){var u,I={},g=null,l=null;v!==void 0&&(g=""+v),a.key!==void 0&&(g=""+a.key),a.ref!==void 0&&(l=a.ref);for(u in a)i.call(a,u)&&!s.hasOwnProperty(u)&&(I[u]=a[u]);if(d&&d.defaultProps)for(u in a=d.defaultProps,a)I[u]===void 0&&(I[u]=a[u]);return{$$typeof:e,type:d,key:g,ref:l,props:I,_owner:r.current}}return j.Fragment=t,j.jsx=c,j.jsxs=c,j}var ie;function je(){return ie||(ie=1,Y.exports=Ue()),Y.exports}var f=je();const re={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=y.addCustomRangeBySelectionFactory(n,{rangeId:c,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:t},unitId:i,selections:r});return d?s.syncExecuteCommand(d.id,d.params):!1}},oe={id:"docs.command.update-hyper-link",type:o.CommandType.COMMAND,handler(n,e){var m;if(!e)return!1;const{unitId:t,payload:i,segmentId:r,linkId:s}=e,c=n.get(o.ICommandService),d=n.get(o.IUniverInstanceService),v=n.get(y.DocSelectionManagerService).getActiveTextRange(),u=d.getUnit(t,o.UniverInstanceType.UNIVER_DOC);if(!v||!u)return!1;const g=(m=o.getBodySlice(u.getSelfOrHeaderFooterModel(r).getBody(),v.startOffset,v.endOffset).textRuns)==null?void 0:m[0];g&&(g.ed=e.label.length+1);const l=y.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:g?[g]:void 0},selection:{startOffset:v.startOffset,endOffset:v.endOffset,collapsed:!1,segmentId:r}});return l?c.syncExecuteCommand(l.id,l.params):!1}},w={docsLinkEdit:"univer-docs-link-edit",docsLinkEditTitle:"univer-docs-link-edit-title",docsLinkEditClose:"univer-docs-link-edit-close",docsLinkEditButtons:"univer-docs-link-edit-buttons",docsLinkEditButton:"univer-docs-link-edit-button"};function Me(n){return/^[a-zA-Z]+:\/\//.test(n)}function Te(n){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(n)}function be(n){return Me(n)?n:Te(n)?`mailto://${n}`:`https://${n}`}const N=()=>{const n=o.useDependency(k),e=o.useDependency(o.LocaleService),t=o.useObservable(n.editingLink$),i=o.useDependency(o.ICommandService),r=o.useDependency(o.IUniverInstanceService),s=o.useDependency(y.DocSelectionManagerService),[c,d]=_.useState(""),[a,v]=_.useState(""),[u,I]=_.useState(!1),g=o.Tools.isLegalUrl(c),l=t?r.getUnit(t.unitId,o.UniverInstanceType.UNIVER_DOC):r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);_.useEffect(()=>{var Ce,ye,Se,Le,ke,xe,Oe,Pe,Re;const h=s.getActiveTextRange();if(!h)return;if(t){const $=(Ce=l==null?void 0:l.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:Ce.getBody(),V=(ye=$==null?void 0:$.customRanges)==null?void 0:ye.find(ee=>(t==null?void 0:t.linkId)===ee.rangeId&&ee.startIndex===t.startIndex&&ee.endIndex===t.endIndex);l&&V&&(d((Le=(Se=V.properties)==null?void 0:Se.url)!=null?Le:""),v(o.BuildTextUtils.transform.getPlainText(o.getBodySlice($,V.startIndex,V.endIndex+1).dataStream)));return}const O=(ke=l==null?void 0:l.getSelfOrHeaderFooterModel(h.segmentId))==null?void 0:ke.getBody(),_e=O?h:null,F=_e&&((Oe=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(_e,(xe=O==null?void 0:O.customRanges)!=null?xe:[]))==null?void 0:Oe[0]);l&&F&&d((Re=(Pe=F==null?void 0:F.properties)==null?void 0:Pe.url)!=null?Re:"")},[l,t,s,r]);const m=()=>{n.hideEditPopup()},x=()=>{if(I(!0),!g||!l)return;const h=be(c);if(!t)i.executeCommand(re.id,{unitId:l.getUnitId(),payload:h});else{if(!a)return;i.executeCommand(oe.id,{unitId:l.getUnitId(),payload:h,linkId:t.linkId,label:a,segmentId:t.segmentId})}n.hideEditPopup()};if(l)return f.jsxs("div",{className:w.docsLinkEdit,children:[f.jsxs("div",{children:[t?f.jsx(L.FormLayout,{label:e.t("docLink.edit.label"),error:u&&!a?e.t("docLink.edit.labelError"):"",children:f.jsx(L.Input,{value:a,onChange:v,autoFocus:!0,onKeyDown:h=>{h.keyCode===C.KeyCode.ENTER&&x()}})}):null,f.jsx(L.FormLayout,{label:e.t("docLink.edit.address"),error:u&&!g?e.t("docLink.edit.addressError"):"",children:f.jsx(L.Input,{value:c,onChange:d,autoFocus:!0,onKeyDown:h=>{h.keyCode===C.KeyCode.ENTER&&x()}})})]}),f.jsxs("div",{className:w.docsLinkEditButtons,children:[f.jsx(L.Button,{className:w.docsLinkEditButton,onClick:m,children:e.t("docLink.edit.cancel")}),f.jsx(L.Button,{disabled:!c,className:w.docsLinkEditButton,type:"primary",onClick:x,children:e.t("docLink.edit.confirm")})]})]})};N.componentKey="docs-hyper-link-edit";var S=function(){return S=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},S.apply(this,arguments)},we=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=we(n,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),a=_.useRef("_".concat(Be()));return se(t,"".concat(i),{defIds:t.defIds,idSuffix:a.current},S({ref:e,className:d},c),s)});function se(n,e,t,i,r){return _.createElement(n.tag,S(S({key:e},Ne(n,t,r)),i),(He(n,t).children||[]).map(function(s,c){return se(s,"".concat(e,"-").concat(n.tag,"-").concat(c),t,void 0,r)}))}function Ne(n,e,t){var i=S({},n.attrs);t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1);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 He(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)?S(S({},n),{children:n.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+e.idSuffix})}):r})}):n}function Be(){return Math.random().toString(36).substring(2,8)}M.displayName="UniverIcon";var Ae={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"}}]},ce=_.forwardRef(function(n,e){return _.createElement(M,Object.assign({},n,{id:"copy-single",ref:e,icon:Ae}))});ce.displayName="CopySingle";var Ke={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:Ke}))});Z.displayName="LinkSingle";var Fe={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"}}]},de=_.forwardRef(function(n,e){return _.createElement(M,Object.assign({},n,{id:"unlink-single",ref:e,icon:Fe}))});de.displayName="UnlinkSingle";var $e={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"}}]},ae=_.forwardRef(function(n,e){return _.createElement(M,Object.assign({},n,{id:"write-single",ref:e,icon:$e}))});ae.displayName="WriteSingle";function le(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=le(n[e]))&&(i&&(i+=" "),i+=t)}else for(t in n)n[t]&&(i&&(i+=" "),i+=t);return i}function ue(){for(var n,e,t=0,i="",r=arguments.length;t<r;t++)(n=arguments[t])&&(e=le(n))&&(i&&(i+=" "),i+=e);return i}const pe={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=y.deleteCustomRangeFactory(n,{unitId:t,rangeId:i,segmentId:r});return c?await s.syncExecuteCommand(c.id,c.params):!1}},fe=n=>{const e=n.get(y.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)},U={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(fe(n)&&!t)return!1;const r=n.get(k),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}},W={type:o.CommandType.OPERATION,id:"doc.operation.toggle-hyper-link-info-popup",handler(n,e){const t=n.get(k);return e?(t.showInfoPopup(e),!0):(t.hideInfoPopup(),!0)}},ve={type:o.CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(n,e){var v,u,I;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(),a=(I=(u=(v=d==null?void 0:d.customRanges)==null?void 0:v.find(g=>g.rangeId===i&&g.rangeType===o.CustomRangeType.HYPERLINK))==null?void 0:u.properties)==null?void 0:I.url;return a&&window.open(a,"_blank","noopener noreferrer"),!0}},P={docLink:"univer-doc-link",docLinkType:"univer-doc-link-type",docLinkContent:"univer-doc-link-content",docLinkContentError:"univer-doc-link-content-error",docLinkUrl:"univer-doc-link-url",docLinkOperations:"univer-doc-link-operations",docLinkOperation:"univer-doc-link-operation",docLinkOperationError:"univer-doc-link-operation-error"},H=()=>{var x,h;const n=o.useDependency(k),e=o.useDependency(o.ICommandService),t=o.useDependency(C.IMessageService),i=o.useDependency(o.LocaleService),r=C.useObservable(n.showingLink$),s=o.useDependency(o.IUniverInstanceService);if(!r)return null;const{unitId:c,linkId:d,segmentId:a,startIndex:v,endIndex:u}=r,I=s.getUnit(c,o.UniverInstanceType.UNIVER_DOC),g=I==null?void 0:I.getSelfOrHeaderFooterModel(a).getBody(),l=(x=g==null?void 0:g.customRanges)==null?void 0:x.find(O=>O.rangeId===d&&O.rangeType===o.CustomRangeType.HYPERLINK&&O.startIndex===v&&O.endIndex===u);if(!l)return null;const m=(h=l.properties)==null?void 0:h.url;return f.jsxs("div",{className:P.docLink,onClick:()=>{n.hideInfoPopup()},children:[f.jsxs("div",{className:ue(P.docLinkContent),onClick:()=>window.open(m),children:[f.jsx("div",{className:P.docLinkType,children:f.jsx(Z,{})}),f.jsx(L.Tooltip,{showIfEllipsis:!0,title:m,children:f.jsx("span",{className:P.docLinkUrl,children:m})})]}),f.jsxs("div",{className:P.docLinkOperations,children:[f.jsx("div",{className:ue(P.docLinkOperation),onClick:()=>{navigator.clipboard.writeText(m),t.show({content:i.t("docLink.info.coped"),type:L.MessageType.Info})},children:f.jsx(L.Tooltip,{placement:"bottom",title:i.t("docLink.info.copy"),children:f.jsx(ce,{})})}),f.jsx("div",{className:P.docLinkOperation,onClick:()=>{e.executeCommand(U.id,{link:r})},children:f.jsx(L.Tooltip,{placement:"bottom",title:i.t("docLink.info.edit"),children:f.jsx(ae,{})})}),f.jsx("div",{className:P.docLinkOperation,onClick:()=>{e.executeCommand(pe.id,{unitId:c,linkId:l.rangeId,segmentId:a})},children:f.jsx(L.Tooltip,{placement:"bottom",title:i.t("docLink.info.cancel"),children:f.jsx(de,{})})})]})]})};H.componentKey="univer.doc.link-info-popup";var Ve=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,Ze=(n,e,t,i)=>{for(var r=i>1?void 0:i?Ye(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&Ve(e,t,r),r},G=(n,e)=>(t,i)=>e(t,i,n);let k=class extends o.Disposable{constructor(e,t,i){super();R(this,"_editingLink$",new D.BehaviorSubject(null));R(this,"_showingLink$",new D.BehaviorSubject(null));R(this,"editingLink$",this._editingLink$.asObservable());R(this,"showingLink$",this._showingLink$.asObservable());R(this,"_editPopup",null);R(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:a}=t;r={collapsed:!1,startOffset:d,endOffset:a+1,segmentId:s,segmentPage:c},this._textSelectionManagerService.replaceDocRanges([{startOffset:d,endOffset:a+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 v,u,I,g,l,m;const{linkId:t,unitId:i,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}=e;if(!(((v=this.showing)==null?void 0:v.linkId)===t&&((u=this.showing)==null?void 0:u.unitId)===i&&((I=this.showing)==null?void 0:I.segmentId)===r&&((g=this.showing)==null?void 0:g.segmentPage)===s&&((l=this.showing)==null?void 0:l.startIndex)===c&&((m=this.showing)==null?void 0:m.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()}};k=Ze([G(0,o.Inject(b.DocCanvasPopManagerService)),G(1,o.Inject(y.DocSelectionManagerService)),G(2,o.IUniverInstanceService)],k);var We=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,Je=(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=(i?c(e,t,r):c(r))||r);return i&&r&&We(e,t,r),r},J=(n,e)=>(t,i)=>e(t,i,n);let B=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===y.SetTextSelectionsOperation.id){const r=n.params,{unitId:s,ranges:c,segmentId:d}=r,a=this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_DOC),v=c[0];if(v&&a){const{startOffset:u,endOffset:I,collapsed:g,segmentPage:l}=v,m=(t=(e=a.getSelfOrHeaderFooterModel(d))==null?void 0:e.getBody())==null?void 0:t.customRanges;if(g){const x=(i=m==null?void 0:m.findIndex(h=>h.startIndex<u&&h.endIndex>I-1))!=null?i:-1;if(x>-1){const h=m[x];this._docHyperLinkService.showInfoPopup({unitId:s,linkId:h.rangeId,segmentId:d,segmentPage:l,startIndex:h.startIndex,endIndex:h.endIndex});return}}else if(m==null?void 0:m.find(h=>h.startIndex<=u&&h.endIndex>=I-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};B=Je([J(0,o.ICommandService),J(1,o.IUniverInstanceService),J(2,o.Inject(k))],B);var ze=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,Xe=(n,e,t,i)=>{for(var r=i>1?void 0:i?Qe(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&ze(e,t,r),r},T=(n,e)=>(t,i)=>e(t,i,n);let z=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(W.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(W.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(ve.id,{unitId:this._context.unitId,linkId:e.rangeId,segmentId:n.segmentId})}))}};z=Xe([T(1,o.Inject(b.DocEventManagerService)),T(2,o.ICommandService),T(3,o.Inject(k)),T(4,o.Inject(y.DocSkeletonManagerService)),T(5,o.Inject(y.DocSelectionManagerService))],z);var qe=Object.defineProperty,en=Object.getOwnPropertyDescriptor,nn=(n,e,t,i)=>{for(var r=i>1?void 0:i?en(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&qe(e,t,r),r},Q=(n,e)=>(t,i)=>e(t,i,n);let X=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(y.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:a,endIndex:v}=s,u=d===i&&n.rangeId===c&&r>=a&&r<=v;return t({...n,active:u})}})}_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)}))}};X=nn([Q(1,o.Inject(y.DocInterceptorService)),Q(2,o.Inject(k)),Q(3,o.Inject(b.DocRenderController))],X);const ge="doc-hyper-link-icon";function he(n){return{id:U.id,type:C.MenuItemType.BUTTON,icon:ge,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:C.getMenuHiddenObservable(n,o.UniverInstanceType.UNIVER_DOC),disabled$:new D.Observable(function(e){const i=n.get(y.DocSelectionManagerService).textSelection$.pipe(D.debounceTime(16)).subscribe(()=>{e.next(fe(n))});return()=>{i.unsubscribe()}})}}const tn={id:U.id,binding:C.MetaKeys.CTRL_COMMAND|C.KeyCode.K,description:"docLink.menu.tooltip",preconditions:b.whenDocAndEditorFocused},rn={[C.RibbonStartGroup.OTHERS]:{[U.id]:{order:0,menuItemFactory:he}},[C.ContextMenuPosition.MAIN_AREA]:{[C.ContextMenuGroup.DATA]:{[U.id]:{order:0,menuItemFactory:he}}}};var on=Object.defineProperty,sn=Object.getOwnPropertyDescriptor,cn=(n,e,t,i)=>{for(var r=i>1?void 0:i?sn(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&on(e,t,r),r},A=(n,e)=>(t,i)=>e(t,i,n);let K=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,ge]].forEach(([n,e])=>{this._componentManager.register(e,n)})}_initCommands(){[re,oe,pe,U,W,ve].forEach(n=>{this._commandService.registerCommand(n)})}_initShortcut(){[tn].forEach(n=>{this._shortcutService.registerShortcut(n)})}_initMenus(){this._menuManagerService.mergeMenu(rn)}};K=cn([A(0,o.Inject(C.ComponentManager)),A(1,o.ICommandService),A(2,C.IMenuManagerService),A(3,C.IShortcutService)],K);const dn="DOC_HYPER_LINK_UI_PLUGIN";var Ie=Object.defineProperty,an=Object.getOwnPropertyDescriptor,ln=(n,e,t)=>e in n?Ie(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,un=(n,e,t,i)=>{for(var r=i>1?void 0:i?an(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&Ie(e,t,r),r},q=(n,e)=>(t,i)=>e(t,i,n),me=(n,e,t)=>ln(n,typeof e!="symbol"?e+"":e,t);p.UniverDocsHyperLinkUIPlugin=class extends o.Plugin{constructor(e=ne,t,i,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=i,this._configService=r;const{menu:s,...c}=o.Tools.deepMerge(ne,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(De,c)}onStarting(){[[k],[K],[B]].forEach(t=>{this._injector.add(t)}),this._injector.get(K)}onReady(){this._injector.get(B)}onRendered(){this._initRenderModule()}_initRenderModule(){[[X],[z]].forEach(e=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,e)})}},me(p.UniverDocsHyperLinkUIPlugin,"pluginName",dn),me(p.UniverDocsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC),p.UniverDocsHyperLinkUIPlugin=un([o.DependentOn(E.UniverDocsHyperLinkPlugin),q(1,o.Inject(o.Injector)),q(2,Ee.IRenderManagerService),q(3,o.IConfigService)],p.UniverDocsHyperLinkUIPlugin),Object.defineProperty(p,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.5.1-nightly.202412241606",
3
+ "version": "0.5.1-nightly.202412261606",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -54,13 +54,13 @@
54
54
  "dependencies": {
55
55
  "@univerjs/icons": "^0.2.8",
56
56
  "clsx": "^2.1.1",
57
- "@univerjs/core": "0.5.1-nightly.202412241606",
58
- "@univerjs/design": "0.5.1-nightly.202412241606",
59
- "@univerjs/docs": "0.5.1-nightly.202412241606",
60
- "@univerjs/docs-ui": "0.5.1-nightly.202412241606",
61
- "@univerjs/ui": "0.5.1-nightly.202412241606",
62
- "@univerjs/docs-hyper-link": "0.5.1-nightly.202412241606",
63
- "@univerjs/engine-render": "0.5.1-nightly.202412241606"
57
+ "@univerjs/design": "0.5.1-nightly.202412261606",
58
+ "@univerjs/docs": "0.5.1-nightly.202412261606",
59
+ "@univerjs/docs-hyper-link": "0.5.1-nightly.202412261606",
60
+ "@univerjs/docs-ui": "0.5.1-nightly.202412261606",
61
+ "@univerjs/core": "0.5.1-nightly.202412261606",
62
+ "@univerjs/ui": "0.5.1-nightly.202412261606",
63
+ "@univerjs/engine-render": "0.5.1-nightly.202412261606"
64
64
  },
65
65
  "devDependencies": {
66
66
  "postcss": "^8.4.49",