@univerjs/docs-ui 0.4.2 → 0.5.0-beta.0

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 (47) hide show
  1. package/lib/cjs/facade.js +1 -0
  2. package/lib/cjs/index.js +14 -14
  3. package/lib/cjs/locale/en-US.js +1 -0
  4. package/lib/cjs/locale/fa-IR.js +1 -0
  5. package/lib/cjs/locale/ru-RU.js +1 -0
  6. package/lib/cjs/locale/vi-VN.js +1 -0
  7. package/lib/cjs/locale/zh-CN.js +1 -0
  8. package/lib/cjs/locale/zh-TW.js +1 -0
  9. package/lib/es/facade.js +106 -0
  10. package/lib/es/index.js +7454 -7611
  11. package/lib/es/locale/en-US.js +85 -0
  12. package/lib/es/locale/fa-IR.js +85 -0
  13. package/lib/es/locale/ru-RU.js +85 -0
  14. package/lib/es/locale/vi-VN.js +85 -0
  15. package/lib/es/locale/zh-CN.js +85 -0
  16. package/lib/es/locale/zh-TW.js +85 -0
  17. package/lib/types/basics/paragraph.d.ts +4 -85
  18. package/lib/types/basics/selection.d.ts +2 -0
  19. package/lib/types/commands/commands/core-editing.command.d.ts +0 -1
  20. package/lib/types/commands/commands/doc-select-all.command.d.ts +5 -0
  21. package/lib/types/commands/commands/inline-format.command.d.ts +3 -1
  22. package/lib/types/controllers/doc-header-footer.controller.d.ts +0 -1
  23. package/lib/types/facade/f-document.d.ts +34 -0
  24. package/lib/types/facade/f-univer.d.ts +34 -0
  25. package/lib/types/facade/index.d.ts +17 -0
  26. package/lib/types/index.d.ts +2 -4
  27. package/lib/types/services/doc-menu-style.service.d.ts +6 -2
  28. package/lib/types/services/doc-popup-manager.service.d.ts +3 -3
  29. package/lib/types/services/editor/editor-manager.service.d.ts +63 -0
  30. package/lib/umd/facade.js +1 -0
  31. package/lib/umd/index.js +14 -14
  32. package/lib/umd/locale/en-US.js +1 -0
  33. package/lib/umd/locale/fa-IR.js +1 -0
  34. package/lib/umd/locale/ru-RU.js +1 -0
  35. package/lib/umd/locale/vi-VN.js +1 -0
  36. package/lib/umd/locale/zh-CN.js +1 -0
  37. package/lib/umd/locale/zh-TW.js +1 -0
  38. package/package.json +38 -21
  39. package/lib/locale/en-US.json +0 -82
  40. package/lib/locale/fa-IR.json +0 -82
  41. package/lib/locale/ru-RU.json +0 -82
  42. package/lib/locale/vi-VN.json +0 -82
  43. package/lib/locale/zh-CN.json +0 -82
  44. package/lib/locale/zh-TW.json +0 -82
  45. package/lib/types/basics/custom-range-factory.d.ts +0 -25
  46. package/lib/types/basics/replace.d.ts +0 -20
  47. package/lib/types/commands/operations/select-all.operation.d.ts +0 -5
@@ -0,0 +1,34 @@
1
+ import { IDocumentData, FUniver } from '@univerjs/core';
2
+ import { FDocument } from './f-document';
3
+ interface IFUniverDocsUIMixin {
4
+ /**
5
+ * Create a new document and get the API handler of that document.
6
+ *
7
+ * @param {Partial<IDocumentData>} data The snapshot of the document.
8
+ * @returns {FDocument} FDocument API instance.
9
+ */
10
+ createUniverDoc(data: Partial<IDocumentData>): FDocument;
11
+ /**
12
+ * Get the document API handler by the document id.
13
+ *
14
+ * @param {string} id The document id.
15
+ * @returns {FDocument | null} The document API instance.
16
+ */
17
+ getUniverDoc(id: string): FDocument | null;
18
+ /**
19
+ * Get the currently focused Univer document.
20
+ *
21
+ * @returns {FDocument | null} The currently focused Univer document.
22
+ */
23
+ getActiveDocument(): FDocument | null;
24
+ }
25
+ export declare class FUniverDocsMixin extends FUniver implements IFUniverDocsUIMixin {
26
+ createUniverDoc(data: Partial<IDocumentData>): FDocument;
27
+ getActiveDocument(): FDocument | null;
28
+ getUniverDoc(id: string): FDocument | null;
29
+ }
30
+ declare module '@univerjs/core' {
31
+ interface FUniver extends IFUniverDocsUIMixin {
32
+ }
33
+ }
34
+ export {};
@@ -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 './f-univer';
17
+ export { FDocument } from './f-document';
@@ -18,10 +18,8 @@ export * from './basics';
18
18
  export type { IDocObjectParam } from './basics/component-tools';
