@univerjs/docs 0.5.0 → 0.5.1
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/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var se = Object.defineProperty;
|
|
2
2
|
var ie = (i, e, t) => e in i ? se(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
3
|
var u = (i, e, t) => ie(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { CommandType as N, RxDisposable as V, UniverInstanceType as b, ICommandService as B, IUniverInstanceService as p, Inject as w, LocaleService as re, isInternalEditorID as oe, JSONX as O, Disposable as J, BuildTextUtils as C, Injector as ce, Plugin as ae, IConfigService as le, createInterceptorKey as Q, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as ue, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as de, DisposableCollection as $, toDisposable as
|
|
4
|
+
import { CommandType as N, RxDisposable as V, UniverInstanceType as b, ICommandService as B, IUniverInstanceService as p, Inject as w, LocaleService as re, isInternalEditorID as oe, JSONX as O, Disposable as J, BuildTextUtils as C, Injector as ce, Plugin as ae, IConfigService as le, createInterceptorKey as Q, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as ue, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as de, DisposableCollection as $, toDisposable as _e, remove as ge, composeInterceptors as he } from "@univerjs/core";
|
|
5
5
|
import { NORMAL_TEXT_SELECTION_PLUGIN_STYLE as fe, DocumentSkeleton as Se, DocumentViewModel as pe, IRenderManagerService as Ie } from "@univerjs/engine-render";
|
|
6
6
|
import { Subject as me, BehaviorSubject as x, takeUntil as Z } from "rxjs";
|
|
7
7
|
const j = {
|
|
@@ -126,14 +126,14 @@ let m = class extends V {
|
|
|
126
126
|
...t
|
|
127
127
|
};
|
|
128
128
|
this._replaceByParam(n), this._textSelection$.next(n);
|
|
129
|
-
const { unitId: s, subUnitId: r, segmentId: o, style: c, textRanges: a, rectRanges: l, isEditing: d } = n,
|
|
129
|
+
const { unitId: s, subUnitId: r, segmentId: o, style: c, textRanges: a, rectRanges: l, isEditing: d } = n, g = [...a, ...l].filter((_) => _.startOffset != null && _.endOffset != null).sort((_, h) => _.startOffset > h.startOffset ? 1 : _.startOffset < h.startOffset ? -1 : 0);
|
|
130
130
|
this._commandService.executeCommand(j.id, {
|
|
131
131
|
unitId: s,
|
|
132
132
|
subUnitId: r,
|
|
133
133
|
segmentId: o,
|
|
134
134
|
style: c,
|
|
135
135
|
isEditing: d,
|
|
136
|
-
ranges:
|
|
136
|
+
ranges: g
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
dispose() {
|
|
@@ -258,8 +258,8 @@ const K = "doc.mutation.rich-text-editing", M = {
|
|
|
258
258
|
noHistory: a,
|
|
259
259
|
isCompositionEnd: l,
|
|
260
260
|
noNeedSetTextRange: d,
|
|
261
|
-
debounce:
|
|
262
|
-
isEditing:
|
|
261
|
+
debounce: g,
|
|
262
|
+
isEditing: _ = !0,
|
|
263
263
|
isSync: h,
|
|
264
264
|
syncer: f
|
|
265
265
|
} = e, v = i.get(p), I = i.get(Ie), R = i.get(ee), S = v.getUniverDocInstance(t), L = (z = I.getRenderById(t)) == null ? void 0 : z.with(D).getViewModel();
|
|
@@ -274,7 +274,7 @@ const K = "doc.mutation.rich-text-editing", M = {
|
|
|
274
274
|
};
|
|
275
275
|
const G = O.invertWithDoc(s, S.getSnapshot());
|
|
276
276
|
S.apply(s), L.reset(S), !d && r && c != null && queueMicrotask(() => {
|
|
277
|
-
X.replaceDocRanges(r, { unitId: t, subUnitId: t },
|
|
277
|
+
X.replaceDocRanges(r, { unitId: t, subUnitId: t }, _, e.options);
|
|
278
278
|
});
|
|
279
279
|
const ne = {
|
|
280
280
|
commandId: K,
|
|
@@ -282,7 +282,7 @@ const K = "doc.mutation.rich-text-editing", M = {
|
|
|
282
282
|
segmentId: n,
|
|
283
283
|
trigger: c,
|
|
284
284
|
noHistory: a,
|
|
285
|
-
debounce:
|
|
285
|
+
debounce: g,
|
|
286
286
|
redoState: {
|
|
287
287
|
actions: s,
|
|
288
288
|
textRanges: r
|
|
@@ -430,7 +430,7 @@ let q = class extends J {
|
|
|
430
430
|
var c, a;
|
|
431
431
|
return ((c = o.priority) != null ? c : 0) - ((a = r.priority) != null ? a : 0);
|
|
432
432
|
})
|
|
433
|
-
), this.disposeWithMe(
|
|
433
|
+
), this.disposeWithMe(_e(() => ge(this._interceptorsByName.get(n), t)));
|
|
434
434
|
}
|
|
435
435
|
fetchThroughInterceptors(e) {
|
|
436
436
|
const t = e, n = this._interceptorsByName.get(t);
|
|
@@ -498,20 +498,20 @@ function Ye(i, e, t) {
|
|
|
498
498
|
}
|
|
499
499
|
function Ke(i, e) {
|
|
500
500
|
var S;
|
|
501
|
-
const { rangeId: t, rangeType: n, wholeEntity: s, properties: r, unitId: o, selections: c } = e, a = i.get(m), l = i.get(p), d = c != null ? c : a.getTextRanges({ unitId: o, subUnitId: o }),
|
|
501
|
+
const { rangeId: t, rangeType: n, wholeEntity: s, properties: r, unitId: o, selections: c } = e, a = i.get(m), l = i.get(p), d = c != null ? c : a.getTextRanges({ unitId: o, subUnitId: o }), g = (S = d == null ? void 0 : d[0]) == null ? void 0 : S.segmentId;
|
|
502
502
|
if (!(d != null && d.length))
|
|
503
503
|
return !1;
|
|
504
|
-
const
|
|
505
|
-
if (!
|
|
504
|
+
const _ = l.getUnit(o, b.UNIVER_DOC);
|
|
505
|
+
if (!_)
|
|
506
506
|
return !1;
|
|
507
|
-
const h =
|
|
507
|
+
const h = _.getSelfOrHeaderFooterModel(g).getBody();
|
|
508
508
|
if (!h)
|
|
509
509
|
return !1;
|
|
510
510
|
const f = C.customRange.add({
|
|
511
511
|
ranges: d,
|
|
512
512
|
rangeId: t,
|
|
513
513
|
rangeType: n,
|
|
514
|
-
segmentId:
|
|
514
|
+
segmentId: g,
|
|
515
515
|
wholeEntity: s,
|
|
516
516
|
properties: r,
|
|
517
517
|
body: h
|
|
@@ -524,10 +524,10 @@ function Ke(i, e) {
|
|
|
524
524
|
unitId: o,
|
|
525
525
|
actions: [],
|
|
526
526
|
textRanges: f.selections,
|
|
527
|
-
segmentId:
|
|
527
|
+
segmentId: g
|
|
528
528
|
},
|
|
529
529
|
textX: f
|
|
530
|
-
}, R = A(
|
|
530
|
+
}, R = A(_, g);
|
|
531
531
|
return I.params.actions = v.editOp(f.serialize(), R), I;
|
|
532
532
|
}
|
|
533
533
|
function He(i, e) {
|
|
@@ -569,14 +569,14 @@ function ke(i, e) {
|
|
|
569
569
|
endOffset: l.startOffset + n.dataStream.length,
|
|
570
570
|
collapsed: !0,
|
|
571
571
|
segmentId: o
|
|
572
|
-
}],
|
|
572
|
+
}], g = C.selection.replace({
|
|
573
573
|
selection: l,
|
|
574
574
|
body: n,
|
|
575
575
|
doc: r
|
|
576
576
|
});
|
|
577
|
-
if (!
|
|
577
|
+
if (!g)
|
|
578
578
|
return !1;
|
|
579
|
-
const
|
|
579
|
+
const _ = {
|
|
580
580
|
id: M.id,
|
|
581
581
|
params: {
|
|
582
582
|
unitId: t,
|
|
@@ -585,9 +585,9 @@ function ke(i, e) {
|
|
|
585
585
|
debounce: !0,
|
|
586
586
|
segmentId: o
|
|
587
587
|
},
|
|
588
|
-
textX:
|
|
588
|
+
textX: g
|
|
589
589
|
}, h = O.getInstance();
|
|
590
|
-
return
|
|
590
|
+
return _.params.actions = h.editOp(g.serialize()), _;
|
|
591
591
|
}
|
|
592
592
|
export {
|
|
593
593
|
E as DOC_INTERCEPTOR_POINT,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export declare const
|
|
16
|
+
export declare const DOCS_PLUGIN_CONFIG_KEY = "docs.config";
|
|
17
17
|
export declare const configSymbol: unique symbol;
|
|
18
18
|
export interface IUniverDocsConfig {
|
|
19
19
|
hasScroll?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DocumentDataModel, Nullable, IUniverInstanceService, LocaleService, RxDisposable } from '@univerjs/core';
|
|
2
|
+
import { IRenderContext, IRenderModule, DocumentSkeleton, DocumentViewModel } from '@univerjs/engine-render';
|
|
3
3
|
/**
|
|
4
4
|
* This service is for document build and manage doc skeletons. It also manages
|
|
5
5
|
* DocumentViewModels.
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(l,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","rxjs"],r):(l=typeof globalThis<"u"?globalThis:l||self,r(l.UniverDocs={},l.UniverCore,l.UniverEngineRender,l.rxjs))})(this,function(l,r,v,m){"use strict";var Se=Object.defineProperty;var Ie=(l,r,v)=>r in l?Se(l,r,{enumerable:!0,configurable:!0,writable:!0,value:v}):l[r]=v;var g=(l,r,v)=>Ie(l,typeof r!="symbol"?r+"":r,v);var w;const C={id:"doc.operation.set-selections",type:r.CommandType.OPERATION,handler:()=>!0};var L=Object.defineProperty,G=Object.getOwnPropertyDescriptor,k=(c,i,e,t)=>{for(var n=t>1?void 0:t?G(i,e):i,s=c.length-1,o;s>=0;s--)(o=c[s])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&L(i,e,n),n},E=(c,i)=>(e,t)=>i(e,t,c);l.DocSelectionManagerService=class extends r.RxDisposable{constructor(e,t){super();g(this,"_currentSelection",null);g(this,"_textSelectionInfo",new Map);g(this,"_textSelection$",new m.Subject);g(this,"textSelection$",this._textSelection$.asObservable());g(this,"_refreshSelection$",new m.BehaviorSubject(null));g(this,"refreshSelection$",this._refreshSelection$.asObservable());this._commandService=e,this._univerInstanceService=t,this._listenCurrentUnit()}_listenCurrentUnit(){this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_DOC).pipe(m.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const t=e.getUnitId();this._setCurrentSelectionNotRefresh({unitId:t,subUnitId:t})})}__getCurrentSelection(){return this._currentSelection}getSelectionInfo(e=this._currentSelection){return this._getTextRanges(e)}refreshSelection(e=this._currentSelection){e!=null&&this._refresh(e)}__TEST_ONLY_setCurrentSelection(e){this._currentSelection=e,this._refresh(e)}getTextRanges(e=this._currentSelection){var t;return(t=this._getTextRanges(e))==null?void 0:t.textRanges}getRectRanges(e=this._currentSelection){var t;return(t=this._getTextRanges(e))==null?void 0:t.rectRanges}getDocRanges(e=this._currentSelection){var o,a;const t=(o=this.getTextRanges(e))!=null?o:[],n=(a=this.getRectRanges(e))!=null?a:[];return[...t,...n].filter(u=>u.startOffset!=null&&u.endOffset!=null).sort((u,d)=>u.startOffset>d.startOffset?1:u.startOffset<d.startOffset?-1:0)}getActiveTextRange(){const e=this._getTextRanges(this._currentSelection);if(e==null)return;const{textRanges:t}=e;return t.find(n=>n.isActive)}getActiveRectRange(){const e=this._getTextRanges(this._currentSelection);if(e==null)return;const{rectRanges:t}=e;return t.find(n=>n.isActive)}__TEST_ONLY_add(e,t=!0){this._currentSelection!=null&&this._addByParam({...this._currentSelection,textRanges:e,rectRanges:[],segmentId:"",segmentPage:-1,isEditing:t,style:v.NORMAL_TEXT_SELECTION_PLUGIN_STYLE})}replaceTextRanges(e,t=!0,n){return this.replaceDocRanges(e,this._currentSelection,t,n)}replaceDocRanges(e,t=this._currentSelection,n=!0,s){if(t==null)return;const{unitId:o,subUnitId:a}=t;this._refreshSelection$.next({unitId:o,subUnitId:a,docRanges:e,isEditing:n,options:s})}__replaceTextRangesWithNoRefresh(e,t){if(this._currentSelection==null)return;const n={...e,...t};this._replaceByParam(n),this._textSelection$.next(n);const{unitId:s,subUnitId:o,segmentId:a,style:u,textRanges:d,rectRanges:_,isEditing:h}=n,I=[...d,..._].filter(f=>f.startOffset!=null&&f.endOffset!=null).sort((f,S)=>f.startOffset>S.startOffset?1:f.startOffset<S.startOffset?-1:0);this._commandService.executeCommand(C.id,{unitId:s,subUnitId:o,segmentId:a,style:u,isEditing:h,ranges:I})}dispose(){this._textSelection$.complete()}_setCurrentSelectionNotRefresh(e){this._currentSelection=e}_getTextRanges(e){var s;if(e==null)return;const{unitId:t,subUnitId:n=""}=e;return(s=this._textSelectionInfo.get(t))==null?void 0:s.get(n)}_refresh(e){const t=this._getTextRanges(e);if(t==null)return;const{textRanges:n,rectRanges:s}=t,o=[...n,...s],{unitId:a,subUnitId:u}=e;this._refreshSelection$.next({unitId:a,subUnitId:u,docRanges:o,isEditing:!1})}_replaceByParam(e){const{unitId:t,subUnitId:n,...s}=e;this._textSelectionInfo.has(t)||this._textSelectionInfo.set(t,new Map),this._textSelectionInfo.get(t).set(n,{...s})}_addByParam(e){const{unitId:t,subUnitId:n,...s}=e;this._textSelectionInfo.has(t)||this._textSelectionInfo.set(t,new Map);const o=this._textSelectionInfo.get(t);o.has(n)?o.get(n).textRanges.push(...e.textRanges):o.set(n,{...s})}},l.DocSelectionManagerService=k([E(0,r.ICommandService),E(1,r.IUniverInstanceService)],l.DocSelectionManagerService);var z=Object.defineProperty,W=Object.getOwnPropertyDescriptor,J=(c,i,e,t)=>{for(var n=t>1?void 0:t?W(i,e):i,s=c.length-1,o;s>=0;s--)(o=c[s])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&z(i,e,n),n},N=(c,i)=>(e,t)=>i(e,t,c);l.DocSkeletonManagerService=class extends r.RxDisposable{constructor(e,t,n){super();g(this,"_skeleton");g(this,"_docViewModel");g(this,"_currentSkeleton$",new m.BehaviorSubject(null));g(this,"currentSkeleton$",this._currentSkeleton$.asObservable());g(this,"_currentSkeletonBefore$",new m.BehaviorSubject(null));g(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());g(this,"_currentViewModel$",new m.BehaviorSubject(null));g(this,"currentViewModel$",this._currentViewModel$.asObservable());this._context=e,this._localeService=t,this._univerInstanceService=n,this._init(),this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_DOC).pipe(m.takeUntil(this.dispose$)).subscribe(s=>{s&&s.getUnitId()===this._context.unitId&&this._update(s)})}dispose(){super.dispose(),this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete()}getSkeleton(){return this._skeleton}getViewModel(){return this._docViewModel}_init(){const e=this._context.unit;this._update(e)}_update(e){const t=this._context.unitId;if(e.getBody()==null)return;this._docViewModel&&r.isInternalEditorID(t)?(this._docViewModel.reset(e),this._context.unit=e):this._docViewModel||(this._docViewModel=this._buildDocViewModel(e)),this._skeleton||(this._skeleton=this._buildSkeleton(this._docViewModel));const n=this._skeleton;n.calculate(),this._currentSkeletonBefore$.next(n),this._currentSkeleton$.next(n),this._currentViewModel$.next(this._docViewModel)}_buildSkeleton(e){return v.DocumentSkeleton.create(e,this._localeService)}_buildDocViewModel(e){return new v.DocumentViewModel(e)}},l.DocSkeletonManagerService=J([N(1,r.Inject(r.LocaleService)),N(2,r.IUniverInstanceService)],l.DocSkeletonManagerService);class U extends r.RxDisposable{constructor(){super();g(this,"_docStateChangeParams$",new m.BehaviorSubject(null));g(this,"docStateChangeParams$",this._docStateChangeParams$.asObservable())}emitStateChangeInfo(e){this._docStateChangeParams$.next(e)}dispose(){super.dispose(),this._docStateChangeParams$.complete()}}const $="doc.mutation.rich-text-editing",O={id:$,type:r.CommandType.MUTATION,handler:(c,i)=>{var X,F;const{unitId:e,segmentId:t="",actions:n,textRanges:s,prevTextRanges:o,trigger:a,noHistory:u,isCompositionEnd:d,noNeedSetTextRange:_,debounce:h,isEditing:I=!0,isSync:f,syncer:S}=i,D=c.get(r.IUniverInstanceService),R=c.get(v.IRenderManagerService),M=c.get(U),p=D.getUniverDocInstance(e),j=(X=R.getRenderById(e))==null?void 0:X.with(l.DocSkeletonManagerService).getViewModel();if(p==null||j==null)throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${e}`);const V=c.get(l.DocSelectionManagerService),P=(F=V.getDocRanges())!=null?F:[],he=!!p.getSnapshot().disabled;if(r.JSONX.isNoop(n)||n&&n.length===0||he)return{unitId:e,actions:[],textRanges:P};const A=r.JSONX.invertWithDoc(n,p.getSnapshot());p.apply(n),j.reset(p),!_&&s&&a!=null&&queueMicrotask(()=>{V.replaceDocRanges(s,{unitId:e,subUnitId:e},I,i.options)});const fe={commandId:$,unitId:e,segmentId:t,trigger:a,noHistory:u,debounce:h,redoState:{actions:n,textRanges:s},undoState:{actions:A,textRanges:o!=null?o:P},isCompositionEnd:d,isSync:f,syncer:S};return M.emitStateChangeInfo(fe),{unitId:e,actions:A,textRanges:P}}},Y={id:"doc.mutation.rename-doc",type:r.CommandType.MUTATION,handler:(c,i)=>{const t=c.get(r.IUniverInstanceService).getUnit(i.unitId,r.UniverInstanceType.UNIVER_DOC);return t?(t.setName(i.name),!0):!1}},K="docs.config",q={};var H=Object.defineProperty,Q=Object.getOwnPropertyDescriptor,Z=(c,i,e,t)=>{for(var n=t>1?void 0:t?Q(i,e):i,s=c.length-1,o;s>=0;s--)(o=c[s])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&H(i,e,n),n},b=(c,i)=>(e,t)=>i(e,t,c);let T=class extends r.Disposable{constructor(c,i,e){super(),this._commandService=c,this._textSelectionManagerService=i,this._univerInstanceService=e,this._initSelectionChange()}_transformCustomRange(c,i){var o;const{startOffset:e,endOffset:t,collapsed:n}=i,s=(o=c.getCustomRanges())==null?void 0:o.filter(a=>!a.wholeEntity||e<=a.startIndex&&t>a.endIndex?!1:n?a.startIndex<e&&a.endIndex>=t:r.BuildTextUtils.range.isIntersects(e,t-1,a.startIndex,a.endIndex));if(s!=null&&s.length){let a=e,u=t;return s.forEach(d=>{a=Math.min(d.startIndex,a),u=Math.max(d.endIndex+1,u)}),{...i,startOffset:a,endOffset:u,collapsed:a===u}}return i}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(c=>{if(c.id===C.id){const i=c.params,{unitId:e,ranges:t,isEditing:n}=i,s=this._univerInstanceService.getUnit(e);if(!s)return;const o=t.map(a=>this._transformCustomRange(s,a));o.some((a,u)=>t[u]!==a)&&this._textSelectionManagerService.replaceTextRanges(o,n)}}))}};T=Z([b(0,r.ICommandService),b(1,r.Inject(l.DocSelectionManagerService)),b(2,r.IUniverInstanceService)],T);var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,ne=(c,i,e,t)=>{for(var n=t>1?void 0:t?te(i,e):i,s=c.length-1,o;s>=0;s--)(o=c[s])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&ee(i,e,n),n},B=(c,i)=>(e,t)=>i(e,t,c);const ie="DOCS_PLUGIN";l.UniverDocsPlugin=(w=class extends r.Plugin{constructor(i=q,e,t){super(),this._config=i,this._injector=e,this._configService=t;const{...n}=this._config;this._configService.setConfig(K,n)}onStarting(){this._initializeDependencies(),this._initializeCommands()}_initializeCommands(){[O,Y,C].forEach(i=>{this._injector.get(r.ICommandService).registerCommand(i)})}_initializeDependencies(){[[l.DocSelectionManagerService],[U],[T]].forEach(i=>this._injector.add(i))}onReady(){this._injector.get(T)}},g(w,"pluginName",ie),w),l.UniverDocsPlugin=ne([B(1,r.Inject(r.Injector)),B(2,r.IConfigService)],l.UniverDocsPlugin);const se=r.createInterceptorKey("CUSTOM_RANGE"),re=r.createInterceptorKey("CUSTOM_DECORATION"),x={CUSTOM_RANGE:se,CUSTOM_DECORATION:re};var oe=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,ae=(c,i,e,t)=>{for(var n=t>1?void 0:t?ce(i,e):i,s=c.length-1,o;s>=0;s--)(o=c[s])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&oe(i,e,n),n},le=(c,i)=>(e,t)=>i(e,t,c);l.DocInterceptorService=class extends r.Disposable{constructor(e,t){super();g(this,"_interceptorsByName",new Map);this._context=e,this._docSkeletonManagerService=t;const n=this._docSkeletonManagerService.getViewModel(),s=n.getDataModel().getUnitId();if(s===r.DOCS_NORMAL_EDITOR_UNIT_ID_KEY||s===r.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;this.disposeWithMe(this.interceptDocumentViewModel(n)),this.disposeWithMe(this.intercept(x.CUSTOM_RANGE,{priority:-1,handler:(a,u,d)=>d(a)}));let o=new r.DisposableCollection;n.segmentViewModels$.subscribe(a=>{o.dispose(),o=new r.DisposableCollection,a.forEach(u=>{o.add(this.interceptDocumentViewModel(u))})}),this.disposeWithMe(o)}intercept(e,t){const n=e;this._interceptorsByName.has(n)||this._interceptorsByName.set(n,[]);const s=this._interceptorsByName.get(n);return s.push(t),this._interceptorsByName.set(n,s.sort((o,a)=>{var u,d;return((u=a.priority)!=null?u:0)-((d=o.priority)!=null?d:0)})),this.disposeWithMe(r.toDisposable(()=>r.remove(this._interceptorsByName.get(n),t)))}fetchThroughInterceptors(e){const t=e,n=this._interceptorsByName.get(t);return r.composeInterceptors(n||[])}interceptDocumentViewModel(e){const t=new r.DisposableCollection;return t.add(e.registerCustomRangeInterceptor({getCustomRange:n=>{var s;return this.fetchThroughInterceptors(x.CUSTOM_RANGE)(e.getCustomRangeRaw(n),{index:n,unitId:e.getDataModel().getUnitId(),customRanges:(s=e.getDataModel().getCustomRanges())!=null?s:[]})},getCustomDecoration:n=>{var s;return this.fetchThroughInterceptors(x.CUSTOM_DECORATION)(e.getCustomDecorationRaw(n),{index:n,unitId:e.getDataModel().getUnitId(),customDecorations:(s=e.getDataModel().getCustomDecorations())!=null?s:[]})}})),t}},l.DocInterceptorService=ae([le(1,r.Inject(l.DocSkeletonManagerService))],l.DocInterceptorService);function y(c,i=""){if(!i)return["body"];const{headers:e,footers:t}=c.getSnapshot();if(e==null&&t==null)throw new Error("Document data model must have headers or footers when update by segment id");if((e==null?void 0:e[i])!=null)return["headers",i,"body"];if((t==null?void 0:t[i])!=null)return["footers",i,"body"];throw new Error("Segment id not found in headers or footers")}function ue(c,i,e){const{unitId:t,segmentId:n}=i,o=c.get(r.IUniverInstanceService).getUnit(t);if(!o)return!1;const a={id:O.id,params:{unitId:i.unitId,actions:[],textRanges:void 0}},u=r.JSONX.getInstance(),d=r.BuildTextUtils.customRange.add({...i,body:e});if(!d)return!1;const _=y(o,n);return a.params.actions=u.editOp(d.serialize(),_),a}function de(c,i){var p;const{rangeId:e,rangeType:t,wholeEntity:n,properties:s,unitId:o,selections:a}=i,u=c.get(l.DocSelectionManagerService),d=c.get(r.IUniverInstanceService),_=a!=null?a:u.getTextRanges({unitId:o,subUnitId:o}),h=(p=_==null?void 0:_[0])==null?void 0:p.segmentId;if(!(_!=null&&_.length))return!1;const I=d.getUnit(o,r.UniverInstanceType.UNIVER_DOC);if(!I)return!1;const f=I.getSelfOrHeaderFooterModel(h).getBody();if(!f)return!1;const S=r.BuildTextUtils.customRange.add({ranges:_,rangeId:e,rangeType:t,segmentId:h,wholeEntity:n,properties:s,body:f});if(!S)return!1;const D=r.JSONX.getInstance(),R={id:O.id,params:{unitId:o,actions:[],textRanges:S.selections,segmentId:h},textX:S},M=y(I,h);return R.params.actions=D.editOp(S.serialize(),M),R}function ge(c,i){const{unitId:e,segmentId:t,insert:n}=i,o=c.get(r.IUniverInstanceService).getUnit(e);if(!o)return!1;const a={id:O.id,params:{unitId:i.unitId,actions:[],textRanges:void 0,segmentId:t}},u=r.JSONX.getInstance(),d=r.BuildTextUtils.customRange.delete(c,{documentDataModel:o,rangeId:i.rangeId,insert:n,segmentId:t});if(!d)return!1;const _=y(o,t);return a.params.actions=u.editOp(d.serialize(),_),a.params.textRanges=d.selections,a}function _e(c,i){var S,D,R,M;const{unitId:e,body:t,doc:n}=i;let s=n;if(s||(s=c.get(r.IUniverInstanceService).getUnit(e)),!s)return!1;const o=(S=i.selection)==null?void 0:S.segmentId,a=(D=s.getSelfOrHeaderFooterModel(o))==null?void 0:D.getBody();if(!a)return!1;const u=c.get(l.DocSelectionManagerService),d=(R=i.selection)!=null?R:u.getActiveTextRange();if(!d||!a)return!1;const _=(M=i.textRanges)!=null?M:[{startOffset:d.startOffset+t.dataStream.length,endOffset:d.startOffset+t.dataStream.length,collapsed:!0,segmentId:o}],h=r.BuildTextUtils.selection.replace({selection:d,body:t,doc:s});if(!h)return!1;const I={id:O.id,params:{unitId:e,actions:[],textRanges:_,debounce:!0,segmentId:o},textX:h},f=r.JSONX.getInstance();return I.params.actions=f.editOp(h.serialize()),I}l.DOC_INTERCEPTOR_POINT=x,l.DocStateEmitService=U,l.RichTextEditingMutation=O,l.SetTextSelectionsOperation=C,l.addCustomRangeBySelectionFactory=de,l.addCustomRangeFactory=ue,l.deleteCustomRangeFactory=ge,l.replaceSelectionFactory=_e,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(l,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","rxjs"],r):(l=typeof globalThis<"u"?globalThis:l||self,r(l.UniverDocs={},l.UniverCore,l.UniverEngineRender,l.rxjs))})(this,function(l,r,v,m){"use strict";var Se=Object.defineProperty;var Ie=(l,r,v)=>r in l?Se(l,r,{enumerable:!0,configurable:!0,writable:!0,value:v}):l[r]=v;var g=(l,r,v)=>Ie(l,typeof r!="symbol"?r+"":r,v);var w;const M={id:"doc.operation.set-selections",type:r.CommandType.OPERATION,handler:()=>!0};var L=Object.defineProperty,G=Object.getOwnPropertyDescriptor,k=(c,i,e,t)=>{for(var n=t>1?void 0:t?G(i,e):i,s=c.length-1,o;s>=0;s--)(o=c[s])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&L(i,e,n),n},E=(c,i)=>(e,t)=>i(e,t,c);l.DocSelectionManagerService=class extends r.RxDisposable{constructor(e,t){super();g(this,"_currentSelection",null);g(this,"_textSelectionInfo",new Map);g(this,"_textSelection$",new m.Subject);g(this,"textSelection$",this._textSelection$.asObservable());g(this,"_refreshSelection$",new m.BehaviorSubject(null));g(this,"refreshSelection$",this._refreshSelection$.asObservable());this._commandService=e,this._univerInstanceService=t,this._listenCurrentUnit()}_listenCurrentUnit(){this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_DOC).pipe(m.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const t=e.getUnitId();this._setCurrentSelectionNotRefresh({unitId:t,subUnitId:t})})}__getCurrentSelection(){return this._currentSelection}getSelectionInfo(e=this._currentSelection){return this._getTextRanges(e)}refreshSelection(e=this._currentSelection){e!=null&&this._refresh(e)}__TEST_ONLY_setCurrentSelection(e){this._currentSelection=e,this._refresh(e)}getTextRanges(e=this._currentSelection){var t;return(t=this._getTextRanges(e))==null?void 0:t.textRanges}getRectRanges(e=this._currentSelection){var t;return(t=this._getTextRanges(e))==null?void 0:t.rectRanges}getDocRanges(e=this._currentSelection){var o,a;const t=(o=this.getTextRanges(e))!=null?o:[],n=(a=this.getRectRanges(e))!=null?a:[];return[...t,...n].filter(u=>u.startOffset!=null&&u.endOffset!=null).sort((u,d)=>u.startOffset>d.startOffset?1:u.startOffset<d.startOffset?-1:0)}getActiveTextRange(){const e=this._getTextRanges(this._currentSelection);if(e==null)return;const{textRanges:t}=e;return t.find(n=>n.isActive)}getActiveRectRange(){const e=this._getTextRanges(this._currentSelection);if(e==null)return;const{rectRanges:t}=e;return t.find(n=>n.isActive)}__TEST_ONLY_add(e,t=!0){this._currentSelection!=null&&this._addByParam({...this._currentSelection,textRanges:e,rectRanges:[],segmentId:"",segmentPage:-1,isEditing:t,style:v.NORMAL_TEXT_SELECTION_PLUGIN_STYLE})}replaceTextRanges(e,t=!0,n){return this.replaceDocRanges(e,this._currentSelection,t,n)}replaceDocRanges(e,t=this._currentSelection,n=!0,s){if(t==null)return;const{unitId:o,subUnitId:a}=t;this._refreshSelection$.next({unitId:o,subUnitId:a,docRanges:e,isEditing:n,options:s})}__replaceTextRangesWithNoRefresh(e,t){if(this._currentSelection==null)return;const n={...e,...t};this._replaceByParam(n),this._textSelection$.next(n);const{unitId:s,subUnitId:o,segmentId:a,style:u,textRanges:d,rectRanges:_,isEditing:h}=n,I=[...d,..._].filter(f=>f.startOffset!=null&&f.endOffset!=null).sort((f,S)=>f.startOffset>S.startOffset?1:f.startOffset<S.startOffset?-1:0);this._commandService.executeCommand(M.id,{unitId:s,subUnitId:o,segmentId:a,style:u,isEditing:h,ranges:I})}dispose(){this._textSelection$.complete()}_setCurrentSelectionNotRefresh(e){this._currentSelection=e}_getTextRanges(e){var s;if(e==null)return;const{unitId:t,subUnitId:n=""}=e;return(s=this._textSelectionInfo.get(t))==null?void 0:s.get(n)}_refresh(e){const t=this._getTextRanges(e);if(t==null)return;const{textRanges:n,rectRanges:s}=t,o=[...n,...s],{unitId:a,subUnitId:u}=e;this._refreshSelection$.next({unitId:a,subUnitId:u,docRanges:o,isEditing:!1})}_replaceByParam(e){const{unitId:t,subUnitId:n,...s}=e;this._textSelectionInfo.has(t)||this._textSelectionInfo.set(t,new Map),this._textSelectionInfo.get(t).set(n,{...s})}_addByParam(e){const{unitId:t,subUnitId:n,...s}=e;this._textSelectionInfo.has(t)||this._textSelectionInfo.set(t,new Map);const o=this._textSelectionInfo.get(t);o.has(n)?o.get(n).textRanges.push(...e.textRanges):o.set(n,{...s})}},l.DocSelectionManagerService=k([E(0,r.ICommandService),E(1,r.IUniverInstanceService)],l.DocSelectionManagerService);var z=Object.defineProperty,W=Object.getOwnPropertyDescriptor,J=(c,i,e,t)=>{for(var n=t>1?void 0:t?W(i,e):i,s=c.length-1,o;s>=0;s--)(o=c[s])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&z(i,e,n),n},N=(c,i)=>(e,t)=>i(e,t,c);l.DocSkeletonManagerService=class extends r.RxDisposable{constructor(e,t,n){super();g(this,"_skeleton");g(this,"_docViewModel");g(this,"_currentSkeleton$",new m.BehaviorSubject(null));g(this,"currentSkeleton$",this._currentSkeleton$.asObservable());g(this,"_currentSkeletonBefore$",new m.BehaviorSubject(null));g(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());g(this,"_currentViewModel$",new m.BehaviorSubject(null));g(this,"currentViewModel$",this._currentViewModel$.asObservable());this._context=e,this._localeService=t,this._univerInstanceService=n,this._init(),this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_DOC).pipe(m.takeUntil(this.dispose$)).subscribe(s=>{s&&s.getUnitId()===this._context.unitId&&this._update(s)})}dispose(){super.dispose(),this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete()}getSkeleton(){return this._skeleton}getViewModel(){return this._docViewModel}_init(){const e=this._context.unit;this._update(e)}_update(e){const t=this._context.unitId;if(e.getBody()==null)return;this._docViewModel&&r.isInternalEditorID(t)?(this._docViewModel.reset(e),this._context.unit=e):this._docViewModel||(this._docViewModel=this._buildDocViewModel(e)),this._skeleton||(this._skeleton=this._buildSkeleton(this._docViewModel));const n=this._skeleton;n.calculate(),this._currentSkeletonBefore$.next(n),this._currentSkeleton$.next(n),this._currentViewModel$.next(this._docViewModel)}_buildSkeleton(e){return v.DocumentSkeleton.create(e,this._localeService)}_buildDocViewModel(e){return new v.DocumentViewModel(e)}},l.DocSkeletonManagerService=J([N(1,r.Inject(r.LocaleService)),N(2,r.IUniverInstanceService)],l.DocSkeletonManagerService);class U extends r.RxDisposable{constructor(){super();g(this,"_docStateChangeParams$",new m.BehaviorSubject(null));g(this,"docStateChangeParams$",this._docStateChangeParams$.asObservable())}emitStateChangeInfo(e){this._docStateChangeParams$.next(e)}dispose(){super.dispose(),this._docStateChangeParams$.complete()}}const $="doc.mutation.rich-text-editing",O={id:$,type:r.CommandType.MUTATION,handler:(c,i)=>{var X,F;const{unitId:e,segmentId:t="",actions:n,textRanges:s,prevTextRanges:o,trigger:a,noHistory:u,isCompositionEnd:d,noNeedSetTextRange:_,debounce:h,isEditing:I=!0,isSync:f,syncer:S}=i,D=c.get(r.IUniverInstanceService),R=c.get(v.IRenderManagerService),C=c.get(U),p=D.getUniverDocInstance(e),j=(X=R.getRenderById(e))==null?void 0:X.with(l.DocSkeletonManagerService).getViewModel();if(p==null||j==null)throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${e}`);const V=c.get(l.DocSelectionManagerService),P=(F=V.getDocRanges())!=null?F:[],he=!!p.getSnapshot().disabled;if(r.JSONX.isNoop(n)||n&&n.length===0||he)return{unitId:e,actions:[],textRanges:P};const A=r.JSONX.invertWithDoc(n,p.getSnapshot());p.apply(n),j.reset(p),!_&&s&&a!=null&&queueMicrotask(()=>{V.replaceDocRanges(s,{unitId:e,subUnitId:e},I,i.options)});const fe={commandId:$,unitId:e,segmentId:t,trigger:a,noHistory:u,debounce:h,redoState:{actions:n,textRanges:s},undoState:{actions:A,textRanges:o!=null?o:P},isCompositionEnd:d,isSync:f,syncer:S};return C.emitStateChangeInfo(fe),{unitId:e,actions:A,textRanges:P}}},Y={id:"doc.mutation.rename-doc",type:r.CommandType.MUTATION,handler:(c,i)=>{const t=c.get(r.IUniverInstanceService).getUnit(i.unitId,r.UniverInstanceType.UNIVER_DOC);return t?(t.setName(i.name),!0):!1}},K="docs.config",q={};var H=Object.defineProperty,Q=Object.getOwnPropertyDescriptor,Z=(c,i,e,t)=>{for(var n=t>1?void 0:t?Q(i,e):i,s=c.length-1,o;s>=0;s--)(o=c[s])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&H(i,e,n),n},b=(c,i)=>(e,t)=>i(e,t,c);let T=class extends r.Disposable{constructor(c,i,e){super(),this._commandService=c,this._textSelectionManagerService=i,this._univerInstanceService=e,this._initSelectionChange()}_transformCustomRange(c,i){var o;const{startOffset:e,endOffset:t,collapsed:n}=i,s=(o=c.getCustomRanges())==null?void 0:o.filter(a=>!a.wholeEntity||e<=a.startIndex&&t>a.endIndex?!1:n?a.startIndex<e&&a.endIndex>=t:r.BuildTextUtils.range.isIntersects(e,t-1,a.startIndex,a.endIndex));if(s!=null&&s.length){let a=e,u=t;return s.forEach(d=>{a=Math.min(d.startIndex,a),u=Math.max(d.endIndex+1,u)}),{...i,startOffset:a,endOffset:u,collapsed:a===u}}return i}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(c=>{if(c.id===M.id){const i=c.params,{unitId:e,ranges:t,isEditing:n}=i,s=this._univerInstanceService.getUnit(e);if(!s)return;const o=t.map(a=>this._transformCustomRange(s,a));o.some((a,u)=>t[u]!==a)&&this._textSelectionManagerService.replaceTextRanges(o,n)}}))}};T=Z([b(0,r.ICommandService),b(1,r.Inject(l.DocSelectionManagerService)),b(2,r.IUniverInstanceService)],T);var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,ne=(c,i,e,t)=>{for(var n=t>1?void 0:t?te(i,e):i,s=c.length-1,o;s>=0;s--)(o=c[s])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&ee(i,e,n),n},B=(c,i)=>(e,t)=>i(e,t,c);const ie="DOCS_PLUGIN";l.UniverDocsPlugin=(w=class extends r.Plugin{constructor(i=q,e,t){super(),this._config=i,this._injector=e,this._configService=t;const{...n}=this._config;this._configService.setConfig(K,n)}onStarting(){this._initializeDependencies(),this._initializeCommands()}_initializeCommands(){[O,Y,M].forEach(i=>{this._injector.get(r.ICommandService).registerCommand(i)})}_initializeDependencies(){[[l.DocSelectionManagerService],[U],[T]].forEach(i=>this._injector.add(i))}onReady(){this._injector.get(T)}},g(w,"pluginName",ie),w),l.UniverDocsPlugin=ne([B(1,r.Inject(r.Injector)),B(2,r.IConfigService)],l.UniverDocsPlugin);const se=r.createInterceptorKey("CUSTOM_RANGE"),re=r.createInterceptorKey("CUSTOM_DECORATION"),x={CUSTOM_RANGE:se,CUSTOM_DECORATION:re};var oe=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,ae=(c,i,e,t)=>{for(var n=t>1?void 0:t?ce(i,e):i,s=c.length-1,o;s>=0;s--)(o=c[s])&&(n=(t?o(i,e,n):o(n))||n);return t&&n&&oe(i,e,n),n},le=(c,i)=>(e,t)=>i(e,t,c);l.DocInterceptorService=class extends r.Disposable{constructor(e,t){super();g(this,"_interceptorsByName",new Map);this._context=e,this._docSkeletonManagerService=t;const n=this._docSkeletonManagerService.getViewModel(),s=n.getDataModel().getUnitId();if(s===r.DOCS_NORMAL_EDITOR_UNIT_ID_KEY||s===r.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;this.disposeWithMe(this.interceptDocumentViewModel(n)),this.disposeWithMe(this.intercept(x.CUSTOM_RANGE,{priority:-1,handler:(a,u,d)=>d(a)}));let o=new r.DisposableCollection;n.segmentViewModels$.subscribe(a=>{o.dispose(),o=new r.DisposableCollection,a.forEach(u=>{o.add(this.interceptDocumentViewModel(u))})}),this.disposeWithMe(o)}intercept(e,t){const n=e;this._interceptorsByName.has(n)||this._interceptorsByName.set(n,[]);const s=this._interceptorsByName.get(n);return s.push(t),this._interceptorsByName.set(n,s.sort((o,a)=>{var u,d;return((u=a.priority)!=null?u:0)-((d=o.priority)!=null?d:0)})),this.disposeWithMe(r.toDisposable(()=>r.remove(this._interceptorsByName.get(n),t)))}fetchThroughInterceptors(e){const t=e,n=this._interceptorsByName.get(t);return r.composeInterceptors(n||[])}interceptDocumentViewModel(e){const t=new r.DisposableCollection;return t.add(e.registerCustomRangeInterceptor({getCustomRange:n=>{var s;return this.fetchThroughInterceptors(x.CUSTOM_RANGE)(e.getCustomRangeRaw(n),{index:n,unitId:e.getDataModel().getUnitId(),customRanges:(s=e.getDataModel().getCustomRanges())!=null?s:[]})},getCustomDecoration:n=>{var s;return this.fetchThroughInterceptors(x.CUSTOM_DECORATION)(e.getCustomDecorationRaw(n),{index:n,unitId:e.getDataModel().getUnitId(),customDecorations:(s=e.getDataModel().getCustomDecorations())!=null?s:[]})}})),t}},l.DocInterceptorService=ae([le(1,r.Inject(l.DocSkeletonManagerService))],l.DocInterceptorService);function y(c,i=""){if(!i)return["body"];const{headers:e,footers:t}=c.getSnapshot();if(e==null&&t==null)throw new Error("Document data model must have headers or footers when update by segment id");if((e==null?void 0:e[i])!=null)return["headers",i,"body"];if((t==null?void 0:t[i])!=null)return["footers",i,"body"];throw new Error("Segment id not found in headers or footers")}function ue(c,i,e){const{unitId:t,segmentId:n}=i,o=c.get(r.IUniverInstanceService).getUnit(t);if(!o)return!1;const a={id:O.id,params:{unitId:i.unitId,actions:[],textRanges:void 0}},u=r.JSONX.getInstance(),d=r.BuildTextUtils.customRange.add({...i,body:e});if(!d)return!1;const _=y(o,n);return a.params.actions=u.editOp(d.serialize(),_),a}function de(c,i){var p;const{rangeId:e,rangeType:t,wholeEntity:n,properties:s,unitId:o,selections:a}=i,u=c.get(l.DocSelectionManagerService),d=c.get(r.IUniverInstanceService),_=a!=null?a:u.getTextRanges({unitId:o,subUnitId:o}),h=(p=_==null?void 0:_[0])==null?void 0:p.segmentId;if(!(_!=null&&_.length))return!1;const I=d.getUnit(o,r.UniverInstanceType.UNIVER_DOC);if(!I)return!1;const f=I.getSelfOrHeaderFooterModel(h).getBody();if(!f)return!1;const S=r.BuildTextUtils.customRange.add({ranges:_,rangeId:e,rangeType:t,segmentId:h,wholeEntity:n,properties:s,body:f});if(!S)return!1;const D=r.JSONX.getInstance(),R={id:O.id,params:{unitId:o,actions:[],textRanges:S.selections,segmentId:h},textX:S},C=y(I,h);return R.params.actions=D.editOp(S.serialize(),C),R}function ge(c,i){const{unitId:e,segmentId:t,insert:n}=i,o=c.get(r.IUniverInstanceService).getUnit(e);if(!o)return!1;const a={id:O.id,params:{unitId:i.unitId,actions:[],textRanges:void 0,segmentId:t}},u=r.JSONX.getInstance(),d=r.BuildTextUtils.customRange.delete(c,{documentDataModel:o,rangeId:i.rangeId,insert:n,segmentId:t});if(!d)return!1;const _=y(o,t);return a.params.actions=u.editOp(d.serialize(),_),a.params.textRanges=d.selections,a}function _e(c,i){var S,D,R,C;const{unitId:e,body:t,doc:n}=i;let s=n;if(s||(s=c.get(r.IUniverInstanceService).getUnit(e)),!s)return!1;const o=(S=i.selection)==null?void 0:S.segmentId,a=(D=s.getSelfOrHeaderFooterModel(o))==null?void 0:D.getBody();if(!a)return!1;const u=c.get(l.DocSelectionManagerService),d=(R=i.selection)!=null?R:u.getActiveTextRange();if(!d||!a)return!1;const _=(C=i.textRanges)!=null?C:[{startOffset:d.startOffset+t.dataStream.length,endOffset:d.startOffset+t.dataStream.length,collapsed:!0,segmentId:o}],h=r.BuildTextUtils.selection.replace({selection:d,body:t,doc:s});if(!h)return!1;const I={id:O.id,params:{unitId:e,actions:[],textRanges:_,debounce:!0,segmentId:o},textX:h},f=r.JSONX.getInstance();return I.params.actions=f.editOp(h.serialize()),I}l.DOC_INTERCEPTOR_POINT=x,l.DocStateEmitService=U,l.RichTextEditingMutation=O,l.SetTextSelectionsOperation=M,l.addCustomRangeBySelectionFactory=de,l.addCustomRangeFactory=ue,l.deleteCustomRangeFactory=ge,l.replaceSelectionFactory=_e,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "UniverSheet normal base-docs",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
"rxjs": ">=7.0.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@univerjs/core": "0.5.
|
|
52
|
-
"@univerjs/engine-render": "0.5.
|
|
51
|
+
"@univerjs/core": "0.5.1",
|
|
52
|
+
"@univerjs/engine-render": "0.5.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"rxjs": "^7.8.1",
|
|
56
|
-
"typescript": "^5.
|
|
57
|
-
"vite": "^
|
|
58
|
-
"vitest": "^2.1.
|
|
59
|
-
"@univerjs-infra/shared": "0.5.
|
|
56
|
+
"typescript": "^5.7.2",
|
|
57
|
+
"vite": "^6.0.1",
|
|
58
|
+
"vitest": "^2.1.6",
|
|
59
|
+
"@univerjs-infra/shared": "0.5.1"
|
|
60
60
|
},
|
|
61
61
|
"space": {
|
|
62
62
|
".": {
|