@univerjs/docs-ui 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1600 -475
- package/lib/cjs/locale/ar-SA.js +14 -0
- package/lib/cjs/locale/ca-ES.js +14 -0
- package/lib/cjs/locale/de-DE.js +14 -0
- package/lib/cjs/locale/en-US.js +14 -0
- package/lib/cjs/locale/es-ES.js +14 -0
- package/lib/cjs/locale/fa-IR.js +14 -0
- package/lib/cjs/locale/fr-FR.js +14 -0
- package/lib/cjs/locale/id-ID.js +14 -0
- package/lib/cjs/locale/it-IT.js +14 -0
- package/lib/cjs/locale/ja-JP.js +14 -0
- package/lib/cjs/locale/ko-KR.js +14 -0
- package/lib/cjs/locale/pl-PL.js +14 -0
- package/lib/cjs/locale/pt-BR.js +14 -0
- package/lib/cjs/locale/ru-RU.js +14 -0
- package/lib/cjs/locale/sk-SK.js +14 -0
- package/lib/cjs/locale/vi-VN.js +14 -0
- package/lib/cjs/locale/zh-CN.js +14 -0
- package/lib/cjs/locale/zh-HK.js +14 -0
- package/lib/cjs/locale/zh-TW.js +14 -0
- package/lib/es/index.js +1585 -466
- package/lib/es/locale/ar-SA.js +14 -0
- package/lib/es/locale/ca-ES.js +14 -0
- package/lib/es/locale/de-DE.js +14 -0
- package/lib/es/locale/en-US.js +14 -0
- package/lib/es/locale/es-ES.js +14 -0
- package/lib/es/locale/fa-IR.js +14 -0
- package/lib/es/locale/fr-FR.js +14 -0
- package/lib/es/locale/id-ID.js +14 -0
- package/lib/es/locale/it-IT.js +14 -0
- package/lib/es/locale/ja-JP.js +14 -0
- package/lib/es/locale/ko-KR.js +14 -0
- package/lib/es/locale/pl-PL.js +14 -0
- package/lib/es/locale/pt-BR.js +14 -0
- package/lib/es/locale/ru-RU.js +14 -0
- package/lib/es/locale/sk-SK.js +14 -0
- package/lib/es/locale/vi-VN.js +14 -0
- package/lib/es/locale/zh-CN.js +14 -0
- package/lib/es/locale/zh-HK.js +14 -0
- package/lib/es/locale/zh-TW.js +14 -0
- package/lib/index.css +26 -4
- package/lib/index.js +1585 -466
- package/lib/locale/ar-SA.js +14 -0
- package/lib/locale/ca-ES.js +14 -0
- package/lib/locale/de-DE.js +14 -0
- package/lib/locale/en-US.js +14 -0
- package/lib/locale/es-ES.js +14 -0
- package/lib/locale/fa-IR.js +14 -0
- package/lib/locale/fr-FR.js +14 -0
- package/lib/locale/id-ID.js +14 -0
- package/lib/locale/it-IT.js +14 -0
- package/lib/locale/ja-JP.js +14 -0
- package/lib/locale/ko-KR.js +14 -0
- package/lib/locale/pl-PL.js +14 -0
- package/lib/locale/pt-BR.js +14 -0
- package/lib/locale/ru-RU.js +14 -0
- package/lib/locale/sk-SK.js +14 -0
- package/lib/locale/vi-VN.js +14 -0
- package/lib/locale/zh-CN.js +14 -0
- package/lib/locale/zh-HK.js +14 -0
- package/lib/locale/zh-TW.js +14 -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 +14 -0
- package/lib/types/menu/display.menu.d.ts +21 -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/doc-paragraph-menu.service.d.ts +11 -2
- package/lib/types/services/doc-zoom.d.ts +4 -1
- package/lib/types/services/selection/doc-selection-render.service.d.ts +2 -0
- 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/facade.js +1 -1
- package/lib/umd/index.js +16 -15
- 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 +13 -13
package/lib/cjs/index.js
CHANGED
|
@@ -270,7 +270,7 @@ function getCustomDecorationAtPosition(customDecorations, position) {
|
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
//#endregion
|
|
273
|
-
//#region \0@oxc-project+runtime@0.
|
|
273
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
274
274
|
function _typeof(o) {
|
|
275
275
|
"@babel/helpers - typeof";
|
|
276
276
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -281,7 +281,7 @@ function _typeof(o) {
|
|
|
281
281
|
}
|
|
282
282
|
|
|
283
283
|
//#endregion
|
|
284
|
-
//#region \0@oxc-project+runtime@0.
|
|
284
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
285
285
|
function toPrimitive(t, r) {
|
|
286
286
|
if ("object" != _typeof(t) || !t) return t;
|
|
287
287
|
var e = t[Symbol.toPrimitive];
|
|
@@ -294,14 +294,14 @@ function toPrimitive(t, r) {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
//#endregion
|
|
297
|
-
//#region \0@oxc-project+runtime@0.
|
|
297
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
298
298
|
function toPropertyKey(t) {
|
|
299
299
|
var i = toPrimitive(t, "string");
|
|
300
300
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
//#endregion
|
|
304
|
-
//#region \0@oxc-project+runtime@0.
|
|
304
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
305
305
|
function _defineProperty(e, r, t) {
|
|
306
306
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
307
307
|
value: t,
|
|
@@ -312,7 +312,7 @@ function _defineProperty(e, r, t) {
|
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
//#endregion
|
|
315
|
-
//#region \0@oxc-project+runtime@0.
|
|
315
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
316
316
|
function __decorateParam(paramIndex, decorator) {
|
|
317
317
|
return function(target, key) {
|
|
318
318
|
decorator(target, key, paramIndex);
|
|
@@ -320,7 +320,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
//#endregion
|
|
323
|
-
//#region \0@oxc-project+runtime@0.
|
|
323
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
324
324
|
function __decorate(decorators, target, key, desc) {
|
|
325
325
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
326
326
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -436,8 +436,8 @@ let DocMenuStyleService = class DocMenuStyleService extends _univerjs_core.Dispo
|
|
|
436
436
|
}));
|
|
437
437
|
}
|
|
438
438
|
_listenDocRangeChange() {
|
|
439
|
-
this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(() => {
|
|
440
|
-
this._clearStyleCache();
|
|
439
|
+
this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(({ options }) => {
|
|
440
|
+
if (!(options === null || options === void 0 ? void 0 : options.preserveInputStyle)) this._clearStyleCache();
|
|
441
441
|
}));
|
|
442
442
|
}
|
|
443
443
|
getStyleCache() {
|
|
@@ -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)({
|
|
@@ -3197,6 +3197,20 @@ function getWordBoundaryByIndex(content, nodeIndex, paragraphStartOffset) {
|
|
|
3197
3197
|
endOffset: paragraphStartOffset + range.end
|
|
3198
3198
|
};
|
|
3199
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
|
+
}
|
|
3200
3214
|
function getNextWordBoundaryOffset(content, nodeIndex, paragraphStartOffset, direction) {
|
|
3201
3215
|
if (nodeIndex < 0) return null;
|
|
3202
3216
|
const ranges = getWordRanges(content);
|
|
@@ -3226,6 +3240,12 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
3226
3240
|
get isFocusing() {
|
|
3227
3241
|
return this._input === this._getOwnerDocument().activeElement;
|
|
3228
3242
|
}
|
|
3243
|
+
get inputElement() {
|
|
3244
|
+
return this._input;
|
|
3245
|
+
}
|
|
3246
|
+
get selectionContainer() {
|
|
3247
|
+
return this._container;
|
|
3248
|
+
}
|
|
3229
3249
|
get isEditing() {
|
|
3230
3250
|
var _this$_textSelectionI;
|
|
3231
3251
|
return ((_this$_textSelectionI = this._textSelectionInner$.value) === null || _this$_textSelectionI === void 0 ? void 0 : _this$_textSelectionI.isEditing) === true;
|
|
@@ -3359,15 +3379,13 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
3359
3379
|
this._selectionStyle = style;
|
|
3360
3380
|
}
|
|
3361
3381
|
replaceDocRanges(ranges, isEditing = true, options) {
|
|
3362
|
-
var _this$_context$unit$g;
|
|
3363
3382
|
if (this._onPointerEvent) {
|
|
3364
3383
|
this._pendingSelection = null;
|
|
3365
3384
|
return false;
|
|
3366
3385
|
}
|
|
3367
3386
|
this._syncNoteSegment(ranges[0]);
|
|
3368
|
-
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;
|
|
3369
3387
|
let currentLogicalSelection = null;
|
|
3370
|
-
if (
|
|
3388
|
+
if (ranges.length > 0) {
|
|
3371
3389
|
const { unitId } = this._context;
|
|
3372
3390
|
const selection = this._docSelectionManagerService.getSelectionInfo({
|
|
3373
3391
|
unitId,
|
|
@@ -3440,7 +3458,12 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
3440
3458
|
this._addRectRanges(rectRanges);
|
|
3441
3459
|
};
|
|
3442
3460
|
for (const range of ranges) {
|
|
3443
|
-
const {
|
|
3461
|
+
const { rangeType } = range;
|
|
3462
|
+
let { startOffset, endOffset, startNodePosition, endNodePosition } = range;
|
|
3463
|
+
if (rangeType !== _univerjs_core.DOC_RANGE_TYPE.RECT && range.direction === _univerjs_core.RANGE_DIRECTION.BACKWARD && startOffset < endOffset) {
|
|
3464
|
+
[startOffset, endOffset] = [endOffset, startOffset];
|
|
3465
|
+
[startNodePosition, endNodePosition] = [endNodePosition, startNodePosition];
|
|
3466
|
+
}
|
|
3444
3467
|
const rangeStyle = range.style ?? style;
|
|
3445
3468
|
if (rangeType !== _univerjs_core.DOC_RANGE_TYPE.RECT && startOffset === endOffset) {
|
|
3446
3469
|
const textRange = cursorConvertToTextRange(scene, {
|
|
@@ -3458,7 +3481,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
3458
3481
|
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);
|
|
3459
3482
|
else textRange = getTextRangeFromCharIndex(startOffset, endOffset, scene, document, docSkeleton, rangeStyle, segmentId, segmentPage);
|
|
3460
3483
|
if (textRange) this._addTextRange(textRange);
|
|
3461
|
-
} catch
|
|
3484
|
+
} catch {
|
|
3462
3485
|
generalAddRange(startOffset, endOffset, rangeStyle);
|
|
3463
3486
|
}
|
|
3464
3487
|
else generalAddRange(startOffset, endOffset, rangeStyle);
|
|
@@ -3548,7 +3571,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
3548
3571
|
if (paragraphInfo == null) return;
|
|
3549
3572
|
const { content, st, nodeIndex } = paragraphInfo;
|
|
3550
3573
|
if (nodeIndex === -1) return;
|
|
3551
|
-
const wordBoundary = getWordBoundaryByIndex(content, nodeIndex, st);
|
|
3574
|
+
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);
|
|
3552
3575
|
if (wordBoundary != null) {
|
|
3553
3576
|
this.removeAllRanges();
|
|
3554
3577
|
const textRanges = [{
|
|
@@ -4137,10 +4160,26 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
4137
4160
|
}));
|
|
4138
4161
|
}
|
|
4139
4162
|
_refreshMissingInputRange(config) {
|
|
4163
|
+
var _this$_context$unit$g;
|
|
4140
4164
|
if (config.activeRange == null) {
|
|
4141
4165
|
config.activeRange = this._getActiveRange();
|
|
4142
4166
|
config.rangeList = this._getAllTextRanges();
|
|
4143
4167
|
}
|
|
4168
|
+
const { unitId } = this._context;
|
|
4169
|
+
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;
|
|
4170
|
+
const selection = this._docSelectionManagerService.getSelectionInfo({
|
|
4171
|
+
unitId,
|
|
4172
|
+
subUnitId: unitId
|
|
4173
|
+
});
|
|
4174
|
+
if (selection == null || selection.textRanges.length !== 1 || selection.rectRanges.length > 0) return;
|
|
4175
|
+
const caret = selection.textRanges[0];
|
|
4176
|
+
if (!caret.isActive || caret.startOffset !== 0 || caret.endOffset !== 0) return;
|
|
4177
|
+
config.activeRange = {
|
|
4178
|
+
...caret,
|
|
4179
|
+
segmentId: selection.segmentId,
|
|
4180
|
+
segmentPage: selection.segmentPage
|
|
4181
|
+
};
|
|
4182
|
+
config.rangeList = [config.activeRange];
|
|
4144
4183
|
}
|
|
4145
4184
|
_handleInputFocus(event) {
|
|
4146
4185
|
this._eventHandle(event, (config) => {
|
|
@@ -5685,7 +5724,7 @@ const CutContentCommand = {
|
|
|
5685
5724
|
id: "doc.command.inner-cut",
|
|
5686
5725
|
type: _univerjs_core.CommandType.COMMAND,
|
|
5687
5726
|
handler: (accessor, params) => {
|
|
5688
|
-
var _selectionInfo$option3;
|
|
5727
|
+
var _selectionInfo$option3, _docDataModel$getSelf7;
|
|
5689
5728
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
5690
5729
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5691
5730
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
@@ -5705,12 +5744,19 @@ const CutContentCommand = {
|
|
|
5705
5744
|
const docSkeletonManagerService = getCommandSkeleton(accessor, unitId);
|
|
5706
5745
|
if (docSkeletonManagerService == null) return false;
|
|
5707
5746
|
const viewModel = docSkeletonManagerService.getViewModel();
|
|
5747
|
+
const body = (_docDataModel$getSelf7 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf7 === void 0 ? void 0 : _docDataModel$getSelf7.getBody();
|
|
5748
|
+
const clearsBody = wholeBodySelected || body != null && isWholeBodySelected(selections, rectRanges, body);
|
|
5708
5749
|
const doMutation = {
|
|
5709
5750
|
id: _univerjs_docs.RichTextEditingMutation.id,
|
|
5710
5751
|
params: {
|
|
5711
5752
|
unitId,
|
|
5712
5753
|
actions: [],
|
|
5713
|
-
textRanges
|
|
5754
|
+
textRanges: clearsBody ? [{
|
|
5755
|
+
...textRanges[0],
|
|
5756
|
+
startOffset: 0,
|
|
5757
|
+
endOffset: 0,
|
|
5758
|
+
collapsed: true
|
|
5759
|
+
}] : textRanges,
|
|
5714
5760
|
trigger: CutContentCommand.id
|
|
5715
5761
|
}
|
|
5716
5762
|
};
|
|
@@ -5727,6 +5773,31 @@ function isHorizontalLineParagraph(dataStream, paragraph) {
|
|
|
5727
5773
|
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;
|
|
5728
5774
|
}
|
|
5729
5775
|
|
|
5776
|
+
//#endregion
|
|
5777
|
+
//#region src/commands/operations/doc-cursor.operation.ts
|
|
5778
|
+
/**
|
|
5779
|
+
* The operation to move cursor in the current document.
|
|
5780
|
+
*/
|
|
5781
|
+
const MoveCursorOperation = {
|
|
5782
|
+
id: "doc.operation.move-cursor",
|
|
5783
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
5784
|
+
handler: (accessor, params) => {
|
|
5785
|
+
if (!params) return false;
|
|
5786
|
+
return true;
|
|
5787
|
+
}
|
|
5788
|
+
};
|
|
5789
|
+
/**
|
|
5790
|
+
* The operation to move selection in the current document.
|
|
5791
|
+
*/
|
|
5792
|
+
const MoveSelectionOperation = {
|
|
5793
|
+
id: "doc.operation.move-selection",
|
|
5794
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
5795
|
+
handler: (accessor, params) => {
|
|
5796
|
+
if (!params) return false;
|
|
5797
|
+
return true;
|
|
5798
|
+
}
|
|
5799
|
+
};
|
|
5800
|
+
|
|
5730
5801
|
//#endregion
|
|
5731
5802
|
//#region src/commands/commands/format-painter.command.ts
|
|
5732
5803
|
function captureTextFormat(body, range, defaultStyle = {}, lists = {}, document = { documentStyle: {} }) {
|
|
@@ -6140,11 +6211,25 @@ function isDeleteOffsetInsideBlockRange(body, offset) {
|
|
|
6140
6211
|
return interval.startOffset < offset && offset < interval.endOffset - 1;
|
|
6141
6212
|
})) ?? false;
|
|
6142
6213
|
}
|
|
6214
|
+
function selectDeleteBoundary(accessor, direction, granularity) {
|
|
6215
|
+
var _selections$getActive, _selections$getRectRa;
|
|
6216
|
+
const selections = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
6217
|
+
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)) {
|
|
6218
|
+
var _selections$getActive2;
|
|
6219
|
+
accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(MoveSelectionOperation.id, {
|
|
6220
|
+
direction,
|
|
6221
|
+
granularity
|
|
6222
|
+
});
|
|
6223
|
+
return ((_selections$getActive2 = selections.getActiveTextRange()) === null || _selections$getActive2 === void 0 ? void 0 : _selections$getActive2.collapsed) === false;
|
|
6224
|
+
}
|
|
6225
|
+
return true;
|
|
6226
|
+
}
|
|
6143
6227
|
const DeleteLeftCommand = {
|
|
6144
6228
|
id: "doc.command.delete-left",
|
|
6145
6229
|
type: _univerjs_core.CommandType.COMMAND,
|
|
6146
|
-
handler: async (accessor) => {
|
|
6230
|
+
handler: async (accessor, params) => {
|
|
6147
6231
|
var _docDataModel$getSelf3, _docDataModel$getSelf4;
|
|
6232
|
+
if ((params === null || params === void 0 ? void 0 : params.granularity) && !selectDeleteBoundary(accessor, _univerjs_core.Direction.LEFT, params.granularity)) return true;
|
|
6148
6233
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
6149
6234
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
6150
6235
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
@@ -6304,8 +6389,9 @@ const DeleteLeftCommand = {
|
|
|
6304
6389
|
const DeleteRightCommand = {
|
|
6305
6390
|
id: "doc.command.delete-right",
|
|
6306
6391
|
type: _univerjs_core.CommandType.COMMAND,
|
|
6307
|
-
handler: async (accessor) => {
|
|
6392
|
+
handler: async (accessor, params) => {
|
|
6308
6393
|
var _docDataModel$getSelf5;
|
|
6394
|
+
if ((params === null || params === void 0 ? void 0 : params.granularity) && !selectDeleteBoundary(accessor, _univerjs_core.Direction.RIGHT, params.granularity)) return true;
|
|
6309
6395
|
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
6310
6396
|
const docDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
6311
6397
|
if (!docDataModel) return false;
|
|
@@ -8480,23 +8566,39 @@ function getTableClipboardBodySlice(body, range) {
|
|
|
8480
8566
|
return getTableCellContentClipboardBodySlice(body, startOffset, endOffset);
|
|
8481
8567
|
}
|
|
8482
8568
|
function getTableCellContentClipboardBodySlice(body, start, end) {
|
|
8483
|
-
var _bodySlice$textRuns, _bodySlice$
|
|
8569
|
+
var _bodySlice$textRuns, _bodySlice$docxExport;
|
|
8484
8570
|
const bodySlice = (0, _univerjs_core.getBodySlice)(body, start, end + 2);
|
|
8485
|
-
|
|
8571
|
+
const prefix = _univerjs_core.DataStreamTreeTokenType.TABLE_START + _univerjs_core.DataStreamTreeTokenType.TABLE_ROW_START + _univerjs_core.DataStreamTreeTokenType.TABLE_CELL_START;
|
|
8572
|
+
bodySlice.dataStream = prefix + bodySlice.dataStream + _univerjs_core.DataStreamTreeTokenType.TABLE_CELL_END + _univerjs_core.DataStreamTreeTokenType.TABLE_ROW_END + _univerjs_core.DataStreamTreeTokenType.TABLE_END;
|
|
8573
|
+
const offset = prefix.length;
|
|
8486
8574
|
(_bodySlice$textRuns = bodySlice.textRuns) === null || _bodySlice$textRuns === void 0 || _bodySlice$textRuns.forEach((textRun) => {
|
|
8487
|
-
|
|
8488
|
-
textRun.
|
|
8489
|
-
textRun.ed = ed + 3;
|
|
8490
|
-
});
|
|
8491
|
-
(_bodySlice$tables = bodySlice.tables) === null || _bodySlice$tables === void 0 || _bodySlice$tables.forEach((table) => {
|
|
8492
|
-
const { startIndex, endIndex } = table;
|
|
8493
|
-
table.startIndex = startIndex + 3;
|
|
8494
|
-
table.endIndex = endIndex + 3;
|
|
8575
|
+
textRun.st += offset;
|
|
8576
|
+
textRun.ed += offset;
|
|
8495
8577
|
});
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8578
|
+
[
|
|
8579
|
+
bodySlice.paragraphs,
|
|
8580
|
+
bodySlice.sectionBreaks,
|
|
8581
|
+
bodySlice.customBlocks,
|
|
8582
|
+
bodySlice.docxRawCustomBlocks,
|
|
8583
|
+
bodySlice.docxRawBlocks
|
|
8584
|
+
].forEach((items) => items === null || items === void 0 ? void 0 : items.forEach((item) => {
|
|
8585
|
+
item.startIndex += offset;
|
|
8586
|
+
}));
|
|
8587
|
+
[
|
|
8588
|
+
bodySlice.tables,
|
|
8589
|
+
bodySlice.columnGroups,
|
|
8590
|
+
bodySlice.blockRanges,
|
|
8591
|
+
bodySlice.customRanges,
|
|
8592
|
+
bodySlice.customDecorations
|
|
8593
|
+
].forEach((ranges) => ranges === null || ranges === void 0 ? void 0 : ranges.forEach((range) => {
|
|
8594
|
+
range.startIndex += offset;
|
|
8595
|
+
range.endIndex += offset;
|
|
8596
|
+
}));
|
|
8597
|
+
(_bodySlice$docxExport = bodySlice.docxExportExcludedRanges) === null || _bodySlice$docxExport === void 0 || _bodySlice$docxExport.forEach((range) => {
|
|
8598
|
+
range.start += offset;
|
|
8599
|
+
range.end += offset;
|
|
8499
8600
|
});
|
|
8601
|
+
if (bodySlice.renderedPageBreaks) bodySlice.renderedPageBreaks = bodySlice.renderedPageBreaks.map((index) => index + offset);
|
|
8500
8602
|
return bodySlice;
|
|
8501
8603
|
}
|
|
8502
8604
|
const IDocClipboardService = (0, _univerjs_core.createIdentifier)("doc.clipboard-service");
|
|
@@ -8526,7 +8628,11 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
8526
8628
|
_defineProperty(this, "_umdToHtml", void 0);
|
|
8527
8629
|
this._umdToHtml = new UDMToHtmlService(docHtmlExportService);
|
|
8528
8630
|
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
8529
|
-
|
|
8631
|
+
var _command$params, _this$_pasteOptions$$;
|
|
8632
|
+
if (this._applyingPaste || command.type !== _univerjs_core.CommandType.MUTATION) return;
|
|
8633
|
+
const unitId = (_command$params = command.params) === null || _command$params === void 0 ? void 0 : _command$params.unitId;
|
|
8634
|
+
const pasteUnitId = ((_this$_pasteOptions$$ = this._pasteOptions$.value) === null || _this$_pasteOptions$$ === void 0 ? void 0 : _this$_pasteOptions$$.unitId) ?? this._getCurrentDocumentUnitId();
|
|
8635
|
+
if (!unitId || unitId === pasteUnitId) this.dismissPasteOptions();
|
|
8530
8636
|
}));
|
|
8531
8637
|
const invalidateSelection = () => {
|
|
8532
8638
|
const key = this._getPasteSelectionKey();
|
|
@@ -8600,6 +8706,12 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
8600
8706
|
mode
|
|
8601
8707
|
});
|
|
8602
8708
|
}
|
|
8709
|
+
isPasteOptionsEnabled(unitId) {
|
|
8710
|
+
return !(0, _univerjs_core.isInternalEditorID)(unitId) || this._clipboardHooks.some((hook) => {
|
|
8711
|
+
var _hook$supportsPasteOp;
|
|
8712
|
+
return (_hook$supportsPasteOp = hook.supportsPasteOptions) === null || _hook$supportsPasteOp === void 0 ? void 0 : _hook$supportsPasteOp.call(hook, unitId);
|
|
8713
|
+
});
|
|
8714
|
+
}
|
|
8603
8715
|
setNextPasteMode(mode) {
|
|
8604
8716
|
this._nextPasteMode = mode;
|
|
8605
8717
|
}
|
|
@@ -8690,7 +8802,7 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
8690
8802
|
try {
|
|
8691
8803
|
this._stateChangeManager.flushPendingChanges(unitId);
|
|
8692
8804
|
const result = this._paste(doc, unitId);
|
|
8693
|
-
if (result &&
|
|
8805
|
+
if (result && this.isPasteOptionsEnabled(unitId)) this._savePasteSession(payload, mode === "text" ? cachedSource : source, style, mode, unitId);
|
|
8694
8806
|
return result;
|
|
8695
8807
|
} finally {
|
|
8696
8808
|
this._applyingPaste = false;
|
|
@@ -8914,7 +9026,11 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
|
|
|
8914
9026
|
this._clipboardHooks.push(hook);
|
|
8915
9027
|
return (0, _univerjs_core.toDisposable)(() => {
|
|
8916
9028
|
const index = this._clipboardHooks.indexOf(hook);
|
|
8917
|
-
if (index > -1)
|
|
9029
|
+
if (index > -1) {
|
|
9030
|
+
this._clipboardHooks.splice(index, 1);
|
|
9031
|
+
const state = this._pasteOptions$.value;
|
|
9032
|
+
if (state && !this.isPasteOptionsEnabled(state.unitId)) this.dismissPasteOptions();
|
|
9033
|
+
}
|
|
8918
9034
|
});
|
|
8919
9035
|
}
|
|
8920
9036
|
_applyCopyDocDataHooks(doc, sourceDocuments) {
|
|
@@ -11620,31 +11736,6 @@ const DocCreateTableOperation = {
|
|
|
11620
11736
|
}
|
|
11621
11737
|
};
|
|
11622
11738
|
|
|
11623
|
-
//#endregion
|
|
11624
|
-
//#region src/commands/operations/doc-cursor.operation.ts
|
|
11625
|
-
/**
|
|
11626
|
-
* The operation to move cursor in the current document.
|
|
11627
|
-
*/
|
|
11628
|
-
const MoveCursorOperation = {
|
|
11629
|
-
id: "doc.operation.move-cursor",
|
|
11630
|
-
type: _univerjs_core.CommandType.OPERATION,
|
|
11631
|
-
handler: (accessor, params) => {
|
|
11632
|
-
if (!params) return false;
|
|
11633
|
-
return true;
|
|
11634
|
-
}
|
|
11635
|
-
};
|
|
11636
|
-
/**
|
|
11637
|
-
* The operation to move selection in the current document.
|
|
11638
|
-
*/
|
|
11639
|
-
const MoveSelectionOperation = {
|
|
11640
|
-
id: "doc.operation.move-selection",
|
|
11641
|
-
type: _univerjs_core.CommandType.OPERATION,
|
|
11642
|
-
handler: (accessor, params) => {
|
|
11643
|
-
if (!params) return false;
|
|
11644
|
-
return true;
|
|
11645
|
-
}
|
|
11646
|
-
};
|
|
11647
|
-
|
|
11648
11739
|
//#endregion
|
|
11649
11740
|
//#region src/config/config.ts
|
|
11650
11741
|
const DOCS_UI_PLUGIN_CONFIG_KEY = "docs-ui.config";
|
|
@@ -12089,6 +12180,7 @@ function getLineFontFamily(line) {
|
|
|
12089
12180
|
function drawParagraphPlaceholders(ctx, placeholders, color = PLACEHOLDER_COLOR) {
|
|
12090
12181
|
ctx.save();
|
|
12091
12182
|
ctx.fillStyle = color;
|
|
12183
|
+
ctx.globalAlpha *= .5;
|
|
12092
12184
|
ctx.textBaseline = "alphabetic";
|
|
12093
12185
|
for (const placeholder of placeholders) {
|
|
12094
12186
|
const clipLeft = placeholder.clipLeft ?? placeholder.x;
|
|
@@ -12712,12 +12804,35 @@ var DocLayoutInteractionService = class extends _univerjs_core.Disposable {
|
|
|
12712
12804
|
//#region src/services/doc-zoom.ts
|
|
12713
12805
|
const DEFAULT_DOC_ZOOM_RATIO = 1;
|
|
12714
12806
|
const DEFAULT_MODERN_DOC_ZOOM_RATIO = 1;
|
|
12807
|
+
const DOC_ZOOM_SHORTCUTS = [
|
|
12808
|
+
50,
|
|
12809
|
+
80,
|
|
12810
|
+
100,
|
|
12811
|
+
130,
|
|
12812
|
+
150,
|
|
12813
|
+
170,
|
|
12814
|
+
200,
|
|
12815
|
+
400
|
|
12816
|
+
];
|
|
12715
12817
|
function getDocEffectiveZoomRatio(documentModel) {
|
|
12716
12818
|
var _documentModel$getSet, _documentModel$getSna;
|
|
12717
12819
|
const zoomRatio = (_documentModel$getSet = documentModel.getSettings()) === null || _documentModel$getSet === void 0 ? void 0 : _documentModel$getSet.zoomRatio;
|
|
12718
12820
|
if (zoomRatio != null) return zoomRatio;
|
|
12719
12821
|
return ((_documentModel$getSna = documentModel.getSnapshot().documentStyle) === null || _documentModel$getSna === void 0 ? void 0 : _documentModel$getSna.documentFlavor) === _univerjs_core.DocumentFlavor.MODERN ? 1 : DEFAULT_DOC_ZOOM_RATIO;
|
|
12720
12822
|
}
|
|
12823
|
+
function getDocZoomRatio$(commandService, instanceService) {
|
|
12824
|
+
return instanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC).pipe((0, rxjs.switchMap)((documentModel) => {
|
|
12825
|
+
if (!documentModel) return (0, rxjs.of)(100);
|
|
12826
|
+
return new rxjs.Observable((subscriber) => {
|
|
12827
|
+
const update = () => subscriber.next(Math.round(getDocEffectiveZoomRatio(documentModel) * 100));
|
|
12828
|
+
const disposable = commandService.onCommandExecuted((command) => {
|
|
12829
|
+
if (command.id === SetDocZoomRatioOperation.id && command.params.unitId === documentModel.getUnitId()) update();
|
|
12830
|
+
});
|
|
12831
|
+
update();
|
|
12832
|
+
return () => disposable.dispose();
|
|
12833
|
+
});
|
|
12834
|
+
}), (0, rxjs.distinctUntilChanged)());
|
|
12835
|
+
}
|
|
12721
12836
|
|
|
12722
12837
|
//#endregion
|
|
12723
12838
|
//#region src/services/doc-view-scale.ts
|
|
@@ -13367,11 +13482,13 @@ function doesDocMutationRequireLayout(actions, drawings) {
|
|
|
13367
13482
|
if (!sawComponent || !drawingOnly) return true;
|
|
13368
13483
|
if (transitions.size === 0) return false;
|
|
13369
13484
|
for (const [drawingId, transition] of transitions) {
|
|
13370
|
-
var
|
|
13371
|
-
const
|
|
13485
|
+
var _currentDrawing$docTr, _currentDrawing$docTr2;
|
|
13486
|
+
const currentDrawing = drawings === null || drawings === void 0 ? void 0 : drawings[drawingId];
|
|
13487
|
+
const currentLayoutType = currentDrawing === null || currentDrawing === void 0 ? void 0 : currentDrawing.layoutType;
|
|
13372
13488
|
const before = transition.before ?? currentLayoutType;
|
|
13373
13489
|
const after = transition.after ?? currentLayoutType;
|
|
13374
13490
|
if (before == null || after == null || before !== _univerjs_core.PositionedObjectLayoutType.WRAP_NONE || after !== _univerjs_core.PositionedObjectLayoutType.WRAP_NONE) return true;
|
|
13491
|
+
if ((currentDrawing === null || currentDrawing === void 0 || (_currentDrawing$docTr = currentDrawing.docTransform) === null || _currentDrawing$docTr === void 0 ? void 0 : _currentDrawing$docTr.positionH.relativeFrom) !== _univerjs_core.ObjectRelativeFromH.PAGE || (currentDrawing === null || currentDrawing === void 0 || (_currentDrawing$docTr2 = currentDrawing.docTransform) === null || _currentDrawing$docTr2 === void 0 ? void 0 : _currentDrawing$docTr2.positionV.relativeFrom) !== _univerjs_core.ObjectRelativeFromV.PAGE) return true;
|
|
13375
13492
|
}
|
|
13376
13493
|
return false;
|
|
13377
13494
|
}
|
|
@@ -14351,6 +14468,8 @@ function getHeaderFooterTarget(viewModel, editArea, segmentPage, page) {
|
|
|
14351
14468
|
* limitations under the License.
|
|
14352
14469
|
*/
|
|
14353
14470
|
const COMPONENT_DOC_HEADER_FOOTER_PANEL = "COMPONENT_DOC_HEADER_FOOTER_PANEL";
|
|
14471
|
+
const DOC_HEADER_FOOTER_RIBBON_TAB = "docs-ui.ribbon.header-footer";
|
|
14472
|
+
const DOC_HEADER_FOOTER_RIBBON_CONTROL = "DocHeaderFooterRibbonControl";
|
|
14354
14473
|
|
|
14355
14474
|
//#endregion
|
|
14356
14475
|
//#region src/commands/operations/doc-header-footer-panel.operation.ts
|
|
@@ -14408,8 +14527,8 @@ const CoreHeaderFooterCommand = {
|
|
|
14408
14527
|
let resolvedCreateType = createType;
|
|
14409
14528
|
if (headerFooterProps != null) Object.keys(headerFooterProps).forEach((key) => {
|
|
14410
14529
|
const value = headerFooterProps[key];
|
|
14411
|
-
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;
|
|
14412
|
-
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;
|
|
14530
|
+
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;
|
|
14531
|
+
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;
|
|
14413
14532
|
});
|
|
14414
14533
|
return commandService.syncExecuteCommand(_univerjs_docs.CreateHeaderFooterCommand.id, {
|
|
14415
14534
|
unitId,
|
|
@@ -14424,8 +14543,8 @@ const CoreHeaderFooterCommand = {
|
|
|
14424
14543
|
const OpenHeaderFooterPanelCommand = {
|
|
14425
14544
|
id: "doc.command.open-header-footer-panel",
|
|
14426
14545
|
type: _univerjs_core.CommandType.COMMAND,
|
|
14427
|
-
handler: async (accessor,
|
|
14428
|
-
var _skeleton$getSkeleton;
|
|
14546
|
+
handler: async (accessor, params) => {
|
|
14547
|
+
var _skeleton$getSkeleton, _docDataModel$getSelf;
|
|
14429
14548
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
14430
14549
|
const instanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
14431
14550
|
const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
|
|
@@ -14442,8 +14561,9 @@ const OpenHeaderFooterPanelCommand = {
|
|
|
14442
14561
|
const currentPage = selectionRenderService.getSegmentPage();
|
|
14443
14562
|
const pageNumber = currentPage >= 0 && currentPage < pages.length ? currentPage : 0;
|
|
14444
14563
|
const page = pages[pageNumber];
|
|
14445
|
-
|
|
14446
|
-
|
|
14564
|
+
const editArea = (params === null || params === void 0 ? void 0 : params.editArea) ?? _univerjs_engine_render.DocumentEditArea.HEADER;
|
|
14565
|
+
viewModel.setEditArea(editArea);
|
|
14566
|
+
const { createType, headerFooterId, sectionId } = getHeaderFooterTarget(viewModel, editArea, pageNumber, page);
|
|
14447
14567
|
selectionRenderService.setSegmentPage(pageNumber);
|
|
14448
14568
|
if (createType != null) {
|
|
14449
14569
|
const segmentId = (0, _univerjs_core.generateRandomId)(6);
|
|
@@ -14460,6 +14580,21 @@ const OpenHeaderFooterPanelCommand = {
|
|
|
14460
14580
|
return false;
|
|
14461
14581
|
}
|
|
14462
14582
|
} else if (headerFooterId != null) selectionRenderService.setSegment(headerFooterId);
|
|
14583
|
+
const segmentId = selectionRenderService.getSegment();
|
|
14584
|
+
const segmentSnapshot = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getSnapshot();
|
|
14585
|
+
if (!segmentSnapshot) return false;
|
|
14586
|
+
const offset = findFirstCursorOffset(segmentSnapshot);
|
|
14587
|
+
accessor.get(_univerjs_docs.DocSelectionManagerService).replaceDocRanges([{
|
|
14588
|
+
startOffset: offset,
|
|
14589
|
+
endOffset: offset,
|
|
14590
|
+
collapsed: true,
|
|
14591
|
+
segmentId,
|
|
14592
|
+
segmentPage: pageNumber
|
|
14593
|
+
}], {
|
|
14594
|
+
unitId,
|
|
14595
|
+
subUnitId: unitId
|
|
14596
|
+
});
|
|
14597
|
+
selectionRenderService.focus();
|
|
14463
14598
|
return commandService.executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "open" });
|
|
14464
14599
|
}
|
|
14465
14600
|
};
|
|
@@ -14502,7 +14637,254 @@ const CloseHeaderFooterCommand = {
|
|
|
14502
14637
|
endOffset: offset
|
|
14503
14638
|
}]);
|
|
14504
14639
|
});
|
|
14505
|
-
commandService.executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "close" });
|
|
14640
|
+
await commandService.executeCommand(SidebarDocHeaderFooterPanelOperation.id, { value: "close" });
|
|
14641
|
+
return true;
|
|
14642
|
+
}
|
|
14643
|
+
};
|
|
14644
|
+
|
|
14645
|
+
//#endregion
|
|
14646
|
+
//#region src/utils/date-time-field.ts
|
|
14647
|
+
function createDateTimeField(format, locale, date) {
|
|
14648
|
+
const options = format === "time" ? {
|
|
14649
|
+
hour: "2-digit",
|
|
14650
|
+
minute: "2-digit",
|
|
14651
|
+
second: "2-digit",
|
|
14652
|
+
hourCycle: "h23"
|
|
14653
|
+
} : {
|
|
14654
|
+
year: "numeric",
|
|
14655
|
+
month: format === "long" ? "long" : "2-digit",
|
|
14656
|
+
day: "2-digit"
|
|
14657
|
+
};
|
|
14658
|
+
const formatter = new Intl.DateTimeFormat(locale, {
|
|
14659
|
+
...options,
|
|
14660
|
+
calendar: "gregory",
|
|
14661
|
+
numberingSystem: "latn"
|
|
14662
|
+
});
|
|
14663
|
+
const parts = formatter.formatToParts(date);
|
|
14664
|
+
const tokens = {
|
|
14665
|
+
year: "yyyy",
|
|
14666
|
+
month: format === "long" ? "MMMM" : "MM",
|
|
14667
|
+
day: "dd",
|
|
14668
|
+
hour: "HH",
|
|
14669
|
+
minute: "mm",
|
|
14670
|
+
second: "ss"
|
|
14671
|
+
};
|
|
14672
|
+
const mask = parts.map((part) => tokens[part.type] ?? `'${part.value.replace(/'/g, "''")}'`).join("");
|
|
14673
|
+
const fieldType = format === "time" ? "TIME" : "DATE";
|
|
14674
|
+
return {
|
|
14675
|
+
fieldType,
|
|
14676
|
+
instruction: `${fieldType} \\@ "${mask}"`,
|
|
14677
|
+
cachedResult: formatter.format(date)
|
|
14678
|
+
};
|
|
14679
|
+
}
|
|
14680
|
+
function resolveDateTimeField(instruction, locale, date) {
|
|
14681
|
+
try {
|
|
14682
|
+
Intl.getCanonicalLocales(locale);
|
|
14683
|
+
} catch {
|
|
14684
|
+
return;
|
|
14685
|
+
}
|
|
14686
|
+
for (const format of [
|
|
14687
|
+
"short",
|
|
14688
|
+
"long",
|
|
14689
|
+
"time"
|
|
14690
|
+
]) {
|
|
14691
|
+
const field = createDateTimeField(format, locale, date);
|
|
14692
|
+
if (field.instruction === instruction) return field.cachedResult;
|
|
14693
|
+
}
|
|
14694
|
+
}
|
|
14695
|
+
|
|
14696
|
+
//#endregion
|
|
14697
|
+
//#region src/commands/commands/insert-header-footer-field.command.ts
|
|
14698
|
+
const InsertHeaderFooterFieldCommand = {
|
|
14699
|
+
id: "doc.command.insert-header-footer-field",
|
|
14700
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
14701
|
+
handler(accessor, params) {
|
|
14702
|
+
var _snapshot$headers, _snapshot$footers, _model$getSelfOrHeade, _body$customRanges;
|
|
14703
|
+
if (!params || ![
|
|
14704
|
+
"PAGE",
|
|
14705
|
+
"NUMPAGES",
|
|
14706
|
+
"DATE",
|
|
14707
|
+
"TIME"
|
|
14708
|
+
].includes(params.fieldType)) return false;
|
|
14709
|
+
const model = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(params.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
14710
|
+
const active = accessor.get(_univerjs_docs.DocSelectionManagerService).getActiveTextRange();
|
|
14711
|
+
const selection = params.selection ?? active;
|
|
14712
|
+
const segmentId = params.segmentId ?? (active === null || active === void 0 ? void 0 : active.segmentId);
|
|
14713
|
+
const snapshot = model === null || model === void 0 ? void 0 : model.getSnapshot();
|
|
14714
|
+
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;
|
|
14715
|
+
const body = (_model$getSelfOrHeade = model.getSelfOrHeaderFooterModel(segmentId)) === null || _model$getSelfOrHeade === void 0 ? void 0 : _model$getSelfOrHeade.getBody();
|
|
14716
|
+
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;
|
|
14717
|
+
if (!(0, _univerjs_docs.canEditDocumentTargets)(accessor.get(_univerjs_core.IPermissionService), params.unitId, (0, _univerjs_docs.getDocumentEditTargetObjectIds)(model, segmentId, selection))) return false;
|
|
14718
|
+
if ((_body$customRanges = body.customRanges) === null || _body$customRanges === void 0 ? void 0 : _body$customRanges.some((range) => {
|
|
14719
|
+
var _range$properties;
|
|
14720
|
+
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;
|
|
14721
|
+
})) return false;
|
|
14722
|
+
const locale = _univerjs_core.LOCALE_META[accessor.get(_univerjs_core.LocaleService).getCurrentLocale()].tag;
|
|
14723
|
+
let properties;
|
|
14724
|
+
if (params.fieldType === "DATE" || params.fieldType === "TIME") {
|
|
14725
|
+
const format = params.format ?? (params.fieldType === "TIME" ? "time" : "short");
|
|
14726
|
+
if (![
|
|
14727
|
+
"short",
|
|
14728
|
+
"long",
|
|
14729
|
+
"time"
|
|
14730
|
+
].includes(format)) return false;
|
|
14731
|
+
properties = createDateTimeField(format, locale, /* @__PURE__ */ new Date());
|
|
14732
|
+
} else {
|
|
14733
|
+
var _accessor$get$getRend, _skeleton$getSkeleton;
|
|
14734
|
+
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();
|
|
14735
|
+
const pages = skeleton === null || skeleton === void 0 || (_skeleton$getSkeleton = skeleton.getSkeletonData()) === null || _skeleton$getSkeleton === void 0 ? void 0 : _skeleton$getSkeleton.pages;
|
|
14736
|
+
if (!(pages === null || pages === void 0 ? void 0 : pages.length)) return false;
|
|
14737
|
+
const pageIndex = params.segmentPage ?? (active === null || active === void 0 ? void 0 : active.segmentPage) ?? 0;
|
|
14738
|
+
const page = pages[Math.max(0, pageIndex)];
|
|
14739
|
+
if (!page) return false;
|
|
14740
|
+
properties = {
|
|
14741
|
+
fieldType: params.fieldType,
|
|
14742
|
+
instruction: params.fieldType,
|
|
14743
|
+
cachedResult: String(params.fieldType === "PAGE" ? page.pageNumber : (skeleton === null || skeleton === void 0 ? void 0 : skeleton.getCompletedPageCount()) ?? "…")
|
|
14744
|
+
};
|
|
14745
|
+
}
|
|
14746
|
+
const automatic = params.automatic !== false || params.fieldType === "PAGE" || params.fieldType === "NUMPAGES";
|
|
14747
|
+
const dataStream = automatic ? `${_univerjs_core.DataStreamTreeTokenType.CUSTOM_RANGE_START}${properties.cachedResult}${_univerjs_core.DataStreamTreeTokenType.CUSTOM_RANGE_END}` : properties.cachedResult;
|
|
14748
|
+
const style = accessor.get(DocMenuStyleService);
|
|
14749
|
+
const textRun = getTextRunForSelection(body, selection, style.getDefaultStyle(), style.getStyleCache(), false);
|
|
14750
|
+
return accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(_univerjs_docs.InsertTextCommand.id, {
|
|
14751
|
+
unitId: params.unitId,
|
|
14752
|
+
segmentId,
|
|
14753
|
+
range: selection,
|
|
14754
|
+
debounce: false,
|
|
14755
|
+
body: {
|
|
14756
|
+
dataStream,
|
|
14757
|
+
textRuns: [{
|
|
14758
|
+
...textRun,
|
|
14759
|
+
ts: {
|
|
14760
|
+
...textRun.ts,
|
|
14761
|
+
lang: locale
|
|
14762
|
+
},
|
|
14763
|
+
st: 0,
|
|
14764
|
+
ed: dataStream.length
|
|
14765
|
+
}],
|
|
14766
|
+
customRanges: automatic ? [{
|
|
14767
|
+
startIndex: 0,
|
|
14768
|
+
endIndex: dataStream.length - 1,
|
|
14769
|
+
rangeId: (0, _univerjs_core.generateRandomId)(),
|
|
14770
|
+
rangeType: _univerjs_core.CustomRangeType.FIELD,
|
|
14771
|
+
wholeEntity: false,
|
|
14772
|
+
properties: {
|
|
14773
|
+
...properties,
|
|
14774
|
+
sourceKind: "complex"
|
|
14775
|
+
}
|
|
14776
|
+
}] : []
|
|
14777
|
+
},
|
|
14778
|
+
textRanges: [{
|
|
14779
|
+
...selection,
|
|
14780
|
+
segmentId,
|
|
14781
|
+
segmentPage: params.segmentPage ?? (active === null || active === void 0 ? void 0 : active.segmentPage),
|
|
14782
|
+
startOffset: selection.startOffset + dataStream.length,
|
|
14783
|
+
endOffset: selection.startOffset + dataStream.length,
|
|
14784
|
+
collapsed: true
|
|
14785
|
+
}]
|
|
14786
|
+
});
|
|
14787
|
+
}
|
|
14788
|
+
};
|
|
14789
|
+
|
|
14790
|
+
//#endregion
|
|
14791
|
+
//#region src/commands/commands/refresh-header-footer-fields.command.ts
|
|
14792
|
+
const RefreshHeaderFooterFieldsCommand = {
|
|
14793
|
+
id: "doc.command.refresh-header-footer-fields",
|
|
14794
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
14795
|
+
handler(accessor, params) {
|
|
14796
|
+
if (!params) return false;
|
|
14797
|
+
const model = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(params.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
14798
|
+
const snapshot = model === null || model === void 0 ? void 0 : model.getSnapshot();
|
|
14799
|
+
if (!model || !snapshot || snapshot.disabled) return false;
|
|
14800
|
+
const permissions = accessor.get(_univerjs_core.IPermissionService);
|
|
14801
|
+
const locale = _univerjs_core.LOCALE_META[accessor.get(_univerjs_core.LocaleService).getCurrentLocale()].tag;
|
|
14802
|
+
const now = /* @__PURE__ */ new Date();
|
|
14803
|
+
const selections = accessor.get(_univerjs_docs.DocSelectionManagerService).getTextRanges({
|
|
14804
|
+
unitId: params.unitId,
|
|
14805
|
+
subUnitId: params.unitId
|
|
14806
|
+
}) ?? [];
|
|
14807
|
+
let actions = null;
|
|
14808
|
+
for (const [segmentId, segment] of Object.entries({
|
|
14809
|
+
"": { body: snapshot.body },
|
|
14810
|
+
...snapshot.headers,
|
|
14811
|
+
...snapshot.footers
|
|
14812
|
+
})) {
|
|
14813
|
+
if (!segment.body) continue;
|
|
14814
|
+
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, {
|
|
14815
|
+
startOffset: field.startIndex,
|
|
14816
|
+
endOffset: field.endIndex + 1
|
|
14817
|
+
})));
|
|
14818
|
+
if (textX.length) actions = _univerjs_core.JSONX.compose(actions, _univerjs_core.JSONX.getInstance().editOp(textX, (0, _univerjs_core.getRichTextEditPath)(model, segmentId)));
|
|
14819
|
+
}
|
|
14820
|
+
if (_univerjs_core.JSONX.isNoop(actions)) return true;
|
|
14821
|
+
if (!params.onOpen) accessor.get(_univerjs_docs.DocStateChangeManagerService).flushPendingChanges(params.unitId);
|
|
14822
|
+
return Boolean(accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(_univerjs_docs.RichTextEditingMutation.id, {
|
|
14823
|
+
unitId: params.unitId,
|
|
14824
|
+
actions,
|
|
14825
|
+
textRanges: (0, _univerjs_docs.transformDocumentTextRanges)(actions, [...selections]),
|
|
14826
|
+
noHistory: params.onOpen === true,
|
|
14827
|
+
debounce: false,
|
|
14828
|
+
trigger: RefreshHeaderFooterFieldsCommand.id
|
|
14829
|
+
}));
|
|
14830
|
+
}
|
|
14831
|
+
};
|
|
14832
|
+
const UpdateSelectedDocFieldsCommand = {
|
|
14833
|
+
id: "doc.command.update-selected-fields",
|
|
14834
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
14835
|
+
handler(accessor) {
|
|
14836
|
+
const model = accessor.get(_univerjs_core.IUniverInstanceService).getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
14837
|
+
if (!model) return false;
|
|
14838
|
+
return accessor.get(_univerjs_core.ICommandService).syncExecuteCommand(RefreshHeaderFooterFieldsCommand.id, {
|
|
14839
|
+
unitId: model.getUnitId(),
|
|
14840
|
+
selectionOnly: true
|
|
14841
|
+
});
|
|
14842
|
+
}
|
|
14843
|
+
};
|
|
14844
|
+
function refreshDateTimeFields(body, locale, date, canEdit) {
|
|
14845
|
+
const textX = new _univerjs_core.TextX();
|
|
14846
|
+
let cursor = 0;
|
|
14847
|
+
const ranges = [...body.customRanges ?? []].sort((a, b) => a.startIndex - b.startIndex);
|
|
14848
|
+
for (const field of ranges) {
|
|
14849
|
+
var _body$textRuns, _run$ts;
|
|
14850
|
+
const properties = field.properties;
|
|
14851
|
+
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;
|
|
14852
|
+
const start = field.startIndex;
|
|
14853
|
+
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);
|
|
14854
|
+
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);
|
|
14855
|
+
if (value == null || start < cursor || body.dataStream.slice(start + 1, field.endIndex) === value && properties.cachedResult === value) continue;
|
|
14856
|
+
const dataStream = `${_univerjs_core.DataStreamTreeTokenType.CUSTOM_RANGE_START}${value}${_univerjs_core.DataStreamTreeTokenType.CUSTOM_RANGE_END}`;
|
|
14857
|
+
textX.retain(start - cursor).delete(field.endIndex - start + 1).insert(dataStream.length, {
|
|
14858
|
+
dataStream,
|
|
14859
|
+
textRuns: run ? [{
|
|
14860
|
+
...run,
|
|
14861
|
+
st: 0,
|
|
14862
|
+
ed: dataStream.length
|
|
14863
|
+
}] : [],
|
|
14864
|
+
customRanges: [{
|
|
14865
|
+
...field,
|
|
14866
|
+
startIndex: 0,
|
|
14867
|
+
endIndex: dataStream.length - 1,
|
|
14868
|
+
properties: {
|
|
14869
|
+
...properties,
|
|
14870
|
+
cachedResult: value
|
|
14871
|
+
}
|
|
14872
|
+
}]
|
|
14873
|
+
});
|
|
14874
|
+
cursor = field.endIndex + 1;
|
|
14875
|
+
}
|
|
14876
|
+
return textX.serialize();
|
|
14877
|
+
}
|
|
14878
|
+
|
|
14879
|
+
//#endregion
|
|
14880
|
+
//#region src/commands/operations/doc-header-footer-ribbon.operation.ts
|
|
14881
|
+
const DocHeaderFooterRibbonOperation = {
|
|
14882
|
+
id: SidebarDocHeaderFooterPanelOperation.id,
|
|
14883
|
+
type: SidebarDocHeaderFooterPanelOperation.type,
|
|
14884
|
+
handler(accessor, params) {
|
|
14885
|
+
const ribbon = accessor.get(_univerjs_ui.IRibbonService);
|
|
14886
|
+
if ((params === null || params === void 0 ? void 0 : params.value) === "open") ribbon.showContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB, { activate: true });
|
|
14887
|
+
else ribbon.hideContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB);
|
|
14506
14888
|
return true;
|
|
14507
14889
|
}
|
|
14508
14890
|
};
|
|
@@ -15131,8 +15513,12 @@ let DocEventManagerService = class DocEventManagerService extends _univerjs_core
|
|
|
15131
15513
|
}
|
|
15132
15514
|
_initPointer() {
|
|
15133
15515
|
let preCursor = _univerjs_engine_render.CURSOR_TYPE.TEXT;
|
|
15516
|
+
let pointing = false;
|
|
15134
15517
|
this.disposeWithMe(this.hoverCustomRanges$.subscribe((ranges) => {
|
|
15135
|
-
|
|
15518
|
+
const nextPointing = ranges.some(({ range }) => range.rangeType !== _univerjs_core.CustomRangeType.FIELD);
|
|
15519
|
+
if (nextPointing === pointing) return;
|
|
15520
|
+
pointing = nextPointing;
|
|
15521
|
+
if (pointing) {
|
|
15136
15522
|
preCursor = this._context.scene.getCursor();
|
|
15137
15523
|
this._context.scene.setCursor(_univerjs_engine_render.CURSOR_TYPE.POINTER);
|
|
15138
15524
|
} else this._context.scene.setCursor(preCursor);
|
|
@@ -15255,6 +15641,10 @@ let DocEventManagerService = class DocEventManagerService extends _univerjs_core
|
|
|
15255
15641
|
this._buildBulletBounds();
|
|
15256
15642
|
return [...this._bulletBounds];
|
|
15257
15643
|
}
|
|
15644
|
+
getCustomRangeBounds() {
|
|
15645
|
+
this._buildCustomRangeBounds();
|
|
15646
|
+
return [...this._customRangeBounds];
|
|
15647
|
+
}
|
|
15258
15648
|
getListContextMenuBulletByOffset(offsetX, offsetY) {
|
|
15259
15649
|
const point = transformOffset2Bound(offsetX, offsetY, this._context.scene);
|
|
15260
15650
|
return this._calcActiveBullet(point) ?? this._calcActiveListParagraph(point);
|
|
@@ -15800,133 +16190,51 @@ const OpenDocPermissionPanelOperation = {
|
|
|
15800
16190
|
};
|
|
15801
16191
|
|
|
15802
16192
|
//#endregion
|
|
15803
|
-
//#region src/
|
|
15804
|
-
|
|
15805
|
-
|
|
15806
|
-
|
|
15807
|
-
|
|
15808
|
-
|
|
15809
|
-
|
|
15810
|
-
|
|
15811
|
-
|
|
15812
|
-
|
|
15813
|
-
|
|
15814
|
-
|
|
15815
|
-
|
|
15816
|
-
|
|
15817
|
-
|
|
15818
|
-
|
|
15819
|
-
|
|
15820
|
-
|
|
15821
|
-
|
|
15822
|
-
|
|
15823
|
-
|
|
15824
|
-
|
|
15825
|
-
|
|
15826
|
-
|
|
15827
|
-
|
|
15828
|
-
|
|
15829
|
-
|
|
15830
|
-
|
|
15831
|
-
|
|
15832
|
-
|
|
15833
|
-
|
|
15834
|
-
|
|
15835
|
-
|
|
15836
|
-
|
|
15837
|
-
|
|
15838
|
-
|
|
15839
|
-
|
|
15840
|
-
|
|
15841
|
-
|
|
15842
|
-
|
|
15843
|
-
|
|
15844
|
-
|
|
15845
|
-
|
|
15846
|
-
type: _univerjs_core.CommandType.OPERATION,
|
|
15847
|
-
handler: (accessor) => {
|
|
15848
|
-
accessor.get(DocParagraphSettingController).openPanel();
|
|
15849
|
-
return true;
|
|
15850
|
-
}
|
|
15851
|
-
};
|
|
15852
|
-
|
|
15853
|
-
//#endregion
|
|
15854
|
-
//#region src/views/section-setting/component-name.ts
|
|
15855
|
-
/**
|
|
15856
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
15857
|
-
*
|
|
15858
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15859
|
-
* you may not use this file except in compliance with the License.
|
|
15860
|
-
* You may obtain a copy of the License at
|
|
15861
|
-
*
|
|
15862
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15863
|
-
*
|
|
15864
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
15865
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15866
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15867
|
-
* See the License for the specific language governing permissions and
|
|
15868
|
-
* limitations under the License.
|
|
15869
|
-
*/
|
|
15870
|
-
const DOC_SECTION_SETTING_COMPONENT = "doc_ui_section-setting-panel";
|
|
15871
|
-
|
|
15872
|
-
//#endregion
|
|
15873
|
-
//#region src/controllers/doc-section-setting.controller.ts
|
|
15874
|
-
/**
|
|
15875
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
15876
|
-
*
|
|
15877
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15878
|
-
* you may not use this file except in compliance with the License.
|
|
15879
|
-
* You may obtain a copy of the License at
|
|
15880
|
-
*
|
|
15881
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15882
|
-
*
|
|
15883
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
15884
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15885
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15886
|
-
* See the License for the specific language governing permissions and
|
|
15887
|
-
* limitations under the License.
|
|
15888
|
-
*/
|
|
15889
|
-
let DocSectionSettingController = class DocSectionSettingController extends _univerjs_core.Disposable {
|
|
15890
|
-
constructor(_sidebarService, _selectionManager) {
|
|
15891
|
-
super();
|
|
15892
|
-
this._sidebarService = _sidebarService;
|
|
15893
|
-
this._selectionManager = _selectionManager;
|
|
15894
|
-
_defineProperty(this, "_panelId", "DocSectionSetting");
|
|
15895
|
-
}
|
|
15896
|
-
openPanel() {
|
|
15897
|
-
this._sidebarService.open({
|
|
15898
|
-
header: { title: "docs-ui.doc.slider.sectionSetting" },
|
|
15899
|
-
id: this._panelId,
|
|
15900
|
-
children: { label: DOC_SECTION_SETTING_COMPONENT },
|
|
15901
|
-
width: 300
|
|
16193
|
+
//#region src/commands/commands/insert-special-character.command.ts
|
|
16194
|
+
const InsertSpecialCharacterCommand = {
|
|
16195
|
+
id: "doc.command.insert-special-character",
|
|
16196
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
16197
|
+
handler: (accessor, params) => {
|
|
16198
|
+
var _docDataModel$getSelf, _getEditorRuntimeConf;
|
|
16199
|
+
if (!(params === null || params === void 0 ? void 0 : params.value)) return false;
|
|
16200
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
16201
|
+
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
16202
|
+
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
16203
|
+
const docMenuStyleService = accessor.get(DocMenuStyleService);
|
|
16204
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
16205
|
+
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
16206
|
+
if (!docDataModel || !activeRange) return false;
|
|
16207
|
+
const { segmentId } = activeRange;
|
|
16208
|
+
const originBody = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
16209
|
+
if (!originBody) return false;
|
|
16210
|
+
const { value } = params;
|
|
16211
|
+
const curTextRun = getTextRunForSelection(originBody, activeRange, docMenuStyleService.getDefaultStyle(), docMenuStyleService.getStyleCache(), false, ((_getEditorRuntimeConf = getEditorRuntimeConfig(docDataModel)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.inheritParagraphStartStyle) === true);
|
|
16212
|
+
const curCustomRange = getCustomRangeAtPosition(originBody.customRanges ?? [], activeRange.endOffset);
|
|
16213
|
+
const curCustomDecorations = getCustomDecorationAtPosition(originBody.customDecorations ?? [], activeRange.endOffset);
|
|
16214
|
+
return commandService.executeCommand(_univerjs_docs.InsertTextCommand.id, {
|
|
16215
|
+
unitId: docDataModel.getUnitId(),
|
|
16216
|
+
body: {
|
|
16217
|
+
dataStream: value,
|
|
16218
|
+
textRuns: [{
|
|
16219
|
+
...curTextRun,
|
|
16220
|
+
st: 0,
|
|
16221
|
+
ed: value.length
|
|
16222
|
+
}],
|
|
16223
|
+
customRanges: curCustomRange ? [{
|
|
16224
|
+
...curCustomRange,
|
|
16225
|
+
startIndex: 0,
|
|
16226
|
+
endIndex: value.length - 1
|
|
16227
|
+
}] : [],
|
|
16228
|
+
customDecorations: curCustomDecorations.map((customDecoration) => ({
|
|
16229
|
+
...customDecoration,
|
|
16230
|
+
startIndex: 0,
|
|
16231
|
+
endIndex: value.length - 1
|
|
16232
|
+
}))
|
|
16233
|
+
},
|
|
16234
|
+
range: activeRange,
|
|
16235
|
+
segmentId
|
|
15902
16236
|
});
|
|
15903
16237
|
}
|
|
15904
|
-
closePanel() {
|
|
15905
|
-
this._sidebarService.close(this._panelId);
|
|
15906
|
-
}
|
|
15907
|
-
navigateToSectionEnd(unitId, sectionStart, sectionEnd) {
|
|
15908
|
-
const params = {
|
|
15909
|
-
unitId,
|
|
15910
|
-
subUnitId: unitId
|
|
15911
|
-
};
|
|
15912
|
-
const cursorOffset = Math.max(sectionStart, sectionEnd - 1);
|
|
15913
|
-
this._selectionManager.replaceDocRanges([{
|
|
15914
|
-
startOffset: cursorOffset,
|
|
15915
|
-
endOffset: cursorOffset
|
|
15916
|
-
}], params, true, { shouldFocus: false });
|
|
15917
|
-
}
|
|
15918
|
-
};
|
|
15919
|
-
DocSectionSettingController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService))], DocSectionSettingController);
|
|
15920
|
-
|
|
15921
|
-
//#endregion
|
|
15922
|
-
//#region src/commands/operations/doc-section-setting-panel.operation.ts
|
|
15923
|
-
const DocSectionSettingPanelOperation = {
|
|
15924
|
-
id: "sidebar.operation.doc-section-setting-panel",
|
|
15925
|
-
type: _univerjs_core.CommandType.OPERATION,
|
|
15926
|
-
handler: (accessor) => {
|
|
15927
|
-
accessor.get(DocSectionSettingController).openPanel();
|
|
15928
|
-
return true;
|
|
15929
|
-
}
|
|
15930
16238
|
};
|
|
15931
16239
|
|
|
15932
16240
|
//#endregion
|
|
@@ -16359,54 +16667,6 @@ const DocOpenPageSettingCommand = {
|
|
|
16359
16667
|
}
|
|
16360
16668
|
};
|
|
16361
16669
|
|
|
16362
|
-
//#endregion
|
|
16363
|
-
//#region src/commands/commands/insert-special-character.command.ts
|
|
16364
|
-
const InsertSpecialCharacterCommand = {
|
|
16365
|
-
id: "doc.command.insert-special-character",
|
|
16366
|
-
type: _univerjs_core.CommandType.COMMAND,
|
|
16367
|
-
handler: (accessor, params) => {
|
|
16368
|
-
var _docDataModel$getSelf, _getEditorRuntimeConf;
|
|
16369
|
-
if (!(params === null || params === void 0 ? void 0 : params.value)) return false;
|
|
16370
|
-
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
16371
|
-
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
16372
|
-
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
16373
|
-
const docMenuStyleService = accessor.get(DocMenuStyleService);
|
|
16374
|
-
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
16375
|
-
const activeRange = docSelectionManagerService.getActiveTextRange();
|
|
16376
|
-
if (!docDataModel || !activeRange) return false;
|
|
16377
|
-
const { segmentId } = activeRange;
|
|
16378
|
-
const originBody = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
16379
|
-
if (!originBody) return false;
|
|
16380
|
-
const { value } = params;
|
|
16381
|
-
const curTextRun = getTextRunForSelection(originBody, activeRange, docMenuStyleService.getDefaultStyle(), docMenuStyleService.getStyleCache(), false, ((_getEditorRuntimeConf = getEditorRuntimeConfig(docDataModel)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.inheritParagraphStartStyle) === true);
|
|
16382
|
-
const curCustomRange = getCustomRangeAtPosition(originBody.customRanges ?? [], activeRange.endOffset);
|
|
16383
|
-
const curCustomDecorations = getCustomDecorationAtPosition(originBody.customDecorations ?? [], activeRange.endOffset);
|
|
16384
|
-
return commandService.executeCommand(_univerjs_docs.InsertTextCommand.id, {
|
|
16385
|
-
unitId: docDataModel.getUnitId(),
|
|
16386
|
-
body: {
|
|
16387
|
-
dataStream: value,
|
|
16388
|
-
textRuns: [{
|
|
16389
|
-
...curTextRun,
|
|
16390
|
-
st: 0,
|
|
16391
|
-
ed: value.length
|
|
16392
|
-
}],
|
|
16393
|
-
customRanges: curCustomRange ? [{
|
|
16394
|
-
...curCustomRange,
|
|
16395
|
-
startIndex: 0,
|
|
16396
|
-
endIndex: value.length - 1
|
|
16397
|
-
}] : [],
|
|
16398
|
-
customDecorations: curCustomDecorations.map((customDecoration) => ({
|
|
16399
|
-
...customDecoration,
|
|
16400
|
-
startIndex: 0,
|
|
16401
|
-
endIndex: value.length - 1
|
|
16402
|
-
}))
|
|
16403
|
-
},
|
|
16404
|
-
range: activeRange,
|
|
16405
|
-
segmentId
|
|
16406
|
-
});
|
|
16407
|
-
}
|
|
16408
|
-
};
|
|
16409
|
-
|
|
16410
16670
|
//#endregion
|
|
16411
16671
|
//#region src/views/const.ts
|
|
16412
16672
|
/**
|
|
@@ -17763,6 +18023,210 @@ function PageSettingMenuItemFactory(accessor) {
|
|
|
17763
18023
|
};
|
|
17764
18024
|
}
|
|
17765
18025
|
|
|
18026
|
+
//#endregion
|
|
18027
|
+
//#region src/menu/header-footer-ribbon.ts
|
|
18028
|
+
const headerFooterRibbonSchema = {
|
|
18029
|
+
[_univerjs_ui.ContextMenuPosition.MAIN_AREA]: { [_univerjs_ui.ContextMenuGroup.FORMAT]: { [UpdateSelectedDocFieldsCommand.id]: {
|
|
18030
|
+
order: 1,
|
|
18031
|
+
menuItemFactory: (accessor) => {
|
|
18032
|
+
const instances = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
18033
|
+
const selections = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
18034
|
+
return {
|
|
18035
|
+
id: UpdateSelectedDocFieldsCommand.id,
|
|
18036
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
18037
|
+
title: "docs-ui.headerFooter.refreshFields",
|
|
18038
|
+
disabled$: disableMenuWithoutDocumentUnitPermission(accessor, _univerjs_protocol.UnitAction.Edit),
|
|
18039
|
+
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({
|
|
18040
|
+
unitId: model.getUnitId(),
|
|
18041
|
+
subUnitId: model.getUnitId()
|
|
18042
|
+
}) ?? []).some((selection) => {
|
|
18043
|
+
var _model$getSelfOrHeade;
|
|
18044
|
+
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);
|
|
18045
|
+
})))
|
|
18046
|
+
};
|
|
18047
|
+
}
|
|
18048
|
+
} } },
|
|
18049
|
+
[_univerjs_ui.MenuManagerPosition.RIBBON]: { [DOC_HEADER_FOOTER_RIBBON_TAB]: {
|
|
18050
|
+
order: 90,
|
|
18051
|
+
title: "docs-ui.toolbar.headerFooter",
|
|
18052
|
+
contextual: true,
|
|
18053
|
+
...Object.fromEntries([
|
|
18054
|
+
"insertion",
|
|
18055
|
+
"navigation",
|
|
18056
|
+
"options",
|
|
18057
|
+
"position"
|
|
18058
|
+
].map((kind, order) => [`${DOC_HEADER_FOOTER_RIBBON_TAB}.${kind}`, {
|
|
18059
|
+
order,
|
|
18060
|
+
[`${DOC_HEADER_FOOTER_RIBBON_CONTROL}.${kind}`]: {
|
|
18061
|
+
order: 0,
|
|
18062
|
+
gridLayout: {
|
|
18063
|
+
row: 1,
|
|
18064
|
+
column: 1,
|
|
18065
|
+
rowSpan: 2
|
|
18066
|
+
},
|
|
18067
|
+
menuItemFactory: () => ({
|
|
18068
|
+
id: `${DOC_HEADER_FOOTER_RIBBON_CONTROL}.${kind}`,
|
|
18069
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
18070
|
+
label: {
|
|
18071
|
+
name: DOC_HEADER_FOOTER_RIBBON_CONTROL,
|
|
18072
|
+
hoverable: false,
|
|
18073
|
+
props: { kind }
|
|
18074
|
+
}
|
|
18075
|
+
})
|
|
18076
|
+
}
|
|
18077
|
+
}])),
|
|
18078
|
+
"docs-ui.headerFooter.close": {
|
|
18079
|
+
order: 5,
|
|
18080
|
+
[CloseHeaderFooterCommand.id]: {
|
|
18081
|
+
order: 0,
|
|
18082
|
+
gridLayout: {
|
|
18083
|
+
row: 1,
|
|
18084
|
+
column: 1,
|
|
18085
|
+
rowSpan: 2,
|
|
18086
|
+
showLabel: true
|
|
18087
|
+
},
|
|
18088
|
+
menuItemFactory: () => ({
|
|
18089
|
+
id: CloseHeaderFooterCommand.id,
|
|
18090
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
18091
|
+
icon: "CloseIcon",
|
|
18092
|
+
title: "docs-ui.headerFooter.closeHeaderFooter",
|
|
18093
|
+
tooltip: "docs-ui.headerFooter.closeHeaderFooter"
|
|
18094
|
+
})
|
|
18095
|
+
}
|
|
18096
|
+
}
|
|
18097
|
+
} }
|
|
18098
|
+
};
|
|
18099
|
+
|
|
18100
|
+
//#endregion
|
|
18101
|
+
//#region src/controllers/doc-paragraph-setting.controller.ts
|
|
18102
|
+
/**
|
|
18103
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
18104
|
+
*
|
|
18105
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
18106
|
+
* you may not use this file except in compliance with the License.
|
|
18107
|
+
* You may obtain a copy of the License at
|
|
18108
|
+
*
|
|
18109
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18110
|
+
*
|
|
18111
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18112
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18113
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18114
|
+
* See the License for the specific language governing permissions and
|
|
18115
|
+
* limitations under the License.
|
|
18116
|
+
*/
|
|
18117
|
+
const paragraphSettingIndexKey$1 = "doc_ui_paragraph-setting-panel";
|
|
18118
|
+
let DocParagraphSettingController = class DocParagraphSettingController extends _univerjs_core.Disposable {
|
|
18119
|
+
constructor(_commandService, _sidebarService) {
|
|
18120
|
+
super();
|
|
18121
|
+
this._commandService = _commandService;
|
|
18122
|
+
this._sidebarService = _sidebarService;
|
|
18123
|
+
_defineProperty(this, "_id", void 0);
|
|
18124
|
+
}
|
|
18125
|
+
openPanel() {
|
|
18126
|
+
const props = {
|
|
18127
|
+
header: { title: "docs-ui.doc.slider.paragraphSetting" },
|
|
18128
|
+
id: this._id,
|
|
18129
|
+
children: { label: paragraphSettingIndexKey$1 },
|
|
18130
|
+
width: 300
|
|
18131
|
+
};
|
|
18132
|
+
this._sidebarService.open(props);
|
|
18133
|
+
}
|
|
18134
|
+
closePanel() {
|
|
18135
|
+
this._sidebarService.close(this._id);
|
|
18136
|
+
}
|
|
18137
|
+
};
|
|
18138
|
+
DocParagraphSettingController = __decorate([__decorateParam(0, _univerjs_core.ICommandService), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService))], DocParagraphSettingController);
|
|
18139
|
+
|
|
18140
|
+
//#endregion
|
|
18141
|
+
//#region src/commands/operations/doc-paragraph-setting-panel.operation.ts
|
|
18142
|
+
const DocParagraphSettingPanelOperation = {
|
|
18143
|
+
id: "sidebar.operation.doc-paragraph-setting-panel",
|
|
18144
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
18145
|
+
handler: (accessor) => {
|
|
18146
|
+
accessor.get(DocParagraphSettingController).openPanel();
|
|
18147
|
+
return true;
|
|
18148
|
+
}
|
|
18149
|
+
};
|
|
18150
|
+
|
|
18151
|
+
//#endregion
|
|
18152
|
+
//#region src/views/section-setting/component-name.ts
|
|
18153
|
+
/**
|
|
18154
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
18155
|
+
*
|
|
18156
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
18157
|
+
* you may not use this file except in compliance with the License.
|
|
18158
|
+
* You may obtain a copy of the License at
|
|
18159
|
+
*
|
|
18160
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18161
|
+
*
|
|
18162
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18163
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18164
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18165
|
+
* See the License for the specific language governing permissions and
|
|
18166
|
+
* limitations under the License.
|
|
18167
|
+
*/
|
|
18168
|
+
const DOC_SECTION_SETTING_COMPONENT = "doc_ui_section-setting-panel";
|
|
18169
|
+
|
|
18170
|
+
//#endregion
|
|
18171
|
+
//#region src/controllers/doc-section-setting.controller.ts
|
|
18172
|
+
/**
|
|
18173
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
18174
|
+
*
|
|
18175
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
18176
|
+
* you may not use this file except in compliance with the License.
|
|
18177
|
+
* You may obtain a copy of the License at
|
|
18178
|
+
*
|
|
18179
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18180
|
+
*
|
|
18181
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18182
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18183
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18184
|
+
* See the License for the specific language governing permissions and
|
|
18185
|
+
* limitations under the License.
|
|
18186
|
+
*/
|
|
18187
|
+
let DocSectionSettingController = class DocSectionSettingController extends _univerjs_core.Disposable {
|
|
18188
|
+
constructor(_sidebarService, _selectionManager) {
|
|
18189
|
+
super();
|
|
18190
|
+
this._sidebarService = _sidebarService;
|
|
18191
|
+
this._selectionManager = _selectionManager;
|
|
18192
|
+
_defineProperty(this, "_panelId", "DocSectionSetting");
|
|
18193
|
+
}
|
|
18194
|
+
openPanel() {
|
|
18195
|
+
this._sidebarService.open({
|
|
18196
|
+
header: { title: "docs-ui.doc.slider.sectionSetting" },
|
|
18197
|
+
id: this._panelId,
|
|
18198
|
+
children: { label: DOC_SECTION_SETTING_COMPONENT },
|
|
18199
|
+
width: 300
|
|
18200
|
+
});
|
|
18201
|
+
}
|
|
18202
|
+
closePanel() {
|
|
18203
|
+
this._sidebarService.close(this._panelId);
|
|
18204
|
+
}
|
|
18205
|
+
navigateToSectionEnd(unitId, sectionStart, sectionEnd) {
|
|
18206
|
+
const params = {
|
|
18207
|
+
unitId,
|
|
18208
|
+
subUnitId: unitId
|
|
18209
|
+
};
|
|
18210
|
+
const cursorOffset = Math.max(sectionStart, sectionEnd - 1);
|
|
18211
|
+
this._selectionManager.replaceDocRanges([{
|
|
18212
|
+
startOffset: cursorOffset,
|
|
18213
|
+
endOffset: cursorOffset
|
|
18214
|
+
}], params, true, { shouldFocus: false });
|
|
18215
|
+
}
|
|
18216
|
+
};
|
|
18217
|
+
DocSectionSettingController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService))], DocSectionSettingController);
|
|
18218
|
+
|
|
18219
|
+
//#endregion
|
|
18220
|
+
//#region src/commands/operations/doc-section-setting-panel.operation.ts
|
|
18221
|
+
const DocSectionSettingPanelOperation = {
|
|
18222
|
+
id: "sidebar.operation.doc-section-setting-panel",
|
|
18223
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
18224
|
+
handler: (accessor) => {
|
|
18225
|
+
accessor.get(DocSectionSettingController).openPanel();
|
|
18226
|
+
return true;
|
|
18227
|
+
}
|
|
18228
|
+
};
|
|
18229
|
+
|
|
17766
18230
|
//#endregion
|
|
17767
18231
|
//#region src/menu/context-menu.ts
|
|
17768
18232
|
const getDisableOnCollapsedObservable = (accessor) => {
|
|
@@ -18046,6 +18510,46 @@ function PasteRibbonMenuFactory(accessor) {
|
|
|
18046
18510
|
};
|
|
18047
18511
|
}
|
|
18048
18512
|
|
|
18513
|
+
//#endregion
|
|
18514
|
+
//#region src/menu/display.menu.ts
|
|
18515
|
+
const DOC_ZOOM_RATIO_MENU_ID = "doc.menu.zoom-ratio";
|
|
18516
|
+
function DocZoomRatioMenuItemFactory(accessor) {
|
|
18517
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
18518
|
+
const instanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
18519
|
+
return {
|
|
18520
|
+
id: DOC_ZOOM_RATIO_MENU_ID,
|
|
18521
|
+
type: _univerjs_ui.MenuItemType.SELECTOR,
|
|
18522
|
+
icon: "ZoomInIcon",
|
|
18523
|
+
tooltip: "docs-ui.toolbar.zoom",
|
|
18524
|
+
selectionsCommandId: SetDocZoomRatioOperation.id,
|
|
18525
|
+
selections: DOC_ZOOM_SHORTCUTS.map((value) => ({
|
|
18526
|
+
value,
|
|
18527
|
+
label: `${value}%`,
|
|
18528
|
+
params: () => {
|
|
18529
|
+
var _instanceService$getC;
|
|
18530
|
+
return {
|
|
18531
|
+
unitId: (_instanceService$getC = instanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC)) === null || _instanceService$getC === void 0 ? void 0 : _instanceService$getC.getUnitId(),
|
|
18532
|
+
zoomRatio: value / 100
|
|
18533
|
+
};
|
|
18534
|
+
}
|
|
18535
|
+
})),
|
|
18536
|
+
value$: getDocZoomRatio$(commandService, instanceService),
|
|
18537
|
+
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC)
|
|
18538
|
+
};
|
|
18539
|
+
}
|
|
18540
|
+
function DocFullscreenMenuItemFactory(accessor) {
|
|
18541
|
+
const root = accessor.get(_univerjs_ui.ILayoutService).rootContainerElement;
|
|
18542
|
+
const fullscreen$ = root ? (0, rxjs.merge)((0, rxjs.of)(null), (0, rxjs.fromEvent)(root.ownerDocument, "fullscreenchange")).pipe((0, rxjs.map)(() => root.ownerDocument.fullscreenElement === root), (0, rxjs.distinctUntilChanged)()) : (0, rxjs.of)(false);
|
|
18543
|
+
return {
|
|
18544
|
+
id: _univerjs_ui.ToggleFullscreenOperation.id,
|
|
18545
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
18546
|
+
tooltip: "docs-ui.toolbar.fullscreen",
|
|
18547
|
+
icon: fullscreen$.pipe((0, rxjs.map)((fullscreen) => fullscreen ? "ShrinkIcon" : "ExpandIcon")),
|
|
18548
|
+
activated$: fullscreen$,
|
|
18549
|
+
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC)
|
|
18550
|
+
};
|
|
18551
|
+
}
|
|
18552
|
+
|
|
18049
18553
|
//#endregion
|
|
18050
18554
|
//#region src/views/paragraph-menu/theme-color.ts
|
|
18051
18555
|
function getHighlightBackgroundColor(themeService, index) {
|
|
@@ -18454,7 +18958,7 @@ function ParagraphMenuInsertBelowSubmenuItemFactory(accessor) {
|
|
|
18454
18958
|
return {
|
|
18455
18959
|
id: DOC_PARAGRAPH_T_INSERT_BELOW_MENU_ID,
|
|
18456
18960
|
type: _univerjs_ui.MenuItemType.SUBITEMS,
|
|
18457
|
-
icon: "
|
|
18961
|
+
icon: "InsertBelowDoubleIcon",
|
|
18458
18962
|
title: "docs-ui.rightClick.insertBellow",
|
|
18459
18963
|
tooltip: "docs-ui.rightClick.insertBellow",
|
|
18460
18964
|
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC)
|
|
@@ -18672,7 +19176,8 @@ const menuSchema = {
|
|
|
18672
19176
|
order: 0,
|
|
18673
19177
|
gridLayout: {
|
|
18674
19178
|
row: 2,
|
|
18675
|
-
column: 1
|
|
19179
|
+
column: 1,
|
|
19180
|
+
width: 44
|
|
18676
19181
|
},
|
|
18677
19182
|
menuItemFactory: BoldMenuItemFactory
|
|
18678
19183
|
},
|
|
@@ -18680,7 +19185,8 @@ const menuSchema = {
|
|
|
18680
19185
|
order: 1,
|
|
18681
19186
|
gridLayout: {
|
|
18682
19187
|
row: 2,
|
|
18683
|
-
column: 2
|
|
19188
|
+
column: 2,
|
|
19189
|
+
width: 44
|
|
18684
19190
|
},
|
|
18685
19191
|
menuItemFactory: ItalicMenuItemFactory
|
|
18686
19192
|
},
|
|
@@ -18688,7 +19194,8 @@ const menuSchema = {
|
|
|
18688
19194
|
order: 2,
|
|
18689
19195
|
gridLayout: {
|
|
18690
19196
|
row: 2,
|
|
18691
|
-
column: 3
|
|
19197
|
+
column: 3,
|
|
19198
|
+
width: 44
|
|
18692
19199
|
},
|
|
18693
19200
|
menuItemFactory: UnderlineMenuItemFactory
|
|
18694
19201
|
},
|
|
@@ -18696,7 +19203,8 @@ const menuSchema = {
|
|
|
18696
19203
|
order: 3,
|
|
18697
19204
|
gridLayout: {
|
|
18698
19205
|
row: 2,
|
|
18699
|
-
column: 4
|
|
19206
|
+
column: 4,
|
|
19207
|
+
width: 44
|
|
18700
19208
|
},
|
|
18701
19209
|
menuItemFactory: StrikeThroughMenuItemFactory
|
|
18702
19210
|
},
|
|
@@ -18704,7 +19212,8 @@ const menuSchema = {
|
|
|
18704
19212
|
order: 4,
|
|
18705
19213
|
gridLayout: {
|
|
18706
19214
|
row: 2,
|
|
18707
|
-
column:
|
|
19215
|
+
column: 6,
|
|
19216
|
+
width: 44
|
|
18708
19217
|
},
|
|
18709
19218
|
menuItemFactory: SubscriptMenuItemFactory
|
|
18710
19219
|
},
|
|
@@ -18712,7 +19221,8 @@ const menuSchema = {
|
|
|
18712
19221
|
order: 5,
|
|
18713
19222
|
gridLayout: {
|
|
18714
19223
|
row: 2,
|
|
18715
|
-
column:
|
|
19224
|
+
column: 5,
|
|
19225
|
+
width: 44
|
|
18716
19226
|
},
|
|
18717
19227
|
menuItemFactory: SuperscriptMenuItemFactory
|
|
18718
19228
|
},
|
|
@@ -18722,7 +19232,7 @@ const menuSchema = {
|
|
|
18722
19232
|
row: 1,
|
|
18723
19233
|
column: 1,
|
|
18724
19234
|
columnSpan: 2,
|
|
18725
|
-
width:
|
|
19235
|
+
width: 96
|
|
18726
19236
|
},
|
|
18727
19237
|
menuItemFactory: HeadingSelectorMenuItemFactory
|
|
18728
19238
|
},
|
|
@@ -18731,7 +19241,8 @@ const menuSchema = {
|
|
|
18731
19241
|
gridLayout: {
|
|
18732
19242
|
row: 1,
|
|
18733
19243
|
column: 7,
|
|
18734
|
-
|
|
19244
|
+
columnSpan: 2,
|
|
19245
|
+
width: 96
|
|
18735
19246
|
},
|
|
18736
19247
|
menuItemFactory: FontSizeSelectorMenuItemFactory
|
|
18737
19248
|
},
|
|
@@ -18741,7 +19252,7 @@ const menuSchema = {
|
|
|
18741
19252
|
row: 1,
|
|
18742
19253
|
column: 3,
|
|
18743
19254
|
columnSpan: 4,
|
|
18744
|
-
width:
|
|
19255
|
+
width: 200
|
|
18745
19256
|
},
|
|
18746
19257
|
menuItemFactory: FontFamilySelectorMenuItemFactory
|
|
18747
19258
|
},
|
|
@@ -18749,7 +19260,8 @@ const menuSchema = {
|
|
|
18749
19260
|
order: 8,
|
|
18750
19261
|
gridLayout: {
|
|
18751
19262
|
row: 2,
|
|
18752
|
-
column:
|
|
19263
|
+
column: 8,
|
|
19264
|
+
width: 44
|
|
18753
19265
|
},
|
|
18754
19266
|
menuItemFactory: TextColorSelectorMenuItemFactory,
|
|
18755
19267
|
[ResetInlineFormatTextColorCommand.id]: {
|
|
@@ -18761,7 +19273,8 @@ const menuSchema = {
|
|
|
18761
19273
|
order: 9,
|
|
18762
19274
|
gridLayout: {
|
|
18763
19275
|
row: 2,
|
|
18764
|
-
column:
|
|
19276
|
+
column: 7,
|
|
19277
|
+
width: 44
|
|
18765
19278
|
},
|
|
18766
19279
|
menuItemFactory: BackgroundColorSelectorMenuItemFactory,
|
|
18767
19280
|
[ResetInlineFormatTextBackgroundColorCommand.id]: {
|
|
@@ -18812,16 +19325,6 @@ const menuSchema = {
|
|
|
18812
19325
|
showLabel: true
|
|
18813
19326
|
},
|
|
18814
19327
|
menuItemFactory: HeaderFooterMenuItemFactory
|
|
18815
|
-
},
|
|
18816
|
-
[DocOpenPageSettingCommand.id]: {
|
|
18817
|
-
order: 12,
|
|
18818
|
-
gridLayout: {
|
|
18819
|
-
row: 1,
|
|
18820
|
-
column: 4,
|
|
18821
|
-
rowSpan: 2,
|
|
18822
|
-
showLabel: true
|
|
18823
|
-
},
|
|
18824
|
-
menuItemFactory: PageSettingMenuItemFactory
|
|
18825
19328
|
}
|
|
18826
19329
|
},
|
|
18827
19330
|
[_univerjs_ui.RibbonInsertGroup.MEDIA]: {
|
|
@@ -18893,7 +19396,35 @@ const menuSchema = {
|
|
|
18893
19396
|
row: 2,
|
|
18894
19397
|
column: 3
|
|
18895
19398
|
},
|
|
18896
|
-
menuItemFactory: SymbolPickerMenuItemFactory
|
|
19399
|
+
menuItemFactory: SymbolPickerMenuItemFactory
|
|
19400
|
+
}
|
|
19401
|
+
},
|
|
19402
|
+
[_univerjs_ui.RibbonViewGroup.DISPLAY]: {
|
|
19403
|
+
[DocOpenPageSettingCommand.id]: {
|
|
19404
|
+
order: 0,
|
|
19405
|
+
gridLayout: {
|
|
19406
|
+
row: 1,
|
|
19407
|
+
column: 1,
|
|
19408
|
+
rowSpan: 2,
|
|
19409
|
+
showLabel: true
|
|
19410
|
+
},
|
|
19411
|
+
menuItemFactory: PageSettingMenuItemFactory
|
|
19412
|
+
},
|
|
19413
|
+
[DOC_ZOOM_RATIO_MENU_ID]: {
|
|
19414
|
+
order: 1,
|
|
19415
|
+
gridLayout: {
|
|
19416
|
+
row: 1,
|
|
19417
|
+
column: 2
|
|
19418
|
+
},
|
|
19419
|
+
menuItemFactory: DocZoomRatioMenuItemFactory
|
|
19420
|
+
},
|
|
19421
|
+
[_univerjs_ui.ToggleFullscreenOperation.id]: {
|
|
19422
|
+
order: 2,
|
|
19423
|
+
gridLayout: {
|
|
19424
|
+
row: 2,
|
|
19425
|
+
column: 2
|
|
19426
|
+
},
|
|
19427
|
+
menuItemFactory: DocFullscreenMenuItemFactory
|
|
18897
19428
|
}
|
|
18898
19429
|
},
|
|
18899
19430
|
[_univerjs_ui.ContextMenuPosition.MAIN_AREA]: {
|
|
@@ -19520,6 +20051,9 @@ const menuSchema = {
|
|
|
19520
20051
|
|
|
19521
20052
|
//#endregion
|
|
19522
20053
|
//#region src/shortcuts/utils.ts
|
|
20054
|
+
function whenTextEditorFocused(contextService) {
|
|
20055
|
+
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));
|
|
20056
|
+
}
|
|
19523
20057
|
function whenDocAndEditorFocused(contextService) {
|
|
19524
20058
|
return contextService.getContextValue(_univerjs_core.FOCUSING_DOC) && contextService.getContextValue(_univerjs_core.FOCUSING_UNIVER_EDITOR) && !contextService.getContextValue(_univerjs_core.FOCUSING_COMMON_DRAWINGS);
|
|
19525
20059
|
}
|
|
@@ -19534,6 +20068,11 @@ const TabShortCut = {
|
|
|
19534
20068
|
binding: _univerjs_ui.KeyCode.TAB,
|
|
19535
20069
|
preconditions: whenDocAndEditorFocused
|
|
19536
20070
|
};
|
|
20071
|
+
const UpdateDocFieldsShortcut = {
|
|
20072
|
+
id: UpdateSelectedDocFieldsCommand.id,
|
|
20073
|
+
binding: _univerjs_ui.KeyCode.F9,
|
|
20074
|
+
preconditions: whenDocAndEditorFocused
|
|
20075
|
+
};
|
|
19537
20076
|
const ShiftTabShortCut = {
|
|
19538
20077
|
id: TabCommand.id,
|
|
19539
20078
|
binding: _univerjs_ui.KeyCode.TAB | _univerjs_ui.MetaKeys.SHIFT,
|
|
@@ -19606,45 +20145,23 @@ const BulletListShortCut = {
|
|
|
19606
20145
|
|
|
19607
20146
|
//#endregion
|
|
19608
20147
|
//#region src/views/count-bar/ZoomSlider.tsx
|
|
19609
|
-
const ZOOM_MAP = [
|
|
19610
|
-
50,
|
|
19611
|
-
80,
|
|
19612
|
-
100,
|
|
19613
|
-
130,
|
|
19614
|
-
150,
|
|
19615
|
-
170,
|
|
19616
|
-
200,
|
|
19617
|
-
400
|
|
19618
|
-
];
|
|
19619
20148
|
const DOC_ZOOM_RANGE = [10, 400];
|
|
19620
20149
|
function ZoomSlider() {
|
|
19621
20150
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
19622
20151
|
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
19623
|
-
const
|
|
19624
|
-
const getCurrentZoom = (0, react.useCallback)((docModel = documentDataModel) => {
|
|
19625
|
-
if (!docModel) return 100;
|
|
19626
|
-
return Math.round(getDocEffectiveZoomRatio(docModel) * 100);
|
|
19627
|
-
}, [documentDataModel]);
|
|
19628
|
-
const [zoom, setZoom] = (0, react.useState)(100);
|
|
19629
|
-
(0, react.useEffect)(() => setZoom(getCurrentZoom(documentDataModel)), [documentDataModel, getCurrentZoom]);
|
|
19630
|
-
(0, react.useEffect)(() => {
|
|
19631
|
-
return commandService.onCommandExecuted((commandInfo) => {
|
|
19632
|
-
if (commandInfo.id === SetDocZoomRatioOperation.id) setZoom(getCurrentZoom());
|
|
19633
|
-
}).dispose;
|
|
19634
|
-
}, [commandService, getCurrentZoom]);
|
|
20152
|
+
const zoom = (0, _univerjs_ui.useObservable)(() => getDocZoomRatio$(commandService, univerInstanceService), 100, void 0, [commandService, univerInstanceService]);
|
|
19635
20153
|
function handleChange(value) {
|
|
19636
|
-
|
|
20154
|
+
const documentDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
19637
20155
|
if (documentDataModel == null) return;
|
|
19638
|
-
|
|
19639
|
-
commandService.executeCommand(SetDocZoomRatioOperation.id, {
|
|
20156
|
+
return commandService.executeCommand(SetDocZoomRatioOperation.id, {
|
|
19640
20157
|
unitId: documentDataModel.getUnitId(),
|
|
19641
|
-
zoomRatio
|
|
20158
|
+
zoomRatio: value / 100
|
|
19642
20159
|
});
|
|
19643
20160
|
}
|
|
19644
20161
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_ui.Slider, {
|
|
19645
20162
|
min: DOC_ZOOM_RANGE[0],
|
|
19646
20163
|
value: zoom,
|
|
19647
|
-
shortcuts:
|
|
20164
|
+
shortcuts: DOC_ZOOM_SHORTCUTS,
|
|
19648
20165
|
onChange: handleChange
|
|
19649
20166
|
});
|
|
19650
20167
|
}
|
|
@@ -20543,21 +21060,6 @@ function DocSideMenuContent() {
|
|
|
20543
21060
|
|
|
20544
21061
|
//#endregion
|
|
20545
21062
|
//#region src/controllers/ui.controller.ts
|
|
20546
|
-
/**
|
|
20547
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
20548
|
-
*
|
|
20549
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
20550
|
-
* you may not use this file except in compliance with the License.
|
|
20551
|
-
* You may obtain a copy of the License at
|
|
20552
|
-
*
|
|
20553
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
20554
|
-
*
|
|
20555
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
20556
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20557
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20558
|
-
* See the License for the specific language governing permissions and
|
|
20559
|
-
* limitations under the License.
|
|
20560
|
-
*/
|
|
20561
21063
|
let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
20562
21064
|
constructor(_injector, _commandService, _layoutService, _menuManagerService, _uiPartsService, _univerInstanceService, _shortcutService, _configService, _embedInteractionBoundaryService, _embedRuntimeFocusCoordinator) {
|
|
20563
21065
|
super();
|
|
@@ -20579,6 +21081,7 @@ let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
|
20579
21081
|
_initMenus() {
|
|
20580
21082
|
this._menuManagerService.appendRootMenu(floatToolbarMenuSchema);
|
|
20581
21083
|
this._menuManagerService.mergeMenu(menuSchema);
|
|
21084
|
+
this._menuManagerService.mergeMenu(headerFooterRibbonSchema);
|
|
20582
21085
|
}
|
|
20583
21086
|
_initShortCut() {
|
|
20584
21087
|
[
|
|
@@ -20594,7 +21097,8 @@ let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
|
20594
21097
|
AlignLeftShortCut,
|
|
20595
21098
|
OrderListShortCut,
|
|
20596
21099
|
BulletListShortCut,
|
|
20597
|
-
TabShortCut
|
|
21100
|
+
TabShortCut,
|
|
21101
|
+
UpdateDocFieldsShortcut
|
|
20598
21102
|
].forEach((shortcut) => {
|
|
20599
21103
|
this.disposeWithMe(this._shortcutService.registerShortcut(shortcut));
|
|
20600
21104
|
});
|
|
@@ -20603,6 +21107,7 @@ let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
|
20603
21107
|
this._initMenus();
|
|
20604
21108
|
this._initFocusHandler();
|
|
20605
21109
|
this._initCommands();
|
|
21110
|
+
this._initDateTimeFields();
|
|
20606
21111
|
this._initUiParts();
|
|
20607
21112
|
this._initShortCut();
|
|
20608
21113
|
}
|
|
@@ -20611,10 +21116,25 @@ let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
|
20611
21116
|
OpenDocPermissionPanelOperation,
|
|
20612
21117
|
OpenDocParagraphPermissionOperation,
|
|
20613
21118
|
CoreHeaderFooterCommand,
|
|
21119
|
+
InsertHeaderFooterFieldCommand,
|
|
21120
|
+
RefreshHeaderFooterFieldsCommand,
|
|
21121
|
+
UpdateSelectedDocFieldsCommand,
|
|
20614
21122
|
OpenHeaderFooterPanelCommand,
|
|
20615
|
-
|
|
21123
|
+
DocHeaderFooterRibbonOperation
|
|
20616
21124
|
].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
|
|
20617
21125
|
}
|
|
21126
|
+
_initDateTimeFields() {
|
|
21127
|
+
const refreshed = /* @__PURE__ */ new WeakSet();
|
|
21128
|
+
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC).subscribe((model) => {
|
|
21129
|
+
if (model && !refreshed.has(model)) {
|
|
21130
|
+
refreshed.add(model);
|
|
21131
|
+
this._commandService.syncExecuteCommand(RefreshHeaderFooterFieldsCommand.id, {
|
|
21132
|
+
unitId: model.getUnitId(),
|
|
21133
|
+
onOpen: true
|
|
21134
|
+
});
|
|
21135
|
+
}
|
|
21136
|
+
}));
|
|
21137
|
+
}
|
|
20618
21138
|
_initFocusHandler() {
|
|
20619
21139
|
this.disposeWithMe(this._layoutService.registerFocusHandler(_univerjs_core.UniverInstanceType.UNIVER_DOC, (unitId) => {
|
|
20620
21140
|
if (this._shouldPreserveEmbedFocus(unitId)) return;
|
|
@@ -20912,7 +21432,7 @@ function resolveDocsCustomBlockRenderViewport(params) {
|
|
|
20912
21432
|
//#endregion
|
|
20913
21433
|
//#region package.json
|
|
20914
21434
|
var name = "@univerjs/docs-ui";
|
|
20915
|
-
var version = "1.0
|
|
21435
|
+
var version = "1.1.0";
|
|
20916
21436
|
|
|
20917
21437
|
//#endregion
|
|
20918
21438
|
//#region src/commands/commands/doc-paragraph-setting.command.ts
|
|
@@ -21159,8 +21679,8 @@ var HeaderFooterContentCover = class extends _univerjs_engine_render.BaseObject
|
|
|
21159
21679
|
right: pageLeft + page.pageWidth,
|
|
21160
21680
|
bottom: pageTop + page.pageHeight
|
|
21161
21681
|
});
|
|
21162
|
-
const header = (_data$skeHeaders$get = data.skeHeaders.get(page.headerId)) === null || _data$skeHeaders$get === void 0 ? void 0 : _data$skeHeaders$get.get(page.pageWidth);
|
|
21163
|
-
const footer = (_data$skeFooters$get = data.skeFooters.get(page.footerId)) === null || _data$skeFooters$get === void 0 ? void 0 : _data$skeFooters$get.get(page.pageWidth);
|
|
21682
|
+
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);
|
|
21683
|
+
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);
|
|
21164
21684
|
const local = [];
|
|
21165
21685
|
if (header) this._collectTextAndTables(header, pageLeft + page.marginLeft, pageTop + header.marginTop, local);
|
|
21166
21686
|
if (footer) this._collectTextAndTables(footer, pageLeft + page.marginLeft, pageTop + page.pageHeight - footer.height - footer.marginBottom, local);
|
|
@@ -21618,7 +22138,7 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
21618
22138
|
const body = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(normalizedSegmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
|
|
21619
22139
|
if (body == null) return;
|
|
21620
22140
|
const dataStreamLength = body.dataStream.length ?? Number.POSITIVE_INFINITY;
|
|
21621
|
-
const customRanges =
|
|
22141
|
+
const customRanges = body.customRanges ?? [];
|
|
21622
22142
|
if (granularity !== "character") {
|
|
21623
22143
|
const nextOffset = this._getCursorOffsetByGranularity(skeleton, focusOffset, direction, granularity, normalizedSegmentId, normalizedSegmentPage, dataStreamLength, body.dataStream);
|
|
21624
22144
|
if (nextOffset == null || nextOffset === focusOffset) return;
|
|
@@ -21690,7 +22210,7 @@ let DocMoveCursorController = class DocMoveCursorController extends _univerjs_co
|
|
|
21690
22210
|
const body = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(normalizedSegmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.getBody();
|
|
21691
22211
|
if (body == null) return;
|
|
21692
22212
|
const dataStreamLength = body.dataStream.length ?? Number.POSITIVE_INFINITY;
|
|
21693
|
-
const customRanges =
|
|
22213
|
+
const customRanges = body.customRanges ?? [];
|
|
21694
22214
|
if (granularity !== "character") {
|
|
21695
22215
|
let cursorOffset;
|
|
21696
22216
|
if (!activeRange.collapsed || allRanges.length > 1) {
|
|
@@ -22313,26 +22833,33 @@ function DocPasteOptions() {
|
|
|
22313
22833
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
22314
22834
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
22315
22835
|
const layoutService = (0, _univerjs_ui.useDependency)(_univerjs_ui.ILayoutService);
|
|
22836
|
+
const editorService = (0, _univerjs_ui.useDependency)(IEditorService);
|
|
22316
22837
|
const state = (0, _univerjs_ui.useObservable)(clipboard.pasteOptions$, null);
|
|
22317
22838
|
const [busy, setBusy] = (0, react.useState)(false);
|
|
22318
22839
|
const [open, setOpen] = (0, react.useState)(false);
|
|
22840
|
+
const focusEditor = () => {
|
|
22841
|
+
const editor = state && clipboard.isPasteOptionsEnabled(state.unitId) && editorService.getEditor(state.unitId);
|
|
22842
|
+
if (editor) editor.focus();
|
|
22843
|
+
else layoutService.focus();
|
|
22844
|
+
};
|
|
22319
22845
|
const changeMode = async (value) => {
|
|
22320
22846
|
setBusy(true);
|
|
22321
22847
|
try {
|
|
22322
22848
|
await commandService.executeCommand(DocChangePasteModeCommand.id, { value });
|
|
22323
22849
|
} finally {
|
|
22324
22850
|
setBusy(false);
|
|
22325
|
-
|
|
22851
|
+
focusEditor();
|
|
22326
22852
|
}
|
|
22327
22853
|
};
|
|
22328
22854
|
if (!state) return null;
|
|
22329
22855
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
|
|
22856
|
+
"data-u-editor-interaction-boundary": "true",
|
|
22330
22857
|
align: "start",
|
|
22331
22858
|
open,
|
|
22332
22859
|
onOpenChange: setOpen,
|
|
22333
22860
|
onCloseAutoFocus: (event) => {
|
|
22334
22861
|
event.preventDefault();
|
|
22335
|
-
|
|
22862
|
+
focusEditor();
|
|
22336
22863
|
},
|
|
22337
22864
|
onEscapeKeyDown: () => clipboard.dismissPasteOptions(),
|
|
22338
22865
|
items: DOC_PASTE_OPTIONS.map((option) => ({
|
|
@@ -22344,6 +22871,7 @@ function DocPasteOptions() {
|
|
|
22344
22871
|
onSelect: () => changeMode(option.value)
|
|
22345
22872
|
})),
|
|
22346
22873
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
|
|
22874
|
+
"data-u-editor-interaction-boundary": "true",
|
|
22347
22875
|
size: "small",
|
|
22348
22876
|
disabled: busy,
|
|
22349
22877
|
"aria-label": localeService.t("docs-ui.pasteOptions.title"),
|
|
@@ -22352,7 +22880,7 @@ function DocPasteOptions() {
|
|
|
22352
22880
|
onKeyDown: (event) => {
|
|
22353
22881
|
if (event.key === "Escape") {
|
|
22354
22882
|
clipboard.dismissPasteOptions();
|
|
22355
|
-
|
|
22883
|
+
focusEditor();
|
|
22356
22884
|
}
|
|
22357
22885
|
},
|
|
22358
22886
|
className: "univer-shadow-sm",
|
|
@@ -22611,28 +23139,37 @@ function useHeaderFooterOptions(unitId) {
|
|
|
22611
23139
|
page
|
|
22612
23140
|
};
|
|
22613
23141
|
};
|
|
22614
|
-
const [
|
|
22615
|
-
|
|
22616
|
-
const
|
|
22617
|
-
|
|
22618
|
-
|
|
22619
|
-
|
|
22620
|
-
|
|
22621
|
-
|
|
23142
|
+
const [, refresh] = (0, react.useReducer)((revision) => revision + 1, 0);
|
|
23143
|
+
(0, react.useEffect)(() => {
|
|
23144
|
+
const commandListener = commandService.onCommandExecuted((command) => {
|
|
23145
|
+
var _command$params;
|
|
23146
|
+
if (command.id === _univerjs_docs.RichTextEditingMutation.id && ((_command$params = command.params) === null || _command$params === void 0 ? void 0 : _command$params.unitId) === unitId) refresh();
|
|
23147
|
+
});
|
|
23148
|
+
const segmentListener = docSelectionRenderService.segmentContext$.subscribe(() => refresh());
|
|
23149
|
+
return () => {
|
|
23150
|
+
commandListener.dispose();
|
|
23151
|
+
segmentListener.unsubscribe();
|
|
22622
23152
|
};
|
|
22623
|
-
}
|
|
23153
|
+
}, [
|
|
23154
|
+
commandService,
|
|
23155
|
+
docSelectionRenderService,
|
|
23156
|
+
unitId
|
|
23157
|
+
]);
|
|
22624
23158
|
const sectionContext = getCurrentSectionContext();
|
|
23159
|
+
const config = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config;
|
|
23160
|
+
const options = {
|
|
23161
|
+
marginHeader: (config === null || config === void 0 ? void 0 : config.marginHeader) ?? 0,
|
|
23162
|
+
marginFooter: (config === null || config === void 0 ? void 0 : config.marginFooter) ?? 0,
|
|
23163
|
+
useFirstPageHeaderFooter: (config === null || config === void 0 ? void 0 : config.useFirstPageHeaderFooter) ?? _univerjs_core.BooleanNumber.FALSE,
|
|
23164
|
+
evenAndOddHeaders: (config === null || config === void 0 ? void 0 : config.evenAndOddHeaders) ?? _univerjs_core.BooleanNumber.FALSE
|
|
23165
|
+
};
|
|
22625
23166
|
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";
|
|
22626
23167
|
const variant = getHeaderFooterVariant((sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config) ?? {}, docSelectionRenderService.getSegmentPage(), sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page);
|
|
22627
23168
|
const referenceKey = (0, _univerjs_core.getSectionHeaderFooterReferenceKey)(headerFooterKind, variant);
|
|
22628
23169
|
const canLinkToPrevious = ((sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionIndex) ?? -1) > 0;
|
|
22629
|
-
const
|
|
22630
|
-
const handleCheckboxChange = (val, type) => {
|
|
23170
|
+
const linkedToPrevious = canLinkToPrevious && !(sectionContext === null || sectionContext === void 0 || (_sectionContext$secti = sectionContext.section) === null || _sectionContext$secti === void 0 ? void 0 : _sectionContext$secti[referenceKey]);
|
|
23171
|
+
const handleCheckboxChange = async (val, type) => {
|
|
22631
23172
|
var _renderManagerService3;
|
|
22632
|
-
setOptions((prev) => ({
|
|
22633
|
-
...prev,
|
|
22634
|
-
[type]: val ? _univerjs_core.BooleanNumber.TRUE : _univerjs_core.BooleanNumber.FALSE
|
|
22635
|
-
}));
|
|
22636
23173
|
const sectionContext = getCurrentSectionContext();
|
|
22637
23174
|
const documentStyle = sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.config;
|
|
22638
23175
|
const docSkeletonManagerService = (_renderManagerService3 = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService3 === void 0 ? void 0 : _renderManagerService3.with(_univerjs_docs.DocSkeletonManagerService);
|
|
@@ -22657,7 +23194,7 @@ function useHeaderFooterOptions(unitId) {
|
|
|
22657
23194
|
if (needCreateHeaderFooter) {
|
|
22658
23195
|
const segmentId = (0, _univerjs_core.generateRandomId)(6);
|
|
22659
23196
|
if (needChangeSegmentId) docSelectionRenderService.setSegment(segmentId);
|
|
22660
|
-
commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
23197
|
+
await commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
22661
23198
|
unitId,
|
|
22662
23199
|
segmentId,
|
|
22663
23200
|
headerFooterProps: { [type]: val ? _univerjs_core.BooleanNumber.TRUE : _univerjs_core.BooleanNumber.FALSE },
|
|
@@ -22671,7 +23208,7 @@ function useHeaderFooterOptions(unitId) {
|
|
|
22671
23208
|
[type]: val ? _univerjs_core.BooleanNumber.TRUE : _univerjs_core.BooleanNumber.FALSE
|
|
22672
23209
|
}, editArea, segmentPageIndex, sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.page);
|
|
22673
23210
|
if (needFocusSegmentId && needFocusSegmentId !== prevSegmentId) docSelectionRenderService.setSegment(needFocusSegmentId);
|
|
22674
|
-
commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
23211
|
+
await commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
22675
23212
|
unitId,
|
|
22676
23213
|
headerFooterProps: { [type]: val ? _univerjs_core.BooleanNumber.TRUE : _univerjs_core.BooleanNumber.FALSE },
|
|
22677
23214
|
sectionId: sectionContext === null || sectionContext === void 0 ? void 0 : sectionContext.sectionId
|
|
@@ -22680,21 +23217,16 @@ function useHeaderFooterOptions(unitId) {
|
|
|
22680
23217
|
layoutService.focus();
|
|
22681
23218
|
};
|
|
22682
23219
|
const handleMarginChange = async (val, type) => {
|
|
22683
|
-
var
|
|
22684
|
-
setOptions((prev) => ({
|
|
22685
|
-
...prev,
|
|
22686
|
-
[type]: val
|
|
22687
|
-
}));
|
|
23220
|
+
var _getCurrentSectionCon;
|
|
22688
23221
|
await commandService.executeCommand(CoreHeaderFooterCommandId, {
|
|
22689
23222
|
unitId,
|
|
22690
23223
|
headerFooterProps: { [type]: val },
|
|
22691
|
-
sectionId: (
|
|
23224
|
+
sectionId: (_getCurrentSectionCon = getCurrentSectionContext()) === null || _getCurrentSectionCon === void 0 ? void 0 : _getCurrentSectionCon.sectionId
|
|
22692
23225
|
});
|
|
22693
|
-
docSelectionRenderService.removeAllRanges();
|
|
22694
23226
|
docSelectionRenderService.blur();
|
|
22695
23227
|
};
|
|
22696
23228
|
const closeHeaderFooter = () => {
|
|
22697
|
-
commandService.executeCommand(CloseHeaderFooterCommand.id, { unitId });
|
|
23229
|
+
return commandService.executeCommand(CloseHeaderFooterCommand.id, { unitId });
|
|
22698
23230
|
};
|
|
22699
23231
|
const handleLinkToPreviousChange = async (linked) => {
|
|
22700
23232
|
var _renderManagerService4;
|
|
@@ -22713,7 +23245,6 @@ function useHeaderFooterOptions(unitId) {
|
|
|
22713
23245
|
linkedToPrevious: linked,
|
|
22714
23246
|
...linked ? {} : { segmentId }
|
|
22715
23247
|
})) return;
|
|
22716
|
-
setLinkedToPrevious(linked);
|
|
22717
23248
|
docSelectionRenderService.setSegment(linked ? previousSegmentId ?? "" : segmentId);
|
|
22718
23249
|
layoutService.focus();
|
|
22719
23250
|
};
|
|
@@ -24089,6 +24620,7 @@ let MobileComponentsController = class MobileComponentsController extends _unive
|
|
|
24089
24620
|
H5Icon: _univerjs_icons.H5Icon,
|
|
24090
24621
|
HeaderFooterIcon: _univerjs_icons.HeaderFooterIcon,
|
|
24091
24622
|
HorizontallyIcon: _univerjs_icons.HorizontallyIcon,
|
|
24623
|
+
InsertBelowDoubleIcon: _univerjs_icons.InsertBelowDoubleIcon,
|
|
24092
24624
|
InsertDoubleIcon: _univerjs_icons.InsertDoubleIcon,
|
|
24093
24625
|
InsertRowAboveDoubleIcon: _univerjs_icons.InsertRowAboveDoubleIcon,
|
|
24094
24626
|
InsertRowBelowDoubleIcon: _univerjs_icons.InsertRowBelowDoubleIcon,
|
|
@@ -24121,6 +24653,7 @@ let MobileComponentsController = class MobileComponentsController extends _unive
|
|
|
24121
24653
|
TodoListDoubleIcon: _univerjs_icons.TodoListDoubleIcon,
|
|
24122
24654
|
UnderlineIcon: _univerjs_icons.UnderlineIcon,
|
|
24123
24655
|
UnorderIcon: _univerjs_icons.UnorderIcon,
|
|
24656
|
+
ZoomInIcon: _univerjs_icons.ZoomInIcon,
|
|
24124
24657
|
DefaultTextColorIcon,
|
|
24125
24658
|
HeaderTextColorIcon,
|
|
24126
24659
|
MoreRightIcon: _univerjs_icons.MoreRightIcon,
|
|
@@ -25415,9 +25948,9 @@ let DocPasteOptionsRenderController = class DocPasteOptionsRenderController exte
|
|
|
25415
25948
|
this._context = _context;
|
|
25416
25949
|
this._clipboard = _clipboard;
|
|
25417
25950
|
_defineProperty(this, "_popup", void 0);
|
|
25418
|
-
if ((0, _univerjs_core.isInternalEditorID)(_context.unitId)) return;
|
|
25419
25951
|
const mobile = contextService.getContextValue(_univerjs_ui.MOBILE_UI_MODE) === true;
|
|
25420
25952
|
this.disposeWithMe(selection.onKeydown$.subscribe(({ event }) => {
|
|
25953
|
+
if (!this._clipboard.isPasteOptionsEnabled(this._context.unitId)) return;
|
|
25421
25954
|
const key = event;
|
|
25422
25955
|
if ((key.ctrlKey || key.metaKey) && key.shiftKey && key.key.toLowerCase() === "v") this._clipboard.setNextPasteMode("text");
|
|
25423
25956
|
else if (![
|
|
@@ -25430,12 +25963,17 @@ let DocPasteOptionsRenderController = class DocPasteOptionsRenderController exte
|
|
|
25430
25963
|
this._clipboard.dismissPasteOptions();
|
|
25431
25964
|
}
|
|
25432
25965
|
}));
|
|
25433
|
-
this.disposeWithMe(selection.onInputBefore$.subscribe(() =>
|
|
25966
|
+
this.disposeWithMe(selection.onInputBefore$.subscribe(() => {
|
|
25967
|
+
if (this._clipboard.isPasteOptionsEnabled(this._context.unitId)) this._clipboard.dismissPasteOptions();
|
|
25968
|
+
}));
|
|
25434
25969
|
this.disposeWithMe(selection.onPointerDown$.subscribe(() => {
|
|
25970
|
+
if (!this._clipboard.isPasteOptionsEnabled(this._context.unitId)) return;
|
|
25435
25971
|
this._clipboard.setNextPasteMode("source");
|
|
25436
25972
|
if (!mobile) this._clipboard.dismissPasteOptions();
|
|
25437
25973
|
}));
|
|
25438
|
-
this.disposeWithMe(selection.onBlur$.subscribe(() =>
|
|
25974
|
+
this.disposeWithMe(selection.onBlur$.subscribe(() => {
|
|
25975
|
+
if (this._clipboard.isPasteOptionsEnabled(this._context.unitId)) this._clipboard.setNextPasteMode("source");
|
|
25976
|
+
}));
|
|
25439
25977
|
this.disposeWithMe(this._clipboard.pasteOptions$.subscribe((state) => {
|
|
25440
25978
|
var _this$_popup;
|
|
25441
25979
|
(_this$_popup = this._popup) === null || _this$_popup === void 0 || _this$_popup.dispose();
|
|
@@ -25455,7 +25993,7 @@ let DocPasteOptionsRenderController = class DocPasteOptionsRenderController exte
|
|
|
25455
25993
|
this.disposeWithMe(() => {
|
|
25456
25994
|
var _this$_popup2;
|
|
25457
25995
|
(_this$_popup2 = this._popup) === null || _this$_popup2 === void 0 || _this$_popup2.dispose();
|
|
25458
|
-
this._clipboard.dismissPasteOptions();
|
|
25996
|
+
if (this._popup) this._clipboard.dismissPasteOptions();
|
|
25459
25997
|
});
|
|
25460
25998
|
}
|
|
25461
25999
|
};
|
|
@@ -26492,8 +27030,8 @@ var DocPrintInterceptorService = class extends _univerjs_core.Disposable {
|
|
|
26492
27030
|
const page = data.pages[pageIndex];
|
|
26493
27031
|
if (!page) return drawingIds;
|
|
26494
27032
|
collectPageDrawingIds(page, drawingIds);
|
|
26495
|
-
const header = (_data$skeHeaders$get = data.skeHeaders.get(page.headerId)) === null || _data$skeHeaders$get === void 0 ? void 0 : _data$skeHeaders$get.get(page.pageWidth);
|
|
26496
|
-
const footer = (_data$skeFooters$get = data.skeFooters.get(page.footerId)) === null || _data$skeFooters$get === void 0 ? void 0 : _data$skeFooters$get.get(page.pageWidth);
|
|
27033
|
+
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);
|
|
27034
|
+
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);
|
|
26497
27035
|
if (header) collectPageDrawingIds(header, drawingIds);
|
|
26498
27036
|
if (footer) collectPageDrawingIds(footer, drawingIds);
|
|
26499
27037
|
return drawingIds;
|
|
@@ -27494,6 +28032,319 @@ UniverDocsMobileUIPlugin = __decorate([
|
|
|
27494
28032
|
__decorateParam(4, _univerjs_core.IConfigService)
|
|
27495
28033
|
], UniverDocsMobileUIPlugin);
|
|
27496
28034
|
|
|
28035
|
+
//#endregion
|
|
28036
|
+
//#region src/views/header-footer/panel/DocHeaderFooterFields.tsx
|
|
28037
|
+
function DocHeaderFooterFields({ unitId, disabled }) {
|
|
28038
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
28039
|
+
(0, _univerjs_ui.useObservable)(localeService.currentLocale$);
|
|
28040
|
+
const commands = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
28041
|
+
const layout = (0, _univerjs_ui.useDependency)(_univerjs_ui.ILayoutService);
|
|
28042
|
+
const shortcuts = (0, _univerjs_ui.useDependency)(_univerjs_ui.IShortcutService);
|
|
28043
|
+
const selections = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocSelectionManagerService);
|
|
28044
|
+
const instances = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
28045
|
+
const [target, setTarget] = (0, react.useState)(null);
|
|
28046
|
+
const [format, setFormat] = (0, react.useState)("short");
|
|
28047
|
+
const [automatic, setAutomatic] = (0, react.useState)(true);
|
|
28048
|
+
const [error, setError] = (0, react.useState)(false);
|
|
28049
|
+
const [previewDate, setPreviewDate] = (0, react.useState)(() => /* @__PURE__ */ new Date());
|
|
28050
|
+
const locale = _univerjs_core.LOCALE_META[localeService.getCurrentLocale()].tag;
|
|
28051
|
+
const dialogOpen = target !== null;
|
|
28052
|
+
const dialogFocusRef = (0, react.useRef)(null);
|
|
28053
|
+
(0, react.useEffect)(() => {
|
|
28054
|
+
var _instances$getFocused;
|
|
28055
|
+
if (dialogOpen) return;
|
|
28056
|
+
const focus = dialogFocusRef.current;
|
|
28057
|
+
dialogFocusRef.current = null;
|
|
28058
|
+
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);
|
|
28059
|
+
}, [
|
|
28060
|
+
dialogOpen,
|
|
28061
|
+
instances,
|
|
28062
|
+
layout,
|
|
28063
|
+
unitId
|
|
28064
|
+
]);
|
|
28065
|
+
(0, react.useEffect)(() => {
|
|
28066
|
+
if (!dialogOpen) return;
|
|
28067
|
+
const escape = shortcuts.forceEscape();
|
|
28068
|
+
return () => escape.dispose();
|
|
28069
|
+
}, [dialogOpen, shortcuts]);
|
|
28070
|
+
function restoreFocus(event) {
|
|
28071
|
+
event.preventDefault();
|
|
28072
|
+
layout.focus(unitId);
|
|
28073
|
+
}
|
|
28074
|
+
function openDateTime() {
|
|
28075
|
+
var _instances$getUnit, _instances$getFocused2;
|
|
28076
|
+
const selection = selections.getActiveTextRange();
|
|
28077
|
+
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();
|
|
28078
|
+
if (!(selection === null || selection === void 0 ? void 0 : selection.segmentId) || !body) return;
|
|
28079
|
+
dialogFocusRef.current = {
|
|
28080
|
+
unitId,
|
|
28081
|
+
focusedUnitId: (_instances$getFocused2 = instances.getFocusedUnit()) === null || _instances$getFocused2 === void 0 ? void 0 : _instances$getFocused2.getUnitId()
|
|
28082
|
+
};
|
|
28083
|
+
setTarget({
|
|
28084
|
+
unitId,
|
|
28085
|
+
selection: { ...selection },
|
|
28086
|
+
segmentId: selection.segmentId,
|
|
28087
|
+
segmentPage: selection.segmentPage,
|
|
28088
|
+
expectedDataStream: body.dataStream
|
|
28089
|
+
});
|
|
28090
|
+
setPreviewDate(/* @__PURE__ */ new Date());
|
|
28091
|
+
setError(false);
|
|
28092
|
+
}
|
|
28093
|
+
async function insertDateTime() {
|
|
28094
|
+
if (!target) return;
|
|
28095
|
+
if (await commands.executeCommand(InsertHeaderFooterFieldCommand.id, {
|
|
28096
|
+
...target,
|
|
28097
|
+
fieldType: format === "time" ? "TIME" : "DATE",
|
|
28098
|
+
format,
|
|
28099
|
+
automatic
|
|
28100
|
+
})) setTarget(null);
|
|
28101
|
+
else setError(true);
|
|
28102
|
+
}
|
|
28103
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
28104
|
+
className: "univer-flex univer-flex-col univer-gap-1 univer-text-xs",
|
|
28105
|
+
children: [
|
|
28106
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
|
|
28107
|
+
onCloseAutoFocus: restoreFocus,
|
|
28108
|
+
disabled,
|
|
28109
|
+
items: [
|
|
28110
|
+
{
|
|
28111
|
+
type: "item",
|
|
28112
|
+
children: localeService.t("docs-ui.headerFooter.currentPage"),
|
|
28113
|
+
onSelect: () => commands.executeCommand(InsertHeaderFooterFieldCommand.id, {
|
|
28114
|
+
unitId,
|
|
28115
|
+
fieldType: "PAGE"
|
|
28116
|
+
})
|
|
28117
|
+
},
|
|
28118
|
+
{
|
|
28119
|
+
type: "item",
|
|
28120
|
+
children: localeService.t("docs-ui.headerFooter.totalPages"),
|
|
28121
|
+
onSelect: () => commands.executeCommand(InsertHeaderFooterFieldCommand.id, {
|
|
28122
|
+
unitId,
|
|
28123
|
+
fieldType: "NUMPAGES"
|
|
28124
|
+
})
|
|
28125
|
+
},
|
|
28126
|
+
{ type: "separator" },
|
|
28127
|
+
{
|
|
28128
|
+
type: "item",
|
|
28129
|
+
children: localeService.t("docs-ui.headerFooter.refreshFields"),
|
|
28130
|
+
onSelect: () => commands.executeCommand(RefreshHeaderFooterFieldsCommand.id, { unitId })
|
|
28131
|
+
}
|
|
28132
|
+
],
|
|
28133
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
|
|
28134
|
+
className: "univer-justify-start",
|
|
28135
|
+
"data-u-command": InsertHeaderFooterFieldCommand.id,
|
|
28136
|
+
size: "small",
|
|
28137
|
+
variant: "text",
|
|
28138
|
+
disabled,
|
|
28139
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
28140
|
+
children: [
|
|
28141
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.NumberIcon, { "aria-hidden": "true" }),
|
|
28142
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
28143
|
+
className: "univer-flex-1 univer-text-start",
|
|
28144
|
+
children: localeService.t("docs-ui.headerFooter.pageNumber")
|
|
28145
|
+
}),
|
|
28146
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { "aria-hidden": "true" })
|
|
28147
|
+
]
|
|
28148
|
+
})
|
|
28149
|
+
}),
|
|
28150
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
|
|
28151
|
+
className: "univer-justify-start",
|
|
28152
|
+
"data-u-command": InsertHeaderFooterFieldCommand.id,
|
|
28153
|
+
size: "small",
|
|
28154
|
+
variant: "text",
|
|
28155
|
+
disabled,
|
|
28156
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
28157
|
+
onClick: openDateTime,
|
|
28158
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CalendarIcon, { "aria-hidden": "true" }), localeService.t("docs-ui.headerFooter.dateTime")]
|
|
28159
|
+
}),
|
|
28160
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dialog, {
|
|
28161
|
+
open: dialogOpen,
|
|
28162
|
+
width: 360,
|
|
28163
|
+
title: localeService.t("docs-ui.headerFooter.dateTime"),
|
|
28164
|
+
showOk: true,
|
|
28165
|
+
showCancel: true,
|
|
28166
|
+
onClose: () => setTarget(null),
|
|
28167
|
+
onCancel: () => setTarget(null),
|
|
28168
|
+
onOk: insertDateTime,
|
|
28169
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
28170
|
+
className: "univer-flex univer-flex-col univer-gap-4",
|
|
28171
|
+
children: [
|
|
28172
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
|
|
28173
|
+
align: "start",
|
|
28174
|
+
className: "univer-w-[--radix-popper-anchor-width]",
|
|
28175
|
+
items: [{
|
|
28176
|
+
type: "radio",
|
|
28177
|
+
value: format,
|
|
28178
|
+
hideIndicator: true,
|
|
28179
|
+
onSelect: (value) => setFormat(value),
|
|
28180
|
+
options: [
|
|
28181
|
+
"short",
|
|
28182
|
+
"long",
|
|
28183
|
+
"time"
|
|
28184
|
+
].map((value) => ({
|
|
28185
|
+
value,
|
|
28186
|
+
label: createDateTimeField(value, locale, previewDate).cachedResult
|
|
28187
|
+
}))
|
|
28188
|
+
}],
|
|
28189
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
|
|
28190
|
+
"aria-label": localeService.t("docs-ui.headerFooter.dateTime"),
|
|
28191
|
+
className: _univerjs_design.selectClassName,
|
|
28192
|
+
"data-u-comp": "select",
|
|
28193
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
28194
|
+
className: "univer-flex-1 univer-truncate univer-text-start",
|
|
28195
|
+
children: createDateTimeField(format, locale, previewDate).cachedResult
|
|
28196
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { "aria-hidden": "true" })]
|
|
28197
|
+
})
|
|
28198
|
+
}),
|
|
28199
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
28200
|
+
checked: automatic,
|
|
28201
|
+
onChange: (value) => setAutomatic(Boolean(value)),
|
|
28202
|
+
children: localeService.t("docs-ui.headerFooter.updateAutomatically")
|
|
28203
|
+
}),
|
|
28204
|
+
error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
28205
|
+
role: "alert",
|
|
28206
|
+
children: localeService.t("docs-ui.headerFooter.insertFailed")
|
|
28207
|
+
})
|
|
28208
|
+
]
|
|
28209
|
+
})
|
|
28210
|
+
})
|
|
28211
|
+
]
|
|
28212
|
+
});
|
|
28213
|
+
}
|
|
28214
|
+
|
|
28215
|
+
//#endregion
|
|
28216
|
+
//#region src/views/header-footer/panel/DocHeaderFooterRibbonControl.tsx
|
|
28217
|
+
function DocHeaderFooterRibbonControl(props) {
|
|
28218
|
+
const instances = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
28219
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
28220
|
+
(0, _univerjs_ui.useObservable)(localeService.currentLocale$);
|
|
28221
|
+
const document = (0, _univerjs_ui.useObservable)(() => instances.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC), void 0, false, [instances]);
|
|
28222
|
+
const containerRef = (0, react.useRef)(null);
|
|
28223
|
+
const [compact, setCompact] = (0, react.useState)(false);
|
|
28224
|
+
const { kind } = props;
|
|
28225
|
+
(0, react.useEffect)(() => {
|
|
28226
|
+
var _containerRef$current;
|
|
28227
|
+
const toolbar = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.closest("[role=\"toolbar\"]");
|
|
28228
|
+
if (!toolbar || kind === "insertion") return;
|
|
28229
|
+
const thresholds = {
|
|
28230
|
+
position: 1100,
|
|
28231
|
+
options: 900,
|
|
28232
|
+
navigation: 650
|
|
28233
|
+
};
|
|
28234
|
+
const resize = () => setCompact(toolbar.getBoundingClientRect().width < thresholds[kind]);
|
|
28235
|
+
const observer = new ResizeObserver(resize);
|
|
28236
|
+
observer.observe(toolbar);
|
|
28237
|
+
return () => observer.disconnect();
|
|
28238
|
+
}, [kind, document]);
|
|
28239
|
+
if (!document) return null;
|
|
28240
|
+
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HeaderFooterRibbonControl, {
|
|
28241
|
+
...props,
|
|
28242
|
+
unitId: document.getUnitId()
|
|
28243
|
+
}, document.getUnitId());
|
|
28244
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
28245
|
+
ref: containerRef,
|
|
28246
|
+
"data-u-command": OpenHeaderFooterPanelCommand.id,
|
|
28247
|
+
className: "univer-flex univer-items-center univer-whitespace-nowrap",
|
|
28248
|
+
children: compact && kind !== "insertion" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
|
|
28249
|
+
items: [{
|
|
28250
|
+
type: "custom",
|
|
28251
|
+
className: "univer-p-2",
|
|
28252
|
+
children: content
|
|
28253
|
+
}],
|
|
28254
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
28255
|
+
"data-u-command": OpenHeaderFooterPanelCommand.id,
|
|
28256
|
+
size: "small",
|
|
28257
|
+
variant: "text",
|
|
28258
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
28259
|
+
children: localeService.t(`docs-ui.headerFooter.${kind}`)
|
|
28260
|
+
})
|
|
28261
|
+
}) : content
|
|
28262
|
+
});
|
|
28263
|
+
}
|
|
28264
|
+
function HeaderFooterRibbonControl({ kind, unitId }) {
|
|
28265
|
+
var _instances$getUnit, _renders$getRenderUni;
|
|
28266
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
28267
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
28268
|
+
const renders = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
|
|
28269
|
+
const permissionService = (0, _univerjs_ui.useDependency)(_univerjs_core.IPermissionService);
|
|
28270
|
+
(0, _univerjs_ui.useObservable)(permissionService.permissionPointUpdate$);
|
|
28271
|
+
const instances = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
28272
|
+
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);
|
|
28273
|
+
const { canLinkToPrevious, linkedToPrevious, options, handleLinkToPreviousChange, handleCheckboxChange, handleMarginChange } = useHeaderFooterOptions(unitId);
|
|
28274
|
+
const area = (_renders$getRenderUni = renders.getRenderUnitById(unitId)) === null || _renders$getRenderUni === void 0 ? void 0 : _renders$getRenderUni.with(_univerjs_docs.DocSkeletonManagerService).getViewModel().getEditArea();
|
|
28275
|
+
if (kind === "insertion") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocHeaderFooterFields, {
|
|
28276
|
+
unitId,
|
|
28277
|
+
disabled
|
|
28278
|
+
});
|
|
28279
|
+
if (kind === "navigation") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
28280
|
+
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",
|
|
28281
|
+
children: [
|
|
28282
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
28283
|
+
"data-u-command": OpenHeaderFooterPanelCommand.id,
|
|
28284
|
+
size: "small",
|
|
28285
|
+
variant: "text",
|
|
28286
|
+
disabled: disabled || area === _univerjs_engine_render.DocumentEditArea.HEADER,
|
|
28287
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
28288
|
+
onClick: () => commandService.executeCommand(OpenHeaderFooterPanelCommand.id, { editArea: _univerjs_engine_render.DocumentEditArea.HEADER }),
|
|
28289
|
+
children: localeService.t("docs-ui.headerFooter.goToHeader")
|
|
28290
|
+
}),
|
|
28291
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
28292
|
+
disabled: disabled || !canLinkToPrevious,
|
|
28293
|
+
checked: linkedToPrevious,
|
|
28294
|
+
onChange: (value) => handleLinkToPreviousChange(Boolean(value)),
|
|
28295
|
+
children: localeService.t("docs-ui.headerFooter.linkToPrevious")
|
|
28296
|
+
}),
|
|
28297
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
28298
|
+
"data-u-command": OpenHeaderFooterPanelCommand.id,
|
|
28299
|
+
size: "small",
|
|
28300
|
+
variant: "text",
|
|
28301
|
+
disabled: disabled || area === _univerjs_engine_render.DocumentEditArea.FOOTER,
|
|
28302
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
28303
|
+
onClick: () => commandService.executeCommand(OpenHeaderFooterPanelCommand.id, { editArea: _univerjs_engine_render.DocumentEditArea.FOOTER }),
|
|
28304
|
+
children: localeService.t("docs-ui.headerFooter.goToFooter")
|
|
28305
|
+
})
|
|
28306
|
+
]
|
|
28307
|
+
});
|
|
28308
|
+
if (kind === "options") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
28309
|
+
className: "univer-flex univer-flex-col univer-gap-2 univer-text-start univer-text-xs",
|
|
28310
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
28311
|
+
disabled,
|
|
28312
|
+
checked: options.useFirstPageHeaderFooter === _univerjs_core.BooleanNumber.TRUE,
|
|
28313
|
+
onChange: (value) => handleCheckboxChange(Boolean(value), "useFirstPageHeaderFooter"),
|
|
28314
|
+
children: localeService.t("docs-ui.headerFooter.firstPageCheckBox")
|
|
28315
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
28316
|
+
disabled,
|
|
28317
|
+
checked: options.evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE,
|
|
28318
|
+
onChange: (value) => handleCheckboxChange(Boolean(value), "evenAndOddHeaders"),
|
|
28319
|
+
children: localeService.t("docs-ui.headerFooter.oddEvenCheckBox")
|
|
28320
|
+
})]
|
|
28321
|
+
});
|
|
28322
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
28323
|
+
className: "univer-flex univer-flex-col univer-gap-1 univer-text-start univer-text-xs",
|
|
28324
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
28325
|
+
className: "univer-grid univer-grid-cols-[1fr_5rem] univer-items-center univer-gap-x-2",
|
|
28326
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("docs-ui.headerFooter.headerTopMargin") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
28327
|
+
disabled,
|
|
28328
|
+
min: 0,
|
|
28329
|
+
max: 200,
|
|
28330
|
+
precision: 1,
|
|
28331
|
+
value: options.marginHeader,
|
|
28332
|
+
onChange: (value) => handleMarginChange(value ?? 0, "marginHeader")
|
|
28333
|
+
})]
|
|
28334
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
28335
|
+
className: "univer-grid univer-grid-cols-[1fr_5rem] univer-items-center univer-gap-x-2",
|
|
28336
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("docs-ui.headerFooter.footerBottomMargin") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
28337
|
+
disabled,
|
|
28338
|
+
min: 0,
|
|
28339
|
+
max: 200,
|
|
28340
|
+
precision: 1,
|
|
28341
|
+
value: options.marginFooter,
|
|
28342
|
+
onChange: (value) => handleMarginChange(value ?? 0, "marginFooter")
|
|
28343
|
+
})]
|
|
28344
|
+
})]
|
|
28345
|
+
});
|
|
28346
|
+
}
|
|
28347
|
+
|
|
27497
28348
|
//#endregion
|
|
27498
28349
|
//#region src/views/paragraph-menu/component-keys.ts
|
|
27499
28350
|
/**
|
|
@@ -27551,6 +28402,10 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
27551
28402
|
var _this$_paragraphMenu2;
|
|
27552
28403
|
return ((_this$_paragraphMenu2 = this._paragraphMenu) === null || _this$_paragraphMenu2 === void 0 ? void 0 : _this$_paragraphMenu2.target) ?? null;
|
|
27553
28404
|
}
|
|
28405
|
+
get focusedTableTarget() {
|
|
28406
|
+
var _this$_focusedTableMe;
|
|
28407
|
+
return ((_this$_focusedTableMe = this._focusedTableMenu) === null || _this$_focusedTableMe === void 0 ? void 0 : _this$_focusedTableMe.target) ?? null;
|
|
28408
|
+
}
|
|
27554
28409
|
setBlockMenuDragging(isDragging) {
|
|
27555
28410
|
this._isBlockMenuDragging = isDragging;
|
|
27556
28411
|
if (isDragging) this._dragInteraction ??= this._docLayoutInteractionService.beginInteraction();
|
|
@@ -27578,6 +28433,11 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
27578
28433
|
_defineProperty(this, "_paragraphMenu", null);
|
|
27579
28434
|
_defineProperty(this, "_activeTarget$", new rxjs.BehaviorSubject(null));
|
|
27580
28435
|
_defineProperty(this, "activeTarget$", this._activeTarget$.asObservable());
|
|
28436
|
+
_defineProperty(this, "_focusedTableMenu", null);
|
|
28437
|
+
_defineProperty(this, "_focusedTableTarget$", new rxjs.BehaviorSubject(null));
|
|
28438
|
+
_defineProperty(this, "focusedTableTarget$", this._focusedTableTarget$.asObservable());
|
|
28439
|
+
_defineProperty(this, "_focusedTableMenuDismiss$", new rxjs.Subject());
|
|
28440
|
+
_defineProperty(this, "focusedTableMenuDismiss$", this._focusedTableMenuDismiss$.asObservable());
|
|
27581
28441
|
_defineProperty(this, "_slashMenuRequest$", new rxjs.BehaviorSubject(null));
|
|
27582
28442
|
_defineProperty(this, "slashMenuRequest$", this._slashMenuRequest$.asObservable());
|
|
27583
28443
|
_defineProperty(this, "_isBlockMenuDragging", false);
|
|
@@ -27593,6 +28453,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
27593
28453
|
this._isBlockMenuDragging = false;
|
|
27594
28454
|
this.hideParagraphMenu(true);
|
|
27595
28455
|
}
|
|
28456
|
+
if (this._focusedTableMenu && !this._canEditDocument(this._focusedTableMenu.target.menuRange)) this.hideFocusedTableMenu();
|
|
27596
28457
|
}));
|
|
27597
28458
|
}
|
|
27598
28459
|
_isCursorInActiveParagraph() {
|
|
@@ -27629,9 +28490,11 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
27629
28490
|
_hasExpandedSelection() {
|
|
27630
28491
|
return this._hasExpandedSelectionRanges(this._docSelectionManagerService.getDocRanges());
|
|
27631
28492
|
}
|
|
27632
|
-
setParagraphMenuActive(active) {
|
|
27633
|
-
|
|
27634
|
-
|
|
28493
|
+
setParagraphMenuActive(active, focusedTable = false) {
|
|
28494
|
+
var _this$_paragraphMenu3, _this$_focusedTableMe2;
|
|
28495
|
+
const menu = focusedTable ? this._focusedTableMenu : this._paragraphMenu;
|
|
28496
|
+
if (menu) menu.active = active;
|
|
28497
|
+
if (((_this$_paragraphMenu3 = this._paragraphMenu) === null || _this$_paragraphMenu3 === void 0 ? void 0 : _this$_paragraphMenu3.active) || ((_this$_focusedTableMe2 = this._focusedTableMenu) === null || _this$_focusedTableMe2 === void 0 ? void 0 : _this$_focusedTableMe2.active)) this._menuInteraction ??= this._docLayoutInteractionService.beginInteraction();
|
|
27635
28498
|
else {
|
|
27636
28499
|
var _this$_menuInteractio;
|
|
27637
28500
|
(_this$_menuInteractio = this._menuInteraction) === null || _this$_menuInteractio === void 0 || _this$_menuInteractio.dispose();
|
|
@@ -27640,7 +28503,9 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
27640
28503
|
}
|
|
27641
28504
|
_init() {
|
|
27642
28505
|
const handleHoverTarget = (paragraph, tableBound) => {
|
|
28506
|
+
var _this$_focusedTableMe3;
|
|
27643
28507
|
if (this._isBlockMenuDragging) return;
|
|
28508
|
+
if ((_this$_focusedTableMe3 = this._focusedTableMenu) === null || _this$_focusedTableMe3 === void 0 ? void 0 : _this$_focusedTableMe3.active) return;
|
|
27644
28509
|
if (this._docSelectionRenderService.isOnPointerEvent) {
|
|
27645
28510
|
this.hideParagraphMenu(true);
|
|
27646
28511
|
return;
|
|
@@ -27651,18 +28516,18 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
27651
28516
|
return;
|
|
27652
28517
|
}
|
|
27653
28518
|
if (selectionState.hasRectRange) {
|
|
27654
|
-
var _this$
|
|
28519
|
+
var _this$_paragraphMenu4;
|
|
27655
28520
|
if (tableBound) {
|
|
27656
28521
|
this.showTableMenu(tableBound);
|
|
27657
28522
|
return;
|
|
27658
28523
|
}
|
|
27659
|
-
if (((_this$
|
|
28524
|
+
if (((_this$_paragraphMenu4 = this._paragraphMenu) === null || _this$_paragraphMenu4 === void 0 ? void 0 : _this$_paragraphMenu4.target.kind) === _univerjs_core.DocumentBlockType.TABLE) return;
|
|
27660
28525
|
this.hideParagraphMenu(true);
|
|
27661
28526
|
return;
|
|
27662
28527
|
}
|
|
27663
28528
|
if (this._docSkeletonManagerService.getViewModel().getEditArea() === _univerjs_engine_render.DocumentEditArea.BODY && !this._floatMenuService.floatMenu && !this._context.unit.getDisabled() && this._canEditDocument()) {
|
|
27664
|
-
var _this$
|
|
27665
|
-
if ((_this$
|
|
28529
|
+
var _this$_paragraphMenu5;
|
|
28530
|
+
if ((_this$_paragraphMenu5 = this._paragraphMenu) === null || _this$_paragraphMenu5 === void 0 ? void 0 : _this$_paragraphMenu5.active) return;
|
|
27666
28531
|
if (paragraph) {
|
|
27667
28532
|
this.showParagraphMenu(paragraph);
|
|
27668
28533
|
return;
|
|
@@ -27688,16 +28553,17 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
27688
28553
|
this.hideParagraphMenu(true);
|
|
27689
28554
|
}));
|
|
27690
28555
|
this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe(({ textRanges, rectRanges }) => {
|
|
27691
|
-
var _this$
|
|
28556
|
+
var _this$_paragraphMenu6;
|
|
27692
28557
|
const selectionState = this._getExpandedSelectionState([...textRanges, ...rectRanges]);
|
|
27693
|
-
if (selectionState.hasExpandedTextRange || selectionState.hasRectRange && ((_this$
|
|
28558
|
+
if (selectionState.hasExpandedTextRange || selectionState.hasRectRange && ((_this$_paragraphMenu6 = this._paragraphMenu) === null || _this$_paragraphMenu6 === void 0 ? void 0 : _this$_paragraphMenu6.target.kind) !== _univerjs_core.DocumentBlockType.TABLE) this.hideParagraphMenu(true);
|
|
27694
28559
|
}));
|
|
27695
28560
|
let lastScrollY = 0;
|
|
27696
28561
|
this.disposeWithMe(this._context.scene.getViewport("viewMain").onScrollAfter$.subscribeEvent((e) => {
|
|
27697
|
-
var _this$
|
|
28562
|
+
var _this$_paragraphMenu7;
|
|
27698
28563
|
if (lastScrollY === e.scrollY) return;
|
|
27699
28564
|
lastScrollY = e.scrollY;
|
|
27700
|
-
|
|
28565
|
+
this._focusedTableMenuDismiss$.next();
|
|
28566
|
+
if ((_this$_paragraphMenu7 = this._paragraphMenu) === null || _this$_paragraphMenu7 === void 0 ? void 0 : _this$_paragraphMenu7.blockRange) return;
|
|
27701
28567
|
if (this._isBlockMenuDragging) return;
|
|
27702
28568
|
this.hideParagraphMenu(true);
|
|
27703
28569
|
}));
|
|
@@ -27708,6 +28574,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
27708
28574
|
this.disposeWithMe(this._docSelectionRenderService.onKeydown$.subscribe((config) => {
|
|
27709
28575
|
if (this._isBlockMenuDragging) return;
|
|
27710
28576
|
if (this._handleSlashMenuKeydown(config)) return;
|
|
28577
|
+
this._focusedTableMenuDismiss$.next();
|
|
27711
28578
|
this.hideParagraphMenu(true);
|
|
27712
28579
|
}));
|
|
27713
28580
|
this.disposeWithMe(this._docSelectionRenderService.onInputBefore$.subscribe((config) => {
|
|
@@ -27763,10 +28630,10 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
27763
28630
|
return null;
|
|
27764
28631
|
}
|
|
27765
28632
|
_getSlashMenuParagraph(config) {
|
|
27766
|
-
var _this$
|
|
28633
|
+
var _this$_paragraphMenu8;
|
|
27767
28634
|
const activeRange = this._getCollapsedTextRange(config);
|
|
27768
28635
|
const offset = activeRange === null || activeRange === void 0 ? void 0 : activeRange.startOffset;
|
|
27769
|
-
const activeParagraph = ((_this$
|
|
28636
|
+
const activeParagraph = ((_this$_paragraphMenu8 = this._paragraphMenu) === null || _this$_paragraphMenu8 === void 0 ? void 0 : _this$_paragraphMenu8.paragraph) ?? null;
|
|
27770
28637
|
if (activeParagraph && offset != null && offset >= activeParagraph.paragraphStart && offset <= activeParagraph.paragraphEnd) return activeParagraph;
|
|
27771
28638
|
if (activeParagraph && offset == null) return activeParagraph;
|
|
27772
28639
|
if (offset == null) return null;
|
|
@@ -27787,7 +28654,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
27787
28654
|
}
|
|
27788
28655
|
}
|
|
27789
28656
|
showParagraphMenu(paragraph) {
|
|
27790
|
-
var _this$
|
|
28657
|
+
var _this$_paragraphMenu9;
|
|
27791
28658
|
if (this._hasExpandedSelection()) {
|
|
27792
28659
|
this.hideParagraphMenu(true);
|
|
27793
28660
|
return;
|
|
@@ -27797,7 +28664,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
27797
28664
|
this.hideParagraphMenu(true);
|
|
27798
28665
|
return;
|
|
27799
28666
|
}
|
|
27800
|
-
if (((_this$
|
|
28667
|
+
if (((_this$_paragraphMenu9 = this._paragraphMenu) === null || _this$_paragraphMenu9 === void 0 ? void 0 : _this$_paragraphMenu9.target.key) === target.key) return;
|
|
27801
28668
|
this.hideParagraphMenu(true);
|
|
27802
28669
|
const targetParagraph = target.paragraph ?? paragraph;
|
|
27803
28670
|
const blockRange = target.blockRange;
|
|
@@ -27832,15 +28699,19 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
27832
28699
|
};
|
|
27833
28700
|
this._activeTarget$.next(target);
|
|
27834
28701
|
}
|
|
27835
|
-
showTableMenu(tableBound) {
|
|
27836
|
-
var _body$tables, _this$
|
|
27837
|
-
if (this.
|
|
28702
|
+
showTableMenu(tableBound, focused = false) {
|
|
28703
|
+
var _this$_focusedTableMe4, _body$tables, _this$_paragraphMenu10;
|
|
28704
|
+
if (!focused && ((_this$_focusedTableMe4 = this._focusedTableMenu) === null || _this$_focusedTableMe4 === void 0 || (_this$_focusedTableMe4 = _this$_focusedTableMe4.target.table) === null || _this$_focusedTableMe4 === void 0 ? void 0 : _this$_focusedTableMe4.tableId) === tableBound.tableId) return;
|
|
28705
|
+
if (!focused && this._hasExpandedTextSelection()) {
|
|
27838
28706
|
this.hideParagraphMenu(true);
|
|
27839
28707
|
return;
|
|
27840
28708
|
}
|
|
27841
28709
|
const body = this._context.unit.getBody();
|
|
27842
28710
|
const table = body === null || body === void 0 || (_body$tables = body.tables) === null || _body$tables === void 0 ? void 0 : _body$tables.find((item) => item.tableId === tableBound.tableId);
|
|
27843
|
-
if (!table)
|
|
28711
|
+
if (!table) {
|
|
28712
|
+
if (focused) this.hideFocusedTableMenu();
|
|
28713
|
+
return;
|
|
28714
|
+
}
|
|
27844
28715
|
const target = {
|
|
27845
28716
|
kind: _univerjs_core.DocumentBlockType.TABLE,
|
|
27846
28717
|
key: `${_univerjs_core.DocumentBlockType.TABLE}:${table.tableId}`,
|
|
@@ -27853,17 +28724,21 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
27853
28724
|
},
|
|
27854
28725
|
moveRange: {
|
|
27855
28726
|
startOffset: table.startIndex,
|
|
27856
|
-
endOffset: table.endIndex
|
|
28727
|
+
endOffset: table.endIndex + ((body === null || body === void 0 ? void 0 : body.dataStream[table.endIndex]) === "\r" ? 1 : 0)
|
|
27857
28728
|
},
|
|
27858
28729
|
emptyMode: false,
|
|
27859
28730
|
draggable: true
|
|
27860
28731
|
};
|
|
27861
28732
|
if (!this._canEditDocument(target.menuRange)) {
|
|
28733
|
+
if (focused) {
|
|
28734
|
+
this.hideFocusedTableMenu();
|
|
28735
|
+
return;
|
|
28736
|
+
}
|
|
27862
28737
|
this.hideParagraphMenu(true);
|
|
27863
28738
|
return;
|
|
27864
28739
|
}
|
|
27865
|
-
if (this._shouldKeepCurrentCellMenuForTable(table)) return;
|
|
27866
|
-
if (((_this$
|
|
28740
|
+
if (!focused && this._shouldKeepCurrentCellMenuForTable(table)) return;
|
|
28741
|
+
if (!focused && ((_this$_paragraphMenu10 = this._paragraphMenu) === null || _this$_paragraphMenu10 === void 0 ? void 0 : _this$_paragraphMenu10.target.key) === target.key) return;
|
|
27867
28742
|
const anchorRect = getTableAnchorRect(tableBound);
|
|
27868
28743
|
const paragraph = {
|
|
27869
28744
|
rect: tableBound.rect,
|
|
@@ -27874,8 +28749,16 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
27874
28749
|
pageIndex: tableBound.pageIndex,
|
|
27875
28750
|
firstLine: anchorRect
|
|
27876
28751
|
};
|
|
28752
|
+
if (focused) {
|
|
28753
|
+
target.paragraph = paragraph;
|
|
28754
|
+
this._showFocusedTableMenu(tableBound, target);
|
|
28755
|
+
return;
|
|
28756
|
+
}
|
|
28757
|
+
this._showHoverTableMenu(tableBound, target, paragraph);
|
|
28758
|
+
}
|
|
28759
|
+
_showHoverTableMenu(tableBound, target, paragraph) {
|
|
27877
28760
|
this.hideParagraphMenu(true);
|
|
27878
|
-
const getFirstLine = () => getTableAnchorRect(this._docEventManagerService.tableBounds.get(
|
|
28761
|
+
const getFirstLine = () => getTableAnchorRect(this._docEventManagerService.tableBounds.get(tableBound.tableId) ?? tableBound);
|
|
27879
28762
|
const disposable = this._docPopupManagerService.attachPopupToRect(getFirstLine, {
|
|
27880
28763
|
componentKey: DOC_TABLE_BLOCK_MENU_COMPONENT_KEY,
|
|
27881
28764
|
constrainToCanvas: true,
|
|
@@ -27894,9 +28777,40 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
27894
28777
|
};
|
|
27895
28778
|
this._activeTarget$.next(target);
|
|
27896
28779
|
}
|
|
28780
|
+
_showFocusedTableMenu(tableBound, target) {
|
|
28781
|
+
var _this$_focusedTableMe5, _this$_paragraphMenu11;
|
|
28782
|
+
if (((_this$_focusedTableMe5 = this._focusedTableMenu) === null || _this$_focusedTableMe5 === void 0 ? void 0 : _this$_focusedTableMe5.target.key) === target.key) {
|
|
28783
|
+
this._focusedTableMenu.target = target;
|
|
28784
|
+
this._focusedTableMenu.bound = tableBound;
|
|
28785
|
+
this._focusedTableTarget$.next(target);
|
|
28786
|
+
return;
|
|
28787
|
+
}
|
|
28788
|
+
this.hideFocusedTableMenu();
|
|
28789
|
+
if (((_this$_paragraphMenu11 = this._paragraphMenu) === null || _this$_paragraphMenu11 === void 0 ? void 0 : _this$_paragraphMenu11.target.key) === target.key) this.hideParagraphMenu(true);
|
|
28790
|
+
const getFocusedAnchor = () => {
|
|
28791
|
+
var _this$_focusedTableMe6;
|
|
28792
|
+
return getTableAnchorRect(this._docEventManagerService.tableBounds.get(tableBound.tableId) ?? ((_this$_focusedTableMe6 = this._focusedTableMenu) === null || _this$_focusedTableMe6 === void 0 ? void 0 : _this$_focusedTableMe6.bound) ?? tableBound);
|
|
28793
|
+
};
|
|
28794
|
+
const disposable = this._docPopupManagerService.attachPopupToRect(getFocusedAnchor, {
|
|
28795
|
+
componentKey: DOC_TABLE_BLOCK_MENU_COMPONENT_KEY,
|
|
28796
|
+
extraProps: { focusedTableMenu: true },
|
|
28797
|
+
constrainToCanvas: true,
|
|
28798
|
+
requiresStableLayout: false,
|
|
28799
|
+
direction: "top-right",
|
|
28800
|
+
onClickOutside: () => this._focusedTableMenuDismiss$.next(),
|
|
28801
|
+
zIndex: 102
|
|
28802
|
+
}, this._context.unitId);
|
|
28803
|
+
this._focusedTableMenu = {
|
|
28804
|
+
target,
|
|
28805
|
+
bound: tableBound,
|
|
28806
|
+
disposable,
|
|
28807
|
+
active: false
|
|
28808
|
+
};
|
|
28809
|
+
this._focusedTableTarget$.next(target);
|
|
28810
|
+
}
|
|
27897
28811
|
_shouldKeepCurrentCellMenuForTable(table) {
|
|
27898
|
-
var _this$
|
|
27899
|
-
const target = (_this$
|
|
28812
|
+
var _this$_paragraphMenu12;
|
|
28813
|
+
const target = (_this$_paragraphMenu12 = this._paragraphMenu) === null || _this$_paragraphMenu12 === void 0 ? void 0 : _this$_paragraphMenu12.target;
|
|
27900
28814
|
if (!target || target.kind === _univerjs_core.DocumentBlockType.TABLE || !target.cellRange) return false;
|
|
27901
28815
|
return target.cellRange.startOffset >= table.startIndex && target.cellRange.startOffset <= table.endIndex;
|
|
27902
28816
|
}
|
|
@@ -27939,22 +28853,32 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
|
|
|
27939
28853
|
hideParagraphMenu(force = false) {
|
|
27940
28854
|
if (this._isBlockMenuDragging) return;
|
|
27941
28855
|
if (this._paragraphMenu && (this._paragraphMenu.disposable.canDispose() || force)) {
|
|
27942
|
-
var _this$_menuInteractio2;
|
|
27943
28856
|
this._paragraphMenu.disposable.dispose();
|
|
27944
28857
|
this._paragraphMenu = null;
|
|
27945
|
-
|
|
27946
|
-
this._menuInteraction = null;
|
|
28858
|
+
this.setParagraphMenuActive(false);
|
|
27947
28859
|
this._isSlashMenuActive = false;
|
|
27948
28860
|
this._slashMenuRequest$.next(null);
|
|
27949
28861
|
this._activeTarget$.next(null);
|
|
27950
28862
|
}
|
|
27951
28863
|
}
|
|
28864
|
+
hideFocusedTableMenu() {
|
|
28865
|
+
var _this$_focusedTableMe7;
|
|
28866
|
+
(_this$_focusedTableMe7 = this._focusedTableMenu) === null || _this$_focusedTableMe7 === void 0 || _this$_focusedTableMe7.disposable.dispose();
|
|
28867
|
+
this._focusedTableMenu = null;
|
|
28868
|
+
this._focusedTableTarget$.next(null);
|
|
28869
|
+
this.setParagraphMenuActive(false, true);
|
|
28870
|
+
}
|
|
27952
28871
|
_canEditDocument(range, segmentId = "") {
|
|
27953
28872
|
return (0, _univerjs_docs.canEditDocumentTargets)(this._permissionService, this._context.unitId, range ? (0, _univerjs_docs.getDocumentEditTargetObjectIds)(this._context.unit, segmentId, range) : []);
|
|
27954
28873
|
}
|
|
27955
28874
|
dispose() {
|
|
27956
|
-
var _this$
|
|
27957
|
-
|
|
28875
|
+
var _this$_menuInteractio2, _this$_dragInteractio2;
|
|
28876
|
+
this._isBlockMenuDragging = false;
|
|
28877
|
+
this.hideFocusedTableMenu();
|
|
28878
|
+
this.hideParagraphMenu(true);
|
|
28879
|
+
this._focusedTableTarget$.complete();
|
|
28880
|
+
this._focusedTableMenuDismiss$.complete();
|
|
28881
|
+
(_this$_menuInteractio2 = this._menuInteraction) === null || _this$_menuInteractio2 === void 0 || _this$_menuInteractio2.dispose();
|
|
27958
28882
|
this._menuInteraction = null;
|
|
27959
28883
|
(_this$_dragInteractio2 = this._dragInteraction) === null || _this$_dragInteractio2 === void 0 || _this$_dragInteractio2.dispose();
|
|
27960
28884
|
this._dragInteraction = null;
|
|
@@ -28286,9 +29210,6 @@ function createParagraphMenuHoverOpenScheduler(openMenu, delay = 800) {
|
|
|
28286
29210
|
}
|
|
28287
29211
|
};
|
|
28288
29212
|
}
|
|
28289
|
-
function setParagraphMenuInteractionActive(docParagraphMenuService, active) {
|
|
28290
|
-
docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(active);
|
|
28291
|
-
}
|
|
28292
29213
|
function isEmptyParagraphMenuTarget(dataStream, paragraph) {
|
|
28293
29214
|
if (!paragraph) return false;
|
|
28294
29215
|
return dataStream.slice(paragraph.paragraphStart, paragraph.paragraphEnd).replace(/[\r\n]/g, "") === "";
|
|
@@ -28698,7 +29619,7 @@ function getBlockRangeClipboardTargetRange(commandId, target, paragraph) {
|
|
|
28698
29619
|
return null;
|
|
28699
29620
|
}
|
|
28700
29621
|
function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
28701
|
-
var _doc$getBody, _paragraphObj$paragra;
|
|
29622
|
+
var _popup$extraProps, _doc$getBody, _paragraphObj$paragra;
|
|
28702
29623
|
const [visible, setVisible] = (0, react.useState)(false);
|
|
28703
29624
|
const [openMode, setOpenMode] = (0, react.useState)("pointer");
|
|
28704
29625
|
const [anchorRect, setAnchorRect] = (0, react.useState)(null);
|
|
@@ -28707,10 +29628,12 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
28707
29628
|
const targetRangeRef = (0, react.useRef)(null);
|
|
28708
29629
|
const dragTargetOffsetRef = (0, react.useRef)(null);
|
|
28709
29630
|
const dragRangeRef = (0, react.useRef)(null);
|
|
29631
|
+
const dragCleanupRef = (0, react.useRef)(null);
|
|
28710
29632
|
const isDraggingRef = (0, react.useRef)(false);
|
|
28711
29633
|
const openMenuRef = (0, react.useRef)(() => void 0);
|
|
28712
29634
|
const hoverOpenSchedulerRef = (0, react.useRef)(createParagraphMenuHoverOpenScheduler(() => openMenuRef.current()));
|
|
28713
29635
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
29636
|
+
const logService = (0, _univerjs_ui.useDependency)(_univerjs_core.ILogService);
|
|
28714
29637
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
28715
29638
|
const themeService = (0, _univerjs_ui.useDependency)(_univerjs_core.ThemeService);
|
|
28716
29639
|
const docSelectionManagerService = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocSelectionManagerService);
|
|
@@ -28731,12 +29654,20 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
28731
29654
|
const doc = univerInstanceService.getUnit(popup.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
28732
29655
|
const docParagraphMenuService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocParagraphMenuService);
|
|
28733
29656
|
const docEventManagerService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocEventManagerService);
|
|
28734
|
-
const
|
|
29657
|
+
const isFocusedTableMenu = ((_popup$extraProps = popup.extraProps) === null || _popup$extraProps === void 0 ? void 0 : _popup$extraProps.focusedTableMenu) === true;
|
|
29658
|
+
const activeTarget = (0, _univerjs_ui.useObservable)(isFocusedTableMenu ? docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.focusedTableTarget$ : docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget$);
|
|
28735
29659
|
const slashMenuRequest = (0, _univerjs_ui.useObservable)(docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.slashMenuRequest$);
|
|
28736
29660
|
const paragraph = (0, _univerjs_ui.useObservable)(docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.hoverParagraph$);
|
|
28737
29661
|
const paragraphLeft = (0, _univerjs_ui.useObservable)(docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.hoverParagraphLeft$);
|
|
28738
|
-
const
|
|
28739
|
-
|
|
29662
|
+
const getActiveTarget = () => {
|
|
29663
|
+
if (isFocusedTableMenu) return (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.focusedTableTarget) ?? activeTarget;
|
|
29664
|
+
return (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
|
|
29665
|
+
};
|
|
29666
|
+
const setMenuInteractionActive = (active) => {
|
|
29667
|
+
docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(active, isFocusedTableMenu);
|
|
29668
|
+
};
|
|
29669
|
+
const rawActiveTarget = getActiveTarget();
|
|
29670
|
+
const currentActiveTarget = (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table" === tableBlockOnly ? rawActiveTarget : null;
|
|
28740
29671
|
const activeParagraphBound = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.paragraph) ?? (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeParagraph) ?? paragraph ?? paragraphLeft;
|
|
28741
29672
|
const startIndex = activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.startIndex;
|
|
28742
29673
|
const dataStream = (doc === null || doc === void 0 || (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.dataStream) ?? "";
|
|
@@ -28789,13 +29720,41 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
28789
29720
|
if (activeElement === focusedElement || !focusedElement.isConnected && activeElement === body) layoutService.focus();
|
|
28790
29721
|
}, [layoutService]);
|
|
28791
29722
|
(0, react.useLayoutEffect)(() => restoreMenuFocus, [restoreMenuFocus]);
|
|
28792
|
-
const handleHideMenu = () => {
|
|
29723
|
+
const handleHideMenu = (0, react.useCallback)(() => {
|
|
29724
|
+
hoverOpenSchedulerRef.current.cancel();
|
|
28793
29725
|
restoreMenuFocus();
|
|
28794
29726
|
setVisible(false);
|
|
28795
29727
|
setOpenMode("pointer");
|
|
28796
29728
|
targetRangeRef.current = null;
|
|
28797
|
-
|
|
28798
|
-
}
|
|
29729
|
+
docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(false, isFocusedTableMenu);
|
|
29730
|
+
}, [
|
|
29731
|
+
docParagraphMenuService,
|
|
29732
|
+
isFocusedTableMenu,
|
|
29733
|
+
restoreMenuFocus
|
|
29734
|
+
]);
|
|
29735
|
+
(0, react.useEffect)(() => {
|
|
29736
|
+
if (!isFocusedTableMenu || !docParagraphMenuService) return;
|
|
29737
|
+
const subscription = docParagraphMenuService.focusedTableMenuDismiss$.subscribe(handleHideMenu);
|
|
29738
|
+
const ownerDocument = popup.canvasElement.ownerDocument;
|
|
29739
|
+
const handleKeydown = (event) => {
|
|
29740
|
+
if (event.key === "Escape") {
|
|
29741
|
+
event.preventDefault();
|
|
29742
|
+
event.stopPropagation();
|
|
29743
|
+
handleHideMenu();
|
|
29744
|
+
}
|
|
29745
|
+
};
|
|
29746
|
+
if (visible) ownerDocument.addEventListener("keydown", handleKeydown, true);
|
|
29747
|
+
return () => {
|
|
29748
|
+
subscription.unsubscribe();
|
|
29749
|
+
ownerDocument.removeEventListener("keydown", handleKeydown, true);
|
|
29750
|
+
};
|
|
29751
|
+
}, [
|
|
29752
|
+
docParagraphMenuService,
|
|
29753
|
+
isFocusedTableMenu,
|
|
29754
|
+
handleHideMenu,
|
|
29755
|
+
popup.canvasElement,
|
|
29756
|
+
visible
|
|
29757
|
+
]);
|
|
28799
29758
|
const clearHideTimer = () => {
|
|
28800
29759
|
if (hideTimerRef.current != null) {
|
|
28801
29760
|
window.clearTimeout(hideTimerRef.current);
|
|
@@ -28813,8 +29772,8 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
28813
29772
|
const handleOpenMenu = (mode = "pointer") => {
|
|
28814
29773
|
clearHideTimer();
|
|
28815
29774
|
if (openMode === "slash") return;
|
|
28816
|
-
const latestTarget = (
|
|
28817
|
-
|
|
29775
|
+
const latestTarget = getActiveTarget();
|
|
29776
|
+
setMenuInteractionActive(true);
|
|
28818
29777
|
const targetRange = latestTarget ? {
|
|
28819
29778
|
...latestTarget.menuRange,
|
|
28820
29779
|
segmentId: activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.segmentId
|
|
@@ -28862,7 +29821,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
28862
29821
|
return commandService.executeCommand(resolved.commandId, resolved.params);
|
|
28863
29822
|
};
|
|
28864
29823
|
const unwrapActiveBlockRange = async () => {
|
|
28865
|
-
const latestTarget = (
|
|
29824
|
+
const latestTarget = getActiveTarget();
|
|
28866
29825
|
if (!latestTarget || latestTarget.kind !== "blockRange" || !latestTarget.blockRange || !(doc === null || doc === void 0 ? void 0 : doc.getBody())) return null;
|
|
28867
29826
|
const previousBody = doc.getBody();
|
|
28868
29827
|
const { body, range } = unwrapBlockRangeBody(previousBody, latestTarget.blockRange);
|
|
@@ -28885,7 +29844,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
28885
29844
|
return nextRange;
|
|
28886
29845
|
};
|
|
28887
29846
|
const executeParagraphMenuOption = async (option) => {
|
|
28888
|
-
const latestTarget = (
|
|
29847
|
+
const latestTarget = getActiveTarget();
|
|
28889
29848
|
const targetRange = getTargetSelectionRange(latestTarget, activeParagraphBound ?? void 0);
|
|
28890
29849
|
const blockRange = getBlockSelectionRange(latestTarget, activeParagraphBound ?? void 0);
|
|
28891
29850
|
const formattingRange = getParagraphFormattingRange(latestTarget, activeParagraphBound ?? void 0);
|
|
@@ -28989,31 +29948,35 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
28989
29948
|
const hoverBridgeStyle = visible && (menuDirection === "left" || menuDirection === "right") ? getParagraphMenuHoverBridgeStyle(anchorRect, menuDirection) : void 0;
|
|
28990
29949
|
const resolvedParagraphMenuType = openMode === "slash" ? DOC_PARAGRAPH_T_INSERT_MENU_ID : paragraphMenuType;
|
|
28991
29950
|
(0, react.useEffect)(() => () => {
|
|
29951
|
+
var _dragCleanupRef$curre;
|
|
29952
|
+
(_dragCleanupRef$curre = dragCleanupRef.current) === null || _dragCleanupRef$curre === void 0 || _dragCleanupRef$curre.call(dragCleanupRef);
|
|
28992
29953
|
if (hideTimerRef.current != null) {
|
|
28993
29954
|
window.clearTimeout(hideTimerRef.current);
|
|
28994
29955
|
hideTimerRef.current = null;
|
|
28995
29956
|
}
|
|
28996
29957
|
hoverOpenSchedulerRef.current.cancel();
|
|
28997
|
-
|
|
28998
|
-
}, []);
|
|
29958
|
+
docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(false, isFocusedTableMenu);
|
|
29959
|
+
}, [docParagraphMenuService, isFocusedTableMenu]);
|
|
28999
29960
|
(0, react.useEffect)(() => {
|
|
29000
|
-
if (!slashMenuRequest || handledSlashRequestNonceRef.current >= slashMenuRequest.nonce) return;
|
|
29961
|
+
if (tableBlockOnly || !slashMenuRequest || handledSlashRequestNonceRef.current >= slashMenuRequest.nonce) return;
|
|
29001
29962
|
handledSlashRequestNonceRef.current = slashMenuRequest.nonce;
|
|
29002
29963
|
hoverOpenSchedulerRef.current.cancel();
|
|
29003
29964
|
clearHideTimer();
|
|
29004
29965
|
isMouseOver.current = false;
|
|
29005
29966
|
handleOpenSlashMenu(slashMenuRequest);
|
|
29006
|
-
}, [slashMenuRequest]);
|
|
29967
|
+
}, [slashMenuRequest, tableBlockOnly]);
|
|
29007
29968
|
if (!currentActiveTarget) return null;
|
|
29008
29969
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
29009
29970
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
29010
29971
|
"data-u-comp": "paragraph-menu",
|
|
29972
|
+
"data-u-table-menu": tableBlockOnly ? "true" : void 0,
|
|
29973
|
+
"data-u-focused-table-menu": isFocusedTableMenu ? "true" : void 0,
|
|
29011
29974
|
ref: anchorRef,
|
|
29012
|
-
className: (0, _univerjs_design.clsx)("univer-mr-1 univer-inline-flex univer-h-7 univer-cursor-pointer univer-items-center univer-gap-1 univer-rounded-md univer-border univer-border-gray-200 univer-bg-gray-0 univer-px-2 univer-py-0 univer-shadow-sm univer-transition-colors hover:univer-bg-gray-50 hover:univer-shadow-md dark:!univer-border-gray-
|
|
29975
|
+
className: (0, _univerjs_design.clsx)("univer-mr-1 univer-inline-flex univer-h-7 univer-cursor-pointer univer-items-center univer-gap-1 univer-rounded-md univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-px-2 univer-py-0 univer-shadow-sm univer-transition-colors hover:univer-bg-gray-50 hover:univer-shadow-md dark:!univer-border-gray-600 dark:!univer-bg-gray-900 dark:hover:!univer-bg-gray-800", { "univer-bg-gray-100 univer-shadow-md dark:!univer-bg-gray-800": visible }),
|
|
29013
29976
|
onMouseEnter: (e) => {
|
|
29014
29977
|
var _popup$onPointerEnter;
|
|
29015
29978
|
(_popup$onPointerEnter = popup.onPointerEnter) === null || _popup$onPointerEnter === void 0 || _popup$onPointerEnter.call(popup, e);
|
|
29016
|
-
|
|
29979
|
+
setMenuInteractionActive(true);
|
|
29017
29980
|
isMouseOver.current = true;
|
|
29018
29981
|
scheduleOpenMenu();
|
|
29019
29982
|
},
|
|
@@ -29035,7 +29998,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29035
29998
|
title: localeService.t("docs-ui.doc.blockMenu.dragBlock"),
|
|
29036
29999
|
onPointerDown: (event) => {
|
|
29037
30000
|
var _event$currentTarget$, _event$currentTarget;
|
|
29038
|
-
const latestTarget = (
|
|
30001
|
+
const latestTarget = getActiveTarget();
|
|
29039
30002
|
const moveRange = latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.moveRange;
|
|
29040
30003
|
if (!moveRange || !(latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.draggable)) return;
|
|
29041
30004
|
event.preventDefault();
|
|
@@ -29063,6 +30026,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29063
30026
|
window.removeEventListener("pointerup", handlePointerUp);
|
|
29064
30027
|
window.removeEventListener("pointercancel", handlePointerCancel);
|
|
29065
30028
|
window.removeEventListener("blur", handleWindowBlur);
|
|
30029
|
+
dragCleanupRef.current = null;
|
|
29066
30030
|
const range = dragRangeRef.current;
|
|
29067
30031
|
const targetOffset = dragTargetOffsetRef.current;
|
|
29068
30032
|
dragRangeRef.current = null;
|
|
@@ -29078,7 +30042,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29078
30042
|
unitId: popup.unitId,
|
|
29079
30043
|
sourceRange: range,
|
|
29080
30044
|
targetOffset
|
|
29081
|
-
});
|
|
30045
|
+
}).catch((error) => logService.error(error));
|
|
29082
30046
|
};
|
|
29083
30047
|
const handlePointerUp = (upEvent) => {
|
|
29084
30048
|
if (upEvent.pointerId !== pointerId) return;
|
|
@@ -29092,6 +30056,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29092
30056
|
const handleWindowBlur = () => {
|
|
29093
30057
|
finishDrag(false);
|
|
29094
30058
|
};
|
|
30059
|
+
dragCleanupRef.current = () => finishDrag(false);
|
|
29095
30060
|
window.addEventListener("pointermove", handlePointerMove);
|
|
29096
30061
|
window.addEventListener("pointerup", handlePointerUp);
|
|
29097
30062
|
window.addEventListener("pointercancel", handlePointerCancel);
|
|
@@ -29107,7 +30072,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29107
30072
|
onMouseEnter: (e) => {
|
|
29108
30073
|
var _popup$onPointerEnter2;
|
|
29109
30074
|
(_popup$onPointerEnter2 = popup.onPointerEnter) === null || _popup$onPointerEnter2 === void 0 || _popup$onPointerEnter2.call(popup, e);
|
|
29110
|
-
|
|
30075
|
+
setMenuInteractionActive(true);
|
|
29111
30076
|
isMouseOver.current = true;
|
|
29112
30077
|
clearHideTimer();
|
|
29113
30078
|
},
|
|
@@ -29130,7 +30095,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29130
30095
|
onMouseEnter: (e) => {
|
|
29131
30096
|
var _popup$onPointerEnter3;
|
|
29132
30097
|
(_popup$onPointerEnter3 = popup.onPointerEnter) === null || _popup$onPointerEnter3 === void 0 || _popup$onPointerEnter3.call(popup, e);
|
|
29133
|
-
|
|
30098
|
+
setMenuInteractionActive(true);
|
|
29134
30099
|
isMouseOver.current = true;
|
|
29135
30100
|
clearHideTimer();
|
|
29136
30101
|
},
|
|
@@ -29148,7 +30113,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29148
30113
|
autoFocusTarget: openMode === "slash" ? "container" : void 0,
|
|
29149
30114
|
suppressHoverUntilPointerMove: openMode === "slash",
|
|
29150
30115
|
onMenuPointerEnter: () => {
|
|
29151
|
-
|
|
30116
|
+
setMenuInteractionActive(true);
|
|
29152
30117
|
isMouseOver.current = true;
|
|
29153
30118
|
clearHideTimer();
|
|
29154
30119
|
},
|
|
@@ -29162,7 +30127,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
|
|
|
29162
30127
|
onOptionSelect: async (params) => {
|
|
29163
30128
|
const targetRange = targetRangeRef.current ?? getParagraphMenuTargetRange(activeParagraphBound);
|
|
29164
30129
|
const { commandId, params: commandParams } = getParagraphMenuCommand(params, targetRange);
|
|
29165
|
-
const latestTarget = (
|
|
30130
|
+
const latestTarget = getActiveTarget();
|
|
29166
30131
|
if ((latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.kind) === "table" && commandId && targetRange) {
|
|
29167
30132
|
univerInstanceService.focusUnit(popup.unitId);
|
|
29168
30133
|
const tableRange = {
|
|
@@ -29289,6 +30254,7 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
29289
30254
|
BoldIcon: _univerjs_icons.BoldIcon,
|
|
29290
30255
|
CopyDoubleIcon: _univerjs_icons.CopyDoubleIcon,
|
|
29291
30256
|
ColumnIcon: _univerjs_icons.ColumnIcon,
|
|
30257
|
+
CloseIcon: _univerjs_icons.CloseIcon,
|
|
29292
30258
|
CutIcon: _univerjs_icons.CutIcon,
|
|
29293
30259
|
DeleteColumnDoubleIcon: _univerjs_icons.DeleteColumnDoubleIcon,
|
|
29294
30260
|
DeleteIcon: _univerjs_icons.DeleteIcon,
|
|
@@ -29304,6 +30270,7 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
29304
30270
|
H5Icon: _univerjs_icons.H5Icon,
|
|
29305
30271
|
HeaderFooterIcon: _univerjs_icons.HeaderFooterIcon,
|
|
29306
30272
|
HorizontallyIcon: _univerjs_icons.HorizontallyIcon,
|
|
30273
|
+
InsertBelowDoubleIcon: _univerjs_icons.InsertBelowDoubleIcon,
|
|
29307
30274
|
InsertDoubleIcon: _univerjs_icons.InsertDoubleIcon,
|
|
29308
30275
|
InsertRowAboveDoubleIcon: _univerjs_icons.InsertRowAboveDoubleIcon,
|
|
29309
30276
|
InsertRowBelowDoubleIcon: _univerjs_icons.InsertRowBelowDoubleIcon,
|
|
@@ -29337,6 +30304,7 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
29337
30304
|
TodoListDoubleIcon: _univerjs_icons.TodoListDoubleIcon,
|
|
29338
30305
|
UnderlineIcon: _univerjs_icons.UnderlineIcon,
|
|
29339
30306
|
UnorderIcon: _univerjs_icons.UnorderIcon,
|
|
30307
|
+
ZoomInIcon: _univerjs_icons.ZoomInIcon,
|
|
29340
30308
|
DefaultTextColorIcon,
|
|
29341
30309
|
HeaderTextColorIcon,
|
|
29342
30310
|
MoreRightIcon: _univerjs_icons.MoreRightIcon,
|
|
@@ -29367,7 +30335,8 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
29367
30335
|
}));
|
|
29368
30336
|
}
|
|
29369
30337
|
_registerComponents() {
|
|
29370
|
-
|
|
30338
|
+
this.disposeWithMe(this._componentManager.register(DOC_HEADER_FOOTER_RIBBON_CONTROL, DocHeaderFooterRibbonControl));
|
|
30339
|
+
if (!this._componentManager.hasDefault("COMPONENT_DOC_HEADER_FOOTER_PANEL")) this.disposeWithMe(this._componentManager.register(COMPONENT_DOC_HEADER_FOOTER_PANEL, DocHeaderFooterPanel));
|
|
29371
30340
|
this.disposeWithMe(this._componentManager.register(paragraphSettingIndexKey, ParagraphSettingIndex));
|
|
29372
30341
|
this.disposeWithMe(this._componentManager.register(DOC_SECTION_SETTING_COMPONENT, SectionSettingIndex));
|
|
29373
30342
|
[
|
|
@@ -29385,6 +30354,43 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
29385
30354
|
};
|
|
29386
30355
|
ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
|
|
29387
30356
|
|
|
30357
|
+
//#endregion
|
|
30358
|
+
//#region src/controllers/doc-header-footer-ribbon.controller.ts
|
|
30359
|
+
let DocHeaderFooterRibbonController = class DocHeaderFooterRibbonController extends _univerjs_core.Disposable {
|
|
30360
|
+
constructor(_context, skeletonManager, _instanceService, _ribbonService, _renderManager) {
|
|
30361
|
+
super();
|
|
30362
|
+
this._context = _context;
|
|
30363
|
+
this._instanceService = _instanceService;
|
|
30364
|
+
this._ribbonService = _ribbonService;
|
|
30365
|
+
this._renderManager = _renderManager;
|
|
30366
|
+
_defineProperty(this, "_visible", false);
|
|
30367
|
+
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) => {
|
|
30368
|
+
if (visible === this._visible) return;
|
|
30369
|
+
this._visible = visible;
|
|
30370
|
+
if (visible) this._ribbonService.showContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB, { activate: true });
|
|
30371
|
+
else if (!this._focusedDocumentEditsHeaderFooter()) this._ribbonService.hideContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB);
|
|
30372
|
+
}));
|
|
30373
|
+
}
|
|
30374
|
+
_focusedDocumentEditsHeaderFooter() {
|
|
30375
|
+
var _this$_renderManager$;
|
|
30376
|
+
const focused = this._instanceService.getFocusedUnit();
|
|
30377
|
+
if (!focused || focused.type !== _univerjs_core.UniverInstanceType.UNIVER_DOC || focused.getUnitId() === this._context.unitId) return false;
|
|
30378
|
+
const manager = (_this$_renderManager$ = this._renderManager.getRenderUnitById(focused.getUnitId())) === null || _this$_renderManager$ === void 0 ? void 0 : _this$_renderManager$.with(_univerjs_docs.DocSkeletonManagerService);
|
|
30379
|
+
const area = manager === null || manager === void 0 ? void 0 : manager.getViewModel().getEditArea();
|
|
30380
|
+
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;
|
|
30381
|
+
}
|
|
30382
|
+
dispose() {
|
|
30383
|
+
if (this._visible && !this._focusedDocumentEditsHeaderFooter()) this._ribbonService.hideContextualTab(DOC_HEADER_FOOTER_RIBBON_TAB);
|
|
30384
|
+
super.dispose();
|
|
30385
|
+
}
|
|
30386
|
+
};
|
|
30387
|
+
DocHeaderFooterRibbonController = __decorate([
|
|
30388
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_docs.DocSkeletonManagerService)),
|
|
30389
|
+
__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
30390
|
+
__decorateParam(3, _univerjs_ui.IRibbonService),
|
|
30391
|
+
__decorateParam(4, _univerjs_engine_render.IRenderManagerService)
|
|
30392
|
+
], DocHeaderFooterRibbonController);
|
|
30393
|
+
|
|
29388
30394
|
//#endregion
|
|
29389
30395
|
//#region src/controllers/format-painter.controller.ts
|
|
29390
30396
|
let DocFormatPainterController = class DocFormatPainterController extends _univerjs_core.Disposable {
|
|
@@ -29452,6 +30458,83 @@ DocFormatPainterController = __decorate([
|
|
|
29452
30458
|
__decorateParam(7, _univerjs_core.ICommandService)
|
|
29453
30459
|
], DocFormatPainterController);
|
|
29454
30460
|
|
|
30461
|
+
//#endregion
|
|
30462
|
+
//#region src/controllers/render-controllers/doc-field.render-controller.ts
|
|
30463
|
+
let DocFieldRenderController = class DocFieldRenderController extends _univerjs_core.Disposable {
|
|
30464
|
+
constructor(_context, _events, _selections, theme, _instances) {
|
|
30465
|
+
super();
|
|
30466
|
+
this._context = _context;
|
|
30467
|
+
this._events = _events;
|
|
30468
|
+
this._selections = _selections;
|
|
30469
|
+
this._instances = _instances;
|
|
30470
|
+
_defineProperty(this, "_hovered", /* @__PURE__ */ new Set());
|
|
30471
|
+
_defineProperty(this, "_shade", "");
|
|
30472
|
+
const documents = this._context.mainComponent;
|
|
30473
|
+
this.disposeWithMe(theme.currentTheme$.subscribe(() => {
|
|
30474
|
+
this._shade = theme.getColorFromTheme("gray.200");
|
|
30475
|
+
documents.makeDirty(true);
|
|
30476
|
+
}));
|
|
30477
|
+
this.disposeWithMe(this._events.hoverCustomRanges$.subscribe((ranges) => {
|
|
30478
|
+
this._hovered = new Set(ranges.filter(({ range }) => range.rangeType === _univerjs_core.CustomRangeType.FIELD).map(({ range, segmentId, segmentPageIndex }) => `${segmentId ?? ""}:${segmentPageIndex}:${range.rangeId}`));
|
|
30479
|
+
documents.makeDirty(true);
|
|
30480
|
+
}));
|
|
30481
|
+
this.disposeWithMe(this._selections.textSelection$.subscribe(({ unitId }) => {
|
|
30482
|
+
if (unitId === this._context.unitId) documents.makeDirty(true);
|
|
30483
|
+
}));
|
|
30484
|
+
this.disposeWithMe(this._instances.focused$.subscribe(() => documents.makeDirty(true)));
|
|
30485
|
+
this.disposeWithMe(documents.getSkeleton().getViewModel().editAreaChange$.subscribe(() => documents.makeDirty(true)));
|
|
30486
|
+
this.disposeWithMe(documents.pageRender$.subscribe((config) => this._drawFields(config)));
|
|
30487
|
+
}
|
|
30488
|
+
_drawFields({ page, pageLeft, pageTop, ctx }) {
|
|
30489
|
+
var _this$_instances$getF;
|
|
30490
|
+
if (((_this$_instances$getF = this._instances.getFocusedUnit()) === null || _this$_instances$getF === void 0 ? void 0 : _this$_instances$getF.getUnitId()) !== this._context.unitId) return;
|
|
30491
|
+
const active = this._getActiveFields();
|
|
30492
|
+
if (!active.size) return;
|
|
30493
|
+
const documents = this._context.mainComponent;
|
|
30494
|
+
const skeleton = documents.getSkeleton();
|
|
30495
|
+
const pageIndex = skeleton.getSkeletonData().pages.indexOf(page);
|
|
30496
|
+
const { docsLeft, docsTop } = documents.getOffsetConfig();
|
|
30497
|
+
const area = skeleton.getViewModel().getEditArea();
|
|
30498
|
+
const snapshot = this._context.unit.getSnapshot();
|
|
30499
|
+
const activeSegments = area === _univerjs_engine_render.DocumentEditArea.HEADER ? snapshot.headers : snapshot.footers;
|
|
30500
|
+
ctx.save();
|
|
30501
|
+
ctx.beginPath();
|
|
30502
|
+
ctx.rect(pageLeft, pageTop, page.pageWidth, page.pageHeight);
|
|
30503
|
+
ctx.clip();
|
|
30504
|
+
ctx.fillStyle = this._shade;
|
|
30505
|
+
ctx.globalAlpha *= .45;
|
|
30506
|
+
for (const { customRange: field, segmentId, segmentPageIndex, rects } of this._events.getCustomRangeBounds()) {
|
|
30507
|
+
if (field.rangeType !== _univerjs_core.CustomRangeType.FIELD) continue;
|
|
30508
|
+
if (segmentId) {
|
|
30509
|
+
if (area === _univerjs_engine_render.DocumentEditArea.BODY || segmentPageIndex !== pageIndex || !(activeSegments === null || activeSegments === void 0 ? void 0 : activeSegments[segmentId])) continue;
|
|
30510
|
+
} else if (area !== _univerjs_engine_render.DocumentEditArea.BODY) continue;
|
|
30511
|
+
if (!active.has(`${segmentId ?? ""}:${segmentPageIndex}:${field.rangeId}`)) continue;
|
|
30512
|
+
for (const rect of rects) ctx.fillRect(rect.left - docsLeft, rect.top - docsTop, rect.right - rect.left, rect.bottom - rect.top);
|
|
30513
|
+
}
|
|
30514
|
+
ctx.restore();
|
|
30515
|
+
}
|
|
30516
|
+
_getActiveFields() {
|
|
30517
|
+
const active = new Set(this._hovered);
|
|
30518
|
+
const selections = this._selections.getTextRanges({
|
|
30519
|
+
unitId: this._context.unitId,
|
|
30520
|
+
subUnitId: this._context.unitId
|
|
30521
|
+
}) ?? [];
|
|
30522
|
+
for (const selection of selections) {
|
|
30523
|
+
var _this$_context$unit$g;
|
|
30524
|
+
const segmentId = selection.segmentId ?? "";
|
|
30525
|
+
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) ?? [];
|
|
30526
|
+
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}`);
|
|
30527
|
+
}
|
|
30528
|
+
return active;
|
|
30529
|
+
}
|
|
30530
|
+
};
|
|
30531
|
+
DocFieldRenderController = __decorate([
|
|
30532
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(DocEventManagerService)),
|
|
30533
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService)),
|
|
30534
|
+
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.ThemeService)),
|
|
30535
|
+
__decorateParam(4, _univerjs_core.IUniverInstanceService)
|
|
30536
|
+
], DocFieldRenderController);
|
|
30537
|
+
|
|
29455
30538
|
//#endregion
|
|
29456
30539
|
//#region src/controllers/render-controllers/doc-selection-render.controller.ts
|
|
29457
30540
|
let DocSelectionRenderController = class DocSelectionRenderController extends _univerjs_core.Disposable {
|
|
@@ -29776,6 +30859,32 @@ const CloseHeaderFooterShortcut = {
|
|
|
29776
30859
|
preconditions: whenDocAndEditorFocused,
|
|
29777
30860
|
binding: _univerjs_ui.KeyCode.ESC
|
|
29778
30861
|
};
|
|
30862
|
+
const DeleteWordLeftShortcut = {
|
|
30863
|
+
id: DeleteLeftCommand.id,
|
|
30864
|
+
preconditions: whenTextEditorFocused,
|
|
30865
|
+
binding: _univerjs_ui.KeyCode.BACKSPACE | _univerjs_ui.MetaKeys.CTRL_COMMAND,
|
|
30866
|
+
mac: _univerjs_ui.KeyCode.BACKSPACE | _univerjs_ui.MetaKeys.ALT,
|
|
30867
|
+
staticParameters: { granularity: "word" }
|
|
30868
|
+
};
|
|
30869
|
+
const DeleteWordRightShortcut = {
|
|
30870
|
+
id: DeleteRightCommand.id,
|
|
30871
|
+
preconditions: whenTextEditorFocused,
|
|
30872
|
+
mac: _univerjs_ui.KeyCode.DELETE | _univerjs_ui.MetaKeys.ALT,
|
|
30873
|
+
staticParameters: { granularity: "word" }
|
|
30874
|
+
};
|
|
30875
|
+
const DeleteLineStartShortcut = {
|
|
30876
|
+
id: DeleteLeftCommand.id,
|
|
30877
|
+
preconditions: whenTextEditorFocused,
|
|
30878
|
+
mac: _univerjs_ui.KeyCode.BACKSPACE | _univerjs_ui.MetaKeys.CTRL_COMMAND,
|
|
30879
|
+
staticParameters: { granularity: "line" }
|
|
30880
|
+
};
|
|
30881
|
+
const DeleteLineEndShortcut = {
|
|
30882
|
+
id: DeleteRightCommand.id,
|
|
30883
|
+
preconditions: whenTextEditorFocused,
|
|
30884
|
+
binding: _univerjs_ui.KeyCode.DELETE | _univerjs_ui.MetaKeys.CTRL_COMMAND,
|
|
30885
|
+
mac: _univerjs_ui.KeyCode.DELETE | _univerjs_ui.MetaKeys.MAC_CTRL,
|
|
30886
|
+
staticParameters: { granularity: "line" }
|
|
30887
|
+
};
|
|
29779
30888
|
|
|
29780
30889
|
//#endregion
|
|
29781
30890
|
//#region src/shortcuts/cursor.shortcut.ts
|
|
@@ -29786,7 +30895,7 @@ function moveCursorShortcut(direction, granularity, binding, mac = binding, win
|
|
|
29786
30895
|
mac,
|
|
29787
30896
|
win,
|
|
29788
30897
|
linux,
|
|
29789
|
-
preconditions:
|
|
30898
|
+
preconditions: whenTextEditorFocused,
|
|
29790
30899
|
staticParameters: {
|
|
29791
30900
|
direction,
|
|
29792
30901
|
granularity
|
|
@@ -29800,7 +30909,7 @@ function moveSelectionShortcut(direction, granularity, binding, mac = binding, w
|
|
|
29800
30909
|
mac,
|
|
29801
30910
|
win,
|
|
29802
30911
|
linux,
|
|
29803
|
-
preconditions:
|
|
30912
|
+
preconditions: whenTextEditorFocused,
|
|
29804
30913
|
staticParameters: {
|
|
29805
30914
|
direction,
|
|
29806
30915
|
granularity
|
|
@@ -30063,6 +31172,10 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
30063
31172
|
MoveSelectionWordRightShortcut,
|
|
30064
31173
|
SelectAllShortcut,
|
|
30065
31174
|
DeleteLeftShortcut,
|
|
31175
|
+
DeleteWordLeftShortcut,
|
|
31176
|
+
DeleteWordRightShortcut,
|
|
31177
|
+
DeleteLineStartShortcut,
|
|
31178
|
+
DeleteLineEndShortcut,
|
|
30066
31179
|
DeleteRightShortcut,
|
|
30067
31180
|
CloseHeaderFooterShortcut,
|
|
30068
31181
|
BreakLineShortcut,
|
|
@@ -30139,10 +31252,12 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
30139
31252
|
_initRenderModules() {
|
|
30140
31253
|
[
|
|
30141
31254
|
[DocEventManagerService],
|
|
31255
|
+
[DocFieldRenderController],
|
|
30142
31256
|
[DocFloatMenuService],
|
|
30143
31257
|
[DocPasteOptionsRenderController],
|
|
30144
31258
|
[DocParagraphMenuService],
|
|
30145
31259
|
[DocHeaderFooterController],
|
|
31260
|
+
[DocHeaderFooterRibbonController],
|
|
30146
31261
|
[DocResizeRenderController],
|
|
30147
31262
|
[DocParagraphPlaceholderRenderController],
|
|
30148
31263
|
[DocContextMenuRenderController],
|
|
@@ -30345,6 +31460,35 @@ const mobileButtonClassName = `
|
|
|
30345
31460
|
`;
|
|
30346
31461
|
const activeButtonClassName = "univer-bg-primary-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-400";
|
|
30347
31462
|
function MobileRichTextToolbar({ editorId, className }) {
|
|
31463
|
+
function resolveToolbarState(editor, defaultTextColor) {
|
|
31464
|
+
var _style$ul, _style$st, _style$cl;
|
|
31465
|
+
const body = editor === null || editor === void 0 ? void 0 : editor.getDocumentData().body;
|
|
31466
|
+
const ranges = (editor === null || editor === void 0 ? void 0 : editor.getSelectionRanges()) ?? [];
|
|
31467
|
+
const range = ranges.find((item) => item.isActive) ?? ranges[0];
|
|
31468
|
+
if (!body || !range) return {
|
|
31469
|
+
bold: false,
|
|
31470
|
+
italic: false,
|
|
31471
|
+
underline: false,
|
|
31472
|
+
strike: false,
|
|
31473
|
+
color: defaultTextColor,
|
|
31474
|
+
bulletList: false,
|
|
31475
|
+
orderList: false
|
|
31476
|
+
};
|
|
31477
|
+
const style = getStyleInTextRange(body, range, {});
|
|
31478
|
+
const listTypes = _univerjs_core.BuildTextUtils.range.getParagraphsInRanges([range], body.paragraphs ?? [], body.dataStream).map((paragraph) => {
|
|
31479
|
+
var _paragraph$bullet;
|
|
31480
|
+
return (_paragraph$bullet = paragraph.bullet) === null || _paragraph$bullet === void 0 ? void 0 : _paragraph$bullet.listType;
|
|
31481
|
+
}).filter((listType) => typeof listType === "string");
|
|
31482
|
+
return {
|
|
31483
|
+
bold: style.bl === _univerjs_core.BooleanNumber.TRUE,
|
|
31484
|
+
italic: style.it === _univerjs_core.BooleanNumber.TRUE,
|
|
31485
|
+
underline: ((_style$ul = style.ul) === null || _style$ul === void 0 ? void 0 : _style$ul.s) === _univerjs_core.BooleanNumber.TRUE,
|
|
31486
|
+
strike: ((_style$st = style.st) === null || _style$st === void 0 ? void 0 : _style$st.s) === _univerjs_core.BooleanNumber.TRUE,
|
|
31487
|
+
color: ((_style$cl = style.cl) === null || _style$cl === void 0 ? void 0 : _style$cl.rgb) ?? defaultTextColor,
|
|
31488
|
+
bulletList: Boolean(listTypes.length && listTypes.every((listType) => listType.startsWith(_univerjs_core.PresetListType.BULLET_LIST))),
|
|
31489
|
+
orderList: Boolean(listTypes.length && listTypes.every((listType) => listType.startsWith(_univerjs_core.PresetListType.ORDER_LIST)))
|
|
31490
|
+
};
|
|
31491
|
+
}
|
|
30348
31492
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
30349
31493
|
const editorService = (0, _univerjs_ui.useDependency)(IEditorService);
|
|
30350
31494
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
@@ -30358,12 +31502,11 @@ function MobileRichTextToolbar({ editorId, className }) {
|
|
|
30358
31502
|
return () => cancelAnimationFrame(frame);
|
|
30359
31503
|
}, [editorId, editorService]);
|
|
30360
31504
|
(0, react.useEffect)(() => {
|
|
30361
|
-
if (!editor) return
|
|
31505
|
+
if (!editor) return;
|
|
30362
31506
|
const subscription = (0, rxjs.merge)(editor.input$, editor.selectionChange$).subscribe(() => setRevision((value) => value + 1));
|
|
30363
31507
|
return () => subscription.unsubscribe();
|
|
30364
31508
|
}, [editor]);
|
|
30365
|
-
const
|
|
30366
|
-
const state = resolveToolbarState(editor, defaultTextColor);
|
|
31509
|
+
const state = resolveToolbarState(editor, themeService.getColorFromTheme("gray.900"));
|
|
30367
31510
|
const colors = COLOR_TOKENS.map((token) => themeService.getColorFromTheme(token));
|
|
30368
31511
|
async function execute(commandId, params) {
|
|
30369
31512
|
const activeEditor = editorService.getEditor(editorId);
|
|
@@ -30462,18 +31605,23 @@ function MobileRichTextToolbar({ editorId, className }) {
|
|
|
30462
31605
|
style: { backgroundColor: color },
|
|
30463
31606
|
onClick: () => execute(SetInlineFormatTextColorCommand.id, { value: color })
|
|
30464
31607
|
}, color)),
|
|
30465
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
30466
|
-
|
|
30467
|
-
|
|
30468
|
-
|
|
31608
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileDropdown, {
|
|
31609
|
+
overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
31610
|
+
className: "univer-px-4 univer-pb-2",
|
|
31611
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
31612
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileColorPicker, {
|
|
31613
|
+
value: state.color,
|
|
31614
|
+
onChange: (color) => execute(SetInlineFormatTextColorCommand.id, { value: color })
|
|
31615
|
+
})
|
|
31616
|
+
}),
|
|
31617
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
31618
|
+
type: "button",
|
|
31619
|
+
variant: "text",
|
|
31620
|
+
size: "icon",
|
|
30469
31621
|
"aria-label": localeService.t("docs-ui.toolbar.textColor.main"),
|
|
30470
|
-
className: "univer-
|
|
30471
|
-
|
|
30472
|
-
|
|
30473
|
-
onChange: (event) => {
|
|
30474
|
-
execute(SetInlineFormatTextColorCommand.id, { value: event.target.value });
|
|
30475
|
-
}
|
|
30476
|
-
})]
|
|
31622
|
+
className: "univer-size-7 univer-justify-self-center",
|
|
31623
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.ColorWheelMultiIcon, { className: "!univer-size-6" })
|
|
31624
|
+
})
|
|
30477
31625
|
})
|
|
30478
31626
|
]
|
|
30479
31627
|
})
|
|
@@ -30492,35 +31640,6 @@ function FormatButton(props) {
|
|
|
30492
31640
|
})
|
|
30493
31641
|
});
|
|
30494
31642
|
}
|
|
30495
|
-
function resolveToolbarState(editor, defaultTextColor) {
|
|
30496
|
-
var _style$ul, _style$st, _style$cl;
|
|
30497
|
-
const body = editor === null || editor === void 0 ? void 0 : editor.getDocumentData().body;
|
|
30498
|
-
const ranges = (editor === null || editor === void 0 ? void 0 : editor.getSelectionRanges()) ?? [];
|
|
30499
|
-
const range = ranges.find((item) => item.isActive) ?? ranges[0];
|
|
30500
|
-
if (!body || !range) return {
|
|
30501
|
-
bold: false,
|
|
30502
|
-
italic: false,
|
|
30503
|
-
underline: false,
|
|
30504
|
-
strike: false,
|
|
30505
|
-
color: defaultTextColor,
|
|
30506
|
-
bulletList: false,
|
|
30507
|
-
orderList: false
|
|
30508
|
-
};
|
|
30509
|
-
const style = getStyleInTextRange(body, range, {});
|
|
30510
|
-
const listTypes = _univerjs_core.BuildTextUtils.range.getParagraphsInRanges([range], body.paragraphs ?? [], body.dataStream).map((paragraph) => {
|
|
30511
|
-
var _paragraph$bullet;
|
|
30512
|
-
return (_paragraph$bullet = paragraph.bullet) === null || _paragraph$bullet === void 0 ? void 0 : _paragraph$bullet.listType;
|
|
30513
|
-
}).filter((listType) => typeof listType === "string");
|
|
30514
|
-
return {
|
|
30515
|
-
bold: style.bl === _univerjs_core.BooleanNumber.TRUE,
|
|
30516
|
-
italic: style.it === _univerjs_core.BooleanNumber.TRUE,
|
|
30517
|
-
underline: ((_style$ul = style.ul) === null || _style$ul === void 0 ? void 0 : _style$ul.s) === _univerjs_core.BooleanNumber.TRUE,
|
|
30518
|
-
strike: ((_style$st = style.st) === null || _style$st === void 0 ? void 0 : _style$st.s) === _univerjs_core.BooleanNumber.TRUE,
|
|
30519
|
-
color: ((_style$cl = style.cl) === null || _style$cl === void 0 ? void 0 : _style$cl.rgb) ?? defaultTextColor,
|
|
30520
|
-
bulletList: Boolean(listTypes.length && listTypes.every((listType) => listType.startsWith(_univerjs_core.PresetListType.BULLET_LIST))),
|
|
30521
|
-
orderList: Boolean(listTypes.length && listTypes.every((listType) => listType.startsWith(_univerjs_core.PresetListType.ORDER_LIST)))
|
|
30522
|
-
};
|
|
30523
|
-
}
|
|
30524
31643
|
|
|
30525
31644
|
//#endregion
|
|
30526
31645
|
//#region src/views/rich-text-editor/hooks/editor-undo-redo-keyboard.ts
|
|
@@ -31289,26 +32408,26 @@ exports.DeleteCurrentParagraphCommand = DeleteCurrentParagraphCommand;
|
|
|
31289
32408
|
exports.DeleteCustomBlockCommand = DeleteCustomBlockCommand;
|
|
31290
32409
|
exports.DeleteLeftCommand = DeleteLeftCommand;
|
|
31291
32410
|
exports.DeleteRightCommand = DeleteRightCommand;
|
|
31292
|
-
Object.defineProperty(exports,
|
|
32411
|
+
Object.defineProperty(exports, "DocAutoFormatService", {
|
|
31293
32412
|
enumerable: true,
|
|
31294
32413
|
get: function () {
|
|
31295
32414
|
return DocAutoFormatService;
|
|
31296
32415
|
}
|
|
31297
32416
|
});
|
|
31298
|
-
Object.defineProperty(exports,
|
|
32417
|
+
Object.defineProperty(exports, "DocBackScrollRenderController", {
|
|
31299
32418
|
enumerable: true,
|
|
31300
32419
|
get: function () {
|
|
31301
32420
|
return DocBackScrollRenderController;
|
|
31302
32421
|
}
|
|
31303
32422
|
});
|
|
31304
|
-
Object.defineProperty(exports,
|
|
32423
|
+
Object.defineProperty(exports, "DocCanvasPopManagerService", {
|
|
31305
32424
|
enumerable: true,
|
|
31306
32425
|
get: function () {
|
|
31307
32426
|
return DocCanvasPopManagerService;
|
|
31308
32427
|
}
|
|
31309
32428
|
});
|
|
31310
32429
|
exports.DocClipboardPasteAdapterService = DocClipboardPasteAdapterService;
|
|
31311
|
-
Object.defineProperty(exports,
|
|
32430
|
+
Object.defineProperty(exports, "DocContextualRibbonService", {
|
|
31312
32431
|
enumerable: true,
|
|
31313
32432
|
get: function () {
|
|
31314
32433
|
return DocContextualRibbonService;
|
|
@@ -31317,13 +32436,13 @@ Object.defineProperty(exports, 'DocContextualRibbonService', {
|
|
|
31317
32436
|
exports.DocCopyCommand = DocCopyCommand;
|
|
31318
32437
|
exports.DocCreateTableOperation = DocCreateTableOperation;
|
|
31319
32438
|
exports.DocCutCommand = DocCutCommand;
|
|
31320
|
-
Object.defineProperty(exports,
|
|
32439
|
+
Object.defineProperty(exports, "DocEventManagerService", {
|
|
31321
32440
|
enumerable: true,
|
|
31322
32441
|
get: function () {
|
|
31323
32442
|
return DocEventManagerService;
|
|
31324
32443
|
}
|
|
31325
32444
|
});
|
|
31326
|
-
Object.defineProperty(exports,
|
|
32445
|
+
Object.defineProperty(exports, "DocFloatMenuService", {
|
|
31327
32446
|
enumerable: true,
|
|
31328
32447
|
get: function () {
|
|
31329
32448
|
return DocFloatMenuService;
|
|
@@ -31332,25 +32451,25 @@ Object.defineProperty(exports, 'DocFloatMenuService', {
|
|
|
31332
32451
|
exports.DocHtmlExportService = DocHtmlExportService;
|
|
31333
32452
|
exports.DocIMEInputManagerService = DocIMEInputManagerService;
|
|
31334
32453
|
exports.DocLayoutInteractionService = DocLayoutInteractionService;
|
|
31335
|
-
Object.defineProperty(exports,
|
|
32454
|
+
Object.defineProperty(exports, "DocMobileElementMenuService", {
|
|
31336
32455
|
enumerable: true,
|
|
31337
32456
|
get: function () {
|
|
31338
32457
|
return DocMobileElementMenuService;
|
|
31339
32458
|
}
|
|
31340
32459
|
});
|
|
31341
|
-
Object.defineProperty(exports,
|
|
32460
|
+
Object.defineProperty(exports, "DocPageLayoutService", {
|
|
31342
32461
|
enumerable: true,
|
|
31343
32462
|
get: function () {
|
|
31344
32463
|
return DocPageLayoutService;
|
|
31345
32464
|
}
|
|
31346
32465
|
});
|
|
31347
|
-
Object.defineProperty(exports,
|
|
32466
|
+
Object.defineProperty(exports, "DocParagraphMenuService", {
|
|
31348
32467
|
enumerable: true,
|
|
31349
32468
|
get: function () {
|
|
31350
32469
|
return DocParagraphMenuService;
|
|
31351
32470
|
}
|
|
31352
32471
|
});
|
|
31353
|
-
Object.defineProperty(exports,
|
|
32472
|
+
Object.defineProperty(exports, "DocParagraphPlaceholderRenderController", {
|
|
31354
32473
|
enumerable: true,
|
|
31355
32474
|
get: function () {
|
|
31356
32475
|
return DocParagraphPlaceholderRenderController;
|
|
@@ -31358,14 +32477,14 @@ Object.defineProperty(exports, 'DocParagraphPlaceholderRenderController', {
|
|
|
31358
32477
|
});
|
|
31359
32478
|
exports.DocPasteCommand = DocPasteCommand;
|
|
31360
32479
|
exports.DocPrintInterceptorService = DocPrintInterceptorService;
|
|
31361
|
-
Object.defineProperty(exports,
|
|
32480
|
+
Object.defineProperty(exports, "DocRenderController", {
|
|
31362
32481
|
enumerable: true,
|
|
31363
32482
|
get: function () {
|
|
31364
32483
|
return DocRenderController;
|
|
31365
32484
|
}
|
|
31366
32485
|
});
|
|
31367
32486
|
exports.DocSelectAllCommand = DocSelectAllCommand;
|
|
31368
|
-
Object.defineProperty(exports,
|
|
32487
|
+
Object.defineProperty(exports, "DocSelectionRenderService", {
|
|
31369
32488
|
enumerable: true,
|
|
31370
32489
|
get: function () {
|
|
31371
32490
|
return DocSelectionRenderService;
|
|
@@ -31381,19 +32500,19 @@ exports.DocTableInsertRowAboveCommand = DocTableInsertRowAboveCommand;
|
|
|
31381
32500
|
exports.DocTableInsertRowBellowCommand = DocTableInsertRowBellowCommand;
|
|
31382
32501
|
exports.DocTableInsertRowCommand = DocTableInsertRowCommand;
|
|
31383
32502
|
exports.DocTableTabCommand = DocTableTabCommand;
|
|
31384
|
-
Object.defineProperty(exports,
|
|
32503
|
+
Object.defineProperty(exports, "DocUIController", {
|
|
31385
32504
|
enumerable: true,
|
|
31386
32505
|
get: function () {
|
|
31387
32506
|
return DocUIController;
|
|
31388
32507
|
}
|
|
31389
32508
|
});
|
|
31390
|
-
Object.defineProperty(exports,
|
|
32509
|
+
Object.defineProperty(exports, "DocViewScaleService", {
|
|
31391
32510
|
enumerable: true,
|
|
31392
32511
|
get: function () {
|
|
31393
32512
|
return DocViewScaleService;
|
|
31394
32513
|
}
|
|
31395
32514
|
});
|
|
31396
|
-
Object.defineProperty(exports,
|
|
32515
|
+
Object.defineProperty(exports, "DocsRenderService", {
|
|
31397
32516
|
enumerable: true,
|
|
31398
32517
|
get: function () {
|
|
31399
32518
|
return DocsRenderService;
|
|
@@ -31402,7 +32521,7 @@ Object.defineProperty(exports, 'DocsRenderService', {
|
|
|
31402
32521
|
exports.DocsUIMenuSchema = menuSchema;
|
|
31403
32522
|
exports.EMPTY_PARAGRAPH_MENU_ID = EMPTY_PARAGRAPH_MENU_ID;
|
|
31404
32523
|
exports.Editor = Editor;
|
|
31405
|
-
Object.defineProperty(exports,
|
|
32524
|
+
Object.defineProperty(exports, "EditorService", {
|
|
31406
32525
|
enumerable: true,
|
|
31407
32526
|
get: function () {
|
|
31408
32527
|
return EditorService;
|
|
@@ -31440,6 +32559,7 @@ exports.NodePositionConvertToRectRange = NodePositionConvertToRectRange;
|
|
|
31440
32559
|
exports.OrderListCommand = OrderListCommand;
|
|
31441
32560
|
exports.OrderListTypePicker = OrderListTypePicker;
|
|
31442
32561
|
exports.ParagraphMenuInsertBelowSubmenuItemFactory = ParagraphMenuInsertBelowSubmenuItemFactory;
|
|
32562
|
+
exports.ParagraphSettingMenuFactory = ParagraphSettingMenuFactory;
|
|
31443
32563
|
exports.PastePluginLark = LarkPastePlugin;
|
|
31444
32564
|
exports.PastePluginUniver = UniverPastePlugin;
|
|
31445
32565
|
exports.PastePluginWord = WordPastePlugin;
|
|
@@ -31475,13 +32595,13 @@ exports.TextColorSelectorMenuItemFactory = TextColorSelectorMenuItemFactory;
|
|
|
31475
32595
|
exports.TextRange = TextRange;
|
|
31476
32596
|
exports.ToggleCheckListCommand = ToggleCheckListCommand;
|
|
31477
32597
|
exports.UnderlineMenuItemFactory = UnderlineMenuItemFactory;
|
|
31478
|
-
Object.defineProperty(exports,
|
|
32598
|
+
Object.defineProperty(exports, "UniverDocsMobileUIPlugin", {
|
|
31479
32599
|
enumerable: true,
|
|
31480
32600
|
get: function () {
|
|
31481
32601
|
return UniverDocsMobileUIPlugin;
|
|
31482
32602
|
}
|
|
31483
32603
|
});
|
|
31484
|
-
Object.defineProperty(exports,
|
|
32604
|
+
Object.defineProperty(exports, "UniverDocsUIPlugin", {
|
|
31485
32605
|
enumerable: true,
|
|
31486
32606
|
get: function () {
|
|
31487
32607
|
return UniverDocsUIPlugin;
|
|
@@ -31509,7 +32629,12 @@ exports.drawDocCustomRangeChrome = drawDocCustomRangeChrome;
|
|
|
31509
32629
|
exports.executeEditorUndoRedoCommand = executeEditorUndoRedoCommand;
|
|
31510
32630
|
exports.findDocRangeNodePositions = findDocRangeNodePositions;
|
|
31511
32631
|
exports.genTableSource = genTableSource;
|
|
31512
|
-
exports
|
|
32632
|
+
Object.defineProperty(exports, "generateParagraphs", {
|
|
32633
|
+
enumerable: true,
|
|
32634
|
+
get: function () {
|
|
32635
|
+
return _univerjs_docs.generateParagraphs;
|
|
32636
|
+
}
|
|
32637
|
+
});
|
|
31513
32638
|
exports.getAnchorBounding = getAnchorBounding;
|
|
31514
32639
|
exports.getCanvasOffsetByEngine = getCanvasOffsetByEngine;
|
|
31515
32640
|
exports.getCommandSkeleton = getCommandSkeleton;
|