@univerjs/docs 1.0.0-alpha.1 → 1.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1156 -868
- package/lib/cjs/index.js +723 -18
- package/lib/es/facade.js +1154 -867
- package/lib/es/index.js +701 -19
- package/lib/facade.js +1154 -867
- package/lib/index.js +701 -19
- package/lib/types/commands/commands/create-header-footer.command.d.ts +45 -0
- package/lib/types/commands/commands/set-document-default-paragraph-style.command.d.ts +24 -0
- package/lib/types/commands/commands/set-section-header-footer-link.command.d.ts +26 -0
- package/lib/types/commands/commands/update-document-section.command.d.ts +38 -0
- package/lib/types/embed-host-anchor.d.ts +61 -0
- package/lib/types/facade/f-document-paragraph.d.ts +87 -100
- package/lib/types/facade/f-document-section.d.ts +281 -0
- package/lib/types/facade/f-document-text-range.d.ts +136 -0
- package/lib/types/facade/f-document.d.ts +316 -26
- package/lib/types/facade/f-enum.d.ts +32 -0
- package/lib/types/facade/f-types.d.ts +16 -0
- package/lib/types/facade/index.d.ts +11 -6
- package/lib/types/facade/utils.d.ts +15 -1
- package/lib/types/index.d.ts +15 -1
- package/lib/types/utils/paragraphs.d.ts +18 -0
- package/lib/types/utils/section-columns.d.ts +18 -0
- package/lib/types/utils/sections.d.ts +18 -0
- package/lib/types/utils/util.d.ts +19 -0
- package/lib/umd/facade.js +3 -1
- package/lib/umd/index.js +2 -1
- package/package.json +5 -5
- package/lib/types/facade/f-document-block-range.d.ts +0 -132
- package/lib/types/facade/f-document-body.d.ts +0 -276
- package/lib/types/facade/f-document-custom-block.d.ts +0 -57
- package/lib/types/facade/f-document-element.d.ts +0 -193
- package/lib/types/facade/f-document-table.d.ts +0 -57
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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 { BooleanNumber, ICommand, IDocumentBody, JSONXActions } from '@univerjs/core';
|
|
17
|
+
export declare enum HeaderFooterType {
|
|
18
|
+
FIRST_PAGE_HEADER = 0,
|
|
19
|
+
FIRST_PAGE_FOOTER = 1,
|
|
20
|
+
DEFAULT_HEADER = 2,
|
|
21
|
+
DEFAULT_FOOTER = 3,
|
|
22
|
+
EVEN_PAGE_HEADER = 4,
|
|
23
|
+
EVEN_PAGE_FOOTER = 5
|
|
24
|
+
}
|
|
25
|
+
export interface IHeaderFooterProps {
|
|
26
|
+
/** Distance from the page edge to the header, in points (pt). */
|
|
27
|
+
marginHeader?: number;
|
|
28
|
+
/** Distance from the page edge to the footer, in points (pt). */
|
|
29
|
+
marginFooter?: number;
|
|
30
|
+
useFirstPageHeaderFooter?: BooleanNumber;
|
|
31
|
+
evenAndOddHeaders?: BooleanNumber;
|
|
32
|
+
}
|
|
33
|
+
export type HeaderFooterCreateMode = 'single' | 'pair';
|
|
34
|
+
export interface ICreateHeaderFooterCommandParams {
|
|
35
|
+
unitId: string;
|
|
36
|
+
createType?: HeaderFooterType;
|
|
37
|
+
segmentId?: string;
|
|
38
|
+
headerFooterProps?: IHeaderFooterProps;
|
|
39
|
+
createMode?: HeaderFooterCreateMode;
|
|
40
|
+
/** Optional stable section id. Omit to configure the document-level default. */
|
|
41
|
+
sectionId?: string;
|
|
42
|
+
}
|
|
43
|
+
export declare function getEmptyHeaderFooterBody(): IDocumentBody;
|
|
44
|
+
export declare function createHeaderFooterAction(segmentId: string | undefined, createType: HeaderFooterType, headerFooterConfig: IHeaderFooterProps, actions: JSONXActions, createMode?: HeaderFooterCreateMode, configPath?: Array<string | number>): JSONXActions;
|
|
45
|
+
export declare const CreateHeaderFooterCommand: ICommand<ICreateHeaderFooterCommandParams>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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 { ICommand, IDocumentDefaultParagraphStyle, Nullable } from '@univerjs/core';
|
|
17
|
+
export type IDocumentDefaultParagraphStylePatch = {
|
|
18
|
+
[K in keyof IDocumentDefaultParagraphStyle]?: Nullable<IDocumentDefaultParagraphStyle[K]>;
|
|
19
|
+
};
|
|
20
|
+
export interface ISetDocumentDefaultParagraphStyleCommandParams {
|
|
21
|
+
unitId: string;
|
|
22
|
+
defaultParagraphStyle: Nullable<IDocumentDefaultParagraphStylePatch>;
|
|
23
|
+
}
|
|
24
|
+
export declare const SetDocumentDefaultParagraphStyleCommand: ICommand<ISetDocumentDefaultParagraphStyleCommandParams>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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 { ICommand, SectionHeaderFooterKind, SectionHeaderFooterVariant } from '@univerjs/core';
|
|
17
|
+
export interface ISetSectionHeaderFooterLinkCommandParams {
|
|
18
|
+
unitId: string;
|
|
19
|
+
sectionId: string;
|
|
20
|
+
kind: SectionHeaderFooterKind;
|
|
21
|
+
variant: SectionHeaderFooterVariant;
|
|
22
|
+
linkedToPrevious: boolean;
|
|
23
|
+
/** Stable id to use when unlinking. Generated automatically when omitted. */
|
|
24
|
+
segmentId?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const SetSectionHeaderFooterLinkCommand: ICommand<ISetSectionHeaderFooterLinkCommandParams>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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 { ICommand, ISectionBreak } from '@univerjs/core';
|
|
17
|
+
export type IDocumentSectionConfig = Omit<ISectionBreak, 'sectionId' | 'startIndex'>;
|
|
18
|
+
export interface IDocumentSectionUpdate {
|
|
19
|
+
sectionId: string;
|
|
20
|
+
config: Partial<IDocumentSectionConfig>;
|
|
21
|
+
}
|
|
22
|
+
export interface IUpdateDocumentSectionCommandParams {
|
|
23
|
+
unitId: string;
|
|
24
|
+
updates: IDocumentSectionUpdate[];
|
|
25
|
+
}
|
|
26
|
+
export interface IInsertDocumentSectionBreakCommandParams {
|
|
27
|
+
unitId: string;
|
|
28
|
+
offset: number;
|
|
29
|
+
sectionId: string;
|
|
30
|
+
config?: Partial<IDocumentSectionConfig>;
|
|
31
|
+
}
|
|
32
|
+
export interface IDeleteDocumentSectionBreakCommandParams {
|
|
33
|
+
unitId: string;
|
|
34
|
+
sectionId: string;
|
|
35
|
+
}
|
|
36
|
+
export declare const UpdateDocumentSectionCommand: ICommand<IUpdateDocumentSectionCommandParams>;
|
|
37
|
+
export declare const InsertDocumentSectionBreakCommand: ICommand<IInsertDocumentSectionBreakCommandParams>;
|
|
38
|
+
export declare const DeleteDocumentSectionBreakCommand: ICommand<IDeleteDocumentSectionBreakCommandParams>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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 { IDocDrawingBase, IMutationInfo, JSONXActions } from '@univerjs/core';
|
|
17
|
+
import type { IRichTextEditingMutationParams } from './commands/mutations/core-editing.mutation';
|
|
18
|
+
import { UniverInstanceType } from '@univerjs/core';
|
|
19
|
+
export interface IDocsCustomBlockMutationParams {
|
|
20
|
+
unitId: string;
|
|
21
|
+
blockId: string;
|
|
22
|
+
startIndex: number;
|
|
23
|
+
segmentId?: string;
|
|
24
|
+
drawingOrderIndex?: number;
|
|
25
|
+
embedId?: string;
|
|
26
|
+
childUnitId?: string;
|
|
27
|
+
childType?: UniverInstanceType;
|
|
28
|
+
componentKey?: string;
|
|
29
|
+
interactionMode?: EmbedDocsCustomBlockInteractionMode;
|
|
30
|
+
}
|
|
31
|
+
export declare const EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY = "UniverEmbedDocsCustomBlock";
|
|
32
|
+
export type EmbedDocsCustomBlockInteractionMode = 'block' | 'inline';
|
|
33
|
+
export interface IEmbedDocsCustomBlockData {
|
|
34
|
+
version: 1;
|
|
35
|
+
embedId: string;
|
|
36
|
+
hostUnitId?: string;
|
|
37
|
+
hostAnchorId: string;
|
|
38
|
+
childUnitId?: string;
|
|
39
|
+
childType?: UniverInstanceType;
|
|
40
|
+
interactionMode?: EmbedDocsCustomBlockInteractionMode;
|
|
41
|
+
}
|
|
42
|
+
export declare function createDocsCustomBlockInsertMutation(params: IDocsCustomBlockMutationParams): IMutationInfo<IRichTextEditingMutationParams>;
|
|
43
|
+
export declare function createDocsCustomBlockRemoveMutation(params: IDocsCustomBlockMutationParams): IMutationInfo<IRichTextEditingMutationParams>;
|
|
44
|
+
export declare function createInsertCustomBlockActions(params: IDocsCustomBlockMutationParams): JSONXActions;
|
|
45
|
+
export declare function createRemoveCustomBlockActions(params: IDocsCustomBlockMutationParams): JSONXActions;
|
|
46
|
+
export declare function createDocsCustomBlockDrawing(params: IDocsCustomBlockMutationParams): IDocDrawingBase;
|
|
47
|
+
export declare function resolveDocsCustomBlockSize(childType?: UniverInstanceType): {
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
50
|
+
};
|
|
51
|
+
export declare function isSheetLikeDocsCustomBlockChildType(childType?: UniverInstanceType): boolean;
|
|
52
|
+
export declare function createEmbedDocsCustomBlockData(params: {
|
|
53
|
+
blockId: string;
|
|
54
|
+
embedId?: string;
|
|
55
|
+
unitId?: string;
|
|
56
|
+
childUnitId?: string;
|
|
57
|
+
childType?: UniverInstanceType;
|
|
58
|
+
interactionMode?: EmbedDocsCustomBlockInteractionMode;
|
|
59
|
+
}): IEmbedDocsCustomBlockData;
|
|
60
|
+
export declare function isEmbedDocsCustomBlockData(data: unknown): data is IEmbedDocsCustomBlockData;
|
|
61
|
+
export declare function shouldUseInlineTextSelectionForDocsCustomBlockDrawing(drawing: unknown): boolean;
|
|
@@ -14,16 +14,13 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { Injector, IParagraph, IParagraphStyle } from '@univerjs/core';
|
|
17
|
-
import type {
|
|
18
|
-
import type {
|
|
19
|
-
import {
|
|
20
|
-
interface IFDocumentParagraphMixin {
|
|
21
|
-
asParagraph(): FDocumentParagraph;
|
|
22
|
-
}
|
|
17
|
+
import type { FDocument } from './f-document';
|
|
18
|
+
import type { IFDocumentTextRange } from './utils';
|
|
19
|
+
import { FDocumentTextRange } from './f-document-text-range';
|
|
23
20
|
/**
|
|
24
21
|
* Resolved paragraph metadata in the the document body.
|
|
25
22
|
*/
|
|
26
|
-
export interface
|
|
23
|
+
export interface IFDocumentParagraphInfo {
|
|
27
24
|
/** The underlying paragraph snapshot object. */
|
|
28
25
|
paragraph: IParagraph;
|
|
29
26
|
/** The current paragraph index in the body paragraph list. */
|
|
@@ -42,74 +39,78 @@ export interface IFDocumentResolvedParagraph {
|
|
|
42
39
|
*
|
|
43
40
|
* @hideconstructor
|
|
44
41
|
*/
|
|
45
|
-
export declare class FDocumentParagraph
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
constructor(
|
|
42
|
+
export declare class FDocumentParagraph {
|
|
43
|
+
private readonly _document;
|
|
44
|
+
private readonly _paragraphId;
|
|
45
|
+
private readonly _segmentId;
|
|
46
|
+
private readonly _injector;
|
|
47
|
+
constructor(_document: FDocument, _paragraphId: string, _segmentId: string | undefined, _injector: Injector);
|
|
51
48
|
/**
|
|
52
49
|
* Get the persisted paragraph id.
|
|
53
50
|
* @returns {string} The paragraph id.
|
|
54
51
|
* @example
|
|
55
52
|
* ```ts
|
|
56
53
|
* const fDocument = univerAPI.getActiveDocument();
|
|
57
|
-
* const
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* if (element?.isParagraph()) {
|
|
61
|
-
* const paragraph = element.asParagraph();
|
|
62
|
-
* console.log(paragraph.getParagraphId());
|
|
63
|
-
* }
|
|
54
|
+
* const paragraph = fDocument.getParagraphs()[0];
|
|
55
|
+
* console.log(paragraph?.getId());
|
|
64
56
|
* ```
|
|
65
57
|
*/
|
|
66
|
-
|
|
58
|
+
getId(): string;
|
|
67
59
|
/**
|
|
68
|
-
* Get the
|
|
69
|
-
*
|
|
60
|
+
* Get the segment id of this paragraph.
|
|
61
|
+
* The main body paragraphs have an empty string segment id.
|
|
62
|
+
* The header and footer paragraphs have a non-empty string segment id.
|
|
63
|
+
* @returns {string} The segment id.
|
|
70
64
|
* @example
|
|
71
65
|
* ```ts
|
|
72
66
|
* const fDocument = univerAPI.getActiveDocument();
|
|
73
|
-
* const
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
*
|
|
67
|
+
* const paragraph = fDocument.getParagraphs()[0];
|
|
68
|
+
* console.log(paragraph?.getSegmentId());
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
getSegmentId(): string;
|
|
72
|
+
/**
|
|
73
|
+
* Get this paragraph's metadata.
|
|
74
|
+
* @returns {IFDocumentParagraphInfo} The paragraph info.
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
78
|
+
* const paragraph = fDocument.getParagraphs()[0];
|
|
79
|
+
* console.log(paragraph?.getInfo());
|
|
80
80
|
* ```
|
|
81
81
|
*/
|
|
82
|
-
|
|
82
|
+
getInfo(): IFDocumentParagraphInfo;
|
|
83
83
|
/**
|
|
84
84
|
* Get the current text range occupied by this paragraph.
|
|
85
85
|
* @returns {IFDocumentTextRange} The paragraph text range, excluding the trailing paragraph break.
|
|
86
86
|
* @example
|
|
87
87
|
* ```ts
|
|
88
88
|
* const fDocument = univerAPI.getActiveDocument();
|
|
89
|
-
* const
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* if (element?.isParagraph()) {
|
|
93
|
-
* const paragraph = element.asParagraph();
|
|
94
|
-
* const range = paragraph.getRange();
|
|
95
|
-
* fDocumentBody.setTextStyle(range, { bl: 1 });
|
|
96
|
-
* }
|
|
89
|
+
* const paragraph = fDocument.getParagraphs()[0];
|
|
90
|
+
* console.log(paragraph?.getRange());
|
|
97
91
|
* ```
|
|
98
92
|
*/
|
|
99
93
|
getRange(): IFDocumentTextRange;
|
|
94
|
+
/**
|
|
95
|
+
* Returns an agent-friendly facade for reading and styling this paragraph's text.
|
|
96
|
+
* @returns {FDocumentTextRange} The paragraph text range, excluding the trailing paragraph break.
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
100
|
+
* const paragraph = fDocument?.findParagraphByText('Launch');
|
|
101
|
+
* const range = paragraph?.getTextRange();
|
|
102
|
+
* console.log(range?.describe());
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
getTextRange(): FDocumentTextRange;
|
|
100
106
|
/**
|
|
101
107
|
* Get this paragraph's plain text.
|
|
102
108
|
* @returns {string} The paragraph text without the trailing paragraph break.
|
|
103
109
|
* @example
|
|
104
110
|
* ```ts
|
|
105
111
|
* const fDocument = univerAPI.getActiveDocument();
|
|
106
|
-
* const
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* if (element?.isParagraph()) {
|
|
110
|
-
* const paragraph = element.asParagraph();
|
|
111
|
-
* console.log(paragraph.getText());
|
|
112
|
-
* }
|
|
112
|
+
* const paragraph = fDocument.getParagraphs()[0];
|
|
113
|
+
* console.log(paragraph?.getText());
|
|
113
114
|
* ```
|
|
114
115
|
*/
|
|
115
116
|
getText(): string;
|
|
@@ -120,14 +121,9 @@ export declare class FDocumentParagraph extends FDocumentElement {
|
|
|
120
121
|
* @example
|
|
121
122
|
* ```ts
|
|
122
123
|
* const fDocument = univerAPI.getActiveDocument();
|
|
123
|
-
* const
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* if (element?.isParagraph()) {
|
|
127
|
-
* const paragraph = element.asParagraph();
|
|
128
|
-
* const success = paragraph.setText('Updated title');
|
|
129
|
-
* console.log(success ? 'Text updated' : 'Failed to update text');
|
|
130
|
-
* }
|
|
124
|
+
* const paragraph = fDocument.getParagraphs()[0];
|
|
125
|
+
* paragraph?.setText('New text');
|
|
126
|
+
* console.log(paragraph?.getText());
|
|
131
127
|
* ```
|
|
132
128
|
*/
|
|
133
129
|
setText(text: string): boolean;
|
|
@@ -138,31 +134,32 @@ export declare class FDocumentParagraph extends FDocumentElement {
|
|
|
138
134
|
* @example
|
|
139
135
|
* ```ts
|
|
140
136
|
* const fDocument = univerAPI.getActiveDocument();
|
|
141
|
-
* const
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
* if (element?.isParagraph()) {
|
|
145
|
-
* const paragraph = element.asParagraph();
|
|
146
|
-
* const success = paragraph.appendText(' Appended text');
|
|
147
|
-
* console.log(success ? 'Text appended' : 'Failed to append text');
|
|
148
|
-
* }
|
|
137
|
+
* const paragraph = fDocument.getParagraphs()[0];
|
|
138
|
+
* paragraph?.appendText(' Appended text');
|
|
139
|
+
* console.log(paragraph?.getText());
|
|
149
140
|
* ```
|
|
150
141
|
*/
|
|
151
142
|
appendText(text: string): boolean;
|
|
152
143
|
/**
|
|
153
144
|
* Apply paragraph style to a paragraph handle or text range.
|
|
145
|
+
* `style.textStyle.fs` is a font size in points (pt), not CSS pixels.
|
|
154
146
|
* @param {IParagraphStyle} style The Univer paragraph style patch.
|
|
155
147
|
* @returns {boolean} `true` if the style was applied.
|
|
156
148
|
* @example
|
|
157
149
|
* ```ts
|
|
158
150
|
* const fDocument = univerAPI.getActiveDocument();
|
|
159
|
-
* const
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
151
|
+
* const paragraph = fDocument.getParagraphs()[0];
|
|
152
|
+
* paragraph?.setText('Styled text');
|
|
153
|
+
* paragraph?.setStyle({
|
|
154
|
+
* textStyle: {
|
|
155
|
+
* cl: {
|
|
156
|
+
* rgb: '#FF0000',
|
|
157
|
+
* },
|
|
158
|
+
* fs: 14,
|
|
159
|
+
* },
|
|
160
|
+
* horizontalAlign: 2,
|
|
161
|
+
* });
|
|
162
|
+
* console.log(paragraph?.getInfo().paragraph.paragraphStyle);
|
|
166
163
|
* ```
|
|
167
164
|
*/
|
|
168
165
|
setStyle(style: IParagraphStyle): boolean;
|
|
@@ -172,13 +169,8 @@ export declare class FDocumentParagraph extends FDocumentElement {
|
|
|
172
169
|
* @example
|
|
173
170
|
* ```ts
|
|
174
171
|
* const fDocument = univerAPI.getActiveDocument();
|
|
175
|
-
* const
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* if (element?.isParagraph()) {
|
|
179
|
-
* const paragraph = element.asParagraph();
|
|
180
|
-
* console.log(paragraph.isListItem() ? 'This is a list item' : 'This is not a list item');
|
|
181
|
-
* }
|
|
172
|
+
* const paragraph = fDocument.getParagraphs()[0];
|
|
173
|
+
* console.log(paragraph?.isListItem());
|
|
182
174
|
* ```
|
|
183
175
|
*/
|
|
184
176
|
isListItem(): boolean;
|
|
@@ -188,13 +180,8 @@ export declare class FDocumentParagraph extends FDocumentElement {
|
|
|
188
180
|
* @example
|
|
189
181
|
* ```ts
|
|
190
182
|
* const fDocument = univerAPI.getActiveDocument();
|
|
191
|
-
* const
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
* if (element?.isParagraph()) {
|
|
195
|
-
* const paragraph = element.asParagraph();
|
|
196
|
-
* console.log(paragraph.isTask() ? 'This is a task item' : 'This is not a task item');
|
|
197
|
-
* }
|
|
183
|
+
* const paragraph = fDocument.getParagraphs()[0];
|
|
184
|
+
* console.log(paragraph?.isTask());
|
|
198
185
|
* ```
|
|
199
186
|
*/
|
|
200
187
|
isTask(): boolean;
|
|
@@ -205,27 +192,27 @@ export declare class FDocumentParagraph extends FDocumentElement {
|
|
|
205
192
|
* @example
|
|
206
193
|
* ```ts
|
|
207
194
|
* const fDocument = univerAPI.getActiveDocument();
|
|
208
|
-
* const
|
|
209
|
-
* const element = fDocumentBody.getElement(0);
|
|
210
|
-
*
|
|
211
|
-
* if (element?.isParagraph()) {
|
|
212
|
-
* const paragraph = element.asParagraph();
|
|
195
|
+
* const paragraph = fDocument.getParagraphs()[0];
|
|
213
196
|
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* }
|
|
197
|
+
* if (paragraph.isTask()) {
|
|
198
|
+
* const success = paragraph.setTaskChecked(true);
|
|
199
|
+
* console.log(success ? 'Task checked' : 'Failed to check task');
|
|
218
200
|
* }
|
|
219
201
|
* ```
|
|
220
202
|
*/
|
|
221
203
|
setTaskChecked(checked: boolean): boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Remove this paragraph.
|
|
206
|
+
* @returns {boolean} `true` if the paragraph was removed.
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
210
|
+
* const paragraph = fDocument.getParagraphs()[0];
|
|
211
|
+
* const success = paragraph?.remove();
|
|
212
|
+
* console.log(success ? 'Paragraph removed' : 'Failed to remove paragraph');
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
remove(): boolean;
|
|
222
216
|
private _preserveExplicitParagraphIds;
|
|
223
217
|
}
|
|
224
|
-
export declare
|
|
225
|
-
asParagraph(): FDocumentParagraph;
|
|
226
|
-
}
|
|
227
|
-
declare module '@univerjs/docs/facade' {
|
|
228
|
-
interface FDocumentElement extends IFDocumentParagraphMixin {
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
export {};
|
|
218
|
+
export declare function isParagraphFacade(value: unknown): value is FDocumentParagraph;
|