19
19
  export { getDocObject, getDocObjectById, neoGetDocObject } from './basics/component-tools';
20
20
  export { addCustomDecorationBySelectionFactory, addCustomDecorationFactory, deleteCustomDecorationFactory } from './basics/custom-decoration-factory';
21
- export { addCustomRangeBySelectionFactory, addCustomRangeFactory, deleteCustomRangeFactory } from './basics/custom-range-factory';
22
21
  export * from './basics/docs-view-key';
23
22
  export { hasParagraphInTable } from './basics/paragraph';
24
- export { replaceSelectionFactory } from './basics/replace';
25
23
  export { docDrawingPositionToTransform, transformToDocDrawingPosition } from './basics/transform-position';
26
24
  export { getCommandSkeleton, getRichTextEditPath } from './commands/util';
27
25
  export { TextEditor } from './components/editor/TextEditor';
@@ -35,7 +33,7 @@ export * from './services';
35
33
  export { IDocClipboardService } from './services/clipboard/clipboard.service';
36
34
  export { DocEventManagerService } from './services/doc-event-manager.service';
37
35
  export { DocIMEInputManagerService } from './services/doc-ime-input-manager.service';
38
- export { DocCanvasPopManagerService } from './services/doc-popup-manager.service';
36
+ export { calcDocRangePositions, DocCanvasPopManagerService } from './services/doc-popup-manager.service';
39
37
  export { DocStateChangeManagerService } from './services/doc-state-change-manager.service';
40
38
  export { DocsRenderService } from './services/docs-render.service';
41
39
  export { Editor } from './services/editor/editor';
@@ -81,5 +79,5 @@ export { genTableSource, getEmptyTableCell, getEmptyTableRow, getTableColumn } f
81
79
  export { DocCreateTableOperation } from './commands/operations/doc-create-table.operation';
82
80
  export { MoveSelectionOperation } from './commands/operations/doc-cursor.operation';
83
81
  export { MoveCursorOperation } from './commands/operations/doc-cursor.operation';
84
- export { SelectAllOperation } from './commands/operations/select-all.operation';
82
+ export { DocSelectAllCommand } from './commands/commands/doc-select-all.command';
85
83
  export { type ISetDocZoomRatioOperationParams, SetDocZoomRatioOperation } from './commands/operations/set-doc-zoom-ratio.operation';
@@ -1,12 +1,16 @@
1
- import { ITextStyle, Nullable, Disposable } from '@univerjs/core';
1
+ import { ITextStyle, Nullable, Disposable, IUniverInstanceService } from '@univerjs/core';
2
2
  import { DocSelectionManagerService } from '@univerjs/docs';
3
+ import { IRenderManagerService } from '@univerjs/engine-render';
3
4
  export declare class DocMenuStyleService extends Disposable {
4
5
  private readonly _textSelectionManagerService;
6
+ private readonly _univerInstanceService;
7
+ private readonly _renderManagerService;
5
8
  private _cacheStyle;
6
- constructor(_textSelectionManagerService: DocSelectionManagerService);
9
+ constructor(_textSelectionManagerService: DocSelectionManagerService, _univerInstanceService: IUniverInstanceService, _renderManagerService: IRenderManagerService);
7
10
  private _init;
8
11
  private _listenDocRangeChange;
9
12
  getStyleCache(): Nullable<ITextStyle>;
13
+ getDefaultStyle(): ITextStyle;
10
14
  setStyleCache(style: ITextStyle): void;
11
15
  private _clearStyleCache;
12
16
  }
