@univerjs/docs-ui 1.0.0-alpha.2 → 1.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1924 -480
- package/lib/cjs/locale/ar-SA.js +40 -19
- package/lib/cjs/locale/ca-ES.js +39 -18
- package/lib/cjs/locale/de-DE.js +40 -19
- package/lib/cjs/locale/en-US.js +23 -2
- package/lib/cjs/locale/es-ES.js +40 -19
- package/lib/cjs/locale/fa-IR.js +40 -19
- package/lib/cjs/locale/fr-FR.js +40 -19
- package/lib/cjs/locale/id-ID.js +39 -18
- package/lib/cjs/locale/it-IT.js +40 -19
- package/lib/cjs/locale/ja-JP.js +40 -19
- package/lib/cjs/locale/ko-KR.js +40 -19
- package/lib/cjs/locale/pl-PL.js +40 -19
- package/lib/cjs/locale/pt-BR.js +39 -18
- package/lib/cjs/locale/ru-RU.js +40 -19
- package/lib/cjs/locale/sk-SK.js +40 -19
- package/lib/cjs/locale/vi-VN.js +40 -19
- package/lib/cjs/locale/zh-CN.js +23 -2
- package/lib/cjs/locale/zh-HK.js +23 -2
- package/lib/cjs/locale/zh-TW.js +23 -2
- package/lib/es/index.js +1845 -476
- package/lib/es/locale/ar-SA.js +40 -19
- package/lib/es/locale/ca-ES.js +39 -18
- package/lib/es/locale/de-DE.js +40 -19
- package/lib/es/locale/en-US.js +23 -2
- package/lib/es/locale/es-ES.js +40 -19
- package/lib/es/locale/fa-IR.js +40 -19
- package/lib/es/locale/fr-FR.js +40 -19
- package/lib/es/locale/id-ID.js +39 -18
- package/lib/es/locale/it-IT.js +40 -19
- package/lib/es/locale/ja-JP.js +40 -19
- package/lib/es/locale/ko-KR.js +40 -19
- package/lib/es/locale/pl-PL.js +40 -19
- package/lib/es/locale/pt-BR.js +39 -18
- package/lib/es/locale/ru-RU.js +40 -19
- package/lib/es/locale/sk-SK.js +40 -19
- package/lib/es/locale/vi-VN.js +40 -19
- package/lib/es/locale/zh-CN.js +23 -2
- package/lib/es/locale/zh-HK.js +23 -2
- package/lib/es/locale/zh-TW.js +23 -2
- package/lib/index.css +8 -0
- package/lib/index.js +1845 -476
- package/lib/locale/ar-SA.js +40 -19
- package/lib/locale/ca-ES.js +39 -18
- package/lib/locale/de-DE.js +40 -19
- package/lib/locale/en-US.js +23 -2
- package/lib/locale/es-ES.js +40 -19
- package/lib/locale/fa-IR.js +40 -19
- package/lib/locale/fr-FR.js +40 -19
- package/lib/locale/id-ID.js +39 -18
- package/lib/locale/it-IT.js +40 -19
- package/lib/locale/ja-JP.js +40 -19
- package/lib/locale/ko-KR.js +40 -19
- package/lib/locale/pl-PL.js +40 -19
- package/lib/locale/pt-BR.js +39 -18
- package/lib/locale/ru-RU.js +40 -19
- package/lib/locale/sk-SK.js +40 -19
- package/lib/locale/vi-VN.js +40 -19
- package/lib/locale/zh-CN.js +23 -2
- package/lib/locale/zh-HK.js +23 -2
- package/lib/locale/zh-TW.js +23 -2
- package/lib/types/commands/commands/break-line.command.d.ts +4 -3
- package/lib/types/commands/commands/doc-block-move.command.d.ts +13 -1
- package/lib/types/commands/commands/doc-header-footer.command.d.ts +1 -0
- package/lib/types/commands/commands/doc-horizontal-line.command.d.ts +1 -0
- package/lib/types/commands/commands/doc-paragraph-setting.command.d.ts +1 -2
- package/lib/types/commands/commands/replace-content.command.d.ts +2 -1
- package/lib/types/commands/operations/doc-section-setting-panel.operation.d.ts +17 -0
- package/lib/types/controllers/doc-section-setting.controller.d.ts +24 -0
- package/lib/types/controllers/render-controllers/doc-input.controller.d.ts +4 -1
- package/lib/types/controllers/render-controllers/doc-selection-render.controller.d.ts +5 -1
- package/lib/types/controllers/render-controllers/doc.render-controller.d.ts +4 -1
- package/lib/types/controllers/render-controllers/zoom.render-controller.d.ts +3 -1
- package/lib/types/controllers/ui.controller.d.ts +4 -1
- package/lib/types/embed-docs-custom-block-bleed.d.ts +30 -0
- package/lib/types/embed-docs-custom-block-refresh.d.ts +28 -0
- package/lib/types/embed-docs-custom-block-scroll.d.ts +19 -0
- package/lib/types/embed-host-anchor.d.ts +45 -0
- package/lib/types/index.d.ts +16 -1
- package/lib/types/locale/en-US.d.ts +17 -0
- package/lib/types/menu/context-menu.d.ts +1 -0
- package/lib/types/menu/menu.d.ts +1 -1
- package/lib/types/services/clipboard/clipboard.service.d.ts +7 -3
- package/lib/types/services/clipboard/doc-paste-mutation-adapter.service.d.ts +47 -0
- package/lib/types/services/clipboard/html-to-udm/converter.d.ts +1 -0
- package/lib/types/services/doc-embed-integration.service.d.ts +63 -0
- package/lib/types/services/doc-popup-manager.service.d.ts +2 -0
- package/lib/types/services/docs-render.service.d.ts +1 -1
- package/lib/types/services/float-menu.service.d.ts +1 -0
- package/lib/types/services/selection/convert-text-range.d.ts +3 -0
- package/lib/types/services/selection/doc-selection-render.service.d.ts +18 -4
- package/lib/types/utils/section-header-footer.d.ts +26 -0
- package/lib/types/views/ParagraphMenu.d.ts +7 -3
- package/lib/types/views/paragraph-setting/hook/utils.d.ts +13 -3
- package/lib/types/views/paragraph-setting/line-spacing.d.ts +4 -4
- package/lib/types/views/section-setting/Setting.d.ts +16 -0
- package/lib/types/views/section-setting/component-name.d.ts +16 -0
- package/lib/types/views/section-setting/index.d.ts +16 -0
- package/lib/types/views/section-setting/use-section-setting.d.ts +43 -0
- package/lib/umd/index.js +9 -9
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +10 -11
package/lib/cjs/index.js
CHANGED
|
@@ -3,7 +3,6 @@ let _univerjs_core = require("@univerjs/core");
|
|
|
3
3
|
let _univerjs_docs = require("@univerjs/docs");
|
|
4
4
|
let _univerjs_engine_render = require("@univerjs/engine-render");
|
|
5
5
|
let _univerjs_ui = require("@univerjs/ui");
|
|
6
|
-
let _univerjs_drawing = require("@univerjs/drawing");
|
|
7
6
|
let rxjs = require("rxjs");
|
|
8
7
|
let rxjs_operators = require("rxjs/operators");
|
|
9
8
|
let _univerjs_design = require("@univerjs/design");
|
|
@@ -432,30 +431,6 @@ DocMenuStyleService = __decorate([
|
|
|
432
431
|
|
|
433
432
|
//#endregion
|
|
434
433
|
//#region src/commands/commands/break-line.command.ts
|
|
435
|
-
function generateParagraphs(dataStream, prevParagraph, borderBottom) {
|
|
436
|
-
const paragraphs = [];
|
|
437
|
-
const existingParagraphIds = /* @__PURE__ */ new Set();
|
|
438
|
-
for (let i = 0, len = dataStream.length; i < len; i++) {
|
|
439
|
-
if (dataStream[i] !== _univerjs_core.DataStreamTreeTokenType.PARAGRAPH) continue;
|
|
440
|
-
paragraphs.push({
|
|
441
|
-
startIndex: i,
|
|
442
|
-
paragraphId: (0, _univerjs_core.createParagraphId)(existingParagraphIds)
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
if (prevParagraph) for (const paragraph of paragraphs) {
|
|
446
|
-
if (prevParagraph.bullet) paragraph.bullet = _univerjs_core.Tools.deepClone(prevParagraph.bullet);
|
|
447
|
-
if (prevParagraph.paragraphStyle) {
|
|
448
|
-
paragraph.paragraphStyle = _univerjs_core.Tools.deepClone(prevParagraph.paragraphStyle);
|
|
449
|
-
delete paragraph.paragraphStyle.borderBottom;
|
|
450
|
-
if (prevParagraph.paragraphStyle.headingId) paragraph.paragraphStyle.headingId = (0, _univerjs_core.generateRandomId)(6);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
if (borderBottom) for (const paragraph of paragraphs) {
|
|
454
|
-
if (!paragraph.paragraphStyle) paragraph.paragraphStyle = {};
|
|
455
|
-
paragraph.paragraphStyle.borderBottom = borderBottom;
|
|
456
|
-
}
|
|
457
|
-
return paragraphs;
|
|
458
|
-
}
|
|
459
434
|
const BreakLineCommand = {
|
|
460
435
|
id: "doc.command.break-line",
|
|
461
436
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -476,21 +451,23 @@ const BreakLineCommand = {
|
|
|
476
451
|
}]);
|
|
477
452
|
return true;
|
|
478
453
|
}
|
|
479
|
-
const { horizontalLine } = params !== null && params !== void 0 ? params : {};
|
|
454
|
+
const { horizontalLine, insertionMode = "split-paragraph" } = params !== null && params !== void 0 ? params : {};
|
|
480
455
|
const { segmentId } = activeTextRange;
|
|
481
456
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
482
457
|
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
458
|
if (docDataModel == null || originBody == null) return false;
|
|
484
459
|
const unitId = docDataModel.getUnitId();
|
|
485
460
|
const { startOffset, endOffset } = activeTextRange;
|
|
486
|
-
const
|
|
487
|
-
|
|
488
|
-
const
|
|
489
|
-
|
|
461
|
+
const paragraphs = (_originBody$paragraph = originBody.paragraphs) !== null && _originBody$paragraph !== void 0 ? _originBody$paragraph : [];
|
|
462
|
+
const insertsAtStructuralGap = insertionMode === "insert-gap" || isTopLevelStructuralGap(originBody.dataStream, startOffset);
|
|
463
|
+
const prevParagraph = insertsAtStructuralGap ? void 0 : paragraphs.find((p) => p.startIndex >= startOffset);
|
|
464
|
+
if (!prevParagraph && !insertsAtStructuralGap) return false;
|
|
465
|
+
const isAtParagraphEnd = startOffset === (prevParagraph === null || prevParagraph === void 0 ? void 0 : prevParagraph.startIndex);
|
|
466
|
+
const prevParagraphIndex = prevParagraph === null || prevParagraph === void 0 ? void 0 : prevParagraph.startIndex;
|
|
490
467
|
const curTextRun = getTextRunAtPosition(originBody, endOffset, docMenuStyleService.getDefaultStyle(), docMenuStyleService.getStyleCache());
|
|
491
468
|
const insertBody = {
|
|
492
469
|
dataStream: _univerjs_core.DataStreamTreeTokenType.PARAGRAPH,
|
|
493
|
-
paragraphs: generateParagraphs(_univerjs_core.DataStreamTreeTokenType.PARAGRAPH, prevParagraph, horizontalLine),
|
|
470
|
+
paragraphs: (0, _univerjs_docs.generateParagraphs)(_univerjs_core.DataStreamTreeTokenType.PARAGRAPH, prevParagraph, horizontalLine),
|
|
494
471
|
textRuns: [{
|
|
495
472
|
st: 0,
|
|
496
473
|
ed: 1,
|
|
@@ -501,7 +478,7 @@ const BreakLineCommand = {
|
|
|
501
478
|
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
502
479
|
if (originBody == null) return false;
|
|
503
480
|
const { collapsed } = activeTextRange;
|
|
504
|
-
const cursorMove = insertBody.dataStream.length;
|
|
481
|
+
const cursorMove = insertsAtStructuralGap ? 0 : insertBody.dataStream.length;
|
|
505
482
|
const textRanges = [{
|
|
506
483
|
startOffset: startOffset + cursorMove,
|
|
507
484
|
endOffset: startOffset + cursorMove,
|
|
@@ -514,7 +491,8 @@ const BreakLineCommand = {
|
|
|
514
491
|
unitId,
|
|
515
492
|
actions: [],
|
|
516
493
|
textRanges,
|
|
517
|
-
debounce: true
|
|
494
|
+
debounce: true,
|
|
495
|
+
trigger: BreakLineCommand.id
|
|
518
496
|
}
|
|
519
497
|
};
|
|
520
498
|
const textX = new _univerjs_core.TextX();
|
|
@@ -533,9 +511,9 @@ const BreakLineCommand = {
|
|
|
533
511
|
const dos = _univerjs_core.BuildTextUtils.selection.delete([activeTextRange], originBody, 0, insertBody);
|
|
534
512
|
textX.push(...dos);
|
|
535
513
|
}
|
|
536
|
-
if (((_prevParagraph$bullet = prevParagraph.bullet) === null || _prevParagraph$bullet === void 0 ? void 0 : _prevParagraph$bullet.listType) === _univerjs_core.PresetListType.CHECK_LIST_CHECKED || ((_prevParagraph$paragr = prevParagraph.paragraphStyle) === null || _prevParagraph$paragr === void 0 ? void 0 : _prevParagraph$paragr.headingId)) {
|
|
514
|
+
if (prevParagraph && (((_prevParagraph$bullet = prevParagraph.bullet) === null || _prevParagraph$bullet === void 0 ? void 0 : _prevParagraph$bullet.listType) === _univerjs_core.PresetListType.CHECK_LIST_CHECKED || ((_prevParagraph$paragr = prevParagraph.paragraphStyle) === null || _prevParagraph$paragr === void 0 ? void 0 : _prevParagraph$paragr.headingId))) {
|
|
537
515
|
var _prevParagraph$paragr2;
|
|
538
|
-
if (activeTextRange.endOffset < prevParagraphIndex) textX.push({
|
|
516
|
+
if (prevParagraphIndex != null && activeTextRange.endOffset < prevParagraphIndex) textX.push({
|
|
539
517
|
t: _univerjs_core.TextXActionType.RETAIN,
|
|
540
518
|
len: prevParagraphIndex - activeTextRange.endOffset
|
|
541
519
|
});
|
|
@@ -574,6 +552,41 @@ const BreakLineCommand = {
|
|
|
574
552
|
return Boolean(result);
|
|
575
553
|
}
|
|
576
554
|
};
|
|
555
|
+
function isTopLevelStructuralGap(dataStream, offset) {
|
|
556
|
+
const previousToken = dataStream[offset - 1];
|
|
557
|
+
const nextToken = dataStream[offset];
|
|
558
|
+
return previousToken === _univerjs_core.DataStreamTreeTokenType.BLOCK_END || previousToken === _univerjs_core.DataStreamTreeTokenType.TABLE_END || previousToken === _univerjs_core.DataStreamTreeTokenType.COLUMN_GROUP_END || nextToken === _univerjs_core.DataStreamTreeTokenType.BLOCK_START || nextToken === _univerjs_core.DataStreamTreeTokenType.TABLE_START || nextToken === _univerjs_core.DataStreamTreeTokenType.COLUMN_GROUP_START;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
//#endregion
|
|
562
|
+
//#region src/services/clipboard/doc-paste-mutation-adapter.service.ts
|
|
563
|
+
const IDocClipboardPasteAdapterService = (0, _univerjs_core.createIdentifier)("doc.clipboard-paste-adapter.service");
|
|
564
|
+
var DocClipboardPasteAdapterService = class {
|
|
565
|
+
constructor() {
|
|
566
|
+
_defineProperty(this, "_adapters", []);
|
|
567
|
+
}
|
|
568
|
+
registerAdapter(adapter) {
|
|
569
|
+
this._adapters.push(adapter);
|
|
570
|
+
return (0, _univerjs_core.toDisposable)(() => {
|
|
571
|
+
const index = this._adapters.indexOf(adapter);
|
|
572
|
+
if (index >= 0) this._adapters.splice(index, 1);
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
getPasteMutationInfos(params) {
|
|
576
|
+
const mutationInfos = {
|
|
577
|
+
redoMutations: [],
|
|
578
|
+
undoMutations: []
|
|
579
|
+
};
|
|
580
|
+
for (const adapter of this._adapters) {
|
|
581
|
+
var _adapter$getPasteMuta;
|
|
582
|
+
const nextMutationInfos = (_adapter$getPasteMuta = adapter.getPasteMutationInfos) === null || _adapter$getPasteMuta === void 0 ? void 0 : _adapter$getPasteMuta.call(adapter, params);
|
|
583
|
+
if (!nextMutationInfos) continue;
|
|
584
|
+
mutationInfos.redoMutations.push(...nextMutationInfos.redoMutations);
|
|
585
|
+
mutationInfos.undoMutations.push(...nextMutationInfos.undoMutations);
|
|
586
|
+
}
|
|
587
|
+
return mutationInfos;
|
|
588
|
+
}
|
|
589
|
+
};
|
|
577
590
|
|
|
578
591
|
//#endregion
|
|
579
592
|
//#region src/commands/util.ts
|
|
@@ -594,6 +607,7 @@ function genEmptyTable(rowCount, colCount) {
|
|
|
594
607
|
const paragraphs = [];
|
|
595
608
|
const sectionBreaks = [];
|
|
596
609
|
const existingParagraphIds = /* @__PURE__ */ new Set();
|
|
610
|
+
const existingSectionIds = /* @__PURE__ */ new Set();
|
|
597
611
|
for (let i = 0; i < rowCount; i++) {
|
|
598
612
|
dataStream += _univerjs_core.DataStreamTreeTokenType.TABLE_ROW_START;
|
|
599
613
|
for (let j = 0; j < colCount; j++) {
|
|
@@ -607,7 +621,10 @@ function genEmptyTable(rowCount, colCount) {
|
|
|
607
621
|
spaceBelow: { v: 0 }
|
|
608
622
|
}
|
|
609
623
|
});
|
|
610
|
-
sectionBreaks.push({
|
|
624
|
+
sectionBreaks.push({
|
|
625
|
+
sectionId: (0, _univerjs_core.createSectionId)(existingSectionIds),
|
|
626
|
+
startIndex: dataStream.length - 2
|
|
627
|
+
});
|
|
611
628
|
}
|
|
612
629
|
dataStream += _univerjs_core.DataStreamTreeTokenType.TABLE_ROW_END;
|
|
613
630
|
}
|
|
@@ -712,6 +729,7 @@ function getInsertRowBody(col) {
|
|
|
712
729
|
const paragraphs = [];
|
|
713
730
|
const sectionBreaks = [];
|
|
714
731
|
const existingParagraphIds = /* @__PURE__ */ new Set();
|
|
732
|
+
const existingSectionIds = /* @__PURE__ */ new Set();
|
|
715
733
|
for (let i = 0; i < col; i++) {
|
|
716
734
|
dataStream += `${_univerjs_core.DataStreamTreeTokenType.TABLE_CELL_START}\r\n${_univerjs_core.DataStreamTreeTokenType.TABLE_CELL_END}`;
|
|
717
735
|
paragraphs.push({
|
|
@@ -723,7 +741,10 @@ function getInsertRowBody(col) {
|
|
|
723
741
|
spaceBelow: { v: 0 }
|
|
724
742
|
}
|
|
725
743
|
});
|
|
726
|
-
sectionBreaks.push({
|
|
744
|
+
sectionBreaks.push({
|
|
745
|
+
sectionId: (0, _univerjs_core.createSectionId)(existingSectionIds),
|
|
746
|
+
startIndex: dataStream.length - 2
|
|
747
|
+
});
|
|
727
748
|
}
|
|
728
749
|
dataStream += _univerjs_core.DataStreamTreeTokenType.TABLE_ROW_END;
|
|
729
750
|
return {
|
|
@@ -745,7 +766,10 @@ function getInsertColumnBody() {
|
|
|
745
766
|
spaceBelow: { v: 0 }
|
|
746
767
|
}
|
|
747
768
|
});
|
|
748
|
-
sectionBreaks.push({
|
|
769
|
+
sectionBreaks.push({
|
|
770
|
+
sectionId: (0, _univerjs_core.createSectionId)(/* @__PURE__ */ new Set()),
|
|
771
|
+
startIndex: 2
|
|
772
|
+
});
|
|
749
773
|
return {
|
|
750
774
|
dataStream,
|
|
751
775
|
paragraphs,
|
|
@@ -1102,8 +1126,10 @@ const InnerPasteCommand = {
|
|
|
1102
1126
|
var _docDataModel$getSelf, _body$tables, _body$customBlocks;
|
|
1103
1127
|
const { segmentId, textRanges, doc } = params;
|
|
1104
1128
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
1129
|
+
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
1105
1130
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
1106
1131
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
1132
|
+
const pasteAdapterService = getPasteAdapterService(accessor);
|
|
1107
1133
|
const selections = docSelectionManagerService.getTextRanges();
|
|
1108
1134
|
const rectRanges = docSelectionManagerService.getRectRanges();
|
|
1109
1135
|
const { body, tableSource, drawings } = doc;
|
|
@@ -1126,6 +1152,9 @@ const InnerPasteCommand = {
|
|
|
1126
1152
|
const textX = new _univerjs_core.TextX();
|
|
1127
1153
|
const jsonX = _univerjs_core.JSONX.getInstance();
|
|
1128
1154
|
const rawActions = [];
|
|
1155
|
+
const resourceRedoMutations = [];
|
|
1156
|
+
const resourceUndoMutations = [];
|
|
1157
|
+
const resourceMutationGroups = [];
|
|
1129
1158
|
const hasTable = !!((_body$tables = body.tables) === null || _body$tables === void 0 ? void 0 : _body$tables.length);
|
|
1130
1159
|
const hasCustomBlock = !!((_body$customBlocks = body.customBlocks) === null || _body$customBlocks === void 0 ? void 0 : _body$customBlocks.length);
|
|
1131
1160
|
if (hasTable && segmentId) return false;
|
|
@@ -1149,17 +1178,42 @@ const InnerPasteCommand = {
|
|
|
1149
1178
|
if (hasCustomBlock && drawings) {
|
|
1150
1179
|
var _docDataModel$getSnap, _docDataModel$getSnap2;
|
|
1151
1180
|
const drawingLen = (_docDataModel$getSnap = (_docDataModel$getSnap2 = docDataModel.getSnapshot().drawingsOrder) === null || _docDataModel$getSnap2 === void 0 ? void 0 : _docDataModel$getSnap2.length) !== null && _docDataModel$getSnap !== void 0 ? _docDataModel$getSnap : 0;
|
|
1181
|
+
const customBlockMappings = [];
|
|
1152
1182
|
for (const block of cloneBody.customBlocks) {
|
|
1153
1183
|
const { blockId } = block;
|
|
1154
1184
|
const drawingId = (0, _univerjs_core.generateRandomId)(6);
|
|
1155
1185
|
block.blockId = drawingId;
|
|
1156
|
-
const
|
|
1186
|
+
const sourceDrawing = drawings[blockId];
|
|
1187
|
+
const drawing = _univerjs_core.Tools.deepClone(sourceDrawing);
|
|
1157
1188
|
drawing.drawingId = drawingId;
|
|
1158
|
-
|
|
1159
|
-
|
|
1189
|
+
customBlockMappings.push({
|
|
1190
|
+
sourceBlockId: blockId,
|
|
1191
|
+
targetBlockId: drawingId,
|
|
1192
|
+
sourceDrawing,
|
|
1193
|
+
targetDrawing: drawing
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
if (customBlockMappings.length > 0 && pasteAdapterService) {
|
|
1197
|
+
const mutationInfos = pasteAdapterService.getPasteMutationInfos({
|
|
1198
|
+
unitId,
|
|
1199
|
+
segmentId,
|
|
1200
|
+
doc,
|
|
1201
|
+
sourceBody: body,
|
|
1202
|
+
targetBody: cloneBody,
|
|
1203
|
+
customBlockMappings
|
|
1204
|
+
});
|
|
1205
|
+
if (mutationInfos.redoMutations.length > 0 || mutationInfos.undoMutations.length > 0) {
|
|
1206
|
+
resourceRedoMutations.push(...mutationInfos.redoMutations);
|
|
1207
|
+
resourceUndoMutations.push(...mutationInfos.undoMutations);
|
|
1208
|
+
resourceMutationGroups.push(mutationInfos);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
customBlockMappings.forEach(({ targetBlockId, targetDrawing }) => {
|
|
1212
|
+
const action = jsonX.insertOp(["drawings", targetBlockId], targetDrawing);
|
|
1213
|
+
const orderAction = jsonX.insertOp(["drawingsOrder", drawingLen], targetBlockId);
|
|
1160
1214
|
rawActions.push(action);
|
|
1161
1215
|
rawActions.push(orderAction);
|
|
1162
|
-
}
|
|
1216
|
+
});
|
|
1163
1217
|
}
|
|
1164
1218
|
const customRange = getCustomRangeAtPosition((_originBody$customRan = originBody.customRanges) !== null && _originBody$customRan !== void 0 ? _originBody$customRan : [], endOffset, UNITS.includes(unitId));
|
|
1165
1219
|
const customDecorations = getCustomDecorationAtPosition((_originBody$customDec = originBody.customDecorations) !== null && _originBody$customDec !== void 0 ? _originBody$customDec : [], endOffset);
|
|
@@ -1195,10 +1249,55 @@ const InnerPasteCommand = {
|
|
|
1195
1249
|
doMutation.params.actions = rawActions.reduce((acc, cur) => {
|
|
1196
1250
|
return _univerjs_core.JSONX.compose(acc, cur);
|
|
1197
1251
|
}, null);
|
|
1252
|
+
if (!executeResourceMutationGroups(resourceMutationGroups, commandService)) return false;
|
|
1253
|
+
const historyId = `doc-paste-resource:${unitId}:${Date.now()}`;
|
|
1254
|
+
let batchingDisposable = null;
|
|
1255
|
+
if (resourceRedoMutations.length > 0 || resourceUndoMutations.length > 0) {
|
|
1256
|
+
batchingDisposable = undoRedoService.__tempBatchingUndoRedo(unitId);
|
|
1257
|
+
undoRedoService.pushUndoRedo({
|
|
1258
|
+
unitID: unitId,
|
|
1259
|
+
redoMutations: resourceRedoMutations,
|
|
1260
|
+
undoMutations: resourceUndoMutations,
|
|
1261
|
+
id: historyId
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1198
1264
|
const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
1265
|
+
if (!result && batchingDisposable != null) {
|
|
1266
|
+
batchingDisposable.dispose();
|
|
1267
|
+
undoRedoService.rollback(historyId, unitId);
|
|
1268
|
+
return false;
|
|
1269
|
+
}
|
|
1270
|
+
batchingDisposable === null || batchingDisposable === void 0 || batchingDisposable.dispose();
|
|
1199
1271
|
return Boolean(result);
|
|
1200
1272
|
}
|
|
1201
1273
|
};
|
|
1274
|
+
function getPasteAdapterService(accessor) {
|
|
1275
|
+
try {
|
|
1276
|
+
return accessor.get(IDocClipboardPasteAdapterService);
|
|
1277
|
+
} catch {
|
|
1278
|
+
return null;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
function executeResourceMutationGroups(mutationGroups, commandService) {
|
|
1282
|
+
const executedUndoGroups = [];
|
|
1283
|
+
for (const mutationGroup of mutationGroups) {
|
|
1284
|
+
if (!executeMutations(mutationGroup.redoMutations, commandService)) {
|
|
1285
|
+
executeMutationGroups([...executedUndoGroups].reverse(), commandService);
|
|
1286
|
+
return false;
|
|
1287
|
+
}
|
|
1288
|
+
executedUndoGroups.push(mutationGroup.undoMutations);
|
|
1289
|
+
}
|
|
1290
|
+
return true;
|
|
1291
|
+
}
|
|
1292
|
+
function executeMutationGroups(mutationGroups, commandService) {
|
|
1293
|
+
mutationGroups.forEach((mutations) => {
|
|
1294
|
+
executeMutations(mutations, commandService);
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
function executeMutations(mutations, commandService) {
|
|
1298
|
+
for (const mutation of mutations) if (!commandService.syncExecuteCommand(mutation.id, mutation.params)) return false;
|
|
1299
|
+
return true;
|
|
1300
|
+
}
|
|
1202
1301
|
function adjustSelectionByTable(selection, tables) {
|
|
1203
1302
|
const { startOffset, endOffset } = selection;
|
|
1204
1303
|
const endsWithTable = tables.some((t) => t.startIndex === endOffset);
|
|
@@ -1614,14 +1713,11 @@ function getCursorWhenDelete(textRanges, rectRanges) {
|
|
|
1614
1713
|
}
|
|
1615
1714
|
return cursor;
|
|
1616
1715
|
}
|
|
1617
|
-
function getBlockRangeEndTokenOffset(body, blockRange) {
|
|
1618
|
-
return body.dataStream[blockRange.endIndex] === _univerjs_core.DataStreamTreeTokenType.BLOCK_END ? blockRange.endIndex : body.dataStream[blockRange.endIndex + 1] === _univerjs_core.DataStreamTreeTokenType.BLOCK_END ? blockRange.endIndex + 1 : blockRange.endIndex;
|
|
1619
|
-
}
|
|
1620
1716
|
function isDeleteOffsetInsideBlockRange(body, offset) {
|
|
1621
1717
|
var _body$blockRanges$som, _body$blockRanges;
|
|
1622
1718
|
return (_body$blockRanges$som = (_body$blockRanges = body.blockRanges) === null || _body$blockRanges === void 0 ? void 0 : _body$blockRanges.some((blockRange) => {
|
|
1623
|
-
const
|
|
1624
|
-
return
|
|
1719
|
+
const interval = (0, _univerjs_core.getBlockRangeInterval)(blockRange);
|
|
1720
|
+
return interval.startOffset < offset && offset < interval.endOffset - 1;
|
|
1625
1721
|
})) !== null && _body$blockRanges$som !== void 0 ? _body$blockRanges$som : false;
|
|
1626
1722
|
}
|
|
1627
1723
|
const DeleteLeftCommand = {
|
|
@@ -2112,6 +2208,10 @@ var HtmlToUDMService = class HtmlToUDMService {
|
|
|
2112
2208
|
var _body$paragraphs;
|
|
2113
2209
|
return (0, _univerjs_core.createParagraphId)(new Set((_body$paragraphs = body.paragraphs) === null || _body$paragraphs === void 0 ? void 0 : _body$paragraphs.map((paragraph) => paragraph.paragraphId)));
|
|
2114
2210
|
}
|
|
2211
|
+
_createSectionId(body) {
|
|
2212
|
+
var _body$sectionBreaks;
|
|
2213
|
+
return (0, _univerjs_core.createSectionId)(new Set((_body$sectionBreaks = body.sectionBreaks) === null || _body$sectionBreaks === void 0 ? void 0 : _body$sectionBreaks.map((sectionBreak) => sectionBreak.sectionId)));
|
|
2214
|
+
}
|
|
2115
2215
|
convert(html, metaConfig = {}) {
|
|
2116
2216
|
var _pastePlugin$preproce, _pastePlugin$preproce2, _metaConfig$unitId;
|
|
2117
2217
|
const pastePlugin = HtmlToUDMService._pluginList.find((plugin) => plugin.checkPasteType(html));
|
|
@@ -2159,7 +2259,7 @@ var HtmlToUDMService = class HtmlToUDMService {
|
|
|
2159
2259
|
var _element$dataset$imag;
|
|
2160
2260
|
const element = node;
|
|
2161
2261
|
const imageSourceType = (_element$dataset$imag = element.dataset.imageSourceType) !== null && _element$dataset$imag !== void 0 ? _element$dataset$imag : element.src ? inferImageSourceType(element.src) : void 0;
|
|
2162
|
-
const source = imageSourceType ===
|
|
2262
|
+
const source = imageSourceType === _univerjs_core.ImageSourceType.UUID ? element.dataset.source : element.src;
|
|
2163
2263
|
if (source && imageSourceType) {
|
|
2164
2264
|
var _readImageSize, _readImageSize2, _readCssSize, _readCssSize2, _doc$body;
|
|
2165
2265
|
const width = (_readImageSize = readImageSize(element, "width")) !== null && _readImageSize !== void 0 ? _readImageSize : 100;
|
|
@@ -2337,7 +2437,7 @@ var HtmlToUDMService = class HtmlToUDMService {
|
|
|
2337
2437
|
if (wordListContext) paragraph.startIndex -= stripListMarkerFromCurrentParagraph(doc.body);
|
|
2338
2438
|
}
|
|
2339
2439
|
_processHtmlTable(node, doc) {
|
|
2340
|
-
var _doc$tableSource, _body$tables, _body$
|
|
2440
|
+
var _doc$tableSource, _body$tables, _body$sectionBreaks2;
|
|
2341
2441
|
const body = doc.body;
|
|
2342
2442
|
if (body.dataStream[body.dataStream.length - 1] !== "\r") {
|
|
2343
2443
|
var _body$paragraphs3;
|
|
@@ -2350,7 +2450,7 @@ var HtmlToUDMService = class HtmlToUDMService {
|
|
|
2350
2450
|
}
|
|
2351
2451
|
(_doc$tableSource = doc.tableSource) !== null && _doc$tableSource !== void 0 || (doc.tableSource = {});
|
|
2352
2452
|
(_body$tables = body.tables) !== null && _body$tables !== void 0 || (body.tables = []);
|
|
2353
|
-
(_body$
|
|
2453
|
+
(_body$sectionBreaks2 = body.sectionBreaks) !== null && _body$sectionBreaks2 !== void 0 || (body.sectionBreaks = []);
|
|
2354
2454
|
const rows = collectHtmlTableRows(node);
|
|
2355
2455
|
const grid = buildHtmlTableGrid(rows);
|
|
2356
2456
|
const columnCount = Math.max(1, ...grid.map((row) => row.length));
|
|
@@ -2402,7 +2502,7 @@ var HtmlToUDMService = class HtmlToUDMService {
|
|
|
2402
2502
|
});
|
|
2403
2503
|
}
|
|
2404
2504
|
_appendHtmlTableCell(cell, doc) {
|
|
2405
|
-
var _body$
|
|
2505
|
+
var _body$sectionBreaks3;
|
|
2406
2506
|
const body = doc.body;
|
|
2407
2507
|
body.dataStream += _univerjs_core.DataStreamTreeTokenType.TABLE_CELL_START;
|
|
2408
2508
|
if (cell.element && !cell.covered) this._process(cell.element, cell.element.childNodes, doc);
|
|
@@ -2410,8 +2510,11 @@ var HtmlToUDMService = class HtmlToUDMService {
|
|
|
2410
2510
|
var _cell$element;
|
|
2411
2511
|
this._appendParagraph(doc, (_cell$element = cell.element) !== null && _cell$element !== void 0 ? _cell$element : document.createElement("td"));
|
|
2412
2512
|
}
|
|
2413
|
-
(_body$
|
|
2414
|
-
body.sectionBreaks.push({
|
|
2513
|
+
(_body$sectionBreaks3 = body.sectionBreaks) !== null && _body$sectionBreaks3 !== void 0 || (body.sectionBreaks = []);
|
|
2514
|
+
body.sectionBreaks.push({
|
|
2515
|
+
sectionId: this._createSectionId(body),
|
|
2516
|
+
startIndex: body.dataStream.length
|
|
2517
|
+
});
|
|
2415
2518
|
body.dataStream += `\n${_univerjs_core.DataStreamTreeTokenType.TABLE_CELL_END}`;
|
|
2416
2519
|
}
|
|
2417
2520
|
_processBeforeTable(node, doc) {
|
|
@@ -2477,7 +2580,7 @@ var HtmlToUDMService = class HtmlToUDMService {
|
|
|
2477
2580
|
body.dataStream += _univerjs_core.DataStreamTreeTokenType.TABLE_ROW_END;
|
|
2478
2581
|
break;
|
|
2479
2582
|
case "TD":
|
|
2480
|
-
var _body$
|
|
2583
|
+
var _body$sectionBreaks4;
|
|
2481
2584
|
if (body.dataStream[body.dataStream.length - 1] !== "\r") {
|
|
2482
2585
|
var _body$paragraphs5;
|
|
2483
2586
|
(_body$paragraphs5 = body.paragraphs) === null || _body$paragraphs5 === void 0 || _body$paragraphs5.push({
|
|
@@ -2486,7 +2589,10 @@ var HtmlToUDMService = class HtmlToUDMService {
|
|
|
2486
2589
|
});
|
|
2487
2590
|
body.dataStream += "\r";
|
|
2488
2591
|
}
|
|
2489
|
-
(_body$
|
|
2592
|
+
(_body$sectionBreaks4 = body.sectionBreaks) === null || _body$sectionBreaks4 === void 0 || _body$sectionBreaks4.push({
|
|
2593
|
+
sectionId: this._createSectionId(body),
|
|
2594
|
+
startIndex: body.dataStream.length
|
|
2595
|
+
});
|
|
2490
2596
|
body.dataStream += `\n${_univerjs_core.DataStreamTreeTokenType.TABLE_CELL_END}`;
|
|
2491
2597
|
break;
|
|
2492
2598
|
}
|
|
@@ -2533,7 +2639,7 @@ function normalizeTextNode(node) {
|
|
|
2533
2639
|
return hasTextSibling(node.previousSibling, "previous") && hasTextSibling(node.nextSibling, "next") ? " " : "";
|
|
2534
2640
|
}
|
|
2535
2641
|
function inferImageSourceType(src) {
|
|
2536
|
-
return src.startsWith("data:image/") ?
|
|
2642
|
+
return src.startsWith("data:image/") ? _univerjs_core.ImageSourceType.BASE64 : _univerjs_core.ImageSourceType.URL;
|
|
2537
2643
|
}
|
|
2538
2644
|
function hasTextSibling(node, direction) {
|
|
2539
2645
|
let current = node;
|
|
@@ -3200,7 +3306,7 @@ function covertImageToHtml(item) {
|
|
|
3200
3306
|
"data-width": (_item$transform = item.transform) === null || _item$transform === void 0 ? void 0 : _item$transform.width,
|
|
3201
3307
|
"data-height": (_item$transform2 = item.transform) === null || _item$transform2 === void 0 ? void 0 : _item$transform2.height,
|
|
3202
3308
|
"data-image-source-type": item.imageSourceType,
|
|
3203
|
-
"data-source": item.imageSourceType ===
|
|
3309
|
+
"data-source": item.imageSourceType === _univerjs_core.ImageSourceType.UUID ? item.source : void 0,
|
|
3204
3310
|
src: item.source
|
|
3205
3311
|
})}></img>`;
|
|
3206
3312
|
}
|
|
@@ -3315,7 +3421,10 @@ function convertBodyToHtml(doc) {
|
|
|
3315
3421
|
startIndex: dataStream.length - 2,
|
|
3316
3422
|
paragraphId: (0, _univerjs_core.createParagraphId)(new Set(paragraphs.map((paragraph) => paragraph.paragraphId)))
|
|
3317
3423
|
});
|
|
3318
|
-
sectionBreaks.push({
|
|
3424
|
+
sectionBreaks.push({
|
|
3425
|
+
sectionId: (0, _univerjs_core.createSectionId)(new Set(sectionBreaks.map((sectionBreak) => sectionBreak.sectionId))),
|
|
3426
|
+
startIndex: dataStream.length - 1
|
|
3427
|
+
});
|
|
3319
3428
|
body.dataStream = dataStream;
|
|
3320
3429
|
body.paragraphs = paragraphs;
|
|
3321
3430
|
body.sectionBreaks = sectionBreaks;
|
|
@@ -3814,6 +3923,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
3814
3923
|
internalDocData = cache;
|
|
3815
3924
|
} else internalDocData = createInternalClipboardDocDataList(documentList);
|
|
3816
3925
|
if (internalDocData) {
|
|
3926
|
+
internalDocData = this._applyCopyDocDataHooks(internalDocData, documentList);
|
|
3817
3927
|
internalJson = createInternalClipboardFragment(internalDocData);
|
|
3818
3928
|
html = embedInternalClipboardFragment(html, internalJson);
|
|
3819
3929
|
}
|
|
@@ -3827,6 +3937,12 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
3827
3937
|
if (index > -1) this._clipboardHooks.splice(index, 1);
|
|
3828
3938
|
});
|
|
3829
3939
|
}
|
|
3940
|
+
_applyCopyDocDataHooks(doc, sourceDocuments) {
|
|
3941
|
+
return this._clipboardHooks.reduce((currentDoc, hook) => {
|
|
3942
|
+
var _hook$onCopyDocData, _hook$onCopyDocData2;
|
|
3943
|
+
return (_hook$onCopyDocData = (_hook$onCopyDocData2 = hook.onCopyDocData) === null || _hook$onCopyDocData2 === void 0 ? void 0 : _hook$onCopyDocData2.call(hook, currentDoc, { sourceDocuments })) !== null && _hook$onCopyDocData !== void 0 ? _hook$onCopyDocData : currentDoc;
|
|
3944
|
+
}, doc);
|
|
3945
|
+
}
|
|
3830
3946
|
_getDocumentBodyInRanges(sliceType, ranges) {
|
|
3831
3947
|
var _docDataModel$getSelf;
|
|
3832
3948
|
const docDataModel = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
@@ -3929,11 +4045,11 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
3929
4045
|
const images = Array.from(doc.querySelectorAll("img[src^=\"data:image/\"]"));
|
|
3930
4046
|
if (images.length === 0) return html;
|
|
3931
4047
|
await Promise.all(images.map(async (image, index) => {
|
|
3932
|
-
if (image.dataset.imageSourceType && image.dataset.imageSourceType !==
|
|
4048
|
+
if (image.dataset.imageSourceType && image.dataset.imageSourceType !== _univerjs_core.ImageSourceType.BASE64) return;
|
|
3933
4049
|
const uploaded = await onBeforePasteImage(dataUrlToFile(image.getAttribute("src") || image.src, `pasted_image_${index}`));
|
|
3934
4050
|
if (!uploaded) return;
|
|
3935
4051
|
image.dataset.imageSourceType = uploaded.imageSourceType;
|
|
3936
|
-
if (uploaded.imageSourceType ===
|
|
4052
|
+
if (uploaded.imageSourceType === _univerjs_core.ImageSourceType.UUID) {
|
|
3937
4053
|
image.dataset.source = uploaded.source;
|
|
3938
4054
|
image.setAttribute("src", uploaded.source);
|
|
3939
4055
|
} else {
|
|
@@ -3960,7 +4076,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
3960
4076
|
reader.onloadend = function() {
|
|
3961
4077
|
res({
|
|
3962
4078
|
source: reader.result,
|
|
3963
|
-
imageSourceType:
|
|
4079
|
+
imageSourceType: _univerjs_core.ImageSourceType.BASE64
|
|
3964
4080
|
});
|
|
3965
4081
|
};
|
|
3966
4082
|
reader.readAsDataURL(file);
|
|
@@ -4120,6 +4236,17 @@ const DocPasteCommand = {
|
|
|
4120
4236
|
|
|
4121
4237
|
//#endregion
|
|
4122
4238
|
//#region src/commands/commands/doc-block-move.command.ts
|
|
4239
|
+
const DOC_BLOCK_MOVE_BODY_PATCH_KEYS = [
|
|
4240
|
+
"paragraphs",
|
|
4241
|
+
"sectionBreaks",
|
|
4242
|
+
"tables",
|
|
4243
|
+
"columnGroups",
|
|
4244
|
+
"customBlocks",
|
|
4245
|
+
"blockRanges",
|
|
4246
|
+
"customRanges",
|
|
4247
|
+
"customDecorations",
|
|
4248
|
+
"textRuns"
|
|
4249
|
+
];
|
|
4123
4250
|
const MoveDocBlockCommand = {
|
|
4124
4251
|
id: "doc.command.move-block",
|
|
4125
4252
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -4143,7 +4270,11 @@ const MoveDocBlockCommand = {
|
|
|
4143
4270
|
previousDocumentData,
|
|
4144
4271
|
result: moveResult
|
|
4145
4272
|
});
|
|
4146
|
-
const actions = buildReplaceDocumentBodyActions(previousDocumentData, nextDocumentData
|
|
4273
|
+
const actions = buildReplaceDocumentBodyActions(previousDocumentData, nextDocumentData, {
|
|
4274
|
+
sourceRange,
|
|
4275
|
+
targetOffset,
|
|
4276
|
+
movedRange
|
|
4277
|
+
});
|
|
4147
4278
|
if (!actions) return false;
|
|
4148
4279
|
const textRanges = [{
|
|
4149
4280
|
startOffset: movedRange.startOffset,
|
|
@@ -4189,23 +4320,121 @@ function buildMoveDocBlockActions(params) {
|
|
|
4189
4320
|
}
|
|
4190
4321
|
};
|
|
4191
4322
|
}
|
|
4192
|
-
function buildReplaceDocumentBodyActions(previousDocumentData, nextDocumentData) {
|
|
4193
|
-
|
|
4323
|
+
function buildReplaceDocumentBodyActions(previousDocumentData, nextDocumentData, move) {
|
|
4324
|
+
_univerjs_core.JSONX.getInstance();
|
|
4194
4325
|
const previousBody = previousDocumentData.body;
|
|
4195
4326
|
const nextBody = nextDocumentData.body;
|
|
4196
4327
|
if (!previousBody || !nextBody) return null;
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4328
|
+
const rawActions = [];
|
|
4329
|
+
let intermediateDocumentData = _univerjs_core.Tools.deepClone(previousDocumentData);
|
|
4330
|
+
const moveTextAction = move ? buildMoveBodyTextAction(previousBody, nextBody, move) : null;
|
|
4331
|
+
if (moveTextAction) {
|
|
4332
|
+
rawActions.push(moveTextAction);
|
|
4333
|
+
intermediateDocumentData = _univerjs_core.JSONX.apply(intermediateDocumentData, moveTextAction);
|
|
4334
|
+
}
|
|
4335
|
+
const residualTextAction = buildSingleBodyTextChangeAction(intermediateDocumentData.body, nextBody);
|
|
4336
|
+
if (residualTextAction) {
|
|
4337
|
+
rawActions.push(residualTextAction);
|
|
4338
|
+
intermediateDocumentData = _univerjs_core.JSONX.apply(intermediateDocumentData, residualTextAction);
|
|
4339
|
+
}
|
|
4340
|
+
if (!moveTextAction) collectBodyPatchActions(intermediateDocumentData.body, nextBody, rawActions);
|
|
4341
|
+
return rawActions.reduce((acc, cur) => _univerjs_core.JSONX.compose(acc, cur), null);
|
|
4342
|
+
}
|
|
4343
|
+
function buildMoveBodyTextAction(previousBody, nextBody, move) {
|
|
4344
|
+
const dataStreamLength = previousBody.dataStream.length;
|
|
4345
|
+
const startOffset = clamp$1(move.sourceRange.startOffset, 0, dataStreamLength);
|
|
4346
|
+
const endOffset = clamp$1(move.sourceRange.endOffset, startOffset, dataStreamLength);
|
|
4347
|
+
const targetOffset = clamp$1(move.targetOffset, 0, dataStreamLength);
|
|
4348
|
+
const moveLength = endOffset - startOffset;
|
|
4349
|
+
if (moveLength <= 0 || targetOffset >= startOffset && targetOffset <= endOffset) return null;
|
|
4350
|
+
const textX = new _univerjs_core.TextX();
|
|
4351
|
+
const insertOffset = move.movedRange.startOffset;
|
|
4352
|
+
const insertBody = (0, _univerjs_core.getBodySliceForTextXAction)(nextBody, insertOffset, insertOffset + moveLength, false);
|
|
4353
|
+
if (targetOffset < startOffset) {
|
|
4354
|
+
textX.retain(targetOffset);
|
|
4355
|
+
textX.insert(moveLength, insertBody);
|
|
4356
|
+
textX.retain(startOffset - targetOffset);
|
|
4357
|
+
textX.delete(moveLength);
|
|
4358
|
+
} else {
|
|
4359
|
+
textX.retain(startOffset);
|
|
4360
|
+
textX.delete(moveLength);
|
|
4361
|
+
textX.retain(targetOffset - endOffset);
|
|
4362
|
+
textX.insert(moveLength, insertBody);
|
|
4363
|
+
}
|
|
4364
|
+
return _univerjs_core.JSONX.getInstance().editOp(textX.serialize(), ["body"]);
|
|
4365
|
+
}
|
|
4366
|
+
function buildSingleBodyTextChangeAction(previousBody, nextBody) {
|
|
4367
|
+
const textChange = getSingleDataStreamChange(previousBody === null || previousBody === void 0 ? void 0 : previousBody.dataStream, nextBody.dataStream);
|
|
4368
|
+
if (!textChange) return null;
|
|
4369
|
+
const textX = new _univerjs_core.TextX();
|
|
4370
|
+
textX.retain(textChange.start);
|
|
4371
|
+
if (textChange.insertLength > 0) textX.insert(textChange.insertLength, (0, _univerjs_core.getBodySliceForTextXAction)(nextBody, textChange.start, textChange.start + textChange.insertLength, false));
|
|
4372
|
+
if (textChange.deleteLength > 0) textX.delete(textChange.deleteLength);
|
|
4373
|
+
return _univerjs_core.JSONX.getInstance().editOp(textX.serialize(), ["body"]);
|
|
4374
|
+
}
|
|
4375
|
+
function getSingleDataStreamChange(previousDataStream, nextDataStream) {
|
|
4376
|
+
if (previousDataStream == null || nextDataStream == null || previousDataStream === nextDataStream) return null;
|
|
4377
|
+
let start = 0;
|
|
4378
|
+
while (start < previousDataStream.length && start < nextDataStream.length && previousDataStream[start] === nextDataStream[start]) start++;
|
|
4379
|
+
let previousEnd = previousDataStream.length;
|
|
4380
|
+
let nextEnd = nextDataStream.length;
|
|
4381
|
+
while (previousEnd > start && nextEnd > start && previousDataStream[previousEnd - 1] === nextDataStream[nextEnd - 1]) {
|
|
4382
|
+
previousEnd--;
|
|
4383
|
+
nextEnd--;
|
|
4384
|
+
}
|
|
4385
|
+
return {
|
|
4386
|
+
start,
|
|
4387
|
+
deleteLength: previousEnd - start,
|
|
4388
|
+
insertLength: nextEnd - start
|
|
4389
|
+
};
|
|
4390
|
+
}
|
|
4391
|
+
function collectBodyPatchActions(previousBody, nextBody, actions) {
|
|
4392
|
+
for (const key of DOC_BLOCK_MOVE_BODY_PATCH_KEYS) collectPatchActions(_univerjs_core.JSONX.getInstance(), ["body", key], previousBody === null || previousBody === void 0 ? void 0 : previousBody[key], nextBody[key], actions);
|
|
4393
|
+
}
|
|
4394
|
+
function collectPatchActions(jsonX, path, oldValue, newValue, actions) {
|
|
4395
|
+
if (isEmptyArrayEquivalent$1(oldValue, newValue)) return;
|
|
4396
|
+
if (_univerjs_core.Tools.diffValue(oldValue, newValue)) return;
|
|
4397
|
+
if (oldValue == null) {
|
|
4398
|
+
actions.push(jsonX.insertOp(path, newValue));
|
|
4399
|
+
return;
|
|
4400
|
+
}
|
|
4401
|
+
if (newValue == null) {
|
|
4402
|
+
actions.push(jsonX.removeOp(path, oldValue));
|
|
4403
|
+
return;
|
|
4404
|
+
}
|
|
4405
|
+
if (Array.isArray(oldValue) && Array.isArray(newValue)) {
|
|
4406
|
+
collectArrayPatchActions(jsonX, path, oldValue, newValue, actions);
|
|
4407
|
+
return;
|
|
4408
|
+
}
|
|
4409
|
+
if (isPlainObject$1(oldValue) && isPlainObject$1(newValue)) {
|
|
4410
|
+
(/* @__PURE__ */ new Set([...Object.keys(oldValue), ...Object.keys(newValue)])).forEach((key) => {
|
|
4411
|
+
collectPatchActions(jsonX, [...path, key], oldValue[key], newValue[key], actions);
|
|
4412
|
+
});
|
|
4413
|
+
return;
|
|
4414
|
+
}
|
|
4415
|
+
actions.push(jsonX.replaceOp(path, oldValue, newValue));
|
|
4416
|
+
}
|
|
4417
|
+
function collectArrayPatchActions(jsonX, path, oldItems, newItems, actions) {
|
|
4418
|
+
if (oldItems.length === newItems.length) {
|
|
4419
|
+
oldItems.forEach((item, index) => collectPatchActions(jsonX, [...path, index], item, newItems[index], actions));
|
|
4420
|
+
return;
|
|
4421
|
+
}
|
|
4422
|
+
let prefix = 0;
|
|
4423
|
+
while (prefix < oldItems.length && prefix < newItems.length && _univerjs_core.Tools.diffValue(oldItems[prefix], newItems[prefix])) prefix++;
|
|
4424
|
+
let oldSuffix = oldItems.length - 1;
|
|
4425
|
+
let newSuffix = newItems.length - 1;
|
|
4426
|
+
while (oldSuffix >= prefix && newSuffix >= prefix && _univerjs_core.Tools.diffValue(oldItems[oldSuffix], newItems[newSuffix])) {
|
|
4427
|
+
oldSuffix--;
|
|
4428
|
+
newSuffix--;
|
|
4429
|
+
}
|
|
4430
|
+
for (let index = oldSuffix; index >= prefix; index--) actions.push(jsonX.removeOp([...path, index], oldItems[index]));
|
|
4431
|
+
for (let index = prefix; index <= newSuffix; index++) actions.push(jsonX.insertOp([...path, index], newItems[index]));
|
|
4432
|
+
}
|
|
4433
|
+
function isPlainObject$1(value) {
|
|
4434
|
+
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
4435
|
+
}
|
|
4436
|
+
function isEmptyArrayEquivalent$1(oldValue, newValue) {
|
|
4437
|
+
return oldValue == null && Array.isArray(newValue) && newValue.length === 0 || newValue == null && Array.isArray(oldValue) && oldValue.length === 0;
|
|
4209
4438
|
}
|
|
4210
4439
|
function remapBodyIndexesAfterMove(body, startOffset, endOffset, targetOffset, insertOffset, moveLength) {
|
|
4211
4440
|
var _body$paragraphs, _body$sectionBreaks, _body$customBlocks, _body$tables, _body$columnGroups, _body$blockRanges, _body$customRanges, _body$customDecoratio, _body$textRuns;
|
|
@@ -4290,6 +4519,7 @@ const HorizontalLineCommand = {
|
|
|
4290
4519
|
width: 1,
|
|
4291
4520
|
dashStyle: _univerjs_core.DashStyleType.SOLID
|
|
4292
4521
|
},
|
|
4522
|
+
insertionMode: params === null || params === void 0 ? void 0 : params.insertionMode,
|
|
4293
4523
|
textRange: params === null || params === void 0 ? void 0 : params.insertRange
|
|
4294
4524
|
});
|
|
4295
4525
|
}
|
|
@@ -4306,10 +4536,13 @@ const InsertHorizontalLineBellowCommand = {
|
|
|
4306
4536
|
} catch {
|
|
4307
4537
|
contentInsertRange = null;
|
|
4308
4538
|
}
|
|
4309
|
-
if (contentInsertRange) return commandService.syncExecuteCommand(HorizontalLineCommand.id, {
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4539
|
+
if (contentInsertRange) return commandService.syncExecuteCommand(HorizontalLineCommand.id, {
|
|
4540
|
+
insertionMode: "insert-gap",
|
|
4541
|
+
insertRange: {
|
|
4542
|
+
startOffset: contentInsertRange.startOffset,
|
|
4543
|
+
endOffset: contentInsertRange.endOffset
|
|
4544
|
+
}
|
|
4545
|
+
});
|
|
4313
4546
|
const paragraph = getCurrentParagraph(accessor);
|
|
4314
4547
|
if (!paragraph) return false;
|
|
4315
4548
|
return commandService.syncExecuteCommand(HorizontalLineCommand.id, { insertRange: {
|
|
@@ -4385,7 +4618,7 @@ function getTextRangesByParagraphs(body, startOffset, endOffset) {
|
|
|
4385
4618
|
return ranges;
|
|
4386
4619
|
}
|
|
4387
4620
|
function getScopedSelectAllRange(body, activeRange) {
|
|
4388
|
-
var _body$tables2, _body$customBlocks, _body$blockRanges, _body$
|
|
4621
|
+
var _body$tables2, _body$customBlocks, _body$blockRanges, _body$tables3;
|
|
4389
4622
|
const startOffset = activeRange.startOffset;
|
|
4390
4623
|
const endOffset = activeRange.endOffset;
|
|
4391
4624
|
if (startOffset == null || endOffset == null) return null;
|
|
@@ -4403,7 +4636,7 @@ function getScopedSelectAllRange(body, activeRange) {
|
|
|
4403
4636
|
rangeType: _univerjs_core.DOC_RANGE_TYPE.TEXT,
|
|
4404
4637
|
startOffset: blockRange.startIndex + 1
|
|
4405
4638
|
}];
|
|
4406
|
-
const paragraphRange = clampParagraphRangeByTables(getParagraphRangeAtOffset(
|
|
4639
|
+
const paragraphRange = clampParagraphRangeByTables(getParagraphRangeAtOffset(body, startOffset), (_body$tables3 = body.tables) !== null && _body$tables3 !== void 0 ? _body$tables3 : [], startOffset);
|
|
4407
4640
|
return paragraphRange ? [{
|
|
4408
4641
|
...paragraphRange,
|
|
4409
4642
|
rangeType: _univerjs_core.DOC_RANGE_TYPE.TEXT
|
|
@@ -4423,11 +4656,13 @@ function getTableRectRange(table) {
|
|
|
4423
4656
|
rangeType: _univerjs_core.DOC_RANGE_TYPE.RECT
|
|
4424
4657
|
};
|
|
4425
4658
|
}
|
|
4426
|
-
function getParagraphRangeAtOffset(
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4659
|
+
function getParagraphRangeAtOffset(body, offset) {
|
|
4660
|
+
var _body$paragraphs2;
|
|
4661
|
+
const sortedParagraphs = [...(_body$paragraphs2 = body.paragraphs) !== null && _body$paragraphs2 !== void 0 ? _body$paragraphs2 : []].sort((left, right) => left.startIndex - right.startIndex);
|
|
4662
|
+
const paragraphStartOffsets = (0, _univerjs_core.getParagraphContentStartOffsets)(body);
|
|
4663
|
+
for (const paragraph of sortedParagraphs) {
|
|
4664
|
+
var _paragraphStartOffset;
|
|
4665
|
+
const startOffset = (_paragraphStartOffset = paragraphStartOffsets.get(paragraph.startIndex)) !== null && _paragraphStartOffset !== void 0 ? _paragraphStartOffset : 0;
|
|
4431
4666
|
if (startOffset <= offset && offset <= paragraph.startIndex) return {
|
|
4432
4667
|
endOffset: paragraph.startIndex,
|
|
4433
4668
|
startOffset
|
|
@@ -4972,47 +5207,55 @@ const ReplaceSnapshotCommand = {
|
|
|
4972
5207
|
}
|
|
4973
5208
|
};
|
|
4974
5209
|
if (options) doMutation.params.options = options;
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
}
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
const actions = jsonX.replaceOp(["headers"], prevHeaders, headers);
|
|
4995
|
-
if (actions != null) rawActions.push(actions);
|
|
4996
|
-
}
|
|
4997
|
-
if (!_univerjs_core.Tools.diffValue(lists, prevLists)) {
|
|
4998
|
-
const actions = jsonX.replaceOp(["lists"], prevLists, lists);
|
|
4999
|
-
if (actions != null) rawActions.push(actions);
|
|
5000
|
-
}
|
|
5001
|
-
if (!_univerjs_core.Tools.diffValue(drawings, prevDrawings)) {
|
|
5002
|
-
const actions = jsonX.replaceOp(["drawings"], prevDrawings, drawings);
|
|
5003
|
-
if (actions != null) rawActions.push(actions);
|
|
5004
|
-
}
|
|
5005
|
-
if (!_univerjs_core.Tools.diffValue(drawingsOrder, prevDrawingsOrder)) {
|
|
5006
|
-
const actions = jsonX.replaceOp(["drawingsOrder"], prevDrawingsOrder, drawingsOrder);
|
|
5007
|
-
if (actions != null) rawActions.push(actions);
|
|
5008
|
-
}
|
|
5009
|
-
doMutation.params.actions = rawActions.reduce((acc, cur) => {
|
|
5010
|
-
return _univerjs_core.JSONX.compose(acc, cur);
|
|
5011
|
-
}, null);
|
|
5210
|
+
doMutation.params.actions = buildReplaceSnapshotActions({
|
|
5211
|
+
body: prevBody,
|
|
5212
|
+
documentStyle: prevDocumentStyle,
|
|
5213
|
+
tableSource: prevTableSource,
|
|
5214
|
+
footers: prevFooters,
|
|
5215
|
+
headers: prevHeaders,
|
|
5216
|
+
lists: prevLists,
|
|
5217
|
+
drawings: prevDrawings,
|
|
5218
|
+
drawingsOrder: prevDrawingsOrder
|
|
5219
|
+
}, {
|
|
5220
|
+
body,
|
|
5221
|
+
documentStyle,
|
|
5222
|
+
tableSource,
|
|
5223
|
+
footers,
|
|
5224
|
+
headers,
|
|
5225
|
+
lists,
|
|
5226
|
+
drawings,
|
|
5227
|
+
drawingsOrder
|
|
5228
|
+
});
|
|
5012
5229
|
const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
5013
5230
|
return Boolean(result);
|
|
5014
5231
|
}
|
|
5015
5232
|
};
|
|
5233
|
+
function buildReplaceSnapshotActions(previousSnapshot, snapshot) {
|
|
5234
|
+
const jsonX = _univerjs_core.JSONX.getInstance();
|
|
5235
|
+
const rawActions = [];
|
|
5236
|
+
const bodyAction = buildReplaceSnapshotBodyAction(previousSnapshot.body, snapshot.body);
|
|
5237
|
+
if (bodyAction) rawActions.push(bodyAction);
|
|
5238
|
+
collectTopLevelReplaceAction(jsonX, rawActions, ["documentStyle"], previousSnapshot.documentStyle, snapshot.documentStyle);
|
|
5239
|
+
collectTopLevelReplaceAction(jsonX, rawActions, ["tableSource"], previousSnapshot.tableSource, snapshot.tableSource);
|
|
5240
|
+
collectTopLevelReplaceAction(jsonX, rawActions, ["footers"], previousSnapshot.footers, snapshot.footers);
|
|
5241
|
+
collectTopLevelReplaceAction(jsonX, rawActions, ["headers"], previousSnapshot.headers, snapshot.headers);
|
|
5242
|
+
collectTopLevelReplaceAction(jsonX, rawActions, ["lists"], previousSnapshot.lists, snapshot.lists);
|
|
5243
|
+
collectTopLevelReplaceAction(jsonX, rawActions, ["drawings"], previousSnapshot.drawings, snapshot.drawings);
|
|
5244
|
+
collectTopLevelReplaceAction(jsonX, rawActions, ["drawingsOrder"], previousSnapshot.drawingsOrder, snapshot.drawingsOrder);
|
|
5245
|
+
return rawActions.reduce((acc, cur) => _univerjs_core.JSONX.compose(acc, cur), null);
|
|
5246
|
+
}
|
|
5247
|
+
function buildReplaceSnapshotBodyAction(previousBody, body) {
|
|
5248
|
+
if (!previousBody || !body || _univerjs_core.Tools.diffValue(previousBody, body)) return null;
|
|
5249
|
+
const textX = new _univerjs_core.TextX();
|
|
5250
|
+
if (previousBody.dataStream.length > 0) textX.delete(previousBody.dataStream.length);
|
|
5251
|
+
if (body.dataStream.length > 0) textX.insert(body.dataStream.length, body);
|
|
5252
|
+
return _univerjs_core.JSONX.getInstance().editOp(textX.serialize(), ["body"]);
|
|
5253
|
+
}
|
|
5254
|
+
function collectTopLevelReplaceAction(jsonX, rawActions, path, previousValue, value) {
|
|
5255
|
+
if (_univerjs_core.Tools.diffValue(previousValue, value)) return;
|
|
5256
|
+
const action = jsonX.replaceOp(path, previousValue, value);
|
|
5257
|
+
if (action != null) rawActions.push(action);
|
|
5258
|
+
}
|
|
5016
5259
|
/**
|
|
5017
5260
|
* @deprecated please use ReplaceSnapshotCommand instead.
|
|
5018
5261
|
*/
|
|
@@ -5490,7 +5733,7 @@ const QuickListCommand = {
|
|
|
5490
5733
|
return Boolean(result);
|
|
5491
5734
|
}
|
|
5492
5735
|
};
|
|
5493
|
-
function insertList(accessor, listType) {
|
|
5736
|
+
function insertList(accessor, listType, trigger) {
|
|
5494
5737
|
var _contentInsertRange$s, _contentInsertRange$e, _sourceParagraph$para;
|
|
5495
5738
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5496
5739
|
const docDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
@@ -5538,7 +5781,8 @@ function insertList(accessor, listType) {
|
|
|
5538
5781
|
endOffset: insertOffset,
|
|
5539
5782
|
collapsed: true
|
|
5540
5783
|
}],
|
|
5541
|
-
isEditing: false
|
|
5784
|
+
isEditing: false,
|
|
5785
|
+
trigger
|
|
5542
5786
|
}
|
|
5543
5787
|
};
|
|
5544
5788
|
const jsonX = _univerjs_core.JSONX.getInstance();
|
|
@@ -5551,21 +5795,21 @@ const InsertBulletListBellowCommand = {
|
|
|
5551
5795
|
id: "doc.command.insert-bullet-list-bellow",
|
|
5552
5796
|
type: _univerjs_core.CommandType.COMMAND,
|
|
5553
5797
|
handler: (accessor) => {
|
|
5554
|
-
return insertList(accessor, _univerjs_core.PresetListType.BULLET_LIST);
|
|
5798
|
+
return insertList(accessor, _univerjs_core.PresetListType.BULLET_LIST, InsertBulletListBellowCommand.id);
|
|
5555
5799
|
}
|
|
5556
5800
|
};
|
|
5557
5801
|
const InsertOrderListBellowCommand = {
|
|
5558
5802
|
id: "doc.command.insert-order-list-bellow",
|
|
5559
5803
|
type: _univerjs_core.CommandType.COMMAND,
|
|
5560
5804
|
handler: (accessor) => {
|
|
5561
|
-
return insertList(accessor, _univerjs_core.PresetListType.ORDER_LIST);
|
|
5805
|
+
return insertList(accessor, _univerjs_core.PresetListType.ORDER_LIST, InsertOrderListBellowCommand.id);
|
|
5562
5806
|
}
|
|
5563
5807
|
};
|
|
5564
5808
|
const InsertCheckListBellowCommand = {
|
|
5565
5809
|
id: "doc.command.insert-check-list-bellow",
|
|
5566
5810
|
type: _univerjs_core.CommandType.COMMAND,
|
|
5567
5811
|
handler: (accessor) => {
|
|
5568
|
-
return insertList(accessor, _univerjs_core.PresetListType.CHECK_LIST);
|
|
5812
|
+
return insertList(accessor, _univerjs_core.PresetListType.CHECK_LIST, InsertCheckListBellowCommand.id);
|
|
5569
5813
|
}
|
|
5570
5814
|
};
|
|
5571
5815
|
|
|
@@ -5734,7 +5978,7 @@ const SetParagraphNamedStyleCommand = {
|
|
|
5734
5978
|
const unitId = doc.getUnitId();
|
|
5735
5979
|
const selectionService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
5736
5980
|
const contentInsertRange = params.textRanges ? null : (0, _univerjs_docs.consumeContentInsertRange)(accessor, unitId);
|
|
5737
|
-
if (contentInsertRange) return insertNamedStyleParagraph(accessor, doc, params.value, contentInsertRange.startOffset, contentInsertRange.endOffset);
|
|
5981
|
+
if (contentInsertRange) return insertNamedStyleParagraph(accessor, doc, params.value, contentInsertRange.startOffset, contentInsertRange.endOffset, contentInsertRange.segmentId);
|
|
5738
5982
|
const selections = (_params$textRanges = params.textRanges) !== null && _params$textRanges !== void 0 ? _params$textRanges : selectionService.getTextRanges({
|
|
5739
5983
|
unitId,
|
|
5740
5984
|
subUnitId: unitId
|
|
@@ -5771,13 +6015,14 @@ const SetParagraphNamedStyleCommand = {
|
|
|
5771
6015
|
return Boolean(result);
|
|
5772
6016
|
}
|
|
5773
6017
|
};
|
|
5774
|
-
function insertNamedStyleParagraph(accessor, doc, namedStyleType, startOffset, endOffset) {
|
|
6018
|
+
function insertNamedStyleParagraph(accessor, doc, namedStyleType, startOffset, endOffset, segmentId = "") {
|
|
5775
6019
|
const textX = _univerjs_core.BuildTextUtils.selection.replace({
|
|
5776
6020
|
doc,
|
|
5777
6021
|
selection: {
|
|
5778
6022
|
startOffset,
|
|
5779
6023
|
endOffset,
|
|
5780
|
-
collapsed: startOffset === endOffset
|
|
6024
|
+
collapsed: startOffset === endOffset,
|
|
6025
|
+
segmentId
|
|
5781
6026
|
},
|
|
5782
6027
|
body: {
|
|
5783
6028
|
dataStream: "\r",
|
|
@@ -5794,16 +6039,22 @@ function insertNamedStyleParagraph(accessor, doc, namedStyleType, startOffset, e
|
|
|
5794
6039
|
if (!textX) return false;
|
|
5795
6040
|
const jsonX = _univerjs_core.JSONX.getInstance();
|
|
5796
6041
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5797
|
-
|
|
5798
|
-
actions: jsonX.editOp(textX.serialize(), (0, _univerjs_core.getRichTextEditPath)(doc)),
|
|
6042
|
+
const success = Boolean(commandService.syncExecuteCommand(_univerjs_docs.RichTextEditingMutation.id, {
|
|
6043
|
+
actions: jsonX.editOp(textX.serialize(), (0, _univerjs_core.getRichTextEditPath)(doc, segmentId)),
|
|
5799
6044
|
isEditing: false,
|
|
5800
6045
|
textRanges: [{
|
|
5801
6046
|
startOffset,
|
|
5802
6047
|
endOffset: startOffset,
|
|
5803
6048
|
collapsed: true
|
|
5804
6049
|
}],
|
|
6050
|
+
segmentId,
|
|
5805
6051
|
unitId: doc.getUnitId()
|
|
5806
6052
|
}));
|
|
6053
|
+
if (success) accessor.get(_univerjs_docs.DocSelectionManagerService).replaceTextRanges([{
|
|
6054
|
+
startOffset,
|
|
6055
|
+
endOffset: startOffset
|
|
6056
|
+
}], false);
|
|
6057
|
+
return success;
|
|
5807
6058
|
}
|
|
5808
6059
|
const QuickHeadingCommand = {
|
|
5809
6060
|
id: "doc.command.quick-heading",
|
|
@@ -5928,6 +6179,88 @@ const SubtitleHeadingCommand = {
|
|
|
5928
6179
|
}
|
|
5929
6180
|
};
|
|
5930
6181
|
|
|
6182
|
+
//#endregion
|
|
6183
|
+
//#region src/services/doc-embed-integration.service.ts
|
|
6184
|
+
const DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
|
|
6185
|
+
var EmbedInteractionBoundaryService = class {
|
|
6186
|
+
constructor() {
|
|
6187
|
+
_defineProperty(this, "_roots", /* @__PURE__ */ new Map());
|
|
6188
|
+
}
|
|
6189
|
+
registerOwnedElement(embedId, element) {
|
|
6190
|
+
element.setAttribute(DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, embedId);
|
|
6191
|
+
element.querySelectorAll("*").forEach((child) => child.setAttribute(DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, embedId));
|
|
6192
|
+
let roots = this._roots.get(embedId);
|
|
6193
|
+
if (!roots) {
|
|
6194
|
+
roots = /* @__PURE__ */ new Set();
|
|
6195
|
+
this._roots.set(embedId, roots);
|
|
6196
|
+
}
|
|
6197
|
+
roots.add(element);
|
|
6198
|
+
return (0, _univerjs_core.toDisposable)(() => {
|
|
6199
|
+
roots === null || roots === void 0 || roots.delete(element);
|
|
6200
|
+
element.removeAttribute(DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE);
|
|
6201
|
+
element.querySelectorAll("*").forEach((child) => child.removeAttribute(DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE));
|
|
6202
|
+
});
|
|
6203
|
+
}
|
|
6204
|
+
contains(embedId, target) {
|
|
6205
|
+
var _this$_roots$get;
|
|
6206
|
+
if (!(target instanceof HTMLElement)) return false;
|
|
6207
|
+
if (!embedId) return [...this._roots.values()].some((roots) => [...roots].some((root) => root.contains(target)));
|
|
6208
|
+
return ((_this$_roots$get = this._roots.get(embedId)) === null || _this$_roots$get === void 0 ? void 0 : _this$_roots$get.has(target)) === true || this._roots.get(embedId) != null && [...this._roots.get(embedId)].some((root) => root.contains(target));
|
|
6209
|
+
}
|
|
6210
|
+
hasRecentInteraction() {
|
|
6211
|
+
return false;
|
|
6212
|
+
}
|
|
6213
|
+
hasRecentInteractionFor() {
|
|
6214
|
+
return false;
|
|
6215
|
+
}
|
|
6216
|
+
};
|
|
6217
|
+
const IDocEmbedInteractionBoundaryService = EmbedInteractionBoundaryService;
|
|
6218
|
+
var EmbedRuntimeFocusCoordinator = class {
|
|
6219
|
+
constructor() {
|
|
6220
|
+
_defineProperty(this, "_leases", /* @__PURE__ */ new Set());
|
|
6221
|
+
_defineProperty(this, "_elements", /* @__PURE__ */ new Map());
|
|
6222
|
+
_defineProperty(this, "runtimeSessionChanged$", new rxjs.Subject());
|
|
6223
|
+
}
|
|
6224
|
+
acquireLease(options) {
|
|
6225
|
+
this._leases.add(options);
|
|
6226
|
+
this.runtimeSessionChanged$.next();
|
|
6227
|
+
return (0, _univerjs_core.toDisposable)(() => {
|
|
6228
|
+
this._leases.delete(options);
|
|
6229
|
+
this.runtimeSessionChanged$.next();
|
|
6230
|
+
});
|
|
6231
|
+
}
|
|
6232
|
+
registerElement(options) {
|
|
6233
|
+
options.element.setAttribute(DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, options.embedId);
|
|
6234
|
+
let elements = this._elements.get(options.embedId);
|
|
6235
|
+
if (!elements) {
|
|
6236
|
+
elements = /* @__PURE__ */ new Set();
|
|
6237
|
+
this._elements.set(options.embedId, elements);
|
|
6238
|
+
}
|
|
6239
|
+
elements.add(options.element);
|
|
6240
|
+
return (0, _univerjs_core.toDisposable)(() => {
|
|
6241
|
+
elements === null || elements === void 0 || elements.delete(options.element);
|
|
6242
|
+
options.element.removeAttribute(DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE);
|
|
6243
|
+
});
|
|
6244
|
+
}
|
|
6245
|
+
registerRuntimeScope(_options) {
|
|
6246
|
+
return (0, _univerjs_core.toDisposable)(() => {});
|
|
6247
|
+
}
|
|
6248
|
+
isChildUnitRuntimeEvent(_unitId, target) {
|
|
6249
|
+
return target instanceof HTMLElement && target.closest(`[${"data-embed-interaction-boundary-owner"}]`) != null;
|
|
6250
|
+
}
|
|
6251
|
+
isChildUnitInActiveSession(unitId) {
|
|
6252
|
+
return [...this._leases].some((lease) => lease.role !== "runtime" && lease.childUnitId === unitId);
|
|
6253
|
+
}
|
|
6254
|
+
shouldSuppressHostInteraction(unitId, target) {
|
|
6255
|
+
if (this.isChildUnitRuntimeEvent(unitId, target)) return false;
|
|
6256
|
+
return [...this._leases].some((lease) => {
|
|
6257
|
+
if (lease.role === "runtime" || lease.childUnitId === unitId) return false;
|
|
6258
|
+
return lease.hostUnitId === unitId || !lease.hostUnitId && !lease.childUnitId;
|
|
6259
|
+
});
|
|
6260
|
+
}
|
|
6261
|
+
};
|
|
6262
|
+
const IDocEmbedRuntimeFocusCoordinator = EmbedRuntimeFocusCoordinator;
|
|
6263
|
+
|
|
5931
6264
|
//#endregion
|
|
5932
6265
|
//#region src/services/selection/convert-text-range.ts
|
|
5933
6266
|
let NodePositionType = /* @__PURE__ */ function(NodePositionType) {
|
|
@@ -6079,7 +6412,10 @@ var NodePositionConvertToCursor = class {
|
|
|
6079
6412
|
const isStartBack = start.glyph === start_sp && isFirst ? start.isBack : true;
|
|
6080
6413
|
const isEndBack = end.glyph === end_sp && isLast ? end.isBack : false;
|
|
6081
6414
|
const collapsed = start === end;
|
|
6082
|
-
const
|
|
6415
|
+
const rawAnchorGlyph = isStartBack ? preGlyph !== null && preGlyph !== void 0 ? preGlyph : firstGlyph : firstGlyph;
|
|
6416
|
+
const anchorGlyph = this._getCaretGlyph(rawAnchorGlyph, glyphGroup, start_sp);
|
|
6417
|
+
const selectedGlyphs = glyphGroup.slice(start_sp, end_sp + 1);
|
|
6418
|
+
const isSelectionOnlyNonInlineEmbedBlock = !collapsed && selectedGlyphs.length > 0 && selectedGlyphs.every((glyph) => this._isNonInlineEmbedCustomBlockGlyph(glyph));
|
|
6083
6419
|
const borderBoxStartY = startY;
|
|
6084
6420
|
const borderBoxEndY = contentHeight == null ? startY + lineHeight - marginTop - marginBottom : startY + paddingTop + contentHeight + paddingBottom;
|
|
6085
6421
|
if (start_sp === 0 && end_sp === glyphGroup.length - 1) {
|
|
@@ -6112,8 +6448,8 @@ var NodePositionConvertToCursor = class {
|
|
|
6112
6448
|
}
|
|
6113
6449
|
const clippedBorderBoxPosition = clipPositionToHorizontalRange(borderBoxPosition, this._horizontalClip);
|
|
6114
6450
|
const clippedContentBoxPosition = clipPositionToHorizontalRange(contentBoxPosition, this._horizontalClip);
|
|
6115
|
-
if (clippedBorderBoxPosition) borderBoxPointGroup.push(pushToPoints(clippedBorderBoxPosition));
|
|
6116
|
-
if (clippedContentBoxPosition) contentBoxPointGroup.push(pushToPoints(clippedContentBoxPosition));
|
|
6451
|
+
if (clippedBorderBoxPosition && !isSelectionOnlyNonInlineEmbedBlock) borderBoxPointGroup.push(pushToPoints(clippedBorderBoxPosition));
|
|
6452
|
+
if (clippedContentBoxPosition && !isSelectionOnlyNonInlineEmbedBlock) contentBoxPointGroup.push(pushToPoints(clippedContentBoxPosition));
|
|
6117
6453
|
cursorList.push({
|
|
6118
6454
|
startOffset: isStartBack ? startOffset : startOffset + firstGlyph.count,
|
|
6119
6455
|
endOffset: isEndBack ? endOffset : endOffset + lastGlyph.count,
|
|
@@ -6126,6 +6462,26 @@ var NodePositionConvertToCursor = class {
|
|
|
6126
6462
|
cursorList
|
|
6127
6463
|
};
|
|
6128
6464
|
}
|
|
6465
|
+
_getCaretGlyph(glyph, glyphGroup, glyphIndex) {
|
|
6466
|
+
var _this$_findTextLikeGl;
|
|
6467
|
+
if (!glyph || !this._isNonInlineEmbedCustomBlockGlyph(glyph)) return glyph;
|
|
6468
|
+
const neighbor = (_this$_findTextLikeGl = this._findTextLikeGlyph(glyphGroup, glyphIndex - 1, -1)) !== null && _this$_findTextLikeGl !== void 0 ? _this$_findTextLikeGl : this._findTextLikeGlyph(glyphGroup, glyphIndex + 1, 1);
|
|
6469
|
+
return neighbor !== null && neighbor !== void 0 ? neighbor : {
|
|
6470
|
+
...glyph,
|
|
6471
|
+
bBox: getDefaultCaretBoundingBox(glyph)
|
|
6472
|
+
};
|
|
6473
|
+
}
|
|
6474
|
+
_findTextLikeGlyph(glyphGroup, startIndex, step) {
|
|
6475
|
+
for (let index = startIndex; index >= 0 && index < glyphGroup.length; index += step) {
|
|
6476
|
+
const glyph = glyphGroup[index];
|
|
6477
|
+
if (!this._isNonInlineEmbedCustomBlockGlyph(glyph)) return glyph;
|
|
6478
|
+
}
|
|
6479
|
+
}
|
|
6480
|
+
_isNonInlineEmbedCustomBlockGlyph(glyph) {
|
|
6481
|
+
var _this$_docSkeleton$ge, _this$_docSkeleton, _this$_docSkeleton$ge2, _this$_docSkeleton$ge3, _this$_docSkeleton$ge4, _this$_docSkeleton$ge5;
|
|
6482
|
+
if (!(glyph === null || glyph === void 0 ? void 0 : glyph.drawingId) || glyph.streamType !== _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK) return false;
|
|
6483
|
+
return !(0, _univerjs_docs.shouldUseInlineTextSelectionForDocsCustomBlockDrawing)((_this$_docSkeleton$ge = (_this$_docSkeleton = this._docSkeleton).getViewModel) === null || _this$_docSkeleton$ge === void 0 || (_this$_docSkeleton$ge3 = (_this$_docSkeleton$ge2 = _this$_docSkeleton$ge.call(_this$_docSkeleton)).getDataModel) === null || _this$_docSkeleton$ge3 === void 0 || (_this$_docSkeleton$ge5 = (_this$_docSkeleton$ge4 = _this$_docSkeleton$ge3.call(_this$_docSkeleton$ge2)).getSnapshot) === null || _this$_docSkeleton$ge5 === void 0 || (_this$_docSkeleton$ge5 = _this$_docSkeleton$ge5.call(_this$_docSkeleton$ge4).drawings) === null || _this$_docSkeleton$ge5 === void 0 ? void 0 : _this$_docSkeleton$ge5[glyph.drawingId]);
|
|
6484
|
+
}
|
|
6129
6485
|
_isValidPosition(startOrigin, endOrigin) {
|
|
6130
6486
|
const { segmentPage: startPage, pageType: startPageType } = startOrigin;
|
|
6131
6487
|
const { segmentPage: endPage, pageType: endPageType } = endOrigin;
|
|
@@ -6371,6 +6727,19 @@ function getCellPageFromSegmentPath(skeletonData, rootPage, path) {
|
|
|
6371
6727
|
}
|
|
6372
6728
|
return null;
|
|
6373
6729
|
}
|
|
6730
|
+
function getDefaultCaretBoundingBox(glyph) {
|
|
6731
|
+
const fontSize = getGlyphFontSize(glyph);
|
|
6732
|
+
return {
|
|
6733
|
+
...glyph.bBox,
|
|
6734
|
+
ba: fontSize,
|
|
6735
|
+
bd: Math.max(2, Math.ceil(fontSize * .25))
|
|
6736
|
+
};
|
|
6737
|
+
}
|
|
6738
|
+
function getGlyphFontSize(glyph) {
|
|
6739
|
+
var _ref, _glyph$fontStyle$orig, _glyph$fontStyle, _glyph$fontStyle2, _glyph$ts;
|
|
6740
|
+
const fontSize = (_ref = (_glyph$fontStyle$orig = (_glyph$fontStyle = glyph.fontStyle) === null || _glyph$fontStyle === void 0 ? void 0 : _glyph$fontStyle.originFontSize) !== null && _glyph$fontStyle$orig !== void 0 ? _glyph$fontStyle$orig : (_glyph$fontStyle2 = glyph.fontStyle) === null || _glyph$fontStyle2 === void 0 ? void 0 : _glyph$fontStyle2.fontSize) !== null && _ref !== void 0 ? _ref : (_glyph$ts = glyph.ts) === null || _glyph$ts === void 0 ? void 0 : _glyph$ts.fs;
|
|
6741
|
+
return typeof fontSize === "number" && Number.isFinite(fontSize) && fontSize > 0 ? fontSize : 14;
|
|
6742
|
+
}
|
|
6374
6743
|
function getDocumentUnitId$1(docSkeleton) {
|
|
6375
6744
|
var _viewModel$getDataMod, _viewModel$getDataMod2, _viewModel$getDataMod3, _viewModel$getDataMod4;
|
|
6376
6745
|
const viewModel = docSkeleton.getViewModel();
|
|
@@ -7521,18 +7890,22 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
7521
7890
|
return this._onPointerEvent;
|
|
7522
7891
|
}
|
|
7523
7892
|
get isFocusing() {
|
|
7524
|
-
return this._input ===
|
|
7893
|
+
return this._input === this._getOwnerDocument().activeElement;
|
|
7525
7894
|
}
|
|
7526
7895
|
get canFocusing() {
|
|
7527
|
-
|
|
7896
|
+
const ownerDocument = this._getOwnerDocument();
|
|
7897
|
+
const activeElement = ownerDocument.activeElement;
|
|
7898
|
+
return !this._shouldPreserveExternalFocus() && (this.isFocusing || activeElement === ownerDocument.body || activeElement === null || activeElement instanceof HTMLElement && this._containsCurrentEmbedRuntimeElement(activeElement));
|
|
7528
7899
|
}
|
|
7529
|
-
constructor(_context, _layoutService, _logService, _univerInstanceService, _docSkeletonManagerService) {
|
|
7900
|
+
constructor(_context, _layoutService, _logService, _univerInstanceService, _docSkeletonManagerService, _embedInteractionBoundaryService, _embedRuntimeFocusCoordinator) {
|
|
7530
7901
|
super();
|
|
7531
7902
|
this._context = _context;
|
|
7532
7903
|
this._layoutService = _layoutService;
|
|
7533
7904
|
this._logService = _logService;
|
|
7534
7905
|
this._univerInstanceService = _univerInstanceService;
|
|
7535
7906
|
this._docSkeletonManagerService = _docSkeletonManagerService;
|
|
7907
|
+
this._embedInteractionBoundaryService = _embedInteractionBoundaryService;
|
|
7908
|
+
this._embedRuntimeFocusCoordinator = _embedRuntimeFocusCoordinator;
|
|
7536
7909
|
_defineProperty(this, "_onInputBefore$", new rxjs.Subject());
|
|
7537
7910
|
_defineProperty(this, "onInputBefore$", this._onInputBefore$.asObservable());
|
|
7538
7911
|
_defineProperty(this, "_onKeydown$", new rxjs.Subject());
|
|
@@ -7570,6 +7943,11 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
7570
7943
|
_defineProperty(this, "_focusNodePosition", null);
|
|
7571
7944
|
_defineProperty(this, "_currentSegmentId", "");
|
|
7572
7945
|
_defineProperty(this, "_currentSegmentPage", -1);
|
|
7946
|
+
_defineProperty(this, "_segmentContext$", new rxjs.BehaviorSubject({
|
|
7947
|
+
segmentId: "",
|
|
7948
|
+
segmentPage: -1
|
|
7949
|
+
}));
|
|
7950
|
+
_defineProperty(this, "segmentContext$", this._segmentContext$.asObservable());
|
|
7573
7951
|
_defineProperty(this, "_selectionStyle", _univerjs_engine_render.NORMAL_TEXT_SELECTION_PLUGIN_STYLE);
|
|
7574
7952
|
_defineProperty(this, "_onPointerEvent", false);
|
|
7575
7953
|
_defineProperty(this, "_viewPortObserverMap", /* @__PURE__ */ new Map());
|
|
@@ -7592,13 +7970,23 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
7592
7970
|
return this._context.scene.getViewports()[0];
|
|
7593
7971
|
}
|
|
7594
7972
|
setSegment(id) {
|
|
7973
|
+
if (this._currentSegmentId === id) return;
|
|
7595
7974
|
this._currentSegmentId = id;
|
|
7975
|
+
this._segmentContext$.next({
|
|
7976
|
+
segmentId: id,
|
|
7977
|
+
segmentPage: this._currentSegmentPage
|
|
7978
|
+
});
|
|
7596
7979
|
}
|
|
7597
7980
|
getSegment() {
|
|
7598
7981
|
return this._currentSegmentId;
|
|
7599
7982
|
}
|
|
7600
7983
|
setSegmentPage(pageIndex) {
|
|
7984
|
+
if (this._currentSegmentPage === pageIndex) return;
|
|
7601
7985
|
this._currentSegmentPage = pageIndex;
|
|
7986
|
+
this._segmentContext$.next({
|
|
7987
|
+
segmentId: this._currentSegmentId,
|
|
7988
|
+
segmentPage: pageIndex
|
|
7989
|
+
});
|
|
7602
7990
|
}
|
|
7603
7991
|
getSegmentPage() {
|
|
7604
7992
|
return this._currentSegmentPage;
|
|
@@ -7673,14 +8061,11 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
7673
8061
|
sync() {
|
|
7674
8062
|
this._updateInputPosition();
|
|
7675
8063
|
}
|
|
7676
|
-
/**
|
|
7677
|
-
* @deprecated
|
|
7678
|
-
*/
|
|
7679
8064
|
activate(x, y, force = false) {
|
|
7680
8065
|
this._ensureHostContainer();
|
|
7681
8066
|
let left = x;
|
|
7682
8067
|
let top = y;
|
|
7683
|
-
const fixedContainer = this._container.
|
|
8068
|
+
const fixedContainer = this._container.offsetParent;
|
|
7684
8069
|
if (fixedContainer) {
|
|
7685
8070
|
const rect = fixedContainer.getBoundingClientRect();
|
|
7686
8071
|
left -= rect.left;
|
|
@@ -7689,12 +8074,13 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
7689
8074
|
this._container.style.left = `${left}px`;
|
|
7690
8075
|
this._container.style.top = `${top}px`;
|
|
7691
8076
|
this._container.style.zIndex = "1000";
|
|
7692
|
-
if (this.
|
|
8077
|
+
if (force && !this._shouldPreserveExternalFocus() || !force && this.canFocusing) this.focus();
|
|
7693
8078
|
}
|
|
7694
8079
|
hasFocus() {
|
|
7695
|
-
return
|
|
8080
|
+
return this._getOwnerDocument().activeElement === this._input;
|
|
7696
8081
|
}
|
|
7697
8082
|
focus() {
|
|
8083
|
+
if (!this._input.hasAttribute("tabindex")) this._input.tabIndex = -1;
|
|
7698
8084
|
this._input.focus();
|
|
7699
8085
|
}
|
|
7700
8086
|
blur() {
|
|
@@ -7936,6 +8322,10 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
7936
8322
|
}
|
|
7937
8323
|
if (this._container.parentElement !== document.body) document.body.appendChild(this._container);
|
|
7938
8324
|
}
|
|
8325
|
+
_getOwnerDocument() {
|
|
8326
|
+
var _this$_container$owne, _this$_container;
|
|
8327
|
+
return (_this$_container$owne = (_this$_container = this._container) === null || _this$_container === void 0 ? void 0 : _this$_container.ownerDocument) !== null && _this$_container$owne !== void 0 ? _this$_container$owne : document;
|
|
8328
|
+
}
|
|
7939
8329
|
_getNodePosition(node) {
|
|
7940
8330
|
if (node == null) return;
|
|
7941
8331
|
const { node: glyph, ratioX, segmentPage } = node;
|
|
@@ -8071,6 +8461,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
8071
8461
|
const activeRangeInstance = this._getActiveRangeInstance();
|
|
8072
8462
|
const anchor = activeRangeInstance === null || activeRangeInstance === void 0 ? void 0 : activeRangeInstance.getAnchor();
|
|
8073
8463
|
if (!anchor || anchor && !anchor.visible || this.activeViewPort == null) {
|
|
8464
|
+
if (this._shouldPreserveExternalFocus()) return;
|
|
8074
8465
|
this.focus();
|
|
8075
8466
|
return;
|
|
8076
8467
|
}
|
|
@@ -8167,12 +8558,15 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
8167
8558
|
}
|
|
8168
8559
|
_initInputEvents() {
|
|
8169
8560
|
this.disposeWithMe((0, rxjs.fromEvent)(this._input, "keydown").subscribe((e) => {
|
|
8561
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8170
8562
|
if (this._isIMEInputApply) return;
|
|
8563
|
+
this._stopEmbedOwnedEditorShortcutPropagation(e);
|
|
8171
8564
|
this._eventHandle(e, (config) => {
|
|
8172
8565
|
this._onKeydown$.next(config);
|
|
8173
8566
|
});
|
|
8174
8567
|
}));
|
|
8175
8568
|
this.disposeWithMe((0, rxjs.fromEvent)(this._input, "input").subscribe((e) => {
|
|
8569
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8176
8570
|
if (e.inputType === "historyUndo" || e.inputType === "historyRedo") return;
|
|
8177
8571
|
if (this._rectRangeList.length > 0) {
|
|
8178
8572
|
e.stopPropagation();
|
|
@@ -8185,6 +8579,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
8185
8579
|
});
|
|
8186
8580
|
}));
|
|
8187
8581
|
this.disposeWithMe((0, rxjs.fromEvent)(this._input, "compositionstart").subscribe((e) => {
|
|
8582
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8188
8583
|
if (this._rectRangeList.length > 0) {
|
|
8189
8584
|
e.stopPropagation();
|
|
8190
8585
|
return e.preventDefault();
|
|
@@ -8195,28 +8590,33 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
8195
8590
|
});
|
|
8196
8591
|
}));
|
|
8197
8592
|
this.disposeWithMe((0, rxjs.fromEvent)(this._input, "compositionend").subscribe((e) => {
|
|
8593
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8198
8594
|
this._isIMEInputApply = false;
|
|
8199
8595
|
this._eventHandle(e, (config) => {
|
|
8200
8596
|
this._onCompositionend$.next(config);
|
|
8201
8597
|
});
|
|
8202
8598
|
}));
|
|
8203
8599
|
this.disposeWithMe((0, rxjs.fromEvent)(this._input, "compositionupdate").subscribe((e) => {
|
|
8600
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8204
8601
|
this._eventHandle(e, (config) => {
|
|
8205
8602
|
this._onInputBefore$.next(config);
|
|
8206
8603
|
this._onCompositionupdate$.next(config);
|
|
8207
8604
|
});
|
|
8208
8605
|
}));
|
|
8209
8606
|
this.disposeWithMe((0, rxjs.fromEvent)(this._input, "paste").subscribe((e) => {
|
|
8607
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8210
8608
|
this._eventHandle(e, (config) => {
|
|
8211
8609
|
this._onPaste$.next(config);
|
|
8212
8610
|
});
|
|
8213
8611
|
}));
|
|
8214
8612
|
this.disposeWithMe((0, rxjs.fromEvent)(this._input, "focus").subscribe((e) => {
|
|
8613
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8215
8614
|
this._eventHandle(e, (config) => {
|
|
8216
8615
|
this._onFocus$.next(config);
|
|
8217
8616
|
});
|
|
8218
8617
|
}));
|
|
8219
8618
|
this.disposeWithMe((0, rxjs.fromEvent)(this._input, "blur").subscribe((e) => {
|
|
8619
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8220
8620
|
this._eventHandle(e, (config) => {
|
|
8221
8621
|
this._onBlur$.next(config);
|
|
8222
8622
|
});
|
|
@@ -8232,6 +8632,26 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
8232
8632
|
rangeList: this._getAllTextRanges()
|
|
8233
8633
|
});
|
|
8234
8634
|
}
|
|
8635
|
+
_shouldSuppressHostHiddenEditorEvent(event) {
|
|
8636
|
+
var _this$_embedRuntimeFo, _this$_embedRuntimeFo2, _this$_embedRuntimeFo3;
|
|
8637
|
+
const unitId = this._context.unitId;
|
|
8638
|
+
if ((0, _univerjs_core.isInternalEditorID)(unitId)) return false;
|
|
8639
|
+
if ((_this$_embedRuntimeFo = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo === void 0 ? void 0 : _this$_embedRuntimeFo.isChildUnitRuntimeEvent(unitId, event.target, event)) return false;
|
|
8640
|
+
if ((_this$_embedRuntimeFo2 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo2 === void 0 ? void 0 : _this$_embedRuntimeFo2.isChildUnitInActiveSession(unitId)) return false;
|
|
8641
|
+
if (event.target instanceof HTMLElement && this._containsCurrentEmbedRuntimeElement(event.target)) return false;
|
|
8642
|
+
if ((_this$_embedRuntimeFo3 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo3 === void 0 ? void 0 : _this$_embedRuntimeFo3.shouldSuppressHostInteraction(unitId, event.target, event)) {
|
|
8643
|
+
event.stopPropagation();
|
|
8644
|
+
if (event.cancelable) event.preventDefault();
|
|
8645
|
+
if (event.type === "focus" && event.target instanceof HTMLElement) event.target.blur();
|
|
8646
|
+
return true;
|
|
8647
|
+
}
|
|
8648
|
+
return false;
|
|
8649
|
+
}
|
|
8650
|
+
_stopEmbedOwnedEditorShortcutPropagation(event) {
|
|
8651
|
+
if (!(event instanceof KeyboardEvent) || !this._getCurrentEmbedOwner()) return;
|
|
8652
|
+
if (!(event.key.toLowerCase() === "a" && (event.metaKey || event.ctrlKey))) return;
|
|
8653
|
+
event.stopPropagation();
|
|
8654
|
+
}
|
|
8235
8655
|
_getTransformCoordForDocumentOffset(evtOffsetX, evtOffsetY) {
|
|
8236
8656
|
const { documentTransform } = this._context.mainComponent.getOffsetConfig();
|
|
8237
8657
|
if (this.activeViewPort == null || documentTransform == null) return;
|
|
@@ -8247,6 +8667,50 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
8247
8667
|
const { pageLayoutType = _univerjs_engine_render.PageLayoutType.VERTICAL, pageMarginLeft, pageMarginTop } = document.getOffsetConfig();
|
|
8248
8668
|
return skeleton.findNodeByCoord(coord, pageLayoutType, pageMarginLeft, pageMarginTop, restrictions);
|
|
8249
8669
|
}
|
|
8670
|
+
_shouldPreserveExternalFocus() {
|
|
8671
|
+
var _this$_embedRuntimeFo4, _this$_embedRuntimeFo5, _this$_embedRuntimeFo6, _this$_embedInteracti, _this$_embedInteracti2, _this$_embedInteracti3;
|
|
8672
|
+
const ownerDocument = this._getOwnerDocument();
|
|
8673
|
+
const activeElement = ownerDocument.activeElement;
|
|
8674
|
+
const currentEmbedOwner = this._getCurrentEmbedOwner();
|
|
8675
|
+
if ((_this$_embedRuntimeFo4 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo4 === void 0 ? void 0 : _this$_embedRuntimeFo4.isChildUnitInActiveSession(this._context.unitId)) return false;
|
|
8676
|
+
if ((_this$_embedRuntimeFo5 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo5 === void 0 ? void 0 : _this$_embedRuntimeFo5.isChildUnitRuntimeEvent(this._context.unitId, activeElement)) return false;
|
|
8677
|
+
if (activeElement instanceof HTMLElement && this._containsOwnEditorElement(activeElement)) return false;
|
|
8678
|
+
if (activeElement instanceof HTMLElement && this._containsCurrentEmbedRuntimeElement(activeElement)) return false;
|
|
8679
|
+
if ((_this$_embedRuntimeFo6 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo6 === void 0 ? void 0 : _this$_embedRuntimeFo6.shouldSuppressHostInteraction(this._context.unitId, activeElement)) return true;
|
|
8680
|
+
if (currentEmbedOwner && ((_this$_embedInteracti = this._embedInteractionBoundaryService) === null || _this$_embedInteracti === void 0 ? void 0 : _this$_embedInteracti.contains(currentEmbedOwner, activeElement))) return true;
|
|
8681
|
+
if (activeElement instanceof HTMLElement && this._containsCurrentLayoutElement(activeElement)) return false;
|
|
8682
|
+
return ((_this$_embedInteracti2 = this._embedInteractionBoundaryService) === null || _this$_embedInteracti2 === void 0 || (_this$_embedInteracti3 = _this$_embedInteracti2.hasRecentInteractionFor) === null || _this$_embedInteracti3 === void 0 ? void 0 : _this$_embedInteracti3.call(_this$_embedInteracti2, currentEmbedOwner, ownerDocument)) === true;
|
|
8683
|
+
}
|
|
8684
|
+
_containsCurrentEmbedRuntimeElement(element) {
|
|
8685
|
+
const currentEmbedOwner = this._getCurrentEmbedOwner();
|
|
8686
|
+
if (!currentEmbedOwner) return false;
|
|
8687
|
+
return this._getElementEmbedOwner(element) === currentEmbedOwner && this._containsCurrentLayoutElement(element);
|
|
8688
|
+
}
|
|
8689
|
+
_getCurrentEmbedOwner() {
|
|
8690
|
+
var _this$_layoutService, _ref, _this$_getElementEmbe;
|
|
8691
|
+
const rootContainerElement = (_this$_layoutService = this._layoutService) === null || _this$_layoutService === void 0 ? void 0 : _this$_layoutService.rootContainerElement;
|
|
8692
|
+
return (_ref = (_this$_getElementEmbe = this._getElementEmbedOwner(this._input)) !== null && _this$_getElementEmbe !== void 0 ? _this$_getElementEmbe : this._getElementEmbedOwner(this._container)) !== null && _ref !== void 0 ? _ref : this._getElementEmbedOwner(rootContainerElement instanceof HTMLElement ? rootContainerElement : void 0);
|
|
8693
|
+
}
|
|
8694
|
+
_getElementEmbedOwner(element) {
|
|
8695
|
+
var _element$closest$getA, _element$closest;
|
|
8696
|
+
if (!element || typeof element.closest !== "function") return;
|
|
8697
|
+
return (_element$closest$getA = (_element$closest = element.closest(`[${"data-embed-interaction-boundary-owner"}]`)) === null || _element$closest === void 0 ? void 0 : _element$closest.getAttribute("data-embed-interaction-boundary-owner")) !== null && _element$closest$getA !== void 0 ? _element$closest$getA : void 0;
|
|
8698
|
+
}
|
|
8699
|
+
_containsOwnEditorElement(element) {
|
|
8700
|
+
var _this$_container2, _this$_inputParent;
|
|
8701
|
+
return this._container === element || this._input === element || typeof ((_this$_container2 = this._container) === null || _this$_container2 === void 0 ? void 0 : _this$_container2.contains) === "function" && this._container.contains(element) || typeof ((_this$_inputParent = this._inputParent) === null || _this$_inputParent === void 0 ? void 0 : _this$_inputParent.contains) === "function" && this._inputParent.contains(element);
|
|
8702
|
+
}
|
|
8703
|
+
_containsCurrentLayoutElement(element) {
|
|
8704
|
+
var _layoutService$checkE, _this$_container4;
|
|
8705
|
+
const layoutService = this._layoutService;
|
|
8706
|
+
if (!layoutService) {
|
|
8707
|
+
var _this$_container3;
|
|
8708
|
+
return this._container === element || typeof ((_this$_container3 = this._container) === null || _this$_container3 === void 0 ? void 0 : _this$_container3.contains) === "function" && this._container.contains(element);
|
|
8709
|
+
}
|
|
8710
|
+
if ((_layoutService$checkE = layoutService.checkElementInCurrentContainers) === null || _layoutService$checkE === void 0 ? void 0 : _layoutService$checkE.call(layoutService, element)) return true;
|
|
8711
|
+
const root = layoutService.rootContainerElement;
|
|
8712
|
+
return root === element || (root === null || root === void 0 ? void 0 : root.contains(element)) === true || this._container === element || typeof ((_this$_container4 = this._container) === null || _this$_container4 === void 0 ? void 0 : _this$_container4.contains) === "function" && this._container.contains(element);
|
|
8713
|
+
}
|
|
8250
8714
|
_detachEvent() {
|
|
8251
8715
|
this._onInputBefore$.complete();
|
|
8252
8716
|
this._onKeydown$.complete();
|
|
@@ -8260,13 +8724,16 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
8260
8724
|
this._onFocus$.complete();
|
|
8261
8725
|
this._onBlur$.complete();
|
|
8262
8726
|
this._onPointerDown$.complete();
|
|
8727
|
+
this._segmentContext$.complete();
|
|
8263
8728
|
}
|
|
8264
8729
|
};
|
|
8265
8730
|
DocSelectionRenderService = __decorate([
|
|
8266
8731
|
__decorateParam(1, _univerjs_ui.ILayoutService),
|
|
8267
8732
|
__decorateParam(2, _univerjs_core.ILogService),
|
|
8268
8733
|
__decorateParam(3, _univerjs_core.IUniverInstanceService),
|
|
8269
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_docs.DocSkeletonManagerService))
|
|
8734
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_docs.DocSkeletonManagerService)),
|
|
8735
|
+
__decorateParam(5, (0, _univerjs_core.Optional)(IDocEmbedInteractionBoundaryService)),
|
|
8736
|
+
__decorateParam(6, (0, _univerjs_core.Optional)(IDocEmbedRuntimeFocusCoordinator))
|
|
8270
8737
|
], DocSelectionRenderService);
|
|
8271
8738
|
|
|
8272
8739
|
//#endregion
|
|
@@ -8388,10 +8855,10 @@ function canInsertTableAtOffset(body, offset) {
|
|
|
8388
8855
|
return !(isOffsetInTableRange(body.tables, offset) || isOffsetInIndexRange(body.blockRanges, offset) || isOffsetOnPointRange(body.customBlocks, offset));
|
|
8389
8856
|
}
|
|
8390
8857
|
function isOffsetInTableRange(ranges, offset) {
|
|
8391
|
-
return Boolean(ranges === null || ranges === void 0 ? void 0 : ranges.some((range) =>
|
|
8858
|
+
return Boolean(ranges === null || ranges === void 0 ? void 0 : ranges.some((range) => (0, _univerjs_core.containsInteriorInsertionOffset)((0, _univerjs_core.getTableRangeInterval)(range), offset)));
|
|
8392
8859
|
}
|
|
8393
8860
|
function isOffsetInIndexRange(ranges, offset) {
|
|
8394
|
-
return Boolean(ranges === null || ranges === void 0 ? void 0 : ranges.some((range) =>
|
|
8861
|
+
return Boolean(ranges === null || ranges === void 0 ? void 0 : ranges.some((range) => (0, _univerjs_core.containsInteriorInsertionOffset)((0, _univerjs_core.getBlockRangeInterval)(range), offset)));
|
|
8395
8862
|
}
|
|
8396
8863
|
function isOffsetOnPointRange(ranges, offset) {
|
|
8397
8864
|
return Boolean(ranges === null || ranges === void 0 ? void 0 : ranges.some((range) => range.startIndex === offset));
|
|
@@ -8429,7 +8896,9 @@ const CreateDocTableCommand = {
|
|
|
8429
8896
|
if (skeleton == null) return false;
|
|
8430
8897
|
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
8898
|
if (!canInsertTableAtOffset(body, startOffset)) return false;
|
|
8432
|
-
const prevParagraph = ((_body$paragraphs = body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : []).find((
|
|
8899
|
+
const prevParagraph = ((_body$paragraphs = body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : []).find((paragraph) => {
|
|
8900
|
+
return (0, _univerjs_core.getParagraphContentStartOffset)(body, paragraph) < startOffset && startOffset <= paragraph.startIndex;
|
|
8901
|
+
});
|
|
8433
8902
|
const curGlyph = skeleton.findNodeByCharIndex(startOffset, segmentId, segmentPage);
|
|
8434
8903
|
if (curGlyph == null) return false;
|
|
8435
8904
|
const needCreateParagraph = shouldCreateParagraphBeforeTable(body, startOffset);
|
|
@@ -8458,7 +8927,7 @@ const CreateDocTableCommand = {
|
|
|
8458
8927
|
t: _univerjs_core.TextXActionType.INSERT,
|
|
8459
8928
|
body: {
|
|
8460
8929
|
dataStream: _univerjs_core.DataStreamTreeTokenType.PARAGRAPH,
|
|
8461
|
-
paragraphs: generateParagraphs(_univerjs_core.DataStreamTreeTokenType.PARAGRAPH, prevParagraph)
|
|
8930
|
+
paragraphs: (0, _univerjs_docs.generateParagraphs)(_univerjs_core.DataStreamTreeTokenType.PARAGRAPH, prevParagraph)
|
|
8462
8931
|
},
|
|
8463
8932
|
len: 1
|
|
8464
8933
|
});
|
|
@@ -9206,11 +9675,14 @@ var Editor = class extends _univerjs_core.Disposable {
|
|
|
9206
9675
|
body: {
|
|
9207
9676
|
dataStream: `${text}\r\n`,
|
|
9208
9677
|
paragraphs: [{
|
|
9209
|
-
startIndex:
|
|
9678
|
+
startIndex: text.length,
|
|
9210
9679
|
paragraphId: (0, _univerjs_core.createParagraphId)(/* @__PURE__ */ new Set())
|
|
9211
9680
|
}],
|
|
9212
9681
|
customRanges: [],
|
|
9213
|
-
sectionBreaks: [
|
|
9682
|
+
sectionBreaks: [{
|
|
9683
|
+
sectionId: (0, _univerjs_core.createSectionId)(/* @__PURE__ */ new Set()),
|
|
9684
|
+
startIndex: text.length + 1
|
|
9685
|
+
}],
|
|
9214
9686
|
tables: [],
|
|
9215
9687
|
textRuns: []
|
|
9216
9688
|
}
|
|
@@ -9580,6 +10052,7 @@ DocBackScrollRenderController = __decorate([
|
|
|
9580
10052
|
//#region src/controllers/render-controllers/doc-paragraph-placeholder.render-controller.ts
|
|
9581
10053
|
const PLACEHOLDER_COLOR = "rgba(0, 0, 0, 0.35)";
|
|
9582
10054
|
const DEFAULT_PLACEHOLDER_FONT_SIZE = 12;
|
|
10055
|
+
const MIN_BODY_TEXT_PLACEHOLDER_FONT_SIZE = 16;
|
|
9583
10056
|
const DEFAULT_PLACEHOLDER_FONT_FAMILY = "Arial";
|
|
9584
10057
|
const LIST_PLACEHOLDER_GAP = 4;
|
|
9585
10058
|
let DocParagraphPlaceholderRenderController = class DocParagraphPlaceholderRenderController extends _univerjs_core.Disposable {
|
|
@@ -9673,11 +10146,11 @@ function getPlaceholderText(paragraph, locale) {
|
|
|
9673
10146
|
}
|
|
9674
10147
|
}
|
|
9675
10148
|
function getLinePlaceholderLayout(line, paragraph, text, originLeft, originTop) {
|
|
9676
|
-
var _divide$glyphGroup, _paragraph$paragraphS2, _paragraph$paragraphS3,
|
|
10149
|
+
var _divide$glyphGroup, _paragraph$paragraphS2, _paragraph$paragraphS3, _getLineFontFamily, _divide$left, _divide$paddingLeft, _ref, _divide$width;
|
|
9677
10150
|
const divide = line.divides[0];
|
|
9678
10151
|
const firstGlyph = ((_divide$glyphGroup = divide === null || divide === void 0 ? void 0 : divide.glyphGroup) !== null && _divide$glyphGroup !== void 0 ? _divide$glyphGroup : [])[0];
|
|
9679
10152
|
const textStyle = _univerjs_core.NAMED_STYLE_MAP[(_paragraph$paragraphS2 = (_paragraph$paragraphS3 = paragraph.paragraphStyle) === null || _paragraph$paragraphS3 === void 0 ? void 0 : _paragraph$paragraphS3.namedStyleType) !== null && _paragraph$paragraphS2 !== void 0 ? _paragraph$paragraphS2 : _univerjs_core.NamedStyleType.NORMAL_TEXT];
|
|
9680
|
-
const fontSize = (
|
|
10153
|
+
const fontSize = getPlaceholderFontSize(line, paragraph);
|
|
9681
10154
|
const fontFamily = (_getLineFontFamily = getLineFontFamily(line)) !== null && _getLineFontFamily !== void 0 ? _getLineFontFamily : DEFAULT_PLACEHOLDER_FONT_FAMILY;
|
|
9682
10155
|
const fontWeight = (textStyle === null || textStyle === void 0 ? void 0 : textStyle.bl) ? "bold" : "normal";
|
|
9683
10156
|
const lineStartX = originLeft + ((_divide$left = divide === null || divide === void 0 ? void 0 : divide.left) !== null && _divide$left !== void 0 ? _divide$left : 0) + ((_divide$paddingLeft = divide === null || divide === void 0 ? void 0 : divide.paddingLeft) !== null && _divide$paddingLeft !== void 0 ? _divide$paddingLeft : 0);
|
|
@@ -9686,7 +10159,7 @@ function getLinePlaceholderLayout(line, paragraph, text, originLeft, originTop)
|
|
|
9686
10159
|
fontFamily,
|
|
9687
10160
|
fontSize,
|
|
9688
10161
|
fontWeight,
|
|
9689
|
-
maxWidth: Math.max(0, ((
|
|
10162
|
+
maxWidth: Math.max(0, ((_ref = (_divide$width = divide === null || divide === void 0 ? void 0 : divide.width) !== null && _divide$width !== void 0 ? _divide$width : line.width) !== null && _ref !== void 0 ? _ref : 0) - listOffset),
|
|
9690
10163
|
text,
|
|
9691
10164
|
x: lineStartX + listOffset,
|
|
9692
10165
|
y: originTop + line.top + line.marginTop + line.paddingTop + line.asc
|
|
@@ -9701,12 +10174,20 @@ function stripNonTextTokens(text) {
|
|
|
9701
10174
|
}
|
|
9702
10175
|
function getLineFontSize(line) {
|
|
9703
10176
|
for (const divide of line.divides) for (const glyph of divide.glyphGroup) {
|
|
9704
|
-
var
|
|
9705
|
-
const fontSize = (
|
|
10177
|
+
var _ref2, _glyph$fontStyle$orig, _glyph$fontStyle, _glyph$fontStyle2, _glyph$ts;
|
|
10178
|
+
const fontSize = (_ref2 = (_glyph$fontStyle$orig = (_glyph$fontStyle = glyph.fontStyle) === null || _glyph$fontStyle === void 0 ? void 0 : _glyph$fontStyle.originFontSize) !== null && _glyph$fontStyle$orig !== void 0 ? _glyph$fontStyle$orig : (_glyph$fontStyle2 = glyph.fontStyle) === null || _glyph$fontStyle2 === void 0 ? void 0 : _glyph$fontStyle2.fontSize) !== null && _ref2 !== void 0 ? _ref2 : (_glyph$ts = glyph.ts) === null || _glyph$ts === void 0 ? void 0 : _glyph$ts.fs;
|
|
9706
10179
|
if (fontSize) return fontSize;
|
|
9707
10180
|
}
|
|
9708
10181
|
return null;
|
|
9709
10182
|
}
|
|
10183
|
+
function getPlaceholderFontSize(line, paragraph) {
|
|
10184
|
+
var _paragraph$paragraphS4, _paragraph$paragraphS5, _ref3, _getLineFontSize;
|
|
10185
|
+
const namedStyleType = (_paragraph$paragraphS4 = (_paragraph$paragraphS5 = paragraph.paragraphStyle) === null || _paragraph$paragraphS5 === void 0 ? void 0 : _paragraph$paragraphS5.namedStyleType) !== null && _paragraph$paragraphS4 !== void 0 ? _paragraph$paragraphS4 : _univerjs_core.NamedStyleType.NORMAL_TEXT;
|
|
10186
|
+
const textStyle = _univerjs_core.NAMED_STYLE_MAP[namedStyleType];
|
|
10187
|
+
const fontSize = (_ref3 = (_getLineFontSize = getLineFontSize(line)) !== null && _getLineFontSize !== void 0 ? _getLineFontSize : textStyle === null || textStyle === void 0 ? void 0 : textStyle.fs) !== null && _ref3 !== void 0 ? _ref3 : DEFAULT_PLACEHOLDER_FONT_SIZE;
|
|
10188
|
+
if (namedStyleType !== _univerjs_core.NamedStyleType.NORMAL_TEXT) return fontSize;
|
|
10189
|
+
return Math.max(fontSize, MIN_BODY_TEXT_PLACEHOLDER_FONT_SIZE);
|
|
10190
|
+
}
|
|
9710
10191
|
function getLineFontFamily(line) {
|
|
9711
10192
|
for (const divide of line.divides) for (const glyph of divide.glyphGroup) {
|
|
9712
10193
|
var _glyph$fontStyle$font, _glyph$fontStyle3, _glyph$ts2;
|
|
@@ -9790,11 +10271,11 @@ let DocViewScaleService = class DocViewScaleService extends _univerjs_core.Dispo
|
|
|
9790
10271
|
return (_this$getPluginConfig = this.getPluginConfig().fitToWidth) !== null && _this$getPluginConfig !== void 0 ? _this$getPluginConfig : DEFAULT_DOC_FIT_TO_WIDTH_OPTIONS;
|
|
9791
10272
|
}
|
|
9792
10273
|
getBaseWidth() {
|
|
9793
|
-
var _documentStyle$pageSi;
|
|
9794
|
-
const documentStyle = this._context.unit.getSnapshot().documentStyle;
|
|
10274
|
+
var _this$_context$unit, _this$_context$unit$g, _documentStyle$pageSi;
|
|
10275
|
+
const documentStyle = (_this$_context$unit = this._context.unit) === null || _this$_context$unit === void 0 || (_this$_context$unit$g = _this$_context$unit.getSnapshot) === null || _this$_context$unit$g === void 0 || (_this$_context$unit$g = _this$_context$unit$g.call(_this$_context$unit)) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.documentStyle;
|
|
9795
10276
|
return resolveDocFitBaseWidth({
|
|
9796
|
-
documentFlavor: documentStyle.documentFlavor,
|
|
9797
|
-
documentStylePageWidth: (_documentStyle$pageSi = documentStyle.pageSize) === null || _documentStyle$pageSi === void 0 ? void 0 : _documentStyle$pageSi.width
|
|
10277
|
+
documentFlavor: documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.documentFlavor,
|
|
10278
|
+
documentStylePageWidth: documentStyle === null || documentStyle === void 0 || (_documentStyle$pageSi = documentStyle.pageSize) === null || _documentStyle$pageSi === void 0 ? void 0 : _documentStyle$pageSi.width
|
|
9798
10279
|
});
|
|
9799
10280
|
}
|
|
9800
10281
|
getAvailableWidth() {
|
|
@@ -9807,6 +10288,7 @@ let DocViewScaleService = class DocViewScaleService extends _univerjs_core.Dispo
|
|
|
9807
10288
|
return this._context.engine.width;
|
|
9808
10289
|
}
|
|
9809
10290
|
getUserZoomRatio() {
|
|
10291
|
+
if (this._context.unit == null) return 1;
|
|
9810
10292
|
return getDocEffectiveZoomRatio(this._context.unit);
|
|
9811
10293
|
}
|
|
9812
10294
|
getFitToWidthScale() {
|
|
@@ -9884,7 +10366,7 @@ DocPageLayoutService = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)
|
|
|
9884
10366
|
//#endregion
|
|
9885
10367
|
//#region src/controllers/render-controllers/doc.render-controller.ts
|
|
9886
10368
|
let DocRenderController = class DocRenderController extends _univerjs_core.RxDisposable {
|
|
9887
|
-
constructor(_context, _commandService, _docSelectionRenderService, _docSkeletonManagerService, _editorService, _renderManagerService, _univerInstanceService, _docPageLayoutService, _textSelectionManagerService, _themeService) {
|
|
10369
|
+
constructor(_context, _commandService, _docSelectionRenderService, _docSkeletonManagerService, _editorService, _renderManagerService, _univerInstanceService, _docPageLayoutService, _textSelectionManagerService, _docViewScaleService, _themeService) {
|
|
9888
10370
|
super();
|
|
9889
10371
|
this._context = _context;
|
|
9890
10372
|
this._commandService = _commandService;
|
|
@@ -9895,6 +10377,7 @@ let DocRenderController = class DocRenderController extends _univerjs_core.RxDis
|
|
|
9895
10377
|
this._univerInstanceService = _univerInstanceService;
|
|
9896
10378
|
this._docPageLayoutService = _docPageLayoutService;
|
|
9897
10379
|
this._textSelectionManagerService = _textSelectionManagerService;
|
|
10380
|
+
this._docViewScaleService = _docViewScaleService;
|
|
9898
10381
|
this._themeService = _themeService;
|
|
9899
10382
|
this._addNewRender();
|
|
9900
10383
|
this._initRenderRefresh();
|
|
@@ -9941,7 +10424,7 @@ let DocRenderController = class DocRenderController extends _univerjs_core.RxDis
|
|
|
9941
10424
|
else e.preventDefault();
|
|
9942
10425
|
} else viewMain.onMouseWheel(e, state);
|
|
9943
10426
|
});
|
|
9944
|
-
new _univerjs_engine_render.ScrollBar(viewMain);
|
|
10427
|
+
new _univerjs_engine_render.ScrollBar(viewMain, { enableHorizontal: this._shouldEnableHorizontalScrollBar() });
|
|
9945
10428
|
scene.addLayer(new _univerjs_engine_render.Layer(scene, [], 2), new _univerjs_engine_render.Layer(scene, [], 4));
|
|
9946
10429
|
this._addComponent();
|
|
9947
10430
|
const frameFn = () => scene.render();
|
|
@@ -9951,6 +10434,10 @@ let DocRenderController = class DocRenderController extends _univerjs_core.RxDis
|
|
|
9951
10434
|
}));
|
|
9952
10435
|
this._docSelectionRenderService.__attachScrollEvent();
|
|
9953
10436
|
}
|
|
10437
|
+
_shouldEnableHorizontalScrollBar() {
|
|
10438
|
+
const options = this._docViewScaleService.getOptions();
|
|
10439
|
+
return !(options.mode === "fit-width" && options.target === "container" && options.align === "start");
|
|
10440
|
+
}
|
|
9954
10441
|
_addComponent() {
|
|
9955
10442
|
const { scene, unit: documentModel, components } = this._context;
|
|
9956
10443
|
const config = {
|
|
@@ -10086,7 +10573,8 @@ DocRenderController = __decorate([
|
|
|
10086
10573
|
__decorateParam(6, _univerjs_core.IUniverInstanceService),
|
|
10087
10574
|
__decorateParam(7, (0, _univerjs_core.Inject)(DocPageLayoutService)),
|
|
10088
10575
|
__decorateParam(8, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService)),
|
|
10089
|
-
__decorateParam(9, (0, _univerjs_core.Inject)(
|
|
10576
|
+
__decorateParam(9, (0, _univerjs_core.Inject)(DocViewScaleService)),
|
|
10577
|
+
__decorateParam(10, (0, _univerjs_core.Inject)(_univerjs_core.ThemeService))
|
|
10090
10578
|
], DocRenderController);
|
|
10091
10579
|
function getPageSizeInModernMode(page) {
|
|
10092
10580
|
let { pageWidth, pageHeight } = page;
|
|
@@ -10187,25 +10675,35 @@ const CoreHeaderFooterCommand = {
|
|
|
10187
10675
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
10188
10676
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
10189
10677
|
const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
|
|
10190
|
-
const { unitId, segmentId, createType, headerFooterProps } = params;
|
|
10678
|
+
const { unitId, segmentId, createType, headerFooterProps, sectionId: requestedSectionId } = params;
|
|
10191
10679
|
const docSkeletonManagerService = (_renderManagerService = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(_univerjs_docs.DocSkeletonManagerService);
|
|
10192
10680
|
const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
10193
10681
|
const docViewModel = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel();
|
|
10194
10682
|
if (docDataModel == null || docViewModel == null) return false;
|
|
10195
10683
|
const editArea = docViewModel.getEditArea();
|
|
10196
|
-
const
|
|
10684
|
+
const snapshot = docDataModel.getSnapshot();
|
|
10685
|
+
const sectionId = requestedSectionId;
|
|
10686
|
+
const sections = snapshot.body ? (0, _univerjs_docs.getTopLevelSectionBreaks)(snapshot.body) : [];
|
|
10687
|
+
const sectionIndex = sectionId == null ? -1 : sections.findIndex((section) => section.sectionId === sectionId);
|
|
10688
|
+
const section = sectionIndex < 0 ? void 0 : sections[sectionIndex];
|
|
10689
|
+
const headerFooterConfig = sectionId == null ? snapshot.documentStyle : {
|
|
10690
|
+
...snapshot.documentStyle,
|
|
10691
|
+
...section,
|
|
10692
|
+
...(0, _univerjs_core.resolveSectionHeaderFooterReferences)(snapshot.documentStyle, sections, sectionIndex)
|
|
10693
|
+
};
|
|
10197
10694
|
let resolvedCreateType = createType;
|
|
10198
10695
|
if (headerFooterProps != null) Object.keys(headerFooterProps).forEach((key) => {
|
|
10199
10696
|
const value = headerFooterProps[key];
|
|
10200
|
-
if (resolvedCreateType == null && key === "useFirstPageHeaderFooter" && value === _univerjs_core.BooleanNumber.TRUE && !
|
|
10201
|
-
else if (resolvedCreateType == null && key === "evenAndOddHeaders" && value === _univerjs_core.BooleanNumber.TRUE && !
|
|
10697
|
+
if (resolvedCreateType == null && key === "useFirstPageHeaderFooter" && value === _univerjs_core.BooleanNumber.TRUE && !headerFooterConfig.firstPageHeaderId) resolvedCreateType = editArea === _univerjs_engine_render.DocumentEditArea.HEADER ? _univerjs_docs.HeaderFooterType.FIRST_PAGE_HEADER : _univerjs_docs.HeaderFooterType.FIRST_PAGE_FOOTER;
|
|
10698
|
+
else if (resolvedCreateType == null && key === "evenAndOddHeaders" && value === _univerjs_core.BooleanNumber.TRUE && !headerFooterConfig.evenPageHeaderId) resolvedCreateType = editArea === _univerjs_engine_render.DocumentEditArea.HEADER ? _univerjs_docs.HeaderFooterType.EVEN_PAGE_HEADER : _univerjs_docs.HeaderFooterType.EVEN_PAGE_FOOTER;
|
|
10202
10699
|
});
|
|
10203
10700
|
return commandService.syncExecuteCommand(_univerjs_docs.CreateHeaderFooterCommand.id, {
|
|
10204
10701
|
unitId,
|
|
10205
10702
|
segmentId,
|
|
10206
10703
|
createType: resolvedCreateType,
|
|
10207
10704
|
headerFooterProps,
|
|
10208
|
-
createMode: "pair"
|
|
10705
|
+
createMode: sectionId == null ? "pair" : "single",
|
|
10706
|
+
sectionId
|
|
10209
10707
|
});
|
|
10210
10708
|
}
|
|
10211
10709
|
};
|
|
@@ -10311,6 +10809,73 @@ const DocParagraphSettingPanelOperation = {
|
|
|
10311
10809
|
}
|
|
10312
10810
|
};
|
|
10313
10811
|
|
|
10812
|
+
//#endregion
|
|
10813
|
+
//#region src/views/section-setting/component-name.ts
|
|
10814
|
+
/**
|
|
10815
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
10816
|
+
*
|
|
10817
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10818
|
+
* you may not use this file except in compliance with the License.
|
|
10819
|
+
* You may obtain a copy of the License at
|
|
10820
|
+
*
|
|
10821
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10822
|
+
*
|
|
10823
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10824
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10825
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10826
|
+
* See the License for the specific language governing permissions and
|
|
10827
|
+
* limitations under the License.
|
|
10828
|
+
*/
|
|
10829
|
+
const DOC_SECTION_SETTING_COMPONENT = "doc_ui_section-setting-panel";
|
|
10830
|
+
|
|
10831
|
+
//#endregion
|
|
10832
|
+
//#region src/controllers/doc-section-setting.controller.ts
|
|
10833
|
+
/**
|
|
10834
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
10835
|
+
*
|
|
10836
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10837
|
+
* you may not use this file except in compliance with the License.
|
|
10838
|
+
* You may obtain a copy of the License at
|
|
10839
|
+
*
|
|
10840
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10841
|
+
*
|
|
10842
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10843
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10844
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10845
|
+
* See the License for the specific language governing permissions and
|
|
10846
|
+
* limitations under the License.
|
|
10847
|
+
*/
|
|
10848
|
+
let DocSectionSettingController = class DocSectionSettingController extends _univerjs_core.Disposable {
|
|
10849
|
+
constructor(_sidebarService) {
|
|
10850
|
+
super();
|
|
10851
|
+
this._sidebarService = _sidebarService;
|
|
10852
|
+
_defineProperty(this, "_panelId", "DocSectionSetting");
|
|
10853
|
+
}
|
|
10854
|
+
openPanel() {
|
|
10855
|
+
this._sidebarService.open({
|
|
10856
|
+
header: { title: "docs-ui.doc.slider.sectionSetting" },
|
|
10857
|
+
id: this._panelId,
|
|
10858
|
+
children: { label: DOC_SECTION_SETTING_COMPONENT },
|
|
10859
|
+
width: 300
|
|
10860
|
+
});
|
|
10861
|
+
}
|
|
10862
|
+
closePanel() {
|
|
10863
|
+
this._sidebarService.close(this._panelId);
|
|
10864
|
+
}
|
|
10865
|
+
};
|
|
10866
|
+
DocSectionSettingController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService))], DocSectionSettingController);
|
|
10867
|
+
|
|
10868
|
+
//#endregion
|
|
10869
|
+
//#region src/commands/operations/doc-section-setting-panel.operation.ts
|
|
10870
|
+
const DocSectionSettingPanelOperation = {
|
|
10871
|
+
id: "sidebar.operation.doc-section-setting-panel",
|
|
10872
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
10873
|
+
handler: (accessor) => {
|
|
10874
|
+
accessor.get(DocSectionSettingController).openPanel();
|
|
10875
|
+
return true;
|
|
10876
|
+
}
|
|
10877
|
+
};
|
|
10878
|
+
|
|
10314
10879
|
//#endregion
|
|
10315
10880
|
//#region src/views/PageSettings.tsx
|
|
10316
10881
|
const MODERN_WIDTH_OPTIONS = [
|
|
@@ -10388,29 +10953,15 @@ function PageSettings(props) {
|
|
|
10388
10953
|
}
|
|
10389
10954
|
}));
|
|
10390
10955
|
};
|
|
10391
|
-
const handleModeChange = (mode) => {
|
|
10392
|
-
setSettings((prev) => ({
|
|
10393
|
-
...prev,
|
|
10394
|
-
mode
|
|
10395
|
-
}));
|
|
10396
|
-
};
|
|
10397
10956
|
const handleModernWidthChange = (modernWidth) => {
|
|
10398
10957
|
setSettings((prev) => ({
|
|
10399
10958
|
...prev,
|
|
10400
10959
|
modernWidth
|
|
10401
10960
|
}));
|
|
10402
10961
|
};
|
|
10403
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
10962
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
10404
10963
|
className: "univer-flex univer-flex-col univer-gap-4",
|
|
10405
|
-
children:
|
|
10406
|
-
className: "univer-grid univer-grid-cols-2 univer-rounded-lg univer-bg-gray-100 univer-p-1 dark:!univer-bg-gray-800",
|
|
10407
|
-
children: [_univerjs_core.DocumentFlavor.MODERN, _univerjs_core.DocumentFlavor.TRADITIONAL].map((mode) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
10408
|
-
type: "button",
|
|
10409
|
-
className: (0, _univerjs_design.clsx)("univer-h-8 univer-cursor-pointer univer-rounded-md univer-border-none univer-bg-transparent univer-text-sm univer-font-medium univer-text-gray-600 univer-transition-colors hover:univer-bg-white hover:univer-text-gray-900 dark:!univer-text-gray-200 dark:hover:!univer-bg-gray-700", { "univer-bg-white univer-text-gray-900 univer-shadow-sm dark:!univer-bg-gray-700 dark:!univer-text-white": settings.mode === mode }),
|
|
10410
|
-
onClick: () => handleModeChange(mode),
|
|
10411
|
-
children: localeService.t(mode === _univerjs_core.DocumentFlavor.MODERN ? "docs-ui.page-settings.modern-mode" : "docs-ui.page-settings.classic-mode")
|
|
10412
|
-
}, mode))
|
|
10413
|
-
}), settings.mode === _univerjs_core.DocumentFlavor.MODERN ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
10964
|
+
children: settings.mode === _univerjs_core.DocumentFlavor.MODERN ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
10414
10965
|
className: "univer-flex univer-flex-col univer-gap-2.5",
|
|
10415
10966
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingsLabel, { children: localeService.t("docs-ui.page-settings.modern-width") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
10416
10967
|
className: "univer-grid univer-grid-cols-3 univer-gap-2",
|
|
@@ -10494,7 +11045,7 @@ function PageSettings(props) {
|
|
|
10494
11045
|
})]
|
|
10495
11046
|
})]
|
|
10496
11047
|
})]
|
|
10497
|
-
})] })
|
|
11048
|
+
})] })
|
|
10498
11049
|
});
|
|
10499
11050
|
}
|
|
10500
11051
|
const PAGE_SETTING_COMPONENT_ID = "docs.component.page-setting";
|
|
@@ -10798,12 +11349,38 @@ function TableInsertMenuItemFactory(accessor) {
|
|
|
10798
11349
|
})
|
|
10799
11350
|
};
|
|
10800
11351
|
}
|
|
10801
|
-
function
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
|
|
11352
|
+
function getSectionSettingUnavailableObservable(accessor) {
|
|
11353
|
+
const selectionManager = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
11354
|
+
const instanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
11355
|
+
return new rxjs.Observable((subscriber) => {
|
|
11356
|
+
const emit = () => {
|
|
11357
|
+
var _body$tables;
|
|
11358
|
+
const documentDataModel = instanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
11359
|
+
const activeRange = selectionManager.getActiveTextRange();
|
|
11360
|
+
const body = documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getBody();
|
|
11361
|
+
const unavailable = !documentDataModel || documentDataModel.getDocumentStyle().documentFlavor !== _univerjs_core.DocumentFlavor.TRADITIONAL || !activeRange || Boolean(activeRange.segmentId) || Boolean(body === null || body === void 0 || (_body$tables = body.tables) === null || _body$tables === void 0 ? void 0 : _body$tables.some((table) => activeRange.startOffset > table.startIndex && activeRange.startOffset < table.endIndex));
|
|
11362
|
+
subscriber.next(unavailable);
|
|
11363
|
+
};
|
|
11364
|
+
emit();
|
|
11365
|
+
const subscription = selectionManager.textSelection$.subscribe(emit);
|
|
11366
|
+
return () => subscription.unsubscribe();
|
|
11367
|
+
});
|
|
11368
|
+
}
|
|
11369
|
+
function SectionSettingMenuFactory(accessor) {
|
|
11370
|
+
return {
|
|
11371
|
+
id: DocSectionSettingPanelOperation.id,
|
|
11372
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
11373
|
+
icon: "MenuIcon",
|
|
11374
|
+
title: "docs-ui.doc.menu.sectionSetting",
|
|
11375
|
+
hidden$: (0, rxjs.combineLatest)((0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC), getSectionSettingUnavailableObservable(accessor), (hidden, unavailable) => hidden || unavailable)
|
|
11376
|
+
};
|
|
11377
|
+
}
|
|
11378
|
+
function InsertRowBeforeMenuItemFactory(accessor) {
|
|
11379
|
+
return {
|
|
11380
|
+
id: DocTableInsertRowAboveCommand.id,
|
|
11381
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
11382
|
+
title: "docs-ui.table.insertRowAbove",
|
|
11383
|
+
icon: "InsertRowAboveDoubleIcon",
|
|
10807
11384
|
disabled$: getDisableWhenSelectionNotInTableObservable(accessor),
|
|
10808
11385
|
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC)
|
|
10809
11386
|
};
|
|
@@ -11023,6 +11600,24 @@ const BULLET_LIST_TYPE_COMPONENT = `${COMPONENT_PREFIX}_BULLET_LIST_TYPE_COMPONE
|
|
|
11023
11600
|
|
|
11024
11601
|
//#endregion
|
|
11025
11602
|
//#region src/menu/menu.ts
|
|
11603
|
+
function shouldSuppressDocMenuStateRefresh(accessor) {
|
|
11604
|
+
let univerInstanceService;
|
|
11605
|
+
let focusCoordinator;
|
|
11606
|
+
try {
|
|
11607
|
+
univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
11608
|
+
} catch (error) {
|
|
11609
|
+
if (isInjectorDisposedError(error)) return true;
|
|
11610
|
+
throw error;
|
|
11611
|
+
}
|
|
11612
|
+
try {
|
|
11613
|
+
focusCoordinator = accessor.get(IDocEmbedRuntimeFocusCoordinator);
|
|
11614
|
+
} catch {
|
|
11615
|
+
return false;
|
|
11616
|
+
}
|
|
11617
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
11618
|
+
const unitId = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getUnitId();
|
|
11619
|
+
return focusCoordinator.shouldSuppressHostInteraction(unitId);
|
|
11620
|
+
}
|
|
11026
11621
|
function getInsertTableHiddenObservable(accessor) {
|
|
11027
11622
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
11028
11623
|
const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
|
|
@@ -11216,6 +11811,7 @@ function BoldMenuItemFactory(accessor) {
|
|
|
11216
11811
|
activated$: new rxjs.Observable((subscriber) => {
|
|
11217
11812
|
const calc = () => {
|
|
11218
11813
|
var _textRun$ts;
|
|
11814
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11219
11815
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11220
11816
|
if (textRun == null) {
|
|
11221
11817
|
subscriber.next(false);
|
|
@@ -11246,6 +11842,7 @@ function ItalicMenuItemFactory(accessor) {
|
|
|
11246
11842
|
activated$: new rxjs.Observable((subscriber) => {
|
|
11247
11843
|
const calc = () => {
|
|
11248
11844
|
var _textRun$ts2;
|
|
11845
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11249
11846
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11250
11847
|
if (textRun == null) {
|
|
11251
11848
|
subscriber.next(false);
|
|
@@ -11276,6 +11873,7 @@ function UnderlineMenuItemFactory(accessor) {
|
|
|
11276
11873
|
activated$: new rxjs.Observable((subscriber) => {
|
|
11277
11874
|
const calc = () => {
|
|
11278
11875
|
var _textRun$ts3;
|
|
11876
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11279
11877
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11280
11878
|
if (textRun == null) {
|
|
11281
11879
|
subscriber.next(false);
|
|
@@ -11306,6 +11904,7 @@ function StrikeThroughMenuItemFactory(accessor) {
|
|
|
11306
11904
|
activated$: new rxjs.Observable((subscriber) => {
|
|
11307
11905
|
const calc = () => {
|
|
11308
11906
|
var _textRun$ts4;
|
|
11907
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11309
11908
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11310
11909
|
if (textRun == null) {
|
|
11311
11910
|
subscriber.next(false);
|
|
@@ -11335,6 +11934,7 @@ function SubscriptMenuItemFactory(accessor) {
|
|
|
11335
11934
|
activated$: new rxjs.Observable((subscriber) => {
|
|
11336
11935
|
const calc = () => {
|
|
11337
11936
|
var _textRun$ts5;
|
|
11937
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11338
11938
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11339
11939
|
if (textRun == null) {
|
|
11340
11940
|
subscriber.next(false);
|
|
@@ -11364,6 +11964,7 @@ function SuperscriptMenuItemFactory(accessor) {
|
|
|
11364
11964
|
activated$: new rxjs.Observable((subscriber) => {
|
|
11365
11965
|
const calc = () => {
|
|
11366
11966
|
var _textRun$ts6;
|
|
11967
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11367
11968
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11368
11969
|
if (textRun == null) {
|
|
11369
11970
|
subscriber.next(false);
|
|
@@ -11403,6 +12004,7 @@ function FontFamilySelectorMenuItemFactory(accessor) {
|
|
|
11403
12004
|
const defaultValue = _univerjs_core.DEFAULT_STYLES.ff;
|
|
11404
12005
|
const calc = () => {
|
|
11405
12006
|
var _textRun$ts7;
|
|
12007
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11406
12008
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11407
12009
|
if (textRun == null) {
|
|
11408
12010
|
subscriber.next(defaultValue);
|
|
@@ -11440,6 +12042,7 @@ function FontSizeSelectorMenuItemFactory(accessor) {
|
|
|
11440
12042
|
const DEFAULT_SIZE = _univerjs_core.DEFAULT_STYLES.fs;
|
|
11441
12043
|
const calc = () => {
|
|
11442
12044
|
var _textRun$ts8;
|
|
12045
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11443
12046
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11444
12047
|
if (textRun == null) {
|
|
11445
12048
|
subscriber.next(DEFAULT_SIZE);
|
|
@@ -11483,6 +12086,7 @@ function HeadingSelectorMenuItemFactory(accessor) {
|
|
|
11483
12086
|
const DEFAULT_TYPE = _univerjs_core.NamedStyleType.NORMAL_TEXT;
|
|
11484
12087
|
const calc = () => {
|
|
11485
12088
|
var _paragraph$paragraphS, _paragraph$paragraphS2;
|
|
12089
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11486
12090
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
11487
12091
|
if (paragraph == null) {
|
|
11488
12092
|
subscriber.next(DEFAULT_TYPE);
|
|
@@ -11573,6 +12177,7 @@ function FloatTextStyleMenuItemFactory(accessor) {
|
|
|
11573
12177
|
selections: FLOAT_TEXT_STYLE_OPTIONS,
|
|
11574
12178
|
value$: new rxjs.Observable((subscriber) => {
|
|
11575
12179
|
const calc = () => {
|
|
12180
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11576
12181
|
subscriber.next(normalizeFloatingTextStyleValue(getParagraphStyleAtCursor(accessor)));
|
|
11577
12182
|
};
|
|
11578
12183
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
@@ -11604,6 +12209,7 @@ function TextColorSelectorMenuItemFactory(accessor) {
|
|
|
11604
12209
|
const defaultValue = _univerjs_core.DEFAULT_STYLES.cl.rgb;
|
|
11605
12210
|
const calc = () => {
|
|
11606
12211
|
var _textRun$ts9;
|
|
12212
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11607
12213
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11608
12214
|
if (!textRun) {
|
|
11609
12215
|
subscriber.next(defaultValue);
|
|
@@ -11623,6 +12229,7 @@ function TextColorSelectorMenuItemFactory(accessor) {
|
|
|
11623
12229
|
const defaultColor = themeService.getColorFromTheme("gray.900");
|
|
11624
12230
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
11625
12231
|
if (c.id === SetInlineFormatTextColorCommand.id) {
|
|
12232
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11626
12233
|
const color = c.params.value;
|
|
11627
12234
|
subscriber.next(color !== null && color !== void 0 ? color : defaultColor);
|
|
11628
12235
|
}
|
|
@@ -11695,6 +12302,7 @@ function AlignLeftMenuItemFactory(accessor) {
|
|
|
11695
12302
|
const id = c.id;
|
|
11696
12303
|
if (id === _univerjs_docs.SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
|
|
11697
12304
|
var _paragraph$paragraphS5;
|
|
12305
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11698
12306
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
11699
12307
|
if (paragraph == null) return;
|
|
11700
12308
|
const alignType = (_paragraph$paragraphS5 = paragraph.paragraphStyle) === null || _paragraph$paragraphS5 === void 0 ? void 0 : _paragraph$paragraphS5.horizontalAlign;
|
|
@@ -11719,6 +12327,7 @@ function AlignCenterMenuItemFactory(accessor) {
|
|
|
11719
12327
|
const id = c.id;
|
|
11720
12328
|
if (id === _univerjs_docs.SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
|
|
11721
12329
|
var _paragraph$paragraphS6;
|
|
12330
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11722
12331
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
11723
12332
|
if (paragraph == null) return;
|
|
11724
12333
|
const alignType = (_paragraph$paragraphS6 = paragraph.paragraphStyle) === null || _paragraph$paragraphS6 === void 0 ? void 0 : _paragraph$paragraphS6.horizontalAlign;
|
|
@@ -11744,6 +12353,7 @@ function AlignRightMenuItemFactory(accessor) {
|
|
|
11744
12353
|
const id = c.id;
|
|
11745
12354
|
if (id === _univerjs_docs.SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
|
|
11746
12355
|
var _paragraph$paragraphS7;
|
|
12356
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11747
12357
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
11748
12358
|
if (paragraph == null) return;
|
|
11749
12359
|
const alignType = (_paragraph$paragraphS7 = paragraph.paragraphStyle) === null || _paragraph$paragraphS7 === void 0 ? void 0 : _paragraph$paragraphS7.horizontalAlign;
|
|
@@ -11769,6 +12379,7 @@ function AlignJustifyMenuItemFactory(accessor) {
|
|
|
11769
12379
|
const id = c.id;
|
|
11770
12380
|
if (id === _univerjs_docs.SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
|
|
11771
12381
|
var _paragraph$paragraphS8;
|
|
12382
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11772
12383
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
11773
12384
|
if (paragraph == null) return;
|
|
11774
12385
|
const alignType = (_paragraph$paragraphS8 = paragraph.paragraphStyle) === null || _paragraph$paragraphS8 === void 0 ? void 0 : _paragraph$paragraphS8.horizontalAlign;
|
|
@@ -11813,6 +12424,10 @@ function AlignMenuItemFactory(accessor) {
|
|
|
11813
12424
|
const value$ = new rxjs.Observable((subscriber) => {
|
|
11814
12425
|
const calc = () => {
|
|
11815
12426
|
var _paragraph$paragraphS9, _paragraph$paragraphS10;
|
|
12427
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) {
|
|
12428
|
+
subscriber.next(_univerjs_core.HorizontalAlign.LEFT);
|
|
12429
|
+
return;
|
|
12430
|
+
}
|
|
11816
12431
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
11817
12432
|
subscriber.next((_paragraph$paragraphS9 = paragraph === null || paragraph === void 0 || (_paragraph$paragraphS10 = paragraph.paragraphStyle) === null || _paragraph$paragraphS10 === void 0 ? void 0 : _paragraph$paragraphS10.horizontalAlign) !== null && _paragraph$paragraphS9 !== void 0 ? _paragraph$paragraphS9 : _univerjs_core.HorizontalAlign.LEFT);
|
|
11818
12433
|
};
|
|
@@ -11852,6 +12467,7 @@ const listValueFactory$ = (accessor) => {
|
|
|
11852
12467
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
11853
12468
|
const subscription = univerInstanceService.focused$.subscribe((unitId) => {
|
|
11854
12469
|
var _docRanges$find;
|
|
12470
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11855
12471
|
if (unitId == null) return;
|
|
11856
12472
|
const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
11857
12473
|
if (docDataModel == null) return;
|
|
@@ -11931,30 +12547,6 @@ function CheckListMenuItemFactory(accessor) {
|
|
|
11931
12547
|
activated$: listValueFactory$(accessor).pipe((0, rxjs.map)((v) => Boolean(v && v.indexOf("CHECK_LIST") === 0)))
|
|
11932
12548
|
};
|
|
11933
12549
|
}
|
|
11934
|
-
function DocSwitchModeMenuItemFactory(accessor) {
|
|
11935
|
-
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
11936
|
-
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
11937
|
-
return {
|
|
11938
|
-
id: SwitchDocModeCommand.id,
|
|
11939
|
-
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
11940
|
-
icon: "KeyboardIcon",
|
|
11941
|
-
tooltip: "docs-ui.toolbar.documentFlavor",
|
|
11942
|
-
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC),
|
|
11943
|
-
activated$: new rxjs.Observable((subscriber) => {
|
|
11944
|
-
var _instance$getSnapshot2;
|
|
11945
|
-
const subscription = commandService.onCommandExecuted((c) => {
|
|
11946
|
-
if (c.id === _univerjs_docs.RichTextEditingMutation.id) {
|
|
11947
|
-
var _instance$getSnapshot;
|
|
11948
|
-
const instance = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
11949
|
-
subscriber.next((instance === null || instance === void 0 || (_instance$getSnapshot = instance.getSnapshot()) === null || _instance$getSnapshot === void 0 ? void 0 : _instance$getSnapshot.documentStyle.documentFlavor) === _univerjs_core.DocumentFlavor.MODERN);
|
|
11950
|
-
}
|
|
11951
|
-
});
|
|
11952
|
-
const instance = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
11953
|
-
subscriber.next((instance === null || instance === void 0 || (_instance$getSnapshot2 = instance.getSnapshot()) === null || _instance$getSnapshot2 === void 0 ? void 0 : _instance$getSnapshot2.documentStyle.documentFlavor) === _univerjs_core.DocumentFlavor.MODERN);
|
|
11954
|
-
return () => subscription.dispose();
|
|
11955
|
-
})
|
|
11956
|
-
};
|
|
11957
|
-
}
|
|
11958
12550
|
function ResetTextColorMenuItemFactory(accessor) {
|
|
11959
12551
|
return {
|
|
11960
12552
|
id: ResetInlineFormatTextColorCommand.id,
|
|
@@ -11989,6 +12581,7 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
|
|
|
11989
12581
|
const defaultValue = themeService.getColorFromTheme("primary.600");
|
|
11990
12582
|
const calc = () => {
|
|
11991
12583
|
var _textRun$ts10;
|
|
12584
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
11992
12585
|
const textRun = getFontStyleAtCursor(accessor);
|
|
11993
12586
|
if (!textRun) {
|
|
11994
12587
|
subscriber.next(defaultValue);
|
|
@@ -12008,6 +12601,7 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
|
|
|
12008
12601
|
const defaultColor = themeService.getColorFromTheme("primary.600");
|
|
12009
12602
|
const disposable = commandService.onCommandExecuted((c) => {
|
|
12010
12603
|
if (c.id === SetInlineFormatTextBackgroundColorCommand.id) {
|
|
12604
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
12011
12605
|
const color = c.params.value;
|
|
12012
12606
|
subscriber.next(color !== null && color !== void 0 ? color : defaultColor);
|
|
12013
12607
|
}
|
|
@@ -12021,9 +12615,18 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
|
|
|
12021
12615
|
}
|
|
12022
12616
|
function getFontStyleAtCursor(accessor) {
|
|
12023
12617
|
var _docRanges$find2, _docMenuStyleService$, _paragraph$paragraphS11, _paragraph$paragraphS12, _docDataModel$getSelf;
|
|
12024
|
-
|
|
12025
|
-
|
|
12026
|
-
|
|
12618
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
12619
|
+
let univerInstanceService;
|
|
12620
|
+
let textSelectionService;
|
|
12621
|
+
let docMenuStyleService;
|
|
12622
|
+
try {
|
|
12623
|
+
univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
12624
|
+
textSelectionService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
12625
|
+
docMenuStyleService = accessor.get(DocMenuStyleService);
|
|
12626
|
+
} catch (error) {
|
|
12627
|
+
if (isInjectorDisposedError(error)) return;
|
|
12628
|
+
throw error;
|
|
12629
|
+
}
|
|
12027
12630
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
12028
12631
|
const docRanges = textSelectionService.getDocRanges();
|
|
12029
12632
|
const activeRange = (_docRanges$find2 = docRanges.find((r) => r.isActive)) !== null && _docRanges$find2 !== void 0 ? _docRanges$find2 : docRanges[0];
|
|
@@ -12054,8 +12657,16 @@ function getFontStyleAtCursor(accessor) {
|
|
|
12054
12657
|
}
|
|
12055
12658
|
function getParagraphStyleAtCursor(accessor) {
|
|
12056
12659
|
var _docRanges$find3, _docDataModel$getSelf2;
|
|
12057
|
-
|
|
12058
|
-
|
|
12660
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
12661
|
+
let univerInstanceService;
|
|
12662
|
+
let textSelectionService;
|
|
12663
|
+
try {
|
|
12664
|
+
univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
12665
|
+
textSelectionService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
12666
|
+
} catch (error) {
|
|
12667
|
+
if (isInjectorDisposedError(error)) return;
|
|
12668
|
+
throw error;
|
|
12669
|
+
}
|
|
12059
12670
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
12060
12671
|
const docRanges = textSelectionService.getDocRanges();
|
|
12061
12672
|
const activeRange = (_docRanges$find3 = docRanges.find((r) => r.isActive)) !== null && _docRanges$find3 !== void 0 ? _docRanges$find3 : docRanges[0];
|
|
@@ -12071,6 +12682,10 @@ function getParagraphStyleAtCursor(accessor) {
|
|
|
12071
12682
|
}
|
|
12072
12683
|
return null;
|
|
12073
12684
|
}
|
|
12685
|
+
function isInjectorDisposedError(error) {
|
|
12686
|
+
if (!(error instanceof Error)) return false;
|
|
12687
|
+
return error.name === "InjectorAlreadyDisposedError" || error.message.includes("Injector cannot be accessed after it was disposed");
|
|
12688
|
+
}
|
|
12074
12689
|
function PageSettingMenuItemFactory(accessor) {
|
|
12075
12690
|
return {
|
|
12076
12691
|
id: DocOpenPageSettingCommand.id,
|
|
@@ -12135,6 +12750,7 @@ function getHeadingActivatedObservable(accessor, headingType) {
|
|
|
12135
12750
|
const DEFAULT_TYPE = _univerjs_core.NamedStyleType.NORMAL_TEXT;
|
|
12136
12751
|
const calc = () => {
|
|
12137
12752
|
var _paragraph$paragraphS, _paragraph$paragraphS2;
|
|
12753
|
+
if (shouldSuppressDocMenuStateRefresh(accessor)) return;
|
|
12138
12754
|
const paragraph = getParagraphStyleAtCursor(accessor);
|
|
12139
12755
|
if (paragraph == null) {
|
|
12140
12756
|
subscriber.next(DEFAULT_TYPE === headingType);
|
|
@@ -12586,7 +13202,7 @@ function ParagraphMenuIndentIncreaseMenuItemFactory(accessor) {
|
|
|
12586
13202
|
return {
|
|
12587
13203
|
id: DOC_PARAGRAPH_T_INDENT_INCREASE_ID,
|
|
12588
13204
|
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
12589
|
-
icon: "
|
|
13205
|
+
icon: "LineIndentIncreaseIcon",
|
|
12590
13206
|
title: "docs-ui.paragraphMenu.increase",
|
|
12591
13207
|
tooltip: "docs-ui.paragraphMenu.increaseIndent",
|
|
12592
13208
|
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC)
|
|
@@ -12596,7 +13212,7 @@ function ParagraphMenuIndentDecreaseMenuItemFactory(accessor) {
|
|
|
12596
13212
|
return {
|
|
12597
13213
|
id: DOC_PARAGRAPH_T_INDENT_DECREASE_ID,
|
|
12598
13214
|
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
12599
|
-
icon: "
|
|
13215
|
+
icon: "LineIndentDecreaseIcon",
|
|
12600
13216
|
title: "docs-ui.paragraphMenu.decrease",
|
|
12601
13217
|
tooltip: "docs-ui.paragraphMenu.decreaseIndent",
|
|
12602
13218
|
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC)
|
|
@@ -12734,10 +13350,6 @@ const menuSchema = {
|
|
|
12734
13350
|
order: 10,
|
|
12735
13351
|
menuItemFactory: HeaderFooterMenuItemFactory
|
|
12736
13352
|
},
|
|
12737
|
-
[SwitchDocModeCommand.id]: {
|
|
12738
|
-
order: 11,
|
|
12739
|
-
menuItemFactory: DocSwitchModeMenuItemFactory
|
|
12740
|
-
},
|
|
12741
13353
|
[DocOpenPageSettingCommand.id]: {
|
|
12742
13354
|
order: 12,
|
|
12743
13355
|
menuItemFactory: PageSettingMenuItemFactory
|
|
@@ -12786,6 +13398,10 @@ const menuSchema = {
|
|
|
12786
13398
|
order: 0,
|
|
12787
13399
|
menuItemFactory: ParagraphSettingMenuFactory
|
|
12788
13400
|
},
|
|
13401
|
+
[DocSectionSettingPanelOperation.id]: {
|
|
13402
|
+
order: 1,
|
|
13403
|
+
menuItemFactory: SectionSettingMenuFactory
|
|
13404
|
+
},
|
|
12789
13405
|
[TABLE_INSERT_MENU_ID]: {
|
|
12790
13406
|
order: 1,
|
|
12791
13407
|
menuItemFactory: TableInsertMenuItemFactory,
|
|
@@ -12878,6 +13494,10 @@ const menuSchema = {
|
|
|
12878
13494
|
order: 0,
|
|
12879
13495
|
menuItemFactory: ParagraphSettingMenuFactory
|
|
12880
13496
|
},
|
|
13497
|
+
[DocSectionSettingPanelOperation.id]: {
|
|
13498
|
+
order: 1,
|
|
13499
|
+
menuItemFactory: SectionSettingMenuFactory
|
|
13500
|
+
},
|
|
12881
13501
|
[INSERT_BELLOW_MENU_ID]: {
|
|
12882
13502
|
order: 1,
|
|
12883
13503
|
menuItemFactory: DocInsertBellowMenuItemFactory,
|
|
@@ -12991,6 +13611,10 @@ const menuSchema = {
|
|
|
12991
13611
|
order: 0,
|
|
12992
13612
|
menuItemFactory: ParagraphSettingMenuFactory
|
|
12993
13613
|
},
|
|
13614
|
+
[DocSectionSettingPanelOperation.id]: {
|
|
13615
|
+
order: 1,
|
|
13616
|
+
menuItemFactory: SectionSettingMenuFactory
|
|
13617
|
+
},
|
|
12994
13618
|
[BulletListCommand.id]: {
|
|
12995
13619
|
order: 1,
|
|
12996
13620
|
menuItemFactory: EmptyParagraphBulletListMenuItemFactory
|
|
@@ -13623,6 +14247,11 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
13623
14247
|
this._univerInstanceService = _univerInstanceService;
|
|
13624
14248
|
this._commandService = _commandService;
|
|
13625
14249
|
}
|
|
14250
|
+
_shouldUpdateForCommand(commandInfo, unitId) {
|
|
14251
|
+
if (commandInfo.id !== SetDocZoomRatioOperation.id && commandInfo.id !== _univerjs_docs.RichTextEditingMutation.id) return false;
|
|
14252
|
+
const params = commandInfo.params;
|
|
14253
|
+
return (params === null || params === void 0 ? void 0 : params.unitId) == null || params.unitId === unitId;
|
|
14254
|
+
}
|
|
13626
14255
|
_createRectPositionObserver(rect, currentRender) {
|
|
13627
14256
|
const calc = () => {
|
|
13628
14257
|
const { scene, engine } = currentRender;
|
|
@@ -13645,20 +14274,21 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
13645
14274
|
if (position == null) throw new Error(`Current render canvas not found, unitId: ${currentRender.unitId}`);
|
|
13646
14275
|
const position$ = new rxjs.BehaviorSubject(position);
|
|
13647
14276
|
const disposable = new _univerjs_core.DisposableCollection();
|
|
13648
|
-
|
|
13649
|
-
|
|
14277
|
+
const updatePosition = () => {
|
|
14278
|
+
try {
|
|
13650
14279
|
const newPosition = calc();
|
|
13651
14280
|
if (newPosition) position$.next(newPosition);
|
|
13652
|
-
}
|
|
14281
|
+
} catch {}
|
|
14282
|
+
};
|
|
14283
|
+
disposable.add(this._commandService.onCommandExecuted((commandInfo) => {
|
|
14284
|
+
if (this._shouldUpdateForCommand(commandInfo, currentRender.unitId)) updatePosition();
|
|
13653
14285
|
}));
|
|
13654
14286
|
const viewMain = currentRender.scene.getViewport("viewMain");
|
|
13655
14287
|
if (viewMain) disposable.add(viewMain.onScrollAfter$.subscribeEvent(() => {
|
|
13656
|
-
|
|
13657
|
-
if (newPosition) position$.next(newPosition);
|
|
14288
|
+
updatePosition();
|
|
13658
14289
|
}));
|
|
13659
14290
|
disposable.add(currentRender.scene.onTransformChange$.subscribeEvent(() => {
|
|
13660
|
-
|
|
13661
|
-
if (newPosition) position$.next(newPosition);
|
|
14291
|
+
updatePosition();
|
|
13662
14292
|
}));
|
|
13663
14293
|
return {
|
|
13664
14294
|
position,
|
|
@@ -13709,11 +14339,13 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
13709
14339
|
attachPopupToRect(rect, popup, unitId) {
|
|
13710
14340
|
const currentRender = this._renderManagerService.getRenderById(unitId);
|
|
13711
14341
|
if (!currentRender) throw new Error(`Current render not found, unitId: ${unitId}`);
|
|
14342
|
+
const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
|
|
13712
14343
|
const { position, position$, disposable } = this._createRectPositionObserver(rect, currentRender);
|
|
13713
14344
|
const id = this._globalPopupManagerService.addPopup({
|
|
13714
14345
|
...popup,
|
|
13715
14346
|
unitId,
|
|
13716
14347
|
subUnitId: "default",
|
|
14348
|
+
connectorInjector: popupInjector,
|
|
13717
14349
|
anchorRect: position,
|
|
13718
14350
|
anchorRect$: position$,
|
|
13719
14351
|
canvasElement: currentRender.engine.getCanvasElement()
|
|
@@ -13736,11 +14368,13 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
13736
14368
|
attachPopupToObject(targetObject, popup, unitId) {
|
|
13737
14369
|
const currentRender = this._renderManagerService.getRenderById(unitId);
|
|
13738
14370
|
if (!currentRender) throw new Error(`Current render not found, unitId: ${unitId}`);
|
|
14371
|
+
const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
|
|
13739
14372
|
const { position, position$, disposable } = this._createObjectPositionObserver(targetObject, currentRender);
|
|
13740
14373
|
const id = this._globalPopupManagerService.addPopup({
|
|
13741
14374
|
...popup,
|
|
13742
14375
|
unitId,
|
|
13743
14376
|
subUnitId: "default",
|
|
14377
|
+
connectorInjector: popupInjector,
|
|
13744
14378
|
anchorRect: position,
|
|
13745
14379
|
anchorRect$: position$,
|
|
13746
14380
|
canvasElement: currentRender.engine.getCanvasElement()
|
|
@@ -13766,12 +14400,14 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
13766
14400
|
const { direction = "top", multipleDirection } = popup;
|
|
13767
14401
|
const currentRender = this._renderManagerService.getRenderById(unitId);
|
|
13768
14402
|
if (!currentRender) throw new Error(`Current render not found, unitId: ${unitId}`);
|
|
14403
|
+
const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
|
|
13769
14404
|
const { positions: bounds, positions$: bounds$, disposable } = this._createRangePositionObserver(range, currentRender);
|
|
13770
14405
|
const position$ = bounds$.pipe((0, rxjs.map)((bounds) => direction.includes("top") ? bounds[0] : bounds[bounds.length - 1]));
|
|
13771
14406
|
const id = this._globalPopupManagerService.addPopup({
|
|
13772
14407
|
...popup,
|
|
13773
14408
|
unitId,
|
|
13774
14409
|
subUnitId: "default",
|
|
14410
|
+
connectorInjector: popupInjector,
|
|
13775
14411
|
anchorRect: direction.includes("top") ? bounds[0] : bounds[bounds.length - 1],
|
|
13776
14412
|
anchorRect$: position$,
|
|
13777
14413
|
excludeRects: bounds,
|
|
@@ -13792,6 +14428,10 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
13792
14428
|
canDispose: () => this._globalPopupManagerService.activePopupId !== id
|
|
13793
14429
|
};
|
|
13794
14430
|
}
|
|
14431
|
+
_resolveEmbeddedPopupInjector(unitId, currentRender) {
|
|
14432
|
+
var _this$_univerInstance, _currentRender$getInj;
|
|
14433
|
+
return ((_this$_univerInstance = this._univerInstanceService.getUnitCreateOptions(unitId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.embeddedRender) === true ? (_currentRender$getInj = currentRender.getInjector) === null || _currentRender$getInj === void 0 ? void 0 : _currentRender$getInj.call(currentRender) : void 0;
|
|
14434
|
+
}
|
|
13795
14435
|
};
|
|
13796
14436
|
DocCanvasPopManagerService = __decorate([
|
|
13797
14437
|
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ICanvasPopupService)),
|
|
@@ -14514,10 +15154,6 @@ function clipRectHorizontally(rect, visibleLeft, visibleRight) {
|
|
|
14514
15154
|
|
|
14515
15155
|
//#endregion
|
|
14516
15156
|
//#region src/views/SideMenu.tsx
|
|
14517
|
-
const commonClass = "univer-font-[500] univer-truncate univer-h-[24px] univer-mb-2 univer-leading-[24px] univer-cursor-pointer univer-pr-1 ";
|
|
14518
|
-
const titleClass = "univer-text-base univer-font-semibold";
|
|
14519
|
-
const h1Class = "univer-text-sm univer-font-semibold";
|
|
14520
|
-
const textClass = "univer-text-sm";
|
|
14521
15157
|
const SideMenu = (0, react.forwardRef)((props, ref) => {
|
|
14522
15158
|
const { menus, onClick, className, style, mode, maxHeight, activeId, open, onOpenChange, maxWidth, wrapperClass, wrapperStyle, iconClass, iconStyle } = props;
|
|
14523
15159
|
const isSideBar = mode === "side-bar";
|
|
@@ -14566,10 +15202,10 @@ const SideMenu = (0, react.forwardRef)((props, ref) => {
|
|
|
14566
15202
|
className: (0, _univerjs_design.clsx)("univer-flex-1 univer-overflow-y-auto univer-overflow-x-hidden", _univerjs_design.scrollbarClassName),
|
|
14567
15203
|
children: menus === null || menus === void 0 ? void 0 : menus.map((menu) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
14568
15204
|
id: `univer-side-menu-${menu.id}`,
|
|
14569
|
-
className: (0, _univerjs_design.clsx)(
|
|
14570
|
-
|
|
14571
|
-
|
|
14572
|
-
|
|
15205
|
+
className: (0, _univerjs_design.clsx)("univer-mb-2 univer-h-[24px] univer-cursor-pointer univer-truncate univer-pr-1 univer-font-[500] univer-leading-[24px]", {
|
|
15206
|
+
"univer-text-base univer-font-semibold": menu.isTitle,
|
|
15207
|
+
"univer-text-sm univer-font-semibold": menu.level === 1,
|
|
15208
|
+
"univer-text-sm": menu.level > 1,
|
|
14573
15209
|
"univer-text-gray-500 dark:!univer-text-gray-400": menu.id !== activeId,
|
|
14574
15210
|
"univer-text-gray-800 dark:!univer-text-gray-200": menu.id === activeId
|
|
14575
15211
|
}),
|
|
@@ -14750,7 +15386,7 @@ function DocSideMenuContent() {
|
|
|
14750
15386
|
* limitations under the License.
|
|
14751
15387
|
*/
|
|
14752
15388
|
let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
14753
|
-
constructor(_injector, _commandService, _layoutService, _menuManagerService, _uiPartsService, _univerInstanceService, _shortcutService, _configService) {
|
|
15389
|
+
constructor(_injector, _commandService, _layoutService, _menuManagerService, _uiPartsService, _univerInstanceService, _shortcutService, _configService, _embedInteractionBoundaryService, _embedRuntimeFocusCoordinator) {
|
|
14754
15390
|
super();
|
|
14755
15391
|
this._injector = _injector;
|
|
14756
15392
|
this._commandService = _commandService;
|
|
@@ -14760,6 +15396,7 @@ let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
|
14760
15396
|
this._univerInstanceService = _univerInstanceService;
|
|
14761
15397
|
this._shortcutService = _shortcutService;
|
|
14762
15398
|
this._configService = _configService;
|
|
15399
|
+
this._embedRuntimeFocusCoordinator = _embedRuntimeFocusCoordinator;
|
|
14763
15400
|
this._init();
|
|
14764
15401
|
}
|
|
14765
15402
|
_initUiParts() {
|
|
@@ -14805,9 +15442,15 @@ let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
|
14805
15442
|
}
|
|
14806
15443
|
_initFocusHandler() {
|
|
14807
15444
|
this.disposeWithMe(this._layoutService.registerFocusHandler(_univerjs_core.UniverInstanceType.UNIVER_DOC, (unitId) => {
|
|
15445
|
+
if (this._shouldPreserveEmbedFocus(unitId)) return;
|
|
14808
15446
|
this._injector.get(_univerjs_engine_render.IRenderManagerService).getRenderById(unitId).with(DocSelectionRenderService).focus();
|
|
14809
15447
|
}));
|
|
14810
15448
|
}
|
|
15449
|
+
_shouldPreserveEmbedFocus(unitId) {
|
|
15450
|
+
var _this$_embedRuntimeFo;
|
|
15451
|
+
if ((_this$_embedRuntimeFo = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo === void 0 ? void 0 : _this$_embedRuntimeFo.shouldSuppressHostInteraction(unitId)) return true;
|
|
15452
|
+
return false;
|
|
15453
|
+
}
|
|
14811
15454
|
};
|
|
14812
15455
|
DocUIController = __decorate([
|
|
14813
15456
|
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
@@ -14817,13 +15460,272 @@ DocUIController = __decorate([
|
|
|
14817
15460
|
__decorateParam(4, _univerjs_ui.IUIPartsService),
|
|
14818
15461
|
__decorateParam(5, _univerjs_core.IUniverInstanceService),
|
|
14819
15462
|
__decorateParam(6, _univerjs_ui.IShortcutService),
|
|
14820
|
-
__decorateParam(7, _univerjs_core.IConfigService)
|
|
15463
|
+
__decorateParam(7, _univerjs_core.IConfigService),
|
|
15464
|
+
__decorateParam(8, (0, _univerjs_core.Optional)(IDocEmbedInteractionBoundaryService)),
|
|
15465
|
+
__decorateParam(9, (0, _univerjs_core.Optional)(IDocEmbedRuntimeFocusCoordinator))
|
|
14821
15466
|
], DocUIController);
|
|
14822
15467
|
|
|
15468
|
+
//#endregion
|
|
15469
|
+
//#region src/embed-docs-custom-block-bleed.ts
|
|
15470
|
+
/**
|
|
15471
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
15472
|
+
*
|
|
15473
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15474
|
+
* you may not use this file except in compliance with the License.
|
|
15475
|
+
* You may obtain a copy of the License at
|
|
15476
|
+
*
|
|
15477
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15478
|
+
*
|
|
15479
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15480
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15481
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15482
|
+
* See the License for the specific language governing permissions and
|
|
15483
|
+
* limitations under the License.
|
|
15484
|
+
*/
|
|
15485
|
+
const DOCS_CUSTOM_BLOCK_VIEWPORT_INSET = 10;
|
|
15486
|
+
function createDefaultDocsTableLikeCustomBlockBleedViewport() {
|
|
15487
|
+
if (typeof window === "undefined") return {
|
|
15488
|
+
bleedLeft: 0,
|
|
15489
|
+
bleedRight: 0,
|
|
15490
|
+
bleedWidth: 1,
|
|
15491
|
+
contentWidth: 1,
|
|
15492
|
+
virtualWidth: 1
|
|
15493
|
+
};
|
|
15494
|
+
const bleedWidth = Math.max(1, window.innerWidth - DOCS_CUSTOM_BLOCK_VIEWPORT_INSET * 2);
|
|
15495
|
+
return {
|
|
15496
|
+
bleedLeft: 0,
|
|
15497
|
+
bleedRight: 0,
|
|
15498
|
+
bleedWidth,
|
|
15499
|
+
contentWidth: 1,
|
|
15500
|
+
virtualWidth: bleedWidth
|
|
15501
|
+
};
|
|
15502
|
+
}
|
|
15503
|
+
function resolveDocsTableLikeCustomBlockBleedViewport(root, contentWidth, hint) {
|
|
15504
|
+
const rootRect = root.getBoundingClientRect();
|
|
15505
|
+
const rootWidth = Math.max(1, rootRect.width);
|
|
15506
|
+
const normalizedContentWidth = Math.max(1, contentWidth);
|
|
15507
|
+
const hintedBleedLeft = hint === null || hint === void 0 ? void 0 : hint.bleedLeft;
|
|
15508
|
+
const hintedBleedWidth = hint === null || hint === void 0 ? void 0 : hint.bleedWidth;
|
|
15509
|
+
if (Number.isFinite(hintedBleedWidth) && (hintedBleedWidth !== null && hintedBleedWidth !== void 0 ? hintedBleedWidth : 0) > 0) {
|
|
15510
|
+
const bleedLeft = Math.max(0, hintedBleedLeft !== null && hintedBleedLeft !== void 0 ? hintedBleedLeft : 0);
|
|
15511
|
+
const bleedWidth = Math.max(1, hintedBleedWidth);
|
|
15512
|
+
return {
|
|
15513
|
+
bleedLeft,
|
|
15514
|
+
bleedRight: Math.max(0, bleedWidth - bleedLeft - rootWidth),
|
|
15515
|
+
bleedWidth,
|
|
15516
|
+
contentWidth: normalizedContentWidth,
|
|
15517
|
+
virtualWidth: Math.max(bleedWidth, bleedLeft + normalizedContentWidth)
|
|
15518
|
+
};
|
|
15519
|
+
}
|
|
15520
|
+
if (normalizedContentWidth <= rootWidth) return {
|
|
15521
|
+
bleedLeft: 0,
|
|
15522
|
+
bleedRight: 0,
|
|
15523
|
+
bleedWidth: rootWidth,
|
|
15524
|
+
contentWidth: normalizedContentWidth,
|
|
15525
|
+
virtualWidth: rootWidth
|
|
15526
|
+
};
|
|
15527
|
+
const bounds = resolveDocsTableLikeCustomBlockBleedBounds(root);
|
|
15528
|
+
const viewportLeft = bounds.left + DOCS_CUSTOM_BLOCK_VIEWPORT_INSET;
|
|
15529
|
+
const viewportWidth = Math.max(1, bounds.width - DOCS_CUSTOM_BLOCK_VIEWPORT_INSET * 2);
|
|
15530
|
+
const bleedLeft = Math.max(0, rootRect.left - viewportLeft);
|
|
15531
|
+
return {
|
|
15532
|
+
bleedLeft,
|
|
15533
|
+
bleedRight: Math.max(0, viewportLeft + viewportWidth - rootRect.right),
|
|
15534
|
+
bleedWidth: viewportWidth,
|
|
15535
|
+
contentWidth: normalizedContentWidth,
|
|
15536
|
+
virtualWidth: Math.max(viewportWidth, bleedLeft + normalizedContentWidth)
|
|
15537
|
+
};
|
|
15538
|
+
}
|
|
15539
|
+
function resolveDocsTableLikeCustomBlockContentWidth(authoritativeContentWidth, fallbackContentWidth) {
|
|
15540
|
+
return Number.isFinite(authoritativeContentWidth) && (authoritativeContentWidth !== null && authoritativeContentWidth !== void 0 ? authoritativeContentWidth : 0) > 0 ? authoritativeContentWidth : Math.max(1, fallbackContentWidth);
|
|
15541
|
+
}
|
|
15542
|
+
function resolveDocsTableLikeCustomBlockContentHeight(authoritativeContentHeight, fallbackContentHeight) {
|
|
15543
|
+
return Number.isFinite(authoritativeContentHeight) && (authoritativeContentHeight !== null && authoritativeContentHeight !== void 0 ? authoritativeContentHeight : 0) > 0 ? authoritativeContentHeight : Math.max(1, fallbackContentHeight);
|
|
15544
|
+
}
|
|
15545
|
+
function resolveDocsTableLikeCustomBlockBleedBounds(root) {
|
|
15546
|
+
const clippingAncestor = findClippingAncestor(root);
|
|
15547
|
+
if (clippingAncestor) {
|
|
15548
|
+
const rect = clippingAncestor.getBoundingClientRect();
|
|
15549
|
+
if (Number.isFinite(rect.width) && rect.width > 0) return {
|
|
15550
|
+
left: rect.left,
|
|
15551
|
+
width: rect.width
|
|
15552
|
+
};
|
|
15553
|
+
}
|
|
15554
|
+
return {
|
|
15555
|
+
left: 0,
|
|
15556
|
+
width: typeof window === "undefined" ? 1 : Math.max(1, window.innerWidth)
|
|
15557
|
+
};
|
|
15558
|
+
}
|
|
15559
|
+
function findClippingAncestor(root) {
|
|
15560
|
+
let current = root.parentElement;
|
|
15561
|
+
while (current && current !== document.body && current !== document.documentElement) {
|
|
15562
|
+
if (clipsOverflow(current)) return current;
|
|
15563
|
+
current = current.parentElement;
|
|
15564
|
+
}
|
|
15565
|
+
return null;
|
|
15566
|
+
}
|
|
15567
|
+
function clipsOverflow(element) {
|
|
15568
|
+
const style = window.getComputedStyle(element);
|
|
15569
|
+
return hasClippingOverflow(style.overflow) || hasClippingOverflow(style.overflowX) || hasClippingOverflow(style.overflowY);
|
|
15570
|
+
}
|
|
15571
|
+
function hasClippingOverflow(value) {
|
|
15572
|
+
return value === "hidden" || value === "auto" || value === "scroll" || value === "clip";
|
|
15573
|
+
}
|
|
15574
|
+
|
|
15575
|
+
//#endregion
|
|
15576
|
+
//#region src/embed-docs-custom-block-refresh.ts
|
|
15577
|
+
function collectDocsTableLikeEmbedChildUnitIds(drawings, resolveChildUnitId) {
|
|
15578
|
+
const childUnitIds = /* @__PURE__ */ new Set();
|
|
15579
|
+
Object.values(drawings !== null && drawings !== void 0 ? drawings : {}).forEach((drawing) => {
|
|
15580
|
+
var _resolveChildUnitId;
|
|
15581
|
+
const data = getDrawingData(drawing);
|
|
15582
|
+
const childUnitId = data ? (_resolveChildUnitId = resolveChildUnitId === null || resolveChildUnitId === void 0 ? void 0 : resolveChildUnitId(data)) !== null && _resolveChildUnitId !== void 0 ? _resolveChildUnitId : typeof data.childUnitId === "string" ? data.childUnitId : void 0 : void 0;
|
|
15583
|
+
const childType = typeof (data === null || data === void 0 ? void 0 : data.childType) === "number" ? data.childType : void 0;
|
|
15584
|
+
if (!childUnitId || !(0, _univerjs_docs.isSheetLikeDocsCustomBlockChildType)(childType)) return;
|
|
15585
|
+
childUnitIds.add(childUnitId);
|
|
15586
|
+
});
|
|
15587
|
+
return childUnitIds;
|
|
15588
|
+
}
|
|
15589
|
+
function getDrawingData(drawing) {
|
|
15590
|
+
if (!drawing || typeof drawing !== "object") return;
|
|
15591
|
+
const data = drawing.data;
|
|
15592
|
+
return data && typeof data === "object" ? data : void 0;
|
|
15593
|
+
}
|
|
15594
|
+
function getCommandUnitId(commandParams) {
|
|
15595
|
+
if (!commandParams || typeof commandParams !== "object") return;
|
|
15596
|
+
const params = commandParams;
|
|
15597
|
+
if (typeof params.unitId === "string") return params.unitId;
|
|
15598
|
+
return typeof params.unitID === "string" ? params.unitID : void 0;
|
|
15599
|
+
}
|
|
15600
|
+
function shouldRefreshDocsCustomBlockSizeForCommand(params) {
|
|
15601
|
+
if (params.commandId && isDocsCustomBlockLayoutNeutralCommand(params.commandId)) return false;
|
|
15602
|
+
const commandUnitId = getCommandUnitId(params.commandParams);
|
|
15603
|
+
return Boolean(commandUnitId && commandUnitId !== params.hostUnitId && params.childUnitIds.has(commandUnitId));
|
|
15604
|
+
}
|
|
15605
|
+
const DOCS_CUSTOM_BLOCK_LAYOUT_NEUTRAL_COMMAND_IDS = /* @__PURE__ */ new Set([
|
|
15606
|
+
"sheet.command.expand-selection",
|
|
15607
|
+
"sheet.command.move-selection",
|
|
15608
|
+
"sheet.operation.scroll-to-cell",
|
|
15609
|
+
"sheet.operation.scroll-to-range",
|
|
15610
|
+
"sheet.operation.set-activate-cell-edit",
|
|
15611
|
+
"sheet.operation.set-cell-edit-visible",
|
|
15612
|
+
"sheet.operation.set-cell-edit-visible-arrow",
|
|
15613
|
+
"sheet.operation.set-cell-edit-visible-f2",
|
|
15614
|
+
"sheet.operation.set-format-painter",
|
|
15615
|
+
"sheet.operation.set-scroll",
|
|
15616
|
+
"sheet.operation.set-selections",
|
|
15617
|
+
"sheet.operation.set-zoom-ratio"
|
|
15618
|
+
]);
|
|
15619
|
+
function isDocsCustomBlockLayoutNeutralCommand(commandId) {
|
|
15620
|
+
return DOCS_CUSTOM_BLOCK_LAYOUT_NEUTRAL_COMMAND_IDS.has(commandId);
|
|
15621
|
+
}
|
|
15622
|
+
function createDocsCustomBlockSizeRefreshScheduler(refresh) {
|
|
15623
|
+
let pendingFrame;
|
|
15624
|
+
return {
|
|
15625
|
+
dispose: () => {
|
|
15626
|
+
if (pendingFrame == null) return;
|
|
15627
|
+
window.cancelAnimationFrame(pendingFrame);
|
|
15628
|
+
pendingFrame = void 0;
|
|
15629
|
+
},
|
|
15630
|
+
schedule: () => {
|
|
15631
|
+
if (pendingFrame != null) return;
|
|
15632
|
+
pendingFrame = window.requestAnimationFrame(() => {
|
|
15633
|
+
pendingFrame = void 0;
|
|
15634
|
+
refresh();
|
|
15635
|
+
});
|
|
15636
|
+
}
|
|
15637
|
+
};
|
|
15638
|
+
}
|
|
15639
|
+
|
|
15640
|
+
//#endregion
|
|
15641
|
+
//#region src/embed-docs-custom-block-scroll.ts
|
|
15642
|
+
function scrollDocsTableLikeCustomBlockLive(event, live, options = {}) {
|
|
15643
|
+
if (event.defaultPrevented || event.ctrlKey || event.metaKey) return false;
|
|
15644
|
+
const deltaX = event.deltaX || (event.shiftKey ? event.deltaY : 0);
|
|
15645
|
+
const deltaY = event.shiftKey ? 0 : event.deltaY;
|
|
15646
|
+
const previousLeft = live.scrollLeft;
|
|
15647
|
+
const previousTop = live.scrollTop;
|
|
15648
|
+
const maxScrollLeft = resolveMaxScrollLeft(live, options.maxScrollLeft);
|
|
15649
|
+
if (deltaX && canScrollX(live, deltaX, maxScrollLeft)) live.scrollLeft = clampScroll(previousLeft + deltaX, 0, maxScrollLeft);
|
|
15650
|
+
if (deltaY && canScrollY(live, deltaY)) live.scrollTop = clampScroll(previousTop + deltaY, 0, live.scrollHeight - live.clientHeight);
|
|
15651
|
+
return live.scrollLeft !== previousLeft || live.scrollTop !== previousTop;
|
|
15652
|
+
}
|
|
15653
|
+
function canScrollX(element, deltaX, maxScrollLeft) {
|
|
15654
|
+
return element.scrollWidth > element.clientWidth && (deltaX < 0 ? element.scrollLeft > 0 : element.scrollLeft < maxScrollLeft);
|
|
15655
|
+
}
|
|
15656
|
+
function canScrollY(element, deltaY) {
|
|
15657
|
+
return element.scrollHeight > element.clientHeight && (deltaY < 0 ? element.scrollTop > 0 : element.scrollTop + element.clientHeight < element.scrollHeight);
|
|
15658
|
+
}
|
|
15659
|
+
function clampScroll(value, min, max) {
|
|
15660
|
+
return Math.max(min, Math.min(max, value));
|
|
15661
|
+
}
|
|
15662
|
+
function resolveMaxScrollLeft(element, requestedMaxScrollLeft) {
|
|
15663
|
+
const nativeMaxScrollLeft = Math.max(0, element.scrollWidth - element.clientWidth);
|
|
15664
|
+
if (!Number.isFinite(requestedMaxScrollLeft)) return nativeMaxScrollLeft;
|
|
15665
|
+
return clampScroll(requestedMaxScrollLeft !== null && requestedMaxScrollLeft !== void 0 ? requestedMaxScrollLeft : nativeMaxScrollLeft, 0, nativeMaxScrollLeft);
|
|
15666
|
+
}
|
|
15667
|
+
|
|
15668
|
+
//#endregion
|
|
15669
|
+
//#region src/embed-host-anchor.ts
|
|
15670
|
+
const MODERN_DOCS_CUSTOM_BLOCK_VIEWPORT_INSET = 10;
|
|
15671
|
+
function resolveDocsCustomBlockRenderViewport(params) {
|
|
15672
|
+
var _params$fallbackWidth, _params$fallbackHeigh, _params$contentHeight, _params$visibleCanvas, _params$pageMarginLef, _params$pageMarginRig, _params$contentWidth, _params$docsLeft, _params$visibleCanvas2;
|
|
15673
|
+
const defaultSize = (0, _univerjs_docs.resolveDocsCustomBlockSize)(params.childType);
|
|
15674
|
+
const fallbackWidth = (_params$fallbackWidth = params.fallbackWidth) !== null && _params$fallbackWidth !== void 0 ? _params$fallbackWidth : defaultSize.width;
|
|
15675
|
+
const fallbackHeight = (_params$fallbackHeigh = params.fallbackHeight) !== null && _params$fallbackHeigh !== void 0 ? _params$fallbackHeigh : defaultSize.height;
|
|
15676
|
+
const sheetLike = (0, _univerjs_docs.isSheetLikeDocsCustomBlockChildType)(params.childType);
|
|
15677
|
+
const contentHeight = Number.isFinite(params.contentHeight) && ((_params$contentHeight = params.contentHeight) !== null && _params$contentHeight !== void 0 ? _params$contentHeight : 0) > 0 ? params.contentHeight : fallbackHeight;
|
|
15678
|
+
const visibleCanvasHeight = Number.isFinite(params.visibleCanvasHeight) && ((_params$visibleCanvas = params.visibleCanvasHeight) !== null && _params$visibleCanvas !== void 0 ? _params$visibleCanvas : 0) > 0 ? params.visibleCanvasHeight : void 0;
|
|
15679
|
+
const height = sheetLike ? contentHeight : fallbackHeight;
|
|
15680
|
+
const viewportHeight = sheetLike && visibleCanvasHeight != null ? Math.min(contentHeight, visibleCanvasHeight) : height;
|
|
15681
|
+
if (!sheetLike) return {
|
|
15682
|
+
height,
|
|
15683
|
+
width: fallbackWidth
|
|
15684
|
+
};
|
|
15685
|
+
const pageWidth = params.pageWidth;
|
|
15686
|
+
const pageMarginLeft = (_params$pageMarginLef = params.pageMarginLeft) !== null && _params$pageMarginLef !== void 0 ? _params$pageMarginLef : 0;
|
|
15687
|
+
const pageMarginRight = (_params$pageMarginRig = params.pageMarginRight) !== null && _params$pageMarginRig !== void 0 ? _params$pageMarginRig : 0;
|
|
15688
|
+
const pageContentWidth = Number.isFinite(pageWidth) ? Math.max(0, pageWidth - pageMarginLeft - pageMarginRight) : fallbackWidth;
|
|
15689
|
+
const contentWidth = Number.isFinite(params.contentWidth) && ((_params$contentWidth = params.contentWidth) !== null && _params$contentWidth !== void 0 ? _params$contentWidth : 0) > 0 ? params.contentWidth : fallbackWidth;
|
|
15690
|
+
if (params.documentFlavor !== _univerjs_core.DocumentFlavor.MODERN || !Number.isFinite(pageWidth)) {
|
|
15691
|
+
const layoutWidth = Math.min(contentWidth, pageContentWidth || contentWidth);
|
|
15692
|
+
return {
|
|
15693
|
+
contentHeight,
|
|
15694
|
+
contentWidth,
|
|
15695
|
+
height,
|
|
15696
|
+
layoutWidth,
|
|
15697
|
+
offsetLeft: 0,
|
|
15698
|
+
viewportHeight,
|
|
15699
|
+
width: layoutWidth
|
|
15700
|
+
};
|
|
15701
|
+
}
|
|
15702
|
+
const inset = MODERN_DOCS_CUSTOM_BLOCK_VIEWPORT_INSET / (params.scale && params.scale > 0 ? params.scale : 1);
|
|
15703
|
+
const docsLeft = (_params$docsLeft = params.docsLeft) !== null && _params$docsLeft !== void 0 ? _params$docsLeft : 0;
|
|
15704
|
+
const fallbackViewportLeft = docsLeft + inset;
|
|
15705
|
+
const fallbackViewportWidth = Math.max(0, pageWidth - inset * 2);
|
|
15706
|
+
const hasVisibleCanvas = Number.isFinite(params.visibleCanvasLeft) && Number.isFinite(params.visibleCanvasWidth) && ((_params$visibleCanvas2 = params.visibleCanvasWidth) !== null && _params$visibleCanvas2 !== void 0 ? _params$visibleCanvas2 : 0) > 0;
|
|
15707
|
+
const viewportLeft = hasVisibleCanvas ? params.visibleCanvasLeft + inset : fallbackViewportLeft;
|
|
15708
|
+
const viewportWidth = hasVisibleCanvas ? Math.max(0, params.visibleCanvasWidth - inset * 2) : fallbackViewportWidth;
|
|
15709
|
+
const paragraphTextStart = docsLeft + pageMarginLeft;
|
|
15710
|
+
const leadingInsetLeft = Math.max(0, paragraphTextStart - viewportLeft);
|
|
15711
|
+
const layoutWidth = Math.min(contentWidth, pageContentWidth || contentWidth);
|
|
15712
|
+
return {
|
|
15713
|
+
bleedLeft: leadingInsetLeft,
|
|
15714
|
+
bleedWidth: viewportWidth,
|
|
15715
|
+
contentHeight,
|
|
15716
|
+
contentWidth,
|
|
15717
|
+
height,
|
|
15718
|
+
layoutWidth,
|
|
15719
|
+
offsetLeft: 0,
|
|
15720
|
+
viewportHeight,
|
|
15721
|
+
width: layoutWidth
|
|
15722
|
+
};
|
|
15723
|
+
}
|
|
15724
|
+
|
|
14823
15725
|
//#endregion
|
|
14824
15726
|
//#region package.json
|
|
14825
15727
|
var name = "@univerjs/docs-ui";
|
|
14826
|
-
var version = "1.0.0-alpha.
|
|
15728
|
+
var version = "1.0.0-alpha.3";
|
|
14827
15729
|
|
|
14828
15730
|
//#endregion
|
|
14829
15731
|
//#region src/commands/commands/doc-paragraph-setting.command.ts
|
|
@@ -14831,7 +15733,7 @@ const DocParagraphSettingCommand = {
|
|
|
14831
15733
|
id: "doc-paragraph-setting.command",
|
|
14832
15734
|
type: _univerjs_core.CommandType.COMMAND,
|
|
14833
15735
|
handler: async (accessor, config) => {
|
|
14834
|
-
var
|
|
15736
|
+
var _segmentBody$paragrap, _segmentBody$dataStre, _BuildTextUtils$range;
|
|
14835
15737
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
14836
15738
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
14837
15739
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
@@ -14841,8 +15743,9 @@ const DocParagraphSettingCommand = {
|
|
|
14841
15743
|
const segmentId = docRanges[0].segmentId;
|
|
14842
15744
|
const unitId = docDataModel.getUnitId();
|
|
14843
15745
|
const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
|
|
14844
|
-
const
|
|
14845
|
-
const
|
|
15746
|
+
const segmentBody = segment === null || segment === void 0 ? void 0 : segment.getBody();
|
|
15747
|
+
const allParagraphs = (_segmentBody$paragrap = segmentBody === null || segmentBody === void 0 ? void 0 : segmentBody.paragraphs) !== null && _segmentBody$paragrap !== void 0 ? _segmentBody$paragrap : [];
|
|
15748
|
+
const dataStream = (_segmentBody$dataStre = segmentBody === null || segmentBody === void 0 ? void 0 : segmentBody.dataStream) !== null && _segmentBody$dataStre !== void 0 ? _segmentBody$dataStre : "";
|
|
14846
15749
|
const paragraphs = (_BuildTextUtils$range = _univerjs_core.BuildTextUtils.range.getParagraphsInRanges(docRanges, allParagraphs, dataStream)) !== null && _BuildTextUtils$range !== void 0 ? _BuildTextUtils$range : [];
|
|
14847
15750
|
const doMutation = {
|
|
14848
15751
|
id: _univerjs_docs.RichTextEditingMutation.id,
|
|
@@ -14852,6 +15755,7 @@ const DocParagraphSettingCommand = {
|
|
|
14852
15755
|
textRanges: docRanges
|
|
14853
15756
|
}
|
|
14854
15757
|
};
|
|
15758
|
+
if (!config.paragraph || Object.keys(config.paragraph).length === 0) return false;
|
|
14855
15759
|
const memoryCursor = new _univerjs_core.MemoryCursor();
|
|
14856
15760
|
memoryCursor.reset();
|
|
14857
15761
|
const textX = new _univerjs_core.TextX();
|
|
@@ -14862,10 +15766,6 @@ const DocParagraphSettingCommand = {
|
|
|
14862
15766
|
t: _univerjs_core.TextXActionType.RETAIN,
|
|
14863
15767
|
len: startIndex - memoryCursor.cursor
|
|
14864
15768
|
});
|
|
14865
|
-
const paragraphStyle = {
|
|
14866
|
-
...paragraph.paragraphStyle,
|
|
14867
|
-
...config.paragraph
|
|
14868
|
-
};
|
|
14869
15769
|
textX.push({
|
|
14870
15770
|
t: _univerjs_core.TextXActionType.RETAIN,
|
|
14871
15771
|
len: 1,
|
|
@@ -14873,7 +15773,10 @@ const DocParagraphSettingCommand = {
|
|
|
14873
15773
|
dataStream: "",
|
|
14874
15774
|
paragraphs: [{
|
|
14875
15775
|
...paragraph,
|
|
14876
|
-
paragraphStyle
|
|
15776
|
+
paragraphStyle: {
|
|
15777
|
+
...paragraph.paragraphStyle,
|
|
15778
|
+
...config.paragraph
|
|
15779
|
+
},
|
|
14877
15780
|
startIndex: 0
|
|
14878
15781
|
}]
|
|
14879
15782
|
},
|
|
@@ -14887,18 +15790,50 @@ const DocParagraphSettingCommand = {
|
|
|
14887
15790
|
}
|
|
14888
15791
|
};
|
|
14889
15792
|
|
|
15793
|
+
//#endregion
|
|
15794
|
+
//#region src/utils/section-header-footer.ts
|
|
15795
|
+
function getDocPageSectionContext(snapshot, page) {
|
|
15796
|
+
const sections = snapshot.body ? (0, _univerjs_docs.getTopLevelSectionBreaks)(snapshot.body) : [];
|
|
15797
|
+
const sectionIndex = (page === null || page === void 0 ? void 0 : page.sectionId) == null ? -1 : sections.findIndex((item) => item.sectionId === page.sectionId);
|
|
15798
|
+
const section = sectionIndex < 0 ? void 0 : sections[sectionIndex];
|
|
15799
|
+
const references = section == null ? {} : (0, _univerjs_core.resolveSectionHeaderFooterReferences)(snapshot.documentStyle, sections, sectionIndex);
|
|
15800
|
+
return {
|
|
15801
|
+
sectionId: section === null || section === void 0 ? void 0 : section.sectionId,
|
|
15802
|
+
sectionIndex,
|
|
15803
|
+
sections,
|
|
15804
|
+
section,
|
|
15805
|
+
config: {
|
|
15806
|
+
...snapshot.documentStyle,
|
|
15807
|
+
...section,
|
|
15808
|
+
...references
|
|
15809
|
+
}
|
|
15810
|
+
};
|
|
15811
|
+
}
|
|
15812
|
+
|
|
14890
15813
|
//#endregion
|
|
14891
15814
|
//#region src/views/header-footer/panel/DocHeaderFooterOptions.tsx
|
|
14892
|
-
function getSegmentId(documentStyle, editArea, pageIndex) {
|
|
15815
|
+
function getSegmentId(documentStyle, editArea, pageIndex, page) {
|
|
14893
15816
|
const { useFirstPageHeaderFooter, evenAndOddHeaders, defaultHeaderId, defaultFooterId, firstPageHeaderId, firstPageFooterId, evenPageHeaderId, evenPageFooterId } = documentStyle;
|
|
14894
|
-
|
|
14895
|
-
|
|
14896
|
-
|
|
14897
|
-
else
|
|
14898
|
-
else return evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE &&
|
|
14899
|
-
else
|
|
15817
|
+
const isFirstPage = page ? page.pageNumber === page.pageNumberStart : pageIndex === 0;
|
|
15818
|
+
const isEvenPage = page ? page.pageNumber % 2 === 0 : pageIndex % 2 === 1;
|
|
15819
|
+
if (editArea === _univerjs_engine_render.DocumentEditArea.HEADER) if (useFirstPageHeaderFooter === _univerjs_core.BooleanNumber.TRUE) if (isFirstPage) return firstPageHeaderId;
|
|
15820
|
+
else return evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE && isEvenPage ? evenPageHeaderId : defaultHeaderId;
|
|
15821
|
+
else return evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE && isEvenPage ? evenPageHeaderId : defaultHeaderId;
|
|
15822
|
+
else if (useFirstPageHeaderFooter === _univerjs_core.BooleanNumber.TRUE) if (isFirstPage) return firstPageFooterId;
|
|
15823
|
+
else return evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE && isEvenPage ? evenPageFooterId : defaultFooterId;
|
|
15824
|
+
else return evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE && isEvenPage ? evenPageFooterId : defaultFooterId;
|
|
14900
15825
|
}
|
|
14901
15826
|
const DocHeaderFooterOptions = (props) => {
|
|
15827
|
+
var _segmentContext$segme, _segmentContext$segme2;
|
|
15828
|
+
const docSelectionRenderService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService).getRenderById(props.unitId).with(DocSelectionRenderService);
|
|
15829
|
+
const segmentContext = (0, _univerjs_ui.useObservable)(docSelectionRenderService.segmentContext$, {
|
|
15830
|
+
segmentId: docSelectionRenderService.getSegment(),
|
|
15831
|
+
segmentPage: docSelectionRenderService.getSegmentPage()
|
|
15832
|
+
});
|
|
15833
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocHeaderFooterOptionsContent, { ...props }, `${(_segmentContext$segme = segmentContext === null || segmentContext === void 0 ? void 0 : segmentContext.segmentId) !== null && _segmentContext$segme !== void 0 ? _segmentContext$segme : ""}:${(_segmentContext$segme2 = segmentContext === null || segmentContext === void 0 ? void 0 : segmentContext.segmentPage) !== null && _segmentContext$segme2 !== void 0 ? _segmentContext$segme2 : -1}`);
|
|
15834
|
+
};
|
|
15835
|
+
function DocHeaderFooterOptionsContent(props) {
|
|
15836
|
+
var _renderManagerService2, _sectionContext$confi, _sectionContext$secti, _sectionContext$secti2;
|
|
14902
15837
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
14903
15838
|
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
14904
15839
|
const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
|
|
@@ -14906,31 +15841,57 @@ const DocHeaderFooterOptions = (props) => {
|
|
|
14906
15841
|
const layoutService = (0, _univerjs_ui.useDependency)(_univerjs_ui.ILayoutService);
|
|
14907
15842
|
const { unitId } = props;
|
|
14908
15843
|
const docSelectionRenderService = renderManagerService.getRenderById(unitId).with(DocSelectionRenderService);
|
|
14909
|
-
const
|
|
15844
|
+
const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
15845
|
+
const getCurrentSectionContext = () => {
|
|
15846
|
+
var _renderManagerService, _docSkeletonManagerSe;
|
|
15847
|
+
const snapshot = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot();
|
|
15848
|
+
const docSkeletonManagerService = (_renderManagerService = renderManagerService.getRenderById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(_univerjs_docs.DocSkeletonManagerService);
|
|
15849
|
+
const page = docSkeletonManagerService === null || docSkeletonManagerService === void 0 || (_docSkeletonManagerSe = docSkeletonManagerService.getSkeleton) === null || _docSkeletonManagerSe === void 0 || (_docSkeletonManagerSe = _docSkeletonManagerSe.call(docSkeletonManagerService)) === null || _docSkeletonManagerSe === void 0 || (_docSkeletonManagerSe = _docSkeletonManagerSe.getSkeletonData()) === null || _docSkeletonManagerSe === void 0 ? void 0 : _docSkeletonManagerSe.pages[docSelectionRenderService.getSegmentPage()];
|
|
15850
|
+
return snapshot == null ? void 0 : {
|
|
15851
|
+
...getDocPageSectionContext(snapshot, page),
|
|
15852
|
+
page
|
|
15853
|
+
};
|
|
15854
|
+
};
|
|
15855
|
+
const [options, setOptions] = (0, react.useState)(() => {
|
|
15856
|
+
var _getCurrentSectionCon, _config$marginHeader, _config$marginFooter, _config$useFirstPageH, _config$evenAndOddHea;
|
|
15857
|
+
const config = (_getCurrentSectionCon = getCurrentSectionContext()) === null || _getCurrentSectionCon === void 0 ? void 0 : _getCurrentSectionCon.config;
|
|
15858
|
+
return {
|
|
15859
|
+
marginHeader: (_config$marginHeader = config === null || config === void 0 ? void 0 : config.marginHeader) !== null && _config$marginHeader !== void 0 ? _config$marginHeader : 0,
|
|
15860
|
+
marginFooter: (_config$marginFooter = config === null || config === void 0 ? void 0 : config.marginFooter) !== null && _config$marginFooter !== void 0 ? _config$marginFooter : 0,
|
|
15861
|
+
useFirstPageHeaderFooter: (_config$useFirstPageH = config === null || config === void 0 ? void 0 : config.useFirstPageHeaderFooter) !== null && _config$useFirstPageH !== void 0 ? _config$useFirstPageH : _univerjs_core.BooleanNumber.FALSE,
|
|
15862
|
+
evenAndOddHeaders: (_config$evenAndOddHea = config === null || config === void 0 ? void 0 : config.evenAndOddHeaders) !== null && _config$evenAndOddHea !== void 0 ? _config$evenAndOddHea : _univerjs_core.BooleanNumber.FALSE
|
|
15863
|
+
};
|
|
15864
|
+
});
|
|
15865
|
+
const sectionContext = getCurrentSectionContext();
|
|
15866
|
+
const referenceKey = (0, _univerjs_core.getSectionHeaderFooterReferenceKey)(((_renderManagerService2 = renderManagerService.getRenderById(unitId)) === null || _renderManagerService2 === void 0 || (_renderManagerService2 = _renderManagerService2.with(_univerjs_docs.DocSkeletonManagerService)) === null || _renderManagerService2 === void 0 || (_renderManagerService2 = _renderManagerService2.getViewModel()) === null || _renderManagerService2 === void 0 ? void 0 : _renderManagerService2.getEditArea()) === _univerjs_engine_render.DocumentEditArea.FOOTER ? "footer" : "header", getHeaderFooterVariant((_sectionContext$confi = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config) !== null && _sectionContext$confi !== void 0 ? _sectionContext$confi : {}, docSelectionRenderService.getSegmentPage(), sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page));
|
|
15867
|
+
const canLinkToPrevious = ((_sectionContext$secti = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionIndex) !== null && _sectionContext$secti !== void 0 ? _sectionContext$secti : -1) > 0;
|
|
15868
|
+
const [linkedToPrevious, setLinkedToPrevious] = (0, react.useState)(canLinkToPrevious && !(sectionContext === null || sectionContext === void 0 || (_sectionContext$secti2 = sectionContext.section) === null || _sectionContext$secti2 === void 0 ? void 0 : _sectionContext$secti2[referenceKey]));
|
|
14910
15869
|
const handleCheckboxChange = (val, type) => {
|
|
14911
|
-
var
|
|
15870
|
+
var _renderManagerService3;
|
|
14912
15871
|
setOptions((prev) => ({
|
|
14913
15872
|
...prev,
|
|
14914
15873
|
[type]: val ? _univerjs_core.BooleanNumber.TRUE : _univerjs_core.BooleanNumber.FALSE
|
|
14915
15874
|
}));
|
|
14916
|
-
const
|
|
14917
|
-
const documentStyle =
|
|
14918
|
-
const docSkeletonManagerService = (
|
|
15875
|
+
const sectionContext = getCurrentSectionContext();
|
|
15876
|
+
const documentStyle = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config;
|
|
15877
|
+
const docSkeletonManagerService = (_renderManagerService3 = renderManagerService.getRenderById(unitId)) === null || _renderManagerService3 === void 0 ? void 0 : _renderManagerService3.with(_univerjs_docs.DocSkeletonManagerService);
|
|
14919
15878
|
const viewModel = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel();
|
|
14920
15879
|
if (documentStyle == null || viewModel == null) return;
|
|
14921
15880
|
const editArea = viewModel.getEditArea();
|
|
14922
15881
|
let needCreateHeaderFooter = false;
|
|
14923
15882
|
const segmentPage = docSelectionRenderService.getSegmentPage();
|
|
15883
|
+
const isFirstSectionPage = (sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page) ? sectionContext.page.pageNumber === sectionContext.page.pageNumberStart : segmentPage === 0;
|
|
15884
|
+
const isEvenPage = (sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page) ? sectionContext.page.pageNumber % 2 === 0 : segmentPage % 2 === 1;
|
|
14924
15885
|
let needChangeSegmentId = false;
|
|
14925
15886
|
if (type === "useFirstPageHeaderFooter" && val === true) {
|
|
14926
15887
|
if (editArea === _univerjs_engine_render.DocumentEditArea.HEADER && !documentStyle.firstPageHeaderId) needCreateHeaderFooter = true;
|
|
14927
15888
|
else if (editArea === _univerjs_engine_render.DocumentEditArea.FOOTER && !documentStyle.firstPageFooterId) needCreateHeaderFooter = true;
|
|
14928
|
-
if (needCreateHeaderFooter &&
|
|
15889
|
+
if (needCreateHeaderFooter && isFirstSectionPage) needChangeSegmentId = true;
|
|
14929
15890
|
}
|
|
14930
15891
|
if (type === "evenAndOddHeaders" && val === true) {
|
|
14931
15892
|
if (editArea === _univerjs_engine_render.DocumentEditArea.HEADER && !documentStyle.evenPageHeaderId) needCreateHeaderFooter = true;
|
|
14932
15893
|
else if (editArea === _univerjs_engine_render.DocumentEditArea.FOOTER && !documentStyle.evenPageFooterId) needCreateHeaderFooter = true;
|
|
14933
|
-
if (needCreateHeaderFooter &&
|
|
15894
|
+
if (needCreateHeaderFooter && isEvenPage) needChangeSegmentId = true;
|
|
14934
15895
|
}
|
|
14935
15896
|
if (needCreateHeaderFooter) {
|
|
14936
15897
|
const segmentId = (0, _univerjs_core.generateRandomId)(6);
|
|
@@ -14938,7 +15899,8 @@ const DocHeaderFooterOptions = (props) => {
|
|
|
14938
15899
|
commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
14939
15900
|
unitId,
|
|
14940
15901
|
segmentId,
|
|
14941
|
-
headerFooterProps: { [type]: val ? _univerjs_core.BooleanNumber.TRUE : _univerjs_core.BooleanNumber.FALSE }
|
|
15902
|
+
headerFooterProps: { [type]: val ? _univerjs_core.BooleanNumber.TRUE : _univerjs_core.BooleanNumber.FALSE },
|
|
15903
|
+
sectionId: sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionId
|
|
14942
15904
|
});
|
|
14943
15905
|
} else {
|
|
14944
15906
|
const segmentPageIndex = docSelectionRenderService.getSegmentPage();
|
|
@@ -14946,23 +15908,26 @@ const DocHeaderFooterOptions = (props) => {
|
|
|
14946
15908
|
const needFocusSegmentId = getSegmentId({
|
|
14947
15909
|
...documentStyle,
|
|
14948
15910
|
[type]: val ? _univerjs_core.BooleanNumber.TRUE : _univerjs_core.BooleanNumber.FALSE
|
|
14949
|
-
}, editArea, segmentPageIndex);
|
|
15911
|
+
}, editArea, segmentPageIndex, sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page);
|
|
14950
15912
|
if (needFocusSegmentId && needFocusSegmentId !== prevSegmentId) docSelectionRenderService.setSegment(needFocusSegmentId);
|
|
14951
15913
|
commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
14952
15914
|
unitId,
|
|
14953
|
-
headerFooterProps: { [type]: val ? _univerjs_core.BooleanNumber.TRUE : _univerjs_core.BooleanNumber.FALSE }
|
|
15915
|
+
headerFooterProps: { [type]: val ? _univerjs_core.BooleanNumber.TRUE : _univerjs_core.BooleanNumber.FALSE },
|
|
15916
|
+
sectionId: sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionId
|
|
14954
15917
|
});
|
|
14955
15918
|
}
|
|
14956
15919
|
layoutService.focus();
|
|
14957
15920
|
};
|
|
14958
15921
|
const handleMarginChange = async (val, type) => {
|
|
15922
|
+
var _getCurrentSectionCon2;
|
|
14959
15923
|
setOptions((prev) => ({
|
|
14960
15924
|
...prev,
|
|
14961
15925
|
[type]: val
|
|
14962
15926
|
}));
|
|
14963
15927
|
await commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
14964
15928
|
unitId,
|
|
14965
|
-
headerFooterProps: { [type]: val }
|
|
15929
|
+
headerFooterProps: { [type]: val },
|
|
15930
|
+
sectionId: (_getCurrentSectionCon2 = getCurrentSectionContext()) === null || _getCurrentSectionCon2 === void 0 ? void 0 : _getCurrentSectionCon2.sectionId
|
|
14966
15931
|
});
|
|
14967
15932
|
docSelectionRenderService.removeAllRanges();
|
|
14968
15933
|
docSelectionRenderService.blur();
|
|
@@ -14970,22 +15935,37 @@ const DocHeaderFooterOptions = (props) => {
|
|
|
14970
15935
|
const closeHeaderFooter = () => {
|
|
14971
15936
|
commandService.executeCommand(CloseHeaderFooterCommand.id, { unitId });
|
|
14972
15937
|
};
|
|
14973
|
-
|
|
14974
|
-
|
|
14975
|
-
const
|
|
14976
|
-
if (
|
|
14977
|
-
|
|
14978
|
-
|
|
14979
|
-
|
|
14980
|
-
|
|
14981
|
-
|
|
14982
|
-
|
|
14983
|
-
|
|
14984
|
-
|
|
14985
|
-
|
|
15938
|
+
const handleLinkToPreviousChange = async (linked) => {
|
|
15939
|
+
var _renderManagerService4;
|
|
15940
|
+
const context = getCurrentSectionContext();
|
|
15941
|
+
if (!(context === null || context === void 0 ? void 0 : context.sectionId) || context.sectionIndex <= 0 || !docDataModel) return;
|
|
15942
|
+
const kind = ((_renderManagerService4 = renderManagerService.getRenderById(unitId)) === null || _renderManagerService4 === void 0 || (_renderManagerService4 = _renderManagerService4.with(_univerjs_docs.DocSkeletonManagerService)) === null || _renderManagerService4 === void 0 || (_renderManagerService4 = _renderManagerService4.getViewModel()) === null || _renderManagerService4 === void 0 ? void 0 : _renderManagerService4.getEditArea()) === _univerjs_engine_render.DocumentEditArea.FOOTER ? "footer" : "header";
|
|
15943
|
+
const currentVariant = getHeaderFooterVariant(context.config, docSelectionRenderService.getSegmentPage(), context.page);
|
|
15944
|
+
const key = (0, _univerjs_core.getSectionHeaderFooterReferenceKey)(kind, currentVariant);
|
|
15945
|
+
const segmentId = (0, _univerjs_core.generateRandomId)(6);
|
|
15946
|
+
const previousSegmentId = (0, _univerjs_core.resolveSectionHeaderFooterReference)(docDataModel.getDocumentStyle(), context.sections, context.sectionIndex - 1, key).segmentId;
|
|
15947
|
+
if (!await commandService.executeCommand(_univerjs_docs.SetSectionHeaderFooterLinkCommand.id, {
|
|
15948
|
+
unitId,
|
|
15949
|
+
sectionId: context.sectionId,
|
|
15950
|
+
kind,
|
|
15951
|
+
variant: currentVariant,
|
|
15952
|
+
linkedToPrevious: linked,
|
|
15953
|
+
...linked ? {} : { segmentId }
|
|
15954
|
+
})) return;
|
|
15955
|
+
setLinkedToPrevious(linked);
|
|
15956
|
+
docSelectionRenderService.setSegment(linked ? previousSegmentId !== null && previousSegmentId !== void 0 ? previousSegmentId : "" : segmentId);
|
|
15957
|
+
layoutService.focus();
|
|
15958
|
+
};
|
|
14986
15959
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
14987
15960
|
className: "univer-grid univer-gap-4",
|
|
14988
15961
|
children: [
|
|
15962
|
+
canLinkToPrevious && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
15963
|
+
checked: linkedToPrevious,
|
|
15964
|
+
onChange: (val) => {
|
|
15965
|
+
handleLinkToPreviousChange(val);
|
|
15966
|
+
},
|
|
15967
|
+
children: localeService.t("docs-ui.headerFooter.linkToPrevious")
|
|
15968
|
+
}) }),
|
|
14989
15969
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
14990
15970
|
className: "univer-grid univer-gap-2",
|
|
14991
15971
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
@@ -15033,7 +16013,14 @@ const DocHeaderFooterOptions = (props) => {
|
|
|
15033
16013
|
})
|
|
15034
16014
|
]
|
|
15035
16015
|
});
|
|
15036
|
-
}
|
|
16016
|
+
}
|
|
16017
|
+
function getHeaderFooterVariant(documentStyle, pageIndex, page) {
|
|
16018
|
+
const isFirstPage = page ? page.pageNumber === page.pageNumberStart : pageIndex === 0;
|
|
16019
|
+
const isEvenPage = page ? page.pageNumber % 2 === 0 : pageIndex % 2 === 1;
|
|
16020
|
+
if (documentStyle.useFirstPageHeaderFooter === _univerjs_core.BooleanNumber.TRUE && isFirstPage) return "first";
|
|
16021
|
+
if (documentStyle.evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE && isEvenPage) return "even";
|
|
16022
|
+
return "default";
|
|
16023
|
+
}
|
|
15037
16024
|
|
|
15038
16025
|
//#endregion
|
|
15039
16026
|
//#region src/views/header-footer/panel/DocHeaderFooterPanel.tsx
|
|
@@ -15128,12 +16115,14 @@ function TextColorSwatchIcon({ className, style, onClick, color }) {
|
|
|
15128
16115
|
stroke: "currentColor",
|
|
15129
16116
|
strokeOpacity: .16
|
|
15130
16117
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("text", {
|
|
15131
|
-
x:
|
|
16118
|
+
x: 12,
|
|
15132
16119
|
y: 16.5,
|
|
16120
|
+
direction: "ltr",
|
|
15133
16121
|
fontFamily: "Arial, sans-serif",
|
|
15134
16122
|
fontSize: 12,
|
|
15135
16123
|
fontWeight: 700,
|
|
15136
16124
|
fill: color,
|
|
16125
|
+
textAnchor: "middle",
|
|
15137
16126
|
children: "A"
|
|
15138
16127
|
})]
|
|
15139
16128
|
});
|
|
@@ -15220,6 +16209,26 @@ const DocParagraphBackgroundColorSwatchIcon13 = createBackgroundColorSwatchIcon(
|
|
|
15220
16209
|
const DocParagraphBackgroundColorSwatchIcon14 = createBackgroundColorSwatchIcon(14);
|
|
15221
16210
|
const DocParagraphBackgroundColorSwatchIcon15 = createBackgroundColorSwatchIcon(15);
|
|
15222
16211
|
|
|
16212
|
+
//#endregion
|
|
16213
|
+
//#region src/views/paragraph-menu/component-keys.ts
|
|
16214
|
+
/**
|
|
16215
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
16216
|
+
*
|
|
16217
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
16218
|
+
* you may not use this file except in compliance with the License.
|
|
16219
|
+
* You may obtain a copy of the License at
|
|
16220
|
+
*
|
|
16221
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16222
|
+
*
|
|
16223
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16224
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16225
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16226
|
+
* See the License for the specific language governing permissions and
|
|
16227
|
+
* limitations under the License.
|
|
16228
|
+
*/
|
|
16229
|
+
const DOC_PARAGRAPH_MENU_COMPONENT_KEY = "doc.paragraph.menu";
|
|
16230
|
+
const DOC_TABLE_BLOCK_MENU_COMPONENT_KEY = "doc.table-block.menu";
|
|
16231
|
+
|
|
15223
16232
|
//#endregion
|
|
15224
16233
|
//#region src/views/paragraph-setting/line-spacing.ts
|
|
15225
16234
|
const AUTO_LINE_SPACING_CONFIG = {
|
|
@@ -15238,22 +16247,20 @@ function round(value, digits) {
|
|
|
15238
16247
|
function clamp(value, min, max) {
|
|
15239
16248
|
return Math.min(max, Math.max(min, value));
|
|
15240
16249
|
}
|
|
15241
|
-
|
|
15242
|
-
|
|
15243
|
-
|
|
15244
|
-
|
|
15245
|
-
|
|
15246
|
-
|
|
15247
|
-
|
|
15248
|
-
|
|
15249
|
-
|
|
15250
|
-
|
|
15251
|
-
|
|
15252
|
-
|
|
15253
|
-
|
|
15254
|
-
|
|
15255
|
-
];
|
|
15256
|
-
}
|
|
16250
|
+
const LINE_SPACING_RULE_OPTIONS = [
|
|
16251
|
+
{
|
|
16252
|
+
label: "docs-ui.doc.paragraphSetting.multiSpace",
|
|
16253
|
+
value: `${_univerjs_core.SpacingRule.AUTO}`
|
|
16254
|
+
},
|
|
16255
|
+
{
|
|
16256
|
+
label: "docs-ui.doc.paragraphSetting.atLeast",
|
|
16257
|
+
value: `${_univerjs_core.SpacingRule.AT_LEAST}`
|
|
16258
|
+
},
|
|
16259
|
+
{
|
|
16260
|
+
label: "docs-ui.doc.paragraphSetting.exactly",
|
|
16261
|
+
value: `${_univerjs_core.SpacingRule.EXACT}`
|
|
16262
|
+
}
|
|
16263
|
+
];
|
|
15257
16264
|
function getLineSpacingInputConfig(spacingRule) {
|
|
15258
16265
|
return spacingRule === _univerjs_core.SpacingRule.AUTO ? AUTO_LINE_SPACING_CONFIG : FIXED_LINE_SPACING_CONFIG;
|
|
15259
16266
|
}
|
|
@@ -15291,6 +16298,21 @@ function convertLineSpacingForRuleChange(currentStoredValue, currentRule, nextRu
|
|
|
15291
16298
|
|
|
15292
16299
|
//#endregion
|
|
15293
16300
|
//#region src/views/paragraph-setting/hook/utils.ts
|
|
16301
|
+
const PARAGRAPH_LAYOUT_BLOCK_TYPES = /* @__PURE__ */ new Set([
|
|
16302
|
+
_univerjs_core.DocumentBlockRangeType.CALLOUT,
|
|
16303
|
+
_univerjs_core.DocumentBlockRangeType.CODE,
|
|
16304
|
+
_univerjs_core.DocumentBlockRangeType.QUOTE
|
|
16305
|
+
]);
|
|
16306
|
+
function resolveParagraphsForSettingPanel(paragraphs, body, documentStyle) {
|
|
16307
|
+
return paragraphs.map((paragraph) => {
|
|
16308
|
+
var _body$blockRanges$som, _body$blockRanges;
|
|
16309
|
+
const hasLayoutBlockRange = (_body$blockRanges$som = (_body$blockRanges = body.blockRanges) === null || _body$blockRanges === void 0 ? void 0 : _body$blockRanges.some((range) => PARAGRAPH_LAYOUT_BLOCK_TYPES.has(range.blockType) && paragraph.startIndex > range.startIndex && paragraph.startIndex < range.endIndex)) !== null && _body$blockRanges$som !== void 0 ? _body$blockRanges$som : false;
|
|
16310
|
+
return {
|
|
16311
|
+
...paragraph,
|
|
16312
|
+
paragraphStyle: (0, _univerjs_core.resolveDocumentParagraphStyle)(documentStyle, paragraph.paragraphStyle, { excludeDocumentOuterSpacing: hasLayoutBlockRange })
|
|
16313
|
+
};
|
|
16314
|
+
});
|
|
16315
|
+
}
|
|
15294
16316
|
const useDocRanges = () => {
|
|
15295
16317
|
const docSelectionManagerService = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocSelectionManagerService);
|
|
15296
16318
|
const docParagraphSettingController = (0, _univerjs_ui.useDependency)(DocParagraphSettingController);
|
|
@@ -15301,15 +16323,17 @@ const useDocRanges = () => {
|
|
|
15301
16323
|
return docRanges;
|
|
15302
16324
|
};
|
|
15303
16325
|
const useCurrentParagraph = () => {
|
|
15304
|
-
var
|
|
16326
|
+
var _body$paragraphs, _body$dataStream, _BuildTextUtils$range;
|
|
15305
16327
|
const docDataModel = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService).getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
15306
16328
|
const docRanges = useDocRanges();
|
|
15307
16329
|
if (!docDataModel || docRanges.length === 0) return [];
|
|
15308
16330
|
const segmentId = docRanges[0].segmentId;
|
|
15309
16331
|
const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
|
|
15310
|
-
const
|
|
15311
|
-
const
|
|
15312
|
-
|
|
16332
|
+
const body = segment === null || segment === void 0 ? void 0 : segment.getBody();
|
|
16333
|
+
const paragraphs = (_body$paragraphs = body === null || body === void 0 ? void 0 : body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : [];
|
|
16334
|
+
const dataStream = (_body$dataStream = body === null || body === void 0 ? void 0 : body.dataStream) !== null && _body$dataStream !== void 0 ? _body$dataStream : "";
|
|
16335
|
+
const currentParagraphs = (_BuildTextUtils$range = _univerjs_core.BuildTextUtils.range.getParagraphsInRanges(docRanges, paragraphs, dataStream)) !== null && _BuildTextUtils$range !== void 0 ? _BuildTextUtils$range : [];
|
|
16336
|
+
return body == null ? currentParagraphs : resolveParagraphsForSettingPanel(currentParagraphs, body, docDataModel.getDocumentStyle());
|
|
15313
16337
|
};
|
|
15314
16338
|
const useFirstParagraphHorizontalAlign = (paragraph, defaultValue) => {
|
|
15315
16339
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
@@ -15475,13 +16499,36 @@ const useFirstParagraphLineSpacing = (paragraph) => {
|
|
|
15475
16499
|
|
|
15476
16500
|
//#endregion
|
|
15477
16501
|
//#region src/views/paragraph-setting/Setting.tsx
|
|
16502
|
+
const ALIGNMENT_OPTIONS = [
|
|
16503
|
+
{
|
|
16504
|
+
label: "docs-ui.toolbar.alignLeft",
|
|
16505
|
+
value: String(_univerjs_core.HorizontalAlign.LEFT),
|
|
16506
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.LeftJustifyingIcon, {})
|
|
16507
|
+
},
|
|
16508
|
+
{
|
|
16509
|
+
label: "docs-ui.toolbar.alignCenter",
|
|
16510
|
+
value: String(_univerjs_core.HorizontalAlign.CENTER),
|
|
16511
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.HorizontallyIcon, {})
|
|
16512
|
+
},
|
|
16513
|
+
{
|
|
16514
|
+
label: "docs-ui.toolbar.alignRight",
|
|
16515
|
+
value: String(_univerjs_core.HorizontalAlign.RIGHT),
|
|
16516
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.RightJustifyingIcon, {})
|
|
16517
|
+
},
|
|
16518
|
+
{
|
|
16519
|
+
label: "docs-ui.toolbar.alignJustify",
|
|
16520
|
+
value: String(_univerjs_core.HorizontalAlign.JUSTIFIED),
|
|
16521
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AlignTextBothIcon, {})
|
|
16522
|
+
}
|
|
16523
|
+
];
|
|
15478
16524
|
const ParagraphSettingSection = (props) => {
|
|
15479
|
-
const {
|
|
16525
|
+
const { titleKey, children, first = false } = props;
|
|
16526
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
15480
16527
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
15481
16528
|
className: (0, _univerjs_design.clsx)(!first && "univer-mt-5"),
|
|
15482
16529
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
15483
16530
|
className: "univer-text-sm univer-font-medium univer-leading-5",
|
|
15484
|
-
children:
|
|
16531
|
+
children: localeService.t(titleKey)
|
|
15485
16532
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
15486
16533
|
className: "univer-mt-3",
|
|
15487
16534
|
children
|
|
@@ -15489,13 +16536,13 @@ const ParagraphSettingSection = (props) => {
|
|
|
15489
16536
|
});
|
|
15490
16537
|
};
|
|
15491
16538
|
const ParagraphSettingRow = (props) => {
|
|
15492
|
-
const {
|
|
16539
|
+
const { labelKey, unit, children } = props;
|
|
15493
16540
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
15494
16541
|
className: "univer-grid univer-min-h-8 univer-items-center univer-gap-3",
|
|
15495
16542
|
style: { gridTemplateColumns: "minmax(0, 1fr) minmax(160px, 180px)" },
|
|
15496
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
16543
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
15497
16544
|
className: "univer-min-w-0 univer-text-xs univer-leading-5 univer-text-gray-900 dark:!univer-text-gray-100",
|
|
15498
|
-
children:
|
|
16545
|
+
children: [(0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService).t(labelKey), unit]
|
|
15499
16546
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
15500
16547
|
className: "univer-w-full univer-min-w-0",
|
|
15501
16548
|
children
|
|
@@ -15525,30 +16572,8 @@ const AutoFocusInputNumber = (props) => {
|
|
|
15525
16572
|
};
|
|
15526
16573
|
function ParagraphSetting() {
|
|
15527
16574
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
15528
|
-
const alignmentOptions = (0, react.useMemo)(() => [
|
|
15529
|
-
{
|
|
15530
|
-
label: localeService.t("docs-ui.toolbar.alignLeft"),
|
|
15531
|
-
value: String(_univerjs_core.HorizontalAlign.LEFT),
|
|
15532
|
-
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.LeftJustifyingIcon, {})
|
|
15533
|
-
},
|
|
15534
|
-
{
|
|
15535
|
-
label: localeService.t("docs-ui.toolbar.alignCenter"),
|
|
15536
|
-
value: String(_univerjs_core.HorizontalAlign.CENTER),
|
|
15537
|
-
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.HorizontallyIcon, {})
|
|
15538
|
-
},
|
|
15539
|
-
{
|
|
15540
|
-
label: localeService.t("docs-ui.toolbar.alignRight"),
|
|
15541
|
-
value: String(_univerjs_core.HorizontalAlign.RIGHT),
|
|
15542
|
-
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.RightJustifyingIcon, {})
|
|
15543
|
-
},
|
|
15544
|
-
{
|
|
15545
|
-
label: localeService.t("docs-ui.toolbar.alignJustify"),
|
|
15546
|
-
value: String(_univerjs_core.HorizontalAlign.JUSTIFIED),
|
|
15547
|
-
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AlignTextBothIcon, {})
|
|
15548
|
-
}
|
|
15549
|
-
], []);
|
|
15550
16575
|
const currentParagraph = useCurrentParagraph();
|
|
15551
|
-
const [horizontalAlignValue, setHorizontalAlign] = useFirstParagraphHorizontalAlign(currentParagraph,
|
|
16576
|
+
const [horizontalAlignValue, setHorizontalAlign] = useFirstParagraphHorizontalAlign(currentParagraph, ALIGNMENT_OPTIONS[0].value);
|
|
15552
16577
|
const [indentStart, setIndentStart] = useFirstParagraphIndentStart(currentParagraph);
|
|
15553
16578
|
const [indentEnd, setIndentEnd] = useFirstParagraphIndentEnd(currentParagraph);
|
|
15554
16579
|
const [indentFirstLine, setIndentFirstLine] = useFirstParagraphIndentFirstLine(currentParagraph);
|
|
@@ -15557,18 +16582,21 @@ function ParagraphSetting() {
|
|
|
15557
16582
|
const [spaceBelow, setSpaceBelow] = useFirstParagraphSpaceBelow(currentParagraph);
|
|
15558
16583
|
const { lineSpacing: [lineSpacing, setLineSpacing], spacingRule: [spacingRule, setSpacingRule] } = useFirstParagraphLineSpacing(currentParagraph);
|
|
15559
16584
|
const lineSpaceConfig = (0, react.useMemo)(() => getLineSpacingInputConfig(spacingRule), [spacingRule]);
|
|
15560
|
-
const lineSpacingOptions =
|
|
16585
|
+
const lineSpacingOptions = LINE_SPACING_RULE_OPTIONS.map((option) => ({
|
|
16586
|
+
...option,
|
|
16587
|
+
label: localeService.t(option.label)
|
|
16588
|
+
}));
|
|
15561
16589
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
15562
16590
|
className: "univer-box-border univer-w-full",
|
|
15563
16591
|
children: [
|
|
15564
16592
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParagraphSettingSection, {
|
|
15565
|
-
|
|
16593
|
+
titleKey: "docs-ui.doc.paragraphSetting.alignment",
|
|
15566
16594
|
first: true,
|
|
15567
16595
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
15568
16596
|
className: (0, _univerjs_design.clsx)("univer-flex univer-grid-cols-4 univer-items-center univer-justify-around univer-gap-2 univer-rounded-lg univer-bg-white univer-p-1 dark:!univer-bg-gray-900", _univerjs_design.borderClassName),
|
|
15569
|
-
children:
|
|
16597
|
+
children: ALIGNMENT_OPTIONS.map((item) => {
|
|
15570
16598
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
|
|
15571
|
-
title: item.label,
|
|
16599
|
+
title: localeService.t(item.label),
|
|
15572
16600
|
placement: "bottom",
|
|
15573
16601
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
15574
16602
|
className: "univer-flex univer-w-full univer-items-center univer-justify-center",
|
|
@@ -15588,33 +16616,37 @@ function ParagraphSetting() {
|
|
|
15588
16616
|
})
|
|
15589
16617
|
}),
|
|
15590
16618
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParagraphSettingSection, {
|
|
15591
|
-
|
|
16619
|
+
titleKey: "docs-ui.doc.paragraphSetting.indentation",
|
|
15592
16620
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
15593
16621
|
className: "univer-grid univer-gap-3",
|
|
15594
16622
|
children: [
|
|
15595
16623
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParagraphSettingRow, {
|
|
15596
|
-
|
|
16624
|
+
labelKey: "docs-ui.doc.paragraphSetting.left",
|
|
16625
|
+
unit: "(px)",
|
|
15597
16626
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AutoFocusInputNumber, {
|
|
15598
16627
|
value: indentStart,
|
|
15599
16628
|
onChange: (v) => setIndentStart(v !== null && v !== void 0 ? v : 0)
|
|
15600
16629
|
})
|
|
15601
16630
|
}),
|
|
15602
16631
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParagraphSettingRow, {
|
|
15603
|
-
|
|
16632
|
+
labelKey: "docs-ui.doc.paragraphSetting.right",
|
|
16633
|
+
unit: "(px)",
|
|
15604
16634
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AutoFocusInputNumber, {
|
|
15605
16635
|
value: indentEnd,
|
|
15606
16636
|
onChange: (v) => setIndentEnd(v !== null && v !== void 0 ? v : 0)
|
|
15607
16637
|
})
|
|
15608
16638
|
}),
|
|
15609
16639
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParagraphSettingRow, {
|
|
15610
|
-
|
|
16640
|
+
labelKey: "docs-ui.doc.paragraphSetting.firstLine",
|
|
16641
|
+
unit: "(px)",
|
|
15611
16642
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AutoFocusInputNumber, {
|
|
15612
16643
|
value: indentFirstLine,
|
|
15613
16644
|
onChange: (v) => setIndentFirstLine(v !== null && v !== void 0 ? v : 0)
|
|
15614
16645
|
})
|
|
15615
16646
|
}),
|
|
15616
16647
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParagraphSettingRow, {
|
|
15617
|
-
|
|
16648
|
+
labelKey: "docs-ui.doc.paragraphSetting.hanging",
|
|
16649
|
+
unit: "(px)",
|
|
15618
16650
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AutoFocusInputNumber, {
|
|
15619
16651
|
value: hanging,
|
|
15620
16652
|
onChange: (v) => setHanging(v !== null && v !== void 0 ? v : 0)
|
|
@@ -15624,26 +16656,28 @@ function ParagraphSetting() {
|
|
|
15624
16656
|
})
|
|
15625
16657
|
}),
|
|
15626
16658
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParagraphSettingSection, {
|
|
15627
|
-
|
|
16659
|
+
titleKey: "docs-ui.doc.paragraphSetting.spacing",
|
|
15628
16660
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
15629
16661
|
className: "univer-grid univer-gap-3",
|
|
15630
16662
|
children: [
|
|
15631
16663
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParagraphSettingRow, {
|
|
15632
|
-
|
|
16664
|
+
labelKey: "docs-ui.doc.paragraphSetting.before",
|
|
16665
|
+
unit: "(px)",
|
|
15633
16666
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AutoFocusInputNumber, {
|
|
15634
16667
|
value: spaceAbove,
|
|
15635
16668
|
onChange: (v) => setSpaceAbove(v !== null && v !== void 0 ? v : 0)
|
|
15636
16669
|
})
|
|
15637
16670
|
}),
|
|
15638
16671
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParagraphSettingRow, {
|
|
15639
|
-
|
|
16672
|
+
labelKey: "docs-ui.doc.paragraphSetting.after",
|
|
16673
|
+
unit: "(px)",
|
|
15640
16674
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AutoFocusInputNumber, {
|
|
15641
16675
|
value: spaceBelow,
|
|
15642
16676
|
onChange: (v) => setSpaceBelow(v !== null && v !== void 0 ? v : 0)
|
|
15643
16677
|
})
|
|
15644
16678
|
}),
|
|
15645
16679
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParagraphSettingRow, {
|
|
15646
|
-
|
|
16680
|
+
labelKey: "docs-ui.doc.paragraphSetting.lineSpace",
|
|
15647
16681
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
15648
16682
|
className: "univer-flex univer-w-full univer-flex-col univer-gap-2",
|
|
15649
16683
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
|
|
@@ -15698,26 +16732,6 @@ function ParagraphSettingIndex() {
|
|
|
15698
16732
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParagraphSetting, {}, key);
|
|
15699
16733
|
}
|
|
15700
16734
|
|
|
15701
|
-
//#endregion
|
|
15702
|
-
//#region src/views/paragraph-menu/component-keys.ts
|
|
15703
|
-
/**
|
|
15704
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
15705
|
-
*
|
|
15706
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15707
|
-
* you may not use this file except in compliance with the License.
|
|
15708
|
-
* You may obtain a copy of the License at
|
|
15709
|
-
*
|
|
15710
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15711
|
-
*
|
|
15712
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
15713
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15714
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15715
|
-
* See the License for the specific language governing permissions and
|
|
15716
|
-
* limitations under the License.
|
|
15717
|
-
*/
|
|
15718
|
-
const DOC_PARAGRAPH_MENU_COMPONENT_KEY = "doc.paragraph.menu";
|
|
15719
|
-
const DOC_TABLE_BLOCK_MENU_COMPONENT_KEY = "doc.table-block.menu";
|
|
15720
|
-
|
|
15721
16735
|
//#endregion
|
|
15722
16736
|
//#region src/views/float-toolbar/FloatToolbar.tsx
|
|
15723
16737
|
const DEFAULT_AVALIABLE_MENUS = [
|
|
@@ -15808,6 +16822,9 @@ let DocFloatMenuService = class DocFloatMenuService extends _univerjs_core.Dispo
|
|
|
15808
16822
|
get floatMenu() {
|
|
15809
16823
|
return this._floatMenu;
|
|
15810
16824
|
}
|
|
16825
|
+
hideFloatMenu() {
|
|
16826
|
+
this._hideFloatMenu();
|
|
16827
|
+
}
|
|
15811
16828
|
_registerFloatMenu() {
|
|
15812
16829
|
this.disposeWithMe(this._componentManager.register(FLOAT_MENU_COMPONENT_KEY, FloatToolbar));
|
|
15813
16830
|
}
|
|
@@ -16463,15 +17480,10 @@ function isParagraphInTable(documentDataModel, paragraphStart) {
|
|
|
16463
17480
|
return ((_documentDataModel$ge = (_documentDataModel$ge2 = documentDataModel.getBody()) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.tables) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : []).some((table) => paragraphStart > table.startIndex && paragraphStart < table.endIndex);
|
|
16464
17481
|
}
|
|
16465
17482
|
function getParagraphMoveRange(documentDataModel, paragraph, cellRange) {
|
|
16466
|
-
|
|
16467
|
-
const
|
|
16468
|
-
const index = paragraphs.findIndex((item) => item.startIndex === paragraph.startIndex);
|
|
16469
|
-
const previousParagraph = index > 0 ? paragraphs.slice(0, index).reverse().find((item) => {
|
|
16470
|
-
if (!cellRange) return true;
|
|
16471
|
-
return item.startIndex > cellRange.startOffset && item.startIndex < cellRange.endOffset;
|
|
16472
|
-
}) : null;
|
|
17483
|
+
const body = documentDataModel.getBody();
|
|
17484
|
+
const paragraphStartOffset = body ? (0, _univerjs_core.getParagraphContentStartOffset)(body, paragraph) : 0;
|
|
16473
17485
|
return {
|
|
16474
|
-
startOffset:
|
|
17486
|
+
startOffset: cellRange ? Math.max(paragraphStartOffset, cellRange.startOffset + 1) : paragraphStartOffset,
|
|
16475
17487
|
endOffset: paragraph.startIndex + 1
|
|
16476
17488
|
};
|
|
16477
17489
|
}
|
|
@@ -16525,8 +17537,8 @@ function unionRects(rects) {
|
|
|
16525
17537
|
}));
|
|
16526
17538
|
}
|
|
16527
17539
|
function getParagraphBlockRange(documentDataModel, paragraph) {
|
|
16528
|
-
var _documentDataModel$
|
|
16529
|
-
return ((_documentDataModel$
|
|
17540
|
+
var _documentDataModel$ge3, _documentDataModel$ge4;
|
|
17541
|
+
return ((_documentDataModel$ge3 = (_documentDataModel$ge4 = documentDataModel.getBody()) === null || _documentDataModel$ge4 === void 0 ? void 0 : _documentDataModel$ge4.blockRanges) !== null && _documentDataModel$ge3 !== void 0 ? _documentDataModel$ge3 : []).find((range) => Math.max(paragraph.paragraphStart, range.startIndex) <= Math.min(paragraph.paragraphEnd, range.endIndex));
|
|
16530
17542
|
}
|
|
16531
17543
|
function getBlockRangeAnchorRect(docEventManagerService, blockRange, fallbackParagraph) {
|
|
16532
17544
|
var _bounds$0$firstLine, _bounds$;
|
|
@@ -16545,8 +17557,12 @@ function getBlockRangeAnchorRect(docEventManagerService, blockRange, fallbackPar
|
|
|
16545
17557
|
|
|
16546
17558
|
//#endregion
|
|
16547
17559
|
//#region src/views/ParagraphMenu.tsx
|
|
16548
|
-
function getParagraphMenuPopupDirection(anchorLeft, menuWidth = 212, viewportPadding = 8) {
|
|
16549
|
-
|
|
17560
|
+
function getParagraphMenuPopupDirection(anchorLeft, menuWidth = 212, viewportPadding = 8, options = {}) {
|
|
17561
|
+
const { anchorRight = anchorLeft, direction = "ltr", viewportWidth = Number.POSITIVE_INFINITY } = options;
|
|
17562
|
+
const hasLeftSpace = anchorLeft - menuWidth >= viewportPadding;
|
|
17563
|
+
const hasRightSpace = anchorRight + menuWidth + viewportPadding <= viewportWidth;
|
|
17564
|
+
if (direction === "rtl") return hasRightSpace || !hasLeftSpace ? "right" : "left";
|
|
17565
|
+
return hasLeftSpace || !hasRightSpace ? "left" : "right";
|
|
16550
17566
|
}
|
|
16551
17567
|
const PARAGRAPH_MENU_HOVER_OPEN_DELAY = 800;
|
|
16552
17568
|
const PARAGRAPH_MENU_HOVER_HIDE_DELAY = 240;
|
|
@@ -16889,19 +17905,75 @@ function unwrapBlockRangeBody(documentBody, blockRange) {
|
|
|
16889
17905
|
}
|
|
16890
17906
|
};
|
|
16891
17907
|
}
|
|
16892
|
-
|
|
16893
|
-
|
|
16894
|
-
|
|
16895
|
-
|
|
16896
|
-
|
|
16897
|
-
|
|
16898
|
-
|
|
16899
|
-
|
|
16900
|
-
|
|
16901
|
-
|
|
16902
|
-
|
|
16903
|
-
|
|
16904
|
-
|
|
17908
|
+
const UNWRAP_BLOCK_BODY_PATCH_KEYS = [
|
|
17909
|
+
"paragraphs",
|
|
17910
|
+
"sectionBreaks",
|
|
17911
|
+
"textRuns",
|
|
17912
|
+
"customRanges",
|
|
17913
|
+
"customDecorations",
|
|
17914
|
+
"customBlocks",
|
|
17915
|
+
"tables",
|
|
17916
|
+
"columnGroups",
|
|
17917
|
+
"blockRanges"
|
|
17918
|
+
];
|
|
17919
|
+
function buildUnwrapBlockRangeActions(previousBody, nextBody, blockRange) {
|
|
17920
|
+
const endTokenOffset = getEndTokenOffset(previousBody, blockRange);
|
|
17921
|
+
const textX = new _univerjs_core.TextX();
|
|
17922
|
+
textX.retain(blockRange.startIndex);
|
|
17923
|
+
textX.delete(1);
|
|
17924
|
+
textX.retain(Math.max(0, endTokenOffset - blockRange.startIndex - 1));
|
|
17925
|
+
textX.delete(1);
|
|
17926
|
+
const textAction = _univerjs_core.JSONX.getInstance().editOp(textX.serialize(), ["body"]);
|
|
17927
|
+
const intermediateBody = _univerjs_core.Tools.deepClone(previousBody);
|
|
17928
|
+
_univerjs_core.TextX.apply(intermediateBody, textX.serialize());
|
|
17929
|
+
const rawActions = [textAction];
|
|
17930
|
+
collectUnwrapBlockBodyPatchActions(intermediateBody, nextBody, rawActions);
|
|
17931
|
+
return rawActions.reduce((acc, action) => _univerjs_core.JSONX.compose(acc, action), null);
|
|
17932
|
+
}
|
|
17933
|
+
function collectUnwrapBlockBodyPatchActions(previousBody, nextBody, actions) {
|
|
17934
|
+
for (const key of UNWRAP_BLOCK_BODY_PATCH_KEYS) collectUnwrapPatchActions(_univerjs_core.JSONX.getInstance(), ["body", key], previousBody[key], nextBody[key], actions);
|
|
17935
|
+
}
|
|
17936
|
+
function collectUnwrapPatchActions(jsonX, path, oldValue, newValue, actions) {
|
|
17937
|
+
if (isEmptyArrayEquivalent(oldValue, newValue) || _univerjs_core.Tools.diffValue(oldValue, newValue)) return;
|
|
17938
|
+
if (oldValue == null) {
|
|
17939
|
+
actions.push(jsonX.insertOp(path, newValue));
|
|
17940
|
+
return;
|
|
17941
|
+
}
|
|
17942
|
+
if (newValue == null) {
|
|
17943
|
+
actions.push(jsonX.removeOp(path, oldValue));
|
|
17944
|
+
return;
|
|
17945
|
+
}
|
|
17946
|
+
if (Array.isArray(oldValue) && Array.isArray(newValue)) {
|
|
17947
|
+
collectUnwrapArrayPatchActions(jsonX, path, oldValue, newValue, actions);
|
|
17948
|
+
return;
|
|
17949
|
+
}
|
|
17950
|
+
if (isPlainObject(oldValue) && isPlainObject(newValue)) {
|
|
17951
|
+
(/* @__PURE__ */ new Set([...Object.keys(oldValue), ...Object.keys(newValue)])).forEach((key) => collectUnwrapPatchActions(jsonX, [...path, key], oldValue[key], newValue[key], actions));
|
|
17952
|
+
return;
|
|
17953
|
+
}
|
|
17954
|
+
actions.push(jsonX.replaceOp(path, oldValue, newValue));
|
|
17955
|
+
}
|
|
17956
|
+
function collectUnwrapArrayPatchActions(jsonX, path, oldItems, newItems, actions) {
|
|
17957
|
+
if (oldItems.length === newItems.length) {
|
|
17958
|
+
oldItems.forEach((item, index) => collectUnwrapPatchActions(jsonX, [...path, index], item, newItems[index], actions));
|
|
17959
|
+
return;
|
|
17960
|
+
}
|
|
17961
|
+
let prefix = 0;
|
|
17962
|
+
while (prefix < oldItems.length && prefix < newItems.length && _univerjs_core.Tools.diffValue(oldItems[prefix], newItems[prefix])) prefix++;
|
|
17963
|
+
let oldSuffix = oldItems.length - 1;
|
|
17964
|
+
let newSuffix = newItems.length - 1;
|
|
17965
|
+
while (oldSuffix >= prefix && newSuffix >= prefix && _univerjs_core.Tools.diffValue(oldItems[oldSuffix], newItems[newSuffix])) {
|
|
17966
|
+
oldSuffix--;
|
|
17967
|
+
newSuffix--;
|
|
17968
|
+
}
|
|
17969
|
+
for (let index = oldSuffix; index >= prefix; index--) actions.push(jsonX.removeOp([...path, index], oldItems[index]));
|
|
17970
|
+
for (let index = prefix; index <= newSuffix; index++) actions.push(jsonX.insertOp([...path, index], newItems[index]));
|
|
17971
|
+
}
|
|
17972
|
+
function isPlainObject(value) {
|
|
17973
|
+
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
17974
|
+
}
|
|
17975
|
+
function isEmptyArrayEquivalent(oldValue, newValue) {
|
|
17976
|
+
return oldValue == null && Array.isArray(newValue) && newValue.length === 0 || newValue == null && Array.isArray(oldValue) && oldValue.length === 0;
|
|
16905
17977
|
}
|
|
16906
17978
|
function getTargetSelectionRange(target, paragraph) {
|
|
16907
17979
|
if (!target) return getParagraphMenuTargetRange(paragraph);
|
|
@@ -16954,7 +18026,9 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
16954
18026
|
const openMenuRef = (0, react.useRef)(() => void 0);
|
|
16955
18027
|
const hoverOpenSchedulerRef = (0, react.useRef)(createParagraphMenuHoverOpenScheduler(() => openMenuRef.current()));
|
|
16956
18028
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
18029
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
16957
18030
|
const docSelectionManagerService = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocSelectionManagerService);
|
|
18031
|
+
const direction = (0, _univerjs_ui.useObservable)(localeService.direction$, "ltr");
|
|
16958
18032
|
const docClipboardService = (0, _univerjs_ui.useDependency)(IDocClipboardService);
|
|
16959
18033
|
const docContentInsertService = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocContentInsertService);
|
|
16960
18034
|
const docBlockMoveValidatorService = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocBlockMoveValidatorService);
|
|
@@ -17002,13 +18076,18 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
17002
18076
|
bottom: 0
|
|
17003
18077
|
}), []);
|
|
17004
18078
|
const updateAnchorRect = () => {
|
|
17005
|
-
var _anchorRef$current, _boundingRect$left, _boundingRect$right, _boundingRect$top, _boundingRect$bottom;
|
|
18079
|
+
var _anchorRef$current, _boundingRect$left, _boundingRect$right, _anchorRef$current$ow, _anchorRef$current2, _boundingRect$top, _boundingRect$bottom;
|
|
17006
18080
|
const boundingRect = (_anchorRef$current = anchorRef.current) === null || _anchorRef$current === void 0 ? void 0 : _anchorRef$current.getBoundingClientRect();
|
|
17007
18081
|
const left = ((_boundingRect$left = boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.left) !== null && _boundingRect$left !== void 0 ? _boundingRect$left : 0) - 4;
|
|
17008
|
-
|
|
18082
|
+
const right = (_boundingRect$right = boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.right) !== null && _boundingRect$right !== void 0 ? _boundingRect$right : 0;
|
|
18083
|
+
setMenuDirection(getParagraphMenuPopupDirection(left, 212, 8, {
|
|
18084
|
+
anchorRight: right,
|
|
18085
|
+
direction,
|
|
18086
|
+
viewportWidth: (_anchorRef$current$ow = (_anchorRef$current2 = anchorRef.current) === null || _anchorRef$current2 === void 0 || (_anchorRef$current2 = _anchorRef$current2.ownerDocument.defaultView) === null || _anchorRef$current2 === void 0 ? void 0 : _anchorRef$current2.innerWidth) !== null && _anchorRef$current$ow !== void 0 ? _anchorRef$current$ow : window.innerWidth
|
|
18087
|
+
}));
|
|
17009
18088
|
const nextAnchorRect = {
|
|
17010
18089
|
left,
|
|
17011
|
-
right
|
|
18090
|
+
right,
|
|
17012
18091
|
top: (_boundingRect$top = boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.top) !== null && _boundingRect$top !== void 0 ? _boundingRect$top : 0,
|
|
17013
18092
|
bottom: (_boundingRect$bottom = boundingRect === null || boundingRect === void 0 ? void 0 : boundingRect.bottom) !== null && _boundingRect$bottom !== void 0 ? _boundingRect$bottom : 0
|
|
17014
18093
|
};
|
|
@@ -17090,7 +18169,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
17090
18169
|
if (!latestTarget || latestTarget.kind !== "blockRange" || !latestTarget.blockRange || !(doc === null || doc === void 0 ? void 0 : doc.getBody())) return null;
|
|
17091
18170
|
const previousBody = doc.getBody();
|
|
17092
18171
|
const { body, range } = unwrapBlockRangeBody(previousBody, latestTarget.blockRange);
|
|
17093
|
-
const actions =
|
|
18172
|
+
const actions = buildUnwrapBlockRangeActions(previousBody, body, latestTarget.blockRange);
|
|
17094
18173
|
const segmentId = (_activeParagraphBound = activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.segmentId) !== null && _activeParagraphBound !== void 0 ? _activeParagraphBound : "";
|
|
17095
18174
|
if (!await commandService.executeCommand(_univerjs_docs.RichTextEditingMutation.id, {
|
|
17096
18175
|
unitId: popup.unitId,
|
|
@@ -17135,14 +18214,12 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
17135
18214
|
}
|
|
17136
18215
|
if (commandId === "doc.menu.paragraph-t.insert-below.command") {
|
|
17137
18216
|
if (!(latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.moveRange)) return;
|
|
17138
|
-
|
|
18217
|
+
docContentInsertService.setInsertRange({
|
|
18218
|
+
unitId: popup.unitId,
|
|
17139
18219
|
startOffset: latestTarget.moveRange.endOffset,
|
|
17140
18220
|
endOffset: latestTarget.moveRange.endOffset,
|
|
17141
|
-
collapsed: true,
|
|
17142
18221
|
segmentId: activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.segmentId
|
|
17143
|
-
};
|
|
17144
|
-
replaceSelection(insertRange);
|
|
17145
|
-
await commandService.executeCommand(BreakLineCommand.id, { textRange: insertRange });
|
|
18222
|
+
});
|
|
17146
18223
|
const wrappedCommandId = typeof (commandParams === null || commandParams === void 0 ? void 0 : commandParams.commandId) === "string" ? commandParams.commandId : void 0;
|
|
17147
18224
|
if (wrappedCommandId) await commandService.executeCommand(wrappedCommandId);
|
|
17148
18225
|
finishParagraphMenuCommand(docParagraphMenuService, layoutService, handleHideMenu);
|
|
@@ -17447,6 +18524,222 @@ function DragHandleDotsIcon() {
|
|
|
17447
18524
|
});
|
|
17448
18525
|
}
|
|
17449
18526
|
|
|
18527
|
+
//#endregion
|
|
18528
|
+
//#region src/views/section-setting/use-section-setting.ts
|
|
18529
|
+
const DEFAULT_SECTION_COLUMN_GAP = 18;
|
|
18530
|
+
function getCommonValue(values) {
|
|
18531
|
+
const first = values[0];
|
|
18532
|
+
return values.every((value) => value === first) ? first : void 0;
|
|
18533
|
+
}
|
|
18534
|
+
function getSectionColumnCount(section) {
|
|
18535
|
+
var _section$columnProper;
|
|
18536
|
+
return ((_section$columnProper = section.columnProperties) === null || _section$columnProper === void 0 ? void 0 : _section$columnProper.length) || 1;
|
|
18537
|
+
}
|
|
18538
|
+
function getSectionColumnGap(section) {
|
|
18539
|
+
var _section$columnProper2, _section$columnProper3;
|
|
18540
|
+
return (_section$columnProper2 = (_section$columnProper3 = section.columnProperties) === null || _section$columnProper3 === void 0 || (_section$columnProper3 = _section$columnProper3[0]) === null || _section$columnProper3 === void 0 ? void 0 : _section$columnProper3.paddingEnd) !== null && _section$columnProper2 !== void 0 ? _section$columnProper2 : DEFAULT_SECTION_COLUMN_GAP;
|
|
18541
|
+
}
|
|
18542
|
+
function getSectionSettingValues(sections) {
|
|
18543
|
+
return {
|
|
18544
|
+
columnCount: getCommonValue(sections.map(getSectionColumnCount)),
|
|
18545
|
+
columnGap: getCommonValue(sections.map(getSectionColumnGap)),
|
|
18546
|
+
separatorType: getCommonValue(sections.map((section) => {
|
|
18547
|
+
var _section$columnSepara;
|
|
18548
|
+
return (_section$columnSepara = section.columnSeparatorType) !== null && _section$columnSepara !== void 0 ? _section$columnSepara : _univerjs_core.ColumnSeparatorType.NONE;
|
|
18549
|
+
})),
|
|
18550
|
+
sectionType: getCommonValue(sections.map((section) => {
|
|
18551
|
+
var _section$sectionType;
|
|
18552
|
+
return (_section$sectionType = section.sectionType) !== null && _section$sectionType !== void 0 ? _section$sectionType : _univerjs_core.SectionType.SECTION_TYPE_UNSPECIFIED;
|
|
18553
|
+
}))
|
|
18554
|
+
};
|
|
18555
|
+
}
|
|
18556
|
+
function createSectionColumnUpdates(sections, documentStyle, change) {
|
|
18557
|
+
return sections.map((section) => {
|
|
18558
|
+
const columnCount = "columnCount" in change ? change.columnCount : getSectionColumnCount(section);
|
|
18559
|
+
const columnGap = "columnGap" in change ? change.columnGap : getSectionColumnGap(section);
|
|
18560
|
+
return {
|
|
18561
|
+
sectionId: section.sectionId,
|
|
18562
|
+
config: { columnProperties: (0, _univerjs_docs.createSectionColumnProperties)(documentStyle, section, columnCount, columnGap) }
|
|
18563
|
+
};
|
|
18564
|
+
});
|
|
18565
|
+
}
|
|
18566
|
+
function getSelectedSections(documentDataModel, ranges) {
|
|
18567
|
+
const body = documentDataModel.getBody();
|
|
18568
|
+
if (!body || ranges.length === 0 || ranges.some((range) => Boolean(range.segmentId))) return [];
|
|
18569
|
+
const sections = (0, _univerjs_docs.getTopLevelSectionBreaks)(body);
|
|
18570
|
+
return sections.filter((section, index) => {
|
|
18571
|
+
const sectionStart = index === 0 ? 0 : sections[index - 1].startIndex + 1;
|
|
18572
|
+
return ranges.some((range) => {
|
|
18573
|
+
const rangeStart = Math.min(range.startOffset, range.endOffset);
|
|
18574
|
+
const rangeEnd = Math.max(range.startOffset, range.endOffset);
|
|
18575
|
+
return rangeStart <= section.startIndex && rangeEnd >= sectionStart;
|
|
18576
|
+
});
|
|
18577
|
+
});
|
|
18578
|
+
}
|
|
18579
|
+
function useSectionSetting() {
|
|
18580
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
18581
|
+
const instanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
18582
|
+
const selectionManager = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocSelectionManagerService);
|
|
18583
|
+
const documentDataModel = (0, _univerjs_ui.useObservable)((0, react.useMemo)(() => instanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC), [instanceService]));
|
|
18584
|
+
(0, _univerjs_ui.useObservable)(selectionManager.textSelection$);
|
|
18585
|
+
(0, _univerjs_ui.useObservable)(documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.change$);
|
|
18586
|
+
const ranges = selectionManager.getDocRanges();
|
|
18587
|
+
const sections = (documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getDocumentStyle().documentFlavor) === _univerjs_core.DocumentFlavor.TRADITIONAL ? getSelectedSections(documentDataModel, ranges) : [];
|
|
18588
|
+
const values = getSectionSettingValues(sections);
|
|
18589
|
+
const update = (updates) => {
|
|
18590
|
+
if (!documentDataModel || updates.length === 0) return Promise.resolve(false);
|
|
18591
|
+
return commandService.executeCommand(_univerjs_docs.UpdateDocumentSectionCommand.id, {
|
|
18592
|
+
unitId: documentDataModel.getUnitId(),
|
|
18593
|
+
updates
|
|
18594
|
+
});
|
|
18595
|
+
};
|
|
18596
|
+
const updateAll = (config) => update(sections.map((section) => ({
|
|
18597
|
+
sectionId: section.sectionId,
|
|
18598
|
+
config
|
|
18599
|
+
})));
|
|
18600
|
+
return {
|
|
18601
|
+
valid: Boolean(documentDataModel && sections.length > 0),
|
|
18602
|
+
selectedCount: sections.length,
|
|
18603
|
+
...values,
|
|
18604
|
+
setColumnCount(value) {
|
|
18605
|
+
const next = Math.max(1, Math.round(value));
|
|
18606
|
+
return update(documentDataModel ? createSectionColumnUpdates(sections, documentDataModel.getDocumentStyle(), { columnCount: next }) : []);
|
|
18607
|
+
},
|
|
18608
|
+
setColumnGap(value) {
|
|
18609
|
+
const next = Math.max(0, value);
|
|
18610
|
+
return update(documentDataModel ? createSectionColumnUpdates(sections, documentDataModel.getDocumentStyle(), { columnGap: next }) : []);
|
|
18611
|
+
},
|
|
18612
|
+
setSeparatorType(value) {
|
|
18613
|
+
return updateAll({ columnSeparatorType: value });
|
|
18614
|
+
},
|
|
18615
|
+
setSectionType(value) {
|
|
18616
|
+
return updateAll({ sectionType: value });
|
|
18617
|
+
}
|
|
18618
|
+
};
|
|
18619
|
+
}
|
|
18620
|
+
|
|
18621
|
+
//#endregion
|
|
18622
|
+
//#region src/views/section-setting/Setting.tsx
|
|
18623
|
+
function SettingRow(props) {
|
|
18624
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
18625
|
+
className: "univer-grid univer-min-h-8 univer-items-center univer-gap-3",
|
|
18626
|
+
style: { gridTemplateColumns: "minmax(0, 1fr) minmax(140px, 160px)" },
|
|
18627
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
18628
|
+
className: "univer-min-w-0 univer-text-xs univer-leading-5 univer-text-gray-900 dark:!univer-text-gray-100",
|
|
18629
|
+
children: props.label
|
|
18630
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
18631
|
+
className: "univer-w-full univer-min-w-0",
|
|
18632
|
+
children: props.children
|
|
18633
|
+
})]
|
|
18634
|
+
});
|
|
18635
|
+
}
|
|
18636
|
+
function SectionSetting() {
|
|
18637
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
18638
|
+
const controller = (0, _univerjs_ui.useDependency)(DocSectionSettingController);
|
|
18639
|
+
const setting = useSectionSetting();
|
|
18640
|
+
(0, react.useEffect)(() => {
|
|
18641
|
+
if (!setting.valid) controller.closePanel();
|
|
18642
|
+
}, [controller, setting.valid]);
|
|
18643
|
+
if (!setting.valid) return null;
|
|
18644
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
18645
|
+
className: "univer-box-border univer-w-full",
|
|
18646
|
+
children: [setting.selectedCount > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
18647
|
+
className: "univer-mb-4 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-300",
|
|
18648
|
+
children: localeService.t("docs-ui.doc.sectionSetting.selectedSections", String(setting.selectedCount))
|
|
18649
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
18650
|
+
className: "univer-grid univer-gap-3",
|
|
18651
|
+
children: [
|
|
18652
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
18653
|
+
label: localeService.t("docs-ui.doc.sectionSetting.columnCount"),
|
|
18654
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
18655
|
+
className: "univer-w-full",
|
|
18656
|
+
min: 1,
|
|
18657
|
+
max: 12,
|
|
18658
|
+
step: 1,
|
|
18659
|
+
precision: 0,
|
|
18660
|
+
value: setting.columnCount,
|
|
18661
|
+
onChange: (value) => value != null && setting.setColumnCount(value)
|
|
18662
|
+
})
|
|
18663
|
+
}),
|
|
18664
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
18665
|
+
label: `${localeService.t("docs-ui.doc.sectionSetting.columnGap")}(px)`,
|
|
18666
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
18667
|
+
className: "univer-w-full",
|
|
18668
|
+
min: 0,
|
|
18669
|
+
max: 1e3,
|
|
18670
|
+
step: 1,
|
|
18671
|
+
precision: 1,
|
|
18672
|
+
value: setting.columnGap,
|
|
18673
|
+
onChange: (value) => value != null && setting.setColumnGap(value)
|
|
18674
|
+
})
|
|
18675
|
+
}),
|
|
18676
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
18677
|
+
label: localeService.t("docs-ui.doc.sectionSetting.columnSeparator"),
|
|
18678
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
|
|
18679
|
+
className: "univer-w-full",
|
|
18680
|
+
value: setting.separatorType == null ? "" : String(setting.separatorType),
|
|
18681
|
+
options: [{
|
|
18682
|
+
label: localeService.t("docs-ui.doc.sectionSetting.none"),
|
|
18683
|
+
value: String(_univerjs_core.ColumnSeparatorType.NONE)
|
|
18684
|
+
}, {
|
|
18685
|
+
label: localeService.t("docs-ui.doc.sectionSetting.betweenColumns"),
|
|
18686
|
+
value: String(_univerjs_core.ColumnSeparatorType.BETWEEN_EACH_COLUMN)
|
|
18687
|
+
}],
|
|
18688
|
+
onChange: (value) => setting.setSeparatorType(Number(value))
|
|
18689
|
+
})
|
|
18690
|
+
}),
|
|
18691
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingRow, {
|
|
18692
|
+
label: localeService.t("docs-ui.doc.sectionSetting.sectionStart"),
|
|
18693
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
|
|
18694
|
+
className: "univer-w-full",
|
|
18695
|
+
value: setting.sectionType == null ? "" : String(setting.sectionType),
|
|
18696
|
+
options: [
|
|
18697
|
+
{
|
|
18698
|
+
label: localeService.t("docs-ui.doc.sectionSetting.unspecified"),
|
|
18699
|
+
value: String(_univerjs_core.SectionType.SECTION_TYPE_UNSPECIFIED)
|
|
18700
|
+
},
|
|
18701
|
+
{
|
|
18702
|
+
label: localeService.t("docs-ui.doc.sectionSetting.continuous"),
|
|
18703
|
+
value: String(_univerjs_core.SectionType.CONTINUOUS)
|
|
18704
|
+
},
|
|
18705
|
+
{
|
|
18706
|
+
label: localeService.t("docs-ui.doc.sectionSetting.nextPage"),
|
|
18707
|
+
value: String(_univerjs_core.SectionType.NEXT_PAGE)
|
|
18708
|
+
},
|
|
18709
|
+
{
|
|
18710
|
+
label: localeService.t("docs-ui.doc.sectionSetting.evenPage"),
|
|
18711
|
+
value: String(_univerjs_core.SectionType.EVEN_PAGE)
|
|
18712
|
+
},
|
|
18713
|
+
{
|
|
18714
|
+
label: localeService.t("docs-ui.doc.sectionSetting.oddPage"),
|
|
18715
|
+
value: String(_univerjs_core.SectionType.ODD_PAGE)
|
|
18716
|
+
}
|
|
18717
|
+
],
|
|
18718
|
+
onChange: (value) => setting.setSectionType(Number(value))
|
|
18719
|
+
})
|
|
18720
|
+
})
|
|
18721
|
+
]
|
|
18722
|
+
})]
|
|
18723
|
+
});
|
|
18724
|
+
}
|
|
18725
|
+
|
|
18726
|
+
//#endregion
|
|
18727
|
+
//#region src/views/section-setting/index.tsx
|
|
18728
|
+
function SectionSettingIndex() {
|
|
18729
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
18730
|
+
(0, _univerjs_ui.useObservable)((0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService).currentLocale$);
|
|
18731
|
+
const [key, setKey] = (0, react.useState)(() => (0, _univerjs_core.generateRandomId)(4));
|
|
18732
|
+
(0, react.useEffect)(() => {
|
|
18733
|
+
const disposable = commandService.onCommandExecuted((info) => {
|
|
18734
|
+
if (info.id === _univerjs_docs.SetTextSelectionsOperation.id) {
|
|
18735
|
+
if (info.params.ranges.length > 0) setKey((0, _univerjs_core.generateRandomId)(4));
|
|
18736
|
+
} else if (info.id === _univerjs_docs.RichTextEditingMutation.id) setKey((0, _univerjs_core.generateRandomId)(4));
|
|
18737
|
+
});
|
|
18738
|
+
return () => disposable.dispose();
|
|
18739
|
+
}, [commandService]);
|
|
18740
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SectionSetting, {}, key);
|
|
18741
|
+
}
|
|
18742
|
+
|
|
17450
18743
|
//#endregion
|
|
17451
18744
|
//#region src/views/table/create/TableCreate.tsx
|
|
17452
18745
|
const DocCreateTableConfirm = ({ handleRowColChange, tableCreateParams }) => {
|
|
@@ -17550,6 +18843,8 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
17550
18843
|
KeyboardIcon: _univerjs_icons.KeyboardIcon,
|
|
17551
18844
|
LeftInsertColumnDoubleIcon: _univerjs_icons.LeftInsertColumnDoubleIcon,
|
|
17552
18845
|
LeftJustifyingIcon: _univerjs_icons.LeftJustifyingIcon,
|
|
18846
|
+
LineIndentDecreaseIcon: _univerjs_icons.LineIndentDecreaseIcon,
|
|
18847
|
+
LineIndentIncreaseIcon: _univerjs_icons.LineIndentIncreaseIcon,
|
|
17553
18848
|
MenuIcon: _univerjs_icons.MenuIcon,
|
|
17554
18849
|
TextTypeIcon: _univerjs_icons.TextTypeIcon,
|
|
17555
18850
|
NoColorDoubleIcon: _univerjs_icons.NoColorDoubleIcon,
|
|
@@ -17601,6 +18896,7 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
17601
18896
|
_registerComponents() {
|
|
17602
18897
|
if (!this._componentManager.get("COMPONENT_DOC_HEADER_FOOTER_PANEL")) this.disposeWithMe(this._componentManager.register(COMPONENT_DOC_HEADER_FOOTER_PANEL, DocHeaderFooterPanel));
|
|
17603
18898
|
this.disposeWithMe(this._componentManager.register(paragraphSettingIndexKey, ParagraphSettingIndex));
|
|
18899
|
+
this.disposeWithMe(this._componentManager.register(DOC_SECTION_SETTING_COMPONENT, SectionSettingIndex));
|
|
17604
18900
|
[
|
|
17605
18901
|
[BULLET_LIST_TYPE_COMPONENT, BulletListTypePicker],
|
|
17606
18902
|
[ORDER_LIST_TYPE_COMPONENT, OrderListTypePicker],
|
|
@@ -17838,48 +19134,33 @@ var TextBubbleShape = class TextBubbleShape extends _univerjs_engine_render.Shap
|
|
|
17838
19134
|
//#region src/controllers/doc-header-footer.controller.ts
|
|
17839
19135
|
const HEADER_FOOTER_STROKE_COLOR = "rgba(58, 96, 247, 1)";
|
|
17840
19136
|
const HEADER_FOOTER_FILL_COLOR = "rgba(58, 96, 247, 0.08)";
|
|
17841
|
-
function checkCreateHeaderFooterType(viewModel, editArea, segmentPage) {
|
|
17842
|
-
const {
|
|
17843
|
-
const { defaultHeaderId, defaultFooterId, evenPageHeaderId, evenPageFooterId, firstPageHeaderId, firstPageFooterId, evenAndOddHeaders, useFirstPageHeaderFooter } =
|
|
17844
|
-
|
|
17845
|
-
|
|
17846
|
-
|
|
17847
|
-
|
|
17848
|
-
|
|
17849
|
-
|
|
17850
|
-
|
|
17851
|
-
|
|
17852
|
-
|
|
17853
|
-
|
|
17854
|
-
|
|
17855
|
-
|
|
17856
|
-
|
|
17857
|
-
|
|
17858
|
-
|
|
17859
|
-
|
|
17860
|
-
|
|
17861
|
-
|
|
17862
|
-
|
|
17863
|
-
|
|
17864
|
-
|
|
17865
|
-
|
|
17866
|
-
|
|
17867
|
-
|
|
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
|
-
}
|
|
19137
|
+
function checkCreateHeaderFooterType(viewModel, editArea, segmentPage, page) {
|
|
19138
|
+
const { sectionId, config } = getDocPageSectionContext(viewModel.getDataModel().getSnapshot(), page);
|
|
19139
|
+
const { defaultHeaderId, defaultFooterId, evenPageHeaderId, evenPageFooterId, firstPageHeaderId, firstPageFooterId, evenAndOddHeaders, useFirstPageHeaderFooter } = config;
|
|
19140
|
+
const isFirstPage = page ? page.pageNumber === page.pageNumberStart : segmentPage === 0;
|
|
19141
|
+
const isEvenPage = page ? page.pageNumber % 2 === 0 : segmentPage % 2 === 1;
|
|
19142
|
+
if (editArea === _univerjs_engine_render.DocumentEditArea.BODY) return {
|
|
19143
|
+
createType: null,
|
|
19144
|
+
headerFooterId: null,
|
|
19145
|
+
sectionId
|
|
19146
|
+
};
|
|
19147
|
+
const isHeader = editArea === _univerjs_engine_render.DocumentEditArea.HEADER;
|
|
19148
|
+
if (!isHeader && editArea !== _univerjs_engine_render.DocumentEditArea.FOOTER) throw new Error(`Invalid editArea: ${editArea}`);
|
|
19149
|
+
const variants = isHeader ? {
|
|
19150
|
+
first: [firstPageHeaderId, _univerjs_docs.HeaderFooterType.FIRST_PAGE_HEADER],
|
|
19151
|
+
even: [evenPageHeaderId, _univerjs_docs.HeaderFooterType.EVEN_PAGE_HEADER],
|
|
19152
|
+
default: [defaultHeaderId, _univerjs_docs.HeaderFooterType.DEFAULT_HEADER]
|
|
19153
|
+
} : {
|
|
19154
|
+
first: [firstPageFooterId, _univerjs_docs.HeaderFooterType.FIRST_PAGE_FOOTER],
|
|
19155
|
+
even: [evenPageFooterId, _univerjs_docs.HeaderFooterType.EVEN_PAGE_FOOTER],
|
|
19156
|
+
default: [defaultFooterId, _univerjs_docs.HeaderFooterType.DEFAULT_FOOTER]
|
|
19157
|
+
};
|
|
19158
|
+
const [headerFooterId, createType] = useFirstPageHeaderFooter === _univerjs_core.BooleanNumber.TRUE && isFirstPage ? variants.first : evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE && isEvenPage ? variants.even : variants.default;
|
|
19159
|
+
return {
|
|
19160
|
+
createType: headerFooterId ? null : createType,
|
|
19161
|
+
headerFooterId: headerFooterId !== null && headerFooterId !== void 0 ? headerFooterId : null,
|
|
19162
|
+
sectionId
|
|
19163
|
+
};
|
|
17883
19164
|
}
|
|
17884
19165
|
let DocHeaderFooterController = class DocHeaderFooterController extends _univerjs_core.Disposable {
|
|
17885
19166
|
constructor(_context, _commandService, _editorService, _instanceSrv, _renderManagerService, _docSkeletonManagerService, _docSelectionRenderService, _localeService) {
|
|
@@ -17925,6 +19206,7 @@ let DocHeaderFooterController = class DocHeaderFooterController extends _univerj
|
|
|
17925
19206
|
_initialMain(unitId) {
|
|
17926
19207
|
const { document } = neoGetDocObject(this._context);
|
|
17927
19208
|
this.disposeWithMe(document.onDblclick$.subscribeEvent(async (evt) => {
|
|
19209
|
+
var _skeleton$getSkeleton;
|
|
17928
19210
|
if (this._isEditorReadOnly(unitId)) return;
|
|
17929
19211
|
if (!this._isTraditionalMode()) return;
|
|
17930
19212
|
const { offsetX, offsetY } = evt;
|
|
@@ -17935,9 +19217,9 @@ let DocHeaderFooterController = class DocHeaderFooterController extends _univerj
|
|
|
17935
19217
|
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
17936
19218
|
const preEditArea = viewModel.getEditArea();
|
|
17937
19219
|
const { editArea, pageNumber } = skeleton.findEditAreaByCoord(coord, pageLayoutType, pageMarginLeft, pageMarginTop);
|
|
17938
|
-
if (preEditArea === editArea) return;
|
|
19220
|
+
if (preEditArea === editArea && (editArea === _univerjs_engine_render.DocumentEditArea.BODY || this._docSelectionRenderService.getSegmentPage() === pageNumber)) return;
|
|
17939
19221
|
viewModel.setEditArea(editArea);
|
|
17940
|
-
const { createType, headerFooterId } = checkCreateHeaderFooterType(viewModel, editArea, pageNumber);
|
|
19222
|
+
const { createType, headerFooterId, sectionId } = checkCreateHeaderFooterType(viewModel, editArea, pageNumber, (_skeleton$getSkeleton = skeleton.getSkeletonData()) === null || _skeleton$getSkeleton === void 0 ? void 0 : _skeleton$getSkeleton.pages[pageNumber]);
|
|
17941
19223
|
if (editArea === _univerjs_engine_render.DocumentEditArea.BODY) {
|
|
17942
19224
|
this._docSelectionRenderService.setSegment("");
|
|
17943
19225
|
this._docSelectionRenderService.setSegmentPage(-1);
|
|
@@ -17949,7 +19231,8 @@ let DocHeaderFooterController = class DocHeaderFooterController extends _univerj
|
|
|
17949
19231
|
await this._commandService.executeCommand(CoreHeaderFooterCommand.id, {
|
|
17950
19232
|
unitId,
|
|
17951
19233
|
createType,
|
|
17952
|
-
segmentId
|
|
19234
|
+
segmentId,
|
|
19235
|
+
sectionId
|
|
17953
19236
|
});
|
|
17954
19237
|
} else if (headerFooterId != null) {
|
|
17955
19238
|
this._docSelectionRenderService.setSegment(headerFooterId);
|
|
@@ -18561,13 +19844,10 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
18561
19844
|
line: newLine,
|
|
18562
19845
|
offsetLeft
|
|
18563
19846
|
};
|
|
18564
|
-
if (this._isColumnGroupContentPage(page))
|
|
18565
|
-
const exitTarget = this._getColumnGroupExitLineTarget(page, direction, offsetLeft);
|
|
18566
|
-
if (exitTarget != null) return exitTarget;
|
|
18567
|
-
}
|
|
19847
|
+
if (this._isColumnGroupContentPage(page)) return this._getColumnGroupExitLineTarget(page, direction, offsetLeft);
|
|
18568
19848
|
if (this._isTableCellContentPage(page)) return this._getAdjacentTableCellLineTarget(page, direction, offsetLeft);
|
|
18569
19849
|
const skeleton = page.parent;
|
|
18570
|
-
if (skeleton == null) return;
|
|
19850
|
+
if ((skeleton === null || skeleton === void 0 ? void 0 : skeleton.pages) == null) return;
|
|
18571
19851
|
const currentPageIndex = skeleton.pages.indexOf(page);
|
|
18572
19852
|
if (currentPageIndex === -1) return;
|
|
18573
19853
|
if (direction === true) {
|
|
@@ -19194,13 +20474,14 @@ DocIMEInputController = __decorate([
|
|
|
19194
20474
|
//#endregion
|
|
19195
20475
|
//#region src/controllers/render-controllers/doc-input.controller.ts
|
|
19196
20476
|
let DocInputController = class DocInputController extends _univerjs_core.Disposable {
|
|
19197
|
-
constructor(_context, _docSelectionRenderService, _docSkeletonManagerService, _commandService, _docMenuStyleService) {
|
|
20477
|
+
constructor(_context, _docSelectionRenderService, _docSkeletonManagerService, _commandService, _docMenuStyleService, _embedInteractionBoundaryService, _embedRuntimeFocusCoordinator) {
|
|
19198
20478
|
super();
|
|
19199
20479
|
this._context = _context;
|
|
19200
20480
|
this._docSelectionRenderService = _docSelectionRenderService;
|
|
19201
20481
|
this._docSkeletonManagerService = _docSkeletonManagerService;
|
|
19202
20482
|
this._commandService = _commandService;
|
|
19203
20483
|
this._docMenuStyleService = _docMenuStyleService;
|
|
20484
|
+
this._embedRuntimeFocusCoordinator = _embedRuntimeFocusCoordinator;
|
|
19204
20485
|
_defineProperty(this, "_onInputSubscription", void 0);
|
|
19205
20486
|
this._init();
|
|
19206
20487
|
}
|
|
@@ -19220,6 +20501,7 @@ let DocInputController = class DocInputController extends _univerjs_core.Disposa
|
|
|
19220
20501
|
const { event, content = "", activeRange } = config;
|
|
19221
20502
|
const e = event;
|
|
19222
20503
|
if (e.defaultPrevented) return;
|
|
20504
|
+
if (!_univerjs_core.SHEET_EDITOR_UNITS.includes(unitId) && this._isEmbedChildInputActive(unitId, e)) return;
|
|
19223
20505
|
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
19224
20506
|
if (e.data == null || skeleton == null || activeRange == null) return;
|
|
19225
20507
|
const { segmentId } = activeRange;
|
|
@@ -19256,12 +20538,21 @@ let DocInputController = class DocInputController extends _univerjs_core.Disposa
|
|
|
19256
20538
|
if (content === " ") await this._commandService.executeCommand(AfterSpaceCommand.id);
|
|
19257
20539
|
});
|
|
19258
20540
|
}
|
|
20541
|
+
_isEmbedChildInputActive(unitId, event) {
|
|
20542
|
+
var _this$_embedRuntimeFo, _this$_embedRuntimeFo2, _this$_embedRuntimeFo3;
|
|
20543
|
+
if ((_this$_embedRuntimeFo = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo === void 0 ? void 0 : _this$_embedRuntimeFo.isChildUnitRuntimeEvent(unitId, event.target, event)) return false;
|
|
20544
|
+
if ((_this$_embedRuntimeFo2 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo2 === void 0 ? void 0 : _this$_embedRuntimeFo2.isChildUnitInActiveSession(unitId)) return false;
|
|
20545
|
+
if ((_this$_embedRuntimeFo3 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo3 === void 0 ? void 0 : _this$_embedRuntimeFo3.shouldSuppressHostInteraction(unitId, event.target, event)) return true;
|
|
20546
|
+
return false;
|
|
20547
|
+
}
|
|
19259
20548
|
};
|
|
19260
20549
|
DocInputController = __decorate([
|
|
19261
20550
|
__decorateParam(1, (0, _univerjs_core.Inject)(DocSelectionRenderService)),
|
|
19262
20551
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_docs.DocSkeletonManagerService)),
|
|
19263
20552
|
__decorateParam(3, _univerjs_core.ICommandService),
|
|
19264
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(DocMenuStyleService))
|
|
20553
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(DocMenuStyleService)),
|
|
20554
|
+
__decorateParam(5, (0, _univerjs_core.Optional)(IDocEmbedInteractionBoundaryService)),
|
|
20555
|
+
__decorateParam(6, (0, _univerjs_core.Optional)(IDocEmbedRuntimeFocusCoordinator))
|
|
19265
20556
|
], DocInputController);
|
|
19266
20557
|
|
|
19267
20558
|
//#endregion
|
|
@@ -19289,7 +20580,7 @@ DocResizeRenderController = __decorate([__decorateParam(1, (0, _univerjs_core.In
|
|
|
19289
20580
|
//#endregion
|
|
19290
20581
|
//#region src/controllers/render-controllers/doc-selection-render.controller.ts
|
|
19291
20582
|
let DocSelectionRenderController = class DocSelectionRenderController extends _univerjs_core.Disposable {
|
|
19292
|
-
constructor(_context, _commandService, _editorService, _instanceSrv, _docSelectionRenderService, _docSkeletonManagerService, _docSelectionManagerService) {
|
|
20583
|
+
constructor(_context, _commandService, _editorService, _instanceSrv, _docSelectionRenderService, _docSkeletonManagerService, _docSelectionManagerService, _embedInteractionBoundaryService, _embedRuntimeFocusCoordinator) {
|
|
19293
20584
|
super();
|
|
19294
20585
|
this._context = _context;
|
|
19295
20586
|
this._commandService = _commandService;
|
|
@@ -19298,6 +20589,7 @@ let DocSelectionRenderController = class DocSelectionRenderController extends _u
|
|
|
19298
20589
|
this._docSelectionRenderService = _docSelectionRenderService;
|
|
19299
20590
|
this._docSkeletonManagerService = _docSkeletonManagerService;
|
|
19300
20591
|
this._docSelectionManagerService = _docSelectionManagerService;
|
|
20592
|
+
this._embedRuntimeFocusCoordinator = _embedRuntimeFocusCoordinator;
|
|
19301
20593
|
_defineProperty(this, "_loadedMap", /* @__PURE__ */ new WeakSet());
|
|
19302
20594
|
this._initialize();
|
|
19303
20595
|
}
|
|
@@ -19329,6 +20621,7 @@ let DocSelectionRenderController = class DocSelectionRenderController extends _u
|
|
|
19329
20621
|
_syncSelection() {
|
|
19330
20622
|
this.disposeWithMe(this._docSelectionRenderService.textSelectionInner$.subscribe((params) => {
|
|
19331
20623
|
if (params == null) return;
|
|
20624
|
+
if (!(0, _univerjs_core.isInternalEditorID)(this._context.unitId) && this._isEmbedChildInteractionActive(this._context.unitId)) return;
|
|
19332
20625
|
this._docSelectionManagerService.__replaceTextRangesWithNoRefresh(params, {
|
|
19333
20626
|
unitId: this._context.unitId,
|
|
19334
20627
|
subUnitId: this._context.unitId
|
|
@@ -19347,8 +20640,10 @@ let DocSelectionRenderController = class DocSelectionRenderController extends _u
|
|
|
19347
20640
|
}));
|
|
19348
20641
|
this.disposeWithMe(document.onPointerDown$.subscribeEvent((evt, state) => {
|
|
19349
20642
|
if (this._isEditorReadOnly(unitId)) return;
|
|
20643
|
+
if (this._isEmbedInteractionEvent(evt, unitId)) return;
|
|
19350
20644
|
const docDataModel = this._instanceSrv.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
19351
20645
|
if ((docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getUnitId()) !== unitId) this._instanceSrv.setCurrentUnitForType(unitId);
|
|
20646
|
+
this._instanceSrv.focusUnit(unitId);
|
|
19352
20647
|
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
19353
20648
|
const { offsetX, offsetY } = evt;
|
|
19354
20649
|
const coord = this._getTransformCoordForDocumentOffset(offsetX, offsetY);
|
|
@@ -19381,10 +20676,12 @@ let DocSelectionRenderController = class DocSelectionRenderController extends _u
|
|
|
19381
20676
|
}));
|
|
19382
20677
|
this.disposeWithMe(document.onDblclick$.subscribeEvent((evt) => {
|
|
19383
20678
|
if (this._isEditorReadOnly(unitId)) return;
|
|
20679
|
+
if (this._isEmbedInteractionEvent(evt, unitId)) return;
|
|
19384
20680
|
this._docSelectionRenderService.__handleDblClick(evt);
|
|
19385
20681
|
}));
|
|
19386
20682
|
this.disposeWithMe(document.onTripleClick$.subscribeEvent((evt) => {
|
|
19387
20683
|
if (this._isEditorReadOnly(unitId)) return;
|
|
20684
|
+
if (this._isEmbedInteractionEvent(evt, unitId)) return;
|
|
19388
20685
|
this._docSelectionRenderService.__handleTripleClick(evt);
|
|
19389
20686
|
}));
|
|
19390
20687
|
}
|
|
@@ -19404,6 +20701,19 @@ let DocSelectionRenderController = class DocSelectionRenderController extends _u
|
|
|
19404
20701
|
_setEditorFocus(unitId) {
|
|
19405
20702
|
this._editorService.focus(unitId);
|
|
19406
20703
|
}
|
|
20704
|
+
_isEmbedInteractionEvent(evt, unitId) {
|
|
20705
|
+
var _this$_embedRuntimeFo, _this$_embedRuntimeFo2, _this$_embedRuntimeFo3;
|
|
20706
|
+
if ((0, _univerjs_core.isInternalEditorID)(unitId)) return false;
|
|
20707
|
+
const target = evt.target;
|
|
20708
|
+
if ((_this$_embedRuntimeFo = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo === void 0 ? void 0 : _this$_embedRuntimeFo.isChildUnitRuntimeEvent(unitId, target, evt)) return false;
|
|
20709
|
+
if ((_this$_embedRuntimeFo2 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo2 === void 0 ? void 0 : _this$_embedRuntimeFo2.isChildUnitInActiveSession(unitId)) return false;
|
|
20710
|
+
if ((_this$_embedRuntimeFo3 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo3 === void 0 ? void 0 : _this$_embedRuntimeFo3.shouldSuppressHostInteraction(unitId, target, evt)) return true;
|
|
20711
|
+
return isEmbedInteractionEvent(evt);
|
|
20712
|
+
}
|
|
20713
|
+
_isEmbedChildInteractionActive(unitId) {
|
|
20714
|
+
var _this$_embedRuntimeFo4;
|
|
20715
|
+
return ((_this$_embedRuntimeFo4 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo4 === void 0 ? void 0 : _this$_embedRuntimeFo4.shouldSuppressHostInteraction(unitId)) === true;
|
|
20716
|
+
}
|
|
19407
20717
|
_commandExecutedListener() {
|
|
19408
20718
|
const updateCommandList = [SetDocZoomRatioOperation.id];
|
|
19409
20719
|
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
@@ -19411,6 +20721,7 @@ let DocSelectionRenderController = class DocSelectionRenderController extends _u
|
|
|
19411
20721
|
var _this$_docSelectionMa;
|
|
19412
20722
|
const { unitId: documentId } = command.params;
|
|
19413
20723
|
if (documentId !== ((_this$_docSelectionMa = this._docSelectionManagerService.__getCurrentSelection()) === null || _this$_docSelectionMa === void 0 ? void 0 : _this$_docSelectionMa.unitId)) return;
|
|
20724
|
+
if (this._isEmbedChildInteractionActive(documentId)) return;
|
|
19414
20725
|
this._docSelectionManagerService.refreshSelection();
|
|
19415
20726
|
}
|
|
19416
20727
|
}));
|
|
@@ -19420,6 +20731,7 @@ let DocSelectionRenderController = class DocSelectionRenderController extends _u
|
|
|
19420
20731
|
if (!skeleton) return;
|
|
19421
20732
|
const { unitId } = this._context;
|
|
19422
20733
|
if (!(0, _univerjs_core.isInternalEditorID)(unitId)) {
|
|
20734
|
+
if (this._isEmbedChildInteractionActive(unitId)) return;
|
|
19423
20735
|
this._docSelectionRenderService.focus();
|
|
19424
20736
|
const offset = findFirstCursorOffset(this._context.unit.getSnapshot());
|
|
19425
20737
|
this._docSelectionManagerService.replaceDocRanges([{
|
|
@@ -19439,8 +20751,39 @@ DocSelectionRenderController = __decorate([
|
|
|
19439
20751
|
__decorateParam(3, _univerjs_core.IUniverInstanceService),
|
|
19440
20752
|
__decorateParam(4, (0, _univerjs_core.Inject)(DocSelectionRenderService)),
|
|
19441
20753
|
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_docs.DocSkeletonManagerService)),
|
|
19442
|
-
__decorateParam(6, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService))
|
|
20754
|
+
__decorateParam(6, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService)),
|
|
20755
|
+
__decorateParam(7, (0, _univerjs_core.Optional)(IDocEmbedInteractionBoundaryService)),
|
|
20756
|
+
__decorateParam(8, (0, _univerjs_core.Optional)(IDocEmbedRuntimeFocusCoordinator))
|
|
19443
20757
|
], DocSelectionRenderController);
|
|
20758
|
+
function isEmbedInteractionEvent(evt) {
|
|
20759
|
+
var _document$elementFrom;
|
|
20760
|
+
const target = evt.target;
|
|
20761
|
+
if (typeof Element !== "undefined" && target instanceof Element && target.closest(`[${"data-embed-interaction-boundary-owner"}]`) != null) return true;
|
|
20762
|
+
if (typeof document === "undefined") return false;
|
|
20763
|
+
const point = getEventClientPoint(evt, target);
|
|
20764
|
+
const clientX = point === null || point === void 0 ? void 0 : point.clientX;
|
|
20765
|
+
const clientY = point === null || point === void 0 ? void 0 : point.clientY;
|
|
20766
|
+
if (typeof clientX !== "number" || typeof clientY !== "number" || !Number.isFinite(clientX) || !Number.isFinite(clientY)) return false;
|
|
20767
|
+
if (typeof document.elementFromPoint !== "function") return false;
|
|
20768
|
+
return ((_document$elementFrom = document.elementFromPoint(clientX, clientY)) === null || _document$elementFrom === void 0 ? void 0 : _document$elementFrom.closest(`[${DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE}]`)) != null;
|
|
20769
|
+
}
|
|
20770
|
+
function getEventClientPoint(evt, target) {
|
|
20771
|
+
if (Number.isFinite(evt.clientX) && Number.isFinite(evt.clientY)) return {
|
|
20772
|
+
clientX: evt.clientX,
|
|
20773
|
+
clientY: evt.clientY
|
|
20774
|
+
};
|
|
20775
|
+
if (typeof Element !== "undefined" && target instanceof Element && Number.isFinite(evt.offsetX) && Number.isFinite(evt.offsetY)) {
|
|
20776
|
+
const rect = target.getBoundingClientRect();
|
|
20777
|
+
return {
|
|
20778
|
+
clientX: rect.left + evt.offsetX,
|
|
20779
|
+
clientY: rect.top + evt.offsetY
|
|
20780
|
+
};
|
|
20781
|
+
}
|
|
20782
|
+
if (Number.isFinite(evt.x) && Number.isFinite(evt.y)) return {
|
|
20783
|
+
clientX: evt.x,
|
|
20784
|
+
clientY: evt.y
|
|
20785
|
+
};
|
|
20786
|
+
}
|
|
19444
20787
|
|
|
19445
20788
|
//#endregion
|
|
19446
20789
|
//#region src/controllers/render-controllers/zoom.render-controller.ts
|
|
@@ -19448,7 +20791,7 @@ function shouldHandleDocWheelZoom(event, focusingDoc, _documentFlavor) {
|
|
|
19448
20791
|
return focusingDoc && (event.ctrlKey || event.metaKey);
|
|
19449
20792
|
}
|
|
19450
20793
|
let DocZoomRenderController = class DocZoomRenderController extends _univerjs_core.Disposable {
|
|
19451
|
-
constructor(_context, _contextService, _docSkeletonManagerService, _univerInstanceService, _commandService, _textSelectionManagerService, _editorService, _docPageLayoutService, _renderManagerService, _docViewScaleService) {
|
|
20794
|
+
constructor(_context, _contextService, _docSkeletonManagerService, _univerInstanceService, _commandService, _textSelectionManagerService, _editorService, _docPageLayoutService, _renderManagerService, _docViewScaleService, _embedInteractionBoundaryService) {
|
|
19452
20795
|
super();
|
|
19453
20796
|
this._context = _context;
|
|
19454
20797
|
this._contextService = _contextService;
|
|
@@ -19460,6 +20803,7 @@ let DocZoomRenderController = class DocZoomRenderController extends _univerjs_co
|
|
|
19460
20803
|
this._docPageLayoutService = _docPageLayoutService;
|
|
19461
20804
|
this._renderManagerService = _renderManagerService;
|
|
19462
20805
|
this._docViewScaleService = _docViewScaleService;
|
|
20806
|
+
this._embedInteractionBoundaryService = _embedInteractionBoundaryService;
|
|
19463
20807
|
_defineProperty(this, "_isSheetEditor", false);
|
|
19464
20808
|
_defineProperty(this, "_initTimer", void 0);
|
|
19465
20809
|
_defineProperty(this, "_updateTimer", void 0);
|
|
@@ -19509,14 +20853,21 @@ let DocZoomRenderController = class DocZoomRenderController extends _univerjs_co
|
|
|
19509
20853
|
}));
|
|
19510
20854
|
}
|
|
19511
20855
|
updateViewZoom(zoomRatio, needRefreshSelection = true) {
|
|
19512
|
-
var
|
|
20856
|
+
var _this$_embedInteracti;
|
|
19513
20857
|
const docObject = neoGetDocObject(this._context);
|
|
19514
20858
|
const viewScale = this._docViewScaleService.getViewScale(zoomRatio);
|
|
19515
20859
|
docObject.scene.scale(viewScale, viewScale);
|
|
19516
20860
|
if (!this._editorService.isEditor(this._context.unitId)) this._docPageLayoutService.calculatePagePosition();
|
|
19517
|
-
if (needRefreshSelection && !this._editorService.isEditor(this._context.unitId)) this._textSelectionManagerService.refreshSelection();
|
|
19518
|
-
if ((0, _univerjs_core.isInternalEditorID)(this._context.unitId))
|
|
19519
|
-
|
|
20861
|
+
if (needRefreshSelection && !this._editorService.isEditor(this._context.unitId) && !((_this$_embedInteracti = this._embedInteractionBoundaryService) === null || _this$_embedInteracti === void 0 ? void 0 : _this$_embedInteracti.hasRecentInteraction())) this._textSelectionManagerService.refreshSelection();
|
|
20862
|
+
if (!(0, _univerjs_core.isInternalEditorID)(this._context.unitId)) {
|
|
20863
|
+
var _docObject$scene$getT;
|
|
20864
|
+
(_docObject$scene$getT = docObject.scene.getTransformer()) === null || _docObject$scene$getT === void 0 || _docObject$scene$getT.clearSelectedObjects();
|
|
20865
|
+
}
|
|
20866
|
+
const createOptions = this._univerInstanceService.getUnitCreateOptions(this._context.unitId);
|
|
20867
|
+
if ((createOptions === null || createOptions === void 0 ? void 0 : createOptions.embeddedRender) === true || (createOptions === null || createOptions === void 0 ? void 0 : createOptions.skipAutoRender) === true) {
|
|
20868
|
+
this._context.scene.makeDirty();
|
|
20869
|
+
this._context.scene.render();
|
|
20870
|
+
}
|
|
19520
20871
|
}
|
|
19521
20872
|
_initZoomEventListener() {
|
|
19522
20873
|
const scene = this._context.scene;
|
|
@@ -19543,7 +20894,8 @@ DocZoomRenderController = __decorate([
|
|
|
19543
20894
|
__decorateParam(6, IEditorService),
|
|
19544
20895
|
__decorateParam(7, (0, _univerjs_core.Inject)(DocPageLayoutService)),
|
|
19545
20896
|
__decorateParam(8, _univerjs_engine_render.IRenderManagerService),
|
|
19546
|
-
__decorateParam(9, (0, _univerjs_core.Inject)(DocViewScaleService))
|
|
20897
|
+
__decorateParam(9, (0, _univerjs_core.Inject)(DocViewScaleService)),
|
|
20898
|
+
__decorateParam(10, (0, _univerjs_core.Optional)(IDocEmbedInteractionBoundaryService))
|
|
19547
20899
|
], DocZoomRenderController);
|
|
19548
20900
|
|
|
19549
20901
|
//#endregion
|
|
@@ -19626,25 +20978,34 @@ let DocsRenderService = class DocsRenderService extends _univerjs_core.RxDisposa
|
|
|
19626
20978
|
}
|
|
19627
20979
|
_init() {
|
|
19628
20980
|
this._renderManagerService.createRender$.pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((unitId) => this._createRenderWithId(unitId));
|
|
19629
|
-
this._instanceSrv.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_DOC).forEach((documentModel) =>
|
|
19630
|
-
|
|
20981
|
+
this._instanceSrv.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_DOC).forEach((documentModel) => {
|
|
20982
|
+
var _this$_instanceSrv$ge;
|
|
20983
|
+
return this._createRenderer(documentModel, (_this$_instanceSrv$ge = this._instanceSrv.getUnitCreateOptions(documentModel.getUnitId())) !== null && _this$_instanceSrv$ge !== void 0 ? _this$_instanceSrv$ge : void 0);
|
|
20984
|
+
});
|
|
20985
|
+
this._instanceSrv.getTypeOfUnitAdded$(_univerjs_core.UniverInstanceType.UNIVER_DOC).pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((event) => this._createRenderer(event.unit, event.options));
|
|
19631
20986
|
this._instanceSrv.getTypeOfUnitDisposed$(_univerjs_core.UniverInstanceType.UNIVER_DOC).pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((doc) => this._disposeRenderer(doc));
|
|
19632
20987
|
}
|
|
19633
|
-
_createRenderer(doc) {
|
|
20988
|
+
_createRenderer(doc, createUnitOptions) {
|
|
20989
|
+
if (createUnitOptions === null || createUnitOptions === void 0 ? void 0 : createUnitOptions.skipAutoRender) return;
|
|
19634
20990
|
const unitId = doc.getUnitId();
|
|
19635
|
-
this._renderManagerService.
|
|
19636
|
-
|
|
19637
|
-
|
|
19638
|
-
|
|
19639
|
-
|
|
19640
|
-
|
|
19641
|
-
|
|
19642
|
-
|
|
19643
|
-
|
|
19644
|
-
if (
|
|
20991
|
+
if (!this._renderManagerService.has(unitId)) {
|
|
20992
|
+
this._createRenderWithId(unitId, doc);
|
|
20993
|
+
return;
|
|
20994
|
+
}
|
|
20995
|
+
const renderer = this._renderManagerService.getRenderById(unitId);
|
|
20996
|
+
if (renderer) this._syncRendererCanvas(renderer, doc);
|
|
20997
|
+
}
|
|
20998
|
+
_createRenderWithId(unitId, doc) {
|
|
20999
|
+
const renderer = this._renderManagerService.createRender(unitId);
|
|
21000
|
+
if (doc) this._syncRendererCanvas(renderer, doc);
|
|
19645
21001
|
}
|
|
19646
|
-
|
|
19647
|
-
|
|
21002
|
+
_syncRendererCanvas(renderer, doc) {
|
|
21003
|
+
const unitId = doc.getUnitId();
|
|
21004
|
+
const documentFlavor = doc.getSnapshot().documentStyle.documentFlavor;
|
|
21005
|
+
const canvas = renderer.engine.getCanvas();
|
|
21006
|
+
canvas.setId(DOC_MAIN_CANVAS_ID);
|
|
21007
|
+
canvas.getContext().setId(DOC_MAIN_CANVAS_ID);
|
|
21008
|
+
canvas.getCanvasEle().style.backgroundColor = getDocsCanvasBackgroundColor(documentFlavor, renderer.engine.canvasColorService, void 0, (0, _univerjs_core.isInternalEditorID)(unitId));
|
|
19648
21009
|
}
|
|
19649
21010
|
_disposeRenderer(doc) {
|
|
19650
21011
|
const unitId = doc.getUnitId();
|
|
@@ -19830,6 +21191,7 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
19830
21191
|
[DocAutoFormatController],
|
|
19831
21192
|
[DocMoveCursorController],
|
|
19832
21193
|
[DocParagraphSettingController],
|
|
21194
|
+
[DocSectionSettingController],
|
|
19833
21195
|
[DocTableController],
|
|
19834
21196
|
[ComponentsController],
|
|
19835
21197
|
[DocUIController]
|
|
@@ -19899,6 +21261,7 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
19899
21261
|
SetDocZoomRatioCommand,
|
|
19900
21262
|
DocSelectAllCommand,
|
|
19901
21263
|
DocParagraphSettingPanelOperation,
|
|
21264
|
+
DocSectionSettingPanelOperation,
|
|
19902
21265
|
MoveCursorOperation,
|
|
19903
21266
|
MoveSelectionOperation,
|
|
19904
21267
|
ReplaceTextRunsCommand,
|
|
@@ -19986,8 +21349,11 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
19986
21349
|
[DocTableController],
|
|
19987
21350
|
[DocMoveCursorController],
|
|
19988
21351
|
[DocParagraphSettingController],
|
|
21352
|
+
[DocSectionSettingController],
|
|
19989
21353
|
[IEditorService, { useClass: EditorService }],
|
|
19990
21354
|
[IDocClipboardService, { useClass: DocClipboardService }],
|
|
21355
|
+
[DocClipboardPasteAdapterService],
|
|
21356
|
+
[IDocClipboardPasteAdapterService, { useClass: DocClipboardPasteAdapterService }],
|
|
19991
21357
|
[DocHtmlExportService],
|
|
19992
21358
|
[DocCanvasPopManagerService],
|
|
19993
21359
|
[DocsRenderService],
|
|
@@ -20003,6 +21369,8 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
20003
21369
|
const doc = currentService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
20004
21370
|
if (!doc) return;
|
|
20005
21371
|
const id = doc.getUnitId();
|
|
21372
|
+
const createOptions = currentService.getUnitCreateOptions(id);
|
|
21373
|
+
if ((createOptions === null || createOptions === void 0 ? void 0 : createOptions.makeCurrent) === false) return;
|
|
20006
21374
|
if (!editorService.isEditor(id)) currentService.focusUnit(doc.getUnitId());
|
|
20007
21375
|
} catch (err) {
|
|
20008
21376
|
this._logService.warn(err);
|
|
@@ -20279,13 +21647,13 @@ function useKeyboardEvent(isNeed, config, editor) {
|
|
|
20279
21647
|
const useLeftAndRightArrow = (isNeed, selectingMode, editor, onMoveInEditor) => {
|
|
20280
21648
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
20281
21649
|
const shortcutService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IShortcutService);
|
|
21650
|
+
const operationId = `doc.rich-text-editor.arrow.${(0, react.useId)()}`;
|
|
20282
21651
|
const selectingModeRef = (0, react.useRef)(selectingMode);
|
|
20283
21652
|
selectingModeRef.current = selectingMode;
|
|
20284
21653
|
const onMoveInEditorRef = (0, react.useRef)(onMoveInEditor);
|
|
20285
21654
|
onMoveInEditorRef.current = onMoveInEditor;
|
|
20286
21655
|
(0, react.useEffect)(() => {
|
|
20287
21656
|
if (!editor || !isNeed) return;
|
|
20288
|
-
const operationId = `doc.rich-text-editor.${editor.getEditorId()}`;
|
|
20289
21657
|
const d = new _univerjs_core.DisposableCollection();
|
|
20290
21658
|
const handleMoveInEditor = (keycode, metaKey) => {
|
|
20291
21659
|
if (onMoveInEditorRef.current) {
|
|
@@ -20332,7 +21700,7 @@ const useLeftAndRightArrow = (isNeed, selectingMode, editor, onMoveInEditor) =>
|
|
|
20332
21700
|
return {
|
|
20333
21701
|
id: operationId,
|
|
20334
21702
|
binding: metaKey ? keyCode | metaKey : keyCode,
|
|
20335
|
-
preconditions: () =>
|
|
21703
|
+
preconditions: () => editor.isFocus(),
|
|
20336
21704
|
priority: 900,
|
|
20337
21705
|
staticParameters: {
|
|
20338
21706
|
eventType: _univerjs_engine_render.DeviceInputEventType.Keyboard,
|
|
@@ -20350,6 +21718,7 @@ const useLeftAndRightArrow = (isNeed, selectingMode, editor, onMoveInEditor) =>
|
|
|
20350
21718
|
commandService,
|
|
20351
21719
|
editor,
|
|
20352
21720
|
isNeed,
|
|
21721
|
+
operationId,
|
|
20353
21722
|
shortcutService
|
|
20354
21723
|
]);
|
|
20355
21724
|
};
|
|
@@ -20634,8 +22003,10 @@ exports.DOCS_COMPONENT_BACKGROUND_LAYER_INDEX = DOCS_COMPONENT_BACKGROUND_LAYER_
|
|
|
20634
22003
|
exports.DOCS_COMPONENT_DEFAULT_Z_INDEX = DOCS_COMPONENT_DEFAULT_Z_INDEX;
|
|
20635
22004
|
exports.DOCS_COMPONENT_HEADER_LAYER_INDEX = DOCS_COMPONENT_HEADER_LAYER_INDEX;
|
|
20636
22005
|
exports.DOCS_COMPONENT_MAIN_LAYER_INDEX = DOCS_COMPONENT_MAIN_LAYER_INDEX;
|
|
22006
|
+
exports.DOCS_UI_PLUGIN_CONFIG_KEY = DOCS_UI_PLUGIN_CONFIG_KEY;
|
|
20637
22007
|
exports.DOCS_VIEW_KEY = DOCS_VIEW_KEY;
|
|
20638
22008
|
exports.DOC_CONTENT_INSERT_MENU_ID = DOC_CONTENT_INSERT_MENU_ID;
|
|
22009
|
+
exports.DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE;
|
|
20639
22010
|
exports.DOC_PARAGRAPH_T_ALIGN_MENU_ID = DOC_PARAGRAPH_T_ALIGN_MENU_ID;
|
|
20640
22011
|
exports.DOC_PARAGRAPH_T_COLORS_MENU_ID = DOC_PARAGRAPH_T_COLORS_MENU_ID;
|
|
20641
22012
|
exports.DOC_PARAGRAPH_T_DIVIDER_MENU_ID = DOC_PARAGRAPH_T_DIVIDER_MENU_ID;
|
|
@@ -20666,6 +22037,7 @@ Object.defineProperty(exports, 'DocCanvasPopManagerService', {
|
|
|
20666
22037
|
return DocCanvasPopManagerService;
|
|
20667
22038
|
}
|
|
20668
22039
|
});
|
|
22040
|
+
exports.DocClipboardPasteAdapterService = DocClipboardPasteAdapterService;
|
|
20669
22041
|
exports.DocCopyCommand = DocCopyCommand;
|
|
20670
22042
|
exports.DocCreateTableOperation = DocCreateTableOperation;
|
|
20671
22043
|
exports.DocCutCommand = DocCutCommand;
|
|
@@ -20675,8 +22047,20 @@ Object.defineProperty(exports, 'DocEventManagerService', {
|
|
|
20675
22047
|
return DocEventManagerService;
|
|
20676
22048
|
}
|
|
20677
22049
|
});
|
|
22050
|
+
Object.defineProperty(exports, 'DocFloatMenuService', {
|
|
22051
|
+
enumerable: true,
|
|
22052
|
+
get: function () {
|
|
22053
|
+
return DocFloatMenuService;
|
|
22054
|
+
}
|
|
22055
|
+
});
|
|
20678
22056
|
exports.DocHtmlExportService = DocHtmlExportService;
|
|
20679
22057
|
exports.DocIMEInputManagerService = DocIMEInputManagerService;
|
|
22058
|
+
Object.defineProperty(exports, 'DocPageLayoutService', {
|
|
22059
|
+
enumerable: true,
|
|
22060
|
+
get: function () {
|
|
22061
|
+
return DocPageLayoutService;
|
|
22062
|
+
}
|
|
22063
|
+
});
|
|
20680
22064
|
Object.defineProperty(exports, 'DocParagraphMenuService', {
|
|
20681
22065
|
enumerable: true,
|
|
20682
22066
|
get: function () {
|
|
@@ -20733,6 +22117,12 @@ Object.defineProperty(exports, 'DocsRenderService', {
|
|
|
20733
22117
|
}
|
|
20734
22118
|
});
|
|
20735
22119
|
exports.DocsUIMenuSchema = menuSchema;
|
|
22120
|
+
Object.defineProperty(exports, 'EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY', {
|
|
22121
|
+
enumerable: true,
|
|
22122
|
+
get: function () {
|
|
22123
|
+
return _univerjs_docs.EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY;
|
|
22124
|
+
}
|
|
22125
|
+
});
|
|
20736
22126
|
exports.EMPTY_PARAGRAPH_MENU_ID = EMPTY_PARAGRAPH_MENU_ID;
|
|
20737
22127
|
exports.Editor = Editor;
|
|
20738
22128
|
Object.defineProperty(exports, 'EditorService', {
|
|
@@ -20748,7 +22138,10 @@ exports.FloatTextStyleMenuItemFactory = FloatTextStyleMenuItemFactory;
|
|
|
20748
22138
|
exports.FontFamilySelectorMenuItemFactory = FontFamilySelectorMenuItemFactory;
|
|
20749
22139
|
exports.FontSizeSelectorMenuItemFactory = FontSizeSelectorMenuItemFactory;
|
|
20750
22140
|
exports.HorizontalLineCommand = HorizontalLineCommand;
|
|
22141
|
+
exports.IDocClipboardPasteAdapterService = IDocClipboardPasteAdapterService;
|
|
20751
22142
|
exports.IDocClipboardService = IDocClipboardService;
|
|
22143
|
+
exports.IDocEmbedInteractionBoundaryService = IDocEmbedInteractionBoundaryService;
|
|
22144
|
+
exports.IDocEmbedRuntimeFocusCoordinator = IDocEmbedRuntimeFocusCoordinator;
|
|
20752
22145
|
exports.IEditorService = IEditorService;
|
|
20753
22146
|
exports.IMEInputCommand = IMEInputCommand;
|
|
20754
22147
|
exports.INSERT_BELLOW_MENU_ID = INSERT_BELLOW_MENU_ID;
|
|
@@ -20812,15 +22205,48 @@ exports.addCustomDecorationFactory = addCustomDecorationFactory;
|
|
|
20812
22205
|
exports.buildMoveDocBlockActions = buildMoveDocBlockActions;
|
|
20813
22206
|
exports.calcDocFitToWidthScale = calcDocFitToWidthScale;
|
|
20814
22207
|
exports.calcDocRangePositions = calcDocRangePositions;
|
|
22208
|
+
exports.collectDocsTableLikeEmbedChildUnitIds = collectDocsTableLikeEmbedChildUnitIds;
|
|
20815
22209
|
exports.convertBodyToHtml = convertBodyToHtml;
|
|
20816
22210
|
exports.convertPositionsToRectRanges = convertPositionsToRectRanges;
|
|
22211
|
+
exports.createDefaultDocsTableLikeCustomBlockBleedViewport = createDefaultDocsTableLikeCustomBlockBleedViewport;
|
|
22212
|
+
Object.defineProperty(exports, 'createDocsCustomBlockInsertMutation', {
|
|
22213
|
+
enumerable: true,
|
|
22214
|
+
get: function () {
|
|
22215
|
+
return _univerjs_docs.createDocsCustomBlockInsertMutation;
|
|
22216
|
+
}
|
|
22217
|
+
});
|
|
22218
|
+
Object.defineProperty(exports, 'createDocsCustomBlockRemoveMutation', {
|
|
22219
|
+
enumerable: true,
|
|
22220
|
+
get: function () {
|
|
22221
|
+
return _univerjs_docs.createDocsCustomBlockRemoveMutation;
|
|
22222
|
+
}
|
|
22223
|
+
});
|
|
22224
|
+
exports.createDocsCustomBlockSizeRefreshScheduler = createDocsCustomBlockSizeRefreshScheduler;
|
|
20817
22225
|
exports.createEditorUndoRedoKeyboardConfig = createEditorUndoRedoKeyboardConfig;
|
|
22226
|
+
Object.defineProperty(exports, 'createEmbedDocsCustomBlockData', {
|
|
22227
|
+
enumerable: true,
|
|
22228
|
+
get: function () {
|
|
22229
|
+
return _univerjs_docs.createEmbedDocsCustomBlockData;
|
|
22230
|
+
}
|
|
22231
|
+
});
|
|
22232
|
+
Object.defineProperty(exports, 'createInsertCustomBlockActions', {
|
|
22233
|
+
enumerable: true,
|
|
22234
|
+
get: function () {
|
|
22235
|
+
return _univerjs_docs.createInsertCustomBlockActions;
|
|
22236
|
+
}
|
|
22237
|
+
});
|
|
22238
|
+
Object.defineProperty(exports, 'createRemoveCustomBlockActions', {
|
|
22239
|
+
enumerable: true,
|
|
22240
|
+
get: function () {
|
|
22241
|
+
return _univerjs_docs.createRemoveCustomBlockActions;
|
|
22242
|
+
}
|
|
22243
|
+
});
|
|
20818
22244
|
exports.deleteCustomDecorationFactory = deleteCustomDecorationFactory;
|
|
20819
22245
|
exports.disableMenuWhenHeaderFooterEditing = disableMenuWhenHeaderFooterEditing;
|
|
20820
22246
|
exports.docDrawingPositionToTransform = docDrawingPositionToTransform;
|
|
20821
22247
|
exports.executeEditorUndoRedoCommand = executeEditorUndoRedoCommand;
|
|
20822
22248
|
exports.genTableSource = genTableSource;
|
|
20823
|
-
exports.generateParagraphs = generateParagraphs;
|
|
22249
|
+
exports.generateParagraphs = _univerjs_docs.generateParagraphs;
|
|
20824
22250
|
exports.getAnchorBounding = getAnchorBounding;
|
|
20825
22251
|
exports.getCanvasOffsetByEngine = getCanvasOffsetByEngine;
|
|
20826
22252
|
exports.getCommandSkeleton = getCommandSkeleton;
|
|
@@ -20841,12 +22267,30 @@ exports.getTableColumn = getTableColumn;
|
|
|
20841
22267
|
exports.hasParagraphInTable = hasParagraphInTable;
|
|
20842
22268
|
exports.hideMenuWhenSelectionInBlockRange = hideMenuWhenSelectionInBlockRange;
|
|
20843
22269
|
exports.isInSameTableCell = isInSameTableCell;
|
|
22270
|
+
Object.defineProperty(exports, 'isSheetLikeDocsCustomBlockChildType', {
|
|
22271
|
+
enumerable: true,
|
|
22272
|
+
get: function () {
|
|
22273
|
+
return _univerjs_docs.isSheetLikeDocsCustomBlockChildType;
|
|
22274
|
+
}
|
|
22275
|
+
});
|
|
20844
22276
|
exports.isTextRangeInAnyBlockRange = isTextRangeInAnyBlockRange;
|
|
20845
22277
|
exports.isValidRectRange = isValidRectRange;
|
|
20846
22278
|
exports.neoGetDocObject = neoGetDocObject;
|
|
20847
22279
|
exports.normalizeDocFitToWidthOptions = normalizeDocFitToWidthOptions;
|
|
20848
22280
|
exports.resolveDocFitBaseWidth = resolveDocFitBaseWidth;
|
|
20849
22281
|
exports.resolveDocViewScale = resolveDocViewScale;
|
|
22282
|
+
exports.resolveDocsCustomBlockRenderViewport = resolveDocsCustomBlockRenderViewport;
|
|
22283
|
+
Object.defineProperty(exports, 'resolveDocsCustomBlockSize', {
|
|
22284
|
+
enumerable: true,
|
|
22285
|
+
get: function () {
|
|
22286
|
+
return _univerjs_docs.resolveDocsCustomBlockSize;
|
|
22287
|
+
}
|
|
22288
|
+
});
|
|
22289
|
+
exports.resolveDocsTableLikeCustomBlockBleedViewport = resolveDocsTableLikeCustomBlockBleedViewport;
|
|
22290
|
+
exports.resolveDocsTableLikeCustomBlockContentHeight = resolveDocsTableLikeCustomBlockContentHeight;
|
|
22291
|
+
exports.resolveDocsTableLikeCustomBlockContentWidth = resolveDocsTableLikeCustomBlockContentWidth;
|
|
22292
|
+
exports.scrollDocsTableLikeCustomBlockLive = scrollDocsTableLikeCustomBlockLive;
|
|
22293
|
+
exports.shouldRefreshDocsCustomBlockSizeForCommand = shouldRefreshDocsCustomBlockSizeForCommand;
|
|
20850
22294
|
exports.transformToDocDrawingPosition = transformToDocDrawingPosition;
|
|
20851
22295
|
exports.useEditor = useEditor;
|
|
20852
22296
|
exports.useEditorClickOutside = useEditorClickOutside;
|