@univerjs/docs-ui 1.1.0 → 1.3.0
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/README.md +45 -0
- package/lib/cjs/index.js +822 -243
- package/lib/cjs/locale/ar-SA.js +4 -0
- package/lib/cjs/locale/ca-ES.js +4 -0
- package/lib/cjs/locale/de-DE.js +4 -0
- package/lib/cjs/locale/en-US.js +4 -0
- package/lib/cjs/locale/es-ES.js +4 -0
- package/lib/cjs/locale/fa-IR.js +4 -0
- package/lib/cjs/locale/fr-FR.js +4 -0
- package/lib/cjs/locale/id-ID.js +4 -0
- package/lib/cjs/locale/it-IT.js +4 -0
- package/lib/cjs/locale/ja-JP.js +4 -0
- package/lib/cjs/locale/ko-KR.js +4 -0
- package/lib/cjs/locale/pl-PL.js +4 -0
- package/lib/cjs/locale/pt-BR.js +4 -0
- package/lib/cjs/locale/ru-RU.js +4 -0
- package/lib/cjs/locale/sk-SK.js +4 -0
- package/lib/cjs/locale/vi-VN.js +4 -0
- package/lib/cjs/locale/zh-CN.js +4 -0
- package/lib/cjs/locale/zh-HK.js +4 -0
- package/lib/cjs/locale/zh-TW.js +4 -0
- package/lib/es/index.js +826 -248
- package/lib/es/locale/ar-SA.js +4 -0
- package/lib/es/locale/ca-ES.js +4 -0
- package/lib/es/locale/de-DE.js +4 -0
- package/lib/es/locale/en-US.js +4 -0
- package/lib/es/locale/es-ES.js +4 -0
- package/lib/es/locale/fa-IR.js +4 -0
- package/lib/es/locale/fr-FR.js +4 -0
- package/lib/es/locale/id-ID.js +4 -0
- package/lib/es/locale/it-IT.js +4 -0
- package/lib/es/locale/ja-JP.js +4 -0
- package/lib/es/locale/ko-KR.js +4 -0
- package/lib/es/locale/pl-PL.js +4 -0
- package/lib/es/locale/pt-BR.js +4 -0
- package/lib/es/locale/ru-RU.js +4 -0
- package/lib/es/locale/sk-SK.js +4 -0
- package/lib/es/locale/vi-VN.js +4 -0
- package/lib/es/locale/zh-CN.js +4 -0
- package/lib/es/locale/zh-HK.js +4 -0
- package/lib/es/locale/zh-TW.js +4 -0
- package/lib/index.css +40 -78
- package/lib/index.js +826 -248
- package/lib/locale/ar-SA.js +4 -0
- package/lib/locale/ca-ES.js +4 -0
- package/lib/locale/de-DE.js +4 -0
- package/lib/locale/en-US.js +4 -0
- package/lib/locale/es-ES.js +4 -0
- package/lib/locale/fa-IR.js +4 -0
- package/lib/locale/fr-FR.js +4 -0
- package/lib/locale/id-ID.js +4 -0
- package/lib/locale/it-IT.js +4 -0
- package/lib/locale/ja-JP.js +4 -0
- package/lib/locale/ko-KR.js +4 -0
- package/lib/locale/pl-PL.js +4 -0
- package/lib/locale/pt-BR.js +4 -0
- package/lib/locale/ru-RU.js +4 -0
- package/lib/locale/sk-SK.js +4 -0
- package/lib/locale/vi-VN.js +4 -0
- package/lib/locale/zh-CN.js +4 -0
- package/lib/locale/zh-HK.js +4 -0
- package/lib/locale/zh-TW.js +4 -0
- package/lib/types/config/config.d.ts +5 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/locale/en-US.d.ts +4 -0
- package/lib/types/menu/menu.d.ts +1 -1
- package/lib/types/menu/mobile-schema.d.ts +41 -2
- package/lib/types/plugin.d.ts +1 -1
- package/lib/types/services/clipboard/clipboard.service.d.ts +1 -1
- package/lib/types/services/doc-heading-collapse.service.d.ts +38 -0
- package/lib/types/services/doc-paragraph-menu.service.d.ts +5 -3
- package/lib/types/services/doc-popup-manager.service.d.ts +4 -1
- package/lib/types/services/mobile/doc-selection-render.service.d.ts +1 -0
- package/lib/types/services/selection/doc-selection-render.service.d.ts +2 -1
- package/lib/types/views/EditorColorPicker.d.ts +20 -0
- package/lib/types/views/ParagraphMenu.d.ts +2 -2
- package/lib/types/views/doc-side-menu-layout.d.ts +17 -0
- package/lib/types/views/heading-collapse-shape.d.ts +38 -0
- package/lib/types/views/paragraph-menu/paragraph-menu-position.d.ts +21 -0
- package/lib/types/views/paragraph-setting/hook/utils.d.ts +2 -0
- package/lib/types/views/rich-text-editor/hooks/editor-undo-redo-keyboard.d.ts +5 -1
- package/lib/umd/index.js +16 -17
- 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 +12 -12
package/lib/cjs/index.js
CHANGED
|
@@ -521,15 +521,34 @@ const BreakLineCommand = {
|
|
|
521
521
|
const { horizontalLine, insertionMode = "split-paragraph" } = params ?? {};
|
|
522
522
|
const { segmentId } = activeTextRange;
|
|
523
523
|
const docDataModel = (params === null || params === void 0 ? void 0 : params.unitId) ? univerInstanceService.getUnit(params.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC) : univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
524
|
-
|
|
524
|
+
let originBody = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId ?? "")) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
525
525
|
if (docDataModel == null || originBody == null) return false;
|
|
526
526
|
const unitId = docDataModel.getUnitId();
|
|
527
527
|
const { startOffset, endOffset } = activeTextRange;
|
|
528
528
|
const paragraphs = originBody.paragraphs ?? [];
|
|
529
529
|
const isBareStructuralGap = isTopLevelStructuralGap(originBody.dataStream, startOffset) && originBody.dataStream[startOffset] !== _univerjs_core.DataStreamTreeTokenType.PARAGRAPH;
|
|
530
530
|
const insertsAtStructuralGap = insertionMode === "insert-gap" || isBareStructuralGap;
|
|
531
|
-
|
|
531
|
+
let prevParagraph = insertsAtStructuralGap ? void 0 : paragraphs.find((p) => p.startIndex >= startOffset);
|
|
532
532
|
if (!prevParagraph && !insertsAtStructuralGap) return false;
|
|
533
|
+
if (!segmentId && (prevParagraph === null || prevParagraph === void 0 ? void 0 : prevParagraph.headingCollapsed) && docDataModel.getSnapshot().documentStyle.documentFlavor === _univerjs_core.DocumentFlavor.MODERN) {
|
|
534
|
+
const paragraphId = prevParagraph.paragraphId;
|
|
535
|
+
const viewModel = new _univerjs_engine_render.DocumentViewModel(docDataModel);
|
|
536
|
+
try {
|
|
537
|
+
if (viewModel.getHeadingSections().some((section) => section.paragraphId === paragraphId)) {
|
|
538
|
+
var _originBody$paragraph;
|
|
539
|
+
if (!commandService.syncExecuteCommand(_univerjs_docs.SetHeadingCollapsedCommand.id, {
|
|
540
|
+
unitId,
|
|
541
|
+
paragraphId,
|
|
542
|
+
collapsed: false
|
|
543
|
+
})) return false;
|
|
544
|
+
originBody = docDataModel.getBody();
|
|
545
|
+
prevParagraph = originBody === null || originBody === void 0 || (_originBody$paragraph = originBody.paragraphs) === null || _originBody$paragraph === void 0 ? void 0 : _originBody$paragraph.find((paragraph) => paragraph.startIndex >= startOffset);
|
|
546
|
+
if (!originBody || !prevParagraph) return false;
|
|
547
|
+
}
|
|
548
|
+
} finally {
|
|
549
|
+
viewModel.dispose();
|
|
550
|
+
}
|
|
551
|
+
}
|
|
533
552
|
const isAtParagraphEnd = startOffset === (prevParagraph === null || prevParagraph === void 0 ? void 0 : prevParagraph.startIndex);
|
|
534
553
|
const prevParagraphIndex = prevParagraph === null || prevParagraph === void 0 ? void 0 : prevParagraph.startIndex;
|
|
535
554
|
const defaultTextStyle = docMenuStyleService.getDefaultStyle();
|
|
@@ -2867,7 +2886,7 @@ function getTextRangeFromCharIndex(startOffset, endOffset, scene, document, skel
|
|
|
2867
2886
|
function getRectRangeFromCharIndex(startOffset, endOffset, scene, document, skeleton, style, segmentId, segmentPage) {
|
|
2868
2887
|
const startNodePosition = skeleton.findNodePositionByCharIndex(startOffset, true, segmentId, segmentPage);
|
|
2869
2888
|
const endNodePosition = skeleton.findNodePositionByCharIndex(endOffset, true, segmentId, segmentPage);
|
|
2870
|
-
if (startNodePosition == null || endNodePosition == null) return;
|
|
2889
|
+
if (startNodePosition == null || endNodePosition == null || startNodePosition.path.indexOf("cells") === -1 || endNodePosition.path.indexOf("cells") === -1) return;
|
|
2871
2890
|
return new RectRange(scene, document, skeleton, startNodePosition, endNodePosition, style, segmentId, segmentPage);
|
|
2872
2891
|
}
|
|
2873
2892
|
function getRangeListFromCharIndex(startOffset, endOffset, scene, document, skeleton, style, segmentId, segmentPage) {
|
|
@@ -3253,7 +3272,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
3253
3272
|
get canFocusing() {
|
|
3254
3273
|
const ownerDocument = this._getOwnerDocument();
|
|
3255
3274
|
const activeElement = ownerDocument.activeElement;
|
|
3256
|
-
return !this._shouldPreserveExternalFocus() && !this._isAnotherEditorFocused() && (this.isFocusing || activeElement === ownerDocument.body || activeElement === null || activeElement instanceof HTMLElement && this._containsCurrentEmbedRuntimeElement(activeElement));
|
|
3275
|
+
return !this._isInUnfocusedFrame() && !this._shouldPreserveExternalFocus() && !this._isAnotherEditorFocused() && (this.isFocusing || activeElement === ownerDocument.body || activeElement === null || activeElement instanceof HTMLElement && this._containsCurrentEmbedRuntimeElement(activeElement));
|
|
3257
3276
|
}
|
|
3258
3277
|
cancelPointerSelection() {
|
|
3259
3278
|
if (!this._onPointerEvent) return;
|
|
@@ -3984,7 +4003,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
3984
4003
|
const activeRangeInstance = this._getActiveRangeInstance();
|
|
3985
4004
|
const anchor = activeRangeInstance === null || activeRangeInstance === void 0 ? void 0 : activeRangeInstance.getAnchor();
|
|
3986
4005
|
if (!anchor || anchor && !anchor.visible || this.activeViewPort == null) {
|
|
3987
|
-
if (preserveFocus || this._shouldPreserveExternalFocus() || !forceFocus && this._isAnotherEditorFocused()) return;
|
|
4006
|
+
if (preserveFocus || this._shouldPreserveExternalFocus() || !forceFocus && (this._isInUnfocusedFrame() || this._isAnotherEditorFocused())) return;
|
|
3988
4007
|
this.focus();
|
|
3989
4008
|
return;
|
|
3990
4009
|
}
|
|
@@ -4262,6 +4281,11 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
4262
4281
|
if (activeElement instanceof HTMLElement && this._containsCurrentLayoutElement(activeElement)) return false;
|
|
4263
4282
|
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;
|
|
4264
4283
|
}
|
|
4284
|
+
_isInUnfocusedFrame() {
|
|
4285
|
+
const ownerDocument = this._getOwnerDocument();
|
|
4286
|
+
const ownerWindow = ownerDocument.defaultView;
|
|
4287
|
+
return ownerWindow != null && ownerWindow.parent !== ownerWindow && !ownerDocument.hasFocus();
|
|
4288
|
+
}
|
|
4265
4289
|
_isAnotherEditorFocused() {
|
|
4266
4290
|
const activeElement = this._getOwnerDocument().activeElement;
|
|
4267
4291
|
return activeElement instanceof HTMLElement && activeElement !== this._input && activeElement.dataset.uComp === this._input.dataset.uComp;
|
|
@@ -6261,6 +6285,14 @@ const DeleteLeftCommand = {
|
|
|
6261
6285
|
const { segmentId, style, segmentPage } = activeRange;
|
|
6262
6286
|
const body = (_docDataModel$getSelf3 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf3 === void 0 ? void 0 : _docDataModel$getSelf3.getBody();
|
|
6263
6287
|
if (body == null) return false;
|
|
6288
|
+
if (activeRange.collapsed && !segmentId) {
|
|
6289
|
+
const hidden = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel().getCollapsedHeadingAtOffset(activeRange.startOffset - 1);
|
|
6290
|
+
if (hidden) return commandService.executeCommand(_univerjs_docs.SetHeadingCollapsedCommand.id, {
|
|
6291
|
+
unitId,
|
|
6292
|
+
paragraphId: hidden.paragraphId,
|
|
6293
|
+
collapsed: false
|
|
6294
|
+
});
|
|
6295
|
+
}
|
|
6264
6296
|
const originalLength = body.dataStream.length;
|
|
6265
6297
|
const typingStyle = captureDeletedTypingStyle(accessor, docDataModel, body, activeRange);
|
|
6266
6298
|
const actualRange = activeRange;
|
|
@@ -6419,6 +6451,14 @@ const DeleteRightCommand = {
|
|
|
6419
6451
|
const { segmentId, style, segmentPage } = activeRange;
|
|
6420
6452
|
const body = docDataModel === null || docDataModel === void 0 || (_docDataModel$getSelf5 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf5 === void 0 ? void 0 : _docDataModel$getSelf5.getBody();
|
|
6421
6453
|
if (!docDataModel || !body) return false;
|
|
6454
|
+
if (activeRange.collapsed && !segmentId) {
|
|
6455
|
+
const hidden = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel().getCollapsedHeadingAtOffset(activeRange.startOffset + 1);
|
|
6456
|
+
if (hidden) return commandService.executeCommand(_univerjs_docs.SetHeadingCollapsedCommand.id, {
|
|
6457
|
+
unitId: docDataModel.getUnitId(),
|
|
6458
|
+
paragraphId: hidden.paragraphId,
|
|
6459
|
+
collapsed: false
|
|
6460
|
+
});
|
|
6461
|
+
}
|
|
6422
6462
|
const actualRange = activeRange;
|
|
6423
6463
|
const { startOffset, endOffset, collapsed } = actualRange;
|
|
6424
6464
|
if (collapsed && shouldResetEmptyCenteredParagraphAlignment(accessor, docDataModel)) {
|
|
@@ -8780,13 +8820,21 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
8780
8820
|
this.dismissPasteOptions();
|
|
8781
8821
|
const unitId = payload.unitId ?? this._getCurrentDocumentUnitId();
|
|
8782
8822
|
if (!unitId || !this._canEditTargets(unitId)) return false;
|
|
8783
|
-
|
|
8823
|
+
const isCommentEditor = (0, _univerjs_core.isCommentEditorID)(unitId);
|
|
8824
|
+
if (!cachedSource && !payload.html && !payload.text && !payload.internalJson && (isCommentEditor || !payload.files.length)) return false;
|
|
8784
8825
|
const generation = this._pasteGeneration;
|
|
8785
|
-
const mode = unitId === _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY ? "text" : payload.mode ?? "source";
|
|
8826
|
+
const mode = isCommentEditor || unitId === _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY ? "text" : payload.mode ?? "source";
|
|
8786
8827
|
const style = this._getPasteStyle(unitId);
|
|
8787
|
-
const source = await this._preparePaste(payload, mode, cachedSource);
|
|
8828
|
+
const source = await (isCommentEditor && payload.text !== void 0 ? { body: { dataStream: payload.text } } : this._preparePaste(payload, mode, cachedSource));
|
|
8788
8829
|
if (generation !== this._pasteGeneration || !this._canEditTargets(unitId)) return false;
|
|
8789
|
-
let doc
|
|
8830
|
+
let doc;
|
|
8831
|
+
if (isCommentEditor) {
|
|
8832
|
+
const text = payload.text ?? getClipboardPlainText(source);
|
|
8833
|
+
if (!text) return false;
|
|
8834
|
+
const body = _univerjs_core.BuildTextUtils.transform.fromPlainText(text);
|
|
8835
|
+
delete body.customRanges;
|
|
8836
|
+
doc = { body };
|
|
8837
|
+
} else doc = applyDocPasteMode(source, mode, style, payload.text);
|
|
8790
8838
|
if (unitId === _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY) {
|
|
8791
8839
|
doc = {
|
|
8792
8840
|
...source,
|
|
@@ -8990,12 +9038,11 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
8990
9038
|
}
|
|
8991
9039
|
}
|
|
8992
9040
|
async _setClipboardData(documentList, needCache = true, plainTextList) {
|
|
8993
|
-
var _documentList$0$body;
|
|
8994
9041
|
const copyId = (0, _univerjs_core.generateRandomId)(6);
|
|
8995
|
-
const text = (plainTextList
|
|
9042
|
+
const text = (plainTextList ?? documentList.map((doc) => {
|
|
8996
9043
|
var _doc$body3;
|
|
8997
9044
|
return ((_doc$body3 = doc.body) === null || _doc$body3 === void 0 ? void 0 : _doc$body3.dataStream) || "";
|
|
8998
|
-
}).join("\n")
|
|
9045
|
+
})).join("\n").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_START, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_END, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_ROW_START, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_ROW_END, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_CELL_START, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_CELL_END, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.BLOCK_START, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.BLOCK_END, "").replaceAll("\r\n", " ").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "");
|
|
8999
9046
|
let html = this._umdToHtml.convert(documentList);
|
|
9000
9047
|
let internalJson = "";
|
|
9001
9048
|
let internalDocData = null;
|
|
@@ -9053,7 +9100,6 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
9053
9100
|
const snapshot = docDataModel.getSnapshot();
|
|
9054
9101
|
if (body == null) return;
|
|
9055
9102
|
for (const range of allRanges) {
|
|
9056
|
-
var _docDataModel$getSelf2, _docBody$tables;
|
|
9057
9103
|
const { startOffset, endOffset, collapsed, rangeType } = range;
|
|
9058
9104
|
if (collapsed || startOffset == null || endOffset == null) continue;
|
|
9059
9105
|
if (rangeType === _univerjs_core.DOC_RANGE_TYPE.RECT) {
|
|
@@ -9063,20 +9109,9 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
9063
9109
|
plainTextResults.push(bodySlice.dataStream);
|
|
9064
9110
|
continue;
|
|
9065
9111
|
}
|
|
9066
|
-
const
|
|
9067
|
-
startOffset,
|
|
9068
|
-
endOffset,
|
|
9069
|
-
collapsed
|
|
9070
|
-
};
|
|
9071
|
-
const docBody = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.sliceBody(deleteRange.startOffset, deleteRange.endOffset, sliceType);
|
|
9072
|
-
if (docBody == null) continue;
|
|
9073
|
-
if ((_docBody$tables = docBody.tables) === null || _docBody$tables === void 0 ? void 0 : _docBody$tables.length) {
|
|
9074
|
-
var _body$tables2;
|
|
9075
|
-
const completeTableIds = new Set((_body$tables2 = body.tables) === null || _body$tables2 === void 0 ? void 0 : _body$tables2.filter((table) => table.startIndex >= startOffset && table.endIndex <= endOffset).map((table) => table.tableId));
|
|
9076
|
-
docBody.tables = docBody.tables.filter((table) => completeTableIds.has(table.tableId));
|
|
9077
|
-
}
|
|
9112
|
+
const docBody = (0, _univerjs_core.getBodySliceForTextXAction)(body, startOffset, endOffset, false, sliceType);
|
|
9078
9113
|
results.push(docBody);
|
|
9079
|
-
plainTextResults.push((copyContentHook === null || copyContentHook === void 0 ? void 0 : copyContentHook(
|
|
9114
|
+
plainTextResults.push((copyContentHook === null || copyContentHook === void 0 ? void 0 : copyContentHook(startOffset, endOffset, {
|
|
9080
9115
|
body,
|
|
9081
9116
|
segmentId,
|
|
9082
9117
|
unitId: docDataModel.getUnitId()
|
|
@@ -11750,7 +11785,6 @@ const DEFAULT_DOC_FIT_TO_WIDTH_OPTIONS = {
|
|
|
11750
11785
|
align: "center"
|
|
11751
11786
|
};
|
|
11752
11787
|
const defaultPluginConfig = {
|
|
11753
|
-
toc: false,
|
|
11754
11788
|
footer: true,
|
|
11755
11789
|
wordCount: true,
|
|
11756
11790
|
placeholder: true,
|
|
@@ -12967,7 +13001,7 @@ let DocPageLayoutService = class DocPageLayoutService extends _univerjs_core.Dis
|
|
|
12967
13001
|
sceneWidth = docsWidth + horizontalMargin * 2;
|
|
12968
13002
|
scrollToX = 0;
|
|
12969
13003
|
}
|
|
12970
|
-
if (engineHeight > docsHeight) sceneHeight = (engineHeight - pageMarginTop * 2) / viewScale;
|
|
13004
|
+
if (engineHeight > (docsHeight + pageMarginTop * 2) * viewScale) sceneHeight = (engineHeight - pageMarginTop * 2) / viewScale;
|
|
12971
13005
|
else sceneHeight = docsHeight + pageMarginTop * 2;
|
|
12972
13006
|
sceneHeight = this.resolveSceneHeight(sceneHeight);
|
|
12973
13007
|
scene.transformByState({
|
|
@@ -13681,9 +13715,13 @@ let DocRenderController = class DocRenderController extends _univerjs_core.RxDis
|
|
|
13681
13715
|
const interactionAnchor = priorityAnchorBelongsToMutation ? options.anchor : options.priorityAnchor ?? options.anchor;
|
|
13682
13716
|
let interactionViewportAnchor = priorityAnchorBelongsToMutation ? null : this._captureViewportAnchor(skeleton, options.priorityAnchor, options.invalidation);
|
|
13683
13717
|
const foregroundEndOffset = this._resolveContinuousForegroundEndOffset(skeleton, options.invalidation);
|
|
13718
|
+
const viewport = this._context.scene.getViewport("viewMain");
|
|
13719
|
+
const docsComponent = this._context.mainComponent;
|
|
13720
|
+
const minimumPublicationHeight = this._context.unit.documentStyle.documentFlavor === _univerjs_core.DocumentFlavor.MODERN && viewport != null && docsComponent instanceof _univerjs_engine_render.Documents ? Math.max(0, viewport.calcViewportInfo().viewBound.bottom - docsComponent.getOffsetConfig().docsTop) : void 0;
|
|
13684
13721
|
this._layoutCoordinator.schedule(skeleton, {
|
|
13685
13722
|
...options,
|
|
13686
13723
|
anchor: interactionAnchor,
|
|
13724
|
+
...minimumPublicationHeight != null && Number.isFinite(minimumPublicationHeight) && minimumPublicationHeight > 0 ? { minimumPublicationHeight } : {},
|
|
13687
13725
|
...foregroundEndOffset == null ? {} : { foregroundEndOffset },
|
|
13688
13726
|
preserveInteractionWindow: interactionAnchor != null && interactionAnchor !== options.anchor,
|
|
13689
13727
|
reuseUnaffectedTail: false
|
|
@@ -15043,7 +15081,8 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
15043
15081
|
const updatePosition = () => {
|
|
15044
15082
|
try {
|
|
15045
15083
|
const newPosition = calc();
|
|
15046
|
-
|
|
15084
|
+
const previous = position$.value;
|
|
15085
|
+
if (newPosition && (newPosition.left !== previous.left || newPosition.right !== previous.right || newPosition.top !== previous.top || newPosition.bottom !== previous.bottom)) position$.next(newPosition);
|
|
15047
15086
|
} catch {}
|
|
15048
15087
|
};
|
|
15049
15088
|
disposable.add(this._commandService.onCommandExecuted((commandInfo) => {
|
|
@@ -15099,6 +15138,7 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
15099
15138
|
disposable.add(currentRender.scene.onTransformChange$.subscribeEvent(() => {
|
|
15100
15139
|
updatePositions();
|
|
15101
15140
|
}));
|
|
15141
|
+
if (currentRender.mainComponent) disposable.add(currentRender.mainComponent.onTransformChange$.subscribeEvent(updatePositions));
|
|
15102
15142
|
return {
|
|
15103
15143
|
positions,
|
|
15104
15144
|
positions$,
|
|
@@ -15110,14 +15150,18 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
15110
15150
|
if (!currentRender) throw new Error(`Current render not found, unitId: ${unitId}`);
|
|
15111
15151
|
const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
|
|
15112
15152
|
const popupManagerService = this._resolvePopupManagerService(popupInjector);
|
|
15113
|
-
const { position, position$, disposable } = this._createRectPositionObserver(rect, currentRender);
|
|
15153
|
+
const { position, position$, disposable, updatePosition } = this._createRectPositionObserver(rect, currentRender);
|
|
15154
|
+
if (popup.positionChanges$) disposable.add(popup.positionChanges$.subscribe(updatePosition));
|
|
15114
15155
|
const id = popupManagerService.addPopup({
|
|
15115
15156
|
...popup,
|
|
15116
15157
|
unitId,
|
|
15117
15158
|
subUnitId: "default",
|
|
15118
15159
|
connectorInjector: popupInjector,
|
|
15119
15160
|
anchorRect: position,
|
|
15120
|
-
anchorRect$: position
|
|
15161
|
+
anchorRect$: position$.pipe((0, rxjs.throttleTime)(0, rxjs.animationFrameScheduler, {
|
|
15162
|
+
leading: true,
|
|
15163
|
+
trailing: true
|
|
15164
|
+
})),
|
|
15121
15165
|
canvasElement: currentRender.engine.getCanvasElement()
|
|
15122
15166
|
});
|
|
15123
15167
|
const popupActivity = popup.requiresStableLayout === false ? null : this._beginPopupActivity(unitId);
|
|
@@ -15149,7 +15193,10 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
15149
15193
|
subUnitId: "default",
|
|
15150
15194
|
connectorInjector: popupInjector,
|
|
15151
15195
|
anchorRect: position,
|
|
15152
|
-
anchorRect$: position
|
|
15196
|
+
anchorRect$: position$.pipe((0, rxjs.throttleTime)(0, rxjs.animationFrameScheduler, {
|
|
15197
|
+
leading: true,
|
|
15198
|
+
trailing: true
|
|
15199
|
+
})),
|
|
15153
15200
|
canvasElement: currentRender.engine.getCanvasElement()
|
|
15154
15201
|
});
|
|
15155
15202
|
const popupActivity = popup.requiresStableLayout === false ? null : this._beginPopupActivity(unitId);
|
|
@@ -15191,7 +15238,11 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
15191
15238
|
}
|
|
15192
15239
|
return direction.includes("top") ? bounds[0] : bounds[bounds.length - 1];
|
|
15193
15240
|
};
|
|
15194
|
-
const
|
|
15241
|
+
const popupBounds$ = bounds$.pipe((0, rxjs.throttleTime)(0, rxjs.animationFrameScheduler, {
|
|
15242
|
+
leading: true,
|
|
15243
|
+
trailing: true
|
|
15244
|
+
}));
|
|
15245
|
+
const position$ = popupBounds$.pipe((0, rxjs.filter)((bounds) => bounds.length > 0), (0, rxjs.map)(getAnchor));
|
|
15195
15246
|
let id;
|
|
15196
15247
|
let popupActivity = null;
|
|
15197
15248
|
const removePopup = () => {
|
|
@@ -15216,7 +15267,7 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
15216
15267
|
anchorRect: getAnchor(bounds),
|
|
15217
15268
|
anchorRect$: position$,
|
|
15218
15269
|
excludeRects: bounds,
|
|
15219
|
-
excludeRects$:
|
|
15270
|
+
excludeRects$: popupBounds$,
|
|
15220
15271
|
direction: [
|
|
15221
15272
|
"top",
|
|
15222
15273
|
"bottom",
|
|
@@ -15525,6 +15576,12 @@ let DocEventManagerService = class DocEventManagerService extends _univerjs_core
|
|
|
15525
15576
|
}));
|
|
15526
15577
|
}
|
|
15527
15578
|
_initResetDirty() {
|
|
15579
|
+
this.disposeWithMe(this._documents.onTransformChange$.subscribeEvent(() => {
|
|
15580
|
+
this._customRangeDirty = true;
|
|
15581
|
+
this._bulletDirty = true;
|
|
15582
|
+
this._paragraphDirty = true;
|
|
15583
|
+
this._tableBoundsDirty = true;
|
|
15584
|
+
}));
|
|
15528
15585
|
this.disposeWithMe(this._skeleton.dirty$.subscribe(() => {
|
|
15529
15586
|
this._customRangeDirty = true;
|
|
15530
15587
|
this._bulletDirty = true;
|
|
@@ -16016,6 +16073,9 @@ let DocEventManagerService = class DocEventManagerService extends _univerjs_core
|
|
|
16016
16073
|
return (_this$_tableCellBound2 = this._tableCellBounds.get(tableId)) === null || _this$_tableCellBound2 === void 0 ? void 0 : _this$_tableCellBound2.find((bound) => bound.rowIndex === rowIndex && bound.colIndex === colIndex && (pageIndex == null || bound.pageIndex === pageIndex));
|
|
16017
16074
|
}
|
|
16018
16075
|
findParagraphBoundByIndex(index) {
|
|
16076
|
+
this._buildParagraphBounds();
|
|
16077
|
+
const paragraph = this._paragraphBounds.get(index);
|
|
16078
|
+
if (paragraph) return paragraph;
|
|
16019
16079
|
this._buildTableBounds();
|
|
16020
16080
|
this._buildTableCellsForDocumentRange(index, index);
|
|
16021
16081
|
let tableParagraph = this._tableParagraphBoundsByIndex.get(index);
|
|
@@ -16027,9 +16087,6 @@ let DocEventManagerService = class DocEventManagerService extends _univerjs_core
|
|
|
16027
16087
|
if (tableParagraph) return tableParagraph;
|
|
16028
16088
|
}
|
|
16029
16089
|
if (tableParagraph) return tableParagraph;
|
|
16030
|
-
this._buildParagraphBounds();
|
|
16031
|
-
const paragraph = this._paragraphBounds.get(index);
|
|
16032
|
-
if (paragraph) return paragraph;
|
|
16033
16090
|
}
|
|
16034
16091
|
findParagraphBoundsInRange(startIndex, endIndex) {
|
|
16035
16092
|
this._buildTableBounds();
|
|
@@ -16667,6 +16724,28 @@ const DocOpenPageSettingCommand = {
|
|
|
16667
16724
|
}
|
|
16668
16725
|
};
|
|
16669
16726
|
|
|
16727
|
+
//#endregion
|
|
16728
|
+
//#region src/views/EditorColorPicker.tsx
|
|
16729
|
+
function EditorColorPicker(props) {
|
|
16730
|
+
const containerRef = (0, react.useRef)(null);
|
|
16731
|
+
const ColorPickerComponent = (0, _univerjs_ui.useDependency)(_univerjs_ui.ComponentManager).get(_univerjs_ui.COLOR_PICKER_COMPONENT);
|
|
16732
|
+
(0, react.useEffect)(() => {
|
|
16733
|
+
const container = containerRef.current;
|
|
16734
|
+
const view = container === null || container === void 0 ? void 0 : container.ownerDocument.defaultView;
|
|
16735
|
+
if (!container || !view) return;
|
|
16736
|
+
const preserveComposition = (event) => {
|
|
16737
|
+
if (event.isComposing && (event.key === "Enter" || event.key === "Escape") && event.target instanceof view.HTMLInputElement && container.contains(event.target)) event.stopPropagation();
|
|
16738
|
+
};
|
|
16739
|
+
view.addEventListener("keydown", preserveComposition, true);
|
|
16740
|
+
return () => view.removeEventListener("keydown", preserveComposition, true);
|
|
16741
|
+
}, []);
|
|
16742
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
16743
|
+
ref: containerRef,
|
|
16744
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorPickerComponent, { ...props })
|
|
16745
|
+
});
|
|
16746
|
+
}
|
|
16747
|
+
EditorColorPicker.componentKey = "docs.editor-color-picker";
|
|
16748
|
+
|
|
16670
16749
|
//#endregion
|
|
16671
16750
|
//#region src/views/const.ts
|
|
16672
16751
|
/**
|
|
@@ -17470,7 +17549,7 @@ function TextColorSelectorMenuItemFactory(accessor) {
|
|
|
17470
17549
|
type: _univerjs_ui.MenuItemType.BUTTON_SELECTOR,
|
|
17471
17550
|
selections: [{
|
|
17472
17551
|
label: {
|
|
17473
|
-
name:
|
|
17552
|
+
name: EditorColorPicker.componentKey,
|
|
17474
17553
|
hoverable: false,
|
|
17475
17554
|
selectable: false
|
|
17476
17555
|
},
|
|
@@ -17899,7 +17978,7 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
|
|
|
17899
17978
|
icon: "PaintBucketDoubleIcon",
|
|
17900
17979
|
selections: [{
|
|
17901
17980
|
label: {
|
|
17902
|
-
name:
|
|
17981
|
+
name: EditorColorPicker.componentKey,
|
|
17903
17982
|
hoverable: false,
|
|
17904
17983
|
selectable: false
|
|
17905
17984
|
},
|
|
@@ -20745,10 +20824,30 @@ function DocFooter() {
|
|
|
20745
20824
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocFooterContent, {});
|
|
20746
20825
|
}
|
|
20747
20826
|
|
|
20827
|
+
//#endregion
|
|
20828
|
+
//#region src/views/doc-side-menu-layout.ts
|
|
20829
|
+
function isDocSideMenuTableOverlapping(outline, table, viewport) {
|
|
20830
|
+
if (table.bottom <= outline.top || table.top >= outline.bottom) return false;
|
|
20831
|
+
let left = table.left;
|
|
20832
|
+
let right = table.right;
|
|
20833
|
+
if (viewport && (viewport.leadingInsetLeft ?? 0) + viewport.contentWidth + (viewport.trailingInsetRight ?? 0) > viewport.viewportWidth) {
|
|
20834
|
+
const clipLeft = viewport.viewportLeft ?? table.left - (viewport.leadingInsetLeft ?? 0);
|
|
20835
|
+
left = Math.max(clipLeft, table.left - viewport.scrollLeft);
|
|
20836
|
+
right = Math.min(clipLeft + viewport.viewportWidth, table.left + viewport.contentWidth - viewport.scrollLeft);
|
|
20837
|
+
}
|
|
20838
|
+
return right > left && left < outline.right && right > outline.left;
|
|
20839
|
+
}
|
|
20840
|
+
|
|
20748
20841
|
//#endregion
|
|
20749
20842
|
//#region src/views/SideMenu.tsx
|
|
20750
20843
|
const SideMenu = (0, react.forwardRef)((props, ref) => {
|
|
20751
|
-
const { label, menus, onClick, className, style, mode, maxHeight, activeId, open, onOpenChange, maxWidth, wrapperClass, wrapperStyle, iconClass, iconStyle } = props;
|
|
20844
|
+
const { label, menus, onClick, className, style, mode = "side-bar", maxHeight, activeId, open: controlledOpen, onOpenChange, maxWidth, wrapperClass, wrapperStyle, iconClass, iconStyle } = props;
|
|
20845
|
+
const [expanded, setExpanded] = (0, react.useState)(mode === "side-bar");
|
|
20846
|
+
const open = controlledOpen ?? expanded;
|
|
20847
|
+
const handleOpenChange = (0, react.useCallback)((nextOpen) => {
|
|
20848
|
+
if (controlledOpen === void 0) setExpanded(nextOpen);
|
|
20849
|
+
onOpenChange === null || onOpenChange === void 0 || onOpenChange(nextOpen);
|
|
20850
|
+
}, [controlledOpen, onOpenChange]);
|
|
20752
20851
|
const panelId = (0, react.useId)();
|
|
20753
20852
|
const wrapperRef = (0, react.useRef)(null);
|
|
20754
20853
|
const containerRef = (0, react.useRef)(null);
|
|
@@ -20776,13 +20875,13 @@ const SideMenu = (0, react.forwardRef)((props, ref) => {
|
|
|
20776
20875
|
if (!open || mode !== "float") return;
|
|
20777
20876
|
const handlePointerDown = (event) => {
|
|
20778
20877
|
var _wrapperRef$current;
|
|
20779
|
-
if (event.target instanceof Node && !((_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.contains(event.target)))
|
|
20878
|
+
if (event.target instanceof Node && !((_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.contains(event.target))) handleOpenChange(false);
|
|
20780
20879
|
};
|
|
20781
20880
|
document.addEventListener("pointerdown", handlePointerDown);
|
|
20782
20881
|
return () => document.removeEventListener("pointerdown", handlePointerDown);
|
|
20783
20882
|
}, [
|
|
20883
|
+
handleOpenChange,
|
|
20784
20884
|
mode,
|
|
20785
|
-
onOpenChange,
|
|
20786
20885
|
open
|
|
20787
20886
|
]);
|
|
20788
20887
|
const handleKeyDown = (event) => {
|
|
@@ -20791,7 +20890,7 @@ const SideMenu = (0, react.forwardRef)((props, ref) => {
|
|
|
20791
20890
|
var _toggleRef$current;
|
|
20792
20891
|
event.preventDefault();
|
|
20793
20892
|
event.stopPropagation();
|
|
20794
|
-
|
|
20893
|
+
handleOpenChange(false);
|
|
20795
20894
|
(_toggleRef$current = toggleRef.current) === null || _toggleRef$current === void 0 || _toggleRef$current.focus();
|
|
20796
20895
|
return;
|
|
20797
20896
|
}
|
|
@@ -20820,51 +20919,47 @@ const SideMenu = (0, react.forwardRef)((props, ref) => {
|
|
|
20820
20919
|
};
|
|
20821
20920
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
20822
20921
|
ref: wrapperRef,
|
|
20823
|
-
className: (0, _univerjs_design.clsx)("univer-relative univer-
|
|
20922
|
+
className: (0, _univerjs_design.clsx)("univer-relative univer-ms-4", wrapperClass),
|
|
20824
20923
|
style: {
|
|
20825
|
-
width,
|
|
20924
|
+
width: open ? width : 32,
|
|
20826
20925
|
...wrapperStyle
|
|
20827
20926
|
},
|
|
20828
20927
|
onKeyDown: handleKeyDown,
|
|
20829
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
20928
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
20830
20929
|
ref: toggleRef,
|
|
20831
20930
|
type: "button",
|
|
20931
|
+
variant: "ghost",
|
|
20932
|
+
size: "icon",
|
|
20832
20933
|
"aria-label": label,
|
|
20833
20934
|
"aria-expanded": !!open,
|
|
20834
20935
|
"aria-controls": open ? panelId : void 0,
|
|
20835
20936
|
title: label,
|
|
20836
|
-
onClick: () =>
|
|
20837
|
-
className: (0, _univerjs_design.clsx)("univer-absolute univer-
|
|
20838
|
-
style:
|
|
20839
|
-
|
|
20840
|
-
|
|
20841
|
-
|
|
20842
|
-
|
|
20843
|
-
|
|
20937
|
+
onClick: () => handleOpenChange(!open),
|
|
20938
|
+
className: (0, _univerjs_design.clsx)("univer-absolute univer-start-0 univer-top-0 univer-z-10 !univer-text-gray-500 hover:!univer-text-gray-900 focus-visible:univer-outline focus-visible:univer-outline-2 focus-visible:univer-outline-primary-600 dark:!univer-text-gray-400 dark:hover:!univer-text-gray-100", iconClass),
|
|
20939
|
+
style: iconStyle,
|
|
20940
|
+
children: open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreLeftIcon, {
|
|
20941
|
+
"aria-hidden": "true",
|
|
20942
|
+
className: "!univer-size-6"
|
|
20943
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CatalogueIcon, {
|
|
20944
|
+
"aria-hidden": "true",
|
|
20945
|
+
className: "!univer-size-5"
|
|
20946
|
+
})
|
|
20947
|
+
}), open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("nav", {
|
|
20844
20948
|
id: panelId,
|
|
20845
20949
|
"aria-label": label,
|
|
20846
|
-
className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-w-full univer-flex-col univer-overflow-hidden univer-
|
|
20950
|
+
className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-w-full univer-flex-col univer-overflow-hidden univer-pt-10", mode === "float" && "univer-bg-gray-0 dark:univer-bg-gray-900", className),
|
|
20847
20951
|
style: {
|
|
20848
20952
|
maxHeight,
|
|
20849
20953
|
...style
|
|
20850
20954
|
},
|
|
20851
|
-
children:
|
|
20852
|
-
className: "univer-flex univer-h-11 univer-shrink-0 univer-items-center univer-gap-2 univer-px-3 univer-pr-12 univer-text-xs univer-font-medium univer-text-gray-500 dark:univer-text-gray-400",
|
|
20853
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CatalogueIcon, {
|
|
20854
|
-
"aria-hidden": "true",
|
|
20855
|
-
className: "univer-shrink-0 univer-text-sm"
|
|
20856
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
20857
|
-
className: "univer-truncate",
|
|
20858
|
-
children: label
|
|
20859
|
-
})]
|
|
20860
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
20955
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
20861
20956
|
ref: containerRef,
|
|
20862
|
-
className: (0, _univerjs_design.clsx)("univer-relative univer-min-h-0 univer-overflow-y-auto univer-overscroll-contain univer-
|
|
20957
|
+
className: (0, _univerjs_design.clsx)("univer-relative univer-min-h-0 univer-overflow-y-auto univer-overscroll-contain univer-pb-2", _univerjs_design.scrollbarClassName),
|
|
20863
20958
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ol", {
|
|
20864
20959
|
className: "univer-m-0 univer-list-none univer-p-0",
|
|
20865
20960
|
children: menus === null || menus === void 0 ? void 0 : menus.map((menu) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
20866
|
-
className: menu.isTitle ? "univer-mb-
|
|
20867
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.
|
|
20961
|
+
className: menu.isTitle ? "univer-mb-2" : void 0,
|
|
20962
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
20868
20963
|
ref: (element) => {
|
|
20869
20964
|
if (element) itemsRef.current.set(menu.id, element);
|
|
20870
20965
|
else itemsRef.current.delete(menu.id);
|
|
@@ -20872,39 +20967,28 @@ const SideMenu = (0, react.forwardRef)((props, ref) => {
|
|
|
20872
20967
|
type: "button",
|
|
20873
20968
|
"aria-current": menu.id === activeId ? "location" : void 0,
|
|
20874
20969
|
title: menu.text,
|
|
20875
|
-
className: (0, _univerjs_design.clsx)("univer-
|
|
20876
|
-
"univer-
|
|
20877
|
-
"univer-text-gray-900 dark:univer-text-gray-100": menu.isTitle && menu.id !== activeId,
|
|
20878
|
-
"univer-text-gray-
|
|
20970
|
+
className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-min-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-border-0 univer-bg-transparent univer-py-1.5 univer-pe-2 univer-text-start univer-text-sm univer-leading-5 univer-transition-colors focus-visible:univer-outline focus-visible:univer-outline-2 focus-visible:-univer-outline-offset-2 focus-visible:univer-outline-primary-600", menu.isTitle ? "univer-font-medium" : "univer-font-normal", {
|
|
20971
|
+
"univer-text-primary-600 dark:univer-text-primary-400": menu.id === activeId,
|
|
20972
|
+
"univer-text-gray-600 hover:univer-text-gray-900 dark:univer-text-gray-300 dark:hover:univer-text-gray-100": menu.isTitle && menu.id !== activeId,
|
|
20973
|
+
"univer-text-gray-500 hover:univer-text-gray-900 dark:univer-text-gray-400 dark:hover:univer-text-gray-100": !menu.isTitle && menu.id !== activeId
|
|
20879
20974
|
}),
|
|
20880
|
-
style: {
|
|
20975
|
+
style: { paddingInlineStart: menu.isTitle ? 0 : 12 + Math.max(0, menu.level - 1) * 12 },
|
|
20881
20976
|
onClick: () => {
|
|
20882
20977
|
onClick === null || onClick === void 0 || onClick(menu);
|
|
20883
20978
|
if (mode === "float") {
|
|
20884
20979
|
var _toggleRef$current2;
|
|
20885
|
-
|
|
20980
|
+
handleOpenChange(false);
|
|
20886
20981
|
(_toggleRef$current2 = toggleRef.current) === null || _toggleRef$current2 === void 0 || _toggleRef$current2.focus();
|
|
20887
20982
|
}
|
|
20888
20983
|
},
|
|
20889
|
-
children:
|
|
20890
|
-
menu.
|
|
20891
|
-
|
|
20892
|
-
|
|
20893
|
-
style: { left: 14 + Math.max(0, menu.level - 2) * 12 }
|
|
20894
|
-
}),
|
|
20895
|
-
menu.id === activeId && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
20896
|
-
"aria-hidden": "true",
|
|
20897
|
-
className: "univer-absolute univer-bottom-2 univer-left-0 univer-top-2 univer-w-0.5 univer-rounded-full univer-bg-primary-600 dark:univer-bg-primary-400"
|
|
20898
|
-
}),
|
|
20899
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
20900
|
-
className: menu.isTitle ? "univer-line-clamp-2 univer-break-words" : "univer-truncate",
|
|
20901
|
-
children: menu.text
|
|
20902
|
-
})
|
|
20903
|
-
]
|
|
20984
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
20985
|
+
className: menu.isTitle ? "univer-line-clamp-2 univer-break-words" : "univer-truncate",
|
|
20986
|
+
children: menu.text
|
|
20987
|
+
})
|
|
20904
20988
|
})
|
|
20905
20989
|
}, menu.id))
|
|
20906
20990
|
})
|
|
20907
|
-
})
|
|
20991
|
+
})
|
|
20908
20992
|
})]
|
|
20909
20993
|
});
|
|
20910
20994
|
});
|
|
@@ -20926,52 +21010,77 @@ function findActiveHeading(boundMap, paragraphMap, scrollTop, bottom) {
|
|
|
20926
21010
|
if (!boundMap) return;
|
|
20927
21011
|
const paragraphBounds = Array.from(boundMap.values());
|
|
20928
21012
|
const paragraphIndex = paragraphBounds.findIndex((p) => p.paragraphStart !== p.paragraphEnd && p.rect.top < bottom && p.rect.bottom > scrollTop);
|
|
20929
|
-
if (paragraphIndex === -1) return
|
|
20930
|
-
|
|
21013
|
+
if (paragraphIndex === -1) return;
|
|
21014
|
+
let lastParagraphIndex = paragraphBounds.length - 1;
|
|
21015
|
+
while (lastParagraphIndex > paragraphIndex) {
|
|
21016
|
+
const bound = paragraphBounds[lastParagraphIndex];
|
|
21017
|
+
if (bound.paragraphStart !== bound.paragraphEnd && bound.rect.top < bottom && bound.rect.bottom > scrollTop) break;
|
|
21018
|
+
lastParagraphIndex--;
|
|
21019
|
+
}
|
|
20931
21020
|
for (let i = paragraphIndex; i <= lastParagraphIndex; i++) {
|
|
20932
|
-
var _paragraph$paragraphS;
|
|
20933
21021
|
const bound = paragraphBounds[i];
|
|
20934
21022
|
const paragraph = paragraphMap.get(bound.startIndex);
|
|
20935
|
-
if (paragraph
|
|
21023
|
+
if (paragraph) return paragraph.paragraphId;
|
|
20936
21024
|
}
|
|
20937
21025
|
for (let i = paragraphIndex; i >= 0; i--) {
|
|
20938
|
-
var _paragraph$paragraphS2;
|
|
20939
21026
|
const bound = paragraphBounds[i];
|
|
20940
21027
|
const paragraph = paragraphMap.get(bound.startIndex);
|
|
20941
|
-
if (paragraph
|
|
21028
|
+
if (paragraph) return paragraph.paragraphId;
|
|
20942
21029
|
}
|
|
20943
21030
|
}
|
|
20944
21031
|
const TITLE_ID = "__title";
|
|
20945
21032
|
function DocSideMenu() {
|
|
20946
21033
|
const config = (0, _univerjs_ui.useConfigValue)(DOCS_UI_PLUGIN_CONFIG_KEY);
|
|
20947
21034
|
const workbenchService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IWorkbenchService);
|
|
20948
|
-
if ((0, _univerjs_ui.useObservable)(workbenchService.rootUnitType$, null, true) === _univerjs_core.UniverInstanceType.UNIVER_DOC && (config === null || config === void 0 ? void 0 : config.toc)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocSideMenuContent, {});
|
|
21035
|
+
if ((0, _univerjs_ui.useObservable)(workbenchService.rootUnitType$, null, true) === _univerjs_core.UniverInstanceType.UNIVER_DOC && (config === null || config === void 0 ? void 0 : config.toc) !== false) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocSideMenuContent, { toc: config === null || config === void 0 ? void 0 : config.toc });
|
|
20949
21036
|
return null;
|
|
20950
21037
|
}
|
|
20951
|
-
function DocSideMenuContent() {
|
|
20952
|
-
var _documentData$body, _documentData$body3;
|
|
21038
|
+
function DocSideMenuContent({ toc }) {
|
|
21039
|
+
var _currentDoc$getSnapsh, _documentData$body, _documentData$body3, _menus$find;
|
|
20953
21040
|
const instanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
20954
21041
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
20955
21042
|
const currentDoc = (0, _univerjs_ui.useObservable)(() => instanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC), void 0, false, [instanceService]);
|
|
21043
|
+
const enabled = toc ?? (currentDoc === null || currentDoc === void 0 || (_currentDoc$getSnapsh = currentDoc.getSnapshot().documentStyle) === null || _currentDoc$getSnapsh === void 0 ? void 0 : _currentDoc$getSnapsh.documentFlavor) === _univerjs_core.DocumentFlavor.MODERN;
|
|
20956
21044
|
const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
|
|
20957
21045
|
const documentData = (0, _univerjs_ui.useObservable)(currentDoc ? () => currentDoc.change$.pipe((0, rxjs.debounceTime)(100), (0, rxjs.map)(() => currentDoc.getSnapshot())) : null, currentDoc === null || currentDoc === void 0 ? void 0 : currentDoc.getSnapshot(), false, [currentDoc]);
|
|
20958
21046
|
const fullDataStream = (documentData === null || documentData === void 0 || (_documentData$body = documentData.body) === null || _documentData$body === void 0 ? void 0 : _documentData$body.dataStream) ?? "";
|
|
20959
21047
|
const [activeId, setActiveId] = (0, react.useState)(void 0);
|
|
21048
|
+
const [outlineHeight, setOutlineHeight] = (0, react.useState)(0);
|
|
21049
|
+
const containerRef = (0, react.useRef)(null);
|
|
20960
21050
|
const unitId = (currentDoc === null || currentDoc === void 0 ? void 0 : currentDoc.getUnitId()) ?? "";
|
|
20961
21051
|
const renderer = renderManagerService.getRenderUnitById(unitId);
|
|
20962
21052
|
const title = documentData === null || documentData === void 0 ? void 0 : documentData.title;
|
|
20963
21053
|
const docEventManagerService = renderer === null || renderer === void 0 ? void 0 : renderer.with(DocEventManagerService);
|
|
20964
|
-
const
|
|
21054
|
+
const viewport = renderer === null || renderer === void 0 ? void 0 : renderer.scene.getViewport("viewMain");
|
|
20965
21055
|
const readLayout = () => {
|
|
20966
21056
|
var _renderer$mainCompone;
|
|
21057
|
+
const scaleX = (renderer === null || renderer === void 0 ? void 0 : renderer.scene.scaleX) ?? 1;
|
|
21058
|
+
const scaleY = (renderer === null || renderer === void 0 ? void 0 : renderer.scene.scaleY) ?? 1;
|
|
21059
|
+
const scrollX = (viewport === null || viewport === void 0 ? void 0 : viewport.viewportScrollX) ?? 0;
|
|
21060
|
+
const scrollY = (viewport === null || viewport === void 0 ? void 0 : viewport.viewportScrollY) ?? 0;
|
|
21061
|
+
const canvasHeight = (renderer === null || renderer === void 0 ? void 0 : renderer.engine.height) ?? 0;
|
|
21062
|
+
const left = (((renderer === null || renderer === void 0 || (_renderer$mainCompone = renderer.mainComponent) === null || _renderer$mainCompone === void 0 ? void 0 : _renderer$mainCompone.left) ?? 0) - scrollX) * scaleX;
|
|
21063
|
+
const outlineRect = {
|
|
21064
|
+
left: scrollX + 16 / scaleX,
|
|
21065
|
+
right: scrollX + 272 / scaleX,
|
|
21066
|
+
top: scrollY + 16 / scaleY,
|
|
21067
|
+
bottom: scrollY + Math.min(canvasHeight - 16, 16 + outlineHeight) / scaleY
|
|
21068
|
+
};
|
|
21069
|
+
const overlapsTable = left >= 288 && outlineHeight > 0 && Array.from((docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.tableBounds.values()) ?? []).some(({ tableId, rect }) => isDocSideMenuTableOverlapping(outlineRect, rect, (0, _univerjs_engine_render.getDocsTableRenderViewport)(unitId, (0, _univerjs_engine_render.getTableIdAndSliceIndex)(tableId).tableId)));
|
|
20967
21070
|
return {
|
|
20968
|
-
left
|
|
20969
|
-
canvasHeight
|
|
21071
|
+
left,
|
|
21072
|
+
canvasHeight,
|
|
20970
21073
|
canvasWidth: (renderer === null || renderer === void 0 ? void 0 : renderer.engine.width) ?? 0,
|
|
20971
|
-
scaleY
|
|
21074
|
+
scaleY,
|
|
21075
|
+
overlapsTable
|
|
20972
21076
|
};
|
|
20973
21077
|
};
|
|
20974
|
-
const
|
|
21078
|
+
const layout = (0, _univerjs_ui.useObservable)((renderer === null || renderer === void 0 ? void 0 : renderer.engine.onTransformChange$) ? () => (0, rxjs.merge)((0, _univerjs_core.fromEventSubject)(renderer.engine.onTransformChange$), (0, _univerjs_core.fromEventSubject)(renderer.scene.onTransformChange$), ...renderer.mainComponent instanceof _univerjs_engine_render.Documents ? [renderer.mainComponent.pageRender$] : [], ...viewport ? [(0, _univerjs_core.fromEventSubject)(viewport.onScrollAfter$)] : [], ...renderer.mainComponent ? [(0, _univerjs_core.fromEventSubject)(renderer.mainComponent.onTransformChange$)] : []).pipe((0, rxjs.auditTime)(33), (0, rxjs.map)(readLayout), (0, rxjs.startWith)(readLayout()), (0, rxjs.distinctUntilChanged)((previous, current) => previous.left === current.left && previous.canvasHeight === current.canvasHeight && previous.canvasWidth === current.canvasWidth && previous.scaleY === current.scaleY && previous.overlapsTable === current.overlapsTable)) : null, readLayout(), false, [
|
|
21079
|
+
renderer,
|
|
21080
|
+
viewport,
|
|
21081
|
+
outlineHeight
|
|
21082
|
+
]);
|
|
21083
|
+
const { left, canvasHeight, canvasWidth, scaleY } = layout;
|
|
20975
21084
|
const paragraphs = (0, react.useMemo)(() => {
|
|
20976
21085
|
var _documentData$body2;
|
|
20977
21086
|
return (documentData === null || documentData === void 0 || (_documentData$body2 = documentData.body) === null || _documentData$body2 === void 0 ? void 0 : _documentData$body2.paragraphs) ?? [];
|
|
@@ -20980,22 +21089,26 @@ function DocSideMenuContent() {
|
|
|
20980
21089
|
dataStream: fullDataStream,
|
|
20981
21090
|
paragraphs
|
|
20982
21091
|
}), [fullDataStream, paragraphs]);
|
|
21092
|
+
const headingParagraphs = (0, react.useMemo)(() => paragraphs.filter((p) => {
|
|
21093
|
+
var _p$paragraphStyle;
|
|
21094
|
+
return ((_p$paragraphStyle = p.paragraphStyle) === null || _p$paragraphStyle === void 0 ? void 0 : _p$paragraphStyle.namedStyleType) !== void 0 && p.paragraphStyle.namedStyleType !== _univerjs_core.NamedStyleType.SUBTITLE && p.paragraphStyle.namedStyleType !== _univerjs_core.NamedStyleType.NORMAL_TEXT;
|
|
21095
|
+
}).map((p) => p.paragraphId ? p : {
|
|
21096
|
+
...p,
|
|
21097
|
+
paragraphId: `__paragraph_${p.startIndex}`
|
|
21098
|
+
}), [paragraphs]);
|
|
20983
21099
|
const paragraphMap = (0, react.useMemo)(() => {
|
|
20984
21100
|
const map = /* @__PURE__ */ new Map();
|
|
20985
|
-
|
|
21101
|
+
headingParagraphs.forEach((p) => {
|
|
20986
21102
|
map.set(p.startIndex, p);
|
|
20987
21103
|
});
|
|
20988
21104
|
return map;
|
|
20989
|
-
}, [
|
|
20990
|
-
const mode = left <
|
|
20991
|
-
const paragraphMenus =
|
|
20992
|
-
var _p$paragraphStyle;
|
|
20993
|
-
return ((_p$paragraphStyle = p.paragraphStyle) === null || _p$paragraphStyle === void 0 ? void 0 : _p$paragraphStyle.namedStyleType) !== void 0 && p.paragraphStyle.namedStyleType !== _univerjs_core.NamedStyleType.SUBTITLE && p.paragraphStyle.namedStyleType !== _univerjs_core.NamedStyleType.NORMAL_TEXT;
|
|
20994
|
-
}).map((p) => {
|
|
21105
|
+
}, [headingParagraphs]);
|
|
21106
|
+
const mode = left < 288 || layout.overlapsTable ? "float" : "side-bar";
|
|
21107
|
+
const paragraphMenus = headingParagraphs.map((p) => {
|
|
20995
21108
|
var _p$paragraphStyle2;
|
|
20996
21109
|
const level = transformNamedStyleTypeToLevel(p.paragraphStyle.namedStyleType);
|
|
20997
21110
|
return {
|
|
20998
|
-
id: p.
|
|
21111
|
+
id: p.paragraphId,
|
|
20999
21112
|
text: (0, _univerjs_core.getPlainText)(fullDataStream.slice(paragraphStarts.get(p.startIndex), p.startIndex)),
|
|
21000
21113
|
level,
|
|
21001
21114
|
isTitle: ((_p$paragraphStyle2 = p.paragraphStyle) === null || _p$paragraphStyle2 === void 0 ? void 0 : _p$paragraphStyle2.namedStyleType) === _univerjs_core.NamedStyleType.TITLE
|
|
@@ -21004,7 +21117,7 @@ function DocSideMenuContent() {
|
|
|
21004
21117
|
const handleScroll = (0, _univerjs_ui.useEvent)((params) => {
|
|
21005
21118
|
const scrollTop = params.viewportScrollY;
|
|
21006
21119
|
const bottom = scrollTop + canvasHeight / scaleY;
|
|
21007
|
-
const activeId = findActiveHeading(paragraphBounds, paragraphMap, scrollTop, bottom);
|
|
21120
|
+
const activeId = findActiveHeading(docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.paragraphBounds, paragraphMap, scrollTop, bottom);
|
|
21008
21121
|
if (activeId) setActiveId(activeId);
|
|
21009
21122
|
});
|
|
21010
21123
|
const menus = (paragraphMenus === null || paragraphMenus === void 0 ? void 0 : paragraphMenus.find((p) => p.isTitle)) ? paragraphMenus : [...title ? [{
|
|
@@ -21013,7 +21126,32 @@ function DocSideMenuContent() {
|
|
|
21013
21126
|
level: 1,
|
|
21014
21127
|
isTitle: true
|
|
21015
21128
|
}] : [], ...paragraphMenus ?? []].filter(Boolean);
|
|
21016
|
-
const
|
|
21129
|
+
const outlineTitle = (_menus$find = menus.find((menu) => menu.isTitle)) === null || _menus$find === void 0 ? void 0 : _menus$find.text;
|
|
21130
|
+
(0, react.useLayoutEffect)(() => {
|
|
21131
|
+
setOutlineHeight(0);
|
|
21132
|
+
}, [
|
|
21133
|
+
unitId,
|
|
21134
|
+
menus.length,
|
|
21135
|
+
outlineTitle
|
|
21136
|
+
]);
|
|
21137
|
+
(0, react.useLayoutEffect)(() => {
|
|
21138
|
+
const container = containerRef.current;
|
|
21139
|
+
const menu = container === null || container === void 0 ? void 0 : container.firstElementChild;
|
|
21140
|
+
if (!container || !menu) return;
|
|
21141
|
+
const measureOutline = () => {
|
|
21142
|
+
var _container$querySelec;
|
|
21143
|
+
const height = (_container$querySelec = container.querySelector("nav")) === null || _container$querySelec === void 0 ? void 0 : _container$querySelec.getBoundingClientRect().height;
|
|
21144
|
+
if (height) setOutlineHeight(height);
|
|
21145
|
+
};
|
|
21146
|
+
const observer = new ResizeObserver(measureOutline);
|
|
21147
|
+
observer.observe(menu);
|
|
21148
|
+
return () => observer.disconnect();
|
|
21149
|
+
}, [
|
|
21150
|
+
mode,
|
|
21151
|
+
unitId,
|
|
21152
|
+
menus.length,
|
|
21153
|
+
enabled
|
|
21154
|
+
]);
|
|
21017
21155
|
(0, react.useEffect)(() => {
|
|
21018
21156
|
const viewport = renderer === null || renderer === void 0 ? void 0 : renderer.scene.getViewport("viewMain");
|
|
21019
21157
|
if (!viewport) return;
|
|
@@ -21030,31 +21168,27 @@ function DocSideMenuContent() {
|
|
|
21030
21168
|
setActiveId(menu.id);
|
|
21031
21169
|
return;
|
|
21032
21170
|
}
|
|
21033
|
-
const paragraph =
|
|
21034
|
-
var _p$paragraphStyle3;
|
|
21035
|
-
return ((_p$paragraphStyle3 = p.paragraphStyle) === null || _p$paragraphStyle3 === void 0 ? void 0 : _p$paragraphStyle3.headingId) === menu.id;
|
|
21036
|
-
});
|
|
21171
|
+
const paragraph = headingParagraphs.find((p) => p.paragraphId === menu.id);
|
|
21037
21172
|
if (!paragraph) return;
|
|
21038
|
-
const bound =
|
|
21173
|
+
const bound = docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.paragraphBounds.get(paragraph.startIndex);
|
|
21039
21174
|
if (!bound) return;
|
|
21040
21175
|
viewport.scrollToViewportPos({ viewportScrollY: bound.rect.top });
|
|
21041
21176
|
setActiveId(menu.id);
|
|
21042
21177
|
});
|
|
21043
|
-
if (!currentDoc || (0, _univerjs_core.isInternalEditorID)(unitId) || !(menus === null || menus === void 0 ? void 0 : menus.length)) return null;
|
|
21178
|
+
if (!enabled || !currentDoc || (0, _univerjs_core.isInternalEditorID)(unitId) || !(menus === null || menus === void 0 ? void 0 : menus.length)) return null;
|
|
21044
21179
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
21180
|
+
ref: containerRef,
|
|
21045
21181
|
className: "univer-absolute univer-bottom-0 univer-left-0 univer-top-0 univer-z-[100] univer-w-[0px]",
|
|
21046
21182
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SideMenu, {
|
|
21047
21183
|
label: localeService.t("docs-ui.outline.title"),
|
|
21048
21184
|
menus,
|
|
21049
|
-
open,
|
|
21050
|
-
onOpenChange: setOpen,
|
|
21051
21185
|
mode,
|
|
21052
21186
|
maxWidth: Math.max(0, Math.floor(mode === "float" ? canvasWidth : left) - 24),
|
|
21053
21187
|
wrapperClass: "univer-mt-4",
|
|
21054
21188
|
activeId,
|
|
21055
21189
|
onClick: handleClick,
|
|
21056
21190
|
maxHeight: Math.max(0, canvasHeight - 32)
|
|
21057
|
-
})
|
|
21191
|
+
}, mode)
|
|
21058
21192
|
});
|
|
21059
21193
|
}
|
|
21060
21194
|
|
|
@@ -21432,7 +21566,7 @@ function resolveDocsCustomBlockRenderViewport(params) {
|
|
|
21432
21566
|
//#endregion
|
|
21433
21567
|
//#region package.json
|
|
21434
21568
|
var name = "@univerjs/docs-ui";
|
|
21435
|
-
var version = "1.
|
|
21569
|
+
var version = "1.3.0";
|
|
21436
21570
|
|
|
21437
21571
|
//#endregion
|
|
21438
21572
|
//#region src/commands/commands/doc-paragraph-setting.command.ts
|
|
@@ -22294,7 +22428,7 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
22294
22428
|
}
|
|
22295
22429
|
_deferUnmaterializedCursorMove(doc, skeleton, offset, segmentId, resume) {
|
|
22296
22430
|
var _skeleton$getSkeleton, _render$getInjector, _doc$getBody;
|
|
22297
|
-
if (segmentId !== "") return false;
|
|
22431
|
+
if (segmentId !== "" || skeleton.getViewModel().getCollapsedHeadingAtOffset(offset)) return false;
|
|
22298
22432
|
const pageIndex = skeleton.findBodyPageIndexByCharIndex(offset);
|
|
22299
22433
|
const page = (_skeleton$getSkeleton = skeleton.getSkeletonData()) === null || _skeleton$getSkeleton === void 0 ? void 0 : _skeleton$getSkeleton.pages[pageIndex];
|
|
22300
22434
|
if (pageIndex >= 0 && !(page === null || page === void 0 ? void 0 : page.isMaterializationPlaceholder)) return false;
|
|
@@ -22403,6 +22537,13 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
22403
22537
|
const visited = /* @__PURE__ */ new Set();
|
|
22404
22538
|
while (current >= 0 && current < dataStream.length && !visited.has(current)) {
|
|
22405
22539
|
visited.add(current);
|
|
22540
|
+
if (!segmentId) {
|
|
22541
|
+
const hidden = skeleton.getViewModel().getCollapsedHeadingAtOffset(current);
|
|
22542
|
+
if (hidden) {
|
|
22543
|
+
current = step < 0 ? hidden.paragraphIndex : hidden.endOffset;
|
|
22544
|
+
continue;
|
|
22545
|
+
}
|
|
22546
|
+
}
|
|
22406
22547
|
const normalizedCursor = this._normalizeCursorOffset(dataStream, customRanges, current, direction);
|
|
22407
22548
|
if (normalizedCursor < 0 || normalizedCursor >= dataStream.length) return;
|
|
22408
22549
|
if (this._isRenderableCursorOffset(skeleton, dataStream, normalizedCursor, segmentId, segmentPage)) return normalizedCursor;
|
|
@@ -24684,6 +24825,7 @@ let MobileComponentsController = class MobileComponentsController extends _unive
|
|
|
24684
24825
|
}));
|
|
24685
24826
|
}
|
|
24686
24827
|
_registerComponents() {
|
|
24828
|
+
this.disposeWithMe(this._componentManager.register(EditorColorPicker.componentKey, EditorColorPicker));
|
|
24687
24829
|
this.disposeWithMe(this._componentManager.register(COMPONENT_DOC_HEADER_FOOTER_PANEL, MobileHeaderFooterPanel));
|
|
24688
24830
|
this.disposeWithMe(this._componentManager.register("doc_ui_paragraph-setting-panel", MobileParagraphSettings));
|
|
24689
24831
|
this.disposeWithMe(this._componentManager.register(DOC_SECTION_SETTING_COMPONENT, MobileSectionSettings));
|
|
@@ -25216,8 +25358,10 @@ let DocMobileUIController = class DocMobileUIController extends _univerjs_core.D
|
|
|
25216
25358
|
this.disposeWithMe(this._uiPartsService.registerComponent(_univerjs_ui.BuiltInUIPart.HEADER_MENU, () => (0, _univerjs_ui.connectInjector)(MobileDocEditDoneButton, this._injector)));
|
|
25217
25359
|
}
|
|
25218
25360
|
_initMenus() {
|
|
25361
|
+
const { [_univerjs_ui.ContextMenuPosition.MAIN_AREA]: mainAreaMenu, ...rootMenus } = mobileMenuSchema;
|
|
25219
25362
|
this._menuManagerService.mergeMenu(menuSchema);
|
|
25220
|
-
this._menuManagerService.
|
|
25363
|
+
this._menuManagerService.mergeMenu({ [_univerjs_ui.ContextMenuPosition.MAIN_AREA]: mainAreaMenu });
|
|
25364
|
+
this._menuManagerService.appendRootMenu(rootMenus);
|
|
25221
25365
|
}
|
|
25222
25366
|
_initFocusHandler() {
|
|
25223
25367
|
this.disposeWithMe(this._layoutService.registerFocusHandler(_univerjs_core.UniverInstanceType.UNIVER_DOC, () => {}));
|
|
@@ -26025,6 +26169,9 @@ let DocResizeRenderController = class DocResizeRenderController extends _univerj
|
|
|
26025
26169
|
this._initResize();
|
|
26026
26170
|
}
|
|
26027
26171
|
_initResize() {
|
|
26172
|
+
this.disposeWithMe(this._context.activated$.pipe((0, rxjs.observeOn)(rxjs.animationFrameScheduler)).subscribe((activated) => {
|
|
26173
|
+
if (activated) this._refreshLayoutAndSelection();
|
|
26174
|
+
}));
|
|
26028
26175
|
this.disposeWithMe((0, _univerjs_core.fromEventSubject)(this._context.engine.onTransformChange$).pipe((0, rxjs.throttleTime)(0, rxjs.animationFrameScheduler)).subscribe(() => this._refreshLayoutAndSelection()));
|
|
26029
26176
|
this.disposeWithMe(this._sidebarService.sidebarOptions$.pipe((0, rxjs.observeOn)(rxjs.animationFrameScheduler)).subscribe(() => this._refreshLayoutAndSelection()));
|
|
26030
26177
|
}
|
|
@@ -27282,7 +27429,7 @@ let DocFloatMenuService = class DocFloatMenuService extends _univerjs_core.Dispo
|
|
|
27282
27429
|
this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe((selection) => {
|
|
27283
27430
|
const { unitId, textRanges } = selection;
|
|
27284
27431
|
if (unitId !== this._context.unitId) return;
|
|
27285
|
-
if (this._suppressed || this._embedSuppressed || this._contextService.getContextValue(_univerjs_core.FOCUSING_COMMON_DRAWINGS)) {
|
|
27432
|
+
if (selection.isEditing || this._suppressed || this._embedSuppressed || this._contextService.getContextValue(_univerjs_core.FOCUSING_COMMON_DRAWINGS)) {
|
|
27286
27433
|
this._hideFloatMenu();
|
|
27287
27434
|
return;
|
|
27288
27435
|
}
|
|
@@ -27569,6 +27716,10 @@ let MobileDocSelectionRenderService = class MobileDocSelectionRenderService exte
|
|
|
27569
27716
|
this.disposeWithMe(this.textSelectionInner$.subscribe(() => this._syncMobileSelectionVisuals()));
|
|
27570
27717
|
this._initMobileKeyboardViewport();
|
|
27571
27718
|
}
|
|
27719
|
+
focus() {
|
|
27720
|
+
if ((this._context.unitId === _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY || this._context.unitId === _univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY) && this.isFocusing) return;
|
|
27721
|
+
super.focus();
|
|
27722
|
+
}
|
|
27572
27723
|
cancelPointerSelection() {
|
|
27573
27724
|
this._handleDragDisposables.dispose();
|
|
27574
27725
|
super.cancelPointerSelection();
|
|
@@ -27609,10 +27760,11 @@ let MobileDocSelectionRenderService = class MobileDocSelectionRenderService exte
|
|
|
27609
27760
|
}
|
|
27610
27761
|
_syncMobileSelectionVisuals() {
|
|
27611
27762
|
const activeRange = this._getActiveRangeInstance();
|
|
27763
|
+
const isInternalEditor = (0, _univerjs_core.isInternalEditorID)(this._context.unitId);
|
|
27612
27764
|
this._selectionVisuals.hide();
|
|
27613
27765
|
for (const range of this._rangeList) {
|
|
27614
27766
|
const caret = range.getAnchor();
|
|
27615
|
-
if (this.isEditing && range === activeRange) caret === null || caret === void 0 || caret.show();
|
|
27767
|
+
if ((this.isEditing || isInternalEditor) && range === activeRange) caret === null || caret === void 0 || caret.show();
|
|
27616
27768
|
else caret === null || caret === void 0 || caret.hide();
|
|
27617
27769
|
}
|
|
27618
27770
|
if (!activeRange || activeRange.collapsed || this.isEditing) return;
|
|
@@ -27646,6 +27798,10 @@ let MobileDocSelectionRenderService = class MobileDocSelectionRenderService exte
|
|
|
27646
27798
|
});
|
|
27647
27799
|
}
|
|
27648
27800
|
_handleInputBlur(event) {
|
|
27801
|
+
if ((0, _univerjs_core.isInternalEditorID)(this._context.unitId)) {
|
|
27802
|
+
super._handleInputBlur(event);
|
|
27803
|
+
return;
|
|
27804
|
+
}
|
|
27649
27805
|
if (this.isEditing) {
|
|
27650
27806
|
this._pendingBlurEvent = event;
|
|
27651
27807
|
return;
|
|
@@ -28393,6 +28549,20 @@ const LIST_ICON_MAP = {
|
|
|
28393
28549
|
[_univerjs_core.PresetListType.CHECK_LIST]: "TodoListDoubleIcon",
|
|
28394
28550
|
[_univerjs_core.PresetListType.CHECK_LIST_CHECKED]: "TodoListDoubleIcon"
|
|
28395
28551
|
};
|
|
28552
|
+
const PASSIVE_PARAGRAPH_MENU_KEYS = /* @__PURE__ */ new Set([
|
|
28553
|
+
"ArrowLeft",
|
|
28554
|
+
"ArrowRight",
|
|
28555
|
+
"ArrowUp",
|
|
28556
|
+
"ArrowDown",
|
|
28557
|
+
"Home",
|
|
28558
|
+
"End",
|
|
28559
|
+
"PageUp",
|
|
28560
|
+
"PageDown",
|
|
28561
|
+
"Shift",
|
|
28562
|
+
"Control",
|
|
28563
|
+
"Alt",
|
|
28564
|
+
"Meta"
|
|
28565
|
+
]);
|
|
28396
28566
|
let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_core.Disposable {
|
|
28397
28567
|
get activeParagraph() {
|
|
28398
28568
|
var _this$_paragraphMenu;
|
|
@@ -28408,8 +28578,10 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28408
28578
|
}
|
|
28409
28579
|
setBlockMenuDragging(isDragging) {
|
|
28410
28580
|
this._isBlockMenuDragging = isDragging;
|
|
28411
|
-
if (isDragging)
|
|
28412
|
-
|
|
28581
|
+
if (isDragging) {
|
|
28582
|
+
this._cancelParagraphMenuHide();
|
|
28583
|
+
this._dragInteraction ??= this._docLayoutInteractionService.beginInteraction();
|
|
28584
|
+
} else {
|
|
28413
28585
|
var _this$_dragInteractio;
|
|
28414
28586
|
(_this$_dragInteractio = this._dragInteraction) === null || _this$_dragInteractio === void 0 || _this$_dragInteractio.dispose();
|
|
28415
28587
|
this._dragInteraction = null;
|
|
@@ -28431,6 +28603,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28431
28603
|
this._docLayoutInteractionService = _docLayoutInteractionService;
|
|
28432
28604
|
this._contextService = _contextService;
|
|
28433
28605
|
_defineProperty(this, "_paragraphMenu", null);
|
|
28606
|
+
_defineProperty(this, "_paragraphMenuHideTimer", null);
|
|
28434
28607
|
_defineProperty(this, "_activeTarget$", new rxjs.BehaviorSubject(null));
|
|
28435
28608
|
_defineProperty(this, "activeTarget$", this._activeTarget$.asObservable());
|
|
28436
28609
|
_defineProperty(this, "_focusedTableMenu", null);
|
|
@@ -28456,13 +28629,6 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28456
28629
|
if (this._focusedTableMenu && !this._canEditDocument(this._focusedTableMenu.target.menuRange)) this.hideFocusedTableMenu();
|
|
28457
28630
|
}));
|
|
28458
28631
|
}
|
|
28459
|
-
_isCursorInActiveParagraph() {
|
|
28460
|
-
if (!this._paragraphMenu) return false;
|
|
28461
|
-
const activeTextRange = this._docSelectionManagerService.getActiveTextRange();
|
|
28462
|
-
if (!(activeTextRange === null || activeTextRange === void 0 ? void 0 : activeTextRange.collapsed)) return false;
|
|
28463
|
-
if (!(activeTextRange === null || activeTextRange === void 0 ? void 0 : activeTextRange.collapsed) || activeTextRange.startOffset < this._paragraphMenu.paragraph.paragraphStart || activeTextRange.startOffset > this._paragraphMenu.paragraph.paragraphEnd) return false;
|
|
28464
|
-
return true;
|
|
28465
|
-
}
|
|
28466
28632
|
_getExpandedSelectionState(ranges) {
|
|
28467
28633
|
return ranges.reduce((state, range) => {
|
|
28468
28634
|
if (range.rangeType === _univerjs_core.DOC_RANGE_TYPE.RECT) {
|
|
@@ -28492,6 +28658,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28492
28658
|
}
|
|
28493
28659
|
setParagraphMenuActive(active, focusedTable = false) {
|
|
28494
28660
|
var _this$_paragraphMenu3, _this$_focusedTableMe2;
|
|
28661
|
+
if (active && !focusedTable) this._cancelParagraphMenuHide();
|
|
28495
28662
|
const menu = focusedTable ? this._focusedTableMenu : this._paragraphMenu;
|
|
28496
28663
|
if (menu) menu.active = active;
|
|
28497
28664
|
if (((_this$_paragraphMenu3 = this._paragraphMenu) === null || _this$_paragraphMenu3 === void 0 ? void 0 : _this$_paragraphMenu3.active) || ((_this$_focusedTableMe2 = this._focusedTableMenu) === null || _this$_focusedTableMe2 === void 0 ? void 0 : _this$_focusedTableMe2.active)) this._menuInteraction ??= this._docLayoutInteractionService.beginInteraction();
|
|
@@ -28506,10 +28673,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28506
28673
|
var _this$_focusedTableMe3;
|
|
28507
28674
|
if (this._isBlockMenuDragging) return;
|
|
28508
28675
|
if ((_this$_focusedTableMe3 = this._focusedTableMenu) === null || _this$_focusedTableMe3 === void 0 ? void 0 : _this$_focusedTableMe3.active) return;
|
|
28509
|
-
if (this._docSelectionRenderService.isOnPointerEvent)
|
|
28510
|
-
this.hideParagraphMenu(true);
|
|
28511
|
-
return;
|
|
28512
|
-
}
|
|
28676
|
+
if (this._docSelectionRenderService.isOnPointerEvent) return;
|
|
28513
28677
|
const selectionState = this._getExpandedSelectionState(this._docSelectionManagerService.getDocRanges());
|
|
28514
28678
|
if (selectionState.hasExpandedTextRange) {
|
|
28515
28679
|
this.hideParagraphMenu(true);
|
|
@@ -28536,6 +28700,8 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28536
28700
|
this.showTableMenu(tableBound);
|
|
28537
28701
|
return;
|
|
28538
28702
|
}
|
|
28703
|
+
this._scheduleParagraphMenuHide();
|
|
28704
|
+
return;
|
|
28539
28705
|
}
|
|
28540
28706
|
this.hideParagraphMenu(true);
|
|
28541
28707
|
};
|
|
@@ -28550,6 +28716,9 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28550
28716
|
handleHoverTarget(p ?? left, table);
|
|
28551
28717
|
}));
|
|
28552
28718
|
this.disposeWithMe(this._docSelectionRenderService.onSelectionStart$.subscribe(() => {
|
|
28719
|
+
this._cancelParagraphMenuHide();
|
|
28720
|
+
}));
|
|
28721
|
+
this.disposeWithMe(this._docSelectionRenderService.movingSelection$.subscribe(() => {
|
|
28553
28722
|
this.hideParagraphMenu(true);
|
|
28554
28723
|
}));
|
|
28555
28724
|
this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe(({ textRanges, rectRanges }) => {
|
|
@@ -28559,13 +28728,13 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28559
28728
|
}));
|
|
28560
28729
|
let lastScrollY = 0;
|
|
28561
28730
|
this.disposeWithMe(this._context.scene.getViewport("viewMain").onScrollAfter$.subscribeEvent((e) => {
|
|
28562
|
-
var _this$_paragraphMenu7;
|
|
28731
|
+
var _this$_paragraphMenu7, _this$_paragraphMenu8;
|
|
28563
28732
|
if (lastScrollY === e.scrollY) return;
|
|
28564
28733
|
lastScrollY = e.scrollY;
|
|
28565
28734
|
this._focusedTableMenuDismiss$.next();
|
|
28566
28735
|
if ((_this$_paragraphMenu7 = this._paragraphMenu) === null || _this$_paragraphMenu7 === void 0 ? void 0 : _this$_paragraphMenu7.blockRange) return;
|
|
28567
28736
|
if (this._isBlockMenuDragging) return;
|
|
28568
|
-
this.hideParagraphMenu(true);
|
|
28737
|
+
if ((_this$_paragraphMenu8 = this._paragraphMenu) === null || _this$_paragraphMenu8 === void 0 ? void 0 : _this$_paragraphMenu8.active) this.hideParagraphMenu(true);
|
|
28569
28738
|
}));
|
|
28570
28739
|
this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(() => {
|
|
28571
28740
|
if (this._isBlockMenuDragging) return;
|
|
@@ -28575,6 +28744,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28575
28744
|
if (this._isBlockMenuDragging) return;
|
|
28576
28745
|
if (this._handleSlashMenuKeydown(config)) return;
|
|
28577
28746
|
this._focusedTableMenuDismiss$.next();
|
|
28747
|
+
if (PASSIVE_PARAGRAPH_MENU_KEYS.has(config.event.key)) return;
|
|
28578
28748
|
this.hideParagraphMenu(true);
|
|
28579
28749
|
}));
|
|
28580
28750
|
this.disposeWithMe(this._docSelectionRenderService.onInputBefore$.subscribe((config) => {
|
|
@@ -28630,10 +28800,10 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28630
28800
|
return null;
|
|
28631
28801
|
}
|
|
28632
28802
|
_getSlashMenuParagraph(config) {
|
|
28633
|
-
var _this$
|
|
28803
|
+
var _this$_paragraphMenu9;
|
|
28634
28804
|
const activeRange = this._getCollapsedTextRange(config);
|
|
28635
28805
|
const offset = activeRange === null || activeRange === void 0 ? void 0 : activeRange.startOffset;
|
|
28636
|
-
const activeParagraph = ((_this$
|
|
28806
|
+
const activeParagraph = ((_this$_paragraphMenu9 = this._paragraphMenu) === null || _this$_paragraphMenu9 === void 0 ? void 0 : _this$_paragraphMenu9.paragraph) ?? null;
|
|
28637
28807
|
if (activeParagraph && offset != null && offset >= activeParagraph.paragraphStart && offset <= activeParagraph.paragraphEnd) return activeParagraph;
|
|
28638
28808
|
if (activeParagraph && offset == null) return activeParagraph;
|
|
28639
28809
|
if (offset == null) return null;
|
|
@@ -28654,7 +28824,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28654
28824
|
}
|
|
28655
28825
|
}
|
|
28656
28826
|
showParagraphMenu(paragraph) {
|
|
28657
|
-
var _this$
|
|
28827
|
+
var _this$_paragraphMenu10;
|
|
28658
28828
|
if (this._hasExpandedSelection()) {
|
|
28659
28829
|
this.hideParagraphMenu(true);
|
|
28660
28830
|
return;
|
|
@@ -28664,43 +28834,27 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28664
28834
|
this.hideParagraphMenu(true);
|
|
28665
28835
|
return;
|
|
28666
28836
|
}
|
|
28667
|
-
|
|
28668
|
-
this.
|
|
28837
|
+
this._cancelParagraphMenuHide();
|
|
28838
|
+
if (((_this$_paragraphMenu10 = this._paragraphMenu) === null || _this$_paragraphMenu10 === void 0 ? void 0 : _this$_paragraphMenu10.target.key) === target.key) return;
|
|
28669
28839
|
const targetParagraph = target.paragraph ?? paragraph;
|
|
28670
28840
|
const blockRange = target.blockRange;
|
|
28671
28841
|
const getFirstLine = () => {
|
|
28842
|
+
var _this$_context$unit$g;
|
|
28672
28843
|
const latestParagraphBound = this._docEventManagerService.findParagraphBoundByIndex(targetParagraph.startIndex) ?? targetParagraph;
|
|
28673
28844
|
const baseAnchor = blockRange ? getBlockRangeAnchorRect(this._docEventManagerService, blockRange, paragraph) : latestParagraphBound.firstLine ?? paragraph.firstLine;
|
|
28674
|
-
|
|
28675
|
-
|
|
28676
|
-
|
|
28677
|
-
|
|
28678
|
-
|
|
28679
|
-
|
|
28680
|
-
|
|
28681
|
-
direction: "left-center",
|
|
28682
|
-
onClickOutside: () => {
|
|
28683
|
-
if (this._isSlashMenuActive) {
|
|
28684
|
-
this.hideParagraphMenu(true);
|
|
28685
|
-
return;
|
|
28686
|
-
}
|
|
28687
|
-
this._docSelectionManagerService.textSelection$.pipe((0, rxjs.first)()).subscribe(() => {
|
|
28688
|
-
if (!this._isCursorInActiveParagraph()) this.hideParagraphMenu(true);
|
|
28689
|
-
});
|
|
28690
|
-
},
|
|
28691
|
-
zIndex: 101
|
|
28692
|
-
}, this._context.unitId);
|
|
28693
|
-
this._paragraphMenu = {
|
|
28694
|
-
paragraph: targetParagraph,
|
|
28695
|
-
target,
|
|
28696
|
-
blockRange,
|
|
28697
|
-
disposable,
|
|
28698
|
-
active: false
|
|
28845
|
+
const menuAnchor = ((_this$_context$unit$g = this._context.unit.getSnapshot().documentStyle) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.documentFlavor) === _univerjs_core.DocumentFlavor.MODERN && this._docSkeletonManagerService.getViewModel().getHeadingSections().some((heading) => heading.paragraphIndex === targetParagraph.startIndex && heading.startOffset < heading.endOffset) ? {
|
|
28846
|
+
...baseAnchor,
|
|
28847
|
+
left: baseAnchor.left - 24,
|
|
28848
|
+
right: baseAnchor.right - 24
|
|
28849
|
+
} : baseAnchor;
|
|
28850
|
+
if (!target.cellRange) return menuAnchor;
|
|
28851
|
+
return getTableCellParagraphAnchorRect(this._docEventManagerService, latestParagraphBound, menuAnchor);
|
|
28699
28852
|
};
|
|
28700
|
-
this.
|
|
28853
|
+
this._showHoverMenu(targetParagraph, target, getFirstLine);
|
|
28701
28854
|
}
|
|
28702
28855
|
showTableMenu(tableBound, focused = false) {
|
|
28703
|
-
var _this$_focusedTableMe4, _body$tables, _this$
|
|
28856
|
+
var _this$_focusedTableMe4, _body$tables, _this$_paragraphMenu11;
|
|
28857
|
+
if (!focused) this._cancelParagraphMenuHide();
|
|
28704
28858
|
if (!focused && ((_this$_focusedTableMe4 = this._focusedTableMenu) === null || _this$_focusedTableMe4 === void 0 || (_this$_focusedTableMe4 = _this$_focusedTableMe4.target.table) === null || _this$_focusedTableMe4 === void 0 ? void 0 : _this$_focusedTableMe4.tableId) === tableBound.tableId) return;
|
|
28705
28859
|
if (!focused && this._hasExpandedTextSelection()) {
|
|
28706
28860
|
this.hideParagraphMenu(true);
|
|
@@ -28738,7 +28892,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28738
28892
|
return;
|
|
28739
28893
|
}
|
|
28740
28894
|
if (!focused && this._shouldKeepCurrentCellMenuForTable(table)) return;
|
|
28741
|
-
if (!focused && ((_this$
|
|
28895
|
+
if (!focused && ((_this$_paragraphMenu11 = this._paragraphMenu) === null || _this$_paragraphMenu11 === void 0 ? void 0 : _this$_paragraphMenu11.target.key) === target.key) return;
|
|
28742
28896
|
const anchorRect = getTableAnchorRect(tableBound);
|
|
28743
28897
|
const paragraph = {
|
|
28744
28898
|
rect: tableBound.rect,
|
|
@@ -28754,31 +28908,47 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28754
28908
|
this._showFocusedTableMenu(tableBound, target);
|
|
28755
28909
|
return;
|
|
28756
28910
|
}
|
|
28757
|
-
this._showHoverTableMenu(tableBound, target, paragraph);
|
|
28758
|
-
}
|
|
28759
|
-
_showHoverTableMenu(tableBound, target, paragraph) {
|
|
28760
|
-
this.hideParagraphMenu(true);
|
|
28761
28911
|
const getFirstLine = () => getTableAnchorRect(this._docEventManagerService.tableBounds.get(tableBound.tableId) ?? tableBound);
|
|
28762
|
-
|
|
28763
|
-
|
|
28912
|
+
this._showHoverMenu(paragraph, target, getFirstLine);
|
|
28913
|
+
}
|
|
28914
|
+
_showHoverMenu(paragraph, target, getAnchor) {
|
|
28915
|
+
const menu = this._paragraphMenu;
|
|
28916
|
+
if ((menu === null || menu === void 0 ? void 0 : menu.active) && menu.target.kind === _univerjs_core.DocumentBlockType.TABLE !== (target.kind === _univerjs_core.DocumentBlockType.TABLE)) this.hideParagraphMenu(true);
|
|
28917
|
+
if (this._paragraphMenu) {
|
|
28918
|
+
this._paragraphMenu.paragraph = paragraph;
|
|
28919
|
+
this._paragraphMenu.target = target;
|
|
28920
|
+
this._paragraphMenu.blockRange = target.blockRange;
|
|
28921
|
+
this._paragraphMenu.getAnchor = getAnchor;
|
|
28922
|
+
this._activeTarget$.next(target);
|
|
28923
|
+
return;
|
|
28924
|
+
}
|
|
28925
|
+
const disposable = this._docPopupManagerService.attachPopupToRect(() => {
|
|
28926
|
+
var _this$_paragraphMenu12;
|
|
28927
|
+
return ((_this$_paragraphMenu12 = this._paragraphMenu) === null || _this$_paragraphMenu12 === void 0 ? void 0 : _this$_paragraphMenu12.getAnchor()) ?? getAnchor();
|
|
28928
|
+
}, {
|
|
28929
|
+
direction: target.kind === _univerjs_core.DocumentBlockType.TABLE ? "top-right" : "left-center",
|
|
28930
|
+
offset: target.kind === _univerjs_core.DocumentBlockType.TABLE ? [0, 0] : [8, 0],
|
|
28931
|
+
componentKey: DOC_PARAGRAPH_MENU_COMPONENT_KEY,
|
|
28932
|
+
positionChanges$: this.activeTarget$,
|
|
28764
28933
|
constrainToCanvas: true,
|
|
28765
28934
|
requiresStableLayout: false,
|
|
28766
|
-
direction: "top-right",
|
|
28767
28935
|
onClickOutside: () => {
|
|
28768
|
-
this.hideParagraphMenu(true);
|
|
28936
|
+
if (this._isSlashMenuActive) this.hideParagraphMenu(true);
|
|
28769
28937
|
},
|
|
28770
28938
|
zIndex: 101
|
|
28771
28939
|
}, this._context.unitId);
|
|
28772
28940
|
this._paragraphMenu = {
|
|
28773
28941
|
paragraph,
|
|
28774
28942
|
target,
|
|
28943
|
+
blockRange: target.blockRange,
|
|
28775
28944
|
disposable,
|
|
28776
|
-
active: false
|
|
28945
|
+
active: false,
|
|
28946
|
+
getAnchor
|
|
28777
28947
|
};
|
|
28778
28948
|
this._activeTarget$.next(target);
|
|
28779
28949
|
}
|
|
28780
28950
|
_showFocusedTableMenu(tableBound, target) {
|
|
28781
|
-
var _this$_focusedTableMe5, _this$
|
|
28951
|
+
var _this$_focusedTableMe5, _this$_paragraphMenu13;
|
|
28782
28952
|
if (((_this$_focusedTableMe5 = this._focusedTableMenu) === null || _this$_focusedTableMe5 === void 0 ? void 0 : _this$_focusedTableMe5.target.key) === target.key) {
|
|
28783
28953
|
this._focusedTableMenu.target = target;
|
|
28784
28954
|
this._focusedTableMenu.bound = tableBound;
|
|
@@ -28786,7 +28956,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28786
28956
|
return;
|
|
28787
28957
|
}
|
|
28788
28958
|
this.hideFocusedTableMenu();
|
|
28789
|
-
if (((_this$
|
|
28959
|
+
if (((_this$_paragraphMenu13 = this._paragraphMenu) === null || _this$_paragraphMenu13 === void 0 ? void 0 : _this$_paragraphMenu13.target.key) === target.key) this.hideParagraphMenu(true);
|
|
28790
28960
|
const getFocusedAnchor = () => {
|
|
28791
28961
|
var _this$_focusedTableMe6;
|
|
28792
28962
|
return getTableAnchorRect(this._docEventManagerService.tableBounds.get(tableBound.tableId) ?? ((_this$_focusedTableMe6 = this._focusedTableMenu) === null || _this$_focusedTableMe6 === void 0 ? void 0 : _this$_focusedTableMe6.bound) ?? tableBound);
|
|
@@ -28809,8 +28979,8 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28809
28979
|
this._focusedTableTarget$.next(target);
|
|
28810
28980
|
}
|
|
28811
28981
|
_shouldKeepCurrentCellMenuForTable(table) {
|
|
28812
|
-
var _this$
|
|
28813
|
-
const target = (_this$
|
|
28982
|
+
var _this$_paragraphMenu14;
|
|
28983
|
+
const target = (_this$_paragraphMenu14 = this._paragraphMenu) === null || _this$_paragraphMenu14 === void 0 ? void 0 : _this$_paragraphMenu14.target;
|
|
28814
28984
|
if (!target || target.kind === _univerjs_core.DocumentBlockType.TABLE || !target.cellRange) return false;
|
|
28815
28985
|
return target.cellRange.startOffset >= table.startIndex && target.cellRange.startOffset <= table.endIndex;
|
|
28816
28986
|
}
|
|
@@ -28850,7 +29020,21 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28850
29020
|
}
|
|
28851
29021
|
};
|
|
28852
29022
|
}
|
|
29023
|
+
_cancelParagraphMenuHide() {
|
|
29024
|
+
if (this._paragraphMenuHideTimer != null) {
|
|
29025
|
+
clearTimeout(this._paragraphMenuHideTimer);
|
|
29026
|
+
this._paragraphMenuHideTimer = null;
|
|
29027
|
+
}
|
|
29028
|
+
}
|
|
29029
|
+
_scheduleParagraphMenuHide() {
|
|
29030
|
+
if (!this._paragraphMenu || this._paragraphMenu.active || this._paragraphMenuHideTimer != null) return;
|
|
29031
|
+
this._paragraphMenuHideTimer = setTimeout(() => {
|
|
29032
|
+
this._paragraphMenuHideTimer = null;
|
|
29033
|
+
this.hideParagraphMenu();
|
|
29034
|
+
}, 200);
|
|
29035
|
+
}
|
|
28853
29036
|
hideParagraphMenu(force = false) {
|
|
29037
|
+
this._cancelParagraphMenuHide();
|
|
28854
29038
|
if (this._isBlockMenuDragging) return;
|
|
28855
29039
|
if (this._paragraphMenu && (this._paragraphMenu.disposable.canDispose() || force)) {
|
|
28856
29040
|
this._paragraphMenu.disposable.dispose();
|
|
@@ -28876,6 +29060,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
28876
29060
|
this._isBlockMenuDragging = false;
|
|
28877
29061
|
this.hideFocusedTableMenu();
|
|
28878
29062
|
this.hideParagraphMenu(true);
|
|
29063
|
+
this._activeTarget$.complete();
|
|
28879
29064
|
this._focusedTableTarget$.complete();
|
|
28880
29065
|
this._focusedTableMenuDismiss$.complete();
|
|
28881
29066
|
(_this$_menuInteractio2 = this._menuInteraction) === null || _this$_menuInteractio2 === void 0 || _this$_menuInteractio2.dispose();
|
|
@@ -29154,6 +29339,74 @@ function getBlockRangeAnchorRect(docEventManagerService, blockRange, fallbackPar
|
|
|
29154
29339
|
};
|
|
29155
29340
|
}
|
|
29156
29341
|
|
|
29342
|
+
//#endregion
|
|
29343
|
+
//#region src/views/paragraph-menu/paragraph-menu-position.ts
|
|
29344
|
+
function observeParagraphMenuPosition(element, popup, targets$) {
|
|
29345
|
+
let anchor;
|
|
29346
|
+
let table = false;
|
|
29347
|
+
let previousPosition;
|
|
29348
|
+
let disposed = false;
|
|
29349
|
+
const previousTransition = element.style.transition;
|
|
29350
|
+
const updatePosition = () => {
|
|
29351
|
+
var _window$matchMedia, _window;
|
|
29352
|
+
if (disposed || !anchor || element.style.visibility === "hidden") return;
|
|
29353
|
+
const gap = table ? 0 : 8;
|
|
29354
|
+
const boundary = popup.canvasElement.getBoundingClientRect();
|
|
29355
|
+
const containerLeft = Math.max(boundary.left, 0);
|
|
29356
|
+
const containerTop = Math.max(boundary.top, 0);
|
|
29357
|
+
const position = _univerjs_ui.RectPopup.calcPopupPosition({
|
|
29358
|
+
position: {
|
|
29359
|
+
...anchor,
|
|
29360
|
+
left: anchor.left - gap,
|
|
29361
|
+
right: anchor.right + gap
|
|
29362
|
+
},
|
|
29363
|
+
width: element.clientWidth,
|
|
29364
|
+
height: element.clientHeight,
|
|
29365
|
+
direction: table ? "top-right" : "left-center",
|
|
29366
|
+
containerLeft,
|
|
29367
|
+
containerTop,
|
|
29368
|
+
containerWidth: Math.max(0, Math.min(boundary.right, window.innerWidth) - containerLeft),
|
|
29369
|
+
containerHeight: Math.max(0, Math.min(boundary.bottom, window.innerHeight) - containerTop),
|
|
29370
|
+
boundaryInsets: popup.boundaryInsets,
|
|
29371
|
+
noPushMinimumGap: popup.noPushMinimumGap
|
|
29372
|
+
});
|
|
29373
|
+
if ((previousPosition === null || previousPosition === void 0 ? void 0 : previousPosition.top) === position.top && previousPosition.left === position.left && element.style.top === previousPosition.styleTop && element.style.left === previousPosition.styleLeft) return;
|
|
29374
|
+
element.style.transition = previousPosition && !((_window$matchMedia = (_window = window).matchMedia) === null || _window$matchMedia === void 0 ? void 0 : _window$matchMedia.call(_window, "(prefers-reduced-motion: reduce)").matches) ? "top 100ms ease-out, left 100ms ease-out" : "";
|
|
29375
|
+
element.style.top = `${position.top}px`;
|
|
29376
|
+
element.style.left = `${position.left}px`;
|
|
29377
|
+
previousPosition = {
|
|
29378
|
+
...position,
|
|
29379
|
+
styleTop: element.style.top,
|
|
29380
|
+
styleLeft: element.style.left
|
|
29381
|
+
};
|
|
29382
|
+
};
|
|
29383
|
+
const mutationObserver = new MutationObserver(updatePosition);
|
|
29384
|
+
mutationObserver.observe(element, {
|
|
29385
|
+
attributes: true,
|
|
29386
|
+
attributeFilter: ["style"]
|
|
29387
|
+
});
|
|
29388
|
+
const resizeObserver = new ResizeObserver(updatePosition);
|
|
29389
|
+
resizeObserver.observe(element);
|
|
29390
|
+
resizeObserver.observe(popup.canvasElement);
|
|
29391
|
+
const subscription = new rxjs.Subscription();
|
|
29392
|
+
subscription.add(targets$.subscribe((target) => {
|
|
29393
|
+
table = (target === null || target === void 0 ? void 0 : target.kind) === _univerjs_core.DocumentBlockType.TABLE;
|
|
29394
|
+
updatePosition();
|
|
29395
|
+
}));
|
|
29396
|
+
subscription.add(popup.anchorRect$.subscribe((rect) => {
|
|
29397
|
+
anchor = rect;
|
|
29398
|
+
updatePosition();
|
|
29399
|
+
}));
|
|
29400
|
+
return () => {
|
|
29401
|
+
if (disposed) return;
|
|
29402
|
+
disposed = true;
|
|
29403
|
+
subscription.unsubscribe();
|
|
29404
|
+
mutationObserver.disconnect();
|
|
29405
|
+
resizeObserver.disconnect();
|
|
29406
|
+
element.style.transition = previousTransition;
|
|
29407
|
+
};
|
|
29408
|
+
}
|
|
29409
|
+
|
|
29157
29410
|
//#endregion
|
|
29158
29411
|
//#region src/views/ParagraphMenu.tsx
|
|
29159
29412
|
function getParagraphMenuPopupDirection(anchorLeft, menuWidth = 212, viewportPadding = 8, options = {}) {
|
|
@@ -29167,26 +29420,9 @@ const PARAGRAPH_MENU_HOVER_OPEN_DELAY = 800;
|
|
|
29167
29420
|
const PARAGRAPH_MENU_HOVER_HIDE_DELAY = 240;
|
|
29168
29421
|
const PARAGRAPH_MENU_HOVER_BRIDGE_EDGE_OVERLAP = 12;
|
|
29169
29422
|
const PARAGRAPH_MENU_HOVER_BRIDGE_VERTICAL_PADDING = 8;
|
|
29170
|
-
function getParagraphMenuIconSizeClass(iconKey) {
|
|
29171
|
-
return iconKey === "TextTypeIcon" ? "univer-size-3" : "univer-size-4";
|
|
29172
|
-
}
|
|
29173
29423
|
function shouldExecuteParagraphMenuMove(validatorService, context) {
|
|
29174
29424
|
return validatorService.canMoveBlock(context);
|
|
29175
29425
|
}
|
|
29176
|
-
function getParagraphMenuTriggerIconKey(namedStyleType) {
|
|
29177
|
-
switch (namedStyleType) {
|
|
29178
|
-
case _univerjs_core.NamedStyleType.HEADING_1: return "H1Icon";
|
|
29179
|
-
case _univerjs_core.NamedStyleType.HEADING_2: return "H2Icon";
|
|
29180
|
-
case _univerjs_core.NamedStyleType.HEADING_3: return "H3Icon";
|
|
29181
|
-
case _univerjs_core.NamedStyleType.HEADING_4: return "H4Icon";
|
|
29182
|
-
case _univerjs_core.NamedStyleType.HEADING_5: return "H5Icon";
|
|
29183
|
-
case _univerjs_core.NamedStyleType.TITLE: return "TitleTypeIcon";
|
|
29184
|
-
case _univerjs_core.NamedStyleType.SUBTITLE: return "SubtitleTypeIcon";
|
|
29185
|
-
case _univerjs_core.NamedStyleType.NORMAL_TEXT:
|
|
29186
|
-
case _univerjs_core.NamedStyleType.NAMED_STYLE_TYPE_UNSPECIFIED:
|
|
29187
|
-
default: return "TextTypeIcon";
|
|
29188
|
-
}
|
|
29189
|
-
}
|
|
29190
29426
|
function createParagraphMenuHoverOpenScheduler(openMenu, delay = 800) {
|
|
29191
29427
|
let openTimer = null;
|
|
29192
29428
|
const cancel = () => {
|
|
@@ -29325,9 +29561,6 @@ const PARAGRAPH_MENU_RESTORE_SELECTION_COMMAND_IDS = /* @__PURE__ */ new Set([
|
|
|
29325
29561
|
SetInlineFormatTextBackgroundColorCommand.id,
|
|
29326
29562
|
ResetInlineFormatTextBackgroundColorCommand.id
|
|
29327
29563
|
]);
|
|
29328
|
-
function shouldRestoreParagraphMenuSelectionAfterCommand(commandId) {
|
|
29329
|
-
return !!commandId && PARAGRAPH_MENU_RESTORE_SELECTION_COMMAND_IDS.has(commandId);
|
|
29330
|
-
}
|
|
29331
29564
|
function getParagraphMenuCommand(params, targetRange) {
|
|
29332
29565
|
const commandId = params.commandId ?? params.id ?? (typeof params.label === "string" ? params.label : void 0);
|
|
29333
29566
|
if (commandId && targetRange && commandId in HEADING_COMMAND_VALUES) return {
|
|
@@ -29369,28 +29602,11 @@ function getParagraphMenuCommandParams(commandId, commandParams, target, unitId)
|
|
|
29369
29602
|
blockRange: target.blockRange
|
|
29370
29603
|
};
|
|
29371
29604
|
}
|
|
29372
|
-
function getParagraphMenuType(target, emptyMode) {
|
|
29373
|
-
if ((target === null || target === void 0 ? void 0 : target.kind) === "table") return DOC_TABLE_BLOCK_MENU_ID;
|
|
29374
|
-
if (emptyMode) return DOC_PARAGRAPH_T_INSERT_MENU_ID;
|
|
29375
|
-
if ((target === null || target === void 0 ? void 0 : target.icon) === "ReduceIcon") return DOC_PARAGRAPH_T_DIVIDER_MENU_ID;
|
|
29376
|
-
return DOC_PARAGRAPH_T_EDIT_MENU_ID;
|
|
29377
|
-
}
|
|
29378
|
-
function getParagraphMenuActiveItemIds(target, namedStyleType) {
|
|
29379
|
-
if ((target === null || target === void 0 ? void 0 : target.kind) === "blockRange") {
|
|
29380
|
-
var _target$blockRange;
|
|
29381
|
-
const commandId = getParagraphMenuBlockRangeCommandId((_target$blockRange = target.blockRange) === null || _target$blockRange === void 0 ? void 0 : _target$blockRange.blockType);
|
|
29382
|
-
return commandId && PARAGRAPH_MENU_BLOCK_RANGE_COMMAND_IDS.has(commandId) ? [commandId] : [];
|
|
29383
|
-
}
|
|
29384
|
-
const activeIds = [getParagraphMenuActiveHeadingCommandId(namedStyleType)];
|
|
29385
|
-
const listCommandId = (target === null || target === void 0 ? void 0 : target.icon) ? LIST_ICON_TO_COMMAND_ID[target.icon] : void 0;
|
|
29386
|
-
if (listCommandId) activeIds.push(listCommandId);
|
|
29387
|
-
return activeIds;
|
|
29388
|
-
}
|
|
29389
29605
|
function getParagraphMenuHiddenItemIds(menuType, target, namedStyleType) {
|
|
29390
|
-
var _target$
|
|
29606
|
+
var _target$blockRange;
|
|
29391
29607
|
if (menuType === "doc.menu.paragraph-t.insert") return [];
|
|
29392
29608
|
const hiddenIds = [...getParagraphMenuHiddenHeadingCommandIds(namedStyleType)];
|
|
29393
|
-
const blockType = (target === null || target === void 0 ? void 0 : target.kind) === "blockRange" ? (_target$
|
|
29609
|
+
const blockType = (target === null || target === void 0 ? void 0 : target.kind) === "blockRange" ? (_target$blockRange = target.blockRange) === null || _target$blockRange === void 0 ? void 0 : _target$blockRange.blockType : void 0;
|
|
29394
29610
|
if ((target === null || target === void 0 ? void 0 : target.kind) !== "blockRange") hiddenIds.push(DocPasteCommand.id);
|
|
29395
29611
|
if (blockType === _univerjs_core.DocumentBlockRangeType.CALLOUT) hiddenIds.push(getParagraphMenuBlockRangeCommandId(_univerjs_core.DocumentBlockRangeType.CODE), getParagraphMenuBlockRangeCommandId(_univerjs_core.DocumentBlockRangeType.QUOTE));
|
|
29396
29612
|
else if (blockType === _univerjs_core.DocumentBlockRangeType.QUOTE || blockType === _univerjs_core.DocumentBlockRangeType.CODE) hiddenIds.push(getParagraphMenuBlockRangeCommandId(_univerjs_core.DocumentBlockRangeType.CALLOUT));
|
|
@@ -29654,6 +29870,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29654
29870
|
const doc = univerInstanceService.getUnit(popup.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
29655
29871
|
const docParagraphMenuService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocParagraphMenuService);
|
|
29656
29872
|
const docEventManagerService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocEventManagerService);
|
|
29873
|
+
const docSelectionRenderService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocSelectionRenderService);
|
|
29657
29874
|
const isFocusedTableMenu = ((_popup$extraProps = popup.extraProps) === null || _popup$extraProps === void 0 ? void 0 : _popup$extraProps.focusedTableMenu) === true;
|
|
29658
29875
|
const activeTarget = (0, _univerjs_ui.useObservable)(isFocusedTableMenu ? docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.focusedTableTarget$ : docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget$);
|
|
29659
29876
|
const slashMenuRequest = (0, _univerjs_ui.useObservable)(docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.slashMenuRequest$);
|
|
@@ -29667,7 +29884,8 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29667
29884
|
docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(active, isFocusedTableMenu);
|
|
29668
29885
|
};
|
|
29669
29886
|
const rawActiveTarget = getActiveTarget();
|
|
29670
|
-
const
|
|
29887
|
+
const isTableMenu = tableBlockOnly || (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table";
|
|
29888
|
+
const currentActiveTarget = (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table" === isTableMenu ? rawActiveTarget : null;
|
|
29671
29889
|
const activeParagraphBound = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.paragraph) ?? (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeParagraph) ?? paragraph ?? paragraphLeft;
|
|
29672
29890
|
const startIndex = activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.startIndex;
|
|
29673
29891
|
const dataStream = (doc === null || doc === void 0 || (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.dataStream) ?? "";
|
|
@@ -29677,10 +29895,38 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29677
29895
|
}, [doc, startIndex]);
|
|
29678
29896
|
const isEmptyParagraph = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.emptyMode) ?? isEmptyParagraphMenuTarget(dataStream, activeParagraphBound);
|
|
29679
29897
|
const namedStyleType = paragraphObj === null || paragraphObj === void 0 || (_paragraphObj$paragra = paragraphObj.paragraphStyle) === null || _paragraphObj$paragra === void 0 ? void 0 : _paragraphObj$paragra.namedStyleType;
|
|
29680
|
-
const
|
|
29898
|
+
const getParagraphMenuTriggerIconKey = () => {
|
|
29899
|
+
switch (namedStyleType) {
|
|
29900
|
+
case _univerjs_core.NamedStyleType.HEADING_1: return "H1Icon";
|
|
29901
|
+
case _univerjs_core.NamedStyleType.HEADING_2: return "H2Icon";
|
|
29902
|
+
case _univerjs_core.NamedStyleType.HEADING_3: return "H3Icon";
|
|
29903
|
+
case _univerjs_core.NamedStyleType.HEADING_4: return "H4Icon";
|
|
29904
|
+
case _univerjs_core.NamedStyleType.HEADING_5: return "H5Icon";
|
|
29905
|
+
case _univerjs_core.NamedStyleType.TITLE: return "TitleTypeIcon";
|
|
29906
|
+
case _univerjs_core.NamedStyleType.SUBTITLE: return "SubtitleTypeIcon";
|
|
29907
|
+
default: return "TextTypeIcon";
|
|
29908
|
+
}
|
|
29909
|
+
};
|
|
29910
|
+
const isModernHeading = (doc === null || doc === void 0 ? void 0 : doc.getDocumentStyle().documentFlavor) === _univerjs_core.DocumentFlavor.MODERN && startIndex != null && (renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(_univerjs_docs.DocSkeletonManagerService).getViewModel().getHeadingSections().some((heading) => heading.paragraphIndex === startIndex && heading.startOffset < heading.endOffset));
|
|
29911
|
+
const targetIconKey = isEmptyParagraph ? "IncreaseIcon" : (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.icon) ?? getParagraphMenuTriggerIconKey();
|
|
29681
29912
|
const TargetIcon = iconManager.get(targetIconKey);
|
|
29682
|
-
const paragraphMenuType = (0, react.useMemo)(() =>
|
|
29683
|
-
|
|
29913
|
+
const paragraphMenuType = (0, react.useMemo)(() => {
|
|
29914
|
+
if ((currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.kind) === "table") return DOC_TABLE_BLOCK_MENU_ID;
|
|
29915
|
+
if (isEmptyParagraph) return DOC_PARAGRAPH_T_INSERT_MENU_ID;
|
|
29916
|
+
if ((currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.icon) === "ReduceIcon") return DOC_PARAGRAPH_T_DIVIDER_MENU_ID;
|
|
29917
|
+
return DOC_PARAGRAPH_T_EDIT_MENU_ID;
|
|
29918
|
+
}, [currentActiveTarget, isEmptyParagraph]);
|
|
29919
|
+
const paragraphMenuActiveItemIds = (0, react.useMemo)(() => {
|
|
29920
|
+
if ((currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.kind) === "blockRange") {
|
|
29921
|
+
var _currentActiveTarget$;
|
|
29922
|
+
const commandId = getParagraphMenuBlockRangeCommandId((_currentActiveTarget$ = currentActiveTarget.blockRange) === null || _currentActiveTarget$ === void 0 ? void 0 : _currentActiveTarget$.blockType);
|
|
29923
|
+
return commandId && PARAGRAPH_MENU_BLOCK_RANGE_COMMAND_IDS.has(commandId) ? [commandId] : [];
|
|
29924
|
+
}
|
|
29925
|
+
const activeIds = [getParagraphMenuActiveHeadingCommandId(namedStyleType)];
|
|
29926
|
+
const listCommandId = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.icon) ? LIST_ICON_TO_COMMAND_ID[currentActiveTarget.icon] : void 0;
|
|
29927
|
+
if (listCommandId) activeIds.push(listCommandId);
|
|
29928
|
+
return activeIds;
|
|
29929
|
+
}, [currentActiveTarget, namedStyleType]);
|
|
29684
29930
|
const paragraphMenuHiddenItemIds = (0, react.useMemo)(() => (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.kind) === "table" ? [] : getParagraphMenuHiddenItemIds(paragraphMenuType, currentActiveTarget, namedStyleType), [
|
|
29685
29931
|
currentActiveTarget,
|
|
29686
29932
|
namedStyleType,
|
|
@@ -29720,6 +29966,17 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29720
29966
|
if (activeElement === focusedElement || !focusedElement.isConnected && activeElement === body) layoutService.focus();
|
|
29721
29967
|
}, [layoutService]);
|
|
29722
29968
|
(0, react.useLayoutEffect)(() => restoreMenuFocus, [restoreMenuFocus]);
|
|
29969
|
+
(0, react.useLayoutEffect)(() => {
|
|
29970
|
+
var _anchorRef$current3;
|
|
29971
|
+
if (isFocusedTableMenu || !docParagraphMenuService) return;
|
|
29972
|
+
const popupElement = (_anchorRef$current3 = anchorRef.current) === null || _anchorRef$current3 === void 0 ? void 0 : _anchorRef$current3.closest("[data-u-comp=\"rect-popup\"]");
|
|
29973
|
+
if (!popupElement) return;
|
|
29974
|
+
return observeParagraphMenuPosition(popupElement, popup, docParagraphMenuService.activeTarget$);
|
|
29975
|
+
}, [
|
|
29976
|
+
docParagraphMenuService,
|
|
29977
|
+
isFocusedTableMenu,
|
|
29978
|
+
popup
|
|
29979
|
+
]);
|
|
29723
29980
|
const handleHideMenu = (0, react.useCallback)(() => {
|
|
29724
29981
|
hoverOpenSchedulerRef.current.cancel();
|
|
29725
29982
|
restoreMenuFocus();
|
|
@@ -29732,6 +29989,16 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29732
29989
|
isFocusedTableMenu,
|
|
29733
29990
|
restoreMenuFocus
|
|
29734
29991
|
]);
|
|
29992
|
+
(0, react.useEffect)(() => {
|
|
29993
|
+
if (!visible || isFocusedTableMenu || !docSelectionRenderService) return;
|
|
29994
|
+
const subscription = docSelectionRenderService.onSelectionStart$.pipe((0, rxjs.skip)(1)).subscribe(handleHideMenu);
|
|
29995
|
+
return () => subscription.unsubscribe();
|
|
29996
|
+
}, [
|
|
29997
|
+
docSelectionRenderService,
|
|
29998
|
+
handleHideMenu,
|
|
29999
|
+
isFocusedTableMenu,
|
|
30000
|
+
visible
|
|
30001
|
+
]);
|
|
29735
30002
|
(0, react.useEffect)(() => {
|
|
29736
30003
|
if (!isFocusedTableMenu || !docParagraphMenuService) return;
|
|
29737
30004
|
const subscription = docParagraphMenuService.focusedTableMenuDismiss$.subscribe(handleHideMenu);
|
|
@@ -29771,7 +30038,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29771
30038
|
};
|
|
29772
30039
|
const handleOpenMenu = (mode = "pointer") => {
|
|
29773
30040
|
clearHideTimer();
|
|
29774
|
-
if (openMode === "slash") return;
|
|
30041
|
+
if (openMode === "slash" || isDraggingRef.current) return;
|
|
29775
30042
|
const latestTarget = getActiveTarget();
|
|
29776
30043
|
setMenuInteractionActive(true);
|
|
29777
30044
|
const targetRange = latestTarget ? {
|
|
@@ -29926,7 +30193,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29926
30193
|
finishParagraphMenuCommand(docParagraphMenuService, handleHideMenu);
|
|
29927
30194
|
return;
|
|
29928
30195
|
}
|
|
29929
|
-
const previousTextRanges =
|
|
30196
|
+
const previousTextRanges = commandId && PARAGRAPH_MENU_RESTORE_SELECTION_COMMAND_IDS.has(commandId) ? getCurrentTextRangesSnapshot() : null;
|
|
29930
30197
|
if (commandId && shouldUseInsertBelowRange(commandId, option) && (latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.moveRange)) docContentInsertService.setInsertRange({
|
|
29931
30198
|
unitId: popup.unitId,
|
|
29932
30199
|
startOffset: latestTarget.moveRange.endOffset,
|
|
@@ -29958,21 +30225,24 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29958
30225
|
docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(false, isFocusedTableMenu);
|
|
29959
30226
|
}, [docParagraphMenuService, isFocusedTableMenu]);
|
|
29960
30227
|
(0, react.useEffect)(() => {
|
|
29961
|
-
if (
|
|
30228
|
+
if (isTableMenu || !slashMenuRequest || handledSlashRequestNonceRef.current >= slashMenuRequest.nonce) return;
|
|
29962
30229
|
handledSlashRequestNonceRef.current = slashMenuRequest.nonce;
|
|
29963
30230
|
hoverOpenSchedulerRef.current.cancel();
|
|
29964
30231
|
clearHideTimer();
|
|
29965
30232
|
isMouseOver.current = false;
|
|
29966
30233
|
handleOpenSlashMenu(slashMenuRequest);
|
|
29967
|
-
}, [slashMenuRequest,
|
|
30234
|
+
}, [slashMenuRequest, isTableMenu]);
|
|
29968
30235
|
if (!currentActiveTarget) return null;
|
|
29969
30236
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
29970
30237
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
29971
30238
|
"data-u-comp": "paragraph-menu",
|
|
29972
|
-
"data-u-table-menu":
|
|
30239
|
+
"data-u-table-menu": isTableMenu ? "true" : void 0,
|
|
29973
30240
|
"data-u-focused-table-menu": isFocusedTableMenu ? "true" : void 0,
|
|
29974
30241
|
ref: anchorRef,
|
|
29975
|
-
className: (0, _univerjs_design.clsx)("univer-
|
|
30242
|
+
className: (0, _univerjs_design.clsx)("univer-inline-flex univer-h-7 univer-cursor-pointer univer-select-none univer-items-center univer-gap-1 univer-rounded-md univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-px-2 univer-py-0 univer-shadow-sm univer-transition-colors hover:univer-bg-gray-50 hover:univer-shadow-md dark:!univer-border-gray-600 dark:!univer-bg-gray-900 dark:hover:!univer-bg-gray-800", {
|
|
30243
|
+
"univer-mr-1": !isModernHeading,
|
|
30244
|
+
"univer-bg-gray-100 univer-shadow-md dark:!univer-bg-gray-800": visible
|
|
30245
|
+
}),
|
|
29976
30246
|
onMouseEnter: (e) => {
|
|
29977
30247
|
var _popup$onPointerEnter;
|
|
29978
30248
|
(_popup$onPointerEnter = popup.onPointerEnter) === null || _popup$onPointerEnter === void 0 || _popup$onPointerEnter.call(popup, e);
|
|
@@ -29991,7 +30261,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29991
30261
|
isMouseOver.current = true;
|
|
29992
30262
|
hoverOpenSchedulerRef.current.openNow();
|
|
29993
30263
|
},
|
|
29994
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TargetIcon, { className: (0, _univerjs_design.clsx)(
|
|
30264
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TargetIcon, { className: (0, _univerjs_design.clsx)(targetIconKey === "TextTypeIcon" ? "univer-size-3" : "univer-size-4", "univer-shrink-0 univer-text-gray-700 dark:!univer-text-gray-0") }), !isEmptyParagraph && (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.draggable) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
29995
30265
|
type: "button",
|
|
29996
30266
|
className: "univer-group univer-flex univer-h-4 univer-w-2.5 univer-cursor-grab univer-items-center univer-justify-center univer-border-none univer-bg-transparent univer-p-0 active:univer-cursor-grabbing",
|
|
29997
30267
|
"aria-label": localeService.t("docs-ui.doc.blockMenu.dragBlock"),
|
|
@@ -30008,6 +30278,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
30008
30278
|
isMouseOver.current = true;
|
|
30009
30279
|
isDraggingRef.current = true;
|
|
30010
30280
|
docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setBlockMenuDragging(true);
|
|
30281
|
+
handleHideMenu();
|
|
30011
30282
|
dragRangeRef.current = moveRange;
|
|
30012
30283
|
dragTargetOffsetRef.current = null;
|
|
30013
30284
|
setDropRect(null);
|
|
@@ -30067,7 +30338,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
30067
30338
|
}),
|
|
30068
30339
|
visible && hoverBridgeStyle && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
30069
30340
|
"aria-hidden": "true",
|
|
30070
|
-
className: "univer-fixed univer-z-[1019] univer-bg-transparent",
|
|
30341
|
+
className: "univer-fixed univer-z-[1019] univer-select-none univer-bg-transparent",
|
|
30071
30342
|
style: hoverBridgeStyle,
|
|
30072
30343
|
onMouseEnter: (e) => {
|
|
30073
30344
|
var _popup$onPointerEnter2;
|
|
@@ -30086,6 +30357,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
30086
30357
|
anchorRect$,
|
|
30087
30358
|
direction: menuDirection,
|
|
30088
30359
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
30360
|
+
className: "univer-select-none",
|
|
30089
30361
|
onFocusCapture: (event) => {
|
|
30090
30362
|
focusedMenuElementRef.current = event.target;
|
|
30091
30363
|
},
|
|
@@ -30345,6 +30617,7 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
30345
30617
|
[DOC_PARAGRAPH_MENU_COMPONENT_KEY, ParagraphMenu],
|
|
30346
30618
|
[DOC_TABLE_BLOCK_MENU_COMPONENT_KEY, TableBlockMenu],
|
|
30347
30619
|
[FLOAT_MENU_COMPONENT_KEY, FloatToolbar],
|
|
30620
|
+
[EditorColorPicker.componentKey, EditorColorPicker],
|
|
30348
30621
|
[PAGE_SETTING_COMPONENT_ID, PageSettings],
|
|
30349
30622
|
[DOC_LAYOUT_RECOVERY_COMPONENT, DocLayoutRecovery]
|
|
30350
30623
|
].forEach(([key, comp]) => {
|
|
@@ -30832,6 +31105,289 @@ let DocContextualRibbonService = class DocContextualRibbonService extends _unive
|
|
|
30832
31105
|
};
|
|
30833
31106
|
DocContextualRibbonService = __decorate([__decorateParam(0, _univerjs_ui.IRibbonService)], DocContextualRibbonService);
|
|
30834
31107
|
|
|
31108
|
+
//#endregion
|
|
31109
|
+
//#region src/views/heading-collapse-shape.ts
|
|
31110
|
+
var HeadingCollapseShape = class extends _univerjs_engine_render.Shape {
|
|
31111
|
+
constructor(key, colors, activate) {
|
|
31112
|
+
super(key, {
|
|
31113
|
+
width: 24,
|
|
31114
|
+
height: 28,
|
|
31115
|
+
debounceParentDirty: false
|
|
31116
|
+
});
|
|
31117
|
+
_defineProperty(this, "_collapsed", false);
|
|
31118
|
+
_defineProperty(this, "_label", "");
|
|
31119
|
+
_defineProperty(this, "_colors", void 0);
|
|
31120
|
+
_defineProperty(this, "_hovered", false);
|
|
31121
|
+
_defineProperty(this, "_tooltipVisible", false);
|
|
31122
|
+
_defineProperty(this, "_tooltipTimer", null);
|
|
31123
|
+
_defineProperty(this, "_pressed", false);
|
|
31124
|
+
this._colors = colors;
|
|
31125
|
+
this.cursor = _univerjs_engine_render.CURSOR_TYPE.POINTER;
|
|
31126
|
+
this.disposeWithMe(this.onPointerEnter$.subscribeEvent((event) => {
|
|
31127
|
+
if (this._hovered || event.buttons) return;
|
|
31128
|
+
this._hovered = true;
|
|
31129
|
+
this._tooltipTimer = setTimeout(() => {
|
|
31130
|
+
this._tooltipTimer = null;
|
|
31131
|
+
this._tooltipVisible = true;
|
|
31132
|
+
this.makeDirty(true);
|
|
31133
|
+
}, 500);
|
|
31134
|
+
this.makeDirty(true);
|
|
31135
|
+
}));
|
|
31136
|
+
this.disposeWithMe(this.onPointerLeave$.subscribeEvent(() => this.resetHover()));
|
|
31137
|
+
this.disposeWithMe(this.onPointerDown$.subscribeEvent((event, state) => {
|
|
31138
|
+
state.stopPropagation();
|
|
31139
|
+
event.preventDefault();
|
|
31140
|
+
this._pressed = event.button === 0;
|
|
31141
|
+
}));
|
|
31142
|
+
this.disposeWithMe(this.onPointerUp$.subscribeEvent((event, state) => {
|
|
31143
|
+
state.stopPropagation();
|
|
31144
|
+
event.preventDefault();
|
|
31145
|
+
const activateButton = this._pressed && event.button === 0;
|
|
31146
|
+
this._pressed = false;
|
|
31147
|
+
this._hideTooltip();
|
|
31148
|
+
if (activateButton) activate();
|
|
31149
|
+
}));
|
|
31150
|
+
this.disposeWithMe(this.onClick$.subscribeEvent((_event, state) => state.stopPropagation()));
|
|
31151
|
+
this.disposeWithMe(this.onDblclick$.subscribeEvent((_event, state) => state.stopPropagation()));
|
|
31152
|
+
}
|
|
31153
|
+
update(collapsed, label, colors) {
|
|
31154
|
+
if (collapsed === this._collapsed && label === this._label && colors === this._colors) return;
|
|
31155
|
+
this._collapsed = collapsed;
|
|
31156
|
+
this._label = label;
|
|
31157
|
+
this._colors = colors;
|
|
31158
|
+
this.makeDirty(true);
|
|
31159
|
+
}
|
|
31160
|
+
resetHover() {
|
|
31161
|
+
this._hideTooltip();
|
|
31162
|
+
this._pressed = false;
|
|
31163
|
+
if (this._hovered) {
|
|
31164
|
+
this._hovered = false;
|
|
31165
|
+
this.makeDirty(true);
|
|
31166
|
+
}
|
|
31167
|
+
}
|
|
31168
|
+
_hideTooltip() {
|
|
31169
|
+
if (this._tooltipTimer !== null) {
|
|
31170
|
+
clearTimeout(this._tooltipTimer);
|
|
31171
|
+
this._tooltipTimer = null;
|
|
31172
|
+
}
|
|
31173
|
+
if (this._tooltipVisible) {
|
|
31174
|
+
this._tooltipVisible = false;
|
|
31175
|
+
this.makeDirty(true);
|
|
31176
|
+
}
|
|
31177
|
+
}
|
|
31178
|
+
_draw(ctx, bounds) {
|
|
31179
|
+
ctx.fillStyle = this._hovered ? this._colors.hover : this._colors.normal;
|
|
31180
|
+
ctx.beginPath();
|
|
31181
|
+
if (this._collapsed) {
|
|
31182
|
+
ctx.moveTo(9, 8);
|
|
31183
|
+
ctx.lineTo(16, 14);
|
|
31184
|
+
ctx.lineTo(9, 20);
|
|
31185
|
+
} else {
|
|
31186
|
+
ctx.moveTo(6, 11);
|
|
31187
|
+
ctx.lineTo(18, 11);
|
|
31188
|
+
ctx.lineTo(12, 18);
|
|
31189
|
+
}
|
|
31190
|
+
ctx.closePath();
|
|
31191
|
+
ctx.fill();
|
|
31192
|
+
if (!this._tooltipVisible) return;
|
|
31193
|
+
ctx.save();
|
|
31194
|
+
ctx.font = "12px sans-serif";
|
|
31195
|
+
const width = ctx.measureText(this._label).width + 20;
|
|
31196
|
+
const viewport = bounds === null || bounds === void 0 ? void 0 : bounds.viewBound;
|
|
31197
|
+
const centeredLeft = (this.width - width) / 2;
|
|
31198
|
+
const left = viewport ? Math.max(viewport.left - this.left, Math.min(centeredLeft, viewport.right - this.left - width)) : centeredLeft;
|
|
31199
|
+
const below = viewport != null && this.top - 36 < viewport.top;
|
|
31200
|
+
ctx.translate(left, below ? this.height + 8 : -36);
|
|
31201
|
+
_univerjs_engine_render.Rect.drawWith(ctx, {
|
|
31202
|
+
width,
|
|
31203
|
+
height: 28,
|
|
31204
|
+
radius: 6,
|
|
31205
|
+
fill: this._colors.tooltipBackground
|
|
31206
|
+
});
|
|
31207
|
+
ctx.fillStyle = this._colors.tooltipBackground;
|
|
31208
|
+
ctx.beginPath();
|
|
31209
|
+
const arrow = this.width / 2 - left;
|
|
31210
|
+
const arrowBase = below ? 0 : 28;
|
|
31211
|
+
ctx.moveTo(arrow - 4, arrowBase);
|
|
31212
|
+
ctx.lineTo(arrow, below ? -4 : 32);
|
|
31213
|
+
ctx.lineTo(arrow + 4, arrowBase);
|
|
31214
|
+
ctx.fill();
|
|
31215
|
+
ctx.fillStyle = this._colors.tooltipText;
|
|
31216
|
+
ctx.textAlign = "center";
|
|
31217
|
+
ctx.textBaseline = "middle";
|
|
31218
|
+
ctx.fillText(this._label, width / 2, 14);
|
|
31219
|
+
ctx.restore();
|
|
31220
|
+
}
|
|
31221
|
+
dispose() {
|
|
31222
|
+
this.resetHover();
|
|
31223
|
+
super.dispose();
|
|
31224
|
+
}
|
|
31225
|
+
};
|
|
31226
|
+
|
|
31227
|
+
//#endregion
|
|
31228
|
+
//#region src/services/doc-heading-collapse.service.ts
|
|
31229
|
+
let DocHeadingCollapseService = class DocHeadingCollapseService extends _univerjs_core.Disposable {
|
|
31230
|
+
constructor(_context, _skeletonManager, _eventManager, _selections, _commandService, _layoutService, themeService, localeService) {
|
|
31231
|
+
super();
|
|
31232
|
+
this._context = _context;
|
|
31233
|
+
this._skeletonManager = _skeletonManager;
|
|
31234
|
+
this._eventManager = _eventManager;
|
|
31235
|
+
this._selections = _selections;
|
|
31236
|
+
this._commandService = _commandService;
|
|
31237
|
+
this._layoutService = _layoutService;
|
|
31238
|
+
_defineProperty(this, "_buttons", /* @__PURE__ */ new Map());
|
|
31239
|
+
_defineProperty(this, "_colors", void 0);
|
|
31240
|
+
_defineProperty(this, "_expandLabel", "");
|
|
31241
|
+
_defineProperty(this, "_collapseLabel", "");
|
|
31242
|
+
this._colors = this._getColors(themeService);
|
|
31243
|
+
if ((0, _univerjs_core.isInternalEditorID)(_context.unitId)) return;
|
|
31244
|
+
this.disposeWithMe(themeService.currentTheme$.subscribe(() => {
|
|
31245
|
+
this._colors = this._getColors(themeService);
|
|
31246
|
+
this._update();
|
|
31247
|
+
}));
|
|
31248
|
+
this.disposeWithMe(localeService.currentLocale$.subscribe(() => {
|
|
31249
|
+
this._expandLabel = localeService.t("docs-ui.heading.expand");
|
|
31250
|
+
this._collapseLabel = localeService.t("docs-ui.heading.collapse");
|
|
31251
|
+
this._update();
|
|
31252
|
+
}));
|
|
31253
|
+
this.disposeWithMe(_context.scene.beforeRender$.subscribe(() => this._update()));
|
|
31254
|
+
this.disposeWithMe(this._skeletonManager.currentSkeleton$.subscribe(() => this._update()));
|
|
31255
|
+
this.disposeWithMe(this._skeletonManager.getSkeleton().dirty$.subscribe(() => this._update()));
|
|
31256
|
+
const resetHover = () => this._buttons.forEach((button) => button.resetHover());
|
|
31257
|
+
const viewport = _context.scene.getViewport("viewMain");
|
|
31258
|
+
if (viewport) {
|
|
31259
|
+
let scrollX = viewport.viewportScrollX;
|
|
31260
|
+
let scrollY = viewport.viewportScrollY;
|
|
31261
|
+
this.disposeWithMe(viewport.onScrollAfter$.subscribeEvent((event) => {
|
|
31262
|
+
if (event.viewportScrollX !== scrollX || event.viewportScrollY !== scrollY) {
|
|
31263
|
+
resetHover();
|
|
31264
|
+
scrollX = event.viewportScrollX;
|
|
31265
|
+
scrollY = event.viewportScrollY;
|
|
31266
|
+
}
|
|
31267
|
+
}));
|
|
31268
|
+
}
|
|
31269
|
+
this.disposeWithMe(_context.scene.onPointerCancel$.subscribeEvent(resetHover));
|
|
31270
|
+
this.disposeWithMe(_context.scene.onTransformChange$.subscribeEvent(({ value, preValue }) => {
|
|
31271
|
+
if (value.scaleX != null && value.scaleX !== preValue.scaleX || value.scaleY != null && value.scaleY !== preValue.scaleY) resetHover();
|
|
31272
|
+
}));
|
|
31273
|
+
this.disposeWithMe(_context.scene.onPointerLeave$.subscribeEvent(resetHover));
|
|
31274
|
+
this.disposeWithMe(this._selections.textSelection$.subscribe(({ unitId }) => {
|
|
31275
|
+
if (unitId === _context.unitId) this._normalizeSelection();
|
|
31276
|
+
}));
|
|
31277
|
+
}
|
|
31278
|
+
_getColors(themeService) {
|
|
31279
|
+
return {
|
|
31280
|
+
normal: themeService.getColorFromTheme("gray.900"),
|
|
31281
|
+
hover: themeService.getColorFromTheme("primary.600"),
|
|
31282
|
+
tooltipBackground: themeService.getColorFromTheme("gray.700"),
|
|
31283
|
+
tooltipText: themeService.getColorFromTheme("gray.0")
|
|
31284
|
+
};
|
|
31285
|
+
}
|
|
31286
|
+
_normalizeSelection() {
|
|
31287
|
+
const target = {
|
|
31288
|
+
unitId: this._context.unitId,
|
|
31289
|
+
subUnitId: this._context.unitId
|
|
31290
|
+
};
|
|
31291
|
+
const info = this._selections.getSelectionInfo(target);
|
|
31292
|
+
if (!info || info.segmentId) return;
|
|
31293
|
+
const viewModel = this._skeletonManager.getViewModel();
|
|
31294
|
+
const hiddenRect = info.rectRanges.find((range) => !range.segmentId && range.startOffset != null && viewModel.getCollapsedHeadingAtOffset(range.startOffset));
|
|
31295
|
+
if ((hiddenRect === null || hiddenRect === void 0 ? void 0 : hiddenRect.startOffset) != null) {
|
|
31296
|
+
const offset = viewModel.getCollapsedHeadingAtOffset(hiddenRect.startOffset).paragraphIndex;
|
|
31297
|
+
const textRanges = [{
|
|
31298
|
+
startOffset: offset,
|
|
31299
|
+
endOffset: offset,
|
|
31300
|
+
collapsed: true,
|
|
31301
|
+
isActive: true
|
|
31302
|
+
}];
|
|
31303
|
+
this._selections.replaceSelectionInfoWithoutRefresh({
|
|
31304
|
+
...info,
|
|
31305
|
+
textRanges,
|
|
31306
|
+
rectRanges: []
|
|
31307
|
+
}, target);
|
|
31308
|
+
this._selections.replaceDocRanges(textRanges, target, false, { forceFocus: false });
|
|
31309
|
+
return;
|
|
31310
|
+
}
|
|
31311
|
+
let changed = false;
|
|
31312
|
+
const textRanges = info.textRanges.map((range) => {
|
|
31313
|
+
var _viewModel$getCollaps, _viewModel$getCollaps2;
|
|
31314
|
+
if (range.segmentId) return range;
|
|
31315
|
+
const startOffset = ((_viewModel$getCollaps = viewModel.getCollapsedHeadingAtOffset(range.startOffset)) === null || _viewModel$getCollaps === void 0 ? void 0 : _viewModel$getCollaps.paragraphIndex) ?? range.startOffset;
|
|
31316
|
+
const endOffset = ((_viewModel$getCollaps2 = viewModel.getCollapsedHeadingAtOffset(range.endOffset)) === null || _viewModel$getCollaps2 === void 0 ? void 0 : _viewModel$getCollaps2.paragraphIndex) ?? range.endOffset;
|
|
31317
|
+
if (startOffset === range.startOffset && endOffset === range.endOffset) return range;
|
|
31318
|
+
changed = true;
|
|
31319
|
+
return {
|
|
31320
|
+
...range,
|
|
31321
|
+
startOffset,
|
|
31322
|
+
endOffset,
|
|
31323
|
+
collapsed: startOffset === endOffset,
|
|
31324
|
+
startNodePosition: void 0,
|
|
31325
|
+
endNodePosition: void 0
|
|
31326
|
+
};
|
|
31327
|
+
});
|
|
31328
|
+
if (changed) {
|
|
31329
|
+
this._selections.replaceSelectionInfoWithoutRefresh({
|
|
31330
|
+
...info,
|
|
31331
|
+
textRanges
|
|
31332
|
+
}, target);
|
|
31333
|
+
this._selections.replaceDocRanges([...textRanges, ...info.rectRanges], target, false, { forceFocus: false });
|
|
31334
|
+
}
|
|
31335
|
+
}
|
|
31336
|
+
_update() {
|
|
31337
|
+
this._normalizeSelection();
|
|
31338
|
+
const active = /* @__PURE__ */ new Set();
|
|
31339
|
+
const viewModel = this._skeletonManager.getViewModel();
|
|
31340
|
+
if (this._context.unit.getSnapshot().documentStyle.documentFlavor === _univerjs_core.DocumentFlavor.MODERN) for (const heading of viewModel.getHeadingSections()) {
|
|
31341
|
+
if (heading.startOffset >= heading.endOffset || viewModel.getCollapsedHeadingAtOffset(heading.paragraphIndex)) continue;
|
|
31342
|
+
const bound = this._eventManager.findParagraphBoundByIndex(heading.paragraphIndex);
|
|
31343
|
+
if (!bound || bound.segmentId) continue;
|
|
31344
|
+
active.add(heading.paragraphId);
|
|
31345
|
+
let button = this._buttons.get(heading.paragraphId);
|
|
31346
|
+
if (!button) {
|
|
31347
|
+
button = new HeadingCollapseShape(`__DocHeadingCollapse__${heading.paragraphId}`, this._colors, () => {
|
|
31348
|
+
var _this$_context$unit$g;
|
|
31349
|
+
const paragraph = (_this$_context$unit$g = this._context.unit.getBody()) === null || _this$_context$unit$g === void 0 || (_this$_context$unit$g = _this$_context$unit$g.paragraphs) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.find((item) => item.paragraphId === heading.paragraphId);
|
|
31350
|
+
if (paragraph && this._commandService.syncExecuteCommand(_univerjs_docs.SetHeadingCollapsedCommand.id, {
|
|
31351
|
+
unitId: this._context.unitId,
|
|
31352
|
+
paragraphId: heading.paragraphId,
|
|
31353
|
+
collapsed: paragraph.headingCollapsed !== true
|
|
31354
|
+
})) this._layoutService.focus(this._context.unitId);
|
|
31355
|
+
});
|
|
31356
|
+
this._buttons.set(heading.paragraphId, button);
|
|
31357
|
+
this._context.scene.addObject(button, 3);
|
|
31358
|
+
}
|
|
31359
|
+
const left = bound.firstLine.left - button.width;
|
|
31360
|
+
const top = (bound.firstLine.top + bound.firstLine.bottom - button.height) / 2;
|
|
31361
|
+
if (button.left !== left || button.top !== top) {
|
|
31362
|
+
button.resetHover();
|
|
31363
|
+
button.transformByState({
|
|
31364
|
+
left,
|
|
31365
|
+
top
|
|
31366
|
+
});
|
|
31367
|
+
}
|
|
31368
|
+
button.update(heading.collapsed, heading.collapsed ? this._expandLabel : this._collapseLabel, this._colors);
|
|
31369
|
+
}
|
|
31370
|
+
for (const [id, button] of this._buttons) if (!active.has(id)) {
|
|
31371
|
+
button.dispose();
|
|
31372
|
+
this._buttons.delete(id);
|
|
31373
|
+
}
|
|
31374
|
+
}
|
|
31375
|
+
dispose() {
|
|
31376
|
+
super.dispose();
|
|
31377
|
+
this._buttons.forEach((button) => button.dispose());
|
|
31378
|
+
this._buttons.clear();
|
|
31379
|
+
}
|
|
31380
|
+
};
|
|
31381
|
+
DocHeadingCollapseService = __decorate([
|
|
31382
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_docs.DocSkeletonManagerService)),
|
|
31383
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(DocEventManagerService)),
|
|
31384
|
+
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService)),
|
|
31385
|
+
__decorateParam(4, _univerjs_core.ICommandService),
|
|
31386
|
+
__decorateParam(5, _univerjs_ui.ILayoutService),
|
|
31387
|
+
__decorateParam(6, (0, _univerjs_core.Inject)(_univerjs_core.ThemeService)),
|
|
31388
|
+
__decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService))
|
|
31389
|
+
], DocHeadingCollapseService);
|
|
31390
|
+
|
|
30835
31391
|
//#endregion
|
|
30836
31392
|
//#region src/shortcuts/core-editing.shortcut.ts
|
|
30837
31393
|
const BreakLineShortcut = {
|
|
@@ -31256,6 +31812,7 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
31256
31812
|
[DocFloatMenuService],
|
|
31257
31813
|
[DocPasteOptionsRenderController],
|
|
31258
31814
|
[DocParagraphMenuService],
|
|
31815
|
+
[DocHeadingCollapseService],
|
|
31259
31816
|
[DocHeaderFooterController],
|
|
31260
31817
|
[DocHeaderFooterRibbonController],
|
|
31261
31818
|
[DocResizeRenderController],
|
|
@@ -31651,18 +32208,30 @@ function isSheetFormulaEditor(editorUnitId, univerInstanceService) {
|
|
|
31651
32208
|
}
|
|
31652
32209
|
function executeEditorUndoRedoCommand(options) {
|
|
31653
32210
|
var _univerInstanceServic;
|
|
31654
|
-
const { commandId, commandService, editorUnitId, univerInstanceService } = options;
|
|
32211
|
+
const { commandId, commandService, contextService, editorUnitId, preserveHostFocus, univerInstanceService } = options;
|
|
31655
32212
|
const shouldUseSheetEditorContext = editorUnitId === _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY || editorUnitId === _univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;
|
|
31656
32213
|
if (isSheetFormulaEditor(editorUnitId, univerInstanceService)) return;
|
|
31657
32214
|
const previousFocusedUnitId = ((_univerInstanceServic = univerInstanceService.getFocusedUnit()) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getUnitId()) ?? null;
|
|
31658
32215
|
const shouldRestoreFocus = !shouldUseSheetEditorContext && previousFocusedUnitId !== null && previousFocusedUnitId !== editorUnitId;
|
|
31659
32216
|
if (!shouldUseSheetEditorContext && previousFocusedUnitId !== editorUnitId) univerInstanceService.focusUnit(editorUnitId);
|
|
31660
32217
|
commandService.executeCommand(commandId).finally(() => {
|
|
31661
|
-
|
|
32218
|
+
var _univerInstanceServic2;
|
|
32219
|
+
if (!shouldRestoreFocus || ((_univerInstanceServic2 = univerInstanceService.getFocusedUnit()) === null || _univerInstanceServic2 === void 0 ? void 0 : _univerInstanceServic2.getUnitId()) !== editorUnitId) return;
|
|
32220
|
+
if (!preserveHostFocus || !contextService) {
|
|
32221
|
+
univerInstanceService.focusUnit(previousFocusedUnitId);
|
|
32222
|
+
return;
|
|
32223
|
+
}
|
|
32224
|
+
const previousDisableAutoFocus = contextService.getContextValue(_univerjs_ui.DISABLE_AUTO_FOCUS_KEY);
|
|
32225
|
+
contextService.setContextValue(_univerjs_ui.DISABLE_AUTO_FOCUS_KEY, true);
|
|
32226
|
+
try {
|
|
32227
|
+
univerInstanceService.focusUnit(previousFocusedUnitId);
|
|
32228
|
+
} finally {
|
|
32229
|
+
contextService.setContextValue(_univerjs_ui.DISABLE_AUTO_FOCUS_KEY, previousDisableAutoFocus);
|
|
32230
|
+
}
|
|
31662
32231
|
});
|
|
31663
32232
|
}
|
|
31664
32233
|
function createEditorUndoRedoKeyboardConfig(options) {
|
|
31665
|
-
const { commandService, editorUnitId, handler, keyCodes = [], univerInstanceService } = options;
|
|
32234
|
+
const { commandService, contextService, editorUnitId, handler, keyCodes = [], preserveHostFocus, univerInstanceService } = options;
|
|
31666
32235
|
const ctrlCommand = _univerjs_ui.MetaKeys.CTRL_COMMAND;
|
|
31667
32236
|
const ctrlCommandShift = _univerjs_ui.MetaKeys.CTRL_COMMAND | _univerjs_ui.MetaKeys.SHIFT;
|
|
31668
32237
|
return {
|
|
@@ -31687,7 +32256,9 @@ function createEditorUndoRedoKeyboardConfig(options) {
|
|
|
31687
32256
|
executeEditorUndoRedoCommand({
|
|
31688
32257
|
commandId: _univerjs_core.UndoCommand.id,
|
|
31689
32258
|
commandService,
|
|
32259
|
+
contextService,
|
|
31690
32260
|
editorUnitId,
|
|
32261
|
+
preserveHostFocus,
|
|
31691
32262
|
univerInstanceService
|
|
31692
32263
|
});
|
|
31693
32264
|
return;
|
|
@@ -31696,7 +32267,9 @@ function createEditorUndoRedoKeyboardConfig(options) {
|
|
|
31696
32267
|
executeEditorUndoRedoCommand({
|
|
31697
32268
|
commandId: _univerjs_core.RedoCommand.id,
|
|
31698
32269
|
commandService,
|
|
32270
|
+
contextService,
|
|
31699
32271
|
editorUnitId,
|
|
32272
|
+
preserveHostFocus,
|
|
31700
32273
|
univerInstanceService
|
|
31701
32274
|
});
|
|
31702
32275
|
return;
|
|
@@ -32142,6 +32715,7 @@ const useResize = (editor, isSingle = true, autoScrollbar, autoScroll, layoutSiz
|
|
|
32142
32715
|
const RichTextEditor = (props) => {
|
|
32143
32716
|
const { className, autoFocus, onFocusChange: _onFocusChange, initialValue, onClickOutside: _onClickOutside, preserveHostFocus, cancelDefaultResizeListener, documentLayoutSize, autoScroll = true, autoScrollbar = true, emitSelectionWhileDragging, keyboardEventsOnSelection = false, keyboardEventConfig, layoutSize, pixelRatio, moveCursor = true, style, isSingle, editorId: propsEditorId, onHeightChange, onChange: _onChange, defaultHeight = 32, maxHeight = 32, icon, editorRef, placeholder, noStyle, canvasStyle, renderConfig } = props;
|
|
32144
32717
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
32718
|
+
const contextService = (0, _univerjs_ui.useDependency)(_univerjs_core.IContextService);
|
|
32145
32719
|
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
32146
32720
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
32147
32721
|
const onFocusChange = (0, _univerjs_ui.useEvent)(_onFocusChange);
|
|
@@ -32209,14 +32783,18 @@ const RichTextEditor = (props) => {
|
|
|
32209
32783
|
useEditorClickOutside(editorId, sheetEmbeddingRef, onClickOutside);
|
|
32210
32784
|
const resolvedKeyboardEventConfig = (0, react.useMemo)(() => createEditorUndoRedoKeyboardConfig({
|
|
32211
32785
|
commandService,
|
|
32786
|
+
contextService,
|
|
32212
32787
|
univerInstanceService,
|
|
32213
32788
|
editorUnitId: editorId,
|
|
32789
|
+
preserveHostFocus,
|
|
32214
32790
|
keyCodes: keyboardEventConfig === null || keyboardEventConfig === void 0 ? void 0 : keyboardEventConfig.keyCodes,
|
|
32215
32791
|
handler: keyboardEventConfig === null || keyboardEventConfig === void 0 ? void 0 : keyboardEventConfig.handler
|
|
32216
32792
|
}), [
|
|
32217
32793
|
commandService,
|
|
32794
|
+
contextService,
|
|
32218
32795
|
editorId,
|
|
32219
32796
|
keyboardEventConfig,
|
|
32797
|
+
preserveHostFocus,
|
|
32220
32798
|
univerInstanceService
|
|
32221
32799
|
]);
|
|
32222
32800
|
useLeftAndRightArrow(isFocusing && moveCursor, false, editor);
|
|
@@ -32521,6 +33099,7 @@ Object.defineProperty(exports, "DocsRenderService", {
|
|
|
32521
33099
|
exports.DocsUIMenuSchema = menuSchema;
|
|
32522
33100
|
exports.EMPTY_PARAGRAPH_MENU_ID = EMPTY_PARAGRAPH_MENU_ID;
|
|
32523
33101
|
exports.Editor = Editor;
|
|
33102
|
+
exports.EditorColorPicker = EditorColorPicker;
|
|
32524
33103
|
Object.defineProperty(exports, "EditorService", {
|
|
32525
33104
|
enumerable: true,
|
|
32526
33105
|
get: function () {
|