@univerjs/docs-ui 0.4.0-alpha.1 → 0.4.0-experimental.20241017-da434a2
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 +5 -5
- package/lib/es/index.js +107 -270
- package/lib/types/commands/commands/list.command.d.ts +1 -1
- package/lib/types/components/range-selector/RangeSelector.d.ts +3 -0
- package/lib/types/controllers/render-controllers/doc-selection-render.controller.d.ts +2 -2
- package/lib/types/services/doc-page-layout.service.d.ts +1 -1
- package/lib/umd/index.js +5 -5
- package/package.json +8 -8
- package/LICENSE +0 -176
package/lib/es/index.js
CHANGED
|
@@ -9,9 +9,9 @@ import * as require$$0 from "react";
|
|
|
9
9
|
import require$$0__default, { useState, useRef, useEffect, forwardRef, createElement, useMemo, useCallback } from "react";
|
|
10
10
|
import { LexerTreeBuilder, operatorToken, isReferenceStrings, serializeRange, serializeRangeWithSheet, serializeRangeWithSpreadsheet, isReferenceStringWithEffectiveColumn, getRangeWithRefsString } from "@univerjs/engine-formula";
|
|
11
11
|
import { Subject, BehaviorSubject, takeUntil, fromEvent, merge, combineLatest, Observable, map as map$1, distinctUntilChanged, filter as filter$1, throttleTime, mergeMap, take, animationFrameScheduler } from "rxjs";
|
|
12
|
-
import { ILayoutService, useEvent, ComponentManager, ISidebarService,
|
|
13
|
-
import { Tooltip, Dialog, Button, Input, Checkbox, InputNumber, Slider, Select, ColorPicker } from "@univerjs/design";
|
|
12
|
+
import { ILayoutService, KeyCode, useEvent, ComponentManager, ISidebarService, MetaKeys, IClipboardInterfaceService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, HTML_CLIPBOARD_MIME_TYPE, CopyCommand, CutCommand, PasteCommand, IConfirmService, MenuItemType, getMenuHiddenObservable, FONT_FAMILY_LIST, FONT_SIZE_LIST, getHeaderFooterMenuHiddenObservable, RibbonStartGroup, ContextMenuPosition, ContextMenuGroup, FontFamily, FontFamilyItem, FontSize, BuiltInUIPart, IMenuManagerService, IUIPartsService, IShortcutService, ICanvasPopupService, IContextMenuService, SetEditorResizeOperation } from "@univerjs/ui";
|
|
14
13
|
import { filter, bufferTime, map } from "rxjs/operators";
|
|
14
|
+
import { Tooltip, Dialog, Button, Input, Checkbox, InputNumber, Slider, Select, ColorPicker } from "@univerjs/design";
|
|
15
15
|
var __defProp$r = Object.defineProperty, __getOwnPropDesc$r = Object.getOwnPropertyDescriptor, __decorateClass$r = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
16
16
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$r(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
17
17
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -1691,6 +1691,7 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
1691
1691
|
_setRangeStyle(style = NORMAL_TEXT_SELECTION_PLUGIN_STYLE) {
|
|
1692
1692
|
this._selectionStyle = style;
|
|
1693
1693
|
}
|
|
1694
|
+
// eslint-disable-next-line max-lines-per-function
|
|
1694
1695
|
addDocRanges(ranges, isEditing = !0, options) {
|
|
1695
1696
|
const {
|
|
1696
1697
|
_currentSegmentId: segmentId,
|
|
@@ -1712,19 +1713,28 @@ let DocSelectionRenderService = (_a2 = class extends RxDisposable {
|
|
|
1712
1713
|
);
|
|
1713
1714
|
rectRange && this._addRectRanges([rectRange]);
|
|
1714
1715
|
} else if (rangeType === DOC_RANGE_TYPE.TEXT) {
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1716
|
+
let textRange = null;
|
|
1717
|
+
startNodePosition && endNodePosition ? textRange = getTextRangeFromCharIndex(
|
|
1718
|
+
startNodePosition.isBack ? startOffset : startOffset - 1,
|
|
1719
|
+
endNodePosition.isBack ? endOffset : endOffset - 1,
|
|
1718
1720
|
scene,
|
|
1719
1721
|
document2,
|
|
1720
1722
|
docSkeleton,
|
|
1721
1723
|
style,
|
|
1722
1724
|
segmentId,
|
|
1723
1725
|
segmentPage,
|
|
1724
|
-
startNodePosition
|
|
1725
|
-
endNodePosition
|
|
1726
|
-
)
|
|
1727
|
-
|
|
1726
|
+
startNodePosition.isBack,
|
|
1727
|
+
endNodePosition.isBack
|
|
1728
|
+
) : textRange = getTextRangeFromCharIndex(
|
|
1729
|
+
startOffset,
|
|
1730
|
+
endOffset,
|
|
1731
|
+
scene,
|
|
1732
|
+
document2,
|
|
1733
|
+
docSkeleton,
|
|
1734
|
+
style,
|
|
1735
|
+
segmentId,
|
|
1736
|
+
segmentPage
|
|
1737
|
+
), textRange && this._addTextRange(textRange);
|
|
1728
1738
|
} else {
|
|
1729
1739
|
const rangeList = getRangeListFromCharIndex(
|
|
1730
1740
|
startOffset,
|
|
@@ -2345,7 +2355,10 @@ const _Editor = class _Editor extends Disposable {
|
|
|
2345
2355
|
), this.disposeWithMe(
|
|
2346
2356
|
merge(
|
|
2347
2357
|
docSelectionRenderService.onInput$,
|
|
2348
|
-
docSelectionRenderService.onKeydown
|
|
2358
|
+
docSelectionRenderService.onKeydown$.pipe(filter((e) => {
|
|
2359
|
+
const event = e.event;
|
|
2360
|
+
return event.ctrlKey || event.metaKey ? [KeyCode.X, KeyCode.V].includes(event.keyCode) : [KeyCode.BACKSPACE].includes(event.keyCode);
|
|
2361
|
+
})),
|
|
2349
2362
|
docSelectionRenderService.onCompositionupdate$,
|
|
2350
2363
|
docSelectionRenderService.onCompositionend$,
|
|
2351
2364
|
docSelectionRenderService.onPaste$
|
|
@@ -2688,7 +2701,7 @@ let EditorService = (_b = class extends Disposable {
|
|
|
2688
2701
|
const editor = this.getEditor(editorUnitId);
|
|
2689
2702
|
if (!editor)
|
|
2690
2703
|
return !1;
|
|
2691
|
-
editor.setFocus(!0), this._contextService.setContextValue(EDITOR_ACTIVATED, !0), this._contextService.setContextValue(FOCUSING_EDITOR_STANDALONE, !0), this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, editor.isSingle()), this._spreadsheetFocusState || this.singleSelection(editor.isSingleChoice()), this._focusStyle$.next(editorUnitId), this.setFocusId(editorUnitId);
|
|
2704
|
+
editor.setFocus(!0), this._contextService.setContextValue(EDITOR_ACTIVATED, !0), this._contextService.setContextValue(FOCUSING_EDITOR_STANDALONE, !0), this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, editor.isSingle()), this._spreadsheetFocusState || this.singleSelection(!!editor.isSingleChoice()), this._focusStyle$.next(editorUnitId), this.setFocusId(editorUnitId);
|
|
2692
2705
|
}
|
|
2693
2706
|
/** @deprecated */
|
|
2694
2707
|
singleSelection(state) {
|
|
@@ -4334,145 +4347,60 @@ __name(getReverseFormatValueInSelection, "getReverseFormatValueInSelection");
|
|
|
4334
4347
|
const ListOperationCommand = {
|
|
4335
4348
|
id: "doc.command.list-operation",
|
|
4336
4349
|
type: CommandType.COMMAND,
|
|
4337
|
-
// eslint-disable-next-line max-lines-per-function, complexity
|
|
4338
4350
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4339
|
-
var _a28, _b2
|
|
4340
|
-
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService);
|
|
4341
|
-
let listType = params.listType;
|
|
4342
|
-
const docDataModel = univerInstanceService.getCurrentUniverDocInstance(), docRanges = (_a28 = docSelectionManagerService.getDocRanges()) != null ? _a28 : [];
|
|
4351
|
+
var _a28, _b2;
|
|
4352
|
+
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), listType = params.listType, docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), docRanges = (_a28 = docSelectionManagerService.getDocRanges()) != null ? _a28 : [];
|
|
4343
4353
|
if (docDataModel == null || docRanges.length === 0)
|
|
4344
4354
|
return !1;
|
|
4345
4355
|
const segmentId = docRanges[0].segmentId, paragraphs = (_b2 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _b2.paragraphs;
|
|
4346
4356
|
if (paragraphs == null)
|
|
4347
4357
|
return !1;
|
|
4348
|
-
const
|
|
4349
|
-
var _a29;
|
|
4350
|
-
return ((_a29 = paragraph.bullet) == null ? void 0 : _a29.listType.indexOf(listType)) === 0;
|
|
4351
|
-
});
|
|
4352
|
-
let listId = Tools.generateRandomId(6);
|
|
4353
|
-
if (currentParagraphs.length === 1) {
|
|
4354
|
-
const curIndex = paragraphs.indexOf(currentParagraphs[0]), prevParagraph = paragraphs[curIndex - 1], nextParagraph = paragraphs[curIndex + 1];
|
|
4355
|
-
prevParagraph && prevParagraph.bullet && prevParagraph.bullet.listType.indexOf(listType) === 0 ? (listId = prevParagraph.bullet.listId, listType !== PresetListType.CHECK_LIST && (listType = prevParagraph.bullet.listType)) : nextParagraph && nextParagraph.bullet && nextParagraph.bullet.listType.indexOf(listType) === 0 && (listId = nextParagraph.bullet.listId, listType !== PresetListType.CHECK_LIST && (listType = nextParagraph.bullet.listType));
|
|
4356
|
-
}
|
|
4357
|
-
const doMutation = {
|
|
4358
|
+
const currentParagraphs = getParagraphsInRanges(docRanges, paragraphs), unitId = docDataModel.getUnitId(), doMutation = {
|
|
4358
4359
|
id: RichTextEditingMutation.id,
|
|
4359
4360
|
params: {
|
|
4360
4361
|
unitId,
|
|
4361
4362
|
actions: [],
|
|
4362
|
-
textRanges: docRanges
|
|
4363
|
+
textRanges: docRanges,
|
|
4364
|
+
isEditing: !1
|
|
4363
4365
|
}
|
|
4364
|
-
}
|
|
4365
|
-
|
|
4366
|
-
const textX =
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
lists[listType].nestingLevel[0].paragraphProperties;
|
|
4373
|
-
const { charSpace, gridType } = findNearestSectionBreak(startIndex, sectionBreaks) || { charSpace: 0, gridType: GridType.LINES };
|
|
4374
|
-
getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid), textX.push({
|
|
4375
|
-
t: TextXActionType.RETAIN,
|
|
4376
|
-
len: startIndex - memoryCursor.cursor,
|
|
4377
|
-
segmentId
|
|
4378
|
-
}), textX.push({
|
|
4379
|
-
t: TextXActionType.RETAIN,
|
|
4380
|
-
len: 1,
|
|
4381
|
-
body: {
|
|
4382
|
-
dataStream: "",
|
|
4383
|
-
paragraphs: [
|
|
4384
|
-
isAlreadyList ? {
|
|
4385
|
-
paragraphStyle: {
|
|
4386
|
-
...paragraphStyle
|
|
4387
|
-
// hanging: undefined,
|
|
4388
|
-
// indentStart: indentStart ? { v: Math.max(0, getNumberUnitValue(indentStart, charSpaceApply) + getNumberUnitValue(listHanging, charSpaceApply) - getNumberUnitValue(listIndentStart, charSpaceApply)) } : undefined,
|
|
4389
|
-
},
|
|
4390
|
-
startIndex: 0
|
|
4391
|
-
} : {
|
|
4392
|
-
startIndex: 0,
|
|
4393
|
-
paragraphStyle: {
|
|
4394
|
-
...paragraphStyle
|
|
4395
|
-
// indentFirstLine: undefined,
|
|
4396
|
-
// hanging: listHanging,
|
|
4397
|
-
// indentStart: { v: getNumberUnitValue(listIndentStart, charSpaceApply) - getNumberUnitValue(listHanging, charSpaceApply) + getNumberUnitValue(indentFirstLine, charSpaceApply) + getNumberUnitValue(indentStart, charSpaceApply) },
|
|
4398
|
-
},
|
|
4399
|
-
bullet: {
|
|
4400
|
-
nestingLevel: (_f = bullet == null ? void 0 : bullet.nestingLevel) != null ? _f : 0,
|
|
4401
|
-
textStyle: {
|
|
4402
|
-
fs: 20
|
|
4403
|
-
},
|
|
4404
|
-
listType,
|
|
4405
|
-
listId
|
|
4406
|
-
}
|
|
4407
|
-
}
|
|
4408
|
-
]
|
|
4409
|
-
},
|
|
4410
|
-
segmentId,
|
|
4411
|
-
coverType: UpdateDocsAttributeType.REPLACE
|
|
4412
|
-
}), memoryCursor.moveCursorTo(startIndex + 1);
|
|
4413
|
-
}
|
|
4414
|
-
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
4366
|
+
};
|
|
4367
|
+
new MemoryCursor().reset();
|
|
4368
|
+
const textX = BuildTextUtils.paragraph.bullet.switch({
|
|
4369
|
+
paragraphs: currentParagraphs,
|
|
4370
|
+
listType,
|
|
4371
|
+
document: docDataModel,
|
|
4372
|
+
segmentId
|
|
4373
|
+
}), jsonX = JSONX.getInstance(), path = getRichTextEditPath(docDataModel, segmentId);
|
|
4415
4374
|
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
4416
4375
|
}, "handler")
|
|
4417
4376
|
}, ChangeListTypeCommand = {
|
|
4418
4377
|
id: "doc.command.change-list-type",
|
|
4419
4378
|
type: CommandType.COMMAND,
|
|
4420
|
-
// eslint-disable-next-line max-lines-per-function
|
|
4421
4379
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4422
|
-
var _a28, _b2
|
|
4423
|
-
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), { listType } = params, docDataModel = univerInstanceService.
|
|
4380
|
+
var _a28, _b2;
|
|
4381
|
+
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), { listType } = params, docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), activeRanges = docSelectionManagerService.getDocRanges();
|
|
4424
4382
|
if (docDataModel == null || activeRanges == null || !activeRanges.length)
|
|
4425
4383
|
return !1;
|
|
4426
4384
|
const { segmentId } = activeRanges[0], selections = (_a28 = docSelectionManagerService.getDocRanges()) != null ? _a28 : [], paragraphs = (_b2 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _b2.paragraphs;
|
|
4427
4385
|
if (paragraphs == null)
|
|
4428
4386
|
return !1;
|
|
4429
|
-
|
|
4430
|
-
|
|
4387
|
+
const currentParagraphs = getParagraphsInRanges(selections, paragraphs), unitId = docDataModel.getUnitId(), textX = BuildTextUtils.paragraph.bullet.set({
|
|
4388
|
+
paragraphs: currentParagraphs,
|
|
4389
|
+
listType,
|
|
4390
|
+
segmentId,
|
|
4391
|
+
document: docDataModel
|
|
4392
|
+
});
|
|
4393
|
+
if (!textX)
|
|
4394
|
+
return !1;
|
|
4395
|
+
const jsonX = JSONX.getInstance(), doMutation = {
|
|
4431
4396
|
id: RichTextEditingMutation.id,
|
|
4432
4397
|
params: {
|
|
4433
4398
|
unitId,
|
|
4434
4399
|
actions: [],
|
|
4435
|
-
textRanges: selections
|
|
4400
|
+
textRanges: selections,
|
|
4401
|
+
isEditing: !1
|
|
4436
4402
|
}
|
|
4437
|
-
},
|
|
4438
|
-
memoryCursor.reset();
|
|
4439
|
-
const textX = new TextX(), jsonX = JSONX.getInstance();
|
|
4440
|
-
for (const paragraph of currentParagraphs) {
|
|
4441
|
-
const { startIndex, paragraphStyle = {}, bullet } = paragraph;
|
|
4442
|
-
textX.push({
|
|
4443
|
-
t: TextXActionType.RETAIN,
|
|
4444
|
-
len: startIndex - memoryCursor.cursor,
|
|
4445
|
-
segmentId
|
|
4446
|
-
}), textX.push({
|
|
4447
|
-
t: TextXActionType.RETAIN,
|
|
4448
|
-
len: 1,
|
|
4449
|
-
body: {
|
|
4450
|
-
dataStream: "",
|
|
4451
|
-
paragraphs: [
|
|
4452
|
-
{
|
|
4453
|
-
startIndex: 0,
|
|
4454
|
-
paragraphStyle: {
|
|
4455
|
-
...paragraphStyle
|
|
4456
|
-
// indentFirstLine: undefined,
|
|
4457
|
-
// hanging: listHanging,
|
|
4458
|
-
// indentStart: { v: getNumberUnitValue(listIndentStart, charSpaceApply) - getNumberUnitValue(listHanging, charSpaceApply) + getNumberUnitValue(indentFirstLine, charSpaceApply) + getNumberUnitValue(indentStart, charSpaceApply) },
|
|
4459
|
-
},
|
|
4460
|
-
bullet: {
|
|
4461
|
-
nestingLevel: (_e = bullet == null ? void 0 : bullet.nestingLevel) != null ? _e : 0,
|
|
4462
|
-
textStyle: (bullet == null ? void 0 : bullet.listType) === listType ? bullet.textStyle : {
|
|
4463
|
-
fs: 20
|
|
4464
|
-
},
|
|
4465
|
-
listType,
|
|
4466
|
-
listId
|
|
4467
|
-
}
|
|
4468
|
-
}
|
|
4469
|
-
]
|
|
4470
|
-
},
|
|
4471
|
-
segmentId,
|
|
4472
|
-
coverType: UpdateDocsAttributeType.REPLACE
|
|
4473
|
-
}), memoryCursor.moveCursorTo(startIndex + 1);
|
|
4474
|
-
}
|
|
4475
|
-
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
4403
|
+
}, path = getRichTextEditPath(docDataModel, segmentId);
|
|
4476
4404
|
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
4477
4405
|
}, "handler")
|
|
4478
4406
|
};
|
|
@@ -4480,68 +4408,30 @@ var ChangeListNestingLevelType = /* @__PURE__ */ ((ChangeListNestingLevelType2)
|
|
|
4480
4408
|
const ChangeListNestingLevelCommand = {
|
|
4481
4409
|
id: "doc.command.change-list-nesting-level",
|
|
4482
4410
|
type: CommandType.COMMAND,
|
|
4483
|
-
// eslint-disable-next-line max-lines-per-function
|
|
4484
4411
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4485
|
-
var _a28, _b2
|
|
4412
|
+
var _a28, _b2;
|
|
4486
4413
|
if (!params)
|
|
4487
4414
|
return !1;
|
|
4488
|
-
const { type } = params, docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), docDataModel = univerInstanceService.
|
|
4415
|
+
const { type } = params, docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), activeRange = docSelectionManagerService.getActiveTextRange();
|
|
4489
4416
|
if (docDataModel == null || activeRange == null)
|
|
4490
4417
|
return !1;
|
|
4491
|
-
const { segmentId } = activeRange,
|
|
4418
|
+
const { segmentId } = activeRange, selections = (_a28 = docSelectionManagerService.getDocRanges()) != null ? _a28 : [], paragraphs = (_b2 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _b2.paragraphs;
|
|
4492
4419
|
if (paragraphs == null)
|
|
4493
4420
|
return !1;
|
|
4494
|
-
const currentParagraphs = getParagraphsInRange(activeRange, paragraphs), unitId = docDataModel.getUnitId(),
|
|
4421
|
+
const currentParagraphs = getParagraphsInRange(activeRange, paragraphs), unitId = docDataModel.getUnitId(), jsonX = JSONX.getInstance(), textX = BuildTextUtils.paragraph.bullet.changeNestLevel({
|
|
4422
|
+
paragraphs: currentParagraphs,
|
|
4423
|
+
type,
|
|
4424
|
+
segmentId,
|
|
4425
|
+
document: docDataModel
|
|
4426
|
+
}), doMutation = {
|
|
4495
4427
|
id: RichTextEditingMutation.id,
|
|
4496
4428
|
params: {
|
|
4497
4429
|
unitId,
|
|
4498
4430
|
actions: [],
|
|
4499
|
-
textRanges: selections
|
|
4431
|
+
textRanges: selections,
|
|
4432
|
+
isEditing: !1
|
|
4500
4433
|
}
|
|
4501
|
-
},
|
|
4502
|
-
memoryCursor.reset();
|
|
4503
|
-
const textX = new TextX(), jsonX = JSONX.getInstance(), customLists = (_e = docDataModel.getSnapshot().lists) != null ? _e : {}, lists = {
|
|
4504
|
-
...PRESET_LIST_TYPE,
|
|
4505
|
-
...customLists
|
|
4506
|
-
};
|
|
4507
|
-
for (const paragraph of currentParagraphs) {
|
|
4508
|
-
const { startIndex, paragraphStyle = {}, bullet } = paragraph, isInTable = hasParagraphInTable(paragraph, tables);
|
|
4509
|
-
if (textX.push({
|
|
4510
|
-
t: TextXActionType.RETAIN,
|
|
4511
|
-
len: startIndex - memoryCursor.cursor,
|
|
4512
|
-
segmentId
|
|
4513
|
-
}), bullet) {
|
|
4514
|
-
const listType = bullet.listType;
|
|
4515
|
-
let maxLevel = lists[listType].nestingLevel.length - 1;
|
|
4516
|
-
isInTable && (maxLevel = Math.min(maxLevel, 2)), textX.push({
|
|
4517
|
-
t: TextXActionType.RETAIN,
|
|
4518
|
-
len: 1,
|
|
4519
|
-
body: {
|
|
4520
|
-
dataStream: "",
|
|
4521
|
-
paragraphs: [
|
|
4522
|
-
{
|
|
4523
|
-
startIndex: 0,
|
|
4524
|
-
paragraphStyle: {
|
|
4525
|
-
...paragraphStyle
|
|
4526
|
-
},
|
|
4527
|
-
bullet: {
|
|
4528
|
-
...bullet,
|
|
4529
|
-
nestingLevel: Math.max(Math.min(bullet.nestingLevel + type, maxLevel), 0)
|
|
4530
|
-
}
|
|
4531
|
-
}
|
|
4532
|
-
]
|
|
4533
|
-
},
|
|
4534
|
-
segmentId,
|
|
4535
|
-
coverType: UpdateDocsAttributeType.REPLACE
|
|
4536
|
-
});
|
|
4537
|
-
} else
|
|
4538
|
-
textX.push({
|
|
4539
|
-
t: TextXActionType.RETAIN,
|
|
4540
|
-
len: 1
|
|
4541
|
-
});
|
|
4542
|
-
memoryCursor.moveCursorTo(startIndex + 1);
|
|
4543
|
-
}
|
|
4544
|
-
const path = getRichTextEditPath(docDataModel, segmentId);
|
|
4434
|
+
}, path = getRichTextEditPath(docDataModel, segmentId);
|
|
4545
4435
|
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
4546
4436
|
}, "handler")
|
|
4547
4437
|
}, BulletListCommand = {
|
|
@@ -4569,56 +4459,30 @@ const ChangeListNestingLevelCommand = {
|
|
|
4569
4459
|
}, ToggleCheckListCommand = {
|
|
4570
4460
|
id: "doc.command.toggle-check-list",
|
|
4571
4461
|
type: CommandType.COMMAND,
|
|
4572
|
-
// eslint-disable-next-line max-lines-per-function
|
|
4573
4462
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4574
4463
|
var _a28;
|
|
4575
4464
|
if (!params)
|
|
4576
4465
|
return !1;
|
|
4577
|
-
const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), { index, segmentId, textRanges } = params, docDataModel = univerInstanceService.
|
|
4578
|
-
if (docDataModel == null)
|
|
4466
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), { index, segmentId, textRanges } = params, docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
|
|
4467
|
+
if (docDataModel == null || ((_a28 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a28.paragraphs) == null)
|
|
4579
4468
|
return !1;
|
|
4580
|
-
const
|
|
4581
|
-
if (paragraphs == null)
|
|
4582
|
-
return !1;
|
|
4583
|
-
const currentParagraph = paragraphs.find((p2) => p2.startIndex === index), unitId = docDataModel.getUnitId();
|
|
4584
|
-
if (!(currentParagraph != null && currentParagraph.bullet) || currentParagraph.bullet.listType.indexOf(PresetListType.CHECK_LIST) === -1)
|
|
4585
|
-
return !1;
|
|
4586
|
-
const doMutation = {
|
|
4469
|
+
const unitId = docDataModel.getUnitId(), doMutation = {
|
|
4587
4470
|
id: RichTextEditingMutation.id,
|
|
4588
4471
|
params: {
|
|
4589
4472
|
unitId,
|
|
4590
4473
|
actions: [],
|
|
4591
4474
|
textRanges: textRanges != null ? textRanges : [],
|
|
4592
|
-
segmentId
|
|
4475
|
+
segmentId,
|
|
4476
|
+
isEditing: !1
|
|
4593
4477
|
}
|
|
4594
|
-
},
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
textX.push({
|
|
4598
|
-
t: TextXActionType.RETAIN,
|
|
4599
|
-
len: startIndex - memoryCursor.cursor,
|
|
4600
|
-
segmentId
|
|
4601
|
-
}), textX.push({
|
|
4602
|
-
t: TextXActionType.RETAIN,
|
|
4603
|
-
len: 1,
|
|
4604
|
-
body: {
|
|
4605
|
-
dataStream: "",
|
|
4606
|
-
paragraphs: [
|
|
4607
|
-
{
|
|
4608
|
-
...currentParagraph,
|
|
4609
|
-
paragraphStyle,
|
|
4610
|
-
startIndex: 0,
|
|
4611
|
-
bullet: {
|
|
4612
|
-
...currentParagraph.bullet,
|
|
4613
|
-
listType
|
|
4614
|
-
}
|
|
4615
|
-
}
|
|
4616
|
-
]
|
|
4617
|
-
},
|
|
4618
|
-
coverType: UpdateDocsAttributeType.REPLACE,
|
|
4478
|
+
}, textX = BuildTextUtils.paragraph.bullet.toggleChecklist({
|
|
4479
|
+
document: docDataModel,
|
|
4480
|
+
paragraphIndex: index,
|
|
4619
4481
|
segmentId
|
|
4620
|
-
})
|
|
4621
|
-
|
|
4482
|
+
});
|
|
4483
|
+
if (!textX)
|
|
4484
|
+
return !1;
|
|
4485
|
+
const jsonX = JSONX.getInstance(), path = getRichTextEditPath(docDataModel, segmentId);
|
|
4622
4486
|
return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
4623
4487
|
}, "handler")
|
|
4624
4488
|
}, OrderListCommand = {
|
|
@@ -4640,7 +4504,7 @@ const ChangeListNestingLevelCommand = {
|
|
|
4640
4504
|
var _a28, _b2, _c, _d, _e;
|
|
4641
4505
|
if (!params)
|
|
4642
4506
|
return !1;
|
|
4643
|
-
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), docDataModel = univerInstanceService.
|
|
4507
|
+
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), activeRange = docSelectionManagerService.getActiveTextRange();
|
|
4644
4508
|
if (docDataModel == null || activeRange == null)
|
|
4645
4509
|
return !1;
|
|
4646
4510
|
const { segmentId } = activeRange, { listType, paragraph } = params, { paragraphStart, paragraphEnd } = paragraph, textX = new TextX(), jsonX = JSONX.getInstance(), { defaultTabStop = 36 } = docDataModel.getSnapshot().documentStyle, sectionBreaks = (_b2 = (_a28 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a28.sectionBreaks) != null ? _b2 : [], { startIndex, paragraphStyle = {} } = paragraph, { indentFirstLine, snapToGrid, indentStart } = paragraphStyle, paragraphProperties = PRESET_LIST_TYPE[listType].nestingLevel[0].paragraphProperties || {}, { hanging: listHanging, indentStart: listIndentStart } = paragraphProperties, bulletParagraphTextStyle = paragraphProperties.textStyle, { charSpace, gridType } = findNearestSectionBreak(startIndex, sectionBreaks) || { charSpace: 0, gridType: GridType.LINES }, charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
|
|
@@ -4656,7 +4520,8 @@ const ChangeListNestingLevelCommand = {
|
|
|
4656
4520
|
startOffset: paragraphStart,
|
|
4657
4521
|
endOffset: paragraphStart,
|
|
4658
4522
|
collapsed: !0
|
|
4659
|
-
}]
|
|
4523
|
+
}],
|
|
4524
|
+
isEditing: !1
|
|
4660
4525
|
}
|
|
4661
4526
|
};
|
|
4662
4527
|
textX.push({
|
|
@@ -4712,22 +4577,6 @@ function getParagraphsInRange(activeRange, paragraphs) {
|
|
|
4712
4577
|
return results;
|
|
4713
4578
|
}
|
|
4714
4579
|
__name(getParagraphsInRange, "getParagraphsInRange");
|
|
4715
|
-
function getParagraphsRelative(ranges, paragraphs) {
|
|
4716
|
-
const selectionParagraphs = getParagraphsInRanges(ranges, paragraphs), startIndex = paragraphs.indexOf(selectionParagraphs[0]), endIndex = paragraphs.indexOf(selectionParagraphs[selectionParagraphs.length - 1]);
|
|
4717
|
-
if (selectionParagraphs[0].bullet)
|
|
4718
|
-
for (let i = startIndex - 1; i >= 0; i--) {
|
|
4719
|
-
const prevParagraph = paragraphs[i];
|
|
4720
|
-
prevParagraph.bullet && prevParagraph.bullet.listId === selectionParagraphs[0].bullet.listId && selectionParagraphs.unshift(prevParagraph);
|
|
4721
|
-
}
|
|
4722
|
-
const lastParagraph = selectionParagraphs[selectionParagraphs.length - 1];
|
|
4723
|
-
if (lastParagraph.bullet)
|
|
4724
|
-
for (let i = endIndex + 1; i < paragraphs.length; i++) {
|
|
4725
|
-
const nextParagraph = paragraphs[i];
|
|
4726
|
-
nextParagraph.bullet && nextParagraph.bullet.listId === lastParagraph.bullet.listId && selectionParagraphs.push(nextParagraph);
|
|
4727
|
-
}
|
|
4728
|
-
return selectionParagraphs;
|
|
4729
|
-
}
|
|
4730
|
-
__name(getParagraphsRelative, "getParagraphsRelative");
|
|
4731
4580
|
function getParagraphsInRanges(ranges, paragraphs) {
|
|
4732
4581
|
const results = [];
|
|
4733
4582
|
for (const range of ranges) {
|
|
@@ -7191,7 +7040,6 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
|
|
|
7191
7040
|
}, "handler")
|
|
7192
7041
|
}, COMPONENT_DOC_CREATE_TABLE_CONFIRM = "COMPONENT_DOC_CREATE_TABLE_CONFIRM";
|
|
7193
7042
|
function generateParagraphs(dataStream, prevParagraph) {
|
|
7194
|
-
var _a28, _b2;
|
|
7195
7043
|
const paragraphs = [];
|
|
7196
7044
|
for (let i = 0, len = dataStream.length; i < len; i++)
|
|
7197
7045
|
dataStream[i] === DataStreamTreeTokenType.PARAGRAPH && paragraphs.push({
|
|
@@ -7199,9 +7047,7 @@ function generateParagraphs(dataStream, prevParagraph) {
|
|
|
7199
7047
|
});
|
|
7200
7048
|
if (prevParagraph)
|
|
7201
7049
|
for (const paragraph of paragraphs)
|
|
7202
|
-
prevParagraph.bullet && (paragraph.bullet = Tools.deepClone(prevParagraph.bullet)
|
|
7203
|
-
s: BooleanNumber.FALSE
|
|
7204
|
-
}));
|
|
7050
|
+
prevParagraph.bullet && (paragraph.bullet = Tools.deepClone(prevParagraph.bullet)), prevParagraph.paragraphStyle && (paragraph.paragraphStyle = Tools.deepClone(prevParagraph.paragraphStyle));
|
|
7205
7051
|
return paragraphs;
|
|
7206
7052
|
}
|
|
7207
7053
|
__name(generateParagraphs, "generateParagraphs");
|
|
@@ -7209,7 +7055,7 @@ const BreakLineCommand = {
|
|
|
7209
7055
|
id: "doc.command.break-line",
|
|
7210
7056
|
type: CommandType.COMMAND,
|
|
7211
7057
|
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
7212
|
-
var _a28, _b2;
|
|
7058
|
+
var _a28, _b2, _c, _d;
|
|
7213
7059
|
const docSelectionManagerService = accessor.get(DocSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), activeTextRange = docSelectionManagerService.getActiveTextRange(), rectRanges = docSelectionManagerService.getRectRanges();
|
|
7214
7060
|
if (activeTextRange == null)
|
|
7215
7061
|
return !1;
|
|
@@ -7224,39 +7070,30 @@ const BreakLineCommand = {
|
|
|
7224
7070
|
if (!docDataModel || !body)
|
|
7225
7071
|
return !1;
|
|
7226
7072
|
const unitId = docDataModel.getUnitId(), { startOffset, endOffset } = BuildTextUtils.selection.getInsertSelection(activeTextRange, body), prevParagraph = ((_a28 = body.paragraphs) != null ? _a28 : []).find((p2) => p2.startIndex >= startOffset);
|
|
7227
|
-
if (prevParagraph
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
}
|
|
7251
|
-
return await commandService.executeCommand(InsertCommand.id, {
|
|
7252
|
-
unitId,
|
|
7253
|
-
body: {
|
|
7254
|
-
dataStream: DataStreamTreeTokenType.PARAGRAPH,
|
|
7255
|
-
paragraphs: generateParagraphs(DataStreamTreeTokenType.PARAGRAPH, prevParagraph)
|
|
7256
|
-
},
|
|
7257
|
-
range: activeTextRange,
|
|
7258
|
-
segmentId
|
|
7259
|
-
});
|
|
7073
|
+
if (!prevParagraph)
|
|
7074
|
+
return !1;
|
|
7075
|
+
const bodyAfter = normalizeBody(getBodySlice(body, endOffset, prevParagraph.startIndex + 1));
|
|
7076
|
+
bodyAfter.customRanges = (_b2 = bodyAfter.customRanges) == null ? void 0 : _b2.map(BuildTextUtils.customRange.copyCustomRange);
|
|
7077
|
+
const deleteRange = {
|
|
7078
|
+
startOffset,
|
|
7079
|
+
endOffset: prevParagraph.startIndex + 1,
|
|
7080
|
+
collapsed: !1
|
|
7081
|
+
};
|
|
7082
|
+
return ((_d = (_c = bodyAfter.paragraphs) == null ? void 0 : _c[0].bullet) == null ? void 0 : _d.listType) === PresetListType.CHECK_LIST_CHECKED && (bodyAfter.paragraphs[0].bullet.listType = PresetListType.CHECK_LIST), updateAttributeByInsert(
|
|
7083
|
+
bodyAfter,
|
|
7084
|
+
{
|
|
7085
|
+
dataStream: DataStreamTreeTokenType.PARAGRAPH,
|
|
7086
|
+
paragraphs: generateParagraphs(DataStreamTreeTokenType.PARAGRAPH, prevParagraph)
|
|
7087
|
+
},
|
|
7088
|
+
1,
|
|
7089
|
+
0
|
|
7090
|
+
), await commandService.executeCommand(InsertCommand.id, {
|
|
7091
|
+
unitId,
|
|
7092
|
+
body: bodyAfter,
|
|
7093
|
+
range: deleteRange,
|
|
7094
|
+
segmentId,
|
|
7095
|
+
cursorOffset: 1
|
|
7096
|
+
});
|
|
7260
7097
|
}, "handler")
|
|
7261
7098
|
}, CreateDocTableCommandId = "doc.command.create-table", CreateDocTableCommand = {
|
|
7262
7099
|
id: CreateDocTableCommandId,
|
|
@@ -7759,7 +7596,7 @@ const getDisableWhenSelectionNotInTableObservable = /* @__PURE__ */ __name((acce
|
|
|
7759
7596
|
}
|
|
7760
7597
|
subscriber.next(!0);
|
|
7761
7598
|
});
|
|
7762
|
-
return () => observable.unsubscribe();
|
|
7599
|
+
return subscriber.next(!0), () => observable.unsubscribe();
|
|
7763
7600
|
});
|
|
7764
7601
|
}, "getDisableWhenSelectionNotInTableObservable"), CopyMenuFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
7765
7602
|
id: DocCopyCommand.name,
|
|
@@ -8792,7 +8629,7 @@ let DocBackScrollRenderController = (_a7 = class extends RxDisposable {
|
|
|
8792
8629
|
if (!skeleton)
|
|
8793
8630
|
return;
|
|
8794
8631
|
const { startOffset } = range, anchorNodePosition = skeleton.findNodePositionByCharIndex(startOffset);
|
|
8795
|
-
this.scrollToNode(anchorNodePosition);
|
|
8632
|
+
anchorNodePosition && this.scrollToNode(anchorNodePosition);
|
|
8796
8633
|
}
|
|
8797
8634
|
scrollToNode(startNodePosition) {
|
|
8798
8635
|
var _a28;
|
|
@@ -10589,7 +10426,7 @@ const _DocPageLayoutService = class _DocPageLayoutService extends Disposable {
|
|
|
10589
10426
|
return;
|
|
10590
10427
|
const { width: engineWidth, height: engineHeight } = parent;
|
|
10591
10428
|
let docsLeft = 0, docsTop = 0, sceneWidth = 0, sceneHeight = 0, scrollToX = Number.POSITIVE_INFINITY;
|
|
10592
|
-
engineWidth > (docsWidth + pageMarginLeft * 2) * zoomRatio ? (docsLeft = engineWidth / 2 - docsWidth * zoomRatio / 2, docsLeft /= zoomRatio, sceneWidth = (engineWidth - pageMarginLeft * 2) / zoomRatio, scrollToX = 0) : (docsLeft = pageMarginLeft, sceneWidth = docsWidth + pageMarginLeft * 2, scrollToX = (sceneWidth - engineWidth / zoomRatio) / 2), engineHeight > docsHeight ? (docsTop = engineHeight / 2 - docsHeight / 2, sceneHeight = (engineHeight - pageMarginTop * 2) / zoomRatio) : (docsTop = pageMarginTop, sceneHeight = docsHeight + pageMarginTop * 2), scene.resize(sceneWidth, sceneHeight + 200), engineWidth <= 1 && (docsLeft =
|
|
10429
|
+
engineWidth > (docsWidth + pageMarginLeft * 2) * zoomRatio ? (docsLeft = engineWidth / 2 - docsWidth * zoomRatio / 2, docsLeft /= zoomRatio, sceneWidth = (engineWidth - pageMarginLeft * 2) / zoomRatio, scrollToX = 0) : (docsLeft = pageMarginLeft, sceneWidth = docsWidth + pageMarginLeft * 2, scrollToX = (sceneWidth - engineWidth / zoomRatio) / 2), engineHeight > docsHeight ? (docsTop = engineHeight / 2 - docsHeight / 2, sceneHeight = (engineHeight - pageMarginTop * 2) / zoomRatio) : (docsTop = pageMarginTop, sceneHeight = docsHeight + pageMarginTop * 2), scene.resize(sceneWidth, sceneHeight + 200), engineWidth <= 1 && (docsLeft = -1e4, docsTop = -1e4), docsComponent.translate(docsLeft, docsTop), docBackground.translate(docsLeft, docsTop);
|
|
10593
10430
|
const viewport = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
|
|
10594
10431
|
return scrollToX !== Number.POSITIVE_INFINITY && viewport != null && viewport.scrollToViewportPos({
|
|
10595
10432
|
viewportScrollX: scrollToX
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ICommand, IParagraph, IParagraphRange, ISectionBreak, PresetListType } from '@univerjs/core';
|
|
2
2
|
import { ITextRangeWithStyle } from '@univerjs/engine-render';
|
|
3
3
|
interface IListOperationCommandParams {
|
|
4
4
|
listType: PresetListType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Disposable, ICommandService, IUniverInstanceService
|
|
2
|
-
import { DocSelectionManagerService, DocSkeletonManagerService } from '@univerjs/docs';
|
|
1
|
+
import { DocumentDataModel, Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
|
|
3
2
|
import { IRenderContext, IRenderModule } from '@univerjs/engine-render';
|
|
3
|
+
import { DocSelectionManagerService, DocSkeletonManagerService } from '@univerjs/docs';
|
|
4
4
|
import { IEditorService } from '../../services/editor/editor-manager.service';
|
|
5
5
|
import { DocSelectionRenderService } from '../../services/selection/doc-selection-render.service';
|
|
6
6
|
export declare class DocSelectionRenderController extends Disposable implements IRenderModule {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DocumentDataModel, Disposable } from '@univerjs/core';
|
|
2
2
|
import { IRenderContext, IRenderModule } from '@univerjs/engine-render';
|
|
3
3
|
export declare class DocPageLayoutService extends Disposable implements IRenderModule {
|
|
4
4
|
private _context;
|