@univerjs/docs-ui 0.1.0-beta.3 → 0.1.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +2 -1
- package/lib/es/index.js +888 -291
- package/lib/types/commands/commands/clipboard.command.d.ts +20 -0
- package/lib/types/controllers/app-ui-controller.d.ts +9 -4
- package/lib/types/controllers/clipboard.controller.d.ts +29 -0
- package/lib/types/controllers/doc-container-ui-controller.d.ts +1 -1
- package/lib/types/docs-ui-plugin.d.ts +1 -0
- package/lib/types/services/clipboard/__test__/html-and-udm-convert.spec.d.ts +16 -0
- package/lib/types/services/clipboard/clipboard.service.d.ts +55 -0
- package/lib/types/services/clipboard/copy-content-cache.d.ts +25 -0
- package/lib/types/services/clipboard/html-to-udm/converter.d.ts +30 -0
- package/lib/types/services/clipboard/html-to-udm/parse-node-style.d.ts +17 -0
- package/lib/types/services/clipboard/html-to-udm/parse-to-dom.d.ts +16 -0
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-lark.d.ts +18 -0
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-word.d.ts +18 -0
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/type.d.ts +30 -0
- package/lib/types/services/clipboard/html-to-udm/utils.d.ts +18 -0
- package/lib/types/services/clipboard/udm-to-html/__test__/convertor.spec.d.ts +16 -0
- package/lib/types/services/clipboard/udm-to-html/convertor.d.ts +19 -0
- package/lib/types/shortcuts/core-editing.shortcut.d.ts +19 -0
- package/lib/types/shortcuts/cursor.shortcut.d.ts +25 -0
- package/lib/umd/index.js +2 -1
- package/package.json +29 -22
|
@@ -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 type { IContextService, IMultiCommand } from '@univerjs/core';
|
|
17
|
+
export declare function whenDocOrEditor(contextService: IContextService): boolean;
|
|
18
|
+
export declare const DocCopyCommand: IMultiCommand;
|
|
19
|
+
export declare const DocCutCommand: IMultiCommand;
|
|
20
|
+
export declare const DocPasteCommand: IMultiCommand;
|
|
@@ -13,18 +13,23 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { LocaleService } from '@univerjs/core';
|
|
16
|
+
import { LocaleService, RxDisposable } from '@univerjs/core';
|
|
17
17
|
import { Injector } from '@wendellhu/redi';
|
|
18
|
+
import { LayoutService } from '@univerjs/ui';
|
|
19
|
+
import { ITextSelectionRenderManager } from '@univerjs/engine-render';
|
|
18
20
|
import type { IUniverDocsUIConfig } from '../basics';
|
|
19
21
|
import { DocContainerUIController } from './doc-container-ui-controller';
|
|
20
|
-
export declare class AppUIController {
|
|
22
|
+
export declare class AppUIController extends RxDisposable {
|
|
21
23
|
private readonly _localeService;
|
|
22
24
|
private readonly _injector;
|
|
25
|
+
private readonly _textSelectionRenderManager;
|
|
26
|
+
private readonly _layoutService?;
|
|
23
27
|
private _docContainerController;
|
|
24
|
-
constructor(_config: IUniverDocsUIConfig, _localeService: LocaleService, _injector: Injector);
|
|
28
|
+
constructor(_config: IUniverDocsUIConfig, _localeService: LocaleService, _injector: Injector, _textSelectionRenderManager: ITextSelectionRenderManager, _layoutService?: LayoutService | undefined);
|
|
29
|
+
private _registerContainer;
|
|
25
30
|
/**
|
|
26
31
|
* Change language
|
|
27
|
-
* @param {
|
|
32
|
+
* @param {string} locale new language
|
|
28
33
|
*
|
|
29
34
|
* e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
|
|
30
35
|
*
|
|
@@ -0,0 +1,29 @@
|
|
|
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, IContextService, RxDisposable } from '@univerjs/core';
|
|
17
|
+
import { IClipboardInterfaceService } from '@univerjs/ui';
|
|
18
|
+
import { ITextSelectionRenderManager } from '@univerjs/engine-render';
|
|
19
|
+
import { IDocClipboardService } from '../services/clipboard/clipboard.service';
|
|
20
|
+
export declare class DocClipboardController extends RxDisposable {
|
|
21
|
+
private readonly _commandService;
|
|
22
|
+
private readonly _clipboardInterfaceService;
|
|
23
|
+
private readonly _docClipboardService;
|
|
24
|
+
private readonly _textSelectionRenderManager;
|
|
25
|
+
private readonly _contextService;
|
|
26
|
+
constructor(_commandService: ICommandService, _clipboardInterfaceService: IClipboardInterfaceService, _docClipboardService: IDocClipboardService, _textSelectionRenderManager: ITextSelectionRenderManager, _contextService: IContextService);
|
|
27
|
+
private _init;
|
|
28
|
+
private _initLegacyPasteCommand;
|
|
29
|
+
}
|
|
@@ -33,7 +33,7 @@ export declare class DocContainerUIController {
|
|
|
33
33
|
getComponent: (ref: DocContainer) => void;
|
|
34
34
|
/**
|
|
35
35
|
* Change language
|
|
36
|
-
* @param {
|
|
36
|
+
* @param {string} lang new language
|
|
37
37
|
*
|
|
38
38
|
* e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
|
|
39
39
|
*
|
|
@@ -25,6 +25,7 @@ export declare class UniverDocsUIPlugin extends Plugin {
|
|
|
25
25
|
constructor(_config: IUniverDocsUIConfig, _injector: Injector, _localeService: LocaleService, _logService: ILogService);
|
|
26
26
|
onRendered(): void;
|
|
27
27
|
onDestroy(): void;
|
|
28
|
+
private _initializeCommands;
|
|
28
29
|
private _initDependencies;
|
|
29
30
|
private _markDocAsFocused;
|
|
30
31
|
private _initModules;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
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, ILogService, IUniverInstanceService } from '@univerjs/core';
|
|
17
|
+
import { IClipboardInterfaceService } from '@univerjs/ui';
|
|
18
|
+
import type { IDisposable } from '@wendellhu/redi';
|
|
19
|
+
import { TextSelectionManagerService } from '@univerjs/docs';
|
|
20
|
+
export interface IClipboardPropertyItem {
|
|
21
|
+
}
|
|
22
|
+
export interface IDocClipboardHook {
|
|
23
|
+
onCopyProperty?(start: number, end: number): IClipboardPropertyItem;
|
|
24
|
+
onCopyContent?(start: number, end: number): string;
|
|
25
|
+
}
|
|
26
|
+
export interface IDocClipboardService {
|
|
27
|
+
copy(): Promise<boolean>;
|
|
28
|
+
cut(): Promise<boolean>;
|
|
29
|
+
paste(items: ClipboardItem[]): Promise<boolean>;
|
|
30
|
+
legacyPaste(html?: string, text?: string): Promise<boolean>;
|
|
31
|
+
addClipboardHook(hook: IDocClipboardHook): IDisposable;
|
|
32
|
+
}
|
|
33
|
+
export declare const IDocClipboardService: import("@wendellhu/redi").IdentifierDecorator<IDocClipboardService>;
|
|
34
|
+
export declare class DocClipboardService extends Disposable implements IDocClipboardService {
|
|
35
|
+
private readonly _currentUniverService;
|
|
36
|
+
private readonly _logService;
|
|
37
|
+
private readonly _commandService;
|
|
38
|
+
private readonly _clipboardInterfaceService;
|
|
39
|
+
private readonly _textSelectionManagerService;
|
|
40
|
+
private _clipboardHooks;
|
|
41
|
+
private _htmlToUDM;
|
|
42
|
+
private _umdToHtml;
|
|
43
|
+
constructor(_currentUniverService: IUniverInstanceService, _logService: ILogService, _commandService: ICommandService, _clipboardInterfaceService: IClipboardInterfaceService, _textSelectionManagerService: TextSelectionManagerService);
|
|
44
|
+
copy(): Promise<boolean>;
|
|
45
|
+
cut(): Promise<boolean>;
|
|
46
|
+
paste(items: ClipboardItem[]): Promise<boolean>;
|
|
47
|
+
legacyPaste(html?: string, text?: string): Promise<boolean>;
|
|
48
|
+
private _cut;
|
|
49
|
+
private _paste;
|
|
50
|
+
private _setClipboardData;
|
|
51
|
+
addClipboardHook(hook: IDocClipboardHook): IDisposable;
|
|
52
|
+
private _getDocumentBodyInRanges;
|
|
53
|
+
private _generateBodyFromClipboardItems;
|
|
54
|
+
private _generateBodyFromHtmlAndText;
|
|
55
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { IDocumentBody } from '@univerjs/core';
|
|
17
|
+
export declare function genId(): string;
|
|
18
|
+
export declare function extractId(html: string): string | null;
|
|
19
|
+
export declare class CopyContentCache {
|
|
20
|
+
private _cache;
|
|
21
|
+
set(id: string, clipboardData: IDocumentBody): void;
|
|
22
|
+
get(id: string): IDocumentBody | undefined;
|
|
23
|
+
clear(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare const copyContentCache: CopyContentCache;
|
|
@@ -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 type { IDocumentBody } from '@univerjs/core';
|
|
17
|
+
import type { IPastePlugin } from './paste-plugins/type';
|
|
18
|
+
/**
|
|
19
|
+
* Convert html strings into data structures in univer, IDocumentBody.
|
|
20
|
+
* Support plug-in, add custom rules,
|
|
21
|
+
*/
|
|
22
|
+
export declare class HtmlToUDMService {
|
|
23
|
+
private static _pluginList;
|
|
24
|
+
static use(plugin: IPastePlugin): void;
|
|
25
|
+
private _styleCache;
|
|
26
|
+
private _styleRules;
|
|
27
|
+
private _afterProcessRules;
|
|
28
|
+
convert(html: string): IDocumentBody;
|
|
29
|
+
private _process;
|
|
30
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { ITextStyle } from '@univerjs/core';
|
|
17
|
+
export declare function extractNodeStyle(node: HTMLElement): ITextStyle;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
export default function parseToDom(rawHtml: string): Element | null;
|
|
@@ -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 { IPastePlugin } from './type';
|
|
17
|
+
declare const wordPastePlugin: IPastePlugin;
|
|
18
|
+
export default wordPastePlugin;
|
|
@@ -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 { IPastePlugin } from './type';
|
|
17
|
+
declare const wordPastePlugin: IPastePlugin;
|
|
18
|
+
export default wordPastePlugin;
|
|
@@ -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 type { IDocumentBody, ITextStyle } from '@univerjs/core';
|
|
17
|
+
export interface IStyleRule {
|
|
18
|
+
filter: string | string[] | ((node: HTMLElement) => boolean);
|
|
19
|
+
getStyle(node: HTMLElement): ITextStyle;
|
|
20
|
+
}
|
|
21
|
+
export interface IAfterProcessRule {
|
|
22
|
+
filter: string | string[] | ((node: HTMLElement) => boolean);
|
|
23
|
+
handler(doc: IDocumentBody, node: HTMLElement): void;
|
|
24
|
+
}
|
|
25
|
+
export interface IPastePlugin {
|
|
26
|
+
name: string;
|
|
27
|
+
checkPasteType(html: string): boolean;
|
|
28
|
+
stylesRules: IStyleRule[];
|
|
29
|
+
afterProcessRules: IAfterProcessRule[];
|
|
30
|
+
}
|
|
@@ -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 { IParagraphStyle, Nullable } from '@univerjs/core';
|
|
17
|
+
export declare function getParagraphStyle(el: HTMLElement): Nullable<IParagraphStyle>;
|
|
18
|
+
export declare function ptToPixel(pt: number): number;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { IDocumentBody } from '@univerjs/core';
|
|
17
|
+
export declare class UDMToHtmlService {
|
|
18
|
+
convert(bodyList: IDocumentBody[]): string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { IShortcutItem } from '@univerjs/ui';
|
|
17
|
+
export declare const BreakLineShortcut: IShortcutItem;
|
|
18
|
+
export declare const DeleteLeftShortcut: IShortcutItem;
|
|
19
|
+
export declare const DeleteRightShortcut: IShortcutItem;
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { IShortcutItem } from '@univerjs/ui';
|
|
17
|
+
export declare const MoveCursorUpShortcut: IShortcutItem;
|
|
18
|
+
export declare const MoveCursorDownShortcut: IShortcutItem;
|
|
19
|
+
export declare const MoveCursorLeftShortcut: IShortcutItem;
|
|
20
|
+
export declare const MoveCursorRightShortcut: IShortcutItem;
|
|
21
|
+
export declare const MoveSelectionUpShortcut: IShortcutItem;
|
|
22
|
+
export declare const MoveSelectionDownShortcut: IShortcutItem;
|
|
23
|
+
export declare const MoveSelectionLeftShortcut: IShortcutItem;
|
|
24
|
+
export declare const MoveSelectionRightShortcut: IShortcutItem;
|
|
25
|
+
export declare const SelectAllShortcut: IShortcutItem;
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
(function(d,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("@univerjs/docs"),require("rxjs"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","@univerjs/docs","rxjs","@univerjs/design"],r):(d=typeof globalThis<"u"?globalThis:d||self,r(d.UniverDocsUi={},d.UniverCore,d["@wendellhu/redi"],d.UniverUi,d.UniverDocs,d.rxjs,d.UniverDesign))})(this,function(d,r,p,s,c,O,N){"use strict";var le=Object.defineProperty;var ce=(d,r,p)=>r in d?le(d,r,{enumerable:!0,configurable:!0,writable:!0,value:p}):d[r]=p;var _=(d,r,p)=>(ce(d,typeof r!="symbol"?r+"":r,p),p);var M;const R={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},U={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0},F={layout:{docContainerConfig:U,toolbarConfig:R}},b="DocUI";var B=Object.defineProperty,$=Object.getOwnPropertyDescriptor,j=(e,n,t,o)=>{for(var i=o>1?void 0:o?$(n,t):n,l=e.length-1,a;l>=0;l--)(a=e[l])&&(i=(o?a(n,t,i):a(i))||i);return o&&i&&B(n,t,i),i},L=(e,n)=>(t,o)=>n(t,o,e);let g=class{constructor(e,n,t){_(this,"_docContainer");_(this,"getComponent",e=>{if(this._docContainer=e,!e.getContentRef().current)throw new Error("container is not ready")});_(this,"changeLocale",e=>{this._localeService.setLocale(e)});this._config=e,this._localeService=n,this._injector=t}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}};g=j([L(1,p.Inject(r.LocaleService)),L(2,p.Inject(p.Injector))],g);var w=Object.defineProperty,z=Object.getOwnPropertyDescriptor,G=(e,n,t,o)=>{for(var i=o>1?void 0:o?z(n,t):n,l=e.length-1,a;l>=0;l--)(a=e[l])&&(i=(o?a(n,t,i):a(i))||i);return o&&i&&w(n,t,i),i},A=(e,n)=>(t,o)=>n(t,o,e);let v=class{constructor(e,n,t){_(this,"_docContainerController");_(this,"changeLocale",e=>{this._localeService.setLocale(e)});this._localeService=n,this._injector=t,this._docContainerController=this._injector.createInstance(g,e)}getDocContainerController(){return this._docContainerController}};v=G([A(1,p.Inject(r.LocaleService)),A(2,p.Inject(p.Injector))],v);const C="UI_PLUGIN_DOCS",y=`${C}_COLOR_PICKER_COMPONENT`,D=`${C}_FONT_FAMILY_COMPONENT`,P=`${C}_FONT_FAMILY_ITEM_COMPONENT`,x=`${C}_FONT_SIZE_COMPONENT`;function H(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatBoldCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const m=(a=u.ts)==null?void 0:a.bl;t.next(m===r.BooleanNumber.TRUE)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function Y(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatItalicCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const m=(a=u.ts)==null?void 0:a.it;t.next(m===r.BooleanNumber.TRUE)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function q(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatUnderlineCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const m=(a=u.ts)==null?void 0:a.ul;t.next((m==null?void 0:m.s)===r.BooleanNumber.TRUE)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function W(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatStrikethroughCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const m=(a=u.ts)==null?void 0:a.st;t.next((m==null?void 0:m.s)===r.BooleanNumber.TRUE)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function Z(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatSubscriptCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"SubscriptSingle",tooltip:"toolbar.subscript",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const m=(a=u.ts)==null?void 0:a.va;t.next(m===r.BaselineOffset.SUBSCRIPT)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function K(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatSuperscriptCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON,icon:"SuperscriptSingle",tooltip:"toolbar.superscript",positions:[s.MenuPosition.TOOLBAR_START],activated$:new O.Observable(t=>{const o=n.onCommandExecuted(i=>{var a;const l=i.id;if(l===c.SetTextSelectionsOperation.id||l===c.SetInlineFormatCommand.id){const u=T(e);if(u==null)return;const m=(a=u.ts)==null?void 0:a.va;t.next(m===r.BaselineOffset.SUPERSCRIPT)}});return t.next(!1),o.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function V(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatFontFamilyCommand.id,tooltip:"toolbar.font",group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.SELECTOR,label:D,positions:[s.MenuPosition.TOOLBAR_START],selections:s.FONT_FAMILY_LIST.map(t=>({label:{name:P,hoverable:!0},value:t.value})),value$:new O.Observable(t=>{const o=s.FONT_FAMILY_LIST[0].value,i=n.onCommandExecuted(l=>{var u;const a=l.id;if(a===c.SetTextSelectionsOperation.id||a===c.SetInlineFormatFontFamilyCommand.id){const m=T(e);if(m==null)return;const f=(u=m.ts)==null?void 0:u.ff;t.next(f??o)}});return t.next(o),i.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function X(e){const n=e.get(r.ICommandService);return{id:c.SetInlineFormatFontSizeCommand.id,group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:x,props:{min:1,max:400}},positions:[s.MenuPosition.TOOLBAR_START],selections:s.FONT_SIZE_LIST,value$:new O.Observable(t=>{const i=n.onCommandExecuted(l=>{var u;const a=l.id;if(a===c.SetTextSelectionsOperation.id||a===c.SetInlineFormatFontSizeCommand.id){const m=T(e);if(m==null)return;const f=(u=m.ts)==null?void 0:u.fs;t.next(f??14)}});return t.next(14),i.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function J(e){const n=e.get(r.ICommandService),t=e.get(r.ThemeService);return{id:c.SetInlineFormatTextColorCommand.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:s.MenuGroup.TOOLBAR_FORMAT,type:s.MenuItemType.BUTTON_SELECTOR,positions:[s.MenuPosition.TOOLBAR_START],selections:[{label:{name:y,hoverable:!1}}],value$:new O.Observable(o=>{const i=t.getCurrentTheme().textColor,l=n.onCommandExecuted(a=>{if(a.id===c.SetInlineFormatTextColorCommand.id){const u=a.params.value;o.next(u??i)}});return o.next(i),l.dispose}),hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function Q(e){return{id:c.OrderListCommand.id,group:s.MenuGroup.TOOLBAR_LAYOUT,type:s.MenuItemType.BUTTON,icon:"OrderSingle",tooltip:"toolbar.order",positions:[s.MenuPosition.TOOLBAR_START],hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function k(e){return{id:c.BulletListCommand.id,group:s.MenuGroup.TOOLBAR_LAYOUT,type:s.MenuItemType.BUTTON,icon:"UnorderSingle",tooltip:"toolbar.unorder",positions:[s.MenuPosition.TOOLBAR_START],hidden$:s.getMenuHiddenObservable(e,r.UniverInstanceType.DOC)}}function T(e){var m;const n=e.get(r.IUniverInstanceService),t=e.get(c.TextSelectionManagerService),o=n.getCurrentUniverDocInstance(),i=t.getActiveRange();if(o==null||i==null)return;const l=(m=o.getBody())==null?void 0:m.textRuns;if(l==null)return;const{startOffset:a}=i;return l.find(({st:f,ed:ae})=>a>=f&&a<ae)}var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,ne=(e,n,t,o)=>{for(var i=o>1?void 0:o?te(n,t):n,l=e.length-1,a;l>=0;l--)(a=e[l])&&(i=(o?a(n,t,i):a(i))||i);return o&&i&&ee(n,t,i),i},S=(e,n)=>(t,o)=>n(t,o,e);let I=class extends r.Disposable{constructor(e,n,t,o,i,l){super(),this._injector=e,this._componentManager=n,this._commandService=t,this._shortcutService=o,this._menuService=i,this._uiController=l,this._init()}_initCustomComponents(){const e=this._componentManager;this.disposeWithMe(e.register(y,N.ColorPicker)),this.disposeWithMe(e.register(D,s.FontFamily)),this.disposeWithMe(e.register(P,s.FontFamilyItem)),this.disposeWithMe(e.register(x,s.FontSize))}_initMenus(){[H,Y,q,W,Z,K,X,V,J,Q,k].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e)))})}_init(){this._initCustomComponents(),this._initMenus()}};I=ne([r.OnLifecycle(r.LifecycleStages.Rendered,I),S(0,p.Inject(p.Injector)),S(1,p.Inject(s.ComponentManager)),S(2,r.ICommandService),S(3,s.IShortcutService),S(4,s.IMenuService),S(5,s.IUIController)],I);const oe={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"}},E={toolbar:{undo:"撤销",redo:"重做",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",order:"有序列表",unorder:"无序列表"}};var ie=Object.defineProperty,re=Object.getOwnPropertyDescriptor,se=(e,n,t,o)=>{for(var i=o>1?void 0:o?re(n,t):n,l=e.length-1,a;l>=0;l--)(a=e[l])&&(i=(o?a(n,t,i):a(i))||i);return o&&i&&ie(n,t,i),i},h=(e,n)=>(t,o)=>n(t,o,e);d.UniverDocsUIPlugin=(M=class extends r.Plugin{constructor(n,t,o,i){super(b),this._config=n,this._injector=t,this._localeService=o,this._logService=i,this._localeService.load({zhCN:E}),this._config=r.Tools.deepMerge({},F,this._config),this._initDependencies(t)}onRendered(){this._initModules(),this._markDocAsFocused()}onDestroy(){}_initDependencies(n){[[I],[v,{useFactory:()=>this._injector.createInstance(v,this._config)}]].forEach(o=>{n.add(o)})}_markDocAsFocused(){const n=this._injector.get(r.IUniverInstanceService);try{const t=n.getCurrentUniverDocInstance(),o=t.getUnitId();o!==r.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&o!==r.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&n.focusUniverInstance(t.getUnitId())}catch(t){this._logService.warn(t)}}_initModules(){this._injector.get(v)}},_(M,"type",r.PluginType.Doc),M),d.UniverDocsUIPlugin=se([h(1,p.Inject(p.Injector)),h(2,p.Inject(r.LocaleService)),h(3,r.ILogService)],d.UniverDocsUIPlugin),d.DOC_UI_PLUGIN_NAME=b,d.DefaultDocContainerConfig=U,d.DefaultDocUiConfig=F,d.DefaultToolbarConfig=R,d.enUS=oe,d.zhCN=E,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
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
|
+
`):t[0].dataStream;let i=this._umdToHtml.convert(t);return t.length===1&&(i=i.replace(/(<[a-z]+)/,(s,a)=>`${a} data-copy-id="${n}"`),ee.set(n,t[0])),this._clipboardInterfaceService.write(o,i)}addClipboardHook(t){return this._clipboardHooks.push(t),r.toDisposable(()=>{const n=this._clipboardHooks.indexOf(t);n>-1&&this._clipboardHooks.splice(n,1)})}_getDocumentBodyInRanges(){const t=this._textSelectionManagerService.getSelections(),n=this._currentUniverService.getCurrentUniverDocInstance(),o=[];if(t==null)return o;for(const i of t){const{startOffset:s,endOffset:a,collapsed:c}=i;if(c||s==null||a==null)continue;const u=n.sliceBody(s,a);u!=null&&o.push(u)}return o}async _generateBodyFromClipboardItems(t){try{let n="",o="";for(const i of t)for(const s of i.types)s===l.PLAIN_TEXT_CLIPBOARD_MIME_TYPE?o=await i.getType(s).then(a=>a&&a.text()):s===l.HTML_CLIPBOARD_MIME_TYPE&&(n=await i.getType(s).then(a=>a&&a.text()));return this._generateBodyFromHtmlAndText(n,o)}catch(n){return Promise.reject(n)}}_generateBodyFromHtmlAndText(t,n){if(!t){if(n)return Je(n);throw new Error("[DocClipboardService] html and text cannot be both empty!")}const o=He(t);if(o){const i=ee.get(o);if(i)return i}return this._htmlToUDM.convert(t)}};w=Xe([R(0,r.IUniverInstanceService),R(1,r.ILogService),R(2,r.ICommandService),R(3,l.IClipboardInterfaceService),R(4,f.Inject(d.TextSelectionManagerService))],w);function E(e){return e.getContextValue(r.FOCUSING_DOC)||e.getContextValue(r.EDITOR_ACTIVATED)}const j=999,Qe={id:l.CopyCommand.id,name:"doc.command.copy",type:r.CommandType.COMMAND,multi:!0,priority:j,preconditions:E,handler:async e=>e.get(M).copy()},et={id:l.CutCommand.id,name:"doc.command.cut",type:r.CommandType.COMMAND,multi:!0,priority:j,preconditions:E,handler:async e=>e.get(M).cut()},tt={id:l.PasteCommand.id,name:"doc.command.paste",type:r.CommandType.COMMAND,multi:!0,priority:j,preconditions:E,handler:async e=>{const t=e.get(M),o=await e.get(l.IClipboardInterfaceService).read();return o.length===0?!1:t.paste(o)}};var nt=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,it=(e,t,n,o)=>{for(var i=o>1?void 0:o?ot(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&&nt(t,n,i),i},D=(e,t)=>(n,o)=>t(n,o,e);let F=class extends r.RxDisposable{constructor(e,t,n,o,i){super(),this._commandService=e,this._clipboardInterfaceService=t,this._docClipboardService=n,this._textSelectionRenderManager=o,this._contextService=i,this._init()}_init(){[Qe,et,tt].forEach(e=>this.disposeWithMe(this._commandService.registerMultipleCommand(e))),[d.InnerPasteCommand,d.CutContentCommand].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e))),this._initLegacyPasteCommand()}_initLegacyPasteCommand(){var e;this._clipboardInterfaceService.supportClipboard||(e=this._textSelectionRenderManager)==null||e.onPaste$.pipe(O.takeUntil(this.dispose$)).subscribe(t=>{var s,a;if(!E(this._contextService))return;t.event.preventDefault();const n=t.event,o=(s=n.clipboardData)==null?void 0:s.getData("text/html"),i=(a=n.clipboardData)==null?void 0:a.getData("text/plain");this._docClipboardService.legacyPaste(o,i)})}};F=it([r.OnLifecycle(r.LifecycleStages.Steady,F),D(0,r.ICommandService),D(1,l.IClipboardInterfaceService),D(2,M),D(3,V.ITextSelectionRenderManager),D(4,r.IContextService)],F);var rt=Object.defineProperty,st=Object.getOwnPropertyDescriptor,at=(e,t,n,o)=>{for(var i=o>1?void 0:o?st(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&&rt(t,n,i),i},H=(e,t)=>(n,o)=>t(n,o,e);p.UniverDocsUIPlugin=(G=class extends r.Plugin{constructor(t,n,o,i){super(Y),this._config=t,this._injector=n,this._localeService=o,this._logService=i,this._localeService.load({zhCN:Q}),this._config=r.Tools.deepMerge({},z,this._config),this._initDependencies(n),this._initializeCommands()}onRendered(){this._initModules(),this._markDocAsFocused()}onDestroy(){}_initializeCommands(){[re,se,le,ae,ce,de,ue,pe,me,Le,Be,Ae].forEach(t=>{this._injector.get(l.IShortcutService).registerShortcut(t)})}_initDependencies(t){[[N],[F],[b,{useFactory:()=>this._injector.createInstance(b,this._config)}],[M,{useClass:w}]].forEach(o=>{t.add(o)})}_markDocAsFocused(){const t=this._injector.get(r.IUniverInstanceService);try{const n=t.getCurrentUniverDocInstance(),o=n.getUnitId();o!==r.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&o!==r.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&t.focusUniverInstance(n.getUnitId())}catch(n){this._logService.warn(n)}}_initModules(){this._injector.get(b)}},g(G,"type",r.PluginType.Doc),G),p.UniverDocsUIPlugin=at([H(1,f.Inject(f.Injector)),H(2,f.Inject(r.LocaleService)),H(3,r.ILogService)],p.UniverDocsUIPlugin),p.DOC_UI_PLUGIN_NAME=Y,p.DefaultDocContainerConfig=W,p.DefaultDocUiConfig=z,p.DefaultToolbarConfig=K,p.enUS=Fe,p.zhCN=Q,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-ui",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer normal ui-plugin-docs",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
|
+
"funding": {
|
|
9
|
+
"type": "opencollective",
|
|
10
|
+
"url": "https://opencollective.com/univer"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://univer.ai",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/dream-num/univer"
|
|
16
|
+
},
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/dream-num/univer/issues"
|
|
19
|
+
},
|
|
8
20
|
"keywords": [],
|
|
9
|
-
"sideEffects": [
|
|
10
|
-
"**/*.css"
|
|
11
|
-
],
|
|
12
21
|
"exports": {
|
|
13
22
|
".": {
|
|
14
23
|
"import": "./lib/es/index.js",
|
|
@@ -39,30 +48,28 @@
|
|
|
39
48
|
"npm": ">=8.0.0"
|
|
40
49
|
},
|
|
41
50
|
"peerDependencies": {
|
|
42
|
-
"@wendellhu/redi": "
|
|
43
|
-
"
|
|
44
|
-
"@univerjs/design": "0.1.0-beta.
|
|
45
|
-
"@univerjs/docs": "0.1.0-beta.
|
|
46
|
-
"@univerjs/
|
|
47
|
-
"@univerjs/
|
|
48
|
-
"@univerjs/ui": "0.1.0-beta.3"
|
|
51
|
+
"@wendellhu/redi": "^0.13.0",
|
|
52
|
+
"@univerjs/core": "0.1.0-beta.5",
|
|
53
|
+
"@univerjs/design": "0.1.0-beta.5",
|
|
54
|
+
"@univerjs/docs": "0.1.0-beta.5",
|
|
55
|
+
"@univerjs/engine-render": "0.1.0-beta.5",
|
|
56
|
+
"@univerjs/ui": "0.1.0-beta.5"
|
|
49
57
|
},
|
|
50
|
-
"dependencies": {},
|
|
51
58
|
"devDependencies": {
|
|
52
|
-
"@types/react": "^18.2.
|
|
53
|
-
"@wendellhu/redi": "^0.
|
|
59
|
+
"@types/react": "^18.2.57",
|
|
60
|
+
"@wendellhu/redi": "^0.13.0",
|
|
54
61
|
"less": "^4.2.0",
|
|
55
62
|
"react": "^18.2.0",
|
|
56
63
|
"rxjs": "^7.8.1",
|
|
57
64
|
"typescript": "^5.3.3",
|
|
58
|
-
"vite": "^5.
|
|
59
|
-
"vitest": "^1.
|
|
60
|
-
"@univerjs/core": "0.1.0-beta.
|
|
61
|
-
"@univerjs/design": "0.1.0-beta.
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/shared": "0.1.0-beta.
|
|
64
|
-
"@univerjs/
|
|
65
|
-
"@univerjs/
|
|
65
|
+
"vite": "^5.1.4",
|
|
66
|
+
"vitest": "^1.3.1",
|
|
67
|
+
"@univerjs/core": "0.1.0-beta.5",
|
|
68
|
+
"@univerjs/design": "0.1.0-beta.5",
|
|
69
|
+
"@univerjs/engine-render": "0.1.0-beta.5",
|
|
70
|
+
"@univerjs/shared": "0.1.0-beta.5",
|
|
71
|
+
"@univerjs/ui": "0.1.0-beta.5",
|
|
72
|
+
"@univerjs/docs": "0.1.0-beta.5"
|
|
66
73
|
},
|
|
67
74
|
"scripts": {
|
|
68
75
|
"test": "vitest run",
|