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