@univerjs/docs-ui 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1315 -349
- package/lib/cjs/locale/ar-SA.js +13 -0
- package/lib/cjs/locale/ca-ES.js +13 -0
- package/lib/cjs/locale/de-DE.js +13 -0
- package/lib/cjs/locale/en-US.js +13 -0
- package/lib/cjs/locale/es-ES.js +13 -0
- package/lib/cjs/locale/fa-IR.js +13 -0
- package/lib/cjs/locale/fr-FR.js +13 -0
- package/lib/cjs/locale/id-ID.js +13 -0
- package/lib/cjs/locale/it-IT.js +13 -0
- package/lib/cjs/locale/ja-JP.js +13 -0
- package/lib/cjs/locale/ko-KR.js +13 -0
- package/lib/cjs/locale/pl-PL.js +13 -0
- package/lib/cjs/locale/pt-BR.js +13 -0
- package/lib/cjs/locale/ru-RU.js +13 -0
- package/lib/cjs/locale/sk-SK.js +13 -0
- package/lib/cjs/locale/vi-VN.js +13 -0
- package/lib/cjs/locale/zh-CN.js +13 -0
- package/lib/cjs/locale/zh-HK.js +13 -0
- package/lib/cjs/locale/zh-TW.js +13 -0
- package/lib/es/index.js +1319 -355
- package/lib/es/locale/ar-SA.js +13 -0
- package/lib/es/locale/ca-ES.js +13 -0
- package/lib/es/locale/de-DE.js +13 -0
- package/lib/es/locale/en-US.js +13 -0
- package/lib/es/locale/es-ES.js +13 -0
- package/lib/es/locale/fa-IR.js +13 -0
- package/lib/es/locale/fr-FR.js +13 -0
- package/lib/es/locale/id-ID.js +13 -0
- package/lib/es/locale/it-IT.js +13 -0
- package/lib/es/locale/ja-JP.js +13 -0
- package/lib/es/locale/ko-KR.js +13 -0
- package/lib/es/locale/pl-PL.js +13 -0
- package/lib/es/locale/pt-BR.js +13 -0
- package/lib/es/locale/ru-RU.js +13 -0
- package/lib/es/locale/sk-SK.js +13 -0
- package/lib/es/locale/vi-VN.js +13 -0
- package/lib/es/locale/zh-CN.js +13 -0
- package/lib/es/locale/zh-HK.js +13 -0
- package/lib/es/locale/zh-TW.js +13 -0
- package/lib/index.css +21 -0
- package/lib/index.js +1319 -355
- package/lib/locale/ar-SA.js +13 -0
- package/lib/locale/ca-ES.js +13 -0
- package/lib/locale/de-DE.js +13 -0
- package/lib/locale/en-US.js +13 -0
- package/lib/locale/es-ES.js +13 -0
- package/lib/locale/fa-IR.js +13 -0
- package/lib/locale/fr-FR.js +13 -0
- package/lib/locale/id-ID.js +13 -0
- package/lib/locale/it-IT.js +13 -0
- package/lib/locale/ja-JP.js +13 -0
- package/lib/locale/ko-KR.js +13 -0
- package/lib/locale/pl-PL.js +13 -0
- package/lib/locale/pt-BR.js +13 -0
- package/lib/locale/ru-RU.js +13 -0
- package/lib/locale/sk-SK.js +13 -0
- package/lib/locale/vi-VN.js +13 -0
- package/lib/locale/zh-CN.js +13 -0
- package/lib/locale/zh-HK.js +13 -0
- package/lib/locale/zh-TW.js +13 -0
- package/lib/types/commands/commands/clipboard.inner.command.d.ts +2 -0
- package/lib/types/commands/commands/doc-delete.command.d.ts +5 -2
- package/lib/types/commands/commands/doc-header-footer.command.d.ts +2 -0
- package/lib/types/commands/commands/insert-header-footer-field.command.d.ts +28 -0
- package/lib/types/commands/commands/refresh-header-footer-fields.command.d.ts +22 -0
- package/lib/types/commands/operations/doc-header-footer-ribbon.operation.d.ts +19 -0
- package/lib/types/controllers/doc-header-footer-ribbon.controller.d.ts +31 -0
- package/lib/types/controllers/render-controllers/doc-field.render-controller.d.ts +31 -0
- package/lib/types/controllers/ui.controller.d.ts +1 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/locale/en-US.d.ts +13 -0
- package/lib/types/menu/context-menu.d.ts +1 -0
- package/lib/types/menu/header-footer-ribbon.d.ts +17 -0
- package/lib/types/services/clipboard/clipboard.service.d.ts +4 -0
- package/lib/types/services/doc-event-manager.service.d.ts +1 -0
- package/lib/types/services/editor/editor-runtime-config.d.ts +2 -0
- package/lib/types/services/selection/doc-selection-render.service.d.ts +2 -0
- package/lib/types/services/selection/text-range.d.ts +6 -1
- package/lib/types/services/selection/word-boundary.d.ts +1 -0
- package/lib/types/shortcuts/core-editing.shortcut.d.ts +4 -0
- package/lib/types/shortcuts/format.shortcut.d.ts +1 -0
- package/lib/types/shortcuts/utils.d.ts +1 -0
- package/lib/types/utils/date-time-field.d.ts +22 -0
- package/lib/types/views/header-footer/panel/DocHeaderFooterFields.d.ts +19 -0
- package/lib/types/views/header-footer/panel/DocHeaderFooterRibbonControl.d.ts +20 -0
- package/lib/types/views/header-footer/panel/component-name.d.ts +2 -0
- package/lib/types/views/header-footer/panel/use-header-footer-options.d.ts +2 -2
- package/lib/umd/index.js +15 -14
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +10 -10
package/lib/cjs/index.js
CHANGED
|
@@ -1671,10 +1671,10 @@ var NodePositionConvertToCursor = class {
|
|
|
1671
1671
|
let segmentPage = page;
|
|
1672
1672
|
if (pageType === _univerjs_engine_render.DocumentSkeletonPageType.HEADER) {
|
|
1673
1673
|
var _skeHeaders$get;
|
|
1674
|
-
segmentPage = (_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(pageWidth);
|
|
1674
|
+
segmentPage = (_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(page.headerLayoutKey ?? pageWidth);
|
|
1675
1675
|
} else if (pageType === _univerjs_engine_render.DocumentSkeletonPageType.FOOTER) {
|
|
1676
1676
|
var _skeFooters$get;
|
|
1677
|
-
segmentPage = (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(pageWidth);
|
|
1677
|
+
segmentPage = (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(page.footerLayoutKey ?? pageWidth);
|
|
1678
1678
|
} else if (pageType === _univerjs_engine_render.DocumentSkeletonPageType.NOTE) {
|
|
1679
1679
|
var _getPageFromPath3, _page$notes;
|
|
1680
1680
|
const noteId = (_getPageFromPath3 = (0, _univerjs_engine_render.getPageFromPath)(skeletonData, path)) === null || _getPageFromPath3 === void 0 ? void 0 : _getPageFromPath3.segmentId;
|
|
@@ -1841,8 +1841,8 @@ function getCellPageFromSegmentPath(skeletonData, rootPage, path) {
|
|
|
1841
1841
|
if (path[0] === "pages") return null;
|
|
1842
1842
|
const segmentPages = [];
|
|
1843
1843
|
const { headerId, footerId, pageWidth } = rootPage;
|
|
1844
|
-
const headerPage = headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(pageWidth);
|
|
1845
|
-
const footerPage = footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(pageWidth);
|
|
1844
|
+
const headerPage = headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(rootPage.headerLayoutKey ?? pageWidth);
|
|
1845
|
+
const footerPage = footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(rootPage.footerLayoutKey ?? pageWidth);
|
|
1846
1846
|
if (headerPage != null) segmentPages.push(headerPage);
|
|
1847
1847
|
if (footerPage != null) segmentPages.push(footerPage);
|
|
1848
1848
|
for (const segmentPage of segmentPages) {
|
|
@@ -2257,7 +2257,7 @@ function getCellPageFromPositionPath(skeletonData, position) {
|
|
|
2257
2257
|
const rootPage = skeletonData.pages[segmentPage];
|
|
2258
2258
|
if (rootPage == null) return null;
|
|
2259
2259
|
const { headerId, footerId, pageWidth } = rootPage;
|
|
2260
|
-
const segmentPages = [headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(pageWidth), footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(pageWidth)];
|
|
2260
|
+
const segmentPages = [headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(rootPage.headerLayoutKey ?? pageWidth), footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(rootPage.footerLayoutKey ?? pageWidth)];
|
|
2261
2261
|
for (const segmentPage of segmentPages) {
|
|
2262
2262
|
if (segmentPage == null) continue;
|
|
2263
2263
|
const page = (0, _univerjs_engine_render.getPageFromPath)({
|
|
@@ -2335,7 +2335,7 @@ function getLineBounding(pointsGroup) {
|
|
|
2335
2335
|
});
|
|
2336
2336
|
}
|
|
2337
2337
|
var TextRange = class {
|
|
2338
|
-
constructor(_scene, _document, _docSkeleton, anchorNodePosition, focusNodePosition, style = _univerjs_engine_render.NORMAL_TEXT_SELECTION_PLUGIN_STYLE, _segmentId = "", _segmentPage = -1) {
|
|
2338
|
+
constructor(_scene, _document, _docSkeleton, anchorNodePosition, focusNodePosition, style = _univerjs_engine_render.NORMAL_TEXT_SELECTION_PLUGIN_STYLE, _segmentId = "", _segmentPage = -1, _logicalRange) {
|
|
2339
2339
|
this._scene = _scene;
|
|
2340
2340
|
this._document = _document;
|
|
2341
2341
|
this._docSkeleton = _docSkeleton;
|
|
@@ -2344,6 +2344,7 @@ var TextRange = class {
|
|
|
2344
2344
|
this.style = style;
|
|
2345
2345
|
this._segmentId = _segmentId;
|
|
2346
2346
|
this._segmentPage = _segmentPage;
|
|
2347
|
+
this._logicalRange = _logicalRange;
|
|
2347
2348
|
_defineProperty(this, "rangeType", _univerjs_core.DOC_RANGE_TYPE.TEXT);
|
|
2348
2349
|
_defineProperty(this, "_current", false);
|
|
2349
2350
|
_defineProperty(this, "_rangeShape", void 0);
|
|
@@ -2373,6 +2374,7 @@ var TextRange = class {
|
|
|
2373
2374
|
}
|
|
2374
2375
|
get startOffset() {
|
|
2375
2376
|
var _this$_docSkeleton$ge;
|
|
2377
|
+
if (this._logicalRange) return Math.min(this._logicalRange.startOffset, this._logicalRange.endOffset);
|
|
2376
2378
|
const { startOffset } = getOneTextSelectionRange(this._cursorList) ?? {};
|
|
2377
2379
|
const body = (_this$_docSkeleton$ge = this._docSkeleton.getViewModel().getDataModel().getSelfOrHeaderFooterModel(this._segmentId)) === null || _this$_docSkeleton$ge === void 0 ? void 0 : _this$_docSkeleton$ge.getBody();
|
|
2378
2380
|
if (startOffset == null || body == null) return startOffset;
|
|
@@ -2381,6 +2383,7 @@ var TextRange = class {
|
|
|
2381
2383
|
}
|
|
2382
2384
|
get endOffset() {
|
|
2383
2385
|
var _this$_docSkeleton$ge2;
|
|
2386
|
+
if (this._logicalRange) return Math.max(this._logicalRange.startOffset, this._logicalRange.endOffset);
|
|
2384
2387
|
const { endOffset } = getOneTextSelectionRange(this._cursorList) ?? {};
|
|
2385
2388
|
const body = (_this$_docSkeleton$ge2 = this._docSkeleton.getViewModel().getDataModel().getSelfOrHeaderFooterModel(this._segmentId)) === null || _this$_docSkeleton$ge2 === void 0 ? void 0 : _this$_docSkeleton$ge2.getBody();
|
|
2386
2389
|
if (endOffset == null || body == null) return endOffset;
|
|
@@ -2404,6 +2407,7 @@ var TextRange = class {
|
|
|
2404
2407
|
return end;
|
|
2405
2408
|
}
|
|
2406
2409
|
get direction() {
|
|
2410
|
+
if (this._logicalRange) return this._logicalRange.startOffset <= this._logicalRange.endOffset ? _univerjs_core.RANGE_DIRECTION.FORWARD : _univerjs_core.RANGE_DIRECTION.BACKWARD;
|
|
2407
2411
|
const { collapsed, anchorNodePosition, focusNodePosition } = this;
|
|
2408
2412
|
if (collapsed || anchorNodePosition == null || focusNodePosition == null) return _univerjs_core.RANGE_DIRECTION.NONE;
|
|
2409
2413
|
return compareNodePositionLogic(anchorNodePosition, focusNodePosition) ? _univerjs_core.RANGE_DIRECTION.FORWARD : _univerjs_core.RANGE_DIRECTION.BACKWARD;
|
|
@@ -2490,6 +2494,7 @@ var TextRange = class {
|
|
|
2490
2494
|
}
|
|
2491
2495
|
refresh() {
|
|
2492
2496
|
var _this$_anchorShape6, _this$_rangeShape2;
|
|
2497
|
+
this._refreshLogicalRangePositions();
|
|
2493
2498
|
const { _document, _docSkeleton } = this;
|
|
2494
2499
|
const anchor = this.anchorNodePosition;
|
|
2495
2500
|
const focus = this.focusNodePosition;
|
|
@@ -2512,6 +2517,26 @@ var TextRange = class {
|
|
|
2512
2517
|
this._setCursorList(cursorList);
|
|
2513
2518
|
if (borderBoxPointGroup.length > 0) this._createOrUpdateRange(borderBoxPointGroup, docsLeft, docsTop);
|
|
2514
2519
|
}
|
|
2520
|
+
_refreshLogicalRangePositions() {
|
|
2521
|
+
var _this$_docSkeleton$ge3;
|
|
2522
|
+
const range = this._logicalRange;
|
|
2523
|
+
if (!range) return;
|
|
2524
|
+
const start = Math.min(range.startOffset, range.endOffset);
|
|
2525
|
+
const end = Math.max(range.startOffset, range.endOffset);
|
|
2526
|
+
let first;
|
|
2527
|
+
let last;
|
|
2528
|
+
for (const page of ((_this$_docSkeleton$ge3 = this._docSkeleton.getSkeletonData()) === null || _this$_docSkeleton$ge3 === void 0 ? void 0 : _this$_docSkeleton$ge3.pages) ?? []) {
|
|
2529
|
+
if (page.isLayoutPlaceholder || page.isMaterializationPlaceholder || page.ed < start || page.st >= end) continue;
|
|
2530
|
+
const positions = findDocRangeNodePositions(this._docSkeleton, Math.max(start, page.st), Math.min(end - 1, page.ed), this._segmentId, this._segmentPage);
|
|
2531
|
+
if (positions) {
|
|
2532
|
+
first ??= positions.startPosition;
|
|
2533
|
+
last = positions.endPosition;
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
const forward = range.startOffset <= range.endOffset;
|
|
2537
|
+
this.anchorNodePosition = forward ? first : last;
|
|
2538
|
+
this.focusNodePosition = forward ? last : first;
|
|
2539
|
+
}
|
|
2515
2540
|
_isEmpty() {
|
|
2516
2541
|
return this.anchorNodePosition == null && this.focusNodePosition == null;
|
|
2517
2542
|
}
|
|
@@ -2826,7 +2851,17 @@ function getColumnInputBoundaryCollapsedPosition(anchorPosition, focusPosition,
|
|
|
2826
2851
|
function getTextRangeFromCharIndex(startOffset, endOffset, scene, document, skeleton, style, segmentId, segmentPage, startIsBack = true, endIsBack = true) {
|
|
2827
2852
|
const startNodePosition = skeleton.findNodePositionByCharIndex(startOffset, startIsBack, segmentId, segmentPage);
|
|
2828
2853
|
const endNodePosition = skeleton.findNodePositionByCharIndex(endOffset, endIsBack, segmentId, segmentPage);
|
|
2829
|
-
if (startNodePosition == null || endNodePosition == null)
|
|
2854
|
+
if (startNodePosition == null || endNodePosition == null) {
|
|
2855
|
+
var _skeleton$getSkeleton;
|
|
2856
|
+
const pages = (_skeleton$getSkeleton = skeleton.getSkeletonData()) === null || _skeleton$getSkeleton === void 0 ? void 0 : _skeleton$getSkeleton.pages;
|
|
2857
|
+
const startPage = pages === null || pages === void 0 ? void 0 : pages[skeleton.findBodyPageIndexByCharIndex(startOffset)];
|
|
2858
|
+
const endPage = pages === null || pages === void 0 ? void 0 : pages[skeleton.findBodyPageIndexByCharIndex(endOffset)];
|
|
2859
|
+
if (segmentId === "" && startOffset !== endOffset && startPage && endPage && (startPage.isMaterializationPlaceholder || endPage.isMaterializationPlaceholder)) return new TextRange(scene, document, skeleton, void 0, void 0, style, segmentId, segmentPage, {
|
|
2860
|
+
startOffset: startIsBack ? startOffset : startOffset + 1,
|
|
2861
|
+
endOffset: endIsBack ? endOffset : endOffset + 1
|
|
2862
|
+
});
|
|
2863
|
+
return;
|
|
2864
|
+
}
|
|
2830
2865
|
return new TextRange(scene, document, skeleton, startNodePosition, endNodePosition, style, segmentId, segmentPage);
|
|
2831
2866
|
}
|
|
2832
2867
|
function getRectRangeFromCharIndex(startOffset, endOffset, scene, document, skeleton, style, segmentId, segmentPage) {
|
|
@@ -2838,7 +2873,14 @@ function getRectRangeFromCharIndex(startOffset, endOffset, scene, document, skel
|
|
|
2838
2873
|
function getRangeListFromCharIndex(startOffset, endOffset, scene, document, skeleton, style, segmentId, segmentPage) {
|
|
2839
2874
|
const startNodePosition = skeleton.findNodePositionByCharIndex(startOffset, true, segmentId, segmentPage);
|
|
2840
2875
|
const endNodePosition = skeleton.findNodePositionByCharIndex(endOffset, true, segmentId, segmentPage);
|
|
2841
|
-
if (startNodePosition == null || endNodePosition == null)
|
|
2876
|
+
if (startNodePosition == null || endNodePosition == null) {
|
|
2877
|
+
const textRange = getTextRangeFromCharIndex(startOffset, endOffset, scene, document, skeleton, style, segmentId, segmentPage);
|
|
2878
|
+
if (textRange) return {
|
|
2879
|
+
textRanges: [textRange],
|
|
2880
|
+
rectRanges: []
|
|
2881
|
+
};
|
|
2882
|
+
return;
|
|
2883
|
+
}
|
|
2842
2884
|
return getRangeListFromSelection(startNodePosition, endNodePosition, scene, document, skeleton, style, segmentId, segmentPage);
|
|
2843
2885
|
}
|
|
2844
2886
|
function getRangeListFromSelection(anchorPosition, focusPosition, scene, document, skeleton, style, segmentId, segmentPage) {
|
|
@@ -3155,6 +3197,20 @@ function getWordBoundaryByIndex(content, nodeIndex, paragraphStartOffset) {
|
|
|
3155
3197
|
endOffset: paragraphStartOffset + range.end
|
|
3156
3198
|
};
|
|
3157
3199
|
}
|
|
3200
|
+
function getWordSelectionByIndex(content, nodeIndex, paragraphStartOffset, isBack) {
|
|
3201
|
+
var _segments;
|
|
3202
|
+
const text = content.replace(/[\r\n]+$/, "");
|
|
3203
|
+
if (!text.length || nodeIndex < 0) return null;
|
|
3204
|
+
const index = Math.min(nodeIndex, text.length - 1);
|
|
3205
|
+
const segments = Array.from(new Intl.Segmenter(void 0, { granularity: "word" }).segment(text));
|
|
3206
|
+
const segmentIndex = segments.findIndex((segment) => segment.index <= index && index < segment.index + segment.segment.length);
|
|
3207
|
+
const segment = segments[segmentIndex];
|
|
3208
|
+
const whitespace = /^\s+$/.test(segment.segment);
|
|
3209
|
+
return {
|
|
3210
|
+
startOffset: paragraphStartOffset + (whitespace ? ((_segments = segments[segmentIndex - 1]) === null || _segments === void 0 ? void 0 : _segments.index) ?? segment.index : segment.index),
|
|
3211
|
+
endOffset: paragraphStartOffset + (whitespace ? Math.min(nodeIndex + (isBack ? 0 : 1), text.length) : segment.index + segment.segment.length)
|
|
3212
|
+
};
|
|
3213
|
+
}
|
|
3158
3214
|
function getNextWordBoundaryOffset(content, nodeIndex, paragraphStartOffset, direction) {
|
|
3159
3215
|
if (nodeIndex < 0) return null;
|
|
3160
3216
|
const ranges = getWordRanges(content);
|
|
@@ -3184,6 +3240,12 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
3184
3240
|
get isFocusing() {
|
|
3185
3241
|
return this._input === this._getOwnerDocument().activeElement;
|
|
3186
3242
|
}
|
|
3243
|
+
get inputElement() {
|
|
3244
|
+
return this._input;
|
|
3245
|
+
}
|
|
3246
|
+
get selectionContainer() {
|
|
3247
|
+
return this._container;
|
|
3248
|
+
}
|
|
3187
3249
|
get isEditing() {
|
|
3188
3250
|
var _this$_textSelectionI;
|
|
3189
3251
|
return ((_this$_textSelectionI = this._textSelectionInner$.value) === null || _this$_textSelectionI === void 0 ? void 0 : _this$_textSelectionI.isEditing) === true;
|
|
@@ -3317,15 +3379,13 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
3317
3379
|
this._selectionStyle = style;
|
|
3318
3380
|
}
|
|
3319
3381
|
replaceDocRanges(ranges, isEditing = true, options) {
|
|
3320
|
-
var _this$_context$unit$g;
|
|
3321
3382
|
if (this._onPointerEvent) {
|
|
3322
3383
|
this._pendingSelection = null;
|
|
3323
3384
|
return false;
|
|
3324
3385
|
}
|
|
3325
3386
|
this._syncNoteSegment(ranges[0]);
|
|
3326
|
-
const isBodyOrNote = this._currentSegmentId === "" || ((_this$_context$unit$g = this._context.unit.getSnapshot().notes) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g[this._currentSegmentId]) != null;
|
|
3327
3387
|
let currentLogicalSelection = null;
|
|
3328
|
-
if (
|
|
3388
|
+
if (ranges.length > 0) {
|
|
3329
3389
|
const { unitId } = this._context;
|
|
3330
3390
|
const selection = this._docSelectionManagerService.getSelectionInfo({
|
|
3331
3391
|
unitId,
|
|
@@ -3416,7 +3476,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
3416
3476
|
if (startNodePosition && endNodePosition) textRange = getTextRangeFromCharIndex(startNodePosition.isBack ? startOffset : startOffset - 1, endNodePosition.isBack ? endOffset : endOffset - 1, scene, document, docSkeleton, rangeStyle, segmentId, segmentPage, startNodePosition.isBack, endNodePosition.isBack);
|
|
3417
3477
|
else textRange = getTextRangeFromCharIndex(startOffset, endOffset, scene, document, docSkeleton, rangeStyle, segmentId, segmentPage);
|
|
3418
3478
|
if (textRange) this._addTextRange(textRange);
|
|
3419
|
-
} catch
|
|
3479
|
+
} catch {
|
|
3420
3480
|
generalAddRange(startOffset, endOffset, rangeStyle);
|
|
3421
3481
|
}
|
|
3422
3482
|
else generalAddRange(startOffset, endOffset, rangeStyle);
|
|
@@ -3506,7 +3566,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
3506
3566
|
if (paragraphInfo == null) return;
|
|
3507
3567
|
const { content, st, nodeIndex } = paragraphInfo;
|
|
3508
3568
|
if (nodeIndex === -1) return;
|
|
3509
|
-
const wordBoundary = getWordBoundaryByIndex(content, nodeIndex, st);
|
|
3569
|
+
const wordBoundary = this._context.unitId === _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY || this._context.unitId === _univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY ? getWordSelectionByIndex(content, nodeIndex, st, startNode.ratioX < .5) : getWordBoundaryByIndex(content, nodeIndex, st);
|
|
3510
3570
|
if (wordBoundary != null) {
|
|
3511
3571
|
this.removeAllRanges();
|
|
3512
3572
|
const textRanges = [{
|
|
@@ -4095,10 +4155,26 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
4095
4155
|
}));
|
|
4096
4156
|
}
|
|
4097
4157
|
_refreshMissingInputRange(config) {
|
|
4158
|
+
var _this$_context$unit$g;
|
|
4098
4159
|
if (config.activeRange == null) {
|
|
4099
4160
|
config.activeRange = this._getActiveRange();
|
|
4100
4161
|
config.rangeList = this._getAllTextRanges();
|
|
4101
4162
|
}
|
|
4163
|
+
const { unitId } = this._context;
|
|
4164
|
+
if (config.activeRange != null || unitId !== _univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY || ((_this$_context$unit$g = this._context.unit.getBody()) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.dataStream) !== "\r\n") return;
|
|
4165
|
+
const selection = this._docSelectionManagerService.getSelectionInfo({
|
|
4166
|
+
unitId,
|
|
4167
|
+
subUnitId: unitId
|
|
4168
|
+
});
|
|
4169
|
+
if (selection == null || selection.textRanges.length !== 1 || selection.rectRanges.length > 0) return;
|
|
4170
|
+
const caret = selection.textRanges[0];
|
|
4171
|
+
if (!caret.isActive || caret.startOffset !== 0 || caret.endOffset !== 0) return;
|
|
4172
|
+
config.activeRange = {
|
|
4173
|
+
...caret,
|
|
4174
|
+
segmentId: selection.segmentId,
|
|
4175
|
+
segmentPage: selection.segmentPage
|
|
4176
|
+
};
|
|
4177
|
+
config.rangeList = [config.activeRange];
|
|
4102
4178
|
}
|
|
4103
4179
|
_handleInputFocus(event) {
|
|
4104
4180
|
this._eventHandle(event, (config) => {
|
|
@@ -5147,7 +5223,7 @@ const InnerPasteCommand = {
|
|
|
5147
5223
|
unitId: targetUnitId,
|
|
5148
5224
|
subUnitId: targetUnitId
|
|
5149
5225
|
};
|
|
5150
|
-
const selections = docSelectionManagerService.getTextRanges(selectionParams) ?? [];
|
|
5226
|
+
const selections = params.selections ?? docSelectionManagerService.getTextRanges(selectionParams) ?? [];
|
|
5151
5227
|
const rectRanges = docSelectionManagerService.getRectRanges(selectionParams) ?? [];
|
|
5152
5228
|
const selectionInfo = docSelectionManagerService.getSelectionInfo(selectionParams);
|
|
5153
5229
|
const { body: sourceBody, tableSource, drawings } = doc;
|
|
@@ -5643,7 +5719,7 @@ const CutContentCommand = {
|
|
|
5643
5719
|
id: "doc.command.inner-cut",
|
|
5644
5720
|
type: _univerjs_core.CommandType.COMMAND,
|
|
5645
5721
|
handler: (accessor, params) => {
|
|
5646
|
-
var _selectionInfo$option3;
|
|
5722
|
+
var _selectionInfo$option3, _docDataModel$getSelf7;
|
|
5647
5723
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
5648
5724
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5649
5725
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
@@ -5663,12 +5739,19 @@ const CutContentCommand = {
|
|
|
5663
5739
|
const docSkeletonManagerService = getCommandSkeleton(accessor, unitId);
|
|
5664
5740
|
if (docSkeletonManagerService == null) return false;
|
|
5665
5741
|
const viewModel = docSkeletonManagerService.getViewModel();
|
|
5742
|
+
const body = (_docDataModel$getSelf7 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf7 === void 0 ? void 0 : _docDataModel$getSelf7.getBody();
|
|
5743
|
+
const clearsBody = wholeBodySelected || body != null && isWholeBodySelected(selections, rectRanges, body);
|
|
5666
5744
|
const doMutation = {
|
|
5667
5745
|
id: _univerjs_docs.RichTextEditingMutation.id,
|
|
5668
5746
|
params: {
|
|
5669
5747
|
unitId,
|
|
5670
5748
|
actions: [],
|
|
5671
|
-
textRanges
|
|
5749
|
+
textRanges: clearsBody ? [{
|
|
5750
|
+
...textRanges[0],
|
|
5751
|
+
startOffset: 0,
|
|
5752
|
+
endOffset: 0,
|
|
5753
|
+
collapsed: true
|
|
5754
|
+
}] : textRanges,
|
|
5672
5755
|
trigger: CutContentCommand.id
|
|
5673
5756
|
}
|
|
5674
5757
|
};
|
|
@@ -5685,6 +5768,31 @@ function isHorizontalLineParagraph(dataStream, paragraph) {
|
|
|
5685
5768
|
return Array.from(dataStream).every((token) => token === _univerjs_core.DataStreamTreeTokenType.PARAGRAPH || token === _univerjs_core.DataStreamTreeTokenType.SECTION_BREAK) && (paragraphStyle === null || paragraphStyle === void 0 ? void 0 : paragraphStyle.borderBottom) != null && paragraphStyle.borderTop == null && paragraphStyle.borderLeft == null && paragraphStyle.borderRight == null && paragraphStyle.borderBetween == null;
|
|
5686
5769
|
}
|
|
5687
5770
|
|
|
5771
|
+
//#endregion
|
|
5772
|
+
//#region src/commands/operations/doc-cursor.operation.ts
|
|
5773
|
+
/**
|
|
5774
|
+
* The operation to move cursor in the current document.
|
|
5775
|
+
*/
|
|
5776
|
+
const MoveCursorOperation = {
|
|
5777
|
+
id: "doc.operation.move-cursor",
|
|
5778
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
5779
|
+
handler: (accessor, params) => {
|
|
5780
|
+
if (!params) return false;
|
|
5781
|
+
return true;
|
|
5782
|
+
}
|
|
5783
|
+
};
|
|
5784
|
+
/**
|
|
5785
|
+
* The operation to move selection in the current document.
|
|
5786
|
+
*/
|
|
5787
|
+
const MoveSelectionOperation = {
|
|
5788
|
+
id: "doc.operation.move-selection",
|
|
5789
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
5790
|
+
handler: (accessor, params) => {
|
|
5791
|
+
if (!params) return false;
|
|
5792
|
+
return true;
|
|
5793
|
+
}
|
|
5794
|
+
};
|
|
5795
|
+
|
|
5688
5796
|
//#endregion
|
|
5689
5797
|
//#region src/commands/commands/format-painter.command.ts
|
|
5690
5798
|
function captureTextFormat(body, range, defaultStyle = {}, lists = {}, document = { documentStyle: {} }) {
|
|
@@ -6098,11 +6206,25 @@ function isDeleteOffsetInsideBlockRange(body, offset) {
|
|
|
6098
6206
|
return interval.startOffset < offset && offset < interval.endOffset - 1;
|
|
6099
6207
|
})) ?? false;
|
|
6100
6208
|
}
|
|
6209
|
+
function selectDeleteBoundary(accessor, direction, granularity) {
|
|
6210
|
+
var _selections$getActive, _selections$getRectRa;
|
|
6211
|
+
const selections = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
6212
|
+
if (((_selections$getActive = selections.getActiveTextRange()) === null || _selections$getActive === void 0 ? void 0 : _selections$getActive.collapsed) && !((_selections$getRectRa = selections.getRectRanges()) === null || _selections$getRectRa === void 0 ? void 0 : _selections$getRectRa.length)) {
|
|
6213
|
+
var _selections$getActive2;
|
|
6214
|
+
accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(MoveSelectionOperation.id, {
|
|
6215
|
+
direction,
|
|
6216
|
+
granularity
|
|
6217
|
+
});
|
|
6218
|
+
return ((_selections$getActive2 = selections.getActiveTextRange()) === null || _selections$getActive2 === void 0 ? void 0 : _selections$getActive2.collapsed) === false;
|
|
6219
|
+
}
|
|
6220
|
+
return true;
|
|
6221
|
+
}
|
|
6101
6222
|
const DeleteLeftCommand = {
|
|
6102
6223
|
id: "doc.command.delete-left",
|
|
6103
6224
|
type: _univerjs_core.CommandType.COMMAND,
|
|
6104
|
-
handler: async (accessor) => {
|
|
6225
|
+
handler: async (accessor, params) => {
|
|
6105
6226
|
var _docDataModel$getSelf3, _docDataModel$getSelf4;
|
|
6227
|
+
if ((params === null || params === void 0 ? void 0 : params.granularity) && !selectDeleteBoundary(accessor, _univerjs_core.Direction.LEFT, params.granularity)) return true;
|
|
6106
6228
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
6107
6229
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
6108
6230
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
@@ -6262,8 +6384,9 @@ const DeleteLeftCommand = {
|
|
|
6262
6384
|
const DeleteRightCommand = {
|
|
6263
6385
|
id: "doc.command.delete-right",
|
|
6264
6386
|
type: _univerjs_core.CommandType.COMMAND,
|
|
6265
|
-
handler: async (accessor) => {
|
|
6387
|
+
handler: async (accessor, params) => {
|
|
6266
6388
|
var _docDataModel$getSelf5;
|
|
6389
|
+
if ((params === null || params === void 0 ? void 0 : params.granularity) && !selectDeleteBoundary(accessor, _univerjs_core.Direction.RIGHT, params.granularity)) return true;
|
|
6267
6390
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
6268
6391
|
const docDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
6269
6392
|
if (!docDataModel) return false;
|
|
@@ -8484,7 +8607,11 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
8484
8607
|
_defineProperty(this, "_umdToHtml", void 0);
|
|
8485
8608
|
this._umdToHtml = new UDMToHtmlService(docHtmlExportService);
|
|
8486
8609
|
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
8487
|
-
|
|
8610
|
+
var _command$params, _this$_pasteOptions$$;
|
|
8611
|
+
if (this._applyingPaste || command.type !== _univerjs_core.CommandType.MUTATION) return;
|
|
8612
|
+
const unitId = (_command$params = command.params) === null || _command$params === void 0 ? void 0 : _command$params.unitId;
|
|
8613
|
+
const pasteUnitId = ((_this$_pasteOptions$$ = this._pasteOptions$.value) === null || _this$_pasteOptions$$ === void 0 ? void 0 : _this$_pasteOptions$$.unitId) ?? this._getCurrentDocumentUnitId();
|
|
8614
|
+
if (!unitId || unitId === pasteUnitId) this.dismissPasteOptions();
|
|
8488
8615
|
}));
|
|
8489
8616
|
const invalidateSelection = () => {
|
|
8490
8617
|
const key = this._getPasteSelectionKey();
|
|
@@ -8558,6 +8685,12 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
8558
8685
|
mode
|
|
8559
8686
|
});
|
|
8560
8687
|
}
|
|
8688
|
+
isPasteOptionsEnabled(unitId) {
|
|
8689
|
+
return !(0, _univerjs_core.isInternalEditorID)(unitId) || this._clipboardHooks.some((hook) => {
|
|
8690
|
+
var _hook$supportsPasteOp;
|
|
8691
|
+
return (_hook$supportsPasteOp = hook.supportsPasteOptions) === null || _hook$supportsPasteOp === void 0 ? void 0 : _hook$supportsPasteOp.call(hook, unitId);
|
|
8692
|
+
});
|
|
8693
|
+
}
|
|
8561
8694
|
setNextPasteMode(mode) {
|
|
8562
8695
|
this._nextPasteMode = mode;
|
|
8563
8696
|
}
|
|
@@ -8648,7 +8781,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
8648
8781
|
try {
|
|
8649
8782
|
this._stateChangeManager.flushPendingChanges(unitId);
|
|
8650
8783
|
const result = this._paste(doc, unitId);
|
|
8651
|
-
if (result &&
|
|
8784
|
+
if (result && this.isPasteOptionsEnabled(unitId)) this._savePasteSession(payload, mode === "text" ? cachedSource : source, style, mode, unitId);
|
|
8652
8785
|
return result;
|
|
8653
8786
|
} finally {
|
|
8654
8787
|
this._applyingPaste = false;
|
|
@@ -8872,7 +9005,11 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
8872
9005
|
this._clipboardHooks.push(hook);
|
|
8873
9006
|
return (0, _univerjs_core.toDisposable)(() => {
|
|
8874
9007
|
const index = this._clipboardHooks.indexOf(hook);
|
|
8875
|
-
if (index > -1)
|
|
9008
|
+
if (index > -1) {
|
|
9009
|
+
this._clipboardHooks.splice(index, 1);
|
|
9010
|
+
const state = this._pasteOptions$.value;
|
|
9011
|
+
if (state && !this.isPasteOptionsEnabled(state.unitId)) this.dismissPasteOptions();
|
|
9012
|
+
}
|
|
8876
9013
|
});
|
|
8877
9014
|
}
|
|
8878
9015
|
_applyCopyDocDataHooks(doc, sourceDocuments) {
|
|
@@ -11578,31 +11715,6 @@ const DocCreateTableOperation = {
|
|
|
11578
11715
|
}
|
|
11579
11716
|
};
|
|
11580
11717
|
|
|
11581
|
-
//#endregion
|
|
11582
|
-
//#region src/commands/operations/doc-cursor.operation.ts
|
|
11583
|
-
/**
|
|
11584
|
-
* The operation to move cursor in the current document.
|
|
11585
|
-
*/
|
|
11586
|
-
const MoveCursorOperation = {
|
|
11587
|
-
id: "doc.operation.move-cursor",
|
|
11588
|
-
type: _univerjs_core.CommandType.OPERATION,
|
|
11589
|
-
handler: (accessor, params) => {
|
|
11590
|
-
if (!params) return false;
|
|
11591
|
-
return true;
|
|
11592
|
-
}
|
|
11593
|
-
};
|
|
11594
|
-
/**
|
|
11595
|
-
* The operation to move selection in the current document.
|
|
11596
|
-
*/
|
|
11597
|
-
const MoveSelectionOperation = {
|
|
11598
|
-
id: "doc.operation.move-selection",
|
|
11599
|
-
type: _univerjs_core.CommandType.OPERATION,
|
|
11600
|
-
handler: (accessor, params) => {
|
|
11601
|
-
if (!params) return false;
|
|
11602
|
-
return true;
|
|
11603
|
-
}
|
|
11604
|
-
};
|
|
11605
|
-
|
|
11606
11718
|
//#endregion
|
|
11607
11719
|
//#region src/config/config.ts
|
|
11608
11720
|
const DOCS_UI_PLUGIN_CONFIG_KEY = "docs-ui.config";
|
|
@@ -13818,6 +13930,10 @@ let DocRenderController = class DocRenderController extends _univerjs_core.RxDis
|
|
|
13818
13930
|
} finally {
|
|
13819
13931
|
this._docLayoutExecutorService.recordHydrationDuration(this._context.unitId, _univerjs_core.Tools.now() - hydrationStartedAt);
|
|
13820
13932
|
}
|
|
13933
|
+
this._textSelectionManagerService.refreshSelection({
|
|
13934
|
+
unitId: this._context.unitId,
|
|
13935
|
+
subUnitId: this._context.unitId
|
|
13936
|
+
}, false);
|
|
13821
13937
|
this._markDocumentRenderDirty();
|
|
13822
13938
|
}
|
|
13823
13939
|
}
|
|
@@ -14305,6 +14421,8 @@ function getHeaderFooterTarget(viewModel, editArea, segmentPage, page) {
|
|
|
14305
14421
|
* limitations under the License.
|
|
14306
14422
|
*/
|
|
14307
14423
|
const COMPONENT_DOC_HEADER_FOOTER_PANEL = "COMPONENT_DOC_HEADER_FOOTER_PANEL";
|
|
14424
|
+
const DOC_HEADER_FOOTER_RIBBON_TAB = "docs-ui.ribbon.header-footer";
|
|
14425
|
+
const DOC_HEADER_FOOTER_RIBBON_CONTROL = "DocHeaderFooterRibbonControl";
|
|
14308
14426
|
|
|
14309
14427
|
//#endregion
|
|
14310
14428
|
//#region src/commands/operations/doc-header-footer-panel.operation.ts
|
|
@@ -14362,8 +14480,8 @@ const CoreHeaderFooterCommand = {
|
|
|
14362
14480
|
let resolvedCreateType = createType;
|
|
14363
14481
|
if (headerFooterProps != null) Object.keys(headerFooterProps).forEach((key) => {
|
|
14364
14482
|
const value = headerFooterProps[key];
|
|
14365
|
-
if (resolvedCreateType == null && key === "useFirstPageHeaderFooter" && value === _univerjs_core.BooleanNumber.TRUE && !headerFooterConfig.firstPageHeaderId) resolvedCreateType = editArea === _univerjs_engine_render.DocumentEditArea.HEADER ? _univerjs_docs.HeaderFooterType.FIRST_PAGE_HEADER : _univerjs_docs.HeaderFooterType.FIRST_PAGE_FOOTER;
|
|
14366
|
-
else if (resolvedCreateType == null && key === "evenAndOddHeaders" && value === _univerjs_core.BooleanNumber.TRUE && !headerFooterConfig.evenPageHeaderId) resolvedCreateType = editArea === _univerjs_engine_render.DocumentEditArea.HEADER ? _univerjs_docs.HeaderFooterType.EVEN_PAGE_HEADER : _univerjs_docs.HeaderFooterType.EVEN_PAGE_FOOTER;
|
|
14483
|
+
if (resolvedCreateType == null && key === "useFirstPageHeaderFooter" && value === _univerjs_core.BooleanNumber.TRUE && !(editArea === _univerjs_engine_render.DocumentEditArea.HEADER ? headerFooterConfig.firstPageHeaderId : headerFooterConfig.firstPageFooterId)) resolvedCreateType = editArea === _univerjs_engine_render.DocumentEditArea.HEADER ? _univerjs_docs.HeaderFooterType.FIRST_PAGE_HEADER : _univerjs_docs.HeaderFooterType.FIRST_PAGE_FOOTER;
|
|
14484
|
+
else if (resolvedCreateType == null && key === "evenAndOddHeaders" && value === _univerjs_core.BooleanNumber.TRUE && !(editArea === _univerjs_engine_render.DocumentEditArea.HEADER ? headerFooterConfig.evenPageHeaderId : headerFooterConfig.evenPageFooterId)) resolvedCreateType = editArea === _univerjs_engine_render.DocumentEditArea.HEADER ? _univerjs_docs.HeaderFooterType.EVEN_PAGE_HEADER : _univerjs_docs.HeaderFooterType.EVEN_PAGE_FOOTER;
|
|
14367
14485
|
});
|
|
14368
14486
|
return commandService.syncExecuteCommand(_univerjs_docs.CreateHeaderFooterCommand.id, {
|
|
14369
14487
|
unitId,
|
|
@@ -14378,8 +14496,8 @@ const CoreHeaderFooterCommand = {
|
|
|
14378
14496
|
const OpenHeaderFooterPanelCommand = {
|
|
14379
14497
|
id: "doc.command.open-header-footer-panel",
|
|
14380
14498
|
type: _univerjs_core.CommandType.COMMAND,
|
|
14381
|
-
handler: async (accessor,
|
|
14382
|
-
var _skeleton$getSkeleton;
|
|
14499
|
+
handler: async (accessor, params) => {
|
|
14500
|
+
var _skeleton$getSkeleton, _docDataModel$getSelf;
|
|
14383
14501
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
14384
14502
|
const instanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
14385
14503
|
const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
|
|
@@ -14396,8 +14514,9 @@ const OpenHeaderFooterPanelCommand = {
|
|
|
14396
14514
|
const currentPage = selectionRenderService.getSegmentPage();
|
|
14397
14515
|
const pageNumber = currentPage >= 0 && currentPage < pages.length ? currentPage : 0;
|
|
14398
14516
|
const page = pages[pageNumber];
|
|
14399
|
-
|
|
14400
|
-
|
|
14517
|
+
const editArea = (params === null || params === void 0 ? void 0 : params.editArea) ?? _univerjs_engine_render.DocumentEditArea.HEADER;
|
|
14518
|
+
viewModel.setEditArea(editArea);
|
|
14519
|
+
const { createType, headerFooterId, sectionId } = getHeaderFooterTarget(viewModel, editArea, pageNumber, page);
|
|
14401
14520
|
selectionRenderService.setSegmentPage(pageNumber);
|
|
14402
14521
|
if (createType != null) {
|
|
14403
14522
|
const segmentId = (0, _univerjs_core.generateRandomId)(6);
|
|
@@ -14414,6 +14533,21 @@ const OpenHeaderFooterPanelCommand = {
|
|
|
14414
14533
|
return false;
|
|
14415
14534
|
}
|
|
14416
14535
|
} else if (headerFooterId != null) selectionRenderService.setSegment(headerFooterId);
|
|
14536
|
+
const segmentId = selectionRenderService.getSegment();
|
|
14537
|
+
const segmentSnapshot = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getSnapshot();
|
|
14538
|
+
if (!segmentSnapshot) return false;
|
|
14539
|
+
const offset = findFirstCursorOffset(segmentSnapshot);
|
|
14540
|
+
accessor.get(_univerjs_docs.DocSelectionManagerService).replaceDocRanges([{
|
|
14541
|
+
startOffset: offset,
|
|
14542
|
+
endOffset: offset,
|
|
14543
|
+
collapsed: true,
|
|
14544
|
+
segmentId,
|
|
14545
|
+
segmentPage: pageNumber
|
|
14546
|
+
}], {
|
|
14547
|
+
unitId,
|
|
14548
|
+
subUnitId: unitId
|
|
14549
|
+
});
|
|
14550
|
+
selectionRenderService.focus();
|
|
14417
14551
|
return commandService.executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "open" });
|
|
14418
14552
|
}
|
|
14419
14553
|
};
|
|
@@ -14456,7 +14590,254 @@ const CloseHeaderFooterCommand = {
|
|
|
14456
14590
|
endOffset: offset
|
|
14457
14591
|
}]);
|
|
14458
14592
|
});
|
|
14459
|
-
commandService.executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "close" });
|
|
14593
|
+
await commandService.executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "close" });
|
|
14594
|
+
return true;
|
|
14595
|
+
}
|
|
14596
|
+
};
|
|
14597
|
+
|
|
14598
|
+
//#endregion
|
|
14599
|
+
//#region src/utils/date-time-field.ts
|
|
14600
|
+
function createDateTimeField(format, locale, date) {
|
|
14601
|
+
const options = format === "time" ? {
|
|
14602
|
+
hour: "2-digit",
|
|
14603
|
+
minute: "2-digit",
|
|
14604
|
+
second: "2-digit",
|
|
14605
|
+
hourCycle: "h23"
|
|
14606
|
+
} : {
|
|
14607
|
+
year: "numeric",
|
|
14608
|
+
month: format === "long" ? "long" : "2-digit",
|
|
14609
|
+
day: "2-digit"
|
|
14610
|
+
};
|
|
14611
|
+
const formatter = new Intl.DateTimeFormat(locale, {
|
|
14612
|
+
...options,
|
|
14613
|
+
calendar: "gregory",
|
|
14614
|
+
numberingSystem: "latn"
|
|
14615
|
+
});
|
|
14616
|
+
const parts = formatter.formatToParts(date);
|
|
14617
|
+
const tokens = {
|
|
14618
|
+
year: "yyyy",
|
|
14619
|
+
month: format === "long" ? "MMMM" : "MM",
|
|
14620
|
+
day: "dd",
|
|
14621
|
+
hour: "HH",
|
|
14622
|
+
minute: "mm",
|
|
14623
|
+
second: "ss"
|
|
14624
|
+
};
|
|
14625
|
+
const mask = parts.map((part) => tokens[part.type] ?? `'${part.value.replace(/'/g, "''")}'`).join("");
|
|
14626
|
+
const fieldType = format === "time" ? "TIME" : "DATE";
|
|
14627
|
+
return {
|
|
14628
|
+
fieldType,
|
|
14629
|
+
instruction: `${fieldType} \\@ "${mask}"`,
|
|
14630
|
+
cachedResult: formatter.format(date)
|
|
14631
|
+
};
|
|
14632
|
+
}
|
|
14633
|
+
function resolveDateTimeField(instruction, locale, date) {
|
|
14634
|
+
try {
|
|
14635
|
+
Intl.getCanonicalLocales(locale);
|
|
14636
|
+
} catch {
|
|
14637
|
+
return;
|
|
14638
|
+
}
|
|
14639
|
+
for (const format of [
|
|
14640
|
+
"short",
|
|
14641
|
+
"long",
|
|
14642
|
+
"time"
|
|
14643
|
+
]) {
|
|
14644
|
+
const field = createDateTimeField(format, locale, date);
|
|
14645
|
+
if (field.instruction === instruction) return field.cachedResult;
|
|
14646
|
+
}
|
|
14647
|
+
}
|
|
14648
|
+
|
|
14649
|
+
//#endregion
|
|
14650
|
+
//#region src/commands/commands/insert-header-footer-field.command.ts
|
|
14651
|
+
const InsertHeaderFooterFieldCommand = {
|
|
14652
|
+
id: "doc.command.insert-header-footer-field",
|
|
14653
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
14654
|
+
handler(accessor, params) {
|
|
14655
|
+
var _snapshot$headers, _snapshot$footers, _model$getSelfOrHeade, _body$customRanges;
|
|
14656
|
+
if (!params || ![
|
|
14657
|
+
"PAGE",
|
|
14658
|
+
"NUMPAGES",
|
|
14659
|
+
"DATE",
|
|
14660
|
+
"TIME"
|
|
14661
|
+
].includes(params.fieldType)) return false;
|
|
14662
|
+
const model = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(params.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
14663
|
+
const active = accessor.get(_univerjs_docs.DocSelectionManagerService).getActiveTextRange();
|
|
14664
|
+
const selection = params.selection ?? active;
|
|
14665
|
+
const segmentId = params.segmentId ?? (active === null || active === void 0 ? void 0 : active.segmentId);
|
|
14666
|
+
const snapshot = model === null || model === void 0 ? void 0 : model.getSnapshot();
|
|
14667
|
+
if (!model || (snapshot === null || snapshot === void 0 ? void 0 : snapshot.disabled) || !selection || !segmentId || !(snapshot === null || snapshot === void 0 || (_snapshot$headers = snapshot.headers) === null || _snapshot$headers === void 0 ? void 0 : _snapshot$headers[segmentId]) && !(snapshot === null || snapshot === void 0 || (_snapshot$footers = snapshot.footers) === null || _snapshot$footers === void 0 ? void 0 : _snapshot$footers[segmentId])) return false;
|
|
14668
|
+
const body = (_model$getSelfOrHeade = model.getSelfOrHeaderFooterModel(segmentId)) === null || _model$getSelfOrHeade === void 0 ? void 0 : _model$getSelfOrHeade.getBody();
|
|
14669
|
+
if (!body || params.expectedDataStream != null && params.expectedDataStream !== body.dataStream || !Number.isInteger(selection.startOffset) || !Number.isInteger(selection.endOffset) || selection.startOffset < 0 || selection.endOffset < selection.startOffset || selection.endOffset > body.dataStream.length - 2) return false;
|
|
14670
|
+
if (!(0, _univerjs_docs.canEditDocumentTargets)(accessor.get(_univerjs_core.IPermissionService), params.unitId, (0, _univerjs_docs.getDocumentEditTargetObjectIds)(model, segmentId, selection))) return false;
|
|
14671
|
+
if ((_body$customRanges = body.customRanges) === null || _body$customRanges === void 0 ? void 0 : _body$customRanges.some((range) => {
|
|
14672
|
+
var _range$properties;
|
|
14673
|
+
return range.rangeType === _univerjs_core.CustomRangeType.FIELD && ((_range$properties = range.properties) === null || _range$properties === void 0 ? void 0 : _range$properties.locked) === _univerjs_core.BooleanNumber.TRUE && selection.startOffset <= range.endIndex && selection.endOffset > range.startIndex;
|
|
14674
|
+
})) return false;
|
|
14675
|
+
const locale = _univerjs_core.LOCALE_META[accessor.get(_univerjs_core.LocaleService).getCurrentLocale()].tag;
|
|
14676
|
+
let properties;
|
|
14677
|
+
if (params.fieldType === "DATE" || params.fieldType === "TIME") {
|
|
14678
|
+
const format = params.format ?? (params.fieldType === "TIME" ? "time" : "short");
|
|
14679
|
+
if (![
|
|
14680
|
+
"short",
|
|
14681
|
+
"long",
|
|
14682
|
+
"time"
|
|
14683
|
+
].includes(format)) return false;
|
|
14684
|
+
properties = createDateTimeField(format, locale, /* @__PURE__ */ new Date());
|
|
14685
|
+
} else {
|
|
14686
|
+
var _accessor$get$getRend, _skeleton$getSkeleton;
|
|
14687
|
+
const skeleton = (_accessor$get$getRend = accessor.get(_univerjs_engine_render.IRenderManagerService).getRenderUnitById(params.unitId)) === null || _accessor$get$getRend === void 0 ? void 0 : _accessor$get$getRend.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton();
|
|
14688
|
+
const pages = skeleton === null || skeleton === void 0 || (_skeleton$getSkeleton = skeleton.getSkeletonData()) === null || _skeleton$getSkeleton === void 0 ? void 0 : _skeleton$getSkeleton.pages;
|
|
14689
|
+
if (!(pages === null || pages === void 0 ? void 0 : pages.length)) return false;
|
|
14690
|
+
const pageIndex = params.segmentPage ?? (active === null || active === void 0 ? void 0 : active.segmentPage) ?? 0;
|
|
14691
|
+
const page = pages[Math.max(0, pageIndex)];
|
|
14692
|
+
if (!page) return false;
|
|
14693
|
+
properties = {
|
|
14694
|
+
fieldType: params.fieldType,
|
|
14695
|
+
instruction: params.fieldType,
|
|
14696
|
+
cachedResult: String(params.fieldType === "PAGE" ? page.pageNumber : (skeleton === null || skeleton === void 0 ? void 0 : skeleton.getCompletedPageCount()) ?? "…")
|
|
14697
|
+
};
|
|
14698
|
+
}
|
|
14699
|
+
const automatic = params.automatic !== false || params.fieldType === "PAGE" || params.fieldType === "NUMPAGES";
|
|
14700
|
+
const dataStream = automatic ? `${_univerjs_core.DataStreamTreeTokenType.CUSTOM_RANGE_START}${properties.cachedResult}${_univerjs_core.DataStreamTreeTokenType.CUSTOM_RANGE_END}` : properties.cachedResult;
|
|
14701
|
+
const style = accessor.get(DocMenuStyleService);
|
|
14702
|
+
const textRun = getTextRunForSelection(body, selection, style.getDefaultStyle(), style.getStyleCache(), false);
|
|
14703
|
+
return accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(_univerjs_docs.InsertTextCommand.id, {
|
|
14704
|
+
unitId: params.unitId,
|
|
14705
|
+
segmentId,
|
|
14706
|
+
range: selection,
|
|
14707
|
+
debounce: false,
|
|
14708
|
+
body: {
|
|
14709
|
+
dataStream,
|
|
14710
|
+
textRuns: [{
|
|
14711
|
+
...textRun,
|
|
14712
|
+
ts: {
|
|
14713
|
+
...textRun.ts,
|
|
14714
|
+
lang: locale
|
|
14715
|
+
},
|
|
14716
|
+
st: 0,
|
|
14717
|
+
ed: dataStream.length
|
|
14718
|
+
}],
|
|
14719
|
+
customRanges: automatic ? [{
|
|
14720
|
+
startIndex: 0,
|
|
14721
|
+
endIndex: dataStream.length - 1,
|
|
14722
|
+
rangeId: (0, _univerjs_core.generateRandomId)(),
|
|
14723
|
+
rangeType: _univerjs_core.CustomRangeType.FIELD,
|
|
14724
|
+
wholeEntity: false,
|
|
14725
|
+
properties: {
|
|
14726
|
+
...properties,
|
|
14727
|
+
sourceKind: "complex"
|
|
14728
|
+
}
|
|
14729
|
+
}] : []
|
|
14730
|
+
},
|
|
14731
|
+
textRanges: [{
|
|
14732
|
+
...selection,
|
|
14733
|
+
segmentId,
|
|
14734
|
+
segmentPage: params.segmentPage ?? (active === null || active === void 0 ? void 0 : active.segmentPage),
|
|
14735
|
+
startOffset: selection.startOffset + dataStream.length,
|
|
14736
|
+
endOffset: selection.startOffset + dataStream.length,
|
|
14737
|
+
collapsed: true
|
|
14738
|
+
}]
|
|
14739
|
+
});
|
|
14740
|
+
}
|
|
14741
|
+
};
|
|
14742
|
+
|
|
14743
|
+
//#endregion
|
|
14744
|
+
//#region src/commands/commands/refresh-header-footer-fields.command.ts
|
|
14745
|
+
const RefreshHeaderFooterFieldsCommand = {
|
|
14746
|
+
id: "doc.command.refresh-header-footer-fields",
|
|
14747
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
14748
|
+
handler(accessor, params) {
|
|
14749
|
+
if (!params) return false;
|
|
14750
|
+
const model = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(params.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
14751
|
+
const snapshot = model === null || model === void 0 ? void 0 : model.getSnapshot();
|
|
14752
|
+
if (!model || !snapshot || snapshot.disabled) return false;
|
|
14753
|
+
const permissions = accessor.get(_univerjs_core.IPermissionService);
|
|
14754
|
+
const locale = _univerjs_core.LOCALE_META[accessor.get(_univerjs_core.LocaleService).getCurrentLocale()].tag;
|
|
14755
|
+
const now = /* @__PURE__ */ new Date();
|
|
14756
|
+
const selections = accessor.get(_univerjs_docs.DocSelectionManagerService).getTextRanges({
|
|
14757
|
+
unitId: params.unitId,
|
|
14758
|
+
subUnitId: params.unitId
|
|
14759
|
+
}) ?? [];
|
|
14760
|
+
let actions = null;
|
|
14761
|
+
for (const [segmentId, segment] of Object.entries({
|
|
14762
|
+
"": { body: snapshot.body },
|
|
14763
|
+
...snapshot.headers,
|
|
14764
|
+
...snapshot.footers
|
|
14765
|
+
})) {
|
|
14766
|
+
if (!segment.body) continue;
|
|
14767
|
+
const textX = refreshDateTimeFields(segment.body, locale, now, (field) => (!params.selectionOnly || selections.some((selection) => (selection.segmentId ?? "") === segmentId && selection.startOffset <= field.endIndex && selection.endOffset > field.startIndex)) && (0, _univerjs_docs.canEditDocumentTargets)(permissions, params.unitId, (0, _univerjs_docs.getDocumentEditTargetObjectIds)(model, segmentId, {
|
|
14768
|
+
startOffset: field.startIndex,
|
|
14769
|
+
endOffset: field.endIndex + 1
|
|
14770
|
+
})));
|
|
14771
|
+
if (textX.length) actions = _univerjs_core.JSONX.compose(actions, _univerjs_core.JSONX.getInstance().editOp(textX, (0, _univerjs_core.getRichTextEditPath)(model, segmentId)));
|
|
14772
|
+
}
|
|
14773
|
+
if (_univerjs_core.JSONX.isNoop(actions)) return true;
|
|
14774
|
+
if (!params.onOpen) accessor.get(_univerjs_docs.DocStateChangeManagerService).flushPendingChanges(params.unitId);
|
|
14775
|
+
return Boolean(accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(_univerjs_docs.RichTextEditingMutation.id, {
|
|
14776
|
+
unitId: params.unitId,
|
|
14777
|
+
actions,
|
|
14778
|
+
textRanges: (0, _univerjs_docs.transformDocumentTextRanges)(actions, [...selections]),
|
|
14779
|
+
noHistory: params.onOpen === true,
|
|
14780
|
+
debounce: false,
|
|
14781
|
+
trigger: RefreshHeaderFooterFieldsCommand.id
|
|
14782
|
+
}));
|
|
14783
|
+
}
|
|
14784
|
+
};
|
|
14785
|
+
const UpdateSelectedDocFieldsCommand = {
|
|
14786
|
+
id: "doc.command.update-selected-fields",
|
|
14787
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
14788
|
+
handler(accessor) {
|
|
14789
|
+
const model = accessor.get(_univerjs_core.IUniverInstanceService).getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
14790
|
+
if (!model) return false;
|
|
14791
|
+
return accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(RefreshHeaderFooterFieldsCommand.id, {
|
|
14792
|
+
unitId: model.getUnitId(),
|
|
14793
|
+
selectionOnly: true
|
|
14794
|
+
});
|
|
14795
|
+
}
|
|
14796
|
+
};
|
|
14797
|
+
function refreshDateTimeFields(body, locale, date, canEdit) {
|
|
14798
|
+
const textX = new _univerjs_core.TextX();
|
|
14799
|
+
let cursor = 0;
|
|
14800
|
+
const ranges = [...body.customRanges ?? []].sort((a, b) => a.startIndex - b.startIndex);
|
|
14801
|
+
for (const field of ranges) {
|
|
14802
|
+
var _body$textRuns, _run$ts;
|
|
14803
|
+
const properties = field.properties;
|
|
14804
|
+
if (field.rangeType !== _univerjs_core.CustomRangeType.FIELD || (properties === null || properties === void 0 ? void 0 : properties.locked) === _univerjs_core.BooleanNumber.TRUE || (properties === null || properties === void 0 ? void 0 : properties.fieldType) !== "DATE" && (properties === null || properties === void 0 ? void 0 : properties.fieldType) !== "TIME" || !canEdit(field) || ranges.some((range) => range !== field && range.startIndex > field.startIndex && range.endIndex < field.endIndex)) continue;
|
|
14805
|
+
const start = field.startIndex;
|
|
14806
|
+
const run = (_body$textRuns = body.textRuns) === null || _body$textRuns === void 0 ? void 0 : _body$textRuns.find((run) => run.st <= start + 1 && run.ed > start + 1);
|
|
14807
|
+
const value = resolveDateTimeField(properties.instruction, (run === null || run === void 0 || (_run$ts = run.ts) === null || _run$ts === void 0 ? void 0 : _run$ts.lang) ?? locale, date);
|
|
14808
|
+
if (value == null || start < cursor || body.dataStream.slice(start + 1, field.endIndex) === value && properties.cachedResult === value) continue;
|
|
14809
|
+
const dataStream = `${_univerjs_core.DataStreamTreeTokenType.CUSTOM_RANGE_START}${value}${_univerjs_core.DataStreamTreeTokenType.CUSTOM_RANGE_END}`;
|
|
14810
|
+
textX.retain(start - cursor).delete(field.endIndex - start + 1).insert(dataStream.length, {
|
|
14811
|
+
dataStream,
|
|
14812
|
+
textRuns: run ? [{
|
|
14813
|
+
...run,
|
|
14814
|
+
st: 0,
|
|
14815
|
+
ed: dataStream.length
|
|
14816
|
+
}] : [],
|
|
14817
|
+
customRanges: [{
|
|
14818
|
+
...field,
|
|
14819
|
+
startIndex: 0,
|
|
14820
|
+
endIndex: dataStream.length - 1,
|
|
14821
|
+
properties: {
|
|
14822
|
+
...properties,
|
|
14823
|
+
cachedResult: value
|
|
14824
|
+
}
|
|
14825
|
+
}]
|
|
14826
|
+
});
|
|
14827
|
+
cursor = field.endIndex + 1;
|
|
14828
|
+
}
|
|
14829
|
+
return textX.serialize();
|
|
14830
|
+
}
|
|
14831
|
+
|
|
14832
|
+
//#endregion
|
|
14833
|
+
//#region src/commands/operations/doc-header-footer-ribbon.operation.ts
|
|
14834
|
+
const DocHeaderFooterRibbonOperation = {
|
|
14835
|
+
id: SidebarDocHeaderFooterPanelOperation.id,
|
|
14836
|
+
type: SidebarDocHeaderFooterPanelOperation.type,
|
|
14837
|
+
handler(accessor, params) {
|
|
14838
|
+
const ribbon = accessor.get(_univerjs_ui.IRibbonService);
|
|
14839
|
+
if ((params === null || params === void 0 ? void 0 : params.value) === "open") ribbon.showContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB, { activate: true });
|
|
14840
|
+
else ribbon.hideContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB);
|
|
14460
14841
|
return true;
|
|
14461
14842
|
}
|
|
14462
14843
|
};
|
|
@@ -15085,8 +15466,12 @@ let DocEventManagerService = class DocEventManagerService extends _univerjs_core
|
|
|
15085
15466
|
}
|
|
15086
15467
|
_initPointer() {
|
|
15087
15468
|
let preCursor = _univerjs_engine_render.CURSOR_TYPE.TEXT;
|
|
15469
|
+
let pointing = false;
|
|
15088
15470
|
this.disposeWithMe(this.hoverCustomRanges$.subscribe((ranges) => {
|
|
15089
|
-
|
|
15471
|
+
const nextPointing = ranges.some(({ range }) => range.rangeType !== _univerjs_core.CustomRangeType.FIELD);
|
|
15472
|
+
if (nextPointing === pointing) return;
|
|
15473
|
+
pointing = nextPointing;
|
|
15474
|
+
if (pointing) {
|
|
15090
15475
|
preCursor = this._context.scene.getCursor();
|
|
15091
15476
|
this._context.scene.setCursor(_univerjs_engine_render.CURSOR_TYPE.POINTER);
|
|
15092
15477
|
} else this._context.scene.setCursor(preCursor);
|
|
@@ -15209,6 +15594,10 @@ let DocEventManagerService = class DocEventManagerService extends _univerjs_core
|
|
|
15209
15594
|
this._buildBulletBounds();
|
|
15210
15595
|
return [...this._bulletBounds];
|
|
15211
15596
|
}
|
|
15597
|
+
getCustomRangeBounds() {
|
|
15598
|
+
this._buildCustomRangeBounds();
|
|
15599
|
+
return [...this._customRangeBounds];
|
|
15600
|
+
}
|
|
15212
15601
|
getListContextMenuBulletByOffset(offsetX, offsetY) {
|
|
15213
15602
|
const point = transformOffset2Bound(offsetX, offsetY, this._context.scene);
|
|
15214
15603
|
return this._calcActiveBullet(point) ?? this._calcActiveListParagraph(point);
|
|
@@ -15754,132 +16143,50 @@ const OpenDocPermissionPanelOperation = {
|
|
|
15754
16143
|
};
|
|
15755
16144
|
|
|
15756
16145
|
//#endregion
|
|
15757
|
-
//#region src/
|
|
15758
|
-
|
|
15759
|
-
|
|
15760
|
-
|
|
15761
|
-
|
|
15762
|
-
|
|
15763
|
-
|
|
15764
|
-
|
|
15765
|
-
|
|
15766
|
-
|
|
15767
|
-
|
|
15768
|
-
|
|
15769
|
-
|
|
15770
|
-
|
|
15771
|
-
|
|
15772
|
-
|
|
15773
|
-
|
|
15774
|
-
|
|
15775
|
-
|
|
15776
|
-
|
|
15777
|
-
|
|
15778
|
-
|
|
15779
|
-
|
|
15780
|
-
|
|
15781
|
-
|
|
15782
|
-
|
|
15783
|
-
|
|
15784
|
-
|
|
15785
|
-
|
|
15786
|
-
|
|
15787
|
-
|
|
15788
|
-
|
|
15789
|
-
|
|
15790
|
-
|
|
15791
|
-
|
|
15792
|
-
|
|
15793
|
-
|
|
15794
|
-
|
|
15795
|
-
|
|
15796
|
-
|
|
15797
|
-
|
|
15798
|
-
|
|
15799
|
-
|
|
15800
|
-
|
|
15801
|
-
handler: (accessor) => {
|
|
15802
|
-
accessor.get(DocParagraphSettingController).openPanel();
|
|
15803
|
-
return true;
|
|
15804
|
-
}
|
|
15805
|
-
};
|
|
15806
|
-
|
|
15807
|
-
//#endregion
|
|
15808
|
-
//#region src/views/section-setting/component-name.ts
|
|
15809
|
-
/**
|
|
15810
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
15811
|
-
*
|
|
15812
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15813
|
-
* you may not use this file except in compliance with the License.
|
|
15814
|
-
* You may obtain a copy of the License at
|
|
15815
|
-
*
|
|
15816
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15817
|
-
*
|
|
15818
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
15819
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15820
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15821
|
-
* See the License for the specific language governing permissions and
|
|
15822
|
-
* limitations under the License.
|
|
15823
|
-
*/
|
|
15824
|
-
const DOC_SECTION_SETTING_COMPONENT = "doc_ui_section-setting-panel";
|
|
15825
|
-
|
|
15826
|
-
//#endregion
|
|
15827
|
-
//#region src/controllers/doc-section-setting.controller.ts
|
|
15828
|
-
/**
|
|
15829
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
15830
|
-
*
|
|
15831
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15832
|
-
* you may not use this file except in compliance with the License.
|
|
15833
|
-
* You may obtain a copy of the License at
|
|
15834
|
-
*
|
|
15835
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15836
|
-
*
|
|
15837
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
15838
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15839
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15840
|
-
* See the License for the specific language governing permissions and
|
|
15841
|
-
* limitations under the License.
|
|
15842
|
-
*/
|
|
15843
|
-
let DocSectionSettingController = class DocSectionSettingController extends _univerjs_core.Disposable {
|
|
15844
|
-
constructor(_sidebarService, _selectionManager) {
|
|
15845
|
-
super();
|
|
15846
|
-
this._sidebarService = _sidebarService;
|
|
15847
|
-
this._selectionManager = _selectionManager;
|
|
15848
|
-
_defineProperty(this, "_panelId", "DocSectionSetting");
|
|
15849
|
-
}
|
|
15850
|
-
openPanel() {
|
|
15851
|
-
this._sidebarService.open({
|
|
15852
|
-
header: { title: "docs-ui.doc.slider.sectionSetting" },
|
|
15853
|
-
id: this._panelId,
|
|
15854
|
-
children: { label: DOC_SECTION_SETTING_COMPONENT },
|
|
15855
|
-
width: 300
|
|
15856
|
-
});
|
|
15857
|
-
}
|
|
15858
|
-
closePanel() {
|
|
15859
|
-
this._sidebarService.close(this._panelId);
|
|
15860
|
-
}
|
|
15861
|
-
navigateToSectionEnd(unitId, sectionStart, sectionEnd) {
|
|
15862
|
-
const params = {
|
|
15863
|
-
unitId,
|
|
15864
|
-
subUnitId: unitId
|
|
15865
|
-
};
|
|
15866
|
-
const cursorOffset = Math.max(sectionStart, sectionEnd - 1);
|
|
15867
|
-
this._selectionManager.replaceDocRanges([{
|
|
15868
|
-
startOffset: cursorOffset,
|
|
15869
|
-
endOffset: cursorOffset
|
|
15870
|
-
}], params, true, { shouldFocus: false });
|
|
15871
|
-
}
|
|
15872
|
-
};
|
|
15873
|
-
DocSectionSettingController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService))], DocSectionSettingController);
|
|
15874
|
-
|
|
15875
|
-
//#endregion
|
|
15876
|
-
//#region src/commands/operations/doc-section-setting-panel.operation.ts
|
|
15877
|
-
const DocSectionSettingPanelOperation = {
|
|
15878
|
-
id: "sidebar.operation.doc-section-setting-panel",
|
|
15879
|
-
type: _univerjs_core.CommandType.OPERATION,
|
|
15880
|
-
handler: (accessor) => {
|
|
15881
|
-
accessor.get(DocSectionSettingController).openPanel();
|
|
15882
|
-
return true;
|
|
16146
|
+
//#region src/commands/commands/insert-special-character.command.ts
|
|
16147
|
+
const InsertSpecialCharacterCommand = {
|
|
16148
|
+
id: "doc.command.insert-special-character",
|
|
16149
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
16150
|
+
handler: (accessor, params) => {
|
|
16151
|
+
var _docDataModel$getSelf, _getEditorRuntimeConf;
|
|
16152
|
+
if (!(params === null || params === void 0 ? void 0 : params.value)) return false;
|
|
16153
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
16154
|
+
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
16155
|
+
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
16156
|
+
const docMenuStyleService = accessor.get(DocMenuStyleService);
|
|
16157
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
16158
|
+
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
16159
|
+
if (!docDataModel || !activeRange) return false;
|
|
16160
|
+
const { segmentId } = activeRange;
|
|
16161
|
+
const originBody = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
16162
|
+
if (!originBody) return false;
|
|
16163
|
+
const { value } = params;
|
|
16164
|
+
const curTextRun = getTextRunForSelection(originBody, activeRange, docMenuStyleService.getDefaultStyle(), docMenuStyleService.getStyleCache(), false, ((_getEditorRuntimeConf = getEditorRuntimeConfig(docDataModel)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.inheritParagraphStartStyle) === true);
|
|
16165
|
+
const curCustomRange = getCustomRangeAtPosition(originBody.customRanges ?? [], activeRange.endOffset);
|
|
16166
|
+
const curCustomDecorations = getCustomDecorationAtPosition(originBody.customDecorations ?? [], activeRange.endOffset);
|
|
16167
|
+
return commandService.executeCommand(_univerjs_docs.InsertTextCommand.id, {
|
|
16168
|
+
unitId: docDataModel.getUnitId(),
|
|
16169
|
+
body: {
|
|
16170
|
+
dataStream: value,
|
|
16171
|
+
textRuns: [{
|
|
16172
|
+
...curTextRun,
|
|
16173
|
+
st: 0,
|
|
16174
|
+
ed: value.length
|
|
16175
|
+
}],
|
|
16176
|
+
customRanges: curCustomRange ? [{
|
|
16177
|
+
...curCustomRange,
|
|
16178
|
+
startIndex: 0,
|
|
16179
|
+
endIndex: value.length - 1
|
|
16180
|
+
}] : [],
|
|
16181
|
+
customDecorations: curCustomDecorations.map((customDecoration) => ({
|
|
16182
|
+
...customDecoration,
|
|
16183
|
+
startIndex: 0,
|
|
16184
|
+
endIndex: value.length - 1
|
|
16185
|
+
}))
|
|
16186
|
+
},
|
|
16187
|
+
range: activeRange,
|
|
16188
|
+
segmentId
|
|
16189
|
+
});
|
|
15883
16190
|
}
|
|
15884
16191
|
};
|
|
15885
16192
|
|
|
@@ -16313,54 +16620,6 @@ const DocOpenPageSettingCommand = {
|
|
|
16313
16620
|
}
|
|
16314
16621
|
};
|
|
16315
16622
|
|
|
16316
|
-
//#endregion
|
|
16317
|
-
//#region src/commands/commands/insert-special-character.command.ts
|
|
16318
|
-
const InsertSpecialCharacterCommand = {
|
|
16319
|
-
id: "doc.command.insert-special-character",
|
|
16320
|
-
type: _univerjs_core.CommandType.COMMAND,
|
|
16321
|
-
handler: (accessor, params) => {
|
|
16322
|
-
var _docDataModel$getSelf, _getEditorRuntimeConf;
|
|
16323
|
-
if (!(params === null || params === void 0 ? void 0 : params.value)) return false;
|
|
16324
|
-
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
16325
|
-
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
16326
|
-
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
16327
|
-
const docMenuStyleService = accessor.get(DocMenuStyleService);
|
|
16328
|
-
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
16329
|
-
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
16330
|
-
if (!docDataModel || !activeRange) return false;
|
|
16331
|
-
const { segmentId } = activeRange;
|
|
16332
|
-
const originBody = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
16333
|
-
if (!originBody) return false;
|
|
16334
|
-
const { value } = params;
|
|
16335
|
-
const curTextRun = getTextRunForSelection(originBody, activeRange, docMenuStyleService.getDefaultStyle(), docMenuStyleService.getStyleCache(), false, ((_getEditorRuntimeConf = getEditorRuntimeConfig(docDataModel)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.inheritParagraphStartStyle) === true);
|
|
16336
|
-
const curCustomRange = getCustomRangeAtPosition(originBody.customRanges ?? [], activeRange.endOffset);
|
|
16337
|
-
const curCustomDecorations = getCustomDecorationAtPosition(originBody.customDecorations ?? [], activeRange.endOffset);
|
|
16338
|
-
return commandService.executeCommand(_univerjs_docs.InsertTextCommand.id, {
|
|
16339
|
-
unitId: docDataModel.getUnitId(),
|
|
16340
|
-
body: {
|
|
16341
|
-
dataStream: value,
|
|
16342
|
-
textRuns: [{
|
|
16343
|
-
...curTextRun,
|
|
16344
|
-
st: 0,
|
|
16345
|
-
ed: value.length
|
|
16346
|
-
}],
|
|
16347
|
-
customRanges: curCustomRange ? [{
|
|
16348
|
-
...curCustomRange,
|
|
16349
|
-
startIndex: 0,
|
|
16350
|
-
endIndex: value.length - 1
|
|
16351
|
-
}] : [],
|
|
16352
|
-
customDecorations: curCustomDecorations.map((customDecoration) => ({
|
|
16353
|
-
...customDecoration,
|
|
16354
|
-
startIndex: 0,
|
|
16355
|
-
endIndex: value.length - 1
|
|
16356
|
-
}))
|
|
16357
|
-
},
|
|
16358
|
-
range: activeRange,
|
|
16359
|
-
segmentId
|
|
16360
|
-
});
|
|
16361
|
-
}
|
|
16362
|
-
};
|
|
16363
|
-
|
|
16364
16623
|
//#endregion
|
|
16365
16624
|
//#region src/views/const.ts
|
|
16366
16625
|
/**
|
|
@@ -17700,22 +17959,226 @@ function getParagraphStyleAtCursor(accessor) {
|
|
|
17700
17959
|
if (startOffset > prevIndex && startOffset <= startIndex) return paragraph;
|
|
17701
17960
|
prevIndex = startIndex;
|
|
17702
17961
|
}
|
|
17703
|
-
return null;
|
|
17704
|
-
}
|
|
17705
|
-
function isInjectorDisposedError(error) {
|
|
17706
|
-
if (!(error instanceof Error)) return false;
|
|
17707
|
-
return error.name === "InjectorAlreadyDisposedError" || error.message.includes("Injector cannot be accessed after it was disposed");
|
|
17708
|
-
}
|
|
17709
|
-
function PageSettingMenuItemFactory(accessor) {
|
|
17710
|
-
return {
|
|
17711
|
-
id: DocOpenPageSettingCommand.id,
|
|
17712
|
-
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
17713
|
-
icon: "DocSettingIcon",
|
|
17714
|
-
tooltip: "docs-ui.toolbar.pageSetup",
|
|
17715
|
-
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC),
|
|
17716
|
-
disabled$: disableMenuWithoutDocumentEditPermission(accessor)
|
|
17717
|
-
};
|
|
17718
|
-
}
|
|
17962
|
+
return null;
|
|
17963
|
+
}
|
|
17964
|
+
function isInjectorDisposedError(error) {
|
|
17965
|
+
if (!(error instanceof Error)) return false;
|
|
17966
|
+
return error.name === "InjectorAlreadyDisposedError" || error.message.includes("Injector cannot be accessed after it was disposed");
|
|
17967
|
+
}
|
|
17968
|
+
function PageSettingMenuItemFactory(accessor) {
|
|
17969
|
+
return {
|
|
17970
|
+
id: DocOpenPageSettingCommand.id,
|
|
17971
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
17972
|
+
icon: "DocSettingIcon",
|
|
17973
|
+
tooltip: "docs-ui.toolbar.pageSetup",
|
|
17974
|
+
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC),
|
|
17975
|
+
disabled$: disableMenuWithoutDocumentEditPermission(accessor)
|
|
17976
|
+
};
|
|
17977
|
+
}
|
|
17978
|
+
|
|
17979
|
+
//#endregion
|
|
17980
|
+
//#region src/menu/header-footer-ribbon.ts
|
|
17981
|
+
const headerFooterRibbonSchema = {
|
|
17982
|
+
[_univerjs_ui.ContextMenuPosition.MAIN_AREA]: { [_univerjs_ui.ContextMenuGroup.FORMAT]: { [UpdateSelectedDocFieldsCommand.id]: {
|
|
17983
|
+
order: 1,
|
|
17984
|
+
menuItemFactory: (accessor) => {
|
|
17985
|
+
const instances = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
17986
|
+
const selections = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
17987
|
+
return {
|
|
17988
|
+
id: UpdateSelectedDocFieldsCommand.id,
|
|
17989
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
17990
|
+
title: "docs-ui.headerFooter.refreshFields",
|
|
17991
|
+
disabled$: disableMenuWithoutDocumentUnitPermission(accessor, _univerjs_protocol.UnitAction.Edit),
|
|
17992
|
+
hidden$: (0, rxjs.combineLatest)([instances.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC), selections.textSelection$.pipe((0, rxjs.startWith)(null))]).pipe((0, rxjs.map)(([model]) => !model || !(selections.getTextRanges({
|
|
17993
|
+
unitId: model.getUnitId(),
|
|
17994
|
+
subUnitId: model.getUnitId()
|
|
17995
|
+
}) ?? []).some((selection) => {
|
|
17996
|
+
var _model$getSelfOrHeade;
|
|
17997
|
+
return (_model$getSelfOrHeade = model.getSelfOrHeaderFooterModel(selection.segmentId)) === null || _model$getSelfOrHeade === void 0 || (_model$getSelfOrHeade = _model$getSelfOrHeade.getBody()) === null || _model$getSelfOrHeade === void 0 || (_model$getSelfOrHeade = _model$getSelfOrHeade.customRanges) === null || _model$getSelfOrHeade === void 0 ? void 0 : _model$getSelfOrHeade.some((field) => field.rangeType === _univerjs_core.CustomRangeType.FIELD && selection.startOffset <= field.endIndex && selection.endOffset > field.startIndex);
|
|
17998
|
+
})))
|
|
17999
|
+
};
|
|
18000
|
+
}
|
|
18001
|
+
} } },
|
|
18002
|
+
[_univerjs_ui.MenuManagerPosition.RIBBON]: { [DOC_HEADER_FOOTER_RIBBON_TAB]: {
|
|
18003
|
+
order: 90,
|
|
18004
|
+
title: "docs-ui.toolbar.headerFooter",
|
|
18005
|
+
contextual: true,
|
|
18006
|
+
...Object.fromEntries([
|
|
18007
|
+
"insertion",
|
|
18008
|
+
"navigation",
|
|
18009
|
+
"options",
|
|
18010
|
+
"position"
|
|
18011
|
+
].map((kind, order) => [`${DOC_HEADER_FOOTER_RIBBON_TAB}.${kind}`, {
|
|
18012
|
+
order,
|
|
18013
|
+
[`${DOC_HEADER_FOOTER_RIBBON_CONTROL}.${kind}`]: {
|
|
18014
|
+
order: 0,
|
|
18015
|
+
gridLayout: {
|
|
18016
|
+
row: 1,
|
|
18017
|
+
column: 1,
|
|
18018
|
+
rowSpan: 2
|
|
18019
|
+
},
|
|
18020
|
+
menuItemFactory: () => ({
|
|
18021
|
+
id: `${DOC_HEADER_FOOTER_RIBBON_CONTROL}.${kind}`,
|
|
18022
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
18023
|
+
label: {
|
|
18024
|
+
name: DOC_HEADER_FOOTER_RIBBON_CONTROL,
|
|
18025
|
+
hoverable: false,
|
|
18026
|
+
props: { kind }
|
|
18027
|
+
}
|
|
18028
|
+
})
|
|
18029
|
+
}
|
|
18030
|
+
}])),
|
|
18031
|
+
"docs-ui.headerFooter.close": {
|
|
18032
|
+
order: 5,
|
|
18033
|
+
[CloseHeaderFooterCommand.id]: {
|
|
18034
|
+
order: 0,
|
|
18035
|
+
gridLayout: {
|
|
18036
|
+
row: 1,
|
|
18037
|
+
column: 1,
|
|
18038
|
+
rowSpan: 2,
|
|
18039
|
+
showLabel: true
|
|
18040
|
+
},
|
|
18041
|
+
menuItemFactory: () => ({
|
|
18042
|
+
id: CloseHeaderFooterCommand.id,
|
|
18043
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
18044
|
+
icon: "CloseIcon",
|
|
18045
|
+
title: "docs-ui.headerFooter.closeHeaderFooter",
|
|
18046
|
+
tooltip: "docs-ui.headerFooter.closeHeaderFooter"
|
|
18047
|
+
})
|
|
18048
|
+
}
|
|
18049
|
+
}
|
|
18050
|
+
} }
|
|
18051
|
+
};
|
|
18052
|
+
|
|
18053
|
+
//#endregion
|
|
18054
|
+
//#region src/controllers/doc-paragraph-setting.controller.ts
|
|
18055
|
+
/**
|
|
18056
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
18057
|
+
*
|
|
18058
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
18059
|
+
* you may not use this file except in compliance with the License.
|
|
18060
|
+
* You may obtain a copy of the License at
|
|
18061
|
+
*
|
|
18062
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18063
|
+
*
|
|
18064
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18065
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18066
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18067
|
+
* See the License for the specific language governing permissions and
|
|
18068
|
+
* limitations under the License.
|
|
18069
|
+
*/
|
|
18070
|
+
const paragraphSettingIndexKey$1 = "doc_ui_paragraph-setting-panel";
|
|
18071
|
+
let DocParagraphSettingController = class DocParagraphSettingController extends _univerjs_core.Disposable {
|
|
18072
|
+
constructor(_commandService, _sidebarService) {
|
|
18073
|
+
super();
|
|
18074
|
+
this._commandService = _commandService;
|
|
18075
|
+
this._sidebarService = _sidebarService;
|
|
18076
|
+
_defineProperty(this, "_id", void 0);
|
|
18077
|
+
}
|
|
18078
|
+
openPanel() {
|
|
18079
|
+
const props = {
|
|
18080
|
+
header: { title: "docs-ui.doc.slider.paragraphSetting" },
|
|
18081
|
+
id: this._id,
|
|
18082
|
+
children: { label: paragraphSettingIndexKey$1 },
|
|
18083
|
+
width: 300
|
|
18084
|
+
};
|
|
18085
|
+
this._sidebarService.open(props);
|
|
18086
|
+
}
|
|
18087
|
+
closePanel() {
|
|
18088
|
+
this._sidebarService.close(this._id);
|
|
18089
|
+
}
|
|
18090
|
+
};
|
|
18091
|
+
DocParagraphSettingController = __decorate([__decorateParam(0, _univerjs_core.ICommandService), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService))], DocParagraphSettingController);
|
|
18092
|
+
|
|
18093
|
+
//#endregion
|
|
18094
|
+
//#region src/commands/operations/doc-paragraph-setting-panel.operation.ts
|
|
18095
|
+
const DocParagraphSettingPanelOperation = {
|
|
18096
|
+
id: "sidebar.operation.doc-paragraph-setting-panel",
|
|
18097
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
18098
|
+
handler: (accessor) => {
|
|
18099
|
+
accessor.get(DocParagraphSettingController).openPanel();
|
|
18100
|
+
return true;
|
|
18101
|
+
}
|
|
18102
|
+
};
|
|
18103
|
+
|
|
18104
|
+
//#endregion
|
|
18105
|
+
//#region src/views/section-setting/component-name.ts
|
|
18106
|
+
/**
|
|
18107
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
18108
|
+
*
|
|
18109
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
18110
|
+
* you may not use this file except in compliance with the License.
|
|
18111
|
+
* You may obtain a copy of the License at
|
|
18112
|
+
*
|
|
18113
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18114
|
+
*
|
|
18115
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18116
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18117
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18118
|
+
* See the License for the specific language governing permissions and
|
|
18119
|
+
* limitations under the License.
|
|
18120
|
+
*/
|
|
18121
|
+
const DOC_SECTION_SETTING_COMPONENT = "doc_ui_section-setting-panel";
|
|
18122
|
+
|
|
18123
|
+
//#endregion
|
|
18124
|
+
//#region src/controllers/doc-section-setting.controller.ts
|
|
18125
|
+
/**
|
|
18126
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
18127
|
+
*
|
|
18128
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
18129
|
+
* you may not use this file except in compliance with the License.
|
|
18130
|
+
* You may obtain a copy of the License at
|
|
18131
|
+
*
|
|
18132
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18133
|
+
*
|
|
18134
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18135
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18136
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18137
|
+
* See the License for the specific language governing permissions and
|
|
18138
|
+
* limitations under the License.
|
|
18139
|
+
*/
|
|
18140
|
+
let DocSectionSettingController = class DocSectionSettingController extends _univerjs_core.Disposable {
|
|
18141
|
+
constructor(_sidebarService, _selectionManager) {
|
|
18142
|
+
super();
|
|
18143
|
+
this._sidebarService = _sidebarService;
|
|
18144
|
+
this._selectionManager = _selectionManager;
|
|
18145
|
+
_defineProperty(this, "_panelId", "DocSectionSetting");
|
|
18146
|
+
}
|
|
18147
|
+
openPanel() {
|
|
18148
|
+
this._sidebarService.open({
|
|
18149
|
+
header: { title: "docs-ui.doc.slider.sectionSetting" },
|
|
18150
|
+
id: this._panelId,
|
|
18151
|
+
children: { label: DOC_SECTION_SETTING_COMPONENT },
|
|
18152
|
+
width: 300
|
|
18153
|
+
});
|
|
18154
|
+
}
|
|
18155
|
+
closePanel() {
|
|
18156
|
+
this._sidebarService.close(this._panelId);
|
|
18157
|
+
}
|
|
18158
|
+
navigateToSectionEnd(unitId, sectionStart, sectionEnd) {
|
|
18159
|
+
const params = {
|
|
18160
|
+
unitId,
|
|
18161
|
+
subUnitId: unitId
|
|
18162
|
+
};
|
|
18163
|
+
const cursorOffset = Math.max(sectionStart, sectionEnd - 1);
|
|
18164
|
+
this._selectionManager.replaceDocRanges([{
|
|
18165
|
+
startOffset: cursorOffset,
|
|
18166
|
+
endOffset: cursorOffset
|
|
18167
|
+
}], params, true, { shouldFocus: false });
|
|
18168
|
+
}
|
|
18169
|
+
};
|
|
18170
|
+
DocSectionSettingController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService))], DocSectionSettingController);
|
|
18171
|
+
|
|
18172
|
+
//#endregion
|
|
18173
|
+
//#region src/commands/operations/doc-section-setting-panel.operation.ts
|
|
18174
|
+
const DocSectionSettingPanelOperation = {
|
|
18175
|
+
id: "sidebar.operation.doc-section-setting-panel",
|
|
18176
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
18177
|
+
handler: (accessor) => {
|
|
18178
|
+
accessor.get(DocSectionSettingController).openPanel();
|
|
18179
|
+
return true;
|
|
18180
|
+
}
|
|
18181
|
+
};
|
|
17719
18182
|
|
|
17720
18183
|
//#endregion
|
|
17721
18184
|
//#region src/menu/context-menu.ts
|
|
@@ -17985,13 +18448,20 @@ function PasteSpecialMenuFactory(accessor) {
|
|
|
17985
18448
|
id: DocPasteSpecialCommand.id,
|
|
17986
18449
|
type: _univerjs_ui.MenuItemType.SELECTOR,
|
|
17987
18450
|
icon: "DocPasteOptionsIcon",
|
|
17988
|
-
title: "docs-ui.pasteOptions.
|
|
17989
|
-
tooltip: "docs-ui.pasteOptions.
|
|
18451
|
+
title: "docs-ui.pasteOptions.special",
|
|
18452
|
+
tooltip: "docs-ui.pasteOptions.special",
|
|
17990
18453
|
selections: DOC_PASTE_OPTIONS.map((option) => ({ ...option })),
|
|
17991
18454
|
disabled$: disableMenuWithoutDocumentUnitPermission(accessor, _univerjs_protocol.UnitAction.Edit),
|
|
17992
18455
|
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC)
|
|
17993
18456
|
};
|
|
17994
18457
|
}
|
|
18458
|
+
function PasteRibbonMenuFactory(accessor) {
|
|
18459
|
+
return {
|
|
18460
|
+
...PasteSpecialMenuFactory(accessor),
|
|
18461
|
+
title: "docs-ui.rightClick.paste",
|
|
18462
|
+
hidden$: (0, rxjs.combineLatest)([(0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC), accessor.get(_univerjs_core.IContextService).subscribeContextValue$(_univerjs_core.FOCUSING_SHAPE_TEXT_EDITOR).pipe((0, rxjs.startWith)(false))]).pipe((0, rxjs.map)(([hidden, editing]) => hidden || editing))
|
|
18463
|
+
};
|
|
18464
|
+
}
|
|
17995
18465
|
|
|
17996
18466
|
//#endregion
|
|
17997
18467
|
//#region src/views/paragraph-menu/theme-color.ts
|
|
@@ -18594,28 +19064,26 @@ const floatToolbarMenuSchema = { [FLOAT_TOOLBAR_MENU_POSITION]: { [FLOAT_TEXT_ST
|
|
|
18594
19064
|
} } };
|
|
18595
19065
|
const menuSchema = {
|
|
18596
19066
|
...floatToolbarMenuSchema,
|
|
18597
|
-
[_univerjs_ui.RibbonStartGroup.
|
|
18598
|
-
|
|
18599
|
-
|
|
18600
|
-
|
|
18601
|
-
|
|
18602
|
-
|
|
18603
|
-
|
|
18604
|
-
showLabel: true
|
|
18605
|
-
},
|
|
18606
|
-
menuItemFactory: PasteSpecialMenuFactory
|
|
19067
|
+
[_univerjs_ui.RibbonStartGroup.HISTORY]: { [DocPasteSpecialCommand.id]: {
|
|
19068
|
+
order: 4,
|
|
19069
|
+
gridLayout: {
|
|
19070
|
+
row: 1,
|
|
19071
|
+
column: 3,
|
|
19072
|
+
rowSpan: 2,
|
|
19073
|
+
showLabel: true
|
|
18607
19074
|
},
|
|
18608
|
-
|
|
18609
|
-
|
|
18610
|
-
|
|
18611
|
-
|
|
18612
|
-
|
|
18613
|
-
|
|
18614
|
-
|
|
18615
|
-
|
|
18616
|
-
|
|
18617
|
-
}
|
|
18618
|
-
|
|
19075
|
+
menuItemFactory: PasteRibbonMenuFactory
|
|
19076
|
+
} },
|
|
19077
|
+
[_univerjs_ui.RibbonStartGroup.OTHERS]: { [OpenDocPermissionPanelOperation.id]: {
|
|
19078
|
+
order: 0,
|
|
19079
|
+
gridLayout: {
|
|
19080
|
+
row: 1,
|
|
19081
|
+
column: 1,
|
|
19082
|
+
rowSpan: 2,
|
|
19083
|
+
showLabel: true
|
|
19084
|
+
},
|
|
19085
|
+
menuItemFactory: DocPermissionMenuItemFactory
|
|
19086
|
+
} },
|
|
18619
19087
|
[_univerjs_ui.RibbonStartGroup.FORMAT]: {
|
|
18620
19088
|
[SetInlineFormatBoldCommand.id]: {
|
|
18621
19089
|
order: 0,
|
|
@@ -18863,16 +19331,18 @@ const menuSchema = {
|
|
|
18863
19331
|
[DocPasteCommand.id]: {
|
|
18864
19332
|
order: 2,
|
|
18865
19333
|
menuItemFactory: PasteMenuFactory
|
|
18866
|
-
}
|
|
19334
|
+
}
|
|
19335
|
+
},
|
|
19336
|
+
[_univerjs_ui.ContextMenuGroup.FORMAT]: {
|
|
18867
19337
|
[DocPasteSpecialCommand.id]: {
|
|
18868
|
-
order:
|
|
19338
|
+
order: -1,
|
|
18869
19339
|
menuItemFactory: PasteSpecialMenuFactory
|
|
19340
|
+
},
|
|
19341
|
+
[DeleteLeftCommand.id]: {
|
|
19342
|
+
order: 0,
|
|
19343
|
+
menuItemFactory: DeleteMenuFactory
|
|
18870
19344
|
}
|
|
18871
19345
|
},
|
|
18872
|
-
[_univerjs_ui.ContextMenuGroup.FORMAT]: { [DeleteLeftCommand.id]: {
|
|
18873
|
-
order: 0,
|
|
18874
|
-
menuItemFactory: DeleteMenuFactory
|
|
18875
|
-
} },
|
|
18876
19346
|
[_univerjs_ui.ContextMenuGroup.LAYOUT]: {
|
|
18877
19347
|
[DocParagraphSettingPanelOperation.id]: {
|
|
18878
19348
|
order: 0,
|
|
@@ -19467,6 +19937,9 @@ const menuSchema = {
|
|
|
19467
19937
|
|
|
19468
19938
|
//#endregion
|
|
19469
19939
|
//#region src/shortcuts/utils.ts
|
|
19940
|
+
function whenTextEditorFocused(contextService) {
|
|
19941
|
+
return contextService.getContextValue(_univerjs_core.FOCUSING_UNIVER_EDITOR) && !contextService.getContextValue(_univerjs_core.FOCUSING_COMMON_DRAWINGS) && (contextService.getContextValue(_univerjs_core.FOCUSING_DOC) || contextService.getContextValue(_univerjs_core.EDITOR_ACTIVATED) || contextService.getContextValue(_univerjs_core.FOCUSING_FX_BAR_EDITOR));
|
|
19942
|
+
}
|
|
19470
19943
|
function whenDocAndEditorFocused(contextService) {
|
|
19471
19944
|
return contextService.getContextValue(_univerjs_core.FOCUSING_DOC) && contextService.getContextValue(_univerjs_core.FOCUSING_UNIVER_EDITOR) && !contextService.getContextValue(_univerjs_core.FOCUSING_COMMON_DRAWINGS);
|
|
19472
19945
|
}
|
|
@@ -19481,6 +19954,11 @@ const TabShortCut = {
|
|
|
19481
19954
|
binding: _univerjs_ui.KeyCode.TAB,
|
|
19482
19955
|
preconditions: whenDocAndEditorFocused
|
|
19483
19956
|
};
|
|
19957
|
+
const UpdateDocFieldsShortcut = {
|
|
19958
|
+
id: UpdateSelectedDocFieldsCommand.id,
|
|
19959
|
+
binding: _univerjs_ui.KeyCode.F9,
|
|
19960
|
+
preconditions: whenDocAndEditorFocused
|
|
19961
|
+
};
|
|
19484
19962
|
const ShiftTabShortCut = {
|
|
19485
19963
|
id: TabCommand.id,
|
|
19486
19964
|
binding: _univerjs_ui.KeyCode.TAB | _univerjs_ui.MetaKeys.SHIFT,
|
|
@@ -20490,21 +20968,6 @@ function DocSideMenuContent() {
|
|
|
20490
20968
|
|
|
20491
20969
|
//#endregion
|
|
20492
20970
|
//#region src/controllers/ui.controller.ts
|
|
20493
|
-
/**
|
|
20494
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
20495
|
-
*
|
|
20496
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
20497
|
-
* you may not use this file except in compliance with the License.
|
|
20498
|
-
* You may obtain a copy of the License at
|
|
20499
|
-
*
|
|
20500
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
20501
|
-
*
|
|
20502
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
20503
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20504
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20505
|
-
* See the License for the specific language governing permissions and
|
|
20506
|
-
* limitations under the License.
|
|
20507
|
-
*/
|
|
20508
20971
|
let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
20509
20972
|
constructor(_injector, _commandService, _layoutService, _menuManagerService, _uiPartsService, _univerInstanceService, _shortcutService, _configService, _embedInteractionBoundaryService, _embedRuntimeFocusCoordinator) {
|
|
20510
20973
|
super();
|
|
@@ -20526,6 +20989,7 @@ let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
|
20526
20989
|
_initMenus() {
|
|
20527
20990
|
this._menuManagerService.appendRootMenu(floatToolbarMenuSchema);
|
|
20528
20991
|
this._menuManagerService.mergeMenu(menuSchema);
|
|
20992
|
+
this._menuManagerService.mergeMenu(headerFooterRibbonSchema);
|
|
20529
20993
|
}
|
|
20530
20994
|
_initShortCut() {
|
|
20531
20995
|
[
|
|
@@ -20541,7 +21005,8 @@ let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
|
20541
21005
|
AlignLeftShortCut,
|
|
20542
21006
|
OrderListShortCut,
|
|
20543
21007
|
BulletListShortCut,
|
|
20544
|
-
TabShortCut
|
|
21008
|
+
TabShortCut,
|
|
21009
|
+
UpdateDocFieldsShortcut
|
|
20545
21010
|
].forEach((shortcut) => {
|
|
20546
21011
|
this.disposeWithMe(this._shortcutService.registerShortcut(shortcut));
|
|
20547
21012
|
});
|
|
@@ -20550,6 +21015,7 @@ let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
|
20550
21015
|
this._initMenus();
|
|
20551
21016
|
this._initFocusHandler();
|
|
20552
21017
|
this._initCommands();
|
|
21018
|
+
this._initDateTimeFields();
|
|
20553
21019
|
this._initUiParts();
|
|
20554
21020
|
this._initShortCut();
|
|
20555
21021
|
}
|
|
@@ -20558,10 +21024,25 @@ let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
|
20558
21024
|
OpenDocPermissionPanelOperation,
|
|
20559
21025
|
OpenDocParagraphPermissionOperation,
|
|
20560
21026
|
CoreHeaderFooterCommand,
|
|
21027
|
+
InsertHeaderFooterFieldCommand,
|
|
21028
|
+
RefreshHeaderFooterFieldsCommand,
|
|
21029
|
+
UpdateSelectedDocFieldsCommand,
|
|
20561
21030
|
OpenHeaderFooterPanelCommand,
|
|
20562
|
-
|
|
21031
|
+
DocHeaderFooterRibbonOperation
|
|
20563
21032
|
].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
|
|
20564
21033
|
}
|
|
21034
|
+
_initDateTimeFields() {
|
|
21035
|
+
const refreshed = /* @__PURE__ */ new WeakSet();
|
|
21036
|
+
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC).subscribe((model) => {
|
|
21037
|
+
if (model && !refreshed.has(model)) {
|
|
21038
|
+
refreshed.add(model);
|
|
21039
|
+
this._commandService.syncExecuteCommand(RefreshHeaderFooterFieldsCommand.id, {
|
|
21040
|
+
unitId: model.getUnitId(),
|
|
21041
|
+
onOpen: true
|
|
21042
|
+
});
|
|
21043
|
+
}
|
|
21044
|
+
}));
|
|
21045
|
+
}
|
|
20565
21046
|
_initFocusHandler() {
|
|
20566
21047
|
this.disposeWithMe(this._layoutService.registerFocusHandler(_univerjs_core.UniverInstanceType.UNIVER_DOC, (unitId) => {
|
|
20567
21048
|
if (this._shouldPreserveEmbedFocus(unitId)) return;
|
|
@@ -20859,7 +21340,7 @@ function resolveDocsCustomBlockRenderViewport(params) {
|
|
|
20859
21340
|
//#endregion
|
|
20860
21341
|
//#region package.json
|
|
20861
21342
|
var name = "@univerjs/docs-ui";
|
|
20862
|
-
var version = "1.0.
|
|
21343
|
+
var version = "1.0.4";
|
|
20863
21344
|
|
|
20864
21345
|
//#endregion
|
|
20865
21346
|
//#region src/commands/commands/doc-paragraph-setting.command.ts
|
|
@@ -21106,8 +21587,8 @@ var HeaderFooterContentCover = class extends _univerjs_engine_render.BaseObject
|
|
|
21106
21587
|
right: pageLeft + page.pageWidth,
|
|
21107
21588
|
bottom: pageTop + page.pageHeight
|
|
21108
21589
|
});
|
|
21109
|
-
const header = (_data$skeHeaders$get = data.skeHeaders.get(page.headerId)) === null || _data$skeHeaders$get === void 0 ? void 0 : _data$skeHeaders$get.get(page.pageWidth);
|
|
21110
|
-
const footer = (_data$skeFooters$get = data.skeFooters.get(page.footerId)) === null || _data$skeFooters$get === void 0 ? void 0 : _data$skeFooters$get.get(page.pageWidth);
|
|
21590
|
+
const header = (_data$skeHeaders$get = data.skeHeaders.get(page.headerId)) === null || _data$skeHeaders$get === void 0 ? void 0 : _data$skeHeaders$get.get(page.headerLayoutKey ?? page.pageWidth);
|
|
21591
|
+
const footer = (_data$skeFooters$get = data.skeFooters.get(page.footerId)) === null || _data$skeFooters$get === void 0 ? void 0 : _data$skeFooters$get.get(page.footerLayoutKey ?? page.pageWidth);
|
|
21111
21592
|
const local = [];
|
|
21112
21593
|
if (header) this._collectTextAndTables(header, pageLeft + page.marginLeft, pageTop + header.marginTop, local);
|
|
21113
21594
|
if (footer) this._collectTextAndTables(footer, pageLeft + page.marginLeft, pageTop + page.pageHeight - footer.height - footer.marginBottom, local);
|
|
@@ -21565,10 +22046,11 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
21565
22046
|
const body = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(normalizedSegmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
21566
22047
|
if (body == null) return;
|
|
21567
22048
|
const dataStreamLength = body.dataStream.length ?? Number.POSITIVE_INFINITY;
|
|
21568
|
-
const customRanges =
|
|
22049
|
+
const customRanges = body.customRanges ?? [];
|
|
21569
22050
|
if (granularity !== "character") {
|
|
21570
22051
|
const nextOffset = this._getCursorOffsetByGranularity(skeleton, focusOffset, direction, granularity, normalizedSegmentId, normalizedSegmentPage, dataStreamLength, body.dataStream);
|
|
21571
22052
|
if (nextOffset == null || nextOffset === focusOffset) return;
|
|
22053
|
+
if (this._deferUnmaterializedCursorMove(docDataModel, skeleton, nextOffset, normalizedSegmentId, () => this._handleShiftMoveSelection(direction, granularity))) return;
|
|
21572
22054
|
const normalizedNextOffset = this._normalizeRenderableCursorOffset(skeleton, body.dataStream, customRanges, nextOffset, direction, normalizedSegmentId, normalizedSegmentPage);
|
|
21573
22055
|
if (normalizedNextOffset == null || normalizedNextOffset === focusOffset) return;
|
|
21574
22056
|
this._textSelectionManagerService.replaceDocRanges([{
|
|
@@ -21636,7 +22118,7 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
21636
22118
|
const body = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(normalizedSegmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.getBody();
|
|
21637
22119
|
if (body == null) return;
|
|
21638
22120
|
const dataStreamLength = body.dataStream.length ?? Number.POSITIVE_INFINITY;
|
|
21639
|
-
const customRanges =
|
|
22121
|
+
const customRanges = body.customRanges ?? [];
|
|
21640
22122
|
if (granularity !== "character") {
|
|
21641
22123
|
let cursorOffset;
|
|
21642
22124
|
if (!activeRange.collapsed || allRanges.length > 1) {
|
|
@@ -22259,26 +22741,33 @@ function DocPasteOptions() {
|
|
|
22259
22741
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
22260
22742
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
22261
22743
|
const layoutService = (0, _univerjs_ui.useDependency)(_univerjs_ui.ILayoutService);
|
|
22744
|
+
const editorService = (0, _univerjs_ui.useDependency)(IEditorService);
|
|
22262
22745
|
const state = (0, _univerjs_ui.useObservable)(clipboard.pasteOptions$, null);
|
|
22263
22746
|
const [busy, setBusy] = (0, react.useState)(false);
|
|
22264
22747
|
const [open, setOpen] = (0, react.useState)(false);
|
|
22748
|
+
const focusEditor = () => {
|
|
22749
|
+
const editor = state && clipboard.isPasteOptionsEnabled(state.unitId) && editorService.getEditor(state.unitId);
|
|
22750
|
+
if (editor) editor.focus();
|
|
22751
|
+
else layoutService.focus();
|
|
22752
|
+
};
|
|
22265
22753
|
const changeMode = async (value) => {
|
|
22266
22754
|
setBusy(true);
|
|
22267
22755
|
try {
|
|
22268
22756
|
await commandService.executeCommand(DocChangePasteModeCommand.id, { value });
|
|
22269
22757
|
} finally {
|
|
22270
22758
|
setBusy(false);
|
|
22271
|
-
|
|
22759
|
+
focusEditor();
|
|
22272
22760
|
}
|
|
22273
22761
|
};
|
|
22274
22762
|
if (!state) return null;
|
|
22275
22763
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
|
|
22764
|
+
"data-u-editor-interaction-boundary": "true",
|
|
22276
22765
|
align: "start",
|
|
22277
22766
|
open,
|
|
22278
22767
|
onOpenChange: setOpen,
|
|
22279
22768
|
onCloseAutoFocus: (event) => {
|
|
22280
22769
|
event.preventDefault();
|
|
22281
|
-
|
|
22770
|
+
focusEditor();
|
|
22282
22771
|
},
|
|
22283
22772
|
onEscapeKeyDown: () => clipboard.dismissPasteOptions(),
|
|
22284
22773
|
items: DOC_PASTE_OPTIONS.map((option) => ({
|
|
@@ -22290,6 +22779,7 @@ function DocPasteOptions() {
|
|
|
22290
22779
|
onSelect: () => changeMode(option.value)
|
|
22291
22780
|
})),
|
|
22292
22781
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
|
|
22782
|
+
"data-u-editor-interaction-boundary": "true",
|
|
22293
22783
|
size: "small",
|
|
22294
22784
|
disabled: busy,
|
|
22295
22785
|
"aria-label": localeService.t("docs-ui.pasteOptions.title"),
|
|
@@ -22298,7 +22788,7 @@ function DocPasteOptions() {
|
|
|
22298
22788
|
onKeyDown: (event) => {
|
|
22299
22789
|
if (event.key === "Escape") {
|
|
22300
22790
|
clipboard.dismissPasteOptions();
|
|
22301
|
-
|
|
22791
|
+
focusEditor();
|
|
22302
22792
|
}
|
|
22303
22793
|
},
|
|
22304
22794
|
className: "univer-shadow-sm",
|
|
@@ -22557,28 +23047,37 @@ function useHeaderFooterOptions(unitId) {
|
|
|
22557
23047
|
page
|
|
22558
23048
|
};
|
|
22559
23049
|
};
|
|
22560
|
-
const [
|
|
22561
|
-
|
|
22562
|
-
const
|
|
22563
|
-
|
|
22564
|
-
|
|
22565
|
-
|
|
22566
|
-
|
|
22567
|
-
|
|
23050
|
+
const [, refresh] = (0, react.useReducer)((revision) => revision + 1, 0);
|
|
23051
|
+
(0, react.useEffect)(() => {
|
|
23052
|
+
const commandListener = commandService.onCommandExecuted((command) => {
|
|
23053
|
+
var _command$params;
|
|
23054
|
+
if (command.id === _univerjs_docs.RichTextEditingMutation.id && ((_command$params = command.params) === null || _command$params === void 0 ? void 0 : _command$params.unitId) === unitId) refresh();
|
|
23055
|
+
});
|
|
23056
|
+
const segmentListener = docSelectionRenderService.segmentContext$.subscribe(() => refresh());
|
|
23057
|
+
return () => {
|
|
23058
|
+
commandListener.dispose();
|
|
23059
|
+
segmentListener.unsubscribe();
|
|
22568
23060
|
};
|
|
22569
|
-
}
|
|
23061
|
+
}, [
|
|
23062
|
+
commandService,
|
|
23063
|
+
docSelectionRenderService,
|
|
23064
|
+
unitId
|
|
23065
|
+
]);
|
|
22570
23066
|
const sectionContext = getCurrentSectionContext();
|
|
23067
|
+
const config = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config;
|
|
23068
|
+
const options = {
|
|
23069
|
+
marginHeader: (config === null || config === void 0 ? void 0 : config.marginHeader) ?? 0,
|
|
23070
|
+
marginFooter: (config === null || config === void 0 ? void 0 : config.marginFooter) ?? 0,
|
|
23071
|
+
useFirstPageHeaderFooter: (config === null || config === void 0 ? void 0 : config.useFirstPageHeaderFooter) ?? _univerjs_core.BooleanNumber.FALSE,
|
|
23072
|
+
evenAndOddHeaders: (config === null || config === void 0 ? void 0 : config.evenAndOddHeaders) ?? _univerjs_core.BooleanNumber.FALSE
|
|
23073
|
+
};
|
|
22571
23074
|
const headerFooterKind = ((_renderManagerService2 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService2 === void 0 || (_renderManagerService2 = _renderManagerService2.with(_univerjs_docs.DocSkeletonManagerService)) === null || _renderManagerService2 === void 0 || (_renderManagerService2 = _renderManagerService2.getViewModel()) === null || _renderManagerService2 === void 0 ? void 0 : _renderManagerService2.getEditArea()) === _univerjs_engine_render.DocumentEditArea.FOOTER ? "footer" : "header";
|
|
22572
23075
|
const variant = getHeaderFooterVariant((sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config) ?? {}, docSelectionRenderService.getSegmentPage(), sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page);
|
|
22573
23076
|
const referenceKey = (0, _univerjs_core.getSectionHeaderFooterReferenceKey)(headerFooterKind, variant);
|
|
22574
23077
|
const canLinkToPrevious = ((sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionIndex) ?? -1) > 0;
|
|
22575
|
-
const
|
|
22576
|
-
const handleCheckboxChange = (val, type) => {
|
|
23078
|
+
const linkedToPrevious = canLinkToPrevious && !(sectionContext === null || sectionContext === void 0 || (_sectionContext$secti = sectionContext.section) === null || _sectionContext$secti === void 0 ? void 0 : _sectionContext$secti[referenceKey]);
|
|
23079
|
+
const handleCheckboxChange = async (val, type) => {
|
|
22577
23080
|
var _renderManagerService3;
|
|
22578
|
-
setOptions((prev) => ({
|
|
22579
|
-
...prev,
|
|
22580
|
-
[type]: val ? _univerjs_core.BooleanNumber.TRUE : _univerjs_core.BooleanNumber.FALSE
|
|
22581
|
-
}));
|
|
22582
23081
|
const sectionContext = getCurrentSectionContext();
|
|
22583
23082
|
const documentStyle = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config;
|
|
22584
23083
|
const docSkeletonManagerService = (_renderManagerService3 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService3 === void 0 ? void 0 : _renderManagerService3.with(_univerjs_docs.DocSkeletonManagerService);
|
|
@@ -22603,7 +23102,7 @@ function useHeaderFooterOptions(unitId) {
|
|
|
22603
23102
|
if (needCreateHeaderFooter) {
|
|
22604
23103
|
const segmentId = (0, _univerjs_core.generateRandomId)(6);
|
|
22605
23104
|
if (needChangeSegmentId) docSelectionRenderService.setSegment(segmentId);
|
|
22606
|
-
commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
23105
|
+
await commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
22607
23106
|
unitId,
|
|
22608
23107
|
segmentId,
|
|
22609
23108
|
headerFooterProps: { [type]: val ? _univerjs_core.BooleanNumber.TRUE : _univerjs_core.BooleanNumber.FALSE },
|
|
@@ -22617,7 +23116,7 @@ function useHeaderFooterOptions(unitId) {
|
|
|
22617
23116
|
[type]: val ? _univerjs_core.BooleanNumber.TRUE : _univerjs_core.BooleanNumber.FALSE
|
|
22618
23117
|
}, editArea, segmentPageIndex, sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page);
|
|
22619
23118
|
if (needFocusSegmentId && needFocusSegmentId !== prevSegmentId) docSelectionRenderService.setSegment(needFocusSegmentId);
|
|
22620
|
-
commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
23119
|
+
await commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
22621
23120
|
unitId,
|
|
22622
23121
|
headerFooterProps: { [type]: val ? _univerjs_core.BooleanNumber.TRUE : _univerjs_core.BooleanNumber.FALSE },
|
|
22623
23122
|
sectionId: sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionId
|
|
@@ -22626,21 +23125,16 @@ function useHeaderFooterOptions(unitId) {
|
|
|
22626
23125
|
layoutService.focus();
|
|
22627
23126
|
};
|
|
22628
23127
|
const handleMarginChange = async (val, type) => {
|
|
22629
|
-
var
|
|
22630
|
-
setOptions((prev) => ({
|
|
22631
|
-
...prev,
|
|
22632
|
-
[type]: val
|
|
22633
|
-
}));
|
|
23128
|
+
var _getCurrentSectionCon;
|
|
22634
23129
|
await commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
22635
23130
|
unitId,
|
|
22636
23131
|
headerFooterProps: { [type]: val },
|
|
22637
|
-
sectionId: (
|
|
23132
|
+
sectionId: (_getCurrentSectionCon = getCurrentSectionContext()) === null || _getCurrentSectionCon === void 0 ? void 0 : _getCurrentSectionCon.sectionId
|
|
22638
23133
|
});
|
|
22639
|
-
docSelectionRenderService.removeAllRanges();
|
|
22640
23134
|
docSelectionRenderService.blur();
|
|
22641
23135
|
};
|
|
22642
23136
|
const closeHeaderFooter = () => {
|
|
22643
|
-
commandService.executeCommand(CloseHeaderFooterCommand.id, { unitId });
|
|
23137
|
+
return commandService.executeCommand(CloseHeaderFooterCommand.id, { unitId });
|
|
22644
23138
|
};
|
|
22645
23139
|
const handleLinkToPreviousChange = async (linked) => {
|
|
22646
23140
|
var _renderManagerService4;
|
|
@@ -22659,7 +23153,6 @@ function useHeaderFooterOptions(unitId) {
|
|
|
22659
23153
|
linkedToPrevious: linked,
|
|
22660
23154
|
...linked ? {} : { segmentId }
|
|
22661
23155
|
})) return;
|
|
22662
|
-
setLinkedToPrevious(linked);
|
|
22663
23156
|
docSelectionRenderService.setSegment(linked ? previousSegmentId ?? "" : segmentId);
|
|
22664
23157
|
layoutService.focus();
|
|
22665
23158
|
};
|
|
@@ -24142,25 +24635,30 @@ const mobileMenuSchema = {
|
|
|
24142
24635
|
menuItemFactory: SelectAllMenuFactory
|
|
24143
24636
|
}
|
|
24144
24637
|
} },
|
|
24145
|
-
[DOC_CARET_MENU_ID]: {
|
|
24146
|
-
|
|
24147
|
-
|
|
24148
|
-
|
|
24149
|
-
|
|
24150
|
-
|
|
24151
|
-
|
|
24152
|
-
|
|
24153
|
-
|
|
24638
|
+
[DOC_CARET_MENU_ID]: {
|
|
24639
|
+
[_univerjs_ui.ContextMenuGroup.QUICK]: {
|
|
24640
|
+
quickLayout: "tile",
|
|
24641
|
+
[DocPasteCommand.id]: {
|
|
24642
|
+
order: 0,
|
|
24643
|
+
menuItemFactory: PasteMenuFactory
|
|
24644
|
+
},
|
|
24645
|
+
[DocSelectWordCommand.id]: {
|
|
24646
|
+
order: 1,
|
|
24647
|
+
menuItemFactory: SelectWordMenuFactory
|
|
24648
|
+
},
|
|
24649
|
+
[DocSelectAllCommand.id]: {
|
|
24650
|
+
order: 2,
|
|
24651
|
+
menuItemFactory: SelectAllMenuFactory
|
|
24652
|
+
}
|
|
24154
24653
|
},
|
|
24155
|
-
[
|
|
24654
|
+
[_univerjs_ui.ContextMenuGroup.FORMAT]: {
|
|
24156
24655
|
order: 1,
|
|
24157
|
-
|
|
24158
|
-
|
|
24159
|
-
|
|
24160
|
-
|
|
24161
|
-
menuItemFactory: SelectAllMenuFactory
|
|
24656
|
+
[DocPasteSpecialCommand.id]: {
|
|
24657
|
+
order: 0,
|
|
24658
|
+
menuItemFactory: PasteSpecialMenuFactory
|
|
24659
|
+
}
|
|
24162
24660
|
}
|
|
24163
|
-
}
|
|
24661
|
+
}
|
|
24164
24662
|
};
|
|
24165
24663
|
|
|
24166
24664
|
//#endregion
|
|
@@ -25356,9 +25854,9 @@ let DocPasteOptionsRenderController = class DocPasteOptionsRenderController exte
|
|
|
25356
25854
|
this._context = _context;
|
|
25357
25855
|
this._clipboard = _clipboard;
|
|
25358
25856
|
_defineProperty(this, "_popup", void 0);
|
|
25359
|
-
if ((0, _univerjs_core.isInternalEditorID)(_context.unitId)) return;
|
|
25360
25857
|
const mobile = contextService.getContextValue(_univerjs_ui.MOBILE_UI_MODE) === true;
|
|
25361
25858
|
this.disposeWithMe(selection.onKeydown$.subscribe(({ event }) => {
|
|
25859
|
+
if (!this._clipboard.isPasteOptionsEnabled(this._context.unitId)) return;
|
|
25362
25860
|
const key = event;
|
|
25363
25861
|
if ((key.ctrlKey || key.metaKey) && key.shiftKey && key.key.toLowerCase() === "v") this._clipboard.setNextPasteMode("text");
|
|
25364
25862
|
else if (![
|
|
@@ -25371,12 +25869,17 @@ let DocPasteOptionsRenderController = class DocPasteOptionsRenderController exte
|
|
|
25371
25869
|
this._clipboard.dismissPasteOptions();
|
|
25372
25870
|
}
|
|
25373
25871
|
}));
|
|
25374
|
-
this.disposeWithMe(selection.onInputBefore$.subscribe(() =>
|
|
25872
|
+
this.disposeWithMe(selection.onInputBefore$.subscribe(() => {
|
|
25873
|
+
if (this._clipboard.isPasteOptionsEnabled(this._context.unitId)) this._clipboard.dismissPasteOptions();
|
|
25874
|
+
}));
|
|
25375
25875
|
this.disposeWithMe(selection.onPointerDown$.subscribe(() => {
|
|
25876
|
+
if (!this._clipboard.isPasteOptionsEnabled(this._context.unitId)) return;
|
|
25376
25877
|
this._clipboard.setNextPasteMode("source");
|
|
25377
25878
|
if (!mobile) this._clipboard.dismissPasteOptions();
|
|
25378
25879
|
}));
|
|
25379
|
-
this.disposeWithMe(selection.onBlur$.subscribe(() =>
|
|
25880
|
+
this.disposeWithMe(selection.onBlur$.subscribe(() => {
|
|
25881
|
+
if (this._clipboard.isPasteOptionsEnabled(this._context.unitId)) this._clipboard.setNextPasteMode("source");
|
|
25882
|
+
}));
|
|
25380
25883
|
this.disposeWithMe(this._clipboard.pasteOptions$.subscribe((state) => {
|
|
25381
25884
|
var _this$_popup;
|
|
25382
25885
|
(_this$_popup = this._popup) === null || _this$_popup === void 0 || _this$_popup.dispose();
|
|
@@ -25396,7 +25899,7 @@ let DocPasteOptionsRenderController = class DocPasteOptionsRenderController exte
|
|
|
25396
25899
|
this.disposeWithMe(() => {
|
|
25397
25900
|
var _this$_popup2;
|
|
25398
25901
|
(_this$_popup2 = this._popup) === null || _this$_popup2 === void 0 || _this$_popup2.dispose();
|
|
25399
|
-
this._clipboard.dismissPasteOptions();
|
|
25902
|
+
if (this._popup) this._clipboard.dismissPasteOptions();
|
|
25400
25903
|
});
|
|
25401
25904
|
}
|
|
25402
25905
|
};
|
|
@@ -26433,8 +26936,8 @@ var DocPrintInterceptorService = class extends _univerjs_core.Disposable {
|
|
|
26433
26936
|
const page = data.pages[pageIndex];
|
|
26434
26937
|
if (!page) return drawingIds;
|
|
26435
26938
|
collectPageDrawingIds(page, drawingIds);
|
|
26436
|
-
const header = (_data$skeHeaders$get = data.skeHeaders.get(page.headerId)) === null || _data$skeHeaders$get === void 0 ? void 0 : _data$skeHeaders$get.get(page.pageWidth);
|
|
26437
|
-
const footer = (_data$skeFooters$get = data.skeFooters.get(page.footerId)) === null || _data$skeFooters$get === void 0 ? void 0 : _data$skeFooters$get.get(page.pageWidth);
|
|
26939
|
+
const header = (_data$skeHeaders$get = data.skeHeaders.get(page.headerId)) === null || _data$skeHeaders$get === void 0 ? void 0 : _data$skeHeaders$get.get(page.headerLayoutKey ?? page.pageWidth);
|
|
26940
|
+
const footer = (_data$skeFooters$get = data.skeFooters.get(page.footerId)) === null || _data$skeFooters$get === void 0 ? void 0 : _data$skeFooters$get.get(page.footerLayoutKey ?? page.pageWidth);
|
|
26438
26941
|
if (header) collectPageDrawingIds(header, drawingIds);
|
|
26439
26942
|
if (footer) collectPageDrawingIds(footer, drawingIds);
|
|
26440
26943
|
return drawingIds;
|
|
@@ -27435,6 +27938,319 @@ UniverDocsMobileUIPlugin = __decorate([
|
|
|
27435
27938
|
__decorateParam(4, _univerjs_core.IConfigService)
|
|
27436
27939
|
], UniverDocsMobileUIPlugin);
|
|
27437
27940
|
|
|
27941
|
+
//#endregion
|
|
27942
|
+
//#region src/views/header-footer/panel/DocHeaderFooterFields.tsx
|
|
27943
|
+
function DocHeaderFooterFields({ unitId, disabled }) {
|
|
27944
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
27945
|
+
(0, _univerjs_ui.useObservable)(localeService.currentLocale$);
|
|
27946
|
+
const commands = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
27947
|
+
const layout = (0, _univerjs_ui.useDependency)(_univerjs_ui.ILayoutService);
|
|
27948
|
+
const shortcuts = (0, _univerjs_ui.useDependency)(_univerjs_ui.IShortcutService);
|
|
27949
|
+
const selections = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocSelectionManagerService);
|
|
27950
|
+
const instances = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
27951
|
+
const [target, setTarget] = (0, react.useState)(null);
|
|
27952
|
+
const [format, setFormat] = (0, react.useState)("short");
|
|
27953
|
+
const [automatic, setAutomatic] = (0, react.useState)(true);
|
|
27954
|
+
const [error, setError] = (0, react.useState)(false);
|
|
27955
|
+
const [previewDate, setPreviewDate] = (0, react.useState)(() => /* @__PURE__ */ new Date());
|
|
27956
|
+
const locale = _univerjs_core.LOCALE_META[localeService.getCurrentLocale()].tag;
|
|
27957
|
+
const dialogOpen = target !== null;
|
|
27958
|
+
const dialogFocusRef = (0, react.useRef)(null);
|
|
27959
|
+
(0, react.useEffect)(() => {
|
|
27960
|
+
var _instances$getFocused;
|
|
27961
|
+
if (dialogOpen) return;
|
|
27962
|
+
const focus = dialogFocusRef.current;
|
|
27963
|
+
dialogFocusRef.current = null;
|
|
27964
|
+
if ((focus === null || focus === void 0 ? void 0 : focus.unitId) === unitId && instances.getUnit(unitId) && ((_instances$getFocused = instances.getFocusedUnit()) === null || _instances$getFocused === void 0 ? void 0 : _instances$getFocused.getUnitId()) === focus.focusedUnitId) layout.focus(unitId);
|
|
27965
|
+
}, [
|
|
27966
|
+
dialogOpen,
|
|
27967
|
+
instances,
|
|
27968
|
+
layout,
|
|
27969
|
+
unitId
|
|
27970
|
+
]);
|
|
27971
|
+
(0, react.useEffect)(() => {
|
|
27972
|
+
if (!dialogOpen) return;
|
|
27973
|
+
const escape = shortcuts.forceEscape();
|
|
27974
|
+
return () => escape.dispose();
|
|
27975
|
+
}, [dialogOpen, shortcuts]);
|
|
27976
|
+
function restoreFocus(event) {
|
|
27977
|
+
event.preventDefault();
|
|
27978
|
+
layout.focus(unitId);
|
|
27979
|
+
}
|
|
27980
|
+
function openDateTime() {
|
|
27981
|
+
var _instances$getUnit, _instances$getFocused2;
|
|
27982
|
+
const selection = selections.getActiveTextRange();
|
|
27983
|
+
const body = (_instances$getUnit = instances.getUnit(unitId)) === null || _instances$getUnit === void 0 || (_instances$getUnit = _instances$getUnit.getSelfOrHeaderFooterModel(selection === null || selection === void 0 ? void 0 : selection.segmentId)) === null || _instances$getUnit === void 0 ? void 0 : _instances$getUnit.getBody();
|
|
27984
|
+
if (!(selection === null || selection === void 0 ? void 0 : selection.segmentId) || !body) return;
|
|
27985
|
+
dialogFocusRef.current = {
|
|
27986
|
+
unitId,
|
|
27987
|
+
focusedUnitId: (_instances$getFocused2 = instances.getFocusedUnit()) === null || _instances$getFocused2 === void 0 ? void 0 : _instances$getFocused2.getUnitId()
|
|
27988
|
+
};
|
|
27989
|
+
setTarget({
|
|
27990
|
+
unitId,
|
|
27991
|
+
selection: { ...selection },
|
|
27992
|
+
segmentId: selection.segmentId,
|
|
27993
|
+
segmentPage: selection.segmentPage,
|
|
27994
|
+
expectedDataStream: body.dataStream
|
|
27995
|
+
});
|
|
27996
|
+
setPreviewDate(/* @__PURE__ */ new Date());
|
|
27997
|
+
setError(false);
|
|
27998
|
+
}
|
|
27999
|
+
async function insertDateTime() {
|
|
28000
|
+
if (!target) return;
|
|
28001
|
+
if (await commands.executeCommand(InsertHeaderFooterFieldCommand.id, {
|
|
28002
|
+
...target,
|
|
28003
|
+
fieldType: format === "time" ? "TIME" : "DATE",
|
|
28004
|
+
format,
|
|
28005
|
+
automatic
|
|
28006
|
+
})) setTarget(null);
|
|
28007
|
+
else setError(true);
|
|
28008
|
+
}
|
|
28009
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
28010
|
+
className: "univer-flex univer-flex-col univer-gap-1 univer-text-xs",
|
|
28011
|
+
children: [
|
|
28012
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
|
|
28013
|
+
onCloseAutoFocus: restoreFocus,
|
|
28014
|
+
disabled,
|
|
28015
|
+
items: [
|
|
28016
|
+
{
|
|
28017
|
+
type: "item",
|
|
28018
|
+
children: localeService.t("docs-ui.headerFooter.currentPage"),
|
|
28019
|
+
onSelect: () => commands.executeCommand(InsertHeaderFooterFieldCommand.id, {
|
|
28020
|
+
unitId,
|
|
28021
|
+
fieldType: "PAGE"
|
|
28022
|
+
})
|
|
28023
|
+
},
|
|
28024
|
+
{
|
|
28025
|
+
type: "item",
|
|
28026
|
+
children: localeService.t("docs-ui.headerFooter.totalPages"),
|
|
28027
|
+
onSelect: () => commands.executeCommand(InsertHeaderFooterFieldCommand.id, {
|
|
28028
|
+
unitId,
|
|
28029
|
+
fieldType: "NUMPAGES"
|
|
28030
|
+
})
|
|
28031
|
+
},
|
|
28032
|
+
{ type: "separator" },
|
|
28033
|
+
{
|
|
28034
|
+
type: "item",
|
|
28035
|
+
children: localeService.t("docs-ui.headerFooter.refreshFields"),
|
|
28036
|
+
onSelect: () => commands.executeCommand(RefreshHeaderFooterFieldsCommand.id, { unitId })
|
|
28037
|
+
}
|
|
28038
|
+
],
|
|
28039
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
|
|
28040
|
+
className: "univer-justify-start",
|
|
28041
|
+
"data-u-command": InsertHeaderFooterFieldCommand.id,
|
|
28042
|
+
size: "small",
|
|
28043
|
+
variant: "text",
|
|
28044
|
+
disabled,
|
|
28045
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
28046
|
+
children: [
|
|
28047
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.NumberIcon, { "aria-hidden": "true" }),
|
|
28048
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
28049
|
+
className: "univer-flex-1 univer-text-start",
|
|
28050
|
+
children: localeService.t("docs-ui.headerFooter.pageNumber")
|
|
28051
|
+
}),
|
|
28052
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { "aria-hidden": "true" })
|
|
28053
|
+
]
|
|
28054
|
+
})
|
|
28055
|
+
}),
|
|
28056
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
|
|
28057
|
+
className: "univer-justify-start",
|
|
28058
|
+
"data-u-command": InsertHeaderFooterFieldCommand.id,
|
|
28059
|
+
size: "small",
|
|
28060
|
+
variant: "text",
|
|
28061
|
+
disabled,
|
|
28062
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
28063
|
+
onClick: openDateTime,
|
|
28064
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CalendarIcon, { "aria-hidden": "true" }), localeService.t("docs-ui.headerFooter.dateTime")]
|
|
28065
|
+
}),
|
|
28066
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dialog, {
|
|
28067
|
+
open: dialogOpen,
|
|
28068
|
+
width: 360,
|
|
28069
|
+
title: localeService.t("docs-ui.headerFooter.dateTime"),
|
|
28070
|
+
showOk: true,
|
|
28071
|
+
showCancel: true,
|
|
28072
|
+
onClose: () => setTarget(null),
|
|
28073
|
+
onCancel: () => setTarget(null),
|
|
28074
|
+
onOk: insertDateTime,
|
|
28075
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
28076
|
+
className: "univer-flex univer-flex-col univer-gap-4",
|
|
28077
|
+
children: [
|
|
28078
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
|
|
28079
|
+
align: "start",
|
|
28080
|
+
className: "univer-w-[--radix-popper-anchor-width]",
|
|
28081
|
+
items: [{
|
|
28082
|
+
type: "radio",
|
|
28083
|
+
value: format,
|
|
28084
|
+
hideIndicator: true,
|
|
28085
|
+
onSelect: (value) => setFormat(value),
|
|
28086
|
+
options: [
|
|
28087
|
+
"short",
|
|
28088
|
+
"long",
|
|
28089
|
+
"time"
|
|
28090
|
+
].map((value) => ({
|
|
28091
|
+
value,
|
|
28092
|
+
label: createDateTimeField(value, locale, previewDate).cachedResult
|
|
28093
|
+
}))
|
|
28094
|
+
}],
|
|
28095
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
|
|
28096
|
+
"aria-label": localeService.t("docs-ui.headerFooter.dateTime"),
|
|
28097
|
+
className: _univerjs_design.selectClassName,
|
|
28098
|
+
"data-u-comp": "select",
|
|
28099
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
28100
|
+
className: "univer-flex-1 univer-truncate univer-text-start",
|
|
28101
|
+
children: createDateTimeField(format, locale, previewDate).cachedResult
|
|
28102
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { "aria-hidden": "true" })]
|
|
28103
|
+
})
|
|
28104
|
+
}),
|
|
28105
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
28106
|
+
checked: automatic,
|
|
28107
|
+
onChange: (value) => setAutomatic(Boolean(value)),
|
|
28108
|
+
children: localeService.t("docs-ui.headerFooter.updateAutomatically")
|
|
28109
|
+
}),
|
|
28110
|
+
error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
28111
|
+
role: "alert",
|
|
28112
|
+
children: localeService.t("docs-ui.headerFooter.insertFailed")
|
|
28113
|
+
})
|
|
28114
|
+
]
|
|
28115
|
+
})
|
|
28116
|
+
})
|
|
28117
|
+
]
|
|
28118
|
+
});
|
|
28119
|
+
}
|
|
28120
|
+
|
|
28121
|
+
//#endregion
|
|
28122
|
+
//#region src/views/header-footer/panel/DocHeaderFooterRibbonControl.tsx
|
|
28123
|
+
function DocHeaderFooterRibbonControl(props) {
|
|
28124
|
+
const instances = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
28125
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
28126
|
+
(0, _univerjs_ui.useObservable)(localeService.currentLocale$);
|
|
28127
|
+
const document = (0, _univerjs_ui.useObservable)(() => instances.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC), void 0, false, [instances]);
|
|
28128
|
+
const containerRef = (0, react.useRef)(null);
|
|
28129
|
+
const [compact, setCompact] = (0, react.useState)(false);
|
|
28130
|
+
const { kind } = props;
|
|
28131
|
+
(0, react.useEffect)(() => {
|
|
28132
|
+
var _containerRef$current;
|
|
28133
|
+
const toolbar = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.closest("[role=\"toolbar\"]");
|
|
28134
|
+
if (!toolbar || kind === "insertion") return;
|
|
28135
|
+
const thresholds = {
|
|
28136
|
+
position: 1100,
|
|
28137
|
+
options: 900,
|
|
28138
|
+
navigation: 650
|
|
28139
|
+
};
|
|
28140
|
+
const resize = () => setCompact(toolbar.getBoundingClientRect().width < thresholds[kind]);
|
|
28141
|
+
const observer = new ResizeObserver(resize);
|
|
28142
|
+
observer.observe(toolbar);
|
|
28143
|
+
return () => observer.disconnect();
|
|
28144
|
+
}, [kind, document]);
|
|
28145
|
+
if (!document) return null;
|
|
28146
|
+
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HeaderFooterRibbonControl, {
|
|
28147
|
+
...props,
|
|
28148
|
+
unitId: document.getUnitId()
|
|
28149
|
+
}, document.getUnitId());
|
|
28150
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
28151
|
+
ref: containerRef,
|
|
28152
|
+
"data-u-command": OpenHeaderFooterPanelCommand.id,
|
|
28153
|
+
className: "univer-flex univer-items-center univer-whitespace-nowrap",
|
|
28154
|
+
children: compact && kind !== "insertion" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
|
|
28155
|
+
items: [{
|
|
28156
|
+
type: "custom",
|
|
28157
|
+
className: "univer-p-2",
|
|
28158
|
+
children: content
|
|
28159
|
+
}],
|
|
28160
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
28161
|
+
"data-u-command": OpenHeaderFooterPanelCommand.id,
|
|
28162
|
+
size: "small",
|
|
28163
|
+
variant: "text",
|
|
28164
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
28165
|
+
children: localeService.t(`docs-ui.headerFooter.${kind}`)
|
|
28166
|
+
})
|
|
28167
|
+
}) : content
|
|
28168
|
+
});
|
|
28169
|
+
}
|
|
28170
|
+
function HeaderFooterRibbonControl({ kind, unitId }) {
|
|
28171
|
+
var _instances$getUnit, _renders$getRenderUni;
|
|
28172
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
28173
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
28174
|
+
const renders = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
|
|
28175
|
+
const permissionService = (0, _univerjs_ui.useDependency)(_univerjs_core.IPermissionService);
|
|
28176
|
+
(0, _univerjs_ui.useObservable)(permissionService.permissionPointUpdate$);
|
|
28177
|
+
const instances = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
28178
|
+
const disabled = Boolean((_instances$getUnit = instances.getUnit(unitId)) === null || _instances$getUnit === void 0 ? void 0 : _instances$getUnit.getSnapshot().disabled) || !(0, _univerjs_docs.getDocumentPermissionValue)(permissionService, unitId, unitId, _univerjs_protocol.UnitAction.Edit);
|
|
28179
|
+
const { canLinkToPrevious, linkedToPrevious, options, handleLinkToPreviousChange, handleCheckboxChange, handleMarginChange } = useHeaderFooterOptions(unitId);
|
|
28180
|
+
const area = (_renders$getRenderUni = renders.getRenderUnitById(unitId)) === null || _renders$getRenderUni === void 0 ? void 0 : _renders$getRenderUni.with(_univerjs_docs.DocSkeletonManagerService).getViewModel().getEditArea();
|
|
28181
|
+
if (kind === "insertion") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocHeaderFooterFields, {
|
|
28182
|
+
unitId,
|
|
28183
|
+
disabled
|
|
28184
|
+
});
|
|
28185
|
+
if (kind === "navigation") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
28186
|
+
className: "univer-grid univer-grid-cols-[auto_auto] univer-items-center univer-gap-x-2 univer-gap-y-1 univer-text-start univer-text-xs",
|
|
28187
|
+
children: [
|
|
28188
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
28189
|
+
"data-u-command": OpenHeaderFooterPanelCommand.id,
|
|
28190
|
+
size: "small",
|
|
28191
|
+
variant: "text",
|
|
28192
|
+
disabled: disabled || area === _univerjs_engine_render.DocumentEditArea.HEADER,
|
|
28193
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
28194
|
+
onClick: () => commandService.executeCommand(OpenHeaderFooterPanelCommand.id, { editArea: _univerjs_engine_render.DocumentEditArea.HEADER }),
|
|
28195
|
+
children: localeService.t("docs-ui.headerFooter.goToHeader")
|
|
28196
|
+
}),
|
|
28197
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
28198
|
+
disabled: disabled || !canLinkToPrevious,
|
|
28199
|
+
checked: linkedToPrevious,
|
|
28200
|
+
onChange: (value) => handleLinkToPreviousChange(Boolean(value)),
|
|
28201
|
+
children: localeService.t("docs-ui.headerFooter.linkToPrevious")
|
|
28202
|
+
}),
|
|
28203
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
28204
|
+
"data-u-command": OpenHeaderFooterPanelCommand.id,
|
|
28205
|
+
size: "small",
|
|
28206
|
+
variant: "text",
|
|
28207
|
+
disabled: disabled || area === _univerjs_engine_render.DocumentEditArea.FOOTER,
|
|
28208
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
28209
|
+
onClick: () => commandService.executeCommand(OpenHeaderFooterPanelCommand.id, { editArea: _univerjs_engine_render.DocumentEditArea.FOOTER }),
|
|
28210
|
+
children: localeService.t("docs-ui.headerFooter.goToFooter")
|
|
28211
|
+
})
|
|
28212
|
+
]
|
|
28213
|
+
});
|
|
28214
|
+
if (kind === "options") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
28215
|
+
className: "univer-flex univer-flex-col univer-gap-2 univer-text-start univer-text-xs",
|
|
28216
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
28217
|
+
disabled,
|
|
28218
|
+
checked: options.useFirstPageHeaderFooter === _univerjs_core.BooleanNumber.TRUE,
|
|
28219
|
+
onChange: (value) => handleCheckboxChange(Boolean(value), "useFirstPageHeaderFooter"),
|
|
28220
|
+
children: localeService.t("docs-ui.headerFooter.firstPageCheckBox")
|
|
28221
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
28222
|
+
disabled,
|
|
28223
|
+
checked: options.evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE,
|
|
28224
|
+
onChange: (value) => handleCheckboxChange(Boolean(value), "evenAndOddHeaders"),
|
|
28225
|
+
children: localeService.t("docs-ui.headerFooter.oddEvenCheckBox")
|
|
28226
|
+
})]
|
|
28227
|
+
});
|
|
28228
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
28229
|
+
className: "univer-flex univer-flex-col univer-gap-1 univer-text-start univer-text-xs",
|
|
28230
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
28231
|
+
className: "univer-grid univer-grid-cols-[1fr_5rem] univer-items-center univer-gap-x-2",
|
|
28232
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("docs-ui.headerFooter.headerTopMargin") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
28233
|
+
disabled,
|
|
28234
|
+
min: 0,
|
|
28235
|
+
max: 200,
|
|
28236
|
+
precision: 1,
|
|
28237
|
+
value: options.marginHeader,
|
|
28238
|
+
onChange: (value) => handleMarginChange(value ?? 0, "marginHeader")
|
|
28239
|
+
})]
|
|
28240
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
28241
|
+
className: "univer-grid univer-grid-cols-[1fr_5rem] univer-items-center univer-gap-x-2",
|
|
28242
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("docs-ui.headerFooter.footerBottomMargin") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
28243
|
+
disabled,
|
|
28244
|
+
min: 0,
|
|
28245
|
+
max: 200,
|
|
28246
|
+
precision: 1,
|
|
28247
|
+
value: options.marginFooter,
|
|
28248
|
+
onChange: (value) => handleMarginChange(value ?? 0, "marginFooter")
|
|
28249
|
+
})]
|
|
28250
|
+
})]
|
|
28251
|
+
});
|
|
28252
|
+
}
|
|
28253
|
+
|
|
27438
28254
|
//#endregion
|
|
27439
28255
|
//#region src/views/paragraph-menu/component-keys.ts
|
|
27440
28256
|
/**
|
|
@@ -29230,6 +30046,7 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
29230
30046
|
BoldIcon: _univerjs_icons.BoldIcon,
|
|
29231
30047
|
CopyDoubleIcon: _univerjs_icons.CopyDoubleIcon,
|
|
29232
30048
|
ColumnIcon: _univerjs_icons.ColumnIcon,
|
|
30049
|
+
CloseIcon: _univerjs_icons.CloseIcon,
|
|
29233
30050
|
CutIcon: _univerjs_icons.CutIcon,
|
|
29234
30051
|
DeleteColumnDoubleIcon: _univerjs_icons.DeleteColumnDoubleIcon,
|
|
29235
30052
|
DeleteIcon: _univerjs_icons.DeleteIcon,
|
|
@@ -29308,7 +30125,8 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
29308
30125
|
}));
|
|
29309
30126
|
}
|
|
29310
30127
|
_registerComponents() {
|
|
29311
|
-
|
|
30128
|
+
this.disposeWithMe(this._componentManager.register(DOC_HEADER_FOOTER_RIBBON_CONTROL, DocHeaderFooterRibbonControl));
|
|
30129
|
+
if (!this._componentManager.hasDefault("COMPONENT_DOC_HEADER_FOOTER_PANEL")) this.disposeWithMe(this._componentManager.register(COMPONENT_DOC_HEADER_FOOTER_PANEL, DocHeaderFooterPanel));
|
|
29312
30130
|
this.disposeWithMe(this._componentManager.register(paragraphSettingIndexKey, ParagraphSettingIndex));
|
|
29313
30131
|
this.disposeWithMe(this._componentManager.register(DOC_SECTION_SETTING_COMPONENT, SectionSettingIndex));
|
|
29314
30132
|
[
|
|
@@ -29326,6 +30144,43 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
29326
30144
|
};
|
|
29327
30145
|
ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
|
|
29328
30146
|
|
|
30147
|
+
//#endregion
|
|
30148
|
+
//#region src/controllers/doc-header-footer-ribbon.controller.ts
|
|
30149
|
+
let DocHeaderFooterRibbonController = class DocHeaderFooterRibbonController extends _univerjs_core.Disposable {
|
|
30150
|
+
constructor(_context, skeletonManager, _instanceService, _ribbonService, _renderManager) {
|
|
30151
|
+
super();
|
|
30152
|
+
this._context = _context;
|
|
30153
|
+
this._instanceService = _instanceService;
|
|
30154
|
+
this._ribbonService = _ribbonService;
|
|
30155
|
+
this._renderManager = _renderManager;
|
|
30156
|
+
_defineProperty(this, "_visible", false);
|
|
30157
|
+
this.disposeWithMe((0, rxjs.combineLatest)([skeletonManager.getViewModel().editAreaChange$, this._instanceService.focused$]).pipe((0, rxjs.map)(([area, focused]) => focused === this._context.unitId && this._context.unit.getDocumentStyle().documentFlavor === _univerjs_core.DocumentFlavor.TRADITIONAL && (area === _univerjs_engine_render.DocumentEditArea.HEADER || area === _univerjs_engine_render.DocumentEditArea.FOOTER)), (0, rxjs.distinctUntilChanged)()).subscribe((visible) => {
|
|
30158
|
+
if (visible === this._visible) return;
|
|
30159
|
+
this._visible = visible;
|
|
30160
|
+
if (visible) this._ribbonService.showContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB, { activate: true });
|
|
30161
|
+
else if (!this._focusedDocumentEditsHeaderFooter()) this._ribbonService.hideContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB);
|
|
30162
|
+
}));
|
|
30163
|
+
}
|
|
30164
|
+
_focusedDocumentEditsHeaderFooter() {
|
|
30165
|
+
var _this$_renderManager$;
|
|
30166
|
+
const focused = this._instanceService.getFocusedUnit();
|
|
30167
|
+
if (!focused || focused.type !== _univerjs_core.UniverInstanceType.UNIVER_DOC || focused.getUnitId() === this._context.unitId) return false;
|
|
30168
|
+
const manager = (_this$_renderManager$ = this._renderManager.getRenderUnitById(focused.getUnitId())) === null || _this$_renderManager$ === void 0 ? void 0 : _this$_renderManager$.with(_univerjs_docs.DocSkeletonManagerService);
|
|
30169
|
+
const area = manager === null || manager === void 0 ? void 0 : manager.getViewModel().getEditArea();
|
|
30170
|
+
return (area === _univerjs_engine_render.DocumentEditArea.HEADER || area === _univerjs_engine_render.DocumentEditArea.FOOTER) && (manager === null || manager === void 0 ? void 0 : manager.getViewModel().getDataModel().getDocumentStyle().documentFlavor) === _univerjs_core.DocumentFlavor.TRADITIONAL;
|
|
30171
|
+
}
|
|
30172
|
+
dispose() {
|
|
30173
|
+
if (this._visible && !this._focusedDocumentEditsHeaderFooter()) this._ribbonService.hideContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB);
|
|
30174
|
+
super.dispose();
|
|
30175
|
+
}
|
|
30176
|
+
};
|
|
30177
|
+
DocHeaderFooterRibbonController = __decorate([
|
|
30178
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_docs.DocSkeletonManagerService)),
|
|
30179
|
+
__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
30180
|
+
__decorateParam(3, _univerjs_ui.IRibbonService),
|
|
30181
|
+
__decorateParam(4, _univerjs_engine_render.IRenderManagerService)
|
|
30182
|
+
], DocHeaderFooterRibbonController);
|
|
30183
|
+
|
|
29329
30184
|
//#endregion
|
|
29330
30185
|
//#region src/controllers/format-painter.controller.ts
|
|
29331
30186
|
let DocFormatPainterController = class DocFormatPainterController extends _univerjs_core.Disposable {
|
|
@@ -29393,6 +30248,83 @@ DocFormatPainterController = __decorate([
|
|
|
29393
30248
|
__decorateParam(7, _univerjs_core.ICommandService)
|
|
29394
30249
|
], DocFormatPainterController);
|
|
29395
30250
|
|
|
30251
|
+
//#endregion
|
|
30252
|
+
//#region src/controllers/render-controllers/doc-field.render-controller.ts
|
|
30253
|
+
let DocFieldRenderController = class DocFieldRenderController extends _univerjs_core.Disposable {
|
|
30254
|
+
constructor(_context, _events, _selections, theme, _instances) {
|
|
30255
|
+
super();
|
|
30256
|
+
this._context = _context;
|
|
30257
|
+
this._events = _events;
|
|
30258
|
+
this._selections = _selections;
|
|
30259
|
+
this._instances = _instances;
|
|
30260
|
+
_defineProperty(this, "_hovered", /* @__PURE__ */ new Set());
|
|
30261
|
+
_defineProperty(this, "_shade", "");
|
|
30262
|
+
const documents = this._context.mainComponent;
|
|
30263
|
+
this.disposeWithMe(theme.currentTheme$.subscribe(() => {
|
|
30264
|
+
this._shade = theme.getColorFromTheme("gray.200");
|
|
30265
|
+
documents.makeDirty(true);
|
|
30266
|
+
}));
|
|
30267
|
+
this.disposeWithMe(this._events.hoverCustomRanges$.subscribe((ranges) => {
|
|
30268
|
+
this._hovered = new Set(ranges.filter(({ range }) => range.rangeType === _univerjs_core.CustomRangeType.FIELD).map(({ range, segmentId, segmentPageIndex }) => `${segmentId ?? ""}:${segmentPageIndex}:${range.rangeId}`));
|
|
30269
|
+
documents.makeDirty(true);
|
|
30270
|
+
}));
|
|
30271
|
+
this.disposeWithMe(this._selections.textSelection$.subscribe(({ unitId }) => {
|
|
30272
|
+
if (unitId === this._context.unitId) documents.makeDirty(true);
|
|
30273
|
+
}));
|
|
30274
|
+
this.disposeWithMe(this._instances.focused$.subscribe(() => documents.makeDirty(true)));
|
|
30275
|
+
this.disposeWithMe(documents.getSkeleton().getViewModel().editAreaChange$.subscribe(() => documents.makeDirty(true)));
|
|
30276
|
+
this.disposeWithMe(documents.pageRender$.subscribe((config) => this._drawFields(config)));
|
|
30277
|
+
}
|
|
30278
|
+
_drawFields({ page, pageLeft, pageTop, ctx }) {
|
|
30279
|
+
var _this$_instances$getF;
|
|
30280
|
+
if (((_this$_instances$getF = this._instances.getFocusedUnit()) === null || _this$_instances$getF === void 0 ? void 0 : _this$_instances$getF.getUnitId()) !== this._context.unitId) return;
|
|
30281
|
+
const active = this._getActiveFields();
|
|
30282
|
+
if (!active.size) return;
|
|
30283
|
+
const documents = this._context.mainComponent;
|
|
30284
|
+
const skeleton = documents.getSkeleton();
|
|
30285
|
+
const pageIndex = skeleton.getSkeletonData().pages.indexOf(page);
|
|
30286
|
+
const { docsLeft, docsTop } = documents.getOffsetConfig();
|
|
30287
|
+
const area = skeleton.getViewModel().getEditArea();
|
|
30288
|
+
const snapshot = this._context.unit.getSnapshot();
|
|
30289
|
+
const activeSegments = area === _univerjs_engine_render.DocumentEditArea.HEADER ? snapshot.headers : snapshot.footers;
|
|
30290
|
+
ctx.save();
|
|
30291
|
+
ctx.beginPath();
|
|
30292
|
+
ctx.rect(pageLeft, pageTop, page.pageWidth, page.pageHeight);
|
|
30293
|
+
ctx.clip();
|
|
30294
|
+
ctx.fillStyle = this._shade;
|
|
30295
|
+
ctx.globalAlpha *= .45;
|
|
30296
|
+
for (const { customRange: field, segmentId, segmentPageIndex, rects } of this._events.getCustomRangeBounds()) {
|
|
30297
|
+
if (field.rangeType !== _univerjs_core.CustomRangeType.FIELD) continue;
|
|
30298
|
+
if (segmentId) {
|
|
30299
|
+
if (area === _univerjs_engine_render.DocumentEditArea.BODY || segmentPageIndex !== pageIndex || !(activeSegments === null || activeSegments === void 0 ? void 0 : activeSegments[segmentId])) continue;
|
|
30300
|
+
} else if (area !== _univerjs_engine_render.DocumentEditArea.BODY) continue;
|
|
30301
|
+
if (!active.has(`${segmentId ?? ""}:${segmentPageIndex}:${field.rangeId}`)) continue;
|
|
30302
|
+
for (const rect of rects) ctx.fillRect(rect.left - docsLeft, rect.top - docsTop, rect.right - rect.left, rect.bottom - rect.top);
|
|
30303
|
+
}
|
|
30304
|
+
ctx.restore();
|
|
30305
|
+
}
|
|
30306
|
+
_getActiveFields() {
|
|
30307
|
+
const active = new Set(this._hovered);
|
|
30308
|
+
const selections = this._selections.getTextRanges({
|
|
30309
|
+
unitId: this._context.unitId,
|
|
30310
|
+
subUnitId: this._context.unitId
|
|
30311
|
+
}) ?? [];
|
|
30312
|
+
for (const selection of selections) {
|
|
30313
|
+
var _this$_context$unit$g;
|
|
30314
|
+
const segmentId = selection.segmentId ?? "";
|
|
30315
|
+
const fields = ((_this$_context$unit$g = this._context.unit.getSelfOrHeaderFooterModel(segmentId)) === null || _this$_context$unit$g === void 0 || (_this$_context$unit$g = _this$_context$unit$g.getBody()) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.customRanges) ?? [];
|
|
30316
|
+
for (const field of fields) if (field.rangeType === _univerjs_core.CustomRangeType.FIELD && selection.startOffset <= field.endIndex && selection.endOffset > field.startIndex) active.add(`${segmentId}:${segmentId ? selection.segmentPage : -1}:${field.rangeId}`);
|
|
30317
|
+
}
|
|
30318
|
+
return active;
|
|
30319
|
+
}
|
|
30320
|
+
};
|
|
30321
|
+
DocFieldRenderController = __decorate([
|
|
30322
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(DocEventManagerService)),
|
|
30323
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService)),
|
|
30324
|
+
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.ThemeService)),
|
|
30325
|
+
__decorateParam(4, _univerjs_core.IUniverInstanceService)
|
|
30326
|
+
], DocFieldRenderController);
|
|
30327
|
+
|
|
29396
30328
|
//#endregion
|
|
29397
30329
|
//#region src/controllers/render-controllers/doc-selection-render.controller.ts
|
|
29398
30330
|
let DocSelectionRenderController = class DocSelectionRenderController extends _univerjs_core.Disposable {
|
|
@@ -29717,6 +30649,32 @@ const CloseHeaderFooterShortcut = {
|
|
|
29717
30649
|
preconditions: whenDocAndEditorFocused,
|
|
29718
30650
|
binding: _univerjs_ui.KeyCode.ESC
|
|
29719
30651
|
};
|
|
30652
|
+
const DeleteWordLeftShortcut = {
|
|
30653
|
+
id: DeleteLeftCommand.id,
|
|
30654
|
+
preconditions: whenTextEditorFocused,
|
|
30655
|
+
binding: _univerjs_ui.KeyCode.BACKSPACE | _univerjs_ui.MetaKeys.CTRL_COMMAND,
|
|
30656
|
+
mac: _univerjs_ui.KeyCode.BACKSPACE | _univerjs_ui.MetaKeys.ALT,
|
|
30657
|
+
staticParameters: { granularity: "word" }
|
|
30658
|
+
};
|
|
30659
|
+
const DeleteWordRightShortcut = {
|
|
30660
|
+
id: DeleteRightCommand.id,
|
|
30661
|
+
preconditions: whenTextEditorFocused,
|
|
30662
|
+
mac: _univerjs_ui.KeyCode.DELETE | _univerjs_ui.MetaKeys.ALT,
|
|
30663
|
+
staticParameters: { granularity: "word" }
|
|
30664
|
+
};
|
|
30665
|
+
const DeleteLineStartShortcut = {
|
|
30666
|
+
id: DeleteLeftCommand.id,
|
|
30667
|
+
preconditions: whenTextEditorFocused,
|
|
30668
|
+
mac: _univerjs_ui.KeyCode.BACKSPACE | _univerjs_ui.MetaKeys.CTRL_COMMAND,
|
|
30669
|
+
staticParameters: { granularity: "line" }
|
|
30670
|
+
};
|
|
30671
|
+
const DeleteLineEndShortcut = {
|
|
30672
|
+
id: DeleteRightCommand.id,
|
|
30673
|
+
preconditions: whenTextEditorFocused,
|
|
30674
|
+
binding: _univerjs_ui.KeyCode.DELETE | _univerjs_ui.MetaKeys.CTRL_COMMAND,
|
|
30675
|
+
mac: _univerjs_ui.KeyCode.DELETE | _univerjs_ui.MetaKeys.MAC_CTRL,
|
|
30676
|
+
staticParameters: { granularity: "line" }
|
|
30677
|
+
};
|
|
29720
30678
|
|
|
29721
30679
|
//#endregion
|
|
29722
30680
|
//#region src/shortcuts/cursor.shortcut.ts
|
|
@@ -29727,7 +30685,7 @@ function moveCursorShortcut(direction, granularity, binding, mac = binding, win
|
|
|
29727
30685
|
mac,
|
|
29728
30686
|
win,
|
|
29729
30687
|
linux,
|
|
29730
|
-
preconditions:
|
|
30688
|
+
preconditions: whenTextEditorFocused,
|
|
29731
30689
|
staticParameters: {
|
|
29732
30690
|
direction,
|
|
29733
30691
|
granularity
|
|
@@ -29741,7 +30699,7 @@ function moveSelectionShortcut(direction, granularity, binding, mac = binding, w
|
|
|
29741
30699
|
mac,
|
|
29742
30700
|
win,
|
|
29743
30701
|
linux,
|
|
29744
|
-
preconditions:
|
|
30702
|
+
preconditions: whenTextEditorFocused,
|
|
29745
30703
|
staticParameters: {
|
|
29746
30704
|
direction,
|
|
29747
30705
|
granularity
|
|
@@ -30004,6 +30962,10 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
30004
30962
|
MoveSelectionWordRightShortcut,
|
|
30005
30963
|
SelectAllShortcut,
|
|
30006
30964
|
DeleteLeftShortcut,
|
|
30965
|
+
DeleteWordLeftShortcut,
|
|
30966
|
+
DeleteWordRightShortcut,
|
|
30967
|
+
DeleteLineStartShortcut,
|
|
30968
|
+
DeleteLineEndShortcut,
|
|
30007
30969
|
DeleteRightShortcut,
|
|
30008
30970
|
CloseHeaderFooterShortcut,
|
|
30009
30971
|
BreakLineShortcut,
|
|
@@ -30080,10 +31042,12 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
30080
31042
|
_initRenderModules() {
|
|
30081
31043
|
[
|
|
30082
31044
|
[DocEventManagerService],
|
|
31045
|
+
[DocFieldRenderController],
|
|
30083
31046
|
[DocFloatMenuService],
|
|
30084
31047
|
[DocPasteOptionsRenderController],
|
|
30085
31048
|
[DocParagraphMenuService],
|
|
30086
31049
|
[DocHeaderFooterController],
|
|
31050
|
+
[DocHeaderFooterRibbonController],
|
|
30087
31051
|
[DocResizeRenderController],
|
|
30088
31052
|
[DocParagraphPlaceholderRenderController],
|
|
30089
31053
|
[DocContextMenuRenderController],
|
|
@@ -31458,6 +32422,7 @@ exports.getCursorWhenDelete = getCursorWhenDelete;
|
|
|
31458
32422
|
exports.getCutActionsFromDocRanges = getCutActionsFromDocRanges;
|
|
31459
32423
|
exports.getDocBlockRangeMenuId = getDocBlockRangeMenuId;
|
|
31460
32424
|
exports.getDocObjectById = getDocObjectById;
|
|
32425
|
+
exports.getEditorRuntimeConfig = getEditorRuntimeConfig;
|
|
31461
32426
|
exports.getEmptyTableCell = getEmptyTableCell;
|
|
31462
32427
|
exports.getEmptyTableRow = getEmptyTableRow;
|
|
31463
32428
|
exports.getLineBounding = getLineBounding;
|
|
@@ -31474,6 +32439,7 @@ exports.isTextRangeInAnyBlockRange = isTextRangeInAnyBlockRange;
|
|
|
31474
32439
|
exports.isValidRectRange = isValidRectRange;
|
|
31475
32440
|
exports.neoGetDocObject = neoGetDocObject;
|
|
31476
32441
|
exports.normalizeDocFitToWidthOptions = normalizeDocFitToWidthOptions;
|
|
32442
|
+
exports.registerEditorRuntimeConfig = registerEditorRuntimeConfig;
|
|
31477
32443
|
exports.removeClipboardHtmlImages = removeClipboardHtmlImages;
|
|
31478
32444
|
exports.resolveDocCustomRangeChromeTheme = resolveDocCustomRangeChromeTheme;
|
|
31479
32445
|
exports.resolveDocFitBaseWidth = resolveDocFitBaseWidth;
|