@univerjs/docs 0.1.0-alpha.1 → 0.1.0-alpha.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/lib/cjs/index.js +2 -5928
- package/lib/es/index.js +2885 -0
- package/lib/types/basics/component-tools.d.ts +15 -1
- package/lib/types/basics/demo-data.d.ts +15 -1
- package/lib/types/basics/docs-view-key.d.ts +15 -1
- package/lib/types/basics/retain-delete-params.d.ts +15 -1
- package/lib/types/commands/commands/__tests__/clipboard.command.spec.d.ts +15 -1
- package/lib/types/commands/commands/__tests__/core-editing.command.spec.d.ts +15 -1
- package/lib/types/commands/commands/__tests__/create-command-test-bed.d.ts +15 -1
- package/lib/types/commands/commands/__tests__/inline-format.command.spec.d.ts +15 -1
- package/lib/types/commands/commands/__tests__/replace-content.command.spec.d.ts +15 -1
- package/lib/types/commands/commands/clipboard.command.d.ts +15 -1
- package/lib/types/commands/commands/clipboard.inner.command.d.ts +15 -1
- package/lib/types/commands/commands/core-editing.command.d.ts +16 -1
- package/lib/types/commands/commands/ime-input.command.d.ts +15 -1
- package/lib/types/commands/commands/inline-format.command.d.ts +15 -1
- package/lib/types/commands/commands/insert-floating-object.command.d.ts +15 -1
- package/lib/types/commands/commands/remove-floating-object.command.d.ts +15 -1
- package/lib/types/commands/commands/replace-content.command.d.ts +15 -1
- package/lib/types/commands/commands/set-doc-zoom-ratio.command.d.ts +15 -1
- package/lib/types/commands/commands/set-floating-object-transform.command.d.ts +15 -1
- package/lib/types/commands/mutations/core-editing.mutation.d.ts +15 -1
- package/lib/types/commands/mutations/insert-floating-object.mutation.d.ts +15 -1
- package/lib/types/commands/mutations/remove-floating-object.mutation.d.ts +15 -1
- package/lib/types/commands/mutations/set-floating-object.mutation.d.ts +15 -1
- package/lib/types/commands/operations/cursor.operation.d.ts +15 -1
- package/lib/types/commands/operations/select-all.operation.d.ts +15 -1
- package/lib/types/commands/operations/set-doc-zoom-ratio.operation.d.ts +15 -1
- package/lib/types/commands/operations/text-selection.operation.d.ts +15 -1
- package/lib/types/controllers/clipboard.controller.d.ts +15 -1
- package/lib/types/controllers/delete.controller.d.ts +15 -1
- package/lib/types/controllers/doc-render.controller.d.ts +16 -3
- package/lib/types/controllers/floating-object.controller.d.ts +15 -1
- package/lib/types/controllers/ime-input.controller.d.ts +15 -1
- package/lib/types/controllers/inline-format.controller.d.ts +15 -1
- package/lib/types/controllers/line-break-input.controller.d.ts +15 -1
- package/lib/types/controllers/move-cursor.controller.d.ts +15 -1
- package/lib/types/controllers/normal-input.controller.d.ts +15 -1
- package/lib/types/controllers/page-render.controller.d.ts +15 -1
- package/lib/types/controllers/text-selection.controller.d.ts +15 -1
- package/lib/types/controllers/zoom.controller.d.ts +15 -1
- package/lib/types/doc-plugin.d.ts +18 -4
- package/lib/types/index.d.ts +16 -2
- package/lib/types/services/clipboard/__test__/html-and-udm-convert.spec.d.ts +15 -1
- package/lib/types/services/clipboard/clipboard.service.d.ts +15 -1
- package/lib/types/services/clipboard/copy-content-cache.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-udm/converter.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-udm/parse-node-style.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-udm/parse-to-dom.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-lark.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-word.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/type.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-udm/utils.d.ts +15 -1
- package/lib/types/services/clipboard/udm-to-html/convertor.d.ts +15 -1
- package/lib/types/services/doc-skeleton-manager.service.d.ts +15 -1
- package/lib/types/services/doc-view-model-manager.service.d.ts +15 -1
- package/lib/types/services/ime-input-manager.service.d.ts +15 -1
- package/lib/types/services/text-selection-manager.service.d.ts +15 -1
- package/lib/types/shortcuts/core-editing.shortcut.d.ts +15 -1
- package/lib/types/shortcuts/cursor.shortcut.d.ts +15 -1
- package/lib/types/views/doc-canvas-view.d.ts +15 -1
- package/lib/umd/index.js +2 -0
- package/package.json +28 -25
- package/LICENSE +0 -21
- package/lib/cjs/locale/en-US.js +0 -26
- package/lib/cjs/locale/zh-CN.js +0 -26
- package/lib/esm/index.js +0 -5845
- package/lib/esm/locale/en-US.js +0 -5
- package/lib/esm/locale/zh-CN.js +0 -5
- package/lib/types/basics/component-tools.d.ts.map +0 -1
- package/lib/types/basics/demo-data.d.ts.map +0 -1
- package/lib/types/basics/docs-view-key.d.ts.map +0 -1
- package/lib/types/basics/retain-delete-params.d.ts.map +0 -1
- package/lib/types/commands/commands/__tests__/clipboard.command.spec.d.ts.map +0 -1
- package/lib/types/commands/commands/__tests__/core-editing.command.spec.d.ts.map +0 -1
- package/lib/types/commands/commands/__tests__/create-command-test-bed.d.ts.map +0 -1
- package/lib/types/commands/commands/__tests__/inline-format.command.spec.d.ts.map +0 -1
- package/lib/types/commands/commands/__tests__/replace-content.command.spec.d.ts.map +0 -1
- package/lib/types/commands/commands/clipboard.command.d.ts.map +0 -1
- package/lib/types/commands/commands/clipboard.inner.command.d.ts.map +0 -1
- package/lib/types/commands/commands/core-editing.command.d.ts.map +0 -1
- package/lib/types/commands/commands/ime-input.command.d.ts.map +0 -1
- package/lib/types/commands/commands/inline-format.command.d.ts.map +0 -1
- package/lib/types/commands/commands/insert-floating-object.command.d.ts.map +0 -1
- package/lib/types/commands/commands/remove-floating-object.command.d.ts.map +0 -1
- package/lib/types/commands/commands/replace-content.command.d.ts.map +0 -1
- package/lib/types/commands/commands/set-doc-zoom-ratio.command.d.ts.map +0 -1
- package/lib/types/commands/commands/set-floating-object-transform.command.d.ts.map +0 -1
- package/lib/types/commands/mutations/core-editing.mutation.d.ts.map +0 -1
- package/lib/types/commands/mutations/insert-floating-object.mutation.d.ts.map +0 -1
- package/lib/types/commands/mutations/remove-floating-object.mutation.d.ts.map +0 -1
- package/lib/types/commands/mutations/set-floating-object.mutation.d.ts.map +0 -1
- package/lib/types/commands/operations/cursor.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/select-all.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/set-doc-zoom-ratio.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/text-selection.operation.d.ts.map +0 -1
- package/lib/types/controllers/clipboard.controller.d.ts.map +0 -1
- package/lib/types/controllers/delete.controller.d.ts.map +0 -1
- package/lib/types/controllers/doc-render.controller.d.ts.map +0 -1
- package/lib/types/controllers/floating-object.controller.d.ts.map +0 -1
- package/lib/types/controllers/ime-input.controller.d.ts.map +0 -1
- package/lib/types/controllers/inline-format.controller.d.ts.map +0 -1
- package/lib/types/controllers/line-break-input.controller.d.ts.map +0 -1
- package/lib/types/controllers/move-cursor.controller.d.ts.map +0 -1
- package/lib/types/controllers/normal-input.controller.d.ts.map +0 -1
- package/lib/types/controllers/page-render.controller.d.ts.map +0 -1
- package/lib/types/controllers/text-selection.controller.d.ts.map +0 -1
- package/lib/types/controllers/zoom.controller.d.ts.map +0 -1
- package/lib/types/doc-plugin.d.ts.map +0 -1
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/locale/en-US.d.ts +0 -3
- package/lib/types/locale/en-US.d.ts.map +0 -1
- package/lib/types/locale/index.d.ts +0 -3
- package/lib/types/locale/index.d.ts.map +0 -1
- package/lib/types/locale/zh-CN.d.ts +0 -3
- package/lib/types/locale/zh-CN.d.ts.map +0 -1
- package/lib/types/services/clipboard/__test__/html-and-udm-convert.spec.d.ts.map +0 -1
- package/lib/types/services/clipboard/clipboard.service.d.ts.map +0 -1
- package/lib/types/services/clipboard/copy-content-cache.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-udm/converter.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-udm/parse-node-style.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-udm/parse-to-dom.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-lark.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-word.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/type.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-udm/utils.d.ts.map +0 -1
- package/lib/types/services/clipboard/udm-to-html/convertor.d.ts.map +0 -1
- package/lib/types/services/doc-skeleton-manager.service.d.ts.map +0 -1
- package/lib/types/services/doc-view-model-manager.service.d.ts.map +0 -1
- package/lib/types/services/ime-input-manager.service.d.ts.map +0 -1
- package/lib/types/services/text-selection-manager.service.d.ts.map +0 -1
- package/lib/types/shortcuts/core-editing.shortcut.d.ts.map +0 -1
- package/lib/types/shortcuts/cursor.shortcut.d.ts.map +0 -1
- package/lib/types/views/doc-canvas-view.d.ts.map +0 -1
|
@@ -1,3 +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
|
+
*/
|
|
1
16
|
import type { ISelectionCell, Nullable } from '@univerjs/core';
|
|
2
17
|
import type { ITextRangeWithStyle, TextRange } from '@univerjs/engine-render';
|
|
3
18
|
import type { IDisposable } from '@wendellhu/redi';
|
|
@@ -45,4 +60,3 @@ export declare class TextSelectionManagerService implements IDisposable {
|
|
|
45
60
|
private _clearByParam;
|
|
46
61
|
private _removeByParam;
|
|
47
62
|
}
|
|
48
|
-
//# sourceMappingURL=text-selection-manager.service.d.ts.map
|
|
@@ -1,5 +1,19 @@
|
|
|
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
|
+
*/
|
|
1
16
|
import type { IShortcutItem } from '@univerjs/ui';
|
|
2
17
|
export declare const BreakLineShortcut: IShortcutItem;
|
|
3
18
|
export declare const DeleteLeftShortcut: IShortcutItem;
|
|
4
19
|
export declare const DeleteRightShortcut: IShortcutItem;
|
|
5
|
-
//# sourceMappingURL=core-editing.shortcut.d.ts.map
|
|
@@ -1,3 +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
|
+
*/
|
|
1
16
|
import type { IShortcutItem } from '@univerjs/ui';
|
|
2
17
|
export declare const MoveCursorUpShortcut: IShortcutItem;
|
|
3
18
|
export declare const MoveCursorDownShortcut: IShortcutItem;
|
|
@@ -8,4 +23,3 @@ export declare const MoveSelectionDownShortcut: IShortcutItem;
|
|
|
8
23
|
export declare const MoveSelectionLeftShortcut: IShortcutItem;
|
|
9
24
|
export declare const MoveSelectionRightShortcut: IShortcutItem;
|
|
10
25
|
export declare const SelectAllShortcut: IShortcutItem;
|
|
11
|
-
//# sourceMappingURL=cursor.shortcut.d.ts.map
|
|
@@ -1,3 +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
|
+
*/
|
|
1
16
|
import { IConfigService, IUniverInstanceService } from '@univerjs/core';
|
|
2
17
|
import type { RenderManagerService } from '@univerjs/engine-render';
|
|
3
18
|
import { DocViewModelManagerService } from '../services/doc-view-model-manager.service';
|
|
@@ -14,4 +29,3 @@ export declare class DocCanvasView {
|
|
|
14
29
|
private _addNewRender;
|
|
15
30
|
private _addComponent;
|
|
16
31
|
}
|
|
17
|
-
//# sourceMappingURL=doc-canvas-view.d.ts.map
|
package/lib/umd/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(p,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("@wendellhu/redi"),require("@ctrl/tinycolor")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui","rxjs","@univerjs/engine-render","@wendellhu/redi","@ctrl/tinycolor"],o):(p=typeof globalThis<"u"?globalThis:p||self,o(p.UniverDocs={},p.UniverCore,p.UniverUi,p.rxjs,p.UniverEngineRender,p["@wendellhu/redi"],p.tinycolor))})(this,function(p,o,O,oe,I,y,Ke){"use strict";var Vn=Object.defineProperty;var zn=(p,o,O)=>o in p?Vn(p,o,{enumerable:!0,configurable:!0,writable:!0,value:O}):p[o]=O;var v=(p,o,O)=>(zn(p,typeof o!="symbol"?o+"":o,O),O);var He;function B(i,e){const n=i.getCurrentUniverDocInstance().getUnitId(),r=e.getRenderById(n);if(r==null)return;const{mainComponent:s,scene:a,engine:c}=r;return{document:s,scene:a,engine:c}}function lt(i,e){const t=e.getRenderById(i);if(t==null)return;const{components:n,mainComponent:r,scene:s,engine:a}=t;return{document:r,scene:s,engine:a}}var ce=(i=>(i.MAIN="__Document_Render_Main__",i))(ce||{}),j=(i=>(i.VIEW_MAIN="viewMain",i.VIEW_TOP="viewTop",i.VIEW_LEFT="viewLeft",i.VIEW_LEFT_TOP="viewLeftTop",i))(j||{});const Le=0,Ye=2,Xe=10,Y="normalTextSelectionPluginName",le={id:O.CopyCommand.id,name:"doc.command.copy",type:o.CommandType.COMMAND,multi:!0,priority:999,preconditions:i=>i.getContextValue(o.FOCUSING_DOC)||i.getContextValue(o.FOCUSING_EDITOR),handler:async()=>!0},de={id:O.CutCommand.id,name:"doc.command.cut",type:o.CommandType.COMMAND,multi:!0,priority:999,preconditions:i=>i.getContextValue(o.FOCUSING_DOC)||i.getContextValue(o.FOCUSING_EDITOR),handler:async()=>!0},ue={id:O.PasteCommand.id,name:"doc.command.paste",type:o.CommandType.COMMAND,multi:!0,priority:999,preconditions:i=>i.getContextValue(o.FOCUSING_DOC)||i.getContextValue(o.FOCUSING_EDITOR),handler:async()=>!0};function X(i,e="",t=0){const{startOffset:n,endOffset:r}=i,s=[],a=n-t,c=r-t;return a>0&&s.push({t:"r",len:a,segmentId:e}),s.push({t:"d",len:c-a,line:0,segmentId:e}),s}class x{constructor(){v(this,"_textSelectionInfo",new Map);v(this,"_currentSelection",null);v(this,"_textSelectionInfo$",new oe.BehaviorSubject(null));v(this,"textSelectionInfo$",this._textSelectionInfo$.asObservable())}getCurrentSelection(){return this._currentSelection}dispose(){this._textSelectionInfo$.complete()}refreshSelection(){this._currentSelection!=null&&this._refresh(this._currentSelection)}setCurrentSelection(e){this._currentSelection=e,this._refresh(e)}setCurrentSelectionNotRefresh(e){this._currentSelection=e}getTextSelectionInfo(){return this._textSelectionInfo}getTextRangesByParam(e){return this._getTextRanges(e)}getSelections(){return this._getTextRanges(this._currentSelection)}getFirst(){return this._getFirstByParam(this._currentSelection)}getLast(){return this._getLastByParam(this._currentSelection)}add(e){this._currentSelection!=null&&this._addByParam({...this._currentSelection,textRanges:e})}replaceTextRanges(e){this._currentSelection!=null&&this._textSelectionInfo$.next(e)}replaceTextRangesWithNoRefresh(e){this._currentSelection!=null&&this._replaceByParam({...this._currentSelection,textRanges:e})}_addByParam(e){const{pluginName:t,unitId:n,textRanges:r}=e;this._textSelectionInfo.has(t)||this._textSelectionInfo.set(t,new Map);const s=this._textSelectionInfo.get(t);s.has(n)?s.get(n).push(...r):s.set(n,[...r]),this._refresh({pluginName:t,unitId:n})}_clear(){this._currentSelection!=null&&this._clearByParam(this._currentSelection)}_remove(e){this._currentSelection!=null&&this._removeByParam(e,this._currentSelection)}_reset(){var e;this._currentSelection!=null&&(this._currentSelection={pluginName:Y,unitId:(e=this._currentSelection)==null?void 0:e.unitId},this._textSelectionInfo.clear(),this._refresh(this._currentSelection))}_resetPlugin(){this._currentSelection!=null&&(this._currentSelection.pluginName=Y,this._refresh(this._currentSelection))}_getTextRanges(e){var r;if(e==null)return;const{pluginName:t,unitId:n}=e;return(r=this._textSelectionInfo.get(t))==null?void 0:r.get(n)}_refresh(e){const t=this._getTextRanges(e)??[];this._textSelectionInfo$.next(t.map(n=>{const r=n.startOffset,s=n.endOffset,a=n.collapsed,c=n.style;return{startOffset:r,endOffset:s,collapsed:a,style:c}}))}_getFirstByParam(e){const t=this._getTextRanges(e);return t==null?void 0:t[0]}_getLastByParam(e){const t=this._getTextRanges(e);return t==null?void 0:t[t.length-1]}_replaceByParam(e){const{pluginName:t,unitId:n,textRanges:r}=e;this._textSelectionInfo.has(t)||this._textSelectionInfo.set(t,new Map),this._textSelectionInfo.get(t).set(n,r)}_clearByParam(e){const t=this._getTextRanges(e);t==null||t.splice(0),this._refresh(e)}_removeByParam(e,t){const n=this._getTextRanges(t);n==null||n.splice(e,1),this._refresh(t)}}var dt=Object.defineProperty,ut=Object.getOwnPropertyDescriptor,mt=(i,e,t,n)=>{for(var r=n>1?void 0:n?ut(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&dt(e,t,r),r},ht=(i,e)=>(t,n)=>e(t,n,i);p.DocViewModelManagerService=class{constructor(e){v(this,"_currentViewModelUnitId","");v(this,"_docViewModelMap",new Map);v(this,"_currentDocViewModel$",new oe.BehaviorSubject(null));v(this,"currentDocViewModel$",this._currentDocViewModel$.asObservable());this._currentUniverService=e}dispose(){this._currentDocViewModel$.complete(),this._docViewModelMap=new Map}getCurrent(){return this._docViewModelMap.get(this._currentViewModelUnitId)}getViewModel(e){var t;return(t=this._docViewModelMap.get(e))==null?void 0:t.docViewModel}setCurrent(e){var n;const t=this._currentUniverService.getUniverDocInstance(e);if(t==null)throw new Error(`Document data model with id ${e} not found when build view model.`);if(t.getBody()!=null){if(!this._docViewModelMap.has(e)){const r=this._buildDocViewModel(t);this._docViewModelMap.set(e,{unitId:e,docViewModel:r})}if(e===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY){const r=(n=this._docViewModelMap.get(e))==null?void 0:n.docViewModel;if(r==null)return;r.reset(t)}this._currentViewModelUnitId=e,this._currentDocViewModel$.next(this.getCurrent())}}_buildDocViewModel(e){return new I.DocumentViewModel(e)}},p.DocViewModelManagerService=mt([ht(0,o.IUniverInstanceService)],p.DocViewModelManagerService);const C={id:"doc.mutation.rich-text-editing",type:o.CommandType.MUTATION,handler:(i,e)=>{const{unitId:t,mutations:n}=e,s=i.get(o.IUniverInstanceService).getUniverDocInstance(t),c=i.get(p.DocViewModelManagerService).getViewModel(t);if(!s)throw new Error(`DocumentDataModel not found for unitId: ${t}`);const l=new o.MemoryCursor;l.reset(),n.forEach(u=>{const{segmentId:g,len:h}=u,m=c==null?void 0:c.getSelfOrHeaderFooterViewModel(g);if(u.t==="r"){const{len:f}=u;l.moveCursor(f)}else if(u.t==="i"){const{body:f}=u;if(f.dataStream.length>1&&/\r/.test(f.dataStream)){const _=s.getSelfOrHeaderFooterModel(g);m.reset(_)}else m.insert(f,l.cursor);l.moveCursor(h)}else if(u.t==="d")m.delete(l.cursor,h);else throw new Error(`Unknown mutation type for mutation: ${u}.`)});const d=s.apply(n);return{unitId:t,mutations:d}}},q={id:"doc.command.delete-left",type:o.CommandType.COMMAND,handler:async()=>!0},me={id:"doc.command.delete-right",type:o.CommandType.COMMAND,handler:async()=>!0},he={id:"doc.command.break-line",type:o.CommandType.COMMAND,handler:async()=>!0},fe={id:"doc.command.insert-text",type:o.CommandType.COMMAND,handler:async(i,e)=>{const t=i.get(o.IUndoRedoService),n=i.get(o.ICommandService),r=i.get(x),{range:s,segmentId:a,body:c,unitId:l,textRanges:d}=e,{startOffset:u,collapsed:g}=s,h={id:C.id,params:{unitId:l,mutations:[]}};g?h.params.mutations.push({t:"r",len:u,segmentId:a}):h.params.mutations.push(...X(s,a)),h.params.mutations.push({t:"i",body:c,len:c.dataStream.length,line:0,segmentId:a});const m=n.syncExecuteCommand(h.id,h.params);return r.replaceTextRanges(d),m?(t.pushUndoRedo({unitID:l,undoMutations:[{id:C.id,params:m}],redoMutations:[{id:C.id,params:h.params}],undo(){return n.syncExecuteCommand(C.id,m),r.replaceTextRanges([s]),!0},redo(){return n.syncExecuteCommand(C.id,h.params),r.replaceTextRanges(d),!0}}),!0):!1}};var Ae=(i=>(i[i.LEFT=0]="LEFT",i[i.RIGHT=1]="RIGHT",i))(Ae||{});const ge={id:"doc.command.delete-text",type:o.CommandType.COMMAND,handler:async(i,e)=>{const t=i.get(o.ICommandService),n=i.get(o.IUndoRedoService),r=i.get(x),{range:s,segmentId:a,unitId:c,direction:l,textRanges:d,len:u=1}=e,{collapsed:g,startOffset:h}=s,m={id:C.id,params:{unitId:c,mutations:[]}};g?(h>0&&m.params.mutations.push({t:"r",len:l===0?h-u:h,segmentId:a}),m.params.mutations.push({t:"d",len:u,line:0,segmentId:a})):m.params.mutations.push(...X(s,a));const f=t.syncExecuteCommand(m.id,m.params);return r.replaceTextRanges(d),f&&n.pushUndoRedo({unitID:c,undoMutations:[{id:C.id,params:f}],redoMutations:[{id:C.id,params:m.params}],undo(){return t.syncExecuteCommand(C.id,f),r.replaceTextRanges([s]),!0},redo(){return t.syncExecuteCommand(C.id,m.params),r.replaceTextRanges(d),!0}}),!1}},$e={id:"doc.command.update-text",type:o.CommandType.COMMAND,handler:async(i,e)=>{const{range:t,segmentId:n,updateBody:r,coverType:s,unitId:a,textRanges:c}=e,l=i.get(o.ICommandService),d=i.get(o.IUndoRedoService),u=i.get(x),g={id:C.id,params:{unitId:a,mutations:[]}},{startOffset:h,endOffset:m}=t;g.params.mutations.push({t:"r",len:h,segmentId:n}),g.params.mutations.push({t:"r",body:r,len:m-h,segmentId:n,coverType:s});const f=l.syncExecuteCommand(g.id,g.params);return u.replaceTextRanges(c),f?(d.pushUndoRedo({unitID:a,undoMutations:[{id:C.id,params:f}],redoMutations:[{id:C.id,params:g.params}],undo(){return l.syncExecuteCommand(C.id,f),u.replaceTextRanges(c),!0},redo(){return l.syncExecuteCommand(C.id,g.params),u.replaceTextRanges(c),!0}}),!0):!1}};class Be{constructor(){v(this,"_previousActiveRange",null);v(this,"_undoMutationParamsCache",[]);v(this,"_redoMutationParamsCache",[])}clearUndoRedoMutationParamsCache(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[]}setActiveRange(e){this._previousActiveRange=e}pushUndoRedoMutationParams(e,t){this._undoMutationParamsCache.push(e),this._redoMutationParamsCache.push(t)}fetchComposedUndoRedoMutationParams(e){if(this._undoMutationParamsCache.length===0||this._previousActiveRange==null)return null;const{unitId:t}=this._undoMutationParamsCache[0],{segmentId:n,startOffset:r,collapsed:s}=this._previousActiveRange,a={unitId:t,mutations:[]},c={unitId:t,mutations:[]};return s?(a.mutations.push({t:"r",len:r,segmentId:n}),c.mutations.push({t:"r",len:r,segmentId:n})):(r>0&&a.mutations.push({t:"r",len:r,segmentId:n}),a.mutations.push(this._undoMutationParamsCache[0].mutations.find(l=>l.t==="i")),c.mutations.push(...X(this._previousActiveRange,n))),e.length&&(a.mutations.push({t:"d",len:e.length,line:0,segmentId:n}),c.mutations.push({t:"i",body:{dataStream:e},len:e.length,line:0,segmentId:n})),{redoMutationParams:c,undoMutationParams:a,previousActiveRange:this._previousActiveRange}}dispose(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[],this._previousActiveRange=null}}const je={id:"doc.command.ime-input",type:o.CommandType.COMMAND,handler:async(i,e)=>{const{unitId:t,newText:n,oldTextLen:r,range:s,segmentId:a,textRanges:c,isCompositionEnd:l}=e,d=i.get(o.ICommandService),u=i.get(o.IUndoRedoService),g=i.get(x),h=i.get(Be),m={id:C.id,params:{unitId:t,mutations:[]}};s.collapsed?m.params.mutations.push({t:"r",len:s.startOffset,segmentId:a}):m.params.mutations.push(...X(s,a)),r>0&&m.params.mutations.push({t:"d",len:r,line:0,segmentId:a}),m.params.mutations.push({t:"i",body:{dataStream:n},len:n.length,line:0,segmentId:a});const f=d.syncExecuteCommand(m.id,m.params);if(h.pushUndoRedoMutationParams(f,m.params),g.replaceTextRanges(c),l){if(f){const _=h.fetchComposedUndoRedoMutationParams(n);if(_==null)return!1;const{undoMutationParams:S,redoMutationParams:M,previousActiveRange:R}=_;return u.pushUndoRedo({unitID:t,undoMutations:[{id:C.id,params:S}],redoMutations:[{id:C.id,params:M}],undo(){return d.syncExecuteCommand(C.id,S),g.replaceTextRanges([R]),!0},redo(){return d.syncExecuteCommand(C.id,M),g.replaceTextRanges(c),!0}}),!0}}else return!!f;return!1}},F={id:"doc.command.set-inline-format-bold",type:o.CommandType.COMMAND,handler:async()=>!0},Z={id:"doc.command.set-inline-format-italic",type:o.CommandType.COMMAND,handler:async()=>!0},J={id:"doc.command.set-inline-format-underline",type:o.CommandType.COMMAND,handler:async()=>!0},Q={id:"doc.command.set-inline-format-strikethrough",type:o.CommandType.COMMAND,handler:async()=>!0},k={id:"doc.command.set-inline-format-fontsize",type:o.CommandType.COMMAND,handler:async()=>!0},V={id:"doc.command.set-inline-format-font-family",type:o.CommandType.COMMAND,handler:async()=>!0},ee={id:"doc.command.set-inline-format-text-color",type:o.CommandType.COMMAND,handler:async()=>!0},Fe={id:"doc.command.set-inline-format",type:o.CommandType.COMMAND,handler:async(i,e)=>{const{segmentId:t,value:n,preCommandId:r}=e,s=i.get(o.IUndoRedoService),a=i.get(o.ICommandService),c=i.get(x),l=i.get(o.IUniverInstanceService),d=c.getSelections();if(!Array.isArray(d)||d.length===0)return!1;let u=l.getCurrentUniverDocInstance(),g=u.getUnitId();g===o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(u=l.getUniverDocInstance(o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),g=u.getUnitId());let h;const m={[F.id]:"bl",[Z.id]:"it",[J.id]:"ul",[Q.id]:"st",[k.id]:"fs",[V.id]:"ff",[ee.id]:"cl"};switch(r){case F.id:case Z.id:case J.id:case Q.id:{h=gt(u.body.textRuns,m[r],d);break}case k.id:case V.id:{h=n;break}case ee.id:{h={rgb:n};break}default:throw new Error(`Unknown command: ${r} in handleInlineFormat`)}const f={id:C.id,params:{unitId:g,mutations:[]}},_=new o.MemoryCursor;_.reset();for(const R of d){const{startOffset:b,endOffset:T}=R,$={dataStream:"",textRuns:[{st:0,ed:T-b,ts:{[m[r]]:h}}]},N=b-_.cursor;N!==0&&f.params.mutations.push({t:"r",len:N,segmentId:t}),f.params.mutations.push({t:"r",body:$,len:T-b,segmentId:t}),_.reset(),_.moveCursor(T)}const S=a.syncExecuteCommand(f.id,f.params),M=[F.id,k.id,V.id];return M.includes(r)&&c.refreshSelection(),S?(s.pushUndoRedo({unitID:g,undoMutations:[{id:C.id,params:S}],redoMutations:[{id:C.id,params:f.params}],undo(){return a.syncExecuteCommand(C.id,S),M.includes(r)&&c.refreshSelection(),!0},redo(){return a.syncExecuteCommand(C.id,f.params),M.includes(r)&&c.refreshSelection(),!0}}),!0):!1}};function ft(i){return i!==null&&typeof i=="object"}function gt(i,e,t){let n=0,r=0;for(;n!==i.length&&r!==t.length;){const{startOffset:s,endOffset:a}=t[r],{st:c,ed:l,ts:d}=i[n];if(a<=c)r++;else if(l<=s)n++;else{if((d==null?void 0:d[e])==null)return/bl|it/.test(e)?o.BooleanNumber.TRUE:{s:o.BooleanNumber.TRUE};if(d[e]===o.BooleanNumber.FALSE)return o.BooleanNumber.TRUE;if(ft(d[e])&&d[e].s===o.BooleanNumber.FALSE)return{s:o.BooleanNumber.TRUE};n++}}return/bl|it/.test(e)?o.BooleanNumber.FALSE:{s:o.BooleanNumber.FALSE}}const qe={id:"doc.command-replace-content",type:o.CommandType.COMMAND,handler:async(i,e)=>{var f;const{unitId:t,body:n,textRanges:r,segmentId:s=""}=e,a=i.get(o.IUniverInstanceService),c=i.get(o.ICommandService),l=i.get(x),d=i.get(o.IUndoRedoService),u=(f=a.getUniverDocInstance(t))==null?void 0:f.getSnapshot().body,g=l.getSelections();if(u==null||!Array.isArray(g)||g.length===0)return!1;const h=Je(t,s,u,n),m=c.syncExecuteCommand(h.id,h.params);return l.replaceTextRanges(r),m?(d.pushUndoRedo({unitID:t,undoMutations:[{id:C.id,params:m}],redoMutations:[{id:C.id,params:h.params}],undo(){return c.syncExecuteCommand(C.id,m),l.replaceTextRanges(g),!0},redo(){return c.syncExecuteCommand(C.id,h.params),l.replaceTextRanges(r),!0}}),!0):!1}},Ze={id:"doc.command-cover-content",type:o.CommandType.COMMAND,handler:async(i,e)=>{var u;const{unitId:t,body:n,segmentId:r=""}=e,s=i.get(o.IUniverInstanceService),a=i.get(o.ICommandService),c=i.get(o.IUndoRedoService),l=(u=s.getUniverDocInstance(t))==null?void 0:u.getSnapshot().body;if(l==null)return!1;const d=Je(t,r,l,n);return a.syncExecuteCommand(d.id,d.params),c.clearUndoRedo(t),!0}};function Je(i,e,t,n){const r={id:C.id,params:{unitId:i,mutations:[]}},s=(t==null?void 0:t.dataStream.length)-2;return s>0&&r.params.mutations.push({t:"d",len:s,line:0,segmentId:e}),n.dataStream.length>0&&r.params.mutations.push({t:"i",body:n,len:n.dataStream.length,line:0,segmentId:e}),r}const U={id:"doc.operation.move-cursor",type:o.CommandType.OPERATION,handler:(i,e)=>!!e},E={id:"doc.operation.move-selection",type:o.CommandType.OPERATION,handler:(i,e)=>!!e},ke={id:"doc.operation.set-selections",type:o.CommandType.OPERATION,handler:(i,e)=>(i.get(x).replaceTextRangesWithNoRefresh(e.ranges),!0)},_t=(i,e)=>{const t=i.get(o.IUniverInstanceService).getUniverDocInstance(e.unitId),n=(t==null?void 0:t.zoomRatio)||1;return{...o.Tools.deepClone(e),zoomRatio:n}},L={id:"doc.operation.set-zoom-ratio",type:o.CommandType.OPERATION,handler:(i,e)=>{const t=i.get(o.IUniverInstanceService).getUniverDocInstance(e.unitId);if(!t)return!1;const n=t.getSnapshot();return n.settings==null?n.settings={zoomRatio:e.zoomRatio}:n.settings.zoomRatio=e.zoomRatio,!0}},Qe={type:o.CommandType.COMMAND,id:"doc.command.set-zoom-ratio",handler:async(i,e)=>{const t=i.get(o.ICommandService),n=i.get(o.IUndoRedoService),r=i.get(o.IUniverInstanceService);let s=r.getCurrentUniverDocInstance().getUnitId(),a=1;if(e&&(s=e.documentId??s,a=e.zoomRatio??a),!r.getUniverDocInstance(s))return!1;const l={zoomRatio:a,unitId:s},d=_t(i,l);return t.syncExecuteCommand(L.id,l)?(n.pushUndoRedo({unitID:s,undoMutations:[{id:L.id,params:d}],redoMutations:[{id:L.id,params:l}]}),!0):!1}},et={id:"doc.operation.select-all",type:o.CommandType.COMMAND,handler:async i=>{const e=i.get(o.IUniverInstanceService),t=i.get(x),n=e.getCurrentUniverDocInstance().getSnapshot().body;if(n==null)return!1;const r=[{startOffset:0,endOffset:n.dataStream.length-2,collapsed:!1}];return t.replaceTextRanges(r),!0}},tt={id:"doc.command.inner-paste",type:o.CommandType.COMMAND,handler:async(i,e)=>{const{segmentId:t,body:n,textRanges:r}=e,s=i.get(o.IUndoRedoService),a=i.get(o.ICommandService),c=i.get(x),l=i.get(o.IUniverInstanceService),d=c.getSelections();if(!Array.isArray(d)||d.length===0)return!1;const g=l.getCurrentUniverDocInstance().getUnitId(),h={id:C.id,params:{unitId:g,mutations:[]}},m=new o.MemoryCursor;m.reset();for(const _ of d){const{startOffset:S,endOffset:M,collapsed:R}=_,b=S-m.cursor;R?h.params.mutations.push({t:"r",len:b,segmentId:t}):h.params.mutations.push(...X(_,t,m.cursor)),h.params.mutations.push({t:"i",body:n,len:n.dataStream.length,line:0,segmentId:t}),m.reset(),m.moveCursor(M)}const f=a.syncExecuteCommand(h.id,h.params);return c.replaceTextRanges(r),f?(s.pushUndoRedo({unitID:g,undoMutations:[{id:C.id,params:f}],redoMutations:[{id:C.id,params:h.params}],undo(){return a.syncExecuteCommand(C.id,f),c.replaceTextRanges(d),!0},redo(){return a.syncExecuteCommand(C.id,h.params),c.replaceTextRanges(r),!0}}),!0):!1}},_e={id:"doc.command.inner-cut",type:o.CommandType.COMMAND,handler:async(i,e)=>{const{segmentId:t,textRanges:n}=e,r=i.get(o.IUndoRedoService),s=i.get(o.ICommandService),a=i.get(x),c=i.get(o.IUniverInstanceService),l=a.getSelections();if(!Array.isArray(l)||l.length===0)return!1;const d=c.getCurrentUniverDocInstance().getUnitId(),u=c.getUniverDocInstance(d),g=o.getDocsUpdateBody(u.snapshot,t);if(g==null)return!1;const h={id:C.id,params:{unitId:d,mutations:[]}},m=new o.MemoryCursor;m.reset();for(const _ of l){const{startOffset:S,endOffset:M,collapsed:R}=_,b=S-m.cursor;R?h.params.mutations.push({t:"r",len:b,segmentId:t}):h.params.mutations.push(...pt(_,g,t,m.cursor)),m.reset(),m.moveCursor(M)}const f=s.syncExecuteCommand(h.id,h.params);return a.replaceTextRanges(n),f?(r.pushUndoRedo({unitID:d,undoMutations:[{id:C.id,params:f}],redoMutations:[{id:C.id,params:h.params}],undo(){return s.syncExecuteCommand(C.id,f),a.replaceTextRanges(l),!0},redo(){return s.syncExecuteCommand(C.id,h.params),a.replaceTextRanges(n),!0}}),!0):!1}};function pt(i,e,t="",n=0){const{startOffset:r,endOffset:s}=i,a=[],{paragraphs:c=[]}=e,l=r-n,d=s-n,u=c==null?void 0:c.find(g=>g.startIndex-n>=l&&g.startIndex-n<=d);if(l>0&&a.push({t:"r",len:l,segmentId:t}),u&&u.startIndex-n>l){const g=u.startIndex-n;a.push({t:"d",len:g-l,line:0,segmentId:t}),a.push({t:"r",len:1,segmentId:t}),d>g+1&&a.push({t:"d",len:d-g-1,line:0,segmentId:t})}else a.push({t:"d",len:d-l,line:0,segmentId:t});return a}const St=10,vt=6;function It(){return o.Tools.generateRandomId(vt)}function Ct(i){const e=i.match(/data-copy-id="([^\s]+)"/);return e&&e[1]?e[1]:null}class Mt{constructor(){v(this,"_cache",new o.LRUMap(St))}set(e,t){this._cache.set(e,t)}get(e){return this._cache.get(e)}clear(){this._cache.clear()}}const nt=new Mt;function Ot(i){const e=i.style,t={};for(let n=0;n<e.length;n++){const r=e[n],s=e.getPropertyValue(r);switch(r){case"margin-top":{const a=parseInt(s);t.spaceAbove=/pt/.test(s)?Ve(a):a;break}case"margin-bottom":{const a=parseInt(s);t.spaceBelow=/pt/.test(s)?Ve(a):a;break}}}return Object.getOwnPropertyNames(t).length?t:null}function Ve(i){return i/.75}function ze(i){const e=i.style,t={},n=i.tagName.toLowerCase();switch(n){case"b":case"em":case"strong":{t.bl=o.BooleanNumber.TRUE;break}case"s":{t.st={s:o.BooleanNumber.TRUE};break}case"u":{t.ul={s:o.BooleanNumber.TRUE};break}case"i":{t.it=o.BooleanNumber.TRUE;break}case"sub":case"sup":{t.va=n==="sup"?o.BaselineOffset.SUPERSCRIPT:o.BaselineOffset.SUBSCRIPT;break}}for(let r=0;r<e.length;r++){const s=e[r],a=e.getPropertyValue(s);switch(s){case"font-family":{t.ff=a;break}case"font-size":{const c=parseInt(a);Number.isNaN(c)||(t.fs=/pt$/.test(a)?Ve(c):c);break}case"font-style":{a==="italic"&&(t.it=o.BooleanNumber.TRUE);break}case"font-weight":{Number(a)>400&&(t.bl=o.BooleanNumber.TRUE);break}case"text-decoration":{/underline/.test(a)?t.ul={s:o.BooleanNumber.TRUE}:/overline/.test(a)?t.ol={s:o.BooleanNumber.TRUE}:/line-through/.test(a)&&(t.st={s:o.BooleanNumber.TRUE});break}case"color":{const c=new Ke.TinyColor(a);c.isValid&&(t.cl={rgb:c.toRgbString()});break}case"background-color":{const c=new Ke.TinyColor(a);c.isValid&&(t.bg={rgb:c.toRgbString()});break}}}return t}function Rt(i){const e=new DOMParser,t=`<x-univer id="univer-root">${i}</x-univer>`;return e.parseFromString(t,"text/html").querySelector("#univer-root")}function rt(i,e){const t=i.tagName.toLowerCase();return typeof e=="string"?t===e:Array.isArray(e)?e.some(n=>n===t):e(i)}const we=class we{constructor(){v(this,"styleCache",new Map);v(this,"styleRules",[]);v(this,"afterProcessRules",[])}static use(e){if(this.pluginList.includes(e))throw new Error(`Univer paste plugin ${e.name} already added`);this.pluginList.push(e)}convert(e){const t=we.pluginList.find(s=>s.checkPasteType(e)),n=Rt(e),r={dataStream:"",textRuns:[]};return t&&(this.styleRules=[...t.stylesRules],this.afterProcessRules=[...t.afterProcessRules]),this.styleCache.clear(),this.process(null,n==null?void 0:n.childNodes,r),this.styleCache.clear(),this.styleRules=[],this.afterProcessRules=[],r}process(e,t,n){var r;for(const s of t)if(s.nodeType===Node.TEXT_NODE){const a=(r=s.nodeValue)==null?void 0:r.replace(/[\r\n]/g,"");let c;e&&this.styleCache.has(e)&&(c=this.styleCache.get(e)),n.dataStream+=a,c&&Object.getOwnPropertyNames(c).length&&n.textRuns.push({st:n.dataStream.length-a.length,ed:n.dataStream.length,ts:c})}else if(s.nodeType===Node.ELEMENT_NODE){const a=e?this.styleCache.get(e):{},c=this.styleRules.find(({filter:g})=>rt(s,g)),l=c?c.getStyle(s):ze(s);this.styleCache.set(s,{...a,...l});const{childNodes:d}=s;this.process(s,d,n);const u=this.afterProcessRules.find(({filter:g})=>rt(s,g));u&&u.handler(n,s)}}};v(we,"pluginList",[]);let te=we;const yt={name:"univer-doc-paste-plugin-lark",checkPasteType(i){return/lark-record-clipboard/i.test(i)},stylesRules:[{filter:["s"],getStyle(i){const e=ze(i);return{st:{s:o.BooleanNumber.TRUE},...e}}}],afterProcessRules:[{filter(i){return i.tagName==="DIV"&&/ace-line/i.test(i.className)},handler(i){i.paragraphs==null&&(i.paragraphs=[]),i.paragraphs.push({startIndex:i.dataStream.length}),i.dataStream+="\r"}}]},Dt={name:"univer-doc-paste-plugin-word",checkPasteType(i){return/word|mso/i.test(i)},stylesRules:[{filter:["b"],getStyle(i){const e=ze(i);return{bl:o.BooleanNumber.TRUE,...e}}}],afterProcessRules:[{filter(i){return i.tagName==="P"&&/mso/i.test(i.className)},handler(i,e){i.paragraphs==null&&(i.paragraphs=[]);const t={startIndex:i.dataStream.length},n=Ot(e);n&&(t.paragraphStyle=n),i.paragraphs.push(t),i.dataStream+="\r"}}]};function bt(i,e){const{st:t,ed:n,ts:r={}}=e,{ff:s,fs:a,it:c,bl:l,ul:d,st:u,ol:g,bg:h,cl:m,va:f}=r;let _=i.slice(t,n);const S=[];return c===o.BooleanNumber.TRUE&&(_=`<i>${_}</i>`),f===o.BaselineOffset.SUPERSCRIPT?_=`<sup>${_}</sup>`:f===o.BaselineOffset.SUBSCRIPT&&(_=`<sub>${_}</sub>`),(d==null?void 0:d.s)===o.BooleanNumber.TRUE&&(_=`<u>${_}</u>`),(u==null?void 0:u.s)===o.BooleanNumber.TRUE&&(_=`<s>${_}</s>`),l===o.BooleanNumber.TRUE&&(_=`<strong>${_}</strong>`),s&&S.push(`font-family: ${s}`),m&&S.push(`color: ${m.rgb}`),a&&S.push(`font-size: ${a}px`),g&&S.push("text-decoration: overline"),h&&S.push(`background: ${h.rgb}`),S.length?`<span style="${S.join(";")}">${_}</span>`:_}function it(i,e=!0){const{dataStream:t,textRuns:n=[],paragraphs:r=[]}=i;let s=0;const a=[],c=[];for(const l of n){const{st:d,ed:u}=l;if(d!==s&&a.push(t.slice(s,d)),a.push(bt(t,l)),s=u,e)for(const g of r){const{startIndex:h,paragraphStyle:m={}}=g;if(h>=d&&h<=u){const{spaceAbove:f,spaceBelow:_}=m,S=[];f!=null&&(typeof f=="number"?S.push(`margin-top: ${f}px`):S.push(`margin-top: ${f.v}px`)),_!=null&&(typeof _=="number"?S.push(`margin-bottom: ${_}px`):S.push(`margin-bottom: ${_.v}px`)),c.push(`<p className="UniverNormal" ${S.length?`style="${S.join(";")}"`:""}>${a.join("")}</p>`),a.length=0}}}return c.join("")+a.join("")}class xt{convert(e){if(e.length===0)throw new Error("The bodyList length at least to be 1");if(e.length===1)return it(e[0]);let t="";for(const n of e)t+='<p className="UniverNormal">',t+=it(n,!1),t+="</p>";return t}}var Tt=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,Ut=(i,e,t,n)=>{for(var r=n>1?void 0:n?Pt(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&Tt(e,t,r),r},st=(i,e)=>(t,n)=>e(t,n,i);te.use(Dt),te.use(yt);const at=y.createIdentifier("doc.clipboard-service");let We=class extends o.Disposable{constructor(e,t){super();v(this,"_clipboardHooks",[]);v(this,"_htmlToUDM",new te);v(this,"_umdToHtml",new xt);this._currentUniverService=e,this._clipboardInterfaceService=t}async queryClipboardData(){const e=await this._clipboardInterfaceService.read();if(e.length===0)return Promise.reject();const t=e[0],n=await t.getType(O.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()),r=await t.getType(O.HTML_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text());if(!r)return{dataStream:n};const s=Ct(r);if(s){const a=nt.get(s);if(a)return a}return this._htmlToUDM.convert(r)}async setClipboardData(e){const t=It(),n=e.length>1?e.map(s=>s.dataStream).join(`
|
|
2
|
+
`):e[0].dataStream;let r=this._umdToHtml.convert(e);return e.length===1&&(r=r.replace(/(<[a-z]+)/,(s,a)=>`${a} data-copy-id="${t}"`),nt.set(t,e[0])),this._clipboardInterfaceService.write(n,r)}addClipboardHook(e){return this._clipboardHooks.push(e),o.toDisposable(()=>{const t=this._clipboardHooks.indexOf(e);t>-1&&this._clipboardHooks.splice(t,1)})}};We=Ut([st(0,o.IUniverInstanceService),st(1,O.IClipboardInterfaceService)],We);var Et=Object.defineProperty,Nt=Object.getOwnPropertyDescriptor,wt=(i,e,t,n)=>{for(var r=n>1?void 0:n?Nt(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&Et(e,t,r),r},z=(i,e)=>(t,n)=>e(t,n,i);let pe=class extends o.Disposable{constructor(i,e,t,n,r,s){super(),this._logService=i,this._commandService=e,this._currentUniverService=t,this._docClipboardService=n,this._textSelectionRenderManager=r,this._contextService=s,this._commandExecutedListener(),this.initialize()}initialize(){[le,de,ue].forEach(i=>this.disposeWithMe(this._commandService.registerAsMultipleCommand(i))),[tt,_e].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_commandExecutedListener(){const i=[de.id,le.id,ue.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)&&!(!this._contextService.getContextValue(o.FOCUSING_DOC)&&!this._contextService.getContextValue(o.FOCUSING_EDITOR)))switch(e.id){case ue.id:{this._handlePaste();break}case le.id:{this._handleCopy();break}case de.id:{this._handleCut();break}default:throw new Error(`Unhandled command ${e.id}`)}}))}async _handlePaste(){const{_docClipboardService:i}=this,{segmentId:e,endOffset:t,style:n}=this._textSelectionRenderManager.getActiveRange()??{},r=this._textSelectionRenderManager.getAllTextRanges();if(e==null&&this._logService.error("[DocClipboardController] segmentId is not existed"),t!=null)try{const s=await i.queryClipboardData();let a=t;for(const l of r){const{startOffset:d,endOffset:u}=l;d==null||u==null||u<=t&&(a+=s.dataStream.length-(u-d))}const c=[{startOffset:a,endOffset:a,collapsed:!0,style:n}];this._commandService.executeCommand(tt.id,{body:s,segmentId:e,textRanges:c})}catch{this._logService.error("[DocClipboardController] clipboard is empty")}}_getDocumentBodyInRanges(){const i=this._textSelectionRenderManager.getAllTextRanges(),e=this._currentUniverService.getCurrentUniverDocInstance(),{dataStream:t,textRuns:n=[],paragraphs:r=[]}=e.getBody(),s=[];for(const a of i){const{startOffset:c,endOffset:l,collapsed:d}=a;if(d||c==null||l==null)continue;const u={dataStream:t.slice(c,l)},g=[];for(const m of n){const f=o.Tools.deepClone(m),{st:_,ed:S}=f;o.Tools.hasIntersectionBetweenTwoRanges(_,S,c,l)&&(c>=_&&c<=S?g.push({...f,st:c,ed:Math.min(l,S)}):l>=_&&l<=S?g.push({...f,st:Math.max(c,_),ed:l}):g.push(f))}g.length&&(u.textRuns=g.map(m=>{const{st:f,ed:_}=m;return{...m,st:f-c,ed:_-c}}));const h=[];for(const m of r){const{startIndex:f}=m;f>=c&&f<=l&&h.push(o.Tools.deepClone(m))}h.length&&(u.paragraphs=h.map(m=>({...m,startIndex:m.startIndex-c}))),s.push(u)}return s}async _handleCopy(){const{_docClipboardService:i}=this,e=this._getDocumentBodyInRanges();try{i.setClipboardData(e)}catch{this._logService.error("[DocClipboardController] set clipboard failed")}}async _handleCut(){const{segmentId:i,endOffset:e,style:t}=this._textSelectionRenderManager.getActiveRange()??{},n=this._textSelectionRenderManager.getAllTextRanges();if(i==null&&this._logService.error("[DocClipboardController] segmentId is not existed"),e!=null){this._handleCopy();try{let r=e;for(const a of n){const{startOffset:c,endOffset:l}=a;c==null||l==null||l<=e&&(r-=l-c)}const s=[{startOffset:r,endOffset:r,collapsed:!0,style:t}];this._commandService.executeCommand(_e.id,{segmentId:i,textRanges:s})}catch{this._logService.error("[DocClipboardController] cut content failed")}}}};pe=wt([o.OnLifecycle(o.LifecycleStages.Rendered,pe),z(0,o.ILogService),z(1,o.ICommandService),z(2,o.IUniverInstanceService),z(3,at),z(4,I.ITextSelectionRenderManager),z(5,o.IContextService)],pe);var Lt=Object.defineProperty,At=Object.getOwnPropertyDescriptor,$t=(i,e,t,n)=>{for(var r=n>1?void 0:n?At(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&Lt(e,t,r),r},ot=(i,e)=>(t,n)=>e(t,n,i);p.DocSkeletonManagerService=class{constructor(e,t){v(this,"_currentSkeletonUnitId","");v(this,"_docSkeletonMap",new Map);v(this,"_currentSkeleton$",new oe.BehaviorSubject(null));v(this,"currentSkeleton$",this._currentSkeleton$.asObservable());v(this,"_currentSkeletonBefore$",new oe.BehaviorSubject(null));v(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._localeService=e,this._docViewModelManagerService=t,this.initialize()}initialize(){this._docViewModelManagerService.currentDocViewModel$.subscribe(e=>{e!=null&&this._setCurrent(e)})}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._docSkeletonMap=new Map}getCurrent(){return this.getSkeletonByUnitId(this._currentSkeletonUnitId)}makeDirtyCurrent(e=!0){this.makeDirty(this._currentSkeletonUnitId,e)}makeDirty(e,t=!0){const n=this.getSkeletonByUnitId(e);n!=null&&(n.dirty=t)}_setCurrent(e){const{unitId:t}=e;if(this._docSkeletonMap.has(t)){const n=this.getSkeletonByUnitId(t);n.skeleton.calculate(),n.dirty=!0}else{const n=this._buildSkeleton(e.docViewModel);n.calculate(),this._docSkeletonMap.set(t,{unitId:t,skeleton:n,dirty:!1})}return this._currentSkeletonUnitId=t,this._currentSkeletonBefore$.next(this.getCurrent()),this._currentSkeleton$.next(this.getCurrent()),this.getCurrent()}getSkeletonByUnitId(e){return this._docSkeletonMap.get(e)}_buildSkeleton(e){return I.DocumentSkeleton.create(e,this._localeService)}},p.DocSkeletonManagerService=$t([ot(0,y.Inject(o.LocaleService)),ot(1,y.Inject(p.DocViewModelManagerService))],p.DocSkeletonManagerService);var Bt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Ft=(i,e,t,n)=>{for(var r=n>1?void 0:n?jt(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&Bt(e,t,r),r},Se=(i,e)=>(t,n)=>e(t,n,i);let ve=class extends o.Disposable{constructor(i,e,t,n){super(),this._docSkeletonManagerService=i,this._currentUniverService=e,this._textSelectionRenderManager=t,this._commandService=n,this._initialize(),this._commandExecutedListener()}_initialize(){}_commandExecutedListener(){const i=[q.id,me.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id))switch(e.id){case q.id:this._handleDeleteLeft();break;case me.id:this._handleDeleteRight();break;default:throw new Error("Unknown command")}}))}_handleDeleteLeft(){var m;const i=this._textSelectionRenderManager.getActiveRange(),e=(m=this._docSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(i==null||e==null)return;const t=this._currentUniverService.getCurrentUniverDocInstance(),{startOffset:n,collapsed:r,segmentId:s,style:a}=i;if(n===0&&r)return;const c=e.findNodeByCharIndex(n),l=I.hasListSpan(c),d=I.isIndentBySpan(c,t.body);let u=n;const g=e.findNodeByCharIndex(n-1);if(I.isFirstSpan(c)&&g!==c&&(l===!0||d===!0)){const f=I.getParagraphBySpan(c,t.body);if(f==null)return;const _=f==null?void 0:f.startIndex,S={startIndex:0},M=f.paragraphStyle;if(l===!0){const b=f.paragraphStyle;b&&(S.paragraphStyle=b)}else if(d===!0){const b=f.bullet;b&&(S.bullet=b),M!=null&&(S.paragraphStyle={...M},delete S.paragraphStyle.hanging,delete S.paragraphStyle.indentStart)}const R=[{startOffset:u,endOffset:u,collapsed:!0,style:a}];this._commandService.executeCommand($e.id,{unitId:t.getUnitId(),updateBody:{dataStream:"",paragraphs:[{...S}]},range:{startOffset:_,endOffset:_+1,collapsed:!1},textRanges:R,coverType:o.UpdateDocsAttributeType.REPLACE,segmentId:s})}else{const{endNodePosition:f}=i;if(f!=null){const _=e.findSpanByPosition(f);I.hasListSpan(_)&&!I.isSameLine(c,_)&&(i.endOffset-=1)}if(r===!0){u-=g.count;const _=[{startOffset:u,endOffset:u,collapsed:!0,style:a}];this._commandService.executeCommand(ge.id,{unitId:t.getUnitId(),range:i,segmentId:s,direction:Ae.LEFT,len:g.count,textRanges:_})}else{const _=this._getTextRangesWhenDelete();this._commandService.executeCommand(_e.id,{segmentId:s,textRanges:_})}}e==null||e.calculate()}_handleDeleteRight(){var c;const i=this._textSelectionRenderManager.getActiveRange(),e=(c=this._docSkeletonManagerService.getCurrent())==null?void 0:c.skeleton;if(i==null||e==null)return;const t=this._currentUniverService.getCurrentUniverDocInstance(),{startOffset:n,collapsed:r,segmentId:s,style:a}=i;if(!(n===t.getBody().dataStream.length-2&&r)){if(r===!0){const l=[{startOffset:n,endOffset:n,collapsed:!0,style:a}],d=e.findNodeByCharIndex(n);this._commandService.executeCommand(ge.id,{unitId:t.getUnitId(),range:i,segmentId:s,direction:Ae.RIGHT,textRanges:l,len:d.count})}else{const l=this._getTextRangesWhenDelete();this._commandService.executeCommand(_e.id,{segmentId:s,textRanges:l})}e==null||e.calculate()}}_getTextRangesWhenDelete(){const i=this._textSelectionRenderManager.getActiveRange(),e=this._textSelectionRenderManager.getAllTextRanges();let t=i.endOffset;for(const r of e){const{startOffset:s,endOffset:a}=r;s==null||a==null||a<=i.endOffset&&(t-=a-s)}return[{startOffset:t,endOffset:t,collapsed:!0,style:i.style}]}};ve=Ft([o.OnLifecycle(o.LifecycleStages.Rendered,ve),Se(0,y.Inject(p.DocSkeletonManagerService)),Se(1,o.IUniverInstanceService),Se(2,I.ITextSelectionRenderManager),Se(3,o.ICommandService)],ve);var kt=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,zt=(i,e,t,n)=>{for(var r=n>1?void 0:n?Vt(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&kt(e,t,r),r},Ge=(i,e)=>(t,n)=>e(t,n,i);let Ie=class extends o.Disposable{constructor(i,e,t){super(),this._docSkeletonManagerService=i,this._renderManagerService=e,this._commandService=t,this._initialRenderRefresh(),this._commandExecutedListener()}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeletonBefore$.subscribe(i=>{if(i==null)return;const{skeleton:e,unitId:t}=i,n=this._renderManagerService.getRenderById(t);if(n==null)return;const{mainComponent:r}=n;r.changeSkeleton(e),this._recalculateSizeBySkeleton(n,e)})}_recalculateSizeBySkeleton(i,e){var c;const{mainComponent:t}=i,n=t,r=(c=e.getSkeletonData())==null?void 0:c.pages;if(r==null)return;let s=0,a=0;for(let l=0,d=r.length;l<d;l++){const u=r[l],{pageWidth:g,pageHeight:h}=u;n.pageLayoutType===I.PageLayoutType.VERTICAL?(a+=h,l!==d-1&&(a+=n.pageMarginTop),s=Math.max(s,g)):n.pageLayoutType===I.PageLayoutType.HORIZONTAL&&(s+=g,l!==d-1&&(s+=n.pageMarginLeft),a=Math.max(a,h))}n.resize(s,a)}_commandExecutedListener(){const i=[C.id],e=[o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(i.includes(t.id)){const r=t.params,{unitId:s}=r,a=this._docSkeletonManagerService.getSkeletonByUnitId(s);if(a==null)return;const{skeleton:c}=a,l=this._renderManagerService.getRenderById(s);if(l==null)return;if(c.calculate(),e.includes(s)){(n=l.mainComponent)==null||n.makeDirty();return}this._recalculateSizeBySkeleton(l,c)}}))}};Ie=zt([o.OnLifecycle(o.LifecycleStages.Rendered,Ie),Ge(0,y.Inject(p.DocSkeletonManagerService)),Ge(1,I.IRenderManagerService),Ge(2,o.ICommandService)],Ie);var Wt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,Ht=(i,e,t,n)=>{for(var r=n>1?void 0:n?Gt(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&Wt(e,t,r),r},ne=(i,e)=>(t,n)=>e(t,n,i);let Ce=class extends o.Disposable{constructor(e,t,n,r,s){super();v(this,"_liquid",new I.Liquid);v(this,"_pageMarginCache",new Map);this._docSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._commandService=r,this._floatingObjectManagerService=s,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialRenderRefresh(),this._updateOnPluginChange()}_updateOnPluginChange(){this._floatingObjectManagerService.pluginUpdate$.subscribe(e=>{const t=this._docSkeletonManagerService.getCurrent();if(t==null)return;const{unitId:n,skeleton:r}=t,s=this._renderManagerService.getRenderById(n);if(s==null)return;const{mainComponent:a,components:c,scene:l}=s,d=a,{left:u,top:g}=d;e.forEach(h=>{const{unitId:m,subComponentId:f,floatingObjectId:_,floatingObject:S}=h,{left:M=0,top:R=0,width:b=0,height:T=0,angle:$,flipX:N,flipY:ie,skewX:se,skewY:ae}=S,D=this._pageMarginCache.get(_),w=(D==null?void 0:D.marginLeft)||0,P=(D==null?void 0:D.marginTop)||0;r==null||r.getViewModel().getDataModel().updateDrawing(_,{left:M-u-w,top:R-g-P,height:T,width:b})}),r==null||r.calculate(),a==null||a.makeDirty()})}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;const{skeleton:t,unitId:n}=e,r=this._renderManagerService.getRenderById(n);if(r==null)return;const{mainComponent:s}=r;s.changeSkeleton(t),this._refreshFloatingObject(n,t,r)})}_commandExecutedListener(){const e=[C.id,L.id],t=[o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var r;if(e.includes(n.id)){const s=n.params,{unitId:a}=s,c=this._docSkeletonManagerService.getCurrent();if(c==null)return;const{unitId:l,skeleton:d}=c;if(a!==l)return;const u=this._renderManagerService.getRenderById(l);if(u==null)return;if(t.includes(l)){(r=u.mainComponent)==null||r.makeDirty();return}this._refreshFloatingObject(l,d,u)}}))}_refreshFloatingObject(e,t,n){const r=t==null?void 0:t.getSkeletonData(),{mainComponent:s,scene:a}=n,c=s;if(!r)return;const{left:l,top:d,pageLayoutType:u,pageMarginLeft:g,pageMarginTop:h}=c,{pages:m}=r,f=[];a.getAncestorScale(),this._liquid.reset(),this._pageMarginCache.clear();for(let _=0,S=m.length;_<S;_++){const M=m[_],{skeDrawings:R,marginLeft:b,marginTop:T}=M;this._liquid.translatePagePadding(M),R.forEach($=>{const{aLeft:N,aTop:ie,height:se,width:ae,objectId:D}=$;f.push({unitId:e,subComponentId:o.DEFAULT_DOCUMENT_SUB_COMPONENT_ID,floatingObjectId:D,floatingObject:{left:N+l+this._liquid.x,top:ie+d+this._liquid.y,width:ae,height:se}}),this._pageMarginCache.set(D,{marginLeft:this._liquid.x,marginTop:this._liquid.y})}),this._liquid.translatePage(M,u,g,h)}this._floatingObjectManagerService.BatchAddOrUpdate(f)}};Ce=Ht([o.OnLifecycle(o.LifecycleStages.Steady,Ce),ne(0,y.Inject(p.DocSkeletonManagerService)),ne(1,o.IUniverInstanceService),ne(2,I.IRenderManagerService),ne(3,o.ICommandService),ne(4,o.IFloatingObjectManagerService)],Ce);var Kt=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,Xt=(i,e,t,n)=>{for(var r=n>1?void 0:n?Yt(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&Kt(e,t,r),r},A=(i,e)=>(t,n)=>e(t,n,i);let Me=class extends o.Disposable{constructor(e,t,n,r,s,a,c){super();v(this,"_previousIMEContent","");v(this,"_previousIMERange");v(this,"_onStartSubscription");v(this,"_onUpdateSubscription");v(this,"_onEndSubscription");this._docSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._textSelectionRenderManager=r,this._textSelectionManagerService=s,this._imeInputManagerService=a,this._commandService=c,this._initialize()}dispose(){var e,t,n;(e=this._onStartSubscription)==null||e.unsubscribe(),(t=this._onUpdateSubscription)==null||t.unsubscribe(),(n=this._onEndSubscription)==null||n.unsubscribe()}_initialize(){this._initialOnCompositionstart(),this._initialOnCompositionUpdate(),this._initialOnCompositionend()}_initialOnCompositionstart(){this._onStartSubscription=this._textSelectionRenderManager.onCompositionstart$.subscribe(e=>{if(e==null)return;const{activeRange:t}=e;t!=null&&(this._imeInputManagerService.clearUndoRedoMutationParamsCache(),this._imeInputManagerService.setActiveRange(o.Tools.deepClone(t)),this._previousIMERange=t)})}_initialOnCompositionUpdate(){this._onUpdateSubscription=this._textSelectionRenderManager.onCompositionupdate$.subscribe(async e=>{this._updateContent(e,!0)})}_initialOnCompositionend(){this._onEndSubscription=this._textSelectionRenderManager.onCompositionend$.subscribe(e=>{this._updateContent(e,!1)})}async _updateContent(e,t){var f;const n=(f=this._docSkeletonManagerService.getCurrent())==null?void 0:f.skeleton;if(this._previousIMERange==null||e==null||n==null)return;const r=this._currentUniverService.getCurrentUniverDocInstance(),{event:s,activeRange:a}=e,{startOffset:c,segmentId:l,style:d}=this._previousIMERange;if(n==null||a==null)return;const g=s.data;if(g===this._previousIMEContent&&t)return;const h=g.length,m=[{startOffset:c+h,endOffset:c+h,collapsed:!0,style:d}];await this._commandService.executeCommand(je.id,{unitId:r.getUnitId(),newText:g,oldTextLen:this._previousIMEContent.length,range:this._previousIMERange,textRanges:m,isCompositionEnd:!t,segmentId:l}),n.calculate(),t?(this._previousIMERange.collapsed||(this._previousIMERange.collapsed=!0),this._previousIMEContent=g):this._resetIME()}_resetIME(){this._previousIMEContent="",this._previousIMERange=null,this._imeInputManagerService.clearUndoRedoMutationParamsCache(),this._imeInputManagerService.setActiveRange(null)}_getDocObject(){return B(this._currentUniverService,this._renderManagerService)}};Me=Xt([o.OnLifecycle(o.LifecycleStages.Rendered,Me),A(0,y.Inject(p.DocSkeletonManagerService)),A(1,o.IUniverInstanceService),A(2,I.IRenderManagerService),A(3,I.ITextSelectionRenderManager),A(4,y.Inject(x)),A(5,y.Inject(Be)),A(6,o.ICommandService)],Me);var qt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Jt=(i,e,t,n)=>{for(var r=n>1?void 0:n?Zt(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&qt(e,t,r),r},Oe=(i,e)=>(t,n)=>e(t,n,i);let Re=class extends o.Disposable{constructor(i,e,t,n){super(),this._currentUniverService=i,this._textSelectionRenderManager=e,this._textSelectionManagerService=t,this._commandService=n,this._commandExecutedListener()}_commandExecutedListener(){const i=[F.id,Z.id,J.id,Q.id,k.id,V.id,ee.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{i.includes(e.id)&&this._handleInlineFormat(e)}))}_handleInlineFormat(i){const{segmentId:e}=this._textSelectionRenderManager.getActiveRange()??{};e!=null&&this._commandService.executeCommand(Fe.id,{segmentId:e,preCommandId:i.id,...i.params??{}})}};Re=Jt([o.OnLifecycle(o.LifecycleStages.Rendered,Re),Oe(0,o.IUniverInstanceService),Oe(1,I.ITextSelectionRenderManager),Oe(2,y.Inject(x)),Oe(3,o.ICommandService)],Re);var Qt=Object.defineProperty,en=Object.getOwnPropertyDescriptor,tn=(i,e,t,n)=>{for(var r=n>1?void 0:n?en(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&Qt(e,t,r),r},W=(i,e)=>(t,n)=>e(t,n,i);function nn(i){const e=[];for(let t=0,n=i.length;t<n;t++)i[t]===o.DataStreamTreeTokenType.PARAGRAPH&&e.push({startIndex:t});return e}let ye=class extends o.Disposable{constructor(e,t,n,r,s,a){super();v(this,"_onInputSubscription");this._docSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._textSelectionRenderManager=r,this._textSelectionManagerService=s,this._commandService=a,this._initialize(),this._commandExecutedListener()}dispose(){var e;(e=this._onInputSubscription)==null||e.unsubscribe()}_initialize(){}_commandExecutedListener(){const e=[he.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{e.includes(t.id)&&this._handleBreakLine()}))}_handleBreakLine(){var d;const e=(d=this._docSkeletonManagerService.getCurrent())==null?void 0:d.skeleton,t=this._textSelectionRenderManager.getActiveRange();if(t==null||e==null)return;const r=this._currentUniverService.getCurrentUniverDocInstance().getUnitId(),{startOffset:s,segmentId:a,style:c}=t,l=[{startOffset:s+1,endOffset:s+1,collapsed:!0,style:c}];this._commandService.executeCommand(fe.id,{unitId:r,body:{dataStream:o.DataStreamTreeTokenType.PARAGRAPH,paragraphs:nn(o.DataStreamTreeTokenType.PARAGRAPH)},range:t,textRanges:l,segmentId:a}),e==null||e.calculate()}_getDocObject(){return B(this._currentUniverService,this._renderManagerService)}};ye=tn([o.OnLifecycle(o.LifecycleStages.Rendered,ye),W(0,y.Inject(p.DocSkeletonManagerService)),W(1,o.IUniverInstanceService),W(2,I.IRenderManagerService),W(3,I.ITextSelectionRenderManager),W(4,y.Inject(x)),W(5,o.ICommandService)],ye);var rn=Object.defineProperty,sn=Object.getOwnPropertyDescriptor,an=(i,e,t,n)=>{for(var r=n>1?void 0:n?sn(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&rn(e,t,r),r},G=(i,e)=>(t,n)=>e(t,n,i);let De=class extends o.Disposable{constructor(e,t,n,r,s,a){super();v(this,"_onInputSubscription");this._docSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._textSelectionRenderManager=r,this._textSelectionManagerService=s,this._commandService=a,this._initialize(),this._commandExecutedListener()}dispose(){var e;(e=this._onInputSubscription)==null||e.unsubscribe()}_initialize(){}_commandExecutedListener(){const e=[U.id,E.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(!e.includes(t.id))return;const n=t.params;switch(t.id){case U.id:return this._handleMoveCursor(n.direction);case E.id:return this._handleShiftMoveSelection(n.direction);default:throw new Error("Unknown command")}}))}_handleShiftMoveSelection(e){var _;const t=this._textSelectionRenderManager.getActiveRange(),n=this._textSelectionRenderManager.getAllTextRanges(),r=this._currentUniverService.getCurrentUniverDocInstance(),s=(_=this._docSkeletonManagerService.getCurrent())==null?void 0:_.skeleton,a=this._getDocObject();if(t==null||s==null||a==null)return;const{startOffset:c,endOffset:l,style:d,collapsed:u,direction:g}=t;if(n.length>1){let S=1/0,M=-1/0;for(const R of n)S=Math.min(S,R.startOffset),M=Math.max(M,R.endOffset);this._textSelectionManagerService.replaceTextRanges([{startOffset:e===o.Direction.LEFT||e===o.Direction.UP?M:S,endOffset:e===o.Direction.LEFT||e===o.Direction.UP?S:M,collapsed:!1,style:d}]);return}const h=u||g===I.RANGE_DIRECTION.FORWARD?c:l;let m=u||g===I.RANGE_DIRECTION.FORWARD?l:c;const f=r.getBody().dataStream.length??1/0;if(e===o.Direction.LEFT||e===o.Direction.RIGHT){const S=s.findNodeByCharIndex(m-1),M=s.findNodeByCharIndex(m);m=e===o.Direction.RIGHT?m+M.count:m-S.count,m=Math.min(f-2,Math.max(0,m)),this._textSelectionManagerService.replaceTextRanges([{startOffset:h,endOffset:m,collapsed:h===m,style:d}])}else{const S=s.findNodeByCharIndex(m),M=a.document.getOffsetConfig(),R=this._getTopOrBottomPosition(s,S,e===o.Direction.DOWN);if(R==null){const T=e===o.Direction.UP?0:f-2;if(T===m)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:h,endOffset:T,collapsed:h===T,style:d}]);return}const b=new I.NodePositionConvertToCursor(M,s).getRangePointData(R,R).cursorList[0];this._textSelectionManagerService.replaceTextRanges([{startOffset:h,endOffset:b.endOffset,collapsed:h===b.endOffset,style:d}])}}_handleMoveCursor(e){var h;const t=this._textSelectionRenderManager.getActiveRange(),n=this._textSelectionRenderManager.getAllTextRanges(),r=this._currentUniverService.getCurrentUniverDocInstance(),s=(h=this._docSkeletonManagerService.getCurrent())==null?void 0:h.skeleton,a=this._getDocObject();if(t==null||s==null||a==null)return;const{startOffset:c,endOffset:l,style:d,collapsed:u}=t,g=r.getBody().dataStream.length??1/0;if(e===o.Direction.LEFT||e===o.Direction.RIGHT){let m;if(!t.collapsed||n.length>1){let f=1/0,_=-1/0;for(const S of n)f=Math.min(f,S.startOffset),_=Math.max(_,S.endOffset);m=e===o.Direction.LEFT?f:_}else{const f=s.findNodeByCharIndex(c-1),_=s.findNodeByCharIndex(c);e===o.Direction.LEFT?m=Math.max(0,c-f.count):m=Math.min(g-2,l+_.count)}this._textSelectionManagerService.replaceTextRanges([{startOffset:m,endOffset:m,collapsed:!0,style:d}])}else{const m=s.findNodeByCharIndex(c),f=s.findNodeByCharIndex(l),_=a.document.getOffsetConfig(),S=this._getTopOrBottomPosition(s,e===o.Direction.UP?m:f,e===o.Direction.DOWN);if(S==null){let R;u?R=e===o.Direction.UP?0:g-2:R=e===o.Direction.UP?c:l,this._textSelectionManagerService.replaceTextRanges([{startOffset:R,endOffset:R,collapsed:!0,style:d}]);return}const M=new I.NodePositionConvertToCursor(_,s).getRangePointData(S,S).cursorList[0];this._textSelectionManagerService.replaceTextRanges([{...M,style:d}])}}_getTopOrBottomPosition(e,t,n){if(t==null)return;const r=this._getSpanLeftOffsetInLine(t),s=this._getNextOrPrevLine(t,n);if(s==null)return;const a=this._matchPositionByLeftOffset(e,s,r);if(a!=null)return{...a,isBack:!0}}_getSpanLeftOffsetInLine(e){const t=e.parent;if(t==null)return-1/0;const n=t.left,{left:r}=e;return n+r}_matchPositionByLeftOffset(e,t,n){const r={distance:1/0};for(const s of t.divides){const a=s.left;for(const c of s.spanGroup){const{left:l}=c,d=a+l,u=Math.abs(n-d);u<r.distance&&(r.span=c,r.distance=u)}}if(r.span!=null)return e.findPositionBySpan(r.span)}_getNextOrPrevLine(e,t){var f,_,S,M,R,b,T,$,N,ie,se,ae;const n=e.parent;if(n==null)return;const r=n.parent;if(r==null)return;const s=r.parent;if(s==null)return;const a=s.lines.indexOf(r);if(a===-1)return;let c;if(t===!0?c=s.lines[a+1]:c=s.lines[a-1],c!=null)return c;const l=s.parent;if(l==null)return;const d=l.columns.indexOf(s);if(d===-1)return;if(t===!0)c=(f=l.columns[d+1])==null?void 0:f.lines[0];else{const D=(S=(_=l.columns)==null?void 0:_[d-1])==null?void 0:S.lines;c=D==null?void 0:D[D.length-1]}if(c!=null)return c;const u=l.parent;if(u==null)return;const g=u.sections.indexOf(l);if(g===-1)return;if(t===!0)c=(R=(M=u.sections[g-1])==null?void 0:M.columns[0])==null?void 0:R.lines[0];else{const D=(T=(b=u.sections)==null?void 0:b[g-1])==null?void 0:T.columns,w=D==null?void 0:D[D.length-1],P=w==null?void 0:w.lines;c=P==null?void 0:P[P.length-1]}if(c!=null)return c;const h=u.parent;if(h==null)return;const m=h.pages.indexOf(u);if(m!==-1){if(t===!0)c=(ie=(N=($=h.pages[m+1])==null?void 0:$.sections[0])==null?void 0:N.columns[0])==null?void 0:ie.lines[0];else{const D=(se=h.pages[m-1])==null?void 0:se.sections;if(D==null)return;const w=(ae=D[D.length-1])==null?void 0:ae.columns,P=w[w.length-1],ct=P==null?void 0:P.lines;c=ct[ct.length-1]}if(c!=null)return c}}_getDocObject(){return B(this._currentUniverService,this._renderManagerService)}};De=an([o.OnLifecycle(o.LifecycleStages.Rendered,De),G(0,y.Inject(p.DocSkeletonManagerService)),G(1,o.IUniverInstanceService),G(2,I.IRenderManagerService),G(3,I.ITextSelectionRenderManager),G(4,y.Inject(x)),G(5,o.ICommandService)],De);var on=Object.defineProperty,cn=Object.getOwnPropertyDescriptor,ln=(i,e,t,n)=>{for(var r=n>1?void 0:n?cn(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&on(e,t,r),r},H=(i,e)=>(t,n)=>e(t,n,i);let be=class extends o.Disposable{constructor(e,t,n,r,s,a){super();v(this,"_onInputSubscription");this._docSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._textSelectionRenderManager=r,this._textSelectionManagerService=s,this._commandService=a,this._initialize(),this._commandExecutedListener()}dispose(){var e;(e=this._onInputSubscription)==null||e.unsubscribe()}_initialize(){this._initialNormalInput()}_initialNormalInput(){this._onInputSubscription=this._textSelectionRenderManager.onInput$.subscribe(async e=>{var m;if(e==null)return;const t=this._currentUniverService.getCurrentUniverDocInstance(),{event:n,content:r="",activeRange:s}=e,a=n,c=(m=this._docSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(a.data==null||c==null||!c||!s)return;const{startOffset:l,segmentId:d,style:u}=s,g=r.length,h=[{startOffset:l+g,endOffset:l+g,collapsed:!0,style:u}];await this._commandService.executeCommand(fe.id,{unitId:t.getUnitId(),body:{dataStream:r},range:s,textRanges:h,segmentId:d}),c.calculate()})}_commandExecutedListener(){}_getDocObject(){return B(this._currentUniverService,this._renderManagerService)}};be=ln([o.OnLifecycle(o.LifecycleStages.Rendered,be),H(0,y.Inject(p.DocSkeletonManagerService)),H(1,o.IUniverInstanceService),H(2,I.IRenderManagerService),H(3,I.ITextSelectionRenderManager),H(4,y.Inject(x)),H(5,o.ICommandService)],be);var dn=Object.defineProperty,un=Object.getOwnPropertyDescriptor,mn=(i,e,t,n)=>{for(var r=n>1?void 0:n?un(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&dn(e,t,r),r},hn=(i,e)=>(t,n)=>e(t,n,i);const fn="rgba(198,198,198, 1)",gn="rgba(255,255,255, 1)";let xe=class extends o.Disposable{constructor(i){super(),this._renderManagerService=i,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialRenderRefresh()}_initialRenderRefresh(){this._renderManagerService.currentRender$.subscribe(i=>{var s;if(i==null)return;const e=this._renderManagerService.getRenderById(i);if(e==null)return;const{mainComponent:t}=e,n=t,r=(s=n.getSkeleton())==null?void 0:s.getPageSize();n.onPageRenderObservable.add(a=>{if([o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY].includes(i))return;const{page:c,pageLeft:l,pageTop:d,ctx:u}=a,{width:g,height:h}=c;u.save(),u.translate(l-.5,d-.5),I.Rect.drawWith(u,{width:(r==null?void 0:r.width)||g,height:(r==null?void 0:r.height)||h,strokeWidth:1,stroke:fn,fill:gn,zIndex:3}),u.restore()})})}_commandExecutedListener(){}};xe=mn([o.OnLifecycle(o.LifecycleStages.Rendered,xe),hn(0,I.IRenderManagerService)],xe);var _n=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,Sn=(i,e,t,n)=>{for(var r=n>1?void 0:n?pn(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&_n(e,t,r),r},K=(i,e)=>(t,n)=>e(t,n,i);let Te=class extends o.Disposable{constructor(e,t,n,r,s,a){super();v(this,"_moveInObserver");v(this,"_moveOutObserver");v(this,"_downObserver");v(this,"_dblClickObserver");v(this,"_tripleClickObserver");v(this,"_loadedMap",new Set);this._docSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=r,this._textSelectionRenderManager=s,this._textSelectionManagerService=a,this._renderManagerService.currentRender$.subscribe(c=>{c!=null&&this._currentUniverService.getUniverDocInstance(c)!=null&&(this._loadedMap.has(c)||(this._initialMain(c),this._loadedMap.add(c)))}),this._initialize()}dispose(){this._renderManagerService.getRenderAll().forEach(e=>{const{mainComponent:t}=e;t!=null&&(t.onPointerEnterObserver.remove(this._moveInObserver),t.onPointerLeaveObserver.remove(this._moveOutObserver),t.onPointerDownObserver.remove(this._downObserver),t.onDblclickObserver.remove(this._dblClickObserver),t.onTripleClickObserver.remove(this._tripleClickObserver))})}_initialize(){this._onChangeListener(),this._skeletonListener(),this._userActionSyncListener(),this._commandExecutedListener()}_initialMain(e){const t=this._getDocObjectById(e);if(t==null)return;const{document:n,scene:r}=t,s=r.getViewport(j.VIEW_MAIN);this._moveInObserver=n.onPointerEnterObserver.add(()=>{n.cursor=I.CURSOR_TYPE.TEXT}),this._moveOutObserver=n.onPointerLeaveObserver.add(()=>{n.cursor=I.CURSOR_TYPE.DEFAULT,r.resetCursor()}),this._downObserver=n==null?void 0:n.onPointerDownObserver.add((a,c)=>{this._currentUniverService.getCurrentUniverDocInstance().getUnitId()!==e&&this._currentUniverService.setCurrentUniverDocInstance(e),this._textSelectionRenderManager.eventTrigger(a,n.getOffsetConfig(),s),a.button!==2&&c.stopPropagation()}),this._dblClickObserver=n==null?void 0:n.onDblclickObserver.add(a=>{this._textSelectionRenderManager.handleDblClick(a,n.getOffsetConfig(),s)}),this._tripleClickObserver=n==null?void 0:n.onTripleClickObserver.add(a=>{this._textSelectionRenderManager.handleTripleClick(a,n.getOffsetConfig(),s)})}_onChangeListener(){this._textSelectionManagerService.textSelectionInfo$.subscribe(e=>{var c,l;const t=(c=this._textSelectionManagerService.getCurrentSelection())==null?void 0:c.unitId;if(this._textSelectionRenderManager.removeAllTextRanges(),e==null||t==null)return;const n=(l=this._docSkeletonManagerService.getCurrent())==null?void 0:l.skeleton,r=this._getDocObjectById(t);if(r==null||n==null)return;const{scene:s,document:a}=r;this._textSelectionRenderManager.addTextRanges(e,{scene:s,skeleton:n,documentOffsetConfig:a.getOffsetConfig()})})}_userActionSyncListener(){this._textSelectionRenderManager.textSelection$.subscribe(e=>{const t=this._docSkeletonManagerService.getCurrent();if(t==null)return;const{unitId:n}=t;this._commandService.executeCommand(ke.id,{unitId:n,pluginName:Y,ranges:e})})}_getDocObjectById(e){return lt(e,this._renderManagerService)}_commandExecutedListener(){const e=[L.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const r=t.params,{unitId:s}=r,a=(n=this._textSelectionManagerService.getCurrentSelection())==null?void 0:n.unitId;if(s!==a)return;this._textSelectionManagerService.refreshSelection()}}))}_skeletonListener(){this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;const{unitId:t,skeleton:n}=e,r=this._renderManagerService.getRenderById(t);if(r==null)return;const{scene:s,mainComponent:a}=r,c=s.getViewport(j.VIEW_MAIN);this._textSelectionRenderManager.changeRuntime(n,s,c,a.getOffsetConfig()),this._textSelectionManagerService.setCurrentSelectionNotRefresh({pluginName:Y,unitId:t})})}};Te=Sn([o.OnLifecycle(o.LifecycleStages.Rendered,Te),K(0,y.Inject(p.DocSkeletonManagerService)),K(1,o.IUniverInstanceService),K(2,o.ICommandService),K(3,I.IRenderManagerService),K(4,I.ITextSelectionRenderManager),K(5,y.Inject(x))],Te);var vn=Object.defineProperty,In=Object.getOwnPropertyDescriptor,Cn=(i,e,t,n)=>{for(var r=n>1?void 0:n?In(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&vn(e,t,r),r},re=(i,e)=>(t,n)=>e(t,n,i);let Pe=class extends o.Disposable{constructor(e,t,n,r,s){super();v(this,"_initializedRender",new Set);this._docSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=r,this._textSelectionManagerService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._initialRenderRefresh()}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;const{unitId:t}=e,n=this._renderManagerService.getRenderById(t);if(n==null||this._initializedRender.has(t)||[o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY].includes(t))return;this._initializedRender.add(t);const{scene:r}=n;this.disposeWithMe(o.toDisposable(r.onMouseWheelObserver.add(s=>{if(!s.ctrlKey)return;const a=Math.abs(s.deltaX);let c=a<40?.2:a<80?.4:.2;c*=s.deltaY>0?-1:1,r.scaleX<1&&(c/=2);const l=this._currentUniverService.getCurrentUniverDocInstance(),d=l.zoomRatio;let u=+parseFloat(`${d+c}`).toFixed(1);u=u>=4?4:u<=.1?.1:u,this._commandService.executeCommand(Qe.id,{zoomRatio:u,workbookId:l.getUnitId()}),s.preventDefault()})))})}_skeletonListener(){this.disposeWithMe(o.toDisposable(this._docSkeletonManagerService.currentSkeletonBefore$.subscribe(e=>{if(e==null)return;const n=this._currentUniverService.getCurrentUniverDocInstance().zoomRatio||1;this._updateViewZoom(n,!1)})))}_commandExecutedListener(){const e=[L.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=this._currentUniverService.getCurrentUniverDocInstance(),r=t.params,{unitId:s}=r;if(s!==n.getUnitId())return;const a=n.zoomRatio||1;this._updateViewZoom(a)}}))}_updateViewZoom(e,t=!0){var r;const n=this._getDocObject();n!=null&&(n.scene.scale(e,e),this._calculatePagePosition(n,e),t&&this._textSelectionManagerService.refreshSelection(),(r=n.scene.getTransformer())==null||r.hideControl())}_calculatePagePosition(e,t){const{document:n,scene:r}=e,s=r==null?void 0:r.getParent(),{width:a,height:c,pageMarginLeft:l,pageMarginTop:d}=n;if(s==null||a===1/0||c===1/0)return;const{width:u,height:g}=s;let h=0,m=0,f=0,_=0,S=1/0;u>(a+l*2)*t?(h=u/2-a*t/2,h/=t,f=(u-l*2)/t,S=0):(h=l,f=a+l*2,S=(f-u/t)/2),g>c?(m=g/2-c/2,_=(g-d*2)/t):(m=d,_=c+d*2),r.resize(f,_+200),n.translate(h,m);const M=r.getViewport(j.VIEW_MAIN);if(S!==1/0&&M!=null){const R=M.getBarScroll(S,0).x;M.scrollTo({x:R})}return this}_getDocObject(){return B(this._currentUniverService,this._renderManagerService)}};Pe=Cn([o.OnLifecycle(o.LifecycleStages.Rendered,Pe),re(0,y.Inject(p.DocSkeletonManagerService)),re(1,o.IUniverInstanceService),re(2,o.ICommandService),re(3,I.IRenderManagerService),re(4,y.Inject(x))],Pe);const Mn={id:he.id,preconditions:i=>i.getContextValue(o.FOCUSING_DOC),binding:O.KeyCode.ENTER},On={id:q.id,preconditions:i=>i.getContextValue(o.FOCUSING_DOC),binding:O.KeyCode.BACKSPACE},Rn={id:me.id,preconditions:i=>i.getContextValue(o.FOCUSING_DOC),binding:O.KeyCode.DELETE},yn={id:U.id,binding:O.KeyCode.ARROW_UP,preconditions:i=>i.getContextValue(o.FOCUSING_DOC),staticParameters:{direction:o.Direction.UP}},Dn={id:U.id,binding:O.KeyCode.ARROW_DOWN,preconditions:i=>i.getContextValue(o.FOCUSING_DOC),staticParameters:{direction:o.Direction.DOWN}},bn={id:U.id,binding:O.KeyCode.ARROW_LEFT,preconditions:i=>i.getContextValue(o.FOCUSING_DOC),staticParameters:{direction:o.Direction.LEFT}},xn={id:U.id,binding:O.KeyCode.ARROW_RIGHT,preconditions:i=>i.getContextValue(o.FOCUSING_DOC),staticParameters:{direction:o.Direction.RIGHT}},Tn={id:E.id,binding:O.KeyCode.ARROW_UP|O.MetaKeys.SHIFT,preconditions:i=>i.getContextValue(o.FOCUSING_DOC),staticParameters:{direction:o.Direction.UP}},Pn={id:E.id,binding:O.KeyCode.ARROW_DOWN|O.MetaKeys.SHIFT,preconditions:i=>i.getContextValue(o.FOCUSING_DOC),staticParameters:{direction:o.Direction.DOWN}},Un={id:E.id,binding:O.KeyCode.ARROW_LEFT|O.MetaKeys.SHIFT,preconditions:i=>i.getContextValue(o.FOCUSING_DOC),staticParameters:{direction:o.Direction.LEFT}},En={id:E.id,binding:O.KeyCode.ARROW_RIGHT|O.MetaKeys.SHIFT,preconditions:i=>i.getContextValue(o.FOCUSING_DOC),staticParameters:{direction:o.Direction.RIGHT}},Nn={id:et.id,binding:O.KeyCode.A|O.MetaKeys.CTRL_COMMAND,preconditions:i=>i.getContextValue(o.FOCUSING_DOC)||i.getContextValue(o.FOCUSING_EDITOR)};var wn=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,An=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ln(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&wn(e,t,r),r},Ue=(i,e)=>(t,n)=>e(t,n,i);let Ee=class{constructor(i,e,t,n){v(this,"_scene");v(this,"_currentDocumentModel");v(this,"_loadedMap",new Set);this._renderManagerService=i,this._configService=e,this._currentUniverService=t,this._docViewModelManagerService=n,this._initialize()}_initialize(){this._currentUniverService.currentDoc$.subscribe(i=>{if(i==null)return;this._currentDocumentModel=i;const e=i.getUnitId();this._docViewModelManagerService.setCurrent(e),this._loadedMap.has(e)||(this._addNewRender(),this._loadedMap.add(e))})}_addNewRender(){const i=this._currentDocumentModel,e=i.getUnitId(),t=i.getContainer(),n=i.getParentRenderUnitId();if(t!=null&&n!=null)throw new Error("container or parentRenderUnitId can only exist one");t==null&&n!=null?this._renderManagerService.createRenderWithParent(e,n):this._renderManagerService.createRender(e);const r=this._renderManagerService.getRenderById(e);if(r==null)return;const{scene:s,engine:a}=r;s.openTransformer(),this._scene=s;const c=new I.Viewport(j.VIEW_MAIN,s,{left:0,top:0,bottom:0,right:0,isWheelPreventDefaultX:!0});s.addViewport(c).attachControl(),s.on(I.EVENT_TYPE.wheel,(u,g)=>{const h=u;if(h.ctrlKey){const m=Math.abs(h.deltaX);let f=m<40?.2:m<80?.4:.2;f*=h.deltaY>0?-1:1,s.scaleX<1&&(f/=2),s.scaleX+f>4?s.scale(4,4):s.scaleX+f<.1?s.scale(.1,.1):h.preventDefault()}else c.onMouseWheel(h,g)}),this._configService.getConfig("hasScroll")!==!1&&e!==o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&new I.ScrollBar(c),s.addLayer(I.Layer.create(s,[],Le),I.Layer.create(s,[],Ye)),this._addComponent(r),this._currentDocumentModel.getShouldRenderLoopImmediately()&&a.runRenderLoop(()=>{s.render()}),this._renderManagerService.setCurrent(e)}_addComponent(i){const e=this._scene,t=this._currentDocumentModel,n=new I.Documents(ce.MAIN,void 0,{pageMarginLeft:t.documentStyle.marginLeft||0,pageMarginTop:t.documentStyle.marginTop||0});n.zIndex=Xe,i.mainComponent=n,i.components.set(ce.MAIN,n),e.addObjects([n],Le)}};Ee=An([o.OnLifecycle(o.LifecycleStages.Ready,Ee),Ue(0,I.IRenderManagerService),Ue(1,o.IConfigService),Ue(2,o.IUniverInstanceService),Ue(3,y.Inject(p.DocViewModelManagerService))],Ee);var $n=Object.defineProperty,Bn=Object.getOwnPropertyDescriptor,jn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Bn(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&$n(e,t,r),r},Ne=(i,e)=>(t,n)=>e(t,n,i);const Fn={hasScroll:!0},kn="docs";p.UniverDocsPlugin=(He=class extends o.Plugin{constructor(t={},n,r,s,a){super(kn);v(this,"_config");this._injector=n,this._localeService=r,this._configService=s,this._currentUniverService=a,this._config=Object.assign(Fn,t),this._initializeDependencies(n),this._initializeCommands()}initialize(){}_initializeCommands(){[U,E,q,me,F,Z,J,Q,k,V,ee,Fe,he,fe,ge,$e,je,C,qe,Ze,Qe,L,ke,et].forEach(t=>{this._injector.get(o.ICommandService).registerCommand(t)}),[yn,Dn,xn,bn,Tn,Pn,Un,En,Nn,On,Rn,Mn].forEach(t=>{this._injector.get(O.IShortcutService).registerShortcut(t)})}onReady(){this.initialize()}_initializeDependencies(t){[[Ee],[p.DocSkeletonManagerService],[p.DocViewModelManagerService],[Be],[at,{useClass:We}],[I.ITextSelectionRenderManager,{useClass:I.TextSelectionRenderManager}],[x],[Ie],[xe],[Te],[be],[Me],[ve],[Re],[pe],[ye],[De],[Pe],[Ce]].forEach(n=>t.add(n))}},v(He,"type",o.PluginType.Doc),He),p.UniverDocsPlugin=jn([Ne(1,y.Inject(y.Injector)),Ne(2,y.Inject(o.LocaleService)),Ne(3,o.IConfigService),Ne(4,o.IUniverInstanceService)],p.UniverDocsPlugin),p.BreakLineCommand=he,p.CoverContentCommand=Ze,p.DOCS_COMPONENT_DEFAULT_Z_INDEX=Xe,p.DOCS_COMPONENT_HEADER_LAYER_INDEX=Ye,p.DOCS_COMPONENT_MAIN_LAYER_INDEX=Le,p.DOCS_VIEW_KEY=ce,p.DeleteCommand=ge,p.DeleteLeftCommand=q,p.DocCopyCommand=le,p.DocCutCommand=de,p.DocPasteCommand=ue,p.IMEInputCommand=je,p.InsertCommand=fe,p.MoveCursorOperation=U,p.MoveSelectionOperation=E,p.NORMAL_TEXT_SELECTION_PLUGIN_NAME=Y,p.ReplaceContentCommand=qe,p.RichTextEditingMutation=C,p.SetInlineFormatBoldCommand=F,p.SetInlineFormatCommand=Fe,p.SetInlineFormatFontFamilyCommand=V,p.SetInlineFormatFontSizeCommand=k,p.SetInlineFormatItalicCommand=Z,p.SetInlineFormatStrikethroughCommand=Q,p.SetInlineFormatTextColorCommand=ee,p.SetInlineFormatUnderlineCommand=J,p.SetTextSelectionsOperation=ke,p.TextSelectionManagerService=x,p.UpdateCommand=$e,p.VIEWPORT_KEY=j,p.getDocObject=B,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
4
|
"description": "UniverSheet normal base-docs",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
7
|
-
"license": "
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
8
|
"main": "./lib/cjs/index.js",
|
|
9
|
-
"module": "./lib/
|
|
9
|
+
"module": "./lib/es/index.js",
|
|
10
10
|
"types": "./lib/types/index.d.ts",
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
|
-
"import": "./lib/
|
|
16
|
+
"import": "./lib/es/index.js",
|
|
17
17
|
"require": "./lib/cjs/index.js",
|
|
18
18
|
"types": "./lib/types/index.d.ts"
|
|
19
19
|
},
|
|
20
20
|
"./*": {
|
|
21
|
-
"import": "./lib/
|
|
21
|
+
"import": "./lib/es/*",
|
|
22
22
|
"require": "./lib/cjs/*",
|
|
23
23
|
"types": "./lib/types/index.d.ts"
|
|
24
|
-
},
|
|
25
|
-
"./locale/*": {
|
|
26
|
-
"import": "./lib/esm/locale/*.js",
|
|
27
|
-
"require": "./lib/cjs/locale/*.js",
|
|
28
|
-
"types": "./lib/types/index.d.ts"
|
|
29
24
|
}
|
|
30
25
|
},
|
|
31
26
|
"directories": {
|
|
@@ -35,28 +30,36 @@
|
|
|
35
30
|
"lib"
|
|
36
31
|
],
|
|
37
32
|
"private": false,
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"@ctrl/tinycolor": "^4.0.2",
|
|
40
|
-
"@wendellhu/redi": "^0.12.11",
|
|
41
|
-
"rxjs": "^7.8.1",
|
|
42
|
-
"@univerjs/engine-render": "0.1.0-alpha.1",
|
|
43
|
-
"@univerjs/sheets": "0.1.0-alpha.1",
|
|
44
|
-
"@univerjs/ui": "0.1.0-alpha.1",
|
|
45
|
-
"@univerjs/core": "0.1.0-alpha.1"
|
|
46
|
-
},
|
|
47
33
|
"devDependencies": {
|
|
48
|
-
"@
|
|
49
|
-
"
|
|
34
|
+
"@ctrl/tinycolor": "^4.0.2",
|
|
35
|
+
"@vitest/coverage-istanbul": "^1.0.2",
|
|
36
|
+
"@wendellhu/redi": "^0.12.12",
|
|
50
37
|
"happy-dom": "^12.10.3",
|
|
51
38
|
"less": "^4.2.0",
|
|
52
|
-
"
|
|
53
|
-
"typescript": "^5.3.
|
|
54
|
-
"
|
|
39
|
+
"rxjs": "^7.8.1",
|
|
40
|
+
"typescript": "^5.3.3",
|
|
41
|
+
"vite": "^5.0.7",
|
|
42
|
+
"vite-plugin-dts": "^3.6.4",
|
|
43
|
+
"vite-plugin-externals": "^0.6.2",
|
|
44
|
+
"vitest": "^1.0.2",
|
|
45
|
+
"@univerjs/engine-render": "0.1.0-alpha.2",
|
|
46
|
+
"@univerjs/core": "0.1.0-alpha.2",
|
|
47
|
+
"@univerjs/sheets": "0.1.0-alpha.2",
|
|
48
|
+
"@univerjs/ui": "0.1.0-alpha.2"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@ctrl/tinycolor": ">=4.0.0",
|
|
52
|
+
"@wendellhu/redi": ">=0.12.12",
|
|
53
|
+
"rxjs": ">=7.0.0",
|
|
54
|
+
"@univerjs/core": "0.1.0-alpha.2",
|
|
55
|
+
"@univerjs/engine-render": "0.1.0-alpha.2",
|
|
56
|
+
"@univerjs/sheets": "0.1.0-alpha.2",
|
|
57
|
+
"@univerjs/ui": "0.1.0-alpha.2"
|
|
55
58
|
},
|
|
56
59
|
"scripts": {
|
|
57
60
|
"test": "vitest run",
|
|
58
61
|
"test:watch": "vitest",
|
|
59
62
|
"coverage": "vitest run --coverage",
|
|
60
|
-
"
|
|
63
|
+
"build": "tsc && vite build"
|
|
61
64
|
}
|
|
62
65
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020-present, DreamNum
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
package/lib/cjs/locale/en-US.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/locale/en-US.ts
|
|
21
|
-
var en_US_exports = {};
|
|
22
|
-
__export(en_US_exports, {
|
|
23
|
-
default: () => en_US_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(en_US_exports);
|
|
26
|
-
var en_US_default = {};
|
package/lib/cjs/locale/zh-CN.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/locale/zh-CN.ts
|
|
21
|
-
var zh_CN_exports = {};
|
|
22
|
-
__export(zh_CN_exports, {
|
|
23
|
-
default: () => zh_CN_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(zh_CN_exports);
|
|
26
|
-
var zh_CN_default = {};
|