@univerjs/docs 0.1.0-beta.5 → 0.1.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/README.md +12 -2
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +974 -1440
- package/lib/types/commands/operations/text-selection.operation.d.ts +3 -2
- package/lib/types/index.d.ts +4 -3
- package/lib/types/services/doc-skeleton-manager.service.d.ts +5 -2
- package/lib/types/services/doc-view-model-manager.service.d.ts +3 -2
- package/lib/types/services/text-selection-manager.service.d.ts +2 -2
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
- package/lib/types/controllers/doc-render.controller.d.ts +0 -27
- package/lib/types/controllers/floating-object.controller.d.ts +0 -33
- package/lib/types/controllers/page-render.controller.d.ts +0 -25
- package/lib/types/controllers/text-selection.controller.d.ts +0 -40
- package/lib/types/controllers/zoom.controller.d.ts +0 -36
- package/lib/types/views/doc-canvas-view.d.ts +0 -34
|
@@ -14,12 +14,13 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { IOperation } from '@univerjs/core';
|
|
17
|
-
import type {
|
|
17
|
+
import type { ITextRangeWithStyle, ITextSelectionStyle } from '@univerjs/engine-render';
|
|
18
18
|
export interface ISetTextSelectionsOperationParams {
|
|
19
19
|
unitId: string;
|
|
20
20
|
subUnitId: string;
|
|
21
21
|
segmentId: string;
|
|
22
|
+
isEditing: boolean;
|
|
22
23
|
style: ITextSelectionStyle;
|
|
23
|
-
ranges:
|
|
24
|
+
ranges: ITextRangeWithStyle[];
|
|
24
25
|
}
|
|
25
26
|
export declare const SetTextSelectionsOperation: IOperation<ISetTextSelectionsOperationParams>;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export type { IDocObjectParam } from './basics/component-tools';
|
|
17
|
-
export { getDocObject } from './basics/component-tools';
|
|
17
|
+
export { getDocObject, getDocObjectById } from './basics/component-tools';
|
|
18
18
|
export * from './basics/docs-view-key';
|
|
19
19
|
export { BreakLineCommand } from './commands/commands/break-line.command';
|
|
20
20
|
export { DeleteCommand, type ICoverCommandParams, type IDeleteCommandParams, type IInsertCommandParams, InsertCommand, type IUpdateCommandParams, UpdateCommand, } from './commands/commands/core-editing.command';
|
|
@@ -27,11 +27,12 @@ export { type IRichTextEditingMutationParams, RichTextEditingMutation, } from '.
|
|
|
27
27
|
export { MoveCursorOperation, MoveSelectionOperation } from './commands/operations/cursor.operation';
|
|
28
28
|
export { type ISetTextSelectionsOperationParams, SetTextSelectionsOperation, } from './commands/operations/text-selection.operation';
|
|
29
29
|
export { type IUniverDocsConfig, UniverDocsPlugin } from './doc-plugin';
|
|
30
|
-
export { DocSkeletonManagerService } from './services/doc-skeleton-manager.service';
|
|
30
|
+
export { DocSkeletonManagerService, type IDocSkeletonManagerParam } from './services/doc-skeleton-manager.service';
|
|
31
31
|
export { DocViewModelManagerService } from './services/doc-view-model-manager.service';
|
|
32
32
|
export { TextSelectionManagerService, serializeTextRange } from './services/text-selection-manager.service';
|
|
33
33
|
export { DocStateChangeManagerService, type IDocStateChangeParams } from './services/doc-state-change-manager.service';
|
|
34
34
|
export { IMEInputManagerService } from './services/ime-input-manager.service';
|
|
35
|
-
export { DocCanvasView } from './views/doc-canvas-view';
|
|
36
35
|
export { SelectAllOperation } from './commands/operations/select-all.operation';
|
|
37
36
|
export { CutContentCommand, InnerPasteCommand } from './commands/commands/clipboard.inner.command';
|
|
37
|
+
export { SetDocZoomRatioOperation, type ISetDocZoomRatioOperationParams } from './commands/operations/set-doc-zoom-ratio.operation';
|
|
38
|
+
export { SetDocZoomRatioCommand } from './commands/commands/set-doc-zoom-ratio.command';
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { Nullable } from '@univerjs/core';
|
|
17
|
-
import { LocaleService, RxDisposable } from '@univerjs/core';
|
|
17
|
+
import { IUniverInstanceService, LocaleService, RxDisposable } from '@univerjs/core';
|
|
18
18
|
import { DocumentSkeleton } from '@univerjs/engine-render';
|
|
19
19
|
import { DocViewModelManagerService } from './doc-view-model-manager.service';
|
|
20
20
|
export interface IDocSkeletonManagerParam {
|
|
@@ -28,16 +28,19 @@ export interface IDocSkeletonManagerParam {
|
|
|
28
28
|
export declare class DocSkeletonManagerService extends RxDisposable {
|
|
29
29
|
private readonly _localeService;
|
|
30
30
|
private readonly _docViewModelManagerService;
|
|
31
|
+
private readonly _currentUniverService;
|
|
31
32
|
private _currentSkeletonUnitId;
|
|
32
33
|
private _docSkeletonMap;
|
|
33
34
|
private readonly _currentSkeleton$;
|
|
34
35
|
readonly currentSkeleton$: import("rxjs").Observable<Nullable<IDocSkeletonManagerParam>>;
|
|
35
36
|
private readonly _currentSkeletonBefore$;
|
|
36
37
|
readonly currentSkeletonBefore$: import("rxjs").Observable<Nullable<IDocSkeletonManagerParam>>;
|
|
37
|
-
constructor(_localeService: LocaleService, _docViewModelManagerService: DocViewModelManagerService);
|
|
38
|
+
constructor(_localeService: LocaleService, _docViewModelManagerService: DocViewModelManagerService, _currentUniverService: IUniverInstanceService);
|
|
38
39
|
private _initialize;
|
|
39
40
|
dispose(): void;
|
|
41
|
+
private _init;
|
|
40
42
|
getCurrent(): Nullable<IDocSkeletonManagerParam>;
|
|
43
|
+
getAllSkeleton(): Map<string, IDocSkeletonManagerParam>;
|
|
41
44
|
makeDirtyCurrent(state?: boolean): void;
|
|
42
45
|
makeDirty(unitId: string, state?: boolean): void;
|
|
43
46
|
getSkeletonByUnitId(unitId: string): Nullable<IDocSkeletonManagerParam>;
|
|
@@ -25,14 +25,15 @@ export interface IDocumentViewModelManagerParam {
|
|
|
25
25
|
*/
|
|
26
26
|
export declare class DocViewModelManagerService extends RxDisposable {
|
|
27
27
|
private readonly _currentUniverService;
|
|
28
|
-
private _currentViewModelUnitId;
|
|
29
28
|
private _docViewModelMap;
|
|
30
29
|
private readonly _currentDocViewModel$;
|
|
31
30
|
readonly currentDocViewModel$: import("rxjs").Observable<Nullable<IDocumentViewModelManagerParam>>;
|
|
32
31
|
constructor(_currentUniverService: IUniverInstanceService);
|
|
33
32
|
private _initialize;
|
|
34
33
|
dispose(): void;
|
|
35
|
-
|
|
34
|
+
private _init;
|
|
35
|
+
private _create;
|
|
36
|
+
getAllModel(): Map<string, IDocumentViewModelManagerParam>;
|
|
36
37
|
getViewModel(unitId: string): DocumentViewModel | undefined;
|
|
37
38
|
private _setCurrent;
|
|
38
39
|
private _buildDocViewModel;
|
|
@@ -53,8 +53,8 @@ export declare class TextSelectionManagerService extends RxDisposable {
|
|
|
53
53
|
setCurrentSelectionNotRefresh(param: ITextSelectionManagerSearchParam): void;
|
|
54
54
|
getSelections(): Readonly<Nullable<TextRange[]>>;
|
|
55
55
|
getActiveRange(): Nullable<ITextActiveRange>;
|
|
56
|
-
add(textRanges: ISuccinctTextRangeParam[]): void;
|
|
57
|
-
replaceTextRanges(textRanges: ISuccinctTextRangeParam[]): void;
|
|
56
|
+
add(textRanges: ISuccinctTextRangeParam[], isEditing?: boolean): void;
|
|
57
|
+
replaceTextRanges(textRanges: ISuccinctTextRangeParam[], isEditing?: boolean): void;
|
|
58
58
|
private _syncSelectionFromRenderService;
|
|
59
59
|
private _replaceTextRangesWithNoRefresh;
|
|
60
60
|
private _getTextRanges;
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(m,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("rxjs"),require("@wendellhu/redi")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","rxjs","@wendellhu/redi"],s):(m=typeof globalThis<"u"?globalThis:m||self,s(m.UniverDocs={},m.UniverCore,m.UniverEngineRender,m.rxjs,m["@wendellhu/redi"]))})(this,function(m,s,C,A,E){"use strict";var sn=Object.defineProperty;var an=(m,s,C)=>s in m?sn(m,s,{enumerable:!0,configurable:!0,writable:!0,value:C}):m[s]=C;var M=(m,s,C)=>(an(m,typeof s!="symbol"?s+"":s,C),C);var Ee;function ie(a,i){const t=a.getCurrentUniverDocInstance().getUnitId(),n=i.getRenderById(t);if(n==null)return;const{mainComponent:r,scene:o,engine:c}=n;return{document:r,scene:o,engine:c}}function Ze(a,i){const e=i.getRenderById(a);if(e==null)return;const{mainComponent:t,scene:n,engine:r}=e;return{document:t,scene:n,engine:r}}var re=(a=>(a.MAIN="__Document_Render_Main__",a))(re||{}),se=(a=>(a.VIEW_MAIN="viewMain",a.VIEW_TOP="viewTop",a.VIEW_LEFT="viewLeft",a.VIEW_LEFT_TOP="viewLeftTop",a))(se||{});const pe=0,Ue=2,Pe=10,Je="normalTextSelectionPluginName",Ie={id:"doc.operation.set-selections",type:s.CommandType.OPERATION,handler:(a,i)=>!0};var Qe=Object.defineProperty,et=Object.getOwnPropertyDescriptor,tt=(a,i,e,t)=>{for(var n=t>1?void 0:t?et(i,e):i,r=a.length-1,o;r>=0;r--)(o=a[r])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&Qe(i,e,n),n},Ne=(a,i)=>(e,t)=>i(e,t,a);function j(a){const{startOffset:i,endOffset:e,collapsed:t}=a;return{startOffset:i,endOffset:e,collapsed:t}}m.TextSelectionManagerService=class extends s.RxDisposable{constructor(e,t){super();M(this,"_currentSelection",null);M(this,"_textSelectionInfo",new Map);M(this,"_textSelection$",new A.BehaviorSubject(null));M(this,"textSelection$",this._textSelection$.asObservable());this._textSelectionRenderManager=e,this._commandService=t,this._syncSelectionFromRenderService()}getCurrentSelection(){return this._currentSelection}getCurrentSelectionInfo(){return this._getTextRanges(this._currentSelection)}dispose(){this._textSelection$.complete()}refreshSelection(){this._currentSelection!=null&&this._refresh(this._currentSelection)}setCurrentSelection(e){this._currentSelection=e,this._refresh(e)}setCurrentSelectionNotRefresh(e){this._currentSelection=e}getSelections(){var e;return(e=this._getTextRanges(this._currentSelection))==null?void 0:e.textRanges}getActiveRange(){const e=this._getTextRanges(this._currentSelection);if(e==null)return;const{textRanges:t,segmentId:n,style:r}=e,o=t.find(S=>S.isActive());if(o==null)return null;const{startOffset:c,endOffset:l,collapsed:u,startNodePosition:d,endNodePosition:h,direction:g}=o;return c==null||l==null?null:{startOffset:c,endOffset:l,collapsed:u,startNodePosition:d,endNodePosition:h,direction:g,segmentId:n,style:r}}add(e){this._currentSelection!=null&&this._addByParam({...this._currentSelection,textRanges:e,segmentId:"",style:C.NORMAL_TEXT_SELECTION_PLUGIN_STYLE})}replaceTextRanges(e){this._currentSelection!=null&&(this._textSelectionRenderManager.removeAllTextRanges(),this._textSelectionRenderManager.addTextRanges(e))}_syncSelectionFromRenderService(){this._textSelectionRenderManager.textSelectionInner$.pipe(A.takeUntil(this.dispose$)).subscribe(e=>{e!=null&&this._replaceTextRangesWithNoRefresh(e)})}_replaceTextRangesWithNoRefresh(e){if(this._currentSelection==null)return;const t={...this._currentSelection,...e};this._replaceByParam(t),this._textSelection$.next(t);const{unitId:n,subUnitId:r,segmentId:o,style:c,textRanges:l}=t;this._commandService.executeCommand(Ie.id,{unitId:n,subUnitId:r,segmentId:o,style:c,ranges:l.map(j)})}_getTextRanges(e){var r;if(e==null)return;const{unitId:t,subUnitId:n=""}=e;return(r=this._textSelectionInfo.get(t))==null?void 0:r.get(n)}_refresh(e){const t=this._getTextRanges(e);this._textSelectionRenderManager.removeAllTextRanges(),t&&Array.isArray(t.textRanges)&&t.textRanges.length&&this._textSelectionRenderManager.addTextRanges(t.textRanges.map(j))}_replaceByParam(e){const{unitId:t,subUnitId:n,style:r,segmentId:o,textRanges:c}=e;this._textSelectionInfo.has(t)||this._textSelectionInfo.set(t,new Map),this._textSelectionInfo.get(t).set(n,{textRanges:c,style:r,segmentId:o})}_addByParam(e){const{unitId:t,subUnitId:n,textRanges:r,style:o,segmentId:c}=e;this._textSelectionInfo.has(t)||this._textSelectionInfo.set(t,new Map);const l=this._textSelectionInfo.get(t);l.has(n)?l.get(n).textRanges.push(...r):l.set(n,{textRanges:r,style:o,segmentId:c})}},m.TextSelectionManagerService=tt([Ne(0,C.ITextSelectionRenderManager),Ne(1,s.ICommandService)],m.TextSelectionManagerService);function Me(a,i="",e=0){const{startOffset:t,endOffset:n}=a,r=[],o=t-e,c=n-e;return o>0&&r.push({t:s.TextXActionType.RETAIN,len:o,segmentId:i}),r.push({t:s.TextXActionType.DELETE,len:c-o,line:0,segmentId:i}),r}var nt=Object.defineProperty,it=Object.getOwnPropertyDescriptor,rt=(a,i,e,t)=>{for(var n=t>1?void 0:t?it(i,e):i,r=a.length-1,o;r>=0;r--)(o=a[r])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&nt(i,e,n),n},st=(a,i)=>(e,t)=>i(e,t,a);m.DocViewModelManagerService=class extends s.RxDisposable{constructor(e){super();M(this,"_currentViewModelUnitId","");M(this,"_docViewModelMap",new Map);M(this,"_currentDocViewModel$",new A.BehaviorSubject(null));M(this,"currentDocViewModel$",this._currentDocViewModel$.asObservable());this._currentUniverService=e,this._initialize()}_initialize(){this._currentUniverService.currentDoc$.pipe(A.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const t=e.getUnitId();this._setCurrent(t)})}dispose(){this._currentDocViewModel$.complete(),this._docViewModelMap.clear()}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===s.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 C.DocumentViewModel(e)}},m.DocViewModelManagerService=rt([st(0,s.IUniverInstanceService)],m.DocViewModelManagerService);var at=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,ct=(a,i,e,t)=>{for(var n=t>1?void 0:t?ot(i,e):i,r=a.length-1,o;r>=0;r--)(o=a[r])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&at(i,e,n),n},Ce=(a,i)=>(e,t)=>i(e,t,a);const lt=300;m.DocStateChangeManagerService=class extends s.RxDisposable{constructor(e,t,n){super();M(this,"_docStateChange$",new A.BehaviorSubject(null));M(this,"docStateChange$",this._docStateChange$.asObservable());M(this,"_stateCache",new Map);M(this,"_timer",null);this._undoRedoService=e,this._commandService=t,this._univerInstanceService=n,this._initialize()}setChangeState(e){const{trigger:t,noHistory:n}=e;t!=null&&(this._cacheChangeState(e),n||this._docStateChange$.next(e))}_initialize(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===s.UndoCommandId||e.id===s.RedoCommandId){const t=this._univerInstanceService.getCurrentUniverDocInstance();if(t==null)return;const n=t.getUnitId();this._pushHistory(n)}}))}_cacheChangeState(e){const{trigger:t,unitId:n,noHistory:r}=e;if(!(t===s.RedoCommandId||t===s.UndoCommandId||r)){if(this._stateCache.has(n)){const o=this._stateCache.get(n);o==null||o.push(e)}else this._stateCache.set(n,[e]);t===k.id||t===X.id?(this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{this._pushHistory(n)},lt)):this._pushHistory(n)}}_pushHistory(e){const t=this._undoRedoService,n=this._stateCache.get(e);if(!Array.isArray(n)||n.length===0)return;const r=n.length,o=n[0].commandId,c=n[0],l=n[r-1],u={unitId:e,actions:n.reduce((h,g)=>s.TextX.compose(h,g.redoState.actions),[]),textRanges:l.redoState.textRanges},d={unitId:e,actions:n.reverse().reduce((h,g)=>s.TextX.compose(h,g.undoState.actions),[]),textRanges:c.undoState.textRanges};t.pushUndoRedo({unitID:e,undoMutations:[{id:o,params:d}],redoMutations:[{id:o,params:u}]}),n.length=0}},m.DocStateChangeManagerService=ct([Ce(0,E.Inject(s.IUndoRedoService)),Ce(1,s.ICommandService),Ce(2,s.IUniverInstanceService)],m.DocStateChangeManagerService);class V{constructor(){M(this,"_previousActiveRange",null);M(this,"_undoMutationParamsCache",[]);M(this,"_redoMutationParamsCache",[])}clearUndoRedoMutationParamsCache(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[]}getUndoRedoMutationParamsCache(){return{undoCache:this._undoMutationParamsCache,redoCache:this._redoMutationParamsCache}}setUndoRedoMutationParamsCache({undoCache:i=[],redoCache:e=[]}){this._undoMutationParamsCache=i,this._redoMutationParamsCache=e}getActiveRange(){return this._previousActiveRange}setActiveRange(i){this._previousActiveRange=i}pushUndoRedoMutationParams(i,e){this._undoMutationParamsCache.push(i),this._redoMutationParamsCache.push(e)}fetchComposedUndoRedoMutationParams(){if(this._undoMutationParamsCache.length===0||this._previousActiveRange==null||this._redoMutationParamsCache.length===0)return null;const{unitId:i}=this._undoMutationParamsCache[0],e={unitId:i,actions:this._undoMutationParamsCache.reverse().reduce((n,r)=>s.TextX.compose(n,r.actions),[]),textRanges:[]};return{redoMutationParams:{unitId:i,actions:this._redoMutationParamsCache.reduce((n,r)=>s.TextX.compose(n,r.actions),[]),textRanges:[]},undoMutationParams:e,previousActiveRange:this._previousActiveRange}}dispose(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[],this._previousActiveRange=null}}const Ae="doc.mutation.rich-text-editing",P={id:Ae,type:s.CommandType.MUTATION,handler:(a,i)=>{var D;const{unitId:e,actions:t,textRanges:n,prevTextRanges:r,trigger:o,noHistory:c,isCompositionEnd:l,noNeedSetTextRange:u}=i,h=a.get(s.IUniverInstanceService).getUniverDocInstance(e),S=a.get(m.DocViewModelManagerService).getViewModel(e),f=a.get(m.TextSelectionManagerService),_=((D=f.getSelections())!=null?D:[]).map(j),p=a.get(m.DocStateChangeManagerService),I=a.get(V);if(h==null||S==null)throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${e}`);if(t.length===0)throw new Error("Mutation's length should great than 0 when call RichTextEditingMutation");const O=h.apply(t),{segmentId:R}=t[0],y=h.getSelfOrHeaderFooterModel(R);S.getSelfOrHeaderFooterViewModel(R).reset(y),!u&&n&&queueMicrotask(()=>{f.replaceTextRanges(n)});const b={commandId:Ae,unitId:e,trigger:o,noHistory:c,redoState:{actions:t,textRanges:n},undoState:{actions:O,textRanges:r!=null?r:_}};if(l){const x=I.fetchComposedUndoRedoMutationParams();if(x==null)throw new Error("historyParams is null in RichTextEditingMutation");const{undoMutationParams:T,redoMutationParams:w,previousActiveRange:N}=x;b.redoState.actions=w.actions,b.undoState.actions=T.actions,b.undoState.textRanges=[N]}return p.setChangeState(b),{unitId:e,actions:O,textRanges:_}}},k={id:"doc.command.insert-text",type:s.CommandType.COMMAND,handler:async(a,i)=>{const e=a.get(s.ICommandService),{range:t,segmentId:n,body:r,unitId:o,textRanges:c}=i,{startOffset:l,collapsed:u}=t,d={id:P.id,params:{unitId:o,actions:[],textRanges:c}},h=new s.TextX;return u?l>0&&h.push({t:s.TextXActionType.RETAIN,len:l,segmentId:n}):h.push(...Me(t,n)),h.push({t:s.TextXActionType.INSERT,body:r,len:r.dataStream.length,line:0,segmentId:n}),d.params.actions=h.serialize(),!!e.syncExecuteCommand(d.id,d.params)}};var L=(a=>(a[a.LEFT=0]="LEFT",a[a.RIGHT=1]="RIGHT",a))(L||{});const X={id:"doc.command.delete-text",type:s.CommandType.COMMAND,handler:async(a,i)=>{const e=a.get(s.ICommandService),{range:t,segmentId:n,unitId:r,direction:o,textRanges:c,len:l=1}=i,{startOffset:u}=t,d={id:P.id,params:{unitId:r,actions:[],textRanges:c}},h=new s.TextX;return u>0&&h.push({t:s.TextXActionType.RETAIN,len:o===0?u-l:u,segmentId:n}),h.push({t:s.TextXActionType.DELETE,len:l,line:0,segmentId:n}),d.params.actions=h.serialize(),!!e.syncExecuteCommand(d.id,d.params)}},Te={id:"doc.command.update-text",type:s.CommandType.COMMAND,handler:async(a,i)=>{const{range:e,segmentId:t,updateBody:n,coverType:r,unitId:o,textRanges:c}=i,l=a.get(s.ICommandService),u={id:P.id,params:{unitId:o,actions:[],textRanges:c}},d=new s.TextX,{startOffset:h,endOffset:g}=e;return d.push({t:s.TextXActionType.RETAIN,len:h,segmentId:t}),d.push({t:s.TextXActionType.RETAIN,body:n,len:g-h,segmentId:t,coverType:r}),u.params.actions=d.serialize(),!!l.syncExecuteCommand(u.id,u.params)}};function dt(a,i){const e=[];for(let t=0,n=a.length;t<n;t++)a[t]===s.DataStreamTreeTokenType.PARAGRAPH&&e.push({startIndex:t});if(i)for(const t of e)i.bullet&&(t.bullet=s.Tools.deepClone(i.bullet)),i.paragraphStyle&&(t.paragraphStyle=s.Tools.deepClone(i.paragraphStyle));return e}const we={id:"doc.command.break-line",type:s.CommandType.COMMAND,handler:async a=>{var f,v;const i=a.get(m.TextSelectionManagerService),e=a.get(s.IUniverInstanceService),t=a.get(s.ICommandService),n=i.getActiveRange();if(n==null)return!1;const r=e.getCurrentUniverDocInstance(),o=r.getUnitId(),{startOffset:c,segmentId:l,style:u}=n,d=[{startOffset:c+1,endOffset:c+1,style:u}],g=((v=(f=r.getBody())==null?void 0:f.paragraphs)!=null?v:[]).find(_=>_.startIndex>=c);return await t.executeCommand(k.id,{unitId:o,body:{dataStream:s.DataStreamTreeTokenType.PARAGRAPH,paragraphs:dt(s.DataStreamTreeTokenType.PARAGRAPH,g)},range:n,textRanges:d,segmentId:l})}};var ut=Object.defineProperty,mt=Object.getOwnPropertyDescriptor,ht=(a,i,e,t)=>{for(var n=t>1?void 0:t?mt(i,e):i,r=a.length-1,o;r>=0;r--)(o=a[r])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&ut(i,e,n),n},Le=(a,i)=>(e,t)=>i(e,t,a);m.DocSkeletonManagerService=class extends s.RxDisposable{constructor(e,t){super();M(this,"_currentSkeletonUnitId","");M(this,"_docSkeletonMap",new Map);M(this,"_currentSkeleton$",new A.BehaviorSubject(null));M(this,"currentSkeleton$",this._currentSkeleton$.asObservable());M(this,"_currentSkeletonBefore$",new A.BehaviorSubject(null));M(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._localeService=e,this._docViewModelManagerService=t,this._initialize()}_initialize(){this._docViewModelManagerService.currentDocViewModel$.pipe(A.takeUntil(this.dispose$)).subscribe(e=>{e!=null&&this._setCurrent(e)})}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._docSkeletonMap.clear()}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)}getSkeletonByUnitId(e){return this._docSkeletonMap.get(e)}_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()}_buildSkeleton(e){return C.DocumentSkeleton.create(e,this._localeService)}},m.DocSkeletonManagerService=ht([Le(0,E.Inject(s.LocaleService)),Le(1,E.Inject(m.DocViewModelManagerService))],m.DocSkeletonManagerService);const gt={id:"doc.command.inner-paste",type:s.CommandType.COMMAND,handler:async(a,i)=>{const{segmentId:e,body:t,textRanges:n}=i,r=a.get(s.ICommandService),o=a.get(m.TextSelectionManagerService),c=a.get(s.IUniverInstanceService),l=o.getSelections();if(!Array.isArray(l)||l.length===0)return!1;const d=c.getCurrentUniverDocInstance().getUnitId(),h={id:P.id,params:{unitId:d,actions:[],textRanges:n}},g=new s.MemoryCursor;g.reset();const S=new s.TextX;for(const v of l){const{startOffset:_,endOffset:p,collapsed:I}=v,O=_-g.cursor;I?S.push({t:s.TextXActionType.RETAIN,len:O,segmentId:e}):S.push(...Me(v,e,g.cursor)),S.push({t:s.TextXActionType.INSERT,body:t,len:t.dataStream.length,line:0,segmentId:e}),g.reset(),g.moveCursor(p)}return h.params.actions=S.serialize(),!!r.syncExecuteCommand(h.id,h.params)}},Oe={id:"doc.command.inner-cut",type:s.CommandType.COMMAND,handler:async(a,i)=>{const{segmentId:e,textRanges:t}=i,n=a.get(s.ICommandService),r=a.get(m.TextSelectionManagerService),o=a.get(s.IUniverInstanceService),c=r.getSelections();if(!Array.isArray(c)||c.length===0)return!1;const l=o.getCurrentUniverDocInstance().getUnitId(),u=o.getUniverDocInstance(l),d=s.getDocsUpdateBody(u.snapshot,e);if(d==null)return!1;const h={id:P.id,params:{unitId:l,actions:[],textRanges:t}},g=new s.MemoryCursor;g.reset();const S=new s.TextX;for(const v of c){const{startOffset:_,endOffset:p,collapsed:I}=v,O=_-g.cursor;I?S.push({t:s.TextXActionType.RETAIN,len:O,segmentId:e}):S.push(...St(v,d,e,g.cursor)),g.reset(),g.moveCursor(p)}return h.params.actions=S.serialize(),!!n.syncExecuteCommand(h.id,h.params)}};function St(a,i,e="",t=0){const{startOffset:n,endOffset:r}=a,o=[],{paragraphs:c=[]}=i,l=n-t,u=r-t,d=c==null?void 0:c.find(h=>h.startIndex-t>=l&&h.startIndex-t<=u);if(l>0&&o.push({t:s.TextXActionType.RETAIN,len:l,segmentId:e}),d&&d.startIndex-t>l){const h=d.startIndex-t;o.push({t:s.TextXActionType.DELETE,len:h-l,line:0,segmentId:e}),o.push({t:s.TextXActionType.RETAIN,len:1,segmentId:e}),u>h+1&&o.push({t:s.TextXActionType.DELETE,len:u-h-1,line:0,segmentId:e})}else o.push({t:s.TextXActionType.DELETE,len:u-l,line:0,segmentId:e});return o}const Be={id:"doc.command.delete-left",type:s.CommandType.COMMAND,handler:async a=>{var R;const i=a.get(m.TextSelectionManagerService),e=a.get(m.DocSkeletonManagerService),t=a.get(s.IUniverInstanceService),n=a.get(s.ICommandService),r=i.getActiveRange(),o=i.getSelections(),c=(R=e.getCurrent())==null?void 0:R.skeleton;let l=!0;if(r==null||c==null||o==null)return!1;const u=t.getCurrentUniverDocInstance(),{startOffset:d,collapsed:h,segmentId:g,style:S}=r,f=c.findNodeByCharIndex(d),v=C.hasListSpan(f),_=C.isIndentBySpan(f,u.getBody());let p=d;const I=c.findNodeByCharIndex(d-1);if(C.isFirstSpan(f)&&I!==f&&(v===!0||_===!0)){const y=C.getParagraphBySpan(f,u.getBody());if(y==null)return!1;const U=y==null?void 0:y.startIndex,b={startIndex:0},D=y.paragraphStyle;if(v===!0){const T=y.paragraphStyle;T&&(b.paragraphStyle=T)}else if(_===!0){const T=y.bullet;T&&(b.bullet=T),D!=null&&(b.paragraphStyle={...D},delete b.paragraphStyle.hanging,delete b.paragraphStyle.indentStart)}const x=[{startOffset:p,endOffset:p,style:S}];l=await n.executeCommand(Te.id,{unitId:u.getUnitId(),updateBody:{dataStream:"",paragraphs:[{...b}]},range:{startOffset:U,endOffset:U+1},textRanges:x,coverType:s.UpdateDocsAttributeType.REPLACE,segmentId:g})}else if(h===!0){if(I==null)return!0;if(I.content==="\r")l=await n.executeCommand(Re.id,{direction:L.LEFT,range:r});else{p-=I.count;const y=[{startOffset:p,endOffset:p,style:S}];l=await n.executeCommand(X.id,{unitId:u.getUnitId(),range:r,segmentId:g,direction:L.LEFT,len:I.count,textRanges:y})}}else{const y=Fe(r,o);l=await n.executeCommand(Oe.id,{segmentId:g,textRanges:y})}return l}},$e={id:"doc.command.delete-right",type:s.CommandType.COMMAND,handler:async a=>{var f;const i=a.get(m.TextSelectionManagerService),e=a.get(m.DocSkeletonManagerService),t=a.get(s.IUniverInstanceService),n=a.get(s.ICommandService),r=i.getActiveRange(),o=i.getSelections(),c=(f=e.getCurrent())==null?void 0:f.skeleton;let l;if(r==null||c==null||o==null)return!1;const u=t.getCurrentUniverDocInstance(),{startOffset:d,collapsed:h,segmentId:g,style:S}=r;if(d===u.getBody().dataStream.length-2&&h)return!0;if(h===!0){const v=c.findNodeByCharIndex(d);if(v.content==="\r")l=await n.executeCommand(Re.id,{direction:L.RIGHT,range:r});else{const _=[{startOffset:d,endOffset:d,style:S}];l=await n.executeCommand(X.id,{unitId:u.getUnitId(),range:r,segmentId:g,direction:L.RIGHT,textRanges:_,len:v.count})}}else{const v=Fe(r,o);l=await n.executeCommand(Oe.id,{segmentId:g,textRanges:v})}return l}},Re={id:"doc.command.merge-two-paragraph",type:s.CommandType.COMMAND,handler:async(a,i)=>{var b,D,x;const e=a.get(m.TextSelectionManagerService),t=a.get(s.IUniverInstanceService),n=a.get(s.ICommandService);a.get(s.IUndoRedoService);const{direction:r,range:o}=i,c=e.getActiveRange(),l=e.getSelections();if(c==null||l==null)return!1;const u=t.getCurrentUniverDocInstance(),{startOffset:d,collapsed:h,segmentId:g,style:S}=c;if(!h)return!1;const f=r===L.LEFT?d:d+1,v=(x=(D=(b=u.getBody())==null?void 0:b.paragraphs)==null?void 0:D.find(T=>T.startIndex>=f))==null?void 0:x.startIndex,_=_t(u.getBody(),f,v),p=r===L.LEFT?d-1:d,I=u.getUnitId(),O=[{startOffset:p,endOffset:p,style:S}],R={id:P.id,params:{unitId:I,actions:[],textRanges:O,prevTextRanges:[o]}},y=new s.TextX;return y.push({t:s.TextXActionType.RETAIN,len:r===L.LEFT?d-1:d,segmentId:g}),_.dataStream.length&&y.push({t:s.TextXActionType.INSERT,body:_,len:_.dataStream.length,line:0,segmentId:g}),y.push({t:s.TextXActionType.RETAIN,len:1,segmentId:g}),y.push({t:s.TextXActionType.DELETE,len:v+1-f,line:0,segmentId:g}),R.params.actions=y.serialize(),!!n.syncExecuteCommand(R.id,R.params)}};function _t(a,i,e){const{textRuns:t}=a,n=a.dataStream.substring(i,e);if(t==null)return{dataStream:n};const r=[];for(const o of t){const{st:c,ed:l}=o;l<=i||c>=e||(c<i?r.push({...o,st:0,ed:l-i}):l>e?r.push({...o,st:c-i,ed:e-i}):r.push({...o,st:c-i,ed:l-i}))}return{dataStream:n,textRuns:r}}function Fe(a,i){let e=a.endOffset;for(const n of i){const{startOffset:r,endOffset:o}=n;r==null||o==null||o<=a.endOffset&&(e-=o-r)}return[{startOffset:e,endOffset:e,style:a.style}]}const ye={id:"doc.command.ime-input",type:s.CommandType.COMMAND,handler:async(a,i)=>{const{unitId:e,newText:t,oldTextLen:n,isCompositionEnd:r,isCompositionStart:o}=i,c=a.get(s.ICommandService),l=a.get(V),u=l.getActiveRange();if(u==null)return!1;const{startOffset:d,style:h,segmentId:g}=u,S=t.length,f=[{startOffset:d+S,endOffset:d+S,collapsed:!0,style:h}],v={id:P.id,params:{unitId:e,actions:[],textRanges:f}},_=new s.TextX;!u.collapsed&&o?_.push(...Me(u,g)):_.push({t:s.TextXActionType.RETAIN,len:d,segmentId:g}),n>0&&_.push({t:s.TextXActionType.DELETE,len:n,line:0,segmentId:g}),_.push({t:s.TextXActionType.INSERT,body:{dataStream:t},len:t.length,line:0,segmentId:g}),v.params.actions=_.serialize(),v.params.noHistory=!r,v.params.isCompositionEnd=r;const p=c.syncExecuteCommand(v.id,v.params);return l.pushUndoRedoMutationParams(p,v.params),!!p}},z={id:"doc.command.set-inline-format-bold",type:s.CommandType.COMMAND,handler:async()=>!0},Y={id:"doc.command.set-inline-format-italic",type:s.CommandType.COMMAND,handler:async()=>!0},H={id:"doc.command.set-inline-format-underline",type:s.CommandType.COMMAND,handler:async()=>!0},W={id:"doc.command.set-inline-format-strikethrough",type:s.CommandType.COMMAND,handler:async()=>!0},B={id:"doc.command.set-inline-format-subscript",type:s.CommandType.COMMAND,handler:async()=>!0},G={id:"doc.command.set-inline-format-superscript",type:s.CommandType.COMMAND,handler:async()=>!0},K={id:"doc.command.set-inline-format-fontsize",type:s.CommandType.COMMAND,handler:async()=>!0},q={id:"doc.command.set-inline-format-font-family",type:s.CommandType.COMMAND,handler:async()=>!0},Z={id:"doc.command.set-inline-format-text-color",type:s.CommandType.COMMAND,handler:async()=>!0},je={[z.id]:"bl",[Y.id]:"it",[H.id]:"ul",[W.id]:"st",[K.id]:"fs",[q.id]:"ff",[Z.id]:"cl",[B.id]:"va",[G.id]:"va"},De={id:"doc.command.set-inline-format",type:s.CommandType.COMMAND,handler:async(a,i)=>{const{segmentId:e,value:t,preCommandId:n}=i,r=a.get(s.ICommandService),o=a.get(m.TextSelectionManagerService),c=a.get(s.IUniverInstanceService),l=o.getSelections();if(!Array.isArray(l)||l.length===0)return!1;let u=c.getCurrentUniverDocInstance(),d=u.getUnitId();d===s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(u=c.getUniverDocInstance(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),d=u.getUnitId());let h;switch(n){case z.id:case Y.id:case H.id:case W.id:case B.id:case G.id:{h=vt(u.getBody().textRuns,n,l);break}case K.id:case q.id:{h=t;break}case Z.id:{h={rgb:t};break}default:throw new Error(`Unknown command: ${n} in handleInlineFormat`)}const g={id:P.id,params:{unitId:d,actions:[],textRanges:l}},S=new s.TextX,f=new s.MemoryCursor;f.reset();for(const _ of l){const{startOffset:p,endOffset:I}=_,O={dataStream:"",textRuns:[{st:0,ed:I-p,ts:{[je[n]]:h}}]},R=p-f.cursor;R!==0&&S.push({t:s.TextXActionType.RETAIN,len:R,segmentId:e}),S.push({t:s.TextXActionType.RETAIN,body:O,len:I-p,segmentId:e}),f.reset(),f.moveCursor(I)}return g.params.actions=S.serialize(),!!r.syncExecuteCommand(g.id,g.params)}};function ft(a){return a!==null&&typeof a=="object"}function vt(a,i,e){let t=0,n=0;const r=je[i];for(;t!==a.length&&n!==e.length;){const{startOffset:o,endOffset:c}=e[n],{st:l,ed:u,ts:d}=a[t];if(c<=l)n++;else if(u<=o)t++;else{if(/bl|it/.test(r))return(d==null?void 0:d[r])===s.BooleanNumber.TRUE?s.BooleanNumber.FALSE:s.BooleanNumber.TRUE;if(/ul|st/.test(r))return ft(d==null?void 0:d[r])&&(d==null?void 0:d[r]).s===s.BooleanNumber.TRUE?{s:s.BooleanNumber.FALSE}:{s:s.BooleanNumber.TRUE};if(/va/.test(r))return i===B.id?(d==null?void 0:d[r])===s.BaselineOffset.SUBSCRIPT?s.BaselineOffset.NORMAL:s.BaselineOffset.SUBSCRIPT:(d==null?void 0:d[r])===s.BaselineOffset.SUPERSCRIPT?s.BaselineOffset.NORMAL:s.BaselineOffset.SUPERSCRIPT;t++}}return/bl|it/.test(r)?s.BooleanNumber.TRUE:/ul|st/.test(r)?{s:s.BooleanNumber.TRUE}:i===B.id?s.BaselineOffset.SUBSCRIPT:s.BaselineOffset.SUPERSCRIPT}const xe={id:"doc.command.list-operation",type:s.CommandType.COMMAND,handler:(a,i)=>{var y,U,b;const e=a.get(m.TextSelectionManagerService),t=a.get(s.IUniverInstanceService),n=a.get(s.ICommandService),{listType:r}=i,o=t.getCurrentUniverDocInstance(),c=e.getActiveRange(),l=(y=e.getSelections())!=null?y:[],u=(U=o.getBody())==null?void 0:U.paragraphs,d=l.map(j);if(c==null||u==null)return!1;const h=pt(c,u),{segmentId:g}=c,S=o.getUnitId(),f=h.every(D=>{var x;return((x=D.bullet)==null?void 0:x.listType)===r});let _=s.Tools.generateRandomId(6);if(h.length===1){const D=u.indexOf(h[0]),x=u[D-1],T=u[D+1];x&&x.bullet&&x.bullet.listType===r?_=x.bullet.listId:T&&T.bullet&&T.bullet.listType===r&&(_=T.bullet.listId)}const p={id:P.id,params:{unitId:S,actions:[],textRanges:d}},I=new s.MemoryCursor;I.reset();const O=new s.TextX;for(const D of h){const{startIndex:x}=D;O.push({t:s.TextXActionType.RETAIN,len:x-I.cursor,segmentId:g});const T={...D.paragraphStyle,hanging:void 0,indentStart:void 0};O.push({t:s.TextXActionType.RETAIN,len:1,body:{dataStream:"",paragraphs:[f?{paragraphStyle:T,startIndex:0}:{...D,startIndex:0,bullet:{...(b=D.bullet)!=null?b:{nestingLevel:0,textStyle:{fs:20}},listType:r,listId:_}}]},segmentId:g,coverType:s.UpdateDocsAttributeType.REPLACE}),I.moveCursorTo(x+1)}return p.params.actions=O.serialize(),!!n.syncExecuteCommand(p.id,p.params)}},Ve={id:"doc.command.bullet-list",type:s.CommandType.COMMAND,handler:a=>a.get(s.ICommandService).syncExecuteCommand(xe.id,{listType:s.PresetListType.BULLET_LIST})},ke={id:"doc.command.order-list",type:s.CommandType.COMMAND,handler:a=>a.get(s.ICommandService).syncExecuteCommand(xe.id,{listType:s.PresetListType.ORDER_LIST})};function pt(a,i){const{startOffset:e,endOffset:t}=a,n=[];let r=-1;for(const o of i){const{startIndex:c}=o;(e>r&&e<=c||t>r&&t<=c||c>=e&&c<=t)&&n.push(o),r=c}return n}const Xe={id:"doc.command-replace-content",type:s.CommandType.COMMAND,handler:async(a,i)=>{var S;const{unitId:e,body:t,textRanges:n,segmentId:r=""}=i,o=a.get(s.IUniverInstanceService),c=a.get(s.ICommandService),l=a.get(m.TextSelectionManagerService),u=(S=o.getUniverDocInstance(e))==null?void 0:S.getSnapshot().body,d=l.getSelections();if(u==null||!Array.isArray(d)||d.length===0)return!1;const h=Ye(e,r,u,t);return h.params.textRanges=n,!!c.syncExecuteCommand(h.id,h.params)}},ze={id:"doc.command-cover-content",type:s.CommandType.COMMAND,handler:async(a,i)=>{var d;const{unitId:e,body:t,segmentId:n=""}=i,r=a.get(s.IUniverInstanceService),o=a.get(s.ICommandService),c=a.get(s.IUndoRedoService),l=(d=r.getUniverDocInstance(e))==null?void 0:d.getSnapshot().body;if(l==null)return!1;const u=Ye(e,n,l,t);return u.params.noNeedSetTextRange=!0,u.params.noHistory=!0,o.syncExecuteCommand(u.id,u.params),c.clearUndoRedo(e),!0}};function Ye(a,i,e,t){const n={id:P.id,params:{unitId:a,actions:[],textRanges:[]}},r=new s.TextX,o=(e==null?void 0:e.dataStream.length)-2;return o>0&&r.push({t:s.TextXActionType.DELETE,len:o,line:0,segmentId:i}),t.dataStream.length>0&&r.push({t:s.TextXActionType.INSERT,body:t,len:t.dataStream.length,line:0,segmentId:i}),n.params.actions=r.serialize(),n}const ae={id:"doc.operation.move-cursor",type:s.CommandType.OPERATION,handler:(a,i)=>!!i},oe={id:"doc.operation.move-selection",type:s.CommandType.OPERATION,handler:(a,i)=>!!i},It=(a,i)=>{const e=a.get(s.IUniverInstanceService).getUniverDocInstance(i.unitId),t=(e==null?void 0:e.zoomRatio)||1;return{...s.Tools.deepClone(i),zoomRatio:t}},$={id:"doc.operation.set-zoom-ratio",type:s.CommandType.OPERATION,handler:(a,i)=>{const e=a.get(s.IUniverInstanceService).getUniverDocInstance(i.unitId);if(!e)return!1;const t=e.getSnapshot();return t.settings==null?t.settings={zoomRatio:i.zoomRatio}:t.settings.zoomRatio=i.zoomRatio,!0}},He={type:s.CommandType.COMMAND,id:"doc.command.set-zoom-ratio",handler:async(a,i)=>{var h,g;const e=a.get(s.ICommandService),t=a.get(s.IUndoRedoService),n=a.get(s.IUniverInstanceService);let r=n.getCurrentUniverDocInstance().getUnitId(),o=1;if(i&&(r=(h=i.documentId)!=null?h:r,o=(g=i.zoomRatio)!=null?g:o),!n.getUniverDocInstance(r))return!1;const l={zoomRatio:o,unitId:r},u=It(a,l);return e.syncExecuteCommand($.id,l)?(t.pushUndoRedo({unitID:r,undoMutations:[{id:$.id,params:u}],redoMutations:[{id:$.id,params:l}]}),!0):!1}},We={id:"doc.operation.select-all",type:s.CommandType.COMMAND,handler:async a=>{const i=a.get(s.IUniverInstanceService),e=a.get(m.TextSelectionManagerService),t=i.getCurrentUniverDocInstance().getSnapshot().body;if(t==null)return!1;const n=[{startOffset:0,endOffset:t.dataStream.length-2}];return e.replaceTextRanges(n),!0}};var Mt=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,Tt=(a,i,e,t)=>{for(var n=t>1?void 0:t?Ct(i,e):i,r=a.length-1,o;r>=0;r--)(o=a[r])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&Mt(i,e,n),n},be=(a,i)=>(e,t)=>i(e,t,a);let ce=class extends s.RxDisposable{constructor(a,i,e){super(),this._docSkeletonManagerService=a,this._renderManagerService=i,this._commandService=e,this._initialRenderRefresh(),this._commandExecutedListener()}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeletonBefore$.pipe(A.takeUntil(this.dispose$)).subscribe(a=>{if(a==null)return;const{skeleton:i,unitId:e}=a,t=this._renderManagerService.getRenderById(e);if(t==null)return;const{mainComponent:n}=t;n.changeSkeleton(i),this._recalculateSizeBySkeleton(t,i)})}_recalculateSizeBySkeleton(a,i){var u;const{mainComponent:e,scene:t}=a,n=e,r=(u=i.getSkeletonData())==null?void 0:u.pages;if(r==null)return;let o=0,c=0;for(let d=0,h=r.length;d<h;d++){const g=r[d],{pageWidth:S,pageHeight:f}=g;n.pageLayoutType===C.PageLayoutType.VERTICAL?(c+=f,c+=n.pageMarginTop,d===h-1&&(c+=n.pageMarginTop),o=Math.max(o,S)):n.pageLayoutType===C.PageLayoutType.HORIZONTAL&&(o+=S,d!==h-1&&(o+=n.pageMarginLeft),c=Math.max(c,f))}n.resize(o,c),[s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY].includes(a.unitId)||t.resize(o,c)}_commandExecutedListener(){const a=[P.id],i=[s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t;if(a.includes(e.id)){const n=e.params,{unitId:r}=n,o=this._docSkeletonManagerService.getSkeletonByUnitId(r);if(o==null)return;const{skeleton:c}=o,l=this._renderManagerService.getRenderById(r);if(l==null)return;if(c.calculate(),i.includes(r)){(t=l.mainComponent)==null||t.makeDirty();return}this._recalculateSizeBySkeleton(l,c)}}))}};ce=Tt([s.OnLifecycle(s.LifecycleStages.Rendered,ce),be(0,E.Inject(m.DocSkeletonManagerService)),be(1,C.IRenderManagerService),be(2,s.ICommandService)],ce);var Ot=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,yt=(a,i,e,t)=>{for(var n=t>1?void 0:t?Rt(i,e):i,r=a.length-1,o;r>=0;r--)(o=a[r])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&Ot(i,e,n),n},J=(a,i)=>(e,t)=>i(e,t,a);let le=class extends s.Disposable{constructor(i,e,t,n,r){super();M(this,"_liquid",new C.Liquid);M(this,"_pageMarginCache",new Map);this._docSkeletonManagerService=i,this._currentUniverService=e,this._renderManagerService=t,this._commandService=n,this._floatingObjectManagerService=r,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialRenderRefresh(),this._updateOnPluginChange()}_updateOnPluginChange(){this._floatingObjectManagerService.pluginUpdate$.subscribe(i=>{const e=this._docSkeletonManagerService.getCurrent();if(e==null)return;const{unitId:t,skeleton:n}=e,r=this._renderManagerService.getRenderById(t);if(r==null)return;const{mainComponent:o,components:c,scene:l}=r,u=o,{left:d,top:h}=u;i.forEach(g=>{const{unitId:S,subUnitId:f,floatingObjectId:v,floatingObject:_}=g,{left:p=0,top:I=0,width:O=0,height:R=0,angle:y,flipX:U,flipY:b,skewX:D,skewY:x}=_,T=this._pageMarginCache.get(v),w=(T==null?void 0:T.marginLeft)||0,N=(T==null?void 0:T.marginTop)||0;n==null||n.getViewModel().getDataModel().updateDrawing(v,{left:p-d-w,top:I-h-N,height:R,width:O})}),n==null||n.calculate(),o==null||o.makeDirty()})}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeleton$.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._refreshFloatingObject(t,e,n)})}_commandExecutedListener(){const i=[P.id,$.id],e=[s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,s.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:o}=r,c=this._docSkeletonManagerService.getCurrent();if(c==null)return;const{unitId:l,skeleton:u}=c;if(o!==l)return;const d=this._renderManagerService.getRenderById(l);if(d==null)return;if(e.includes(l)){(n=d.mainComponent)==null||n.makeDirty();return}this._refreshFloatingObject(l,u,d)}}))}_refreshFloatingObject(i,e,t){const n=e==null?void 0:e.getSkeletonData(),{mainComponent:r,scene:o}=t,c=r;if(!n)return;const{left:l,top:u,pageLayoutType:d,pageMarginLeft:h,pageMarginTop:g}=c,{pages:S}=n,f=[];o.getAncestorScale(),this._liquid.reset(),this._pageMarginCache.clear();for(let v=0,_=S.length;v<_;v++){const p=S[v],{skeDrawings:I,marginLeft:O,marginTop:R}=p;this._liquid.translatePagePadding(p),I.forEach(y=>{const{aLeft:U,aTop:b,height:D,width:x,objectId:T}=y;f.push({unitId:i,subUnitId:s.DEFAULT_DOCUMENT_SUB_COMPONENT_ID,floatingObjectId:T,floatingObject:{left:U+l+this._liquid.x,top:b+u+this._liquid.y,width:x,height:D}}),this._pageMarginCache.set(T,{marginLeft:this._liquid.x,marginTop:this._liquid.y})}),this._liquid.translatePage(p,d,h,g)}this._floatingObjectManagerService.BatchAddOrUpdate(f)}};le=yt([s.OnLifecycle(s.LifecycleStages.Steady,le),J(0,E.Inject(m.DocSkeletonManagerService)),J(1,s.IUniverInstanceService),J(2,C.IRenderManagerService),J(3,s.ICommandService),J(4,s.IFloatingObjectManagerService)],le);var Dt=Object.defineProperty,xt=Object.getOwnPropertyDescriptor,bt=(a,i,e,t)=>{for(var n=t>1?void 0:t?xt(i,e):i,r=a.length-1,o;r>=0;r--)(o=a[r])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&Dt(i,e,n),n},Q=(a,i)=>(e,t)=>i(e,t,a);let de=class extends s.Disposable{constructor(i,e,t,n,r){super();M(this,"_previousIMEContent","");M(this,"_isCompositionStart",!0);M(this,"_onStartSubscription");M(this,"_onUpdateSubscription");M(this,"_onEndSubscription");this._docSkeletonManagerService=i,this._currentUniverService=e,this._textSelectionRenderManager=t,this._imeInputManagerService=n,this._commandService=r,this._initialize()}dispose(){var i,e,t;(i=this._onStartSubscription)==null||i.unsubscribe(),(e=this._onUpdateSubscription)==null||e.unsubscribe(),(t=this._onEndSubscription)==null||t.unsubscribe()}_initialize(){this._initialOnCompositionstart(),this._initialOnCompositionUpdate(),this._initialOnCompositionend()}_initialOnCompositionstart(){this._onStartSubscription=this._textSelectionRenderManager.onCompositionstart$.subscribe(i=>{if(i==null)return;const{activeRange:e}=i;e!=null&&(this._imeInputManagerService.clearUndoRedoMutationParamsCache(),this._imeInputManagerService.setActiveRange(s.Tools.deepClone(e)),this._isCompositionStart=!0)})}_initialOnCompositionUpdate(){this._onUpdateSubscription=this._textSelectionRenderManager.onCompositionupdate$.subscribe(async i=>{this._updateContent(i,!0)})}_initialOnCompositionend(){this._onEndSubscription=this._textSelectionRenderManager.onCompositionend$.subscribe(i=>{this._updateContent(i,!1)})}async _updateContent(i,e){var u;const t=(u=this._docSkeletonManagerService.getCurrent())==null?void 0:u.skeleton;if(i==null||t==null)return;const n=this._currentUniverService.getCurrentUniverDocInstance(),{event:r,activeRange:o}=i;if(t==null||o==null)return;const l=r.data;l===this._previousIMEContent&&e||(await this._commandService.executeCommand(ye.id,{unitId:n.getUnitId(),newText:l,oldTextLen:this._previousIMEContent.length,isCompositionStart:this._isCompositionStart,isCompositionEnd:!e}),e?(this._isCompositionStart&&(this._isCompositionStart=!1),this._previousIMEContent=l):this._resetIME())}_resetIME(){this._previousIMEContent="",this._isCompositionStart=!0,this._imeInputManagerService.clearUndoRedoMutationParamsCache(),this._imeInputManagerService.setActiveRange(null)}};de=bt([s.OnLifecycle(s.LifecycleStages.Rendered,de),Q(0,E.Inject(m.DocSkeletonManagerService)),Q(1,s.IUniverInstanceService),Q(2,C.ITextSelectionRenderManager),Q(3,E.Inject(V)),Q(4,s.ICommandService)],de);var Et=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,Pt=(a,i,e,t)=>{for(var n=t>1?void 0:t?Ut(i,e):i,r=a.length-1,o;r>=0;r--)(o=a[r])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&Et(i,e,n),n},Ge=(a,i)=>(e,t)=>i(e,t,a);let ue=class extends s.Disposable{constructor(a,i){super(),this._textSelectionManagerService=a,this._commandService=i,this._commandExecutedListener()}_commandExecutedListener(){const a=[z.id,Y.id,H.id,W.id,B.id,G.id,K.id,q.id,Z.id];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{a.includes(i.id)&&this._handleInlineFormat(i)}))}_handleInlineFormat(a){var e,t;const{segmentId:i}=(e=this._textSelectionManagerService.getActiveRange())!=null?e:{};i!=null&&this._commandService.executeCommand(De.id,{segmentId:i,preCommandId:a.id,...(t=a.params)!=null?t:{}})}};ue=Pt([s.OnLifecycle(s.LifecycleStages.Rendered,ue),Ge(0,E.Inject(m.TextSelectionManagerService)),Ge(1,s.ICommandService)],ue);var Nt=Object.defineProperty,At=Object.getOwnPropertyDescriptor,wt=(a,i,e,t)=>{for(var n=t>1?void 0:t?At(i,e):i,r=a.length-1,o;r>=0;r--)(o=a[r])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&Nt(i,e,n),n},ee=(a,i)=>(e,t)=>i(e,t,a);let me=class extends s.Disposable{constructor(i,e,t,n,r){super();M(this,"_onInputSubscription");this._docSkeletonManagerService=i,this._currentUniverService=e,this._renderManagerService=t,this._textSelectionManagerService=n,this._commandService=r,this._initialize(),this._commandExecutedListener()}dispose(){var i;(i=this._onInputSubscription)==null||i.unsubscribe()}_initialize(){}_commandExecutedListener(){const i=[ae.id,oe.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(!i.includes(e.id))return;const t=e.params;switch(e.id){case ae.id:return this._handleMoveCursor(t.direction);case oe.id:return this._handleShiftMoveSelection(t.direction);default:throw new Error("Unknown command")}}))}_handleShiftMoveSelection(i){var v,_,p;const e=this._textSelectionManagerService.getActiveRange(),t=this._textSelectionManagerService.getSelections(),n=this._currentUniverService.getCurrentUniverDocInstance(),r=(v=this._docSkeletonManagerService.getCurrent())==null?void 0:v.skeleton,o=this._getDocObject();if(e==null||r==null||o==null)return;const{startOffset:c,endOffset:l,style:u,collapsed:d,direction:h}=e;if(t.length>1){let I=Number.POSITIVE_INFINITY,O=Number.NEGATIVE_INFINITY;for(const R of t)I=Math.min(I,R.startOffset),O=Math.max(O,R.endOffset);this._textSelectionManagerService.replaceTextRanges([{startOffset:i===s.Direction.LEFT||i===s.Direction.UP?O:I,endOffset:i===s.Direction.LEFT||i===s.Direction.UP?I:O,style:u}]);return}const g=d||h===C.RANGE_DIRECTION.FORWARD?c:l;let S=d||h===C.RANGE_DIRECTION.FORWARD?l:c;const f=(_=n.getBody().dataStream.length)!=null?_:Number.POSITIVE_INFINITY;if(i===s.Direction.LEFT||i===s.Direction.RIGHT){const I=r.findNodeByCharIndex(S-1),O=r.findNodeByCharIndex(S);S=i===s.Direction.RIGHT?S+O.count:S-((p=I==null?void 0:I.count)!=null?p:0),S=Math.min(f-2,Math.max(0,S)),this._textSelectionManagerService.replaceTextRanges([{startOffset:g,endOffset:S,style:u}])}else{const I=r.findNodeByCharIndex(S),O=o.document.getOffsetConfig(),R=this._getTopOrBottomPosition(r,I,i===s.Direction.DOWN);if(R==null){const U=i===s.Direction.UP?0:f-2;if(U===S)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:g,endOffset:U,style:u}]);return}const y=new C.NodePositionConvertToCursor(O,r).getRangePointData(R,R).cursorList[0];this._textSelectionManagerService.replaceTextRanges([{startOffset:g,endOffset:y.endOffset,style:u}])}}_handleMoveCursor(i){var g,S,f;const e=this._textSelectionManagerService.getActiveRange(),t=this._textSelectionManagerService.getSelections(),n=this._currentUniverService.getCurrentUniverDocInstance(),r=(g=this._docSkeletonManagerService.getCurrent())==null?void 0:g.skeleton,o=this._getDocObject();if(e==null||r==null||o==null||t==null)return;const{startOffset:c,endOffset:l,style:u,collapsed:d}=e,h=(S=n.getBody().dataStream.length)!=null?S:Number.POSITIVE_INFINITY;if(i===s.Direction.LEFT||i===s.Direction.RIGHT){let v;if(!e.collapsed||t.length>1){let _=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY;for(const I of t)_=Math.min(_,I.startOffset),p=Math.max(p,I.endOffset);v=i===s.Direction.LEFT?_:p}else{const _=r.findNodeByCharIndex(c-1),p=r.findNodeByCharIndex(c);i===s.Direction.LEFT?v=Math.max(0,c-((f=_==null?void 0:_.count)!=null?f:0)):v=Math.min(h-2,l+p.count)}this._textSelectionManagerService.replaceTextRanges([{startOffset:v,endOffset:v,style:u}])}else{const v=r.findNodeByCharIndex(c),_=r.findNodeByCharIndex(l),p=o.document.getOffsetConfig(),I=this._getTopOrBottomPosition(r,i===s.Direction.UP?v:_,i===s.Direction.DOWN);if(I==null){let R;d?R=i===s.Direction.UP?0:h-2:R=i===s.Direction.UP?c:l,this._textSelectionManagerService.replaceTextRanges([{startOffset:R,endOffset:R,style:u}]);return}const O=new C.NodePositionConvertToCursor(p,r).getRangePointData(I,I).cursorList[0];this._textSelectionManagerService.replaceTextRanges([{...O,style:u}])}}_getTopOrBottomPosition(i,e,t){if(e==null)return;const n=this._getSpanLeftOffsetInLine(e),r=this._getNextOrPrevLine(e,t);if(r==null)return;const o=this._matchPositionByLeftOffset(i,r,n);if(o!=null)return{...o,isBack:!0}}_getSpanLeftOffsetInLine(i){const e=i.parent;if(e==null)return Number.NEGATIVE_INFINITY;const t=e.left,{left:n}=i;return t+n}_matchPositionByLeftOffset(i,e,t){const n={distance:Number.POSITIVE_INFINITY};for(const r of e.divides){const o=r.left;for(const c of r.spanGroup){const{left:l}=c,u=o+l,d=Math.abs(t-u);d<n.distance&&(n.span=c,n.distance=d)}}if(n.span!=null)return i.findPositionBySpan(n.span)}_getNextOrPrevLine(i,e){var f,v,_,p,I,O,R,y,U,b,D,x;const t=i.parent;if(t==null)return;const n=t.parent;if(n==null)return;const r=n.parent;if(r==null)return;const o=r.lines.indexOf(n);if(o===-1)return;let c;if(e===!0?c=r.lines[o+1]:c=r.lines[o-1],c!=null)return c;const l=r.parent;if(l==null)return;const u=l.columns.indexOf(r);if(u===-1)return;if(e===!0)c=(f=l.columns[u+1])==null?void 0:f.lines[0];else{const T=(_=(v=l.columns)==null?void 0:v[u-1])==null?void 0:_.lines;c=T==null?void 0:T[T.length-1]}if(c!=null)return c;const d=l.parent;if(d==null)return;const h=d.sections.indexOf(l);if(h===-1)return;if(e===!0)c=(I=(p=d.sections[h-1])==null?void 0:p.columns[0])==null?void 0:I.lines[0];else{const T=(R=(O=d.sections)==null?void 0:O[h-1])==null?void 0:R.columns,w=T==null?void 0:T[T.length-1],N=w==null?void 0:w.lines;c=N==null?void 0:N[N.length-1]}if(c!=null)return c;const g=d.parent;if(g==null)return;const S=g.pages.indexOf(d);if(S!==-1){if(e===!0)c=(b=(U=(y=g.pages[S+1])==null?void 0:y.sections[0])==null?void 0:U.columns[0])==null?void 0:b.lines[0];else{const T=(D=g.pages[S-1])==null?void 0:D.sections;if(T==null)return;const w=(x=T[T.length-1])==null?void 0:x.columns,N=w[w.length-1],qe=N==null?void 0:N.lines;c=qe[qe.length-1]}if(c!=null)return c}}_getDocObject(){return ie(this._currentUniverService,this._renderManagerService)}};me=wt([s.OnLifecycle(s.LifecycleStages.Rendered,me),ee(0,E.Inject(m.DocSkeletonManagerService)),ee(1,s.IUniverInstanceService),ee(2,C.IRenderManagerService),ee(3,E.Inject(m.TextSelectionManagerService)),ee(4,s.ICommandService)],me);var Lt=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,$t=(a,i,e,t)=>{for(var n=t>1?void 0:t?Bt(i,e):i,r=a.length-1,o;r>=0;r--)(o=a[r])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&Lt(i,e,n),n},te=(a,i)=>(e,t)=>i(e,t,a);let he=class extends s.Disposable{constructor(i,e,t,n,r){super();M(this,"_onInputSubscription");this._docSkeletonManagerService=i,this._currentUniverService=e,this._renderManagerService=t,this._textSelectionRenderManager=n,this._commandService=r,this._initialize(),this._commandExecutedListener()}dispose(){var i;(i=this._onInputSubscription)==null||i.unsubscribe()}_initialize(){this._initialNormalInput()}_initialNormalInput(){this._onInputSubscription=this._textSelectionRenderManager.onInput$.subscribe(async i=>{var f;if(i==null)return;const t=this._currentUniverService.getCurrentUniverDocInstance().getUnitId(),{event:n,content:r="",activeRange:o}=i,c=n,l=(f=this._docSkeletonManagerService.getCurrent())==null?void 0:f.skeleton;if(c.data==null||l==null||!l||!o)return;const{startOffset:u,segmentId:d,style:h}=o,g=r.length,S=[{startOffset:u+g,endOffset:u+g,style:h}];await this._commandService.executeCommand(k.id,{unitId:t,body:{dataStream:r},range:o,textRanges:S,segmentId:d})})}_commandExecutedListener(){}_getDocObject(){return ie(this._currentUniverService,this._renderManagerService)}};he=$t([s.OnLifecycle(s.LifecycleStages.Rendered,he),te(0,E.Inject(m.DocSkeletonManagerService)),te(1,s.IUniverInstanceService),te(2,C.IRenderManagerService),te(3,C.ITextSelectionRenderManager),te(4,s.ICommandService)],he);var Ft=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Vt=(a,i,e,t)=>{for(var n=t>1?void 0:t?jt(i,e):i,r=a.length-1,o;r>=0;r--)(o=a[r])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&Ft(i,e,n),n},Ke=(a,i)=>(e,t)=>i(e,t,a);const kt="rgba(198, 198, 198, 1)",Xt="rgba(255, 255, 255, 1)";let ge=class extends s.Disposable{constructor(a,i){super(),this._renderManagerService=a,this._currentUniverService=i,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialRenderRefresh()}_initialRenderRefresh(){this._renderManagerService.currentRender$.subscribe(a=>{var r;if(a==null||this._currentUniverService.getUniverDocInstance(a)==null)return;const i=this._renderManagerService.getRenderById(a);if(i==null)return;const{mainComponent:e}=i,t=e,n=(r=t.getSkeleton())==null?void 0:r.getPageSize();t.onPageRenderObservable.add(o=>{var v,_,p,I;if([s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY].includes(a))return;const{page:c,pageLeft:l,pageTop:u,ctx:d}=o,{width:h,pageWidth:g,height:S,pageHeight:f}=c;d.save(),d.translate(l-.5,u-.5),C.Rect.drawWith(d,{width:(_=(v=n==null?void 0:n.width)!=null?v:g)!=null?_:h,height:(I=(p=n==null?void 0:n.height)!=null?p:f)!=null?I:S,strokeWidth:1,stroke:kt,fill:Xt,zIndex:3}),d.restore()})})}_commandExecutedListener(){}};ge=Vt([s.OnLifecycle(s.LifecycleStages.Rendered,ge),Ke(0,C.IRenderManagerService),Ke(1,E.Inject(s.IUniverInstanceService))],ge);var zt=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,Ht=(a,i,e,t)=>{for(var n=t>1?void 0:t?Yt(i,e):i,r=a.length-1,o;r>=0;r--)(o=a[r])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&zt(i,e,n),n},F=(a,i)=>(e,t)=>i(e,t,a);let Se=class extends s.Disposable{constructor(i,e,t,n,r,o){super();M(this,"_moveInObserver");M(this,"_moveOutObserver");M(this,"_downObserver");M(this,"_dblClickObserver");M(this,"_tripleClickObserver");M(this,"_loadedMap",new Set);this._docSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._textSelectionRenderManager=r,this._textSelectionManagerService=o,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()}_initialize(){this._skeletonListener(),this._commandExecutedListener()}dispose(){this._renderManagerService.getRenderAll().forEach(i=>{const{mainComponent:e}=i;e!=null&&(e.onPointerEnterObserver.remove(this._moveInObserver),e.onPointerLeaveObserver.remove(this._moveOutObserver),e.onPointerDownObserver.remove(this._downObserver),e.onDblclickObserver.remove(this._dblClickObserver),e.onTripleClickObserver.remove(this._tripleClickObserver))})}_initialMain(i){const e=this._getDocObjectById(i);if(e==null)return;const{document:t,scene:n}=e;this._moveInObserver=t.onPointerEnterObserver.add(()=>{t.cursor=C.CURSOR_TYPE.TEXT}),this._moveOutObserver=t.onPointerLeaveObserver.add(()=>{t.cursor=C.CURSOR_TYPE.DEFAULT,n.resetCursor()}),this._downObserver=t==null?void 0:t.onPointerDownObserver.add((r,o)=>{this._currentUniverService.getCurrentUniverDocInstance().getUnitId()!==i&&this._currentUniverService.setCurrentUniverDocInstance(i),this._textSelectionRenderManager.eventTrigger(r),r.button!==2&&o.stopPropagation()}),this._dblClickObserver=t==null?void 0:t.onDblclickObserver.add(r=>{this._textSelectionRenderManager.handleDblClick(r)}),this._tripleClickObserver=t==null?void 0:t.onTripleClickObserver.add(r=>{this._textSelectionRenderManager.handleTripleClick(r)})}_commandExecutedListener(){const i=[$.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t;if(i.includes(e.id)){const n=e.params,{unitId:r}=n,o=(t=this._textSelectionManagerService.getCurrentSelection())==null?void 0:t.unitId;if(r!==o)return;this._textSelectionManagerService.refreshSelection()}}))}_skeletonListener(){this._docSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:e,skeleton:t}=i,n=this._renderManagerService.getRenderById(e);if(n==null)return;const{scene:r,mainComponent:o}=n;this._textSelectionRenderManager.changeRuntime(t,r,o),this._textSelectionManagerService.setCurrentSelectionNotRefresh({unitId:e,subUnitId:""})})}_getDocObjectById(i){return Ze(i,this._renderManagerService)}};Se=Ht([s.OnLifecycle(s.LifecycleStages.Rendered,Se),F(0,E.Inject(m.DocSkeletonManagerService)),F(1,s.IUniverInstanceService),F(2,s.ICommandService),F(3,C.IRenderManagerService),F(4,C.ITextSelectionRenderManager),F(5,E.Inject(m.TextSelectionManagerService))],Se);var Wt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,Kt=(a,i,e,t)=>{for(var n=t>1?void 0:t?Gt(i,e):i,r=a.length-1,o;r>=0;r--)(o=a[r])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&Wt(i,e,n),n},ne=(a,i)=>(e,t)=>i(e,t,a);let _e=class extends s.Disposable{constructor(i,e,t,n,r){super();M(this,"_initializedRender",new Set);this._docSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._textSelectionManagerService=r,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._initialRenderRefresh()}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:e}=i,t=this._renderManagerService.getRenderById(e);if(t==null||this._initializedRender.has(e)||[s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY].includes(e))return;this._initializedRender.add(e);const{scene:n}=t;this.disposeWithMe(s.toDisposable(n.onMouseWheelObserver.add(r=>{if(!r.ctrlKey)return;const o=Math.abs(r.deltaX);let c=o<40?.2:o<80?.4:.2;c*=r.deltaY>0?-1:1,n.scaleX<1&&(c/=2);const l=this._currentUniverService.getCurrentUniverDocInstance(),u=l.zoomRatio;let d=+Number.parseFloat(`${u+c}`).toFixed(1);d=d>=4?4:d<=.1?.1:d,this._commandService.executeCommand(He.id,{zoomRatio:d,unitId:l.getUnitId()}),r.preventDefault()})))})}_skeletonListener(){this.disposeWithMe(s.toDisposable(this._docSkeletonManagerService.currentSkeletonBefore$.subscribe(i=>{if(i==null)return;const t=this._currentUniverService.getCurrentUniverDocInstance().zoomRatio||1;this._updateViewZoom(t,!1)})))}_commandExecutedListener(){const i=[$.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const t=this._currentUniverService.getCurrentUniverDocInstance(),n=e.params,{unitId:r}=n;if(r!==t.getUnitId())return;const o=t.zoomRatio||1;this._updateViewZoom(o)}}))}_updateViewZoom(i,e=!0){var n;const t=this._getDocObject();t!=null&&(t.scene.scale(i,i),this._calculatePagePosition(t,i),e&&this._textSelectionManagerService.refreshSelection(),(n=t.scene.getTransformer())==null||n.hideControl())}_calculatePagePosition(i,e){const{document:t,scene:n}=i,r=n==null?void 0:n.getParent(),{width:o,height:c,pageMarginLeft:l,pageMarginTop:u}=t;if(r==null||o===Number.POSITIVE_INFINITY||c===Number.POSITIVE_INFINITY)return;const{width:d,height:h}=r;let g=0,S=0,f=0,v=0,_=Number.POSITIVE_INFINITY;d>(o+l*2)*e?(g=d/2-o*e/2,g/=e,f=(d-l*2)/e,_=0):(g=l,f=o+l*2,_=(f-d/e)/2),h>c?(S=h/2-c/2,v=(h-u*2)/e):(S=u,v=c+u*2),n.resize(f,v+200),t.translate(g,S);const p=n.getViewport(se.VIEW_MAIN);if(_!==Number.POSITIVE_INFINITY&&p!=null){const I=p.getBarScroll(_,0).x;p.scrollTo({x:I})}return this}_getDocObject(){return ie(this._currentUniverService,this._renderManagerService)}};_e=Kt([s.OnLifecycle(s.LifecycleStages.Rendered,_e),ne(0,E.Inject(m.DocSkeletonManagerService)),ne(1,s.IUniverInstanceService),ne(2,s.ICommandService),ne(3,C.IRenderManagerService),ne(4,E.Inject(m.TextSelectionManagerService))],_e);var qt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Jt=(a,i,e,t)=>{for(var n=t>1?void 0:t?Zt(i,e):i,r=a.length-1,o;r>=0;r--)(o=a[r])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&qt(i,e,n),n},fe=(a,i)=>(e,t)=>i(e,t,a);m.DocCanvasView=class extends s.RxDisposable{constructor(e,t,n,r){super();M(this,"_scene");M(this,"_currentDocumentModel");M(this,"_loadedMap",new Set);M(this,"_fps$",new A.BehaviorSubject(""));M(this,"fps$",this._fps$.asObservable());this._renderManagerService=e,this._configService=t,this._currentUniverService=n,this._docViewModelManagerService=r,this._initialize()}_initialize(){this._currentUniverService.currentDoc$.pipe(A.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;this._currentDocumentModel=e;const t=e.getUnitId();this._loadedMap.has(t)||(this._addNewRender(),this._loadedMap.add(t))})}dispose(){this._fps$.complete()}_addNewRender(){const e=this._currentDocumentModel,t=e.getUnitId(),n=e.getContainer(),r=e.getParentRenderUnitId();if(n!=null&&r!=null)throw new Error("container or parentRenderUnitId can only exist one");n==null&&r!=null?this._renderManagerService.createRenderWithParent(t,r):this._renderManagerService.createRender(t);const o=this._renderManagerService.getRenderById(t);if(o==null)return;const{scene:c,engine:l}=o;c.openTransformer(),this._scene=c;const u=new C.Viewport(se.VIEW_MAIN,c,{left:0,top:0,bottom:0,right:0,isWheelPreventDefaultX:!0});c.attachControl(),c.on(C.EVENT_TYPE.wheel,(g,S)=>{const f=g;if(f.ctrlKey){const v=Math.abs(f.deltaX);let _=v<40?.2:v<80?.4:.2;_*=f.deltaY>0?-1:1,c.scaleX<1&&(_/=2),c.scaleX+_>4?c.scale(4,4):c.scaleX+_<.1?c.scale(.1,.1):f.preventDefault()}else u.onMouseWheel(f,S)}),this._configService.getConfig("hasScroll")!==!1&&t!==s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&new C.ScrollBar(u),c.addLayer(new C.Layer(c,[],pe),new C.Layer(c,[],Ue)),this._addComponent(o),this._currentDocumentModel.getShouldRenderLoopImmediately()&&l.runRenderLoop(()=>{c.render(),this._fps$.next(Math.round(l.getFps()).toString())}),this._renderManagerService.setCurrent(t)}_addComponent(e){const t=this._scene,n=this._currentDocumentModel,r=new C.Documents(re.MAIN,void 0,{pageMarginLeft:n.documentStyle.marginLeft||0,pageMarginTop:n.documentStyle.marginTop||0});r.zIndex=Pe,e.mainComponent=r,e.components.set(re.MAIN,r),t.addObjects([r],pe)}},m.DocCanvasView=Jt([s.OnLifecycle(s.LifecycleStages.Ready,m.DocCanvasView),fe(0,C.IRenderManagerService),fe(1,s.IConfigService),fe(2,s.IUniverInstanceService),fe(3,E.Inject(m.DocViewModelManagerService))],m.DocCanvasView);var Qt=Object.defineProperty,en=Object.getOwnPropertyDescriptor,tn=(a,i,e,t)=>{for(var n=t>1?void 0:t?en(i,e):i,r=a.length-1,o;r>=0;r--)(o=a[r])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&Qt(i,e,n),n},ve=(a,i)=>(e,t)=>i(e,t,a);const nn={hasScroll:!0},rn="docs";m.UniverDocsPlugin=(Ee=class extends s.Plugin{constructor(e={},t,n,r,o){super(rn);M(this,"_config");this._injector=t,this._localeService=n,this._configService=r,this._currentUniverService=o,this._config=Object.assign(nn,e),this._initializeDependencies(t),this._initializeCommands()}initialize(){}_initializeCommands(){[ae,oe,Be,$e,z,Y,H,W,B,G,K,q,Z,De,we,k,X,Te,ye,Re,P,Xe,ze,He,$,Ie,We,ke,Ve,xe].forEach(e=>{this._injector.get(s.ICommandService).registerCommand(e)})}onReady(){this.initialize()}_initializeDependencies(e){[[m.DocCanvasView],[m.DocSkeletonManagerService],[m.DocViewModelManagerService],[m.DocStateChangeManagerService],[V],[C.ITextSelectionRenderManager,{useClass:C.TextSelectionRenderManager}],[m.TextSelectionManagerService],[ce],[ge],[Se],[he],[de],[ue],[me],[_e],[le]].forEach(t=>e.add(t))}},M(Ee,"type",s.PluginType.Doc),Ee),m.UniverDocsPlugin=tn([ve(1,E.Inject(E.Injector)),ve(2,E.Inject(s.LocaleService)),ve(3,s.IConfigService),ve(4,s.IUniverInstanceService)],m.UniverDocsPlugin),m.BreakLineCommand=we,m.BulletListCommand=Ve,m.CoverContentCommand=ze,m.CutContentCommand=Oe,m.DOCS_COMPONENT_DEFAULT_Z_INDEX=Pe,m.DOCS_COMPONENT_HEADER_LAYER_INDEX=Ue,m.DOCS_COMPONENT_MAIN_LAYER_INDEX=pe,m.DOCS_VIEW_KEY=re,m.DeleteCommand=X,m.DeleteLeftCommand=Be,m.DeleteRightCommand=$e,m.IMEInputCommand=ye,m.IMEInputManagerService=V,m.InnerPasteCommand=gt,m.InsertCommand=k,m.MoveCursorOperation=ae,m.MoveSelectionOperation=oe,m.NORMAL_TEXT_SELECTION_PLUGIN_NAME=Je,m.OrderListCommand=ke,m.ReplaceContentCommand=Xe,m.RichTextEditingMutation=P,m.SelectAllOperation=We,m.SetInlineFormatBoldCommand=z,m.SetInlineFormatCommand=De,m.SetInlineFormatFontFamilyCommand=q,m.SetInlineFormatFontSizeCommand=K,m.SetInlineFormatItalicCommand=Y,m.SetInlineFormatStrikethroughCommand=W,m.SetInlineFormatSubscriptCommand=B,m.SetInlineFormatSuperscriptCommand=G,m.SetInlineFormatTextColorCommand=Z,m.SetInlineFormatUnderlineCommand=H,m.SetTextSelectionsOperation=Ie,m.UpdateCommand=Te,m.VIEWPORT_KEY=se,m.getDocObject=ie,m.serializeTextRange=j,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(d,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("rxjs"),require("@wendellhu/redi")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","rxjs","@wendellhu/redi"],a):(d=typeof globalThis<"u"?globalThis:d||self,a(d.UniverDocs={},d.UniverCore,d.UniverEngineRender,d.rxjs,d["@wendellhu/redi"]))})(this,function(d,a,O,P,A){"use strict";var xt=Object.defineProperty;var Dt=(d,a,O)=>a in d?xt(d,a,{enumerable:!0,configurable:!0,writable:!0,value:O}):d[a]=O;var M=(d,a,O)=>(Dt(d,typeof a!="symbol"?a+"":a,O),O);var ve;function re(o,i){const t=o.getCurrentUniverDocInstance().getUnitId(),n=i.getRenderById(t);if(n==null)return;const{mainComponent:s,scene:r,engine:c}=n;return{document:s,scene:r,engine:c}}function Be(o,i){const e=i.getRenderById(o);if(e==null)return;const{mainComponent:t,scene:n,engine:s}=e;return{document:t,scene:n,engine:s}}var _e=(o=>(o.MAIN="__Document_Render_Main__",o))(_e||{}),Ie=(o=>(o.VIEW_MAIN="viewMain",o.VIEW_TOP="viewTop",o.VIEW_LEFT="viewLeft",o.VIEW_LEFT_TOP="viewLeftTop",o))(Ie||{});const $e=0,Fe=2,Xe=10,Ve="normalTextSelectionPluginName",ce={id:"doc.operation.set-selections",type:a.CommandType.OPERATION,handler:(o,i)=>!0};var ke=Object.defineProperty,je=Object.getOwnPropertyDescriptor,ze=(o,i,e,t)=>{for(var n=t>1?void 0:t?je(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&ke(i,e,n),n},Ce=(o,i)=>(e,t)=>i(e,t,o);function $(o){const{startOffset:i,endOffset:e,collapsed:t}=o,n={startOffset:i,endOffset:e,collapsed:t};return typeof o.isActive=="function"&&(n.isActive=o.isActive()),n}d.TextSelectionManagerService=class extends a.RxDisposable{constructor(e,t){super();M(this,"_currentSelection",null);M(this,"_textSelectionInfo",new Map);M(this,"_textSelection$",new P.BehaviorSubject(null));M(this,"textSelection$",this._textSelection$.asObservable());this._textSelectionRenderManager=e,this._commandService=t,this._syncSelectionFromRenderService()}getCurrentSelection(){return this._currentSelection}getCurrentSelectionInfo(){return this._getTextRanges(this._currentSelection)}dispose(){this._textSelection$.complete()}refreshSelection(){this._currentSelection!=null&&this._refresh(this._currentSelection)}setCurrentSelection(e){this._currentSelection=e,this._refresh(e)}setCurrentSelectionNotRefresh(e){this._currentSelection=e}getSelections(){var e;return(e=this._getTextRanges(this._currentSelection))==null?void 0:e.textRanges}getActiveRange(){const e=this._getTextRanges(this._currentSelection);if(e==null)return;const{textRanges:t,segmentId:n,style:s}=e,r=t.find(f=>f.isActive());if(r==null)return null;const{startOffset:c,endOffset:l,collapsed:m,startNodePosition:u,endNodePosition:g,direction:S}=r;return c==null||l==null?null:{startOffset:c,endOffset:l,collapsed:m,startNodePosition:u,endNodePosition:g,direction:S,segmentId:n,style:s}}add(e,t=!0){this._currentSelection!=null&&this._addByParam({...this._currentSelection,textRanges:e,segmentId:"",isEditing:t,style:O.NORMAL_TEXT_SELECTION_PLUGIN_STYLE})}replaceTextRanges(e,t=!0){this._currentSelection!=null&&(this._textSelectionRenderManager.removeAllTextRanges(),this._textSelectionRenderManager.addTextRanges(e,t))}_syncSelectionFromRenderService(){this._textSelectionRenderManager.textSelectionInner$.pipe(P.takeUntil(this.dispose$)).subscribe(e=>{e!=null&&this._replaceTextRangesWithNoRefresh(e)})}_replaceTextRangesWithNoRefresh(e){if(this._currentSelection==null)return;const t={...this._currentSelection,...e};this._replaceByParam(t),this._textSelection$.next(t);const{unitId:n,subUnitId:s,segmentId:r,style:c,textRanges:l,isEditing:m}=t;this._commandService.executeCommand(ce.id,{unitId:n,subUnitId:s,segmentId:r,style:c,isEditing:m,ranges:l.map($)})}_getTextRanges(e){var s;if(e==null)return;const{unitId:t,subUnitId:n=""}=e;return(s=this._textSelectionInfo.get(t))==null?void 0:s.get(n)}_refresh(e){const t=this._getTextRanges(e);this._textSelectionRenderManager.removeAllTextRanges(),t&&Array.isArray(t.textRanges)&&t.textRanges.length&&this._textSelectionRenderManager.addTextRanges(t.textRanges.map($))}_replaceByParam(e){const{unitId:t,subUnitId:n,style:s,segmentId:r,textRanges:c,isEditing:l}=e;this._textSelectionInfo.has(t)||this._textSelectionInfo.set(t,new Map),this._textSelectionInfo.get(t).set(n,{textRanges:c,style:s,segmentId:r,isEditing:l})}_addByParam(e){const{unitId:t,subUnitId:n,textRanges:s,style:r,segmentId:c,isEditing:l}=e;this._textSelectionInfo.has(t)||this._textSelectionInfo.set(t,new Map);const m=this._textSelectionInfo.get(t);m.has(n)?m.get(n).textRanges.push(...s):m.set(n,{textRanges:s,style:r,segmentId:c,isEditing:l})}},d.TextSelectionManagerService=ze([Ce(0,O.ITextSelectionRenderManager),Ce(1,a.ICommandService)],d.TextSelectionManagerService);function le(o,i="",e=0){const{startOffset:t,endOffset:n}=o,s=[],r=t-e,c=n-e;return r>0&&s.push({t:a.TextXActionType.RETAIN,len:r,segmentId:i}),s.push({t:a.TextXActionType.DELETE,len:c-r,line:0,segmentId:i}),s}var He=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,Ye=(o,i,e,t)=>{for(var n=t>1?void 0:t?Ge(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&He(i,e,n),n},We=(o,i)=>(e,t)=>i(e,t,o);d.DocViewModelManagerService=class extends a.RxDisposable{constructor(e){super();M(this,"_docViewModelMap",new Map);M(this,"_currentDocViewModel$",new P.BehaviorSubject(null));M(this,"currentDocViewModel$",this._currentDocViewModel$.asObservable());this._currentUniverService=e,this._initialize()}_initialize(){this._init()}dispose(){this._currentDocViewModel$.complete(),this._docViewModelMap.clear()}_init(){this._currentUniverService.currentDoc$.pipe(P.takeUntil(this.dispose$)).subscribe(e=>{this._create(e)}),this._currentUniverService.getAllUniverDocsInstance().forEach(e=>{this._create(e)}),this._currentUniverService.docDisposed$.pipe(P.takeUntil(this.dispose$)).subscribe(e=>{this._docViewModelMap.delete(e.getUnitId())})}_create(e){if(e==null)return;const t=e.getUnitId();this._setCurrent(t)}getAllModel(){return this._docViewModelMap}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 s=this._buildDocViewModel(t);this._docViewModelMap.set(e,{unitId:e,docViewModel:s})}if(e===a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY){const s=(n=this._docViewModelMap.get(e))==null?void 0:n.docViewModel;if(s==null)return;s.reset(t)}this._currentDocViewModel$.next(this._docViewModelMap.get(e))}}_buildDocViewModel(e){return new O.DocumentViewModel(e)}},d.DocViewModelManagerService=Ye([We(0,a.IUniverInstanceService)],d.DocViewModelManagerService);var Ze=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,Ke=(o,i,e,t)=>{for(var n=t>1?void 0:t?qe(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&Ze(i,e,n),n},de=(o,i)=>(e,t)=>i(e,t,o);const Je=300;d.DocStateChangeManagerService=class extends a.RxDisposable{constructor(e,t,n){super();M(this,"_docStateChange$",new P.BehaviorSubject(null));M(this,"docStateChange$",this._docStateChange$.asObservable());M(this,"_stateCache",new Map);M(this,"_timer",null);this._undoRedoService=e,this._commandService=t,this._univerInstanceService=n,this._initialize()}setChangeState(e){const{trigger:t,noHistory:n}=e;t!=null&&(this._cacheChangeState(e),n||this._docStateChange$.next(e))}_initialize(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===a.UndoCommandId||e.id===a.RedoCommandId){const t=this._univerInstanceService.getCurrentUniverDocInstance();if(t==null)return;const n=t.getUnitId();this._pushHistory(n)}}))}_cacheChangeState(e){const{trigger:t,unitId:n,noHistory:s}=e;if(!(t===a.RedoCommandId||t===a.UndoCommandId||s)){if(this._stateCache.has(n)){const r=this._stateCache.get(n);r==null||r.push(e)}else this._stateCache.set(n,[e]);t===X.id||t===V.id?(this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{this._pushHistory(n)},Je)):this._pushHistory(n)}}_pushHistory(e){const t=this._undoRedoService,n=this._stateCache.get(e);if(!Array.isArray(n)||n.length===0)return;const s=n.length,r=n[0].commandId,c=n[0],l=n[s-1],m={unitId:e,actions:n.reduce((g,S)=>a.TextX.compose(g,S.redoState.actions),[]),textRanges:l.redoState.textRanges},u={unitId:e,actions:n.reverse().reduce((g,S)=>a.TextX.compose(g,S.undoState.actions),[]),textRanges:c.undoState.textRanges};t.pushUndoRedo({unitID:e,undoMutations:[{id:r,params:u}],redoMutations:[{id:r,params:m}]}),n.length=0}},d.DocStateChangeManagerService=Ke([de(0,A.Inject(a.IUndoRedoService)),de(1,a.ICommandService),de(2,a.IUniverInstanceService)],d.DocStateChangeManagerService);class F{constructor(){M(this,"_previousActiveRange",null);M(this,"_undoMutationParamsCache",[]);M(this,"_redoMutationParamsCache",[])}clearUndoRedoMutationParamsCache(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[]}getUndoRedoMutationParamsCache(){return{undoCache:this._undoMutationParamsCache,redoCache:this._redoMutationParamsCache}}setUndoRedoMutationParamsCache({undoCache:i=[],redoCache:e=[]}){this._undoMutationParamsCache=i,this._redoMutationParamsCache=e}getActiveRange(){return this._previousActiveRange}setActiveRange(i){this._previousActiveRange=i}pushUndoRedoMutationParams(i,e){this._undoMutationParamsCache.push(i),this._redoMutationParamsCache.push(e)}fetchComposedUndoRedoMutationParams(){if(this._undoMutationParamsCache.length===0||this._previousActiveRange==null||this._redoMutationParamsCache.length===0)return null;const{unitId:i}=this._undoMutationParamsCache[0],e={unitId:i,actions:this._undoMutationParamsCache.reverse().reduce((n,s)=>a.TextX.compose(n,s.actions),[]),textRanges:[]};return{redoMutationParams:{unitId:i,actions:this._redoMutationParamsCache.reduce((n,s)=>a.TextX.compose(n,s.actions),[]),textRanges:[]},undoMutationParams:e,previousActiveRange:this._previousActiveRange}}dispose(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[],this._previousActiveRange=null}}const Me="doc.mutation.rich-text-editing",N={id:Me,type:a.CommandType.MUTATION,handler:(o,i)=>{var x;const{unitId:e,actions:t,textRanges:n,prevTextRanges:s,trigger:r,noHistory:c,isCompositionEnd:l,noNeedSetTextRange:m}=i,g=o.get(a.IUniverInstanceService).getUniverDocInstance(e),f=o.get(d.DocViewModelManagerService).getViewModel(e),_=o.get(d.TextSelectionManagerService),h=((x=_.getSelections())!=null?x:[]).map($),I=o.get(d.DocStateChangeManagerService),v=o.get(F);if(g==null||f==null)throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${e}`);if(t.length===0)return{unitId:e,actions:[],textRanges:h};const T=g.apply(t),{segmentId:y}=t[0],R=g.getSelfOrHeaderFooterModel(y);f.getSelfOrHeaderFooterViewModel(y).reset(R),!m&&n&&r!=null&&queueMicrotask(()=>{_.replaceTextRanges(n)});const E={commandId:Me,unitId:e,trigger:r,noHistory:c,redoState:{actions:t,textRanges:n},undoState:{actions:T,textRanges:s!=null?s:h}};if(l){const D=v.fetchComposedUndoRedoMutationParams();if(D==null)throw new Error("historyParams is null in RichTextEditingMutation");const{undoMutationParams:C,redoMutationParams:L,previousActiveRange:b}=D;E.redoState.actions=L.actions,E.undoState.actions=C.actions,E.undoState.textRanges=[b]}return I.setChangeState(E),{unitId:e,actions:T,textRanges:h}}},X={id:"doc.command.insert-text",type:a.CommandType.COMMAND,handler:async(o,i)=>{const e=o.get(a.ICommandService),{range:t,segmentId:n,body:s,unitId:r,textRanges:c}=i,{startOffset:l,collapsed:m}=t,u={id:N.id,params:{unitId:r,actions:[],textRanges:c}},g=new a.TextX;return m?l>0&&g.push({t:a.TextXActionType.RETAIN,len:l,segmentId:n}):g.push(...le(t,n)),g.push({t:a.TextXActionType.INSERT,body:s,len:s.dataStream.length,line:0,segmentId:n}),u.params.actions=g.serialize(),!!e.syncExecuteCommand(u.id,u.params)}};var w=(o=>(o[o.LEFT=0]="LEFT",o[o.RIGHT=1]="RIGHT",o))(w||{});const V={id:"doc.command.delete-text",type:a.CommandType.COMMAND,handler:async(o,i)=>{const e=o.get(a.ICommandService),{range:t,segmentId:n,unitId:s,direction:r,textRanges:c,len:l=1}=i,{startOffset:m}=t,u={id:N.id,params:{unitId:s,actions:[],textRanges:c}},g=new a.TextX;return m>0&&g.push({t:a.TextXActionType.RETAIN,len:r===0?m-l:m,segmentId:n}),g.push({t:a.TextXActionType.DELETE,len:l,line:0,segmentId:n}),u.params.actions=g.serialize(),!!e.syncExecuteCommand(u.id,u.params)}},ue={id:"doc.command.update-text",type:a.CommandType.COMMAND,handler:async(o,i)=>{const{range:e,segmentId:t,updateBody:n,coverType:s,unitId:r,textRanges:c}=i,l=o.get(a.ICommandService),m={id:N.id,params:{unitId:r,actions:[],textRanges:c}},u=new a.TextX,{startOffset:g,endOffset:S}=e;return u.push({t:a.TextXActionType.RETAIN,len:g,segmentId:t}),u.push({t:a.TextXActionType.RETAIN,body:n,len:S-g,segmentId:t,coverType:s}),m.params.actions=u.serialize(),!!l.syncExecuteCommand(m.id,m.params)}};function Qe(o,i){const e=[];for(let t=0,n=o.length;t<n;t++)o[t]===a.DataStreamTreeTokenType.PARAGRAPH&&e.push({startIndex:t});if(i)for(const t of e)i.bullet&&(t.bullet=a.Tools.deepClone(i.bullet)),i.paragraphStyle&&(t.paragraphStyle=a.Tools.deepClone(i.paragraphStyle));return e}const Te={id:"doc.command.break-line",type:a.CommandType.COMMAND,handler:async o=>{var _,p;const i=o.get(d.TextSelectionManagerService),e=o.get(a.IUniverInstanceService),t=o.get(a.ICommandService),n=i.getActiveRange();if(n==null)return!1;const s=e.getCurrentUniverDocInstance(),r=s.getUnitId(),{startOffset:c,segmentId:l,style:m}=n,u=[{startOffset:c+1,endOffset:c+1,style:m}],S=((p=(_=s.getBody())==null?void 0:_.paragraphs)!=null?p:[]).find(h=>h.startIndex>=c);return await t.executeCommand(X.id,{unitId:r,body:{dataStream:a.DataStreamTreeTokenType.PARAGRAPH,paragraphs:Qe(a.DataStreamTreeTokenType.PARAGRAPH,S)},range:n,textRanges:u,segmentId:l})}};var et=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,nt=(o,i,e,t)=>{for(var n=t>1?void 0:t?tt(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&et(i,e,n),n},me=(o,i)=>(e,t)=>i(e,t,o);d.DocSkeletonManagerService=class extends a.RxDisposable{constructor(e,t,n){super();M(this,"_currentSkeletonUnitId","");M(this,"_docSkeletonMap",new Map);M(this,"_currentSkeleton$",new P.BehaviorSubject(null));M(this,"currentSkeleton$",this._currentSkeleton$.asObservable());M(this,"_currentSkeletonBefore$",new P.BehaviorSubject(null));M(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._localeService=e,this._docViewModelManagerService=t,this._currentUniverService=n,this._initialize()}_initialize(){this._init()}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._docSkeletonMap.clear()}_init(){this._docViewModelManagerService.currentDocViewModel$.pipe(P.takeUntil(this.dispose$)).subscribe(e=>{e!=null&&this._setCurrent(e)}),this._docViewModelManagerService.getAllModel().forEach(e=>{e!=null&&this._setCurrent(e)}),this._currentUniverService.docDisposed$.pipe(P.takeUntil(this.dispose$)).subscribe(e=>{this._docSkeletonMap.delete(e.getUnitId()),this._currentSkeletonUnitId=this._currentUniverService.getCurrentUniverDocInstance().getUnitId()})}getCurrent(){return this.getSkeletonByUnitId(this._currentSkeletonUnitId)}getAllSkeleton(){return this._docSkeletonMap}makeDirtyCurrent(e=!0){this.makeDirty(this._currentSkeletonUnitId,e)}makeDirty(e,t=!0){const n=this.getSkeletonByUnitId(e);n!=null&&(n.dirty=t)}getSkeletonByUnitId(e){return this._docSkeletonMap.get(e)}_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()}_buildSkeleton(e){return O.DocumentSkeleton.create(e,this._localeService)}},d.DocSkeletonManagerService=nt([me(0,A.Inject(a.LocaleService)),me(1,A.Inject(d.DocViewModelManagerService)),me(2,a.IUniverInstanceService)],d.DocSkeletonManagerService);const it={id:"doc.command.inner-paste",type:a.CommandType.COMMAND,handler:async(o,i)=>{const{segmentId:e,body:t,textRanges:n}=i,s=o.get(a.ICommandService),r=o.get(d.TextSelectionManagerService),c=o.get(a.IUniverInstanceService),l=r.getSelections();if(!Array.isArray(l)||l.length===0)return!1;const u=c.getCurrentUniverDocInstance().getUnitId(),g={id:N.id,params:{unitId:u,actions:[],textRanges:n}},S=new a.MemoryCursor;S.reset();const f=new a.TextX;for(const p of l){const{startOffset:h,endOffset:I,collapsed:v}=p,T=h-S.cursor;v?f.push({t:a.TextXActionType.RETAIN,len:T,segmentId:e}):f.push(...le(p,e,S.cursor)),f.push({t:a.TextXActionType.INSERT,body:t,len:t.dataStream.length,line:0,segmentId:e}),S.reset(),S.moveCursor(I)}return g.params.actions=f.serialize(),!!s.syncExecuteCommand(g.id,g.params)}},ge={id:"doc.command.inner-cut",type:a.CommandType.COMMAND,handler:async(o,i)=>{const{segmentId:e,textRanges:t}=i,n=o.get(a.ICommandService),s=o.get(d.TextSelectionManagerService),r=o.get(a.IUniverInstanceService),c=s.getSelections();if(!Array.isArray(c)||c.length===0)return!1;const l=r.getCurrentUniverDocInstance().getUnitId(),m=r.getUniverDocInstance(l),u=a.getDocsUpdateBody(m.snapshot,e);if(u==null)return!1;const g={id:N.id,params:{unitId:l,actions:[],textRanges:t}},S=new a.MemoryCursor;S.reset();const f=new a.TextX;for(const p of c){const{startOffset:h,endOffset:I,collapsed:v}=p,T=h-S.cursor;v?f.push({t:a.TextXActionType.RETAIN,len:T,segmentId:e}):f.push(...at(p,u,e,S.cursor)),S.reset(),S.moveCursor(I)}return g.params.actions=f.serialize(),!!n.syncExecuteCommand(g.id,g.params)}};function at(o,i,e="",t=0){const{startOffset:n,endOffset:s}=o,r=[],{paragraphs:c=[]}=i,l=n-t,m=s-t,u=c==null?void 0:c.find(g=>g.startIndex-t>=l&&g.startIndex-t<=m);if(l>0&&r.push({t:a.TextXActionType.RETAIN,len:l,segmentId:e}),u&&u.startIndex-t>l){const g=u.startIndex-t;r.push({t:a.TextXActionType.DELETE,len:g-l,line:0,segmentId:e}),r.push({t:a.TextXActionType.RETAIN,len:1,segmentId:e}),m>g+1&&r.push({t:a.TextXActionType.DELETE,len:m-g-1,line:0,segmentId:e})}else r.push({t:a.TextXActionType.DELETE,len:m-l,line:0,segmentId:e});return r}const ye={id:"doc.command.delete-left",type:a.CommandType.COMMAND,handler:async o=>{var y;const i=o.get(d.TextSelectionManagerService),e=o.get(d.DocSkeletonManagerService),t=o.get(a.IUniverInstanceService),n=o.get(a.ICommandService),s=i.getActiveRange(),r=i.getSelections(),c=(y=e.getCurrent())==null?void 0:y.skeleton;let l=!0;if(s==null||c==null||r==null)return!1;const m=t.getCurrentUniverDocInstance(),{startOffset:u,collapsed:g,segmentId:S,style:f}=s,_=c.findNodeByCharIndex(u),p=O.hasListSpan(_),h=O.isIndentBySpan(_,m.getBody());let I=u;const v=c.findNodeByCharIndex(u-1);if(O.isFirstSpan(_)&&v!==_&&(p===!0||h===!0)){const R=O.getParagraphBySpan(_,m.getBody());if(R==null)return!1;const U=R==null?void 0:R.startIndex,E={startIndex:0},x=R.paragraphStyle;if(p===!0){const C=R.paragraphStyle;C&&(E.paragraphStyle=C)}else if(h===!0){const C=R.bullet;C&&(E.bullet=C),x!=null&&(E.paragraphStyle={...x},delete E.paragraphStyle.hanging,delete E.paragraphStyle.indentStart)}const D=[{startOffset:I,endOffset:I,style:f}];l=await n.executeCommand(ue.id,{unitId:m.getUnitId(),updateBody:{dataStream:"",paragraphs:[{...E}]},range:{startOffset:U,endOffset:U+1},textRanges:D,coverType:a.UpdateDocsAttributeType.REPLACE,segmentId:S})}else if(g===!0){if(v==null)return!0;if(v.content==="\r")l=await n.executeCommand(Se.id,{direction:w.LEFT,range:s});else{I-=v.count;const R=[{startOffset:I,endOffset:I,style:f}];l=await n.executeCommand(V.id,{unitId:m.getUnitId(),range:s,segmentId:S,direction:w.LEFT,len:v.count,textRanges:R})}}else{const R=Oe(s,r);l=await n.executeCommand(ge.id,{segmentId:S,textRanges:R})}return l}},Re={id:"doc.command.delete-right",type:a.CommandType.COMMAND,handler:async o=>{var _;const i=o.get(d.TextSelectionManagerService),e=o.get(d.DocSkeletonManagerService),t=o.get(a.IUniverInstanceService),n=o.get(a.ICommandService),s=i.getActiveRange(),r=i.getSelections(),c=(_=e.getCurrent())==null?void 0:_.skeleton;let l;if(s==null||c==null||r==null)return!1;const m=t.getCurrentUniverDocInstance(),{startOffset:u,collapsed:g,segmentId:S,style:f}=s;if(u===m.getBody().dataStream.length-2&&g)return!0;if(g===!0){const p=c.findNodeByCharIndex(u);if(p.content==="\r")l=await n.executeCommand(Se.id,{direction:w.RIGHT,range:s});else{const h=[{startOffset:u,endOffset:u,style:f}];l=await n.executeCommand(V.id,{unitId:m.getUnitId(),range:s,segmentId:S,direction:w.RIGHT,textRanges:h,len:p.count})}}else{const p=Oe(s,r);l=await n.executeCommand(ge.id,{segmentId:S,textRanges:p})}return l}},Se={id:"doc.command.merge-two-paragraph",type:a.CommandType.COMMAND,handler:async(o,i)=>{var E,x,D;const e=o.get(d.TextSelectionManagerService),t=o.get(a.IUniverInstanceService),n=o.get(a.ICommandService);o.get(a.IUndoRedoService);const{direction:s,range:r}=i,c=e.getActiveRange(),l=e.getSelections();if(c==null||l==null)return!1;const m=t.getCurrentUniverDocInstance(),{startOffset:u,collapsed:g,segmentId:S,style:f}=c;if(!g)return!1;const _=s===w.LEFT?u:u+1,p=(D=(x=(E=m.getBody())==null?void 0:E.paragraphs)==null?void 0:x.find(C=>C.startIndex>=_))==null?void 0:D.startIndex,h=st(m.getBody(),_,p),I=s===w.LEFT?u-1:u,v=m.getUnitId(),T=[{startOffset:I,endOffset:I,style:f}],y={id:N.id,params:{unitId:v,actions:[],textRanges:T,prevTextRanges:[r]}},R=new a.TextX;return R.push({t:a.TextXActionType.RETAIN,len:s===w.LEFT?u-1:u,segmentId:S}),h.dataStream.length&&R.push({t:a.TextXActionType.INSERT,body:h,len:h.dataStream.length,line:0,segmentId:S}),R.push({t:a.TextXActionType.RETAIN,len:1,segmentId:S}),R.push({t:a.TextXActionType.DELETE,len:p+1-_,line:0,segmentId:S}),y.params.actions=R.serialize(),!!n.syncExecuteCommand(y.id,y.params)}};function st(o,i,e){const{textRuns:t}=o,n=o.dataStream.substring(i,e);if(t==null)return{dataStream:n};const s=[];for(const r of t){const{st:c,ed:l}=r;l<=i||c>=e||(c<i?s.push({...r,st:0,ed:l-i}):l>e?s.push({...r,st:c-i,ed:e-i}):s.push({...r,st:c-i,ed:l-i}))}return{dataStream:n,textRuns:s}}function Oe(o,i){let e=o.endOffset;for(const n of i){const{startOffset:s,endOffset:r}=n;s==null||r==null||r<=o.endOffset&&(e-=r-s)}return[{startOffset:e,endOffset:e,style:o.style}]}const fe={id:"doc.command.ime-input",type:a.CommandType.COMMAND,handler:async(o,i)=>{const{unitId:e,newText:t,oldTextLen:n,isCompositionEnd:s,isCompositionStart:r}=i,c=o.get(a.ICommandService),l=o.get(F),m=l.getActiveRange();if(m==null)return!1;const{startOffset:u,style:g,segmentId:S}=m,f=t.length,_=[{startOffset:u+f,endOffset:u+f,collapsed:!0,style:g}],p={id:N.id,params:{unitId:e,actions:[],textRanges:_}},h=new a.TextX;!m.collapsed&&r?h.push(...le(m,S)):h.push({t:a.TextXActionType.RETAIN,len:u,segmentId:S}),n>0&&h.push({t:a.TextXActionType.DELETE,len:n,line:0,segmentId:S}),h.push({t:a.TextXActionType.INSERT,body:{dataStream:t},len:t.length,line:0,segmentId:S}),p.params.actions=h.serialize(),p.params.noHistory=!s,p.params.isCompositionEnd=s;const I=c.syncExecuteCommand(p.id,p.params);return l.pushUndoRedoMutationParams(I,p.params),!!I}},k={id:"doc.command.set-inline-format-bold",type:a.CommandType.COMMAND,handler:async()=>!0},j={id:"doc.command.set-inline-format-italic",type:a.CommandType.COMMAND,handler:async()=>!0},z={id:"doc.command.set-inline-format-underline",type:a.CommandType.COMMAND,handler:async()=>!0},H={id:"doc.command.set-inline-format-strikethrough",type:a.CommandType.COMMAND,handler:async()=>!0},B={id:"doc.command.set-inline-format-subscript",type:a.CommandType.COMMAND,handler:async()=>!0},G={id:"doc.command.set-inline-format-superscript",type:a.CommandType.COMMAND,handler:async()=>!0},Y={id:"doc.command.set-inline-format-fontsize",type:a.CommandType.COMMAND,handler:async()=>!0},W={id:"doc.command.set-inline-format-font-family",type:a.CommandType.COMMAND,handler:async()=>!0},Z={id:"doc.command.set-inline-format-text-color",type:a.CommandType.COMMAND,handler:async()=>!0},xe={[k.id]:"bl",[j.id]:"it",[z.id]:"ul",[H.id]:"st",[Y.id]:"fs",[W.id]:"ff",[Z.id]:"cl",[B.id]:"va",[G.id]:"va"},he={id:"doc.command.set-inline-format",type:a.CommandType.COMMAND,handler:async(o,i)=>{const{segmentId:e,value:t,preCommandId:n}=i,s=o.get(a.ICommandService),r=o.get(d.TextSelectionManagerService),c=o.get(a.IUniverInstanceService),l=r.getSelections();if(!Array.isArray(l)||l.length===0)return!1;let m=c.getCurrentUniverDocInstance(),u=m.getUnitId();u===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(m=c.getUniverDocInstance(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),u=m.getUnitId());let g;switch(n){case k.id:case j.id:case z.id:case H.id:case B.id:case G.id:{g=rt(m.getBody().textRuns,n,l);break}case Y.id:case W.id:{g=t;break}case Z.id:{g={rgb:t};break}default:throw new Error(`Unknown command: ${n} in handleInlineFormat`)}const S={id:N.id,params:{unitId:u,actions:[],textRanges:l.map($)}},f=new a.TextX,_=new a.MemoryCursor;_.reset();for(const h of l){const{startOffset:I,endOffset:v}=h,T={dataStream:"",textRuns:[{st:0,ed:v-I,ts:{[xe[n]]:g}}]},y=I-_.cursor;y!==0&&f.push({t:a.TextXActionType.RETAIN,len:y,segmentId:e}),f.push({t:a.TextXActionType.RETAIN,body:T,len:v-I,segmentId:e}),_.reset(),_.moveCursor(v)}return S.params.actions=f.serialize(),!!s.syncExecuteCommand(S.id,S.params)}};function ot(o){return o!==null&&typeof o=="object"}function rt(o,i,e){let t=0,n=0;const s=xe[i];for(;t!==o.length&&n!==e.length;){const{startOffset:r,endOffset:c}=e[n],{st:l,ed:m,ts:u}=o[t];if(c<=l)n++;else if(m<=r)t++;else{if(/bl|it/.test(s))return(u==null?void 0:u[s])===a.BooleanNumber.TRUE?a.BooleanNumber.FALSE:a.BooleanNumber.TRUE;if(/ul|st/.test(s))return ot(u==null?void 0:u[s])&&(u==null?void 0:u[s]).s===a.BooleanNumber.TRUE?{s:a.BooleanNumber.FALSE}:{s:a.BooleanNumber.TRUE};if(/va/.test(s))return i===B.id?(u==null?void 0:u[s])===a.BaselineOffset.SUBSCRIPT?a.BaselineOffset.NORMAL:a.BaselineOffset.SUBSCRIPT:(u==null?void 0:u[s])===a.BaselineOffset.SUPERSCRIPT?a.BaselineOffset.NORMAL:a.BaselineOffset.SUPERSCRIPT;t++}}return/bl|it/.test(s)?a.BooleanNumber.TRUE:/ul|st/.test(s)?{s:a.BooleanNumber.TRUE}:i===B.id?a.BaselineOffset.SUBSCRIPT:a.BaselineOffset.SUPERSCRIPT}const pe={id:"doc.command.list-operation",type:a.CommandType.COMMAND,handler:(o,i)=>{var R,U,E;const e=o.get(d.TextSelectionManagerService),t=o.get(a.IUniverInstanceService),n=o.get(a.ICommandService),{listType:s}=i,r=t.getCurrentUniverDocInstance(),c=e.getActiveRange(),l=(R=e.getSelections())!=null?R:[],m=(U=r.getBody())==null?void 0:U.paragraphs,u=l.map($);if(c==null||m==null)return!1;const g=ct(c,m),{segmentId:S}=c,f=r.getUnitId(),_=g.every(x=>{var D;return((D=x.bullet)==null?void 0:D.listType)===s});let h=a.Tools.generateRandomId(6);if(g.length===1){const x=m.indexOf(g[0]),D=m[x-1],C=m[x+1];D&&D.bullet&&D.bullet.listType===s?h=D.bullet.listId:C&&C.bullet&&C.bullet.listType===s&&(h=C.bullet.listId)}const I={id:N.id,params:{unitId:f,actions:[],textRanges:u}},v=new a.MemoryCursor;v.reset();const T=new a.TextX;for(const x of g){const{startIndex:D}=x;T.push({t:a.TextXActionType.RETAIN,len:D-v.cursor,segmentId:S});const C={...x.paragraphStyle,hanging:void 0,indentStart:void 0};T.push({t:a.TextXActionType.RETAIN,len:1,body:{dataStream:"",paragraphs:[_?{paragraphStyle:C,startIndex:0}:{...x,startIndex:0,bullet:{...(E=x.bullet)!=null?E:{nestingLevel:0,textStyle:{fs:20}},listType:s,listId:h}}]},segmentId:S,coverType:a.UpdateDocsAttributeType.REPLACE}),v.moveCursorTo(D+1)}return I.params.actions=T.serialize(),!!n.syncExecuteCommand(I.id,I.params)}},De={id:"doc.command.bullet-list",type:a.CommandType.COMMAND,handler:o=>o.get(a.ICommandService).syncExecuteCommand(pe.id,{listType:a.PresetListType.BULLET_LIST})},Ee={id:"doc.command.order-list",type:a.CommandType.COMMAND,handler:o=>o.get(a.ICommandService).syncExecuteCommand(pe.id,{listType:a.PresetListType.ORDER_LIST})};function ct(o,i){const{startOffset:e,endOffset:t}=o,n=[];let s=-1;for(const r of i){const{startIndex:c}=r;(e>s&&e<=c||t>s&&t<=c||c>=e&&c<=t)&&n.push(r),s=c}return n}const Ue={id:"doc.command-replace-content",type:a.CommandType.COMMAND,handler:async(o,i)=>{var f;const{unitId:e,body:t,textRanges:n,segmentId:s=""}=i,r=o.get(a.IUniverInstanceService),c=o.get(a.ICommandService),l=o.get(d.TextSelectionManagerService),m=(f=r.getUniverDocInstance(e))==null?void 0:f.getSnapshot().body,u=l.getSelections();if(m==null||!Array.isArray(u)||u.length===0)return!1;const g=Ne(e,s,m,t);return g.params.textRanges=n,!!c.syncExecuteCommand(g.id,g.params)}},Ae={id:"doc.command-cover-content",type:a.CommandType.COMMAND,handler:async(o,i)=>{var u;const{unitId:e,body:t,segmentId:n=""}=i,s=o.get(a.IUniverInstanceService),r=o.get(a.ICommandService),c=o.get(a.IUndoRedoService),l=(u=s.getUniverDocInstance(e))==null?void 0:u.getSnapshot().body;if(l==null)return!1;const m=Ne(e,n,l,t);return m.params.noNeedSetTextRange=!0,m.params.noHistory=!0,r.syncExecuteCommand(m.id,m.params),c.clearUndoRedo(e),!0}};function Ne(o,i,e,t){const n={id:N.id,params:{unitId:o,actions:[],textRanges:[]}},s=new a.TextX,r=(e==null?void 0:e.dataStream.length)-2;return r>0&&s.push({t:a.TextXActionType.DELETE,len:r,line:0,segmentId:i}),t.dataStream.length>0&&s.push({t:a.TextXActionType.INSERT,body:t,len:t.dataStream.length,line:0,segmentId:i}),n.params.actions=s.serialize(),n}const ee={id:"doc.operation.move-cursor",type:a.CommandType.OPERATION,handler:(o,i)=>!!i},te={id:"doc.operation.move-selection",type:a.CommandType.OPERATION,handler:(o,i)=>!!i},lt=(o,i)=>{const e=o.get(a.IUniverInstanceService).getUniverDocInstance(i.unitId),t=(e==null?void 0:e.zoomRatio)||1;return{...a.Tools.deepClone(i),zoomRatio:t}},q={id:"doc.operation.set-zoom-ratio",type:a.CommandType.OPERATION,handler:(o,i)=>{const e=o.get(a.IUniverInstanceService).getUniverDocInstance(i.unitId);if(!e)return!1;const t=e.getSnapshot();return t.settings==null?t.settings={zoomRatio:i.zoomRatio}:t.settings.zoomRatio=i.zoomRatio,!0}},Pe={type:a.CommandType.COMMAND,id:"doc.command.set-zoom-ratio",handler:async(o,i)=>{var g,S;const e=o.get(a.ICommandService),t=o.get(a.IUndoRedoService),n=o.get(a.IUniverInstanceService);let s=n.getCurrentUniverDocInstance().getUnitId(),r=1;if(i&&(s=(g=i.documentId)!=null?g:s,r=(S=i.zoomRatio)!=null?S:r),!n.getUniverDocInstance(s))return!1;const l={zoomRatio:r,unitId:s},m=lt(o,l);return e.syncExecuteCommand(q.id,l)?(t.pushUndoRedo({unitID:s,undoMutations:[{id:q.id,params:m}],redoMutations:[{id:q.id,params:l}]}),!0):!1}},be={id:"doc.operation.select-all",type:a.CommandType.COMMAND,handler:async o=>{const i=o.get(a.IUniverInstanceService),e=o.get(d.TextSelectionManagerService),t=i.getCurrentUniverDocInstance().getSnapshot().body;if(t==null)return!1;const n=[{startOffset:0,endOffset:t.dataStream.length-2}];return e.replaceTextRanges(n,!1),!0}};var dt=Object.defineProperty,ut=Object.getOwnPropertyDescriptor,mt=(o,i,e,t)=>{for(var n=t>1?void 0:t?ut(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&dt(i,e,n),n},K=(o,i)=>(e,t)=>i(e,t,o);let ne=class extends a.Disposable{constructor(i,e,t,n,s){super();M(this,"_previousIMEContent","");M(this,"_isCompositionStart",!0);M(this,"_onStartSubscription");M(this,"_onUpdateSubscription");M(this,"_onEndSubscription");this._docSkeletonManagerService=i,this._currentUniverService=e,this._textSelectionRenderManager=t,this._imeInputManagerService=n,this._commandService=s,this._initialize()}dispose(){var i,e,t;(i=this._onStartSubscription)==null||i.unsubscribe(),(e=this._onUpdateSubscription)==null||e.unsubscribe(),(t=this._onEndSubscription)==null||t.unsubscribe()}_initialize(){this._initialOnCompositionstart(),this._initialOnCompositionUpdate(),this._initialOnCompositionend()}_initialOnCompositionstart(){this._onStartSubscription=this._textSelectionRenderManager.onCompositionstart$.subscribe(i=>{if(i==null)return;const{activeRange:e}=i;e!=null&&(this._imeInputManagerService.clearUndoRedoMutationParamsCache(),this._imeInputManagerService.setActiveRange(a.Tools.deepClone(e)),this._isCompositionStart=!0)})}_initialOnCompositionUpdate(){this._onUpdateSubscription=this._textSelectionRenderManager.onCompositionupdate$.subscribe(async i=>{this._updateContent(i,!0)})}_initialOnCompositionend(){this._onEndSubscription=this._textSelectionRenderManager.onCompositionend$.subscribe(i=>{this._updateContent(i,!1)})}async _updateContent(i,e){var m;const t=(m=this._docSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(i==null||t==null)return;const n=this._currentUniverService.getCurrentUniverDocInstance(),{event:s,activeRange:r}=i;if(t==null||r==null)return;const l=s.data;l===this._previousIMEContent&&e||(await this._commandService.executeCommand(fe.id,{unitId:n.getUnitId(),newText:l,oldTextLen:this._previousIMEContent.length,isCompositionStart:this._isCompositionStart,isCompositionEnd:!e}),e?(this._isCompositionStart&&(this._isCompositionStart=!1),this._previousIMEContent=l):this._resetIME())}_resetIME(){this._previousIMEContent="",this._isCompositionStart=!0,this._imeInputManagerService.clearUndoRedoMutationParamsCache(),this._imeInputManagerService.setActiveRange(null)}};ne=mt([a.OnLifecycle(a.LifecycleStages.Rendered,ne),K(0,A.Inject(d.DocSkeletonManagerService)),K(1,a.IUniverInstanceService),K(2,O.ITextSelectionRenderManager),K(3,A.Inject(F)),K(4,a.ICommandService)],ne);var gt=Object.defineProperty,St=Object.getOwnPropertyDescriptor,ft=(o,i,e,t)=>{for(var n=t>1?void 0:t?St(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&>(i,e,n),n},we=(o,i)=>(e,t)=>i(e,t,o);let ie=class extends a.Disposable{constructor(o,i){super(),this._textSelectionManagerService=o,this._commandService=i,this._commandExecutedListener()}_commandExecutedListener(){const o=[k.id,j.id,z.id,H.id,B.id,G.id,Y.id,W.id,Z.id];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{o.includes(i.id)&&this._handleInlineFormat(i)}))}_handleInlineFormat(o){var e,t;const{segmentId:i}=(e=this._textSelectionManagerService.getActiveRange())!=null?e:{};i!=null&&this._commandService.executeCommand(he.id,{segmentId:i,preCommandId:o.id,...(t=o.params)!=null?t:{}})}};ie=ft([a.OnLifecycle(a.LifecycleStages.Rendered,ie),we(0,A.Inject(d.TextSelectionManagerService)),we(1,a.ICommandService)],ie);var ht=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,vt=(o,i,e,t)=>{for(var n=t>1?void 0:t?pt(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&ht(i,e,n),n},J=(o,i)=>(e,t)=>i(e,t,o);let ae=class extends a.Disposable{constructor(i,e,t,n,s){super();M(this,"_onInputSubscription");this._docSkeletonManagerService=i,this._currentUniverService=e,this._renderManagerService=t,this._textSelectionManagerService=n,this._commandService=s,this._initialize(),this._commandExecutedListener()}dispose(){var i;(i=this._onInputSubscription)==null||i.unsubscribe()}_initialize(){}_commandExecutedListener(){const i=[ee.id,te.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(!i.includes(e.id))return;const t=e.params;switch(e.id){case ee.id:return this._handleMoveCursor(t.direction);case te.id:return this._handleShiftMoveSelection(t.direction);default:throw new Error("Unknown command")}}))}_handleShiftMoveSelection(i){var p,h,I;const e=this._textSelectionManagerService.getActiveRange(),t=this._textSelectionManagerService.getSelections(),n=this._currentUniverService.getCurrentUniverDocInstance(),s=(p=this._docSkeletonManagerService.getCurrent())==null?void 0:p.skeleton,r=this._getDocObject();if(e==null||s==null||r==null)return;const{startOffset:c,endOffset:l,style:m,collapsed:u,direction:g}=e;if(t.length>1){let v=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY;for(const y of t)v=Math.min(v,y.startOffset),T=Math.max(T,y.endOffset);this._textSelectionManagerService.replaceTextRanges([{startOffset:i===a.Direction.LEFT||i===a.Direction.UP?T:v,endOffset:i===a.Direction.LEFT||i===a.Direction.UP?v:T,style:m}],!1);return}const S=u||g===O.RANGE_DIRECTION.FORWARD?c:l;let f=u||g===O.RANGE_DIRECTION.FORWARD?l:c;const _=(h=n.getBody().dataStream.length)!=null?h:Number.POSITIVE_INFINITY;if(i===a.Direction.LEFT||i===a.Direction.RIGHT){const v=s.findNodeByCharIndex(f-1),T=s.findNodeByCharIndex(f);f=i===a.Direction.RIGHT?f+T.count:f-((I=v==null?void 0:v.count)!=null?I:0),f=Math.min(_-2,Math.max(0,f)),this._textSelectionManagerService.replaceTextRanges([{startOffset:S,endOffset:f,style:m}],!1)}else{const v=s.findNodeByCharIndex(f),T=r.document.getOffsetConfig(),y=this._getTopOrBottomPosition(s,v,i===a.Direction.DOWN);if(y==null){const U=i===a.Direction.UP?0:_-2;if(U===f)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:S,endOffset:U,style:m}],!1);return}const R=new O.NodePositionConvertToCursor(T,s).getRangePointData(y,y).cursorList[0];this._textSelectionManagerService.replaceTextRanges([{startOffset:S,endOffset:R.endOffset,style:m}],!1)}}_handleMoveCursor(i){var S,f,_;const e=this._textSelectionManagerService.getActiveRange(),t=this._textSelectionManagerService.getSelections(),n=this._currentUniverService.getCurrentUniverDocInstance(),s=(S=this._docSkeletonManagerService.getCurrent())==null?void 0:S.skeleton,r=this._getDocObject();if(e==null||s==null||r==null||t==null)return;const{startOffset:c,endOffset:l,style:m,collapsed:u}=e,g=(f=n.getBody().dataStream.length)!=null?f:Number.POSITIVE_INFINITY;if(i===a.Direction.LEFT||i===a.Direction.RIGHT){let p;if(!e.collapsed||t.length>1){let h=Number.POSITIVE_INFINITY,I=Number.NEGATIVE_INFINITY;for(const v of t)h=Math.min(h,v.startOffset),I=Math.max(I,v.endOffset);p=i===a.Direction.LEFT?h:I}else{const h=s.findNodeByCharIndex(c-1),I=s.findNodeByCharIndex(c);i===a.Direction.LEFT?p=Math.max(0,c-((_=h==null?void 0:h.count)!=null?_:0)):p=Math.min(g-2,l+I.count)}this._textSelectionManagerService.replaceTextRanges([{startOffset:p,endOffset:p,style:m}],!1)}else{const p=s.findNodeByCharIndex(c),h=s.findNodeByCharIndex(l),I=r.document.getOffsetConfig(),v=this._getTopOrBottomPosition(s,i===a.Direction.UP?p:h,i===a.Direction.DOWN);if(v==null){let y;u?y=i===a.Direction.UP?0:g-2:y=i===a.Direction.UP?c:l,this._textSelectionManagerService.replaceTextRanges([{startOffset:y,endOffset:y,style:m}],!1);return}const T=new O.NodePositionConvertToCursor(I,s).getRangePointData(v,v).cursorList[0];this._textSelectionManagerService.replaceTextRanges([{...T,style:m}],!1)}}_getTopOrBottomPosition(i,e,t){if(e==null)return;const n=this._getSpanLeftOffsetInLine(e),s=this._getNextOrPrevLine(e,t);if(s==null)return;const r=this._matchPositionByLeftOffset(i,s,n);if(r!=null)return{...r,isBack:!0}}_getSpanLeftOffsetInLine(i){const e=i.parent;if(e==null)return Number.NEGATIVE_INFINITY;const t=e.left,{left:n}=i;return t+n}_matchPositionByLeftOffset(i,e,t){const n={distance:Number.POSITIVE_INFINITY};for(const s of e.divides){const r=s.left;for(const c of s.spanGroup){const{left:l}=c,m=r+l,u=Math.abs(t-m);u<n.distance&&(n.span=c,n.distance=u)}}if(n.span!=null)return i.findPositionBySpan(n.span)}_getNextOrPrevLine(i,e){var _,p,h,I,v,T,y,R,U,E,x,D;const t=i.parent;if(t==null)return;const n=t.parent;if(n==null)return;const s=n.parent;if(s==null)return;const r=s.lines.indexOf(n);if(r===-1)return;let c;if(e===!0?c=s.lines[r+1]:c=s.lines[r-1],c!=null)return c;const l=s.parent;if(l==null)return;const m=l.columns.indexOf(s);if(m===-1)return;if(e===!0)c=(_=l.columns[m+1])==null?void 0:_.lines[0];else{const C=(h=(p=l.columns)==null?void 0:p[m-1])==null?void 0:h.lines;c=C==null?void 0:C[C.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(e===!0)c=(v=(I=u.sections[g-1])==null?void 0:I.columns[0])==null?void 0:v.lines[0];else{const C=(y=(T=u.sections)==null?void 0:T[g-1])==null?void 0:y.columns,L=C==null?void 0:C[C.length-1],b=L==null?void 0:L.lines;c=b==null?void 0:b[b.length-1]}if(c!=null)return c;const S=u.parent;if(S==null)return;const f=S.pages.indexOf(u);if(f!==-1){if(e===!0)c=(E=(U=(R=S.pages[f+1])==null?void 0:R.sections[0])==null?void 0:U.columns[0])==null?void 0:E.lines[0];else{const C=(x=S.pages[f-1])==null?void 0:x.sections;if(C==null)return;const L=(D=C[C.length-1])==null?void 0:D.columns,b=L[L.length-1],Le=b==null?void 0:b.lines;c=Le[Le.length-1]}if(c!=null)return c}}_getDocObject(){return re(this._currentUniverService,this._renderManagerService)}};ae=vt([a.OnLifecycle(a.LifecycleStages.Rendered,ae),J(0,A.Inject(d.DocSkeletonManagerService)),J(1,a.IUniverInstanceService),J(2,O.IRenderManagerService),J(3,A.Inject(d.TextSelectionManagerService)),J(4,a.ICommandService)],ae);var _t=Object.defineProperty,It=Object.getOwnPropertyDescriptor,Ct=(o,i,e,t)=>{for(var n=t>1?void 0:t?It(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&_t(i,e,n),n},Q=(o,i)=>(e,t)=>i(e,t,o);let se=class extends a.Disposable{constructor(i,e,t,n,s){super();M(this,"_onInputSubscription");this._docSkeletonManagerService=i,this._currentUniverService=e,this._renderManagerService=t,this._textSelectionRenderManager=n,this._commandService=s,this._initialize(),this._commandExecutedListener()}dispose(){var i;(i=this._onInputSubscription)==null||i.unsubscribe()}_initialize(){this._initialNormalInput()}_initialNormalInput(){this._onInputSubscription=this._textSelectionRenderManager.onInput$.subscribe(async i=>{var _;if(i==null)return;const t=this._currentUniverService.getCurrentUniverDocInstance().getUnitId(),{event:n,content:s="",activeRange:r}=i,c=n,l=(_=this._docSkeletonManagerService.getCurrent())==null?void 0:_.skeleton;if(c.data==null||l==null||!l||!r)return;const{startOffset:m,segmentId:u,style:g}=r,S=s.length,f=[{startOffset:m+S,endOffset:m+S,style:g}];await this._commandService.executeCommand(X.id,{unitId:t,body:{dataStream:s},range:r,textRanges:f,segmentId:u})})}_commandExecutedListener(){}_getDocObject(){return re(this._currentUniverService,this._renderManagerService)}};se=Ct([a.OnLifecycle(a.LifecycleStages.Rendered,se),Q(0,A.Inject(d.DocSkeletonManagerService)),Q(1,a.IUniverInstanceService),Q(2,O.IRenderManagerService),Q(3,O.ITextSelectionRenderManager),Q(4,a.ICommandService)],se);var Mt=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,yt=(o,i,e,t)=>{for(var n=t>1?void 0:t?Tt(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&Mt(i,e,n),n},oe=(o,i)=>(e,t)=>i(e,t,o);const Rt={hasScroll:!0},Ot="docs";d.UniverDocsPlugin=(ve=class extends a.Plugin{constructor(e={},t,n,s,r){super(Ot);M(this,"_config");this._injector=t,this._localeService=n,this._configService=s,this._currentUniverService=r,this._config=Object.assign(Rt,e),this._initializeDependencies(t),this._initializeCommands()}initialize(){}_initializeCommands(){[ee,te,ye,Re,k,j,z,H,B,G,Y,W,Z,he,Te,X,V,ue,fe,Se,N,Ue,Ae,Pe,q,ce,be,Ee,De,pe].forEach(e=>{this._injector.get(a.ICommandService).registerCommand(e)})}onReady(){this.initialize()}_initializeDependencies(e){[[d.DocSkeletonManagerService],[d.DocViewModelManagerService],[d.DocStateChangeManagerService],[F],[O.ITextSelectionRenderManager,{useClass:O.TextSelectionRenderManager}],[d.TextSelectionManagerService],[se],[ne],[ie],[ae]].forEach(t=>e.add(t))}},M(ve,"type",a.PluginType.Doc),ve),d.UniverDocsPlugin=yt([oe(1,A.Inject(A.Injector)),oe(2,A.Inject(a.LocaleService)),oe(3,a.IConfigService),oe(4,a.IUniverInstanceService)],d.UniverDocsPlugin),d.BreakLineCommand=Te,d.BulletListCommand=De,d.CoverContentCommand=Ae,d.CutContentCommand=ge,d.DOCS_COMPONENT_DEFAULT_Z_INDEX=Xe,d.DOCS_COMPONENT_HEADER_LAYER_INDEX=Fe,d.DOCS_COMPONENT_MAIN_LAYER_INDEX=$e,d.DOCS_VIEW_KEY=_e,d.DeleteCommand=V,d.DeleteLeftCommand=ye,d.DeleteRightCommand=Re,d.IMEInputCommand=fe,d.IMEInputManagerService=F,d.InnerPasteCommand=it,d.InsertCommand=X,d.MoveCursorOperation=ee,d.MoveSelectionOperation=te,d.NORMAL_TEXT_SELECTION_PLUGIN_NAME=Ve,d.OrderListCommand=Ee,d.ReplaceContentCommand=Ue,d.RichTextEditingMutation=N,d.SelectAllOperation=be,d.SetDocZoomRatioCommand=Pe,d.SetDocZoomRatioOperation=q,d.SetInlineFormatBoldCommand=k,d.SetInlineFormatCommand=he,d.SetInlineFormatFontFamilyCommand=W,d.SetInlineFormatFontSizeCommand=Y,d.SetInlineFormatItalicCommand=j,d.SetInlineFormatStrikethroughCommand=H,d.SetInlineFormatSubscriptCommand=B,d.SetInlineFormatSuperscriptCommand=G,d.SetInlineFormatTextColorCommand=Z,d.SetInlineFormatUnderlineCommand=z,d.SetTextSelectionsOperation=ce,d.UpdateCommand=ue,d.VIEWPORT_KEY=Ie,d.getDocObject=re,d.getDocObjectById=Be,d.serializeTextRange=$,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "UniverSheet normal base-docs",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@wendellhu/redi": "^0.13.0",
|
|
52
52
|
"rxjs": ">=7.0.0",
|
|
53
|
-
"@univerjs/core": "0.1.
|
|
54
|
-
"@univerjs/engine-render": "0.1.
|
|
53
|
+
"@univerjs/core": "0.1.2",
|
|
54
|
+
"@univerjs/engine-render": "0.1.2"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {},
|
|
57
57
|
"devDependencies": {
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"typescript": "^5.3.3",
|
|
62
62
|
"vite": "^5.1.4",
|
|
63
63
|
"vitest": "^1.3.1",
|
|
64
|
-
"@univerjs/
|
|
65
|
-
"@univerjs/
|
|
66
|
-
"@univerjs/shared": "0.1.
|
|
64
|
+
"@univerjs/engine-render": "0.1.2",
|
|
65
|
+
"@univerjs/core": "0.1.2",
|
|
66
|
+
"@univerjs/shared": "0.1.2"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"test": "vitest run",
|
|
@@ -1,27 +0,0 @@
|
|
|
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, RxDisposable } from '@univerjs/core';
|
|
17
|
-
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
18
|
-
import { DocSkeletonManagerService } from '../services/doc-skeleton-manager.service';
|
|
19
|
-
export declare class DocRenderController extends RxDisposable {
|
|
20
|
-
private readonly _docSkeletonManagerService;
|
|
21
|
-
private readonly _renderManagerService;
|
|
22
|
-
private readonly _commandService;
|
|
23
|
-
constructor(_docSkeletonManagerService: DocSkeletonManagerService, _renderManagerService: IRenderManagerService, _commandService: ICommandService);
|
|
24
|
-
private _initialRenderRefresh;
|
|
25
|
-
private _recalculateSizeBySkeleton;
|
|
26
|
-
private _commandExecutedListener;
|
|
27
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
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, IFloatingObjectManagerService, IUniverInstanceService } from '@univerjs/core';
|
|
17
|
-
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
18
|
-
import { DocSkeletonManagerService } from '../services/doc-skeleton-manager.service';
|
|
19
|
-
export declare class FloatingObjectController extends Disposable {
|
|
20
|
-
private readonly _docSkeletonManagerService;
|
|
21
|
-
private readonly _currentUniverService;
|
|
22
|
-
private readonly _renderManagerService;
|
|
23
|
-
private readonly _commandService;
|
|
24
|
-
private readonly _floatingObjectManagerService;
|
|
25
|
-
private _liquid;
|
|
26
|
-
private _pageMarginCache;
|
|
27
|
-
constructor(_docSkeletonManagerService: DocSkeletonManagerService, _currentUniverService: IUniverInstanceService, _renderManagerService: IRenderManagerService, _commandService: ICommandService, _floatingObjectManagerService: IFloatingObjectManagerService);
|
|
28
|
-
private _initialize;
|
|
29
|
-
private _updateOnPluginChange;
|
|
30
|
-
private _initialRenderRefresh;
|
|
31
|
-
private _commandExecutedListener;
|
|
32
|
-
private _refreshFloatingObject;
|
|
33
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
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, IUniverInstanceService } from '@univerjs/core';
|
|
17
|
-
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
18
|
-
export declare class PageRenderController extends Disposable {
|
|
19
|
-
private readonly _renderManagerService;
|
|
20
|
-
private readonly _currentUniverService;
|
|
21
|
-
constructor(_renderManagerService: IRenderManagerService, _currentUniverService: IUniverInstanceService);
|
|
22
|
-
private _initialize;
|
|
23
|
-
private _initialRenderRefresh;
|
|
24
|
-
private _commandExecutedListener;
|
|
25
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
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, IUniverInstanceService } from '@univerjs/core';
|
|
17
|
-
import { IRenderManagerService, ITextSelectionRenderManager } from '@univerjs/engine-render';
|
|
18
|
-
import { DocSkeletonManagerService } from '../services/doc-skeleton-manager.service';
|
|
19
|
-
import { TextSelectionManagerService } from '../services/text-selection-manager.service';
|
|
20
|
-
export declare class TextSelectionController extends Disposable {
|
|
21
|
-
private readonly _docSkeletonManagerService;
|
|
22
|
-
private readonly _currentUniverService;
|
|
23
|
-
private readonly _commandService;
|
|
24
|
-
private readonly _renderManagerService;
|
|
25
|
-
private readonly _textSelectionRenderManager;
|
|
26
|
-
private readonly _textSelectionManagerService;
|
|
27
|
-
private _moveInObserver;
|
|
28
|
-
private _moveOutObserver;
|
|
29
|
-
private _downObserver;
|
|
30
|
-
private _dblClickObserver;
|
|
31
|
-
private _tripleClickObserver;
|
|
32
|
-
private _loadedMap;
|
|
33
|
-
constructor(_docSkeletonManagerService: DocSkeletonManagerService, _currentUniverService: IUniverInstanceService, _commandService: ICommandService, _renderManagerService: IRenderManagerService, _textSelectionRenderManager: ITextSelectionRenderManager, _textSelectionManagerService: TextSelectionManagerService);
|
|
34
|
-
private _initialize;
|
|
35
|
-
dispose(): void;
|
|
36
|
-
private _initialMain;
|
|
37
|
-
private _commandExecutedListener;
|
|
38
|
-
private _skeletonListener;
|
|
39
|
-
private _getDocObjectById;
|
|
40
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
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, IUniverInstanceService } from '@univerjs/core';
|
|
17
|
-
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
18
|
-
import { DocSkeletonManagerService } from '../services/doc-skeleton-manager.service';
|
|
19
|
-
import { TextSelectionManagerService } from '../services/text-selection-manager.service';
|
|
20
|
-
export declare class ZoomController extends Disposable {
|
|
21
|
-
private readonly _docSkeletonManagerService;
|
|
22
|
-
private readonly _currentUniverService;
|
|
23
|
-
private readonly _commandService;
|
|
24
|
-
private readonly _renderManagerService;
|
|
25
|
-
private readonly _textSelectionManagerService;
|
|
26
|
-
private _initializedRender;
|
|
27
|
-
constructor(_docSkeletonManagerService: DocSkeletonManagerService, _currentUniverService: IUniverInstanceService, _commandService: ICommandService, _renderManagerService: IRenderManagerService, _textSelectionManagerService: TextSelectionManagerService);
|
|
28
|
-
dispose(): void;
|
|
29
|
-
private _initialize;
|
|
30
|
-
private _initialRenderRefresh;
|
|
31
|
-
private _skeletonListener;
|
|
32
|
-
private _commandExecutedListener;
|
|
33
|
-
private _updateViewZoom;
|
|
34
|
-
private _calculatePagePosition;
|
|
35
|
-
private _getDocObject;
|
|
36
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
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 { IConfigService, IUniverInstanceService, RxDisposable } from '@univerjs/core';
|
|
17
|
-
import type { RenderManagerService } from '@univerjs/engine-render';
|
|
18
|
-
import { DocViewModelManagerService } from '../services/doc-view-model-manager.service';
|
|
19
|
-
export declare class DocCanvasView extends RxDisposable {
|
|
20
|
-
private readonly _renderManagerService;
|
|
21
|
-
private readonly _configService;
|
|
22
|
-
private readonly _currentUniverService;
|
|
23
|
-
private readonly _docViewModelManagerService;
|
|
24
|
-
private _scene;
|
|
25
|
-
private _currentDocumentModel;
|
|
26
|
-
private _loadedMap;
|
|
27
|
-
private readonly _fps$;
|
|
28
|
-
readonly fps$: import("rxjs").Observable<string>;
|
|
29
|
-
constructor(_renderManagerService: RenderManagerService, _configService: IConfigService, _currentUniverService: IUniverInstanceService, _docViewModelManagerService: DocViewModelManagerService);
|
|
30
|
-
private _initialize;
|
|
31
|
-
dispose(): void;
|
|
32
|
-
private _addNewRender;
|
|
33
|
-
private _addComponent;
|
|
34
|
-
}
|