@univerjs/docs-ui 1.0.0-alpha.1 → 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/cjs/index.js +920 -883
- package/lib/es/index.js +919 -884
- package/lib/index.js +919 -884
- package/lib/types/commands/commands/doc-delete.command.d.ts +6 -2
- package/lib/types/commands/commands/doc-header-footer.command.d.ts +3 -9
- package/lib/types/commands/commands/table/doc-table-create.command.d.ts +2 -1
- package/lib/types/controllers/doc-header-footer.controller.d.ts +0 -8
- package/lib/types/index.d.ts +3 -3
- package/lib/types/menu/menu.d.ts +1 -0
- package/lib/types/services/doc-paragraph-menu.service.d.ts +1 -1
- package/lib/types/services/index.d.ts +1 -0
- package/lib/types/shortcuts/core-editing.shortcut.d.ts +1 -0
- package/lib/types/views/ParagraphMenu.d.ts +1 -0
- package/lib/types/views/paragraph-setting/line-spacing.d.ts +2 -14
- package/lib/umd/index.js +9 -10
- package/package.json +11 -11
package/lib/cjs/index.js
CHANGED
|
@@ -315,20 +315,20 @@ let DocAutoFormatService = class DocAutoFormatService extends _univerjs_core.Dis
|
|
|
315
315
|
});
|
|
316
316
|
}
|
|
317
317
|
onAutoFormat(id, params) {
|
|
318
|
-
var _this$_matches$get, _docRanges$find;
|
|
318
|
+
var _this$_matches$get, _docRanges$find, _selection$segmentId;
|
|
319
319
|
const autoFormats = (_this$_matches$get = this._matches.get(id)) !== null && _this$_matches$get !== void 0 ? _this$_matches$get : [];
|
|
320
320
|
const unit = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
321
321
|
const docRanges = this._textSelectionManagerService.getDocRanges();
|
|
322
322
|
const selection = (_docRanges$find = docRanges.find((range) => range.isActive)) !== null && _docRanges$find !== void 0 ? _docRanges$find : docRanges[0];
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
323
|
+
const documentDataModel = unit === null || unit === void 0 ? void 0 : unit.getSelfOrHeaderFooterModel((_selection$segmentId = selection === null || selection === void 0 ? void 0 : selection.segmentId) !== null && _selection$segmentId !== void 0 ? _selection$segmentId : "");
|
|
324
|
+
if (unit && selection && documentDataModel) {
|
|
325
|
+
var _documentDataModel$ge, _documentDataModel$ge2, _documentDataModel$ge3, _documentDataModel$ge4, _documentDataModel$ge5, _documentDataModel$ge6, _matched$getMutations;
|
|
326
326
|
const context = {
|
|
327
|
-
unit:
|
|
327
|
+
unit: documentDataModel,
|
|
328
328
|
selection,
|
|
329
329
|
isBody: !selection.segmentId,
|
|
330
|
-
paragraphs: _univerjs_core.BuildTextUtils.range.getParagraphsInRange(selection, (
|
|
331
|
-
customRanges: _univerjs_core.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (
|
|
330
|
+
paragraphs: _univerjs_core.BuildTextUtils.range.getParagraphsInRange(selection, (_documentDataModel$ge = (_documentDataModel$ge2 = documentDataModel.getBody()) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.paragraphs) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : [], (_documentDataModel$ge3 = (_documentDataModel$ge4 = documentDataModel.getBody()) === null || _documentDataModel$ge4 === void 0 ? void 0 : _documentDataModel$ge4.dataStream) !== null && _documentDataModel$ge3 !== void 0 ? _documentDataModel$ge3 : ""),
|
|
331
|
+
customRanges: _univerjs_core.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection, (_documentDataModel$ge5 = (_documentDataModel$ge6 = documentDataModel.getBody()) === null || _documentDataModel$ge6 === void 0 ? void 0 : _documentDataModel$ge6.customRanges) !== null && _documentDataModel$ge5 !== void 0 ? _documentDataModel$ge5 : []),
|
|
332
332
|
commandId: id,
|
|
333
333
|
commandParams: params
|
|
334
334
|
};
|
|
@@ -460,7 +460,7 @@ const BreakLineCommand = {
|
|
|
460
460
|
id: "doc.command.break-line",
|
|
461
461
|
type: _univerjs_core.CommandType.COMMAND,
|
|
462
462
|
handler: (accessor, params) => {
|
|
463
|
-
var _params$textRange, _originBody$paragraph, _prevParagraph$bullet, _prevParagraph$paragr;
|
|
463
|
+
var _params$textRange, _docDataModel$getSelf, _originBody$paragraph, _prevParagraph$bullet, _prevParagraph$paragr;
|
|
464
464
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
465
465
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
466
466
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
@@ -479,7 +479,7 @@ const BreakLineCommand = {
|
|
|
479
479
|
const { horizontalLine } = params !== null && params !== void 0 ? params : {};
|
|
480
480
|
const { segmentId } = activeTextRange;
|
|
481
481
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
482
|
-
const originBody = docDataModel === null || docDataModel === void 0
|
|
482
|
+
const originBody = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId !== null && segmentId !== void 0 ? segmentId : "")) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
483
483
|
if (docDataModel == null || originBody == null) return false;
|
|
484
484
|
const unitId = docDataModel.getUnitId();
|
|
485
485
|
const { startOffset, endOffset } = activeTextRange;
|
|
@@ -1099,7 +1099,7 @@ const InnerPasteCommand = {
|
|
|
1099
1099
|
id: "doc.command.inner-paste",
|
|
1100
1100
|
type: _univerjs_core.CommandType.COMMAND,
|
|
1101
1101
|
handler: async (accessor, params) => {
|
|
1102
|
-
var _body$tables, _body$customBlocks;
|
|
1102
|
+
var _docDataModel$getSelf, _body$tables, _body$customBlocks;
|
|
1103
1103
|
const { segmentId, textRanges, doc } = params;
|
|
1104
1104
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
1105
1105
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
@@ -1108,8 +1108,8 @@ const InnerPasteCommand = {
|
|
|
1108
1108
|
const rectRanges = docSelectionManagerService.getRectRanges();
|
|
1109
1109
|
const { body, tableSource, drawings } = doc;
|
|
1110
1110
|
if (!Array.isArray(selections) || selections.length === 0 || body == null) return false;
|
|
1111
|
-
const docDataModel = univerInstanceService.
|
|
1112
|
-
const originBody = docDataModel === null || docDataModel === void 0
|
|
1111
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
1112
|
+
const originBody = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
1113
1113
|
if (docDataModel == null || originBody == null) return false;
|
|
1114
1114
|
const unitId = docDataModel.getUnitId();
|
|
1115
1115
|
const doMutation = {
|
|
@@ -1210,8 +1210,8 @@ function adjustSelectionByTable(selection, tables) {
|
|
|
1210
1210
|
};
|
|
1211
1211
|
}
|
|
1212
1212
|
function getCutActionsFromTextRanges(selections, docDataModel, segmentId) {
|
|
1213
|
-
var _docDataModel$getDraw, _docDataModel$getDraw2;
|
|
1214
|
-
const originBody = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
1213
|
+
var _docDataModel$getSelf2, _docDataModel$getDraw, _docDataModel$getDraw2;
|
|
1214
|
+
const originBody = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.getBody();
|
|
1215
1215
|
const textX = new _univerjs_core.TextX();
|
|
1216
1216
|
const jsonX = _univerjs_core.JSONX.getInstance();
|
|
1217
1217
|
const rawActions = [];
|
|
@@ -1255,8 +1255,9 @@ function getCutActionsFromTextRanges(selections, docDataModel, segmentId) {
|
|
|
1255
1255
|
}, null);
|
|
1256
1256
|
}
|
|
1257
1257
|
function getCutActionsFromRectRanges(ranges, docDataModel, viewModel, segmentId) {
|
|
1258
|
+
var _docDataModel$getSelf3;
|
|
1258
1259
|
const rawActions = [];
|
|
1259
|
-
if (docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody() == null) return rawActions;
|
|
1260
|
+
if (((_docDataModel$getSelf3 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf3 === void 0 ? void 0 : _docDataModel$getSelf3.getBody()) == null) return rawActions;
|
|
1260
1261
|
const textX = new _univerjs_core.TextX();
|
|
1261
1262
|
const jsonX = _univerjs_core.JSONX.getInstance();
|
|
1262
1263
|
const memoryCursor = new _univerjs_core.MemoryCursor();
|
|
@@ -1351,16 +1352,14 @@ const CutContentCommand = {
|
|
|
1351
1352
|
id: "doc.command.inner-cut",
|
|
1352
1353
|
type: _univerjs_core.CommandType.COMMAND,
|
|
1353
1354
|
handler: (accessor, params) => {
|
|
1354
|
-
var _univerInstanceServic;
|
|
1355
1355
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
1356
1356
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
1357
1357
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
1358
1358
|
const { segmentId, textRanges, selections = docSelectionManagerService.getTextRanges(), rectRanges = docSelectionManagerService.getRectRanges() } = params;
|
|
1359
1359
|
if ((!Array.isArray(selections) || selections.length === 0) && (!Array.isArray(rectRanges) || rectRanges.length === 0)) return false;
|
|
1360
|
-
const
|
|
1361
|
-
if (!unitId) return false;
|
|
1362
|
-
const docDataModel = univerInstanceService.getUniverDocInstance(unitId);
|
|
1360
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
1363
1361
|
if (docDataModel == null) return false;
|
|
1362
|
+
const unitId = docDataModel.getUnitId();
|
|
1364
1363
|
const docSkeletonManagerService = getCommandSkeleton(accessor, unitId);
|
|
1365
1364
|
if (docSkeletonManagerService == null) return false;
|
|
1366
1365
|
const viewModel = docSkeletonManagerService.getViewModel();
|
|
@@ -1399,10 +1398,10 @@ const DeleteCustomBlockCommand = {
|
|
|
1399
1398
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
1400
1399
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
1401
1400
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
1401
|
+
const { direction, range, unitId, drawingId } = params;
|
|
1402
1402
|
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
1403
|
-
const documentDataModel = univerInstanceService.
|
|
1403
|
+
const documentDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
1404
1404
|
if (activeRange == null || documentDataModel == null) return false;
|
|
1405
|
-
const { direction, range, unitId, drawingId } = params;
|
|
1406
1405
|
const { startOffset, segmentId, style } = activeRange;
|
|
1407
1406
|
const cursor = direction === _univerjs_core.DeleteDirection.LEFT ? startOffset - 1 : startOffset;
|
|
1408
1407
|
const textRanges = [{
|
|
@@ -1449,6 +1448,7 @@ const MergeTwoParagraphCommand = {
|
|
|
1449
1448
|
id: "doc.command.merge-two-paragraph",
|
|
1450
1449
|
type: _univerjs_core.CommandType.COMMAND,
|
|
1451
1450
|
handler: async (accessor, params) => {
|
|
1451
|
+
var _docDataModel$getSelf;
|
|
1452
1452
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
1453
1453
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
1454
1454
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
@@ -1458,7 +1458,7 @@ const MergeTwoParagraphCommand = {
|
|
|
1458
1458
|
if (activeRange == null || ranges == null) return false;
|
|
1459
1459
|
const { segmentId, style } = activeRange;
|
|
1460
1460
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
1461
|
-
const originBody = docDataModel === null || docDataModel === void 0
|
|
1461
|
+
const originBody = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
1462
1462
|
if (docDataModel == null || originBody == null) return false;
|
|
1463
1463
|
const dataStream = originBody.dataStream;
|
|
1464
1464
|
const actualRange = activeRange;
|
|
@@ -1529,7 +1529,7 @@ const RemoveHorizontalLineCommand = {
|
|
|
1529
1529
|
id: "doc.command.remove-horizontal-line",
|
|
1530
1530
|
type: _univerjs_core.CommandType.COMMAND,
|
|
1531
1531
|
handler: async (accessor) => {
|
|
1532
|
-
var _originBody$paragraph;
|
|
1532
|
+
var _docDataModel$getSelf2, _originBody$paragraph;
|
|
1533
1533
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
1534
1534
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
1535
1535
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
@@ -1538,7 +1538,7 @@ const RemoveHorizontalLineCommand = {
|
|
|
1538
1538
|
if (activeRange == null || ranges == null) return false;
|
|
1539
1539
|
const { segmentId, style } = activeRange;
|
|
1540
1540
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
1541
|
-
const originBody = docDataModel === null || docDataModel === void 0
|
|
1541
|
+
const originBody = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.getBody();
|
|
1542
1542
|
if (docDataModel == null || originBody == null) return false;
|
|
1543
1543
|
const actualRange = activeRange;
|
|
1544
1544
|
const unitId = docDataModel.getUnitId();
|
|
@@ -1628,11 +1628,12 @@ const DeleteLeftCommand = {
|
|
|
1628
1628
|
id: "doc.command.delete-left",
|
|
1629
1629
|
type: _univerjs_core.CommandType.COMMAND,
|
|
1630
1630
|
handler: async (accessor) => {
|
|
1631
|
+
var _docDataModel$getSelf3;
|
|
1631
1632
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
1632
1633
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
1633
1634
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
1634
1635
|
let result = true;
|
|
1635
|
-
const docDataModel = univerInstanceService.
|
|
1636
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
1636
1637
|
if (docDataModel == null) return false;
|
|
1637
1638
|
const docSkeletonManagerService = getCommandSkeleton(accessor, docDataModel.getUnitId());
|
|
1638
1639
|
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
@@ -1656,7 +1657,7 @@ const DeleteLeftCommand = {
|
|
|
1656
1657
|
const autoFormatResult = await executeDeleteAutoFormat(accessor, DeleteLeftCommand.id);
|
|
1657
1658
|
if (autoFormatResult != null) return autoFormatResult;
|
|
1658
1659
|
const { segmentId, style, segmentPage } = activeRange;
|
|
1659
|
-
const body = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
1660
|
+
const body = (_docDataModel$getSelf3 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf3 === void 0 ? void 0 : _docDataModel$getSelf3.getBody();
|
|
1660
1661
|
if (body == null) return false;
|
|
1661
1662
|
const actualRange = activeRange;
|
|
1662
1663
|
const { startOffset, collapsed } = actualRange;
|
|
@@ -1782,8 +1783,9 @@ const DeleteRightCommand = {
|
|
|
1782
1783
|
id: "doc.command.delete-right",
|
|
1783
1784
|
type: _univerjs_core.CommandType.COMMAND,
|
|
1784
1785
|
handler: async (accessor) => {
|
|
1786
|
+
var _docDataModel$getSelf4;
|
|
1785
1787
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
1786
|
-
const docDataModel = accessor.get(_univerjs_core.IUniverInstanceService).
|
|
1788
|
+
const docDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
1787
1789
|
if (!docDataModel) return false;
|
|
1788
1790
|
const docSkeletonManagerService = getCommandSkeleton(accessor, docDataModel.getUnitId());
|
|
1789
1791
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
@@ -1807,7 +1809,7 @@ const DeleteRightCommand = {
|
|
|
1807
1809
|
const autoFormatResult = await executeDeleteAutoFormat(accessor, DeleteRightCommand.id);
|
|
1808
1810
|
if (autoFormatResult != null) return autoFormatResult;
|
|
1809
1811
|
const { segmentId, style, segmentPage } = activeRange;
|
|
1810
|
-
const body = docDataModel === null || docDataModel === void 0
|
|
1812
|
+
const body = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf4 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf4 === void 0 ? void 0 : _docDataModel$getSelf4.getBody();
|
|
1811
1813
|
if (!docDataModel || !body) return false;
|
|
1812
1814
|
const actualRange = activeRange;
|
|
1813
1815
|
const { startOffset, endOffset, collapsed } = actualRange;
|
|
@@ -1930,6 +1932,9 @@ function resetEmptyCenteredParagraphAlignment(commandService, docDataModel, segm
|
|
|
1930
1932
|
}
|
|
1931
1933
|
const DeleteCurrentParagraphCommand = {
|
|
1932
1934
|
id: "doc.command.delete-current-paragraph",
|
|
1935
|
+
name: "doc.command.delete-current-paragraph",
|
|
1936
|
+
multi: true,
|
|
1937
|
+
priority: 0,
|
|
1933
1938
|
type: _univerjs_core.CommandType.COMMAND,
|
|
1934
1939
|
handler: async (accessor) => {
|
|
1935
1940
|
var _docDataModel$getBody2, _docDataModel$getBody3;
|
|
@@ -3824,7 +3829,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
3824
3829
|
}
|
|
3825
3830
|
_getDocumentBodyInRanges(sliceType, ranges) {
|
|
3826
3831
|
var _docDataModel$getSelf;
|
|
3827
|
-
const docDataModel = this._univerInstanceService.
|
|
3832
|
+
const docDataModel = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
3828
3833
|
const allRanges = ranges !== null && ranges !== void 0 ? ranges : this._docSelectionManagerService.getDocRanges();
|
|
3829
3834
|
const results = [];
|
|
3830
3835
|
let needCache = true;
|
|
@@ -3834,6 +3839,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
3834
3839
|
const snapshot = docDataModel.getSnapshot();
|
|
3835
3840
|
if (body == null) return;
|
|
3836
3841
|
for (const range of allRanges) {
|
|
3842
|
+
var _docDataModel$getSelf2;
|
|
3837
3843
|
const { startOffset, endOffset, collapsed, rangeType } = range;
|
|
3838
3844
|
if (collapsed || startOffset == null || endOffset == null) continue;
|
|
3839
3845
|
if (rangeType === _univerjs_core.DOC_RANGE_TYPE.RECT) {
|
|
@@ -3847,7 +3853,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
3847
3853
|
endOffset,
|
|
3848
3854
|
collapsed
|
|
3849
3855
|
};
|
|
3850
|
-
const docBody = docDataModel.getSelfOrHeaderFooterModel(segmentId).sliceBody(deleteRange.startOffset, deleteRange.endOffset, sliceType);
|
|
3856
|
+
const docBody = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.sliceBody(deleteRange.startOffset, deleteRange.endOffset, sliceType);
|
|
3851
3857
|
if (docBody == null) continue;
|
|
3852
3858
|
results.push(docBody);
|
|
3853
3859
|
}
|
|
@@ -4121,18 +4127,19 @@ const MoveDocBlockCommand = {
|
|
|
4121
4127
|
if (!params) return false;
|
|
4122
4128
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
4123
4129
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4124
|
-
const
|
|
4130
|
+
const { unitId, sourceRange, targetOffset } = params;
|
|
4131
|
+
const doc = unitId ? univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC) : univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
4125
4132
|
if (!doc) return false;
|
|
4126
4133
|
const previousDocumentData = doc.getSnapshot();
|
|
4127
4134
|
const moveResult = buildMoveDocBlockActions({
|
|
4128
4135
|
documentData: previousDocumentData,
|
|
4129
|
-
sourceRange
|
|
4130
|
-
targetOffset
|
|
4136
|
+
sourceRange,
|
|
4137
|
+
targetOffset
|
|
4131
4138
|
});
|
|
4132
4139
|
const { nextDocumentData, movedRange } = accessor.get(_univerjs_docs.DocBlockMoveValidatorService).transformMoveResult({
|
|
4133
4140
|
unitId: doc.getUnitId(),
|
|
4134
|
-
sourceRange
|
|
4135
|
-
targetOffset
|
|
4141
|
+
sourceRange,
|
|
4142
|
+
targetOffset,
|
|
4136
4143
|
previousDocumentData,
|
|
4137
4144
|
result: moveResult
|
|
4138
4145
|
});
|
|
@@ -4318,7 +4325,7 @@ const DocSelectAllCommand = {
|
|
|
4318
4325
|
id: "doc.command.select-all",
|
|
4319
4326
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4320
4327
|
handler: async (accessor) => {
|
|
4321
|
-
var _docRanges$find;
|
|
4328
|
+
var _docRanges$find, _docDataModel$getSelf;
|
|
4322
4329
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
4323
4330
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
4324
4331
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
@@ -4327,7 +4334,7 @@ const DocSelectAllCommand = {
|
|
|
4327
4334
|
if (docDataModel == null || activeRange == null) return false;
|
|
4328
4335
|
const { segmentId } = activeRange;
|
|
4329
4336
|
const unitId = docDataModel.getUnitId();
|
|
4330
|
-
const body = docDataModel.getSelfOrHeaderFooterModel(segmentId).
|
|
4337
|
+
const body = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
4331
4338
|
if (body == null) return false;
|
|
4332
4339
|
const { dataStream } = body;
|
|
4333
4340
|
if (dataStream === "\r\n") return true;
|
|
@@ -4521,7 +4528,7 @@ const IMEInputCommand = {
|
|
|
4521
4528
|
id: "doc.command.ime-input",
|
|
4522
4529
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4523
4530
|
handler: async (accessor, params) => {
|
|
4524
|
-
var _renderManagerService, _body$customRanges, _body$customDecoratio;
|
|
4531
|
+
var _renderManagerService, _docDataModel$getSelf, _body$customRanges, _body$customDecoratio;
|
|
4525
4532
|
const { unitId, newText, oldTextLen, isCompositionEnd, isCompositionStart } = params;
|
|
4526
4533
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4527
4534
|
const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
|
|
@@ -4533,7 +4540,7 @@ const IMEInputCommand = {
|
|
|
4533
4540
|
const previousActiveRange = imeInputManagerService.getActiveRange();
|
|
4534
4541
|
if (previousActiveRange == null) return false;
|
|
4535
4542
|
const { style, segmentId } = previousActiveRange;
|
|
4536
|
-
const body = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
4543
|
+
const body = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
4537
4544
|
if (body == null) return false;
|
|
4538
4545
|
Object.assign(previousActiveRange, previousActiveRange);
|
|
4539
4546
|
const { startOffset, endOffset } = previousActiveRange;
|
|
@@ -4737,7 +4744,7 @@ const SetInlineFormatCommand = {
|
|
|
4737
4744
|
id: "doc.command.set-inline-format",
|
|
4738
4745
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4739
4746
|
handler: async (accessor, params) => {
|
|
4740
|
-
var _docSelectionManagerS, _docRanges$find;
|
|
4747
|
+
var _docSelectionManagerS, _docRanges$find, _docDataModel$getSelf;
|
|
4741
4748
|
const { value, preCommandId } = params;
|
|
4742
4749
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4743
4750
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
@@ -4750,7 +4757,7 @@ const SetInlineFormatCommand = {
|
|
|
4750
4757
|
const { segmentId } = docRanges[0];
|
|
4751
4758
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
4752
4759
|
if (docDataModel == null) return false;
|
|
4753
|
-
const body = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
4760
|
+
const body = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
4754
4761
|
if (body == null) return false;
|
|
4755
4762
|
const unitId = docDataModel.getUnitId();
|
|
4756
4763
|
let formatValue;
|
|
@@ -4938,12 +4945,13 @@ const ReplaceSnapshotCommand = {
|
|
|
4938
4945
|
id: "doc.command-replace-snapshot",
|
|
4939
4946
|
type: _univerjs_core.CommandType.COMMAND,
|
|
4940
4947
|
handler: (accessor, params) => {
|
|
4948
|
+
var _docDataModel$getSelf;
|
|
4941
4949
|
const { unitId, snapshot, textRanges, segmentId = "", options } = params;
|
|
4942
4950
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
4943
4951
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
4944
4952
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
4945
4953
|
const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
4946
|
-
const prevSnapshot = docDataModel === null || docDataModel === void 0
|
|
4954
|
+
const prevSnapshot = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getSnapshot();
|
|
4947
4955
|
if (docDataModel == null || prevSnapshot == null) return false;
|
|
4948
4956
|
const { body, tableSource, footers, headers, lists, drawings, drawingsOrder, documentStyle } = _univerjs_core.Tools.deepClone(snapshot);
|
|
4949
4957
|
const { body: prevBody, tableSource: prevTableSource, footers: prevFooters, headers: prevHeaders, lists: prevLists, drawings: prevDrawings, drawingsOrder: prevDrawingsOrder, documentStyle: prevDocumentStyle } = prevSnapshot;
|
|
@@ -5012,12 +5020,13 @@ const ReplaceContentCommand = {
|
|
|
5012
5020
|
id: "doc.command-replace-content",
|
|
5013
5021
|
type: _univerjs_core.CommandType.COMMAND,
|
|
5014
5022
|
handler: async (accessor, params) => {
|
|
5023
|
+
var _docDataModel$getSelf2;
|
|
5015
5024
|
const { unitId, body, textRanges, segmentId = "", options } = params;
|
|
5016
5025
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
5017
5026
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5018
5027
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
5019
5028
|
const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
5020
|
-
const prevBody = docDataModel === null || docDataModel === void 0
|
|
5029
|
+
const prevBody = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.getBody();
|
|
5021
5030
|
if (docDataModel == null || prevBody == null) return false;
|
|
5022
5031
|
const doMutation = getMutationParams(unitId, segmentId, docDataModel, prevBody, body);
|
|
5023
5032
|
doMutation.params.textRanges = textRanges;
|
|
@@ -5041,7 +5050,7 @@ const CoverContentCommand = {
|
|
|
5041
5050
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
5042
5051
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5043
5052
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
5044
|
-
const docDatModel = univerInstanceService.
|
|
5053
|
+
const docDatModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
5045
5054
|
const prevBody = docDatModel === null || docDatModel === void 0 ? void 0 : docDatModel.getSnapshot().body;
|
|
5046
5055
|
if (docDatModel == null || prevBody == null) return false;
|
|
5047
5056
|
const doMutation = getMutationParams(unitId, segmentId, docDatModel, prevBody, body);
|
|
@@ -5116,12 +5125,13 @@ const ReplaceTextRunsCommand = {
|
|
|
5116
5125
|
id: "doc.command.replace-text-runs",
|
|
5117
5126
|
type: _univerjs_core.CommandType.COMMAND,
|
|
5118
5127
|
handler: (accessor, params) => {
|
|
5128
|
+
var _docDataModel$getSelf3;
|
|
5119
5129
|
const { unitId, body, textRanges, segmentId = "", options } = params;
|
|
5120
5130
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
5121
5131
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5122
5132
|
const themeService = accessor.get(_univerjs_core.ThemeService);
|
|
5123
5133
|
const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
5124
|
-
const prevBody = docDataModel === null || docDataModel === void 0
|
|
5134
|
+
const prevBody = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf3 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf3 === void 0 ? void 0 : _docDataModel$getSelf3.getBody();
|
|
5125
5135
|
if (docDataModel == null || prevBody == null) return false;
|
|
5126
5136
|
const textX = _univerjs_core.BuildTextUtils.selection.replaceTextRuns({
|
|
5127
5137
|
doc: docDataModel,
|
|
@@ -5197,8 +5207,8 @@ const ListOperationCommand = {
|
|
|
5197
5207
|
if (docDataModel == null || docRanges.length === 0) return false;
|
|
5198
5208
|
const segmentId = docRanges[0].segmentId;
|
|
5199
5209
|
const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
|
|
5200
|
-
const paragraphs = (_segment$getBody$para = (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [];
|
|
5201
|
-
const dataStream = (_segment$getBody$data = (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "";
|
|
5210
|
+
const paragraphs = (_segment$getBody$para = segment === null || segment === void 0 || (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [];
|
|
5211
|
+
const dataStream = (_segment$getBody$data = segment === null || segment === void 0 || (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "";
|
|
5202
5212
|
if (!paragraphs.length) return false;
|
|
5203
5213
|
const currentParagraphs = _univerjs_core.BuildTextUtils.range.getParagraphsInRanges(docRanges, paragraphs, dataStream);
|
|
5204
5214
|
const unitId = docDataModel.getUnitId();
|
|
@@ -5239,8 +5249,8 @@ const ChangeListTypeCommand = {
|
|
|
5239
5249
|
if (docDataModel == null || activeRanges == null || !activeRanges.length) return false;
|
|
5240
5250
|
const { segmentId } = activeRanges[0];
|
|
5241
5251
|
const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
|
|
5242
|
-
const paragraphs = (_segment$getBody$para2 = (_segment$getBody3 = segment.getBody()) === null || _segment$getBody3 === void 0 ? void 0 : _segment$getBody3.paragraphs) !== null && _segment$getBody$para2 !== void 0 ? _segment$getBody$para2 : [];
|
|
5243
|
-
const dataStream = (_segment$getBody$data2 = (_segment$getBody4 = segment.getBody()) === null || _segment$getBody4 === void 0 ? void 0 : _segment$getBody4.dataStream) !== null && _segment$getBody$data2 !== void 0 ? _segment$getBody$data2 : "";
|
|
5252
|
+
const paragraphs = (_segment$getBody$para2 = segment === null || segment === void 0 || (_segment$getBody3 = segment.getBody()) === null || _segment$getBody3 === void 0 ? void 0 : _segment$getBody3.paragraphs) !== null && _segment$getBody$para2 !== void 0 ? _segment$getBody$para2 : [];
|
|
5253
|
+
const dataStream = (_segment$getBody$data2 = segment === null || segment === void 0 || (_segment$getBody4 = segment.getBody()) === null || _segment$getBody4 === void 0 ? void 0 : _segment$getBody4.dataStream) !== null && _segment$getBody$data2 !== void 0 ? _segment$getBody$data2 : "";
|
|
5244
5254
|
if (!paragraphs.length) return false;
|
|
5245
5255
|
const currentParagraphs = _univerjs_core.BuildTextUtils.range.getParagraphsInRanges(activeRanges, paragraphs, dataStream);
|
|
5246
5256
|
const unitId = docDataModel.getUnitId();
|
|
@@ -5288,8 +5298,8 @@ const ChangeListNestingLevelCommand = {
|
|
|
5288
5298
|
const { segmentId } = activeRange;
|
|
5289
5299
|
const selections = (_docSelectionManagerS = docSelectionManagerService.getDocRanges()) !== null && _docSelectionManagerS !== void 0 ? _docSelectionManagerS : [];
|
|
5290
5300
|
const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
|
|
5291
|
-
const paragraphs = (_segment$getBody$para3 = (_segment$getBody5 = segment.getBody()) === null || _segment$getBody5 === void 0 ? void 0 : _segment$getBody5.paragraphs) !== null && _segment$getBody$para3 !== void 0 ? _segment$getBody$para3 : [];
|
|
5292
|
-
const dataStream = (_segment$getBody$data3 = (_segment$getBody6 = segment.getBody()) === null || _segment$getBody6 === void 0 ? void 0 : _segment$getBody6.dataStream) !== null && _segment$getBody$data3 !== void 0 ? _segment$getBody$data3 : "";
|
|
5301
|
+
const paragraphs = (_segment$getBody$para3 = segment === null || segment === void 0 || (_segment$getBody5 = segment.getBody()) === null || _segment$getBody5 === void 0 ? void 0 : _segment$getBody5.paragraphs) !== null && _segment$getBody$para3 !== void 0 ? _segment$getBody$para3 : [];
|
|
5302
|
+
const dataStream = (_segment$getBody$data3 = segment === null || segment === void 0 || (_segment$getBody6 = segment.getBody()) === null || _segment$getBody6 === void 0 ? void 0 : _segment$getBody6.dataStream) !== null && _segment$getBody$data3 !== void 0 ? _segment$getBody$data3 : "";
|
|
5293
5303
|
if (!paragraphs.length) return false;
|
|
5294
5304
|
const currentParagraphs = _univerjs_core.BuildTextUtils.range.getParagraphsInRange(activeRange, paragraphs, dataStream);
|
|
5295
5305
|
const unitId = docDataModel.getUnitId();
|
|
@@ -5356,7 +5366,7 @@ const ToggleCheckListCommand = {
|
|
|
5356
5366
|
const { index, segmentId, textRanges } = params;
|
|
5357
5367
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
5358
5368
|
if (docDataModel == null) return false;
|
|
5359
|
-
if (((_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.paragraphs) == null) return false;
|
|
5369
|
+
if (((_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 || (_docDataModel$getSelf = _docDataModel$getSelf.getBody()) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.paragraphs) == null) return false;
|
|
5360
5370
|
const unitId = docDataModel.getUnitId();
|
|
5361
5371
|
const doMutation = {
|
|
5362
5372
|
id: _univerjs_docs.RichTextEditingMutation.id,
|
|
@@ -5570,14 +5580,14 @@ const AlignOperationCommand = {
|
|
|
5570
5580
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
5571
5581
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5572
5582
|
const { alignType } = params;
|
|
5573
|
-
const docDataModel = univerInstanceService.
|
|
5583
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
5574
5584
|
if (docDataModel == null) return false;
|
|
5575
5585
|
const allRanges = docSelectionManagerService.getDocRanges();
|
|
5576
5586
|
if (allRanges.length === 0) return false;
|
|
5577
5587
|
const segmentId = allRanges[0].segmentId;
|
|
5578
5588
|
const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
|
|
5579
|
-
const paragraphs = (_segment$getBody$para = (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [];
|
|
5580
|
-
const dataStream = (_segment$getBody$data = (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "";
|
|
5589
|
+
const paragraphs = (_segment$getBody$para = segment === null || segment === void 0 || (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [];
|
|
5590
|
+
const dataStream = (_segment$getBody$data = segment === null || segment === void 0 || (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "";
|
|
5581
5591
|
if (paragraphs == null) return false;
|
|
5582
5592
|
const currentParagraphs = _univerjs_core.BuildTextUtils.range.getParagraphsInRanges(allRanges, paragraphs, dataStream);
|
|
5583
5593
|
const unitId = docDataModel.getUnitId();
|
|
@@ -5681,27 +5691,21 @@ const SetDocZoomRatioCommand = {
|
|
|
5681
5691
|
type: _univerjs_core.CommandType.COMMAND,
|
|
5682
5692
|
id: "doc.command.set-zoom-ratio",
|
|
5683
5693
|
handler: async (accessor, params) => {
|
|
5684
|
-
var _univerInstanceServic;
|
|
5685
5694
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5686
5695
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
5687
5696
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
var _params$documentId, _params$zoomRatio;
|
|
5693
|
-
documentId = (_params$documentId = params.documentId) !== null && _params$documentId !== void 0 ? _params$documentId : documentId;
|
|
5694
|
-
zoomRatio = (_params$zoomRatio = params.zoomRatio) !== null && _params$zoomRatio !== void 0 ? _params$zoomRatio : zoomRatio;
|
|
5695
|
-
}
|
|
5696
|
-
if (!univerInstanceService.getUniverDocInstance(documentId)) return false;
|
|
5697
|
+
const { zoomRatio = 1, documentId } = params || {};
|
|
5698
|
+
const docDatModel = documentId ? univerInstanceService.getUnit(documentId, _univerjs_core.UniverInstanceType.UNIVER_DOC) : univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
5699
|
+
if (!docDatModel) return false;
|
|
5700
|
+
const unitId = docDatModel.getUnitId();
|
|
5697
5701
|
const setZoomRatioMutationParams = {
|
|
5698
5702
|
zoomRatio,
|
|
5699
|
-
unitId
|
|
5703
|
+
unitId
|
|
5700
5704
|
};
|
|
5701
5705
|
const undoMutationParams = SetDocZoomRatioUndoMutationFactory(accessor, setZoomRatioMutationParams);
|
|
5702
5706
|
if (commandService.syncExecuteCommand(SetDocZoomRatioOperation.id, setZoomRatioMutationParams)) {
|
|
5703
5707
|
undoRedoService.pushUndoRedo({
|
|
5704
|
-
unitID:
|
|
5708
|
+
unitID: unitId,
|
|
5705
5709
|
undoMutations: [{
|
|
5706
5710
|
id: SetDocZoomRatioOperation.id,
|
|
5707
5711
|
params: undoMutationParams
|
|
@@ -5729,7 +5733,7 @@ const SetParagraphNamedStyleCommand = {
|
|
|
5729
5733
|
if (!doc) return false;
|
|
5730
5734
|
const unitId = doc.getUnitId();
|
|
5731
5735
|
const selectionService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
5732
|
-
const contentInsertRange = params.textRanges ? null : consumeContentInsertRange(accessor, unitId);
|
|
5736
|
+
const contentInsertRange = params.textRanges ? null : (0, _univerjs_docs.consumeContentInsertRange)(accessor, unitId);
|
|
5733
5737
|
if (contentInsertRange) return insertNamedStyleParagraph(accessor, doc, params.value, contentInsertRange.startOffset, contentInsertRange.endOffset);
|
|
5734
5738
|
const selections = (_params$textRanges = params.textRanges) !== null && _params$textRanges !== void 0 ? _params$textRanges : selectionService.getTextRanges({
|
|
5735
5739
|
unitId,
|
|
@@ -5737,8 +5741,10 @@ const SetParagraphNamedStyleCommand = {
|
|
|
5737
5741
|
});
|
|
5738
5742
|
if (!(selections === null || selections === void 0 ? void 0 : selections.length)) return false;
|
|
5739
5743
|
const segmentId = selections[0].segmentId;
|
|
5744
|
+
const documentDataModel = doc.getSelfOrHeaderFooterModel(segmentId);
|
|
5745
|
+
if (!documentDataModel) return false;
|
|
5740
5746
|
const textX = _univerjs_core.BuildTextUtils.paragraph.style.set({
|
|
5741
|
-
document:
|
|
5747
|
+
document: documentDataModel,
|
|
5742
5748
|
textRanges: selections,
|
|
5743
5749
|
style: {
|
|
5744
5750
|
namedStyleType: params.value,
|
|
@@ -5765,13 +5771,6 @@ const SetParagraphNamedStyleCommand = {
|
|
|
5765
5771
|
return Boolean(result);
|
|
5766
5772
|
}
|
|
5767
5773
|
};
|
|
5768
|
-
function consumeContentInsertRange(accessor, unitId) {
|
|
5769
|
-
try {
|
|
5770
|
-
return accessor.get(_univerjs_docs.DocContentInsertService).consumeInsertRange(unitId);
|
|
5771
|
-
} catch {
|
|
5772
|
-
return null;
|
|
5773
|
-
}
|
|
5774
|
-
}
|
|
5775
5774
|
function insertNamedStyleParagraph(accessor, doc, namedStyleType, startOffset, endOffset) {
|
|
5776
5775
|
const textX = _univerjs_core.BuildTextUtils.selection.replace({
|
|
5777
5776
|
doc,
|
|
@@ -5821,8 +5820,8 @@ const QuickHeadingCommand = {
|
|
|
5821
5820
|
if (docDataModel == null || activeRange == null || !activeRange.collapsed) return false;
|
|
5822
5821
|
const { segmentId, startOffset } = activeRange;
|
|
5823
5822
|
const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
|
|
5824
|
-
const paragraphs = (_segment$getBody$para = (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [];
|
|
5825
|
-
const dataStream = (_segment$getBody$data = (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "";
|
|
5823
|
+
const paragraphs = (_segment$getBody$para = segment === null || segment === void 0 || (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [];
|
|
5824
|
+
const dataStream = (_segment$getBody$data = segment === null || segment === void 0 || (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "";
|
|
5826
5825
|
const paragraph = _univerjs_core.BuildTextUtils.paragraph.util.getParagraphsInRange(activeRange, paragraphs, dataStream)[0];
|
|
5827
5826
|
if (!paragraph) return false;
|
|
5828
5827
|
const { paragraphStart } = paragraph;
|
|
@@ -6207,14 +6206,17 @@ var NodePositionConvertToCursor = class {
|
|
|
6207
6206
|
this._resetCurrentNodePositionState();
|
|
6208
6207
|
if (this._documentOffsetConfig == null) return [];
|
|
6209
6208
|
const { pageLayoutType, pageMarginLeft, pageMarginTop } = this._documentOffsetConfig;
|
|
6210
|
-
const
|
|
6209
|
+
const startRootPageIndex = pageType === _univerjs_engine_render.DocumentSkeletonPageType.CELL && pages[pageIndex] == null ? segmentPage : pageIndex;
|
|
6210
|
+
const endRootPageIndex = pageType === _univerjs_engine_render.DocumentSkeletonPageType.CELL && pages[endPageIndex] == null ? endSegmentPage : endPageIndex;
|
|
6211
|
+
const skipPageIndex = pageType === _univerjs_engine_render.DocumentSkeletonPageType.BODY || pageType === _univerjs_engine_render.DocumentSkeletonPageType.CELL ? startRootPageIndex : segmentPage;
|
|
6211
6212
|
for (let p = 0; p < skipPageIndex; p++) {
|
|
6212
6213
|
const page = pages[p];
|
|
6213
6214
|
this._liquid.translatePage(page, pageLayoutType, pageMarginLeft, pageMarginTop);
|
|
6214
6215
|
}
|
|
6215
|
-
const endIndex = pageType === _univerjs_engine_render.DocumentSkeletonPageType.BODY || pageType === _univerjs_engine_render.DocumentSkeletonPageType.CELL ?
|
|
6216
|
+
const endIndex = pageType === _univerjs_engine_render.DocumentSkeletonPageType.BODY || pageType === _univerjs_engine_render.DocumentSkeletonPageType.CELL ? endRootPageIndex : endSegmentPage;
|
|
6216
6217
|
for (let p = skipPageIndex; p <= endIndex; p++) {
|
|
6217
6218
|
const page = pages[p];
|
|
6219
|
+
if (page == null) continue;
|
|
6218
6220
|
const { headerId, footerId, pageWidth } = page;
|
|
6219
6221
|
let segmentPage = page;
|
|
6220
6222
|
if (pageType === _univerjs_engine_render.DocumentSkeletonPageType.HEADER) {
|
|
@@ -6223,7 +6225,7 @@ var NodePositionConvertToCursor = class {
|
|
|
6223
6225
|
} else if (pageType === _univerjs_engine_render.DocumentSkeletonPageType.FOOTER) {
|
|
6224
6226
|
var _skeFooters$get;
|
|
6225
6227
|
segmentPage = (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(pageWidth);
|
|
6226
|
-
} else if (pageType === _univerjs_engine_render.DocumentSkeletonPageType.CELL) segmentPage = (0, _univerjs_engine_render.getPageFromPath)(skeletonData, path);
|
|
6228
|
+
} else if (pageType === _univerjs_engine_render.DocumentSkeletonPageType.CELL) segmentPage = path[0] === "pages" ? (0, _univerjs_engine_render.getPageFromPath)(skeletonData, path) : getCellPageFromSegmentPath(skeletonData, page, path);
|
|
6227
6229
|
if (segmentPage == null) {
|
|
6228
6230
|
this._liquid.translatePage(page, pageLayoutType, pageMarginLeft, pageMarginTop);
|
|
6229
6231
|
continue;
|
|
@@ -6253,7 +6255,6 @@ var NodePositionConvertToCursor = class {
|
|
|
6253
6255
|
this._liquid.translatePagePadding(segmentPage);
|
|
6254
6256
|
break;
|
|
6255
6257
|
}
|
|
6256
|
-
this._liquid.translatePagePadding(page);
|
|
6257
6258
|
const rowSke = segmentPage.parent;
|
|
6258
6259
|
const tableSke = rowSke.parent;
|
|
6259
6260
|
const tablePage = tableSke.parent;
|
|
@@ -6265,6 +6266,14 @@ var NodePositionConvertToCursor = class {
|
|
|
6265
6266
|
const viewport = (0, _univerjs_engine_render.getDocsTableRenderViewport)(getDocumentUnitId$1(skeleton), sourceTableId);
|
|
6266
6267
|
const hasHorizontalViewport = hasHorizontalTableViewport$2(viewport);
|
|
6267
6268
|
const scrollLeft = hasHorizontalViewport ? viewport.scrollLeft : 0;
|
|
6269
|
+
if ((tablePage === null || tablePage === void 0 ? void 0 : tablePage.type) === _univerjs_engine_render.DocumentSkeletonPageType.HEADER) this._liquid.translatePagePadding({
|
|
6270
|
+
...tablePage,
|
|
6271
|
+
marginLeft: page.marginLeft
|
|
6272
|
+
});
|
|
6273
|
+
else if ((tablePage === null || tablePage === void 0 ? void 0 : tablePage.type) === _univerjs_engine_render.DocumentSkeletonPageType.FOOTER) {
|
|
6274
|
+
const footerTop = page.pageHeight - tablePage.height - tablePage.marginBottom;
|
|
6275
|
+
this._liquid.translate(page.marginLeft, footerTop);
|
|
6276
|
+
} else this._liquid.translatePagePadding(page);
|
|
6268
6277
|
if (tablePageNestedOffset) {
|
|
6269
6278
|
this._liquid.translate(tablePageNestedOffset.left, tablePageNestedOffset.top);
|
|
6270
6279
|
this._liquid.translatePagePadding(tablePage);
|
|
@@ -6340,6 +6349,28 @@ function clipPositionToHorizontalRange(position, clip) {
|
|
|
6340
6349
|
endX
|
|
6341
6350
|
};
|
|
6342
6351
|
}
|
|
6352
|
+
function getCellPageFromSegmentPath(skeletonData, rootPage, path) {
|
|
6353
|
+
var _skeletonData$skeHead, _skeletonData$skeFoot;
|
|
6354
|
+
if (path[0] === "pages") return null;
|
|
6355
|
+
const segmentPages = [];
|
|
6356
|
+
const { headerId, footerId, pageWidth } = rootPage;
|
|
6357
|
+
const headerPage = headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(pageWidth);
|
|
6358
|
+
const footerPage = footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(pageWidth);
|
|
6359
|
+
if (headerPage != null) segmentPages.push(headerPage);
|
|
6360
|
+
if (footerPage != null) segmentPages.push(footerPage);
|
|
6361
|
+
for (const segmentPage of segmentPages) {
|
|
6362
|
+
const page = (0, _univerjs_engine_render.getPageFromPath)({
|
|
6363
|
+
...skeletonData,
|
|
6364
|
+
pages: [segmentPage]
|
|
6365
|
+
}, [
|
|
6366
|
+
"pages",
|
|
6367
|
+
0,
|
|
6368
|
+
...path
|
|
6369
|
+
]);
|
|
6370
|
+
if (page != null) return page;
|
|
6371
|
+
}
|
|
6372
|
+
return null;
|
|
6373
|
+
}
|
|
6343
6374
|
function getDocumentUnitId$1(docSkeleton) {
|
|
6344
6375
|
var _viewModel$getDataMod, _viewModel$getDataMod2, _viewModel$getDataMod3, _viewModel$getDataMod4;
|
|
6345
6376
|
const viewModel = docSkeleton.getViewModel();
|
|
@@ -6493,9 +6524,12 @@ var NodePositionConvertToRectRange = class {
|
|
|
6493
6524
|
docsLeft: (_this$_documentOffset = this._documentOffsetConfig.docsLeft) !== null && _this$_documentOffset !== void 0 ? _this$_documentOffset : 0,
|
|
6494
6525
|
docsTop: (_this$_documentOffset2 = this._documentOffsetConfig.docsTop) !== null && _this$_documentOffset2 !== void 0 ? _this$_documentOffset2 : 0,
|
|
6495
6526
|
pageMarginTop,
|
|
6527
|
+
skeFooters: skeletonData === null || skeletonData === void 0 ? void 0 : skeletonData.skeFooters,
|
|
6528
|
+
skeHeaders: skeletonData === null || skeletonData === void 0 ? void 0 : skeletonData.skeHeaders,
|
|
6496
6529
|
unitId
|
|
6497
6530
|
});
|
|
6498
|
-
const
|
|
6531
|
+
const startRootPage = pageType === _univerjs_engine_render.DocumentSkeletonPageType.CELL && pages[startPage] == null ? startSegmentPage : startPage;
|
|
6532
|
+
const skipPageIndex = pageType === _univerjs_engine_render.DocumentSkeletonPageType.BODY || pageType === _univerjs_engine_render.DocumentSkeletonPageType.CELL ? startRootPage : startSegmentPage;
|
|
6499
6533
|
for (let p = 0; p < skipPageIndex; p++) {
|
|
6500
6534
|
const page = pages[p];
|
|
6501
6535
|
this._liquid.translatePage(page, pageLayoutType, pageMarginLeft, pageMarginTop);
|
|
@@ -6507,12 +6541,13 @@ var NodePositionConvertToRectRange = class {
|
|
|
6507
6541
|
let table = null;
|
|
6508
6542
|
for (const [id, tableSke] of skeTables.entries()) if (id.startsWith(tableId)) table = tableSke;
|
|
6509
6543
|
if (table == null) {
|
|
6510
|
-
const nestedTableContext = nestedTableContexts.find((context) => context.pageIndex === p && context.source === "column" && context.tableId.startsWith(tableId));
|
|
6544
|
+
const nestedTableContext = nestedTableContexts.find((context) => context.pageIndex === p && (context.source === "column" || context.source === "header" || context.source === "footer") && context.tableId.startsWith(tableId));
|
|
6511
6545
|
if (nestedTableContext) {
|
|
6546
|
+
var _this$_documentOffset3, _this$_documentOffset4;
|
|
6512
6547
|
const nestedTable = nestedTableContext.table;
|
|
6513
6548
|
const viewport = (0, _univerjs_engine_render.getDocsTableRenderViewport)(unitId, sourceTableId);
|
|
6514
|
-
const nestedX = nestedTableContext.tableRect.left - nestedTable.left;
|
|
6515
|
-
const nestedY = nestedTableContext.tableRect.top;
|
|
6549
|
+
const nestedX = nestedTableContext.tableRect.left - nestedTable.left - ((_this$_documentOffset3 = this._documentOffsetConfig.docsLeft) !== null && _this$_documentOffset3 !== void 0 ? _this$_documentOffset3 : 0);
|
|
6550
|
+
const nestedY = nestedTableContext.tableRect.top - ((_this$_documentOffset4 = this._documentOffsetConfig.docsTop) !== null && _this$_documentOffset4 !== void 0 ? _this$_documentOffset4 : 0);
|
|
6516
6551
|
if (intersectsMergedCell) {
|
|
6517
6552
|
const rows = nestedTable.rows.filter((row) => row.index >= startRow && row.index <= endRow);
|
|
6518
6553
|
const firstRow = rows[0];
|
|
@@ -6643,8 +6678,8 @@ var NodePositionConvertToRectRange = class {
|
|
|
6643
6678
|
const { path: anchorPath } = anchorPosition;
|
|
6644
6679
|
const { path: focusPath } = focusPosition;
|
|
6645
6680
|
if (anchorPath.indexOf("cells") === -1 || focusPath.indexOf("cells") === -1) return;
|
|
6646
|
-
const anchorCell = (
|
|
6647
|
-
const focusCell = (
|
|
6681
|
+
const anchorCell = getCellPageFromPositionPath(skeletonData, anchorPosition);
|
|
6682
|
+
const focusCell = getCellPageFromPositionPath(skeletonData, focusPosition);
|
|
6648
6683
|
if (anchorCell == null || focusCell == null) return;
|
|
6649
6684
|
const anchorRow = anchorCell.parent;
|
|
6650
6685
|
const focusRow = focusCell.parent;
|
|
@@ -6720,6 +6755,28 @@ function rangeIntersectsMergedCell(table, range) {
|
|
|
6720
6755
|
});
|
|
6721
6756
|
}));
|
|
6722
6757
|
}
|
|
6758
|
+
function getCellPageFromPositionPath(skeletonData, position) {
|
|
6759
|
+
var _skeletonData$skeHead, _skeletonData$skeFoot;
|
|
6760
|
+
const { path, segmentPage } = position;
|
|
6761
|
+
if (path[0] === "pages") return (0, _univerjs_engine_render.getPageFromPath)(skeletonData, path);
|
|
6762
|
+
const rootPage = skeletonData.pages[segmentPage];
|
|
6763
|
+
if (rootPage == null) return null;
|
|
6764
|
+
const { headerId, footerId, pageWidth } = rootPage;
|
|
6765
|
+
const segmentPages = [headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(pageWidth), footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(pageWidth)];
|
|
6766
|
+
for (const segmentPage of segmentPages) {
|
|
6767
|
+
if (segmentPage == null) continue;
|
|
6768
|
+
const page = (0, _univerjs_engine_render.getPageFromPath)({
|
|
6769
|
+
...skeletonData,
|
|
6770
|
+
pages: [segmentPage]
|
|
6771
|
+
}, [
|
|
6772
|
+
"pages",
|
|
6773
|
+
0,
|
|
6774
|
+
...path
|
|
6775
|
+
]);
|
|
6776
|
+
if (page != null) return page;
|
|
6777
|
+
}
|
|
6778
|
+
return null;
|
|
6779
|
+
}
|
|
6723
6780
|
function normalizeRange(range) {
|
|
6724
6781
|
return {
|
|
6725
6782
|
startRowIndex: Math.min(range.startRowIndex, range.endRowIndex),
|
|
@@ -6812,17 +6869,17 @@ var TextRange = class {
|
|
|
6812
6869
|
}, 1e3);
|
|
6813
6870
|
}
|
|
6814
6871
|
get startOffset() {
|
|
6815
|
-
var _getOneTextSelectionR;
|
|
6872
|
+
var _getOneTextSelectionR, _this$_docSkeleton$ge;
|
|
6816
6873
|
const { startOffset } = (_getOneTextSelectionR = getOneTextSelectionRange(this._cursorList)) !== null && _getOneTextSelectionR !== void 0 ? _getOneTextSelectionR : {};
|
|
6817
|
-
const body = this._docSkeleton.getViewModel().getDataModel().getSelfOrHeaderFooterModel(this._segmentId).getBody();
|
|
6874
|
+
const body = (_this$_docSkeleton$ge = this._docSkeleton.getViewModel().getDataModel().getSelfOrHeaderFooterModel(this._segmentId)) === null || _this$_docSkeleton$ge === void 0 ? void 0 : _this$_docSkeleton$ge.getBody();
|
|
6818
6875
|
if (startOffset == null || body == null) return startOffset;
|
|
6819
6876
|
const maxLength = body.dataStream.length - 2;
|
|
6820
6877
|
return Math.min(maxLength, startOffset);
|
|
6821
6878
|
}
|
|
6822
6879
|
get endOffset() {
|
|
6823
|
-
var _getOneTextSelectionR2;
|
|
6880
|
+
var _getOneTextSelectionR2, _this$_docSkeleton$ge2;
|
|
6824
6881
|
const { endOffset } = (_getOneTextSelectionR2 = getOneTextSelectionRange(this._cursorList)) !== null && _getOneTextSelectionR2 !== void 0 ? _getOneTextSelectionR2 : {};
|
|
6825
|
-
const body = this._docSkeleton.getViewModel().getDataModel().getSelfOrHeaderFooterModel(this._segmentId).getBody();
|
|
6882
|
+
const body = (_this$_docSkeleton$ge2 = this._docSkeleton.getViewModel().getDataModel().getSelfOrHeaderFooterModel(this._segmentId)) === null || _this$_docSkeleton$ge2 === void 0 ? void 0 : _this$_docSkeleton$ge2.getBody();
|
|
6826
6883
|
if (endOffset == null || body == null) return endOffset;
|
|
6827
6884
|
const maxLength = body.dataStream.length - 2;
|
|
6828
6885
|
return Math.min(endOffset, maxLength);
|
|
@@ -8222,7 +8279,7 @@ const SwitchDocModeCommand = {
|
|
|
8222
8279
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
8223
8280
|
const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
|
|
8224
8281
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
8225
|
-
const docDataModel = accessor.get(_univerjs_core.IUniverInstanceService).
|
|
8282
|
+
const docDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
8226
8283
|
if (docDataModel == null) return false;
|
|
8227
8284
|
const unitId = docDataModel.getUnitId();
|
|
8228
8285
|
const skeleton = (_renderManagerService = renderManagerService.getRenderById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton();
|
|
@@ -8327,6 +8384,18 @@ function shouldCreateParagraphBeforeTable(body, startOffset) {
|
|
|
8327
8384
|
function normalizeTableInsertOffset(body, startOffset) {
|
|
8328
8385
|
return startOffset === 0 && body.dataStream[0] === _univerjs_core.DataStreamTreeTokenType.PARAGRAPH ? 1 : startOffset;
|
|
8329
8386
|
}
|
|
8387
|
+
function canInsertTableAtOffset(body, offset) {
|
|
8388
|
+
return !(isOffsetInTableRange(body.tables, offset) || isOffsetInIndexRange(body.blockRanges, offset) || isOffsetOnPointRange(body.customBlocks, offset));
|
|
8389
|
+
}
|
|
8390
|
+
function isOffsetInTableRange(ranges, offset) {
|
|
8391
|
+
return Boolean(ranges === null || ranges === void 0 ? void 0 : ranges.some((range) => range.startIndex <= offset && offset < range.endIndex));
|
|
8392
|
+
}
|
|
8393
|
+
function isOffsetInIndexRange(ranges, offset) {
|
|
8394
|
+
return Boolean(ranges === null || ranges === void 0 ? void 0 : ranges.some((range) => range.startIndex <= offset && offset <= range.endIndex));
|
|
8395
|
+
}
|
|
8396
|
+
function isOffsetOnPointRange(ranges, offset) {
|
|
8397
|
+
return Boolean(ranges === null || ranges === void 0 ? void 0 : ranges.some((range) => range.startIndex === offset));
|
|
8398
|
+
}
|
|
8330
8399
|
/**
|
|
8331
8400
|
* The command to create a table at cursor point.
|
|
8332
8401
|
*/
|
|
@@ -8334,13 +8403,13 @@ const CreateDocTableCommand = {
|
|
|
8334
8403
|
id: CreateDocTableCommandId,
|
|
8335
8404
|
type: _univerjs_core.CommandType.COMMAND,
|
|
8336
8405
|
handler: async (accessor, params) => {
|
|
8337
|
-
var _ref, _contentInsertRange$s, _contentInsertRange$s2, _body$paragraphs, _curGlyph$parent, _body$paragraphs2;
|
|
8406
|
+
var _ref, _contentInsertRange$s, _docDataModel$getSelf, _contentInsertRange$s2, _body$paragraphs, _curGlyph$parent, _body$paragraphs2;
|
|
8338
8407
|
const { rowCount, colCount } = params;
|
|
8339
8408
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
8340
8409
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
8341
8410
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
8342
8411
|
const docMenuStyleService = accessor.get(DocMenuStyleService);
|
|
8343
|
-
const docDataModel = univerInstanceService.
|
|
8412
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
8344
8413
|
if (docDataModel == null) return false;
|
|
8345
8414
|
let contentInsertRange = null;
|
|
8346
8415
|
try {
|
|
@@ -8352,13 +8421,14 @@ const CreateDocTableCommand = {
|
|
|
8352
8421
|
if (activeRange == null && contentInsertRange == null) return false;
|
|
8353
8422
|
const segmentId = (_ref = (_contentInsertRange$s = contentInsertRange === null || contentInsertRange === void 0 ? void 0 : contentInsertRange.segmentId) !== null && _contentInsertRange$s !== void 0 ? _contentInsertRange$s : activeRange === null || activeRange === void 0 ? void 0 : activeRange.segmentId) !== null && _ref !== void 0 ? _ref : "";
|
|
8354
8423
|
const segmentPage = activeRange === null || activeRange === void 0 ? void 0 : activeRange.segmentPage;
|
|
8355
|
-
const body = docDataModel === null || docDataModel === void 0
|
|
8424
|
+
const body = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
8356
8425
|
if (body == null) return false;
|
|
8357
8426
|
const unitId = docDataModel.getUnitId();
|
|
8358
8427
|
const docSkeletonManagerService = getCommandSkeleton(accessor, unitId);
|
|
8359
8428
|
const skeleton = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getSkeleton();
|
|
8360
8429
|
if (skeleton == null) return false;
|
|
8361
8430
|
const startOffset = normalizeTableInsertOffset(body, (_contentInsertRange$s2 = contentInsertRange === null || contentInsertRange === void 0 ? void 0 : contentInsertRange.startOffset) !== null && _contentInsertRange$s2 !== void 0 ? _contentInsertRange$s2 : activeRange.startOffset);
|
|
8431
|
+
if (!canInsertTableAtOffset(body, startOffset)) return false;
|
|
8362
8432
|
const prevParagraph = ((_body$paragraphs = body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : []).find((p) => p.startIndex >= startOffset);
|
|
8363
8433
|
const curGlyph = skeleton.findNodeByCharIndex(startOffset, segmentId, segmentPage);
|
|
8364
8434
|
if (curGlyph == null) return false;
|
|
@@ -8429,6 +8499,7 @@ const DocTableDeleteRowsCommand = {
|
|
|
8429
8499
|
id: "doc.table.delete-rows",
|
|
8430
8500
|
type: _univerjs_core.CommandType.COMMAND,
|
|
8431
8501
|
handler: async (accessor) => {
|
|
8502
|
+
var _docDataModel$getSelf;
|
|
8432
8503
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
8433
8504
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
8434
8505
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
@@ -8436,8 +8507,8 @@ const DocTableDeleteRowsCommand = {
|
|
|
8436
8507
|
const rangeInfo = getRangeInfoFromRanges(docSelectionManagerService.getActiveTextRange(), activeRectRanges);
|
|
8437
8508
|
if (rangeInfo == null) return false;
|
|
8438
8509
|
const { segmentId } = rangeInfo;
|
|
8439
|
-
const docDataModel = univerInstanceService.
|
|
8440
|
-
const body = docDataModel === null || docDataModel === void 0
|
|
8510
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
8511
|
+
const body = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
8441
8512
|
if (docDataModel == null || body == null) return false;
|
|
8442
8513
|
const docSkeletonManagerService = getCommandSkeleton(accessor, docDataModel.getUnitId());
|
|
8443
8514
|
if (docSkeletonManagerService == null) return false;
|
|
@@ -8493,6 +8564,7 @@ const DocTableDeleteColumnsCommand = {
|
|
|
8493
8564
|
id: "doc.table.delete-columns",
|
|
8494
8565
|
type: _univerjs_core.CommandType.COMMAND,
|
|
8495
8566
|
handler: async (accessor) => {
|
|
8567
|
+
var _docDataModel$getSelf2;
|
|
8496
8568
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
8497
8569
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
8498
8570
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
@@ -8500,8 +8572,8 @@ const DocTableDeleteColumnsCommand = {
|
|
|
8500
8572
|
const rangeInfo = getRangeInfoFromRanges(docSelectionManagerService.getActiveTextRange(), activeRectRanges);
|
|
8501
8573
|
if (rangeInfo == null) return false;
|
|
8502
8574
|
const { segmentId } = rangeInfo;
|
|
8503
|
-
const docDataModel = univerInstanceService.
|
|
8504
|
-
const body = docDataModel === null || docDataModel === void 0
|
|
8575
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
8576
|
+
const body = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.getBody();
|
|
8505
8577
|
if (docDataModel == null || body == null) return false;
|
|
8506
8578
|
const docSkeletonManagerService = getCommandSkeleton(accessor, docDataModel.getUnitId());
|
|
8507
8579
|
if (docSkeletonManagerService == null) return false;
|
|
@@ -8572,6 +8644,7 @@ const DocTableDeleteTableCommand = {
|
|
|
8572
8644
|
id: "doc.table.delete-table",
|
|
8573
8645
|
type: _univerjs_core.CommandType.COMMAND,
|
|
8574
8646
|
handler: async (accessor) => {
|
|
8647
|
+
var _docDataModel$getSelf3;
|
|
8575
8648
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
8576
8649
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
8577
8650
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
@@ -8579,8 +8652,8 @@ const DocTableDeleteTableCommand = {
|
|
|
8579
8652
|
const rangeInfo = getRangeInfoFromRanges(docSelectionManagerService.getActiveTextRange(), activeRectRanges);
|
|
8580
8653
|
if (rangeInfo == null) return false;
|
|
8581
8654
|
const { segmentId } = rangeInfo;
|
|
8582
|
-
const docDataModel = univerInstanceService.
|
|
8583
|
-
const body = docDataModel === null || docDataModel === void 0
|
|
8655
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
8656
|
+
const body = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf3 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf3 === void 0 ? void 0 : _docDataModel$getSelf3.getBody();
|
|
8584
8657
|
if (docDataModel == null || body == null) return false;
|
|
8585
8658
|
const docSkeletonManagerService = getCommandSkeleton(accessor, docDataModel.getUnitId());
|
|
8586
8659
|
if (docSkeletonManagerService == null) return false;
|
|
@@ -8668,6 +8741,7 @@ const DocTableInsertRowCommand = {
|
|
|
8668
8741
|
id: DocTableInsertRowCommandId,
|
|
8669
8742
|
type: _univerjs_core.CommandType.COMMAND,
|
|
8670
8743
|
handler: async (accessor, params) => {
|
|
8744
|
+
var _docDataModel$getSelf;
|
|
8671
8745
|
const { position } = params;
|
|
8672
8746
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
8673
8747
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
@@ -8677,7 +8751,7 @@ const DocTableInsertRowCommand = {
|
|
|
8677
8751
|
if (rangeInfo == null) return false;
|
|
8678
8752
|
const { segmentId } = rangeInfo;
|
|
8679
8753
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
8680
|
-
const body = docDataModel === null || docDataModel === void 0
|
|
8754
|
+
const body = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
8681
8755
|
if (docDataModel == null || body == null) return false;
|
|
8682
8756
|
const docSkeletonManagerService = getCommandSkeleton(accessor, docDataModel.getUnitId());
|
|
8683
8757
|
if (docSkeletonManagerService == null) return false;
|
|
@@ -8737,7 +8811,7 @@ const DocTableInsertColumnCommand = {
|
|
|
8737
8811
|
id: DocTableInsertColumnCommandId,
|
|
8738
8812
|
type: _univerjs_core.CommandType.COMMAND,
|
|
8739
8813
|
handler: async (accessor, params) => {
|
|
8740
|
-
var _snapshot$tableSource, _documentStyle$pageSi, _documentStyle$pageSi2;
|
|
8814
|
+
var _docDataModel$getSelf2, _snapshot$tableSource, _documentStyle$pageSi, _documentStyle$pageSi2;
|
|
8741
8815
|
const { position } = params;
|
|
8742
8816
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
8743
8817
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
@@ -8746,8 +8820,8 @@ const DocTableInsertColumnCommand = {
|
|
|
8746
8820
|
const rangeInfo = getRangeInfoFromRanges(docSelectionManagerService.getActiveTextRange(), activeRectRanges);
|
|
8747
8821
|
if (rangeInfo == null) return false;
|
|
8748
8822
|
const { segmentId } = rangeInfo;
|
|
8749
|
-
const docDataModel = univerInstanceService.
|
|
8750
|
-
const body = docDataModel === null || docDataModel === void 0
|
|
8823
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
8824
|
+
const body = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.getBody();
|
|
8751
8825
|
if (docDataModel == null || body == null) return false;
|
|
8752
8826
|
const docSkeletonManagerService = getCommandSkeleton(accessor, docDataModel.getUnitId());
|
|
8753
8827
|
if (docSkeletonManagerService == null) return false;
|
|
@@ -8846,7 +8920,7 @@ const DocTableTabCommand = {
|
|
|
8846
8920
|
const textSelectionManager = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
8847
8921
|
const docRanges = textSelectionManager.getDocRanges();
|
|
8848
8922
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
8849
|
-
const docDataModel = accessor.get(_univerjs_core.IUniverInstanceService).
|
|
8923
|
+
const docDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
8850
8924
|
if (!docDataModel) return false;
|
|
8851
8925
|
const activeRange = (_docRanges$find = docRanges.find((range) => range.isActive)) !== null && _docRanges$find !== void 0 ? _docRanges$find : docRanges[0];
|
|
8852
8926
|
const docSkeletonManagerService = getCommandSkeleton(accessor, docDataModel.getUnitId());
|
|
@@ -9399,7 +9473,7 @@ let EditorService = class EditorService extends _univerjs_core.Disposable {
|
|
|
9399
9473
|
this._univerInstanceService.disposeUnit(editorUnitId);
|
|
9400
9474
|
}
|
|
9401
9475
|
_getCurrentEditorUnitId() {
|
|
9402
|
-
return this._univerInstanceService.
|
|
9476
|
+
return this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC).getUnitId();
|
|
9403
9477
|
}
|
|
9404
9478
|
_getBlank(id) {
|
|
9405
9479
|
return {
|
|
@@ -10056,325 +10130,138 @@ function findFirstCursorOffset(snapshot) {
|
|
|
10056
10130
|
}
|
|
10057
10131
|
|
|
10058
10132
|
//#endregion
|
|
10059
|
-
//#region src/views/header-footer/
|
|
10060
|
-
const COLLAB_CURSOR_LABEL_HEIGHT = 18;
|
|
10061
|
-
const COLLAB_CURSOR_LABEL_MAX_WIDTH = 200;
|
|
10062
|
-
const COLLAB_CURSOR_LABEL_TEXT_PADDING_LR = 6;
|
|
10063
|
-
const COLLAB_CURSOR_LABEL_TEXT_PADDING_TB = 4;
|
|
10064
|
-
function drawBubble(ctx, props) {
|
|
10065
|
-
var _radius, _width, _height;
|
|
10066
|
-
let { radius, width, height } = props;
|
|
10067
|
-
radius = (_radius = radius) !== null && _radius !== void 0 ? _radius : 0;
|
|
10068
|
-
width = (_width = width) !== null && _width !== void 0 ? _width : 30;
|
|
10069
|
-
height = (_height = height) !== null && _height !== void 0 ? _height : 30;
|
|
10070
|
-
let bottomRight = 0;
|
|
10071
|
-
bottomRight = Math.min(radius, width / 2, height / 2);
|
|
10072
|
-
ctx.beginPath();
|
|
10073
|
-
ctx.moveTo(0, 0);
|
|
10074
|
-
ctx.lineTo(width, 0);
|
|
10075
|
-
ctx.lineTo(width, height - bottomRight);
|
|
10076
|
-
ctx.arc(width - bottomRight, height - bottomRight, bottomRight, 0, Math.PI / 2, false);
|
|
10077
|
-
ctx.lineTo(0, height);
|
|
10078
|
-
ctx.lineTo(0, 0);
|
|
10079
|
-
ctx.closePath();
|
|
10080
|
-
if (props.fill) {
|
|
10081
|
-
ctx.save();
|
|
10082
|
-
ctx.fillStyle = props.fill;
|
|
10083
|
-
if (props.fillRule === "evenodd") ctx.fill("evenodd");
|
|
10084
|
-
else ctx.fill();
|
|
10085
|
-
ctx.restore();
|
|
10086
|
-
}
|
|
10087
|
-
}
|
|
10133
|
+
//#region src/views/header-footer/panel/component-name.ts
|
|
10088
10134
|
/**
|
|
10089
|
-
*
|
|
10135
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
10136
|
+
*
|
|
10137
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10138
|
+
* you may not use this file except in compliance with the License.
|
|
10139
|
+
* You may obtain a copy of the License at
|
|
10140
|
+
*
|
|
10141
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10142
|
+
*
|
|
10143
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10144
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10145
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10146
|
+
* See the License for the specific language governing permissions and
|
|
10147
|
+
* limitations under the License.
|
|
10090
10148
|
*/
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10149
|
+
const COMPONENT_DOC_HEADER_FOOTER_PANEL = "COMPONENT_DOC_HEADER_FOOTER_PANEL";
|
|
10150
|
+
|
|
10151
|
+
//#endregion
|
|
10152
|
+
//#region src/commands/operations/doc-header-footer-panel.operation.ts
|
|
10153
|
+
const SidebarDocHeaderFooterPanelOperation = {
|
|
10154
|
+
id: "sidebar.operation.doc-header-footer-panel",
|
|
10155
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
10156
|
+
handler: async (accessor, params) => {
|
|
10157
|
+
const sidebarService = accessor.get(_univerjs_ui.ISidebarService);
|
|
10158
|
+
const localeService = accessor.get(_univerjs_core.LocaleService);
|
|
10159
|
+
switch (params.value) {
|
|
10160
|
+
case "open":
|
|
10161
|
+
sidebarService.open({
|
|
10162
|
+
header: { title: localeService.t("docs-ui.headerFooter.panel") },
|
|
10163
|
+
children: { label: COMPONENT_DOC_HEADER_FOOTER_PANEL },
|
|
10164
|
+
onClose: () => {},
|
|
10165
|
+
width: 400
|
|
10166
|
+
});
|
|
10167
|
+
break;
|
|
10168
|
+
default:
|
|
10169
|
+
sidebarService.close();
|
|
10170
|
+
break;
|
|
10171
|
+
}
|
|
10172
|
+
return true;
|
|
10098
10173
|
}
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
|
|
10174
|
+
};
|
|
10175
|
+
|
|
10176
|
+
//#endregion
|
|
10177
|
+
//#region src/commands/commands/doc-header-footer.command.ts
|
|
10178
|
+
const CoreHeaderFooterCommandId = "doc.command.core-header-footer";
|
|
10179
|
+
/**
|
|
10180
|
+
* The command to update header and footer or create them.
|
|
10181
|
+
*/
|
|
10182
|
+
const CoreHeaderFooterCommand = {
|
|
10183
|
+
id: CoreHeaderFooterCommandId,
|
|
10184
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
10185
|
+
handler: async (accessor, params) => {
|
|
10186
|
+
var _renderManagerService;
|
|
10187
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
10188
|
+
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
10189
|
+
const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
|
|
10190
|
+
const { unitId, segmentId, createType, headerFooterProps } = params;
|
|
10191
|
+
const docSkeletonManagerService = (_renderManagerService = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(_univerjs_docs.DocSkeletonManagerService);
|
|
10192
|
+
const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
10193
|
+
const docViewModel = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel();
|
|
10194
|
+
if (docDataModel == null || docViewModel == null) return false;
|
|
10195
|
+
const editArea = docViewModel.getEditArea();
|
|
10196
|
+
const { documentStyle } = docDataModel.getSnapshot();
|
|
10197
|
+
let resolvedCreateType = createType;
|
|
10198
|
+
if (headerFooterProps != null) Object.keys(headerFooterProps).forEach((key) => {
|
|
10199
|
+
const value = headerFooterProps[key];
|
|
10200
|
+
if (resolvedCreateType == null && key === "useFirstPageHeaderFooter" && value === _univerjs_core.BooleanNumber.TRUE && !documentStyle.firstPageHeaderId) resolvedCreateType = editArea === _univerjs_engine_render.DocumentEditArea.HEADER ? _univerjs_docs.HeaderFooterType.FIRST_PAGE_HEADER : _univerjs_docs.HeaderFooterType.FIRST_PAGE_FOOTER;
|
|
10201
|
+
else if (resolvedCreateType == null && key === "evenAndOddHeaders" && value === _univerjs_core.BooleanNumber.TRUE && !documentStyle.evenPageHeaderId) resolvedCreateType = editArea === _univerjs_engine_render.DocumentEditArea.HEADER ? _univerjs_docs.HeaderFooterType.EVEN_PAGE_HEADER : _univerjs_docs.HeaderFooterType.EVEN_PAGE_FOOTER;
|
|
10202
|
+
});
|
|
10203
|
+
return commandService.syncExecuteCommand(_univerjs_docs.CreateHeaderFooterCommand.id, {
|
|
10204
|
+
unitId,
|
|
10205
|
+
segmentId,
|
|
10206
|
+
createType: resolvedCreateType,
|
|
10207
|
+
headerFooterProps,
|
|
10208
|
+
createMode: "pair"
|
|
10110
10209
|
});
|
|
10111
|
-
ctx.fillStyle = "rgba(58, 96, 247, 1)";
|
|
10112
|
-
const offsetX = 6;
|
|
10113
|
-
const offsetY = 18 - 4;
|
|
10114
|
-
const maxTextWidth = 200 - 2 * 6;
|
|
10115
|
-
if (textWidth > maxTextWidth) {
|
|
10116
|
-
let truncatedText = "";
|
|
10117
|
-
let currentWidth = 0;
|
|
10118
|
-
for (const element of text) {
|
|
10119
|
-
const charWidth = ctx.measureText(element).width;
|
|
10120
|
-
if (currentWidth + charWidth <= maxTextWidth - ctx.measureText("...").width) {
|
|
10121
|
-
truncatedText += element;
|
|
10122
|
-
currentWidth += charWidth;
|
|
10123
|
-
} else {
|
|
10124
|
-
truncatedText += "...";
|
|
10125
|
-
break;
|
|
10126
|
-
}
|
|
10127
|
-
}
|
|
10128
|
-
ctx.fillText(truncatedText, offsetX, offsetY);
|
|
10129
|
-
} else ctx.fillText(text, offsetX, offsetY);
|
|
10130
|
-
ctx.restore();
|
|
10131
10210
|
}
|
|
10132
|
-
|
|
10133
|
-
|
|
10211
|
+
};
|
|
10212
|
+
const OpenHeaderFooterPanelCommand = {
|
|
10213
|
+
id: "doc.command.open-header-footer-panel",
|
|
10214
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
10215
|
+
handler: async (accessor, _params) => {
|
|
10216
|
+
return accessor.get(_univerjs_core.ICommandService).executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "open" });
|
|
10217
|
+
}
|
|
10218
|
+
};
|
|
10219
|
+
const CloseHeaderFooterCommand = {
|
|
10220
|
+
id: "doc.command.close-header-footer",
|
|
10221
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
10222
|
+
handler: async (accessor, params) => {
|
|
10223
|
+
var _params$unitId, _instanceService$getC, _renderObject$mainCom;
|
|
10224
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
10225
|
+
const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
|
|
10226
|
+
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
10227
|
+
const instanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
10228
|
+
const unitId = (_params$unitId = params === null || params === void 0 ? void 0 : params.unitId) !== null && _params$unitId !== void 0 ? _params$unitId : (_instanceService$getC = instanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC)) === null || _instanceService$getC === void 0 ? void 0 : _instanceService$getC.getUnitId();
|
|
10229
|
+
if (unitId == null) return false;
|
|
10230
|
+
const renderObject = renderManagerService.getRenderById(unitId);
|
|
10231
|
+
if (renderObject == null) return false;
|
|
10232
|
+
const docSkeletonManagerService = renderObject.with(_univerjs_docs.DocSkeletonManagerService);
|
|
10233
|
+
const viewModel = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel();
|
|
10234
|
+
if (viewModel == null) return false;
|
|
10235
|
+
if (viewModel.getEditArea() === _univerjs_engine_render.DocumentEditArea.BODY) return false;
|
|
10236
|
+
const skeleton = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getSkeleton();
|
|
10237
|
+
if (skeleton == null) return false;
|
|
10238
|
+
const { scene } = renderObject;
|
|
10239
|
+
const transformer = scene.getTransformerByCreate();
|
|
10240
|
+
const docSelectionRenderService = renderObject.with(DocSelectionRenderService);
|
|
10241
|
+
docSelectionManagerService.replaceDocRanges([]);
|
|
10242
|
+
transformer.clearSelectedObjects();
|
|
10243
|
+
docSelectionRenderService.setSegment("");
|
|
10244
|
+
docSelectionRenderService.setSegmentPage(-1);
|
|
10245
|
+
viewModel.setEditArea(_univerjs_engine_render.DocumentEditArea.BODY);
|
|
10246
|
+
skeleton.calculate();
|
|
10247
|
+
(_renderObject$mainCom = renderObject.mainComponent) === null || _renderObject$mainCom === void 0 || _renderObject$mainCom.makeDirty(true);
|
|
10248
|
+
queueMicrotask(() => {
|
|
10249
|
+
const docDataModel = instanceService.getUnit(unitId);
|
|
10250
|
+
const snapshot = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot();
|
|
10251
|
+
if (snapshot == null) return;
|
|
10252
|
+
const offset = findFirstCursorOffset(snapshot);
|
|
10253
|
+
docSelectionManagerService.replaceDocRanges([{
|
|
10254
|
+
startOffset: offset,
|
|
10255
|
+
endOffset: offset
|
|
10256
|
+
}]);
|
|
10257
|
+
});
|
|
10258
|
+
commandService.executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "close" });
|
|
10259
|
+
return true;
|
|
10134
10260
|
}
|
|
10135
10261
|
};
|
|
10136
10262
|
|
|
10137
10263
|
//#endregion
|
|
10138
|
-
//#region src/controllers/doc-
|
|
10139
|
-
const HEADER_FOOTER_STROKE_COLOR = "rgba(58, 96, 247, 1)";
|
|
10140
|
-
const HEADER_FOOTER_FILL_COLOR = "rgba(58, 96, 247, 0.08)";
|
|
10141
|
-
function checkCreateHeaderFooterType(viewModel, editArea, segmentPage) {
|
|
10142
|
-
const { documentStyle } = viewModel.getDataModel().getSnapshot();
|
|
10143
|
-
const { defaultHeaderId, defaultFooterId, evenPageHeaderId, evenPageFooterId, firstPageHeaderId, firstPageFooterId, evenAndOddHeaders, useFirstPageHeaderFooter } = documentStyle;
|
|
10144
|
-
switch (editArea) {
|
|
10145
|
-
case _univerjs_engine_render.DocumentEditArea.BODY: return {
|
|
10146
|
-
createType: null,
|
|
10147
|
-
headerFooterId: null
|
|
10148
|
-
};
|
|
10149
|
-
case _univerjs_engine_render.DocumentEditArea.HEADER:
|
|
10150
|
-
if (useFirstPageHeaderFooter === _univerjs_core.BooleanNumber.TRUE && !firstPageHeaderId) return {
|
|
10151
|
-
createType: 0,
|
|
10152
|
-
headerFooterId: null
|
|
10153
|
-
};
|
|
10154
|
-
if (evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE && segmentPage % 2 === 0 && !evenPageHeaderId) return {
|
|
10155
|
-
createType: 4,
|
|
10156
|
-
headerFooterId: null
|
|
10157
|
-
};
|
|
10158
|
-
return defaultHeaderId ? {
|
|
10159
|
-
createType: null,
|
|
10160
|
-
headerFooterId: defaultHeaderId
|
|
10161
|
-
} : {
|
|
10162
|
-
createType: 2,
|
|
10163
|
-
headerFooterId: null
|
|
10164
|
-
};
|
|
10165
|
-
case _univerjs_engine_render.DocumentEditArea.FOOTER:
|
|
10166
|
-
if (useFirstPageHeaderFooter === _univerjs_core.BooleanNumber.TRUE && !firstPageFooterId) return {
|
|
10167
|
-
createType: 1,
|
|
10168
|
-
headerFooterId: null
|
|
10169
|
-
};
|
|
10170
|
-
if (evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE && segmentPage % 2 === 0 && !evenPageFooterId) return {
|
|
10171
|
-
createType: 5,
|
|
10172
|
-
headerFooterId: null
|
|
10173
|
-
};
|
|
10174
|
-
return defaultFooterId ? {
|
|
10175
|
-
createType: null,
|
|
10176
|
-
headerFooterId: defaultFooterId
|
|
10177
|
-
} : {
|
|
10178
|
-
createType: 3,
|
|
10179
|
-
headerFooterId: null
|
|
10180
|
-
};
|
|
10181
|
-
default: throw new Error(`Invalid editArea: ${editArea}`);
|
|
10182
|
-
}
|
|
10183
|
-
}
|
|
10184
|
-
let DocHeaderFooterController = class DocHeaderFooterController extends _univerjs_core.Disposable {
|
|
10185
|
-
constructor(_context, _commandService, _editorService, _instanceSrv, _renderManagerService, _docSkeletonManagerService, _docSelectionRenderService, _localeService) {
|
|
10186
|
-
super();
|
|
10187
|
-
this._context = _context;
|
|
10188
|
-
this._commandService = _commandService;
|
|
10189
|
-
this._editorService = _editorService;
|
|
10190
|
-
this._instanceSrv = _instanceSrv;
|
|
10191
|
-
this._renderManagerService = _renderManagerService;
|
|
10192
|
-
this._docSkeletonManagerService = _docSkeletonManagerService;
|
|
10193
|
-
this._docSelectionRenderService = _docSelectionRenderService;
|
|
10194
|
-
this._localeService = _localeService;
|
|
10195
|
-
_defineProperty(this, "_loadedMap", /* @__PURE__ */ new WeakSet());
|
|
10196
|
-
this._initialize();
|
|
10197
|
-
}
|
|
10198
|
-
_initialize() {
|
|
10199
|
-
this._init();
|
|
10200
|
-
this._drawHeaderFooterLabel();
|
|
10201
|
-
this._listenSwitchMode();
|
|
10202
|
-
}
|
|
10203
|
-
dispose() {
|
|
10204
|
-
super.dispose();
|
|
10205
|
-
}
|
|
10206
|
-
_listenSwitchMode() {
|
|
10207
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
10208
|
-
if (_univerjs_docs.RichTextEditingMutation.id === command.id) {
|
|
10209
|
-
const docDataModel = this._context.unit;
|
|
10210
|
-
const editArea = this._docSkeletonManagerService.getViewModel().getEditArea();
|
|
10211
|
-
const documentFlavor = docDataModel.getSnapshot().documentStyle.documentFlavor;
|
|
10212
|
-
if (editArea !== _univerjs_engine_render.DocumentEditArea.BODY && documentFlavor === _univerjs_core.DocumentFlavor.MODERN) this._commandService.executeCommand(CloseHeaderFooterCommand.id, { unitId: this._context.unitId });
|
|
10213
|
-
}
|
|
10214
|
-
}));
|
|
10215
|
-
}
|
|
10216
|
-
_init() {
|
|
10217
|
-
const { unitId } = this._context;
|
|
10218
|
-
const docObject = neoGetDocObject(this._context);
|
|
10219
|
-
if (docObject == null || docObject.document == null) return;
|
|
10220
|
-
if (!this._loadedMap.has(docObject.document)) {
|
|
10221
|
-
this._initialMain(unitId);
|
|
10222
|
-
this._loadedMap.add(docObject.document);
|
|
10223
|
-
}
|
|
10224
|
-
}
|
|
10225
|
-
_initialMain(unitId) {
|
|
10226
|
-
const { document } = neoGetDocObject(this._context);
|
|
10227
|
-
this.disposeWithMe(document.onDblclick$.subscribeEvent(async (evt) => {
|
|
10228
|
-
if (this._isEditorReadOnly(unitId)) return;
|
|
10229
|
-
if (!this._isTraditionalMode()) return;
|
|
10230
|
-
const { offsetX, offsetY } = evt;
|
|
10231
|
-
const { pageLayoutType = _univerjs_engine_render.PageLayoutType.VERTICAL, pageMarginLeft, pageMarginTop } = document.getOffsetConfig();
|
|
10232
|
-
const coord = this._getTransformCoordForDocumentOffset(offsetX, offsetY);
|
|
10233
|
-
if (coord == null) return;
|
|
10234
|
-
const viewModel = this._docSkeletonManagerService.getViewModel();
|
|
10235
|
-
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
10236
|
-
const preEditArea = viewModel.getEditArea();
|
|
10237
|
-
const { editArea, pageNumber } = skeleton.findEditAreaByCoord(coord, pageLayoutType, pageMarginLeft, pageMarginTop);
|
|
10238
|
-
if (preEditArea === editArea) return;
|
|
10239
|
-
viewModel.setEditArea(editArea);
|
|
10240
|
-
const { createType, headerFooterId } = checkCreateHeaderFooterType(viewModel, editArea, pageNumber);
|
|
10241
|
-
if (editArea === _univerjs_engine_render.DocumentEditArea.BODY) {
|
|
10242
|
-
this._docSelectionRenderService.setSegment("");
|
|
10243
|
-
this._docSelectionRenderService.setSegmentPage(-1);
|
|
10244
|
-
this._docSelectionRenderService.setCursorManually(offsetX, offsetY);
|
|
10245
|
-
} else if (createType != null) {
|
|
10246
|
-
const segmentId = (0, _univerjs_core.generateRandomId)(6);
|
|
10247
|
-
this._docSelectionRenderService.setSegment(segmentId);
|
|
10248
|
-
this._docSelectionRenderService.setSegmentPage(pageNumber);
|
|
10249
|
-
await this._commandService.executeCommand(CoreHeaderFooterCommand.id, {
|
|
10250
|
-
unitId,
|
|
10251
|
-
createType,
|
|
10252
|
-
segmentId
|
|
10253
|
-
});
|
|
10254
|
-
} else if (headerFooterId != null) {
|
|
10255
|
-
this._docSelectionRenderService.setSegment(headerFooterId);
|
|
10256
|
-
this._docSelectionRenderService.setSegmentPage(pageNumber);
|
|
10257
|
-
this._docSelectionRenderService.setCursorManually(offsetX, offsetY);
|
|
10258
|
-
}
|
|
10259
|
-
}));
|
|
10260
|
-
}
|
|
10261
|
-
_getTransformCoordForDocumentOffset(evtOffsetX, evtOffsetY) {
|
|
10262
|
-
const { document, scene } = neoGetDocObject(this._context);
|
|
10263
|
-
const { documentTransform } = document.getOffsetConfig();
|
|
10264
|
-
const activeViewport = scene.getViewports()[0];
|
|
10265
|
-
if (activeViewport == null) return;
|
|
10266
|
-
const originCoord = activeViewport.transformVector2SceneCoord(_univerjs_engine_render.Vector2.FromArray([evtOffsetX, evtOffsetY]));
|
|
10267
|
-
return documentTransform.clone().invert().applyPoint(originCoord);
|
|
10268
|
-
}
|
|
10269
|
-
_drawHeaderFooterLabel() {
|
|
10270
|
-
const localeService = this._localeService;
|
|
10271
|
-
this.disposeWithMe(this._instanceSrv.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC).subscribe((unit) => {
|
|
10272
|
-
if (unit == null) return;
|
|
10273
|
-
const unitId = unit.getUnitId();
|
|
10274
|
-
const currentRender = this._renderManagerService.getRenderById(unitId);
|
|
10275
|
-
if (this._editorService.isEditor(unitId) || this._instanceSrv.getUniverDocInstance(unitId) == null) return;
|
|
10276
|
-
if (currentRender == null) return;
|
|
10277
|
-
const { mainComponent } = currentRender;
|
|
10278
|
-
const docsComponent = mainComponent;
|
|
10279
|
-
this.disposeWithMe((0, _univerjs_core.toDisposable)(docsComponent.pageRender$.subscribe((config) => {
|
|
10280
|
-
if (this._editorService.isEditor(unitId)) return;
|
|
10281
|
-
if (!this._isTraditionalMode()) return;
|
|
10282
|
-
const isEditBody = this._docSkeletonManagerService.getViewModel().getEditArea() === _univerjs_engine_render.DocumentEditArea.BODY;
|
|
10283
|
-
const { page, pageLeft, pageTop, ctx } = config;
|
|
10284
|
-
const { pageWidth, pageHeight, marginTop, marginBottom } = page;
|
|
10285
|
-
ctx.save();
|
|
10286
|
-
ctx.translate(pageLeft - .5, pageTop - .5);
|
|
10287
|
-
if (isEditBody) {
|
|
10288
|
-
_univerjs_engine_render.Rect.drawWith(ctx, {
|
|
10289
|
-
left: 0,
|
|
10290
|
-
top: 0,
|
|
10291
|
-
width: pageWidth,
|
|
10292
|
-
height: marginTop,
|
|
10293
|
-
fill: "rgba(255, 255, 255, 0.5)"
|
|
10294
|
-
});
|
|
10295
|
-
ctx.save();
|
|
10296
|
-
ctx.translate(0, pageHeight - marginBottom);
|
|
10297
|
-
_univerjs_engine_render.Rect.drawWith(ctx, {
|
|
10298
|
-
left: 0,
|
|
10299
|
-
top: 0,
|
|
10300
|
-
width: pageWidth,
|
|
10301
|
-
height: marginBottom,
|
|
10302
|
-
fill: "rgba(255, 255, 255, 0.5)"
|
|
10303
|
-
});
|
|
10304
|
-
ctx.restore();
|
|
10305
|
-
} else {
|
|
10306
|
-
ctx.save();
|
|
10307
|
-
ctx.translate(0, marginTop);
|
|
10308
|
-
_univerjs_engine_render.Rect.drawWith(ctx, {
|
|
10309
|
-
left: 0,
|
|
10310
|
-
top: marginTop,
|
|
10311
|
-
width: pageWidth,
|
|
10312
|
-
height: pageHeight - marginTop - marginBottom,
|
|
10313
|
-
fill: "rgba(255, 255, 255, 0.5)"
|
|
10314
|
-
});
|
|
10315
|
-
ctx.restore();
|
|
10316
|
-
}
|
|
10317
|
-
if (!isEditBody) {
|
|
10318
|
-
const headerPathConfigIPathProps = {
|
|
10319
|
-
dataArray: [{
|
|
10320
|
-
command: "M",
|
|
10321
|
-
points: [0, marginTop]
|
|
10322
|
-
}, {
|
|
10323
|
-
command: "L",
|
|
10324
|
-
points: [pageWidth, marginTop]
|
|
10325
|
-
}],
|
|
10326
|
-
strokeWidth: 1,
|
|
10327
|
-
stroke: HEADER_FOOTER_STROKE_COLOR
|
|
10328
|
-
};
|
|
10329
|
-
const footerPathConfigIPathProps = {
|
|
10330
|
-
dataArray: [{
|
|
10331
|
-
command: "M",
|
|
10332
|
-
points: [0, pageHeight - marginBottom]
|
|
10333
|
-
}, {
|
|
10334
|
-
command: "L",
|
|
10335
|
-
points: [pageWidth, pageHeight - marginBottom]
|
|
10336
|
-
}],
|
|
10337
|
-
strokeWidth: 1,
|
|
10338
|
-
stroke: HEADER_FOOTER_STROKE_COLOR
|
|
10339
|
-
};
|
|
10340
|
-
_univerjs_engine_render.Path.drawWith(ctx, headerPathConfigIPathProps);
|
|
10341
|
-
_univerjs_engine_render.Path.drawWith(ctx, footerPathConfigIPathProps);
|
|
10342
|
-
ctx.translate(0, marginTop + 1);
|
|
10343
|
-
TextBubbleShape.drawWith(ctx, {
|
|
10344
|
-
text: localeService.t("docs-ui.headerFooter.header"),
|
|
10345
|
-
color: HEADER_FOOTER_FILL_COLOR
|
|
10346
|
-
});
|
|
10347
|
-
ctx.translate(0, pageHeight - marginTop - marginBottom);
|
|
10348
|
-
TextBubbleShape.drawWith(ctx, {
|
|
10349
|
-
text: localeService.t("docs-ui.headerFooter.footer"),
|
|
10350
|
-
color: HEADER_FOOTER_FILL_COLOR
|
|
10351
|
-
});
|
|
10352
|
-
}
|
|
10353
|
-
ctx.restore();
|
|
10354
|
-
})));
|
|
10355
|
-
}));
|
|
10356
|
-
}
|
|
10357
|
-
_isEditorReadOnly(unitId) {
|
|
10358
|
-
const editor = this._editorService.getEditor(unitId);
|
|
10359
|
-
if (!editor) return false;
|
|
10360
|
-
return editor.isReadOnly();
|
|
10361
|
-
}
|
|
10362
|
-
_isTraditionalMode() {
|
|
10363
|
-
return this._context.unit.getSnapshot().documentStyle.documentFlavor === _univerjs_core.DocumentFlavor.TRADITIONAL;
|
|
10364
|
-
}
|
|
10365
|
-
};
|
|
10366
|
-
DocHeaderFooterController = __decorate([
|
|
10367
|
-
__decorateParam(1, _univerjs_core.ICommandService),
|
|
10368
|
-
__decorateParam(2, IEditorService),
|
|
10369
|
-
__decorateParam(3, _univerjs_core.IUniverInstanceService),
|
|
10370
|
-
__decorateParam(4, _univerjs_engine_render.IRenderManagerService),
|
|
10371
|
-
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_docs.DocSkeletonManagerService)),
|
|
10372
|
-
__decorateParam(6, (0, _univerjs_core.Inject)(DocSelectionRenderService)),
|
|
10373
|
-
__decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService))
|
|
10374
|
-
], DocHeaderFooterController);
|
|
10375
|
-
|
|
10376
|
-
//#endregion
|
|
10377
|
-
//#region src/views/header-footer/panel/component-name.ts
|
|
10264
|
+
//#region src/controllers/doc-paragraph-setting.controller.ts
|
|
10378
10265
|
/**
|
|
10379
10266
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
10380
10267
|
*
|
|
@@ -10390,261 +10277,36 @@ DocHeaderFooterController = __decorate([
|
|
|
10390
10277
|
* See the License for the specific language governing permissions and
|
|
10391
10278
|
* limitations under the License.
|
|
10392
10279
|
*/
|
|
10393
|
-
const
|
|
10280
|
+
const paragraphSettingIndexKey$1 = "doc_ui_paragraph-setting-panel";
|
|
10281
|
+
let DocParagraphSettingController = class DocParagraphSettingController extends _univerjs_core.Disposable {
|
|
10282
|
+
constructor(_commandService, _sidebarService) {
|
|
10283
|
+
super();
|
|
10284
|
+
this._commandService = _commandService;
|
|
10285
|
+
this._sidebarService = _sidebarService;
|
|
10286
|
+
_defineProperty(this, "_id", void 0);
|
|
10287
|
+
}
|
|
10288
|
+
openPanel() {
|
|
10289
|
+
const props = {
|
|
10290
|
+
header: { title: "docs-ui.doc.slider.paragraphSetting" },
|
|
10291
|
+
id: this._id,
|
|
10292
|
+
children: { label: paragraphSettingIndexKey$1 },
|
|
10293
|
+
width: 300
|
|
10294
|
+
};
|
|
10295
|
+
this._sidebarService.open(props);
|
|
10296
|
+
}
|
|
10297
|
+
closePanel() {
|
|
10298
|
+
this._sidebarService.close(this._id);
|
|
10299
|
+
}
|
|
10300
|
+
};
|
|
10301
|
+
DocParagraphSettingController = __decorate([__decorateParam(0, _univerjs_core.ICommandService), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService))], DocParagraphSettingController);
|
|
10394
10302
|
|
|
10395
10303
|
//#endregion
|
|
10396
|
-
//#region src/commands/operations/doc-
|
|
10397
|
-
const
|
|
10398
|
-
id: "sidebar.operation.doc-
|
|
10304
|
+
//#region src/commands/operations/doc-paragraph-setting-panel.operation.ts
|
|
10305
|
+
const DocParagraphSettingPanelOperation = {
|
|
10306
|
+
id: "sidebar.operation.doc-paragraph-setting-panel",
|
|
10399
10307
|
type: _univerjs_core.CommandType.OPERATION,
|
|
10400
|
-
handler:
|
|
10401
|
-
|
|
10402
|
-
const localeService = accessor.get(_univerjs_core.LocaleService);
|
|
10403
|
-
switch (params.value) {
|
|
10404
|
-
case "open":
|
|
10405
|
-
sidebarService.open({
|
|
10406
|
-
header: { title: localeService.t("docs-ui.headerFooter.panel") },
|
|
10407
|
-
children: { label: COMPONENT_DOC_HEADER_FOOTER_PANEL },
|
|
10408
|
-
onClose: () => {},
|
|
10409
|
-
width: 400
|
|
10410
|
-
});
|
|
10411
|
-
break;
|
|
10412
|
-
default:
|
|
10413
|
-
sidebarService.close();
|
|
10414
|
-
break;
|
|
10415
|
-
}
|
|
10416
|
-
return true;
|
|
10417
|
-
}
|
|
10418
|
-
};
|
|
10419
|
-
|
|
10420
|
-
//#endregion
|
|
10421
|
-
//#region src/commands/commands/doc-header-footer.command.ts
|
|
10422
|
-
function getEmptyHeaderFooterBody() {
|
|
10423
|
-
return {
|
|
10424
|
-
dataStream: "\r\n",
|
|
10425
|
-
textRuns: [{
|
|
10426
|
-
st: 0,
|
|
10427
|
-
ed: 0,
|
|
10428
|
-
ts: { fs: 9 }
|
|
10429
|
-
}],
|
|
10430
|
-
customBlocks: [],
|
|
10431
|
-
paragraphs: [{
|
|
10432
|
-
startIndex: 0,
|
|
10433
|
-
paragraphId: (0, _univerjs_core.createParagraphId)(/* @__PURE__ */ new Set()),
|
|
10434
|
-
paragraphStyle: {
|
|
10435
|
-
spaceAbove: { v: 0 },
|
|
10436
|
-
lineSpacing: 1.5,
|
|
10437
|
-
spaceBelow: { v: 0 }
|
|
10438
|
-
}
|
|
10439
|
-
}],
|
|
10440
|
-
sectionBreaks: [{ startIndex: 1 }]
|
|
10441
|
-
};
|
|
10442
|
-
}
|
|
10443
|
-
function createHeaderFooterAction(segmentId, createType, documentStyle, actions) {
|
|
10444
|
-
const jsonX = _univerjs_core.JSONX.getInstance();
|
|
10445
|
-
const ID_LEN = 6;
|
|
10446
|
-
const firstSegmentId = segmentId !== null && segmentId !== void 0 ? segmentId : (0, _univerjs_core.generateRandomId)(ID_LEN);
|
|
10447
|
-
const isHeader = createType === 2 || createType === 0 || createType === 4;
|
|
10448
|
-
const insertAction = jsonX.insertOp([isHeader ? "headers" : "footers", firstSegmentId], {
|
|
10449
|
-
[isHeader ? "headerId" : "footerId"]: firstSegmentId,
|
|
10450
|
-
body: getEmptyHeaderFooterBody()
|
|
10451
|
-
});
|
|
10452
|
-
actions.push(insertAction);
|
|
10453
|
-
const secondSegmentId = (0, _univerjs_core.generateRandomId)(ID_LEN);
|
|
10454
|
-
const insertPairAction = jsonX.insertOp([isHeader ? "footers" : "headers", secondSegmentId], {
|
|
10455
|
-
[isHeader ? "footerId" : "headerId"]: secondSegmentId,
|
|
10456
|
-
body: getEmptyHeaderFooterBody()
|
|
10457
|
-
});
|
|
10458
|
-
actions.push(insertPairAction);
|
|
10459
|
-
let key = "defaultHeaderId";
|
|
10460
|
-
let pairKey = "defaultFooterId";
|
|
10461
|
-
switch (createType) {
|
|
10462
|
-
case 2:
|
|
10463
|
-
key = "defaultHeaderId";
|
|
10464
|
-
pairKey = "defaultFooterId";
|
|
10465
|
-
break;
|
|
10466
|
-
case 3:
|
|
10467
|
-
key = "defaultFooterId";
|
|
10468
|
-
pairKey = "defaultHeaderId";
|
|
10469
|
-
break;
|
|
10470
|
-
case 0:
|
|
10471
|
-
key = "firstPageHeaderId";
|
|
10472
|
-
pairKey = "firstPageFooterId";
|
|
10473
|
-
break;
|
|
10474
|
-
case 1:
|
|
10475
|
-
key = "firstPageFooterId";
|
|
10476
|
-
pairKey = "firstPageHeaderId";
|
|
10477
|
-
break;
|
|
10478
|
-
case 4:
|
|
10479
|
-
key = "evenPageHeaderId";
|
|
10480
|
-
pairKey = "evenPageFooterId";
|
|
10481
|
-
break;
|
|
10482
|
-
case 5:
|
|
10483
|
-
key = "evenPageFooterId";
|
|
10484
|
-
pairKey = "evenPageHeaderId";
|
|
10485
|
-
break;
|
|
10486
|
-
default: throw new Error(`Unknown header footer type: ${createType}`);
|
|
10487
|
-
}
|
|
10488
|
-
for (const [k, id] of [[key, firstSegmentId], [pairKey, secondSegmentId]]) if (documentStyle[k] != null) {
|
|
10489
|
-
const replaceAction = jsonX.replaceOp(["documentStyle", k], documentStyle[k], id);
|
|
10490
|
-
actions.push(replaceAction);
|
|
10491
|
-
} else {
|
|
10492
|
-
const insertAction = jsonX.insertOp(["documentStyle", k], id);
|
|
10493
|
-
actions.push(insertAction);
|
|
10494
|
-
}
|
|
10495
|
-
return actions;
|
|
10496
|
-
}
|
|
10497
|
-
const CoreHeaderFooterCommandId = "doc.command.core-header-footer";
|
|
10498
|
-
/**
|
|
10499
|
-
* The command to update header and footer or create them.
|
|
10500
|
-
*/
|
|
10501
|
-
const CoreHeaderFooterCommand = {
|
|
10502
|
-
id: CoreHeaderFooterCommandId,
|
|
10503
|
-
type: _univerjs_core.CommandType.COMMAND,
|
|
10504
|
-
handler: async (accessor, params) => {
|
|
10505
|
-
var _renderManagerService;
|
|
10506
|
-
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
10507
|
-
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
10508
|
-
const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
|
|
10509
|
-
const { unitId, segmentId, createType, headerFooterProps } = params;
|
|
10510
|
-
const docSkeletonManagerService = (_renderManagerService = renderManagerService.getRenderById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(_univerjs_docs.DocSkeletonManagerService);
|
|
10511
|
-
const docDataModel = univerInstanceService.getUniverDocInstance(unitId);
|
|
10512
|
-
const docViewModel = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel();
|
|
10513
|
-
if (docDataModel == null || docViewModel == null) return false;
|
|
10514
|
-
const editArea = docViewModel.getEditArea();
|
|
10515
|
-
const { documentStyle } = docDataModel.getSnapshot();
|
|
10516
|
-
const isUpdateMargin = (headerFooterProps === null || headerFooterProps === void 0 ? void 0 : headerFooterProps.marginFooter) != null || (headerFooterProps === null || headerFooterProps === void 0 ? void 0 : headerFooterProps.marginHeader) != null;
|
|
10517
|
-
const doMutation = {
|
|
10518
|
-
id: _univerjs_docs.RichTextEditingMutation.id,
|
|
10519
|
-
params: {
|
|
10520
|
-
unitId,
|
|
10521
|
-
actions: [],
|
|
10522
|
-
textRanges: [{
|
|
10523
|
-
startOffset: 0,
|
|
10524
|
-
endOffset: 0,
|
|
10525
|
-
collapsed: true
|
|
10526
|
-
}],
|
|
10527
|
-
debounce: true
|
|
10528
|
-
}
|
|
10529
|
-
};
|
|
10530
|
-
if (isUpdateMargin) doMutation.params.noNeedSetTextRange = true;
|
|
10531
|
-
const jsonX = _univerjs_core.JSONX.getInstance();
|
|
10532
|
-
const rawActions = [];
|
|
10533
|
-
if (createType != null) createHeaderFooterAction(segmentId, createType, documentStyle, rawActions);
|
|
10534
|
-
if (headerFooterProps != null) Object.keys(headerFooterProps).forEach((key) => {
|
|
10535
|
-
const value = headerFooterProps[key];
|
|
10536
|
-
const oldValue = documentStyle[key];
|
|
10537
|
-
if (value === oldValue) return;
|
|
10538
|
-
let action;
|
|
10539
|
-
if (oldValue === void 0) action = jsonX.insertOp(["documentStyle", key], value);
|
|
10540
|
-
else action = jsonX.replaceOp(["documentStyle", key], oldValue, value);
|
|
10541
|
-
rawActions.push(action);
|
|
10542
|
-
if (key === "useFirstPageHeaderFooter" && value === _univerjs_core.BooleanNumber.TRUE && !documentStyle.firstPageHeaderId) createHeaderFooterAction(segmentId, editArea === _univerjs_engine_render.DocumentEditArea.HEADER ? 0 : 1, documentStyle, rawActions);
|
|
10543
|
-
else if (key === "evenAndOddHeaders" && value === _univerjs_core.BooleanNumber.TRUE && !documentStyle.evenPageHeaderId) createHeaderFooterAction(segmentId, editArea === _univerjs_engine_render.DocumentEditArea.HEADER ? 4 : 5, documentStyle, rawActions);
|
|
10544
|
-
});
|
|
10545
|
-
if (rawActions.length === 0) return false;
|
|
10546
|
-
doMutation.params.actions = rawActions.reduce((acc, cur) => {
|
|
10547
|
-
return _univerjs_core.JSONX.compose(acc, cur);
|
|
10548
|
-
}, null);
|
|
10549
|
-
const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
10550
|
-
return Boolean(result);
|
|
10551
|
-
}
|
|
10552
|
-
};
|
|
10553
|
-
const OpenHeaderFooterPanelCommand = {
|
|
10554
|
-
id: "doc.command.open-header-footer-panel",
|
|
10555
|
-
type: _univerjs_core.CommandType.COMMAND,
|
|
10556
|
-
handler: async (accessor, _params) => {
|
|
10557
|
-
return accessor.get(_univerjs_core.ICommandService).executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "open" });
|
|
10558
|
-
}
|
|
10559
|
-
};
|
|
10560
|
-
const CloseHeaderFooterCommand = {
|
|
10561
|
-
id: "doc.command.close-header-footer",
|
|
10562
|
-
type: _univerjs_core.CommandType.COMMAND,
|
|
10563
|
-
handler: async (accessor, params) => {
|
|
10564
|
-
var _renderObject$mainCom;
|
|
10565
|
-
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
10566
|
-
const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
|
|
10567
|
-
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
10568
|
-
const instanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
10569
|
-
const { unitId } = params;
|
|
10570
|
-
const renderObject = renderManagerService.getRenderById(unitId);
|
|
10571
|
-
if (renderObject == null) return false;
|
|
10572
|
-
const { scene } = renderObject;
|
|
10573
|
-
const transformer = scene.getTransformerByCreate();
|
|
10574
|
-
const docSkeletonManagerService = renderObject.with(_univerjs_docs.DocSkeletonManagerService);
|
|
10575
|
-
const docSelectionRenderService = renderObject.with(DocSelectionRenderService);
|
|
10576
|
-
const skeleton = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getSkeleton();
|
|
10577
|
-
const viewModel = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel();
|
|
10578
|
-
if (viewModel == null || skeleton == null) return false;
|
|
10579
|
-
docSelectionManagerService.replaceDocRanges([]);
|
|
10580
|
-
transformer.clearSelectedObjects();
|
|
10581
|
-
docSelectionRenderService.setSegment("");
|
|
10582
|
-
docSelectionRenderService.setSegmentPage(-1);
|
|
10583
|
-
viewModel.setEditArea(_univerjs_engine_render.DocumentEditArea.BODY);
|
|
10584
|
-
skeleton.calculate();
|
|
10585
|
-
(_renderObject$mainCom = renderObject.mainComponent) === null || _renderObject$mainCom === void 0 || _renderObject$mainCom.makeDirty(true);
|
|
10586
|
-
queueMicrotask(() => {
|
|
10587
|
-
const docDataModel = instanceService.getUnit(unitId);
|
|
10588
|
-
const snapshot = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot();
|
|
10589
|
-
if (snapshot == null) return;
|
|
10590
|
-
const offset = findFirstCursorOffset(snapshot);
|
|
10591
|
-
docSelectionManagerService.replaceDocRanges([{
|
|
10592
|
-
startOffset: offset,
|
|
10593
|
-
endOffset: offset
|
|
10594
|
-
}]);
|
|
10595
|
-
});
|
|
10596
|
-
commandService.executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "close" });
|
|
10597
|
-
return true;
|
|
10598
|
-
}
|
|
10599
|
-
};
|
|
10600
|
-
|
|
10601
|
-
//#endregion
|
|
10602
|
-
//#region src/controllers/doc-paragraph-setting.controller.ts
|
|
10603
|
-
/**
|
|
10604
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
10605
|
-
*
|
|
10606
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10607
|
-
* you may not use this file except in compliance with the License.
|
|
10608
|
-
* You may obtain a copy of the License at
|
|
10609
|
-
*
|
|
10610
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10611
|
-
*
|
|
10612
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
10613
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10614
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10615
|
-
* See the License for the specific language governing permissions and
|
|
10616
|
-
* limitations under the License.
|
|
10617
|
-
*/
|
|
10618
|
-
const paragraphSettingIndexKey$1 = "doc_ui_paragraph-setting-panel";
|
|
10619
|
-
let DocParagraphSettingController = class DocParagraphSettingController extends _univerjs_core.Disposable {
|
|
10620
|
-
constructor(_commandService, _sidebarService) {
|
|
10621
|
-
super();
|
|
10622
|
-
this._commandService = _commandService;
|
|
10623
|
-
this._sidebarService = _sidebarService;
|
|
10624
|
-
_defineProperty(this, "_id", void 0);
|
|
10625
|
-
}
|
|
10626
|
-
openPanel() {
|
|
10627
|
-
const props = {
|
|
10628
|
-
header: { title: "docs-ui.doc.slider.paragraphSetting" },
|
|
10629
|
-
id: this._id,
|
|
10630
|
-
children: { label: paragraphSettingIndexKey$1 },
|
|
10631
|
-
width: 300
|
|
10632
|
-
};
|
|
10633
|
-
this._sidebarService.open(props);
|
|
10634
|
-
}
|
|
10635
|
-
closePanel() {
|
|
10636
|
-
this._sidebarService.close(this._id);
|
|
10637
|
-
}
|
|
10638
|
-
};
|
|
10639
|
-
DocParagraphSettingController = __decorate([__decorateParam(0, _univerjs_core.ICommandService), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService))], DocParagraphSettingController);
|
|
10640
|
-
|
|
10641
|
-
//#endregion
|
|
10642
|
-
//#region src/commands/operations/doc-paragraph-setting-panel.operation.ts
|
|
10643
|
-
const DocParagraphSettingPanelOperation = {
|
|
10644
|
-
id: "sidebar.operation.doc-paragraph-setting-panel",
|
|
10645
|
-
type: _univerjs_core.CommandType.OPERATION,
|
|
10646
|
-
handler: (accessor) => {
|
|
10647
|
-
accessor.get(DocParagraphSettingController).openPanel();
|
|
10308
|
+
handler: (accessor) => {
|
|
10309
|
+
accessor.get(DocParagraphSettingController).openPanel();
|
|
10648
10310
|
return true;
|
|
10649
10311
|
}
|
|
10650
10312
|
};
|
|
@@ -11050,8 +10712,8 @@ function notInTableSubscriber(subscriber, docSelectionManagerService, univerInst
|
|
|
11050
10712
|
subscriber.next(true);
|
|
11051
10713
|
return;
|
|
11052
10714
|
}
|
|
11053
|
-
const docDataModel = univerInstanceService.
|
|
11054
|
-
const tables = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.tables;
|
|
10715
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
10716
|
+
const tables = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 || (_docDataModel$getSelf = _docDataModel$getSelf.getBody()) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.tables;
|
|
11055
10717
|
if (tables && tables.length) {
|
|
11056
10718
|
if (tables.some((table) => {
|
|
11057
10719
|
const { startIndex, endIndex } = table;
|
|
@@ -11377,6 +11039,46 @@ function getInsertTableHiddenObservable(accessor) {
|
|
|
11377
11039
|
return () => subscription.unsubscribe();
|
|
11378
11040
|
});
|
|
11379
11041
|
}
|
|
11042
|
+
function disableMenuWhenHeaderFooterEditing(accessor) {
|
|
11043
|
+
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
11044
|
+
const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
|
|
11045
|
+
return new rxjs.Observable((subscriber) => {
|
|
11046
|
+
let editAreaSubscription = null;
|
|
11047
|
+
let lastDisabled;
|
|
11048
|
+
const emit = (disabled) => {
|
|
11049
|
+
if (disabled !== lastDisabled) {
|
|
11050
|
+
lastDisabled = disabled;
|
|
11051
|
+
subscriber.next(disabled);
|
|
11052
|
+
}
|
|
11053
|
+
};
|
|
11054
|
+
const emitByUnit = (unitId) => {
|
|
11055
|
+
editAreaSubscription === null || editAreaSubscription === void 0 || editAreaSubscription.unsubscribe();
|
|
11056
|
+
editAreaSubscription = null;
|
|
11057
|
+
if (!unitId || univerInstanceService.getUnitType(unitId) !== _univerjs_core.UniverInstanceType.UNIVER_DOC) {
|
|
11058
|
+
emit(true);
|
|
11059
|
+
return;
|
|
11060
|
+
}
|
|
11061
|
+
const currentRender = renderManagerService.getRenderById(unitId);
|
|
11062
|
+
const skeletonManager = currentRender === null || currentRender === void 0 ? void 0 : currentRender.with(_univerjs_docs.DocSkeletonManagerService);
|
|
11063
|
+
const viewModel = skeletonManager === null || skeletonManager === void 0 ? void 0 : skeletonManager.getViewModel();
|
|
11064
|
+
if (!viewModel) {
|
|
11065
|
+
emit(true);
|
|
11066
|
+
return;
|
|
11067
|
+
}
|
|
11068
|
+
const emitDisabled = (editArea) => {
|
|
11069
|
+
const currentEditArea = editArea !== null && editArea !== void 0 ? editArea : viewModel.getEditArea();
|
|
11070
|
+
emit(currentEditArea === _univerjs_engine_render.DocumentEditArea.HEADER || currentEditArea === _univerjs_engine_render.DocumentEditArea.FOOTER);
|
|
11071
|
+
};
|
|
11072
|
+
emitDisabled();
|
|
11073
|
+
editAreaSubscription = viewModel.editAreaChange$.subscribe(emitDisabled);
|
|
11074
|
+
};
|
|
11075
|
+
const focusedSubscription = univerInstanceService.focused$.subscribe(emitByUnit);
|
|
11076
|
+
return () => {
|
|
11077
|
+
editAreaSubscription === null || editAreaSubscription === void 0 || editAreaSubscription.unsubscribe();
|
|
11078
|
+
focusedSubscription.unsubscribe();
|
|
11079
|
+
};
|
|
11080
|
+
});
|
|
11081
|
+
}
|
|
11380
11082
|
function getHeaderFooterMenuHiddenObservable(accessor) {
|
|
11381
11083
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
11382
11084
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
@@ -11395,11 +11097,11 @@ function getHeaderFooterMenuHiddenObservable(accessor) {
|
|
|
11395
11097
|
});
|
|
11396
11098
|
const subscription = univerInstanceService.focused$.subscribe((unitId) => {
|
|
11397
11099
|
if (unitId == null) return subscriber.next(true);
|
|
11398
|
-
const docDataModel = univerInstanceService.
|
|
11100
|
+
const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
11399
11101
|
const documentFlavor = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot().documentStyle.documentFlavor;
|
|
11400
11102
|
subscriber.next(documentFlavor !== _univerjs_core.DocumentFlavor.TRADITIONAL);
|
|
11401
11103
|
});
|
|
11402
|
-
const docDataModel = univerInstanceService.
|
|
11104
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
11403
11105
|
if (docDataModel == null) return subscriber.next(true);
|
|
11404
11106
|
const documentFlavor = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot().documentStyle.documentFlavor;
|
|
11405
11107
|
subscriber.next(documentFlavor !== _univerjs_core.DocumentFlavor.TRADITIONAL);
|
|
@@ -11428,7 +11130,7 @@ function getTableDisabledObservable(accessor) {
|
|
|
11428
11130
|
subscriber.next(true);
|
|
11429
11131
|
return;
|
|
11430
11132
|
}
|
|
11431
|
-
const docDataModel = univerInstanceService.
|
|
11133
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
11432
11134
|
if (docDataModel == null) {
|
|
11433
11135
|
subscriber.next(true);
|
|
11434
11136
|
return;
|
|
@@ -12151,14 +11853,14 @@ const listValueFactory$ = (accessor) => {
|
|
|
12151
11853
|
const subscription = univerInstanceService.focused$.subscribe((unitId) => {
|
|
12152
11854
|
var _docRanges$find;
|
|
12153
11855
|
if (unitId == null) return;
|
|
12154
|
-
const docDataModel = univerInstanceService.
|
|
11856
|
+
const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
12155
11857
|
if (docDataModel == null) return;
|
|
12156
11858
|
const docRanges = docSelectionManagerService.getDocRanges();
|
|
12157
11859
|
const range = (_docRanges$find = docRanges.find((r) => r.isActive)) !== null && _docRanges$find !== void 0 ? _docRanges$find : docRanges[0];
|
|
12158
11860
|
if (range) {
|
|
12159
11861
|
var _doc$getBody$paragrap, _doc$getBody, _doc$getBody$dataStre, _doc$getBody2;
|
|
12160
11862
|
const doc = docDataModel.getSelfOrHeaderFooterModel(range === null || range === void 0 ? void 0 : range.segmentId);
|
|
12161
|
-
const paragraphs = _univerjs_core.BuildTextUtils.range.getParagraphsInRange(range, (_doc$getBody$paragrap = (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.paragraphs) !== null && _doc$getBody$paragrap !== void 0 ? _doc$getBody$paragrap : [], (_doc$getBody$dataStre = (_doc$getBody2 = doc.getBody()) === null || _doc$getBody2 === void 0 ? void 0 : _doc$getBody2.dataStream) !== null && _doc$getBody$dataStre !== void 0 ? _doc$getBody$dataStre : "");
|
|
11863
|
+
const paragraphs = _univerjs_core.BuildTextUtils.range.getParagraphsInRange(range, (_doc$getBody$paragrap = doc === null || doc === void 0 || (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.paragraphs) !== null && _doc$getBody$paragrap !== void 0 ? _doc$getBody$paragrap : [], (_doc$getBody$dataStre = doc === null || doc === void 0 || (_doc$getBody2 = doc.getBody()) === null || _doc$getBody2 === void 0 ? void 0 : _doc$getBody2.dataStream) !== null && _doc$getBody$dataStre !== void 0 ? _doc$getBody$dataStre : "");
|
|
12162
11864
|
let listType;
|
|
12163
11865
|
if (paragraphs.every((p) => {
|
|
12164
11866
|
if (!listType) {
|
|
@@ -12318,7 +12020,7 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
|
|
|
12318
12020
|
};
|
|
12319
12021
|
}
|
|
12320
12022
|
function getFontStyleAtCursor(accessor) {
|
|
12321
|
-
var _docRanges$find2, _docMenuStyleService$, _paragraph$paragraphS11, _paragraph$paragraphS12;
|
|
12023
|
+
var _docRanges$find2, _docMenuStyleService$, _paragraph$paragraphS11, _paragraph$paragraphS12, _docDataModel$getSelf;
|
|
12322
12024
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
12323
12025
|
const textSelectionService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
12324
12026
|
const docMenuStyleService = accessor.get(DocMenuStyleService);
|
|
@@ -12335,7 +12037,7 @@ function getFontStyleAtCursor(accessor) {
|
|
|
12335
12037
|
...cacheStyle
|
|
12336
12038
|
} };
|
|
12337
12039
|
const { segmentId } = activeRange;
|
|
12338
|
-
const body = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
12040
|
+
const body = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
12339
12041
|
if (body == null) return { ts: {
|
|
12340
12042
|
...defaultTextStyle,
|
|
12341
12043
|
...namedStyle,
|
|
@@ -12351,15 +12053,15 @@ function getFontStyleAtCursor(accessor) {
|
|
|
12351
12053
|
} };
|
|
12352
12054
|
}
|
|
12353
12055
|
function getParagraphStyleAtCursor(accessor) {
|
|
12354
|
-
var _docRanges$find3, _docDataModel$
|
|
12056
|
+
var _docRanges$find3, _docDataModel$getSelf2;
|
|
12355
12057
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
12356
12058
|
const textSelectionService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
12357
|
-
const docDataModel = univerInstanceService.
|
|
12059
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
12358
12060
|
const docRanges = textSelectionService.getDocRanges();
|
|
12359
12061
|
const activeRange = (_docRanges$find3 = docRanges.find((r) => r.isActive)) !== null && _docRanges$find3 !== void 0 ? _docRanges$find3 : docRanges[0];
|
|
12360
12062
|
if (docDataModel == null || activeRange == null) return;
|
|
12361
12063
|
const { startOffset, segmentId } = activeRange;
|
|
12362
|
-
const paragraphs = (_docDataModel$
|
|
12064
|
+
const paragraphs = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 || (_docDataModel$getSelf2 = _docDataModel$getSelf2.getBody()) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.paragraphs;
|
|
12363
12065
|
if (paragraphs == null) return;
|
|
12364
12066
|
let prevIndex = -1;
|
|
12365
12067
|
for (const paragraph of paragraphs) {
|
|
@@ -15121,7 +14823,7 @@ DocUIController = __decorate([
|
|
|
15121
14823
|
//#endregion
|
|
15122
14824
|
//#region package.json
|
|
15123
14825
|
var name = "@univerjs/docs-ui";
|
|
15124
|
-
var version = "1.0.0-alpha.
|
|
14826
|
+
var version = "1.0.0-alpha.2";
|
|
15125
14827
|
|
|
15126
14828
|
//#endregion
|
|
15127
14829
|
//#region src/commands/commands/doc-paragraph-setting.command.ts
|
|
@@ -15139,8 +14841,8 @@ const DocParagraphSettingCommand = {
|
|
|
15139
14841
|
const segmentId = docRanges[0].segmentId;
|
|
15140
14842
|
const unitId = docDataModel.getUnitId();
|
|
15141
14843
|
const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
|
|
15142
|
-
const allParagraphs = (_segment$getBody$para = (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [];
|
|
15143
|
-
const dataStream = (_segment$getBody$data = (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "";
|
|
14844
|
+
const allParagraphs = (_segment$getBody$para = segment === null || segment === void 0 || (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [];
|
|
14845
|
+
const dataStream = (_segment$getBody$data = segment === null || segment === void 0 || (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "";
|
|
15144
14846
|
const paragraphs = (_BuildTextUtils$range = _univerjs_core.BuildTextUtils.range.getParagraphsInRanges(docRanges, allParagraphs, dataStream)) !== null && _BuildTextUtils$range !== void 0 ? _BuildTextUtils$range : [];
|
|
15145
14847
|
const doMutation = {
|
|
15146
14848
|
id: _univerjs_docs.RichTextEditingMutation.id,
|
|
@@ -15211,7 +14913,7 @@ const DocHeaderFooterOptions = (props) => {
|
|
|
15211
14913
|
...prev,
|
|
15212
14914
|
[type]: val ? _univerjs_core.BooleanNumber.TRUE : _univerjs_core.BooleanNumber.FALSE
|
|
15213
14915
|
}));
|
|
15214
|
-
const docDataModel = univerInstanceService.
|
|
14916
|
+
const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
15215
14917
|
const documentStyle = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot().documentStyle;
|
|
15216
14918
|
const docSkeletonManagerService = (_renderManagerService = renderManagerService.getRenderById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(_univerjs_docs.DocSkeletonManagerService);
|
|
15217
14919
|
const viewModel = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel();
|
|
@@ -15269,7 +14971,7 @@ const DocHeaderFooterOptions = (props) => {
|
|
|
15269
14971
|
commandService.executeCommand(CloseHeaderFooterCommand.id, { unitId });
|
|
15270
14972
|
};
|
|
15271
14973
|
(0, react.useEffect)(() => {
|
|
15272
|
-
const docDataModel = univerInstanceService.
|
|
14974
|
+
const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
15273
14975
|
const documentStyle = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot().documentStyle;
|
|
15274
14976
|
if (documentStyle) {
|
|
15275
14977
|
const { marginHeader = 0, marginFooter = 0, useFirstPageHeaderFooter = _univerjs_core.BooleanNumber.FALSE, evenAndOddHeaders = _univerjs_core.BooleanNumber.FALSE } = documentStyle;
|
|
@@ -15339,8 +15041,8 @@ const DocHeaderFooterPanel = () => {
|
|
|
15339
15041
|
var _renderManagerService;
|
|
15340
15042
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
15341
15043
|
const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
|
|
15342
|
-
const unitId = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService).
|
|
15343
|
-
const viewModel = ((_renderManagerService = renderManagerService.
|
|
15044
|
+
const unitId = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService).getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC).getUnitId();
|
|
15045
|
+
const viewModel = ((_renderManagerService = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(_univerjs_docs.DocSkeletonManagerService)).getViewModel();
|
|
15344
15046
|
const [isEditHeaderFooter, setIsEditHeaderFooter] = (0, react.useState)(true);
|
|
15345
15047
|
(0, react.useEffect)(() => {
|
|
15346
15048
|
setIsEditHeaderFooter(viewModel.getEditArea() !== _univerjs_engine_render.DocumentEditArea.BODY);
|
|
@@ -15605,8 +15307,8 @@ const useCurrentParagraph = () => {
|
|
|
15605
15307
|
if (!docDataModel || docRanges.length === 0) return [];
|
|
15606
15308
|
const segmentId = docRanges[0].segmentId;
|
|
15607
15309
|
const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
|
|
15608
|
-
const paragraphs = (_segment$getBody$para = (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [];
|
|
15609
|
-
const dataStream = (_segment$getBody$data = (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "";
|
|
15310
|
+
const paragraphs = (_segment$getBody$para = segment === null || segment === void 0 || (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [];
|
|
15311
|
+
const dataStream = (_segment$getBody$data = segment === null || segment === void 0 || (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "";
|
|
15610
15312
|
return (_BuildTextUtils$range = _univerjs_core.BuildTextUtils.range.getParagraphsInRanges(docRanges, paragraphs, dataStream)) !== null && _BuildTextUtils$range !== void 0 ? _BuildTextUtils$range : [];
|
|
15611
15313
|
};
|
|
15612
15314
|
const useFirstParagraphHorizontalAlign = (paragraph, defaultValue) => {
|
|
@@ -16195,12 +15897,12 @@ const LIST_ICON_MAP = {
|
|
|
16195
15897
|
};
|
|
16196
15898
|
let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_core.Disposable {
|
|
16197
15899
|
get activeParagraph() {
|
|
16198
|
-
var _this$
|
|
16199
|
-
return (_this$
|
|
15900
|
+
var _this$_paragraphMenu;
|
|
15901
|
+
return (_this$_paragraphMenu = this._paragraphMenu) === null || _this$_paragraphMenu === void 0 ? void 0 : _this$_paragraphMenu.paragraph;
|
|
16200
15902
|
}
|
|
16201
15903
|
get activeTarget() {
|
|
16202
|
-
var _this$
|
|
16203
|
-
return (_this$
|
|
15904
|
+
var _this$_paragraphMenu$, _this$_paragraphMenu2;
|
|
15905
|
+
return (_this$_paragraphMenu$ = (_this$_paragraphMenu2 = this._paragraphMenu) === null || _this$_paragraphMenu2 === void 0 ? void 0 : _this$_paragraphMenu2.target) !== null && _this$_paragraphMenu$ !== void 0 ? _this$_paragraphMenu$ : null;
|
|
16204
15906
|
}
|
|
16205
15907
|
setBlockMenuDragging(isDragging) {
|
|
16206
15908
|
this._isBlockMenuDragging = isDragging;
|
|
@@ -16217,7 +15919,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
16217
15919
|
this._docSkeletonManagerService = _docSkeletonManagerService;
|
|
16218
15920
|
this._floatMenuService = _floatMenuService;
|
|
16219
15921
|
this._docSelectionRenderService = _docSelectionRenderService;
|
|
16220
|
-
_defineProperty(this, "
|
|
15922
|
+
_defineProperty(this, "_paragraphMenu", null);
|
|
16221
15923
|
_defineProperty(this, "_activeTarget$", new rxjs.BehaviorSubject(null));
|
|
16222
15924
|
_defineProperty(this, "activeTarget$", this._activeTarget$.asObservable());
|
|
16223
15925
|
_defineProperty(this, "_slashMenuRequest$", new rxjs.BehaviorSubject(null));
|
|
@@ -16229,10 +15931,10 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
16229
15931
|
this._init();
|
|
16230
15932
|
}
|
|
16231
15933
|
_isCursorInActiveParagraph() {
|
|
16232
|
-
if (!this.
|
|
15934
|
+
if (!this._paragraphMenu) return false;
|
|
16233
15935
|
const activeTextRange = this._docSelectionManagerService.getActiveTextRange();
|
|
16234
15936
|
if (!(activeTextRange === null || activeTextRange === void 0 ? void 0 : activeTextRange.collapsed)) return false;
|
|
16235
|
-
if (!(activeTextRange === null || activeTextRange === void 0 ? void 0 : activeTextRange.collapsed) || activeTextRange.startOffset < this.
|
|
15937
|
+
if (!(activeTextRange === null || activeTextRange === void 0 ? void 0 : activeTextRange.collapsed) || activeTextRange.startOffset < this._paragraphMenu.paragraph.paragraphStart || activeTextRange.startOffset > this._paragraphMenu.paragraph.paragraphEnd) return false;
|
|
16236
15938
|
return true;
|
|
16237
15939
|
}
|
|
16238
15940
|
_getExpandedSelectionState(ranges) {
|
|
@@ -16263,7 +15965,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
16263
15965
|
return this._hasExpandedSelectionRanges(this._docSelectionManagerService.getDocRanges());
|
|
16264
15966
|
}
|
|
16265
15967
|
setParagraphMenuActive(active) {
|
|
16266
|
-
if (this.
|
|
15968
|
+
if (this._paragraphMenu) this._paragraphMenu.active = active;
|
|
16267
15969
|
}
|
|
16268
15970
|
_init() {
|
|
16269
15971
|
var _this$_docEventManage;
|
|
@@ -16279,18 +15981,18 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
16279
15981
|
return;
|
|
16280
15982
|
}
|
|
16281
15983
|
if (selectionState.hasRectRange) {
|
|
16282
|
-
var _this$
|
|
15984
|
+
var _this$_paragraphMenu3;
|
|
16283
15985
|
if (tableBound) {
|
|
16284
15986
|
this.showTableMenu(tableBound);
|
|
16285
15987
|
return;
|
|
16286
15988
|
}
|
|
16287
|
-
if (((_this$
|
|
15989
|
+
if (((_this$_paragraphMenu3 = this._paragraphMenu) === null || _this$_paragraphMenu3 === void 0 ? void 0 : _this$_paragraphMenu3.target.kind) === _univerjs_core.DocumentBlockType.TABLE) return;
|
|
16288
15990
|
this.hideParagraphMenu(true);
|
|
16289
15991
|
return;
|
|
16290
15992
|
}
|
|
16291
15993
|
if (this._docSkeletonManagerService.getViewModel().getEditArea() === _univerjs_engine_render.DocumentEditArea.BODY && !this._floatMenuService.floatMenu && !this._context.unit.getDisabled()) {
|
|
16292
|
-
var _this$
|
|
16293
|
-
if ((_this$
|
|
15994
|
+
var _this$_paragraphMenu4;
|
|
15995
|
+
if ((_this$_paragraphMenu4 = this._paragraphMenu) === null || _this$_paragraphMenu4 === void 0 ? void 0 : _this$_paragraphMenu4.active) return;
|
|
16294
15996
|
if (paragraph) {
|
|
16295
15997
|
this.showParagraphMenu(paragraph);
|
|
16296
15998
|
return;
|
|
@@ -16316,16 +16018,16 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
16316
16018
|
this.hideParagraphMenu(true);
|
|
16317
16019
|
}));
|
|
16318
16020
|
this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe(({ textRanges, rectRanges }) => {
|
|
16319
|
-
var _this$
|
|
16021
|
+
var _this$_paragraphMenu5;
|
|
16320
16022
|
const selectionState = this._getExpandedSelectionState([...textRanges, ...rectRanges]);
|
|
16321
|
-
if (selectionState.hasExpandedTextRange || selectionState.hasRectRange && ((_this$
|
|
16023
|
+
if (selectionState.hasExpandedTextRange || selectionState.hasRectRange && ((_this$_paragraphMenu5 = this._paragraphMenu) === null || _this$_paragraphMenu5 === void 0 ? void 0 : _this$_paragraphMenu5.target.kind) !== _univerjs_core.DocumentBlockType.TABLE) this.hideParagraphMenu(true);
|
|
16322
16024
|
}));
|
|
16323
16025
|
let lastScrollY = 0;
|
|
16324
16026
|
this.disposeWithMe(this._context.scene.getViewport("viewMain").onScrollAfter$.subscribeEvent((e) => {
|
|
16325
|
-
var _this$
|
|
16027
|
+
var _this$_paragraphMenu6;
|
|
16326
16028
|
if (lastScrollY === e.scrollY) return;
|
|
16327
16029
|
lastScrollY = e.scrollY;
|
|
16328
|
-
if ((_this$
|
|
16030
|
+
if ((_this$_paragraphMenu6 = this._paragraphMenu) === null || _this$_paragraphMenu6 === void 0 ? void 0 : _this$_paragraphMenu6.blockRange) return;
|
|
16329
16031
|
if (this._isBlockMenuDragging) return;
|
|
16330
16032
|
this.hideParagraphMenu(true);
|
|
16331
16033
|
}));
|
|
@@ -16389,10 +16091,10 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
16389
16091
|
return null;
|
|
16390
16092
|
}
|
|
16391
16093
|
_getSlashMenuParagraph(config) {
|
|
16392
|
-
var _this$
|
|
16094
|
+
var _this$_paragraphMenu$2, _this$_paragraphMenu7, _find;
|
|
16393
16095
|
const activeRange = this._getCollapsedTextRange(config);
|
|
16394
16096
|
const offset = activeRange === null || activeRange === void 0 ? void 0 : activeRange.startOffset;
|
|
16395
|
-
const activeParagraph = (_this$
|
|
16097
|
+
const activeParagraph = (_this$_paragraphMenu$2 = (_this$_paragraphMenu7 = this._paragraphMenu) === null || _this$_paragraphMenu7 === void 0 ? void 0 : _this$_paragraphMenu7.paragraph) !== null && _this$_paragraphMenu$2 !== void 0 ? _this$_paragraphMenu$2 : null;
|
|
16396
16098
|
if (activeParagraph && offset != null && offset >= activeParagraph.paragraphStart && offset <= activeParagraph.paragraphEnd) return activeParagraph;
|
|
16397
16099
|
if (activeParagraph && offset == null) return activeParagraph;
|
|
16398
16100
|
if (offset == null) return null;
|
|
@@ -16413,7 +16115,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
16413
16115
|
}
|
|
16414
16116
|
}
|
|
16415
16117
|
showParagraphMenu(paragraph) {
|
|
16416
|
-
var _this$
|
|
16118
|
+
var _this$_paragraphMenu8, _target$paragraph;
|
|
16417
16119
|
if (this._hasExpandedSelection()) {
|
|
16418
16120
|
this.hideParagraphMenu(true);
|
|
16419
16121
|
return;
|
|
@@ -16423,7 +16125,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
16423
16125
|
this.hideParagraphMenu(true);
|
|
16424
16126
|
return;
|
|
16425
16127
|
}
|
|
16426
|
-
if (((_this$
|
|
16128
|
+
if (((_this$_paragraphMenu8 = this._paragraphMenu) === null || _this$_paragraphMenu8 === void 0 ? void 0 : _this$_paragraphMenu8.target.key) === target.key) return;
|
|
16427
16129
|
this.hideParagraphMenu(true);
|
|
16428
16130
|
const targetParagraph = (_target$paragraph = target.paragraph) !== null && _target$paragraph !== void 0 ? _target$paragraph : paragraph;
|
|
16429
16131
|
const blockRange = target.blockRange;
|
|
@@ -16448,7 +16150,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
16448
16150
|
},
|
|
16449
16151
|
zIndex: 101
|
|
16450
16152
|
}, this._context.unitId);
|
|
16451
|
-
this.
|
|
16153
|
+
this._paragraphMenu = {
|
|
16452
16154
|
paragraph: targetParagraph,
|
|
16453
16155
|
target,
|
|
16454
16156
|
blockRange,
|
|
@@ -16458,7 +16160,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
16458
16160
|
this._activeTarget$.next(target);
|
|
16459
16161
|
}
|
|
16460
16162
|
showTableMenu(tableBound) {
|
|
16461
|
-
var _body$tables, _this$
|
|
16163
|
+
var _body$tables, _this$_paragraphMenu9;
|
|
16462
16164
|
if (this._hasExpandedTextSelection()) {
|
|
16463
16165
|
this.hideParagraphMenu(true);
|
|
16464
16166
|
return;
|
|
@@ -16484,7 +16186,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
16484
16186
|
draggable: true
|
|
16485
16187
|
};
|
|
16486
16188
|
if (this._shouldKeepCurrentCellMenuForTable(table)) return;
|
|
16487
|
-
if (((_this$
|
|
16189
|
+
if (((_this$_paragraphMenu9 = this._paragraphMenu) === null || _this$_paragraphMenu9 === void 0 ? void 0 : _this$_paragraphMenu9.target.key) === target.key) return;
|
|
16488
16190
|
const anchorRect = getTableAnchorRect(tableBound);
|
|
16489
16191
|
const paragraph = {
|
|
16490
16192
|
rect: tableBound.rect,
|
|
@@ -16508,7 +16210,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
16508
16210
|
},
|
|
16509
16211
|
zIndex: 101
|
|
16510
16212
|
}, this._context.unitId);
|
|
16511
|
-
this.
|
|
16213
|
+
this._paragraphMenu = {
|
|
16512
16214
|
paragraph,
|
|
16513
16215
|
target,
|
|
16514
16216
|
disposable,
|
|
@@ -16517,8 +16219,8 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
16517
16219
|
this._activeTarget$.next(target);
|
|
16518
16220
|
}
|
|
16519
16221
|
_shouldKeepCurrentCellMenuForTable(table) {
|
|
16520
|
-
var _this$
|
|
16521
|
-
const target = (_this$
|
|
16222
|
+
var _this$_paragraphMenu10;
|
|
16223
|
+
const target = (_this$_paragraphMenu10 = this._paragraphMenu) === null || _this$_paragraphMenu10 === void 0 ? void 0 : _this$_paragraphMenu10.target;
|
|
16522
16224
|
if (!target || target.kind === _univerjs_core.DocumentBlockType.TABLE || !target.cellRange) return false;
|
|
16523
16225
|
return target.cellRange.startOffset >= table.startIndex && target.cellRange.startOffset <= table.endIndex;
|
|
16524
16226
|
}
|
|
@@ -16559,9 +16261,9 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
16559
16261
|
}
|
|
16560
16262
|
hideParagraphMenu(force = false) {
|
|
16561
16263
|
if (this._isBlockMenuDragging) return;
|
|
16562
|
-
if (this.
|
|
16563
|
-
this.
|
|
16564
|
-
this.
|
|
16264
|
+
if (this._paragraphMenu && (this._paragraphMenu.disposable.canDispose() || force)) {
|
|
16265
|
+
this._paragraphMenu.disposable.dispose();
|
|
16266
|
+
this._paragraphMenu = null;
|
|
16565
16267
|
this._isSlashMenuActive = false;
|
|
16566
16268
|
this._slashMenuRequest$.next(null);
|
|
16567
16269
|
this._activeTarget$.next(null);
|
|
@@ -17049,6 +16751,14 @@ function getParagraphMenuResolvedCommand(option, targetRange) {
|
|
|
17049
16751
|
id: (_option$id = option.id) !== null && _option$id !== void 0 ? _option$id : commandId
|
|
17050
16752
|
}, targetRange);
|
|
17051
16753
|
}
|
|
16754
|
+
function getParagraphMenuCommandParams(commandId, commandParams, target, unitId) {
|
|
16755
|
+
if (commandId !== DeleteCurrentParagraphCommand.id || (target === null || target === void 0 ? void 0 : target.kind) !== "blockRange" || !target.blockRange) return commandParams;
|
|
16756
|
+
return {
|
|
16757
|
+
...commandParams !== null && commandParams !== void 0 ? commandParams : {},
|
|
16758
|
+
unitId,
|
|
16759
|
+
blockRange: target.blockRange
|
|
16760
|
+
};
|
|
16761
|
+
}
|
|
17052
16762
|
function getParagraphMenuType(target, emptyMode) {
|
|
17053
16763
|
if ((target === null || target === void 0 ? void 0 : target.kind) === "table") return DOC_TABLE_BLOCK_MENU_ID;
|
|
17054
16764
|
if (emptyMode) return DOC_PARAGRAPH_T_INSERT_MENU_ID;
|
|
@@ -17486,7 +17196,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
17486
17196
|
await executeResolvedCommand({
|
|
17487
17197
|
...option,
|
|
17488
17198
|
commandId,
|
|
17489
|
-
params: commandParams
|
|
17199
|
+
params: getParagraphMenuCommandParams(commandId, commandParams, latestTarget, popup.unitId)
|
|
17490
17200
|
}, getParagraphMenuCommandTargetRange(commandId, targetRange, formattingRange));
|
|
17491
17201
|
} finally {
|
|
17492
17202
|
restoreTextRanges(previousTextRanges);
|
|
@@ -17888,162 +17598,480 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
17888
17598
|
"DocParagraphBackgroundColorSwatchIcon.15": DocParagraphBackgroundColorSwatchIcon15
|
|
17889
17599
|
}));
|
|
17890
17600
|
}
|
|
17891
|
-
_registerComponents() {
|
|
17892
|
-
if (!this._componentManager.get("COMPONENT_DOC_HEADER_FOOTER_PANEL")) this.disposeWithMe(this._componentManager.register(COMPONENT_DOC_HEADER_FOOTER_PANEL, DocHeaderFooterPanel));
|
|
17893
|
-
this.disposeWithMe(this._componentManager.register(paragraphSettingIndexKey, ParagraphSettingIndex));
|
|
17894
|
-
[
|
|
17895
|
-
[BULLET_LIST_TYPE_COMPONENT, BulletListTypePicker],
|
|
17896
|
-
[ORDER_LIST_TYPE_COMPONENT, OrderListTypePicker],
|
|
17897
|
-
[DOC_PARAGRAPH_MENU_COMPONENT_KEY, ParagraphMenu],
|
|
17898
|
-
[DOC_TABLE_BLOCK_MENU_COMPONENT_KEY, TableBlockMenu],
|
|
17899
|
-
[PAGE_SETTING_COMPONENT_ID, PageSettings]
|
|
17900
|
-
].forEach(([key, comp]) => {
|
|
17901
|
-
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
17902
|
-
});
|
|
17903
|
-
}
|
|
17904
|
-
};
|
|
17905
|
-
ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
|
|
17906
|
-
|
|
17907
|
-
//#endregion
|
|
17908
|
-
//#region src/controllers/doc-auto-format.controller.ts
|
|
17909
|
-
function hasQuickListType(text) {
|
|
17910
|
-
return Object.prototype.hasOwnProperty.call(_univerjs_core.QuickListTypeMap, text);
|
|
17911
|
-
}
|
|
17912
|
-
function hasQuickHeading(text) {
|
|
17913
|
-
return Object.prototype.hasOwnProperty.call(QUICK_HEADING_MAP, text);
|
|
17914
|
-
}
|
|
17915
|
-
let DocAutoFormatController = class DocAutoFormatController extends _univerjs_core.Disposable {
|
|
17916
|
-
constructor(_docAutoFormatService, _renderManagerService) {
|
|
17917
|
-
super();
|
|
17918
|
-
this._docAutoFormatService = _docAutoFormatService;
|
|
17919
|
-
this._renderManagerService = _renderManagerService;
|
|
17920
|
-
this._initListTabAutoFormat();
|
|
17921
|
-
this._initSpaceAutoFormat();
|
|
17922
|
-
this._initDefaultEnterFormat();
|
|
17923
|
-
this._initExitListAutoFormat();
|
|
17601
|
+
_registerComponents() {
|
|
17602
|
+
if (!this._componentManager.get("COMPONENT_DOC_HEADER_FOOTER_PANEL")) this.disposeWithMe(this._componentManager.register(COMPONENT_DOC_HEADER_FOOTER_PANEL, DocHeaderFooterPanel));
|
|
17603
|
+
this.disposeWithMe(this._componentManager.register(paragraphSettingIndexKey, ParagraphSettingIndex));
|
|
17604
|
+
[
|
|
17605
|
+
[BULLET_LIST_TYPE_COMPONENT, BulletListTypePicker],
|
|
17606
|
+
[ORDER_LIST_TYPE_COMPONENT, OrderListTypePicker],
|
|
17607
|
+
[DOC_PARAGRAPH_MENU_COMPONENT_KEY, ParagraphMenu],
|
|
17608
|
+
[DOC_TABLE_BLOCK_MENU_COMPONENT_KEY, TableBlockMenu],
|
|
17609
|
+
[PAGE_SETTING_COMPONENT_ID, PageSettings]
|
|
17610
|
+
].forEach(([key, comp]) => {
|
|
17611
|
+
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
17612
|
+
});
|
|
17613
|
+
}
|
|
17614
|
+
};
|
|
17615
|
+
ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
|
|
17616
|
+
|
|
17617
|
+
//#endregion
|
|
17618
|
+
//#region src/controllers/doc-auto-format.controller.ts
|
|
17619
|
+
function hasQuickListType(text) {
|
|
17620
|
+
return Object.prototype.hasOwnProperty.call(_univerjs_core.QuickListTypeMap, text);
|
|
17621
|
+
}
|
|
17622
|
+
function hasQuickHeading(text) {
|
|
17623
|
+
return Object.prototype.hasOwnProperty.call(QUICK_HEADING_MAP, text);
|
|
17624
|
+
}
|
|
17625
|
+
let DocAutoFormatController = class DocAutoFormatController extends _univerjs_core.Disposable {
|
|
17626
|
+
constructor(_docAutoFormatService, _renderManagerService) {
|
|
17627
|
+
super();
|
|
17628
|
+
this._docAutoFormatService = _docAutoFormatService;
|
|
17629
|
+
this._renderManagerService = _renderManagerService;
|
|
17630
|
+
this._initListTabAutoFormat();
|
|
17631
|
+
this._initSpaceAutoFormat();
|
|
17632
|
+
this._initDefaultEnterFormat();
|
|
17633
|
+
this._initExitListAutoFormat();
|
|
17634
|
+
}
|
|
17635
|
+
_initListTabAutoFormat() {
|
|
17636
|
+
this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({
|
|
17637
|
+
id: TabCommand.id,
|
|
17638
|
+
match: (context) => {
|
|
17639
|
+
const { selection, paragraphs, unit } = context;
|
|
17640
|
+
if (paragraphs.length === 1 && selection.startOffset === paragraphs[0].paragraphStart && paragraphs[0].bullet) {
|
|
17641
|
+
var _unit$getBody;
|
|
17642
|
+
const allParagraphs = (_unit$getBody = unit.getBody()) === null || _unit$getBody === void 0 ? void 0 : _unit$getBody.paragraphs;
|
|
17643
|
+
const bulletParagraphs = allParagraphs === null || allParagraphs === void 0 ? void 0 : allParagraphs.filter((p) => {
|
|
17644
|
+
var _p$bullet;
|
|
17645
|
+
return ((_p$bullet = p.bullet) === null || _p$bullet === void 0 ? void 0 : _p$bullet.listId) === paragraphs[0].bullet.listId;
|
|
17646
|
+
});
|
|
17647
|
+
if ((bulletParagraphs === null || bulletParagraphs === void 0 ? void 0 : bulletParagraphs.findIndex((p) => p.startIndex === paragraphs[0].startIndex)) === 0) return false;
|
|
17648
|
+
return true;
|
|
17649
|
+
} else if (paragraphs.length > 1 && paragraphs.some((p) => p.bullet)) return true;
|
|
17650
|
+
return false;
|
|
17651
|
+
},
|
|
17652
|
+
getMutations(context) {
|
|
17653
|
+
const params = context.commandParams;
|
|
17654
|
+
return [{
|
|
17655
|
+
id: ChangeListNestingLevelCommand.id,
|
|
17656
|
+
params: { type: (params === null || params === void 0 ? void 0 : params.shift) ? -1 : 1 }
|
|
17657
|
+
}];
|
|
17658
|
+
},
|
|
17659
|
+
priority: 100
|
|
17660
|
+
}));
|
|
17661
|
+
this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({
|
|
17662
|
+
id: TabCommand.id,
|
|
17663
|
+
match: (context) => {
|
|
17664
|
+
const { selection, unit } = context;
|
|
17665
|
+
const { startNodePosition, endNodePosition } = selection;
|
|
17666
|
+
const renderObject = this._renderManagerService.getRenderById(unit.getUnitId());
|
|
17667
|
+
const skeleton = renderObject === null || renderObject === void 0 ? void 0 : renderObject.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton();
|
|
17668
|
+
if (skeleton == null) return false;
|
|
17669
|
+
if (startNodePosition && endNodePosition && isInSameTableCellData(skeleton, startNodePosition, endNodePosition)) return true;
|
|
17670
|
+
if (startNodePosition && !endNodePosition && startNodePosition.path.indexOf("cells") > -1) return true;
|
|
17671
|
+
return false;
|
|
17672
|
+
},
|
|
17673
|
+
getMutations(context) {
|
|
17674
|
+
const params = context.commandParams;
|
|
17675
|
+
return [{
|
|
17676
|
+
id: DocTableTabCommand.id,
|
|
17677
|
+
params: { shift: !!(params === null || params === void 0 ? void 0 : params.shift) }
|
|
17678
|
+
}];
|
|
17679
|
+
},
|
|
17680
|
+
priority: 99
|
|
17681
|
+
}));
|
|
17682
|
+
}
|
|
17683
|
+
_initSpaceAutoFormat() {
|
|
17684
|
+
this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({
|
|
17685
|
+
id: AfterSpaceCommand.id,
|
|
17686
|
+
match: (context) => {
|
|
17687
|
+
var _unit$getBody2;
|
|
17688
|
+
const { selection, paragraphs, unit } = context;
|
|
17689
|
+
if (!selection.collapsed) return false;
|
|
17690
|
+
if (paragraphs.length !== 1) return false;
|
|
17691
|
+
if (!selection.collapsed) return false;
|
|
17692
|
+
const text = (_unit$getBody2 = unit.getBody()) === null || _unit$getBody2 === void 0 ? void 0 : _unit$getBody2.dataStream.slice(paragraphs[0].paragraphStart, selection.startOffset - 1);
|
|
17693
|
+
if (text && (hasQuickListType(text) || hasQuickHeading(text))) return true;
|
|
17694
|
+
return false;
|
|
17695
|
+
},
|
|
17696
|
+
getMutations(context) {
|
|
17697
|
+
var _unit$getBody3;
|
|
17698
|
+
const { paragraphs, unit, selection } = context;
|
|
17699
|
+
const text = (_unit$getBody3 = unit.getBody()) === null || _unit$getBody3 === void 0 ? void 0 : _unit$getBody3.dataStream.slice(paragraphs[0].paragraphStart, selection.startOffset - 1);
|
|
17700
|
+
if (text && hasQuickListType(text)) {
|
|
17701
|
+
const type = _univerjs_core.QuickListTypeMap[text];
|
|
17702
|
+
return [{
|
|
17703
|
+
id: QuickListCommand.id,
|
|
17704
|
+
params: {
|
|
17705
|
+
listType: type,
|
|
17706
|
+
paragraph: paragraphs[0]
|
|
17707
|
+
}
|
|
17708
|
+
}];
|
|
17709
|
+
}
|
|
17710
|
+
if (text && hasQuickHeading(text)) {
|
|
17711
|
+
const type = QUICK_HEADING_MAP[text];
|
|
17712
|
+
return [{
|
|
17713
|
+
id: QuickHeadingCommand.id,
|
|
17714
|
+
params: { value: type }
|
|
17715
|
+
}];
|
|
17716
|
+
}
|
|
17717
|
+
return [];
|
|
17718
|
+
}
|
|
17719
|
+
}));
|
|
17720
|
+
}
|
|
17721
|
+
_initExitListAutoFormat() {
|
|
17722
|
+
this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({
|
|
17723
|
+
id: EnterCommand.id,
|
|
17724
|
+
match: (context) => {
|
|
17725
|
+
const { paragraphs } = context;
|
|
17726
|
+
if (paragraphs.length === 1 && paragraphs[0].bullet && paragraphs[0].paragraphStart === paragraphs[0].paragraphEnd) return true;
|
|
17727
|
+
return false;
|
|
17728
|
+
},
|
|
17729
|
+
getMutations: (context) => {
|
|
17730
|
+
const bullet = context.paragraphs[0].bullet;
|
|
17731
|
+
if (!bullet) return [];
|
|
17732
|
+
if (bullet.nestingLevel > 0) return [{
|
|
17733
|
+
id: ChangeListNestingLevelCommand.id,
|
|
17734
|
+
params: { type: -1 }
|
|
17735
|
+
}];
|
|
17736
|
+
return [{
|
|
17737
|
+
id: ListOperationCommand.id,
|
|
17738
|
+
params: { listType: context.paragraphs[0].bullet.listType }
|
|
17739
|
+
}];
|
|
17740
|
+
}
|
|
17741
|
+
}));
|
|
17742
|
+
}
|
|
17743
|
+
_initDefaultEnterFormat() {
|
|
17744
|
+
this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({
|
|
17745
|
+
id: EnterCommand.id,
|
|
17746
|
+
match: () => {
|
|
17747
|
+
return true;
|
|
17748
|
+
},
|
|
17749
|
+
getMutations() {
|
|
17750
|
+
return [{ id: BreakLineCommand.id }];
|
|
17751
|
+
},
|
|
17752
|
+
priority: -9999
|
|
17753
|
+
}));
|
|
17754
|
+
}
|
|
17755
|
+
};
|
|
17756
|
+
DocAutoFormatController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(DocAutoFormatService)), __decorateParam(1, _univerjs_engine_render.IRenderManagerService)], DocAutoFormatController);
|
|
17757
|
+
|
|
17758
|
+
//#endregion
|
|
17759
|
+
//#region src/views/header-footer/text-bubble.ts
|
|
17760
|
+
const COLLAB_CURSOR_LABEL_HEIGHT = 18;
|
|
17761
|
+
const COLLAB_CURSOR_LABEL_MAX_WIDTH = 200;
|
|
17762
|
+
const COLLAB_CURSOR_LABEL_TEXT_PADDING_LR = 6;
|
|
17763
|
+
const COLLAB_CURSOR_LABEL_TEXT_PADDING_TB = 4;
|
|
17764
|
+
function drawBubble(ctx, props) {
|
|
17765
|
+
var _radius, _width, _height;
|
|
17766
|
+
let { radius, width, height } = props;
|
|
17767
|
+
radius = (_radius = radius) !== null && _radius !== void 0 ? _radius : 0;
|
|
17768
|
+
width = (_width = width) !== null && _width !== void 0 ? _width : 30;
|
|
17769
|
+
height = (_height = height) !== null && _height !== void 0 ? _height : 30;
|
|
17770
|
+
let bottomRight = 0;
|
|
17771
|
+
bottomRight = Math.min(radius, width / 2, height / 2);
|
|
17772
|
+
ctx.beginPath();
|
|
17773
|
+
ctx.moveTo(0, 0);
|
|
17774
|
+
ctx.lineTo(width, 0);
|
|
17775
|
+
ctx.lineTo(width, height - bottomRight);
|
|
17776
|
+
ctx.arc(width - bottomRight, height - bottomRight, bottomRight, 0, Math.PI / 2, false);
|
|
17777
|
+
ctx.lineTo(0, height);
|
|
17778
|
+
ctx.lineTo(0, 0);
|
|
17779
|
+
ctx.closePath();
|
|
17780
|
+
if (props.fill) {
|
|
17781
|
+
ctx.save();
|
|
17782
|
+
ctx.fillStyle = props.fill;
|
|
17783
|
+
if (props.fillRule === "evenodd") ctx.fill("evenodd");
|
|
17784
|
+
else ctx.fill();
|
|
17785
|
+
ctx.restore();
|
|
17786
|
+
}
|
|
17787
|
+
}
|
|
17788
|
+
/**
|
|
17789
|
+
* Render a single collaborated cursor on the canvas.
|
|
17790
|
+
*/
|
|
17791
|
+
var TextBubbleShape = class TextBubbleShape extends _univerjs_engine_render.Shape {
|
|
17792
|
+
constructor(key, props) {
|
|
17793
|
+
super(key, props);
|
|
17794
|
+
_defineProperty(this, "color", void 0);
|
|
17795
|
+
_defineProperty(this, "text", void 0);
|
|
17796
|
+
this.color = props === null || props === void 0 ? void 0 : props.color;
|
|
17797
|
+
this.text = props === null || props === void 0 ? void 0 : props.text;
|
|
17798
|
+
}
|
|
17799
|
+
static drawWith(ctx, props) {
|
|
17800
|
+
const { text, color } = props;
|
|
17801
|
+
ctx.save();
|
|
17802
|
+
ctx.font = "13px Source Han Sans CN";
|
|
17803
|
+
const textWidth = ctx.measureText(text).width;
|
|
17804
|
+
drawBubble(ctx, {
|
|
17805
|
+
height: 18,
|
|
17806
|
+
width: Math.min(textWidth + 2 * 6, 200),
|
|
17807
|
+
radius: 4,
|
|
17808
|
+
fill: color,
|
|
17809
|
+
evented: false
|
|
17810
|
+
});
|
|
17811
|
+
ctx.fillStyle = "rgba(58, 96, 247, 1)";
|
|
17812
|
+
const offsetX = 6;
|
|
17813
|
+
const offsetY = 18 - 4;
|
|
17814
|
+
const maxTextWidth = 200 - 2 * 6;
|
|
17815
|
+
if (textWidth > maxTextWidth) {
|
|
17816
|
+
let truncatedText = "";
|
|
17817
|
+
let currentWidth = 0;
|
|
17818
|
+
for (const element of text) {
|
|
17819
|
+
const charWidth = ctx.measureText(element).width;
|
|
17820
|
+
if (currentWidth + charWidth <= maxTextWidth - ctx.measureText("...").width) {
|
|
17821
|
+
truncatedText += element;
|
|
17822
|
+
currentWidth += charWidth;
|
|
17823
|
+
} else {
|
|
17824
|
+
truncatedText += "...";
|
|
17825
|
+
break;
|
|
17826
|
+
}
|
|
17827
|
+
}
|
|
17828
|
+
ctx.fillText(truncatedText, offsetX, offsetY);
|
|
17829
|
+
} else ctx.fillText(text, offsetX, offsetY);
|
|
17830
|
+
ctx.restore();
|
|
17831
|
+
}
|
|
17832
|
+
_draw(ctx) {
|
|
17833
|
+
TextBubbleShape.drawWith(ctx, this);
|
|
17834
|
+
}
|
|
17835
|
+
};
|
|
17836
|
+
|
|
17837
|
+
//#endregion
|
|
17838
|
+
//#region src/controllers/doc-header-footer.controller.ts
|
|
17839
|
+
const HEADER_FOOTER_STROKE_COLOR = "rgba(58, 96, 247, 1)";
|
|
17840
|
+
const HEADER_FOOTER_FILL_COLOR = "rgba(58, 96, 247, 0.08)";
|
|
17841
|
+
function checkCreateHeaderFooterType(viewModel, editArea, segmentPage) {
|
|
17842
|
+
const { documentStyle } = viewModel.getDataModel().getSnapshot();
|
|
17843
|
+
const { defaultHeaderId, defaultFooterId, evenPageHeaderId, evenPageFooterId, firstPageHeaderId, firstPageFooterId, evenAndOddHeaders, useFirstPageHeaderFooter } = documentStyle;
|
|
17844
|
+
switch (editArea) {
|
|
17845
|
+
case _univerjs_engine_render.DocumentEditArea.BODY: return {
|
|
17846
|
+
createType: null,
|
|
17847
|
+
headerFooterId: null
|
|
17848
|
+
};
|
|
17849
|
+
case _univerjs_engine_render.DocumentEditArea.HEADER:
|
|
17850
|
+
if (useFirstPageHeaderFooter === _univerjs_core.BooleanNumber.TRUE && !firstPageHeaderId) return {
|
|
17851
|
+
createType: _univerjs_docs.HeaderFooterType.FIRST_PAGE_HEADER,
|
|
17852
|
+
headerFooterId: null
|
|
17853
|
+
};
|
|
17854
|
+
if (evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE && segmentPage % 2 === 0 && !evenPageHeaderId) return {
|
|
17855
|
+
createType: _univerjs_docs.HeaderFooterType.EVEN_PAGE_HEADER,
|
|
17856
|
+
headerFooterId: null
|
|
17857
|
+
};
|
|
17858
|
+
return defaultHeaderId ? {
|
|
17859
|
+
createType: null,
|
|
17860
|
+
headerFooterId: defaultHeaderId
|
|
17861
|
+
} : {
|
|
17862
|
+
createType: _univerjs_docs.HeaderFooterType.DEFAULT_HEADER,
|
|
17863
|
+
headerFooterId: null
|
|
17864
|
+
};
|
|
17865
|
+
case _univerjs_engine_render.DocumentEditArea.FOOTER:
|
|
17866
|
+
if (useFirstPageHeaderFooter === _univerjs_core.BooleanNumber.TRUE && !firstPageFooterId) return {
|
|
17867
|
+
createType: _univerjs_docs.HeaderFooterType.FIRST_PAGE_FOOTER,
|
|
17868
|
+
headerFooterId: null
|
|
17869
|
+
};
|
|
17870
|
+
if (evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE && segmentPage % 2 === 0 && !evenPageFooterId) return {
|
|
17871
|
+
createType: _univerjs_docs.HeaderFooterType.EVEN_PAGE_FOOTER,
|
|
17872
|
+
headerFooterId: null
|
|
17873
|
+
};
|
|
17874
|
+
return defaultFooterId ? {
|
|
17875
|
+
createType: null,
|
|
17876
|
+
headerFooterId: defaultFooterId
|
|
17877
|
+
} : {
|
|
17878
|
+
createType: _univerjs_docs.HeaderFooterType.DEFAULT_FOOTER,
|
|
17879
|
+
headerFooterId: null
|
|
17880
|
+
};
|
|
17881
|
+
default: throw new Error(`Invalid editArea: ${editArea}`);
|
|
17882
|
+
}
|
|
17883
|
+
}
|
|
17884
|
+
let DocHeaderFooterController = class DocHeaderFooterController extends _univerjs_core.Disposable {
|
|
17885
|
+
constructor(_context, _commandService, _editorService, _instanceSrv, _renderManagerService, _docSkeletonManagerService, _docSelectionRenderService, _localeService) {
|
|
17886
|
+
super();
|
|
17887
|
+
this._context = _context;
|
|
17888
|
+
this._commandService = _commandService;
|
|
17889
|
+
this._editorService = _editorService;
|
|
17890
|
+
this._instanceSrv = _instanceSrv;
|
|
17891
|
+
this._renderManagerService = _renderManagerService;
|
|
17892
|
+
this._docSkeletonManagerService = _docSkeletonManagerService;
|
|
17893
|
+
this._docSelectionRenderService = _docSelectionRenderService;
|
|
17894
|
+
this._localeService = _localeService;
|
|
17895
|
+
_defineProperty(this, "_loadedMap", /* @__PURE__ */ new WeakSet());
|
|
17896
|
+
this._initialize();
|
|
17897
|
+
}
|
|
17898
|
+
_initialize() {
|
|
17899
|
+
this._init();
|
|
17900
|
+
this._drawHeaderFooterLabel();
|
|
17901
|
+
this._listenSwitchMode();
|
|
17902
|
+
}
|
|
17903
|
+
dispose() {
|
|
17904
|
+
super.dispose();
|
|
17905
|
+
}
|
|
17906
|
+
_listenSwitchMode() {
|
|
17907
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
17908
|
+
if (_univerjs_docs.RichTextEditingMutation.id === command.id) {
|
|
17909
|
+
const docDataModel = this._context.unit;
|
|
17910
|
+
const editArea = this._docSkeletonManagerService.getViewModel().getEditArea();
|
|
17911
|
+
const documentFlavor = docDataModel.getSnapshot().documentStyle.documentFlavor;
|
|
17912
|
+
if (editArea !== _univerjs_engine_render.DocumentEditArea.BODY && documentFlavor === _univerjs_core.DocumentFlavor.MODERN) this._commandService.executeCommand(CloseHeaderFooterCommand.id, { unitId: this._context.unitId });
|
|
17913
|
+
}
|
|
17914
|
+
}));
|
|
17915
|
+
}
|
|
17916
|
+
_init() {
|
|
17917
|
+
const { unitId } = this._context;
|
|
17918
|
+
const docObject = neoGetDocObject(this._context);
|
|
17919
|
+
if (docObject == null || docObject.document == null) return;
|
|
17920
|
+
if (!this._loadedMap.has(docObject.document)) {
|
|
17921
|
+
this._initialMain(unitId);
|
|
17922
|
+
this._loadedMap.add(docObject.document);
|
|
17923
|
+
}
|
|
17924
|
+
}
|
|
17925
|
+
_initialMain(unitId) {
|
|
17926
|
+
const { document } = neoGetDocObject(this._context);
|
|
17927
|
+
this.disposeWithMe(document.onDblclick$.subscribeEvent(async (evt) => {
|
|
17928
|
+
if (this._isEditorReadOnly(unitId)) return;
|
|
17929
|
+
if (!this._isTraditionalMode()) return;
|
|
17930
|
+
const { offsetX, offsetY } = evt;
|
|
17931
|
+
const { pageLayoutType = _univerjs_engine_render.PageLayoutType.VERTICAL, pageMarginLeft, pageMarginTop } = document.getOffsetConfig();
|
|
17932
|
+
const coord = this._getTransformCoordForDocumentOffset(offsetX, offsetY);
|
|
17933
|
+
if (coord == null) return;
|
|
17934
|
+
const viewModel = this._docSkeletonManagerService.getViewModel();
|
|
17935
|
+
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
17936
|
+
const preEditArea = viewModel.getEditArea();
|
|
17937
|
+
const { editArea, pageNumber } = skeleton.findEditAreaByCoord(coord, pageLayoutType, pageMarginLeft, pageMarginTop);
|
|
17938
|
+
if (preEditArea === editArea) return;
|
|
17939
|
+
viewModel.setEditArea(editArea);
|
|
17940
|
+
const { createType, headerFooterId } = checkCreateHeaderFooterType(viewModel, editArea, pageNumber);
|
|
17941
|
+
if (editArea === _univerjs_engine_render.DocumentEditArea.BODY) {
|
|
17942
|
+
this._docSelectionRenderService.setSegment("");
|
|
17943
|
+
this._docSelectionRenderService.setSegmentPage(-1);
|
|
17944
|
+
this._docSelectionRenderService.setCursorManually(offsetX, offsetY);
|
|
17945
|
+
} else if (createType != null) {
|
|
17946
|
+
const segmentId = (0, _univerjs_core.generateRandomId)(6);
|
|
17947
|
+
this._docSelectionRenderService.setSegment(segmentId);
|
|
17948
|
+
this._docSelectionRenderService.setSegmentPage(pageNumber);
|
|
17949
|
+
await this._commandService.executeCommand(CoreHeaderFooterCommand.id, {
|
|
17950
|
+
unitId,
|
|
17951
|
+
createType,
|
|
17952
|
+
segmentId
|
|
17953
|
+
});
|
|
17954
|
+
} else if (headerFooterId != null) {
|
|
17955
|
+
this._docSelectionRenderService.setSegment(headerFooterId);
|
|
17956
|
+
this._docSelectionRenderService.setSegmentPage(pageNumber);
|
|
17957
|
+
this._docSelectionRenderService.setCursorManually(offsetX, offsetY);
|
|
17958
|
+
}
|
|
17959
|
+
}));
|
|
17960
|
+
}
|
|
17961
|
+
_getTransformCoordForDocumentOffset(evtOffsetX, evtOffsetY) {
|
|
17962
|
+
const { document, scene } = neoGetDocObject(this._context);
|
|
17963
|
+
const { documentTransform } = document.getOffsetConfig();
|
|
17964
|
+
const activeViewport = scene.getViewports()[0];
|
|
17965
|
+
if (activeViewport == null) return;
|
|
17966
|
+
const originCoord = activeViewport.transformVector2SceneCoord(_univerjs_engine_render.Vector2.FromArray([evtOffsetX, evtOffsetY]));
|
|
17967
|
+
return documentTransform.clone().invert().applyPoint(originCoord);
|
|
17924
17968
|
}
|
|
17925
|
-
|
|
17926
|
-
this.
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
|
|
17930
|
-
|
|
17931
|
-
|
|
17932
|
-
|
|
17933
|
-
|
|
17934
|
-
|
|
17935
|
-
|
|
17969
|
+
_drawHeaderFooterLabel() {
|
|
17970
|
+
const localeService = this._localeService;
|
|
17971
|
+
this.disposeWithMe(this._instanceSrv.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC).subscribe((unit) => {
|
|
17972
|
+
if (unit == null) return;
|
|
17973
|
+
const unitId = unit.getUnitId();
|
|
17974
|
+
const currentRender = this._renderManagerService.getRenderUnitById(unitId);
|
|
17975
|
+
if (this._editorService.isEditor(unitId) || this._instanceSrv.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC) == null) return;
|
|
17976
|
+
if (currentRender == null) return;
|
|
17977
|
+
const { mainComponent } = currentRender;
|
|
17978
|
+
const docsComponent = mainComponent;
|
|
17979
|
+
this.disposeWithMe((0, _univerjs_core.toDisposable)(docsComponent.pageRender$.subscribe((config) => {
|
|
17980
|
+
if (this._editorService.isEditor(unitId)) return;
|
|
17981
|
+
if (!this._isTraditionalMode()) return;
|
|
17982
|
+
const isEditBody = this._docSkeletonManagerService.getViewModel().getEditArea() === _univerjs_engine_render.DocumentEditArea.BODY;
|
|
17983
|
+
const { page, pageLeft, pageTop, ctx } = config;
|
|
17984
|
+
const { pageWidth, pageHeight, marginTop, marginBottom } = page;
|
|
17985
|
+
ctx.save();
|
|
17986
|
+
ctx.translate(pageLeft - .5, pageTop - .5);
|
|
17987
|
+
if (isEditBody) {
|
|
17988
|
+
_univerjs_engine_render.Rect.drawWith(ctx, {
|
|
17989
|
+
left: 0,
|
|
17990
|
+
top: 0,
|
|
17991
|
+
width: pageWidth,
|
|
17992
|
+
height: marginTop,
|
|
17993
|
+
fill: "rgba(255, 255, 255, 0.5)"
|
|
17936
17994
|
});
|
|
17937
|
-
|
|
17938
|
-
|
|
17939
|
-
|
|
17940
|
-
|
|
17941
|
-
|
|
17942
|
-
|
|
17943
|
-
|
|
17944
|
-
|
|
17945
|
-
|
|
17946
|
-
|
|
17947
|
-
}
|
|
17948
|
-
|
|
17949
|
-
|
|
17950
|
-
|
|
17951
|
-
|
|
17952
|
-
|
|
17953
|
-
|
|
17954
|
-
|
|
17955
|
-
|
|
17956
|
-
|
|
17957
|
-
|
|
17958
|
-
if (skeleton == null) return false;
|
|
17959
|
-
if (startNodePosition && endNodePosition && isInSameTableCellData(skeleton, startNodePosition, endNodePosition)) return true;
|
|
17960
|
-
if (startNodePosition && !endNodePosition && startNodePosition.path.indexOf("cells") > -1) return true;
|
|
17961
|
-
return false;
|
|
17962
|
-
},
|
|
17963
|
-
getMutations(context) {
|
|
17964
|
-
const params = context.commandParams;
|
|
17965
|
-
return [{
|
|
17966
|
-
id: DocTableTabCommand.id,
|
|
17967
|
-
params: { shift: !!(params === null || params === void 0 ? void 0 : params.shift) }
|
|
17968
|
-
}];
|
|
17969
|
-
},
|
|
17970
|
-
priority: 99
|
|
17971
|
-
}));
|
|
17972
|
-
}
|
|
17973
|
-
_initSpaceAutoFormat() {
|
|
17974
|
-
this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({
|
|
17975
|
-
id: AfterSpaceCommand.id,
|
|
17976
|
-
match: (context) => {
|
|
17977
|
-
var _unit$getBody2;
|
|
17978
|
-
const { selection, paragraphs, unit } = context;
|
|
17979
|
-
if (!selection.collapsed) return false;
|
|
17980
|
-
if (paragraphs.length !== 1) return false;
|
|
17981
|
-
if (!selection.collapsed) return false;
|
|
17982
|
-
const text = (_unit$getBody2 = unit.getBody()) === null || _unit$getBody2 === void 0 ? void 0 : _unit$getBody2.dataStream.slice(paragraphs[0].paragraphStart, selection.startOffset - 1);
|
|
17983
|
-
if (text && (hasQuickListType(text) || hasQuickHeading(text))) return true;
|
|
17984
|
-
return false;
|
|
17985
|
-
},
|
|
17986
|
-
getMutations(context) {
|
|
17987
|
-
var _unit$getBody3;
|
|
17988
|
-
const { paragraphs, unit, selection } = context;
|
|
17989
|
-
const text = (_unit$getBody3 = unit.getBody()) === null || _unit$getBody3 === void 0 ? void 0 : _unit$getBody3.dataStream.slice(paragraphs[0].paragraphStart, selection.startOffset - 1);
|
|
17990
|
-
if (text && hasQuickListType(text)) {
|
|
17991
|
-
const type = _univerjs_core.QuickListTypeMap[text];
|
|
17992
|
-
return [{
|
|
17993
|
-
id: QuickListCommand.id,
|
|
17994
|
-
params: {
|
|
17995
|
-
listType: type,
|
|
17996
|
-
paragraph: paragraphs[0]
|
|
17997
|
-
}
|
|
17998
|
-
}];
|
|
17995
|
+
ctx.save();
|
|
17996
|
+
ctx.translate(0, pageHeight - marginBottom);
|
|
17997
|
+
_univerjs_engine_render.Rect.drawWith(ctx, {
|
|
17998
|
+
left: 0,
|
|
17999
|
+
top: 0,
|
|
18000
|
+
width: pageWidth,
|
|
18001
|
+
height: marginBottom,
|
|
18002
|
+
fill: "rgba(255, 255, 255, 0.5)"
|
|
18003
|
+
});
|
|
18004
|
+
ctx.restore();
|
|
18005
|
+
} else {
|
|
18006
|
+
ctx.save();
|
|
18007
|
+
ctx.translate(0, marginTop);
|
|
18008
|
+
_univerjs_engine_render.Rect.drawWith(ctx, {
|
|
18009
|
+
left: 0,
|
|
18010
|
+
top: marginTop,
|
|
18011
|
+
width: pageWidth,
|
|
18012
|
+
height: pageHeight - marginTop - marginBottom,
|
|
18013
|
+
fill: "rgba(255, 255, 255, 0.5)"
|
|
18014
|
+
});
|
|
18015
|
+
ctx.restore();
|
|
17999
18016
|
}
|
|
18000
|
-
if (
|
|
18001
|
-
const
|
|
18002
|
-
|
|
18003
|
-
|
|
18004
|
-
|
|
18005
|
-
|
|
18017
|
+
if (!isEditBody) {
|
|
18018
|
+
const headerPathConfigIPathProps = {
|
|
18019
|
+
dataArray: [{
|
|
18020
|
+
command: "M",
|
|
18021
|
+
points: [0, marginTop]
|
|
18022
|
+
}, {
|
|
18023
|
+
command: "L",
|
|
18024
|
+
points: [pageWidth, marginTop]
|
|
18025
|
+
}],
|
|
18026
|
+
strokeWidth: 1,
|
|
18027
|
+
stroke: HEADER_FOOTER_STROKE_COLOR
|
|
18028
|
+
};
|
|
18029
|
+
const footerPathConfigIPathProps = {
|
|
18030
|
+
dataArray: [{
|
|
18031
|
+
command: "M",
|
|
18032
|
+
points: [0, pageHeight - marginBottom]
|
|
18033
|
+
}, {
|
|
18034
|
+
command: "L",
|
|
18035
|
+
points: [pageWidth, pageHeight - marginBottom]
|
|
18036
|
+
}],
|
|
18037
|
+
strokeWidth: 1,
|
|
18038
|
+
stroke: HEADER_FOOTER_STROKE_COLOR
|
|
18039
|
+
};
|
|
18040
|
+
_univerjs_engine_render.Path.drawWith(ctx, headerPathConfigIPathProps);
|
|
18041
|
+
_univerjs_engine_render.Path.drawWith(ctx, footerPathConfigIPathProps);
|
|
18042
|
+
ctx.translate(0, marginTop + 1);
|
|
18043
|
+
TextBubbleShape.drawWith(ctx, {
|
|
18044
|
+
text: localeService.t("docs-ui.headerFooter.header"),
|
|
18045
|
+
color: HEADER_FOOTER_FILL_COLOR
|
|
18046
|
+
});
|
|
18047
|
+
ctx.translate(0, pageHeight - marginTop - marginBottom);
|
|
18048
|
+
TextBubbleShape.drawWith(ctx, {
|
|
18049
|
+
text: localeService.t("docs-ui.headerFooter.footer"),
|
|
18050
|
+
color: HEADER_FOOTER_FILL_COLOR
|
|
18051
|
+
});
|
|
18006
18052
|
}
|
|
18007
|
-
|
|
18008
|
-
}
|
|
18053
|
+
ctx.restore();
|
|
18054
|
+
})));
|
|
18009
18055
|
}));
|
|
18010
18056
|
}
|
|
18011
|
-
|
|
18012
|
-
this.
|
|
18013
|
-
|
|
18014
|
-
|
|
18015
|
-
const { paragraphs } = context;
|
|
18016
|
-
if (paragraphs.length === 1 && paragraphs[0].bullet && paragraphs[0].paragraphStart === paragraphs[0].paragraphEnd) return true;
|
|
18017
|
-
return false;
|
|
18018
|
-
},
|
|
18019
|
-
getMutations: (context) => {
|
|
18020
|
-
const bullet = context.paragraphs[0].bullet;
|
|
18021
|
-
if (!bullet) return [];
|
|
18022
|
-
if (bullet.nestingLevel > 0) return [{
|
|
18023
|
-
id: ChangeListNestingLevelCommand.id,
|
|
18024
|
-
params: { type: -1 }
|
|
18025
|
-
}];
|
|
18026
|
-
return [{
|
|
18027
|
-
id: ListOperationCommand.id,
|
|
18028
|
-
params: { listType: context.paragraphs[0].bullet.listType }
|
|
18029
|
-
}];
|
|
18030
|
-
}
|
|
18031
|
-
}));
|
|
18057
|
+
_isEditorReadOnly(unitId) {
|
|
18058
|
+
const editor = this._editorService.getEditor(unitId);
|
|
18059
|
+
if (!editor) return false;
|
|
18060
|
+
return editor.isReadOnly();
|
|
18032
18061
|
}
|
|
18033
|
-
|
|
18034
|
-
this.
|
|
18035
|
-
id: EnterCommand.id,
|
|
18036
|
-
match: () => {
|
|
18037
|
-
return true;
|
|
18038
|
-
},
|
|
18039
|
-
getMutations() {
|
|
18040
|
-
return [{ id: BreakLineCommand.id }];
|
|
18041
|
-
},
|
|
18042
|
-
priority: -9999
|
|
18043
|
-
}));
|
|
18062
|
+
_isTraditionalMode() {
|
|
18063
|
+
return this._context.unit.getSnapshot().documentStyle.documentFlavor === _univerjs_core.DocumentFlavor.TRADITIONAL;
|
|
18044
18064
|
}
|
|
18045
18065
|
};
|
|
18046
|
-
|
|
18066
|
+
DocHeaderFooterController = __decorate([
|
|
18067
|
+
__decorateParam(1, _univerjs_core.ICommandService),
|
|
18068
|
+
__decorateParam(2, IEditorService),
|
|
18069
|
+
__decorateParam(3, _univerjs_core.IUniverInstanceService),
|
|
18070
|
+
__decorateParam(4, _univerjs_engine_render.IRenderManagerService),
|
|
18071
|
+
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_docs.DocSkeletonManagerService)),
|
|
18072
|
+
__decorateParam(6, (0, _univerjs_core.Inject)(DocSelectionRenderService)),
|
|
18073
|
+
__decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService))
|
|
18074
|
+
], DocHeaderFooterController);
|
|
18047
18075
|
|
|
18048
18076
|
//#endregion
|
|
18049
18077
|
//#region src/basics/table.ts
|
|
@@ -18109,10 +18137,10 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
18109
18137
|
}));
|
|
18110
18138
|
}
|
|
18111
18139
|
_handleShiftMoveSelection(direction, granularity = "character") {
|
|
18112
|
-
var _this$_renderManagerS, _body$dataStream$leng, _docDataModel$getCust;
|
|
18140
|
+
var _this$_renderManagerS, _docDataModel$getSelf, _body$dataStream$leng, _docDataModel$getCust;
|
|
18113
18141
|
const activeRange = this._textSelectionManagerService.getActiveTextRange();
|
|
18114
18142
|
const allRanges = this._textSelectionManagerService.getTextRanges();
|
|
18115
|
-
const docDataModel = this._univerInstanceService.
|
|
18143
|
+
const docDataModel = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
18116
18144
|
if (docDataModel == null) return;
|
|
18117
18145
|
const skeleton = (_this$_renderManagerS = this._renderManagerService.getRenderById(docDataModel.getUnitId())) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton();
|
|
18118
18146
|
const docObject = this._getDocObject();
|
|
@@ -18136,7 +18164,7 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
18136
18164
|
}
|
|
18137
18165
|
const anchorOffset = collapsed ? startOffset : rangeDirection === _univerjs_core.RANGE_DIRECTION.FORWARD ? startOffset : endOffset;
|
|
18138
18166
|
let focusOffset = collapsed ? endOffset : rangeDirection === _univerjs_core.RANGE_DIRECTION.FORWARD ? endOffset : startOffset;
|
|
18139
|
-
const body = docDataModel.getSelfOrHeaderFooterModel(normalizedSegmentId).getBody();
|
|
18167
|
+
const body = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(normalizedSegmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
18140
18168
|
if (body == null) return;
|
|
18141
18169
|
const dataStreamLength = (_body$dataStream$leng = body.dataStream.length) !== null && _body$dataStream$leng !== void 0 ? _body$dataStream$leng : Number.POSITIVE_INFINITY;
|
|
18142
18170
|
const customRanges = (_docDataModel$getCust = docDataModel.getCustomRanges()) !== null && _docDataModel$getCust !== void 0 ? _docDataModel$getCust : [];
|
|
@@ -18192,10 +18220,10 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
18192
18220
|
}
|
|
18193
18221
|
}
|
|
18194
18222
|
_handleMoveCursor(direction, granularity = "character") {
|
|
18195
|
-
var _this$_renderManagerS2, _body$dataStream$leng2, _docDataModel$getCust2;
|
|
18223
|
+
var _this$_renderManagerS2, _docDataModel$getSelf2, _body$dataStream$leng2, _docDataModel$getCust2;
|
|
18196
18224
|
const activeRange = this._textSelectionManagerService.getActiveTextRange();
|
|
18197
18225
|
const allRanges = this._textSelectionManagerService.getTextRanges();
|
|
18198
|
-
const docDataModel = this._univerInstanceService.
|
|
18226
|
+
const docDataModel = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
18199
18227
|
if (docDataModel == null) return false;
|
|
18200
18228
|
const skeleton = (_this$_renderManagerS2 = this._renderManagerService.getRenderById(docDataModel.getUnitId())) === null || _this$_renderManagerS2 === void 0 ? void 0 : _this$_renderManagerS2.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton();
|
|
18201
18229
|
const docObject = this._getDocObject();
|
|
@@ -18203,7 +18231,7 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
18203
18231
|
const { startOffset, endOffset, style, collapsed, segmentId, startNodePosition, endNodePosition, segmentPage } = activeRange;
|
|
18204
18232
|
const normalizedSegmentId = segmentId !== null && segmentId !== void 0 ? segmentId : "";
|
|
18205
18233
|
const normalizedSegmentPage = segmentPage !== null && segmentPage !== void 0 ? segmentPage : -1;
|
|
18206
|
-
const body = docDataModel.getSelfOrHeaderFooterModel(normalizedSegmentId).getBody();
|
|
18234
|
+
const body = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(normalizedSegmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.getBody();
|
|
18207
18235
|
if (body == null) return;
|
|
18208
18236
|
const dataStreamLength = (_body$dataStream$leng2 = body.dataStream.length) !== null && _body$dataStream$leng2 !== void 0 ? _body$dataStream$leng2 : Number.POSITIVE_INFINITY;
|
|
18209
18237
|
const customRanges = (_docDataModel$getCust2 = docDataModel.getCustomRanges()) !== null && _docDataModel$getCust2 !== void 0 ? _docDataModel$getCust2 : [];
|
|
@@ -18971,7 +18999,7 @@ let DocEditorBridgeController = class DocEditorBridgeController extends _univerj
|
|
|
18971
18999
|
if (unitId == null) return;
|
|
18972
19000
|
const editor = this._editorService.getEditor(unitId);
|
|
18973
19001
|
if ((editor === null || editor === void 0 ? void 0 : editor.cancelDefaultResizeListener) === true) return;
|
|
18974
|
-
const editorDataModel = this._univerInstanceService.
|
|
19002
|
+
const editorDataModel = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
18975
19003
|
if (!editorDataModel) return;
|
|
18976
19004
|
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
18977
19005
|
if (editor == null || editor.render == null || skeleton == null || editorDataModel == null) return;
|
|
@@ -19186,7 +19214,7 @@ let DocInputController = class DocInputController extends _univerjs_core.Disposa
|
|
|
19186
19214
|
}
|
|
19187
19215
|
_initialNormalInput() {
|
|
19188
19216
|
this._onInputSubscription = this._docSelectionRenderService.onInput$.subscribe(async (config) => {
|
|
19189
|
-
var _originBody$customRan, _originBody$customDec;
|
|
19217
|
+
var _docDataModel$getSelf, _originBody$customRan, _originBody$customDec;
|
|
19190
19218
|
if (config == null) return;
|
|
19191
19219
|
const { unitId } = this._context;
|
|
19192
19220
|
const { event, content = "", activeRange } = config;
|
|
@@ -19195,7 +19223,8 @@ let DocInputController = class DocInputController extends _univerjs_core.Disposa
|
|
|
19195
19223
|
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
19196
19224
|
if (e.data == null || skeleton == null || activeRange == null) return;
|
|
19197
19225
|
const { segmentId } = activeRange;
|
|
19198
|
-
const originBody = this._context.unit.getSelfOrHeaderFooterModel(segmentId).getBody();
|
|
19226
|
+
const originBody = (_docDataModel$getSelf = this._context.unit.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
19227
|
+
if (!originBody) return;
|
|
19199
19228
|
const defaultTextStyle = this._docMenuStyleService.getDefaultStyle();
|
|
19200
19229
|
const cacheStyle = this._docMenuStyleService.getStyleCache();
|
|
19201
19230
|
const curCustomRange = getCustomRangeAtPosition((_originBody$customRan = originBody === null || originBody === void 0 ? void 0 : originBody.customRanges) !== null && _originBody$customRan !== void 0 ? _originBody$customRan : [], activeRange.endOffset, _univerjs_core.SHEET_EDITOR_UNITS.includes(unitId));
|
|
@@ -19452,11 +19481,11 @@ let DocZoomRenderController = class DocZoomRenderController extends _univerjs_co
|
|
|
19452
19481
|
_initSkeletonListener() {
|
|
19453
19482
|
this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe((param) => {
|
|
19454
19483
|
if (param == null) return;
|
|
19455
|
-
const documentModel = this._univerInstanceService.
|
|
19484
|
+
const documentModel = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
19456
19485
|
if (!documentModel) return;
|
|
19457
19486
|
this._updateTimer = window.setTimeout(() => {
|
|
19458
19487
|
const currentSheet = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
19459
|
-
const sheetRenderer = currentSheet && this._renderManagerService.
|
|
19488
|
+
const sheetRenderer = currentSheet && this._renderManagerService.getRenderUnitById(currentSheet.getUnitId());
|
|
19460
19489
|
const zoomRatio = !this._isSheetEditor ? getDocEffectiveZoomRatio(documentModel) : (sheetRenderer === null || sheetRenderer === void 0 ? void 0 : sheetRenderer.scene.scaleX) || 1;
|
|
19461
19490
|
this.updateViewZoom(zoomRatio, false);
|
|
19462
19491
|
});
|
|
@@ -19492,7 +19521,7 @@ let DocZoomRenderController = class DocZoomRenderController extends _univerjs_co
|
|
|
19492
19521
|
_initZoomEventListener() {
|
|
19493
19522
|
const scene = this._context.scene;
|
|
19494
19523
|
this.disposeWithMe(scene.onMouseWheel$.subscribeEvent((e) => {
|
|
19495
|
-
const documentModel = this._univerInstanceService.
|
|
19524
|
+
const documentModel = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
19496
19525
|
if (!documentModel) return;
|
|
19497
19526
|
const { documentFlavor } = documentModel.getSnapshot().documentStyle;
|
|
19498
19527
|
if (!shouldHandleDocWheelZoom(e, Boolean(this._contextService.getContextValue(_univerjs_core.FOCUSING_DOC)), documentFlavor)) return;
|
|
@@ -19646,6 +19675,11 @@ const DeleteRightShortcut = {
|
|
|
19646
19675
|
preconditions: whenDocAndEditorFocused,
|
|
19647
19676
|
binding: _univerjs_ui.KeyCode.DELETE
|
|
19648
19677
|
};
|
|
19678
|
+
const CloseHeaderFooterShortcut = {
|
|
19679
|
+
id: CloseHeaderFooterCommand.id,
|
|
19680
|
+
preconditions: whenDocAndEditorFocused,
|
|
19681
|
+
binding: _univerjs_ui.KeyCode.ESC
|
|
19682
|
+
};
|
|
19649
19683
|
|
|
19650
19684
|
//#endregion
|
|
19651
19685
|
//#region src/shortcuts/cursor.shortcut.ts
|
|
@@ -19872,7 +19906,6 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
19872
19906
|
InsertCustomRangeCommand,
|
|
19873
19907
|
SetParagraphNamedStyleCommand,
|
|
19874
19908
|
QuickHeadingCommand,
|
|
19875
|
-
DeleteCurrentParagraphCommand,
|
|
19876
19909
|
DocCopyCurrentParagraphCommand,
|
|
19877
19910
|
DocCutCurrentParagraphCommand,
|
|
19878
19911
|
H1HeadingCommand,
|
|
@@ -19895,7 +19928,8 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
19895
19928
|
[
|
|
19896
19929
|
DocCopyCommand,
|
|
19897
19930
|
DocCutCommand,
|
|
19898
|
-
DocPasteCommand
|
|
19931
|
+
DocPasteCommand,
|
|
19932
|
+
DeleteCurrentParagraphCommand
|
|
19899
19933
|
].forEach((command) => this.disposeWithMe(this._commandService.registerMultipleCommand(command)));
|
|
19900
19934
|
}
|
|
19901
19935
|
_initializeShortcut() {
|
|
@@ -19927,6 +19961,7 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
19927
19961
|
SelectAllShortcut,
|
|
19928
19962
|
DeleteLeftShortcut,
|
|
19929
19963
|
DeleteRightShortcut,
|
|
19964
|
+
CloseHeaderFooterShortcut,
|
|
19930
19965
|
BreakLineShortcut,
|
|
19931
19966
|
SoftBreakLineShortcut,
|
|
19932
19967
|
ShiftTabShortCut,
|
|
@@ -20012,7 +20047,7 @@ _defineProperty(UniverDocsUIPlugin, "pluginName", "DOC_UI_PLUGIN");
|
|
|
20012
20047
|
_defineProperty(UniverDocsUIPlugin, "packageName", name);
|
|
20013
20048
|
_defineProperty(UniverDocsUIPlugin, "version", version);
|
|
20014
20049
|
UniverDocsUIPlugin = __decorate([
|
|
20015
|
-
(0, _univerjs_core.DependentOn)(_univerjs_engine_render.UniverRenderEnginePlugin),
|
|
20050
|
+
(0, _univerjs_core.DependentOn)(_univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_docs.UniverDocsPlugin),
|
|
20016
20051
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
20017
20052
|
__decorateParam(2, _univerjs_engine_render.IRenderManagerService),
|
|
20018
20053
|
__decorateParam(3, _univerjs_core.ICommandService),
|
|
@@ -20609,6 +20644,7 @@ exports.DOC_PARAGRAPH_T_INSERT_BELOW_MENU_ID = DOC_PARAGRAPH_T_INSERT_BELOW_MENU
|
|
|
20609
20644
|
exports.DOC_PARAGRAPH_T_INSERT_MENU_ID = DOC_PARAGRAPH_T_INSERT_MENU_ID;
|
|
20610
20645
|
exports.DOC_TABLE_BLOCK_MENU_ID = DOC_TABLE_BLOCK_MENU_ID;
|
|
20611
20646
|
exports.DOC_VERTICAL_PADDING = DOC_VERTICAL_PADDING;
|
|
20647
|
+
exports.DeleteCurrentParagraphCommand = DeleteCurrentParagraphCommand;
|
|
20612
20648
|
exports.DeleteCustomBlockCommand = DeleteCustomBlockCommand;
|
|
20613
20649
|
exports.DeleteLeftCommand = DeleteLeftCommand;
|
|
20614
20650
|
exports.DeleteRightCommand = DeleteRightCommand;
|
|
@@ -20780,6 +20816,7 @@ exports.convertBodyToHtml = convertBodyToHtml;
|
|
|
20780
20816
|
exports.convertPositionsToRectRanges = convertPositionsToRectRanges;
|
|
20781
20817
|
exports.createEditorUndoRedoKeyboardConfig = createEditorUndoRedoKeyboardConfig;
|
|
20782
20818
|
exports.deleteCustomDecorationFactory = deleteCustomDecorationFactory;
|
|
20819
|
+
exports.disableMenuWhenHeaderFooterEditing = disableMenuWhenHeaderFooterEditing;
|
|
20783
20820
|
exports.docDrawingPositionToTransform = docDrawingPositionToTransform;
|
|
20784
20821
|
exports.executeEditorUndoRedoCommand = executeEditorUndoRedoCommand;
|
|
20785
20822
|
exports.genTableSource = genTableSource;
|