@@ -1,6 +1,6 @@
1
- import { Disposable, ICommandService, IUniverInstanceService, IDisposable, INeedCheckDisposable, ITextRangeParam } from '@univerjs/core';
2
- import { IRenderManagerService, BaseObject, IBoundRectNoAngle, IRender, Scene } from '@univerjs/engine-render';
3
- import { ICanvasPopupService, IPopup } from '@univerjs/ui';
1
+ import { IDisposable, INeedCheckDisposable, ITextRangeParam, Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
2
+ import { BaseObject, IBoundRectNoAngle, IRender, Scene, IRenderManagerService } from '@univerjs/engine-render';
3
+ import { IPopup, ICanvasPopupService } from '@univerjs/ui';
4
4
  export declare function transformBound2OffsetBound(originBound: IBoundRectNoAngle, scene: Scene): IBoundRectNoAngle;
5
5
  export declare function transformPosition2Offset(x: number, y: number, scene: Scene): {
6
6
  x: number;
@@ -12,14 +12,29 @@ export interface IEditorInputFormulaParam {
12
12
  editorUnitId: string;
13
13
  formulaString: string;
14
14
  }
15
+ /**
16
+ * @deprecated
17
+ */
15
18
  export interface IEditorService {
16
19
  getEditor(id?: string): Readonly<Nullable<Editor>>;
17
20
  register(config: IEditorConfigParams, container: HTMLDivElement): IDisposable;
21
+ /**
22
+ * @deprecated
23
+ */
18
24
  isVisible(id: string): Nullable<boolean>;
19
25
  inputFormula$: Observable<IEditorInputFormulaParam>;
26
+ /**
27
+ * @deprecated
28
+ */
20
29
  setFormula(formulaString: string): void;
21
30
  resize$: Observable<string>;
31
+ /**
32
+ * @deprecated
33
+ */
22
34
  resize(id: string): void;
35
+ /**
36
+ * @deprecated
37
+ */
23
38
  getAllEditor(): Map<string, Editor>;
24
39
  /**
25
40
  * The sheet currently being operated on will determine
@@ -36,27 +51,75 @@ export interface IEditorService {
36
51
  isEditor(editorUnitId: string): boolean;
37
52
  isSheetEditor(editorUnitId: string): boolean;
38
53
  closeRangePrompt$: Observable<unknown>;
54
+ /**
55
+ * @deprecated
56
+ */
39
57
  closeRangePrompt(): void;
40
58
  blur$: Observable<unknown>;
59
+ /**
60
+ * @deprecated
61
+ */
41
62
  blur(): void;
42
63
  focus$: Observable<ISuccinctDocRangeParam>;
64
+ /**
65
+ * @deprecated
66
+ */
43
67
  focus(editorUnitId?: string): void;
44
68
  setValue$: Observable<IEditorSetValueParam>;
45
69
  valueChange$: Observable<Readonly<Editor>>;
70
+ /**
71
+ * @deprecated
72
+ */
46
73
  setValue(val: string, editorUnitId?: string): void;
74
+ /**
75
+ * @deprecated
76
+ */
47
77
  setValueNoRefresh(val: string, editorUnitId?: string): void;
78
+ /**
79
+ * @deprecated
80
+ */
48
81
  setRichValue(body: IDocumentBody, editorUnitId?: string): void;
82
+ /**
83
+ * @deprecated
84
+ */
49
85
  getFirstEditor(): Editor;
50
86
  focusStyle$: Observable<Nullable<string>>;
87
+ /**
88
+ * @deprecated
89
+ */
51
90
  focusStyle(editorUnitId: Nullable<string>): void;
91
+ /**
92
+ * @deprecated
93
+ */
52
94
  refreshValueChange(editorId: string): void;
95
+ /**
96
+ * @deprecated
97
+ */
53
98
  checkValueLegality(editorId: string): boolean;
99
+ /**
100
+ * @deprecated
101
+ */
54
102
  getValue(id: string): Nullable<string>;
103
+ /**
104
+ * @deprecated
105
+ */
55
106
  getRichValue(id: string): Nullable<IDocumentBody>;
107
+ /**
108
+ * @deprecated
109
+ */
56
110
  changeSpreadsheetFocusState(state: boolean): void;
111
+ /**
112
+ * @deprecated
113
+ */
57
114
  getSpreadsheetFocusState(): boolean;
115
+ /**
116
+ * @deprecated
117
+ */
58
118
  selectionChangingState(): boolean;
59
119
  singleSelection$: Observable<boolean>;
120
+ /**
121
+ * @deprecated
122
+ */
60
123
  singleSelection(state: boolean): void;
61
124
  setFocusId(id: Nullable<string>): void;
62
125
  getFocusId(): Nullable<string>;
@@ -0,0 +1 @@
1
+ (function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("@univerjs/core"),require("@univerjs/docs-ui"),require("@univerjs/engine-render")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-ui","@univerjs/engine-render"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.UniverDocsUiFacade={},t.UniverCore,t.UniverDocsUi,t.UniverEngineRender))})(this,function(t,e,a,m){"use strict";var f=Object.defineProperty;var D=(t,e,a)=>e in t?f(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var v=(t,e,a)=>D(t,typeof e!="symbol"?e+"":e,a);var h=Object.defineProperty,_=Object.getOwnPropertyDescriptor,I=(u,n,i,r)=>{for(var s=r>1?void 0:r?_(n,i):n,c=u.length-1,o;c>=0;c--)(o=u[c])&&(s=(r?o(n,i,s):o(s))||s);return r&&s&&h(n,i,s),s},d=(u,n)=>(i,r)=>n(i,r,u);t.FDocument=class{constructor(n,i,r,s,c,o){v(this,"id");this._documentDataModel=n,this._injector=i,this._univerInstanceService=r,this._commandService=s,this._resourceManagerService=c,this._renderManagerService=o,this.id=this._documentDataModel.getUnitId()}getId(){return this._documentDataModel.getUnitId()}getName(){return this.getSnapshot().title||""}getSnapshot(){const n=this._resourceManagerService.getResourcesByType(this.id,e.UniverInstanceType.UNIVER_DOC),i=this._documentDataModel.getSnapshot();return i.resources=n,i}undo(){return this._univerInstanceService.focusUnit(this.id),this._commandService.executeCommand(e.UndoCommand.id)}redo(){return this._univerInstanceService.focusUnit(this.id),this._commandService.executeCommand(e.RedoCommand.id)}appendText(n){const i=this.id,{body:r}=this.getSnapshot();if(!r)throw new Error("The document body is empty");const s=r.dataStream.length-2,c={startOffset:s,endOffset:s,collapsed:!0,segmentId:""},{segmentId:o}=c;return this._commandService.executeCommand(a.InsertCommand.id,{unitId:i,body:{dataStream:n},range:c,segmentId:o})}setSelection(n,i){var s;const r=(s=this._renderManagerService.getRenderById(this.getId()))==null?void 0:s.with(a.DocSelectionRenderService);r==null||r.removeAllRanges(),r==null||r.addDocRanges([{startOffset:n,endOffset:i,rangeType:e.DOC_RANGE_TYPE.TEXT}],!0)}},t.FDocument=I([d(1,e.Inject(e.Injector)),d(2,e.IUniverInstanceService),d(3,e.ICommandService),d(4,e.IResourceManagerService),d(5,m.IRenderManagerService)],t.FDocument);class g extends e.FUniver{createUniverDoc(n){const i=this._univerInstanceService.createUnit(e.UniverInstanceType.UNIVER_DOC,n);return this._injector.createInstance(t.FDocument,i)}getActiveDocument(){const n=this._univerInstanceService.getCurrentUnitForType(e.UniverInstanceType.UNIVER_DOC);return n?this._injector.createInstance(t.FDocument,n):null}getUniverDoc(n){const i=this._univerInstanceService.getUniverDocInstance(n);return i?this._injector.createInstance(t.FDocument,i):null}}e.FUniver.extend(g),Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});