@univerjs/docs-hyper-link-ui 0.5.3 → 0.5.4-experimental.20250114-7c09c35

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
@@ -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 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.merge({},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);
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,f){var u,v={},g=null,l=null;f!==void 0&&(g=""+f),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)&&(v[u]=a[u]);if(d&&d.defaultProps)for(u in a=d.defaultProps,a)v[u]===void 0&&(v[u]=a[u]);return{$$typeof:e,type:d,key:g,ref:l,props:v,_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 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}},he={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),f=n.get(C.DocSelectionManagerService).getActiveTextRange(),u=d.getUnit(t,o.UniverInstanceType.UNIVER_DOC);if(!f||!u)return!1;const g=(I=o.getBodySlice(u.getSelfOrHeaderFooterModel(r).getBody(),f.startOffset,f.endOffset).textRuns)==null?void 0:I[0];g&&(g.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:g?[g]:void 0},selection:{startOffset:f.startOffset,endOffset:f.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,f]=m.useState(""),[u,v]=m.useState(!1),g=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 h=s.getActiveTextRange();if(!h)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:""),f(o.BuildTextUtils.transform.getPlainText(o.getBodySlice(w,T.startIndex,T.endIndex+1).dataStream)));return}const x=(re=l==null?void 0:l.getSelfOrHeaderFooterModel(h.segmentId))==null?void 0:re.getBody(),X=x?h: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(v(!0),!g||!l)return;const h=Ae(c);if(!t)i.executeCommand(ge.id,{unitId:l.getUnitId(),payload:h});else{if(!a)return;i.executeCommand(he.id,{unitId:l.getUnitId(),payload:h,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:f,autoFocus:!0,onKeyDown:h=>{h.keyCode===_.KeyCode.ENTER&&L()}})}):null,p.jsx(S.FormLayout,{label:e.t("docLink.edit.address"),error:u&&!g?e.t("docLink.edit.addressError"):"",children:p.jsx(S.Input,{value:c,onChange:d,autoFocus:!0,onKeyDown:h=>{h.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"}}]},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 f,u,v;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=(v=(u=(f=d==null?void 0:d.customRanges)==null?void 0:f.find(g=>g.rangeId===i&&g.rangeType===o.CustomRangeType.HYPERLINK))==null?void 0:u.properties)==null?void 0:v.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,h;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:f,endIndex:u}=r,v=s.getUnit(c,o.UniverInstanceType.UNIVER_DOC),g=v==null?void 0:v.getSelfOrHeaderFooterModel(a).getBody(),l=(L=g==null?void 0:g.customRanges)==null?void 0:L.find(x=>x.rangeId===d&&x.rangeType===o.CustomRangeType.HYPERLINK&&x.startIndex===f&&x.endIndex===u);if(!l)return null;const I=(h=l.properties)==null?void 0:h.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 f,u,v,g,l,I;const{linkId:t,unitId:i,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}=e;if(!(((f=this.showing)==null?void 0:f.linkId)===t&&((u=this.showing)==null?void 0:u.unitId)===i&&((v=this.showing)==null?void 0:v.segmentId)===r&&((g=this.showing)==null?void 0:g.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),f=c[0];if(f&&a){const{startOffset:u,endOffset:v,collapsed:g,segmentPage:l}=f,I=(t=(e=a.getSelfOrHeaderFooterModel(d))==null?void 0:e.getBody())==null?void 0:t.customRanges;if(g){const L=(i=I==null?void 0:I.findIndex(h=>h.startIndex<u&&h.endIndex>v-1))!=null?i:-1;if(L>-1){const h=I[L];this._docHyperLinkService.showInfoPopup({unitId:s,linkId:h.rangeId,segmentId:d,segmentPage:l,startIndex:h.startIndex,endIndex:h.endIndex});return}}else if(I==null?void 0:I.find(h=>h.startIndex<=u&&h.endIndex>=v-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,fn=(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=fn([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 gn=Object.defineProperty,hn=Object.getOwnPropertyDescriptor,vn=(n,e,t,i)=>{for(var r=i>1?void 0:i?hn(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&&gn(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:f}=s,u=d===i&&n.rangeId===c&&r>=a&&r<=f;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=vn([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 fe(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:fe}},[_.ContextMenuPosition.MAIN_AREA]:{[_.ContextMenuGroup.DATA]:{[E.id]:{order:0,menuItemFactory:fe}}}};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(){[ge,he,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.merge({},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,13 +1,13 @@
1
1
  var Ke = Object.defineProperty;
2
2
  var Fe = (n, e, t) => e in n ? Ke(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
3
  var P = (n, e, t) => Fe(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { CommandType as E, ICommandService as x, generateRandomId as Ve, CustomRangeType as D, IUniverInstanceService as O, UniverInstanceType as I, getBodySlice as Pe, useDependency as S, LocaleService as Re, useObservable as Ye, Tools as Ze, 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, merge as Qe, IConfigService as Xe } from "@univerjs/core";
4
+ import { CommandType as E, ICommandService as x, generateRandomId as Ve, CustomRangeType as D, IUniverInstanceService as O, UniverInstanceType as I, getBodySlice as Pe, useDependency as S, LocaleService as Re, useObservable as Ye, Tools as Ze, BuildTextUtils as _e, Disposable as N, Inject as v, 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, merge as Qe, IConfigService as Xe } from "@univerjs/core";
5
5
  import { UniverDocsHyperLinkPlugin as en } from "@univerjs/docs-hyper-link";
6
6
  import { IRenderManagerService as nn } from "@univerjs/engine-render";
7
7
  import { addCustomRangeBySelectionFactory as tn, DocSelectionManagerService as b, replaceSelectionFactory as rn, deleteCustomRangeFactory as on, SetTextSelectionsOperation as sn, DocSkeletonManagerService as cn, DocInterceptorService as dn, DOC_INTERCEPTOR_POINT as an } from "@univerjs/docs";
8
8
  import { DocCanvasPopManagerService as ln, DocEventManagerService as un, DocRenderController as pn, whenDocAndEditorFocused as fn } from "@univerjs/docs-ui";
9
- import { BehaviorSubject as _e, distinctUntilChanged as gn, pairwise as hn, Observable as vn, debounceTime as mn } from "rxjs";
10
- import _n, { useState as J, useEffect as In, forwardRef as j, useRef as Cn, createElement as U } from "react";
9
+ import { BehaviorSubject as ve, distinctUntilChanged as gn, pairwise as hn, Observable as mn, debounceTime as _n } from "rxjs";
10
+ import vn, { useState as J, useEffect as In, forwardRef as j, useRef as Cn, createElement as U } from "react";
11
11
  import { FormLayout as Ie, Input as Ce, Button as Se, Tooltip as B, MessageType as Sn } from "@univerjs/design";
12
12
  import { KeyCode as te, IMessageService as Ln, useObservable as yn, MetaKeys as kn, MenuItemType as xn, getMenuHiddenObservable as On, RibbonStartGroup as Pn, ContextMenuPosition as Rn, ContextMenuGroup as En, ComponentManager as bn, IMenuManagerService as Mn, IShortcutService as wn } from "@univerjs/ui";
13
13
  const Dn = "docs-hyper-link-ui.config", Le = {};
@@ -25,7 +25,7 @@ var ye;
25
25
  function Nn() {
26
26
  if (ye) return M;
27
27
  ye = 1;
28
- var n = _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, o = { key: !0, ref: !0, __self: !0, __source: !0 };
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 };
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);
@@ -64,13 +64,13 @@ const Ee = {
64
64
  id: "docs.command.update-hyper-link",
65
65
  type: E.COMMAND,
66
66
  handler(n, e) {
67
- var v;
67
+ var m;
68
68
  if (!e)
69
69
  return !1;
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 = Pe(l.getSelfOrHeaderFooterModel(r).getBody(), p.startOffset, p.endOffset).textRuns) == null ? void 0 : v[0];
73
+ const f = (m = Pe(l.getSelfOrHeaderFooterModel(r).getBody(), p.startOffset, p.endOffset).textRuns) == null ? void 0 : m[0];
74
74
  f && (f.ed = e.label.length + 1);
75
75
  const a = rn(n, {
76
76
  unitId: t,
@@ -115,19 +115,19 @@ function Fn(n) {
115
115
  const V = () => {
116
116
  const n = S(L), e = S(Re), t = Ye(n.editingLink$), i = S(x), r = S(O), o = S(b), [s, c] = J(""), [d, p] = J(""), [l, h] = J(!1), f = Ze.isLegalUrl(s), a = t ? r.getUnit(t.unitId, I.UNIVER_DOC) : r.getCurrentUnitForType(I.UNIVER_DOC);
117
117
  In(() => {
118
- var de, ae, le, ue, pe, fe, ge, he, ve;
118
+ var de, ae, le, ue, pe, fe, ge, he, me;
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(Pe(H, A.startIndex, A.endIndex + 1).dataStream)));
124
+ a && A && (c((ue = (le = A.properties) == null ? void 0 : le.url) != null ? ue : ""), p(_e.transform.getPlainText(Pe(H, A.startIndex, A.endIndex + 1).dataStream)));
125
125
  return;
126
126
  }
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]);
128
- a && T && c((ve = (he = T == null ? void 0 : T.properties) == null ? void 0 : he.url) != null ? ve : "");
127
+ const y = (pe = a == null ? void 0 : a.getSelfOrHeaderFooterModel(g.segmentId)) == null ? void 0 : pe.getBody(), ce = y ? g : null, T = ce && ((ge = _e.customRange.getCustomRangesInterestsWithSelection(ce, (fe = y == null ? void 0 : y.customRanges) != null ? fe : [])) == null ? void 0 : ge[0]);
128
+ a && T && c((me = (he = T == null ? void 0 : T.properties) == null ? void 0 : he.url) != null ? me : "");
129
129
  }, [a, t, o, r]);
130
- const v = () => {
130
+ const m = () => {
131
131
  n.hideEditPopup();
132
132
  }, C = () => {
133
133
  if (h(!0), !f || !a)
@@ -196,7 +196,7 @@ const V = () => {
196
196
  Se,
197
197
  {
198
198
  className: K.docsLinkEditButton,
199
- onClick: v,
199
+ onClick: m,
200
200
  children: e.t("docLink.edit.cancel")
201
201
  }
202
202
  ),
@@ -214,14 +214,14 @@ const V = () => {
214
214
  ] });
215
215
  };
216
216
  V.componentKey = "docs-hyper-link-edit";
217
- var m = function() {
218
- return m = Object.assign || function(n) {
217
+ var _ = function() {
218
+ return _ = Object.assign || function(n) {
219
219
  for (var e, t = 1, i = arguments.length; t < i; t++) {
220
220
  e = arguments[t];
221
221
  for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (n[r] = e[r]);
222
222
  }
223
223
  return n;
224
- }, m.apply(this, arguments);
224
+ }, _.apply(this, arguments);
225
225
  }, Vn = function(n, e) {
226
226
  var t = {};
227
227
  for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && e.indexOf(i) < 0 && (t[i] = n[i]);
@@ -231,15 +231,15 @@ var m = function() {
231
231
  return t;
232
232
  }, $ = j(function(n, e) {
233
233
  var t = n.icon, i = n.id, r = n.className, o = n.extend, s = Vn(n, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), d = Cn("_".concat(Wn()));
234
- return Me(t, "".concat(i), { defIds: t.defIds, idSuffix: d.current }, m({ ref: e, className: c }, s), o);
234
+ return Me(t, "".concat(i), { defIds: t.defIds, idSuffix: d.current }, _({ ref: e, className: c }, s), o);
235
235
  });
236
236
  function Me(n, e, t, i, r) {
237
- return U(n.tag, m(m({ key: e }, Yn(n, t, r)), i), (Zn(n, t).children || []).map(function(o, s) {
237
+ return U(n.tag, _(_({ key: e }, Yn(n, t, r)), i), (Zn(n, t).children || []).map(function(o, s) {
238
238
  return Me(o, "".concat(e, "-").concat(n.tag, "-").concat(s), t, void 0, r);
239
239
  }));
240
240
  }
241
241
  function Yn(n, e, t) {
242
- var i = m({}, n.attrs);
242
+ var i = _({}, n.attrs);
243
243
  t != null && t.colorChannel1 && i.fill === "colorChannel1" && (i.fill = t.colorChannel1);
244
244
  var r = e.defIds;
245
245
  return !r || r.length === 0 || (n.tag === "use" && i["xlink:href"] && (i["xlink:href"] = i["xlink:href"] + e.idSuffix), Object.entries(i).forEach(function(o) {
@@ -249,8 +249,8 @@ function Yn(n, e, t) {
249
249
  }
250
250
  function Zn(n, e) {
251
251
  var t, i = e.defIds;
252
- return !i || i.length === 0 ? n : n.tag === "defs" && (!((t = n.children) === null || t === void 0) && t.length) ? m(m({}, n), { children: n.children.map(function(r) {
253
- return typeof r.attrs.id == "string" && i && i.indexOf(r.attrs.id) > -1 ? m(m({}, r), { attrs: m(m({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
252
+ return !i || i.length === 0 ? n : n.tag === "defs" && (!((t = n.children) === null || t === void 0) && t.length) ? _(_({}, n), { children: n.children.map(function(r) {
253
+ return typeof r.attrs.id == "string" && i && i.indexOf(r.attrs.id) > -1 ? _(_({}, r), { attrs: _(_({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
254
254
  }) }) : n;
255
255
  }
256
256
  function Wn() {
@@ -362,7 +362,7 @@ const Ue = {
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);
363
363
  if (!a)
364
364
  return null;
365
- const v = (g = a.properties) == null ? void 0 : g.url;
365
+ const m = (g = a.properties) == null ? void 0 : g.url;
366
366
  return /* @__PURE__ */ u.jsxs(
367
367
  "div",
368
368
  {
@@ -371,9 +371,9 @@ const Ue = {
371
371
  n.hideInfoPopup();
372
372
  },
373
373
  children: [
374
- /* @__PURE__ */ u.jsxs("div", { className: xe(k.docLinkContent), onClick: () => window.open(v), children: [
374
+ /* @__PURE__ */ u.jsxs("div", { className: xe(k.docLinkContent), onClick: () => window.open(m), children: [
375
375
  /* @__PURE__ */ u.jsx("div", { className: k.docLinkType, children: /* @__PURE__ */ u.jsx(se, {}) }),
376
- /* @__PURE__ */ u.jsx(B, { showIfEllipsis: !0, title: v, children: /* @__PURE__ */ u.jsx("span", { className: k.docLinkUrl, children: v }) })
376
+ /* @__PURE__ */ u.jsx(B, { showIfEllipsis: !0, title: m, children: /* @__PURE__ */ u.jsx("span", { className: k.docLinkUrl, children: m }) })
377
377
  ] }),
378
378
  /* @__PURE__ */ u.jsxs("div", { className: k.docLinkOperations, children: [
379
379
  /* @__PURE__ */ u.jsx(
@@ -381,7 +381,7 @@ const Ue = {
381
381
  {
382
382
  className: xe(k.docLinkOperation),
383
383
  onClick: () => {
384
- navigator.clipboard.writeText(v), t.show({
384
+ navigator.clipboard.writeText(m), t.show({
385
385
  content: i.t("docLink.info.coped"),
386
386
  type: Sn.Info
387
387
  });
@@ -429,8 +429,8 @@ var st = Object.defineProperty, ct = Object.getOwnPropertyDescriptor, dt = (n, e
429
429
  let L = class extends N {
430
430
  constructor(e, t, i) {
431
431
  super();
432
- P(this, "_editingLink$", new _e(null));
433
- P(this, "_showingLink$", new _e(null));
432
+ P(this, "_editingLink$", new ve(null));
433
+ P(this, "_showingLink$", new ve(null));
434
434
  P(this, "editingLink$", this._editingLink$.asObservable());
435
435
  P(this, "showingLink$", this._showingLink$.asObservable());
436
436
  P(this, "_editPopup", null);
@@ -476,9 +476,9 @@ let L = class extends N {
476
476
  this._editingLink$.next(null), (e = this._editPopup) == null || e.dispose();
477
477
  }
478
478
  showInfoPopup(e) {
479
- var p, l, h, f, a, v;
479
+ var p, l, h, f, a, m;
480
480
  const { linkId: t, unitId: i, segmentId: r, segmentPage: o, startIndex: s, endIndex: c } = e;
481
- if (!(((p = this.showing) == null ? void 0 : p.linkId) === t && ((l = this.showing) == null ? void 0 : l.unitId) === i && ((h = this.showing) == null ? void 0 : h.segmentId) === r && ((f = this.showing) == null ? void 0 : f.segmentPage) === o && ((a = this.showing) == null ? void 0 : a.startIndex) === s && ((v = this.showing) == null ? void 0 : v.endIndex) === c || (this._infoPopup && this._infoPopup.dispose(), !this._univerInstanceService.getUnit(i, I.UNIVER_DOC))))
481
+ if (!(((p = this.showing) == null ? void 0 : p.linkId) === t && ((l = this.showing) == null ? void 0 : l.unitId) === i && ((h = this.showing) == null ? void 0 : h.segmentId) === r && ((f = this.showing) == null ? void 0 : f.segmentPage) === o && ((a = this.showing) == null ? void 0 : a.startIndex) === s && ((m = this.showing) == null ? void 0 : m.endIndex) === c || (this._infoPopup && this._infoPopup.dispose(), !this._univerInstanceService.getUnit(i, I.UNIVER_DOC))))
482
482
  return this._showingLink$.next({ unitId: i, linkId: t, segmentId: r, segmentPage: o, startIndex: s, endIndex: c }), this._infoPopup = this._docCanvasPopupManagerService.attachPopupToRange(
483
483
  {
484
484
  collapsed: !1,
@@ -504,8 +504,8 @@ let L = class extends N {
504
504
  }
505
505
  };
506
506
  L = dt([
507
- Q(0, _(ln)),
508
- Q(1, _(b)),
507
+ Q(0, v(ln)),
508
+ Q(1, v(b)),
509
509
  Q(2, O)
510
510
  ], L);
511
511
  var at = Object.defineProperty, lt = Object.getOwnPropertyDescriptor, ut = (n, e, t, i) => {
@@ -524,15 +524,15 @@ let Z = class extends N {
524
524
  if (n.id === sn.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
- 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;
527
+ const { startOffset: l, endOffset: h, collapsed: f, segmentPage: a } = p, m = (t = (e = d.getSelfOrHeaderFooterModel(c)) == null ? void 0 : e.getBody()) == null ? void 0 : t.customRanges;
528
528
  if (f) {
529
- const C = (i = v == null ? void 0 : v.findIndex((g) => g.startIndex < l && g.endIndex > h - 1)) != null ? i : -1;
529
+ const C = (i = m == null ? void 0 : m.findIndex((g) => g.startIndex < l && g.endIndex > h - 1)) != null ? i : -1;
530
530
  if (C > -1) {
531
- const g = v[C];
531
+ const g = m[C];
532
532
  this._docHyperLinkService.showInfoPopup({ unitId: o, linkId: g.rangeId, segmentId: c, segmentPage: a, startIndex: g.startIndex, endIndex: g.endIndex });
533
533
  return;
534
534
  }
535
- } else if (v == null ? void 0 : v.find((g) => g.startIndex <= l && g.endIndex >= h - 1))
535
+ } else if (m == null ? void 0 : m.find((g) => g.startIndex <= l && g.endIndex >= h - 1))
536
536
  return;
537
537
  }
538
538
  this._docHyperLinkService.hideInfoPopup(), this._docHyperLinkService.hideEditPopup();
@@ -544,7 +544,7 @@ let Z = class extends N {
544
544
  Z = ut([
545
545
  X(0, x),
546
546
  X(1, O),
547
- X(2, _(L))
547
+ X(2, v(L))
548
548
  ], Z);
549
549
  var pt = Object.defineProperty, ft = Object.getOwnPropertyDescriptor, gt = (n, e, t, i) => {
550
550
  for (var r = i > 1 ? void 0 : i ? ft(e, t) : e, o = n.length - 1, s; o >= 0; o--)
@@ -604,14 +604,14 @@ let re = class extends N {
604
604
  }
605
605
  };
606
606
  re = gt([
607
- w(1, _(un)),
607
+ w(1, v(un)),
608
608
  w(2, x),
609
- w(3, _(L)),
610
- w(4, _(cn)),
611
- w(5, _(b))
609
+ w(3, v(L)),
610
+ w(4, v(cn)),
611
+ w(5, v(b))
612
612
  ], re);
613
- var ht = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, mt = (n, e, t, i) => {
614
- for (var r = i > 1 ? void 0 : i ? vt(e, t) : e, o = n.length - 1, s; o >= 0; o--)
613
+ var ht = Object.defineProperty, mt = Object.getOwnPropertyDescriptor, _t = (n, e, t, i) => {
614
+ for (var r = i > 1 ? void 0 : i ? mt(e, t) : e, o = n.length - 1, s; o >= 0; o--)
615
615
  (s = n[o]) && (r = (i ? s(e, t, r) : s(r)) || r);
616
616
  return i && r && ht(e, t, r), r;
617
617
  }, ee = (n, e) => (t, i) => e(t, i, n);
@@ -647,10 +647,10 @@ let oe = class extends N {
647
647
  }));
648
648
  }
649
649
  };
650
- oe = mt([
651
- ee(1, _(dn)),
652
- ee(2, _(L)),
653
- ee(3, _(pn))
650
+ oe = _t([
651
+ ee(1, v(dn)),
652
+ ee(2, v(L)),
653
+ ee(3, v(pn))
654
654
  ], oe);
655
655
  const He = "doc-hyper-link-icon";
656
656
  function Oe(n) {
@@ -661,8 +661,8 @@ function Oe(n) {
661
661
  title: "docLink.menu.tooltip",
662
662
  tooltip: "docLink.menu.tooltip",
663
663
  hidden$: On(n, I.UNIVER_DOC),
664
- disabled$: new vn(function(e) {
665
- const i = n.get(b).textSelection$.pipe(mn(16)).subscribe(() => {
664
+ disabled$: new mn(function(e) {
665
+ const i = n.get(b).textSelection$.pipe(_n(16)).subscribe(() => {
666
666
  e.next($e(n));
667
667
  });
668
668
  return () => {
@@ -671,7 +671,7 @@ function Oe(n) {
671
671
  })
672
672
  };
673
673
  }
674
- const _t = {
674
+ const vt = {
675
675
  id: R.id,
676
676
  binding: kn.CTRL_COMMAND | te.K,
677
677
  description: "docLink.menu.tooltip",
@@ -723,7 +723,7 @@ let W = class extends N {
723
723
  });
724
724
  }
725
725
  _initShortcut() {
726
- [_t].forEach((n) => {
726
+ [vt].forEach((n) => {
727
727
  this._shortcutService.registerShortcut(n);
728
728
  });
729
729
  }
@@ -732,7 +732,7 @@ let W = class extends N {
732
732
  }
733
733
  };
734
734
  W = Lt([
735
- F(0, _(bn)),
735
+ F(0, v(bn)),
736
736
  F(1, x),
737
737
  F(2, Mn),
738
738
  F(3, wn)
@@ -781,7 +781,7 @@ Be(G, "pluginName", yt);
781
781
  Be(G, "type", I.UNIVER_DOC);
782
782
  G = Ot([
783
783
  qe(en),
784
- ne(1, _(Je)),
784
+ ne(1, v(Je)),
785
785
  ne(2, nn),
786
786
  ne(3, Xe)
787
787
  ], G);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-hyper-link-ui",
3
- "version": "0.5.3",
3
+ "version": "0.5.4-experimental.20250114-7c09c35",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -52,24 +52,25 @@
52
52
  "rxjs": ">=7.0.0"
53
53
  },
54
54
  "dependencies": {
55
- "@univerjs/icons": "^0.2.10",
55
+ "@univerjs/icons": "^0.2.12",
56
56
  "clsx": "^2.1.1",
57
- "@univerjs/core": "0.5.3",
58
- "@univerjs/design": "0.5.3",
59
- "@univerjs/docs": "0.5.3",
60
- "@univerjs/docs-hyper-link": "0.5.3",
61
- "@univerjs/docs-ui": "0.5.3",
62
- "@univerjs/engine-render": "0.5.3",
63
- "@univerjs/ui": "0.5.3"
57
+ "@univerjs/design": "0.5.4-experimental.20250114-7c09c35",
58
+ "@univerjs/core": "0.5.4-experimental.20250114-7c09c35",
59
+ "@univerjs/docs": "0.5.4-experimental.20250114-7c09c35",
60
+ "@univerjs/docs-hyper-link": "0.5.4-experimental.20250114-7c09c35",
61
+ "@univerjs/engine-render": "0.5.4-experimental.20250114-7c09c35",
62
+ "@univerjs/ui": "0.5.4-experimental.20250114-7c09c35",
63
+ "@univerjs/docs-ui": "0.5.4-experimental.20250114-7c09c35"
64
64
  },
65
65
  "devDependencies": {
66
66
  "postcss": "^8.4.49",
67
67
  "react": "18.3.1",
68
68
  "rxjs": "^7.8.1",
69
+ "tailwindcss": "^3.4.17",
69
70
  "typescript": "^5.7.2",
70
- "vite": "^6.0.6",
71
+ "vite": "^6.0.7",
71
72
  "vitest": "^2.1.8",
72
- "@univerjs-infra/shared": "0.5.3"
73
+ "@univerjs-infra/shared": "0.5.4"
73
74
  },
74
75
  "scripts": {
75
76
  "test": "vitest run",
package/LICENSE DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS