@univerjs/docs-hyper-link-ui 0.2.15 → 0.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +332 -333
- package/lib/index.css +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +17 -17
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@univerjs/core"),engineRender=require("@univerjs/engine-render"),docsHyperLink=require("@univerjs/docs-hyper-link"),ui=require("@univerjs/ui"),design=require("@univerjs/design"),docs=require("@univerjs/docs"),docsUi=require("@univerjs/docs-ui"),React=require("react"),rxjs=require("rxjs"),cs=require("clsx"),DOC_HYPER_LINK_UI_PLUGIN="DOC_HYPER_LINK_UI_PLUGIN";var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=React.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=React.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return React.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a7){var key=_a7[0],value=_a7[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a7,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a7=node.children)===null||_a7===void 0)&&_a7.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid");IconBase.displayName="UniverIcon";var element$3={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"}}]},CopySingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"copy-single",ref,icon:element$3}))});CopySingle.displayName="CopySingle";var element$2={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},LinkSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"link-single",ref,icon:element$2}))});LinkSingle.displayName="LinkSingle";var element$1={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"}}]},UnlinkSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"unlink-single",ref,icon:element$1}))});UnlinkSingle.displayName="UnlinkSingle";var element={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"}}]},WriteSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"write-single",ref,icon:element}))});WriteSingle.displayName="WriteSingle";const AddDocHyperLinkCommand={type:core.CommandType.COMMAND,id:"docs.command.add-hyper-link",async handler(accessor,params){if(!params)return!1;const{payload,unitId,selection}=params,commandService=accessor.get(core.ICommandService),id=core.generateRandomId(),doMutation=docsUi.addCustomRangeBySelectionFactory(accessor,{rangeId:id,rangeType:core.CustomRangeType.HYPERLINK,properties:{url:payload},unitId,selection});return doMutation?commandService.syncExecuteCommand(doMutation.id,doMutation.params):!1}},UpdateDocHyperLinkCommand={id:"docs.command.update-hyper-link",type:core.CommandType.COMMAND,handler(accessor,params){var _a7;if(!params)return!1;const{unitId,payload,segmentId}=params,commandService=accessor.get(core.ICommandService),univerInstanceService=accessor.get(core.IUniverInstanceService),currentSelection=accessor.get(docs.DocSelectionManagerService).getActiveTextRange(),doc=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC);if(!currentSelection||!doc)return!1;const newId=core.generateRandomId(),textRun=(_a7=core.getBodySlice(doc.getSelfOrHeaderFooterModel(segmentId).getBody(),currentSelection.startOffset,currentSelection.endOffset).textRuns)==null?void 0:_a7[0];textRun&&(textRun.ed=params.label.length+1);const replaceSelection=docsUi.replaceSelectionFactory(accessor,{unitId,body:{dataStream:`${core.DataStreamTreeTokenType.CUSTOM_RANGE_START}${params.label}${core.DataStreamTreeTokenType.CUSTOM_RANGE_END}`,customRanges:[{rangeId:newId,rangeType:core.CustomRangeType.HYPERLINK,startIndex:0,endIndex:params.label.length+1,properties:{url:payload}}],textRuns:textRun?[textRun]:void 0},selection:{startOffset:currentSelection.startOffset,endOffset:currentSelection.endOffset,collapsed:!1,segmentId}});return replaceSelection?commandService.syncExecuteCommand(replaceSelection.id,replaceSelection.params):!1}},DeleteDocHyperLinkCommand={type:core.CommandType.COMMAND,id:"docs.command.delete-hyper-link",async handler(accessor,params){if(!params)return!1;const{unitId,linkId,segmentId}=params,commandService=accessor.get(core.ICommandService),doMutation=docsUi.deleteCustomRangeFactory(accessor,{unitId,rangeId:linkId,segmentId});return doMutation?await commandService.syncExecuteCommand(doMutation.id,doMutation.params):!1}},shouldDisableAddLink=__name(accessor=>{var _a7;const textSelectionService=accessor.get(docs.DocSelectionManagerService),univerInstanceService=accessor.get(core.IUniverInstanceService),textRanges=textSelectionService.getDocRanges();if(!textRanges.length||textRanges.length>1)return!0;const activeRange=textRanges[0],doc=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC);if(!doc||!activeRange||activeRange.collapsed)return!0;const body=doc.getSelfOrHeaderFooterModel(activeRange.segmentId).getBody(),paragraphs=body==null?void 0:body.paragraphs;if(!paragraphs)return!0;for(let i=0,len=paragraphs.length;i<len;i++){const p=paragraphs[i];if(activeRange.startOffset<=p.startIndex&&activeRange.endOffset>p.startIndex)return!0;if(p.startIndex>activeRange.endOffset)break}return!core.BuildTextUtils.customRange.getCustomRangesInterestsWithRange(activeRange,(_a7=body.customRanges)!=null?_a7:[]).every(range=>range.rangeType===core.CustomRangeType.HYPERLINK)},"shouldDisableAddLink"),ShowDocHyperLinkEditPopupOperation={type:core.CommandType.OPERATION,id:"doc.operation.show-hyper-link-edit-popup",handler(accessor,params){var _a7;const linkInfo=params==null?void 0:params.link,univerInstanceService=accessor.get(core.IUniverInstanceService);if(shouldDisableAddLink(accessor)&&!linkInfo)return!1;const hyperLinkService=accessor.get(DocHyperLinkPopupService),unitId=(linkInfo==null?void 0:linkInfo.unitId)||((_a7=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC))==null?void 0:_a7.getUnitId());return unitId?(hyperLinkService.showEditPopup(unitId,linkInfo),!0):!1}},ToggleDocHyperLinkInfoPopupOperation={type:core.CommandType.OPERATION,id:"doc.operation.toggle-hyper-link-info-popup",handler(accessor,params){const hyperLinkService=accessor.get(DocHyperLinkPopupService);return params?(hyperLinkService.showInfoPopup(params),!0):(hyperLinkService.hideInfoPopup(),!0)}},ClickDocHyperLinkOperation={type:core.CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(accessor,params){var _a7,_b,_c;if(!params)return!1;const{unitId,linkId,segmentId}=params,doc=accessor.get(core.IUniverInstanceService).getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),body=doc==null?void 0:doc.getSelfOrHeaderFooterModel(segmentId).getBody(),link=(_c=(_b=(_a7=body==null?void 0:body.customRanges)==null?void 0:_a7.find(range=>range.rangeId===linkId&&range.rangeType===core.CustomRangeType.HYPERLINK))==null?void 0:_b.properties)==null?void 0:_c.url;return link&&window.open(link,"_blank","noopener noreferrer"),!0}},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",styles$1={docLink,docLinkType,docLinkContent,docLinkContentError,docLinkUrl,docLinkOperations,docLinkOperation,docLinkOperationError},DocLinkPopup=__name(()=>{var _a7,_b;const hyperLinkService=core.useDependency(DocHyperLinkPopupService),commandService=core.useDependency(core.ICommandService),messageService=core.useDependency(ui.IMessageService),localeService=core.useDependency(core.LocaleService),currentPopup=ui.useObservable(hyperLinkService.showingLink$),univerInstanceService=core.useDependency(core.IUniverInstanceService);if(!currentPopup)return null;const{unitId,linkId,segmentId}=currentPopup,doc=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),body=doc==null?void 0:doc.getSelfOrHeaderFooterModel(segmentId).getBody(),link=(_a7=body==null?void 0:body.customRanges)==null?void 0:_a7.find(range=>range.rangeId===linkId&&range.rangeType===core.CustomRangeType.HYPERLINK);if(!link)return null;const url=(_b=link.properties)==null?void 0:_b.url;return React.createElement("div",{className:styles$1.docLink,onClick:__name(()=>{hyperLinkService.hideInfoPopup()},"onClick")},React.createElement("div",{className:cs(styles$1.docLinkContent),onClick:__name(()=>window.open(url),"onClick")},React.createElement("div",{className:styles$1.docLinkType},React.createElement(LinkSingle,null)),React.createElement(design.Tooltip,{showIfEllipsis:!0,title:url},React.createElement("span",{className:styles$1.docLinkUrl},url))),React.createElement("div",{className:styles$1.docLinkOperations},React.createElement("div",{className:cs(styles$1.docLinkOperation),onClick:__name(()=>{navigator.clipboard.writeText(url),messageService.show({content:localeService.t("docLink.info.coped"),type:design.MessageType.Info})},"onClick")},React.createElement(design.Tooltip,{placement:"bottom",title:localeService.t("docLink.info.copy")},React.createElement(CopySingle,null))),React.createElement("div",{className:styles$1.docLinkOperation,onClick:__name(()=>{commandService.executeCommand(ShowDocHyperLinkEditPopupOperation.id,{link:currentPopup})},"onClick")},React.createElement(design.Tooltip,{placement:"bottom",title:localeService.t("docLink.info.edit")},React.createElement(WriteSingle,null))),React.createElement("div",{className:styles$1.docLinkOperation,onClick:__name(()=>{commandService.executeCommand(DeleteDocHyperLinkCommand.id,{unitId,linkId:link.rangeId,segmentId})},"onClick")},React.createElement(design.Tooltip,{placement:"bottom",title:localeService.t("docLink.info.cancel")},React.createElement(UnlinkSingle,null)))))},"DocLinkPopup");DocLinkPopup.componentKey="univer.doc.link-info-popup";var __defProp$5=Object.defineProperty,__getOwnPropDesc$5=Object.getOwnPropertyDescriptor,__decorateClass$5=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$5(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$5(target,key,result),result},"__decorateClass$5"),__decorateParam$5=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$5");const SKIT_PLACEHOLDER=0;var _a;let DocHyperLinkPopupService=(_a=class extends core.Disposable{constructor(_docCanvasPopupManagerService,_textSelectionManagerService,_univerInstanceService){super();__publicField(this,"_editingLink$",new rxjs.BehaviorSubject(null));__publicField(this,"_showingLink$",new rxjs.BehaviorSubject(null));__publicField(this,"editingLink$",this._editingLink$.asObservable());__publicField(this,"showingLink$",this._showingLink$.asObservable());__publicField(this,"_editPopup",null);__publicField(this,"_infoPopup",null);this._docCanvasPopupManagerService=_docCanvasPopupManagerService,this._textSelectionManagerService=_textSelectionManagerService,this._univerInstanceService=_univerInstanceService,this.disposeWithMe(()=>{this._editingLink$.complete(),this._showingLink$.complete()})}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(unitId,linkInfo){var _a7,_b,_c;this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(linkInfo);let activeRange=this._textSelectionManagerService.getActiveTextRange();if(linkInfo){const{unitId:unitId2,linkId,segmentId,segmentPage}=linkInfo,doc=this._univerInstanceService.getUnit(unitId2,core.UniverInstanceType.UNIVER_DOC),range=(_c=(_b=(_a7=doc==null?void 0:doc.getSelfOrHeaderFooterModel(segmentId))==null?void 0:_a7.getBody())==null?void 0:_b.customRanges)==null?void 0:_c.find(i=>i.rangeId===linkId);range&&(activeRange={collapsed:!1,startOffset:range.startIndex+SKIT_PLACEHOLDER,endOffset:range.endIndex+1,segmentId,segmentPage},this._textSelectionManagerService.replaceTextRanges([{startOffset:range.startIndex,endOffset:range.endIndex+1}]))}return activeRange?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(activeRange,{componentKey:DocHyperLinkEdit.componentKey,direction:"bottom"},unitId),this._editPopup):null}hideEditPopup(){var _a7;this._editingLink$.next(null),(_a7=this._editPopup)==null||_a7.dispose()}showInfoPopup(info){var _a7,_b,_c,_d,_e,_f;const{linkId,unitId,segmentId,segmentPage}=info;if(((_a7=this.showing)==null?void 0:_a7.linkId)===linkId&&((_b=this.showing)==null?void 0:_b.unitId)===unitId&&((_c=this.showing)==null?void 0:_c.segmentId)===segmentId&&((_d=this.showing)==null?void 0:_d.segmentPage)===segmentPage)return;this._infoPopup&&this._infoPopup.dispose();const doc=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC);if(!doc)return;const range=(_f=(_e=doc.getSelfOrHeaderFooterModel(info.segmentId).getBody())==null?void 0:_e.customRanges)==null?void 0:_f.find(i=>i.rangeId===linkId);if(this._showingLink$.next({unitId,linkId,segmentId,segmentPage}),!!range)return this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:range.startIndex+SKIT_PLACEHOLDER,endOffset:range.endIndex+1,segmentId:info.segmentId,segmentPage:info.segmentPage},{componentKey:DocLinkPopup.componentKey,direction:"top-center",multipleDirection:"top",onClickOutside:__name(()=>{this.hideInfoPopup()},"onClickOutside")},info.unitId),this._infoPopup}hideInfoPopup(){var _a7;this._showingLink$.next(null),(_a7=this._infoPopup)==null||_a7.dispose()}},__name(_a,"DocHyperLinkPopupService"),_a);DocHyperLinkPopupService=__decorateClass$5([__decorateParam$5(0,core.Inject(docsUi.DocCanvasPopManagerService)),__decorateParam$5(1,core.Inject(docs.DocSelectionManagerService)),__decorateParam$5(2,core.IUniverInstanceService)],DocHyperLinkPopupService);const 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",styles={docsLinkEdit,docsLinkEditTitle,docsLinkEditClose,docsLinkEditButtons,docsLinkEditButton};function hasProtocol(urlString){return/^[a-zA-Z]+:\/\//.test(urlString)}__name(hasProtocol,"hasProtocol");function isEmail(url){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url)}__name(isEmail,"isEmail");function transformUrl(urlStr){return hasProtocol(urlStr)?urlStr:isEmail(urlStr)?`mailto://${urlStr}`:`https://${urlStr}`}__name(transformUrl,"transformUrl");const DocHyperLinkEdit=__name(()=>{var _a7;const hyperLinkService=core.useDependency(DocHyperLinkPopupService),localeService=core.useDependency(core.LocaleService),editing=core.useObservable(hyperLinkService.editingLink$),commandService=core.useDependency(core.ICommandService),univerInstanceService=core.useDependency(core.IUniverInstanceService),renderManagerService=core.useDependency(engineRender.IRenderManagerService),docSelectionManagerService=core.useDependency(docs.DocSelectionManagerService),[link,setLink]=React.useState(""),[label,setLabel]=React.useState(""),[showError,setShowError]=React.useState(!1),isLegal=core.Tools.isLegalUrl(link),doc=editing?univerInstanceService.getUnit(editing.unitId,core.UniverInstanceType.UNIVER_DOC):univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC),docSelectionRenderService=(_a7=renderManagerService.getRenderById(doc.getUnitId()))==null?void 0:_a7.with(docsUi.DocSelectionRenderService);React.useEffect(()=>{var _a8,_b,_c,_d,_e,_f,_g,_h,_i;const activeRange=docSelectionManagerService.getActiveTextRange();if(!activeRange)return;if(editing){const body=(_a8=doc==null?void 0:doc.getSelfOrHeaderFooterModel(editing.segmentId))==null?void 0:_a8.getBody(),matchedRange2=(_b=body==null?void 0:body.customRanges)==null?void 0:_b.find(i=>(editing==null?void 0:editing.linkId)===i.rangeId);doc&&matchedRange2&&(setLink((_d=(_c=matchedRange2.properties)==null?void 0:_c.url)!=null?_d:""),setLabel(core.BuildTextUtils.transform.getPlainText(core.getBodySlice(body,matchedRange2.startIndex,matchedRange2.endIndex).dataStream)));return}const matchedRange=(_g=(_f=(_e=doc==null?void 0:doc.getSelfOrHeaderFooterModel(activeRange.segmentId))==null?void 0:_e.getBody())==null?void 0:_f.customRanges)==null?void 0:_g.find(i=>Math.max(activeRange.startOffset,i.startIndex)<=Math.min(activeRange.endOffset-1,i.endIndex));doc&&matchedRange&&setLink((_i=(_h=matchedRange==null?void 0:matchedRange.properties)==null?void 0:_h.url)!=null?_i:"")},[doc,editing,docSelectionManagerService,univerInstanceService]),React.useEffect(()=>(docSelectionRenderService&&docSelectionRenderService.blurEditor(),()=>{docSelectionRenderService&&docSelectionRenderService.focusEditor()}),[docSelectionRenderService]);const handleCancel=__name(()=>{hyperLinkService.hideEditPopup()},"handleCancel"),handleConfirm=__name(()=>{if(setShowError(!0),!isLegal||!doc)return;const linkFinal=transformUrl(link);if(!editing)commandService.executeCommand(AddDocHyperLinkCommand.id,{unitId:doc.getUnitId(),payload:linkFinal});else{if(!label)return;commandService.executeCommand(UpdateDocHyperLinkCommand.id,{unitId:doc.getUnitId(),payload:linkFinal,linkId:editing.linkId,label,segmentId:editing.segmentId})}hyperLinkService.hideEditPopup()},"handleConfirm");if(doc)return React.createElement("div",{className:styles.docsLinkEdit},React.createElement("div",null,editing?React.createElement(design.FormLayout,{label:localeService.t("docLink.edit.label"),error:showError&&!label?localeService.t("docLink.edit.labelError"):""},React.createElement(design.Input,{value:label,onChange:setLabel,autoFocus:!0,onKeyDown:__name(evt=>{evt.keyCode===ui.KeyCode.ENTER&&handleConfirm()},"onKeyDown")})):null,React.createElement(design.FormLayout,{label:localeService.t("docLink.edit.address"),error:showError&&!isLegal?localeService.t("docLink.edit.addressError"):""},React.createElement(design.Input,{value:link,onChange:setLink,autoFocus:!0,onKeyDown:__name(evt=>{evt.keyCode===ui.KeyCode.ENTER&&handleConfirm()},"onKeyDown")}))),React.createElement("div",{className:styles.docsLinkEditButtons},React.createElement(design.Button,{className:styles.docsLinkEditButton,onClick:handleCancel},localeService.t("docLink.edit.cancel")),React.createElement(design.Button,{disabled:!link,className:styles.docsLinkEditButton,type:"primary",onClick:handleConfirm},localeService.t("docLink.edit.confirm"))))},"DocHyperLinkEdit");DocHyperLinkEdit.componentKey="docs-hyper-link-edit";const DOC_LINK_ICON="doc-hyper-link-icon";function AddHyperLinkMenuItemFactory(accessor){return{id:ShowDocHyperLinkEditPopupOperation.id,type:ui.MenuItemType.BUTTON,icon:DOC_LINK_ICON,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC),disabled$:new rxjs.Observable(function(subscribe){const observer=accessor.get(docs.DocSelectionManagerService).textSelection$.pipe(rxjs.debounceTime(16)).subscribe(()=>{subscribe.next(shouldDisableAddLink(accessor))});return()=>{observer.unsubscribe()}})}}__name(AddHyperLinkMenuItemFactory,"AddHyperLinkMenuItemFactory");const addLinkShortcut={id:ShowDocHyperLinkEditPopupOperation.id,binding:ui.MetaKeys.CTRL_COMMAND|ui.KeyCode.K,description:"docLink.menu.tooltip",preconditions:docsUi.whenDocAndEditorFocused},menuSchema={[ui.RibbonStartGroup.OTHERS]:{[ShowDocHyperLinkEditPopupOperation.id]:{order:0,menuItemFactory:AddHyperLinkMenuItemFactory}},[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.DATA]:{[ShowDocHyperLinkEditPopupOperation.id]:{order:0,menuItemFactory:AddHyperLinkMenuItemFactory}}}};var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4"),_a2;let DocHyperLinkUIController=(_a2=class extends core.Disposable{constructor(_componentManager,_commandService,_menuManagerService,_injector,_shortcutService){super(),this._componentManager=_componentManager,this._commandService=_commandService,this._menuManagerService=_menuManagerService,this._injector=_injector,this._shortcutService=_shortcutService,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[DocHyperLinkEdit,DocHyperLinkEdit.componentKey],[DocLinkPopup,DocLinkPopup.componentKey],[LinkSingle,DOC_LINK_ICON]].forEach(([comp,key])=>{this._componentManager.register(key,comp)})}_initCommands(){[AddDocHyperLinkCommand,UpdateDocHyperLinkCommand,DeleteDocHyperLinkCommand,ShowDocHyperLinkEditPopupOperation,ToggleDocHyperLinkInfoPopupOperation,ClickDocHyperLinkOperation].forEach(command=>{this._commandService.registerCommand(command)})}_initShortcut(){[addLinkShortcut].forEach(shortcut=>{this._shortcutService.registerShortcut(shortcut)})}_initMenus(){this._menuManagerService.mergeMenu(menuSchema)}},__name(_a2,"DocHyperLinkUIController"),_a2);DocHyperLinkUIController=__decorateClass$4([core.OnLifecycle(core.LifecycleStages.Starting,DocHyperLinkUIController),__decorateParam$4(0,core.Inject(ui.ComponentManager)),__decorateParam$4(1,core.ICommandService),__decorateParam$4(2,ui.IMenuManagerService),__decorateParam$4(3,core.Inject(core.Injector)),__decorateParam$4(4,ui.IShortcutService)],DocHyperLinkUIController);var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3"),_a3;let DocHyperLinkSelectionController=(_a3=class extends core.Disposable{constructor(_commandService,_univerInstanceService,_docHyperLinkService){super(),this._commandService=_commandService,this._univerInstanceService=_univerInstanceService,this._docHyperLinkService=_docHyperLinkService,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(commandInfo=>{var _a7,_b,_c;if(commandInfo.id===docs.SetTextSelectionsOperation.id){const params=commandInfo.params,{unitId,ranges,segmentId}=params,doc=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),primary=ranges[0];if(primary&&doc){const{startOffset,endOffset,collapsed,segmentPage}=primary,customRanges=(_b=(_a7=doc.getSelfOrHeaderFooterModel(segmentId))==null?void 0:_a7.getBody())==null?void 0:_b.customRanges;if(collapsed){const index=(_c=customRanges==null?void 0:customRanges.findIndex(value=>value.startIndex<startOffset&&value.endIndex>endOffset-1))!=null?_c:-1;if(index>-1){const customRange=customRanges[index];this._docHyperLinkService.showInfoPopup({unitId,linkId:customRange.rangeId,segmentId,segmentPage});return}}else if(customRanges==null?void 0:customRanges.find(value=>value.startIndex<=startOffset&&value.endIndex>=endOffset-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}},__name(_a3,"DocHyperLinkSelectionController"),_a3);DocHyperLinkSelectionController=__decorateClass$3([core.OnLifecycle(core.LifecycleStages.Ready,DocHyperLinkSelectionController),__decorateParam$3(0,core.ICommandService),__decorateParam$3(1,core.IUniverInstanceService),__decorateParam$3(2,core.Inject(DocHyperLinkPopupService))],DocHyperLinkSelectionController);var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2"),_a4;let DocHyperLinkRenderController=(_a4=class extends core.Disposable{constructor(_context,_docInterceptorService,_hyperLinkService,_docRenderController){super(),this._context=_context,this._docInterceptorService=_docInterceptorService,this._hyperLinkService=_hyperLinkService,this._docRenderController=_docRenderController,this._init(),this._initReRender()}_init(){this._docInterceptorService.intercept(docs.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:__name((data,pos,next)=>{if(!data)return next(data);const{unitId}=pos,activeLink=this._hyperLinkService.showing,{linkId,unitId:linkUnitId}=activeLink||{},isActive=linkUnitId===unitId&&data.rangeId===linkId;return next({...data,active:isActive})},"handler")})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(rxjs.distinctUntilChanged((prev,aft)=>(prev==null?void 0:prev.linkId)===(aft==null?void 0:aft.linkId)&&(prev==null?void 0:prev.unitId)===(aft==null?void 0:aft.unitId)),rxjs.pairwise()).subscribe(([preLink,link])=>{link?link.unitId===this._context.unitId&&this._docRenderController.reRender(link.unitId):preLink&&preLink.unitId===this._context.unitId&&this._docRenderController.reRender(preLink.unitId)}))}},__name(_a4,"DocHyperLinkRenderController"),_a4);DocHyperLinkRenderController=__decorateClass$2([__decorateParam$2(1,core.Inject(docs.DocInterceptorService)),__decorateParam$2(2,core.Inject(DocHyperLinkPopupService)),__decorateParam$2(3,core.Inject(docsUi.DocRenderController))],DocHyperLinkRenderController);var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1"),_a5;let DocHyperLinkEventRenderController=(_a5=class extends core.Disposable{constructor(_context,_docEventManagerService,_commandService,_hyperLinkPopupService,_docSkeletonManagerService,_docSelectionManagerService){super(),this._context=_context,this._docEventManagerService=_docEventManagerService,this._commandService=_commandService,this._hyperLinkPopupService=_hyperLinkPopupService,this._docSkeletonManagerService=_docSkeletonManagerService,this._docSelectionManagerService=_docSelectionManagerService,this._initHover(),this._initClick()}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(ToggleDocHyperLinkInfoPopupOperation.id)}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(ranges=>{var _a7;const link=ranges.find(range=>range.range.rangeType===core.CustomRangeType.HYPERLINK),activeRanges=this._docSelectionManagerService.getCurrentTextRanges(),currentSegmentId=activeRanges==null?void 0:activeRanges[0].segmentId;if(((_a7=link==null?void 0:link.segmentId)!=null?_a7:"")!==currentSegmentId){this._hideInfoPopup();return}link?this._commandService.executeCommand(ToggleDocHyperLinkInfoPopupOperation.id,{unitId:this._context.unitId,linkId:link.range.rangeId,segmentId:link.segmentId,segmentPage:link.segmentPageIndex,rangeId:link.range.rangeId}):this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(range=>{const link=range.range;link&&this._commandService.executeCommand(ClickDocHyperLinkOperation.id,{unitId:this._context.unitId,linkId:link.rangeId,segmentId:range.segmentId})}))}},__name(_a5,"DocHyperLinkEventRenderController"),_a5);DocHyperLinkEventRenderController=__decorateClass$1([__decorateParam$1(1,core.Inject(docsUi.DocEventManagerService)),__decorateParam$1(2,core.ICommandService),__decorateParam$1(3,core.Inject(DocHyperLinkPopupService)),__decorateParam$1(4,core.Inject(docs.DocSkeletonManagerService)),__decorateParam$1(5,core.Inject(docs.DocSelectionManagerService))],DocHyperLinkEventRenderController);const PLUGIN_CONFIG_KEY="docs-hyper-link-ui.config",defaultPluginConfig={};var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField"),_a6;exports.UniverDocsHyperLinkUIPlugin=(_a6=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_renderManagerSrv,_configService){super(),this._config=_config,this._injector=_injector,this._renderManagerSrv=_renderManagerSrv,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[DocHyperLinkPopupService],[DocHyperLinkUIController],[DocHyperLinkSelectionController]].forEach(dep=>{this._injector.add(dep)})}onRendered(){this._initRenderModule()}_initRenderModule(){[[DocHyperLinkRenderController],[DocHyperLinkEventRenderController]].forEach(dep=>{this._renderManagerSrv.registerRenderModule(core.UniverInstanceType.UNIVER_DOC,dep)})}},__name(_a6,"UniverDocsHyperLinkUIPlugin"),_a6);__publicField2(exports.UniverDocsHyperLinkUIPlugin,"pluginName",DOC_HYPER_LINK_UI_PLUGIN);__publicField2(exports.UniverDocsHyperLinkUIPlugin,"type",core.UniverInstanceType.UNIVER_DOC);exports.UniverDocsHyperLinkUIPlugin=__decorateClass([core.DependentOn(docsHyperLink.UniverDocsHyperLinkPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,engineRender.IRenderManagerService),__decorateParam(3,core.IConfigService)],exports.UniverDocsHyperLinkUIPlugin);
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@univerjs/core"),docsHyperLink=require("@univerjs/docs-hyper-link"),engineRender=require("@univerjs/engine-render"),docs=require("@univerjs/docs"),docsUi=require("@univerjs/docs-ui"),rxjs=require("rxjs"),design=require("@univerjs/design"),ui=require("@univerjs/ui"),React=require("react"),cs=require("clsx"),PLUGIN_CONFIG_KEY="docs-hyper-link-ui.config",defaultPluginConfig={},AddDocHyperLinkCommand={type:core.CommandType.COMMAND,id:"docs.command.add-hyper-link",async handler(accessor,params){if(!params)return!1;const{payload,unitId,selection}=params,commandService=accessor.get(core.ICommandService),id=core.generateRandomId(),doMutation=docsUi.addCustomRangeBySelectionFactory(accessor,{rangeId:id,rangeType:core.CustomRangeType.HYPERLINK,properties:{url:payload},unitId,selection});return doMutation?commandService.syncExecuteCommand(doMutation.id,doMutation.params):!1}},UpdateDocHyperLinkCommand={id:"docs.command.update-hyper-link",type:core.CommandType.COMMAND,handler(accessor,params){var _a7;if(!params)return!1;const{unitId,payload,segmentId}=params,commandService=accessor.get(core.ICommandService),univerInstanceService=accessor.get(core.IUniverInstanceService),currentSelection=accessor.get(docs.DocSelectionManagerService).getActiveTextRange(),doc=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC);if(!currentSelection||!doc)return!1;const newId=core.generateRandomId(),textRun=(_a7=core.getBodySlice(doc.getSelfOrHeaderFooterModel(segmentId).getBody(),currentSelection.startOffset,currentSelection.endOffset).textRuns)==null?void 0:_a7[0];textRun&&(textRun.ed=params.label.length+1);const replaceSelection=docsUi.replaceSelectionFactory(accessor,{unitId,body:{dataStream:`${core.DataStreamTreeTokenType.CUSTOM_RANGE_START}${params.label}${core.DataStreamTreeTokenType.CUSTOM_RANGE_END}`,customRanges:[{rangeId:newId,rangeType:core.CustomRangeType.HYPERLINK,startIndex:0,endIndex:params.label.length+1,properties:{url:payload}}],textRuns:textRun?[textRun]:void 0},selection:{startOffset:currentSelection.startOffset,endOffset:currentSelection.endOffset,collapsed:!1,segmentId}});return replaceSelection?commandService.syncExecuteCommand(replaceSelection.id,replaceSelection.params):!1}},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",styles$1={docsLinkEdit,docsLinkEditTitle,docsLinkEditClose,docsLinkEditButtons,docsLinkEditButton};function hasProtocol(urlString){return/^[a-zA-Z]+:\/\//.test(urlString)}__name(hasProtocol,"hasProtocol");function isEmail(url){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url)}__name(isEmail,"isEmail");function transformUrl(urlStr){return hasProtocol(urlStr)?urlStr:isEmail(urlStr)?`mailto://${urlStr}`:`https://${urlStr}`}__name(transformUrl,"transformUrl");const DocHyperLinkEdit=__name(()=>{var _a7;const hyperLinkService=core.useDependency(DocHyperLinkPopupService),localeService=core.useDependency(core.LocaleService),editing=core.useObservable(hyperLinkService.editingLink$),commandService=core.useDependency(core.ICommandService),univerInstanceService=core.useDependency(core.IUniverInstanceService),renderManagerService=core.useDependency(engineRender.IRenderManagerService),docSelectionManagerService=core.useDependency(docs.DocSelectionManagerService),[link,setLink]=React.useState(""),[label,setLabel]=React.useState(""),[showError,setShowError]=React.useState(!1),isLegal=core.Tools.isLegalUrl(link),doc=editing?univerInstanceService.getUnit(editing.unitId,core.UniverInstanceType.UNIVER_DOC):univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC),docSelectionRenderService=(_a7=renderManagerService.getRenderById(doc.getUnitId()))==null?void 0:_a7.with(docsUi.DocSelectionRenderService);React.useEffect(()=>{var _a8,_b,_c,_d,_e,_f,_g,_h,_i;const activeRange=docSelectionManagerService.getActiveTextRange();if(!activeRange)return;if(editing){const body=(_a8=doc==null?void 0:doc.getSelfOrHeaderFooterModel(editing.segmentId))==null?void 0:_a8.getBody(),matchedRange2=(_b=body==null?void 0:body.customRanges)==null?void 0:_b.find(i=>(editing==null?void 0:editing.linkId)===i.rangeId);doc&&matchedRange2&&(setLink((_d=(_c=matchedRange2.properties)==null?void 0:_c.url)!=null?_d:""),setLabel(core.BuildTextUtils.transform.getPlainText(core.getBodySlice(body,matchedRange2.startIndex,matchedRange2.endIndex).dataStream)));return}const matchedRange=(_g=(_f=(_e=doc==null?void 0:doc.getSelfOrHeaderFooterModel(activeRange.segmentId))==null?void 0:_e.getBody())==null?void 0:_f.customRanges)==null?void 0:_g.find(i=>Math.max(activeRange.startOffset,i.startIndex)<=Math.min(activeRange.endOffset-1,i.endIndex));doc&&matchedRange&&setLink((_i=(_h=matchedRange==null?void 0:matchedRange.properties)==null?void 0:_h.url)!=null?_i:"")},[doc,editing,docSelectionManagerService,univerInstanceService]),React.useEffect(()=>(docSelectionRenderService&&docSelectionRenderService.blurEditor(),()=>{docSelectionRenderService&&docSelectionRenderService.focusEditor()}),[docSelectionRenderService]);const handleCancel=__name(()=>{hyperLinkService.hideEditPopup()},"handleCancel"),handleConfirm=__name(()=>{if(setShowError(!0),!isLegal||!doc)return;const linkFinal=transformUrl(link);if(!editing)commandService.executeCommand(AddDocHyperLinkCommand.id,{unitId:doc.getUnitId(),payload:linkFinal});else{if(!label)return;commandService.executeCommand(UpdateDocHyperLinkCommand.id,{unitId:doc.getUnitId(),payload:linkFinal,linkId:editing.linkId,label,segmentId:editing.segmentId})}hyperLinkService.hideEditPopup()},"handleConfirm");if(doc)return React.createElement("div",{className:styles$1.docsLinkEdit},React.createElement("div",null,editing?React.createElement(design.FormLayout,{label:localeService.t("docLink.edit.label"),error:showError&&!label?localeService.t("docLink.edit.labelError"):""},React.createElement(design.Input,{value:label,onChange:setLabel,autoFocus:!0,onKeyDown:__name(evt=>{evt.keyCode===ui.KeyCode.ENTER&&handleConfirm()},"onKeyDown")})):null,React.createElement(design.FormLayout,{label:localeService.t("docLink.edit.address"),error:showError&&!isLegal?localeService.t("docLink.edit.addressError"):""},React.createElement(design.Input,{value:link,onChange:setLink,autoFocus:!0,onKeyDown:__name(evt=>{evt.keyCode===ui.KeyCode.ENTER&&handleConfirm()},"onKeyDown")}))),React.createElement("div",{className:styles$1.docsLinkEditButtons},React.createElement(design.Button,{className:styles$1.docsLinkEditButton,onClick:handleCancel},localeService.t("docLink.edit.cancel")),React.createElement(design.Button,{disabled:!link,className:styles$1.docsLinkEditButton,type:"primary",onClick:handleConfirm},localeService.t("docLink.edit.confirm"))))},"DocHyperLinkEdit");DocHyperLinkEdit.componentKey="docs-hyper-link-edit";var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=React.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=React.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return React.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a7){var key=_a7[0],value=_a7[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a7,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a7=node.children)===null||_a7===void 0)&&_a7.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid");IconBase.displayName="UniverIcon";var element$3={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"}}]},CopySingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"copy-single",ref,icon:element$3}))});CopySingle.displayName="CopySingle";var element$2={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},LinkSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"link-single",ref,icon:element$2}))});LinkSingle.displayName="LinkSingle";var element$1={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"}}]},UnlinkSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"unlink-single",ref,icon:element$1}))});UnlinkSingle.displayName="UnlinkSingle";var element={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"}}]},WriteSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"write-single",ref,icon:element}))});WriteSingle.displayName="WriteSingle";const DeleteDocHyperLinkCommand={type:core.CommandType.COMMAND,id:"docs.command.delete-hyper-link",async handler(accessor,params){if(!params)return!1;const{unitId,linkId,segmentId}=params,commandService=accessor.get(core.ICommandService),doMutation=docsUi.deleteCustomRangeFactory(accessor,{unitId,rangeId:linkId,segmentId});return doMutation?await commandService.syncExecuteCommand(doMutation.id,doMutation.params):!1}},shouldDisableAddLink=__name(accessor=>{var _a7;const textSelectionService=accessor.get(docs.DocSelectionManagerService),univerInstanceService=accessor.get(core.IUniverInstanceService),textRanges=textSelectionService.getDocRanges();if(!textRanges.length||textRanges.length>1)return!0;const activeRange=textRanges[0],doc=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC);if(!doc||!activeRange||activeRange.collapsed)return!0;const body=doc.getSelfOrHeaderFooterModel(activeRange.segmentId).getBody(),paragraphs=body==null?void 0:body.paragraphs;if(!paragraphs)return!0;for(let i=0,len=paragraphs.length;i<len;i++){const p=paragraphs[i];if(activeRange.startOffset<=p.startIndex&&activeRange.endOffset>p.startIndex)return!0;if(p.startIndex>activeRange.endOffset)break}return!core.BuildTextUtils.customRange.getCustomRangesInterestsWithRange(activeRange,(_a7=body.customRanges)!=null?_a7:[]).every(range=>range.rangeType===core.CustomRangeType.HYPERLINK)},"shouldDisableAddLink"),ShowDocHyperLinkEditPopupOperation={type:core.CommandType.OPERATION,id:"doc.operation.show-hyper-link-edit-popup",handler(accessor,params){var _a7;const linkInfo=params==null?void 0:params.link,univerInstanceService=accessor.get(core.IUniverInstanceService);if(shouldDisableAddLink(accessor)&&!linkInfo)return!1;const hyperLinkService=accessor.get(DocHyperLinkPopupService),unitId=(linkInfo==null?void 0:linkInfo.unitId)||((_a7=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC))==null?void 0:_a7.getUnitId());return unitId?(hyperLinkService.showEditPopup(unitId,linkInfo),!0):!1}},ToggleDocHyperLinkInfoPopupOperation={type:core.CommandType.OPERATION,id:"doc.operation.toggle-hyper-link-info-popup",handler(accessor,params){const hyperLinkService=accessor.get(DocHyperLinkPopupService);return params?(hyperLinkService.showInfoPopup(params),!0):(hyperLinkService.hideInfoPopup(),!0)}},ClickDocHyperLinkOperation={type:core.CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(accessor,params){var _a7,_b,_c;if(!params)return!1;const{unitId,linkId,segmentId}=params,doc=accessor.get(core.IUniverInstanceService).getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),body=doc==null?void 0:doc.getSelfOrHeaderFooterModel(segmentId).getBody(),link=(_c=(_b=(_a7=body==null?void 0:body.customRanges)==null?void 0:_a7.find(range=>range.rangeId===linkId&&range.rangeType===core.CustomRangeType.HYPERLINK))==null?void 0:_b.properties)==null?void 0:_c.url;return link&&window.open(link,"_blank","noopener noreferrer"),!0}},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",styles={docLink,docLinkType,docLinkContent,docLinkContentError,docLinkUrl,docLinkOperations,docLinkOperation,docLinkOperationError},DocLinkPopup=__name(()=>{var _a7,_b;const hyperLinkService=core.useDependency(DocHyperLinkPopupService),commandService=core.useDependency(core.ICommandService),messageService=core.useDependency(ui.IMessageService),localeService=core.useDependency(core.LocaleService),currentPopup=ui.useObservable(hyperLinkService.showingLink$),univerInstanceService=core.useDependency(core.IUniverInstanceService);if(!currentPopup)return null;const{unitId,linkId,segmentId}=currentPopup,doc=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),body=doc==null?void 0:doc.getSelfOrHeaderFooterModel(segmentId).getBody(),link=(_a7=body==null?void 0:body.customRanges)==null?void 0:_a7.find(range=>range.rangeId===linkId&&range.rangeType===core.CustomRangeType.HYPERLINK);if(!link)return null;const url=(_b=link.properties)==null?void 0:_b.url;return React.createElement("div",{className:styles.docLink,onClick:__name(()=>{hyperLinkService.hideInfoPopup()},"onClick")},React.createElement("div",{className:cs(styles.docLinkContent),onClick:__name(()=>window.open(url),"onClick")},React.createElement("div",{className:styles.docLinkType},React.createElement(LinkSingle,null)),React.createElement(design.Tooltip,{showIfEllipsis:!0,title:url},React.createElement("span",{className:styles.docLinkUrl},url))),React.createElement("div",{className:styles.docLinkOperations},React.createElement("div",{className:cs(styles.docLinkOperation),onClick:__name(()=>{navigator.clipboard.writeText(url),messageService.show({content:localeService.t("docLink.info.coped"),type:design.MessageType.Info})},"onClick")},React.createElement(design.Tooltip,{placement:"bottom",title:localeService.t("docLink.info.copy")},React.createElement(CopySingle,null))),React.createElement("div",{className:styles.docLinkOperation,onClick:__name(()=>{commandService.executeCommand(ShowDocHyperLinkEditPopupOperation.id,{link:currentPopup})},"onClick")},React.createElement(design.Tooltip,{placement:"bottom",title:localeService.t("docLink.info.edit")},React.createElement(WriteSingle,null))),React.createElement("div",{className:styles.docLinkOperation,onClick:__name(()=>{commandService.executeCommand(DeleteDocHyperLinkCommand.id,{unitId,linkId:link.rangeId,segmentId})},"onClick")},React.createElement(design.Tooltip,{placement:"bottom",title:localeService.t("docLink.info.cancel")},React.createElement(UnlinkSingle,null)))))},"DocLinkPopup");DocLinkPopup.componentKey="univer.doc.link-info-popup";var __defProp$5=Object.defineProperty,__getOwnPropDesc$5=Object.getOwnPropertyDescriptor,__decorateClass$5=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$5(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$5(target,key,result),result},"__decorateClass$5"),__decorateParam$5=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$5");const SKIT_PLACEHOLDER=0;var _a;let DocHyperLinkPopupService=(_a=class extends core.Disposable{constructor(_docCanvasPopupManagerService,_textSelectionManagerService,_univerInstanceService){super();__publicField(this,"_editingLink$",new rxjs.BehaviorSubject(null));__publicField(this,"_showingLink$",new rxjs.BehaviorSubject(null));__publicField(this,"editingLink$",this._editingLink$.asObservable());__publicField(this,"showingLink$",this._showingLink$.asObservable());__publicField(this,"_editPopup",null);__publicField(this,"_infoPopup",null);this._docCanvasPopupManagerService=_docCanvasPopupManagerService,this._textSelectionManagerService=_textSelectionManagerService,this._univerInstanceService=_univerInstanceService,this.disposeWithMe(()=>{this._editingLink$.complete(),this._showingLink$.complete()})}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(unitId,linkInfo){var _a7,_b,_c;this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(linkInfo);let activeRange=this._textSelectionManagerService.getActiveTextRange();if(linkInfo){const{unitId:unitId2,linkId,segmentId,segmentPage}=linkInfo,doc=this._univerInstanceService.getUnit(unitId2,core.UniverInstanceType.UNIVER_DOC),range=(_c=(_b=(_a7=doc==null?void 0:doc.getSelfOrHeaderFooterModel(segmentId))==null?void 0:_a7.getBody())==null?void 0:_b.customRanges)==null?void 0:_c.find(i=>i.rangeId===linkId);range&&(activeRange={collapsed:!1,startOffset:range.startIndex+SKIT_PLACEHOLDER,endOffset:range.endIndex+1,segmentId,segmentPage},this._textSelectionManagerService.replaceTextRanges([{startOffset:range.startIndex,endOffset:range.endIndex+1}]))}return activeRange?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(activeRange,{componentKey:DocHyperLinkEdit.componentKey,direction:"bottom"},unitId),this._editPopup):null}hideEditPopup(){var _a7;this._editingLink$.next(null),(_a7=this._editPopup)==null||_a7.dispose()}showInfoPopup(info){var _a7,_b,_c,_d,_e,_f;const{linkId,unitId,segmentId,segmentPage}=info;if(((_a7=this.showing)==null?void 0:_a7.linkId)===linkId&&((_b=this.showing)==null?void 0:_b.unitId)===unitId&&((_c=this.showing)==null?void 0:_c.segmentId)===segmentId&&((_d=this.showing)==null?void 0:_d.segmentPage)===segmentPage)return;this._infoPopup&&this._infoPopup.dispose();const doc=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC);if(!doc)return;const range=(_f=(_e=doc.getSelfOrHeaderFooterModel(info.segmentId).getBody())==null?void 0:_e.customRanges)==null?void 0:_f.find(i=>i.rangeId===linkId);if(this._showingLink$.next({unitId,linkId,segmentId,segmentPage}),!!range)return this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:range.startIndex+SKIT_PLACEHOLDER,endOffset:range.endIndex+1,segmentId:info.segmentId,segmentPage:info.segmentPage},{componentKey:DocLinkPopup.componentKey,direction:"top-center",multipleDirection:"top",onClickOutside:__name(()=>{this.hideInfoPopup()},"onClickOutside")},info.unitId),this._infoPopup}hideInfoPopup(){var _a7;this._showingLink$.next(null),(_a7=this._infoPopup)==null||_a7.dispose()}},__name(_a,"DocHyperLinkPopupService"),_a);DocHyperLinkPopupService=__decorateClass$5([__decorateParam$5(0,core.Inject(docsUi.DocCanvasPopManagerService)),__decorateParam$5(1,core.Inject(docs.DocSelectionManagerService)),__decorateParam$5(2,core.IUniverInstanceService)],DocHyperLinkPopupService);var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4"),_a2;let DocHyperLinkSelectionController=(_a2=class extends core.Disposable{constructor(_commandService,_univerInstanceService,_docHyperLinkService){super(),this._commandService=_commandService,this._univerInstanceService=_univerInstanceService,this._docHyperLinkService=_docHyperLinkService,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(commandInfo=>{var _a7,_b,_c;if(commandInfo.id===docs.SetTextSelectionsOperation.id){const params=commandInfo.params,{unitId,ranges,segmentId}=params,doc=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),primary=ranges[0];if(primary&&doc){const{startOffset,endOffset,collapsed,segmentPage}=primary,customRanges=(_b=(_a7=doc.getSelfOrHeaderFooterModel(segmentId))==null?void 0:_a7.getBody())==null?void 0:_b.customRanges;if(collapsed){const index=(_c=customRanges==null?void 0:customRanges.findIndex(value=>value.startIndex<startOffset&&value.endIndex>endOffset-1))!=null?_c:-1;if(index>-1){const customRange=customRanges[index];this._docHyperLinkService.showInfoPopup({unitId,linkId:customRange.rangeId,segmentId,segmentPage});return}}else if(customRanges==null?void 0:customRanges.find(value=>value.startIndex<=startOffset&&value.endIndex>=endOffset-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}},__name(_a2,"DocHyperLinkSelectionController"),_a2);DocHyperLinkSelectionController=__decorateClass$4([core.OnLifecycle(core.LifecycleStages.Ready,DocHyperLinkSelectionController),__decorateParam$4(0,core.ICommandService),__decorateParam$4(1,core.IUniverInstanceService),__decorateParam$4(2,core.Inject(DocHyperLinkPopupService))],DocHyperLinkSelectionController);var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3"),_a3;let DocHyperLinkEventRenderController=(_a3=class extends core.Disposable{constructor(_context,_docEventManagerService,_commandService,_hyperLinkPopupService,_docSkeletonManagerService,_docSelectionManagerService){super(),this._context=_context,this._docEventManagerService=_docEventManagerService,this._commandService=_commandService,this._hyperLinkPopupService=_hyperLinkPopupService,this._docSkeletonManagerService=_docSkeletonManagerService,this._docSelectionManagerService=_docSelectionManagerService,this._initHover(),this._initClick()}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(ToggleDocHyperLinkInfoPopupOperation.id)}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(ranges=>{var _a7;const link=ranges.find(range=>range.range.rangeType===core.CustomRangeType.HYPERLINK),activeRanges=this._docSelectionManagerService.getTextRanges(),currentSegmentId=activeRanges==null?void 0:activeRanges[0].segmentId;if(((_a7=link==null?void 0:link.segmentId)!=null?_a7:"")!==currentSegmentId){this._hideInfoPopup();return}link?this._commandService.executeCommand(ToggleDocHyperLinkInfoPopupOperation.id,{unitId:this._context.unitId,linkId:link.range.rangeId,segmentId:link.segmentId,segmentPage:link.segmentPageIndex,rangeId:link.range.rangeId}):this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(range=>{const link=range.range;link&&this._commandService.executeCommand(ClickDocHyperLinkOperation.id,{unitId:this._context.unitId,linkId:link.rangeId,segmentId:range.segmentId})}))}},__name(_a3,"DocHyperLinkEventRenderController"),_a3);DocHyperLinkEventRenderController=__decorateClass$3([__decorateParam$3(1,core.Inject(docsUi.DocEventManagerService)),__decorateParam$3(2,core.ICommandService),__decorateParam$3(3,core.Inject(DocHyperLinkPopupService)),__decorateParam$3(4,core.Inject(docs.DocSkeletonManagerService)),__decorateParam$3(5,core.Inject(docs.DocSelectionManagerService))],DocHyperLinkEventRenderController);var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2"),_a4;let DocHyperLinkRenderController=(_a4=class extends core.Disposable{constructor(_context,_docInterceptorService,_hyperLinkService,_docRenderController){super(),this._context=_context,this._docInterceptorService=_docInterceptorService,this._hyperLinkService=_hyperLinkService,this._docRenderController=_docRenderController,this._init(),this._initReRender()}_init(){this._docInterceptorService.intercept(docs.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:__name((data,pos,next)=>{if(!data)return next(data);const{unitId}=pos,activeLink=this._hyperLinkService.showing,{linkId,unitId:linkUnitId}=activeLink||{},isActive=linkUnitId===unitId&&data.rangeId===linkId;return next({...data,active:isActive})},"handler")})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(rxjs.distinctUntilChanged((prev,aft)=>(prev==null?void 0:prev.linkId)===(aft==null?void 0:aft.linkId)&&(prev==null?void 0:prev.unitId)===(aft==null?void 0:aft.unitId)),rxjs.pairwise()).subscribe(([preLink,link])=>{link?link.unitId===this._context.unitId&&this._docRenderController.reRender(link.unitId):preLink&&preLink.unitId===this._context.unitId&&this._docRenderController.reRender(preLink.unitId)}))}},__name(_a4,"DocHyperLinkRenderController"),_a4);DocHyperLinkRenderController=__decorateClass$2([__decorateParam$2(1,core.Inject(docs.DocInterceptorService)),__decorateParam$2(2,core.Inject(DocHyperLinkPopupService)),__decorateParam$2(3,core.Inject(docsUi.DocRenderController))],DocHyperLinkRenderController);const DOC_LINK_ICON="doc-hyper-link-icon";function AddHyperLinkMenuItemFactory(accessor){return{id:ShowDocHyperLinkEditPopupOperation.id,type:ui.MenuItemType.BUTTON,icon:DOC_LINK_ICON,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC),disabled$:new rxjs.Observable(function(subscribe){const observer=accessor.get(docs.DocSelectionManagerService).textSelection$.pipe(rxjs.debounceTime(16)).subscribe(()=>{subscribe.next(shouldDisableAddLink(accessor))});return()=>{observer.unsubscribe()}})}}__name(AddHyperLinkMenuItemFactory,"AddHyperLinkMenuItemFactory");const addLinkShortcut={id:ShowDocHyperLinkEditPopupOperation.id,binding:ui.MetaKeys.CTRL_COMMAND|ui.KeyCode.K,description:"docLink.menu.tooltip",preconditions:docsUi.whenDocAndEditorFocused},menuSchema={[ui.RibbonStartGroup.OTHERS]:{[ShowDocHyperLinkEditPopupOperation.id]:{order:0,menuItemFactory:AddHyperLinkMenuItemFactory}},[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.DATA]:{[ShowDocHyperLinkEditPopupOperation.id]:{order:0,menuItemFactory:AddHyperLinkMenuItemFactory}}}};var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1"),_a5;let DocHyperLinkUIController=(_a5=class extends core.Disposable{constructor(_componentManager,_commandService,_menuManagerService,_injector,_shortcutService){super(),this._componentManager=_componentManager,this._commandService=_commandService,this._menuManagerService=_menuManagerService,this._injector=_injector,this._shortcutService=_shortcutService,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[DocHyperLinkEdit,DocHyperLinkEdit.componentKey],[DocLinkPopup,DocLinkPopup.componentKey],[LinkSingle,DOC_LINK_ICON]].forEach(([comp,key])=>{this._componentManager.register(key,comp)})}_initCommands(){[AddDocHyperLinkCommand,UpdateDocHyperLinkCommand,DeleteDocHyperLinkCommand,ShowDocHyperLinkEditPopupOperation,ToggleDocHyperLinkInfoPopupOperation,ClickDocHyperLinkOperation].forEach(command=>{this._commandService.registerCommand(command)})}_initShortcut(){[addLinkShortcut].forEach(shortcut=>{this._shortcutService.registerShortcut(shortcut)})}_initMenus(){this._menuManagerService.mergeMenu(menuSchema)}},__name(_a5,"DocHyperLinkUIController"),_a5);DocHyperLinkUIController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,DocHyperLinkUIController),__decorateParam$1(0,core.Inject(ui.ComponentManager)),__decorateParam$1(1,core.ICommandService),__decorateParam$1(2,ui.IMenuManagerService),__decorateParam$1(3,core.Inject(core.Injector)),__decorateParam$1(4,ui.IShortcutService)],DocHyperLinkUIController);const DOC_HYPER_LINK_UI_PLUGIN="DOC_HYPER_LINK_UI_PLUGIN";var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField"),_a6;exports.UniverDocsHyperLinkUIPlugin=(_a6=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_renderManagerSrv,_configService){super(),this._config=_config,this._injector=_injector,this._renderManagerSrv=_renderManagerSrv,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[DocHyperLinkPopupService],[DocHyperLinkUIController],[DocHyperLinkSelectionController]].forEach(dep=>{this._injector.add(dep)})}onRendered(){this._initRenderModule()}_initRenderModule(){[[DocHyperLinkRenderController],[DocHyperLinkEventRenderController]].forEach(dep=>{this._renderManagerSrv.registerRenderModule(core.UniverInstanceType.UNIVER_DOC,dep)})}},__name(_a6,"UniverDocsHyperLinkUIPlugin"),_a6);__publicField2(exports.UniverDocsHyperLinkUIPlugin,"pluginName",DOC_HYPER_LINK_UI_PLUGIN);__publicField2(exports.UniverDocsHyperLinkUIPlugin,"type",core.UniverInstanceType.UNIVER_DOC);exports.UniverDocsHyperLinkUIPlugin=__decorateClass([core.DependentOn(docsHyperLink.UniverDocsHyperLinkPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,engineRender.IRenderManagerService),__decorateParam(3,core.IConfigService)],exports.UniverDocsHyperLinkUIPlugin);
|
package/lib/es/index.js
CHANGED
|
@@ -2,17 +2,187 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { CommandType, ICommandService, generateRandomId, CustomRangeType, IUniverInstanceService, UniverInstanceType, getBodySlice, DataStreamTreeTokenType,
|
|
6
|
-
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
5
|
+
import { CommandType, ICommandService, generateRandomId, CustomRangeType, IUniverInstanceService, UniverInstanceType, getBodySlice, DataStreamTreeTokenType, useDependency, LocaleService, useObservable, Tools, BuildTextUtils, Disposable, Inject, OnLifecycle, LifecycleStages, Injector, DependentOn, Plugin, IConfigService } from "@univerjs/core";
|
|
7
6
|
import { UniverDocsHyperLinkPlugin } from "@univerjs/docs-hyper-link";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
7
|
+
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
8
|
+
import { DocSelectionManagerService, SetTextSelectionsOperation, DocSkeletonManagerService, DocInterceptorService, DOC_INTERCEPTOR_POINT } from "@univerjs/docs";
|
|
9
|
+
import { addCustomRangeBySelectionFactory, replaceSelectionFactory, DocSelectionRenderService, deleteCustomRangeFactory, DocCanvasPopManagerService, DocEventManagerService, DocRenderController, whenDocAndEditorFocused } from "@univerjs/docs-ui";
|
|
10
|
+
import { BehaviorSubject, distinctUntilChanged, pairwise, Observable, debounceTime } from "rxjs";
|
|
11
|
+
import { FormLayout, Input, Button, Tooltip, MessageType } from "@univerjs/design";
|
|
12
|
+
import { KeyCode, IMessageService, useObservable as useObservable$1, MetaKeys, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, ContextMenuPosition, ContextMenuGroup, ComponentManager, IMenuManagerService, IShortcutService } from "@univerjs/ui";
|
|
13
|
+
import React, { useState, useEffect, forwardRef, useRef, createElement } from "react";
|
|
14
14
|
import cs from "clsx";
|
|
15
|
-
const
|
|
15
|
+
const PLUGIN_CONFIG_KEY = "docs-hyper-link-ui.config", defaultPluginConfig = {}, AddDocHyperLinkCommand = {
|
|
16
|
+
type: CommandType.COMMAND,
|
|
17
|
+
id: "docs.command.add-hyper-link",
|
|
18
|
+
async handler(accessor, params) {
|
|
19
|
+
if (!params)
|
|
20
|
+
return !1;
|
|
21
|
+
const { payload, unitId, selection } = params, commandService = accessor.get(ICommandService), id = generateRandomId(), doMutation = addCustomRangeBySelectionFactory(
|
|
22
|
+
accessor,
|
|
23
|
+
{
|
|
24
|
+
rangeId: id,
|
|
25
|
+
rangeType: CustomRangeType.HYPERLINK,
|
|
26
|
+
properties: {
|
|
27
|
+
url: payload
|
|
28
|
+
},
|
|
29
|
+
unitId,
|
|
30
|
+
selection
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
return doMutation ? commandService.syncExecuteCommand(doMutation.id, doMutation.params) : !1;
|
|
34
|
+
}
|
|
35
|
+
}, UpdateDocHyperLinkCommand = {
|
|
36
|
+
id: "docs.command.update-hyper-link",
|
|
37
|
+
type: CommandType.COMMAND,
|
|
38
|
+
handler(accessor, params) {
|
|
39
|
+
var _a7;
|
|
40
|
+
if (!params)
|
|
41
|
+
return !1;
|
|
42
|
+
const { unitId, payload, segmentId } = params, commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), currentSelection = accessor.get(DocSelectionManagerService).getActiveTextRange(), doc = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
43
|
+
if (!currentSelection || !doc)
|
|
44
|
+
return !1;
|
|
45
|
+
const newId = generateRandomId(), textRun = (_a7 = getBodySlice(doc.getSelfOrHeaderFooterModel(segmentId).getBody(), currentSelection.startOffset, currentSelection.endOffset).textRuns) == null ? void 0 : _a7[0];
|
|
46
|
+
textRun && (textRun.ed = params.label.length + 1);
|
|
47
|
+
const replaceSelection = replaceSelectionFactory(accessor, {
|
|
48
|
+
unitId,
|
|
49
|
+
body: {
|
|
50
|
+
dataStream: `${DataStreamTreeTokenType.CUSTOM_RANGE_START}${params.label}${DataStreamTreeTokenType.CUSTOM_RANGE_END}`,
|
|
51
|
+
customRanges: [{
|
|
52
|
+
rangeId: newId,
|
|
53
|
+
rangeType: CustomRangeType.HYPERLINK,
|
|
54
|
+
startIndex: 0,
|
|
55
|
+
endIndex: params.label.length + 1,
|
|
56
|
+
properties: {
|
|
57
|
+
url: payload
|
|
58
|
+
}
|
|
59
|
+
}],
|
|
60
|
+
textRuns: textRun ? [textRun] : void 0
|
|
61
|
+
},
|
|
62
|
+
selection: {
|
|
63
|
+
startOffset: currentSelection.startOffset,
|
|
64
|
+
endOffset: currentSelection.endOffset,
|
|
65
|
+
collapsed: !1,
|
|
66
|
+
segmentId
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return replaceSelection ? commandService.syncExecuteCommand(replaceSelection.id, replaceSelection.params) : !1;
|
|
70
|
+
}
|
|
71
|
+
}, 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", styles$1 = {
|
|
72
|
+
docsLinkEdit,
|
|
73
|
+
docsLinkEditTitle,
|
|
74
|
+
docsLinkEditClose,
|
|
75
|
+
docsLinkEditButtons,
|
|
76
|
+
docsLinkEditButton
|
|
77
|
+
};
|
|
78
|
+
function hasProtocol(urlString) {
|
|
79
|
+
return /^[a-zA-Z]+:\/\//.test(urlString);
|
|
80
|
+
}
|
|
81
|
+
__name(hasProtocol, "hasProtocol");
|
|
82
|
+
function isEmail(url) {
|
|
83
|
+
return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url);
|
|
84
|
+
}
|
|
85
|
+
__name(isEmail, "isEmail");
|
|
86
|
+
function transformUrl(urlStr) {
|
|
87
|
+
return hasProtocol(urlStr) ? urlStr : isEmail(urlStr) ? `mailto://${urlStr}` : `https://${urlStr}`;
|
|
88
|
+
}
|
|
89
|
+
__name(transformUrl, "transformUrl");
|
|
90
|
+
const DocHyperLinkEdit = /* @__PURE__ */ __name(() => {
|
|
91
|
+
var _a7;
|
|
92
|
+
const hyperLinkService = useDependency(DocHyperLinkPopupService), localeService = useDependency(LocaleService), editing = useObservable(hyperLinkService.editingLink$), commandService = useDependency(ICommandService), univerInstanceService = useDependency(IUniverInstanceService), renderManagerService = useDependency(IRenderManagerService), docSelectionManagerService = useDependency(DocSelectionManagerService), [link, setLink] = useState(""), [label, setLabel] = useState(""), [showError, setShowError] = useState(!1), isLegal = Tools.isLegalUrl(link), doc = editing ? univerInstanceService.getUnit(editing.unitId, UniverInstanceType.UNIVER_DOC) : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), docSelectionRenderService = (_a7 = renderManagerService.getRenderById(doc.getUnitId())) == null ? void 0 : _a7.with(DocSelectionRenderService);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
var _a8, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
95
|
+
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
96
|
+
if (!activeRange)
|
|
97
|
+
return;
|
|
98
|
+
if (editing) {
|
|
99
|
+
const body = (_a8 = doc == null ? void 0 : doc.getSelfOrHeaderFooterModel(editing.segmentId)) == null ? void 0 : _a8.getBody(), matchedRange2 = (_b = body == null ? void 0 : body.customRanges) == null ? void 0 : _b.find((i) => (editing == null ? void 0 : editing.linkId) === i.rangeId);
|
|
100
|
+
doc && matchedRange2 && (setLink((_d = (_c = matchedRange2.properties) == null ? void 0 : _c.url) != null ? _d : ""), setLabel(BuildTextUtils.transform.getPlainText(getBodySlice(body, matchedRange2.startIndex, matchedRange2.endIndex).dataStream)));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const matchedRange = (_g = (_f = (_e = doc == null ? void 0 : doc.getSelfOrHeaderFooterModel(activeRange.segmentId)) == null ? void 0 : _e.getBody()) == null ? void 0 : _f.customRanges) == null ? void 0 : _g.find((i) => Math.max(activeRange.startOffset, i.startIndex) <= Math.min(activeRange.endOffset - 1, i.endIndex));
|
|
104
|
+
doc && matchedRange && setLink((_i = (_h = matchedRange == null ? void 0 : matchedRange.properties) == null ? void 0 : _h.url) != null ? _i : "");
|
|
105
|
+
}, [doc, editing, docSelectionManagerService, univerInstanceService]), useEffect(() => (docSelectionRenderService && docSelectionRenderService.blurEditor(), () => {
|
|
106
|
+
docSelectionRenderService && docSelectionRenderService.focusEditor();
|
|
107
|
+
}), [docSelectionRenderService]);
|
|
108
|
+
const handleCancel = /* @__PURE__ */ __name(() => {
|
|
109
|
+
hyperLinkService.hideEditPopup();
|
|
110
|
+
}, "handleCancel"), handleConfirm = /* @__PURE__ */ __name(() => {
|
|
111
|
+
if (setShowError(!0), !isLegal || !doc)
|
|
112
|
+
return;
|
|
113
|
+
const linkFinal = transformUrl(link);
|
|
114
|
+
if (!editing)
|
|
115
|
+
commandService.executeCommand(AddDocHyperLinkCommand.id, {
|
|
116
|
+
unitId: doc.getUnitId(),
|
|
117
|
+
payload: linkFinal
|
|
118
|
+
});
|
|
119
|
+
else {
|
|
120
|
+
if (!label)
|
|
121
|
+
return;
|
|
122
|
+
commandService.executeCommand(UpdateDocHyperLinkCommand.id, {
|
|
123
|
+
unitId: doc.getUnitId(),
|
|
124
|
+
payload: linkFinal,
|
|
125
|
+
linkId: editing.linkId,
|
|
126
|
+
label,
|
|
127
|
+
segmentId: editing.segmentId
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
hyperLinkService.hideEditPopup();
|
|
131
|
+
}, "handleConfirm");
|
|
132
|
+
if (doc)
|
|
133
|
+
return /* @__PURE__ */ React.createElement("div", { className: styles$1.docsLinkEdit }, /* @__PURE__ */ React.createElement("div", null, editing ? /* @__PURE__ */ React.createElement(
|
|
134
|
+
FormLayout,
|
|
135
|
+
{
|
|
136
|
+
label: localeService.t("docLink.edit.label"),
|
|
137
|
+
error: showError && !label ? localeService.t("docLink.edit.labelError") : ""
|
|
138
|
+
},
|
|
139
|
+
/* @__PURE__ */ React.createElement(
|
|
140
|
+
Input,
|
|
141
|
+
{
|
|
142
|
+
value: label,
|
|
143
|
+
onChange: setLabel,
|
|
144
|
+
autoFocus: !0,
|
|
145
|
+
onKeyDown: /* @__PURE__ */ __name((evt) => {
|
|
146
|
+
evt.keyCode === KeyCode.ENTER && handleConfirm();
|
|
147
|
+
}, "onKeyDown")
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
) : null, /* @__PURE__ */ React.createElement(
|
|
151
|
+
FormLayout,
|
|
152
|
+
{
|
|
153
|
+
label: localeService.t("docLink.edit.address"),
|
|
154
|
+
error: showError && !isLegal ? localeService.t("docLink.edit.addressError") : ""
|
|
155
|
+
},
|
|
156
|
+
/* @__PURE__ */ React.createElement(
|
|
157
|
+
Input,
|
|
158
|
+
{
|
|
159
|
+
value: link,
|
|
160
|
+
onChange: setLink,
|
|
161
|
+
autoFocus: !0,
|
|
162
|
+
onKeyDown: /* @__PURE__ */ __name((evt) => {
|
|
163
|
+
evt.keyCode === KeyCode.ENTER && handleConfirm();
|
|
164
|
+
}, "onKeyDown")
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
)), /* @__PURE__ */ React.createElement("div", { className: styles$1.docsLinkEditButtons }, /* @__PURE__ */ React.createElement(
|
|
168
|
+
Button,
|
|
169
|
+
{
|
|
170
|
+
className: styles$1.docsLinkEditButton,
|
|
171
|
+
onClick: handleCancel
|
|
172
|
+
},
|
|
173
|
+
localeService.t("docLink.edit.cancel")
|
|
174
|
+
), /* @__PURE__ */ React.createElement(
|
|
175
|
+
Button,
|
|
176
|
+
{
|
|
177
|
+
disabled: !link,
|
|
178
|
+
className: styles$1.docsLinkEditButton,
|
|
179
|
+
type: "primary",
|
|
180
|
+
onClick: handleConfirm
|
|
181
|
+
},
|
|
182
|
+
localeService.t("docLink.edit.confirm")
|
|
183
|
+
)));
|
|
184
|
+
}, "DocHyperLinkEdit");
|
|
185
|
+
DocHyperLinkEdit.componentKey = "docs-hyper-link-edit";
|
|
16
186
|
var __assign = function() {
|
|
17
187
|
return __assign = Object.assign || function(t) {
|
|
18
188
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -92,63 +262,7 @@ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width:
|
|
|
92
262
|
}));
|
|
93
263
|
});
|
|
94
264
|
WriteSingle.displayName = "WriteSingle";
|
|
95
|
-
const
|
|
96
|
-
type: CommandType.COMMAND,
|
|
97
|
-
id: "docs.command.add-hyper-link",
|
|
98
|
-
async handler(accessor, params) {
|
|
99
|
-
if (!params)
|
|
100
|
-
return !1;
|
|
101
|
-
const { payload, unitId, selection } = params, commandService = accessor.get(ICommandService), id = generateRandomId(), doMutation = addCustomRangeBySelectionFactory(
|
|
102
|
-
accessor,
|
|
103
|
-
{
|
|
104
|
-
rangeId: id,
|
|
105
|
-
rangeType: CustomRangeType.HYPERLINK,
|
|
106
|
-
properties: {
|
|
107
|
-
url: payload
|
|
108
|
-
},
|
|
109
|
-
unitId,
|
|
110
|
-
selection
|
|
111
|
-
}
|
|
112
|
-
);
|
|
113
|
-
return doMutation ? commandService.syncExecuteCommand(doMutation.id, doMutation.params) : !1;
|
|
114
|
-
}
|
|
115
|
-
}, UpdateDocHyperLinkCommand = {
|
|
116
|
-
id: "docs.command.update-hyper-link",
|
|
117
|
-
type: CommandType.COMMAND,
|
|
118
|
-
handler(accessor, params) {
|
|
119
|
-
var _a7;
|
|
120
|
-
if (!params)
|
|
121
|
-
return !1;
|
|
122
|
-
const { unitId, payload, segmentId } = params, commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), currentSelection = accessor.get(DocSelectionManagerService).getActiveTextRange(), doc = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
123
|
-
if (!currentSelection || !doc)
|
|
124
|
-
return !1;
|
|
125
|
-
const newId = generateRandomId(), textRun = (_a7 = getBodySlice(doc.getSelfOrHeaderFooterModel(segmentId).getBody(), currentSelection.startOffset, currentSelection.endOffset).textRuns) == null ? void 0 : _a7[0];
|
|
126
|
-
textRun && (textRun.ed = params.label.length + 1);
|
|
127
|
-
const replaceSelection = replaceSelectionFactory(accessor, {
|
|
128
|
-
unitId,
|
|
129
|
-
body: {
|
|
130
|
-
dataStream: `${DataStreamTreeTokenType.CUSTOM_RANGE_START}${params.label}${DataStreamTreeTokenType.CUSTOM_RANGE_END}`,
|
|
131
|
-
customRanges: [{
|
|
132
|
-
rangeId: newId,
|
|
133
|
-
rangeType: CustomRangeType.HYPERLINK,
|
|
134
|
-
startIndex: 0,
|
|
135
|
-
endIndex: params.label.length + 1,
|
|
136
|
-
properties: {
|
|
137
|
-
url: payload
|
|
138
|
-
}
|
|
139
|
-
}],
|
|
140
|
-
textRuns: textRun ? [textRun] : void 0
|
|
141
|
-
},
|
|
142
|
-
selection: {
|
|
143
|
-
startOffset: currentSelection.startOffset,
|
|
144
|
-
endOffset: currentSelection.endOffset,
|
|
145
|
-
collapsed: !1,
|
|
146
|
-
segmentId
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
return replaceSelection ? commandService.syncExecuteCommand(replaceSelection.id, replaceSelection.params) : !1;
|
|
150
|
-
}
|
|
151
|
-
}, DeleteDocHyperLinkCommand = {
|
|
265
|
+
const DeleteDocHyperLinkCommand = {
|
|
152
266
|
type: CommandType.COMMAND,
|
|
153
267
|
id: "docs.command.delete-hyper-link",
|
|
154
268
|
async handler(accessor, params) {
|
|
@@ -204,7 +318,7 @@ const AddDocHyperLinkCommand = {
|
|
|
204
318
|
const { unitId, linkId, segmentId } = params, doc = accessor.get(IUniverInstanceService).getUnit(unitId, UniverInstanceType.UNIVER_DOC), body = doc == null ? void 0 : doc.getSelfOrHeaderFooterModel(segmentId).getBody(), link = (_c = (_b = (_a7 = body == null ? void 0 : body.customRanges) == null ? void 0 : _a7.find((range) => range.rangeId === linkId && range.rangeType === CustomRangeType.HYPERLINK)) == null ? void 0 : _b.properties) == null ? void 0 : _c.url;
|
|
205
319
|
return link && window.open(link, "_blank", "noopener noreferrer"), !0;
|
|
206
320
|
}
|
|
207
|
-
}, 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", styles
|
|
321
|
+
}, 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", styles = {
|
|
208
322
|
docLink,
|
|
209
323
|
docLinkType,
|
|
210
324
|
docLinkContent,
|
|
@@ -215,7 +329,7 @@ const AddDocHyperLinkCommand = {
|
|
|
215
329
|
docLinkOperationError
|
|
216
330
|
}, DocLinkPopup = /* @__PURE__ */ __name(() => {
|
|
217
331
|
var _a7, _b;
|
|
218
|
-
const hyperLinkService = useDependency(DocHyperLinkPopupService), commandService = useDependency(ICommandService), messageService = useDependency(IMessageService), localeService = useDependency(LocaleService), currentPopup = useObservable(hyperLinkService.showingLink$), univerInstanceService = useDependency(IUniverInstanceService);
|
|
332
|
+
const hyperLinkService = useDependency(DocHyperLinkPopupService), commandService = useDependency(ICommandService), messageService = useDependency(IMessageService), localeService = useDependency(LocaleService), currentPopup = useObservable$1(hyperLinkService.showingLink$), univerInstanceService = useDependency(IUniverInstanceService);
|
|
219
333
|
if (!currentPopup)
|
|
220
334
|
return null;
|
|
221
335
|
const { unitId, linkId, segmentId } = currentPopup, doc = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC), body = doc == null ? void 0 : doc.getSelfOrHeaderFooterModel(segmentId).getBody(), link = (_a7 = body == null ? void 0 : body.customRanges) == null ? void 0 : _a7.find((range) => range.rangeId === linkId && range.rangeType === CustomRangeType.HYPERLINK);
|
|
@@ -225,16 +339,16 @@ const AddDocHyperLinkCommand = {
|
|
|
225
339
|
return /* @__PURE__ */ React.createElement(
|
|
226
340
|
"div",
|
|
227
341
|
{
|
|
228
|
-
className: styles
|
|
342
|
+
className: styles.docLink,
|
|
229
343
|
onClick: /* @__PURE__ */ __name(() => {
|
|
230
344
|
hyperLinkService.hideInfoPopup();
|
|
231
345
|
}, "onClick")
|
|
232
346
|
},
|
|
233
|
-
/* @__PURE__ */ React.createElement("div", { className: cs(styles
|
|
234
|
-
/* @__PURE__ */ React.createElement("div", { className: styles
|
|
347
|
+
/* @__PURE__ */ React.createElement("div", { className: cs(styles.docLinkContent), onClick: /* @__PURE__ */ __name(() => window.open(url), "onClick") }, /* @__PURE__ */ React.createElement("div", { className: styles.docLinkType }, /* @__PURE__ */ React.createElement(LinkSingle, null)), /* @__PURE__ */ React.createElement(Tooltip, { showIfEllipsis: !0, title: url }, /* @__PURE__ */ React.createElement("span", { className: styles.docLinkUrl }, url))),
|
|
348
|
+
/* @__PURE__ */ React.createElement("div", { className: styles.docLinkOperations }, /* @__PURE__ */ React.createElement(
|
|
235
349
|
"div",
|
|
236
350
|
{
|
|
237
|
-
className: cs(styles
|
|
351
|
+
className: cs(styles.docLinkOperation),
|
|
238
352
|
onClick: /* @__PURE__ */ __name(() => {
|
|
239
353
|
navigator.clipboard.writeText(url), messageService.show({
|
|
240
354
|
content: localeService.t("docLink.info.coped"),
|
|
@@ -246,7 +360,7 @@ const AddDocHyperLinkCommand = {
|
|
|
246
360
|
), /* @__PURE__ */ React.createElement(
|
|
247
361
|
"div",
|
|
248
362
|
{
|
|
249
|
-
className: styles
|
|
363
|
+
className: styles.docLinkOperation,
|
|
250
364
|
onClick: /* @__PURE__ */ __name(() => {
|
|
251
365
|
commandService.executeCommand(ShowDocHyperLinkEditPopupOperation.id, {
|
|
252
366
|
link: currentPopup
|
|
@@ -257,7 +371,7 @@ const AddDocHyperLinkCommand = {
|
|
|
257
371
|
), /* @__PURE__ */ React.createElement(
|
|
258
372
|
"div",
|
|
259
373
|
{
|
|
260
|
-
className: styles
|
|
374
|
+
className: styles.docLinkOperation,
|
|
261
375
|
onClick: /* @__PURE__ */ __name(() => {
|
|
262
376
|
commandService.executeCommand(DeleteDocHyperLinkCommand.id, {
|
|
263
377
|
unitId,
|
|
@@ -367,215 +481,12 @@ DocHyperLinkPopupService = __decorateClass$5([
|
|
|
367
481
|
__decorateParam$5(1, Inject(DocSelectionManagerService)),
|
|
368
482
|
__decorateParam$5(2, IUniverInstanceService)
|
|
369
483
|
], DocHyperLinkPopupService);
|
|
370
|
-
const 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", styles = {
|
|
371
|
-
docsLinkEdit,
|
|
372
|
-
docsLinkEditTitle,
|
|
373
|
-
docsLinkEditClose,
|
|
374
|
-
docsLinkEditButtons,
|
|
375
|
-
docsLinkEditButton
|
|
376
|
-
};
|
|
377
|
-
function hasProtocol(urlString) {
|
|
378
|
-
return /^[a-zA-Z]+:\/\//.test(urlString);
|
|
379
|
-
}
|
|
380
|
-
__name(hasProtocol, "hasProtocol");
|
|
381
|
-
function isEmail(url) {
|
|
382
|
-
return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url);
|
|
383
|
-
}
|
|
384
|
-
__name(isEmail, "isEmail");
|
|
385
|
-
function transformUrl(urlStr) {
|
|
386
|
-
return hasProtocol(urlStr) ? urlStr : isEmail(urlStr) ? `mailto://${urlStr}` : `https://${urlStr}`;
|
|
387
|
-
}
|
|
388
|
-
__name(transformUrl, "transformUrl");
|
|
389
|
-
const DocHyperLinkEdit = /* @__PURE__ */ __name(() => {
|
|
390
|
-
var _a7;
|
|
391
|
-
const hyperLinkService = useDependency(DocHyperLinkPopupService), localeService = useDependency(LocaleService), editing = useObservable$1(hyperLinkService.editingLink$), commandService = useDependency(ICommandService), univerInstanceService = useDependency(IUniverInstanceService), renderManagerService = useDependency(IRenderManagerService), docSelectionManagerService = useDependency(DocSelectionManagerService), [link, setLink] = useState(""), [label, setLabel] = useState(""), [showError, setShowError] = useState(!1), isLegal = Tools.isLegalUrl(link), doc = editing ? univerInstanceService.getUnit(editing.unitId, UniverInstanceType.UNIVER_DOC) : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), docSelectionRenderService = (_a7 = renderManagerService.getRenderById(doc.getUnitId())) == null ? void 0 : _a7.with(DocSelectionRenderService);
|
|
392
|
-
useEffect(() => {
|
|
393
|
-
var _a8, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
394
|
-
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
395
|
-
if (!activeRange)
|
|
396
|
-
return;
|
|
397
|
-
if (editing) {
|
|
398
|
-
const body = (_a8 = doc == null ? void 0 : doc.getSelfOrHeaderFooterModel(editing.segmentId)) == null ? void 0 : _a8.getBody(), matchedRange2 = (_b = body == null ? void 0 : body.customRanges) == null ? void 0 : _b.find((i) => (editing == null ? void 0 : editing.linkId) === i.rangeId);
|
|
399
|
-
doc && matchedRange2 && (setLink((_d = (_c = matchedRange2.properties) == null ? void 0 : _c.url) != null ? _d : ""), setLabel(BuildTextUtils.transform.getPlainText(getBodySlice(body, matchedRange2.startIndex, matchedRange2.endIndex).dataStream)));
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
const matchedRange = (_g = (_f = (_e = doc == null ? void 0 : doc.getSelfOrHeaderFooterModel(activeRange.segmentId)) == null ? void 0 : _e.getBody()) == null ? void 0 : _f.customRanges) == null ? void 0 : _g.find((i) => Math.max(activeRange.startOffset, i.startIndex) <= Math.min(activeRange.endOffset - 1, i.endIndex));
|
|
403
|
-
doc && matchedRange && setLink((_i = (_h = matchedRange == null ? void 0 : matchedRange.properties) == null ? void 0 : _h.url) != null ? _i : "");
|
|
404
|
-
}, [doc, editing, docSelectionManagerService, univerInstanceService]), useEffect(() => (docSelectionRenderService && docSelectionRenderService.blurEditor(), () => {
|
|
405
|
-
docSelectionRenderService && docSelectionRenderService.focusEditor();
|
|
406
|
-
}), [docSelectionRenderService]);
|
|
407
|
-
const handleCancel = /* @__PURE__ */ __name(() => {
|
|
408
|
-
hyperLinkService.hideEditPopup();
|
|
409
|
-
}, "handleCancel"), handleConfirm = /* @__PURE__ */ __name(() => {
|
|
410
|
-
if (setShowError(!0), !isLegal || !doc)
|
|
411
|
-
return;
|
|
412
|
-
const linkFinal = transformUrl(link);
|
|
413
|
-
if (!editing)
|
|
414
|
-
commandService.executeCommand(AddDocHyperLinkCommand.id, {
|
|
415
|
-
unitId: doc.getUnitId(),
|
|
416
|
-
payload: linkFinal
|
|
417
|
-
});
|
|
418
|
-
else {
|
|
419
|
-
if (!label)
|
|
420
|
-
return;
|
|
421
|
-
commandService.executeCommand(UpdateDocHyperLinkCommand.id, {
|
|
422
|
-
unitId: doc.getUnitId(),
|
|
423
|
-
payload: linkFinal,
|
|
424
|
-
linkId: editing.linkId,
|
|
425
|
-
label,
|
|
426
|
-
segmentId: editing.segmentId
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
hyperLinkService.hideEditPopup();
|
|
430
|
-
}, "handleConfirm");
|
|
431
|
-
if (doc)
|
|
432
|
-
return /* @__PURE__ */ React.createElement("div", { className: styles.docsLinkEdit }, /* @__PURE__ */ React.createElement("div", null, editing ? /* @__PURE__ */ React.createElement(
|
|
433
|
-
FormLayout,
|
|
434
|
-
{
|
|
435
|
-
label: localeService.t("docLink.edit.label"),
|
|
436
|
-
error: showError && !label ? localeService.t("docLink.edit.labelError") : ""
|
|
437
|
-
},
|
|
438
|
-
/* @__PURE__ */ React.createElement(
|
|
439
|
-
Input,
|
|
440
|
-
{
|
|
441
|
-
value: label,
|
|
442
|
-
onChange: setLabel,
|
|
443
|
-
autoFocus: !0,
|
|
444
|
-
onKeyDown: /* @__PURE__ */ __name((evt) => {
|
|
445
|
-
evt.keyCode === KeyCode.ENTER && handleConfirm();
|
|
446
|
-
}, "onKeyDown")
|
|
447
|
-
}
|
|
448
|
-
)
|
|
449
|
-
) : null, /* @__PURE__ */ React.createElement(
|
|
450
|
-
FormLayout,
|
|
451
|
-
{
|
|
452
|
-
label: localeService.t("docLink.edit.address"),
|
|
453
|
-
error: showError && !isLegal ? localeService.t("docLink.edit.addressError") : ""
|
|
454
|
-
},
|
|
455
|
-
/* @__PURE__ */ React.createElement(
|
|
456
|
-
Input,
|
|
457
|
-
{
|
|
458
|
-
value: link,
|
|
459
|
-
onChange: setLink,
|
|
460
|
-
autoFocus: !0,
|
|
461
|
-
onKeyDown: /* @__PURE__ */ __name((evt) => {
|
|
462
|
-
evt.keyCode === KeyCode.ENTER && handleConfirm();
|
|
463
|
-
}, "onKeyDown")
|
|
464
|
-
}
|
|
465
|
-
)
|
|
466
|
-
)), /* @__PURE__ */ React.createElement("div", { className: styles.docsLinkEditButtons }, /* @__PURE__ */ React.createElement(
|
|
467
|
-
Button,
|
|
468
|
-
{
|
|
469
|
-
className: styles.docsLinkEditButton,
|
|
470
|
-
onClick: handleCancel
|
|
471
|
-
},
|
|
472
|
-
localeService.t("docLink.edit.cancel")
|
|
473
|
-
), /* @__PURE__ */ React.createElement(
|
|
474
|
-
Button,
|
|
475
|
-
{
|
|
476
|
-
disabled: !link,
|
|
477
|
-
className: styles.docsLinkEditButton,
|
|
478
|
-
type: "primary",
|
|
479
|
-
onClick: handleConfirm
|
|
480
|
-
},
|
|
481
|
-
localeService.t("docLink.edit.confirm")
|
|
482
|
-
)));
|
|
483
|
-
}, "DocHyperLinkEdit");
|
|
484
|
-
DocHyperLinkEdit.componentKey = "docs-hyper-link-edit";
|
|
485
|
-
const DOC_LINK_ICON = "doc-hyper-link-icon";
|
|
486
|
-
function AddHyperLinkMenuItemFactory(accessor) {
|
|
487
|
-
return {
|
|
488
|
-
id: ShowDocHyperLinkEditPopupOperation.id,
|
|
489
|
-
type: MenuItemType.BUTTON,
|
|
490
|
-
icon: DOC_LINK_ICON,
|
|
491
|
-
title: "docLink.menu.tooltip",
|
|
492
|
-
tooltip: "docLink.menu.tooltip",
|
|
493
|
-
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
|
|
494
|
-
disabled$: new Observable(function(subscribe) {
|
|
495
|
-
const observer = accessor.get(DocSelectionManagerService).textSelection$.pipe(debounceTime(16)).subscribe(() => {
|
|
496
|
-
subscribe.next(shouldDisableAddLink(accessor));
|
|
497
|
-
});
|
|
498
|
-
return () => {
|
|
499
|
-
observer.unsubscribe();
|
|
500
|
-
};
|
|
501
|
-
})
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
__name(AddHyperLinkMenuItemFactory, "AddHyperLinkMenuItemFactory");
|
|
505
|
-
const addLinkShortcut = {
|
|
506
|
-
id: ShowDocHyperLinkEditPopupOperation.id,
|
|
507
|
-
binding: MetaKeys.CTRL_COMMAND | KeyCode.K,
|
|
508
|
-
description: "docLink.menu.tooltip",
|
|
509
|
-
preconditions: whenDocAndEditorFocused
|
|
510
|
-
}, menuSchema = {
|
|
511
|
-
[RibbonStartGroup.OTHERS]: {
|
|
512
|
-
[ShowDocHyperLinkEditPopupOperation.id]: {
|
|
513
|
-
order: 0,
|
|
514
|
-
menuItemFactory: AddHyperLinkMenuItemFactory
|
|
515
|
-
}
|
|
516
|
-
},
|
|
517
|
-
[ContextMenuPosition.MAIN_AREA]: {
|
|
518
|
-
[ContextMenuGroup.DATA]: {
|
|
519
|
-
[ShowDocHyperLinkEditPopupOperation.id]: {
|
|
520
|
-
order: 0,
|
|
521
|
-
menuItemFactory: AddHyperLinkMenuItemFactory
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
};
|
|
526
484
|
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
527
485
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
528
486
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
529
487
|
return kind && result && __defProp$4(target, key, result), result;
|
|
530
488
|
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a2;
|
|
531
|
-
let
|
|
532
|
-
constructor(_componentManager, _commandService, _menuManagerService, _injector, _shortcutService) {
|
|
533
|
-
super(), this._componentManager = _componentManager, this._commandService = _commandService, this._menuManagerService = _menuManagerService, this._injector = _injector, this._shortcutService = _shortcutService, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortcut();
|
|
534
|
-
}
|
|
535
|
-
_initComponents() {
|
|
536
|
-
[
|
|
537
|
-
[DocHyperLinkEdit, DocHyperLinkEdit.componentKey],
|
|
538
|
-
[DocLinkPopup, DocLinkPopup.componentKey],
|
|
539
|
-
[LinkSingle, DOC_LINK_ICON]
|
|
540
|
-
].forEach(([comp, key]) => {
|
|
541
|
-
this._componentManager.register(key, comp);
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
_initCommands() {
|
|
545
|
-
[
|
|
546
|
-
AddDocHyperLinkCommand,
|
|
547
|
-
UpdateDocHyperLinkCommand,
|
|
548
|
-
DeleteDocHyperLinkCommand,
|
|
549
|
-
ShowDocHyperLinkEditPopupOperation,
|
|
550
|
-
ToggleDocHyperLinkInfoPopupOperation,
|
|
551
|
-
ClickDocHyperLinkOperation
|
|
552
|
-
].forEach((command) => {
|
|
553
|
-
this._commandService.registerCommand(command);
|
|
554
|
-
});
|
|
555
|
-
}
|
|
556
|
-
_initShortcut() {
|
|
557
|
-
[addLinkShortcut].forEach((shortcut) => {
|
|
558
|
-
this._shortcutService.registerShortcut(shortcut);
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
_initMenus() {
|
|
562
|
-
this._menuManagerService.mergeMenu(menuSchema);
|
|
563
|
-
}
|
|
564
|
-
}, __name(_a2, "DocHyperLinkUIController"), _a2);
|
|
565
|
-
DocHyperLinkUIController = __decorateClass$4([
|
|
566
|
-
OnLifecycle(LifecycleStages.Starting, DocHyperLinkUIController),
|
|
567
|
-
__decorateParam$4(0, Inject(ComponentManager)),
|
|
568
|
-
__decorateParam$4(1, ICommandService),
|
|
569
|
-
__decorateParam$4(2, IMenuManagerService),
|
|
570
|
-
__decorateParam$4(3, Inject(Injector)),
|
|
571
|
-
__decorateParam$4(4, IShortcutService)
|
|
572
|
-
], DocHyperLinkUIController);
|
|
573
|
-
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
574
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
575
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
576
|
-
return kind && result && __defProp$3(target, key, result), result;
|
|
577
|
-
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a3;
|
|
578
|
-
let DocHyperLinkSelectionController = (_a3 = class extends Disposable {
|
|
489
|
+
let DocHyperLinkSelectionController = (_a2 = class extends Disposable {
|
|
579
490
|
constructor(_commandService, _univerInstanceService, _docHyperLinkService) {
|
|
580
491
|
super(), this._commandService = _commandService, this._univerInstanceService = _univerInstanceService, this._docHyperLinkService = _docHyperLinkService, this._initSelectionChange();
|
|
581
492
|
}
|
|
@@ -602,55 +513,19 @@ let DocHyperLinkSelectionController = (_a3 = class extends Disposable {
|
|
|
602
513
|
})
|
|
603
514
|
);
|
|
604
515
|
}
|
|
605
|
-
}, __name(
|
|
606
|
-
DocHyperLinkSelectionController = __decorateClass$
|
|
516
|
+
}, __name(_a2, "DocHyperLinkSelectionController"), _a2);
|
|
517
|
+
DocHyperLinkSelectionController = __decorateClass$4([
|
|
607
518
|
OnLifecycle(LifecycleStages.Ready, DocHyperLinkSelectionController),
|
|
608
|
-
__decorateParam$
|
|
609
|
-
__decorateParam$
|
|
610
|
-
__decorateParam$
|
|
519
|
+
__decorateParam$4(0, ICommandService),
|
|
520
|
+
__decorateParam$4(1, IUniverInstanceService),
|
|
521
|
+
__decorateParam$4(2, Inject(DocHyperLinkPopupService))
|
|
611
522
|
], DocHyperLinkSelectionController);
|
|
612
|
-
var __defProp$
|
|
613
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
614
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
615
|
-
return kind && result && __defProp$2(target, key, result), result;
|
|
616
|
-
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a4;
|
|
617
|
-
let DocHyperLinkRenderController = (_a4 = class extends Disposable {
|
|
618
|
-
constructor(_context, _docInterceptorService, _hyperLinkService, _docRenderController) {
|
|
619
|
-
super(), this._context = _context, this._docInterceptorService = _docInterceptorService, this._hyperLinkService = _hyperLinkService, this._docRenderController = _docRenderController, this._init(), this._initReRender();
|
|
620
|
-
}
|
|
621
|
-
_init() {
|
|
622
|
-
this._docInterceptorService.intercept(DOC_INTERCEPTOR_POINT.CUSTOM_RANGE, {
|
|
623
|
-
handler: /* @__PURE__ */ __name((data, pos, next) => {
|
|
624
|
-
if (!data)
|
|
625
|
-
return next(data);
|
|
626
|
-
const { unitId } = pos, activeLink = this._hyperLinkService.showing, { linkId, unitId: linkUnitId } = activeLink || {}, isActive = linkUnitId === unitId && data.rangeId === linkId;
|
|
627
|
-
return next({
|
|
628
|
-
...data,
|
|
629
|
-
active: isActive
|
|
630
|
-
});
|
|
631
|
-
}, "handler")
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
_initReRender() {
|
|
635
|
-
this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(
|
|
636
|
-
distinctUntilChanged((prev, aft) => (prev == null ? void 0 : prev.linkId) === (aft == null ? void 0 : aft.linkId) && (prev == null ? void 0 : prev.unitId) === (aft == null ? void 0 : aft.unitId)),
|
|
637
|
-
pairwise()
|
|
638
|
-
).subscribe(([preLink, link]) => {
|
|
639
|
-
link ? link.unitId === this._context.unitId && this._docRenderController.reRender(link.unitId) : preLink && preLink.unitId === this._context.unitId && this._docRenderController.reRender(preLink.unitId);
|
|
640
|
-
}));
|
|
641
|
-
}
|
|
642
|
-
}, __name(_a4, "DocHyperLinkRenderController"), _a4);
|
|
643
|
-
DocHyperLinkRenderController = __decorateClass$2([
|
|
644
|
-
__decorateParam$2(1, Inject(DocInterceptorService)),
|
|
645
|
-
__decorateParam$2(2, Inject(DocHyperLinkPopupService)),
|
|
646
|
-
__decorateParam$2(3, Inject(DocRenderController))
|
|
647
|
-
], DocHyperLinkRenderController);
|
|
648
|
-
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
649
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
523
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
524
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
650
525
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
651
|
-
return kind && result && __defProp$
|
|
652
|
-
}, "__decorateClass$
|
|
653
|
-
let DocHyperLinkEventRenderController = (
|
|
526
|
+
return kind && result && __defProp$3(target, key, result), result;
|
|
527
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a3;
|
|
528
|
+
let DocHyperLinkEventRenderController = (_a3 = class extends Disposable {
|
|
654
529
|
constructor(_context, _docEventManagerService, _commandService, _hyperLinkPopupService, _docSkeletonManagerService, _docSelectionManagerService) {
|
|
655
530
|
super(), this._context = _context, this._docEventManagerService = _docEventManagerService, this._commandService = _commandService, this._hyperLinkPopupService = _hyperLinkPopupService, this._docSkeletonManagerService = _docSkeletonManagerService, this._docSelectionManagerService = _docSelectionManagerService, this._initHover(), this._initClick();
|
|
656
531
|
}
|
|
@@ -666,7 +541,7 @@ let DocHyperLinkEventRenderController = (_a5 = class extends Disposable {
|
|
|
666
541
|
this.disposeWithMe(
|
|
667
542
|
this._docEventManagerService.hoverCustomRanges$.subscribe((ranges) => {
|
|
668
543
|
var _a7;
|
|
669
|
-
const link = ranges.find((range) => range.range.rangeType === CustomRangeType.HYPERLINK), activeRanges = this._docSelectionManagerService.
|
|
544
|
+
const link = ranges.find((range) => range.range.rangeType === CustomRangeType.HYPERLINK), activeRanges = this._docSelectionManagerService.getTextRanges(), currentSegmentId = activeRanges == null ? void 0 : activeRanges[0].segmentId;
|
|
670
545
|
if (((_a7 = link == null ? void 0 : link.segmentId) != null ? _a7 : "") !== currentSegmentId) {
|
|
671
546
|
this._hideInfoPopup();
|
|
672
547
|
return;
|
|
@@ -699,15 +574,139 @@ let DocHyperLinkEventRenderController = (_a5 = class extends Disposable {
|
|
|
699
574
|
})
|
|
700
575
|
);
|
|
701
576
|
}
|
|
702
|
-
}, __name(
|
|
703
|
-
DocHyperLinkEventRenderController = __decorateClass$
|
|
704
|
-
__decorateParam$
|
|
705
|
-
__decorateParam$
|
|
706
|
-
__decorateParam$
|
|
707
|
-
__decorateParam$
|
|
708
|
-
__decorateParam$
|
|
577
|
+
}, __name(_a3, "DocHyperLinkEventRenderController"), _a3);
|
|
578
|
+
DocHyperLinkEventRenderController = __decorateClass$3([
|
|
579
|
+
__decorateParam$3(1, Inject(DocEventManagerService)),
|
|
580
|
+
__decorateParam$3(2, ICommandService),
|
|
581
|
+
__decorateParam$3(3, Inject(DocHyperLinkPopupService)),
|
|
582
|
+
__decorateParam$3(4, Inject(DocSkeletonManagerService)),
|
|
583
|
+
__decorateParam$3(5, Inject(DocSelectionManagerService))
|
|
709
584
|
], DocHyperLinkEventRenderController);
|
|
710
|
-
|
|
585
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
586
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
587
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
588
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
589
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a4;
|
|
590
|
+
let DocHyperLinkRenderController = (_a4 = class extends Disposable {
|
|
591
|
+
constructor(_context, _docInterceptorService, _hyperLinkService, _docRenderController) {
|
|
592
|
+
super(), this._context = _context, this._docInterceptorService = _docInterceptorService, this._hyperLinkService = _hyperLinkService, this._docRenderController = _docRenderController, this._init(), this._initReRender();
|
|
593
|
+
}
|
|
594
|
+
_init() {
|
|
595
|
+
this._docInterceptorService.intercept(DOC_INTERCEPTOR_POINT.CUSTOM_RANGE, {
|
|
596
|
+
handler: /* @__PURE__ */ __name((data, pos, next) => {
|
|
597
|
+
if (!data)
|
|
598
|
+
return next(data);
|
|
599
|
+
const { unitId } = pos, activeLink = this._hyperLinkService.showing, { linkId, unitId: linkUnitId } = activeLink || {}, isActive = linkUnitId === unitId && data.rangeId === linkId;
|
|
600
|
+
return next({
|
|
601
|
+
...data,
|
|
602
|
+
active: isActive
|
|
603
|
+
});
|
|
604
|
+
}, "handler")
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
_initReRender() {
|
|
608
|
+
this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(
|
|
609
|
+
distinctUntilChanged((prev, aft) => (prev == null ? void 0 : prev.linkId) === (aft == null ? void 0 : aft.linkId) && (prev == null ? void 0 : prev.unitId) === (aft == null ? void 0 : aft.unitId)),
|
|
610
|
+
pairwise()
|
|
611
|
+
).subscribe(([preLink, link]) => {
|
|
612
|
+
link ? link.unitId === this._context.unitId && this._docRenderController.reRender(link.unitId) : preLink && preLink.unitId === this._context.unitId && this._docRenderController.reRender(preLink.unitId);
|
|
613
|
+
}));
|
|
614
|
+
}
|
|
615
|
+
}, __name(_a4, "DocHyperLinkRenderController"), _a4);
|
|
616
|
+
DocHyperLinkRenderController = __decorateClass$2([
|
|
617
|
+
__decorateParam$2(1, Inject(DocInterceptorService)),
|
|
618
|
+
__decorateParam$2(2, Inject(DocHyperLinkPopupService)),
|
|
619
|
+
__decorateParam$2(3, Inject(DocRenderController))
|
|
620
|
+
], DocHyperLinkRenderController);
|
|
621
|
+
const DOC_LINK_ICON = "doc-hyper-link-icon";
|
|
622
|
+
function AddHyperLinkMenuItemFactory(accessor) {
|
|
623
|
+
return {
|
|
624
|
+
id: ShowDocHyperLinkEditPopupOperation.id,
|
|
625
|
+
type: MenuItemType.BUTTON,
|
|
626
|
+
icon: DOC_LINK_ICON,
|
|
627
|
+
title: "docLink.menu.tooltip",
|
|
628
|
+
tooltip: "docLink.menu.tooltip",
|
|
629
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
|
|
630
|
+
disabled$: new Observable(function(subscribe) {
|
|
631
|
+
const observer = accessor.get(DocSelectionManagerService).textSelection$.pipe(debounceTime(16)).subscribe(() => {
|
|
632
|
+
subscribe.next(shouldDisableAddLink(accessor));
|
|
633
|
+
});
|
|
634
|
+
return () => {
|
|
635
|
+
observer.unsubscribe();
|
|
636
|
+
};
|
|
637
|
+
})
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
__name(AddHyperLinkMenuItemFactory, "AddHyperLinkMenuItemFactory");
|
|
641
|
+
const addLinkShortcut = {
|
|
642
|
+
id: ShowDocHyperLinkEditPopupOperation.id,
|
|
643
|
+
binding: MetaKeys.CTRL_COMMAND | KeyCode.K,
|
|
644
|
+
description: "docLink.menu.tooltip",
|
|
645
|
+
preconditions: whenDocAndEditorFocused
|
|
646
|
+
}, menuSchema = {
|
|
647
|
+
[RibbonStartGroup.OTHERS]: {
|
|
648
|
+
[ShowDocHyperLinkEditPopupOperation.id]: {
|
|
649
|
+
order: 0,
|
|
650
|
+
menuItemFactory: AddHyperLinkMenuItemFactory
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
[ContextMenuPosition.MAIN_AREA]: {
|
|
654
|
+
[ContextMenuGroup.DATA]: {
|
|
655
|
+
[ShowDocHyperLinkEditPopupOperation.id]: {
|
|
656
|
+
order: 0,
|
|
657
|
+
menuItemFactory: AddHyperLinkMenuItemFactory
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
663
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
664
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
665
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
666
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a5;
|
|
667
|
+
let DocHyperLinkUIController = (_a5 = class extends Disposable {
|
|
668
|
+
constructor(_componentManager, _commandService, _menuManagerService, _injector, _shortcutService) {
|
|
669
|
+
super(), this._componentManager = _componentManager, this._commandService = _commandService, this._menuManagerService = _menuManagerService, this._injector = _injector, this._shortcutService = _shortcutService, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortcut();
|
|
670
|
+
}
|
|
671
|
+
_initComponents() {
|
|
672
|
+
[
|
|
673
|
+
[DocHyperLinkEdit, DocHyperLinkEdit.componentKey],
|
|
674
|
+
[DocLinkPopup, DocLinkPopup.componentKey],
|
|
675
|
+
[LinkSingle, DOC_LINK_ICON]
|
|
676
|
+
].forEach(([comp, key]) => {
|
|
677
|
+
this._componentManager.register(key, comp);
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
_initCommands() {
|
|
681
|
+
[
|
|
682
|
+
AddDocHyperLinkCommand,
|
|
683
|
+
UpdateDocHyperLinkCommand,
|
|
684
|
+
DeleteDocHyperLinkCommand,
|
|
685
|
+
ShowDocHyperLinkEditPopupOperation,
|
|
686
|
+
ToggleDocHyperLinkInfoPopupOperation,
|
|
687
|
+
ClickDocHyperLinkOperation
|
|
688
|
+
].forEach((command) => {
|
|
689
|
+
this._commandService.registerCommand(command);
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
_initShortcut() {
|
|
693
|
+
[addLinkShortcut].forEach((shortcut) => {
|
|
694
|
+
this._shortcutService.registerShortcut(shortcut);
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
_initMenus() {
|
|
698
|
+
this._menuManagerService.mergeMenu(menuSchema);
|
|
699
|
+
}
|
|
700
|
+
}, __name(_a5, "DocHyperLinkUIController"), _a5);
|
|
701
|
+
DocHyperLinkUIController = __decorateClass$1([
|
|
702
|
+
OnLifecycle(LifecycleStages.Starting, DocHyperLinkUIController),
|
|
703
|
+
__decorateParam$1(0, Inject(ComponentManager)),
|
|
704
|
+
__decorateParam$1(1, ICommandService),
|
|
705
|
+
__decorateParam$1(2, IMenuManagerService),
|
|
706
|
+
__decorateParam$1(3, Inject(Injector)),
|
|
707
|
+
__decorateParam$1(4, IShortcutService)
|
|
708
|
+
], DocHyperLinkUIController);
|
|
709
|
+
const DOC_HYPER_LINK_UI_PLUGIN = "DOC_HYPER_LINK_UI_PLUGIN";
|
|
711
710
|
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
712
711
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
713
712
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
package/lib/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.univer-doc-link{display:flex;flex-direction:row;align-items:center;justify-content:space-between;padding:12px;box-shadow:var(--box-shadow-base);border-radius:8px;border:1px solid rgb(var(--grey-200));background:rgb(var(--color-white));max-width:328px;box-sizing:border-box;overflow:hidden}.univer-doc-link-type{height:20px;width:20px;font-size:16px;margin-right:8px;display:flex;align-items:center;justify-content:center;flex:0 0 auto;color:rgb(var(--color-black))}.univer-doc-link-content{height:24px;display:flex;flex-direction:row;align-items:center;font-size:13px;line-height:20px;color:rgb(var(--blue-500));cursor:pointer;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-doc-link-content-error{color:rgb(var(--grey-500))}.univer-doc-link-url{flex:1;overflow:hidden;text-overflow:ellipsis}.univer-doc-link-operations{display:flex;flex-direction:row;justify-content:center;align-items:center;height:24px;flex-basis:auto;flex-grow:0;flex-shrink:0}.univer-doc-link-operation{width:24px;height:24px;margin-left:8px;font-size:16px;display:flex;flex-direction:row;justify-content:center;align-items:center;cursor:pointer;border-radius:4px}.univer-doc-link-operation-error{color:rgb(var(--grey-500))}.univer-doc-link-operation:hover{background:#ccc}
|
|
1
|
+
.univer-docs-link-edit{border-radius:12px;border:1px solid rgb(var(--grey-200));background:rgb(var(--color-white));box-shadow:var(--box-shadow-base);padding:20px 24px;width:328px;box-sizing:border-box}.univer-docs-link-edit-title{display:flex;flex-direction:row;align-items:center;justify-content:space-between;height:24px;font-size:16px;font-style:normal;font-weight:500;line-height:24px;margin-bottom:16px;color:rgb(var(--color-black))}.univer-docs-link-edit-close{width:16px;height:16px;font-size:16px;color:rgb(var(--grey-600));cursor:pointer}.univer-docs-link-edit-buttons{display:flex;flex-direction:row;justify-content:flex-end}.univer-docs-link-edit-button{margin-left:12px}.univer-doc-link{display:flex;flex-direction:row;align-items:center;justify-content:space-between;padding:12px;box-shadow:var(--box-shadow-base);border-radius:8px;border:1px solid rgb(var(--grey-200));background:rgb(var(--color-white));max-width:328px;box-sizing:border-box;overflow:hidden}.univer-doc-link-type{height:20px;width:20px;font-size:16px;margin-right:8px;display:flex;align-items:center;justify-content:center;flex:0 0 auto;color:rgb(var(--color-black))}.univer-doc-link-content{height:24px;display:flex;flex-direction:row;align-items:center;font-size:13px;line-height:20px;color:rgb(var(--blue-500));cursor:pointer;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-doc-link-content-error{color:rgb(var(--grey-500))}.univer-doc-link-url{flex:1;overflow:hidden;text-overflow:ellipsis}.univer-doc-link-operations{display:flex;flex-direction:row;justify-content:center;align-items:center;height:24px;flex-basis:auto;flex-grow:0;flex-shrink:0}.univer-doc-link-operation{width:24px;height:24px;margin-left:8px;font-size:16px;display:flex;flex-direction:row;justify-content:center;align-items:center;cursor:pointer;border-radius:4px}.univer-doc-link-operation-error{color:rgb(var(--grey-500))}.univer-doc-link-operation:hover{background:#ccc}
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/docs-hyper-link"),require("@univerjs/ui"),require("@univerjs/design"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("react"),require("rxjs"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/docs-hyper-link","@univerjs/ui","@univerjs/design","@univerjs/docs","@univerjs/docs-ui","react","rxjs","clsx"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverDocsHyperLinkUi={},global.UniverCore,global.UniverEngineRender,global.UniverDocsHyperLink,global.UniverUi,global.UniverDesign,global.UniverDocs,global.UniverDocsUi,global.React,global.rxjs,global.clsx))})(this,function(exports2,core,engineRender,docsHyperLink,ui,design,docs,docsUi,React,rxjs,cs){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c,_d,_e,_f;const DOC_HYPER_LINK_UI_PLUGIN="DOC_HYPER_LINK_UI_PLUGIN";var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=React.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=React.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return React.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a2){var key=_a2[0],value=_a2[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a2,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a2=node.children)===null||_a2===void 0)&&_a2.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid"),IconBase.displayName="UniverIcon";var element$3={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"}}]},CopySingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"copy-single",ref,icon:element$3}))});CopySingle.displayName="CopySingle";var element$2={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},LinkSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"link-single",ref,icon:element$2}))});LinkSingle.displayName="LinkSingle";var element$1={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"}}]},UnlinkSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"unlink-single",ref,icon:element$1}))});UnlinkSingle.displayName="UnlinkSingle";var element={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"}}]},WriteSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"write-single",ref,icon:element}))});WriteSingle.displayName="WriteSingle";const AddDocHyperLinkCommand={type:core.CommandType.COMMAND,id:"docs.command.add-hyper-link",async handler(accessor,params){if(!params)return!1;const{payload,unitId,selection}=params,commandService=accessor.get(core.ICommandService),id=core.generateRandomId(),doMutation=docsUi.addCustomRangeBySelectionFactory(accessor,{rangeId:id,rangeType:core.CustomRangeType.HYPERLINK,properties:{url:payload},unitId,selection});return doMutation?commandService.syncExecuteCommand(doMutation.id,doMutation.params):!1}},UpdateDocHyperLinkCommand={id:"docs.command.update-hyper-link",type:core.CommandType.COMMAND,handler(accessor,params){var _a2;if(!params)return!1;const{unitId,payload,segmentId}=params,commandService=accessor.get(core.ICommandService),univerInstanceService=accessor.get(core.IUniverInstanceService),currentSelection=accessor.get(docs.DocSelectionManagerService).getActiveTextRange(),doc=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC);if(!currentSelection||!doc)return!1;const newId=core.generateRandomId(),textRun=(_a2=core.getBodySlice(doc.getSelfOrHeaderFooterModel(segmentId).getBody(),currentSelection.startOffset,currentSelection.endOffset).textRuns)==null?void 0:_a2[0];textRun&&(textRun.ed=params.label.length+1);const replaceSelection=docsUi.replaceSelectionFactory(accessor,{unitId,body:{dataStream:`${core.DataStreamTreeTokenType.CUSTOM_RANGE_START}${params.label}${core.DataStreamTreeTokenType.CUSTOM_RANGE_END}`,customRanges:[{rangeId:newId,rangeType:core.CustomRangeType.HYPERLINK,startIndex:0,endIndex:params.label.length+1,properties:{url:payload}}],textRuns:textRun?[textRun]:void 0},selection:{startOffset:currentSelection.startOffset,endOffset:currentSelection.endOffset,collapsed:!1,segmentId}});return replaceSelection?commandService.syncExecuteCommand(replaceSelection.id,replaceSelection.params):!1}},DeleteDocHyperLinkCommand={type:core.CommandType.COMMAND,id:"docs.command.delete-hyper-link",async handler(accessor,params){if(!params)return!1;const{unitId,linkId,segmentId}=params,commandService=accessor.get(core.ICommandService),doMutation=docsUi.deleteCustomRangeFactory(accessor,{unitId,rangeId:linkId,segmentId});return doMutation?await commandService.syncExecuteCommand(doMutation.id,doMutation.params):!1}},shouldDisableAddLink=__name(accessor=>{var _a2;const textSelectionService=accessor.get(docs.DocSelectionManagerService),univerInstanceService=accessor.get(core.IUniverInstanceService),textRanges=textSelectionService.getDocRanges();if(!textRanges.length||textRanges.length>1)return!0;const activeRange=textRanges[0],doc=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC);if(!doc||!activeRange||activeRange.collapsed)return!0;const body=doc.getSelfOrHeaderFooterModel(activeRange.segmentId).getBody(),paragraphs=body==null?void 0:body.paragraphs;if(!paragraphs)return!0;for(let i=0,len=paragraphs.length;i<len;i++){const p=paragraphs[i];if(activeRange.startOffset<=p.startIndex&&activeRange.endOffset>p.startIndex)return!0;if(p.startIndex>activeRange.endOffset)break}return!core.BuildTextUtils.customRange.getCustomRangesInterestsWithRange(activeRange,(_a2=body.customRanges)!=null?_a2:[]).every(range=>range.rangeType===core.CustomRangeType.HYPERLINK)},"shouldDisableAddLink"),ShowDocHyperLinkEditPopupOperation={type:core.CommandType.OPERATION,id:"doc.operation.show-hyper-link-edit-popup",handler(accessor,params){var _a2;const linkInfo=params==null?void 0:params.link,univerInstanceService=accessor.get(core.IUniverInstanceService);if(shouldDisableAddLink(accessor)&&!linkInfo)return!1;const hyperLinkService=accessor.get(DocHyperLinkPopupService),unitId=(linkInfo==null?void 0:linkInfo.unitId)||((_a2=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC))==null?void 0:_a2.getUnitId());return unitId?(hyperLinkService.showEditPopup(unitId,linkInfo),!0):!1}},ToggleDocHyperLinkInfoPopupOperation={type:core.CommandType.OPERATION,id:"doc.operation.toggle-hyper-link-info-popup",handler(accessor,params){const hyperLinkService=accessor.get(DocHyperLinkPopupService);return params?(hyperLinkService.showInfoPopup(params),!0):(hyperLinkService.hideInfoPopup(),!0)}},ClickDocHyperLinkOperation={type:core.CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(accessor,params){var _a2,_b2,_c2;if(!params)return!1;const{unitId,linkId,segmentId}=params,doc=accessor.get(core.IUniverInstanceService).getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),body=doc==null?void 0:doc.getSelfOrHeaderFooterModel(segmentId).getBody(),link=(_c2=(_b2=(_a2=body==null?void 0:body.customRanges)==null?void 0:_a2.find(range=>range.rangeId===linkId&&range.rangeType===core.CustomRangeType.HYPERLINK))==null?void 0:_b2.properties)==null?void 0:_c2.url;return link&&window.open(link,"_blank","noopener noreferrer"),!0}},styles$1={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"},DocLinkPopup=__name(()=>{var _a2,_b2;const hyperLinkService=core.useDependency(DocHyperLinkPopupService),commandService=core.useDependency(core.ICommandService),messageService=core.useDependency(ui.IMessageService),localeService=core.useDependency(core.LocaleService),currentPopup=ui.useObservable(hyperLinkService.showingLink$),univerInstanceService=core.useDependency(core.IUniverInstanceService);if(!currentPopup)return null;const{unitId,linkId,segmentId}=currentPopup,doc=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),body=doc==null?void 0:doc.getSelfOrHeaderFooterModel(segmentId).getBody(),link=(_a2=body==null?void 0:body.customRanges)==null?void 0:_a2.find(range=>range.rangeId===linkId&&range.rangeType===core.CustomRangeType.HYPERLINK);if(!link)return null;const url=(_b2=link.properties)==null?void 0:_b2.url;return React.createElement("div",{className:styles$1.docLink,onClick:__name(()=>{hyperLinkService.hideInfoPopup()},"onClick")},React.createElement("div",{className:cs(styles$1.docLinkContent),onClick:__name(()=>window.open(url),"onClick")},React.createElement("div",{className:styles$1.docLinkType},React.createElement(LinkSingle,null)),React.createElement(design.Tooltip,{showIfEllipsis:!0,title:url},React.createElement("span",{className:styles$1.docLinkUrl},url))),React.createElement("div",{className:styles$1.docLinkOperations},React.createElement("div",{className:cs(styles$1.docLinkOperation),onClick:__name(()=>{navigator.clipboard.writeText(url),messageService.show({content:localeService.t("docLink.info.coped"),type:design.MessageType.Info})},"onClick")},React.createElement(design.Tooltip,{placement:"bottom",title:localeService.t("docLink.info.copy")},React.createElement(CopySingle,null))),React.createElement("div",{className:styles$1.docLinkOperation,onClick:__name(()=>{commandService.executeCommand(ShowDocHyperLinkEditPopupOperation.id,{link:currentPopup})},"onClick")},React.createElement(design.Tooltip,{placement:"bottom",title:localeService.t("docLink.info.edit")},React.createElement(WriteSingle,null))),React.createElement("div",{className:styles$1.docLinkOperation,onClick:__name(()=>{commandService.executeCommand(DeleteDocHyperLinkCommand.id,{unitId,linkId:link.rangeId,segmentId})},"onClick")},React.createElement(design.Tooltip,{placement:"bottom",title:localeService.t("docLink.info.cancel")},React.createElement(UnlinkSingle,null)))))},"DocLinkPopup");DocLinkPopup.componentKey="univer.doc.link-info-popup";var __defProp$5=Object.defineProperty,__getOwnPropDesc$5=Object.getOwnPropertyDescriptor,__decorateClass$5=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$5(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$5(target,key,result),result},"__decorateClass$5"),__decorateParam$5=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$5");const SKIT_PLACEHOLDER=0;let DocHyperLinkPopupService=(_a=class extends core.Disposable{constructor(_docCanvasPopupManagerService,_textSelectionManagerService,_univerInstanceService){super();__publicField(this,"_editingLink$",new rxjs.BehaviorSubject(null));__publicField(this,"_showingLink$",new rxjs.BehaviorSubject(null));__publicField(this,"editingLink$",this._editingLink$.asObservable());__publicField(this,"showingLink$",this._showingLink$.asObservable());__publicField(this,"_editPopup",null);__publicField(this,"_infoPopup",null);this._docCanvasPopupManagerService=_docCanvasPopupManagerService,this._textSelectionManagerService=_textSelectionManagerService,this._univerInstanceService=_univerInstanceService,this.disposeWithMe(()=>{this._editingLink$.complete(),this._showingLink$.complete()})}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(unitId,linkInfo){var _a2,_b2,_c2;this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(linkInfo);let activeRange=this._textSelectionManagerService.getActiveTextRange();if(linkInfo){const{unitId:unitId2,linkId,segmentId,segmentPage}=linkInfo,doc=this._univerInstanceService.getUnit(unitId2,core.UniverInstanceType.UNIVER_DOC),range=(_c2=(_b2=(_a2=doc==null?void 0:doc.getSelfOrHeaderFooterModel(segmentId))==null?void 0:_a2.getBody())==null?void 0:_b2.customRanges)==null?void 0:_c2.find(i=>i.rangeId===linkId);range&&(activeRange={collapsed:!1,startOffset:range.startIndex+SKIT_PLACEHOLDER,endOffset:range.endIndex+1,segmentId,segmentPage},this._textSelectionManagerService.replaceTextRanges([{startOffset:range.startIndex,endOffset:range.endIndex+1}]))}return activeRange?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(activeRange,{componentKey:DocHyperLinkEdit.componentKey,direction:"bottom"},unitId),this._editPopup):null}hideEditPopup(){var _a2;this._editingLink$.next(null),(_a2=this._editPopup)==null||_a2.dispose()}showInfoPopup(info){var _a2,_b2,_c2,_d2,_e2,_f2;const{linkId,unitId,segmentId,segmentPage}=info;if(((_a2=this.showing)==null?void 0:_a2.linkId)===linkId&&((_b2=this.showing)==null?void 0:_b2.unitId)===unitId&&((_c2=this.showing)==null?void 0:_c2.segmentId)===segmentId&&((_d2=this.showing)==null?void 0:_d2.segmentPage)===segmentPage)return;this._infoPopup&&this._infoPopup.dispose();const doc=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC);if(!doc)return;const range=(_f2=(_e2=doc.getSelfOrHeaderFooterModel(info.segmentId).getBody())==null?void 0:_e2.customRanges)==null?void 0:_f2.find(i=>i.rangeId===linkId);if(this._showingLink$.next({unitId,linkId,segmentId,segmentPage}),!!range)return this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:range.startIndex+SKIT_PLACEHOLDER,endOffset:range.endIndex+1,segmentId:info.segmentId,segmentPage:info.segmentPage},{componentKey:DocLinkPopup.componentKey,direction:"top-center",multipleDirection:"top",onClickOutside:__name(()=>{this.hideInfoPopup()},"onClickOutside")},info.unitId),this._infoPopup}hideInfoPopup(){var _a2;this._showingLink$.next(null),(_a2=this._infoPopup)==null||_a2.dispose()}},__name(_a,"DocHyperLinkPopupService"),_a);DocHyperLinkPopupService=__decorateClass$5([__decorateParam$5(0,core.Inject(docsUi.DocCanvasPopManagerService)),__decorateParam$5(1,core.Inject(docs.DocSelectionManagerService)),__decorateParam$5(2,core.IUniverInstanceService)],DocHyperLinkPopupService);const styles={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 hasProtocol(urlString){return/^[a-zA-Z]+:\/\//.test(urlString)}__name(hasProtocol,"hasProtocol");function isEmail(url){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url)}__name(isEmail,"isEmail");function transformUrl(urlStr){return hasProtocol(urlStr)?urlStr:isEmail(urlStr)?`mailto://${urlStr}`:`https://${urlStr}`}__name(transformUrl,"transformUrl");const DocHyperLinkEdit=__name(()=>{var _a2;const hyperLinkService=core.useDependency(DocHyperLinkPopupService),localeService=core.useDependency(core.LocaleService),editing=core.useObservable(hyperLinkService.editingLink$),commandService=core.useDependency(core.ICommandService),univerInstanceService=core.useDependency(core.IUniverInstanceService),renderManagerService=core.useDependency(engineRender.IRenderManagerService),docSelectionManagerService=core.useDependency(docs.DocSelectionManagerService),[link,setLink]=React.useState(""),[label,setLabel]=React.useState(""),[showError,setShowError]=React.useState(!1),isLegal=core.Tools.isLegalUrl(link),doc=editing?univerInstanceService.getUnit(editing.unitId,core.UniverInstanceType.UNIVER_DOC):univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC),docSelectionRenderService=(_a2=renderManagerService.getRenderById(doc.getUnitId()))==null?void 0:_a2.with(docsUi.DocSelectionRenderService);React.useEffect(()=>{var _a3,_b2,_c2,_d2,_e2,_f2,_g,_h,_i;const activeRange=docSelectionManagerService.getActiveTextRange();if(!activeRange)return;if(editing){const body=(_a3=doc==null?void 0:doc.getSelfOrHeaderFooterModel(editing.segmentId))==null?void 0:_a3.getBody(),matchedRange2=(_b2=body==null?void 0:body.customRanges)==null?void 0:_b2.find(i=>(editing==null?void 0:editing.linkId)===i.rangeId);doc&&matchedRange2&&(setLink((_d2=(_c2=matchedRange2.properties)==null?void 0:_c2.url)!=null?_d2:""),setLabel(core.BuildTextUtils.transform.getPlainText(core.getBodySlice(body,matchedRange2.startIndex,matchedRange2.endIndex).dataStream)));return}const matchedRange=(_g=(_f2=(_e2=doc==null?void 0:doc.getSelfOrHeaderFooterModel(activeRange.segmentId))==null?void 0:_e2.getBody())==null?void 0:_f2.customRanges)==null?void 0:_g.find(i=>Math.max(activeRange.startOffset,i.startIndex)<=Math.min(activeRange.endOffset-1,i.endIndex));doc&&matchedRange&&setLink((_i=(_h=matchedRange==null?void 0:matchedRange.properties)==null?void 0:_h.url)!=null?_i:"")},[doc,editing,docSelectionManagerService,univerInstanceService]),React.useEffect(()=>(docSelectionRenderService&&docSelectionRenderService.blurEditor(),()=>{docSelectionRenderService&&docSelectionRenderService.focusEditor()}),[docSelectionRenderService]);const handleCancel=__name(()=>{hyperLinkService.hideEditPopup()},"handleCancel"),handleConfirm=__name(()=>{if(setShowError(!0),!isLegal||!doc)return;const linkFinal=transformUrl(link);if(!editing)commandService.executeCommand(AddDocHyperLinkCommand.id,{unitId:doc.getUnitId(),payload:linkFinal});else{if(!label)return;commandService.executeCommand(UpdateDocHyperLinkCommand.id,{unitId:doc.getUnitId(),payload:linkFinal,linkId:editing.linkId,label,segmentId:editing.segmentId})}hyperLinkService.hideEditPopup()},"handleConfirm");if(doc)return React.createElement("div",{className:styles.docsLinkEdit},React.createElement("div",null,editing?React.createElement(design.FormLayout,{label:localeService.t("docLink.edit.label"),error:showError&&!label?localeService.t("docLink.edit.labelError"):""},React.createElement(design.Input,{value:label,onChange:setLabel,autoFocus:!0,onKeyDown:__name(evt=>{evt.keyCode===ui.KeyCode.ENTER&&handleConfirm()},"onKeyDown")})):null,React.createElement(design.FormLayout,{label:localeService.t("docLink.edit.address"),error:showError&&!isLegal?localeService.t("docLink.edit.addressError"):""},React.createElement(design.Input,{value:link,onChange:setLink,autoFocus:!0,onKeyDown:__name(evt=>{evt.keyCode===ui.KeyCode.ENTER&&handleConfirm()},"onKeyDown")}))),React.createElement("div",{className:styles.docsLinkEditButtons},React.createElement(design.Button,{className:styles.docsLinkEditButton,onClick:handleCancel},localeService.t("docLink.edit.cancel")),React.createElement(design.Button,{disabled:!link,className:styles.docsLinkEditButton,type:"primary",onClick:handleConfirm},localeService.t("docLink.edit.confirm"))))},"DocHyperLinkEdit");DocHyperLinkEdit.componentKey="docs-hyper-link-edit";const DOC_LINK_ICON="doc-hyper-link-icon";function AddHyperLinkMenuItemFactory(accessor){return{id:ShowDocHyperLinkEditPopupOperation.id,type:ui.MenuItemType.BUTTON,icon:DOC_LINK_ICON,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC),disabled$:new rxjs.Observable(function(subscribe){const observer=accessor.get(docs.DocSelectionManagerService).textSelection$.pipe(rxjs.debounceTime(16)).subscribe(()=>{subscribe.next(shouldDisableAddLink(accessor))});return()=>{observer.unsubscribe()}})}}__name(AddHyperLinkMenuItemFactory,"AddHyperLinkMenuItemFactory");const addLinkShortcut={id:ShowDocHyperLinkEditPopupOperation.id,binding:ui.MetaKeys.CTRL_COMMAND|ui.KeyCode.K,description:"docLink.menu.tooltip",preconditions:docsUi.whenDocAndEditorFocused},menuSchema={[ui.RibbonStartGroup.OTHERS]:{[ShowDocHyperLinkEditPopupOperation.id]:{order:0,menuItemFactory:AddHyperLinkMenuItemFactory}},[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.DATA]:{[ShowDocHyperLinkEditPopupOperation.id]:{order:0,menuItemFactory:AddHyperLinkMenuItemFactory}}}};var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4");let DocHyperLinkUIController=(_b=class extends core.Disposable{constructor(_componentManager,_commandService,_menuManagerService,_injector,_shortcutService){super(),this._componentManager=_componentManager,this._commandService=_commandService,this._menuManagerService=_menuManagerService,this._injector=_injector,this._shortcutService=_shortcutService,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[DocHyperLinkEdit,DocHyperLinkEdit.componentKey],[DocLinkPopup,DocLinkPopup.componentKey],[LinkSingle,DOC_LINK_ICON]].forEach(([comp,key])=>{this._componentManager.register(key,comp)})}_initCommands(){[AddDocHyperLinkCommand,UpdateDocHyperLinkCommand,DeleteDocHyperLinkCommand,ShowDocHyperLinkEditPopupOperation,ToggleDocHyperLinkInfoPopupOperation,ClickDocHyperLinkOperation].forEach(command=>{this._commandService.registerCommand(command)})}_initShortcut(){[addLinkShortcut].forEach(shortcut=>{this._shortcutService.registerShortcut(shortcut)})}_initMenus(){this._menuManagerService.mergeMenu(menuSchema)}},__name(_b,"DocHyperLinkUIController"),_b);DocHyperLinkUIController=__decorateClass$4([core.OnLifecycle(core.LifecycleStages.Starting,DocHyperLinkUIController),__decorateParam$4(0,core.Inject(ui.ComponentManager)),__decorateParam$4(1,core.ICommandService),__decorateParam$4(2,ui.IMenuManagerService),__decorateParam$4(3,core.Inject(core.Injector)),__decorateParam$4(4,ui.IShortcutService)],DocHyperLinkUIController);var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3");let DocHyperLinkSelectionController=(_c=class extends core.Disposable{constructor(_commandService,_univerInstanceService,_docHyperLinkService){super(),this._commandService=_commandService,this._univerInstanceService=_univerInstanceService,this._docHyperLinkService=_docHyperLinkService,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(commandInfo=>{var _a2,_b2,_c2;if(commandInfo.id===docs.SetTextSelectionsOperation.id){const params=commandInfo.params,{unitId,ranges,segmentId}=params,doc=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),primary=ranges[0];if(primary&&doc){const{startOffset,endOffset,collapsed,segmentPage}=primary,customRanges=(_b2=(_a2=doc.getSelfOrHeaderFooterModel(segmentId))==null?void 0:_a2.getBody())==null?void 0:_b2.customRanges;if(collapsed){const index=(_c2=customRanges==null?void 0:customRanges.findIndex(value=>value.startIndex<startOffset&&value.endIndex>endOffset-1))!=null?_c2:-1;if(index>-1){const customRange=customRanges[index];this._docHyperLinkService.showInfoPopup({unitId,linkId:customRange.rangeId,segmentId,segmentPage});return}}else if(customRanges==null?void 0:customRanges.find(value=>value.startIndex<=startOffset&&value.endIndex>=endOffset-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}},__name(_c,"DocHyperLinkSelectionController"),_c);DocHyperLinkSelectionController=__decorateClass$3([core.OnLifecycle(core.LifecycleStages.Ready,DocHyperLinkSelectionController),__decorateParam$3(0,core.ICommandService),__decorateParam$3(1,core.IUniverInstanceService),__decorateParam$3(2,core.Inject(DocHyperLinkPopupService))],DocHyperLinkSelectionController);var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");let DocHyperLinkRenderController=(_d=class extends core.Disposable{constructor(_context,_docInterceptorService,_hyperLinkService,_docRenderController){super(),this._context=_context,this._docInterceptorService=_docInterceptorService,this._hyperLinkService=_hyperLinkService,this._docRenderController=_docRenderController,this._init(),this._initReRender()}_init(){this._docInterceptorService.intercept(docs.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:__name((data,pos,next)=>{if(!data)return next(data);const{unitId}=pos,activeLink=this._hyperLinkService.showing,{linkId,unitId:linkUnitId}=activeLink||{},isActive=linkUnitId===unitId&&data.rangeId===linkId;return next({...data,active:isActive})},"handler")})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(rxjs.distinctUntilChanged((prev,aft)=>(prev==null?void 0:prev.linkId)===(aft==null?void 0:aft.linkId)&&(prev==null?void 0:prev.unitId)===(aft==null?void 0:aft.unitId)),rxjs.pairwise()).subscribe(([preLink,link])=>{link?link.unitId===this._context.unitId&&this._docRenderController.reRender(link.unitId):preLink&&preLink.unitId===this._context.unitId&&this._docRenderController.reRender(preLink.unitId)}))}},__name(_d,"DocHyperLinkRenderController"),_d);DocHyperLinkRenderController=__decorateClass$2([__decorateParam$2(1,core.Inject(docs.DocInterceptorService)),__decorateParam$2(2,core.Inject(DocHyperLinkPopupService)),__decorateParam$2(3,core.Inject(docsUi.DocRenderController))],DocHyperLinkRenderController);var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");let DocHyperLinkEventRenderController=(_e=class extends core.Disposable{constructor(_context,_docEventManagerService,_commandService,_hyperLinkPopupService,_docSkeletonManagerService,_docSelectionManagerService){super(),this._context=_context,this._docEventManagerService=_docEventManagerService,this._commandService=_commandService,this._hyperLinkPopupService=_hyperLinkPopupService,this._docSkeletonManagerService=_docSkeletonManagerService,this._docSelectionManagerService=_docSelectionManagerService,this._initHover(),this._initClick()}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(ToggleDocHyperLinkInfoPopupOperation.id)}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(ranges=>{var _a2;const link=ranges.find(range=>range.range.rangeType===core.CustomRangeType.HYPERLINK),activeRanges=this._docSelectionManagerService.getCurrentTextRanges(),currentSegmentId=activeRanges==null?void 0:activeRanges[0].segmentId;if(((_a2=link==null?void 0:link.segmentId)!=null?_a2:"")!==currentSegmentId){this._hideInfoPopup();return}link?this._commandService.executeCommand(ToggleDocHyperLinkInfoPopupOperation.id,{unitId:this._context.unitId,linkId:link.range.rangeId,segmentId:link.segmentId,segmentPage:link.segmentPageIndex,rangeId:link.range.rangeId}):this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(range=>{const link=range.range;link&&this._commandService.executeCommand(ClickDocHyperLinkOperation.id,{unitId:this._context.unitId,linkId:link.rangeId,segmentId:range.segmentId})}))}},__name(_e,"DocHyperLinkEventRenderController"),_e);DocHyperLinkEventRenderController=__decorateClass$1([__decorateParam$1(1,core.Inject(docsUi.DocEventManagerService)),__decorateParam$1(2,core.ICommandService),__decorateParam$1(3,core.Inject(DocHyperLinkPopupService)),__decorateParam$1(4,core.Inject(docs.DocSkeletonManagerService)),__decorateParam$1(5,core.Inject(docs.DocSelectionManagerService))],DocHyperLinkEventRenderController);const PLUGIN_CONFIG_KEY="docs-hyper-link-ui.config",defaultPluginConfig={};var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField");exports2.UniverDocsHyperLinkUIPlugin=(_f=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_renderManagerSrv,_configService){super(),this._config=_config,this._injector=_injector,this._renderManagerSrv=_renderManagerSrv,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[DocHyperLinkPopupService],[DocHyperLinkUIController],[DocHyperLinkSelectionController]].forEach(dep=>{this._injector.add(dep)})}onRendered(){this._initRenderModule()}_initRenderModule(){[[DocHyperLinkRenderController],[DocHyperLinkEventRenderController]].forEach(dep=>{this._renderManagerSrv.registerRenderModule(core.UniverInstanceType.UNIVER_DOC,dep)})}},__name(_f,"UniverDocsHyperLinkUIPlugin"),_f),__publicField2(exports2.UniverDocsHyperLinkUIPlugin,"pluginName",DOC_HYPER_LINK_UI_PLUGIN),__publicField2(exports2.UniverDocsHyperLinkUIPlugin,"type",core.UniverInstanceType.UNIVER_DOC),exports2.UniverDocsHyperLinkUIPlugin=__decorateClass([core.DependentOn(docsHyperLink.UniverDocsHyperLinkPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,engineRender.IRenderManagerService),__decorateParam(3,core.IConfigService)],exports2.UniverDocsHyperLinkUIPlugin),Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/docs-hyper-link"),require("@univerjs/engine-render"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("rxjs"),require("@univerjs/design"),require("@univerjs/ui"),require("react"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-hyper-link","@univerjs/engine-render","@univerjs/docs","@univerjs/docs-ui","rxjs","@univerjs/design","@univerjs/ui","react","clsx"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverDocsHyperLinkUi={},global.UniverCore,global.UniverDocsHyperLink,global.UniverEngineRender,global.UniverDocs,global.UniverDocsUi,global.rxjs,global.UniverDesign,global.UniverUi,global.React,global.clsx))})(this,function(exports2,core,docsHyperLink,engineRender,docs,docsUi,rxjs,design,ui,React,cs){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c,_d,_e,_f;const PLUGIN_CONFIG_KEY="docs-hyper-link-ui.config",defaultPluginConfig={},AddDocHyperLinkCommand={type:core.CommandType.COMMAND,id:"docs.command.add-hyper-link",async handler(accessor,params){if(!params)return!1;const{payload,unitId,selection}=params,commandService=accessor.get(core.ICommandService),id=core.generateRandomId(),doMutation=docsUi.addCustomRangeBySelectionFactory(accessor,{rangeId:id,rangeType:core.CustomRangeType.HYPERLINK,properties:{url:payload},unitId,selection});return doMutation?commandService.syncExecuteCommand(doMutation.id,doMutation.params):!1}},UpdateDocHyperLinkCommand={id:"docs.command.update-hyper-link",type:core.CommandType.COMMAND,handler(accessor,params){var _a2;if(!params)return!1;const{unitId,payload,segmentId}=params,commandService=accessor.get(core.ICommandService),univerInstanceService=accessor.get(core.IUniverInstanceService),currentSelection=accessor.get(docs.DocSelectionManagerService).getActiveTextRange(),doc=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC);if(!currentSelection||!doc)return!1;const newId=core.generateRandomId(),textRun=(_a2=core.getBodySlice(doc.getSelfOrHeaderFooterModel(segmentId).getBody(),currentSelection.startOffset,currentSelection.endOffset).textRuns)==null?void 0:_a2[0];textRun&&(textRun.ed=params.label.length+1);const replaceSelection=docsUi.replaceSelectionFactory(accessor,{unitId,body:{dataStream:`${core.DataStreamTreeTokenType.CUSTOM_RANGE_START}${params.label}${core.DataStreamTreeTokenType.CUSTOM_RANGE_END}`,customRanges:[{rangeId:newId,rangeType:core.CustomRangeType.HYPERLINK,startIndex:0,endIndex:params.label.length+1,properties:{url:payload}}],textRuns:textRun?[textRun]:void 0},selection:{startOffset:currentSelection.startOffset,endOffset:currentSelection.endOffset,collapsed:!1,segmentId}});return replaceSelection?commandService.syncExecuteCommand(replaceSelection.id,replaceSelection.params):!1}},styles$1={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 hasProtocol(urlString){return/^[a-zA-Z]+:\/\//.test(urlString)}__name(hasProtocol,"hasProtocol");function isEmail(url){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url)}__name(isEmail,"isEmail");function transformUrl(urlStr){return hasProtocol(urlStr)?urlStr:isEmail(urlStr)?`mailto://${urlStr}`:`https://${urlStr}`}__name(transformUrl,"transformUrl");const DocHyperLinkEdit=__name(()=>{var _a2;const hyperLinkService=core.useDependency(DocHyperLinkPopupService),localeService=core.useDependency(core.LocaleService),editing=core.useObservable(hyperLinkService.editingLink$),commandService=core.useDependency(core.ICommandService),univerInstanceService=core.useDependency(core.IUniverInstanceService),renderManagerService=core.useDependency(engineRender.IRenderManagerService),docSelectionManagerService=core.useDependency(docs.DocSelectionManagerService),[link,setLink]=React.useState(""),[label,setLabel]=React.useState(""),[showError,setShowError]=React.useState(!1),isLegal=core.Tools.isLegalUrl(link),doc=editing?univerInstanceService.getUnit(editing.unitId,core.UniverInstanceType.UNIVER_DOC):univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC),docSelectionRenderService=(_a2=renderManagerService.getRenderById(doc.getUnitId()))==null?void 0:_a2.with(docsUi.DocSelectionRenderService);React.useEffect(()=>{var _a3,_b2,_c2,_d2,_e2,_f2,_g,_h,_i;const activeRange=docSelectionManagerService.getActiveTextRange();if(!activeRange)return;if(editing){const body=(_a3=doc==null?void 0:doc.getSelfOrHeaderFooterModel(editing.segmentId))==null?void 0:_a3.getBody(),matchedRange2=(_b2=body==null?void 0:body.customRanges)==null?void 0:_b2.find(i=>(editing==null?void 0:editing.linkId)===i.rangeId);doc&&matchedRange2&&(setLink((_d2=(_c2=matchedRange2.properties)==null?void 0:_c2.url)!=null?_d2:""),setLabel(core.BuildTextUtils.transform.getPlainText(core.getBodySlice(body,matchedRange2.startIndex,matchedRange2.endIndex).dataStream)));return}const matchedRange=(_g=(_f2=(_e2=doc==null?void 0:doc.getSelfOrHeaderFooterModel(activeRange.segmentId))==null?void 0:_e2.getBody())==null?void 0:_f2.customRanges)==null?void 0:_g.find(i=>Math.max(activeRange.startOffset,i.startIndex)<=Math.min(activeRange.endOffset-1,i.endIndex));doc&&matchedRange&&setLink((_i=(_h=matchedRange==null?void 0:matchedRange.properties)==null?void 0:_h.url)!=null?_i:"")},[doc,editing,docSelectionManagerService,univerInstanceService]),React.useEffect(()=>(docSelectionRenderService&&docSelectionRenderService.blurEditor(),()=>{docSelectionRenderService&&docSelectionRenderService.focusEditor()}),[docSelectionRenderService]);const handleCancel=__name(()=>{hyperLinkService.hideEditPopup()},"handleCancel"),handleConfirm=__name(()=>{if(setShowError(!0),!isLegal||!doc)return;const linkFinal=transformUrl(link);if(!editing)commandService.executeCommand(AddDocHyperLinkCommand.id,{unitId:doc.getUnitId(),payload:linkFinal});else{if(!label)return;commandService.executeCommand(UpdateDocHyperLinkCommand.id,{unitId:doc.getUnitId(),payload:linkFinal,linkId:editing.linkId,label,segmentId:editing.segmentId})}hyperLinkService.hideEditPopup()},"handleConfirm");if(doc)return React.createElement("div",{className:styles$1.docsLinkEdit},React.createElement("div",null,editing?React.createElement(design.FormLayout,{label:localeService.t("docLink.edit.label"),error:showError&&!label?localeService.t("docLink.edit.labelError"):""},React.createElement(design.Input,{value:label,onChange:setLabel,autoFocus:!0,onKeyDown:__name(evt=>{evt.keyCode===ui.KeyCode.ENTER&&handleConfirm()},"onKeyDown")})):null,React.createElement(design.FormLayout,{label:localeService.t("docLink.edit.address"),error:showError&&!isLegal?localeService.t("docLink.edit.addressError"):""},React.createElement(design.Input,{value:link,onChange:setLink,autoFocus:!0,onKeyDown:__name(evt=>{evt.keyCode===ui.KeyCode.ENTER&&handleConfirm()},"onKeyDown")}))),React.createElement("div",{className:styles$1.docsLinkEditButtons},React.createElement(design.Button,{className:styles$1.docsLinkEditButton,onClick:handleCancel},localeService.t("docLink.edit.cancel")),React.createElement(design.Button,{disabled:!link,className:styles$1.docsLinkEditButton,type:"primary",onClick:handleConfirm},localeService.t("docLink.edit.confirm"))))},"DocHyperLinkEdit");DocHyperLinkEdit.componentKey="docs-hyper-link-edit";var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=React.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=React.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return React.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a2){var key=_a2[0],value=_a2[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a2,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a2=node.children)===null||_a2===void 0)&&_a2.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid"),IconBase.displayName="UniverIcon";var element$3={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"}}]},CopySingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"copy-single",ref,icon:element$3}))});CopySingle.displayName="CopySingle";var element$2={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},LinkSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"link-single",ref,icon:element$2}))});LinkSingle.displayName="LinkSingle";var element$1={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"}}]},UnlinkSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"unlink-single",ref,icon:element$1}))});UnlinkSingle.displayName="UnlinkSingle";var element={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"}}]},WriteSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"write-single",ref,icon:element}))});WriteSingle.displayName="WriteSingle";const DeleteDocHyperLinkCommand={type:core.CommandType.COMMAND,id:"docs.command.delete-hyper-link",async handler(accessor,params){if(!params)return!1;const{unitId,linkId,segmentId}=params,commandService=accessor.get(core.ICommandService),doMutation=docsUi.deleteCustomRangeFactory(accessor,{unitId,rangeId:linkId,segmentId});return doMutation?await commandService.syncExecuteCommand(doMutation.id,doMutation.params):!1}},shouldDisableAddLink=__name(accessor=>{var _a2;const textSelectionService=accessor.get(docs.DocSelectionManagerService),univerInstanceService=accessor.get(core.IUniverInstanceService),textRanges=textSelectionService.getDocRanges();if(!textRanges.length||textRanges.length>1)return!0;const activeRange=textRanges[0],doc=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC);if(!doc||!activeRange||activeRange.collapsed)return!0;const body=doc.getSelfOrHeaderFooterModel(activeRange.segmentId).getBody(),paragraphs=body==null?void 0:body.paragraphs;if(!paragraphs)return!0;for(let i=0,len=paragraphs.length;i<len;i++){const p=paragraphs[i];if(activeRange.startOffset<=p.startIndex&&activeRange.endOffset>p.startIndex)return!0;if(p.startIndex>activeRange.endOffset)break}return!core.BuildTextUtils.customRange.getCustomRangesInterestsWithRange(activeRange,(_a2=body.customRanges)!=null?_a2:[]).every(range=>range.rangeType===core.CustomRangeType.HYPERLINK)},"shouldDisableAddLink"),ShowDocHyperLinkEditPopupOperation={type:core.CommandType.OPERATION,id:"doc.operation.show-hyper-link-edit-popup",handler(accessor,params){var _a2;const linkInfo=params==null?void 0:params.link,univerInstanceService=accessor.get(core.IUniverInstanceService);if(shouldDisableAddLink(accessor)&&!linkInfo)return!1;const hyperLinkService=accessor.get(DocHyperLinkPopupService),unitId=(linkInfo==null?void 0:linkInfo.unitId)||((_a2=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC))==null?void 0:_a2.getUnitId());return unitId?(hyperLinkService.showEditPopup(unitId,linkInfo),!0):!1}},ToggleDocHyperLinkInfoPopupOperation={type:core.CommandType.OPERATION,id:"doc.operation.toggle-hyper-link-info-popup",handler(accessor,params){const hyperLinkService=accessor.get(DocHyperLinkPopupService);return params?(hyperLinkService.showInfoPopup(params),!0):(hyperLinkService.hideInfoPopup(),!0)}},ClickDocHyperLinkOperation={type:core.CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(accessor,params){var _a2,_b2,_c2;if(!params)return!1;const{unitId,linkId,segmentId}=params,doc=accessor.get(core.IUniverInstanceService).getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),body=doc==null?void 0:doc.getSelfOrHeaderFooterModel(segmentId).getBody(),link=(_c2=(_b2=(_a2=body==null?void 0:body.customRanges)==null?void 0:_a2.find(range=>range.rangeId===linkId&&range.rangeType===core.CustomRangeType.HYPERLINK))==null?void 0:_b2.properties)==null?void 0:_c2.url;return link&&window.open(link,"_blank","noopener noreferrer"),!0}},styles={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"},DocLinkPopup=__name(()=>{var _a2,_b2;const hyperLinkService=core.useDependency(DocHyperLinkPopupService),commandService=core.useDependency(core.ICommandService),messageService=core.useDependency(ui.IMessageService),localeService=core.useDependency(core.LocaleService),currentPopup=ui.useObservable(hyperLinkService.showingLink$),univerInstanceService=core.useDependency(core.IUniverInstanceService);if(!currentPopup)return null;const{unitId,linkId,segmentId}=currentPopup,doc=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),body=doc==null?void 0:doc.getSelfOrHeaderFooterModel(segmentId).getBody(),link=(_a2=body==null?void 0:body.customRanges)==null?void 0:_a2.find(range=>range.rangeId===linkId&&range.rangeType===core.CustomRangeType.HYPERLINK);if(!link)return null;const url=(_b2=link.properties)==null?void 0:_b2.url;return React.createElement("div",{className:styles.docLink,onClick:__name(()=>{hyperLinkService.hideInfoPopup()},"onClick")},React.createElement("div",{className:cs(styles.docLinkContent),onClick:__name(()=>window.open(url),"onClick")},React.createElement("div",{className:styles.docLinkType},React.createElement(LinkSingle,null)),React.createElement(design.Tooltip,{showIfEllipsis:!0,title:url},React.createElement("span",{className:styles.docLinkUrl},url))),React.createElement("div",{className:styles.docLinkOperations},React.createElement("div",{className:cs(styles.docLinkOperation),onClick:__name(()=>{navigator.clipboard.writeText(url),messageService.show({content:localeService.t("docLink.info.coped"),type:design.MessageType.Info})},"onClick")},React.createElement(design.Tooltip,{placement:"bottom",title:localeService.t("docLink.info.copy")},React.createElement(CopySingle,null))),React.createElement("div",{className:styles.docLinkOperation,onClick:__name(()=>{commandService.executeCommand(ShowDocHyperLinkEditPopupOperation.id,{link:currentPopup})},"onClick")},React.createElement(design.Tooltip,{placement:"bottom",title:localeService.t("docLink.info.edit")},React.createElement(WriteSingle,null))),React.createElement("div",{className:styles.docLinkOperation,onClick:__name(()=>{commandService.executeCommand(DeleteDocHyperLinkCommand.id,{unitId,linkId:link.rangeId,segmentId})},"onClick")},React.createElement(design.Tooltip,{placement:"bottom",title:localeService.t("docLink.info.cancel")},React.createElement(UnlinkSingle,null)))))},"DocLinkPopup");DocLinkPopup.componentKey="univer.doc.link-info-popup";var __defProp$5=Object.defineProperty,__getOwnPropDesc$5=Object.getOwnPropertyDescriptor,__decorateClass$5=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$5(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$5(target,key,result),result},"__decorateClass$5"),__decorateParam$5=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$5");const SKIT_PLACEHOLDER=0;let DocHyperLinkPopupService=(_a=class extends core.Disposable{constructor(_docCanvasPopupManagerService,_textSelectionManagerService,_univerInstanceService){super();__publicField(this,"_editingLink$",new rxjs.BehaviorSubject(null));__publicField(this,"_showingLink$",new rxjs.BehaviorSubject(null));__publicField(this,"editingLink$",this._editingLink$.asObservable());__publicField(this,"showingLink$",this._showingLink$.asObservable());__publicField(this,"_editPopup",null);__publicField(this,"_infoPopup",null);this._docCanvasPopupManagerService=_docCanvasPopupManagerService,this._textSelectionManagerService=_textSelectionManagerService,this._univerInstanceService=_univerInstanceService,this.disposeWithMe(()=>{this._editingLink$.complete(),this._showingLink$.complete()})}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(unitId,linkInfo){var _a2,_b2,_c2;this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(linkInfo);let activeRange=this._textSelectionManagerService.getActiveTextRange();if(linkInfo){const{unitId:unitId2,linkId,segmentId,segmentPage}=linkInfo,doc=this._univerInstanceService.getUnit(unitId2,core.UniverInstanceType.UNIVER_DOC),range=(_c2=(_b2=(_a2=doc==null?void 0:doc.getSelfOrHeaderFooterModel(segmentId))==null?void 0:_a2.getBody())==null?void 0:_b2.customRanges)==null?void 0:_c2.find(i=>i.rangeId===linkId);range&&(activeRange={collapsed:!1,startOffset:range.startIndex+SKIT_PLACEHOLDER,endOffset:range.endIndex+1,segmentId,segmentPage},this._textSelectionManagerService.replaceTextRanges([{startOffset:range.startIndex,endOffset:range.endIndex+1}]))}return activeRange?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(activeRange,{componentKey:DocHyperLinkEdit.componentKey,direction:"bottom"},unitId),this._editPopup):null}hideEditPopup(){var _a2;this._editingLink$.next(null),(_a2=this._editPopup)==null||_a2.dispose()}showInfoPopup(info){var _a2,_b2,_c2,_d2,_e2,_f2;const{linkId,unitId,segmentId,segmentPage}=info;if(((_a2=this.showing)==null?void 0:_a2.linkId)===linkId&&((_b2=this.showing)==null?void 0:_b2.unitId)===unitId&&((_c2=this.showing)==null?void 0:_c2.segmentId)===segmentId&&((_d2=this.showing)==null?void 0:_d2.segmentPage)===segmentPage)return;this._infoPopup&&this._infoPopup.dispose();const doc=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC);if(!doc)return;const range=(_f2=(_e2=doc.getSelfOrHeaderFooterModel(info.segmentId).getBody())==null?void 0:_e2.customRanges)==null?void 0:_f2.find(i=>i.rangeId===linkId);if(this._showingLink$.next({unitId,linkId,segmentId,segmentPage}),!!range)return this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:range.startIndex+SKIT_PLACEHOLDER,endOffset:range.endIndex+1,segmentId:info.segmentId,segmentPage:info.segmentPage},{componentKey:DocLinkPopup.componentKey,direction:"top-center",multipleDirection:"top",onClickOutside:__name(()=>{this.hideInfoPopup()},"onClickOutside")},info.unitId),this._infoPopup}hideInfoPopup(){var _a2;this._showingLink$.next(null),(_a2=this._infoPopup)==null||_a2.dispose()}},__name(_a,"DocHyperLinkPopupService"),_a);DocHyperLinkPopupService=__decorateClass$5([__decorateParam$5(0,core.Inject(docsUi.DocCanvasPopManagerService)),__decorateParam$5(1,core.Inject(docs.DocSelectionManagerService)),__decorateParam$5(2,core.IUniverInstanceService)],DocHyperLinkPopupService);var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4");let DocHyperLinkSelectionController=(_b=class extends core.Disposable{constructor(_commandService,_univerInstanceService,_docHyperLinkService){super(),this._commandService=_commandService,this._univerInstanceService=_univerInstanceService,this._docHyperLinkService=_docHyperLinkService,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(commandInfo=>{var _a2,_b2,_c2;if(commandInfo.id===docs.SetTextSelectionsOperation.id){const params=commandInfo.params,{unitId,ranges,segmentId}=params,doc=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),primary=ranges[0];if(primary&&doc){const{startOffset,endOffset,collapsed,segmentPage}=primary,customRanges=(_b2=(_a2=doc.getSelfOrHeaderFooterModel(segmentId))==null?void 0:_a2.getBody())==null?void 0:_b2.customRanges;if(collapsed){const index=(_c2=customRanges==null?void 0:customRanges.findIndex(value=>value.startIndex<startOffset&&value.endIndex>endOffset-1))!=null?_c2:-1;if(index>-1){const customRange=customRanges[index];this._docHyperLinkService.showInfoPopup({unitId,linkId:customRange.rangeId,segmentId,segmentPage});return}}else if(customRanges==null?void 0:customRanges.find(value=>value.startIndex<=startOffset&&value.endIndex>=endOffset-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}},__name(_b,"DocHyperLinkSelectionController"),_b);DocHyperLinkSelectionController=__decorateClass$4([core.OnLifecycle(core.LifecycleStages.Ready,DocHyperLinkSelectionController),__decorateParam$4(0,core.ICommandService),__decorateParam$4(1,core.IUniverInstanceService),__decorateParam$4(2,core.Inject(DocHyperLinkPopupService))],DocHyperLinkSelectionController);var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3");let DocHyperLinkEventRenderController=(_c=class extends core.Disposable{constructor(_context,_docEventManagerService,_commandService,_hyperLinkPopupService,_docSkeletonManagerService,_docSelectionManagerService){super(),this._context=_context,this._docEventManagerService=_docEventManagerService,this._commandService=_commandService,this._hyperLinkPopupService=_hyperLinkPopupService,this._docSkeletonManagerService=_docSkeletonManagerService,this._docSelectionManagerService=_docSelectionManagerService,this._initHover(),this._initClick()}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(ToggleDocHyperLinkInfoPopupOperation.id)}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(ranges=>{var _a2;const link=ranges.find(range=>range.range.rangeType===core.CustomRangeType.HYPERLINK),activeRanges=this._docSelectionManagerService.getTextRanges(),currentSegmentId=activeRanges==null?void 0:activeRanges[0].segmentId;if(((_a2=link==null?void 0:link.segmentId)!=null?_a2:"")!==currentSegmentId){this._hideInfoPopup();return}link?this._commandService.executeCommand(ToggleDocHyperLinkInfoPopupOperation.id,{unitId:this._context.unitId,linkId:link.range.rangeId,segmentId:link.segmentId,segmentPage:link.segmentPageIndex,rangeId:link.range.rangeId}):this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(range=>{const link=range.range;link&&this._commandService.executeCommand(ClickDocHyperLinkOperation.id,{unitId:this._context.unitId,linkId:link.rangeId,segmentId:range.segmentId})}))}},__name(_c,"DocHyperLinkEventRenderController"),_c);DocHyperLinkEventRenderController=__decorateClass$3([__decorateParam$3(1,core.Inject(docsUi.DocEventManagerService)),__decorateParam$3(2,core.ICommandService),__decorateParam$3(3,core.Inject(DocHyperLinkPopupService)),__decorateParam$3(4,core.Inject(docs.DocSkeletonManagerService)),__decorateParam$3(5,core.Inject(docs.DocSelectionManagerService))],DocHyperLinkEventRenderController);var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");let DocHyperLinkRenderController=(_d=class extends core.Disposable{constructor(_context,_docInterceptorService,_hyperLinkService,_docRenderController){super(),this._context=_context,this._docInterceptorService=_docInterceptorService,this._hyperLinkService=_hyperLinkService,this._docRenderController=_docRenderController,this._init(),this._initReRender()}_init(){this._docInterceptorService.intercept(docs.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:__name((data,pos,next)=>{if(!data)return next(data);const{unitId}=pos,activeLink=this._hyperLinkService.showing,{linkId,unitId:linkUnitId}=activeLink||{},isActive=linkUnitId===unitId&&data.rangeId===linkId;return next({...data,active:isActive})},"handler")})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(rxjs.distinctUntilChanged((prev,aft)=>(prev==null?void 0:prev.linkId)===(aft==null?void 0:aft.linkId)&&(prev==null?void 0:prev.unitId)===(aft==null?void 0:aft.unitId)),rxjs.pairwise()).subscribe(([preLink,link])=>{link?link.unitId===this._context.unitId&&this._docRenderController.reRender(link.unitId):preLink&&preLink.unitId===this._context.unitId&&this._docRenderController.reRender(preLink.unitId)}))}},__name(_d,"DocHyperLinkRenderController"),_d);DocHyperLinkRenderController=__decorateClass$2([__decorateParam$2(1,core.Inject(docs.DocInterceptorService)),__decorateParam$2(2,core.Inject(DocHyperLinkPopupService)),__decorateParam$2(3,core.Inject(docsUi.DocRenderController))],DocHyperLinkRenderController);const DOC_LINK_ICON="doc-hyper-link-icon";function AddHyperLinkMenuItemFactory(accessor){return{id:ShowDocHyperLinkEditPopupOperation.id,type:ui.MenuItemType.BUTTON,icon:DOC_LINK_ICON,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC),disabled$:new rxjs.Observable(function(subscribe){const observer=accessor.get(docs.DocSelectionManagerService).textSelection$.pipe(rxjs.debounceTime(16)).subscribe(()=>{subscribe.next(shouldDisableAddLink(accessor))});return()=>{observer.unsubscribe()}})}}__name(AddHyperLinkMenuItemFactory,"AddHyperLinkMenuItemFactory");const addLinkShortcut={id:ShowDocHyperLinkEditPopupOperation.id,binding:ui.MetaKeys.CTRL_COMMAND|ui.KeyCode.K,description:"docLink.menu.tooltip",preconditions:docsUi.whenDocAndEditorFocused},menuSchema={[ui.RibbonStartGroup.OTHERS]:{[ShowDocHyperLinkEditPopupOperation.id]:{order:0,menuItemFactory:AddHyperLinkMenuItemFactory}},[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.DATA]:{[ShowDocHyperLinkEditPopupOperation.id]:{order:0,menuItemFactory:AddHyperLinkMenuItemFactory}}}};var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");let DocHyperLinkUIController=(_e=class extends core.Disposable{constructor(_componentManager,_commandService,_menuManagerService,_injector,_shortcutService){super(),this._componentManager=_componentManager,this._commandService=_commandService,this._menuManagerService=_menuManagerService,this._injector=_injector,this._shortcutService=_shortcutService,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[DocHyperLinkEdit,DocHyperLinkEdit.componentKey],[DocLinkPopup,DocLinkPopup.componentKey],[LinkSingle,DOC_LINK_ICON]].forEach(([comp,key])=>{this._componentManager.register(key,comp)})}_initCommands(){[AddDocHyperLinkCommand,UpdateDocHyperLinkCommand,DeleteDocHyperLinkCommand,ShowDocHyperLinkEditPopupOperation,ToggleDocHyperLinkInfoPopupOperation,ClickDocHyperLinkOperation].forEach(command=>{this._commandService.registerCommand(command)})}_initShortcut(){[addLinkShortcut].forEach(shortcut=>{this._shortcutService.registerShortcut(shortcut)})}_initMenus(){this._menuManagerService.mergeMenu(menuSchema)}},__name(_e,"DocHyperLinkUIController"),_e);DocHyperLinkUIController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Starting,DocHyperLinkUIController),__decorateParam$1(0,core.Inject(ui.ComponentManager)),__decorateParam$1(1,core.ICommandService),__decorateParam$1(2,ui.IMenuManagerService),__decorateParam$1(3,core.Inject(core.Injector)),__decorateParam$1(4,ui.IShortcutService)],DocHyperLinkUIController);const DOC_HYPER_LINK_UI_PLUGIN="DOC_HYPER_LINK_UI_PLUGIN";var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField");exports2.UniverDocsHyperLinkUIPlugin=(_f=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_renderManagerSrv,_configService){super(),this._config=_config,this._injector=_injector,this._renderManagerSrv=_renderManagerSrv,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[DocHyperLinkPopupService],[DocHyperLinkUIController],[DocHyperLinkSelectionController]].forEach(dep=>{this._injector.add(dep)})}onRendered(){this._initRenderModule()}_initRenderModule(){[[DocHyperLinkRenderController],[DocHyperLinkEventRenderController]].forEach(dep=>{this._renderManagerSrv.registerRenderModule(core.UniverInstanceType.UNIVER_DOC,dep)})}},__name(_f,"UniverDocsHyperLinkUIPlugin"),_f),__publicField2(exports2.UniverDocsHyperLinkUIPlugin,"pluginName",DOC_HYPER_LINK_UI_PLUGIN),__publicField2(exports2.UniverDocsHyperLinkUIPlugin,"type",core.UniverInstanceType.UNIVER_DOC),exports2.UniverDocsHyperLinkUIPlugin=__decorateClass([core.DependentOn(docsHyperLink.UniverDocsHyperLinkPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,engineRender.IRenderManagerService),__decorateParam(3,core.IConfigService)],exports2.UniverDocsHyperLinkUIPlugin),Object.defineProperty(exports2,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.
|
|
3
|
+
"version": "0.3.0-alpha.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer thread comment plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -48,31 +48,31 @@
|
|
|
48
48
|
"clsx": ">=2.0.0",
|
|
49
49
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
50
50
|
"rxjs": ">=7.0.0",
|
|
51
|
-
"@univerjs/core": "0.
|
|
52
|
-
"@univerjs/
|
|
53
|
-
"@univerjs/docs-
|
|
54
|
-
"@univerjs/engine-render": "0.
|
|
55
|
-
"@univerjs/ui": "0.
|
|
56
|
-
"@univerjs/docs": "0.
|
|
57
|
-
"@univerjs/
|
|
51
|
+
"@univerjs/core": "0.3.0-alpha.0",
|
|
52
|
+
"@univerjs/design": "0.3.0-alpha.0",
|
|
53
|
+
"@univerjs/docs-hyper-link": "0.3.0-alpha.0",
|
|
54
|
+
"@univerjs/engine-render": "0.3.0-alpha.0",
|
|
55
|
+
"@univerjs/ui": "0.3.0-alpha.0",
|
|
56
|
+
"@univerjs/docs": "0.3.0-alpha.0",
|
|
57
|
+
"@univerjs/docs-ui": "0.3.0-alpha.0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@univerjs/icons": "^0.1.78",
|
|
61
61
|
"clsx": "^2.1.1",
|
|
62
|
-
"@univerjs/core": "0.
|
|
63
|
-
"@univerjs/design": "0.
|
|
64
|
-
"@univerjs/docs
|
|
65
|
-
"@univerjs/
|
|
66
|
-
"@univerjs/
|
|
67
|
-
"@univerjs/ui": "0.
|
|
62
|
+
"@univerjs/core": "0.3.0-alpha.0",
|
|
63
|
+
"@univerjs/design": "0.3.0-alpha.0",
|
|
64
|
+
"@univerjs/docs": "0.3.0-alpha.0",
|
|
65
|
+
"@univerjs/engine-render": "0.3.0-alpha.0",
|
|
66
|
+
"@univerjs/docs-hyper-link": "0.3.0-alpha.0",
|
|
67
|
+
"@univerjs/ui": "0.3.0-alpha.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"react": "18.3.1",
|
|
71
71
|
"rxjs": "^7.8.1",
|
|
72
72
|
"typescript": "^5.6.2",
|
|
73
|
-
"vite": "^5.4.
|
|
74
|
-
"vitest": "^2.
|
|
75
|
-
"@univerjs-infra/shared": "0.
|
|
73
|
+
"vite": "^5.4.8",
|
|
74
|
+
"vitest": "^2.1.1",
|
|
75
|
+
"@univerjs-infra/shared": "0.3.0-alpha.0"
|
|
76
76
|
},
|
|
77
77
|
"univerSpace": {
|
|
78
78
|
".": {
|