@univerjs/sheets-zen-editor 0.1.0-beta.2
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/LICENSE.txt +178 -0
- package/README.md +16 -0
- package/lib/cjs/index.js +9 -0
- package/lib/es/index.js +2448 -0
- package/lib/index.css +1 -0
- package/lib/types/commands/commands/zen-editor.command.d.ts +18 -0
- package/lib/types/commands/operations/zen-editor.operation.d.ts +17 -0
- package/lib/types/controllers/zen-editor-ui.controller.d.ts +29 -0
- package/lib/types/controllers/zen-editor.controller.d.ts +44 -0
- package/lib/types/index.d.ts +16 -0
- package/lib/types/plugin.d.ts +27 -0
- package/lib/types/services/zen-editor.service.d.ts +34 -0
- package/lib/types/views/menu.d.ts +17 -0
- package/lib/types/views/zen-editor/ZenEditor.d.ts +18 -0
- package/lib/types/views/zen-editor/index.d.ts +16 -0
- package/lib/umd/index.js +9 -0
- package/package.json +76 -0
package/lib/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.univer-zen-editor{position:absolute;top:0;left:0;width:100%;height:100%}.univer-zen-editor-icon-wrapper{position:absolute;z-index:10;top:0;right:20px;display:flex;align-items:center;justify-content:space-around;width:60px;height:30px}.univer-zen-editor-icon-container{cursor:pointer;display:flex;align-items:center;justify-content:center;width:30px;height:30px}.univer-zen-editor-icon-success{color:rgb(var(--success-color))}.univer-zen-editor-icon-error{color:rgb(var(--error-color))}.univer-zen-editor-canvas-container{position:absolute;top:0;left:0;width:100%;height:100%}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { ICommand } from '@univerjs/core';
|
|
17
|
+
export declare const CancelZenEditCommand: ICommand;
|
|
18
|
+
export declare const ConfirmZenEditCommand: ICommand;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { IOperation } from '@univerjs/core';
|
|
17
|
+
export declare const OpenZenEditorOperation: IOperation;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Disposable, ICommandService } from '@univerjs/core';
|
|
17
|
+
import { IMenuService, IZenZoneService } from '@univerjs/ui';
|
|
18
|
+
import { Injector } from '@wendellhu/redi';
|
|
19
|
+
export declare class ZenEditorUIController extends Disposable {
|
|
20
|
+
private readonly _injector;
|
|
21
|
+
private readonly _zenZoneService;
|
|
22
|
+
private readonly _commandService;
|
|
23
|
+
private readonly _menuService;
|
|
24
|
+
constructor(_injector: Injector, _zenZoneService: IZenZoneService, _commandService: ICommandService, _menuService: IMenuService);
|
|
25
|
+
private _initialize;
|
|
26
|
+
private _initCustomComponents;
|
|
27
|
+
private _initCommands;
|
|
28
|
+
private _initMenus;
|
|
29
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { ICommandService, IUndoRedoService, IUniverInstanceService, RxDisposable } from '@univerjs/core';
|
|
17
|
+
import { DocSkeletonManagerService, DocViewModelManagerService, TextSelectionManagerService } from '@univerjs/docs';
|
|
18
|
+
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
19
|
+
import { IEditorBridgeService } from '@univerjs/sheets-ui/services/editor-bridge.service.js';
|
|
20
|
+
import { IZenZoneService } from '@univerjs/ui';
|
|
21
|
+
import { IZenEditorManagerService } from '../services/zen-editor.service';
|
|
22
|
+
export declare const DOCS_ZEN_EDITOR_UNIT_ID_KEY = "__defaultDocumentZenEditorSpecialUnitId_20231218__";
|
|
23
|
+
export declare class ZenEditorController extends RxDisposable {
|
|
24
|
+
private readonly _currentUniverService;
|
|
25
|
+
private readonly _zenEditorManagerService;
|
|
26
|
+
private readonly _renderManagerService;
|
|
27
|
+
private readonly _commandService;
|
|
28
|
+
private readonly _zenZoneService;
|
|
29
|
+
private readonly _editorBridgeService;
|
|
30
|
+
private readonly _undoRedoService;
|
|
31
|
+
private readonly _textSelectionManagerService;
|
|
32
|
+
private readonly _docSkeletonManagerService;
|
|
33
|
+
private readonly _docViewModelManagerService;
|
|
34
|
+
constructor(_currentUniverService: IUniverInstanceService, _zenEditorManagerService: IZenEditorManagerService, _renderManagerService: IRenderManagerService, _commandService: ICommandService, _zenZoneService: IZenZoneService, _editorBridgeService: IEditorBridgeService, _undoRedoService: IUndoRedoService, _textSelectionManagerService: TextSelectionManagerService, _docSkeletonManagerService: DocSkeletonManagerService, _docViewModelManagerService: DocViewModelManagerService);
|
|
35
|
+
private _initialize;
|
|
36
|
+
private _createZenEditorInstance;
|
|
37
|
+
private _syncZenEditorSize;
|
|
38
|
+
private _handleOpenZenEditor;
|
|
39
|
+
private _editorSyncHandler;
|
|
40
|
+
private _syncContentAndRender;
|
|
41
|
+
private _calculatePagePosition;
|
|
42
|
+
private _commandExecutedListener;
|
|
43
|
+
private _getDocObject;
|
|
44
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export * from './plugin';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Plugin, PluginType } from '@univerjs/core';
|
|
17
|
+
import { Injector } from '@wendellhu/redi';
|
|
18
|
+
export interface IUniverSheetsZenEditorPluginConfig {
|
|
19
|
+
}
|
|
20
|
+
export declare class UniverSheetsZenEditorPlugin extends Plugin {
|
|
21
|
+
readonly _injector: Injector;
|
|
22
|
+
static type: PluginType;
|
|
23
|
+
constructor(config: IUniverSheetsZenEditorPluginConfig, _injector: Injector);
|
|
24
|
+
private _initializeDependencies;
|
|
25
|
+
onRendered(): void;
|
|
26
|
+
onDestroy(): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { Nullable } from '@univerjs/core';
|
|
17
|
+
import type { IDisposable } from '@wendellhu/redi';
|
|
18
|
+
import type { Observable } from 'rxjs';
|
|
19
|
+
export interface IZenEditorManagerService {
|
|
20
|
+
position$: Observable<Nullable<DOMRect>>;
|
|
21
|
+
dispose(): void;
|
|
22
|
+
setPosition(param: DOMRect): void;
|
|
23
|
+
getPosition(): Readonly<Nullable<DOMRect>>;
|
|
24
|
+
}
|
|
25
|
+
export declare class ZenEditorManagerService implements IDisposable {
|
|
26
|
+
private _position;
|
|
27
|
+
private readonly _position$;
|
|
28
|
+
readonly position$: Observable<Nullable<DOMRect>>;
|
|
29
|
+
dispose(): void;
|
|
30
|
+
setPosition(param: DOMRect): void;
|
|
31
|
+
getPosition(): Readonly<Nullable<DOMRect>>;
|
|
32
|
+
private _refresh;
|
|
33
|
+
}
|
|
34
|
+
export declare const IZenEditorManagerService: import("@wendellhu/redi").IdentifierDecorator<ZenEditorManagerService>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { type IMenuButtonItem } from '@univerjs/ui';
|
|
17
|
+
export declare function ZenEditorMenuItemFactory(): IMenuButtonItem;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import React from 'react';
|
|
17
|
+
export declare const ZEN_EDITOR_COMPONENT = "ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT";
|
|
18
|
+
export declare function ZenEditor(): React.JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export { ZEN_EDITOR_COMPONENT, ZenEditor } from './ZenEditor';
|
package/lib/umd/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
(function(k,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/sheets"),require("@univerjs/ui"),require("react"),require("@wendellhu/redi/react-bindings"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/docs","@univerjs/engine-render","rxjs","@univerjs/sheets","@univerjs/ui","react","@wendellhu/redi/react-bindings","clsx"],m):(k=typeof globalThis<"u"?globalThis:k||self,m(k.UniverSheetsZenEditor={},k.UniverCore,k["@wendellhu/redi"],k.UniverDocs,k.engineRender,k.rxjs,k.UniverSheets,k.UniverUi,k.React,k["@wendellhu/redi/react-bindings"],k.clsx))})(this,function(k,m,Y,fe,_,X,A,$,Z,Ie,Be){"use strict";var xt=Object.defineProperty;var Dt=(k,m,Y)=>m in k?xt(k,m,{enumerable:!0,configurable:!0,writable:!0,value:Y}):k[m]=Y;var c=(k,m,Y)=>(Dt(k,typeof m!="symbol"?m+"":m,Y),Y);var Me;function Ge(n,e){if(n==null)return;const t=e.getRenderById(n);if(t==null)return;const{mainComponent:o,scene:i,engine:r}=t;return{document:o,scene:i,engine:r}}var O=(n=>(n.VIEW_MAIN="viewMain",n.VIEW_MAIN_LEFT_TOP="viewMainLeftTop",n.VIEW_MAIN_TOP="viewMainTop",n.VIEW_MAIN_LEFT="viewMainLeft",n.VIEW_ROW_TOP="viewRowTop",n.VIEW_ROW_BOTTOM="viewRowBottom",n.VIEW_COLUMN_LEFT="viewColumnLeft",n.VIEW_COLUMN_RIGHT="viewColumnRight",n.VIEW_LEFT_TOP="viewLeftTop",n))(O||{});const Ke=3;var qe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(n,e,t,o)=>{for(var i=o>1?void 0:o?Je(e,t):e,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=(o?s(e,t,i):s(i))||i);return o&&i&&qe(e,t,i),i},Ye=(n,e)=>(t,o)=>e(t,o,n);let Se=class{constructor(n,e){c(this,"_currentSkeleton",{unitId:"",sheetId:""});c(this,"_sheetSkeletonParam",[]);c(this,"_currentSkeleton$",new X.BehaviorSubject(null));c(this,"currentSkeleton$",this._currentSkeleton$.asObservable());c(this,"_currentSkeletonBefore$",new X.BehaviorSubject(null));c(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._currentUniverService=n,this._localeService=e}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParam=[]}getCurrent(){return this._getCurrentBySearch(this._currentSkeleton)}setCurrent(n){const e=this._getCurrentBySearch(n);if(e!=null)this._reCalculate(e);else{const{unitId:o,sheetId:i}=n,r=this._currentUniverService.getUniverSheetInstance(n.unitId),s=r==null?void 0:r.getSheetBySheetId(n.sheetId);if(s==null||r==null)return;const h=this._buildSkeleton(s,r);this._sheetSkeletonParam.push({unitId:o,sheetId:i,skeleton:h,dirty:!1})}this._currentSkeleton=n;const t=this.getCurrent();return this._currentSkeletonBefore$.next(t),this._currentSkeleton$.next(t),this.getCurrent()}reCalculate(){const n=this.getCurrent();n!=null&&this._reCalculate(n)}_reCalculate(n){n.dirty&&(n.skeleton.makeDirty(!0),n.dirty=!1),n.skeleton.calculate()}makeDirtyCurrent(n=!0){this.makeDirty(this._currentSkeleton,n)}makeDirty(n,e=!0){const t=this._getCurrentBySearch(n);t!=null&&(t.dirty=e)}_getCurrentBySearch(n){const e=this._sheetSkeletonParam.find(t=>t.unitId===n.unitId&&t.sheetId===n.sheetId);return e!=null&&(e.commandId=n.commandId),e}_buildSkeleton(n,e){const t=n.getConfig();return _.SpreadsheetSkeleton.create(n,t,n.getCellMatrix(),e.getStyles(),this._localeService)}};Se=Qe([Ye(0,m.IUniverInstanceService),Ye(1,Y.Inject(m.LocaleService))],Se);class et{constructor(){c(this,"_startColumn",-1);c(this,"_startRow",-1);c(this,"_endColumn",-1);c(this,"_endRow",-1);c(this,"_startX",0);c(this,"_startY",0);c(this,"_endX",0);c(this,"_endY",0);c(this,"_currentCell");c(this,"_rangeType",m.RANGE_TYPE.NORMAL)}get startColumn(){return this._startColumn}get startRow(){return this._startRow}get endColumn(){return this._endColumn}get endRow(){return this._endRow}get startX(){return this._startX}get startY(){return this._startY}get endX(){return this._endX}get endY(){return this._endY}get currentCell(){return this._currentCell}get rangeType(){return this._rangeType}isEqual(e){const{startColumn:t,startRow:o,endColumn:i,endRow:r}=this,{startColumn:s,startRow:h,endColumn:a,endRow:l}=e;return t===s&&o===h&&i===a&&r===l}isInclude(e){const{startColumn:t,startRow:o,endColumn:i,endRow:r}=this,{startColumn:s,startRow:h,endColumn:a,endRow:l}=e;return!(a<t||s>i||h>r||l<o)}highlightToSelection(){return m.makeCellToSelection(this._currentCell)}getRange(){return{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this.rangeType}}getCell(){return this._currentCell}getRangeType(){return this._rangeType}getValue(){return{rangeWithCoord:{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this._rangeType},primaryWithCoord:this._currentCell}}setValue(e,t){const{startColumn:o,startRow:i,endColumn:r,endRow:s,startX:h,startY:a,endX:l,endY:g,rangeType:C}=e;this._startColumn=o,this._startRow=i,this._endColumn=r,this._endRow=s,this._startX=h,this._startY=a,this._endX=l,this._endY=g,C!=null&&(this._rangeType=C),this.setCurrentCell(t)}setCurrentCell(e){e&&(this._currentCell=e)}clearCurrentCell(){this._currentCell=null}}const He=.3;class Ne{constructor(e,t,o=!0,i){c(this,"_leftControl");c(this,"_rightControl");c(this,"_topControl");c(this,"_bottomControl");c(this,"_backgroundControlTop");c(this,"_backgroundControlBottom");c(this,"_backgroundControlMiddleLeft");c(this,"_backgroundControlMiddleRight");c(this,"_fillControl");c(this,"_selectionShape");c(this,"_rowHeaderBackground");c(this,"_rowHeaderBorder");c(this,"_rowHeaderGroup");c(this,"_rowHeaderHighlight");c(this,"_columnHeaderBackground");c(this,"_columnHeaderBorder");c(this,"_columnHeaderGroup");c(this,"_columnHeaderHighlight");c(this,"_topLeftWidget");c(this,"_topCenterWidget");c(this,"_topRightWidget");c(this,"_middleLeftWidget");c(this,"_middleRightWidget");c(this,"_bottomLeftWidget");c(this,"_bottomCenterWidget");c(this,"_bottomRightWidget");c(this,"_dashRect");c(this,"_selectionModel");c(this,"_selectionStyle");c(this,"_rowHeaderWidth",0);c(this,"_columnHeaderHeight",0);c(this,"_widgetRects",[]);c(this,"_dispose$",new X.BehaviorSubject(this));c(this,"dispose$",this._dispose$.asObservable());c(this,"selectionMoving$",new X.Subject);c(this,"selectionMoved$",new X.Subject);c(this,"selectionScaling$",new X.Subject);c(this,"selectionScaled$",new X.Subject);c(this,"selectionFilling$",new X.Subject);c(this,"_selectionFilled$",new X.Subject);c(this,"selectionFilled$",this._selectionFilled$.asObservable());c(this,"_defaultStyle");c(this,"_isHelperSelection",!0);this._scene=e,this._zIndex=t,this._isHeaderHighlight=o,this._themeService=i,this._initialize()}get zIndex(){return this._zIndex}get leftControl(){return this._leftControl}get rightControl(){return this._rightControl}get topControl(){return this._topControl}get bottomControl(){return this._bottomControl}get fillControl(){return this._fillControl}get backgroundControlTop(){return this._backgroundControlTop}get backgroundControlBottom(){return this._backgroundControlBottom}get backgroundControlMiddleLeft(){return this._backgroundControlMiddleLeft}get backgroundControlMiddleRight(){return this._backgroundControlMiddleRight}get selectionShape(){return this._selectionShape}get model(){return this._selectionModel}get topLeftWidget(){return this._topLeftWidget}get topCenterWidget(){return this._topCenterWidget}get topRightWidget(){return this._topRightWidget}get middleLeftWidget(){return this._middleLeftWidget}get middleRightWidget(){return this._middleRightWidget}get bottomLeftWidget(){return this._bottomLeftWidget}get bottomCenterWidget(){return this._bottomCenterWidget}get bottomRightWidget(){return this._bottomRightWidget}get selectionStyle(){return this._selectionStyle}get dashRect(){return this._dashRect}get isHelperSelection(){return this._isHelperSelection}setEvent(e){this.leftControl.evented=e,this.rightControl.evented=e,this.topControl.evented=e,this.bottomControl.evented=e}enableHeaderHighlight(){this._isHelperSelection=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}refreshSelectionFilled(e){this._selectionFilled$.next(e)}updateStyle(e){this._updateControl(e,this._rowHeaderWidth,this._columnHeaderHeight)}update(e,t=0,o=0,i,r){this._selectionModel.setValue(e,r),i==null&&(i=this._selectionStyle),this._updateControl(i,t,o)}clearHighlight(){this._selectionModel.clearCurrentCell(),this._updateControl(this._selectionStyle,this._rowHeaderWidth,this._columnHeaderHeight)}getScene(){return this._scene}dispose(){var e,t,o,i,r,s,h,a,l,g,C,u,f,d,S,v,p,w,E,R,b,T,L,M,B;(e=this._leftControl)==null||e.dispose(),(t=this._rightControl)==null||t.dispose(),(o=this._topControl)==null||o.dispose(),(i=this._bottomControl)==null||i.dispose(),(r=this._backgroundControlTop)==null||r.dispose(),(s=this._backgroundControlMiddleLeft)==null||s.dispose(),(h=this._backgroundControlMiddleRight)==null||h.dispose(),(a=this._backgroundControlBottom)==null||a.dispose(),(l=this._fillControl)==null||l.dispose(),(g=this._selectionShape)==null||g.dispose(),(C=this._rowHeaderBackground)==null||C.dispose(),(u=this._rowHeaderBorder)==null||u.dispose(),(f=this._rowHeaderGroup)==null||f.dispose(),(d=this._rowHeaderBackground)==null||d.dispose(),(S=this._columnHeaderBackground)==null||S.dispose(),(v=this._columnHeaderBorder)==null||v.dispose(),(p=this._columnHeaderGroup)==null||p.dispose(),(w=this._topLeftWidget)==null||w.dispose(),(E=this._topCenterWidget)==null||E.dispose(),(R=this._topRightWidget)==null||R.dispose(),(b=this._middleLeftWidget)==null||b.dispose(),(T=this._middleRightWidget)==null||T.dispose(),(L=this._bottomLeftWidget)==null||L.dispose(),(M=this._bottomCenterWidget)==null||M.dispose(),(B=this._bottomRightWidget)==null||B.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let t;if(e.isMerged){const o=e.mergeInfo;t={startRow:o.startRow,endRow:o.endRow,startColumn:o.startColumn,endColumn:o.endColumn,startX:o.startX,endX:o.endX,startY:o.startY,endY:o.endY}}else{const{actualRow:o,actualColumn:i,startX:r,endX:s,startY:h,endY:a}=e;t={startRow:o,endRow:o,startColumn:i,endColumn:i,startX:r,endX:s,startY:h,endY:a}}return t}}getValue(){return{...this._selectionModel.getValue(),style:this._selectionStyle}}getRange(){return this._selectionModel.getValue().rangeWithCoord}enableHelperSelection(){this._isHelperSelection=!0}disableHelperSelection(){this._isHelperSelection=!1}updateStyleId(e){this._selectionStyle!=null&&(this._selectionStyle.id=e)}_updateControl(e,t,o){const{startX:i,startY:r,endX:s,endY:h}=this._selectionModel,a=this._defaultStyle;e==null&&(e=a);const{stroke:l=a.stroke,widgets:g=a.widgets,hasAutoFill:C=a.hasAutoFill,AutofillStroke:u=a.AutofillStroke,strokeDash:f}=e;let{strokeWidth:d=a.strokeWidth,AutofillSize:S=a.AutofillSize,AutofillStrokeWidth:v=a.AutofillStrokeWidth}=e;const p=this._getScale(),w=(d+A.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/p;d/=p,S/=p,v/=p<1?1:p;const E=A.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/p,R=_.FIX_ONE_PIXEL_BLUR_OFFSET/p;this.leftControl.transformByState({height:h-r,left:-w+R,width:d,strokeWidth:E,top:-E/2+R}),this.leftControl.setProps({fill:l,stroke:A.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:h-r,left:s-i-w+R,width:d,strokeWidth:E,top:-E/2+R}),this.rightControl.setProps({fill:l,stroke:A.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:s-i+d,top:-w+R,left:-w+R,height:d,strokeWidth:E}),this.topControl.setProps({fill:l,stroke:A.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:s-i+d,top:h-r-w+R,height:d,left:-w+R,strokeWidth:E}),this.bottomControl.setProps({fill:l,stroke:A.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),f==null?this.dashRect.hide():(this.dashRect.transformByState({height:h-r-d/2,width:s-i-d/2,strokeWidth:d,left:d/2-1/p,top:d/2-1/p}),this.dashRect.setProps({strokeDashArray:[0,f]}),this.dashRect.show()),C===!0&&!this._hasWidgets(g)?(this.fillControl.setProps({fill:l,stroke:u,strokeScaleEnabled:!1}),this.fillControl.transformByState({width:S-v,height:S-v,left:s-i-S/2+v/2,top:h-r-S/2+v/2,strokeWidth:v}),this.fillControl.show()):this.fillControl.hide(),this._updateBackgroundControl(e),this._updateBackgroundTitle(e,t,o),this._updateWidgets(e),this.selectionShape.show(),this.selectionShape.translate(i,r),this._selectionStyle=e,this._rowHeaderWidth=t||0,this._columnHeaderHeight=o||0,this.selectionShape.makeDirtyNoDebounce(!0)}_initialize(){this._defaultStyle=A.getNormalSelectionStyle(this._themeService),this._selectionModel=new et;const e=this._zIndex;this._leftControl=new _.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightControl=new _.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topControl=new _.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomControl=new _.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new _.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new _.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new _.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new _.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._fillControl=new _.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._dashRect=new _.Rect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const t=[this._fillControl,this._leftControl,this._rightControl,this._topControl,this._bottomControl,this._backgroundControlTop,this._backgroundControlMiddleLeft,this._backgroundControlMiddleRight,this._backgroundControlBottom,this._dashRect];this._widgetRects=this._initialWidget(),this._selectionShape=new _.Group("__SpreadsheetSelectionShape__"+e,...t,...this._widgetRects),this._selectionShape.hide(),this._selectionShape.evented=!1,this._selectionShape.zIndex=e,this.getScene().addObject(this._selectionShape,Ke),this._initialTitle()}_initialTitle(){const e=this._zIndex;this._rowHeaderBackground=new _.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new _.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new _.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new _.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new _.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new _.Group("__SpreadSheetSelectionColumnHeaderGroup__"+e,this._columnHeaderBackground,this._columnHeaderBorder),this._columnHeaderGroup.hide(),this._columnHeaderGroup.evented=!1,this._columnHeaderGroup.zIndex=e,this.getScene().addObjects([this._rowHeaderGroup,this._columnHeaderGroup],_.DEFAULT_SELECTION_LAYER_INDEX)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new _.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new _.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new _.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new _.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new _.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new _.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new _.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new _.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}_updateBackgroundTitle(e,t,o){const{startX:i,startY:r,endX:s,endY:h,rangeType:a}=this._selectionModel,l=this._defaultStyle;e==null&&(e=l);const g=this._getScale(),{stroke:C,hasRowHeader:u,rowHeaderFill:f=l.rowHeaderFill,rowHeaderStroke:d=l.rowHeaderStroke,hasColumnHeader:S,columnHeaderFill:v=l.columnHeaderFill,columnHeaderStroke:p=l.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:w=l.rowHeaderStrokeWidth,columnHeaderStrokeWidth:E=l.columnHeaderStrokeWidth}=e;if(w/=g,E/=g,S===!0){let R=v;this._isHeaderHighlight&&a===m.RANGE_TYPE.COLUMN&&(R=new m.ColorKit(C).setAlpha(He).toString()),this._columnHeaderBackground.setProps({fill:R}),this._columnHeaderBackground.resize(s-i,o),this._columnHeaderBorder.setProps({fill:p}),this._columnHeaderBorder.transformByState({width:s-i,height:E,top:o-E+1/g}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(i,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),u===!0){let R=f;this._isHeaderHighlight&&a===m.RANGE_TYPE.ROW&&(R=new m.ColorKit(C).setAlpha(He).toString()),this._rowHeaderBackground.setProps({fill:R}),this._rowHeaderBackground.resize(t,h-r),this._rowHeaderBorder.setProps({fill:d}),this._rowHeaderBorder.transformByState({width:w,height:h-r,left:t-w+1/g}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,r)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:t,startY:o,endX:i,endY:r}=this._selectionModel,s=this._defaultStyle;e==null&&(e=s);const h=this._getScale(),{fill:a=s.fill}=e;let{strokeWidth:l=s.strokeWidth}=e;l/=h;const g=this._selectionModel.highlightToSelection();if(!g){this._backgroundControlTop.resize(i-t,r-o),this._backgroundControlTop.setProps({fill:a}),this._backgroundControlBottom.resize(0,0),this._backgroundControlMiddleLeft.resize(0,0),this._backgroundControlMiddleRight.resize(0,0);return}const{startX:C,startY:u,endX:f,endY:d}=g,S=l/2,v={left:-S,top:-S,width:i-t+S*2,height:u-o+S};v.height<0&&(v.width=0,v.height=0),this._backgroundControlTop.transformByState(v);const p={left:-S,top:u-o,width:C-t+S,height:d-u};p.width<0&&(p.width=0,p.height=0),this._backgroundControlMiddleLeft.transformByState(p);const w={left:f-t-S,top:u-o,width:i-f+S*2,height:d-u};w.width<0&&(w.width=0,w.height=0),this._backgroundControlMiddleRight.transformByState(w);const E={left:-S,top:d-o,width:i-t+S*2,height:r-d+S};E.height<0&&(E.width=0,E.height=0),this._backgroundControlBottom.transformByState(E),this._backgroundControlTop.setProps({fill:a}),this._backgroundControlMiddleLeft.setProps({fill:a}),this._backgroundControlMiddleRight.setProps({fill:a}),this._backgroundControlBottom.setProps({fill:a})}_updateWidgets(e){const{startX:t,startY:o,endX:i,endY:r}=this._selectionModel,s=this._defaultStyle;e==null&&(e=s);const{stroke:h=s.stroke,widgets:a=s.widgets,widgetStroke:l=s.widgetStroke}=e,g=this._getScale();let{widgetSize:C=s.widgetSize,widgetStrokeWidth:u=s.widgetStrokeWidth}=e;C/=g,u/=g;const f={left:-C/2+u/2,center:(i-t)/2-C/2+u/2,right:i-t-C/2+u/2,top:-C/2,middle:(r-o)/2-C/2,bottom:r-o-C/2+u/2},d=C-u;this._widgetRects.forEach(S=>{S.setProps({fill:h,stroke:l})}),a.tl===!0?(this._topLeftWidget.transformByState({height:d,width:d,left:f.left,top:f.top,strokeWidth:u}),this._topLeftWidget.show()):this._topLeftWidget.hide(),a.tc===!0?(this._topCenterWidget.transformByState({height:d,width:d,left:f.center,top:f.top,strokeWidth:u}),this._topCenterWidget.show()):this._topCenterWidget.hide(),a.tr===!0?(this._topRightWidget.transformByState({height:d,width:d,left:f.right,top:f.top,strokeWidth:u}),this._topRightWidget.show()):this._topRightWidget.hide(),a.ml===!0?(this._middleLeftWidget.transformByState({height:d,width:d,left:f.left,top:f.middle,strokeWidth:u}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),a.mr===!0?(this._middleRightWidget.transformByState({height:d,width:d,left:f.right,top:f.middle,strokeWidth:u}),this._middleRightWidget.show()):this._middleRightWidget.hide(),a.bl===!0?(this._bottomLeftWidget.transformByState({height:d,width:d,left:f.left,top:f.bottom,strokeWidth:u}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),a.bc===!0?(this._bottomCenterWidget.transformByState({height:d,width:d,left:f.center,top:f.bottom,strokeWidth:u}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),a.br===!0?(this._bottomRightWidget.transformByState({height:d,width:d,left:f.right,top:f.bottom,strokeWidth:u}),this._bottomRightWidget.show()):this._bottomRightWidget.hide()}_hasWidgets(e){if(e==null)return!1;const t=Object.keys(e);if(t.length===0)return!1;for(const o of t)if(e[o]===!0)return!0;return!0}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}}const Xe="__SpreadsheetHelperSelectionTempRect",tt=35;class xe{constructor(e,t,o,i,r){c(this,"_startOffsetX",0);c(this,"_startOffsetY",0);c(this,"_relativeSelectionPositionRow",0);c(this,"_relativeSelectionPositionColumn",0);c(this,"_relativeSelectionRowLength",0);c(this,"_relativeSelectionColumnLength",0);c(this,"_moveObserver");c(this,"_upObserver");c(this,"_helperSelection");c(this,"_scrollTimer");c(this,"_activeViewport");c(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});c(this,"_isInMergeState",!1);c(this,"_fillControlColors",[]);this._control=e,this._skeleton=t,this._scene=o,this._themeService=i,this._injector=r,this._initialControl(),this._initialWidget(),this._initialFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var e,t;(e=this._scrollTimer)==null||e.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(t=this._helperSelection)==null||t.dispose()}_getFreeze(){var t;return(t=this._injector.get(Se).getCurrent())==null?void 0:t.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(e,t){const o=this._getFreeze()||{startRow:-1,startColumn:-1,xSplit:0,ySplit:0};switch(t.viewPortKey){case O.VIEW_MAIN:return e.endRow>=o.startRow&&e.endColumn>=o.startColumn;case O.VIEW_MAIN_TOP:case O.VIEW_COLUMN_RIGHT:return e.endColumn>=o.startColumn&&e.startRow<o.startRow;case O.VIEW_MAIN_LEFT:case O.VIEW_ROW_BOTTOM:return e.endRow>=o.startRow&&e.startColumn<o.startColumn;case O.VIEW_MAIN_LEFT_TOP:case O.VIEW_COLUMN_LEFT:case O.VIEW_ROW_TOP:case O.VIEW_LEFT_TOP:return e.startRow<o.startRow&&e.startColumn<o.startColumn}}_clearObserverEvent(){this._scene.onPointerMoveObserver.remove(this._moveObserver),this._scene.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_initialControl(){const{leftControl:e,rightControl:t,topControl:o,bottomControl:i}=this._control;[e,t,o,i].forEach(r=>{r.onPointerEnterObserver.add(()=>{r.setCursor(_.CURSOR_TYPE.MOVE)}),r.onPointerLeaveObserver.add(()=>{r.resetCursor()}),r.onPointerDownObserver.add(this._controlEvent.bind(this))})}_controlMoving(e,t){var T;const o=this._scene,i=o.getScrollXYByRelativeCoords(_.Vector2.FromArray([e,t])),{scaleX:r,scaleY:s}=o.getAncestorScale(),h=this._skeleton.getCellPositionByOffset(e,t,r,s,i),{row:a,column:l}=h,g=this._skeleton.getRowCount()-1,C=this._skeleton.getColumnCount()-1;let u=a+this._relativeSelectionPositionRow;u<0&&(u=0);let f=u+this._relativeSelectionRowLength;f>g&&(f=g,f-u<this._relativeSelectionRowLength&&(u=f-this._relativeSelectionRowLength));let d=l+this._relativeSelectionPositionColumn;d<0&&(d=0);let S=d+this._relativeSelectionColumnLength;S>C&&(S=C,S-d<this._relativeSelectionColumnLength&&(d=S-this._relativeSelectionColumnLength));const v=this._skeleton.getNoMergeCellPositionByIndex(u,d),p=this._skeleton.getNoMergeCellPositionByIndex(f,S),w=(v==null?void 0:v.startY)||0,E=(p==null?void 0:p.endY)||0,R=(v==null?void 0:v.startX)||0,b=(p==null?void 0:p.endX)||0;(T=this._helperSelection)==null||T.transformByState({left:R,top:w,width:b-R,height:E-w}),this._targetSelection={startY:w,endY:E,startX:R,endX:b,startRow:u,endRow:f,startColumn:d,endColumn:S},this._control.selectionMoving$.next(this._targetSelection)}_controlEvent(e){const{offsetX:t,offsetY:o}=e,i=this._scene,r=i.getRelativeCoord(_.Vector2.FromArray([t,o])),{x:s,y:h}=r,a=i.getScrollXYByRelativeCoords(r),{scaleX:l,scaleY:g}=i.getAncestorScale(),C=this._skeleton.getCellPositionByOffset(s,h,l,g,a);this._startOffsetX=s,this._startOffsetY=h;const{row:u,column:f}=C,{startRow:d,startColumn:S,endRow:v,endColumn:p}=this._control.model;let w=0,E=0;u<d?w-=1:u>v&&(w+=1),f<S?E-=1:f>p&&(E+=1),this._relativeSelectionPositionRow=d-u+w,this._relativeSelectionPositionColumn=S-f+E,this._relativeSelectionRowLength=v-d,this._relativeSelectionColumnLength=p-S;const R=this._control.selectionStyle,b=this._getScale();this.isHelperSelection&&(this._helperSelection=new _.Rect(Xe,{stroke:R.stroke,strokeWidth:R.strokeWidth/b}),i.addObject(this._helperSelection));const T=i.getViewport(O.VIEW_MAIN),L=_.ScrollTimer.create(i);L.startScroll(s,h,T),this._scrollTimer=L,i.disableEvent(),this._moveObserver=i.onPointerMoveObserver.add(M=>{const{offsetX:B,offsetY:W}=M,{x:y,y:N}=i.getRelativeCoord(_.Vector2.FromArray([B,W]));this._controlMoving(y,N),i.setCursor(_.CURSOR_TYPE.MOVE),L.scrolling(y,N,()=>{this._controlMoving(y,N)})}),this._upObserver=i.onPointerUpObserver.add(()=>{var B,W;(B=this._helperSelection)==null||B.dispose();const M=this._scene;M.resetCursor(),this._clearObserverEvent(),M.enableEvent(),(W=this._scrollTimer)==null||W.dispose(),this._control.selectionMoved$.next(this._targetSelection)})}_initialWidget(){const{topLeftWidget:e,topCenterWidget:t,topRightWidget:o,middleLeftWidget:i,middleRightWidget:r,bottomLeftWidget:s,bottomCenterWidget:h,bottomRightWidget:a}=this._control,l=[_.CURSOR_TYPE.NORTH_WEST_RESIZE,_.CURSOR_TYPE.NORTH_RESIZE,_.CURSOR_TYPE.NORTH_EAST_RESIZE,_.CURSOR_TYPE.WEST_RESIZE,_.CURSOR_TYPE.EAST_RESIZE,_.CURSOR_TYPE.SOUTH_WEST_RESIZE,_.CURSOR_TYPE.SOUTH_RESIZE,_.CURSOR_TYPE.SOUTH_EAST_RESIZE];[e,t,o,i,r,s,h,a].forEach((g,C)=>{g.onPointerEnterObserver.add(()=>{g.setCursor(l[C])}),g.onPointerLeaveObserver.add(()=>{g.resetCursor()}),g.onPointerDownObserver.add(u=>{this._widgetEvent(u,l[C])})})}_widgetMoving(e,t,o){const i=this._scene,r=i.getScrollXYByRelativeCoords(_.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:h}=i.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(e,t,s,h,r),{row:l,column:g}=a,{rowHeaderWidth:C,columnHeaderHeight:u}=this._skeleton;let f=this._relativeSelectionPositionRow,d=this._relativeSelectionPositionColumn,S=l,v=g;o===_.CURSOR_TYPE.NORTH_WEST_RESIZE?(f=l,d=g,S=this._relativeSelectionPositionRow,v=this._relativeSelectionPositionColumn):o===_.CURSOR_TYPE.NORTH_RESIZE?(f=l,d=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):o===_.CURSOR_TYPE.NORTH_EAST_RESIZE?(f=l,d=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,v=g):o===_.CURSOR_TYPE.WEST_RESIZE?(f=this._relativeSelectionPositionRow,d=g,S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,v=this._relativeSelectionPositionColumn):o===_.CURSOR_TYPE.EAST_RESIZE?S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:o===_.CURSOR_TYPE.SOUTH_WEST_RESIZE?(f=this._relativeSelectionPositionRow,d=g,S=l,v=this._relativeSelectionPositionColumn):o===_.CURSOR_TYPE.SOUTH_RESIZE&&(f=this._relativeSelectionPositionRow,d=this._relativeSelectionPositionColumn,S=l,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const{startRow:p,startColumn:w,endRow:E,endColumn:R}=this._swapPositions(f,d,S,v),b=this._skeleton.getNoMergeCellPositionByIndex(p,w),T=this._skeleton.getNoMergeCellPositionByIndex(E,R),L=(b==null?void 0:b.startY)||0,M=(T==null?void 0:T.endY)||0,B=(b==null?void 0:b.startX)||0,W=(T==null?void 0:T.endX)||0;this._targetSelection={startY:L,endY:M,startX:B,endX:W,startRow:f,endRow:S,startColumn:d,endColumn:v},this._control.update(this._targetSelection,C,u,this._control.selectionStyle),this._control.clearHighlight(),this._control.selectionScaling$.next(this._targetSelection)}_widgetEvent(e,t){const{offsetX:o,offsetY:i}=e,r=this._scene,s=r.getRelativeCoord(_.Vector2.FromArray([o,i])),{x:h,y:a}=s;this._startOffsetX=o,this._startOffsetY=i;const{startRow:l,startColumn:g,endRow:C,endColumn:u}=this._control.model;this._relativeSelectionPositionRow=l,this._relativeSelectionPositionColumn=g,this._relativeSelectionRowLength=C-l,this._relativeSelectionColumnLength=u-g,t===_.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=C,this._relativeSelectionPositionColumn=u):t===_.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=C:t===_.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=C:t===_.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=u:t===_.CURSOR_TYPE.SOUTH_WEST_RESIZE&&(this._relativeSelectionPositionColumn=u);const f=_.ScrollTimer.create(r);f.startScroll(h,a),this._scrollTimer=f,r.disableEvent(),this._moveObserver=r.onPointerMoveObserver.add(d=>{const{offsetX:S,offsetY:v}=d,{x:p,y:w}=r.getRelativeCoord(_.Vector2.FromArray([S,v]));this._widgetMoving(p,w,t),r.setCursor(t),f.scrolling(p,w,()=>{this._widgetMoving(p,w,t)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var S;const d=this._scene;d.resetCursor(),this._clearObserverEvent(),d.enableEvent(),(S=this._scrollTimer)==null||S.dispose(),this._control.selectionScaled$.next(this._targetSelection)})}_initialFill(){const{fillControl:e}=this._control;e.onPointerEnterObserver.add(()=>{e.setCursor(_.CURSOR_TYPE.CROSSHAIR)}),e.onPointerLeaveObserver.add(()=>{e.resetCursor()}),e.onPointerDownObserver.add(this._fillEvent.bind(this))}_fillMoving(e,t){var W,y,N;const o=this._scene,i=o.getScrollXY(this._activeViewport),{scaleX:r,scaleY:s}=o.getAncestorScale(),h=this._skeleton.getCellPositionByOffset(e,t,r,s,i),{row:a,column:l}=h,g=o.getRelativeCoord(_.Vector2.FromArray([e,t])),C=this._skeleton.getRowCount()-1,u=this._skeleton.getColumnCount()-1;let f=this._relativeSelectionPositionRow,d=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,p=!1,w=!0;if((l<d||l>v)&&a>=f&&a<=S){const I=this._fillRuler(l,d,v,this._relativeSelectionColumnLength,u);d=I.startRowOrColumn,v=I.endRowOrColumn,p=I.isLighten,w=!1}else if((a<f||a>S)&&l>=d&&l<=v){const I=this._fillRuler(a,f,S,this._relativeSelectionRowLength,C);f=I.startRowOrColumn,S=I.endRowOrColumn,p=I.isLighten}else if(Math.abs(this._startOffsetX-g.x-i.x)/2>Math.abs(this._startOffsetY-g.y-i.y)){const I=this._fillRuler(l,d,v,this._relativeSelectionColumnLength,u);d=I.startRowOrColumn,v=I.endRowOrColumn,p=I.isLighten,w=!1}else{const I=this._fillRuler(a,f,S,this._relativeSelectionRowLength,C);f=I.startRowOrColumn,S=I.endRowOrColumn,p=I.isLighten}const E=this._skeleton.getNoMergeCellPositionByIndex(f,d),R=this._skeleton.getNoMergeCellPositionByIndex(S,v),b=(E==null?void 0:E.startY)||0,T=(R==null?void 0:R.endY)||0,L=(E==null?void 0:E.startX)||0,M=(R==null?void 0:R.endX)||0;p?this._controlHandler((I,P)=>{const z=new m.ColorKit(this._fillControlColors[P]).lighten(tt).toRgbString();I.setProps({fill:z})}):this._controlHandler((I,P)=>{I.setProps({fill:this._fillControlColors[P]})});const B=A.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();f===S&&w===!0||d===v&&w===!1?(W=this._helperSelection)==null||W.hide():((y=this._helperSelection)==null||y.transformByState({left:L-B/2,top:b-B/2,width:M-L,height:T-b}),(N=this._helperSelection)==null||N.show()),this._targetSelection={startY:b,endY:T,startX:L,endX:M,startRow:f,endRow:S,startColumn:d,endColumn:v},this._control.selectionFilling$.next(this._targetSelection)}_fillEvent(e){const{offsetX:t,offsetY:o}=e,i=this._scene,r=i.getRelativeCoord(_.Vector2.FromArray([t,o])),{x:s,y:h}=r;this._startOffsetX=s,this._startOffsetY=h;const{startRow:a,startColumn:l,endRow:g,endColumn:C}=this._control.model;this._isInMergeState=this._hasMergeInRange(a,l,g,C),this._relativeSelectionPositionRow=a,this._relativeSelectionPositionColumn=l,this._relativeSelectionRowLength=g-a,this._relativeSelectionColumnLength=C-l;const u=this._control.selectionStyle;let f=u==null?void 0:u.stroke,d=u==null?void 0:u.strokeWidth;const S=A.getNormalSelectionStyle(this._themeService);f==null&&(f=S.stroke),d==null&&(d=S.strokeWidth);const v=this._getScale();d/=v;const p=A.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/v,w=new m.ColorKit(f).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new _.Rect(Xe,{stroke:w,strokeWidth:d+p/2}),i.addObject(this._helperSelection)),this._activeViewport=i.getActiveViewportByCoord(_.Vector2.FromArray([t,o]));const E=i.getViewport(O.VIEW_MAIN),R=_.ScrollTimer.create(i,this._activeViewport.viewPortKey===O.VIEW_MAIN?_.ScrollTimerType.ALL:_.ScrollTimerType.NONE);R.startScroll(s,h,E),this._scrollTimer=R,i.disableEvent(),this._controlHandler(b=>{this._fillControlColors.push(b.fill)}),this._moveObserver=i.onPointerMoveObserver.add(b=>{var N;const{offsetX:T,offsetY:L}=b,M=i.getActiveViewportByCoord(_.Vector2.FromArray([T,L])),{x:B,y:W}=i.getRelativeCoord(_.Vector2.FromArray([T,L]));this._fillMoving(B,W),i.setCursor(_.CURSOR_TYPE.CROSSHAIR);const y=this._targetSelection;if(E&&M&&((N=this._activeViewport)==null?void 0:N.viewPortKey)!==(M==null?void 0:M.viewPortKey)){let I;y.startRow!==a?(R.scrollTimerType=_.ScrollTimerType.Y,I={...y,endRow:y.startRow}):y.endRow!==g?(R.scrollTimerType=_.ScrollTimerType.Y,I={...y,startRow:y.endRow}):y.startColumn!==l?(R.scrollTimerType=_.ScrollTimerType.X,I={...y,endColumn:y.startColumn}):(R.scrollTimerType=_.ScrollTimerType.X,I={...y,startColumn:y.endColumn}),this._isSelectionInViewport(I,M)&&(E.scrollTo({x:R.scrollTimerType===_.ScrollTimerType.X?0:void 0,y:R.scrollTimerType===_.ScrollTimerType.Y?0:void 0}),this._activeViewport=M)}R.scrolling(B,W,()=>{this._fillMoving(B,W)})}),this._upObserver=i.onPointerUpObserver.add(()=>{var T,L;(T=this._helperSelection)==null||T.dispose();const b=this._scene;b.resetCursor(),this._clearObserverEvent(),b.enableEvent(),(L=this._scrollTimer)==null||L.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((M,B)=>{M.setProps({fill:this._fillControlColors[B]})}),this._fillControlColors=[]})}_hasMergeInRange(e,t,o,i){const r=this._skeleton.mergeData;if(!r)return!1;for(const s of r){const{startRow:h,startColumn:a,endRow:l,endColumn:g}=s,C={left:t,top:e,right:i,bottom:o},u={left:a,top:h,right:g,bottom:l};if(_.isRectIntersect(C,u))return!0}return!1}_swapPositions(e,t,o,i){const r=Math.min(e,o),s=Math.min(t,i),h=Math.max(e,o),a=Math.max(t,i);return{startRow:r,startColumn:s,endRow:h,endColumn:a}}_controlHandler(e){const{leftControl:t,rightControl:o,topControl:i,bottomControl:r,backgroundControlTop:s,backgroundControlMiddleLeft:h,backgroundControlMiddleRight:a,backgroundControlBottom:l,fillControl:g}=this._control,C=[t,o,i,r,s,h,a,l,g];for(let u=0,f=C.length;u<f;u++){const d=C[u];e(d,u)}}_fillRuler(e,t,o,i,r){let s=!1;if(e<t)if(this._isInMergeState&&e<t){const h=t-e,a=i+1,l=Math.ceil(h/a);let g=t-l*a;g<0&&(g=t-(l-1)*a),t=g}else t=e;else if(e>=t&&e<=o)s=!0,o=e;else if(this._isInMergeState&&e>o){const h=e-o,a=i+1,l=Math.ceil(h/a);let g=o+l*a;g>r&&(g=o+(l-1)*a),o=g}else o=e;return{rowOrColumn:e,startRowOrColumn:t,endRowOrColumn:o,isLighten:s}}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}}var ot=Object.defineProperty,it=Object.getOwnPropertyDescriptor,nt=(n,e,t,o)=>{for(var i=o>1?void 0:o?it(e,t):e,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=(o?s(e,t,i):s(i))||i);return o&&i&&ot(e,t,i),i},me=(n,e)=>(t,o)=>e(t,o,n);let De=class{constructor(n,e,t,o){c(this,"hasSelection",!1);c(this,"_downObserver");c(this,"_moveObserver");c(this,"_upObserver");c(this,"_controlFillConfig$",new X.BehaviorSubject(null));c(this,"controlFillConfig$",this._controlFillConfig$.asObservable());c(this,"_selectionControls",[]);c(this,"_startSelectionRange",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});c(this,"_startOffsetX",0);c(this,"_startOffsetY",0);c(this,"_scrollTimer");c(this,"_cancelDownObserver");c(this,"_cancelUpObserver");c(this,"_skeleton");c(this,"_scene");c(this,"_isHeaderHighlight",!0);c(this,"_isDetectMergedCell",!0);c(this,"_selectionStyle");c(this,"_isSelectionEnabled",!0);c(this,"_isShowPreviousEnable",0);c(this,"_isRemainLastEnable",!0);c(this,"_isSkipRemainLastEnable",!1);c(this,"_selectionMoveEnd$",new X.BehaviorSubject([]));c(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());c(this,"_selectionMoving$",new X.Subject);c(this,"selectionMoving$",this._selectionMoving$.asObservable());c(this,"_selectionMoveStart$",new X.Subject);c(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());c(this,"_activeViewport");this._themeService=n,this._shortcutService=e,this._sheetSkeletonManagerService=t,this._injector=o,this._selectionStyle=A.getNormalSelectionStyle(this._themeService)}enableHeaderHighlight(){this._isHeaderHighlight=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}enableDetectMergedCell(){this._isDetectMergedCell=!0}disableDetectMergedCell(){this._isDetectMergedCell=!1}setStyle(n){this._selectionStyle=n}resetStyle(){this.setStyle(A.getNormalSelectionStyle(this._themeService))}enableSelection(){this._isSelectionEnabled=!0}disableSelection(){this._isSelectionEnabled=!1}enableShowPrevious(){this._isShowPreviousEnable=!0}disableShowPrevious(){this._isShowPreviousEnable=!1}enableRemainLast(){this._isRemainLastEnable=!0}disableRemainLast(){this._isRemainLastEnable=!1}enableSkipRemainLast(){this._isSkipRemainLastEnable=!0}disableSkipRemainLast(){this._isSkipRemainLastEnable=!1}getViewPort(){return this._activeViewport}addControlToCurrentByRangeData(n){const e=this.getCurrentControls();if(!e)return;const{rangeWithCoord:t,primaryWithCoord:o}=n,i=this._skeleton;let r=n.style;r==null&&(r=A.getNormalSelectionStyle(this._themeService));const s=this._scene;if(s==null||i==null)return;const h=new Ne(s,e.length,this._isHeaderHighlight,this._themeService);new xe(h,i,s,this._themeService,this._injector);const{rowHeaderWidth:a,columnHeaderHeight:l}=i;h.update(t,a,l,r,o),this._isHeaderHighlight?h.enableHeaderHighlight():h.disableHeaderHighlight(),e.push(h)}updateControlForCurrentByRangeData(n){const e=this.getCurrentControls();if(!e)return;const t=this._skeleton;if(t==null)return;const{rowHeaderWidth:o,columnHeaderHeight:i}=t;for(let r=0,s=n.length;r<s;r++){const{rangeWithCoord:h,primaryWithCoord:a,style:l}=n[r];e[r].update(h,o,i,l,a)}}refreshSelectionMoveStart(){this._selectionMoveStart$.next(this.getSelectionDataWithStyle())}changeRuntime(n,e,t){this._skeleton=n,this._scene=e,this._activeViewport=t||e.getViewports()[0]}getSelectionDataWithStyle(){return this._selectionControls.map(e=>e.getValue())}getCurrentControls(){return this._selectionControls}_clearSelectionControls(){const n=this.getCurrentControls();if(n.length>0){for(const e of n)e.dispose();n.length=0}}_getFreeze(){var e;return(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig().freeze}_getViewportByCell(n,e){if(!this._scene||n===void 0||e===void 0)return null;const t=this._getFreeze();if(!t||t.startRow<=0&&t.startColumn<=0)return this._scene.getViewport(O.VIEW_MAIN);if(n>t.startRow&&e>t.startColumn)return this._scene.getViewport(O.VIEW_MAIN);if(n<=t.startRow&&e<=t.startColumn)return this._scene.getViewport(O.VIEW_MAIN_LEFT_TOP);if(n<=t.startRow&&e>t.startColumn)return this._scene.getViewport(O.VIEW_MAIN_TOP);if(n>t.startRow&&e<=t.startColumn)return this._scene.getViewport(O.VIEW_MAIN_LEFT)}getActiveSelections(){const n=this.getCurrentControls();if(n&&n.length>0)return n==null?void 0:n.map(t=>{const o=t.model,i=o.currentCell;let r=null;return i&&(r={actualRow:i.actualRow,actualColumn:i.actualColumn,isMerged:i.isMerged,isMergedMainCell:i.isMergedMainCell,startRow:i.mergeInfo.startRow,startColumn:i.mergeInfo.startColumn,endRow:i.mergeInfo.endRow,endColumn:i.mergeInfo.endColumn}),{range:{startRow:o.startRow,startColumn:o.startColumn,endRow:o.endRow,endColumn:o.endColumn},primary:r}})}getActiveRange(){const n=this.getCurrentControls(),e=n&&n[n.length-1].model;return e&&{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}}getActiveSelection(){const n=this.getCurrentControls();return n&&n[n.length-1]}endSelection(){this._endSelection()}reset(){this._clearSelectionControls(),this._moveObserver=null,this._upObserver=null,this._downObserver=null}resetAndEndSelection(){this.endSelection(),this.reset()}eventTrigger(n,e=0,t=m.RANGE_TYPE.NORMAL,o,i=_.ScrollTimerType.ALL){if(this._isSelectionEnabled===!1)return;const r=this._skeleton,{offsetX:s,offsetY:h}=n,a=this._scene;if(a==null||r==null)return;o!=null&&(this._activeViewport=o);const l=a.getViewport(O.VIEW_MAIN),g=a.getRelativeCoord(_.Vector2.FromArray([s,h]));let{x:C,y:u}=g;this._startOffsetX=C,this._startOffsetY=u;const f=a.getScrollXYByRelativeCoords(g),{scaleX:d,scaleY:S}=a.getAncestorScale();t===m.RANGE_TYPE.ROW?C=0:t===m.RANGE_TYPE.COLUMN&&(u=0);const v=this._getSelectedRangeWithMerge(C,u,d,S,f);if(!v)return!1;const{rangeWithCoord:p,primaryWithCoord:w}=v,{startRow:E,startColumn:R,endColumn:b,endRow:T,startY:L,endY:M,startX:B,endX:W}=p,{rowHeaderWidth:y,columnHeaderHeight:N}=r,I={startColumn:R,startRow:E,endColumn:b,endRow:T,startY:L,endY:M,startX:B,endX:W,rangeType:t};this._startSelectionRange=I;let P=this.getActiveSelection();const z=this.getCurrentControls();if(!z)return!1;for(const x of z){if(n.button===2&&x.model.isInclude(I)){P=x;return}if(x.model.isEqual(I)){P=x;break}n.shiftKey||x.clearHighlight()}if(z.length>0&&!n.ctrlKey&&!n.shiftKey&&!this._isShowPreviousEnable&&!this._isRemainLastEnable){for(const x of z)x.dispose();z.length=0}const se=P&&P.model.currentCell;if(P&&n.shiftKey&&se){const{actualRow:x,actualColumn:he,mergeInfo:te}=se,oe=Math.min(x,I.startRow,te.startRow),ie=Math.max(x,I.endRow,te.endRow),de=Math.min(he,I.startColumn,te.startColumn),_e=Math.max(he,I.endColumn,te.endColumn),F=r.getMergeBounding(oe,de,ie,_e),D=r.getNoMergeCellPositionByIndex(F.startRow,F.startColumn),H=r.getNoMergeCellPositionByIndex(F.endRow,F.endColumn),ge={startColumn:F.startColumn,startRow:F.startRow,endColumn:F.endColumn,endRow:F.endRow,startY:D.startY,endY:H.endY,startX:D.startX,endX:H.endX,rangeType:t},j=r.getCellByIndex(x,he);this._startSelectionRange={startColumn:j.mergeInfo.startColumn,startRow:j.mergeInfo.startRow,endColumn:j.mergeInfo.endColumn,endRow:j.mergeInfo.endRow,startY:j.mergeInfo.startY||0,endY:j.mergeInfo.endY||0,startX:j.mergeInfo.startX||0,endX:j.mergeInfo.endX||0,rangeType:t},P.update(ge,y,N,this._selectionStyle,se)}else this._isRemainLastEnable&&P&&!n.ctrlKey&&!n.shiftKey&&!this._isSkipRemainLastEnable?P.update(I,y,N,this._selectionStyle,w):(P=new Ne(a,z.length+e,this._isHeaderHighlight,this._themeService),new xe(P,r,a,this._themeService,this._injector),P.update(I,y,N,this._selectionStyle,w),z.push(P));this._selectionMoveStart$.next(this.getSelectionDataWithStyle()),this.hasSelection=!0,this._endSelection(),a.disableEvent();const ee=a.getActiveViewportByCoord(_.Vector2.FromArray([C,u])),le=_.ScrollTimer.create(this._scene,i);le.startScroll((l==null?void 0:l.left)??0,(l==null?void 0:l.top)??0,l),this._scrollTimer=le,this._addCancelObserver(),(t===m.RANGE_TYPE.ROW||t===m.RANGE_TYPE.COLUMN)&&this._moving(C,u,P,t);let ae=0,ce=0,K=C,q=u;this._moveObserver=a.onPointerMoveObserver.add(x=>{var j;const{offsetX:he,offsetY:te}=x,{x:oe,y:ie}=a.getRelativeCoord(_.Vector2.FromArray([he,te]));this._moving(oe,ie,P,t);let de=oe,_e=ie;const F=this.getActiveSelection(),D=(j=this._sheetSkeletonManagerService.getCurrent())==null?void 0:j.skeleton.getWorksheetConfig().freeze,H=F==null?void 0:F.model,ge=a.getActiveViewportByCoord(_.Vector2.FromArray([he,te]))??this._getViewportByCell(H==null?void 0:H.endRow,H==null?void 0:H.endColumn);if(ee&&ge&&l){const We=K<l.left&&oe>l.left||K>l.left&&oe<l.left,Pe=q<l.top&&ie>l.top||q>l.top&&ie<l.top;We&&(ae+=1),Pe&&(ce+=1);const J=ee.viewPortKey,Ce=ge.viewPortKey;if(J===O.VIEW_ROW_TOP)te<l.top&&((H==null?void 0:H.endRow)??0)<((D==null?void 0:D.startRow)??0)?_e=l.top:Pe&&ce%2===1&&l.scrollTo({y:0});else if(J===O.VIEW_COLUMN_LEFT)he<l.left&&((H==null?void 0:H.endColumn)??0)<((D==null?void 0:D.startColumn)??0)?de=l.left:We&&ae%2===1&&l.scrollTo({x:0});else if(J===Ce){let Q=!1,ue=!1;J===O.VIEW_MAIN_LEFT_TOP?(Q=!0,ue=!0):J===O.VIEW_MAIN_TOP?ue=!0:J===O.VIEW_MAIN_LEFT&&(Q=!0),((H==null?void 0:H.endRow)??0)>((D==null?void 0:D.startRow)??0)&&(ue=!1),((H==null?void 0:H.endColumn)??0)>((D==null?void 0:D.startColumn)??0)&&(Q=!1),Q&&(de=l.left),ue&&(_e=l.top)}else{const Q={x:ee.scrollX,y:ee.scrollY},ue={x:ge.scrollX,y:ge.scrollY},Le=Q.x!==ue.x&&We&&ae%2===1,ke=Q.y!==ue.y&&Pe&&ce%2===1;(Le||ke)&&(l.scrollTo({x:Le?Q.x:void 0,y:ke?Q.y:void 0}),Le||(de=l.left),ke||(_e=l.top)),(J===O.VIEW_MAIN_LEFT_TOP&&Ce===O.VIEW_MAIN_LEFT||Ce===O.VIEW_MAIN_LEFT_TOP&&J===O.VIEW_MAIN_LEFT)&&(de=l.left),(J===O.VIEW_MAIN_LEFT_TOP&&Ce===O.VIEW_MAIN_TOP||Ce===O.VIEW_MAIN_LEFT_TOP&&J===O.VIEW_MAIN_TOP)&&(_e=l.top)}K=oe,q=ie}le.scrolling(de,_e,()=>{this._moving(oe,ie,P,t)})}),this._upObserver=a.onPointerUpObserver.add(x=>{this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}),this._shortcutService.setDisable(!0)}convertSelectionRangeToData(n){const{range:e,primary:t,style:o}=n;let i=this.convertRangeDataToSelection(e);return i==null&&(i={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1,startY:0,endY:0,startX:0,endX:0,rangeType:m.RANGE_TYPE.NORMAL}),{rangeWithCoord:i,primaryWithCoord:this.convertCellRangeToInfo(t),style:o}}convertRangeDataToSelection(n){const{startRow:e,startColumn:t,endRow:o,endColumn:i,rangeType:r}=n,s=this._scene,h=this._skeleton;if(s==null||h==null)return;s.getAncestorScale();const a=h.getNoMergeCellPositionByIndex(e,t),l=h.getNoMergeCellPositionByIndex(o,i);return{startRow:e,startColumn:t,endRow:o,endColumn:i,rangeType:r,startY:(a==null?void 0:a.startY)||0,endY:(l==null?void 0:l.endY)||0,startX:(a==null?void 0:a.startX)||0,endX:(l==null?void 0:l.endX)||0}}convertCellRangeToInfo(n){if(n==null)return;const e=this._scene,t=this._skeleton;if(e==null||t==null)return;const{actualRow:o,actualColumn:i,isMerged:r,isMergedMainCell:s,startRow:h,startColumn:a,endRow:l,endColumn:g}=n,C=t.getNoMergeCellPositionByIndex(o,i),u=t.getNoMergeCellPositionByIndex(h,a),f=t.getNoMergeCellPositionByIndex(l,g);return{actualRow:o,actualColumn:i,isMerged:r,isMergedMainCell:s,startX:C.startX,startY:C.startY,endX:C.endX,endY:C.endY,mergeInfo:{startRow:h,startColumn:a,endRow:l,endColumn:g,startY:(u==null?void 0:u.startY)||0,endY:(f==null?void 0:f.endY)||0,startX:(u==null?void 0:u.startX)||0,endX:(f==null?void 0:f.endX)||0}}}_moving(n,e,t,o){const i=this._skeleton,r=this._scene;if(r==null||i==null)return!1;const{startRow:s,startColumn:h,endRow:a,endColumn:l}=this._startSelectionRange,{startRow:g,endRow:C,startColumn:u,endColumn:f}=(t==null?void 0:t.model)||{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1},d=r.getViewport(O.VIEW_MAIN),S=this._getViewportByCell(C,f)??d,v=r.getScrollXYByRelativeCoords(_.Vector2.FromArray([this._startOffsetX,this._startOffsetY]),S),{scaleX:p,scaleY:w}=r.getAncestorScale(),{rowHeaderWidth:E,columnHeaderHeight:R}=i;o===m.RANGE_TYPE.ROW?n=1/0:o===m.RANGE_TYPE.COLUMN&&(e=1/0);const b=this._getSelectedRangeWithMerge(n,e,p,w,v);if(!b)return!1;const{rangeWithCoord:T,primaryWithCoord:L}=b,{startRow:M,startColumn:B,endColumn:W,endRow:y}=T,N=Math.min(M,s),I=Math.min(B,h),P=Math.max(y,a),z=Math.max(W,l);let se={startRow:N,startColumn:I,endRow:P,endColumn:z};if(this._isDetectMergedCell&&(se=i.getSelectionBounding(N,I,P,z)),!se)return!1;const{startRow:ee,startColumn:le,endRow:ae,endColumn:ce}=se,K=i.getNoMergeCellPositionByIndex(ee,le),q=i.getNoMergeCellPositionByIndex(ae,ce),x={startColumn:le,startRow:ee,endColumn:ce,endRow:ae,startY:(K==null?void 0:K.startY)||0,endY:(q==null?void 0:q.endY)||0,startX:(K==null?void 0:K.startX)||0,endX:(q==null?void 0:q.endX)||0};(u!==le||g!==ee||f!==ce||C!==ae)&&t!=null&&(t.update(x,E,R),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_endSelection(){var t,o;const n=this._scene;if(n==null)return;n.onPointerMoveObserver.remove(this._moveObserver),n.onPointerUpObserver.remove(this._upObserver),n.enableEvent(),(t=this._scrollTimer)==null||t.dispose();const e=(o=n.getEngine())==null?void 0:o.activeScene;e==null||e.onPointerDownObserver.remove(this._cancelDownObserver),e==null||e.onPointerUpObserver.remove(this._cancelUpObserver)}_addCancelObserver(){var t;const n=this._scene;if(n==null)return;const e=(t=n.getEngine())==null?void 0:t.activeScene;e==null||e===n||(e.onPointerDownObserver.remove(this._cancelDownObserver),e.onPointerUpObserver.remove(this._cancelUpObserver),this._cancelDownObserver=e.onPointerDownObserver.add(o=>{this._endSelection()}),this._cancelUpObserver=e.onPointerUpObserver.add(o=>{this._endSelection()}))}_getSelectedRangeWithMerge(n,e,t,o,i){var v;if(this._isDetectMergedCell){const p=(v=this._skeleton)==null?void 0:v.calculateCellIndexByPosition(n,e,t,o,i),w=m.makeCellToSelection(p);return w==null?void 0:{primaryWithCoord:p,rangeWithCoord:w}}const r=this._skeleton;if(r==null)return;const s=r.getCellPositionByOffset(n,e,t,o,i),{row:h,column:a}=s,l=r.getNoMergeCellPositionByIndex(h,a),{startX:g,startY:C,endX:u,endY:f}=l,d={startY:C,endY:f,startX:g,endX:u,startRow:h,endRow:h,startColumn:a,endColumn:a};return{primaryWithCoord:{actualRow:h,actualColumn:a,isMerged:!1,isMergedMainCell:!1,startY:C,endY:f,startX:g,endX:u,mergeInfo:d},rangeWithCoord:d}}};De=nt([me(0,Y.Inject(m.ThemeService)),me(1,$.IShortcutService),me(2,Y.Inject(Se)),me(3,Y.Inject(Y.Injector))],De);const rt=Y.createIdentifier("deprecated.univer.sheet.selection-render-service");var st=Object.defineProperty,lt=Object.getOwnPropertyDescriptor,at=(n,e,t,o)=>{for(var i=o>1?void 0:o?lt(e,t):e,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=(o?s(e,t,i):s(i))||i);return o&&i&&st(e,t,i),i},ve=(n,e)=>(t,o)=>e(t,o,n);const ct=m.createInterceptorKey("BEFORE_CELL_EDIT"),ht=m.createInterceptorKey("AFTER_CELL_EDIT");let Ae=class extends m.Disposable{constructor(e,t,o,i){super();c(this,"_editorUnitId",m.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);c(this,"_isForceKeepVisible",!1);c(this,"_editorIsDirty",!1);c(this,"_visible",{visible:!1,eventType:_.DeviceInputEventType.Dblclick});c(this,"_currentEditCell",null);c(this,"_currentEditCellState",null);c(this,"_currentEditCellState$",new X.BehaviorSubject(null));c(this,"currentEditCellState$",this._currentEditCellState$.asObservable());c(this,"_visible$",new X.BehaviorSubject(this._visible));c(this,"visible$",this._visible$.asObservable());c(this,"_afterVisible$",new X.BehaviorSubject(this._visible));c(this,"afterVisible$",this._afterVisible$.asObservable());c(this,"interceptor",new m.InterceptorManager({BEFORE_CELL_EDIT:ct,AFTER_CELL_EDIT:ht}));this._sheetSkeletonManagerService=e,this._selectionRenderService=t,this._themeService=o,this._currentUniverService=i,this.disposeWithMe(m.toDisposable(()=>{this._currentEditCellState$.complete(),this._currentEditCell=null})),this.disposeWithMe(m.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{priority:-1,handler:r=>r}))),this.disposeWithMe(m.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{priority:-1,handler:r=>r})))}refreshEditCellState(){const e=this.getLatestEditCellState();this._currentEditCellState=e,this._currentEditCellState$.next(e)}setEditCell(e){this._currentEditCell=e;const t=this.getLatestEditCellState();this._currentEditCellState=t,this._currentEditCellState$.next(t)}getEditCellState(){return this._currentEditCellState}getLatestEditCellState(){var N,I;const e=this._currentEditCell;if(e==null)return;const t=this._sheetSkeletonManagerService.getCurrent();if(t==null)return;const{skeleton:o}=t,{primary:i,unitId:r,sheetId:s,scene:h,engine:a}=e,{startRow:l,startColumn:g}=i,C=this._selectionRenderService.convertCellRangeToInfo(i);if(C==null)return;const u=m.makeCellToSelection(C);if(u==null)return;const f=_.getCanvasOffsetByEngine(a);let{startX:d,startY:S,endX:v,endY:p}=u;const{scaleX:w,scaleY:E}=h.getAncestorScale(),{scaleX:R,scaleY:b}=h.getPrecisionScale(),T=h.getScrollXY(this._selectionRenderService.getViewPort());d=_.fixLineWidthByScale(o.convertTransformToOffsetX(d,w,T),R),S=_.fixLineWidthByScale(o.convertTransformToOffsetY(S,E,T),b),v=_.fixLineWidthByScale(o.convertTransformToOffsetX(v,w,T),R),p=_.fixLineWidthByScale(o.convertTransformToOffsetY(p,E,T),b);const L=this._currentUniverService.getCurrentUniverSheetInstance(),M=L.getActiveSheet(),B={workbook:L,worksheet:M,unitId:L.getUnitId(),subUnitId:M.getSheetId(),row:l,col:g},W=this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT)(M.getCell(l,g),B);let y=W&&o.getCellDocumentModelWithFormula(W);if((!y||y.documentModel==null)&&(y=o.getBlankCellDocumentModel(W)),(N=y.documentModel)==null||N.setZoomRatio(Math.max(w,E)),(W==null?void 0:W.isInArrayFormulaRange)===!0){const P=(I=y.documentModel)==null?void 0:I.getBody();P&&(P.textRuns=[{st:0,ed:P.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}return{position:{startX:d,startY:S,endX:v,endY:p},scaleX:w,scaleY:E,canvasOffset:f,row:l,column:g,unitId:r,sheetId:s,documentLayoutObject:y,editorUnitId:this._editorUnitId,isInArrayFormulaRange:W==null?void 0:W.isInArrayFormulaRange}}getCurrentEditorId(){return this._editorUnitId}changeVisible(e){this._visible=e,e.visible&&(this._editorIsDirty=!1),this._visible$.next(this._visible),this._afterVisible$.next(this._visible)}isVisible(){return this._visible}enableForceKeepVisible(){this._isForceKeepVisible=!0}disableForceKeepVisible(){this._isForceKeepVisible=!1}isForceKeepVisible(){return this._isForceKeepVisible}changeEditorDirty(e){this._editorIsDirty=e}getEditorDirty(){return this._editorIsDirty}};Ae=at([ve(0,Y.Inject(Se)),ve(1,rt),ve(2,Y.Inject(m.ThemeService)),ve(3,m.IUniverInstanceService)],Ae);const Oe=Y.createIdentifier("univer.sheet-editor-bridge.service");var Ue={exports:{}},pe={};/**
|
|
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 dt=Z,_t=Symbol.for("react.element"),ut=Symbol.for("react.fragment"),ft=Object.prototype.hasOwnProperty,gt=dt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,St={key:!0,ref:!0,__self:!0,__source:!0};function Ve(n,e,t){var o,i={},r=null,s=null;t!==void 0&&(r=""+t),e.key!==void 0&&(r=""+e.key),e.ref!==void 0&&(s=e.ref);for(o in e)ft.call(e,o)&&!St.hasOwnProperty(o)&&(i[o]=e[o]);if(n&&n.defaultProps)for(o in e=n.defaultProps,e)i[o]===void 0&&(i[o]=e[o]);return{$$typeof:_t,type:n,key:r,ref:s,props:i,_owner:gt.current}}pe.Fragment=ut,pe.jsx=Ve,pe.jsxs=Ve,Ue.exports=pe;var ne=Ue.exports,U=function(){return U=Object.assign||function(n){for(var e,t=1,o=arguments.length;t<o;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},U.apply(this,arguments)},Ct=function(n,e){var t={};for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&e.indexOf(o)<0&&(t[o]=n[o]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,o=Object.getOwnPropertySymbols(n);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(n,o[i])&&(t[o[i]]=n[o[i]]);return t},be=Z.forwardRef(function(n,e){var t=n.icon,o=n.id,i=n.className,r=n.extend,s=Ct(n,["icon","id","className","extend"]),h="univerjs-icon univerjs-icon-".concat(o," ").concat(i||"").trim(),a=Z.useRef("_".concat(pt()));return ze(t,"".concat(o),{defIds:t.defIds,idSuffix:a.current},U({ref:e,className:h},s),r)});function ze(n,e,t,o,i){return Z.createElement(n.tag,U(U({key:e},mt(n,t,i)),o),(vt(n,t).children||[]).map(function(r,s){return ze(r,"".concat(e,"-").concat(n.tag,"-").concat(s),t,void 0,i)}))}function mt(n,e,t){var o=U({},n.attrs);t!=null&&t.colorChannel1&&o.fill==="colorChannel1"&&(o.fill=t.colorChannel1);var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&o["xlink:href"]&&(o["xlink:href"]=o["xlink:href"]+e.idSuffix),Object.entries(o).forEach(function(r){var s=r[0],h=r[1];typeof h=="string"&&(o[s]=h.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),o}function vt(n,e){var t,o=e.defIds;return!o||o.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?U(U({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&o&&o.indexOf(i.attrs.id)>-1?U(U({},i),{attrs:U(U({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function pt(){return Math.random().toString(36).substring(2,8)}be.displayName="UniverIcon";var wt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.6152 4.52067C14.8732 4.77869 14.8732 5.19703 14.6152 5.45505L6.61862 13.4514C6.46241 13.6077 6.20915 13.6077 6.05294 13.4514L1.73512 9.13354C1.4771 8.87551 1.4771 8.45718 1.73513 8.19915C1.99315 7.94113 2.41149 7.94114 2.66951 8.19916L6.19436 11.7241C6.27247 11.8022 6.3991 11.8022 6.47721 11.7241L13.6808 4.52067C13.9388 4.26264 14.3571 4.26264 14.6152 4.52067Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Fe=Z.forwardRef(function(n,e){return Z.createElement(be,Object.assign({},n,{id:"check-mark-single",ref:e,icon:wt}))});Fe.displayName="CheckMarkSingle";const Rt=Fe;var Et={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.48712 4.59907C5.23328 4.34523 4.82172 4.34523 4.56788 4.59907C4.31404 4.85291 4.31404 5.26447 4.56788 5.51831L7.9973 8.94773L4.56773 12.3773C4.31389 12.6311 4.31389 13.0427 4.56773 13.2965C4.82157 13.5504 5.23313 13.5504 5.48697 13.2965L8.91654 9.86697L12.3461 13.2965C12.5999 13.5503 13.0114 13.5503 13.2653 13.2965C13.5191 13.0426 13.5191 12.6311 13.2653 12.3772L9.83577 8.94773L13.2651 5.51836C13.519 5.26452 13.519 4.85296 13.2651 4.59912C13.0113 4.34528 12.5997 4.34528 12.3459 4.59912L8.91654 8.02849L5.48712 4.59907Z"}}]},je=Z.forwardRef(function(n,e){return Z.createElement(be,Object.assign({},n,{id:"close-single",ref:e,icon:Et}))});je.displayName="CloseSingle";const It=je,Te={id:"zen-editor.operation.open-zen-editor",type:m.CommandType.OPERATION,handler:n=>!0};class Ot{constructor(){c(this,"_position",null);c(this,"_position$",new X.BehaviorSubject(null));c(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(e){this._position=e,this._refresh(e)}getPosition(){return this._position}_refresh(e){this._position$.next(e)}}const ye=Y.createIdentifier("univer.sheet-zen-editor-manager.service");var bt=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,yt=(n,e,t,o)=>{for(var i=o>1?void 0:o?Tt(e,t):e,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=(o?s(e,t,i):s(i))||i);return o&&i&&bt(e,t,i),i},G=(n,e)=>(t,o)=>e(t,o,n);const V="__defaultDocumentZenEditorSpecialUnitId_20231218__";let we=class extends m.RxDisposable{constructor(n,e,t,o,i,r,s,h,a,l){super(),this._currentUniverService=n,this._zenEditorManagerService=e,this._renderManagerService=t,this._commandService=o,this._zenZoneService=i,this._editorBridgeService=r,this._undoRedoService=s,this._textSelectionManagerService=h,this._docSkeletonManagerService=a,this._docViewModelManagerService=l,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener(),this._createZenEditorInstance()}_createZenEditorInstance(){const n={id:V,body:{dataStream:`${m.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:595,height:842},marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}}};this._currentUniverService.createDoc(n)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(X.takeUntil(this.dispose$)).subscribe(n=>{var h;if(n==null)return;const e=Ge(V,this._renderManagerService),t=this._currentUniverService.getUniverDocInstance(V);if(e==null||t==null)return;const{width:o,height:i}=n,{engine:r}=e,s=(h=this._docSkeletonManagerService.getSkeletonByUnitId(V))==null?void 0:h.skeleton;requestIdleCallback(()=>{r.resizeBySize(o,i),this._calculatePagePosition(e),s&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){this._zenZoneService.open(),this._undoRedoService.clearUndoRedo(V),this._currentUniverService.focusUniverInstance(V),this._currentUniverService.setCurrentUniverDocInstance(V),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:_.DeviceInputEventType.PointerDown});const e=this._editorBridgeService.getLatestEditCellState();if(e==null)return;this._editorSyncHandler(e);const t=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(t)}_editorSyncHandler(n){var r,s;const e=(r=n.documentLayoutObject.documentModel)==null?void 0:r.getBody(),t=e==null?void 0:e.dataStream,o=e==null?void 0:e.paragraphs;let i=[];t==null||o==null||((s=e==null?void 0:e.textRuns)!=null&&s.length&&(i=e==null?void 0:e.textRuns),this._syncContentAndRender(V,t,o,i))}_syncContentAndRender(n,e,t,o=[]){const i=[V,m.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,m.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],r=this._docSkeletonManagerService.getSkeletonByUnitId(n),s=this._currentUniverService.getUniverDocInstance(n),h=this._docViewModelManagerService.getViewModel(n);if(s==null||h==null||r==null)return;const a=s.getBody();a.dataStream=e,a.paragraphs=t,n===m.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(a.textRuns=[]),o.length>0&&(a.textRuns=o),h.reset(s);const{skeleton:l}=r,g=this._getDocObject();g!=null&&(l.calculate(),i.includes(n)&&g.document.makeDirty())}_calculatePagePosition(n){const{document:e,scene:t}=n,o=t==null?void 0:t.getParent(),{width:i,height:r,pageMarginLeft:s,pageMarginTop:h}=e;if(o==null||i===1/0||r===1/0)return;const{width:a,height:l}=o;let g=0,C=0,u=0,f=0,d=1/0;const{scaleX:S,scaleY:v}=t.getAncestorScale();a>(i+s*2)*S?(g=a/2-i*S/2,g/=S,u=(a-s*2)/S,d=0):(g=s,u=i+s*2,d=(u-a/S)/2),l>r?(C=l/2-r/2,f=(l-h*2)/v):(C=h,f=r+h*2),t.resize(u,f+200),e.translate(g,C);const p=t.getViewport(fe.VIEWPORT_KEY.VIEW_MAIN);if(d!==1/0&&p!=null){const w=p.getBarScroll(d,0).x;p.scrollTo({x:w})}return this}_commandExecutedListener(){const n=[Te.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{n.includes(t.id)&&this._handleOpenZenEditor()}));const e=[fe.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const o=t.params,{unitId:i}=o;if(i===V){const r=this._currentUniverService.getUniverDocInstance(i),s=r==null?void 0:r.getBody(),h=s==null?void 0:s.dataStream,a=s==null?void 0:s.paragraphs,l=s==null?void 0:s.textRuns;if(h==null||a==null)return;this._syncContentAndRender(m.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,h,a,l)}}}))}_getDocObject(){return fe.getDocObject(this._currentUniverService,this._renderManagerService)}};we=yt([m.OnLifecycle(m.LifecycleStages.Steady,we),G(0,m.IUniverInstanceService),G(1,ye),G(2,_.IRenderManagerService),G(3,m.ICommandService),G(4,$.IZenZoneService),G(5,Oe),G(6,m.IUndoRedoService),G(7,Y.Inject(fe.TextSelectionManagerService)),G(8,Y.Inject(fe.DocSkeletonManagerService)),G(9,Y.Inject(fe.DocViewModelManagerService))],we);const $e={id:"zen-editor.command.cancel-zen-edit",type:m.CommandType.COMMAND,handler:async n=>{const e=n.get($.IZenZoneService),t=n.get(Oe),o=n.get(m.IUniverInstanceService);t.isVisible().visible&&t.changeVisible({visible:!1,eventType:_.DeviceInputEventType.Keyboard,keycode:$.KeyCode.ESC}),e.close();const r=o.getCurrentUniverSheetInstance();return o.focusUniverInstance(r.getUnitId()),t.refreshEditCellState(),!0}},Ze={id:"zen-editor.command.confirm-zen-edit",type:m.CommandType.COMMAND,handler:async n=>{const e=n.get($.IZenZoneService),t=n.get(Oe),o=n.get(m.IUniverInstanceService);t.isVisible().visible&&t.changeVisible({visible:!1,eventType:_.DeviceInputEventType.PointerDown}),e.close();const r=o.getCurrentUniverSheetInstance();return o.focusUniverInstance(r.getUnitId()),t.refreshEditCellState(),!0}};function Mt(){return{id:Te.id,group:$.MenuGroup.CONTEXT_MENU_OTHERS,type:$.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[$.MenuPosition.CONTEXT_MENU]}}const re={zenEditor:"univer-zen-editor",zenEditorIconWrapper:"univer-zen-editor-icon-wrapper",zenEditorIconContainer:"univer-zen-editor-icon-container",zenEditorIconSuccess:"univer-zen-editor-icon-success",zenEditorIconError:"univer-zen-editor-icon-error",zenEditorCanvasContainer:"univer-zen-editor-canvas-container"},Wt="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT";function Pt(){const n=Z.useRef(null),e=Ie.useDependency(_.IRenderManagerService),t=Ie.useDependency(ye),o=Ie.useDependency(m.ICommandService);Z.useEffect(()=>{const s=n.current;if(!s)return;const h=e.currentRender$.subscribe(l=>{var C;if(l!==V)return;const g=(C=e.getRenderById(V))==null?void 0:C.engine;g==null||g.setContainer(s)}),a=new ResizeObserver(()=>{const l=s.getBoundingClientRect();t.setPosition(l)});return a.observe(s),()=>{a.unobserve(s),h.unsubscribe()}},[]);function i(){o.executeCommand($e.id)}function r(){o.executeCommand(Ze.id)}return ne.jsxs("div",{className:re.zenEditor,children:[ne.jsxs("div",{className:re.zenEditorIconWrapper,children:[ne.jsx("span",{className:Be(re.zenEditorIconContainer,re.zenEditorIconError),onClick:i,children:ne.jsx(It,{style:{fontSize:"22px"}})}),ne.jsx("span",{className:Be(re.zenEditorIconContainer,re.zenEditorIconSuccess),onClick:r,children:ne.jsx(Rt,{style:{fontSize:"22px"}})})]}),ne.jsx("div",{className:re.zenEditorCanvasContainer,ref:n})]})}var Lt=Object.defineProperty,kt=Object.getOwnPropertyDescriptor,Bt=(n,e,t,o)=>{for(var i=o>1?void 0:o?kt(e,t):e,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=(o?s(e,t,i):s(i))||i);return o&&i&&Lt(e,t,i),i},Re=(n,e)=>(t,o)=>e(t,o,n);let Ee=class extends m.Disposable{constructor(n,e,t,o){super(),this._injector=n,this._zenZoneService=e,this._commandService=t,this._menuService=o,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(Wt,Pt))}_initCommands(){[Te,$e,Ze].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initMenus(){[Mt].forEach(n=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(n)))})}};Ee=Bt([m.OnLifecycle(m.LifecycleStages.Ready,Ee),Re(0,Y.Inject(Y.Injector)),Re(1,$.IZenZoneService),Re(2,m.ICommandService),Re(3,$.IMenuService)],Ee);var Yt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,Nt=(n,e,t,o)=>{for(var i=o>1?void 0:o?Ht(e,t):e,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=(o?s(e,t,i):s(i))||i);return o&&i&&Yt(e,t,i),i},Xt=(n,e)=>(t,o)=>e(t,o,n);k.UniverSheetsZenEditorPlugin=(Me=class extends m.Plugin{constructor(e,t){super("zen-editor"),this._injector=t,this._initializeDependencies(this._injector)}_initializeDependencies(e){[[Ee],[we],[ye,{useClass:Ot}]].forEach(o=>e.add(o))}onRendered(){}onDestroy(){}},c(Me,"type",m.PluginType.Doc),Me),k.UniverSheetsZenEditorPlugin=Nt([Xt(1,Y.Inject(Y.Injector))],k.UniverSheetsZenEditorPlugin),Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@univerjs/sheets-zen-editor",
|
|
3
|
+
"version": "0.1.0-beta.2",
|
|
4
|
+
"description": "Zen Editor plugin for Univer Sheets.",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"author": "DreamNum <developer@univer.ai>",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"main": "./lib/cjs/index.js",
|
|
9
|
+
"module": "./lib/es/index.js",
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./lib/es/index.js",
|
|
17
|
+
"require": "./lib/cjs/index.js",
|
|
18
|
+
"types": "./lib/types/index.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./*": {
|
|
21
|
+
"import": "./lib/es/*",
|
|
22
|
+
"require": "./lib/cjs/*",
|
|
23
|
+
"types": "./lib/types/index.d.ts"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"directories": {
|
|
27
|
+
"lib": "lib"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"lib"
|
|
31
|
+
],
|
|
32
|
+
"private": false,
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@univerjs/icons": "^0.1.25",
|
|
35
|
+
"@wendellhu/redi": "^0.12.13",
|
|
36
|
+
"clsx": "^2.0.0",
|
|
37
|
+
"react": "^18.2.0",
|
|
38
|
+
"rxjs": "^7.8.1",
|
|
39
|
+
"@univerjs/core": "0.1.0-beta.2",
|
|
40
|
+
"@univerjs/design": "0.1.0-beta.2",
|
|
41
|
+
"@univerjs/docs": "0.1.0-beta.2",
|
|
42
|
+
"@univerjs/engine-render": "0.1.0-beta.2",
|
|
43
|
+
"@univerjs/sheets": "0.1.0-beta.2",
|
|
44
|
+
"@univerjs/ui": "0.1.0-beta.2",
|
|
45
|
+
"@univerjs/sheets-ui": "0.1.0-beta.2"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
49
|
+
"@vitest/coverage-istanbul": "^1.1.1",
|
|
50
|
+
"less": "^4.2.0",
|
|
51
|
+
"typescript": "^5.3.3",
|
|
52
|
+
"vite": "^5.0.10",
|
|
53
|
+
"vite-plugin-dts": "^3.7.0",
|
|
54
|
+
"vite-plugin-externals": "^0.6.2",
|
|
55
|
+
"vitest": "^1.1.1"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"@wendellhu/redi": ">=0.12.12",
|
|
59
|
+
"clsx": ">=2.0.0",
|
|
60
|
+
"react": ">=16.9.0",
|
|
61
|
+
"rxjs": ">=7.0.0",
|
|
62
|
+
"@univerjs/design": "0.1.0-beta.2",
|
|
63
|
+
"@univerjs/core": "0.1.0-beta.2",
|
|
64
|
+
"@univerjs/docs": "0.1.0-beta.2",
|
|
65
|
+
"@univerjs/engine-render": "0.1.0-beta.2",
|
|
66
|
+
"@univerjs/sheets-ui": "0.1.0-beta.2",
|
|
67
|
+
"@univerjs/ui": "0.1.0-beta.2",
|
|
68
|
+
"@univerjs/sheets": "0.1.0-beta.2"
|
|
69
|
+
},
|
|
70
|
+
"scripts": {
|
|
71
|
+
"test": "vitest run",
|
|
72
|
+
"test:watch": "vitest",
|
|
73
|
+
"coverage": "vitest run --coverage",
|
|
74
|
+
"build": "tsc && vite build"
|
|
75
|
+
}
|
|
76
|
+
}
|