@univerjs/sheets-crosshair-highlight 0.6.4 → 0.6.5
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 +5 -1
- package/lib/es/index.js +193 -192
- package/lib/index.css +1 -1
- package/lib/umd/index.js +5 -1
- package/package.json +12 -13
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
"use strict";var W=Object.defineProperty;var F=(i,e,t)=>e in i?W(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var l=(i,e,t)=>F(i,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),w=require("@univerjs/engine-render"),f=require("@univerjs/ui"),d=require("rxjs"),j=require("react/jsx-runtime"),X=require("@univerjs/design"),S=require("react"),M=require("@univerjs/sheets"),$=require("@univerjs/sheets-ui"),K="sheets-crosshair-highlight.config",V={};var h=function(){return h=Object.assign||function(i){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=e[s])}return i},h.apply(this,arguments)},z=function(i,e){var t={};for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(i);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(i,r[s])&&(t[r[s]]=i[r[s]]);return t},A=S.forwardRef(function(i,e){var t=i.icon,r=i.id,s=i.className,n=i.extend,o=z(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(r," ").concat(s||"").trim(),g=S.useRef("_".concat(ee()));return L(t,"".concat(r),{defIds:t.defIds,idSuffix:g.current},h({ref:e,className:c},o),n)});function L(i,e,t,r,s){return S.createElement(i.tag,h(h({key:e},J(i,t,s)),r),(Q(i,t).children||[]).map(function(n,o){return L(n,"".concat(e,"-").concat(i.tag,"-").concat(o),t,void 0,s)}))}function J(i,e,t){var r=h({},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(function(n){var o=n[0],c=n[1];o==="mask"&&typeof c=="string"&&(r[o]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var s=e.defIds;return!s||s.length===0||(i.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(n){var o=n[0],c=n[1];typeof c=="string"&&(r[o]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Q(i,e){var t,r=e.defIds;return!r||r.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?h(h({},i),{children:i.children.map(function(s){return typeof s.attrs.id=="string"&&r&&r.indexOf(s.attrs.id)>-1?h(h({},s),{attrs:h(h({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):i}function ee(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var te={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=S.forwardRef(function(i,e){return S.createElement(A,Object.assign({},i,{id:"cross-highlighting-single",ref:e,icon:te}))});G.displayName="CrossHighlightingSingle";const x=["rgba(158, 109, 227, 0.3)","rgba(254, 75, 75, 0.3)","rgba(255, 140, 81, 0.3)","rgba(164, 220, 22, 0.3)","rgba(45, 174, 255, 0.3)","rgba(58, 96, 247, 0.3)","rgba(242, 72, 166, 0.3)","rgba(153, 153, 153, 0.3)","rgba(158, 109, 227, 0.15)","rgba(254, 75, 75, 0.15)","rgba(255, 140, 81, 0.15)","rgba(164, 220, 22, 0.15)","rgba(45, 174, 255, 0.15)","rgba(58, 96, 247, 0.15)","rgba(242, 72, 166, 0.15)","rgba(153, 153, 153, 0.15)"];class u extends a.Disposable{constructor(){super(...arguments);l(this,"_enabled$",new d.BehaviorSubject(!1));l(this,"enabled$",this._enabled$.asObservable());l(this,"_color$",new d.BehaviorSubject(x[0]));l(this,"color$",this._color$.asObservable())}get enabled(){return this._enabled$.getValue()}get color(){return this._color$.getValue()}dispose(){this._enabled$.complete()}setEnabled(t){this._enabled$.next(t)}setColor(t){this._color$.next(t)}}const I={id:"sheet.operation.toggle-crosshair-highlight",type:a.CommandType.OPERATION,handler(i){const e=i.get(u),t=e.enabled;return e.setEnabled(!t),!0}},N={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}},k={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)}},U={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}},re="univer-crosshair-highlight-overlay",ie="univer-crosshair-highlight-item",se="univer-crosshair-highlight-item-selected",E={crosshairHighlightOverlay:re,crosshairHighlightItem:ie,crosshairHighlightItemSelected:se};function ne(i){const{onChange:e}=i,t=f.useDependency(u),r=f.useObservable(t.color$),s=S.useCallback(n=>{e==null||e(n)},[e]);return j.jsx("div",{className:E.crosshairHighlightOverlay,children:x.map(n=>j.jsx("div",{className:X.clsx(E.crosshairHighlightItem,{[E.crosshairHighlightItemSelected]:n===r}),style:{backgroundColor:n},onClick:()=>s(n)},n))})}const D="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function oe(i){const e=i.get(u);return{id:I.id,tooltip:"crosshair.button.tooltip",type:f.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:D,hoverable:!1}}],selectionsCommandId:N.id,activated$:e.enabled$,hidden$:f.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}const ae={[f.ContextMenuPosition.FOOTER_MENU]:{[f.ContextMenuGroup.OTHERS]:{[I.id]:{order:0,menuItemFactory:oe}}}};var ce=Object.getOwnPropertyDescriptor,le=(i,e,t,r)=>{for(var s=r>1?void 0:r?ce(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=o(s)||s);return s},y=(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,N,k,U].forEach(i=>this._cmdSrv.registerCommand(i))}_initMenus(){this._menuManagerService.mergeMenu(ae)}_initComponents(){this._componentMgr.register(D,ne),this._componentMgr.register("CrossHighlightingSingle",G)}};b=le([y(0,a.Inject(f.ComponentManager)),y(1,f.IMenuManagerService),y(2,a.ICommandService)],b);const he=1;class ge{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 de extends w.Shape{constructor(t,r){super(t,r);l(this,"_color");r&&this.setShapeProps(r)}setShapeProps(t){typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){var 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})`;w.Rect.drawWith(t,{width:this.width,height:this.height,fill:r,stroke:void 0,strokeWidth:0,evented:!1})}}var ue=Object.getOwnPropertyDescriptor,fe=(i,e,t,r)=>{for(var s=r>1?void 0:r?ue(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=o(s)||s);return s},p=(i,e)=>(t,r)=>e(t,r,i);let O=class extends a.Disposable{constructor(e,t,r,s,n,o){super();l(this,"_shapes",[]);l(this,"_rangeCollection",new ge);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:g,startColumn:v,endColumn:C}=o.range;g-c+1===r||C-v+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(d.combineLatest([this._contextService.subscribeContextValue$(M.REF_SELECTIONS_ENABLED).pipe(d.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(d.tap(t=>this._color=t)),d.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(d.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),d.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(d.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,r,s,n,o,c])=>{if(this._clear(),!s)return;const g=t?c:o;this._rangeCollection.reset(),this._transformSelection(g,e.getActiveSheet()),this.render(this._rangeCollection.getRanges())}))}addSelection(e,t){if(e.rangeType===a.RANGE_TYPE.COLUMN||e.rangeType===a.RANGE_TYPE.ROW||e.rangeType===a.RANGE_TYPE.ALL)return;const r=t.getRowCount(),s=t.getColumnCount(),{startRow:n,endRow:o,startColumn:c,endColumn:g}=e,v={startRow:n,endRow:o,startColumn:0,endColumn:c-1},C={startRow:n,endRow:o,startColumn:g+1,endColumn:s},m={startRow:0,endRow:n-1,startColumn:c,endColumn:g},H={startRow:o+1,endRow:r,startColumn:c,endColumn:g};for(const _ of[v,C,m,H])_.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:g}=e,v=$.getCoordByCell(n,c,r,s),C=$.getCoordByCell(o,g,r,s),{startX:m,startY:H}=v,{endX:_,endY:Y}=C,q=_-m,B=Y-H,Z={left:m,top:H,color:new a.ColorKit(this._color).toRgb(),width:q,height:B,zIndex:he,evented:!1},P=new de(`crosshair-${t}`,Z);this._shapes.push(P),r.addObject(P)}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()}};O=fe([p(1,a.Inject($.SheetSkeletonManagerService)),p(2,a.Inject(M.SheetsSelectionsService)),p(3,a.Inject(u)),p(4,a.Inject(a.IContextService)),p(5,M.IRefSelectionsService)],O);var _e=Object.getOwnPropertyDescriptor,Se=(i,e,t,r)=>{for(var s=r>1?void 0:r?_e(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=o(s)||s);return s},T=(i,e)=>(t,r)=>e(t,r,i),R;exports.UniverSheetsCrosshairHighlightPlugin=(R=class extends a.Plugin{constructor(e=V,t,r,s){super(),this._config=e,this._injector=t,this._renderManagerService=r,this._configService=s;const{...n}=a.merge({},V,this._config);this._configService.setConfig(K,n)}onStarting(){[[u],[b]].forEach(e=>this._injector.add(e))}onReady(){[[O]].forEach(e=>this._injector.add(e)),this._injector.get(b),this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,[O])}},l(R,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),l(R,"type",a.UniverInstanceType.UNIVER_SHEET),R);exports.UniverSheetsCrosshairHighlightPlugin=Se([T(1,a.Inject(a.Injector)),T(2,w.IRenderManagerService),T(3,a.IConfigService)],exports.UniverSheetsCrosshairHighlightPlugin);exports.CROSSHAIR_HIGHLIGHT_COLORS=x;exports.DisableCrosshairHighlightOperation=U;exports.EnableCrosshairHighlightOperation=k;exports.SetCrosshairHighlightColorOperation=N;exports.SheetsCrosshairHighlightService=u;exports.ToggleCrosshairHighlightOperation=I;
|
|
1
|
+
"use strict";var Z=Object.defineProperty;var W=(n,e,t)=>e in n?Z(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var l=(n,e,t)=>W(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),T=require("@univerjs/engine-render"),f=require("@univerjs/ui"),u=require("rxjs"),P=require("react/jsx-runtime"),F=require("@univerjs/design"),S=require("react"),w=require("@univerjs/sheets"),M=require("@univerjs/sheets-ui"),X="sheets-crosshair-highlight.config",j={};var h=function(){return h=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},h.apply(this,arguments)},z=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},V=S.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,s=n.extend,o=z(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),g=S.useRef("_".concat(Q()));return A(t,"".concat(r),{defIds:t.defIds,idSuffix:g.current},h({ref:e,className:c},o),s)});function A(n,e,t,r,i){return S.createElement(n.tag,h(h({key:e},K(n,t,i)),r),(J(n,t).children||[]).map(function(s,o){return A(s,"".concat(e,"-").concat(n.tag,"-").concat(o),t,void 0,i)}))}function K(n,e,t){var r=h({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(s){var o=s[0],c=s[1];o==="mask"&&typeof c=="string"&&(r[o]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(s){var o=s[0],c=s[1];typeof c=="string"&&(r[o]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function J(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?h(h({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?h(h({},i),{attrs:h(h({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function Q(){return Math.random().toString(36).substring(2,8)}V.displayName="UniverIcon";var ee={tag:"svg",attrs:{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"}}]},L=S.forwardRef(function(n,e){return S.createElement(V,Object.assign({},n,{id:"cross-highlighting-single",ref:e,icon:ee}))});L.displayName="CrossHighlightingSingle";const x=["rgba(158, 109, 227, 0.3)","rgba(254, 75, 75, 0.3)","rgba(255, 140, 81, 0.3)","rgba(164, 220, 22, 0.3)","rgba(45, 174, 255, 0.3)","rgba(58, 96, 247, 0.3)","rgba(242, 72, 166, 0.3)","rgba(153, 153, 153, 0.3)","rgba(158, 109, 227, 0.15)","rgba(254, 75, 75, 0.15)","rgba(255, 140, 81, 0.15)","rgba(164, 220, 22, 0.15)","rgba(45, 174, 255, 0.15)","rgba(58, 96, 247, 0.15)","rgba(242, 72, 166, 0.15)","rgba(153, 153, 153, 0.15)"];class d extends a.Disposable{constructor(){super(...arguments);l(this,"_enabled$",new u.BehaviorSubject(!1));l(this,"enabled$",this._enabled$.asObservable());l(this,"_color$",new u.BehaviorSubject(x[0]));l(this,"color$",this._color$.asObservable())}get enabled(){return this._enabled$.getValue()}get color(){return this._color$.getValue()}dispose(){this._enabled$.complete()}setEnabled(t){this._enabled$.next(t)}setColor(t){this._color$.next(t)}}const I={id:"sheet.operation.toggle-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(d),t=e.enabled;return e.setEnabled(!t),!0}},$={id:"sheet.operation.set-crosshair-highlight-color",type:a.CommandType.OPERATION,handler(n,{value:e}){const t=n.get(d);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},G={id:"sheet.operation.enable-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(d);return e.enabled?!1:(e.setEnabled(!0),!0)}},k={id:"sheet.operation.disable-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(d);return e.enabled?(e.setEnabled(!1),!0):!1}};function te(n){const{onChange:e}=n,t=f.useDependency(d),r=f.useObservable(t.color$),i=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:x.map(s=>P.jsx("div",{className:F.clsx(`
|
|
2
|
+
univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-border
|
|
3
|
+
univer-border-solid univer-border-gray-200 univer-ring-offset-1 univer-transition-shadow
|
|
4
|
+
hover:univer-ring-[1.5px] hover:univer-ring-primary-600/40
|
|
5
|
+
`,{"univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600":s===r}),style:{backgroundColor:s},onClick:()=>i(s)},s))})}const U="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function re(n){const e=n.get(d);return{id:I.id,tooltip:"crosshair.button.tooltip",type:f.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:U,hoverable:!1,selectable:!1}}],selectionsCommandId:$.id,activated$:e.enabled$,hidden$:f.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const ne={[f.ContextMenuPosition.FOOTER_MENU]:{[f.ContextMenuGroup.OTHERS]:{[I.id]:{order:0,menuItemFactory:re}}}};var ie=Object.getOwnPropertyDescriptor,se=(n,e,t,r)=>{for(var i=r>1?void 0:r?ie(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(i)||i);return i},E=(n,e)=>(t,r)=>e(t,r,n);let H=class extends a.Disposable{constructor(n,e,t){super(),this._componentMgr=n,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[I,$,G,k].forEach(n=>this._cmdSrv.registerCommand(n))}_initMenus(){this._menuManagerService.mergeMenu(ne)}_initComponents(){this._componentMgr.register(U,te),this._componentMgr.register("CrossHighlightingSingle",L)}};H=se([E(0,a.Inject(f.ComponentManager)),E(1,f.IMenuManagerService),E(2,a.ICommandService)],H);const oe=1;class ae{constructor(){l(this,"_selectedRanges",[]);l(this,"_ranges",[])}addRange(e){if(e.rangeType===a.RANGE_TYPE.COLUMN||e.rangeType===a.RANGE_TYPE.ROW||e.rangeType===a.RANGE_TYPE.ALL)return;const t=this._getIntersects(e),r=this._getSplitRanges(e,t);r.length>0&&this._ranges.push(...r)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,t){let r=[e];for(const i of t.concat(this._selectedRanges)){const s=[];for(const o of r){const c=a.Rectangle.subtract(o,i);c&&c.length>0&&s.push(...c)}r=s}return r.filter(i=>i.startRow<=i.endRow&&i.startColumn<=i.endColumn)}_getIntersects(e){const t=[];for(const r of this._ranges){const i=a.Rectangle.getIntersects(r,e);i&&t.push(i)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class ce extends T.Shape{constructor(t,r){super(t,r);l(this,"_color");r&&this.setShapeProps(r)}setShapeProps(t){typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){var i,s;const r=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(s=(i=this._color)==null?void 0:i.a)!=null?s:.5})`;T.Rect.drawWith(t,{width:this.width,height:this.height,fill:r,stroke:void 0,strokeWidth:0,evented:!1})}}var le=Object.getOwnPropertyDescriptor,he=(n,e,t,r)=>{for(var i=r>1?void 0:r?le(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(i)||i);return i},p=(n,e)=>(t,r)=>e(t,r,n);let O=class extends a.Disposable{constructor(e,t,r,i,s,o){super();l(this,"_shapes",[]);l(this,"_rangeCollection",new ae);l(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=r,this._sheetsCrosshairHighlightService=i,this._contextService=s,this._refSelectionsService=o,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const r=t.getRowCount(),i=t.getColumnCount(),s=[];for(const o of e){const{startRow:c,endRow:g,startColumn:v,endColumn:C}=o.range;g-c+1===r||C-v+1===i||s.push(o.range)}this._rangeCollection.setSelectedRanges(s);for(const o of s)this.addSelection(o,t)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(u.combineLatest([this._contextService.subscribeContextValue$(w.REF_SELECTIONS_ENABLED).pipe(u.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(u.tap(t=>this._color=t)),u.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(u.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),u.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(u.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,r,i,s,o,c])=>{if(this._clear(),!i)return;const g=t?c:o;this._rangeCollection.reset(),this._transformSelection(g,e.getActiveSheet()),this.render(this._rangeCollection.getRanges())}))}addSelection(e,t){if(e.rangeType===a.RANGE_TYPE.COLUMN||e.rangeType===a.RANGE_TYPE.ROW||e.rangeType===a.RANGE_TYPE.ALL)return;const r=t.getRowCount(),i=t.getColumnCount(),{startRow:s,endRow:o,startColumn:c,endColumn:g}=e,v={startRow:s,endRow:o,startColumn:0,endColumn:c-1},C={startRow:s,endRow:o,startColumn:g+1,endColumn:i},m={startRow:0,endRow:s-1,startColumn:c,endColumn:g},b={startRow:o+1,endRow:r,startColumn:c,endColumn:g};for(const _ of[v,C,m,b])_.startRow<=_.endRow&&_.startColumn<=_.endColumn&&this._rangeCollection.addRange(_)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,r,i){const{startRow:s,endRow:o,startColumn:c,endColumn:g}=e,v=M.getCoordByCell(s,c,r,i),C=M.getCoordByCell(o,g,r,i),{startX:m,startY:b}=v,{endX:_,endY:D}=C,Y=_-m,q=D-b,B={left:m,top:b,color:new a.ColorKit(this._color).toRgb(),width:Y,height:q,zIndex:oe,evented:!1},N=new ce(`crosshair-${t}`,B);this._shapes.push(N),r.addObject(N)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:r}=this._context;this._clear();for(let i=0;i<e.length;i++){const s=e[i];this._addShapes(s,i,r,t)}r.makeDirty(!0)}async dispose(){super.dispose()}};O=he([p(1,a.Inject(M.SheetSkeletonManagerService)),p(2,a.Inject(w.SheetsSelectionsService)),p(3,a.Inject(d)),p(4,a.Inject(a.IContextService)),p(5,w.IRefSelectionsService)],O);var ge=Object.getOwnPropertyDescriptor,ue=(n,e,t,r)=>{for(var i=r>1?void 0:r?ge(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(i)||i);return i},y=(n,e)=>(t,r)=>e(t,r,n),R;exports.UniverSheetsCrosshairHighlightPlugin=(R=class extends a.Plugin{constructor(e=j,t,r,i){super(),this._config=e,this._injector=t,this._renderManagerService=r,this._configService=i;const{...s}=a.merge({},j,this._config);this._configService.setConfig(X,s)}onStarting(){[[d],[H]].forEach(e=>this._injector.add(e))}onReady(){[[O]].forEach(e=>this._injector.add(e)),this._injector.get(H),this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,[O])}},l(R,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),l(R,"type",a.UniverInstanceType.UNIVER_SHEET),R);exports.UniverSheetsCrosshairHighlightPlugin=ue([y(1,a.Inject(a.Injector)),y(2,T.IRenderManagerService),y(3,a.IConfigService)],exports.UniverSheetsCrosshairHighlightPlugin);exports.CROSSHAIR_HIGHLIGHT_COLORS=x;exports.DisableCrosshairHighlightOperation=k;exports.EnableCrosshairHighlightOperation=G;exports.SetCrosshairHighlightColorOperation=$;exports.SheetsCrosshairHighlightService=d;exports.ToggleCrosshairHighlightOperation=I;
|
package/lib/es/index.js
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var c = (
|
|
4
|
-
import { Disposable as
|
|
5
|
-
import { Shape as
|
|
6
|
-
import { useDependency as
|
|
7
|
-
import { BehaviorSubject as
|
|
8
|
-
import { jsx as
|
|
9
|
-
import { clsx as
|
|
10
|
-
import { forwardRef as
|
|
11
|
-
import { SheetsSelectionsService as Re, IRefSelectionsService as
|
|
12
|
-
import { SheetSkeletonManagerService as
|
|
13
|
-
const
|
|
1
|
+
var K = Object.defineProperty;
|
|
2
|
+
var q = (n, e, t) => e in n ? K(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var c = (n, e, t) => q(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Disposable as y, CommandType as H, UniverInstanceType as E, Inject as u, ICommandService as J, RANGE_TYPE as f, Rectangle as $, IContextService as Q, ColorKit as ee, Plugin as te, merge as re, Injector as ne, IConfigService as ie } from "@univerjs/core";
|
|
5
|
+
import { Shape as se, Rect as oe, IRenderManagerService as ae } from "@univerjs/engine-render";
|
|
6
|
+
import { useDependency as ce, useObservable as le, getMenuHiddenObservable as he, MenuItemType as ge, ContextMenuPosition as de, ContextMenuGroup as ue, ComponentManager as fe, IMenuManagerService as _e } from "@univerjs/ui";
|
|
7
|
+
import { BehaviorSubject as x, combineLatest as ve, merge as T, startWith as Se, tap as pe, map as V } from "rxjs";
|
|
8
|
+
import { jsx as N } from "react/jsx-runtime";
|
|
9
|
+
import { clsx as Ce } from "@univerjs/design";
|
|
10
|
+
import { forwardRef as k, useRef as me, createElement as A, useCallback as be } from "react";
|
|
11
|
+
import { SheetsSelectionsService as Re, IRefSelectionsService as He, REF_SELECTIONS_ENABLED as Oe } from "@univerjs/sheets";
|
|
12
|
+
import { SheetSkeletonManagerService as Ie, getCoordByCell as P } from "@univerjs/sheets-ui";
|
|
13
|
+
const Ee = "sheets-crosshair-highlight.config", j = {};
|
|
14
14
|
var l = function() {
|
|
15
|
-
return l = Object.assign || function(
|
|
15
|
+
return l = Object.assign || function(n) {
|
|
16
16
|
for (var e, t = 1, r = arguments.length; t < r; t++) {
|
|
17
17
|
e = arguments[t];
|
|
18
|
-
for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (
|
|
18
|
+
for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (n[i] = e[i]);
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return n;
|
|
21
21
|
}, l.apply(this, arguments);
|
|
22
|
-
},
|
|
22
|
+
}, ye = function(n, e) {
|
|
23
23
|
var t = {};
|
|
24
|
-
for (var r in
|
|
25
|
-
if (
|
|
26
|
-
for (var i = 0, r = Object.getOwnPropertySymbols(
|
|
27
|
-
e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(
|
|
24
|
+
for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && e.indexOf(r) < 0 && (t[r] = n[r]);
|
|
25
|
+
if (n != null && typeof Object.getOwnPropertySymbols == "function")
|
|
26
|
+
for (var i = 0, r = Object.getOwnPropertySymbols(n); i < r.length; i++)
|
|
27
|
+
e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[i]) && (t[r[i]] = n[r[i]]);
|
|
28
28
|
return t;
|
|
29
|
-
},
|
|
30
|
-
var t =
|
|
31
|
-
return
|
|
29
|
+
}, G = k(function(n, e) {
|
|
30
|
+
var t = n.icon, r = n.id, i = n.className, s = n.extend, o = ye(n, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(r, " ").concat(i || "").trim(), h = me("_".concat($e()));
|
|
31
|
+
return U(t, "".concat(r), { defIds: t.defIds, idSuffix: h.current }, l({ ref: e, className: a }, o), s);
|
|
32
32
|
});
|
|
33
|
-
function
|
|
34
|
-
return
|
|
35
|
-
return
|
|
33
|
+
function U(n, e, t, r, i) {
|
|
34
|
+
return A(n.tag, l(l({ key: e }, we(n, t, i)), r), (Me(n, t).children || []).map(function(s, o) {
|
|
35
|
+
return U(s, "".concat(e, "-").concat(n.tag, "-").concat(o), t, void 0, i);
|
|
36
36
|
}));
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
var r = l({},
|
|
40
|
-
t != null && t.colorChannel1 && r.fill === "colorChannel1" && (r.fill = t.colorChannel1),
|
|
41
|
-
var o =
|
|
38
|
+
function we(n, e, t) {
|
|
39
|
+
var r = l({}, n.attrs);
|
|
40
|
+
t != null && t.colorChannel1 && r.fill === "colorChannel1" && (r.fill = t.colorChannel1), n.tag === "mask" && r.id && (r.id = r.id + e.idSuffix), Object.entries(r).forEach(function(s) {
|
|
41
|
+
var o = s[0], a = s[1];
|
|
42
42
|
o === "mask" && typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
43
43
|
});
|
|
44
44
|
var i = e.defIds;
|
|
45
|
-
return !i || i.length === 0 || (
|
|
46
|
-
var o =
|
|
45
|
+
return !i || i.length === 0 || (n.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(s) {
|
|
46
|
+
var o = s[0], a = s[1];
|
|
47
47
|
typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
48
48
|
})), r;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Me(n, e) {
|
|
51
51
|
var t, r = e.defIds;
|
|
52
|
-
return !r || r.length === 0 ?
|
|
52
|
+
return !r || r.length === 0 ? n : n.tag === "defs" && (!((t = n.children) === null || t === void 0) && t.length) ? l(l({}, n), { children: n.children.map(function(i) {
|
|
53
53
|
return typeof i.attrs.id == "string" && r && r.indexOf(i.attrs.id) > -1 ? l(l({}, i), { attrs: l(l({}, i.attrs), { id: i.attrs.id + e.idSuffix }) }) : i;
|
|
54
|
-
}) }) :
|
|
54
|
+
}) }) : n;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function $e() {
|
|
57
57
|
return Math.random().toString(36).substring(2, 8);
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
var
|
|
61
|
-
return G
|
|
59
|
+
G.displayName = "UniverIcon";
|
|
60
|
+
var xe = { 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" } }] }, D = k(function(n, e) {
|
|
61
|
+
return A(G, Object.assign({}, n, {
|
|
62
62
|
id: "cross-highlighting-single",
|
|
63
63
|
ref: e,
|
|
64
|
-
icon:
|
|
64
|
+
icon: xe
|
|
65
65
|
}));
|
|
66
66
|
});
|
|
67
|
-
|
|
68
|
-
const
|
|
67
|
+
D.displayName = "CrossHighlightingSingle";
|
|
68
|
+
const Z = [
|
|
69
69
|
"rgba(158, 109, 227, 0.3)",
|
|
70
70
|
"rgba(254, 75, 75, 0.3)",
|
|
71
71
|
"rgba(255, 140, 81, 0.3)",
|
|
@@ -83,12 +83,12 @@ const B = [
|
|
|
83
83
|
"rgba(242, 72, 166, 0.15)",
|
|
84
84
|
"rgba(153, 153, 153, 0.15)"
|
|
85
85
|
];
|
|
86
|
-
class g extends
|
|
86
|
+
class g extends y {
|
|
87
87
|
constructor() {
|
|
88
88
|
super(...arguments);
|
|
89
|
-
c(this, "_enabled$", new
|
|
89
|
+
c(this, "_enabled$", new x(!1));
|
|
90
90
|
c(this, "enabled$", this._enabled$.asObservable());
|
|
91
|
-
c(this, "_color$", new
|
|
91
|
+
c(this, "_color$", new x(Z[0]));
|
|
92
92
|
c(this, "color$", this._color$.asObservable());
|
|
93
93
|
}
|
|
94
94
|
get enabled() {
|
|
@@ -107,117 +107,118 @@ class g extends w {
|
|
|
107
107
|
this._color$.next(t);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
const
|
|
110
|
+
const w = {
|
|
111
111
|
id: "sheet.operation.toggle-crosshair-highlight",
|
|
112
|
-
type:
|
|
113
|
-
handler(
|
|
114
|
-
const e =
|
|
112
|
+
type: H.OPERATION,
|
|
113
|
+
handler(n) {
|
|
114
|
+
const e = n.get(g), t = e.enabled;
|
|
115
115
|
return e.setEnabled(!t), !0;
|
|
116
116
|
}
|
|
117
|
-
},
|
|
117
|
+
}, B = {
|
|
118
118
|
id: "sheet.operation.set-crosshair-highlight-color",
|
|
119
|
-
type:
|
|
120
|
-
handler(
|
|
121
|
-
const t =
|
|
119
|
+
type: H.OPERATION,
|
|
120
|
+
handler(n, { value: e }) {
|
|
121
|
+
const t = n.get(g);
|
|
122
122
|
return t.enabled || t.setEnabled(!0), t.setColor(e), !0;
|
|
123
123
|
}
|
|
124
|
-
},
|
|
124
|
+
}, Te = {
|
|
125
125
|
id: "sheet.operation.enable-crosshair-highlight",
|
|
126
|
-
type:
|
|
127
|
-
handler(
|
|
128
|
-
const e =
|
|
126
|
+
type: H.OPERATION,
|
|
127
|
+
handler(n) {
|
|
128
|
+
const e = n.get(g);
|
|
129
129
|
return e.enabled ? !1 : (e.setEnabled(!0), !0);
|
|
130
130
|
}
|
|
131
|
-
},
|
|
131
|
+
}, Ve = {
|
|
132
132
|
id: "sheet.operation.disable-crosshair-highlight",
|
|
133
|
-
type:
|
|
134
|
-
handler(
|
|
135
|
-
const e =
|
|
133
|
+
type: H.OPERATION,
|
|
134
|
+
handler(n) {
|
|
135
|
+
const e = n.get(g);
|
|
136
136
|
return e.enabled ? (e.setEnabled(!1), !0) : !1;
|
|
137
137
|
}
|
|
138
|
-
}, Pe = "univer-crosshair-highlight-overlay", je = "univer-crosshair-highlight-item", Le = "univer-crosshair-highlight-item-selected", O = {
|
|
139
|
-
crosshairHighlightOverlay: Pe,
|
|
140
|
-
crosshairHighlightItem: je,
|
|
141
|
-
crosshairHighlightItemSelected: Le
|
|
142
138
|
};
|
|
143
|
-
function
|
|
144
|
-
const { onChange: e } =
|
|
145
|
-
e == null || e(
|
|
139
|
+
function Ne(n) {
|
|
140
|
+
const { onChange: e } = n, t = ce(g), r = le(t.color$), i = be((s) => {
|
|
141
|
+
e == null || e(s);
|
|
146
142
|
}, [e]);
|
|
147
|
-
return /* @__PURE__ */
|
|
143
|
+
return /* @__PURE__ */ N("div", { className: "univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3", children: Z.map((s) => /* @__PURE__ */ N(
|
|
148
144
|
"div",
|
|
149
145
|
{
|
|
150
|
-
className:
|
|
151
|
-
|
|
146
|
+
className: Ce(`
|
|
147
|
+
univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-border
|
|
148
|
+
univer-border-solid univer-border-gray-200 univer-ring-offset-1 univer-transition-shadow
|
|
149
|
+
hover:univer-ring-[1.5px] hover:univer-ring-primary-600/40
|
|
150
|
+
`, {
|
|
151
|
+
"univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600": s === r
|
|
152
152
|
}),
|
|
153
|
-
style: { backgroundColor:
|
|
154
|
-
onClick: () => i(
|
|
153
|
+
style: { backgroundColor: s },
|
|
154
|
+
onClick: () => i(s)
|
|
155
155
|
},
|
|
156
|
-
|
|
156
|
+
s
|
|
157
157
|
)) });
|
|
158
158
|
}
|
|
159
|
-
const
|
|
160
|
-
function
|
|
161
|
-
const e =
|
|
159
|
+
const W = "CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";
|
|
160
|
+
function Pe(n) {
|
|
161
|
+
const e = n.get(g);
|
|
162
162
|
return {
|
|
163
|
-
id:
|
|
163
|
+
id: w.id,
|
|
164
164
|
tooltip: "crosshair.button.tooltip",
|
|
165
|
-
type:
|
|
165
|
+
type: ge.BUTTON_SELECTOR,
|
|
166
166
|
icon: "CrossHighlightingSingle",
|
|
167
167
|
selections: [
|
|
168
168
|
{
|
|
169
169
|
label: {
|
|
170
|
-
name:
|
|
171
|
-
hoverable: !1
|
|
170
|
+
name: W,
|
|
171
|
+
hoverable: !1,
|
|
172
|
+
selectable: !1
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
175
|
],
|
|
175
|
-
selectionsCommandId:
|
|
176
|
+
selectionsCommandId: B.id,
|
|
176
177
|
activated$: e.enabled$,
|
|
177
|
-
hidden$:
|
|
178
|
+
hidden$: he(n, E.UNIVER_SHEET)
|
|
178
179
|
};
|
|
179
180
|
}
|
|
180
|
-
const
|
|
181
|
-
[
|
|
182
|
-
[
|
|
183
|
-
[
|
|
181
|
+
const je = {
|
|
182
|
+
[de.FOOTER_MENU]: {
|
|
183
|
+
[ue.OTHERS]: {
|
|
184
|
+
[w.id]: {
|
|
184
185
|
order: 0,
|
|
185
|
-
menuItemFactory:
|
|
186
|
+
menuItemFactory: Pe
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
};
|
|
190
|
-
var
|
|
191
|
-
for (var i = r > 1 ? void 0 : r ?
|
|
192
|
-
(o = s
|
|
191
|
+
var Le = Object.getOwnPropertyDescriptor, ke = (n, e, t, r) => {
|
|
192
|
+
for (var i = r > 1 ? void 0 : r ? Le(e, t) : e, s = n.length - 1, o; s >= 0; s--)
|
|
193
|
+
(o = n[s]) && (i = o(i) || i);
|
|
193
194
|
return i;
|
|
194
|
-
},
|
|
195
|
-
let
|
|
196
|
-
constructor(
|
|
197
|
-
super(), this._componentMgr =
|
|
195
|
+
}, O = (n, e) => (t, r) => e(t, r, n);
|
|
196
|
+
let b = class extends y {
|
|
197
|
+
constructor(n, e, t) {
|
|
198
|
+
super(), this._componentMgr = n, this._menuManagerService = e, this._cmdSrv = t, this._initCommands(), this._initMenus(), this._initComponents();
|
|
198
199
|
}
|
|
199
200
|
_initCommands() {
|
|
200
201
|
[
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
].forEach((
|
|
202
|
+
w,
|
|
203
|
+
B,
|
|
204
|
+
Te,
|
|
205
|
+
Ve
|
|
206
|
+
].forEach((n) => this._cmdSrv.registerCommand(n));
|
|
206
207
|
}
|
|
207
208
|
_initMenus() {
|
|
208
|
-
this._menuManagerService.mergeMenu(
|
|
209
|
+
this._menuManagerService.mergeMenu(je);
|
|
209
210
|
}
|
|
210
211
|
_initComponents() {
|
|
211
|
-
this._componentMgr.register(
|
|
212
|
+
this._componentMgr.register(W, Ne), this._componentMgr.register("CrossHighlightingSingle", D);
|
|
212
213
|
}
|
|
213
214
|
};
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
],
|
|
219
|
-
const
|
|
220
|
-
class
|
|
215
|
+
b = ke([
|
|
216
|
+
O(0, u(fe)),
|
|
217
|
+
O(1, _e),
|
|
218
|
+
O(2, J)
|
|
219
|
+
], b);
|
|
220
|
+
const Ae = 1;
|
|
221
|
+
class Ge {
|
|
221
222
|
constructor() {
|
|
222
223
|
c(this, "_selectedRanges", []);
|
|
223
224
|
c(this, "_ranges", []);
|
|
@@ -234,19 +235,19 @@ class Be {
|
|
|
234
235
|
_getSplitRanges(e, t) {
|
|
235
236
|
let r = [e];
|
|
236
237
|
for (const i of t.concat(this._selectedRanges)) {
|
|
237
|
-
const
|
|
238
|
+
const s = [];
|
|
238
239
|
for (const o of r) {
|
|
239
|
-
const a =
|
|
240
|
-
a && a.length > 0 &&
|
|
240
|
+
const a = $.subtract(o, i);
|
|
241
|
+
a && a.length > 0 && s.push(...a);
|
|
241
242
|
}
|
|
242
|
-
r =
|
|
243
|
+
r = s;
|
|
243
244
|
}
|
|
244
245
|
return r.filter((i) => i.startRow <= i.endRow && i.startColumn <= i.endColumn);
|
|
245
246
|
}
|
|
246
247
|
_getIntersects(e) {
|
|
247
248
|
const t = [];
|
|
248
249
|
for (const r of this._ranges) {
|
|
249
|
-
const i =
|
|
250
|
+
const i = $.getIntersects(r, e);
|
|
250
251
|
i && t.push(i);
|
|
251
252
|
}
|
|
252
253
|
return t;
|
|
@@ -258,7 +259,7 @@ class Be {
|
|
|
258
259
|
this._ranges = [], this._selectedRanges = [];
|
|
259
260
|
}
|
|
260
261
|
}
|
|
261
|
-
class
|
|
262
|
+
class Ue extends se {
|
|
262
263
|
constructor(t, r) {
|
|
263
264
|
super(t, r);
|
|
264
265
|
// protected _showHighLight = false;
|
|
@@ -272,9 +273,9 @@ class We extends oe {
|
|
|
272
273
|
});
|
|
273
274
|
}
|
|
274
275
|
_draw(t) {
|
|
275
|
-
var i,
|
|
276
|
-
const r = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(
|
|
277
|
-
|
|
276
|
+
var i, s;
|
|
277
|
+
const r = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(s = (i = this._color) == null ? void 0 : i.a) != null ? s : 0.5})`;
|
|
278
|
+
oe.drawWith(t, {
|
|
278
279
|
width: this.width,
|
|
279
280
|
height: this.height,
|
|
280
281
|
fill: r,
|
|
@@ -284,53 +285,53 @@ class We extends oe {
|
|
|
284
285
|
});
|
|
285
286
|
}
|
|
286
287
|
}
|
|
287
|
-
var
|
|
288
|
-
for (var i = r > 1 ? void 0 : r ?
|
|
289
|
-
(o = s
|
|
288
|
+
var De = Object.getOwnPropertyDescriptor, Ze = (n, e, t, r) => {
|
|
289
|
+
for (var i = r > 1 ? void 0 : r ? De(e, t) : e, s = n.length - 1, o; s >= 0; s--)
|
|
290
|
+
(o = n[s]) && (i = o(i) || i);
|
|
290
291
|
return i;
|
|
291
|
-
},
|
|
292
|
-
let
|
|
293
|
-
constructor(e, t, r, i,
|
|
292
|
+
}, S = (n, e) => (t, r) => e(t, r, n);
|
|
293
|
+
let R = class extends y {
|
|
294
|
+
constructor(e, t, r, i, s, o) {
|
|
294
295
|
super();
|
|
295
296
|
c(this, "_shapes", []);
|
|
296
|
-
c(this, "_rangeCollection", new
|
|
297
|
+
c(this, "_rangeCollection", new Ge());
|
|
297
298
|
c(this, "_color", "rgba(255,0,0,0.5)");
|
|
298
|
-
this._context = e, this._sheetSkeletonManagerService = t, this._sheetsSelectionsService = r, this._sheetsCrosshairHighlightService = i, this._contextService =
|
|
299
|
+
this._context = e, this._sheetSkeletonManagerService = t, this._sheetsSelectionsService = r, this._sheetsCrosshairHighlightService = i, this._contextService = s, this._refSelectionsService = o, this._initRenderListener();
|
|
299
300
|
}
|
|
300
301
|
_transformSelection(e, t) {
|
|
301
302
|
if (!e)
|
|
302
303
|
return;
|
|
303
|
-
const r = t.getRowCount(), i = t.getColumnCount(),
|
|
304
|
+
const r = t.getRowCount(), i = t.getColumnCount(), s = [];
|
|
304
305
|
for (const o of e) {
|
|
305
|
-
const { startRow: a, endRow: h, startColumn: _, endColumn:
|
|
306
|
-
h - a + 1 === r ||
|
|
306
|
+
const { startRow: a, endRow: h, startColumn: _, endColumn: v } = o.range;
|
|
307
|
+
h - a + 1 === r || v - _ + 1 === i || s.push(o.range);
|
|
307
308
|
}
|
|
308
|
-
this._rangeCollection.setSelectedRanges(
|
|
309
|
-
for (const o of
|
|
309
|
+
this._rangeCollection.setSelectedRanges(s);
|
|
310
|
+
for (const o of s)
|
|
310
311
|
this.addSelection(o, t);
|
|
311
312
|
}
|
|
312
313
|
_initRenderListener() {
|
|
313
314
|
const e = this._context.unit;
|
|
314
315
|
this.disposeWithMe(ve([
|
|
315
|
-
this._contextService.subscribeContextValue$(
|
|
316
|
+
this._contextService.subscribeContextValue$(Oe).pipe(Se(!1)),
|
|
316
317
|
this._sheetSkeletonManagerService.currentSkeleton$,
|
|
317
318
|
this._sheetsCrosshairHighlightService.enabled$,
|
|
318
|
-
this._sheetsCrosshairHighlightService.color$.pipe(
|
|
319
|
-
|
|
319
|
+
this._sheetsCrosshairHighlightService.color$.pipe(pe((t) => this._color = t)),
|
|
320
|
+
T(
|
|
320
321
|
this._sheetsSelectionsService.selectionMoveStart$,
|
|
321
322
|
this._sheetsSelectionsService.selectionMoving$,
|
|
322
323
|
this._sheetsSelectionsService.selectionMoveEnd$,
|
|
323
324
|
this._sheetsSelectionsService.selectionSet$,
|
|
324
|
-
e.activeSheet$.pipe(
|
|
325
|
+
e.activeSheet$.pipe(V(() => this._sheetsSelectionsService.getCurrentSelections()))
|
|
325
326
|
),
|
|
326
|
-
|
|
327
|
+
T(
|
|
327
328
|
this._refSelectionsService.selectionMoveStart$,
|
|
328
329
|
this._refSelectionsService.selectionMoving$,
|
|
329
330
|
this._refSelectionsService.selectionMoveEnd$,
|
|
330
331
|
this._sheetsSelectionsService.selectionSet$,
|
|
331
|
-
e.activeSheet$.pipe(
|
|
332
|
+
e.activeSheet$.pipe(V(() => this._refSelectionsService.getCurrentSelections()))
|
|
332
333
|
)
|
|
333
|
-
]).subscribe(([t, r, i,
|
|
334
|
+
]).subscribe(([t, r, i, s, o, a]) => {
|
|
334
335
|
if (this._clear(), !i) return;
|
|
335
336
|
const h = t ? a : o;
|
|
336
337
|
this._rangeCollection.reset(), this._transformSelection(h, e.getActiveSheet()), this.render(this._rangeCollection.getRanges());
|
|
@@ -339,28 +340,28 @@ let b = class extends w {
|
|
|
339
340
|
addSelection(e, t) {
|
|
340
341
|
if (e.rangeType === f.COLUMN || e.rangeType === f.ROW || e.rangeType === f.ALL)
|
|
341
342
|
return;
|
|
342
|
-
const r = t.getRowCount(), i = t.getColumnCount(), { startRow:
|
|
343
|
-
startRow:
|
|
343
|
+
const r = t.getRowCount(), i = t.getColumnCount(), { startRow: s, endRow: o, startColumn: a, endColumn: h } = e, _ = {
|
|
344
|
+
startRow: s,
|
|
344
345
|
endRow: o,
|
|
345
346
|
startColumn: 0,
|
|
346
347
|
endColumn: a - 1
|
|
347
|
-
},
|
|
348
|
-
startRow:
|
|
348
|
+
}, v = {
|
|
349
|
+
startRow: s,
|
|
349
350
|
endRow: o,
|
|
350
351
|
startColumn: h + 1,
|
|
351
352
|
endColumn: i
|
|
352
|
-
},
|
|
353
|
+
}, p = {
|
|
353
354
|
startRow: 0,
|
|
354
|
-
endRow:
|
|
355
|
+
endRow: s - 1,
|
|
355
356
|
startColumn: a,
|
|
356
357
|
endColumn: h
|
|
357
|
-
},
|
|
358
|
+
}, C = {
|
|
358
359
|
startRow: o + 1,
|
|
359
360
|
endRow: r,
|
|
360
361
|
startColumn: a,
|
|
361
362
|
endColumn: h
|
|
362
363
|
};
|
|
363
|
-
for (const d of [_,
|
|
364
|
+
for (const d of [_, v, p, C])
|
|
364
365
|
d.startRow <= d.endRow && d.startColumn <= d.endColumn && this._rangeCollection.addRange(d);
|
|
365
366
|
}
|
|
366
367
|
_clear() {
|
|
@@ -369,16 +370,16 @@ let b = class extends w {
|
|
|
369
370
|
}), this._shapes = [];
|
|
370
371
|
}
|
|
371
372
|
_addShapes(e, t, r, i) {
|
|
372
|
-
const { startRow:
|
|
373
|
-
left:
|
|
374
|
-
top:
|
|
375
|
-
color: new
|
|
376
|
-
width:
|
|
377
|
-
height:
|
|
378
|
-
zIndex:
|
|
373
|
+
const { startRow: s, endRow: o, startColumn: a, endColumn: h } = e, _ = P(s, a, r, i), v = P(o, h, r, i), { startX: p, startY: C } = _, { endX: d, endY: Y } = v, F = d - p, X = Y - C, z = {
|
|
374
|
+
left: p,
|
|
375
|
+
top: C,
|
|
376
|
+
color: new ee(this._color).toRgb(),
|
|
377
|
+
width: F,
|
|
378
|
+
height: X,
|
|
379
|
+
zIndex: Ae,
|
|
379
380
|
evented: !1
|
|
380
|
-
},
|
|
381
|
-
this._shapes.push(
|
|
381
|
+
}, M = new Ue(`crosshair-${t}`, z);
|
|
382
|
+
this._shapes.push(M), r.addObject(M);
|
|
382
383
|
}
|
|
383
384
|
render(e) {
|
|
384
385
|
const t = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
@@ -387,8 +388,8 @@ let b = class extends w {
|
|
|
387
388
|
const { scene: r } = this._context;
|
|
388
389
|
this._clear();
|
|
389
390
|
for (let i = 0; i < e.length; i++) {
|
|
390
|
-
const
|
|
391
|
-
this._addShapes(
|
|
391
|
+
const s = e[i];
|
|
392
|
+
this._addShapes(s, i, r, t);
|
|
392
393
|
}
|
|
393
394
|
r.makeDirty(!0);
|
|
394
395
|
}
|
|
@@ -396,51 +397,51 @@ let b = class extends w {
|
|
|
396
397
|
super.dispose();
|
|
397
398
|
}
|
|
398
399
|
};
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
],
|
|
406
|
-
var
|
|
407
|
-
for (var i = r > 1 ? void 0 : r ?
|
|
408
|
-
(o = s
|
|
400
|
+
R = Ze([
|
|
401
|
+
S(1, u(Ie)),
|
|
402
|
+
S(2, u(Re)),
|
|
403
|
+
S(3, u(g)),
|
|
404
|
+
S(4, u(Q)),
|
|
405
|
+
S(5, He)
|
|
406
|
+
], R);
|
|
407
|
+
var Be = Object.getOwnPropertyDescriptor, We = (n, e, t, r) => {
|
|
408
|
+
for (var i = r > 1 ? void 0 : r ? Be(e, t) : e, s = n.length - 1, o; s >= 0; s--)
|
|
409
|
+
(o = n[s]) && (i = o(i) || i);
|
|
409
410
|
return i;
|
|
410
|
-
},
|
|
411
|
-
let
|
|
412
|
-
constructor(
|
|
413
|
-
super(), this._config =
|
|
414
|
-
const { ...i } =
|
|
411
|
+
}, I = (n, e) => (t, r) => e(t, r, n), m;
|
|
412
|
+
let L = (m = class extends te {
|
|
413
|
+
constructor(n = j, e, t, r) {
|
|
414
|
+
super(), this._config = n, this._injector = e, this._renderManagerService = t, this._configService = r;
|
|
415
|
+
const { ...i } = re(
|
|
415
416
|
{},
|
|
416
|
-
|
|
417
|
+
j,
|
|
417
418
|
this._config
|
|
418
419
|
);
|
|
419
|
-
this._configService.setConfig(
|
|
420
|
+
this._configService.setConfig(Ee, i);
|
|
420
421
|
}
|
|
421
422
|
onStarting() {
|
|
422
423
|
[
|
|
423
424
|
[g],
|
|
424
|
-
[
|
|
425
|
-
].forEach((
|
|
425
|
+
[b]
|
|
426
|
+
].forEach((n) => this._injector.add(n));
|
|
426
427
|
}
|
|
427
428
|
onReady() {
|
|
428
429
|
[
|
|
429
|
-
[
|
|
430
|
-
].forEach((
|
|
431
|
-
}
|
|
432
|
-
}, c(
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
],
|
|
430
|
+
[R]
|
|
431
|
+
].forEach((n) => this._injector.add(n)), this._injector.get(b), this._renderManagerService.registerRenderModule(E.UNIVER_SHEET, [R]);
|
|
432
|
+
}
|
|
433
|
+
}, c(m, "pluginName", "SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"), c(m, "type", E.UNIVER_SHEET), m);
|
|
434
|
+
L = We([
|
|
435
|
+
I(1, u(ne)),
|
|
436
|
+
I(2, ae),
|
|
437
|
+
I(3, ie)
|
|
438
|
+
], L);
|
|
438
439
|
export {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
440
|
+
Z as CROSSHAIR_HIGHLIGHT_COLORS,
|
|
441
|
+
Ve as DisableCrosshairHighlightOperation,
|
|
442
|
+
Te as EnableCrosshairHighlightOperation,
|
|
443
|
+
B as SetCrosshairHighlightColorOperation,
|
|
443
444
|
g as SheetsCrosshairHighlightService,
|
|
444
|
-
|
|
445
|
-
|
|
445
|
+
w as ToggleCrosshairHighlightOperation,
|
|
446
|
+
L as UniverSheetsCrosshairHighlightPlugin
|
|
446
447
|
};
|
package/lib/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.univer-
|
|
1
|
+
.univer-box-border{box-sizing:border-box}.univer-grid{display:grid}.univer-size-5{width:1.25rem;height:1.25rem}.univer-cursor-pointer{cursor:pointer}.univer-grid-cols-8{grid-template-columns:repeat(8,minmax(0,1fr))}.univer-gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}.univer-gap-y-3{row-gap:.75rem}.univer-rounded{border-radius:.25rem}.univer-border{border-width:1px}.univer-border-solid{border-style:solid}.univer-border-gray-200{--tw-border-opacity: 1;border-color:#e3e5ea;border-color:rgba(227,229,234,var(--tw-border-opacity, 1))}.univer-ring-\[1\.5px\]{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1.5px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),0 0 #0000;box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 rgba(0,0,0,0))}.univer-ring-primary-600{--tw-ring-opacity: 1;--tw-ring-color: rgba(44, 83, 241, var(--tw-ring-opacity, 1)) }.univer-ring-offset-1{--tw-ring-offset-width: 1px }.univer-transition-shadow{transition-property:box-shadow;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.hover\:univer-ring-\[1\.5px\]:hover{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1.5px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),0 0 #0000;box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 rgba(0,0,0,0))}.hover\:univer-ring-primary-600:hover{--tw-ring-opacity: 1;--tw-ring-color: rgba(44, 83, 241, var(--tw-ring-opacity, 1)) }.hover\:univer-ring-primary-600\/40:hover{--tw-ring-color: rgba(44, 83, 241, .4) }
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
(function(h,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/sheets"),require("@univerjs/sheets-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/ui","rxjs","react/jsx-runtime","@univerjs/design","react","@univerjs/sheets","@univerjs/sheets-ui"],o):(h=typeof globalThis<"u"?globalThis:h||self,o(h.UniverSheetsCrosshairHighlight={},h.UniverCore,h.UniverEngineRender,h.UniverUi,h.rxjs,h.React,h.UniverDesign,h.React,h.UniverSheets,h.UniverSheetsUi))})(this,function(h,o,_,S,u,V,q,C,T,w){"use strict";var ue=Object.defineProperty;var fe=(h,o,_)=>o in h?ue(h,o,{enumerable:!0,configurable:!0,writable:!0,value:_}):h[o]=_;var l=(h,o,_)=>fe(h,typeof o!="symbol"?o+"":o,_);var I;const B="sheets-crosshair-highlight.config",x={};var g=function(){return g=Object.assign||function(r){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},g.apply(this,arguments)},Z=function(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(r,i[n])&&(t[i[n]]=r[i[n]]);return t},A=C.forwardRef(function(r,e){var t=r.icon,i=r.id,n=r.className,s=r.extend,a=Z(r,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(i," ").concat(n||"").trim(),d=C.useRef("_".concat(X()));return L(t,"".concat(i),{defIds:t.defIds,idSuffix:d.current},g({ref:e,className:c},a),s)});function L(r,e,t,i,n){return C.createElement(r.tag,g(g({key:e},W(r,t,n)),i),(F(r,t).children||[]).map(function(s,a){return L(s,"".concat(e,"-").concat(r.tag,"-").concat(a),t,void 0,n)}))}function W(r,e,t){var i=g({},r.attrs);t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1),r.tag==="mask"&&i.id&&(i.id=i.id+e.idSuffix),Object.entries(i).forEach(function(s){var a=s[0],c=s[1];a==="mask"&&typeof c=="string"&&(i[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var n=e.defIds;return!n||n.length===0||(r.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(s){var a=s[0],c=s[1];typeof c=="string"&&(i[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function F(r,e){var t,i=e.defIds;return!i||i.length===0?r:r.tag==="defs"&&(!((t=r.children)===null||t===void 0)&&t.length)?g(g({},r),{children:r.children.map(function(n){return typeof n.attrs.id=="string"&&i&&i.indexOf(n.attrs.id)>-1?g(g({},n),{attrs:g(g({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):r}function X(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var K={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"}}]},U=C.forwardRef(function(r,e){return C.createElement(A,Object.assign({},r,{id:"cross-highlighting-single",ref:e,icon:K}))});U.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 f extends o.Disposable{constructor(){super(...arguments);l(this,"_enabled$",new u.BehaviorSubject(!1));l(this,"enabled$",this._enabled$.asObservable());l(this,"_color$",new u.BehaviorSubject(M[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 R={id:"sheet.operation.toggle-crosshair-highlight",type:o.CommandType.OPERATION,handler(r){const e=r.get(f),t=e.enabled;return e.setEnabled(!t),!0}},$={id:"sheet.operation.set-crosshair-highlight-color",type:o.CommandType.OPERATION,handler(r,{value:e}){const t=r.get(f);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},G={id:"sheet.operation.enable-crosshair-highlight",type:o.CommandType.OPERATION,handler(r){const e=r.get(f);return e.enabled?!1:(e.setEnabled(!0),!0)}},k={id:"sheet.operation.disable-crosshair-highlight",type:o.CommandType.OPERATION,handler(r){const e=r.get(f);return e.enabled?(e.setEnabled(!1),!0):!1}},j={crosshairHighlightOverlay:"univer-crosshair-highlight-overlay",crosshairHighlightItem:"univer-crosshair-highlight-item",crosshairHighlightItemSelected:"univer-crosshair-highlight-item-selected"};function z(r){const{onChange:e}=r,t=S.useDependency(f),i=S.useObservable(t.color$),n=C.useCallback(s=>{e==null||e(s)},[e]);return V.jsx("div",{className:j.crosshairHighlightOverlay,children:M.map(s=>V.jsx("div",{className:q.clsx(j.crosshairHighlightItem,{[j.crosshairHighlightItemSelected]:s===i}),style:{backgroundColor:s},onClick:()=>n(s)},s))})}const D="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function J(r){const e=r.get(f);return{id:R.id,tooltip:"crosshair.button.tooltip",type:S.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:D,hoverable:!1}}],selectionsCommandId:$.id,activated$:e.enabled$,hidden$:S.getMenuHiddenObservable(r,o.UniverInstanceType.UNIVER_SHEET)}}const Q={[S.ContextMenuPosition.FOOTER_MENU]:{[S.ContextMenuGroup.OTHERS]:{[R.id]:{order:0,menuItemFactory:J}}}};var ee=Object.getOwnPropertyDescriptor,te=(r,e,t,i)=>{for(var n=i>1?void 0:i?ee(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(n=a(n)||n);return n},N=(r,e)=>(t,i)=>e(t,i,r);let b=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(){[R,$,G,k].forEach(r=>this._cmdSrv.registerCommand(r))}_initMenus(){this._menuManagerService.mergeMenu(Q)}_initComponents(){this._componentMgr.register(D,z),this._componentMgr.register("CrossHighlightingSingle",U)}};b=te([N(0,o.Inject(S.ComponentManager)),N(1,S.IMenuManagerService),N(2,o.ICommandService)],b);const ie=1;class ne{constructor(){l(this,"_selectedRanges",[]);l(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 s=[];for(const a of i){const c=o.Rectangle.subtract(a,n);c&&c.length>0&&s.push(...c)}i=s}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 re extends _.Shape{constructor(t,i){super(t,i);l(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,s;const i=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(s=(n=this._color)==null?void 0:n.a)!=null?s:.5})`;_.Rect.drawWith(t,{width:this.width,height:this.height,fill:i,stroke:void 0,strokeWidth:0,evented:!1})}}var se=Object.getOwnPropertyDescriptor,oe=(r,e,t,i)=>{for(var n=i>1?void 0:i?se(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(n=a(n)||n);return n},p=(r,e)=>(t,i)=>e(t,i,r);let O=class extends o.Disposable{constructor(e,t,i,n,s,a){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=i,this._sheetsCrosshairHighlightService=n,this._contextService=s,this._refSelectionsService=a,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const i=t.getRowCount(),n=t.getColumnCount(),s=[];for(const a of e){const{startRow:c,endRow:d,startColumn:m,endColumn:H}=a.range;d-c+1===i||H-m+1===n||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(u.combineLatest([this._contextService.subscribeContextValue$(T.REF_SELECTIONS_ENABLED).pipe(u.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(u.tap(t=>this._color=t)),u.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(u.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),u.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(u.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,i,n,s,a,c])=>{if(this._clear(),!n)return;const d=t?c: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 i=t.getRowCount(),n=t.getColumnCount(),{startRow:s,endRow:a,startColumn:c,endColumn:d}=e,m={startRow:s,endRow:a,startColumn:0,endColumn:c-1},H={startRow:s,endRow:a,startColumn:d+1,endColumn:n},E={startRow:0,endRow:s-1,startColumn:c,endColumn:d},y={startRow:a+1,endRow:i,startColumn:c,endColumn:d};for(const v of[m,H,E,y])v.startRow<=v.endRow&&v.startColumn<=v.endColumn&&this._rangeCollection.addRange(v)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,i,n){const{startRow:s,endRow:a,startColumn:c,endColumn:d}=e,m=w.getCoordByCell(s,c,i,n),H=w.getCoordByCell(a,d,i,n),{startX:E,startY:y}=m,{endX:v,endY:ce}=H,le=v-E,ge=ce-y,de={left:E,top:y,color:new o.ColorKit(this._color).toRgb(),width:le,height:ge,zIndex:ie,evented:!1},Y=new re(`crosshair-${t}`,de);this._shapes.push(Y),i.addObject(Y)}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 s=e[n];this._addShapes(s,n,i,t)}i.makeDirty(!0)}async dispose(){super.dispose()}};O=oe([p(1,o.Inject(w.SheetSkeletonManagerService)),p(2,o.Inject(T.SheetsSelectionsService)),p(3,o.Inject(f)),p(4,o.Inject(o.IContextService)),p(5,T.IRefSelectionsService)],O);var ae=Object.getOwnPropertyDescriptor,he=(r,e,t,i)=>{for(var n=i>1?void 0:i?ae(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(n=a(n)||n);return n},P=(r,e)=>(t,i)=>e(t,i,r);h.UniverSheetsCrosshairHighlightPlugin=(I=class extends o.Plugin{constructor(e=x,t,i,n){super(),this._config=e,this._injector=t,this._renderManagerService=i,this._configService=n;const{...s}=o.merge({},x,this._config);this._configService.setConfig(B,s)}onStarting(){[[f],[b]].forEach(e=>this._injector.add(e))}onReady(){[[O]].forEach(e=>this._injector.add(e)),this._injector.get(b),this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[O])}},l(I,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),l(I,"type",o.UniverInstanceType.UNIVER_SHEET),I),h.UniverSheetsCrosshairHighlightPlugin=he([P(1,o.Inject(o.Injector)),P(2,_.IRenderManagerService),P(3,o.IConfigService)],h.UniverSheetsCrosshairHighlightPlugin),h.CROSSHAIR_HIGHLIGHT_COLORS=M,h.DisableCrosshairHighlightOperation=k,h.EnableCrosshairHighlightOperation=G,h.SetCrosshairHighlightColorOperation=$,h.SheetsCrosshairHighlightService=f,h.ToggleCrosshairHighlightOperation=R,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/sheets"),require("@univerjs/sheets-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/ui","rxjs","react/jsx-runtime","@univerjs/design","react","@univerjs/sheets","@univerjs/sheets-ui"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverSheetsCrosshairHighlight={},c.UniverCore,c.UniverEngineRender,c.UniverUi,c.rxjs,c.React,c.UniverDesign,c.React,c.UniverSheets,c.UniverSheetsUi))})(this,function(c,o,v,_,d,P,Y,C,T,w){"use strict";var ue=Object.defineProperty;var de=(c,o,v)=>o in c?ue(c,o,{enumerable:!0,configurable:!0,writable:!0,value:v}):c[o]=v;var h=(c,o,v)=>de(c,typeof o!="symbol"?o+"":o,v);var E;const q="sheets-crosshair-highlight.config",V={};var g=function(){return g=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},g.apply(this,arguments)},B=function(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(t[n[r]]=i[n[r]]);return t},x=C.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,s=i.extend,a=B(i,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),u=C.useRef("_".concat(F()));return A(t,"".concat(n),{defIds:t.defIds,idSuffix:u.current},g({ref:e,className:l},a),s)});function A(i,e,t,n,r){return C.createElement(i.tag,g(g({key:e},Z(i,t,r)),n),(W(i,t).children||[]).map(function(s,a){return A(s,"".concat(e,"-").concat(i.tag,"-").concat(a),t,void 0,r)}))}function Z(i,e,t){var n=g({},i.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1),i.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],l=s[1];a==="mask"&&typeof l=="string"&&(n[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var r=e.defIds;return!r||r.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],l=s[1];typeof l=="string"&&(n[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function W(i,e){var t,n=e.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?g(g({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?g(g({},r),{attrs:g(g({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function F(){return Math.random().toString(36).substring(2,8)}x.displayName="UniverIcon";var X={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"}}]},L=C.forwardRef(function(i,e){return C.createElement(x,Object.assign({},i,{id:"cross-highlighting-single",ref:e,icon:X}))});L.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 f extends o.Disposable{constructor(){super(...arguments);h(this,"_enabled$",new d.BehaviorSubject(!1));h(this,"enabled$",this._enabled$.asObservable());h(this,"_color$",new d.BehaviorSubject(M[0]));h(this,"color$",this._color$.asObservable())}get enabled(){return this._enabled$.getValue()}get color(){return this._color$.getValue()}dispose(){this._enabled$.complete()}setEnabled(t){this._enabled$.next(t)}setColor(t){this._color$.next(t)}}const 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}},U={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)}},G={id:"sheet.operation.disable-crosshair-highlight",type:o.CommandType.OPERATION,handler(i){const e=i.get(f);return e.enabled?(e.setEnabled(!1),!0):!1}};function z(i){const{onChange:e}=i,t=_.useDependency(f),n=_.useObservable(t.color$),r=C.useCallback(s=>{e==null||e(s)},[e]);return P.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3",children:M.map(s=>P.jsx("div",{className:Y.clsx(`
|
|
2
|
+
univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-border
|
|
3
|
+
univer-border-solid univer-border-gray-200 univer-ring-offset-1 univer-transition-shadow
|
|
4
|
+
hover:univer-ring-[1.5px] hover:univer-ring-primary-600/40
|
|
5
|
+
`,{"univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600":s===n}),style:{backgroundColor:s},onClick:()=>r(s)},s))})}const k="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function K(i){const e=i.get(f);return{id:R.id,tooltip:"crosshair.button.tooltip",type:_.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:k,hoverable:!1,selectable:!1}}],selectionsCommandId:$.id,activated$:e.enabled$,hidden$:_.getMenuHiddenObservable(i,o.UniverInstanceType.UNIVER_SHEET)}}const J={[_.ContextMenuPosition.FOOTER_MENU]:{[_.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,$,U,G].forEach(i=>this._cmdSrv.registerCommand(i))}_initMenus(){this._menuManagerService.mergeMenu(J)}_initComponents(){this._componentMgr.register(k,z),this._componentMgr.register("CrossHighlightingSingle",L)}};b=ee([j(0,o.Inject(_.ComponentManager)),j(1,_.IMenuManagerService),j(2,o.ICommandService)],b);const te=1;class ne{constructor(){h(this,"_selectedRanges",[]);h(this,"_ranges",[])}addRange(e){if(e.rangeType===o.RANGE_TYPE.COLUMN||e.rangeType===o.RANGE_TYPE.ROW||e.rangeType===o.RANGE_TYPE.ALL)return;const t=this._getIntersects(e),n=this._getSplitRanges(e,t);n.length>0&&this._ranges.push(...n)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,t){let n=[e];for(const r of t.concat(this._selectedRanges)){const s=[];for(const a of n){const l=o.Rectangle.subtract(a,r);l&&l.length>0&&s.push(...l)}n=s}return n.filter(r=>r.startRow<=r.endRow&&r.startColumn<=r.endColumn)}_getIntersects(e){const t=[];for(const n of this._ranges){const r=o.Rectangle.getIntersects(n,e);r&&t.push(r)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class re extends v.Shape{constructor(t,n){super(t,n);h(this,"_color");n&&this.setShapeProps(n)}setShapeProps(t){typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){var r,s;const n=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(s=(r=this._color)==null?void 0:r.a)!=null?s:.5})`;v.Rect.drawWith(t,{width:this.width,height:this.height,fill:n,stroke:void 0,strokeWidth:0,evented:!1})}}var ie=Object.getOwnPropertyDescriptor,se=(i,e,t,n)=>{for(var r=n>1?void 0:n?ie(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},p=(i,e)=>(t,n)=>e(t,n,i);let O=class extends o.Disposable{constructor(e,t,n,r,s,a){super();h(this,"_shapes",[]);h(this,"_rangeCollection",new ne);h(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=n,this._sheetsCrosshairHighlightService=r,this._contextService=s,this._refSelectionsService=a,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const n=t.getRowCount(),r=t.getColumnCount(),s=[];for(const a of e){const{startRow:l,endRow:u,startColumn:m,endColumn:H}=a.range;u-l+1===n||H-m+1===r||s.push(a.range)}this._rangeCollection.setSelectedRanges(s);for(const a of s)this.addSelection(a,t)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(d.combineLatest([this._contextService.subscribeContextValue$(T.REF_SELECTIONS_ENABLED).pipe(d.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(d.tap(t=>this._color=t)),d.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(d.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),d.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(d.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,n,r,s,a,l])=>{if(this._clear(),!r)return;const u=t?l:a;this._rangeCollection.reset(),this._transformSelection(u,e.getActiveSheet()),this.render(this._rangeCollection.getRanges())}))}addSelection(e,t){if(e.rangeType===o.RANGE_TYPE.COLUMN||e.rangeType===o.RANGE_TYPE.ROW||e.rangeType===o.RANGE_TYPE.ALL)return;const n=t.getRowCount(),r=t.getColumnCount(),{startRow:s,endRow:a,startColumn:l,endColumn:u}=e,m={startRow:s,endRow:a,startColumn:0,endColumn:l-1},H={startRow:s,endRow:a,startColumn:u+1,endColumn:r},I={startRow:0,endRow:s-1,startColumn:l,endColumn:u},y={startRow:a+1,endRow:n,startColumn:l,endColumn:u};for(const S of[m,H,I,y])S.startRow<=S.endRow&&S.startColumn<=S.endColumn&&this._rangeCollection.addRange(S)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,n,r){const{startRow:s,endRow:a,startColumn:l,endColumn:u}=e,m=w.getCoordByCell(s,l,n,r),H=w.getCoordByCell(a,u,n,r),{startX:I,startY:y}=m,{endX:S,endY:ce}=H,le=S-I,he=ce-y,ge={left:I,top:y,color:new o.ColorKit(this._color).toRgb(),width:le,height:he,zIndex:te,evented:!1},D=new re(`crosshair-${t}`,ge);this._shapes.push(D),n.addObject(D)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:n}=this._context;this._clear();for(let r=0;r<e.length;r++){const s=e[r];this._addShapes(s,r,n,t)}n.makeDirty(!0)}async dispose(){super.dispose()}};O=se([p(1,o.Inject(w.SheetSkeletonManagerService)),p(2,o.Inject(T.SheetsSelectionsService)),p(3,o.Inject(f)),p(4,o.Inject(o.IContextService)),p(5,T.IRefSelectionsService)],O);var oe=Object.getOwnPropertyDescriptor,ae=(i,e,t,n)=>{for(var r=n>1?void 0:n?oe(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},N=(i,e)=>(t,n)=>e(t,n,i);c.UniverSheetsCrosshairHighlightPlugin=(E=class extends o.Plugin{constructor(e=V,t,n,r){super(),this._config=e,this._injector=t,this._renderManagerService=n,this._configService=r;const{...s}=o.merge({},V,this._config);this._configService.setConfig(q,s)}onStarting(){[[f],[b]].forEach(e=>this._injector.add(e))}onReady(){[[O]].forEach(e=>this._injector.add(e)),this._injector.get(b),this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[O])}},h(E,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),h(E,"type",o.UniverInstanceType.UNIVER_SHEET),E),c.UniverSheetsCrosshairHighlightPlugin=ae([N(1,o.Inject(o.Injector)),N(2,v.IRenderManagerService),N(3,o.IConfigService)],c.UniverSheetsCrosshairHighlightPlugin),c.CROSSHAIR_HIGHLIGHT_COLORS=M,c.DisableCrosshairHighlightOperation=G,c.EnableCrosshairHighlightOperation=U,c.SetCrosshairHighlightColorOperation=$,c.SheetsCrosshairHighlightService=f,c.ToggleCrosshairHighlightOperation=R,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-crosshair-highlight",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -53,28 +53,27 @@
|
|
|
53
53
|
"lib"
|
|
54
54
|
],
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"react": ">=16.9.0
|
|
56
|
+
"react": ">=16.9.0",
|
|
57
57
|
"rxjs": ">=7.0.0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@univerjs/icons": "^0.2.
|
|
61
|
-
"@univerjs/core": "0.6.
|
|
62
|
-
"@univerjs/design": "0.6.
|
|
63
|
-
"@univerjs/engine-render": "0.6.
|
|
64
|
-
"@univerjs/sheets": "0.6.
|
|
65
|
-
"@univerjs/
|
|
66
|
-
"@univerjs/
|
|
60
|
+
"@univerjs/icons": "^0.2.21",
|
|
61
|
+
"@univerjs/core": "0.6.5",
|
|
62
|
+
"@univerjs/design": "0.6.5",
|
|
63
|
+
"@univerjs/engine-render": "0.6.5",
|
|
64
|
+
"@univerjs/sheets-ui": "0.6.5",
|
|
65
|
+
"@univerjs/ui": "0.6.5",
|
|
66
|
+
"@univerjs/sheets": "0.6.5"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"less": "^4.2.2",
|
|
70
69
|
"postcss": "^8.5.3",
|
|
71
70
|
"react": "18.3.1",
|
|
72
71
|
"rxjs": "^7.8.1",
|
|
73
72
|
"tailwindcss": "^3.4.17",
|
|
74
73
|
"typescript": "^5.8.2",
|
|
75
|
-
"vite": "^6.2.
|
|
76
|
-
"vitest": "^3.0.
|
|
77
|
-
"@univerjs-infra/shared": "0.6.
|
|
74
|
+
"vite": "^6.2.1",
|
|
75
|
+
"vitest": "^3.0.8",
|
|
76
|
+
"@univerjs-infra/shared": "0.6.5"
|
|
78
77
|
},
|
|
79
78
|
"scripts": {
|
|
80
79
|
"test": "vitest run",
|