@univerjs/docs 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +3 -2
- package/lib/es/index.js +193 -145
- package/lib/types/basics/custom-range-factory.d.ts +0 -1
- package/lib/types/basics/custom-range.d.ts +1 -1
- package/lib/types/basics/paragraph.d.ts +2 -0
- package/lib/types/basics/plain-text.d.ts +5 -1
- package/lib/types/basics/replace.d.ts +2 -2
- package/lib/types/basics/selection.d.ts +1 -1
- package/lib/types/basics/table.d.ts +0 -2
- package/lib/types/commands/commands/core-editing.command.d.ts +0 -1
- package/lib/types/commands/commands/list.command.d.ts +1 -0
- package/lib/types/commands/commands/table/doc-table-tab.command.d.ts +1 -3
- package/lib/types/commands/commands/table/table.d.ts +10 -0
- package/lib/types/index.d.ts +5 -3
- package/lib/types/services/doc-auto-format.service.d.ts +4 -4
- package/lib/types/services/doc-interceptor/doc-interceptor.service.d.ts +2 -2
- package/lib/umd/index.js +3 -2
- package/package.json +7 -7
package/lib/es/index.js
CHANGED
|
@@ -2,10 +2,42 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { CommandType, RxDisposable, ICommandService, Inject, IUndoRedoService, UndoCommandId, RedoCommandId, JSONX, IUniverInstanceService, LocaleService, UniverInstanceType, isInternalEditorID, Tools, PresetListType, MemoryCursor, TextX, PRESET_LIST_TYPE, GridType, TextXActionType,
|
|
5
|
+
import { DataStreamTreeTokenType, CommandType, RxDisposable, ICommandService, Inject, IUndoRedoService, UndoCommandId, RedoCommandId, JSONX, IUniverInstanceService, LocaleService, UniverInstanceType, isInternalEditorID, Tools, PresetListType, MemoryCursor, TextX, PRESET_LIST_TYPE, GridType, TextXActionType, UpdateDocsAttributeType, sortRulesFactory, toDisposable, normalizeBody, getBodySlice, updateAttributeByInsert, BooleanNumber, TableCellHeightRule, TableSizeType, generateRandomId, TableAlignmentType, TableTextWrapType, ObjectRelativeFromH, ObjectRelativeFromV, PositionedObjectLayoutType, getCustomRangeSlice, getCustomDecorationSlice, BaselineOffset, OnLifecycle, LifecycleStages, Disposable, Direction, sequenceExecuteAsync, HorizontalAlign, Plugin, Injector, createInterceptorKey, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DisposableCollection, remove, composeInterceptors } from "@univerjs/core";
|
|
6
6
|
import { NORMAL_TEXT_SELECTION_PLUGIN_STYLE, ITextSelectionRenderManager, DocumentSkeleton, DocumentViewModel, IRenderManagerService, getCharSpaceApply, getNumberUnitValue, hasListGlyph, isIndentByGlyph, isFirstGlyph, getParagraphByGlyph, DocumentSkeletonPageType, lineIterator, getLastLine, RANGE_DIRECTION, NodePositionConvertToCursor, TextSelectionRenderManager } from "@univerjs/engine-render";
|
|
7
7
|
import { BehaviorSubject, takeUntil } from "rxjs";
|
|
8
8
|
import { TextSelectionManagerService as TextSelectionManagerService$1, getCommandSkeleton as getCommandSkeleton$1, getInsertSelection as getInsertSelection$1, RichTextEditingMutation as RichTextEditingMutation$1, generateParagraphs as generateParagraphs$1, getRichTextEditPath as getRichTextEditPath$1 } from "@univerjs/docs";
|
|
9
|
+
function isCustomRangeSplitSymbol(text) {
|
|
10
|
+
return text === DataStreamTreeTokenType.CUSTOM_RANGE_END || text === DataStreamTreeTokenType.CUSTOM_RANGE_START;
|
|
11
|
+
}
|
|
12
|
+
__name(isCustomRangeSplitSymbol, "isCustomRangeSplitSymbol");
|
|
13
|
+
function isIntersecting(line1Start, line1End, line2Start, line2End) {
|
|
14
|
+
return line1Start <= line2Start && line1End >= line2Start || line1Start >= line2Start && line1Start <= line2End;
|
|
15
|
+
}
|
|
16
|
+
__name(isIntersecting, "isIntersecting");
|
|
17
|
+
function shouldDeleteCustomRange(deleteStart, deleteLen, customRange, dataStream) {
|
|
18
|
+
const dataStreamSlice = dataStream.slice(customRange.startIndex + 1, customRange.endIndex), start = Math.max(deleteStart - (customRange.startIndex + 1), 0), end = deleteStart + deleteLen - 1 - (customRange.startIndex + 1);
|
|
19
|
+
if (end < 0)
|
|
20
|
+
return !1;
|
|
21
|
+
if (start === 0 && end >= dataStreamSlice.length)
|
|
22
|
+
return !0;
|
|
23
|
+
const result = dataStreamSlice.slice(0, start) + dataStreamSlice.slice(start + deleteLen);
|
|
24
|
+
for (let i = 0, len = result.length; i < len; i++) {
|
|
25
|
+
const letter = result[i];
|
|
26
|
+
if (!isCustomRangeSplitSymbol(letter))
|
|
27
|
+
return !1;
|
|
28
|
+
}
|
|
29
|
+
return !0;
|
|
30
|
+
}
|
|
31
|
+
__name(shouldDeleteCustomRange, "shouldDeleteCustomRange");
|
|
32
|
+
function getCustomRangesInterestsWithRange(range, customRanges) {
|
|
33
|
+
const result = [];
|
|
34
|
+
for (let i = 0, len = customRanges.length; i < len; i++) {
|
|
35
|
+
const customRange = customRanges[i];
|
|
36
|
+
range.collapsed ? customRange.startIndex < range.startOffset && range.startOffset <= customRange.endIndex && result.push(customRange) : isIntersecting(range.startOffset, range.endOffset, customRange.startIndex, customRange.endIndex) && result.push(customRange);
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
__name(getCustomRangesInterestsWithRange, "getCustomRangesInterestsWithRange");
|
|
9
41
|
const SetTextSelectionsOperation = {
|
|
10
42
|
id: "doc.operation.set-selections",
|
|
11
43
|
type: CommandType.OPERATION,
|
|
@@ -155,7 +187,7 @@ let TextSelectionManagerService = (_a = class extends RxDisposable {
|
|
|
155
187
|
if (this._textSelectionRenderManager.removeAllRanges(), allTextSelectionInfo == null)
|
|
156
188
|
return;
|
|
157
189
|
const { textRanges, rectRanges } = allTextSelectionInfo, docRanges = [...textRanges, ...rectRanges];
|
|
158
|
-
docRanges.length > 0 && this._textSelectionRenderManager.addDocRanges(docRanges.map(serializeDocRange));
|
|
190
|
+
docRanges.length > 0 && this._textSelectionRenderManager.addDocRanges(docRanges.map(serializeDocRange), !1);
|
|
159
191
|
}
|
|
160
192
|
_replaceByParam(insertParam) {
|
|
161
193
|
const { unitId, subUnitId, style, segmentId, textRanges, rectRanges, isEditing, segmentPage } = insertParam;
|
|
@@ -456,6 +488,10 @@ function getRichTextEditPath(docDataModel, segmentId = "") {
|
|
|
456
488
|
throw new Error("Segment id not found in headers or footers");
|
|
457
489
|
}
|
|
458
490
|
__name(getRichTextEditPath, "getRichTextEditPath");
|
|
491
|
+
function hasParagraphInTable(paragraph, tables) {
|
|
492
|
+
return tables.some((table) => paragraph.startIndex > table.startIndex && paragraph.startIndex < table.endIndex);
|
|
493
|
+
}
|
|
494
|
+
__name(hasParagraphInTable, "hasParagraphInTable");
|
|
459
495
|
const ListOperationCommand = {
|
|
460
496
|
id: "doc.command.list-operation",
|
|
461
497
|
type: CommandType.COMMAND,
|
|
@@ -493,7 +529,7 @@ const ListOperationCommand = {
|
|
|
493
529
|
...customLists
|
|
494
530
|
}, { defaultTabStop = 36 } = docDataModel.getSnapshot().documentStyle;
|
|
495
531
|
for (const paragraph of currentParagraphs) {
|
|
496
|
-
const { startIndex, paragraphStyle = {}, bullet } = paragraph, { indentFirstLine, snapToGrid, indentStart } = paragraphStyle, paragraphProperties = lists[listType].nestingLevel[0].paragraphProperties || {}, { hanging: listHanging, indentStart: listIndentStart } = paragraphProperties,
|
|
532
|
+
const { startIndex, paragraphStyle = {}, bullet } = paragraph, { indentFirstLine, snapToGrid, indentStart } = paragraphStyle, paragraphProperties = lists[listType].nestingLevel[0].paragraphProperties || {}, { hanging: listHanging, indentStart: listIndentStart } = paragraphProperties, { charSpace, gridType } = findNearestSectionBreak(startIndex, sectionBreaks) || { charSpace: 0, gridType: GridType.LINES }, charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
|
|
497
533
|
textX.push({
|
|
498
534
|
t: TextXActionType.RETAIN,
|
|
499
535
|
len: startIndex - memoryCursor.cursor,
|
|
@@ -508,26 +544,13 @@ const ListOperationCommand = {
|
|
|
508
544
|
paragraphStyle: {
|
|
509
545
|
...paragraphStyle,
|
|
510
546
|
hanging: void 0,
|
|
511
|
-
indentStart: indentStart ? { v: Math.max(0, getNumberUnitValue(indentStart, charSpaceApply) + getNumberUnitValue(listHanging, charSpaceApply) - getNumberUnitValue(listIndentStart, charSpaceApply)) } : void 0
|
|
512
|
-
textStyle: {
|
|
513
|
-
...paragraphStyle.textStyle,
|
|
514
|
-
...bulletParagraphTextStyleEmpty
|
|
515
|
-
}
|
|
547
|
+
indentStart: indentStart ? { v: Math.max(0, getNumberUnitValue(indentStart, charSpaceApply) + getNumberUnitValue(listHanging, charSpaceApply) - getNumberUnitValue(listIndentStart, charSpaceApply)) } : void 0
|
|
516
548
|
},
|
|
517
549
|
startIndex: 0
|
|
518
550
|
} : {
|
|
519
551
|
startIndex: 0,
|
|
520
552
|
paragraphStyle: {
|
|
521
553
|
...paragraphStyle,
|
|
522
|
-
textStyle: {
|
|
523
|
-
...paragraphStyle.textStyle,
|
|
524
|
-
...bulletParagraphTextStyle,
|
|
525
|
-
...(bullet == null ? void 0 : bullet.listType) === PresetListType.CHECK_LIST_CHECKED ? {
|
|
526
|
-
st: {
|
|
527
|
-
s: BooleanNumber.FALSE
|
|
528
|
-
}
|
|
529
|
-
} : null
|
|
530
|
-
},
|
|
531
554
|
indentFirstLine: void 0,
|
|
532
555
|
hanging: listHanging,
|
|
533
556
|
indentStart: { v: getNumberUnitValue(listIndentStart, charSpaceApply) - getNumberUnitValue(listHanging, charSpaceApply) + getNumberUnitValue(indentFirstLine, charSpaceApply) + getNumberUnitValue(indentStart, charSpaceApply) }
|
|
@@ -553,7 +576,7 @@ const ListOperationCommand = {
|
|
|
553
576
|
}, ChangeListTypeCommand = {
|
|
554
577
|
id: "doc.command.change-list-type",
|
|
555
578
|
type: CommandType.COMMAND,
|
|
556
|
-
// eslint-disable-next-line max-lines-per-function
|
|
579
|
+
// eslint-disable-next-line max-lines-per-function
|
|
557
580
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
558
581
|
var _a11, _b, _c, _d, _e, _f;
|
|
559
582
|
const textSelectionManagerService = accessor.get(TextSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), { listType } = params, docDataModel = univerInstanceService.getCurrentUniverDocInstance(), activeRanges = textSelectionManagerService.getDocRanges();
|
|
@@ -576,7 +599,7 @@ const ListOperationCommand = {
|
|
|
576
599
|
...customLists
|
|
577
600
|
}, { defaultTabStop = 36 } = docDataModel.getSnapshot().documentStyle;
|
|
578
601
|
for (const paragraph of currentParagraphs) {
|
|
579
|
-
const { startIndex, paragraphStyle = {}, bullet } = paragraph, { indentFirstLine, snapToGrid, indentStart } = paragraphStyle, paragraphProperties = lists[listType].nestingLevel[0].paragraphProperties || {},
|
|
602
|
+
const { startIndex, paragraphStyle = {}, bullet } = paragraph, { indentFirstLine, snapToGrid, indentStart } = paragraphStyle, paragraphProperties = lists[listType].nestingLevel[0].paragraphProperties || {}, { hanging: listHanging, indentStart: listIndentStart } = paragraphProperties, { charSpace, gridType } = findNearestSectionBreak(startIndex, sectionBreaks) || { charSpace: 0, gridType: GridType.LINES }, charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
|
|
580
603
|
textX.push({
|
|
581
604
|
t: TextXActionType.RETAIN,
|
|
582
605
|
len: startIndex - memoryCursor.cursor,
|
|
@@ -591,15 +614,6 @@ const ListOperationCommand = {
|
|
|
591
614
|
startIndex: 0,
|
|
592
615
|
paragraphStyle: {
|
|
593
616
|
...paragraphStyle,
|
|
594
|
-
textStyle: {
|
|
595
|
-
...paragraphStyle.textStyle,
|
|
596
|
-
...bulletParagraphTextStyle,
|
|
597
|
-
...(bullet == null ? void 0 : bullet.listType) === PresetListType.CHECK_LIST_CHECKED ? {
|
|
598
|
-
st: {
|
|
599
|
-
s: BooleanNumber.FALSE
|
|
600
|
-
}
|
|
601
|
-
} : null
|
|
602
|
-
},
|
|
603
617
|
indentFirstLine: void 0,
|
|
604
618
|
hanging: listHanging,
|
|
605
619
|
indentStart: { v: getNumberUnitValue(listIndentStart, charSpaceApply) - getNumberUnitValue(listHanging, charSpaceApply) + getNumberUnitValue(indentFirstLine, charSpaceApply) + getNumberUnitValue(indentStart, charSpaceApply) }
|
|
@@ -629,13 +643,13 @@ const ChangeListNestingLevelCommand = {
|
|
|
629
643
|
type: CommandType.COMMAND,
|
|
630
644
|
// eslint-disable-next-line max-lines-per-function
|
|
631
645
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
632
|
-
var _a11, _b, _c;
|
|
646
|
+
var _a11, _b, _c, _d, _e;
|
|
633
647
|
if (!params)
|
|
634
648
|
return !1;
|
|
635
649
|
const { type } = params, textSelectionManagerService = accessor.get(TextSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), docDataModel = univerInstanceService.getCurrentUniverDocInstance(), activeRange = textSelectionManagerService.getActiveTextRangeWithStyle();
|
|
636
650
|
if (docDataModel == null || activeRange == null)
|
|
637
651
|
return !1;
|
|
638
|
-
const { segmentId } = activeRange,
|
|
652
|
+
const { segmentId } = activeRange, tables = (_b = (_a11 = docDataModel.getBody()) == null ? void 0 : _a11.tables) != null ? _b : [], selections = (_c = textSelectionManagerService.getDocRanges()) != null ? _c : [], paragraphs = (_d = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _d.paragraphs, serializedSelections = selections.map(serializeDocRange);
|
|
639
653
|
if (paragraphs == null)
|
|
640
654
|
return !1;
|
|
641
655
|
const currentParagraphs = getParagraphsInRange$1(activeRange, paragraphs), unitId = docDataModel.getUnitId(), doMutation = {
|
|
@@ -647,19 +661,20 @@ const ChangeListNestingLevelCommand = {
|
|
|
647
661
|
}
|
|
648
662
|
}, memoryCursor = new MemoryCursor();
|
|
649
663
|
memoryCursor.reset();
|
|
650
|
-
const textX = new TextX(), jsonX = JSONX.getInstance(), customLists = (
|
|
664
|
+
const textX = new TextX(), jsonX = JSONX.getInstance(), customLists = (_e = docDataModel.getSnapshot().lists) != null ? _e : {}, lists = {
|
|
651
665
|
...PRESET_LIST_TYPE,
|
|
652
666
|
...customLists
|
|
653
667
|
};
|
|
654
668
|
for (const paragraph of currentParagraphs) {
|
|
655
|
-
const { startIndex, paragraphStyle = {}, bullet } = paragraph;
|
|
669
|
+
const { startIndex, paragraphStyle = {}, bullet } = paragraph, isInTable = hasParagraphInTable(paragraph, tables);
|
|
656
670
|
if (textX.push({
|
|
657
671
|
t: TextXActionType.RETAIN,
|
|
658
672
|
len: startIndex - memoryCursor.cursor,
|
|
659
673
|
segmentId
|
|
660
674
|
}), bullet) {
|
|
661
|
-
const listType = bullet.listType
|
|
662
|
-
|
|
675
|
+
const listType = bullet.listType;
|
|
676
|
+
let maxLevel = lists[listType].nestingLevel.length - 1;
|
|
677
|
+
isInTable && (maxLevel = Math.min(maxLevel, 2)), textX.push({
|
|
663
678
|
t: TextXActionType.RETAIN,
|
|
664
679
|
len: 1,
|
|
665
680
|
body: {
|
|
@@ -715,15 +730,14 @@ const ChangeListNestingLevelCommand = {
|
|
|
715
730
|
}, ToggleCheckListCommand = {
|
|
716
731
|
id: "doc.command.toggle-check-list",
|
|
717
732
|
type: CommandType.COMMAND,
|
|
718
|
-
// eslint-disable-next-line max-lines-per-function
|
|
719
733
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
720
|
-
var _a11
|
|
734
|
+
var _a11;
|
|
721
735
|
if (!params)
|
|
722
736
|
return !1;
|
|
723
|
-
const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), { index } = params, docDataModel = univerInstanceService.getCurrentUniverDocInstance();
|
|
737
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), { index, segmentId } = params, docDataModel = univerInstanceService.getCurrentUniverDocInstance();
|
|
724
738
|
if (docDataModel == null)
|
|
725
739
|
return !1;
|
|
726
|
-
const paragraphs = (_a11 = docDataModel.getBody()) == null ? void 0 : _a11.paragraphs;
|
|
740
|
+
const paragraphs = (_a11 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a11.paragraphs;
|
|
727
741
|
if (paragraphs == null)
|
|
728
742
|
return !1;
|
|
729
743
|
const currentParagraph = paragraphs.find((p) => p.startIndex === index), unitId = docDataModel.getUnitId();
|
|
@@ -734,17 +748,16 @@ const ChangeListNestingLevelCommand = {
|
|
|
734
748
|
params: {
|
|
735
749
|
unitId,
|
|
736
750
|
actions: [],
|
|
737
|
-
textRanges: []
|
|
751
|
+
textRanges: [],
|
|
752
|
+
segmentId
|
|
738
753
|
}
|
|
739
754
|
}, memoryCursor = new MemoryCursor();
|
|
740
755
|
memoryCursor.reset();
|
|
741
|
-
const textX = new TextX(), jsonX = JSONX.getInstance(),
|
|
742
|
-
...PRESET_LIST_TYPE,
|
|
743
|
-
...customLists
|
|
744
|
-
}, { startIndex, paragraphStyle = {} } = currentParagraph, listType = currentParagraph.bullet.listType === PresetListType.CHECK_LIST ? PresetListType.CHECK_LIST_CHECKED : PresetListType.CHECK_LIST, bulletParagraphTextStyle = (lists[listType].nestingLevel[0].paragraphProperties || {}).textStyle;
|
|
756
|
+
const textX = new TextX(), jsonX = JSONX.getInstance(), { startIndex, paragraphStyle = {} } = currentParagraph, listType = currentParagraph.bullet.listType === PresetListType.CHECK_LIST ? PresetListType.CHECK_LIST_CHECKED : PresetListType.CHECK_LIST;
|
|
745
757
|
textX.push({
|
|
746
758
|
t: TextXActionType.RETAIN,
|
|
747
|
-
len: startIndex - memoryCursor.cursor
|
|
759
|
+
len: startIndex - memoryCursor.cursor,
|
|
760
|
+
segmentId
|
|
748
761
|
}), textX.push({
|
|
749
762
|
t: TextXActionType.RETAIN,
|
|
750
763
|
len: 1,
|
|
@@ -753,13 +766,7 @@ const ChangeListNestingLevelCommand = {
|
|
|
753
766
|
paragraphs: [
|
|
754
767
|
{
|
|
755
768
|
...currentParagraph,
|
|
756
|
-
paragraphStyle
|
|
757
|
-
...paragraphStyle,
|
|
758
|
-
textStyle: {
|
|
759
|
-
...paragraphStyle.textStyle,
|
|
760
|
-
...bulletParagraphTextStyle
|
|
761
|
-
}
|
|
762
|
-
},
|
|
769
|
+
paragraphStyle,
|
|
763
770
|
startIndex: 0,
|
|
764
771
|
bullet: {
|
|
765
772
|
...currentParagraph.bullet,
|
|
@@ -768,9 +775,10 @@ const ChangeListNestingLevelCommand = {
|
|
|
768
775
|
}
|
|
769
776
|
]
|
|
770
777
|
},
|
|
771
|
-
coverType: UpdateDocsAttributeType.REPLACE
|
|
778
|
+
coverType: UpdateDocsAttributeType.REPLACE,
|
|
779
|
+
segmentId
|
|
772
780
|
}), memoryCursor.moveCursorTo(startIndex + 1);
|
|
773
|
-
const path = getRichTextEditPath(docDataModel);
|
|
781
|
+
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
774
782
|
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
775
783
|
}, "handler")
|
|
776
784
|
}, OrderListCommand = {
|
|
@@ -898,38 +906,6 @@ function findNearestSectionBreak(currentIndex, sectionBreaks) {
|
|
|
898
906
|
}
|
|
899
907
|
}
|
|
900
908
|
__name(findNearestSectionBreak, "findNearestSectionBreak");
|
|
901
|
-
function isCustomRangeSplitSymbol(text) {
|
|
902
|
-
return text === DataStreamTreeTokenType.CUSTOM_RANGE_END || text === DataStreamTreeTokenType.CUSTOM_RANGE_START;
|
|
903
|
-
}
|
|
904
|
-
__name(isCustomRangeSplitSymbol, "isCustomRangeSplitSymbol");
|
|
905
|
-
function isIntersecting(line1Start, line1End, line2Start, line2End) {
|
|
906
|
-
return line1Start <= line2Start && line1End >= line2Start || line1Start >= line2Start && line1Start <= line2End;
|
|
907
|
-
}
|
|
908
|
-
__name(isIntersecting, "isIntersecting");
|
|
909
|
-
function shouldDeleteCustomRange(deleteStart, deleteLen, customRange, dataStream) {
|
|
910
|
-
const dataStreamSlice = dataStream.slice(customRange.startIndex + 1, customRange.endIndex), start = Math.max(deleteStart - (customRange.startIndex + 1), 0), end = deleteStart + deleteLen - 1 - (customRange.startIndex + 1);
|
|
911
|
-
if (end < 0)
|
|
912
|
-
return !1;
|
|
913
|
-
if (start === 0 && end >= dataStreamSlice.length)
|
|
914
|
-
return !0;
|
|
915
|
-
const result = dataStreamSlice.slice(0, start) + dataStreamSlice.slice(start + deleteLen);
|
|
916
|
-
for (let i = 0, len = result.length; i < len; i++) {
|
|
917
|
-
const letter = result[i];
|
|
918
|
-
if (!isCustomRangeSplitSymbol(letter))
|
|
919
|
-
return !1;
|
|
920
|
-
}
|
|
921
|
-
return !0;
|
|
922
|
-
}
|
|
923
|
-
__name(shouldDeleteCustomRange, "shouldDeleteCustomRange");
|
|
924
|
-
function getCustomRangesIntesetsWithRange(range, customRanges) {
|
|
925
|
-
const result = [];
|
|
926
|
-
for (let i = 0, len = customRanges.length; i < len; i++) {
|
|
927
|
-
const customRange = customRanges[i];
|
|
928
|
-
range.collapsed ? customRange.startIndex < range.startOffset && range.startOffset <= customRange.endIndex && result.push(customRange) : isIntersecting(range.startOffset, range.endOffset, customRange.startIndex, customRange.endIndex) && result.push(customRange);
|
|
929
|
-
}
|
|
930
|
-
return result;
|
|
931
|
-
}
|
|
932
|
-
__name(getCustomRangesIntesetsWithRange, "getCustomRangesIntesetsWithRange");
|
|
933
909
|
var DeleteDirection = /* @__PURE__ */ ((DeleteDirection2) => (DeleteDirection2[DeleteDirection2.LEFT = 0] = "LEFT", DeleteDirection2[DeleteDirection2.RIGHT = 1] = "RIGHT", DeleteDirection2))(DeleteDirection || {});
|
|
934
910
|
function makeSelection(startOffset, endOffset) {
|
|
935
911
|
if (typeof endOffset > "u")
|
|
@@ -994,12 +970,14 @@ function getInsertSelection(selection, body) {
|
|
|
994
970
|
for (; body.dataStream[endOffset - 1] === DataStreamTreeTokenType.CUSTOM_RANGE_START; )
|
|
995
971
|
endOffset -= 1, startOffset -= 1;
|
|
996
972
|
return {
|
|
973
|
+
...selection,
|
|
997
974
|
startOffset,
|
|
998
975
|
endOffset,
|
|
999
976
|
collapsed
|
|
1000
977
|
};
|
|
1001
978
|
} else
|
|
1002
979
|
return {
|
|
980
|
+
...selection,
|
|
1003
981
|
...getSelectionWithSymbolMax(selection, body),
|
|
1004
982
|
collapsed: !1
|
|
1005
983
|
};
|
|
@@ -1130,38 +1108,40 @@ function getRetainAndDeleteAndExcludeLineBreak(selection, body, segmentId = "",
|
|
|
1130
1108
|
}
|
|
1131
1109
|
__name(getRetainAndDeleteAndExcludeLineBreak, "getRetainAndDeleteAndExcludeLineBreak");
|
|
1132
1110
|
function replaceSelectionFactory(accessor, params) {
|
|
1133
|
-
var _a11, _b;
|
|
1134
|
-
const { unitId, originBody, body: insertBody } = params,
|
|
1111
|
+
var _a11, _b, _c, _d;
|
|
1112
|
+
const { unitId, originBody, body: insertBody } = params, docDataModel = accessor.get(IUniverInstanceService).getUnit(unitId);
|
|
1113
|
+
if (!docDataModel)
|
|
1114
|
+
return !1;
|
|
1115
|
+
const segmentId = (_a11 = params.selection) == null ? void 0 : _a11.segmentId;
|
|
1135
1116
|
let body;
|
|
1136
|
-
if (params.originBody)
|
|
1137
|
-
|
|
1138
|
-
else {
|
|
1139
|
-
const docDataModel = univerInstanceService.getUnit(unitId);
|
|
1140
|
-
body = docDataModel == null ? void 0 : docDataModel.getBody();
|
|
1141
|
-
}
|
|
1142
|
-
if (!body) return !1;
|
|
1143
|
-
const textSelectionManagerService = accessor.get(TextSelectionManagerService), selection = (_a11 = params.selection) != null ? _a11 : textSelectionManagerService.getActiveTextRangeWithStyle();
|
|
1117
|
+
if (params.originBody ? body = originBody : body = (_b = docDataModel.getSelfOrHeaderFooterModel(segmentId)) == null ? void 0 : _b.getBody(), !body) return !1;
|
|
1118
|
+
const textSelectionManagerService = accessor.get(TextSelectionManagerService), selection = (_c = params.selection) != null ? _c : textSelectionManagerService.getActiveTextRangeWithStyle();
|
|
1144
1119
|
if (!selection || !body)
|
|
1145
1120
|
return !1;
|
|
1146
|
-
const textRanges = (
|
|
1121
|
+
const textRanges = (_d = params.textRanges) != null ? _d : [{
|
|
1147
1122
|
startOffset: selection.startOffset + insertBody.dataStream.length,
|
|
1148
1123
|
endOffset: selection.startOffset + insertBody.dataStream.length,
|
|
1149
|
-
collapsed: !0
|
|
1124
|
+
collapsed: !0,
|
|
1125
|
+
segmentId
|
|
1150
1126
|
}], doMutation = {
|
|
1151
1127
|
id: RichTextEditingMutation.id,
|
|
1152
1128
|
params: {
|
|
1153
1129
|
unitId,
|
|
1154
1130
|
actions: [],
|
|
1155
1131
|
textRanges,
|
|
1156
|
-
debounce: !0
|
|
1132
|
+
debounce: !0,
|
|
1133
|
+
segmentId
|
|
1157
1134
|
}
|
|
1158
1135
|
}, textX = new TextX(), jsonX = JSONX.getInstance();
|
|
1159
|
-
|
|
1136
|
+
textX.push(...getRetainAndDeleteAndExcludeLineBreak(selection, body, segmentId)), textX.push({
|
|
1160
1137
|
t: TextXActionType.INSERT,
|
|
1161
1138
|
body: insertBody,
|
|
1162
1139
|
len: insertBody.dataStream.length,
|
|
1163
|
-
line: 0
|
|
1164
|
-
|
|
1140
|
+
line: 0,
|
|
1141
|
+
segmentId
|
|
1142
|
+
});
|
|
1143
|
+
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
1144
|
+
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), doMutation;
|
|
1165
1145
|
}
|
|
1166
1146
|
__name(replaceSelectionFactory, "replaceSelectionFactory");
|
|
1167
1147
|
var DOCS_VIEW_KEY = /* @__PURE__ */ ((DOCS_VIEW_KEY2) => (DOCS_VIEW_KEY2.MAIN = "__Document_Render_Main__", DOCS_VIEW_KEY2.BACKGROUND = "__Document_Render_Background__", DOCS_VIEW_KEY2))(DOCS_VIEW_KEY || {}), VIEWPORT_KEY = /* @__PURE__ */ ((VIEWPORT_KEY2) => (VIEWPORT_KEY2.VIEW_MAIN = "viewMain", VIEWPORT_KEY2.VIEW_TOP = "viewTop", VIEWPORT_KEY2.VIEW_LEFT = "viewLeft", VIEWPORT_KEY2.VIEW_LEFT_TOP = "viewLeftTop", VIEWPORT_KEY2))(VIEWPORT_KEY || {});
|
|
@@ -1263,10 +1243,9 @@ __name(getRetainAndDeleteFromReplace, "getRetainAndDeleteFromReplace");
|
|
|
1263
1243
|
const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
1264
1244
|
id: EditorInsertTextCommandId,
|
|
1265
1245
|
type: CommandType.COMMAND,
|
|
1266
|
-
// eslint-disable-next-line max-lines-per-function
|
|
1267
1246
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
1268
1247
|
var _a11;
|
|
1269
|
-
const commandService = accessor.get(ICommandService), { range, segmentId, body, unitId,
|
|
1248
|
+
const commandService = accessor.get(ICommandService), { range, segmentId, body, unitId, cursorOffset } = params, textSelectionManagerService = accessor.get(TextSelectionManagerService), docDataModel = accessor.get(IUniverInstanceService).getUnit(unitId, UniverInstanceType.UNIVER_DOC);
|
|
1270
1249
|
if (docDataModel == null)
|
|
1271
1250
|
return !1;
|
|
1272
1251
|
const activeRange = textSelectionManagerService.getActiveTextRangeWithStyle(), originBody = docDataModel.getSelfOrHeaderFooterModel((_a11 = activeRange == null ? void 0 : activeRange.segmentId) != null ? _a11 : "").getBody();
|
|
@@ -1284,7 +1263,7 @@ const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
|
1284
1263
|
params: {
|
|
1285
1264
|
unitId,
|
|
1286
1265
|
actions: [],
|
|
1287
|
-
textRanges
|
|
1266
|
+
textRanges,
|
|
1288
1267
|
debounce: !0
|
|
1289
1268
|
}
|
|
1290
1269
|
}, textX = new TextX(), jsonX = JSONX.getInstance();
|
|
@@ -1296,11 +1275,11 @@ const EditorInsertTextCommandId = "doc.command.insert-text", InsertCommand = {
|
|
|
1296
1275
|
});
|
|
1297
1276
|
else {
|
|
1298
1277
|
const { dos, retain } = getRetainAndDeleteFromReplace(actualRange, segmentId, 0, originBody);
|
|
1299
|
-
textX.push(...dos),
|
|
1278
|
+
textX.push(...dos), doMutation.params.textRanges = [{
|
|
1300
1279
|
startOffset: startOffset + cursorMove + retain,
|
|
1301
1280
|
endOffset: startOffset + cursorMove + retain,
|
|
1302
1281
|
collapsed
|
|
1303
|
-
}]
|
|
1282
|
+
}];
|
|
1304
1283
|
}
|
|
1305
1284
|
textX.push({
|
|
1306
1285
|
t: TextXActionType.INSERT,
|
|
@@ -1876,6 +1855,54 @@ function getDeleteRowContentActionParams(rangeInfo, viewModel) {
|
|
|
1876
1855
|
};
|
|
1877
1856
|
}
|
|
1878
1857
|
__name(getDeleteRowContentActionParams, "getDeleteRowContentActionParams");
|
|
1858
|
+
var CellPosition = /* @__PURE__ */ ((CellPosition2) => (CellPosition2[CellPosition2.NEXT = 0] = "NEXT", CellPosition2[CellPosition2.PREV = 1] = "PREV", CellPosition2))(CellPosition || {});
|
|
1859
|
+
function getCellOffsets(viewModel, range, position) {
|
|
1860
|
+
const { startOffset } = range;
|
|
1861
|
+
let targetTable = null;
|
|
1862
|
+
for (const section of viewModel.children) {
|
|
1863
|
+
for (const paragraph of section.children) {
|
|
1864
|
+
const table = paragraph.children[0];
|
|
1865
|
+
if (table && startOffset > table.startIndex && startOffset < table.endIndex) {
|
|
1866
|
+
targetTable = table;
|
|
1867
|
+
break;
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
if (targetTable)
|
|
1871
|
+
break;
|
|
1872
|
+
}
|
|
1873
|
+
if (targetTable == null)
|
|
1874
|
+
return null;
|
|
1875
|
+
let cellIndex = -1, rowIndex = -1, targetRow = null;
|
|
1876
|
+
for (const row of targetTable.children) {
|
|
1877
|
+
for (const cell of row.children)
|
|
1878
|
+
if (startOffset > cell.startIndex && startOffset < cell.endIndex) {
|
|
1879
|
+
cellIndex = row.children.indexOf(cell), rowIndex = targetTable.children.indexOf(row), targetRow = row;
|
|
1880
|
+
break;
|
|
1881
|
+
}
|
|
1882
|
+
if (cellIndex > -1)
|
|
1883
|
+
break;
|
|
1884
|
+
}
|
|
1885
|
+
if (cellIndex === -1 || rowIndex === -1 || targetRow == null)
|
|
1886
|
+
return null;
|
|
1887
|
+
let newCell = null;
|
|
1888
|
+
if (position === 0) {
|
|
1889
|
+
if (newCell = targetRow.children[cellIndex + 1], !newCell) {
|
|
1890
|
+
const nextRow = targetTable.children[rowIndex + 1];
|
|
1891
|
+
nextRow && (newCell = nextRow.children[0]);
|
|
1892
|
+
}
|
|
1893
|
+
} else if (newCell = targetRow.children[cellIndex - 1], !newCell) {
|
|
1894
|
+
const prevRow = targetTable.children[rowIndex - 1];
|
|
1895
|
+
prevRow && (newCell = prevRow.children[prevRow.children.length - 1]);
|
|
1896
|
+
}
|
|
1897
|
+
if (newCell) {
|
|
1898
|
+
const { startIndex, endIndex } = newCell;
|
|
1899
|
+
return {
|
|
1900
|
+
startOffset: startIndex + 1,
|
|
1901
|
+
endOffset: endIndex - 2
|
|
1902
|
+
};
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
__name(getCellOffsets, "getCellOffsets");
|
|
1879
1906
|
function hasRangeInTable(ranges) {
|
|
1880
1907
|
return ranges.some((range) => {
|
|
1881
1908
|
const { anchorNodePosition } = range;
|
|
@@ -1900,7 +1927,8 @@ const InnerPasteCommand = {
|
|
|
1900
1927
|
params: {
|
|
1901
1928
|
unitId,
|
|
1902
1929
|
actions: [],
|
|
1903
|
-
textRanges
|
|
1930
|
+
textRanges,
|
|
1931
|
+
segmentId
|
|
1904
1932
|
}
|
|
1905
1933
|
}, memoryCursor = new MemoryCursor();
|
|
1906
1934
|
memoryCursor.reset();
|
|
@@ -2499,12 +2527,12 @@ const IMEInputCommand = {
|
|
|
2499
2527
|
const previousActiveRange = imeInputManagerService.getActiveRange();
|
|
2500
2528
|
if (!previousActiveRange)
|
|
2501
2529
|
return !1;
|
|
2502
|
-
const {
|
|
2530
|
+
const { style, segmentId } = previousActiveRange, body = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
2503
2531
|
if (body == null)
|
|
2504
2532
|
return !1;
|
|
2505
2533
|
const insertRange = getInsertSelection(previousActiveRange, body);
|
|
2506
2534
|
Object.assign(previousActiveRange, insertRange);
|
|
2507
|
-
const len = newText.length, textRanges = [
|
|
2535
|
+
const { startOffset } = previousActiveRange, len = newText.length, textRanges = [
|
|
2508
2536
|
{
|
|
2509
2537
|
startOffset: startOffset + len,
|
|
2510
2538
|
endOffset: startOffset + len,
|
|
@@ -3453,17 +3481,17 @@ let DocAutoFormatService = (_a6 = class extends Disposable {
|
|
|
3453
3481
|
}
|
|
3454
3482
|
onAutoFormat(id, params) {
|
|
3455
3483
|
var _a11, _b, _c, _d, _e, _f;
|
|
3456
|
-
const
|
|
3484
|
+
const autoFormats = (_a11 = this._matches.get(id)) != null ? _a11 : [], unit = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), selection = this._textSelectionManagerService.getActiveTextRangeWithStyle();
|
|
3457
3485
|
if (unit && selection) {
|
|
3458
3486
|
const doc = unit.getSelfOrHeaderFooterModel(selection.segmentId), context = {
|
|
3459
3487
|
unit: doc,
|
|
3460
3488
|
selection,
|
|
3461
3489
|
isBody: !selection.segmentId,
|
|
3462
3490
|
paragraphs: getParagraphsInRange(selection, (_c = (_b = doc.getBody()) == null ? void 0 : _b.paragraphs) != null ? _c : []),
|
|
3463
|
-
customRanges:
|
|
3491
|
+
customRanges: getCustomRangesInterestsWithRange(selection, (_e = (_d = doc.getBody()) == null ? void 0 : _d.customRanges) != null ? _e : []),
|
|
3464
3492
|
commandId: id,
|
|
3465
3493
|
commandParams: params
|
|
3466
|
-
}, matched =
|
|
3494
|
+
}, matched = autoFormats.find((i) => i.match(context));
|
|
3467
3495
|
return (_f = matched == null ? void 0 : matched.getMutations(context)) != null ? _f : [];
|
|
3468
3496
|
}
|
|
3469
3497
|
return [];
|
|
@@ -3524,21 +3552,12 @@ let NormalInputController = (_a7 = class extends Disposable {
|
|
|
3524
3552
|
const unitId = documentModel.getUnitId(), { event, content = "", activeRange } = config, e = event, skeleton = (_a11 = this._renderManagerService.getRenderById(documentModel.getUnitId())) == null ? void 0 : _a11.with(DocSkeletonManagerService).getSkeleton();
|
|
3525
3553
|
if (e.data == null || skeleton == null || !skeleton || !activeRange)
|
|
3526
3554
|
return;
|
|
3527
|
-
const {
|
|
3528
|
-
{
|
|
3529
|
-
startOffset: startOffset + len,
|
|
3530
|
-
endOffset: startOffset + len,
|
|
3531
|
-
segmentId,
|
|
3532
|
-
segmentPage,
|
|
3533
|
-
style
|
|
3534
|
-
}
|
|
3535
|
-
];
|
|
3555
|
+
const { segmentId } = activeRange;
|
|
3536
3556
|
await this._commandService.executeCommand(InsertCommand.id, {
|
|
3537
3557
|
unitId,
|
|
3538
3558
|
body: {
|
|
3539
3559
|
dataStream: content
|
|
3540
3560
|
},
|
|
3541
|
-
textRanges,
|
|
3542
3561
|
range: activeRange,
|
|
3543
3562
|
segmentId
|
|
3544
3563
|
}), content === " " && await this._commandService.executeCommand(AfterSpaceCommand.id);
|
|
@@ -4034,11 +4053,25 @@ const DocsRenameMutation = {
|
|
|
4034
4053
|
}, DocTableTabCommand = {
|
|
4035
4054
|
id: "doc.table.tab-in-table",
|
|
4036
4055
|
type: CommandType.COMMAND,
|
|
4037
|
-
handler: /* @__PURE__ */ __name(async () =>
|
|
4038
|
-
},
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4056
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
4057
|
+
const { shift } = params, textSelectionManager = accessor.get(TextSelectionManagerService), activeTextRange = textSelectionManager.getActiveTextRangeWithStyle(), commandService = accessor.get(ICommandService), docDataModel = accessor.get(IUniverInstanceService).getCurrentUniverDocInstance();
|
|
4058
|
+
if (!docDataModel)
|
|
4059
|
+
return !1;
|
|
4060
|
+
const unitId = docDataModel.getUnitId(), docSkeletonManagerService = getCommandSkeleton(accessor, unitId), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton(), viewModel = skeleton == null ? void 0 : skeleton.getViewModel().getSelfOrHeaderFooterViewModel(activeTextRange == null ? void 0 : activeTextRange.segmentId);
|
|
4061
|
+
if (viewModel == null || activeTextRange == null)
|
|
4062
|
+
return !1;
|
|
4063
|
+
let offsets = null;
|
|
4064
|
+
if (shift ? offsets = getCellOffsets(viewModel, activeTextRange, CellPosition.PREV) : offsets = getCellOffsets(viewModel, activeTextRange, CellPosition.NEXT), offsets) {
|
|
4065
|
+
const { startOffset, endOffset } = offsets, textRanges = [{
|
|
4066
|
+
startOffset,
|
|
4067
|
+
endOffset
|
|
4068
|
+
}];
|
|
4069
|
+
return textSelectionManager.replaceTextRanges(textRanges), !0;
|
|
4070
|
+
}
|
|
4071
|
+
return shift === !1 ? await commandService.executeCommand(DocTableInsertRowCommand.id, {
|
|
4072
|
+
position: INSERT_ROW_POSITION.BELLOW
|
|
4073
|
+
}) : !0;
|
|
4074
|
+
}, "handler")
|
|
4042
4075
|
};
|
|
4043
4076
|
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
4044
4077
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -4102,7 +4135,6 @@ let UniverDocsPlugin = (_a9 = class extends Plugin {
|
|
|
4102
4135
|
DocTableDeleteColumnsCommand,
|
|
4103
4136
|
DocTableDeleteTableCommand,
|
|
4104
4137
|
DocTableTabCommand,
|
|
4105
|
-
DocTableShiftTabCommand,
|
|
4106
4138
|
DocsRenameMutation,
|
|
4107
4139
|
TabCommand,
|
|
4108
4140
|
AfterSpaceCommand,
|
|
@@ -4141,7 +4173,11 @@ let UniverDocsPlugin = (_a9 = class extends Plugin {
|
|
|
4141
4173
|
UniverDocsPlugin = __decorateClass$1([
|
|
4142
4174
|
__decorateParam$1(1, Inject(Injector))
|
|
4143
4175
|
], UniverDocsPlugin);
|
|
4144
|
-
const
|
|
4176
|
+
const getPlainTextFormBody = /* @__PURE__ */ __name((body) => {
|
|
4177
|
+
let str = body.dataStream;
|
|
4178
|
+
return body.dataStream.endsWith(`\r
|
|
4179
|
+
`) && (str = body.dataStream.slice(0, -2)), str.replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_START, "").replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_END, "");
|
|
4180
|
+
}, "getPlainTextFormBody"), getPlainTextFormDocument = /* @__PURE__ */ __name((data) => data.body ? getPlainTextFormBody(data.body) : "", "getPlainTextFormDocument");
|
|
4145
4181
|
function addCustomRangeTextX(param, body) {
|
|
4146
4182
|
const { range, rangeId, rangeType, segmentId } = param, actualRange = getSelectionForAddCustomRange(range, body);
|
|
4147
4183
|
if (!actualRange)
|
|
@@ -4197,13 +4233,13 @@ function addCustomRangeFactory(param, body) {
|
|
|
4197
4233
|
__name(addCustomRangeFactory, "addCustomRangeFactory");
|
|
4198
4234
|
function addCustomRangeBySelectionFactory(accessor, param) {
|
|
4199
4235
|
var _a11;
|
|
4200
|
-
const {
|
|
4236
|
+
const { rangeId, rangeType, wholeEntity } = param, textSelectionManagerService = accessor.get(TextSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), selection = textSelectionManagerService.getActiveTextRangeWithStyle(), segmentId = selection == null ? void 0 : selection.segmentId;
|
|
4201
4237
|
if (!selection)
|
|
4202
4238
|
return !1;
|
|
4203
4239
|
const documentDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
4204
4240
|
if (!documentDataModel)
|
|
4205
4241
|
return !1;
|
|
4206
|
-
const body = documentDataModel.getBody(), unitId = documentDataModel.getUnitId();
|
|
4242
|
+
const body = documentDataModel.getSelfOrHeaderFooterModel(selection.segmentId).getBody(), unitId = documentDataModel.getUnitId();
|
|
4207
4243
|
if (!body)
|
|
4208
4244
|
return !1;
|
|
4209
4245
|
const { startOffset, endOffset } = normalizeSelection(selection), customRanges = (_a11 = body.customRanges) != null ? _a11 : [], relativeCustomRanges = [];
|
|
@@ -4270,8 +4306,8 @@ function addCustomRangeBySelectionFactory(accessor, param) {
|
|
|
4270
4306
|
actions: [],
|
|
4271
4307
|
textRanges: void 0
|
|
4272
4308
|
}
|
|
4273
|
-
};
|
|
4274
|
-
return doMutation.params.actions = jsonX.editOp(textX.serialize()), doMutation;
|
|
4309
|
+
}, path = getRichTextEditPath(documentDataModel, segmentId);
|
|
4310
|
+
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), doMutation;
|
|
4275
4311
|
}
|
|
4276
4312
|
__name(addCustomRangeBySelectionFactory, "addCustomRangeBySelectionFactory");
|
|
4277
4313
|
function deleteCustomRangeTextX(accessor, params) {
|
|
@@ -4279,7 +4315,7 @@ function deleteCustomRangeTextX(accessor, params) {
|
|
|
4279
4315
|
const { unitId, rangeId, segmentId } = params, documentDataModel = accessor.get(IUniverInstanceService).getUnit(unitId);
|
|
4280
4316
|
if (!documentDataModel)
|
|
4281
4317
|
return !1;
|
|
4282
|
-
const range = (_b = (_a11 = documentDataModel.getBody()) == null ? void 0 : _a11.customRanges) == null ? void 0 : _b.find((r) => r.rangeId === rangeId);
|
|
4318
|
+
const range = (_b = (_a11 = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a11.customRanges) == null ? void 0 : _b.find((r) => r.rangeId === rangeId);
|
|
4283
4319
|
if (!range)
|
|
4284
4320
|
return !1;
|
|
4285
4321
|
const { startIndex, endIndex } = range, textX = new TextX(), len = endIndex - startIndex + 1;
|
|
@@ -4305,15 +4341,22 @@ function deleteCustomRangeTextX(accessor, params) {
|
|
|
4305
4341
|
}
|
|
4306
4342
|
__name(deleteCustomRangeTextX, "deleteCustomRangeTextX");
|
|
4307
4343
|
function deleteCustomRangeFactory(accessor, params) {
|
|
4344
|
+
const { unitId, segmentId } = params, documentDataModel = accessor.get(IUniverInstanceService).getUnit(unitId);
|
|
4345
|
+
if (!documentDataModel)
|
|
4346
|
+
return !1;
|
|
4308
4347
|
const doMutation = {
|
|
4309
4348
|
id: RichTextEditingMutation.id,
|
|
4310
4349
|
params: {
|
|
4311
4350
|
unitId: params.unitId,
|
|
4312
4351
|
actions: [],
|
|
4313
|
-
textRanges: void 0
|
|
4352
|
+
textRanges: void 0,
|
|
4353
|
+
segmentId
|
|
4314
4354
|
}
|
|
4315
4355
|
}, jsonX = JSONX.getInstance(), textX = deleteCustomRangeTextX(accessor, params);
|
|
4316
|
-
|
|
4356
|
+
if (!textX)
|
|
4357
|
+
return !1;
|
|
4358
|
+
const path = getRichTextEditPath(documentDataModel, segmentId);
|
|
4359
|
+
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), doMutation;
|
|
4317
4360
|
}
|
|
4318
4361
|
__name(deleteCustomRangeFactory, "deleteCustomRangeFactory");
|
|
4319
4362
|
function addCustomDecorationFactory(param) {
|
|
@@ -4420,17 +4463,20 @@ let DocInterceptorService = (_a10 = class extends Disposable {
|
|
|
4420
4463
|
constructor(_context, _docSkeletonManagerService) {
|
|
4421
4464
|
super();
|
|
4422
4465
|
__publicField(this, "_interceptorsByName", /* @__PURE__ */ new Map());
|
|
4423
|
-
this._context = _context, this._docSkeletonManagerService = _docSkeletonManagerService
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
this.interceptDocumentViewModel(viewModel);
|
|
4429
|
-
}
|
|
4430
|
-
})), this.disposeWithMe(this.intercept(DOC_INTERCEPTOR_POINT.CUSTOM_RANGE, {
|
|
4466
|
+
this._context = _context, this._docSkeletonManagerService = _docSkeletonManagerService;
|
|
4467
|
+
const viewModel = this._docSkeletonManagerService.getViewModel(), unitId = viewModel.getDataModel().getUnitId();
|
|
4468
|
+
if (unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY || unitId === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)
|
|
4469
|
+
return;
|
|
4470
|
+
this.disposeWithMe(this.interceptDocumentViewModel(viewModel)), this.disposeWithMe(this.intercept(DOC_INTERCEPTOR_POINT.CUSTOM_RANGE, {
|
|
4431
4471
|
priority: -1,
|
|
4432
4472
|
handler: /* @__PURE__ */ __name((data, pos, next) => next(data), "handler")
|
|
4433
4473
|
}));
|
|
4474
|
+
let disposableCollection = new DisposableCollection();
|
|
4475
|
+
viewModel.segmentViewModels$.subscribe((segmentViewModels) => {
|
|
4476
|
+
disposableCollection.dispose(), disposableCollection = new DisposableCollection(), segmentViewModels.forEach((segmentViewModel) => {
|
|
4477
|
+
disposableCollection.add(this.interceptDocumentViewModel(segmentViewModel));
|
|
4478
|
+
});
|
|
4479
|
+
}), this.disposeWithMe(disposableCollection);
|
|
4434
4480
|
}
|
|
4435
4481
|
intercept(name, interceptor) {
|
|
4436
4482
|
const key = name;
|
|
@@ -4520,7 +4566,6 @@ export {
|
|
|
4520
4566
|
DocTableInsertRowAboveCommand,
|
|
4521
4567
|
DocTableInsertRowBellowCommand,
|
|
4522
4568
|
DocTableInsertRowCommand,
|
|
4523
|
-
DocTableShiftTabCommand,
|
|
4524
4569
|
DocTableTabCommand,
|
|
4525
4570
|
EditorInsertTextCommandId,
|
|
4526
4571
|
EnterCommand,
|
|
@@ -4569,6 +4614,7 @@ export {
|
|
|
4569
4614
|
generateParagraphs,
|
|
4570
4615
|
getCommandSkeleton,
|
|
4571
4616
|
getCursorWhenDelete,
|
|
4617
|
+
getCustomRangesInterestsWithRange,
|
|
4572
4618
|
getDeleteSelection,
|
|
4573
4619
|
getDocObject,
|
|
4574
4620
|
getDocObjectById,
|
|
@@ -4577,11 +4623,13 @@ export {
|
|
|
4577
4623
|
getInsertSelection,
|
|
4578
4624
|
getParagraphsInRange$1 as getParagraphsInRange,
|
|
4579
4625
|
getParagraphsInRanges,
|
|
4626
|
+
getPlainTextFormBody,
|
|
4580
4627
|
getPlainTextFormDocument,
|
|
4581
4628
|
getRetainAndDeleteFromReplace,
|
|
4582
4629
|
getRichTextEditPath,
|
|
4583
4630
|
getSelectionText,
|
|
4584
4631
|
getTableColumn,
|
|
4632
|
+
hasParagraphInTable,
|
|
4585
4633
|
isSegmentIntersects,
|
|
4586
4634
|
makeSelection,
|
|
4587
4635
|
neoGetDocObject,
|