@univerjs/docs 0.24.0 → 0.25.0-insiders.20260604-29ebbff
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/cjs/facade.js +305 -0
- package/lib/cjs/index.js +207 -29
- package/lib/es/facade.js +299 -0
- package/lib/es/index.js +202 -28
- package/lib/facade.js +299 -0
- package/lib/index.js +202 -28
- package/lib/types/commands/commands/core-editing.command.d.ts +57 -0
- package/lib/types/facade/f-document.d.ts +178 -0
- package/lib/types/facade/f-univer.d.ts +64 -0
- package/lib/types/facade/index.d.ts +18 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/services/doc-content-insert.service.d.ts +28 -0
- package/lib/types/utils/custom-range-factory.d.ts +1 -5
- package/lib/umd/facade.js +5 -0
- package/lib/umd/index.js +1 -1
- package/package.json +15 -5
- package/LICENSE +0 -176
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { DocumentDataModel, IDocumentData } from '@univerjs/core';
|
|
17
|
+
import { ICommandService, Injector, IResourceLoaderService, IUniverInstanceService } from '@univerjs/core';
|
|
18
|
+
import { FBaseInitialable } from '@univerjs/core/facade';
|
|
19
|
+
export interface IDocumentInsertTextFacadeOptions {
|
|
20
|
+
startOffset?: number;
|
|
21
|
+
endOffset?: number;
|
|
22
|
+
segmentId?: string;
|
|
23
|
+
cursorOffset?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Facade API object bounded to a document. It provides a set of methods to interact with the document.
|
|
27
|
+
* @hideconstructor
|
|
28
|
+
*/
|
|
29
|
+
export declare class FDocument extends FBaseInitialable {
|
|
30
|
+
private readonly _documentDataModel;
|
|
31
|
+
protected readonly _injector: Injector;
|
|
32
|
+
protected readonly _univerInstanceService: IUniverInstanceService;
|
|
33
|
+
protected readonly _resourceLoaderService: IResourceLoaderService;
|
|
34
|
+
private readonly _commandService;
|
|
35
|
+
readonly id: string;
|
|
36
|
+
constructor(_documentDataModel: DocumentDataModel, _injector: Injector, _univerInstanceService: IUniverInstanceService, _resourceLoaderService: IResourceLoaderService, _commandService: ICommandService);
|
|
37
|
+
/**
|
|
38
|
+
* Get the document data model of the document.
|
|
39
|
+
* @returns {DocumentDataModel} The document data model.
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
43
|
+
* const documentDataModel = fDocument.getDocumentDataModel();
|
|
44
|
+
* console.log(documentDataModel);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
getDocumentDataModel(): DocumentDataModel;
|
|
48
|
+
dispose(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Get the document id.
|
|
51
|
+
* @returns {string} The document id.
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
55
|
+
* const unitId = fDocument.getId();
|
|
56
|
+
* console.log(unitId);
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
getId(): string;
|
|
60
|
+
/**
|
|
61
|
+
* Get the document name.
|
|
62
|
+
* @returns {string} The document name.
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
66
|
+
* const name = fDocument.getName();
|
|
67
|
+
* console.log(name);
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
getName(): string;
|
|
71
|
+
/**
|
|
72
|
+
* Save the document snapshot data, including the document content and resource data, etc.
|
|
73
|
+
* @returns {IDocumentData} The document snapshot data.
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
77
|
+
* const snapshot = fDocument.save();
|
|
78
|
+
* console.log(snapshot);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
save(): IDocumentData;
|
|
82
|
+
/**
|
|
83
|
+
* Undo the last operation in the document.
|
|
84
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the undo operation was successful, or false if it failed.
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
88
|
+
* await fDocument.undo();
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
undo(): Promise<boolean>;
|
|
92
|
+
/**
|
|
93
|
+
* Redo the last undone operation in the document.
|
|
94
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the redo operation was successful, or false if it failed.
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
98
|
+
* await fDocument.redo();
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
redo(): Promise<boolean>;
|
|
102
|
+
/**
|
|
103
|
+
* Adds the specified text to the end of this text region.
|
|
104
|
+
* @param {string} text - The text to be added to the end of this text region.
|
|
105
|
+
* @return {Promise<boolean>} A promise that resolves to true if the text was successfully appended, or false if it failed.
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
109
|
+
* await fDocument.appendText('Hello, world!');
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
appendText(text: string): Promise<boolean>;
|
|
113
|
+
/**
|
|
114
|
+
* Inserts text at the provided document range. Defaults to appending before the final section break.
|
|
115
|
+
* @param {string} text - The text to insert.
|
|
116
|
+
* @param {IDocumentInsertTextFacadeOptions} options - Optional target range, segment id, and cursor offset.
|
|
117
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the text was successfully inserted, or false if it failed.
|
|
118
|
+
* @example
|
|
119
|
+
*
|
|
120
|
+
* // Insert text at a specific range in the document body
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
123
|
+
* await fDocument.insertText('Hello, world!', {
|
|
124
|
+
* startOffset: 5,
|
|
125
|
+
* endOffset: 5,
|
|
126
|
+
* segmentId: '',
|
|
127
|
+
* cursorOffset: 13,
|
|
128
|
+
* });
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* // Insert text at the beginning of a header or footer segment
|
|
132
|
+
* ```typescript
|
|
133
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
134
|
+
* const snapshot = fDocument.save();
|
|
135
|
+
* const { headers, footers } = snapshot;
|
|
136
|
+
*
|
|
137
|
+
* if (headers) {
|
|
138
|
+
* for (const headerId in headers) {
|
|
139
|
+
* if (headerId === 'target-header-id') {
|
|
140
|
+
* await fDocument.insertText('Hello, header!', {
|
|
141
|
+
* startOffset: 0,
|
|
142
|
+
* endOffset: 0,
|
|
143
|
+
* segmentId: headerId,
|
|
144
|
+
* });
|
|
145
|
+
* }
|
|
146
|
+
* }
|
|
147
|
+
* }
|
|
148
|
+
*
|
|
149
|
+
* if (footers) {
|
|
150
|
+
* for (const footerId in footers) {
|
|
151
|
+
* if (footerId === 'target-footer-id') {
|
|
152
|
+
* await fDocument.insertText('Hello, footer!', {
|
|
153
|
+
* startOffset: 0,
|
|
154
|
+
* endOffset: 0,
|
|
155
|
+
* segmentId: footerId,
|
|
156
|
+
* });
|
|
157
|
+
* }
|
|
158
|
+
* }
|
|
159
|
+
* }
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
insertText(text: string, options?: IDocumentInsertTextFacadeOptions): Promise<boolean>;
|
|
163
|
+
/**
|
|
164
|
+
* Inserts one or more plain-text paragraphs at the provided document range.
|
|
165
|
+
* @param {string} text - The paragraph text to insert. Newlines are normalized to document paragraph separators.
|
|
166
|
+
* @param {IDocumentInsertTextFacadeOptions} options - Optional target range, segment id, and cursor offset.
|
|
167
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the paragraphs were successfully inserted, or false if it failed.
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
171
|
+
* await fDocument.insertParagraph('Hello, world! This is a new paragraph.', {
|
|
172
|
+
* startOffset: 5,
|
|
173
|
+
* endOffset: 5,
|
|
174
|
+
* });
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
insertParagraph(text?: string, options?: IDocumentInsertTextFacadeOptions): Promise<boolean>;
|
|
178
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { IDocumentData } from '@univerjs/core';
|
|
17
|
+
import { FUniver } from '@univerjs/core/facade';
|
|
18
|
+
import { FDocument } from './f-document';
|
|
19
|
+
/**
|
|
20
|
+
* @ignore
|
|
21
|
+
*/
|
|
22
|
+
export interface IFUniverDocsUIMixin {
|
|
23
|
+
/**
|
|
24
|
+
* Create a new document and get the API handler of that document.
|
|
25
|
+
* @param {Partial<IDocumentData>} data The snapshot of the document.
|
|
26
|
+
* @returns {FDocument} The document API instance.
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const fDocument = univerAPI.createUniverDoc({ id: 'document-01', title: 'Document1' });
|
|
30
|
+
* console.log(fDocument);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
createDocument(data: Partial<IDocumentData>): FDocument;
|
|
34
|
+
/**
|
|
35
|
+
* Get the currently focused Univer document.
|
|
36
|
+
* @returns {FDocument | null} The currently focused Univer document API instance, or null if there is no focused Univer document.
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
40
|
+
* console.log(fDocument);
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
getActiveDocument(): FDocument | null;
|
|
44
|
+
/**
|
|
45
|
+
* Get the document API handler by the document id.
|
|
46
|
+
* @param {string} id The document id.
|
|
47
|
+
* @returns {FDocument | null} The document API instance corresponding to the document id, or null if not found.
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const fDocument = univerAPI.getDocument('document-01');
|
|
51
|
+
* console.log(fDocument);
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
getDocument(id: string): FDocument | null;
|
|
55
|
+
}
|
|
56
|
+
export declare class FUniverDocsUIMixin extends FUniver implements IFUniverDocsUIMixin {
|
|
57
|
+
createDocument(data: Partial<IDocumentData>): FDocument;
|
|
58
|
+
getActiveDocument(): FDocument | null;
|
|
59
|
+
getDocument(id: string): FDocument | null;
|
|
60
|
+
}
|
|
61
|
+
declare module '@univerjs/core/facade' {
|
|
62
|
+
interface FUniver extends IFUniverDocsUIMixin {
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import './f-univer';
|
|
17
|
+
export { FDocument } from './f-document';
|
|
18
|
+
export type * from './f-univer';
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,10 +13,12 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
export { DeleteTextCommand, type IDeleteTextCommandParams, type IInsertTextCommandParams, InsertTextCommand, type IUpdateTextCommandParams, UpdateTextCommand, } from './commands/commands/core-editing.command';
|
|
16
17
|
export { type IRichTextEditingMutationParams, RichTextEditingMutation } from './commands/mutations/core-editing.mutation';
|
|
17
18
|
export { type ISetTextSelectionsOperationParams, SetTextSelectionsOperation } from './commands/operations/text-selection.operation';
|
|
18
19
|
export type { IUniverDocsConfig } from './config/config';
|
|
19
20
|
export { UniverDocsPlugin } from './plugin';
|
|
21
|
+
export { DocContentInsertService, type IDocContentInsertRange } from './services/doc-content-insert.service';
|
|
20
22
|
export { DocInterceptorService } from './services/doc-interceptor/doc-interceptor.service';
|
|
21
23
|
export { DOC_INTERCEPTOR_POINT } from './services/doc-interceptor/interceptor-const';
|
|
22
24
|
export { DocSelectionManagerService } from './services/doc-selection-manager.service';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Disposable } from '@univerjs/core';
|
|
17
|
+
export interface IDocContentInsertRange {
|
|
18
|
+
unitId: string;
|
|
19
|
+
startOffset: number;
|
|
20
|
+
endOffset: number;
|
|
21
|
+
segmentId?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare class DocContentInsertService extends Disposable {
|
|
24
|
+
private _range;
|
|
25
|
+
setInsertRange(range: IDocContentInsertRange): void;
|
|
26
|
+
consumeInsertRange(unitId?: string): IDocContentInsertRange | null;
|
|
27
|
+
clearInsertRange(): void;
|
|
28
|
+
}
|
|
@@ -13,15 +13,11 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { CustomRangeType,
|
|
16
|
+
import type { CustomRangeType, IAccessor, IAddCustomRangeTextXParam, IDocumentBody, IMutationInfo, ITextRangeParam, Nullable, TextX } from '@univerjs/core';
|
|
17
17
|
import type { IRichTextEditingMutationParams } from '../commands/mutations/core-editing.mutation';
|
|
18
18
|
interface IAddCustomRangeParam extends IAddCustomRangeTextXParam {
|
|
19
19
|
unitId: string;
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
* @deprecated This is a duplication from docs-ui to avoid making too much breaking changes.
|
|
23
|
-
*/
|
|
24
|
-
export declare function getRichTextEditPath(docDataModel: DocumentDataModel, segmentId?: string): string[];
|
|
25
21
|
export declare function addCustomRangeFactory(accessor: IAccessor, param: IAddCustomRangeParam, body: IDocumentBody): false | IMutationInfo<IRichTextEditingMutationParams>;
|
|
26
22
|
interface IAddCustomRangeFactoryParam {
|
|
27
23
|
rangeId: string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/core/facade"),require("@univerjs/docs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/core/facade`,`@univerjs/docs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsFacade={},e.UniverCore,e.UniverCoreFacade,e.UniverDocs))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){return function(n,r){t(n,r,e)}}function l(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let u=class extends n.FBaseInitialable{constructor(e,t,n,r,i){super(t),this._documentDataModel=e,this._injector=t,this._univerInstanceService=n,this._resourceLoaderService=r,this._commandService=i,s(this,`id`,void 0),this.id=this._documentDataModel.getUnitId()}getDocumentDataModel(){return this._documentDataModel}dispose(){super.dispose()}getId(){return this.id}getName(){return this._documentDataModel.getTitle()||``}save(){return this._resourceLoaderService.saveUnit(this._documentDataModel.getUnitId())}undo(){return this._univerInstanceService.focusUnit(this.id),this._commandService.executeCommand(t.UndoCommand.id)}redo(){return this._univerInstanceService.focusUnit(this.id),this._commandService.executeCommand(t.RedoCommand.id)}appendText(e){let{body:t}=this.save();if(!t)throw Error(`The document body is empty`);let n=t.dataStream.length-2;return this.insertText(e,{startOffset:n,endOffset:n,segmentId:``})}insertText(e,t={}){var n,i,a;let o=this.id,{body:s}=this.save();if(!s)throw Error(`The document body is empty`);let c=(n=t.startOffset)==null?Math.max(0,s.dataStream.length-2):n,l=(i=t.endOffset)==null?c:i,u=(a=t.segmentId)==null?``:a,d={startOffset:c,endOffset:l,collapsed:c===l,segmentId:u};return this._commandService.executeCommand(r.InsertTextCommand.id,{unitId:o,body:{dataStream:e},range:d,segmentId:u,...t.cursorOffset==null?{}:{cursorOffset:t.cursorOffset}})}insertParagraph(e=``,t={}){var n;let r=`${e.replace(/\r\n/g,`
|
|
2
|
+
`).replace(/\r/g,`
|
|
3
|
+
`).split(`
|
|
4
|
+
`).join(`\r
|
|
5
|
+
`)}\r\n`;return this.insertText(r,{...t,cursorOffset:(n=t.cursorOffset)==null?r.length:n})}};u=l([c(1,(0,t.Inject)(t.Injector)),c(2,t.IUniverInstanceService),c(3,(0,t.Inject)(t.IResourceLoaderService)),c(4,t.ICommandService)],u);var d=class extends n.FUniver{createDocument(e){let n=this._injector.get(t.IUniverInstanceService).createUnit(t.UniverInstanceType.UNIVER_DOC,e);return this._injector.createInstance(u,n)}getActiveDocument(){let e=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);return e?this._injector.createInstance(u,e):null}getDocument(e){let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);return n?this._injector.createInstance(u,n):null}};n.FUniver.extend(d),Object.defineProperty(e,"FDocument",{enumerable:!0,get:function(){return u}})});
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/engine-render`),require(`rxjs`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/engine-render`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocs={},e.UniverCore,e.UniverEngineRender,e.rxjs))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let i={id:`doc.operation.set-selections`,type:t.CommandType.OPERATION,handler:()=>!0};function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){return function(n,r){t(n,r,e)}}function u(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let d=class extends t.RxDisposable{constructor(e,t){super(),this._commandService=e,this._univerInstanceService=t,c(this,`_currentSelection`,null),c(this,`_textSelectionInfo`,new Map),c(this,`_textSelection$`,new r.Subject),c(this,`textSelection$`,this._textSelection$.asObservable()),c(this,`_refreshSelection$`,new r.BehaviorSubject(null)),c(this,`refreshSelection$`,this._refreshSelection$.asObservable()),this._listenCurrentUnit()}_listenCurrentUnit(){this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC).pipe((0,r.takeUntil)(this.dispose$)).subscribe(e=>{if(e==null)return;let 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 t,n;let r=(t=this.getTextRanges(e))==null?[]:t,i=(n=this.getRectRanges(e))==null?[]:n;return[...r,...i].filter(e=>e.startOffset!=null&&e.endOffset!=null).sort((e,t)=>e.startOffset>t.startOffset?1:e.startOffset<t.startOffset?-1:0)}getActiveTextRange(){let e=this._getTextRanges(this._currentSelection);if(e==null)return;let{textRanges:t}=e;return t.find(e=>e.isActive)}getActiveRectRange(){let e=this._getTextRanges(this._currentSelection);if(e==null)return;let{rectRanges:t}=e;return t.find(e=>e.isActive)}__TEST_ONLY_add(e,t=!0){this._currentSelection!=null&&this._addByParam({...this._currentSelection,textRanges:e,rectRanges:[],segmentId:``,segmentPage:-1,isEditing:t,style:n.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,r){if(t==null)return;let{unitId:i,subUnitId:a}=t;this._refreshSelection$.next({unitId:i,subUnitId:a,docRanges:e,isEditing:n,options:r})}__replaceTextRangesWithNoRefresh(e,t){if(this._currentSelection==null)return;let n={...e,...t};this._replaceByParam(n),this._textSelection$.next(n);let{unitId:r,subUnitId:a,segmentId:o,style:s,textRanges:c,rectRanges:l,isEditing:u}=n,d=[...c,...l].filter(e=>e.startOffset!=null&&e.endOffset!=null).sort((e,t)=>e.startOffset>t.startOffset?1:e.startOffset<t.startOffset?-1:0);this._commandService.executeCommand(i.id,{unitId:r,subUnitId:a,segmentId:o,style:s,isEditing:u,ranges:d})}dispose(){this._textSelection$.complete(),this._refreshSelection$.complete()}_setCurrentSelectionNotRefresh(e){this._currentSelection=e}_getTextRanges(e){var t;if(e==null)return;let{unitId:n,subUnitId:r=``}=e;return(t=this._textSelectionInfo.get(n))==null?void 0:t.get(r)}_refresh(e){let t=this._getTextRanges(e);if(t==null)return;let{textRanges:n,rectRanges:r}=t,i=[...n,...r],{unitId:a,subUnitId:o}=e;this._refreshSelection$.next({unitId:a,subUnitId:o,docRanges:i,isEditing:!1})}_replaceByParam(e){let{unitId:t,subUnitId:n,...r}=e;this._textSelectionInfo.has(t)||this._textSelectionInfo.set(t,new Map),this._textSelectionInfo.get(t).set(n,{...r})}_addByParam(e){let{unitId:t,subUnitId:n,...r}=e;this._textSelectionInfo.has(t)||this._textSelectionInfo.set(t,new Map);let i=this._textSelectionInfo.get(t);i.has(n)?i.get(n).textRanges.push(...e.textRanges):i.set(n,{...r})}};d=u([l(0,t.ICommandService),l(1,t.IUniverInstanceService)],d);let f=class extends t.RxDisposable{constructor(e,n,i){super(),this._context=e,this._localeService=n,this._univerInstanceService=i,c(this,`_skeleton`,void 0),c(this,`_docViewModel`,void 0),c(this,`_currentSkeleton$`,new r.BehaviorSubject(null)),c(this,`currentSkeleton$`,this._currentSkeleton$.asObservable()),c(this,`_currentSkeletonBefore$`,new r.BehaviorSubject(null)),c(this,`currentSkeletonBefore$`,this._currentSkeletonBefore$.asObservable()),c(this,`_currentViewModel$`,new r.BehaviorSubject(null)),c(this,`currentViewModel$`,this._currentViewModel$.asObservable()),this._init(),this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC).pipe((0,r.takeUntil)(this.dispose$)).subscribe(e=>{e&&e.getUnitId()===this._context.unitId&&this._update(e)})}dispose(){super.dispose(),this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete()}getSkeleton(){return this._skeleton}getViewModel(){return this._docViewModel}_init(){let e=this._context.unit;this._update(e)}_update(e){let n=this._context.unitId;if(e.getBody()==null)return;this._docViewModel&&(0,t.isInternalEditorID)(n)?(this._docViewModel.reset(e),this._context.unit=e):this._docViewModel||(this._docViewModel=this._buildDocViewModel(e)),this._skeleton||(this._skeleton=this._buildSkeleton(this._docViewModel));let r=this._skeleton;r.calculate(),this._currentSkeletonBefore$.next(r),this._currentSkeleton$.next(r),this._currentViewModel$.next(this._docViewModel)}_buildSkeleton(e){return n.DocumentSkeleton.create(e,this._localeService)}_buildDocViewModel(e){return new n.DocumentViewModel(e)}};f=u([l(1,(0,t.Inject)(t.LocaleService)),l(2,t.IUniverInstanceService)],f);var p=class extends t.RxDisposable{constructor(){super(),c(this,`_docStateChangeParams$`,new r.BehaviorSubject(null)),c(this,`docStateChangeParams$`,this._docStateChangeParams$.asObservable())}emitStateChangeInfo(e){this._docStateChangeParams$.next(e)}dispose(){super.dispose(),this._docStateChangeParams$.complete()}};let m=`doc.mutation.rich-text-editing`,h={id:m,type:t.CommandType.MUTATION,handler:(e,r)=>{var i,a;let{unitId:o,segmentId:s=``,actions:c,textRanges:l,prevTextRanges:u,trigger:h,noHistory:g,isCompositionEnd:_,noNeedSetTextRange:v,debounce:y,isEditing:b=!0,isSync:x,syncer:S}=r,C=e.get(t.IUniverInstanceService),w=e.get(n.IRenderManagerService),T=e.get(p),E=C.getUniverDocInstance(o),D=(i=w.getRenderById(o))==null?void 0:i.with(f).getViewModel();if(E==null||D==null)throw Error(`DocumentDataModel or documentViewModel not found for unitId: ${o}`);let O=e.get(d),k=(a=O.getDocRanges())==null?[]:a,A=!!E.getSnapshot().disabled;if(t.JSONX.isNoop(c)||c&&c.length===0||A)return{unitId:o,actions:[],textRanges:k};let j=t.JSONX.invertWithDoc(c,E.getSnapshot());E.apply(c),D.reset(E),!v&&l&&h!=null&&!x&&queueMicrotask(()=>{O.replaceDocRanges(l,{unitId:o,subUnitId:o},b,r.options)});let M={commandId:m,unitId:o,segmentId:s,trigger:h,noHistory:g,debounce:y,redoState:{actions:c,textRanges:l},undoState:{actions:j,textRanges:u==null?k:u},isCompositionEnd:_,isSync:x,syncer:S};return T.emitStateChangeInfo(M),{unitId:o,actions:j,textRanges:k}}};var g=`@univerjs/docs`,_=`0.24.0`;let v={id:`doc.mutation.rename-doc`,type:t.CommandType.MUTATION,handler:(e,n)=>{let r=e.get(t.IUniverInstanceService).getUnit(n.unitId,t.UniverInstanceType.UNIVER_DOC);return r?(r.setName(n.name),!0):!1}},y=`docs.config`;Symbol(y);let b={},x=class extends t.Disposable{constructor(e,t,n){super(),this._commandService=e,this._textSelectionManagerService=t,this._univerInstanceService=n,this._initSelectionChange()}_transformCustomRange(e,n){var r;let{startOffset:i,endOffset:a,collapsed:o}=n,s=(r=e.getCustomRanges())==null?void 0:r.filter(e=>!e.wholeEntity||i<=e.startIndex&&a>e.endIndex?!1:o?e.startIndex<i&&e.endIndex>=a:t.BuildTextUtils.range.isIntersects(i,a-1,e.startIndex,e.endIndex));if(s!=null&&s.length){let e=i,t=a;return s.forEach(n=>{e=Math.min(n.startIndex,e),t=Math.max(n.endIndex+1,t)}),{...n,startOffset:e,endOffset:t,collapsed:e===t}}return n}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===i.id){let{unitId:t,ranges:n,isEditing:r}=e.params,i=this._univerInstanceService.getUnit(t);if(!i)return;let a=n.map(e=>this._transformCustomRange(i,e));a.some((e,t)=>n[t]!==e)&&this._textSelectionManagerService.replaceTextRanges(a,r)}}))}};x=u([l(0,t.ICommandService),l(1,(0,t.Inject)(d)),l(2,t.IUniverInstanceService)],x);let S=class extends t.Plugin{constructor(e=b,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},b,this._config);this._configService.setConfig(y,i)}onStarting(){this._initializeDependencies(),this._initializeCommands()}_initializeCommands(){[h,v,i].forEach(e=>{this._injector.get(t.ICommandService).registerCommand(e)})}_initializeDependencies(){[[d],[p],[x]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(x)}};c(S,`pluginName`,`DOCS_PLUGIN`),c(S,`packageName`,g),c(S,`version`,_),S=u([l(1,(0,t.Inject)(t.Injector)),l(2,t.IConfigService)],S);let C={CUSTOM_RANGE:(0,t.createInterceptorKey)(`CUSTOM_RANGE`),CUSTOM_DECORATION:(0,t.createInterceptorKey)(`CUSTOM_DECORATION`)},w=class extends t.Disposable{constructor(e,n){super(),this._context=e,this._docSkeletonManagerService=n,c(this,`_interceptorsByName`,new Map);let r=this._docSkeletonManagerService.getViewModel(),i=r.getDataModel().getUnitId();if(i===t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY||i===t.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;this.disposeWithMe(this.interceptDocumentViewModel(r)),this.disposeWithMe(this.intercept(C.CUSTOM_RANGE,{priority:-1,handler:(e,t,n)=>n(e)}));let a=new t.DisposableCollection;r.segmentViewModels$.subscribe(e=>{a.dispose(),a=new t.DisposableCollection,e.forEach(e=>{a.add(this.interceptDocumentViewModel(e))})}),this.disposeWithMe(a)}intercept(e,n){let r=e;this._interceptorsByName.has(r)||this._interceptorsByName.set(r,[]);let i=this._interceptorsByName.get(r);return i.push(n),this._interceptorsByName.set(r,i.sort((e,t)=>{var n,r;return((n=t.priority)==null?0:n)-((r=e.priority)==null?0:r)})),this.disposeWithMe((0,t.toDisposable)(()=>(0,t.remove)(this._interceptorsByName.get(r),n)))}fetchThroughInterceptors(e){let n=e;return(0,t.composeInterceptors)(this._interceptorsByName.get(n)||[])}interceptDocumentViewModel(e){let n=new t.DisposableCollection;return n.add(e.registerCustomRangeInterceptor({getCustomRange:t=>{var n;return this.fetchThroughInterceptors(C.CUSTOM_RANGE)(e.getCustomRangeRaw(t),{index:t,unitId:e.getDataModel().getUnitId(),customRanges:(n=e.getDataModel().getCustomRanges())==null?[]:n})},getCustomDecoration:t=>{var n;return this.fetchThroughInterceptors(C.CUSTOM_DECORATION)(e.getCustomDecorationRaw(t),{index:t,unitId:e.getDataModel().getUnitId(),customDecorations:(n=e.getDataModel().getCustomDecorations())==null?[]:n})}})),n}};w=u([l(1,(0,t.Inject)(f))],w);function T(e,t=``){if(!t)return[`body`];let{headers:n,footers:r}=e.getSnapshot();if(n==null&&r==null)throw Error(`Document data model must have headers or footers when update by segment id`);if((n==null?void 0:n[t])!=null)return[`headers`,t,`body`];if((r==null?void 0:r[t])!=null)return[`footers`,t,`body`];throw Error(`Segment id not found in headers or footers`)}function E(e,n,r){let{unitId:i,segmentId:a}=n,o=e.get(t.IUniverInstanceService).getUnit(i);if(!o)return!1;let s={id:h.id,params:{unitId:n.unitId,actions:[],textRanges:void 0}},c=t.JSONX.getInstance(),l=t.BuildTextUtils.customRange.add({...n,body:r});if(!l)return!1;let u=T(o,a);return s.params.actions=c.editOp(l.serialize(),u),s}function D(e,n){var r;let{rangeId:i,rangeType:a,wholeEntity:o,properties:s,unitId:c,selections:l}=n,u=e.get(d),f=e.get(t.IUniverInstanceService),p=l==null?u.getTextRanges({unitId:c,subUnitId:c}):l,m=p==null||(r=p[0])==null?void 0:r.segmentId;if(!(p!=null&&p.length))return!1;let g=f.getUnit(c,t.UniverInstanceType.UNIVER_DOC);if(!g)return!1;let _=g.getSelfOrHeaderFooterModel(m).getBody();if(!_)return!1;let v=t.BuildTextUtils.customRange.add({ranges:p,rangeId:i,rangeType:a,segmentId:m,wholeEntity:o,properties:s,body:_});if(!v)return!1;let y=t.JSONX.getInstance(),b={id:h.id,params:{unitId:c,actions:[],textRanges:v.selections,segmentId:m},textX:v},x=T(g,m);return b.params.actions=y.editOp(v.serialize(),x),b}function O(e,n){let{unitId:r,segmentId:i,insert:a}=n,o=e.get(t.IUniverInstanceService).getUnit(r);if(!o)return!1;let s={id:h.id,params:{unitId:n.unitId,actions:[],textRanges:void 0,segmentId:i}},c=t.JSONX.getInstance(),l=t.BuildTextUtils.customRange.delete({documentDataModel:o,rangeId:n.rangeId,insert:a,segmentId:i});if(!l)return!1;let u=T(o,i);return s.params.actions=c.editOp(l.serialize(),u),s.params.textRanges=l.selections,s}function k(e,n){var r,i,a,o;let{unitId:s,body:c,doc:l}=n,u=l;if(u||(u=e.get(t.IUniverInstanceService).getUnit(s)),!u)return!1;let f=(r=n.selection)==null?void 0:r.segmentId,p=(i=u.getSelfOrHeaderFooterModel(f))==null?void 0:i.getBody();if(!p)return!1;let m=e.get(d),g=(a=n.selection)==null?m.getActiveTextRange():a;if(!g||!p)return!1;let _=(o=n.textRanges)==null?[{startOffset:g.startOffset+c.dataStream.length,endOffset:g.startOffset+c.dataStream.length,collapsed:!0,segmentId:f}]:o,v=t.BuildTextUtils.selection.replace({selection:g,body:c,doc:u});if(!v)return!1;let y={id:h.id,params:{unitId:s,actions:[],textRanges:_,debounce:!0,segmentId:f},textX:v},b=t.JSONX.getInstance();return y.params.actions=b.editOp(v.serialize()),y}e.DOC_INTERCEPTOR_POINT=C,Object.defineProperty(e,`DocInterceptorService`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,`DocSelectionManagerService`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,`DocSkeletonManagerService`,{enumerable:!0,get:function(){return f}}),e.DocStateEmitService=p,e.RichTextEditingMutation=h,e.SetTextSelectionsOperation=i,Object.defineProperty(e,`UniverDocsPlugin`,{enumerable:!0,get:function(){return S}}),e.addCustomRangeBySelectionFactory=D,e.addCustomRangeFactory=E,e.deleteCustomRangeFactory=O,e.replaceSelectionFactory=k});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/engine-render`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocs={},e.UniverCore,e.UniverEngineRender,e.rxjs))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let i={id:`doc.operation.set-selections`,type:t.CommandType.OPERATION,handler:()=>!0};function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){return function(n,r){t(n,r,e)}}function u(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let d=class extends t.RxDisposable{constructor(e,t){super(),this._commandService=e,this._univerInstanceService=t,c(this,`_currentSelection`,null),c(this,`_textSelectionInfo`,new Map),c(this,`_textSelection$`,new r.Subject),c(this,`textSelection$`,this._textSelection$.asObservable()),c(this,`_refreshSelection$`,new r.BehaviorSubject(null)),c(this,`refreshSelection$`,this._refreshSelection$.asObservable()),this._listenCurrentUnit()}_listenCurrentUnit(){this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC).pipe((0,r.takeUntil)(this.dispose$)).subscribe(e=>{if(e==null)return;let 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 t,n;let r=(t=this.getTextRanges(e))==null?[]:t,i=(n=this.getRectRanges(e))==null?[]:n;return[...r,...i].filter(e=>e.startOffset!=null&&e.endOffset!=null).sort((e,t)=>e.startOffset>t.startOffset?1:e.startOffset<t.startOffset?-1:0)}getActiveTextRange(){let e=this._getTextRanges(this._currentSelection);if(e==null)return;let{textRanges:t}=e;return t.find(e=>e.isActive)}getActiveRectRange(){let e=this._getTextRanges(this._currentSelection);if(e==null)return;let{rectRanges:t}=e;return t.find(e=>e.isActive)}__TEST_ONLY_add(e,t=!0){this._currentSelection!=null&&this._addByParam({...this._currentSelection,textRanges:e,rectRanges:[],segmentId:``,segmentPage:-1,isEditing:t,style:n.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,r){if(t==null)return;let{unitId:i,subUnitId:a}=t;this._refreshSelection$.next({unitId:i,subUnitId:a,docRanges:e,isEditing:n,options:r})}__replaceTextRangesWithNoRefresh(e,t){if(this._currentSelection==null)return;let n={...e,...t};this._replaceByParam(n),this._textSelection$.next(n);let{unitId:r,subUnitId:a,segmentId:o,style:s,textRanges:c,rectRanges:l,isEditing:u}=n,d=[...c,...l].filter(e=>e.startOffset!=null&&e.endOffset!=null).sort((e,t)=>e.startOffset>t.startOffset?1:e.startOffset<t.startOffset?-1:0);this._commandService.executeCommand(i.id,{unitId:r,subUnitId:a,segmentId:o,style:s,isEditing:u,ranges:d})}dispose(){this._textSelection$.complete(),this._refreshSelection$.complete()}_setCurrentSelectionNotRefresh(e){this._currentSelection=e}_getTextRanges(e){var t;if(e==null)return;let{unitId:n,subUnitId:r=``}=e;return(t=this._textSelectionInfo.get(n))==null?void 0:t.get(r)}_refresh(e){let t=this._getTextRanges(e);if(t==null)return;let{textRanges:n,rectRanges:r}=t,i=[...n,...r],{unitId:a,subUnitId:o}=e;this._refreshSelection$.next({unitId:a,subUnitId:o,docRanges:i,isEditing:!1})}_replaceByParam(e){let{unitId:t,subUnitId:n,...r}=e;this._textSelectionInfo.has(t)||this._textSelectionInfo.set(t,new Map),this._textSelectionInfo.get(t).set(n,{...r})}_addByParam(e){let{unitId:t,subUnitId:n,...r}=e;this._textSelectionInfo.has(t)||this._textSelectionInfo.set(t,new Map);let i=this._textSelectionInfo.get(t);i.has(n)?i.get(n).textRanges.push(...e.textRanges):i.set(n,{...r})}};d=u([l(0,t.ICommandService),l(1,t.IUniverInstanceService)],d);let f=class extends t.RxDisposable{constructor(e,n,i){super(),this._context=e,this._localeService=n,this._univerInstanceService=i,c(this,`_skeleton`,void 0),c(this,`_docViewModel`,void 0),c(this,`_currentSkeleton$`,new r.BehaviorSubject(null)),c(this,`currentSkeleton$`,this._currentSkeleton$.asObservable()),c(this,`_currentSkeletonBefore$`,new r.BehaviorSubject(null)),c(this,`currentSkeletonBefore$`,this._currentSkeletonBefore$.asObservable()),c(this,`_currentViewModel$`,new r.BehaviorSubject(null)),c(this,`currentViewModel$`,this._currentViewModel$.asObservable()),this._init(),this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC).pipe((0,r.takeUntil)(this.dispose$)).subscribe(e=>{e&&e.getUnitId()===this._context.unitId&&this._update(e)})}dispose(){super.dispose(),this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete()}getSkeleton(){return this._skeleton}getViewModel(){return this._docViewModel}_init(){let e=this._context.unit;this._update(e)}_update(e){let n=this._context.unitId;if(e.getBody()==null)return;this._docViewModel&&(0,t.isInternalEditorID)(n)?(this._docViewModel.reset(e),this._context.unit=e):this._docViewModel||(this._docViewModel=this._buildDocViewModel(e)),this._skeleton||(this._skeleton=this._buildSkeleton(this._docViewModel));let r=this._skeleton;r.calculate(),this._currentSkeletonBefore$.next(r),this._currentSkeleton$.next(r),this._currentViewModel$.next(this._docViewModel)}_buildSkeleton(e){return n.DocumentSkeleton.create(e,this._localeService)}_buildDocViewModel(e){return new n.DocumentViewModel(e)}};f=u([l(1,(0,t.Inject)(t.LocaleService)),l(2,t.IUniverInstanceService)],f);var p=class extends t.RxDisposable{constructor(){super(),c(this,`_docStateChangeParams$`,new r.BehaviorSubject(null)),c(this,`docStateChangeParams$`,this._docStateChangeParams$.asObservable())}emitStateChangeInfo(e){this._docStateChangeParams$.next(e)}dispose(){super.dispose(),this._docStateChangeParams$.complete()}};let m=`doc.mutation.rich-text-editing`,h={id:m,type:t.CommandType.MUTATION,handler:(e,r)=>{var i,a;let{unitId:o,segmentId:s=``,actions:c,textRanges:l,prevTextRanges:u,trigger:h,noHistory:g,isCompositionEnd:_,noNeedSetTextRange:v,debounce:y,isEditing:b=!0,isSync:x,syncer:S}=r,C=e.get(t.IUniverInstanceService),w=e.get(n.IRenderManagerService),T=e.get(p),E=C.getUniverDocInstance(o),D=(i=w.getRenderById(o))==null?void 0:i.with(f).getViewModel();if(E==null||D==null)throw Error(`DocumentDataModel or documentViewModel not found for unitId: ${o}`);let O=e.get(d),k=(a=O.getDocRanges())==null?[]:a,A=!!E.getSnapshot().disabled;if(t.JSONX.isNoop(c)||c&&c.length===0||A)return{unitId:o,actions:[],textRanges:k};let j=t.JSONX.invertWithDoc(c,E.getSnapshot());E.apply(c),D.reset(E),!v&&l&&h!=null&&!x&&queueMicrotask(()=>{O.replaceDocRanges(l,{unitId:o,subUnitId:o},b,r.options)});let M={commandId:m,unitId:o,segmentId:s,trigger:h,noHistory:g,debounce:y,redoState:{actions:c,textRanges:l},undoState:{actions:j,textRanges:u==null?k:u},isCompositionEnd:_,isSync:x,syncer:S};return T.emitStateChangeInfo(M),{unitId:o,actions:j,textRanges:k}}},g={id:`doc.command.insert-text`,type:t.CommandType.COMMAND,handler:async(e,n)=>{var r;let i=e.get(t.ICommandService),{range:a,segmentId:o,body:s,unitId:c,cursorOffset:l}=n,u=e.get(d),f=e.get(t.IUniverInstanceService).getUnit(c,t.UniverInstanceType.UNIVER_DOC);if(f==null)return!1;let p=u.getActiveTextRange(),m=f.getSelfOrHeaderFooterModel((r=p==null?void 0:p.segmentId)==null?``:r).getBody();if(m==null)return!1;let{startOffset:g,collapsed:_}=a,v=l==null?s.dataStream.length:l,y=[{startOffset:g+v,endOffset:g+v,style:p==null?void 0:p.style,collapsed:_}],b={id:h.id,params:{unitId:c,actions:[],textRanges:y,debounce:!0}},x=new t.TextX,S=t.JSONX.getInstance();if(_)g>0&&x.push({t:t.TextXActionType.RETAIN,len:g}),x.push({t:t.TextXActionType.INSERT,body:s,len:s.dataStream.length});else{let e=t.BuildTextUtils.selection.delete([a],m,0,s);x.push(...e)}b.params.textRanges=[{startOffset:g+v,endOffset:g+v,collapsed:_}];let C=(0,t.getRichTextEditPath)(f,o);return b.params.actions=S.editOp(x.serialize(),C),!!i.syncExecuteCommand(b.id,b.params)}},_={id:`doc.command.delete-text`,type:t.CommandType.COMMAND,handler:async(e,n)=>{var r;let i=e.get(t.ICommandService),a=e.get(t.IUniverInstanceService),{range:o,segmentId:s,unitId:c,direction:l,len:u=1}=n,d=a.getUnit(c,t.UniverInstanceType.UNIVER_DOC),f=d==null?void 0:d.getSelfOrHeaderFooterModel(s).getBody();if(d==null||f==null)return!1;let{startOffset:p}=o,m=l===t.DeleteDirection.LEFT?p-u:p,g=l===t.DeleteDirection.LEFT?p-1:p+u-1,_=(r=f.customRanges)==null?void 0:r.find(e=>e.startIndex<=m&&e.endIndex>=g);_!=null&&_.wholeEntity&&(m=_.startIndex,g=Math.max(g,_.endIndex));let v={id:h.id,params:{unitId:c,actions:[],textRanges:[{startOffset:m,endOffset:m,collapsed:!0}],debounce:!0}},y=new t.TextX,b=t.JSONX.getInstance();y.push({t:t.TextXActionType.RETAIN,len:m-0}),y.push({t:t.TextXActionType.DELETE,len:g-m+1});let x=(0,t.getRichTextEditPath)(d,s);return v.params.actions=b.editOp(y.serialize(),x),!!i.syncExecuteCommand(v.id,v.params)}},v={id:`doc.command.update-text`,type:t.CommandType.COMMAND,handler:async(e,n)=>{let{range:r,segmentId:i,updateBody:a,coverType:o,unitId:s,textRanges:c}=n,l=e.get(t.ICommandService),u=e.get(t.IUniverInstanceService).getCurrentUniverDocInstance();if(u==null)return!1;let d={id:h.id,params:{unitId:s,actions:[],textRanges:c}},f=new t.TextX,p=t.JSONX.getInstance(),{startOffset:m,endOffset:g}=r;f.push({t:t.TextXActionType.RETAIN,len:m}),f.push({t:t.TextXActionType.RETAIN,body:a,len:g-m,coverType:o});let _=(0,t.getRichTextEditPath)(u,i);return d.params.actions=p.editOp(f.serialize(),_),!!l.syncExecuteCommand(d.id,d.params)}};var y=`@univerjs/docs`,b=`0.25.0-insiders.20260604-29ebbff`;let x={id:`doc.mutation.rename-doc`,type:t.CommandType.MUTATION,handler:(e,n)=>{let r=e.get(t.IUniverInstanceService).getUnit(n.unitId,t.UniverInstanceType.UNIVER_DOC);return r?(r.setName(n.name),!0):!1}},S={},C=class extends t.Disposable{constructor(e,t,n){super(),this._commandService=e,this._textSelectionManagerService=t,this._univerInstanceService=n,this._initSelectionChange()}_transformCustomRange(e,n){var r;let{startOffset:i,endOffset:a,collapsed:o}=n,s=(r=e.getCustomRanges())==null?void 0:r.filter(e=>!e.wholeEntity||i<=e.startIndex&&a>e.endIndex?!1:o?e.startIndex<i&&e.endIndex>=a:t.BuildTextUtils.range.isIntersects(i,a-1,e.startIndex,e.endIndex));if(s!=null&&s.length){let e=i,t=a;return s.forEach(n=>{e=Math.min(n.startIndex,e),t=Math.max(n.endIndex+1,t)}),{...n,startOffset:e,endOffset:t,collapsed:e===t}}return n}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===i.id){let{unitId:t,ranges:n,isEditing:r}=e.params,i=this._univerInstanceService.getUnit(t);if(!i)return;let a=n.map(e=>this._transformCustomRange(i,e));a.some((e,t)=>n[t]!==e)&&this._textSelectionManagerService.replaceTextRanges(a,r)}}))}};C=u([l(0,t.ICommandService),l(1,(0,t.Inject)(d)),l(2,t.IUniverInstanceService)],C);var w=class extends t.Disposable{constructor(...e){super(...e),c(this,`_range`,null)}setInsertRange(e){this._range=e}consumeInsertRange(e){if(!this._range||e&&this._range.unitId!==e)return null;let t=this._range;return this._range=null,t}clearInsertRange(){this._range=null}};let T=class extends t.Plugin{constructor(e=S,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},S,this._config);this._configService.setConfig(`docs.config`,i)}onStarting(){this._initializeDependencies(),this._initializeCommands()}_initializeCommands(){[g,_,v,h,x,i].forEach(e=>{this._injector.get(t.ICommandService).registerCommand(e)})}_initializeDependencies(){[[d],[p],[w],[C]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(C)}};c(T,`pluginName`,`DOCS_PLUGIN`),c(T,`packageName`,y),c(T,`version`,b),T=u([l(1,(0,t.Inject)(t.Injector)),l(2,t.IConfigService)],T);let E={CUSTOM_RANGE:(0,t.createInterceptorKey)(`CUSTOM_RANGE`),CUSTOM_DECORATION:(0,t.createInterceptorKey)(`CUSTOM_DECORATION`)},D=class extends t.Disposable{constructor(e,n){super(),this._context=e,this._docSkeletonManagerService=n,c(this,`_interceptorsByName`,new Map);let r=this._docSkeletonManagerService.getViewModel(),i=r.getDataModel().getUnitId();if(i===t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY||i===t.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;this.disposeWithMe(this.interceptDocumentViewModel(r)),this.disposeWithMe(this.intercept(E.CUSTOM_RANGE,{priority:-1,handler:(e,t,n)=>n(e)}));let a=new t.DisposableCollection;r.segmentViewModels$.subscribe(e=>{a.dispose(),a=new t.DisposableCollection,e.forEach(e=>{a.add(this.interceptDocumentViewModel(e))})}),this.disposeWithMe(a)}intercept(e,n){let r=e;this._interceptorsByName.has(r)||this._interceptorsByName.set(r,[]);let i=this._interceptorsByName.get(r);return i.push(n),this._interceptorsByName.set(r,i.sort((e,t)=>{var n,r;return((n=t.priority)==null?0:n)-((r=e.priority)==null?0:r)})),this.disposeWithMe((0,t.toDisposable)(()=>(0,t.remove)(this._interceptorsByName.get(r),n)))}fetchThroughInterceptors(e){let n=e;return(0,t.composeInterceptors)(this._interceptorsByName.get(n)||[])}interceptDocumentViewModel(e){let n=new t.DisposableCollection;return n.add(e.registerCustomRangeInterceptor({getCustomRange:t=>{var n;return this.fetchThroughInterceptors(E.CUSTOM_RANGE)(e.getCustomRangeRaw(t),{index:t,unitId:e.getDataModel().getUnitId(),customRanges:(n=e.getDataModel().getCustomRanges())==null?[]:n})},getCustomDecoration:t=>{var n;return this.fetchThroughInterceptors(E.CUSTOM_DECORATION)(e.getCustomDecorationRaw(t),{index:t,unitId:e.getDataModel().getUnitId(),customDecorations:(n=e.getDataModel().getCustomDecorations())==null?[]:n})}})),n}};D=u([l(1,(0,t.Inject)(f))],D);function O(e,n,r){let{unitId:i,segmentId:a}=n,o=e.get(t.IUniverInstanceService).getUnit(i);if(!o)return!1;let s={id:h.id,params:{unitId:n.unitId,actions:[],textRanges:void 0}},c=t.JSONX.getInstance(),l=t.BuildTextUtils.customRange.add({...n,body:r});if(!l)return!1;let u=(0,t.getRichTextEditPath)(o,a);return s.params.actions=c.editOp(l.serialize(),u),s}function k(e,n){var r;let{rangeId:i,rangeType:a,wholeEntity:o,properties:s,unitId:c,selections:l}=n,u=e.get(d),f=e.get(t.IUniverInstanceService),p=l==null?u.getTextRanges({unitId:c,subUnitId:c}):l,m=p==null||(r=p[0])==null?void 0:r.segmentId;if(!(p!=null&&p.length))return!1;let g=f.getUnit(c,t.UniverInstanceType.UNIVER_DOC);if(!g)return!1;let _=g.getSelfOrHeaderFooterModel(m).getBody();if(!_)return!1;let v=t.BuildTextUtils.customRange.add({ranges:p,rangeId:i,rangeType:a,segmentId:m,wholeEntity:o,properties:s,body:_});if(!v)return!1;let y=t.JSONX.getInstance(),b={id:h.id,params:{unitId:c,actions:[],textRanges:v.selections,segmentId:m},textX:v},x=(0,t.getRichTextEditPath)(g,m);return b.params.actions=y.editOp(v.serialize(),x),b}function A(e,n){let{unitId:r,segmentId:i,insert:a}=n,o=e.get(t.IUniverInstanceService).getUnit(r);if(!o)return!1;let s={id:h.id,params:{unitId:n.unitId,actions:[],textRanges:void 0,segmentId:i}},c=t.JSONX.getInstance(),l=t.BuildTextUtils.customRange.delete({documentDataModel:o,rangeId:n.rangeId,insert:a,segmentId:i});if(!l)return!1;let u=(0,t.getRichTextEditPath)(o,i);return s.params.actions=c.editOp(l.serialize(),u),s.params.textRanges=l.selections,s}function j(e,n){var r,i,a,o;let{unitId:s,body:c,doc:l}=n,u=l;if(u||(u=e.get(t.IUniverInstanceService).getUnit(s)),!u)return!1;let f=(r=n.selection)==null?void 0:r.segmentId,p=(i=u.getSelfOrHeaderFooterModel(f))==null?void 0:i.getBody();if(!p)return!1;let m=e.get(d),g=(a=n.selection)==null?m.getActiveTextRange():a;if(!g||!p)return!1;let _=(o=n.textRanges)==null?[{startOffset:g.startOffset+c.dataStream.length,endOffset:g.startOffset+c.dataStream.length,collapsed:!0,segmentId:f}]:o,v=t.BuildTextUtils.selection.replace({selection:g,body:c,doc:u});if(!v)return!1;let y={id:h.id,params:{unitId:s,actions:[],textRanges:_,debounce:!0,segmentId:f},textX:v},b=t.JSONX.getInstance();return y.params.actions=b.editOp(v.serialize()),y}e.DOC_INTERCEPTOR_POINT=E,e.DeleteTextCommand=_,e.DocContentInsertService=w,Object.defineProperty(e,"DocInterceptorService",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"DocSelectionManagerService",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"DocSkeletonManagerService",{enumerable:!0,get:function(){return f}}),e.DocStateEmitService=p,e.InsertTextCommand=g,e.RichTextEditingMutation=h,e.SetTextSelectionsOperation=i,Object.defineProperty(e,"UniverDocsPlugin",{enumerable:!0,get:function(){return T}}),e.UpdateTextCommand=v,e.addCustomRangeBySelectionFactory=k,e.addCustomRangeFactory=O,e.deleteCustomRangeFactory=A,e.replaceSelectionFactory=j});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0-insiders.20260604-29ebbff",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Core document model and rich-text operations for Univer Docs.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -35,6 +35,16 @@
|
|
|
35
35
|
"require": "./lib/cjs/*",
|
|
36
36
|
"types": "./lib/types/index.d.ts"
|
|
37
37
|
},
|
|
38
|
+
"./facade": {
|
|
39
|
+
"import": "./lib/es/facade.js",
|
|
40
|
+
"require": "./lib/cjs/facade.js",
|
|
41
|
+
"types": "./lib/types/facade/index.d.ts"
|
|
42
|
+
},
|
|
43
|
+
"./lib/facade": {
|
|
44
|
+
"import": "./lib/es/facade.js",
|
|
45
|
+
"require": "./lib/cjs/facade.js",
|
|
46
|
+
"types": "./lib/types/facade/index.d.ts"
|
|
47
|
+
},
|
|
38
48
|
"./lib/*": "./lib/*"
|
|
39
49
|
},
|
|
40
50
|
"main": "./lib/es/index.js",
|
|
@@ -52,14 +62,14 @@
|
|
|
52
62
|
"rxjs": ">=7.0.0"
|
|
53
63
|
},
|
|
54
64
|
"dependencies": {
|
|
55
|
-
"@univerjs/core": "0.
|
|
56
|
-
"@univerjs/engine-render": "0.
|
|
65
|
+
"@univerjs/core": "0.25.0-insiders.20260604-29ebbff",
|
|
66
|
+
"@univerjs/engine-render": "0.25.0-insiders.20260604-29ebbff"
|
|
57
67
|
},
|
|
58
68
|
"devDependencies": {
|
|
59
69
|
"rxjs": "^7.8.2",
|
|
60
70
|
"typescript": "^6.0.3",
|
|
61
|
-
"vitest": "^4.1.
|
|
62
|
-
"@univerjs-infra/shared": "0.
|
|
71
|
+
"vitest": "^4.1.7",
|
|
72
|
+
"@univerjs-infra/shared": "0.25.0"
|
|
63
73
|
},
|
|
64
74
|
"scripts": {
|
|
65
75
|
"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
|