@univerjs/sheets-crosshair-highlight 0.10.12-nightly.202510221114 → 0.10.12-nightly.202510251119
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +221 -203
- package/lib/index.js +221 -203
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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("hover:univer-ring-primary-600/40 hover:univer-ring-[1.5px] univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1 univer-transition-shadow",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"})}));
|
|
1
|
+
(function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("rxjs"),require("@univerjs/engine-render"),require("react"),require("@univerjs/ui"),require("react/jsx-runtime"),require("@univerjs/design"),require("@univerjs/sheets"),require("@univerjs/sheets-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs","@univerjs/engine-render","react","@univerjs/ui","react/jsx-runtime","@univerjs/design","@univerjs/sheets","@univerjs/sheets-ui"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverSheetsCrosshairHighlight={},c.UniverCore,c.rxjs,c.UniverEngineRender,c.React,c.UniverUi,c.React,c.UniverDesign,c.UniverSheets,c.UniverSheetsUi))})(this,(function(c,o,l,O,f,_,j,P,$,T){"use strict";var le=Object.defineProperty;var ge=(c,o,l)=>o in c?le(c,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):c[o]=l;var g=(c,o,l)=>ge(c,typeof o!="symbol"?o+"":o,l);var b;const y=["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 o.Disposable{constructor(){super(...arguments);g(this,"_enabled$",new l.BehaviorSubject(!1));g(this,"enabled$",this._enabled$.asObservable());g(this,"_color$",new l.BehaviorSubject(y[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 m={id:"sheet.operation.toggle-crosshair-highlight",type:o.CommandType.OPERATION,handler(s){const e=s.get(d),t=e.enabled;return e.setEnabled(!t),!0}},w={id:"sheet.operation.set-crosshair-highlight-color",type:o.CommandType.OPERATION,handler(s,{value:e}){const t=s.get(d);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},A={id:"sheet.operation.enable-crosshair-highlight",type:o.CommandType.OPERATION,handler(s){const e=s.get(d);return e.enabled?!1:(e.setEnabled(!0),!0)}},L={id:"sheet.operation.disable-crosshair-highlight",type:o.CommandType.OPERATION,handler(s){const e=s.get(d);return e.enabled?(e.setEnabled(!1),!0):!1}},Y="sheets-crosshair-highlight.config",U={};function x({ref:s,...e}){const{icon:t,id:i,className:n,extend:r,...a}=e,h=`univerjs-icon univerjs-icon-${i} ${n||""}`.trim(),u=f.useRef(`_${Z()}`);return G(t,`${i}`,{defIds:t.defIds,idSuffix:u.current},{ref:s,className:h,...a},r)}function G(s,e,t,i,n){return f.createElement(s.tag,{key:e,...q(s,t,n),...i},(B(s,t).children||[]).map((r,a)=>G(r,`${e}-${s.tag}-${a}`,t,void 0,n)))}function q(s,e,t){const i={...s.attrs};t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1),s.tag==="mask"&&i.id&&(i.id=i.id+e.idSuffix),Object.entries(i).forEach(([r,a])=>{r==="mask"&&typeof a=="string"&&(i[r]=a.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:n}=e;return!n||n.length===0||(s.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(([r,a])=>{typeof a=="string"&&(i[r]=a.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),i}function B(s,e){var i;const{defIds:t}=e;return!t||t.length===0?s:s.tag==="defs"&&((i=s.children)!=null&&i.length)?{...s,children:s.children.map(n=>typeof n.attrs.id=="string"&&t&&t.includes(n.attrs.id)?{...n,attrs:{...n.attrs,id:n.attrs.id+e.idSuffix}}:n)}:s}function Z(){return Math.random().toString(36).substring(2,8)}x.displayName="UniverIcon";const W={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=f.forwardRef(function(e,t){return f.createElement(x,Object.assign({},e,{id:"cross-highlighting-icon",ref:t,icon:W}))});V.displayName="CrossHighlightingIcon";function F(s){const{onChange:e}=s,t=_.useDependency(d),i=_.useObservable(t.color$),n=f.useCallback(r=>{e==null||e(r)},[e]);return j.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3",children:y.map(r=>j.jsx("div",{className:P.clsx("hover:univer-ring-primary-600/40 hover:univer-ring-[1.5px] univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1 univer-transition-shadow",P.borderClassName,{"univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600":r===i}),style:{backgroundColor:r},onClick:()=>n(r)},r))})}const k="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function X(s){const e=s.get(d);return{id:m.id,tooltip:"crosshair.button.tooltip",type:_.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingIcon",selections:[{label:{name:k,hoverable:!1,selectable:!1}}],selectionsCommandId:w.id,activated$:e.enabled$,hidden$:_.getMenuHiddenObservable(s,o.UniverInstanceType.UNIVER_SHEET)}}const z={[_.ContextMenuPosition.FOOTER_MENU]:{[_.ContextMenuGroup.OTHERS]:{[m.id]:{order:0,menuItemFactory:X}}}};var K=Object.getOwnPropertyDescriptor,J=(s,e,t,i)=>{for(var n=i>1?void 0:i?K(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=a(n)||n);return n},M=(s,e)=>(t,i)=>e(t,i,s);let R=class extends o.Disposable{constructor(s,e,t){super(),this._componentMgr=s,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[m,w,A,L].forEach(s=>this._cmdSrv.registerCommand(s))}_initMenus(){this._menuManagerService.mergeMenu(z)}_initComponents(){this._componentMgr.register(k,F),this._componentMgr.register("CrossHighlightingIcon",V)}};R=J([M(0,o.Inject(_.ComponentManager)),M(1,_.IMenuManagerService),M(2,o.ICommandService)],R);const Q=1;class ee{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),i=this._getSplitRanges(e,t);i.length>0&&this._ranges.push(...i)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,t){let i=[e];for(const n of t.concat(this._selectedRanges)){const r=[];for(const a of i){const h=o.Rectangle.subtract(a,n);h&&h.length>0&&r.push(...h)}i=r}return i.filter(n=>n.startRow<=n.endRow&&n.startColumn<=n.endColumn)}_getIntersects(e){const t=[];for(const i of this._ranges){const n=o.Rectangle.getIntersects(i,e);n&&t.push(n)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class te extends O.Shape{constructor(t,i){super(t,i);g(this,"_color");i&&this.setShapeProps(i)}setShapeProps(t){typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){var n,r;const i=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(r=(n=this._color)==null?void 0:n.a)!=null?r:.5})`;O.Rect.drawWith(t,{width:this.width,height:this.height,fill:i,stroke:void 0,strokeWidth:0,evented:!1})}}var ie=Object.getOwnPropertyDescriptor,ne=(s,e,t,i)=>{for(var n=i>1?void 0:i?ie(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=a(n)||n);return n},v=(s,e)=>(t,i)=>e(t,i,s);let H=class extends o.Disposable{constructor(e,t,i,n,r,a){super();g(this,"_shapes",[]);g(this,"_rangeCollection",new ee);g(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=i,this._sheetsCrosshairHighlightService=n,this._contextService=r,this._refSelectionsService=a,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const i=t.getRowCount(),n=t.getColumnCount(),r=[];for(const a of e){const{startRow:h,endRow:u,startColumn:C,endColumn:p}=a.range;u-h+1===i||p-C+1===n||r.push(a.range)}this._rangeCollection.setSelectedRanges(r);for(const a of r)this.addSelection(a,t)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(l.combineLatest([this._contextService.subscribeContextValue$($.REF_SELECTIONS_ENABLED).pipe(l.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(l.tap(t=>this._color=t)),l.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(l.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),l.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(l.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,i,n,r,a,h])=>{if(this._clear(),!n)return;const u=t?h: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 i=t.getRowCount(),n=t.getColumnCount(),{startRow:r,endRow:a,startColumn:h,endColumn:u}=e,C={startRow:r,endRow:a,startColumn:0,endColumn:h-1},p={startRow:r,endRow:a,startColumn:u+1,endColumn:n},I={startRow:0,endRow:r-1,startColumn:h,endColumn:u},E={startRow:a+1,endRow:i,startColumn:h,endColumn:u};for(const S of[C,p,I,E])S.startRow<=S.endRow&&S.startColumn<=S.endColumn&&this._rangeCollection.addRange(S)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,i,n){const{startRow:r,endRow:a,startColumn:h,endColumn:u}=e,C=T.getCoordByCell(r,h,i,n),p=T.getCoordByCell(a,u,i,n),{startX:I,startY:E}=C,{endX:S,endY:oe}=p,ae=S-I,ce=oe-E,he={left:I,top:E,color:new o.ColorKit(this._color).toRgb(),width:ae,height:ce,zIndex:Q,evented:!1},D=new te(`crosshair-${t}`,he);this._shapes.push(D),i.addObject(D)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:i}=this._context;this._clear();for(let n=0;n<e.length;n++){const r=e[n];this._addShapes(r,n,i,t)}i.makeDirty(!0)}async dispose(){super.dispose()}};H=ne([v(1,o.Inject(T.SheetSkeletonManagerService)),v(2,o.Inject($.SheetsSelectionsService)),v(3,o.Inject(d)),v(4,o.Inject(o.IContextService)),v(5,$.IRefSelectionsService)],H);var se=Object.getOwnPropertyDescriptor,re=(s,e,t,i)=>{for(var n=i>1?void 0:i?se(e,t):e,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=a(n)||n);return n},N=(s,e)=>(t,i)=>e(t,i,s);c.UniverSheetsCrosshairHighlightPlugin=(b=class extends o.Plugin{constructor(e=U,t,i,n){super(),this._config=e,this._injector=t,this._renderManagerService=i,this._configService=n;const{...r}=o.merge({},U,this._config);this._configService.setConfig(Y,r)}onStarting(){[[d],[R]].forEach(e=>this._injector.add(e))}onReady(){[[H]].forEach(e=>this._injector.add(e)),this._injector.get(R),this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[H])}},g(b,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),g(b,"type",o.UniverInstanceType.UNIVER_SHEET),b),c.UniverSheetsCrosshairHighlightPlugin=re([N(1,o.Inject(o.Injector)),N(2,O.IRenderManagerService),N(3,o.IConfigService)],c.UniverSheetsCrosshairHighlightPlugin),c.CROSSHAIR_HIGHLIGHT_COLORS=y,c.DisableCrosshairHighlightOperation=L,c.EnableCrosshairHighlightOperation=A,c.SetCrosshairHighlightColorOperation=w,c.SheetsCrosshairHighlightService=d,c.ToggleCrosshairHighlightOperation=m,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.10.12-nightly.
|
|
3
|
+
"version": "0.10.12-nightly.202510251119",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"rxjs": ">=7.0.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@univerjs/icons": "^0.
|
|
66
|
-
"@univerjs/core": "0.10.12-nightly.
|
|
67
|
-
"@univerjs/design": "0.10.12-nightly.
|
|
68
|
-
"@univerjs/
|
|
69
|
-
"@univerjs/
|
|
70
|
-
"@univerjs/
|
|
71
|
-
"@univerjs/ui": "0.10.12-nightly.
|
|
65
|
+
"@univerjs/icons": "^1.0.2",
|
|
66
|
+
"@univerjs/core": "0.10.12-nightly.202510251119",
|
|
67
|
+
"@univerjs/design": "0.10.12-nightly.202510251119",
|
|
68
|
+
"@univerjs/engine-render": "0.10.12-nightly.202510251119",
|
|
69
|
+
"@univerjs/sheets": "0.10.12-nightly.202510251119",
|
|
70
|
+
"@univerjs/ui": "0.10.12-nightly.202510251119",
|
|
71
|
+
"@univerjs/sheets-ui": "0.10.12-nightly.202510251119"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"postcss": "^8.5.6",
|