@univerjs/docs-ui 0.1.0-beta.4 → 0.1.1

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.
Files changed (36) hide show
  1. package/lib/cjs/index.js +10 -1
  2. package/lib/es/index.js +1443 -297
  3. package/lib/index.css +1 -0
  4. package/lib/types/commands/commands/clipboard.command.d.ts +20 -0
  5. package/lib/types/controllers/app-ui-controller.d.ts +9 -4
  6. package/lib/types/controllers/clipboard.controller.d.ts +29 -0
  7. package/lib/types/controllers/doc-container-ui-controller.d.ts +1 -1
  8. package/lib/types/controllers/doc-editor-bridge.controller.d.ts +37 -0
  9. package/lib/types/controllers/doc-render.controller.d.ts +31 -0
  10. package/lib/types/controllers/doc-ui.controller.d.ts +6 -5
  11. package/lib/types/controllers/floating-object.controller.d.ts +35 -0
  12. package/lib/types/controllers/page-render.controller.d.ts +27 -0
  13. package/lib/types/controllers/zoom.controller.d.ts +37 -0
  14. package/lib/types/docs-ui-plugin.d.ts +1 -0
  15. package/lib/types/index.d.ts +1 -0
  16. package/lib/types/locale/en-US.d.ts +3 -21
  17. package/lib/types/locale/zh-CN.d.ts +2 -2
  18. package/lib/types/services/clipboard/__test__/html-and-udm-convert.spec.d.ts +16 -0
  19. package/lib/types/services/clipboard/clipboard.service.d.ts +55 -0
  20. package/lib/types/services/clipboard/copy-content-cache.d.ts +25 -0
  21. package/lib/types/services/clipboard/html-to-udm/converter.d.ts +30 -0
  22. package/lib/types/services/clipboard/html-to-udm/parse-node-style.d.ts +17 -0
  23. package/lib/types/services/clipboard/html-to-udm/parse-to-dom.d.ts +16 -0
  24. package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-lark.d.ts +18 -0
  25. package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-word.d.ts +18 -0
  26. package/lib/types/services/clipboard/html-to-udm/paste-plugins/type.d.ts +30 -0
  27. package/lib/types/services/clipboard/html-to-udm/utils.d.ts +17 -0
  28. package/lib/types/services/clipboard/udm-to-html/__test__/convertor.spec.d.ts +16 -0
  29. package/lib/types/services/clipboard/udm-to-html/convertor.d.ts +19 -0
  30. package/lib/types/shortcuts/core-editing.shortcut.d.ts +19 -0
  31. package/lib/types/shortcuts/cursor.shortcut.d.ts +25 -0
  32. package/lib/types/shortcuts/utils.d.ts +17 -0
  33. package/lib/types/views/doc-background/DocBackground.d.ts +20 -0
  34. package/lib/types/views/doc-canvas-view.d.ts +32 -0
  35. package/lib/umd/index.js +10 -1
  36. package/package.json +29 -22
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}
@@ -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 { ILayoutService } 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?: ILayoutService | undefined);
29
+ private _registerContainer;
25
30
  /**
26
31
  * Change language
27
- * @param {String} locale new language
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 {String} lang new language
36
+ * @param {string} lang new language
37
37
  *
38
38
  * e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771
39
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 { 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
+ /**
34
+ * Listen to document edits to refresh the size of the normula editor.
35
+ */
36
+ private _commandExecutedListener;
37
+ }
@@ -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,20 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Disposable, ICommandService } from '@univerjs/core';
16
+ import { Disposable, IUniverInstanceService } from '@univerjs/core';
17
17
  import type { IDesktopUIController } from '@univerjs/ui';
18
- import { ComponentManager, IMenuService, IShortcutService } from '@univerjs/ui';
18
+ import { ComponentManager, IEditorService, 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 _commandService;
24
- private readonly _shortcutService;
23
+ private readonly _editorService;
25
24
  private readonly _menuService;
26
25
  private readonly _uiController;
27
- constructor(_injector: Injector, _componentManager: ComponentManager, _commandService: ICommandService, _shortcutService: IShortcutService, _menuService: IMenuService, _uiController: IDesktopUIController);
26
+ private readonly _currentUniverService;
27
+ constructor(_injector: Injector, _componentManager: ComponentManager, _editorService: IEditorService, _menuService: IMenuService, _uiController: IDesktopUIController, _currentUniverService: IUniverInstanceService);
28
28
  private _initCustomComponents;
29
29
  private _initMenus;
30
30
  private _init;
31
+ private _initDocBackground;
31
32
  }
@@ -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,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
+ }
@@ -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;
@@ -16,3 +16,4 @@
16
16
  export * from './basics';
17
17
  export * from './docs-ui-plugin';
18
18
  export { enUS, zhCN } from './locale';
19
+ export { DocCanvasView } from './views/doc-canvas-view';
@@ -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
- declare const _default: {
17
- toolbar: {
18
- undo: string;
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 _default: {
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 _default;
37
+ export default locale;
@@ -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,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 { IParagraphStyle, Nullable } from '@univerjs/core';
17
+ export declare function getParagraphStyle(el: HTMLElement): Nullable<IParagraphStyle>;
@@ -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
+ }