@univerjs/sheets-crosshair-highlight 0.8.2-nightly.202506261607 → 0.8.3-nightly.202506271607

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var W=Object.defineProperty;var F=(n,e,t)=>e in n?W(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var l=(n,e,t)=>F(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),w=require("@univerjs/engine-render"),_=require("@univerjs/ui"),u=require("rxjs"),P=require("react/jsx-runtime"),j=require("@univerjs/design"),v=require("react"),T=require("@univerjs/sheets"),M=require("@univerjs/sheets-ui"),X="sheets-crosshair-highlight.config",A={};var h=function(){return h=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},h.apply(this,arguments)},z=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},L=v.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,s=n.extend,o=z(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),g=v.useRef("_".concat(Q()));return G(t,"".concat(r),{defIds:t.defIds,idSuffix:g.current},h({ref:e,className:c},o),s)});function G(n,e,t,r,i){return v.createElement(n.tag,h(h({key:e},K(n,t,i)),r),(J(n,t).children||[]).map(function(s,o){return G(s,"".concat(e,"-").concat(n.tag,"-").concat(o),t,void 0,i)}))}function K(n,e,t){var r=h({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(s){var o=s[0],c=s[1];o==="mask"&&typeof c=="string"&&(r[o]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(s){var o=s[0],c=s[1];typeof c=="string"&&(r[o]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function J(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?h(h({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.includes(i.attrs.id)?h(h({},i),{attrs:h(h({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function Q(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var ee={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z",fillRule:"evenodd",clipRule:"evenodd"}}]},V=v.forwardRef(function(n,e){return v.createElement(L,Object.assign({},n,{id:"cross-highlighting-icon",ref:e,icon:ee}))});V.displayName="CrossHighlightingIcon";const x=["rgba(158, 109, 227, 0.3)","rgba(254, 75, 75, 0.3)","rgba(255, 140, 81, 0.3)","rgba(164, 220, 22, 0.3)","rgba(45, 174, 255, 0.3)","rgba(58, 96, 247, 0.3)","rgba(242, 72, 166, 0.3)","rgba(153, 153, 153, 0.3)","rgba(158, 109, 227, 0.15)","rgba(254, 75, 75, 0.15)","rgba(255, 140, 81, 0.15)","rgba(164, 220, 22, 0.15)","rgba(45, 174, 255, 0.15)","rgba(58, 96, 247, 0.15)","rgba(242, 72, 166, 0.15)","rgba(153, 153, 153, 0.15)"];class d extends a.Disposable{constructor(){super(...arguments);l(this,"_enabled$",new u.BehaviorSubject(!1));l(this,"enabled$",this._enabled$.asObservable());l(this,"_color$",new u.BehaviorSubject(x[0]));l(this,"color$",this._color$.asObservable())}get enabled(){return this._enabled$.getValue()}get color(){return this._color$.getValue()}dispose(){this._enabled$.complete()}setEnabled(t){this._enabled$.next(t)}setColor(t){this._color$.next(t)}}const I={id:"sheet.operation.toggle-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(d),t=e.enabled;return e.setEnabled(!t),!0}},$={id:"sheet.operation.set-crosshair-highlight-color",type:a.CommandType.OPERATION,handler(n,{value:e}){const t=n.get(d);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},k={id:"sheet.operation.enable-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(d);return e.enabled?!1:(e.setEnabled(!0),!0)}},U={id:"sheet.operation.disable-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(d);return e.enabled?(e.setEnabled(!1),!0):!1}};function te(n){const{onChange:e}=n,t=_.useDependency(d),r=_.useObservable(t.color$),i=v.useCallback(s=>{e==null||e(s)},[e]);return P.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3",children:x.map(s=>P.jsx("div",{className:j.clsx("univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1 univer-transition-shadow hover:univer-ring-primary-600/40 hover:univer-ring-[1.5px]",j.borderClassName,{"univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600":s===r}),style:{backgroundColor:s},onClick:()=>i(s)},s))})}const D="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function re(n){const e=n.get(d);return{id:I.id,tooltip:"crosshair.button.tooltip",type:_.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingIcon",selections:[{label:{name:D,hoverable:!1,selectable:!1}}],selectionsCommandId:$.id,activated$:e.enabled$,hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const ne={[_.ContextMenuPosition.FOOTER_MENU]:{[_.ContextMenuGroup.OTHERS]:{[I.id]:{order:0,menuItemFactory:re}}}};var ie=Object.getOwnPropertyDescriptor,se=(n,e,t,r)=>{for(var i=r>1?void 0:r?ie(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(i)||i);return i},E=(n,e)=>(t,r)=>e(t,r,n);let H=class extends a.Disposable{constructor(n,e,t){super(),this._componentMgr=n,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[I,$,k,U].forEach(n=>this._cmdSrv.registerCommand(n))}_initMenus(){this._menuManagerService.mergeMenu(ne)}_initComponents(){this._componentMgr.register(D,te),this._componentMgr.register("CrossHighlightingIcon",V)}};H=se([E(0,a.Inject(_.ComponentManager)),E(1,_.IMenuManagerService),E(2,a.ICommandService)],H);const oe=1;class ae{constructor(){l(this,"_selectedRanges",[]);l(this,"_ranges",[])}addRange(e){if(e.rangeType===a.RANGE_TYPE.COLUMN||e.rangeType===a.RANGE_TYPE.ROW||e.rangeType===a.RANGE_TYPE.ALL)return;const t=this._getIntersects(e),r=this._getSplitRanges(e,t);r.length>0&&this._ranges.push(...r)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,t){let r=[e];for(const i of t.concat(this._selectedRanges)){const s=[];for(const o of r){const c=a.Rectangle.subtract(o,i);c&&c.length>0&&s.push(...c)}r=s}return r.filter(i=>i.startRow<=i.endRow&&i.startColumn<=i.endColumn)}_getIntersects(e){const t=[];for(const r of this._ranges){const i=a.Rectangle.getIntersects(r,e);i&&t.push(i)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class ce extends w.Shape{constructor(t,r){super(t,r);l(this,"_color");r&&this.setShapeProps(r)}setShapeProps(t){typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){var i,s;const r=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(s=(i=this._color)==null?void 0:i.a)!=null?s:.5})`;w.Rect.drawWith(t,{width:this.width,height:this.height,fill:r,stroke:void 0,strokeWidth:0,evented:!1})}}var le=Object.getOwnPropertyDescriptor,he=(n,e,t,r)=>{for(var i=r>1?void 0:r?le(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(i)||i);return i},p=(n,e)=>(t,r)=>e(t,r,n);let O=class extends a.Disposable{constructor(e,t,r,i,s,o){super();l(this,"_shapes",[]);l(this,"_rangeCollection",new ae);l(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=r,this._sheetsCrosshairHighlightService=i,this._contextService=s,this._refSelectionsService=o,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const r=t.getRowCount(),i=t.getColumnCount(),s=[];for(const o of e){const{startRow:c,endRow:g,startColumn:S,endColumn:C}=o.range;g-c+1===r||C-S+1===i||s.push(o.range)}this._rangeCollection.setSelectedRanges(s);for(const o of s)this.addSelection(o,t)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(u.combineLatest([this._contextService.subscribeContextValue$(T.REF_SELECTIONS_ENABLED).pipe(u.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(u.tap(t=>this._color=t)),u.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(u.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),u.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(u.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,r,i,s,o,c])=>{if(this._clear(),!i)return;const g=t?c:o;this._rangeCollection.reset(),this._transformSelection(g,e.getActiveSheet()),this.render(this._rangeCollection.getRanges())}))}addSelection(e,t){if(e.rangeType===a.RANGE_TYPE.COLUMN||e.rangeType===a.RANGE_TYPE.ROW||e.rangeType===a.RANGE_TYPE.ALL)return;const r=t.getRowCount(),i=t.getColumnCount(),{startRow:s,endRow:o,startColumn:c,endColumn:g}=e,S={startRow:s,endRow:o,startColumn:0,endColumn:c-1},C={startRow:s,endRow:o,startColumn:g+1,endColumn:i},m={startRow:0,endRow:s-1,startColumn:c,endColumn:g},b={startRow:o+1,endRow:r,startColumn:c,endColumn:g};for(const f of[S,C,m,b])f.startRow<=f.endRow&&f.startColumn<=f.endColumn&&this._rangeCollection.addRange(f)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,r,i){const{startRow:s,endRow:o,startColumn:c,endColumn:g}=e,S=M.getCoordByCell(s,c,r,i),C=M.getCoordByCell(o,g,r,i),{startX:m,startY:b}=S,{endX:f,endY:Y}=C,q=f-m,B=Y-b,Z={left:m,top:b,color:new a.ColorKit(this._color).toRgb(),width:q,height:B,zIndex:oe,evented:!1},N=new ce(`crosshair-${t}`,Z);this._shapes.push(N),r.addObject(N)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:r}=this._context;this._clear();for(let i=0;i<e.length;i++){const s=e[i];this._addShapes(s,i,r,t)}r.makeDirty(!0)}async dispose(){super.dispose()}};O=he([p(1,a.Inject(M.SheetSkeletonManagerService)),p(2,a.Inject(T.SheetsSelectionsService)),p(3,a.Inject(d)),p(4,a.Inject(a.IContextService)),p(5,T.IRefSelectionsService)],O);var ge=Object.getOwnPropertyDescriptor,ue=(n,e,t,r)=>{for(var i=r>1?void 0:r?ge(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(i)||i);return i},y=(n,e)=>(t,r)=>e(t,r,n),R;exports.UniverSheetsCrosshairHighlightPlugin=(R=class extends a.Plugin{constructor(e=A,t,r,i){super(),this._config=e,this._injector=t,this._renderManagerService=r,this._configService=i;const{...s}=a.merge({},A,this._config);this._configService.setConfig(X,s)}onStarting(){[[d],[H]].forEach(e=>this._injector.add(e))}onReady(){[[O]].forEach(e=>this._injector.add(e)),this._injector.get(H),this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,[O])}},l(R,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),l(R,"type",a.UniverInstanceType.UNIVER_SHEET),R);exports.UniverSheetsCrosshairHighlightPlugin=ue([y(1,a.Inject(a.Injector)),y(2,w.IRenderManagerService),y(3,a.IConfigService)],exports.UniverSheetsCrosshairHighlightPlugin);exports.CROSSHAIR_HIGHLIGHT_COLORS=x;exports.DisableCrosshairHighlightOperation=U;exports.EnableCrosshairHighlightOperation=k;exports.SetCrosshairHighlightColorOperation=$;exports.SheetsCrosshairHighlightService=d;exports.ToggleCrosshairHighlightOperation=I;
1
+ "use strict";var W=Object.defineProperty;var F=(n,e,t)=>e in n?W(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var l=(n,e,t)=>F(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),u=require("rxjs"),w=require("@univerjs/engine-render"),_=require("@univerjs/ui"),P=require("react/jsx-runtime"),j=require("@univerjs/design"),v=require("react"),T=require("@univerjs/sheets"),M=require("@univerjs/sheets-ui"),x=["rgba(158, 109, 227, 0.3)","rgba(254, 75, 75, 0.3)","rgba(255, 140, 81, 0.3)","rgba(164, 220, 22, 0.3)","rgba(45, 174, 255, 0.3)","rgba(58, 96, 247, 0.3)","rgba(242, 72, 166, 0.3)","rgba(153, 153, 153, 0.3)","rgba(158, 109, 227, 0.15)","rgba(254, 75, 75, 0.15)","rgba(255, 140, 81, 0.15)","rgba(164, 220, 22, 0.15)","rgba(45, 174, 255, 0.15)","rgba(58, 96, 247, 0.15)","rgba(242, 72, 166, 0.15)","rgba(153, 153, 153, 0.15)"];class d extends a.Disposable{constructor(){super(...arguments);l(this,"_enabled$",new u.BehaviorSubject(!1));l(this,"enabled$",this._enabled$.asObservable());l(this,"_color$",new u.BehaviorSubject(x[0]));l(this,"color$",this._color$.asObservable())}get enabled(){return this._enabled$.getValue()}get color(){return this._color$.getValue()}dispose(){this._enabled$.complete()}setEnabled(t){this._enabled$.next(t)}setColor(t){this._color$.next(t)}}const I={id:"sheet.operation.toggle-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(d),t=e.enabled;return e.setEnabled(!t),!0}},$={id:"sheet.operation.set-crosshair-highlight-color",type:a.CommandType.OPERATION,handler(n,{value:e}){const t=n.get(d);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},L={id:"sheet.operation.enable-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(d);return e.enabled?!1:(e.setEnabled(!0),!0)}},G={id:"sheet.operation.disable-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(d);return e.enabled?(e.setEnabled(!1),!0):!1}},X="sheets-crosshair-highlight.config",A={};var h=function(){return h=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},h.apply(this,arguments)},z=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},V=v.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,s=n.extend,o=z(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),g=v.useRef("_".concat(Q()));return k(t,"".concat(r),{defIds:t.defIds,idSuffix:g.current},h({ref:e,className:c},o),s)});function k(n,e,t,r,i){return v.createElement(n.tag,h(h({key:e},K(n,t,i)),r),(J(n,t).children||[]).map(function(s,o){return k(s,"".concat(e,"-").concat(n.tag,"-").concat(o),t,void 0,i)}))}function K(n,e,t){var r=h({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(s){var o=s[0],c=s[1];o==="mask"&&typeof c=="string"&&(r[o]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(s){var o=s[0],c=s[1];typeof c=="string"&&(r[o]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function J(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?h(h({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.includes(i.attrs.id)?h(h({},i),{attrs:h(h({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function Q(){return Math.random().toString(36).substring(2,8)}V.displayName="UniverIcon";var ee={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z",fillRule:"evenodd",clipRule:"evenodd"}}]},U=v.forwardRef(function(n,e){return v.createElement(V,Object.assign({},n,{id:"cross-highlighting-icon",ref:e,icon:ee}))});U.displayName="CrossHighlightingIcon";function te(n){const{onChange:e}=n,t=_.useDependency(d),r=_.useObservable(t.color$),i=v.useCallback(s=>{e==null||e(s)},[e]);return P.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3",children:x.map(s=>P.jsx("div",{className:j.clsx("univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1 univer-transition-shadow hover:univer-ring-primary-600/40 hover:univer-ring-[1.5px]",j.borderClassName,{"univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600":s===r}),style:{backgroundColor:s},onClick:()=>i(s)},s))})}const D="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function re(n){const e=n.get(d);return{id:I.id,tooltip:"crosshair.button.tooltip",type:_.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingIcon",selections:[{label:{name:D,hoverable:!1,selectable:!1}}],selectionsCommandId:$.id,activated$:e.enabled$,hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const ne={[_.ContextMenuPosition.FOOTER_MENU]:{[_.ContextMenuGroup.OTHERS]:{[I.id]:{order:0,menuItemFactory:re}}}};var ie=Object.getOwnPropertyDescriptor,se=(n,e,t,r)=>{for(var i=r>1?void 0:r?ie(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(i)||i);return i},E=(n,e)=>(t,r)=>e(t,r,n);let H=class extends a.Disposable{constructor(n,e,t){super(),this._componentMgr=n,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[I,$,L,G].forEach(n=>this._cmdSrv.registerCommand(n))}_initMenus(){this._menuManagerService.mergeMenu(ne)}_initComponents(){this._componentMgr.register(D,te),this._componentMgr.register("CrossHighlightingIcon",U)}};H=se([E(0,a.Inject(_.ComponentManager)),E(1,_.IMenuManagerService),E(2,a.ICommandService)],H);const oe=1;class ae{constructor(){l(this,"_selectedRanges",[]);l(this,"_ranges",[])}addRange(e){if(e.rangeType===a.RANGE_TYPE.COLUMN||e.rangeType===a.RANGE_TYPE.ROW||e.rangeType===a.RANGE_TYPE.ALL)return;const t=this._getIntersects(e),r=this._getSplitRanges(e,t);r.length>0&&this._ranges.push(...r)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,t){let r=[e];for(const i of t.concat(this._selectedRanges)){const s=[];for(const o of r){const c=a.Rectangle.subtract(o,i);c&&c.length>0&&s.push(...c)}r=s}return r.filter(i=>i.startRow<=i.endRow&&i.startColumn<=i.endColumn)}_getIntersects(e){const t=[];for(const r of this._ranges){const i=a.Rectangle.getIntersects(r,e);i&&t.push(i)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class ce extends w.Shape{constructor(t,r){super(t,r);l(this,"_color");r&&this.setShapeProps(r)}setShapeProps(t){typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){var i,s;const r=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(s=(i=this._color)==null?void 0:i.a)!=null?s:.5})`;w.Rect.drawWith(t,{width:this.width,height:this.height,fill:r,stroke:void 0,strokeWidth:0,evented:!1})}}var le=Object.getOwnPropertyDescriptor,he=(n,e,t,r)=>{for(var i=r>1?void 0:r?le(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(i)||i);return i},p=(n,e)=>(t,r)=>e(t,r,n);let O=class extends a.Disposable{constructor(e,t,r,i,s,o){super();l(this,"_shapes",[]);l(this,"_rangeCollection",new ae);l(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=r,this._sheetsCrosshairHighlightService=i,this._contextService=s,this._refSelectionsService=o,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const r=t.getRowCount(),i=t.getColumnCount(),s=[];for(const o of e){const{startRow:c,endRow:g,startColumn:S,endColumn:C}=o.range;g-c+1===r||C-S+1===i||s.push(o.range)}this._rangeCollection.setSelectedRanges(s);for(const o of s)this.addSelection(o,t)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(u.combineLatest([this._contextService.subscribeContextValue$(T.REF_SELECTIONS_ENABLED).pipe(u.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(u.tap(t=>this._color=t)),u.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(u.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),u.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(u.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,r,i,s,o,c])=>{if(this._clear(),!i)return;const g=t?c:o;this._rangeCollection.reset(),this._transformSelection(g,e.getActiveSheet()),this.render(this._rangeCollection.getRanges())}))}addSelection(e,t){if(e.rangeType===a.RANGE_TYPE.COLUMN||e.rangeType===a.RANGE_TYPE.ROW||e.rangeType===a.RANGE_TYPE.ALL)return;const r=t.getRowCount(),i=t.getColumnCount(),{startRow:s,endRow:o,startColumn:c,endColumn:g}=e,S={startRow:s,endRow:o,startColumn:0,endColumn:c-1},C={startRow:s,endRow:o,startColumn:g+1,endColumn:i},m={startRow:0,endRow:s-1,startColumn:c,endColumn:g},b={startRow:o+1,endRow:r,startColumn:c,endColumn:g};for(const f of[S,C,m,b])f.startRow<=f.endRow&&f.startColumn<=f.endColumn&&this._rangeCollection.addRange(f)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,r,i){const{startRow:s,endRow:o,startColumn:c,endColumn:g}=e,S=M.getCoordByCell(s,c,r,i),C=M.getCoordByCell(o,g,r,i),{startX:m,startY:b}=S,{endX:f,endY:Y}=C,q=f-m,B=Y-b,Z={left:m,top:b,color:new a.ColorKit(this._color).toRgb(),width:q,height:B,zIndex:oe,evented:!1},N=new ce(`crosshair-${t}`,Z);this._shapes.push(N),r.addObject(N)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:r}=this._context;this._clear();for(let i=0;i<e.length;i++){const s=e[i];this._addShapes(s,i,r,t)}r.makeDirty(!0)}async dispose(){super.dispose()}};O=he([p(1,a.Inject(M.SheetSkeletonManagerService)),p(2,a.Inject(T.SheetsSelectionsService)),p(3,a.Inject(d)),p(4,a.Inject(a.IContextService)),p(5,T.IRefSelectionsService)],O);var ge=Object.getOwnPropertyDescriptor,ue=(n,e,t,r)=>{for(var i=r>1?void 0:r?ge(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(i)||i);return i},y=(n,e)=>(t,r)=>e(t,r,n),R;exports.UniverSheetsCrosshairHighlightPlugin=(R=class extends a.Plugin{constructor(e=A,t,r,i){super(),this._config=e,this._injector=t,this._renderManagerService=r,this._configService=i;const{...s}=a.merge({},A,this._config);this._configService.setConfig(X,s)}onStarting(){[[d],[H]].forEach(e=>this._injector.add(e))}onReady(){[[O]].forEach(e=>this._injector.add(e)),this._injector.get(H),this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,[O])}},l(R,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),l(R,"type",a.UniverInstanceType.UNIVER_SHEET),R);exports.UniverSheetsCrosshairHighlightPlugin=ue([y(1,a.Inject(a.Injector)),y(2,w.IRenderManagerService),y(3,a.IConfigService)],exports.UniverSheetsCrosshairHighlightPlugin);exports.CROSSHAIR_HIGHLIGHT_COLORS=x;exports.DisableCrosshairHighlightOperation=G;exports.EnableCrosshairHighlightOperation=L;exports.SetCrosshairHighlightColorOperation=$;exports.SheetsCrosshairHighlightService=d;exports.ToggleCrosshairHighlightOperation=I;
package/lib/es/index.js CHANGED
@@ -2,70 +2,15 @@ var K = Object.defineProperty;
2
2
  var q = (n, e, t) => e in n ? K(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
3
  var c = (n, e, t) => q(n, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { Disposable as y, CommandType as H, UniverInstanceType as E, Inject as u, ICommandService as J, RANGE_TYPE as f, Rectangle as $, IContextService as Q, ColorKit as ee, Plugin as te, merge as re, Injector as ne, IConfigService as ie } from "@univerjs/core";
5
- import { Shape as se, Rect as oe, IRenderManagerService as ae } from "@univerjs/engine-render";
6
- import { useDependency as ce, useObservable as le, getMenuHiddenObservable as he, MenuItemType as ge, ContextMenuPosition as de, ContextMenuGroup as ue, ComponentManager as fe, IMenuManagerService as _e } from "@univerjs/ui";
7
- import { BehaviorSubject as x, combineLatest as ve, merge as T, startWith as Se, tap as pe, map as N } from "rxjs";
5
+ import { BehaviorSubject as x, combineLatest as se, merge as T, startWith as oe, tap as ae, map as N } from "rxjs";
6
+ import { Shape as ce, Rect as le, IRenderManagerService as he } from "@univerjs/engine-render";
7
+ import { useDependency as ge, useObservable as de, getMenuHiddenObservable as ue, MenuItemType as fe, ContextMenuPosition as _e, ContextMenuGroup as ve, ComponentManager as Se, IMenuManagerService as pe } from "@univerjs/ui";
8
8
  import { jsx as P } from "react/jsx-runtime";
9
9
  import { clsx as Ce, borderClassName as me } from "@univerjs/design";
10
10
  import { forwardRef as k, useRef as be, createElement as A, useCallback as Re } from "react";
11
11
  import { SheetsSelectionsService as He, IRefSelectionsService as Oe, REF_SELECTIONS_ENABLED as Ie } from "@univerjs/sheets";
12
12
  import { SheetSkeletonManagerService as Ee, getCoordByCell as V } from "@univerjs/sheets-ui";
13
- const ye = "sheets-crosshair-highlight.config", j = {};
14
- var l = function() {
15
- return l = Object.assign || function(n) {
16
- for (var e, t = 1, r = arguments.length; t < r; t++) {
17
- e = arguments[t];
18
- for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (n[i] = e[i]);
19
- }
20
- return n;
21
- }, l.apply(this, arguments);
22
- }, we = function(n, e) {
23
- var t = {};
24
- for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && e.indexOf(r) < 0 && (t[r] = n[r]);
25
- if (n != null && typeof Object.getOwnPropertySymbols == "function")
26
- for (var i = 0, r = Object.getOwnPropertySymbols(n); i < r.length; i++)
27
- e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[i]) && (t[r[i]] = n[r[i]]);
28
- return t;
29
- }, G = k(function(n, e) {
30
- var t = n.icon, r = n.id, i = n.className, s = n.extend, o = we(n, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(r, " ").concat(i || "").trim(), h = be("_".concat(xe()));
31
- return U(t, "".concat(r), { defIds: t.defIds, idSuffix: h.current }, l({ ref: e, className: a }, o), s);
32
- });
33
- function U(n, e, t, r, i) {
34
- return A(n.tag, l(l({ key: e }, Me(n, t, i)), r), ($e(n, t).children || []).map(function(s, o) {
35
- return U(s, "".concat(e, "-").concat(n.tag, "-").concat(o), t, void 0, i);
36
- }));
37
- }
38
- function Me(n, e, t) {
39
- var r = l({}, n.attrs);
40
- t != null && t.colorChannel1 && r.fill === "colorChannel1" && (r.fill = t.colorChannel1), n.tag === "mask" && r.id && (r.id = r.id + e.idSuffix), Object.entries(r).forEach(function(s) {
41
- var o = s[0], a = s[1];
42
- o === "mask" && typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
43
- });
44
- var i = e.defIds;
45
- return !i || i.length === 0 || (n.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(s) {
46
- var o = s[0], a = s[1];
47
- typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
48
- })), r;
49
- }
50
- function $e(n, e) {
51
- var t, r = e.defIds;
52
- return !r || r.length === 0 ? n : n.tag === "defs" && (!((t = n.children) === null || t === void 0) && t.length) ? l(l({}, n), { children: n.children.map(function(i) {
53
- return typeof i.attrs.id == "string" && r && r.includes(i.attrs.id) ? l(l({}, i), { attrs: l(l({}, i.attrs), { id: i.attrs.id + e.idSuffix }) }) : i;
54
- }) }) : n;
55
- }
56
- function xe() {
57
- return Math.random().toString(36).substring(2, 8);
58
- }
59
- G.displayName = "UniverIcon";
60
- var Te = { tag: "svg", attrs: { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, D = k(function(n, e) {
61
- return A(G, Object.assign({}, n, {
62
- id: "cross-highlighting-icon",
63
- ref: e,
64
- icon: Te
65
- }));
66
- });
67
- D.displayName = "CrossHighlightingIcon";
68
- const B = [
13
+ const G = [
69
14
  "rgba(158, 109, 227, 0.3)",
70
15
  "rgba(254, 75, 75, 0.3)",
71
16
  "rgba(255, 140, 81, 0.3)",
@@ -88,7 +33,7 @@ class g extends y {
88
33
  super(...arguments);
89
34
  c(this, "_enabled$", new x(!1));
90
35
  c(this, "enabled$", this._enabled$.asObservable());
91
- c(this, "_color$", new x(B[0]));
36
+ c(this, "_color$", new x(G[0]));
92
37
  c(this, "color$", this._color$.asObservable());
93
38
  }
94
39
  get enabled() {
@@ -114,33 +59,87 @@ const w = {
114
59
  const e = n.get(g), t = e.enabled;
115
60
  return e.setEnabled(!t), !0;
116
61
  }
117
- }, Z = {
62
+ }, U = {
118
63
  id: "sheet.operation.set-crosshair-highlight-color",
119
64
  type: H.OPERATION,
120
65
  handler(n, { value: e }) {
121
66
  const t = n.get(g);
122
67
  return t.enabled || t.setEnabled(!0), t.setColor(e), !0;
123
68
  }
124
- }, Ne = {
69
+ }, ye = {
125
70
  id: "sheet.operation.enable-crosshair-highlight",
126
71
  type: H.OPERATION,
127
72
  handler(n) {
128
73
  const e = n.get(g);
129
74
  return e.enabled ? !1 : (e.setEnabled(!0), !0);
130
75
  }
131
- }, Pe = {
76
+ }, we = {
132
77
  id: "sheet.operation.disable-crosshair-highlight",
133
78
  type: H.OPERATION,
134
79
  handler(n) {
135
80
  const e = n.get(g);
136
81
  return e.enabled ? (e.setEnabled(!1), !0) : !1;
137
82
  }
138
- };
83
+ }, Me = "sheets-crosshair-highlight.config", j = {};
84
+ var l = function() {
85
+ return l = Object.assign || function(n) {
86
+ for (var e, t = 1, r = arguments.length; t < r; t++) {
87
+ e = arguments[t];
88
+ for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (n[i] = e[i]);
89
+ }
90
+ return n;
91
+ }, l.apply(this, arguments);
92
+ }, $e = function(n, e) {
93
+ var t = {};
94
+ for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && e.indexOf(r) < 0 && (t[r] = n[r]);
95
+ if (n != null && typeof Object.getOwnPropertySymbols == "function")
96
+ for (var i = 0, r = Object.getOwnPropertySymbols(n); i < r.length; i++)
97
+ e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[i]) && (t[r[i]] = n[r[i]]);
98
+ return t;
99
+ }, D = k(function(n, e) {
100
+ var t = n.icon, r = n.id, i = n.className, s = n.extend, o = $e(n, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(r, " ").concat(i || "").trim(), h = be("_".concat(Ne()));
101
+ return B(t, "".concat(r), { defIds: t.defIds, idSuffix: h.current }, l({ ref: e, className: a }, o), s);
102
+ });
103
+ function B(n, e, t, r, i) {
104
+ return A(n.tag, l(l({ key: e }, xe(n, t, i)), r), (Te(n, t).children || []).map(function(s, o) {
105
+ return B(s, "".concat(e, "-").concat(n.tag, "-").concat(o), t, void 0, i);
106
+ }));
107
+ }
108
+ function xe(n, e, t) {
109
+ var r = l({}, n.attrs);
110
+ t != null && t.colorChannel1 && r.fill === "colorChannel1" && (r.fill = t.colorChannel1), n.tag === "mask" && r.id && (r.id = r.id + e.idSuffix), Object.entries(r).forEach(function(s) {
111
+ var o = s[0], a = s[1];
112
+ o === "mask" && typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
113
+ });
114
+ var i = e.defIds;
115
+ return !i || i.length === 0 || (n.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(s) {
116
+ var o = s[0], a = s[1];
117
+ typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
118
+ })), r;
119
+ }
120
+ function Te(n, e) {
121
+ var t, r = e.defIds;
122
+ return !r || r.length === 0 ? n : n.tag === "defs" && (!((t = n.children) === null || t === void 0) && t.length) ? l(l({}, n), { children: n.children.map(function(i) {
123
+ return typeof i.attrs.id == "string" && r && r.includes(i.attrs.id) ? l(l({}, i), { attrs: l(l({}, i.attrs), { id: i.attrs.id + e.idSuffix }) }) : i;
124
+ }) }) : n;
125
+ }
126
+ function Ne() {
127
+ return Math.random().toString(36).substring(2, 8);
128
+ }
129
+ D.displayName = "UniverIcon";
130
+ var Pe = { tag: "svg", attrs: { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Z = k(function(n, e) {
131
+ return A(D, Object.assign({}, n, {
132
+ id: "cross-highlighting-icon",
133
+ ref: e,
134
+ icon: Pe
135
+ }));
136
+ });
137
+ Z.displayName = "CrossHighlightingIcon";
139
138
  function Ve(n) {
140
- const { onChange: e } = n, t = ce(g), r = le(t.color$), i = Re((s) => {
139
+ const { onChange: e } = n, t = ge(g), r = de(t.color$), i = Re((s) => {
141
140
  e == null || e(s);
142
141
  }, [e]);
143
- return /* @__PURE__ */ P("div", { className: "univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3", children: B.map((s) => /* @__PURE__ */ P(
142
+ return /* @__PURE__ */ P("div", { className: "univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3", children: G.map((s) => /* @__PURE__ */ P(
144
143
  "div",
145
144
  {
146
145
  className: Ce("univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1 univer-transition-shadow hover:univer-ring-primary-600/40 hover:univer-ring-[1.5px]", me, {
@@ -158,7 +157,7 @@ function je(n) {
158
157
  return {
159
158
  id: w.id,
160
159
  tooltip: "crosshair.button.tooltip",
161
- type: ge.BUTTON_SELECTOR,
160
+ type: fe.BUTTON_SELECTOR,
162
161
  icon: "CrossHighlightingIcon",
163
162
  selections: [
164
163
  {
@@ -169,14 +168,14 @@ function je(n) {
169
168
  }
170
169
  }
171
170
  ],
172
- selectionsCommandId: Z.id,
171
+ selectionsCommandId: U.id,
173
172
  activated$: e.enabled$,
174
- hidden$: he(n, E.UNIVER_SHEET)
173
+ hidden$: ue(n, E.UNIVER_SHEET)
175
174
  };
176
175
  }
177
176
  const Le = {
178
- [de.FOOTER_MENU]: {
179
- [ue.OTHERS]: {
177
+ [_e.FOOTER_MENU]: {
178
+ [ve.OTHERS]: {
180
179
  [w.id]: {
181
180
  order: 0,
182
181
  menuItemFactory: je
@@ -196,21 +195,21 @@ let b = class extends y {
196
195
  _initCommands() {
197
196
  [
198
197
  w,
199
- Z,
200
- Ne,
201
- Pe
198
+ U,
199
+ ye,
200
+ we
202
201
  ].forEach((n) => this._cmdSrv.registerCommand(n));
203
202
  }
204
203
  _initMenus() {
205
204
  this._menuManagerService.mergeMenu(Le);
206
205
  }
207
206
  _initComponents() {
208
- this._componentMgr.register(W, Ve), this._componentMgr.register("CrossHighlightingIcon", D);
207
+ this._componentMgr.register(W, Ve), this._componentMgr.register("CrossHighlightingIcon", Z);
209
208
  }
210
209
  };
211
210
  b = Ae([
212
- O(0, u(fe)),
213
- O(1, _e),
211
+ O(0, u(Se)),
212
+ O(1, pe),
214
213
  O(2, J)
215
214
  ], b);
216
215
  const Ge = 1;
@@ -255,7 +254,7 @@ class Ue {
255
254
  this._ranges = [], this._selectedRanges = [];
256
255
  }
257
256
  }
258
- class De extends se {
257
+ class De extends ce {
259
258
  constructor(t, r) {
260
259
  super(t, r);
261
260
  // protected _showHighLight = false;
@@ -271,7 +270,7 @@ class De extends se {
271
270
  _draw(t) {
272
271
  var i, s;
273
272
  const r = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(s = (i = this._color) == null ? void 0 : i.a) != null ? s : 0.5})`;
274
- oe.drawWith(t, {
273
+ le.drawWith(t, {
275
274
  width: this.width,
276
275
  height: this.height,
277
276
  fill: r,
@@ -308,11 +307,11 @@ let R = class extends y {
308
307
  }
309
308
  _initRenderListener() {
310
309
  const e = this._context.unit;
311
- this.disposeWithMe(ve([
312
- this._contextService.subscribeContextValue$(Ie).pipe(Se(!1)),
310
+ this.disposeWithMe(se([
311
+ this._contextService.subscribeContextValue$(Ie).pipe(oe(!1)),
313
312
  this._sheetSkeletonManagerService.currentSkeleton$,
314
313
  this._sheetsCrosshairHighlightService.enabled$,
315
- this._sheetsCrosshairHighlightService.color$.pipe(pe((t) => this._color = t)),
314
+ this._sheetsCrosshairHighlightService.color$.pipe(ae((t) => this._color = t)),
316
315
  T(
317
316
  this._sheetsSelectionsService.selectionMoveStart$,
318
317
  this._sheetsSelectionsService.selectionMoving$,
@@ -413,7 +412,7 @@ let L = (m = class extends te {
413
412
  j,
414
413
  this._config
415
414
  );
416
- this._configService.setConfig(ye, i);
415
+ this._configService.setConfig(Me, i);
417
416
  }
418
417
  onStarting() {
419
418
  [
@@ -429,14 +428,14 @@ let L = (m = class extends te {
429
428
  }, c(m, "pluginName", "SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"), c(m, "type", E.UNIVER_SHEET), m);
430
429
  L = Ye([
431
430
  I(1, u(ne)),
432
- I(2, ae),
431
+ I(2, he),
433
432
  I(3, ie)
434
433
  ], L);
435
434
  export {
436
- B as CROSSHAIR_HIGHLIGHT_COLORS,
437
- Pe as DisableCrosshairHighlightOperation,
438
- Ne as EnableCrosshairHighlightOperation,
439
- Z as SetCrosshairHighlightColorOperation,
435
+ G as CROSSHAIR_HIGHLIGHT_COLORS,
436
+ we as DisableCrosshairHighlightOperation,
437
+ ye as EnableCrosshairHighlightOperation,
438
+ U as SetCrosshairHighlightColorOperation,
440
439
  g as SheetsCrosshairHighlightService,
441
440
  w as ToggleCrosshairHighlightOperation,
442
441
  L as UniverSheetsCrosshairHighlightPlugin
package/lib/index.js CHANGED
@@ -2,70 +2,15 @@ var K = Object.defineProperty;
2
2
  var q = (n, e, t) => e in n ? K(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
3
  var c = (n, e, t) => q(n, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { Disposable as y, CommandType as H, UniverInstanceType as E, Inject as u, ICommandService as J, RANGE_TYPE as f, Rectangle as $, IContextService as Q, ColorKit as ee, Plugin as te, merge as re, Injector as ne, IConfigService as ie } from "@univerjs/core";
5
- import { Shape as se, Rect as oe, IRenderManagerService as ae } from "@univerjs/engine-render";
6
- import { useDependency as ce, useObservable as le, getMenuHiddenObservable as he, MenuItemType as ge, ContextMenuPosition as de, ContextMenuGroup as ue, ComponentManager as fe, IMenuManagerService as _e } from "@univerjs/ui";
7
- import { BehaviorSubject as x, combineLatest as ve, merge as T, startWith as Se, tap as pe, map as N } from "rxjs";
5
+ import { BehaviorSubject as x, combineLatest as se, merge as T, startWith as oe, tap as ae, map as N } from "rxjs";
6
+ import { Shape as ce, Rect as le, IRenderManagerService as he } from "@univerjs/engine-render";
7
+ import { useDependency as ge, useObservable as de, getMenuHiddenObservable as ue, MenuItemType as fe, ContextMenuPosition as _e, ContextMenuGroup as ve, ComponentManager as Se, IMenuManagerService as pe } from "@univerjs/ui";
8
8
  import { jsx as P } from "react/jsx-runtime";
9
9
  import { clsx as Ce, borderClassName as me } from "@univerjs/design";
10
10
  import { forwardRef as k, useRef as be, createElement as A, useCallback as Re } from "react";
11
11
  import { SheetsSelectionsService as He, IRefSelectionsService as Oe, REF_SELECTIONS_ENABLED as Ie } from "@univerjs/sheets";
12
12
  import { SheetSkeletonManagerService as Ee, getCoordByCell as V } from "@univerjs/sheets-ui";
13
- const ye = "sheets-crosshair-highlight.config", j = {};
14
- var l = function() {
15
- return l = Object.assign || function(n) {
16
- for (var e, t = 1, r = arguments.length; t < r; t++) {
17
- e = arguments[t];
18
- for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (n[i] = e[i]);
19
- }
20
- return n;
21
- }, l.apply(this, arguments);
22
- }, we = function(n, e) {
23
- var t = {};
24
- for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && e.indexOf(r) < 0 && (t[r] = n[r]);
25
- if (n != null && typeof Object.getOwnPropertySymbols == "function")
26
- for (var i = 0, r = Object.getOwnPropertySymbols(n); i < r.length; i++)
27
- e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[i]) && (t[r[i]] = n[r[i]]);
28
- return t;
29
- }, G = k(function(n, e) {
30
- var t = n.icon, r = n.id, i = n.className, s = n.extend, o = we(n, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(r, " ").concat(i || "").trim(), h = be("_".concat(xe()));
31
- return U(t, "".concat(r), { defIds: t.defIds, idSuffix: h.current }, l({ ref: e, className: a }, o), s);
32
- });
33
- function U(n, e, t, r, i) {
34
- return A(n.tag, l(l({ key: e }, Me(n, t, i)), r), ($e(n, t).children || []).map(function(s, o) {
35
- return U(s, "".concat(e, "-").concat(n.tag, "-").concat(o), t, void 0, i);
36
- }));
37
- }
38
- function Me(n, e, t) {
39
- var r = l({}, n.attrs);
40
- t != null && t.colorChannel1 && r.fill === "colorChannel1" && (r.fill = t.colorChannel1), n.tag === "mask" && r.id && (r.id = r.id + e.idSuffix), Object.entries(r).forEach(function(s) {
41
- var o = s[0], a = s[1];
42
- o === "mask" && typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
43
- });
44
- var i = e.defIds;
45
- return !i || i.length === 0 || (n.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(s) {
46
- var o = s[0], a = s[1];
47
- typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
48
- })), r;
49
- }
50
- function $e(n, e) {
51
- var t, r = e.defIds;
52
- return !r || r.length === 0 ? n : n.tag === "defs" && (!((t = n.children) === null || t === void 0) && t.length) ? l(l({}, n), { children: n.children.map(function(i) {
53
- return typeof i.attrs.id == "string" && r && r.includes(i.attrs.id) ? l(l({}, i), { attrs: l(l({}, i.attrs), { id: i.attrs.id + e.idSuffix }) }) : i;
54
- }) }) : n;
55
- }
56
- function xe() {
57
- return Math.random().toString(36).substring(2, 8);
58
- }
59
- G.displayName = "UniverIcon";
60
- var Te = { tag: "svg", attrs: { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, D = k(function(n, e) {
61
- return A(G, Object.assign({}, n, {
62
- id: "cross-highlighting-icon",
63
- ref: e,
64
- icon: Te
65
- }));
66
- });
67
- D.displayName = "CrossHighlightingIcon";
68
- const B = [
13
+ const G = [
69
14
  "rgba(158, 109, 227, 0.3)",
70
15
  "rgba(254, 75, 75, 0.3)",
71
16
  "rgba(255, 140, 81, 0.3)",
@@ -88,7 +33,7 @@ class g extends y {
88
33
  super(...arguments);
89
34
  c(this, "_enabled$", new x(!1));
90
35
  c(this, "enabled$", this._enabled$.asObservable());
91
- c(this, "_color$", new x(B[0]));
36
+ c(this, "_color$", new x(G[0]));
92
37
  c(this, "color$", this._color$.asObservable());
93
38
  }
94
39
  get enabled() {
@@ -114,33 +59,87 @@ const w = {
114
59
  const e = n.get(g), t = e.enabled;
115
60
  return e.setEnabled(!t), !0;
116
61
  }
117
- }, Z = {
62
+ }, U = {
118
63
  id: "sheet.operation.set-crosshair-highlight-color",
119
64
  type: H.OPERATION,
120
65
  handler(n, { value: e }) {
121
66
  const t = n.get(g);
122
67
  return t.enabled || t.setEnabled(!0), t.setColor(e), !0;
123
68
  }
124
- }, Ne = {
69
+ }, ye = {
125
70
  id: "sheet.operation.enable-crosshair-highlight",
126
71
  type: H.OPERATION,
127
72
  handler(n) {
128
73
  const e = n.get(g);
129
74
  return e.enabled ? !1 : (e.setEnabled(!0), !0);
130
75
  }
131
- }, Pe = {
76
+ }, we = {
132
77
  id: "sheet.operation.disable-crosshair-highlight",
133
78
  type: H.OPERATION,
134
79
  handler(n) {
135
80
  const e = n.get(g);
136
81
  return e.enabled ? (e.setEnabled(!1), !0) : !1;
137
82
  }
138
- };
83
+ }, Me = "sheets-crosshair-highlight.config", j = {};
84
+ var l = function() {
85
+ return l = Object.assign || function(n) {
86
+ for (var e, t = 1, r = arguments.length; t < r; t++) {
87
+ e = arguments[t];
88
+ for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (n[i] = e[i]);
89
+ }
90
+ return n;
91
+ }, l.apply(this, arguments);
92
+ }, $e = function(n, e) {
93
+ var t = {};
94
+ for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && e.indexOf(r) < 0 && (t[r] = n[r]);
95
+ if (n != null && typeof Object.getOwnPropertySymbols == "function")
96
+ for (var i = 0, r = Object.getOwnPropertySymbols(n); i < r.length; i++)
97
+ e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[i]) && (t[r[i]] = n[r[i]]);
98
+ return t;
99
+ }, D = k(function(n, e) {
100
+ var t = n.icon, r = n.id, i = n.className, s = n.extend, o = $e(n, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(r, " ").concat(i || "").trim(), h = be("_".concat(Ne()));
101
+ return B(t, "".concat(r), { defIds: t.defIds, idSuffix: h.current }, l({ ref: e, className: a }, o), s);
102
+ });
103
+ function B(n, e, t, r, i) {
104
+ return A(n.tag, l(l({ key: e }, xe(n, t, i)), r), (Te(n, t).children || []).map(function(s, o) {
105
+ return B(s, "".concat(e, "-").concat(n.tag, "-").concat(o), t, void 0, i);
106
+ }));
107
+ }
108
+ function xe(n, e, t) {
109
+ var r = l({}, n.attrs);
110
+ t != null && t.colorChannel1 && r.fill === "colorChannel1" && (r.fill = t.colorChannel1), n.tag === "mask" && r.id && (r.id = r.id + e.idSuffix), Object.entries(r).forEach(function(s) {
111
+ var o = s[0], a = s[1];
112
+ o === "mask" && typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
113
+ });
114
+ var i = e.defIds;
115
+ return !i || i.length === 0 || (n.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(s) {
116
+ var o = s[0], a = s[1];
117
+ typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
118
+ })), r;
119
+ }
120
+ function Te(n, e) {
121
+ var t, r = e.defIds;
122
+ return !r || r.length === 0 ? n : n.tag === "defs" && (!((t = n.children) === null || t === void 0) && t.length) ? l(l({}, n), { children: n.children.map(function(i) {
123
+ return typeof i.attrs.id == "string" && r && r.includes(i.attrs.id) ? l(l({}, i), { attrs: l(l({}, i.attrs), { id: i.attrs.id + e.idSuffix }) }) : i;
124
+ }) }) : n;
125
+ }
126
+ function Ne() {
127
+ return Math.random().toString(36).substring(2, 8);
128
+ }
129
+ D.displayName = "UniverIcon";
130
+ var Pe = { tag: "svg", attrs: { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Z = k(function(n, e) {
131
+ return A(D, Object.assign({}, n, {
132
+ id: "cross-highlighting-icon",
133
+ ref: e,
134
+ icon: Pe
135
+ }));
136
+ });
137
+ Z.displayName = "CrossHighlightingIcon";
139
138
  function Ve(n) {
140
- const { onChange: e } = n, t = ce(g), r = le(t.color$), i = Re((s) => {
139
+ const { onChange: e } = n, t = ge(g), r = de(t.color$), i = Re((s) => {
141
140
  e == null || e(s);
142
141
  }, [e]);
143
- return /* @__PURE__ */ P("div", { className: "univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3", children: B.map((s) => /* @__PURE__ */ P(
142
+ return /* @__PURE__ */ P("div", { className: "univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3", children: G.map((s) => /* @__PURE__ */ P(
144
143
  "div",
145
144
  {
146
145
  className: Ce("univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1 univer-transition-shadow hover:univer-ring-primary-600/40 hover:univer-ring-[1.5px]", me, {
@@ -158,7 +157,7 @@ function je(n) {
158
157
  return {
159
158
  id: w.id,
160
159
  tooltip: "crosshair.button.tooltip",
161
- type: ge.BUTTON_SELECTOR,
160
+ type: fe.BUTTON_SELECTOR,
162
161
  icon: "CrossHighlightingIcon",
163
162
  selections: [
164
163
  {
@@ -169,14 +168,14 @@ function je(n) {
169
168
  }
170
169
  }
171
170
  ],
172
- selectionsCommandId: Z.id,
171
+ selectionsCommandId: U.id,
173
172
  activated$: e.enabled$,
174
- hidden$: he(n, E.UNIVER_SHEET)
173
+ hidden$: ue(n, E.UNIVER_SHEET)
175
174
  };
176
175
  }
177
176
  const Le = {
178
- [de.FOOTER_MENU]: {
179
- [ue.OTHERS]: {
177
+ [_e.FOOTER_MENU]: {
178
+ [ve.OTHERS]: {
180
179
  [w.id]: {
181
180
  order: 0,
182
181
  menuItemFactory: je
@@ -196,21 +195,21 @@ let b = class extends y {
196
195
  _initCommands() {
197
196
  [
198
197
  w,
199
- Z,
200
- Ne,
201
- Pe
198
+ U,
199
+ ye,
200
+ we
202
201
  ].forEach((n) => this._cmdSrv.registerCommand(n));
203
202
  }
204
203
  _initMenus() {
205
204
  this._menuManagerService.mergeMenu(Le);
206
205
  }
207
206
  _initComponents() {
208
- this._componentMgr.register(W, Ve), this._componentMgr.register("CrossHighlightingIcon", D);
207
+ this._componentMgr.register(W, Ve), this._componentMgr.register("CrossHighlightingIcon", Z);
209
208
  }
210
209
  };
211
210
  b = Ae([
212
- O(0, u(fe)),
213
- O(1, _e),
211
+ O(0, u(Se)),
212
+ O(1, pe),
214
213
  O(2, J)
215
214
  ], b);
216
215
  const Ge = 1;
@@ -255,7 +254,7 @@ class Ue {
255
254
  this._ranges = [], this._selectedRanges = [];
256
255
  }
257
256
  }
258
- class De extends se {
257
+ class De extends ce {
259
258
  constructor(t, r) {
260
259
  super(t, r);
261
260
  // protected _showHighLight = false;
@@ -271,7 +270,7 @@ class De extends se {
271
270
  _draw(t) {
272
271
  var i, s;
273
272
  const r = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(s = (i = this._color) == null ? void 0 : i.a) != null ? s : 0.5})`;
274
- oe.drawWith(t, {
273
+ le.drawWith(t, {
275
274
  width: this.width,
276
275
  height: this.height,
277
276
  fill: r,
@@ -308,11 +307,11 @@ let R = class extends y {
308
307
  }
309
308
  _initRenderListener() {
310
309
  const e = this._context.unit;
311
- this.disposeWithMe(ve([
312
- this._contextService.subscribeContextValue$(Ie).pipe(Se(!1)),
310
+ this.disposeWithMe(se([
311
+ this._contextService.subscribeContextValue$(Ie).pipe(oe(!1)),
313
312
  this._sheetSkeletonManagerService.currentSkeleton$,
314
313
  this._sheetsCrosshairHighlightService.enabled$,
315
- this._sheetsCrosshairHighlightService.color$.pipe(pe((t) => this._color = t)),
314
+ this._sheetsCrosshairHighlightService.color$.pipe(ae((t) => this._color = t)),
316
315
  T(
317
316
  this._sheetsSelectionsService.selectionMoveStart$,
318
317
  this._sheetsSelectionsService.selectionMoving$,
@@ -413,7 +412,7 @@ let L = (m = class extends te {
413
412
  j,
414
413
  this._config
415
414
  );
416
- this._configService.setConfig(ye, i);
415
+ this._configService.setConfig(Me, i);
417
416
  }
418
417
  onStarting() {
419
418
  [
@@ -429,14 +428,14 @@ let L = (m = class extends te {
429
428
  }, c(m, "pluginName", "SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"), c(m, "type", E.UNIVER_SHEET), m);
430
429
  L = Ye([
431
430
  I(1, u(ne)),
432
- I(2, ae),
431
+ I(2, he),
433
432
  I(3, ie)
434
433
  ], L);
435
434
  export {
436
- B as CROSSHAIR_HIGHLIGHT_COLORS,
437
- Pe as DisableCrosshairHighlightOperation,
438
- Ne as EnableCrosshairHighlightOperation,
439
- Z as SetCrosshairHighlightColorOperation,
435
+ G as CROSSHAIR_HIGHLIGHT_COLORS,
436
+ we as DisableCrosshairHighlightOperation,
437
+ ye as EnableCrosshairHighlightOperation,
438
+ U as SetCrosshairHighlightColorOperation,
440
439
  g as SheetsCrosshairHighlightService,
441
440
  w as ToggleCrosshairHighlightOperation,
442
441
  L as UniverSheetsCrosshairHighlightPlugin
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import './global.css';
17
+ export { DisableCrosshairHighlightOperation, EnableCrosshairHighlightOperation, type ISetCrosshairHighlightColorOperationParams, SetCrosshairHighlightColorOperation, ToggleCrosshairHighlightOperation, } from './commands/operations/operation';
18
+ export type { IUniverSheetsCrosshairHighlightConfig } from './controllers/config.schema';
17
19
  export { UniverSheetsCrosshairHighlightPlugin } from './plugin';
18
20
  export { CROSSHAIR_HIGHLIGHT_COLORS, SheetsCrosshairHighlightService } from './services/crosshair.service';
19
- export { DisableCrosshairHighlightOperation, EnableCrosshairHighlightOperation, type ISetCrosshairHighlightColorOperationParams, SetCrosshairHighlightColorOperation, ToggleCrosshairHighlightOperation, } from './commands/operations/operation';
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/sheets"),require("@univerjs/sheets-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/ui","rxjs","react/jsx-runtime","@univerjs/design","react","@univerjs/sheets","@univerjs/sheets-ui"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverSheetsCrosshairHighlight={},c.UniverCore,c.UniverEngineRender,c.UniverUi,c.rxjs,c.React,c.UniverDesign,c.React,c.UniverSheets,c.UniverSheetsUi))})(this,function(c,o,v,_,d,P,x,C,w,T){"use strict";var ue=Object.defineProperty;var de=(c,o,v)=>o in c?ue(c,o,{enumerable:!0,configurable:!0,writable:!0,value:v}):c[o]=v;var h=(c,o,v)=>de(c,typeof o!="symbol"?o+"":o,v);var I;const q="sheets-crosshair-highlight.config",A={};var g=function(){return g=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},g.apply(this,arguments)},B=function(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(t[n[r]]=i[n[r]]);return t},L=C.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,s=i.extend,a=B(i,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),u=C.useRef("_".concat(F()));return U(t,"".concat(n),{defIds:t.defIds,idSuffix:u.current},g({ref:e,className:l},a),s)});function U(i,e,t,n,r){return C.createElement(i.tag,g(g({key:e},Z(i,t,r)),n),(W(i,t).children||[]).map(function(s,a){return U(s,"".concat(e,"-").concat(i.tag,"-").concat(a),t,void 0,r)}))}function Z(i,e,t){var n=g({},i.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1),i.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],l=s[1];a==="mask"&&typeof l=="string"&&(n[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var r=e.defIds;return!r||r.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],l=s[1];typeof l=="string"&&(n[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function W(i,e){var t,n=e.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?g(g({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.includes(r.attrs.id)?g(g({},r),{attrs:g(g({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function F(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var X={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z",fillRule:"evenodd",clipRule:"evenodd"}}]},G=C.forwardRef(function(i,e){return C.createElement(L,Object.assign({},i,{id:"cross-highlighting-icon",ref:e,icon:X}))});G.displayName="CrossHighlightingIcon";const M=["rgba(158, 109, 227, 0.3)","rgba(254, 75, 75, 0.3)","rgba(255, 140, 81, 0.3)","rgba(164, 220, 22, 0.3)","rgba(45, 174, 255, 0.3)","rgba(58, 96, 247, 0.3)","rgba(242, 72, 166, 0.3)","rgba(153, 153, 153, 0.3)","rgba(158, 109, 227, 0.15)","rgba(254, 75, 75, 0.15)","rgba(255, 140, 81, 0.15)","rgba(164, 220, 22, 0.15)","rgba(45, 174, 255, 0.15)","rgba(58, 96, 247, 0.15)","rgba(242, 72, 166, 0.15)","rgba(153, 153, 153, 0.15)"];class f extends o.Disposable{constructor(){super(...arguments);h(this,"_enabled$",new d.BehaviorSubject(!1));h(this,"enabled$",this._enabled$.asObservable());h(this,"_color$",new d.BehaviorSubject(M[0]));h(this,"color$",this._color$.asObservable())}get enabled(){return this._enabled$.getValue()}get color(){return this._color$.getValue()}dispose(){this._enabled$.complete()}setEnabled(t){this._enabled$.next(t)}setColor(t){this._color$.next(t)}}const b={id:"sheet.operation.toggle-crosshair-highlight",type:o.CommandType.OPERATION,handler(i){const e=i.get(f),t=e.enabled;return e.setEnabled(!t),!0}},$={id:"sheet.operation.set-crosshair-highlight-color",type:o.CommandType.OPERATION,handler(i,{value:e}){const t=i.get(f);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},V={id:"sheet.operation.enable-crosshair-highlight",type:o.CommandType.OPERATION,handler(i){const e=i.get(f);return e.enabled?!1:(e.setEnabled(!0),!0)}},k={id:"sheet.operation.disable-crosshair-highlight",type:o.CommandType.OPERATION,handler(i){const e=i.get(f);return e.enabled?(e.setEnabled(!1),!0):!1}};function z(i){const{onChange:e}=i,t=_.useDependency(f),n=_.useObservable(t.color$),r=C.useCallback(s=>{e==null||e(s)},[e]);return P.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3",children:M.map(s=>P.jsx("div",{className:x.clsx("univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1 univer-transition-shadow hover:univer-ring-primary-600/40 hover:univer-ring-[1.5px]",x.borderClassName,{"univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600":s===n}),style:{backgroundColor:s},onClick:()=>r(s)},s))})}const D="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function K(i){const e=i.get(f);return{id:b.id,tooltip:"crosshair.button.tooltip",type:_.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingIcon",selections:[{label:{name:D,hoverable:!1,selectable:!1}}],selectionsCommandId:$.id,activated$:e.enabled$,hidden$:_.getMenuHiddenObservable(i,o.UniverInstanceType.UNIVER_SHEET)}}const J={[_.ContextMenuPosition.FOOTER_MENU]:{[_.ContextMenuGroup.OTHERS]:{[b.id]:{order:0,menuItemFactory:K}}}};var Q=Object.getOwnPropertyDescriptor,ee=(i,e,t,n)=>{for(var r=n>1?void 0:n?Q(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},j=(i,e)=>(t,n)=>e(t,n,i);let H=class extends o.Disposable{constructor(i,e,t){super(),this._componentMgr=i,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[b,$,V,k].forEach(i=>this._cmdSrv.registerCommand(i))}_initMenus(){this._menuManagerService.mergeMenu(J)}_initComponents(){this._componentMgr.register(D,z),this._componentMgr.register("CrossHighlightingIcon",G)}};H=ee([j(0,o.Inject(_.ComponentManager)),j(1,_.IMenuManagerService),j(2,o.ICommandService)],H);const te=1;class ne{constructor(){h(this,"_selectedRanges",[]);h(this,"_ranges",[])}addRange(e){if(e.rangeType===o.RANGE_TYPE.COLUMN||e.rangeType===o.RANGE_TYPE.ROW||e.rangeType===o.RANGE_TYPE.ALL)return;const t=this._getIntersects(e),n=this._getSplitRanges(e,t);n.length>0&&this._ranges.push(...n)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,t){let n=[e];for(const r of t.concat(this._selectedRanges)){const s=[];for(const a of n){const l=o.Rectangle.subtract(a,r);l&&l.length>0&&s.push(...l)}n=s}return n.filter(r=>r.startRow<=r.endRow&&r.startColumn<=r.endColumn)}_getIntersects(e){const t=[];for(const n of this._ranges){const r=o.Rectangle.getIntersects(n,e);r&&t.push(r)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class re extends v.Shape{constructor(t,n){super(t,n);h(this,"_color");n&&this.setShapeProps(n)}setShapeProps(t){typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){var r,s;const n=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(s=(r=this._color)==null?void 0:r.a)!=null?s:.5})`;v.Rect.drawWith(t,{width:this.width,height:this.height,fill:n,stroke:void 0,strokeWidth:0,evented:!1})}}var ie=Object.getOwnPropertyDescriptor,se=(i,e,t,n)=>{for(var r=n>1?void 0:n?ie(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},p=(i,e)=>(t,n)=>e(t,n,i);let O=class extends o.Disposable{constructor(e,t,n,r,s,a){super();h(this,"_shapes",[]);h(this,"_rangeCollection",new ne);h(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=n,this._sheetsCrosshairHighlightService=r,this._contextService=s,this._refSelectionsService=a,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const n=t.getRowCount(),r=t.getColumnCount(),s=[];for(const a of e){const{startRow:l,endRow:u,startColumn:m,endColumn:R}=a.range;u-l+1===n||R-m+1===r||s.push(a.range)}this._rangeCollection.setSelectedRanges(s);for(const a of s)this.addSelection(a,t)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(d.combineLatest([this._contextService.subscribeContextValue$(w.REF_SELECTIONS_ENABLED).pipe(d.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(d.tap(t=>this._color=t)),d.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(d.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),d.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(d.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,n,r,s,a,l])=>{if(this._clear(),!r)return;const u=t?l:a;this._rangeCollection.reset(),this._transformSelection(u,e.getActiveSheet()),this.render(this._rangeCollection.getRanges())}))}addSelection(e,t){if(e.rangeType===o.RANGE_TYPE.COLUMN||e.rangeType===o.RANGE_TYPE.ROW||e.rangeType===o.RANGE_TYPE.ALL)return;const n=t.getRowCount(),r=t.getColumnCount(),{startRow:s,endRow:a,startColumn:l,endColumn:u}=e,m={startRow:s,endRow:a,startColumn:0,endColumn:l-1},R={startRow:s,endRow:a,startColumn:u+1,endColumn:r},E={startRow:0,endRow:s-1,startColumn:l,endColumn:u},y={startRow:a+1,endRow:n,startColumn:l,endColumn:u};for(const S of[m,R,E,y])S.startRow<=S.endRow&&S.startColumn<=S.endColumn&&this._rangeCollection.addRange(S)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,n,r){const{startRow:s,endRow:a,startColumn:l,endColumn:u}=e,m=T.getCoordByCell(s,l,n,r),R=T.getCoordByCell(a,u,n,r),{startX:E,startY:y}=m,{endX:S,endY:ce}=R,le=S-E,he=ce-y,ge={left:E,top:y,color:new o.ColorKit(this._color).toRgb(),width:le,height:he,zIndex:te,evented:!1},Y=new re(`crosshair-${t}`,ge);this._shapes.push(Y),n.addObject(Y)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:n}=this._context;this._clear();for(let r=0;r<e.length;r++){const s=e[r];this._addShapes(s,r,n,t)}n.makeDirty(!0)}async dispose(){super.dispose()}};O=se([p(1,o.Inject(T.SheetSkeletonManagerService)),p(2,o.Inject(w.SheetsSelectionsService)),p(3,o.Inject(f)),p(4,o.Inject(o.IContextService)),p(5,w.IRefSelectionsService)],O);var oe=Object.getOwnPropertyDescriptor,ae=(i,e,t,n)=>{for(var r=n>1?void 0:n?oe(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},N=(i,e)=>(t,n)=>e(t,n,i);c.UniverSheetsCrosshairHighlightPlugin=(I=class extends o.Plugin{constructor(e=A,t,n,r){super(),this._config=e,this._injector=t,this._renderManagerService=n,this._configService=r;const{...s}=o.merge({},A,this._config);this._configService.setConfig(q,s)}onStarting(){[[f],[H]].forEach(e=>this._injector.add(e))}onReady(){[[O]].forEach(e=>this._injector.add(e)),this._injector.get(H),this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[O])}},h(I,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),h(I,"type",o.UniverInstanceType.UNIVER_SHEET),I),c.UniverSheetsCrosshairHighlightPlugin=ae([N(1,o.Inject(o.Injector)),N(2,v.IRenderManagerService),N(3,o.IConfigService)],c.UniverSheetsCrosshairHighlightPlugin),c.CROSSHAIR_HIGHLIGHT_COLORS=M,c.DisableCrosshairHighlightOperation=k,c.EnableCrosshairHighlightOperation=V,c.SetCrosshairHighlightColorOperation=$,c.SheetsCrosshairHighlightService=f,c.ToggleCrosshairHighlightOperation=b,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
1
+ (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/sheets"),require("@univerjs/sheets-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs","@univerjs/engine-render","@univerjs/ui","react/jsx-runtime","@univerjs/design","react","@univerjs/sheets","@univerjs/sheets-ui"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverSheetsCrosshairHighlight={},c.UniverCore,c.rxjs,c.UniverEngineRender,c.UniverUi,c.React,c.UniverDesign,c.React,c.UniverSheets,c.UniverSheetsUi))})(this,function(c,o,h,y,v,P,x,S,w,T){"use strict";var ue=Object.defineProperty;var de=(c,o,h)=>o in c?ue(c,o,{enumerable:!0,configurable:!0,writable:!0,value:h}):c[o]=h;var g=(c,o,h)=>de(c,typeof o!="symbol"?o+"":o,h);var O;const M=["rgba(158, 109, 227, 0.3)","rgba(254, 75, 75, 0.3)","rgba(255, 140, 81, 0.3)","rgba(164, 220, 22, 0.3)","rgba(45, 174, 255, 0.3)","rgba(58, 96, 247, 0.3)","rgba(242, 72, 166, 0.3)","rgba(153, 153, 153, 0.3)","rgba(158, 109, 227, 0.15)","rgba(254, 75, 75, 0.15)","rgba(255, 140, 81, 0.15)","rgba(164, 220, 22, 0.15)","rgba(45, 174, 255, 0.15)","rgba(58, 96, 247, 0.15)","rgba(242, 72, 166, 0.15)","rgba(153, 153, 153, 0.15)"];class f extends o.Disposable{constructor(){super(...arguments);g(this,"_enabled$",new h.BehaviorSubject(!1));g(this,"enabled$",this._enabled$.asObservable());g(this,"_color$",new h.BehaviorSubject(M[0]));g(this,"color$",this._color$.asObservable())}get enabled(){return this._enabled$.getValue()}get color(){return this._color$.getValue()}dispose(){this._enabled$.complete()}setEnabled(t){this._enabled$.next(t)}setColor(t){this._color$.next(t)}}const R={id:"sheet.operation.toggle-crosshair-highlight",type:o.CommandType.OPERATION,handler(i){const e=i.get(f),t=e.enabled;return e.setEnabled(!t),!0}},$={id:"sheet.operation.set-crosshair-highlight-color",type:o.CommandType.OPERATION,handler(i,{value:e}){const t=i.get(f);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},A={id:"sheet.operation.enable-crosshair-highlight",type:o.CommandType.OPERATION,handler(i){const e=i.get(f);return e.enabled?!1:(e.setEnabled(!0),!0)}},L={id:"sheet.operation.disable-crosshair-highlight",type:o.CommandType.OPERATION,handler(i){const e=i.get(f);return e.enabled?(e.setEnabled(!1),!0):!1}},q="sheets-crosshair-highlight.config",U={};var u=function(){return u=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},u.apply(this,arguments)},B=function(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(t[n[r]]=i[n[r]]);return t},G=S.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,s=i.extend,a=B(i,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),d=S.useRef("_".concat(F()));return V(t,"".concat(n),{defIds:t.defIds,idSuffix:d.current},u({ref:e,className:l},a),s)});function V(i,e,t,n,r){return S.createElement(i.tag,u(u({key:e},Z(i,t,r)),n),(W(i,t).children||[]).map(function(s,a){return V(s,"".concat(e,"-").concat(i.tag,"-").concat(a),t,void 0,r)}))}function Z(i,e,t){var n=u({},i.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1),i.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],l=s[1];a==="mask"&&typeof l=="string"&&(n[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var r=e.defIds;return!r||r.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],l=s[1];typeof l=="string"&&(n[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function W(i,e){var t,n=e.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?u(u({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.includes(r.attrs.id)?u(u({},r),{attrs:u(u({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function F(){return Math.random().toString(36).substring(2,8)}G.displayName="UniverIcon";var X={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z",fillRule:"evenodd",clipRule:"evenodd"}}]},k=S.forwardRef(function(i,e){return S.createElement(G,Object.assign({},i,{id:"cross-highlighting-icon",ref:e,icon:X}))});k.displayName="CrossHighlightingIcon";function z(i){const{onChange:e}=i,t=v.useDependency(f),n=v.useObservable(t.color$),r=S.useCallback(s=>{e==null||e(s)},[e]);return P.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3",children:M.map(s=>P.jsx("div",{className:x.clsx("univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1 univer-transition-shadow hover:univer-ring-primary-600/40 hover:univer-ring-[1.5px]",x.borderClassName,{"univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600":s===n}),style:{backgroundColor:s},onClick:()=>r(s)},s))})}const D="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function K(i){const e=i.get(f);return{id:R.id,tooltip:"crosshair.button.tooltip",type:v.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingIcon",selections:[{label:{name:D,hoverable:!1,selectable:!1}}],selectionsCommandId:$.id,activated$:e.enabled$,hidden$:v.getMenuHiddenObservable(i,o.UniverInstanceType.UNIVER_SHEET)}}const J={[v.ContextMenuPosition.FOOTER_MENU]:{[v.ContextMenuGroup.OTHERS]:{[R.id]:{order:0,menuItemFactory:K}}}};var Q=Object.getOwnPropertyDescriptor,ee=(i,e,t,n)=>{for(var r=n>1?void 0:n?Q(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},j=(i,e)=>(t,n)=>e(t,n,i);let b=class extends o.Disposable{constructor(i,e,t){super(),this._componentMgr=i,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[R,$,A,L].forEach(i=>this._cmdSrv.registerCommand(i))}_initMenus(){this._menuManagerService.mergeMenu(J)}_initComponents(){this._componentMgr.register(D,z),this._componentMgr.register("CrossHighlightingIcon",k)}};b=ee([j(0,o.Inject(v.ComponentManager)),j(1,v.IMenuManagerService),j(2,o.ICommandService)],b);const te=1;class ne{constructor(){g(this,"_selectedRanges",[]);g(this,"_ranges",[])}addRange(e){if(e.rangeType===o.RANGE_TYPE.COLUMN||e.rangeType===o.RANGE_TYPE.ROW||e.rangeType===o.RANGE_TYPE.ALL)return;const t=this._getIntersects(e),n=this._getSplitRanges(e,t);n.length>0&&this._ranges.push(...n)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,t){let n=[e];for(const r of t.concat(this._selectedRanges)){const s=[];for(const a of n){const l=o.Rectangle.subtract(a,r);l&&l.length>0&&s.push(...l)}n=s}return n.filter(r=>r.startRow<=r.endRow&&r.startColumn<=r.endColumn)}_getIntersects(e){const t=[];for(const n of this._ranges){const r=o.Rectangle.getIntersects(n,e);r&&t.push(r)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class re extends y.Shape{constructor(t,n){super(t,n);g(this,"_color");n&&this.setShapeProps(n)}setShapeProps(t){typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){var r,s;const n=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(s=(r=this._color)==null?void 0:r.a)!=null?s:.5})`;y.Rect.drawWith(t,{width:this.width,height:this.height,fill:n,stroke:void 0,strokeWidth:0,evented:!1})}}var ie=Object.getOwnPropertyDescriptor,se=(i,e,t,n)=>{for(var r=n>1?void 0:n?ie(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},C=(i,e)=>(t,n)=>e(t,n,i);let H=class extends o.Disposable{constructor(e,t,n,r,s,a){super();g(this,"_shapes",[]);g(this,"_rangeCollection",new ne);g(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=n,this._sheetsCrosshairHighlightService=r,this._contextService=s,this._refSelectionsService=a,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const n=t.getRowCount(),r=t.getColumnCount(),s=[];for(const a of e){const{startRow:l,endRow:d,startColumn:p,endColumn:m}=a.range;d-l+1===n||m-p+1===r||s.push(a.range)}this._rangeCollection.setSelectedRanges(s);for(const a of s)this.addSelection(a,t)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(h.combineLatest([this._contextService.subscribeContextValue$(w.REF_SELECTIONS_ENABLED).pipe(h.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(h.tap(t=>this._color=t)),h.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(h.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),h.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(h.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,n,r,s,a,l])=>{if(this._clear(),!r)return;const d=t?l:a;this._rangeCollection.reset(),this._transformSelection(d,e.getActiveSheet()),this.render(this._rangeCollection.getRanges())}))}addSelection(e,t){if(e.rangeType===o.RANGE_TYPE.COLUMN||e.rangeType===o.RANGE_TYPE.ROW||e.rangeType===o.RANGE_TYPE.ALL)return;const n=t.getRowCount(),r=t.getColumnCount(),{startRow:s,endRow:a,startColumn:l,endColumn:d}=e,p={startRow:s,endRow:a,startColumn:0,endColumn:l-1},m={startRow:s,endRow:a,startColumn:d+1,endColumn:r},I={startRow:0,endRow:s-1,startColumn:l,endColumn:d},E={startRow:a+1,endRow:n,startColumn:l,endColumn:d};for(const _ of[p,m,I,E])_.startRow<=_.endRow&&_.startColumn<=_.endColumn&&this._rangeCollection.addRange(_)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,n,r){const{startRow:s,endRow:a,startColumn:l,endColumn:d}=e,p=T.getCoordByCell(s,l,n,r),m=T.getCoordByCell(a,d,n,r),{startX:I,startY:E}=p,{endX:_,endY:ce}=m,le=_-I,he=ce-E,ge={left:I,top:E,color:new o.ColorKit(this._color).toRgb(),width:le,height:he,zIndex:te,evented:!1},Y=new re(`crosshair-${t}`,ge);this._shapes.push(Y),n.addObject(Y)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:n}=this._context;this._clear();for(let r=0;r<e.length;r++){const s=e[r];this._addShapes(s,r,n,t)}n.makeDirty(!0)}async dispose(){super.dispose()}};H=se([C(1,o.Inject(T.SheetSkeletonManagerService)),C(2,o.Inject(w.SheetsSelectionsService)),C(3,o.Inject(f)),C(4,o.Inject(o.IContextService)),C(5,w.IRefSelectionsService)],H);var oe=Object.getOwnPropertyDescriptor,ae=(i,e,t,n)=>{for(var r=n>1?void 0:n?oe(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},N=(i,e)=>(t,n)=>e(t,n,i);c.UniverSheetsCrosshairHighlightPlugin=(O=class extends o.Plugin{constructor(e=U,t,n,r){super(),this._config=e,this._injector=t,this._renderManagerService=n,this._configService=r;const{...s}=o.merge({},U,this._config);this._configService.setConfig(q,s)}onStarting(){[[f],[b]].forEach(e=>this._injector.add(e))}onReady(){[[H]].forEach(e=>this._injector.add(e)),this._injector.get(b),this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[H])}},g(O,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),g(O,"type",o.UniverInstanceType.UNIVER_SHEET),O),c.UniverSheetsCrosshairHighlightPlugin=ae([N(1,o.Inject(o.Injector)),N(2,y.IRenderManagerService),N(3,o.IConfigService)],c.UniverSheetsCrosshairHighlightPlugin),c.CROSSHAIR_HIGHLIGHT_COLORS=M,c.DisableCrosshairHighlightOperation=L,c.EnableCrosshairHighlightOperation=A,c.SetCrosshairHighlightColorOperation=$,c.SheetsCrosshairHighlightService=f,c.ToggleCrosshairHighlightOperation=R,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-crosshair-highlight",
3
- "version": "0.8.2-nightly.202506261607",
3
+ "version": "0.8.3-nightly.202506271607",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -63,12 +63,12 @@
63
63
  },
64
64
  "dependencies": {
65
65
  "@univerjs/icons": "^0.4.4",
66
- "@univerjs/design": "0.8.2-nightly.202506261607",
67
- "@univerjs/core": "0.8.2-nightly.202506261607",
68
- "@univerjs/sheets": "0.8.2-nightly.202506261607",
69
- "@univerjs/engine-render": "0.8.2-nightly.202506261607",
70
- "@univerjs/ui": "0.8.2-nightly.202506261607",
71
- "@univerjs/sheets-ui": "0.8.2-nightly.202506261607"
66
+ "@univerjs/design": "0.8.3-nightly.202506271607",
67
+ "@univerjs/engine-render": "0.8.3-nightly.202506271607",
68
+ "@univerjs/core": "0.8.3-nightly.202506271607",
69
+ "@univerjs/ui": "0.8.3-nightly.202506271607",
70
+ "@univerjs/sheets-ui": "0.8.3-nightly.202506271607",
71
+ "@univerjs/sheets": "0.8.3-nightly.202506271607"
72
72
  },
73
73
  "devDependencies": {
74
74
  "postcss": "^8.5.6",
@@ -78,7 +78,7 @@
78
78
  "typescript": "^5.8.3",
79
79
  "vite": "^6.3.5",
80
80
  "vitest": "^3.2.4",
81
- "@univerjs-infra/shared": "0.8.2"
81
+ "@univerjs-infra/shared": "0.8.3"
82
82
  },
83
83
  "scripts": {
84
84
  "test": "vitest run",