@univerjs/docs 0.5.3 → 0.5.4-experimental.20250114-7c09c35
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 +29 -29
- package/lib/umd/index.js +1 -1
- package/package.json +5 -5
- package/LICENSE +0 -176
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var k=Object.defineProperty;var z=(o,i,e)=>i in o?k(o,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[i]=e;var d=(o,i,e)=>z(o,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),D=require("@univerjs/engine-render"),v=require("rxjs"),C={id:"doc.operation.set-selections",type:c.CommandType.OPERATION,handler:()=>!0};var W=Object.defineProperty,J=Object.getOwnPropertyDescriptor,Y=(o,i,e,t)=>{for(var n=t>1?void 0:t?J(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&W(i,e,n),n},j=(o,i)=>(e,t)=>i(e,t,o);exports.DocSelectionManagerService=class extends c.RxDisposable{constructor(e,t){super();d(this,"_currentSelection",null);d(this,"_textSelectionInfo",new Map);d(this,"_textSelection$",new v.Subject);d(this,"textSelection$",this._textSelection$.asObservable());d(this,"_refreshSelection$",new v.BehaviorSubject(null));d(this,"refreshSelection$",this._refreshSelection$.asObservable());this._commandService=e,this._univerInstanceService=t,this._listenCurrentUnit()}_listenCurrentUnit(){this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_DOC).pipe(v.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 r,a;const t=(r=this.getTextRanges(e))!=null?r:[],n=(a=this.getRectRanges(e))!=null?a:[];return[...t,...n].filter(l=>l.startOffset!=null&&l.endOffset!=null).sort((l,u)=>l.startOffset>u.startOffset?1:l.startOffset<u.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:D.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:r,subUnitId:a}=t;this._refreshSelection$.next({unitId:r,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:r,segmentId:a,style:l,textRanges:u,rectRanges:g,isEditing:_}=n,f=[...u,...g].filter(h=>h.startOffset!=null&&h.endOffset!=null).sort((h,S)=>h.startOffset>S.startOffset?1:h.startOffset<S.startOffset?-1:0);this._commandService.executeCommand(C.id,{unitId:s,subUnitId:r,segmentId:a,style:l,isEditing:_,ranges:f})}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,r=[...n,...s],{unitId:a,subUnitId:l}=e;this._refreshSelection$.next({unitId:a,subUnitId:l,docRanges:r,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 r=this._textSelectionInfo.get(t);r.has(n)?r.get(n).textRanges.push(...e.textRanges):r.set(n,{...s})}};exports.DocSelectionManagerService=Y([j(0,c.ICommandService),j(1,c.IUniverInstanceService)],exports.DocSelectionManagerService);var K=Object.defineProperty,q=Object.getOwnPropertyDescriptor,H=(o,i,e,t)=>{for(var n=t>1?void 0:t?q(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&K(i,e,n),n},V=(o,i)=>(e,t)=>i(e,t,o);exports.DocSkeletonManagerService=class extends c.RxDisposable{constructor(e,t,n){super();d(this,"_skeleton");d(this,"_docViewModel");d(this,"_currentSkeleton$",new v.BehaviorSubject(null));d(this,"currentSkeleton$",this._currentSkeleton$.asObservable());d(this,"_currentSkeletonBefore$",new v.BehaviorSubject(null));d(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());d(this,"_currentViewModel$",new v.BehaviorSubject(null));d(this,"currentViewModel$",this._currentViewModel$.asObservable());this._context=e,this._localeService=t,this._univerInstanceService=n,this._init(),this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_DOC).pipe(v.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&&c.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 D.DocumentSkeleton.create(e,this._localeService)}_buildDocViewModel(e){return new D.DocumentViewModel(e)}};exports.DocSkeletonManagerService=H([V(1,c.Inject(c.LocaleService)),V(2,c.IUniverInstanceService)],exports.DocSkeletonManagerService);class y extends c.RxDisposable{constructor(){super();d(this,"_docStateChangeParams$",new v.BehaviorSubject(null));d(this,"docStateChangeParams$",this._docStateChangeParams$.asObservable())}emitStateChangeInfo(e){this._docStateChangeParams$.next(e)}dispose(){super.dispose(),this._docStateChangeParams$.complete()}}const A="doc.mutation.rich-text-editing",O={id:A,type:c.CommandType.MUTATION,handler:(o,i)=>{var $,B;const{unitId:e,segmentId:t="",actions:n,textRanges:s,prevTextRanges:r,trigger:a,noHistory:l,isCompositionEnd:u,noNeedSetTextRange:g,debounce:_,isEditing:f=!0,isSync:h,syncer:S}=i,m=o.get(c.IUniverInstanceService),p=o.get(D.IRenderManagerService),R=o.get(y),I=m.getUniverDocInstance(e),P=($=p.getRenderById(e))==null?void 0:$.with(exports.DocSkeletonManagerService).getViewModel();if(I==null||P==null)throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${e}`);const E=o.get(exports.DocSelectionManagerService),T=(B=E.getDocRanges())!=null?B:[],L=!!I.getSnapshot().disabled;if(c.JSONX.isNoop(n)||n&&n.length===0||L)return{unitId:e,actions:[],textRanges:T};const N=c.JSONX.invertWithDoc(n,I.getSnapshot());I.apply(n),P.reset(I),!g&&s&&a!=null&&queueMicrotask(()=>{E.replaceDocRanges(s,{unitId:e,subUnitId:e},f,i.options)});const G={commandId:A,unitId:e,segmentId:t,trigger:a,noHistory:l,debounce:_,redoState:{actions:n,textRanges:s},undoState:{actions:N,textRanges:r!=null?r:T},isCompositionEnd:u,isSync:h,syncer:S};return R.emitStateChangeInfo(G),{unitId:e,actions:N,textRanges:T}}},Q={id:"doc.mutation.rename-doc",type:c.CommandType.MUTATION,handler:(o,i)=>{const t=o.get(c.IUniverInstanceService).getUnit(i.unitId,c.UniverInstanceType.UNIVER_DOC);return t?(t.setName(i.name),!0):!1}},Z="docs.config",X={};var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,ne=(o,i,e,t)=>{for(var n=t>1?void 0:t?te(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&ee(i,e,n),n},b=(o,i)=>(e,t)=>i(e,t,o);let M=class extends c.Disposable{constructor(o,i,e){super(),this._commandService=o,this._textSelectionManagerService=i,this._univerInstanceService=e,this._initSelectionChange()}_transformCustomRange(o,i){var r;const{startOffset:e,endOffset:t,collapsed:n}=i,s=(r=o.getCustomRanges())==null?void 0:r.filter(a=>!a.wholeEntity||e<=a.startIndex&&t>a.endIndex?!1:n?a.startIndex<e&&a.endIndex>=t:c.BuildTextUtils.range.isIntersects(e,t-1,a.startIndex,a.endIndex));if(s!=null&&s.length){let a=e,l=t;return s.forEach(u=>{a=Math.min(u.startIndex,a),l=Math.max(u.endIndex+1,l)}),{...i,startOffset:a,endOffset:l,collapsed:a===l}}return i}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(o=>{if(o.id===C.id){const i=o.params,{unitId:e,ranges:t,isEditing:n}=i,s=this._univerInstanceService.getUnit(e);if(!s)return;const r=t.map(a=>this._transformCustomRange(s,a));r.some((a,l)=>t[l]!==a)&&this._textSelectionManagerService.replaceTextRanges(r,n)}}))}};M=ne([b(0,c.ICommandService),b(1,c.Inject(exports.DocSelectionManagerService)),b(2,c.IUniverInstanceService)],M);var ie=Object.defineProperty,se=Object.getOwnPropertyDescriptor,re=(o,i,e,t)=>{for(var n=t>1?void 0:t?se(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&ie(i,e,n),n},F=(o,i)=>(e,t)=>i(e,t,o);const oe="DOCS_PLUGIN";var U;exports.UniverDocsPlugin=(U=class extends c.Plugin{constructor(i=X,e,t){super(),this._config=i,this._injector=e,this._configService=t;const{...n}=c.merge({},X,this._config);this._configService.setConfig(Z,n)}onStarting(){this._initializeDependencies(),this._initializeCommands()}_initializeCommands(){[O,Q,C].forEach(i=>{this._injector.get(c.ICommandService).registerCommand(i)})}_initializeDependencies(){[[exports.DocSelectionManagerService],[y],[M]].forEach(i=>this._injector.add(i))}onReady(){this._injector.get(M)}},d(U,"pluginName",oe),U);exports.UniverDocsPlugin=re([F(1,c.Inject(c.Injector)),F(2,c.IConfigService)],exports.UniverDocsPlugin);const ce=c.createInterceptorKey("CUSTOM_RANGE"),ae=c.createInterceptorKey("CUSTOM_DECORATION"),x={CUSTOM_RANGE:ce,CUSTOM_DECORATION:ae};var le=Object.defineProperty,ue=Object.getOwnPropertyDescriptor,de=(o,i,e,t)=>{for(var n=t>1?void 0:t?ue(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&le(i,e,n),n},ge=(o,i)=>(e,t)=>i(e,t,o);exports.DocInterceptorService=class extends c.Disposable{constructor(e,t){super();d(this,"_interceptorsByName",new Map);this._context=e,this._docSkeletonManagerService=t;const n=this._docSkeletonManagerService.getViewModel(),s=n.getDataModel().getUnitId();if(s===c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY||s===c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;this.disposeWithMe(this.interceptDocumentViewModel(n)),this.disposeWithMe(this.intercept(x.CUSTOM_RANGE,{priority:-1,handler:(a,l,u)=>u(a)}));let r=new c.DisposableCollection;n.segmentViewModels$.subscribe(a=>{r.dispose(),r=new c.DisposableCollection,a.forEach(l=>{r.add(this.interceptDocumentViewModel(l))})}),this.disposeWithMe(r)}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((r,a)=>{var l,u;return((l=a.priority)!=null?l:0)-((u=r.priority)!=null?u:0)})),this.disposeWithMe(c.toDisposable(()=>c.remove(this._interceptorsByName.get(n),t)))}fetchThroughInterceptors(e){const t=e,n=this._interceptorsByName.get(t);return c.composeInterceptors(n||[])}interceptDocumentViewModel(e){const t=new c.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}};exports.DocInterceptorService=de([ge(1,c.Inject(exports.DocSkeletonManagerService))],exports.DocInterceptorService);function w(o,i=""){if(!i)return["body"];const{headers:e,footers:t}=o.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 _e(o,i,e){const{unitId:t,segmentId:n}=i,r=o.get(c.IUniverInstanceService).getUnit(t);if(!r)return!1;const a={id:O.id,params:{unitId:i.unitId,actions:[],textRanges:void 0}},l=c.JSONX.getInstance(),u=c.BuildTextUtils.customRange.add({...i,body:e});if(!u)return!1;const g=w(r,n);return a.params.actions=l.editOp(u.serialize(),g),a}function he(o,i){var I;const{rangeId:e,rangeType:t,wholeEntity:n,properties:s,unitId:r,selections:a}=i,l=o.get(exports.DocSelectionManagerService),u=o.get(c.IUniverInstanceService),g=a!=null?a:l.getTextRanges({unitId:r,subUnitId:r}),_=(I=g==null?void 0:g[0])==null?void 0:I.segmentId;if(!(g!=null&&g.length))return!1;const f=u.getUnit(r,c.UniverInstanceType.UNIVER_DOC);if(!f)return!1;const h=f.getSelfOrHeaderFooterModel(_).getBody();if(!h)return!1;const S=c.BuildTextUtils.customRange.add({ranges:g,rangeId:e,rangeType:t,segmentId:_,wholeEntity:n,properties:s,body:h});if(!S)return!1;const m=c.JSONX.getInstance(),p={id:O.id,params:{unitId:r,actions:[],textRanges:S.selections,segmentId:_},textX:S},R=w(f,_);return p.params.actions=m.editOp(S.serialize(),R),p}function Se(o,i){const{unitId:e,segmentId:t,insert:n}=i,r=o.get(c.IUniverInstanceService).getUnit(e);if(!r)return!1;const a={id:O.id,params:{unitId:i.unitId,actions:[],textRanges:void 0,segmentId:t}},l=c.JSONX.getInstance(),u=c.BuildTextUtils.customRange.delete(o,{documentDataModel:r,rangeId:i.rangeId,insert:n,segmentId:t});if(!u)return!1;const g=w(r,t);return a.params.actions=l.editOp(u.serialize(),g),a.params.textRanges=u.selections,a}function fe(o,i){var S,m,p,R;const{unitId:e,body:t,doc:n}=i;let s=n;if(s||(s=o.get(c.IUniverInstanceService).getUnit(e)),!s)return!1;const r=(S=i.selection)==null?void 0:S.segmentId,a=(m=s.getSelfOrHeaderFooterModel(r))==null?void 0:m.getBody();if(!a)return!1;const l=o.get(exports.DocSelectionManagerService),u=(p=i.selection)!=null?p:l.getActiveTextRange();if(!u||!a)return!1;const g=(R=i.textRanges)!=null?R:[{startOffset:u.startOffset+t.dataStream.length,endOffset:u.startOffset+t.dataStream.length,collapsed:!0,segmentId:r}],_=c.BuildTextUtils.selection.replace({selection:u,body:t,doc:s});if(!_)return!1;const f={id:O.id,params:{unitId:e,actions:[],textRanges:g,debounce:!0,segmentId:r},textX:_},h=c.JSONX.getInstance();return f.params.actions=h.editOp(_.serialize()),f}exports.DOC_INTERCEPTOR_POINT=x;exports.DocStateEmitService=y;exports.RichTextEditingMutation=O;exports.SetTextSelectionsOperation=C;exports.addCustomRangeBySelectionFactory=he;exports.addCustomRangeFactory=_e;exports.deleteCustomRangeFactory=Se;exports.replaceSelectionFactory=fe;
|
|
1
|
+
"use strict";var k=Object.defineProperty;var z=(o,i,e)=>i in o?k(o,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[i]=e;var d=(o,i,e)=>z(o,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),D=require("@univerjs/engine-render"),p=require("rxjs"),C={id:"doc.operation.set-selections",type:c.CommandType.OPERATION,handler:()=>!0};var W=Object.defineProperty,J=Object.getOwnPropertyDescriptor,Y=(o,i,e,t)=>{for(var n=t>1?void 0:t?J(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&W(i,e,n),n},j=(o,i)=>(e,t)=>i(e,t,o);exports.DocSelectionManagerService=class extends c.RxDisposable{constructor(e,t){super();d(this,"_currentSelection",null);d(this,"_textSelectionInfo",new Map);d(this,"_textSelection$",new p.Subject);d(this,"textSelection$",this._textSelection$.asObservable());d(this,"_refreshSelection$",new p.BehaviorSubject(null));d(this,"refreshSelection$",this._refreshSelection$.asObservable());this._commandService=e,this._univerInstanceService=t,this._listenCurrentUnit()}_listenCurrentUnit(){this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_DOC).pipe(p.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 r,a;const t=(r=this.getTextRanges(e))!=null?r:[],n=(a=this.getRectRanges(e))!=null?a:[];return[...t,...n].filter(l=>l.startOffset!=null&&l.endOffset!=null).sort((l,u)=>l.startOffset>u.startOffset?1:l.startOffset<u.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:D.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:r,subUnitId:a}=t;this._refreshSelection$.next({unitId:r,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:r,segmentId:a,style:l,textRanges:u,rectRanges:g,isEditing:h}=n,S=[...u,...g].filter(_=>_.startOffset!=null&&_.endOffset!=null).sort((_,f)=>_.startOffset>f.startOffset?1:_.startOffset<f.startOffset?-1:0);this._commandService.executeCommand(C.id,{unitId:s,subUnitId:r,segmentId:a,style:l,isEditing:h,ranges:S})}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,r=[...n,...s],{unitId:a,subUnitId:l}=e;this._refreshSelection$.next({unitId:a,subUnitId:l,docRanges:r,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 r=this._textSelectionInfo.get(t);r.has(n)?r.get(n).textRanges.push(...e.textRanges):r.set(n,{...s})}};exports.DocSelectionManagerService=Y([j(0,c.ICommandService),j(1,c.IUniverInstanceService)],exports.DocSelectionManagerService);var K=Object.defineProperty,q=Object.getOwnPropertyDescriptor,H=(o,i,e,t)=>{for(var n=t>1?void 0:t?q(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&K(i,e,n),n},V=(o,i)=>(e,t)=>i(e,t,o);exports.DocSkeletonManagerService=class extends c.RxDisposable{constructor(e,t,n){super();d(this,"_skeleton");d(this,"_docViewModel");d(this,"_currentSkeleton$",new p.BehaviorSubject(null));d(this,"currentSkeleton$",this._currentSkeleton$.asObservable());d(this,"_currentSkeletonBefore$",new p.BehaviorSubject(null));d(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());d(this,"_currentViewModel$",new p.BehaviorSubject(null));d(this,"currentViewModel$",this._currentViewModel$.asObservable());this._context=e,this._localeService=t,this._univerInstanceService=n,this._init(),this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_DOC).pipe(p.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&&c.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 D.DocumentSkeleton.create(e,this._localeService)}_buildDocViewModel(e){return new D.DocumentViewModel(e)}};exports.DocSkeletonManagerService=H([V(1,c.Inject(c.LocaleService)),V(2,c.IUniverInstanceService)],exports.DocSkeletonManagerService);class y extends c.RxDisposable{constructor(){super();d(this,"_docStateChangeParams$",new p.BehaviorSubject(null));d(this,"docStateChangeParams$",this._docStateChangeParams$.asObservable())}emitStateChangeInfo(e){this._docStateChangeParams$.next(e)}dispose(){super.dispose(),this._docStateChangeParams$.complete()}}const A="doc.mutation.rich-text-editing",O={id:A,type:c.CommandType.MUTATION,handler:(o,i)=>{var $,B;const{unitId:e,segmentId:t="",actions:n,textRanges:s,prevTextRanges:r,trigger:a,noHistory:l,isCompositionEnd:u,noNeedSetTextRange:g,debounce:h,isEditing:S=!0,isSync:_,syncer:f}=i,m=o.get(c.IUniverInstanceService),v=o.get(D.IRenderManagerService),R=o.get(y),I=m.getUniverDocInstance(e),P=($=v.getRenderById(e))==null?void 0:$.with(exports.DocSkeletonManagerService).getViewModel();if(I==null||P==null)throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${e}`);const E=o.get(exports.DocSelectionManagerService),T=(B=E.getDocRanges())!=null?B:[],L=!!I.getSnapshot().disabled;if(c.JSONX.isNoop(n)||n&&n.length===0||L)return{unitId:e,actions:[],textRanges:T};const N=c.JSONX.invertWithDoc(n,I.getSnapshot());I.apply(n),P.reset(I),!g&&s&&a!=null&&!_&&queueMicrotask(()=>{E.replaceDocRanges(s,{unitId:e,subUnitId:e},S,i.options)});const G={commandId:A,unitId:e,segmentId:t,trigger:a,noHistory:l,debounce:h,redoState:{actions:n,textRanges:s},undoState:{actions:N,textRanges:r!=null?r:T},isCompositionEnd:u,isSync:_,syncer:f};return R.emitStateChangeInfo(G),{unitId:e,actions:N,textRanges:T}}},Q={id:"doc.mutation.rename-doc",type:c.CommandType.MUTATION,handler:(o,i)=>{const t=o.get(c.IUniverInstanceService).getUnit(i.unitId,c.UniverInstanceType.UNIVER_DOC);return t?(t.setName(i.name),!0):!1}},Z="docs.config",X={};var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,ne=(o,i,e,t)=>{for(var n=t>1?void 0:t?te(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&ee(i,e,n),n},b=(o,i)=>(e,t)=>i(e,t,o);let M=class extends c.Disposable{constructor(o,i,e){super(),this._commandService=o,this._textSelectionManagerService=i,this._univerInstanceService=e,this._initSelectionChange()}_transformCustomRange(o,i){var r;const{startOffset:e,endOffset:t,collapsed:n}=i,s=(r=o.getCustomRanges())==null?void 0:r.filter(a=>!a.wholeEntity||e<=a.startIndex&&t>a.endIndex?!1:n?a.startIndex<e&&a.endIndex>=t:c.BuildTextUtils.range.isIntersects(e,t-1,a.startIndex,a.endIndex));if(s!=null&&s.length){let a=e,l=t;return s.forEach(u=>{a=Math.min(u.startIndex,a),l=Math.max(u.endIndex+1,l)}),{...i,startOffset:a,endOffset:l,collapsed:a===l}}return i}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(o=>{if(o.id===C.id){const i=o.params,{unitId:e,ranges:t,isEditing:n}=i,s=this._univerInstanceService.getUnit(e);if(!s)return;const r=t.map(a=>this._transformCustomRange(s,a));r.some((a,l)=>t[l]!==a)&&this._textSelectionManagerService.replaceTextRanges(r,n)}}))}};M=ne([b(0,c.ICommandService),b(1,c.Inject(exports.DocSelectionManagerService)),b(2,c.IUniverInstanceService)],M);var ie=Object.defineProperty,se=Object.getOwnPropertyDescriptor,re=(o,i,e,t)=>{for(var n=t>1?void 0:t?se(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&ie(i,e,n),n},F=(o,i)=>(e,t)=>i(e,t,o);const oe="DOCS_PLUGIN";var U;exports.UniverDocsPlugin=(U=class extends c.Plugin{constructor(i=X,e,t){super(),this._config=i,this._injector=e,this._configService=t;const{...n}=c.merge({},X,this._config);this._configService.setConfig(Z,n)}onStarting(){this._initializeDependencies(),this._initializeCommands()}_initializeCommands(){[O,Q,C].forEach(i=>{this._injector.get(c.ICommandService).registerCommand(i)})}_initializeDependencies(){[[exports.DocSelectionManagerService],[y],[M]].forEach(i=>this._injector.add(i))}onReady(){this._injector.get(M)}},d(U,"pluginName",oe),U);exports.UniverDocsPlugin=re([F(1,c.Inject(c.Injector)),F(2,c.IConfigService)],exports.UniverDocsPlugin);const ce=c.createInterceptorKey("CUSTOM_RANGE"),ae=c.createInterceptorKey("CUSTOM_DECORATION"),x={CUSTOM_RANGE:ce,CUSTOM_DECORATION:ae};var le=Object.defineProperty,ue=Object.getOwnPropertyDescriptor,de=(o,i,e,t)=>{for(var n=t>1?void 0:t?ue(i,e):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(t?r(i,e,n):r(n))||n);return t&&n&&le(i,e,n),n},ge=(o,i)=>(e,t)=>i(e,t,o);exports.DocInterceptorService=class extends c.Disposable{constructor(e,t){super();d(this,"_interceptorsByName",new Map);this._context=e,this._docSkeletonManagerService=t;const n=this._docSkeletonManagerService.getViewModel(),s=n.getDataModel().getUnitId();if(s===c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY||s===c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;this.disposeWithMe(this.interceptDocumentViewModel(n)),this.disposeWithMe(this.intercept(x.CUSTOM_RANGE,{priority:-1,handler:(a,l,u)=>u(a)}));let r=new c.DisposableCollection;n.segmentViewModels$.subscribe(a=>{r.dispose(),r=new c.DisposableCollection,a.forEach(l=>{r.add(this.interceptDocumentViewModel(l))})}),this.disposeWithMe(r)}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((r,a)=>{var l,u;return((l=a.priority)!=null?l:0)-((u=r.priority)!=null?u:0)})),this.disposeWithMe(c.toDisposable(()=>c.remove(this._interceptorsByName.get(n),t)))}fetchThroughInterceptors(e){const t=e,n=this._interceptorsByName.get(t);return c.composeInterceptors(n||[])}interceptDocumentViewModel(e){const t=new c.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}};exports.DocInterceptorService=de([ge(1,c.Inject(exports.DocSkeletonManagerService))],exports.DocInterceptorService);function w(o,i=""){if(!i)return["body"];const{headers:e,footers:t}=o.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 _e(o,i,e){const{unitId:t,segmentId:n}=i,r=o.get(c.IUniverInstanceService).getUnit(t);if(!r)return!1;const a={id:O.id,params:{unitId:i.unitId,actions:[],textRanges:void 0}},l=c.JSONX.getInstance(),u=c.BuildTextUtils.customRange.add({...i,body:e});if(!u)return!1;const g=w(r,n);return a.params.actions=l.editOp(u.serialize(),g),a}function he(o,i){var I;const{rangeId:e,rangeType:t,wholeEntity:n,properties:s,unitId:r,selections:a}=i,l=o.get(exports.DocSelectionManagerService),u=o.get(c.IUniverInstanceService),g=a!=null?a:l.getTextRanges({unitId:r,subUnitId:r}),h=(I=g==null?void 0:g[0])==null?void 0:I.segmentId;if(!(g!=null&&g.length))return!1;const S=u.getUnit(r,c.UniverInstanceType.UNIVER_DOC);if(!S)return!1;const _=S.getSelfOrHeaderFooterModel(h).getBody();if(!_)return!1;const f=c.BuildTextUtils.customRange.add({ranges:g,rangeId:e,rangeType:t,segmentId:h,wholeEntity:n,properties:s,body:_});if(!f)return!1;const m=c.JSONX.getInstance(),v={id:O.id,params:{unitId:r,actions:[],textRanges:f.selections,segmentId:h},textX:f},R=w(S,h);return v.params.actions=m.editOp(f.serialize(),R),v}function fe(o,i){const{unitId:e,segmentId:t,insert:n}=i,r=o.get(c.IUniverInstanceService).getUnit(e);if(!r)return!1;const a={id:O.id,params:{unitId:i.unitId,actions:[],textRanges:void 0,segmentId:t}},l=c.JSONX.getInstance(),u=c.BuildTextUtils.customRange.delete({documentDataModel:r,rangeId:i.rangeId,insert:n,segmentId:t});if(!u)return!1;const g=w(r,t);return a.params.actions=l.editOp(u.serialize(),g),a.params.textRanges=u.selections,a}function Se(o,i){var f,m,v,R;const{unitId:e,body:t,doc:n}=i;let s=n;if(s||(s=o.get(c.IUniverInstanceService).getUnit(e)),!s)return!1;const r=(f=i.selection)==null?void 0:f.segmentId,a=(m=s.getSelfOrHeaderFooterModel(r))==null?void 0:m.getBody();if(!a)return!1;const l=o.get(exports.DocSelectionManagerService),u=(v=i.selection)!=null?v:l.getActiveTextRange();if(!u||!a)return!1;const g=(R=i.textRanges)!=null?R:[{startOffset:u.startOffset+t.dataStream.length,endOffset:u.startOffset+t.dataStream.length,collapsed:!0,segmentId:r}],h=c.BuildTextUtils.selection.replace({selection:u,body:t,doc:s});if(!h)return!1;const S={id:O.id,params:{unitId:e,actions:[],textRanges:g,debounce:!0,segmentId:r},textX:h},_=c.JSONX.getInstance();return S.params.actions=_.editOp(h.serialize()),S}exports.DOC_INTERCEPTOR_POINT=x;exports.DocStateEmitService=y;exports.RichTextEditingMutation=O;exports.SetTextSelectionsOperation=C;exports.addCustomRangeBySelectionFactory=he;exports.addCustomRangeFactory=_e;exports.deleteCustomRangeFactory=fe;exports.replaceSelectionFactory=Se;
|
package/lib/es/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var ie = Object.defineProperty;
|
|
2
2
|
var re = (i, e, t) => e in i ? ie(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
3
|
var u = (i, e, t) => re(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 oe, isInternalEditorID as ce, JSONX as O, Disposable as Q, BuildTextUtils as C, Injector as ae, Plugin as le, merge as ue, IConfigService as de, createInterceptorKey as Z, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as ge, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as _e, DisposableCollection as $, toDisposable as
|
|
5
|
-
import { NORMAL_TEXT_SELECTION_PLUGIN_STYLE as pe, DocumentSkeleton as Ie, DocumentViewModel as me, IRenderManagerService as
|
|
6
|
-
import { Subject as
|
|
4
|
+
import { CommandType as N, RxDisposable as V, UniverInstanceType as b, ICommandService as B, IUniverInstanceService as p, Inject as w, LocaleService as oe, isInternalEditorID as ce, JSONX as O, Disposable as Q, BuildTextUtils as C, Injector as ae, Plugin as le, merge as ue, IConfigService as de, createInterceptorKey as Z, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as ge, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as _e, DisposableCollection as $, toDisposable as fe, remove as he, composeInterceptors as Se } from "@univerjs/core";
|
|
5
|
+
import { NORMAL_TEXT_SELECTION_PLUGIN_STYLE as pe, DocumentSkeleton as Ie, DocumentViewModel as me, IRenderManagerService as Re } from "@univerjs/engine-render";
|
|
6
|
+
import { Subject as ve, BehaviorSubject as x, takeUntil as ee } from "rxjs";
|
|
7
7
|
const j = {
|
|
8
8
|
id: "doc.operation.set-selections",
|
|
9
9
|
type: N.OPERATION,
|
|
@@ -19,7 +19,7 @@ let m = class extends V {
|
|
|
19
19
|
super();
|
|
20
20
|
u(this, "_currentSelection", null);
|
|
21
21
|
u(this, "_textSelectionInfo", /* @__PURE__ */ new Map());
|
|
22
|
-
u(this, "_textSelection$", new
|
|
22
|
+
u(this, "_textSelection$", new ve());
|
|
23
23
|
u(this, "textSelection$", this._textSelection$.asObservable());
|
|
24
24
|
u(this, "_refreshSelection$", new x(null));
|
|
25
25
|
u(this, "refreshSelection$", this._refreshSelection$.asObservable());
|
|
@@ -126,7 +126,7 @@ 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, _ = [...a, ...l].filter((g) => g.startOffset != null && g.endOffset != null).sort((g,
|
|
129
|
+
const { unitId: s, subUnitId: r, segmentId: o, style: c, textRanges: a, rectRanges: l, isEditing: d } = n, _ = [...a, ...l].filter((g) => g.startOffset != null && g.endOffset != null).sort((g, f) => g.startOffset > f.startOffset ? 1 : g.startOffset < f.startOffset ? -1 : 0);
|
|
130
130
|
this._commandService.executeCommand(j.id, {
|
|
131
131
|
unitId: s,
|
|
132
132
|
subUnitId: r,
|
|
@@ -260,9 +260,9 @@ const K = "doc.mutation.rich-text-editing", M = {
|
|
|
260
260
|
noNeedSetTextRange: d,
|
|
261
261
|
debounce: _,
|
|
262
262
|
isEditing: g = !0,
|
|
263
|
-
isSync:
|
|
264
|
-
syncer:
|
|
265
|
-
} = e,
|
|
263
|
+
isSync: f,
|
|
264
|
+
syncer: h
|
|
265
|
+
} = e, R = i.get(p), I = i.get(Re), v = i.get(te), S = R.getUniverDocInstance(t), L = (z = I.getRenderById(t)) == null ? void 0 : z.with(D).getViewModel();
|
|
266
266
|
if (S == null || L == null)
|
|
267
267
|
throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${t}`);
|
|
268
268
|
const X = i.get(m), y = (F = X.getDocRanges()) != null ? F : [], ne = !!S.getSnapshot().disabled;
|
|
@@ -273,7 +273,7 @@ const K = "doc.mutation.rich-text-editing", M = {
|
|
|
273
273
|
textRanges: y
|
|
274
274
|
};
|
|
275
275
|
const G = O.invertWithDoc(s, S.getSnapshot());
|
|
276
|
-
S.apply(s), L.reset(S), !d && r && c != null && queueMicrotask(() => {
|
|
276
|
+
S.apply(s), L.reset(S), !d && r && c != null && !f && queueMicrotask(() => {
|
|
277
277
|
X.replaceDocRanges(r, { unitId: t, subUnitId: t }, g, e.options);
|
|
278
278
|
});
|
|
279
279
|
const se = {
|
|
@@ -292,10 +292,10 @@ const K = "doc.mutation.rich-text-editing", M = {
|
|
|
292
292
|
textRanges: o != null ? o : y
|
|
293
293
|
},
|
|
294
294
|
isCompositionEnd: l,
|
|
295
|
-
isSync:
|
|
296
|
-
syncer:
|
|
295
|
+
isSync: f,
|
|
296
|
+
syncer: h
|
|
297
297
|
};
|
|
298
|
-
return
|
|
298
|
+
return v.emitStateChangeInfo(se), {
|
|
299
299
|
unitId: t,
|
|
300
300
|
actions: G,
|
|
301
301
|
textRanges: y
|
|
@@ -434,7 +434,7 @@ let J = class extends Q {
|
|
|
434
434
|
var c, a;
|
|
435
435
|
return ((c = o.priority) != null ? c : 0) - ((a = r.priority) != null ? a : 0);
|
|
436
436
|
})
|
|
437
|
-
), this.disposeWithMe(
|
|
437
|
+
), this.disposeWithMe(fe(() => he(this._interceptorsByName.get(n), t)));
|
|
438
438
|
}
|
|
439
439
|
fetchThroughInterceptors(e) {
|
|
440
440
|
const t = e, n = this._interceptorsByName.get(t);
|
|
@@ -508,31 +508,31 @@ function He(i, e) {
|
|
|
508
508
|
const g = l.getUnit(o, b.UNIVER_DOC);
|
|
509
509
|
if (!g)
|
|
510
510
|
return !1;
|
|
511
|
-
const
|
|
512
|
-
if (!
|
|
511
|
+
const f = g.getSelfOrHeaderFooterModel(_).getBody();
|
|
512
|
+
if (!f)
|
|
513
513
|
return !1;
|
|
514
|
-
const
|
|
514
|
+
const h = C.customRange.add({
|
|
515
515
|
ranges: d,
|
|
516
516
|
rangeId: t,
|
|
517
517
|
rangeType: n,
|
|
518
518
|
segmentId: _,
|
|
519
519
|
wholeEntity: s,
|
|
520
520
|
properties: r,
|
|
521
|
-
body:
|
|
521
|
+
body: f
|
|
522
522
|
});
|
|
523
|
-
if (!
|
|
523
|
+
if (!h)
|
|
524
524
|
return !1;
|
|
525
|
-
const
|
|
525
|
+
const R = O.getInstance(), I = {
|
|
526
526
|
id: M.id,
|
|
527
527
|
params: {
|
|
528
528
|
unitId: o,
|
|
529
529
|
actions: [],
|
|
530
|
-
textRanges:
|
|
530
|
+
textRanges: h.selections,
|
|
531
531
|
segmentId: _
|
|
532
532
|
},
|
|
533
|
-
textX:
|
|
534
|
-
},
|
|
535
|
-
return I.params.actions =
|
|
533
|
+
textX: h
|
|
534
|
+
}, v = A(g, _);
|
|
535
|
+
return I.params.actions = R.editOp(h.serialize(), v), I;
|
|
536
536
|
}
|
|
537
537
|
function ke(i, e) {
|
|
538
538
|
const { unitId: t, segmentId: n, insert: s } = e, o = i.get(p).getUnit(t);
|
|
@@ -546,7 +546,7 @@ function ke(i, e) {
|
|
|
546
546
|
textRanges: void 0,
|
|
547
547
|
segmentId: n
|
|
548
548
|
}
|
|
549
|
-
}, a = O.getInstance(), l = C.customRange.delete(
|
|
549
|
+
}, a = O.getInstance(), l = C.customRange.delete({
|
|
550
550
|
documentDataModel: o,
|
|
551
551
|
rangeId: e.rangeId,
|
|
552
552
|
insert: s,
|
|
@@ -558,17 +558,17 @@ function ke(i, e) {
|
|
|
558
558
|
return c.params.actions = a.editOp(l.serialize(), d), c.params.textRanges = l.selections, c;
|
|
559
559
|
}
|
|
560
560
|
function qe(i, e) {
|
|
561
|
-
var
|
|
561
|
+
var h, R, I, v;
|
|
562
562
|
const { unitId: t, body: n, doc: s } = e;
|
|
563
563
|
let r = s;
|
|
564
564
|
if (r || (r = i.get(p).getUnit(t)), !r)
|
|
565
565
|
return !1;
|
|
566
|
-
const o = (
|
|
566
|
+
const o = (h = e.selection) == null ? void 0 : h.segmentId, c = (R = r.getSelfOrHeaderFooterModel(o)) == null ? void 0 : R.getBody();
|
|
567
567
|
if (!c) return !1;
|
|
568
568
|
const a = i.get(m), l = (I = e.selection) != null ? I : a.getActiveTextRange();
|
|
569
569
|
if (!l || !c)
|
|
570
570
|
return !1;
|
|
571
|
-
const d = (
|
|
571
|
+
const d = (v = e.textRanges) != null ? v : [{
|
|
572
572
|
startOffset: l.startOffset + n.dataStream.length,
|
|
573
573
|
endOffset: l.startOffset + n.dataStream.length,
|
|
574
574
|
collapsed: !0,
|
|
@@ -590,8 +590,8 @@ function qe(i, e) {
|
|
|
590
590
|
segmentId: o
|
|
591
591
|
},
|
|
592
592
|
textX: _
|
|
593
|
-
},
|
|
594
|
-
return g.params.actions =
|
|
593
|
+
}, f = O.getInstance();
|
|
594
|
+
return g.params.actions = f.editOp(_.serialize()), g;
|
|
595
595
|
}
|
|
596
596
|
export {
|
|
597
597
|
E as DOC_INTERCEPTOR_POINT,
|
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 M={id:"doc.operation.set-selections",type:r.CommandType.OPERATION,handler:()=>!0};var G=Object.defineProperty,k=Object.getOwnPropertyDescriptor,z=(c,i,e,t)=>{for(var n=t>1?void 0:t?k(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&&G(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=z([E(0,r.ICommandService),E(1,r.IUniverInstanceService)],l.DocSelectionManagerService);var W=Object.defineProperty,J=Object.getOwnPropertyDescriptor,Y=(c,i,e,t)=>{for(var n=t>1?void 0:t?J(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&&W(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=Y([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 F,L;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),V=(F=R.getRenderById(e))==null?void 0:F.with(l.DocSkeletonManagerService).getViewModel();if(p==null||V==null)throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${e}`);const A=c.get(l.DocSelectionManagerService),P=(L=A.getDocRanges())!=null?L:[],he=!!p.getSnapshot().disabled;if(r.JSONX.isNoop(n)||n&&n.length===0||he)return{unitId:e,actions:[],textRanges:P};const X=r.JSONX.invertWithDoc(n,p.getSnapshot());p.apply(n),V.reset(p),!_&&s&&a!=null&&queueMicrotask(()=>{A.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:X,textRanges:o!=null?o:P},isCompositionEnd:d,isSync:f,syncer:S};return C.emitStateChangeInfo(fe),{unitId:e,actions:X,textRanges:P}}},K={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}},q="docs.config",B={};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},j=(c,i)=>(e,t)=>i(e,t,c);const ie="DOCS_PLUGIN";l.UniverDocsPlugin=(w=class extends r.Plugin{constructor(i=B,e,t){super(),this._config=i,this._injector=e,this._configService=t;const{...n}=r.merge({},B,this._config);this._configService.setConfig(q,n)}onStarting(){this._initializeDependencies(),this._initializeCommands()}_initializeCommands(){[O,K,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([j(1,r.Inject(r.Injector)),j(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"})});
|
|
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 G=Object.defineProperty,k=Object.getOwnPropertyDescriptor,z=(c,i,e,t)=>{for(var n=t>1?void 0:t?k(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&&G(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:f,isEditing:h}=n,I=[...d,...f].filter(_=>_.startOffset!=null&&_.endOffset!=null).sort((_,S)=>_.startOffset>S.startOffset?1:_.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=z([E(0,r.ICommandService),E(1,r.IUniverInstanceService)],l.DocSelectionManagerService);var W=Object.defineProperty,J=Object.getOwnPropertyDescriptor,Y=(c,i,e,t)=>{for(var n=t>1?void 0:t?J(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&&W(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=Y([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 F,L;const{unitId:e,segmentId:t="",actions:n,textRanges:s,prevTextRanges:o,trigger:a,noHistory:u,isCompositionEnd:d,noNeedSetTextRange:f,debounce:h,isEditing:I=!0,isSync:_,syncer:S}=i,D=c.get(r.IUniverInstanceService),R=c.get(v.IRenderManagerService),C=c.get(U),p=D.getUniverDocInstance(e),V=(F=R.getRenderById(e))==null?void 0:F.with(l.DocSkeletonManagerService).getViewModel();if(p==null||V==null)throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${e}`);const A=c.get(l.DocSelectionManagerService),P=(L=A.getDocRanges())!=null?L:[],_e=!!p.getSnapshot().disabled;if(r.JSONX.isNoop(n)||n&&n.length===0||_e)return{unitId:e,actions:[],textRanges:P};const X=r.JSONX.invertWithDoc(n,p.getSnapshot());p.apply(n),V.reset(p),!f&&s&&a!=null&&!_&&queueMicrotask(()=>{A.replaceDocRanges(s,{unitId:e,subUnitId:e},I,i.options)});const he={commandId:$,unitId:e,segmentId:t,trigger:a,noHistory:u,debounce:h,redoState:{actions:n,textRanges:s},undoState:{actions:X,textRanges:o!=null?o:P},isCompositionEnd:d,isSync:_,syncer:S};return C.emitStateChangeInfo(he),{unitId:e,actions:X,textRanges:P}}},K={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}},q="docs.config",B={};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},j=(c,i)=>(e,t)=>i(e,t,c);const ie="DOCS_PLUGIN";l.UniverDocsPlugin=(w=class extends r.Plugin{constructor(i=B,e,t){super(),this._config=i,this._injector=e,this._configService=t;const{...n}=r.merge({},B,this._config);this._configService.setConfig(q,n)}onStarting(){this._initializeDependencies(),this._initializeCommands()}_initializeCommands(){[O,K,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([j(1,r.Inject(r.Injector)),j(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 f=y(o,n);return a.params.actions=u.editOp(d.serialize(),f),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),f=a!=null?a:u.getTextRanges({unitId:o,subUnitId:o}),h=(p=f==null?void 0:f[0])==null?void 0:p.segmentId;if(!(f!=null&&f.length))return!1;const I=d.getUnit(o,r.UniverInstanceType.UNIVER_DOC);if(!I)return!1;const _=I.getSelfOrHeaderFooterModel(h).getBody();if(!_)return!1;const S=r.BuildTextUtils.customRange.add({ranges:f,rangeId:e,rangeType:t,segmentId:h,wholeEntity:n,properties:s,body:_});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({documentDataModel:o,rangeId:i.rangeId,insert:n,segmentId:t});if(!d)return!1;const f=y(o,t);return a.params.actions=u.editOp(d.serialize(),f),a.params.textRanges=d.selections,a}function fe(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 f=(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:f,debounce:!0,segmentId:o},textX:h},_=r.JSONX.getInstance();return I.params.actions=_.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=fe,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.4-experimental.20250114-7c09c35",
|
|
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.4-experimental.20250114-7c09c35",
|
|
52
|
+
"@univerjs/engine-render": "0.5.4-experimental.20250114-7c09c35"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"rxjs": "^7.8.1",
|
|
56
56
|
"typescript": "^5.7.2",
|
|
57
|
-
"vite": "^6.0.
|
|
57
|
+
"vite": "^6.0.7",
|
|
58
58
|
"vitest": "^2.1.8",
|
|
59
|
-
"@univerjs-infra/shared": "0.5.
|
|
59
|
+
"@univerjs-infra/shared": "0.5.4"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"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
|