@univerjs/docs-ui 0.1.0-beta.5 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/lib/cjs/index.js +10 -2
- package/lib/es/index.js +1431 -664
- package/lib/index.css +1 -0
- package/lib/types/controllers/app-ui-controller.d.ts +2 -2
- package/lib/types/controllers/back-scroll.controller.d.ts +30 -0
- package/lib/types/controllers/doc-editor-bridge.controller.d.ts +39 -0
- package/lib/types/controllers/doc-render.controller.d.ts +31 -0
- package/lib/types/controllers/doc-ui.controller.d.ts +8 -5
- package/lib/types/controllers/floating-object.controller.d.ts +35 -0
- package/lib/types/controllers/page-render.controller.d.ts +27 -0
- package/lib/types/controllers/text-selection.controller.d.ts +39 -0
- package/lib/types/controllers/zoom.controller.d.ts +37 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/locale/en-US.d.ts +3 -21
- package/lib/types/locale/zh-CN.d.ts +2 -2
- package/lib/types/services/clipboard/html-to-udm/utils.d.ts +0 -1
- package/lib/types/shortcuts/utils.d.ts +18 -0
- package/lib/types/views/doc-background/DocBackground.d.ts +20 -0
- package/lib/types/views/doc-canvas-view.d.ts +32 -0
- package/lib/umd/index.js +10 -2
- package/package.json +12 -12
package/lib/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.univer-docs-ui-canvas-background{position:relative;width:100%;height:100%;background:rgb(var(--grey-50));z-index:1;user-select:none;pointer-events:none}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { LocaleService, RxDisposable } from '@univerjs/core';
|
|
17
17
|
import { Injector } from '@wendellhu/redi';
|
|
18
|
-
import {
|
|
18
|
+
import { ILayoutService } from '@univerjs/ui';
|
|
19
19
|
import { ITextSelectionRenderManager } from '@univerjs/engine-render';
|
|
20
20
|
import type { IUniverDocsUIConfig } from '../basics';
|
|
21
21
|
import { DocContainerUIController } from './doc-container-ui-controller';
|
|
@@ -25,7 +25,7 @@ export declare class AppUIController extends RxDisposable {
|
|
|
25
25
|
private readonly _textSelectionRenderManager;
|
|
26
26
|
private readonly _layoutService?;
|
|
27
27
|
private _docContainerController;
|
|
28
|
-
constructor(_config: IUniverDocsUIConfig, _localeService: LocaleService, _injector: Injector, _textSelectionRenderManager: ITextSelectionRenderManager, _layoutService?:
|
|
28
|
+
constructor(_config: IUniverDocsUIConfig, _localeService: LocaleService, _injector: Injector, _textSelectionRenderManager: ITextSelectionRenderManager, _layoutService?: ILayoutService | undefined);
|
|
29
29
|
private _registerContainer;
|
|
30
30
|
/**
|
|
31
31
|
* Change language
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { IUniverInstanceService, RxDisposable } from '@univerjs/core';
|
|
17
|
+
import { DocSkeletonManagerService, TextSelectionManagerService } from '@univerjs/docs';
|
|
18
|
+
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
19
|
+
import { IEditorService } from '@univerjs/ui';
|
|
20
|
+
export declare class BackScrollController extends RxDisposable {
|
|
21
|
+
private readonly _docSkeletonManagerService;
|
|
22
|
+
private readonly _textSelectionManagerService;
|
|
23
|
+
private readonly _editorService;
|
|
24
|
+
private readonly _currentUniverService;
|
|
25
|
+
private readonly _renderManagerService;
|
|
26
|
+
constructor(_docSkeletonManagerService: DocSkeletonManagerService, _textSelectionManagerService: TextSelectionManagerService, _editorService: IEditorService, _currentUniverService: IUniverInstanceService, _renderManagerService: IRenderManagerService);
|
|
27
|
+
private _init;
|
|
28
|
+
private _scrollToSelection;
|
|
29
|
+
private _getDocObject;
|
|
30
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
|
|
17
|
+
import { ITextSelectionRenderManager } from '@univerjs/engine-render';
|
|
18
|
+
import { DocSkeletonManagerService } from '@univerjs/docs';
|
|
19
|
+
import { IEditorService } from '@univerjs/ui';
|
|
20
|
+
export declare class DocEditorBridgeController extends Disposable {
|
|
21
|
+
private readonly _currentUniverService;
|
|
22
|
+
private readonly _docSkeletonManagerService;
|
|
23
|
+
private readonly _editorService;
|
|
24
|
+
private readonly _commandService;
|
|
25
|
+
private readonly _textSelectionRenderManager;
|
|
26
|
+
private _initialEditors;
|
|
27
|
+
constructor(_currentUniverService: IUniverInstanceService, _docSkeletonManagerService: DocSkeletonManagerService, _editorService: IEditorService, _commandService: ICommandService, _textSelectionRenderManager: ITextSelectionRenderManager);
|
|
28
|
+
private _initialize;
|
|
29
|
+
private _resize;
|
|
30
|
+
private _initialSetValue;
|
|
31
|
+
private _initialBlur;
|
|
32
|
+
private _initialFocus;
|
|
33
|
+
private _initialValueChange;
|
|
34
|
+
private _valueChange;
|
|
35
|
+
/**
|
|
36
|
+
* Listen to document edits to refresh the size of the normula editor.
|
|
37
|
+
*/
|
|
38
|
+
private _commandExecutedListener;
|
|
39
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { ICommandService, RxDisposable } from '@univerjs/core';
|
|
17
|
+
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
18
|
+
import { IEditorService } from '@univerjs/ui';
|
|
19
|
+
import { DocSkeletonManagerService } from '@univerjs/docs';
|
|
20
|
+
export declare class DocRenderController extends RxDisposable {
|
|
21
|
+
private readonly _docSkeletonManagerService;
|
|
22
|
+
private readonly _renderManagerService;
|
|
23
|
+
private readonly _commandService;
|
|
24
|
+
private readonly _editorService;
|
|
25
|
+
private _docRenderMap;
|
|
26
|
+
constructor(_docSkeletonManagerService: DocSkeletonManagerService, _renderManagerService: IRenderManagerService, _commandService: ICommandService, _editorService: IEditorService);
|
|
27
|
+
private _initialRenderRefresh;
|
|
28
|
+
private _create;
|
|
29
|
+
private _recalculateSizeBySkeleton;
|
|
30
|
+
private _commandExecutedListener;
|
|
31
|
+
}
|
|
@@ -13,19 +13,22 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Disposable,
|
|
16
|
+
import { Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
17
17
|
import type { IDesktopUIController } from '@univerjs/ui';
|
|
18
|
-
import { ComponentManager,
|
|
18
|
+
import { ComponentManager, IEditorService, ILayoutService, IMenuService } from '@univerjs/ui';
|
|
19
19
|
import { Injector } from '@wendellhu/redi';
|
|
20
20
|
export declare class DocUIController extends Disposable {
|
|
21
21
|
private readonly _injector;
|
|
22
22
|
private readonly _componentManager;
|
|
23
|
-
private readonly
|
|
24
|
-
private readonly
|
|
23
|
+
private readonly _layoutService;
|
|
24
|
+
private readonly _editorService;
|
|
25
25
|
private readonly _menuService;
|
|
26
26
|
private readonly _uiController;
|
|
27
|
-
|
|
27
|
+
private readonly _currentUniverService;
|
|
28
|
+
constructor(_injector: Injector, _componentManager: ComponentManager, _layoutService: ILayoutService, _editorService: IEditorService, _menuService: IMenuService, _uiController: IDesktopUIController, _currentUniverService: IUniverInstanceService);
|
|
28
29
|
private _initCustomComponents;
|
|
29
30
|
private _initMenus;
|
|
30
31
|
private _init;
|
|
32
|
+
private _initDocBackground;
|
|
33
|
+
private _initFocusHandler;
|
|
31
34
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { Disposable, ICommandService, IFloatingObjectManagerService, IUniverInstanceService } from '@univerjs/core';
|
|
17
|
+
import { DocSkeletonManagerService } from '@univerjs/docs';
|
|
18
|
+
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
19
|
+
import { IEditorService } from '@univerjs/ui';
|
|
20
|
+
export declare class FloatingObjectController extends Disposable {
|
|
21
|
+
private readonly _docSkeletonManagerService;
|
|
22
|
+
private readonly _currentUniverService;
|
|
23
|
+
private readonly _renderManagerService;
|
|
24
|
+
private readonly _commandService;
|
|
25
|
+
private readonly _floatingObjectManagerService;
|
|
26
|
+
private readonly _editorService;
|
|
27
|
+
private _liquid;
|
|
28
|
+
private _pageMarginCache;
|
|
29
|
+
constructor(_docSkeletonManagerService: DocSkeletonManagerService, _currentUniverService: IUniverInstanceService, _renderManagerService: IRenderManagerService, _commandService: ICommandService, _floatingObjectManagerService: IFloatingObjectManagerService, _editorService: IEditorService);
|
|
30
|
+
private _initialize;
|
|
31
|
+
private _updateOnPluginChange;
|
|
32
|
+
private _initialRenderRefresh;
|
|
33
|
+
private _commandExecutedListener;
|
|
34
|
+
private _refreshFloatingObject;
|
|
35
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
17
|
+
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
18
|
+
import { IEditorService } from '@univerjs/ui';
|
|
19
|
+
export declare class PageRenderController extends Disposable {
|
|
20
|
+
private readonly _renderManagerService;
|
|
21
|
+
private readonly _editorService;
|
|
22
|
+
private readonly _currentUniverService;
|
|
23
|
+
constructor(_renderManagerService: IRenderManagerService, _editorService: IEditorService, _currentUniverService: IUniverInstanceService);
|
|
24
|
+
private _initialize;
|
|
25
|
+
private _initialRenderRefresh;
|
|
26
|
+
private _commandExecutedListener;
|
|
27
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
|
|
17
|
+
import { IRenderManagerService, ITextSelectionRenderManager } from '@univerjs/engine-render';
|
|
18
|
+
import { IEditorService } from '@univerjs/ui';
|
|
19
|
+
import { DocSkeletonManagerService, TextSelectionManagerService } from '@univerjs/docs';
|
|
20
|
+
export declare class TextSelectionController extends Disposable {
|
|
21
|
+
private readonly _docSkeletonManagerService;
|
|
22
|
+
private readonly _currentUniverService;
|
|
23
|
+
private readonly _commandService;
|
|
24
|
+
private readonly _renderManagerService;
|
|
25
|
+
private readonly _textSelectionRenderManager;
|
|
26
|
+
private readonly _textSelectionManagerService;
|
|
27
|
+
private readonly _editorService;
|
|
28
|
+
private _loadedMap;
|
|
29
|
+
constructor(_docSkeletonManagerService: DocSkeletonManagerService, _currentUniverService: IUniverInstanceService, _commandService: ICommandService, _renderManagerService: IRenderManagerService, _textSelectionRenderManager: ITextSelectionRenderManager, _textSelectionManagerService: TextSelectionManagerService, _editorService: IEditorService);
|
|
30
|
+
private _initialize;
|
|
31
|
+
private _init;
|
|
32
|
+
private _create;
|
|
33
|
+
private _initialMain;
|
|
34
|
+
private _isEditorReadOnly;
|
|
35
|
+
private _setEditorFocus;
|
|
36
|
+
private _commandExecutedListener;
|
|
37
|
+
private _skeletonListener;
|
|
38
|
+
private _getDocObjectById;
|
|
39
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
|
|
17
|
+
import { DocSkeletonManagerService, TextSelectionManagerService } from '@univerjs/docs';
|
|
18
|
+
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
19
|
+
import { IEditorService } from '@univerjs/ui';
|
|
20
|
+
export declare class ZoomController extends Disposable {
|
|
21
|
+
private readonly _docSkeletonManagerService;
|
|
22
|
+
private readonly _currentUniverService;
|
|
23
|
+
private readonly _commandService;
|
|
24
|
+
private readonly _renderManagerService;
|
|
25
|
+
private readonly _textSelectionManagerService;
|
|
26
|
+
private readonly _editorService;
|
|
27
|
+
private _initializedRender;
|
|
28
|
+
constructor(_docSkeletonManagerService: DocSkeletonManagerService, _currentUniverService: IUniverInstanceService, _commandService: ICommandService, _renderManagerService: IRenderManagerService, _textSelectionManagerService: TextSelectionManagerService, _editorService: IEditorService);
|
|
29
|
+
dispose(): void;
|
|
30
|
+
private _initialize;
|
|
31
|
+
private _initialRenderRefresh;
|
|
32
|
+
private _skeletonListener;
|
|
33
|
+
private _commandExecutedListener;
|
|
34
|
+
private _updateViewZoom;
|
|
35
|
+
private _calculatePagePosition;
|
|
36
|
+
private _getDocObject;
|
|
37
|
+
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,24 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
redo: string;
|
|
20
|
-
font: string;
|
|
21
|
-
fontSize: string;
|
|
22
|
-
bold: string;
|
|
23
|
-
italic: string;
|
|
24
|
-
strikethrough: string;
|
|
25
|
-
subscript: string;
|
|
26
|
-
superscript: string;
|
|
27
|
-
textColor: {
|
|
28
|
-
main: string;
|
|
29
|
-
right: string;
|
|
30
|
-
};
|
|
31
|
-
resetColor: string;
|
|
32
|
-
order: string;
|
|
33
|
-
unorder: string;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
export default _default;
|
|
16
|
+
import type zhCN from './zh-CN';
|
|
17
|
+
declare const locale: typeof zhCN;
|
|
18
|
+
export default locale;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
declare const
|
|
16
|
+
declare const locale: {
|
|
17
17
|
toolbar: {
|
|
18
18
|
undo: string;
|
|
19
19
|
redo: string;
|
|
@@ -34,4 +34,4 @@ declare const _default: {
|
|
|
34
34
|
unorder: string;
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
|
-
export default
|
|
37
|
+
export default locale;
|
|
@@ -0,0 +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
|
+
*/
|
|
16
|
+
import type { IContextService } from '@univerjs/core';
|
|
17
|
+
export declare function whenDocAndEditorFocused(contextService: IContextService): boolean;
|
|
18
|
+
export declare function whenDocAndEditorFocusedWithBreakLine(contextService: IContextService): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
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 React from 'react';
|
|
17
|
+
/**
|
|
18
|
+
* Doc standalone background
|
|
19
|
+
*/
|
|
20
|
+
export declare const DocBackground: () => React.JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
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';
|
|
17
|
+
import type { RenderManagerService } from '@univerjs/engine-render';
|
|
18
|
+
export declare class DocCanvasView extends RxDisposable {
|
|
19
|
+
private readonly _renderManagerService;
|
|
20
|
+
private readonly _configService;
|
|
21
|
+
private readonly _currentUniverService;
|
|
22
|
+
private _scene;
|
|
23
|
+
private _currentDocumentModel;
|
|
24
|
+
private readonly _fps$;
|
|
25
|
+
readonly fps$: import("rxjs").Observable<string>;
|
|
26
|
+
constructor(_renderManagerService: RenderManagerService, _configService: IConfigService, _currentUniverService: IUniverInstanceService);
|
|
27
|
+
private _initialize;
|
|
28
|
+
dispose(): void;
|
|
29
|
+
private _create;
|
|
30
|
+
private _addNewRender;
|
|
31
|
+
private _addComponent;
|
|
32
|
+
}
|
package/lib/umd/index.js
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
(function(p,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("@univerjs/design"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","@univerjs/docs","@univerjs/engine-render","@univerjs/design","rxjs"],r):(p=typeof globalThis<"u"?globalThis:p||self,r(p.UniverDocsUi={},p.UniverCore,p["@wendellhu/redi"],p.UniverUi,p.UniverDocs,p.UniverEngineRender,p.UniverDesign,p.rxjs))})(this,function(p,r,f,l,d,V,ie,O){"use strict";var lt=Object.defineProperty;var ct=(p,r,f)=>r in p?lt(p,r,{enumerable:!0,configurable:!0,writable:!0,value:f}):p[r]=f;var g=(p,r,f)=>(ct(p,typeof r!="symbol"?r+"":r,f),f);var G;const K={undo:!0,redo:!0,font:!0,fontSize:!0,bold:!0,italic:!0,strikethrough:!0,underline:!0,textColor:!0,fillColor:!0,horizontalAlignMode:!0,verticalAlignMode:!0,textWrapMode:!0,textRotateMode:!0},W={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0},z={layout:{docContainerConfig:W,toolbarConfig:K}},Y="DocUI",re={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_UP,preconditions:e=>e.getContextValue(r.FOCUSING_DOC),staticParameters:{direction:r.Direction.UP}},se={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_DOWN,preconditions:e=>e.getContextValue(r.FOCUSING_DOC),staticParameters:{direction:r.Direction.DOWN}},ae={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_LEFT,preconditions:e=>e.getContextValue(r.FOCUSING_DOC),staticParameters:{direction:r.Direction.LEFT}},le={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_RIGHT,preconditions:e=>e.getContextValue(r.FOCUSING_DOC),staticParameters:{direction:r.Direction.RIGHT}},ce={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_UP|l.MetaKeys.SHIFT,preconditions:e=>e.getContextValue(r.FOCUSING_DOC),staticParameters:{direction:r.Direction.UP}},de={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_DOWN|l.MetaKeys.SHIFT,preconditions:e=>e.getContextValue(r.FOCUSING_DOC),staticParameters:{direction:r.Direction.DOWN}},ue={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_LEFT|l.MetaKeys.SHIFT,preconditions:e=>e.getContextValue(r.FOCUSING_DOC),staticParameters:{direction:r.Direction.LEFT}},pe={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_RIGHT|l.MetaKeys.SHIFT,preconditions:e=>e.getContextValue(r.FOCUSING_DOC),staticParameters:{direction:r.Direction.RIGHT}},me={id:d.SelectAllOperation.id,binding:l.KeyCode.A|l.MetaKeys.CTRL_COMMAND,preconditions:e=>e.getContextValue(r.FOCUSING_DOC)||e.getContextValue(r.EDITOR_ACTIVATED)};var fe=Object.defineProperty,he=Object.getOwnPropertyDescriptor,Ce=(e,t,n,o)=>{for(var i=o>1?void 0:o?he(t,n):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=(o?a(t,n,i):a(i))||i);return o&&i&&fe(t,n,i),i},k=(e,t)=>(n,o)=>t(n,o,e);let B=class{constructor(e,t,n){g(this,"_docContainer");g(this,"getComponent",e=>{if(this._docContainer=e,!e.getContentRef().current)throw new Error("container is not ready")});g(this,"changeLocale",e=>{this._localeService.setLocale(e)});this._config=e,this._localeService=t,this._injector=n}getUIConfig(){return{injector:this._injector,config:this._config,changeLocale:this.changeLocale,getComponent:this.getComponent}}getContentRef(){return this._docContainer.getContentRef()}UIDidMount(e){if(this._docContainer)return e(this._docContainer)}getDocContainer(){return this._docContainer}};B=Ce([k(1,f.Inject(r.LocaleService)),k(2,f.Inject(f.Injector))],B);var ge=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,Se=(e,t,n,o)=>{for(var i=o>1?void 0:o?_e(t,n):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=(o?a(t,n,i):a(i))||i);return o&&i&&ge(t,n,i),i},U=(e,t)=>(n,o)=>t(n,o,e);let b=class extends r.RxDisposable{constructor(t,n,o,i,s){super();g(this,"_docContainerController");g(this,"changeLocale",t=>{this._localeService.setLocale(t)});this._localeService=n,this._injector=o,this._textSelectionRenderManager=i,this._layoutService=s,this._docContainerController=this._injector.createInstance(B,t),this._registerContainer()}_registerContainer(){this._layoutService&&this.disposeWithMe(this._layoutService.registerContainer(this._textSelectionRenderManager.__getEditorContainer()))}getDocContainerController(){return this._docContainerController}};b=Se([U(1,f.Inject(r.LocaleService)),U(2,f.Inject(f.Injector)),U(3,V.ITextSelectionRenderManager),U(4,f.Optional(l.LayoutService))],b);const x="UI_PLUGIN_DOCS",q=`${x}_COLOR_PICKER_COMPONENT`,Z=`${x}_FONT_FAMILY_COMPONENT`,X=`${x}_FONT_FAMILY_ITEM_COMPONENT`,J=`${x}_FONT_SIZE_COMPONENT`;function Oe(e){const t=e.get(r.ICommandService);return{id:d.SetInlineFormatBoldCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[l.MenuPosition.TOOLBAR_START],activated$:new O.Observable(n=>{const o=t.onCommandExecuted(i=>{var a;const s=i.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatCommand.id){const c=v(e);if(c==null)return;const u=(a=c.ts)==null?void 0:a.bl;n.next(u===r.BooleanNumber.TRUE)}});return n.next(!1),o.dispose}),hidden$:l.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function ve(e){const t=e.get(r.ICommandService);return{id:d.SetInlineFormatItalicCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[l.MenuPosition.TOOLBAR_START],activated$:new O.Observable(n=>{const o=t.onCommandExecuted(i=>{var a;const s=i.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatCommand.id){const c=v(e);if(c==null)return;const u=(a=c.ts)==null?void 0:a.it;n.next(u===r.BooleanNumber.TRUE)}});return n.next(!1),o.dispose}),hidden$:l.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function Te(e){const t=e.get(r.ICommandService);return{id:d.SetInlineFormatUnderlineCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[l.MenuPosition.TOOLBAR_START],activated$:new O.Observable(n=>{const o=t.onCommandExecuted(i=>{var a;const s=i.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatCommand.id){const c=v(e);if(c==null)return;const u=(a=c.ts)==null?void 0:a.ul;n.next((u==null?void 0:u.s)===r.BooleanNumber.TRUE)}});return n.next(!1),o.dispose}),hidden$:l.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function Ie(e){const t=e.get(r.ICommandService);return{id:d.SetInlineFormatStrikethroughCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[l.MenuPosition.TOOLBAR_START],activated$:new O.Observable(n=>{const o=t.onCommandExecuted(i=>{var a;const s=i.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatCommand.id){const c=v(e);if(c==null)return;const u=(a=c.ts)==null?void 0:a.st;n.next((u==null?void 0:u.s)===r.BooleanNumber.TRUE)}});return n.next(!1),o.dispose}),hidden$:l.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function be(e){const t=e.get(r.ICommandService);return{id:d.SetInlineFormatSubscriptCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"SubscriptSingle",tooltip:"toolbar.subscript",positions:[l.MenuPosition.TOOLBAR_START],activated$:new O.Observable(n=>{const o=t.onCommandExecuted(i=>{var a;const s=i.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatCommand.id){const c=v(e);if(c==null)return;const u=(a=c.ts)==null?void 0:a.va;n.next(u===r.BaselineOffset.SUBSCRIPT)}});return n.next(!1),o.dispose}),hidden$:l.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function ye(e){const t=e.get(r.ICommandService);return{id:d.SetInlineFormatSuperscriptCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"SuperscriptSingle",tooltip:"toolbar.superscript",positions:[l.MenuPosition.TOOLBAR_START],activated$:new O.Observable(n=>{const o=t.onCommandExecuted(i=>{var a;const s=i.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatCommand.id){const c=v(e);if(c==null)return;const u=(a=c.ts)==null?void 0:a.va;n.next(u===r.BaselineOffset.SUPERSCRIPT)}});return n.next(!1),o.dispose}),hidden$:l.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function Re(e){const t=e.get(r.ICommandService);return{id:d.SetInlineFormatFontFamilyCommand.id,tooltip:"toolbar.font",group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.SELECTOR,label:Z,positions:[l.MenuPosition.TOOLBAR_START],selections:l.FONT_FAMILY_LIST.map(n=>({label:{name:X,hoverable:!0},value:n.value})),value$:new O.Observable(n=>{const o=l.FONT_FAMILY_LIST[0].value,i=t.onCommandExecuted(s=>{var c;const a=s.id;if(a===d.SetTextSelectionsOperation.id||a===d.SetInlineFormatFontFamilyCommand.id){const u=v(e);if(u==null)return;const m=(c=u.ts)==null?void 0:c.ff;n.next(m!=null?m:o)}});return n.next(o),i.dispose}),hidden$:l.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function Me(e){const t=e.get(r.ICommandService);return{id:d.SetInlineFormatFontSizeCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:J,props:{min:1,max:400}},positions:[l.MenuPosition.TOOLBAR_START],selections:l.FONT_SIZE_LIST,value$:new O.Observable(n=>{const i=t.onCommandExecuted(s=>{var c;const a=s.id;if(a===d.SetTextSelectionsOperation.id||a===d.SetInlineFormatFontSizeCommand.id){const u=v(e);if(u==null)return;const m=(c=u.ts)==null?void 0:c.fs;n.next(m!=null?m:14)}});return n.next(14),i.dispose}),hidden$:l.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function De(e){const t=e.get(r.ICommandService),n=e.get(r.ThemeService);return{id:d.SetInlineFormatTextColorCommand.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON_SELECTOR,positions:[l.MenuPosition.TOOLBAR_START],selections:[{label:{name:q,hoverable:!1}}],value$:new O.Observable(o=>{const i=n.getCurrentTheme().textColor,s=t.onCommandExecuted(a=>{if(a.id===d.SetInlineFormatTextColorCommand.id){const c=a.params.value;o.next(c!=null?c:i)}});return o.next(i),s.dispose}),hidden$:l.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function Pe(e){return{id:d.OrderListCommand.id,group:l.MenuGroup.TOOLBAR_LAYOUT,type:l.MenuItemType.BUTTON,icon:"OrderSingle",tooltip:"toolbar.order",positions:[l.MenuPosition.TOOLBAR_START],hidden$:l.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function Ue(e){return{id:d.BulletListCommand.id,group:l.MenuGroup.TOOLBAR_LAYOUT,type:l.MenuItemType.BUTTON,icon:"UnorderSingle",tooltip:"toolbar.unorder",positions:[l.MenuPosition.TOOLBAR_START],hidden$:l.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function v(e){var u;const t=e.get(r.IUniverInstanceService),n=e.get(d.TextSelectionManagerService),o=t.getCurrentUniverDocInstance(),i=n.getActiveRange();if(o==null||i==null)return;const s=(u=o.getBody())==null?void 0:u.textRuns;if(s==null)return;const{startOffset:a}=i;return s.find(({st:m,ed:C})=>a>=m&&a<C)}var xe=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Ee=(e,t,n,o)=>{for(var i=o>1?void 0:o?Ne(t,n):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=(o?a(t,n,i):a(i))||i);return o&&i&&xe(t,n,i),i},I=(e,t)=>(n,o)=>t(n,o,e);let N=class extends r.Disposable{constructor(e,t,n,o,i,s){super(),this._injector=e,this._componentManager=t,this._commandService=n,this._shortcutService=o,this._menuService=i,this._uiController=s,this._init()}_initCustomComponents(){const e=this._componentManager;this.disposeWithMe(e.register(q,ie.ColorPicker)),this.disposeWithMe(e.register(Z,l.FontFamily)),this.disposeWithMe(e.register(X,l.FontFamilyItem)),this.disposeWithMe(e.register(J,l.FontSize))}_initMenus(){[Oe,ve,Te,Ie,be,ye,Me,Re,De,Pe,Ue].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e)))})}_init(){this._initCustomComponents(),this._initMenus()}};N=Ee([r.OnLifecycle(r.LifecycleStages.Rendered,N),I(0,f.Inject(f.Injector)),I(1,f.Inject(l.ComponentManager)),I(2,r.ICommandService),I(3,l.IShortcutService),I(4,l.IMenuService),I(5,l.IUIController)],N);const Fe={toolbar:{undo:"Undo",redo:"Redo",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript",textColor:{main:"Text color",right:"Choose color"},resetColor:"Reset",order:"Ordered list",unorder:"Unordered list"}},Q={toolbar:{undo:"撤销",redo:"重做",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",order:"有序列表",unorder:"无序列表"}},Ae={id:d.BreakLineCommand.id,preconditions:e=>e.getContextValue(r.FOCUSING_DOC),binding:l.KeyCode.ENTER},Le={id:d.DeleteLeftCommand.id,preconditions:e=>e.getContextValue(r.FOCUSING_DOC),binding:l.KeyCode.BACKSPACE},Be={id:d.DeleteRightCommand.id,preconditions:e=>e.getContextValue(r.FOCUSING_DOC),binding:l.KeyCode.DELETE},$e=10,we=6;function je(){return r.Tools.generateRandomId(we)}function He(e){const t=e.match(/data-copy-id="([^\s]+)"/);return t&&t[1]?t[1]:null}class Ge{constructor(){g(this,"_cache",new r.LRUMap($e))}set(t,n){this._cache.set(t,n)}get(t){return this._cache.get(t)}clear(){this._cache.clear()}}const ee=new Ge;function $(e){const t=e.style,n={},o=e.tagName.toLowerCase();switch(o){case"b":case"em":case"strong":{n.bl=r.BooleanNumber.TRUE;break}case"s":{n.st={s:r.BooleanNumber.TRUE};break}case"u":{n.ul={s:r.BooleanNumber.TRUE};break}case"i":{n.it=r.BooleanNumber.TRUE;break}case"sub":case"sup":{n.va=o==="sup"?r.BaselineOffset.SUPERSCRIPT:r.BaselineOffset.SUBSCRIPT;break}}for(let i=0;i<t.length;i++){const s=t[i],a=t.getPropertyValue(s);switch(s){case"font-family":{n.ff=a;break}case"font-size":{const c=Number.parseInt(a);Number.isNaN(c)||a.endsWith("pt")&&(n.fs=c);break}case"font-style":{a==="italic"&&(n.it=r.BooleanNumber.TRUE);break}case"font-weight":{Number(a)>400&&(n.bl=r.BooleanNumber.TRUE);break}case"text-decoration":{/underline/.test(a)?n.ul={s:r.BooleanNumber.TRUE}:/overline/.test(a)?n.ol={s:r.BooleanNumber.TRUE}:/line-through/.test(a)&&(n.st={s:r.BooleanNumber.TRUE});break}case"color":{const c=new r.ColorKit(a);c.isValid&&(n.cl={rgb:c.toRgbString()});break}case"background-color":{const c=new r.ColorKit(a);c.isValid&&(n.bg={rgb:c.toRgbString()});break}}}return n}function Ve(e){const t=new DOMParser,n=`<x-univer id="univer-root">${e}</x-univer>`;return t.parseFromString(n,"text/html").querySelector("#univer-root")}function te(e,t){const n=e.tagName.toLowerCase();return typeof t=="string"?n===t:Array.isArray(t)?t.some(o=>o===n):t(e)}const A=class A{constructor(){g(this,"_styleCache",new Map);g(this,"_styleRules",[]);g(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 n=A._pluginList.find(s=>s.checkPasteType(t)),o=Ve(t),i={dataStream:"",textRuns:[]};return n&&(this._styleRules=[...n.stylesRules],this._afterProcessRules=[...n.afterProcessRules]),this._styleCache.clear(),this._process(null,o==null?void 0:o.childNodes,i),this._styleCache.clear(),this._styleRules=[],this._afterProcessRules=[],i}_process(t,n,o){var i;for(const s of n)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)),o.dataStream+=a,c&&Object.getOwnPropertyNames(c).length&&o.textRuns.push({st:o.dataStream.length-a.length,ed:o.dataStream.length,ts:c})}else if(s.nodeType===Node.ELEMENT_NODE){const a=t?this._styleCache.get(t):{},c=this._styleRules.find(({filter:S})=>te(s,S)),u=c?c.getStyle(s):$(s);this._styleCache.set(s,{...a,...u});const{childNodes:m}=s;this._process(s,m,o);const C=this._afterProcessRules.find(({filter:S})=>te(s,S));C&&C.handler(o,s)}}};g(A,"_pluginList",[]);let y=A;const Ke={name:"univer-doc-paste-plugin-lark",checkPasteType(e){return/lark-record-clipboard/i.test(e)},stylesRules:[{filter:["s"],getStyle(e){const t=$(e);return{st:{s:r.BooleanNumber.TRUE},...t}}}],afterProcessRules:[{filter(e){return e.tagName==="DIV"&&/ace-line/i.test(e.className)},handler(e){e.paragraphs==null&&(e.paragraphs=[]),e.paragraphs.push({startIndex:e.dataStream.length}),e.dataStream+="\r"}}]};function We(e){const t=e.style,n={};for(let o=0;o<t.length;o++){const i=t[o],s=t.getPropertyValue(i);switch(i){case"margin-top":{const a=Number.parseInt(s);n.spaceAbove=/pt/.test(s)?ne(a):a;break}case"margin-bottom":{const a=Number.parseInt(s);n.spaceBelow=/pt/.test(s)?ne(a):a;break}}}return Object.getOwnPropertyNames(n).length?n:null}function ne(e){return e/.75}const ze={name:"univer-doc-paste-plugin-word",checkPasteType(e){return/word|mso/i.test(e)},stylesRules:[{filter:["b"],getStyle(e){const t=$(e);return{bl:r.BooleanNumber.TRUE,...t}}}],afterProcessRules:[{filter(e){return e.tagName==="P"&&/mso/i.test(e.className)},handler(e,t){e.paragraphs==null&&(e.paragraphs=[]);const n={startIndex:e.dataStream.length},o=We(t);o&&(n.paragraphStyle=o),e.paragraphs.push(n),e.dataStream+="\r"}}]};function Ye(e,t){const{st:n,ed:o,ts:i={}}=t,{ff:s,fs:a,it:c,bl:u,ul:m,st:C,ol:S,bg:P,cl:L,va:T}=i;let h=e.slice(n,o);const _=[];return c===r.BooleanNumber.TRUE&&(h=`<i>${h}</i>`),T===r.BaselineOffset.SUPERSCRIPT?h=`<sup>${h}</sup>`:T===r.BaselineOffset.SUBSCRIPT&&(h=`<sub>${h}</sub>`),(m==null?void 0:m.s)===r.BooleanNumber.TRUE&&(h=`<u>${h}</u>`),(C==null?void 0:C.s)===r.BooleanNumber.TRUE&&(h=`<s>${h}</s>`),u===r.BooleanNumber.TRUE&&(h=`<strong>${h}</strong>`),s&&_.push(`font-family: ${s}`),L&&_.push(`color: ${L.rgb}`),a&&_.push(`font-size: ${a}px`),S&&_.push("text-decoration: overline"),P&&_.push(`background: ${P.rgb}`),_.length?`<span style="${_.join(";")}">${h}</span>`:h}function oe(e,t=!0){const{dataStream:n,textRuns:o=[],paragraphs:i=[]}=e;let s=0;const a=[],c=[];for(const u of o){const{st:m,ed:C}=u;if(m!==s&&a.push(n.slice(s,m)),a.push(Ye(n,u)),s=C,t)for(const S of i){const{startIndex:P,paragraphStyle:L={}}=S;if(P>=m&&P<=C){const{spaceAbove:T,spaceBelow:h}=L,_=[];T!=null&&(typeof T=="number"?_.push(`margin-top: ${T}px`):_.push(`margin-top: ${T.v}px`)),h!=null&&(typeof h=="number"?_.push(`margin-bottom: ${h}px`):_.push(`margin-bottom: ${h.v}px`)),c.push(`<p className="UniverNormal" ${_.length?`style="${_.join(";")}"`:""}>${a.join("")}</p>`),a.length=0}}}return s<n.length&&a.push(n.slice(s,n.length)),c.join("")+a.join("")}class ke{convert(t){if(t.length===0)throw new Error("The bodyList length at least to be 1");if(t.length===1)return oe(t[0]);let n="";for(const o of t)n+='<p className="UniverNormal">',n+=oe(o,!1),n+="</p>";return n}}var qe=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,Xe=(e,t,n,o)=>{for(var i=o>1?void 0:o?Ze(t,n):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=(o?a(t,n,i):a(i))||i);return o&&i&&qe(t,n,i),i},R=(e,t)=>(n,o)=>t(n,o,e);y.use(ze),y.use(Ke);function Je(e){const t=e.replace(/\n/g,"\r"),n=[];for(let o=0;o<t.length;o++)t[o]==="\r"&&n.push({startIndex:o});return{dataStream:t,paragraphs:n}}const M=f.createIdentifier("doc.clipboard-service");let w=class extends r.Disposable{constructor(t,n,o,i,s){super();g(this,"_clipboardHooks",[]);g(this,"_htmlToUDM",new y);g(this,"_umdToHtml",new ke);this._currentUniverService=t,this._logService=n,this._commandService=o,this._clipboardInterfaceService=i,this._textSelectionManagerService=s}async copy(){const t=this._getDocumentBodyInRanges();try{this._setClipboardData(t)}catch(n){return this._logService.error("[DocClipboardService] copy failed",n),!1}return!0}async cut(){return this._cut()}async paste(t){const n=await this._generateBodyFromClipboardItems(t);return this._paste(n)}async legacyPaste(t,n){const o=this._generateBodyFromHtmlAndText(t,n);return this._paste(o)}async _cut(){var s;const{segmentId:t,endOffset:n,style:o}=(s=this._textSelectionManagerService.getActiveRange())!=null?s:{},i=this._textSelectionManagerService.getSelections();if(t==null&&this._logService.error("[DocClipboardController] segmentId is not existed"),n==null||i==null)return!1;this.copy();try{let a=n;for(const u of i){const{startOffset:m,endOffset:C}=u;m==null||C==null||C<=n&&(a-=C-m)}const c=[{startOffset:a,endOffset:a,style:o}];return this._commandService.executeCommand(d.CutContentCommand.id,{segmentId:t,textRanges:c})}catch{return this._logService.error("[DocClipboardController] cut content failed"),!1}}async _paste(t){var a;const{segmentId:n,endOffset:o,style:i}=(a=this._textSelectionManagerService.getActiveRange())!=null?a:{},s=this._textSelectionManagerService.getSelections();if(n==null&&this._logService.error("[DocClipboardController] segmentId does not exist!"),o==null||s==null)return!1;try{let c=o;for(const m of s){const{startOffset:C,endOffset:S}=m;C==null||S==null||S<=o&&(c+=t.dataStream.length-(S-C))}const u=[{startOffset:c,endOffset:c,style:i}];return this._commandService.executeCommand(d.InnerPasteCommand.id,{body:t,segmentId:n,textRanges:u})}catch{return this._logService.error("[DocClipboardController]","clipboard is empty."),!1}}async _setClipboardData(t){const n=je(),o=t.length>1?t.map(s=>s.dataStream).join(`
|
|
2
|
-
|
|
1
|
+
(function(f,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("@wendellhu/redi/react-bindings"),require("@univerjs/design"),require("react"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","@univerjs/docs","@univerjs/engine-render","@wendellhu/redi/react-bindings","@univerjs/design","react","rxjs"],a):(f=typeof globalThis<"u"?globalThis:f||self,a(f.UniverDocsUi={},f.UniverCore,f["@wendellhu/redi"],f.UniverUi,f.UniverDocs,f.UniverEngineRender,f["@wendellhu/redi/react-bindings"],f.UniverDesign,f.React,f.rxjs))})(this,function(f,a,m,l,d,C,Le,Ne,Be,T){"use strict";var Mn=Object.defineProperty;var Tn=(f,a,m)=>a in f?Mn(f,a,{enumerable:!0,configurable:!0,writable:!0,value:m}):f[a]=m;var O=(f,a,m)=>(Tn(f,typeof a!="symbol"?a+"":a,m),m);var Se;const fe={undo:!0,redo:!0,font:!0,fontSize:!0,bold:!0,italic:!0,strikethrough:!0,underline:!0,textColor:!0,fillColor:!0,horizontalAlignMode:!0,verticalAlignMode:!0,textWrapMode:!0,textRotateMode:!0},ve={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0},me={layout:{docContainerConfig:ve,toolbarConfig:fe}},Ce="DocUI";function D(r){return r.getContextValue(a.FOCUSING_DOC)&&r.getContextValue(a.FOCUSING_UNIVER_EDITOR)}function Ae(r){return r.getContextValue(a.FOCUSING_DOC)&&r.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&!r.getContextValue(a.FOCUSING_UNIVER_EDITOR_SINGLE_MODE)}const $e={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_UP,preconditions:D,staticParameters:{direction:a.Direction.UP}},we={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_DOWN,preconditions:D,staticParameters:{direction:a.Direction.DOWN}},Fe={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_LEFT,preconditions:D,staticParameters:{direction:a.Direction.LEFT}},je={id:d.MoveCursorOperation.id,binding:l.KeyCode.ARROW_RIGHT,preconditions:D,staticParameters:{direction:a.Direction.RIGHT}},We={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_UP|l.MetaKeys.SHIFT,preconditions:D,staticParameters:{direction:a.Direction.UP}},Ve={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_DOWN|l.MetaKeys.SHIFT,preconditions:D,staticParameters:{direction:a.Direction.DOWN}},ze={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_LEFT|l.MetaKeys.SHIFT,preconditions:D,staticParameters:{direction:a.Direction.LEFT}},ke={id:d.MoveSelectionOperation.id,binding:l.KeyCode.ARROW_RIGHT|l.MetaKeys.SHIFT,preconditions:D,staticParameters:{direction:a.Direction.RIGHT}},He={id:d.SelectAllOperation.id,binding:l.KeyCode.A|l.MetaKeys.CTRL_COMMAND,preconditions:r=>r.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&(r.getContextValue(a.FOCUSING_DOC)||r.getContextValue(a.EDITOR_ACTIVATED))};var Ye=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,Ke=(r,e,t,n)=>{for(var i=n>1?void 0:n?Ge(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Ye(e,t,i),i},Ie=(r,e)=>(t,n)=>e(t,n,r);let le=class{constructor(r,e,t){O(this,"_docContainer");O(this,"getComponent",r=>{if(this._docContainer=r,!r.getContentRef().current)throw new Error("container is not ready")});O(this,"changeLocale",r=>{this._localeService.setLocale(r)});this._config=r,this._localeService=e,this._injector=t}getUIConfig(){return{injector:this._injector,config:this._config,changeLocale:this.changeLocale,getComponent:this.getComponent}}getContentRef(){return this._docContainer.getContentRef()}UIDidMount(r){if(this._docContainer)return r(this._docContainer)}getDocContainer(){return this._docContainer}};le=Ke([Ie(1,m.Inject(a.LocaleService)),Ie(2,m.Inject(m.Injector))],le);var qe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,Ze=(r,e,t,n)=>{for(var i=n>1?void 0:n?Xe(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&qe(e,t,i),i},Y=(r,e)=>(t,n)=>e(t,n,r);let F=class extends a.RxDisposable{constructor(e,t,n,i,o){super();O(this,"_docContainerController");O(this,"changeLocale",e=>{this._localeService.setLocale(e)});this._localeService=t,this._injector=n,this._textSelectionRenderManager=i,this._layoutService=o,this._docContainerController=this._injector.createInstance(le,e),this._registerContainer()}_registerContainer(){this._layoutService&&this.disposeWithMe(this._layoutService.registerContainerElement(this._textSelectionRenderManager.__getEditorContainer()))}getDocContainerController(){return this._docContainerController}};F=Ze([Y(1,m.Inject(a.LocaleService)),Y(2,m.Inject(m.Injector)),Y(3,C.ITextSelectionRenderManager),Y(4,m.Optional(l.ILayoutService))],F);const G="UI_PLUGIN_DOCS",Oe=`${G}_COLOR_PICKER_COMPONENT`,be=`${G}_FONT_FAMILY_COMPONENT`,Me=`${G}_FONT_FAMILY_ITEM_COMPONENT`,Te=`${G}_FONT_SIZE_COMPONENT`;var Re={exports:{}},K={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Je=Be,Qe=Symbol.for("react.element"),et=Symbol.for("react.fragment"),tt=Object.prototype.hasOwnProperty,nt=Je.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,it={key:!0,ref:!0,__self:!0,__source:!0};function ye(r,e,t){var n,i={},o=null,s=null;t!==void 0&&(o=""+t),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)tt.call(e,n)&&!it.hasOwnProperty(n)&&(i[n]=e[n]);if(r&&r.defaultProps)for(n in e=r.defaultProps,e)i[n]===void 0&&(i[n]=e[n]);return{$$typeof:Qe,type:r,key:o,ref:s,props:i,_owner:nt.current}}K.Fragment=et,K.jsx=ye,K.jsxs=ye,Re.exports=K;var rt=Re.exports;const ot={docsUiCanvasBackground:"univer-docs-ui-canvas-background"},st=()=>rt.jsx("div",{className:ot.docsUiCanvasBackground});function at(r){const e=r.get(a.ICommandService);return{id:d.SetInlineFormatBoldCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=E(r);if(c==null)return;const u=(s=c.ts)==null?void 0:s.bl;t.next(u===a.BooleanNumber.TRUE)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.DOC)}}function ct(r){const e=r.get(a.ICommandService);return{id:d.SetInlineFormatItalicCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=E(r);if(c==null)return;const u=(s=c.ts)==null?void 0:s.it;t.next(u===a.BooleanNumber.TRUE)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.DOC)}}function lt(r){const e=r.get(a.ICommandService);return{id:d.SetInlineFormatUnderlineCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=E(r);if(c==null)return;const u=(s=c.ts)==null?void 0:s.ul;t.next((u==null?void 0:u.s)===a.BooleanNumber.TRUE)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.DOC)}}function dt(r){const e=r.get(a.ICommandService);return{id:d.SetInlineFormatStrikethroughCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=E(r);if(c==null)return;const u=(s=c.ts)==null?void 0:s.st;t.next((u==null?void 0:u.s)===a.BooleanNumber.TRUE)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.DOC)}}function ut(r){const e=r.get(a.ICommandService);return{id:d.SetInlineFormatSubscriptCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"SubscriptSingle",tooltip:"toolbar.subscript",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=E(r);if(c==null)return;const u=(s=c.ts)==null?void 0:s.va;t.next(u===a.BaselineOffset.SUBSCRIPT)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.DOC)}}function ht(r){const e=r.get(a.ICommandService);return{id:d.SetInlineFormatSuperscriptCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON,icon:"SuperscriptSingle",tooltip:"toolbar.superscript",positions:[l.MenuPosition.TOOLBAR_START],activated$:new T.Observable(t=>{const n=e.onCommandExecuted(i=>{var s;const o=i.id;if(o===d.SetTextSelectionsOperation.id||o===d.SetInlineFormatCommand.id){const c=E(r);if(c==null)return;const u=(s=c.ts)==null?void 0:s.va;t.next(u===a.BaselineOffset.SUPERSCRIPT)}});return t.next(!1),n.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.DOC)}}function _t(r){const e=r.get(a.ICommandService);return{id:d.SetInlineFormatFontFamilyCommand.id,tooltip:"toolbar.font",group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.SELECTOR,label:be,positions:[l.MenuPosition.TOOLBAR_START],selections:l.FONT_FAMILY_LIST.map(t=>({label:{name:Me,hoverable:!0},value:t.value})),value$:new T.Observable(t=>{const n=l.FONT_FAMILY_LIST[0].value,i=e.onCommandExecuted(o=>{var c;const s=o.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatFontFamilyCommand.id){const u=E(r);if(u==null)return;const _=(c=u.ts)==null?void 0:c.ff;t.next(_!=null?_:n)}});return t.next(n),i.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.DOC)}}function pt(r){const e=r.get(a.ICommandService);return{id:d.SetInlineFormatFontSizeCommand.id,group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:Te,props:{min:1,max:400}},positions:[l.MenuPosition.TOOLBAR_START],selections:l.FONT_SIZE_LIST,value$:new T.Observable(t=>{const i=e.onCommandExecuted(o=>{var c;const s=o.id;if(s===d.SetTextSelectionsOperation.id||s===d.SetInlineFormatFontSizeCommand.id){const u=E(r);if(u==null)return;const _=(c=u.ts)==null?void 0:c.fs;t.next(_!=null?_:14)}});return t.next(14),i.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.DOC)}}function gt(r){const e=r.get(a.ICommandService),t=r.get(a.ThemeService);return{id:d.SetInlineFormatTextColorCommand.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:l.MenuGroup.TOOLBAR_FORMAT,type:l.MenuItemType.BUTTON_SELECTOR,positions:[l.MenuPosition.TOOLBAR_START],selections:[{label:{name:Oe,hoverable:!1}}],value$:new T.Observable(n=>{const i=t.getCurrentTheme().textColor,o=e.onCommandExecuted(s=>{if(s.id===d.SetInlineFormatTextColorCommand.id){const c=s.params.value;n.next(c!=null?c:i)}});return n.next(i),o.dispose}),hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.DOC)}}function St(r){return{id:d.OrderListCommand.id,group:l.MenuGroup.TOOLBAR_LAYOUT,type:l.MenuItemType.BUTTON,icon:"OrderSingle",tooltip:"toolbar.order",positions:[l.MenuPosition.TOOLBAR_START],hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.DOC)}}function ft(r){return{id:d.BulletListCommand.id,group:l.MenuGroup.TOOLBAR_LAYOUT,type:l.MenuItemType.BUTTON,icon:"UnorderSingle",tooltip:"toolbar.unorder",positions:[l.MenuPosition.TOOLBAR_START],hidden$:l.getMenuHiddenObservable(r,a.UniverInstanceType.DOC)}}function E(r){var u;const e=r.get(a.IUniverInstanceService),t=r.get(d.TextSelectionManagerService),n=e.getCurrentUniverDocInstance(),i=t.getActiveRange();if(n==null||i==null)return;const o=(u=n.getBody())==null?void 0:u.textRuns;if(o==null)return;const{startOffset:s}=i;return o.find(({st:_,ed:p})=>s>=_&&s<p)}var vt=Object.defineProperty,mt=Object.getOwnPropertyDescriptor,Ct=(r,e,t,n)=>{for(var i=n>1?void 0:n?mt(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&vt(e,t,i),i},L=(r,e)=>(t,n)=>e(t,n,r);let q=class extends a.Disposable{constructor(r,e,t,n,i,o,s){super(),this._injector=r,this._componentManager=e,this._layoutService=t,this._editorService=n,this._menuService=i,this._uiController=o,this._currentUniverService=s,this._init()}_initCustomComponents(){const r=this._componentManager;this.disposeWithMe(r.register(Oe,Ne.ColorPicker)),this.disposeWithMe(r.register(be,l.FontFamily)),this.disposeWithMe(r.register(Me,l.FontFamilyItem)),this.disposeWithMe(r.register(Te,l.FontSize))}_initMenus(){[at,ct,lt,dt,ut,ht,pt,_t,gt,St,ft].forEach(r=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(r)))})}_init(){this._initCustomComponents(),this._initMenus(),this._initDocBackground()}_initDocBackground(){const r=this._currentUniverService.getAllUniverDocsInstance()[0].getUnitId();if(r==null)return;this._editorService.isEditor(r)||this.disposeWithMe(this._uiController.registerContentComponent(()=>Le.connectInjector(st,this._injector)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(a.UniverInstanceType.DOC,()=>{this._injector.get(C.ITextSelectionRenderManager).focus()}))}};q=Ct([a.OnLifecycle(a.LifecycleStages.Rendered,q),L(0,m.Inject(m.Injector)),L(1,m.Inject(l.ComponentManager)),L(2,l.ILayoutService),L(3,l.IEditorService),L(4,l.IMenuService),L(5,l.IUIController),L(6,a.IUniverInstanceService)],q);const It={toolbar:{undo:"Undo",redo:"Redo",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript",underline:"Underline",textColor:{main:"Text color",right:"Choose color"},resetColor:"Reset",order:"Ordered list",unorder:"Unordered list"}},De={toolbar:{undo:"撤销",redo:"重做",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",order:"有序列表",unorder:"无序列表"}},Ot={id:d.BreakLineCommand.id,preconditions:Ae,binding:l.KeyCode.ENTER},bt={id:d.DeleteLeftCommand.id,preconditions:D,binding:l.KeyCode.BACKSPACE},Mt={id:d.DeleteRightCommand.id,preconditions:D,binding:l.KeyCode.DELETE},Tt=10,Rt=6;function yt(){return a.Tools.generateRandomId(Rt)}function Dt(r){const e=r.match(/data-copy-id="([^\s]+)"/);return e&&e[1]?e[1]:null}class Et{constructor(){O(this,"_cache",new a.LRUMap(Tt))}set(e,t){this._cache.set(e,t)}get(e){return this._cache.get(e)}clear(){this._cache.clear()}}const Ee=new Et;function de(r){const e=r.style,t={},n=r.tagName.toLowerCase();switch(n){case"b":case"em":case"strong":{t.bl=a.BooleanNumber.TRUE;break}case"s":{t.st={s:a.BooleanNumber.TRUE};break}case"u":{t.ul={s:a.BooleanNumber.TRUE};break}case"i":{t.it=a.BooleanNumber.TRUE;break}case"sub":case"sup":{t.va=n==="sup"?a.BaselineOffset.SUPERSCRIPT:a.BaselineOffset.SUBSCRIPT;break}}for(let i=0;i<e.length;i++){const o=e[i],s=e.getPropertyValue(o);switch(o){case"font-family":{t.ff=s;break}case"font-size":{const c=Number.parseInt(s);Number.isNaN(c)||s.endsWith("pt")&&(t.fs=c);break}case"font-style":{s==="italic"&&(t.it=a.BooleanNumber.TRUE);break}case"font-weight":{Number(s)>400&&(t.bl=a.BooleanNumber.TRUE);break}case"text-decoration":{/underline/.test(s)?t.ul={s:a.BooleanNumber.TRUE}:/overline/.test(s)?t.ol={s:a.BooleanNumber.TRUE}:/line-through/.test(s)&&(t.st={s:a.BooleanNumber.TRUE});break}case"color":{const c=new a.ColorKit(s);c.isValid&&(t.cl={rgb:c.toRgbString()});break}case"background-color":{const c=new a.ColorKit(s);c.isValid&&(t.bg={rgb:c.toRgbString()});break}}}return t}function Pt(r){const e=new DOMParser,t=`<x-univer id="univer-root">${r}</x-univer>`;return e.parseFromString(t,"text/html").querySelector("#univer-root")}function Pe(r,e){const t=r.tagName.toLowerCase();return typeof e=="string"?t===e:Array.isArray(e)?e.some(n=>n===t):e(r)}const se=class se{constructor(){O(this,"_styleCache",new Map);O(this,"_styleRules",[]);O(this,"_afterProcessRules",[])}static use(e){if(this._pluginList.includes(e))throw new Error(`Univer paste plugin ${e.name} already added`);this._pluginList.push(e)}convert(e){const t=se._pluginList.find(o=>o.checkPasteType(e)),n=Pt(e),i={dataStream:"",textRuns:[]};return t&&(this._styleRules=[...t.stylesRules],this._afterProcessRules=[...t.afterProcessRules]),this._styleCache.clear(),this._process(null,n==null?void 0:n.childNodes,i),this._styleCache.clear(),this._styleRules=[],this._afterProcessRules=[],i}_process(e,t,n){var i;for(const o of t)if(o.nodeType===Node.TEXT_NODE){const s=(i=o.nodeValue)==null?void 0:i.replace(/[\r\n]/g,"");let c;e&&this._styleCache.has(e)&&(c=this._styleCache.get(e)),n.dataStream+=s,c&&Object.getOwnPropertyNames(c).length&&n.textRuns.push({st:n.dataStream.length-s.length,ed:n.dataStream.length,ts:c})}else if(o.nodeType===Node.ELEMENT_NODE){const s=e?this._styleCache.get(e):{},c=this._styleRules.find(({filter:v})=>Pe(o,v)),u=c?c.getStyle(o):de(o);this._styleCache.set(o,{...s,...u});const{childNodes:_}=o;this._process(o,_,n);const p=this._afterProcessRules.find(({filter:v})=>Pe(o,v));p&&p.handler(n,o)}}};O(se,"_pluginList",[]);let j=se;const Ut={name:"univer-doc-paste-plugin-lark",checkPasteType(r){return/lark-record-clipboard/i.test(r)},stylesRules:[{filter:["s"],getStyle(r){const e=de(r);return{st:{s:a.BooleanNumber.TRUE},...e}}}],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"}}]};function xt(r){const e=r.style,t={};for(let n=0;n<e.length;n++){const i=e[n],o=e.getPropertyValue(i);switch(i){case"margin-top":{const s=Number.parseInt(o);t.spaceAbove=/pt/.test(o)?C.ptToPixel(s):s;break}case"margin-bottom":{const s=Number.parseInt(o);t.spaceBelow=/pt/.test(o)?C.ptToPixel(s):s;break}}}return Object.getOwnPropertyNames(t).length?t:null}const Lt={name:"univer-doc-paste-plugin-word",checkPasteType(r){return/word|mso/i.test(r)},stylesRules:[{filter:["b"],getStyle(r){const e=de(r);return{bl:a.BooleanNumber.TRUE,...e}}}],afterProcessRules:[{filter(r){return r.tagName==="P"&&/mso/i.test(r.className)},handler(r,e){r.paragraphs==null&&(r.paragraphs=[]);const t={startIndex:r.dataStream.length},n=xt(e);n&&(t.paragraphStyle=n),r.paragraphs.push(t),r.dataStream+="\r"}}]};function Nt(r,e){const{st:t,ed:n,ts:i={}}=e,{ff:o,fs:s,it:c,bl:u,ul:_,st:p,ol:v,bg:I,cl:b,va:S}=i;let h=r.slice(t,n);const g=[];return c===a.BooleanNumber.TRUE&&(h=`<i>${h}</i>`),S===a.BaselineOffset.SUPERSCRIPT?h=`<sup>${h}</sup>`:S===a.BaselineOffset.SUBSCRIPT&&(h=`<sub>${h}</sub>`),(_==null?void 0:_.s)===a.BooleanNumber.TRUE&&(h=`<u>${h}</u>`),(p==null?void 0:p.s)===a.BooleanNumber.TRUE&&(h=`<s>${h}</s>`),u===a.BooleanNumber.TRUE&&(h=`<strong>${h}</strong>`),o&&g.push(`font-family: ${o}`),b&&g.push(`color: ${b.rgb}`),s&&g.push(`font-size: ${s}px`),v&&g.push("text-decoration: overline"),I&&g.push(`background: ${I.rgb}`),g.length?`<span style="${g.join(";")}">${h}</span>`:h}function Ue(r,e=!0){const{dataStream:t,textRuns:n=[],paragraphs:i=[]}=r;let o=0;const s=[],c=[];for(const u of n){const{st:_,ed:p}=u;if(_!==o&&s.push(t.slice(o,_)),s.push(Nt(t,u)),o=p,e)for(const v of i){const{startIndex:I,paragraphStyle:b={}}=v;if(I>=_&&I<=p){const{spaceAbove:S,spaceBelow:h}=b,g=[];S!=null&&(typeof S=="number"?g.push(`margin-top: ${S}px`):g.push(`margin-top: ${S.v}px`)),h!=null&&(typeof h=="number"?g.push(`margin-bottom: ${h}px`):g.push(`margin-bottom: ${h.v}px`)),c.push(`<p className="UniverNormal" ${g.length?`style="${g.join(";")}"`:""}>${s.join("")}</p>`),s.length=0}}}return o<t.length&&s.push(t.slice(o,t.length)),c.join("")+s.join("")}class Bt{convert(e){if(e.length===0)throw new Error("The bodyList length at least to be 1");if(e.length===1)return Ue(e[0]);let t="";for(const n of e)t+='<p className="UniverNormal">',t+=Ue(n,!1),t+="</p>";return t}}var At=Object.defineProperty,$t=Object.getOwnPropertyDescriptor,wt=(r,e,t,n)=>{for(var i=n>1?void 0:n?$t(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&At(e,t,i),i},W=(r,e)=>(t,n)=>e(t,n,r);j.use(Lt),j.use(Ut);function Ft(r){const e=r.replace(/\n/g,"\r"),t=[];for(let n=0;n<e.length;n++)e[n]==="\r"&&t.push({startIndex:n});return{dataStream:e,paragraphs:t}}const V=m.createIdentifier("doc.clipboard-service");let ue=class extends a.Disposable{constructor(e,t,n,i,o){super();O(this,"_clipboardHooks",[]);O(this,"_htmlToUDM",new j);O(this,"_umdToHtml",new Bt);this._currentUniverService=e,this._logService=t,this._commandService=n,this._clipboardInterfaceService=i,this._textSelectionManagerService=o}async copy(){const e=this._getDocumentBodyInRanges();if(e.length===0)return!1;try{this._setClipboardData(e)}catch(t){return this._logService.error("[DocClipboardService] copy failed",t),!1}return!0}async cut(){return this._cut()}async paste(e){const t=await this._generateBodyFromClipboardItems(e);return this._paste(t)}async legacyPaste(e,t){const n=this._generateBodyFromHtmlAndText(e,t);return this._paste(n)}async _cut(){var o;const{segmentId:e,endOffset:t,style:n}=(o=this._textSelectionManagerService.getActiveRange())!=null?o:{},i=this._textSelectionManagerService.getSelections();if(e==null&&this._logService.error("[DocClipboardController] segmentId is not existed"),t==null||i==null)return!1;this.copy();try{let s=t;for(const u of i){const{startOffset:_,endOffset:p}=u;_==null||p==null||p<=t&&(s-=p-_)}const c=[{startOffset:s,endOffset:s,style:n}];return this._commandService.executeCommand(d.CutContentCommand.id,{segmentId:e,textRanges:c})}catch{return this._logService.error("[DocClipboardController] cut content failed"),!1}}async _paste(e){var s;const{segmentId:t,endOffset:n,style:i}=(s=this._textSelectionManagerService.getActiveRange())!=null?s:{},o=this._textSelectionManagerService.getSelections();if(t==null&&this._logService.error("[DocClipboardController] segmentId does not exist!"),n==null||o==null)return!1;try{let c=n;for(const _ of o){const{startOffset:p,endOffset:v}=_;p==null||v==null||v<=n&&(c+=e.dataStream.length-(v-p))}const u=[{startOffset:c,endOffset:c,style:i}];return this._commandService.executeCommand(d.InnerPasteCommand.id,{body:e,segmentId:t,textRanges:u})}catch{return this._logService.error("[DocClipboardController]","clipboard is empty."),!1}}async _setClipboardData(e){const t=yt(),n=e.length>1?e.map(o=>o.dataStream).join(`
|
|
10
|
+
`):e[0].dataStream;let i=this._umdToHtml.convert(e);return e.length===1&&(i=i.replace(/(<[a-z]+)/,(o,s)=>`${s} data-copy-id="${t}"`),Ee.set(t,e[0])),this._clipboardInterfaceService.write(n,i)}addClipboardHook(e){return this._clipboardHooks.push(e),a.toDisposable(()=>{const t=this._clipboardHooks.indexOf(e);t>-1&&this._clipboardHooks.splice(t,1)})}_getDocumentBodyInRanges(){const e=this._textSelectionManagerService.getSelections(),t=this._currentUniverService.getCurrentUniverDocInstance(),n=[];if(e==null)return n;for(const i of e){const{startOffset:o,endOffset:s,collapsed:c}=i;if(c||o==null||s==null)continue;const u=t.sliceBody(o,s);u!=null&&n.push(u)}return n}async _generateBodyFromClipboardItems(e){try{let t="",n="";for(const i of e)for(const o of i.types)o===l.PLAIN_TEXT_CLIPBOARD_MIME_TYPE?n=await i.getType(o).then(s=>s&&s.text()):o===l.HTML_CLIPBOARD_MIME_TYPE&&(t=await i.getType(o).then(s=>s&&s.text()));return this._generateBodyFromHtmlAndText(t,n)}catch(t){return Promise.reject(t)}}_generateBodyFromHtmlAndText(e,t){if(!e){if(t)return Ft(t);throw new Error("[DocClipboardService] html and text cannot be both empty!")}const n=Dt(e);if(n){const i=Ee.get(n);if(i)return i}return this._htmlToUDM.convert(e)}};ue=wt([W(0,a.IUniverInstanceService),W(1,a.ILogService),W(2,a.ICommandService),W(3,l.IClipboardInterfaceService),W(4,m.Inject(d.TextSelectionManagerService))],ue);function X(r){return r.getContextValue(a.FOCUSING_DOC)||r.getContextValue(a.EDITOR_ACTIVATED)}const he=999,jt={id:l.CopyCommand.id,name:"doc.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:he,preconditions:X,handler:async r=>r.get(V).copy()},Wt={id:l.CutCommand.id,name:"doc.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:he,preconditions:X,handler:async r=>r.get(V).cut()},Vt={id:l.PasteCommand.id,name:"doc.command.paste",type:a.CommandType.COMMAND,multi:!0,priority:he,preconditions:X,handler:async r=>{const e=r.get(V),n=await r.get(l.IClipboardInterfaceService).read();return n.length===0?!1:e.paste(n)}};var zt=Object.defineProperty,kt=Object.getOwnPropertyDescriptor,Ht=(r,e,t,n)=>{for(var i=n>1?void 0:n?kt(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&zt(e,t,i),i},z=(r,e)=>(t,n)=>e(t,n,r);let Z=class extends a.RxDisposable{constructor(r,e,t,n,i){super(),this._commandService=r,this._clipboardInterfaceService=e,this._docClipboardService=t,this._textSelectionRenderManager=n,this._contextService=i,this._init()}_init(){[jt,Wt,Vt].forEach(r=>this.disposeWithMe(this._commandService.registerMultipleCommand(r))),[d.InnerPasteCommand,d.CutContentCommand].forEach(r=>this.disposeWithMe(this._commandService.registerCommand(r))),this._initLegacyPasteCommand()}_initLegacyPasteCommand(){var r;this._clipboardInterfaceService.supportClipboard||(r=this._textSelectionRenderManager)==null||r.onPaste$.pipe(T.takeUntil(this.dispose$)).subscribe(e=>{var o,s;if(!X(this._contextService))return;e.event.preventDefault();const t=e.event,n=(o=t.clipboardData)==null?void 0:o.getData("text/html"),i=(s=t.clipboardData)==null?void 0:s.getData("text/plain");this._docClipboardService.legacyPaste(n,i)})}};Z=Ht([a.OnLifecycle(a.LifecycleStages.Steady,Z),z(0,a.ICommandService),z(1,l.IClipboardInterfaceService),z(2,V),z(3,C.ITextSelectionRenderManager),z(4,a.IContextService)],Z);var Yt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,Kt=(r,e,t,n)=>{for(var i=n>1?void 0:n?Gt(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Yt(e,t,i),i},k=(r,e)=>(t,n)=>e(t,n,r);let J=class extends a.Disposable{constructor(e,t,n,i,o){super();O(this,"_initialEditors",new Set);this._currentUniverService=e,this._docSkeletonManagerService=t,this._editorService=n,this._commandService=i,this._textSelectionRenderManager=o,this._initialize()}_initialize(){this.disposeWithMe(this._editorService.resize$.subscribe(e=>{this._resize(e)})),this._editorService.getAllEditor().forEach(e=>{const t=e.editorUnitId;this._initialEditors.has(t)||(this._initialEditors.add(t),this._resize(t))}),this._commandExecutedListener(),this._initialSetValue(),this._initialBlur(),this._initialFocus(),this._initialValueChange()}_resize(e){var P,U,x;if(e==null)return;const t=this._editorService.getEditor(e);if((t==null?void 0:t.cancelDefaultResizeListener)===!0)return;const n=(P=this._docSkeletonManagerService.getSkeletonByUnitId(e))==null?void 0:P.skeleton,i=this._currentUniverService.getUniverDocInstance(e);if(t==null||t.render==null||n==null||i==null)return;const{marginTop:o=0,marginBottom:s=0,marginLeft:c=0,marginRight:u=0}=i.getSnapshot().documentStyle,{scene:_,mainComponent:p}=t.render;let{actualHeight:v,actualWidth:I}=n.getActualSize();v+=o+s,I+=c+u;const{width:b,height:S}=t.getBoundingClientRect(),h=_.getViewport(d.VIEWPORT_KEY.VIEW_MAIN);let g=h==null?void 0:h.getScrollBar();const M=Math.max(I,b),R=Math.max(v,S);_.transformByState({width:M,height:R}),p==null||p.resize(M,R),t.isSingle()?I>b?g==null?h&&new C.ScrollBar(h,{barSize:8,enableVertical:!1}):h==null||h.resetSizeAndScrollBar():(g=null,h==null||h.scrollTo({x:0,y:0}),(x=h==null?void 0:h.getScrollBar())==null||x.dispose()):v>S?g==null?h&&new C.ScrollBar(h,{enableHorizontal:!1,barSize:8}):h==null||h.resetSizeAndScrollBar():(g=null,h==null||h.scrollTo({x:0,y:0}),(U=h==null?void 0:h.getScrollBar())==null||U.dispose())}_initialSetValue(){this.disposeWithMe(this._editorService.setValue$.subscribe(e=>{this._commandService.executeCommand(d.CoverContentCommand.id,{unitId:e.editorUnitId,body:e.body,segmentId:null})}))}_initialBlur(){this.disposeWithMe(this._editorService.blur$.subscribe(()=>{this._textSelectionRenderManager.removeAllTextRanges(),this._textSelectionRenderManager.blur()}))}_initialFocus(){this.disposeWithMe(this._editorService.focus$.subscribe(e=>{this._textSelectionRenderManager.removeAllTextRanges(),this._textSelectionRenderManager.addTextRanges([e])}))}_initialValueChange(){this.disposeWithMe(this._textSelectionRenderManager.onCompositionupdate$.subscribe(this._valueChange.bind(this))),this.disposeWithMe(this._textSelectionRenderManager.onInput$.subscribe(this._valueChange.bind(this))),this.disposeWithMe(this._textSelectionRenderManager.onKeydown$.subscribe(this._valueChange.bind(this))),this.disposeWithMe(this._textSelectionRenderManager.onPaste$.subscribe(this._valueChange.bind(this)))}_valueChange(){const e=this._currentUniverService.getCurrentUniverDocInstance().getUnitId();if(e==null)return;const t=this._editorService.getEditor(e);t==null||t.isSheetEditor()||this._editorService.refreshValueChange(e)}_commandExecutedListener(){const e=[d.RichTextEditingMutation.id,l.SetEditorResizeOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=t.params,{unitId:i}=n;if(this._editorService.isSheetEditor(i))return;this._resize(i),this._valueChange()}}))}};J=Kt([a.OnLifecycle(a.LifecycleStages.Rendered,J),k(0,a.IUniverInstanceService),k(1,m.Inject(d.DocSkeletonManagerService)),k(2,l.IEditorService),k(3,a.ICommandService),k(4,C.ITextSelectionRenderManager)],J);var qt=Object.defineProperty,Xt=Object.getOwnPropertyDescriptor,Zt=(r,e,t,n)=>{for(var i=n>1?void 0:n?Xt(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&qt(e,t,i),i},Q=(r,e)=>(t,n)=>e(t,n,r);let ee=class extends a.RxDisposable{constructor(e,t,n,i){super();O(this,"_docRenderMap",new Set);this._docSkeletonManagerService=e,this._renderManagerService=t,this._commandService=n,this._editorService=i,this._initialRenderRefresh(),this._commandExecutedListener()}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeletonBefore$.pipe(T.takeUntil(this.dispose$)).subscribe(e=>{this._create(e)})}_create(e){if(e==null)return;const{skeleton:t,unitId:n}=e;let i=this._renderManagerService.getRenderById(n);i==null&&(this._renderManagerService.create(n),i=this._renderManagerService.getRenderById(n));const{mainComponent:o}=i;o.changeSkeleton(t),this._recalculateSizeBySkeleton(i,t)}_recalculateSizeBySkeleton(e,t){var p;const{mainComponent:n,scene:i,unitId:o}=e,s=n,c=(p=t.getSkeletonData())==null?void 0:p.pages;if(c==null)return;let u=0,_=0;for(let v=0,I=c.length;v<I;v++){const b=c[v],{pageWidth:S,pageHeight:h}=b;s.pageLayoutType===C.PageLayoutType.VERTICAL?(_+=h,_+=s.pageMarginTop,v===I-1&&(_+=s.pageMarginTop),u=Math.max(u,S)):s.pageLayoutType===C.PageLayoutType.HORIZONTAL&&(u+=S,v!==I-1&&(u+=s.pageMarginLeft),_=Math.max(_,h))}s.resize(u,_),this._editorService.isEditor(o)||i.resize(u,_)}_commandExecutedListener(){const e=[d.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const i=t.params,{unitId:o}=i,s=this._docSkeletonManagerService.getSkeletonByUnitId(o);if(s==null)return;const{skeleton:c}=s,u=this._renderManagerService.getRenderById(o);if(u==null)return;if(c.calculate(),this._editorService.isEditor(o)){(n=u.mainComponent)==null||n.makeDirty();return}this._recalculateSizeBySkeleton(u,c)}}))}};ee=Zt([a.OnLifecycle(a.LifecycleStages.Rendered,ee),Q(0,m.Inject(d.DocSkeletonManagerService)),Q(1,C.IRenderManagerService),Q(2,a.ICommandService),Q(3,l.IEditorService)],ee);var Jt=Object.defineProperty,Qt=Object.getOwnPropertyDescriptor,en=(r,e,t,n)=>{for(var i=n>1?void 0:n?Qt(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Jt(e,t,i),i},_e=(r,e)=>(t,n)=>e(t,n,r);f.DocCanvasView=class extends a.RxDisposable{constructor(t,n,i){super();O(this,"_scene");O(this,"_currentDocumentModel");O(this,"_fps$",new T.BehaviorSubject(""));O(this,"fps$",this._fps$.asObservable());this._renderManagerService=t,this._configService=n,this._currentUniverService=i,this._initialize()}_initialize(){this._renderManagerService.createRender$.pipe(T.takeUntil(this.dispose$)).subscribe(t=>{this._create(t)}),this._currentUniverService.currentDoc$.pipe(T.takeUntil(this.dispose$)).subscribe(t=>{this._create(t==null?void 0:t.getUnitId())}),this._currentUniverService.getAllUniverDocsInstance().forEach(t=>{this._create(t.getUnitId())})}dispose(){this._fps$.complete()}_create(t){if(t==null)return;const n=this._currentUniverService.getUniverDocInstance(t);n!=null&&(this._currentDocumentModel=n,this._renderManagerService.has(t)||this._addNewRender())}_addNewRender(){const t=this._currentDocumentModel,n=t.getUnitId(),i=t.getContainer(),o=t.getParentRenderUnitId();if(i!=null&&o!=null)throw new Error("container or parentRenderUnitId can only exist one");i==null&&o!=null?this._renderManagerService.createRenderWithParent(n,o):this._renderManagerService.createRender(n);const s=this._renderManagerService.getRenderById(n);if(s==null)return;const{scene:c,engine:u}=s;c.openTransformer(),this._scene=c;const _=new C.Viewport(d.VIEWPORT_KEY.VIEW_MAIN,c,{left:0,top:0,bottom:0,right:0,isWheelPreventDefaultX:!0});c.attachControl(),c.on(C.EVENT_TYPE.wheel,(I,b)=>{const S=I;if(S.ctrlKey){const h=Math.abs(S.deltaX);let g=h<40?.2:h<80?.4:.2;g*=S.deltaY>0?-1:1,c.scaleX<1&&(g/=2),c.scaleX+g>4?c.scale(4,4):c.scaleX+g<.1?c.scale(.1,.1):S.preventDefault()}else _.onMouseWheel(S,b)}),this._configService.getConfig("hasScroll")!==!1&&new C.ScrollBar(_),c.addLayer(new C.Layer(c,[],d.DOCS_COMPONENT_MAIN_LAYER_INDEX),new C.Layer(c,[],d.DOCS_COMPONENT_HEADER_LAYER_INDEX)),this._addComponent(s),this._currentDocumentModel.getShouldRenderLoopImmediately()&&u.runRenderLoop(()=>{c.render(),this._fps$.next(Math.round(u.getFps()).toString())}),this._renderManagerService.setCurrent(n)}_addComponent(t){const n=this._scene,i=this._currentDocumentModel,o=new C.Documents(d.DOCS_VIEW_KEY.MAIN,void 0,{pageMarginLeft:i.documentStyle.marginLeft||0,pageMarginTop:i.documentStyle.marginTop||0});o.zIndex=d.DOCS_COMPONENT_DEFAULT_Z_INDEX,t.mainComponent=o,t.components.set(d.DOCS_VIEW_KEY.MAIN,o),n.addObjects([o],d.DOCS_COMPONENT_MAIN_LAYER_INDEX)}},f.DocCanvasView=en([a.OnLifecycle(a.LifecycleStages.Starting,f.DocCanvasView),_e(0,C.IRenderManagerService),_e(1,a.IConfigService),_e(2,a.IUniverInstanceService)],f.DocCanvasView);var tn=Object.defineProperty,nn=Object.getOwnPropertyDescriptor,rn=(r,e,t,n)=>{for(var i=n>1?void 0:n?nn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&tn(e,t,i),i},B=(r,e)=>(t,n)=>e(t,n,r);let te=class extends a.Disposable{constructor(e,t,n,i,o,s){super();O(this,"_liquid",new C.Liquid);O(this,"_pageMarginCache",new Map);this._docSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._commandService=i,this._floatingObjectManagerService=o,this._editorService=s,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialRenderRefresh(),this._updateOnPluginChange()}_updateOnPluginChange(){this._floatingObjectManagerService.pluginUpdate$.subscribe(e=>{const t=this._docSkeletonManagerService.getCurrent();if(t==null)return;const{unitId:n,skeleton:i}=t,o=this._renderManagerService.getRenderById(n);if(o==null)return;const{mainComponent:s,components:c,scene:u}=o,_=s,{left:p,top:v}=_;e.forEach(I=>{const{unitId:b,subUnitId:S,floatingObjectId:h,floatingObject:g}=I,{left:M=0,top:R=0,width:P=0,height:U=0,angle:x,flipX:$,flipY:w,skewX:ae,skewY:ce}=g,y=this._pageMarginCache.get(h),On=(y==null?void 0:y.marginLeft)||0,bn=(y==null?void 0:y.marginTop)||0;i==null||i.getViewModel().getDataModel().updateDrawing(h,{left:M-p-On,top:R-v-bn,height:U,width:P})}),i==null||i.calculate(),s==null||s.makeDirty()})}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;const{skeleton:t,unitId:n}=e,i=this._renderManagerService.getRenderById(n);if(i==null)return;const{mainComponent:o}=i;o.changeSkeleton(t),this._refreshFloatingObject(n,t,i)})}_commandExecutedListener(){const e=[d.RichTextEditingMutation.id,d.SetDocZoomRatioOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const i=t.params,{unitId:o}=i,s=this._docSkeletonManagerService.getCurrent();if(s==null)return;const{unitId:c,skeleton:u}=s;if(o!==c)return;const _=this._renderManagerService.getRenderById(c);if(_==null)return;if(this._editorService.isEditor(c)){(n=_.mainComponent)==null||n.makeDirty();return}this._refreshFloatingObject(c,u,_)}}))}_refreshFloatingObject(e,t,n){const i=t==null?void 0:t.getSkeletonData(),{mainComponent:o,scene:s}=n,c=o;if(!i)return;const{left:u,top:_,pageLayoutType:p,pageMarginLeft:v,pageMarginTop:I}=c,{pages:b}=i,S=[];s.getAncestorScale(),this._liquid.reset(),this._pageMarginCache.clear();for(let h=0,g=b.length;h<g;h++){const M=b[h],{skeDrawings:R,marginLeft:P,marginTop:U}=M;this._liquid.translatePagePadding(M),R.forEach(x=>{const{aLeft:$,aTop:w,height:ae,width:ce,objectId:y}=x;S.push({unitId:e,subUnitId:a.DEFAULT_DOCUMENT_SUB_COMPONENT_ID,floatingObjectId:y,floatingObject:{left:$+u+this._liquid.x,top:w+_+this._liquid.y,width:ce,height:ae}}),this._pageMarginCache.set(y,{marginLeft:this._liquid.x,marginTop:this._liquid.y})}),this._liquid.translatePage(M,p,v,I)}this._floatingObjectManagerService.BatchAddOrUpdate(S)}};te=rn([a.OnLifecycle(a.LifecycleStages.Steady,te),B(0,m.Inject(d.DocSkeletonManagerService)),B(1,a.IUniverInstanceService),B(2,C.IRenderManagerService),B(3,a.ICommandService),B(4,a.IFloatingObjectManagerService),B(5,l.IEditorService)],te);var on=Object.defineProperty,sn=Object.getOwnPropertyDescriptor,an=(r,e,t,n)=>{for(var i=n>1?void 0:n?sn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&on(e,t,i),i},pe=(r,e)=>(t,n)=>e(t,n,r);const cn="rgba(198, 198, 198, 1)",ln="rgba(255, 255, 255, 1)";let ne=class extends a.Disposable{constructor(r,e,t){super(),this._renderManagerService=r,this._editorService=e,this._currentUniverService=t,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialRenderRefresh()}_initialRenderRefresh(){this._renderManagerService.currentRender$.subscribe(r=>{var o;if(r==null)return;const e=this._renderManagerService.getRenderById(r);if(this._editorService.isEditor(r)||this._currentUniverService.getUniverDocInstance(r)==null||e==null)return;const{mainComponent:t}=e,n=t,i=(o=n.getSkeleton())==null?void 0:o.getPageSize();this.disposeWithMe(a.toDisposable(n.onPageRenderObservable.add(s=>{var h,g,M,R;if(this._editorService.isEditor(r))return;const{page:c,pageLeft:u,pageTop:_,ctx:p}=s,{width:v,pageWidth:I,height:b,pageHeight:S}=c;p.save(),p.translate(u-.5,_-.5),C.Rect.drawWith(p,{width:(g=(h=i==null?void 0:i.width)!=null?h:I)!=null?g:v,height:(R=(M=i==null?void 0:i.height)!=null?M:S)!=null?R:b,strokeWidth:1,stroke:cn,fill:ln,zIndex:3}),p.restore()})))})}_commandExecutedListener(){}};ne=an([a.OnLifecycle(a.LifecycleStages.Rendered,ne),pe(0,C.IRenderManagerService),pe(1,l.IEditorService),pe(2,a.IUniverInstanceService)],ne);var dn=Object.defineProperty,un=Object.getOwnPropertyDescriptor,hn=(r,e,t,n)=>{for(var i=n>1?void 0:n?un(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&dn(e,t,i),i},A=(r,e)=>(t,n)=>e(t,n,r);let ie=class extends a.Disposable{constructor(e,t,n,i,o,s){super();O(this,"_initializedRender",new Set);this._docSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=i,this._textSelectionManagerService=o,this._editorService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._initialRenderRefresh()}_initialRenderRefresh(){this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;const{unitId:t}=e,n=this._renderManagerService.getRenderById(t);if(n==null||this._initializedRender.has(t)||this._editorService.isEditor(t))return;this._initializedRender.add(t);const{scene:i}=n;this.disposeWithMe(a.toDisposable(i.onMouseWheelObserver.add(o=>{if(!o.ctrlKey)return;const s=Math.abs(o.deltaX);let c=s<40?.2:s<80?.4:.2;c*=o.deltaY>0?-1:1,i.scaleX<1&&(c/=2);const u=this._currentUniverService.getCurrentUniverDocInstance(),_=u.zoomRatio;let p=+Number.parseFloat(`${_+c}`).toFixed(1);p=p>=4?4:p<=.1?.1:p,this._commandService.executeCommand(d.SetDocZoomRatioCommand.id,{zoomRatio:p,unitId:u.getUnitId()}),o.preventDefault()})))})}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;const n=this._currentUniverService.getCurrentUniverDocInstance().zoomRatio||1;this._updateViewZoom(n,!1)})))}_commandExecutedListener(){const e=[d.SetDocZoomRatioOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=this._currentUniverService.getCurrentUniverDocInstance(),i=t.params,{unitId:o}=i;if(o!==n.getUnitId())return;const s=n.zoomRatio||1;this._updateViewZoom(s)}}))}_updateViewZoom(e,t=!0){var i;const n=this._getDocObject();n!=null&&(n.scene.scale(e,e),this._calculatePagePosition(n,e),t&&this._textSelectionManagerService.refreshSelection(),(i=n.scene.getTransformer())==null||i.hideControl())}_calculatePagePosition(e,t){const{document:n,scene:i}=e,o=i==null?void 0:i.getParent(),{width:s,height:c,pageMarginLeft:u,pageMarginTop:_}=n;if(o==null||s===Number.POSITIVE_INFINITY||c===Number.POSITIVE_INFINITY)return;const{width:p,height:v}=o;let I=0,b=0,S=0,h=0,g=Number.POSITIVE_INFINITY;p>(s+u*2)*t?(I=p/2-s*t/2,I/=t,S=(p-u*2)/t,g=0):(I=u,S=s+u*2,g=(S-p/t)/2),v>c?(b=v/2-c/2,h=(v-_*2)/t):(b=_,h=c+_*2),i.resize(S,h+200),n.translate(I,b);const M=i.getViewport(d.VIEWPORT_KEY.VIEW_MAIN);if(g!==Number.POSITIVE_INFINITY&&M!=null){const R=M.getBarScroll(g,0).x;M.scrollTo({x:R})}return this}_getDocObject(){return d.getDocObject(this._currentUniverService,this._renderManagerService)}};ie=hn([a.OnLifecycle(a.LifecycleStages.Rendered,ie),A(0,m.Inject(d.DocSkeletonManagerService)),A(1,a.IUniverInstanceService),A(2,a.ICommandService),A(3,C.IRenderManagerService),A(4,m.Inject(d.TextSelectionManagerService)),A(5,l.IEditorService)],ie);var _n=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,gn=(r,e,t,n)=>{for(var i=n>1?void 0:n?pn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&_n(e,t,i),i},N=(r,e)=>(t,n)=>e(t,n,r);let re=class extends a.Disposable{constructor(e,t,n,i,o,s,c){super();O(this,"_loadedMap",new WeakSet);this._docSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=i,this._textSelectionRenderManager=o,this._textSelectionManagerService=s,this._editorService=c,this._initialize()}_initialize(){this._init(),this._skeletonListener(),this._commandExecutedListener()}_init(){this.disposeWithMe(this._renderManagerService.currentRender$.subscribe(e=>{this._create(e)})),this._renderManagerService.getRenderAll().forEach((e,t)=>{this._create(t)})}_create(e){if(e==null||this._currentUniverService.getUniverDocInstance(e)==null)return;const t=this._getDocObjectById(e);t==null||t.document==null||this._loadedMap.has(t.document)||(this._initialMain(e),this._loadedMap.add(t.document))}_initialMain(e){const t=this._getDocObjectById(e);if(t==null)return;const{document:n,scene:i}=t;this.disposeWithMe(a.toDisposable(n.onPointerEnterObserver.add(()=>{this._isEditorReadOnly(e)||(n.cursor=C.CURSOR_TYPE.TEXT)}))),this.disposeWithMe(a.toDisposable(n.onPointerLeaveObserver.add(()=>{n.cursor=C.CURSOR_TYPE.DEFAULT,i.resetCursor()}))),this.disposeWithMe(a.toDisposable(n==null?void 0:n.onPointerDownObserver.add((o,s)=>{if(this._isEditorReadOnly(e))return;this._currentUniverService.getCurrentUniverDocInstance().getUnitId()!==e&&this._currentUniverService.setCurrentUniverDocInstance(e),this._textSelectionRenderManager.eventTrigger(o),this._setEditorFocus(e),o.button!==2&&s.stopPropagation()}))),this.disposeWithMe(a.toDisposable(n==null?void 0:n.onDblclickObserver.add(o=>{this._textSelectionRenderManager.handleDblClick(o)}))),this.disposeWithMe(a.toDisposable(n==null?void 0:n.onTripleClickObserver.add(o=>{this._textSelectionRenderManager.handleTripleClick(o)})))}_isEditorReadOnly(e){const t=this._editorService.getEditor(e);return t?t.isReadOnly():!1}_setEditorFocus(e){if(this._currentUniverService.getAllUniverSheetsInstance().length>0){const n=this._currentUniverService.getCurrentUniverSheetInstance();this._editorService.setOperationSheetUnitId(n.getUnitId())}this._editorService.focusStyle(e)}_commandExecutedListener(){const e=[d.SetDocZoomRatioOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(e.includes(t.id)){const i=t.params,{unitId:o}=i,s=(n=this._textSelectionManagerService.getCurrentSelection())==null?void 0:n.unitId;if(o!==s)return;this._textSelectionManagerService.refreshSelection()}}))}_skeletonListener(){this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;const{unitId:t,skeleton:n}=e,i=this._renderManagerService.getRenderById(t);if(i==null)return;const{scene:o,mainComponent:s}=i;this._textSelectionRenderManager.changeRuntime(n,o,s),this._textSelectionManagerService.setCurrentSelectionNotRefresh({unitId:t,subUnitId:""})}))}_getDocObjectById(e){return d.getDocObjectById(e,this._renderManagerService)}};re=gn([a.OnLifecycle(a.LifecycleStages.Rendered,re),N(0,m.Inject(d.DocSkeletonManagerService)),N(1,a.IUniverInstanceService),N(2,a.ICommandService),N(3,C.IRenderManagerService),N(4,C.ITextSelectionRenderManager),N(5,m.Inject(d.TextSelectionManagerService)),N(6,l.IEditorService)],re);var Sn=Object.defineProperty,fn=Object.getOwnPropertyDescriptor,vn=(r,e,t,n)=>{for(var i=n>1?void 0:n?fn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Sn(e,t,i),i},H=(r,e)=>(t,n)=>e(t,n,r);const xe=1.5;let oe=class extends a.RxDisposable{constructor(r,e,t,n,i){super(),this._docSkeletonManagerService=r,this._textSelectionManagerService=e,this._editorService=t,this._currentUniverService=n,this._renderManagerService=i,this._init()}_init(){this._textSelectionManagerService.textSelection$.pipe(T.takeUntil(this.dispose$)).subscribe(r=>{if(r==null)return;const{isEditing:e,unitId:t}=r;e&&this._scrollToSelection(t)})}_scrollToSelection(r){var y;const e=this._textSelectionManagerService.getActiveRange(),t=this._getDocObject(),n=(y=this._docSkeletonManagerService.getCurrent())==null?void 0:y.skeleton;if(e==null||t==null||n==null)return;const{collapsed:i,startNodePosition:o}=e;if(!i)return;const s=t.document.getOffsetConfig(),{docsLeft:c,docsTop:u}=s,_=new C.NodePositionConvertToCursor(s,n),{contentBoxPointGroup:p}=_.getRangePointData(o,o),{left:v,top:I,height:b}=C.getAnchorBounding(p),S=v+c,h=I+u,g=t.scene.getViewport(d.VIEWPORT_KEY.VIEW_MAIN),M=!!this._editorService.getEditor(r);if(g==null)return;const{left:R,top:P,right:U,bottom:x}=g.getBounding().viewBound;let $=0,w=0;const ae=M?0:100;h<P?$=h-P:h>x-b&&($=h-x+b+ae),S<R?w=S-R:S>U-xe&&(w=S-U+xe);const ce=g.getBarScroll(w,$);g.scrollBy(ce)}_getDocObject(){return d.getDocObject(this._currentUniverService,this._renderManagerService)}};oe=vn([a.OnLifecycle(a.LifecycleStages.Rendered,oe),H(0,m.Inject(d.DocSkeletonManagerService)),H(1,m.Inject(d.TextSelectionManagerService)),H(2,l.IEditorService),H(3,a.IUniverInstanceService),H(4,C.IRenderManagerService)],oe);var mn=Object.defineProperty,Cn=Object.getOwnPropertyDescriptor,In=(r,e,t,n)=>{for(var i=n>1?void 0:n?Cn(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&mn(e,t,i),i},ge=(r,e)=>(t,n)=>e(t,n,r);f.UniverDocsUIPlugin=(Se=class extends a.Plugin{constructor(e,t,n,i){super(Ce),this._config=e,this._injector=t,this._localeService=n,this._logService=i,this._localeService.load({zhCN:De}),this._config=a.Tools.deepMerge({},me,this._config),this._initDependencies(t),this._initializeCommands()}onRendered(){this._initModules(),this._markDocAsFocused()}onDestroy(){}_initializeCommands(){[$e,we,je,Fe,We,Ve,ze,ke,He,bt,Mt,Ot].forEach(e=>{this._injector.get(l.IShortcutService).registerShortcut(e)})}_initDependencies(e){[[q],[Z],[J],[ee],[te],[ne],[ie],[re],[oe],[F,{useFactory:()=>this._injector.createInstance(F,this._config)}],[V,{useClass:ue}],[f.DocCanvasView]].forEach(n=>{e.add(n)})}_markDocAsFocused(){const e=this._injector.get(a.IUniverInstanceService),t=this._injector.get(l.IEditorService);try{const n=e.getCurrentUniverDocInstance(),i=n.getUnitId();t.isEditor(i)||e.focusUniverInstance(n.getUnitId())}catch(n){this._logService.warn(n)}}_initModules(){this._injector.get(F)}},O(Se,"type",a.PluginType.Doc),Se),f.UniverDocsUIPlugin=In([ge(1,m.Inject(m.Injector)),ge(2,m.Inject(a.LocaleService)),ge(3,a.ILogService)],f.UniverDocsUIPlugin),f.DOC_UI_PLUGIN_NAME=Ce,f.DefaultDocContainerConfig=ve,f.DefaultDocUiConfig=me,f.DefaultToolbarConfig=fe,f.enUS=It,f.zhCN=De,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|