@univerjs/sheets-crosshair-highlight 0.15.3 → 0.15.4
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 +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/locale/sk-SK.js +1 -0
- package/lib/es/facade.js +31 -27
- package/lib/es/index.js +1 -1
- package/lib/es/locale/sk-SK.js +10 -0
- package/lib/facade.js +31 -27
- package/lib/index.js +1 -1
- package/lib/locale/sk-SK.js +10 -0
- package/lib/types/locale/sk-SK.d.ts +3 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -0
- package/package.json +9 -9
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const o=require("@univerjs/core"),
|
|
1
|
+
"use strict";const o=require("@univerjs/core"),r=require("@univerjs/core/facade"),i=require("@univerjs/sheets-crosshair-highlight");class a{get CrosshairHighlightEnabledChanged(){return"CrosshairHighlightEnabledChanged"}get CrosshairHighlightColorChanged(){return"CrosshairHighlightColorChanged"}}class n extends r.FUniver{_initialize(e){const s=e.get(o.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.CrosshairHighlightEnabledChanged,()=>s.onCommandExecuted(t=>{if(t.id===i.EnableCrosshairHighlightOperation.id||t.id===i.DisableCrosshairHighlightOperation.id||t.id===i.ToggleCrosshairHighlightOperation.id){const h=this.getActiveSheet();if(!h)return;this.fireEvent(this.Event.CrosshairHighlightEnabledChanged,{enabled:this.getCrosshairHighlightEnabled(),...h})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.CrosshairHighlightColorChanged,()=>s.onCommandExecuted(t=>{if(t.id===i.SetCrosshairHighlightColorOperation.id){const h=this.getActiveSheet();if(!h)return;this.fireEvent(this.Event.CrosshairHighlightColorChanged,{color:this.getCrosshairHighlightColor(),...h})}})))}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}}r.FEventName.extend(a);r.FUniver.extend(n);
|
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Z=Object.defineProperty;var W=(i,e,t)=>e in i?Z(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var l=(i,e,t)=>W(i,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),g=require("rxjs"),$=require("@univerjs/engine-render"),v=require("react"),d=require("@univerjs/ui"),N=require("react/jsx-runtime"),P=require("@univerjs/design"),T=require("@univerjs/sheets"),w=require("@univerjs/sheets-ui"),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 u extends a.Disposable{constructor(){super(...arguments);l(this,"_enabled$",new g.BehaviorSubject(!1));l(this,"enabled$",this._enabled$.asObservable());l(this,"_color$",new g.BehaviorSubject(y[0]));l(this,"color$",this._color$.asObservable())}get enabled(){return this._enabled$.getValue()}get color(){return this._color$.getValue()}dispose(){this._enabled$.complete()}setEnabled(t){this._enabled$.next(t)}setColor(t){this._color$.next(t)}}const I={id:"sheet.operation.toggle-crosshair-highlight",type:a.CommandType.OPERATION,handler(i){const e=i.get(u),t=e.enabled;return e.setEnabled(!t),!0}},M={id:"sheet.operation.set-crosshair-highlight-color",type:a.CommandType.OPERATION,handler(i,{value:e}){const t=i.get(u);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},A={id:"sheet.operation.enable-crosshair-highlight",type:a.CommandType.OPERATION,handler(i){const e=i.get(u);return e.enabled?!1:(e.setEnabled(!0),!0)}},L={id:"sheet.operation.disable-crosshair-highlight",type:a.CommandType.OPERATION,handler(i){const e=i.get(u);return e.enabled?(e.setEnabled(!1),!0):!1}},F="sheets-crosshair-highlight.config",j={};function G({ref:i,...e}){const{icon:t,id:r,className:s,extend:n,...o}=e,c=`univerjs-icon univerjs-icon-${r} ${s||""}`.trim(),h=v.useRef(`_${K()}`);return V(t,`${r}`,{defIds:t.defIds,idSuffix:h.current},{ref:i,className:c,...o},n)}function V(i,e,t,r,s){return v.createElement(i.tag,{key:e,...X(i,t,s),...r},(z(i,t).children||[]).map((n,o)=>V(n,`${e}-${i.tag}-${o}`,t,void 0,s)))}function X(i,e,t){const r={...i.attrs};t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),i.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(([n,o])=>{n==="mask"&&typeof o=="string"&&(r[n]=o.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:s}=e;return!s||s.length===0||(i.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(([n,o])=>{typeof o=="string"&&(r[n]=o.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),r}function z(i,e){var r;const{defIds:t}=e;return!t||t.length===0?i:i.tag==="defs"&&((r=i.children)!=null&&r.length)?{...i,children:i.children.map(s=>typeof s.attrs.id=="string"&&t&&t.includes(s.attrs.id)?{...s,attrs:{...s.attrs,id:s.attrs.id+e.idSuffix}}:s)}:i}function K(){return Math.random().toString(36).substring(2,8)}G.displayName="UniverIcon";const J={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z",fillRule:"evenodd",clipRule:"evenodd"}}]},U=v.forwardRef(function(e,t){return v.createElement(G,Object.assign({},e,{id:"cross-highlighting-icon",ref:t,icon:J}))});U.displayName="CrossHighlightingIcon";function Q(i){const{onChange:e}=i,t=d.useDependency(u),r=d.useObservable(t.color$),s=v.useCallback(n=>{e==null||e(n)},[e]);return N.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3",children:y.map(n=>N.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":n===r}),style:{backgroundColor:n},onClick:()=>s(n)},n))})}const k="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function ee(i){const e=i.get(u);return{id:I.id,tooltip:"crosshair.button.tooltip",type:d.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingIcon",selections:[{label:{name:k,hoverable:!1,selectable:!1}}],selectionsCommandId:M.id,activated$:e.enabled$,hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}const te={[d.ContextMenuPosition.FOOTER_MENU]:{[d.ContextMenuGroup.OTHERS]:{[I.id]:{order:0,menuItemFactory:ee}}}};var re=Object.getOwnPropertyDescriptor,se=(i,e,t,r)=>{for(var s=r>1?void 0:r?re(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=o(s)||s);return s},E=(i,e)=>(t,r)=>e(t,r,i);let b=class extends a.Disposable{constructor(i,e,t){super(),this._componentMgr=i,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[I,M,A,L].forEach(i=>this._cmdSrv.registerCommand(i))}_initMenus(){this._menuManagerService.mergeMenu(te)}_initComponents(){this._componentMgr.register(k,Q),this._componentMgr.register("CrossHighlightingIcon",U)}};b=se([E(0,a.Inject(d.ComponentManager)),E(1,d.IMenuManagerService),E(2,a.ICommandService)],b);const ie=1;class ne{constructor(){l(this,"_selectedRanges",[]);l(this,"_ranges",[])}addRange(e){if(e.rangeType===a.RANGE_TYPE.COLUMN||e.rangeType===a.RANGE_TYPE.ROW||e.rangeType===a.RANGE_TYPE.ALL)return;const t=this._getIntersects(e),r=this._getSplitRanges(e,t);r.length>0&&this._ranges.push(...r)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,t){let r=[e];for(const s of t.concat(this._selectedRanges)){const n=[];for(const o of r){const c=a.Rectangle.subtract(o,s);c&&c.length>0&&n.push(...c)}r=n}return r.filter(s=>s.startRow<=s.endRow&&s.startColumn<=s.endColumn)}_getIntersects(e){const t=[];for(const r of this._ranges){const s=a.Rectangle.getIntersects(r,e);s&&t.push(s)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class oe extends $.Shape{constructor(t,r){super(t,r);l(this,"_color");r&&this.setShapeProps(r)}setShapeProps(t){typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){var s,n;const r=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(n=(s=this._color)==null?void 0:s.a)!=null?n:.5})`;$.Rect.drawWith(t,{width:this.width,height:this.height,fill:r,stroke:void 0,strokeWidth:0,evented:!1})}}var ae=Object.getOwnPropertyDescriptor,ce=(i,e,t,r)=>{for(var s=r>1?void 0:r?ae(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=o(s)||s);return s},C=(i,e)=>(t,r)=>e(t,r,i);let H=class extends a.Disposable{constructor(e,t,r,s,n,o){super();l(this,"_shapes",[]);l(this,"_rangeCollection",new ne);l(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=r,this._sheetsCrosshairHighlightService=s,this._contextService=n,this._refSelectionsService=o,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const r=t.getRowCount(),s=t.getColumnCount(),n=[];for(const o of e){const{startRow:c,endRow:h,startColumn:S,endColumn:f}=o.range;h-c+1===r||f-S+1===s||n.push(o.range)}this._rangeCollection.setSelectedRanges(n);for(const o of n)this.addSelection(o,t)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(g.combineLatest([this._contextService.subscribeContextValue$(T.REF_SELECTIONS_ENABLED).pipe(g.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(g.tap(t=>this._color=t)),g.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(g.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),g.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(g.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,r,s,n,o,c])=>{if(this._clear(),!s)return;const h=t?c:o;this._rangeCollection.reset(),this._transformSelection(h,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(),s=t.getColumnCount(),{startRow:n,endRow:o,startColumn:c,endColumn:h}=e,S={startRow:n,endRow:o,startColumn:0,endColumn:c-1},f={startRow:n,endRow:o,startColumn:h+1,endColumn:s},p={startRow:0,endRow:n-1,startColumn:c,endColumn:h},m={startRow:o+1,endRow:r,startColumn:c,endColumn:h};for(const _ of[S,f,p,m])_.startRow<=_.endRow&&_.startColumn<=_.endColumn&&this._rangeCollection.addRange(_)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,r,s){const{startRow:n,endRow:o,startColumn:c,endColumn:h}=e,S=w.getCoordByCell(n,c,r,s),f=w.getCoordByCell(o,h,r,s),{startX:p,startY:m}=S,{endX:_,endY:D}=f,Y=_-p,q=D-m,B={left:p,top:m,color:new a.ColorKit(this._color).toRgb(),width:Y,height:q,zIndex:ie,evented:!1},x=new oe(`crosshair-${t}`,B);this._shapes.push(x),r.addObject(x)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:r}=this._context;this._clear();for(let s=0;s<e.length;s++){const n=e[s];this._addShapes(n,s,r,t)}r.makeDirty(!0)}async dispose(){super.dispose()}};H=ce([C(1,a.Inject(w.SheetSkeletonManagerService)),C(2,a.Inject(T.SheetsSelectionsService)),C(3,a.Inject(u)),C(4,a.Inject(a.IContextService)),C(5,T.IRefSelectionsService)],H);var le=Object.getOwnPropertyDescriptor,he=(i,e,t,r)=>{for(var s=r>1?void 0:r?le(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=o(s)||s);return s},O=(i,e)=>(t,r)=>e(t,r,i),R;exports.UniverSheetsCrosshairHighlightPlugin=(R=class extends a.Plugin{constructor(e=j,t,r,s){super(),this._config=e,this._injector=t,this._renderManagerService=r,this._configService=s;const{...n}=a.merge({},j,this._config);this._configService.setConfig(F,n)}onStarting(){[[u],[b]].forEach(e=>this._injector.add(e))}onReady(){[[H]].forEach(e=>this._injector.add(e)),this._injector.get(b),this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,[H])}},l(R,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),l(R,"type",a.UniverInstanceType.UNIVER_SHEET),R);exports.UniverSheetsCrosshairHighlightPlugin=he([O(1,a.Inject(a.Injector)),O(2,$.IRenderManagerService),O(3,a.IConfigService)],exports.UniverSheetsCrosshairHighlightPlugin);exports.CROSSHAIR_HIGHLIGHT_COLORS=y;exports.DisableCrosshairHighlightOperation=L;exports.EnableCrosshairHighlightOperation=A;exports.SetCrosshairHighlightColorOperation=M;exports.SheetsCrosshairHighlightService=u;exports.ToggleCrosshairHighlightOperation=I;
|
|
1
|
+
"use strict";var Z=Object.defineProperty;var W=(i,e,t)=>e in i?Z(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var l=(i,e,t)=>W(i,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),g=require("rxjs"),$=require("@univerjs/engine-render"),v=require("react"),d=require("@univerjs/ui"),N=require("react/jsx-runtime"),P=require("@univerjs/design"),T=require("@univerjs/sheets"),w=require("@univerjs/sheets-ui"),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 u extends a.Disposable{constructor(){super(...arguments);l(this,"_enabled$",new g.BehaviorSubject(!1));l(this,"enabled$",this._enabled$.asObservable());l(this,"_color$",new g.BehaviorSubject(y[0]));l(this,"color$",this._color$.asObservable())}get enabled(){return this._enabled$.getValue()}get color(){return this._color$.getValue()}dispose(){this._enabled$.complete()}setEnabled(t){this._enabled$.next(t)}setColor(t){this._color$.next(t)}}const I={id:"sheet.operation.toggle-crosshair-highlight",type:a.CommandType.OPERATION,handler(i){const e=i.get(u),t=e.enabled;return e.setEnabled(!t),!0}},M={id:"sheet.operation.set-crosshair-highlight-color",type:a.CommandType.OPERATION,handler(i,{value:e}){const t=i.get(u);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},A={id:"sheet.operation.enable-crosshair-highlight",type:a.CommandType.OPERATION,handler(i){const e=i.get(u);return e.enabled?!1:(e.setEnabled(!0),!0)}},L={id:"sheet.operation.disable-crosshair-highlight",type:a.CommandType.OPERATION,handler(i){const e=i.get(u);return e.enabled?(e.setEnabled(!1),!0):!1}},F="sheets-crosshair-highlight.config",j={};function G({ref:i,...e}){const{icon:t,id:r,className:s,extend:n,...o}=e,c=`univerjs-icon univerjs-icon-${r} ${s||""}`.trim(),h=v.useRef(`_${K()}`);return V(t,`${r}`,{defIds:t.defIds,idSuffix:h.current},{ref:i,className:c,...o},n)}function V(i,e,t,r,s){return v.createElement(i.tag,{key:e,...X(i,t,s),...r},(z(i,t).children||[]).map((n,o)=>V(n,`${e}-${i.tag}-${o}`,t,void 0,s)))}function X(i,e,t){const r={...i.attrs};t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),i.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(([n,o])=>{n==="mask"&&typeof o=="string"&&(r[n]=o.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:s}=e;return!s||s.length===0||(i.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(([n,o])=>{typeof o=="string"&&(r[n]=o.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),r}function z(i,e){var r;const{defIds:t}=e;return!t||t.length===0?i:i.tag==="defs"&&((r=i.children)!=null&&r.length)?{...i,children:i.children.map(s=>typeof s.attrs.id=="string"&&t&&t.includes(s.attrs.id)?{...s,attrs:{...s.attrs,id:s.attrs.id+e.idSuffix}}:s)}:i}function K(){return Math.random().toString(36).substring(2,8)}G.displayName="UniverIcon";const J={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z",fillRule:"evenodd",clipRule:"evenodd"}}]},U=v.forwardRef(function(e,t){return v.createElement(G,Object.assign({},e,{id:"cross-highlighting-icon",ref:t,icon:J}))});U.displayName="CrossHighlightingIcon";function Q(i){const{onChange:e}=i,t=d.useDependency(u),r=d.useObservable(t.color$),s=v.useCallback(n=>{e==null||e(n)},[e]);return N.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3",children:y.map(n=>N.jsx("div",{className:P.clsx("hover:univer-ring-primary-600/40 univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1 univer-transition-shadow hover:univer-ring-[1.5px]",P.borderClassName,{"univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600":n===r}),style:{backgroundColor:n},onClick:()=>s(n)},n))})}const k="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function ee(i){const e=i.get(u);return{id:I.id,tooltip:"crosshair.button.tooltip",type:d.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingIcon",selections:[{label:{name:k,hoverable:!1,selectable:!1}}],selectionsCommandId:M.id,activated$:e.enabled$,hidden$:d.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}const te={[d.ContextMenuPosition.FOOTER_MENU]:{[d.ContextMenuGroup.OTHERS]:{[I.id]:{order:0,menuItemFactory:ee}}}};var re=Object.getOwnPropertyDescriptor,se=(i,e,t,r)=>{for(var s=r>1?void 0:r?re(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=o(s)||s);return s},E=(i,e)=>(t,r)=>e(t,r,i);let b=class extends a.Disposable{constructor(i,e,t){super(),this._componentMgr=i,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[I,M,A,L].forEach(i=>this._cmdSrv.registerCommand(i))}_initMenus(){this._menuManagerService.mergeMenu(te)}_initComponents(){this._componentMgr.register(k,Q),this._componentMgr.register("CrossHighlightingIcon",U)}};b=se([E(0,a.Inject(d.ComponentManager)),E(1,d.IMenuManagerService),E(2,a.ICommandService)],b);const ie=1;class ne{constructor(){l(this,"_selectedRanges",[]);l(this,"_ranges",[])}addRange(e){if(e.rangeType===a.RANGE_TYPE.COLUMN||e.rangeType===a.RANGE_TYPE.ROW||e.rangeType===a.RANGE_TYPE.ALL)return;const t=this._getIntersects(e),r=this._getSplitRanges(e,t);r.length>0&&this._ranges.push(...r)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,t){let r=[e];for(const s of t.concat(this._selectedRanges)){const n=[];for(const o of r){const c=a.Rectangle.subtract(o,s);c&&c.length>0&&n.push(...c)}r=n}return r.filter(s=>s.startRow<=s.endRow&&s.startColumn<=s.endColumn)}_getIntersects(e){const t=[];for(const r of this._ranges){const s=a.Rectangle.getIntersects(r,e);s&&t.push(s)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class oe extends $.Shape{constructor(t,r){super(t,r);l(this,"_color");r&&this.setShapeProps(r)}setShapeProps(t){typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){var s,n;const r=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(n=(s=this._color)==null?void 0:s.a)!=null?n:.5})`;$.Rect.drawWith(t,{width:this.width,height:this.height,fill:r,stroke:void 0,strokeWidth:0,evented:!1})}}var ae=Object.getOwnPropertyDescriptor,ce=(i,e,t,r)=>{for(var s=r>1?void 0:r?ae(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=o(s)||s);return s},C=(i,e)=>(t,r)=>e(t,r,i);let H=class extends a.Disposable{constructor(e,t,r,s,n,o){super();l(this,"_shapes",[]);l(this,"_rangeCollection",new ne);l(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=r,this._sheetsCrosshairHighlightService=s,this._contextService=n,this._refSelectionsService=o,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const r=t.getRowCount(),s=t.getColumnCount(),n=[];for(const o of e){const{startRow:c,endRow:h,startColumn:S,endColumn:f}=o.range;h-c+1===r||f-S+1===s||n.push(o.range)}this._rangeCollection.setSelectedRanges(n);for(const o of n)this.addSelection(o,t)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(g.combineLatest([this._contextService.subscribeContextValue$(T.REF_SELECTIONS_ENABLED).pipe(g.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(g.tap(t=>this._color=t)),g.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(g.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),g.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(g.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,r,s,n,o,c])=>{if(this._clear(),!s)return;const h=t?c:o;this._rangeCollection.reset(),this._transformSelection(h,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(),s=t.getColumnCount(),{startRow:n,endRow:o,startColumn:c,endColumn:h}=e,S={startRow:n,endRow:o,startColumn:0,endColumn:c-1},f={startRow:n,endRow:o,startColumn:h+1,endColumn:s},p={startRow:0,endRow:n-1,startColumn:c,endColumn:h},m={startRow:o+1,endRow:r,startColumn:c,endColumn:h};for(const _ of[S,f,p,m])_.startRow<=_.endRow&&_.startColumn<=_.endColumn&&this._rangeCollection.addRange(_)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,r,s){const{startRow:n,endRow:o,startColumn:c,endColumn:h}=e,S=w.getCoordByCell(n,c,r,s),f=w.getCoordByCell(o,h,r,s),{startX:p,startY:m}=S,{endX:_,endY:D}=f,Y=_-p,q=D-m,B={left:p,top:m,color:new a.ColorKit(this._color).toRgb(),width:Y,height:q,zIndex:ie,evented:!1},x=new oe(`crosshair-${t}`,B);this._shapes.push(x),r.addObject(x)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:r}=this._context;this._clear();for(let s=0;s<e.length;s++){const n=e[s];this._addShapes(n,s,r,t)}r.makeDirty(!0)}async dispose(){super.dispose()}};H=ce([C(1,a.Inject(w.SheetSkeletonManagerService)),C(2,a.Inject(T.SheetsSelectionsService)),C(3,a.Inject(u)),C(4,a.Inject(a.IContextService)),C(5,T.IRefSelectionsService)],H);var le=Object.getOwnPropertyDescriptor,he=(i,e,t,r)=>{for(var s=r>1?void 0:r?le(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=o(s)||s);return s},O=(i,e)=>(t,r)=>e(t,r,i),R;exports.UniverSheetsCrosshairHighlightPlugin=(R=class extends a.Plugin{constructor(e=j,t,r,s){super(),this._config=e,this._injector=t,this._renderManagerService=r,this._configService=s;const{...n}=a.merge({},j,this._config);this._configService.setConfig(F,n)}onStarting(){[[u],[b]].forEach(e=>this._injector.add(e))}onReady(){[[H]].forEach(e=>this._injector.add(e)),this._injector.get(b),this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,[H])}},l(R,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),l(R,"type",a.UniverInstanceType.UNIVER_SHEET),R);exports.UniverSheetsCrosshairHighlightPlugin=he([O(1,a.Inject(a.Injector)),O(2,$.IRenderManagerService),O(3,a.IConfigService)],exports.UniverSheetsCrosshairHighlightPlugin);exports.CROSSHAIR_HIGHLIGHT_COLORS=y;exports.DisableCrosshairHighlightOperation=L;exports.EnableCrosshairHighlightOperation=A;exports.SetCrosshairHighlightColorOperation=M;exports.SheetsCrosshairHighlightService=u;exports.ToggleCrosshairHighlightOperation=I;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t={crosshair:{button:{tooltip:"Zvýraznenie krížika"}}};module.exports=t;
|
package/lib/es/facade.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ICommandService as l } from "@univerjs/core";
|
|
2
2
|
import { FEventName as C, FUniver as n } from "@univerjs/core/facade";
|
|
3
|
-
import { EnableCrosshairHighlightOperation as
|
|
3
|
+
import { EnableCrosshairHighlightOperation as r, DisableCrosshairHighlightOperation as s, ToggleCrosshairHighlightOperation as d, SetCrosshairHighlightColorOperation as g, SheetsCrosshairHighlightService as o, CROSSHAIR_HIGHLIGHT_COLORS as c } from "@univerjs/sheets-crosshair-highlight";
|
|
4
4
|
class H {
|
|
5
5
|
get CrosshairHighlightEnabledChanged() {
|
|
6
6
|
return "CrosshairHighlightEnabledChanged";
|
|
@@ -14,35 +14,39 @@ class v extends n {
|
|
|
14
14
|
* @ignore
|
|
15
15
|
*/
|
|
16
16
|
_initialize(i) {
|
|
17
|
-
const
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
17
|
+
const h = i.get(l);
|
|
18
|
+
this.disposeWithMe(
|
|
19
|
+
this.registerEventHandler(
|
|
20
|
+
this.Event.CrosshairHighlightEnabledChanged,
|
|
21
|
+
() => h.onCommandExecuted((e) => {
|
|
22
|
+
if (e.id === r.id || e.id === s.id || e.id === d.id) {
|
|
23
|
+
const t = this.getActiveSheet();
|
|
24
|
+
if (!t) return;
|
|
25
|
+
this.fireEvent(this.Event.CrosshairHighlightEnabledChanged, {
|
|
26
|
+
enabled: this.getCrosshairHighlightEnabled(),
|
|
27
|
+
...t
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
)
|
|
32
|
+
), this.disposeWithMe(
|
|
33
|
+
this.registerEventHandler(
|
|
34
|
+
this.Event.CrosshairHighlightColorChanged,
|
|
35
|
+
() => h.onCommandExecuted((e) => {
|
|
36
|
+
if (e.id === g.id) {
|
|
37
|
+
const t = this.getActiveSheet();
|
|
38
|
+
if (!t) return;
|
|
39
|
+
this.fireEvent(this.Event.CrosshairHighlightColorChanged, {
|
|
40
|
+
color: this.getCrosshairHighlightColor(),
|
|
41
|
+
...t
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
)
|
|
42
46
|
);
|
|
43
47
|
}
|
|
44
48
|
setCrosshairHighlightEnabled(i) {
|
|
45
|
-
return i ? this._commandService.syncExecuteCommand(
|
|
49
|
+
return i ? this._commandService.syncExecuteCommand(r.id) : this._commandService.syncExecuteCommand(s.id), this;
|
|
46
50
|
}
|
|
47
51
|
setCrosshairHighlightColor(i) {
|
|
48
52
|
return this._commandService.syncExecuteCommand(g.id, {
|
package/lib/es/index.js
CHANGED
|
@@ -160,7 +160,7 @@ function Ne(s) {
|
|
|
160
160
|
return /* @__PURE__ */ N("div", { className: "univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3", children: j.map((n) => /* @__PURE__ */ N(
|
|
161
161
|
"div",
|
|
162
162
|
{
|
|
163
|
-
className: me("hover:univer-ring-primary-600/40
|
|
163
|
+
className: me("hover:univer-ring-primary-600/40 univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1 univer-transition-shadow hover:univer-ring-[1.5px]", Re, {
|
|
164
164
|
"univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600": n === r
|
|
165
165
|
}),
|
|
166
166
|
style: { backgroundColor: n },
|
package/lib/facade.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ICommandService as l } from "@univerjs/core";
|
|
2
2
|
import { FEventName as C, FUniver as n } from "@univerjs/core/facade";
|
|
3
|
-
import { EnableCrosshairHighlightOperation as
|
|
3
|
+
import { EnableCrosshairHighlightOperation as r, DisableCrosshairHighlightOperation as s, ToggleCrosshairHighlightOperation as d, SetCrosshairHighlightColorOperation as g, SheetsCrosshairHighlightService as o, CROSSHAIR_HIGHLIGHT_COLORS as c } from "@univerjs/sheets-crosshair-highlight";
|
|
4
4
|
class H {
|
|
5
5
|
get CrosshairHighlightEnabledChanged() {
|
|
6
6
|
return "CrosshairHighlightEnabledChanged";
|
|
@@ -14,35 +14,39 @@ class v extends n {
|
|
|
14
14
|
* @ignore
|
|
15
15
|
*/
|
|
16
16
|
_initialize(i) {
|
|
17
|
-
const
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
17
|
+
const h = i.get(l);
|
|
18
|
+
this.disposeWithMe(
|
|
19
|
+
this.registerEventHandler(
|
|
20
|
+
this.Event.CrosshairHighlightEnabledChanged,
|
|
21
|
+
() => h.onCommandExecuted((e) => {
|
|
22
|
+
if (e.id === r.id || e.id === s.id || e.id === d.id) {
|
|
23
|
+
const t = this.getActiveSheet();
|
|
24
|
+
if (!t) return;
|
|
25
|
+
this.fireEvent(this.Event.CrosshairHighlightEnabledChanged, {
|
|
26
|
+
enabled: this.getCrosshairHighlightEnabled(),
|
|
27
|
+
...t
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
)
|
|
32
|
+
), this.disposeWithMe(
|
|
33
|
+
this.registerEventHandler(
|
|
34
|
+
this.Event.CrosshairHighlightColorChanged,
|
|
35
|
+
() => h.onCommandExecuted((e) => {
|
|
36
|
+
if (e.id === g.id) {
|
|
37
|
+
const t = this.getActiveSheet();
|
|
38
|
+
if (!t) return;
|
|
39
|
+
this.fireEvent(this.Event.CrosshairHighlightColorChanged, {
|
|
40
|
+
color: this.getCrosshairHighlightColor(),
|
|
41
|
+
...t
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
)
|
|
42
46
|
);
|
|
43
47
|
}
|
|
44
48
|
setCrosshairHighlightEnabled(i) {
|
|
45
|
-
return i ? this._commandService.syncExecuteCommand(
|
|
49
|
+
return i ? this._commandService.syncExecuteCommand(r.id) : this._commandService.syncExecuteCommand(s.id), this;
|
|
46
50
|
}
|
|
47
51
|
setCrosshairHighlightColor(i) {
|
|
48
52
|
return this._commandService.syncExecuteCommand(g.id, {
|
package/lib/index.js
CHANGED
|
@@ -160,7 +160,7 @@ function Ne(s) {
|
|
|
160
160
|
return /* @__PURE__ */ N("div", { className: "univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3", children: j.map((n) => /* @__PURE__ */ N(
|
|
161
161
|
"div",
|
|
162
162
|
{
|
|
163
|
-
className: me("hover:univer-ring-primary-600/40
|
|
163
|
+
className: me("hover:univer-ring-primary-600/40 univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1 univer-transition-shadow hover:univer-ring-[1.5px]", Re, {
|
|
164
164
|
"univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600": n === r
|
|
165
165
|
}),
|
|
166
166
|
style: { backgroundColor: n },
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(e,r){typeof exports=="object"&&typeof module<"u"?r(require("@univerjs/core"),require("@univerjs/core/facade"),require("@univerjs/sheets-crosshair-highlight")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/core/facade","@univerjs/sheets-crosshair-highlight"],r):(e=typeof globalThis<"u"?globalThis:e||self,r(e.UniverCore,e.UniverCoreFacade,e.UniverSheetsCrosshairHighlight))})(this,(function(e,r,i){"use strict";class o{get CrosshairHighlightEnabledChanged(){return"CrosshairHighlightEnabledChanged"}get CrosshairHighlightColorChanged(){return"CrosshairHighlightColorChanged"}}class g extends r.FUniver{_initialize(t){const s=t.get(e.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.CrosshairHighlightEnabledChanged,()=>s.onCommandExecuted(h=>{if(h.id===i.EnableCrosshairHighlightOperation.id||h.id===i.DisableCrosshairHighlightOperation.id||h.id===i.ToggleCrosshairHighlightOperation.id){const n=this.getActiveSheet();if(!n)return;this.fireEvent(this.Event.CrosshairHighlightEnabledChanged,{enabled:this.getCrosshairHighlightEnabled(),...n})}}))),this.disposeWithMe(this.registerEventHandler(this.Event.CrosshairHighlightColorChanged,()=>s.onCommandExecuted(h=>{if(h.id===i.SetCrosshairHighlightColorOperation.id){const n=this.getActiveSheet();if(!n)return;this.fireEvent(this.Event.CrosshairHighlightColorChanged,{color:this.getCrosshairHighlightColor(),...n})}})))}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}}r.FEventName.extend(o),r.FUniver.extend(g)}));
|
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("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"})}));
|
|
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 univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1 univer-transition-shadow hover:univer-ring-[1.5px]",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"})}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsCrosshairHighlightSkSK=i())})(this,(function(){"use strict";return{crosshair:{button:{tooltip:"Zvýraznenie krížika"}}}}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-crosshair-highlight",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -63,12 +63,12 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@univerjs/icons": "^1.1.1",
|
|
66
|
-
"@univerjs/
|
|
67
|
-
"@univerjs/
|
|
68
|
-
"@univerjs/engine-render": "0.15.
|
|
69
|
-
"@univerjs/sheets": "0.15.
|
|
70
|
-
"@univerjs/sheets-ui": "0.15.
|
|
71
|
-
"@univerjs/ui": "0.15.
|
|
66
|
+
"@univerjs/design": "0.15.4",
|
|
67
|
+
"@univerjs/core": "0.15.4",
|
|
68
|
+
"@univerjs/engine-render": "0.15.4",
|
|
69
|
+
"@univerjs/sheets": "0.15.4",
|
|
70
|
+
"@univerjs/sheets-ui": "0.15.4",
|
|
71
|
+
"@univerjs/ui": "0.15.4"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"postcss": "^8.5.6",
|
|
@@ -77,8 +77,8 @@
|
|
|
77
77
|
"tailwindcss": "3.4.18",
|
|
78
78
|
"typescript": "^5.9.3",
|
|
79
79
|
"vite": "^7.3.1",
|
|
80
|
-
"vitest": "^4.0.
|
|
81
|
-
"@univerjs-infra/shared": "0.15.
|
|
80
|
+
"vitest": "^4.0.18",
|
|
81
|
+
"@univerjs-infra/shared": "0.15.4"
|
|
82
82
|
},
|
|
83
83
|
"scripts": {
|
|
84
84
|
"test": "vitest run",
|