@univerjs/docs 0.1.0-alpha.1 → 0.1.0-alpha.3
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/LICENSE.txt +178 -0
- package/README.md +1 -1
- package/lib/cjs/index.js +2 -5928
- package/lib/es/index.js +2993 -0
- package/lib/types/basics/component-tools.d.ts +15 -1
- package/lib/types/basics/docs-view-key.d.ts +15 -1
- package/lib/types/basics/retain-delete-params.d.ts +15 -1
- package/lib/types/commands/commands/__tests__/clipboard.command.spec.d.ts +15 -1
- package/lib/types/commands/commands/__tests__/core-editing.command.spec.d.ts +15 -1
- package/lib/types/commands/commands/__tests__/create-command-test-bed.d.ts +15 -1
- package/lib/types/commands/commands/__tests__/inline-format.command.spec.d.ts +15 -1
- package/lib/types/commands/commands/__tests__/mock-text-selection-render-manager.d.ts +24 -0
- package/lib/types/commands/commands/__tests__/replace-content.command.spec.d.ts +15 -1
- package/lib/types/commands/commands/break-line.command.d.ts +17 -0
- package/lib/types/commands/commands/clipboard.command.d.ts +15 -1
- package/lib/types/commands/commands/clipboard.inner.command.d.ts +15 -1
- package/lib/types/commands/commands/core-editing.command.d.ts +18 -6
- package/lib/types/commands/commands/delete.command.d.ts +26 -0
- package/lib/types/commands/commands/ime-input.command.d.ts +15 -1
- package/lib/types/commands/commands/inline-format.command.d.ts +17 -1
- package/lib/types/commands/commands/insert-floating-object.command.d.ts +15 -1
- package/lib/types/commands/commands/list.command.d.ts +28 -0
- package/lib/types/commands/commands/remove-floating-object.command.d.ts +15 -1
- package/lib/types/commands/commands/replace-content.command.d.ts +15 -1
- package/lib/types/commands/commands/set-doc-zoom-ratio.command.d.ts +15 -1
- package/lib/types/commands/commands/set-floating-object-transform.command.d.ts +15 -1
- package/lib/types/commands/mutations/core-editing.mutation.d.ts +15 -1
- package/lib/types/commands/mutations/insert-floating-object.mutation.d.ts +15 -1
- package/lib/types/commands/mutations/remove-floating-object.mutation.d.ts +15 -1
- package/lib/types/commands/mutations/set-floating-object.mutation.d.ts +15 -1
- package/lib/types/commands/operations/cursor.operation.d.ts +15 -1
- package/lib/types/commands/operations/select-all.operation.d.ts +15 -1
- package/lib/types/commands/operations/set-doc-zoom-ratio.operation.d.ts +15 -1
- package/lib/types/commands/operations/text-selection.operation.d.ts +19 -3
- package/lib/types/controllers/clipboard.controller.d.ts +18 -4
- package/lib/types/controllers/doc-render.controller.d.ts +16 -3
- package/lib/types/controllers/floating-object.controller.d.ts +15 -1
- package/lib/types/controllers/ime-input.controller.d.ts +16 -4
- package/lib/types/controllers/inline-format.controller.d.ts +17 -6
- package/lib/types/controllers/move-cursor.controller.d.ts +17 -4
- package/lib/types/controllers/normal-input.controller.d.ts +16 -4
- package/lib/types/controllers/page-render.controller.d.ts +18 -3
- package/lib/types/controllers/text-selection.controller.d.ts +20 -6
- package/lib/types/controllers/zoom.controller.d.ts +15 -1
- package/lib/types/doc-plugin.d.ts +18 -4
- package/lib/types/index.d.ts +22 -4
- package/lib/types/services/clipboard/__test__/html-and-udm-convert.spec.d.ts +15 -1
- package/lib/types/services/clipboard/clipboard.service.d.ts +15 -1
- package/lib/types/services/clipboard/copy-content-cache.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-udm/converter.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-udm/parse-node-style.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-udm/parse-to-dom.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-lark.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-word.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/type.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-udm/utils.d.ts +15 -1
- package/lib/types/services/clipboard/udm-to-html/convertor.d.ts +15 -1
- package/lib/types/services/doc-skeleton-manager.service.d.ts +15 -1
- package/lib/types/services/doc-view-model-manager.service.d.ts +15 -1
- package/lib/types/services/ime-input-manager.service.d.ts +15 -1
- package/lib/types/services/text-selection-manager.service.d.ts +48 -32
- package/lib/types/shortcuts/core-editing.shortcut.d.ts +15 -1
- package/lib/types/shortcuts/cursor.shortcut.d.ts +15 -1
- package/lib/types/views/doc-canvas-view.d.ts +20 -3
- package/lib/umd/index.js +2 -0
- package/package.json +26 -25
- package/LICENSE +0 -21
- package/lib/cjs/locale/en-US.js +0 -26
- package/lib/cjs/locale/zh-CN.js +0 -26
- package/lib/esm/index.js +0 -5845
- package/lib/esm/locale/en-US.js +0 -5
- package/lib/esm/locale/zh-CN.js +0 -5
- package/lib/types/basics/component-tools.d.ts.map +0 -1
- package/lib/types/basics/demo-data.d.ts +0 -3
- package/lib/types/basics/demo-data.d.ts.map +0 -1
- package/lib/types/basics/docs-view-key.d.ts.map +0 -1
- package/lib/types/basics/retain-delete-params.d.ts.map +0 -1
- package/lib/types/commands/commands/__tests__/clipboard.command.spec.d.ts.map +0 -1
- package/lib/types/commands/commands/__tests__/core-editing.command.spec.d.ts.map +0 -1
- package/lib/types/commands/commands/__tests__/create-command-test-bed.d.ts.map +0 -1
- package/lib/types/commands/commands/__tests__/inline-format.command.spec.d.ts.map +0 -1
- package/lib/types/commands/commands/__tests__/replace-content.command.spec.d.ts.map +0 -1
- package/lib/types/commands/commands/clipboard.command.d.ts.map +0 -1
- package/lib/types/commands/commands/clipboard.inner.command.d.ts.map +0 -1
- package/lib/types/commands/commands/core-editing.command.d.ts.map +0 -1
- package/lib/types/commands/commands/ime-input.command.d.ts.map +0 -1
- package/lib/types/commands/commands/inline-format.command.d.ts.map +0 -1
- package/lib/types/commands/commands/insert-floating-object.command.d.ts.map +0 -1
- package/lib/types/commands/commands/remove-floating-object.command.d.ts.map +0 -1
- package/lib/types/commands/commands/replace-content.command.d.ts.map +0 -1
- package/lib/types/commands/commands/set-doc-zoom-ratio.command.d.ts.map +0 -1
- package/lib/types/commands/commands/set-floating-object-transform.command.d.ts.map +0 -1
- package/lib/types/commands/mutations/core-editing.mutation.d.ts.map +0 -1
- package/lib/types/commands/mutations/insert-floating-object.mutation.d.ts.map +0 -1
- package/lib/types/commands/mutations/remove-floating-object.mutation.d.ts.map +0 -1
- package/lib/types/commands/mutations/set-floating-object.mutation.d.ts.map +0 -1
- package/lib/types/commands/operations/cursor.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/select-all.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/set-doc-zoom-ratio.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/text-selection.operation.d.ts.map +0 -1
- package/lib/types/controllers/clipboard.controller.d.ts.map +0 -1
- package/lib/types/controllers/delete.controller.d.ts +0 -16
- package/lib/types/controllers/delete.controller.d.ts.map +0 -1
- package/lib/types/controllers/doc-render.controller.d.ts.map +0 -1
- package/lib/types/controllers/floating-object.controller.d.ts.map +0 -1
- package/lib/types/controllers/ime-input.controller.d.ts.map +0 -1
- package/lib/types/controllers/inline-format.controller.d.ts.map +0 -1
- package/lib/types/controllers/line-break-input.controller.d.ts +0 -20
- package/lib/types/controllers/line-break-input.controller.d.ts.map +0 -1
- package/lib/types/controllers/move-cursor.controller.d.ts.map +0 -1
- package/lib/types/controllers/normal-input.controller.d.ts.map +0 -1
- package/lib/types/controllers/page-render.controller.d.ts.map +0 -1
- package/lib/types/controllers/text-selection.controller.d.ts.map +0 -1
- package/lib/types/controllers/zoom.controller.d.ts.map +0 -1
- package/lib/types/doc-plugin.d.ts.map +0 -1
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/locale/en-US.d.ts +0 -3
- package/lib/types/locale/en-US.d.ts.map +0 -1
- package/lib/types/locale/index.d.ts +0 -3
- package/lib/types/locale/index.d.ts.map +0 -1
- package/lib/types/locale/zh-CN.d.ts +0 -3
- package/lib/types/locale/zh-CN.d.ts.map +0 -1
- package/lib/types/services/clipboard/__test__/html-and-udm-convert.spec.d.ts.map +0 -1
- package/lib/types/services/clipboard/clipboard.service.d.ts.map +0 -1
- package/lib/types/services/clipboard/copy-content-cache.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-udm/converter.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-udm/parse-node-style.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-udm/parse-to-dom.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-lark.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-word.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/type.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-udm/utils.d.ts.map +0 -1
- package/lib/types/services/clipboard/udm-to-html/convertor.d.ts.map +0 -1
- package/lib/types/services/doc-skeleton-manager.service.d.ts.map +0 -1
- package/lib/types/services/doc-view-model-manager.service.d.ts.map +0 -1
- package/lib/types/services/ime-input-manager.service.d.ts.map +0 -1
- package/lib/types/services/text-selection-manager.service.d.ts.map +0 -1
- package/lib/types/shortcuts/core-editing.shortcut.d.ts.map +0 -1
- package/lib/types/shortcuts/cursor.shortcut.d.ts.map +0 -1
- package/lib/types/views/doc-canvas-view.d.ts.map +0 -1
|
@@ -1,4 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
1
16
|
import type { IPastePlugin } from './type';
|
|
2
17
|
declare const wordPastePlugin: IPastePlugin;
|
|
3
18
|
export default wordPastePlugin;
|
|
4
|
-
//# sourceMappingURL=plugin-lark.d.ts.map
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
1
16
|
import type { IPastePlugin } from './type';
|
|
2
17
|
declare const wordPastePlugin: IPastePlugin;
|
|
3
18
|
export default wordPastePlugin;
|
|
4
|
-
//# sourceMappingURL=plugin-word.d.ts.map
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
1
16
|
import type { IDocumentBody, ITextStyle } from '@univerjs/core';
|
|
2
17
|
export interface IStyleRule {
|
|
3
18
|
filter: string | string[] | ((node: HTMLElement) => boolean);
|
|
@@ -13,4 +28,3 @@ export interface IPastePlugin {
|
|
|
13
28
|
stylesRules: IStyleRule[];
|
|
14
29
|
afterProcessRules: IAfterProcessRule[];
|
|
15
30
|
}
|
|
16
|
-
//# sourceMappingURL=type.d.ts.map
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
1
16
|
import type { IParagraphStyle, Nullable } from '@univerjs/core';
|
|
2
17
|
export declare function getParagraphStyle(el: HTMLElement): Nullable<IParagraphStyle>;
|
|
3
18
|
export declare function ptToPixel(pt: number): number;
|
|
4
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
1
16
|
import type { IDocumentBody } from '@univerjs/core';
|
|
2
17
|
export declare class UDMToHtmlService {
|
|
3
18
|
convert(bodyList: IDocumentBody[]): string;
|
|
4
19
|
}
|
|
5
|
-
//# sourceMappingURL=convertor.d.ts.map
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
1
16
|
import type { Nullable } from '@univerjs/core';
|
|
2
17
|
import { LocaleService } from '@univerjs/core';
|
|
3
18
|
import { DocumentSkeleton } from '@univerjs/engine-render';
|
|
@@ -33,4 +48,3 @@ export declare class DocSkeletonManagerService implements IDisposable {
|
|
|
33
48
|
getSkeletonByUnitId(unitId: string): Nullable<IDocSkeletonManagerParam>;
|
|
34
49
|
private _buildSkeleton;
|
|
35
50
|
}
|
|
36
|
-
//# sourceMappingURL=doc-skeleton-manager.service.d.ts.map
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
1
16
|
import type { Nullable } from '@univerjs/core';
|
|
2
17
|
import { IUniverInstanceService } from '@univerjs/core';
|
|
3
18
|
import { DocumentViewModel } from '@univerjs/engine-render';
|
|
@@ -22,4 +37,3 @@ export declare class DocViewModelManagerService implements IDisposable {
|
|
|
22
37
|
setCurrent(unitId: string): void;
|
|
23
38
|
private _buildDocViewModel;
|
|
24
39
|
}
|
|
25
|
-
//# sourceMappingURL=doc-view-model-manager.service.d.ts.map
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
1
16
|
import type { Nullable } from '@univerjs/core';
|
|
2
17
|
import type { ITextRangeWithStyle } from '@univerjs/engine-render';
|
|
3
18
|
import type { IDisposable } from '@wendellhu/redi';
|
|
@@ -16,4 +31,3 @@ export declare class IMEInputManagerService implements IDisposable {
|
|
|
16
31
|
} | null;
|
|
17
32
|
dispose(): void;
|
|
18
33
|
}
|
|
19
|
-
//# sourceMappingURL=ime-input-manager.service.d.ts.map
|
|
@@ -1,48 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { Nullable } from '@univerjs/core';
|
|
17
|
+
import { ICommandService, RxDisposable } from '@univerjs/core';
|
|
18
|
+
import type { INodePosition, ISuccinctTextRangeParam, ITextSelectionInnerParam, ITextSelectionStyle, RANGE_DIRECTION, TextRange } from '@univerjs/engine-render';
|
|
19
|
+
import { ITextSelectionRenderManager } from '@univerjs/engine-render';
|
|
20
|
+
interface ITextSelectionManagerSearchParam {
|
|
6
21
|
unitId: string;
|
|
22
|
+
subUnitId: string;
|
|
7
23
|
}
|
|
8
|
-
export interface
|
|
9
|
-
|
|
24
|
+
export interface ITextActiveRange {
|
|
25
|
+
startOffset: number;
|
|
26
|
+
endOffset: number;
|
|
27
|
+
collapsed: boolean;
|
|
28
|
+
startNodePosition: Nullable<INodePosition>;
|
|
29
|
+
endNodePosition: Nullable<INodePosition>;
|
|
30
|
+
direction: RANGE_DIRECTION;
|
|
31
|
+
segmentId: string;
|
|
32
|
+
style: ITextSelectionStyle;
|
|
33
|
+
}
|
|
34
|
+
interface ITextSelectionManagerInsertParam extends ITextSelectionManagerSearchParam, ITextSelectionInnerParam {
|
|
10
35
|
}
|
|
11
|
-
export type ITextSelectionInfo = Map<string, Map<string, TextRange[]>>;
|
|
12
36
|
/**
|
|
13
|
-
* This service is for selection.
|
|
37
|
+
* This service is for text selection.
|
|
14
38
|
*/
|
|
15
|
-
export declare class TextSelectionManagerService
|
|
16
|
-
private
|
|
39
|
+
export declare class TextSelectionManagerService extends RxDisposable {
|
|
40
|
+
private _textSelectionRenderManager;
|
|
41
|
+
private readonly _commandService;
|
|
17
42
|
private _currentSelection;
|
|
18
|
-
private readonly _textSelectionInfo
|
|
19
|
-
readonly
|
|
43
|
+
private readonly _textSelectionInfo;
|
|
44
|
+
private readonly _textSelection$;
|
|
45
|
+
readonly textSelection$: import("rxjs").Observable<Nullable<ITextSelectionManagerInsertParam>>;
|
|
46
|
+
constructor(_textSelectionRenderManager: ITextSelectionRenderManager, _commandService: ICommandService);
|
|
20
47
|
getCurrentSelection(): Nullable<ITextSelectionManagerSearchParam>;
|
|
48
|
+
getCurrentSelectionInfo(): ITextSelectionInnerParam | undefined;
|
|
21
49
|
dispose(): void;
|
|
22
50
|
refreshSelection(): void;
|
|
23
51
|
setCurrentSelection(param: ITextSelectionManagerSearchParam): void;
|
|
24
52
|
setCurrentSelectionNotRefresh(param: ITextSelectionManagerSearchParam): void;
|
|
25
|
-
getTextSelectionInfo(): Readonly<ITextSelectionInfo>;
|
|
26
|
-
getTextRangesByParam(param: Nullable<ITextSelectionManagerSearchParam>): Readonly<Nullable<TextRange[]>>;
|
|
27
53
|
getSelections(): Readonly<Nullable<TextRange[]>>;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
replaceTextRanges(textRanges: ITextRangeWithStyle[]): void;
|
|
34
|
-
replaceTextRangesWithNoRefresh(textRanges: TextRange[]): void;
|
|
35
|
-
private _addByParam;
|
|
36
|
-
private _clear;
|
|
37
|
-
private _remove;
|
|
38
|
-
private _reset;
|
|
39
|
-
private _resetPlugin;
|
|
54
|
+
getActiveRange(): Nullable<ITextActiveRange>;
|
|
55
|
+
add(textRanges: ISuccinctTextRangeParam[]): void;
|
|
56
|
+
replaceTextRanges(textRanges: ISuccinctTextRangeParam[]): void;
|
|
57
|
+
private _syncSelectionFromRenderService;
|
|
58
|
+
private _replaceTextRangesWithNoRefresh;
|
|
40
59
|
private _getTextRanges;
|
|
41
60
|
private _refresh;
|
|
42
|
-
private _getFirstByParam;
|
|
43
|
-
private _getLastByParam;
|
|
44
61
|
private _replaceByParam;
|
|
45
|
-
private
|
|
46
|
-
private _removeByParam;
|
|
62
|
+
private _addByParam;
|
|
47
63
|
}
|
|
48
|
-
|
|
64
|
+
export {};
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
1
16
|
import type { IShortcutItem } from '@univerjs/ui';
|
|
2
17
|
export declare const BreakLineShortcut: IShortcutItem;
|
|
3
18
|
export declare const DeleteLeftShortcut: IShortcutItem;
|
|
4
19
|
export declare const DeleteRightShortcut: IShortcutItem;
|
|
5
|
-
//# sourceMappingURL=core-editing.shortcut.d.ts.map
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
1
16
|
import type { IShortcutItem } from '@univerjs/ui';
|
|
2
17
|
export declare const MoveCursorUpShortcut: IShortcutItem;
|
|
3
18
|
export declare const MoveCursorDownShortcut: IShortcutItem;
|
|
@@ -8,4 +23,3 @@ export declare const MoveSelectionDownShortcut: IShortcutItem;
|
|
|
8
23
|
export declare const MoveSelectionLeftShortcut: IShortcutItem;
|
|
9
24
|
export declare const MoveSelectionRightShortcut: IShortcutItem;
|
|
10
25
|
export declare const SelectAllShortcut: IShortcutItem;
|
|
11
|
-
//# sourceMappingURL=cursor.shortcut.d.ts.map
|
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { IConfigService, IUniverInstanceService, RxDisposable } from '@univerjs/core';
|
|
2
17
|
import type { RenderManagerService } from '@univerjs/engine-render';
|
|
3
18
|
import { DocViewModelManagerService } from '../services/doc-view-model-manager.service';
|
|
4
|
-
export declare class DocCanvasView {
|
|
19
|
+
export declare class DocCanvasView extends RxDisposable {
|
|
5
20
|
private readonly _renderManagerService;
|
|
6
21
|
private readonly _configService;
|
|
7
22
|
private readonly _currentUniverService;
|
|
@@ -9,9 +24,11 @@ export declare class DocCanvasView {
|
|
|
9
24
|
private _scene;
|
|
10
25
|
private _currentDocumentModel;
|
|
11
26
|
private _loadedMap;
|
|
27
|
+
private readonly _fps$;
|
|
28
|
+
readonly fps$: import("rxjs").Observable<string>;
|
|
12
29
|
constructor(_renderManagerService: RenderManagerService, _configService: IConfigService, _currentUniverService: IUniverInstanceService, _docViewModelManagerService: DocViewModelManagerService);
|
|
13
30
|
private _initialize;
|
|
31
|
+
dispose(): void;
|
|
14
32
|
private _addNewRender;
|
|
15
33
|
private _addComponent;
|
|
16
34
|
}
|
|
17
|
-
//# sourceMappingURL=doc-canvas-view.d.ts.map
|
package/lib/umd/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(h,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/ui"),require("@wendellhu/redi")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","rxjs","@univerjs/ui","@wendellhu/redi"],o):(h=typeof globalThis<"u"?globalThis:h||self,o(h.UniverDocs={},h.UniverCore,h.UniverEngineRender,h.rxjs,h.UniverUi,h["@wendellhu/redi"]))})(this,function(h,o,M,z,T,b){"use strict";var Wn=Object.defineProperty;var Gn=(h,o,M)=>o in h?Wn(h,o,{enumerable:!0,configurable:!0,writable:!0,value:M}):h[o]=M;var C=(h,o,M)=>(Gn(h,typeof o!="symbol"?o+"":o,M),M);var ke;function q(r,t){const n=r.getCurrentUniverDocInstance().getUnitId(),i=t.getRenderById(n);if(i==null)return;const{mainComponent:s,scene:a,engine:c}=i;return{document:s,scene:a,engine:c}}function mt(r,t){const e=t.getRenderById(r);if(e==null)return;const{components:n,mainComponent:i,scene:s,engine:a}=e;return{document:i,scene:s,engine:a}}var ae=(r=>(r.MAIN="__Document_Render_Main__",r))(ae||{}),W=(r=>(r.VIEW_MAIN="viewMain",r.VIEW_TOP="viewTop",r.VIEW_LEFT="viewLeft",r.VIEW_LEFT_TOP="viewLeftTop",r))(W||{});const oe=0,ze=2,We=10,gt="normalTextSelectionPluginName",be={id:"doc.operation.set-selections",type:o.CommandType.OPERATION,handler:(r,t)=>!0};var ft=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,pt=(r,t,e,n)=>{for(var i=n>1?void 0:n?ht(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&ft(t,e,i),i},Ge=(r,t)=>(e,n)=>t(e,n,r);function He(r){const{startOffset:t,endOffset:e,collapsed:n}=r;return{startOffset:t,endOffset:e,collapsed:n}}h.TextSelectionManagerService=class extends o.RxDisposable{constructor(e,n){super();C(this,"_currentSelection",null);C(this,"_textSelectionInfo",new Map);C(this,"_textSelection$",new z.BehaviorSubject(null));C(this,"textSelection$",this._textSelection$.asObservable());this._textSelectionRenderManager=e,this._commandService=n,this._syncSelectionFromRenderService()}getCurrentSelection(){return this._currentSelection}getCurrentSelectionInfo(){return this._getTextRanges(this._currentSelection)}dispose(){this._textSelection$.complete()}refreshSelection(){this._currentSelection!=null&&this._refresh(this._currentSelection)}setCurrentSelection(e){this._currentSelection=e,this._refresh(e)}setCurrentSelectionNotRefresh(e){this._currentSelection=e}getSelections(){var e;return(e=this._getTextRanges(this._currentSelection))==null?void 0:e.textRanges}getActiveRange(){const e=this._getTextRanges(this._currentSelection);if(e==null)return;const{textRanges:n,segmentId:i,style:s}=e,a=n.find(m=>m.isActive());if(a==null)return null;const{startOffset:c,endOffset:l,collapsed:u,startNodePosition:d,endNodePosition:g,direction:f}=a;return c==null||l==null?null:{startOffset:c,endOffset:l,collapsed:u,startNodePosition:d,endNodePosition:g,direction:f,segmentId:i,style:s}}add(e){this._currentSelection!=null&&this._addByParam({...this._currentSelection,textRanges:e,segmentId:"",style:M.NORMAL_TEXT_SELECTION_PLUGIN_STYLE})}replaceTextRanges(e){this._currentSelection!=null&&(this._textSelectionRenderManager.removeAllTextRanges(),this._textSelectionRenderManager.addTextRanges(e))}_syncSelectionFromRenderService(){this._textSelectionRenderManager.textSelectionInner$.pipe(z.takeUntil(this.dispose$)).subscribe(e=>{e!=null&&this._replaceTextRangesWithNoRefresh(e)})}_replaceTextRangesWithNoRefresh(e){if(this._currentSelection==null)return;const n={...this._currentSelection,...e};this._replaceByParam(n),this._textSelection$.next(n);const{unitId:i,subUnitId:s,segmentId:a,style:c,textRanges:l}=n;this._commandService.executeCommand(be.id,{unitId:i,subUnitId:s,segmentId:a,style:c,ranges:l.map(He)})}_getTextRanges(e){var s;if(e==null)return;const{unitId:n,subUnitId:i=""}=e;return(s=this._textSelectionInfo.get(n))==null?void 0:s.get(i)}_refresh(e){const n=this._getTextRanges(e);this._textSelectionRenderManager.removeAllTextRanges(),n&&Array.isArray(n.textRanges)&&n.textRanges.length&&this._textSelectionRenderManager.addTextRanges(n.textRanges.map(He))}_replaceByParam(e){const{unitId:n,subUnitId:i,style:s,segmentId:a,textRanges:c}=e;this._textSelectionInfo.has(n)||this._textSelectionInfo.set(n,new Map),this._textSelectionInfo.get(n).set(i,{textRanges:c,style:s,segmentId:a})}_addByParam(e){const{unitId:n,subUnitId:i,textRanges:s,style:a,segmentId:c}=e;this._textSelectionInfo.has(n)||this._textSelectionInfo.set(n,new Map);const l=this._textSelectionInfo.get(n);l.has(i)?l.get(i).textRanges.push(...s):l.set(i,{textRanges:s,style:a,segmentId:c})}},h.TextSelectionManagerService=pt([Ge(0,M.ITextSelectionRenderManager),Ge(1,o.ICommandService)],h.TextSelectionManagerService);function ce(r,t="",e=0){const{startOffset:n,endOffset:i}=r,s=[],a=n-e,c=i-e;return a>0&&s.push({t:"r",len:a,segmentId:t}),s.push({t:"d",len:c-a,line:0,segmentId:t}),s}var St=Object.defineProperty,_t=Object.getOwnPropertyDescriptor,vt=(r,t,e,n)=>{for(var i=n>1?void 0:n?_t(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&St(t,e,i),i},Ct=(r,t)=>(e,n)=>t(e,n,r);h.DocViewModelManagerService=class{constructor(t){C(this,"_currentViewModelUnitId","");C(this,"_docViewModelMap",new Map);C(this,"_currentDocViewModel$",new z.BehaviorSubject(null));C(this,"currentDocViewModel$",this._currentDocViewModel$.asObservable());this._currentUniverService=t}dispose(){this._currentDocViewModel$.complete(),this._docViewModelMap=new Map}getCurrent(){return this._docViewModelMap.get(this._currentViewModelUnitId)}getViewModel(t){var e;return(e=this._docViewModelMap.get(t))==null?void 0:e.docViewModel}setCurrent(t){var n;const e=this._currentUniverService.getUniverDocInstance(t);if(e==null)throw new Error(`Document data model with id ${t} not found when build view model.`);if(e.getBody()!=null){if(!this._docViewModelMap.has(t)){const i=this._buildDocViewModel(e);this._docViewModelMap.set(t,{unitId:t,docViewModel:i})}if(t===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY){const i=(n=this._docViewModelMap.get(t))==null?void 0:n.docViewModel;if(i==null)return;i.reset(e)}this._currentViewModelUnitId=t,this._currentDocViewModel$.next(this.getCurrent())}}_buildDocViewModel(t){return new M.DocumentViewModel(t)}},h.DocViewModelManagerService=vt([Ct(0,o.IUniverInstanceService)],h.DocViewModelManagerService);const v={id:"doc.mutation.rich-text-editing",type:o.CommandType.MUTATION,handler:(r,t)=>{const{unitId:e,mutations:n}=t,s=r.get(o.IUniverInstanceService).getUniverDocInstance(e),c=r.get(h.DocViewModelManagerService).getViewModel(e);if(s==null||c==null)throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${e}`);const l=s.apply(n),u=n[0].segmentId,d=s.getSelfOrHeaderFooterModel(u);return c.getSelfOrHeaderFooterViewModel(u).reset(d),{unitId:e,mutations:l}}},le={id:"doc.command.insert-text",type:o.CommandType.COMMAND,handler:async(r,t)=>{const e=r.get(o.IUndoRedoService),n=r.get(o.ICommandService),i=r.get(h.TextSelectionManagerService),{range:s,segmentId:a,body:c,unitId:l,textRanges:u}=t,{startOffset:d,collapsed:g}=s,f={id:v.id,params:{unitId:l,mutations:[]}};g?f.params.mutations.push({t:"r",len:d,segmentId:a}):f.params.mutations.push(...ce(s,a)),f.params.mutations.push({t:"i",body:c,len:c.dataStream.length,line:0,segmentId:a});const m=n.syncExecuteCommand(f.id,f.params);return i.replaceTextRanges(u),m?(e.pushUndoRedo({unitID:l,undoMutations:[{id:v.id,params:m}],redoMutations:[{id:v.id,params:f.params}],undo(){return n.syncExecuteCommand(v.id,m),i.replaceTextRanges([s]),!0},redo(){return n.syncExecuteCommand(v.id,f.params),i.replaceTextRanges(u),!0}}),!0):!1}};var L=(r=>(r[r.LEFT=0]="LEFT",r[r.RIGHT=1]="RIGHT",r))(L||{});const de={id:"doc.command.delete-text",type:o.CommandType.COMMAND,handler:async(r,t)=>{const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(h.TextSelectionManagerService),{range:s,segmentId:a,unitId:c,direction:l,textRanges:u,len:d=1}=t,{startOffset:g}=s,f={id:v.id,params:{unitId:c,mutations:[]}};g>0&&f.params.mutations.push({t:"r",len:l===0?g-d:g,segmentId:a}),f.params.mutations.push({t:"d",len:d,line:0,segmentId:a});const m=e.syncExecuteCommand(f.id,f.params);return i.replaceTextRanges(u),m&&n.pushUndoRedo({unitID:c,undoMutations:[{id:v.id,params:m}],redoMutations:[{id:v.id,params:f.params}],undo(){return e.syncExecuteCommand(v.id,m),i.replaceTextRanges([s]),!0},redo(){return e.syncExecuteCommand(v.id,f.params),i.replaceTextRanges(u),!0}}),!1}},xe={id:"doc.command.update-text",type:o.CommandType.COMMAND,handler:async(r,t)=>{const{range:e,segmentId:n,updateBody:i,coverType:s,unitId:a,textRanges:c}=t,l=r.get(o.ICommandService),u=r.get(o.IUndoRedoService),d=r.get(h.TextSelectionManagerService),g={id:v.id,params:{unitId:a,mutations:[]}},{startOffset:f,endOffset:m}=e;g.params.mutations.push({t:"r",len:f,segmentId:n}),g.params.mutations.push({t:"r",body:i,len:m-f,segmentId:n,coverType:s});const p=l.syncExecuteCommand(g.id,g.params);return d.replaceTextRanges(c),p?(u.pushUndoRedo({unitID:a,undoMutations:[{id:v.id,params:p}],redoMutations:[{id:v.id,params:g.params}],undo(){return l.syncExecuteCommand(v.id,p),d.replaceTextRanges(c),!0},redo(){return l.syncExecuteCommand(v.id,g.params),d.replaceTextRanges(c),!0}}),!0):!1}};function It(r,t){const e=[];for(let n=0,i=r.length;n<i;n++)r[n]===o.DataStreamTreeTokenType.PARAGRAPH&&e.push({startIndex:n});if(t)for(const n of e)t.bullet&&(n.bullet=o.Tools.deepClone(t.bullet)),t.paragraphStyle&&(n.paragraphStyle=o.Tools.deepClone(t.paragraphStyle));return e}const Ue={id:"doc.command.break-line",type:o.CommandType.COMMAND,handler:async r=>{var p;const t=r.get(h.TextSelectionManagerService),e=r.get(o.IUniverInstanceService),n=r.get(o.ICommandService),i=t.getActiveRange();if(i==null)return!1;const s=e.getCurrentUniverDocInstance(),a=s.getUnitId(),{startOffset:c,segmentId:l,style:u}=i,d=[{startOffset:c+1,endOffset:c+1,style:u}],f=(((p=s.getBody())==null?void 0:p.paragraphs)??[]).find(S=>S.startIndex>=c);return await n.executeCommand(le.id,{unitId:a,body:{dataStream:o.DataStreamTreeTokenType.PARAGRAPH,paragraphs:It(o.DataStreamTreeTokenType.PARAGRAPH,f)},range:i,textRanges:d,segmentId:l})}},ue={id:T.CopyCommand.id,name:"doc.command.copy",type:o.CommandType.COMMAND,multi:!0,priority:999,preconditions:r=>r.getContextValue(o.FOCUSING_DOC)||r.getContextValue(o.FOCUSING_EDITOR),handler:async()=>!0},me={id:T.CutCommand.id,name:"doc.command.cut",type:o.CommandType.COMMAND,multi:!0,priority:999,preconditions:r=>r.getContextValue(o.FOCUSING_DOC)||r.getContextValue(o.FOCUSING_EDITOR),handler:async()=>!0},ge={id:T.PasteCommand.id,name:"doc.command.paste",type:o.CommandType.COMMAND,multi:!0,priority:999,preconditions:r=>r.getContextValue(o.FOCUSING_DOC)||r.getContextValue(o.FOCUSING_EDITOR),handler:async()=>!0};var Mt=Object.defineProperty,Ot=Object.getOwnPropertyDescriptor,Rt=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ot(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Mt(t,e,i),i},Ke=(r,t)=>(e,n)=>t(e,n,r);h.DocSkeletonManagerService=class{constructor(t,e){C(this,"_currentSkeletonUnitId","");C(this,"_docSkeletonMap",new Map);C(this,"_currentSkeleton$",new z.BehaviorSubject(null));C(this,"currentSkeleton$",this._currentSkeleton$.asObservable());C(this,"_currentSkeletonBefore$",new z.BehaviorSubject(null));C(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._localeService=t,this._docViewModelManagerService=e,this.initialize()}initialize(){this._docViewModelManagerService.currentDocViewModel$.subscribe(t=>{t!=null&&this._setCurrent(t)})}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._docSkeletonMap=new Map}getCurrent(){return this.getSkeletonByUnitId(this._currentSkeletonUnitId)}makeDirtyCurrent(t=!0){this.makeDirty(this._currentSkeletonUnitId,t)}makeDirty(t,e=!0){const n=this.getSkeletonByUnitId(t);n!=null&&(n.dirty=e)}_setCurrent(t){const{unitId:e}=t;if(this._docSkeletonMap.has(e)){const n=this.getSkeletonByUnitId(e);n.skeleton.calculate(),n.dirty=!0}else{const n=this._buildSkeleton(t.docViewModel);n.calculate(),this._docSkeletonMap.set(e,{unitId:e,skeleton:n,dirty:!1})}return this._currentSkeletonUnitId=e,this._currentSkeletonBefore$.next(this.getCurrent()),this._currentSkeleton$.next(this.getCurrent()),this.getCurrent()}getSkeletonByUnitId(t){return this._docSkeletonMap.get(t)}_buildSkeleton(t){return M.DocumentSkeleton.create(t,this._localeService)}},h.DocSkeletonManagerService=Rt([Ke(0,b.Inject(o.LocaleService)),Ke(1,b.Inject(h.DocViewModelManagerService))],h.DocSkeletonManagerService);const Ye={id:"doc.command.inner-paste",type:o.CommandType.COMMAND,handler:async(r,t)=>{const{segmentId:e,body:n,textRanges:i}=t,s=r.get(o.IUndoRedoService),a=r.get(o.ICommandService),c=r.get(h.TextSelectionManagerService),l=r.get(o.IUniverInstanceService),u=c.getSelections();if(!Array.isArray(u)||u.length===0)return!1;const g=l.getCurrentUniverDocInstance().getUnitId(),f={id:v.id,params:{unitId:g,mutations:[]}},m=new o.MemoryCursor;m.reset();for(const S of u){const{startOffset:_,endOffset:I,collapsed:O}=S,x=_-m.cursor;O?f.params.mutations.push({t:"r",len:x,segmentId:e}):f.params.mutations.push(...ce(S,e,m.cursor)),f.params.mutations.push({t:"i",body:n,len:n.dataStream.length,line:0,segmentId:e}),m.reset(),m.moveCursor(I)}const p=a.syncExecuteCommand(f.id,f.params);return c.replaceTextRanges(i),p?(s.pushUndoRedo({unitID:g,undoMutations:[{id:v.id,params:p}],redoMutations:[{id:v.id,params:f.params}],undo(){return a.syncExecuteCommand(v.id,p),c.replaceTextRanges(u),!0},redo(){return a.syncExecuteCommand(v.id,f.params),c.replaceTextRanges(i),!0}}),!0):!1}},fe={id:"doc.command.inner-cut",type:o.CommandType.COMMAND,handler:async(r,t)=>{const{segmentId:e,textRanges:n}=t,i=r.get(o.IUndoRedoService),s=r.get(o.ICommandService),a=r.get(h.TextSelectionManagerService),c=r.get(o.IUniverInstanceService),l=a.getSelections();if(!Array.isArray(l)||l.length===0)return!1;const u=c.getCurrentUniverDocInstance().getUnitId(),d=c.getUniverDocInstance(u),g=o.getDocsUpdateBody(d.snapshot,e);if(g==null)return!1;const f={id:v.id,params:{unitId:u,mutations:[]}},m=new o.MemoryCursor;m.reset();for(const S of l){const{startOffset:_,endOffset:I,collapsed:O}=S,x=_-m.cursor;O?f.params.mutations.push({t:"r",len:x,segmentId:e}):f.params.mutations.push(...yt(S,g,e,m.cursor)),m.reset(),m.moveCursor(I)}const p=s.syncExecuteCommand(f.id,f.params);return a.replaceTextRanges(n),p?(i.pushUndoRedo({unitID:u,undoMutations:[{id:v.id,params:p}],redoMutations:[{id:v.id,params:f.params}],undo(){return s.syncExecuteCommand(v.id,p),a.replaceTextRanges(l),!0},redo(){return s.syncExecuteCommand(v.id,f.params),a.replaceTextRanges(n),!0}}),!0):!1}};function yt(r,t,e="",n=0){const{startOffset:i,endOffset:s}=r,a=[],{paragraphs:c=[]}=t,l=i-n,u=s-n,d=c==null?void 0:c.find(g=>g.startIndex-n>=l&&g.startIndex-n<=u);if(l>0&&a.push({t:"r",len:l,segmentId:e}),d&&d.startIndex-n>l){const g=d.startIndex-n;a.push({t:"d",len:g-l,line:0,segmentId:e}),a.push({t:"r",len:1,segmentId:e}),u>g+1&&a.push({t:"d",len:u-g-1,line:0,segmentId:e})}else a.push({t:"d",len:u-l,line:0,segmentId:e});return a}const Ee={id:"doc.command.delete-left",type:o.CommandType.COMMAND,handler:async r=>{var D;const t=r.get(h.TextSelectionManagerService),e=r.get(h.DocSkeletonManagerService),n=r.get(o.IUniverInstanceService),i=r.get(o.ICommandService),s=t.getActiveRange(),a=t.getSelections(),c=(D=e.getCurrent())==null?void 0:D.skeleton;let l;if(s==null||c==null||a==null)return!1;const u=n.getCurrentUniverDocInstance(),{startOffset:d,collapsed:g,segmentId:f,style:m}=s;if(d===0&&g)return!0;const p=c.findNodeByCharIndex(d),S=M.hasListSpan(p),_=M.isIndentBySpan(p,u.body);let I=d;const O=c.findNodeByCharIndex(d-1);if(M.isFirstSpan(p)&&O!==p&&(S===!0||_===!0)){const R=M.getParagraphBySpan(p,u.body);if(R==null)return!1;const U=R==null?void 0:R.startIndex,E={startIndex:0},P=R.paragraphStyle;if(S===!0){const y=R.paragraphStyle;y&&(E.paragraphStyle=y)}else if(_===!0){const y=R.bullet;y&&(E.bullet=y),P!=null&&(E.paragraphStyle={...P},delete E.paragraphStyle.hanging,delete E.paragraphStyle.indentStart)}const w=[{startOffset:I,endOffset:I,style:m}];l=await i.executeCommand(xe.id,{unitId:u.getUnitId(),updateBody:{dataStream:"",paragraphs:[{...E}]},range:{startOffset:U,endOffset:U+1},textRanges:w,coverType:o.UpdateDocsAttributeType.REPLACE,segmentId:f})}else if(g===!0)if(O.content==="\r")l=await i.executeCommand(we.id,{direction:L.LEFT,range:s});else{I-=O.count;const R=[{startOffset:I,endOffset:I,style:m}];l=await i.executeCommand(de.id,{unitId:u.getUnitId(),range:s,segmentId:f,direction:L.LEFT,len:O.count,textRanges:R})}else{const R=Xe(s,a);l=await i.executeCommand(fe.id,{segmentId:f,textRanges:R})}return l}},Pe={id:"doc.command.delete-right",type:o.CommandType.COMMAND,handler:async r=>{var p;const t=r.get(h.TextSelectionManagerService),e=r.get(h.DocSkeletonManagerService),n=r.get(o.IUniverInstanceService),i=r.get(o.ICommandService),s=t.getActiveRange(),a=t.getSelections(),c=(p=e.getCurrent())==null?void 0:p.skeleton;let l;if(s==null||c==null||a==null)return!1;const u=n.getCurrentUniverDocInstance(),{startOffset:d,collapsed:g,segmentId:f,style:m}=s;if(d===u.getBody().dataStream.length-2&&g)return!0;if(g===!0){const S=c.findNodeByCharIndex(d);if(S.content==="\r")l=await i.executeCommand(we.id,{direction:L.RIGHT,range:s});else{const _=[{startOffset:d,endOffset:d,style:m}];l=await i.executeCommand(de.id,{unitId:u.getUnitId(),range:s,segmentId:f,direction:L.RIGHT,textRanges:_,len:S.count})}}else{const S=Xe(s,a);l=await i.executeCommand(fe.id,{segmentId:f,textRanges:S})}return l}},we={id:"doc.command.merge-two-paragraph",type:o.CommandType.COMMAND,handler:async(r,t)=>{var E,P,w;const e=r.get(h.TextSelectionManagerService),n=r.get(o.IUniverInstanceService),i=r.get(o.ICommandService),s=r.get(o.IUndoRedoService),{direction:a,range:c}=t,l=e.getActiveRange(),u=e.getSelections();if(l==null||u==null)return!1;const d=n.getCurrentUniverDocInstance(),{startOffset:g,collapsed:f,segmentId:m,style:p}=l;if(!f)return!1;const S=a===L.LEFT?g:g+1,_=(w=(P=(E=d.getBody())==null?void 0:E.paragraphs)==null?void 0:P.find(y=>y.startIndex>=S))==null?void 0:w.startIndex,I=Dt(d.getBody(),S,_),O=a===L.LEFT?g-1:g,x=d.getUnitId(),D=[{startOffset:O,endOffset:O,style:p}],R={id:v.id,params:{unitId:x,mutations:[]}};R.params.mutations.push({t:"r",len:a===L.LEFT?g-1:g,segmentId:m}),I.dataStream.length&&R.params.mutations.push({t:"i",body:I,len:I.dataStream.length,line:0,segmentId:m}),R.params.mutations.push({t:"r",len:1,segmentId:m}),R.params.mutations.push({t:"d",len:_+1-S,line:0,segmentId:m});const U=i.syncExecuteCommand(R.id,R.params);return e.replaceTextRanges(D),U?(s.pushUndoRedo({unitID:x,undoMutations:[{id:v.id,params:U}],redoMutations:[{id:v.id,params:R.params}],undo(){return i.syncExecuteCommand(v.id,U),e.replaceTextRanges([c]),!0},redo(){return i.syncExecuteCommand(v.id,R.params),e.replaceTextRanges(D),!0}}),!0):!1}};function Dt(r,t,e){const{textRuns:n}=r,i=r.dataStream.substring(t,e);if(n==null)return{dataStream:i};const s=[];for(const a of n){const{st:c,ed:l}=a;l<=t||c>=e||(c<t?s.push({...a,st:0,ed:l-t}):l>e?s.push({...a,st:c-t,ed:e-t}):s.push({...a,st:c-t,ed:l-t}))}return{dataStream:i,textRuns:s}}function Xe(r,t){let e=r.endOffset;for(const i of t){const{startOffset:s,endOffset:a}=i;s==null||a==null||a<=r.endOffset&&(e-=a-s)}return[{startOffset:e,endOffset:e,style:r.style}]}class Ne{constructor(){C(this,"_previousActiveRange",null);C(this,"_undoMutationParamsCache",[]);C(this,"_redoMutationParamsCache",[])}clearUndoRedoMutationParamsCache(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[]}setActiveRange(t){this._previousActiveRange=t}pushUndoRedoMutationParams(t,e){this._undoMutationParamsCache.push(t),this._redoMutationParamsCache.push(e)}fetchComposedUndoRedoMutationParams(t){if(this._undoMutationParamsCache.length===0||this._previousActiveRange==null)return null;const{unitId:e}=this._undoMutationParamsCache[0],{segmentId:n,startOffset:i,collapsed:s}=this._previousActiveRange,a={unitId:e,mutations:[]},c={unitId:e,mutations:[]};return s?(a.mutations.push({t:"r",len:i,segmentId:n}),c.mutations.push({t:"r",len:i,segmentId:n})):(i>0&&a.mutations.push({t:"r",len:i,segmentId:n}),a.mutations.push(this._undoMutationParamsCache[0].mutations.find(l=>l.t==="i")),c.mutations.push(...ce(this._previousActiveRange,n))),t.length&&(a.mutations.push({t:"d",len:t.length,line:0,segmentId:n}),c.mutations.push({t:"i",body:{dataStream:t},len:t.length,line:0,segmentId:n})),{redoMutationParams:c,undoMutationParams:a,previousActiveRange:this._previousActiveRange}}dispose(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[],this._previousActiveRange=null}}const Le={id:"doc.command.ime-input",type:o.CommandType.COMMAND,handler:async(r,t)=>{const{unitId:e,newText:n,oldTextLen:i,range:s,segmentId:a,textRanges:c,isCompositionEnd:l}=t,u=r.get(o.ICommandService),d=r.get(o.IUndoRedoService),g=r.get(h.TextSelectionManagerService),f=r.get(Ne),m={id:v.id,params:{unitId:e,mutations:[]}};s.collapsed?m.params.mutations.push({t:"r",len:s.startOffset,segmentId:a}):m.params.mutations.push(...ce(s,a)),i>0&&m.params.mutations.push({t:"d",len:i,line:0,segmentId:a}),m.params.mutations.push({t:"i",body:{dataStream:n},len:n.length,line:0,segmentId:a});const p=u.syncExecuteCommand(m.id,m.params);if(f.pushUndoRedoMutationParams(p,m.params),g.replaceTextRanges(c),l){if(p){const S=f.fetchComposedUndoRedoMutationParams(n);if(S==null)return!1;const{undoMutationParams:_,redoMutationParams:I,previousActiveRange:O}=S;return d.pushUndoRedo({unitID:e,undoMutations:[{id:v.id,params:_}],redoMutations:[{id:v.id,params:I}],undo(){return u.syncExecuteCommand(v.id,_),g.replaceTextRanges([O]),!0},redo(){return u.syncExecuteCommand(v.id,I),g.replaceTextRanges(c),!0}}),!0}}else return!!p;return!1}},G={id:"doc.command.set-inline-format-bold",type:o.CommandType.COMMAND,handler:async()=>!0},Z={id:"doc.command.set-inline-format-italic",type:o.CommandType.COMMAND,handler:async()=>!0},J={id:"doc.command.set-inline-format-underline",type:o.CommandType.COMMAND,handler:async()=>!0},Q={id:"doc.command.set-inline-format-strikethrough",type:o.CommandType.COMMAND,handler:async()=>!0},A={id:"doc.command.set-inline-format-subscript",type:o.CommandType.COMMAND,handler:async()=>!0},j={id:"doc.command.set-inline-format-superscript",type:o.CommandType.COMMAND,handler:async()=>!0},H={id:"doc.command.set-inline-format-fontsize",type:o.CommandType.COMMAND,handler:async()=>!0},K={id:"doc.command.set-inline-format-font-family",type:o.CommandType.COMMAND,handler:async()=>!0},ee={id:"doc.command.set-inline-format-text-color",type:o.CommandType.COMMAND,handler:async()=>!0},qe={[G.id]:"bl",[Z.id]:"it",[J.id]:"ul",[Q.id]:"st",[H.id]:"fs",[K.id]:"ff",[ee.id]:"cl",[A.id]:"va",[j.id]:"va"},Ae={id:"doc.command.set-inline-format",type:o.CommandType.COMMAND,handler:async(r,t)=>{const{segmentId:e,value:n,preCommandId:i}=t,s=r.get(o.IUndoRedoService),a=r.get(o.ICommandService),c=r.get(h.TextSelectionManagerService),l=r.get(o.IUniverInstanceService),u=c.getSelections();if(!Array.isArray(u)||u.length===0)return!1;let d=l.getCurrentUniverDocInstance(),g=d.getUnitId();g===o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(d=l.getUniverDocInstance(o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),g=d.getUnitId());let f;switch(i){case G.id:case Z.id:case J.id:case Q.id:case A.id:case j.id:{f=bt(d.getBody().textRuns,i,u);break}case H.id:case K.id:{f=n;break}case ee.id:{f={rgb:n};break}default:throw new Error(`Unknown command: ${i} in handleInlineFormat`)}const m={id:v.id,params:{unitId:g,mutations:[]}},p=new o.MemoryCursor;p.reset();for(const I of u){const{startOffset:O,endOffset:x}=I,D={dataStream:"",textRuns:[{st:0,ed:x-O,ts:{[qe[i]]:f}}]},R=O-p.cursor;R!==0&&m.params.mutations.push({t:"r",len:R,segmentId:e}),m.params.mutations.push({t:"r",body:D,len:x-O,segmentId:e}),p.reset(),p.moveCursor(x)}const S=a.syncExecuteCommand(m.id,m.params),_=[G.id,H.id,K.id,A.id,j.id];return _.includes(i)&&c.refreshSelection(),S?(s.pushUndoRedo({unitID:g,undoMutations:[{id:v.id,params:S}],redoMutations:[{id:v.id,params:m.params}],undo(){return a.syncExecuteCommand(v.id,S),_.includes(i)&&c.refreshSelection(),!0},redo(){return a.syncExecuteCommand(v.id,m.params),_.includes(i)&&c.refreshSelection(),!0}}),!0):!1}};function Tt(r){return r!==null&&typeof r=="object"}function bt(r,t,e){let n=0,i=0;const s=qe[t];for(;n!==r.length&&i!==e.length;){const{startOffset:a,endOffset:c}=e[i],{st:l,ed:u,ts:d}=r[n];if(c<=l)i++;else if(u<=a)n++;else{if((d==null?void 0:d[s])==null){if(/bl|it/.test(s))return o.BooleanNumber.TRUE;if(/ul|st/.test(s))return{s:o.BooleanNumber.TRUE};if(/va/.test(s))return t===A.id?o.BaselineOffset.SUBSCRIPT:o.BaselineOffset.SUPERSCRIPT}if(Tt(d==null?void 0:d[s])&&d[s].s===o.BooleanNumber.FALSE)return{s:o.BooleanNumber.TRUE};if(t===A.id&&(d==null?void 0:d[s])!==o.BaselineOffset.SUBSCRIPT)return o.BaselineOffset.SUBSCRIPT;if(t===j.id&&(d==null?void 0:d[s])!==o.BaselineOffset.SUPERSCRIPT)return o.BaselineOffset.SUPERSCRIPT;if((d==null?void 0:d[s])===o.BooleanNumber.FALSE)return o.BooleanNumber.TRUE;n++}}return/bl|it/.test(s)?o.BooleanNumber.FALSE:/ul|st/.test(s)?{s:o.BooleanNumber.FALSE}:o.BaselineOffset.NORMAL}const Ze={id:"doc.command.bullet-list",type:o.CommandType.COMMAND,handler:r=>r.get(o.ICommandService).syncExecuteCommand(Be.id,{listType:o.PresetListType.BULLET_LIST})},Je={id:"doc.command.order-list",type:o.CommandType.COMMAND,handler:r=>r.get(o.ICommandService).syncExecuteCommand(Be.id,{listType:o.PresetListType.ORDER_LIST})},Be={id:"doc.command.list-operation",type:o.CommandType.COMMAND,handler:(r,t)=>{var x;const e=r.get(h.TextSelectionManagerService),n=r.get(o.IUniverInstanceService),i=r.get(o.ICommandService),s=r.get(o.IUndoRedoService),{listType:a}=t,c=n.getCurrentUniverDocInstance(),l=e.getActiveRange(),u=(x=c.getBody())==null?void 0:x.paragraphs;if(l==null||u==null)return!1;const d=xt(l,u),{segmentId:g}=l,f=c.getUnitId(),m=d.every(D=>{var R;return((R=D.bullet)==null?void 0:R.listType)===a}),p=6;let S=o.Tools.generateRandomId(p);if(d.length===1){const D=u.indexOf(d[0]),R=u[D-1],U=u[D+1];R&&R.bullet&&R.bullet.listType===a?S=R.bullet.listId:U&&U.bullet&&U.bullet.listType===a&&(S=U.bullet.listId)}const _={id:v.id,params:{unitId:f,mutations:[]}},I=new o.MemoryCursor;I.reset();for(const D of d){const{startIndex:R}=D;_.params.mutations.push({t:"r",len:R-I.cursor,segmentId:g});const U={...D.paragraphStyle,hanging:void 0,indentStart:void 0};_.params.mutations.push({t:"r",len:1,body:{dataStream:"",paragraphs:[m?{paragraphStyle:U,startIndex:0}:{...D,startIndex:0,bullet:{...D.bullet??{nestingLevel:0,textStyle:{fs:20}},listType:a,listId:S}}]},segmentId:g,coverType:o.UpdateDocsAttributeType.REPLACE}),I.moveCursorTo(R+1)}const O=i.syncExecuteCommand(_.id,_.params);return e.refreshSelection(),O&&s.pushUndoRedo({unitID:f,undoMutations:[{id:v.id,params:O}],redoMutations:[{id:v.id,params:_.params}],undo(){return i.syncExecuteCommand(v.id,O),e.refreshSelection(),!0},redo(){return i.syncExecuteCommand(v.id,_.params),e.refreshSelection(),!0}}),!0}};function xt(r,t){const{startOffset:e,endOffset:n}=r,i=[];let s=0;for(const a of t){const{startIndex:c}=a;(e>s&&e<=c||n>s&&n<=c||c>=e&&c<=n)&&i.push(a),s=c}return i}const Qe={id:"doc.command-replace-content",type:o.CommandType.COMMAND,handler:async(r,t)=>{var p;const{unitId:e,body:n,textRanges:i,segmentId:s=""}=t,a=r.get(o.IUniverInstanceService),c=r.get(o.ICommandService),l=r.get(h.TextSelectionManagerService),u=r.get(o.IUndoRedoService),d=(p=a.getUniverDocInstance(e))==null?void 0:p.getSnapshot().body,g=l.getSelections();if(d==null||!Array.isArray(g)||g.length===0)return!1;const f=tt(e,s,d,n),m=c.syncExecuteCommand(f.id,f.params);return l.replaceTextRanges(i),m?(u.pushUndoRedo({unitID:e,undoMutations:[{id:v.id,params:m}],redoMutations:[{id:v.id,params:f.params}],undo(){return c.syncExecuteCommand(v.id,m),l.replaceTextRanges(g),!0},redo(){return c.syncExecuteCommand(v.id,f.params),l.replaceTextRanges(i),!0}}),!0):!1}},et={id:"doc.command-cover-content",type:o.CommandType.COMMAND,handler:async(r,t)=>{var d;const{unitId:e,body:n,segmentId:i=""}=t,s=r.get(o.IUniverInstanceService),a=r.get(o.ICommandService),c=r.get(o.IUndoRedoService),l=(d=s.getUniverDocInstance(e))==null?void 0:d.getSnapshot().body;if(l==null)return!1;const u=tt(e,i,l,n);return a.syncExecuteCommand(u.id,u.params),c.clearUndoRedo(e),!0}};function tt(r,t,e,n){const i={id:v.id,params:{unitId:r,mutations:[]}},s=(e==null?void 0:e.dataStream.length)-2;return s>0&&i.params.mutations.push({t:"d",len:s,line:0,segmentId:t}),n.dataStream.length>0&&i.params.mutations.push({t:"i",body:n,len:n.dataStream.length,line:0,segmentId:t}),i}const B={id:"doc.operation.move-cursor",type:o.CommandType.OPERATION,handler:(r,t)=>!!t},$={id:"doc.operation.move-selection",type:o.CommandType.OPERATION,handler:(r,t)=>!!t},Ut=(r,t)=>{const e=r.get(o.IUniverInstanceService).getUniverDocInstance(t.unitId),n=(e==null?void 0:e.zoomRatio)||1;return{...o.Tools.deepClone(t),zoomRatio:n}},V={id:"doc.operation.set-zoom-ratio",type:o.CommandType.OPERATION,handler:(r,t)=>{const e=r.get(o.IUniverInstanceService).getUniverDocInstance(t.unitId);if(!e)return!1;const n=e.getSnapshot();return n.settings==null?n.settings={zoomRatio:t.zoomRatio}:n.settings.zoomRatio=t.zoomRatio,!0}},nt={type:o.CommandType.COMMAND,id:"doc.command.set-zoom-ratio",handler:async(r,t)=>{const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService);let s=i.getCurrentUniverDocInstance().getUnitId(),a=1;if(t&&(s=t.documentId??s,a=t.zoomRatio??a),!i.getUniverDocInstance(s))return!1;const l={zoomRatio:a,unitId:s},u=Ut(r,l);return e.syncExecuteCommand(V.id,l)?(n.pushUndoRedo({unitID:s,undoMutations:[{id:V.id,params:u}],redoMutations:[{id:V.id,params:l}]}),!0):!1}},it={id:"doc.operation.select-all",type:o.CommandType.COMMAND,handler:async r=>{const t=r.get(o.IUniverInstanceService),e=r.get(h.TextSelectionManagerService),n=t.getCurrentUniverDocInstance().getSnapshot().body;if(n==null)return!1;const i=[{startOffset:0,endOffset:n.dataStream.length-2}];return e.replaceTextRanges(i),!0}},Et=10,Pt=6;function wt(){return o.Tools.generateRandomId(Pt)}function Nt(r){const t=r.match(/data-copy-id="([^\s]+)"/);return t&&t[1]?t[1]:null}class Lt{constructor(){C(this,"_cache",new o.LRUMap(Et))}set(t,e){this._cache.set(t,e)}get(t){return this._cache.get(t)}clear(){this._cache.clear()}}const rt=new Lt;function At(r){const t=r.style,e={};for(let n=0;n<t.length;n++){const i=t[n],s=t.getPropertyValue(i);switch(i){case"margin-top":{const a=parseInt(s);e.spaceAbove=/pt/.test(s)?$e(a):a;break}case"margin-bottom":{const a=parseInt(s);e.spaceBelow=/pt/.test(s)?$e(a):a;break}}}return Object.getOwnPropertyNames(e).length?e:null}function $e(r){return r/.75}function Fe(r){const t=r.style,e={},n=r.tagName.toLowerCase();switch(n){case"b":case"em":case"strong":{e.bl=o.BooleanNumber.TRUE;break}case"s":{e.st={s:o.BooleanNumber.TRUE};break}case"u":{e.ul={s:o.BooleanNumber.TRUE};break}case"i":{e.it=o.BooleanNumber.TRUE;break}case"sub":case"sup":{e.va=n==="sup"?o.BaselineOffset.SUPERSCRIPT:o.BaselineOffset.SUBSCRIPT;break}}for(let i=0;i<t.length;i++){const s=t[i],a=t.getPropertyValue(s);switch(s){case"font-family":{e.ff=a;break}case"font-size":{const c=parseInt(a);Number.isNaN(c)||(e.fs=/pt$/.test(a)?$e(c):c);break}case"font-style":{a==="italic"&&(e.it=o.BooleanNumber.TRUE);break}case"font-weight":{Number(a)>400&&(e.bl=o.BooleanNumber.TRUE);break}case"text-decoration":{/underline/.test(a)?e.ul={s:o.BooleanNumber.TRUE}:/overline/.test(a)?e.ol={s:o.BooleanNumber.TRUE}:/line-through/.test(a)&&(e.st={s:o.BooleanNumber.TRUE});break}case"color":{const c=new o.ColorKit(a);c.isValid&&(e.cl={rgb:c.toRgbString()});break}case"background-color":{const c=new o.ColorKit(a);c.isValid&&(e.bg={rgb:c.toRgbString()});break}}}return e}function Bt(r){const t=new DOMParser,e=`<x-univer id="univer-root">${r}</x-univer>`;return t.parseFromString(e,"text/html").querySelector("#univer-root")}function st(r,t){const e=r.tagName.toLowerCase();return typeof t=="string"?e===t:Array.isArray(t)?t.some(n=>n===e):t(r)}const Te=class Te{constructor(){C(this,"styleCache",new Map);C(this,"styleRules",[]);C(this,"afterProcessRules",[])}static use(t){if(this.pluginList.includes(t))throw new Error(`Univer paste plugin ${t.name} already added`);this.pluginList.push(t)}convert(t){const e=Te.pluginList.find(s=>s.checkPasteType(t)),n=Bt(t),i={dataStream:"",textRuns:[]};return e&&(this.styleRules=[...e.stylesRules],this.afterProcessRules=[...e.afterProcessRules]),this.styleCache.clear(),this.process(null,n==null?void 0:n.childNodes,i),this.styleCache.clear(),this.styleRules=[],this.afterProcessRules=[],i}process(t,e,n){var i;for(const s of e)if(s.nodeType===Node.TEXT_NODE){const a=(i=s.nodeValue)==null?void 0:i.replace(/[\r\n]/g,"");let c;t&&this.styleCache.has(t)&&(c=this.styleCache.get(t)),n.dataStream+=a,c&&Object.getOwnPropertyNames(c).length&&n.textRuns.push({st:n.dataStream.length-a.length,ed:n.dataStream.length,ts:c})}else if(s.nodeType===Node.ELEMENT_NODE){const a=t?this.styleCache.get(t):{},c=this.styleRules.find(({filter:g})=>st(s,g)),l=c?c.getStyle(s):Fe(s);this.styleCache.set(s,{...a,...l});const{childNodes:u}=s;this.process(s,u,n);const d=this.afterProcessRules.find(({filter:g})=>st(s,g));d&&d.handler(n,s)}}};C(Te,"pluginList",[]);let te=Te;const $t={name:"univer-doc-paste-plugin-lark",checkPasteType(r){return/lark-record-clipboard/i.test(r)},stylesRules:[{filter:["s"],getStyle(r){const t=Fe(r);return{st:{s:o.BooleanNumber.TRUE},...t}}}],afterProcessRules:[{filter(r){return r.tagName==="DIV"&&/ace-line/i.test(r.className)},handler(r){r.paragraphs==null&&(r.paragraphs=[]),r.paragraphs.push({startIndex:r.dataStream.length}),r.dataStream+="\r"}}]},Ft={name:"univer-doc-paste-plugin-word",checkPasteType(r){return/word|mso/i.test(r)},stylesRules:[{filter:["b"],getStyle(r){const t=Fe(r);return{bl:o.BooleanNumber.TRUE,...t}}}],afterProcessRules:[{filter(r){return r.tagName==="P"&&/mso/i.test(r.className)},handler(r,t){r.paragraphs==null&&(r.paragraphs=[]);const e={startIndex:r.dataStream.length},n=At(t);n&&(e.paragraphStyle=n),r.paragraphs.push(e),r.dataStream+="\r"}}]};function jt(r,t){const{st:e,ed:n,ts:i={}}=t,{ff:s,fs:a,it:c,bl:l,ul:u,st:d,ol:g,bg:f,cl:m,va:p}=i;let S=r.slice(e,n);const _=[];return c===o.BooleanNumber.TRUE&&(S=`<i>${S}</i>`),p===o.BaselineOffset.SUPERSCRIPT?S=`<sup>${S}</sup>`:p===o.BaselineOffset.SUBSCRIPT&&(S=`<sub>${S}</sub>`),(u==null?void 0:u.s)===o.BooleanNumber.TRUE&&(S=`<u>${S}</u>`),(d==null?void 0:d.s)===o.BooleanNumber.TRUE&&(S=`<s>${S}</s>`),l===o.BooleanNumber.TRUE&&(S=`<strong>${S}</strong>`),s&&_.push(`font-family: ${s}`),m&&_.push(`color: ${m.rgb}`),a&&_.push(`font-size: ${a}px`),g&&_.push("text-decoration: overline"),f&&_.push(`background: ${f.rgb}`),_.length?`<span style="${_.join(";")}">${S}</span>`:S}function at(r,t=!0){const{dataStream:e,textRuns:n=[],paragraphs:i=[]}=r;let s=0;const a=[],c=[];for(const l of n){const{st:u,ed:d}=l;if(u!==s&&a.push(e.slice(s,u)),a.push(jt(e,l)),s=d,t)for(const g of i){const{startIndex:f,paragraphStyle:m={}}=g;if(f>=u&&f<=d){const{spaceAbove:p,spaceBelow:S}=m,_=[];p!=null&&(typeof p=="number"?_.push(`margin-top: ${p}px`):_.push(`margin-top: ${p.v}px`)),S!=null&&(typeof S=="number"?_.push(`margin-bottom: ${S}px`):_.push(`margin-bottom: ${S.v}px`)),c.push(`<p className="UniverNormal" ${_.length?`style="${_.join(";")}"`:""}>${a.join("")}</p>`),a.length=0}}}return c.join("")+a.join("")}class Vt{convert(t){if(t.length===0)throw new Error("The bodyList length at least to be 1");if(t.length===1)return at(t[0]);let e="";for(const n of t)e+='<p className="UniverNormal">',e+=at(n,!1),e+="</p>";return e}}var kt=Object.defineProperty,zt=Object.getOwnPropertyDescriptor,Wt=(r,t,e,n)=>{for(var i=n>1?void 0:n?zt(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&kt(t,e,i),i},ot=(r,t)=>(e,n)=>t(e,n,r);te.use(Ft),te.use($t);const ct=b.createIdentifier("doc.clipboard-service");let je=class extends o.Disposable{constructor(t,e){super();C(this,"_clipboardHooks",[]);C(this,"_htmlToUDM",new te);C(this,"_umdToHtml",new Vt);this._currentUniverService=t,this._clipboardInterfaceService=e}async queryClipboardData(){const t=await this._clipboardInterfaceService.read();if(t.length===0)return Promise.reject();try{let e="",n="";for(const s of t)for(const a of s.types)a===T.PLAIN_TEXT_CLIPBOARD_MIME_TYPE?n=await s.getType(a).then(c=>c&&c.text()):a===T.HTML_CLIPBOARD_MIME_TYPE&&(e=await s.getType(a).then(c=>c&&c.text()));if(!e)return{dataStream:n};const i=Nt(e);if(i){const s=rt.get(i);if(s)return s}return this._htmlToUDM.convert(e)}catch(e){return Promise.reject(e)}}async setClipboardData(t){const e=wt(),n=t.length>1?t.map(s=>s.dataStream).join(`
|
|
2
|
+
`):t[0].dataStream;let i=this._umdToHtml.convert(t);return t.length===1&&(i=i.replace(/(<[a-z]+)/,(s,a)=>`${a} data-copy-id="${e}"`),rt.set(e,t[0])),this._clipboardInterfaceService.write(n,i)}addClipboardHook(t){return this._clipboardHooks.push(t),o.toDisposable(()=>{const e=this._clipboardHooks.indexOf(t);e>-1&&this._clipboardHooks.splice(e,1)})}};je=Wt([ot(0,o.IUniverInstanceService),ot(1,T.IClipboardInterfaceService)],je);var Gt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,Kt=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ht(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Gt(t,e,i),i},Y=(r,t)=>(e,n)=>t(e,n,r);let he=class extends o.Disposable{constructor(r,t,e,n,i,s){super(),this._logService=r,this._commandService=t,this._currentUniverService=e,this._docClipboardService=n,this._textSelectionManagerService=i,this._contextService=s,this._commandExecutedListener(),this.initialize()}initialize(){[ue,me,ge].forEach(r=>this.disposeWithMe(this._commandService.registerAsMultipleCommand(r))),[Ye,fe].forEach(r=>this.disposeWithMe(this._commandService.registerCommand(r)))}_commandExecutedListener(){const r=[me.id,ue.id,ge.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(r.includes(t.id)&&!(!this._contextService.getContextValue(o.FOCUSING_DOC)&&!this._contextService.getContextValue(o.FOCUSING_EDITOR)))switch(t.id){case ge.id:{this._handlePaste();break}case ue.id:{this._handleCopy();break}case me.id:{this._handleCut();break}default:throw new Error(`Unhandled command ${t.id}`)}}))}async _handlePaste(){const{_docClipboardService:r}=this,{segmentId:t,endOffset:e,style:n}=this._textSelectionManagerService.getActiveRange()??{},i=this._textSelectionManagerService.getSelections();if(t==null&&this._logService.error("[DocClipboardController] segmentId is not existed"),!(e==null||i==null))try{const s=await r.queryClipboardData();let a=e;for(const l of i){const{startOffset:u,endOffset:d}=l;u==null||d==null||d<=e&&(a+=s.dataStream.length-(d-u))}const c=[{startOffset:a,endOffset:a,style:n}];this._commandService.executeCommand(Ye.id,{body:s,segmentId:t,textRanges:c})}catch{this._logService.error("[DocClipboardController] clipboard is empty")}}_getDocumentBodyInRanges(){const r=this._textSelectionManagerService.getSelections(),t=this._currentUniverService.getCurrentUniverDocInstance(),{dataStream:e,textRuns:n=[],paragraphs:i=[]}=t.getBody(),s=[];if(r==null)return s;for(const a of r){const{startOffset:c,endOffset:l,collapsed:u}=a;if(u||c==null||l==null)continue;const d={dataStream:e.slice(c,l)},g=[];for(const m of n){const p=o.Tools.deepClone(m),{st:S,ed:_}=p;o.Tools.hasIntersectionBetweenTwoRanges(S,_,c,l)&&(c>=S&&c<=_?g.push({...p,st:c,ed:Math.min(l,_)}):l>=S&&l<=_?g.push({...p,st:Math.max(c,S),ed:l}):g.push(p))}g.length&&(d.textRuns=g.map(m=>{const{st:p,ed:S}=m;return{...m,st:p-c,ed:S-c}}));const f=[];for(const m of i){const{startIndex:p}=m;p>=c&&p<=l&&f.push(o.Tools.deepClone(m))}f.length&&(d.paragraphs=f.map(m=>({...m,startIndex:m.startIndex-c}))),s.push(d)}return s}async _handleCopy(){const{_docClipboardService:r}=this,t=this._getDocumentBodyInRanges();try{r.setClipboardData(t)}catch{this._logService.error("[DocClipboardController] set clipboard failed")}}async _handleCut(){const{segmentId:r,endOffset:t,style:e}=this._textSelectionManagerService.getActiveRange()??{},n=this._textSelectionManagerService.getSelections();if(r==null&&this._logService.error("[DocClipboardController] segmentId is not existed"),!(t==null||n==null)){this._handleCopy();try{let i=t;for(const a of n){const{startOffset:c,endOffset:l}=a;c==null||l==null||l<=t&&(i-=l-c)}const s=[{startOffset:i,endOffset:i,style:e}];this._commandService.executeCommand(fe.id,{segmentId:r,textRanges:s})}catch{this._logService.error("[DocClipboardController] cut content failed")}}}};he=Kt([o.OnLifecycle(o.LifecycleStages.Rendered,he),Y(0,o.ILogService),Y(1,o.ICommandService),Y(2,o.IUniverInstanceService),Y(3,ct),Y(4,b.Inject(h.TextSelectionManagerService)),Y(5,o.IContextService)],he);var Yt=Object.defineProperty,Xt=Object.getOwnPropertyDescriptor,qt=(r,t,e,n)=>{for(var i=n>1?void 0:n?Xt(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Yt(t,e,i),i},Ve=(r,t)=>(e,n)=>t(e,n,r);let pe=class extends o.Disposable{constructor(r,t,e){super(),this._docSkeletonManagerService=r,this._renderManagerService=t,this._commandService=e,this._initialRenderRefresh(),this._commandExecutedListener()}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeletonBefore$.subscribe(r=>{if(r==null)return;const{skeleton:t,unitId:e}=r,n=this._renderManagerService.getRenderById(e);if(n==null)return;const{mainComponent:i}=n;i.changeSkeleton(t),this._recalculateSizeBySkeleton(n,t)})}_recalculateSizeBySkeleton(r,t){var u;const{mainComponent:e,scene:n}=r,i=e,s=(u=t.getSkeletonData())==null?void 0:u.pages;if(s==null)return;let a=0,c=0;for(let d=0,g=s.length;d<g;d++){const f=s[d],{pageWidth:m,pageHeight:p}=f;i.pageLayoutType===M.PageLayoutType.VERTICAL?(c+=p,c+=i.pageMarginTop,d===g-1&&(c+=i.pageMarginTop),a=Math.max(a,m)):i.pageLayoutType===M.PageLayoutType.HORIZONTAL&&(a+=m,d!==g-1&&(a+=i.pageMarginLeft),c=Math.max(c,p))}i.resize(a,c),[o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY].includes(r.unitId)||n.resize(a,c)}_commandExecutedListener(){const r=[v.id],t=[o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var n;if(r.includes(e.id)){const i=e.params,{unitId:s}=i,a=this._docSkeletonManagerService.getSkeletonByUnitId(s);if(a==null)return;const{skeleton:c}=a,l=this._renderManagerService.getRenderById(s);if(l==null)return;if(c.calculate(),t.includes(s)){(n=l.mainComponent)==null||n.makeDirty();return}this._recalculateSizeBySkeleton(l,c)}}))}};pe=qt([o.OnLifecycle(o.LifecycleStages.Rendered,pe),Ve(0,b.Inject(h.DocSkeletonManagerService)),Ve(1,M.IRenderManagerService),Ve(2,o.ICommandService)],pe);var Zt=Object.defineProperty,Jt=Object.getOwnPropertyDescriptor,Qt=(r,t,e,n)=>{for(var i=n>1?void 0:n?Jt(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Zt(t,e,i),i},ne=(r,t)=>(e,n)=>t(e,n,r);let Se=class extends o.Disposable{constructor(t,e,n,i,s){super();C(this,"_liquid",new M.Liquid);C(this,"_pageMarginCache",new Map);this._docSkeletonManagerService=t,this._currentUniverService=e,this._renderManagerService=n,this._commandService=i,this._floatingObjectManagerService=s,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialRenderRefresh(),this._updateOnPluginChange()}_updateOnPluginChange(){this._floatingObjectManagerService.pluginUpdate$.subscribe(t=>{const e=this._docSkeletonManagerService.getCurrent();if(e==null)return;const{unitId:n,skeleton:i}=e,s=this._renderManagerService.getRenderById(n);if(s==null)return;const{mainComponent:a,components:c,scene:l}=s,u=a,{left:d,top:g}=u;t.forEach(f=>{const{unitId:m,subComponentId:p,floatingObjectId:S,floatingObject:_}=f,{left:I=0,top:O=0,width:x=0,height:D=0,angle:R,flipX:U,flipY:E,skewX:P,skewY:w}=_,y=this._pageMarginCache.get(S),F=(y==null?void 0:y.marginLeft)||0,N=(y==null?void 0:y.marginTop)||0;i==null||i.getViewModel().getDataModel().updateDrawing(S,{left:I-d-F,top:O-g-N,height:D,width:x})}),i==null||i.calculate(),a==null||a.makeDirty()})}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeleton$.subscribe(t=>{if(t==null)return;const{skeleton:e,unitId:n}=t,i=this._renderManagerService.getRenderById(n);if(i==null)return;const{mainComponent:s}=i;s.changeSkeleton(e),this._refreshFloatingObject(n,e,i)})}_commandExecutedListener(){const t=[v.id,V.id],e=[o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var i;if(t.includes(n.id)){const s=n.params,{unitId:a}=s,c=this._docSkeletonManagerService.getCurrent();if(c==null)return;const{unitId:l,skeleton:u}=c;if(a!==l)return;const d=this._renderManagerService.getRenderById(l);if(d==null)return;if(e.includes(l)){(i=d.mainComponent)==null||i.makeDirty();return}this._refreshFloatingObject(l,u,d)}}))}_refreshFloatingObject(t,e,n){const i=e==null?void 0:e.getSkeletonData(),{mainComponent:s,scene:a}=n,c=s;if(!i)return;const{left:l,top:u,pageLayoutType:d,pageMarginLeft:g,pageMarginTop:f}=c,{pages:m}=i,p=[];a.getAncestorScale(),this._liquid.reset(),this._pageMarginCache.clear();for(let S=0,_=m.length;S<_;S++){const I=m[S],{skeDrawings:O,marginLeft:x,marginTop:D}=I;this._liquid.translatePagePadding(I),O.forEach(R=>{const{aLeft:U,aTop:E,height:P,width:w,objectId:y}=R;p.push({unitId:t,subComponentId:o.DEFAULT_DOCUMENT_SUB_COMPONENT_ID,floatingObjectId:y,floatingObject:{left:U+l+this._liquid.x,top:E+u+this._liquid.y,width:w,height:P}}),this._pageMarginCache.set(y,{marginLeft:this._liquid.x,marginTop:this._liquid.y})}),this._liquid.translatePage(I,d,g,f)}this._floatingObjectManagerService.BatchAddOrUpdate(p)}};Se=Qt([o.OnLifecycle(o.LifecycleStages.Steady,Se),ne(0,b.Inject(h.DocSkeletonManagerService)),ne(1,o.IUniverInstanceService),ne(2,M.IRenderManagerService),ne(3,o.ICommandService),ne(4,o.IFloatingObjectManagerService)],Se);var en=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,nn=(r,t,e,n)=>{for(var i=n>1?void 0:n?tn(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&en(t,e,i),i},X=(r,t)=>(e,n)=>t(e,n,r);let _e=class extends o.Disposable{constructor(t,e,n,i,s,a){super();C(this,"_previousIMEContent","");C(this,"_previousIMERange");C(this,"_onStartSubscription");C(this,"_onUpdateSubscription");C(this,"_onEndSubscription");this._docSkeletonManagerService=t,this._currentUniverService=e,this._renderManagerService=n,this._textSelectionRenderManager=i,this._imeInputManagerService=s,this._commandService=a,this._initialize()}dispose(){var t,e,n;(t=this._onStartSubscription)==null||t.unsubscribe(),(e=this._onUpdateSubscription)==null||e.unsubscribe(),(n=this._onEndSubscription)==null||n.unsubscribe()}_initialize(){this._initialOnCompositionstart(),this._initialOnCompositionUpdate(),this._initialOnCompositionend()}_initialOnCompositionstart(){this._onStartSubscription=this._textSelectionRenderManager.onCompositionstart$.subscribe(t=>{if(t==null)return;const{activeRange:e}=t;e!=null&&(this._imeInputManagerService.clearUndoRedoMutationParamsCache(),this._imeInputManagerService.setActiveRange(o.Tools.deepClone(e)),this._previousIMERange=e)})}_initialOnCompositionUpdate(){this._onUpdateSubscription=this._textSelectionRenderManager.onCompositionupdate$.subscribe(async t=>{this._updateContent(t,!0)})}_initialOnCompositionend(){this._onEndSubscription=this._textSelectionRenderManager.onCompositionend$.subscribe(t=>{this._updateContent(t,!1)})}async _updateContent(t,e){var p;const n=(p=this._docSkeletonManagerService.getCurrent())==null?void 0:p.skeleton;if(this._previousIMERange==null||t==null||n==null)return;const i=this._currentUniverService.getCurrentUniverDocInstance(),{event:s,activeRange:a}=t,{startOffset:c,segmentId:l,style:u}=this._previousIMERange;if(n==null||a==null)return;const g=s.data;if(g===this._previousIMEContent&&e)return;const f=g.length,m=[{startOffset:c+f,endOffset:c+f,style:u}];await this._commandService.executeCommand(Le.id,{unitId:i.getUnitId(),newText:g,oldTextLen:this._previousIMEContent.length,range:this._previousIMERange,textRanges:m,isCompositionEnd:!e,segmentId:l}),n.calculate(),e?(this._previousIMERange.collapsed||(this._previousIMERange.collapsed=!0),this._previousIMEContent=g):this._resetIME()}_resetIME(){this._previousIMEContent="",this._previousIMERange=null,this._imeInputManagerService.clearUndoRedoMutationParamsCache(),this._imeInputManagerService.setActiveRange(null)}_getDocObject(){return q(this._currentUniverService,this._renderManagerService)}};_e=nn([o.OnLifecycle(o.LifecycleStages.Rendered,_e),X(0,b.Inject(h.DocSkeletonManagerService)),X(1,o.IUniverInstanceService),X(2,M.IRenderManagerService),X(3,M.ITextSelectionRenderManager),X(4,b.Inject(Ne)),X(5,o.ICommandService)],_e);var rn=Object.defineProperty,sn=Object.getOwnPropertyDescriptor,an=(r,t,e,n)=>{for(var i=n>1?void 0:n?sn(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&rn(t,e,i),i},lt=(r,t)=>(e,n)=>t(e,n,r);let ve=class extends o.Disposable{constructor(r,t){super(),this._textSelectionManagerService=r,this._commandService=t,this._commandExecutedListener()}_commandExecutedListener(){const r=[G.id,Z.id,J.id,Q.id,A.id,j.id,H.id,K.id,ee.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{r.includes(t.id)&&this._handleInlineFormat(t)}))}_handleInlineFormat(r){const{segmentId:t}=this._textSelectionManagerService.getActiveRange()??{};t!=null&&this._commandService.executeCommand(Ae.id,{segmentId:t,preCommandId:r.id,...r.params??{}})}};ve=an([o.OnLifecycle(o.LifecycleStages.Rendered,ve),lt(0,b.Inject(h.TextSelectionManagerService)),lt(1,o.ICommandService)],ve);var on=Object.defineProperty,cn=Object.getOwnPropertyDescriptor,ln=(r,t,e,n)=>{for(var i=n>1?void 0:n?cn(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&on(t,e,i),i},ie=(r,t)=>(e,n)=>t(e,n,r);let Ce=class extends o.Disposable{constructor(t,e,n,i,s){super();C(this,"_onInputSubscription");this._docSkeletonManagerService=t,this._currentUniverService=e,this._renderManagerService=n,this._textSelectionManagerService=i,this._commandService=s,this._initialize(),this._commandExecutedListener()}dispose(){var t;(t=this._onInputSubscription)==null||t.unsubscribe()}_initialize(){}_commandExecutedListener(){const t=[B.id,$.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(!t.includes(e.id))return;const n=e.params;switch(e.id){case B.id:return this._handleMoveCursor(n.direction);case $.id:return this._handleShiftMoveSelection(n.direction);default:throw new Error("Unknown command")}}))}_handleShiftMoveSelection(t){var S;const e=this._textSelectionManagerService.getActiveRange(),n=this._textSelectionManagerService.getSelections(),i=this._currentUniverService.getCurrentUniverDocInstance(),s=(S=this._docSkeletonManagerService.getCurrent())==null?void 0:S.skeleton,a=this._getDocObject();if(e==null||s==null||a==null)return;const{startOffset:c,endOffset:l,style:u,collapsed:d,direction:g}=e;if(n.length>1){let _=1/0,I=-1/0;for(const O of n)_=Math.min(_,O.startOffset),I=Math.max(I,O.endOffset);this._textSelectionManagerService.replaceTextRanges([{startOffset:t===o.Direction.LEFT||t===o.Direction.UP?I:_,endOffset:t===o.Direction.LEFT||t===o.Direction.UP?_:I,style:u}]);return}const f=d||g===M.RANGE_DIRECTION.FORWARD?c:l;let m=d||g===M.RANGE_DIRECTION.FORWARD?l:c;const p=i.getBody().dataStream.length??1/0;if(t===o.Direction.LEFT||t===o.Direction.RIGHT){const _=s.findNodeByCharIndex(m-1),I=s.findNodeByCharIndex(m);m=t===o.Direction.RIGHT?m+I.count:m-((_==null?void 0:_.count)??0),m=Math.min(p-2,Math.max(0,m)),this._textSelectionManagerService.replaceTextRanges([{startOffset:f,endOffset:m,style:u}])}else{const _=s.findNodeByCharIndex(m),I=a.document.getOffsetConfig(),O=this._getTopOrBottomPosition(s,_,t===o.Direction.DOWN);if(O==null){const D=t===o.Direction.UP?0:p-2;if(D===m)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:f,endOffset:D,style:u}]);return}const x=new M.NodePositionConvertToCursor(I,s).getRangePointData(O,O).cursorList[0];this._textSelectionManagerService.replaceTextRanges([{startOffset:f,endOffset:x.endOffset,style:u}])}}_handleMoveCursor(t){var f;const e=this._textSelectionManagerService.getActiveRange(),n=this._textSelectionManagerService.getSelections(),i=this._currentUniverService.getCurrentUniverDocInstance(),s=(f=this._docSkeletonManagerService.getCurrent())==null?void 0:f.skeleton,a=this._getDocObject();if(e==null||s==null||a==null||n==null)return;const{startOffset:c,endOffset:l,style:u,collapsed:d}=e,g=i.getBody().dataStream.length??1/0;if(t===o.Direction.LEFT||t===o.Direction.RIGHT){let m;if(!e.collapsed||n.length>1){let p=1/0,S=-1/0;for(const _ of n)p=Math.min(p,_.startOffset),S=Math.max(S,_.endOffset);m=t===o.Direction.LEFT?p:S}else{const p=s.findNodeByCharIndex(c-1),S=s.findNodeByCharIndex(c);t===o.Direction.LEFT?m=Math.max(0,c-((p==null?void 0:p.count)??0)):m=Math.min(g-2,l+S.count)}this._textSelectionManagerService.replaceTextRanges([{startOffset:m,endOffset:m,style:u}])}else{const m=s.findNodeByCharIndex(c),p=s.findNodeByCharIndex(l),S=a.document.getOffsetConfig(),_=this._getTopOrBottomPosition(s,t===o.Direction.UP?m:p,t===o.Direction.DOWN);if(_==null){let O;d?O=t===o.Direction.UP?0:g-2:O=t===o.Direction.UP?c:l,this._textSelectionManagerService.replaceTextRanges([{startOffset:O,endOffset:O,style:u}]);return}const I=new M.NodePositionConvertToCursor(S,s).getRangePointData(_,_).cursorList[0];this._textSelectionManagerService.replaceTextRanges([{...I,style:u}])}}_getTopOrBottomPosition(t,e,n){if(e==null)return;const i=this._getSpanLeftOffsetInLine(e),s=this._getNextOrPrevLine(e,n);if(s==null)return;const a=this._matchPositionByLeftOffset(t,s,i);if(a!=null)return{...a,isBack:!0}}_getSpanLeftOffsetInLine(t){const e=t.parent;if(e==null)return-1/0;const n=e.left,{left:i}=t;return n+i}_matchPositionByLeftOffset(t,e,n){const i={distance:1/0};for(const s of e.divides){const a=s.left;for(const c of s.spanGroup){const{left:l}=c,u=a+l,d=Math.abs(n-u);d<i.distance&&(i.span=c,i.distance=d)}}if(i.span!=null)return t.findPositionBySpan(i.span)}_getNextOrPrevLine(t,e){var p,S,_,I,O,x,D,R,U,E,P,w;const n=t.parent;if(n==null)return;const i=n.parent;if(i==null)return;const s=i.parent;if(s==null)return;const a=s.lines.indexOf(i);if(a===-1)return;let c;if(e===!0?c=s.lines[a+1]:c=s.lines[a-1],c!=null)return c;const l=s.parent;if(l==null)return;const u=l.columns.indexOf(s);if(u===-1)return;if(e===!0)c=(p=l.columns[u+1])==null?void 0:p.lines[0];else{const y=(_=(S=l.columns)==null?void 0:S[u-1])==null?void 0:_.lines;c=y==null?void 0:y[y.length-1]}if(c!=null)return c;const d=l.parent;if(d==null)return;const g=d.sections.indexOf(l);if(g===-1)return;if(e===!0)c=(O=(I=d.sections[g-1])==null?void 0:I.columns[0])==null?void 0:O.lines[0];else{const y=(D=(x=d.sections)==null?void 0:x[g-1])==null?void 0:D.columns,F=y==null?void 0:y[y.length-1],N=F==null?void 0:F.lines;c=N==null?void 0:N[N.length-1]}if(c!=null)return c;const f=d.parent;if(f==null)return;const m=f.pages.indexOf(d);if(m!==-1){if(e===!0)c=(E=(U=(R=f.pages[m+1])==null?void 0:R.sections[0])==null?void 0:U.columns[0])==null?void 0:E.lines[0];else{const y=(P=f.pages[m-1])==null?void 0:P.sections;if(y==null)return;const F=(w=y[y.length-1])==null?void 0:w.columns,N=F[F.length-1],ut=N==null?void 0:N.lines;c=ut[ut.length-1]}if(c!=null)return c}}_getDocObject(){return q(this._currentUniverService,this._renderManagerService)}};Ce=ln([o.OnLifecycle(o.LifecycleStages.Rendered,Ce),ie(0,b.Inject(h.DocSkeletonManagerService)),ie(1,o.IUniverInstanceService),ie(2,M.IRenderManagerService),ie(3,b.Inject(h.TextSelectionManagerService)),ie(4,o.ICommandService)],Ce);var dn=Object.defineProperty,un=Object.getOwnPropertyDescriptor,mn=(r,t,e,n)=>{for(var i=n>1?void 0:n?un(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&dn(t,e,i),i},re=(r,t)=>(e,n)=>t(e,n,r);let Ie=class extends o.Disposable{constructor(t,e,n,i,s){super();C(this,"_onInputSubscription");this._docSkeletonManagerService=t,this._currentUniverService=e,this._renderManagerService=n,this._textSelectionRenderManager=i,this._commandService=s,this._initialize(),this._commandExecutedListener()}dispose(){var t;(t=this._onInputSubscription)==null||t.unsubscribe()}_initialize(){this._initialNormalInput()}_initialNormalInput(){this._onInputSubscription=this._textSelectionRenderManager.onInput$.subscribe(async t=>{var p;if(t==null)return;const n=this._currentUniverService.getCurrentUniverDocInstance().getUnitId(),{event:i,content:s="",activeRange:a}=t,c=i,l=(p=this._docSkeletonManagerService.getCurrent())==null?void 0:p.skeleton;if(c.data==null||l==null||!l||!a)return;const{startOffset:u,segmentId:d,style:g}=a,f=s.length,m=[{startOffset:u+f,endOffset:u+f,style:g}];await this._commandService.executeCommand(le.id,{unitId:n,body:{dataStream:s},range:a,textRanges:m,segmentId:d})})}_commandExecutedListener(){}_getDocObject(){return q(this._currentUniverService,this._renderManagerService)}};Ie=mn([o.OnLifecycle(o.LifecycleStages.Rendered,Ie),re(0,b.Inject(h.DocSkeletonManagerService)),re(1,o.IUniverInstanceService),re(2,M.IRenderManagerService),re(3,M.ITextSelectionRenderManager),re(4,o.ICommandService)],Ie);var gn=Object.defineProperty,fn=Object.getOwnPropertyDescriptor,hn=(r,t,e,n)=>{for(var i=n>1?void 0:n?fn(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&gn(t,e,i),i},dt=(r,t)=>(e,n)=>t(e,n,r);const pn="rgba(198, 198, 198, 1)",Sn="rgba(255, 255, 255, 1)";let Me=class extends o.Disposable{constructor(r,t){super(),this._renderManagerService=r,this._currentUniverService=t,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialRenderRefresh()}_initialRenderRefresh(){this._renderManagerService.currentRender$.subscribe(r=>{var s;if(r==null||this._currentUniverService.getUniverDocInstance(r)==null)return;const t=this._renderManagerService.getRenderById(r);if(t==null)return;const{mainComponent:e}=t,n=e,i=(s=n.getSkeleton())==null?void 0:s.getPageSize();n.onPageRenderObservable.add(a=>{if([o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY].includes(r))return;const{page:c,pageLeft:l,pageTop:u,ctx:d}=a,{width:g,height:f}=c;d.save(),d.translate(l-.5,u-.5),M.Rect.drawWith(d,{width:(i==null?void 0:i.width)||g,height:(i==null?void 0:i.height)||f,strokeWidth:1,stroke:pn,fill:Sn,zIndex:3}),d.restore()})})}_commandExecutedListener(){}};Me=hn([o.OnLifecycle(o.LifecycleStages.Rendered,Me),dt(0,M.IRenderManagerService),dt(1,b.Inject(o.IUniverInstanceService))],Me);var _n=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,Cn=(r,t,e,n)=>{for(var i=n>1?void 0:n?vn(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&_n(t,e,i),i},k=(r,t)=>(e,n)=>t(e,n,r);let Oe=class extends o.Disposable{constructor(t,e,n,i,s,a,c){super();C(this,"_moveInObserver");C(this,"_moveOutObserver");C(this,"_downObserver");C(this,"_dblClickObserver");C(this,"_tripleClickObserver");C(this,"_loadedMap",new Set);this._docSkeletonManagerService=t,this._currentUniverService=e,this._commandService=n,this._renderManagerService=i,this._textSelectionRenderManager=s,this._textSelectionManagerService=a,this._layoutService=c,this._renderManagerService.currentRender$.subscribe(l=>{l!=null&&this._currentUniverService.getUniverDocInstance(l)!=null&&(this._loadedMap.has(l)||(this._initialMain(l),this._loadedMap.add(l)))}),this._initialize()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._layoutService&&this.disposeWithMe(this._layoutService.registerContainer(this._textSelectionRenderManager.__getEditorContainer()))}dispose(){this._renderManagerService.getRenderAll().forEach(t=>{const{mainComponent:e}=t;e!=null&&(e.onPointerEnterObserver.remove(this._moveInObserver),e.onPointerLeaveObserver.remove(this._moveOutObserver),e.onPointerDownObserver.remove(this._downObserver),e.onDblclickObserver.remove(this._dblClickObserver),e.onTripleClickObserver.remove(this._tripleClickObserver))})}_initialMain(t){const e=this._getDocObjectById(t);if(e==null)return;const{document:n,scene:i}=e,s=i.getViewport(W.VIEW_MAIN);this._moveInObserver=n.onPointerEnterObserver.add(()=>{n.cursor=M.CURSOR_TYPE.TEXT}),this._moveOutObserver=n.onPointerLeaveObserver.add(()=>{n.cursor=M.CURSOR_TYPE.DEFAULT,i.resetCursor()}),this._downObserver=n==null?void 0:n.onPointerDownObserver.add((a,c)=>{this._currentUniverService.getCurrentUniverDocInstance().getUnitId()!==t&&this._currentUniverService.setCurrentUniverDocInstance(t),this._textSelectionRenderManager.eventTrigger(a,n.getOffsetConfig(),s),a.button!==2&&c.stopPropagation()}),this._dblClickObserver=n==null?void 0:n.onDblclickObserver.add(a=>{this._textSelectionRenderManager.handleDblClick(a,n.getOffsetConfig(),s)}),this._tripleClickObserver=n==null?void 0:n.onTripleClickObserver.add(a=>{this._textSelectionRenderManager.handleTripleClick(a,n.getOffsetConfig(),s)})}_commandExecutedListener(){const t=[V.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var n;if(t.includes(e.id)){const i=e.params,{unitId:s}=i,a=(n=this._textSelectionManagerService.getCurrentSelection())==null?void 0:n.unitId;if(s!==a)return;this._textSelectionManagerService.refreshSelection()}}))}_skeletonListener(){this._docSkeletonManagerService.currentSkeleton$.subscribe(t=>{if(t==null)return;const{unitId:e,skeleton:n}=t,i=this._renderManagerService.getRenderById(e);if(i==null)return;const{scene:s,mainComponent:a}=i,c=s.getViewport(W.VIEW_MAIN);this._textSelectionRenderManager.changeRuntime(n,s,c,a.getOffsetConfig()),this._textSelectionManagerService.setCurrentSelectionNotRefresh({unitId:e,subUnitId:""})})}_getDocObjectById(t){return mt(t,this._renderManagerService)}};Oe=Cn([o.OnLifecycle(o.LifecycleStages.Rendered,Oe),k(0,b.Inject(h.DocSkeletonManagerService)),k(1,o.IUniverInstanceService),k(2,o.ICommandService),k(3,M.IRenderManagerService),k(4,M.ITextSelectionRenderManager),k(5,b.Inject(h.TextSelectionManagerService)),k(6,b.Optional(T.LayoutService))],Oe);var In=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,On=(r,t,e,n)=>{for(var i=n>1?void 0:n?Mn(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&In(t,e,i),i},se=(r,t)=>(e,n)=>t(e,n,r);let Re=class extends o.Disposable{constructor(t,e,n,i,s){super();C(this,"_initializedRender",new Set);this._docSkeletonManagerService=t,this._currentUniverService=e,this._commandService=n,this._renderManagerService=i,this._textSelectionManagerService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._initialRenderRefresh()}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeleton$.subscribe(t=>{if(t==null)return;const{unitId:e}=t,n=this._renderManagerService.getRenderById(e);if(n==null||this._initializedRender.has(e)||[o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY].includes(e))return;this._initializedRender.add(e);const{scene:i}=n;this.disposeWithMe(o.toDisposable(i.onMouseWheelObserver.add(s=>{if(!s.ctrlKey)return;const a=Math.abs(s.deltaX);let c=a<40?.2:a<80?.4:.2;c*=s.deltaY>0?-1:1,i.scaleX<1&&(c/=2);const l=this._currentUniverService.getCurrentUniverDocInstance(),u=l.zoomRatio;let d=+parseFloat(`${u+c}`).toFixed(1);d=d>=4?4:d<=.1?.1:d,this._commandService.executeCommand(nt.id,{zoomRatio:d,unitId:l.getUnitId()}),s.preventDefault()})))})}_skeletonListener(){this.disposeWithMe(o.toDisposable(this._docSkeletonManagerService.currentSkeletonBefore$.subscribe(t=>{if(t==null)return;const n=this._currentUniverService.getCurrentUniverDocInstance().zoomRatio||1;this._updateViewZoom(n,!1)})))}_commandExecutedListener(){const t=[V.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(t.includes(e.id)){const n=this._currentUniverService.getCurrentUniverDocInstance(),i=e.params,{unitId:s}=i;if(s!==n.getUnitId())return;const a=n.zoomRatio||1;this._updateViewZoom(a)}}))}_updateViewZoom(t,e=!0){var i;const n=this._getDocObject();n!=null&&(n.scene.scale(t,t),this._calculatePagePosition(n,t),e&&this._textSelectionManagerService.refreshSelection(),(i=n.scene.getTransformer())==null||i.hideControl())}_calculatePagePosition(t,e){const{document:n,scene:i}=t,s=i==null?void 0:i.getParent(),{width:a,height:c,pageMarginLeft:l,pageMarginTop:u}=n;if(s==null||a===1/0||c===1/0)return;const{width:d,height:g}=s;let f=0,m=0,p=0,S=0,_=1/0;d>(a+l*2)*e?(f=d/2-a*e/2,f/=e,p=(d-l*2)/e,_=0):(f=l,p=a+l*2,_=(p-d/e)/2),g>c?(m=g/2-c/2,S=(g-u*2)/e):(m=u,S=c+u*2),i.resize(p,S+200),n.translate(f,m);const I=i.getViewport(W.VIEW_MAIN);if(_!==1/0&&I!=null){const O=I.getBarScroll(_,0).x;I.scrollTo({x:O})}return this}_getDocObject(){return q(this._currentUniverService,this._renderManagerService)}};Re=On([o.OnLifecycle(o.LifecycleStages.Rendered,Re),se(0,b.Inject(h.DocSkeletonManagerService)),se(1,o.IUniverInstanceService),se(2,o.ICommandService),se(3,M.IRenderManagerService),se(4,b.Inject(h.TextSelectionManagerService))],Re);const Rn={id:Ue.id,preconditions:r=>r.getContextValue(o.FOCUSING_DOC),binding:T.KeyCode.ENTER},yn={id:Ee.id,preconditions:r=>r.getContextValue(o.FOCUSING_DOC),binding:T.KeyCode.BACKSPACE},Dn={id:Pe.id,preconditions:r=>r.getContextValue(o.FOCUSING_DOC),binding:T.KeyCode.DELETE},Tn={id:B.id,binding:T.KeyCode.ARROW_UP,preconditions:r=>r.getContextValue(o.FOCUSING_DOC),staticParameters:{direction:o.Direction.UP}},bn={id:B.id,binding:T.KeyCode.ARROW_DOWN,preconditions:r=>r.getContextValue(o.FOCUSING_DOC),staticParameters:{direction:o.Direction.DOWN}},xn={id:B.id,binding:T.KeyCode.ARROW_LEFT,preconditions:r=>r.getContextValue(o.FOCUSING_DOC),staticParameters:{direction:o.Direction.LEFT}},Un={id:B.id,binding:T.KeyCode.ARROW_RIGHT,preconditions:r=>r.getContextValue(o.FOCUSING_DOC),staticParameters:{direction:o.Direction.RIGHT}},En={id:$.id,binding:T.KeyCode.ARROW_UP|T.MetaKeys.SHIFT,preconditions:r=>r.getContextValue(o.FOCUSING_DOC),staticParameters:{direction:o.Direction.UP}},Pn={id:$.id,binding:T.KeyCode.ARROW_DOWN|T.MetaKeys.SHIFT,preconditions:r=>r.getContextValue(o.FOCUSING_DOC),staticParameters:{direction:o.Direction.DOWN}},wn={id:$.id,binding:T.KeyCode.ARROW_LEFT|T.MetaKeys.SHIFT,preconditions:r=>r.getContextValue(o.FOCUSING_DOC),staticParameters:{direction:o.Direction.LEFT}},Nn={id:$.id,binding:T.KeyCode.ARROW_RIGHT|T.MetaKeys.SHIFT,preconditions:r=>r.getContextValue(o.FOCUSING_DOC),staticParameters:{direction:o.Direction.RIGHT}},Ln={id:it.id,binding:T.KeyCode.A|T.MetaKeys.CTRL_COMMAND,preconditions:r=>r.getContextValue(o.FOCUSING_DOC)||r.getContextValue(o.FOCUSING_EDITOR)};var An=Object.defineProperty,Bn=Object.getOwnPropertyDescriptor,$n=(r,t,e,n)=>{for(var i=n>1?void 0:n?Bn(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&An(t,e,i),i},ye=(r,t)=>(e,n)=>t(e,n,r);h.DocCanvasView=class extends o.RxDisposable{constructor(e,n,i,s){super();C(this,"_scene");C(this,"_currentDocumentModel");C(this,"_loadedMap",new Set);C(this,"_fps$",new z.BehaviorSubject(""));C(this,"fps$",this._fps$.asObservable());this._renderManagerService=e,this._configService=n,this._currentUniverService=i,this._docViewModelManagerService=s,this._initialize()}_initialize(){this._currentUniverService.currentDoc$.subscribe(e=>{if(e==null)return;this._currentDocumentModel=e;const n=e.getUnitId();this._docViewModelManagerService.setCurrent(n),this._loadedMap.has(n)||(this._addNewRender(),this._loadedMap.add(n))})}dispose(){this._fps$.complete()}_addNewRender(){const e=this._currentDocumentModel,n=e.getUnitId(),i=e.getContainer(),s=e.getParentRenderUnitId();if(i!=null&&s!=null)throw new Error("container or parentRenderUnitId can only exist one");i==null&&s!=null?this._renderManagerService.createRenderWithParent(n,s):this._renderManagerService.createRender(n);const a=this._renderManagerService.getRenderById(n);if(a==null)return;const{scene:c,engine:l}=a;c.openTransformer(),this._scene=c;const u=new M.Viewport(W.VIEW_MAIN,c,{left:0,top:0,bottom:0,right:0,isWheelPreventDefaultX:!0});c.addViewport(u).attachControl(),c.on(M.EVENT_TYPE.wheel,(f,m)=>{const p=f;if(p.ctrlKey){const S=Math.abs(p.deltaX);let _=S<40?.2:S<80?.4:.2;_*=p.deltaY>0?-1:1,c.scaleX<1&&(_/=2),c.scaleX+_>4?c.scale(4,4):c.scaleX+_<.1?c.scale(.1,.1):p.preventDefault()}else u.onMouseWheel(p,m)}),this._configService.getConfig("hasScroll")!==!1&&n!==o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&new M.ScrollBar(u),c.addLayer(new M.Layer(c,[],oe),new M.Layer(c,[],ze)),this._addComponent(a),this._currentDocumentModel.getShouldRenderLoopImmediately()&&l.runRenderLoop(()=>{c.render(),this._fps$.next(Math.round(l.getFps()).toString())}),this._renderManagerService.setCurrent(n)}_addComponent(e){const n=this._scene,i=this._currentDocumentModel,s=new M.Documents(ae.MAIN,void 0,{pageMarginLeft:i.documentStyle.marginLeft||0,pageMarginTop:i.documentStyle.marginTop||0});s.zIndex=We,e.mainComponent=s,e.components.set(ae.MAIN,s),n.addObjects([s],oe),n.enableLayerCache(oe)}},h.DocCanvasView=$n([o.OnLifecycle(o.LifecycleStages.Ready,h.DocCanvasView),ye(0,M.IRenderManagerService),ye(1,o.IConfigService),ye(2,o.IUniverInstanceService),ye(3,b.Inject(h.DocViewModelManagerService))],h.DocCanvasView);var Fn=Object.defineProperty,jn=Object.getOwnPropertyDescriptor,Vn=(r,t,e,n)=>{for(var i=n>1?void 0:n?jn(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Fn(t,e,i),i},De=(r,t)=>(e,n)=>t(e,n,r);const kn={hasScroll:!0},zn="docs";h.UniverDocsPlugin=(ke=class extends o.Plugin{constructor(e={},n,i,s,a){super(zn);C(this,"_config");this._injector=n,this._localeService=i,this._configService=s,this._currentUniverService=a,this._config=Object.assign(kn,e),this._initializeDependencies(n),this._initializeCommands()}initialize(){}_initializeCommands(){[B,$,Ee,Pe,G,Z,J,Q,A,j,H,K,ee,Ae,Ue,le,de,xe,Le,we,v,Qe,et,nt,V,be,it,Je,Ze,Be].forEach(e=>{this._injector.get(o.ICommandService).registerCommand(e)}),[Tn,bn,Un,xn,En,Pn,wn,Nn,Ln,yn,Dn,Rn].forEach(e=>{this._injector.get(T.IShortcutService).registerShortcut(e)})}onReady(){this.initialize()}_initializeDependencies(e){[[h.DocCanvasView],[h.DocSkeletonManagerService],[h.DocViewModelManagerService],[Ne],[ct,{useClass:je}],[M.ITextSelectionRenderManager,{useClass:M.TextSelectionRenderManager}],[h.TextSelectionManagerService],[pe],[Me],[Oe],[Ie],[_e],[ve],[he],[Ce],[Re],[Se]].forEach(n=>e.add(n))}},C(ke,"type",o.PluginType.Doc),ke),h.UniverDocsPlugin=Vn([De(1,b.Inject(b.Injector)),De(2,b.Inject(o.LocaleService)),De(3,o.IConfigService),De(4,o.IUniverInstanceService)],h.UniverDocsPlugin),h.BreakLineCommand=Ue,h.BulletListCommand=Ze,h.CoverContentCommand=et,h.DOCS_COMPONENT_DEFAULT_Z_INDEX=We,h.DOCS_COMPONENT_HEADER_LAYER_INDEX=ze,h.DOCS_COMPONENT_MAIN_LAYER_INDEX=oe,h.DOCS_VIEW_KEY=ae,h.DeleteCommand=de,h.DeleteLeftCommand=Ee,h.DeleteRightCommand=Pe,h.DocCopyCommand=ue,h.DocCutCommand=me,h.DocPasteCommand=ge,h.IMEInputCommand=Le,h.InsertCommand=le,h.MoveCursorOperation=B,h.MoveSelectionOperation=$,h.NORMAL_TEXT_SELECTION_PLUGIN_NAME=gt,h.OrderListCommand=Je,h.ReplaceContentCommand=Qe,h.RichTextEditingMutation=v,h.SetInlineFormatBoldCommand=G,h.SetInlineFormatCommand=Ae,h.SetInlineFormatFontFamilyCommand=K,h.SetInlineFormatFontSizeCommand=H,h.SetInlineFormatItalicCommand=Z,h.SetInlineFormatStrikethroughCommand=Q,h.SetInlineFormatSubscriptCommand=A,h.SetInlineFormatSuperscriptCommand=j,h.SetInlineFormatTextColorCommand=ee,h.SetInlineFormatUnderlineCommand=J,h.SetTextSelectionsOperation=be,h.UpdateCommand=xe,h.VIEWPORT_KEY=W,h.getDocObject=q,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.3",
|
|
4
4
|
"description": "UniverSheet normal base-docs",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
7
|
-
"license": "
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
8
|
"main": "./lib/cjs/index.js",
|
|
9
|
-
"module": "./lib/
|
|
9
|
+
"module": "./lib/es/index.js",
|
|
10
10
|
"types": "./lib/types/index.d.ts",
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
|
-
"import": "./lib/
|
|
16
|
+
"import": "./lib/es/index.js",
|
|
17
17
|
"require": "./lib/cjs/index.js",
|
|
18
18
|
"types": "./lib/types/index.d.ts"
|
|
19
19
|
},
|
|
20
20
|
"./*": {
|
|
21
|
-
"import": "./lib/
|
|
21
|
+
"import": "./lib/es/*",
|
|
22
22
|
"require": "./lib/cjs/*",
|
|
23
23
|
"types": "./lib/types/index.d.ts"
|
|
24
|
-
},
|
|
25
|
-
"./locale/*": {
|
|
26
|
-
"import": "./lib/esm/locale/*.js",
|
|
27
|
-
"require": "./lib/cjs/locale/*.js",
|
|
28
|
-
"types": "./lib/types/index.d.ts"
|
|
29
24
|
}
|
|
30
25
|
},
|
|
31
26
|
"directories": {
|
|
@@ -35,28 +30,34 @@
|
|
|
35
30
|
"lib"
|
|
36
31
|
],
|
|
37
32
|
"private": false,
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"@ctrl/tinycolor": "^4.0.2",
|
|
40
|
-
"@wendellhu/redi": "^0.12.11",
|
|
41
|
-
"rxjs": "^7.8.1",
|
|
42
|
-
"@univerjs/engine-render": "0.1.0-alpha.1",
|
|
43
|
-
"@univerjs/sheets": "0.1.0-alpha.1",
|
|
44
|
-
"@univerjs/ui": "0.1.0-alpha.1",
|
|
45
|
-
"@univerjs/core": "0.1.0-alpha.1"
|
|
46
|
-
},
|
|
47
33
|
"devDependencies": {
|
|
48
|
-
"@vitest/coverage-istanbul": "^0.
|
|
49
|
-
"
|
|
34
|
+
"@vitest/coverage-istanbul": "^1.0.4",
|
|
35
|
+
"@wendellhu/redi": "^0.12.12",
|
|
50
36
|
"happy-dom": "^12.10.3",
|
|
51
37
|
"less": "^4.2.0",
|
|
52
|
-
"
|
|
53
|
-
"typescript": "^5.3.
|
|
54
|
-
"
|
|
38
|
+
"rxjs": "^7.8.1",
|
|
39
|
+
"typescript": "^5.3.3",
|
|
40
|
+
"vite": "^5.0.8",
|
|
41
|
+
"vite-plugin-dts": "^3.6.4",
|
|
42
|
+
"vite-plugin-externals": "^0.6.2",
|
|
43
|
+
"vitest": "^1.0.4",
|
|
44
|
+
"@univerjs/core": "0.1.0-alpha.3",
|
|
45
|
+
"@univerjs/engine-render": "0.1.0-alpha.3",
|
|
46
|
+
"@univerjs/sheets": "0.1.0-alpha.3",
|
|
47
|
+
"@univerjs/ui": "0.1.0-alpha.3"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@wendellhu/redi": ">=0.12.12",
|
|
51
|
+
"rxjs": ">=7.0.0",
|
|
52
|
+
"@univerjs/engine-render": "0.1.0-alpha.3",
|
|
53
|
+
"@univerjs/core": "0.1.0-alpha.3",
|
|
54
|
+
"@univerjs/sheets": "0.1.0-alpha.3",
|
|
55
|
+
"@univerjs/ui": "0.1.0-alpha.3"
|
|
55
56
|
},
|
|
56
57
|
"scripts": {
|
|
57
58
|
"test": "vitest run",
|
|
58
59
|
"test:watch": "vitest",
|
|
59
60
|
"coverage": "vitest run --coverage",
|
|
60
|
-
"
|
|
61
|
+
"build": "tsc && vite build"
|
|
61
62
|
}
|
|
62
63
|
}
|