@univerjs/docs 1.0.0-alpha.0 → 1.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { BuildTextUtils, CommandType, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DeleteDirection, Disposable, DisposableCollection, ICommandService, IConfigService, IUndoRedoService, IUniverInstanceService, Inject, Injector, JSONX, LocaleService, Optional, Plugin, RedoCommandId, RxDisposable, TextX, TextXActionType, UndoCommandId, UniverInstanceType, composeInterceptors, createIdentifier, createInterceptorKey, getRichTextEditPath, isInternalEditorID, merge, remove, toDisposable } from "@univerjs/core";
1
+ import { BuildTextUtils, CommandType, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DeleteDirection, Disposable, DisposableCollection, DocumentFlavor, ICommandService, IConfigService, IUndoRedoService, IUniverInstanceService, Inject, Injector, JSONX, LocaleService, Optional, Plugin, RedoCommandId, RxDisposable, TextX, TextXActionType, UndoCommandId, UniverInstanceType, composeInterceptors, createIdentifier, createInterceptorKey, createParagraphId, generateRandomId, getRichTextEditPath, isInternalEditorID, merge, remove, toDisposable } from "@univerjs/core";
2
2
  import { DocumentSkeleton, DocumentViewModel, IRenderManagerService, NORMAL_TEXT_SELECTION_PLUGIN_STYLE } from "@univerjs/engine-render";
3
3
  import { BehaviorSubject, Subject, takeUntil } from "rxjs";
4
4
 
