@univerjs/sheets-crosshair-highlight 0.20.1 → 0.21.0
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 +74 -1
- package/lib/cjs/index.js +562 -1
- package/lib/cjs/locale/ca-ES.js +6 -1
- package/lib/cjs/locale/en-US.js +21 -1
- package/lib/cjs/locale/es-ES.js +6 -1
- package/lib/cjs/locale/fa-IR.js +6 -1
- package/lib/cjs/locale/fr-FR.js +6 -1
- package/lib/cjs/locale/ja-JP.js +6 -1
- package/lib/cjs/locale/ko-KR.js +6 -1
- package/lib/cjs/locale/ru-RU.js +6 -1
- package/lib/cjs/locale/sk-SK.js +6 -1
- package/lib/cjs/locale/vi-VN.js +6 -1
- package/lib/cjs/locale/zh-CN.js +6 -1
- package/lib/cjs/locale/zh-TW.js +6 -1
- package/lib/es/facade.js +75 -1
- package/lib/es/index.js +550 -1
- package/lib/es/locale/ca-ES.js +5 -1
- package/lib/es/locale/en-US.js +20 -1
- package/lib/es/locale/es-ES.js +5 -1
- package/lib/es/locale/fa-IR.js +5 -1
- package/lib/es/locale/fr-FR.js +5 -1
- package/lib/es/locale/ja-JP.js +5 -1
- package/lib/es/locale/ko-KR.js +5 -1
- package/lib/es/locale/ru-RU.js +5 -1
- package/lib/es/locale/sk-SK.js +5 -1
- package/lib/es/locale/vi-VN.js +5 -1
- package/lib/es/locale/zh-CN.js +5 -1
- package/lib/es/locale/zh-TW.js +5 -1
- package/lib/facade.js +75 -1
- package/lib/index.js +550 -1
- package/lib/locale/ca-ES.js +5 -1
- package/lib/locale/en-US.js +20 -1
- package/lib/locale/es-ES.js +5 -1
- package/lib/locale/fa-IR.js +5 -1
- package/lib/locale/fr-FR.js +5 -1
- package/lib/locale/ja-JP.js +5 -1
- package/lib/locale/ko-KR.js +5 -1
- package/lib/locale/ru-RU.js +5 -1
- package/lib/locale/sk-SK.js +5 -1
- package/lib/locale/vi-VN.js +5 -1
- package/lib/locale/zh-CN.js +5 -1
- package/lib/locale/zh-TW.js +5 -1
- package/lib/umd/index.js +1 -1
- package/package.json +10 -10
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1,74 @@
|
|
|
1
|
-
let
|
|
1
|
+
let _univerjs_core = require("@univerjs/core");
|
|
2
|
+
let _univerjs_core_facade = require("@univerjs/core/facade");
|
|
3
|
+
let _univerjs_sheets_crosshair_highlight = require("@univerjs/sheets-crosshair-highlight");
|
|
4
|
+
|
|
5
|
+
//#region src/facade/f-univer.ts
|
|
6
|
+
/**
|
|
7
|
+
* @ignore
|
|
8
|
+
*/
|
|
9
|
+
var FUniverSheetsCrosshairHighlightMixin = class extends _univerjs_core_facade.FUniver {
|
|
10
|
+
/**
|
|
11
|
+
* @ignore
|
|
12
|
+
*/
|
|
13
|
+
_initialize(injector) {
|
|
14
|
+
const commandService = injector.get(_univerjs_core.ICommandService);
|
|
15
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.CrosshairHighlightEnabledChanged, () => commandService.onCommandExecuted((commandInfo) => {
|
|
16
|
+
if (commandInfo.id === _univerjs_sheets_crosshair_highlight.EnableCrosshairHighlightOperation.id || commandInfo.id === _univerjs_sheets_crosshair_highlight.DisableCrosshairHighlightOperation.id || commandInfo.id === _univerjs_sheets_crosshair_highlight.ToggleCrosshairHighlightOperation.id) {
|
|
17
|
+
const activeSheet = this.getActiveSheet();
|
|
18
|
+
if (!activeSheet) return;
|
|
19
|
+
const eventParams = {
|
|
20
|
+
enabled: this.getCrosshairHighlightEnabled(),
|
|
21
|
+
...activeSheet
|
|
22
|
+
};
|
|
23
|
+
this.fireEvent(this.Event.CrosshairHighlightEnabledChanged, eventParams);
|
|
24
|
+
}
|
|
25
|
+
})));
|
|
26
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.CrosshairHighlightColorChanged, () => commandService.onCommandExecuted((commandInfo) => {
|
|
27
|
+
if (commandInfo.id === _univerjs_sheets_crosshair_highlight.SetCrosshairHighlightColorOperation.id) {
|
|
28
|
+
const activeSheet = this.getActiveSheet();
|
|
29
|
+
if (!activeSheet) return;
|
|
30
|
+
const eventParams = {
|
|
31
|
+
color: this.getCrosshairHighlightColor(),
|
|
32
|
+
...activeSheet
|
|
33
|
+
};
|
|
34
|
+
this.fireEvent(this.Event.CrosshairHighlightColorChanged, eventParams);
|
|
35
|
+
}
|
|
36
|
+
})));
|
|
37
|
+
}
|
|
38
|
+
setCrosshairHighlightEnabled(enabled) {
|
|
39
|
+
if (enabled) this._commandService.syncExecuteCommand(_univerjs_sheets_crosshair_highlight.EnableCrosshairHighlightOperation.id);
|
|
40
|
+
else this._commandService.syncExecuteCommand(_univerjs_sheets_crosshair_highlight.DisableCrosshairHighlightOperation.id);
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
setCrosshairHighlightColor(color) {
|
|
44
|
+
this._commandService.syncExecuteCommand(_univerjs_sheets_crosshair_highlight.SetCrosshairHighlightColorOperation.id, { value: color });
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
getCrosshairHighlightEnabled() {
|
|
48
|
+
return this._injector.get(_univerjs_sheets_crosshair_highlight.SheetsCrosshairHighlightService).enabled;
|
|
49
|
+
}
|
|
50
|
+
getCrosshairHighlightColor() {
|
|
51
|
+
return this._injector.get(_univerjs_sheets_crosshair_highlight.SheetsCrosshairHighlightService).color;
|
|
52
|
+
}
|
|
53
|
+
get CROSSHAIR_HIGHLIGHT_COLORS() {
|
|
54
|
+
return _univerjs_sheets_crosshair_highlight.CROSSHAIR_HIGHLIGHT_COLORS;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
_univerjs_core_facade.FUniver.extend(FUniverSheetsCrosshairHighlightMixin);
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/facade/f-event.ts
|
|
61
|
+
/**
|
|
62
|
+
* @ignore
|
|
63
|
+
*/
|
|
64
|
+
var FSheetsCrosshairHighlightEventNameMixin = class extends _univerjs_core_facade.FEventName {
|
|
65
|
+
get CrosshairHighlightEnabledChanged() {
|
|
66
|
+
return "CrosshairHighlightEnabledChanged";
|
|
67
|
+
}
|
|
68
|
+
get CrosshairHighlightColorChanged() {
|
|
69
|
+
return "CrosshairHighlightColorChanged";
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
_univerjs_core_facade.FEventName.extend(FSheetsCrosshairHighlightEventNameMixin);
|
|
73
|
+
|
|
74
|
+
//#endregion
|
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1,562 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs/core`),t=require(`rxjs`),n=require(`@univerjs/engine-render`),r=require(`@univerjs/icons`),i=require(`@univerjs/ui`),a=require(`@univerjs/design`),o=require(`react`),s=require(`react/jsx-runtime`),c=require(`@univerjs/sheets`),l=require(`@univerjs/sheets-ui`);function u(e){"@babel/helpers - typeof";return u=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},u(e)}function d(e,t){if(u(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(u(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}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)`];var h=class extends e.Disposable{constructor(...e){super(...e),p(this,`_enabled$`,new t.BehaviorSubject(!1)),p(this,`enabled$`,this._enabled$.asObservable()),p(this,`_color$`,new t.BehaviorSubject(m[0])),p(this,`color$`,this._color$.asObservable())}get enabled(){return this._enabled$.getValue()}get color(){return this._color$.getValue()}dispose(){this._enabled$.complete()}setEnabled(e){this._enabled$.next(e)}setColor(e){this._color$.next(e)}};const g={id:`sheet.operation.toggle-crosshair-highlight`,type:e.CommandType.OPERATION,handler(e){let t=e.get(h),n=t.enabled;return t.setEnabled(!n),!0}},_={id:`sheet.operation.set-crosshair-highlight-color`,type:e.CommandType.OPERATION,handler(e,{value:t}){let n=e.get(h);return n.enabled||n.setEnabled(!0),n.setColor(t),!0}},v={id:`sheet.operation.enable-crosshair-highlight`,type:e.CommandType.OPERATION,handler(e){let t=e.get(h);return t.enabled?!1:(t.setEnabled(!0),!0)}},y={id:`sheet.operation.disable-crosshair-highlight`,type:e.CommandType.OPERATION,handler(e){let t=e.get(h);return t.enabled?(t.setEnabled(!1),!0):!1}};var b=`@univerjs/sheets-crosshair-highlight`,x=`0.20.1`;const S=`sheets-crosshair-highlight.config`;Symbol(S);const C={},w=`CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT`;function T(t){let n=t.get(h);return{id:g.id,tooltip:`crosshair.button.tooltip`,type:i.MenuItemType.BUTTON_SELECTOR,icon:`CrossHighlightingIcon`,selections:[{label:{name:w,hoverable:!1,selectable:!1}}],selectionsCommandId:_.id,activated$:n.enabled$,hidden$:(0,i.getMenuHiddenObservable)(t,e.UniverInstanceType.UNIVER_SHEET)}}const E={[i.ContextMenuPosition.FOOTER_MENU]:{[i.ContextMenuGroup.OTHERS]:{[g.id]:{order:0,menuItemFactory:T}}}};function D(e){let{onChange:t}=e,n=(0,i.useObservable)((0,i.useDependency)(h).color$),r=(0,o.useCallback)(e=>{t==null||t(e)},[t]);return(0,s.jsx)(`div`,{className:`univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3`,children:m.map(e=>(0,s.jsx)(`div`,{className:(0,a.clsx)(`hover:univer-ring-primary-600/40 univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1 univer-transition-shadow hover:univer-ring-[1.5px]`,a.borderClassName,{"univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600":e===n}),style:{backgroundColor:e},onClick:()=>r(e)},e))})}function O(e,t){return function(n,r){t(n,r,e)}}function k(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let A=class extends e.Disposable{constructor(e,t,n){super(),this._componentMgr=e,this._menuManagerService=t,this._cmdSrv=n,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[g,_,v,y].forEach(e=>this._cmdSrv.registerCommand(e))}_initMenus(){this._menuManagerService.mergeMenu(E)}_initComponents(){this._componentMgr.register(w,D),this._componentMgr.register(`CrossHighlightingIcon`,r.CrossHighlightingIcon)}};A=k([O(0,(0,e.Inject)(i.ComponentManager)),O(1,i.IMenuManagerService),O(2,e.ICommandService)],A);var j=class{constructor(){p(this,`_selectedRanges`,[]),p(this,`_ranges`,[])}addRange(t){if(t.rangeType===e.RANGE_TYPE.COLUMN||t.rangeType===e.RANGE_TYPE.ROW||t.rangeType===e.RANGE_TYPE.ALL)return;let n=this._getIntersects(t),r=this._getSplitRanges(t,n);r.length>0&&this._ranges.push(...r)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(t,n){let r=[t];for(let t of n.concat(this._selectedRanges)){let n=[];for(let i of r){let r=e.Rectangle.subtract(i,t);r&&r.length>0&&n.push(...r)}r=n}return r.filter(e=>e.startRow<=e.endRow&&e.startColumn<=e.endColumn)}_getIntersects(t){let n=[];for(let r of this._ranges){let i=e.Rectangle.getIntersects(r,t);i&&n.push(i)}return n}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}},M=class extends n.Shape{constructor(e,t){super(e,t),p(this,`_color`,void 0),t&&this.setShapeProps(t)}setShapeProps(e){e.color!==void 0&&(this._color=e.color),this.transformByState({width:e.width,height:e.height})}_draw(e){var t,r;let i=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(t=(r=this._color)==null?void 0:r.a)==null?.5:t})`;n.Rect.drawWith(e,{width:this.width,height:this.height,fill:i,stroke:void 0,strokeWidth:0,evented:!1})}};let N=class extends e.Disposable{constructor(e,t,n,r,i,a){super(),this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=n,this._sheetsCrosshairHighlightService=r,this._contextService=i,this._refSelectionsService=a,p(this,`_shapes`,[]),p(this,`_rangeCollection`,new j),p(this,`_color`,`rgba(255,0,0,0.5)`),this._initRenderListener()}_transformSelection(e,t){if(!e)return;let n=t.getRowCount(),r=t.getColumnCount(),i=[];for(let t of e){let{startRow:e,endRow:a,startColumn:o,endColumn:s}=t.range;a-e+1===n||s-o+1===r||i.push(t.range)}this._rangeCollection.setSelectedRanges(i);for(let e of i)this.addSelection(e,t)}_initRenderListener(){let e=this._context.unit;this.disposeWithMe((0,t.combineLatest)([this._contextService.subscribeContextValue$(c.REF_SELECTIONS_ENABLED).pipe((0,t.startWith)(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe((0,t.tap)(e=>this._color=e)),(0,t.merge)(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe((0,t.map)(()=>this._sheetsSelectionsService.getCurrentSelections()))),(0,t.merge)(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe((0,t.map)(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,n,r,i,a,o])=>{if(this._clear(),!r)return;let s=t?o:a;this._rangeCollection.reset(),this._transformSelection(s,e.getActiveSheet()),this.render(this._rangeCollection.getRanges())}))}addSelection(t,n){if(t.rangeType===e.RANGE_TYPE.COLUMN||t.rangeType===e.RANGE_TYPE.ROW||t.rangeType===e.RANGE_TYPE.ALL)return;let r=n.getRowCount(),i=n.getColumnCount(),{startRow:a,endRow:o,startColumn:s,endColumn:c}=t,l={startRow:a,endRow:o,startColumn:0,endColumn:s-1},u={startRow:a,endRow:o,startColumn:c+1,endColumn:i},d={startRow:0,endRow:a-1,startColumn:s,endColumn:c},f={startRow:o+1,endRow:r,startColumn:s,endColumn:c};for(let e of[l,u,d,f])e.startRow<=e.endRow&&e.startColumn<=e.endColumn&&this._rangeCollection.addRange(e)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(t,n,r,i){let{startRow:a,endRow:o,startColumn:s,endColumn:c}=t,u=(0,l.getCoordByCell)(a,s,r,i),d=(0,l.getCoordByCell)(o,c,r,i),{startX:f,startY:p}=u,{endX:m,endY:h}=d,g=m-f,_=h-p,v={left:f,top:p,color:new e.ColorKit(this._color).toRgb(),width:g,height:_,zIndex:1,evented:!1},y=new M(`crosshair-${n}`,v);this._shapes.push(y),r.addObject(y)}render(e){let t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;let{scene:n}=this._context;this._clear();for(let r=0;r<e.length;r++){let i=e[r];this._addShapes(i,r,n,t)}n.makeDirty(!0)}async dispose(){super.dispose()}};N=k([O(1,(0,e.Inject)(l.SheetSkeletonManagerService)),O(2,(0,e.Inject)(c.SheetsSelectionsService)),O(3,(0,e.Inject)(h)),O(4,(0,e.Inject)(e.IContextService)),O(5,c.IRefSelectionsService)],N);let P=class extends e.Plugin{constructor(t=C,n,r,i){super(),this._config=t,this._injector=n,this._renderManagerService=r,this._configService=i;let{...a}=(0,e.merge)({},C,this._config);this._configService.setConfig(S,a)}onStarting(){[[h],[A]].forEach(e=>this._injector.add(e))}onReady(){[[N]].forEach(e=>this._injector.add(e)),this._injector.get(A),this._renderManagerService.registerRenderModule(e.UniverInstanceType.UNIVER_SHEET,[N])}};p(P,`pluginName`,`SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN`),p(P,`packageName`,b),p(P,`version`,x),p(P,`type`,e.UniverInstanceType.UNIVER_SHEET),P=k([O(1,(0,e.Inject)(e.Injector)),O(2,n.IRenderManagerService),O(3,e.IConfigService)],P),exports.CROSSHAIR_HIGHLIGHT_COLORS=m,exports.DisableCrosshairHighlightOperation=y,exports.EnableCrosshairHighlightOperation=v,exports.SetCrosshairHighlightColorOperation=_,exports.SheetsCrosshairHighlightService=h,exports.ToggleCrosshairHighlightOperation=g,Object.defineProperty(exports,`UniverSheetsCrosshairHighlightPlugin`,{enumerable:!0,get:function(){return P}});
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _univerjs_core = require("@univerjs/core");
|
|
3
|
+
let rxjs = require("rxjs");
|
|
4
|
+
let _univerjs_engine_render = require("@univerjs/engine-render");
|
|
5
|
+
let _univerjs_icons = require("@univerjs/icons");
|
|
6
|
+
let _univerjs_ui = require("@univerjs/ui");
|
|
7
|
+
let _univerjs_design = require("@univerjs/design");
|
|
8
|
+
let react = require("react");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
let _univerjs_sheets = require("@univerjs/sheets");
|
|
11
|
+
let _univerjs_sheets_ui = require("@univerjs/sheets-ui");
|
|
12
|
+
|
|
13
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
|
|
14
|
+
function _typeof(o) {
|
|
15
|
+
"@babel/helpers - typeof";
|
|
16
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
17
|
+
return typeof o;
|
|
18
|
+
} : function(o) {
|
|
19
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
20
|
+
}, _typeof(o);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
|
|
25
|
+
function toPrimitive(t, r) {
|
|
26
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
27
|
+
var e = t[Symbol.toPrimitive];
|
|
28
|
+
if (void 0 !== e) {
|
|
29
|
+
var i = e.call(t, r || "default");
|
|
30
|
+
if ("object" != _typeof(i)) return i;
|
|
31
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
32
|
+
}
|
|
33
|
+
return ("string" === r ? String : Number)(t);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
|
|
38
|
+
function toPropertyKey(t) {
|
|
39
|
+
var i = toPrimitive(t, "string");
|
|
40
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
|
|
45
|
+
function _defineProperty(e, r, t) {
|
|
46
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
47
|
+
value: t,
|
|
48
|
+
enumerable: !0,
|
|
49
|
+
configurable: !0,
|
|
50
|
+
writable: !0
|
|
51
|
+
}) : e[r] = t, e;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/services/crosshair.service.ts
|
|
56
|
+
/**
|
|
57
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
58
|
+
*
|
|
59
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
60
|
+
* you may not use this file except in compliance with the License.
|
|
61
|
+
* You may obtain a copy of the License at
|
|
62
|
+
*
|
|
63
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
64
|
+
*
|
|
65
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
66
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
67
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
68
|
+
* See the License for the specific language governing permissions and
|
|
69
|
+
* limitations under the License.
|
|
70
|
+
*/
|
|
71
|
+
const CROSSHAIR_HIGHLIGHT_COLORS = [
|
|
72
|
+
"rgba(158, 109, 227, 0.3)",
|
|
73
|
+
"rgba(254, 75, 75, 0.3)",
|
|
74
|
+
"rgba(255, 140, 81, 0.3)",
|
|
75
|
+
"rgba(164, 220, 22, 0.3)",
|
|
76
|
+
"rgba(45, 174, 255, 0.3)",
|
|
77
|
+
"rgba(58, 96, 247, 0.3)",
|
|
78
|
+
"rgba(242, 72, 166, 0.3)",
|
|
79
|
+
"rgba(153, 153, 153, 0.3)",
|
|
80
|
+
"rgba(158, 109, 227, 0.15)",
|
|
81
|
+
"rgba(254, 75, 75, 0.15)",
|
|
82
|
+
"rgba(255, 140, 81, 0.15)",
|
|
83
|
+
"rgba(164, 220, 22, 0.15)",
|
|
84
|
+
"rgba(45, 174, 255, 0.15)",
|
|
85
|
+
"rgba(58, 96, 247, 0.15)",
|
|
86
|
+
"rgba(242, 72, 166, 0.15)",
|
|
87
|
+
"rgba(153, 153, 153, 0.15)"
|
|
88
|
+
];
|
|
89
|
+
var SheetsCrosshairHighlightService = class extends _univerjs_core.Disposable {
|
|
90
|
+
constructor(..._args) {
|
|
91
|
+
super(..._args);
|
|
92
|
+
_defineProperty(this, "_enabled$", new rxjs.BehaviorSubject(false));
|
|
93
|
+
_defineProperty(this, "enabled$", this._enabled$.asObservable());
|
|
94
|
+
_defineProperty(this, "_color$", new rxjs.BehaviorSubject(CROSSHAIR_HIGHLIGHT_COLORS[0]));
|
|
95
|
+
_defineProperty(this, "color$", this._color$.asObservable());
|
|
96
|
+
}
|
|
97
|
+
get enabled() {
|
|
98
|
+
return this._enabled$.getValue();
|
|
99
|
+
}
|
|
100
|
+
get color() {
|
|
101
|
+
return this._color$.getValue();
|
|
102
|
+
}
|
|
103
|
+
dispose() {
|
|
104
|
+
this._enabled$.complete();
|
|
105
|
+
}
|
|
106
|
+
setEnabled(value) {
|
|
107
|
+
this._enabled$.next(value);
|
|
108
|
+
}
|
|
109
|
+
setColor(value) {
|
|
110
|
+
this._color$.next(value);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/commands/operations/operation.ts
|
|
116
|
+
/**
|
|
117
|
+
* A {@link CommandType.OPERATION} to toggle the crosshair highlight.
|
|
118
|
+
*/
|
|
119
|
+
const ToggleCrosshairHighlightOperation = {
|
|
120
|
+
id: "sheet.operation.toggle-crosshair-highlight",
|
|
121
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
122
|
+
handler(accessor) {
|
|
123
|
+
const service = accessor.get(SheetsCrosshairHighlightService);
|
|
124
|
+
const turnedOn = service.enabled;
|
|
125
|
+
service.setEnabled(!turnedOn);
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* A {@link CommandType.OPERATION} to set the crosshair highlight color. It the crosshair highlight is not enabled,
|
|
131
|
+
* it will be enabled.
|
|
132
|
+
*
|
|
133
|
+
* Its params {@link ISetCrosshairHighlightColorOperationParams} contains the color value to set as and is required.
|
|
134
|
+
*/
|
|
135
|
+
const SetCrosshairHighlightColorOperation = {
|
|
136
|
+
id: "sheet.operation.set-crosshair-highlight-color",
|
|
137
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
138
|
+
handler(accessor, { value }) {
|
|
139
|
+
const service = accessor.get(SheetsCrosshairHighlightService);
|
|
140
|
+
if (!service.enabled) service.setEnabled(true);
|
|
141
|
+
service.setColor(value);
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* A {@link CommandType.OPERATION} to enable the crosshair highlight.
|
|
147
|
+
*/
|
|
148
|
+
const EnableCrosshairHighlightOperation = {
|
|
149
|
+
id: "sheet.operation.enable-crosshair-highlight",
|
|
150
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
151
|
+
handler(accessor) {
|
|
152
|
+
const service = accessor.get(SheetsCrosshairHighlightService);
|
|
153
|
+
if (service.enabled) return false;
|
|
154
|
+
service.setEnabled(true);
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* A {@link CommandType.OPERATION} to disable the crosshair highlight.
|
|
160
|
+
*/
|
|
161
|
+
const DisableCrosshairHighlightOperation = {
|
|
162
|
+
id: "sheet.operation.disable-crosshair-highlight",
|
|
163
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
164
|
+
handler(accessor) {
|
|
165
|
+
const service = accessor.get(SheetsCrosshairHighlightService);
|
|
166
|
+
if (!service.enabled) return false;
|
|
167
|
+
service.setEnabled(false);
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region package.json
|
|
174
|
+
var name = "@univerjs/sheets-crosshair-highlight";
|
|
175
|
+
var version = "0.21.0";
|
|
176
|
+
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/config/config.ts
|
|
179
|
+
const SHEETS_CROSSHAIR_HIGHLIGHT_PLUGIN_CONFIG_KEY = "sheets-crosshair-highlight.config";
|
|
180
|
+
const configSymbol = Symbol(SHEETS_CROSSHAIR_HIGHLIGHT_PLUGIN_CONFIG_KEY);
|
|
181
|
+
const defaultPluginConfig = {};
|
|
182
|
+
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/menu/crosshair.menu.ts
|
|
185
|
+
const CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT = "CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";
|
|
186
|
+
function CrosshairHighlightMenuItemFactory(accessor) {
|
|
187
|
+
const crosshairHighlightService = accessor.get(SheetsCrosshairHighlightService);
|
|
188
|
+
return {
|
|
189
|
+
id: ToggleCrosshairHighlightOperation.id,
|
|
190
|
+
tooltip: "crosshair.button.tooltip",
|
|
191
|
+
type: _univerjs_ui.MenuItemType.BUTTON_SELECTOR,
|
|
192
|
+
icon: "CrossHighlightingIcon",
|
|
193
|
+
selections: [{ label: {
|
|
194
|
+
name: CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT,
|
|
195
|
+
hoverable: false,
|
|
196
|
+
selectable: false
|
|
197
|
+
} }],
|
|
198
|
+
selectionsCommandId: SetCrosshairHighlightColorOperation.id,
|
|
199
|
+
activated$: crosshairHighlightService.enabled$,
|
|
200
|
+
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET)
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/menu/schema.ts
|
|
206
|
+
const menuSchema = { [_univerjs_ui.ContextMenuPosition.FOOTER_MENU]: { [_univerjs_ui.ContextMenuGroup.OTHERS]: { [ToggleCrosshairHighlightOperation.id]: {
|
|
207
|
+
order: 0,
|
|
208
|
+
menuItemFactory: CrosshairHighlightMenuItemFactory
|
|
209
|
+
} } } };
|
|
210
|
+
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region src/views/components/CrosshairHighlight.tsx
|
|
213
|
+
/**
|
|
214
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
215
|
+
*
|
|
216
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
217
|
+
* you may not use this file except in compliance with the License.
|
|
218
|
+
* You may obtain a copy of the License at
|
|
219
|
+
*
|
|
220
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
221
|
+
*
|
|
222
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
223
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
224
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
225
|
+
* See the License for the specific language governing permissions and
|
|
226
|
+
* limitations under the License.
|
|
227
|
+
*/
|
|
228
|
+
function CrosshairOverlay(props) {
|
|
229
|
+
const { onChange } = props;
|
|
230
|
+
const currentColor = (0, _univerjs_ui.useObservable)((0, _univerjs_ui.useDependency)(SheetsCrosshairHighlightService).color$);
|
|
231
|
+
const handleColorPicked = (0, react.useCallback)((color) => {
|
|
232
|
+
onChange === null || onChange === void 0 || onChange(color);
|
|
233
|
+
}, [onChange]);
|
|
234
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
235
|
+
className: "univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3",
|
|
236
|
+
children: CROSSHAIR_HIGHLIGHT_COLORS.map((color) => {
|
|
237
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
238
|
+
className: (0, _univerjs_design.clsx)("hover:univer-ring-primary-600/40 univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1 univer-transition-shadow hover:univer-ring-[1.5px]", _univerjs_design.borderClassName, { "univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600": color === currentColor }),
|
|
239
|
+
style: { backgroundColor: color },
|
|
240
|
+
onClick: () => handleColorPicked(color)
|
|
241
|
+
}, color);
|
|
242
|
+
})
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
|
|
248
|
+
function __decorateParam(paramIndex, decorator) {
|
|
249
|
+
return function(target, key) {
|
|
250
|
+
decorator(target, key, paramIndex);
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
|
|
256
|
+
function __decorate(decorators, target, key, desc) {
|
|
257
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
258
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
259
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
260
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/controllers/crosshair.controller.tsx
|
|
265
|
+
/**
|
|
266
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
267
|
+
*
|
|
268
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
269
|
+
* you may not use this file except in compliance with the License.
|
|
270
|
+
* You may obtain a copy of the License at
|
|
271
|
+
*
|
|
272
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
273
|
+
*
|
|
274
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
275
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
276
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
277
|
+
* See the License for the specific language governing permissions and
|
|
278
|
+
* limitations under the License.
|
|
279
|
+
*/
|
|
280
|
+
let SheetsCrosshairHighlightController = class SheetsCrosshairHighlightController extends _univerjs_core.Disposable {
|
|
281
|
+
constructor(_componentMgr, _menuManagerService, _cmdSrv) {
|
|
282
|
+
super();
|
|
283
|
+
this._componentMgr = _componentMgr;
|
|
284
|
+
this._menuManagerService = _menuManagerService;
|
|
285
|
+
this._cmdSrv = _cmdSrv;
|
|
286
|
+
this._initCommands();
|
|
287
|
+
this._initMenus();
|
|
288
|
+
this._initComponents();
|
|
289
|
+
}
|
|
290
|
+
_initCommands() {
|
|
291
|
+
[
|
|
292
|
+
ToggleCrosshairHighlightOperation,
|
|
293
|
+
SetCrosshairHighlightColorOperation,
|
|
294
|
+
EnableCrosshairHighlightOperation,
|
|
295
|
+
DisableCrosshairHighlightOperation
|
|
296
|
+
].forEach((c) => this._cmdSrv.registerCommand(c));
|
|
297
|
+
}
|
|
298
|
+
_initMenus() {
|
|
299
|
+
this._menuManagerService.mergeMenu(menuSchema);
|
|
300
|
+
}
|
|
301
|
+
_initComponents() {
|
|
302
|
+
this._componentMgr.register(CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT, CrosshairOverlay);
|
|
303
|
+
this._componentMgr.register("CrossHighlightingIcon", _univerjs_icons.CrossHighlightingIcon);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
SheetsCrosshairHighlightController = __decorate([
|
|
307
|
+
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)),
|
|
308
|
+
__decorateParam(1, _univerjs_ui.IMenuManagerService),
|
|
309
|
+
__decorateParam(2, _univerjs_core.ICommandService)
|
|
310
|
+
], SheetsCrosshairHighlightController);
|
|
311
|
+
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/util.ts
|
|
314
|
+
var CrossHairRangeCollection = class {
|
|
315
|
+
constructor() {
|
|
316
|
+
_defineProperty(this, "_selectedRanges", []);
|
|
317
|
+
_defineProperty(this, "_ranges", []);
|
|
318
|
+
}
|
|
319
|
+
addRange(range) {
|
|
320
|
+
if (range.rangeType === _univerjs_core.RANGE_TYPE.COLUMN || range.rangeType === _univerjs_core.RANGE_TYPE.ROW || range.rangeType === _univerjs_core.RANGE_TYPE.ALL) return;
|
|
321
|
+
const intersects = this._getIntersects(range);
|
|
322
|
+
const splitRanges = this._getSplitRanges(range, intersects);
|
|
323
|
+
if (splitRanges.length > 0) this._ranges.push(...splitRanges);
|
|
324
|
+
}
|
|
325
|
+
setSelectedRanges(selectedRange) {
|
|
326
|
+
this._selectedRanges = selectedRange;
|
|
327
|
+
}
|
|
328
|
+
_getSplitRanges(range, intersects) {
|
|
329
|
+
let splitRanges = [range];
|
|
330
|
+
for (const intersect of intersects.concat(this._selectedRanges)) {
|
|
331
|
+
const newRanges = [];
|
|
332
|
+
for (const splitRange of splitRanges) {
|
|
333
|
+
const split = _univerjs_core.Rectangle.subtract(splitRange, intersect);
|
|
334
|
+
if (split && split.length > 0) newRanges.push(...split);
|
|
335
|
+
}
|
|
336
|
+
splitRanges = newRanges;
|
|
337
|
+
}
|
|
338
|
+
return splitRanges.filter((range) => range.startRow <= range.endRow && range.startColumn <= range.endColumn);
|
|
339
|
+
}
|
|
340
|
+
_getIntersects(addRange) {
|
|
341
|
+
const intersects = [];
|
|
342
|
+
for (const range of this._ranges) {
|
|
343
|
+
const intersect = _univerjs_core.Rectangle.getIntersects(range, addRange);
|
|
344
|
+
if (intersect) intersects.push(intersect);
|
|
345
|
+
}
|
|
346
|
+
return intersects;
|
|
347
|
+
}
|
|
348
|
+
getRanges() {
|
|
349
|
+
return this._ranges;
|
|
350
|
+
}
|
|
351
|
+
reset() {
|
|
352
|
+
this._ranges = [];
|
|
353
|
+
this._selectedRanges = [];
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/views/widgets/crosshair-highlight-shape.ts
|
|
359
|
+
var SheetCrossHairHighlightShape = class extends _univerjs_engine_render.Shape {
|
|
360
|
+
constructor(key, props) {
|
|
361
|
+
super(key, props);
|
|
362
|
+
_defineProperty(this, "_color", void 0);
|
|
363
|
+
if (props) this.setShapeProps(props);
|
|
364
|
+
}
|
|
365
|
+
setShapeProps(props) {
|
|
366
|
+
if (typeof props.color !== "undefined") this._color = props.color;
|
|
367
|
+
this.transformByState({
|
|
368
|
+
width: props.width,
|
|
369
|
+
height: props.height
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
_draw(ctx) {
|
|
373
|
+
var _this$_color$a, _this$_color;
|
|
374
|
+
const color = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(_this$_color$a = (_this$_color = this._color) === null || _this$_color === void 0 ? void 0 : _this$_color.a) !== null && _this$_color$a !== void 0 ? _this$_color$a : .5})`;
|
|
375
|
+
_univerjs_engine_render.Rect.drawWith(ctx, {
|
|
376
|
+
width: this.width,
|
|
377
|
+
height: this.height,
|
|
378
|
+
fill: color,
|
|
379
|
+
stroke: void 0,
|
|
380
|
+
strokeWidth: 0,
|
|
381
|
+
evented: false
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
//#endregion
|
|
387
|
+
//#region src/views/widgets/crosshair-highlight.render-controller.ts
|
|
388
|
+
let SheetCrosshairHighlightRenderController = class SheetCrosshairHighlightRenderController extends _univerjs_core.Disposable {
|
|
389
|
+
constructor(_context, _sheetSkeletonManagerService, _sheetsSelectionsService, _sheetsCrosshairHighlightService, _contextService, _refSelectionsService) {
|
|
390
|
+
super();
|
|
391
|
+
this._context = _context;
|
|
392
|
+
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
393
|
+
this._sheetsSelectionsService = _sheetsSelectionsService;
|
|
394
|
+
this._sheetsCrosshairHighlightService = _sheetsCrosshairHighlightService;
|
|
395
|
+
this._contextService = _contextService;
|
|
396
|
+
this._refSelectionsService = _refSelectionsService;
|
|
397
|
+
_defineProperty(this, "_shapes", []);
|
|
398
|
+
_defineProperty(this, "_rangeCollection", new CrossHairRangeCollection());
|
|
399
|
+
_defineProperty(this, "_color", "rgba(255,0,0,0.5)");
|
|
400
|
+
this._initRenderListener();
|
|
401
|
+
}
|
|
402
|
+
_transformSelection(selectionData, sheet) {
|
|
403
|
+
if (!selectionData) return;
|
|
404
|
+
const rowCount = sheet.getRowCount();
|
|
405
|
+
const columnCount = sheet.getColumnCount();
|
|
406
|
+
const ranges = [];
|
|
407
|
+
for (const selection of selectionData) {
|
|
408
|
+
const { startRow, endRow, startColumn, endColumn } = selection.range;
|
|
409
|
+
if (endRow - startRow + 1 === rowCount || endColumn - startColumn + 1 === columnCount) continue;
|
|
410
|
+
ranges.push(selection.range);
|
|
411
|
+
}
|
|
412
|
+
this._rangeCollection.setSelectedRanges(ranges);
|
|
413
|
+
for (const range of ranges) this.addSelection(range, sheet);
|
|
414
|
+
}
|
|
415
|
+
_initRenderListener() {
|
|
416
|
+
const workbook = this._context.unit;
|
|
417
|
+
this.disposeWithMe((0, rxjs.combineLatest)([
|
|
418
|
+
this._contextService.subscribeContextValue$(_univerjs_sheets.REF_SELECTIONS_ENABLED).pipe((0, rxjs.startWith)(false)),
|
|
419
|
+
this._sheetSkeletonManagerService.currentSkeleton$,
|
|
420
|
+
this._sheetsCrosshairHighlightService.enabled$,
|
|
421
|
+
this._sheetsCrosshairHighlightService.color$.pipe((0, rxjs.tap)((color) => this._color = color)),
|
|
422
|
+
(0, rxjs.merge)(this._sheetsSelectionsService.selectionMoveStart$, this._sheetsSelectionsService.selectionMoving$, this._sheetsSelectionsService.selectionMoveEnd$, this._sheetsSelectionsService.selectionSet$, workbook.activeSheet$.pipe((0, rxjs.map)(() => this._sheetsSelectionsService.getCurrentSelections()))),
|
|
423
|
+
(0, rxjs.merge)(this._refSelectionsService.selectionMoveStart$, this._refSelectionsService.selectionMoving$, this._refSelectionsService.selectionMoveEnd$, this._sheetsSelectionsService.selectionSet$, workbook.activeSheet$.pipe((0, rxjs.map)(() => this._refSelectionsService.getCurrentSelections())))
|
|
424
|
+
]).subscribe(([refSelectionEnabled, _, enabled, _color, normalSelections, refSelection]) => {
|
|
425
|
+
this._clear();
|
|
426
|
+
if (!enabled) return;
|
|
427
|
+
const selections = refSelectionEnabled ? refSelection : normalSelections;
|
|
428
|
+
this._rangeCollection.reset();
|
|
429
|
+
this._transformSelection(selections, workbook.getActiveSheet());
|
|
430
|
+
this.render(this._rangeCollection.getRanges());
|
|
431
|
+
}));
|
|
432
|
+
}
|
|
433
|
+
addSelection(range, sheet) {
|
|
434
|
+
if (range.rangeType === _univerjs_core.RANGE_TYPE.COLUMN || range.rangeType === _univerjs_core.RANGE_TYPE.ROW || range.rangeType === _univerjs_core.RANGE_TYPE.ALL) return;
|
|
435
|
+
const maxRow = sheet.getRowCount();
|
|
436
|
+
const maxColumn = sheet.getColumnCount();
|
|
437
|
+
const { startRow, endRow, startColumn, endColumn } = range;
|
|
438
|
+
const left = {
|
|
439
|
+
startRow,
|
|
440
|
+
endRow,
|
|
441
|
+
startColumn: 0,
|
|
442
|
+
endColumn: startColumn - 1
|
|
443
|
+
};
|
|
444
|
+
const right = {
|
|
445
|
+
startRow,
|
|
446
|
+
endRow,
|
|
447
|
+
startColumn: endColumn + 1,
|
|
448
|
+
endColumn: maxColumn
|
|
449
|
+
};
|
|
450
|
+
const top = {
|
|
451
|
+
startRow: 0,
|
|
452
|
+
endRow: startRow - 1,
|
|
453
|
+
startColumn,
|
|
454
|
+
endColumn
|
|
455
|
+
};
|
|
456
|
+
const bottom = {
|
|
457
|
+
startRow: endRow + 1,
|
|
458
|
+
endRow: maxRow,
|
|
459
|
+
startColumn,
|
|
460
|
+
endColumn
|
|
461
|
+
};
|
|
462
|
+
for (const range of [
|
|
463
|
+
left,
|
|
464
|
+
right,
|
|
465
|
+
top,
|
|
466
|
+
bottom
|
|
467
|
+
]) if (range.startRow <= range.endRow && range.startColumn <= range.endColumn) this._rangeCollection.addRange(range);
|
|
468
|
+
}
|
|
469
|
+
_clear() {
|
|
470
|
+
this._shapes.forEach((shape) => {
|
|
471
|
+
shape.dispose();
|
|
472
|
+
});
|
|
473
|
+
this._shapes = [];
|
|
474
|
+
}
|
|
475
|
+
_addShapes(range, index, scene, skeleton) {
|
|
476
|
+
const { startRow, endRow, startColumn, endColumn } = range;
|
|
477
|
+
const startPosition = (0, _univerjs_sheets_ui.getCoordByCell)(startRow, startColumn, scene, skeleton);
|
|
478
|
+
const endPosition = (0, _univerjs_sheets_ui.getCoordByCell)(endRow, endColumn, scene, skeleton);
|
|
479
|
+
const { startX, startY } = startPosition;
|
|
480
|
+
const { endX, endY } = endPosition;
|
|
481
|
+
const width = endX - startX;
|
|
482
|
+
const height = endY - startY;
|
|
483
|
+
const shapeProps = {
|
|
484
|
+
left: startX,
|
|
485
|
+
top: startY,
|
|
486
|
+
color: new _univerjs_core.ColorKit(this._color).toRgb(),
|
|
487
|
+
width,
|
|
488
|
+
height,
|
|
489
|
+
zIndex: 1,
|
|
490
|
+
evented: false
|
|
491
|
+
};
|
|
492
|
+
const currentShapes = new SheetCrossHairHighlightShape(`crosshair-${index}`, shapeProps);
|
|
493
|
+
this._shapes.push(currentShapes);
|
|
494
|
+
scene.addObject(currentShapes);
|
|
495
|
+
}
|
|
496
|
+
render(ranges) {
|
|
497
|
+
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
498
|
+
if (!skeleton) return;
|
|
499
|
+
const { scene } = this._context;
|
|
500
|
+
this._clear();
|
|
501
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
502
|
+
const range = ranges[i];
|
|
503
|
+
this._addShapes(range, i, scene, skeleton);
|
|
504
|
+
}
|
|
505
|
+
scene.makeDirty(true);
|
|
506
|
+
}
|
|
507
|
+
async dispose() {
|
|
508
|
+
super.dispose();
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
SheetCrosshairHighlightRenderController = __decorate([
|
|
512
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.SheetSkeletonManagerService)),
|
|
513
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetsSelectionsService)),
|
|
514
|
+
__decorateParam(3, (0, _univerjs_core.Inject)(SheetsCrosshairHighlightService)),
|
|
515
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.IContextService)),
|
|
516
|
+
__decorateParam(5, _univerjs_sheets.IRefSelectionsService)
|
|
517
|
+
], SheetCrosshairHighlightRenderController);
|
|
518
|
+
|
|
519
|
+
//#endregion
|
|
520
|
+
//#region src/plugin.ts
|
|
521
|
+
let UniverSheetsCrosshairHighlightPlugin = class UniverSheetsCrosshairHighlightPlugin extends _univerjs_core.Plugin {
|
|
522
|
+
constructor(_config = defaultPluginConfig, _injector, _renderManagerService, _configService) {
|
|
523
|
+
super();
|
|
524
|
+
this._config = _config;
|
|
525
|
+
this._injector = _injector;
|
|
526
|
+
this._renderManagerService = _renderManagerService;
|
|
527
|
+
this._configService = _configService;
|
|
528
|
+
const { ...rest } = (0, _univerjs_core.merge)({}, defaultPluginConfig, this._config);
|
|
529
|
+
this._configService.setConfig(SHEETS_CROSSHAIR_HIGHLIGHT_PLUGIN_CONFIG_KEY, rest);
|
|
530
|
+
}
|
|
531
|
+
onStarting() {
|
|
532
|
+
[[SheetsCrosshairHighlightService], [SheetsCrosshairHighlightController]].forEach((d) => this._injector.add(d));
|
|
533
|
+
}
|
|
534
|
+
onReady() {
|
|
535
|
+
[[SheetCrosshairHighlightRenderController]].forEach((d) => this._injector.add(d));
|
|
536
|
+
this._injector.get(SheetsCrosshairHighlightController);
|
|
537
|
+
this._renderManagerService.registerRenderModule(_univerjs_core.UniverInstanceType.UNIVER_SHEET, [SheetCrosshairHighlightRenderController]);
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
_defineProperty(UniverSheetsCrosshairHighlightPlugin, "pluginName", "SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN");
|
|
541
|
+
_defineProperty(UniverSheetsCrosshairHighlightPlugin, "packageName", name);
|
|
542
|
+
_defineProperty(UniverSheetsCrosshairHighlightPlugin, "version", version);
|
|
543
|
+
_defineProperty(UniverSheetsCrosshairHighlightPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
544
|
+
UniverSheetsCrosshairHighlightPlugin = __decorate([
|
|
545
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
546
|
+
__decorateParam(2, _univerjs_engine_render.IRenderManagerService),
|
|
547
|
+
__decorateParam(3, _univerjs_core.IConfigService)
|
|
548
|
+
], UniverSheetsCrosshairHighlightPlugin);
|
|
549
|
+
|
|
550
|
+
//#endregion
|
|
551
|
+
exports.CROSSHAIR_HIGHLIGHT_COLORS = CROSSHAIR_HIGHLIGHT_COLORS;
|
|
552
|
+
exports.DisableCrosshairHighlightOperation = DisableCrosshairHighlightOperation;
|
|
553
|
+
exports.EnableCrosshairHighlightOperation = EnableCrosshairHighlightOperation;
|
|
554
|
+
exports.SetCrosshairHighlightColorOperation = SetCrosshairHighlightColorOperation;
|
|
555
|
+
exports.SheetsCrosshairHighlightService = SheetsCrosshairHighlightService;
|
|
556
|
+
exports.ToggleCrosshairHighlightOperation = ToggleCrosshairHighlightOperation;
|
|
557
|
+
Object.defineProperty(exports, 'UniverSheetsCrosshairHighlightPlugin', {
|
|
558
|
+
enumerable: true,
|
|
559
|
+
get: function () {
|
|
560
|
+
return UniverSheetsCrosshairHighlightPlugin;
|
|
561
|
+
}
|
|
562
|
+
});
|
package/lib/cjs/locale/ca-ES.js
CHANGED