@univerjs/sheets-crosshair-highlight 0.5.4-nightly.202501150735 → 0.5.4-nightly.202501151252

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/facade.js CHANGED
@@ -1 +1 @@
1
- "use strict";const r=require("@univerjs/core"),e=require("@univerjs/sheets-crosshair-highlight");class s extends r.FUniver{setCrosshairHighlightEnabled(i){return i?this._commandService.syncExecuteCommand(e.EnableCrosshairHighlightOperation.id):this._commandService.syncExecuteCommand(e.DisableCrosshairHighlightOperation.id),this}setCrosshairHighlightColor(i){return this._commandService.syncExecuteCommand(e.SetCrosshairHighlightColorOperation.id,{value:i}),this}}r.FUniver.extend(s);
1
+ "use strict";const h=require("@univerjs/core"),i=require("@univerjs/sheets-crosshair-highlight");class o extends h.FUniver{_initialize(e){const s=e.get(h.ICommandService);this.disposeWithMe(s.onCommandExecuted(r=>{if(r.id===i.EnableCrosshairHighlightOperation.id||r.id===i.DisableCrosshairHighlightOperation.id){const t=this.getActiveSheet();if(!t||!this._eventListend(this.Event.CrosshairHighlightEnabledChanged))return;this.fireEvent(this.Event.CrosshairHighlightEnabledChanged,{enabled:this.getCrosshairHighlightEnabled(),...t})}if(r.id===i.SetCrosshairHighlightColorOperation.id){const t=this.getActiveSheet();if(!t||!this._eventListend(this.Event.CrosshairHighlightColorChanged))return;this.fireEvent(this.Event.CrosshairHighlightColorChanged,{color:this.getCrosshairHighlightColor(),...t})}}))}setCrosshairHighlightEnabled(e){return e?this._commandService.syncExecuteCommand(i.EnableCrosshairHighlightOperation.id):this._commandService.syncExecuteCommand(i.DisableCrosshairHighlightOperation.id),this}setCrosshairHighlightColor(e){return this._commandService.syncExecuteCommand(i.SetCrosshairHighlightColorOperation.id,{value:e}),this}getCrosshairHighlightEnabled(){return this._injector.get(i.SheetsCrosshairHighlightService).enabled}getCrosshairHighlightColor(){return this._injector.get(i.SheetsCrosshairHighlightService).color}get CROSSHAIR_HIGHLIGHT_COLORS(){return i.CROSSHAIR_HIGHLIGHT_COLORS}}h.FUniver.extend(o);
package/lib/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var z=Object.defineProperty;var Q=(n,e,t)=>e in n?z(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var g=(n,e,t)=>Q(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),P=require("@univerjs/engine-render"),m=require("@univerjs/ui"),_=require("rxjs"),C=require("react"),$=require("@univerjs/sheets"),M=require("@univerjs/sheets-ui"),ee="sheets-crosshair-highlight.config",A={};var u=function(){return u=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},u.apply(this,arguments)},te=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},D=C.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,s=n.extend,o=te(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),l=C.useRef("_".concat(ie()));return q(t,"".concat(r),{defIds:t.defIds,idSuffix:l.current},u({ref:e,className:c},o),s)});function q(n,e,t,r,i){return C.createElement(n.tag,u(u({key:e},re(n,t,i)),r),(ne(n,t).children||[]).map(function(s,o){return q(s,"".concat(e,"-").concat(n.tag,"-").concat(o),t,void 0,i)}))}function re(n,e,t){var r=u({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);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 ne(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)?u(u({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?u(u({},i),{attrs:u(u({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function ie(){return Math.random().toString(36).substring(2,8)}D.displayName="UniverIcon";var se={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#E5E5E5",d:"M1.6499 3.65002C1.6499 2.54545 2.54533 1.65002 3.6499 1.65002H12.3499C13.4545 1.65002 14.3499 2.54545 14.3499 3.65002V12.35C14.3499 13.4546 13.4545 14.35 12.3499 14.35H3.6499C2.54533 14.35 1.6499 13.4546 1.6499 12.35V3.65002Z"}},{tag:"path",attrs:{fill:"#fff",d:"M9.9998 1.65002H5.9998V6H1.6499V10H5.9998V14.35H9.9998V10H14.3499V6H9.9998V1.65002Z"}},{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"}}]},Y=C.forwardRef(function(n,e){return C.createElement(D,Object.assign({},n,{id:"cross-highlighting-single",ref:e,icon:se}))});Y.displayName="CrossHighlightingSingle";const j=["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 v extends a.Disposable{constructor(){super(...arguments);g(this,"_enabled$",new _.BehaviorSubject(!1));g(this,"enabled$",this._enabled$.asObservable());g(this,"_color$",new _.BehaviorSubject(j[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 E={id:"sheet.operation.toggle-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(v),t=e.enabled;return e.setEnabled(!t),!0}},N={id:"sheet.operation.set-crosshair-highlight-color",type:a.CommandType.OPERATION,handler(n,{value:e}){const t=n.get(v);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(v);return e.enabled?!1:(e.setEnabled(!0),!0)}},B={id:"sheet.operation.disable-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(v);return e.enabled?(e.setEnabled(!1),!0):!1}};var y={exports:{}},R={};/**
1
+ "use strict";var z=Object.defineProperty;var Q=(n,e,t)=>e in n?z(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var g=(n,e,t)=>Q(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),P=require("@univerjs/engine-render"),m=require("@univerjs/ui"),_=require("rxjs"),C=require("react"),$=require("@univerjs/sheets"),M=require("@univerjs/sheets-ui"),ee="sheets-crosshair-highlight.config",A={};var u=function(){return u=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},u.apply(this,arguments)},te=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},D=C.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,s=n.extend,o=te(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),l=C.useRef("_".concat(ie()));return q(t,"".concat(r),{defIds:t.defIds,idSuffix:l.current},u({ref:e,className:c},o),s)});function q(n,e,t,r,i){return C.createElement(n.tag,u(u({key:e},re(n,t,i)),r),(ne(n,t).children||[]).map(function(s,o){return q(s,"".concat(e,"-").concat(n.tag,"-").concat(o),t,void 0,i)}))}function re(n,e,t){var r=u({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);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 ne(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)?u(u({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?u(u({},i),{attrs:u(u({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function ie(){return Math.random().toString(36).substring(2,8)}D.displayName="UniverIcon";var se={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#E5E5E5",d:"M1.6499 3.65002C1.6499 2.54545 2.54533 1.65002 3.6499 1.65002H12.3499C13.4545 1.65002 14.3499 2.54545 14.3499 3.65002V12.35C14.3499 13.4546 13.4545 14.35 12.3499 14.35H3.6499C2.54533 14.35 1.6499 13.4546 1.6499 12.35V3.65002Z"}},{tag:"path",attrs:{fill:"#fff",d:"M9.9998 1.65002H5.9998V6H1.6499V10H5.9998V14.35H9.9998V10H14.3499V6H9.9998V1.65002Z"}},{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"}}]},Y=C.forwardRef(function(n,e){return C.createElement(D,Object.assign({},n,{id:"cross-highlighting-single",ref:e,icon:se}))});Y.displayName="CrossHighlightingSingle";const j=["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 S extends a.Disposable{constructor(){super(...arguments);g(this,"_enabled$",new _.BehaviorSubject(!1));g(this,"enabled$",this._enabled$.asObservable());g(this,"_color$",new _.BehaviorSubject(j[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 E={id:"sheet.operation.toggle-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(S),t=e.enabled;return e.setEnabled(!t),!0}},N={id:"sheet.operation.set-crosshair-highlight-color",type:a.CommandType.OPERATION,handler(n,{value:e}){const t=n.get(S);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(S);return e.enabled?!1:(e.setEnabled(!0),!0)}},B={id:"sheet.operation.disable-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(S);return e.enabled?(e.setEnabled(!1),!0):!1}};var y={exports:{}},R={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var L;function oe(){if(L)return R;L=1;var n=C,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(c,l,S){var h,f={},p=null,d=null;S!==void 0&&(p=""+S),l.key!==void 0&&(p=""+l.key),l.ref!==void 0&&(d=l.ref);for(h in l)r.call(l,h)&&!s.hasOwnProperty(h)&&(f[h]=l[h]);if(c&&c.defaultProps)for(h in l=c.defaultProps,l)f[h]===void 0&&(f[h]=l[h]);return{$$typeof:e,type:c,key:p,ref:d,props:f,_owner:i.current}}return R.Fragment=t,R.jsx=o,R.jsxs=o,R}var G;function ae(){return G||(G=1,y.exports=oe()),y.exports}var U=ae();function Z(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=Z(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function ce(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=Z(n))&&(r&&(r+=" "),r+=e);return r}const le="univer-crosshair-highlight-overlay",he="univer-crosshair-highlight-item",ge="univer-crosshair-highlight-item-selected",T={crosshairHighlightOverlay:le,crosshairHighlightItem:he,crosshairHighlightItemSelected:ge};function ue(n){const{onChange:e}=n,t=a.useDependency(v),r=a.useObservable(t.color$),i=C.useCallback(s=>{e==null||e(s)},[e]);return U.jsx("div",{className:T.crosshairHighlightOverlay,children:j.map(s=>U.jsx("div",{className:ce(T.crosshairHighlightItem,{[T.crosshairHighlightItemSelected]:s===r}),style:{backgroundColor:s},onClick:()=>i(s)},s))})}const F="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function de(n){const e=n.get(v);return{id:E.id,tooltip:"crosshair.button.tooltip",type:m.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:F,hoverable:!1}}],selectionsCommandId:N.id,activated$:e.enabled$,hidden$:m.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const fe={[m.ContextMenuPosition.FOOTER_MENU]:{[m.ContextMenuGroup.OTHERS]:{[E.id]:{order:0,menuItemFactory:de}}}};var _e=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,pe=(n,e,t,r)=>{for(var i=r>1?void 0:r?Se(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&_e(e,t,i),i},w=(n,e)=>(t,r)=>e(t,r,n);let O=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(){[E,N,k,B].forEach(n=>this._cmdSrv.registerCommand(n))}_initMenus(){this._menuManagerService.mergeMenu(fe)}_initComponents(){this._componentMgr.register(F,ue),this._componentMgr.register("CrossHighlightingSingle",Y)}};O=pe([w(0,a.Inject(m.ComponentManager)),w(1,m.IMenuManagerService),w(2,a.ICommandService)],O);const ve=1;class Ce{constructor(){g(this,"_selectedRanges",[]);g(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 me extends P.Shape{constructor(t,r){super(t,r);g(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){const r=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${this._color.a})`;P.Rect.drawWith(t,{width:this.width,height:this.height,fill:r,stroke:void 0,strokeWidth:0,evented:!1})}}var Re=Object.defineProperty,be=Object.getOwnPropertyDescriptor,He=(n,e,t,r)=>{for(var i=r>1?void 0:r?be(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Re(e,t,i),i},b=(n,e)=>(t,r)=>e(t,r,n);let I=class extends a.Disposable{constructor(e,t,r,i,s,o){super();g(this,"_shapes",[]);g(this,"_rangeCollection",new Ce);g(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:l,startColumn:S,endColumn:h}=o.range;l-c+1===r||h-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(_.combineLatest([this._contextService.subscribeContextValue$($.REF_SELECTIONS_ENABLED).pipe(_.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(_.tap(t=>this._color=t)),_.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(_.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),_.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(_.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,r,i,s,o,c])=>{if(this._clear(),!i)return;const l=t?c:o;this._rangeCollection.reset(),this._transformSelection(l,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:l}=e,S={startRow:s,endRow:o,startColumn:0,endColumn:c-1},h={startRow:s,endRow:o,startColumn:l+1,endColumn:i},f={startRow:0,endRow:s-1,startColumn:c,endColumn:l},p={startRow:o+1,endRow:r,startColumn:c,endColumn:l};for(const d of[S,h,f,p])d.startRow<=d.endRow&&d.startColumn<=d.endColumn&&this._rangeCollection.addRange(d)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,r,i){const{startRow:s,endRow:o,startColumn:c,endColumn:l}=e,S=M.getCoordByCell(s,c,r,i),h=M.getCoordByCell(o,l,r,i),{startX:f,startY:p}=S,{endX:d,endY:W}=h,J=d-f,X=W-p,K={left:f,top:p,color:new a.ColorKit(this._color).toRgb(),width:J,height:X,zIndex:ve,evented:!1},V=new me(`crosshair-${t}`,K);this._shapes.push(V),r.addObject(V)}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()}};I=He([b(1,a.Inject(M.SheetSkeletonManagerService)),b(2,a.Inject($.SheetsSelectionsService)),b(3,a.Inject(v)),b(4,a.Inject(a.IContextService)),b(5,$.IRefSelectionsService)],I);var Oe=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Ee=(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=(r?o(e,t,i):o(i))||i);return r&&i&&Oe(e,t,i),i},x=(n,e)=>(t,r)=>e(t,r,n),H;exports.UniverSheetsCrosshairHighlightPlugin=(H=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(ee,s)}onStarting(){[[v],[O]].forEach(e=>this._injector.add(e))}onReady(){[[I]].forEach(e=>this._injector.add(e)),this._injector.get(O),this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,[I])}},g(H,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),g(H,"type",a.UniverInstanceType.UNIVER_SHEET),H);exports.UniverSheetsCrosshairHighlightPlugin=Ee([x(1,a.Inject(a.Injector)),x(2,P.IRenderManagerService),x(3,a.IConfigService)],exports.UniverSheetsCrosshairHighlightPlugin);exports.CROSSHAIR_HIGHLIGHT_COLORS=j;exports.DisableCrosshairHighlightOperation=B;exports.EnableCrosshairHighlightOperation=k;exports.SetCrosshairHighlightColorOperation=N;exports.ToggleCrosshairHighlightOperation=E;
9
+ */var L;function oe(){if(L)return R;L=1;var n=C,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(c,l,p){var h,f={},v=null,d=null;p!==void 0&&(v=""+p),l.key!==void 0&&(v=""+l.key),l.ref!==void 0&&(d=l.ref);for(h in l)r.call(l,h)&&!s.hasOwnProperty(h)&&(f[h]=l[h]);if(c&&c.defaultProps)for(h in l=c.defaultProps,l)f[h]===void 0&&(f[h]=l[h]);return{$$typeof:e,type:c,key:v,ref:d,props:f,_owner:i.current}}return R.Fragment=t,R.jsx=o,R.jsxs=o,R}var G;function ae(){return G||(G=1,y.exports=oe()),y.exports}var U=ae();function Z(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=Z(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function ce(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=Z(n))&&(r&&(r+=" "),r+=e);return r}const le="univer-crosshair-highlight-overlay",he="univer-crosshair-highlight-item",ge="univer-crosshair-highlight-item-selected",T={crosshairHighlightOverlay:le,crosshairHighlightItem:he,crosshairHighlightItemSelected:ge};function ue(n){const{onChange:e}=n,t=a.useDependency(S),r=a.useObservable(t.color$),i=C.useCallback(s=>{e==null||e(s)},[e]);return U.jsx("div",{className:T.crosshairHighlightOverlay,children:j.map(s=>U.jsx("div",{className:ce(T.crosshairHighlightItem,{[T.crosshairHighlightItemSelected]:s===r}),style:{backgroundColor:s},onClick:()=>i(s)},s))})}const F="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function de(n){const e=n.get(S);return{id:E.id,tooltip:"crosshair.button.tooltip",type:m.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:F,hoverable:!1}}],selectionsCommandId:N.id,activated$:e.enabled$,hidden$:m.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const fe={[m.ContextMenuPosition.FOOTER_MENU]:{[m.ContextMenuGroup.OTHERS]:{[E.id]:{order:0,menuItemFactory:de}}}};var _e=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,pe=(n,e,t,r)=>{for(var i=r>1?void 0:r?Se(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&_e(e,t,i),i},w=(n,e)=>(t,r)=>e(t,r,n);let O=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(){[E,N,k,B].forEach(n=>this._cmdSrv.registerCommand(n))}_initMenus(){this._menuManagerService.mergeMenu(fe)}_initComponents(){this._componentMgr.register(F,ue),this._componentMgr.register("CrossHighlightingSingle",Y)}};O=pe([w(0,a.Inject(m.ComponentManager)),w(1,m.IMenuManagerService),w(2,a.ICommandService)],O);const ve=1;class Ce{constructor(){g(this,"_selectedRanges",[]);g(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 me extends P.Shape{constructor(t,r){super(t,r);g(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){const r=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${this._color.a})`;P.Rect.drawWith(t,{width:this.width,height:this.height,fill:r,stroke:void 0,strokeWidth:0,evented:!1})}}var Re=Object.defineProperty,be=Object.getOwnPropertyDescriptor,He=(n,e,t,r)=>{for(var i=r>1?void 0:r?be(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Re(e,t,i),i},b=(n,e)=>(t,r)=>e(t,r,n);let I=class extends a.Disposable{constructor(e,t,r,i,s,o){super();g(this,"_shapes",[]);g(this,"_rangeCollection",new Ce);g(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:l,startColumn:p,endColumn:h}=o.range;l-c+1===r||h-p+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(_.combineLatest([this._contextService.subscribeContextValue$($.REF_SELECTIONS_ENABLED).pipe(_.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(_.tap(t=>this._color=t)),_.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(_.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),_.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(_.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,r,i,s,o,c])=>{if(this._clear(),!i)return;const l=t?c:o;this._rangeCollection.reset(),this._transformSelection(l,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:l}=e,p={startRow:s,endRow:o,startColumn:0,endColumn:c-1},h={startRow:s,endRow:o,startColumn:l+1,endColumn:i},f={startRow:0,endRow:s-1,startColumn:c,endColumn:l},v={startRow:o+1,endRow:r,startColumn:c,endColumn:l};for(const d of[p,h,f,v])d.startRow<=d.endRow&&d.startColumn<=d.endColumn&&this._rangeCollection.addRange(d)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,r,i){const{startRow:s,endRow:o,startColumn:c,endColumn:l}=e,p=M.getCoordByCell(s,c,r,i),h=M.getCoordByCell(o,l,r,i),{startX:f,startY:v}=p,{endX:d,endY:W}=h,J=d-f,X=W-v,K={left:f,top:v,color:new a.ColorKit(this._color).toRgb(),width:J,height:X,zIndex:ve,evented:!1},V=new me(`crosshair-${t}`,K);this._shapes.push(V),r.addObject(V)}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()}};I=He([b(1,a.Inject(M.SheetSkeletonManagerService)),b(2,a.Inject($.SheetsSelectionsService)),b(3,a.Inject(S)),b(4,a.Inject(a.IContextService)),b(5,$.IRefSelectionsService)],I);var Oe=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Ee=(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=(r?o(e,t,i):o(i))||i);return r&&i&&Oe(e,t,i),i},x=(n,e)=>(t,r)=>e(t,r,n),H;exports.UniverSheetsCrosshairHighlightPlugin=(H=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(ee,s)}onStarting(){[[S],[O]].forEach(e=>this._injector.add(e))}onReady(){[[I]].forEach(e=>this._injector.add(e)),this._injector.get(O),this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,[I])}},g(H,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),g(H,"type",a.UniverInstanceType.UNIVER_SHEET),H);exports.UniverSheetsCrosshairHighlightPlugin=Ee([x(1,a.Inject(a.Injector)),x(2,P.IRenderManagerService),x(3,a.IConfigService)],exports.UniverSheetsCrosshairHighlightPlugin);exports.CROSSHAIR_HIGHLIGHT_COLORS=j;exports.DisableCrosshairHighlightOperation=B;exports.EnableCrosshairHighlightOperation=k;exports.SetCrosshairHighlightColorOperation=N;exports.SheetsCrosshairHighlightService=S;exports.ToggleCrosshairHighlightOperation=E;
package/lib/es/facade.js CHANGED
@@ -1,13 +1,43 @@
1
- import { FUniver as e } from "@univerjs/core";
2
- import { EnableCrosshairHighlightOperation as r, DisableCrosshairHighlightOperation as s, SetCrosshairHighlightColorOperation as t } from "@univerjs/sheets-crosshair-highlight";
3
- class h extends e {
1
+ import { FUniver as o, ICommandService as a } from "@univerjs/core";
2
+ import { EnableCrosshairHighlightOperation as h, DisableCrosshairHighlightOperation as r, SetCrosshairHighlightColorOperation as s, SheetsCrosshairHighlightService as n, CROSSHAIR_HIGHLIGHT_COLORS as l } from "@univerjs/sheets-crosshair-highlight";
3
+ class c extends o {
4
+ _initialize(i) {
5
+ const g = i.get(a);
6
+ this.disposeWithMe(g.onCommandExecuted((t) => {
7
+ if (t.id === h.id || t.id === r.id) {
8
+ const e = this.getActiveSheet();
9
+ if (!e || !this._eventListend(this.Event.CrosshairHighlightEnabledChanged)) return;
10
+ this.fireEvent(this.Event.CrosshairHighlightEnabledChanged, {
11
+ enabled: this.getCrosshairHighlightEnabled(),
12
+ ...e
13
+ });
14
+ }
15
+ if (t.id === s.id) {
16
+ const e = this.getActiveSheet();
17
+ if (!e || !this._eventListend(this.Event.CrosshairHighlightColorChanged)) return;
18
+ this.fireEvent(this.Event.CrosshairHighlightColorChanged, {
19
+ color: this.getCrosshairHighlightColor(),
20
+ ...e
21
+ });
22
+ }
23
+ }));
24
+ }
4
25
  setCrosshairHighlightEnabled(i) {
5
- return i ? this._commandService.syncExecuteCommand(r.id) : this._commandService.syncExecuteCommand(s.id), this;
26
+ return i ? this._commandService.syncExecuteCommand(h.id) : this._commandService.syncExecuteCommand(r.id), this;
6
27
  }
7
28
  setCrosshairHighlightColor(i) {
8
- return this._commandService.syncExecuteCommand(t.id, {
29
+ return this._commandService.syncExecuteCommand(s.id, {
9
30
  value: i
10
31
  }), this;
11
32
  }
33
+ getCrosshairHighlightEnabled() {
34
+ return this._injector.get(n).enabled;
35
+ }
36
+ getCrosshairHighlightColor() {
37
+ return this._injector.get(n).color;
38
+ }
39
+ get CROSSHAIR_HIGHLIGHT_COLORS() {
40
+ return l;
41
+ }
12
42
  }
13
- e.extend(h);
43
+ o.extend(c);
package/lib/es/index.js CHANGED
@@ -477,6 +477,7 @@ export {
477
477
  Ge as DisableCrosshairHighlightOperation,
478
478
  Ae as EnableCrosshairHighlightOperation,
479
479
  J as SetCrosshairHighlightColorOperation,
480
+ S as SheetsCrosshairHighlightService,
480
481
  M as ToggleCrosshairHighlightOperation,
481
482
  k as UniverSheetsCrosshairHighlightPlugin
482
483
  };
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- .univer-crosshair-highlight-overlay{display:grid;row-gap:12px;-moz-column-gap:8px;column-gap:8px;grid-template-columns:repeat(8,20px)}.univer-crosshair-highlight-item{width:20px;height:20px;box-sizing:border-box;border-radius:4px;border:.5px solid rgb(var(--grey-400))}.univer-crosshair-highlight-item-selected{outline:1.5px solid rgb(var(--primary-color));outline-offset:1.5px}
1
+ .univer-crosshair-highlight-overlay{display:grid;grid-row-gap:12px;row-gap:12px;grid-column-gap:8px;-moz-column-gap:8px;column-gap:8px;grid-template-columns:repeat(8,20px)}.univer-crosshair-highlight-item{width:20px;height:20px;box-sizing:border-box;border-radius:4px;border:.5px solid rgb(var(--grey-400))}.univer-crosshair-highlight-item-selected{outline:1.5px solid rgb(var(--primary-color));outline-offset:1.5px}
@@ -1,21 +1,124 @@
1
- import { FUniver } from '@univerjs/core';
1
+ import { IEventBase, Injector, FUniver } from '@univerjs/core';
2
+ import { FWorkbook, FWorksheet } from '@univerjs/sheets/facade';
3
+ export interface IFSheetCrosshairHighlightEventMixin {
4
+ /**
5
+ * Triggered when the crosshair highlight is enabled or disabled.
6
+ * @example
7
+ * ```ts
8
+ * univerAPI.addEvent(univerAPI.Event.CrosshairHighlightEnabledChanged, (event) => {
9
+ * const enabled = event.enabled;
10
+ * const workbook = event.workbook;
11
+ * const worksheet = event.worksheet;
12
+ * });
13
+ * ```
14
+ */
15
+ readonly CrosshairHighlightEnabledChanged: 'CrosshairHighlightEnabledChanged';
16
+ /**
17
+ * Triggered when the crosshair highlight color is changed.
18
+ * @example
19
+ * ```ts
20
+ * univerAPI.addEvent(univerAPI.Event.CrosshairHighlightColorChanged, (event) => {
21
+ * const color = event.color;
22
+ * const workbook = event.workbook;
23
+ * const worksheet = event.worksheet;
24
+ * });
25
+ * ```
26
+ */
27
+ readonly CrosshairHighlightColorChanged: 'CrosshairHighlightColorChanged';
28
+ }
29
+ export interface ICrosshairHighlightEnabledChangedEvent extends IEventBase {
30
+ /**
31
+ * Whether the crosshair highlight is enabled.
32
+ */
33
+ enabled: boolean;
34
+ /**
35
+ * The workbook that the crosshair highlight is enabled in.
36
+ */
37
+ workbook: FWorkbook;
38
+ /**
39
+ * The worksheet that the crosshair highlight is enabled in.
40
+ */
41
+ worksheet: FWorksheet;
42
+ }
43
+ export interface ICrosshairHighlightColorChangedEvent extends IEventBase {
44
+ /**
45
+ * The color of the crosshair highlight.
46
+ */
47
+ color: string;
48
+ /**
49
+ * The workbook that the crosshair highlight is enabled in.
50
+ */
51
+ workbook: FWorkbook;
52
+ /**
53
+ * The worksheet that the crosshair highlight is enabled in.
54
+ */
55
+ worksheet: FWorksheet;
56
+ }
57
+ export declare class FSheetCrosshairHighlightEventMixin implements IFSheetCrosshairHighlightEventMixin {
58
+ get CrosshairHighlightEnabledChanged(): 'CrosshairHighlightEnabledChanged';
59
+ get CrosshairHighlightColorChanged(): 'CrosshairHighlightColorChanged';
60
+ }
61
+ export interface ISheetCrosshairHighlightEventConfigs {
62
+ CrosshairHighlightEnabledChanged: ICrosshairHighlightEnabledChangedEvent;
63
+ CrosshairHighlightColorChanged: ICrosshairHighlightColorChangedEvent;
64
+ }
2
65
  export interface IFUniverCrosshairHighlightMixin {
3
66
  /**
4
67
  * Enable or disable crosshair highlight.
5
68
  * @param {boolean} enabled if crosshair highlight should be enabled
69
+ * @returns {FUniver} the FUniver instance
70
+ * @example
71
+ * ```ts
72
+ * univer.setCrosshairHighlightEnabled(true);
73
+ * ```
6
74
  */
7
75
  setCrosshairHighlightEnabled(enabled: boolean): FUniver;
8
76
  /**
9
77
  * Set the color of the crosshair highlight.
10
78
  * @param {string} color the color of the crosshair highlight
79
+ * @returns {FUniver} the FUniver instance
80
+ * @example
81
+ * ```ts
82
+ * univer.setCrosshairHighlightColor('#FF0000');
83
+ * ```
11
84
  */
12
85
  setCrosshairHighlightColor(color: string): FUniver;
86
+ /**
87
+ * Get whether the crosshair highlight is enabled.
88
+ * @returns {boolean} whether the crosshair highlight is enabled
89
+ * @example
90
+ * ```ts
91
+ * const enabled = univer.getCrosshairHighlightEnabled();
92
+ * ```
93
+ */
94
+ getCrosshairHighlightEnabled(): boolean;
95
+ /**
96
+ * Get the color of the crosshair highlight.
97
+ * @returns {string} the color of the crosshair highlight
98
+ * @example
99
+ * ```ts
100
+ * const color = univer.getCrosshairHighlightColor();
101
+ * ```
102
+ */
103
+ getCrosshairHighlightColor(): string;
104
+ /**
105
+ * Get the available built-in colors for the crosshair highlight.
106
+ */
107
+ readonly CROSSHAIR_HIGHLIGHT_COLORS: string[];
13
108
  }
14
109
  export declare class FUniverCrosshairHighlightMixin extends FUniver implements IFUniverCrosshairHighlightMixin {
110
+ _initialize(injector: Injector): void;
15
111
  setCrosshairHighlightEnabled(enabled: boolean): FUniver;
16
112
  setCrosshairHighlightColor(color: string): FUniver;
113
+ getCrosshairHighlightEnabled(): boolean;
114
+ getCrosshairHighlightColor(): string;
115
+ get CROSSHAIR_HIGHLIGHT_COLORS(): string[];
17
116
  }
18
117
  declare module '@univerjs/core' {
19
118
  interface FUniver extends IFUniverCrosshairHighlightMixin {
20
119
  }
120
+ interface FEventName extends IFSheetCrosshairHighlightEventMixin {
121
+ }
122
+ interface IEventParamConfig extends ISheetCrosshairHighlightEventConfigs {
123
+ }
21
124
  }
@@ -15,5 +15,5 @@
15
15
  */
16
16
  import './global.css';
17
17
  export { UniverSheetsCrosshairHighlightPlugin } from './plugin';
18
- export { CROSSHAIR_HIGHLIGHT_COLORS } from './services/crosshair.service';
18
+ export { CROSSHAIR_HIGHLIGHT_COLORS, SheetsCrosshairHighlightService } from './services/crosshair.service';
19
19
  export { DisableCrosshairHighlightOperation, EnableCrosshairHighlightOperation, type ISetCrosshairHighlightColorOperationParams, SetCrosshairHighlightColorOperation, ToggleCrosshairHighlightOperation, } from './commands/operations/operation';
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(e,i){typeof exports=="object"&&typeof module<"u"?i(require("@univerjs/core"),require("@univerjs/sheets-crosshair-highlight")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/sheets-crosshair-highlight"],i):(e=typeof globalThis<"u"?globalThis:e||self,i(e.UniverCore,e.UniverSheetsCrosshairHighlight))})(this,function(e,i){"use strict";class r extends e.FUniver{setCrosshairHighlightEnabled(n){return n?this._commandService.syncExecuteCommand(i.EnableCrosshairHighlightOperation.id):this._commandService.syncExecuteCommand(i.DisableCrosshairHighlightOperation.id),this}setCrosshairHighlightColor(n){return this._commandService.syncExecuteCommand(i.SetCrosshairHighlightColorOperation.id,{value:n}),this}}e.FUniver.extend(r)});
1
+ (function(e,i){typeof exports=="object"&&typeof module<"u"?i(require("@univerjs/core"),require("@univerjs/sheets-crosshair-highlight")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/sheets-crosshair-highlight"],i):(e=typeof globalThis<"u"?globalThis:e||self,i(e.UniverCore,e.UniverSheetsCrosshairHighlight))})(this,function(e,i){"use strict";class n extends e.FUniver{_initialize(t){const s=t.get(e.ICommandService);this.disposeWithMe(s.onCommandExecuted(h=>{if(h.id===i.EnableCrosshairHighlightOperation.id||h.id===i.DisableCrosshairHighlightOperation.id){const r=this.getActiveSheet();if(!r||!this._eventListend(this.Event.CrosshairHighlightEnabledChanged))return;this.fireEvent(this.Event.CrosshairHighlightEnabledChanged,{enabled:this.getCrosshairHighlightEnabled(),...r})}if(h.id===i.SetCrosshairHighlightColorOperation.id){const r=this.getActiveSheet();if(!r||!this._eventListend(this.Event.CrosshairHighlightColorChanged))return;this.fireEvent(this.Event.CrosshairHighlightColorChanged,{color:this.getCrosshairHighlightColor(),...r})}}))}setCrosshairHighlightEnabled(t){return t?this._commandService.syncExecuteCommand(i.EnableCrosshairHighlightOperation.id):this._commandService.syncExecuteCommand(i.DisableCrosshairHighlightOperation.id),this}setCrosshairHighlightColor(t){return this._commandService.syncExecuteCommand(i.SetCrosshairHighlightColorOperation.id,{value:t}),this}getCrosshairHighlightEnabled(){return this._injector.get(i.SheetsCrosshairHighlightService).enabled}getCrosshairHighlightColor(){return this._injector.get(i.SheetsCrosshairHighlightService).color}get CROSSHAIR_HIGHLIGHT_COLORS(){return i.CROSSHAIR_HIGHLIGHT_COLORS}}e.FUniver.extend(n)});
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
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"),require("@univerjs/sheets"),require("@univerjs/sheets-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/ui","rxjs","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.UniverSheets,c.UniverSheetsUi))})(this,function(c,o,v,H,_,R,w,P){"use strict";var be=Object.defineProperty;var Oe=(c,o,v)=>o in c?be(c,o,{enumerable:!0,configurable:!0,writable:!0,value:v}):c[o]=v;var u=(c,o,v)=>Oe(c,typeof o!="symbol"?o+"":o,v);var T;const J="sheets-crosshair-highlight.config",A={};var d=function(){return d=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},d.apply(this,arguments)},X=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t},L=R.forwardRef(function(r,e){var t=r.icon,n=r.id,i=r.className,s=r.extend,a=X(r,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),h=R.useRef("_".concat(Q()));return U(t,"".concat(n),{defIds:t.defIds,idSuffix:h.current},d({ref:e,className:l},a),s)});function U(r,e,t,n,i){return R.createElement(r.tag,d(d({key:e},K(r,t,i)),n),(z(r,t).children||[]).map(function(s,a){return U(s,"".concat(e,"-").concat(r.tag,"-").concat(a),t,void 0,i)}))}function K(r,e,t){var n=d({},r.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1);var i=e.defIds;return!i||i.length===0||(r.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 z(r,e){var t,n=e.defIds;return!n||n.length===0?r:r.tag==="defs"&&(!((t=r.children)===null||t===void 0)&&t.length)?d(d({},r),{children:r.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?d(d({},i),{attrs:d(d({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):r}function Q(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var ee={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#E5E5E5",d:"M1.6499 3.65002C1.6499 2.54545 2.54533 1.65002 3.6499 1.65002H12.3499C13.4545 1.65002 14.3499 2.54545 14.3499 3.65002V12.35C14.3499 13.4546 13.4545 14.35 12.3499 14.35H3.6499C2.54533 14.35 1.6499 13.4546 1.6499 12.35V3.65002Z"}},{tag:"path",attrs:{fill:"#fff",d:"M9.9998 1.65002H5.9998V6H1.6499V10H5.9998V14.35H9.9998V10H14.3499V6H9.9998V1.65002Z"}},{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=R.forwardRef(function(r,e){return R.createElement(L,Object.assign({},r,{id:"cross-highlighting-single",ref:e,icon:ee}))});G.displayName="CrossHighlightingSingle";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 p extends o.Disposable{constructor(){super(...arguments);u(this,"_enabled$",new _.BehaviorSubject(!1));u(this,"enabled$",this._enabled$.asObservable());u(this,"_color$",new _.BehaviorSubject(M[0]));u(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:o.CommandType.OPERATION,handler(r){const e=r.get(p),t=e.enabled;return e.setEnabled(!t),!0}},j={id:"sheet.operation.set-crosshair-highlight-color",type:o.CommandType.OPERATION,handler(r,{value:e}){const t=r.get(p);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},D={id:"sheet.operation.enable-crosshair-highlight",type:o.CommandType.OPERATION,handler(r){const e=r.get(p);return e.enabled?!1:(e.setEnabled(!0),!0)}},Y={id:"sheet.operation.disable-crosshair-highlight",type:o.CommandType.OPERATION,handler(r){const e=r.get(p);return e.enabled?(e.setEnabled(!1),!0):!1}};var N={exports:{}},b={};/**
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"),require("@univerjs/sheets"),require("@univerjs/sheets-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/ui","rxjs","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.UniverSheets,c.UniverSheetsUi))})(this,function(c,o,p,H,_,R,w,P){"use strict";var be=Object.defineProperty;var Oe=(c,o,p)=>o in c?be(c,o,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[o]=p;var u=(c,o,p)=>Oe(c,typeof o!="symbol"?o+"":o,p);var T;const J="sheets-crosshair-highlight.config",A={};var d=function(){return d=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},d.apply(this,arguments)},X=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t},L=R.forwardRef(function(r,e){var t=r.icon,n=r.id,i=r.className,s=r.extend,a=X(r,["icon","id","className","extend"]),h="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),l=R.useRef("_".concat(Q()));return U(t,"".concat(n),{defIds:t.defIds,idSuffix:l.current},d({ref:e,className:h},a),s)});function U(r,e,t,n,i){return R.createElement(r.tag,d(d({key:e},K(r,t,i)),n),(z(r,t).children||[]).map(function(s,a){return U(s,"".concat(e,"-").concat(r.tag,"-").concat(a),t,void 0,i)}))}function K(r,e,t){var n=d({},r.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1);var i=e.defIds;return!i||i.length===0||(r.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],h=s[1];typeof h=="string"&&(n[a]=h.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function z(r,e){var t,n=e.defIds;return!n||n.length===0?r:r.tag==="defs"&&(!((t=r.children)===null||t===void 0)&&t.length)?d(d({},r),{children:r.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?d(d({},i),{attrs:d(d({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):r}function Q(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var ee={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#E5E5E5",d:"M1.6499 3.65002C1.6499 2.54545 2.54533 1.65002 3.6499 1.65002H12.3499C13.4545 1.65002 14.3499 2.54545 14.3499 3.65002V12.35C14.3499 13.4546 13.4545 14.35 12.3499 14.35H3.6499C2.54533 14.35 1.6499 13.4546 1.6499 12.35V3.65002Z"}},{tag:"path",attrs:{fill:"#fff",d:"M9.9998 1.65002H5.9998V6H1.6499V10H5.9998V14.35H9.9998V10H14.3499V6H9.9998V1.65002Z"}},{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=R.forwardRef(function(r,e){return R.createElement(L,Object.assign({},r,{id:"cross-highlighting-single",ref:e,icon:ee}))});G.displayName="CrossHighlightingSingle";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 S extends o.Disposable{constructor(){super(...arguments);u(this,"_enabled$",new _.BehaviorSubject(!1));u(this,"enabled$",this._enabled$.asObservable());u(this,"_color$",new _.BehaviorSubject(M[0]));u(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:o.CommandType.OPERATION,handler(r){const e=r.get(S),t=e.enabled;return e.setEnabled(!t),!0}},j={id:"sheet.operation.set-crosshair-highlight-color",type:o.CommandType.OPERATION,handler(r,{value:e}){const t=r.get(S);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},D={id:"sheet.operation.enable-crosshair-highlight",type:o.CommandType.OPERATION,handler(r){const e=r.get(S);return e.enabled?!1:(e.setEnabled(!0),!0)}},Y={id:"sheet.operation.disable-crosshair-highlight",type:o.CommandType.OPERATION,handler(r){const e=r.get(S);return e.enabled?(e.setEnabled(!1),!0):!1}};var N={exports:{}},b={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var k;function te(){if(k)return b;k=1;var r=R,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(l,h,C){var g,S={},m=null,f=null;C!==void 0&&(m=""+C),h.key!==void 0&&(m=""+h.key),h.ref!==void 0&&(f=h.ref);for(g in h)n.call(h,g)&&!s.hasOwnProperty(g)&&(S[g]=h[g]);if(l&&l.defaultProps)for(g in h=l.defaultProps,h)S[g]===void 0&&(S[g]=h[g]);return{$$typeof:e,type:l,key:m,ref:f,props:S,_owner:i.current}}return b.Fragment=t,b.jsx=a,b.jsxs=a,b}var B;function ne(){return B||(B=1,N.exports=te()),N.exports}var Z=ne();function F(r){var e,t,n="";if(typeof r=="string"||typeof r=="number")n+=r;else if(typeof r=="object")if(Array.isArray(r)){var i=r.length;for(e=0;e<i;e++)r[e]&&(t=F(r[e]))&&(n&&(n+=" "),n+=t)}else for(t in r)r[t]&&(n&&(n+=" "),n+=t);return n}function re(){for(var r,e,t=0,n="",i=arguments.length;t<i;t++)(r=arguments[t])&&(e=F(r))&&(n&&(n+=" "),n+=e);return n}const x={crosshairHighlightOverlay:"univer-crosshair-highlight-overlay",crosshairHighlightItem:"univer-crosshair-highlight-item",crosshairHighlightItemSelected:"univer-crosshair-highlight-item-selected"};function ie(r){const{onChange:e}=r,t=o.useDependency(p),n=o.useObservable(t.color$),i=R.useCallback(s=>{e==null||e(s)},[e]);return Z.jsx("div",{className:x.crosshairHighlightOverlay,children:M.map(s=>Z.jsx("div",{className:re(x.crosshairHighlightItem,{[x.crosshairHighlightItemSelected]:s===n}),style:{backgroundColor:s},onClick:()=>i(s)},s))})}const W="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function se(r){const e=r.get(p);return{id:I.id,tooltip:"crosshair.button.tooltip",type:H.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:W,hoverable:!1}}],selectionsCommandId:j.id,activated$:e.enabled$,hidden$:H.getMenuHiddenObservable(r,o.UniverInstanceType.UNIVER_SHEET)}}const oe={[H.ContextMenuPosition.FOOTER_MENU]:{[H.ContextMenuGroup.OTHERS]:{[I.id]:{order:0,menuItemFactory:se}}}};var ae=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,le=(r,e,t,n)=>{for(var i=n>1?void 0:n?ce(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(e,t,i):a(i))||i);return n&&i&&ae(e,t,i),i},$=(r,e)=>(t,n)=>e(t,n,r);let y=class extends o.Disposable{constructor(r,e,t){super(),this._componentMgr=r,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[I,j,D,Y].forEach(r=>this._cmdSrv.registerCommand(r))}_initMenus(){this._menuManagerService.mergeMenu(oe)}_initComponents(){this._componentMgr.register(W,ie),this._componentMgr.register("CrossHighlightingSingle",G)}};y=le([$(0,o.Inject(H.ComponentManager)),$(1,H.IMenuManagerService),$(2,o.ICommandService)],y);const he=1;class ge{constructor(){u(this,"_selectedRanges",[]);u(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 i of t.concat(this._selectedRanges)){const s=[];for(const a of n){const l=o.Rectangle.subtract(a,i);l&&l.length>0&&s.push(...l)}n=s}return n.filter(i=>i.startRow<=i.endRow&&i.startColumn<=i.endColumn)}_getIntersects(e){const t=[];for(const n of this._ranges){const i=o.Rectangle.getIntersects(n,e);i&&t.push(i)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class ue extends v.Shape{constructor(t,n){super(t,n);u(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){const n=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${this._color.a})`;v.Rect.drawWith(t,{width:this.width,height:this.height,fill:n,stroke:void 0,strokeWidth:0,evented:!1})}}var de=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,_e=(r,e,t,n)=>{for(var i=n>1?void 0:n?fe(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(e,t,i):a(i))||i);return n&&i&&de(e,t,i),i},O=(r,e)=>(t,n)=>e(t,n,r);let E=class extends o.Disposable{constructor(e,t,n,i,s,a){super();u(this,"_shapes",[]);u(this,"_rangeCollection",new ge);u(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=n,this._sheetsCrosshairHighlightService=i,this._contextService=s,this._refSelectionsService=a,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const n=t.getRowCount(),i=t.getColumnCount(),s=[];for(const a of e){const{startRow:l,endRow:h,startColumn:C,endColumn:g}=a.range;h-l+1===n||g-C+1===i||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(_.combineLatest([this._contextService.subscribeContextValue$(w.REF_SELECTIONS_ENABLED).pipe(_.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(_.tap(t=>this._color=t)),_.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(_.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),_.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(_.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,n,i,s,a,l])=>{if(this._clear(),!i)return;const h=t?l:a;this._rangeCollection.reset(),this._transformSelection(h,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(),i=t.getColumnCount(),{startRow:s,endRow:a,startColumn:l,endColumn:h}=e,C={startRow:s,endRow:a,startColumn:0,endColumn:l-1},g={startRow:s,endRow:a,startColumn:h+1,endColumn:i},S={startRow:0,endRow:s-1,startColumn:l,endColumn:h},m={startRow:a+1,endRow:n,startColumn:l,endColumn:h};for(const f of[C,g,S,m])f.startRow<=f.endRow&&f.startColumn<=f.endColumn&&this._rangeCollection.addRange(f)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,n,i){const{startRow:s,endRow:a,startColumn:l,endColumn:h}=e,C=P.getCoordByCell(s,l,n,i),g=P.getCoordByCell(a,h,n,i),{startX:S,startY:m}=C,{endX:f,endY:Ce}=g,me=f-S,Re=Ce-m,He={left:S,top:m,color:new o.ColorKit(this._color).toRgb(),width:me,height:Re,zIndex:he,evented:!1},q=new ue(`crosshair-${t}`,He);this._shapes.push(q),n.addObject(q)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:n}=this._context;this._clear();for(let i=0;i<e.length;i++){const s=e[i];this._addShapes(s,i,n,t)}n.makeDirty(!0)}async dispose(){super.dispose()}};E=_e([O(1,o.Inject(P.SheetSkeletonManagerService)),O(2,o.Inject(w.SheetsSelectionsService)),O(3,o.Inject(p)),O(4,o.Inject(o.IContextService)),O(5,w.IRefSelectionsService)],E);var Se=Object.defineProperty,ve=Object.getOwnPropertyDescriptor,pe=(r,e,t,n)=>{for(var i=n>1?void 0:n?ve(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(e,t,i):a(i))||i);return n&&i&&Se(e,t,i),i},V=(r,e)=>(t,n)=>e(t,n,r);c.UniverSheetsCrosshairHighlightPlugin=(T=class extends o.Plugin{constructor(e=A,t,n,i){super(),this._config=e,this._injector=t,this._renderManagerService=n,this._configService=i;const{...s}=o.merge({},A,this._config);this._configService.setConfig(J,s)}onStarting(){[[p],[y]].forEach(e=>this._injector.add(e))}onReady(){[[E]].forEach(e=>this._injector.add(e)),this._injector.get(y),this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[E])}},u(T,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),u(T,"type",o.UniverInstanceType.UNIVER_SHEET),T),c.UniverSheetsCrosshairHighlightPlugin=pe([V(1,o.Inject(o.Injector)),V(2,v.IRenderManagerService),V(3,o.IConfigService)],c.UniverSheetsCrosshairHighlightPlugin),c.CROSSHAIR_HIGHLIGHT_COLORS=M,c.DisableCrosshairHighlightOperation=Y,c.EnableCrosshairHighlightOperation=D,c.SetCrosshairHighlightColorOperation=j,c.ToggleCrosshairHighlightOperation=I,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
9
+ */var k;function te(){if(k)return b;k=1;var r=R,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(h,l,C){var g,v={},m=null,f=null;C!==void 0&&(m=""+C),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(f=l.ref);for(g in l)n.call(l,g)&&!s.hasOwnProperty(g)&&(v[g]=l[g]);if(h&&h.defaultProps)for(g in l=h.defaultProps,l)v[g]===void 0&&(v[g]=l[g]);return{$$typeof:e,type:h,key:m,ref:f,props:v,_owner:i.current}}return b.Fragment=t,b.jsx=a,b.jsxs=a,b}var B;function ne(){return B||(B=1,N.exports=te()),N.exports}var Z=ne();function F(r){var e,t,n="";if(typeof r=="string"||typeof r=="number")n+=r;else if(typeof r=="object")if(Array.isArray(r)){var i=r.length;for(e=0;e<i;e++)r[e]&&(t=F(r[e]))&&(n&&(n+=" "),n+=t)}else for(t in r)r[t]&&(n&&(n+=" "),n+=t);return n}function re(){for(var r,e,t=0,n="",i=arguments.length;t<i;t++)(r=arguments[t])&&(e=F(r))&&(n&&(n+=" "),n+=e);return n}const x={crosshairHighlightOverlay:"univer-crosshair-highlight-overlay",crosshairHighlightItem:"univer-crosshair-highlight-item",crosshairHighlightItemSelected:"univer-crosshair-highlight-item-selected"};function ie(r){const{onChange:e}=r,t=o.useDependency(S),n=o.useObservable(t.color$),i=R.useCallback(s=>{e==null||e(s)},[e]);return Z.jsx("div",{className:x.crosshairHighlightOverlay,children:M.map(s=>Z.jsx("div",{className:re(x.crosshairHighlightItem,{[x.crosshairHighlightItemSelected]:s===n}),style:{backgroundColor:s},onClick:()=>i(s)},s))})}const W="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function se(r){const e=r.get(S);return{id:I.id,tooltip:"crosshair.button.tooltip",type:H.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:W,hoverable:!1}}],selectionsCommandId:j.id,activated$:e.enabled$,hidden$:H.getMenuHiddenObservable(r,o.UniverInstanceType.UNIVER_SHEET)}}const oe={[H.ContextMenuPosition.FOOTER_MENU]:{[H.ContextMenuGroup.OTHERS]:{[I.id]:{order:0,menuItemFactory:se}}}};var ae=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,he=(r,e,t,n)=>{for(var i=n>1?void 0:n?ce(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(e,t,i):a(i))||i);return n&&i&&ae(e,t,i),i},$=(r,e)=>(t,n)=>e(t,n,r);let y=class extends o.Disposable{constructor(r,e,t){super(),this._componentMgr=r,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[I,j,D,Y].forEach(r=>this._cmdSrv.registerCommand(r))}_initMenus(){this._menuManagerService.mergeMenu(oe)}_initComponents(){this._componentMgr.register(W,ie),this._componentMgr.register("CrossHighlightingSingle",G)}};y=he([$(0,o.Inject(H.ComponentManager)),$(1,H.IMenuManagerService),$(2,o.ICommandService)],y);const le=1;class ge{constructor(){u(this,"_selectedRanges",[]);u(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 i of t.concat(this._selectedRanges)){const s=[];for(const a of n){const h=o.Rectangle.subtract(a,i);h&&h.length>0&&s.push(...h)}n=s}return n.filter(i=>i.startRow<=i.endRow&&i.startColumn<=i.endColumn)}_getIntersects(e){const t=[];for(const n of this._ranges){const i=o.Rectangle.getIntersects(n,e);i&&t.push(i)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class ue extends p.Shape{constructor(t,n){super(t,n);u(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){const n=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${this._color.a})`;p.Rect.drawWith(t,{width:this.width,height:this.height,fill:n,stroke:void 0,strokeWidth:0,evented:!1})}}var de=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,_e=(r,e,t,n)=>{for(var i=n>1?void 0:n?fe(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(e,t,i):a(i))||i);return n&&i&&de(e,t,i),i},O=(r,e)=>(t,n)=>e(t,n,r);let E=class extends o.Disposable{constructor(e,t,n,i,s,a){super();u(this,"_shapes",[]);u(this,"_rangeCollection",new ge);u(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=n,this._sheetsCrosshairHighlightService=i,this._contextService=s,this._refSelectionsService=a,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const n=t.getRowCount(),i=t.getColumnCount(),s=[];for(const a of e){const{startRow:h,endRow:l,startColumn:C,endColumn:g}=a.range;l-h+1===n||g-C+1===i||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(_.combineLatest([this._contextService.subscribeContextValue$(w.REF_SELECTIONS_ENABLED).pipe(_.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(_.tap(t=>this._color=t)),_.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(_.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),_.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(_.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,n,i,s,a,h])=>{if(this._clear(),!i)return;const l=t?h:a;this._rangeCollection.reset(),this._transformSelection(l,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(),i=t.getColumnCount(),{startRow:s,endRow:a,startColumn:h,endColumn:l}=e,C={startRow:s,endRow:a,startColumn:0,endColumn:h-1},g={startRow:s,endRow:a,startColumn:l+1,endColumn:i},v={startRow:0,endRow:s-1,startColumn:h,endColumn:l},m={startRow:a+1,endRow:n,startColumn:h,endColumn:l};for(const f of[C,g,v,m])f.startRow<=f.endRow&&f.startColumn<=f.endColumn&&this._rangeCollection.addRange(f)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,n,i){const{startRow:s,endRow:a,startColumn:h,endColumn:l}=e,C=P.getCoordByCell(s,h,n,i),g=P.getCoordByCell(a,l,n,i),{startX:v,startY:m}=C,{endX:f,endY:Ce}=g,me=f-v,Re=Ce-m,He={left:v,top:m,color:new o.ColorKit(this._color).toRgb(),width:me,height:Re,zIndex:le,evented:!1},q=new ue(`crosshair-${t}`,He);this._shapes.push(q),n.addObject(q)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:n}=this._context;this._clear();for(let i=0;i<e.length;i++){const s=e[i];this._addShapes(s,i,n,t)}n.makeDirty(!0)}async dispose(){super.dispose()}};E=_e([O(1,o.Inject(P.SheetSkeletonManagerService)),O(2,o.Inject(w.SheetsSelectionsService)),O(3,o.Inject(S)),O(4,o.Inject(o.IContextService)),O(5,w.IRefSelectionsService)],E);var Se=Object.defineProperty,ve=Object.getOwnPropertyDescriptor,pe=(r,e,t,n)=>{for(var i=n>1?void 0:n?ve(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(e,t,i):a(i))||i);return n&&i&&Se(e,t,i),i},V=(r,e)=>(t,n)=>e(t,n,r);c.UniverSheetsCrosshairHighlightPlugin=(T=class extends o.Plugin{constructor(e=A,t,n,i){super(),this._config=e,this._injector=t,this._renderManagerService=n,this._configService=i;const{...s}=o.merge({},A,this._config);this._configService.setConfig(J,s)}onStarting(){[[S],[y]].forEach(e=>this._injector.add(e))}onReady(){[[E]].forEach(e=>this._injector.add(e)),this._injector.get(y),this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[E])}},u(T,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),u(T,"type",o.UniverInstanceType.UNIVER_SHEET),T),c.UniverSheetsCrosshairHighlightPlugin=pe([V(1,o.Inject(o.Injector)),V(2,p.IRenderManagerService),V(3,o.IConfigService)],c.UniverSheetsCrosshairHighlightPlugin),c.CROSSHAIR_HIGHLIGHT_COLORS=M,c.DisableCrosshairHighlightOperation=Y,c.EnableCrosshairHighlightOperation=D,c.SetCrosshairHighlightColorOperation=j,c.SheetsCrosshairHighlightService=S,c.ToggleCrosshairHighlightOperation=I,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.5.4-nightly.202501150735",
3
+ "version": "0.5.4-nightly.202501151252",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -59,11 +59,11 @@
59
59
  "dependencies": {
60
60
  "@univerjs/icons": "^0.2.12",
61
61
  "clsx": "^2.1.1",
62
- "@univerjs/core": "0.5.4-nightly.202501150735",
63
- "@univerjs/engine-render": "0.5.4-nightly.202501150735",
64
- "@univerjs/ui": "0.5.4-nightly.202501150735",
65
- "@univerjs/sheets": "0.5.4-nightly.202501150735",
66
- "@univerjs/sheets-ui": "0.5.4-nightly.202501150735"
62
+ "@univerjs/core": "0.5.4-nightly.202501151252",
63
+ "@univerjs/engine-render": "0.5.4-nightly.202501151252",
64
+ "@univerjs/sheets-ui": "0.5.4-nightly.202501151252",
65
+ "@univerjs/ui": "0.5.4-nightly.202501151252",
66
+ "@univerjs/sheets": "0.5.4-nightly.202501151252"
67
67
  },
68
68
  "devDependencies": {
69
69
  "less": "^4.2.1",