@@ -386,14 +386,14 @@ const InsertTextCommand = {
386
386
  id: "doc.command.insert-text",
387
387
  type: CommandType.COMMAND,
388
388
  handler: (accessor, params) => {
389
- var _activeRange$segmentI;
389
+ var _docDataModel$getSelf, _activeRange$segmentI;
390
390
  const commandService = accessor.get(ICommandService);
391
391
  const { range, segmentId, body, unitId, cursorOffset } = params;
392
392
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
393
393
  const docDataModel = accessor.get(IUniverInstanceService).getUnit(unitId, UniverInstanceType.UNIVER_DOC);
394
394
  if (docDataModel == null) return false;
395
395
  const activeRange = docSelectionManagerService.getActiveTextRange();
396
- const originBody = docDataModel.getSelfOrHeaderFooterModel((_activeRange$segmentI = activeRange === null || activeRange === void 0 ? void 0 : activeRange.segmentId) !== null && _activeRange$segmentI !== void 0 ? _activeRange$segmentI : "").getBody();
396
+ const originBody = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel((_activeRange$segmentI = activeRange === null || activeRange === void 0 ? void 0 : activeRange.segmentId) !== null && _activeRange$segmentI !== void 0 ? _activeRange$segmentI : "")) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
397
397
  if (originBody == null) return false;
398
398
  const { startOffset, collapsed } = range;
399
399
  const cursorMove = cursorOffset !== null && cursorOffset !== void 0 ? cursorOffset : body.dataStream.length;
@@ -446,12 +446,12 @@ const DeleteTextCommand = {
446
446
  id: "doc.command.delete-text",
447
447
  type: CommandType.COMMAND,
448
448
  handler: (accessor, params) => {
449
- var _body$customRanges;
449
+ var _docDataModel$getSelf2, _body$customRanges;
450
450
  const commandService = accessor.get(ICommandService);
451
451
  const univerInstanceService = accessor.get(IUniverInstanceService);
452
452
  const { range, segmentId, unitId, direction, len = 1 } = params;
453
453
  const docDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
454
- const body = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
454
+ const body = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.getBody();
455
455
  if (docDataModel == null || body == null) return false;
456
456
  const { startOffset } = range;
457
457
  let start = direction === DeleteDirection.LEFT ? startOffset - len : startOffset;
@@ -499,7 +499,7 @@ const UpdateTextCommand = {
499
499
  handler: (accessor, params) => {
500
500
  const { range, segmentId, updateBody, coverType, unitId, textRanges } = params;
501
501
  const commandService = accessor.get(ICommandService);
502
- const docDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
502
+ const docDataModel = accessor.get(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
503
503
  if (docDataModel == null) return false;
504
504
  const doMutation = {
505
505
  id: RichTextEditingMutation.id,
@@ -529,10 +529,141 @@ const UpdateTextCommand = {
529
529
  }
530
530
  };
531
531
 
532
+ //#endregion
533
+ //#region src/commands/commands/create-header-footer.command.ts
534
+ let HeaderFooterType = /* @__PURE__ */ function(HeaderFooterType) {
535
+ HeaderFooterType[HeaderFooterType["FIRST_PAGE_HEADER"] = 0] = "FIRST_PAGE_HEADER";
536
+ HeaderFooterType[HeaderFooterType["FIRST_PAGE_FOOTER"] = 1] = "FIRST_PAGE_FOOTER";
537
+ HeaderFooterType[HeaderFooterType["DEFAULT_HEADER"] = 2] = "DEFAULT_HEADER";
538
+ HeaderFooterType[HeaderFooterType["DEFAULT_FOOTER"] = 3] = "DEFAULT_FOOTER";
539
+ HeaderFooterType[HeaderFooterType["EVEN_PAGE_HEADER"] = 4] = "EVEN_PAGE_HEADER";
540
+ HeaderFooterType[HeaderFooterType["EVEN_PAGE_FOOTER"] = 5] = "EVEN_PAGE_FOOTER";
541
+ return HeaderFooterType;
542
+ }({});
543
+ function getEmptyHeaderFooterBody() {
544
+ return {
545
+ dataStream: "\r\n",
546
+ textRuns: [{
547
+ st: 0,
548
+ ed: 0,
549
+ ts: { fs: 9 }
550
+ }],
551
+ customBlocks: [],
552
+ paragraphs: [{
553
+ startIndex: 0,
554
+ paragraphId: createParagraphId(/* @__PURE__ */ new Set()),
555
+ paragraphStyle: {
556
+ spaceAbove: { v: 0 },
557
+ lineSpacing: 1.5,
558
+ spaceBelow: { v: 0 }
559
+ }
560
+ }],
561
+ sectionBreaks: [{ startIndex: 1 }]
562
+ };
563
+ }
564
+ function createHeaderFooterAction(segmentId, createType, documentStyle, actions, createMode = "single") {
565
+ const jsonX = JSONX.getInstance();
566
+ const ID_LEN = 6;
567
+ const firstSegmentId = segmentId !== null && segmentId !== void 0 ? segmentId : generateRandomId(ID_LEN);
568
+ const isHeader = createType === 2 || createType === 0 || createType === 4;
569
+ const insertAction = jsonX.insertOp([isHeader ? "headers" : "footers", firstSegmentId], {
570
+ [isHeader ? "headerId" : "footerId"]: firstSegmentId,
571
+ body: getEmptyHeaderFooterBody()
572
+ });
573
+ actions.push(insertAction);
574
+ let key = "defaultHeaderId";
575
+ let pairKey = "defaultFooterId";
576
+ switch (createType) {
577
+ case 2:
578
+ key = "defaultHeaderId";
579
+ pairKey = "defaultFooterId";
580
+ break;
581
+ case 3:
582
+ key = "defaultFooterId";
583
+ pairKey = "defaultHeaderId";
584
+ break;
585
+ case 0:
586
+ key = "firstPageHeaderId";
587
+ pairKey = "firstPageFooterId";
588
+ break;
589
+ case 1:
590
+ key = "firstPageFooterId";
591
+ pairKey = "firstPageHeaderId";
592
+ break;
593
+ case 4:
594
+ key = "evenPageHeaderId";
595
+ pairKey = "evenPageFooterId";
596
+ break;
597
+ case 5:
598
+ key = "evenPageFooterId";
599
+ pairKey = "evenPageHeaderId";
600
+ break;
601
+ default: throw new Error(`Unknown header footer type: ${createType}`);
602
+ }
603
+ const linkedSegmentIds = [[key, firstSegmentId]];
604
+ if (createMode === "pair" && pairKey != null) {
605
+ const secondSegmentId = generateRandomId(ID_LEN);
606
+ const insertPairAction = jsonX.insertOp([isHeader ? "footers" : "headers", secondSegmentId], {
607
+ [isHeader ? "footerId" : "headerId"]: secondSegmentId,
608
+ body: getEmptyHeaderFooterBody()
609
+ });
610
+ actions.push(insertPairAction);
611
+ linkedSegmentIds.push([pairKey, secondSegmentId]);
612
+ }
613
+ for (const [k, id] of linkedSegmentIds) if (documentStyle[k] != null) {
614
+ const replaceAction = jsonX.replaceOp(["documentStyle", k], documentStyle[k], id);
615
+ actions.push(replaceAction);
616
+ } else {
617
+ const insertAction = jsonX.insertOp(["documentStyle", k], id);
618
+ actions.push(insertAction);
619
+ }
620
+ return actions;
621
+ }
622
+ const CreateHeaderFooterCommand = {
623
+ id: "doc.command.create-header-footer",
624
+ type: CommandType.COMMAND,
625
+ handler: (accessor, params) => {
626
+ const commandService = accessor.get(ICommandService);
627
+ const univerInstanceService = accessor.get(IUniverInstanceService);
628
+ const { unitId, segmentId, createType, headerFooterProps, createMode = "single" } = params;
629
+ const docDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
630
+ if (docDataModel == null) return false;
631
+ const { documentStyle } = docDataModel.getSnapshot();
632
+ if (documentStyle.documentFlavor === DocumentFlavor.MODERN) return false;
633
+ const rawActions = [];
634
+ const jsonX = JSONX.getInstance();
635
+ if (createType != null) createHeaderFooterAction(segmentId, createType, documentStyle, rawActions, createMode);
636
+ if (headerFooterProps != null) Object.keys(headerFooterProps).forEach((key) => {
637
+ const value = headerFooterProps[key];
638
+ const oldValue = documentStyle[key];
639
+ if (value === oldValue) return;
640
+ const action = oldValue === void 0 ? jsonX.insertOp(["documentStyle", key], value) : jsonX.replaceOp(["documentStyle", key], oldValue, value);
641
+ rawActions.push(action);
642
+ });
643
+ if (rawActions.length === 0) return false;
644
+ const doMutation = {
645
+ id: RichTextEditingMutation.id,
646
+ params: {
647
+ unitId,
648
+ actions: rawActions.reduce((acc, cur) => JSONX.compose(acc, cur), null),
649
+ textRanges: [{
650
+ startOffset: 0,
651
+ endOffset: 0,
652
+ collapsed: true
653
+ }],
654
+ debounce: true
655
+ }
656
+ };
657
+ if ((headerFooterProps === null || headerFooterProps === void 0 ? void 0 : headerFooterProps.marginFooter) != null || (headerFooterProps === null || headerFooterProps === void 0 ? void 0 : headerFooterProps.marginHeader) != null) doMutation.params.noNeedSetTextRange = true;
658
+ const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
659
+ return Boolean(result);
660
+ }
661
+ };
662
+
532
663
  //#endregion
533
664
  //#region package.json
534
665
  var name = "@univerjs/docs";
535
- var version = "1.0.0-alpha.0";
666
+ var version = "1.0.0-alpha.2";
536
667
 
537
668
  //#endregion
538
669
  //#region src/commands/mutations/docs-rename.mutation.ts
@@ -621,6 +752,33 @@ DocCustomRangeController = __decorate([
621
752
  __decorateParam(2, IUniverInstanceService)
622
753
  ], DocCustomRangeController);
623
754
 
755
+ //#endregion
756
+ //#region src/services/doc-block-move-validator.service.ts
757
+ var DocBlockMoveValidatorService = class extends Disposable {
758
+ constructor(..._args) {
759
+ super(..._args);
760
+ _defineProperty(this, "_validators", []);
761
+ _defineProperty(this, "_transformers", []);
762
+ }
763
+ registerValidator(validator) {
764
+ this._validators.push(validator);
765
+ return this.disposeWithMe(toDisposable(() => remove(this._validators, validator)));
766
+ }
767
+ registerTransformer(transformer) {
768
+ this._transformers.push(transformer);
769
+ return this.disposeWithMe(toDisposable(() => remove(this._transformers, transformer)));
770
+ }
771
+ canMoveBlock(context) {
772
+ return this._validators.every((validator) => validator(context));
773
+ }
774
+ transformMoveResult(context) {
775
+ return this._transformers.reduce((result, transformer) => transformer({
776
+ ...context,
777
+ result
778
+ }), context.result);
779
+ }
780
+ };
781
+
624
782
  //#endregion
625
783
  //#region src/services/doc-content-insert.service.ts
626
784
  /**
@@ -697,7 +855,7 @@ let DocStateChangeManagerService = class DocStateChangeManagerService extends Rx
697
855
  _initialize() {
698
856
  this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
699
857
  if (command.id === UndoCommandId || command.id === RedoCommandId) {
700
- const univerDoc = this._univerInstanceService.getCurrentUniverDocInstance();
858
+ const univerDoc = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
701
859
  if (univerDoc == null) return;
702
860
  const unitId = univerDoc.getUnitId();
703
861
  this._pushHistory(unitId);
@@ -827,6 +985,7 @@ let UniverDocsPlugin = class UniverDocsPlugin extends Plugin {
827
985
  InsertTextCommand,
828
986
  DeleteTextCommand,
829
987
  UpdateTextCommand,
988
+ CreateHeaderFooterCommand,
830
989
  RichTextEditingMutation,
831
990
  DocsRenameMutation,
832
991
  SetTextSelectionsOperation
@@ -839,6 +998,7 @@ let UniverDocsPlugin = class UniverDocsPlugin extends Plugin {
839
998
  [DocSelectionManagerService],
840
999
  [DocStateEmitService],
841
1000
  [DocStateChangeManagerService],
1001
+ [DocBlockMoveValidatorService],
842
1002
  [DocContentInsertService],
843
1003
  [DocCustomRangeController]
844
1004
  ].forEach((d) => this._injector.add(d));
@@ -955,7 +1115,7 @@ function addCustomRangeFactory(accessor, param, body) {
955
1115
  return doMutation;
956
1116
  }
957
1117
  function addCustomRangeBySelectionFactory(accessor, param) {
958
- var _selections$;
1118
+ var _selections$, _documentDataModel$ge;
959
1119
  const { rangeId, rangeType, wholeEntity, properties, unitId, selections: propSelection } = param;
960
1120
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
961
1121
  const univerInstanceService = accessor.get(IUniverInstanceService);
@@ -967,7 +1127,7 @@ function addCustomRangeBySelectionFactory(accessor, param) {
967
1127
  if (!(selections === null || selections === void 0 ? void 0 : selections.length)) return false;
968
1128
  const documentDataModel = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
969
1129
  if (!documentDataModel) return false;
970
- const body = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
1130
+ const body = (_documentDataModel$ge = documentDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.getBody();
971
1131
  if (!body) return false;
972
1132
  const textX = BuildTextUtils.customRange.add({
973
1133
  ranges: selections,
@@ -1064,4 +1224,17 @@ function replaceSelectionFactory(accessor, params) {
1064
1224
  }
1065
1225
 
1066
1226
  //#endregion
1067
- export { DOC_INTERCEPTOR_POINT, DeleteTextCommand, DocContentInsertService, DocInterceptorService, DocSelectionManagerService, DocSkeletonManagerService, DocStateChangeManagerService, DocStateEmitService, IDocStateChangeInterceptorService, InsertTextCommand, RichTextEditingMutation, SetTextSelectionsOperation, UniverDocsPlugin, UpdateTextCommand, addCustomRangeBySelectionFactory, addCustomRangeFactory, deleteCustomRangeFactory, replaceSelectionFactory };
1227
+ //#region src/utils/util.ts
1228
+ function consumeContentInsertRange(accessor, unitId) {
1229
+ try {
1230
+ return accessor.get(DocContentInsertService).consumeInsertRange(unitId);
1231
+ } catch {
1232
+ return null;
1233
+ }
1234
+ }
1235
+ function isHeaderFooterSelection(range) {
1236
+ return Boolean(range === null || range === void 0 ? void 0 : range.segmentId);
1237
+ }
1238
+
1239
+ //#endregion
1240
+ export { CreateHeaderFooterCommand, DOC_INTERCEPTOR_POINT, DeleteTextCommand, DocBlockMoveValidatorService, DocContentInsertService, DocInterceptorService, DocSelectionManagerService, DocSkeletonManagerService, DocStateChangeManagerService, DocStateEmitService, HeaderFooterType, IDocStateChangeInterceptorService, InsertTextCommand, RichTextEditingMutation, SetTextSelectionsOperation, UniverDocsPlugin, UpdateTextCommand, addCustomRangeBySelectionFactory, addCustomRangeFactory, consumeContentInsertRange, deleteCustomRangeFactory, isHeaderFooterSelection, replaceSelectionFactory };
@@ -0,0 +1,41 @@
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
+ marginHeader?: number;
27
+ marginFooter?: number;
28
+ useFirstPageHeaderFooter?: BooleanNumber;
29
+ evenAndOddHeaders?: BooleanNumber;
30
+ }
31
+ export type HeaderFooterCreateMode = 'single' | 'pair';
32
+ export interface ICreateHeaderFooterCommandParams {
33
+ unitId: string;
34
+ createType?: HeaderFooterType;
35
+ segmentId?: string;
36
+ headerFooterProps?: IHeaderFooterProps;
37
+ createMode?: HeaderFooterCreateMode;
38
+ }
39
+ export declare function getEmptyHeaderFooterBody(): IDocumentBody;
40
+ export declare function createHeaderFooterAction(segmentId: string | undefined, createType: HeaderFooterType, documentStyle: IHeaderFooterProps, actions: JSONXActions, createMode?: HeaderFooterCreateMode): JSONXActions;
41
+ export declare const CreateHeaderFooterCommand: ICommand<ICreateHeaderFooterCommandParams>;
@@ -0,0 +1,204 @@
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 { Injector, IParagraph, IParagraphStyle } from '@univerjs/core';
17
+ import type { FDocument } from './f-document';
18
+ import type { IFDocumentTextRange } from './utils';
19
+ /**
20
+ * Resolved paragraph metadata in the the document body.
21
+ */
22
+ export interface IFDocumentParagraphInfo {
23
+ /** The underlying paragraph snapshot object. */
24
+ paragraph: IParagraph;
25
+ /** The current paragraph index in the body paragraph list. */
26
+ paragraphIndex: number;
27
+ /** The inclusive start offset of the paragraph text. */
28
+ startOffset: number;
29
+ /** The exclusive end offset of the paragraph text, before the paragraph break. */
30
+ endOffset: number;
31
+ }
32
+ /**
33
+ * A paragraph facade wrapper.
34
+ *
35
+ * Paragraph identity is backed by the persisted `paragraphId`. The id is
36
+ * re-resolved before each method call, so insertions before this paragraph do
37
+ * not break the wrapper.
38
+ *
39
+ * @hideconstructor
40
+ */
41
+ export declare class FDocumentParagraph {
42
+ private readonly _document;
43
+ private readonly _paragraphId;
44
+ private readonly _segmentId;
45
+ private readonly _injector;
46
+ constructor(_document: FDocument, _paragraphId: string, _segmentId: string | undefined, _injector: Injector);
47
+ /**
48
+ * Get the persisted paragraph id.
49
+ * @returns {string} The paragraph id.
50
+ * @example
51
+ * ```ts
52
+ * const fDocument = univerAPI.getActiveDocument();
53
+ * const paragraph = fDocument.getParagraphs()[0];
54
+ * console.log(paragraph?.getId());
55
+ * ```
56
+ */
57
+ getId(): string;
58
+ /**
59
+ * Get the segment id of this paragraph.
60
+ * The main body paragraphs have an empty string segment id.
61
+ * The header and footer paragraphs have a non-empty string segment id.
62
+ * @returns {string} The segment id.
63
+ * @example
64
+ * ```ts
65
+ * const fDocument = univerAPI.getActiveDocument();
66
+ * const paragraph = fDocument.getParagraphs()[0];
67
+ * console.log(paragraph?.getSegmentId());
68
+ * ```
69
+ */
70
+ getSegmentId(): string;
71
+ /**
72
+ * Get this paragraph's metadata.
73
+ * @returns {IFDocumentParagraphInfo} The paragraph info.
74
+ * @example
75
+ * ```ts
76
+ * const fDocument = univerAPI.getActiveDocument();
77
+ * const paragraph = fDocument.getParagraphs()[0];
78
+ * console.log(paragraph?.getInfo());
79
+ * ```
80
+ */
81
+ getInfo(): IFDocumentParagraphInfo;
82
+ /**
83
+ * Get the current text range occupied by this paragraph.
84
+ * @returns {IFDocumentTextRange} The paragraph text range, excluding the trailing paragraph break.
85
+ * @example
86
+ * ```ts
87
+ * const fDocument = univerAPI.getActiveDocument();
88
+ * const paragraph = fDocument.getParagraphs()[0];
89
+ * console.log(paragraph?.getRange());
90
+ * ```
91
+ */
92
+ getRange(): IFDocumentTextRange;
93
+ /**
94
+ * Get this paragraph's plain text.
95
+ * @returns {string} The paragraph text without the trailing paragraph break.
96
+ * @example
97
+ * ```ts
98
+ * const fDocument = univerAPI.getActiveDocument();
99
+ * const paragraph = fDocument.getParagraphs()[0];
100
+ * console.log(paragraph?.getText());
101
+ * ```
102
+ */
103
+ getText(): string;
104
+ /**
105
+ * Replace this paragraph's plain text.
106
+ * @param {string} text The replacement text. Do not include the paragraph break.
107
+ * @returns {boolean} `true` if the paragraph text was replaced.
108
+ * @example
109
+ * ```ts
110
+ * const fDocument = univerAPI.getActiveDocument();
111
+ * const paragraph = fDocument.getParagraphs()[0];
112
+ * paragraph?.setText('New text');
113
+ * console.log(paragraph?.getText());
114
+ * ```
115
+ */
116
+ setText(text: string): boolean;
117
+ /**
118
+ * Append plain text before this paragraph's trailing paragraph break.
119
+ * @param {string} text The plain text to append.
120
+ * @returns {boolean} `true` if the text was appended.
121
+ * @example
122
+ * ```ts
123
+ * const fDocument = univerAPI.getActiveDocument();
124
+ * const paragraph = fDocument.getParagraphs()[0];
125
+ * paragraph?.appendText(' Appended text');
126
+ * console.log(paragraph?.getText());
127
+ * ```
128
+ */
129
+ appendText(text: string): boolean;
130
+ /**
131
+ * Apply paragraph style to a paragraph handle or text range.
132
+ * @param {IParagraphStyle} style The Univer paragraph style patch.
133
+ * @returns {boolean} `true` if the style was applied.
134
+ * @example
135
+ * ```ts
136
+ * const fDocument = univerAPI.getActiveDocument();
137
+ * const paragraph = fDocument.getParagraphs()[0];
138
+ * paragraph?.setText('Styled text');
139
+ * paragraph?.setStyle({
140
+ * textStyle: {
141
+ * cl: {
142
+ * rgb: '#FF0000',
143
+ * },
144
+ * fs: 14,
145
+ * },
146
+ * horizontalAlign: 2,
147
+ * });
148
+ * console.log(paragraph?.getInfo().paragraph.paragraphStyle);
149
+ * ```
150
+ */
151
+ setStyle(style: IParagraphStyle): boolean;
152
+ /**
153
+ * Check whether this paragraph is a bullet, ordered, or checklist item.
154
+ * @returns {boolean} `true` if the paragraph has list metadata.
155
+ * @example
156
+ * ```ts
157
+ * const fDocument = univerAPI.getActiveDocument();
158
+ * const paragraph = fDocument.getParagraphs()[0];
159
+ * console.log(paragraph?.isListItem());
160
+ * ```
161
+ */
162
+ isListItem(): boolean;
163
+ /**
164
+ * Check whether this paragraph is a task/checklist item.
165
+ * @returns {boolean} `true` if this paragraph is an unchecked or checked task item.
166
+ * @example
167
+ * ```ts
168
+ * const fDocument = univerAPI.getActiveDocument();
169
+ * const paragraph = fDocument.getParagraphs()[0];
170
+ * console.log(paragraph?.isTask());
171
+ * ```
172
+ */
173
+ isTask(): boolean;
174
+ /**
175
+ * Set the checked state of this task/checklist paragraph.
176
+ * @param {boolean} checked Whether the task item should be checked.
177
+ * @returns {boolean} `true` if the task state was updated, or `false` if this paragraph is not a task item.
178
+ * @example
179
+ * ```ts
180
+ * const fDocument = univerAPI.getActiveDocument();
181
+ * const paragraph = fDocument.getParagraphs()[0];
182
+ *
183
+ * if (paragraph.isTask()) {
184
+ * const success = paragraph.setTaskChecked(true);
185
+ * console.log(success ? 'Task checked' : 'Failed to check task');
186
+ * }
187
+ * ```
188
+ */
189
+ setTaskChecked(checked: boolean): boolean;
190
+ /**
191
+ * Remove this paragraph.
192
+ * @returns {boolean} `true` if the paragraph was removed.
193
+ * @example
194
+ * ```ts
195
+ * const fDocument = univerAPI.getActiveDocument();
196
+ * const paragraph = fDocument.getParagraphs()[0];
197
+ * const success = paragraph?.remove();
198
+ * console.log(success ? 'Paragraph removed' : 'Failed to remove paragraph');
199
+ * ```
200
+ */
201
+ remove(): boolean;
202
+ private _preserveExplicitParagraphIds;
203
+ }
204
+ export declare function isParagraphFacade(value: unknown): value is FDocumentParagraph;