@univerjs/docs-hyper-link-ui 0.6.0-alpha.0 → 0.6.0-experimental.20250212-dbe9830
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 +1 -1
- package/lib/es/index.js +125 -125
- package/lib/types/index.d.ts +1 -1
- package/lib/types/locale/zh-CN.d.ts +1 -1
- package/lib/types/types/const/index.d.ts +1 -1
- package/lib/types/views/hyper-link-edit/index.d.ts +1 -1
- package/lib/types/views/hyper-link-popup/index.d.ts +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +11 -11
- package/LICENSE +0 -176
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Le=Object.defineProperty;var ke=(n,e,t)=>e in n?Le(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var P=(n,e,t)=>ke(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),xe=require("@univerjs/docs-hyper-link"),Oe=require("@univerjs/engine-render"),C=require("@univerjs/docs"),K=require("@univerjs/docs-ui"),D=require("rxjs"),l=require("react/jsx-runtime"),y=require("@univerjs/design"),_=require("@univerjs/ui"),m=require("react"),Pe="docs-hyper-link-ui.config",ce={},le={type:o.CommandType.COMMAND,id:"docs.command.add-hyper-link",async handler(n,e){if(!e)return!1;const{payload:t,unitId:i,selections:r}=e,s=n.get(o.ICommandService),c=o.generateRandomId(),d=C.addCustomRangeBySelectionFactory(n,{rangeId:c,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:t},unitId:i,selections:r});return d?s.syncExecuteCommand(d.id,d.params):!1}},ue={id:"docs.command.update-hyper-link",type:o.CommandType.COMMAND,handler(n,e){var f;if(!e)return!1;const{unitId:t,payload:i,segmentId:r,linkId:s}=e,c=n.get(o.ICommandService),d=n.get(o.IUniverInstanceService),g=n.get(C.DocSelectionManagerService).getActiveTextRange(),v=d.getUnit(t,o.UniverInstanceType.UNIVER_DOC);if(!g||!v)return!1;const h=(f=o.getBodySlice(v.getSelfOrHeaderFooterModel(r).getBody(),g.startOffset,g.endOffset).textRuns)==null?void 0:f[0];h&&(h.ed=e.label.length+1);const a=C.replaceSelectionFactory(n,{unitId:t,body:{dataStream:`${e.label}`,customRanges:[{rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:e.label.length+1,properties:{url:i}}],textRuns:h?[h]:void 0},selection:{startOffset:g.startOffset,endOffset:g.endOffset,collapsed:!1,segmentId:r}});return a?c.syncExecuteCommand(a.id,a.params):!1}},De="univer-docs-link-edit",Ee="univer-docs-link-edit-title",Re="univer-docs-link-edit-close",be="univer-docs-link-edit-buttons",Me="univer-docs-link-edit-button",T={docsLinkEdit:De,docsLinkEditTitle:Ee,docsLinkEditClose:Re,docsLinkEditButtons:be,docsLinkEditButton:Me};function Ue(n){return/^[a-zA-Z]+:\/\//.test(n)}function we(n){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(n)}function Te(n){return Ue(n)?n:we(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(C.DocSelectionManagerService),[c,d]=m.useState(""),[p,g]=m.useState(""),[v,I]=m.useState(!1),h=o.Tools.isLegalUrl(c),a=t?r.getUnit(t.unitId,o.UniverInstanceType.UNIVER_DOC):r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);m.useEffect(()=>{var Q,X,ee,ne,te,ie,re,oe,se;const u=s.getActiveTextRange();if(!u)return;if(t){const U=(Q=a==null?void 0:a.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:Q.getBody(),w=(X=U==null?void 0:U.customRanges)==null?void 0:X.find(A=>(t==null?void 0:t.linkId)===A.rangeId&&A.startIndex===t.startIndex&&A.endIndex===t.endIndex);a&&w&&(d((ne=(ee=w.properties)==null?void 0:ee.url)!=null?ne:""),g(o.BuildTextUtils.transform.getPlainText(o.getBodySlice(U,w.startIndex,w.endIndex+1).dataStream)));return}const x=(te=a==null?void 0:a.getSelfOrHeaderFooterModel(u.segmentId))==null?void 0:te.getBody(),J=x?u:null,M=J&&((re=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(J,(ie=x==null?void 0:x.customRanges)!=null?ie:[]))==null?void 0:re[0]);a&&M&&d((se=(oe=M==null?void 0:M.properties)==null?void 0:oe.url)!=null?se:"")},[a,t,s,r]);const f=()=>{n.hideEditPopup()},L=()=>{if(I(!0),!h||!a)return;const u=Te(c);if(!t)i.executeCommand(le.id,{unitId:a.getUnitId(),payload:u});else{if(!p)return;i.executeCommand(ue.id,{unitId:a.getUnitId(),payload:u,linkId:t.linkId,label:p,segmentId:t.segmentId})}n.hideEditPopup()};if(a)return l.jsxs("div",{className:T.docsLinkEdit,children:[l.jsxs("div",{children:[t?l.jsx(y.FormLayout,{label:e.t("docLink.edit.label"),error:v&&!p?e.t("docLink.edit.labelError"):"",children:l.jsx(y.Input,{value:p,onChange:g,autoFocus:!0,onKeyDown:u=>{u.keyCode===_.KeyCode.ENTER&&L()}})}):null,l.jsx(y.FormLayout,{label:e.t("docLink.edit.address"),error:v&&!h?e.t("docLink.edit.addressError"):"",children:l.jsx(y.Input,{value:c,onChange:d,autoFocus:!0,onKeyDown:u=>{u.keyCode===_.KeyCode.ENTER&&L()}})})]}),l.jsxs("div",{className:T.docsLinkEditButtons,children:[l.jsx(y.Button,{className:T.docsLinkEditButton,onClick:f,children:e.t("docLink.edit.cancel")}),l.jsx(y.Button,{disabled:!c,className:T.docsLinkEditButton,type:"primary",onClick:L,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)},je=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},b=m.forwardRef(function(n,e){var t=n.icon,i=n.id,r=n.className,s=n.extend,c=je(n,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),p=m.useRef("_".concat($e()));return pe(t,"".concat(i),{defIds:t.defIds,idSuffix:p.current},S({ref:e,className:d},c),s)});function pe(n,e,t,i,r){return m.createElement(n.tag,S(S({key:e},Ne(n,t,r)),i),(He(n,t).children||[]).map(function(s,c){return pe(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 $e(){return Math.random().toString(36).substring(2,8)}b.displayName="UniverIcon";var Be={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ge=m.forwardRef(function(n,e){return m.createElement(b,Object.assign({},n,{id:"copy-single",ref:e,icon:Be}))});ge.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=m.forwardRef(function(n,e){return m.createElement(b,Object.assign({},n,{id:"link-single",ref:e,icon:Ke}))});z.displayName="LinkSingle";var Ae={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"}}]},fe=m.forwardRef(function(n,e){return m.createElement(b,Object.assign({},n,{id:"unlink-single",ref:e,icon:Ae}))});fe.displayName="UnlinkSingle";var Fe={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"}}]},he=m.forwardRef(function(n,e){return m.createElement(b,Object.assign({},n,{id:"write-single",ref:e,icon:Fe}))});he.displayName="WriteSingle";function ve(n){var e,t,i="";if(typeof n=="string"||typeof n=="number")i+=n;else if(typeof n=="object")if(Array.isArray(n)){var r=n.length;for(e=0;e<r;e++)n[e]&&(t=ve(n[e]))&&(i&&(i+=" "),i+=t)}else for(t in n)n[t]&&(i&&(i+=" "),i+=t);return i}function de(){for(var n,e,t=0,i="",r=arguments.length;t<r;t++)(n=arguments[t])&&(e=ve(n))&&(i&&(i+=" "),i+=e);return i}const Ie={type:o.CommandType.COMMAND,id:"docs.command.delete-hyper-link",async handler(n,e){if(!e)return!1;const{unitId:t,linkId:i,segmentId:r}=e,s=n.get(o.ICommandService),c=C.deleteCustomRangeFactory(n,{unitId:t,rangeId:i,segmentId:r});return c?await s.syncExecuteCommand(c.id,c.params):!1}},me=n=>{const e=n.get(C.DocSelectionManagerService),t=n.get(o.IUniverInstanceService),i=e.getTextRanges();if(!(i!=null&&i.length))return!0;const r=i[0];return!!(!t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC)||!r||r.collapsed)},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(me(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}},Z={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)}},_e={type:o.CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(n,e){var g,v,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(),p=(I=(v=(g=d==null?void 0:d.customRanges)==null?void 0:g.find(h=>h.rangeId===i&&h.rangeType===o.CustomRangeType.HYPERLINK))==null?void 0:v.properties)==null?void 0:I.url;return p&&window.open(p,"_blank","noopener noreferrer"),!0}},Ve="univer-doc-link",Ye="univer-doc-link-type",qe="univer-doc-link-content",Ze="univer-doc-link-content-error",We="univer-doc-link-url",Ge="univer-doc-link-operations",ze="univer-doc-link-operation",Je="univer-doc-link-operation-error",O={docLink:Ve,docLinkType:Ye,docLinkContent:qe,docLinkContentError:Ze,docLinkUrl:We,docLinkOperations:Ge,docLinkOperation:ze,docLinkOperationError:Je},H=()=>{var L,u;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:p,startIndex:g,endIndex:v}=r,I=s.getUnit(c,o.UniverInstanceType.UNIVER_DOC),h=I==null?void 0:I.getSelfOrHeaderFooterModel(p).getBody(),a=(L=h==null?void 0:h.customRanges)==null?void 0:L.find(x=>x.rangeId===d&&x.rangeType===o.CustomRangeType.HYPERLINK&&x.startIndex===g&&x.endIndex===v);if(!a)return null;const f=(u=a.properties)==null?void 0:u.url;return l.jsxs("div",{className:O.docLink,onClick:()=>{n.hideInfoPopup()},children:[l.jsxs("div",{className:de(O.docLinkContent),onClick:()=>window.open(f),children:[l.jsx("div",{className:O.docLinkType,children:l.jsx(z,{})}),l.jsx(y.Tooltip,{showIfEllipsis:!0,title:f,children:l.jsx("span",{className:O.docLinkUrl,children:f})})]}),l.jsxs("div",{className:O.docLinkOperations,children:[l.jsx("div",{className:de(O.docLinkOperation),onClick:()=>{navigator.clipboard.writeText(f),t.show({content:i.t("docLink.info.coped"),type:y.MessageType.Info})},children:l.jsx(y.Tooltip,{placement:"bottom",title:i.t("docLink.info.copy"),children:l.jsx(ge,{})})}),l.jsx("div",{className:O.docLinkOperation,onClick:()=>{e.executeCommand(E.id,{link:r})},children:l.jsx(y.Tooltip,{placement:"bottom",title:i.t("docLink.info.edit"),children:l.jsx(he,{})})}),l.jsx("div",{className:O.docLinkOperation,onClick:()=>{e.executeCommand(Ie.id,{unitId:c,linkId:a.rangeId,segmentId:p})},children:l.jsx(y.Tooltip,{placement:"bottom",title:i.t("docLink.info.cancel"),children:l.jsx(fe,{})})})]})]})};H.componentKey="univer.doc.link-info-popup";var Qe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,en=(n,e,t,i)=>{for(var r=i>1?void 0:i?Xe(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&Qe(e,t,r),r},F=(n,e)=>(t,i)=>e(t,i,n);let k=class extends o.Disposable{constructor(e,t,i){super();P(this,"_editingLink$",new D.BehaviorSubject(null));P(this,"_showingLink$",new D.BehaviorSubject(null));P(this,"editingLink$",this._editingLink$.asObservable());P(this,"showingLink$",this._showingLink$.asObservable());P(this,"_editPopup",null);P(this,"_infoPopup",null);this._docCanvasPopupManagerService=e,this._textSelectionManagerService=t,this._univerInstanceService=i,this.disposeWithMe(()=>{this._editingLink$.complete(),this._showingLink$.complete()})}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(e,t){this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(t);const i=this._textSelectionManagerService.getTextRanges({unitId:e,subUnitId:e});let r=i==null?void 0:i[i.length-1];if(t){const{segmentId:s,segmentPage:c,startIndex:d,endIndex:p}=t;r={collapsed:!1,startOffset:d,endOffset:p+1,segmentId:s,segmentPage:c},this._textSelectionManagerService.replaceDocRanges([{startOffset:d,endOffset:p+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 g,v,I,h,a,f;const{linkId:t,unitId:i,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}=e;if(!(((g=this.showing)==null?void 0:g.linkId)===t&&((v=this.showing)==null?void 0:v.unitId)===i&&((I=this.showing)==null?void 0:I.segmentId)===r&&((h=this.showing)==null?void 0:h.segmentPage)===s&&((a=this.showing)==null?void 0:a.startIndex)===c&&((f=this.showing)==null?void 0:f.endIndex)===d||(this._infoPopup&&this._infoPopup.dispose(),!this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_DOC))))return this._showingLink$.next({unitId:i,linkId:t,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}),this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:c,endOffset:d+1,segmentId:r,segmentPage:s},{componentKey:H.componentKey,direction:"top-center",multipleDirection:"top",onClickOutside:()=>{this.hideInfoPopup()}},i),this._infoPopup}hideInfoPopup(){var e;this._showingLink$.next(null),(e=this._infoPopup)==null||e.dispose()}};k=en([F(0,o.Inject(K.DocCanvasPopManagerService)),F(1,o.Inject(C.DocSelectionManagerService)),F(2,o.IUniverInstanceService)],k);var nn=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,rn=(n,e,t,i)=>{for(var r=i>1?void 0:i?tn(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&&nn(e,t,r),r},V=(n,e)=>(t,i)=>e(t,i,n);let $=class extends o.Disposable{constructor(n,e,t){super(),this._commandService=n,this._univerInstanceService=e,this._docHyperLinkService=t,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var e,t,i;if(n.id===C.SetTextSelectionsOperation.id){const r=n.params,{unitId:s,ranges:c,segmentId:d}=r,p=this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_DOC),g=c[0];if(g&&p){const{startOffset:v,endOffset:I,collapsed:h,segmentPage:a}=g,f=(t=(e=p.getSelfOrHeaderFooterModel(d))==null?void 0:e.getBody())==null?void 0:t.customRanges;if(h){const L=(i=f==null?void 0:f.findIndex(u=>u.startIndex<v&&u.endIndex>I-1))!=null?i:-1;if(L>-1){const u=f[L];this._docHyperLinkService.showInfoPopup({unitId:s,linkId:u.rangeId,segmentId:d,segmentPage:a,startIndex:u.startIndex,endIndex:u.endIndex});return}}else if(f==null?void 0:f.find(u=>u.startIndex<=v&&u.endIndex>=I-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};$=rn([V(0,o.ICommandService),V(1,o.IUniverInstanceService),V(2,o.Inject(k))],$);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},R=(n,e)=>(t,i)=>e(t,i,n);let W=class extends o.Disposable{constructor(n,e,t,i,r,s){super(),this._context=n,this._docEventManagerService=e,this._commandService=t,this._hyperLinkPopupService=i,this._docSkeletonManagerService=r,this._docSelectionManagerService=s,!(this._context.unitId===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY||this._context.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)&&(this._initHover(),this._initClick())}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(Z.id)}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(n=>{var r;const e=n.find(s=>s.range.rangeType===o.CustomRangeType.HYPERLINK),t=this._docSelectionManagerService.getTextRanges(),i=t==null?void 0:t[0].segmentId;if(((r=e==null?void 0:e.segmentId)!=null?r:"")!==i){this._hideInfoPopup();return}e?this._commandService.executeCommand(Z.id,{unitId:this._context.unitId,linkId:e.range.rangeId,segmentId:e.segmentId,segmentPage:e.segmentPageIndex,rangeId:e.range.rangeId,startIndex:e.range.startIndex,endIndex:e.range.endIndex}):this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(n=>{const e=n.range;e&&this._commandService.executeCommand(_e.id,{unitId:this._context.unitId,linkId:e.rangeId,segmentId:n.segmentId})}))}};W=cn([R(1,o.Inject(K.DocEventManagerService)),R(2,o.ICommandService),R(3,o.Inject(k)),R(4,o.Inject(C.DocSkeletonManagerService)),R(5,o.Inject(C.DocSelectionManagerService))],W);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 G=class extends o.Disposable{constructor(n,e,t,i){super(),this._context=n,this._docInterceptorService=e,this._hyperLinkService=t,this._docRenderController=i,this._init(),this._initReRender()}_init(){this._docInterceptorService.intercept(C.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:(n,e,t)=>{if(!n)return t(n);const{unitId:i,index:r}=e,s=this._hyperLinkService.showing;if(!s)return t({...n,active:!1});const{linkId:c,unitId:d,startIndex:p,endIndex:g}=s,v=d===i&&n.rangeId===c&&r>=p&&r<=g;return t({...n,active:v})}})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(D.distinctUntilChanged((n,e)=>(n==null?void 0:n.linkId)===(e==null?void 0:e.linkId)&&(n==null?void 0:n.unitId)===(e==null?void 0:e.unitId)&&(n==null?void 0:n.startIndex)===(e==null?void 0:e.startIndex)),D.pairwise()).subscribe(([n,e])=>{e?e.unitId===this._context.unitId&&this._docRenderController.reRender(e.unitId):n&&n.unitId===this._context.unitId&&this._docRenderController.reRender(n.unitId)}))}};G=ln([Y(1,o.Inject(C.DocInterceptorService)),Y(2,o.Inject(k)),Y(3,o.Inject(K.DocRenderController))],G);const Ce="doc-hyper-link-icon";function ae(n){return{id:E.id,type:_.MenuItemType.BUTTON,icon:Ce,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:_.getMenuHiddenObservable(n,o.UniverInstanceType.UNIVER_DOC),disabled$:new D.Observable(function(e){const i=n.get(C.DocSelectionManagerService).textSelection$.pipe(D.debounceTime(16)).subscribe(()=>{e.next(me(n))});return()=>{i.unsubscribe()}})}}const un={id:E.id,binding:_.MetaKeys.CTRL_COMMAND|_.KeyCode.K,description:"docLink.menu.tooltip",preconditions:K.whenDocAndEditorFocused},pn={[_.RibbonStartGroup.OTHERS]:{[E.id]:{order:0,menuItemFactory:ae}},[_.ContextMenuPosition.MAIN_AREA]:{[_.ContextMenuGroup.DATA]:{[E.id]:{order:0,menuItemFactory:ae}}}};var gn=Object.defineProperty,fn=Object.getOwnPropertyDescriptor,hn=(n,e,t,i)=>{for(var r=i>1?void 0:i?fn(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},j=(n,e)=>(t,i)=>e(t,i,n);let B=class extends o.Disposable{constructor(n,e,t,i){super(),this._componentManager=n,this._commandService=e,this._menuManagerService=t,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[N,N.componentKey],[H,H.componentKey],[z,Ce]].forEach(([n,e])=>{this._componentManager.register(e,n)})}_initCommands(){[le,ue,Ie,E,Z,_e].forEach(n=>{this._commandService.registerCommand(n)})}_initShortcut(){[un].forEach(n=>{this._shortcutService.registerShortcut(n)})}_initMenus(){this._menuManagerService.mergeMenu(pn)}};B=hn([j(0,o.Inject(_.ComponentManager)),j(1,o.ICommandService),j(2,_.IMenuManagerService),j(3,_.IShortcutService)],B);const vn="DOC_HYPER_LINK_UI_PLUGIN";var Se=Object.defineProperty,In=Object.getOwnPropertyDescriptor,mn=(n,e,t)=>e in n?Se(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,_n=(n,e,t,i)=>{for(var r=i>1?void 0:i?In(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&&Se(e,t,r),r},q=(n,e)=>(t,i)=>e(t,i,n),ye=(n,e,t)=>mn(n,typeof e!="symbol"?e+"":e,t);exports.UniverDocsHyperLinkUIPlugin=class extends o.Plugin{constructor(e=ce,t,i,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=i,this._configService=r;const{menu:s,...c}=o.merge({},ce,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Pe,c)}onStarting(){[[k],[B],[$]].forEach(t=>{this._injector.add(t)}),this._injector.get(B)}onReady(){this._injector.get($)}onRendered(){this._initRenderModule()}_initRenderModule(){[[G],[W]].forEach(e=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,e)})}};ye(exports.UniverDocsHyperLinkUIPlugin,"pluginName",vn);ye(exports.UniverDocsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC);exports.UniverDocsHyperLinkUIPlugin=_n([o.DependentOn(xe.UniverDocsHyperLinkPlugin),q(1,o.Inject(o.Injector)),q(2,Oe.IRenderManagerService),q(3,o.IConfigService)],exports.UniverDocsHyperLinkUIPlugin);
|
|
1
|
+
"use strict";var Le=Object.defineProperty;var ke=(n,e,t)=>e in n?Le(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var P=(n,e,t)=>ke(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),xe=require("@univerjs/docs-hyper-link"),Oe=require("@univerjs/engine-render"),C=require("@univerjs/docs"),K=require("@univerjs/docs-ui"),D=require("rxjs"),l=require("react/jsx-runtime"),y=require("@univerjs/design"),u=require("@univerjs/ui"),_=require("react"),Pe="docs-hyper-link-ui.config",ce={},le={type:o.CommandType.COMMAND,id:"docs.command.add-hyper-link",async handler(n,e){if(!e)return!1;const{payload:t,unitId:i,selections:r}=e,s=n.get(o.ICommandService),c=o.generateRandomId(),d=C.addCustomRangeBySelectionFactory(n,{rangeId:c,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:t},unitId:i,selections:r});return d?s.syncExecuteCommand(d.id,d.params):!1}},ue={id:"docs.command.update-hyper-link",type:o.CommandType.COMMAND,handler(n,e){var h;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(),I=d.getUnit(t,o.UniverInstanceType.UNIVER_DOC);if(!f||!I)return!1;const v=(h=o.getBodySlice(I.getSelfOrHeaderFooterModel(r).getBody(),f.startOffset,f.endOffset).textRuns)==null?void 0:h[0];v&&(v.ed=e.label.length+1);const a=C.replaceSelectionFactory(n,{unitId:t,body:{dataStream:`${e.label}`,customRanges:[{rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:e.label.length+1,properties:{url:i}}],textRuns:v?[v]:void 0},selection:{startOffset:f.startOffset,endOffset:f.endOffset,collapsed:!1,segmentId:r}});return a?c.syncExecuteCommand(a.id,a.params):!1}},De="univer-docs-link-edit",Ee="univer-docs-link-edit-title",Re="univer-docs-link-edit-close",be="univer-docs-link-edit-buttons",Me="univer-docs-link-edit-button",T={docsLinkEdit:De,docsLinkEditTitle:Ee,docsLinkEditClose:Re,docsLinkEditButtons:be,docsLinkEditButton:Me};function Ue(n){return/^[a-zA-Z]+:\/\//.test(n)}function we(n){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(n)}function Te(n){return Ue(n)?n:we(n)?`mailto://${n}`:`https://${n}`}const N=()=>{const n=u.useDependency(k),e=u.useDependency(o.LocaleService),t=u.useObservable(n.editingLink$),i=u.useDependency(o.ICommandService),r=u.useDependency(o.IUniverInstanceService),s=u.useDependency(C.DocSelectionManagerService),[c,d]=_.useState(""),[g,f]=_.useState(""),[I,m]=_.useState(!1),v=o.Tools.isLegalUrl(c),a=t?r.getUnit(t.unitId,o.UniverInstanceType.UNIVER_DOC):r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);_.useEffect(()=>{var Q,X,ee,ne,te,ie,re,oe,se;const p=s.getActiveTextRange();if(!p)return;if(t){const U=(Q=a==null?void 0:a.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:Q.getBody(),w=(X=U==null?void 0:U.customRanges)==null?void 0:X.find(A=>(t==null?void 0:t.linkId)===A.rangeId&&A.startIndex===t.startIndex&&A.endIndex===t.endIndex);a&&w&&(d((ne=(ee=w.properties)==null?void 0:ee.url)!=null?ne:""),f(o.BuildTextUtils.transform.getPlainText(o.getBodySlice(U,w.startIndex,w.endIndex+1).dataStream)));return}const x=(te=a==null?void 0:a.getSelfOrHeaderFooterModel(p.segmentId))==null?void 0:te.getBody(),J=x?p:null,M=J&&((re=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(J,(ie=x==null?void 0:x.customRanges)!=null?ie:[]))==null?void 0:re[0]);a&&M&&d((se=(oe=M==null?void 0:M.properties)==null?void 0:oe.url)!=null?se:"")},[a,t,s,r]);const h=()=>{n.hideEditPopup()},L=()=>{if(m(!0),!v||!a)return;const p=Te(c);if(!t)i.executeCommand(le.id,{unitId:a.getUnitId(),payload:p});else{if(!g)return;i.executeCommand(ue.id,{unitId:a.getUnitId(),payload:p,linkId:t.linkId,label:g,segmentId:t.segmentId})}n.hideEditPopup()};if(a)return l.jsxs("div",{className:T.docsLinkEdit,children:[l.jsxs("div",{children:[t?l.jsx(y.FormLayout,{label:e.t("docLink.edit.label"),error:I&&!g?e.t("docLink.edit.labelError"):"",children:l.jsx(y.Input,{value:g,onChange:f,autoFocus:!0,onKeyDown:p=>{p.keyCode===u.KeyCode.ENTER&&L()}})}):null,l.jsx(y.FormLayout,{label:e.t("docLink.edit.address"),error:I&&!v?e.t("docLink.edit.addressError"):"",children:l.jsx(y.Input,{value:c,onChange:d,autoFocus:!0,onKeyDown:p=>{p.keyCode===u.KeyCode.ENTER&&L()}})})]}),l.jsxs("div",{className:T.docsLinkEditButtons,children:[l.jsx(y.Button,{className:T.docsLinkEditButton,onClick:h,children:e.t("docLink.edit.cancel")}),l.jsx(y.Button,{disabled:!c,className:T.docsLinkEditButton,type:"primary",onClick:L,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)},je=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},b=_.forwardRef(function(n,e){var t=n.icon,i=n.id,r=n.className,s=n.extend,c=je(n,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),g=_.useRef("_".concat($e()));return pe(t,"".concat(i),{defIds:t.defIds,idSuffix:g.current},S({ref:e,className:d},c),s)});function pe(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 pe(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 $e(){return Math.random().toString(36).substring(2,8)}b.displayName="UniverIcon";var Be={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ge=_.forwardRef(function(n,e){return _.createElement(b,Object.assign({},n,{id:"copy-single",ref:e,icon:Be}))});ge.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(b,Object.assign({},n,{id:"link-single",ref:e,icon:Ke}))});z.displayName="LinkSingle";var Ae={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"}}]},fe=_.forwardRef(function(n,e){return _.createElement(b,Object.assign({},n,{id:"unlink-single",ref:e,icon:Ae}))});fe.displayName="UnlinkSingle";var Fe={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"}}]},he=_.forwardRef(function(n,e){return _.createElement(b,Object.assign({},n,{id:"write-single",ref:e,icon:Fe}))});he.displayName="WriteSingle";function ve(n){var e,t,i="";if(typeof n=="string"||typeof n=="number")i+=n;else if(typeof n=="object")if(Array.isArray(n)){var r=n.length;for(e=0;e<r;e++)n[e]&&(t=ve(n[e]))&&(i&&(i+=" "),i+=t)}else for(t in n)n[t]&&(i&&(i+=" "),i+=t);return i}function de(){for(var n,e,t=0,i="",r=arguments.length;t<r;t++)(n=arguments[t])&&(e=ve(n))&&(i&&(i+=" "),i+=e);return i}const Ie={type:o.CommandType.COMMAND,id:"docs.command.delete-hyper-link",async handler(n,e){if(!e)return!1;const{unitId:t,linkId:i,segmentId:r}=e,s=n.get(o.ICommandService),c=C.deleteCustomRangeFactory(n,{unitId:t,rangeId:i,segmentId:r});return c?await s.syncExecuteCommand(c.id,c.params):!1}},me=n=>{const e=n.get(C.DocSelectionManagerService),t=n.get(o.IUniverInstanceService),i=e.getTextRanges();if(!(i!=null&&i.length))return!0;const r=i[0];return!!(!t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC)||!r||r.collapsed)},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(me(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}},Z={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)}},_e={type:o.CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(n,e){var f,I,m;if(!e)return!1;const{unitId:t,linkId:i,segmentId:r}=e,c=n.get(o.IUniverInstanceService).getUnit(t,o.UniverInstanceType.UNIVER_DOC),d=c==null?void 0:c.getSelfOrHeaderFooterModel(r).getBody(),g=(m=(I=(f=d==null?void 0:d.customRanges)==null?void 0:f.find(v=>v.rangeId===i&&v.rangeType===o.CustomRangeType.HYPERLINK))==null?void 0:I.properties)==null?void 0:m.url;return g&&window.open(g,"_blank","noopener noreferrer"),!0}},Ve="univer-doc-link",Ye="univer-doc-link-type",qe="univer-doc-link-content",Ze="univer-doc-link-content-error",We="univer-doc-link-url",Ge="univer-doc-link-operations",ze="univer-doc-link-operation",Je="univer-doc-link-operation-error",O={docLink:Ve,docLinkType:Ye,docLinkContent:qe,docLinkContentError:Ze,docLinkUrl:We,docLinkOperations:Ge,docLinkOperation:ze,docLinkOperationError:Je},H=()=>{var L,p;const n=u.useDependency(k),e=u.useDependency(o.ICommandService),t=u.useDependency(u.IMessageService),i=u.useDependency(o.LocaleService),r=u.useObservable(n.showingLink$),s=u.useDependency(o.IUniverInstanceService);if(!r)return null;const{unitId:c,linkId:d,segmentId:g,startIndex:f,endIndex:I}=r,m=s.getUnit(c,o.UniverInstanceType.UNIVER_DOC),v=m==null?void 0:m.getSelfOrHeaderFooterModel(g).getBody(),a=(L=v==null?void 0:v.customRanges)==null?void 0:L.find(x=>x.rangeId===d&&x.rangeType===o.CustomRangeType.HYPERLINK&&x.startIndex===f&&x.endIndex===I);if(!a)return null;const h=(p=a.properties)==null?void 0:p.url;return l.jsxs("div",{className:O.docLink,onClick:()=>{n.hideInfoPopup()},children:[l.jsxs("div",{className:de(O.docLinkContent),onClick:()=>window.open(h),children:[l.jsx("div",{className:O.docLinkType,children:l.jsx(z,{})}),l.jsx(y.Tooltip,{showIfEllipsis:!0,title:h,children:l.jsx("span",{className:O.docLinkUrl,children:h})})]}),l.jsxs("div",{className:O.docLinkOperations,children:[l.jsx("div",{className:de(O.docLinkOperation),onClick:()=>{navigator.clipboard.writeText(h),t.show({content:i.t("docLink.info.coped"),type:y.MessageType.Info})},children:l.jsx(y.Tooltip,{placement:"bottom",title:i.t("docLink.info.copy"),children:l.jsx(ge,{})})}),l.jsx("div",{className:O.docLinkOperation,onClick:()=>{e.executeCommand(E.id,{link:r})},children:l.jsx(y.Tooltip,{placement:"bottom",title:i.t("docLink.info.edit"),children:l.jsx(he,{})})}),l.jsx("div",{className:O.docLinkOperation,onClick:()=>{e.executeCommand(Ie.id,{unitId:c,linkId:a.rangeId,segmentId:g})},children:l.jsx(y.Tooltip,{placement:"bottom",title:i.t("docLink.info.cancel"),children:l.jsx(fe,{})})})]})]})};H.componentKey="univer.doc.link-info-popup";var Qe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,en=(n,e,t,i)=>{for(var r=i>1?void 0:i?Xe(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&Qe(e,t,r),r},F=(n,e)=>(t,i)=>e(t,i,n);let k=class extends o.Disposable{constructor(e,t,i){super();P(this,"_editingLink$",new D.BehaviorSubject(null));P(this,"_showingLink$",new D.BehaviorSubject(null));P(this,"editingLink$",this._editingLink$.asObservable());P(this,"showingLink$",this._showingLink$.asObservable());P(this,"_editPopup",null);P(this,"_infoPopup",null);this._docCanvasPopupManagerService=e,this._textSelectionManagerService=t,this._univerInstanceService=i,this.disposeWithMe(()=>{this._editingLink$.complete(),this._showingLink$.complete()})}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(e,t){this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(t);const i=this._textSelectionManagerService.getTextRanges({unitId:e,subUnitId:e});let r=i==null?void 0:i[i.length-1];if(t){const{segmentId:s,segmentPage:c,startIndex:d,endIndex:g}=t;r={collapsed:!1,startOffset:d,endOffset:g+1,segmentId:s,segmentPage:c},this._textSelectionManagerService.replaceDocRanges([{startOffset:d,endOffset:g+1}])}return r?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(r,{componentKey:N.componentKey,direction:"bottom"},e),this._editPopup):null}hideEditPopup(){var e;this._editingLink$.next(null),(e=this._editPopup)==null||e.dispose()}showInfoPopup(e){var f,I,m,v,a,h;const{linkId:t,unitId:i,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}=e;if(!(((f=this.showing)==null?void 0:f.linkId)===t&&((I=this.showing)==null?void 0:I.unitId)===i&&((m=this.showing)==null?void 0:m.segmentId)===r&&((v=this.showing)==null?void 0:v.segmentPage)===s&&((a=this.showing)==null?void 0:a.startIndex)===c&&((h=this.showing)==null?void 0:h.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=en([F(0,o.Inject(K.DocCanvasPopManagerService)),F(1,o.Inject(C.DocSelectionManagerService)),F(2,o.IUniverInstanceService)],k);var nn=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,rn=(n,e,t,i)=>{for(var r=i>1?void 0:i?tn(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&&nn(e,t,r),r},V=(n,e)=>(t,i)=>e(t,i,n);let $=class extends o.Disposable{constructor(n,e,t){super(),this._commandService=n,this._univerInstanceService=e,this._docHyperLinkService=t,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var e,t,i;if(n.id===C.SetTextSelectionsOperation.id){const r=n.params,{unitId:s,ranges:c,segmentId:d}=r,g=this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_DOC),f=c[0];if(f&&g){const{startOffset:I,endOffset:m,collapsed:v,segmentPage:a}=f,h=(t=(e=g.getSelfOrHeaderFooterModel(d))==null?void 0:e.getBody())==null?void 0:t.customRanges;if(v){const L=(i=h==null?void 0:h.findIndex(p=>p.startIndex<I&&p.endIndex>m-1))!=null?i:-1;if(L>-1){const p=h[L];this._docHyperLinkService.showInfoPopup({unitId:s,linkId:p.rangeId,segmentId:d,segmentPage:a,startIndex:p.startIndex,endIndex:p.endIndex});return}}else if(h==null?void 0:h.find(p=>p.startIndex<=I&&p.endIndex>=m-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};$=rn([V(0,o.ICommandService),V(1,o.IUniverInstanceService),V(2,o.Inject(k))],$);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},R=(n,e)=>(t,i)=>e(t,i,n);let W=class extends o.Disposable{constructor(n,e,t,i,r,s){super(),this._context=n,this._docEventManagerService=e,this._commandService=t,this._hyperLinkPopupService=i,this._docSkeletonManagerService=r,this._docSelectionManagerService=s,!(this._context.unitId===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY||this._context.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)&&(this._initHover(),this._initClick())}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(Z.id)}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(n=>{var r;const e=n.find(s=>s.range.rangeType===o.CustomRangeType.HYPERLINK),t=this._docSelectionManagerService.getTextRanges(),i=t==null?void 0:t[0].segmentId;if(((r=e==null?void 0:e.segmentId)!=null?r:"")!==i){this._hideInfoPopup();return}e?this._commandService.executeCommand(Z.id,{unitId:this._context.unitId,linkId:e.range.rangeId,segmentId:e.segmentId,segmentPage:e.segmentPageIndex,rangeId:e.range.rangeId,startIndex:e.range.startIndex,endIndex:e.range.endIndex}):this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(n=>{const e=n.range;e&&this._commandService.executeCommand(_e.id,{unitId:this._context.unitId,linkId:e.rangeId,segmentId:n.segmentId})}))}};W=cn([R(1,o.Inject(K.DocEventManagerService)),R(2,o.ICommandService),R(3,o.Inject(k)),R(4,o.Inject(C.DocSkeletonManagerService)),R(5,o.Inject(C.DocSelectionManagerService))],W);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 G=class extends o.Disposable{constructor(n,e,t,i){super(),this._context=n,this._docInterceptorService=e,this._hyperLinkService=t,this._docRenderController=i,this._init(),this._initReRender()}_init(){this._docInterceptorService.intercept(C.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:(n,e,t)=>{if(!n)return t(n);const{unitId:i,index:r}=e,s=this._hyperLinkService.showing;if(!s)return t({...n,active:!1});const{linkId:c,unitId:d,startIndex:g,endIndex:f}=s,I=d===i&&n.rangeId===c&&r>=g&&r<=f;return t({...n,active:I})}})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(D.distinctUntilChanged((n,e)=>(n==null?void 0:n.linkId)===(e==null?void 0:e.linkId)&&(n==null?void 0:n.unitId)===(e==null?void 0:e.unitId)&&(n==null?void 0:n.startIndex)===(e==null?void 0:e.startIndex)),D.pairwise()).subscribe(([n,e])=>{e?e.unitId===this._context.unitId&&this._docRenderController.reRender(e.unitId):n&&n.unitId===this._context.unitId&&this._docRenderController.reRender(n.unitId)}))}};G=ln([Y(1,o.Inject(C.DocInterceptorService)),Y(2,o.Inject(k)),Y(3,o.Inject(K.DocRenderController))],G);const Ce="doc-hyper-link-icon";function ae(n){return{id:E.id,type:u.MenuItemType.BUTTON,icon:Ce,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:u.getMenuHiddenObservable(n,o.UniverInstanceType.UNIVER_DOC),disabled$:new D.Observable(function(e){const i=n.get(C.DocSelectionManagerService).textSelection$.pipe(D.debounceTime(16)).subscribe(()=>{e.next(me(n))});return()=>{i.unsubscribe()}})}}const un={id:E.id,binding:u.MetaKeys.CTRL_COMMAND|u.KeyCode.K,description:"docLink.menu.tooltip",preconditions:K.whenDocAndEditorFocused},pn={[u.RibbonStartGroup.OTHERS]:{[E.id]:{order:0,menuItemFactory:ae}},[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.DATA]:{[E.id]:{order:0,menuItemFactory:ae}}}};var gn=Object.defineProperty,fn=Object.getOwnPropertyDescriptor,hn=(n,e,t,i)=>{for(var r=i>1?void 0:i?fn(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},j=(n,e)=>(t,i)=>e(t,i,n);let B=class extends o.Disposable{constructor(n,e,t,i){super(),this._componentManager=n,this._commandService=e,this._menuManagerService=t,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[N,N.componentKey],[H,H.componentKey],[z,Ce]].forEach(([n,e])=>{this._componentManager.register(e,n)})}_initCommands(){[le,ue,Ie,E,Z,_e].forEach(n=>{this._commandService.registerCommand(n)})}_initShortcut(){[un].forEach(n=>{this._shortcutService.registerShortcut(n)})}_initMenus(){this._menuManagerService.mergeMenu(pn)}};B=hn([j(0,o.Inject(u.ComponentManager)),j(1,o.ICommandService),j(2,u.IMenuManagerService),j(3,u.IShortcutService)],B);const vn="DOC_HYPER_LINK_UI_PLUGIN";var Se=Object.defineProperty,In=Object.getOwnPropertyDescriptor,mn=(n,e,t)=>e in n?Se(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,_n=(n,e,t,i)=>{for(var r=i>1?void 0:i?In(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&&Se(e,t,r),r},q=(n,e)=>(t,i)=>e(t,i,n),ye=(n,e,t)=>mn(n,typeof e!="symbol"?e+"":e,t);exports.UniverDocsHyperLinkUIPlugin=class extends o.Plugin{constructor(e=ce,t,i,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=i,this._configService=r;const{menu:s,...c}=o.merge({},ce,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Pe,c)}onStarting(){[[k],[B],[$]].forEach(t=>{this._injector.add(t)}),this._injector.get(B)}onReady(){this._injector.get($)}onRendered(){this._initRenderModule()}_initRenderModule(){[[G],[W]].forEach(e=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,e)})}};ye(exports.UniverDocsHyperLinkUIPlugin,"pluginName",vn);ye(exports.UniverDocsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC);exports.UniverDocsHyperLinkUIPlugin=_n([o.DependentOn(xe.UniverDocsHyperLinkPlugin),q(1,o.Inject(o.Injector)),q(2,Oe.IRenderManagerService),q(3,o.IConfigService)],exports.UniverDocsHyperLinkUIPlugin);
|
package/lib/es/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var P = (n, e, t) =>
|
|
4
|
-
import { CommandType as
|
|
1
|
+
var Ae = Object.defineProperty;
|
|
2
|
+
var Be = (n, e, t) => e in n ? Ae(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var P = (n, e, t) => Be(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { CommandType as M, ICommandService as O, generateRandomId as Ke, CustomRangeType as D, IUniverInstanceService as x, UniverInstanceType as I, getBodySlice as ye, LocaleService as Oe, Tools as Fe, BuildTextUtils as me, Disposable as N, Inject as _, DOCS_ZEN_EDITOR_UNIT_ID_KEY as Ve, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as Ye, DependentOn as Ze, Injector as We, Plugin as Ge, merge as ze, IConfigService as qe } from "@univerjs/core";
|
|
5
5
|
import { UniverDocsHyperLinkPlugin as Je } from "@univerjs/docs-hyper-link";
|
|
6
6
|
import { IRenderManagerService as Qe } from "@univerjs/engine-render";
|
|
7
|
-
import { addCustomRangeBySelectionFactory as Xe, DocSelectionManagerService as
|
|
7
|
+
import { addCustomRangeBySelectionFactory as Xe, DocSelectionManagerService as b, replaceSelectionFactory as en, deleteCustomRangeFactory as nn, SetTextSelectionsOperation as tn, DocSkeletonManagerService as rn, DocInterceptorService as on, DOC_INTERCEPTOR_POINT as sn } from "@univerjs/docs";
|
|
8
8
|
import { DocCanvasPopManagerService as cn, DocEventManagerService as dn, DocRenderController as an, whenDocAndEditorFocused as ln } from "@univerjs/docs-ui";
|
|
9
9
|
import { BehaviorSubject as ve, distinctUntilChanged as un, pairwise as pn, Observable as fn, debounceTime as gn } from "rxjs";
|
|
10
10
|
import { jsxs as E, jsx as g } from "react/jsx-runtime";
|
|
11
11
|
import { FormLayout as _e, Input as Ie, Button as Ce, Tooltip as B, MessageType as hn } from "@univerjs/design";
|
|
12
|
-
import {
|
|
13
|
-
import { useState as q, useEffect as
|
|
14
|
-
const
|
|
15
|
-
type:
|
|
12
|
+
import { useDependency as S, useObservable as xe, KeyCode as ne, IMessageService as mn, MetaKeys as vn, MenuItemType as _n, getMenuHiddenObservable as In, RibbonStartGroup as Cn, ContextMenuPosition as Sn, ContextMenuGroup as Ln, ComponentManager as kn, IMenuManagerService as yn, IShortcutService as On } from "@univerjs/ui";
|
|
13
|
+
import { useState as q, useEffect as xn, forwardRef as U, useRef as Pn, createElement as T } from "react";
|
|
14
|
+
const En = "docs-hyper-link-ui.config", Se = {}, Pe = {
|
|
15
|
+
type: M.COMMAND,
|
|
16
16
|
id: "docs.command.add-hyper-link",
|
|
17
17
|
async handler(n, e) {
|
|
18
18
|
if (!e)
|
|
19
19
|
return !1;
|
|
20
|
-
const { payload: t, unitId: i, selections: r } = e, o = n.get(O), s =
|
|
20
|
+
const { payload: t, unitId: i, selections: r } = e, o = n.get(O), s = Ke(), c = Xe(
|
|
21
21
|
n,
|
|
22
22
|
{
|
|
23
23
|
rangeId: s,
|
|
@@ -31,14 +31,14 @@ const Rn = "docs-hyper-link-ui.config", Se = {}, xe = {
|
|
|
31
31
|
);
|
|
32
32
|
return c ? o.syncExecuteCommand(c.id, c.params) : !1;
|
|
33
33
|
}
|
|
34
|
-
},
|
|
34
|
+
}, Ee = {
|
|
35
35
|
id: "docs.command.update-hyper-link",
|
|
36
|
-
type:
|
|
36
|
+
type: M.COMMAND,
|
|
37
37
|
handler(n, e) {
|
|
38
38
|
var p;
|
|
39
39
|
if (!e)
|
|
40
40
|
return !1;
|
|
41
|
-
const { unitId: t, payload: i, segmentId: r, linkId: o } = e, s = n.get(O), c = n.get(x), u = n.get(
|
|
41
|
+
const { unitId: t, payload: i, segmentId: r, linkId: o } = e, s = n.get(O), c = n.get(x), u = n.get(b).getActiveTextRange(), h = c.getUnit(t, I.UNIVER_DOC);
|
|
42
42
|
if (!u || !h)
|
|
43
43
|
return !1;
|
|
44
44
|
const f = (p = ye(h.getSelfOrHeaderFooterModel(r).getBody(), u.startOffset, u.endOffset).textRuns) == null ? void 0 : p[0];
|
|
@@ -67,25 +67,25 @@ const Rn = "docs-hyper-link-ui.config", Se = {}, xe = {
|
|
|
67
67
|
});
|
|
68
68
|
return d ? s.syncExecuteCommand(d.id, d.params) : !1;
|
|
69
69
|
}
|
|
70
|
-
},
|
|
71
|
-
docsLinkEdit:
|
|
70
|
+
}, Rn = "univer-docs-link-edit", Mn = "univer-docs-link-edit-title", bn = "univer-docs-link-edit-close", wn = "univer-docs-link-edit-buttons", Dn = "univer-docs-link-edit-button", K = {
|
|
71
|
+
docsLinkEdit: Rn,
|
|
72
72
|
docsLinkEditTitle: Mn,
|
|
73
|
-
docsLinkEditClose:
|
|
74
|
-
docsLinkEditButtons:
|
|
75
|
-
docsLinkEditButton:
|
|
73
|
+
docsLinkEditClose: bn,
|
|
74
|
+
docsLinkEditButtons: wn,
|
|
75
|
+
docsLinkEditButton: Dn
|
|
76
76
|
};
|
|
77
|
-
function
|
|
77
|
+
function Nn(n) {
|
|
78
78
|
return /^[a-zA-Z]+:\/\//.test(n);
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function Un(n) {
|
|
81
81
|
return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(n);
|
|
82
82
|
}
|
|
83
83
|
function Tn(n) {
|
|
84
|
-
return
|
|
84
|
+
return Nn(n) ? n : Un(n) ? `mailto://${n}` : `https://${n}`;
|
|
85
85
|
}
|
|
86
86
|
const V = () => {
|
|
87
|
-
const n = S(L), e = S(Oe), t =
|
|
88
|
-
|
|
87
|
+
const n = S(L), e = S(Oe), t = xe(n.editingLink$), i = S(O), r = S(x), o = S(b), [s, c] = q(""), [l, u] = q(""), [h, m] = q(!1), f = Fe.isLegalUrl(s), d = t ? r.getUnit(t.unitId, I.UNIVER_DOC) : r.getCurrentUnitForType(I.UNIVER_DOC);
|
|
88
|
+
xn(() => {
|
|
89
89
|
var ce, de, ae, le, ue, pe, fe, ge, he;
|
|
90
90
|
const a = o.getActiveTextRange();
|
|
91
91
|
if (!a)
|
|
@@ -105,14 +105,14 @@ const V = () => {
|
|
|
105
105
|
return;
|
|
106
106
|
const a = Tn(s);
|
|
107
107
|
if (!t)
|
|
108
|
-
i.executeCommand(
|
|
108
|
+
i.executeCommand(Pe.id, {
|
|
109
109
|
unitId: d.getUnitId(),
|
|
110
110
|
payload: a
|
|
111
111
|
});
|
|
112
112
|
else {
|
|
113
113
|
if (!l)
|
|
114
114
|
return;
|
|
115
|
-
i.executeCommand(
|
|
115
|
+
i.executeCommand(Ee.id, {
|
|
116
116
|
unitId: d.getUnitId(),
|
|
117
117
|
payload: a,
|
|
118
118
|
linkId: t.linkId,
|
|
@@ -193,23 +193,23 @@ var v = function() {
|
|
|
193
193
|
}
|
|
194
194
|
return n;
|
|
195
195
|
}, v.apply(this, arguments);
|
|
196
|
-
},
|
|
196
|
+
}, $n = function(n, e) {
|
|
197
197
|
var t = {};
|
|
198
198
|
for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && e.indexOf(i) < 0 && (t[i] = n[i]);
|
|
199
199
|
if (n != null && typeof Object.getOwnPropertySymbols == "function")
|
|
200
200
|
for (var r = 0, i = Object.getOwnPropertySymbols(n); r < i.length; r++)
|
|
201
201
|
e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(n, i[r]) && (t[i[r]] = n[i[r]]);
|
|
202
202
|
return t;
|
|
203
|
-
},
|
|
204
|
-
var t = n.icon, i = n.id, r = n.className, o = n.extend, s =
|
|
205
|
-
return
|
|
203
|
+
}, $ = U(function(n, e) {
|
|
204
|
+
var t = n.icon, i = n.id, r = n.className, o = n.extend, s = $n(n, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), l = Pn("_".concat(An()));
|
|
205
|
+
return Re(t, "".concat(i), { defIds: t.defIds, idSuffix: l.current }, v({ ref: e, className: c }, s), o);
|
|
206
206
|
});
|
|
207
|
-
function
|
|
208
|
-
return
|
|
209
|
-
return
|
|
207
|
+
function Re(n, e, t, i, r) {
|
|
208
|
+
return T(n.tag, v(v({ key: e }, Hn(n, t, r)), i), (jn(n, t).children || []).map(function(o, s) {
|
|
209
|
+
return Re(o, "".concat(e, "-").concat(n.tag, "-").concat(s), t, void 0, r);
|
|
210
210
|
}));
|
|
211
211
|
}
|
|
212
|
-
function
|
|
212
|
+
function Hn(n, e, t) {
|
|
213
213
|
var i = v({}, n.attrs);
|
|
214
214
|
t != null && t.colorChannel1 && i.fill === "colorChannel1" && (i.fill = t.colorChannel1);
|
|
215
215
|
var r = e.defIds;
|
|
@@ -218,63 +218,63 @@ function jn(n, e, t) {
|
|
|
218
218
|
typeof c == "string" && (i[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
219
219
|
})), i;
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function jn(n, e) {
|
|
222
222
|
var t, i = e.defIds;
|
|
223
223
|
return !i || i.length === 0 ? n : n.tag === "defs" && (!((t = n.children) === null || t === void 0) && t.length) ? v(v({}, n), { children: n.children.map(function(r) {
|
|
224
224
|
return typeof r.attrs.id == "string" && i && i.indexOf(r.attrs.id) > -1 ? v(v({}, r), { attrs: v(v({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
|
|
225
225
|
}) }) : n;
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function An() {
|
|
228
228
|
return Math.random().toString(36).substring(2, 8);
|
|
229
229
|
}
|
|
230
|
-
|
|
231
|
-
var
|
|
232
|
-
return
|
|
230
|
+
$.displayName = "UniverIcon";
|
|
231
|
+
var Bn = { 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 = U(function(n, e) {
|
|
232
|
+
return T($, Object.assign({}, n, {
|
|
233
233
|
id: "copy-single",
|
|
234
234
|
ref: e,
|
|
235
|
-
icon:
|
|
235
|
+
icon: Bn
|
|
236
236
|
}));
|
|
237
237
|
});
|
|
238
|
-
|
|
239
|
-
var
|
|
240
|
-
return
|
|
238
|
+
Me.displayName = "CopySingle";
|
|
239
|
+
var Kn = { 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" } }] }, oe = U(function(n, e) {
|
|
240
|
+
return T($, Object.assign({}, n, {
|
|
241
241
|
id: "link-single",
|
|
242
242
|
ref: e,
|
|
243
|
-
icon:
|
|
243
|
+
icon: Kn
|
|
244
244
|
}));
|
|
245
245
|
});
|
|
246
246
|
oe.displayName = "LinkSingle";
|
|
247
|
-
var
|
|
248
|
-
return
|
|
247
|
+
var Fn = { 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" } }] }, be = U(function(n, e) {
|
|
248
|
+
return T($, Object.assign({}, n, {
|
|
249
249
|
id: "unlink-single",
|
|
250
250
|
ref: e,
|
|
251
|
-
icon:
|
|
251
|
+
icon: Fn
|
|
252
252
|
}));
|
|
253
253
|
});
|
|
254
254
|
be.displayName = "UnlinkSingle";
|
|
255
|
-
var
|
|
256
|
-
return
|
|
255
|
+
var Vn = { 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" } }] }, we = U(function(n, e) {
|
|
256
|
+
return T($, Object.assign({}, n, {
|
|
257
257
|
id: "write-single",
|
|
258
258
|
ref: e,
|
|
259
|
-
icon:
|
|
259
|
+
icon: Vn
|
|
260
260
|
}));
|
|
261
261
|
});
|
|
262
|
-
|
|
263
|
-
function
|
|
262
|
+
we.displayName = "WriteSingle";
|
|
263
|
+
function De(n) {
|
|
264
264
|
var e, t, i = "";
|
|
265
265
|
if (typeof n == "string" || typeof n == "number") i += n;
|
|
266
266
|
else if (typeof n == "object") if (Array.isArray(n)) {
|
|
267
267
|
var r = n.length;
|
|
268
|
-
for (e = 0; e < r; e++) n[e] && (t =
|
|
268
|
+
for (e = 0; e < r; e++) n[e] && (t = De(n[e])) && (i && (i += " "), i += t);
|
|
269
269
|
} else for (t in n) n[t] && (i && (i += " "), i += t);
|
|
270
270
|
return i;
|
|
271
271
|
}
|
|
272
272
|
function Le() {
|
|
273
|
-
for (var n, e, t = 0, i = "", r = arguments.length; t < r; t++) (n = arguments[t]) && (e =
|
|
273
|
+
for (var n, e, t = 0, i = "", r = arguments.length; t < r; t++) (n = arguments[t]) && (e = De(n)) && (i && (i += " "), i += e);
|
|
274
274
|
return i;
|
|
275
275
|
}
|
|
276
|
-
const
|
|
277
|
-
type:
|
|
276
|
+
const Ne = {
|
|
277
|
+
type: M.COMMAND,
|
|
278
278
|
id: "docs.command.delete-hyper-link",
|
|
279
279
|
async handler(n, e) {
|
|
280
280
|
if (!e)
|
|
@@ -282,32 +282,32 @@ const De = {
|
|
|
282
282
|
const { unitId: t, linkId: i, segmentId: r } = e, o = n.get(O), s = nn(n, { unitId: t, rangeId: i, segmentId: r });
|
|
283
283
|
return s ? await o.syncExecuteCommand(s.id, s.params) : !1;
|
|
284
284
|
}
|
|
285
|
-
},
|
|
286
|
-
const e = n.get(
|
|
285
|
+
}, Ue = (n) => {
|
|
286
|
+
const e = n.get(b), t = n.get(x), i = e.getTextRanges();
|
|
287
287
|
if (!(i != null && i.length))
|
|
288
288
|
return !0;
|
|
289
289
|
const r = i[0];
|
|
290
290
|
return !!(!t.getCurrentUnitForType(I.UNIVER_DOC) || !r || r.collapsed);
|
|
291
291
|
}, R = {
|
|
292
|
-
type:
|
|
292
|
+
type: M.OPERATION,
|
|
293
293
|
id: "doc.operation.show-hyper-link-edit-popup",
|
|
294
294
|
handler(n, e) {
|
|
295
295
|
var s;
|
|
296
296
|
const t = e == null ? void 0 : e.link, i = n.get(x);
|
|
297
|
-
if (
|
|
297
|
+
if (Ue(n) && !t)
|
|
298
298
|
return !1;
|
|
299
299
|
const r = n.get(L), o = (t == null ? void 0 : t.unitId) || ((s = i.getCurrentUnitForType(I.UNIVER_DOC)) == null ? void 0 : s.getUnitId());
|
|
300
300
|
return o ? (r.showEditPopup(o, t), !0) : !1;
|
|
301
301
|
}
|
|
302
302
|
}, te = {
|
|
303
|
-
type:
|
|
303
|
+
type: M.OPERATION,
|
|
304
304
|
id: "doc.operation.toggle-hyper-link-info-popup",
|
|
305
305
|
handler(n, e) {
|
|
306
306
|
const t = n.get(L);
|
|
307
307
|
return e ? (t.showInfoPopup(e), !0) : (t.hideInfoPopup(), !0);
|
|
308
308
|
}
|
|
309
|
-
},
|
|
310
|
-
type:
|
|
309
|
+
}, Te = {
|
|
310
|
+
type: M.OPERATION,
|
|
311
311
|
id: "doc.operation.click-hyper-link",
|
|
312
312
|
handler(n, e) {
|
|
313
313
|
var u, h, m;
|
|
@@ -316,18 +316,18 @@ const De = {
|
|
|
316
316
|
const { unitId: t, linkId: i, segmentId: r } = e, s = n.get(x).getUnit(t, I.UNIVER_DOC), c = s == null ? void 0 : s.getSelfOrHeaderFooterModel(r).getBody(), l = (m = (h = (u = c == null ? void 0 : c.customRanges) == null ? void 0 : u.find((f) => f.rangeId === i && f.rangeType === D.HYPERLINK)) == null ? void 0 : h.properties) == null ? void 0 : m.url;
|
|
317
317
|
return l && window.open(l, "_blank", "noopener noreferrer"), !0;
|
|
318
318
|
}
|
|
319
|
-
},
|
|
320
|
-
docLink:
|
|
321
|
-
docLinkType:
|
|
322
|
-
docLinkContent:
|
|
323
|
-
docLinkContentError:
|
|
324
|
-
docLinkUrl:
|
|
325
|
-
docLinkOperations:
|
|
326
|
-
docLinkOperation:
|
|
327
|
-
docLinkOperationError:
|
|
319
|
+
}, Yn = "univer-doc-link", Zn = "univer-doc-link-type", Wn = "univer-doc-link-content", Gn = "univer-doc-link-content-error", zn = "univer-doc-link-url", qn = "univer-doc-link-operations", Jn = "univer-doc-link-operation", Qn = "univer-doc-link-operation-error", y = {
|
|
320
|
+
docLink: Yn,
|
|
321
|
+
docLinkType: Zn,
|
|
322
|
+
docLinkContent: Wn,
|
|
323
|
+
docLinkContentError: Gn,
|
|
324
|
+
docLinkUrl: zn,
|
|
325
|
+
docLinkOperations: qn,
|
|
326
|
+
docLinkOperation: Jn,
|
|
327
|
+
docLinkOperationError: Qn
|
|
328
328
|
}, Y = () => {
|
|
329
329
|
var C, a;
|
|
330
|
-
const n = S(L), e = S(O), t = S(mn), i = S(Oe), r =
|
|
330
|
+
const n = S(L), e = S(O), t = S(mn), i = S(Oe), r = xe(n.showingLink$), o = S(x);
|
|
331
331
|
if (!r)
|
|
332
332
|
return null;
|
|
333
333
|
const { unitId: s, linkId: c, segmentId: l, startIndex: u, endIndex: h } = r, m = o.getUnit(s, I.UNIVER_DOC), f = m == null ? void 0 : m.getSelfOrHeaderFooterModel(l).getBody(), d = (C = f == null ? void 0 : f.customRanges) == null ? void 0 : C.find((k) => k.rangeId === c && k.rangeType === D.HYPERLINK && k.startIndex === u && k.endIndex === h);
|
|
@@ -357,7 +357,7 @@ const De = {
|
|
|
357
357
|
type: hn.Info
|
|
358
358
|
});
|
|
359
359
|
},
|
|
360
|
-
children: /* @__PURE__ */ g(B, { placement: "bottom", title: i.t("docLink.info.copy"), children: /* @__PURE__ */ g(
|
|
360
|
+
children: /* @__PURE__ */ g(B, { placement: "bottom", title: i.t("docLink.info.copy"), children: /* @__PURE__ */ g(Me, {}) })
|
|
361
361
|
}
|
|
362
362
|
),
|
|
363
363
|
/* @__PURE__ */ g(
|
|
@@ -369,7 +369,7 @@ const De = {
|
|
|
369
369
|
link: r
|
|
370
370
|
});
|
|
371
371
|
},
|
|
372
|
-
children: /* @__PURE__ */ g(B, { placement: "bottom", title: i.t("docLink.info.edit"), children: /* @__PURE__ */ g(
|
|
372
|
+
children: /* @__PURE__ */ g(B, { placement: "bottom", title: i.t("docLink.info.edit"), children: /* @__PURE__ */ g(we, {}) })
|
|
373
373
|
}
|
|
374
374
|
),
|
|
375
375
|
/* @__PURE__ */ g(
|
|
@@ -377,7 +377,7 @@ const De = {
|
|
|
377
377
|
{
|
|
378
378
|
className: y.docLinkOperation,
|
|
379
379
|
onClick: () => {
|
|
380
|
-
e.executeCommand(
|
|
380
|
+
e.executeCommand(Ne.id, {
|
|
381
381
|
unitId: s,
|
|
382
382
|
linkId: d.rangeId,
|
|
383
383
|
segmentId: l
|
|
@@ -392,10 +392,10 @@ const De = {
|
|
|
392
392
|
);
|
|
393
393
|
};
|
|
394
394
|
Y.componentKey = "univer.doc.link-info-popup";
|
|
395
|
-
var
|
|
396
|
-
for (var r = i > 1 ? void 0 : i ?
|
|
395
|
+
var Xn = Object.defineProperty, et = Object.getOwnPropertyDescriptor, nt = (n, e, t, i) => {
|
|
396
|
+
for (var r = i > 1 ? void 0 : i ? et(e, t) : e, o = n.length - 1, s; o >= 0; o--)
|
|
397
397
|
(s = n[o]) && (r = (i ? s(e, t, r) : s(r)) || r);
|
|
398
|
-
return i && r &&
|
|
398
|
+
return i && r && Xn(e, t, r), r;
|
|
399
399
|
}, J = (n, e) => (t, i) => e(t, i, n);
|
|
400
400
|
let L = class extends N {
|
|
401
401
|
constructor(e, t, i) {
|
|
@@ -474,15 +474,15 @@ let L = class extends N {
|
|
|
474
474
|
this._showingLink$.next(null), (e = this._infoPopup) == null || e.dispose();
|
|
475
475
|
}
|
|
476
476
|
};
|
|
477
|
-
L =
|
|
477
|
+
L = nt([
|
|
478
478
|
J(0, _(cn)),
|
|
479
|
-
J(1, _(
|
|
479
|
+
J(1, _(b)),
|
|
480
480
|
J(2, x)
|
|
481
481
|
], L);
|
|
482
|
-
var
|
|
483
|
-
for (var r = i > 1 ? void 0 : i ?
|
|
482
|
+
var tt = Object.defineProperty, it = Object.getOwnPropertyDescriptor, rt = (n, e, t, i) => {
|
|
483
|
+
for (var r = i > 1 ? void 0 : i ? it(e, t) : e, o = n.length - 1, s; o >= 0; o--)
|
|
484
484
|
(s = n[o]) && (r = (i ? s(e, t, r) : s(r)) || r);
|
|
485
|
-
return i && r &&
|
|
485
|
+
return i && r && tt(e, t, r), r;
|
|
486
486
|
}, Q = (n, e) => (t, i) => e(t, i, n);
|
|
487
487
|
let Z = class extends N {
|
|
488
488
|
constructor(n, e, t) {
|
|
@@ -512,15 +512,15 @@ let Z = class extends N {
|
|
|
512
512
|
);
|
|
513
513
|
}
|
|
514
514
|
};
|
|
515
|
-
Z =
|
|
515
|
+
Z = rt([
|
|
516
516
|
Q(0, O),
|
|
517
517
|
Q(1, x),
|
|
518
518
|
Q(2, _(L))
|
|
519
519
|
], Z);
|
|
520
|
-
var
|
|
521
|
-
for (var r = i > 1 ? void 0 : i ?
|
|
520
|
+
var ot = Object.defineProperty, st = Object.getOwnPropertyDescriptor, ct = (n, e, t, i) => {
|
|
521
|
+
for (var r = i > 1 ? void 0 : i ? st(e, t) : e, o = n.length - 1, s; o >= 0; o--)
|
|
522
522
|
(s = n[o]) && (r = (i ? s(e, t, r) : s(r)) || r);
|
|
523
|
-
return i && r &&
|
|
523
|
+
return i && r && ot(e, t, r), r;
|
|
524
524
|
}, w = (n, e) => (t, i) => e(t, i, n);
|
|
525
525
|
let ie = class extends N {
|
|
526
526
|
constructor(n, e, t, i, r, o) {
|
|
@@ -563,7 +563,7 @@ let ie = class extends N {
|
|
|
563
563
|
this._docEventManagerService.clickCustomRanges$.subscribe((n) => {
|
|
564
564
|
const e = n.range;
|
|
565
565
|
e && this._commandService.executeCommand(
|
|
566
|
-
|
|
566
|
+
Te.id,
|
|
567
567
|
{
|
|
568
568
|
unitId: this._context.unitId,
|
|
569
569
|
linkId: e.rangeId,
|
|
@@ -574,17 +574,17 @@ let ie = class extends N {
|
|
|
574
574
|
);
|
|
575
575
|
}
|
|
576
576
|
};
|
|
577
|
-
ie =
|
|
577
|
+
ie = ct([
|
|
578
578
|
w(1, _(dn)),
|
|
579
579
|
w(2, O),
|
|
580
580
|
w(3, _(L)),
|
|
581
581
|
w(4, _(rn)),
|
|
582
|
-
w(5, _(
|
|
582
|
+
w(5, _(b))
|
|
583
583
|
], ie);
|
|
584
|
-
var
|
|
585
|
-
for (var r = i > 1 ? void 0 : i ?
|
|
584
|
+
var dt = Object.defineProperty, at = Object.getOwnPropertyDescriptor, lt = (n, e, t, i) => {
|
|
585
|
+
for (var r = i > 1 ? void 0 : i ? at(e, t) : e, o = n.length - 1, s; o >= 0; o--)
|
|
586
586
|
(s = n[o]) && (r = (i ? s(e, t, r) : s(r)) || r);
|
|
587
|
-
return i && r &&
|
|
587
|
+
return i && r && dt(e, t, r), r;
|
|
588
588
|
}, X = (n, e) => (t, i) => e(t, i, n);
|
|
589
589
|
let re = class extends N {
|
|
590
590
|
constructor(n, e, t, i) {
|
|
@@ -618,7 +618,7 @@ let re = class extends N {
|
|
|
618
618
|
}));
|
|
619
619
|
}
|
|
620
620
|
};
|
|
621
|
-
re =
|
|
621
|
+
re = lt([
|
|
622
622
|
X(1, _(on)),
|
|
623
623
|
X(2, _(L)),
|
|
624
624
|
X(3, _(an))
|
|
@@ -627,14 +627,14 @@ const $e = "doc-hyper-link-icon";
|
|
|
627
627
|
function ke(n) {
|
|
628
628
|
return {
|
|
629
629
|
id: R.id,
|
|
630
|
-
type:
|
|
630
|
+
type: _n.BUTTON,
|
|
631
631
|
icon: $e,
|
|
632
632
|
title: "docLink.menu.tooltip",
|
|
633
633
|
tooltip: "docLink.menu.tooltip",
|
|
634
|
-
hidden$:
|
|
634
|
+
hidden$: In(n, I.UNIVER_DOC),
|
|
635
635
|
disabled$: new fn(function(e) {
|
|
636
|
-
const i = n.get(
|
|
637
|
-
e.next(
|
|
636
|
+
const i = n.get(b).textSelection$.pipe(gn(16)).subscribe(() => {
|
|
637
|
+
e.next(Ue(n));
|
|
638
638
|
});
|
|
639
639
|
return () => {
|
|
640
640
|
i.unsubscribe();
|
|
@@ -642,20 +642,20 @@ function ke(n) {
|
|
|
642
642
|
})
|
|
643
643
|
};
|
|
644
644
|
}
|
|
645
|
-
const
|
|
645
|
+
const ut = {
|
|
646
646
|
id: R.id,
|
|
647
|
-
binding:
|
|
647
|
+
binding: vn.CTRL_COMMAND | ne.K,
|
|
648
648
|
description: "docLink.menu.tooltip",
|
|
649
649
|
preconditions: ln
|
|
650
|
-
},
|
|
651
|
-
[
|
|
650
|
+
}, pt = {
|
|
651
|
+
[Cn.OTHERS]: {
|
|
652
652
|
[R.id]: {
|
|
653
653
|
order: 0,
|
|
654
654
|
menuItemFactory: ke
|
|
655
655
|
}
|
|
656
656
|
},
|
|
657
|
-
[
|
|
658
|
-
[
|
|
657
|
+
[Sn.MAIN_AREA]: {
|
|
658
|
+
[Ln.DATA]: {
|
|
659
659
|
[R.id]: {
|
|
660
660
|
order: 0,
|
|
661
661
|
menuItemFactory: ke
|
|
@@ -663,10 +663,10 @@ const pt = {
|
|
|
663
663
|
}
|
|
664
664
|
}
|
|
665
665
|
};
|
|
666
|
-
var
|
|
667
|
-
for (var r = i > 1 ? void 0 : i ?
|
|
666
|
+
var ft = Object.defineProperty, gt = Object.getOwnPropertyDescriptor, ht = (n, e, t, i) => {
|
|
667
|
+
for (var r = i > 1 ? void 0 : i ? gt(e, t) : e, o = n.length - 1, s; o >= 0; o--)
|
|
668
668
|
(s = n[o]) && (r = (i ? s(e, t, r) : s(r)) || r);
|
|
669
|
-
return i && r &&
|
|
669
|
+
return i && r && ft(e, t, r), r;
|
|
670
670
|
}, F = (n, e) => (t, i) => e(t, i, n);
|
|
671
671
|
let W = class extends N {
|
|
672
672
|
constructor(n, e, t, i) {
|
|
@@ -683,37 +683,37 @@ let W = class extends N {
|
|
|
683
683
|
}
|
|
684
684
|
_initCommands() {
|
|
685
685
|
[
|
|
686
|
-
xe,
|
|
687
686
|
Pe,
|
|
688
|
-
|
|
687
|
+
Ee,
|
|
688
|
+
Ne,
|
|
689
689
|
R,
|
|
690
690
|
te,
|
|
691
|
-
|
|
691
|
+
Te
|
|
692
692
|
].forEach((n) => {
|
|
693
693
|
this._commandService.registerCommand(n);
|
|
694
694
|
});
|
|
695
695
|
}
|
|
696
696
|
_initShortcut() {
|
|
697
|
-
[
|
|
697
|
+
[ut].forEach((n) => {
|
|
698
698
|
this._shortcutService.registerShortcut(n);
|
|
699
699
|
});
|
|
700
700
|
}
|
|
701
701
|
_initMenus() {
|
|
702
|
-
this._menuManagerService.mergeMenu(
|
|
702
|
+
this._menuManagerService.mergeMenu(pt);
|
|
703
703
|
}
|
|
704
704
|
};
|
|
705
|
-
W =
|
|
706
|
-
F(0, _(
|
|
705
|
+
W = ht([
|
|
706
|
+
F(0, _(kn)),
|
|
707
707
|
F(1, O),
|
|
708
|
-
F(2,
|
|
709
|
-
F(3,
|
|
708
|
+
F(2, yn),
|
|
709
|
+
F(3, On)
|
|
710
710
|
], W);
|
|
711
|
-
const
|
|
712
|
-
var
|
|
713
|
-
for (var r = i > 1 ? void 0 : i ?
|
|
711
|
+
const mt = "DOC_HYPER_LINK_UI_PLUGIN";
|
|
712
|
+
var He = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, _t = (n, e, t) => e in n ? He(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, It = (n, e, t, i) => {
|
|
713
|
+
for (var r = i > 1 ? void 0 : i ? vt(e, t) : e, o = n.length - 1, s; o >= 0; o--)
|
|
714
714
|
(s = n[o]) && (r = (i ? s(e, t, r) : s(r)) || r);
|
|
715
|
-
return i && r &&
|
|
716
|
-
}, ee = (n, e) => (t, i) => e(t, i, n),
|
|
715
|
+
return i && r && He(e, t, r), r;
|
|
716
|
+
}, ee = (n, e) => (t, i) => e(t, i, n), je = (n, e, t) => _t(n, typeof e != "symbol" ? e + "" : e, t);
|
|
717
717
|
let G = class extends Ge {
|
|
718
718
|
constructor(n = Se, e, t, i) {
|
|
719
719
|
super(), this._config = n, this._injector = e, this._renderManagerSrv = t, this._configService = i;
|
|
@@ -722,7 +722,7 @@ let G = class extends Ge {
|
|
|
722
722
|
Se,
|
|
723
723
|
this._config
|
|
724
724
|
);
|
|
725
|
-
r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(
|
|
725
|
+
r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(En, o);
|
|
726
726
|
}
|
|
727
727
|
onStarting() {
|
|
728
728
|
[
|
|
@@ -748,9 +748,9 @@ let G = class extends Ge {
|
|
|
748
748
|
});
|
|
749
749
|
}
|
|
750
750
|
};
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
G =
|
|
751
|
+
je(G, "pluginName", mt);
|
|
752
|
+
je(G, "type", I.UNIVER_DOC);
|
|
753
|
+
G = It([
|
|
754
754
|
Ze(Je),
|
|
755
755
|
ee(1, _(We)),
|
|
756
756
|
ee(2, Qe),
|
package/lib/types/index.d.ts
CHANGED
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(a,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/docs-hyper-link"),require("@univerjs/engine-render"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("@univerjs/ui"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-hyper-link","@univerjs/engine-render","@univerjs/docs","@univerjs/docs-ui","rxjs","react/jsx-runtime","@univerjs/design","@univerjs/ui","react"],o):(a=typeof globalThis<"u"?globalThis:a||self,o(a.UniverDocsHyperLinkUi={},a.UniverCore,a.UniverDocsHyperLink,a.UniverEngineRender,a.UniverDocs,a.UniverDocsUi,a.rxjs,a.React,a.UniverDesign,a.UniverUi,a.React))})(this,function(a,o,D,Oe,y,w,U,u,L,C,m){"use strict";var sn=Object.defineProperty;var cn=(a,o,D)=>o in a?sn(a,o,{enumerable:!0,configurable:!0,writable:!0,value:D}):a[o]=D;var x=(a,o,D)=>cn(a,typeof o!="symbol"?o+"":o,D);const Pe="docs-hyper-link-ui.config",X={},ee={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}},ne={id:"docs.command.update-hyper-link",type:o.CommandType.COMMAND,handler(n,e){var v;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(y.DocSelectionManagerService).getActiveTextRange(),I=d.getUnit(t,o.UniverInstanceType.UNIVER_DOC);if(!g||!I)return!1;const h=(v=o.getBodySlice(I.getSelfOrHeaderFooterModel(r).getBody(),g.startOffset,g.endOffset).textRuns)==null?void 0:v[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:g.startOffset,endOffset:g.endOffset,collapsed:!1,segmentId:r}});return l?c.syncExecuteCommand(l.id,l.params):!1}},R={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 Ee(n){return/^[a-zA-Z]+:\/\//.test(n)}function xe(n){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(n)}function De(n){return Ee(n)?n:xe(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]=m.useState(""),[f,g]=m.useState(""),[I,_]=m.useState(!1),h=o.Tools.isLegalUrl(c),l=t?r.getUnit(t.unitId,o.UniverInstanceType.UNIVER_DOC):r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);m.useEffect(()=>{var he,Ie,me,_e,Ce,ye,Se,Le,ke;const p=s.getActiveTextRange();if(!p)return;if(t){const A=(he=l==null?void 0:l.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:he.getBody(),F=(Ie=A==null?void 0:A.customRanges)==null?void 0:Ie.find(Q=>(t==null?void 0:t.linkId)===Q.rangeId&&Q.startIndex===t.startIndex&&Q.endIndex===t.endIndex);l&&F&&(d((_e=(me=F.properties)==null?void 0:me.url)!=null?_e:""),g(o.BuildTextUtils.transform.getPlainText(o.getBodySlice(A,F.startIndex,F.endIndex+1).dataStream)));return}const P=(Ce=l==null?void 0:l.getSelfOrHeaderFooterModel(p.segmentId))==null?void 0:Ce.getBody(),ve=P?p:null,K=ve&&((Se=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(ve,(ye=P==null?void 0:P.customRanges)!=null?ye:[]))==null?void 0:Se[0]);l&&K&&d((ke=(Le=K==null?void 0:K.properties)==null?void 0:Le.url)!=null?ke:"")},[l,t,s,r]);const v=()=>{n.hideEditPopup()},O=()=>{if(_(!0),!h||!l)return;const p=De(c);if(!t)i.executeCommand(ee.id,{unitId:l.getUnitId(),payload:p});else{if(!f)return;i.executeCommand(ne.id,{unitId:l.getUnitId(),payload:p,linkId:t.linkId,label:f,segmentId:t.segmentId})}n.hideEditPopup()};if(l)return u.jsxs("div",{className:R.docsLinkEdit,children:[u.jsxs("div",{children:[t?u.jsx(L.FormLayout,{label:e.t("docLink.edit.label"),error:I&&!f?e.t("docLink.edit.labelError"):"",children:u.jsx(L.Input,{value:f,onChange:g,autoFocus:!0,onKeyDown:p=>{p.keyCode===C.KeyCode.ENTER&&O()}})}):null,u.jsx(L.FormLayout,{label:e.t("docLink.edit.address"),error:I&&!h?e.t("docLink.edit.addressError"):"",children:u.jsx(L.Input,{value:c,onChange:d,autoFocus:!0,onKeyDown:p=>{p.keyCode===C.KeyCode.ENTER&&O()}})})]}),u.jsxs("div",{className:R.docsLinkEditButtons,children:[u.jsx(L.Button,{className:R.docsLinkEditButton,onClick:v,children:e.t("docLink.edit.cancel")}),u.jsx(L.Button,{disabled:!c,className:R.docsLinkEditButton,type:"primary",onClick:O,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)},Ue=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},T=m.forwardRef(function(n,e){var t=n.icon,i=n.id,r=n.className,s=n.extend,c=Ue(n,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),f=m.useRef("_".concat(be()));return te(t,"".concat(i),{defIds:t.defIds,idSuffix:f.current},S({ref:e,className:d},c),s)});function te(n,e,t,i,r){return m.createElement(n.tag,S(S({key:e},Me(n,t,r)),i),(Te(n,t).children||[]).map(function(s,c){return te(s,"".concat(e,"-").concat(n.tag,"-").concat(c),t,void 0,r)}))}function Me(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 Te(n,e){var t,i=e.defIds;return!i||i.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?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)}T.displayName="UniverIcon";var we={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=m.forwardRef(function(n,e){return m.createElement(T,Object.assign({},n,{id:"copy-single",ref:e,icon:we}))});ie.displayName="CopySingle";var Re={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},V=m.forwardRef(function(n,e){return m.createElement(T,Object.assign({},n,{id:"link-single",ref:e,icon:Re}))});V.displayName="LinkSingle";var Ne={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},re=m.forwardRef(function(n,e){return m.createElement(T,Object.assign({},n,{id:"unlink-single",ref:e,icon:Ne}))});re.displayName="UnlinkSingle";var je={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},oe=m.forwardRef(function(n,e){return m.createElement(T,Object.assign({},n,{id:"write-single",ref:e,icon:je}))});oe.displayName="WriteSingle";function se(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=se(n[e]))&&(i&&(i+=" "),i+=t)}else for(t in n)n[t]&&(i&&(i+=" "),i+=t);return i}function ce(){for(var n,e,t=0,i="",r=arguments.length;t<r;t++)(n=arguments[t])&&(e=se(n))&&(i&&(i+=" "),i+=e);return i}const de={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}},ae=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)},M={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(ae(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}},Y={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,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(),f=(_=(I=(g=d==null?void 0:d.customRanges)==null?void 0:g.find(h=>h.rangeId===i&&h.rangeType===o.CustomRangeType.HYPERLINK))==null?void 0:I.properties)==null?void 0:_.url;return f&&window.open(f,"_blank","noopener noreferrer"),!0}},E={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"},j=()=>{var O,p;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:f,startIndex:g,endIndex:I}=r,_=s.getUnit(c,o.UniverInstanceType.UNIVER_DOC),h=_==null?void 0:_.getSelfOrHeaderFooterModel(f).getBody(),l=(O=h==null?void 0:h.customRanges)==null?void 0:O.find(P=>P.rangeId===d&&P.rangeType===o.CustomRangeType.HYPERLINK&&P.startIndex===g&&P.endIndex===I);if(!l)return null;const v=(p=l.properties)==null?void 0:p.url;return u.jsxs("div",{className:E.docLink,onClick:()=>{n.hideInfoPopup()},children:[u.jsxs("div",{className:ce(E.docLinkContent),onClick:()=>window.open(v),children:[u.jsx("div",{className:E.docLinkType,children:u.jsx(V,{})}),u.jsx(L.Tooltip,{showIfEllipsis:!0,title:v,children:u.jsx("span",{className:E.docLinkUrl,children:v})})]}),u.jsxs("div",{className:E.docLinkOperations,children:[u.jsx("div",{className:ce(E.docLinkOperation),onClick:()=>{navigator.clipboard.writeText(v),t.show({content:i.t("docLink.info.coped"),type:L.MessageType.Info})},children:u.jsx(L.Tooltip,{placement:"bottom",title:i.t("docLink.info.copy"),children:u.jsx(ie,{})})}),u.jsx("div",{className:E.docLinkOperation,onClick:()=>{e.executeCommand(M.id,{link:r})},children:u.jsx(L.Tooltip,{placement:"bottom",title:i.t("docLink.info.edit"),children:u.jsx(oe,{})})}),u.jsx("div",{className:E.docLinkOperation,onClick:()=>{e.executeCommand(de.id,{unitId:c,linkId:l.rangeId,segmentId:f})},children:u.jsx(L.Tooltip,{placement:"bottom",title:i.t("docLink.info.cancel"),children:u.jsx(re,{})})})]})]})};j.componentKey="univer.doc.link-info-popup";var He=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Be=(n,e,t,i)=>{for(var r=i>1?void 0:i?$e(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&&He(e,t,r),r},q=(n,e)=>(t,i)=>e(t,i,n);let k=class extends o.Disposable{constructor(e,t,i){super();x(this,"_editingLink$",new U.BehaviorSubject(null));x(this,"_showingLink$",new U.BehaviorSubject(null));x(this,"editingLink$",this._editingLink$.asObservable());x(this,"showingLink$",this._showingLink$.asObservable());x(this,"_editPopup",null);x(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:f}=t;r={collapsed:!1,startOffset:d,endOffset:f+1,segmentId:s,segmentPage:c},this._textSelectionManagerService.replaceDocRanges([{startOffset:d,endOffset:f+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 g,I,_,h,l,v;const{linkId:t,unitId:i,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}=e;if(!(((g=this.showing)==null?void 0:g.linkId)===t&&((I=this.showing)==null?void 0:I.unitId)===i&&((_=this.showing)==null?void 0:_.segmentId)===r&&((h=this.showing)==null?void 0:h.segmentPage)===s&&((l=this.showing)==null?void 0:l.startIndex)===c&&((v=this.showing)==null?void 0:v.endIndex)===d||(this._infoPopup&&this._infoPopup.dispose(),!this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_DOC))))return this._showingLink$.next({unitId:i,linkId:t,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}),this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:c,endOffset:d+1,segmentId:r,segmentPage:s},{componentKey:j.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=Be([q(0,o.Inject(w.DocCanvasPopManagerService)),q(1,o.Inject(y.DocSelectionManagerService)),q(2,o.IUniverInstanceService)],k);var Ke=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Fe=(n,e,t,i)=>{for(var r=i>1?void 0:i?Ae(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},Z=(n,e)=>(t,i)=>e(t,i,n);let H=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,f=this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_DOC),g=c[0];if(g&&f){const{startOffset:I,endOffset:_,collapsed:h,segmentPage:l}=g,v=(t=(e=f.getSelfOrHeaderFooterModel(d))==null?void 0:e.getBody())==null?void 0:t.customRanges;if(h){const O=(i=v==null?void 0:v.findIndex(p=>p.startIndex<I&&p.endIndex>_-1))!=null?i:-1;if(O>-1){const p=v[O];this._docHyperLinkService.showInfoPopup({unitId:s,linkId:p.rangeId,segmentId:d,segmentPage:l,startIndex:p.startIndex,endIndex:p.endIndex});return}}else if(v==null?void 0:v.find(p=>p.startIndex<=I&&p.endIndex>=_-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};H=Fe([Z(0,o.ICommandService),Z(1,o.IUniverInstanceService),Z(2,o.Inject(k))],H);var Ve=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,qe=(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},b=(n,e)=>(t,i)=>e(t,i,n);let W=class extends o.Disposable{constructor(n,e,t,i,r,s){super(),this._context=n,this._docEventManagerService=e,this._commandService=t,this._hyperLinkPopupService=i,this._docSkeletonManagerService=r,this._docSelectionManagerService=s,!(this._context.unitId===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY||this._context.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)&&(this._initHover(),this._initClick())}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(Y.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(Y.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})}))}};W=qe([b(1,o.Inject(w.DocEventManagerService)),b(2,o.ICommandService),b(3,o.Inject(k)),b(4,o.Inject(y.DocSkeletonManagerService)),b(5,o.Inject(y.DocSelectionManagerService))],W);var Ze=Object.defineProperty,We=Object.getOwnPropertyDescriptor,Ge=(n,e,t,i)=>{for(var r=i>1?void 0:i?We(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},G=(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(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:f,endIndex:g}=s,I=d===i&&n.rangeId===c&&r>=f&&r<=g;return t({...n,active:I})}})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(U.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)),U.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=Ge([G(1,o.Inject(y.DocInterceptorService)),G(2,o.Inject(k)),G(3,o.Inject(w.DocRenderController))],z);const ue="doc-hyper-link-icon";function pe(n){return{id:M.id,type:C.MenuItemType.BUTTON,icon:ue,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:C.getMenuHiddenObservable(n,o.UniverInstanceType.UNIVER_DOC),disabled$:new U.Observable(function(e){const i=n.get(y.DocSelectionManagerService).textSelection$.pipe(U.debounceTime(16)).subscribe(()=>{e.next(ae(n))});return()=>{i.unsubscribe()}})}}const ze={id:M.id,binding:C.MetaKeys.CTRL_COMMAND|C.KeyCode.K,description:"docLink.menu.tooltip",preconditions:w.whenDocAndEditorFocused},Je={[C.RibbonStartGroup.OTHERS]:{[M.id]:{order:0,menuItemFactory:pe}},[C.ContextMenuPosition.MAIN_AREA]:{[C.ContextMenuGroup.DATA]:{[M.id]:{order:0,menuItemFactory:pe}}}};var Qe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,en=(n,e,t,i)=>{for(var r=i>1?void 0:i?Xe(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&Qe(e,t,r),r},$=(n,e)=>(t,i)=>e(t,i,n);let B=class extends o.Disposable{constructor(n,e,t,i){super(),this._componentManager=n,this._commandService=e,this._menuManagerService=t,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[N,N.componentKey],[j,j.componentKey],[V,ue]].forEach(([n,e])=>{this._componentManager.register(e,n)})}_initCommands(){[ee,ne,de,M,Y,le].forEach(n=>{this._commandService.registerCommand(n)})}_initShortcut(){[ze].forEach(n=>{this._shortcutService.registerShortcut(n)})}_initMenus(){this._menuManagerService.mergeMenu(Je)}};B=en([$(0,o.Inject(C.ComponentManager)),$(1,o.ICommandService),$(2,C.IMenuManagerService),$(3,C.IShortcutService)],B);const nn="DOC_HYPER_LINK_UI_PLUGIN";var fe=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,rn=(n,e,t)=>e in n?fe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,on=(n,e,t,i)=>{for(var r=i>1?void 0:i?tn(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&&fe(e,t,r),r},J=(n,e)=>(t,i)=>e(t,i,n),ge=(n,e,t)=>rn(n,typeof e!="symbol"?e+"":e,t);a.UniverDocsHyperLinkUIPlugin=class extends o.Plugin{constructor(e=X,t,i,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=i,this._configService=r;const{menu:s,...c}=o.merge({},X,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Pe,c)}onStarting(){[[k],[B],[H]].forEach(t=>{this._injector.add(t)}),this._injector.get(B)}onReady(){this._injector.get(H)}onRendered(){this._initRenderModule()}_initRenderModule(){[[z],[W]].forEach(e=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,e)})}},ge(a.UniverDocsHyperLinkUIPlugin,"pluginName",nn),ge(a.UniverDocsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC),a.UniverDocsHyperLinkUIPlugin=on([o.DependentOn(D.UniverDocsHyperLinkPlugin),J(1,o.Inject(o.Injector)),J(2,Oe.IRenderManagerService),J(3,o.IConfigService)],a.UniverDocsHyperLinkUIPlugin),Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(a,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/docs-hyper-link"),require("@univerjs/engine-render"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("@univerjs/ui"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-hyper-link","@univerjs/engine-render","@univerjs/docs","@univerjs/docs-ui","rxjs","react/jsx-runtime","@univerjs/design","@univerjs/ui","react"],o):(a=typeof globalThis<"u"?globalThis:a||self,o(a.UniverDocsHyperLinkUi={},a.UniverCore,a.UniverDocsHyperLink,a.UniverEngineRender,a.UniverDocs,a.UniverDocsUi,a.rxjs,a.React,a.UniverDesign,a.UniverUi,a.React))})(this,function(a,o,D,Oe,y,w,U,u,L,p,_){"use strict";var sn=Object.defineProperty;var cn=(a,o,D)=>o in a?sn(a,o,{enumerable:!0,configurable:!0,writable:!0,value:D}):a[o]=D;var x=(a,o,D)=>cn(a,typeof o!="symbol"?o+"":o,D);const Pe="docs-hyper-link-ui.config",X={},ee={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}},ne={id:"docs.command.update-hyper-link",type:o.CommandType.COMMAND,handler(n,e){var h;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(),m=d.getUnit(t,o.UniverInstanceType.UNIVER_DOC);if(!v||!m)return!1;const I=(h=o.getBodySlice(m.getSelfOrHeaderFooterModel(r).getBody(),v.startOffset,v.endOffset).textRuns)==null?void 0:h[0];I&&(I.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:I?[I]:void 0},selection:{startOffset:v.startOffset,endOffset:v.endOffset,collapsed:!1,segmentId:r}});return l?c.syncExecuteCommand(l.id,l.params):!1}},R={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 Ee(n){return/^[a-zA-Z]+:\/\//.test(n)}function xe(n){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(n)}function De(n){return Ee(n)?n:xe(n)?`mailto://${n}`:`https://${n}`}const N=()=>{const n=p.useDependency(k),e=p.useDependency(o.LocaleService),t=p.useObservable(n.editingLink$),i=p.useDependency(o.ICommandService),r=p.useDependency(o.IUniverInstanceService),s=p.useDependency(y.DocSelectionManagerService),[c,d]=_.useState(""),[g,v]=_.useState(""),[m,C]=_.useState(!1),I=o.Tools.isLegalUrl(c),l=t?r.getUnit(t.unitId,o.UniverInstanceType.UNIVER_DOC):r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);_.useEffect(()=>{var he,Ie,me,_e,Ce,ye,Se,Le,ke;const f=s.getActiveTextRange();if(!f)return;if(t){const A=(he=l==null?void 0:l.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:he.getBody(),F=(Ie=A==null?void 0:A.customRanges)==null?void 0:Ie.find(Q=>(t==null?void 0:t.linkId)===Q.rangeId&&Q.startIndex===t.startIndex&&Q.endIndex===t.endIndex);l&&F&&(d((_e=(me=F.properties)==null?void 0:me.url)!=null?_e:""),v(o.BuildTextUtils.transform.getPlainText(o.getBodySlice(A,F.startIndex,F.endIndex+1).dataStream)));return}const P=(Ce=l==null?void 0:l.getSelfOrHeaderFooterModel(f.segmentId))==null?void 0:Ce.getBody(),ve=P?f:null,K=ve&&((Se=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(ve,(ye=P==null?void 0:P.customRanges)!=null?ye:[]))==null?void 0:Se[0]);l&&K&&d((ke=(Le=K==null?void 0:K.properties)==null?void 0:Le.url)!=null?ke:"")},[l,t,s,r]);const h=()=>{n.hideEditPopup()},O=()=>{if(C(!0),!I||!l)return;const f=De(c);if(!t)i.executeCommand(ee.id,{unitId:l.getUnitId(),payload:f});else{if(!g)return;i.executeCommand(ne.id,{unitId:l.getUnitId(),payload:f,linkId:t.linkId,label:g,segmentId:t.segmentId})}n.hideEditPopup()};if(l)return u.jsxs("div",{className:R.docsLinkEdit,children:[u.jsxs("div",{children:[t?u.jsx(L.FormLayout,{label:e.t("docLink.edit.label"),error:m&&!g?e.t("docLink.edit.labelError"):"",children:u.jsx(L.Input,{value:g,onChange:v,autoFocus:!0,onKeyDown:f=>{f.keyCode===p.KeyCode.ENTER&&O()}})}):null,u.jsx(L.FormLayout,{label:e.t("docLink.edit.address"),error:m&&!I?e.t("docLink.edit.addressError"):"",children:u.jsx(L.Input,{value:c,onChange:d,autoFocus:!0,onKeyDown:f=>{f.keyCode===p.KeyCode.ENTER&&O()}})})]}),u.jsxs("div",{className:R.docsLinkEditButtons,children:[u.jsx(L.Button,{className:R.docsLinkEditButton,onClick:h,children:e.t("docLink.edit.cancel")}),u.jsx(L.Button,{disabled:!c,className:R.docsLinkEditButton,type:"primary",onClick:O,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)},Ue=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},T=_.forwardRef(function(n,e){var t=n.icon,i=n.id,r=n.className,s=n.extend,c=Ue(n,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),g=_.useRef("_".concat(be()));return te(t,"".concat(i),{defIds:t.defIds,idSuffix:g.current},S({ref:e,className:d},c),s)});function te(n,e,t,i,r){return _.createElement(n.tag,S(S({key:e},Me(n,t,r)),i),(Te(n,t).children||[]).map(function(s,c){return te(s,"".concat(e,"-").concat(n.tag,"-").concat(c),t,void 0,r)}))}function Me(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 Te(n,e){var t,i=e.defIds;return!i||i.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?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)}T.displayName="UniverIcon";var we={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=_.forwardRef(function(n,e){return _.createElement(T,Object.assign({},n,{id:"copy-single",ref:e,icon:we}))});ie.displayName="CopySingle";var Re={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},V=_.forwardRef(function(n,e){return _.createElement(T,Object.assign({},n,{id:"link-single",ref:e,icon:Re}))});V.displayName="LinkSingle";var Ne={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},re=_.forwardRef(function(n,e){return _.createElement(T,Object.assign({},n,{id:"unlink-single",ref:e,icon:Ne}))});re.displayName="UnlinkSingle";var je={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},oe=_.forwardRef(function(n,e){return _.createElement(T,Object.assign({},n,{id:"write-single",ref:e,icon:je}))});oe.displayName="WriteSingle";function se(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=se(n[e]))&&(i&&(i+=" "),i+=t)}else for(t in n)n[t]&&(i&&(i+=" "),i+=t);return i}function ce(){for(var n,e,t=0,i="",r=arguments.length;t<r;t++)(n=arguments[t])&&(e=se(n))&&(i&&(i+=" "),i+=e);return i}const de={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}},ae=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)},M={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(ae(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}},Y={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 v,m,C;if(!e)return!1;const{unitId:t,linkId:i,segmentId:r}=e,c=n.get(o.IUniverInstanceService).getUnit(t,o.UniverInstanceType.UNIVER_DOC),d=c==null?void 0:c.getSelfOrHeaderFooterModel(r).getBody(),g=(C=(m=(v=d==null?void 0:d.customRanges)==null?void 0:v.find(I=>I.rangeId===i&&I.rangeType===o.CustomRangeType.HYPERLINK))==null?void 0:m.properties)==null?void 0:C.url;return g&&window.open(g,"_blank","noopener noreferrer"),!0}},E={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"},j=()=>{var O,f;const n=p.useDependency(k),e=p.useDependency(o.ICommandService),t=p.useDependency(p.IMessageService),i=p.useDependency(o.LocaleService),r=p.useObservable(n.showingLink$),s=p.useDependency(o.IUniverInstanceService);if(!r)return null;const{unitId:c,linkId:d,segmentId:g,startIndex:v,endIndex:m}=r,C=s.getUnit(c,o.UniverInstanceType.UNIVER_DOC),I=C==null?void 0:C.getSelfOrHeaderFooterModel(g).getBody(),l=(O=I==null?void 0:I.customRanges)==null?void 0:O.find(P=>P.rangeId===d&&P.rangeType===o.CustomRangeType.HYPERLINK&&P.startIndex===v&&P.endIndex===m);if(!l)return null;const h=(f=l.properties)==null?void 0:f.url;return u.jsxs("div",{className:E.docLink,onClick:()=>{n.hideInfoPopup()},children:[u.jsxs("div",{className:ce(E.docLinkContent),onClick:()=>window.open(h),children:[u.jsx("div",{className:E.docLinkType,children:u.jsx(V,{})}),u.jsx(L.Tooltip,{showIfEllipsis:!0,title:h,children:u.jsx("span",{className:E.docLinkUrl,children:h})})]}),u.jsxs("div",{className:E.docLinkOperations,children:[u.jsx("div",{className:ce(E.docLinkOperation),onClick:()=>{navigator.clipboard.writeText(h),t.show({content:i.t("docLink.info.coped"),type:L.MessageType.Info})},children:u.jsx(L.Tooltip,{placement:"bottom",title:i.t("docLink.info.copy"),children:u.jsx(ie,{})})}),u.jsx("div",{className:E.docLinkOperation,onClick:()=>{e.executeCommand(M.id,{link:r})},children:u.jsx(L.Tooltip,{placement:"bottom",title:i.t("docLink.info.edit"),children:u.jsx(oe,{})})}),u.jsx("div",{className:E.docLinkOperation,onClick:()=>{e.executeCommand(de.id,{unitId:c,linkId:l.rangeId,segmentId:g})},children:u.jsx(L.Tooltip,{placement:"bottom",title:i.t("docLink.info.cancel"),children:u.jsx(re,{})})})]})]})};j.componentKey="univer.doc.link-info-popup";var He=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Be=(n,e,t,i)=>{for(var r=i>1?void 0:i?$e(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&&He(e,t,r),r},q=(n,e)=>(t,i)=>e(t,i,n);let k=class extends o.Disposable{constructor(e,t,i){super();x(this,"_editingLink$",new U.BehaviorSubject(null));x(this,"_showingLink$",new U.BehaviorSubject(null));x(this,"editingLink$",this._editingLink$.asObservable());x(this,"showingLink$",this._showingLink$.asObservable());x(this,"_editPopup",null);x(this,"_infoPopup",null);this._docCanvasPopupManagerService=e,this._textSelectionManagerService=t,this._univerInstanceService=i,this.disposeWithMe(()=>{this._editingLink$.complete(),this._showingLink$.complete()})}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(e,t){this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(t);const i=this._textSelectionManagerService.getTextRanges({unitId:e,subUnitId:e});let r=i==null?void 0:i[i.length-1];if(t){const{segmentId:s,segmentPage:c,startIndex:d,endIndex:g}=t;r={collapsed:!1,startOffset:d,endOffset:g+1,segmentId:s,segmentPage:c},this._textSelectionManagerService.replaceDocRanges([{startOffset:d,endOffset:g+1}])}return r?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(r,{componentKey:N.componentKey,direction:"bottom"},e),this._editPopup):null}hideEditPopup(){var e;this._editingLink$.next(null),(e=this._editPopup)==null||e.dispose()}showInfoPopup(e){var v,m,C,I,l,h;const{linkId:t,unitId:i,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}=e;if(!(((v=this.showing)==null?void 0:v.linkId)===t&&((m=this.showing)==null?void 0:m.unitId)===i&&((C=this.showing)==null?void 0:C.segmentId)===r&&((I=this.showing)==null?void 0:I.segmentPage)===s&&((l=this.showing)==null?void 0:l.startIndex)===c&&((h=this.showing)==null?void 0:h.endIndex)===d||(this._infoPopup&&this._infoPopup.dispose(),!this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_DOC))))return this._showingLink$.next({unitId:i,linkId:t,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}),this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:c,endOffset:d+1,segmentId:r,segmentPage:s},{componentKey:j.componentKey,direction:"top-center",multipleDirection:"top",onClickOutside:()=>{this.hideInfoPopup()}},i),this._infoPopup}hideInfoPopup(){var e;this._showingLink$.next(null),(e=this._infoPopup)==null||e.dispose()}};k=Be([q(0,o.Inject(w.DocCanvasPopManagerService)),q(1,o.Inject(y.DocSelectionManagerService)),q(2,o.IUniverInstanceService)],k);var Ke=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Fe=(n,e,t,i)=>{for(var r=i>1?void 0:i?Ae(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},Z=(n,e)=>(t,i)=>e(t,i,n);let H=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,g=this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_DOC),v=c[0];if(v&&g){const{startOffset:m,endOffset:C,collapsed:I,segmentPage:l}=v,h=(t=(e=g.getSelfOrHeaderFooterModel(d))==null?void 0:e.getBody())==null?void 0:t.customRanges;if(I){const O=(i=h==null?void 0:h.findIndex(f=>f.startIndex<m&&f.endIndex>C-1))!=null?i:-1;if(O>-1){const f=h[O];this._docHyperLinkService.showInfoPopup({unitId:s,linkId:f.rangeId,segmentId:d,segmentPage:l,startIndex:f.startIndex,endIndex:f.endIndex});return}}else if(h==null?void 0:h.find(f=>f.startIndex<=m&&f.endIndex>=C-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};H=Fe([Z(0,o.ICommandService),Z(1,o.IUniverInstanceService),Z(2,o.Inject(k))],H);var Ve=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,qe=(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},b=(n,e)=>(t,i)=>e(t,i,n);let W=class extends o.Disposable{constructor(n,e,t,i,r,s){super(),this._context=n,this._docEventManagerService=e,this._commandService=t,this._hyperLinkPopupService=i,this._docSkeletonManagerService=r,this._docSelectionManagerService=s,!(this._context.unitId===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY||this._context.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)&&(this._initHover(),this._initClick())}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(Y.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(Y.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})}))}};W=qe([b(1,o.Inject(w.DocEventManagerService)),b(2,o.ICommandService),b(3,o.Inject(k)),b(4,o.Inject(y.DocSkeletonManagerService)),b(5,o.Inject(y.DocSelectionManagerService))],W);var Ze=Object.defineProperty,We=Object.getOwnPropertyDescriptor,Ge=(n,e,t,i)=>{for(var r=i>1?void 0:i?We(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},G=(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(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:g,endIndex:v}=s,m=d===i&&n.rangeId===c&&r>=g&&r<=v;return t({...n,active:m})}})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(U.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)),U.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=Ge([G(1,o.Inject(y.DocInterceptorService)),G(2,o.Inject(k)),G(3,o.Inject(w.DocRenderController))],z);const ue="doc-hyper-link-icon";function pe(n){return{id:M.id,type:p.MenuItemType.BUTTON,icon:ue,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:p.getMenuHiddenObservable(n,o.UniverInstanceType.UNIVER_DOC),disabled$:new U.Observable(function(e){const i=n.get(y.DocSelectionManagerService).textSelection$.pipe(U.debounceTime(16)).subscribe(()=>{e.next(ae(n))});return()=>{i.unsubscribe()}})}}const ze={id:M.id,binding:p.MetaKeys.CTRL_COMMAND|p.KeyCode.K,description:"docLink.menu.tooltip",preconditions:w.whenDocAndEditorFocused},Je={[p.RibbonStartGroup.OTHERS]:{[M.id]:{order:0,menuItemFactory:pe}},[p.ContextMenuPosition.MAIN_AREA]:{[p.ContextMenuGroup.DATA]:{[M.id]:{order:0,menuItemFactory:pe}}}};var Qe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,en=(n,e,t,i)=>{for(var r=i>1?void 0:i?Xe(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&Qe(e,t,r),r},$=(n,e)=>(t,i)=>e(t,i,n);let B=class extends o.Disposable{constructor(n,e,t,i){super(),this._componentManager=n,this._commandService=e,this._menuManagerService=t,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[N,N.componentKey],[j,j.componentKey],[V,ue]].forEach(([n,e])=>{this._componentManager.register(e,n)})}_initCommands(){[ee,ne,de,M,Y,le].forEach(n=>{this._commandService.registerCommand(n)})}_initShortcut(){[ze].forEach(n=>{this._shortcutService.registerShortcut(n)})}_initMenus(){this._menuManagerService.mergeMenu(Je)}};B=en([$(0,o.Inject(p.ComponentManager)),$(1,o.ICommandService),$(2,p.IMenuManagerService),$(3,p.IShortcutService)],B);const nn="DOC_HYPER_LINK_UI_PLUGIN";var fe=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,rn=(n,e,t)=>e in n?fe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,on=(n,e,t,i)=>{for(var r=i>1?void 0:i?tn(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&&fe(e,t,r),r},J=(n,e)=>(t,i)=>e(t,i,n),ge=(n,e,t)=>rn(n,typeof e!="symbol"?e+"":e,t);a.UniverDocsHyperLinkUIPlugin=class extends o.Plugin{constructor(e=X,t,i,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=i,this._configService=r;const{menu:s,...c}=o.merge({},X,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Pe,c)}onStarting(){[[k],[B],[H]].forEach(t=>{this._injector.add(t)}),this._injector.get(B)}onReady(){this._injector.get(H)}onRendered(){this._initRenderModule()}_initRenderModule(){[[z],[W]].forEach(e=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,e)})}},ge(a.UniverDocsHyperLinkUIPlugin,"pluginName",nn),ge(a.UniverDocsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC),a.UniverDocsHyperLinkUIPlugin=on([o.DependentOn(D.UniverDocsHyperLinkPlugin),J(1,o.Inject(o.Injector)),J(2,Oe.IRenderManagerService),J(3,o.IConfigService)],a.UniverDocsHyperLinkUIPlugin),Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-hyper-link-ui",
|
|
3
|
-
"version": "0.6.0-
|
|
3
|
+
"version": "0.6.0-experimental.20250212-dbe9830",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer thread comment plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -54,22 +54,22 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@univerjs/icons": "^0.2.14",
|
|
56
56
|
"clsx": "^2.1.1",
|
|
57
|
-
"@univerjs/core": "0.6.0-
|
|
58
|
-
"@univerjs/docs": "0.6.0-
|
|
59
|
-
"@univerjs/docs-hyper-link": "0.6.0-
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/
|
|
57
|
+
"@univerjs/core": "0.6.0-experimental.20250212-dbe9830",
|
|
58
|
+
"@univerjs/docs": "0.6.0-experimental.20250212-dbe9830",
|
|
59
|
+
"@univerjs/docs-hyper-link": "0.6.0-experimental.20250212-dbe9830",
|
|
60
|
+
"@univerjs/docs-ui": "0.6.0-experimental.20250212-dbe9830",
|
|
61
|
+
"@univerjs/engine-render": "0.6.0-experimental.20250212-dbe9830",
|
|
62
|
+
"@univerjs/design": "0.6.0-experimental.20250212-dbe9830",
|
|
63
|
+
"@univerjs/ui": "0.6.0-experimental.20250212-dbe9830"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"postcss": "^8.
|
|
66
|
+
"postcss": "^8.5.1",
|
|
67
67
|
"react": "18.3.1",
|
|
68
68
|
"rxjs": "^7.8.1",
|
|
69
69
|
"tailwindcss": "^3.4.17",
|
|
70
70
|
"typescript": "^5.7.3",
|
|
71
|
-
"vite": "^6.0.
|
|
72
|
-
"vitest": "^
|
|
71
|
+
"vite": "^6.0.11",
|
|
72
|
+
"vitest": "^3.0.4",
|
|
73
73
|
"@univerjs-infra/shared": "0.6.0-alpha.0"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
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
|