@univerjs/docs 0.1.12 → 0.1.13-nightly.202406041140
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +989 -975
- package/lib/types/commands/commands/core-editing.command.d.ts +1 -0
- package/lib/types/commands/mutations/core-editing.mutation.d.ts +4 -3
- package/lib/types/index.d.ts +2 -2
- package/lib/types/services/doc-state-change-manager.service.d.ts +3 -2
- package/lib/types/services/text-selection-manager.service.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +7 -7
- package/LICENSE +0 -176
- package/lib/types/commands/commands/insert-floating-object.command.d.ts +0 -3
- package/lib/types/commands/commands/remove-floating-object.command.d.ts +0 -3
- package/lib/types/commands/commands/set-floating-object-transform.command.d.ts +0 -15
- package/lib/types/commands/mutations/insert-floating-object.mutation.d.ts +0 -7
- package/lib/types/commands/mutations/remove-floating-object.mutation.d.ts +0 -4
- package/lib/types/commands/mutations/set-floating-object.mutation.d.ts +0 -32
|
@@ -8,6 +8,7 @@ export interface IInsertCommandParams {
|
|
|
8
8
|
textRanges: ITextRangeWithStyle[];
|
|
9
9
|
segmentId?: string;
|
|
10
10
|
}
|
|
11
|
+
export declare const EditorInsertTextCommandId = "doc.command.insert-text";
|
|
11
12
|
/**
|
|
12
13
|
* The command to insert text. The changed range could be non-collapsed, mainly use in line break and normal input.
|
|
13
14
|
*/
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { IMutation, IMutationCommonParams,
|
|
1
|
+
import { IMutation, IMutationCommonParams, JSONXActions, Nullable } from '@univerjs/core';
|
|
2
2
|
import { ITextRangeWithStyle } from '@univerjs/engine-render';
|
|
3
3
|
|
|
4
4
|
export interface IRichTextEditingMutationParams extends IMutationCommonParams {
|
|
5
5
|
unitId: string;
|
|
6
|
-
|
|
6
|
+
segmentId?: string;
|
|
7
|
+
actions: JSONXActions;
|
|
7
8
|
textRanges: Nullable<ITextRangeWithStyle[]>;
|
|
8
9
|
prevTextRanges?: Nullable<ITextRangeWithStyle[]>;
|
|
9
10
|
noNeedSetTextRange?: boolean;
|
|
10
|
-
noHistory?: boolean;
|
|
11
11
|
isCompositionEnd?: boolean;
|
|
12
|
+
noHistory?: boolean;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* The core mutator to change rich text actions. The execution result would be undo mutation params. Could be directly
|
package/lib/types/index.d.ts
CHANGED
|
@@ -17,11 +17,11 @@ export type { IDocObjectParam } from './basics/component-tools';
|
|
|
17
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
|
-
export { DeleteCommand, type ICoverCommandParams, type IDeleteCommandParams, type IInsertCommandParams, InsertCommand, type IUpdateCommandParams, UpdateCommand, } from './commands/commands/core-editing.command';
|
|
20
|
+
export { DeleteCommand, type ICoverCommandParams, type IDeleteCommandParams, type IInsertCommandParams, InsertCommand, type IUpdateCommandParams, UpdateCommand, EditorInsertTextCommandId, } from './commands/commands/core-editing.command';
|
|
21
21
|
export { DeleteLeftCommand, DeleteRightCommand } from './commands/commands/delete.command';
|
|
22
22
|
export { type IIMEInputCommandParams, IMEInputCommand } from './commands/commands/ime-input.command';
|
|
23
23
|
export { SetInlineFormatBoldCommand, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, SetInlineFormatTextColorCommand, SetInlineFormatUnderlineCommand, ResetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextBackgroundColorCommand, } from './commands/commands/inline-format.command';
|
|
24
|
-
export { AlignOperationCommand, AlignLeftCommand, AlignCenterCommand, AlignRightCommand, AlignJustifyCommand } from './commands/commands/paragraph-align.command';
|
|
24
|
+
export { AlignOperationCommand, AlignLeftCommand, AlignCenterCommand, AlignRightCommand, AlignJustifyCommand, } from './commands/commands/paragraph-align.command';
|
|
25
25
|
export { BulletListCommand, OrderListCommand } from './commands/commands/list.command';
|
|
26
26
|
export { CoverContentCommand, ReplaceContentCommand } from './commands/commands/replace-content.command';
|
|
27
27
|
export { type IRichTextEditingMutationParams, RichTextEditingMutation, } from './commands/mutations/core-editing.mutation';
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JSONXActions, Nullable, ICommandService, IUndoRedoService, IUniverInstanceService, RxDisposable } from '@univerjs/core';
|
|
2
2
|
import { ITextRangeWithStyle } from '@univerjs/engine-render';
|
|
3
3
|
|
|
4
4
|
interface IDocChangeState {
|
|
5
|
-
actions:
|
|
5
|
+
actions: JSONXActions;
|
|
6
6
|
textRanges: Nullable<ITextRangeWithStyle[]>;
|
|
7
7
|
}
|
|
8
8
|
export interface IDocStateChangeParams {
|
|
9
9
|
commandId: string;
|
|
10
10
|
unitId: string;
|
|
11
|
+
segmentId?: string;
|
|
11
12
|
trigger: Nullable<string>;
|
|
12
13
|
redoState: IDocChangeState;
|
|
13
14
|
undoState: IDocChangeState;
|
|
@@ -36,6 +36,7 @@ export declare class TextSelectionManagerService extends RxDisposable {
|
|
|
36
36
|
setCurrentSelection(param: ITextSelectionManagerSearchParam): void;
|
|
37
37
|
setCurrentSelectionNotRefresh(param: ITextSelectionManagerSearchParam): void;
|
|
38
38
|
getSelections(): Readonly<Nullable<TextRange[]>>;
|
|
39
|
+
getActiveTextRange(): Nullable<TextRange>;
|
|
39
40
|
getActiveRange(): Nullable<ITextActiveRange>;
|
|
40
41
|
add(textRanges: ISuccinctTextRangeParam[], isEditing?: boolean): void;
|
|
41
42
|
replaceTextRanges(textRanges: ISuccinctTextRangeParam[], isEditing?: boolean): void;
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,i){typeof exports=="object"&&typeof module<"u"?i(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"],i):(c=typeof globalThis<"u"?globalThis:c||self,i(c.UniverDocs={},c.UniverCore,c.UniverEngineRender,c.rxjs,c["@wendellhu/redi"]))})(this,function(c,i,R,w,L){"use strict";var Kt=Object.defineProperty;var qt=(c,i,R)=>i in c?Kt(c,i,{enumerable:!0,configurable:!0,writable:!0,value:R}):c[i]=R;var y=(c,i,R)=>(qt(c,typeof i!="symbol"?i+"":i,R),R);var Se;var J=(o=>(o.MAIN="__Document_Render_Main__",o.BACKGROUND="__Document_Render_Background__",o))(J||{}),De=(o=>(o.VIEW_MAIN="viewMain",o.VIEW_TOP="viewTop",o.VIEW_LEFT="viewLeft",o.VIEW_LEFT_TOP="viewLeftTop",o))(De||{});const rt=0,ct=2,lt=4,dt=10,ut="normalTextSelectionPluginName";function Ee(o,n){const e=o.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC);if(!e)return null;const t=e.getUnitId(),a=n.getRenderById(t);if(a==null)return;const{mainComponent:s,scene:r,engine:l,components:d}=a,u=s,m=d.get(J.BACKGROUND);return{document:u,docBackground:m,scene:r,engine:l}}function mt(o,n){const e=n.getRenderById(o);if(e==null)return;const{mainComponent:t,scene:a,engine:s,components:r}=e,l=t,d=r.get(J.BACKGROUND);return{document:l,docBackground:d,scene:a,engine:s}}const fe={id:"doc.operation.set-selections",type:i.CommandType.OPERATION,handler:(o,n)=>!0};var gt=Object.defineProperty,St=Object.getOwnPropertyDescriptor,ft=(o,n,e,t)=>{for(var a=t>1?void 0:t?St(n,e):n,s=o.length-1,r;s>=0;s--)(r=o[s])&&(a=(t?r(n,e,a):r(a))||a);return t&&a&>(n,e,a),a},Ae=(o,n)=>(e,t)=>n(e,t,o);function k(o){const{startOffset:n,endOffset:e,collapsed:t}=o,a={startOffset:n,endOffset:e,collapsed:t};return typeof o.isActive=="function"&&(a.isActive=o.isActive()),a}c.TextSelectionManagerService=class extends i.RxDisposable{constructor(e,t){super();y(this,"_currentSelection",null);y(this,"_textSelectionInfo",new Map);y(this,"_textSelection$",new w.BehaviorSubject(null));y(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:a,style:s}=e,r=t.find(f=>f.isActive());if(r==null)return null;const{startOffset:l,endOffset:d,collapsed:u,startNodePosition:m,endNodePosition:g,direction:S}=r;return l==null||d==null?null:{startOffset:l,endOffset:d,collapsed:u,startNodePosition:m,endNodePosition:g,direction:S,segmentId:a,style:s}}add(e,t=!0){this._currentSelection!=null&&this._addByParam({...this._currentSelection,textRanges:e,segmentId:"",isEditing:t,style:R.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(w.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:a,subUnitId:s,segmentId:r,style:l,textRanges:d,isEditing:u}=t;this._commandService.executeCommand(fe.id,{unitId:a,subUnitId:s,segmentId:r,style:l,isEditing:u,ranges:d.map(k)})}_getTextRanges(e){var s;if(e==null)return;const{unitId:t,subUnitId:a=""}=e;return(s=this._textSelectionInfo.get(t))==null?void 0:s.get(a)}_refresh(e){const t=this._getTextRanges(e);this._textSelectionRenderManager.removeAllTextRanges(),t&&Array.isArray(t.textRanges)&&t.textRanges.length&&this._textSelectionRenderManager.addTextRanges(t.textRanges.map(k))}_replaceByParam(e){const{unitId:t,subUnitId:a,style:s,segmentId:r,textRanges:l,isEditing:d}=e;this._textSelectionInfo.has(t)||this._textSelectionInfo.set(t,new Map),this._textSelectionInfo.get(t).set(a,{textRanges:l,style:s,segmentId:r,isEditing:d})}_addByParam(e){const{unitId:t,subUnitId:a,textRanges:s,style:r,segmentId:l,isEditing:d}=e;this._textSelectionInfo.has(t)||this._textSelectionInfo.set(t,new Map);const u=this._textSelectionInfo.get(t);u.has(a)?u.get(a).textRanges.push(...s):u.set(a,{textRanges:s,style:r,segmentId:l,isEditing:d})}},c.TextSelectionManagerService=ft([Ae(0,R.ITextSelectionRenderManager),Ae(1,i.ICommandService)],c.TextSelectionManagerService);function he(o,n="",e=0){const{startOffset:t,endOffset:a}=o,s=[],r=t-e,l=a-e;return r>0&&s.push({t:i.TextXActionType.RETAIN,len:r,segmentId:n}),s.push({t:i.TextXActionType.DELETE,len:l-r,line:0,segmentId:n}),s}var ht=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,vt=(o,n,e,t)=>{for(var a=t>1?void 0:t?pt(n,e):n,s=o.length-1,r;s>=0;s--)(r=o[s])&&(a=(t?r(n,e,a):r(a))||a);return t&&a&&ht(n,e,a),a},It=(o,n)=>(e,t)=>n(e,t,o);c.DocViewModelManagerService=class extends i.RxDisposable{constructor(e){super();y(this,"_docViewModelMap",new Map);y(this,"_currentDocViewModel$",new w.BehaviorSubject(null));y(this,"currentDocViewModel$",this._currentDocViewModel$.asObservable());this._univerInstanceService=e,this._initialize()}_initialize(){this._init()}dispose(){this._currentDocViewModel$.complete(),this._docViewModelMap.clear()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_DOC).pipe(w.takeUntil(this.dispose$)).subscribe(e=>{this._create(e)}),this._univerInstanceService.getAllUnitsForType(i.UniverInstanceType.UNIVER_DOC).forEach(e=>{this._create(e)}),this._univerInstanceService.getTypeOfUnitDisposed$(i.UniverInstanceType.UNIVER_DOC).pipe(w.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 a;const t=this._univerInstanceService.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===i.DOCS_NORMAL_EDITOR_UNIT_ID_KEY){const s=(a=this._docViewModelMap.get(e))==null?void 0:a.docViewModel;if(s==null)return;s.reset(t)}this._currentDocViewModel$.next(this._docViewModelMap.get(e))}}_buildDocViewModel(e){return new R.DocumentViewModel(e)}},c.DocViewModelManagerService=vt([It(0,i.IUniverInstanceService)],c.DocViewModelManagerService);var Ct=Object.defineProperty,_t=Object.getOwnPropertyDescriptor,Mt=(o,n,e,t)=>{for(var a=t>1?void 0:t?_t(n,e):n,s=o.length-1,r;s>=0;s--)(r=o[s])&&(a=(t?r(n,e,a):r(a))||a);return t&&a&&Ct(n,e,a),a},pe=(o,n)=>(e,t)=>n(e,t,o);const Tt=300;c.DocStateChangeManagerService=class extends i.RxDisposable{constructor(e,t,a){super();y(this,"_docStateChange$",new w.BehaviorSubject(null));y(this,"docStateChange$",this._docStateChange$.asObservable());y(this,"_stateCache",new Map);y(this,"_timer",null);this._undoRedoService=e,this._commandService=t,this._univerInstanceService=a,this._initialize()}setChangeState(e){const{trigger:t,noHistory:a}=e;t!=null&&(this._cacheChangeState(e),a||this._docStateChange$.next(e))}_initialize(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===i.UndoCommandId||e.id===i.RedoCommandId){const t=this._univerInstanceService.getCurrentUniverDocInstance();if(t==null)return;const a=t.getUnitId();this._pushHistory(a)}}))}_cacheChangeState(e){const{trigger:t,unitId:a,noHistory:s}=e;if(!(t===i.RedoCommandId||t===i.UndoCommandId||s)){if(this._stateCache.has(a)){const r=this._stateCache.get(a);r==null||r.push(e)}else this._stateCache.set(a,[e]);t===H.id||t===Y.id?(this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{this._pushHistory(a)},Tt)):this._pushHistory(a)}}_pushHistory(e){const t=this._undoRedoService,a=this._stateCache.get(e);if(!Array.isArray(a)||a.length===0)return;const s=a.length,r=a[0].commandId,l=a[0],d=a[s-1],u={unitId:e,actions:a.reduce((g,S)=>i.TextX.compose(g,S.redoState.actions),[]),textRanges:d.redoState.textRanges},m={unitId:e,actions:a.reverse().reduce((g,S)=>i.TextX.compose(g,S.undoState.actions),[]),textRanges:l.undoState.textRanges};t.pushUndoRedo({unitID:e,undoMutations:[{id:r,params:m}],redoMutations:[{id:r,params:u}]}),a.length=0}},c.DocStateChangeManagerService=Mt([pe(0,L.Inject(i.IUndoRedoService)),pe(1,i.ICommandService),pe(2,i.IUniverInstanceService)],c.DocStateChangeManagerService);class G{constructor(){y(this,"_previousActiveRange",null);y(this,"_undoMutationParamsCache",[]);y(this,"_redoMutationParamsCache",[])}clearUndoRedoMutationParamsCache(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[]}getUndoRedoMutationParamsCache(){return{undoCache:this._undoMutationParamsCache,redoCache:this._redoMutationParamsCache}}setUndoRedoMutationParamsCache({undoCache:n=[],redoCache:e=[]}){this._undoMutationParamsCache=n,this._redoMutationParamsCache=e}getActiveRange(){return this._previousActiveRange}setActiveRange(n){this._previousActiveRange=n}pushUndoRedoMutationParams(n,e){this._undoMutationParamsCache.push(n),this._redoMutationParamsCache.push(e)}fetchComposedUndoRedoMutationParams(){if(this._undoMutationParamsCache.length===0||this._previousActiveRange==null||this._redoMutationParamsCache.length===0)return null;const{unitId:n}=this._undoMutationParamsCache[0],e={unitId:n,actions:this._undoMutationParamsCache.reverse().reduce((a,s)=>i.TextX.compose(a,s.actions),[]),textRanges:[]};return{redoMutationParams:{unitId:n,actions:this._redoMutationParamsCache.reduce((a,s)=>i.TextX.compose(a,s.actions),[]),textRanges:[]},undoMutationParams:e,previousActiveRange:this._previousActiveRange}}dispose(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[],this._previousActiveRange=null}}const Ne="doc.mutation.rich-text-editing",N={id:Ne,type:i.CommandType.MUTATION,handler:(o,n)=>{var P;const{unitId:e,actions:t,textRanges:a,prevTextRanges:s,trigger:r,noHistory:l,isCompositionEnd:d,noNeedSetTextRange:u}=n,g=o.get(i.IUniverInstanceService).getUniverDocInstance(e),f=o.get(c.DocViewModelManagerService).getViewModel(e),v=o.get(c.TextSelectionManagerService),h=((P=v.getSelections())!=null?P:[]).map(k),I=o.get(c.DocStateChangeManagerService),C=o.get(G);if(g==null||f==null)throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${e}`);const T=!!g.getSnapshot().disabled;if(t.length===0||T)return{unitId:e,actions:[],textRanges:h};const _=g.apply(t),{segmentId:M}=t[0],x=g.getSelfOrHeaderFooterModel(M);f.getSelfOrHeaderFooterViewModel(M).reset(x),!u&&a&&r!=null&&queueMicrotask(()=>{v.replaceTextRanges(a)});const E={commandId:Ne,unitId:e,trigger:r,noHistory:l,redoState:{actions:t,textRanges:a},undoState:{actions:_,textRanges:s!=null?s:h}};if(d){const O=C.fetchComposedUndoRedoMutationParams();if(O==null)throw new Error("historyParams is null in RichTextEditingMutation");const{undoMutationParams:A,redoMutationParams:U,previousActiveRange:X}=O;E.redoState.actions=U.actions,E.undoState.actions=A.actions,E.undoState.textRanges=[X]}return I.setChangeState(E),{unitId:e,actions:_,textRanges:h}}},H={id:"doc.command.insert-text",type:i.CommandType.COMMAND,handler:async(o,n)=>{const e=o.get(i.ICommandService),{range:t,segmentId:a,body:s,unitId:r,textRanges:l}=n,{startOffset:d,collapsed:u}=t,m={id:N.id,params:{unitId:r,actions:[],textRanges:l}},g=new i.TextX;return u?d>0&&g.push({t:i.TextXActionType.RETAIN,len:d,segmentId:a}):g.push(...he(t,a)),g.push({t:i.TextXActionType.INSERT,body:s,len:s.dataStream.length,line:0,segmentId:a}),m.params.actions=g.serialize(),!!e.syncExecuteCommand(m.id,m.params)}};var F=(o=>(o[o.LEFT=0]="LEFT",o[o.RIGHT=1]="RIGHT",o))(F||{});const Y={id:"doc.command.delete-text",type:i.CommandType.COMMAND,handler:async(o,n)=>{const e=o.get(i.ICommandService),{range:t,segmentId:a,unitId:s,direction:r,textRanges:l,len:d=1}=n,{startOffset:u}=t,m={id:N.id,params:{unitId:s,actions:[],textRanges:l}},g=new i.TextX;return u>0&&g.push({t:i.TextXActionType.RETAIN,len:r===0?u-d:u,segmentId:a}),g.push({t:i.TextXActionType.DELETE,len:d,line:0,segmentId:a}),m.params.actions=g.serialize(),!!e.syncExecuteCommand(m.id,m.params)}},ve={id:"doc.command.update-text",type:i.CommandType.COMMAND,handler:async(o,n)=>{const{range:e,segmentId:t,updateBody:a,coverType:s,unitId:r,textRanges:l}=n,d=o.get(i.ICommandService),u={id:N.id,params:{unitId:r,actions:[],textRanges:l}},m=new i.TextX,{startOffset:g,endOffset:S}=e;return m.push({t:i.TextXActionType.RETAIN,len:g,segmentId:t}),m.push({t:i.TextXActionType.RETAIN,body:a,len:S-g,segmentId:t,coverType:s}),u.params.actions=m.serialize(),!!d.syncExecuteCommand(u.id,u.params)}};function yt(o,n){const e=[];for(let t=0,a=o.length;t<a;t++)o[t]===i.DataStreamTreeTokenType.PARAGRAPH&&e.push({startIndex:t});if(n)for(const t of e)n.bullet&&(t.bullet=i.Tools.deepClone(n.bullet)),n.paragraphStyle&&(t.paragraphStyle=i.Tools.deepClone(n.paragraphStyle));return e}const Ue={id:"doc.command.break-line",type:i.CommandType.COMMAND,handler:async o=>{var v,p;const n=o.get(c.TextSelectionManagerService),e=o.get(i.IUniverInstanceService),t=o.get(i.ICommandService),a=n.getActiveRange();if(a==null)return!1;const s=e.getCurrentUniverDocInstance();if(!s)return!1;const r=s.getUnitId(),{startOffset:l,segmentId:d,style:u}=a,m=[{startOffset:l+1,endOffset:l+1,style:u}],S=((p=(v=s.getBody())==null?void 0:v.paragraphs)!=null?p:[]).find(h=>h.startIndex>=l);return await t.executeCommand(H.id,{unitId:r,body:{dataStream:i.DataStreamTreeTokenType.PARAGRAPH,paragraphs:yt(i.DataStreamTreeTokenType.PARAGRAPH,S)},range:a,textRanges:m,segmentId:d})}};var Rt=Object.defineProperty,Ot=Object.getOwnPropertyDescriptor,xt=(o,n,e,t)=>{for(var a=t>1?void 0:t?Ot(n,e):n,s=o.length-1,r;s>=0;s--)(r=o[s])&&(a=(t?r(n,e,a):r(a))||a);return t&&a&&Rt(n,e,a),a},Ie=(o,n)=>(e,t)=>n(e,t,o);c.DocSkeletonManagerService=class extends i.RxDisposable{constructor(e,t,a){super();y(this,"_currentSkeletonUnitId","");y(this,"_docSkeletonMap",new Map);y(this,"_currentSkeleton$",new w.BehaviorSubject(null));y(this,"currentSkeleton$",this._currentSkeleton$.asObservable());y(this,"_currentSkeletonBefore$",new w.BehaviorSubject(null));y(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._localeService=e,this._docViewModelManagerService=t,this._univerInstanceService=a,this._initialize()}_initialize(){this._init()}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._docSkeletonMap.clear()}_init(){this._docViewModelManagerService.currentDocViewModel$.pipe(w.takeUntil(this.dispose$)).subscribe(e=>{e!=null&&this._setCurrent(e)}),this._docViewModelManagerService.getAllModel().forEach(e=>{e!=null&&this._setCurrent(e)}),this._univerInstanceService.getTypeOfUnitDisposed$(i.UniverInstanceType.UNIVER_DOC).pipe(w.takeUntil(this.dispose$)).subscribe(e=>{var t,a;this._docSkeletonMap.delete(e.getUnitId()),this._currentSkeletonUnitId=(a=(t=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_DOC))==null?void 0:t.getUnitId())!=null?a:""})}getCurrent(){return this.getSkeletonByUnitId(this._currentSkeletonUnitId)}getAllSkeleton(){return this._docSkeletonMap}makeDirtyCurrent(e=!0){this.makeDirty(this._currentSkeletonUnitId,e)}makeDirty(e,t=!0){const a=this.getSkeletonByUnitId(e);a!=null&&(a.dirty=t)}getSkeletonByUnitId(e){return this._docSkeletonMap.get(e)}_setCurrent(e){const{unitId:t}=e;if(this._docSkeletonMap.has(t)){const a=this.getSkeletonByUnitId(t);a.skeleton.calculate(),a.dirty=!0}else{const a=this._buildSkeleton(e.docViewModel);a.calculate(),this._docSkeletonMap.set(t,{unitId:t,skeleton:a,dirty:!1})}return this._currentSkeletonUnitId=t,this._currentSkeletonBefore$.next(this.getCurrent()),this._currentSkeleton$.next(this.getCurrent()),this.getCurrent()}_buildSkeleton(e){return R.DocumentSkeleton.create(e,this._localeService)}},c.DocSkeletonManagerService=xt([Ie(0,L.Inject(i.LocaleService)),Ie(1,L.Inject(c.DocViewModelManagerService)),Ie(2,i.IUniverInstanceService)],c.DocSkeletonManagerService);const Dt={id:"doc.command.inner-paste",type:i.CommandType.COMMAND,handler:async(o,n)=>{const{segmentId:e,body:t,textRanges:a}=n,s=o.get(i.ICommandService),r=o.get(c.TextSelectionManagerService),l=o.get(i.IUniverInstanceService),d=r.getSelections();if(!Array.isArray(d)||d.length===0)return!1;const u=l.getCurrentUniverDocInstance();if(!u)return!1;const m=u.getUnitId(),g={id:N.id,params:{unitId:m,actions:[],textRanges:a}},S=new i.MemoryCursor;S.reset();const f=new i.TextX;for(const p of d){const{startOffset:h,endOffset:I,collapsed:C}=p,T=h-S.cursor;C?f.push({t:i.TextXActionType.RETAIN,len:T,segmentId:e}):f.push(...he(p,e,S.cursor)),f.push({t:i.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)}},Ce={id:"doc.command.inner-cut",type:i.CommandType.COMMAND,handler:async(o,n)=>{var p;const{segmentId:e,textRanges:t}=n,a=o.get(i.ICommandService),s=o.get(c.TextSelectionManagerService),r=o.get(i.IUniverInstanceService),l=s.getSelections();if(!Array.isArray(l)||l.length===0)return!1;const d=(p=r.getCurrentUniverDocInstance())==null?void 0:p.getUnitId();if(!d)return!1;const u=r.getUniverDocInstance(d),m=i.getDocsUpdateBody(u.snapshot,e);if(m==null)return!1;const g={id:N.id,params:{unitId:d,actions:[],textRanges:t}},S=new i.MemoryCursor;S.reset();const f=new i.TextX;for(const h of l){const{startOffset:I,endOffset:C,collapsed:T}=h,_=I-S.cursor;T?f.push({t:i.TextXActionType.RETAIN,len:_,segmentId:e}):f.push(...Et(h,m,e,S.cursor)),S.reset(),S.moveCursor(C)}return g.params.actions=f.serialize(),!!a.syncExecuteCommand(g.id,g.params)}};function Et(o,n,e="",t=0){const{startOffset:a,endOffset:s}=o,r=[],{paragraphs:l=[]}=n,d=a-t,u=s-t,m=l==null?void 0:l.find(g=>g.startIndex-t>=d&&g.startIndex-t<=u);if(d>0&&r.push({t:i.TextXActionType.RETAIN,len:d,segmentId:e}),m&&m.startIndex-t>d){const g=m.startIndex-t;r.push({t:i.TextXActionType.DELETE,len:g-d,line:0,segmentId:e}),r.push({t:i.TextXActionType.RETAIN,len:1,segmentId:e}),u>g+1&&r.push({t:i.TextXActionType.DELETE,len:u-g-1,line:0,segmentId:e})}else r.push({t:i.TextXActionType.DELETE,len:u-d,line:0,segmentId:e});return r}const be={id:"doc.command.delete-left",type:i.CommandType.COMMAND,handler:async o=>{var _;const n=o.get(c.TextSelectionManagerService),e=o.get(c.DocSkeletonManagerService),t=o.get(i.IUniverInstanceService),a=o.get(i.ICommandService),s=n.getActiveRange(),r=n.getSelections(),l=(_=e.getCurrent())==null?void 0:_.skeleton;let d=!0;if(s==null||l==null||r==null)return!1;const u=t.getCurrentUniverDocInstance();if(!u)return!1;const{startOffset:m,collapsed:g,segmentId:S,style:f}=s,v=l.findNodeByCharIndex(m),p=R.hasListGlyph(v),h=R.isIndentByGlyph(v,u.getBody());let I=m;const C=l.findNodeByCharIndex(m-1);if(R.isFirstGlyph(v)&&C!==v&&(p===!0||h===!0)&&g){const M=R.getParagraphByGlyph(v,u.getBody());if(M==null)return!1;const x=M==null?void 0:M.startIndex,D={startIndex:0},E=M.paragraphStyle;if(p===!0){const O=M.paragraphStyle;if(O){D.paragraphStyle=O;const{hanging:A}=O;A&&(D.paragraphStyle.indentStart=A,D.paragraphStyle.hanging=void 0)}}else if(h===!0){const O=M.bullet;O&&(D.bullet=O),E!=null&&(D.paragraphStyle={...E},delete D.paragraphStyle.hanging,delete D.paragraphStyle.indentStart)}const P=[{startOffset:I,endOffset:I,style:f}];d=await a.executeCommand(ve.id,{unitId:u.getUnitId(),updateBody:{dataStream:"",paragraphs:[{...D}]},range:{startOffset:x,endOffset:x+1},textRanges:P,coverType:i.UpdateDocsAttributeType.REPLACE,segmentId:S})}else if(g===!0){if(C==null)return!0;if(C.content==="\r")d=await a.executeCommand(_e.id,{direction:F.LEFT,range:s});else{I-=C.count;const M=[{startOffset:I,endOffset:I,style:f}];d=await a.executeCommand(Y.id,{unitId:u.getUnitId(),range:s,segmentId:S,direction:F.LEFT,len:C.count,textRanges:M})}}else{const M=we(s,r);d=await a.executeCommand(Ce.id,{segmentId:S,textRanges:M})}return d}},Pe={id:"doc.command.delete-right",type:i.CommandType.COMMAND,handler:async o=>{var v;const n=o.get(c.TextSelectionManagerService),e=o.get(c.DocSkeletonManagerService),t=o.get(i.IUniverInstanceService),a=o.get(i.ICommandService),s=n.getActiveRange(),r=n.getSelections(),l=(v=e.getCurrent())==null?void 0:v.skeleton;let d;if(s==null||l==null||r==null)return!1;const u=t.getCurrentUniverDocInstance();if(!u)return!1;const{startOffset:m,collapsed:g,segmentId:S,style:f}=s;if(m===u.getBody().dataStream.length-2&&g)return!0;if(g===!0){const p=l.findNodeByCharIndex(m);if(p.content==="\r")d=await a.executeCommand(_e.id,{direction:F.RIGHT,range:s});else{const h=[{startOffset:m,endOffset:m,style:f}];d=await a.executeCommand(Y.id,{unitId:u.getUnitId(),range:s,segmentId:S,direction:F.RIGHT,textRanges:h,len:p.count})}}else{const p=we(s,r);d=await a.executeCommand(Ce.id,{segmentId:S,textRanges:p})}return d}},_e={id:"doc.command.merge-two-paragraph",type:i.CommandType.COMMAND,handler:async(o,n)=>{var D,E,P;const e=o.get(c.TextSelectionManagerService),t=o.get(i.IUniverInstanceService),a=o.get(i.ICommandService),{direction:s,range:r}=n,l=e.getActiveRange(),d=e.getSelections();if(l==null||d==null)return!1;const u=t.getCurrentUniverDocInstance();if(!u)return!1;const{startOffset:m,collapsed:g,segmentId:S,style:f}=l;if(!g)return!1;const v=s===F.LEFT?m:m+1,p=(P=(E=(D=u.getBody())==null?void 0:D.paragraphs)==null?void 0:E.find(O=>O.startIndex>=v))==null?void 0:P.startIndex,h=At(u.getBody(),v,p),I=s===F.LEFT?m-1:m,C=u.getUnitId(),T=[{startOffset:I,endOffset:I,style:f}],_={id:N.id,params:{unitId:C,actions:[],textRanges:T,prevTextRanges:[r]}},M=new i.TextX;return M.push({t:i.TextXActionType.RETAIN,len:s===F.LEFT?m-1:m,segmentId:S}),h.dataStream.length&&M.push({t:i.TextXActionType.INSERT,body:h,len:h.dataStream.length,line:0,segmentId:S}),M.push({t:i.TextXActionType.RETAIN,len:1,segmentId:S}),M.push({t:i.TextXActionType.DELETE,len:p+1-v,line:0,segmentId:S}),_.params.actions=M.serialize(),!!a.syncExecuteCommand(_.id,_.params)}};function At(o,n,e){const{textRuns:t}=o,a=o.dataStream.substring(n,e);if(t==null)return{dataStream:a};const s=[];for(const r of t){const{st:l,ed:d}=r;d<=n||l>=e||(l<n?s.push({...r,st:0,ed:d-n}):d>e?s.push({...r,st:l-n,ed:e-n}):s.push({...r,st:l-n,ed:d-n}))}return{dataStream:a,textRuns:s}}function we(o,n){let e=o.endOffset;for(const a of n){const{startOffset:s,endOffset:r}=a;s==null||r==null||r<=o.endOffset&&(e-=r-s)}return[{startOffset:e,endOffset:e,style:o.style}]}const Me={id:"doc.command.ime-input",type:i.CommandType.COMMAND,handler:async(o,n)=>{const{unitId:e,newText:t,oldTextLen:a,isCompositionEnd:s,isCompositionStart:r}=n,l=o.get(i.ICommandService),d=o.get(G),u=d.getActiveRange();if(u==null)return!1;const{startOffset:m,style:g,segmentId:S}=u,f=t.length,v=[{startOffset:m+f,endOffset:m+f,collapsed:!0,style:g}],p={id:N.id,params:{unitId:e,actions:[],textRanges:v}},h=new i.TextX;!u.collapsed&&r?h.push(...he(u,S)):h.push({t:i.TextXActionType.RETAIN,len:m,segmentId:S}),a>0&&h.push({t:i.TextXActionType.DELETE,len:a,line:0,segmentId:S}),h.push({t:i.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=l.syncExecuteCommand(p.id,p.params);return d.pushUndoRedoMutationParams(I,p.params),!!I}};function b(o,n,e,t){var s;const{segmentId:a}=(s=e.getActiveRange())!=null?s:{};return a==null?!1:t.executeCommand(Te.id,{segmentId:a,preCommandId:o,...n!=null?n:{}})}const Le="doc.command.set-inline-format-bold",Q={id:Le,type:i.CommandType.COMMAND,handler:async(o,n)=>{const e=o.get(i.ICommandService),t=o.get(c.TextSelectionManagerService);return b(Le,n,t,e)}},Be="doc.command.set-inline-format-italic",ee={id:Be,type:i.CommandType.COMMAND,handler:async(o,n)=>{const e=o.get(i.ICommandService),t=o.get(c.TextSelectionManagerService);return b(Be,n,t,e)}},Fe="doc.command.set-inline-format-underline",te={id:Fe,type:i.CommandType.COMMAND,handler:async(o,n)=>{const e=o.get(i.ICommandService),t=o.get(c.TextSelectionManagerService);return b(Fe,n,t,e)}},$e="doc.command.set-inline-format-strikethrough",ne={id:$e,type:i.CommandType.COMMAND,handler:async(o,n)=>{const e=o.get(i.ICommandService),t=o.get(c.TextSelectionManagerService);return b($e,n,t,e)}},ke="doc.command.set-inline-format-subscript",z={id:ke,type:i.CommandType.COMMAND,handler:async(o,n)=>{const e=o.get(i.ICommandService),t=o.get(c.TextSelectionManagerService);return b(ke,n,t,e)}},Xe="doc.command.set-inline-format-superscript",ie={id:Xe,type:i.CommandType.COMMAND,handler:async(o,n)=>{const e=o.get(i.ICommandService),t=o.get(c.TextSelectionManagerService);return b(Xe,n,t,e)}},Ve="doc.command.set-inline-format-fontsize",ae={id:Ve,type:i.CommandType.COMMAND,handler:async(o,n)=>{const e=o.get(i.ICommandService),t=o.get(c.TextSelectionManagerService);return b(Ve,n,t,e)}},ze="doc.command.set-inline-format-font-family",oe={id:ze,type:i.CommandType.COMMAND,handler:async(o,n)=>{const e=o.get(i.ICommandService),t=o.get(c.TextSelectionManagerService);return b(ze,n,t,e)}},je="doc.command.set-inline-format-text-color",se={id:je,type:i.CommandType.COMMAND,handler:async(o,n)=>{const e=o.get(i.ICommandService),t=o.get(c.TextSelectionManagerService);return b(je,n,t,e)}},Ge="doc.command.set-inline-format-text-background-color",re={id:Ge,type:i.CommandType.COMMAND,handler:async(o,n)=>{const e=o.get(i.ICommandService),t=o.get(c.TextSelectionManagerService);return b(Ge,n,t,e)}},He="doc.command.reset-inline-format-text-background-color",ce={id:He,type:i.CommandType.COMMAND,handler:async(o,n)=>{const e=o.get(i.ICommandService),t=o.get(c.TextSelectionManagerService);return b(He,n,t,e)}},Ye={[Q.id]:"bl",[ee.id]:"it",[te.id]:"ul",[ne.id]:"st",[ae.id]:"fs",[oe.id]:"ff",[se.id]:"cl",[re.id]:"bg",[ce.id]:"bg",[z.id]:"va",[ie.id]:"va"},Te={id:"doc.command.set-inline-format",type:i.CommandType.COMMAND,handler:async(o,n)=>{const{segmentId:e,value:t,preCommandId:a}=n,s=o.get(i.ICommandService),r=o.get(c.TextSelectionManagerService),l=o.get(i.IUniverInstanceService),d=r.getSelections();if(!Array.isArray(d)||d.length===0)return!1;let u=l.getCurrentUniverDocInstance();if(!u)return!1;let m=u.getUnitId();m===i.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(u=l.getUniverDocInstance(i.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),m=u.getUnitId());let g;switch(a){case Q.id:case ee.id:case te.id:case ne.id:case z.id:case ie.id:{g=Ut(u.getBody().textRuns,a,d);break}case ae.id:case oe.id:{g=t;break}case se.id:case re.id:{g={rgb:t};break}case ce.id:{g={rgb:null};break}default:throw new Error(`Unknown command: ${a} in handleInlineFormat`)}const S={id:N.id,params:{unitId:m,actions:[],textRanges:d.map(k)}},f=new i.TextX,v=new i.MemoryCursor;v.reset();for(const h of d){const{startOffset:I,endOffset:C}=h,T={dataStream:"",textRuns:[{st:0,ed:C-I,ts:{[Ye[a]]:g}}]},_=I-v.cursor;_!==0&&f.push({t:i.TextXActionType.RETAIN,len:_,segmentId:e}),f.push({t:i.TextXActionType.RETAIN,body:T,len:C-I,segmentId:e}),v.reset(),v.moveCursor(C)}return S.params.actions=f.serialize(),!!s.syncExecuteCommand(S.id,S.params)}};function Nt(o){return o!==null&&typeof o=="object"}function Ut(o,n,e){let t=0,a=0;const s=Ye[n];for(;t!==o.length&&a!==e.length;){const{startOffset:r,endOffset:l}=e[a],{st:d,ed:u,ts:m}=o[t];if(l<=d)a++;else if(u<=r)t++;else{if(/bl|it/.test(s))return(m==null?void 0:m[s])===i.BooleanNumber.TRUE?i.BooleanNumber.FALSE:i.BooleanNumber.TRUE;if(/ul|st/.test(s))return Nt(m==null?void 0:m[s])&&(m==null?void 0:m[s]).s===i.BooleanNumber.TRUE?{s:i.BooleanNumber.FALSE}:{s:i.BooleanNumber.TRUE};if(/va/.test(s))return n===z.id?(m==null?void 0:m[s])===i.BaselineOffset.SUBSCRIPT?i.BaselineOffset.NORMAL:i.BaselineOffset.SUBSCRIPT:(m==null?void 0:m[s])===i.BaselineOffset.SUPERSCRIPT?i.BaselineOffset.NORMAL:i.BaselineOffset.SUPERSCRIPT;t++}}return/bl|it/.test(s)?i.BooleanNumber.TRUE:/ul|st/.test(s)?{s:i.BooleanNumber.TRUE}:n===z.id?i.BaselineOffset.SUBSCRIPT:i.BaselineOffset.SUPERSCRIPT}const ye={id:"doc.command.list-operation",type:i.CommandType.COMMAND,handler:(o,n)=>{var O,A,U,X;const e=o.get(c.TextSelectionManagerService),t=o.get(i.IUniverInstanceService),a=o.get(i.ICommandService),{listType:s}=n,r=t.getCurrentUniverDocInstance();if(!r)return!1;const l=e.getActiveRange(),d=(O=e.getSelections())!=null?O:[],u=(A=r.getBody())==null?void 0:A.paragraphs,m=d.map(k);if(l==null||u==null)return!1;const g=Ke(l,u),{segmentId:S}=l,f=r.getUnitId(),v=g.every(V=>{var B;return((B=V.bullet)==null?void 0:B.listType)===s});let h=i.Tools.generateRandomId(6);if(g.length===1){const V=u.indexOf(g[0]),B=u[V-1],$=u[V+1];B&&B.bullet&&B.bullet.listType===s?h=B.bullet.listId:$&&$.bullet&&$.bullet.listType===s&&(h=$.bullet.listId)}const I={id:N.id,params:{unitId:f,actions:[],textRanges:m}},C=new i.MemoryCursor;C.reset();const T=new i.TextX,_=(U=r.getSnapshot().lists)!=null?U:{},M={...i.PRESET_LIST_TYPE,..._},{charSpace:x,defaultTabStop:D=36,gridType:E}=r.getSnapshot().documentStyle;for(const V of g){const{startIndex:B,paragraphStyle:$={}}=V,{indentFirstLine:Wt=0,snapToGrid:Zt,indentStart:Re=0}=$,{hanging:Oe,indentStart:st}=M[s].nestingLevel[0],xe=R.getCharSpaceApply(x,D,E,Zt);T.push({t:i.TextXActionType.RETAIN,len:B-C.cursor,segmentId:S}),T.push({t:i.TextXActionType.RETAIN,len:1,body:{dataStream:"",paragraphs:[v?{paragraphStyle:{...$,hanging:void 0,indentStart:Re?Math.max(0,R.getNumberUnitValue(Re,xe)+Oe-st):void 0},startIndex:0}:{startIndex:0,paragraphStyle:{...$,indentFirstLine:void 0,hanging:Oe,indentStart:st-Oe+R.getNumberUnitValue(Wt,xe)+R.getNumberUnitValue(Re,xe)},bullet:{...(X=V.bullet)!=null?X:{nestingLevel:0,textStyle:{fs:20}},listType:s,listId:h}}]},segmentId:S,coverType:i.UpdateDocsAttributeType.REPLACE}),C.moveCursorTo(B+1)}return I.params.actions=T.serialize(),!!a.syncExecuteCommand(I.id,I.params)}},We={id:"doc.command.bullet-list",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(ye.id,{listType:i.PresetListType.BULLET_LIST})},Ze={id:"doc.command.order-list",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(ye.id,{listType:i.PresetListType.ORDER_LIST})};function Ke(o,n){const{startOffset:e,endOffset:t}=o,a=[];let s=-1;for(const r of n){const{startIndex:l}=r;(e>s&&e<=l||t>s&&t<=l||l>=e&&l<=t)&&a.push(r),s=l}return a}const j={id:"doc.command.align-operation",type:i.CommandType.COMMAND,handler:(o,n)=>{var T,_;const e=o.get(c.TextSelectionManagerService),t=o.get(i.IUniverInstanceService),a=o.get(i.ICommandService),{alignType:s}=n,r=t.getCurrentUniverDocInstance();if(!r)return!1;const l=e.getActiveRange(),d=(T=e.getSelections())!=null?T:[],u=(_=r.getBody())==null?void 0:_.paragraphs,m=d.map(k);if(l==null||u==null)return!1;const g=Ke(l,u),{segmentId:S}=l,f=r.getUnitId(),v=g.every(M=>{var x;return((x=M.paragraphStyle)==null?void 0:x.horizontalAlign)===s}),p={id:N.id,params:{unitId:f,actions:[],textRanges:m}},h=new i.MemoryCursor;h.reset();const I=new i.TextX;for(const M of g){const{startIndex:x}=M;I.push({t:i.TextXActionType.RETAIN,len:x-h.cursor,segmentId:S});const D={...M.paragraphStyle,horizontalAlign:v?i.HorizontalAlign.UNSPECIFIED:s};I.push({t:i.TextXActionType.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...M,paragraphStyle:D,startIndex:0}]},segmentId:S,coverType:i.UpdateDocsAttributeType.REPLACE}),h.moveCursorTo(x+1)}return p.params.actions=I.serialize(),!!a.syncExecuteCommand(p.id,p.params)}},qe={id:"doc.command.align-left",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(j.id,{alignType:i.HorizontalAlign.LEFT})},Je={id:"doc.command.align-center",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(j.id,{alignType:i.HorizontalAlign.CENTER})},Qe={id:"doc.command.align-right",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(j.id,{alignType:i.HorizontalAlign.RIGHT})},et={id:"doc.command.align-justify",type:i.CommandType.COMMAND,handler:o=>o.get(i.ICommandService).syncExecuteCommand(j.id,{alignType:i.HorizontalAlign.JUSTIFIED})},tt={id:"doc.command-replace-content",type:i.CommandType.COMMAND,handler:async(o,n)=>{var f;const{unitId:e,body:t,textRanges:a,segmentId:s=""}=n,r=o.get(i.IUniverInstanceService),l=o.get(i.ICommandService),d=o.get(c.TextSelectionManagerService),u=(f=r.getUniverDocInstance(e))==null?void 0:f.getSnapshot().body,m=d.getSelections();if(u==null||!Array.isArray(m)||m.length===0)return!1;const g=it(e,s,u,t);return g.params.textRanges=a,!!l.syncExecuteCommand(g.id,g.params)}},nt={id:"doc.command-cover-content",type:i.CommandType.COMMAND,handler:async(o,n)=>{var m;const{unitId:e,body:t,segmentId:a=""}=n,s=o.get(i.IUniverInstanceService),r=o.get(i.ICommandService),l=o.get(i.IUndoRedoService),d=(m=s.getUniverDocInstance(e))==null?void 0:m.getSnapshot().body;if(d==null)return!1;const u=it(e,a,d,t);return u.params.noNeedSetTextRange=!0,u.params.noHistory=!0,r.syncExecuteCommand(u.id,u.params),l.clearUndoRedo(e),!0}};function it(o,n,e,t){const a={id:N.id,params:{unitId:o,actions:[],textRanges:[]}},s=new i.TextX,r=(e==null?void 0:e.dataStream.length)-2;return r>0&&s.push({t:i.TextXActionType.DELETE,len:r,line:0,segmentId:n}),t.dataStream.length>0&&s.push({t:i.TextXActionType.INSERT,body:t,len:t.dataStream.length,line:0,segmentId:n}),a.params.actions=s.serialize(),a}const le={id:"doc.operation.move-cursor",type:i.CommandType.OPERATION,handler:(o,n)=>!!n},de={id:"doc.operation.move-selection",type:i.CommandType.OPERATION,handler:(o,n)=>!!n},bt=(o,n)=>{const e=o.get(i.IUniverInstanceService).getUniverDocInstance(n.unitId),t=(e==null?void 0:e.zoomRatio)||1;return{...i.Tools.deepClone(n),zoomRatio:t}},W={id:"doc.operation.set-zoom-ratio",type:i.CommandType.OPERATION,handler:(o,n)=>{const e=o.get(i.IUniverInstanceService).getUniverDocInstance(n.unitId);if(!e)return!1;const t=e.getSnapshot();return t.settings==null?t.settings={zoomRatio:n.zoomRatio}:t.settings.zoomRatio=n.zoomRatio,!0}},at={type:i.CommandType.COMMAND,id:"doc.command.set-zoom-ratio",handler:async(o,n)=>{var g,S,f;const e=o.get(i.ICommandService),t=o.get(i.IUndoRedoService),a=o.get(i.IUniverInstanceService);let s=(g=a.getCurrentUniverDocInstance())==null?void 0:g.getUnitId();if(!s)return!1;let r=1;if(n&&(s=(S=n.documentId)!=null?S:s,r=(f=n.zoomRatio)!=null?f:r),!a.getUniverDocInstance(s))return!1;const d={zoomRatio:r,unitId:s},u=bt(o,d);return e.syncExecuteCommand(W.id,d)?(t.pushUndoRedo({unitID:s,undoMutations:[{id:W.id,params:u}],redoMutations:[{id:W.id,params:d}]}),!0):!1}},ot={id:"doc.operation.select-all",type:i.CommandType.COMMAND,handler:async o=>{const n=o.get(i.IUniverInstanceService),e=o.get(c.TextSelectionManagerService),t=n.getCurrentUniverDocInstance();if(!t)return!1;const a=t.getSnapshot().body;if(a==null)return!1;const s=[{startOffset:0,endOffset:a.dataStream.length-2}];return e.replaceTextRanges(s,!1),!0}};var Pt=Object.defineProperty,wt=Object.getOwnPropertyDescriptor,Lt=(o,n,e,t)=>{for(var a=t>1?void 0:t?wt(n,e):n,s=o.length-1,r;s>=0;s--)(r=o[s])&&(a=(t?r(n,e,a):r(a))||a);return t&&a&&Pt(n,e,a),a},Z=(o,n)=>(e,t)=>n(e,t,o);let ue=class extends i.Disposable{constructor(n,e,t,a,s){super();y(this,"_previousIMEContent","");y(this,"_isCompositionStart",!0);y(this,"_onStartSubscription");y(this,"_onUpdateSubscription");y(this,"_onEndSubscription");this._docSkeletonManagerService=n,this._univerInstanceService=e,this._textSelectionRenderManager=t,this._imeInputManagerService=a,this._commandService=s,this._initialize()}dispose(){var n,e,t;(n=this._onStartSubscription)==null||n.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(n=>{if(n==null)return;this._resetIME();const{activeRange:e}=n;e!=null&&this._imeInputManagerService.setActiveRange(i.Tools.deepClone(e))})}_initialOnCompositionUpdate(){this._onUpdateSubscription=this._textSelectionRenderManager.onCompositionupdate$.subscribe(async n=>{this._updateContent(n,!0)})}_initialOnCompositionend(){this._onEndSubscription=this._textSelectionRenderManager.onCompositionend$.subscribe(n=>{this._updateContent(n,!1)})}async _updateContent(n,e){var u;const t=(u=this._docSkeletonManagerService.getCurrent())==null?void 0:u.skeleton;if(n==null||t==null)return;const a=this._univerInstanceService.getCurrentUniverDocInstance();if(!a)return;const{event:s,activeRange:r}=n;if(t==null||r==null)return;const d=s.data;d===this._previousIMEContent&&e||(await this._commandService.executeCommand(Me.id,{unitId:a.getUnitId(),newText:d,oldTextLen:this._previousIMEContent.length,isCompositionStart:this._isCompositionStart,isCompositionEnd:!e}),e?(this._isCompositionStart&&(this._isCompositionStart=!1),this._previousIMEContent=d):this._resetIME())}_resetIME(){this._previousIMEContent="",this._isCompositionStart=!0,this._imeInputManagerService.clearUndoRedoMutationParamsCache(),this._imeInputManagerService.setActiveRange(null)}};ue=Lt([i.OnLifecycle(i.LifecycleStages.Rendered,ue),Z(0,L.Inject(c.DocSkeletonManagerService)),Z(1,i.IUniverInstanceService),Z(2,R.ITextSelectionRenderManager),Z(3,L.Inject(G)),Z(4,i.ICommandService)],ue);var Bt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor,$t=(o,n,e,t)=>{for(var a=t>1?void 0:t?Ft(n,e):n,s=o.length-1,r;s>=0;s--)(r=o[s])&&(a=(t?r(n,e,a):r(a))||a);return t&&a&&Bt(n,e,a),a},K=(o,n)=>(e,t)=>n(e,t,o);let me=class extends i.Disposable{constructor(n,e,t,a,s){super();y(this,"_onInputSubscription");this._docSkeletonManagerService=n,this._univerInstanceService=e,this._renderManagerService=t,this._textSelectionManagerService=a,this._commandService=s,this._commandExecutedListener()}dispose(){var n;super.dispose(),(n=this._onInputSubscription)==null||n.unsubscribe()}_commandExecutedListener(){const n=[le.id,de.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(!n.includes(e.id))return;const t=e.params;switch(e.id){case le.id:return this._handleMoveCursor(t.direction);case de.id:return this._handleShiftMoveSelection(t.direction);default:throw new Error("Unknown command")}}))}_handleShiftMoveSelection(n){var p,h,I;const e=this._textSelectionManagerService.getActiveRange(),t=this._textSelectionManagerService.getSelections(),a=this._univerInstanceService.getCurrentUniverDocInstance();if(!a)return;const s=(p=this._docSkeletonManagerService.getCurrent())==null?void 0:p.skeleton,r=this._getDocObject();if(e==null||s==null||r==null)return;const{startOffset:l,endOffset:d,style:u,collapsed:m,direction:g}=e;if(t.length>1){let C=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY;for(const _ of t)C=Math.min(C,_.startOffset),T=Math.max(T,_.endOffset);this._textSelectionManagerService.replaceTextRanges([{startOffset:n===i.Direction.LEFT||n===i.Direction.UP?T:C,endOffset:n===i.Direction.LEFT||n===i.Direction.UP?C:T,style:u}],!1);return}const S=m||g===R.RANGE_DIRECTION.FORWARD?l:d;let f=m||g===R.RANGE_DIRECTION.FORWARD?d:l;const v=(h=a.getBody().dataStream.length)!=null?h:Number.POSITIVE_INFINITY;if(n===i.Direction.LEFT||n===i.Direction.RIGHT){const C=s.findNodeByCharIndex(f-1),T=s.findNodeByCharIndex(f);f=n===i.Direction.RIGHT?f+T.count:f-((I=C==null?void 0:C.count)!=null?I:0),f=Math.min(v-2,Math.max(0,f)),this._textSelectionManagerService.replaceTextRanges([{startOffset:S,endOffset:f,style:u}],!1)}else{const C=s.findNodeByCharIndex(f),T=r.document.getOffsetConfig(),_=this._getTopOrBottomPosition(s,C,n===i.Direction.DOWN);if(_==null){const x=n===i.Direction.UP?0:v-2;if(x===f)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:S,endOffset:x,style:u}],!1);return}const M=new R.NodePositionConvertToCursor(T,s).getRangePointData(_,_).cursorList[0];this._textSelectionManagerService.replaceTextRanges([{startOffset:S,endOffset:M.endOffset,style:u}],!1)}}_handleMoveCursor(n){var S,f,v;const e=this._textSelectionManagerService.getActiveRange(),t=this._textSelectionManagerService.getSelections(),a=this._univerInstanceService.getCurrentUniverDocInstance();if(!a)return!1;const 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:l,endOffset:d,style:u,collapsed:m}=e,g=(f=a.getBody().dataStream.length)!=null?f:Number.POSITIVE_INFINITY;if(n===i.Direction.LEFT||n===i.Direction.RIGHT){let p;if(!e.collapsed||t.length>1){let h=Number.POSITIVE_INFINITY,I=Number.NEGATIVE_INFINITY;for(const C of t)h=Math.min(h,C.startOffset),I=Math.max(I,C.endOffset);p=n===i.Direction.LEFT?h:I}else{const h=s.findNodeByCharIndex(l-1),I=s.findNodeByCharIndex(l);n===i.Direction.LEFT?p=Math.max(0,l-((v=h==null?void 0:h.count)!=null?v:0)):p=Math.min(g-2,d+I.count)}this._textSelectionManagerService.replaceTextRanges([{startOffset:p,endOffset:p,style:u}],!1)}else{const p=s.findNodeByCharIndex(l),h=s.findNodeByCharIndex(d),I=r.document.getOffsetConfig(),C=this._getTopOrBottomPosition(s,n===i.Direction.UP?p:h,n===i.Direction.DOWN);if(C==null){let _;m?_=n===i.Direction.UP?0:g-2:_=n===i.Direction.UP?l:d,this._textSelectionManagerService.replaceTextRanges([{startOffset:_,endOffset:_,style:u}],!1);return}const T=new R.NodePositionConvertToCursor(I,s).getRangePointData(C,C).cursorList[0];this._textSelectionManagerService.replaceTextRanges([{...T,style:u}],!1)}}_getTopOrBottomPosition(n,e,t){if(e==null)return;const a=this._getSpanLeftOffsetInLine(e),s=this._getNextOrPrevLine(e,t);if(s==null)return;const r=this._matchPositionByLeftOffset(n,s,a);if(r!=null)return{...r,isBack:!0}}_getSpanLeftOffsetInLine(n){const e=n.parent;if(e==null)return Number.NEGATIVE_INFINITY;const t=e.left,{left:a}=n;return t+a}_matchPositionByLeftOffset(n,e,t){const a={distance:Number.POSITIVE_INFINITY};for(const s of e.divides){const r=s.left;for(const l of s.glyphGroup){const{left:d}=l,u=r+d,m=Math.abs(t-u);m<a.distance&&(a.glyph=l,a.distance=m)}}if(a.glyph!=null)return n.findPositionByGlyph(a.glyph)}_getNextOrPrevLine(n,e){var v,p,h,I,C,T,_,M,x,D,E,P;const t=n.parent;if(t==null)return;const a=t.parent;if(a==null)return;const s=a.parent;if(s==null)return;const r=s.lines.indexOf(a);if(r===-1)return;let l;if(e===!0?l=s.lines[r+1]:l=s.lines[r-1],l!=null)return l;const d=s.parent;if(d==null)return;const u=d.columns.indexOf(s);if(u===-1)return;if(e===!0)l=(v=d.columns[u+1])==null?void 0:v.lines[0];else{const O=(h=(p=d.columns)==null?void 0:p[u-1])==null?void 0:h.lines;l=O==null?void 0:O[O.length-1]}if(l!=null)return l;const m=d.parent;if(m==null)return;const g=m.sections.indexOf(d);if(g===-1)return;if(e===!0)l=(C=(I=m.sections[g-1])==null?void 0:I.columns[0])==null?void 0:C.lines[0];else{const O=(_=(T=m.sections)==null?void 0:T[g-1])==null?void 0:_.columns,A=O==null?void 0:O[O.length-1],U=A==null?void 0:A.lines;l=U==null?void 0:U[U.length-1]}if(l!=null)return l;const S=m.parent;if(S==null)return;const f=S.pages.indexOf(m);if(f!==-1){if(e===!0)l=(D=(x=(M=S.pages[f+1])==null?void 0:M.sections[0])==null?void 0:x.columns[0])==null?void 0:D.lines[0];else{const O=(E=S.pages[f-1])==null?void 0:E.sections;if(O==null)return;const A=(P=O[O.length-1])==null?void 0:P.columns,U=A[A.length-1],X=U==null?void 0:U.lines;l=X[X.length-1]}if(l!=null)return l}}_getDocObject(){return Ee(this._univerInstanceService,this._renderManagerService)}};me=$t([i.OnLifecycle(i.LifecycleStages.Rendered,me),K(0,L.Inject(c.DocSkeletonManagerService)),K(1,i.IUniverInstanceService),K(2,R.IRenderManagerService),K(3,L.Inject(c.TextSelectionManagerService)),K(4,i.ICommandService)],me);var kt=Object.defineProperty,Xt=Object.getOwnPropertyDescriptor,Vt=(o,n,e,t)=>{for(var a=t>1?void 0:t?Xt(n,e):n,s=o.length-1,r;s>=0;s--)(r=o[s])&&(a=(t?r(n,e,a):r(a))||a);return t&&a&&kt(n,e,a),a},q=(o,n)=>(e,t)=>n(e,t,o);let ge=class extends i.Disposable{constructor(n,e,t,a,s){super();y(this,"_onInputSubscription");this._docSkeletonManagerService=n,this._univerInstanceService=e,this._renderManagerService=t,this._textSelectionRenderManager=a,this._commandService=s,this._init()}dispose(){var n;super.dispose(),(n=this._onInputSubscription)==null||n.unsubscribe()}_init(){this._initialNormalInput()}_initialNormalInput(){this._onInputSubscription=this._textSelectionRenderManager.onInput$.subscribe(async n=>{var v;if(n==null)return;const e=this._univerInstanceService.getCurrentUniverDocInstance();if(!e)return;const t=e.getUnitId(),{event:a,content:s="",activeRange:r}=n,l=a,d=(v=this._docSkeletonManagerService.getCurrent())==null?void 0:v.skeleton;if(l.data==null||d==null||!d||!r)return;const{startOffset:u,segmentId:m,style:g}=r,S=s.length,f=[{startOffset:u+S,endOffset:u+S,style:g}];await this._commandService.executeCommand(H.id,{unitId:t,body:{dataStream:s},range:r,textRanges:f,segmentId:m})})}};ge=Vt([i.OnLifecycle(i.LifecycleStages.Rendered,ge),q(0,L.Inject(c.DocSkeletonManagerService)),q(1,i.IUniverInstanceService),q(2,R.IRenderManagerService),q(3,R.ITextSelectionRenderManager),q(4,i.ICommandService)],ge);var zt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Gt=(o,n,e,t)=>{for(var a=t>1?void 0:t?jt(n,e):n,s=o.length-1,r;s>=0;s--)(r=o[s])&&(a=(t?r(n,e,a):r(a))||a);return t&&a&&zt(n,e,a),a},Ht=(o,n)=>(e,t)=>n(e,t,o);const Yt="docs";c.UniverDocsPlugin=(Se=class extends i.Plugin{constructor(n={},e){super(),this._injector=e,this._initializeDependencies(e),this._initializeCommands()}_initializeCommands(){[le,de,be,Pe,Q,ee,te,ne,z,ie,ae,oe,se,ce,re,Te,Ue,H,Y,ve,Me,_e,N,tt,nt,at,W,fe,ot,Ze,We,ye,qe,Je,Qe,j,et].forEach(n=>{this._injector.get(i.ICommandService).registerCommand(n)})}_initializeDependencies(n){[[c.DocSkeletonManagerService],[c.DocViewModelManagerService],[c.DocStateChangeManagerService],[G],[R.ITextSelectionRenderManager,{useClass:R.TextSelectionRenderManager}],[c.TextSelectionManagerService],[ge],[ue],[me]].forEach(e=>n.add(e))}},y(Se,"pluginName",Yt),y(Se,"type",i.UniverInstanceType.UNIVER_DOC),Se),c.UniverDocsPlugin=Gt([Ht(1,L.Inject(L.Injector))],c.UniverDocsPlugin),c.AlignCenterCommand=Je,c.AlignJustifyCommand=et,c.AlignLeftCommand=qe,c.AlignOperationCommand=j,c.AlignRightCommand=Qe,c.BreakLineCommand=Ue,c.BulletListCommand=We,c.CoverContentCommand=nt,c.CutContentCommand=Ce,c.DOCS_COMPONENT_BACKGROUND_LAYER_INDEX=rt,c.DOCS_COMPONENT_DEFAULT_Z_INDEX=dt,c.DOCS_COMPONENT_HEADER_LAYER_INDEX=lt,c.DOCS_COMPONENT_MAIN_LAYER_INDEX=ct,c.DOCS_VIEW_KEY=J,c.DeleteCommand=Y,c.DeleteLeftCommand=be,c.DeleteRightCommand=Pe,c.IMEInputCommand=Me,c.IMEInputManagerService=G,c.InnerPasteCommand=Dt,c.InsertCommand=H,c.MoveCursorOperation=le,c.MoveSelectionOperation=de,c.NORMAL_TEXT_SELECTION_PLUGIN_NAME=ut,c.OrderListCommand=Ze,c.ReplaceContentCommand=tt,c.ResetInlineFormatTextBackgroundColorCommand=ce,c.RichTextEditingMutation=N,c.SelectAllOperation=ot,c.SetDocZoomRatioCommand=at,c.SetDocZoomRatioOperation=W,c.SetInlineFormatBoldCommand=Q,c.SetInlineFormatCommand=Te,c.SetInlineFormatFontFamilyCommand=oe,c.SetInlineFormatFontSizeCommand=ae,c.SetInlineFormatItalicCommand=ee,c.SetInlineFormatStrikethroughCommand=ne,c.SetInlineFormatSubscriptCommand=z,c.SetInlineFormatSuperscriptCommand=ie,c.SetInlineFormatTextBackgroundColorCommand=re,c.SetInlineFormatTextColorCommand=se,c.SetInlineFormatUnderlineCommand=te,c.SetTextSelectionsOperation=fe,c.UpdateCommand=ve,c.VIEWPORT_KEY=De,c.getDocObject=Ee,c.getDocObjectById=mt,c.serializeTextRange=k,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,t){typeof exports=="object"&&typeof module<"u"?t(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"],t):(c=typeof globalThis<"u"?globalThis:c||self,t(c.UniverDocs={},c.UniverCore,c.UniverEngineRender,c.rxjs,c["@wendellhu/redi"]))})(this,function(c,t,R,k,w){"use strict";var wt=Object.defineProperty;var Bt=(c,t,R)=>t in c?wt(c,t,{enumerable:!0,configurable:!0,writable:!0,value:R}):c[t]=R;var y=(c,t,R)=>(Bt(c,typeof t!="symbol"?t+"":t,R),R);var Se;var K=(a=>(a.MAIN="__Document_Render_Main__",a.BACKGROUND="__Document_Render_Background__",a))(K||{}),De=(a=>(a.VIEW_MAIN="viewMain",a.VIEW_TOP="viewTop",a.VIEW_LEFT="viewLeft",a.VIEW_LEFT_TOP="viewLeftTop",a))(De||{});const lt=0,dt=2,ut=4,mt=10,gt="normalTextSelectionPluginName";function Ee(a,i){const e=a.getCurrentUnitForType(t.UniverInstanceType.UNIVER_DOC);if(!e)return null;const n=e.getUnitId(),s=i.getRenderById(n);if(s==null)return;const{mainComponent:o,scene:r,engine:l,components:d}=s,u=o,m=d.get(K.BACKGROUND);return{document:u,docBackground:m,scene:r,engine:l}}function St(a,i){const e=i.getRenderById(a);if(e==null)return;const{mainComponent:n,scene:s,engine:o,components:r}=e,l=n,d=r.get(K.BACKGROUND);return{document:l,docBackground:d,scene:s,engine:o}}const fe={id:"doc.operation.set-selections",type:t.CommandType.OPERATION,handler:(a,i)=>!0};var ft=(a,i,e,n)=>{for(var s=i,o=a.length-1,r;o>=0;o--)(r=a[o])&&(s=r(s)||s);return s},Ae=(a,i)=>(e,n)=>i(e,n,a);function X(a){const{startOffset:i,endOffset:e,collapsed:n}=a,s={startOffset:i,endOffset:e,collapsed:n};return typeof a.isActive=="function"&&(s.isActive=a.isActive()),s}c.TextSelectionManagerService=class extends t.RxDisposable{constructor(e,n){super();y(this,"_currentSelection",null);y(this,"_textSelectionInfo",new Map);y(this,"_textSelection$",new k.BehaviorSubject(null));y(this,"textSelection$",this._textSelection$.asObservable());this._textSelectionRenderManager=e,this._commandService=n,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}getActiveTextRange(){const e=this._getTextRanges(this._currentSelection);if(e==null)return;const{textRanges:n}=e;return n.find(s=>s.isActive())}getActiveRange(){const e=this._getTextRanges(this._currentSelection);if(e==null)return;const{textRanges:n,segmentId:s,style:o}=e,r=n.find(f=>f.isActive());if(r==null)return null;const{startOffset:l,endOffset:d,collapsed:u,startNodePosition:m,endNodePosition:S,direction:g}=r;return l==null||d==null?null:{startOffset:l,endOffset:d,collapsed:u,startNodePosition:m,endNodePosition:S,direction:g,segmentId:s,style:o}}add(e,n=!0){this._currentSelection!=null&&this._addByParam({...this._currentSelection,textRanges:e,segmentId:"",isEditing:n,style:R.NORMAL_TEXT_SELECTION_PLUGIN_STYLE})}replaceTextRanges(e,n=!0){this._currentSelection!=null&&(this._textSelectionRenderManager.removeAllTextRanges(),this._textSelectionRenderManager.addTextRanges(e,n))}_syncSelectionFromRenderService(){this._textSelectionRenderManager.textSelectionInner$.pipe(k.takeUntil(this.dispose$)).subscribe(e=>{e!=null&&this._replaceTextRangesWithNoRefresh(e)})}_replaceTextRangesWithNoRefresh(e){if(this._currentSelection==null)return;const n={...this._currentSelection,...e};this._replaceByParam(n),this._textSelection$.next(n);const{unitId:s,subUnitId:o,segmentId:r,style:l,textRanges:d,isEditing:u}=n;this._commandService.executeCommand(fe.id,{unitId:s,subUnitId:o,segmentId:r,style:l,isEditing:u,ranges:d.map(X)})}_getTextRanges(e){var o;if(e==null)return;const{unitId:n,subUnitId:s=""}=e;return(o=this._textSelectionInfo.get(n))==null?void 0:o.get(s)}_refresh(e){const n=this._getTextRanges(e);this._textSelectionRenderManager.removeAllTextRanges(),n&&Array.isArray(n.textRanges)&&n.textRanges.length&&this._textSelectionRenderManager.addTextRanges(n.textRanges.map(X))}_replaceByParam(e){const{unitId:n,subUnitId:s,style:o,segmentId:r,textRanges:l,isEditing:d}=e;this._textSelectionInfo.has(n)||this._textSelectionInfo.set(n,new Map),this._textSelectionInfo.get(n).set(s,{textRanges:l,style:o,segmentId:r,isEditing:d})}_addByParam(e){const{unitId:n,subUnitId:s,textRanges:o,style:r,segmentId:l,isEditing:d}=e;this._textSelectionInfo.has(n)||this._textSelectionInfo.set(n,new Map);const u=this._textSelectionInfo.get(n);u.has(s)?u.get(s).textRanges.push(...o):u.set(s,{textRanges:o,style:r,segmentId:l,isEditing:d})}},c.TextSelectionManagerService=ft([Ae(0,R.ITextSelectionRenderManager),Ae(1,t.ICommandService)],c.TextSelectionManagerService);function he(a,i="",e=0){const{startOffset:n,endOffset:s}=a,o=[],r=n-e,l=s-e;return r>0&&o.push({t:t.TextXActionType.RETAIN,len:r,segmentId:i}),o.push({t:t.TextXActionType.DELETE,len:l-r,line:0,segmentId:i}),o}var ht=(a,i,e,n)=>{for(var s=i,o=a.length-1,r;o>=0;o--)(r=a[o])&&(s=r(s)||s);return s},pt=(a,i)=>(e,n)=>i(e,n,a);c.DocViewModelManagerService=class extends t.RxDisposable{constructor(e){super();y(this,"_docViewModelMap",new Map);y(this,"_currentDocViewModel$",new k.BehaviorSubject(null));y(this,"currentDocViewModel$",this._currentDocViewModel$.asObservable());this._univerInstanceService=e,this._initialize()}_initialize(){this._init()}dispose(){this._currentDocViewModel$.complete(),this._docViewModelMap.clear()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC).pipe(k.takeUntil(this.dispose$)).subscribe(e=>{this._create(e)}),this._univerInstanceService.getAllUnitsForType(t.UniverInstanceType.UNIVER_DOC).forEach(e=>{this._create(e)}),this._univerInstanceService.getTypeOfUnitDisposed$(t.UniverInstanceType.UNIVER_DOC).pipe(k.takeUntil(this.dispose$)).subscribe(e=>{this._docViewModelMap.delete(e.getUnitId())})}_create(e){if(e==null)return;const n=e.getUnitId();this._setCurrent(n)}getAllModel(){return this._docViewModelMap}getViewModel(e){var n;return(n=this._docViewModelMap.get(e))==null?void 0:n.docViewModel}_setCurrent(e){var s;const n=this._univerInstanceService.getUniverDocInstance(e);if(n==null)throw new Error(`Document data model with id ${e} not found when build view model.`);if(n.getBody()!=null){if(!this._docViewModelMap.has(e)){const o=this._buildDocViewModel(n);this._docViewModelMap.set(e,{unitId:e,docViewModel:o})}if(e===t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY){const o=(s=this._docViewModelMap.get(e))==null?void 0:s.docViewModel;if(o==null)return;o.reset(n)}this._currentDocViewModel$.next(this._docViewModelMap.get(e))}}_buildDocViewModel(e){return new R.DocumentViewModel(e)}},c.DocViewModelManagerService=ht([pt(0,t.IUniverInstanceService)],c.DocViewModelManagerService);var It=(a,i,e,n)=>{for(var s=i,o=a.length-1,r;o>=0;o--)(r=a[o])&&(s=r(s)||s);return s},pe=(a,i)=>(e,n)=>i(e,n,a);const vt=300;c.DocStateChangeManagerService=class extends t.RxDisposable{constructor(e,n,s){super();y(this,"_docStateChange$",new k.BehaviorSubject(null));y(this,"docStateChange$",this._docStateChange$.asObservable());y(this,"_stateCache",new Map);y(this,"_timer",null);this._undoRedoService=e,this._commandService=n,this._univerInstanceService=s,this._initialize()}setChangeState(e){const{trigger:n,noHistory:s}=e;n!=null&&(this._cacheChangeState(e),s||this._docStateChange$.next(e))}_initialize(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===t.UndoCommandId||e.id===t.RedoCommandId){const n=this._univerInstanceService.getCurrentUniverDocInstance();if(n==null)return;const s=n.getUnitId();this._pushHistory(s)}}))}_cacheChangeState(e){const{trigger:n,unitId:s,noHistory:o}=e;if(!(n===t.RedoCommandId||n===t.UndoCommandId||o)){if(this._stateCache.has(s)){const r=this._stateCache.get(s);r==null||r.push(e)}else this._stateCache.set(s,[e]);n===H.id||n===J.id?(this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{this._pushHistory(s)},vt)):this._pushHistory(s)}}_pushHistory(e){const n=this._undoRedoService,s=this._stateCache.get(e);if(!Array.isArray(s)||s.length===0)return;const o=s.length,r=s[0].commandId,l=s[0],d=s[o-1],u={unitId:e,actions:s.reduce((S,g)=>t.JSONX.compose(S,g.redoState.actions),null),textRanges:d.redoState.textRanges},m={unitId:e,actions:s.reverse().reduce((S,g)=>t.JSONX.compose(S,g.undoState.actions),null),textRanges:l.undoState.textRanges};n.pushUndoRedo({unitID:e,undoMutations:[{id:r,params:m}],redoMutations:[{id:r,params:u}]}),s.length=0}},c.DocStateChangeManagerService=It([pe(0,w.Inject(t.IUndoRedoService)),pe(1,t.ICommandService),pe(2,t.IUniverInstanceService)],c.DocStateChangeManagerService);class G{constructor(){y(this,"_previousActiveRange",null);y(this,"_undoMutationParamsCache",[]);y(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((s,o)=>t.JSONX.compose(s,o.actions),null),textRanges:[]};return{redoMutationParams:{unitId:i,actions:this._redoMutationParamsCache.reduce((s,o)=>t.JSONX.compose(s,o.actions),null),textRanges:[]},undoMutationParams:e,previousActiveRange:this._previousActiveRange}}dispose(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[],this._previousActiveRange=null}}const Ne="doc.mutation.rich-text-editing",N={id:Ne,type:t.CommandType.MUTATION,handler:(a,i)=>{var b;const{unitId:e,segmentId:n="",actions:s,textRanges:o,prevTextRanges:r,trigger:l,noHistory:d,isCompositionEnd:u,noNeedSetTextRange:m}=i,g=a.get(t.IUniverInstanceService).getUniverDocInstance(e),v=a.get(c.DocViewModelManagerService).getViewModel(e),h=a.get(c.TextSelectionManagerService),C=((b=h.getSelections())!=null?b:[]).map(X),I=a.get(c.DocStateChangeManagerService),T=a.get(G);if(g==null||v==null)throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${e}`);const M=!!g.getSnapshot().disabled;if(t.JSONX.isNoop(s)||s&&s.length===0||M)return{unitId:e,actions:[],textRanges:C};const _=t.JSONX.invertWithDoc(s,g.getSnapshot());g.apply(s);const D=g.getSelfOrHeaderFooterModel(n);v.getSelfOrHeaderFooterViewModel(n).reset(D),!m&&o&&l!=null&&queueMicrotask(()=>{h.replaceTextRanges(o)});const E={commandId:Ne,unitId:e,segmentId:n,trigger:l,noHistory:d,redoState:{actions:s,textRanges:o},undoState:{actions:_,textRanges:r!=null?r:C}};if(u){const O=T.fetchComposedUndoRedoMutationParams();if(O==null)throw new Error("historyParams is null in RichTextEditingMutation");const{undoMutationParams:A,redoMutationParams:U,previousActiveRange:V}=O;E.redoState.actions=U.actions,E.undoState.actions=A.actions,E.undoState.textRanges=[V]}return I.setChangeState(E),{unitId:e,actions:_,textRanges:C}}},Ue="doc.command.insert-text",H={id:Ue,type:t.CommandType.COMMAND,handler:async(a,i)=>{const e=a.get(t.ICommandService),{range:n,segmentId:s,body:o,unitId:r,textRanges:l}=i,{startOffset:d,collapsed:u}=n,m={id:N.id,params:{unitId:r,actions:[],textRanges:l}},S=new t.TextX,g=t.JSONX.getInstance();return u?d>0&&S.push({t:t.TextXActionType.RETAIN,len:d,segmentId:s}):S.push(...he(n,s)),S.push({t:t.TextXActionType.INSERT,body:o,len:o.dataStream.length,line:0,segmentId:s}),m.params.actions=g.editOp(S.serialize()),!!e.syncExecuteCommand(m.id,m.params)}};var L=(a=>(a[a.LEFT=0]="LEFT",a[a.RIGHT=1]="RIGHT",a))(L||{});const J={id:"doc.command.delete-text",type:t.CommandType.COMMAND,handler:async(a,i)=>{const e=a.get(t.ICommandService),{range:n,segmentId:s,unitId:o,direction:r,textRanges:l,len:d=1}=i,{startOffset:u}=n,m={id:N.id,params:{unitId:o,actions:[],textRanges:l}},S=new t.TextX,g=t.JSONX.getInstance();return u>0&&S.push({t:t.TextXActionType.RETAIN,len:r===0?u-d:u,segmentId:s}),S.push({t:t.TextXActionType.DELETE,len:d,line:0,segmentId:s}),m.params.actions=g.editOp(S.serialize()),!!e.syncExecuteCommand(m.id,m.params)}},Ie={id:"doc.command.update-text",type:t.CommandType.COMMAND,handler:async(a,i)=>{const{range:e,segmentId:n,updateBody:s,coverType:o,unitId:r,textRanges:l}=i,d=a.get(t.ICommandService),u={id:N.id,params:{unitId:r,actions:[],textRanges:l}},m=new t.TextX,S=t.JSONX.getInstance(),{startOffset:g,endOffset:f}=e;return m.push({t:t.TextXActionType.RETAIN,len:g,segmentId:n}),m.push({t:t.TextXActionType.RETAIN,body:s,len:f-g,segmentId:n,coverType:o}),u.params.actions=S.editOp(m.serialize()),!!d.syncExecuteCommand(u.id,u.params)}};function Ct(a,i){const e=[];for(let n=0,s=a.length;n<s;n++)a[n]===t.DataStreamTreeTokenType.PARAGRAPH&&e.push({startIndex:n});if(i)for(const n of e)i.bullet&&(n.bullet=t.Tools.deepClone(i.bullet)),i.paragraphStyle&&(n.paragraphStyle=t.Tools.deepClone(i.paragraphStyle));return e}const be={id:"doc.command.break-line",type:t.CommandType.COMMAND,handler:async a=>{var v,h;const i=a.get(c.TextSelectionManagerService),e=a.get(t.IUniverInstanceService),n=a.get(t.ICommandService),s=i.getActiveRange();if(s==null)return!1;const o=e.getCurrentUniverDocInstance();if(!o)return!1;const r=o.getUnitId(),{startOffset:l,segmentId:d,style:u}=s,m=[{startOffset:l+1,endOffset:l+1,style:u}],g=((h=(v=o.getBody())==null?void 0:v.paragraphs)!=null?h:[]).find(p=>p.startIndex>=l);return await n.executeCommand(H.id,{unitId:r,body:{dataStream:t.DataStreamTreeTokenType.PARAGRAPH,paragraphs:Ct(t.DataStreamTreeTokenType.PARAGRAPH,g)},range:s,textRanges:m,segmentId:d})}};var _t=(a,i,e,n)=>{for(var s=i,o=a.length-1,r;o>=0;o--)(r=a[o])&&(s=r(s)||s);return s},ve=(a,i)=>(e,n)=>i(e,n,a);c.DocSkeletonManagerService=class extends t.RxDisposable{constructor(e,n,s){super();y(this,"_currentSkeletonUnitId","");y(this,"_docSkeletonMap",new Map);y(this,"_currentSkeleton$",new k.BehaviorSubject(null));y(this,"currentSkeleton$",this._currentSkeleton$.asObservable());y(this,"_currentSkeletonBefore$",new k.BehaviorSubject(null));y(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._localeService=e,this._docViewModelManagerService=n,this._univerInstanceService=s,this._initialize()}_initialize(){this._init()}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._docSkeletonMap.clear()}_init(){this._docViewModelManagerService.currentDocViewModel$.pipe(k.takeUntil(this.dispose$)).subscribe(e=>{e!=null&&this._setCurrent(e)}),this._docViewModelManagerService.getAllModel().forEach(e=>{e!=null&&this._setCurrent(e)}),this._univerInstanceService.getTypeOfUnitDisposed$(t.UniverInstanceType.UNIVER_DOC).pipe(k.takeUntil(this.dispose$)).subscribe(e=>{var n,s;this._docSkeletonMap.delete(e.getUnitId()),this._currentSkeletonUnitId=(s=(n=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_DOC))==null?void 0:n.getUnitId())!=null?s:""})}getCurrent(){return this.getSkeletonByUnitId(this._currentSkeletonUnitId)}getAllSkeleton(){return this._docSkeletonMap}makeDirtyCurrent(e=!0){this.makeDirty(this._currentSkeletonUnitId,e)}makeDirty(e,n=!0){const s=this.getSkeletonByUnitId(e);s!=null&&(s.dirty=n)}getSkeletonByUnitId(e){return this._docSkeletonMap.get(e)}_setCurrent(e){const{unitId:n}=e;if(this._docSkeletonMap.has(n)){const s=this.getSkeletonByUnitId(n);s.skeleton.calculate(),s.dirty=!0}else{const s=this._buildSkeleton(e.docViewModel);s.calculate(),this._docSkeletonMap.set(n,{unitId:n,skeleton:s,dirty:!1})}return this._currentSkeletonUnitId=n,this._currentSkeletonBefore$.next(this.getCurrent()),this._currentSkeleton$.next(this.getCurrent()),this.getCurrent()}_buildSkeleton(e){return R.DocumentSkeleton.create(e,this._localeService)}},c.DocSkeletonManagerService=_t([ve(0,w.Inject(t.LocaleService)),ve(1,w.Inject(c.DocViewModelManagerService)),ve(2,t.IUniverInstanceService)],c.DocSkeletonManagerService);const Mt={id:"doc.command.inner-paste",type:t.CommandType.COMMAND,handler:async(a,i)=>{const{segmentId:e,body:n,textRanges:s}=i,o=a.get(t.ICommandService),r=a.get(c.TextSelectionManagerService),l=a.get(t.IUniverInstanceService),d=r.getSelections();if(!Array.isArray(d)||d.length===0)return!1;const u=l.getCurrentUniverDocInstance();if(!u)return!1;const m=u.getUnitId(),S={id:N.id,params:{unitId:m,actions:[],textRanges:s}},g=new t.MemoryCursor;g.reset();const f=new t.TextX,v=t.JSONX.getInstance();for(const p of d){const{startOffset:C,endOffset:I,collapsed:T}=p,M=C-g.cursor;T?f.push({t:t.TextXActionType.RETAIN,len:M,segmentId:e}):f.push(...he(p,e,g.cursor)),f.push({t:t.TextXActionType.INSERT,body:n,len:n.dataStream.length,line:0,segmentId:e}),g.reset(),g.moveCursor(I)}return S.params.actions=v.editOp(f.serialize()),!!o.syncExecuteCommand(S.id,S.params)}},Ce={id:"doc.command.inner-cut",type:t.CommandType.COMMAND,handler:async(a,i)=>{var p;const{segmentId:e,textRanges:n}=i,s=a.get(t.ICommandService),o=a.get(c.TextSelectionManagerService),r=a.get(t.IUniverInstanceService),l=o.getSelections();if(!Array.isArray(l)||l.length===0)return!1;const d=(p=r.getCurrentUniverDocInstance())==null?void 0:p.getUnitId();if(!d)return!1;const u=r.getUniverDocInstance(d),m=t.getDocsUpdateBody(u.getSnapshot(),e);if(m==null)return!1;const S={id:N.id,params:{unitId:d,actions:[],textRanges:n}},g=new t.MemoryCursor;g.reset();const f=new t.TextX,v=t.JSONX.getInstance();for(const C of l){const{startOffset:I,endOffset:T,collapsed:M}=C,_=I-g.cursor;M?f.push({t:t.TextXActionType.RETAIN,len:_,segmentId:e}):f.push(...Tt(C,m,e,g.cursor)),g.reset(),g.moveCursor(T)}return S.params.actions=v.editOp(f.serialize()),!!s.syncExecuteCommand(S.id,S.params)}};function Tt(a,i,e="",n=0){const{startOffset:s,endOffset:o}=a,r=[],{paragraphs:l=[]}=i,d=s-n,u=o-n,m=l==null?void 0:l.find(S=>S.startIndex-n>=d&&S.startIndex-n<=u);if(d>0&&r.push({t:t.TextXActionType.RETAIN,len:d,segmentId:e}),m&&m.startIndex-n>d){const S=m.startIndex-n;r.push({t:t.TextXActionType.DELETE,len:S-d,line:0,segmentId:e}),r.push({t:t.TextXActionType.RETAIN,len:1,segmentId:e}),u>S+1&&r.push({t:t.TextXActionType.DELETE,len:u-S-1,line:0,segmentId:e})}else r.push({t:t.TextXActionType.DELETE,len:u-d,line:0,segmentId:e});return r}const Pe={id:"doc.command.delete-left",type:t.CommandType.COMMAND,handler:async a=>{var M;const i=a.get(c.TextSelectionManagerService),e=a.get(c.DocSkeletonManagerService),n=a.get(t.IUniverInstanceService),s=a.get(t.ICommandService),o=i.getActiveRange(),r=i.getSelections(),l=(M=e.getCurrent())==null?void 0:M.skeleton;let d=!0;if(o==null||l==null||r==null)return!1;const u=n.getCurrentUniverDocInstance();if(!u)return!1;const{startOffset:m,collapsed:S,segmentId:g,style:f}=o,v=l.findNodeByCharIndex(m),h=R.hasListGlyph(v),p=R.isIndentByGlyph(v,u.getBody());let C=m;const I=l.findNodeByCharIndex(m-1);if(R.isFirstGlyph(v)&&I!==v&&(h===!0||p===!0)&&S){const _=R.getParagraphByGlyph(v,u.getBody());if(_==null)return!1;const D=_==null?void 0:_.startIndex,x={startIndex:0},E=_.paragraphStyle;if(h===!0){const O=_.paragraphStyle;if(O){x.paragraphStyle=O;const{hanging:A}=O;A&&(x.paragraphStyle.indentStart=A,x.paragraphStyle.hanging=void 0)}}else if(p===!0){const O=_.bullet;O&&(x.bullet=O),E!=null&&(x.paragraphStyle={...E},delete x.paragraphStyle.hanging,delete x.paragraphStyle.indentStart)}const b=[{startOffset:C,endOffset:C,style:f}];d=await s.executeCommand(Ie.id,{unitId:u.getUnitId(),updateBody:{dataStream:"",paragraphs:[{...x}]},range:{startOffset:D,endOffset:D+1},textRanges:b,coverType:t.UpdateDocsAttributeType.REPLACE,segmentId:g})}else if(S===!0){if(I==null)return!0;if(I.content==="\r")d=await s.executeCommand(_e.id,{direction:L.LEFT,range:o});else{C-=I.count;const _=[{startOffset:C,endOffset:C,style:f}];d=await s.executeCommand(J.id,{unitId:u.getUnitId(),range:o,segmentId:g,direction:L.LEFT,len:I.count,textRanges:_})}}else{const _=we(o,r);d=await s.executeCommand(Ce.id,{segmentId:g,textRanges:_})}return d}},ke={id:"doc.command.delete-right",type:t.CommandType.COMMAND,handler:async a=>{var v;const i=a.get(c.TextSelectionManagerService),e=a.get(c.DocSkeletonManagerService),n=a.get(t.IUniverInstanceService),s=a.get(t.ICommandService),o=i.getActiveRange(),r=i.getSelections(),l=(v=e.getCurrent())==null?void 0:v.skeleton;let d;if(o==null||l==null||r==null)return!1;const u=n.getCurrentUniverDocInstance();if(!u)return!1;const{startOffset:m,collapsed:S,segmentId:g,style:f}=o;if(m===u.getBody().dataStream.length-2&&S)return!0;if(S===!0){const h=l.findNodeByCharIndex(m);if(h.content==="\r")d=await s.executeCommand(_e.id,{direction:L.RIGHT,range:o});else{const p=[{startOffset:m,endOffset:m,style:f}];d=await s.executeCommand(J.id,{unitId:u.getUnitId(),range:o,segmentId:g,direction:L.RIGHT,textRanges:p,len:h.count})}}else{const h=we(o,r);d=await s.executeCommand(Ce.id,{segmentId:g,textRanges:h})}return d}},_e={id:"doc.command.merge-two-paragraph",type:t.CommandType.COMMAND,handler:async(a,i)=>{var E,b,O;const e=a.get(c.TextSelectionManagerService),n=a.get(t.IUniverInstanceService),s=a.get(t.ICommandService),{direction:o,range:r}=i,l=e.getActiveRange(),d=e.getSelections();if(l==null||d==null)return!1;const u=n.getCurrentUniverDocInstance();if(!u)return!1;const{startOffset:m,collapsed:S,segmentId:g,style:f}=l;if(!S)return!1;const v=o===L.LEFT?m:m+1,h=(O=(b=(E=u.getBody())==null?void 0:E.paragraphs)==null?void 0:b.find(A=>A.startIndex>=v))==null?void 0:O.startIndex,p=yt(u.getBody(),v,h),C=o===L.LEFT?m-1:m,I=u.getUnitId(),T=[{startOffset:C,endOffset:C,style:f}],M={id:N.id,params:{unitId:I,actions:[],textRanges:T,prevTextRanges:[r]}},_=new t.TextX,D=t.JSONX.getInstance();return _.push({t:t.TextXActionType.RETAIN,len:o===L.LEFT?m-1:m,segmentId:g}),p.dataStream.length&&_.push({t:t.TextXActionType.INSERT,body:p,len:p.dataStream.length,line:0,segmentId:g}),_.push({t:t.TextXActionType.RETAIN,len:1,segmentId:g}),_.push({t:t.TextXActionType.DELETE,len:h+1-v,line:0,segmentId:g}),M.params.actions=D.editOp(_.serialize()),!!s.syncExecuteCommand(M.id,M.params)}};function yt(a,i,e){const{textRuns:n}=a,s=a.dataStream.substring(i,e);if(n==null)return{dataStream:s};const o=[];for(const r of n){const{st:l,ed:d}=r;d<=i||l>=e||(l<i?o.push({...r,st:0,ed:d-i}):d>e?o.push({...r,st:l-i,ed:e-i}):o.push({...r,st:l-i,ed:d-i}))}return{dataStream:s,textRuns:o}}function we(a,i){let e=a.endOffset;for(const s of i){const{startOffset:o,endOffset:r}=s;o==null||r==null||r<=a.endOffset&&(e-=r-o)}return[{startOffset:e,endOffset:e,style:a.style}]}const Me={id:"doc.command.ime-input",type:t.CommandType.COMMAND,handler:async(a,i)=>{const{unitId:e,newText:n,oldTextLen:s,isCompositionEnd:o,isCompositionStart:r}=i,l=a.get(t.ICommandService),d=a.get(G),u=d.getActiveRange();if(u==null)return!1;const{startOffset:m,style:S,segmentId:g}=u,f=n.length,v=[{startOffset:m+f,endOffset:m+f,collapsed:!0,style:S}],h={id:N.id,params:{unitId:e,actions:[],textRanges:v}},p=new t.TextX,C=t.JSONX.getInstance();!u.collapsed&&r?p.push(...he(u,g)):p.push({t:t.TextXActionType.RETAIN,len:m,segmentId:g}),s>0&&p.push({t:t.TextXActionType.DELETE,len:s,line:0,segmentId:g}),p.push({t:t.TextXActionType.INSERT,body:{dataStream:n},len:n.length,line:0,segmentId:g}),h.params.actions=C.editOp(p.serialize()),h.params.noHistory=!o,h.params.isCompositionEnd=o;const I=l.syncExecuteCommand(h.id,h.params);return d.pushUndoRedoMutationParams(I,h.params),!!I}};function P(a,i,e,n){var o;const{segmentId:s}=(o=e.getActiveRange())!=null?o:{};return s==null?!1:n.executeCommand(Te.id,{segmentId:s,preCommandId:a,...i!=null?i:{}})}const Be="doc.command.set-inline-format-bold",Q={id:Be,type:t.CommandType.COMMAND,handler:async(a,i)=>{const e=a.get(t.ICommandService),n=a.get(c.TextSelectionManagerService);return P(Be,i,n,e)}},Le="doc.command.set-inline-format-italic",ee={id:Le,type:t.CommandType.COMMAND,handler:async(a,i)=>{const e=a.get(t.ICommandService),n=a.get(c.TextSelectionManagerService);return P(Le,i,n,e)}},Fe="doc.command.set-inline-format-underline",te={id:Fe,type:t.CommandType.COMMAND,handler:async(a,i)=>{const e=a.get(t.ICommandService),n=a.get(c.TextSelectionManagerService);return P(Fe,i,n,e)}},Xe="doc.command.set-inline-format-strikethrough",ne={id:Xe,type:t.CommandType.COMMAND,handler:async(a,i)=>{const e=a.get(t.ICommandService),n=a.get(c.TextSelectionManagerService);return P(Xe,i,n,e)}},Ve="doc.command.set-inline-format-subscript",z={id:Ve,type:t.CommandType.COMMAND,handler:async(a,i)=>{const e=a.get(t.ICommandService),n=a.get(c.TextSelectionManagerService);return P(Ve,i,n,e)}},$e="doc.command.set-inline-format-superscript",ie={id:$e,type:t.CommandType.COMMAND,handler:async(a,i)=>{const e=a.get(t.ICommandService),n=a.get(c.TextSelectionManagerService);return P($e,i,n,e)}},ze="doc.command.set-inline-format-fontsize",ae={id:ze,type:t.CommandType.COMMAND,handler:async(a,i)=>{const e=a.get(t.ICommandService),n=a.get(c.TextSelectionManagerService);return P(ze,i,n,e)}},je="doc.command.set-inline-format-font-family",se={id:je,type:t.CommandType.COMMAND,handler:async(a,i)=>{const e=a.get(t.ICommandService),n=a.get(c.TextSelectionManagerService);return P(je,i,n,e)}},Ge="doc.command.set-inline-format-text-color",oe={id:Ge,type:t.CommandType.COMMAND,handler:async(a,i)=>{const e=a.get(t.ICommandService),n=a.get(c.TextSelectionManagerService);return P(Ge,i,n,e)}},He="doc.command.set-inline-format-text-background-color",re={id:He,type:t.CommandType.COMMAND,handler:async(a,i)=>{const e=a.get(t.ICommandService),n=a.get(c.TextSelectionManagerService);return P(He,i,n,e)}},Je="doc.command.reset-inline-format-text-background-color",ce={id:Je,type:t.CommandType.COMMAND,handler:async(a,i)=>{const e=a.get(t.ICommandService),n=a.get(c.TextSelectionManagerService);return P(Je,i,n,e)}},Ye={[Q.id]:"bl",[ee.id]:"it",[te.id]:"ul",[ne.id]:"st",[ae.id]:"fs",[se.id]:"ff",[oe.id]:"cl",[re.id]:"bg",[ce.id]:"bg",[z.id]:"va",[ie.id]:"va"},Te={id:"doc.command.set-inline-format",type:t.CommandType.COMMAND,handler:async(a,i)=>{const{segmentId:e,value:n,preCommandId:s}=i,o=a.get(t.ICommandService),r=a.get(c.TextSelectionManagerService),l=a.get(t.IUniverInstanceService),d=r.getSelections();if(!Array.isArray(d)||d.length===0)return!1;const u=l.getCurrentUniverDocInstance();if(!u)return!1;const m=u.getUnitId();let S;switch(s){case Q.id:case ee.id:case te.id:case ne.id:case z.id:case ie.id:{S=Ot(u.getBody().textRuns,s,d);break}case ae.id:case se.id:{S=n;break}case oe.id:case re.id:{S={rgb:n};break}case ce.id:{S={rgb:null};break}default:throw new Error(`Unknown command: ${s} in handleInlineFormat`)}const g={id:N.id,params:{unitId:m,actions:[],textRanges:d.map(X)}},f=new t.TextX,v=t.JSONX.getInstance(),h=new t.MemoryCursor;h.reset();for(const C of d){const{startOffset:I,endOffset:T}=C,M={dataStream:"",textRuns:[{st:0,ed:T-I,ts:{[Ye[s]]:S}}]},_=I-h.cursor;_!==0&&f.push({t:t.TextXActionType.RETAIN,len:_,segmentId:e}),f.push({t:t.TextXActionType.RETAIN,body:M,len:T-I,segmentId:e}),h.reset(),h.moveCursor(T)}return g.params.actions=v.editOp(f.serialize()),!!o.syncExecuteCommand(g.id,g.params)}};function Rt(a){return a!==null&&typeof a=="object"}function Ot(a,i,e){let n=0,s=0;const o=Ye[i];for(;n!==a.length&&s!==e.length;){const{startOffset:r,endOffset:l}=e[s],{st:d,ed:u,ts:m}=a[n];if(l<=d)s++;else if(u<=r)n++;else{if(/bl|it/.test(o))return(m==null?void 0:m[o])===t.BooleanNumber.TRUE?t.BooleanNumber.FALSE:t.BooleanNumber.TRUE;if(/ul|st/.test(o))return Rt(m==null?void 0:m[o])&&(m==null?void 0:m[o]).s===t.BooleanNumber.TRUE?{s:t.BooleanNumber.FALSE}:{s:t.BooleanNumber.TRUE};if(/va/.test(o))return i===z.id?(m==null?void 0:m[o])===t.BaselineOffset.SUBSCRIPT?t.BaselineOffset.NORMAL:t.BaselineOffset.SUBSCRIPT:(m==null?void 0:m[o])===t.BaselineOffset.SUPERSCRIPT?t.BaselineOffset.NORMAL:t.BaselineOffset.SUPERSCRIPT;n++}}return/bl|it/.test(o)?t.BooleanNumber.TRUE:/ul|st/.test(o)?{s:t.BooleanNumber.TRUE}:i===z.id?t.BaselineOffset.SUBSCRIPT:t.BaselineOffset.SUPERSCRIPT}const ye={id:"doc.command.list-operation",type:t.CommandType.COMMAND,handler:(a,i)=>{var A,U,V,rt;const e=a.get(c.TextSelectionManagerService),n=a.get(t.IUniverInstanceService),s=a.get(t.ICommandService),{listType:o}=i,r=n.getCurrentUniverDocInstance();if(!r)return!1;const l=e.getActiveRange(),d=(A=e.getSelections())!=null?A:[],u=(U=r.getBody())==null?void 0:U.paragraphs,m=d.map(X);if(l==null||u==null)return!1;const S=qe(l,u),{segmentId:g}=l,f=r.getUnitId(),v=S.every($=>{var B;return((B=$.bullet)==null?void 0:B.listType)===o});let p=t.Tools.generateRandomId(6);if(S.length===1){const $=u.indexOf(S[0]),B=u[$-1],F=u[$+1];B&&B.bullet&&B.bullet.listType===o?p=B.bullet.listId:F&&F.bullet&&F.bullet.listType===o&&(p=F.bullet.listId)}const C={id:N.id,params:{unitId:f,actions:[],textRanges:m}},I=new t.MemoryCursor;I.reset();const T=new t.TextX,M=t.JSONX.getInstance(),_=(V=r.getSnapshot().lists)!=null?V:{},D={...t.PRESET_LIST_TYPE,..._},{charSpace:x,defaultTabStop:E=36,gridType:b}=r.getSnapshot().documentStyle;for(const $ of S){const{startIndex:B,paragraphStyle:F={}}=$,{indentFirstLine:Pt=0,snapToGrid:kt,indentStart:Re=0}=F,{hanging:Oe,indentStart:ct}=D[o].nestingLevel[0],xe=R.getCharSpaceApply(x,E,b,kt);T.push({t:t.TextXActionType.RETAIN,len:B-I.cursor,segmentId:g}),T.push({t:t.TextXActionType.RETAIN,len:1,body:{dataStream:"",paragraphs:[v?{paragraphStyle:{...F,hanging:void 0,indentStart:Re?Math.max(0,R.getNumberUnitValue(Re,xe)+Oe-ct):void 0},startIndex:0}:{startIndex:0,paragraphStyle:{...F,indentFirstLine:void 0,hanging:Oe,indentStart:ct-Oe+R.getNumberUnitValue(Pt,xe)+R.getNumberUnitValue(Re,xe)},bullet:{...(rt=$.bullet)!=null?rt:{nestingLevel:0,textStyle:{fs:20}},listType:o,listId:p}}]},segmentId:g,coverType:t.UpdateDocsAttributeType.REPLACE}),I.moveCursorTo(B+1)}return C.params.actions=M.editOp(T.serialize()),!!s.syncExecuteCommand(C.id,C.params)}},We={id:"doc.command.bullet-list",type:t.CommandType.COMMAND,handler:a=>a.get(t.ICommandService).syncExecuteCommand(ye.id,{listType:t.PresetListType.BULLET_LIST})},Ze={id:"doc.command.order-list",type:t.CommandType.COMMAND,handler:a=>a.get(t.ICommandService).syncExecuteCommand(ye.id,{listType:t.PresetListType.ORDER_LIST})};function qe(a,i){const{startOffset:e,endOffset:n}=a,s=[];let o=-1;for(const r of i){const{startIndex:l}=r;(e>o&&e<=l||n>o&&n<=l||l>=e&&l<=n)&&s.push(r),o=l}return s}const j={id:"doc.command.align-operation",type:t.CommandType.COMMAND,handler:(a,i)=>{var M,_;const e=a.get(c.TextSelectionManagerService),n=a.get(t.IUniverInstanceService),s=a.get(t.ICommandService),{alignType:o}=i,r=n.getCurrentUniverDocInstance();if(!r)return!1;const l=e.getActiveRange(),d=(M=e.getSelections())!=null?M:[],u=(_=r.getBody())==null?void 0:_.paragraphs,m=d.map(X);if(l==null||u==null)return!1;const S=qe(l,u),{segmentId:g}=l,f=r.getUnitId(),v=S.every(D=>{var x;return((x=D.paragraphStyle)==null?void 0:x.horizontalAlign)===o}),h={id:N.id,params:{unitId:f,actions:[],textRanges:m}},p=new t.MemoryCursor;p.reset();const C=new t.TextX,I=t.JSONX.getInstance();for(const D of S){const{startIndex:x}=D;C.push({t:t.TextXActionType.RETAIN,len:x-p.cursor,segmentId:g});const E={...D.paragraphStyle,horizontalAlign:v?t.HorizontalAlign.UNSPECIFIED:o};C.push({t:t.TextXActionType.RETAIN,len:1,body:{dataStream:"",paragraphs:[{...D,paragraphStyle:E,startIndex:0}]},segmentId:g,coverType:t.UpdateDocsAttributeType.REPLACE}),p.moveCursorTo(x+1)}return h.params.actions=I.editOp(C.serialize()),!!s.syncExecuteCommand(h.id,h.params)}},Ke={id:"doc.command.align-left",type:t.CommandType.COMMAND,handler:a=>a.get(t.ICommandService).syncExecuteCommand(j.id,{alignType:t.HorizontalAlign.LEFT})},Qe={id:"doc.command.align-center",type:t.CommandType.COMMAND,handler:a=>a.get(t.ICommandService).syncExecuteCommand(j.id,{alignType:t.HorizontalAlign.CENTER})},et={id:"doc.command.align-right",type:t.CommandType.COMMAND,handler:a=>a.get(t.ICommandService).syncExecuteCommand(j.id,{alignType:t.HorizontalAlign.RIGHT})},tt={id:"doc.command.align-justify",type:t.CommandType.COMMAND,handler:a=>a.get(t.ICommandService).syncExecuteCommand(j.id,{alignType:t.HorizontalAlign.JUSTIFIED})},nt={id:"doc.command-replace-content",type:t.CommandType.COMMAND,handler:async(a,i)=>{var f;const{unitId:e,body:n,textRanges:s,segmentId:o=""}=i,r=a.get(t.IUniverInstanceService),l=a.get(t.ICommandService),d=a.get(c.TextSelectionManagerService),u=(f=r.getUniverDocInstance(e))==null?void 0:f.getSnapshot().body,m=d.getSelections();if(u==null||!Array.isArray(m)||m.length===0)return!1;const S=at(e,o,u,n);return S.params.textRanges=s,!!l.syncExecuteCommand(S.id,S.params)}},it={id:"doc.command-cover-content",type:t.CommandType.COMMAND,handler:async(a,i)=>{var m;const{unitId:e,body:n,segmentId:s=""}=i,o=a.get(t.IUniverInstanceService),r=a.get(t.ICommandService),l=a.get(t.IUndoRedoService),d=(m=o.getUniverDocInstance(e))==null?void 0:m.getSnapshot().body;if(d==null)return!1;const u=at(e,s,d,n);return u.params.noNeedSetTextRange=!0,u.params.noHistory=!0,r.syncExecuteCommand(u.id,u.params),l.clearUndoRedo(e),!0}};function at(a,i,e,n){const s={id:N.id,params:{unitId:a,actions:[],textRanges:[]}},o=new t.TextX,r=t.JSONX.getInstance(),l=(e==null?void 0:e.dataStream.length)-2;return l>0&&o.push({t:t.TextXActionType.DELETE,len:l,line:0,segmentId:i}),n.dataStream.length>0&&o.push({t:t.TextXActionType.INSERT,body:n,len:n.dataStream.length,line:0,segmentId:i}),s.params.actions=r.editOp(o.serialize()),s}const le={id:"doc.operation.move-cursor",type:t.CommandType.OPERATION,handler:(a,i)=>!!i},de={id:"doc.operation.move-selection",type:t.CommandType.OPERATION,handler:(a,i)=>!!i},xt=(a,i)=>{const e=a.get(t.IUniverInstanceService).getUniverDocInstance(i.unitId),n=(e==null?void 0:e.zoomRatio)||1;return{...t.Tools.deepClone(i),zoomRatio:n}},Y={id:"doc.operation.set-zoom-ratio",type:t.CommandType.OPERATION,handler:(a,i)=>{const e=a.get(t.IUniverInstanceService).getUniverDocInstance(i.unitId);if(!e)return!1;const n=e.getSnapshot();return n.settings==null?n.settings={zoomRatio:i.zoomRatio}:n.settings.zoomRatio=i.zoomRatio,!0}},st={type:t.CommandType.COMMAND,id:"doc.command.set-zoom-ratio",handler:async(a,i)=>{var S,g,f;const e=a.get(t.ICommandService),n=a.get(t.IUndoRedoService),s=a.get(t.IUniverInstanceService);let o=(S=s.getCurrentUniverDocInstance())==null?void 0:S.getUnitId();if(!o)return!1;let r=1;if(i&&(o=(g=i.documentId)!=null?g:o,r=(f=i.zoomRatio)!=null?f:r),!s.getUniverDocInstance(o))return!1;const d={zoomRatio:r,unitId:o},u=xt(a,d);return e.syncExecuteCommand(Y.id,d)?(n.pushUndoRedo({unitID:o,undoMutations:[{id:Y.id,params:u}],redoMutations:[{id:Y.id,params:d}]}),!0):!1}},ot={id:"doc.operation.select-all",type:t.CommandType.COMMAND,handler:async a=>{const i=a.get(t.IUniverInstanceService),e=a.get(c.TextSelectionManagerService),n=i.getCurrentUniverDocInstance();if(!n)return!1;const s=n.getSnapshot().body;if(s==null)return!1;const o=[{startOffset:0,endOffset:s.dataStream.length-2}];return e.replaceTextRanges(o,!1),!0}};var Dt=(a,i,e,n)=>{for(var s=i,o=a.length-1,r;o>=0;o--)(r=a[o])&&(s=r(s)||s);return s},W=(a,i)=>(e,n)=>i(e,n,a);let ue=class extends t.Disposable{constructor(i,e,n,s,o){super();y(this,"_previousIMEContent","");y(this,"_isCompositionStart",!0);y(this,"_onStartSubscription");y(this,"_onUpdateSubscription");y(this,"_onEndSubscription");this._docSkeletonManagerService=i,this._univerInstanceService=e,this._textSelectionRenderManager=n,this._imeInputManagerService=s,this._commandService=o,this._initialize()}dispose(){var i,e,n;(i=this._onStartSubscription)==null||i.unsubscribe(),(e=this._onUpdateSubscription)==null||e.unsubscribe(),(n=this._onEndSubscription)==null||n.unsubscribe()}_initialize(){this._initialOnCompositionstart(),this._initialOnCompositionUpdate(),this._initialOnCompositionend()}_initialOnCompositionstart(){this._onStartSubscription=this._textSelectionRenderManager.onCompositionstart$.subscribe(i=>{if(i==null)return;this._resetIME();const{activeRange:e}=i;e!=null&&this._imeInputManagerService.setActiveRange(t.Tools.deepClone(e))})}_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 n=(u=this._docSkeletonManagerService.getCurrent())==null?void 0:u.skeleton;if(i==null||n==null)return;const s=this._univerInstanceService.getCurrentUniverDocInstance();if(!s)return;const{event:o,activeRange:r}=i;if(n==null||r==null)return;const d=o.data;d===this._previousIMEContent&&e||(await this._commandService.executeCommand(Me.id,{unitId:s.getUnitId(),newText:d,oldTextLen:this._previousIMEContent.length,isCompositionStart:this._isCompositionStart,isCompositionEnd:!e}),e?(this._isCompositionStart&&(this._isCompositionStart=!1),this._previousIMEContent=d):this._resetIME())}_resetIME(){this._previousIMEContent="",this._isCompositionStart=!0,this._imeInputManagerService.clearUndoRedoMutationParamsCache(),this._imeInputManagerService.setActiveRange(null)}};ue=Dt([t.OnLifecycle(t.LifecycleStages.Rendered,ue),W(0,w.Inject(c.DocSkeletonManagerService)),W(1,t.IUniverInstanceService),W(2,R.ITextSelectionRenderManager),W(3,w.Inject(G)),W(4,t.ICommandService)],ue);var Et=(a,i,e,n)=>{for(var s=i,o=a.length-1,r;o>=0;o--)(r=a[o])&&(s=r(s)||s);return s},Z=(a,i)=>(e,n)=>i(e,n,a);let me=class extends t.Disposable{constructor(i,e,n,s,o){super();y(this,"_onInputSubscription");this._docSkeletonManagerService=i,this._univerInstanceService=e,this._renderManagerService=n,this._textSelectionManagerService=s,this._commandService=o,this._commandExecutedListener()}dispose(){var i;super.dispose(),(i=this._onInputSubscription)==null||i.unsubscribe()}_commandExecutedListener(){const i=[le.id,de.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(!i.includes(e.id))return;const n=e.params;switch(e.id){case le.id:return this._handleMoveCursor(n.direction);case de.id:return this._handleShiftMoveSelection(n.direction);default:throw new Error("Unknown command")}}))}_handleShiftMoveSelection(i){var h,p,C;const e=this._textSelectionManagerService.getActiveRange(),n=this._textSelectionManagerService.getSelections(),s=this._univerInstanceService.getCurrentUniverDocInstance();if(!s)return;const o=(h=this._docSkeletonManagerService.getCurrent())==null?void 0:h.skeleton,r=this._getDocObject();if(e==null||o==null||r==null)return;const{startOffset:l,endOffset:d,style:u,collapsed:m,direction:S}=e;if(n.length>1){let I=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY;for(const M of n)I=Math.min(I,M.startOffset),T=Math.max(T,M.endOffset);this._textSelectionManagerService.replaceTextRanges([{startOffset:i===t.Direction.LEFT||i===t.Direction.UP?T:I,endOffset:i===t.Direction.LEFT||i===t.Direction.UP?I:T,style:u}],!1);return}const g=m||S===R.RANGE_DIRECTION.FORWARD?l:d;let f=m||S===R.RANGE_DIRECTION.FORWARD?d:l;const v=(p=s.getBody().dataStream.length)!=null?p:Number.POSITIVE_INFINITY;if(i===t.Direction.LEFT||i===t.Direction.RIGHT){const I=o.findNodeByCharIndex(f-1),T=o.findNodeByCharIndex(f);f=i===t.Direction.RIGHT?f+T.count:f-((C=I==null?void 0:I.count)!=null?C:0),f=Math.min(v-2,Math.max(0,f)),this._textSelectionManagerService.replaceTextRanges([{startOffset:g,endOffset:f,style:u}],!1)}else{const I=o.findNodeByCharIndex(f),T=r.document.getOffsetConfig(),M=this._getTopOrBottomPosition(o,I,i===t.Direction.DOWN);if(M==null){const D=i===t.Direction.UP?0:v-2;if(D===f)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:g,endOffset:D,style:u}],!1);return}const _=new R.NodePositionConvertToCursor(T,o).getRangePointData(M,M).cursorList[0];this._textSelectionManagerService.replaceTextRanges([{startOffset:g,endOffset:_.endOffset,style:u}],!1)}}_handleMoveCursor(i){var g,f,v;const e=this._textSelectionManagerService.getActiveRange(),n=this._textSelectionManagerService.getSelections(),s=this._univerInstanceService.getCurrentUniverDocInstance();if(!s)return!1;const o=(g=this._docSkeletonManagerService.getCurrent())==null?void 0:g.skeleton,r=this._getDocObject();if(e==null||o==null||r==null||n==null)return;const{startOffset:l,endOffset:d,style:u,collapsed:m}=e,S=(f=s.getBody().dataStream.length)!=null?f:Number.POSITIVE_INFINITY;if(i===t.Direction.LEFT||i===t.Direction.RIGHT){let h;if(!e.collapsed||n.length>1){let p=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY;for(const I of n)p=Math.min(p,I.startOffset),C=Math.max(C,I.endOffset);h=i===t.Direction.LEFT?p:C}else{const p=o.findNodeByCharIndex(l-1),C=o.findNodeByCharIndex(l);i===t.Direction.LEFT?h=Math.max(0,l-((v=p==null?void 0:p.count)!=null?v:0)):h=Math.min(S-2,d+C.count)}this._textSelectionManagerService.replaceTextRanges([{startOffset:h,endOffset:h,style:u}],!1)}else{const h=o.findNodeByCharIndex(l),p=o.findNodeByCharIndex(d),C=r.document.getOffsetConfig(),I=this._getTopOrBottomPosition(o,i===t.Direction.UP?h:p,i===t.Direction.DOWN);if(I==null){let M;m?M=i===t.Direction.UP?0:S-2:M=i===t.Direction.UP?l:d,this._textSelectionManagerService.replaceTextRanges([{startOffset:M,endOffset:M,style:u}],!1);return}const T=new R.NodePositionConvertToCursor(C,o).getRangePointData(I,I).cursorList[0];this._textSelectionManagerService.replaceTextRanges([{...T,style:u}],!1)}}_getTopOrBottomPosition(i,e,n){if(e==null)return;const s=this._getSpanLeftOffsetInLine(e),o=this._getNextOrPrevLine(e,n);if(o==null)return;const r=this._matchPositionByLeftOffset(i,o,s);if(r!=null)return{...r,isBack:!0}}_getSpanLeftOffsetInLine(i){const e=i.parent;if(e==null)return Number.NEGATIVE_INFINITY;const n=e.left,{left:s}=i;return n+s}_matchPositionByLeftOffset(i,e,n){const s={distance:Number.POSITIVE_INFINITY};for(const o of e.divides){const r=o.left;for(const l of o.glyphGroup){const{left:d}=l,u=r+d,m=Math.abs(n-u);m<s.distance&&(s.glyph=l,s.distance=m)}}if(s.glyph!=null)return i.findPositionByGlyph(s.glyph)}_getNextOrPrevLine(i,e){var v,h,p,C,I,T,M,_,D,x,E,b;const n=i.parent;if(n==null)return;const s=n.parent;if(s==null)return;const o=s.parent;if(o==null)return;const r=o.lines.indexOf(s);if(r===-1)return;let l;if(e===!0?l=o.lines[r+1]:l=o.lines[r-1],l!=null)return l;const d=o.parent;if(d==null)return;const u=d.columns.indexOf(o);if(u===-1)return;if(e===!0)l=(v=d.columns[u+1])==null?void 0:v.lines[0];else{const O=(p=(h=d.columns)==null?void 0:h[u-1])==null?void 0:p.lines;l=O==null?void 0:O[O.length-1]}if(l!=null)return l;const m=d.parent;if(m==null)return;const S=m.sections.indexOf(d);if(S===-1)return;if(e===!0)l=(I=(C=m.sections[S-1])==null?void 0:C.columns[0])==null?void 0:I.lines[0];else{const O=(M=(T=m.sections)==null?void 0:T[S-1])==null?void 0:M.columns,A=O==null?void 0:O[O.length-1],U=A==null?void 0:A.lines;l=U==null?void 0:U[U.length-1]}if(l!=null)return l;const g=m.parent;if(g==null)return;const f=g.pages.indexOf(m);if(f!==-1){if(e===!0)l=(x=(D=(_=g.pages[f+1])==null?void 0:_.sections[0])==null?void 0:D.columns[0])==null?void 0:x.lines[0];else{const O=(E=g.pages[f-1])==null?void 0:E.sections;if(O==null)return;const A=(b=O[O.length-1])==null?void 0:b.columns,U=A[A.length-1],V=U==null?void 0:U.lines;l=V[V.length-1]}if(l!=null)return l}}_getDocObject(){return Ee(this._univerInstanceService,this._renderManagerService)}};me=Et([t.OnLifecycle(t.LifecycleStages.Rendered,me),Z(0,w.Inject(c.DocSkeletonManagerService)),Z(1,t.IUniverInstanceService),Z(2,R.IRenderManagerService),Z(3,w.Inject(c.TextSelectionManagerService)),Z(4,t.ICommandService)],me);var At=(a,i,e,n)=>{for(var s=i,o=a.length-1,r;o>=0;o--)(r=a[o])&&(s=r(s)||s);return s},q=(a,i)=>(e,n)=>i(e,n,a);let ge=class extends t.Disposable{constructor(i,e,n,s,o){super();y(this,"_onInputSubscription");this._docSkeletonManagerService=i,this._univerInstanceService=e,this._renderManagerService=n,this._textSelectionRenderManager=s,this._commandService=o,this._init()}dispose(){var i;super.dispose(),(i=this._onInputSubscription)==null||i.unsubscribe()}_init(){this._initialNormalInput()}_initialNormalInput(){this._onInputSubscription=this._textSelectionRenderManager.onInput$.subscribe(async i=>{var v;if(i==null)return;const e=this._univerInstanceService.getCurrentUniverDocInstance();if(!e)return;const n=e.getUnitId(),{event:s,content:o="",activeRange:r}=i,l=s,d=(v=this._docSkeletonManagerService.getCurrent())==null?void 0:v.skeleton;if(l.data==null||d==null||!d||!r)return;const{startOffset:u,segmentId:m,style:S}=r,g=o.length,f=[{startOffset:u+g,endOffset:u+g,style:S}];await this._commandService.executeCommand(H.id,{unitId:n,body:{dataStream:o},range:r,textRanges:f,segmentId:m})})}};ge=At([t.OnLifecycle(t.LifecycleStages.Rendered,ge),q(0,w.Inject(c.DocSkeletonManagerService)),q(1,t.IUniverInstanceService),q(2,R.IRenderManagerService),q(3,R.ITextSelectionRenderManager),q(4,t.ICommandService)],ge);var Nt=(a,i,e,n)=>{for(var s=i,o=a.length-1,r;o>=0;o--)(r=a[o])&&(s=r(s)||s);return s},Ut=(a,i)=>(e,n)=>i(e,n,a);const bt="docs";c.UniverDocsPlugin=(Se=class extends t.Plugin{constructor(i={},e){super(),this._injector=e,this._initializeDependencies(e),this._initializeCommands()}_initializeCommands(){[le,de,Pe,ke,Q,ee,te,ne,z,ie,ae,se,oe,ce,re,Te,be,H,J,Ie,Me,_e,N,nt,it,st,Y,fe,ot,Ze,We,ye,Ke,Qe,et,j,tt].forEach(i=>{this._injector.get(t.ICommandService).registerCommand(i)})}_initializeDependencies(i){[[c.DocSkeletonManagerService],[c.DocViewModelManagerService],[c.DocStateChangeManagerService],[G],[R.ITextSelectionRenderManager,{useClass:R.TextSelectionRenderManager}],[c.TextSelectionManagerService],[ge],[ue],[me]].forEach(e=>i.add(e))}},y(Se,"pluginName",bt),y(Se,"type",t.UniverInstanceType.UNIVER_DOC),Se),c.UniverDocsPlugin=Nt([Ut(1,w.Inject(w.Injector))],c.UniverDocsPlugin),c.AlignCenterCommand=Qe,c.AlignJustifyCommand=tt,c.AlignLeftCommand=Ke,c.AlignOperationCommand=j,c.AlignRightCommand=et,c.BreakLineCommand=be,c.BulletListCommand=We,c.CoverContentCommand=it,c.CutContentCommand=Ce,c.DOCS_COMPONENT_BACKGROUND_LAYER_INDEX=lt,c.DOCS_COMPONENT_DEFAULT_Z_INDEX=mt,c.DOCS_COMPONENT_HEADER_LAYER_INDEX=ut,c.DOCS_COMPONENT_MAIN_LAYER_INDEX=dt,c.DOCS_VIEW_KEY=K,c.DeleteCommand=J,c.DeleteLeftCommand=Pe,c.DeleteRightCommand=ke,c.EditorInsertTextCommandId=Ue,c.IMEInputCommand=Me,c.IMEInputManagerService=G,c.InnerPasteCommand=Mt,c.InsertCommand=H,c.MoveCursorOperation=le,c.MoveSelectionOperation=de,c.NORMAL_TEXT_SELECTION_PLUGIN_NAME=gt,c.OrderListCommand=Ze,c.ReplaceContentCommand=nt,c.ResetInlineFormatTextBackgroundColorCommand=ce,c.RichTextEditingMutation=N,c.SelectAllOperation=ot,c.SetDocZoomRatioCommand=st,c.SetDocZoomRatioOperation=Y,c.SetInlineFormatBoldCommand=Q,c.SetInlineFormatCommand=Te,c.SetInlineFormatFontFamilyCommand=se,c.SetInlineFormatFontSizeCommand=ae,c.SetInlineFormatItalicCommand=ee,c.SetInlineFormatStrikethroughCommand=ne,c.SetInlineFormatSubscriptCommand=z,c.SetInlineFormatSuperscriptCommand=ie,c.SetInlineFormatTextBackgroundColorCommand=re,c.SetInlineFormatTextColorCommand=oe,c.SetInlineFormatUnderlineCommand=te,c.SetTextSelectionsOperation=fe,c.UpdateCommand=Ie,c.VIEWPORT_KEY=De,c.getDocObject=Ee,c.getDocObjectById=St,c.serializeTextRange=X,Object.defineProperty(c,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.13-nightly.202406041140",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "UniverSheet normal base-docs",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -52,18 +52,18 @@
|
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@wendellhu/redi": "0.15.2",
|
|
54
54
|
"rxjs": ">=7.0.0",
|
|
55
|
-
"@univerjs/core": "0.1.
|
|
56
|
-
"@univerjs/engine-render": "0.1.
|
|
55
|
+
"@univerjs/core": "0.1.13-nightly.202406041140",
|
|
56
|
+
"@univerjs/engine-render": "0.1.13-nightly.202406041140"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@wendellhu/redi": "0.15.2",
|
|
60
60
|
"rxjs": "^7.8.1",
|
|
61
61
|
"typescript": "^5.4.5",
|
|
62
|
-
"vite": "^5.2.
|
|
62
|
+
"vite": "^5.2.12",
|
|
63
63
|
"vitest": "^1.6.0",
|
|
64
|
-
"@univerjs/
|
|
65
|
-
"@univerjs/
|
|
66
|
-
"@univerjs/shared": "0.1.
|
|
64
|
+
"@univerjs/core": "0.1.13-nightly.202406041140",
|
|
65
|
+
"@univerjs/engine-render": "0.1.13-nightly.202406041140",
|
|
66
|
+
"@univerjs/shared": "0.1.13"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"test": "vitest run",
|
package/LICENSE
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ICommand, IObjectPositionH, IObjectPositionV, ISize } from '@univerjs/core';
|
|
2
|
-
|
|
3
|
-
export interface ISetDrawingSizeCommandParams {
|
|
4
|
-
documentId: string;
|
|
5
|
-
objectId: string;
|
|
6
|
-
size: ISize;
|
|
7
|
-
}
|
|
8
|
-
export declare const SetDrawingSizeCommand: ICommand;
|
|
9
|
-
export interface ISetDrawingPositionCommandParams {
|
|
10
|
-
documentId: string;
|
|
11
|
-
objectId: string;
|
|
12
|
-
positionH: IObjectPositionH;
|
|
13
|
-
positionV: IObjectPositionV;
|
|
14
|
-
}
|
|
15
|
-
export declare const SetDrawingPositionCommand: ICommand;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { IDrawing, IMutation } from '@univerjs/core';
|
|
2
|
-
import { ISeachDrawingMutation } from './set-floating-object.mutation';
|
|
3
|
-
|
|
4
|
-
export interface IInsertDrawingMutation extends ISeachDrawingMutation {
|
|
5
|
-
drawing: IDrawing;
|
|
6
|
-
}
|
|
7
|
-
export declare const InsertDrawingMutation: IMutation<IInsertDrawingMutation>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { BooleanNumber, IMutation, IObjectPositionH, IObjectPositionV, ISize, PositionedObjectLayoutType, WrapTextType } from '@univerjs/core';
|
|
2
|
-
import { IAccessor } from '@wendellhu/redi';
|
|
3
|
-
|
|
4
|
-
export interface ISeachDrawingMutation {
|
|
5
|
-
documentId: string;
|
|
6
|
-
objectId: string;
|
|
7
|
-
}
|
|
8
|
-
export interface IDrawingTransformMutation extends ISeachDrawingMutation {
|
|
9
|
-
size?: ISize;
|
|
10
|
-
positionH?: IObjectPositionH;
|
|
11
|
-
positionV?: IObjectPositionV;
|
|
12
|
-
angle?: number;
|
|
13
|
-
}
|
|
14
|
-
export declare const SetDrawingTransformMutationFactory: (accessor: IAccessor, params: IDrawingTransformMutation) => IDrawingTransformMutation;
|
|
15
|
-
export declare const SetDrawingTransformMutation: IMutation<IDrawingTransformMutation>;
|
|
16
|
-
export interface IDrawingLayoutMutation extends ISeachDrawingMutation {
|
|
17
|
-
layoutType?: PositionedObjectLayoutType;
|
|
18
|
-
behindDoc?: BooleanNumber;
|
|
19
|
-
start?: number[];
|
|
20
|
-
lineTo?: number[][];
|
|
21
|
-
wrapText?: WrapTextType;
|
|
22
|
-
distL?: number;
|
|
23
|
-
distR?: number;
|
|
24
|
-
distT?: number;
|
|
25
|
-
distB?: number;
|
|
26
|
-
}
|
|
27
|
-
export declare const SetDrawingLayoutMutation: IMutation<IDrawingLayoutMutation>;
|
|
28
|
-
export interface IDrawingInfoMutation extends ISeachDrawingMutation {
|
|
29
|
-
title?: string;
|
|
30
|
-
description?: string;
|
|
31
|
-
}
|
|
32
|
-
export declare const SetDrawingInfoMutation: IMutation<IDrawingInfoMutation>;
|