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